Mercurial > pidgin-twitter
changeset 256:9fb8f597adf3
- moved is_*_account() functions to util.c.
- moved get_service_type() functions to util.c.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Sun, 23 Nov 2008 00:45:35 +0900 |
parents | dcf53bc05627 |
children | 954753a52ed8 |
files | main.c util.c util.h |
diffstat | 3 files changed, 151 insertions(+), 147 deletions(-) [+] |
line wrap: on
line diff
--- a/main.c Sat Nov 22 18:14:10 2008 +0900 +++ b/main.c Sun Nov 23 00:45:35 2008 +0900 @@ -42,13 +42,6 @@ #endif /* prototypes */ -static gboolean is_twitter_conv(PurpleConversation *conv); -static gboolean is_wassr_account(PurpleAccount *account, const char *name); -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 cleanup_hash_entry_func(gpointer key, gpointer value, gpointer user_data); static void init_plugin(PurplePlugin *plugin); @@ -692,141 +685,6 @@ gtk_widget_queue_draw(pidgin_conv_get_window(gtkconv)->window); } -gboolean -is_twitter_account(PurpleAccount *account, const char *name) -{ - const gchar *proto = purple_account_get_protocol_id(account); - - if(g_strstr_len(name, 19, "twitter@twitter.com") && - g_strstr_len(proto, 11, "prpl-jabber")) { - return TRUE; - } - - return FALSE; -} - -static gboolean -is_twitter_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_twitter_account(account, name); -} - -static gboolean -is_wassr_account(PurpleAccount *account, const char *name) -{ - const gchar *proto = purple_account_get_protocol_id(account); - - if(g_strstr_len(name, 18, "wassr-bot@wassr.jp") && - g_strstr_len(proto, 11, "prpl-jabber")) { - return TRUE; - } - - return FALSE; -} - -static gboolean -is_wassr_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_wassr_account(account, name); -} - -static gboolean -is_identica_account(PurpleAccount *account, const char *name) -{ - const gchar *proto = purple_account_get_protocol_id(account); - - if(g_strstr_len(name, 16, "update@identi.ca") && - g_strstr_len(proto, 11, "prpl-jabber")) { - return TRUE; - } - - return FALSE; -} - -static gboolean -is_identica_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_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); -} - -gint -get_service_type_by_account(PurpleAccount *account, const char *sender) -{ - gint service = unknown_service; - - g_return_val_if_fail(account != NULL, unknown_service); - g_return_val_if_fail(sender != NULL, unknown_service); - - if(is_twitter_account(account, sender)) - service = twitter_service; - else if(is_wassr_account(account, sender)) - service = wassr_service; - else if(is_identica_account(account, sender)) - service = identica_service; - else if(is_jisko_account(account, sender)) - service = jisko_service; - - return service; -} - -gint -get_service_type(PurpleConversation *conv) -{ - gint service = unknown_service; - - g_return_val_if_fail(conv != NULL, unknown_service); - - if(is_twitter_conv(conv)) - service = twitter_service; - else if(is_wassr_conv(conv)) - service = wassr_service; - else if(is_identica_conv(conv)) - service = identica_service; - else if(is_jisko_conv(conv)) - service = jisko_service; - - return service; -} - static void conv_created_cb(PurpleConversation *conv, gpointer null) { @@ -1401,11 +1259,11 @@ static PidginPluginUiInfo ui_info = { prefs_get_frame, - 0, /* page number - reserved */ - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - NULL, /* reserved 3 */ - NULL /* reserved 4 */ + 0, /* page number - reserved */ + NULL, /* reserved 1 */ + NULL, /* reserved 2 */ + NULL, /* reserved 3 */ + NULL /* reserved 4 */ }; static PurplePluginInfo info = {
--- a/util.c Sat Nov 22 18:14:10 2008 +0900 +++ b/util.c Sun Nov 23 00:45:35 2008 +0900 @@ -257,3 +257,138 @@ } twitter_debug("result=%s\n", *str); } + +gboolean +is_twitter_account(PurpleAccount *account, const char *name) +{ + const gchar *proto = purple_account_get_protocol_id(account); + + if(g_strstr_len(name, 19, "twitter@twitter.com") && + g_strstr_len(proto, 11, "prpl-jabber")) { + return TRUE; + } + + return FALSE; +} + +gboolean +is_twitter_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_twitter_account(account, name); +} + +gboolean +is_wassr_account(PurpleAccount *account, const char *name) +{ + const gchar *proto = purple_account_get_protocol_id(account); + + if(g_strstr_len(name, 18, "wassr-bot@wassr.jp") && + g_strstr_len(proto, 11, "prpl-jabber")) { + return TRUE; + } + + return FALSE; +} + +gboolean +is_wassr_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_wassr_account(account, name); +} + +gboolean +is_identica_account(PurpleAccount *account, const char *name) +{ + const gchar *proto = purple_account_get_protocol_id(account); + + if(g_strstr_len(name, 16, "update@identi.ca") && + g_strstr_len(proto, 11, "prpl-jabber")) { + return TRUE; + } + + return FALSE; +} + +gboolean +is_identica_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_identica_account(account, name); +} + +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; +} + +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); +} + +gint +get_service_type_by_account(PurpleAccount *account, const char *sender) +{ + gint service = unknown_service; + + g_return_val_if_fail(account != NULL, unknown_service); + g_return_val_if_fail(sender != NULL, unknown_service); + + if(is_twitter_account(account, sender)) + service = twitter_service; + else if(is_wassr_account(account, sender)) + service = wassr_service; + else if(is_identica_account(account, sender)) + service = identica_service; + else if(is_jisko_account(account, sender)) + service = jisko_service; + + return service; +} + +gint +get_service_type(PurpleConversation *conv) +{ + gint service = unknown_service; + + g_return_val_if_fail(conv != NULL, unknown_service); + + if(is_twitter_conv(conv)) + service = twitter_service; + else if(is_wassr_conv(conv)) + service = wassr_service; + else if(is_identica_conv(conv)) + service = identica_service; + else if(is_jisko_conv(conv)) + service = jisko_service; + + return service; +}
--- a/util.h Sat Nov 22 18:14:10 2008 +0900 +++ b/util.h Sun Nov 23 00:45:35 2008 +0900 @@ -6,4 +6,15 @@ gchar *strip_html_markup(const gchar *src); gboolean ensure_path_exists(const char *dir); +gboolean is_twitter_conv(PurpleConversation *conv); +gboolean is_wassr_account(PurpleAccount *account, const char *name); +gboolean is_wassr_conv(PurpleConversation *conv); +gboolean is_identica_account(PurpleAccount *account, const char *name); +gboolean is_identica_conv(PurpleConversation *conv); +gboolean is_jisko_account(PurpleAccount *account, const char *name); +gboolean is_jisko_conv(PurpleConversation *conv); + +gint get_service_type(PurpleConversation *conv); +gint get_service_type_by_account(PurpleAccount *account, const char *sender); + #endif