diff options
Diffstat (limited to 'src/gnunet_chat_context.c')
-rw-r--r-- | src/gnunet_chat_context.c | 68 |
1 files changed, 4 insertions, 64 deletions
diff --git a/src/gnunet_chat_context.c b/src/gnunet_chat_context.c index a4f3db0..fe15307 100644 --- a/src/gnunet_chat_context.c +++ b/src/gnunet_chat_context.c | |||
@@ -269,76 +269,16 @@ context_write_records (struct GNUNET_CHAT_Context *context) | |||
269 | context->room | 269 | context->room |
270 | ); | 270 | ); |
271 | 271 | ||
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; | 272 | char *label; |
333 | util_get_context_label(context->type, hash, &label); | 273 | util_get_context_label(context->type, hash, &label); |
334 | 274 | ||
335 | GNUNET_NAMESTORE_records_store( | 275 | GNUNET_NAMESTORE_records_open( |
336 | context->handle->namestore, | 276 | context->handle->namestore, |
337 | zone, | 277 | zone, |
338 | label, | 278 | label, |
339 | count, | 279 | error_context_write_records, |
340 | data, | 280 | context, |
341 | cont_context_write_records, | 281 | monitor_context_write_records, |
342 | context | 282 | context |
343 | ); | 283 | ); |
344 | 284 | ||