Changeset b8c336b for protocols


Ignore:
Timestamp:
2015-05-09T19:50:30Z (9 years ago)
Author:
dequis <dx@…>
Children:
ec8b369
Parents:
356e2dd (diff), 5014380 (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 'develop' into feat/hip-cat

Conflicts:

protocols/jabber/hipchat.c
protocols/jabber/iq.c
protocols/jabber/jabber.h

Location:
protocols
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/hipchat.c

    r356e2dd rb8c336b  
    4747        jd->flags &= ~JFLAG_STREAM_RESTART;
    4848
    49         if (!jabber_get_roster(ic)) {
    50                 return XT_ABORT;
    51         }
    52         if (!jabber_iq_disco_server(ic)) {
    53                 return XT_ABORT;
    54         }
    55         if (!jabber_get_hipchat_profile(ic)) {
    56                 return XT_ABORT;
    57         }
    58         if (!jabber_iq_disco_muc(ic, muc_host)) {
     49        if (!jabber_get_roster(ic) ||
     50            !jabber_iq_disco_server(ic) ||
     51            !jabber_get_hipchat_profile(ic) ||
     52            !jabber_iq_disco_muc(ic, muc_host)) {
    5953                return XT_ABORT;
    6054        }
     
    8478{
    8579        struct xt_node *query, *name_node;
    86 
    87         //char *name;
    8880
    8981        if (!(query = xt_find_node(node->children, "query"))) {
  • protocols/jabber/iq.c

    r356e2dd rb8c336b  
    373373static xt_status jabber_parse_roster(struct im_connection *ic, struct xt_node *node, struct xt_node *orig)
    374374{
     375        struct jabber_data *jd = ic->proto_data;
    375376        struct xt_node *query, *c;
    376377        int initial = (orig != NULL);
     
    388389                char *sub = xt_find_attr(c, "subscription");
    389390                char *mention_name = xt_find_attr(c, "mention_name");
    390                 char *nick = mention_name ? : name;
    391391
    392392                if (jid && sub) {
     
    399399                                }
    400400
    401                                 if (nick) {
    402                                         imcb_buddy_nick_hint(ic, jid, nick);
     401                                /* This could also be used to set the full name as nick for fb/gtalk,
     402                                 * but i'm keeping the old (ugly?) default behavior just to be safe */
     403                                if (mention_name && (jd->flags & JFLAG_HIPCHAT)) {
     404                                        imcb_buddy_nick_hint(ic, jid, mention_name);
    403405                                }
    404406                        } else if (strcmp(sub, "remove") == 0) {
  • protocols/jabber/jabber.c

    r356e2dd rb8c336b  
    428428        }
    429429
    430         jabber_get_vcard(ic, bud ? bud->full_jid : who);
     430        jabber_get_vcard(ic, who);
    431431}
    432432
  • protocols/msn/gw.c

    r356e2dd rb8c336b  
    8787        gw->polling = FALSE;
    8888
     89        if (req->status_code != 200 || !req->reply_body) {
     90                gw->callback(gw->md, -1, B_EV_IO_READ);
     91                return;
     92        }
     93
    8994        if (getenv("BITLBEE_DEBUG")) {
    9095                fprintf(stderr, "\n\x1b[90mHTTP:%s\n", req->reply_body);
    9196                fprintf(stderr, "\n\x1b[97m\n");
    92         }
    93 
    94         if (req->status_code != 200) {
    95                 gw->callback(gw->md, -1, B_EV_IO_READ);
    96                 return;
    9797        }
    9898
     
    113113        if (req->body_size) {
    114114                g_byte_array_append(gw->in, (const guint8 *) req->reply_body, req->body_size);
    115                 gw->callback(gw->md, -1, B_EV_IO_READ);
     115
     116                if (!gw->callback(gw->md, -1, B_EV_IO_READ)) {
     117                        return;
     118                }
    116119        }
    117120
  • protocols/msn/ns.c

    r356e2dd rb8c336b  
    181181                imcb_error(ic, "Error while reading from server");
    182182                imc_logout(ic, TRUE);
     183                g_free(bytes);
    183184                return FALSE;
    184185        }
     
    188189        g_free(bytes);
    189190
    190         /* Ignore ret == 0, it's already disconnected then. */
    191         msn_handler(md);
    192 
    193         return TRUE;
    194        
     191        return msn_handler(md);
    195192}
    196193
  • protocols/oscar/ssi.c

    r356e2dd rb8c336b  
    6666                                newitem->gid += 0x0001;
    6767                                for (cur = *list, i = 0; ((cur) && (!i)); cur = cur->next) {
    68                                         if ((cur->gid == newitem->gid) && (cur->gid == newitem->gid)) {
     68                                        if ((cur->bid == newitem->bid) && (cur->gid == newitem->gid)) {
    6969                                                i = 1;
    7070                                        }
  • protocols/twitter/twitter.c

    r356e2dd rb8c336b  
    483483}
    484484
    485 static gboolean twitter_length_check(struct im_connection *ic, gchar * msg)
    486 {
    487         int max = set_getint(&ic->acc->set, "message_length"), len;
    488         int target_len = set_getint(&ic->acc->set, "target_url_length");
     485int twitter_message_len(gchar *msg, int target_len)
     486{
    489487        int url_len_diff = 0;
    490488
     
    493491        }
    494492
    495         if (max == 0 || (len = g_utf8_strlen(msg, -1) + url_len_diff) <= max) {
     493        return g_utf8_strlen(msg, -1) + url_len_diff;
     494}
     495
     496static gboolean twitter_length_check(struct im_connection *ic, gchar * msg)
     497{
     498        int max = set_getint(&ic->acc->set, "message_length");
     499        int target_len = set_getint(&ic->acc->set, "target_url_length");
     500        int len = twitter_message_len(msg, target_len);
     501
     502        if (max == 0 || len <= max) {
    496503                return TRUE;
    497504        }
     
    867874}
    868875
     876bee_user_t twitter_log_local_user;
     877
    869878/** Convert the given bitlbee tweet ID, bitlbee username, or twitter tweet ID
    870879 *  into a twitter tweet ID.
     
    897906                        bu = td->log[id].bu;
    898907                        id = td->log[id].id;
    899                         /* Beware of dangling pointers! */
    900                         if (!g_slist_find(ic->bee->users, bu)) {
    901                                 bu = NULL;
    902                         }
    903908                } else if (twitter_parse_id(arg, 10, &id)) {
    904909                        /* Allow normal tweet IDs as well; not a very useful
     
    911916        }
    912917        if (bu_) {
     918                if (bu == &twitter_log_local_user) {
     919                        /* HACK alert. There's no bee_user object for the local
     920                         * user so just fake one for the few cmds that need it. */
     921                        twitter_log_local_user.handle = td->user;
     922                } else {
     923                        /* Beware of dangling pointers! */
     924                        if (!g_slist_find(ic->bee->users, bu)) {
     925                                bu = NULL;
     926                        }
     927                }
    913928                *bu_ = bu;
    914929        }
     
    10031018                in_reply_to = id;
    10041019                allow_post = TRUE;
     1020        } else if (g_strcasecmp(cmd[0], "url") == 0) {
     1021                id = twitter_message_id_from_command_arg(ic, cmd[1], &bu);
     1022                if (!id) {
     1023                        twitter_log(ic, "Tweet `%s' does not exist", cmd[1]);
     1024                } else {
     1025                        /* More common link is twitter.com/$UID/status/$ID (and that's
     1026                         * what this will 302 to) but can't generate that since for RTs,
     1027                         * bu here points at the retweeter while id contains the id of
     1028                         * the original message. */
     1029                        twitter_log(ic, "https://twitter.com/statuses/%lld", id);
     1030                }
     1031                goto eof;
     1032
    10051033        } else if (g_strcasecmp(cmd[0], "post") == 0) {
    10061034                message += 5;
  • protocols/twitter/twitter.h

    r356e2dd rb8c336b  
    101101struct twitter_log_data {
    102102        guint64 id;
    103         struct bee_user *bu; /* DANGER: can be a dead pointer. Check it first. */
     103        /* DANGER: bu can be a dead pointer. Check it first.
     104         * twitter_message_id_from_command_arg() will do this. */
     105        struct bee_user *bu;
    104106};
    105107
     
    110112 */
    111113extern GSList *twitter_connections;
     114
     115/**
     116 * Evil hack: Fake bee_user which will always point at the local user.
     117 * Sometimes used as a return value by twitter_message_id_from_command_arg.
     118 * NOT thread safe but don't you dare to even think of ever making BitlBee
     119 * threaded. :-)
     120 */
     121extern bee_user_t twitter_log_local_user;
    112122
    113123void twitter_login_finish(struct im_connection *ic);
  • protocols/twitter/twitter_lib.c

    r356e2dd rb8c336b  
    460460#endif
    461461
    462 static char* expand_entities(char* text, const json_value *entities);
     462static void expand_entities(char **text, const json_value *node);
    463463
    464464/**
     
    473473{
    474474        struct twitter_xml_status *txs;
    475         const json_value *rt = NULL, *entities = NULL;
     475        const json_value *rt = NULL;
    476476
    477477        if (node->type != json_object) {
     
    501501                } else if (strcmp("in_reply_to_status_id", k) == 0 && v->type == json_integer) {
    502502                        txs->reply_to = v->u.integer;
    503                 } else if (strcmp("entities", k) == 0 && v->type == json_object) {
    504                         entities = v;
    505503                }
    506504        }
     
    516514                        txs_free(rtxs);
    517515                }
    518         } else if (entities) {
    519                 txs->text = expand_entities(txs->text, entities);
     516        } else {
     517                expand_entities(&txs->text, node);
    520518        }
    521519
     
    534532{
    535533        struct twitter_xml_status *txs;
    536         const json_value *entities = NULL;
    537534
    538535        if (node->type != json_object) {
     
    561558        }
    562559
    563         if (entities) {
    564                 txs->text = expand_entities(txs->text, entities);
    565         }
     560        expand_entities(&txs->text, node);
    566561
    567562        if (txs->text && txs->user && txs->id) {
     
    573568}
    574569
    575 static char* expand_entities(char* text, const json_value *entities)
    576 {
     570static void expand_entities(char **text, const json_value *node)
     571{
     572        json_value *entities, *quoted;
     573        char *quote_url = NULL, *quote_text = NULL;
     574
     575        if (!((entities = json_o_get(node, "entities")) && entities->type == json_object))
     576                return;
     577        if ((quoted = json_o_get(node, "quoted_status")) && quoted->type == json_object) {
     578                /* New "retweets with comments" feature. Note that this info
     579                 * seems to be included in the streaming API only! Grab the
     580                 * full message and try to insert it when we run into the
     581                 * Tweet entity. */
     582                struct twitter_xml_status *txs = twitter_xt_get_status(quoted);
     583                quote_text = g_strdup_printf("@%s: %s", txs->user->screen_name, txs->text);
     584                quote_url = g_strdup_printf("%s/status/%" G_GUINT64_FORMAT, txs->user->screen_name, txs->id);
     585                txs_free(txs);
     586        } else {
     587                quoted = NULL;
     588        }
     589
    577590        JSON_O_FOREACH(entities, k, v) {
    578591                int i;
     
    586599
    587600                for (i = 0; i < v->u.array.length; i++) {
     601                        const char *format = "%s%s <%s>%s";
     602
    588603                        if (v->u.array.values[i]->type != json_object) {
    589604                                continue;
     
    592607                        const char *kort = json_o_str(v->u.array.values[i], "url");
    593608                        const char *disp = json_o_str(v->u.array.values[i], "display_url");
     609                        const char *full = json_o_str(v->u.array.values[i], "expanded_url");
    594610                        char *pos, *new;
    595611
    596                         if (!kort || !disp || !(pos = strstr(text, kort))) {
     612                        if (!kort || !disp || !(pos = strstr(*text, kort))) {
    597613                                continue;
    598614                        }
     615                        if (quote_url && strstr(full, quote_url)) {
     616                                format = "%s<%s> [%s]%s";
     617                                disp = quote_text;
     618                        }
    599619
    600620                        *pos = '\0';
    601                         new = g_strdup_printf("%s%s <%s>%s", text, kort,
     621                        new = g_strdup_printf(format, *text, kort,
    602622                                              disp, pos + strlen(kort));
    603623
    604                         g_free(text);
    605                         text = new;
    606                 }
    607         }
    608 
    609         return text;
     624                        g_free(*text);
     625                        *text = new;
     626                }
     627        }
     628        g_free(quote_text);
     629        g_free(quote_url);
    610630}
    611631
     
    681701        if (g_strcasecmp(txs->user->screen_name, td->user) == 0) {
    682702                td->log[td->log_id].id = txs->rt_id;
     703                /* More useful than NULL. */
     704                td->log[td->log_id].bu = &twitter_log_local_user;
    683705        }
    684706
  • protocols/yahoo/yahoo2.h

    r356e2dd rb8c336b  
    3333#undef malloc
    3434#define malloc(x)             g_malloc(x)
    35 #undef calloc
    36 #define calloc(x, y)          g_calloc(x, y)
    3735#undef realloc
    3836#define realloc(x, y)         g_realloc(x, y)
Note: See TracChangeset for help on using the changeset viewer.