diff options
Diffstat (limited to 'src/conversation/gnunet-conversation-gtk_contacts.c')
-rw-r--r-- | src/conversation/gnunet-conversation-gtk_contacts.c | 472 |
1 files changed, 174 insertions, 298 deletions
diff --git a/src/conversation/gnunet-conversation-gtk_contacts.c b/src/conversation/gnunet-conversation-gtk_contacts.c index fec7dac1..aee03604 100644 --- a/src/conversation/gnunet-conversation-gtk_contacts.c +++ b/src/conversation/gnunet-conversation-gtk_contacts.c | |||
@@ -25,6 +25,26 @@ | |||
25 | * @author hark | 25 | * @author hark |
26 | */ | 26 | */ |
27 | #include "gnunet-conversation-gtk.h" | 27 | #include "gnunet-conversation-gtk.h" |
28 | #include "gnunet-conversation-gtk_contacts.h" | ||
29 | #include "gnunet-conversation-gtk_egos.h" | ||
30 | |||
31 | |||
32 | /** | ||
33 | * Columns in the #contacts_liststore. | ||
34 | */ | ||
35 | enum ContactsListstoreValues | ||
36 | { | ||
37 | /** | ||
38 | * Human-readable name of the label in the zone. | ||
39 | */ | ||
40 | CONTACTS_LS_NAME = 0, | ||
41 | |||
42 | /** | ||
43 | * Type of the label (as a 'const char *') | ||
44 | */ | ||
45 | CONTACTS_LS_TYPE = 1 | ||
46 | }; | ||
47 | |||
28 | 48 | ||
29 | /** | 49 | /** |
30 | * Our ego. | 50 | * Our ego. |
@@ -37,11 +57,6 @@ static struct GNUNET_IDENTITY_Ego *contacts_ego; | |||
37 | static GtkListStore *contacts_liststore; | 57 | static GtkListStore *contacts_liststore; |
38 | 58 | ||
39 | /** | 59 | /** |
40 | * list of zones | ||
41 | */ | ||
42 | static GtkListStore *zone_liststore; | ||
43 | |||
44 | /** | ||
45 | * zone treeview | 60 | * zone treeview |
46 | */ | 61 | */ |
47 | static GtkTreeView *zone_treeview; | 62 | static GtkTreeView *zone_treeview; |
@@ -61,18 +76,10 @@ static GtkTreeView *contacts_treeview; | |||
61 | */ | 76 | */ |
62 | static GtkTreeModel *contacts_treemodel; | 77 | static GtkTreeModel *contacts_treemodel; |
63 | 78 | ||
64 | /* | ||
65 | * List iterator for the 'list' operation. | ||
66 | */ | ||
67 | static struct GNUNET_NAMESTORE_ZoneIterator *list_it; | ||
68 | |||
69 | |||
70 | static struct GNUNET_IDENTITY_Ego *currentAddressBookEgo; | ||
71 | |||
72 | /** | 79 | /** |
73 | * Handle to identity service. | 80 | * Monitor to view information in our current zone. |
74 | */ | 81 | */ |
75 | static struct GNUNET_IDENTITY_Handle *id; | 82 | static struct GNUNET_NAMESTORE_ZoneMonitor *zone_mon; |
76 | 83 | ||
77 | /** | 84 | /** |
78 | * Handle to the namestore. | 85 | * Handle to the namestore. |
@@ -100,136 +107,6 @@ static struct GNUNET_NAMESTORE_QueueEntry *add_qe; | |||
100 | static struct GNUNET_NAMESTORE_QueueEntry *del_qe; | 107 | static struct GNUNET_NAMESTORE_QueueEntry *del_qe; |
101 | 108 | ||
102 | 109 | ||
103 | //////////////////////////// | ||
104 | static void | ||
105 | display_record (void *cls, | ||
106 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | ||
107 | const char *rname, | ||
108 | unsigned int rd_len, | ||
109 | const struct GNUNET_GNSRECORD_Data *rd) | ||
110 | { | ||
111 | char *s; | ||
112 | char *type; | ||
113 | unsigned int i; | ||
114 | struct GNUNET_TIME_Absolute at; | ||
115 | struct GNUNET_TIME_Relative rt; | ||
116 | GtkTreeIter display_iter; | ||
117 | |||
118 | |||
119 | if (NULL == rname) | ||
120 | { | ||
121 | |||
122 | list_it = NULL; | ||
123 | //test_finished (); | ||
124 | return; | ||
125 | } | ||
126 | |||
127 | for (i = 0; i < rd_len; i++) | ||
128 | { | ||
129 | |||
130 | if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) && | ||
131 | (0 != strcmp (rname, "+"))) | ||
132 | continue; | ||
133 | /* typestring = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type);*/ | ||
134 | s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type, rd[i].data, | ||
135 | rd[i].data_size); | ||
136 | if (NULL == s) | ||
137 | { | ||
138 | FPRINTF (stdout, _("\tCorrupt or unsupported record of type %u\n"), | ||
139 | (unsigned int) rd[i].record_type); | ||
140 | continue; | ||
141 | } | ||
142 | if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) | ||
143 | { | ||
144 | rt.rel_value_us = rd[i].expiration_time; | ||
145 | /* ets = GNUNET_STRINGS_relative_time_to_string (rt, GNUNET_YES);*/ | ||
146 | } | ||
147 | else | ||
148 | { | ||
149 | at.abs_value_us = rd[i].expiration_time; | ||
150 | /* ets = GNUNET_STRINGS_absolute_time_to_string (at);*/ | ||
151 | } | ||
152 | if (rd[i].record_type == 65536) | ||
153 | { | ||
154 | type = "PKEY"; | ||
155 | } // if pubkey record | ||
156 | if (rd[i].record_type == 65542) | ||
157 | { | ||
158 | type = "PHONE"; | ||
159 | } | ||
160 | // FPRINTF (stdout, "%s", rname); | ||
161 | if (rd[i].record_type == 65536 || rd[i].record_type == 65542) | ||
162 | { | ||
163 | gtk_list_store_append (contacts_liststore, &display_iter); | ||
164 | gtk_list_store_set (contacts_liststore, &display_iter, 1, type, 0, rname, -1); | ||
165 | } | ||
166 | |||
167 | /* FPRINTF (stdout, | ||
168 | "\t%s: %s (%s)\t%s\t%s\t%s\n", | ||
169 | typestring, | ||
170 | s, | ||
171 | ets, | ||
172 | (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) ? "PRIVATE" : "PUBLIC", | ||
173 | (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) ? "SHADOW" : "", | ||
174 | (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PENDING)) ? "PENDING" : ""); | ||
175 | */ | ||
176 | //gtk_widget_show(contacts_liststore); | ||
177 | GNUNET_free (s); | ||
178 | } | ||
179 | // FPRINTF (stdout, "%s", "\n"); | ||
180 | |||
181 | GNUNET_NAMESTORE_zone_iterator_next (list_it); | ||
182 | // GNUNET_NAMESTORE_zone_iteration_stop(list_it); | ||
183 | |||
184 | } | ||
185 | |||
186 | |||
187 | |||
188 | /** | ||
189 | * Function called by identity service with information about egos. | ||
190 | * | ||
191 | * @param cls NULL | ||
192 | * @param ego ego handle | ||
193 | * @param ctx unused | ||
194 | * @param name name of the ego | ||
195 | */ | ||
196 | static void | ||
197 | identity_cb (void *cls, | ||
198 | struct GNUNET_IDENTITY_Ego *ego, | ||
199 | void **ctx, | ||
200 | const char *name) | ||
201 | { | ||
202 | /* | ||
203 | struct GNUNET_CRYPTO_EcdsaPublicKey pk; | ||
204 | char *s; | ||
205 | */ | ||
206 | GtkTreeIter iter; | ||
207 | |||
208 | if (NULL != ego) | ||
209 | { | ||
210 | /* | ||
211 | GNUNET_IDENTITY_ego_get_public_key (ego, &pk); | ||
212 | s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); | ||
213 | */ | ||
214 | fprintf (stderr, "contacts idenity_cb: %s \n", name); | ||
215 | |||
216 | |||
217 | /* FIXME: this should be done in gnunet-conversation-gtk.c */ | ||
218 | gtk_list_store_insert_with_values (zone_liststore, | ||
219 | &iter, -1, | ||
220 | 0, name, | ||
221 | 1, ego, | ||
222 | -1); | ||
223 | |||
224 | } | ||
225 | |||
226 | contacts_ego = ego; | ||
227 | |||
228 | |||
229 | // zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id); | ||
230 | ns = GNUNET_NAMESTORE_connect (GCG_get_configuration ()); | ||
231 | } | ||
232 | |||
233 | 110 | ||
234 | /** | 111 | /** |
235 | * Continuation called to notify client about result of the | 112 | * Continuation called to notify client about result of the |
@@ -242,7 +119,9 @@ identity_cb (void *cls, | |||
242 | * @param emsg NULL on success, otherwise an error message | 119 | * @param emsg NULL on success, otherwise an error message |
243 | */ | 120 | */ |
244 | static void | 121 | static void |
245 | add_continuation (void *cls, int32_t success, const char *emsg) | 122 | add_continuation (void *cls, |
123 | int32_t success, | ||
124 | const char *emsg) | ||
246 | { | 125 | { |
247 | 126 | ||
248 | struct GNUNET_NAMESTORE_QueueEntry **qe = cls; | 127 | struct GNUNET_NAMESTORE_QueueEntry **qe = cls; |
@@ -273,7 +152,9 @@ add_continuation (void *cls, int32_t success, const char *emsg) | |||
273 | * @param emsg NULL on success, otherwise an error message | 152 | * @param emsg NULL on success, otherwise an error message |
274 | */ | 153 | */ |
275 | static void | 154 | static void |
276 | del_continuation (void *cls, int32_t success, const char *emsg) | 155 | del_continuation (void *cls, |
156 | int32_t success, | ||
157 | const char *emsg) | ||
277 | { | 158 | { |
278 | del_qe = NULL; | 159 | del_qe = NULL; |
279 | if (GNUNET_NO == success) | 160 | if (GNUNET_NO == success) |
@@ -292,6 +173,7 @@ del_continuation (void *cls, int32_t success, const char *emsg) | |||
292 | 173 | ||
293 | /** | 174 | /** |
294 | * add a new contact | 175 | * add a new contact |
176 | * | ||
295 | * @param name | 177 | * @param name |
296 | * @param address | 178 | * @param address |
297 | */ | 179 | */ |
@@ -299,29 +181,20 @@ static void | |||
299 | add_contact (const gchar *name, | 181 | add_contact (const gchar *name, |
300 | const gchar *address) | 182 | const gchar *address) |
301 | { | 183 | { |
302 | // memmove(&address+1,&address+51,1); | ||
303 | GtkTreeIter iter; | 184 | GtkTreeIter iter; |
304 | struct GNUNET_GNSRECORD_Data rd; | 185 | struct GNUNET_GNSRECORD_Data rd; |
305 | struct GNUNET_GNSRECORD_Data *rde; | 186 | struct GNUNET_GNSRECORD_Data *rde; |
306 | static void *data; | 187 | static void *data; |
307 | static size_t data_size; | 188 | static size_t data_size; |
308 | struct GNUNET_CRYPTO_EcdsaPublicKey pkey; | 189 | struct GNUNET_CRYPTO_EcdsaPublicKey pkey; |
190 | struct GNUNET_IDENTITY_Ego *ego; | ||
309 | 191 | ||
310 | struct GNUNET_IDENTITY_Ego *tempEgo; | 192 | ego = GCG_EGOS_get_selected_ego (); |
311 | char *tempName; | 193 | zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego); |
312 | GtkTreeIter testIter; | 194 | GNUNET_CRYPTO_ecdsa_public_key_from_string (address, |
313 | gtk_combo_box_get_active_iter(GTK_COMBO_BOX (GCG_get_main_window_object ("gnunet_conversation_gtk_contacts_zone_combobox")), &testIter); | 195 | strlen (address), |
314 | 196 | &pkey); | |
315 | gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore), | ||
316 | &testIter, | ||
317 | 0, &tempName, | ||
318 | 1, &tempEgo, | ||
319 | -1); | ||
320 | |||
321 | |||
322 | GNUNET_CRYPTO_ecdsa_public_key_from_string (address, strlen (address), &pkey); | ||
323 | rde = &rd; | 197 | rde = &rd; |
324 | zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (tempEgo); | ||
325 | rd.data = &pkey; | 198 | rd.data = &pkey; |
326 | rd.data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey); | 199 | rd.data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey); |
327 | rd.record_type = GNUNET_GNSRECORD_TYPE_PKEY; | 200 | rd.record_type = GNUNET_GNSRECORD_TYPE_PKEY; |
@@ -364,6 +237,7 @@ GNUNET_CONVERSATION_GTK_on_add_clicked (GtkButton * button, | |||
364 | add_contact (gtk_entry_get_text (nameEntry),gtk_entry_get_text(addressEntry)); | 237 | add_contact (gtk_entry_get_text (nameEntry),gtk_entry_get_text(addressEntry)); |
365 | } | 238 | } |
366 | 239 | ||
240 | |||
367 | void | 241 | void |
368 | GNUNET_CONVERSATION_GTK_on_remove_clicked (GtkButton * button, | 242 | GNUNET_CONVERSATION_GTK_on_remove_clicked (GtkButton * button, |
369 | gpointer * user_data) | 243 | gpointer * user_data) |
@@ -414,6 +288,9 @@ GNUNET_CONVERSATION_GTK_on_remove_clicked (GtkButton * button, | |||
414 | } | 288 | } |
415 | 289 | ||
416 | 290 | ||
291 | /** | ||
292 | * FIXME: what was clicked where? | ||
293 | */ | ||
417 | void | 294 | void |
418 | GNUNET_CONVERSATION_GTK_on_current_clicked (GtkButton *button, | 295 | GNUNET_CONVERSATION_GTK_on_current_clicked (GtkButton *button, |
419 | gpointer *user_data) | 296 | gpointer *user_data) |
@@ -427,198 +304,197 @@ GNUNET_CONVERSATION_GTK_on_current_clicked (GtkButton *button, | |||
427 | } | 304 | } |
428 | 305 | ||
429 | 306 | ||
430 | /* | 307 | /** |
431 | * row activated | 308 | * A row was activated in the contacts list. Initiate call. |
309 | * | ||
432 | * @return void | 310 | * @return void |
433 | */ | 311 | */ |
434 | |||
435 | void | 312 | void |
436 | GNUNET_CONVERSATION_GTK_row_activated () | 313 | GNUNET_CONVERSATION_GTK_row_activated () |
437 | { | 314 | { |
438 | gchar *callAddress; | 315 | char *address; |
439 | gchar *type; | 316 | gchar *type; |
440 | |||
441 | // FPRINTF (stderr, "row activated \n"); | ||
442 | |||
443 | GtkTreeSelection *selection; | 317 | GtkTreeSelection *selection; |
444 | |||
445 | GtkTreeIter iterA; | 318 | GtkTreeIter iterA; |
446 | 319 | GtkEntry *address_entry; | |
447 | 320 | ||
448 | selection = gtk_tree_view_get_selection (contacts_treeview); | 321 | selection = gtk_tree_view_get_selection (contacts_treeview); |
449 | |||
450 | gtk_tree_selection_get_selected (selection, &contacts_treemodel, &iterA); | 322 | gtk_tree_selection_get_selected (selection, &contacts_treemodel, &iterA); |
451 | gtk_tree_model_get (contacts_treemodel, &iterA, 0, &name, 1, &type, -1); | 323 | gtk_tree_model_get (contacts_treemodel, |
452 | // g_print ("ego name %s\n", ego_name); | 324 | &iterA, |
453 | // g_print ("selected row is: %s\n", name); | 325 | CONTACTS_LS_NAME, &name, |
454 | // g_print ("selected rowtype is: %s\n", type); | 326 | CONTACTS_LS_TYPE, &type, |
455 | 327 | -1); | |
456 | 328 | if (0 == strcmp (type, "PKEY")) | |
457 | g_print ("type @row active%s", type); | ||
458 | if (strcmp (type, "PKEY") == 0) | ||
459 | { | 329 | { |
460 | GNUNET_asprintf (&callAddress, "call.%s.gnu", name); | 330 | GNUNET_asprintf (&address, "call.%s.gnu", name); |
461 | } | 331 | } |
462 | if (strcmp (type, "PHONE") == 0) | 332 | else |
463 | { | 333 | { |
464 | GNUNET_asprintf (&callAddress, "%s.gnu", name); | 334 | GNUNET_assert (0 == strcmp (type, "PHONE")); |
335 | GNUNET_asprintf (&address, "%s.gnu", name); | ||
465 | } | 336 | } |
466 | // else { GNUNET_asprintf(&callAddress, "%s", peer_id);} | 337 | g_free (type); |
467 | |||
468 | g_print ("ego name %s\n", callAddress); | ||
469 | GtkEntry *address_entry; | ||
470 | 338 | ||
471 | address_entry = GTK_ENTRY ( GCG_get_main_window_object ("GNUNET_GTK_conversation_address")); | 339 | address_entry = GTK_ENTRY (GCG_get_main_window_object ("GNUNET_GTK_conversation_address")); |
472 | gtk_entry_set_text (address_entry, callAddress); | 340 | gtk_entry_set_text (address_entry, |
473 | do_call (callAddress); | 341 | address); |
342 | do_call (address); | ||
343 | GNUNET_free (address); | ||
474 | } | 344 | } |
475 | 345 | ||
476 | /* | 346 | |
347 | /** | ||
348 | * Process a record that was stored or modified the namestore by | ||
349 | * adding/modifying/removing it in the liststore. | ||
350 | * | ||
351 | * @param cls closure | ||
352 | * @param zone private key of the zone; NULL on disconnect | ||
353 | * @param label label of the records; NULL on disconnect | ||
354 | * @param rd_count number of entries in @a rd array, 0 if label was deleted | ||
355 | * @param rd array of records with data to store | ||
356 | */ | ||
477 | static void | 357 | static void |
478 | print_ego (void *cls, | 358 | display_record (void *cls, |
479 | struct GNUNET_IDENTITY_Ego *ego, | 359 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
480 | void **ctx, | 360 | const char *rname, |
481 | const char *identifier) | 361 | unsigned int rd_len, |
362 | const struct GNUNET_GNSRECORD_Data *rd) | ||
482 | { | 363 | { |
483 | struct GNUNET_CRYPTO_EcdsaPublicKey pk; | 364 | unsigned int i; |
484 | char *s; | 365 | GtkTreeIter iter; |
485 | GNUNET_IDENTITY_ego_get_public_key (ego, &pk); | 366 | gboolean do_display; |
486 | s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); | 367 | const char *type; |
487 | fprintf (stdout, "%s \n", identifier); | 368 | |
488 | // GNUNET_free (s); | 369 | if (NULL == zone_key) |
370 | { | ||
371 | /* disconnect, clear (and possibly freeze) view */ | ||
372 | gtk_list_store_clear (contacts_liststore); | ||
373 | return; | ||
374 | } | ||
375 | do_display = FALSE; | ||
376 | for (i = 0; i < rd_len; i++) | ||
377 | { | ||
378 | switch (rd[i].record_type) | ||
379 | { | ||
380 | case GNUNET_GNSRECORD_TYPE_PKEY: | ||
381 | type = "PKEY"; | ||
382 | do_display = TRUE; | ||
383 | break; | ||
384 | case GNUNET_GNSRECORD_TYPE_PHONE: | ||
385 | type = "PHONE"; | ||
386 | do_display = TRUE; | ||
387 | break; | ||
388 | default: | ||
389 | /* ignore, not useful for conversation */ | ||
390 | break; | ||
391 | } | ||
392 | } | ||
393 | /* FIXME: check if exists, if so, update or delete */ | ||
394 | |||
395 | |||
396 | /* insert new record */ | ||
397 | if (! do_display) | ||
398 | return; | ||
399 | gtk_list_store_append (contacts_liststore, | ||
400 | &iter); | ||
401 | gtk_list_store_set (contacts_liststore, | ||
402 | &iter, | ||
403 | CONTACTS_LS_NAME, rname, | ||
404 | CONTACTS_LS_TYPE, type, | ||
405 | -1); | ||
489 | } | 406 | } |
490 | */ | 407 | |
491 | /* | 408 | |
409 | /** | ||
410 | * Function called once the monitor has caught up with the current | ||
411 | * state of the database. Will be called AGAIN after each disconnect | ||
412 | * (record monitor called with 'NULL' for zone_key) once we're again | ||
413 | * in sync. | ||
414 | * | ||
415 | * Could be used to optimize visuals if we block GTK updates while the | ||
416 | * list is not in sync. | ||
417 | * | ||
418 | * @param cls closure | ||
419 | */ | ||
492 | static void | 420 | static void |
493 | setCurrentAddressbookEgo(void *cls, struct GNUNET_IDENTITY_Ego *ego) | 421 | unfreeze_view (void *cls) |
494 | { | 422 | { |
495 | currentAddressBookEgo = ego; | 423 | // tbd |
496 | } | 424 | } |
497 | */ | 425 | |
498 | 426 | ||
499 | /** | 427 | /** |
500 | * A different zone was selected in the zone toggle bar. Load the | 428 | * A different zone was selected in the zone toggle bar. Load the |
501 | * appropriate zone. | 429 | * appropriate zone. |
502 | * | 430 | * |
503 | * @param widget button that was toggled (could be to "on" or "off", we only react to "on") | 431 | * @param widget combobox that was changed, unused |
504 | * @param user_data builder, unused | 432 | * @param user_data builder, unused |
505 | */ | 433 | */ |
506 | void | 434 | void |
507 | gnunet_conversation_gtk_contacts_zone_combobox_changed_cb (GtkComboBox *widget, | 435 | gnunet_conversation_gtk_contacts_zone_combobox_changed_cb (GtkComboBox *widget, |
508 | gpointer user_data) | 436 | gpointer user_data) |
509 | { | 437 | { |
510 | GtkTreeIter contacts_zone_iter; | 438 | struct GNUNET_IDENTITY_Ego *ego; |
511 | struct GNUNET_IDENTITY_Ego *tempEgo; | 439 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *temp_zone_pkey; |
512 | char *tempName; | ||
513 | struct GNUNET_CRYPTO_EcdsaPrivateKey temp_zone_pkey; | ||
514 | //GtkTreeSelection *selection; | ||
515 | //GtkTreeIter iterA; | ||
516 | |||
517 | |||
518 | gtk_combo_box_get_active_iter(widget, &contacts_zone_iter); | ||
519 | |||
520 | gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore), | ||
521 | &contacts_zone_iter, | ||
522 | 0, &tempName, | ||
523 | 1, &tempEgo, | ||
524 | -1); | ||
525 | // FPRINTF(stderr,"blat: %s\n", tempName); | ||
526 | temp_zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (tempEgo); | ||
527 | gtk_list_store_clear(contacts_liststore); | ||
528 | /* | ||
529 | GNUNET_IDENTITY_ego_lookup (cfg, | ||
530 | tempName, | ||
531 | setCurrentAddressbookEgo, | ||
532 | NULL); | ||
533 | */ | ||
534 | //selection = gtk_tree_view_get_selection (zone_treeview); | ||
535 | |||
536 | //gtk_tree_selection_get_selected (selection, &zone_treemodel, &iterA); | ||
537 | |||
538 | //gtk_tree_model_get_iter_first(zone_treemodel, &iterA); | ||
539 | //gtk_tree_model_get (zone_treemodel, &iterA, 0, &tempName, 1, &tempEgo, -1); | ||
540 | |||
541 | |||
542 | list_it = | ||
543 | GNUNET_NAMESTORE_zone_iteration_start (ns, &temp_zone_pkey, &display_record, | ||
544 | NULL); | ||
545 | |||
546 | // GNUNET_IDENTITY_disconnect (id); | ||
547 | 440 | ||
441 | ego = GCG_EGOS_get_selected_ego (); | ||
442 | temp_zone_pkey = GNUNET_IDENTITY_ego_get_private_key (ego); | ||
443 | if (NULL != zone_mon) | ||
444 | { | ||
445 | GNUNET_NAMESTORE_zone_monitor_stop (zone_mon); | ||
446 | zone_mon = NULL; | ||
447 | } | ||
448 | gtk_list_store_clear (contacts_liststore); | ||
449 | zone_mon = GNUNET_NAMESTORE_zone_monitor_start (GCG_get_configuration (), | ||
450 | temp_zone_pkey, | ||
451 | GNUNET_YES, | ||
452 | &display_record, | ||
453 | &unfreeze_view, | ||
454 | NULL); | ||
548 | } | 455 | } |
549 | 456 | ||
550 | 457 | ||
551 | 458 | /** | |
552 | ////// | 459 | * Initialize the contact list |
460 | */ | ||
553 | void | 461 | void |
554 | GNUNET_CONVERSATION_GTK_CONTACTS_init () | 462 | GCG_CONTACTS_init () |
555 | { | 463 | { |
556 | GtkTreeIter iterContactsInit; | 464 | contacts_liststore |
557 | 465 | = GTK_LIST_STORE (GCG_get_main_window_object | |
558 | // contacts | ||
559 | contacts_liststore = | ||
560 | GTK_LIST_STORE (GCG_get_main_window_object | ||
561 | ("gnunet_conversation_gtk_contacts_liststore")); | 466 | ("gnunet_conversation_gtk_contacts_liststore")); |
562 | contacts_treeview = | ||
563 | GTK_TREE_VIEW (GCG_get_main_window_object ("gnunet_conversation_gtk_treeview")); | ||
564 | |||
565 | // gtk_tree_view_set_activate_on_single_click (contacts_treeview, TRUE); | ||
566 | contacts_treemodel = GTK_TREE_MODEL (contacts_liststore); | 467 | contacts_treemodel = GTK_TREE_MODEL (contacts_liststore); |
468 | contacts_treeview | ||
469 | = GTK_TREE_VIEW (GCG_get_main_window_object ("gnunet_conversation_gtk_treeview")); | ||
470 | // gtk_tree_view_set_activate_on_single_click (contacts_treeview, TRUE); | ||
567 | 471 | ||
568 | // zone list | 472 | zone_treemodel |
569 | zone_liststore = | 473 | = GTK_TREE_MODEL (GCG_get_main_window_object ("gnunet_conversation_gtk_contacts_zone_liststore")); |
570 | GTK_LIST_STORE (GCG_get_main_window_object ("gnunet_conversation_gtk_contacts_zone_liststore")); | 474 | zone_treeview |
571 | 475 | = GTK_TREE_VIEW (GCG_get_main_window_object ("gnunet_conversation_gtk_zone_treeview")); | |
572 | // zone_treestore = | 476 | ns = GNUNET_NAMESTORE_connect (GCG_get_configuration ()); |
573 | // GTK_TREE_STORE (GCG_get_main_window_object ("gnunet_conversation_gtk_contacts_zone_treestore")); | ||
574 | zone_treemodel = GTK_TREE_MODEL (zone_liststore); | ||
575 | zone_treeview = | ||
576 | GTK_TREE_VIEW (GCG_get_main_window_object ("gnunet_conversation_gtk_zone_treeview")); | ||
577 | |||
578 | gtk_tree_model_get_iter_first(zone_treemodel, &iterContactsInit); | ||
579 | gtk_tree_model_iter_next(zone_treemodel, &iterContactsInit); | ||
580 | |||
581 | gtk_combo_box_set_active_iter(GTK_COMBO_BOX (GCG_get_main_window_object ("gnunet_conversation_gtk_contacts_zone_combobox")), &iterContactsInit); | ||
582 | |||
583 | id = GNUNET_IDENTITY_connect (GCG_get_configuration (), | ||
584 | &identity_cb, | ||
585 | NULL); | ||
586 | // zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id); | ||
587 | // gtk_combo_box_set_active(GTK_WIDGET (GCG_get_main_window_object ("gnunet_conversation_gtk_contacts_zone_combobox")), 1); | ||
588 | // gtk_combo_box_set_active(GTK_WIDGET (GCG_get_main_window_object (ml,"gnunet_conversation_gtk_outgoing_zone_combobox")), 1); | ||
589 | |||
590 | } | 477 | } |
591 | 478 | ||
592 | 479 | ||
480 | /** | ||
481 | * Shutdown the contact list | ||
482 | */ | ||
593 | void | 483 | void |
594 | GNUNET_CONVERSATION_GTK_CONTACTS_shutdown() | 484 | GCG_CONTACTS_shutdown () |
595 | { | 485 | { |
596 | 486 | if (NULL != zone_mon) | |
597 | if (NULL != id) | ||
598 | { | 487 | { |
599 | GNUNET_IDENTITY_disconnect (id); | 488 | GNUNET_NAMESTORE_zone_monitor_stop (zone_mon); |
600 | id = NULL; | 489 | zone_mon = NULL; |
601 | } else { | ||
602 | GNUNET_break(0); | ||
603 | } | ||
604 | |||
605 | if (NULL != list_it) | ||
606 | { | ||
607 | FPRINTF(stderr,"LIST_IT == NULL"); | ||
608 | // GNUNET_NAMESTORE_zone_iteration_stop(list_it); | ||
609 | } | 490 | } |
610 | if (NULL != ns) | 491 | if (NULL != ns) |
611 | { | 492 | { |
612 | GNUNET_NAMESTORE_disconnect (ns); | 493 | GNUNET_NAMESTORE_disconnect (ns); |
613 | ns = NULL; | 494 | ns = NULL; |
614 | } else { | ||
615 | GNUNET_break(0); | ||
616 | } | 495 | } |
617 | |||
618 | GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey); | 496 | GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey); |
619 | |||
620 | } | 497 | } |
621 | 498 | ||
622 | 499 | /* end of gnunet-conversation-gtk_contacts.c */ | |
623 | |||
624 | 500 | ||