aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/daemon/daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/daemon/daemon.c')
-rw-r--r--src/plugins/daemon/daemon.c90
1 files changed, 56 insertions, 34 deletions
diff --git a/src/plugins/daemon/daemon.c b/src/plugins/daemon/daemon.c
index 537f19c5..73d39c0e 100644
--- a/src/plugins/daemon/daemon.c
+++ b/src/plugins/daemon/daemon.c
@@ -57,7 +57,8 @@ updateAppModelSafe (void *unused)
57 apps = NULL; 57 apps = NULL;
58 sock = GNUNET_client_connection_create (ectx, cfg); 58 sock = GNUNET_client_connection_create (ectx, cfg);
59 if (sock != NULL) 59 if (sock != NULL)
60 apps = GNUNET_get_daemon_configuration_value (sock, "GNUNETD", "APPLICATIONS"); 60 apps =
61 GNUNET_get_daemon_configuration_value (sock, "GNUNETD", "APPLICATIONS");
61 if (apps != NULL) 62 if (apps != NULL)
62 { 63 {
63 next = apps; 64 next = apps;
@@ -79,7 +80,8 @@ updateAppModelSafe (void *unused)
79 } 80 }
80 if (strlen (pos) > 0) 81 if (strlen (pos) > 0)
81 { 82 {
82 desc = GNUNET_get_daemon_configuration_value (sock, "ABOUT", pos); 83 desc =
84 GNUNET_get_daemon_configuration_value (sock, "ABOUT", pos);
83 85
84 gtk_list_store_append (model, &iter); 86 gtk_list_store_append (model, &iter);
85 gtk_list_store_set (model, 87 gtk_list_store_set (model,
@@ -91,11 +93,13 @@ updateAppModelSafe (void *unused)
91 while (next != NULL); 93 while (next != NULL);
92 GNUNET_free (apps); 94 GNUNET_free (apps);
93 } 95 }
94 w = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "applicationList"); 96 w =
97 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
98 "applicationList");
95 gtk_tree_view_set_model (GTK_TREE_VIEW (w), GTK_TREE_MODEL (model)); 99 gtk_tree_view_set_model (GTK_TREE_VIEW (w), GTK_TREE_MODEL (model));
96 gtk_tree_selection_set_mode (gtk_tree_view_get_selection 100 gtk_tree_selection_set_mode (gtk_tree_view_get_selection
97 (GTK_TREE_VIEW (w)), GTK_SELECTION_NONE); 101 (GTK_TREE_VIEW (w)), GTK_SELECTION_NONE);
98 g_object_unref(model); 102 g_object_unref (model);
99 GNUNET_client_connection_destroy (sock); 103 GNUNET_client_connection_destroy (sock);
100 return NULL; 104 return NULL;
101} 105}
@@ -129,18 +133,25 @@ doUpdateMenus (void *arg)
129 if (once) 133 if (once)
130 { 134 {
131 once = 0; 135 once = 0;
132 killEntry = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "stopDaemon"); 136 killEntry =
133 launchEntry = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "startDaemon"); 137 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "stopDaemon");
134 statsEntryYes = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "statusPixmapYes"); 138 launchEntry =
135 statsEntryNo = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "statusPixmapNo"); 139 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
136 statsEntryError 140 "startDaemon");
137 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "statusPixmapError"); 141 statsEntryYes =
138 chooser 142 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
139 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), 143 "statusPixmapYes");
140 "gnunetdconfigFileChooserButton"); 144 statsEntryNo =
141 GNUNET_GC_get_configuration_value_string (cfg, 145 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
142 "NETWORK", 146 "statusPixmapNo");
143 "HOST", "localhost", &host); 147 statsEntryError =
148 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
149 "statusPixmapError");
150 chooser =
151 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
152 "gnunetdconfigFileChooserButton");
153 GNUNET_GC_get_configuration_value_string (cfg, "NETWORK", "HOST",
154 "localhost", &host);
144 if (strcmp (host, "localhost") == 0) 155 if (strcmp (host, "localhost") == 0)
145 isLocal = TRUE; 156 isLocal = TRUE;
146 else 157 else
@@ -163,8 +174,8 @@ doUpdateMenus (void *arg)
163 canStart = 0; 174 canStart = 0;
164 user = NULL; 175 user = NULL;
165 GNUNET_GC_get_configuration_value_string (dcfg, 176 GNUNET_GC_get_configuration_value_string (dcfg,
166 "GNUNETD", 177 "GNUNETD",
167 "USER", "", &user); 178 "USER", "", &user);
168 if (strlen (user) > 0) 179 if (strlen (user) > 0)
169 { 180 {
170#ifndef WINDOWS 181#ifndef WINDOWS
@@ -237,7 +248,8 @@ on_startDaemon_clicked_daemon (GtkWidget * widget, gpointer data)
237 GtkWidget *chooser; 248 GtkWidget *chooser;
238 char *fn; 249 char *fn;
239 250
240 launchEntry = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "startDaemon"); 251 launchEntry =
252 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "startDaemon");
241 gtk_widget_set_sensitive (launchEntry, FALSE); 253 gtk_widget_set_sensitive (launchEntry, FALSE);
242 if (GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg)) 254 if (GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg))
243 { 255 {
@@ -274,13 +286,15 @@ on_stopDaemon_clicked_daemon (GtkWidget * widget, gpointer data)
274 GtkWidget *killEntry = NULL; 286 GtkWidget *killEntry = NULL;
275 struct GNUNET_ClientServerConnection *sock; 287 struct GNUNET_ClientServerConnection *sock;
276 288
277 killEntry = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "stopDaemon"); 289 killEntry =
290 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "stopDaemon");
278 gtk_widget_set_sensitive (killEntry, FALSE); 291 gtk_widget_set_sensitive (killEntry, FALSE);
279 292
280 if (GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg)) 293 if (GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg))
281 { 294 {
282 sock = GNUNET_client_connection_create (ectx, cfg); 295 sock = GNUNET_client_connection_create (ectx, cfg);
283 if (GNUNET_OK != GNUNET_client_connection_request_daemon_shutdown (sock)) 296 if (GNUNET_OK !=
297 GNUNET_client_connection_request_daemon_shutdown (sock))
284 { 298 {
285 GtkWidget *dialog; 299 GtkWidget *dialog;
286 300
@@ -313,7 +327,9 @@ init_daemon (struct GNUNET_GEContext *e, struct GNUNET_GC_Configuration *c)
313 327
314 ectx = e; 328 ectx = e;
315 cfg = c; 329 cfg = c;
316 apps = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "applicationList"); 330 apps =
331 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
332 "applicationList");
317 model = gtk_list_store_new (1, G_TYPE_STRING); 333 model = gtk_list_store_new (1, G_TYPE_STRING);
318 gtk_tree_view_set_model (GTK_TREE_VIEW (apps), GTK_TREE_MODEL (model)); 334 gtk_tree_view_set_model (GTK_TREE_VIEW (apps), GTK_TREE_MODEL (model));
319 renderer = gtk_cell_renderer_text_new (); 335 renderer = gtk_cell_renderer_text_new ();
@@ -333,14 +349,16 @@ init_daemon (struct GNUNET_GEContext *e, struct GNUNET_GC_Configuration *c)
333 gtk_tree_view_column_set_resizable (gtk_tree_view_get_column 349 gtk_tree_view_column_set_resizable (gtk_tree_view_get_column
334 (GTK_TREE_VIEW (apps), col - 1), TRUE); 350 (GTK_TREE_VIEW (apps), col - 1), TRUE);
335 351
336 tab = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "daemonScrolledWindow"); 352 tab =
353 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
354 "daemonScrolledWindow");
337 gtk_widget_show (tab); 355 gtk_widget_show (tab);
338 daemon_config = NULL; 356 daemon_config = NULL;
339 GNUNET_GC_get_configuration_value_filename (cfg, 357 GNUNET_GC_get_configuration_value_filename (cfg,
340 "DAEMON", 358 "DAEMON",
341 "CONFIGFILE", 359 "CONFIGFILE",
342 GNUNET_DEFAULT_DAEMON_CONFIG_FILE, 360 GNUNET_DEFAULT_DAEMON_CONFIG_FILE,
343 &daemon_config); 361 &daemon_config);
344 if (GNUNET_YES == GNUNET_disk_file_test (NULL, daemon_config)) 362 if (GNUNET_YES == GNUNET_disk_file_test (NULL, daemon_config))
345 { 363 {
346 gtk_file_chooser_set_filename (GTK_FILE_CHOOSER 364 gtk_file_chooser_set_filename (GTK_FILE_CHOOSER
@@ -352,15 +370,16 @@ init_daemon (struct GNUNET_GEContext *e, struct GNUNET_GC_Configuration *c)
352 else 370 else
353 { 371 {
354 GNUNET_GTK_add_log_entry (_ 372 GNUNET_GTK_add_log_entry (_
355 ("Configuration file for GNUnet daemon `%s' does not exist! Run `gnunet-setup -d'."), 373 ("Configuration file for GNUnet daemon `%s' does not exist! Run `gnunet-setup -d'."),
356 daemon_config); 374 daemon_config);
357 } 375 }
358 GNUNET_free (daemon_config); 376 GNUNET_free (daemon_config);
359 377
360 cron = GNUNET_GTK_get_cron_manager (); 378 cron = GNUNET_GTK_get_cron_manager ();
361 GNUNET_cron_add_job (cron, &cronCheckDaemon, 0, 15 * GNUNET_CRON_SECONDS, NULL); 379 GNUNET_cron_add_job (cron, &cronCheckDaemon, 0, 15 * GNUNET_CRON_SECONDS,
362 GNUNET_cron_add_job (cron, 380 NULL);
363 &updateAppModel, 5 * GNUNET_CRON_MINUTES, 5 * GNUNET_CRON_MINUTES, NULL); 381 GNUNET_cron_add_job (cron, &updateAppModel, 5 * GNUNET_CRON_MINUTES,
382 5 * GNUNET_CRON_MINUTES, NULL);
364} 383}
365 384
366void 385void
@@ -368,9 +387,12 @@ done_daemon ()
368{ 387{
369 GtkWidget *w; 388 GtkWidget *w;
370 389
371 GNUNET_cron_del_job (cron, &cronCheckDaemon, 15 * GNUNET_CRON_SECONDS, NULL); 390 GNUNET_cron_del_job (cron, &cronCheckDaemon, 15 * GNUNET_CRON_SECONDS,
391 NULL);
372 GNUNET_cron_del_job (cron, &updateAppModel, 5 * GNUNET_CRON_MINUTES, NULL); 392 GNUNET_cron_del_job (cron, &updateAppModel, 5 * GNUNET_CRON_MINUTES, NULL);
373 w = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "applicationList"); 393 w =
394 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
395 "applicationList");
374 gtk_tree_view_set_model (GTK_TREE_VIEW (w), NULL); 396 gtk_tree_view_set_model (GTK_TREE_VIEW (w), NULL);
375 397
376} 398}