Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/nogaim.c

    r9076a1c r977a9d5  
    9090
    9191GList *protocols = NULL;
     92GList *disabled_protocols = NULL;
    9293
    9394void register_protocol(struct prpl *p)
     
    103104
    104105        if (refused) {
    105                 log_message(LOGLVL_WARNING, "Protocol %s disabled\n", p->name);
     106                disabled_protocols = g_list_append(disabled_protocols, p);
    106107        } else {
    107108                protocols = g_list_append(protocols, p);
     
    109110}
    110111
     112static 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
    111118struct prpl *find_protocol(const char *name)
    112119{
    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
     124gboolean is_protocol_disabled(const char *name)
     125{
     126        return g_list_find_custom(disabled_protocols, name, proto_name_cmp) != NULL;
    124127}
    125128
     
    132135        extern void twitter_initmodule();
    133136        extern void purple_initmodule();
    134         extern void rpc_initmodule();
    135137
    136138#ifdef WITH_MSN
     
    156158#ifdef WITH_PURPLE
    157159        purple_initmodule();
    158 #endif
    159 
    160 #ifdef WITH_RPC
    161         rpc_initmodule();
    162160#endif
    163161
     
    209207        account_t *a;
    210208
     209        if (!ic->bee->ui->log) {
     210                return;
     211        }
     212
    211213        va_start(params, format);
    212214        text = g_strdup_vprintf(format, params);
     
    227229        /* If we found one, include the screenname in the message. */
    228230        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);
    231232        } else {
    232                 irc_rootmsg(ic->bee->ui_data, "%s - %s", ic->acc->prpl->name, text);
     233                ic->bee->ui->log(ic->bee, ic->acc->prpl->name, text);
    233234        }
    234235
     
    312313        }
    313314
    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) {
    317316                GHashTableIter nicks;
    318                 gpointer handle;
     317                gpointer k, v;
    319318                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);
    322321                }
    323322        }
     
    414413        query_del_by_conn((irc_t *) ic->bee->ui_data, ic);
    415414
    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 
    425415        if (!a) {
    426416                /* Uhm... This is very sick. */
     
    508498}
    509499
    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 
    538500
    539501struct imcb_ask_cb_data {
     
    594556        struct imcb_ask_cb_data *cbd = data;
    595557
    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);
    599559
    600560        imcb_ask_cb_free(data);
     
    662622                GList *m = ic->acc->prpl->away_states(ic);
    663623                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);
    665626        } else if (ic->acc->flags & ACC_FLAG_STATUS_MESSAGE) {
    666627                away = NULL;
     
    781742}
    782743
     744/* Deprecated: using this function resulted in merging several handles accidentally
     745 * Also the irc layer handles this decently nowadays */
    783746void imcb_clean_handle(struct im_connection *ic, char *handle)
    784747{
    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.