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_file.c
Go to the documentation of this file.
1 /*
2  * Remmina - The GTK+ Remote Desktop Client
3  * Copyright (C) 2014-2021 Antenore Gatta, Giovanni Panozzo, Mathias Winterhalter (ToolsDevler)
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 
35 // I N C L U D E S
37 
41 #include "remmina_file.h"
42 
44 // D E C L A R A T I O N S
46 
48 // A P I
50 
52 {
53  TRACE_CALL(__func__);
54 }
55 
57 {
58  TRACE_CALL(__func__);
59 
60  PyObject* result = NULL;
61 
62  PyPlugin* plugin = remmina_plugin_python_get_plugin(instance->name);
63 
64  if (plugin)
65  {
66  result = CallPythonMethod(plugin->instance, "import_test_func", "s", from_file);
67  }
68 
69  return result == Py_None || result != Py_False;
70 }
71 
73 {
74  TRACE_CALL(__func__);
75 
76  PyObject* result = NULL;
77 
78  PyPlugin* plugin = remmina_plugin_python_get_plugin(instance->name);
79  if (!plugin)
80  {
81  return NULL;
82  }
83 
84  result = CallPythonMethod(plugin->instance, "import_func", "s", from_file);
85 
86  if (result == Py_None || result == Py_False)
87  {
88  return NULL;
89  }
90 
91  return ((PyRemminaFile*)result)->file;
92 }
93 
95 {
96  TRACE_CALL(__func__);
97 
98  PyObject* result = NULL;
99 
100  PyPlugin* plugin = remmina_plugin_python_get_plugin(instance->name);
101  if (plugin)
102  {
103  result = CallPythonMethod(plugin->instance,
104  "export_test_func",
105  "O",
107  }
108 
109  return result == Py_None || result != Py_False;
110 }
111 
112 gboolean
114 {
115  TRACE_CALL(__func__);
116 
117  PyObject* result = NULL;
118 
119  PyPlugin* plugin = remmina_plugin_python_get_plugin(instance->name);
120  if (plugin)
121  {
122  result = CallPythonMethod(plugin->instance, "export_func", "s", to_file);
123  }
124 
125  return result == Py_None || result != Py_False;
126 }
127 
129 {
130  TRACE_CALL(__func__);
131 
132  PyObject* instance = plugin->instance;
133  Py_IncRef(instance);
134 
136  {
137  g_printerr("Unable to create file plugin. Aborting!\n");
138  return NULL;
139  }
140 
142 
143  remmina_plugin->type = REMMINA_PLUGIN_TYPE_FILE;
144  remmina_plugin->domain = GETTEXT_PACKAGE;
145  remmina_plugin->name = PyUnicode_AsUTF8(PyObject_GetAttrString(instance, ATTR_NAME));
146  remmina_plugin->version = PyUnicode_AsUTF8(PyObject_GetAttrString(instance, ATTR_VERSION));
147  remmina_plugin->description = PyUnicode_AsUTF8(PyObject_GetAttrString(instance, ATTR_DESCRIPTION));
148  remmina_plugin->export_hints = PyUnicode_AsUTF8(PyObject_GetAttrString(instance, ATTR_EXPORT_HINTS));
149 
154 
155  plugin->file_plugin = remmina_plugin;
156  plugin->generic_plugin = (RemminaPlugin*)remmina_plugin;
157 
159 
160  return (RemminaPlugin*)remmina_plugin;
161 }
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...
Maps an instance of a Python plugin to a Remmina one.
typedefG_BEGIN_DECLS struct _RemminaFile RemminaFile
Definition: types.h:44
const char * ATTR_EXPORT_HINTS
const gchar * export_hints
Definition: plugin.h:109
RemminaFile *(* import_func)(struct _RemminaFilePlugin *instance, const gchar *from_file)
Definition: plugin.h:106
static RemminaProtocolPlugin remmina_plugin
Definition: exec_plugin.c:280
gboolean remmina_plugin_python_file_export_test_func_wrapper(RemminaFilePlugin *instance, RemminaFile *file)
RemminaFilePlugin * file_plugin
const gchar * domain
Definition: plugin.h:102
PyPlugin * remmina_plugin_python_get_plugin(const char *name)
Tries to find the Python plugin matching to the given instance of RemminaPlugin.
void remmina_plugin_python_file_init(void)
Initializes the Python plugin specialisation for file plugins.
RemminaPlugin * remmina_plugin_python_create_file_plugin(PyPlugin *plugin)
Creates a new instance of the RemminaPluginFile, initializes its members and references the wrapper f...
const char * ATTR_DESCRIPTION
gboolean(* export_test_func)(struct _RemminaFilePlugin *instance, RemminaFile *file)
Definition: plugin.h:107
gboolean remmina_plugin_python_file_import_test_func_wrapper(RemminaFilePlugin *instance, const gchar *from_file)
RemminaPlugin * generic_plugin
const gchar * name
Definition: plugin.h:100
gboolean remmina_plugin_python_file_export_func_wrapper(RemminaFilePlugin *instance, RemminaFile *file, const gchar *to_file)
void remmina_plugin_python_add_plugin(PyPlugin *plugin)
Registers the given plugin if no other plugin with the same name has been already registered...
const gchar * version
Definition: plugin.h:103
gboolean remmina_plugin_python_check_attribute(PyObject *instance, const char *attr_name)
Checks if a given attribute exists.
const char * ATTR_NAME
Wrapper for a Python object that contains a pointer to an instance of RemminaFile.
RemminaPluginType type
Definition: plugin.h:99
gboolean(* import_test_func)(struct _RemminaFilePlugin *instance, const gchar *from_file)
Definition: plugin.h:105
const gchar * description
Definition: plugin.h:101
Contains functions and constants that are commonly used throughout the Python plugin implementation...
RemminaFile * remmina_plugin_python_file_import_func_wrapper(RemminaFilePlugin *instance, const gchar *from_file)
gboolean(* export_func)(struct _RemminaFilePlugin *instance, RemminaFile *file, const gchar *to_file)
Definition: plugin.h:108
void * remmina_plugin_python_malloc(int bytes)
Allocates memory and checks for errors before returning.
Contains the specialisation of RemminaPluginFile plugins in Python.
const char * ATTR_VERSION