aboutsummaryrefslogtreecommitdiff
path: root/src/gnunet_chat_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnunet_chat_lib.c')
-rw-r--r--src/gnunet_chat_lib.c172
1 files changed, 172 insertions, 0 deletions
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c
index 8ec7499..1fcc419 100644
--- a/src/gnunet_chat_lib.c
+++ b/src/gnunet_chat_lib.c
@@ -39,11 +39,19 @@
39 39
40#include "gnunet_chat_lib_intern.c" 40#include "gnunet_chat_lib_intern.c"
41 41
42#define GNUNET_CHAT_VERSION_ASSERT() {\
43 GNUNET_assert(\
44 (GNUNET_MESSENGER_VERSION == ((GNUNET_CHAT_VERSION >> 16L) & 0xFFFFFFFFL))\
45 );\
46}
47
42struct GNUNET_CHAT_Handle* 48struct GNUNET_CHAT_Handle*
43GNUNET_CHAT_start (const struct GNUNET_CONFIGURATION_Handle *cfg, 49GNUNET_CHAT_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
44 const char *directory, 50 const char *directory,
45 GNUNET_CHAT_ContextMessageCallback msg_cb, void *msg_cls) 51 GNUNET_CHAT_ContextMessageCallback msg_cb, void *msg_cls)
46{ 52{
53 GNUNET_CHAT_VERSION_ASSERT();
54
47 if (!cfg) 55 if (!cfg)
48 return NULL; 56 return NULL;
49 57
@@ -57,6 +65,8 @@ GNUNET_CHAT_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
57void 65void
58GNUNET_CHAT_stop (struct GNUNET_CHAT_Handle *handle) 66GNUNET_CHAT_stop (struct GNUNET_CHAT_Handle *handle)
59{ 67{
68 GNUNET_CHAT_VERSION_ASSERT();
69
60 if (!handle) 70 if (!handle)
61 return; 71 return;
62 72
@@ -68,6 +78,8 @@ int
68GNUNET_CHAT_account_create (struct GNUNET_CHAT_Handle *handle, 78GNUNET_CHAT_account_create (struct GNUNET_CHAT_Handle *handle,
69 const char* name) 79 const char* name)
70{ 80{
81 GNUNET_CHAT_VERSION_ASSERT();
82
71 if ((!handle) || (!name)) 83 if ((!handle) || (!name))
72 return GNUNET_SYSERR; 84 return GNUNET_SYSERR;
73 85
@@ -106,6 +118,8 @@ GNUNET_CHAT_iterate_accounts (const struct GNUNET_CHAT_Handle *handle,
106 GNUNET_CHAT_AccountCallback callback, 118 GNUNET_CHAT_AccountCallback callback,
107 void *cls) 119 void *cls)
108{ 120{
121 GNUNET_CHAT_VERSION_ASSERT();
122
109 if (!handle) 123 if (!handle)
110 return GNUNET_SYSERR; 124 return GNUNET_SYSERR;
111 125
@@ -133,6 +147,8 @@ void
133GNUNET_CHAT_connect (struct GNUNET_CHAT_Handle *handle, 147GNUNET_CHAT_connect (struct GNUNET_CHAT_Handle *handle,
134 const struct GNUNET_CHAT_Account *account) 148 const struct GNUNET_CHAT_Account *account)
135{ 149{
150 GNUNET_CHAT_VERSION_ASSERT();
151
136 if (!handle) 152 if (!handle)
137 return; 153 return;
138 154
@@ -152,6 +168,8 @@ GNUNET_CHAT_connect (struct GNUNET_CHAT_Handle *handle,
152void 168void
153GNUNET_CHAT_disconnect (struct GNUNET_CHAT_Handle *handle) 169GNUNET_CHAT_disconnect (struct GNUNET_CHAT_Handle *handle)
154{ 170{
171 GNUNET_CHAT_VERSION_ASSERT();
172
155 if ((!handle) || (!(handle->current))) 173 if ((!handle) || (!(handle->current)))
156 return; 174 return;
157 175
@@ -162,6 +180,8 @@ GNUNET_CHAT_disconnect (struct GNUNET_CHAT_Handle *handle)
162const struct GNUNET_CHAT_Account* 180const struct GNUNET_CHAT_Account*
163GNUNET_CHAT_get_connected (const struct GNUNET_CHAT_Handle *handle) 181GNUNET_CHAT_get_connected (const struct GNUNET_CHAT_Handle *handle)
164{ 182{
183 GNUNET_CHAT_VERSION_ASSERT();
184
165 if (!handle) 185 if (!handle)
166 return NULL; 186 return NULL;
167 187
@@ -172,6 +192,8 @@ GNUNET_CHAT_get_connected (const struct GNUNET_CHAT_Handle *handle)
172int 192int
173GNUNET_CHAT_update (struct GNUNET_CHAT_Handle *handle) 193GNUNET_CHAT_update (struct GNUNET_CHAT_Handle *handle)
174{ 194{
195 GNUNET_CHAT_VERSION_ASSERT();
196
175 if (!handle) 197 if (!handle)
176 return GNUNET_SYSERR; 198 return GNUNET_SYSERR;
177 199
@@ -183,6 +205,8 @@ int
183GNUNET_CHAT_set_name (struct GNUNET_CHAT_Handle *handle, 205GNUNET_CHAT_set_name (struct GNUNET_CHAT_Handle *handle,
184 const char *name) 206 const char *name)
185{ 207{
208 GNUNET_CHAT_VERSION_ASSERT();
209
186 if (!handle) 210 if (!handle)
187 return GNUNET_SYSERR; 211 return GNUNET_SYSERR;
188 212
@@ -196,6 +220,8 @@ GNUNET_CHAT_set_name (struct GNUNET_CHAT_Handle *handle,
196const char* 220const char*
197GNUNET_CHAT_get_name (const struct GNUNET_CHAT_Handle *handle) 221GNUNET_CHAT_get_name (const struct GNUNET_CHAT_Handle *handle)
198{ 222{
223 GNUNET_CHAT_VERSION_ASSERT();
224
199 if (!handle) 225 if (!handle)
200 return NULL; 226 return NULL;
201 227
@@ -206,6 +232,8 @@ GNUNET_CHAT_get_name (const struct GNUNET_CHAT_Handle *handle)
206const char* 232const char*
207GNUNET_CHAT_get_key (const struct GNUNET_CHAT_Handle *handle) 233GNUNET_CHAT_get_key (const struct GNUNET_CHAT_Handle *handle)
208{ 234{
235 GNUNET_CHAT_VERSION_ASSERT();
236
209 if (!handle) 237 if (!handle)
210 return NULL; 238 return NULL;
211 239
@@ -217,6 +245,8 @@ struct GNUNET_CHAT_Uri*
217GNUNET_CHAT_uri_parse (const char *uri, 245GNUNET_CHAT_uri_parse (const char *uri,
218 char **emsg) 246 char **emsg)
219{ 247{
248 GNUNET_CHAT_VERSION_ASSERT();
249
220 if (!uri) 250 if (!uri)
221 return NULL; 251 return NULL;
222 252
@@ -264,6 +294,8 @@ GNUNET_CHAT_uri_parse (const char *uri,
264char* 294char*
265GNUNET_CHAT_uri_to_string (const struct GNUNET_CHAT_Uri *uri) 295GNUNET_CHAT_uri_to_string (const struct GNUNET_CHAT_Uri *uri)
266{ 296{
297 GNUNET_CHAT_VERSION_ASSERT();
298
267 if (!uri) 299 if (!uri)
268 return NULL; 300 return NULL;
269 301
@@ -285,6 +317,8 @@ GNUNET_CHAT_uri_to_string (const struct GNUNET_CHAT_Uri *uri)
285void 317void
286GNUNET_CHAT_uri_destroy (struct GNUNET_CHAT_Uri *uri) 318GNUNET_CHAT_uri_destroy (struct GNUNET_CHAT_Uri *uri)
287{ 319{
320 GNUNET_CHAT_VERSION_ASSERT();
321
288 if (!uri) 322 if (!uri)
289 return; 323 return;
290 324
@@ -298,6 +332,8 @@ GNUNET_CHAT_lobby_open (struct GNUNET_CHAT_Handle *handle,
298 GNUNET_CHAT_LobbyCallback callback, 332 GNUNET_CHAT_LobbyCallback callback,
299 void *cls) 333 void *cls)
300{ 334{
335 GNUNET_CHAT_VERSION_ASSERT();
336
301 if (!handle) 337 if (!handle)
302 return NULL; 338 return NULL;
303 339
@@ -322,6 +358,8 @@ GNUNET_CHAT_lobby_open (struct GNUNET_CHAT_Handle *handle,
322void 358void
323GNUNET_CHAT_lobby_close (struct GNUNET_CHAT_Lobby *lobby) 359GNUNET_CHAT_lobby_close (struct GNUNET_CHAT_Lobby *lobby)
324{ 360{
361 GNUNET_CHAT_VERSION_ASSERT();
362
325 if (!lobby) 363 if (!lobby)
326 return; 364 return;
327 365
@@ -352,6 +390,8 @@ void
352GNUNET_CHAT_lobby_join (struct GNUNET_CHAT_Handle *handle, 390GNUNET_CHAT_lobby_join (struct GNUNET_CHAT_Handle *handle,
353 const struct GNUNET_CHAT_Uri *uri) 391 const struct GNUNET_CHAT_Uri *uri)
354{ 392{
393 GNUNET_CHAT_VERSION_ASSERT();
394
355 if ((!handle) || (!uri) || (!(handle->gns))) 395 if ((!handle) || (!uri) || (!(handle->gns)))
356 return; 396 return;
357 397
@@ -384,6 +424,8 @@ void
384GNUNET_CHAT_set_user_pointer (struct GNUNET_CHAT_Handle *handle, 424GNUNET_CHAT_set_user_pointer (struct GNUNET_CHAT_Handle *handle,
385 void *user_pointer) 425 void *user_pointer)
386{ 426{
427 GNUNET_CHAT_VERSION_ASSERT();
428
387 if (!handle) 429 if (!handle)
388 return; 430 return;
389 431
@@ -394,6 +436,8 @@ GNUNET_CHAT_set_user_pointer (struct GNUNET_CHAT_Handle *handle,
394void* 436void*
395GNUNET_CHAT_get_user_pointer (const struct GNUNET_CHAT_Handle *handle) 437GNUNET_CHAT_get_user_pointer (const struct GNUNET_CHAT_Handle *handle)
396{ 438{
439 GNUNET_CHAT_VERSION_ASSERT();
440
397 if (!handle) 441 if (!handle)
398 return NULL; 442 return NULL;
399 443
@@ -406,6 +450,8 @@ GNUNET_CHAT_iterate_contacts (struct GNUNET_CHAT_Handle *handle,
406 GNUNET_CHAT_ContactCallback callback, 450 GNUNET_CHAT_ContactCallback callback,
407 void *cls) 451 void *cls)
408{ 452{
453 GNUNET_CHAT_VERSION_ASSERT();
454
409 if ((!handle) || (!(handle->contacts))) 455 if ((!handle) || (!(handle->contacts)))
410 return GNUNET_SYSERR; 456 return GNUNET_SYSERR;
411 457
@@ -423,6 +469,8 @@ GNUNET_CHAT_iterate_contacts (struct GNUNET_CHAT_Handle *handle,
423const char* 469const char*
424GNUNET_CHAT_account_get_name (const struct GNUNET_CHAT_Account *account) 470GNUNET_CHAT_account_get_name (const struct GNUNET_CHAT_Account *account)
425{ 471{
472 GNUNET_CHAT_VERSION_ASSERT();
473
426 if (!account) 474 if (!account)
427 return NULL; 475 return NULL;
428 476
@@ -434,6 +482,8 @@ void
434GNUNET_CHAT_account_set_user_pointer (struct GNUNET_CHAT_Account *account, 482GNUNET_CHAT_account_set_user_pointer (struct GNUNET_CHAT_Account *account,
435 void *user_pointer) 483 void *user_pointer)
436{ 484{
485 GNUNET_CHAT_VERSION_ASSERT();
486
437 if (!account) 487 if (!account)
438 return; 488 return;
439 489
@@ -444,6 +494,8 @@ GNUNET_CHAT_account_set_user_pointer (struct GNUNET_CHAT_Account *account,
444void* 494void*
445GNUNET_CHAT_account_get_user_pointer (const struct GNUNET_CHAT_Account *account) 495GNUNET_CHAT_account_get_user_pointer (const struct GNUNET_CHAT_Account *account)
446{ 496{
497 GNUNET_CHAT_VERSION_ASSERT();
498
447 if (!account) 499 if (!account)
448 return NULL; 500 return NULL;
449 501
@@ -455,6 +507,8 @@ struct GNUNET_CHAT_Group *
455GNUNET_CHAT_group_create (struct GNUNET_CHAT_Handle *handle, 507GNUNET_CHAT_group_create (struct GNUNET_CHAT_Handle *handle,
456 const char* topic) 508 const char* topic)
457{ 509{
510 GNUNET_CHAT_VERSION_ASSERT();
511
458 if ((!handle) || (!(handle->groups)) || (!(handle->contexts))) 512 if ((!handle) || (!(handle->groups)) || (!(handle->contexts)))
459 return NULL; 513 return NULL;
460 514
@@ -517,6 +571,8 @@ GNUNET_CHAT_iterate_groups (struct GNUNET_CHAT_Handle *handle,
517 GNUNET_CHAT_GroupCallback callback, 571 GNUNET_CHAT_GroupCallback callback,
518 void *cls) 572 void *cls)
519{ 573{
574 GNUNET_CHAT_VERSION_ASSERT();
575
520 if ((!handle) || (!(handle->groups))) 576 if ((!handle) || (!(handle->groups)))
521 return GNUNET_SYSERR; 577 return GNUNET_SYSERR;
522 578
@@ -534,6 +590,8 @@ GNUNET_CHAT_iterate_groups (struct GNUNET_CHAT_Handle *handle,
534int 590int
535GNUNET_CHAT_contact_delete (struct GNUNET_CHAT_Contact *contact) 591GNUNET_CHAT_contact_delete (struct GNUNET_CHAT_Contact *contact)
536{ 592{
593 GNUNET_CHAT_VERSION_ASSERT();
594
537 if (!contact) 595 if (!contact)
538 return GNUNET_SYSERR; 596 return GNUNET_SYSERR;
539 597
@@ -567,6 +625,8 @@ void
567GNUNET_CHAT_contact_set_name (struct GNUNET_CHAT_Contact *contact, 625GNUNET_CHAT_contact_set_name (struct GNUNET_CHAT_Contact *contact,
568 const char *name) 626 const char *name)
569{ 627{
628 GNUNET_CHAT_VERSION_ASSERT();
629
570 if ((!contact) || (!(contact->context))) 630 if ((!contact) || (!(contact->context)))
571 return; 631 return;
572 632
@@ -580,6 +640,8 @@ GNUNET_CHAT_contact_set_name (struct GNUNET_CHAT_Contact *contact,
580const char* 640const char*
581GNUNET_CHAT_contact_get_name (const struct GNUNET_CHAT_Contact *contact) 641GNUNET_CHAT_contact_get_name (const struct GNUNET_CHAT_Contact *contact)
582{ 642{
643 GNUNET_CHAT_VERSION_ASSERT();
644
583 if (!contact) 645 if (!contact)
584 return NULL; 646 return NULL;
585 647
@@ -593,6 +655,8 @@ GNUNET_CHAT_contact_get_name (const struct GNUNET_CHAT_Contact *contact)
593const char* 655const char*
594GNUNET_CHAT_contact_get_key (const struct GNUNET_CHAT_Contact *contact) 656GNUNET_CHAT_contact_get_key (const struct GNUNET_CHAT_Contact *contact)
595{ 657{
658 GNUNET_CHAT_VERSION_ASSERT();
659
596 if (!contact) 660 if (!contact)
597 return NULL; 661 return NULL;
598 662
@@ -603,6 +667,8 @@ GNUNET_CHAT_contact_get_key (const struct GNUNET_CHAT_Contact *contact)
603struct GNUNET_CHAT_Context* 667struct GNUNET_CHAT_Context*
604GNUNET_CHAT_contact_get_context (struct GNUNET_CHAT_Contact *contact) 668GNUNET_CHAT_contact_get_context (struct GNUNET_CHAT_Contact *contact)
605{ 669{
670 GNUNET_CHAT_VERSION_ASSERT();
671
606 if (!contact) 672 if (!contact)
607 return NULL; 673 return NULL;
608 674
@@ -627,6 +693,8 @@ void
627GNUNET_CHAT_contact_set_user_pointer (struct GNUNET_CHAT_Contact *contact, 693GNUNET_CHAT_contact_set_user_pointer (struct GNUNET_CHAT_Contact *contact,
628 void *user_pointer) 694 void *user_pointer)
629{ 695{
696 GNUNET_CHAT_VERSION_ASSERT();
697
630 if (!contact) 698 if (!contact)
631 return; 699 return;
632 700
@@ -637,6 +705,8 @@ GNUNET_CHAT_contact_set_user_pointer (struct GNUNET_CHAT_Contact *contact,
637void* 705void*
638GNUNET_CHAT_contact_get_user_pointer (const struct GNUNET_CHAT_Contact *contact) 706GNUNET_CHAT_contact_get_user_pointer (const struct GNUNET_CHAT_Contact *contact)
639{ 707{
708 GNUNET_CHAT_VERSION_ASSERT();
709
640 if (!contact) 710 if (!contact)
641 return NULL; 711 return NULL;
642 712
@@ -647,6 +717,8 @@ GNUNET_CHAT_contact_get_user_pointer (const struct GNUNET_CHAT_Contact *contact)
647int 717int
648GNUNET_CHAT_contact_is_owned (const struct GNUNET_CHAT_Contact *contact) 718GNUNET_CHAT_contact_is_owned (const struct GNUNET_CHAT_Contact *contact)
649{ 719{
720 GNUNET_CHAT_VERSION_ASSERT();
721
650 if (!contact) 722 if (!contact)
651 return GNUNET_SYSERR; 723 return GNUNET_SYSERR;
652 724
@@ -657,6 +729,8 @@ GNUNET_CHAT_contact_is_owned (const struct GNUNET_CHAT_Contact *contact)
657int 729int
658GNUNET_CHAT_group_leave (struct GNUNET_CHAT_Group *group) 730GNUNET_CHAT_group_leave (struct GNUNET_CHAT_Group *group)
659{ 731{
732 GNUNET_CHAT_VERSION_ASSERT();
733
660 if (!group) 734 if (!group)
661 return GNUNET_SYSERR; 735 return GNUNET_SYSERR;
662 736
@@ -687,6 +761,8 @@ void
687GNUNET_CHAT_group_set_name (struct GNUNET_CHAT_Group *group, 761GNUNET_CHAT_group_set_name (struct GNUNET_CHAT_Group *group,
688 const char *name) 762 const char *name)
689{ 763{
764 GNUNET_CHAT_VERSION_ASSERT();
765
690 if ((!group) || (!(group->context))) 766 if ((!group) || (!(group->context)))
691 return; 767 return;
692 768
@@ -700,6 +776,8 @@ GNUNET_CHAT_group_set_name (struct GNUNET_CHAT_Group *group,
700const char* 776const char*
701GNUNET_CHAT_group_get_name (const struct GNUNET_CHAT_Group *group) 777GNUNET_CHAT_group_get_name (const struct GNUNET_CHAT_Group *group)
702{ 778{
779 GNUNET_CHAT_VERSION_ASSERT();
780
703 if ((!group) || (!(group->context))) 781 if ((!group) || (!(group->context)))
704 return NULL; 782 return NULL;
705 783
@@ -714,6 +792,8 @@ void
714GNUNET_CHAT_group_set_user_pointer (struct GNUNET_CHAT_Group *group, 792GNUNET_CHAT_group_set_user_pointer (struct GNUNET_CHAT_Group *group,
715 void *user_pointer) 793 void *user_pointer)
716{ 794{
795 GNUNET_CHAT_VERSION_ASSERT();
796
717 if (!group) 797 if (!group)
718 return; 798 return;
719 799
@@ -724,6 +804,8 @@ GNUNET_CHAT_group_set_user_pointer (struct GNUNET_CHAT_Group *group,
724void* 804void*
725GNUNET_CHAT_group_get_user_pointer (const struct GNUNET_CHAT_Group *group) 805GNUNET_CHAT_group_get_user_pointer (const struct GNUNET_CHAT_Group *group)
726{ 806{
807 GNUNET_CHAT_VERSION_ASSERT();
808
727 if (!group) 809 if (!group)
728 return NULL; 810 return NULL;
729 811
@@ -735,6 +817,8 @@ void
735GNUNET_CHAT_group_invite_contact (const struct GNUNET_CHAT_Group *group, 817GNUNET_CHAT_group_invite_contact (const struct GNUNET_CHAT_Group *group,
736 struct GNUNET_CHAT_Contact *contact) 818 struct GNUNET_CHAT_Contact *contact)
737{ 819{
820 GNUNET_CHAT_VERSION_ASSERT();
821
738 if ((!group) || (!contact)) 822 if ((!group) || (!contact))
739 return; 823 return;
740 824
@@ -765,6 +849,8 @@ GNUNET_CHAT_group_iterate_contacts (const struct GNUNET_CHAT_Group *group,
765 GNUNET_CHAT_GroupContactCallback callback, 849 GNUNET_CHAT_GroupContactCallback callback,
766 void *cls) 850 void *cls)
767{ 851{
852 GNUNET_CHAT_VERSION_ASSERT();
853
768 if (!group) 854 if (!group)
769 return GNUNET_SYSERR; 855 return GNUNET_SYSERR;
770 856
@@ -782,6 +868,8 @@ GNUNET_CHAT_group_iterate_contacts (const struct GNUNET_CHAT_Group *group,
782struct GNUNET_CHAT_Context* 868struct GNUNET_CHAT_Context*
783GNUNET_CHAT_group_get_context (struct GNUNET_CHAT_Group *group) 869GNUNET_CHAT_group_get_context (struct GNUNET_CHAT_Group *group)
784{ 870{
871 GNUNET_CHAT_VERSION_ASSERT();
872
785 if (!group) 873 if (!group)
786 return NULL; 874 return NULL;
787 875
@@ -792,6 +880,8 @@ GNUNET_CHAT_group_get_context (struct GNUNET_CHAT_Group *group)
792int 880int
793GNUNET_CHAT_context_get_status (const struct GNUNET_CHAT_Context *context) 881GNUNET_CHAT_context_get_status (const struct GNUNET_CHAT_Context *context)
794{ 882{
883 GNUNET_CHAT_VERSION_ASSERT();
884
795 if ((!context) || (!(context->room))) 885 if ((!context) || (!(context->room)))
796 return GNUNET_SYSERR; 886 return GNUNET_SYSERR;
797 887
@@ -806,6 +896,8 @@ GNUNET_CHAT_context_get_status (const struct GNUNET_CHAT_Context *context)
806void 896void
807GNUNET_CHAT_context_request (struct GNUNET_CHAT_Context *context) 897GNUNET_CHAT_context_request (struct GNUNET_CHAT_Context *context)
808{ 898{
899 GNUNET_CHAT_VERSION_ASSERT();
900
809 if ((!context) || (context->room)) 901 if ((!context) || (context->room))
810 return; 902 return;
811 903
@@ -857,6 +949,8 @@ GNUNET_CHAT_context_request (struct GNUNET_CHAT_Context *context)
857struct GNUNET_CHAT_Contact* 949struct GNUNET_CHAT_Contact*
858GNUNET_CHAT_context_get_contact (struct GNUNET_CHAT_Context *context) 950GNUNET_CHAT_context_get_contact (struct GNUNET_CHAT_Context *context)
859{ 951{
952 GNUNET_CHAT_VERSION_ASSERT();
953
860 if ((!context) || (GNUNET_CHAT_CONTEXT_TYPE_CONTACT != context->type)) 954 if ((!context) || (GNUNET_CHAT_CONTEXT_TYPE_CONTACT != context->type))
861 return NULL; 955 return NULL;
862 956
@@ -885,6 +979,8 @@ GNUNET_CHAT_context_get_contact (struct GNUNET_CHAT_Context *context)
885struct GNUNET_CHAT_Group* 979struct GNUNET_CHAT_Group*
886GNUNET_CHAT_context_get_group (struct GNUNET_CHAT_Context *context) 980GNUNET_CHAT_context_get_group (struct GNUNET_CHAT_Context *context)
887{ 981{
982 GNUNET_CHAT_VERSION_ASSERT();
983
888 if ((!context) || (GNUNET_CHAT_CONTEXT_TYPE_GROUP != context->type)) 984 if ((!context) || (GNUNET_CHAT_CONTEXT_TYPE_GROUP != context->type))
889 return NULL; 985 return NULL;
890 986
@@ -899,6 +995,8 @@ void
899GNUNET_CHAT_context_set_user_pointer (struct GNUNET_CHAT_Context *context, 995GNUNET_CHAT_context_set_user_pointer (struct GNUNET_CHAT_Context *context,
900 void *user_pointer) 996 void *user_pointer)
901{ 997{
998 GNUNET_CHAT_VERSION_ASSERT();
999
902 if (!context) 1000 if (!context)
903 return; 1001 return;
904 1002
@@ -909,6 +1007,8 @@ GNUNET_CHAT_context_set_user_pointer (struct GNUNET_CHAT_Context *context,
909void* 1007void*
910GNUNET_CHAT_context_get_user_pointer (const struct GNUNET_CHAT_Context *context) 1008GNUNET_CHAT_context_get_user_pointer (const struct GNUNET_CHAT_Context *context)
911{ 1009{
1010 GNUNET_CHAT_VERSION_ASSERT();
1011
912 if (!context) 1012 if (!context)
913 return NULL; 1013 return NULL;
914 1014
@@ -920,6 +1020,8 @@ int
920GNUNET_CHAT_context_send_text (struct GNUNET_CHAT_Context *context, 1020GNUNET_CHAT_context_send_text (struct GNUNET_CHAT_Context *context,
921 const char *text) 1021 const char *text)
922{ 1022{
1023 GNUNET_CHAT_VERSION_ASSERT();
1024
923 if ((!context) || (!text) || (!(context->room))) 1025 if ((!context) || (!text) || (!(context->room)))
924 return GNUNET_SYSERR; 1026 return GNUNET_SYSERR;
925 1027
@@ -938,6 +1040,8 @@ int
938GNUNET_CHAT_context_send_read_receipt (struct GNUNET_CHAT_Context *context, 1040GNUNET_CHAT_context_send_read_receipt (struct GNUNET_CHAT_Context *context,
939 const struct GNUNET_CHAT_Message *message) 1041 const struct GNUNET_CHAT_Message *message)
940{ 1042{
1043 GNUNET_CHAT_VERSION_ASSERT();
1044
941 if ((!context) || (!(context->room))) 1045 if ((!context) || (!(context->room)))
942 return GNUNET_SYSERR; 1046 return GNUNET_SYSERR;
943 1047
@@ -985,6 +1089,8 @@ GNUNET_CHAT_context_send_file (struct GNUNET_CHAT_Context *context,
985 GNUNET_CHAT_FileUploadCallback callback, 1089 GNUNET_CHAT_FileUploadCallback callback,
986 void *cls) 1090 void *cls)
987{ 1091{
1092 GNUNET_CHAT_VERSION_ASSERT();
1093
988 if ((!context) || (!path) || (!(context->room))) 1094 if ((!context) || (!path) || (!(context->room)))
989 return NULL; 1095 return NULL;
990 1096
@@ -1091,6 +1197,8 @@ int
1091GNUNET_CHAT_context_share_file (struct GNUNET_CHAT_Context *context, 1197GNUNET_CHAT_context_share_file (struct GNUNET_CHAT_Context *context,
1092 const struct GNUNET_CHAT_File *file) 1198 const struct GNUNET_CHAT_File *file)
1093{ 1199{
1200 GNUNET_CHAT_VERSION_ASSERT();
1201
1094 if ((!context) || (!file) || (strlen(file->name) > NAME_MAX) || 1202 if ((!context) || (!file) || (strlen(file->name) > NAME_MAX) ||
1095 (!(context->room))) 1203 (!(context->room)))
1096 return GNUNET_SYSERR; 1204 return GNUNET_SYSERR;
@@ -1114,6 +1222,8 @@ GNUNET_CHAT_context_iterate_messages (struct GNUNET_CHAT_Context *context,
1114 GNUNET_CHAT_ContextMessageCallback callback, 1222 GNUNET_CHAT_ContextMessageCallback callback,
1115 void *cls) 1223 void *cls)
1116{ 1224{
1225 GNUNET_CHAT_VERSION_ASSERT();
1226
1117 if (!context) 1227 if (!context)
1118 return GNUNET_SYSERR; 1228 return GNUNET_SYSERR;
1119 1229
@@ -1133,6 +1243,8 @@ GNUNET_CHAT_context_iterate_files (struct GNUNET_CHAT_Context *context,
1133 GNUNET_CHAT_ContextFileCallback callback, 1243 GNUNET_CHAT_ContextFileCallback callback,
1134 void *cls) 1244 void *cls)
1135{ 1245{
1246 GNUNET_CHAT_VERSION_ASSERT();
1247
1136 if (!context) 1248 if (!context)
1137 return GNUNET_SYSERR; 1249 return GNUNET_SYSERR;
1138 1250
@@ -1152,6 +1264,8 @@ GNUNET_CHAT_member_set_user_pointer (struct GNUNET_CHAT_Context *context,
1152 const struct GNUNET_CHAT_Contact *member, 1264 const struct GNUNET_CHAT_Contact *member,
1153 void *user_pointer) 1265 void *user_pointer)
1154{ 1266{
1267 GNUNET_CHAT_VERSION_ASSERT();
1268
1155 if ((!context) || (!member)) 1269 if ((!context) || (!member))
1156 return; 1270 return;
1157 1271
@@ -1171,6 +1285,8 @@ void*
1171GNUNET_CHAT_member_get_user_pointer (const struct GNUNET_CHAT_Context *context, 1285GNUNET_CHAT_member_get_user_pointer (const struct GNUNET_CHAT_Context *context,
1172 const struct GNUNET_CHAT_Contact *member) 1286 const struct GNUNET_CHAT_Contact *member)
1173{ 1287{
1288 GNUNET_CHAT_VERSION_ASSERT();
1289
1174 if ((!context) || (!member)) 1290 if ((!context) || (!member))
1175 return NULL; 1291 return NULL;
1176 1292
@@ -1187,6 +1303,8 @@ GNUNET_CHAT_member_get_user_pointer (const struct GNUNET_CHAT_Context *context,
1187enum GNUNET_CHAT_MessageKind 1303enum GNUNET_CHAT_MessageKind
1188GNUNET_CHAT_message_get_kind (const struct GNUNET_CHAT_Message *message) 1304GNUNET_CHAT_message_get_kind (const struct GNUNET_CHAT_Message *message)
1189{ 1305{
1306 GNUNET_CHAT_VERSION_ASSERT();
1307
1190 if (!message) 1308 if (!message)
1191 return GNUNET_CHAT_KIND_UNKNOWN; 1309 return GNUNET_CHAT_KIND_UNKNOWN;
1192 1310
@@ -1236,6 +1354,8 @@ GNUNET_CHAT_message_get_kind (const struct GNUNET_CHAT_Message *message)
1236struct GNUNET_TIME_Absolute 1354struct GNUNET_TIME_Absolute
1237GNUNET_CHAT_message_get_timestamp (const struct GNUNET_CHAT_Message *message) 1355GNUNET_CHAT_message_get_timestamp (const struct GNUNET_CHAT_Message *message)
1238{ 1356{
1357 GNUNET_CHAT_VERSION_ASSERT();
1358
1239 if ((!message) || (!(message->msg))) 1359 if ((!message) || (!(message->msg)))
1240 return GNUNET_TIME_absolute_get_zero_(); 1360 return GNUNET_TIME_absolute_get_zero_();
1241 1361
@@ -1246,6 +1366,8 @@ GNUNET_CHAT_message_get_timestamp (const struct GNUNET_CHAT_Message *message)
1246struct GNUNET_CHAT_Contact* 1366struct GNUNET_CHAT_Contact*
1247GNUNET_CHAT_message_get_sender (const struct GNUNET_CHAT_Message *message) 1367GNUNET_CHAT_message_get_sender (const struct GNUNET_CHAT_Message *message)
1248{ 1368{
1369 GNUNET_CHAT_VERSION_ASSERT();
1370
1249 if ((!message) || (GNUNET_CHAT_FLAG_NONE != message->flag) || 1371 if ((!message) || (GNUNET_CHAT_FLAG_NONE != message->flag) ||
1250 (!(message->context)) || (!(message->context->room))) 1372 (!(message->context)) || (!(message->context->room)))
1251 return NULL; 1373 return NULL;
@@ -1264,6 +1386,8 @@ GNUNET_CHAT_message_get_sender (const struct GNUNET_CHAT_Message *message)
1264int 1386int
1265GNUNET_CHAT_message_is_sent (const struct GNUNET_CHAT_Message *message) 1387GNUNET_CHAT_message_is_sent (const struct GNUNET_CHAT_Message *message)
1266{ 1388{
1389 GNUNET_CHAT_VERSION_ASSERT();
1390
1267 if (!message) 1391 if (!message)
1268 return GNUNET_SYSERR; 1392 return GNUNET_SYSERR;
1269 1393
@@ -1277,6 +1401,8 @@ GNUNET_CHAT_message_is_sent (const struct GNUNET_CHAT_Message *message)
1277int 1401int
1278GNUNET_CHAT_message_is_private (const struct GNUNET_CHAT_Message *message) 1402GNUNET_CHAT_message_is_private (const struct GNUNET_CHAT_Message *message)
1279{ 1403{
1404 GNUNET_CHAT_VERSION_ASSERT();
1405
1280 if (!message) 1406 if (!message)
1281 return GNUNET_SYSERR; 1407 return GNUNET_SYSERR;
1282 1408
@@ -1292,6 +1418,8 @@ GNUNET_CHAT_message_get_read_receipt (const struct GNUNET_CHAT_Message *message,
1292 GNUNET_CHAT_MessageReadReceiptCallback callback, 1418 GNUNET_CHAT_MessageReadReceiptCallback callback,
1293 void *cls) 1419 void *cls)
1294{ 1420{
1421 GNUNET_CHAT_VERSION_ASSERT();
1422
1295 if ((!message) || (!(message->msg)) || (!(message->context))) 1423 if ((!message) || (!(message->msg)) || (!(message->context)))
1296 return GNUNET_SYSERR; 1424 return GNUNET_SYSERR;
1297 1425
@@ -1309,6 +1437,8 @@ GNUNET_CHAT_message_get_read_receipt (const struct GNUNET_CHAT_Message *message,
1309const char* 1437const char*
1310GNUNET_CHAT_message_get_text (const struct GNUNET_CHAT_Message *message) 1438GNUNET_CHAT_message_get_text (const struct GNUNET_CHAT_Message *message)
1311{ 1439{
1440 GNUNET_CHAT_VERSION_ASSERT();
1441
1312 if ((!message) || (!(message->msg))) 1442 if ((!message) || (!(message->msg)))
1313 return NULL; 1443 return NULL;
1314 1444
@@ -1326,6 +1456,8 @@ GNUNET_CHAT_message_get_text (const struct GNUNET_CHAT_Message *message)
1326struct GNUNET_CHAT_File* 1456struct GNUNET_CHAT_File*
1327GNUNET_CHAT_message_get_file (const struct GNUNET_CHAT_Message *message) 1457GNUNET_CHAT_message_get_file (const struct GNUNET_CHAT_Message *message)
1328{ 1458{
1459 GNUNET_CHAT_VERSION_ASSERT();
1460
1329 if ((!message) || (!(message->msg)) || (!(message->context))) 1461 if ((!message) || (!(message->msg)) || (!(message->context)))
1330 return NULL; 1462 return NULL;
1331 1463
@@ -1342,6 +1474,8 @@ GNUNET_CHAT_message_get_file (const struct GNUNET_CHAT_Message *message)
1342struct GNUNET_CHAT_Invitation* 1474struct GNUNET_CHAT_Invitation*
1343GNUNET_CHAT_message_get_invitation (const struct GNUNET_CHAT_Message *message) 1475GNUNET_CHAT_message_get_invitation (const struct GNUNET_CHAT_Message *message)
1344{ 1476{
1477 GNUNET_CHAT_VERSION_ASSERT();
1478
1345 if ((!message) || (!(message->msg)) || (!(message->context))) 1479 if ((!message) || (!(message->msg)) || (!(message->context)))
1346 return NULL; 1480 return NULL;
1347 1481
@@ -1358,6 +1492,8 @@ GNUNET_CHAT_message_get_invitation (const struct GNUNET_CHAT_Message *message)
1358const struct GNUNET_CHAT_Message* 1492const struct GNUNET_CHAT_Message*
1359GNUNET_CHAT_message_get_target (const struct GNUNET_CHAT_Message *message) 1493GNUNET_CHAT_message_get_target (const struct GNUNET_CHAT_Message *message)
1360{ 1494{
1495 GNUNET_CHAT_VERSION_ASSERT();
1496
1361 if ((!message) || (!(message->msg)) || (!(message->context))) 1497 if ((!message) || (!(message->msg)) || (!(message->context)))
1362 return NULL; 1498 return NULL;
1363 1499
@@ -1378,6 +1514,8 @@ int
1378GNUNET_CHAT_message_delete (const struct GNUNET_CHAT_Message *message, 1514GNUNET_CHAT_message_delete (const struct GNUNET_CHAT_Message *message,
1379 struct GNUNET_TIME_Relative delay) 1515 struct GNUNET_TIME_Relative delay)
1380{ 1516{
1517 GNUNET_CHAT_VERSION_ASSERT();
1518
1381 if ((!message) || (!(message->msg)) || (!(message->context))) 1519 if ((!message) || (!(message->msg)) || (!(message->context)))
1382 return GNUNET_SYSERR; 1520 return GNUNET_SYSERR;
1383 1521
@@ -1394,6 +1532,8 @@ GNUNET_CHAT_message_delete (const struct GNUNET_CHAT_Message *message,
1394const char* 1532const char*
1395GNUNET_CHAT_file_get_name (const struct GNUNET_CHAT_File *file) 1533GNUNET_CHAT_file_get_name (const struct GNUNET_CHAT_File *file)
1396{ 1534{
1535 GNUNET_CHAT_VERSION_ASSERT();
1536
1397 if (!file) 1537 if (!file)
1398 return NULL; 1538 return NULL;
1399 1539
@@ -1404,6 +1544,8 @@ GNUNET_CHAT_file_get_name (const struct GNUNET_CHAT_File *file)
1404const struct GNUNET_HashCode* 1544const struct GNUNET_HashCode*
1405GNUNET_CHAT_file_get_hash (const struct GNUNET_CHAT_File *file) 1545GNUNET_CHAT_file_get_hash (const struct GNUNET_CHAT_File *file)
1406{ 1546{
1547 GNUNET_CHAT_VERSION_ASSERT();
1548
1407 if (!file) 1549 if (!file)
1408 return NULL; 1550 return NULL;
1409 1551
@@ -1414,6 +1556,8 @@ GNUNET_CHAT_file_get_hash (const struct GNUNET_CHAT_File *file)
1414uint64_t 1556uint64_t
1415GNUNET_CHAT_file_get_size (const struct GNUNET_CHAT_File *file) 1557GNUNET_CHAT_file_get_size (const struct GNUNET_CHAT_File *file)
1416{ 1558{
1559 GNUNET_CHAT_VERSION_ASSERT();
1560
1417 if ((!file) || (!(file->uri))) 1561 if ((!file) || (!(file->uri)))
1418 return 0; 1562 return 0;
1419 1563
@@ -1424,6 +1568,8 @@ GNUNET_CHAT_file_get_size (const struct GNUNET_CHAT_File *file)
1424uint64_t 1568uint64_t
1425GNUNET_CHAT_file_get_local_size (const struct GNUNET_CHAT_File *file) 1569GNUNET_CHAT_file_get_local_size (const struct GNUNET_CHAT_File *file)
1426{ 1570{
1571 GNUNET_CHAT_VERSION_ASSERT();
1572
1427 if (!file) 1573 if (!file)
1428 return 0; 1574 return 0;
1429 1575
@@ -1449,6 +1595,8 @@ GNUNET_CHAT_file_get_local_size (const struct GNUNET_CHAT_File *file)
1449int 1595int
1450GNUNET_CHAT_file_is_uploading (const struct GNUNET_CHAT_File *file) 1596GNUNET_CHAT_file_is_uploading (const struct GNUNET_CHAT_File *file)
1451{ 1597{
1598 GNUNET_CHAT_VERSION_ASSERT();
1599
1452 if ((!file) || (0 == (file->status & GNUNET_CHAT_FILE_STATUS_PUBLISH))) 1600 if ((!file) || (0 == (file->status & GNUNET_CHAT_FILE_STATUS_PUBLISH)))
1453 return GNUNET_NO; 1601 return GNUNET_NO;
1454 else 1602 else
@@ -1459,6 +1607,8 @@ GNUNET_CHAT_file_is_uploading (const struct GNUNET_CHAT_File *file)
1459const char* 1607const char*
1460GNUNET_CHAT_file_open_preview (struct GNUNET_CHAT_File *file) 1608GNUNET_CHAT_file_open_preview (struct GNUNET_CHAT_File *file)
1461{ 1609{
1610 GNUNET_CHAT_VERSION_ASSERT();
1611
1462 if (!file) 1612 if (!file)
1463 return NULL; 1613 return NULL;
1464 1614
@@ -1503,6 +1653,8 @@ free_filename:
1503void 1653void
1504GNUNET_CHAT_file_close_preview (struct GNUNET_CHAT_File *file) 1654GNUNET_CHAT_file_close_preview (struct GNUNET_CHAT_File *file)
1505{ 1655{
1656 GNUNET_CHAT_VERSION_ASSERT();
1657
1506 if ((!file) || (!(file->preview))) 1658 if ((!file) || (!(file->preview)))
1507 return; 1659 return;
1508 1660
@@ -1517,6 +1669,8 @@ void
1517GNUNET_CHAT_file_set_user_pointer (struct GNUNET_CHAT_File *file, 1669GNUNET_CHAT_file_set_user_pointer (struct GNUNET_CHAT_File *file,
1518 void *user_pointer) 1670 void *user_pointer)
1519{ 1671{
1672 GNUNET_CHAT_VERSION_ASSERT();
1673
1520 if (!file) 1674 if (!file)
1521 return; 1675 return;
1522 1676
@@ -1527,6 +1681,8 @@ GNUNET_CHAT_file_set_user_pointer (struct GNUNET_CHAT_File *file,
1527void* 1681void*
1528GNUNET_CHAT_file_get_user_pointer (const struct GNUNET_CHAT_File *file) 1682GNUNET_CHAT_file_get_user_pointer (const struct GNUNET_CHAT_File *file)
1529{ 1683{
1684 GNUNET_CHAT_VERSION_ASSERT();
1685
1530 if (!file) 1686 if (!file)
1531 return NULL; 1687 return NULL;
1532 1688
@@ -1537,6 +1693,8 @@ GNUNET_CHAT_file_get_user_pointer (const struct GNUNET_CHAT_File *file)
1537int 1693int
1538GNUNET_CHAT_file_is_downloading (const struct GNUNET_CHAT_File *file) 1694GNUNET_CHAT_file_is_downloading (const struct GNUNET_CHAT_File *file)
1539{ 1695{
1696 GNUNET_CHAT_VERSION_ASSERT();
1697
1540 if ((!file) || (0 == (file->status & GNUNET_CHAT_FILE_STATUS_DOWNLOAD))) 1698 if ((!file) || (0 == (file->status & GNUNET_CHAT_FILE_STATUS_DOWNLOAD)))
1541 return GNUNET_NO; 1699 return GNUNET_NO;
1542 else 1700 else
@@ -1549,6 +1707,8 @@ GNUNET_CHAT_file_start_download (struct GNUNET_CHAT_File *file,
1549 GNUNET_CHAT_FileDownloadCallback callback, 1707 GNUNET_CHAT_FileDownloadCallback callback,
1550 void *cls) 1708 void *cls)
1551{ 1709{
1710 GNUNET_CHAT_VERSION_ASSERT();
1711
1552 if ((!file) || (!(file->uri))) 1712 if ((!file) || (!(file->uri)))
1553 return GNUNET_SYSERR; 1713 return GNUNET_SYSERR;
1554 1714
@@ -1613,6 +1773,8 @@ GNUNET_CHAT_file_start_download (struct GNUNET_CHAT_File *file,
1613int 1773int
1614GNUNET_CHAT_file_pause_download (struct GNUNET_CHAT_File *file) 1774GNUNET_CHAT_file_pause_download (struct GNUNET_CHAT_File *file)
1615{ 1775{
1776 GNUNET_CHAT_VERSION_ASSERT();
1777
1616 if (!file) 1778 if (!file)
1617 return GNUNET_SYSERR; 1779 return GNUNET_SYSERR;
1618 1780
@@ -1624,6 +1786,8 @@ GNUNET_CHAT_file_pause_download (struct GNUNET_CHAT_File *file)
1624int 1786int
1625GNUNET_CHAT_file_resume_download (struct GNUNET_CHAT_File *file) 1787GNUNET_CHAT_file_resume_download (struct GNUNET_CHAT_File *file)
1626{ 1788{
1789 GNUNET_CHAT_VERSION_ASSERT();
1790
1627 if (!file) 1791 if (!file)
1628 return GNUNET_SYSERR; 1792 return GNUNET_SYSERR;
1629 1793
@@ -1635,6 +1799,8 @@ GNUNET_CHAT_file_resume_download (struct GNUNET_CHAT_File *file)
1635int 1799int
1636GNUNET_CHAT_file_stop_download (struct GNUNET_CHAT_File *file) 1800GNUNET_CHAT_file_stop_download (struct GNUNET_CHAT_File *file)
1637{ 1801{
1802 GNUNET_CHAT_VERSION_ASSERT();
1803
1638 if (!file) 1804 if (!file)
1639 return GNUNET_SYSERR; 1805 return GNUNET_SYSERR;
1640 1806
@@ -1647,6 +1813,8 @@ GNUNET_CHAT_file_stop_download (struct GNUNET_CHAT_File *file)
1647int 1813int
1648GNUNET_CHAT_file_is_unindexing (const struct GNUNET_CHAT_File *file) 1814GNUNET_CHAT_file_is_unindexing (const struct GNUNET_CHAT_File *file)
1649{ 1815{
1816 GNUNET_CHAT_VERSION_ASSERT();
1817
1650 if ((!file) || (0 == (file->status & GNUNET_CHAT_FILE_STATUS_UNINDEX))) 1818 if ((!file) || (0 == (file->status & GNUNET_CHAT_FILE_STATUS_UNINDEX)))
1651 return GNUNET_NO; 1819 return GNUNET_NO;
1652 else 1820 else
@@ -1659,6 +1827,8 @@ GNUNET_CHAT_file_unindex (struct GNUNET_CHAT_File *file,
1659 GNUNET_CHAT_FileUnindexCallback callback, 1827 GNUNET_CHAT_FileUnindexCallback callback,
1660 void *cls) 1828 void *cls)
1661{ 1829{
1830 GNUNET_CHAT_VERSION_ASSERT();
1831
1662 if (!file) 1832 if (!file)
1663 return GNUNET_SYSERR; 1833 return GNUNET_SYSERR;
1664 1834
@@ -1699,6 +1869,8 @@ GNUNET_CHAT_file_unindex (struct GNUNET_CHAT_File *file,
1699void 1869void
1700GNUNET_CHAT_invitation_accept (struct GNUNET_CHAT_Invitation *invitation) 1870GNUNET_CHAT_invitation_accept (struct GNUNET_CHAT_Invitation *invitation)
1701{ 1871{
1872 GNUNET_CHAT_VERSION_ASSERT();
1873
1702 if (!invitation) 1874 if (!invitation)
1703 return; 1875 return;
1704 1876