aboutsummaryrefslogtreecommitdiff
path: root/src/messenger/gnunet-service-messenger_handle.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/messenger/gnunet-service-messenger_handle.c')
-rw-r--r--src/messenger/gnunet-service-messenger_handle.c114
1 files changed, 57 insertions, 57 deletions
diff --git a/src/messenger/gnunet-service-messenger_handle.c b/src/messenger/gnunet-service-messenger_handle.c
index 218482e45..a4fa81623 100644
--- a/src/messenger/gnunet-service-messenger_handle.c
+++ b/src/messenger/gnunet-service-messenger_handle.c
@@ -31,8 +31,8 @@
31#include "messenger_api_util.h" 31#include "messenger_api_util.h"
32 32
33struct GNUNET_MESSENGER_SrvHandle* 33struct GNUNET_MESSENGER_SrvHandle*
34create_handle (struct GNUNET_MESSENGER_Service *service, 34create_srv_handle (struct GNUNET_MESSENGER_Service *service,
35 struct GNUNET_MQ_Handle *mq) 35 struct GNUNET_MQ_Handle *mq)
36{ 36{
37 GNUNET_assert((service) && (mq)); 37 GNUNET_assert((service) && (mq));
38 38
@@ -60,12 +60,12 @@ iterate_free_member_ids (void *cls,
60} 60}
61 61
62void 62void
63destroy_handle (struct GNUNET_MESSENGER_SrvHandle *handle) 63destroy_srv_handle (struct GNUNET_MESSENGER_SrvHandle *handle)
64{ 64{
65 GNUNET_assert(handle); 65 GNUNET_assert(handle);
66 66
67 if (handle->service->dir) 67 if (handle->service->dir)
68 save_handle_configuration (handle); 68 save_srv_handle_configuration (handle);
69 69
70 if (handle->name) 70 if (handle->name)
71 { 71 {
@@ -83,9 +83,9 @@ destroy_handle (struct GNUNET_MESSENGER_SrvHandle *handle)
83} 83}
84 84
85void 85void
86get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, 86get_srv_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle,
87 const char *name, 87 const char *name,
88 char **dir) 88 char **dir)
89{ 89{
90 GNUNET_assert((handle) && (dir)); 90 GNUNET_assert((handle) && (dir));
91 91
@@ -124,8 +124,8 @@ create_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle,
124} 124}
125 125
126const struct GNUNET_ShortHashCode* 126const struct GNUNET_ShortHashCode*
127get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, 127get_srv_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle,
128 const struct GNUNET_HashCode *key) 128 const struct GNUNET_HashCode *key)
129{ 129{
130 GNUNET_assert((handle) && (key)); 130 GNUNET_assert((handle) && (key));
131 131
@@ -133,9 +133,9 @@ get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle,
133} 133}
134 134
135int 135int
136change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, 136change_srv_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle,
137 const struct GNUNET_HashCode *key, 137 const struct GNUNET_HashCode *key,
138 const struct GNUNET_ShortHashCode *unique_id) 138 const struct GNUNET_ShortHashCode *unique_id)
139{ 139{
140 GNUNET_assert((handle) && (key) && (unique_id)); 140 GNUNET_assert((handle) && (key) && (unique_id));
141 141
@@ -214,7 +214,7 @@ change_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle,
214 214
215 handle->ego = ego; 215 handle->ego = ego;
216 216
217 ego = get_handle_ego (handle); 217 ego = get_srv_handle_ego (handle);
218 218
219 const uint16_t length = GNUNET_IDENTITY_key_get_length(&(ego->pub)); 219 const uint16_t length = GNUNET_IDENTITY_key_get_length(&(ego->pub));
220 220
@@ -244,14 +244,14 @@ iterate_send_message (void *cls,
244{ 244{
245 struct GNUNET_MESSENGER_MessageHandle *msg_handle = cls; 245 struct GNUNET_MESSENGER_MessageHandle *msg_handle = cls;
246 246
247 send_handle_message (msg_handle->handle, key, msg_handle->message); 247 send_srv_handle_message (msg_handle->handle, key, msg_handle->message);
248 248
249 return GNUNET_YES; 249 return GNUNET_YES;
250} 250}
251 251
252void 252void
253set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, 253set_srv_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle,
254 const struct GNUNET_MESSENGER_Ego *ego) 254 const struct GNUNET_MESSENGER_Ego *ego)
255{ 255{
256 GNUNET_assert((handle) && (ego)); 256 GNUNET_assert((handle) && (ego));
257 257
@@ -268,7 +268,7 @@ set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle,
268} 268}
269 269
270const struct GNUNET_MESSENGER_Ego* 270const struct GNUNET_MESSENGER_Ego*
271get_handle_ego (const struct GNUNET_MESSENGER_SrvHandle *handle) 271get_srv_handle_ego (const struct GNUNET_MESSENGER_SrvHandle *handle)
272{ 272{
273 GNUNET_assert(handle); 273 GNUNET_assert(handle);
274 274
@@ -302,12 +302,12 @@ callback_setup_handle_name (void *cls,
302 change_handle_ego (handle, ego); 302 change_handle_ego (handle, ego);
303 303
304 if (handle->service->dir) 304 if (handle->service->dir)
305 load_handle_configuration (handle); 305 load_srv_handle_configuration (handle);
306} 306}
307 307
308void 308void
309setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, 309setup_srv_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
310 const char *name) 310 const char *name)
311{ 311{
312 GNUNET_assert(handle); 312 GNUNET_assert(handle);
313 313
@@ -336,7 +336,7 @@ callback_update_handle (void *cls,
336} 336}
337 337
338void 338void
339update_handle (struct GNUNET_MESSENGER_SrvHandle *handle) 339update_srv_handle (struct GNUNET_MESSENGER_SrvHandle *handle)
340{ 340{
341 GNUNET_assert (handle); 341 GNUNET_assert (handle);
342 342
@@ -369,10 +369,10 @@ callback_set_handle_name (void *cls,
369 struct GNUNET_MESSENGER_EgoStore *store = get_service_ego_store(handle->service); 369 struct GNUNET_MESSENGER_EgoStore *store = get_service_ego_store(handle->service);
370 370
371 char *old_dir; 371 char *old_dir;
372 get_handle_data_subdir (handle, handle->name, &old_dir); 372 get_srv_handle_data_subdir (handle, handle->name, &old_dir);
373 373
374 char *new_dir; 374 char *new_dir;
375 get_handle_data_subdir (handle, name, &new_dir); 375 get_srv_handle_data_subdir (handle, name, &new_dir);
376 376
377 if ((GNUNET_YES == GNUNET_DISK_directory_test (new_dir, GNUNET_NO)) && 377 if ((GNUNET_YES == GNUNET_DISK_directory_test (new_dir, GNUNET_NO)) &&
378 (GNUNET_OK != GNUNET_DISK_directory_remove(new_dir))) 378 (GNUNET_OK != GNUNET_DISK_directory_remove(new_dir)))
@@ -403,8 +403,8 @@ free_dirs:
403} 403}
404 404
405void 405void
406set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, 406set_srv_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
407 const char *name) 407 const char *name)
408{ 408{
409 GNUNET_assert(handle); 409 GNUNET_assert(handle);
410 410
@@ -424,50 +424,50 @@ set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
424} 424}
425 425
426int 426int
427open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, 427open_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
428 const struct GNUNET_HashCode *key) 428 const struct GNUNET_HashCode *key)
429{ 429{
430 GNUNET_assert((handle) && (key)); 430 GNUNET_assert((handle) && (key));
431 431
432 if ((!get_handle_member_id (handle, key)) && (GNUNET_YES != create_handle_member_id (handle, key))) 432 if ((!get_srv_handle_member_id (handle, key)) && (GNUNET_YES != create_handle_member_id (handle, key)))
433 return GNUNET_NO; 433 return GNUNET_NO;
434 434
435 return open_service_room (handle->service, handle, key); 435 return open_service_room (handle->service, handle, key);
436} 436}
437 437
438int 438int
439entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, 439entry_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
440 const struct GNUNET_PeerIdentity *door, 440 const struct GNUNET_PeerIdentity *door,
441 const struct GNUNET_HashCode *key) 441 const struct GNUNET_HashCode *key)
442{ 442{
443 GNUNET_assert((handle) && (door) && (key)); 443 GNUNET_assert((handle) && (door) && (key));
444 444
445 if ((!get_handle_member_id (handle, key)) && (GNUNET_YES != create_handle_member_id (handle, key))) 445 if ((!get_srv_handle_member_id (handle, key)) && (GNUNET_YES != create_handle_member_id (handle, key)))
446 return GNUNET_NO; 446 return GNUNET_NO;
447 447
448 return entry_service_room (handle->service, handle, door, key); 448 return entry_service_room (handle->service, handle, door, key);
449} 449}
450 450
451int 451int
452close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, 452close_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
453 const struct GNUNET_HashCode *key) 453 const struct GNUNET_HashCode *key)
454{ 454{
455 GNUNET_assert((handle) && (key)); 455 GNUNET_assert((handle) && (key));
456 456
457 if (!get_handle_member_id (handle, key)) 457 if (!get_srv_handle_member_id (handle, key))
458 return GNUNET_NO; 458 return GNUNET_NO;
459 459
460 return close_service_room (handle->service, handle, key); 460 return close_service_room (handle->service, handle, key);
461} 461}
462 462
463int 463int
464send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, 464send_srv_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
465 const struct GNUNET_HashCode *key, 465 const struct GNUNET_HashCode *key,
466 const struct GNUNET_MESSENGER_Message *message) 466 const struct GNUNET_MESSENGER_Message *message)
467{ 467{
468 GNUNET_assert((handle) && (key) && (message)); 468 GNUNET_assert((handle) && (key) && (message));
469 469
470 const struct GNUNET_ShortHashCode *id = get_handle_member_id (handle, key); 470 const struct GNUNET_ShortHashCode *id = get_srv_handle_member_id (handle, key);
471 471
472 if (!id) 472 if (!id)
473 { 473 {
@@ -487,7 +487,7 @@ send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
487 487
488 GNUNET_memcpy(&(msg->header.sender_id), id, sizeof(*id)); 488 GNUNET_memcpy(&(msg->header.sender_id), id, sizeof(*id));
489 489
490 return send_room_message (room, handle, msg); 490 return send_srv_room_message (room, handle, msg);
491} 491}
492 492
493static const struct GNUNET_HashCode* 493static const struct GNUNET_HashCode*
@@ -506,15 +506,15 @@ get_handle_member_session (struct GNUNET_MESSENGER_SrvHandle *handle,
506{ 506{
507 GNUNET_assert((handle) && (room) && (key) && (handle->service)); 507 GNUNET_assert((handle) && (room) && (key) && (handle->service));
508 508
509 const struct GNUNET_ShortHashCode *id = get_handle_member_id(handle, key); 509 const struct GNUNET_ShortHashCode *id = get_srv_handle_member_id(handle, key);
510 510
511 if (!id) 511 if (!id)
512 return NULL; 512 return NULL;
513 513
514 struct GNUNET_MESSENGER_MemberStore *store = get_room_member_store(room); 514 struct GNUNET_MESSENGER_MemberStore *store = get_srv_room_member_store(room);
515 struct GNUNET_MESSENGER_Member *member = get_store_member(store, id); 515 struct GNUNET_MESSENGER_Member *member = get_store_member(store, id);
516 516
517 const struct GNUNET_MESSENGER_Ego *ego = get_handle_ego(handle); 517 const struct GNUNET_MESSENGER_Ego *ego = get_srv_handle_ego(handle);
518 518
519 if (!ego) 519 if (!ego)
520 return NULL; 520 return NULL;
@@ -523,17 +523,17 @@ get_handle_member_session (struct GNUNET_MESSENGER_SrvHandle *handle,
523} 523}
524 524
525void 525void
526notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, 526notify_srv_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
527 struct GNUNET_MESSENGER_SrvRoom *room, 527 struct GNUNET_MESSENGER_SrvRoom *room,
528 const struct GNUNET_MESSENGER_MemberSession *session, 528 const struct GNUNET_MESSENGER_MemberSession *session,
529 const struct GNUNET_MESSENGER_Message *message, 529 const struct GNUNET_MESSENGER_Message *message,
530 const struct GNUNET_HashCode *hash) 530 const struct GNUNET_HashCode *hash)
531{ 531{
532 GNUNET_assert((handle) && (room) && (session) && (message) && (hash)); 532 GNUNET_assert((handle) && (room) && (session) && (message) && (hash));
533 533
534 const struct GNUNET_HashCode *key = get_room_key(room); 534 const struct GNUNET_HashCode *key = get_srv_room_key(room);
535 535
536 if ((!handle->mq) || (!get_handle_member_id (handle, key))) 536 if ((!handle->mq) || (!get_srv_handle_member_id (handle, key)))
537 { 537 {
538 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Notifying client about message requires membership!\n"); 538 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Notifying client about message requires membership!\n");
539 return; 539 return;
@@ -554,7 +554,7 @@ notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
554 { 554 {
555 private_message = copy_message(message); 555 private_message = copy_message(message);
556 556
557 if (GNUNET_YES != decrypt_message(private_message, &(get_handle_ego(handle)->priv))) 557 if (GNUNET_YES != decrypt_message(private_message, &(get_srv_handle_ego(handle)->priv)))
558 { 558 {
559 destroy_message(private_message); 559 destroy_message(private_message);
560 private_message = NULL; 560 private_message = NULL;
@@ -612,7 +612,7 @@ callback_scan_for_rooms (void *cls,
612 612
613 if ((GNUNET_OK == GNUNET_CONFIGURATION_get_data (cfg, "room", "key", &key, sizeof(key))) && 613 if ((GNUNET_OK == GNUNET_CONFIGURATION_get_data (cfg, "room", "key", &key, sizeof(key))) &&
614 (GNUNET_OK == GNUNET_CONFIGURATION_get_data (cfg, "room", "member_id", &member_id, sizeof(member_id)))) 614 (GNUNET_OK == GNUNET_CONFIGURATION_get_data (cfg, "room", "member_id", &member_id, sizeof(member_id))))
615 change_handle_member_id (handle, &key, &member_id); 615 change_srv_handle_member_id (handle, &key, &member_id);
616 } 616 }
617 617
618 GNUNET_CONFIGURATION_destroy (cfg); 618 GNUNET_CONFIGURATION_destroy (cfg);
@@ -620,12 +620,12 @@ callback_scan_for_rooms (void *cls,
620} 620}
621 621
622void 622void
623load_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle) 623load_srv_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle)
624{ 624{
625 GNUNET_assert(handle); 625 GNUNET_assert(handle);
626 626
627 char *id_dir; 627 char *id_dir;
628 get_handle_data_subdir (handle, handle->name, &id_dir); 628 get_srv_handle_data_subdir (handle, handle->name, &id_dir);
629 629
630 if (GNUNET_YES == GNUNET_DISK_directory_test (id_dir, GNUNET_YES)) 630 if (GNUNET_YES == GNUNET_DISK_directory_test (id_dir, GNUNET_YES))
631 { 631 {
@@ -650,7 +650,7 @@ iterate_save_rooms (void *cls,
650 struct GNUNET_ShortHashCode *member_id = value; 650 struct GNUNET_ShortHashCode *member_id = value;
651 651
652 char *id_dir; 652 char *id_dir;
653 get_handle_data_subdir (handle, handle->name, &id_dir); 653 get_srv_handle_data_subdir (handle, handle->name, &id_dir);
654 654
655 char *filename; 655 char *filename;
656 GNUNET_asprintf (&filename, "%s%s%c%s.cfg", id_dir, "rooms", DIR_SEPARATOR, GNUNET_h2s (key)); 656 GNUNET_asprintf (&filename, "%s%s%c%s.cfg", id_dir, "rooms", DIR_SEPARATOR, GNUNET_h2s (key));
@@ -687,12 +687,12 @@ iterate_save_rooms (void *cls,
687} 687}
688 688
689void 689void
690save_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle) 690save_srv_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle)
691{ 691{
692 GNUNET_assert(handle); 692 GNUNET_assert(handle);
693 693
694 char *id_dir; 694 char *id_dir;
695 get_handle_data_subdir (handle, handle->name, &id_dir); 695 get_srv_handle_data_subdir (handle, handle->name, &id_dir);
696 696
697 if ((GNUNET_YES == GNUNET_DISK_directory_test (id_dir, GNUNET_NO)) || (GNUNET_OK 697 if ((GNUNET_YES == GNUNET_DISK_directory_test (id_dir, GNUNET_NO)) || (GNUNET_OK
698 == GNUNET_DISK_directory_create (id_dir))) 698 == GNUNET_DISK_directory_create (id_dir)))