66 py_plugin->
gp->
gp = gp;
67 CallPythonMethod(py_plugin->
instance,
"init",
"O", py_plugin->
gp);
76 PyObject* result = CallPythonMethod(py_plugin->
instance,
"open_connection",
"O", py_plugin->
gp);
77 return result == Py_True;
89 PyObject* result = CallPythonMethod(py_plugin->
instance,
"close_connection",
"O", py_plugin->
gp);
90 return result == Py_True;
99 pyFeature->
type = (gint)feature->
type;
100 pyFeature->
id = feature->
id;
108 PyObject* result = CallPythonMethod(py_plugin->
instance,
"query_feature",
"OO", py_plugin->
gp, pyFeature);
109 Py_DecRef((PyObject*)pyFeature);
110 Py_DecRef((PyObject*)pyFeature->opt1);
111 Py_DecRef((PyObject*)pyFeature->opt2);
112 Py_DecRef((PyObject*)pyFeature->opt3);
113 return result == Py_True;
118 TRACE_CALL(__func__);
121 pyFeature->
type = (gint)feature->
type;
122 pyFeature->
id = feature->
id;
133 CallPythonMethod(py_plugin->
instance,
"call_feature",
"OO", py_plugin->
gp, pyFeature);
134 Py_DecRef((PyObject*)pyFeature);
135 Py_DecRef((PyObject*)pyFeature->opt1);
136 Py_DecRef((PyObject*)pyFeature->opt2);
137 Py_DecRef((PyObject*)pyFeature->opt3);
141 const guint keystrokes[],
144 TRACE_CALL(__func__);
146 PyObject* obj = PyList_New(keylen);
148 for (
int i = 0; i < keylen; ++i)
150 PyList_SetItem(obj, i, PyLong_FromLong(keystrokes[i]));
152 CallPythonMethod(py_plugin->
instance,
"send_keystrokes",
"OO", py_plugin->
gp, obj);
159 TRACE_CALL(__func__);
163 Py_IncRef((PyObject*)data);
164 PyObject* result = CallPythonMethod(py_plugin->
instance,
"get_plugin_screenshot",
"OO", py_plugin->
gp, data);
165 if (result == Py_True)
167 if (!PyByteArray_Check((PyObject*)data->buffer))
169 g_printerr(
"Unable to parse screenshot data. 'buffer' needs to be an byte array!");
172 Py_ssize_t buffer_len = PyByteArray_Size((PyObject*)data->buffer);
180 memcpy(rpsd->
buffer, PyByteArray_AsString((PyObject*)data->buffer),
sizeof(
unsigned char) * buffer_len);
183 rpsd->
height = data->height;
184 rpsd->
width = data->width;
186 Py_DecRef((PyObject*)data->buffer);
187 Py_DecRef((PyObject*)data);
188 return result == Py_True;
194 PyObject* result = CallPythonMethod(plugin->
instance,
"map_event",
"O", plugin->
gp);
195 return PyBool_Check(result) && result == Py_True;
201 PyObject* result = CallPythonMethod(plugin->
instance,
"unmap_event",
"O", plugin->
gp);
202 return PyBool_Check(result) && result == Py_True;
207 PyObject* instance = plugin->
instance;
216 g_printerr(
"Unable to create protocol plugin. Aborting!\n");
223 remmina_plugin->
domain = GETTEXT_PACKAGE;
228 remmina_plugin->
name = PyUnicode_AsUTF8(PyObject_GetAttrString(instance,
ATTR_NAME));
230 remmina_plugin->
version = PyUnicode_AsUTF8(PyObject_GetAttrString(instance,
ATTR_VERSION));
234 PyObject* list = PyObject_GetAttrString(instance,
"basic_settings");
235 Py_ssize_t len = PyList_Size(list);
242 for (Py_ssize_t i = 0; i < len; ++i)
252 list = PyObject_GetAttrString(instance,
"advanced_settings");
253 len = PyList_Size(list);
260 for (Py_ssize_t i = 0; i < len; ++i)
272 list = PyObject_GetAttrString(instance,
"features");
273 len = PyList_Size(list);
280 for (Py_ssize_t i = 0; i < len; ++i)
289 remmina_plugin->
features = features;
PyPlugin * python_wrapper_get_plugin_by_protocol_widget(RemminaProtocolWidget *gp)
Tries to find the Python plugin matching to the given instance of RemminaPlugin.
PyObject_HEAD RemminaProtocolFeatureType type
void(* call_feature)(RemminaProtocolWidget *gp, const RemminaProtocolFeature *feature)
PyRemminaPluginScreenshotData * python_wrapper_screenshot_data_new(void)
void remmina_protocol_init_wrapper(RemminaProtocolWidget *gp)
Wrapper for a Python object that contains a pointer to an instance of RemminaProtocolFeature.
void python_wrapper_to_protocol_setting(RemminaProtocolSetting *dest, PyObject *setting)
Converts the PyObject to RemminaProtocolSetting.
Maps an instance of a Python plugin to a Remmina one.
gboolean python_wrapper_check_attribute(PyObject *instance, const char *attr_name)
Checks if a given attribute exists.
RemminaProtocolSSHSetting ssh_setting
gboolean remmina_protocol_get_plugin_screenshot_wrapper(RemminaProtocolWidget *gp, RemminaPluginScreenshotData *rpsd)
const char * ATTR_VERSION
Contains the implementation of the Python module 'remmina', provided to interface with the applicatio...
void * python_wrapper_malloc(int bytes)
Allocates memory and checks for errors before returning.
void(* init)(RemminaProtocolWidget *gp)
static RemminaProtocolPlugin remmina_plugin
long python_wrapper_get_attribute_long(PyObject *instance, const char *attr_name, long def)
Gets the attribute as long value.
const RemminaProtocolFeature * features
gboolean remmina_protocol_map_event_wrapper(RemminaProtocolWidget *gp)
void remmina_protocol_call_feature_wrapper(RemminaProtocolWidget *gp, const RemminaProtocolFeature *feature)
RemminaProtocolPlugin * protocol_plugin
gboolean(* open_connection)(RemminaProtocolWidget *gp)
const char * ATTR_ADVANCED_SETTINGS
void python_wrapper_protocol_init(void)
Initializes the Python plugin specialisation for protocol plugins.
void remmina_protocol_send_keytrokes_wrapper(RemminaProtocolWidget *gp, const guint keystrokes[], const gint keylen)
Contains functions and constants that are commonly used throughout the Python plugin implementation...
const gchar * icon_name_ssh
PyRemminaProtocolWidget * gp
const char * ATTR_FEATURES
gboolean remmina_protocol_close_connection_wrapper(RemminaProtocolWidget *gp)
gboolean(* unmap_event)(RemminaProtocolWidget *gp)
void python_wrapper_add_plugin(PyPlugin *plugin)
Registers the given plugin if no other plugin with the same name has been already registered...
const gchar * description
RemminaProtocolFeatureType type
void(* send_keystrokes)(RemminaProtocolWidget *gp, const guint keystrokes[], const gint keylen)
RemminaPlugin * generic_plugin
RemminaProtocolSSHSetting
const char * ATTR_BASIC_SETTINGS
gboolean remmina_protocol_query_feature_wrapper(RemminaProtocolWidget *gp, const RemminaProtocolFeature *feature)
const RemminaProtocolSetting * basic_settings
RemminaTypeHint opt1_type_hint
const char * ATTR_DESCRIPTION
gboolean(* close_connection)(RemminaProtocolWidget *gp)
RemminaProtocolSettingType type
const char * ATTR_ICON_NAME
Contains the specialisation of RemminaPluginFile plugins in Python.
RemminaTypeHint type_hint
RemminaTypeHint opt2_type_hint
void python_wrapper_to_protocol_feature(RemminaProtocolFeature *dest, PyObject *feature)
Converts the PyObject to RemminaProtocolFeature.
gboolean remmina_protocol_unmap_event_wrapper(RemminaProtocolWidget *gp)
gboolean(* map_event)(RemminaProtocolWidget *gp)
gboolean(* query_feature)(RemminaProtocolWidget *gp, const RemminaProtocolFeature *feature)
PyRemminaProtocolFeature * python_wrapper_protocol_feature_new(void)
const char * ATTR_ICON_NAME_SSH
PyGeneric * python_wrapper_generic_new(void)
Creates a new instance of PyGeneric.
const RemminaProtocolSetting * advanced_settings
const char * ATTR_SSH_SETTING
gboolean(* get_plugin_screenshot)(RemminaProtocolWidget *gp, RemminaPluginScreenshotData *rpsd)
RemminaTypeHint opt3_type_hint
gboolean remmina_protocol_open_connection_wrapper(RemminaProtocolWidget *gp)
RemminaPlugin * python_wrapper_create_protocol_plugin(PyPlugin *plugin)
Creates a new instance of the RemminaPluginProtocol, initializes its members and references the wrapp...