diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-08-11 12:32:23 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-08-11 12:32:23 +0000 |
commit | 53474ae4ed557c4432e2748dd334c1b20386ee0f (patch) | |
tree | f7b898c396d21fd2bf983249ae14a462cbe3d6d2 /src/identity | |
parent | d47efb829ce86cf28c05df51452f2611cdc92c3c (diff) | |
download | gnunet-gtk-53474ae4ed557c4432e2748dd334c1b20386ee0f.tar.gz gnunet-gtk-53474ae4ed557c4432e2748dd334c1b20386ee0f.zip |
-towards advertisement handling
Diffstat (limited to 'src/identity')
-rw-r--r-- | src/identity/Makefile.am | 3 | ||||
-rw-r--r-- | src/identity/gnunet-identity-gtk.c | 16 | ||||
-rw-r--r-- | src/identity/gnunet-identity-gtk_namespace_manager.c | 300 | ||||
-rw-r--r-- | src/identity/gnunet-identity-gtk_namespace_manager.h | 29 |
4 files changed, 279 insertions, 69 deletions
diff --git a/src/identity/Makefile.am b/src/identity/Makefile.am index 001a4e29..2213b076 100644 --- a/src/identity/Makefile.am +++ b/src/identity/Makefile.am | |||
@@ -11,7 +11,8 @@ bin_PROGRAMS = gnunet-identity-gtk | |||
11 | 11 | ||
12 | gnunet_identity_gtk_SOURCES = \ | 12 | gnunet_identity_gtk_SOURCES = \ |
13 | gnunet-identity-gtk.c \ | 13 | gnunet-identity-gtk.c \ |
14 | gnunet-identity-gtk_about.c | 14 | gnunet-identity-gtk_about.c \ |
15 | gnunet-identity-gtk_namespace_manager.c gnunet-identity-gtk_namespace_manager.h | ||
15 | gnunet_identity_gtk_LDADD = \ | 16 | gnunet_identity_gtk_LDADD = \ |
16 | $(top_builddir)/src/lib/libgnunetgtk.la \ | 17 | $(top_builddir)/src/lib/libgnunetgtk.la \ |
17 | @GTK_LIBS@ \ | 18 | @GTK_LIBS@ \ |
diff --git a/src/identity/gnunet-identity-gtk.c b/src/identity/gnunet-identity-gtk.c index 69db7e65..9128d44e 100644 --- a/src/identity/gnunet-identity-gtk.c +++ b/src/identity/gnunet-identity-gtk.c | |||
@@ -25,6 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | #include "gnunet_gtk.h" | 26 | #include "gnunet_gtk.h" |
27 | #include <gnunet/gnunet_identity_service.h> | 27 | #include <gnunet/gnunet_identity_service.h> |
28 | #include "gnunet-identity-gtk_namespace_manager.h" | ||
28 | 29 | ||
29 | 30 | ||
30 | /** | 31 | /** |
@@ -159,11 +160,6 @@ struct AdvertisePopupContext | |||
159 | * Ego to advertise. | 160 | * Ego to advertise. |
160 | */ | 161 | */ |
161 | struct GNUNET_IDENTITY_Ego *ego; | 162 | struct GNUNET_IDENTITY_Ego *ego; |
162 | |||
163 | /** | ||
164 | * Row where the search list popup was created. | ||
165 | */ | ||
166 | GtkTreeRowReference *rr; | ||
167 | 163 | ||
168 | }; | 164 | }; |
169 | 165 | ||
@@ -176,11 +172,13 @@ struct AdvertisePopupContext | |||
176 | */ | 172 | */ |
177 | static void | 173 | static void |
178 | advertise_ctx_menu (GtkMenuItem *item, | 174 | advertise_ctx_menu (GtkMenuItem *item, |
179 | gpointer user_data) | 175 | gpointer user_data) |
180 | { | 176 | { |
181 | struct AdvertisePopupContext *apc = user_data; | 177 | struct AdvertisePopupContext *apc = user_data; |
178 | const struct GNUNET_CRYPTO_EccPrivateKey *priv; | ||
182 | 179 | ||
183 | fprintf (stderr, "ADVERTISE TIME!\n"); | 180 | priv = GNUNET_IDENTITY_ego_get_private_key (apc->ego); |
181 | GNUNET_IDENTITY_advertise_dialog_start_ (priv); | ||
184 | } | 182 | } |
185 | 183 | ||
186 | 184 | ||
@@ -197,7 +195,6 @@ advertise_popup_selection_done (GtkMenuShell *menushell, | |||
197 | struct AdvertisePopupContext *apc = user_data; | 195 | struct AdvertisePopupContext *apc = user_data; |
198 | 196 | ||
199 | gtk_widget_destroy (GTK_WIDGET (menushell)); | 197 | gtk_widget_destroy (GTK_WIDGET (menushell)); |
200 | gtk_tree_row_reference_free (apc->rr); | ||
201 | GNUNET_free (apc); | 198 | GNUNET_free (apc); |
202 | } | 199 | } |
203 | 200 | ||
@@ -240,6 +237,7 @@ GNUNET_GTK_identity_treeview_button_press_event_cb (GtkWidget *widget, | |||
240 | gtk_tree_path_free (path); | 237 | gtk_tree_path_free (path); |
241 | return FALSE; /* not sure how we got a path but no iter... */ | 238 | return FALSE; /* not sure how we got a path but no iter... */ |
242 | } | 239 | } |
240 | gtk_tree_path_free (path); | ||
243 | gtk_tree_model_get (GTK_TREE_MODEL (ls), &iter, | 241 | gtk_tree_model_get (GTK_TREE_MODEL (ls), &iter, |
244 | IDENTITY_MC_EGO, &ego, | 242 | IDENTITY_MC_EGO, &ego, |
245 | -1); | 243 | -1); |
@@ -247,8 +245,6 @@ GNUNET_GTK_identity_treeview_button_press_event_cb (GtkWidget *widget, | |||
247 | return FALSE; | 245 | return FALSE; |
248 | apc = GNUNET_new (struct AdvertisePopupContext); | 246 | apc = GNUNET_new (struct AdvertisePopupContext); |
249 | apc->ego = ego; | 247 | apc->ego = ego; |
250 | apc->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ls), path); | ||
251 | gtk_tree_path_free (path); | ||
252 | menu = GTK_MENU (gtk_menu_new ()); | 248 | menu = GTK_MENU (gtk_menu_new ()); |
253 | child = gtk_menu_item_new_with_label (_("_Advertise")); | 249 | child = gtk_menu_item_new_with_label (_("_Advertise")); |
254 | g_signal_connect (child, "activate", | 250 | g_signal_connect (child, "activate", |
diff --git a/src/identity/gnunet-identity-gtk_namespace_manager.c b/src/identity/gnunet-identity-gtk_namespace_manager.c index ca4a14c5..788c18a3 100644 --- a/src/identity/gnunet-identity-gtk_namespace_manager.c +++ b/src/identity/gnunet-identity-gtk_namespace_manager.c | |||
@@ -19,60 +19,266 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file src/fs/gnunet-fs-gtk_namespace_manager.c | 22 | * @file src/identity/gnunet-identity-gtk_namespace_manager.c |
23 | * @author LRN | 23 | * @author LRN |
24 | * @author Christian Grothoff | ||
24 | */ | 25 | */ |
25 | #include "gnunet-fs-gtk_common.h" | 26 | #include "gnunet-identity-gtk_namespace_manager.h" |
26 | #include "gnunet-fs-gtk.h" | ||
27 | #include <gnunet/gnunet_util_lib.h> | ||
28 | #include <gnunet/gnunet_fs_service.h> | 27 | #include <gnunet/gnunet_fs_service.h> |
29 | 28 | ||
30 | struct GNUNET_GTK_NamespaceManagerContext | 29 | /** |
30 | * Types of metadata we offer for namespaces. | ||
31 | */ | ||
32 | static gint types[] = { | ||
33 | EXTRACTOR_METATYPE_TITLE, | ||
34 | EXTRACTOR_METATYPE_KEYWORDS, | ||
35 | EXTRACTOR_METATYPE_SUBJECT, | ||
36 | EXTRACTOR_METATYPE_DESCRIPTION, | ||
37 | EXTRACTOR_METATYPE_COMMENT, | ||
38 | EXTRACTOR_METATYPE_COPYRIGHT, | ||
39 | EXTRACTOR_METATYPE_URI, | ||
40 | EXTRACTOR_METATYPE_CREATOR, | ||
41 | EXTRACTOR_METATYPE_CREATION_DATE, | ||
42 | EXTRACTOR_METATYPE_RESERVED | ||
43 | }; | ||
44 | |||
45 | |||
46 | /** | ||
47 | * Columns in the metadata list store. | ||
48 | */ | ||
49 | enum METADATA_ModelColumns | ||
50 | { | ||
51 | /** | ||
52 | * A guint | ||
53 | */ | ||
54 | METADATA_MC_TYPE_AS_ENUM = 0, | ||
55 | |||
56 | /** | ||
57 | * A gchararray | ||
58 | */ | ||
59 | METADATA_MC_TYPE_AS_STRING = 1, | ||
60 | |||
61 | /** | ||
62 | * A gchararray | ||
63 | */ | ||
64 | METADATA_MC_VALUE = 2 | ||
65 | |||
66 | }; | ||
67 | |||
68 | |||
69 | /** | ||
70 | * Columns in the keyword list tree store. | ||
71 | */ | ||
72 | enum KEYWORDS_ModelColumns | ||
73 | { | ||
74 | |||
75 | /** | ||
76 | * A gchararray | ||
77 | */ | ||
78 | KEYWORDS_MC_KEYWORD = 0 | ||
79 | |||
80 | }; | ||
81 | |||
82 | |||
83 | /** | ||
84 | * Columns in the meta types list tree store. | ||
85 | */ | ||
86 | enum METATYPES_ModelColumns | ||
87 | { | ||
88 | |||
89 | /** | ||
90 | * A gchararray | ||
91 | */ | ||
92 | METATYPES_MC_TYPE_AS_STRING = 0, | ||
93 | |||
94 | /** | ||
95 | * A guint | ||
96 | */ | ||
97 | METATYPES_MC_TYPE_AS_ENUM = 1 | ||
98 | |||
99 | }; | ||
100 | |||
101 | |||
102 | /** | ||
103 | * Context for advertisement operations. | ||
104 | */ | ||
105 | struct AdvertiseContext | ||
31 | { | 106 | { |
107 | /** | ||
108 | * Builder for accessing objects in the dialog. | ||
109 | */ | ||
32 | GtkBuilder *builder; | 110 | GtkBuilder *builder; |
33 | GtkWidget *known_ns; | 111 | |
34 | GtkWidget *ns_order; | 112 | /** |
35 | GtkWidget *ns_details; | 113 | * Private key of the namespace we will be advertising. |
36 | GtkTreeSelection *known_ns_sel; | 114 | */ |
37 | GtkTreeSelection *ns_order_sel; | 115 | struct GNUNET_CRYPTO_EccPrivateKey priv; |
38 | GtkTreeSelection *ns_details_sel; | 116 | |
39 | GtkListStore *ns_order_store; | 117 | /** |
40 | GtkListStore *known_ns_store; | 118 | * Main dialog object. |
41 | GtkListStore *ns_details_store; | 119 | */ |
42 | GtkWindow *namespace_manager; | 120 | GtkWidget *dialog; |
43 | GtkTreeViewColumn *order_rank; | 121 | |
44 | GtkTreeViewColumn *order_name; | 122 | /** |
45 | GtkTreeViewColumn *order_id; | 123 | * List of keywords to advertise under. |
46 | GtkWidget *details_apply_button; | 124 | */ |
47 | GtkWidget *details_delete_button; | 125 | GtkListStore *keywords; |
48 | int sort_direction; | 126 | |
49 | GList *deleted_namespaces; | 127 | /** |
50 | struct GNUNET_CONTAINER_MetaData *uneditable_md; | 128 | * Metadata to include in the advertisement. |
51 | struct GNUNET_GTK_MainWindowContext *main_ctx; | 129 | */ |
130 | GtkListStore *metadata; | ||
131 | |||
132 | /** | ||
133 | * Model with the meta types. | ||
134 | */ | ||
135 | GtkListStore *meta_types; | ||
136 | |||
52 | }; | 137 | }; |
53 | 138 | ||
54 | #define GNUNET_GTK_KNOWN_NAMESPACES_IS_MINE_COLUMN 0 | ||
55 | #define GNUNET_GTK_KNOWN_NAMESPACES_RANK_COLUMN 1 | ||
56 | #define GNUNET_GTK_KNOWN_NAMESPACES_NAME_COLUMN 2 | ||
57 | #define GNUNET_GTK_KNOWN_NAMESPACES_IDENTIFIER_COLUMN 3 | ||
58 | #define GNUNET_GTK_KNOWN_NAMESPACES_IDENTIFIER_BIN_COLUMN 4 | ||
59 | #define GNUNET_GTK_KNOWN_NAMESPACES_ORDER_ROW_REFERENCE_COLUMN 5 | ||
60 | #define GNUNET_GTK_KNOWN_NAMESPACES_METADATA_COLUMN 6 | ||
61 | #define GNUNET_GTK_KNOWN_NAMESPACES_NON_UNIQUE_NAME_COLUMN 7 | ||
62 | |||
63 | #define GNUNET_GTK_NAMESPACE_ORDER_RANK_COLUMN 0 | ||
64 | #define GNUNET_GTK_NAMESPACE_ORDER_NAME_COLUMN 1 | ||
65 | #define GNUNET_GTK_NAMESPACE_ORDER_IDENTIFIER_COLUMN 2 | ||
66 | #define GNUNET_GTK_NAMESPACE_ORDER_IDENTIFIER_BIN_COLUMN 3 | ||
67 | #define GNUNET_GTK_NAMESPACE_ORDER_KNOWN_ROW_REFERENCE_COLUMN 4 | ||
68 | |||
69 | #define GNUNET_GTK_NAMESPACE_DETAILS_PLUGIN_NAME_COLUMN 0 | ||
70 | #define GNUNET_GTK_NAMESPACE_DETAILS_TYPE_BIN_COLUMN 1 | ||
71 | #define GNUNET_GTK_NAMESPACE_DETAILS_TYPE_COLUMN 2 | ||
72 | #define GNUNET_GTK_NAMESPACE_DETAILS_FORMAT_COLUMN 3 | ||
73 | #define GNUNET_GTK_NAMESPACE_DETAILS_DATA_MIME_COLUMN 4 | ||
74 | #define GNUNET_GTK_NAMESPACE_DETAILS_VALUE_COLUMN 5 | ||
75 | 139 | ||
140 | /** | ||
141 | * The user terminated the dialog. Perform the appropriate action. | ||
142 | * | ||
143 | * @param dialog the advertisement dialog | ||
144 | * @param response_id action selected by the user | ||
145 | * @param user_data our 'struct AdvertiseContext' (to be cleaned up) | ||
146 | */ | ||
147 | void | ||
148 | GNUNET_GTK_identity_advertise_dialog_response_cb (GtkDialog *dialog, | ||
149 | gint response_id, | ||
150 | gpointer user_data) | ||
151 | { | ||
152 | struct AdvertiseContext *ac = user_data; | ||
153 | |||
154 | if (GTK_RESPONSE_OK == response_id) | ||
155 | { | ||
156 | GNUNET_break (0); // FIXME: not implemented | ||
157 | } | ||
158 | |||
159 | gtk_widget_destroy (ac->dialog); | ||
160 | g_object_unref (G_OBJECT (ac->builder)); | ||
161 | GNUNET_free (ac); | ||
162 | } | ||
163 | |||
164 | |||
165 | /** | ||
166 | * FIXME: do we need this event? If so, what do we do? | ||
167 | */ | ||
168 | void | ||
169 | GNUNET_GTK_identity_advertise_keywords_column_clicked_cb () | ||
170 | { | ||
171 | GNUNET_break (0); | ||
172 | } | ||
173 | |||
174 | |||
175 | /** | ||
176 | * User edited keywords in the keyword tree view. Update | ||
177 | * the model accordingly. | ||
178 | */ | ||
179 | void | ||
180 | GNUNET_GTK_identity_advertise_keywords_text_edited_cb () | ||
181 | { | ||
182 | GNUNET_break (0); | ||
183 | } | ||
184 | |||
185 | |||
186 | /** | ||
187 | * User pushed a key in the metadata tree view. Check if it was | ||
188 | * "DEL" and if so, remove the selected values. | ||
189 | */ | ||
190 | void | ||
191 | GNUNET_GTK_identity_advertise_metadata_treeview_key_press_event_cb () | ||
192 | { | ||
193 | GNUNET_break (0); | ||
194 | } | ||
195 | |||
196 | |||
197 | /** | ||
198 | * FIXME: how is this event triggered exactly? | ||
199 | */ | ||
200 | void | ||
201 | GNUNET_GTK_identity_advertise_metadata_treeview_delete_event_cb () | ||
202 | { | ||
203 | GNUNET_break (0); | ||
204 | } | ||
205 | |||
206 | |||
207 | /** | ||
208 | * User edited metadata value. Update sensitivity of the 'add' button. | ||
209 | */ | ||
210 | void | ||
211 | GNUNET_GTK_identity_advertise_metadata_value_text_edited_cb () | ||
212 | { | ||
213 | GNUNET_break (0); | ||
214 | } | ||
215 | |||
216 | |||
217 | /** | ||
218 | * User edited metadata type. Not sure we need to do something here... | ||
219 | */ | ||
220 | void | ||
221 | GNUNET_GTK_identity_advertise_metadata_type_text_edited_cb () | ||
222 | { | ||
223 | GNUNET_break (0); | ||
224 | } | ||
225 | |||
226 | |||
227 | /** | ||
228 | * User clicked the 'add' button, get the type and value and update | ||
229 | * the metadata model. | ||
230 | */ | ||
231 | void | ||
232 | GNUNET_GTK_identity_advertise_metadata_add_button_clicked_cb () | ||
233 | { | ||
234 | GNUNET_break (0); | ||
235 | } | ||
236 | |||
237 | |||
238 | /** | ||
239 | * Run the dialog for advertising a namespace. | ||
240 | * | ||
241 | * @param priv private key of the namespace to advertise | ||
242 | */ | ||
243 | void | ||
244 | GNUNET_IDENTITY_advertise_dialog_start_ (const struct GNUNET_CRYPTO_EccPrivateKey *priv) | ||
245 | { | ||
246 | struct AdvertiseContext *ac; | ||
247 | gint i; | ||
248 | GtkTreeIter iter; | ||
249 | |||
250 | ac = GNUNET_new (struct AdvertiseContext); | ||
251 | ac->priv = *priv; | ||
252 | ac->builder = | ||
253 | GNUNET_GTK_get_new_builder ("gnunet_identity_gtk_advertise_dialog.glade", | ||
254 | ac); | ||
255 | if (NULL == ac->builder) | ||
256 | { | ||
257 | GNUNET_break (0); | ||
258 | GNUNET_free (ac); | ||
259 | return; | ||
260 | } | ||
261 | ac->dialog = GTK_WIDGET (gtk_builder_get_object | ||
262 | (ac->builder, "GNUNET_GTK_identity_advertise_dialog")); | ||
263 | ac->keywords = GTK_LIST_STORE (gtk_builder_get_object | ||
264 | (ac->builder, "GNUNET_GTK_identity_advertise_keywords_liststore")); | ||
265 | ac->metadata = GTK_LIST_STORE (gtk_builder_get_object | ||
266 | (ac->builder, "GNUNET_GTK_identity_advertise_metadata_liststore")); | ||
267 | ac->meta_types = GTK_LIST_STORE (gtk_builder_get_object | ||
268 | (ac->builder, "GNUNET_GTK_identity_metadata_types_liststore")); | ||
269 | for (i = 0; EXTRACTOR_METATYPE_RESERVED != types[i]; i++) | ||
270 | gtk_list_store_insert_with_values (ac->meta_types, | ||
271 | &iter, G_MAXINT, | ||
272 | METATYPES_MC_TYPE_AS_STRING, | ||
273 | EXTRACTOR_metatype_to_string (types[i]), | ||
274 | METATYPES_MC_TYPE_AS_ENUM, | ||
275 | types[i], | ||
276 | -1); | ||
277 | gtk_window_present (GTK_WINDOW (ac->dialog)); | ||
278 | } | ||
279 | |||
280 | |||
281 | #if 0 | ||
76 | 282 | ||
77 | static void | 283 | static void |
78 | sort_order_list (struct GNUNET_GTK_NamespaceManagerContext *ctx, | 284 | sort_order_list (struct GNUNET_GTK_NamespaceManagerContext *ctx, |
@@ -1064,6 +1270,6 @@ namespace_selector_manage_namespaces_button_clicked_cb (GtkButton *button, gpoin | |||
1064 | { | 1270 | { |
1065 | GNUNET_GTK_open_ns_manager (user_data); | 1271 | GNUNET_GTK_open_ns_manager (user_data); |
1066 | } | 1272 | } |
1273 | #endif | ||
1067 | 1274 | ||
1068 | 1275 | /* end of gnunet-identity-gtk_namespace_manager.c */ | |
1069 | /* end of gnunet-fs-gtk_namespace_manager.c */ | ||
diff --git a/src/identity/gnunet-identity-gtk_namespace_manager.h b/src/identity/gnunet-identity-gtk_namespace_manager.h index cffa6894..aceca5e4 100644 --- a/src/identity/gnunet-identity-gtk_namespace_manager.h +++ b/src/identity/gnunet-identity-gtk_namespace_manager.h | |||
@@ -1,10 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | (C) 2005, 2006, 2010, 2012 Christian Grothoff (and other contributing authors) | 3 | (C) 2005-2013 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 |
7 | by the Free Software Foundation; either version 2, or (at your | 7 | by the Free Software Foundation; either version 3, or (at your |
8 | option) any later version. | 8 | option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
@@ -19,18 +19,25 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file src/fs/gnunet-fs-gtk_namespace_manager.h | 22 | * @file src/identity/gnunet-identity-gtk_namespace_manager.h |
23 | * @author LRN | 23 | * @author LRN |
24 | * @author Christian Grothoff | ||
24 | */ | 25 | */ |
25 | 26 | ||
26 | #ifndef GNUNET_FS_GTK_NAMESPACE_MANAGER_H | 27 | #ifndef GNUNET_IDENTITY_GTK_NAMESPACE_MANAGER_H |
27 | #define GNUNET_FS_GTK_NAMESPACE_MANAGER_H | 28 | #define GNUNET_IDENTITY_GTK_NAMESPACE_MANAGER_H |
28 | 29 | ||
29 | #include "gnunet-fs-gtk_common.h" | 30 | #include "gnunet_gtk.h" |
30 | #include "gnunet-fs-gtk.h" | ||
31 | 31 | ||
32 | GtkObject * | 32 | /** |
33 | GNUNET_GTK_namespace_manager_open (struct GNUNET_GTK_MainWindowContext *main_ctx); | 33 | * Run the dialog for advertising a namespace. |
34 | * | ||
35 | * @param priv private key of the namespace to advertise | ||
36 | */ | ||
37 | void | ||
38 | GNUNET_IDENTITY_advertise_dialog_start_ (const struct GNUNET_CRYPTO_EccPrivateKey *priv); | ||
39 | |||
40 | #endif | ||
41 | /* GNUNET_FS_GTK_NAMESPACE_MANAGER_H */ | ||
34 | 42 | ||
35 | #endif /* GNUNET_FS_GTK_NAMESPACE_MANAGER_H */ | 43 | /* end of gnunet-identity-gtk_namespace_manager.h */ |
36 | /* end of gnunet-fs-gtk_namespace_manager.c */ | ||