Mercurial > pidgin-twitter
diff main.c @ 330:cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Mon, 12 Oct 2009 21:51:13 +0900 |
parents | 38a2ef743019 |
children | b4c846870b3c |
line wrap: on
line diff
--- a/main.c Mon Oct 12 01:45:36 2009 +0900 +++ b/main.c Mon Oct 12 21:51:13 2009 +0900 @@ -31,6 +31,8 @@ static GList *wassr_parrot_list = NULL; static GList *identica_parrot_list = NULL; static GList *ffeed_parrot_list = NULL; +guint64 reply_to_msgid = 0; +PurpleAccount *account_for_twitter = NULL; #ifdef _WIN32 gboolean blink_state = FALSE; gboolean blink_modified = FALSE; @@ -63,6 +65,7 @@ #ifndef _WIN32 extern gchar *sanitize_utf(const gchar *msg, gsize len, gsize *newlen) __attribute__ ((weak)); #endif +gboolean pt_uri_handler(const char *proto, const char *cmd, GHashTable *params); /*************/ @@ -392,7 +395,7 @@ g_free(*buffer); *buffer = m; } - } + } /* send */ /* strip all markups */ strip_markup(buffer, TRUE); @@ -405,6 +408,17 @@ playsound(buffer, RECIPIENT); } + if(service == twitter_service) { + /* escape pseudo command (to show the same result as + sending message) */ + if(purple_prefs_get_bool(OPT_ESCAPE_PSEUDO)) { + escape(buffer); + } + + /* replace ptmsgid=123 with appropriate links */ + twitter_add_links(buffer); + } + /* translate */ if(purple_prefs_get_bool(OPT_TRANSLATE_SENDER)) { if(service == ffeed_service) @@ -432,11 +446,18 @@ translate(buffer, GROUP_IDENTICA, service); } - /* escape pseudo command (to show the same result as sending message) */ - if(service == twitter_service && - purple_prefs_get_bool(OPT_ESCAPE_PSEUDO)) { - escape(buffer); +#if 0 + if(service == twitter_service) { + /* escape pseudo command (to show the same result as + sending message) */ + if(purple_prefs_get_bool(OPT_ESCAPE_PSEUDO)) { + escape(buffer); + } + + /* replace ptmsgid=123 with appropriate links */ + twitter_add_links(buffer); } +#endif if(purple_prefs_get_bool(OPT_STRIP_EXCESS_LF)) { translate(buffer, EXCESS_LF, service); @@ -528,6 +549,9 @@ break; } + if(count == 0) + reply_to_msgid = 0; + box = gtkconv->toolbar; counter = g_object_get_data(G_OBJECT(box), PLUGIN_ID "-counter"); if(counter) @@ -760,6 +784,7 @@ get_status_with_api, (gpointer)conv); source.conv = conv; attach_to_conv(conv, NULL); + account_for_twitter = conv->account; /* xxx */ break; case wassr_service: case identica_service: @@ -1160,6 +1185,22 @@ } static gboolean +pt_url_clicked_cb(GtkIMHtml *imhtml, GtkIMHtmlLink *link) +{ + const gchar * url = gtk_imhtml_link_get_url(link); + + purple_got_protocol_handler_uri(url); + + return TRUE; +} + +static gboolean +pt_url_context_menu_cb(GtkIMHtml *imhtml, GtkIMHtmlLink *link, GtkWidget *menu) +{ + return TRUE; +} + +static gboolean load_plugin(PurplePlugin *plugin) { int i; @@ -1191,6 +1232,14 @@ "signed-on", plugin, PURPLE_CALLBACK(signed_on_cb), NULL); + gtk_imhtml_class_register_protocol("PT://", + pt_url_clicked_cb, + pt_url_context_menu_cb); + purple_signal_connect(purple_get_core(), + "uri-handler", + plugin, + PURPLE_CALLBACK(pt_uri_handler), NULL); + /* compile regex */ regp[RECIPIENT] = g_regex_new(P_RECIPIENT, 0, 0, NULL); @@ -1211,6 +1260,7 @@ regp[SIZE_128_WASSR] = g_regex_new(P_SIZE_128_WASSR, 0, 0, NULL); regp[EXCESS_LF] = g_regex_new(P_EXCESS_LF, 0, 0, NULL); regp[TRAIL_HASH] = g_regex_new(P_TRAIL_HASH, 0, 0, NULL); + regp[MESSAGE_ID] = g_regex_new(P_MESSAGE_ID, 0, 0, NULL); for(i = twitter_service; i < NUM_SERVICES; i++) { icon_hash[i] = g_hash_table_new_full(g_str_hash, g_str_equal, @@ -1289,6 +1339,13 @@ "signed-on", plugin, PURPLE_CALLBACK(signed_on_cb)); + gtk_imhtml_class_register_protocol("PT://", NULL, NULL); + + /* should do? --yaz */ + purple_signal_disconnect(purple_get_core(), + "uri-handler", + plugin, PURPLE_CALLBACK(pt_uri_handler)); + /* unreference regp */ for(i = 0; i < NUM_REGPS; i++) { g_regex_unref(regp[i]);