aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2007-02-04 05:05:02 +0000
committerChristian Grothoff <christian@grothoff.org>2007-02-04 05:05:02 +0000
commitd8a28757f539b4ab99818bb57dbe93892c3b37b1 (patch)
tree9a58495e1d3976263c19ba6170bc4d16342a384b
parenta2d587059dc69d76ebe92f0754b440dca0ec10ab (diff)
downloadgnunet-gtk-d8a28757f539b4ab99818bb57dbe93892c3b37b1.tar.gz
gnunet-gtk-d8a28757f539b4ab99818bb57dbe93892c3b37b1.zip
fixing mantis 1012
-rw-r--r--ChangeLog3
-rw-r--r--gnunet-gtk.glade39
-rw-r--r--src/plugins/fs/Makefile.am1
-rw-r--r--src/plugins/fs/directory.c162
-rw-r--r--src/plugins/fs/namespace.c5
-rw-r--r--src/plugins/fs/search.c55
-rw-r--r--src/plugins/fs/upload.c1
7 files changed, 235 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog
index 59eddbd6..9849b9e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
1Sat Feb 3 22:03:52 MST 2007
2 Added ability to open gnunet-directory.
3
1Sat Feb 3 21:00:23 MST 2007 4Sat Feb 3 21:00:23 MST 2007
2 Added ability to save search results as gnunet-directory 5 Added ability to save search results as gnunet-directory
3 (in right-click context menu). 6 (in right-click context menu).
diff --git a/gnunet-gtk.glade b/gnunet-gtk.glade
index db0473bb..863120f2 100644
--- a/gnunet-gtk.glade
+++ b/gnunet-gtk.glade
@@ -1883,6 +1883,35 @@ This release fixes downloads of files from directories. The previous version ha
1883 <property name="fill">True</property> 1883 <property name="fill">True</property>
1884 </packing> 1884 </packing>
1885 </child> 1885 </child>
1886
1887 <child>
1888 <widget class="GtkVSeparator" id="vseparator3">
1889 <property name="visible">True</property>
1890 </widget>
1891 <packing>
1892 <property name="padding">9</property>
1893 <property name="expand">False</property>
1894 <property name="fill">False</property>
1895 </packing>
1896 </child>
1897
1898 <child>
1899 <widget class="GtkButton" id="openDirectoryButton">
1900 <property name="visible">True</property>
1901 <property name="tooltip" translatable="yes">Open GNUnet directory</property>
1902 <property name="can_focus">True</property>
1903 <property name="label">gtk-open</property>
1904 <property name="use_stock">True</property>
1905 <property name="relief">GTK_RELIEF_NORMAL</property>
1906 <property name="focus_on_click">True</property>
1907 <signal name="clicked" handler="on_open_menu_activate_" last_modification_time="Sun, 04 Feb 2007 04:42:58 GMT"/>
1908 </widget>
1909 <packing>
1910 <property name="padding">0</property>
1911 <property name="expand">False</property>
1912 <property name="fill">False</property>
1913 </packing>
1914 </child>
1886 </widget> 1915 </widget>
1887 <packing> 1916 <packing>
1888 <property name="padding">0</property> 1917 <property name="padding">0</property>
@@ -7934,21 +7963,23 @@ Daniel Nylander &lt;po@danielnylander.se&gt;
7934 </child> 7963 </child>
7935</widget> 7964</widget>
7936 7965
7937<widget class="GtkFileChooserDialog" id="filechooserdialog1"> 7966<widget class="GtkFileChooserDialog" id="openDirectoryFileDialog">
7938 <property name="visible">True</property> 7967 <property name="visible">True</property>
7939 <property name="action">GTK_FILE_CHOOSER_ACTION_OPEN</property> 7968 <property name="action">GTK_FILE_CHOOSER_ACTION_OPEN</property>
7940 <property name="local_only">True</property> 7969 <property name="local_only">True</property>
7941 <property name="select_multiple">False</property> 7970 <property name="select_multiple">False</property>
7942 <property name="show_hidden">False</property> 7971 <property name="show_hidden">False</property>
7943 <property name="do_overwrite_confirmation">False</property> 7972 <property name="do_overwrite_confirmation">False</property>
7973 <property name="title" translatable="yes">Select GNUnet directory file to open</property>
7944 <property name="type">GTK_WINDOW_TOPLEVEL</property> 7974 <property name="type">GTK_WINDOW_TOPLEVEL</property>
7945 <property name="window_position">GTK_WIN_POS_NONE</property> 7975 <property name="window_position">GTK_WIN_POS_NONE</property>
7946 <property name="modal">False</property> 7976 <property name="modal">True</property>
7947 <property name="resizable">True</property> 7977 <property name="resizable">True</property>
7948 <property name="destroy_with_parent">False</property> 7978 <property name="destroy_with_parent">False</property>
7979 <property name="icon_name">gtk-open</property>
7949 <property name="decorated">True</property> 7980 <property name="decorated">True</property>
7950 <property name="skip_taskbar_hint">False</property> 7981 <property name="skip_taskbar_hint">True</property>
7951 <property name="skip_pager_hint">False</property> 7982 <property name="skip_pager_hint">True</property>
7952 <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> 7983 <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
7953 <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> 7984 <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
7954 <property name="focus_on_map">True</property> 7985 <property name="focus_on_map">True</property>
diff --git a/src/plugins/fs/Makefile.am b/src/plugins/fs/Makefile.am
index 2d07659f..17bd42ac 100644
--- a/src/plugins/fs/Makefile.am
+++ b/src/plugins/fs/Makefile.am
@@ -11,6 +11,7 @@ plugin_LTLIBRARIES = \
11 11
12libgnunetgtkmodule_fs_la_SOURCES = \ 12libgnunetgtkmodule_fs_la_SOURCES = \
13 collection.c collection.h \ 13 collection.c collection.h \
14 directory.c \
14 fs.c fs.h \ 15 fs.c fs.h \
15 helper.c helper.h \ 16 helper.c helper.h \
16 meta.c meta.h \ 17 meta.c meta.h \
diff --git a/src/plugins/fs/directory.c b/src/plugins/fs/directory.c
new file mode 100644
index 00000000..1bf2db5d
--- /dev/null
+++ b/src/plugins/fs/directory.c
@@ -0,0 +1,162 @@
1/*
2 This file is part of GNUnet.
3 (C) 2007 Christian Grothoff (and other contributing authors)
4
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
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/plugins/fs/directory.c
23 * @brief code for opening directories
24 * @author Christian Grothoff
25 */
26
27#include "platform.h"
28#include "gnunetgtk_common.h"
29#include "fs.h"
30#include "helper.h"
31#include "meta.h"
32#include "search.h"
33#include <GNUnet/gnunet_util_crypto.h>
34#include <GNUnet/gnunet_uritrack_lib.h>
35#include <GNUnet/gnunet_namespace_lib.h>
36#include <extractor.h>
37
38#ifndef MINGW
39static char *
40selectFile() {
41 GladeXML * uploadXML;
42 GtkFileChooser * dialog;
43 char * ret;
44
45 uploadXML
46 = glade_xml_new(getGladeFileName(),
47 "openDirectoryFileDialog",
48 PACKAGE_NAME);
49 connectGladeWithPlugins(uploadXML);
50 dialog = GTK_FILE_CHOOSER(glade_xml_get_widget(uploadXML,
51 "openDirectoryFileDialog"));
52 if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_CANCEL)
53 ret = gtk_file_chooser_get_filename(dialog);
54 else
55 ret = NULL;
56 gtk_widget_destroy(GTK_WIDGET(dialog));
57 UNREF(uploadXML);
58 return ret;
59}
60#else /* MINGW */
61static char *
62selectFile() {
63 return plibc_ChooseFile(_("Choose the directory you want to open."),
64 OFN_FILEMUSTEXIST | OFN_SHAREAWARE);
65}
66#endif /* MINGW */
67
68static int
69spcb(const ECRS_FileInfo * fi,
70 const HashCode512 * key,
71 int isRoot,
72 void * closure) {
73 SearchList * list = closure;
74 fs_search_result_received(list,
75 fi,
76 list->uri);
77 return OK;
78}
79
80
81void on_open_menu_activate_fs(GtkWidget * dummy1,
82 GtkWidget * dummy2) {
83 char * dn;
84 char * directory_data;
85 unsigned long long directory_data_len;
86 size_t dlen;
87 struct ECRS_MetaData * md;
88 int fd;
89 SearchList * list;
90 struct ECRS_URI * uri;
91 const char * kws[2];
92#if 1
93 /* somehow on my system I get this (and only this event)
94 always twice -- not sure why, but this is a workaround
95 for now */
96 static int modulo;
97
98 if (0 == (1 & modulo++))
99 return;
100#endif
101 dn = selectFile();
102 if (dn == NULL)
103 return;
104 if ( (YES != disk_file_test(NULL,
105 dn)) ||
106 (OK != disk_file_size(NULL,
107 dn,
108 &directory_data_len,
109 YES)) ) {
110 addLogEntry(_("Error accessing file `%s'."),
111 dn);
112 FREE(dn);
113 return;
114 }
115 fd = disk_file_open(NULL,
116 dn,
117 O_LARGEFILE | O_RDONLY);
118 if (fd == -1) {
119 addLogEntry(_("Error opening file `%s'."),
120 dn);
121 FREE(dn);
122 return;
123 }
124 dlen = (size_t) directory_data_len;
125 directory_data = MMAP(NULL,
126 dlen,
127 PROT_READ,
128 MAP_SHARED,
129 fd,
130 0);
131 if (directory_data == MAP_FAILED) {
132 addLogEntry(_("Error mapping file `%s' into memory."),
133 dn);
134 CLOSE(fd);
135 FREE(dn);
136 return;
137 }
138 kws[0] = dn;
139 kws[1] = NULL;
140 uri = ECRS_keywordsToUri(kws);
141 md = NULL;
142 list = fs_search_started(NULL,
143 uri,
144 0,
145 0,
146 NULL,
147 FSUI_COMPLETED);
148 ECRS_freeUri(uri);
149 ECRS_listDirectory(NULL,
150 directory_data,
151 directory_data_len,
152 &md,
153 &spcb,
154 list);
155 if (md != NULL)
156 ECRS_freeMetaData(md);
157 MUNMAP(directory_data, dlen);
158 CLOSE(fd);
159 FREE(dn);
160}
161
162/* end of directory.c */
diff --git a/src/plugins/fs/namespace.c b/src/plugins/fs/namespace.c
index 0b257c68..c81cbaa6 100644
--- a/src/plugins/fs/namespace.c
+++ b/src/plugins/fs/namespace.c
@@ -1439,11 +1439,6 @@ void fs_namespace_start() {
1439 DEBUG_END(); 1439 DEBUG_END();
1440} 1440}
1441 1441
1442void on_open_menu_activate_fs(GtkWidget * dummy1,
1443 GtkWidget * dummy2) {
1444 printf("Not implemented\n");
1445}
1446
1447#if 0 1442#if 0
1448void on_availableContentList_destroy_fs(GtkWidget * dummy1, 1443void on_availableContentList_destroy_fs(GtkWidget * dummy1,
1449 GtkWidget * dummy2) { 1444 GtkWidget * dummy2) {
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c
index a851b6cb..5c2b0df7 100644
--- a/src/plugins/fs/search.c
+++ b/src/plugins/fs/search.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2005, 2006 Christian Grothoff (and other contributing authors) 3 (C) 2005, 2006, 2007 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
@@ -908,13 +908,19 @@ void on_closeSearchButton_clicked_fs(GtkWidget * searchPage,
908 list = list->next; 908 list = list->next;
909 } 909 }
910 GE_ASSERT(ectx, list != NULL); 910 GE_ASSERT(ectx, list != NULL);
911 fcbc.method = &FSUI_abortSearch; 911 if (list->fsui_list == NULL) {
912 fcbc.argument = list->fsui_list; 912 /* open directory - close directly */
913 run_with_save_calls(&fsui_callback, 913 fs_search_stopped(list);
914 &fcbc); 914 } else {
915 fcbc.method = &FSUI_stopSearch; 915 /* actual search - close via FSUI */
916 run_with_save_calls(&fsui_callback, 916 fcbc.method = &FSUI_abortSearch;
917 &fcbc); 917 fcbc.argument = list->fsui_list;
918 run_with_save_calls(&fsui_callback,
919 &fcbc);
920 fcbc.method = &FSUI_stopSearch;
921 run_with_save_calls(&fsui_callback,
922 &fcbc);
923 }
918} 924}
919 925
920/** 926/**
@@ -932,11 +938,12 @@ void on_abortSearchButton_clicked_fs(GtkWidget * searchPage,
932 list = list->next; 938 list = list->next;
933 } 939 }
934 GE_ASSERT(ectx, list != NULL); 940 GE_ASSERT(ectx, list != NULL);
935 941 if (list->fsui_list != NULL) {
936 fcbc.method = &FSUI_abortSearch; 942 fcbc.method = &FSUI_abortSearch;
937 fcbc.argument = list->fsui_list; 943 fcbc.argument = list->fsui_list;
938 run_with_save_calls(&fsui_callback, 944 run_with_save_calls(&fsui_callback,
939 &fcbc); 945 &fcbc);
946 }
940} 947}
941 948
942static void stopSearch(GtkTreeModel * model, 949static void stopSearch(GtkTreeModel * model,
@@ -952,13 +959,18 @@ static void stopSearch(GtkTreeModel * model,
952 SEARCH_SUMMARY_INTERNAL, &s, 959 SEARCH_SUMMARY_INTERNAL, &s,
953 -1); 960 -1);
954 if (s != NULL) { 961 if (s != NULL) {
955 fcbc.method = &FSUI_abortSearch; 962 if (s->fsui_list == NULL) {
956 fcbc.argument = s->fsui_list; 963 /* open directory - close directly */
957 run_with_save_calls(&fsui_callback, 964 fs_search_stopped(s);
958 &fcbc); 965 } else {
959 fcbc.method = &FSUI_stopSearch; 966 fcbc.method = &FSUI_abortSearch;
960 run_with_save_calls(&fsui_callback, 967 fcbc.argument = s->fsui_list;
961 &fcbc); 968 run_with_save_calls(&fsui_callback,
969 &fcbc);
970 fcbc.method = &FSUI_stopSearch;
971 run_with_save_calls(&fsui_callback,
972 &fcbc);
973 }
962 } 974 }
963} 975}
964 976
@@ -988,7 +1000,8 @@ static void abortSearch(GtkTreeModel * model,
988 iter, 1000 iter,
989 SEARCH_SUMMARY_INTERNAL, &s, 1001 SEARCH_SUMMARY_INTERNAL, &s,
990 -1); 1002 -1);
991 if (s != NULL) { 1003 if ( (s != NULL) &&
1004 (s->fsui_list != NULL) ) {
992 fcbc.method = &FSUI_abortSearch; 1005 fcbc.method = &FSUI_abortSearch;
993 fcbc.argument = s->fsui_list; 1006 fcbc.argument = s->fsui_list;
994 run_with_save_calls(&fsui_callback, 1007 run_with_save_calls(&fsui_callback,
diff --git a/src/plugins/fs/upload.c b/src/plugins/fs/upload.c
index e8d91b2e..971c1bb9 100644
--- a/src/plugins/fs/upload.c
+++ b/src/plugins/fs/upload.c
@@ -452,7 +452,6 @@ void on_fsinsertuploadbutton_clicked_fs(gpointer dummy,
452} 452}
453 453
454#ifndef MINGW 454#ifndef MINGW
455
456static char * 455static char *
457selectFile(const char * oldfilename) { 456selectFile(const char * oldfilename) {
458 GladeXML * uploadXML; 457 GladeXML * uploadXML;