diff options
Diffstat (limited to 'src/conversation/gnunet-conversation-gtk_contacts.c')
-rw-r--r-- | src/conversation/gnunet-conversation-gtk_contacts.c | 673 |
1 files changed, 673 insertions, 0 deletions
diff --git a/src/conversation/gnunet-conversation-gtk_contacts.c b/src/conversation/gnunet-conversation-gtk_contacts.c new file mode 100644 index 00000000..6daf8a0f --- /dev/null +++ b/src/conversation/gnunet-conversation-gtk_contacts.c | |||
@@ -0,0 +1,673 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2010-2013 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 3, 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/conversation/gnunet-conversation-gtk_contacts.c | ||
23 | * @brief | ||
24 | * @author yids | ||
25 | * @author hark | ||
26 | */ | ||
27 | #include "gnunet-conversation-gtk_common.h" | ||
28 | #include "gnunet-conversation-gtk.h" | ||
29 | |||
30 | |||
31 | //#include "gnunet/gnunet_gnsrecord_lib.h" | ||
32 | |||
33 | |||
34 | |||
35 | /////////////////// | ||
36 | //addressbook | ||
37 | //#include "gnunet_gtk.h" | ||
38 | |||
39 | //#include "gnunet/gnunet_identity_service.h" | ||
40 | //#include "gnunet/gnunet_namestore_service.h" | ||
41 | //#include "gnunet/gnunet_gnsrecord_lib.h" | ||
42 | |||
43 | /************* | ||
44 | * contacts * | ||
45 | *************/ | ||
46 | /** | ||
47 | * Our configurations. | ||
48 | */ | ||
49 | static struct GNUNET_CONFIGURATION_Handle *cfg; | ||
50 | /** | ||
51 | * Name of our ego. | ||
52 | */ | ||
53 | static char *contacts_ego_name; | ||
54 | |||
55 | /** | ||
56 | * Our ego. | ||
57 | */ | ||
58 | static struct GNUNET_IDENTITY_Ego *contacts_ego; | ||
59 | |||
60 | |||
61 | |||
62 | //static struct GNUNET_CONFIGURATION_Handle *cfg1; | ||
63 | //static struct GNUNET_CONFIGURATION_Handle *cfg2; | ||
64 | /** | ||
65 | * Be verbose. | ||
66 | */ | ||
67 | static int verbose = 1; | ||
68 | |||
69 | |||
70 | |||
71 | char *currentlySelectedCallAddress; | ||
72 | |||
73 | //static void | ||
74 | //identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, | ||
75 | // const char *name); | ||
76 | |||
77 | |||
78 | /** | ||
79 | * List of contacts (records). | ||
80 | */ | ||
81 | static GtkListStore *contacts_liststore; | ||
82 | |||
83 | |||
84 | /** | ||
85 | * list of zones | ||
86 | */ | ||
87 | static GtkListStore *zone_liststore; | ||
88 | |||
89 | /** | ||
90 | * zone treestore | ||
91 | */ | ||
92 | static GtkTreeStore *zone_treestore; | ||
93 | |||
94 | /** | ||
95 | * zone treeview | ||
96 | */ | ||
97 | static GtkTreeView *zone_treeview; | ||
98 | |||
99 | /** | ||
100 | * zone tree model | ||
101 | */ | ||
102 | static GtkTreeModel *zone_treemodel; | ||
103 | |||
104 | |||
105 | |||
106 | /** | ||
107 | * List of contacts. | ||
108 | */ | ||
109 | //static GtkTreeStore *contacts_treestore; | ||
110 | |||
111 | /** | ||
112 | * The main tree view for 'gns' that shows the records. | ||
113 | */ | ||
114 | static GtkTreeView *contacts_treeview; | ||
115 | |||
116 | /** | ||
117 | * Tree model (same object as 'contacts_treestore', just different type). | ||
118 | */ | ||
119 | static GtkTreeModel *contacts_treemodel; | ||
120 | |||
121 | /* | ||
122 | * List iterator for the 'list' operation. | ||
123 | */ | ||
124 | static struct GNUNET_NAMESTORE_ZoneIterator *list_it; | ||
125 | |||
126 | |||
127 | static struct GNUNET_IDENTITY_Ego *currentAddressBookEgo; | ||
128 | /** | ||
129 | * Handle to identity service. | ||
130 | */ | ||
131 | static struct GNUNET_IDENTITY_Handle *id; | ||
132 | |||
133 | |||
134 | |||
135 | /** | ||
136 | * Handle to the namestore. | ||
137 | */ | ||
138 | struct GNUNET_NAMESTORE_Handle *ns; | ||
139 | |||
140 | /** | ||
141 | * Private key for the our zone. | ||
142 | */ | ||
143 | struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey; | ||
144 | |||
145 | /** | ||
146 | * Public key of the zone we are currently editing. | ||
147 | */ | ||
148 | struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; | ||
149 | |||
150 | |||
151 | |||
152 | |||
153 | /** | ||
154 | * Name of the records to add/list/remove. | ||
155 | */ | ||
156 | static char *name; | ||
157 | |||
158 | /** | ||
159 | * Queue entry for the 'add' operation. | ||
160 | */ | ||
161 | static struct GNUNET_NAMESTORE_QueueEntry *add_qe; | ||
162 | |||
163 | /** | ||
164 | * Queue entry for the 'del' operation. | ||
165 | */ | ||
166 | static struct GNUNET_NAMESTORE_QueueEntry *del_qe; | ||
167 | |||
168 | |||
169 | |||
170 | //////////////////////////// | ||
171 | static void | ||
172 | display_record (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | ||
173 | const char *rname, unsigned int rd_len, | ||
174 | const struct GNUNET_GNSRECORD_Data *rd) | ||
175 | { | ||
176 | const char *typestring; | ||
177 | char *s, *type; | ||
178 | unsigned int i; | ||
179 | const char *ets; | ||
180 | struct GNUNET_TIME_Absolute at; | ||
181 | struct GNUNET_TIME_Relative rt; | ||
182 | GtkTreeIter display_iter; | ||
183 | |||
184 | if (NULL == rname) | ||
185 | { | ||
186 | list_it = NULL; | ||
187 | //test_finished (); | ||
188 | return; | ||
189 | } | ||
190 | for (i = 0; i < rd_len; i++) | ||
191 | { | ||
192 | |||
193 | if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) && | ||
194 | (0 != strcmp (rname, "+"))) | ||
195 | continue; | ||
196 | typestring = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type); | ||
197 | s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type, rd[i].data, | ||
198 | rd[i].data_size); | ||
199 | if (NULL == s) | ||
200 | { | ||
201 | FPRINTF (stdout, _("\tCorrupt or unsupported record of type %u\n"), | ||
202 | (unsigned int) rd[i].record_type); | ||
203 | continue; | ||
204 | } | ||
205 | if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) | ||
206 | { | ||
207 | rt.rel_value_us = rd[i].expiration_time; | ||
208 | ets = GNUNET_STRINGS_relative_time_to_string (rt, GNUNET_YES); | ||
209 | } | ||
210 | else | ||
211 | { | ||
212 | at.abs_value_us = rd[i].expiration_time; | ||
213 | ets = GNUNET_STRINGS_absolute_time_to_string (at); | ||
214 | } | ||
215 | if (rd[i].record_type == 65536) | ||
216 | { | ||
217 | type = "PKEY"; | ||
218 | } // if pubkey record | ||
219 | if (rd[i].record_type == 65542) | ||
220 | { | ||
221 | type = "PHONE"; | ||
222 | } | ||
223 | // FPRINTF (stdout, "%s", rname); | ||
224 | if (rd[i].record_type == 65536 || rd[i].record_type == 65542) | ||
225 | { | ||
226 | gtk_list_store_append (contacts_liststore, &display_iter); | ||
227 | gtk_list_store_set (contacts_liststore, &display_iter, 1, type, 0, rname, -1); | ||
228 | } | ||
229 | |||
230 | /* FPRINTF (stdout, | ||
231 | "\t%s: %s (%s)\t%s\t%s\t%s\n", | ||
232 | typestring, | ||
233 | s, | ||
234 | ets, | ||
235 | (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) ? "PRIVATE" : "PUBLIC", | ||
236 | (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) ? "SHADOW" : "", | ||
237 | (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PENDING)) ? "PENDING" : ""); | ||
238 | */ | ||
239 | //gtk_widget_show(contacts_liststore); | ||
240 | GNUNET_free (s); | ||
241 | } | ||
242 | // FPRINTF (stdout, "%s", "\n"); | ||
243 | GNUNET_NAMESTORE_zone_iterator_next (list_it); | ||
244 | } | ||
245 | |||
246 | |||
247 | |||
248 | /** | ||
249 | * Function called by identity service with information about egos. | ||
250 | * | ||
251 | * @param cls NULL | ||
252 | * @param ego ego handle | ||
253 | * @param ctx unused | ||
254 | * @param name name of the ego | ||
255 | */ | ||
256 | static void | ||
257 | identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, | ||
258 | const char *name) | ||
259 | { | ||
260 | struct GNUNET_CRYPTO_EcdsaPublicKey pk; | ||
261 | char *s; | ||
262 | GtkTreeIter iter; | ||
263 | |||
264 | if (NULL != ego) | ||
265 | { | ||
266 | GNUNET_IDENTITY_ego_get_public_key (ego, &pk); | ||
267 | s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); | ||
268 | fprintf (stderr, "contacts idenity_cb: %s \n", name); | ||
269 | |||
270 | |||
271 | /* FIXME: this should be done in gnunet-conversation-gtk.c */ | ||
272 | gtk_list_store_insert_with_values (zone_liststore, | ||
273 | &iter, -1, | ||
274 | 0, name, | ||
275 | 1, ego, | ||
276 | -1); | ||
277 | |||
278 | } | ||
279 | |||
280 | /* | ||
281 | if (NULL == name) | ||
282 | return; | ||
283 | if (ego == contacts_ego) | ||
284 | { | ||
285 | //if (verbose) | ||
286 | LOG (_("Name of phonebook ego changed to `%s'\n"), name); | ||
287 | GNUNET_free (contacts_ego_name); | ||
288 | contacts_ego_name = GNUNET_strdup (name); | ||
289 | return; | ||
290 | } | ||
291 | if (0 != strcmp (name, contacts_ego_name)) | ||
292 | return; | ||
293 | if (NULL == ego) | ||
294 | { | ||
295 | if (verbose) | ||
296 | LOG (_("Our phonebook ego `%s' was deleted!\n"), contacts_ego_name); | ||
297 | contacts_ego = NULL; | ||
298 | return; | ||
299 | } | ||
300 | */ | ||
301 | contacts_ego = ego; | ||
302 | |||
303 | |||
304 | // zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id); | ||
305 | ns = GNUNET_NAMESTORE_connect (cfg); | ||
306 | |||
307 | |||
308 | // list_it = | ||
309 | // GNUNET_NAMESTORE_zone_iteration_start (ns, &zone_pkey, &display_record, | ||
310 | // NULL); | ||
311 | |||
312 | } | ||
313 | /** | ||
314 | * Continuation called to notify client about result of the | ||
315 | * operation. | ||
316 | * | ||
317 | * @param cls closure, location of the QueueEntry pointer to NULL out | ||
318 | * @param success #GNUNET_SYSERR on failure (including timeout/queue drop/failure to validate) | ||
319 | * #GNUNET_NO if content was already there | ||
320 | * #GNUNET_YES (or other positive value) on success | ||
321 | * @param emsg NULL on success, otherwise an error message | ||
322 | */ | ||
323 | static void | ||
324 | add_continuation (void *cls, int32_t success, const char *emsg) | ||
325 | { | ||
326 | |||
327 | struct GNUNET_NAMESTORE_QueueEntry **qe = cls; | ||
328 | |||
329 | *qe = NULL; | ||
330 | if (GNUNET_YES != success) | ||
331 | { | ||
332 | fprintf (stderr, _("Adding record failed: %s\n"), | ||
333 | (GNUNET_NO == success) ? "record exists" : emsg); | ||
334 | if (GNUNET_NO != success) | ||
335 | LOG("GNUNET_NO != success"); | ||
336 | //ret = 1; | ||
337 | } | ||
338 | LOG("blaat"); | ||
339 | //ret = 0; | ||
340 | //test_finished (); | ||
341 | } | ||
342 | |||
343 | /** | ||
344 | * Continuation called to notify client about result of the | ||
345 | * operation. | ||
346 | * | ||
347 | * @param cls closure, unused | ||
348 | * @param success #GNUNET_SYSERR on failure (including timeout/queue drop/failure to validate) | ||
349 | * #GNUNET_NO if content was already there | ||
350 | * #GNUNET_YES (or other positive value) on success | ||
351 | * @param emsg NULL on success, otherwise an error message | ||
352 | */ | ||
353 | static void | ||
354 | del_continuation (void *cls, int32_t success, const char *emsg) | ||
355 | { | ||
356 | del_qe = NULL; | ||
357 | if (GNUNET_NO == success) | ||
358 | { | ||
359 | fprintf (stderr, _("Deleting record failed, record does not exist%s%s\n"), | ||
360 | (NULL != emsg) ? ": " : "", (NULL != emsg) ? emsg : ""); | ||
361 | } | ||
362 | if (GNUNET_SYSERR == success) | ||
363 | { | ||
364 | fprintf (stderr, _("Deleting record failed%s%s\n"), | ||
365 | (NULL != emsg) ? ": " : "", (NULL != emsg) ? emsg : ""); | ||
366 | } | ||
367 | // test_finished (); | ||
368 | } | ||
369 | |||
370 | /* | ||
371 | * add a new contact | ||
372 | * @param name | ||
373 | * @param address | ||
374 | */ | ||
375 | void | ||
376 | add_contact (const gchar * name, const gchar * address) | ||
377 | { | ||
378 | // memmove(&address+1,&address+51,1); | ||
379 | GtkTreeIter iter; | ||
380 | struct GNUNET_GNSRECORD_Data rd; | ||
381 | struct GNUNET_GNSRECORD_Data *rde; | ||
382 | static void *data; | ||
383 | static size_t data_size; | ||
384 | struct GNUNET_CRYPTO_EcdsaPublicKey pkey; | ||
385 | |||
386 | struct GNUNET_IDENTITY_Ego *tempEgo; | ||
387 | char *tempName; | ||
388 | GtkTreeIter testIter; | ||
389 | gtk_combo_box_get_active_iter(GTK_WIDGET (GNUNET_CONVERSATION_GTK_get_main_window_object ("gnunet_conversation_gtk_contacts_zone_combobox")), &testIter); | ||
390 | |||
391 | gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore), | ||
392 | &testIter, | ||
393 | 0, &tempName, | ||
394 | 1, &tempEgo, | ||
395 | -1); | ||
396 | |||
397 | |||
398 | GNUNET_CRYPTO_ecdsa_public_key_from_string (address, strlen (address), &pkey); | ||
399 | rde = &rd; | ||
400 | zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (tempEgo); | ||
401 | rd.data = &pkey; | ||
402 | rd.data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey); | ||
403 | rd.record_type = GNUNET_GNSRECORD_TYPE_PKEY; | ||
404 | rd.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; // always set to relative for testing purposes | ||
405 | rde->flags |= GNUNET_GNSRECORD_RF_PRIVATE; | ||
406 | rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; | ||
407 | //FPRINTF (stderr, "adding\n"); | ||
408 | //FPRINTF (stderr, "name: %s\n", name); | ||
409 | //FPRINTF (stderr, "address: %s\n", address); | ||
410 | if (GNUNET_OK != | ||
411 | GNUNET_GNSRECORD_string_to_value (65536, address, &data, &data_size)) | ||
412 | { | ||
413 | FPRINTF (stderr, "invalid address\n"); | ||
414 | } | ||
415 | else | ||
416 | { | ||
417 | add_qe = | ||
418 | GNUNET_NAMESTORE_records_store (ns, &zone_pkey, name, 1, rde, | ||
419 | &add_continuation, &add_qe); | ||
420 | gtk_list_store_append (contacts_liststore, &iter); | ||
421 | gtk_list_store_set (contacts_liststore, &iter, 1, "PKEY", 0, name, -1); | ||
422 | } | ||
423 | } | ||
424 | /* | ||
425 | * executed when clicked on add contact | ||
426 | * @param button | ||
427 | * @param user_data | ||
428 | */ | ||
429 | |||
430 | void | ||
431 | GNUNET_CONVERSATION_GTK_on_add_clicked (GtkButton * button, | ||
432 | gpointer * user_data) | ||
433 | { | ||
434 | |||
435 | GtkEntry *nameEntry, *addressEntry; | ||
436 | |||
437 | nameEntry = GTK_ENTRY (GNUNET_CONVERSATION_GTK_get_main_window_object ("GNUNET_GTK_conversation_nameAdd")); | ||
438 | addressEntry = GTK_ENTRY (GNUNET_CONVERSATION_GTK_get_main_window_object ("GNUNET_GTK_conversation_addressAdd")); | ||
439 | FPRINTF(stderr,"name %s \n", gtk_entry_get_text (nameEntry)); | ||
440 | FPRINTF(stderr,"addr %s \n", gtk_entry_get_text (addressEntry)); | ||
441 | |||
442 | add_contact (gtk_entry_get_text (nameEntry),gtk_entry_get_text(addressEntry)); | ||
443 | } | ||
444 | |||
445 | void | ||
446 | GNUNET_CONVERSATION_GTK_on_remove_clicked (GtkButton * button, | ||
447 | gpointer * user_data) | ||
448 | { | ||
449 | GtkTreeSelection *selection; | ||
450 | GtkTreeModel *model; | ||
451 | GtkTreeIter iter; | ||
452 | GtkDialog *confirm; | ||
453 | GtkWindow *main_window; | ||
454 | GtkLabel *notification; | ||
455 | GtkHBox *content_area; | ||
456 | |||
457 | selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (contacts_treeview)); | ||
458 | if (gtk_tree_selection_get_selected (selection, &model, &iter)) | ||
459 | { | ||
460 | gtk_tree_model_get (model, &iter, 0, &name, -1); | ||
461 | //FPRINTF (stderr, "selected %s \n", name); | ||
462 | main_window = GTK_WINDOW (GNUNET_CONVERSATION_GTK_get_main_window_object ("GNUNET_GTK_conversation_window")); | ||
463 | confirm = | ||
464 | GTK_DIALOG (gtk_dialog_new_with_buttons | ||
465 | ("Removing contact", main_window, | ||
466 | GTK_DIALOG_DESTROY_WITH_PARENT, _("Yes"), | ||
467 | GTK_RESPONSE_ACCEPT, _("No"), GTK_RESPONSE_CANCEL, NULL)); | ||
468 | content_area = | ||
469 | GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (confirm))); | ||
470 | notification = | ||
471 | GTK_LABEL (gtk_label_new | ||
472 | ("Do you really want to remove this contact?")); | ||
473 | gtk_container_add (GTK_CONTAINER (content_area), GTK_WIDGET (notification)); | ||
474 | gtk_widget_show_all (GTK_WIDGET (confirm)); | ||
475 | switch (gtk_dialog_run (confirm)) | ||
476 | { | ||
477 | case GTK_RESPONSE_ACCEPT: | ||
478 | zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (contacts_ego); | ||
479 | del_qe = | ||
480 | GNUNET_NAMESTORE_records_store (ns, &zone_pkey, name, 0, NULL, | ||
481 | &del_continuation, NULL); | ||
482 | gtk_list_store_remove (contacts_liststore, &iter); | ||
483 | gtk_widget_destroy (GTK_WIDGET (confirm)); | ||
484 | break; | ||
485 | case GTK_RESPONSE_CANCEL: | ||
486 | FPRINTF (stderr, "not removing \n"); | ||
487 | gtk_widget_destroy (GTK_WIDGET (confirm)); | ||
488 | break; | ||
489 | } | ||
490 | |||
491 | } | ||
492 | } | ||
493 | |||
494 | void | ||
495 | GNUNET_CONVERSATION_GTK_on_current_clicked (GtkButton * button, | ||
496 | gpointer * user_data) | ||
497 | { | ||
498 | GtkEntry *addressEntry; | ||
499 | // FPRINTF(stderr,"on current clicked %s\n",callerName); | ||
500 | char *strippedAddress; | ||
501 | addressEntry = GTK_ENTRY (GNUNET_CONVERSATION_GTK_get_main_window_object ("GNUNET_GTK_conversation_addressAdd")); | ||
502 | currentlySelectedCallAddress[52] = '\0'; | ||
503 | gtk_entry_set_text(addressEntry, currentlySelectedCallAddress); | ||
504 | |||
505 | } | ||
506 | |||
507 | |||
508 | /* | ||
509 | * row activated | ||
510 | * @return void | ||
511 | */ | ||
512 | |||
513 | void | ||
514 | GNUNET_CONVERSATION_GTK_row_activated () | ||
515 | { | ||
516 | gchar *callAddress; | ||
517 | gchar *type; | ||
518 | |||
519 | // FPRINTF (stderr, "row activated \n"); | ||
520 | |||
521 | GtkTreeSelection *selection; | ||
522 | |||
523 | GtkTreeIter iterA; | ||
524 | |||
525 | |||
526 | selection = gtk_tree_view_get_selection (contacts_treeview); | ||
527 | |||
528 | gtk_tree_selection_get_selected (selection, &contacts_treemodel, &iterA); | ||
529 | gtk_tree_model_get (contacts_treemodel, &iterA, 0, &name, 1, &type, -1); | ||
530 | // g_print ("ego name %s\n", ego_name); | ||
531 | // g_print ("selected row is: %s\n", name); | ||
532 | // g_print ("selected rowtype is: %s\n", type); | ||
533 | |||
534 | |||
535 | g_print ("type @row active%s", type); | ||
536 | if (strcmp (type, "PKEY") == 0) | ||
537 | { | ||
538 | GNUNET_asprintf (&callAddress, "call\.%s\.gnu", name); | ||
539 | } | ||
540 | if (strcmp (type, "PHONE") == 0) | ||
541 | { | ||
542 | GNUNET_asprintf (&callAddress, "%s\.gnu", name); | ||
543 | } | ||
544 | // else { GNUNET_asprintf(&callAddress, "%s", peer_id);} | ||
545 | |||
546 | g_print ("ego name %s\n", callAddress); | ||
547 | GtkEntry *address_entry; | ||
548 | |||
549 | address_entry = GTK_ENTRY ( GNUNET_CONVERSATION_GTK_get_main_window_object ("GNUNET_GTK_conversation_address")); | ||
550 | gtk_entry_set_text (address_entry, callAddress); | ||
551 | //do_call (callAddress); | ||
552 | } | ||
553 | |||
554 | /* | ||
555 | static void | ||
556 | print_ego (void *cls, | ||
557 | struct GNUNET_IDENTITY_Ego *ego, | ||
558 | void **ctx, | ||
559 | const char *identifier) | ||
560 | { | ||
561 | struct GNUNET_CRYPTO_EcdsaPublicKey pk; | ||
562 | char *s; | ||
563 | GNUNET_IDENTITY_ego_get_public_key (ego, &pk); | ||
564 | s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); | ||
565 | fprintf (stdout, "%s \n", identifier); | ||
566 | // GNUNET_free (s); | ||
567 | } | ||
568 | */ | ||
569 | GNUNET_IDENTITY_EgoCallback | ||
570 | setCurrentAddressbookEgo(void *cls, struct GNUNET_IDENTITY_Ego *ego) | ||
571 | { | ||
572 | currentAddressBookEgo = ego; | ||
573 | } | ||
574 | |||
575 | /** | ||
576 | * A different zone was selected in the zone toggle bar. Load the | ||
577 | * appropriate zone. | ||
578 | * | ||
579 | * @param widget button that was toggled (could be to "on" or "off", we only react to "on") | ||
580 | * @param user_data builder, unused | ||
581 | */ | ||
582 | void | ||
583 | gnunet_conversation_gtk_contacts_zone_combobox_changed_cb (GtkComboBox *widget, | ||
584 | gpointer user_data) | ||
585 | { | ||
586 | GtkTreeIter contacts_zone_iter; | ||
587 | struct GNUNET_IDENTITY_Ego *tempEgo; | ||
588 | char *tempName; | ||
589 | struct GNUNET_CRYPTO_EcdsaPrivateKey temp_zone_pkey; | ||
590 | GtkTreeSelection *selection; | ||
591 | GtkTreeIter iterA; | ||
592 | |||
593 | |||
594 | gtk_combo_box_get_active_iter(widget, &contacts_zone_iter); | ||
595 | |||
596 | gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore), | ||
597 | &contacts_zone_iter, | ||
598 | 0, &tempName, | ||
599 | 1, &tempEgo, | ||
600 | -1); | ||
601 | // FPRINTF(stderr,"blat: %s\n", tempName); | ||
602 | temp_zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (tempEgo); | ||
603 | gtk_list_store_clear(contacts_liststore); | ||
604 | /* | ||
605 | GNUNET_IDENTITY_ego_lookup (cfg, | ||
606 | tempName, | ||
607 | setCurrentAddressbookEgo, | ||
608 | NULL); | ||
609 | */ | ||
610 | //selection = gtk_tree_view_get_selection (zone_treeview); | ||
611 | |||
612 | //gtk_tree_selection_get_selected (selection, &zone_treemodel, &iterA); | ||
613 | |||
614 | //gtk_tree_model_get_iter_first(zone_treemodel, &iterA); | ||
615 | //gtk_tree_model_get (zone_treemodel, &iterA, 0, &tempName, 1, &tempEgo, -1); | ||
616 | |||
617 | |||
618 | list_it = | ||
619 | GNUNET_NAMESTORE_zone_iteration_start (ns, &temp_zone_pkey, &display_record, | ||
620 | NULL); | ||
621 | |||
622 | // GNUNET_IDENTITY_disconnect (id); | ||
623 | |||
624 | } | ||
625 | |||
626 | |||
627 | |||
628 | ////// | ||
629 | extern void | ||
630 | GNUNET_CONVERSATION_GTK_CONTACTS_init () | ||
631 | { | ||
632 | GtkTreeIter iterContactsInit; | ||
633 | |||
634 | cfg = GIG_get_configuration (); | ||
635 | |||
636 | |||
637 | // contacts | ||
638 | contacts_liststore = | ||
639 | GTK_LIST_STORE (GNUNET_CONVERSATION_GTK_get_main_window_object | ||
640 | ("gnunet_conversation_gtk_contacts_liststore")); | ||
641 | contacts_treeview = | ||
642 | GTK_TREE_VIEW (GNUNET_CONVERSATION_GTK_get_main_window_object ("gnunet_conversation_gtk_treeview")); | ||
643 | contacts_treemodel = GTK_TREE_MODEL (contacts_liststore); | ||
644 | |||
645 | |||
646 | // zone list | ||
647 | zone_liststore = | ||
648 | GTK_LIST_STORE (GNUNET_CONVERSATION_GTK_get_main_window_object ("gnunet_conversation_gtk_contacts_zone_liststore")); | ||
649 | zone_treestore = | ||
650 | GTK_TREE_STORE (GNUNET_CONVERSATION_GTK_get_main_window_object ("gnunet_conversation_gtk_contacts_zone_treestore")); | ||
651 | zone_treemodel = GTK_TREE_MODEL (zone_liststore); | ||
652 | |||
653 | gtk_tree_model_get_iter_first(zone_treemodel, &iterContactsInit); | ||
654 | gtk_tree_model_iter_next(zone_treemodel, &iterContactsInit); | ||
655 | |||
656 | gtk_combo_box_set_active_iter(GTK_WIDGET (GNUNET_CONVERSATION_GTK_get_main_window_object ("gnunet_conversation_gtk_contacts_zone_combobox")), &iterContactsInit); | ||
657 | |||
658 | id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL); | ||
659 | // zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id); | ||
660 | // gtk_combo_box_set_active(GTK_WIDGET (get_object ("gnunet_conversation_gtk_contacts_zone_combobox")), 1); | ||
661 | // gtk_combo_box_set_active(GTK_WIDGET (get_object (ml,"gnunet_conversation_gtk_outgoing_zone_combobox")), 1); | ||
662 | |||
663 | } | ||
664 | |||
665 | extern void | ||
666 | GNUNET_CONVERSATION_GTK_CONTACTS_shutdown() | ||
667 | { | ||
668 | GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey); | ||
669 | } | ||
670 | |||
671 | |||
672 | |||
673 | |||