aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2006-12-18 00:18:20 +0000
committerChristian Grothoff <christian@grothoff.org>2006-12-18 00:18:20 +0000
commit7fe29e686c208df4ac5e95342e9e9a2e5ee6eee4 (patch)
treed85ac1fb899f3508a11b0c544221ba9339132df0
parent67bbc5bad5f8241d2a1e31e9579ac8b2f25debfa (diff)
downloadgnunet-gtk-7fe29e686c208df4ac5e95342e9e9a2e5ee6eee4.tar.gz
gnunet-gtk-7fe29e686c208df4ac5e95342e9e9a2e5ee6eee4.zip
fixing Mantis 1088
-rw-r--r--gnunet-gtk.glade146
-rw-r--r--src/plugins/daemon/Makefile.am1
-rw-r--r--src/plugins/daemon/daemon.c103
3 files changed, 236 insertions, 14 deletions
diff --git a/gnunet-gtk.glade b/gnunet-gtk.glade
index 7b793887..322716df 100644
--- a/gnunet-gtk.glade
+++ b/gnunet-gtk.glade
@@ -476,6 +476,23 @@ This release fixes downloads of files from directories. The previous version ha
476 <property name="fill">False</property> 476 <property name="fill">False</property>
477 </packing> 477 </packing>
478 </child> 478 </child>
479
480 <child>
481 <widget class="GtkImage" id="statusPixmapError">
482 <property agent="glademm" name="cxx_visibility">public</property>
483 <property name="stock">gtk-dialog-error</property>
484 <property name="icon_size">4</property>
485 <property name="xalign">0.5</property>
486 <property name="yalign">0.5</property>
487 <property name="xpad">0</property>
488 <property name="ypad">0</property>
489 </widget>
490 <packing>
491 <property name="padding">0</property>
492 <property name="expand">False</property>
493 <property name="fill">True</property>
494 </packing>
495 </child>
479 </widget> 496 </widget>
480 </child> 497 </child>
481 498
@@ -510,6 +527,72 @@ This release fixes downloads of files from directories. The previous version ha
510 </child> 527 </child>
511 528
512 <child> 529 <child>
530 <widget class="GtkHBox" id="hbox67">
531 <property name="visible">True</property>
532 <property name="homogeneous">False</property>
533 <property name="spacing">0</property>
534
535 <child>
536 <widget class="GtkLabel" id="label152">
537 <property name="visible">True</property>
538 <property name="label" translatable="yes">_configuration file that should be used when starting gnunetd:</property>
539 <property name="use_underline">True</property>
540 <property name="use_markup">False</property>
541 <property name="justify">GTK_JUSTIFY_LEFT</property>
542 <property name="wrap">False</property>
543 <property name="selectable">False</property>
544 <property name="xalign">0.5</property>
545 <property name="yalign">0.5</property>
546 <property name="xpad">5</property>
547 <property name="ypad">0</property>
548 <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
549 <property name="width_chars">-1</property>
550 <property name="single_line_mode">False</property>
551 <property name="angle">0</property>
552 </widget>
553 <packing>
554 <property name="padding">0</property>
555 <property name="expand">False</property>
556 <property name="fill">False</property>
557 </packing>
558 </child>
559
560 <child>
561 <widget class="GtkFileChooserButton" id="gnunetdconfigFileChooserButton">
562 <property name="visible">True</property>
563 <property name="title" translatable="yes">Select gnunetd configuration File</property>
564 <property name="action">GTK_FILE_CHOOSER_ACTION_OPEN</property>
565 <property name="local_only">True</property>
566 <property name="show_hidden">True</property>
567 <property name="do_overwrite_confirmation">False</property>
568 <property name="width_chars">-1</property>
569 </widget>
570 <packing>
571 <property name="padding">0</property>
572 <property name="expand">True</property>
573 <property name="fill">True</property>
574 </packing>
575 </child>
576 </widget>
577 <packing>
578 <property name="padding">0</property>
579 <property name="expand">False</property>
580 <property name="fill">True</property>
581 </packing>
582 </child>
583
584 <child>
585 <widget class="GtkHSeparator" id="hseparator1">
586 <property name="visible">True</property>
587 </widget>
588 <packing>
589 <property name="padding">0</property>
590 <property name="expand">False</property>
591 <property name="fill">False</property>
592 </packing>
593 </child>
594
595 <child>
513 <widget class="GtkFrame" id="frame1"> 596 <widget class="GtkFrame" id="frame1">
514 <property name="visible">True</property> 597 <property name="visible">True</property>
515 <property name="label_xalign">0</property> 598 <property name="label_xalign">0</property>
@@ -572,6 +655,16 @@ This release fixes downloads of files from directories. The previous version ha
572 </child> 655 </child>
573 656
574 <child> 657 <child>
658 <widget class="GtkHSeparator" id="hseparator2">
659 </widget>
660 <packing>
661 <property name="padding">0</property>
662 <property name="expand">True</property>
663 <property name="fill">False</property>
664 </packing>
665 </child>
666
667 <child>
575 <widget class="GtkFrame" id="daemonConfigFrame"> 668 <widget class="GtkFrame" id="daemonConfigFrame">
576 <property name="label_xalign">0</property> 669 <property name="label_xalign">0</property>
577 <property name="label_yalign">0.5</property> 670 <property name="label_yalign">0.5</property>
@@ -749,7 +842,7 @@ This release fixes downloads of files from directories. The previous version ha
749 <child> 842 <child>
750 <widget class="GtkLabel" id="daemonConfigLabel"> 843 <widget class="GtkLabel" id="daemonConfigLabel">
751 <property name="visible">True</property> 844 <property name="visible">True</property>
752 <property name="label" translatable="yes">&lt;b&gt;GNUnet daemon configuration&lt;/b&gt;</property> 845 <property name="label" translatable="yes">&lt;b&gt;GNUnet configuration&lt;/b&gt;</property>
753 <property name="use_underline">False</property> 846 <property name="use_underline">False</property>
754 <property name="use_markup">True</property> 847 <property name="use_markup">True</property>
755 <property name="justify">GTK_JUSTIFY_LEFT</property> 848 <property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -775,6 +868,57 @@ This release fixes downloads of files from directories. The previous version ha
775 <property name="fill">False</property> 868 <property name="fill">False</property>
776 </packing> 869 </packing>
777 </child> 870 </child>
871
872 <child>
873 <widget class="GtkHBox" id="hbox68">
874 <property name="homogeneous">False</property>
875 <property name="spacing">0</property>
876
877 <child>
878 <widget class="GtkRadioButton" id="configureClientRadioButton">
879 <property name="visible">True</property>
880 <property name="can_focus">True</property>
881 <property name="label" translatable="yes">C_onfigure client</property>
882 <property name="use_underline">True</property>
883 <property name="relief">GTK_RELIEF_NORMAL</property>
884 <property name="focus_on_click">True</property>
885 <property name="active">True</property>
886 <property name="inconsistent">False</property>
887 <property name="draw_indicator">True</property>
888 </widget>
889 <packing>
890 <property name="padding">0</property>
891 <property name="expand">True</property>
892 <property name="fill">False</property>
893 </packing>
894 </child>
895
896 <child>
897 <widget class="GtkRadioButton" id="configureDaemonRadioButton">
898 <property name="visible">True</property>
899 <property name="can_focus">True</property>
900 <property name="label" translatable="yes">Configure da_emon</property>
901 <property name="use_underline">True</property>
902 <property name="relief">GTK_RELIEF_NORMAL</property>
903 <property name="focus_on_click">True</property>
904 <property name="active">False</property>
905 <property name="inconsistent">False</property>
906 <property name="draw_indicator">True</property>
907 <property name="group">configureClientRadioButton</property>
908 </widget>
909 <packing>
910 <property name="padding">0</property>
911 <property name="expand">True</property>
912 <property name="fill">False</property>
913 </packing>
914 </child>
915 </widget>
916 <packing>
917 <property name="padding">0</property>
918 <property name="expand">False</property>
919 <property name="fill">False</property>
920 </packing>
921 </child>
778 </widget> 922 </widget>
779 </child> 923 </child>
780 </widget> 924 </widget>
diff --git a/src/plugins/daemon/Makefile.am b/src/plugins/daemon/Makefile.am
index d0a40f98..7a938a89 100644
--- a/src/plugins/daemon/Makefile.am
+++ b/src/plugins/daemon/Makefile.am
@@ -16,6 +16,7 @@ libgnunetgtkmodule_daemon_la_LIBADD = \
16 $(top_builddir)/src/common/libgnunetgtk_common.la \ 16 $(top_builddir)/src/common/libgnunetgtk_common.la \
17 -lgnunetutil \ 17 -lgnunetutil \
18 -lgnunetutil_cron \ 18 -lgnunetutil_cron \
19 -lgnunetutil_config \
19 -lgnunetgetoption_api \ 20 -lgnunetgetoption_api \
20 -lgnunetutil_network_client 21 -lgnunetutil_network_client
21libgnunetgtkmodule_daemon_la_LDFLAGS = \ 22libgnunetgtkmodule_daemon_la_LDFLAGS = \
diff --git a/src/plugins/daemon/daemon.c b/src/plugins/daemon/daemon.c
index 27b95cfd..a3d0af10 100644
--- a/src/plugins/daemon/daemon.c
+++ b/src/plugins/daemon/daemon.c
@@ -26,7 +26,9 @@
26 26
27#include "platform.h" 27#include "platform.h"
28#include "gnunetgtk_common.h" 28#include "gnunetgtk_common.h"
29#include <GNUnet/gnunet_directories.h>
29#include <GNUnet/gnunet_getoption_lib.h> 30#include <GNUnet/gnunet_getoption_lib.h>
31#include <GNUnet/gnunet_util_config_impl.h>
30#include <GNUnet/gnunet_util_cron.h> 32#include <GNUnet/gnunet_util_cron.h>
31#include <GNUnet/gnunet_util_network_client.h> 33#include <GNUnet/gnunet_util_network_client.h>
32#include <gtk/gtk.h> 34#include <gtk/gtk.h>
@@ -114,9 +116,16 @@ static void * doUpdateMenus(void * arg) {
114 static GtkWidget * launchEntry = NULL; 116 static GtkWidget * launchEntry = NULL;
115 static GtkWidget * statsEntryYes = NULL; 117 static GtkWidget * statsEntryYes = NULL;
116 static GtkWidget * statsEntryNo = NULL; 118 static GtkWidget * statsEntryNo = NULL;
119 static GtkWidget * statsEntryError = NULL;
120 static GtkWidget * chooser = NULL;
117 static int once = 1; 121 static int once = 1;
118 static int isLocal; 122 static int isLocal;
119 char * host; 123 char * host;
124 int canStart;
125 struct GC_Configuration * dcfg;
126 char * fn;
127 char * user;
128 struct passwd * pws;
120 129
121 if (once) { 130 if (once) {
122 once = 0; 131 once = 0;
@@ -132,6 +141,12 @@ static void * doUpdateMenus(void * arg) {
132 statsEntryNo 141 statsEntryNo
133 = glade_xml_get_widget(getMainXML(), 142 = glade_xml_get_widget(getMainXML(),
134 "statusPixmapNo"); 143 "statusPixmapNo");
144 statsEntryError
145 = glade_xml_get_widget(getMainXML(),
146 "statusPixmapError");
147 chooser
148 = glade_xml_get_widget(getMainXML(),
149 "gnunetdconfigFileChooserButton");
135 GC_get_configuration_value_string(cfg, 150 GC_get_configuration_value_string(cfg,
136 "NETWORK", 151 "NETWORK",
137 "HOST", 152 "HOST",
@@ -141,16 +156,53 @@ static void * doUpdateMenus(void * arg) {
141 isLocal = TRUE; 156 isLocal = TRUE;
142 else 157 else
143 isLocal = FALSE; 158 isLocal = FALSE;
144 FREENONNULL(host); 159 FREE(host);
145 } 160 }
146 updateAppModelSafe(NULL); 161 updateAppModelSafe(NULL);
147 if (ret == SYSERR) { 162 if (ret == 0) {
163 canStart = 0;
164 if ( (isLocal) &&
165 (NULL != (fn = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser)))) ) {
166 if (disk_file_test(ectx, fn) == YES) {
167 dcfg = GC_create_C_impl();
168 canStart = 1;
169 if (0 != GC_parse_configuration(dcfg, fn))
170 canStart = 0;
171 user = NULL;
172 GC_get_configuration_value_string(dcfg,
173 "GNUNETD",
174 "USER",
175 "",
176 &user);
177 if (strlen(user) > 0) {
178 if (NULL == (pws = getpwnam(user))) {
179 canStart = 0;
180 } else {
181 if (pws->pw_uid != getuid())
182 canStart = (geteuid() == 0);
183 else
184 canStart = 1;
185 }
186 }
187 FREE(user);
188 GC_free(dcfg);
189 }
190 g_free(fn);
191 }
148 gtk_widget_hide(statsEntryYes); 192 gtk_widget_hide(statsEntryYes);
149 gtk_widget_show_all(statsEntryNo);
150 gtk_widget_set_sensitive(killEntry, FALSE); 193 gtk_widget_set_sensitive(killEntry, FALSE);
151 gtk_widget_set_sensitive(launchEntry, (TRUE & isLocal) ); 194 if (canStart && isLocal) {
195 gtk_widget_set_sensitive(launchEntry, TRUE);
196 gtk_widget_show_all(statsEntryNo);
197 gtk_widget_hide(statsEntryError);
198 } else {
199 gtk_widget_set_sensitive(launchEntry, FALSE);
200 gtk_widget_show_all(statsEntryError);
201 gtk_widget_hide(statsEntryNo);
202 }
152 } else { 203 } else {
153 gtk_widget_hide(statsEntryNo); 204 gtk_widget_hide(statsEntryNo);
205 gtk_widget_hide(statsEntryError);
154 gtk_widget_show_all(statsEntryYes); 206 gtk_widget_show_all(statsEntryYes);
155 gtk_widget_set_sensitive(killEntry, TRUE); 207 gtk_widget_set_sensitive(killEntry, TRUE);
156 gtk_widget_set_sensitive(launchEntry, FALSE); 208 gtk_widget_set_sensitive(launchEntry, FALSE);
@@ -159,15 +211,14 @@ static void * doUpdateMenus(void * arg) {
159} 211}
160 212
161static void cronCheckDaemon(void * dummy) { 213static void cronCheckDaemon(void * dummy) {
162 static int last = 42;
163 int ret; 214 int ret;
164 215
165 ret = connection_test_running(ectx, 216 if (OK == connection_test_running(ectx,
166 cfg); 217 cfg))
167 if (ret != last) { 218 ret = 1;
168 last = ret; 219 else
169 gtkSaveCall(&doUpdateMenus, &ret); 220 ret = 0;
170 } 221 gtkSaveCall(&doUpdateMenus, &ret);
171} 222}
172 223
173 224
@@ -177,7 +228,9 @@ static void cronCheckDaemon(void * dummy) {
177void on_startDaemon_clicked_daemon(GtkWidget * widget, 228void on_startDaemon_clicked_daemon(GtkWidget * widget,
178 gpointer data) { 229 gpointer data) {
179 GtkWidget * launchEntry; 230 GtkWidget * launchEntry;
180 231 GtkWidget * chooser;
232 char * fn;
233
181 launchEntry 234 launchEntry
182 = glade_xml_get_widget(getMainXML(), 235 = glade_xml_get_widget(getMainXML(),
183 "startDaemon"); 236 "startDaemon");
@@ -188,14 +241,21 @@ void on_startDaemon_clicked_daemon(GtkWidget * widget,
188 return; 241 return;
189 } else { 242 } else {
190 addLogEntry(_("Launching gnunetd...")); 243 addLogEntry(_("Launching gnunetd..."));
244 chooser
245 = glade_xml_get_widget(getMainXML(),
246 "gnunetdconfigFileChooserButton");
247 fn = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser));
248 GE_BREAK(ectx, fn != NULL);
191 if (SYSERR != os_daemon_start(ectx, 249 if (SYSERR != os_daemon_start(ectx,
192 cfg, 250 cfg,
193 NULL, /* fixme: cfgFile */ 251 fn,
194 YES)) { 252 YES)) {
195 addLogEntry(_("Launched gnunetd")); 253 addLogEntry(_("Launched gnunetd"));
196 } else { 254 } else {
197 addLogEntry(_("Launching gnunetd failed")); 255 addLogEntry(_("Launching gnunetd failed"));
198 } 256 }
257 if (fn != NULL)
258 g_free(fn);
199 } 259 }
200} 260}
201 261
@@ -242,6 +302,7 @@ void init_daemon(struct GE_Context * e,
242 GtkListStore * model; 302 GtkListStore * model;
243 GtkCellRenderer * renderer; 303 GtkCellRenderer * renderer;
244 int col; 304 int col;
305 char * daemon_config;
245 306
246 ectx = e; 307 ectx = e;
247 cfg = c; 308 cfg = c;
@@ -277,6 +338,22 @@ void init_daemon(struct GE_Context * e,
277 = glade_xml_get_widget(getMainXML(), 338 = glade_xml_get_widget(getMainXML(),
278 "daemonScrolledWindow"); 339 "daemonScrolledWindow");
279 gtk_widget_show(tab); 340 gtk_widget_show(tab);
341 daemon_config = NULL;
342 GC_get_configuration_value_filename(cfg,
343 "DAEMON",
344 "CONFIGFILE",
345 DEFAULT_DAEMON_CONFIG_FILE,
346 &daemon_config);
347 if (YES == disk_file_test(NULL, daemon_config)) {
348 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(glade_xml_get_widget(getMainXML(),
349 "gnunetdconfigFileChooserButton")),
350 daemon_config);
351 } else {
352 addLogEntry(_("Configuration file for GNUnet daemon `%s' does not exist! Run `gnunet-setup -d'."),
353 daemon_config);
354 }
355 FREE(daemon_config);
356
280 cron = cron_create(ectx); 357 cron = cron_create(ectx);
281 cron_add_job(cron, 358 cron_add_job(cron,
282 &cronCheckDaemon, 359 &cronCheckDaemon,