comparison pidgin-twitter.h @ 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 300241bd1879
children dff611cb9f7b
comparison
equal deleted inserted replaced
329:300241bd1879 330:cc41ee1f5d3a
21 #include <connection.h> 21 #include <connection.h>
22 #include <version.h> 22 #include <version.h>
23 #include <sound.h> 23 #include <sound.h>
24 #include <gtkconv.h> 24 #include <gtkconv.h>
25 #include <gtkimhtml.h> 25 #include <gtkimhtml.h>
26 #include <core.h>
26 27
27 #include "util.h" 28 #include "util.h"
28 #include "prefs.h" 29 #include "prefs.h"
29 #include "twitter_api.h" 30 #include "twitter_api.h"
30 #include "icon.h" 31 #include "icon.h"
47 IMAGE_IDENTICA, 48 IMAGE_IDENTICA,
48 IMAGE_JISKO, 49 IMAGE_JISKO,
49 IMAGE_FFEED, 50 IMAGE_FFEED,
50 SIZE_128_WASSR, 51 SIZE_128_WASSR,
51 EXCESS_LF, 52 EXCESS_LF,
52 TRAIL_HASH 53 TRAIL_HASH,
54 MESSAGE_ID
53 }; 55 };
54 56
55 /* service id */ 57 /* service id */
56 enum { 58 enum {
57 unknown_service = -1, 59 unknown_service = -1,
168 #define CHANNEL_FORMAT_WASSR "%s<a href='http://wassr.jp/channel/%s'>%s</a> " 170 #define CHANNEL_FORMAT_WASSR "%s<a href='http://wassr.jp/channel/%s'>%s</a> "
169 #define CHANNEL_FORMAT_IDENTICA "%s<a href='http://identi.ca/tag/%s'>%s</a> " 171 #define CHANNEL_FORMAT_IDENTICA "%s<a href='http://identi.ca/tag/%s'>%s</a> "
170 #define TAG_FORMAT_TWITTER "%s<a href='http://twitter.com/search?q=%%23%s'>#%s</a>" 172 #define TAG_FORMAT_TWITTER "%s<a href='http://twitter.com/search?q=%%23%s'>#%s</a>"
171 #define TAG_FORMAT_IDENTICA "#<a href='http://identi.ca/tag/%s'>%s</a>" 173 #define TAG_FORMAT_IDENTICA "#<a href='http://identi.ca/tag/%s'>%s</a>"
172 #define GROUP_FORMAT_IDENTICA "!<a href='http://identi.ca/group/%s'>%s</a>" 174 #define GROUP_FORMAT_IDENTICA "!<a href='http://identi.ca/group/%s'>%s</a>"
175 #define LINK_FORMAT_TWITTER " <a href='PT://reply-twitter/?id=%s&user=%s'>R</a> <a href='PT://fav-twitter/?id=%s'>F</a> <a href='PT://retweet-twitter/?id=%s&user=%s&msg=%s'>RT</a>"
176 #define TWITTER_REPLY_FORMAT "in_reply_to_status_id=%llu"
173 177
174 #define DEFAULT_LIST "(list of users: separated with ' ,:;')" 178 #define DEFAULT_LIST "(list of users: separated with ' ,:;')"
175 #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>" 179 #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>"
176 #define EMPTY "" 180 #define EMPTY ""
177 181
192 #define P_IMAGE_JISKO "<img src=\"(https?://jisko.net/.+/img/avatar/.+_side\\..+)\" alt=\"Avatar\" />" 196 #define P_IMAGE_JISKO "<img src=\"(https?://jisko.net/.+/img/avatar/.+_side\\..+)\" alt=\"Avatar\" />"
193 #define P_IMAGE_FFEED "<img src=\"(https?://i.friendfeed.com/.+)\" alt=\"" 197 #define P_IMAGE_FFEED "<img src=\"(https?://i.friendfeed.com/.+)\" alt=\""
194 #define P_SIZE_128_WASSR "\\.128\\." 198 #define P_SIZE_128_WASSR "\\.128\\."
195 #define P_EXCESS_LF "([\\r|\\n]{2,})" 199 #define P_EXCESS_LF "([\\r|\\n]{2,})"
196 #define P_TRAIL_HASH "( #\\s+$)" 200 #define P_TRAIL_HASH "( #\\s+$)"
201 #define P_MESSAGE_ID " ptmsgid=([0-9]+)$"
197 202
198 /* twitter API specific macros */ 203 /* twitter API specific macros */
199 #define TWITTER_BASE_URL "http://twitter.com" 204 #define TWITTER_BASE_URL "http://twitter.com"
200 #define TWITTER_STATUS_GET "GET /statuses/friends_timeline.xml?count=%d HTTP/1.1\r\n" \ 205 #define TWITTER_STATUS_GET "GET /statuses/friends_timeline.xml?count=%d HTTP/1.1\r\n" \
201 "Host: twitter.com\r\n" \ 206 "Host: twitter.com\r\n" \
205 "Host: twitter.com\r\n" \ 210 "Host: twitter.com\r\n" \
206 "User-Agent: pidgin-twitter\r\n" \ 211 "User-Agent: pidgin-twitter\r\n" \
207 "Authorization: Basic %s\r\n" \ 212 "Authorization: Basic %s\r\n" \
208 "Content-Length: %d\r\n" 213 "Content-Length: %d\r\n"
209 #define TWITTER_STATUS_FORMAT "status=%s&source=pidgintwitter" 214 #define TWITTER_STATUS_FORMAT "status=%s&source=pidgintwitter"
215
216 #define TWITTER_FAV_POST "POST /favorites/create/%llu.xml HTTP/1.1\r\n" \
217 "Host: twitter.com\r\n" \
218 "User-Agent: pidgin-twitter\r\n" \
219 "Authorization: Basic %s\r\n"
220
221
210 #define TWITTER_DEFAULT_INTERVAL (60) 222 #define TWITTER_DEFAULT_INTERVAL (60)
211 #define TWITTER_OLD_DEFAULT_ICON_URL "http://static.twitter.com/images/default_profile_bigger.png" 223 #define TWITTER_OLD_DEFAULT_ICON_URL "http://static.twitter.com/images/default_profile_bigger.png"
212 #define TWITTER_DEFAULT_ICON_URL "http://s.twimg.com/images/default_profile_3_bigger.png" 224 #define TWITTER_DEFAULT_ICON_URL "http://s.twimg.com/images/default_profile_3_bigger.png"
213 225
214 #define TWITTER_DEFAULT_RETRIEVE_COUNT (20) 226 #define TWITTER_DEFAULT_RETRIEVE_COUNT (20)
232 /* misc macros */ 244 /* misc macros */
233 #define DEFAULT_ICON_SIZE (48) 245 #define DEFAULT_ICON_SIZE (48)
234 #define DEFAULT_ICON_MAX_COUNT (50) 246 #define DEFAULT_ICON_MAX_COUNT (50)
235 #define DEFAULT_ICON_MAX_DAYS (7) 247 #define DEFAULT_ICON_MAX_DAYS (7)
236 #define DAYS_TO_SECONDS(d) ((d) * 86400) 248 #define DAYS_TO_SECONDS(d) ((d) * 86400)
237 #define NUM_REGPS (18) 249 #define NUM_REGPS (19)
238 #define NUM_SERVICES (5) /* twitter, wassr, identica, jisko, ffeed. */ 250 #define NUM_SERVICES (5) /* twitter, wassr, identica, jisko, ffeed. */
239 251
240 /* debug macros */ 252 /* debug macros */
241 #define twitter_debug(fmt, ...) do { if(purple_prefs_get_bool(OPT_LOG_OUTPUT)) purple_debug(PURPLE_DEBUG_INFO, PLUGIN_NAME, "%s: %s():%4d: " fmt, __FILE__, __FUNCTION__, (int)__LINE__, ## __VA_ARGS__); } while(0); 253 #define twitter_debug(fmt, ...) do { if(purple_prefs_get_bool(OPT_LOG_OUTPUT)) purple_debug(PURPLE_DEBUG_INFO, PLUGIN_NAME, "%s: %s():%4d: " fmt, __FILE__, __FUNCTION__, (int)__LINE__, ## __VA_ARGS__); } while(0);
242 #define twitter_error(fmt, ...) do { if(purple_prefs_get_bool(OPT_LOG_OUTPUT)) purple_debug(PURPLE_DEBUG_ERROR, PLUGIN_NAME, "%s: %s():%4d: " fmt, __FILE__, __FUNCTION__, (int)__LINE__, ## __VA_ARGS__); } while(0); 254 #define twitter_error(fmt, ...) do { if(purple_prefs_get_bool(OPT_LOG_OUTPUT)) purple_debug(PURPLE_DEBUG_ERROR, PLUGIN_NAME, "%s: %s():%4d: " fmt, __FILE__, __FUNCTION__, (int)__LINE__, ## __VA_ARGS__); } while(0);