Changeset 3fbce97 for protocols/nogaim.c


Ignore:
Timestamp:
2016-09-24T20:14:34Z (8 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Children:
ba52ac5
Parents:
63cad66 (diff), 82cb190 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into parson

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/nogaim.c

    r63cad66 r3fbce97  
    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
     
    209212        account_t *a;
    210213
     214        if (!ic->bee->ui->log) {
     215                return;
     216        }
     217
    211218        va_start(params, format);
    212219        text = g_strdup_vprintf(format, params);
     
    227234        /* If we found one, include the screenname in the message. */
    228235        if (a) {
    229                 /* FIXME(wilmer): ui_log callback or so */
    230                 irc_rootmsg(ic->bee->ui_data, "%s - %s", ic->acc->tag, text);
     236                ic->bee->ui->log(ic->bee, ic->acc->tag, text);
    231237        } else {
    232                 irc_rootmsg(ic->bee->ui_data, "%s - %s", ic->acc->prpl->name, text);
     238                ic->bee->ui->log(ic->bee, ic->acc->prpl->name, text);
    233239        }
    234240
     
    662668                GList *m = ic->acc->prpl->away_states(ic);
    663669                msg = ic->acc->flags & ACC_FLAG_AWAY_MESSAGE ? away : NULL;
    664                 away = imc_away_state_find(m, away, &msg) ? : m->data;
     670                away = imc_away_state_find(m, away, &msg) ? :
     671                       (imc_away_state_find(m, "away", &msg) ? : m->data);
    665672        } else if (ic->acc->flags & ACC_FLAG_STATUS_MESSAGE) {
    666673                away = NULL;
     
    781788}
    782789
     790/* Deprecated: using this function resulted in merging several handles accidentally
     791 * Also the irc layer handles this decently nowadays */
    783792void imcb_clean_handle(struct im_connection *ic, char *handle)
    784793{
    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 }
     794}
Note: See TracChangeset for help on using the changeset viewer.