diff options
Diffstat (limited to 'src/gnunet_chat_lib.c')
-rw-r--r-- | src/gnunet_chat_lib.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c index 6739d15..c52ddf4 100644 --- a/src/gnunet_chat_lib.c +++ b/src/gnunet_chat_lib.c | |||
@@ -70,8 +70,11 @@ GNUNET_CHAT_stop (struct GNUNET_CHAT_Handle *handle) | |||
70 | if ((!handle) || (handle->destruction)) | 70 | if ((!handle) || (handle->destruction)) |
71 | return; | 71 | return; |
72 | 72 | ||
73 | handle->destruction = GNUNET_SCHEDULER_add_now( | 73 | handle->destruction = GNUNET_SCHEDULER_add_at_with_priority( |
74 | task_handle_destruction, handle | 74 | GNUNET_TIME_absolute_get(), |
75 | GNUNET_SCHEDULER_PRIORITY_IDLE, | ||
76 | task_handle_destruction, | ||
77 | handle | ||
75 | ); | 78 | ); |
76 | } | 79 | } |
77 | 80 | ||
@@ -82,7 +85,7 @@ GNUNET_CHAT_account_create (struct GNUNET_CHAT_Handle *handle, | |||
82 | { | 85 | { |
83 | GNUNET_CHAT_VERSION_ASSERT(); | 86 | GNUNET_CHAT_VERSION_ASSERT(); |
84 | 87 | ||
85 | if ((!handle) || (!name)) | 88 | if ((!handle) || (handle->destruction) || (!name)) |
86 | return GNUNET_SYSERR; | 89 | return GNUNET_SYSERR; |
87 | 90 | ||
88 | struct GNUNET_CHAT_InternalAccounts *accounts = handle->accounts_head; | 91 | struct GNUNET_CHAT_InternalAccounts *accounts = handle->accounts_head; |
@@ -134,7 +137,7 @@ GNUNET_CHAT_account_delete(struct GNUNET_CHAT_Handle *handle, | |||
134 | { | 137 | { |
135 | GNUNET_CHAT_VERSION_ASSERT(); | 138 | GNUNET_CHAT_VERSION_ASSERT(); |
136 | 139 | ||
137 | if ((!handle) || (!name)) | 140 | if ((!handle) || (handle->destruction) || (!name)) |
138 | return GNUNET_SYSERR; | 141 | return GNUNET_SYSERR; |
139 | 142 | ||
140 | struct GNUNET_CHAT_InternalAccounts *accounts = handle->accounts_head; | 143 | struct GNUNET_CHAT_InternalAccounts *accounts = handle->accounts_head; |
@@ -161,7 +164,7 @@ GNUNET_CHAT_account_delete(struct GNUNET_CHAT_Handle *handle, | |||
161 | handle->identity, | 164 | handle->identity, |
162 | name, | 165 | name, |
163 | cb_account_deletion, | 166 | cb_account_deletion, |
164 | accounts | 167 | handle |
165 | ); | 168 | ); |
166 | 169 | ||
167 | return (accounts->op? GNUNET_OK : GNUNET_SYSERR); | 170 | return (accounts->op? GNUNET_OK : GNUNET_SYSERR); |
@@ -175,7 +178,7 @@ GNUNET_CHAT_iterate_accounts (const struct GNUNET_CHAT_Handle *handle, | |||
175 | { | 178 | { |
176 | GNUNET_CHAT_VERSION_ASSERT(); | 179 | GNUNET_CHAT_VERSION_ASSERT(); |
177 | 180 | ||
178 | if (!handle) | 181 | if ((!handle) || (handle->destruction)) |
179 | return GNUNET_SYSERR; | 182 | return GNUNET_SYSERR; |
180 | 183 | ||
181 | int result = 0; | 184 | int result = 0; |
@@ -205,7 +208,7 @@ GNUNET_CHAT_connect (struct GNUNET_CHAT_Handle *handle, | |||
205 | { | 208 | { |
206 | GNUNET_CHAT_VERSION_ASSERT(); | 209 | GNUNET_CHAT_VERSION_ASSERT(); |
207 | 210 | ||
208 | if (!handle) | 211 | if ((!handle) || (handle->destruction)) |
209 | return; | 212 | return; |
210 | 213 | ||
211 | if (handle->current == account) | 214 | if (handle->current == account) |
@@ -226,7 +229,7 @@ GNUNET_CHAT_disconnect (struct GNUNET_CHAT_Handle *handle) | |||
226 | { | 229 | { |
227 | GNUNET_CHAT_VERSION_ASSERT(); | 230 | GNUNET_CHAT_VERSION_ASSERT(); |
228 | 231 | ||
229 | if ((!handle) || (!(handle->current))) | 232 | if ((!handle) || (handle->destruction) || (!(handle->current))) |
230 | return; | 233 | return; |
231 | 234 | ||
232 | handle_disconnect(handle); | 235 | handle_disconnect(handle); |
@@ -238,7 +241,7 @@ GNUNET_CHAT_get_connected (const struct GNUNET_CHAT_Handle *handle) | |||
238 | { | 241 | { |
239 | GNUNET_CHAT_VERSION_ASSERT(); | 242 | GNUNET_CHAT_VERSION_ASSERT(); |
240 | 243 | ||
241 | if (!handle) | 244 | if ((!handle) || (handle->destruction)) |
242 | return NULL; | 245 | return NULL; |
243 | 246 | ||
244 | return handle->current; | 247 | return handle->current; |
@@ -250,7 +253,7 @@ GNUNET_CHAT_update (struct GNUNET_CHAT_Handle *handle) | |||
250 | { | 253 | { |
251 | GNUNET_CHAT_VERSION_ASSERT(); | 254 | GNUNET_CHAT_VERSION_ASSERT(); |
252 | 255 | ||
253 | if (!handle) | 256 | if ((!handle) || (handle->destruction)) |
254 | return GNUNET_SYSERR; | 257 | return GNUNET_SYSERR; |
255 | 258 | ||
256 | return GNUNET_MESSENGER_update(handle->messenger); | 259 | return GNUNET_MESSENGER_update(handle->messenger); |
@@ -263,7 +266,7 @@ GNUNET_CHAT_set_name (struct GNUNET_CHAT_Handle *handle, | |||
263 | { | 266 | { |
264 | GNUNET_CHAT_VERSION_ASSERT(); | 267 | GNUNET_CHAT_VERSION_ASSERT(); |
265 | 268 | ||
266 | if (!handle) | 269 | if ((!handle) || (handle->destruction)) |
267 | return GNUNET_SYSERR; | 270 | return GNUNET_SYSERR; |
268 | 271 | ||
269 | if (!name) | 272 | if (!name) |
@@ -278,7 +281,7 @@ GNUNET_CHAT_get_name (const struct GNUNET_CHAT_Handle *handle) | |||
278 | { | 281 | { |
279 | GNUNET_CHAT_VERSION_ASSERT(); | 282 | GNUNET_CHAT_VERSION_ASSERT(); |
280 | 283 | ||
281 | if (!handle) | 284 | if ((!handle) || (handle->destruction)) |
282 | return NULL; | 285 | return NULL; |
283 | 286 | ||
284 | return GNUNET_MESSENGER_get_name(handle->messenger); | 287 | return GNUNET_MESSENGER_get_name(handle->messenger); |
@@ -290,7 +293,7 @@ GNUNET_CHAT_get_key (const struct GNUNET_CHAT_Handle *handle) | |||
290 | { | 293 | { |
291 | GNUNET_CHAT_VERSION_ASSERT(); | 294 | GNUNET_CHAT_VERSION_ASSERT(); |
292 | 295 | ||
293 | if (!handle) | 296 | if ((!handle) || (handle->destruction)) |
294 | return NULL; | 297 | return NULL; |
295 | 298 | ||
296 | return handle->public_key; | 299 | return handle->public_key; |
@@ -390,7 +393,7 @@ GNUNET_CHAT_lobby_open (struct GNUNET_CHAT_Handle *handle, | |||
390 | { | 393 | { |
391 | GNUNET_CHAT_VERSION_ASSERT(); | 394 | GNUNET_CHAT_VERSION_ASSERT(); |
392 | 395 | ||
393 | if (!handle) | 396 | if ((!handle) || (handle->destruction)) |
394 | return NULL; | 397 | return NULL; |
395 | 398 | ||
396 | struct GNUNET_CHAT_InternalLobbies *lobbies = GNUNET_new( | 399 | struct GNUNET_CHAT_InternalLobbies *lobbies = GNUNET_new( |
@@ -448,7 +451,7 @@ GNUNET_CHAT_lobby_join (struct GNUNET_CHAT_Handle *handle, | |||
448 | { | 451 | { |
449 | GNUNET_CHAT_VERSION_ASSERT(); | 452 | GNUNET_CHAT_VERSION_ASSERT(); |
450 | 453 | ||
451 | if ((!handle) || (!uri) || (!(handle->gns))) | 454 | if ((!handle) || (handle->destruction) || (!uri) || (!(handle->gns))) |
452 | return; | 455 | return; |
453 | 456 | ||
454 | struct GNUNET_CHAT_UriLookups *lookups = GNUNET_new( | 457 | struct GNUNET_CHAT_UriLookups *lookups = GNUNET_new( |
@@ -482,7 +485,7 @@ GNUNET_CHAT_set_user_pointer (struct GNUNET_CHAT_Handle *handle, | |||
482 | { | 485 | { |
483 | GNUNET_CHAT_VERSION_ASSERT(); | 486 | GNUNET_CHAT_VERSION_ASSERT(); |
484 | 487 | ||
485 | if (!handle) | 488 | if ((!handle) || (handle->destruction)) |
486 | return; | 489 | return; |
487 | 490 | ||
488 | handle->user_pointer = user_pointer; | 491 | handle->user_pointer = user_pointer; |
@@ -494,7 +497,7 @@ GNUNET_CHAT_get_user_pointer (const struct GNUNET_CHAT_Handle *handle) | |||
494 | { | 497 | { |
495 | GNUNET_CHAT_VERSION_ASSERT(); | 498 | GNUNET_CHAT_VERSION_ASSERT(); |
496 | 499 | ||
497 | if (!handle) | 500 | if ((!handle) || (handle->destruction)) |
498 | return NULL; | 501 | return NULL; |
499 | 502 | ||
500 | return handle->user_pointer; | 503 | return handle->user_pointer; |
@@ -508,7 +511,7 @@ GNUNET_CHAT_iterate_contacts (struct GNUNET_CHAT_Handle *handle, | |||
508 | { | 511 | { |
509 | GNUNET_CHAT_VERSION_ASSERT(); | 512 | GNUNET_CHAT_VERSION_ASSERT(); |
510 | 513 | ||
511 | if ((!handle) || (!(handle->contacts))) | 514 | if ((!handle) || (handle->destruction) || (!(handle->contacts))) |
512 | return GNUNET_SYSERR; | 515 | return GNUNET_SYSERR; |
513 | 516 | ||
514 | struct GNUNET_CHAT_HandleIterateContacts it; | 517 | struct GNUNET_CHAT_HandleIterateContacts it; |
@@ -565,7 +568,8 @@ GNUNET_CHAT_group_create (struct GNUNET_CHAT_Handle *handle, | |||
565 | { | 568 | { |
566 | GNUNET_CHAT_VERSION_ASSERT(); | 569 | GNUNET_CHAT_VERSION_ASSERT(); |
567 | 570 | ||
568 | if ((!handle) || (!(handle->groups)) || (!(handle->contexts))) | 571 | if ((!handle) || (handle->destruction) || |
572 | (!(handle->groups)) || (!(handle->contexts))) | ||
569 | return NULL; | 573 | return NULL; |
570 | 574 | ||
571 | struct GNUNET_HashCode key; | 575 | struct GNUNET_HashCode key; |
@@ -629,7 +633,7 @@ GNUNET_CHAT_iterate_groups (struct GNUNET_CHAT_Handle *handle, | |||
629 | { | 633 | { |
630 | GNUNET_CHAT_VERSION_ASSERT(); | 634 | GNUNET_CHAT_VERSION_ASSERT(); |
631 | 635 | ||
632 | if ((!handle) || (!(handle->groups))) | 636 | if ((!handle) || (handle->destruction) || (!(handle->groups))) |
633 | return GNUNET_SYSERR; | 637 | return GNUNET_SYSERR; |
634 | 638 | ||
635 | struct GNUNET_CHAT_HandleIterateGroups it; | 639 | struct GNUNET_CHAT_HandleIterateGroups it; |