Mercurial > pidgin-twitter
changeset 118:8b097fcb9243
Add function that opens twitter's conversation window automatically when the
API-based post is enabled.
author | Konosuke Watanabe <sasugaanija@gmail.com> |
---|---|
date | Thu, 17 Jul 2008 23:53:15 +0900 |
parents | 423dc1a670c9 |
children | 0c4a83f734cd |
files | pidgin-twitter.c |
diffstat | 1 files changed, 72 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin-twitter.c Wed Jul 16 20:25:01 2008 +0900 +++ b/pidgin-twitter.c Thu Jul 17 23:53:15 2008 +0900 @@ -2061,6 +2061,69 @@ twitter_debug("reach end of function\n"); } + +static void +signed_on_cb(PurpleConnection *gc) +{ + PurpleBuddyList *list = purple_get_blist(); + PurpleBlistNode *gnode, *cnode, *bnode; + PurpleBuddy *b; + + twitter_debug("called\n"); + + if(!purple_prefs_get_bool(OPT_API_BASE_POST)) + return; + + if (!list) + return; + + twitter_debug("scan list\n"); + + for (gnode = list->root; gnode; gnode = gnode->next) { + if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) + continue; + + for(cnode = gnode->child; cnode; cnode = cnode->next) { + + if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) + continue; + + for(bnode = cnode->child; bnode; bnode = bnode->next) { + if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) + continue; + + b = (PurpleBuddy *)bnode; + + if(!PURPLE_BUDDY_IS_ONLINE(b)) { + const char *name; + PurpleAccount *account; + name = purple_buddy_get_name(b); + account = purple_buddy_get_account(b); + if (is_twitter_account(account, name)) { + PurpleConversation *gconv; + gconv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, name, account); + if (!gconv) { + gconv = purple_conversation_new(PURPLE_CONV_TYPE_IM, + account, name); + } + } + } + } + } + } +} + + + +static void +api_base_post_cb(const char *name, PurplePrefType type, gconstpointer value, + gpointer data) +{ + signed_on_cb(NULL); +} + + + static gboolean load_plugin(PurplePlugin *plugin) { @@ -2082,6 +2145,9 @@ purple_signal_connect(purple_conversations_get_handle(), "deleting-conversation", plugin, PURPLE_CALLBACK(deleting_conv_cb), NULL); + purple_signal_connect(purple_connections_get_handle(), "signed-on", + plugin, PURPLE_CALLBACK(signed_on_cb), NULL); + /* compile regex */ regp[RECIPIENT] = g_regex_new(P_RECIPIENT, 0, 0, NULL); @@ -2159,6 +2225,9 @@ purple_signal_disconnect(purple_conversations_get_handle(), "deleting-conversation", plugin, PURPLE_CALLBACK(deleting_conv_cb)); + purple_signal_disconnect(purple_connections_get_handle(), + "signed-on", + plugin, PURPLE_CALLBACK(signed_on_cb)); /* unreference regp */ g_regex_unref(regp[RECIPIENT]); @@ -2413,6 +2482,9 @@ "Post Status to Twitter via API"); purple_plugin_pref_frame_add(frame, pref); + purple_prefs_connect_callback(plugin, OPT_API_BASE_POST, + api_base_post_cb, NULL); + /* password */ pref = purple_plugin_pref_new_with_name_and_label(OPT_PASSWORD_TWITTER, "Password");