From 3b5fe74069fad29d53eb25be74d8ea807cce0c0e Mon Sep 17 00:00:00 2001 From: Patryk Nowak Date: Tue, 2 Jan 2024 19:19:21 +0100 Subject: Add unlocking code to let plugins use passwords --- plugins/python_wrapper/python_wrapper_remmina.c | 21 +++++++++++++++++++++ src/include/remmina/plugin.h | 1 + src/remmina_plugin_manager.c | 2 ++ 3 files changed, 24 insertions(+) diff --git a/plugins/python_wrapper/python_wrapper_remmina.c b/plugins/python_wrapper/python_wrapper_remmina.c index 955be8ef0..7a4a7711d 100644 --- a/plugins/python_wrapper/python_wrapper_remmina.c +++ b/plugins/python_wrapper/python_wrapper_remmina.c @@ -67,6 +67,7 @@ static PyObject* python_wrapper_debug_wrapper(PyObject* self, PyObject* msg); static PyObject* remmina_register_plugin_wrapper(PyObject* self, PyObject* plugin); static PyObject* remmina_file_get_datadir_wrapper(PyObject* self, PyObject* plugin); static PyObject* remmina_file_new_wrapper(PyObject* self, PyObject* args, PyObject* kwargs); +static PyObject* remmina_unlock_new_wrapper(PyObject* self, PyObject* args, PyObject* kwargs); static PyObject* remmina_pref_set_value_wrapper(PyObject* self, PyObject* args, PyObject* kwargs); static PyObject* remmina_pref_get_value_wrapper(PyObject* self, PyObject* args, PyObject* kwargs); static PyObject* remmina_pref_get_scale_quality_wrapper(PyObject* self, PyObject* plugin); @@ -132,6 +133,11 @@ static PyMethodDef remmina_python_module_type_methods[] = { */ { "file_new", (PyCFunction)remmina_file_new_wrapper, METH_VARARGS | METH_KEYWORDS, NULL }, + /** + * Calls remmina_unlock_new and returns its result. + */ + { "unlock_new", (PyCFunction)remmina_unlock_new_wrapper, METH_VARARGS | METH_KEYWORDS, NULL }, + /** * Calls remmina_pref_set_value and returns its result. */ @@ -854,6 +860,21 @@ static PyObject* remmina_file_new_wrapper(PyObject* self, PyObject* args, PyObje return Py_None; } +static PyObject* remmina_unlock_new_wrapper(PyObject* self, PyObject* args, PyObject* kwargs) +{ + TRACE_CALL(__func__); + + static char* kwlist[] = { "window", NULL}; + GtkWindow* window = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|0", kwlist, &window)) + { + return Py_None; + } + + return PyBool_FromLong(python_wrapper_get_service()->plugin_unlock_new(window)); +} + static PyObject* remmina_pref_set_value_wrapper(PyObject* self, PyObject* args, PyObject* kwargs) { TRACE_CALL(__func__); diff --git a/src/include/remmina/plugin.h b/src/include/remmina/plugin.h index a69b54359..cef051be5 100644 --- a/src/include/remmina/plugin.h +++ b/src/include/remmina/plugin.h @@ -301,6 +301,7 @@ typedef struct _RemminaPluginService { GtkWidget *(*rcw_open_from_file_full)(RemminaFile *remminafile, GCallback disconnect_cb, gpointer data, guint *handler); void (*show_dialog)(GtkMessageType msg, GtkButtonsType buttons, const gchar* message); GtkWindow *(*get_window)(void); + gint (*plugin_unlock_new)(GtkWindow* parent); } RemminaPluginService; /* "Prototype" of the plugin entry function */ diff --git a/src/remmina_plugin_manager.c b/src/remmina_plugin_manager.c index 27c248644..aaa617ab2 100644 --- a/src/remmina_plugin_manager.c +++ b/src/remmina_plugin_manager.c @@ -60,6 +60,7 @@ #include "remmina_public.h" #include "remmina_masterthread_exec.h" #include "remmina/remmina_trace_calls.h" +#include "remmina_unlock.h" static GPtrArray* remmina_plugin_table = NULL; @@ -308,6 +309,7 @@ RemminaPluginService remmina_plugin_manager_service = rcw_open_from_file_full, remmina_main_show_dialog, remmina_main_get_window, + remmina_unlock_new, }; const char *get_filename_ext(const char *filename) { -- cgit v1.2.3