Remmina - The GTK+ Remote Desktop Client  v1.4.33
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.
python_wrapper_secret.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 L U C E S
37 
38 #include "python_wrapper_common.h"
39 #include "python_wrapper_secret.h"
41 
43 // A P I
45 
47 {
48  TRACE_CALL(__func__);
49 }
50 
52 {
53  TRACE_CALL(__func__);
54 
55  PyPlugin* plugin = python_wrapper_get_plugin(instance->name);
56  PyObject* result = CallPythonMethod(plugin->instance, "init", NULL);
57  return result == Py_None || result != Py_False;
58 }
59 
61 {
62  TRACE_CALL(__func__);
63 
64  PyPlugin* plugin = python_wrapper_get_plugin(instance->name);
65  PyObject* result = CallPythonMethod(plugin->instance, "is_service_available", NULL);
66  return result == Py_None || result != Py_False;
67 }
68 
69 void
70 python_wrapper_secret_store_password_wrapper(RemminaSecretPlugin* instance, RemminaFile* file, const gchar* key, const gchar* password)
71 {
72  TRACE_CALL(__func__);
73 
74  PyPlugin* plugin = python_wrapper_get_plugin(instance->name);
75  CallPythonMethod(plugin
76  ->instance, "store_password", "Oss", (PyObject*)python_wrapper_remmina_file_to_python(file), key, password);
77 }
78 
79 gchar*
81 {
82  TRACE_CALL(__func__);
83 
84  PyPlugin* plugin = python_wrapper_get_plugin(instance->name);
85  PyObject* result = CallPythonMethod(plugin
86  ->instance, "get_password", "Os", (PyObject*)python_wrapper_remmina_file_to_python(file), key);
87  Py_ssize_t len = PyUnicode_GetLength(result);
88  if (len == 0)
89  {
90  return NULL;
91  }
92 
93  return python_wrapper_copy_string_from_python(result, len);
94 }
95 
96 void
98 {
99  TRACE_CALL(__func__);
100 
101  PyPlugin* plugin = python_wrapper_get_plugin(instance->name);
102  CallPythonMethod(plugin
103  ->instance, "delete_password", "Os", (PyObject*)python_wrapper_remmina_file_to_python(file), key);
104 }
105 
107 {
108  TRACE_CALL(__func__);
109 
110  PyObject* instance = plugin->instance;
111 
113  {
114  return NULL;
115  }
116 
118 
119  remmina_plugin->type = REMMINA_PLUGIN_TYPE_SECRET;
120  remmina_plugin->domain = GETTEXT_PACKAGE;
121  remmina_plugin->name = PyUnicode_AsUTF8(PyObject_GetAttrString(instance, ATTR_NAME));
122  remmina_plugin->version = PyUnicode_AsUTF8(PyObject_GetAttrString(instance, ATTR_VERSION));
123  remmina_plugin->description = PyUnicode_AsUTF8(PyObject_GetAttrString(instance, ATTR_DESCRIPTION));
124  remmina_plugin->init_order = PyLong_AsLong(PyObject_GetAttrString(instance, ATTR_INIT_ORDER));
125 
126  remmina_plugin->init = python_wrapper_secret_init_wrapper;
131 
132  plugin->secret_plugin = remmina_plugin;
133  plugin->generic_plugin = (RemminaPlugin*)remmina_plugin;
134 
136 
137  return (RemminaPlugin*)remmina_plugin;
138 }
RemminaPluginType type
Definition: plugin.h:136
Maps an instance of a Python plugin to a Remmina one.
typedefG_BEGIN_DECLS struct _RemminaFile RemminaFile
Definition: types.h:44
gboolean(* init)(struct _RemminaSecretPlugin *instance)
Definition: plugin.h:143
RemminaSecretPlugin * secret_plugin
gboolean python_wrapper_check_attribute(PyObject *instance, const char *attr_name)
Checks if a given attribute exists.
const char * ATTR_VERSION
void * python_wrapper_malloc(int bytes)
Allocates memory and checks for errors before returning.
static RemminaProtocolPlugin remmina_plugin
Definition: exec_plugin.c:304
const gchar * version
Definition: plugin.h:140
const gchar * domain
Definition: plugin.h:139
gboolean(* is_service_available)(struct _RemminaSecretPlugin *instance)
Definition: plugin.h:144
void(* delete_password)(struct _RemminaSecretPlugin *instance, RemminaFile *remminafile, const gchar *key)
Definition: plugin.h:147
gchar * python_wrapper_secret_get_password_wrapper(RemminaSecretPlugin *instance, RemminaFile *file, const gchar *key)
void python_wrapper_secret_store_password_wrapper(RemminaSecretPlugin *instance, RemminaFile *file, const gchar *key, const gchar *password)
const char * ATTR_INIT_ORDER
RemminaPlugin * python_wrapper_create_secret_plugin(PyPlugin *plugin)
Creates a new instance of the RemminaPluginSecret, initializes its members and references the wrapper...
Contains functions and constants that are commonly used throughout the Python plugin implementation...
PyRemminaFile * python_wrapper_remmina_file_to_python(RemminaFile *file)
Converts the instance of RemminaFile to a Python object that can be passed to the Python engine...
PyPlugin * python_wrapper_get_plugin(const gchar *name)
Tries to find the Python plugin matching to the given instance of RemminaPlugin.
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
Definition: plugin.h:138
void python_wrapper_secret_init(void)
Initializes the Python plugin specialisation for secret plugins.
const gchar * name
Definition: plugin.h:137
RemminaPlugin * generic_plugin
gboolean python_wrapper_secret_init_wrapper(RemminaSecretPlugin *instance)
char * python_wrapper_copy_string_from_python(PyObject *string, Py_ssize_t len)
Copies a string from a Python object to a new point in memory.
const char * ATTR_NAME
const char * ATTR_DESCRIPTION
gboolean python_wrapper_secret_is_service_available_wrapper(RemminaSecretPlugin *instance)
gchar *(* get_password)(struct _RemminaSecretPlugin *instance, RemminaFile *remminafile, const gchar *key)
Definition: plugin.h:146
void(* store_password)(struct _RemminaSecretPlugin *instance, RemminaFile *remminafile, const gchar *key, const gchar *password)
Definition: plugin.h:145
void python_wrapper_secret_delete_password_wrapper(RemminaSecretPlugin *instance, RemminaFile *file, const gchar *key)
PyObject * instance