Ignore:
Timestamp:
2011-12-17T13:50:01Z (12 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
18c6d36
Parents:
87dddee (diff), 17f057d (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:

Mainline merge.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter.c

    r87dddee r6e9ae72  
    3030
    3131#define twitter_msg( ic, fmt... ) \
    32         do {                                                        \
    33                 struct twitter_data *td = ic->proto_data;           \
    34                 if( td->home_timeline_gc )                          \
    35                         imcb_chat_log( td->home_timeline_gc, fmt ); \
    36                 else                                                \
    37                         imcb_log( ic, fmt );                        \
     32        do {                                            \
     33                struct twitter_data *td = ic->proto_data;   \
     34                if( td->timeline_gc )                       \
     35                        imcb_chat_log( td->timeline_gc, fmt ); \
     36                else                                        \
     37                        imcb_log( ic, fmt );                    \
    3838        } while( 0 );
    3939
     
    5252
    5353        // Do stuff..
    54         twitter_get_home_timeline(ic, -1);
     54        twitter_get_timeline(ic, -1);
    5555
    5656        // If we are still logged in run this function again after timeout.
     
    6969        // Queue the main_loop
    7070        // Save the return value, so we can remove the timeout on logout.
    71         td->main_loop_id = b_timeout_add(60000, twitter_main_loop, ic);
     71        td->main_loop_id =
     72            b_timeout_add(set_getint(&ic->acc->set, "fetch_interval") * 1000, twitter_main_loop, ic);
    7273}
    7374
     
    7778{
    7879        struct twitter_data *td = ic->proto_data;
     80
     81        td->flags &= ~TWITTER_DOING_TIMELINE;
    7982
    8083        if (set_getbool(&ic->acc->set, "oauth") && !td->oauth_info)
     
    9093
    9194static const struct oauth_service twitter_oauth = {
    92         "http://api.twitter.com/oauth/request_token",
    93         "http://api.twitter.com/oauth/access_token",
     95        "https://api.twitter.com/oauth/request_token",
     96        "https://api.twitter.com/oauth/access_token",
    9497        "https://api.twitter.com/oauth/authorize",
    9598        .consumer_key = "xsDNKJuNZYkZyMcu914uEA",
     
    98101
    99102static const struct oauth_service identica_oauth = {
    100         "http://identi.ca/api/oauth/request_token",
    101         "http://identi.ca/api/oauth/access_token",
     103        "https://identi.ca/api/oauth/request_token",
     104        "https://identi.ca/api/oauth/access_token",
    102105        "https://identi.ca/api/oauth/authorize",
    103106        .consumer_key = "e147ff789fcbd8a5a07963afbb43f9da",
     
    216219                def_oauth = "true";
    217220        } else {                /* if( strcmp( acc->prpl->name, "identica" ) == 0 ) */
    218 
    219221                def_url = IDENTICA_API_URL;
    220222                def_oauth = "false";
     
    228230        s = set_add(&acc->set, "commands", "true", set_eval_bool, acc);
    229231
     232        s = set_add(&acc->set, "fetch_interval", "60", set_eval_int, acc);
     233        s->flags |= ACC_SET_OFFLINE_ONLY;
     234
     235        s = set_add(&acc->set, "fetch_mentions", "true", set_eval_bool, acc);
     236
    230237        s = set_add(&acc->set, "message_length", "140", set_eval_int, acc);
    231238
     
    235242        s = set_add(&acc->set, "show_ids", "false", set_eval_bool, acc);
    236243        s->flags |= ACC_SET_OFFLINE_ONLY;
     244
     245        s = set_add(&acc->set, "show_old_mentions", "true", set_eval_bool, acc);
    237246
    238247        s = set_add(&acc->set, "oauth", def_oauth, set_eval_bool, acc);
     
    317326        b_event_remove(td->main_loop_id);
    318327
    319         if (td->home_timeline_gc)
    320                 imcb_chat_free(td->home_timeline_gc);
     328        if (td->timeline_gc)
     329                imcb_chat_free(td->timeline_gc);
    321330
    322331        if (td) {
     
    404413        struct twitter_data *td = c->ic->proto_data;
    405414
    406         if (c != td->home_timeline_gc)
     415        if (c != td->timeline_gc)
    407416                return;         /* WTF? */
    408417
    409418        /* If the user leaves the channel: Fine. Rejoin him/her once new
    410419           tweets come in. */
    411         imcb_chat_free(td->home_timeline_gc);
    412         td->home_timeline_gc = NULL;
     420        imcb_chat_free(td->timeline_gc);
     421        td->timeline_gc = NULL;
    413422}
    414423
     
    465474                guint64 id;
    466475
    467                 if (cmd[1])
    468                         id = g_ascii_strtoull(cmd[1], NULL, 10);
    469                 else
    470                         id = td->last_status_id;
    471 
    472                 /* TODO: User feedback. */
    473                 if (id)
     476                if (cmd[1] == NULL)
     477                        twitter_status_destroy(ic, td->last_status_id);
     478                else if (sscanf(cmd[1], "%" G_GUINT64_FORMAT, &id) == 1) {
     479                        if (id < TWITTER_LOG_LENGTH && td->log)
     480                                id = td->log[id].id;
     481                       
    474482                        twitter_status_destroy(ic, id);
    475                 else
     483                } else
    476484                        twitter_msg(ic, "Could not undo last action");
    477485
     
    491499                guint64 id;
    492500
    493                 if ((bu = bee_user_by_handle(ic->bee, ic, cmd[1])) &&
     501                if (g_str_has_prefix(cmd[1], "#") &&
     502                    sscanf(cmd[1] + 1, "%" G_GUINT64_FORMAT, &id) == 1) {
     503                        if (id < TWITTER_LOG_LENGTH && td->log)
     504                                id = td->log[id].id;
     505                } else if ((bu = bee_user_by_handle(ic->bee, ic, cmd[1])) &&
    494506                    (tud = bu->data) && tud->last_id)
    495507                        id = tud->last_id;
    496                 else {
    497                         id = g_ascii_strtoull(cmd[1], NULL, 10);
     508                else if (sscanf(cmd[1], "%" G_GUINT64_FORMAT, &id) == 1){
    498509                        if (id < TWITTER_LOG_LENGTH && td->log)
    499510                                id = td->log[id].id;
     
    514525                guint64 id = 0;
    515526
    516                 if ((bu = bee_user_by_handle(ic->bee, ic, cmd[1])) &&
     527                if (g_str_has_prefix(cmd[1], "#") &&
     528                    sscanf(cmd[1] + 1, "%" G_GUINT64_FORMAT, &id) == 1 &&
     529                    (id < TWITTER_LOG_LENGTH) && td->log) {
     530                        bu = td->log[id].bu;
     531                        if (g_slist_find(ic->bee->users, bu))
     532                                id = td->log[id].id;
     533                        else
     534                                bu = NULL;
     535                } else if ((bu = bee_user_by_handle(ic->bee, ic, cmd[1])) &&
    517536                    (tud = bu->data) && tud->last_id) {
    518537                        id = tud->last_id;
     
    525544                                bu = NULL;
    526545                }
     546
    527547                if (!id || !bu) {
    528548                        twitter_msg(ic, "User `%s' does not exist or didn't "
Note: See TracChangeset for help on using the changeset viewer.