Changes in protocols/nogaim.c [977a9d5:9076a1c]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.c
r977a9d5 r9076a1c 90 90 91 91 GList *protocols = NULL; 92 GList *disabled_protocols = NULL;93 92 94 93 void register_protocol(struct prpl *p) … … 104 103 105 104 if (refused) { 106 disabled_protocols = g_list_append(disabled_protocols, p);105 log_message(LOGLVL_WARNING, "Protocol %s disabled\n", p->name); 107 106 } else { 108 107 protocols = g_list_append(protocols, p); … … 110 109 } 111 110 112 static int proto_name_cmp(const void *proto_, const void *name)113 {114 const struct prpl *proto = proto_;115 return g_strcasecmp(proto->name, name);116 }117 118 111 struct prpl *find_protocol(const char *name) 119 112 { 120 GList *gl = g_list_find_custom(protocols, name, proto_name_cmp); 121 return gl ? gl->data: NULL; 122 } 123 124 gboolean is_protocol_disabled(const char *name) 125 { 126 return g_list_find_custom(disabled_protocols, name, proto_name_cmp) != NULL; 113 GList *gl; 114 115 for (gl = protocols; gl; gl = gl->next) { 116 struct prpl *proto = gl->data; 117 118 if (g_strcasecmp(proto->name, name) == 0) { 119 return proto; 120 } 121 } 122 123 return NULL; 127 124 } 128 125 … … 135 132 extern void twitter_initmodule(); 136 133 extern void purple_initmodule(); 134 extern void rpc_initmodule(); 137 135 138 136 #ifdef WITH_MSN … … 158 156 #ifdef WITH_PURPLE 159 157 purple_initmodule(); 158 #endif 159 160 #ifdef WITH_RPC 161 rpc_initmodule(); 160 162 #endif 161 163 … … 207 209 account_t *a; 208 210 209 if (!ic->bee->ui->log) {210 return;211 }212 213 211 va_start(params, format); 214 212 text = g_strdup_vprintf(format, params); … … 229 227 /* If we found one, include the screenname in the message. */ 230 228 if (a) { 231 ic->bee->ui->log(ic->bee, ic->acc->tag, text); 229 /* FIXME(wilmer): ui_log callback or so */ 230 irc_rootmsg(ic->bee->ui_data, "%s - %s", ic->acc->tag, text); 232 231 } else { 233 i c->bee->ui->log(ic->bee, ic->acc->prpl->name, text);232 irc_rootmsg(ic->bee->ui_data, "%s - %s", ic->acc->prpl->name, text); 234 233 } 235 234 … … 313 312 } 314 313 315 if (ic->acc->flags & ACC_FLAG_LOCAL) { 314 if ((ic->acc->flags & ACC_FLAG_LOCAL_CONTACTS) && 315 !(ic->flags & OPT_LOCAL_CONTACTS_SENT) && 316 ic->acc->prpl->add_buddy) { 316 317 GHashTableIter nicks; 317 gpointer k, v;318 gpointer handle; 318 319 g_hash_table_iter_init(&nicks, ic->acc->nicks); 319 while (g_hash_table_iter_next(&nicks, & k, &v)) {320 ic->acc->prpl->add_buddy(ic, (char *) k, NULL);320 while (g_hash_table_iter_next(&nicks, &handle, NULL)) { 321 ic->acc->prpl->add_buddy(ic, (char *) handle, NULL); 321 322 } 322 323 } … … 413 414 query_del_by_conn((irc_t *) ic->bee->ui_data, ic); 414 415 416 /* Throw away groupchats owned by this account. Historically this was only 417 ever done by IM modules which is a bug. But it gives them opportunity 418 to clean up protocol-specific bits as well so keep it that way, just 419 do another cleanup here as a fallback. Don't want to leave any dangling 420 pointers! */ 421 while (ic->groupchats) { 422 imcb_chat_free(ic->groupchats->data); 423 } 424 415 425 if (!a) { 416 426 /* Uhm... This is very sick. */ … … 498 508 } 499 509 510 /* Returns the local contacts for an IM account (based on assigned nicks). 511 Linked list should be freed, the strings themselves not! So look at it 512 like a GSList<const char*> I guess? Empty list means NULL retval (as 513 always with GSList). */ 514 GSList *imcb_get_local_contacts(struct im_connection *ic) 515 { 516 GHashTableIter nicks; 517 GSList *ret = NULL; 518 519 if (!(ic->acc->flags & ACC_FLAG_LOCAL_CONTACTS)) { 520 /* Only allow protocols that indicate local contact list 521 support to use this function. */ 522 return ret; 523 } 524 525 g_hash_table_iter_init(&nicks, ic->acc->nicks); 526 gpointer handle; 527 while (g_hash_table_iter_next(&nicks, &handle, NULL)) { 528 ret = g_slist_prepend(ret, (char *) handle); 529 } 530 531 /* If the protocol asked for the list, assume we won't have to send it 532 anymore in imcb_connected(). */ 533 ic->flags |= OPT_LOCAL_CONTACTS_SENT; 534 535 return ret; 536 } 537 500 538 501 539 struct imcb_ask_cb_data { … … 556 594 struct imcb_ask_cb_data *cbd = data; 557 595 558 cbd->ic->acc->prpl->add_buddy(cbd->ic, cbd->handle, NULL); 596 if (cbd->ic->acc->prpl->add_buddy) { 597 cbd->ic->acc->prpl->add_buddy(cbd->ic, cbd->handle, NULL); 598 } 559 599 560 600 imcb_ask_cb_free(data); … … 622 662 GList *m = ic->acc->prpl->away_states(ic); 623 663 msg = ic->acc->flags & ACC_FLAG_AWAY_MESSAGE ? away : NULL; 624 away = imc_away_state_find(m, away, &msg) ? : 625 (imc_away_state_find(m, "away", &msg) ? : m->data); 664 away = imc_away_state_find(m, away, &msg) ? : m->data; 626 665 } else if (ic->acc->flags & ACC_FLAG_STATUS_MESSAGE) { 627 666 away = NULL; … … 742 781 } 743 782 744 /* Deprecated: using this function resulted in merging several handles accidentally745 * Also the irc layer handles this decently nowadays */746 783 void imcb_clean_handle(struct im_connection *ic, char *handle) 747 784 { 748 } 785 /* Accepts a handle and does whatever is necessary to make it 786 BitlBee-friendly. Currently this means removing everything 787 outside 33-127 (ASCII printable excl spaces), @ (only one 788 is allowed) and ! and : */ 789 char out[strlen(handle) + 1]; 790 int s, d; 791 792 s = d = 0; 793 while (handle[s]) { 794 if (handle[s] > ' ' && handle[s] != '!' && handle[s] != ':' && 795 (handle[s] & 0x80) == 0) { 796 if (handle[s] == '@') { 797 /* See if we got an @ already? */ 798 out[d] = 0; 799 if (strchr(out, '@')) { 800 continue; 801 } 802 } 803 804 out[d++] = handle[s]; 805 } 806 s++; 807 } 808 out[d] = handle[s]; 809 810 strcpy(handle, out); 811 }
Note: See TracChangeset
for help on using the changeset viewer.