Mercurial > pidgin-twitter
changeset 194:1495b478680b
tentative support for jisko.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Sat, 09 Aug 2008 04:47:18 +0900 |
parents | c76cd73cd2e6 |
children | 3e459b078788 |
files | pidgin-twitter.c pidgin-twitter.h prefs.ui |
diffstat | 3 files changed, 287 insertions(+), 106 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin-twitter.c Tue Aug 05 23:24:50 2008 +0900 +++ b/pidgin-twitter.c Sat Aug 09 04:47:18 2008 +0900 @@ -25,9 +25,10 @@ /* globals */ /***********/ #define NUM_REGP 10 +#define NUM_SERVICES 4 /* twitter, wassr, identica, jisko. */ static GRegex *regp[NUM_REGP]; static gboolean suppress_oops = FALSE; -static GHashTable *icon_hash[3]; /* twitter, wassr, identica. */ +static GHashTable *icon_hash[NUM_SERVICES]; static GHashTable *conv_hash = NULL; static GList *statuseslist = NULL; static GList *postedlist = NULL; @@ -848,6 +849,9 @@ case identica_service: format = RECIPIENT_FORMAT_IDENTICA; break; + case jisko_service: + format = RECIPIENT_FORMAT_JISKO; + break; default: twitter_debug("unknown service\n"); break; @@ -870,6 +874,9 @@ case identica_service: format = SENDER_FORMAT_IDENTICA; break; + case jisko_service: + format = SENDER_FORMAT_JISKO; + break; default: twitter_debug("unknown service\n"); break; @@ -996,6 +1003,9 @@ case identica_service: screen_name = purple_prefs_get_string(OPT_SCREEN_NAME_IDENTICA); break; + case jisko_service: + screen_name = purple_prefs_get_string(OPT_SCREEN_NAME_JISKO); + break; } if (screen_name) { @@ -1056,6 +1066,7 @@ switch(service) { case twitter_service: + case jisko_service: count = gtk_text_buffer_get_char_count(textbuffer) + (unsigned int)g_utf8_strlen(new_text, -1); markup = g_markup_printf_escaped("<span color=\"%s\">%u</span>", @@ -1109,6 +1120,7 @@ switch(service) { case twitter_service: + case jisko_service: count= gtk_text_buffer_get_char_count(textbuffer) - (gtk_text_iter_get_offset(end_pos) - gtk_text_iter_get_offset(start_pos)); @@ -1167,10 +1179,9 @@ gint service = get_service_type(conv); switch(service) { case twitter_service: - detach_from_conv(conv, NULL); - break; case wassr_service: case identica_service: + case jisko_service: detach_from_conv(conv, NULL); break; default: @@ -1280,10 +1291,9 @@ /* only attach to twitter conversation window */ switch(service) { case twitter_service: - attach_to_conv(conv, NULL); - break; case wassr_service: case identica_service: + case jisko_service: attach_to_conv(conv, NULL); break; default: @@ -1425,6 +1435,30 @@ return is_identica_account(account, name); } +static gboolean +is_jisko_account(PurpleAccount *account, const char *name) +{ + const gchar *proto = purple_account_get_protocol_id(account); + + if(g_strstr_len(name, 16, "bot@jisko.net") && + g_strstr_len(proto, 11, "prpl-jabber")) { + return TRUE; + } + + return FALSE; +} + +static gboolean +is_jisko_conv(PurpleConversation *conv) +{ + g_return_val_if_fail(conv != NULL, FALSE); + + const char *name = purple_conversation_get_name(conv); + PurpleAccount *account = purple_conversation_get_account(conv); + + return is_jisko_account(account, name); +} + static gint get_service_type(PurpleConversation *conv) { @@ -1438,6 +1472,8 @@ service = wassr_service; else if(is_identica_conv(conv)) service = identica_service; + else if(is_jisko_conv(conv)) + service = jisko_service; return service; } @@ -1464,6 +1500,7 @@ break; case wassr_service: case identica_service: + case jisko_service: attach_to_conv(conv, NULL); break; default: @@ -1500,6 +1537,9 @@ case identica_service: hash = icon_hash[identica_service]; break; + case jisko_service: + hash = icon_hash[jisko_service]; + break; default: twitter_debug("unknown service\n"); break; @@ -1557,7 +1597,7 @@ return FALSE; } - /* if we use api, discard incoming IM message. XXX too wild? */ + /* if we use api, discard all incoming IM messages. */ if(purple_prefs_get_bool(OPT_API_BASE_POST)) { g_free(*sender); *sender = NULL; g_free(*buffer); *buffer = NULL; @@ -1637,6 +1677,9 @@ case identica_service: hash = icon_hash[identica_service]; break; + case jisko_service: + hash = icon_hash[jisko_service]; + break; default: twitter_debug("unknown service\n"); } @@ -1697,6 +1740,9 @@ case identica_service: hash = icon_hash[identica_service]; break; + case jisko_service: + hash = icon_hash[jisko_service]; + break; default: twitter_debug("unknown service\n"); break; @@ -1883,6 +1929,9 @@ case identica_service: hash = icon_hash[identica_service]; break; + case jisko_service: + hash = icon_hash[jisko_service]; + break; default: twitter_debug("unknown service\n"); } @@ -1954,6 +2003,9 @@ case identica_service: suffix = "identica"; break; + case jisko_service: + suffix = "jisko"; + break; default: twitter_debug("unknown service\n"); break; @@ -2018,6 +2070,10 @@ suffix = "identica"; hash = icon_hash[identica_service]; break; + case jisko_service: + suffix = "jisko"; + hash = icon_hash[jisko_service]; + break; default: twitter_debug("unknown service\n"); break; @@ -2106,6 +2162,11 @@ case identica_service: url = g_strdup_printf("http://identi.ca/%s", user_name); break; + case jisko_service: + url = g_strdup_printf("http://jisko.net/users/%s/img/avatar/thumb_side.png", + user_name); + data->img_type = "png"; + break; default: twitter_debug("unknown service\n"); break; @@ -2150,6 +2211,9 @@ case identica_service: hash = icon_hash[identica_service]; break; + case jisko_service: + hash = icon_hash[jisko_service]; + break; default: twitter_debug("unknown service\n"); break; @@ -2249,6 +2313,9 @@ case identica_service: hash = icon_hash[identica_service]; break; + case jisko_service: + hash = icon_hash[jisko_service]; + break; default: twitter_debug("unknown service\n"); break; @@ -2400,7 +2467,7 @@ regp[IMAGE_IDENTICA] = g_regex_new(P_IMAGE_IDENTICA, 0, 0, NULL); regp[IMAGE_TWITTER] = g_regex_new(P_IMAGE_TWITTER, 0, 0, NULL); - for(i = twitter_service; i <= identica_service; i++) { + for(i = twitter_service; i < NUM_SERVICES; i++) { icon_hash[i] = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); } @@ -2488,7 +2555,7 @@ /* remove mark list in each hash entry */ /* cancel request that has not been finished yet */ - for(i = twitter_service; i <= identica_service; i++) { + for(i = twitter_service; i < NUM_SERVICES; i++) { /* delete mark list and stop requeset for each hash table */ g_hash_table_foreach(icon_hash[i], (GHFunc)cleanup_hash_entry_func, NULL); @@ -2542,7 +2609,7 @@ int i; /* invalidate icon cache */ - for(i = twitter_service; i <= identica_service; i++) { + for(i = twitter_service; i < NUM_SERVICES; i++) { g_hash_table_foreach(icon_hash[i], (GHFunc)invalidate_icon_data_func, NULL); } @@ -2677,6 +2744,13 @@ g_signal_connect(e, "changed", G_CALLBACK(text_changed_cb), &e); + e = GTK_WIDGET(gtk_builder_get_object (builder, "account_jisko")); + g_object_set_data(G_OBJECT(e), "pref", OPT_SCREEN_NAME_JISKO); + text = purple_prefs_get_string(OPT_SCREEN_NAME_JISKO); + gtk_entry_set_text(GTK_ENTRY(e), text); + g_signal_connect(e, "changed", + G_CALLBACK(text_changed_cb), &e); + e = GTK_WIDGET(gtk_builder_get_object (builder, "account_api")); g_object_set_data(G_OBJECT(e), "pref", OPT_API_BASE_POST); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(e),
--- a/pidgin-twitter.h Tue Aug 05 23:24:50 2008 +0900 +++ b/pidgin-twitter.h Sat Aug 09 04:47:18 2008 +0900 @@ -43,7 +43,8 @@ unknown_service = -1, twitter_service, wassr_service, - identica_service + identica_service, + jisko_service }; /* container to hold icon data */ @@ -109,6 +110,7 @@ #define OPT_SCREEN_NAME_TWITTER OPT_PIDGINTWITTER "/screen_name_twitter" #define OPT_SCREEN_NAME_WASSR OPT_PIDGINTWITTER "/screen_name_wassr" #define OPT_SCREEN_NAME_IDENTICA OPT_PIDGINTWITTER "/screen_name_identica" +#define OPT_SCREEN_NAME_JISKO OPT_PIDGINTWITTER "/screen_name_jisko" #define OPT_PASSWORD_TWITTER OPT_PIDGINTWITTER "/password_twitter" #define OPT_SHOW_ICON OPT_PIDGINTWITTER "/show_icon" #define OPT_ICON_SIZE OPT_PIDGINTWITTER "/icon_size" @@ -125,6 +127,8 @@ #define SENDER_FORMAT_WASSR "%s<a href='http://wassr.jp/user/%s'>%s</a>: " #define RECIPIENT_FORMAT_IDENTICA "@<a href='http://identi.ca/%s'>%s</a>" #define SENDER_FORMAT_IDENTICA "%s<a href='http://identi.ca/%s'>%s</a>: " +#define RECIPIENT_FORMAT_JISKO "@<a href='http://jisko.net/%s'>%s</a>" +#define SENDER_FORMAT_JISKO "%s<a href='http://jisko.net/%s'>%s</a>: " #define CHANNEL_FORMAT_WASSR "%s<a href='http://wassr.jp/channel/%s'>%s</a> " #define DEFAULT_LIST "(list of users: separated with ' ,:;')" #define OOPS_MESSAGE "<body>Oops! Your update was over 140 characters. We sent the short version to your friends (they can view the entire update on the web).<BR></body>" @@ -132,7 +136,7 @@ /* patterns */ #define P_RECIPIENT "@([A-Za-z0-9_]+)" -#define P_SENDER "^(\\r?\\n?)\\s*([A-Za-z0-9_]+): " +#define P_SENDER "^(\\r?\\n?)\\s*([A-Za-z0-9_]+)(?:\\(.+\\))?: " #define P_COMMAND "^(?:\\s*)([dDfFgGlLmMnNtTwW]{1}\\s+[A-Za-z0-9_]+)(?:\\s*\\Z)" #define P_PSEUDO "^\\s*(?:[\"#$%&'()*+,\\-./:;<=>?\\[\\\\\\]_`{|}~]|[^\\s\\x21-\\x7E])*([dDfFgGlLmMnNtTwW]{1})(?:\\Z|\\s+|[^\\x21-\\x7E]+\\Z)" #define P_USER "^\\(.+?\\)\\s*([A-Za-z0-9_]+):" @@ -191,6 +195,8 @@ static gboolean is_wassr_conv(PurpleConversation *conv); static gboolean is_identica_account(PurpleAccount *account, const char *name); static gboolean is_identica_conv(PurpleConversation *conv); +static gboolean is_jisko_account(PurpleAccount *account, const char *name); +static gboolean is_jisko_conv(PurpleConversation *conv); static void conv_created_cb(PurpleConversation *conv, gpointer null); static void deleting_conv_cb(PurpleConversation *conv); static gboolean receiving_im_cb(PurpleAccount *account, char **sender, char **buffer, PurpleConversation *conv, PurpleMessageFlags *flags, void *data);
--- a/prefs.ui Tue Aug 05 23:24:50 2008 +0900 +++ b/prefs.ui Sat Aug 09 04:47:18 2008 +0900 @@ -188,6 +188,47 @@ </packing> </child> <child> + <object class="GtkHBox" id="hbox10"> + <property name="visible">True</property> + <child> + <object class="GtkAlignment" id="alignment43"> + <property name="visible">True</property> + <property name="left_padding">20</property> + <child> + <object class="GtkLabel" id="label30"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">jisko</property> + <property name="max_width_chars">10</property> + </object> + </child> + </object> + </child> + <child> + <object class="GtkAlignment" id="alignment44"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="right_padding">4</property> + <child> + <object class="GtkEntry" id="account_jisko"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="width_chars">20</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="position">4</property> + </packing> + </child> + <child> <object class="GtkAlignment" id="alignment8"> <property name="visible">True</property> <property name="top_padding">8</property> @@ -204,7 +245,7 @@ </child> </object> <packing> - <property name="position">4</property> + <property name="position">5</property> </packing> </child> <child> @@ -223,7 +264,7 @@ </child> </object> <packing> - <property name="position">5</property> + <property name="position">6</property> </packing> </child> <child> @@ -267,7 +308,7 @@ </child> </object> <packing> - <property name="position">6</property> + <property name="position">7</property> </packing> </child> <child> @@ -336,7 +377,7 @@ </object> <packing> <property name="expand">False</property> - <property name="position">7</property> + <property name="position">8</property> </packing> </child> </object> @@ -498,46 +539,41 @@ <property name="visible">True</property> <property name="n_columns">4</property> <child> - <object class="GtkAlignment" id="alignment18"> - <property name="visible">True</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="x_options"></property> - <property name="y_options"></property> - </packing> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> </child> <child> - <object class="GtkAlignment" id="alignment16"> - <property name="visible">True</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="y_options"></property> - </packing> + <placeholder/> + </child> + <child> + <placeholder/> </child> <child> - <object class="GtkAlignment" id="alignment45"> + <placeholder/> + </child> + <child> + <object class="GtkAlignment" id="alignment40"> <property name="visible">True</property> - <property name="right_padding">20</property> + <property name="left_padding">40</property> <child> - <object class="GtkLabel" id="label27"> + <object class="GtkLabel" id="label24"> <property name="visible">True</property> - <property name="label" translatable="yes">pixel</property> + <property name="label" translatable="yes">Icon size</property> </object> </child> </object> <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> <property name="x_options"></property> <property name="y_options"></property> </packing> @@ -564,17 +600,46 @@ </packing> </child> <child> - <object class="GtkAlignment" id="alignment40"> + <object class="GtkAlignment" id="alignment45"> <property name="visible">True</property> - <property name="left_padding">40</property> + <property name="right_padding">20</property> <child> - <object class="GtkLabel" id="label24"> + <object class="GtkLabel" id="label27"> <property name="visible">True</property> - <property name="label" translatable="yes">Icon size</property> + <property name="label" translatable="yes">pixel</property> </object> </child> </object> <packing> + <property name="left_attach">3</property> + <property name="right_attach">4</property> + <property name="x_options"></property> + <property name="y_options"></property> + </packing> + </child> + <child> + <object class="GtkAlignment" id="alignment16"> + <property name="visible">True</property> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="y_options"></property> + </packing> + </child> + <child> + <object class="GtkAlignment" id="alignment18"> + <property name="visible">True</property> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> <property name="x_options"></property> <property name="y_options"></property> </packing> @@ -629,72 +694,60 @@ <property name="visible">True</property> <property name="n_columns">6</property> <child> - <object class="GtkAlignment" id="alignment19"> - <property name="visible">True</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="y_options"></property> - </packing> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> </child> <child> - <object class="GtkAlignment" id="alignment50"> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <object class="GtkAlignment" id="alignment52"> <property name="visible">True</property> - <property name="left_padding">40</property> + <property name="right_padding">20</property> <child> - <object class="GtkLabel" id="label25"> + <object class="GtkLabel" id="label18"> <property name="visible">True</property> - <property name="label" translatable="yes">Update every</property> + <property name="label" translatable="yes">days</property> </object> </child> </object> <packing> + <property name="left_attach">5</property> + <property name="right_attach">6</property> <property name="x_options"></property> <property name="y_options"></property> </packing> </child> <child> - <object class="GtkAlignment" id="alignment51"> - <property name="visible">True</property> - <property name="left_padding">4</property> - <child> - <object class="GtkSpinButton" id="icon_max_count_spin"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="climb_rate">1</property> - <property name="snap_to_ticks">True</property> - <property name="numeric">True</property> - </object> - </child> - </object> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="x_options"></property> - <property name="y_options"></property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment53"> - <property name="visible">True</property> - <child> - <object class="GtkLabel" id="label3"> - <property name="visible">True</property> - <property name="label" translatable="yes">times or</property> - </object> - </child> - </object> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="y_options"></property> - </packing> - </child> - <child> <object class="GtkAlignment" id="alignment54"> <property name="visible">True</property> <property name="left_padding">4</property> @@ -717,23 +770,71 @@ </packing> </child> <child> - <object class="GtkAlignment" id="alignment52"> + <object class="GtkAlignment" id="alignment53"> <property name="visible">True</property> - <property name="right_padding">20</property> <child> - <object class="GtkLabel" id="label18"> + <object class="GtkLabel" id="label3"> <property name="visible">True</property> - <property name="label" translatable="yes">days</property> + <property name="label" translatable="yes">times or</property> + </object> + </child> + </object> + <packing> + <property name="left_attach">3</property> + <property name="right_attach">4</property> + <property name="y_options"></property> + </packing> + </child> + <child> + <object class="GtkAlignment" id="alignment51"> + <property name="visible">True</property> + <property name="left_padding">4</property> + <child> + <object class="GtkSpinButton" id="icon_max_count_spin"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="climb_rate">1</property> + <property name="snap_to_ticks">True</property> + <property name="numeric">True</property> </object> </child> </object> <packing> - <property name="left_attach">5</property> - <property name="right_attach">6</property> + <property name="left_attach">2</property> + <property name="right_attach">3</property> <property name="x_options"></property> <property name="y_options"></property> </packing> </child> + <child> + <object class="GtkAlignment" id="alignment50"> + <property name="visible">True</property> + <property name="left_padding">40</property> + <child> + <object class="GtkLabel" id="label25"> + <property name="visible">True</property> + <property name="label" translatable="yes">Update every</property> + </object> + </child> + </object> + <packing> + <property name="x_options"></property> + <property name="y_options"></property> + </packing> + </child> + <child> + <object class="GtkAlignment" id="alignment19"> + <property name="visible">True</property> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="y_options"></property> + </packing> + </child> </object> <packing> <property name="expand">False</property>