diff options
author | Christian Grothoff <christian@grothoff.org> | 2006-10-29 21:57:35 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2006-10-29 21:57:35 +0000 |
commit | ff49f834ef18690d06cd83fbcbc2fe0b3392c4ba (patch) | |
tree | 044d20e88ef424320839c6aa29b29b7d152c1b91 | |
parent | 965c66fafda17b192e30bfbf1c547144de1e6dc6 (diff) | |
download | gnunet-gtk-ff49f834ef18690d06cd83fbcbc2fe0b3392c4ba.tar.gz gnunet-gtk-ff49f834ef18690d06cd83fbcbc2fe0b3392c4ba.zip |
first half of upload refactoring done
-rw-r--r-- | src/plugins/fs/collection.c | 13 | ||||
-rw-r--r-- | src/plugins/fs/collection.h | 5 | ||||
-rw-r--r-- | src/plugins/fs/fs.c | 213 | ||||
-rw-r--r-- | src/plugins/fs/fs.h | 41 | ||||
-rw-r--r-- | src/plugins/fs/meta.h | 2 | ||||
-rw-r--r-- | src/plugins/fs/namespace.c | 10 | ||||
-rw-r--r-- | src/plugins/fs/namespace.h | 5 | ||||
-rw-r--r-- | src/plugins/fs/upload.c | 220 | ||||
-rw-r--r-- | src/plugins/fs/upload.h | 41 |
9 files changed, 318 insertions, 232 deletions
diff --git a/src/plugins/fs/collection.c b/src/plugins/fs/collection.c index 712c777d..886ea3c1 100644 --- a/src/plugins/fs/collection.c +++ b/src/plugins/fs/collection.c | |||
@@ -35,10 +35,6 @@ | |||
35 | 35 | ||
36 | static GladeXML * metaXML; | 36 | static GladeXML * metaXML; |
37 | 37 | ||
38 | static struct GE_Context * ectx; | ||
39 | |||
40 | static struct GC_Configuration * cfg; | ||
41 | |||
42 | void on_collectionDialogMetaDataAddButton_clicked_fs(gpointer dummy, | 38 | void on_collectionDialogMetaDataAddButton_clicked_fs(gpointer dummy, |
43 | GtkWidget * uploadButton) { | 39 | GtkWidget * uploadButton) { |
44 | handleMetaDataListUpdate(metaXML, | 40 | handleMetaDataListUpdate(metaXML, |
@@ -168,12 +164,9 @@ void deleteCollection_clicked_fs(GtkWidget * dummy1, | |||
168 | } | 164 | } |
169 | } | 165 | } |
170 | 166 | ||
171 | void fs_collection_start(struct GE_Context * e, | 167 | void fs_collection_start() { |
172 | struct GC_Configuration * c) { | ||
173 | GtkWidget * w; | 168 | GtkWidget * w; |
174 | 169 | ||
175 | ectx = e; | ||
176 | cfg = c; | ||
177 | if (NULL != CO_getCollection(ectx, | 170 | if (NULL != CO_getCollection(ectx, |
178 | cfg)) | 171 | cfg)) |
179 | w = glade_xml_get_widget(getMainXML(), | 172 | w = glade_xml_get_widget(getMainXML(), |
@@ -184,8 +177,4 @@ void fs_collection_start(struct GE_Context * e, | |||
184 | gtk_widget_set_sensitive(w, FALSE); | 177 | gtk_widget_set_sensitive(w, FALSE); |
185 | } | 178 | } |
186 | 179 | ||
187 | void fs_collection_stop() { | ||
188 | /* nothing to do */ | ||
189 | } | ||
190 | |||
191 | /* end of collection.c */ | 180 | /* end of collection.c */ |
diff --git a/src/plugins/fs/collection.h b/src/plugins/fs/collection.h index 2c8f712c..0e4ba1e7 100644 --- a/src/plugins/fs/collection.h +++ b/src/plugins/fs/collection.h | |||
@@ -29,9 +29,6 @@ | |||
29 | 29 | ||
30 | #include <GNUnet/gnunet_util.h> | 30 | #include <GNUnet/gnunet_util.h> |
31 | 31 | ||
32 | void fs_collection_start(struct GE_Context * ectx, | 32 | void fs_collection_start(void); |
33 | struct GC_Configuration * cfg); | ||
34 | |||
35 | void fs_collection_stop(void); | ||
36 | 33 | ||
37 | #endif | 34 | #endif |
diff --git a/src/plugins/fs/fs.c b/src/plugins/fs/fs.c index edd2e045..be00afa7 100644 --- a/src/plugins/fs/fs.c +++ b/src/plugins/fs/fs.c | |||
@@ -42,29 +42,25 @@ SearchList * search_head; | |||
42 | 42 | ||
43 | DownloadList * download_head; | 43 | DownloadList * download_head; |
44 | 44 | ||
45 | UploadList * upload_head; | ||
46 | |||
45 | GtkListStore * search_summary; | 47 | GtkListStore * search_summary; |
46 | 48 | ||
47 | GtkTreeStore * download_summary; | 49 | GtkTreeStore * download_summary; |
48 | 50 | ||
49 | typedef struct { | 51 | GtkTreeStore * upload_summary; |
50 | const FSUI_Event * event; | ||
51 | void * ret; | ||
52 | } SEP_Closure; | ||
53 | 52 | ||
54 | static void saveEventProcessor(void * arg) { | 53 | static void * eventProcessor(void * unused, |
55 | SEP_Closure * cls = arg; | 54 | const FSUI_Event * event) { |
56 | const FSUI_Event * event = cls->event; | 55 | void * ret = NULL; |
57 | |||
58 | cls->ret = NULL; | ||
59 | DEBUG_BEGIN(); | ||
60 | switch (event->type) { | 56 | switch (event->type) { |
61 | /* search events */ | 57 | /* search events */ |
62 | case FSUI_search_started: | 58 | case FSUI_search_started: |
63 | cls->ret = fs_search_started(event->data.SearchStarted.sc.pos, | 59 | ret = fs_search_started(event->data.SearchStarted.sc.pos, |
64 | event->data.SearchStarted.searchURI, | 60 | event->data.SearchStarted.searchURI, |
65 | event->data.SearchStarted.anonymityLevel, | 61 | event->data.SearchStarted.anonymityLevel, |
66 | 0, | 62 | 0, |
67 | NULL); | 63 | NULL); |
68 | break; | 64 | break; |
69 | case FSUI_search_result: | 65 | case FSUI_search_result: |
70 | fs_search_result_received(event->data.SearchResult.sc.cctx, | 66 | fs_search_result_received(event->data.SearchResult.sc.cctx, |
@@ -85,11 +81,11 @@ static void saveEventProcessor(void * arg) { | |||
85 | fs_search_aborted(event->data.SearchSuspended.sc.cctx); | 81 | fs_search_aborted(event->data.SearchSuspended.sc.cctx); |
86 | break; | 82 | break; |
87 | case FSUI_search_resumed: | 83 | case FSUI_search_resumed: |
88 | cls->ret = fs_search_started(event->data.SearchResumed.sc.pos, | 84 | ret = fs_search_started(event->data.SearchResumed.sc.pos, |
89 | event->data.SearchResumed.searchURI, | 85 | event->data.SearchResumed.searchURI, |
90 | event->data.SearchResumed.anonymityLevel, | 86 | event->data.SearchResumed.anonymityLevel, |
91 | event->data.SearchResumed.fisSize, | 87 | event->data.SearchResumed.fisSize, |
92 | event->data.SearchResumed.fis); | 88 | event->data.SearchResumed.fis); |
93 | case FSUI_search_stopped: | 89 | case FSUI_search_stopped: |
94 | fs_search_aborted(event->data.SearchError.sc.cctx); | 90 | fs_search_aborted(event->data.SearchError.sc.cctx); |
95 | break; | 91 | break; |
@@ -117,56 +113,68 @@ static void saveEventProcessor(void * arg) { | |||
117 | case FSUI_download_stopped: | 113 | case FSUI_download_stopped: |
118 | fs_download_stopped(event->data.DownloadCompleted.dc.cctx); | 114 | fs_download_stopped(event->data.DownloadCompleted.dc.cctx); |
119 | break; | 115 | break; |
120 | case FSUI_download_started: | 116 | case FSUI_download_started: |
121 | cls->ret = fs_download_started(event->data.DownloadStarted.dc.pos, | 117 | ret = fs_download_started(event->data.DownloadStarted.dc.pos, |
122 | event->data.DownloadStarted.dc.pcctx, | 118 | event->data.DownloadStarted.dc.pcctx, |
123 | event->data.DownloadStarted.dc.sctx, | 119 | event->data.DownloadStarted.dc.sctx, |
124 | event->data.DownloadStarted.total, | 120 | event->data.DownloadStarted.total, |
125 | event->data.DownloadStarted.anonymityLevel, | 121 | event->data.DownloadStarted.anonymityLevel, |
126 | &event->data.DownloadStarted.fi, | 122 | &event->data.DownloadStarted.fi, |
127 | event->data.DownloadStarted.filename, | 123 | event->data.DownloadStarted.filename, |
128 | 0, | 124 | 0, |
129 | get_time()); | 125 | get_time()); |
130 | break; | 126 | break; |
131 | case FSUI_download_resumed: | 127 | case FSUI_download_resumed: |
132 | cls->ret = fs_download_started(event->data.DownloadResumed.dc.pos, | 128 | ret = fs_download_started(event->data.DownloadResumed.dc.pos, |
133 | event->data.DownloadStarted.dc.pcctx, | 129 | event->data.DownloadStarted.dc.pcctx, |
134 | event->data.DownloadStarted.dc.sctx, | 130 | event->data.DownloadStarted.dc.sctx, |
135 | event->data.DownloadResumed.total, | 131 | event->data.DownloadResumed.total, |
136 | event->data.DownloadResumed.anonymityLevel, | 132 | event->data.DownloadResumed.anonymityLevel, |
137 | &event->data.DownloadResumed.fi, | 133 | &event->data.DownloadResumed.fi, |
138 | event->data.DownloadResumed.filename, | 134 | event->data.DownloadResumed.filename, |
139 | event->data.DownloadResumed.completed, | 135 | event->data.DownloadResumed.completed, |
140 | event->data.DownloadResumed.eta); | 136 | event->data.DownloadResumed.eta); |
141 | break; | 137 | break; |
142 | 138 | ||
143 | 139 | /* upload events */ | |
144 | /* upload */ | ||
145 | case FSUI_upload_progress: | 140 | case FSUI_upload_progress: |
146 | displayUploadUpdate(event->data.UploadProgress.uc.cctx, | 141 | fs_upload_update(event->data.UploadProgress.uc.cctx, |
147 | event->data.UploadProgress.filename, | 142 | event->data.UploadProgress.completed); |
148 | event->data.UploadProgress.completed, | ||
149 | event->data.UploadProgress.total); | ||
150 | break; | 143 | break; |
151 | case FSUI_upload_completed: | 144 | case FSUI_upload_completed: |
152 | displayUploadComplete(event->data.UploadCompleted.uc.cctx, | 145 | fs_upload_complete(event->data.UploadCompleted.uc.cctx, |
153 | event->data.UploadCompleted.filename, | 146 | event->data.UploadCompleted.uri); |
154 | event->data.UploadCompleted.uri); | ||
155 | addLogEntry(_("Upload `%s' complete"), | ||
156 | event->data.UploadCompleted.filename); | ||
157 | gnunetgtk_notify(NOTIFY_NORMAL, | ||
158 | _("Upload `%s' complete"), | ||
159 | event->data.UploadCompleted.filename); | ||
160 | break; | 147 | break; |
161 | case FSUI_upload_error: | 148 | case FSUI_upload_error: |
162 | GE_LOG(ectx, | 149 | fs_upload_error(event->data.UploadError.uc.cctx); |
163 | GE_ERROR, | 150 | break; |
164 | _("Error while uploading: %s\n"), | 151 | case FSUI_upload_aborted: |
165 | event->data.UploadError.message); | 152 | fs_upload_error(event->data.UploadAborted.uc.cctx); |
166 | gnunetgtk_notify(NOTIFY_NORMAL, | 153 | break; |
167 | _("Error while uploading `%s'"), | 154 | case FSUI_upload_stopped: |
168 | event->data.UploadError.message); | 155 | fs_upload_stopped(event->data.UploadStopped.uc.cctx); |
156 | break; | ||
157 | case FSUI_upload_suspended: | ||
158 | fs_upload_stopped(event->data.UploadSuspended.uc.cctx); | ||
159 | break; | ||
160 | case FSUI_upload_started: | ||
161 | ret = fs_upload_started(event->data.UploadStarted.uc.pos, | ||
162 | event->data.UploadStarted.uc.pcctx, | ||
163 | event->data.UploadStarted.filename, | ||
164 | NULL, | ||
165 | event->data.UploadStarted.total, | ||
166 | 0); | ||
169 | break; | 167 | break; |
168 | case FSUI_upload_resumed: | ||
169 | ret = fs_upload_started(event->data.UploadResumed.uc.pos, | ||
170 | event->data.UploadResumed.uc.pcctx, | ||
171 | event->data.UploadResumed.filename, | ||
172 | NULL, /* FIXME: maybe completed!? */ | ||
173 | event->data.UploadResumed.total, | ||
174 | event->data.UploadResumed.completed); | ||
175 | break; | ||
176 | |||
177 | /* TODO: unindex events */ | ||
170 | default: | 178 | default: |
171 | GE_BREAK(ectx, 0); | 179 | GE_BREAK(ectx, 0); |
172 | GE_LOG(ectx, | 180 | GE_LOG(ectx, |
@@ -175,38 +183,26 @@ static void saveEventProcessor(void * arg) { | |||
175 | event->type); | 183 | event->type); |
176 | break; | 184 | break; |
177 | } | 185 | } |
178 | DEBUG_END(); | 186 | return ret; |
179 | } | ||
180 | |||
181 | /** | ||
182 | * FSUI event handler. | ||
183 | */ | ||
184 | static void * eventProcessor(void * unused, | ||
185 | const FSUI_Event * event) { | ||
186 | SEP_Closure cls; | ||
187 | |||
188 | cls.event = event; | ||
189 | cls.ret = NULL; | ||
190 | gtkSaveCall(&saveEventProcessor, | ||
191 | &cls); | ||
192 | return cls.ret; | ||
193 | } | 187 | } |
194 | 188 | ||
195 | 189 | ||
196 | |||
197 | /** | 190 | /** |
198 | * Setup the summary views (in particular the models | 191 | * Setup the summary views (in particular the models |
199 | * and the renderers). | 192 | * and the renderers). |
200 | */ | 193 | */ |
201 | static void fs_summary_start() { | 194 | static void fs_summary_start() { |
202 | GtkComboBoxEntry * searchCB; | 195 | GtkComboBoxEntry * searchCB; |
196 | GtkWidget * uploadEntry; | ||
203 | GtkTreeView * searchList; | 197 | GtkTreeView * searchList; |
204 | GtkTreeView * downloadList; | 198 | GtkTreeView * downloadList; |
199 | GtkTreeView * uploadList; | ||
205 | GtkListStore * model; | 200 | GtkListStore * model; |
206 | GtkCellRenderer * renderer; | 201 | GtkCellRenderer * renderer; |
207 | GtkTreeViewColumn * column; | 202 | GtkTreeViewColumn * column; |
208 | int col; | 203 | int col; |
209 | 204 | ||
205 | /* search namespace selection setup */ | ||
210 | searchCB | 206 | searchCB |
211 | = GTK_COMBO_BOX_ENTRY(glade_xml_get_widget(getMainXML(), | 207 | = GTK_COMBO_BOX_ENTRY(glade_xml_get_widget(getMainXML(), |
212 | "fssearchKeywordComboBoxEntry")); | 208 | "fssearchKeywordComboBoxEntry")); |
@@ -221,6 +217,8 @@ static void fs_summary_start() { | |||
221 | GTK_TREE_MODEL(model)); | 217 | GTK_TREE_MODEL(model)); |
222 | gtk_combo_box_entry_set_text_column(searchCB, | 218 | gtk_combo_box_entry_set_text_column(searchCB, |
223 | NS_SEARCH_DESCRIPTION); | 219 | NS_SEARCH_DESCRIPTION); |
220 | |||
221 | /* search summary setup */ | ||
224 | searchList = GTK_TREE_VIEW(glade_xml_get_widget(getMainXML(), | 222 | searchList = GTK_TREE_VIEW(glade_xml_get_widget(getMainXML(), |
225 | "activeSearchesSummary")); | 223 | "activeSearchesSummary")); |
226 | search_summary = | 224 | search_summary = |
@@ -262,7 +260,7 @@ static void fs_summary_start() { | |||
262 | gtk_tree_view_column_set_sort_column_id(column, SEARCH_SUMMARY_RESULT_COUNT); | 260 | gtk_tree_view_column_set_sort_column_id(column, SEARCH_SUMMARY_RESULT_COUNT); |
263 | gtk_tree_view_column_set_resizable(column, TRUE); | 261 | gtk_tree_view_column_set_resizable(column, TRUE); |
264 | 262 | ||
265 | 263 | /* download summary setup */ | |
266 | downloadList = GTK_TREE_VIEW(glade_xml_get_widget(getMainXML(), | 264 | downloadList = GTK_TREE_VIEW(glade_xml_get_widget(getMainXML(), |
267 | "activeDownloadsList")); | 265 | "activeDownloadsList")); |
268 | download_summary = | 266 | download_summary = |
@@ -324,10 +322,56 @@ static void fs_summary_start() { | |||
324 | gtk_tree_view_column_set_reorderable(column, TRUE); | 322 | gtk_tree_view_column_set_reorderable(column, TRUE); |
325 | /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/ | 323 | /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/ |
326 | gtk_tree_view_column_set_resizable(column, TRUE); | 324 | gtk_tree_view_column_set_resizable(column, TRUE); |
325 | |||
326 | /* upload summary setup */ | ||
327 | uploadList = GTK_TREE_VIEW(glade_xml_get_widget(getMainXML(), | ||
328 | "activeUploadsList")); | ||
329 | upload_summary = | ||
330 | gtk_tree_store_new(UPLOAD_NUM, | ||
331 | G_TYPE_STRING, /* filename */ | ||
332 | G_TYPE_INT, /* progress */ | ||
333 | G_TYPE_STRING, | ||
334 | G_TYPE_POINTER); /* URI (as string) - after completion */ | ||
335 | gtk_tree_view_set_model(uploadList, | ||
336 | GTK_TREE_MODEL(upload_summary)); | ||
337 | gtk_tree_selection_set_mode(gtk_tree_view_get_selection(uploadList), | ||
338 | GTK_SELECTION_MULTIPLE); | ||
339 | renderer = gtk_cell_renderer_progress_new(); | ||
340 | col = gtk_tree_view_insert_column_with_attributes(uploadList, | ||
341 | -1, | ||
342 | _("Filename"), | ||
343 | renderer, | ||
344 | "text", UPLOAD_FILENAME, | ||
345 | "value", UPLOAD_PROGRESS, | ||
346 | NULL); | ||
347 | gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(uploadList, | ||
348 | col - 1), | ||
349 | TRUE); | ||
350 | renderer = gtk_cell_renderer_text_new(); | ||
351 | col = gtk_tree_view_insert_column_with_attributes(uploadList, | ||
352 | -1, | ||
353 | _("URI"), | ||
354 | renderer, | ||
355 | "text", UPLOAD_URISTRING, | ||
356 | NULL); | ||
357 | gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(uploadList, | ||
358 | col - 1), | ||
359 | TRUE); | ||
360 | |||
361 | /* upload entry setup */ | ||
362 | uploadEntry | ||
363 | = glade_xml_get_widget(getMainXML(), | ||
364 | "uploadFilenameComboBoxEntry"); | ||
365 | |||
366 | model = gtk_list_store_new(1, G_TYPE_STRING); | ||
367 | gtk_combo_box_set_model(GTK_COMBO_BOX(uploadEntry), | ||
368 | GTK_TREE_MODEL(model)); | ||
369 | gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(uploadEntry), | ||
370 | 0); | ||
327 | } | 371 | } |
328 | 372 | ||
329 | /** | 373 | /** |
330 | * Shutdown. | 374 | * Shutdown the summary dialogs. |
331 | */ | 375 | */ |
332 | static void fs_summary_stop() { | 376 | static void fs_summary_stop() { |
333 | GtkComboBox * searchCB; | 377 | GtkComboBox * searchCB; |
@@ -343,8 +387,6 @@ static void fs_summary_stop() { | |||
343 | 387 | ||
344 | 388 | ||
345 | 389 | ||
346 | |||
347 | |||
348 | void init_fs(struct GE_Context * e, | 390 | void init_fs(struct GE_Context * e, |
349 | struct GC_Configuration * c) { | 391 | struct GC_Configuration * c) { |
350 | GtkWidget * tab; | 392 | GtkWidget * tab; |
@@ -366,14 +408,13 @@ void init_fs(struct GE_Context * e, | |||
366 | ctx = FSUI_start(ectx, | 408 | ctx = FSUI_start(ectx, |
367 | cfg, | 409 | cfg, |
368 | "gnunet-gtk", | 410 | "gnunet-gtk", |
369 | 128, | 411 | 128, /* FIXME: allow user to configure download parallelism */ |
370 | YES, | 412 | YES, |
371 | &eventProcessor, | 413 | &eventProcessor, |
372 | NULL); | 414 | NULL); |
373 | fs_collection_start(ectx, cfg); | 415 | fs_collection_start(); |
374 | fs_summary_start(); | 416 | fs_summary_start(); |
375 | fs_upload_start(ectx, cfg); | 417 | fs_namespace_start(); |
376 | fs_namespace_start(ectx, cfg); | ||
377 | } | 418 | } |
378 | 419 | ||
379 | void done_fs() { | 420 | void done_fs() { |
@@ -384,9 +425,7 @@ void done_fs() { | |||
384 | "fsnotebook"); | 425 | "fsnotebook"); |
385 | gtk_widget_hide(tab); | 426 | gtk_widget_hide(tab); |
386 | fs_summary_stop(); | 427 | fs_summary_stop(); |
387 | fs_collection_stop(); | ||
388 | fs_namespace_stop(); | 428 | fs_namespace_stop(); |
389 | fs_upload_stop(); | ||
390 | FSUI_stop(ctx); | 429 | FSUI_stop(ctx); |
391 | } | 430 | } |
392 | 431 | ||
diff --git a/src/plugins/fs/fs.h b/src/plugins/fs/fs.h index 24a638a1..39ff7c1d 100644 --- a/src/plugins/fs/fs.h +++ b/src/plugins/fs/fs.h | |||
@@ -73,6 +73,9 @@ enum { | |||
73 | SEARCH_SUMMARY_NUM | 73 | SEARCH_SUMMARY_NUM |
74 | }; | 74 | }; |
75 | 75 | ||
76 | /** | ||
77 | * Entry in download summary. | ||
78 | */ | ||
76 | enum { | 79 | enum { |
77 | DOWNLOAD_FILENAME = 0, | 80 | DOWNLOAD_FILENAME = 0, |
78 | DOWNLOAD_SHORTNAME, | 81 | DOWNLOAD_SHORTNAME, |
@@ -109,11 +112,14 @@ enum { | |||
109 | IN_NAMESPACE_NUM | 112 | IN_NAMESPACE_NUM |
110 | }; | 113 | }; |
111 | 114 | ||
112 | 115 | /** | |
116 | * Entry in upload summary. | ||
117 | */ | ||
113 | enum { | 118 | enum { |
114 | UPLOAD_FILENAME = 0, | 119 | UPLOAD_FILENAME = 0, |
115 | UPLOAD_PROGRESS, | 120 | UPLOAD_PROGRESS, |
116 | UPLOAD_URISTRING, | 121 | UPLOAD_URISTRING, |
122 | UPLOAD_INTERNAL, | ||
117 | UPLOAD_NUM | 123 | UPLOAD_NUM |
118 | }; | 124 | }; |
119 | 125 | ||
@@ -249,6 +255,35 @@ typedef struct DL { | |||
249 | 255 | ||
250 | } DownloadList; | 256 | } DownloadList; |
251 | 257 | ||
258 | typedef struct UL { | ||
259 | struct UL * next; | ||
260 | |||
261 | /** | ||
262 | * Which file or directory are we uploading? | ||
263 | */ | ||
264 | char * filename; | ||
265 | |||
266 | /** | ||
267 | * Path in the summary view for this download. | ||
268 | */ | ||
269 | GtkTreeRowReference * summaryViewRowReference; | ||
270 | |||
271 | struct FSUI_UploadList * fsui_list; | ||
272 | |||
273 | /** | ||
274 | * Set to final URI upon successful completion. | ||
275 | */ | ||
276 | struct ECRS_URI * uri; | ||
277 | |||
278 | /** | ||
279 | * Total size of the upload. | ||
280 | */ | ||
281 | unsigned long long total; | ||
282 | |||
283 | int has_terminated; | ||
284 | |||
285 | } UploadList; | ||
286 | |||
252 | extern struct FSUI_Context * ctx; | 287 | extern struct FSUI_Context * ctx; |
253 | 288 | ||
254 | extern struct GE_Context * ectx; | 289 | extern struct GE_Context * ectx; |
@@ -259,10 +294,12 @@ extern SearchList * search_head; | |||
259 | 294 | ||
260 | extern DownloadList * download_head; | 295 | extern DownloadList * download_head; |
261 | 296 | ||
297 | extern UploadList * upload_head; | ||
298 | |||
262 | extern GtkListStore * search_summary; | 299 | extern GtkListStore * search_summary; |
263 | 300 | ||
264 | extern GtkTreeStore * download_summary; | 301 | extern GtkTreeStore * download_summary; |
265 | 302 | ||
266 | 303 | extern GtkTreeStore * upload_summary; | |
267 | 304 | ||
268 | #endif | 305 | #endif |
diff --git a/src/plugins/fs/meta.h b/src/plugins/fs/meta.h index 97fd8f64..5852d79f 100644 --- a/src/plugins/fs/meta.h +++ b/src/plugins/fs/meta.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2005 Christian Grothoff (and other contributing authors) | 3 | (C) 2005, 2006 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
diff --git a/src/plugins/fs/namespace.c b/src/plugins/fs/namespace.c index 3b6e708f..37e6b99f 100644 --- a/src/plugins/fs/namespace.c +++ b/src/plugins/fs/namespace.c | |||
@@ -55,10 +55,6 @@ static NamespaceList * head; | |||
55 | 55 | ||
56 | static GladeXML * metaXML; | 56 | static GladeXML * metaXML; |
57 | 57 | ||
58 | static struct GE_Context * ectx; | ||
59 | |||
60 | static struct GC_Configuration * cfg; | ||
61 | |||
62 | static GtkWidget * makeNamespaceFrame(GtkWidget ** treeview, | 58 | static GtkWidget * makeNamespaceFrame(GtkWidget ** treeview, |
63 | GtkWidget ** anonSpin) { | 59 | GtkWidget ** anonSpin) { |
64 | GtkWidget * window; | 60 | GtkWidget * window; |
@@ -1353,8 +1349,7 @@ void on_searchNamespaceComboBoxEntry_changed_fs(GtkWidget * dummy, | |||
1353 | 1349 | ||
1354 | 1350 | ||
1355 | 1351 | ||
1356 | void fs_namespace_start(struct GE_Context * e, | 1352 | void fs_namespace_start() { |
1357 | struct GC_Configuration * c) { | ||
1358 | GtkWidget * contentList; | 1353 | GtkWidget * contentList; |
1359 | GtkListStore * model; | 1354 | GtkListStore * model; |
1360 | GtkCellRenderer * renderer; | 1355 | GtkCellRenderer * renderer; |
@@ -1362,8 +1357,6 @@ void fs_namespace_start(struct GE_Context * e, | |||
1362 | GtkTreeViewColumn * column; | 1357 | GtkTreeViewColumn * column; |
1363 | int col; | 1358 | int col; |
1364 | 1359 | ||
1365 | ectx = e; | ||
1366 | cfg = c; | ||
1367 | DEBUG_BEGIN(); | 1360 | DEBUG_BEGIN(); |
1368 | trackCheckButton | 1361 | trackCheckButton |
1369 | = glade_xml_get_widget(getMainXML(), | 1362 | = glade_xml_get_widget(getMainXML(), |
@@ -1508,6 +1501,7 @@ void on_localNamespacesNotebook_destroy_fs(GtkWidget * dummy1, | |||
1508 | #endif | 1501 | #endif |
1509 | 1502 | ||
1510 | void fs_namespace_stop() { | 1503 | void fs_namespace_stop() { |
1504 | /* FIXME: free resources! */ | ||
1511 | } | 1505 | } |
1512 | 1506 | ||
1513 | /* end of namespace.c */ | 1507 | /* end of namespace.c */ |
diff --git a/src/plugins/fs/namespace.h b/src/plugins/fs/namespace.h index 50e1b258..c2260f29 100644 --- a/src/plugins/fs/namespace.h +++ b/src/plugins/fs/namespace.h | |||
@@ -27,10 +27,7 @@ | |||
27 | #ifndef GTK_NAMESPACE_H | 27 | #ifndef GTK_NAMESPACE_H |
28 | #define GTK_NAMESPACE_H | 28 | #define GTK_NAMESPACE_H |
29 | 29 | ||
30 | #include <GNUnet/gnunet_util.h> | 30 | void fs_namespace_start(void); |
31 | |||
32 | void fs_namespace_start(struct GE_Context * ectx, | ||
33 | struct GC_Configuration * cfg); | ||
34 | 31 | ||
35 | void fs_namespace_stop(void); | 32 | void fs_namespace_stop(void); |
36 | 33 | ||
diff --git a/src/plugins/fs/upload.c b/src/plugins/fs/upload.c index 83c008d0..b4bf68cb 100644 --- a/src/plugins/fs/upload.c +++ b/src/plugins/fs/upload.c | |||
@@ -39,9 +39,6 @@ | |||
39 | #endif | 39 | #endif |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | |||
43 | static GtkTreeStore * summary; | ||
44 | |||
45 | /** | 42 | /** |
46 | * XML tree for the meta-data dialog of upload. | 43 | * XML tree for the meta-data dialog of upload. |
47 | * (there can only be one at a time; | 44 | * (there can only be one at a time; |
@@ -49,44 +46,148 @@ static GtkTreeStore * summary; | |||
49 | */ | 46 | */ |
50 | static GladeXML * metaXML; | 47 | static GladeXML * metaXML; |
51 | 48 | ||
52 | static struct GE_Context * ectx; | 49 | /* ************ FSUI event handlers ************ */ |
53 | |||
54 | static struct GC_Configuration * cfg; | ||
55 | 50 | ||
56 | /** | 51 | void fs_upload_update(UploadList * list, |
57 | */ | 52 | unsigned long long completed) { |
58 | void displayUploadUpdate(struct FSUI_UploadList * list, | 53 | GtkTreeIter iter; |
59 | const char * filename, | 54 | GtkTreePath * path; |
60 | unsigned long long completed, | ||
61 | unsigned long long total) { | ||
62 | int progress; | 55 | int progress; |
63 | 56 | ||
64 | DEBUG_BEGIN(); | 57 | if (list->total != 0) |
65 | if (total != 0) | 58 | progress = 100 * completed / list->total; |
66 | progress = 100 * completed / total; | ||
67 | else | 59 | else |
68 | progress = 100; | 60 | progress = 100; |
69 | 61 | path = gtk_tree_row_reference_get_path(list->summaryViewRowReference); | |
70 | /* FIXME! */ | 62 | gtk_tree_model_get_iter(GTK_TREE_MODEL(upload_summary), |
71 | DEBUG_END(); | 63 | &iter, |
64 | path); | ||
65 | gtk_tree_path_free(path); | ||
66 | gtk_tree_store_set(upload_summary, | ||
67 | &iter, | ||
68 | UPLOAD_PROGRESS, progress, | ||
69 | -1); | ||
72 | } | 70 | } |
73 | 71 | ||
74 | /** | 72 | void fs_upload_complete(UploadList * list, |
75 | */ | 73 | struct ECRS_URI * uri) { |
76 | void displayUploadComplete(struct FSUI_UploadList * list, | 74 | GtkTreeIter iter; |
77 | const char * filename, | 75 | GtkTreePath * path; |
78 | const struct ECRS_URI * uri) { | ||
79 | char * us; | 76 | char * us; |
80 | 77 | ||
81 | DEBUG_BEGIN(); | 78 | list->has_terminated = YES; |
82 | GE_ASSERT(ectx, uri != NULL); | 79 | list->uri = ECRS_dupUri(uri); |
83 | us = ECRS_uriToString(uri); | 80 | us = ECRS_uriToString(uri); |
84 | GE_ASSERT(ectx, us != NULL); | 81 | path = gtk_tree_row_reference_get_path(list->summaryViewRowReference); |
85 | /* FIXME */ | 82 | gtk_tree_model_get_iter(GTK_TREE_MODEL(upload_summary), |
83 | &iter, | ||
84 | path); | ||
85 | gtk_tree_path_free(path); | ||
86 | gtk_tree_store_set(upload_summary, | ||
87 | &iter, | ||
88 | UPLOAD_URISTRING, us, | ||
89 | -1); | ||
86 | FREE(us); | 90 | FREE(us); |
87 | DEBUG_END(); | ||
88 | } | 91 | } |
89 | 92 | ||
93 | void fs_upload_error(UploadList * list) { | ||
94 | /* FIXME: indicate error in summary dialog! */ | ||
95 | list->has_terminated = YES; | ||
96 | } | ||
97 | |||
98 | void fs_upload_stopped(UploadList * list) { | ||
99 | GtkTreeIter iter; | ||
100 | GtkTreePath * path; | ||
101 | UploadList * prev; | ||
102 | |||
103 | path = gtk_tree_row_reference_get_path(list->summaryViewRowReference); | ||
104 | gtk_tree_model_get_iter(GTK_TREE_MODEL(upload_summary), | ||
105 | &iter, | ||
106 | path); | ||
107 | gtk_tree_path_free(path); | ||
108 | gtk_tree_row_reference_free(list->summaryViewRowReference); | ||
109 | list->summaryViewRowReference = NULL; | ||
110 | gtk_tree_store_remove(upload_summary, | ||
111 | &iter); | ||
112 | FREE(list->filename); | ||
113 | if (list->uri != NULL) { | ||
114 | ECRS_freeUri(list->uri); | ||
115 | list->uri = NULL; | ||
116 | } | ||
117 | if (upload_head == list) | ||
118 | upload_head = list->next; | ||
119 | else { | ||
120 | prev = upload_head; | ||
121 | while ( (prev != NULL) && | ||
122 | (prev->next != list) ) | ||
123 | prev = prev->next; | ||
124 | if (prev != NULL) | ||
125 | prev->next = list->next; | ||
126 | else | ||
127 | GE_BREAK(ectx, 0); | ||
128 | } | ||
129 | FREE(list); | ||
130 | } | ||
131 | |||
132 | UploadList * | ||
133 | fs_upload_started(struct FSUI_UploadList * fsui, | ||
134 | UploadList * parent, | ||
135 | const char * filename, | ||
136 | struct ECRS_URI * uri, | ||
137 | unsigned long long total, | ||
138 | unsigned long long completed) { | ||
139 | UploadList * ret; | ||
140 | GtkTreeIter iter; | ||
141 | GtkTreePath * path; | ||
142 | int progress; | ||
143 | |||
144 | ret = MALLOC(sizeof(UploadList)); | ||
145 | memset(ret, | ||
146 | 0, | ||
147 | sizeof(UploadList)); | ||
148 | ret->filename = STRDUP(filename); | ||
149 | ret->fsui_list = fsui; | ||
150 | ret->total = total; | ||
151 | if (parent == NULL) { | ||
152 | gtk_tree_store_append(upload_summary, | ||
153 | &iter, | ||
154 | NULL); | ||
155 | } else { | ||
156 | GtkTreeIter par; | ||
157 | |||
158 | path = gtk_tree_row_reference_get_path(parent->summaryViewRowReference); | ||
159 | gtk_tree_model_get_iter(GTK_TREE_MODEL(upload_summary), | ||
160 | &par, | ||
161 | path); | ||
162 | gtk_tree_path_free(path); | ||
163 | gtk_tree_store_append(upload_summary, | ||
164 | &iter, | ||
165 | &par); | ||
166 | } | ||
167 | |||
168 | if (total != 0) | ||
169 | progress = 100 * completed / total; | ||
170 | else | ||
171 | progress = 100; | ||
172 | gtk_tree_store_set(upload_summary, | ||
173 | &iter, | ||
174 | UPLOAD_FILENAME, filename, | ||
175 | UPLOAD_PROGRESS, progress, | ||
176 | UPLOAD_URISTRING, "", /* FIXME: set if URI != NULL! */ | ||
177 | UPLOAD_INTERNAL, ret, | ||
178 | -1); | ||
179 | path = gtk_tree_model_get_path(GTK_TREE_MODEL(upload_summary), | ||
180 | &iter); | ||
181 | ret->summaryViewRowReference | ||
182 | = gtk_tree_row_reference_new(GTK_TREE_MODEL(upload_summary), | ||
183 | path); | ||
184 | ret->next = upload_head; | ||
185 | upload_head = ret; | ||
186 | return ret; | ||
187 | } | ||
188 | |||
189 | /* *************** Glade UI event handling ************** */ | ||
190 | |||
90 | 191 | ||
91 | void on_selectAlternativePreviewButton_selection_changed_fs(GtkWidget * preview, | 192 | void on_selectAlternativePreviewButton_selection_changed_fs(GtkWidget * preview, |
92 | GtkWidget * fileChooser) { | 193 | GtkWidget * fileChooser) { |
@@ -239,8 +340,8 @@ void on_fsinsertuploadbutton_clicked_fs(gpointer dummy, | |||
239 | "previewImage"); | 340 | "previewImage"); |
240 | uc.keywordURI = getKeywordURIFromList(metaXML, | 341 | uc.keywordURI = getKeywordURIFromList(metaXML, |
241 | "metaDataDialogKeywordList"); | 342 | "metaDataDialogKeywordList"); |
242 | uc.anon = getAnonymityLevel(getMainXML(), | 343 | uc.anon = getSpinButtonValue(getMainXML(), |
243 | "uploadAnonymityLevelSpinButton"); | 344 | "uploadAnonymityLevelSpinButton"); |
244 | deepIndex = glade_xml_get_widget(getMainXML(), | 345 | deepIndex = glade_xml_get_widget(getMainXML(), |
245 | "deepIndexCheckButton"); | 346 | "deepIndexCheckButton"); |
246 | uc.deepIndex = (TRUE == gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(deepIndex))) ? YES : NO; | 347 | uc.deepIndex = (TRUE == gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(deepIndex))) ? YES : NO; |
@@ -342,63 +443,4 @@ void on_mainFileSharingInsertBrowseButton_clicked_fs(GtkWidget * browseButton, | |||
342 | } | 443 | } |
343 | } | 444 | } |
344 | 445 | ||
345 | |||
346 | void fs_upload_start(struct GE_Context * e, | ||
347 | struct GC_Configuration * c) { | ||
348 | GtkWidget * uploadList; | ||
349 | GtkWidget * uploadEntry; | ||
350 | GtkCellRenderer * renderer; | ||
351 | GtkListStore * model; | ||
352 | int col; | ||
353 | |||
354 | ectx = e; | ||
355 | cfg = c; | ||
356 | uploadList = glade_xml_get_widget(getMainXML(), | ||
357 | "activeUploadsList"); | ||
358 | summary = | ||
359 | gtk_tree_store_new(UPLOAD_NUM, | ||
360 | G_TYPE_STRING, /* filename */ | ||
361 | G_TYPE_INT, /* progress */ | ||
362 | G_TYPE_STRING); /* URI (as string) - after completion */ | ||
363 | gtk_tree_view_set_model(GTK_TREE_VIEW(uploadList), | ||
364 | GTK_TREE_MODEL(summary)); | ||
365 | gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(uploadList)), | ||
366 | GTK_SELECTION_MULTIPLE); | ||
367 | renderer = gtk_cell_renderer_progress_new(); | ||
368 | col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(uploadList), | ||
369 | -1, | ||
370 | _("Filename"), | ||
371 | renderer, | ||
372 | "text", UPLOAD_FILENAME, | ||
373 | "value", UPLOAD_PROGRESS, | ||
374 | NULL); | ||
375 | gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(uploadList), | ||
376 | col - 1), | ||
377 | TRUE); | ||
378 | renderer = gtk_cell_renderer_text_new(); | ||
379 | col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(uploadList), | ||
380 | -1, | ||
381 | _("URI"), | ||
382 | renderer, | ||
383 | "text", UPLOAD_URISTRING, | ||
384 | NULL); | ||
385 | gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(uploadList), | ||
386 | col - 1), | ||
387 | TRUE); | ||
388 | |||
389 | uploadEntry | ||
390 | = glade_xml_get_widget(getMainXML(), | ||
391 | "uploadFilenameComboBoxEntry"); | ||
392 | |||
393 | model = gtk_list_store_new(1, G_TYPE_STRING); | ||
394 | gtk_combo_box_set_model(GTK_COMBO_BOX(uploadEntry), | ||
395 | GTK_TREE_MODEL(model)); | ||
396 | gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(uploadEntry), | ||
397 | 0); | ||
398 | } | ||
399 | |||
400 | void fs_upload_stop() { | ||
401 | /* nothing to be done */ | ||
402 | } | ||
403 | |||
404 | /* end of upload.c */ | 446 | /* end of upload.c */ |
diff --git a/src/plugins/fs/upload.h b/src/plugins/fs/upload.h index d3b418cc..55bca7f6 100644 --- a/src/plugins/fs/upload.h +++ b/src/plugins/fs/upload.h | |||
@@ -27,36 +27,27 @@ | |||
27 | #ifndef GTK_UPLOAD_H | 27 | #ifndef GTK_UPLOAD_H |
28 | #define GTK_UPLOAD_H | 28 | #define GTK_UPLOAD_H |
29 | 29 | ||
30 | /** | 30 | #include "fs.h" |
31 | */ | ||
32 | void displayUploadUpdate(struct FSUI_UploadList * list, | ||
33 | const char * filename, | ||
34 | unsigned long long completed, | ||
35 | unsigned long long total); | ||
36 | 31 | ||
37 | /** | 32 | void fs_upload_update(UploadList * list, |
38 | */ | 33 | unsigned long long completed); |
39 | void displayUploadComplete(struct FSUI_UploadList * list, | ||
40 | const char * filename, | ||
41 | const struct ECRS_URI * uri); | ||
42 | 34 | ||
35 | void fs_upload_complete(UploadList * list, | ||
36 | struct ECRS_URI * uri); | ||
43 | 37 | ||
38 | void fs_upload_error(UploadList * list); | ||
39 | |||
40 | void fs_upload_stopped(UploadList * list); | ||
44 | 41 | ||
45 | /** | 42 | /** |
46 | * Add the given result to the model (upload result | 43 | * @param uri NULL if upload is not yet finished |
47 | * list). | ||
48 | * @param info the information to add to the model | ||
49 | * @param uri the upload URI | ||
50 | * @param path the tree path that selects where to add | ||
51 | * the information, NULL for top-level | ||
52 | */ | 44 | */ |
53 | void displayUploadResult(const ECRS_FileInfo * info, | 45 | UploadList * |
54 | const struct ECRS_URI * uri, | 46 | fs_upload_started(struct FSUI_UploadList * fsui, |
55 | GtkTreeRowReference * row); | 47 | UploadList * parent, |
56 | 48 | const char * filename, | |
57 | void fs_upload_start(struct GE_Context * e, | 49 | struct ECRS_URI * uri, |
58 | struct GC_Configuration * c); | 50 | unsigned long long total, |
59 | 51 | unsigned long long completed); | |
60 | void fs_upload_stop(void); | ||
61 | 52 | ||
62 | #endif | 53 | #endif |