Changes in protocols/nogaim.c [9076a1c:977a9d5]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.c
r9076a1c r977a9d5 90 90 91 91 GList *protocols = NULL; 92 GList *disabled_protocols = NULL; 92 93 93 94 void register_protocol(struct prpl *p) … … 103 104 104 105 if (refused) { 105 log_message(LOGLVL_WARNING, "Protocol %s disabled\n", p->name);106 disabled_protocols = g_list_append(disabled_protocols, p); 106 107 } else { 107 108 protocols = g_list_append(protocols, p); … … 109 110 } 110 111 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 111 118 struct prpl *find_protocol(const char *name) 112 119 { 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; 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; 124 127 } 125 128 … … 132 135 extern void twitter_initmodule(); 133 136 extern void purple_initmodule(); 134 extern void rpc_initmodule();135 137 136 138 #ifdef WITH_MSN … … 156 158 #ifdef WITH_PURPLE 157 159 purple_initmodule(); 158 #endif159 160 #ifdef WITH_RPC161 rpc_initmodule();162 160 #endif 163 161 … … 209 207 account_t *a; 210 208 209 if (!ic->bee->ui->log) { 210 return; 211 } 212 211 213 va_start(params, format); 212 214 text = g_strdup_vprintf(format, params); … … 227 229 /* If we found one, include the screenname in the message. */ 228 230 if (a) { 229 /* FIXME(wilmer): ui_log callback or so */ 230 irc_rootmsg(ic->bee->ui_data, "%s - %s", ic->acc->tag, text); 231 ic->bee->ui->log(ic->bee, ic->acc->tag, text); 231 232 } else { 232 i rc_rootmsg(ic->bee->ui_data, "%s - %s", ic->acc->prpl->name, text);233 ic->bee->ui->log(ic->bee, ic->acc->prpl->name, text); 233 234 } 234 235 … … 312 313 } 313 314 314 if ((ic->acc->flags & ACC_FLAG_LOCAL_CONTACTS) && 315 !(ic->flags & OPT_LOCAL_CONTACTS_SENT) && 316 ic->acc->prpl->add_buddy) { 315 if (ic->acc->flags & ACC_FLAG_LOCAL) { 317 316 GHashTableIter nicks; 318 gpointer handle;317 gpointer k, v; 319 318 g_hash_table_iter_init(&nicks, ic->acc->nicks); 320 while (g_hash_table_iter_next(&nicks, & handle, NULL)) {321 ic->acc->prpl->add_buddy(ic, (char *) handle, NULL);319 while (g_hash_table_iter_next(&nicks, &k, &v)) { 320 ic->acc->prpl->add_buddy(ic, (char *) k, NULL); 322 321 } 323 322 } … … 414 413 query_del_by_conn((irc_t *) ic->bee->ui_data, ic); 415 414 416 /* Throw away groupchats owned by this account. Historically this was only417 ever done by IM modules which is a bug. But it gives them opportunity418 to clean up protocol-specific bits as well so keep it that way, just419 do another cleanup here as a fallback. Don't want to leave any dangling420 pointers! */421 while (ic->groupchats) {422 imcb_chat_free(ic->groupchats->data);423 }424 425 415 if (!a) { 426 416 /* Uhm... This is very sick. */ … … 508 498 } 509 499 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 it512 like a GSList<const char*> I guess? Empty list means NULL retval (as513 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 list521 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 it532 anymore in imcb_connected(). */533 ic->flags |= OPT_LOCAL_CONTACTS_SENT;534 535 return ret;536 }537 538 500 539 501 struct imcb_ask_cb_data { … … 594 556 struct imcb_ask_cb_data *cbd = data; 595 557 596 if (cbd->ic->acc->prpl->add_buddy) { 597 cbd->ic->acc->prpl->add_buddy(cbd->ic, cbd->handle, NULL); 598 } 558 cbd->ic->acc->prpl->add_buddy(cbd->ic, cbd->handle, NULL); 599 559 600 560 imcb_ask_cb_free(data); … … 662 622 GList *m = ic->acc->prpl->away_states(ic); 663 623 msg = ic->acc->flags & ACC_FLAG_AWAY_MESSAGE ? away : NULL; 664 away = imc_away_state_find(m, away, &msg) ? : m->data; 624 away = imc_away_state_find(m, away, &msg) ? : 625 (imc_away_state_find(m, "away", &msg) ? : m->data); 665 626 } else if (ic->acc->flags & ACC_FLAG_STATUS_MESSAGE) { 666 627 away = NULL; … … 781 742 } 782 743 744 /* Deprecated: using this function resulted in merging several handles accidentally 745 * Also the irc layer handles this decently nowadays */ 783 746 void imcb_clean_handle(struct im_connection *ic, char *handle) 784 747 { 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 } 748 }
Note: See TracChangeset
for help on using the changeset viewer.