diff options
Diffstat (limited to 'src/plugins/fs/upload.c')
-rw-r--r-- | src/plugins/fs/upload.c | 220 |
1 files changed, 131 insertions, 89 deletions
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 */ |