aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2005-07-07 00:24:08 +0000
committerChristian Grothoff <christian@grothoff.org>2005-07-07 00:24:08 +0000
commitf91ec886191cbee8c5c60c6459387cea7a8d785d (patch)
tree127b967611405d589f3691d4f8d0aeb0f7edb4c8
parente19fe696a4bbc6b1083225c7b909282257f22746 (diff)
downloadgnunet-gtk-f91ec886191cbee8c5c60c6459387cea7a8d785d.tar.gz
gnunet-gtk-f91ec886191cbee8c5c60c6459387cea7a8d785d.zip
app list
-rw-r--r--TODO4
-rw-r--r--src/plugins/daemon/daemon.c145
2 files changed, 84 insertions, 65 deletions
diff --git a/TODO b/TODO
index 1e9134c3..8115e013 100644
--- a/TODO
+++ b/TODO
@@ -15,10 +15,10 @@ Important (for 0.7.0):
15 * need visual feedback for collection status! 15 * need visual feedback for collection status!
16 - stop collection [ easy, CG ] 16 - stop collection [ easy, CG ]
17 * enable start collection! 17 * enable start collection!
18* list available apps [ easy, CG ] 18
19 19
20Later (0.7.1): 20Later (0.7.1):
210) stats integration [ medium ] 210) stats integration (daemon+own module for graphical stats) [ medium ]
221) auto-rename downloaded files 221) auto-rename downloaded files
23 to better names (user feedback!?) [ medium ] 23 to better names (user feedback!?) [ medium ]
242) create directory from known file IDs [ medium ] 242) create directory from known file IDs [ medium ]
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