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.c145
1 files changed, 82 insertions, 63 deletions
diff --git a/src/plugins/daemon/daemon.c b/src/plugins/daemon/daemon.c
index 6939f37b..c0d4a4f4 100644
--- a/src/plugins/daemon/daemon.c
+++ b/src/plugins/daemon/daemon.c
@@ -29,6 +29,78 @@
29#include <GNUnet/gnunet_getoption_lib.h> 29#include <GNUnet/gnunet_getoption_lib.h>
30 30
31 31
32
33/**
34 * cron job that periodically updates the model for the
35 * application list.
36 */
37static void updateAppModelSafe(void * unused) {
38 GNUNET_TCP_SOCKET * sock;
39 GtkWidget * w;
40 GtkListStore * model;
41 GtkTreeIter iter;
42 char * apps;
43 char * next;
44 char * pos;
45 char * desc;
46
47 model = gtk_list_store_new(2,
48 G_TYPE_STRING,
49 G_TYPE_STRING);
50 sock = getClientSocket();
51 if (sock == NULL) {
52 apps = NULL;
53 } else {
54 apps
55 = getConfigurationOptionValue(sock,
56 "GNUNETD",
57 "APPLICATIONS");
58 }
59 if (apps != NULL) {
60 next = apps;
61 do {
62 while (*next == ' ')
63 next++;
64 pos = next;
65 while ( (*next != '\0') &&
66 (*next != ' ') )
67 next++;
68 if (*next == '\0') {
69 next = NULL; /* terminate! */
70 } else {
71 *next = '\0'; /* add 0-termination for pos */
72 next++;
73 }
74 if (strlen(pos) > 0) {
75 desc
76 = getConfigurationOptionValue(sock,
77 "ABOUT",
78 pos);
79
80 gtk_list_store_append(model,
81 &iter);
82 gtk_list_store_set(model,
83 &iter,
84 0, pos,
85 1, desc,
86 -1);
87 FREENONNULL(desc);
88 }
89 } while (next != NULL);
90 FREE(apps);
91 }
92 w = glade_xml_get_widget(getMainXML(),
93 "applicationList");
94 gtk_tree_view_set_model(GTK_TREE_VIEW(w),
95 GTK_TREE_MODEL(model));
96 releaseClientSocket(sock);
97}
98
99static void updateAppModel(void * dummy) {
100 gtkSaveCall(&updateAppModelSafe, NULL);
101}
102
103
32static void doUpdateMenus(void * arg) { 104static void doUpdateMenus(void * arg) {
33 int ret = *(int*) arg; 105 int ret = *(int*) arg;
34 static GtkWidget * killEntry = NULL; 106 static GtkWidget * killEntry = NULL;
@@ -62,6 +134,7 @@ static void doUpdateMenus(void * arg) {
62 isLocal = FALSE; 134 isLocal = FALSE;
63 FREENONNULL(host); 135 FREENONNULL(host);
64 } 136 }
137 updateAppModelSafe(NULL);
65 if (ret == SYSERR) { 138 if (ret == SYSERR) {
66 gtk_widget_hide(statsEntryYes); 139 gtk_widget_hide(statsEntryYes);
67 gtk_widget_show_all(statsEntryNo); 140 gtk_widget_show_all(statsEntryNo);
@@ -102,7 +175,7 @@ void on_startDaemon_clicked(GtkWidget * widget,
102 return; 175 return;
103 } else { 176 } else {
104 addLogEntry(_("Launching gnunetd...")); 177 addLogEntry(_("Launching gnunetd..."));
105 if (OK == startGNUnetDaemon(YES)) { 178 if (SYSERR != startGNUnetDaemon(YES)) {
106 addLogEntry(_("Launched gnunetd")); 179 addLogEntry(_("Launched gnunetd"));
107 } else { 180 } else {
108 addLogEntry(_("Launching gnunetd failed")); 181 addLogEntry(_("Launching gnunetd failed"));
@@ -140,67 +213,6 @@ void on_stopDaemon_clicked(GtkWidget * widget,
140 cronCheckDaemon(NULL); 213 cronCheckDaemon(NULL);
141} 214}
142 215
143
144/**
145 * cron job that periodically updates the model for the
146 * application list.
147 */
148static void updateAppModelSafe(void * unused) {
149 GNUNET_TCP_SOCKET * sock;
150 GtkWidget * w;
151 GtkListStore * model;
152 GtkTreeIter iter;
153 char * apps;
154 char * next;
155 char * pos;
156
157 model = gtk_list_store_new(1, G_TYPE_STRING);
158 sock = getClientSocket();
159 if (sock == NULL) {
160 apps = NULL;
161 } else {
162 apps
163 = getConfigurationOptionValue(sock,
164 "GNUNETD",
165 "APPLICATIONS");
166 releaseClientSocket(sock);
167 }
168 if (apps != NULL) {
169 next = apps;
170 do {
171 while (*next == ' ')
172 next++;
173 pos = next;
174 while ( (*next != '\0') &&
175 (*next != ' ') )
176 next++;
177 if (*next == '\0') {
178 next = NULL; /* terminate! */
179 } else {
180 *next = '\0'; /* add 0-termination for pos */
181 next++;
182 }
183 if (strlen(pos) > 0) {
184 gtk_list_store_append(model,
185 &iter);
186 gtk_list_store_set(model,
187 &iter,
188 0, pos,
189 -1);
190 }
191 } while (next != NULL);
192 FREE(apps);
193 }
194 w = glade_xml_get_widget(getMainXML(),
195 "applicationList");
196 gtk_tree_view_set_model(GTK_TREE_VIEW(w),
197 GTK_TREE_MODEL(model));
198}
199
200static void updateAppModel(void * dummy) {
201 gtkSaveCall(&updateAppModelSafe, NULL);
202}
203
204void init_daemon() { 216void init_daemon() {
205 GtkWidget * tab; 217 GtkWidget * tab;
206 GtkWidget * apps; 218 GtkWidget * apps;
@@ -216,10 +228,17 @@ void init_daemon() {
216 renderer = gtk_cell_renderer_text_new(); 228 renderer = gtk_cell_renderer_text_new();
217 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(apps), 229 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(apps),
218 -1, 230 -1,
219 _("Applications"), 231 _("Application"),
220 renderer, 232 renderer,
221 "text", 0, 233 "text", 0,
222 NULL); 234 NULL);
235 renderer = gtk_cell_renderer_text_new();
236 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(apps),
237 -1,
238 _("Description"),
239 renderer,
240 "text", 1,
241 NULL);
223 242
224 updateAppModelSafe(NULL); 243 updateAppModelSafe(NULL);
225 tab 244 tab