changeset 124:ec861f8a2268

- added new pref value for API based fetch interval. - some hard-coded constant have been replaced with macros. - removed unnecessary code.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 18 Jul 2008 20:03:59 +0900
parents 76012df4e194
children f0305c387d32
files pidgin-twitter.c pidgin-twitter.h
diffstat 2 files changed, 15 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin-twitter.c	Fri Jul 18 19:17:30 2008 +0900
+++ b/pidgin-twitter.c	Fri Jul 18 20:03:59 2008 +0900
@@ -1173,13 +1173,6 @@
         /* only attach to twitter conversation window */
         switch(service) {
         case twitter_service:
-#if 0
-            /* api based retrieve */ //xxx should configurable
-            if(purple_prefs_get_bool(OPT_API_BASE_POST)) {
-                get_status_with_api((gpointer)conv);
-                g_timeout_add_seconds(60, get_status_with_api, (gpointer)conv);
-            }
-#endif
             attach_to_conv(conv, NULL);
             break;
         case wassr_service:
@@ -1356,12 +1349,12 @@
     switch(service) {
     case twitter_service:
         /* api based retrieve */ //xxx should configurable
-#if 1
         if(purple_prefs_get_bool(OPT_API_BASE_POST)) {
             get_status_with_api((gpointer)conv);
-            g_timeout_add_seconds(60, get_status_with_api, (gpointer)conv);
+            g_timeout_add_seconds(
+                purple_prefs_get_int(OPT_API_BASE_GET_INTERVAL),
+                get_status_with_api, (gpointer)conv);
         }
-#endif
         attach_to_conv(conv, NULL);
         break;
     case wassr_service:
@@ -2578,9 +2571,10 @@
     purple_prefs_add_string(OPT_SCREEN_NAME_TWITTER, EMPTY);
     purple_prefs_add_string(OPT_PASSWORD_TWITTER, EMPTY);
 
-    purple_prefs_add_int(OPT_ICON_SIZE, 48);
+    purple_prefs_add_int(OPT_ICON_SIZE, DEFAULT_ICON_SIZE);
     purple_prefs_add_string(OPT_SCREEN_NAME_WASSR, EMPTY);
     purple_prefs_add_string(OPT_SCREEN_NAME_IDENTICA, EMPTY);
+    purple_prefs_add_int(OPT_API_BASE_GET_INTERVAL, TWITTER_DEFAULT_INTERVAL);
 
 }
 
--- a/pidgin-twitter.h	Fri Jul 18 19:17:30 2008 +0900
+++ b/pidgin-twitter.h	Fri Jul 18 20:03:59 2008 +0900
@@ -108,6 +108,7 @@
 #define OPT_PASSWORD_TWITTER    OPT_PIDGINTWITTER "/password_twitter"
 #define OPT_SHOW_ICON           OPT_PIDGINTWITTER "/show_icon"
 #define OPT_ICON_SIZE           OPT_PIDGINTWITTER "/icon_size"
+#define OPT_API_BASE_GET_INTERVAL OPT_PIDGINTWITTER "/api_base_get_interval"
 
 /* formats and templates */
 #define RECIPIENT_FORMAT_TWITTER "@<a href='http://twitter.com/%s'>%s</a>"
@@ -133,25 +134,26 @@
 #define P_IMAGE_IDENTICA    "<img src=\"(http://avatar.identi.ca/[A-Za-z0-9-.]+)\" class=\"avatar profile\" width=\"96\" height=\"96\" alt=\"[A-Za-z0-0_]+\"/>"
 
 /* twitter API specific macros */
+#define TWITTER_BASE_URL "http://twitter.com"
+#define TWITTER_STATUS_GET "GET /statuses/friends_timeline.xml HTTP/1.0\r\n" \
+    "Host: twitter.com\r\n"                                          \
+    "User-Agent: Pidgin-Twitter\r\n"                                 \
+    "Authorization: Basic %s\r\n"
 #define TWITTER_STATUS_POST "POST /statuses/update.xml HTTP/1.0\r\n" \
     "Host: twitter.com\r\n"                                          \
     "User-Agent: Pidgin-Twitter\r\n"                                 \
     "Authorization: Basic %s\r\n"                                    \
     "Content-Length: %d\r\n\r\n"
-
 #define TWITTER_STATUS_FORMAT "status=%s"
 #define TWITTER_STATUS_TERMINATOR "\r\n\r\n"
-
-#define TWITTER_BASE_URL "http://twitter.com"
-
-#define TWITTER_STATUS_GET "GET /statuses/friends_timeline.xml HTTP/1.0\r\n" \
-    "Host: twitter.com\r\n"                                          \
-    "User-Agent: Pidgin-Twitter\r\n"                                 \
-    "Authorization: Basic %s\r\n"
+#define TWITTER_DEFAULT_INTERVAL 60
 
 /* wassr specific macros */
 #define WASSR_POST_LEN (255 * 4)
 
+/* misc macros */
+#define DEFAULT_ICON_SIZE 48
+
 /* debug macros */
 #define twitter_debug(fmt, ...)	purple_debug(PURPLE_DEBUG_INFO, PLUGIN_NAME, "%s():%4d:  " fmt, __FUNCTION__, (int)__LINE__, ## __VA_ARGS__);
 #define twitter_error(fmt, ...)	purple_debug(PURPLE_DEBUG_ERROR, PLUGIN_NAME, "%s():%4d:  " fmt, __FUNCTION__, (int)__LINE__, ## __VA_ARGS__);