Patch for VINO - new feature
- From: "Jorge Pereira" <jpereiran gmail com>
- To: "GNOME - Desktop-Dev-List" <desktop-devel-list gnome org>, "Mark McLoughlin" <mark skynet ie>, "Jonh Wendell" <wendell bani com br>
- Subject: Patch for VINO - new feature
- Date: Sun, 23 Mar 2008 02:45:22 -0300
Hello!
I using VINO a lot for access my personal computer from my machine of work, but
has happened of forgot my password, and don't known how to change my pass on terminal.
So, i get the source code from SVN and found where the vino save the password in gconf
using the format base64.
i known that i can change the fields using gconf from console, but it's nothing "friendly",
so i write this patch in attachment that add new feature for manager of configuration in
"vino-preferences", you found all options using the option "--cli" in "vino-preferences".
I found many people with this "necessity" that manager VINO from console, i think
that this patch help "someone" guys. :)
Atc: Sorry for my bad english! =/
[]s
--
Regards,
+ ---------------------------------------------------------------------------------+
Jorge Pereira, From: Olinda/Pe/Brazil
Home:
http://www.jorgepereira.com.br/
E-mail:
jpereiran gmail com,
jorge jorgepereira com br Mobile: +55 (81) 8833-2484
My Public Key:
http://www.jorgepereira.com.br/public.pgp
+ ---------------------------------------------------------------------------------+
"Se você ama alguma coisa, liberte-a;
Se ela não voltar a ti, cace-a e mate-a."
+----------------------------------------------------------------------------------+
diff -uNr trunk.20080323/capplet/Makefile.am trunk.20080323.jorge/capplet/Makefile.am
--- trunk.20080323/capplet/Makefile.am 2008-03-23 01:53:53.000000000 -0300
+++ trunk.20080323.jorge/capplet/Makefile.am 2008-03-23 01:58:46.000000000 -0300
@@ -4,6 +4,7 @@
-DVINO_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-DVINO_GLADEDIR=\""$(datadir)/vino"\" \
-DVINO_ICONDIR=\""$(datadir)/pixmaps\"" \
+ $(VINO_DEBUG_CFLAGS) \
$(VINO_CAPPLET_CFLAGS) \
$(VINO_KEYRING_CFLAGS) \
$(VINO_HTTP_CFLAGS) \
diff -uNr trunk.20080323/capplet/vino-preferences.c trunk.20080323.jorge/capplet/vino-preferences.c
--- trunk.20080323/capplet/vino-preferences.c 2008-03-23 01:53:53.000000000 -0300
+++ trunk.20080323.jorge/capplet/vino-preferences.c 2008-03-23 01:59:45.000000000 -0300
@@ -30,6 +30,8 @@
#include <libintl.h>
#include <unistd.h>
#include <netdb.h>
+#include <termios.h>
+#include <getopt.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <gconf/gconf-client.h>
@@ -41,6 +43,12 @@
#include <gnome-keyring.h>
#endif
+#define PRINT_BOOL(x) ((x == TRUE) ? _("enable") : \
+ ((x == FALSE) ? _("disabled") : _("unknown")))
+
+#define IS_BOOLEAN(x) ((x == TRUE) ? TRUE : \
+ ((x == FALSE) ? FALSE : -1))
+
#define VINO_PREFS_DIR "/desktop/gnome/remote_access"
#define VINO_PREFS_ENABLED VINO_PREFS_DIR "/enabled"
#define VINO_PREFS_PROMPT_ENABLED VINO_PREFS_DIR "/prompt_enabled"
@@ -56,9 +64,12 @@
#define VINO_PREFS_LOCK_SCREEN VINO_PREFS_DIR "/lock_screen_on_disconnect"
#define N_LISTENERS 12
+#define VINO_PREFS_CLI_NOTI_ALWAYS "always"
+#define VINO_PREFS_CLI_NOTI_CLIENT "client"
+#define VINO_PREFS_CLI_NOTI_NEVER "never"
-#define VINO_DBUS_BUS_NAME "org.gnome.Vino"
-#define VINO_DBUS_INTERFACE "org.gnome.VinoScreen"
+#define VINO_DBUS_BUS_NAME "org.gnome.Vino"
+#define VINO_DBUS_INTERFACE "org.gnome.VinoScreen"
typedef struct {
GladeXML *xml;
@@ -90,8 +101,575 @@
int expected_listeners;
guint use_password : 1;
+ gboolean vb_flg;
+
} VinoPreferencesDialog;
+static gboolean
+vino_preferences_dialog_set_password_in_keyring (VinoPreferencesDialog *dialog,
+ const char *password);
+static gboolean
+vino_preferences_cli_set_flag(VinoPreferencesDialog *dialog,
+ const char *pref,
+ gboolean allowed)
+{
+ if(IS_BOOLEAN(allowed) == -1 || pref == NULL)
+ {
+ g_printerr(_("The argument %d is invalid, exiting...\n"), allowed);
+ return FALSE;
+ }
+
+ if(!gconf_client_set_bool (dialog->client, pref, allowed, NULL))
+ {
+ g_printerr(_("Problems in change value, exiting...\n"));
+ return FALSE;
+ }
+
+ if(dialog->vb_flg)
+ g_printerr(_(" VERBOSE: set_flag(): The value (%s=%d) changed was successfull!\n"),
+ pref, allowed);
+
+ return TRUE;
+}
+
+static gboolean
+vino_preferences_cli_get_flag(VinoPreferencesDialog *dialog,
+ const gchar *pref
+ )
+{
+ return gconf_client_get_bool (dialog->client, pref, NULL);
+}
+
+static void
+vino_preferences_load_prepare(VinoPreferencesDialog *dialog)
+{
+ dialog->client = gconf_client_get_default ();
+ gconf_client_add_dir (dialog->client, VINO_PREFS_DIR,
+ GCONF_CLIENT_PRELOAD_ONELEVEL, NULL
+ );
+}
+
+static void
+vino_preferences_cli_show_version(void)
+{
+ printf("VINO %s\n", VERSION);
+}
+
+static gboolean
+vino_preferences_cli_set_password(VinoPreferencesDialog *dialog,
+ const char *password)
+{
+ if(dialog->vb_flg)
+ g_printerr(_(" VERBOSE: set_password(): password = \"%s\"\n"), password);
+
+ if (vino_preferences_dialog_set_password_in_keyring (dialog, password))
+ return TRUE;
+
+ if (!password || !password [0])
+ {
+ gconf_client_unset (dialog->client, VINO_PREFS_VNC_PASSWORD, NULL);
+ return TRUE;
+ }
+ else if (strlen (password) > 1)
+ {
+ char *password_b64;
+
+ password_b64 = g_base64_encode ((guchar *) password, strlen (password));
+
+ gconf_client_set_string (dialog->client,
+ VINO_PREFS_VNC_PASSWORD, password_b64, NULL);
+
+ g_free (password_b64);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gchar*
+vino_preferences_cli_get_password_b64(VinoPreferencesDialog *dialog)
+{
+ return gconf_client_get_string(dialog->client, VINO_PREFS_VNC_PASSWORD, NULL);
+}
+
+static gchar*
+vino_preferences_cli_get_password(VinoPreferencesDialog *dialog)
+{
+ gchar *password;
+ gsize len;
+
+ password = gconf_client_get_string(dialog->client, VINO_PREFS_VNC_PASSWORD, NULL);
+ if(strlen(password) > 1)
+ {
+ return (gchar*)g_base64_decode ((const gchar *) password, &len);
+ }
+
+ return password;
+}
+
+static gboolean
+vino_preferences_cli_set_alternative_port(VinoPreferencesDialog *dialog,
+ guint local_port)
+{
+ if(dialog->vb_flg)
+ g_printerr(_(" VERBOSE: set_alternative_port(): local_port = %d\n"), local_port);
+
+ if(local_port == 0x00)
+ {
+ vino_preferences_cli_set_flag (dialog,
+ VINO_PREFS_USE_ALTERNATIVE_PORT, FALSE);
+ g_printerr(_("The alternative port has been disabled!\n"));
+ return FALSE;
+ }
+
+ if(local_port > 0x00 && local_port <= 0xFFFF)
+ {
+ vino_preferences_cli_set_flag (dialog, VINO_PREFS_USE_ALTERNATIVE_PORT, TRUE);
+ return gconf_client_set_int (dialog->client, VINO_PREFS_ALTERNATIVE_PORT,
+ local_port, NULL);
+ }
+
+ g_printerr(_("Invalid port, try port number between 1 and 65535\n"));
+
+ return FALSE;
+}
+
+static gboolean
+vino_preferences_cli_set_notification(VinoPreferencesDialog *dialog,
+ const gchar *value)
+{
+ if(dialog->vb_flg)
+ g_printerr(_(" VERBOSE: set_notification(): value = %s\n"), value);
+
+ return gconf_client_set_string (dialog->client, VINO_PREFS_ICON_VISIBILITY,
+ value, NULL);
+}
+
+static gboolean
+vino_preferences_cli_set_use_password(VinoPreferencesDialog *dialog,
+ gboolean allowed)
+{
+ GSList *auth_methods = NULL;
+
+ if(dialog->vb_flg)
+ g_printerr(_(" VERBOSE: set_use_password(): allowed = %s\n"), PRINT_BOOL(allowed));
+
+ if(IS_BOOLEAN(allowed) == -1)
+ {
+ g_printerr(_("The argument %d is invalid, exiting...\n"), allowed);
+ return FALSE;
+ }
+
+ dialog->use_password = allowed;
+
+ if (dialog->use_password)
+ auth_methods = g_slist_prepend (auth_methods, "vnc");
+ else
+ auth_methods = g_slist_append (auth_methods, "none");
+
+ gconf_client_set_list (dialog->client,
+ VINO_PREFS_AUTHENTICATION_METHODS,
+ GCONF_VALUE_STRING,
+ auth_methods,
+ NULL);
+
+ g_slist_free (auth_methods);
+
+ return TRUE;
+}
+
+static gboolean
+vino_preferences_cli_get_use_password (VinoPreferencesDialog *dialog)
+{
+ GSList *auth_methods, *l;
+ gboolean use_password;
+
+ auth_methods = gconf_client_get_list (dialog->client,
+ VINO_PREFS_AUTHENTICATION_METHODS,
+ GCONF_VALUE_STRING,
+ NULL);
+
+ use_password = FALSE;
+ for (l = auth_methods; l; l = l->next)
+ {
+ char *method = l->data;
+
+ if (!strcmp (method, "vnc"))
+ use_password = TRUE;
+
+ g_free (method);
+ }
+ g_slist_free (auth_methods);
+
+ return use_password;
+}
+
+static void
+vino_preferences_cli_show_help(char **argv)
+{
+ printf( "Usage:\n"
+ "%s [OPTION...] [KEY] - Directly edit your entire configuration database\n"
+ "\n"
+ "Help Options:\n"
+ " -h, --help Show help options\n"
+ " -v, --version output version information and exit\n"
+ " -V, --verbose Verbose flag is set\n"
+ " -s, --show-config output all current config and exit\n"
+ "\n"
+ "General -> Sharing\n"
+ " -u, --users-view=0/1 Allow other users to view your desktop\n"
+ " -U, --users-control=0/1 Allow other users to control your desktop\n"
+ "\n"
+ "General -> Security\n"
+ "\n"
+ " When a user tries to view or control your desktop:\n"
+ " -a, --ask-confirm=0/1 Ask you for confirmation\n"
+ " -P, --require-password=0/1 Require the user to enter this password\n"
+ " -p, --set-password=pass Set a new password\n"
+ "\n"
+ "Advanced -> Network\n"
+ "\n"
+ " -l, --only-local-connections=0/1 Only allow local connections\n"
+ " -S, --set-alternative-port=6969 Use an alternative port, set '0' for use\n"
+ " defaul port\n"
+ "\n"
+ "Advanced -> Security\n"
+ "\n"
+ " -r, --require-encryption=0/1 Require encryption\n"
+ " -k, --lock-screen=0/1 Lock screen on disconnect\n"
+ "\n"
+ "Advanced -> Notification Area\n"
+ "\n"
+ " -A, --set-notification-always Always display an icon\n"
+ " -O, --set-notification-only Only display an icon when there is someone connected\n"
+ " -N, --set-notification-never Never display an icon\n"
+ "\n"
+ "VINO %s\n",
+ argv[0], VERSION);
+
+ exit(EXIT_SUCCESS);
+}
+
+static void
+vino_preferences_cli_show_config(VinoPreferencesDialog *dialog)
+{
+ gboolean view_only;
+ gboolean prom_enab;
+ gboolean prompt_enabled;
+ gboolean req_encryp;
+ gboolean lock_screen;
+ gboolean authentication_methods;
+ gboolean only_local_conne;
+ gboolean use_alter_port;
+ guint alter_port;
+ const gchar *value;
+ const gchar *password;
+ const gchar *password_b64;
+
+ g_printerr(_(" Remote Desktop Preferences - CLI\n"));
+ g_printerr("\n");
+
+ view_only = vino_preferences_cli_get_flag (dialog, VINO_PREFS_VIEW_ONLY);
+ prom_enab = vino_preferences_cli_get_flag (dialog, VINO_PREFS_ENABLED);
+ g_printerr(_(" General -> Sharing\n"));
+ g_printerr("\n");
+ g_printerr(" -> ");
+ g_printerr(_("Allow other users to view your desktop = %s\n"),
+ PRINT_BOOL(prom_enab));
+ g_printerr(" -> ");
+ g_printerr(_("Allow other users to control your desktop = %s\n"),
+ PRINT_BOOL(!view_only));
+ g_printerr("\n");
+
+ prompt_enabled = vino_preferences_cli_get_flag (dialog, VINO_PREFS_PROMPT_ENABLED);
+ g_printerr(_(" General -> Security\n"));
+ g_printerr("\n");
+ g_printerr(_(" When a user tries to view or control your desktop:\n"));
+ g_printerr("\n");
+ g_printerr(" -> ");
+ g_printerr(_("Ask you for confirmation = %s\n"),
+ PRINT_BOOL(prompt_enabled));
+
+ authentication_methods = vino_preferences_cli_get_use_password (dialog);
+ password_b64 = vino_preferences_cli_get_password_b64 (dialog);
+ password = vino_preferences_cli_get_password (dialog);
+ g_printerr(" -> ");
+ g_printerr(_("Require the user to enter this password = %s plain(%s) b64(%s)\n"),
+ PRINT_BOOL(authentication_methods),
+ password,
+ password_b64);
+ g_printerr("\n");
+
+ only_local_conne = vino_preferences_cli_get_flag (dialog, VINO_PREFS_LOCAL_ONLY);
+ g_printerr(_(" Advanced -> Network\n"));
+ g_printerr("\n");
+ g_printerr(" -> ");
+ g_printerr(_("Only allow local connections = %s\n"),
+ PRINT_BOOL(only_local_conne));
+
+ use_alter_port = vino_preferences_cli_get_flag (dialog, VINO_PREFS_USE_ALTERNATIVE_PORT);
+ alter_port = gconf_client_get_int (dialog->client, VINO_PREFS_ALTERNATIVE_PORT, NULL);
+ g_printerr(" -> ");
+ g_printerr(_("Use an alternative port = %s (%d)\n"),
+ PRINT_BOOL(use_alter_port),
+ alter_port
+ );
+ g_printerr("\n");
+
+ req_encryp = vino_preferences_cli_get_flag (dialog, VINO_PREFS_ENCRYPTION);
+ g_printerr(_(" Advanced -> Security\n"));
+ g_printerr("\n");
+ g_printerr(" -> ");
+ g_printerr(_("Require encryption = %s\n"),
+ PRINT_BOOL(req_encryp));
+
+ lock_screen = vino_preferences_cli_get_flag (dialog, VINO_PREFS_LOCK_SCREEN);
+ g_printerr(" -> ");
+ g_printerr(_("Lock screen on disconnect = %s\n"),
+ PRINT_BOOL(lock_screen));
+ g_printerr("\n");
+
+ value = gconf_client_get_string (dialog->client, VINO_PREFS_ICON_VISIBILITY, NULL);
+ if (!g_ascii_strcasecmp (value, VINO_PREFS_CLI_NOTI_ALWAYS))
+ value = "Always display an icon";
+ else if (!g_ascii_strcasecmp (value, VINO_PREFS_CLI_NOTI_CLIENT))
+ value = "Only display an icon when there is someone connected";
+ else if (!g_ascii_strcasecmp (value, VINO_PREFS_CLI_NOTI_NEVER))
+ value = "Never display an icon";
+ else
+ {
+ vino_preferences_cli_set_notification(dialog, VINO_PREFS_CLI_NOTI_ALWAYS);
+ value = "Always display an icon";
+ }
+
+ g_printerr(_(" Advanced -> Notification Area\n"));
+ g_printerr("\n");
+ g_printerr(" -> ");
+ g_printerr(_("%s\n"), value);
+ g_printerr("\n");
+ g_printerr("VINO %s\n", VERSION);
+
+ exit(EXIT_SUCCESS);
+}
+
+static void
+vino_preferences_cli_init(VinoPreferencesDialog *dialog,
+ int argc,
+ char **argv)
+{
+ int ch;
+ int option_index = 0;
+ gboolean vb_msg = TRUE;
+ dialog->vb_flg = FALSE;
+
+ struct option long_options[] = {
+ { "help", 0, NULL, 'h' },
+ { "version", 0, NULL, 'v' },
+ { "verbose", 0, &dialog->vb_flg, 1 },
+ { "show-config", 0, NULL, 's' },
+ { "users-view", 1, NULL, 'u' },
+ { "users-control", 1, NULL, 'U' },
+ { "ask-confirm", 1, NULL, 'a' },
+ { "set-password", 0, NULL, 'p' },
+ { "require-password", 1, NULL, 'P' },
+ { "only-local-connections", 1, NULL, 'l' },
+ { "set-alternative-port", 1, NULL, 'S' },
+ { "require-encryption", 1, NULL, 'r' },
+ { "lock-screen", 1, NULL, 'k' },
+ { "set-notification-always", 0, NULL, 'A' },
+ { "set-notification-only", 0, NULL, 'O' },
+ { "set-notification-never", 0, NULL, 'N' },
+ { "cli", 0, NULL, 0 },
+ { 0, 0, NULL, 0 }
+ };
+
+ if(argc < 2 || (argc == 2 && !strcmp(argv[1], "--cli")))
+ {
+ vino_preferences_cli_show_help(argv);
+ }
+
+ while ((ch = getopt_long(argc, argv, "h?vpsVAONu:a:l:r:S:k:P:U:",
+ long_options, &option_index)) != -1)
+ {
+ if(dialog->vb_flg && vb_msg)
+ {
+ vb_msg = FALSE;
+ g_printerr(_("WARNING: Verbose flag is set\n"));
+ }
+
+ switch (ch)
+ {
+ case 'h':
+ vino_preferences_cli_show_help(argv);
+ break;
+
+ case 'v':
+ vino_preferences_cli_show_version();
+ break;
+
+ case 'V':
+ dialog->vb_flg = TRUE;
+ break;
+
+ case 's':
+ vino_preferences_cli_show_config(dialog);
+ break;
+
+ case 'u':
+
+ if(vino_preferences_cli_set_flag(dialog, VINO_PREFS_ENABLED, atoi(optarg)))
+ {
+ g_printerr(_("Allow other users to view your desktop, has been %s\n"),
+ PRINT_BOOL(atoi(optarg)));
+ }
+
+ break;
+
+ case 'U':
+
+ if(vino_preferences_cli_set_flag(dialog, VINO_PREFS_VIEW_ONLY, atoi(optarg)))
+ {
+ g_printerr(_("Allow other users to control your desktop, has been %s\n"),
+ PRINT_BOOL(atoi(optarg)));
+ }
+
+ break;
+
+ case 'a':
+
+ if(vino_preferences_cli_set_flag(dialog, VINO_PREFS_PROMPT_ENABLED, atoi(optarg)))
+ {
+ g_printerr(_("Ask you for confirmation, has been %s\n"),
+ PRINT_BOOL(atoi(optarg)));
+ }
+
+ break;
+
+ case 'P':
+
+ if(vino_preferences_cli_set_use_password(dialog,atoi(optarg)))
+ {
+ g_printerr(_("Requirement for password has been %s\n"),
+ PRINT_BOOL(atoi(optarg)));
+ }
+
+ break;
+
+ case 'p':
+ {
+ char password[9+1];
+ struct termios told, tnew;
+
+ tcgetattr(0, &told);
+ tnew = told;
+ tnew.c_lflag &= ~(ICANON | ECHO | ISIG);
+ tnew.c_iflag &= ~(IXON | IXOFF);
+
+ g_printerr(_("Enter your new password: "));
+
+ tcsetattr(0, TCSAFLUSH, &tnew);
+ fgets(password, sizeof(password), stdin);
+ password[strlen(password)-1] = 0x00; /* Removing \n from string */
+ tcsetattr(0, TCSAFLUSH, &told);
+ fflush(stdout);
+
+ g_printerr("\n");
+ if(strlen(password) > 1 && vino_preferences_cli_set_password(dialog, password))
+ {
+ g_printerr(_("Done!\n"));
+ }
+ else
+ {
+ g_printerr(_("You must choose a longer password\n"));
+ }
+ }
+ break;
+
+ case 'l':
+
+ if(vino_preferences_cli_set_flag(dialog, VINO_PREFS_LOCAL_ONLY, atoi(optarg)))
+ {
+ g_printerr(_("Only allow local connections, has been %s\n"),
+ PRINT_BOOL(atoi(optarg)));
+ }
+
+ break;
+
+ case 'S':
+
+ if(vino_preferences_cli_set_alternative_port(dialog, atoi(optarg)))
+ {
+ g_printerr(_("The alternative port has been enabled using %d port!\n"),
+ atoi(optarg));
+ }
+
+ break;
+
+ case 'r':
+
+ if(vino_preferences_cli_set_flag(dialog, VINO_PREFS_ENCRYPTION, atoi(optarg)))
+ {
+ g_printerr(_("Require encryption, has been %s\n"),
+ PRINT_BOOL(atoi(optarg)));
+ }
+
+ break;
+
+ case 'k':
+
+ if(vino_preferences_cli_set_flag(dialog, VINO_PREFS_LOCK_SCREEN, atoi(optarg)))
+ {
+ g_printerr(_("Lock screen on disconnect, has been %s\n"),
+ PRINT_BOOL(atoi(optarg)));
+ }
+
+ break;
+
+ case 'A':
+
+ if(vino_preferences_cli_set_notification(dialog, VINO_PREFS_CLI_NOTI_ALWAYS))
+ {
+ g_printerr(_("Notification Area, Always display an icon\n"));
+ }
+
+ break;
+
+ case 'O':
+
+ if(vino_preferences_cli_set_notification(dialog, VINO_PREFS_CLI_NOTI_CLIENT))
+ {
+ g_printerr(_("Notification Area, Only display an icon when there is someone connected\n"));
+ }
+
+ break;
+
+ case 'N':
+
+ if(vino_preferences_cli_set_notification(dialog, VINO_PREFS_CLI_NOTI_NEVER))
+ {
+ g_printerr(_("Notification Area, Never display an icon\n"));
+ }
+
+ break;
+
+ case '?':
+ break;
+ }
+ }
+
+ /* Print any remaining command line arguments (not options). */
+ if (optind < argc)
+ {
+ g_printerr(_("WARNING: The option don't exist: "));
+ while (optind < argc)
+ printf("%s ", argv[optind++]);
+ printf("\n");
+ }
+
+ exit(EXIT_SUCCESS);
+}
+
static void
vino_preferences_dialog_update_url_label (VinoPreferencesDialog *dialog);
@@ -107,7 +685,7 @@
matches = NULL;
result = gnome_keyring_find_network_password_sync (
- NULL, /* user */
+ NULL, /* user */
NULL, /* domain */
"vino.local", /* server */
NULL, /* object */
@@ -119,7 +697,6 @@
if (result != GNOME_KEYRING_RESULT_OK || matches == NULL || matches->data == NULL)
return NULL;
-
found_item = (GnomeKeyringNetworkPasswordData *) matches->data;
password = g_strdup (found_item->password);
@@ -160,7 +737,7 @@
static void
vino_preferences_dialog_update_for_allowed (VinoPreferencesDialog *dialog,
- gboolean allowed)
+ gboolean allowed)
{
gtk_widget_set_sensitive (dialog->prompt_enabled_toggle, allowed);
gtk_widget_set_sensitive (dialog->view_only_toggle, allowed);
@@ -174,7 +751,7 @@
gtk_widget_set_sensitive (dialog->encryption_toggle, allowed);
gtk_widget_set_sensitive (dialog->use_alternative_port_toggle, allowed);
gtk_widget_set_sensitive (dialog->alternative_port_entry, allowed &&
- gconf_client_get_bool (dialog->client, VINO_PREFS_USE_ALTERNATIVE_PORT, NULL));
+ vino_preferences_cli_get_flag (dialog, VINO_PREFS_USE_ALTERNATIVE_PORT));
gtk_widget_set_sensitive (dialog->lock_screen_toggle, allowed);
}
@@ -186,14 +763,14 @@
local_only = gtk_toggle_button_get_active (toggle);
- gconf_client_set_bool (dialog->client, VINO_PREFS_LOCAL_ONLY, local_only, NULL);
+ vino_preferences_cli_set_flag(dialog, VINO_PREFS_LOCAL_ONLY, local_only);
}
static void
-vino_preferences_dialog_local_only_notify (GConfClient *client,
- guint cnx_id,
- GConfEntry *entry,
- VinoPreferencesDialog *dialog)
+vino_preferences_dialog_local_only_notify ( GConfClient *client,
+ guint cnx_id,
+ GConfEntry *entry,
+ VinoPreferencesDialog *dialog)
{
gboolean local_only;
@@ -216,7 +793,7 @@
dialog->local_only_toggle = glade_xml_get_widget (dialog->xml, "local_only_toggle");
g_assert (dialog->local_only_toggle != NULL);
- local_only = gconf_client_get_bool (dialog->client, VINO_PREFS_LOCAL_ONLY, NULL);
+ local_only = vino_preferences_cli_get_flag (dialog, VINO_PREFS_LOCAL_ONLY);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->local_only_toggle), local_only);
@@ -241,20 +818,20 @@
static void
vino_preferences_dialog_encryption_toggled (GtkToggleButton *toggle,
- VinoPreferencesDialog *dialog)
+ VinoPreferencesDialog *dialog)
{
gboolean encryption;
encryption = gtk_toggle_button_get_active (toggle);
- gconf_client_set_bool (dialog->client, VINO_PREFS_ENCRYPTION, encryption, NULL);
+ vino_preferences_cli_set_flag (dialog, VINO_PREFS_ENCRYPTION, encryption);
}
static void
vino_preferences_dialog_encryption_notify (GConfClient *client,
- guint cnx_id,
- GConfEntry *entry,
- VinoPreferencesDialog *dialog)
+ guint cnx_id,
+ GConfEntry *entry,
+ VinoPreferencesDialog *dialog)
{
gboolean encryption;
@@ -277,7 +854,7 @@
dialog->encryption_toggle = glade_xml_get_widget (dialog->xml, "encryption_toggle");
g_assert (dialog->encryption_toggle != NULL);
- encryption = gconf_client_get_bool (dialog->client, VINO_PREFS_ENCRYPTION, NULL);
+ encryption = vino_preferences_cli_get_flag (dialog, VINO_PREFS_ENCRYPTION);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->encryption_toggle), encryption);
@@ -302,21 +879,21 @@
static void
vino_preferences_dialog_use_alternative_port_toggled (GtkToggleButton *toggle,
- VinoPreferencesDialog *dialog)
+ VinoPreferencesDialog *dialog)
{
gboolean use_alternative_port;
use_alternative_port = gtk_toggle_button_get_active (toggle);
gtk_widget_set_sensitive (dialog->alternative_port_entry, use_alternative_port);
- gconf_client_set_bool (dialog->client, VINO_PREFS_USE_ALTERNATIVE_PORT, use_alternative_port, NULL);
+ vino_preferences_cli_set_flag (dialog, VINO_PREFS_USE_ALTERNATIVE_PORT, use_alternative_port);
}
static void
vino_preferences_dialog_use_alternative_port_notify (GConfClient *client,
- guint cnx_id,
- GConfEntry *entry,
- VinoPreferencesDialog *dialog)
+ guint cnx_id,
+ GConfEntry *entry,
+ VinoPreferencesDialog *dialog)
{
gboolean use_alternative_port;
@@ -339,7 +916,7 @@
dialog->use_alternative_port_toggle = glade_xml_get_widget (dialog->xml, "use_alternative_port_toggle");
g_assert (dialog->use_alternative_port_toggle != NULL);
- use_alternative_port = gconf_client_get_bool (dialog->client, VINO_PREFS_USE_ALTERNATIVE_PORT, NULL);
+ use_alternative_port = vino_preferences_cli_get_flag (dialog, VINO_PREFS_USE_ALTERNATIVE_PORT);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->use_alternative_port_toggle), use_alternative_port);
gtk_widget_set_sensitive (dialog->alternative_port_entry, use_alternative_port);
@@ -366,7 +943,7 @@
static void
vino_preferences_dialog_alternative_port_changed (GtkSpinButton *button,
- VinoPreferencesDialog *dialog)
+ VinoPreferencesDialog *dialog)
{
gint alternative_port;
@@ -377,9 +954,9 @@
static void
vino_preferences_dialog_alternative_port_notify (GConfClient *client,
- guint cnx_id,
- GConfEntry *entry,
- VinoPreferencesDialog *dialog)
+ guint cnx_id,
+ GConfEntry *entry,
+ VinoPreferencesDialog *dialog)
{
gint alternative_port;
@@ -434,14 +1011,14 @@
lock_screen = gtk_toggle_button_get_active (toggle);
- gconf_client_set_bool (dialog->client, VINO_PREFS_LOCK_SCREEN, lock_screen, NULL);
+ vino_preferences_cli_set_flag (dialog, VINO_PREFS_LOCK_SCREEN, lock_screen);
}
static void
vino_preferences_dialog_lock_screen_notify (GConfClient *client,
- guint cnx_id,
- GConfEntry *entry,
- VinoPreferencesDialog *dialog)
+ guint cnx_id,
+ GConfEntry *entry,
+ VinoPreferencesDialog *dialog)
{
gboolean lock_screen;
@@ -464,7 +1041,7 @@
dialog->lock_screen_toggle = glade_xml_get_widget (dialog->xml, "lock_screen_toggle");
g_assert (dialog->lock_screen_toggle != NULL);
- lock_screen = gconf_client_get_bool (dialog->client, VINO_PREFS_LOCK_SCREEN, NULL);
+ lock_screen = vino_preferences_cli_get_flag (dialog, VINO_PREFS_LOCK_SCREEN);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->lock_screen_toggle), lock_screen);
@@ -489,22 +1066,20 @@
static void
vino_preferences_dialog_allowed_toggled (GtkToggleButton *toggle,
- VinoPreferencesDialog *dialog)
+ VinoPreferencesDialog *dialog)
{
gboolean allowed;
allowed = gtk_toggle_button_get_active (toggle);
-
- gconf_client_set_bool (dialog->client, VINO_PREFS_ENABLED, allowed, NULL);
-
+ vino_preferences_cli_set_flag(dialog, VINO_PREFS_ENABLED, allowed);
vino_preferences_dialog_update_for_allowed (dialog, allowed);
}
static void
vino_preferences_dialog_allowed_notify (GConfClient *client,
- guint cnx_id,
- GConfEntry *entry,
- VinoPreferencesDialog *dialog)
+ guint cnx_id,
+ GConfEntry *entry,
+ VinoPreferencesDialog *dialog)
{
gboolean allowed;
@@ -529,7 +1104,7 @@
gtk_label_set_use_markup (GTK_LABEL (GTK_BIN (dialog->allowed_toggle)->child), TRUE);
- allowed = gconf_client_get_bool (dialog->client, VINO_PREFS_ENABLED, NULL);
+ allowed = vino_preferences_cli_get_flag (dialog, VINO_PREFS_ENABLED);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->allowed_toggle), allowed);
@@ -554,19 +1129,19 @@
static void
vino_preferences_dialog_prompt_enabled_toggled (GtkToggleButton *toggle,
- VinoPreferencesDialog *dialog)
+ VinoPreferencesDialog *dialog)
{
- gconf_client_set_bool (dialog->client,
- VINO_PREFS_PROMPT_ENABLED,
- gtk_toggle_button_get_active (toggle),
- NULL);
+ vino_preferences_cli_set_flag (dialog,
+ VINO_PREFS_PROMPT_ENABLED,
+ gtk_toggle_button_get_active (toggle)
+ );
}
static void
vino_preferences_dialog_prompt_enabled_notify (GConfClient *client,
- guint cnx_id,
- GConfEntry *entry,
- VinoPreferencesDialog *dialog)
+ guint cnx_id,
+ GConfEntry *entry,
+ VinoPreferencesDialog *dialog)
{
gboolean prompt_enabled;
@@ -589,7 +1164,7 @@
dialog->prompt_enabled_toggle = glade_xml_get_widget (dialog->xml, "prompt_enabled_toggle");
g_assert (dialog->prompt_enabled_toggle != NULL);
- prompt_enabled = gconf_client_get_bool (dialog->client, VINO_PREFS_PROMPT_ENABLED, NULL);
+ prompt_enabled = vino_preferences_cli_get_flag(dialog, VINO_PREFS_PROMPT_ENABLED);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->prompt_enabled_toggle), prompt_enabled);
@@ -612,19 +1187,18 @@
static void
vino_preferences_dialog_view_only_toggled (GtkToggleButton *toggle,
- VinoPreferencesDialog *dialog)
+ VinoPreferencesDialog *dialog)
{
- gconf_client_set_bool (dialog->client,
+ vino_preferences_cli_set_flag (dialog,
VINO_PREFS_VIEW_ONLY,
- !gtk_toggle_button_get_active (toggle),
- NULL);
+ !gtk_toggle_button_get_active (toggle));
}
static void
vino_preferences_dialog_view_only_notify (GConfClient *client,
- guint cnx_id,
- GConfEntry *entry,
- VinoPreferencesDialog *dialog)
+ guint cnx_id,
+ GConfEntry *entry,
+ VinoPreferencesDialog *dialog)
{
gboolean view_only;
@@ -647,7 +1221,7 @@
dialog->view_only_toggle = glade_xml_get_widget (dialog->xml, "view_only_toggle");
g_assert (dialog->view_only_toggle != NULL);
- view_only = gconf_client_get_bool (dialog->client, VINO_PREFS_VIEW_ONLY, NULL);
+ view_only = vino_preferences_cli_get_flag (dialog, VINO_PREFS_VIEW_ONLY);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->view_only_toggle), !view_only);
@@ -670,14 +1244,14 @@
static void
vino_preferences_dialog_icon_visibility_toggled (GtkToggleButton *toggle,
- VinoPreferencesDialog *dialog)
+ VinoPreferencesDialog *dialog)
{
- gchar *value = "client";
+ gchar *value = VINO_PREFS_CLI_NOTI_CLIENT;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->icon_always_radio)))
- value = "always";
+ value = VINO_PREFS_CLI_NOTI_ALWAYS;
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->icon_never_radio)))
- value = "never";
+ value = VINO_PREFS_CLI_NOTI_NEVER;
gconf_client_set_string (dialog->client,
VINO_PREFS_ICON_VISIBILITY,
@@ -687,9 +1261,9 @@
static void
vino_preferences_dialog_icon_visibility_notify (GConfClient *client,
- guint cnx_id,
- GConfEntry *entry,
- VinoPreferencesDialog *dialog)
+ guint cnx_id,
+ GConfEntry *entry,
+ VinoPreferencesDialog *dialog)
{
const gchar *value;
@@ -697,15 +1271,14 @@
return;
value = gconf_value_get_string (entry->value);
- if (!g_ascii_strcasecmp (value, "always"))
+ if (!g_ascii_strcasecmp (value, VINO_PREFS_CLI_NOTI_ALWAYS))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->icon_always_radio), TRUE);
- else if (!g_ascii_strcasecmp (value, "client"))
+ else if (!g_ascii_strcasecmp (value, VINO_PREFS_CLI_NOTI_CLIENT))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->icon_client_radio), TRUE);
- else if (!g_ascii_strcasecmp (value, "never"))
+ else if (!g_ascii_strcasecmp (value, VINO_PREFS_CLI_NOTI_NEVER))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->icon_never_radio), TRUE);
}
-
static void
vino_preferences_dialog_setup_icon_visibility (VinoPreferencesDialog *dialog)
{
@@ -719,11 +1292,11 @@
g_assert (dialog->icon_never_radio != NULL);
value = gconf_client_get_string (dialog->client, VINO_PREFS_ICON_VISIBILITY, NULL);
- if (!g_ascii_strcasecmp (value, "always"))
+ if (!g_ascii_strcasecmp (value, VINO_PREFS_CLI_NOTI_ALWAYS))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->icon_always_radio), TRUE);
- else if (!g_ascii_strcasecmp (value, "client"))
+ else if (!g_ascii_strcasecmp (value, VINO_PREFS_CLI_NOTI_CLIENT))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->icon_client_radio), TRUE);
- else if (!g_ascii_strcasecmp (value, "never"))
+ else if (!g_ascii_strcasecmp (value, VINO_PREFS_CLI_NOTI_NEVER))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->icon_never_radio), TRUE);
g_signal_connect (dialog->icon_always_radio, "toggled",
@@ -751,33 +1324,17 @@
static void
vino_preferences_dialog_use_password_toggled (GtkToggleButton *toggle,
- VinoPreferencesDialog *dialog)
+ VinoPreferencesDialog *dialog)
{
- GSList *auth_methods = NULL;
-
- dialog->use_password = gtk_toggle_button_get_active (toggle);
-
- if (dialog->use_password)
- auth_methods = g_slist_prepend (auth_methods, "vnc");
- else
- auth_methods = g_slist_append (auth_methods, "none");
-
- gconf_client_set_list (dialog->client,
- VINO_PREFS_AUTHENTICATION_METHODS,
- GCONF_VALUE_STRING,
- auth_methods,
- NULL);
-
- g_slist_free (auth_methods);
-
- gtk_widget_set_sensitive (dialog->password_box, dialog->use_password);
+ vino_preferences_cli_set_use_password(dialog, gtk_toggle_button_get_active (toggle));
+ gtk_widget_set_sensitive (dialog->password_box, dialog->use_password);
}
static void
vino_preferences_dialog_use_password_notify (GConfClient *client,
- guint cnx_id,
- GConfEntry *entry,
- VinoPreferencesDialog *dialog)
+ guint cnx_id,
+ GConfEntry *entry,
+ VinoPreferencesDialog *dialog)
{
GSList *auth_methods, *l;
gboolean use_password;
@@ -797,7 +1354,7 @@
method = gconf_value_get_string (value);
if (!strcmp (method, "vnc"))
- use_password = TRUE;
+ use_password = TRUE;
}
if (use_password != dialog->use_password)
@@ -806,39 +1363,13 @@
}
}
-static gboolean
-vino_preferences_dialog_get_use_password (VinoPreferencesDialog *dialog)
-{
- GSList *auth_methods, *l;
- gboolean use_password;
-
- auth_methods = gconf_client_get_list (dialog->client,
- VINO_PREFS_AUTHENTICATION_METHODS,
- GCONF_VALUE_STRING,
- NULL);
-
- use_password = FALSE;
- for (l = auth_methods; l; l = l->next)
- {
- char *method = l->data;
-
- if (!strcmp (method, "vnc"))
- use_password = TRUE;
-
- g_free (method);
- }
- g_slist_free (auth_methods);
-
- return use_password;
-}
-
static void
vino_preferences_dialog_setup_password_toggle (VinoPreferencesDialog *dialog)
{
dialog->password_toggle = glade_xml_get_widget (dialog->xml, "password_toggle");
g_assert (dialog->password_toggle != NULL);
- dialog->use_password = vino_preferences_dialog_get_use_password (dialog);
+ dialog->use_password = vino_preferences_cli_get_use_password (dialog);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->password_toggle), dialog->use_password);
@@ -861,9 +1392,9 @@
static void
vino_preferences_vnc_password_notify (GConfClient *client,
- guint cnx_id,
- GConfEntry *entry,
- VinoPreferencesDialog *dialog)
+ guint cnx_id,
+ GConfEntry *entry,
+ VinoPreferencesDialog *dialog)
{
const char *password_b64;
guchar *blob;
@@ -908,7 +1439,7 @@
static void
vino_preferences_dialog_password_changed (GtkEntry *entry,
- VinoPreferencesDialog *dialog)
+ VinoPreferencesDialog *dialog)
{
const char *password;
@@ -953,7 +1484,7 @@
gsize blob_len;
char *password_b64;
- password_b64 = gconf_client_get_string (dialog->client, VINO_PREFS_VNC_PASSWORD, NULL);
+ password_b64 = vino_preferences_cli_get_password_b64(dialog);
if (password_b64 && *password_b64)
{
@@ -1240,9 +1771,9 @@
static void
vino_preferences_dialog_mailto_notify (GConfClient *client,
- guint cnx_id,
- GConfEntry *entry,
- VinoPreferencesDialog *dialog)
+ guint cnx_id,
+ GConfEntry *entry,
+ VinoPreferencesDialog *dialog)
{
const char *mailto;
@@ -1340,8 +1871,8 @@
static void
vino_preferences_dialog_response (GtkWidget *widget,
- int response,
- VinoPreferencesDialog *dialog)
+ int response,
+ VinoPreferencesDialog *dialog)
{
GError *error;
@@ -1377,7 +1908,7 @@
static void
vino_preferences_dialog_destroyed (GtkWidget *widget,
- VinoPreferencesDialog *dialog)
+ VinoPreferencesDialog *dialog)
{
dialog->dialog = NULL;
@@ -1415,9 +1946,6 @@
G_CALLBACK (vino_preferences_dialog_destroyed), dialog);
g_signal_connect (dialog->dialog, "delete_event", G_CALLBACK (gtk_true), NULL);
- dialog->client = gconf_client_get_default ();
- gconf_client_add_dir (dialog->client, VINO_PREFS_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
-
vino_preferences_dialog_setup_url_labels (dialog);
dialog->writability_warning = glade_xml_get_widget (dialog->xml, "writability_warning");
@@ -1495,19 +2023,29 @@
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE,
- argc, argv, NULL);
-
- if (!vino_preferences_dialog_init (&dialog))
- {
- vino_preferences_dialog_finalize (&dialog);
- return 1;
- }
+ vino_preferences_load_prepare(&dialog);
+ vino_preferences_start_listening (&dialog);
+
+ if( !strcmp(basename(argv[0]), "vino-preferences-cli") ||
+ (argc > 1 && !strcmp(argv[1], "--cli")))
+ {
+ vino_preferences_cli_init(&dialog, argc, argv);
+ }
+ else
+ {
+ gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE,
+ argc, argv, NULL);
- vino_preferences_start_listening (&dialog);
- gtk_main ();
+ if (!vino_preferences_dialog_init (&dialog))
+ {
+ vino_preferences_dialog_finalize (&dialog);
+ return EXIT_FAILURE;
+ }
+ gtk_main ();
+ }
+
vino_preferences_dialog_finalize (&dialog);
- return 0;
+ return EXIT_SUCCESS;
}
diff -uNr trunk.20080323/ChangeLog trunk.20080323.jorge/ChangeLog
--- trunk.20080323/ChangeLog 2008-03-23 01:54:10.000000000 -0300
+++ trunk.20080323.jorge/ChangeLog 2008-03-23 01:58:15.000000000 -0300
@@ -1,3 +1,11 @@
+2008-03-23 Jorge Pereira <jorge jorgepereira com br>
+ * configure.in,
+ * capplet/Makefile.am,
+ * capplet/vino-preferences.c:
+ Added extra new feature, advanced configuration in command line
+ interface, using paramenter "--cli" in vino-preferences or command
+ vino-preferences-cli.
+
2008-03-13 Jonh Wendell <jwendell gnome org>
* server/vino-status-icon.c (vino_status_icon_remove_client):
diff -uNr trunk.20080323/configure.in trunk.20080323.jorge/configure.in
--- trunk.20080323/configure.in 2008-03-23 01:54:10.000000000 -0300
+++ trunk.20080323.jorge/configure.in 2008-03-23 01:58:26.000000000 -0300
@@ -270,8 +270,8 @@
AC_SUBST(LIBZ)
AC_SUBST(LIBJPEG)
-AC_CHECK_HEADERS([netinet/in.h sys/time.h fcntl.h unistd.h sys/socket.h])
-AC_CHECK_FUNCS([gettimeofday])
+AC_CHECK_HEADERS([netinet/in.h sys/time.h fcntl.h unistd.h sys/socket.h getopt.h termios.h])
+AC_CHECK_FUNCS([gettimeofday getopt_long tcsetattr tcgetattr fgets])
dnl
dnl End of libvncserver stuff
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]