gnunet_chat_lib.h (63822B)
1 /* 2 This file is part of GNUnet. 3 Copyright (C) 2021--2025 GNUnet e.V. 4 5 GNUnet is free software: you can redistribute it and/or modify it 6 under the terms of the GNU Affero General Public License as published 7 by the Free Software Foundation, either version 3 of the License, 8 or (at your option) any later version. 9 10 GNUnet is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Affero General Public License for more details. 14 15 You should have received a copy of the GNU Affero General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 SPDX-License-Identifier: AGPL3.0-or-later 19 */ 20 /* 21 The development of this code was supported by the NLnet foundation as part 22 of the NGI Assure initative to have a more free and secure internet. 23 */ 24 /* 25 * @author Tobias Frisch 26 * @file gnunet_chat_lib.h 27 */ 28 29 #ifndef GNUNET_CHAT_LIB_H_ 30 #define GNUNET_CHAT_LIB_H_ 31 32 /** 33 * @defgroup gnunet_chat GNUnet Chat library 34 */ 35 /**@{*/ 36 37 #ifndef __cplusplus 38 #include <gnunet/gnunet_util_lib.h> 39 #else 40 enum GNUNET_GenericReturnValue { 41 GNUNET_SYSERR = -1, 42 GNUNET_NO = 0, 43 GNUNET_OK = 1, 44 GNUNET_YES = 1, 45 }; 46 47 struct GNUNET_CONFIGURATION_Handle; 48 #endif 49 50 #include <stdint.h> 51 #include <time.h> 52 53 /** 54 * @def GNUNET_CHAT_VERSION The major and minor version should be identical to 55 * the #GNUNET_MESSENGER_VERSION of the GNUnet Messenger 56 * service while the patch version is independent. 57 */ 58 #define GNUNET_CHAT_VERSION 0x000000050003L 59 60 #define GNUNET_CHAT_VERSION_MAJOR ((GNUNET_CHAT_VERSION >> 32L) & 0xFFFFL) 61 #define GNUNET_CHAT_VERSION_MINOR ((GNUNET_CHAT_VERSION >> 16L) & 0xFFFFL) 62 #define GNUNET_CHAT_VERSION_PATCH ((GNUNET_CHAT_VERSION >> 0L) & 0xFFFFL) 63 64 #define GNUNET_CHAT_ATTRIBUTE_AVATAR "chat_avatar" 65 #define GNUNET_CHAT_ATTRIBUTE_BIRTHDAY "chat_birthday" 66 #define GNUNET_CHAT_ATTRIBUTE_EMAIL "chat_email" 67 #define GNUNET_CHAT_ATTRIBUTE_NAME "chat_name" 68 #define GNUNET_CHAT_ATTRIBUTE_PHONE "chat_phone" 69 #define GNUNET_CHAT_ATTRIBUTE_POSTAL "chat_postal" 70 71 #define GNUNET_CHAT_URI_PREFIX "gnunet://chat/" 72 73 /** 74 * Enum for the different types of supported URIs. 75 */ 76 enum GNUNET_CHAT_UriType 77 { 78 /** 79 * The type to share and join a lobby or chat. 80 */ 81 GNUNET_CHAT_URI_TYPE_CHAT = 1, /**< GNUNET_CHAT_URI_TYPE_CHAT */ 82 83 /** 84 * The type to download and query files vis FS service from GNUnet. 85 */ 86 GNUNET_CHAT_URI_TYPE_FS = 2, /**< GNUNET_CHAT_URI_TYPE_FS */ 87 88 /** 89 * An unknown type of uri. 90 */ 91 GNUNET_CHAT_URI_TYPE_UNKNOWN = 0 /**< GNUNET_CHAT_URI_TYPE_UNKNOWN */ 92 }; 93 94 /** 95 * Enum for the different kinds of messages. 96 */ 97 enum GNUNET_CHAT_MessageKind 98 { 99 /** 100 * The kind to inform that something went wrong. 101 */ 102 GNUNET_CHAT_KIND_WARNING = 1, /**< GNUNET_CHAT_KIND_WARNING */ 103 104 /** 105 * The kind to inform that the list of accounts was refreshed. 106 */ 107 GNUNET_CHAT_KIND_REFRESH = 2, /**< GNUNET_CHAT_KIND_REFRESH */ 108 109 /** 110 * The kind to inform that the application can be used. 111 */ 112 GNUNET_CHAT_KIND_LOGIN = 3, /**< GNUNET_CHAT_KIND_LOGIN */ 113 114 /** 115 * The kind to inform that the application needs to cleanup 116 * resources related to the currently connected account. 117 */ 118 GNUNET_CHAT_KIND_LOGOUT = 4, /**< GNUNET_CHAT_KIND_LOGOUT */ 119 120 /** 121 * The kind to inform that an account was successfully created. 122 */ 123 GNUNET_CHAT_KIND_CREATED_ACCOUNT = 5, /**< GNUNET_CHAT_KIND_CREATED_ACCOUNT */ 124 125 /** 126 * The kind to inform that an account was successfully deleted. 127 */ 128 GNUNET_CHAT_KIND_DELETED_ACCOUNT = 6, /**< GNUNET_CHAT_KIND_DELETED_ACCOUNT */ 129 130 /** 131 * The kind to inform that an account was updated. 132 */ 133 GNUNET_CHAT_KIND_UPDATE_ACCOUNT = 7, /**< GNUNET_CHAT_KIND_UPDATE_ACCOUNT */ 134 135 /** 136 * The kind to inform that a context was updated. 137 */ 138 GNUNET_CHAT_KIND_UPDATE_CONTEXT = 8, /**< GNUNET_CHAT_KIND_UPDATE_CONTEXT */ 139 140 /** 141 * The kind to inform that a contact has joined a chat. 142 */ 143 GNUNET_CHAT_KIND_JOIN = 9, /**< GNUNET_CHAT_KIND_JOIN */ 144 145 /** 146 * The kind to inform that a contact has left a chat. 147 */ 148 GNUNET_CHAT_KIND_LEAVE = 10, /**< GNUNET_CHAT_KIND_LEAVE */ 149 150 /** 151 * The kind to inform that a contact has changed. 152 */ 153 GNUNET_CHAT_KIND_CONTACT = 11, /**< GNUNET_CHAT_KIND_CONTACT */ 154 155 /** 156 * The kind to describe an invitation to a different chat. 157 */ 158 GNUNET_CHAT_KIND_INVITATION = 12, /**< GNUNET_CHAT_KIND_INVITATION */ 159 160 /** 161 * The kind to describe a text message. 162 */ 163 GNUNET_CHAT_KIND_TEXT = 13, /**< GNUNET_CHAT_KIND_TEXT */ 164 165 /** 166 * The kind to describe a shared file. 167 */ 168 GNUNET_CHAT_KIND_FILE = 14, /**< GNUNET_CHAT_KIND_FILE */ 169 170 /** 171 * The kind to inform about a deletion of a previous message. 172 */ 173 GNUNET_CHAT_KIND_DELETION = 15, /**< GNUNET_CHAT_KIND_DELETION */ 174 175 /** 176 * The kind to tag a previous message. 177 */ 178 GNUNET_CHAT_KIND_TAG = 16, /**< GNUNET_CHAT_KIND_TAG */ 179 180 /** 181 * The kind to inform that attributes were updated. 182 */ 183 GNUNET_CHAT_KIND_ATTRIBUTES = 17, /**< GNUNET_CHAT_KIND_ATTRIBUTES */ 184 185 /** 186 * The kind to inform that attributes were shared. 187 */ 188 GNUNET_CHAT_KIND_SHARED_ATTRIBUTES = 18, /**< GNUNET_CHAT_KIND_SHARED_ATTRIBUTES */ 189 190 /** 191 * The kind to inform that a discourse was updated. 192 */ 193 GNUNET_CHAT_KIND_DISCOURSE = 19, /**< GNUNET_CHAT_KIND_DISCOURSE */ 194 195 /** 196 * The kind to describe a data message from a discourse. 197 */ 198 GNUNET_CHAT_KIND_DATA = 20, /**< GNUNET_CHAT_KIND_DATA */ 199 200 /** 201 * An unknown kind of message. 202 */ 203 GNUNET_CHAT_KIND_UNKNOWN = 0 /**< GNUNET_CHAT_KIND_UNKNOWN */ 204 }; 205 206 /** 207 * Struct to identify discourses 208 */ 209 struct GNUNET_CHAT_DiscourseId 210 { 211 char identifier [32]; 212 }; 213 214 /** 215 * Struct of a chat handle. 216 */ 217 struct GNUNET_CHAT_Handle; 218 219 /** 220 * Struct of a chat account. 221 */ 222 struct GNUNET_CHAT_Account; 223 224 /** 225 * Struct of a chat URI. 226 */ 227 struct GNUNET_CHAT_Uri; 228 229 /** 230 * Struct of a chat lobby. 231 */ 232 struct GNUNET_CHAT_Lobby; 233 234 /** 235 * Struct of a chat contact. 236 */ 237 struct GNUNET_CHAT_Contact; 238 239 /** 240 * Struct of a chat group. 241 */ 242 struct GNUNET_CHAT_Group; 243 244 /** 245 * Struct of a chat context. 246 */ 247 struct GNUNET_CHAT_Context; 248 249 /** 250 * Struct of a chat message. 251 */ 252 struct GNUNET_CHAT_Message; 253 254 /** 255 * Struct of a chat file. 256 */ 257 struct GNUNET_CHAT_File; 258 259 /** 260 * Struct of a chat invitation. 261 */ 262 struct GNUNET_CHAT_Invitation; 263 264 /** 265 * Struct of a chat discourse. 266 */ 267 struct GNUNET_CHAT_Discourse; 268 269 /** 270 * Iterator over chat accounts of a specific chat handle. 271 * 272 * @param[in,out] cls Closure from #GNUNET_CHAT_iterate_accounts 273 * @param[in,out] handle Chat handle 274 * @param[in,out] account Chat account 275 * @return #GNUNET_YES if we should continue to iterate, #GNUNET_NO otherwise. 276 */ 277 typedef enum GNUNET_GenericReturnValue 278 (*GNUNET_CHAT_AccountCallback) (void *cls, 279 struct GNUNET_CHAT_Handle *handle, 280 struct GNUNET_CHAT_Account *account); 281 282 /** 283 * Iterator over attributes of a specific chat account. 284 * 285 * @param[in,out] cls Closure from #GNUNET_CHAT_get_attributes 286 * @param[in,out] account Chat account 287 * @param[in] name Attribute name 288 * @param[in] value Attribute value 289 * @return #GNUNET_YES if we should continue to iterate, #GNUNET_NO otherwise. 290 */ 291 typedef enum GNUNET_GenericReturnValue 292 (*GNUNET_CHAT_AccountAttributeCallback) (void *cls, 293 struct GNUNET_CHAT_Account *account, 294 const char *name, 295 const char *value); 296 297 /** 298 * Iterator over attributes of a specific chat handle. 299 * 300 * @param[in,out] cls Closure from #GNUNET_CHAT_get_attributes 301 * @param[in,out] handle Chat handle 302 * @param[in] name Attribute name 303 * @param[in] value Attribute value 304 * @return #GNUNET_YES if we should continue to iterate, #GNUNET_NO otherwise. 305 */ 306 typedef enum GNUNET_GenericReturnValue 307 (*GNUNET_CHAT_AttributeCallback) (void *cls, 308 struct GNUNET_CHAT_Handle *handle, 309 const char *name, 310 const char *value); 311 312 /** 313 * Method called when a lobby is opened to share with others via a chat URI. 314 * 315 * @param[in,out] cls Closure from #GNUNET_CHAT_lobby_open 316 * @param[in] uri Chat URI of the lobby or NULL on error 317 */ 318 typedef void 319 (*GNUNET_CHAT_LobbyCallback) (void *cls, 320 const struct GNUNET_CHAT_Uri *uri); 321 322 /** 323 * Iterator over chat files of a specific chat handle. 324 * 325 * @param[in,out] cls Closure from #GNUNET_CHAT_iterate_files 326 * @param[in,out] handle Chat handle 327 * @param[in,out] file Chat file 328 * @return #GNUNET_YES if we should continue to iterate, #GNUNET_NO otherwise. 329 */ 330 typedef enum GNUNET_GenericReturnValue 331 (*GNUNET_CHAT_FileCallback) (void *cls, 332 struct GNUNET_CHAT_Handle *handle, 333 struct GNUNET_CHAT_File *file); 334 335 /** 336 * Iterator over chat contacts of a specific chat handle. 337 * 338 * @param[in,out] cls Closure from #GNUNET_CHAT_iterate_contacts 339 * @param[in,out] handle Chat handle 340 * @param[in,out] contact Chat contact 341 * @return #GNUNET_YES if we should continue to iterate, #GNUNET_NO otherwise. 342 */ 343 typedef enum GNUNET_GenericReturnValue 344 (*GNUNET_CHAT_ContactCallback) (void *cls, 345 struct GNUNET_CHAT_Handle *handle, 346 struct GNUNET_CHAT_Contact *contact); 347 348 /** 349 * Iterator over tags of a specific chat contact. 350 * 351 * @param[in,out] cls Closure 352 * @param[in,out] contact Chat contact 353 * @param[in] tag Tag 354 * @return #GNUNET_YES if we should continue to iterate, #GNUNET_NO otherwise. 355 */ 356 typedef enum GNUNET_GenericReturnValue 357 (*GNUNET_CHAT_ContactTagCallback) (void *cls, 358 struct GNUNET_CHAT_Contact *contact, 359 const char *tag); 360 361 /** 362 * Iterator over accessible attributes of a specific chat contact. 363 * 364 * @param[in,out] cls Closure 365 * @param[in,out] contact Chat contact 366 * @param[in] name Attribute name 367 * @param[in] value Attribute value 368 * @return #GNUNET_YES if we should continue to iterate, #GNUNET_NO otherwise. 369 */ 370 typedef enum GNUNET_GenericReturnValue 371 (*GNUNET_CHAT_ContactAttributeCallback) (void *cls, 372 struct GNUNET_CHAT_Contact *contact, 373 const char *name, 374 const char *value); 375 376 /** 377 * Iterator over chat groups of a specific chat handle. 378 * 379 * @param[in,out] cls Closure from #GNUNET_CHAT_iterate_groups 380 * @param[in,out] handle Chat handle 381 * @param[in,out] group Chat group 382 * @return #GNUNET_YES if we should continue to iterate, #GNUNET_NO otherwise. 383 */ 384 typedef enum GNUNET_GenericReturnValue 385 (*GNUNET_CHAT_GroupCallback) (void *cls, 386 struct GNUNET_CHAT_Handle *handle, 387 struct GNUNET_CHAT_Group *group); 388 389 /** 390 * Iterator over chat contacts in a specific chat group. 391 * 392 * @param[in,out] cls Closure from #GNUNET_CHAT_group_iterate_contacts 393 * @param[in,out] group Chat group 394 * @param[in,out] contact Chat contact 395 * @return #GNUNET_YES if we should continue to iterate, #GNUNET_NO otherwise. 396 */ 397 typedef enum GNUNET_GenericReturnValue 398 (*GNUNET_CHAT_GroupContactCallback) (void *cls, 399 struct GNUNET_CHAT_Group *group, 400 struct GNUNET_CHAT_Contact *contact); 401 402 /** 403 * Iterator over chat messages in a specific chat context. 404 * 405 * @param[in,out] cls Closure from #GNUNET_CHAT_context_iterate_messages 406 * @param[in,out] context Chat context or NULL 407 * @param[in,out] message Chat message 408 * @return #GNUNET_YES if we should continue to iterate, #GNUNET_NO otherwise. 409 */ 410 typedef enum GNUNET_GenericReturnValue 411 (*GNUNET_CHAT_ContextMessageCallback) (void *cls, 412 struct GNUNET_CHAT_Context *context, 413 struct GNUNET_CHAT_Message *message); 414 415 /** 416 * Iterator over chat files in a specific chat context. 417 * 418 * @param[in,out] cls Closure from #GNUNET_CHAT_context_iterate_files 419 * @param[in,out] context Chat context 420 * @param[in,out] file Chat file 421 * @return #GNUNET_YES if we should continue to iterate, #GNUNET_NO otherwise. 422 */ 423 typedef enum GNUNET_GenericReturnValue 424 (*GNUNET_CHAT_ContextFileCallback) (void *cls, 425 struct GNUNET_CHAT_Context *context, 426 struct GNUNET_CHAT_File *file); 427 428 /** 429 * Iterator over chat contacts in a chat to check whether they received a 430 * specific message or not. 431 * 432 * @param[in,out] cls Closure from #GNUNET_CHAT_message_get_read_receipt 433 * @param[in,out] message Chat message 434 * @param[in,out] contact Chat contact 435 * @param[in] read_receipt #GNUNET_YES if the message was received by the contact, 436 * #GNUNET_NO otherwise 437 * @return #GNUNET_YES if we should continue to iterate, #GNUNET_NO otherwise. 438 */ 439 typedef enum GNUNET_GenericReturnValue 440 (*GNUNET_CHAT_MessageReadReceiptCallback) (void *cls, 441 struct GNUNET_CHAT_Message *message, 442 struct GNUNET_CHAT_Contact *contact, 443 int read_receipt); 444 445 /** 446 * Iterator over chat tag messages with a specific target message. 447 * 448 * @param[in,out] cls Closure from #GNUNET_CHAT_message_iterate_tags 449 * @param[in,out] message Chat message 450 * @return #GNUNET_YES if we should continue to iterate, #GNUNET_NO otherwise. 451 */ 452 typedef enum GNUNET_GenericReturnValue 453 (*GNUNET_CHAT_MessageCallback) (void *cls, 454 struct GNUNET_CHAT_Message *message); 455 456 /** 457 * Method called during an upload of a specific file in a chat to share it. 458 * 459 * @param[in,out] cls Closure from #GNUNET_CHAT_context_send_file 460 * @param[in,out] file Chat file 461 * @param[in] completed Amount of the file being uploaded (in bytes) 462 * @param[in] size Full size of the uploading file (in bytes) 463 */ 464 typedef void 465 (*GNUNET_CHAT_FileUploadCallback) (void *cls, 466 struct GNUNET_CHAT_File *file, 467 uint64_t completed, 468 uint64_t size); 469 470 /** 471 * Method called during a download of a specific file in a chat which was shared. 472 * 473 * @param[in,out] cls Closure from #GNUNET_CHAT_file_start_download 474 * @param[in,out] file Chat file 475 * @param[in] completed Amount of the file being downloaded (in bytes) 476 * @param[in] size Full size of the downloading file (in bytes) 477 */ 478 typedef void 479 (*GNUNET_CHAT_FileDownloadCallback) (void *cls, 480 struct GNUNET_CHAT_File *file, 481 uint64_t completed, 482 uint64_t size); 483 484 /** 485 * Method called during an unindexing of a specific file in a chat which was 486 * uploaded before. 487 * 488 * @param[in,out] cls Closure from #GNUNET_CHAT_file_unindex 489 * @param[in,out] file Chat file 490 * @param[in] completed Amount of the file being unindexed (in bytes) 491 * @param[in] size Full size of the unindexing file (in bytes) 492 */ 493 typedef void 494 (*GNUNET_CHAT_FileUnindexCallback) (void *cls, 495 struct GNUNET_CHAT_File *file, 496 uint64_t completed, 497 uint64_t size); 498 499 /** 500 * Iterator over chat discourses in a specific chat context. 501 * 502 * @param[in,out] cls Closure from #GNUNET_CHAT_context_iterate_discourses 503 * @param[in,out] context Chat context 504 * @param[in,out] discourse Chat discourse 505 */ 506 typedef enum GNUNET_GenericReturnValue 507 (*GNUNET_CHAT_DiscourseCallback) (void *cls, 508 struct GNUNET_CHAT_Context *context, 509 struct GNUNET_CHAT_Discourse *discourse); 510 511 /** 512 * Iterator over chat contacts in a specific chat discourse. 513 * 514 * @param[in,out] cls Closure from #GNUNET_CHAT_discourse_iterate_contacts 515 * @param[in,out] discourse Chat discourse 516 * @param[in,out] contact Chat contact 517 * @return #GNUNET_YES if we should continue to iterate, #GNUNET_NO otherwise. 518 */ 519 typedef enum GNUNET_GenericReturnValue 520 (*GNUNET_CHAT_DiscourseContactCallback) (void *cls, 521 struct GNUNET_CHAT_Discourse *discourse, 522 struct GNUNET_CHAT_Contact *contact); 523 524 /** 525 * Start a chat handle with a certain configuration. 526 * 527 * A custom callback for warnings and message events can be provided optionally 528 * together with their respective closures. 529 * 530 * @param[in] cfg Configuration 531 * @param[in] msg_cb Callback for message events (optional) 532 * @param[in,out] msg_cls Closure for message events (optional) 533 * @return Chat handle 534 */ 535 struct GNUNET_CHAT_Handle* 536 GNUNET_CHAT_start (const struct GNUNET_CONFIGURATION_Handle *cfg, 537 GNUNET_CHAT_ContextMessageCallback msg_cb, 538 void *msg_cls); 539 540 /** 541 * Stops a chat handle closing all its remaining resources and frees the 542 * regarding memory. 543 * 544 * @param[in,out] handle Chat handle 545 */ 546 void 547 GNUNET_CHAT_stop (struct GNUNET_CHAT_Handle *handle); 548 549 /** 550 * Creates a new chat account to use with a given chat <i>handle</i> under a 551 * unique <i>name</i>. 552 * 553 * If a specific name is already in use of another chat accounts, the function 554 * will fail and return #GNUNET_NO. 555 * 556 * @param[in,out] handle Chat handle 557 * @param[in] name Account name 558 * @return #GNUNET_OK on success, #GNUNET_NO on failure and otherwise #GNUNET_SYSERR 559 */ 560 enum GNUNET_GenericReturnValue 561 GNUNET_CHAT_account_create (struct GNUNET_CHAT_Handle *handle, 562 const char *name); 563 564 /** 565 * Deletes an existing chat account of a given chat <i>handle</i> under a 566 * unique <i>name</i>. 567 * 568 * @param[in,out] handle Chat handle 569 * @param[in] name Account name 570 * @return #GNUNET_OK on success, otherwise #GNUNET_SYSERR 571 */ 572 enum GNUNET_GenericReturnValue 573 GNUNET_CHAT_account_delete(struct GNUNET_CHAT_Handle *handle, 574 const char *name); 575 576 /** 577 * Iterates through the accounts of a given chat <i>handle</i> with a selected 578 * callback and custom closure. 579 * 580 * @param[in,out] handle Chat handle 581 * @param[in] callback Callback for account iteration (optional) 582 * @param[in,out] cls Closure for account iteration (optional) 583 * @return Amount of accounts iterated or #GNUNET_SYSERR on failure 584 */ 585 int 586 GNUNET_CHAT_iterate_accounts (struct GNUNET_CHAT_Handle *handle, 587 GNUNET_CHAT_AccountCallback callback, 588 void *cls); 589 590 /** 591 * Searches for an existing chat account of a given chat <i>handle</i> with 592 * a unique <i>name</i>. 593 * 594 * @param[in] handle Chat handle 595 * @param[in] name Account name 596 * @return Found account by the handle or NULL 597 */ 598 struct GNUNET_CHAT_Account* 599 GNUNET_CHAT_find_account (const struct GNUNET_CHAT_Handle *handle, 600 const char *name); 601 602 /** 603 * Connects a chat <i>handle</i> to a selected chat <i>account</i>. 604 * 605 * @param[in,out] handle Chat handle 606 * @param[in,out] account Chat account 607 */ 608 void 609 GNUNET_CHAT_connect (struct GNUNET_CHAT_Handle *handle, 610 struct GNUNET_CHAT_Account *account); 611 612 /** 613 * Disconnects a chat <i>handle</i> from the current chat account. 614 * 615 * @param[in,out] handle Chat handle 616 */ 617 void 618 GNUNET_CHAT_disconnect (struct GNUNET_CHAT_Handle *handle); 619 620 /** 621 * Returns the connected account of a chat <i>handle</i> for related 622 * communication or NULL if no account is set yet. 623 * 624 * @param[in] handle Chat handle 625 * @return Account used by the handle or NULL 626 */ 627 struct GNUNET_CHAT_Account* 628 GNUNET_CHAT_get_connected (const struct GNUNET_CHAT_Handle *handle); 629 630 /** 631 * Updates a chat handle to renew the used ego to sign sent messages in active 632 * chats. 633 * 634 * Updating the chat handle should only be used if necessary because the usage 635 * can require renewed exchanging of GNS entries. 636 * 637 * @param[in,out] handle Chat handle 638 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 639 */ 640 enum GNUNET_GenericReturnValue 641 GNUNET_CHAT_update (struct GNUNET_CHAT_Handle *handle); 642 643 /** 644 * Updates the name of a chat handle for related communication. 645 * 646 * @param[in,out] handle Chat handle 647 * @param[in] name New name or NULL 648 * @return #GNUNET_YES on success, #GNUNET_NO on failure and #GNUNET_SYSERR if <i>handle</i> is NULL 649 */ 650 enum GNUNET_GenericReturnValue 651 GNUNET_CHAT_set_name (struct GNUNET_CHAT_Handle *handle, 652 const char *name); 653 654 /** 655 * Returns the name of a chat handle for related communication or NULL if no 656 * name is set. 657 * 658 * @param[in] handle Chat handle 659 * @return Name used by the handle or NULL 660 */ 661 const char* 662 GNUNET_CHAT_get_name (const struct GNUNET_CHAT_Handle *handle); 663 664 /** 665 * Returns the public key of the used ego to verify signatures of sent messages. 666 * 667 * @param[in] handle Chat handle 668 * @return Public key of the handles ego or NULL 669 */ 670 const char* 671 GNUNET_CHAT_get_key (const struct GNUNET_CHAT_Handle *handle); 672 673 /** 674 * Updates an attribute of a chat handle for related communication under a given 675 * <i>name</i> and a custom <i>value</i>. 676 * 677 * @param[in,out] handle Chat handle 678 * @param[in] name Attribute name 679 * @param[in] value Attribute value 680 */ 681 void 682 GNUNET_CHAT_set_attribute (struct GNUNET_CHAT_Handle *handle, 683 const char *name, 684 const char *value); 685 686 /** 687 * Deletes an attribute of a chat <i>handle</i> for related communication 688 * under a given <i>name</i>. 689 * 690 * @param[in,out] handle Chat handle 691 * @param[in] name Attribute name 692 */ 693 void 694 GNUNET_CHAT_delete_attribute (struct GNUNET_CHAT_Handle *handle, 695 const char *name); 696 697 /** 698 * Calls an optional <i>callback</i> for each attribute of a given chat 699 * <i>handle</i>. 700 * 701 * @param[in,out] handle Chat handle 702 * @param[in] callback Callback for attribute iteration (optional) 703 * @param[in,out] cls Closure for attribute iteration (optional) 704 */ 705 void 706 GNUNET_CHAT_get_attributes (struct GNUNET_CHAT_Handle *handle, 707 GNUNET_CHAT_AttributeCallback callback, 708 void *cls); 709 710 /** 711 * Share an attribute of a chat <i>handle</i> under a given <i>name</i> 712 * with a specific chat <i>contact</i>. 713 * 714 * @param[in,out] handle Chat handle 715 * @param[in,out] contact Chat contact 716 * @param[in] name Attribute name 717 */ 718 void 719 GNUNET_CHAT_share_attribute_with (struct GNUNET_CHAT_Handle *handle, 720 struct GNUNET_CHAT_Contact *contact, 721 const char *name); 722 723 /** 724 * Unshare an attribute of a chat <i>handle</i> under a given <i>name</i> 725 * from a specific chat <i>contact</i>. 726 * 727 * @param[in,out] handle Chat handle 728 * @param[in,out] contact Chat contact 729 * @param[in] name Attribute name 730 */ 731 void 732 GNUNET_CHAT_unshare_attribute_from (struct GNUNET_CHAT_Handle *handle, 733 struct GNUNET_CHAT_Contact *contact, 734 const char *name); 735 736 /** 737 * Calls an optional <i>callback</i> for each attribute of a given chat 738 * <i>handle</i> shared with a specific chat <i>contact</i>. 739 * 740 * @param[in,out] handle Chat handle 741 * @param[in] contact Chat contact 742 * @param[in] callback Callback for attribute iteration (optional) 743 * @param[in,out] cls Closure for attribute iteration (optional) 744 */ 745 void 746 GNUNET_CHAT_get_shared_attributes (struct GNUNET_CHAT_Handle *handle, 747 struct GNUNET_CHAT_Contact *contact, 748 GNUNET_CHAT_ContactAttributeCallback callback, 749 void *cls); 750 751 /** 752 * Convert an UTF-8 String to a chat URI which will be newly allocated. 753 * 754 * @param[in] uri UTF-8 string to parse 755 * @param[out] emsg Where to store the parser error message (if any) 756 * @return URI on success, NULL on error 757 */ 758 struct GNUNET_CHAT_Uri* 759 GNUNET_CHAT_uri_parse (const char *uri, 760 char **emsg); 761 762 /** 763 * Convert a chat URI to a UTF-8 String. 764 * 765 * @param[in] uri Chat URI 766 * @return The UTF-8 string representing the URI 767 */ 768 char* 769 GNUNET_CHAT_uri_to_string (const struct GNUNET_CHAT_Uri *uri); 770 771 /** 772 * Returns the type of a given chat URI. 773 * 774 * @param[in] uri Chat URI 775 * @return The type of URI 776 */ 777 enum GNUNET_CHAT_UriType 778 GNUNET_CHAT_uri_get_type (const struct GNUNET_CHAT_Uri *uri); 779 780 /** 781 * Free an allocated chat URI. 782 * 783 * @param[in,out] uri Chat URI 784 */ 785 void 786 GNUNET_CHAT_uri_destroy (struct GNUNET_CHAT_Uri *uri); 787 788 /** 789 * Opens an empty chat lobby which will expire after a custom <i>delay</i>. 790 * 791 * @param[in,out] handle Chat handle 792 * @param[in] delay Expiration delay 793 * @param[in] callback Callback for the lobby opening 794 * @param[in,out] cls Closure for the lobby opening (optional) 795 * @return Chat lobby 796 */ 797 struct GNUNET_CHAT_Lobby* 798 GNUNET_CHAT_lobby_open (struct GNUNET_CHAT_Handle *handle, 799 unsigned int delay, 800 GNUNET_CHAT_LobbyCallback callback, 801 void *cls); 802 803 /** 804 * Closes a chat <i>lobby</i> overriding the expiration to be now. 805 * 806 * @param[in,out] lobby Chat lobby 807 */ 808 void 809 GNUNET_CHAT_lobby_close (struct GNUNET_CHAT_Lobby *lobby); 810 811 /** 812 * Joins an open lobby via URI with a given chat <i>handle</i> if it can still 813 * be resolved (depends on connection and expiration of the lobby). 814 * 815 * @param[in,out] handle Chat handle 816 * @param[in] uri Chat URI 817 */ 818 void 819 GNUNET_CHAT_lobby_join (struct GNUNET_CHAT_Handle *handle, 820 const struct GNUNET_CHAT_Uri *uri); 821 822 /** 823 * Requests a file with a given chat <i>handle</i> from a selected chat 824 * <i>uri</i> to potentially download it. 825 * 826 * @param[in,out] handle Chat handle 827 * @param[in] uri Chat URI 828 * @return File handle on success, NULL on failure 829 */ 830 struct GNUNET_CHAT_File* 831 GNUNET_CHAT_request_file (struct GNUNET_CHAT_Handle *handle, 832 const struct GNUNET_CHAT_Uri *uri); 833 834 /** 835 * Uploads a local file specified via its <i>path</i> to share its uri 836 * with others afterwards. 837 * 838 * @param[in,out] handle Chat handle 839 * @param[in] path Local file path 840 * @param[in] callback Callback for file uploading (optional) 841 * @param[in,out] cls Closure for file uploading (optional) 842 * @return The file handle on success, NULL on failure 843 */ 844 struct GNUNET_CHAT_File* 845 GNUNET_CHAT_upload_file (struct GNUNET_CHAT_Handle *handle, 846 const char *path, 847 GNUNET_CHAT_FileUploadCallback callback, 848 void *cls); 849 850 /** 851 * Iterates through the files of a given chat <i>handle</i> with a selected 852 * callback and custom closure. 853 * 854 * @param[in,out] handle Chat handle 855 * @param[in] callback Callback for file iteration (optional) 856 * @param[in,out] cls Closure for file iteration (optional) 857 * @return Amount of files iterated or #GNUNET_SYSERR on failure 858 */ 859 int 860 GNUNET_CHAT_iterate_files (struct GNUNET_CHAT_Handle *handle, 861 GNUNET_CHAT_FileCallback callback, 862 void *cls); 863 864 /** 865 * Sets a custom <i>user pointer</i> to a given chat <i>handle</i> so it can 866 * be accessed in all handle related callbacks. 867 * 868 * @param[in,out] handle Chat handle 869 * @param[in] user_pointer Custom user pointer 870 */ 871 void 872 GNUNET_CHAT_set_user_pointer (struct GNUNET_CHAT_Handle *handle, 873 void *user_pointer); 874 875 /** 876 * Returns the custom user pointer of a given chat <i>handle</i> or NULL if it 877 * was not set any. 878 * 879 * @param[in] handle Chat handle 880 * @return Custom user pointer or NULL 881 */ 882 void* 883 GNUNET_CHAT_get_user_pointer (const struct GNUNET_CHAT_Handle *handle); 884 885 /** 886 * Iterates through the contacts of a given chat <i>handle</i> with a selected 887 * callback and custom closure. 888 * 889 * @param[in,out] handle Chat handle 890 * @param[in] callback Callback for contact iteration (optional) 891 * @param[in,out] cls Closure for contact iteration (optional) 892 * @return Amount of contacts iterated or #GNUNET_SYSERR on failure 893 */ 894 int 895 GNUNET_CHAT_iterate_contacts (struct GNUNET_CHAT_Handle *handle, 896 GNUNET_CHAT_ContactCallback callback, 897 void *cls); 898 899 /** 900 * Returns the provided name of a given <i>account</i> or NULL on failure. 901 * 902 * @param[in] account Chat account 903 * @return Name or NULL 904 */ 905 const char* 906 GNUNET_CHAT_account_get_name (const struct GNUNET_CHAT_Account *account); 907 908 /** 909 * Calls an optional <i>callback</i> for each attribute of a given chat 910 * <i>account</i> using a chat <i>handle</i>. 911 * 912 * @param[in,out] handle Chat handle 913 * @param[in] account Chat account 914 * @param[in] callback Callback for attribute iteration (optional) 915 * @param[in,out] cls Closure for attribute iteration (optional) 916 */ 917 void 918 GNUNET_CHAT_account_get_attributes (struct GNUNET_CHAT_Handle *handle, 919 struct GNUNET_CHAT_Account *account, 920 GNUNET_CHAT_AccountAttributeCallback callback, 921 void *cls); 922 923 /** 924 * Sets a custom <i>user pointer</i> to a given chat <i>account</i> so it can 925 * be accessed in account related callbacks. 926 * 927 * @param[in,out] account Chat account 928 * @param[in] user_pointer Custom user pointer 929 */ 930 void 931 GNUNET_CHAT_account_set_user_pointer (struct GNUNET_CHAT_Account *account, 932 void *user_pointer); 933 934 /** 935 * Returns the custom user pointer of a given <i>contact</i> or NULL if it was 936 * not set any. 937 * 938 * @param[in] account Chat account 939 * @return Custom user pointer or NULL 940 */ 941 void* 942 GNUNET_CHAT_account_get_user_pointer (const struct GNUNET_CHAT_Account *account); 943 944 /** 945 * Creates a new group chat to use with a given chat <i>handle</i> with an 946 * optional public <i>topic</i>. 947 * 948 * If a specific <i>topic</i> is used, the created group will be publically 949 * available to join for others searching for the used topic. Otherwise the 950 * group will be private using a randomly generated key and others can only 951 * join the chat via a private invitation. 952 * 953 * @param[in,out] handle Chat handle 954 * @param[in] topic Public topic (optional) 955 * @return New group chat 956 */ 957 struct GNUNET_CHAT_Group* 958 GNUNET_CHAT_group_create (struct GNUNET_CHAT_Handle *handle, 959 const char* topic); 960 961 /** 962 * Iterates through the groups of a given chat <i>handle</i> with a selected 963 * callback and custom closure. 964 * 965 * @param[in,out] handle Chat handle 966 * @param[in] callback Callback for group iteration (optional) 967 * @param[in,out] cls Closure for group iteration (optional) 968 * @return Amount of groups iterated or #GNUNET_SYSERR on failure 969 */ 970 int 971 GNUNET_CHAT_iterate_groups (struct GNUNET_CHAT_Handle *handle, 972 GNUNET_CHAT_GroupCallback callback, 973 void *cls); 974 975 /** 976 * Leaves the private chat with a specific <i>contact</i> and frees the 977 * regarding memory of the contact if there remains no common chat with it. 978 * 979 * @param[in,out] contact Contact 980 */ 981 void 982 GNUNET_CHAT_contact_delete (struct GNUNET_CHAT_Contact *contact); 983 984 /** 985 * Overrides the name of a given <i>contact</i> with a custom nick <i>name</i> 986 * which will be only used locally. 987 * 988 * @param[in,out] contact Contact 989 * @param[in] name Custom nick name 990 */ 991 void 992 GNUNET_CHAT_contact_set_name (struct GNUNET_CHAT_Contact *contact, 993 const char *name); 994 995 /** 996 * Returns the provided name of a given <i>contact</i> or its custom nick name 997 * if it was overriden. 998 * 999 * @param[in] contact Contact 1000 * @return Name or custom nick name 1001 */ 1002 const char* 1003 GNUNET_CHAT_contact_get_name (const struct GNUNET_CHAT_Contact *contact); 1004 1005 /** 1006 * Returns the public key of the used ego by a specific <i>contact</i> to 1007 * verify signatures of sent messages. 1008 * 1009 * @param[in] contact Contact 1010 * @return Public key of the contacts ego or NULL 1011 */ 1012 const char* 1013 GNUNET_CHAT_contact_get_key (const struct GNUNET_CHAT_Contact *contact); 1014 1015 /** 1016 * Returns the chat context for a private chat with a given <i>contact</i>. 1017 * 1018 * @param[in,out] contact Contact 1019 * @return Chat context 1020 */ 1021 struct GNUNET_CHAT_Context* 1022 GNUNET_CHAT_contact_get_context (struct GNUNET_CHAT_Contact *contact); 1023 1024 /** 1025 * Sets a custom <i>user pointer</i> to a given <i>contact</i> so it can be 1026 * accessed in contact related callbacks. 1027 * 1028 * @param[in,out] contact Contact 1029 * @param[in] user_pointer Custom user pointer 1030 */ 1031 void 1032 GNUNET_CHAT_contact_set_user_pointer (struct GNUNET_CHAT_Contact *contact, 1033 void *user_pointer); 1034 1035 /** 1036 * Returns the custom user pointer of a given <i>contact</i> or NULL if it was 1037 * not set any. 1038 * 1039 * @param[in] contact Contact 1040 * @return Custom user pointer or NULL 1041 */ 1042 void* 1043 GNUNET_CHAT_contact_get_user_pointer (const struct GNUNET_CHAT_Contact *contact); 1044 1045 /** 1046 * Returns if a given <i>contact</i> is owned by the current account and whether 1047 * it has sent messages with. 1048 * 1049 * @param[in] contact Contact 1050 * @return #GNUNET_YES if the contact is owned, otherwise# GNUNET_NO 1051 * and #GNUNET_SYSERR on failure 1052 */ 1053 enum GNUNET_GenericReturnValue 1054 GNUNET_CHAT_contact_is_owned (const struct GNUNET_CHAT_Contact *contact); 1055 1056 /** 1057 * Blocks or unblocks a given <i>contact</i> by the current account. 1058 * 1059 * @param[in,out] contact Contact 1060 * @param[in] blocked #GNUNET_YES to block, #GNUNET_NO to unblock 1061 */ 1062 void 1063 GNUNET_CHAT_contact_set_blocked (struct GNUNET_CHAT_Contact *contact, 1064 enum GNUNET_GenericReturnValue blocked); 1065 1066 /** 1067 * Returns if a given <i>contact</i> is blocked by the current account and 1068 * whether messages of it should be filtered. 1069 * 1070 * @param[in] contact Contact 1071 * @return #GNUNET_YES if the contact is blocked, #GNUNET_SYSERR on failure and 1072 * #GNUNET_NO otherwise 1073 */ 1074 enum GNUNET_GenericReturnValue 1075 GNUNET_CHAT_contact_is_blocked (const struct GNUNET_CHAT_Contact *contact); 1076 1077 /** 1078 * Tags a given <i>contact</i> by the current account with a specific 1079 * <i>tag</i>. 1080 * 1081 * @param[in,out] contact Contact 1082 * @param[in] tag Tag 1083 */ 1084 void 1085 GNUNET_CHAT_contact_tag (struct GNUNET_CHAT_Contact *contact, 1086 const char *tag); 1087 1088 /** 1089 * Untags a given <i>contact</i> by the current account with a specific 1090 * <i>tag</i>. 1091 * 1092 * @param[in,out] contact Contact 1093 * @param[in] tag Tag 1094 */ 1095 void 1096 GNUNET_CHAT_contact_untag (struct GNUNET_CHAT_Contact *contact, 1097 const char *tag); 1098 1099 /** 1100 * Returns if a given <i>contact</i> is tagged by the current account with 1101 * a specific <i>tag</i>. 1102 * 1103 * @param[in] contact Contact 1104 * @param[in] tag Tag 1105 * @return #GNUNET_YES if the contact is tagged, #GNUNET_SYSERR on failure and 1106 * #GNUNET_NO otherwise 1107 */ 1108 enum GNUNET_GenericReturnValue 1109 GNUNET_CHAT_contact_is_tagged (const struct GNUNET_CHAT_Contact *contact, 1110 const char *tag); 1111 1112 /** 1113 * Calls an optional <i>callback</i> for each tag of a given chat 1114 * <i>contact</i>. 1115 * 1116 * @param[in] contact Chat contact 1117 * @param[in] callback Callback for tag iteration (optional) 1118 * @param[in,out] cls Closure for tag iteration (optional) 1119 * @return Amount of tags iterated or #GNUNET_SYSERR on failure 1120 */ 1121 int 1122 GNUNET_CHAT_contact_iterate_tags (struct GNUNET_CHAT_Contact *contact, 1123 GNUNET_CHAT_ContactTagCallback callback, 1124 void *cls); 1125 1126 /** 1127 * Calls an optional <i>callback</i> for each attribute of a given chat 1128 * <i>contact</i>. 1129 * 1130 * @param[in,out] contact Chat contact 1131 * @param[in] callback Callback for attribute iteration (optional) 1132 * @param[in,out] cls Closure for attribute iteration (optional) 1133 */ 1134 void 1135 GNUNET_CHAT_contact_get_attributes (struct GNUNET_CHAT_Contact *contact, 1136 GNUNET_CHAT_ContactAttributeCallback callback, 1137 void *cls); 1138 1139 /** 1140 * Leaves a specific <i>group</i> chat and frees its memory if it is not shared 1141 * with other groups or contacts. 1142 * 1143 * @param[in,out] group Group 1144 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 1145 */ 1146 enum GNUNET_GenericReturnValue 1147 GNUNET_CHAT_group_leave (struct GNUNET_CHAT_Group *group); 1148 1149 /** 1150 * Sets the name of a given <i>group</i> to a custom nick <i>name</i> 1151 * which will be only used locally. 1152 * 1153 * @param[in,out] group Group 1154 * @param[in] name Custom nick name 1155 */ 1156 void 1157 GNUNET_CHAT_group_set_name (struct GNUNET_CHAT_Group *group, 1158 const char *name); 1159 1160 /** 1161 * Returns the custom nick name of a given <i>group</i> if it was overriden. 1162 * 1163 * @param[in] group Group 1164 * @return Custom nick name or NULL 1165 */ 1166 const char* 1167 GNUNET_CHAT_group_get_name (const struct GNUNET_CHAT_Group *group); 1168 1169 /** 1170 * Sets a custom <i>user pointer</i> to a given <i>group</i> so it can be 1171 * accessed in group related callbacks. 1172 * 1173 * @param[in,out] group Group 1174 * @param[in] user_pointer Custom user pointer 1175 */ 1176 void 1177 GNUNET_CHAT_group_set_user_pointer (struct GNUNET_CHAT_Group *group, 1178 void *user_pointer); 1179 1180 /** 1181 * Returns the custom user pointer of a given <i>group</i> or NULL if it was 1182 * not set any. 1183 * 1184 * @param[in] group Group 1185 * @return Custom user pointer or NULL 1186 */ 1187 void* 1188 GNUNET_CHAT_group_get_user_pointer (const struct GNUNET_CHAT_Group *group); 1189 1190 /** 1191 * Invites a specific <i>contact</i> to a given <i>group</i> via a privately 1192 * sent invitation. 1193 * 1194 * @param[in,out] group Group 1195 * @param[in,out] contact Contact 1196 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 1197 */ 1198 enum GNUNET_GenericReturnValue 1199 GNUNET_CHAT_group_invite_contact (struct GNUNET_CHAT_Group *group, 1200 struct GNUNET_CHAT_Contact *contact); 1201 1202 /** 1203 * Iterates through the contacts of a given <i>group</i> with a selected 1204 * callback and custom closure. 1205 * 1206 * @param[in,out] group Group 1207 * @param[in] callback Callback for contact iteration (optional) 1208 * @param[in,out] cls Closure for contact iteration (optional) 1209 * @return Amount of contacts iterated or #GNUNET_SYSERR on failure 1210 */ 1211 int 1212 GNUNET_CHAT_group_iterate_contacts (struct GNUNET_CHAT_Group *group, 1213 GNUNET_CHAT_GroupContactCallback callback, 1214 void *cls); 1215 1216 /** 1217 * Sets a custom <i>user pointer</i> to a given <i>member</i> relative to a 1218 * <i>group</i> so it can be accessed in member related callbacks. 1219 * 1220 * @param[in,out] group Chat group 1221 * @param[in] member Contact 1222 * @param[in] user_pointer Custom user pointer 1223 */ 1224 void 1225 GNUNET_CHAT_member_set_user_pointer (struct GNUNET_CHAT_Group *group, 1226 const struct GNUNET_CHAT_Contact *member, 1227 void *user_pointer); 1228 1229 /** 1230 * Returns the custom user pointer of a given <i>member</i> relative to a 1231 * <i>group</i> or NULL if it was not set any. 1232 * 1233 * @param[in] group Chat group 1234 * @param[in] member Contact 1235 * @return Custom user pointer or NULL 1236 */ 1237 void* 1238 GNUNET_CHAT_member_get_user_pointer (const struct GNUNET_CHAT_Group *group, 1239 const struct GNUNET_CHAT_Contact *member); 1240 1241 /** 1242 * Returns the chat context for a chat with a given <i>group</i>. 1243 * 1244 * @param[in,out] group Group 1245 * @return Chat context 1246 */ 1247 struct GNUNET_CHAT_Context* 1248 GNUNET_CHAT_group_get_context (struct GNUNET_CHAT_Group *group); 1249 1250 /** 1251 * Returns the current status of a given <i>context</i> whether it is usable 1252 * or not to communicate with other contacts. 1253 * 1254 * @param[in] context Context 1255 * @return #GNUNET_OK if usable, #GNUNET_NO if the context has been requested, 1256 * #GNUNET_SYSERR otherwise. 1257 */ 1258 enum GNUNET_GenericReturnValue 1259 GNUNET_CHAT_context_get_status (const struct GNUNET_CHAT_Context *context); 1260 1261 /** 1262 * Requests a <i>context</i> to get established between all required contacts. 1263 * The current status of this request can be tracked via 1264 * #GNUNET_CHAT_context_get_status() and will only change through the 1265 * receivement of new messages. 1266 * 1267 * @param[in,out] context Context 1268 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 1269 */ 1270 enum GNUNET_GenericReturnValue 1271 GNUNET_CHAT_context_request (struct GNUNET_CHAT_Context *context); 1272 1273 /** 1274 * Returns the chat contact which uses a given <i>context</i>. 1275 * 1276 * @param[in] context Context 1277 * @return Chat contact 1278 */ 1279 struct GNUNET_CHAT_Contact* 1280 GNUNET_CHAT_context_get_contact (struct GNUNET_CHAT_Context *context); 1281 1282 /** 1283 * Returns the chat group which uses a given <i>context</i>. 1284 * 1285 * @param[in] context Context 1286 * @return Chat group 1287 */ 1288 struct GNUNET_CHAT_Group* 1289 GNUNET_CHAT_context_get_group (struct GNUNET_CHAT_Context *context); 1290 1291 /** 1292 * Sets a custom <i>user pointer</i> to a given chat <i>context</i> so it can 1293 * be accessed in chat context related callbacks. 1294 * 1295 * @param[in,out] context Chat context 1296 * @param[in] user_pointer Custom user pointer 1297 */ 1298 void 1299 GNUNET_CHAT_context_set_user_pointer (struct GNUNET_CHAT_Context *context, 1300 void *user_pointer); 1301 1302 /** 1303 * Returns the custom user pointer of a given chat <i>context</i> or NULL if it 1304 * was not set any. 1305 * 1306 * @param[in] context Chat context 1307 * @return Custom user pointer or NULL 1308 */ 1309 void* 1310 GNUNET_CHAT_context_get_user_pointer (const struct GNUNET_CHAT_Context *context); 1311 1312 /** 1313 * Sends a selected <i>text</i> into a given chat <i>context</i>. 1314 * 1315 * @param[in,out] context Chat context 1316 * @param[in] text Text 1317 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 1318 */ 1319 enum GNUNET_GenericReturnValue 1320 GNUNET_CHAT_context_send_text (struct GNUNET_CHAT_Context *context, 1321 const char *text); 1322 1323 /** 1324 * Sends a read receipt depending on a selected <i>message</i> into a given 1325 * chat <i>context</i>. 1326 * 1327 * @param[in,out] context Chat context 1328 * @param[in,out] message Message (optional) 1329 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 1330 */ 1331 enum GNUNET_GenericReturnValue 1332 GNUNET_CHAT_context_send_read_receipt (struct GNUNET_CHAT_Context *context, 1333 struct GNUNET_CHAT_Message *message); 1334 1335 /** 1336 * Uploads a local file specified via its <i>path</i> using symmetric encryption 1337 * and shares the regarding information to download and decrypt it in a given 1338 * chat <i>context</i>. 1339 * 1340 * @param[in,out] context Chat context 1341 * @param[in] path Local file path 1342 * @param[in] callback Callback for file uploading (optional) 1343 * @param[in,out] cls Closure for file uploading (optional) 1344 * @return The file handle on success, NULL on failure 1345 */ 1346 struct GNUNET_CHAT_File* 1347 GNUNET_CHAT_context_send_file (struct GNUNET_CHAT_Context *context, 1348 const char *path, 1349 GNUNET_CHAT_FileUploadCallback callback, 1350 void *cls); 1351 1352 /** 1353 * Shares the information to download and decrypt a specific <i>file</i> from 1354 * another chat in a given chat <i>context</i>. 1355 * 1356 * @param[in,out] context Chat context 1357 * @param[in,out] file File handle 1358 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 1359 */ 1360 enum GNUNET_GenericReturnValue 1361 GNUNET_CHAT_context_share_file (struct GNUNET_CHAT_Context *context, 1362 struct GNUNET_CHAT_File *file); 1363 1364 /** 1365 * Sends a tag message targeting a selected <i>message</i> into a given 1366 * chat <i>context</i> with a given <i>tag</i> value. 1367 * 1368 * @param[in,out] context Chat context 1369 * @param[in,out] message Message 1370 * @param[in] tag Tag value 1371 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 1372 */ 1373 enum GNUNET_GenericReturnValue 1374 GNUNET_CHAT_context_send_tag (struct GNUNET_CHAT_Context *context, 1375 struct GNUNET_CHAT_Message *message, 1376 const char *tag); 1377 1378 /** 1379 * Opens a chat discourse under a specific <i>id</i> in a given chat 1380 * <i>context</i> to send data live to other contacts. 1381 * 1382 * @param[in,out] context Chat context 1383 * @param[in] id Discourse id 1384 * @return Chat discourse 1385 */ 1386 struct GNUNET_CHAT_Discourse* 1387 GNUNET_CHAT_context_open_discourse (struct GNUNET_CHAT_Context *context, 1388 const struct GNUNET_CHAT_DiscourseId *id); 1389 1390 /** 1391 * Iterates through the contacts of a given chat <i>context</i> with a selected 1392 * callback and custom closure. 1393 * 1394 * @param[in,out] context Chat context 1395 * @param[in] callback Callback for contact iteration (optional) 1396 * @param[in,out] cls Closure for contact iteration (optional) 1397 * @return Amount of contacts iterated or #GNUNET_SYSERR on failure 1398 */ 1399 int 1400 GNUNET_CHAT_context_iterate_messages (struct GNUNET_CHAT_Context *context, 1401 GNUNET_CHAT_ContextMessageCallback callback, 1402 void *cls); 1403 1404 /** 1405 * Iterates through the files of a given chat <i>context</i> with a selected 1406 * callback and custom closure. 1407 * 1408 * @param[in,out] context Chat context 1409 * @param[in] callback Callback for file iteration (optional) 1410 * @param[in,out] cls Closure for file iteration (optional) 1411 * @return Amount of files iterated or #GNUNET_SYSERR on failure 1412 */ 1413 int 1414 GNUNET_CHAT_context_iterate_files (struct GNUNET_CHAT_Context *context, 1415 GNUNET_CHAT_ContextFileCallback callback, 1416 void *cls); 1417 1418 /** 1419 * Iterates through the discourses of a given chat <i>context</i> with a 1420 * selected callback and custom closure. 1421 * 1422 * @param[in,out] context Chat context 1423 * @param[in] callback Callback for file iteration (optional) 1424 * @param[in,out] cls Closure for file iteration (optional) 1425 * @return Amount of discourses iterated or #GNUNET_SYSERR on failure 1426 */ 1427 int 1428 GNUNET_CHAT_context_iterate_discourses (struct GNUNET_CHAT_Context *context, 1429 GNUNET_CHAT_DiscourseCallback callback, 1430 void *cls); 1431 1432 /** 1433 * Returns the kind of a given <i>message</i> to determine its content and 1434 * related usage. 1435 * 1436 * @param[in] message Message 1437 * @return The kind of message 1438 */ 1439 enum GNUNET_CHAT_MessageKind 1440 GNUNET_CHAT_message_get_kind (const struct GNUNET_CHAT_Message *message); 1441 1442 /** 1443 * Returns the timestamp of a given <i>message</i> in absolute measure. 1444 * 1445 * @param[in] message Message 1446 * @return The timestamp of message 1447 */ 1448 time_t 1449 GNUNET_CHAT_message_get_timestamp (const struct GNUNET_CHAT_Message *message); 1450 1451 /** 1452 * Returns the contact of the sender from a given <i>message</i>. 1453 * 1454 * @param[in] message Message 1455 * @return Contact of the messages sender 1456 */ 1457 struct GNUNET_CHAT_Contact* 1458 GNUNET_CHAT_message_get_sender (const struct GNUNET_CHAT_Message *message); 1459 1460 /** 1461 * Returns the contact of the recipient from a given <i>message</i>. 1462 * 1463 * @param[in] message Message 1464 * @return Contact of the messages recipient or NULL 1465 */ 1466 struct GNUNET_CHAT_Contact* 1467 GNUNET_CHAT_message_get_recipient (const struct GNUNET_CHAT_Message *message); 1468 1469 /** 1470 * Returns #GNUNET_YES if the <i>message</i> was sent by the related chat 1471 * handle, otherwise it returns #GNUNET_NO. 1472 * 1473 * @param[in] message Message 1474 * @return #GNUNET_YES if the message was sent, otherwise #GNUNET_NO 1475 */ 1476 enum GNUNET_GenericReturnValue 1477 GNUNET_CHAT_message_is_sent (const struct GNUNET_CHAT_Message *message); 1478 1479 /** 1480 * Returns #GNUNET_YES if the <i>message</i> was received privately encrypted 1481 * by the related chat handle, otherwise it returns #GNUNET_NO. 1482 * 1483 * @param[in] message Message 1484 * @return #GNUNET_YES if the message was privately received, 1485 * otherwise #GNUNET_NO 1486 */ 1487 enum GNUNET_GenericReturnValue 1488 GNUNET_CHAT_message_is_private (const struct GNUNET_CHAT_Message *message); 1489 1490 /** 1491 * Returns #GNUNET_YES if the <i>message</i> was received recently by related 1492 * chat handle, otherwise it returns #GNUNET_NO. 1493 * 1494 * @param[in] message Message 1495 * @return #GNUNET_YES if the message was received recently, 1496 * otherwise #GNUNET_NO 1497 */ 1498 enum GNUNET_GenericReturnValue 1499 GNUNET_CHAT_message_is_recent (const struct GNUNET_CHAT_Message *message); 1500 1501 /** 1502 * Returns #GNUNET_YES if the <i>message</i> was received because of an 1503 * update by related chat handle, otherwise it returns #GNUNET_NO. 1504 * 1505 * @param[in] message Message 1506 * @return #GNUNET_YES if the message was received to update 1507 * a previous message, otherwise #GNUNET_NO 1508 */ 1509 enum GNUNET_GenericReturnValue 1510 GNUNET_CHAT_message_is_update (const struct GNUNET_CHAT_Message *message); 1511 1512 /** 1513 * Returns #GNUNET_YES if the <i>message</i> was received because of a 1514 * deletion by related chat handle or if it has been deleted internally, 1515 * otherwise it returns #GNUNET_NO. 1516 * 1517 * @param[in] message Message 1518 * @return #GNUNET_YES if the message was received to delete 1519 * a previous message, otherwise #GNUNET_NO 1520 */ 1521 enum GNUNET_GenericReturnValue 1522 GNUNET_CHAT_message_is_deleted (const struct GNUNET_CHAT_Message *message); 1523 1524 /** 1525 * Returns #GNUNET_YES if the <i>message</i> was tagged with a custom 1526 * <i>tag</i> value, otherwise it returns #GNUNET_NO. 1527 * 1528 * @param[in] message Message 1529 * @return #GNUNET_YES if the message was tagged with 1530 * the given tag value, otherwise #GNUNET_NO 1531 */ 1532 enum GNUNET_GenericReturnValue 1533 GNUNET_CHAT_message_is_tagged (const struct GNUNET_CHAT_Message *message, 1534 const char *tag); 1535 1536 /** 1537 * Iterates through the contacts of the context related to a given chat 1538 * <i>message</i> to check whether it was received by each of the contacts. 1539 * 1540 * @param[in,out] message Message 1541 * @param[in] callback Callback for contact iteration (optional) 1542 * @param[in,out] cls Closure for contact iteration (optional) 1543 * @return Amount of contacts iterated or #GNUNET_SYSERR on failure 1544 */ 1545 int 1546 GNUNET_CHAT_message_get_read_receipt (struct GNUNET_CHAT_Message *message, 1547 GNUNET_CHAT_MessageReadReceiptCallback callback, 1548 void *cls); 1549 1550 /** 1551 * Returns the text of a given <i>message</i> if its kind is 1552 * #GNUNET_CHAT_KIND_TEXT or #GNUNET_CHAT_KIND_WARNING, 1553 * otherwise it returns NULL. 1554 * 1555 * @param[in] message Message 1556 * @return The text of message or NULL 1557 */ 1558 const char* 1559 GNUNET_CHAT_message_get_text (const struct GNUNET_CHAT_Message *message); 1560 1561 /** 1562 * Returns the account of a given <i>message</i> which is either 1563 * its sender or target of the message depending on the kind of 1564 * the message, otherwise it returns NULL. 1565 * 1566 * @param[in] message Message 1567 * @return The account of message or NULL 1568 */ 1569 struct GNUNET_CHAT_Account* 1570 GNUNET_CHAT_message_get_account (const struct GNUNET_CHAT_Message *message); 1571 1572 /** 1573 * Returns the file handle of a given <i>message</i> if its kind is 1574 * #GNUNET_CHAT_KIND_FILE, otherwise it returns NULL. 1575 * 1576 * @param[in] message Message 1577 * @return The file handle of message or NULL 1578 */ 1579 struct GNUNET_CHAT_File* 1580 GNUNET_CHAT_message_get_file (const struct GNUNET_CHAT_Message *message); 1581 1582 /** 1583 * Returns the invitation of a given <i>message</i> if its kind is 1584 * #GNUNET_CHAT_KIND_INVITATION, otherwise it returns NULL. 1585 * 1586 * @param[in] message Message 1587 * @return The invitation of message or NULL 1588 */ 1589 struct GNUNET_CHAT_Invitation* 1590 GNUNET_CHAT_message_get_invitation (const struct GNUNET_CHAT_Message *message); 1591 1592 /** 1593 * Returns the discourse of a given <i>message</i> if its kind is 1594 * #GNUNET_CHAT_KIND_DISCOURSE or #GNUNET_CHAT_KIND_DATA, 1595 * otherwise it returns NULL. 1596 * 1597 * @param[in] message Message 1598 * @return The discourse of message or NULL 1599 */ 1600 struct GNUNET_CHAT_Discourse* 1601 GNUNET_CHAT_message_get_discourse (const struct GNUNET_CHAT_Message *message); 1602 1603 /** 1604 * Returns the target message of an operation represented by a given 1605 * <i>message</i> if its kind is #GNUNET_CHAT_KIND_DELETION, otherwise it 1606 * returns NULL. 1607 * 1608 * @param[in] message Message 1609 * @return The target of message or NULL 1610 */ 1611 struct GNUNET_CHAT_Message* 1612 GNUNET_CHAT_message_get_target (const struct GNUNET_CHAT_Message *message); 1613 1614 /** 1615 * Deletes a given <i>message</i> with a specific relative <i>delay</i> 1616 * in seconds. 1617 * 1618 * @param[in,out] message Message 1619 * @param[in] delay Relative delay 1620 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 1621 */ 1622 enum GNUNET_GenericReturnValue 1623 GNUNET_CHAT_message_delete (struct GNUNET_CHAT_Message *message, 1624 unsigned int delay); 1625 1626 /** 1627 * Iterates through the tag messages in the context of a given 1628 * <i>message</i>. 1629 * 1630 * @param[in,out] message Message 1631 * @param[in] callback Callback for tag message iteration (optional) 1632 * @param[in,out] cls Closure for tag message iteration (optional) 1633 * @return Amount of tag messages iterated or #GNUNET_SYSERR on failure 1634 */ 1635 int 1636 GNUNET_CHAT_message_iterate_tags (struct GNUNET_CHAT_Message *message, 1637 GNUNET_CHAT_MessageCallback callback, 1638 void *cls); 1639 1640 /** 1641 * Returns the amount of data from a given chat <i>message</i> if its 1642 * kind is #GNUNET_CHAT_KIND_DATA, otherwise it returns zero. 1643 * 1644 * @param[in] message Message 1645 * @return The amount of data or zero 1646 */ 1647 uint64_t 1648 GNUNET_CHAT_message_available (const struct GNUNET_CHAT_Message *message); 1649 1650 /** 1651 * Reads the data from a given chat <i>message</i> if its kind is 1652 * #GNUNET_CHAT_KIND_DATA into a specific <i>data</i> buffer 1653 * up to a selected <i>size</i>. 1654 * 1655 * @param[in] message Message 1656 * @param[out] data Data buffer 1657 * @param[in] size Data size 1658 * @return #GNUNET_OK on success, #GNUNET_NO if there's missing data 1659 * to read, otherwise #GNUNET_SYSERR on failure 1660 */ 1661 enum GNUNET_GenericReturnValue 1662 GNUNET_CHAT_message_read (const struct GNUNET_CHAT_Message *message, 1663 char *data, 1664 uint64_t size); 1665 1666 /** 1667 * Feeds the data from a given chat <i>message</i> if its kind is 1668 * #GNUNET_CHAT_KIND_DATA into a specific file descriptor (of pipe for 1669 * example). 1670 * 1671 * @param[in] message Message 1672 * @param[in] fd File descriptor 1673 * @return #GNUNET_OK on success, #GNUNET_NO if there's not enough data 1674 * to read, otherwise #GNUNET_SYSERR on failure 1675 */ 1676 enum GNUNET_GenericReturnValue 1677 GNUNET_CHAT_message_feed (const struct GNUNET_CHAT_Message *message, 1678 int fd); 1679 1680 /** 1681 * Returns the name of a given <i>file</i> handle. 1682 * 1683 * @param[in] file File handle 1684 * @return The file name of file 1685 */ 1686 const char* 1687 GNUNET_CHAT_file_get_name (const struct GNUNET_CHAT_File *file); 1688 1689 /** 1690 * Returns the hash of a given <i>file</i> handle. 1691 * 1692 * @param[in] file File handle 1693 * @return The hash of file 1694 */ 1695 const char* 1696 GNUNET_CHAT_file_get_hash (const struct GNUNET_CHAT_File *file); 1697 1698 /** 1699 * Returns the actual file size of a given <i>file</i> handle. 1700 * 1701 * @param[in] file File handle 1702 * @return The file size of file 1703 */ 1704 uint64_t 1705 GNUNET_CHAT_file_get_size (const struct GNUNET_CHAT_File *file); 1706 1707 /** 1708 * Returns the local file size of a given <i>file</i> handle. 1709 * 1710 * This can be less than the actual size of the file once its download 1711 * has been completed! 1712 * 1713 * @param[in] file File handle 1714 * @return The local file size of file 1715 */ 1716 uint64_t 1717 GNUNET_CHAT_file_get_local_size (const struct GNUNET_CHAT_File *file); 1718 1719 /** 1720 * Returns a new allocated uri to access the content of a given 1721 * <i>file</i> handle. 1722 * 1723 * @param[in] file File handle 1724 * @return URI on success, NULL on error 1725 */ 1726 struct GNUNET_CHAT_Uri* 1727 GNUNET_CHAT_file_get_uri (const struct GNUNET_CHAT_File *file); 1728 1729 /** 1730 * Returns if a given <i>file</i> handle is currently uploading. 1731 * 1732 * @param[in] file File handle 1733 * @return #GNUNET_YES during active upload, #GNUNET_NO otherwise 1734 */ 1735 enum GNUNET_GenericReturnValue 1736 GNUNET_CHAT_file_is_uploading (const struct GNUNET_CHAT_File *file); 1737 1738 /** 1739 * Returns if a given <i>file</i> handle is currently ready 1740 * for previewing its content. 1741 * 1742 * @param[in] file File handle 1743 * @return #GNUNET_YES when ready, #GNUNET_NO otherwise 1744 */ 1745 enum GNUNET_GenericReturnValue 1746 GNUNET_CHAT_file_is_ready (const struct GNUNET_CHAT_File *file); 1747 1748 /** 1749 * Returns the temporary file name of the decrypted file preview 1750 * of a given <i>file</i> handle. 1751 * 1752 * This can only be used when the file handle is ready to preview! 1753 * @see GNUNET_CHAT_file_is_ready() 1754 * 1755 * @param[in,out] file File handle 1756 * @return The temporary file name or NULL on error 1757 */ 1758 const char* 1759 GNUNET_CHAT_file_open_preview (struct GNUNET_CHAT_File *file); 1760 1761 /** 1762 * Deletes the temporary decrypted file preview of a given <i>file</i> 1763 * handle. 1764 * 1765 * This can only be used when the file handle is ready to preview! 1766 * @see GNUNET_CHAT_file_is_ready() 1767 * 1768 * @param[out] file File handle 1769 */ 1770 void 1771 GNUNET_CHAT_file_close_preview (struct GNUNET_CHAT_File *file); 1772 1773 /** 1774 * Sets a custom <i>user pointer</i> to a given <i>file</i> handle so it can 1775 * be accessed in file related callbacks. 1776 * 1777 * @param[in,out] file File handle 1778 * @param[in] user_pointer Custom user pointer 1779 */ 1780 void 1781 GNUNET_CHAT_file_set_user_pointer (struct GNUNET_CHAT_File *file, 1782 void *user_pointer); 1783 1784 /** 1785 * Returns the custom user pointer of a given <i>file</i> handle or NULL if it 1786 * was not set any. 1787 * 1788 * @param[in] file File handle 1789 * @return Custom user pointer 1790 */ 1791 void* 1792 GNUNET_CHAT_file_get_user_pointer (const struct GNUNET_CHAT_File *file); 1793 1794 /** 1795 * Returns if a given <i>file</i> handle is currently downloading. 1796 * 1797 * @param[in] file File handle 1798 * @return #GNUNET_YES during active download, #GNUNET_NO otherwise 1799 */ 1800 enum GNUNET_GenericReturnValue 1801 GNUNET_CHAT_file_is_downloading (const struct GNUNET_CHAT_File *file); 1802 1803 /** 1804 * Starts downloading a file from a given <i>file</i> handle and sets up a 1805 * selected callback and custom closure for its progress. 1806 * 1807 * @param[in,out] file File handle 1808 * @param[in] callback Callback for file downloading (optional) 1809 * @param[in,out] cls Closure for file downloading (optional) 1810 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 1811 */ 1812 enum GNUNET_GenericReturnValue 1813 GNUNET_CHAT_file_start_download (struct GNUNET_CHAT_File *file, 1814 GNUNET_CHAT_FileDownloadCallback callback, 1815 void *cls); 1816 1817 /** 1818 * Pause downloading a file from a given <i>file</i> handle. 1819 * 1820 * @param[in,out] file File handle 1821 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 1822 */ 1823 enum GNUNET_GenericReturnValue 1824 GNUNET_CHAT_file_pause_download (struct GNUNET_CHAT_File *file); 1825 1826 /** 1827 * Resume downloading a file from a given <i>file</i> handle. 1828 * 1829 * @param[in,out] file File handle 1830 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 1831 */ 1832 enum GNUNET_GenericReturnValue 1833 GNUNET_CHAT_file_resume_download (struct GNUNET_CHAT_File *file); 1834 1835 /** 1836 * Stops downloading a file from a given <i>file</i> handle. 1837 * 1838 * @param[in,out] file File handle 1839 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 1840 */ 1841 enum GNUNET_GenericReturnValue 1842 GNUNET_CHAT_file_stop_download (struct GNUNET_CHAT_File *file); 1843 1844 /** 1845 * Returns if a given <i>file</i> handle is currently unindexing. 1846 * 1847 * @param[in] file File handle 1848 * @return #GNUNET_YES during active unindexing, #GNUNET_NO otherwise 1849 */ 1850 enum GNUNET_GenericReturnValue 1851 GNUNET_CHAT_file_is_unindexing (const struct GNUNET_CHAT_File *file); 1852 1853 /** 1854 * Unindexes an uploaded file from a given <i>file</i> handle with a selected 1855 * callback and a custom closure. 1856 * 1857 * @param[in,out] file File handle 1858 * @param[in] callback Callback for file unindexing (optional) 1859 * @param[in,out] cls Closure for file unindexing (optional) 1860 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 1861 */ 1862 enum GNUNET_GenericReturnValue 1863 GNUNET_CHAT_file_unindex (struct GNUNET_CHAT_File *file, 1864 GNUNET_CHAT_FileUnindexCallback callback, 1865 void *cls); 1866 1867 /** 1868 * Accepts a given chat <i>invitation</i> to enter another chat. 1869 * 1870 * @param[in,out] invitation Chat invitation 1871 */ 1872 void 1873 GNUNET_CHAT_invitation_accept (struct GNUNET_CHAT_Invitation *invitation); 1874 1875 /** 1876 * Rejects a given chat <i>invitation</i> to enter another chat. 1877 * 1878 * @param[in,out] invitation Chat invitation 1879 */ 1880 void 1881 GNUNET_CHAT_invitation_reject (struct GNUNET_CHAT_Invitation *invitation); 1882 1883 /** 1884 * Returns if a given <i>invitation</i> got accepted. 1885 * 1886 * @param[in] invitation Chat invitation 1887 * @return #GNUNET_YES if accepted, #GNUNET_NO otherwise 1888 */ 1889 enum GNUNET_GenericReturnValue 1890 GNUNET_CHAT_invitation_is_accepted (const struct GNUNET_CHAT_Invitation *invitation); 1891 1892 /** 1893 * Returns if a given <i>invitation</i> got rejected. 1894 * 1895 * @param[in] invitation Chat invitation 1896 * @return #GNUNET_YES if rejected, #GNUNET_NO otherwise 1897 */ 1898 enum GNUNET_GenericReturnValue 1899 GNUNET_CHAT_invitation_is_rejected (const struct GNUNET_CHAT_Invitation *invitation); 1900 1901 /** 1902 * Returns the discourse id of a given chat <i>discourse</i>. 1903 * 1904 * @param[in] discourse Chat discourse 1905 * @return Discourse id 1906 */ 1907 const struct GNUNET_CHAT_DiscourseId* 1908 GNUNET_CHAT_discourse_get_id (const struct GNUNET_CHAT_Discourse *discourse); 1909 1910 /** 1911 * Returns whether a chat <i>discourse</i> is currently open. 1912 * 1913 * @param[in] discourse Chat discourse 1914 * @return #GNUNET_YES if the discourse is open, #GNUNET_SYSERR on failure and 1915 * #GNUNET_NO otherwise. 1916 */ 1917 enum GNUNET_GenericReturnValue 1918 GNUNET_CHAT_discourse_is_open (const struct GNUNET_CHAT_Discourse *discourse); 1919 1920 /** 1921 * Sets a custom <i>user pointer</i> to a given chat <i>discourse</i> so it can 1922 * be accessed in chat discourse related callbacks. 1923 * 1924 * @param[in,out] discourse Chat discourse 1925 * @param[in] user_pointer Custom user pointer 1926 */ 1927 void 1928 GNUNET_CHAT_discourse_set_user_pointer (struct GNUNET_CHAT_Discourse *discourse, 1929 void *user_pointer); 1930 1931 /** 1932 * Returns the custom user pointer of a given chat <i>discourse</i> or NULL if it 1933 * was not set any. 1934 * 1935 * @param[in] discourse Chat discourse 1936 * @return Custom user pointer or NULL 1937 */ 1938 void* 1939 GNUNET_CHAT_discourse_get_user_pointer (const struct GNUNET_CHAT_Discourse *discourse); 1940 1941 /** 1942 * Closes a given chat <i>discourse</i> to stop receiving any data messages 1943 * from the specific discourse. 1944 * 1945 * @param[in,out] discourse Chat discourse 1946 */ 1947 void 1948 GNUNET_CHAT_discourse_close (struct GNUNET_CHAT_Discourse *discourse); 1949 1950 /** 1951 * Sends messages to a given chat <i>discourse</i> containing the 1952 * specified <i>data</i> of a custom <i>size</i> in bytes. 1953 * 1954 * @param[in,out] discourse Chat discourse 1955 * @param[in] data Data buffer 1956 * @param[in] size Data size 1957 * @return #GNUNET_OK on success, otherwise #GNUNET_SYSERR 1958 */ 1959 enum GNUNET_GenericReturnValue 1960 GNUNET_CHAT_discourse_write (struct GNUNET_CHAT_Discourse *discourse, 1961 const char *data, 1962 uint64_t size); 1963 1964 /** 1965 * Returns a file descriptor of a pipe to write data via IPC 1966 * into the given chat <i>discourse</i>. 1967 * 1968 * @param[in] discourse Chat discourse 1969 * @return File descriptor of pipe end or #GNUNET_SYSERR on failure 1970 */ 1971 int 1972 GNUNET_CHAT_discourse_get_fd (const struct GNUNET_CHAT_Discourse *discourse); 1973 1974 /** 1975 * Iterates through the subscribed chat contacts of a given chat <i>discourse</i> 1976 * with a selected callback and custom closure. 1977 * 1978 * @param[in,out] discourse Chat discourse 1979 * @param[in] callback Callback for contact iteration (optional) 1980 * @param[in,out] cls Closure for contact iteration (optional) 1981 * @return Amount of contacts iterated or #GNUNET_SYSERR on failure 1982 */ 1983 int 1984 GNUNET_CHAT_discourse_iterate_contacts (struct GNUNET_CHAT_Discourse *discourse, 1985 GNUNET_CHAT_DiscourseContactCallback callback, 1986 void *cls); 1987 1988 /**@}*/ 1989 1990 #endif /* GNUNET_CHAT_LIB_H_ */