Changeset 6e9ae72 for protocols/twitter/twitter.c
- Timestamp:
- 2011-12-17T13:50:01Z (13 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/twitter/twitter.c
r87dddee r6e9ae72 30 30 31 31 #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 ); \ 38 38 } while( 0 ); 39 39 … … 52 52 53 53 // Do stuff.. 54 twitter_get_ home_timeline(ic, -1);54 twitter_get_timeline(ic, -1); 55 55 56 56 // If we are still logged in run this function again after timeout. … … 69 69 // Queue the main_loop 70 70 // 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); 72 73 } 73 74 … … 77 78 { 78 79 struct twitter_data *td = ic->proto_data; 80 81 td->flags &= ~TWITTER_DOING_TIMELINE; 79 82 80 83 if (set_getbool(&ic->acc->set, "oauth") && !td->oauth_info) … … 90 93 91 94 static 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", 94 97 "https://api.twitter.com/oauth/authorize", 95 98 .consumer_key = "xsDNKJuNZYkZyMcu914uEA", … … 98 101 99 102 static 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", 102 105 "https://identi.ca/api/oauth/authorize", 103 106 .consumer_key = "e147ff789fcbd8a5a07963afbb43f9da", … … 216 219 def_oauth = "true"; 217 220 } else { /* if( strcmp( acc->prpl->name, "identica" ) == 0 ) */ 218 219 221 def_url = IDENTICA_API_URL; 220 222 def_oauth = "false"; … … 228 230 s = set_add(&acc->set, "commands", "true", set_eval_bool, acc); 229 231 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 230 237 s = set_add(&acc->set, "message_length", "140", set_eval_int, acc); 231 238 … … 235 242 s = set_add(&acc->set, "show_ids", "false", set_eval_bool, acc); 236 243 s->flags |= ACC_SET_OFFLINE_ONLY; 244 245 s = set_add(&acc->set, "show_old_mentions", "true", set_eval_bool, acc); 237 246 238 247 s = set_add(&acc->set, "oauth", def_oauth, set_eval_bool, acc); … … 317 326 b_event_remove(td->main_loop_id); 318 327 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); 321 330 322 331 if (td) { … … 404 413 struct twitter_data *td = c->ic->proto_data; 405 414 406 if (c != td-> home_timeline_gc)415 if (c != td->timeline_gc) 407 416 return; /* WTF? */ 408 417 409 418 /* If the user leaves the channel: Fine. Rejoin him/her once new 410 419 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; 413 422 } 414 423 … … 465 474 guint64 id; 466 475 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 474 482 twitter_status_destroy(ic, id); 475 else483 } else 476 484 twitter_msg(ic, "Could not undo last action"); 477 485 … … 491 499 guint64 id; 492 500 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])) && 494 506 (tud = bu->data) && tud->last_id) 495 507 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){ 498 509 if (id < TWITTER_LOG_LENGTH && td->log) 499 510 id = td->log[id].id; … … 514 525 guint64 id = 0; 515 526 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])) && 517 536 (tud = bu->data) && tud->last_id) { 518 537 id = tud->last_id; … … 525 544 bu = NULL; 526 545 } 546 527 547 if (!id || !bu) { 528 548 twitter_msg(ic, "User `%s' does not exist or didn't "
Note: See TracChangeset
for help on using the changeset viewer.