diff options
-rw-r--r-- | src/gnunet_chat_context.c | 115 | ||||
-rw-r--r-- | src/gnunet_chat_context.h | 3 | ||||
-rw-r--r-- | src/gnunet_chat_context_intern.c | 162 | ||||
-rw-r--r-- | src/gnunet_chat_lib.c | 18 | ||||
-rw-r--r-- | src/gnunet_chat_lobby.c | 9 | ||||
-rw-r--r-- | src/gnunet_chat_lobby.h | 3 | ||||
-rw-r--r-- | src/gnunet_chat_lobby_intern.c | 133 |
7 files changed, 316 insertions, 127 deletions
diff --git a/src/gnunet_chat_context.c b/src/gnunet_chat_context.c index a4f3db0..be3dd4a 100644 --- a/src/gnunet_chat_context.c +++ b/src/gnunet_chat_context.c | |||
@@ -57,6 +57,9 @@ context_create_from_room (struct GNUNET_CHAT_Handle *handle, | |||
57 | 8, GNUNET_NO | 57 | 8, GNUNET_NO |
58 | ); | 58 | ); |
59 | 59 | ||
60 | context->query_open = NULL; | ||
61 | context->query_commit = NULL; | ||
62 | |||
60 | return context; | 63 | return context; |
61 | } | 64 | } |
62 | 65 | ||
@@ -88,6 +91,9 @@ context_create_from_contact (struct GNUNET_CHAT_Handle *handle, | |||
88 | 8, GNUNET_NO | 91 | 8, GNUNET_NO |
89 | ); | 92 | ); |
90 | 93 | ||
94 | context->query_open = NULL; | ||
95 | context->query_commit = NULL; | ||
96 | |||
91 | return context; | 97 | return context; |
92 | } | 98 | } |
93 | 99 | ||
@@ -100,6 +106,12 @@ context_destroy (struct GNUNET_CHAT_Context *context) | |||
100 | (context->invites) && | 106 | (context->invites) && |
101 | (context->files)); | 107 | (context->files)); |
102 | 108 | ||
109 | if (context->query_open) | ||
110 | GNUNET_NAMESTORE_cancel(context->query_open); | ||
111 | |||
112 | if (context->query_commit) | ||
113 | GNUNET_NAMESTORE_cancel(context->query_commit); | ||
114 | |||
103 | GNUNET_CONTAINER_multishortmap_iterate( | 115 | GNUNET_CONTAINER_multishortmap_iterate( |
104 | context->timestamps, it_destroy_context_timestamps, NULL | 116 | context->timestamps, it_destroy_context_timestamps, NULL |
105 | ); | 117 | ); |
@@ -269,76 +281,19 @@ context_write_records (struct GNUNET_CHAT_Context *context) | |||
269 | context->room | 281 | context->room |
270 | ); | 282 | ); |
271 | 283 | ||
272 | struct GNUNET_TIME_Absolute expiration = GNUNET_TIME_absolute_get_forever_(); | ||
273 | |||
274 | struct GNUNET_MESSENGER_RoomEntryRecord room; | ||
275 | GNUNET_CRYPTO_get_peer_identity(context->handle->cfg, &(room.door)); | ||
276 | |||
277 | GNUNET_memcpy( | ||
278 | &(room.key), | ||
279 | hash, | ||
280 | sizeof(room.key) | ||
281 | ); | ||
282 | |||
283 | const char *nick = context->nick; | ||
284 | const char *topic = context->topic; | ||
285 | |||
286 | if (topic) | ||
287 | { | ||
288 | struct GNUNET_HashCode topic_hash; | ||
289 | GNUNET_CRYPTO_hash(topic, strlen(topic), &topic_hash); | ||
290 | |||
291 | if (0 != GNUNET_CRYPTO_hash_cmp(&topic_hash, hash)) | ||
292 | topic = NULL; | ||
293 | } | ||
294 | |||
295 | unsigned int count = 1; | ||
296 | |||
297 | struct GNUNET_GNSRECORD_Data data [3]; | ||
298 | data[0].record_type = GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY; | ||
299 | data[0].data = &room; | ||
300 | data[0].data_size = sizeof(room); | ||
301 | data[0].expiration_time = expiration.abs_value_us; | ||
302 | data[0].flags = GNUNET_GNSRECORD_RF_PRIVATE; | ||
303 | |||
304 | if (nick) | ||
305 | { | ||
306 | data[count].record_type = GNUNET_GNSRECORD_TYPE_NICK; | ||
307 | data[count].data = nick; | ||
308 | data[count].data_size = strlen(nick); | ||
309 | data[count].expiration_time = expiration.abs_value_us; | ||
310 | data[count].flags = ( | ||
311 | GNUNET_GNSRECORD_RF_PRIVATE | | ||
312 | GNUNET_GNSRECORD_RF_SUPPLEMENTAL | ||
313 | ); | ||
314 | |||
315 | count++; | ||
316 | } | ||
317 | |||
318 | if (topic) | ||
319 | { | ||
320 | data[count].record_type = GNUNET_DNSPARSER_TYPE_TXT; | ||
321 | data[count].data = topic; | ||
322 | data[count].data_size = strlen(topic); | ||
323 | data[count].expiration_time = expiration.abs_value_us; | ||
324 | data[count].flags = ( | ||
325 | GNUNET_GNSRECORD_RF_PRIVATE | | ||
326 | GNUNET_GNSRECORD_RF_SUPPLEMENTAL | ||
327 | ); | ||
328 | |||
329 | count++; | ||
330 | } | ||
331 | |||
332 | char *label; | 284 | char *label; |
333 | util_get_context_label(context->type, hash, &label); | 285 | util_get_context_label(context->type, hash, &label); |
334 | 286 | ||
335 | GNUNET_NAMESTORE_records_store( | 287 | if (context->query_open) |
288 | GNUNET_NAMESTORE_cancel(context->query_open); | ||
289 | |||
290 | context->query_open = GNUNET_NAMESTORE_records_open( | ||
336 | context->handle->namestore, | 291 | context->handle->namestore, |
337 | zone, | 292 | zone, |
338 | label, | 293 | label, |
339 | count, | 294 | error_context_open_records, |
340 | data, | 295 | context, |
341 | cont_context_write_records, | 296 | monitor_context_open_records, |
342 | context | 297 | context |
343 | ); | 298 | ); |
344 | 299 | ||
@@ -363,35 +318,19 @@ context_delete_records (struct GNUNET_CHAT_Context *context) | |||
363 | context->room | 318 | context->room |
364 | ); | 319 | ); |
365 | 320 | ||
366 | const char *type_string = "chat"; | ||
367 | |||
368 | switch (context->type) | ||
369 | { | ||
370 | case GNUNET_CHAT_CONTEXT_TYPE_CONTACT: | ||
371 | type_string = "contact"; | ||
372 | break; | ||
373 | case GNUNET_CHAT_CONTEXT_TYPE_GROUP: | ||
374 | type_string = "group"; | ||
375 | break; | ||
376 | default: | ||
377 | break; | ||
378 | } | ||
379 | |||
380 | char *label; | 321 | char *label; |
381 | GNUNET_asprintf ( | 322 | util_get_context_label(context->type, hash, &label); |
382 | &label, | ||
383 | "%s_%s", | ||
384 | type_string, | ||
385 | GNUNET_h2s(hash) | ||
386 | ); | ||
387 | 323 | ||
388 | GNUNET_NAMESTORE_records_store( | 324 | if (context->query_open) |
325 | GNUNET_NAMESTORE_cancel(context->query_open); | ||
326 | |||
327 | context->query_open = GNUNET_NAMESTORE_records_open( | ||
389 | context->handle->namestore, | 328 | context->handle->namestore, |
390 | zone, | 329 | zone, |
391 | label, | 330 | label, |
392 | 0, | 331 | error_context_open_records, |
393 | NULL, | 332 | context, |
394 | cont_context_write_records, | 333 | monitor_context_delete_records, |
395 | context | 334 | context |
396 | ); | 335 | ); |
397 | 336 | ||
diff --git a/src/gnunet_chat_context.h b/src/gnunet_chat_context.h index 37d9bc8..f2e41d0 100644 --- a/src/gnunet_chat_context.h +++ b/src/gnunet_chat_context.h | |||
@@ -56,6 +56,9 @@ struct GNUNET_CHAT_Context | |||
56 | void *user_pointer; | 56 | void *user_pointer; |
57 | 57 | ||
58 | struct GNUNET_CONTAINER_MultiShortmap *member_pointers; | 58 | struct GNUNET_CONTAINER_MultiShortmap *member_pointers; |
59 | |||
60 | struct GNUNET_NAMESTORE_QueueEntry *query_open; | ||
61 | struct GNUNET_NAMESTORE_QueueEntry *query_commit; | ||
59 | }; | 62 | }; |
60 | 63 | ||
61 | struct GNUNET_CHAT_Context* | 64 | struct GNUNET_CHAT_Context* |
diff --git a/src/gnunet_chat_context_intern.c b/src/gnunet_chat_context_intern.c index c4a3d5b..af1e2cc 100644 --- a/src/gnunet_chat_context_intern.c +++ b/src/gnunet_chat_context_intern.c | |||
@@ -64,17 +64,161 @@ it_destroy_context_invites (GNUNET_UNUSED void *cls, | |||
64 | } | 64 | } |
65 | 65 | ||
66 | void | 66 | void |
67 | cont_context_write_records (void *cls, | 67 | cont_context_commit_records (void *cls, |
68 | GNUNET_UNUSED int32_t success, | 68 | GNUNET_UNUSED int32_t success, |
69 | const char *emsg) | 69 | const char *emsg) |
70 | { | 70 | { |
71 | struct GNUNET_CHAT_Context *context = cls; | 71 | struct GNUNET_CHAT_Context *context = cls; |
72 | 72 | ||
73 | if (emsg) | 73 | GNUNET_assert(context); |
74 | handle_send_internal_message( | 74 | |
75 | context->handle, | 75 | context->query_commit = NULL; |
76 | context, | 76 | |
77 | GNUNET_CHAT_FLAG_WARNING, | 77 | if ((!emsg) || (!(context->handle))) |
78 | emsg | 78 | return; |
79 | |||
80 | handle_send_internal_message( | ||
81 | context->handle, | ||
82 | context, | ||
83 | GNUNET_CHAT_FLAG_WARNING, | ||
84 | emsg | ||
85 | ); | ||
86 | } | ||
87 | |||
88 | void | ||
89 | error_context_open_records (void *cls) | ||
90 | { | ||
91 | struct GNUNET_CHAT_Context *context = cls; | ||
92 | |||
93 | GNUNET_assert(context); | ||
94 | |||
95 | context->query_open = NULL; | ||
96 | |||
97 | if (!(context->handle)) | ||
98 | return; | ||
99 | |||
100 | handle_send_internal_message( | ||
101 | context->handle, | ||
102 | context, | ||
103 | GNUNET_CHAT_FLAG_WARNING, | ||
104 | _("Namestore busy!") | ||
105 | ); | ||
106 | } | ||
107 | |||
108 | void | ||
109 | monitor_context_open_records (void *cls, | ||
110 | const struct GNUNET_IDENTITY_PrivateKey *zone, | ||
111 | const char *label, | ||
112 | GNUNET_UNUSED unsigned int rd_count, | ||
113 | GNUNET_UNUSED const struct GNUNET_GNSRECORD_Data *rd) | ||
114 | { | ||
115 | struct GNUNET_CHAT_Context *context = cls; | ||
116 | |||
117 | GNUNET_assert((context) && (context->handle)); | ||
118 | |||
119 | context->query_open = NULL; | ||
120 | |||
121 | const struct GNUNET_HashCode *hash = GNUNET_MESSENGER_room_get_key( | ||
122 | context->room | ||
123 | ); | ||
124 | |||
125 | struct GNUNET_MESSENGER_RoomEntryRecord room; | ||
126 | GNUNET_CRYPTO_get_peer_identity(context->handle->cfg, &(room.door)); | ||
127 | |||
128 | GNUNET_memcpy( | ||
129 | &(room.key), | ||
130 | hash, | ||
131 | sizeof(room.key) | ||
132 | ); | ||
133 | |||
134 | struct GNUNET_TIME_Absolute expiration = GNUNET_TIME_absolute_get_forever_(); | ||
135 | |||
136 | const char *nick = context->nick; | ||
137 | const char *topic = context->topic; | ||
138 | |||
139 | if (topic) | ||
140 | { | ||
141 | struct GNUNET_HashCode topic_hash; | ||
142 | GNUNET_CRYPTO_hash(topic, strlen(topic), &topic_hash); | ||
143 | |||
144 | if (0 != GNUNET_CRYPTO_hash_cmp(&topic_hash, hash)) | ||
145 | topic = NULL; | ||
146 | } | ||
147 | |||
148 | unsigned int count = 1; | ||
149 | |||
150 | struct GNUNET_GNSRECORD_Data data [3]; | ||
151 | data[0].record_type = GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY; | ||
152 | data[0].data = &room; | ||
153 | data[0].data_size = sizeof(room); | ||
154 | data[0].expiration_time = expiration.abs_value_us; | ||
155 | data[0].flags = GNUNET_GNSRECORD_RF_PRIVATE; | ||
156 | |||
157 | if (nick) | ||
158 | { | ||
159 | data[count].record_type = GNUNET_GNSRECORD_TYPE_NICK; | ||
160 | data[count].data = nick; | ||
161 | data[count].data_size = strlen(nick); | ||
162 | data[count].expiration_time = expiration.abs_value_us; | ||
163 | data[count].flags = ( | ||
164 | GNUNET_GNSRECORD_RF_PRIVATE | | ||
165 | GNUNET_GNSRECORD_RF_SUPPLEMENTAL | ||
79 | ); | 166 | ); |
167 | |||
168 | count++; | ||
169 | } | ||
170 | |||
171 | if (topic) | ||
172 | { | ||
173 | data[count].record_type = GNUNET_DNSPARSER_TYPE_TXT; | ||
174 | data[count].data = topic; | ||
175 | data[count].data_size = strlen(topic); | ||
176 | data[count].expiration_time = expiration.abs_value_us; | ||
177 | data[count].flags = ( | ||
178 | GNUNET_GNSRECORD_RF_PRIVATE | | ||
179 | GNUNET_GNSRECORD_RF_SUPPLEMENTAL | ||
180 | ); | ||
181 | |||
182 | count++; | ||
183 | } | ||
184 | |||
185 | if (context->query_commit) | ||
186 | GNUNET_NAMESTORE_cancel(context->query_commit); | ||
187 | |||
188 | context->query_commit = GNUNET_NAMESTORE_records_commit( | ||
189 | context->handle->namestore, | ||
190 | zone, | ||
191 | label, | ||
192 | count, | ||
193 | data, | ||
194 | cont_context_commit_records, | ||
195 | context | ||
196 | ); | ||
197 | } | ||
198 | |||
199 | void | ||
200 | monitor_context_delete_records (void *cls, | ||
201 | const struct GNUNET_IDENTITY_PrivateKey *zone, | ||
202 | const char *label, | ||
203 | GNUNET_UNUSED unsigned int rd_count, | ||
204 | GNUNET_UNUSED const struct GNUNET_GNSRECORD_Data *rd) | ||
205 | { | ||
206 | struct GNUNET_CHAT_Context *context = cls; | ||
207 | |||
208 | GNUNET_assert((context) && (context->handle)); | ||
209 | |||
210 | context->query_open = NULL; | ||
211 | |||
212 | if (context->query_commit) | ||
213 | GNUNET_NAMESTORE_cancel(context->query_commit); | ||
214 | |||
215 | context->query_commit = GNUNET_NAMESTORE_records_commit( | ||
216 | context->handle->namestore, | ||
217 | zone, | ||
218 | label, | ||
219 | 0, | ||
220 | NULL, | ||
221 | cont_context_commit_records, | ||
222 | context | ||
223 | ); | ||
80 | } | 224 | } |
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c index e11c92d..6f53819 100644 --- a/src/gnunet_chat_lib.c +++ b/src/gnunet_chat_lib.c | |||
@@ -569,6 +569,13 @@ GNUNET_CHAT_contact_set_name (struct GNUNET_CHAT_Contact *contact, | |||
569 | 569 | ||
570 | if (contact->context->room) | 570 | if (contact->context->room) |
571 | context_write_records(contact->context); | 571 | context_write_records(contact->context); |
572 | |||
573 | handle_send_internal_message( | ||
574 | contact->handle, | ||
575 | contact->context, | ||
576 | GNUNET_CHAT_FLAG_UPDATE, | ||
577 | NULL | ||
578 | ); | ||
572 | } | 579 | } |
573 | 580 | ||
574 | 581 | ||
@@ -684,7 +691,16 @@ GNUNET_CHAT_group_set_name (struct GNUNET_CHAT_Group *group, | |||
684 | return; | 691 | return; |
685 | 692 | ||
686 | context_update_nick(group->context, name); | 693 | context_update_nick(group->context, name); |
687 | context_write_records(group->context); | 694 | |
695 | if (group->context->room) | ||
696 | context_write_records(group->context); | ||
697 | |||
698 | handle_send_internal_message( | ||
699 | group->handle, | ||
700 | group->context, | ||
701 | GNUNET_CHAT_FLAG_UPDATE, | ||
702 | NULL | ||
703 | ); | ||
688 | } | 704 | } |
689 | 705 | ||
690 | 706 | ||
diff --git a/src/gnunet_chat_lobby.c b/src/gnunet_chat_lobby.c index 23c6d32..385fae8 100644 --- a/src/gnunet_chat_lobby.c +++ b/src/gnunet_chat_lobby.c | |||
@@ -41,6 +41,9 @@ lobby_create (struct GNUNET_CHAT_Handle *handle) | |||
41 | lobby->op_create = NULL; | 41 | lobby->op_create = NULL; |
42 | lobby->op_delete = NULL; | 42 | lobby->op_delete = NULL; |
43 | 43 | ||
44 | lobby->query_open = NULL; | ||
45 | lobby->query_commit = NULL; | ||
46 | |||
44 | lobby->expiration = GNUNET_TIME_absolute_get_forever_(); | 47 | lobby->expiration = GNUNET_TIME_absolute_get_forever_(); |
45 | lobby->callback = NULL; | 48 | lobby->callback = NULL; |
46 | lobby->cls = NULL; | 49 | lobby->cls = NULL; |
@@ -59,6 +62,12 @@ lobby_destroy (struct GNUNET_CHAT_Lobby *lobby) | |||
59 | if (lobby->op_delete) | 62 | if (lobby->op_delete) |
60 | GNUNET_IDENTITY_cancel(lobby->op_delete); | 63 | GNUNET_IDENTITY_cancel(lobby->op_delete); |
61 | 64 | ||
65 | if (lobby->query_open) | ||
66 | GNUNET_NAMESTORE_cancel(lobby->query_open); | ||
67 | |||
68 | if (lobby->query_commit) | ||
69 | GNUNET_NAMESTORE_cancel(lobby->query_commit); | ||
70 | |||
62 | if (lobby->uri) | 71 | if (lobby->uri) |
63 | uri_destroy(lobby->uri); | 72 | uri_destroy(lobby->uri); |
64 | 73 | ||
diff --git a/src/gnunet_chat_lobby.h b/src/gnunet_chat_lobby.h index e913134..6248a05 100644 --- a/src/gnunet_chat_lobby.h +++ b/src/gnunet_chat_lobby.h | |||
@@ -46,6 +46,9 @@ struct GNUNET_CHAT_Lobby | |||
46 | struct GNUNET_IDENTITY_Operation *op_create; | 46 | struct GNUNET_IDENTITY_Operation *op_create; |
47 | struct GNUNET_IDENTITY_Operation *op_delete; | 47 | struct GNUNET_IDENTITY_Operation *op_delete; |
48 | 48 | ||
49 | struct GNUNET_NAMESTORE_QueueEntry *query_open; | ||
50 | struct GNUNET_NAMESTORE_QueueEntry *query_commit; | ||
51 | |||
49 | struct GNUNET_TIME_Absolute expiration; | 52 | struct GNUNET_TIME_Absolute expiration; |
50 | GNUNET_CHAT_LobbyCallback callback; | 53 | GNUNET_CHAT_LobbyCallback callback; |
51 | void *cls; | 54 | void *cls; |
diff --git a/src/gnunet_chat_lobby_intern.c b/src/gnunet_chat_lobby_intern.c index 31d1673..c66800c 100644 --- a/src/gnunet_chat_lobby_intern.c +++ b/src/gnunet_chat_lobby_intern.c | |||
@@ -25,21 +25,28 @@ | |||
25 | #include "gnunet_chat_context.h" | 25 | #include "gnunet_chat_context.h" |
26 | 26 | ||
27 | void | 27 | void |
28 | cont_lobby_write_records (void *cls, | 28 | cont_lobby_commit_records (void *cls, |
29 | GNUNET_UNUSED int32_t success, | 29 | GNUNET_UNUSED int32_t success, |
30 | const char *emsg) | 30 | const char *emsg) |
31 | { | 31 | { |
32 | struct GNUNET_CHAT_Lobby *lobby = cls; | 32 | struct GNUNET_CHAT_Lobby *lobby = cls; |
33 | 33 | ||
34 | GNUNET_assert((lobby) && | ||
35 | (lobby->handle) && | ||
36 | (lobby->context)); | ||
37 | |||
38 | lobby->query_commit = NULL; | ||
39 | |||
34 | if (!emsg) | 40 | if (!emsg) |
35 | goto call_cb; | 41 | goto call_cb; |
36 | 42 | ||
37 | handle_send_internal_message( | 43 | if (lobby->handle) |
38 | lobby->handle, | 44 | handle_send_internal_message( |
39 | lobby->context, | 45 | lobby->handle, |
40 | GNUNET_CHAT_FLAG_WARNING, | 46 | lobby->context, |
41 | emsg | 47 | GNUNET_CHAT_FLAG_WARNING, |
42 | ); | 48 | emsg |
49 | ); | ||
43 | 50 | ||
44 | if (lobby->uri) | 51 | if (lobby->uri) |
45 | uri_destroy(lobby->uri); | 52 | uri_destroy(lobby->uri); |
@@ -52,40 +59,41 @@ call_cb: | |||
52 | } | 59 | } |
53 | 60 | ||
54 | void | 61 | void |
55 | cont_lobby_identity_delete (void *cls, | 62 | error_lobby_open_records (void *cls) |
56 | const char *emsg) | ||
57 | { | 63 | { |
58 | struct GNUNET_CHAT_Lobby *lobby = cls; | 64 | struct GNUNET_CHAT_Lobby *lobby = cls; |
59 | 65 | ||
60 | if (!emsg) | 66 | GNUNET_assert((lobby) && |
67 | (lobby->handle) && | ||
68 | (lobby->context)); | ||
69 | |||
70 | lobby->query_open = NULL; | ||
71 | |||
72 | if (!(lobby->handle)) | ||
61 | return; | 73 | return; |
62 | 74 | ||
63 | handle_send_internal_message( | 75 | handle_send_internal_message( |
64 | lobby->handle, | 76 | lobby->handle, |
65 | lobby->context, | 77 | lobby->context, |
66 | GNUNET_CHAT_FLAG_WARNING, | 78 | GNUNET_CHAT_FLAG_WARNING, |
67 | emsg | 79 | _("Namestore busy!") |
68 | ); | 80 | ); |
69 | } | 81 | } |
70 | 82 | ||
71 | void | 83 | void |
72 | cont_lobby_identity_create (void *cls, | 84 | monitor_lobby_open_records (void *cls, |
73 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 85 | const struct GNUNET_IDENTITY_PrivateKey *zone, |
74 | const char *emsg) | 86 | const char *label, |
87 | GNUNET_UNUSED unsigned int rd_count, | ||
88 | GNUNET_UNUSED const struct GNUNET_GNSRECORD_Data *rd) | ||
75 | { | 89 | { |
76 | struct GNUNET_CHAT_Lobby *lobby = cls; | 90 | struct GNUNET_CHAT_Lobby *lobby = cls; |
77 | 91 | ||
78 | if (emsg) | 92 | GNUNET_assert((lobby) && |
79 | { | 93 | (lobby->handle) && |
80 | handle_send_internal_message( | 94 | (lobby->context)); |
81 | lobby->handle, | ||
82 | lobby->context, | ||
83 | GNUNET_CHAT_FLAG_WARNING, | ||
84 | emsg | ||
85 | ); | ||
86 | 95 | ||
87 | return; | 96 | lobby->query_open = NULL; |
88 | } | ||
89 | 97 | ||
90 | const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key( | 98 | const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key( |
91 | lobby->context->room | 99 | lobby->context->room |
@@ -102,6 +110,73 @@ cont_lobby_identity_create (void *cls, | |||
102 | data[0].expiration_time = lobby->expiration.abs_value_us; | 110 | data[0].expiration_time = lobby->expiration.abs_value_us; |
103 | data[0].flags = GNUNET_GNSRECORD_RF_NONE; | 111 | data[0].flags = GNUNET_GNSRECORD_RF_NONE; |
104 | 112 | ||
113 | lobby->query_commit = GNUNET_NAMESTORE_records_commit( | ||
114 | lobby->handle->namestore, | ||
115 | zone, | ||
116 | label, | ||
117 | 1, | ||
118 | data, | ||
119 | cont_lobby_commit_records, | ||
120 | lobby | ||
121 | ); | ||
122 | } | ||
123 | |||
124 | void | ||
125 | cont_lobby_identity_delete (void *cls, | ||
126 | const char *emsg) | ||
127 | { | ||
128 | struct GNUNET_CHAT_Lobby *lobby = cls; | ||
129 | |||
130 | GNUNET_assert((lobby) && | ||
131 | (lobby->handle) && | ||
132 | (lobby->context)); | ||
133 | |||
134 | lobby->op_delete = NULL; | ||
135 | |||
136 | if ((!emsg) || (!(lobby->handle))) | ||
137 | return; | ||
138 | |||
139 | handle_send_internal_message( | ||
140 | lobby->handle, | ||
141 | lobby->context, | ||
142 | GNUNET_CHAT_FLAG_WARNING, | ||
143 | emsg | ||
144 | ); | ||
145 | } | ||
146 | |||
147 | void | ||
148 | cont_lobby_identity_create (void *cls, | ||
149 | const struct GNUNET_IDENTITY_PrivateKey *zone, | ||
150 | const char *emsg) | ||
151 | { | ||
152 | struct GNUNET_CHAT_Lobby *lobby = cls; | ||
153 | |||
154 | GNUNET_assert((lobby) && | ||
155 | (lobby->handle) && | ||
156 | (lobby->context)); | ||
157 | |||
158 | const struct GNUNET_HashCode *key; | ||
159 | |||
160 | lobby->op_create = NULL; | ||
161 | |||
162 | if (!emsg) | ||
163 | goto continue_with_lobby; | ||
164 | |||
165 | if (lobby->handle) | ||
166 | handle_send_internal_message( | ||
167 | lobby->handle, | ||
168 | lobby->context, | ||
169 | GNUNET_CHAT_FLAG_WARNING, | ||
170 | emsg | ||
171 | ); | ||
172 | |||
173 | return; | ||
174 | |||
175 | continue_with_lobby: | ||
176 | key = GNUNET_MESSENGER_room_get_key( | ||
177 | lobby->context->room | ||
178 | ); | ||
179 | |||
105 | if (lobby->uri) | 180 | if (lobby->uri) |
106 | uri_destroy(lobby->uri); | 181 | uri_destroy(lobby->uri); |
107 | 182 | ||
@@ -114,13 +189,13 @@ cont_lobby_identity_create (void *cls, | |||
114 | lobby->uri = uri_create(&public_zone, label); | 189 | lobby->uri = uri_create(&public_zone, label); |
115 | GNUNET_free(label); | 190 | GNUNET_free(label); |
116 | 191 | ||
117 | GNUNET_NAMESTORE_records_store( | 192 | lobby->query_open = GNUNET_NAMESTORE_records_open( |
118 | lobby->handle->namestore, | 193 | lobby->handle->namestore, |
119 | zone, | 194 | zone, |
120 | lobby->uri->label, | 195 | lobby->uri->label, |
121 | 1, | 196 | error_lobby_open_records, |
122 | data, | 197 | lobby, |
123 | cont_lobby_write_records, | 198 | monitor_lobby_open_records, |
124 | lobby | 199 | lobby |
125 | ); | 200 | ); |
126 | 201 | ||