Changeset eb4ad8d for protocols


Ignore:
Timestamp:
2015-01-17T20:13:19Z (9 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
e26aa72
Parents:
1065dd4 (diff), 664bac3 (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:

Merging random other fixes/cleanups.

Location:
protocols
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • protocols/bee_chat.c

    r1065dd4 reb4ad8d  
    8585        bee_t *bee = ic->bee;
    8686        bee_user_t *bu;
     87        gboolean temp;
    8788        char *s;
    8889       
     
    9293       
    9394        bu = bee_user_by_handle( bee, ic, who );
     95        temp = ( bu == NULL );
     96       
     97        if( temp )
     98                bu = bee_user_new( bee, ic, who, BEE_USER_ONLINE );
    9499       
    95100        s = set_getstr( &ic->bee->set, "strip_html" );
     
    98103                strip_html( msg );
    99104       
    100         if( bu && bee->ui->chat_msg )
     105        if( bee->ui->chat_msg )
    101106                bee->ui->chat_msg( bee, c, bu, msg, sent_at );
    102         else
    103                 imcb_chat_log( c, "Message from unknown participant %s: %s", who, msg );
     107       
     108        if( temp )
     109                bee_user_free( bee, bu );
    104110}
    105111
  • protocols/jabber/jabber_util.c

    r1065dd4 reb4ad8d  
    330330}
    331331
    332 /* Returns a new string. Don't leak it! */
     332/* The /resource part is case sensitive. This stops once we see a slash.
     333   Returns a new string. Don't leak it! */
    333334char *jabber_normalize( const char *orig )
    334335{
    335         int len, i;
    336         char *new;
    337        
    338         len = strlen( orig );
    339         new = g_new( char, len + 1 );
    340        
    341         /* So it turns out the /resource part is case sensitive. Yeah, and
    342            it's Unicode but feck Unicode. :-P So stop once we see a slash. */
    343         for( i = 0; i < len && orig[i] != '/' ; i ++ )
    344                 new[i] = g_ascii_tolower( orig[i] );
    345         for( ; orig[i]; i ++ )
    346                 new[i] = orig[i];
    347        
    348         new[i] = 0;
     336        char *lower, *new, *s;
     337
     338        if ( ! ( s = strchr( orig, '/' ) ) )
     339                return g_utf8_strdown( orig, -1 );
     340
     341        lower = g_utf8_strdown( orig, (s - orig) );  /* stop in s */
     342        new = g_strconcat( lower, s, NULL );
     343        g_free( lower );
     344        return new;
     345}
     346
     347/* Similar to jabber_normalize, but works with addresses in the form
     348 * resource=chatroom@example.com */
     349char *jabber_normalize_ext( const char *orig )
     350{
     351        char *lower, *new, *s;
     352
     353        if ( ! ( s = strchr( orig, '=' ) ) )
     354                return g_utf8_strdown( orig, -1 );
     355
     356        lower = g_utf8_strdown( s, -1 ); /* start in s */
     357
     358        *s = 0;
     359        new = g_strconcat( orig, lower, NULL );
     360        *s = '=';
     361
     362        g_free( lower );
    349363        return new;
    350364}
     
    556570        char *s, *jid;
    557571       
    558         jid = jabber_normalize( jid_ );
     572        jid = jabber_normalize_ext( jid_ );
    559573       
    560574        if( ( s = strchr( jid, '=' ) ) == NULL )
  • protocols/msn/ns.c

    r1065dd4 reb4ad8d  
    881881        struct msn_buddy_data *bd = bu->data;
    882882        struct msn_data *md = bu->ic->proto_data;
    883         char handle[strlen(bu->handle)];
     883        char handle[strlen(bu->handle) + 1];
    884884        char *domain;
    885885        char l[4];
  • protocols/oscar/conn.c

    r1065dd4 reb4ad8d  
    571571
    572572        if (FD_ISSET(conn->fd, &fds) || FD_ISSET(conn->fd, &wfds)) {
    573                 unsigned int len = sizeof(error);
     573                socklen_t len = sizeof(error);
    574574
    575575                if (getsockopt(conn->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0)
  • protocols/twitter/twitter.c

    r1065dd4 reb4ad8d  
    5151        struct twitter_data *td = ic->proto_data;
    5252
     53        char *last_tweet = set_getstr(&ic->acc->set, "_last_tweet");
     54        if (last_tweet)
     55                td->timeline_id = g_ascii_strtoull(last_tweet, NULL, 0);
     56
    5357        /* Create the room now that we "logged in". */
    5458        if (td->flags & TWITTER_MODE_CHAT)
     
    327331        s = set_add(&acc->set, "strip_newlines", "false", set_eval_bool, acc);
    328332       
     333        s = set_add(&acc->set, "_last_tweet", "0", NULL, acc);
     334        s->flags |= SET_HIDDEN | SET_NOSAVE;
     335
    329336        if (strcmp(acc->prpl->name, "twitter") == 0) {
    330337                s = set_add(&acc->set, "stream", "true", set_eval_bool, acc);
  • protocols/twitter/twitter_lib.c

    r1065dd4 reb4ad8d  
    234234void twitter_get_friends_ids(struct im_connection *ic, gint64 next_cursor)
    235235{
    236         // Primitive, but hey! It works...     
     236        // Primitive, but hey! It works...
    237237        char *args[2];
    238238        args[0] = "cursor";
    239         args[1] = g_strdup_printf("%lld", (long long) next_cursor);
     239        args[1] = g_strdup_printf("%" G_GINT64_FORMAT, next_cursor);
    240240        twitter_http(ic, TWITTER_FRIENDS_IDS_URL, twitter_http_get_friends_ids, ic, 0, args, 2);
    241241
     
    721721{
    722722        struct twitter_data *td = ic->proto_data;
     723        char *last_id_str;
    723724       
    724725        if (status->user == NULL || status->text == NULL)
     
    738739        // we won't pick up the updates already in the list.
    739740        td->timeline_id = MAX(td->timeline_id, status->rt_id);
     741
     742        last_id_str = g_strdup_printf("%" G_GUINT64_FORMAT, td->timeline_id);
     743        set_setstr(&ic->acc->set, "last_tweet", last_id_str);
     744        g_free(last_id_str);
    740745}
    741746
     
    9971002        char *args[6];
    9981003        args[0] = "cursor";
    999         args[1] = g_strdup_printf("%lld", (long long) next_cursor);
     1004        args[1] = g_strdup_printf("%" G_GINT64_FORMAT, next_cursor);
    10001005        args[2] = "include_entities";
    10011006        args[3] = "true";
    10021007        if (td->timeline_id) {
    10031008                args[4] = "since_id";
    1004                 args[5] = g_strdup_printf("%llu", (long long unsigned int) td->timeline_id);
     1009                args[5] = g_strdup_printf("%" G_GUINT64_FORMAT, td->timeline_id);
    10051010        }
    10061011
     
    10331038        char *args[6];
    10341039        args[0] = "cursor";
    1035         args[1] = g_strdup_printf("%lld", (long long) next_cursor);
     1040        args[1] = g_strdup_printf("%" G_GINT64_FORMAT, next_cursor);
    10361041        args[2] = "include_entities";
    10371042        args[3] = "true";
    10381043        if (td->timeline_id) {
    10391044                args[4] = "since_id";
    1040                 args[5] = g_strdup_printf("%llu", (long long unsigned int) td->timeline_id);
     1045                args[5] = g_strdup_printf("%" G_GUINT64_FORMAT, td->timeline_id);
    10411046        } else {
    10421047                args[4] = "count";
     
    11671172                "status", msg,
    11681173                "in_reply_to_status_id",
    1169                 g_strdup_printf("%llu", (unsigned long long) in_reply_to)
     1174                g_strdup_printf("%" G_GUINT64_FORMAT, in_reply_to)
    11701175        };
    11711176        twitter_http(ic, TWITTER_STATUS_UPDATE_URL, twitter_http_post, ic, 1,
     
    12011206{
    12021207        char *url;
    1203         url = g_strdup_printf("%s%llu%s", TWITTER_STATUS_DESTROY_URL,
    1204                               (unsigned long long) id, ".json");
     1208        url = g_strdup_printf("%s%" G_GUINT64_FORMAT "%s",
     1209                              TWITTER_STATUS_DESTROY_URL, id, ".json");
    12051210        twitter_http_f(ic, url, twitter_http_post, ic, 1, NULL, 0,
    12061211                       TWITTER_HTTP_USER_ACK);
     
    12111216{
    12121217        char *url;
    1213         url = g_strdup_printf("%s%llu%s", TWITTER_STATUS_RETWEET_URL,
    1214                               (unsigned long long) id, ".json");
     1218        url = g_strdup_printf("%s%" G_GUINT64_FORMAT "%s",
     1219                              TWITTER_STATUS_RETWEET_URL, id, ".json");
    12151220        twitter_http_f(ic, url, twitter_http_post, ic, 1, NULL, 0,
    12161221                       TWITTER_HTTP_USER_ACK);
     
    12411246                NULL,
    12421247        };
    1243         args[1] = g_strdup_printf("%llu", (unsigned long long) id);
     1248        args[1] = g_strdup_printf("%" G_GUINT64_FORMAT, id);
    12441249        twitter_http_f(ic, TWITTER_FAVORITE_CREATE_URL, twitter_http_post,
    12451250                       ic, 1, args, 2, TWITTER_HTTP_USER_ACK);
  • protocols/yahoo/libyahoo2.c

    r1065dd4 reb4ad8d  
    974974                        msg = pair->value;
    975975
    976                 if (pair->key == 13) ;
     976                if (pair->key == 13)
     977                        ;
    977978                if (pair->key == 16)    /* error */
    978979                        msg = pair->value;
     
    17951796        switch (code)
    17961797        {
    1797                 case 1212: return YAHOO_LOGIN_PASSWD;
    1798                 case 1213: return YAHOO_LOGIN_LOCK;
    1799                 case 1235: return YAHOO_LOGIN_UNAME;
     1798                case 1212: return (enum yahoo_status) YAHOO_LOGIN_PASSWD;
     1799                case 1213: return (enum yahoo_status) YAHOO_LOGIN_LOCK;
     1800                case 1235: return (enum yahoo_status) YAHOO_LOGIN_UNAME;
    18001801                default: return (enum yahoo_status) code;
    18011802        }
     
    36103611        yd = yid->yd;
    36113612
    3612         pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE,
     3613        pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, (enum ypacket_status) YAHOO_STATUS_OFFLINE,
    36133614                yd->session_id);
    36143615
     
    36773678        if (yd->current_status == YAHOO_STATUS_INVISIBLE) {
    36783679                pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE,
    3679                         YAHOO_STATUS_AVAILABLE, 0);
     3680                        (enum ypacket_status) YAHOO_STATUS_AVAILABLE, 0);
    36803681                yahoo_packet_hash(pkt, 13, "2");
    36813682                yahoo_send_packet(yid, pkt, 0);
     
    36963697        if (old_status == YAHOO_STATUS_INVISIBLE) {
    36973698                pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE,
    3698                         YAHOO_STATUS_AVAILABLE, 0);
     3699                        (enum ypacket_status) YAHOO_STATUS_AVAILABLE, 0);
    36993700                yahoo_packet_hash(pkt, 13, "1");
    37003701                yahoo_send_packet(yid, pkt, 0);
  • protocols/yahoo/yahoo_util.h

    r1065dd4 reb4ad8d  
    4848
    4949# define snprintf       g_snprintf
     50#ifdef vsnprintf
     51#undef vsnprintf
     52#endif
    5053# define vsnprintf      g_vsnprintf
    5154
Note: See TracChangeset for help on using the changeset viewer.