Changeset 631ec80 for protocols/twitter/twitter_lib.c
- Timestamp:
- 2012-11-25T14:26:23Z (11 years ago)
- Branches:
- master
- Children:
- 7f557d5
- Parents:
- 96dd574
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/twitter/twitter_lib.c
r96dd574 r631ec80 70 70 }; 71 71 72 static void twitter_groupchat_init(struct im_connection *ic);73 74 72 /** 75 73 * Frees a twitter_xml_user struct. … … 148 146 // Check if the buddy is already in the buddy list. 149 147 if (!bee_user_by_handle(ic->bee, ic, name)) { 150 char *mode = set_getstr(&ic->acc->set, "mode");151 152 148 // The buddy is not in the list, add the buddy and set the status to logged in. 153 149 imcb_add_buddy(ic, name, NULL); 154 150 imcb_rename_buddy(ic, name, fullname); 155 if ( g_strcasecmp(mode, "chat") == 0) {151 if (td->flags & TWITTER_MODE_CHAT) { 156 152 /* Necessary so that nicks always get translated to the 157 153 exact Twitter username. */ 158 154 imcb_buddy_nick_hint(ic, name, name); 159 155 imcb_chat_add_buddy(td->timeline_gc, name); 160 } else if ( g_strcasecmp(mode, "many") == 0)156 } else if (td->flags & TWITTER_MODE_MANY) 161 157 imcb_buddy_status(ic, name, OPT_LOGGED_IN, NULL, NULL); 162 158 } … … 305 301 306 302 td = ic->proto_data; 307 308 /* Create the room now that we "logged in". */309 if (!td->timeline_gc && g_strcasecmp(set_getstr(&ic->acc->set, "mode"), "chat") == 0)310 twitter_groupchat_init(ic);311 303 312 304 txl = g_new0(struct twitter_xml_list, 1); … … 663 655 } 664 656 665 static void twitter_groupchat_init(struct im_connection *ic)666 {667 char *name_hint;668 struct groupchat *gc;669 struct twitter_data *td = ic->proto_data;670 GSList *l;671 672 td->timeline_gc = gc = imcb_chat_new(ic, "twitter/timeline");673 674 name_hint = g_strdup_printf("%s_%s", td->prefix, ic->acc->user);675 imcb_chat_name_hint(gc, name_hint);676 g_free(name_hint);677 678 for (l = ic->bee->users; l; l = l->next) {679 bee_user_t *bu = l->data;680 if (bu->ic == ic)681 imcb_chat_add_buddy(td->timeline_gc, bu->handle);682 }683 }684 685 657 /** 686 658 * Function that is called to see the statuses in a groupchat window. … … 695 667 696 668 // Create a new groupchat if it does not exsist. 697 if (!td->timeline_gc) 698 twitter_groupchat_init(ic); 699 700 gc = td->timeline_gc; 701 if (!gc->joined) 702 imcb_chat_add_buddy(gc, ic->acc->user); 669 gc = twitter_groupchat_init(ic); 703 670 704 671 for (l = list; l; l = g_slist_next(l)) { … … 744 711 GSList *l = NULL; 745 712 struct twitter_xml_status *status; 746 char from[MAX_STRING]; 747 gboolean mode_one; 713 char from[MAX_STRING] = ""; 748 714 guint64 last_id = 0; 749 715 750 mode_one = g_strcasecmp(set_getstr(&ic->acc->set, "mode"), "one") == 0; 751 752 if (mode_one) { 716 if (td->flags & TWITTER_MODE_ONE) { 753 717 g_snprintf(from, sizeof(from) - 1, "%s_%s", td->prefix, ic->acc->user); 754 718 from[MAX_STRING - 1] = '\0'; … … 765 729 766 730 strip_html(status->text); 767 if ( mode_one)731 if (td->flags & TWITTER_MODE_ONE) 768 732 prefix = g_strdup_printf("\002<\002%s\002>\002 ", 769 733 status->user->screen_name); 770 734 else 771 735 twitter_add_buddy(ic, status->user->screen_name, status->user->name); … … 774 738 775 739 imcb_buddy_msg(ic, 776 mode_one? from : status->user->screen_name,777 740 *from ? from : status->user->screen_name, 741 text ? text : status->text, 0, status->created_at); 778 742 779 743 // Update the timeline_id to hold the highest id, so that by the next request … … 1017 981 1018 982 // See if the user wants to see the messages in a groupchat window or as private messages. 1019 if ( g_strcasecmp(set_getstr(&ic->acc->set, "mode"), "chat") == 0)983 if (td->flags & TWITTER_MODE_CHAT) 1020 984 twitter_groupchat(ic, output); 1021 985 else
Note: See TracChangeset
for help on using the changeset viewer.