Changeset 8c3637b
- Timestamp:
- 2015-05-24T19:43:09Z (9 years ago)
- Children:
- a852b2b
- Parents:
- 93e0901
- Location:
- protocols
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.c
r93e0901 r8c3637b 312 312 } 313 313 314 if (ic->acc->flags & ACC_FLAG_LOCAL_CONTACTS) { 314 if ((ic->acc->flags & ACC_FLAG_LOCAL_CONTACTS) && 315 !(ic->flags & OPT_LOCAL_CONTACTS_SENT)) { 315 316 GHashTableIter nicks; 316 gpointer k, v;317 gpointer handle; 317 318 g_hash_table_iter_init(&nicks, ic->acc->nicks); 318 while (g_hash_table_iter_next(&nicks, & k, &v)) {319 ic->acc->prpl->add_buddy(ic, (char *) k, NULL);319 while (g_hash_table_iter_next(&nicks, &handle, NULL)) { 320 ic->acc->prpl->add_buddy(ic, (char *) handle, NULL); 320 321 } 321 322 } … … 495 496 bee->ui->user_nick_hint(bee, bu, nick); 496 497 } 498 } 499 500 /* Returns the local contacts for an IM account (based on assigned nicks). 501 Linked list should be freed, the strings themselves not! So look at it 502 like a GSList<const char*> I guess? Empty list means NULL retval (as 503 always with GSList). */ 504 GSList *imcb_get_local_contacts(struct im_connection *ic) 505 { 506 GHashTableIter nicks; 507 GSList *ret = NULL; 508 509 g_hash_table_iter_init(&nicks, ic->acc->nicks); 510 gpointer handle; 511 while (g_hash_table_iter_next(&nicks, &handle, NULL)) { 512 ret = g_slist_prepend(ret, (char *) handle); 513 } 514 515 /* If the protocol asked for the list, assume we won't have to send it 516 anymore in imcb_connected(). */ 517 ic->flags |= OPT_LOCAL_CONTACTS_SENT; 518 519 return ret; 497 520 } 498 521 -
protocols/nogaim.h
r93e0901 r8c3637b 57 57 58 58 /* Sharing flags between all kinds of things. I just hope I won't hit any 59 limits before 32-bit machines become extinct. ;-) */ 59 limits before 32-bit machines become extinct. ;-) 60 61 Argh! This needs to be renamed to be more clear which field they're used 62 for. As said it's currently mixed which is nonsense. Some are for the 63 im_connection flags field, some for imcb_buddy_status(), some for typing 64 notifications, and who knows what else... */ 60 65 #define OPT_LOGGED_IN 0x00000001 61 66 #define OPT_LOGGING_OUT 0x00000002 … … 70 75 #define OPT_PONGS 0x00010000 /* Service sends us keep-alives */ 71 76 #define OPT_PONGED 0x00020000 /* Received a keep-alive during last interval */ 77 #define OPT_LOCAL_CONTACTS_SENT 0x00040000 /* Protocol already requested local contact list, so don't send it after finishing login. */ 72 78 73 79 /* ok. now the fun begins. first we create a connection structure */ … … 324 330 G_MODULE_EXPORT void imcb_buddy_nick_hint(struct im_connection *ic, const char *handle, const char *nick); 325 331 G_MODULE_EXPORT void imcb_buddy_action_response(bee_user_t *bu, const char *action, char * const args[], void *data); 332 G_MODULE_EXPORT GSList *imcb_get_local_contacts(struct im_connection *ic); 326 333 327 334 G_MODULE_EXPORT void imcb_buddy_typing(struct im_connection *ic, const char *handle, uint32_t flags); -
protocols/rpc/rpc.c
r93e0901 r8c3637b 605 605 } 606 606 607 static JSON_Value *rpc_imcb_get_local_contacts(struct im_connection *ic, void *func_, JSON_Array *params) { 608 JSON_Value *resp = json_value_init_object(); 609 JSON_Value *arr = json_value_init_array(); 610 GSList *contacts = imcb_get_local_contacts(ic); 611 GSList *c; 612 for (c = contacts; c; c = c->next) { 613 json_array_append_string(json_array(arr), (const char*) c->data); 614 } 615 g_slist_free(contacts); 616 json_object_set_value(json_object(resp), "result", arr); 617 return resp; 618 } 619 607 620 static JSON_Value *rpc_imcb_chat_new(struct im_connection *ic, void *func_, JSON_Array *params) { 608 621 struct rpc_groupchat *rc = rpc_groupchat_new(ic, json_array_get_string(params, 0)); … … 719 732 { "imcb_buddy_msg", imcb_buddy_msg, rpc_imcb_buddy_msg, "ssii" }, 720 733 { "imcb_buddy_typing", imcb_buddy_typing, rpc_imcb_buddy_typing, "si" }, 734 { "imcb_get_local_contacts", NULL, rpc_imcb_get_local_contacts, "" }, 721 735 { "imcb_chat_new", NULL, rpc_imcb_chat_new, "s" }, 722 736
Note: See TracChangeset
for help on using the changeset viewer.