aboutsummaryrefslogtreecommitdiff
path: root/src/common/helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/helper.c')
-rw-r--r--src/common/helper.c118
1 files changed, 68 insertions, 50 deletions
diff --git a/src/common/helper.c b/src/common/helper.c
index e022b1cc..413795ce 100644
--- a/src/common/helper.c
+++ b/src/common/helper.c
@@ -38,9 +38,9 @@
38#endif 38#endif
39 39
40#ifdef WITH_LIBGKSU2 40#ifdef WITH_LIBGKSU2
41/*#include <libgksu/libgksu.h> 41/* Not used because libgksu2 headers have broken depends in Debian
42* commented because support is broken in Debian, 42And this is not really needed
43* and these headers are not really useful for us */ 43#include <libgksu/libgksu.h> */
44#endif 44#endif
45 45
46typedef struct 46typedef struct
@@ -516,7 +516,7 @@ GNUNET_GTK_notify (int type, const char *message, ...)
516 va_end (arg); 516 va_end (arg);
517 libnotify = notify_notification_new ("gnunet-gtk", 517 libnotify = notify_notification_new ("gnunet-gtk",
518 msg, 518 msg,
519 PACKAGNUNET_GE_DATA 519 PACKAGE_DATA
520 "/gnunet-gtk/gnunet-gtk-notify.png", 520 "/gnunet-gtk/gnunet-gtk-notify.png",
521 NULL); 521 NULL);
522 GNUNET_free (msg); 522 GNUNET_free (msg);
@@ -588,61 +588,79 @@ GNUNET_GTK_get_main_window_state ()
588 * Start gnunet-setup, asking for a password if needed 588 * Start gnunet-setup, asking for a password if needed
589 */ 589 */
590gboolean 590gboolean
591GNUNET_GTK_run_gnunet_setup (gboolean run_wizard) 591GNUNET_GTK_run_gnunet_setup (gchar *conffile, gboolean run_wizard)
592{ 592{
593 GtkWidget *mainWindow; 593 GtkWidget *mainWindow;
594 GtkWidget *messageDialog; 594 GtkWidget *messageDialog;
595 int code;
596 char *error_message;
597#ifdef WITH_LIBGKSU2
598 GError *gerror = NULL; 595 GError *gerror = NULL;
599 if (run_wizard) 596 char *error_message = NULL;
600 { 597
601 code = gksu_run ("gnunet-setup -d wizard-gtk", &gerror); 598 if (0 == ACCESS(conffile, W_OK))
602 }
603 else
604 {
605 code = gksu_run ("gnunet-setup -d", &gerror);
606 }
607 if (code && !gerror)
608 {
609 error_message =
610 GNUNET_strdup (_
611 ("GKSu encountered an unknown error running the configuration tool (gnunet-setup)."));
612 }
613 else if (code && gerror)
614 { 599 {
615 error_message = g_strdup_printf (_("GKSu returned:\n%s"), 600 if (run_wizard)
616 gerror->message); 601 {
617 g_error_free (gerror); 602 char *argv[]
603 = {"gnunet-setup", "-d", "wizard-gtk", "-c", conffile, NULL};
604 g_spawn_async (NULL, argv, NULL,
605 G_SPAWN_SEARCH_PATH|G_SPAWN_CHILD_INHERITS_STDIN,
606 NULL, NULL, NULL, &gerror);
607 }
608 else
609 {
610 char *argv[]
611 = {"gnunet-setup", "-d", "gconfig", "-c", conffile, NULL};
612 g_spawn_async (NULL, argv, NULL,
613 G_SPAWN_SEARCH_PATH|G_SPAWN_CHILD_INHERITS_STDIN,
614 NULL, NULL, NULL, &gerror);
615 }
616 if (gerror)
617 {
618 error_message = GNUNET_strdup(gerror->message);
619 g_error_free (gerror);
620 }
618 } 621 }
619 else 622 else
620 { 623#ifndef WITH_LIBGKSU2
621 error_message = NULL; 624 {
622 } 625 error_message = GNUNET_strdup(_("You don't have rights to write to the provided configuration file."));
623#elif defined(WINDOWS) 626 }
624/* FIXME: run gnunet-setup, assuming we can get the needed rights */
625 error_message = GNUNET_strdup (_("Not implemented yet!"));
626 code = TRUE;
627#else 627#else
628 error_message = 628 {
629 GNUNET_strdup (_ 629 char *commandline;
630 ("GKSu support is not enabled, impossible to get the needed rights. You should build gnunet-gtk with the --enable-libgksu2 option, or get the right binary package. Note you can still start the configuration tool (gnunet-setup) manually.")); 630
631 code = TRUE; 631 if (run_wizard)
632 {
633 commandline = g_strconcat ("gnunet-setup -d wizard-gtk -c ", conffile, NULL);
634 gksu_run (commandline, &gerror);
635 }
636 else
637 {
638 commandline = g_strconcat ("gnunet-setup -d gconfig -c ", conffile, NULL);
639 gksu_run (commandline, &gerror);
640 }
641 GNUNET_free (commandline);
642 if (gerror)
643 {
644 error_message = GNUNET_strdup(gerror->message);
645 g_error_free (gerror);
646 }
647 }
632#endif 648#endif
633 mainWindow = 649 if(error_message) {
634 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "mainWindow"); 650 mainWindow = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "mainWindow");
635 messageDialog = 651 messageDialog = gtk_message_dialog_new (GTK_WINDOW (mainWindow),
636 gtk_message_dialog_new (GTK_WINDOW (mainWindow), 652 GTK_DIALOG_MODAL |
637 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, 653 GTK_DIALOG_DESTROY_WITH_PARENT,
638 GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, 654 GTK_MESSAGE_WARNING,
639 _ 655 GTK_BUTTONS_CLOSE,
640 ("Failed to run the configuration tool (gnunet-setup): %s"), 656 _("Failed to run the configuration tool (gnunet-setup): %s"),
641 error_message); 657 error_message);
642 gtk_dialog_run (GTK_DIALOG (messageDialog)); 658 gtk_dialog_run (GTK_DIALOG (messageDialog));
643 gtk_widget_destroy (messageDialog); 659 gtk_widget_destroy (messageDialog);
644 GNUNET_free (error_message); 660 GNUNET_free (error_message);
645 return code; 661 return FALSE;
662 }
663 return TRUE;
646} 664}
647 665
648/* end of helper.c */ 666/* end of helper.c */