Mercurial > pidgin-twitter
changeset 6:ca8f95431962
fixed indentation
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Wed, 30 Apr 2008 17:06:58 +0900 |
parents | 6ac1867d7e8e |
children | 44a66c52b190 |
files | pidgin-twitter.c |
diffstat | 1 files changed, 80 insertions(+), 91 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin-twitter.c Wed Apr 30 17:02:47 2008 +0900 +++ b/pidgin-twitter.c Wed Apr 30 17:06:58 2008 +0900 @@ -30,7 +30,8 @@ #include "version.h" #include "sound.h" -extern gchar *botch_utf(const gchar *msg, gsize len, gsize *newlen) __attribute__ ((weak)); +extern gchar *botch_utf(const gchar *msg, gsize len, gsize * newlen) + __attribute__ ((weak)); #define PIDGINTWITTER_PLUGIN_ID "pidgin_twitter" #define OPT_PIDGINTWITTER "/plugins/pidgin_twitter" @@ -40,45 +41,42 @@ #define TWITTER_FORMAT "@<a href='http://twitter.com/%s'>%s</a>" #define twitter_debug(fmt, ...) purple_debug(PURPLE_DEBUG_INFO, PIDGINTWITTER_PLUGIN_ID, \ - fmt, ## __VA_ARGS__); + fmt, ## __VA_ARGS__); #define twitter_error(fmt, ...) purple_debug(PURPLE_DEBUG_ERROR, PIDGINTWITTER_PLUGIN_ID, \ - fmt, ## __VA_ARGS__); + fmt, ## __VA_ARGS__); /* globals */ static GRegex *preg; static gboolean -eval(const GMatchInfo *match_info, GString *result, gpointer user_data) +eval(const GMatchInfo * match_info, GString * result, gpointer user_data) { gchar sub[128]; gchar *match = g_match_info_fetch(match_info, 0); - snprintf(sub, 128, TWITTER_FORMAT, - match + 1, // +1 is to strip preceding '@'. + snprintf(sub, 128, TWITTER_FORMAT, match + 1, // +1 is to strip preceding '@'. match + 1); - twitter_debug("sub = %s\n", sub); + twitter_debug("sub = %s\n", sub); g_string_append(result, sub); g_free(match); return FALSE; } -static void -translate(gchar **str) +static void translate(gchar **str) { gchar *newstr; twitter_debug("*str = %s\n", *str); - newstr = g_regex_replace_eval( - preg, // compiled regex - *str, // subject string - -1, // length of the subject string - 0, // start position - 0, // match options - eval, // function to call for each match - NULL, // user data (not used) - NULL); // error handler + newstr = g_regex_replace_eval(preg, // compiled regex + *str, // subject string + -1, // length of the subject string + 0, // start position + 0, // match options + eval, // function to call for each match + NULL, // user data (not used) + NULL); // error handler twitter_debug("newstr = %s\n", newstr); @@ -86,8 +84,7 @@ *str = newstr; } -static void -playsound(gchar **str) +static void playsound(gchar **str) { GMatchInfo *match_info; GList *list, *lp; @@ -95,31 +92,30 @@ list = purple_prefs_get_string_list(OPT_USERLIST); g_return_if_fail(list != NULL); - g_regex_match (preg, *str, 0, &match_info); - while (g_match_info_matches (match_info)) - { - gchar *user = g_match_info_fetch (match_info, 0); + g_regex_match(preg, *str, 0, &match_info); + while(g_match_info_matches(match_info)) { + gchar *user = g_match_info_fetch(match_info, 0); twitter_debug("user = %s\n", user); for(lp = list; lp; lp = g_list_next(lp)) { twitter_debug("lp->data = %s\n", (char *)lp->data); - if(!strcmp(user, lp->data) || !strcmp(user+1, lp->data)) { + if(!strcmp(user, lp->data) || !strcmp(user + 1, lp->data)) { twitter_debug("match. play sound\n"); purple_sound_play_event(PURPLE_SOUND_POUNCE_DEFAULT, NULL); } } - g_free (user); - g_match_info_next (match_info, NULL); + g_free(user); + g_match_info_next(match_info, NULL); } - g_match_info_free (match_info); + g_match_info_free(match_info); } static gboolean -process_im_cb(PurpleAccount *account, char *sender, char **buffer, - PurpleConversation *conv, int *flags, void *data) +process_im_cb(PurpleAccount * account, char *sender, char **buffer, + PurpleConversation * conv, int *flags, void *data) { const gchar *proto; @@ -128,8 +124,7 @@ twitter_debug("proto = %s\n", proto); twitter_debug("sender = %s\n", sender); - if (!strcmp(proto, "prpl-jabber") && - !strcmp(sender, "twitter@twitter.com")) { + if(!strcmp(proto, "prpl-jabber") && !strcmp(sender, "twitter@twitter.com")) { if(purple_prefs_get_bool(OPT_PLAYSOUND)) { /* playsound */ playsound(buffer); @@ -142,90 +137,84 @@ return FALSE; } -static gboolean -load_plugin(PurplePlugin *plugin) +static gboolean load_plugin(PurplePlugin * plugin) { - /* connect to signal */ - purple_signal_connect(purple_conversations_get_handle(), "writing-im-msg", - plugin, PURPLE_CALLBACK(process_im_cb), NULL); + /* connect to signal */ + purple_signal_connect(purple_conversations_get_handle(), "writing-im-msg", + plugin, PURPLE_CALLBACK(process_im_cb), NULL); - return TRUE; + return TRUE; } -static gboolean -unload_plugin(PurplePlugin *plugin) +static gboolean unload_plugin(PurplePlugin * plugin) { - twitter_debug("pidgin-twitter unload called\n"); + twitter_debug("pidgin-twitter unload called\n"); g_regex_unref(preg); preg = NULL; - return TRUE; + return TRUE; } -static PurplePluginPrefFrame * -get_plugin_pref_frame(PurplePlugin *plugin) +static PurplePluginPrefFrame *get_plugin_pref_frame(PurplePlugin * plugin) { - PurplePluginPref *pref; - PurplePluginPrefFrame *frame = purple_plugin_pref_frame_new(); + PurplePluginPref *pref; + PurplePluginPrefFrame *frame = purple_plugin_pref_frame_new(); - /* create gtk elements for the plugin preferences */ - pref = purple_plugin_pref_new_with_label("Pidgin-Twitter Configuration"); - purple_plugin_pref_frame_add(frame, pref); + /* create gtk elements for the plugin preferences */ + pref = purple_plugin_pref_new_with_label("Pidgin-Twitter Configuration"); + purple_plugin_pref_frame_add(frame, pref); - pref = purple_plugin_pref_new_with_name_and_label(OPT_TRANSLATE, - "Translate @username to the link to the user"); - purple_plugin_pref_frame_add(frame, pref); + pref = purple_plugin_pref_new_with_name_and_label(OPT_TRANSLATE, + "Translate @username to the link to the user"); + purple_plugin_pref_frame_add(frame, pref); - pref = purple_plugin_pref_new_with_name_and_label(OPT_PLAYSOUND, - "Play sound if a reply to listed users arrives"); - purple_plugin_pref_frame_add(frame, pref); + pref = purple_plugin_pref_new_with_name_and_label(OPT_PLAYSOUND, + "Play sound if a reply to listed users arrives"); + purple_plugin_pref_frame_add(frame, pref); // xxx add pref field for OPT_USERLIST (gtk packing is needed) --yaz - return frame; + return frame; } -static PurplePluginUiInfo pref_info = -{ - get_plugin_pref_frame +static PurplePluginUiInfo pref_info = { + get_plugin_pref_frame }; -static PurplePluginInfo info = -{ - PURPLE_PLUGIN_MAGIC, - PURPLE_MAJOR_VERSION, - PURPLE_MINOR_VERSION, - PURPLE_PLUGIN_STANDARD, /**< type */ - NULL, /**< ui_req */ - 0, /**< flags */ - NULL, /**< deps */ - PURPLE_PRIORITY_DEFAULT, /**< priority */ - PIDGINTWITTER_PLUGIN_ID, /**< id */ - "Pidgin-Twitter", /**< name */ - "0.1.0", /**< version */ - "replaces @username in a message with link to the user", /** summary */ - "replaces @username in a message with link to the user", /** desc */ - "Yoshiki Yazawa (yaz@honeyplanet.jp)", /**< author */ - "http://www.honeyplanet.jp/", /**< homepage */ - load_plugin, /**< load */ - unload_plugin, /**< unload */ - NULL, /**< destroy */ - NULL, /**< ui_info */ - NULL, /**< extra_info */ - &pref_info, /**< pref info */ - NULL +static PurplePluginInfo info = { + PURPLE_PLUGIN_MAGIC, + PURPLE_MAJOR_VERSION, + PURPLE_MINOR_VERSION, + PURPLE_PLUGIN_STANDARD, /**< type */ + NULL, /**< ui_req */ + 0, /**< flags */ + NULL, /**< deps */ + PURPLE_PRIORITY_DEFAULT, /**< priority */ + PIDGINTWITTER_PLUGIN_ID, /**< id */ + "Pidgin-Twitter", /**< name */ + "0.1.0", /**< version */ + "replaces @username in a message with link to the user", /** summary */ + "replaces @username in a message with link to the user", /** desc */ + "Yoshiki Yazawa (yaz@honeyplanet.jp)", /**< author */ + "http://www.honeyplanet.jp/", /**< homepage */ + load_plugin, /**< load */ + unload_plugin, /**< unload */ + NULL, /**< destroy */ + NULL, /**< ui_info */ + NULL, /**< extra_info */ + &pref_info, /**< pref info */ + NULL }; -static void -init_plugin(PurplePlugin *plugin) +static void init_plugin(PurplePlugin * plugin) { - g_type_init(); + g_type_init(); - /* add plugin preferences */ - purple_prefs_add_none(OPT_PIDGINTWITTER); - purple_prefs_add_bool(OPT_TRANSLATE, TRUE); - purple_prefs_add_bool(OPT_PLAYSOUND, TRUE); - purple_prefs_add_string_list(OPT_USERLIST, NULL); + /* add plugin preferences */ + purple_prefs_add_none(OPT_PIDGINTWITTER); + purple_prefs_add_bool(OPT_TRANSLATE, TRUE); + purple_prefs_add_bool(OPT_PLAYSOUND, TRUE); + purple_prefs_add_string_list(OPT_USERLIST, NULL); /* compile regex */ preg = g_regex_new("@[A-Za-z0-9_]+", 0, 0, NULL);