Remmina - The GTK+ Remote Desktop Client  v1.4.25
Remmina is a remote desktop client written in GTK+, aiming to be useful for system administrators and travellers, who need to work with lots of remote computers in front of either large monitors or tiny netbooks. Remmina supports multiple network protocols in an integrated and consistent user interface. Currently RDP, VNC, NX, XDMCP and SSH are supported.
remmina_plugin_python_protocol_widget.c
Go to the documentation of this file.
1 /*
2  * Remmina - The GTK+ Remote Desktop Client
3  * Copyright (C) 2014-2022 Antenore Gatta, Giovanni Panozzo
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  * In addition, as a special exception, the copyright holders give
21  * permission to link the code of portions of this program with the
22  * OpenSSL library under certain conditions as described in each
23  * individual source file, and distribute linked combinations
24  * including the two.
25  * You must obey the GNU General Public License in all respects
26  * for all of the code used other than OpenSSL. * If you modify
27  * file(s) with this exception, you may extend this exception to your
28  * version of the file(s), but you are not obligated to do so. * If you
29  * do not wish to do so, delete this exception statement from your
30  * version. * If you delete this exception statement from all source
31  * files in the program, then also delete it here.
32  */
33 
85 // I N L U C E S
88 
90 #include "remmina/plugin.h"
92 #include "remmina/types.h"
96 
97 // -- Python Type -> RemminaWidget
98 
100 // D E C L A R A T I O N S
102 
103 static PyObject* protocol_widget_get_viewport(PyRemminaProtocolWidget* self, PyObject* args);
104 static PyObject* protocol_widget_get_width(PyRemminaProtocolWidget* self, PyObject* args);
105 static PyObject* protocol_widget_set_width(PyRemminaProtocolWidget* self, PyObject* var_width);
106 static PyObject* protocol_widget_get_height(PyRemminaProtocolWidget* self, PyObject* args);
107 static PyObject* protocol_widget_set_height(PyRemminaProtocolWidget* self, PyObject* var_height);
108 static PyObject* protocol_widget_get_current_scale_mode(PyRemminaProtocolWidget* self, PyObject* args);
109 static PyObject* protocol_widget_get_expand(PyRemminaProtocolWidget* self, PyObject* args);
110 static PyObject* protocol_widget_set_expand(PyRemminaProtocolWidget* self, PyObject* var_expand);
111 static PyObject* protocol_widget_has_error(PyRemminaProtocolWidget* self, PyObject* args);
112 static PyObject* protocol_widget_set_error(PyRemminaProtocolWidget* self, PyObject* var_msg);
113 static PyObject* protocol_widget_is_closed(PyRemminaProtocolWidget* self, PyObject* args);
114 static PyObject* protocol_widget_get_file(PyRemminaProtocolWidget* self, PyObject* args);
115 static PyObject* protocol_widget_emit_signal(PyRemminaProtocolWidget* self, PyObject* var_signal);
116 static PyObject* protocol_widget_register_hostkey(PyRemminaProtocolWidget* self, PyObject* var_widget);
117 static PyObject* protocol_widget_start_direct_tunnel(PyRemminaProtocolWidget* self, PyObject* args);
118 static PyObject* protocol_widget_start_reverse_tunnel(PyRemminaProtocolWidget* self, PyObject* var_local_port);
119 static PyObject* protocol_widget_start_xport_tunnel(PyRemminaProtocolWidget* self, PyObject* args);
120 static PyObject* protocol_widget_set_display(PyRemminaProtocolWidget* self, PyObject* var_display);
121 static PyObject* protocol_widget_signal_connection_closed(PyRemminaProtocolWidget* self, PyObject* args);
122 static PyObject* protocol_widget_signal_connection_opened(PyRemminaProtocolWidget* self, PyObject* args);
123 static PyObject* protocol_widget_update_align(PyRemminaProtocolWidget* self, PyObject* args);
124 static PyObject* protocol_widget_unlock_dynres(PyRemminaProtocolWidget* self, PyObject* args);
125 static PyObject* protocol_widget_desktop_resize(PyRemminaProtocolWidget* self, PyObject* args);
126 static PyObject* protocol_widget_panel_new_certificate(PyRemminaProtocolWidget* self, PyObject* args);
127 static PyObject* protocol_widget_panel_changed_certificate(PyRemminaProtocolWidget* self, PyObject* args);
128 static PyObject* protocol_widget_get_username(PyRemminaProtocolWidget* self, PyObject* args);
129 static PyObject* protocol_widget_get_password(PyRemminaProtocolWidget* self, PyObject* args);
130 static PyObject* protocol_widget_get_domain(PyRemminaProtocolWidget* self, PyObject* args);
131 static PyObject* protocol_widget_get_savepassword(PyRemminaProtocolWidget* self, PyObject* args);
132 static PyObject* protocol_widget_panel_authx509(PyRemminaProtocolWidget* self, PyObject* args);
133 static PyObject* protocol_widget_get_cacert(PyRemminaProtocolWidget* self, PyObject* args);
134 static PyObject* protocol_widget_get_cacrl(PyRemminaProtocolWidget* self, PyObject* args);
135 static PyObject* protocol_widget_get_clientcert(PyRemminaProtocolWidget* self, PyObject* args);
136 static PyObject* protocol_widget_get_clientkey(PyRemminaProtocolWidget* self, PyObject* args);
137 static PyObject* protocol_widget_save_cred(PyRemminaProtocolWidget* self, PyObject* args);
138 static PyObject* protocol_widget_panel_show_listen(PyRemminaProtocolWidget* self, PyObject* args);
139 static PyObject* protocol_widget_panel_show_retry(PyRemminaProtocolWidget* self, PyObject* args);
140 static PyObject* protocol_widget_panel_show(PyRemminaProtocolWidget* self, PyObject* args);
141 static PyObject* protocol_widget_panel_hide(PyRemminaProtocolWidget* self, PyObject* args);
142 static PyObject* protocol_widget_ssh_exec(PyRemminaProtocolWidget* self, PyObject* args);
143 static PyObject* protocol_widget_chat_open(PyRemminaProtocolWidget* self, PyObject* var_name);
144 static PyObject* protocol_widget_chat_close(PyRemminaProtocolWidget* self, PyObject* args);
145 static PyObject* protocol_widget_chat_receive(PyRemminaProtocolWidget* self, PyObject* args);
146 static PyObject* protocol_widget_send_keys_signals(PyRemminaProtocolWidget* self, PyObject* args);
147 
148 static struct PyMethodDef python_protocol_widget_type_methods[] =
149  {{ "get_viewport", (PyCFunction)protocol_widget_get_viewport, METH_NOARGS, "" },
150  { "get_width", (PyCFunction)protocol_widget_get_width, METH_NOARGS, "" },
151  { "set_width", (PyCFunction)protocol_widget_set_width, METH_VARARGS, "" },
152  { "get_height", (PyCFunction)protocol_widget_get_height, METH_VARARGS, "" },
153  { "set_height", (PyCFunction)protocol_widget_set_height, METH_VARARGS, "" },
154  { "get_current_scale_mode", (PyCFunction)protocol_widget_get_current_scale_mode, METH_VARARGS, "" },
155  { "get_expand", (PyCFunction)protocol_widget_get_expand, METH_VARARGS, "" },
156  { "set_expand", (PyCFunction)protocol_widget_set_expand, METH_VARARGS, "" },
157  { "has_error", (PyCFunction)protocol_widget_has_error, METH_VARARGS, "" },
158  { "set_error", (PyCFunction)protocol_widget_set_error, METH_VARARGS, "" },
159  { "is_closed", (PyCFunction)protocol_widget_is_closed, METH_VARARGS, "" },
160  { "get_file", (PyCFunction)protocol_widget_get_file, METH_NOARGS, "" },
161  { "emit_signal", (PyCFunction)protocol_widget_emit_signal, METH_VARARGS, "" },
162  { "register_hostkey", (PyCFunction)protocol_widget_register_hostkey, METH_VARARGS, "" },
163  { "start_direct_tunnel", (PyCFunction)protocol_widget_start_direct_tunnel, METH_VARARGS | METH_KEYWORDS, "" },
164  { "start_reverse_tunnel", (PyCFunction)protocol_widget_start_reverse_tunnel, METH_VARARGS, "" },
165  { "start_xport_tunnel", (PyCFunction)protocol_widget_start_xport_tunnel, METH_VARARGS, "" },
166  { "set_display", (PyCFunction)protocol_widget_set_display, METH_VARARGS, "" },
167  { "signal_connection_closed", (PyCFunction)protocol_widget_signal_connection_closed, METH_VARARGS, "" },
168  { "signal_connection_opened", (PyCFunction)protocol_widget_signal_connection_opened, METH_VARARGS, "" },
169  { "update_align", (PyCFunction)protocol_widget_update_align, METH_VARARGS, "" },
170  { "unlock_dynres", (PyCFunction)protocol_widget_unlock_dynres, METH_VARARGS, "" },
171  { "desktop_resize", (PyCFunction)protocol_widget_desktop_resize, METH_VARARGS, "" },
172  { "panel_new_certificate", (PyCFunction)protocol_widget_panel_new_certificate, METH_VARARGS | METH_KEYWORDS, "" },
173  { "panel_changed_certificate", (PyCFunction)protocol_widget_panel_changed_certificate,
174  METH_VARARGS | METH_KEYWORDS, "" },
175  { "get_username", (PyCFunction)protocol_widget_get_username, METH_VARARGS, "" },
176  { "get_password", (PyCFunction)protocol_widget_get_password, METH_VARARGS, "" },
177  { "get_domain", (PyCFunction)protocol_widget_get_domain, METH_VARARGS, "" },
178  { "get_savepassword", (PyCFunction)protocol_widget_get_savepassword, METH_VARARGS, "" },
179  { "panel_authx509", (PyCFunction)protocol_widget_panel_authx509, METH_VARARGS, "" },
180  { "get_cacert", (PyCFunction)protocol_widget_get_cacert, METH_VARARGS, "" },
181  { "get_cacrl", (PyCFunction)protocol_widget_get_cacrl, METH_VARARGS, "" },
182  { "get_clientcert", (PyCFunction)protocol_widget_get_clientcert, METH_VARARGS, "" },
183  { "get_clientkey", (PyCFunction)protocol_widget_get_clientkey, METH_VARARGS, "" },
184  { "save_cred", (PyCFunction)protocol_widget_save_cred, METH_VARARGS, "" },
185  { "panel_show_listen", (PyCFunction)protocol_widget_panel_show_listen, METH_VARARGS, "" },
186  { "panel_show_retry", (PyCFunction)protocol_widget_panel_show_retry, METH_VARARGS, "" },
187  { "panel_show", (PyCFunction)protocol_widget_panel_show, METH_VARARGS, "" },
188  { "panel_hide", (PyCFunction)protocol_widget_panel_hide, METH_VARARGS, "" },
189  { "ssh_exec", (PyCFunction)protocol_widget_ssh_exec, METH_VARARGS | METH_KEYWORDS, "" },
190  { "chat_open", (PyCFunction)protocol_widget_chat_open, METH_VARARGS, "" },
191  { "chat_close", (PyCFunction)protocol_widget_chat_close, METH_VARARGS, "" },
192  { "chat_receive", (PyCFunction)protocol_widget_chat_receive, METH_VARARGS, "" },
193  { "send_keys_signals", (PyCFunction)protocol_widget_send_keys_signals, METH_VARARGS | METH_KEYWORDS, "" },
194  { NULL }};
195 
197 // A P I
199 
200 static PyObject* python_protocol_feature_new(PyTypeObject* type, PyObject* kws, PyObject* args)
201 {
202  TRACE_CALL(__func__);
204  self = (PyRemminaProtocolWidget*)type->tp_alloc(type, 0);
205  if (!self)
206  {
207  return NULL;
208  }
209 
210  return (PyObject*)self;
211 }
212 
213 static int python_protocol_feature_init(PyObject* self, PyObject* args, PyObject* kwds)
214 {
215  return 0;
216 }
217 
218 static PyTypeObject python_protocol_widget_type = {
219  PyVarObject_HEAD_INIT(NULL, 0)
220  .tp_name = "remmina.RemminaProtocolWidget",
221  .tp_doc = "RemminaProtocolWidget",
222  .tp_basicsize = sizeof(PyRemminaProtocolWidget),
223  .tp_itemsize = 0,
224  .tp_flags = Py_TPFLAGS_DEFAULT,
225  .tp_new = python_protocol_feature_new,
226  .tp_init = python_protocol_feature_init,
228 };
229 
231 {
232  TRACE_CALL(__func__);
233 
235  assert(result);
236 
237  PyErr_Print();
238  Py_INCREF(result);
239  result->gp = NULL;
240  return result;
241 }
242 
244 {
245  init_pygobject();
246 }
247 
249 {
250  TRACE_CALL(__func__);
251  if (PyType_Ready(&python_protocol_widget_type) < 0)
252  {
253  g_printerr("Error initializing remmina.RemminaWidget!\n");
254  PyErr_Print();
255  }
256 }
257 
258 static PyObject* protocol_widget_get_viewport(PyRemminaProtocolWidget* self, PyObject* args)
259 {
260  TRACE_CALL(__func__);
261  SELF_CHECK();
262  return (PyObject*)new_pywidget(G_OBJECT(remmina_protocol_widget_gtkviewport(self->gp)));
263 }
264 
265 static PyObject* protocol_widget_get_width(PyRemminaProtocolWidget* self, PyObject* args)
266 {
267  TRACE_CALL(__func__);
268  SELF_CHECK();
269 
270  return Py_BuildValue("i", remmina_protocol_widget_get_width(self->gp));
271 }
272 
273 static PyObject* protocol_widget_set_width(PyRemminaProtocolWidget* self, PyObject* var_width)
274 {
275  TRACE_CALL(__func__);
276  SELF_CHECK();
277 
278  if (!var_width)
279  {
280  g_printerr("[%s:%d@%s]: Argument is null!\n", __FILE__, __LINE__, __func__);
281  return NULL;
282  }
283 
284  if (PyLong_Check(var_width))
285  {
286  g_printerr("[%s:%d@%s]: Argument is not of type Long!\n", __FILE__, __LINE__, __func__);
287  return NULL;
288  }
289 
290  gint width = (gint)PyLong_AsLong(var_width);
291  remmina_protocol_widget_set_height(self->gp, width);
292 
293  return Py_None;
294 }
295 
296 static PyObject* protocol_widget_get_height(PyRemminaProtocolWidget* self, PyObject* args)
297 {
298  TRACE_CALL(__func__);
299  SELF_CHECK();
300 
301  return Py_BuildValue("i", remmina_protocol_widget_get_height(self->gp));
302 }
303 
304 static PyObject* protocol_widget_set_height(PyRemminaProtocolWidget* self, PyObject* var_height)
305 {
306  TRACE_CALL(__func__);
307  SELF_CHECK();
308 
309  if (!var_height)
310  {
311  g_printerr("[%s:%d@%s]: Argument is null!\n", __FILE__, __LINE__, __func__);
312  return NULL;
313  }
314 
315  if (PyLong_Check(var_height))
316  {
317  g_printerr("[%s:%d@%s]: Argument is not of type Long!\n", __FILE__, __LINE__, __func__);
318  return NULL;
319  }
320 
321  gint height = (gint)PyLong_AsLong(var_height);
322  remmina_protocol_widget_set_height(self->gp, height);
323 
324  return Py_None;
325 }
326 
328 {
329  TRACE_CALL(__func__);
330  SELF_CHECK();
331 
332  return Py_BuildValue("i", remmina_protocol_widget_get_current_scale_mode(self->gp));
333 }
334 
335 static PyObject* protocol_widget_get_expand(PyRemminaProtocolWidget* self, PyObject* args)
336 {
337  TRACE_CALL(__func__);
338  SELF_CHECK();
339 
340  return Py_BuildValue("p", remmina_protocol_widget_get_expand(self->gp));
341 }
342 
343 static PyObject* protocol_widget_set_expand(PyRemminaProtocolWidget* self, PyObject* var_expand)
344 {
345  TRACE_CALL(__func__);
346  SELF_CHECK();
347 
348  if (!var_expand)
349  {
350  g_printerr("[%s:%d@%s]: Argument is null!\n", __FILE__, __LINE__, __func__);
351  return NULL;
352  }
353 
354  if (PyBool_Check(var_expand))
355  {
356  g_printerr("[%s:%d@%s]: Argument is not of type Boolean!\n", __FILE__, __LINE__, __func__);
357  return NULL;
358  }
359 
360  remmina_protocol_widget_set_expand(self->gp, PyObject_IsTrue(var_expand));
361 
362  return Py_None;
363 }
364 
365 static PyObject* protocol_widget_has_error(PyRemminaProtocolWidget* self, PyObject* args)
366 {
367  TRACE_CALL(__func__);
368  SELF_CHECK();
369 
370  return Py_BuildValue("p", remmina_protocol_widget_has_error(self->gp));
371 }
372 
373 static PyObject* protocol_widget_set_error(PyRemminaProtocolWidget* self, PyObject* var_msg)
374 {
375  TRACE_CALL(__func__);
376  SELF_CHECK();
377 
378  if (!var_msg)
379  {
380  g_printerr("[%s:%d@%s]: Argument is null!\n", __FILE__, __LINE__, __func__);
381  return NULL;
382  }
383 
384  if (PyUnicode_Check(var_msg))
385  {
386  g_printerr("[%s:%d@%s]: Argument is not of type String!\n", __FILE__, __LINE__, __func__);
387  return NULL;
388  }
389 
390  const gchar* msg = PyUnicode_AsUTF8(var_msg);
391  remmina_protocol_widget_set_error(self->gp, msg);
392 
393  return Py_None;
394 }
395 
396 static PyObject* protocol_widget_is_closed(PyRemminaProtocolWidget* self, PyObject* args)
397 {
398  TRACE_CALL(__func__);
399  SELF_CHECK();
400 
401  return Py_BuildValue("p", remmina_protocol_widget_is_closed(self->gp));
402 }
403 
404 static PyObject* protocol_widget_get_file(PyRemminaProtocolWidget* self, PyObject* args)
405 {
406  TRACE_CALL(__func__);
407  SELF_CHECK();
408 
410  return (PyObject*)remmina_plugin_python_remmina_file_to_python(file);
411 }
412 
413 static PyObject* protocol_widget_emit_signal(PyRemminaProtocolWidget* self, PyObject* var_signal)
414 {
415  TRACE_CALL(__func__);
416  SELF_CHECK();
417 
418  if (!var_signal)
419  {
420  g_printerr("[%s:%d@%s]: Argument is null!\n", __FILE__, __LINE__, __func__);
421  return NULL;
422  }
423 
424  if (PyUnicode_Check(var_signal))
425  {
426  g_printerr("[%s:%d@%s]: Argument is not of type String!\n", __FILE__, __LINE__, __func__);
427  return NULL;
428  }
429 
430  remmina_protocol_widget_set_error(self->gp, PyUnicode_AsUTF8(var_signal));
431 
432  return Py_None;
433 }
434 
435 static PyObject* protocol_widget_register_hostkey(PyRemminaProtocolWidget* self, PyObject* var_widget)
436 {
437  TRACE_CALL(__func__);
438  SELF_CHECK();
439 
440  if (!var_widget)
441  {
442  g_printerr("[%s:%d@%s]: Argument is null!\n", __FILE__, __LINE__, __func__);
443  return NULL;
444  }
445 
447 
448  return Py_None;
449 }
450 
451 static PyObject* protocol_widget_start_direct_tunnel(PyRemminaProtocolWidget* self, PyObject* args)
452 {
453  TRACE_CALL(__func__);
454  SELF_CHECK();
455 
456  gint default_port;
457  gboolean port_plus;
458 
459  if (!args)
460  {
461  g_printerr("[%s:%d@%s]: Argument is null!\n", __FILE__, __LINE__, __func__);
462  }
463 
464  if (PyArg_ParseTuple(args, "ii", &default_port, &port_plus))
465  {
466  return Py_BuildValue("s", remmina_protocol_widget_start_direct_tunnel(self->gp, default_port, port_plus));
467  }
468  else
469  {
470  PyErr_Print();
471  return NULL;
472  }
473  return Py_None;
474 }
475 
476 static PyObject* protocol_widget_start_reverse_tunnel(PyRemminaProtocolWidget* self, PyObject* var_local_port)
477 {
478  TRACE_CALL(__func__);
479  SELF_CHECK();
480 
481  if (!PyLong_Check(var_local_port))
482  {
483  g_printerr("[%s:%d@%s]: Argument is null!\n", __FILE__, __LINE__, __func__);
484  return NULL;
485  }
486 
487  if (!PyLong_Check(var_local_port))
488  {
489  g_printerr("[%s:%d@%s]: Argument is not of type Long!\n", __FILE__, __LINE__, __func__);
490  return NULL;
491  }
492 
493  return Py_BuildValue("p", remmina_protocol_widget_start_reverse_tunnel(self->gp, (gint)PyLong_AsLong(var_local_port)));
494 }
495 
496 static gboolean xport_tunnel_init(RemminaProtocolWidget* gp, gint remotedisplay, const gchar* server, gint port)
497 {
498  TRACE_CALL(__func__);
500  PyObject* result = PyObject_CallMethod(plugin->instance, "xport_tunnel_init", "Oisi", gp, remotedisplay, server, port);
501  return PyObject_IsTrue(result);
502 }
503 
504 static PyObject* protocol_widget_start_xport_tunnel(PyRemminaProtocolWidget* self, PyObject* args)
505 {
506  TRACE_CALL(__func__);
507  SELF_CHECK();
508 
509  return Py_BuildValue("p", remmina_protocol_widget_start_xport_tunnel(self->gp, xport_tunnel_init));
510 }
511 
512 static PyObject* protocol_widget_set_display(PyRemminaProtocolWidget* self, PyObject* var_display)
513 {
514  TRACE_CALL(__func__);
515  SELF_CHECK();
516 
517  if (!var_display)
518  {
519  g_printerr("[%s:%d@%s]: Argument is null!\n", __FILE__, __LINE__, __func__);
520  return NULL;
521  }
522 
523  if (!PyLong_Check(var_display))
524  {
525  g_printerr("[%s:%d@%s]: Argument is not of type Long!\n", __FILE__, __LINE__, __func__);
526  return NULL;
527  }
528 
529  remmina_protocol_widget_set_display(self->gp, (gint)PyLong_AsLong(var_display));
530 
531  return Py_None;
532 }
533 
535 {
536  TRACE_CALL(__func__);
537  SELF_CHECK();
538 
540  return Py_None;
541 }
542 
544 {
545  TRACE_CALL(__func__);
546  SELF_CHECK();
547 
549  return Py_None;
550 }
551 
552 static PyObject* protocol_widget_update_align(PyRemminaProtocolWidget* self, PyObject* args)
553 {
554  TRACE_CALL(__func__);
555  SELF_CHECK();
556 
558  return Py_None;
559 }
560 
561 static PyObject* protocol_widget_unlock_dynres(PyRemminaProtocolWidget* self, PyObject* args)
562 {
563  TRACE_CALL(__func__);
564  SELF_CHECK();
565 
567  return Py_None;
568 }
569 
570 static PyObject* protocol_widget_desktop_resize(PyRemminaProtocolWidget* self, PyObject* args)
571 {
572  TRACE_CALL(__func__);
573  SELF_CHECK();
574 
576  return Py_None;
577 }
578 
579 static PyObject* protocol_widget_panel_new_certificate(PyRemminaProtocolWidget* self, PyObject* args)
580 {
581  TRACE_CALL(__func__);
582  SELF_CHECK();
583  gchar* subject, * issuer, * fingerprint;
584 
585  if (PyArg_ParseTuple(args, "sss", &subject, &issuer, &fingerprint))
586  {
587  remmina_protocol_widget_panel_new_certificate(self->gp, subject, issuer, fingerprint);
588  }
589  else
590  {
591  PyErr_Print();
592  return NULL;
593  }
594  return Py_None;
595 }
596 
598 {
599  TRACE_CALL(__func__);
600  SELF_CHECK();
601  gchar* subject, * issuer, * new_fingerprint, * old_fingerprint;
602 
603  if (PyArg_ParseTuple(args, "sss", &subject, &issuer, &new_fingerprint, &old_fingerprint))
604  {
605  remmina_protocol_widget_panel_changed_certificate(self->gp, subject, issuer, new_fingerprint, old_fingerprint);
606  }
607  else
608  {
609  PyErr_Print();
610  return NULL;
611  }
612  return Py_None;
613 }
614 
615 static PyObject* protocol_widget_get_username(PyRemminaProtocolWidget* self, PyObject* args)
616 {
617  TRACE_CALL(__func__);
618  SELF_CHECK();
619 
620  return Py_BuildValue("s", remmina_protocol_widget_get_username(self->gp));
621 }
622 
623 static PyObject* protocol_widget_get_password(PyRemminaProtocolWidget* self, PyObject* args)
624 {
625  TRACE_CALL(__func__);
626  SELF_CHECK();
627 
628  return Py_BuildValue("s", remmina_protocol_widget_get_password(self->gp));
629 }
630 
631 static PyObject* protocol_widget_get_domain(PyRemminaProtocolWidget* self, PyObject* args)
632 {
633  TRACE_CALL(__func__);
634  SELF_CHECK();
635 
636  return Py_BuildValue("s", remmina_protocol_widget_get_domain(self->gp));
637 }
638 
639 static PyObject* protocol_widget_get_savepassword(PyRemminaProtocolWidget* self, PyObject* args)
640 {
641  TRACE_CALL(__func__);
642  SELF_CHECK();
643 
644  return Py_BuildValue("p", remmina_protocol_widget_get_savepassword(self->gp));
645 }
646 
647 static PyObject* protocol_widget_panel_authx509(PyRemminaProtocolWidget* self, PyObject* args)
648 {
649  TRACE_CALL(__func__);
650  SELF_CHECK();
651 
652  return Py_BuildValue("i", remmina_protocol_widget_panel_authx509(self->gp));
653 }
654 
655 static PyObject* protocol_widget_get_cacert(PyRemminaProtocolWidget* self, PyObject* args)
656 {
657  TRACE_CALL(__func__);
658  SELF_CHECK();
659 
660  return Py_BuildValue("s", remmina_protocol_widget_get_cacert(self->gp));
661 }
662 
663 static PyObject* protocol_widget_get_cacrl(PyRemminaProtocolWidget* self, PyObject* args)
664 {
665  TRACE_CALL(__func__);
666  SELF_CHECK();
667 
668  return Py_BuildValue("s", remmina_protocol_widget_get_cacrl(self->gp));
669 }
670 
671 static PyObject* protocol_widget_get_clientcert(PyRemminaProtocolWidget* self, PyObject* args)
672 {
673  TRACE_CALL(__func__);
674  SELF_CHECK();
675 
676  return Py_BuildValue("s", remmina_protocol_widget_get_clientcert(self->gp));
677 }
678 
679 static PyObject* protocol_widget_get_clientkey(PyRemminaProtocolWidget* self, PyObject* args)
680 {
681  TRACE_CALL(__func__);
682  SELF_CHECK();
683 
684  return Py_BuildValue("s", remmina_protocol_widget_get_clientkey(self->gp));
685 }
686 
687 static PyObject* protocol_widget_save_cred(PyRemminaProtocolWidget* self, PyObject* args)
688 {
689  TRACE_CALL(__func__);
690  SELF_CHECK();
691 
693  return Py_None;
694 }
695 
696 static PyObject* protocol_widget_panel_show_listen(PyRemminaProtocolWidget* self, PyObject* args)
697 {
698  TRACE_CALL(__func__);
699  SELF_CHECK();
700  gint port = 0;
701 
702  if (PyArg_ParseTuple(args, "i", &port))
703  {
705  }
706  else
707  {
708  PyErr_Print();
709  return NULL;
710  }
711  return Py_None;
712 }
713 
714 static PyObject* protocol_widget_panel_show_retry(PyRemminaProtocolWidget* self, PyObject* args)
715 {
716  TRACE_CALL(__func__);
717  SELF_CHECK();
718 
720  return Py_None;
721 }
722 
723 static PyObject* protocol_widget_panel_show(PyRemminaProtocolWidget* self, PyObject* args)
724 {
725  TRACE_CALL(__func__);
726  SELF_CHECK();
727 
729  return Py_None;
730 }
731 
732 static PyObject* protocol_widget_panel_hide(PyRemminaProtocolWidget* self, PyObject* args)
733 {
734  TRACE_CALL(__func__);
735  SELF_CHECK();
736 
738  return Py_None;
739 }
740 
741 static PyObject* protocol_widget_ssh_exec(PyRemminaProtocolWidget* self, PyObject* args)
742 {
743  TRACE_CALL(__func__);
744  SELF_CHECK();
745  gboolean wait;
746  gchar* cmd;
747 
748  if (PyArg_ParseTuple(args, "ps", &wait, &cmd))
749  {
750  remmina_protocol_widget_ssh_exec(self->gp, wait, cmd);
751  }
752  else
753  {
754  PyErr_Print();
755  return NULL;
756  }
757  return Py_None;
758 }
759 
760 static void _on_send_callback_wrapper(RemminaProtocolWidget* gp, const gchar* text)
761 {
763  PyObject_CallMethod(plugin->instance, "on_send", "Os", gp, text);
764 }
765 
767 {
769  PyObject_CallMethod(plugin->instance, "on_destroy", "O", gp);
770 }
771 
772 static PyObject* protocol_widget_chat_open(PyRemminaProtocolWidget* self, PyObject* var_name)
773 {
774  TRACE_CALL(__func__);
775  SELF_CHECK();
776 
777  if (!PyUnicode_Check(var_name))
778  {
779  g_printerr("[%s:%d@%s]: Argument is not of type String!\n", __FILE__, __LINE__, __func__);
780  }
781 
783  PyUnicode_AsUTF8(var_name),
786 
787  return Py_None;
788 }
789 
790 static PyObject* protocol_widget_chat_close(PyRemminaProtocolWidget* self, PyObject* args)
791 {
792  TRACE_CALL(__func__);
793  SELF_CHECK();
794 
796  return Py_None;
797 }
798 
799 static PyObject* protocol_widget_chat_receive(PyRemminaProtocolWidget* self, PyObject* args)
800 {
801  TRACE_CALL(__func__);
802  SELF_CHECK();
803  gchar* text;
804 
805  if (PyArg_ParseTuple(args, "s", &text))
806  {
807  remmina_protocol_widget_chat_receive(self->gp, text);
808  }
809  else
810  {
811  PyErr_Print();
812  return NULL;
813  }
814 
815  return Py_None;
816 }
817 
818 static PyObject* protocol_widget_send_keys_signals(PyRemminaProtocolWidget* self, PyObject* args)
819 {
820  TRACE_CALL(__func__);
821  SELF_CHECK();
822  guint* keyvals;
823  int length;
824  GdkEventType event_type;
825  PyObject* widget;
826 
827  if (PyArg_ParseTuple(args, "Osii", &widget, &keyvals, &length, &event_type) && widget && keyvals)
828  {
829  if (event_type < GDK_NOTHING || event_type >= GDK_EVENT_LAST)
830  {
831  g_printerr("[%s:%d@%s]: %d is not a known value for GdkEventType!\n", __FILE__, __LINE__, __func__, event_type);
832  return NULL;
833  }
834  else
835  {
836  remmina_protocol_widget_send_keys_signals((GtkWidget*)widget, keyvals, length, event_type);
837  }
838  }
839  else
840  {
841  PyErr_Print();
842  return NULL;
843  }
844 
845  return Py_None;
846 }
gboolean remmina_protocol_widget_get_expand(RemminaProtocolWidget *gp)
static PyObject * protocol_widget_chat_open(PyRemminaProtocolWidget *self, PyObject *var_name)
void remmina_protocol_widget_panel_show(RemminaProtocolWidget *gp)
void remmina_protocol_widget_set_error(RemminaProtocolWidget *gp, const gchar *fmt,...)
void remmina_protocol_widget_panel_hide(RemminaProtocolWidget *gp)
gchar * remmina_protocol_widget_start_direct_tunnel(RemminaProtocolWidget *gp, gint default_port, gboolean port_plus)
Start an SSH tunnel if possible and return the host:port string.
static PyObject * protocol_widget_panel_new_certificate(PyRemminaProtocolWidget *self, PyObject *args)
static PyObject * protocol_widget_set_error(PyRemminaProtocolWidget *self, PyObject *var_msg)
PyRemminaFile * remmina_plugin_python_remmina_file_to_python(RemminaFile *file)
Converts the instance of RemminaFile to a Python object that can be passed to the Python engine...
static PyObject * protocol_widget_get_expand(PyRemminaProtocolWidget *self, PyObject *args)
void remmina_protocol_widget_chat_receive(RemminaProtocolWidget *gp, const gchar *text)
static PyObject * protocol_widget_panel_hide(PyRemminaProtocolWidget *self, PyObject *args)
gint remmina_protocol_widget_get_width(RemminaProtocolWidget *gp)
static PyObject * protocol_widget_panel_authx509(PyRemminaProtocolWidget *self, PyObject *args)
void init_pygobject()
Initializes the pygobject library.
void remmina_protocol_widget_save_cred(RemminaProtocolWidget *gp)
gboolean remmina_protocol_widget_get_savepassword(RemminaProtocolWidget *gp)
GtkWidget * remmina_protocol_widget_gtkviewport(RemminaProtocolWidget *gp)
Maps an instance of a Python plugin to a Remmina one.
static PyObject * python_protocol_feature_new(PyTypeObject *type, PyObject *kws, PyObject *args)
typedefG_BEGIN_DECLS struct _RemminaFile RemminaFile
Definition: types.h:44
gboolean remmina_protocol_widget_has_error(RemminaProtocolWidget *gp)
void remmina_protocol_widget_register_hostkey(RemminaProtocolWidget *gp, GtkWidget *widget)
gboolean remmina_protocol_widget_start_reverse_tunnel(RemminaProtocolWidget *gp, gint local_port)
gchar * remmina_protocol_widget_get_domain(RemminaProtocolWidget *gp)
static PyObject * protocol_widget_get_viewport(PyRemminaProtocolWidget *self, PyObject *args)
static PyTypeObject python_protocol_widget_type
PyObject_HEAD RemminaProtocolWidget * gp
static PyObject * protocol_widget_get_cacert(PyRemminaProtocolWidget *self, PyObject *args)
static PyObject * protocol_widget_get_savepassword(PyRemminaProtocolWidget *self, PyObject *args)
static PyObject * protocol_widget_panel_show_retry(PyRemminaProtocolWidget *self, PyObject *args)
static PyObject * protocol_widget_panel_show(PyRemminaProtocolWidget *self, PyObject *args)
static PyObject * protocol_widget_get_clientkey(PyRemminaProtocolWidget *self, PyObject *args)
gchar * remmina_protocol_widget_get_cacert(RemminaProtocolWidget *gp)
gint remmina_protocol_widget_get_height(RemminaProtocolWidget *gp)
RemminaScaleMode remmina_protocol_widget_get_current_scale_mode(RemminaProtocolWidget *gp)
void remmina_protocol_widget_update_align(RemminaProtocolWidget *gp)
PyPlugin * remmina_plugin_python_get_plugin(const char *name)
Tries to find the Python plugin matching to the given instance of RemminaPlugin.
gint remmina_protocol_widget_panel_authx509(RemminaProtocolWidget *gp)
GtkWidget * get_pywidget(PyObject *obj)
Extracts a GtkWidget from a PyObject instance.
static PyObject * protocol_widget_get_clientcert(PyRemminaProtocolWidget *self, PyObject *args)
static PyObject * protocol_widget_signal_connection_opened(PyRemminaProtocolWidget *self, PyObject *args)
PyRemminaProtocolWidget * remmina_plugin_python_protocol_widget_create(void)
Creates a new instance of PyRemminaProtocolWidget and initializes its fields.
Contains the specialisation of RemminaPluginFile plugins in Python.
static PyObject * protocol_widget_get_current_scale_mode(PyRemminaProtocolWidget *self, PyObject *args)
static PyObject * protocol_widget_set_expand(PyRemminaProtocolWidget *self, PyObject *var_expand)
void remmina_protocol_widget_set_display(RemminaProtocolWidget *gp, gint display)
static PyObject * protocol_widget_register_hostkey(PyRemminaProtocolWidget *self, PyObject *var_widget)
void remmina_protocol_widget_panel_show_listen(RemminaProtocolWidget *gp, gint port)
static PyObject * protocol_widget_signal_connection_closed(PyRemminaProtocolWidget *self, PyObject *args)
static PyObject * protocol_widget_set_height(PyRemminaProtocolWidget *self, PyObject *var_height)
void remmina_protocol_widget_signal_connection_closed(RemminaProtocolWidget *gp)
static PyObject * protocol_widget_panel_show_listen(PyRemminaProtocolWidget *self, PyObject *args)
void remmina_protocol_widget_desktop_resize(RemminaProtocolWidget *gp)
RemminaProtocolPlugin * plugin
gint remmina_protocol_widget_panel_changed_certificate(RemminaProtocolWidget *gp, const gchar *subject, const gchar *issuer, const gchar *new_fingerprint, const gchar *old_fingerprint)
gchar * remmina_protocol_widget_get_clientcert(RemminaProtocolWidget *gp)
void remmina_protocol_widget_unlock_dynres(RemminaProtocolWidget *gp)
static PyObject * protocol_widget_get_username(PyRemminaProtocolWidget *self, PyObject *args)
static PyObject * protocol_widget_desktop_resize(PyRemminaProtocolWidget *self, PyObject *args)
void remmina_plugin_python_protocol_widget_type_ready(void)
Initializes Python types used for protocol widgets.
static struct PyMethodDef python_protocol_widget_type_methods[]
void remmina_protocol_widget_panel_show_retry(RemminaProtocolWidget *gp)
static PyObject * protocol_widget_get_domain(PyRemminaProtocolWidget *self, PyObject *args)
static void _on_destroy_callback_wrapper(RemminaProtocolWidget *gp)
gint remmina_protocol_widget_panel_new_certificate(RemminaProtocolWidget *gp, const gchar *subject, const gchar *issuer, const gchar *fingerprint)
static PyObject * protocol_widget_set_width(PyRemminaProtocolWidget *self, PyObject *var_width)
gboolean remmina_protocol_widget_ssh_exec(RemminaProtocolWidget *gp, gboolean wait, const gchar *fmt,...)
gchar * remmina_protocol_widget_get_cacrl(RemminaProtocolWidget *gp)
static PyObject * protocol_widget_chat_close(PyRemminaProtocolWidget *self, PyObject *args)
void remmina_plugin_python_protocol_widget_init(void)
Initializes the widget backend of the protocol plugin implementation.
static PyObject * protocol_widget_get_password(PyRemminaProtocolWidget *self, PyObject *args)
void remmina_protocol_widget_set_height(RemminaProtocolWidget *gp, gint height)
static PyObject * protocol_widget_save_cred(PyRemminaProtocolWidget *self, PyObject *args)
static void _on_send_callback_wrapper(RemminaProtocolWidget *gp, const gchar *text)
static PyObject * protocol_widget_start_direct_tunnel(PyRemminaProtocolWidget *self, PyObject *args)
static PyObject * protocol_widget_unlock_dynres(PyRemminaProtocolWidget *self, PyObject *args)
gboolean remmina_protocol_widget_is_closed(RemminaProtocolWidget *gp)
gchar * remmina_protocol_widget_get_clientkey(RemminaProtocolWidget *gp)
static PyObject * protocol_widget_get_height(PyRemminaProtocolWidget *self, PyObject *args)
static PyObject * protocol_widget_get_cacrl(PyRemminaProtocolWidget *self, PyObject *args)
static PyObject * protocol_widget_set_display(PyRemminaProtocolWidget *self, PyObject *var_display)
static PyObject * protocol_widget_is_closed(PyRemminaProtocolWidget *self, PyObject *args)
gboolean remmina_protocol_widget_start_xport_tunnel(RemminaProtocolWidget *gp, RemminaXPortTunnelInitFunc init_func)
The Python abstraction of the protocol widget struct.
static PyObject * protocol_widget_get_file(PyRemminaProtocolWidget *self, PyObject *args)
void remmina_protocol_widget_signal_connection_opened(RemminaProtocolWidget *gp)
static PyObject * protocol_widget_panel_changed_certificate(PyRemminaProtocolWidget *self, PyObject *args)
Contains functions and constants that are commonly used throughout the Python plugin implementation...
static int python_protocol_feature_init(PyObject *self, PyObject *args, PyObject *kwds)
const gchar * name
Definition: plugin.h:65
gchar * remmina_protocol_widget_get_password(RemminaProtocolWidget *gp)
static PyObject * protocol_widget_emit_signal(PyRemminaProtocolWidget *self, PyObject *var_signal)
static PyObject * protocol_widget_start_xport_tunnel(PyRemminaProtocolWidget *self, PyObject *args)
static PyObject * protocol_widget_start_reverse_tunnel(PyRemminaProtocolWidget *self, PyObject *var_local_port)
static PyObject * protocol_widget_has_error(PyRemminaProtocolWidget *self, PyObject *args)
static PyObject * protocol_widget_get_width(PyRemminaProtocolWidget *self, PyObject *args)
void remmina_protocol_widget_set_expand(RemminaProtocolWidget *gp, gboolean expand)
void remmina_protocol_widget_send_keys_signals(GtkWidget *widget, const guint *keyvals, int keyvals_length, GdkEventType action)
GtkWidget * new_pywidget(GObject *obj)
Creates a new GtkWidget.
static PyObject * protocol_widget_send_keys_signals(PyRemminaProtocolWidget *self, PyObject *args)
static PyObject * protocol_widget_update_align(PyRemminaProtocolWidget *self, PyObject *args)
RemminaFile * remmina_protocol_widget_get_file(RemminaProtocolWidget *gp)
static PyObject * protocol_widget_ssh_exec(PyRemminaProtocolWidget *self, PyObject *args)
static gboolean xport_tunnel_init(RemminaProtocolWidget *gp, gint remotedisplay, const gchar *server, gint port)
void remmina_protocol_widget_chat_open(RemminaProtocolWidget *gp, const gchar *name, void(*on_send)(RemminaProtocolWidget *gp, const gchar *text), void(*on_destroy)(RemminaProtocolWidget *gp))
Contains the implementation of the widget handling used from the protocol plugin. ...
static PyObject * protocol_widget_chat_receive(PyRemminaProtocolWidget *self, PyObject *args)
gchar * remmina_protocol_widget_get_username(RemminaProtocolWidget *gp)