aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-05-30 18:34:35 +0000
committerChristian Grothoff <christian@grothoff.org>2013-05-30 18:34:35 +0000
commit85a4cb09701bb7f764ae79cd0adef9dc2b92a5e4 (patch)
tree4a237e064efff359c70c470018a94ded8ac849c8
parent397b94dcff90a976449523ad957f7f38c3b8cadf (diff)
downloadgnunet-gtk-85a4cb09701bb7f764ae79cd0adef9dc2b92a5e4.tar.gz
gnunet-gtk-85a4cb09701bb7f764ae79cd0adef9dc2b92a5e4.zip
-fixes, including grabbing FS handle as soon as possible
-rw-r--r--src/fs/gnunet-fs-gtk.c13
-rw-r--r--src/fs/gnunet-fs-gtk.h8
-rw-r--r--src/fs/gnunet-fs-gtk_event-handler.c49
3 files changed, 58 insertions, 12 deletions
diff --git a/src/fs/gnunet-fs-gtk.c b/src/fs/gnunet-fs-gtk.c
index 1617b5d2..ef5e03a7 100644
--- a/src/fs/gnunet-fs-gtk.c
+++ b/src/fs/gnunet-fs-gtk.c
@@ -101,6 +101,19 @@ GNUNET_FS_GTK_get_fs_handle ()
101 101
102 102
103/** 103/**
104 * Remember FS handle if we don't have one yet.
105 *
106 * @param fsh file sharing handle to use
107 */
108void
109GNUNET_FS_GTK_set_fs_handle (struct GNUNET_FS_Handle *fsh)
110{
111 if (NULL == fs)
112 fs = fsh;
113}
114
115
116/**
104 * Get our configuration. 117 * Get our configuration.
105 * 118 *
106 * @return configuration handle 119 * @return configuration handle
diff --git a/src/fs/gnunet-fs-gtk.h b/src/fs/gnunet-fs-gtk.h
index c5cfa7d6..c19e07b8 100644
--- a/src/fs/gnunet-fs-gtk.h
+++ b/src/fs/gnunet-fs-gtk.h
@@ -215,6 +215,14 @@ GNUNET_FS_GTK_get_fs_handle (void);
215 215
216 216
217/** 217/**
218 * Remember FS handle if we don't have one yet.
219 *
220 * @param fsh file sharing handle to use
221 */
222void
223GNUNET_FS_GTK_set_fs_handle (struct GNUNET_FS_Handle *fsh);
224
225/**
218 * Get an object from the main window. 226 * Get an object from the main window.
219 * 227 *
220 * @param name name of the object 228 * @param name name of the object
diff --git a/src/fs/gnunet-fs-gtk_event-handler.c b/src/fs/gnunet-fs-gtk_event-handler.c
index cab95366..030f5e88 100644
--- a/src/fs/gnunet-fs-gtk_event-handler.c
+++ b/src/fs/gnunet-fs-gtk_event-handler.c
@@ -978,23 +978,33 @@ struct sks_scanner_callback_context
978 void *cls; 978 void *cls;
979}; 979};
980 980
981/* Metadata callback. Checks metadata item for being an SKS URI, 981
982/**
983 * Metadata callback. Checks metadata item for being an SKS URI,
982 * invokes the callback if so. 984 * invokes the callback if so.
985 *
986 * @return GNUNET_OK if we did not invoke the callback, otherwise
987 * whatever the callback returned
983 */ 988 */
984static int 989static int
985check_for_embedded_sks (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, 990check_for_embedded_sks (void *cls,
986 enum EXTRACTOR_MetaFormat format, const char *data_mime_type, 991 const char *plugin_name,
987 const char *data, size_t data_size) 992 enum EXTRACTOR_MetaType type,
993 enum EXTRACTOR_MetaFormat format,
994 const char *data_mime_type,
995 const char *data, size_t data_size)
988{ 996{
989 struct sks_scanner_callback_context *ctx = cls; 997 struct sks_scanner_callback_context *ctx = cls;
990 int result; 998 int result;
991 999
1000 result = GNUNET_OK;
992 if ((EXTRACTOR_METATYPE_URI == type) && 1001 if ((EXTRACTOR_METATYPE_URI == type) &&
993 (EXTRACTOR_METAFORMAT_UTF8 == format) && 1002 (EXTRACTOR_METAFORMAT_UTF8 == format) &&
994 (data_mime_type && (0 == strcmp ("text/plain", data_mime_type)))) 1003 (data_mime_type && (0 == strcmp ("text/plain", data_mime_type))))
995 { 1004 {
996 struct GNUNET_FS_Uri *sks_uri; 1005 struct GNUNET_FS_Uri *sks_uri;
997 char *emsg; 1006 char *emsg;
1007
998 emsg = NULL; 1008 emsg = NULL;
999 sks_uri = GNUNET_FS_uri_parse (data, &emsg); 1009 sks_uri = GNUNET_FS_uri_parse (data, &emsg);
1000 if (NULL != sks_uri) 1010 if (NULL != sks_uri)
@@ -1018,16 +1028,23 @@ check_for_embedded_sks (void *cls, const char *plugin_name, enum EXTRACTOR_MetaT
1018 return result; 1028 return result;
1019} 1029}
1020 1030
1021/* Search metadata for SKS URIs, invoke the callback for each one. */ 1031
1032/**
1033 * Search metadata for SKS URIs, invoke the callback for each one.
1034 */
1022static void 1035static void
1023find_embedded_sks (const struct GNUNET_CONTAINER_MetaData *meta, embedded_sks_callback cb, void *cls) 1036find_embedded_sks (const struct GNUNET_CONTAINER_MetaData *meta,
1037 embedded_sks_callback cb, void *cls)
1024{ 1038{
1025 struct sks_scanner_callback_context ctx; 1039 struct sks_scanner_callback_context ctx;
1040
1026 ctx.cb = cb; 1041 ctx.cb = cb;
1027 ctx.cls = cls; 1042 ctx.cls = cls;
1028 GNUNET_CONTAINER_meta_data_iterate (meta, check_for_embedded_sks, &ctx); 1043 GNUNET_CONTAINER_meta_data_iterate (meta,
1044 &check_for_embedded_sks, &ctx);
1029} 1045}
1030 1046
1047
1031struct sks_population_context 1048struct sks_population_context
1032{ 1049{
1033 GtkMenu *menu; 1050 GtkMenu *menu;
@@ -2143,11 +2160,16 @@ update_search_result (struct SearchResult *sr,
2143 gtk_tree_path_free (tp); 2160 gtk_tree_path_free (tp);
2144} 2161}
2145 2162
2163
2146static int 2164static int
2147see_if_there_are_any_sks_uris (void *cls, const struct GNUNET_FS_Uri *sks_uri, 2165see_if_there_are_any_sks_uris (void *cls,
2148 const char *sks_uri_string, struct GNUNET_FS_PseudonymIdentifier *nsid) 2166 const struct GNUNET_FS_Uri *sks_uri,
2167 const char *sks_uri_string,
2168 struct GNUNET_FS_PseudonymIdentifier *nsid)
2149{ 2169{
2150 * ((gboolean *) cls) = TRUE; 2170 gboolean *gb = cls;
2171
2172 *gb = TRUE;
2151 return GNUNET_SYSERR; 2173 return GNUNET_SYSERR;
2152} 2174}
2153 2175
@@ -2231,7 +2253,9 @@ GNUNET_GTK_add_search_result (struct SearchTab *tab,
2231 desc = GNUNET_FS_GTK_get_description_from_metadata (meta, &desc_is_a_dup); 2253 desc = GNUNET_FS_GTK_get_description_from_metadata (meta, &desc_is_a_dup);
2232 pixbuf = GNUNET_FS_GTK_get_thumbnail_from_meta_data (meta); 2254 pixbuf = GNUNET_FS_GTK_get_thumbnail_from_meta_data (meta);
2233 2255
2234 find_embedded_sks (meta, see_if_there_are_any_sks_uris, &show_ns_association); 2256 find_embedded_sks (meta,
2257 &see_if_there_are_any_sks_uris,
2258 &show_ns_association);
2235 2259
2236 sr = GNUNET_new (struct SearchResult); 2260 sr = GNUNET_new (struct SearchResult);
2237 sr->result = result; 2261 sr->result = result;
@@ -3695,7 +3719,8 @@ GNUNET_GTK_fs_event_handler (void *cls,
3695 const struct GNUNET_FS_ProgressInfo *info) 3719 const struct GNUNET_FS_ProgressInfo *info)
3696{ 3720{
3697 void *ret; 3721 void *ret;
3698 3722
3723 GNUNET_FS_GTK_set_fs_handle (info->fsh);
3699 switch (info->status) 3724 switch (info->status)
3700 { 3725 {
3701 case GNUNET_FS_STATUS_PUBLISH_START: 3726 case GNUNET_FS_STATUS_PUBLISH_START: