aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/helper.c20
-rw-r--r--src/common/iterators.c5
-rw-r--r--src/common/logging.c34
-rw-r--r--src/plugins/fs/download.c73
-rw-r--r--src/plugins/fs/fs.c2
-rw-r--r--src/plugins/fs/meta.c2
-rw-r--r--src/plugins/fs/namespace.c22
-rw-r--r--src/plugins/fs/search.c11
8 files changed, 104 insertions, 65 deletions
diff --git a/src/common/helper.c b/src/common/helper.c
index 558d8f3f..c8312776 100644
--- a/src/common/helper.c
+++ b/src/common/helper.c
@@ -60,12 +60,6 @@ static GladeXML * mainXML;
60 60
61static char * gladeFile; 61static char * gladeFile;
62 62
63static GladeXML * statusXML;
64
65static GtkWidget * infoWindow;
66
67static GtkWidget * infoWindowTextView;
68
69static GdkWindowState main_window_state; 63static GdkWindowState main_window_state;
70 64
71/** 65/**
@@ -320,16 +314,6 @@ void initGNUnetGTKCommon(struct GE_Context * e,
320 GE_FATAL | GE_USER | GE_IMMEDIATE, 314 GE_FATAL | GE_USER | GE_IMMEDIATE,
321 "glade_xml_new", 315 "glade_xml_new",
322 gladeFile); 316 gladeFile);
323 statusXML
324 = glade_xml_new(getGladeFileName(),
325 "statusWindow",
326 PACKAGE_NAME);
327 infoWindow
328 = glade_xml_get_widget(statusXML,
329 "statusWindow");
330 infoWindowTextView
331 = glade_xml_get_widget(statusXML,
332 "messageWindowTextView");
333 /* load the plugins */ 317 /* load the plugins */
334 GC_get_configuration_value_string(cfg, 318 GC_get_configuration_value_string(cfg,
335 "GNUNET-GTK", 319 "GNUNET-GTK",
@@ -339,7 +323,6 @@ void initGNUnetGTKCommon(struct GE_Context * e,
339 loadPlugins(load); 323 loadPlugins(load);
340 FREE(load); 324 FREE(load);
341 connectGladeWithPlugins(mainXML); 325 connectGladeWithPlugins(mainXML);
342 connectGladeWithPlugins(statusXML);
343} 326}
344 327
345void shutdownPlugins() { 328void shutdownPlugins() {
@@ -353,9 +336,6 @@ void shutdownPlugins() {
353 unloadPlugin(plugin); 336 unloadPlugin(plugin);
354 plugin = next; 337 plugin = next;
355 } 338 }
356 gtk_widget_destroy(infoWindow);
357 infoWindow = NULL;
358 UNREF(statusXML);
359 UNREF(mainXML); 339 UNREF(mainXML);
360 mainXML = NULL; 340 mainXML = NULL;
361 FREE(gladeFile); 341 FREE(gladeFile);
diff --git a/src/common/iterators.c b/src/common/iterators.c
index 36fe7dba..d7441753 100644
--- a/src/common/iterators.c
+++ b/src/common/iterators.c
@@ -23,7 +23,10 @@
23 * @author Igor Wronsky 23 * @author Igor Wronsky
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26 26#include "platform.h"
27#include "gnunetgtk_common.h"
28#include <GNUnet/gnunet_util_crypto.h>
29#include <glib.h>
27/** 30/**
28 * Identical to "gtk_tree_selection_selected_foreach", 31 * Identical to "gtk_tree_selection_selected_foreach",
29 * except that modifications of the underlying model 32 * except that modifications of the underlying model
diff --git a/src/common/logging.c b/src/common/logging.c
index d49298fd..aad69f96 100644
--- a/src/common/logging.c
+++ b/src/common/logging.c
@@ -30,6 +30,28 @@
30#include <glib.h> 30#include <glib.h>
31#include <gmodule.h> 31#include <gmodule.h>
32 32
33static GtkWidget * infoWindow;
34
35static GtkWidget * infoWindowTextView;
36
37static GladeXML * statusXML;
38
39static void init() {
40 if (statusXML != NULL)
41 return;
42 statusXML
43 = glade_xml_new(getGladeFileName(),
44 "statusWindow",
45 PACKAGE_NAME);
46 infoWindow
47 = glade_xml_get_widget(statusXML,
48 "statusWindow");
49 infoWindowTextView
50 = glade_xml_get_widget(statusXML,
51 "messageWindowTextView");
52 connectGladeWithPlugins(statusXML);
53}
54
33/** 55/**
34 * Closure for doInfoMessage. 56 * Closure for doInfoMessage.
35 */ 57 */
@@ -46,6 +68,7 @@ static void * doInfoMessage(void * args) {
46 GtkTextIter iter; 68 GtkTextIter iter;
47 GtkTextBuffer * buffer; 69 GtkTextBuffer * buffer;
48 70
71 init();
49 if (info->doPopup==YES) 72 if (info->doPopup==YES)
50 gtk_widget_show(infoWindow); 73 gtk_widget_show(infoWindow);
51 buffer 74 buffer
@@ -83,9 +106,10 @@ static void * saveAddLogEntry(void * args) {
83 static int once = 1; 106 static int once = 1;
84 static guint id; 107 static guint id;
85 108
109 init();
86 if (once) { 110 if (once) {
87 once = 0; 111 once = 0;
88 s = glade_xml_get_widget(mainXML, 112 s = glade_xml_get_widget(getMainXML(),
89 "statusbar"); 113 "statusbar");
90 id = gtk_statusbar_get_context_id(GTK_STATUSBAR(s), 114 id = gtk_statusbar_get_context_id(GTK_STATUSBAR(s),
91 "LOG"); 115 "LOG");
@@ -118,3 +142,11 @@ void addLogEntry(const char * txt,
118 g_free(note); 142 g_free(note);
119} 143}
120 144
145void __attribute__ ((destructor)) gnunet_crypto_ltdl_fini() {
146 if (statusXML != NULL) {
147 gtk_widget_destroy(infoWindow);
148 infoWindow = NULL;
149 UNREF(statusXML);
150 statusXML = NULL;
151 }
152}
diff --git a/src/plugins/fs/download.c b/src/plugins/fs/download.c
index 453a847e..7f243a3c 100644
--- a/src/plugins/fs/download.c
+++ b/src/plugins/fs/download.c
@@ -396,7 +396,7 @@ check_pending(const char * filename,
396 GtkTreeIter * parent) { 396 GtkTreeIter * parent) {
397 GtkTreeModel * model; 397 GtkTreeModel * model;
398 GtkTreeIter iter; 398 GtkTreeIter iter;
399 const char * name; 399 char * name;
400 400
401 model = GTK_TREE_MODEL(download_summary); 401 model = GTK_TREE_MODEL(download_summary);
402 if (gtk_tree_model_iter_children(model, 402 if (gtk_tree_model_iter_children(model,
@@ -408,8 +408,11 @@ check_pending(const char * filename,
408 DOWNLOAD_FILENAME, &name, 408 DOWNLOAD_FILENAME, &name,
409 -1); 409 -1);
410 if ( (name != NULL) && 410 if ( (name != NULL) &&
411 (0 == strcmp(name, filename)) ) 411 (0 == strcmp(name, filename)) ) {
412 FREE(name);
412 return SYSERR; 413 return SYSERR;
414 }
415 FREENONNULL(name);
413 if (SYSERR == check_pending(filename, 416 if (SYSERR == check_pending(filename,
414 &iter)) 417 &iter))
415 return SYSERR; 418 return SYSERR;
@@ -431,24 +434,20 @@ initiateDownload(GtkTreeModel * model,
431 char * uri_name; 434 char * uri_name;
432 char * final_download_dir; 435 char * final_download_dir;
433 GtkTreeIter iiter; 436 GtkTreeIter iiter;
434 const char * oname; 437 char * tmp;
435 const char * cname; 438 char * cname;
436 char * dname; 439 char * dname;
437 GtkTreePath *dirTreePath; 440 GtkTreePath *dirTreePath;
438 char *dirPath; 441 char *dirPath;
439 unsigned int dirPathLen; 442 unsigned int dirPathLen;
440 struct ECRS_URI * idc_uri; 443 struct ECRS_URI * idc_uri;
441 struct ECRS_MetaData * idc_meta; 444 struct ECRS_MetaData * idc_meta;
442 const char * idc_name; 445 char * idc_name;
443 const char * idc_mime; 446 char * idc_mime;
444 char * idc_final_download_destination; 447 char * idc_final_download_destination;
445 SearchList * searchContext; 448 SearchList * searchContext;
446 DownloadList * parentContext; 449 DownloadList * parentContext;
447 450
448#ifdef WINDOWS
449 char *filehash = NULL;
450#endif
451
452 DEBUG_BEGIN(); 451 DEBUG_BEGIN();
453 idc_uri = NULL; 452 idc_uri = NULL;
454 idc_meta = NULL; 453 idc_meta = NULL;
@@ -468,6 +467,8 @@ initiateDownload(GtkTreeModel * model,
468 if ( (idc_uri == NULL) || 467 if ( (idc_uri == NULL) ||
469 (! ECRS_isFileUri(idc_uri)) ) { 468 (! ECRS_isFileUri(idc_uri)) ) {
470 GE_BREAK(ectx, 0); 469 GE_BREAK(ectx, 0);
470 FREENONNULL(idc_name);
471 FREENONNULL(idc_mime);
471 return; 472 return;
472 } 473 }
473 uri_name = ECRS_uriToString(idc_uri); 474 uri_name = ECRS_uriToString(idc_uri);
@@ -477,40 +478,39 @@ initiateDownload(GtkTreeModel * model,
477 strlen(ECRS_FILE_INFIX)) ) { 478 strlen(ECRS_FILE_INFIX)) ) {
478 GE_BREAK(ectx, 0); 479 GE_BREAK(ectx, 0);
479 FREENONNULL(uri_name); 480 FREENONNULL(uri_name);
481 FREENONNULL(idc_name);
482 FREENONNULL(idc_mime);
480 return; 483 return;
481 } 484 }
482 if (idc_name == NULL) { 485 if (idc_name == NULL) {
483#ifdef WINDOWS 486#ifdef WINDOWS
487 char * filehash;
488
484 filehash = STRDUP(uri_name); 489 filehash = STRDUP(uri_name);
485 filehash[16] = 0; 490 filehash[16] = 0;
486 idc_name = filehash; 491 idc_name = STRDUP(filehash);
492 FREENONNULL(filehash);
487#else 493#else
488 idc_name = uri_name; 494 idc_name = STRDUP(uri_name);
489#endif 495#endif
490 } 496 }
497
498 /* dname = directory portion of idc_name */
491 cname = idc_name; 499 cname = idc_name;
492 oname = idc_name; 500 dname = STRDUP(idc_name);
493 dname = MALLOC(strlen(idc_name)+1); 501 cname = &dname[strlen(dname)-1];
494 dname[0] = '\0'; 502 while ( (cname != dname) &&
495 while (*idc_name != '\0') { 503 (*cname != DIR_SEPARATOR) )
496 if ( (*idc_name == DIR_SEPARATOR) && 504 cname--;
497 (idc_name[1] != '\0') ) { 505 *cname = '\0';
498 memcpy(dname, oname, idc_name - oname); 506 cname = NULL;
499 dname[idc_name - oname] = '\0'; 507
500 cname = &idc_name[1];
501 }
502 idc_name++;
503 }
504 if (*cname == '\0') /* name ended in '/' - likely directory */
505 cname = oname;
506 idc_name = cname;
507 GC_get_configuration_value_filename(cfg, 508 GC_get_configuration_value_filename(cfg,
508 "FS", 509 "FS",
509 "INCOMINGDIR", 510 "INCOMINGDIR",
510 "$HOME/gnunet-downloads/", 511 "$HOME/gnunet-downloads/",
511 &final_download_dir); 512 &final_download_dir);
512 if (strlen(dname) > 0) { 513 if (strlen(dname) > 0) {
513 char * tmp;
514 tmp = MALLOC(strlen(final_download_dir) + strlen(dname) + 2); 514 tmp = MALLOC(strlen(final_download_dir) + strlen(dname) + 2);
515 strcpy(tmp, final_download_dir); 515 strcpy(tmp, final_download_dir);
516 if (tmp[strlen(tmp)] != DIR_SEPARATOR) 516 if (tmp[strlen(tmp)] != DIR_SEPARATOR)
@@ -523,6 +523,7 @@ initiateDownload(GtkTreeModel * model,
523 final_download_dir = tmp; 523 final_download_dir = tmp;
524 } 524 }
525 FREE(dname); 525 FREE(dname);
526 dname = NULL;
526 disk_directory_create(ectx, final_download_dir); 527 disk_directory_create(ectx, final_download_dir);
527 528
528 529
@@ -562,11 +563,13 @@ initiateDownload(GtkTreeModel * model,
562 idc_final_download_destination = MALLOC(strlen(final_download_dir) + 2 + 563 idc_final_download_destination = MALLOC(strlen(final_download_dir) + 2 +
563 strlen(idc_name) + strlen(GNUNET_DIRECTORY_EXT) + 564 strlen(idc_name) + strlen(GNUNET_DIRECTORY_EXT) +
564 strlen(dirPath)); 565 strlen(dirPath));
565 strcpy(idc_final_download_destination, final_download_dir); 566 strcpy(idc_final_download_destination,
567 final_download_dir);
566 if (idc_final_download_destination[strlen(idc_final_download_destination)-1] != DIR_SEPARATOR) 568 if (idc_final_download_destination[strlen(idc_final_download_destination)-1] != DIR_SEPARATOR)
567 strcat(idc_final_download_destination, 569 strcat(idc_final_download_destination,
568 DIR_SEPARATOR_STR); 570 DIR_SEPARATOR_STR);
569 strcat(idc_final_download_destination, dirPath); 571 strcat(idc_final_download_destination,
572 dirPath);
570 disk_directory_create(ectx, 573 disk_directory_create(ectx,
571 idc_final_download_destination); 574 idc_final_download_destination);
572 strcat(idc_final_download_destination, idc_name); 575 strcat(idc_final_download_destination, idc_name);
@@ -601,10 +604,10 @@ initiateDownload(GtkTreeModel * model,
601 } 604 }
602 FREE(uri_name); 605 FREE(uri_name);
603 FREE(dirPath); 606 FREE(dirPath);
607 FREE(idc_final_download_destination);
604 FREENONNULL(final_download_dir); 608 FREENONNULL(final_download_dir);
605#ifdef WINDOWS 609 FREENONNULL(idc_name);
606 FREENONNULL(filehash); 610 FREENONNULL(idc_mime);
607#endif
608} 611}
609 612
610/** 613/**
@@ -756,7 +759,7 @@ fsuiCallDownloadCallback(GtkTreeModel * model,
756} 759}
757 760
758void on_abortDownloadButton_clicked_fs(void * unused, 761void on_abortDownloadButton_clicked_fs(void * unused,
759 GtkWidget * clearButton) { 762 GtkWidget * abortButton) {
760 GtkTreeSelection * selection; 763 GtkTreeSelection * selection;
761 GtkWidget * downloadList; 764 GtkWidget * downloadList;
762 765
@@ -770,7 +773,7 @@ void on_abortDownloadButton_clicked_fs(void * unused,
770} 773}
771 774
772void on_stopDownloadButton_clicked_fs(void * unused, 775void on_stopDownloadButton_clicked_fs(void * unused,
773 GtkWidget * clearButton) { 776 GtkWidget * stopButton) {
774 GtkTreeSelection * selection; 777 GtkTreeSelection * selection;
775 GtkWidget * downloadList; 778 GtkWidget * downloadList;
776 779
diff --git a/src/plugins/fs/fs.c b/src/plugins/fs/fs.c
index 51e9dc60..4cf8fccd 100644
--- a/src/plugins/fs/fs.c
+++ b/src/plugins/fs/fs.c
@@ -437,7 +437,7 @@ void init_fs(struct GE_Context * e,
437 ctx = FSUI_start(ectx, 437 ctx = FSUI_start(ectx,
438 cfg, 438 cfg,
439 "gnunet-gtk", 439 "gnunet-gtk",
440 128, /* FIXME: allow user to configure download parallelism */ 440 8, /* FIXME: allow user to configure download parallelism */
441 YES, 441 YES,
442 &eventProcessor, 442 &eventProcessor,
443 NULL); 443 NULL);
diff --git a/src/plugins/fs/meta.c b/src/plugins/fs/meta.c
index d6014697..cb32959c 100644
--- a/src/plugins/fs/meta.c
+++ b/src/plugins/fs/meta.c
@@ -318,6 +318,7 @@ void handleMetaDataListUpdate(GladeXML * xml,
318 META_VALUE, value, 318 META_VALUE, value,
319 -1); 319 -1);
320 gtk_entry_set_text(GTK_ENTRY(entryLine), ""); 320 gtk_entry_set_text(GTK_ENTRY(entryLine), "");
321 FREENONNULL(stype);
321 DEBUG_END(); 322 DEBUG_END();
322} 323}
323 324
@@ -349,6 +350,7 @@ struct ECRS_MetaData * getMetaDataFromList(GladeXML * xml,
349 ECRS_addToMetaData(meta, 350 ECRS_addToMetaData(meta,
350 type, 351 type,
351 mvalue); 352 mvalue);
353 FREENONNULL(mvalue);
352 } while (gtk_tree_model_iter_next(metamodel, 354 } while (gtk_tree_model_iter_next(metamodel,
353 &iter)); 355 &iter));
354 } 356 }
diff --git a/src/plugins/fs/namespace.c b/src/plugins/fs/namespace.c
index 6378ee53..faf02567 100644
--- a/src/plugins/fs/namespace.c
+++ b/src/plugins/fs/namespace.c
@@ -937,9 +937,9 @@ void on_namespaceUpdateButton_clicked_fs(GtkWidget * dummy1,
937 GtkTreeSelection * selectionNamespace; 937 GtkTreeSelection * selectionNamespace;
938 IUC cls; 938 IUC cls;
939 gint num; 939 gint num;
940 const char * last; 940 char * last;
941 const char * next; 941 char * next;
942 const char * freq; 942 char * freq;
943 943
944 DEBUG_BEGIN(); 944 DEBUG_BEGIN();
945 contentList 945 contentList
@@ -1031,6 +1031,9 @@ void on_namespaceUpdateButton_clicked_fs(GtkWidget * dummy1,
1031 GE_BREAK(ectx, 0); 1031 GE_BREAK(ectx, 0);
1032 UNREF(metaXML); 1032 UNREF(metaXML);
1033 metaXML = NULL; 1033 metaXML = NULL;
1034 FREENONNULL(last);
1035 FREENONNULL(next);
1036 FREENONNULL(freq);
1034 return; 1037 return;
1035 } 1038 }
1036 if (OK == enc2hash(last, 1039 if (OK == enc2hash(last,
@@ -1063,6 +1066,9 @@ void on_namespaceUpdateButton_clicked_fs(GtkWidget * dummy1,
1063 GE_BREAK(ectx, 0); 1066 GE_BREAK(ectx, 0);
1064 UNREF(metaXML); 1067 UNREF(metaXML);
1065 metaXML = NULL; 1068 metaXML = NULL;
1069 FREENONNULL(last);
1070 FREENONNULL(next);
1071 FREENONNULL(freq);
1066 return; 1072 return;
1067 } 1073 }
1068 hash2enc(&nextId, 1074 hash2enc(&nextId,
@@ -1116,6 +1122,9 @@ void on_namespaceUpdateButton_clicked_fs(GtkWidget * dummy1,
1116 error); 1122 error);
1117 gtk_dialog_run(GTK_DIALOG(dialog)); 1123 gtk_dialog_run(GTK_DIALOG(dialog));
1118 gtk_widget_destroy(dialog); 1124 gtk_widget_destroy(dialog);
1125 FREENONNULL(last);
1126 FREENONNULL(next);
1127 FREENONNULL(freq);
1119 return; 1128 return;
1120 } 1129 }
1121 hash(identifierName, 1130 hash(identifierName,
@@ -1139,6 +1148,9 @@ void on_namespaceUpdateButton_clicked_fs(GtkWidget * dummy1,
1139 gtk_widget_destroy(dialog); 1148 gtk_widget_destroy(dialog);
1140 UNREF(metaXML); 1149 UNREF(metaXML);
1141 metaXML = NULL; 1150 metaXML = NULL;
1151 FREENONNULL(last);
1152 FREENONNULL(next);
1153 FREENONNULL(freq);
1142 DEBUG_END(); 1154 DEBUG_END();
1143} 1155}
1144 1156
@@ -1236,6 +1248,8 @@ void on_namespaceRatingSpinButton_changed_fs(GtkWidget * dummy,
1236 gtk_widget_set_sensitive(spin, 1248 gtk_widget_set_sensitive(spin,
1237 FALSE); 1249 FALSE);
1238 } 1250 }
1251 FREENONNULL(description);
1252 FREENONNULL(encStr);
1239 DEBUG_END(); 1253 DEBUG_END();
1240} 1254}
1241 1255
@@ -1310,6 +1324,8 @@ void on_searchNamespaceComboBoxEntry_changed_fs(GtkWidget * dummy,
1310 gtk_widget_set_sensitive(spin, 1324 gtk_widget_set_sensitive(spin,
1311 FALSE); 1325 FALSE);
1312 } 1326 }
1327 FREENONNULL(descStr);
1328 FREENONNULL(encStr);
1313 DEBUG_END(); 1329 DEBUG_END();
1314} 1330}
1315 1331
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c
index f70f6630..916504a5 100644
--- a/src/plugins/fs/search.c
+++ b/src/plugins/fs/search.c
@@ -510,8 +510,8 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2,
510 "searchNamespaceComboBoxEntry"); 510 "searchNamespaceComboBoxEntry");
511 if (TRUE == gtk_combo_box_get_active_iter(GTK_COMBO_BOX(searchNamespaceGtkCB), 511 if (TRUE == gtk_combo_box_get_active_iter(GTK_COMBO_BOX(searchNamespaceGtkCB),
512 &iter)) { 512 &iter)) {
513 const char * descStr; 513 char * descStr;
514 const char * ns; 514 char * ns;
515 515
516 ns = NULL; 516 ns = NULL;
517 descStr = NULL; 517 descStr = NULL;
@@ -527,8 +527,9 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2,
527 ns = NULL; 527 ns = NULL;
528 } else { 528 } else {
529 GE_ASSERT(ectx, strlen(ns) == sizeof(EncName) - 1); 529 GE_ASSERT(ectx, strlen(ns) == sizeof(EncName) - 1);
530 if (descStr == NULL) 530 if ( (descStr == NULL) &&
531 descStr = ns; 531 (ns != NULL) )
532 descStr = STRDUP(ns);
532 } 533 }
533 if (ns != NULL) { 534 if (ns != NULL) {
534 char * ustring; 535 char * ustring;
@@ -550,6 +551,8 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2,
550 } 551 }
551 FREE(ustring); 552 FREE(ustring);
552 } 553 }
554 FREENONNULL(descStr);
555 FREENONNULL(ns);
553 } 556 }
554 if (uri == NULL) 557 if (uri == NULL)
555 uri = ECRS_parseCharKeywordURI(ectx, searchString); 558 uri = ECRS_parseCharKeywordURI(ectx, searchString);