Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/Remmina/Remmina.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorllyzs <llyzs.vic@gmail.com>2011-02-03 10:38:31 +0300
committerVic Lee (llyzs) <llyzs@b6cfa94a-2857-405c-b0d6-536ef9fc39e1>2011-02-03 10:38:31 +0300
commita1889f44c28f10ba95a6d02bc8667d8c98f9902f (patch)
tree9a4a00fe27365c67cd339ea67d58b93510572963 /remmina
parentccca0c5ccaeeb23356ae481b7e114db8baed6261 (diff)
Add new 'Secret' plugin type
Diffstat (limited to 'remmina')
-rw-r--r--remmina/include/remmina/plugin.h35
-rw-r--r--remmina/src/remminafile.c82
-rw-r--r--remmina/src/remminafile.h5
-rw-r--r--remmina/src/remminafileeditor.c10
-rw-r--r--remmina/src/remminafileeditor.h2
-rw-r--r--remmina/src/remminamain.c5
-rw-r--r--remmina/src/remminamain.h2
-rw-r--r--remmina/src/remminapluginmanager.c22
-rw-r--r--remmina/src/remminapluginmanager.h1
9 files changed, 140 insertions, 24 deletions
diff --git a/remmina/include/remmina/plugin.h b/remmina/include/remmina/plugin.h
index 6ab6d2f6e..090c58576 100644
--- a/remmina/include/remmina/plugin.h
+++ b/remmina/include/remmina/plugin.h
@@ -1,6 +1,6 @@
/*
* Remmina - The GTK+ Remote Desktop Client
- * Copyright (C) 2010 Vic Lee
+ * Copyright (C) 2010-2011 Vic Lee
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -31,7 +31,8 @@ typedef enum
REMMINA_PLUGIN_TYPE_ENTRY = 1,
REMMINA_PLUGIN_TYPE_FILE = 2,
REMMINA_PLUGIN_TYPE_TOOL = 3,
- REMMINA_PLUGIN_TYPE_PREF = 4
+ REMMINA_PLUGIN_TYPE_PREF = 4,
+ REMMINA_PLUGIN_TYPE_SECRET = 5
} RemminaPluginType;
typedef struct _RemminaPlugin
@@ -40,7 +41,7 @@ typedef struct _RemminaPlugin
const gchar *name;
const gchar *description;
const gchar *domain;
- const gchar *version;
+ const gchar *version;
} RemminaPlugin;
typedef struct _RemminaProtocolPlugin
@@ -49,7 +50,7 @@ typedef struct _RemminaProtocolPlugin
const gchar *name;
const gchar *description;
const gchar *domain;
- const gchar *version;
+ const gchar *version;
const gchar *icon_name;
const gchar *icon_name_ssh;
@@ -71,7 +72,7 @@ typedef struct _RemminaEntryPlugin
const gchar *name;
const gchar *description;
const gchar *domain;
- const gchar *version;
+ const gchar *version;
void (* entry_func) (void);
} RemminaEntryPlugin;
@@ -82,7 +83,7 @@ typedef struct _RemminaFilePlugin
const gchar *name;
const gchar *description;
const gchar *domain;
- const gchar *version;
+ const gchar *version;
gboolean (* import_test_func) (const gchar *from_file);
RemminaFile* (* import_func) (const gchar *from_file);
@@ -97,7 +98,7 @@ typedef struct _RemminaToolPlugin
const gchar *name;
const gchar *description;
const gchar *domain;
- const gchar *version;
+ const gchar *version;
void (* exec_func) (void);
} RemminaToolPlugin;
@@ -108,12 +109,29 @@ typedef struct _RemminaPrefPlugin
const gchar *name;
const gchar *description;
const gchar *domain;
- const gchar *version;
+ const gchar *version;
const gchar *pref_label;
GtkWidget* (* get_pref_body) (void);
} RemminaPrefPlugin;
+typedef struct _RemminaSecretPlugin
+{
+ RemminaPluginType type;
+ const gchar *name;
+ const gchar *description;
+ const gchar *domain;
+ const gchar *version;
+
+ gboolean trusted;
+ void (* store_password) (RemminaFile *remminafile, const gchar *key, const gchar *password);
+ gchar* (* get_password) (RemminaFile *remminafile, const gchar *key);
+ void (* delete_password) (RemminaFile *remminafile, const gchar *key);
+ void (* store_group_password) (const gchar *name, const gchar *password);
+ gchar* (* get_group_password) (const gchar *name);
+ void (* delete_group_password) (const gchar *name);
+} RemminaSecretPlugin;
+
/* Plugin Service is a struct containing a list of function pointers,
* which is passed from Remmina main program to the plugin module
* through the plugin entry function remmina_plugin_entry() */
@@ -163,6 +181,7 @@ typedef struct _RemminaPluginService
RemminaFile* (* file_new) (void);
void (* file_set_string) (RemminaFile *remminafile, const gchar *setting, const gchar *value);
const gchar* (* file_get_string) (RemminaFile *remminafile, const gchar *setting);
+ const gchar* (* file_get_secret) (RemminaFile *remminafile, const gchar *setting);
void (* file_set_int) (RemminaFile *remminafile, const gchar *setting, gint value);
gint (* file_get_int) (RemminaFile *remminafile, const gchar *setting, gint default_value);
diff --git a/remmina/src/remminafile.c b/remmina/src/remminafile.c
index 10c8444d6..b6254b5d8 100644
--- a/remmina/src/remminafile.c
+++ b/remmina/src/remminafile.c
@@ -1,6 +1,6 @@
/*
* Remmina - The GTK+ Remote Desktop Client
- * Copyright (C) 2009-2010 Vic Lee
+ * Copyright (C) 2009-2011 Vic Lee
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
+#include <glib/gstdio.h>
#include <stdlib.h>
#include "remminapublic.h"
#include "remminapref.h"
@@ -69,7 +70,7 @@ const RemminaSetting remmina_system_settings[] =
static RemminaSettingGroup
remmina_setting_get_group (const gchar *setting, gboolean *encrypted)
{
- int i;
+ gint i;
for (i = 0; remmina_system_settings[i].setting; i++)
{
@@ -229,6 +230,25 @@ remmina_file_get_string (RemminaFile *remminafile, const gchar *setting)
return value && value[0] ? value : NULL;
}
+const gchar*
+remmina_file_get_secret (RemminaFile *remminafile, const gchar *setting)
+{
+ RemminaSecretPlugin *plugin;
+ gchar *value;
+
+ plugin = remmina_plugin_manager_get_secret_plugin ();
+ if (plugin)
+ {
+ value = plugin->get_password (remminafile, setting);
+ remmina_file_set_string_ref (remminafile, setting, value);
+ return value && value[0] ? value : NULL;
+ }
+ else
+ {
+ return remmina_file_get_string (remminafile, setting);
+ }
+}
+
void
remmina_file_set_int (RemminaFile *remminafile, const gchar *setting, gint value)
{
@@ -247,12 +267,14 @@ remmina_file_get_int (RemminaFile *remminafile, const gchar *setting, gint defau
static void
remmina_file_store_group (RemminaFile *remminafile, GKeyFile *gkeyfile, RemminaSettingGroup group)
{
+ RemminaSecretPlugin *plugin;
GHashTableIter iter;
const gchar *key, *value;
gchar *s;
gboolean encrypted;
RemminaSettingGroup g;
+ plugin = remmina_plugin_manager_get_secret_plugin ();
g_hash_table_iter_init (&iter, remminafile->settings);
while (g_hash_table_iter_next (&iter, (gpointer*) &key, (gpointer*) &value))
{
@@ -260,11 +282,33 @@ remmina_file_store_group (RemminaFile *remminafile, GKeyFile *gkeyfile, RemminaS
g = remmina_setting_get_group (key, &encrypted);
if (g != REMMINA_SETTING_GROUP_NONE && (group == REMMINA_SETTING_GROUP_ALL || group == g))
{
- if (encrypted && value && value[0])
+ if (encrypted)
{
- s = remmina_crypt_encrypt (value);
- g_key_file_set_string (gkeyfile, "remmina", key, s);
- g_free (s);
+ if (plugin)
+ {
+ g_key_file_set_string (gkeyfile, "remmina", key, "");
+ if (value && value[0])
+ {
+ plugin->store_password (remminafile, key, value);
+ }
+ else
+ {
+ plugin->delete_password (remminafile, key);
+ }
+ }
+ else
+ {
+ if (value && value[0])
+ {
+ s = remmina_crypt_encrypt (value);
+ g_key_file_set_string (gkeyfile, "remmina", key, s);
+ g_free (s);
+ }
+ else
+ {
+ g_key_file_set_string (gkeyfile, "remmina", key, "");
+ }
+ }
}
else
{
@@ -406,3 +450,29 @@ remmina_file_dup_temp_protocol (RemminaFile *remminafile, const gchar *new_proto
return tmp;
}
+void
+remmina_file_delete (const gchar *filename)
+{
+ RemminaSecretPlugin *plugin;
+ RemminaFile *remminafile;
+ gint i;
+
+ remminafile = remmina_file_load (filename);
+ if (remminafile)
+ {
+ plugin = remmina_plugin_manager_get_secret_plugin ();
+ if (plugin)
+ {
+ for (i = 0; remmina_system_settings[i].setting; i++)
+ {
+ if (remmina_system_settings[i].encrypted)
+ {
+ plugin->delete_password (remminafile, remmina_system_settings[i].setting);
+ }
+ }
+ }
+ remmina_file_free (remminafile);
+ }
+ g_unlink (filename);
+}
+
diff --git a/remmina/src/remminafile.h b/remmina/src/remminafile.h
index 393797403..141489645 100644
--- a/remmina/src/remminafile.h
+++ b/remmina/src/remminafile.h
@@ -1,6 +1,6 @@
/*
* Remmina - The GTK+ Remote Desktop Client
- * Copyright (C) 2009-2010 Vic Lee
+ * Copyright (C) 2009-2011 Vic Lee
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -56,6 +56,7 @@ RemminaFile* remmina_file_load (const gchar *filename);
void remmina_file_set_string (RemminaFile *remminafile, const gchar *setting, const gchar *value);
void remmina_file_set_string_ref (RemminaFile *remminafile, const gchar *setting, gchar *value);
const gchar* remmina_file_get_string (RemminaFile *remminafile, const gchar *setting);
+const gchar* remmina_file_get_secret (RemminaFile *remminafile, const gchar *setting);
void remmina_file_set_int (RemminaFile *remminafile, const gchar *setting, gint value);
gint remmina_file_get_int (RemminaFile *remminafile, const gchar *setting, gint default_value);
/* Create or overwrite the .remmina file */
@@ -71,6 +72,8 @@ void remmina_file_update_screen_resolution (RemminaFile *remminafile);
const gchar* remmina_file_get_icon_name (RemminaFile *remminafile);
/* Duplicate a temporary RemminaFile and change the protocol */
RemminaFile* remmina_file_dup_temp_protocol (RemminaFile *remminafile, const gchar *new_protocol);
+/* Delete a .remmina file */
+void remmina_file_delete (const gchar *filename);
G_END_DECLS
diff --git a/remmina/src/remminafileeditor.c b/remmina/src/remminafileeditor.c
index 89e7ea736..d950ed7b7 100644
--- a/remmina/src/remminafileeditor.c
+++ b/remmina/src/remminafileeditor.c
@@ -1,6 +1,6 @@
/*
* Remmina - The GTK+ Remote Desktop Client
- * Copyright (C) 2009-2010 Vic Lee
+ * Copyright (C) 2009-2011 Vic Lee
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -393,9 +393,13 @@ remmina_file_editor_create_password (RemminaFileEditor *gfe, GtkWidget *table, g
gtk_widget_show (widget);
gtk_table_attach_defaults (GTK_TABLE (table), widget, 1, 2, row, row + 1);
gtk_entry_set_visibility (GTK_ENTRY (widget), FALSE);
- cs = remmina_file_get_string (gfe->priv->remmina_file, "password");
- if (cs) gtk_entry_set_text (GTK_ENTRY (widget), cs);
gfe->priv->password_entry = widget;
+
+ cs = remmina_file_get_secret (gfe->priv->remmina_file, "password");
+ if (cs)
+ {
+ gtk_entry_set_text (GTK_ENTRY (widget), cs);
+ }
}
static void
diff --git a/remmina/src/remminafileeditor.h b/remmina/src/remminafileeditor.h
index 657b4d56c..304d954e0 100644
--- a/remmina/src/remminafileeditor.h
+++ b/remmina/src/remminafileeditor.h
@@ -1,6 +1,6 @@
/*
* Remmina - The GTK+ Remote Desktop Client
- * Copyright (C) 2009 - Vic Lee
+ * Copyright (C) 2009-2011 Vic Lee
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/remmina/src/remminamain.c b/remmina/src/remminamain.c
index f4f009854..adb6a6fa0 100644
--- a/remmina/src/remminamain.c
+++ b/remmina/src/remminamain.c
@@ -1,6 +1,6 @@
/*
* Remmina - The GTK+ Remote Desktop Client
- * Copyright (C) 2009-2010 Vic Lee
+ * Copyright (C) 2009-2011 Vic Lee
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,7 +20,6 @@
#include "config.h"
#include <gtk/gtk.h>
-#include <glib/gstdio.h>
#include <glib/gi18n.h>
#include "remminastringarray.h"
#include "remminapublic.h"
@@ -574,7 +573,7 @@ remmina_main_action_connection_delete (GtkAction *action, RemminaMain *remminama
_("Are you sure to delete '%s'"), remminamain->priv->selected_name);
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES)
{
- g_unlink (remminamain->priv->selected_filename);
+ remmina_file_delete (remminamain->priv->selected_filename);
remmina_main_load_files (remminamain, TRUE);
}
gtk_widget_destroy (dialog);
diff --git a/remmina/src/remminamain.h b/remmina/src/remminamain.h
index 8866ee102..7265f2c65 100644
--- a/remmina/src/remminamain.h
+++ b/remmina/src/remminamain.h
@@ -1,6 +1,6 @@
/*
* Remmina - The GTK+ Remote Desktop Client
- * Copyright (C) 2009 - Vic Lee
+ * Copyright (C) 2009-2011 Vic Lee
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/remmina/src/remminapluginmanager.c b/remmina/src/remminapluginmanager.c
index 836358a39..d7ea9e1af 100644
--- a/remmina/src/remminapluginmanager.c
+++ b/remmina/src/remminapluginmanager.c
@@ -1,6 +1,6 @@
/*
* Remmina - The GTK+ Remote Desktop Client
- * Copyright (C) 2010 Vic Lee
+ * Copyright (C) 2010-2011 Vic Lee
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -33,6 +33,9 @@
static GPtrArray* remmina_plugin_table = NULL;
+/* There can be only one secret plugin loaded */
+static RemminaSecretPlugin *remmina_secret_plugin = NULL;
+
static const gchar *remmina_plugin_type_name[] =
{
N_("Protocol"),
@@ -40,6 +43,7 @@ static const gchar *remmina_plugin_type_name[] =
N_("File"),
N_("Tool"),
N_("Preference"),
+ N_("Secret"),
NULL
};
@@ -52,6 +56,15 @@ remmina_plugin_manager_compare_func (RemminaPlugin **a, RemminaPlugin **b)
static gboolean
remmina_plugin_manager_register_plugin (RemminaPlugin *plugin)
{
+ if (plugin->type == REMMINA_PLUGIN_TYPE_SECRET)
+ {
+ if (remmina_secret_plugin)
+ {
+ g_print ("Remmina plugin %s (type=%s) bypassed.\n", plugin->name, _(remmina_plugin_type_name[plugin->type]));
+ return FALSE;
+ }
+ remmina_secret_plugin = (RemminaSecretPlugin*) plugin;
+ }
g_ptr_array_add (remmina_plugin_table, plugin);
g_ptr_array_sort (remmina_plugin_table, (GCompareFunc) remmina_plugin_manager_compare_func);
g_print ("Remmina plugin %s (type=%s) registered.\n", plugin->name, _(remmina_plugin_type_name[plugin->type]));
@@ -102,6 +115,7 @@ RemminaPluginService remmina_plugin_manager_service =
remmina_file_new,
remmina_file_set_string,
remmina_file_get_string,
+ remmina_file_get_secret,
remmina_file_set_int,
remmina_file_get_int,
@@ -322,3 +336,9 @@ remmina_plugin_manager_get_export_file_handler (RemminaFile *remminafile)
return NULL;
}
+RemminaSecretPlugin*
+remmina_plugin_manager_get_secret_plugin (void)
+{
+ return remmina_secret_plugin;
+}
+
diff --git a/remmina/src/remminapluginmanager.h b/remmina/src/remminapluginmanager.h
index df060ef9a..6c988bd46 100644
--- a/remmina/src/remminapluginmanager.h
+++ b/remmina/src/remminapluginmanager.h
@@ -33,6 +33,7 @@ void remmina_plugin_manager_for_each_plugin (RemminaPluginType type, RemminaPlug
void remmina_plugin_manager_show (GtkWindow *parent);
RemminaFilePlugin* remmina_plugin_manager_get_import_file_handler (const gchar *file);
RemminaFilePlugin* remmina_plugin_manager_get_export_file_handler (RemminaFile *remminafile);
+RemminaSecretPlugin* remmina_plugin_manager_get_secret_plugin (void);
extern RemminaPluginService remmina_plugin_manager_service;