Mercurial > pidgin-twitter
comparison pidgin-twitter.h @ 119:0c4a83f734cd
- duplication avoidance for the posted messages has been implemented.
- time stamps in a log will be printed correctly.
- some functions have been relocated in the source file.
- some data definitions and macros have been moved to the header file.
- minor modification to Makefile.in.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Fri, 18 Jul 2008 01:00:18 +0900 |
parents | 48bfe86ff990 |
children | a37dd74c8355 |
comparison
equal
deleted
inserted
replaced
118:8b097fcb9243 | 119:0c4a83f734cd |
---|---|
1 #ifndef _PIDGIN_TWITTER_H_ | 1 #ifndef _PIDGIN_TWITTER_H_ |
2 #define _PIDGIN_TWITTER_H_ | 2 #define _PIDGIN_TWITTER_H_ |
3 | 3 |
4 #define _XOPEN_SOURCE 600 | |
4 #include <stdio.h> | 5 #include <stdio.h> |
5 #include <stdlib.h> | 6 #include <stdlib.h> |
6 #include <string.h> | 7 #include <string.h> |
7 #include <glib.h> | 8 #include <glib.h> |
8 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <time.h> | |
11 #include <locale.h> | |
12 | |
13 #include <gdk-pixbuf/gdk-pixbuf.h> | |
14 #include <libxml/xmlreader.h> | |
9 | 15 |
10 #include "gtkplugin.h" | 16 #include "gtkplugin.h" |
11 #include "util.h" | 17 #include "util.h" |
12 #include "debug.h" | 18 #include "debug.h" |
13 #include "connection.h" | 19 #include "connection.h" |
26 USER_FIRST_LINE, | 32 USER_FIRST_LINE, |
27 USER_FORMATTED, | 33 USER_FORMATTED, |
28 CHANNEL, | 34 CHANNEL, |
29 IMAGE_IDENTICA | 35 IMAGE_IDENTICA |
30 }; | 36 }; |
37 | |
38 /* service id */ | |
39 enum { | |
40 unknown_service = 0, | |
41 twitter_service, | |
42 wassr_service, | |
43 identica_service | |
44 }; | |
45 | |
46 /* container to hold icon data */ | |
47 typedef struct _icon_data { | |
48 gint icon_id; // image id | |
49 gboolean requested; // TRUE if download icon has been requested | |
50 GList *request_list; // marker list | |
51 PurpleUtilFetchUrlData *fetch_data; // icon fetch data | |
52 } icon_data; | |
53 | |
54 /* used by got_icon_cb */ | |
55 typedef struct _got_icon_data { | |
56 gchar *user_name; | |
57 gint service; | |
58 } got_icon_data; | |
59 | |
60 /* used by eval */ | |
61 typedef struct _eval_data { | |
62 gint which; | |
63 gint service; | |
64 } eval_data; | |
65 | |
66 /* container for api based retrieve */ | |
67 typedef struct _status { | |
68 gchar *created_at; | |
69 gchar *text; | |
70 gchar *screen_name; | |
71 gchar *profile_image_url; | |
72 time_t time; | |
73 guint id; | |
74 } status_t; | |
75 | |
76 /* container for api based post */ | |
77 typedef struct twitter_message { | |
78 PurpleAccount *account; | |
79 char *status; | |
80 time_t time; | |
81 } twitter_message_t; | |
82 | |
31 | 83 |
32 #define PLUGIN_ID "gtk-honeyplanet-pidgin_twitter" | 84 #define PLUGIN_ID "gtk-honeyplanet-pidgin_twitter" |
33 #define PLUGIN_NAME "pidgin-twitter" | 85 #define PLUGIN_NAME "pidgin-twitter" |
34 | 86 |
35 /* options */ | 87 /* options */ |
76 #define P_USER "^\\(.+?\\)\\s*([A-Za-z0-9_]+):" | 128 #define P_USER "^\\(.+?\\)\\s*([A-Za-z0-9_]+):" |
77 #define P_USER_FIRST_LINE "^\\(.+?\\)\\s*.+:\\s*([A-Za-z0-9_]+):" | 129 #define P_USER_FIRST_LINE "^\\(.+?\\)\\s*.+:\\s*([A-Za-z0-9_]+):" |
78 #define P_USER_FORMATTED "^.*?<a .+?>([A-Za-z0-9_]+)</a>:" | 130 #define P_USER_FORMATTED "^.*?<a .+?>([A-Za-z0-9_]+)</a>:" |
79 #define P_CHANNEL "^(.*?<a .+?>[A-Za-z0-9_]+</a>: \\r?\\n?#)([A-Za-z0-9_]+) " | 131 #define P_CHANNEL "^(.*?<a .+?>[A-Za-z0-9_]+</a>: \\r?\\n?#)([A-Za-z0-9_]+) " |
80 #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_]+\"/>" | 132 #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_]+\"/>" |
133 | |
134 /* twitter API specific macros */ | |
135 #define TWITTER_STATUS_POST "POST /statuses/update.xml HTTP/1.0\r\n" \ | |
136 "Host: twitter.com\r\n" \ | |
137 "User-Agent: Pidgin-Twitter\r\n" \ | |
138 "Authorization: Basic %s\r\n" \ | |
139 "Content-Length: %d\r\n\r\n" | |
140 | |
141 #define TWITTER_STATUS_FORMAT "status=%s" | |
142 #define TWITTER_STATUS_TERMINATOR "\r\n\r\n" | |
143 | |
144 #define TWITTER_BASE_URL "http://twitter.com" | |
145 | |
146 #define TWITTER_STATUS_GET "GET /statuses/friends_timeline.xml HTTP/1.0\r\n" \ | |
147 "Host: twitter.com\r\n" \ | |
148 "User-Agent: Pidgin-Twitter\r\n" \ | |
149 "Authorization: Basic %s\r\n" | |
150 | |
151 /* wassr specific macros */ | |
152 #define WASSR_POST_LEN (255 * 4) | |
81 | 153 |
82 /* debug macros */ | 154 /* debug macros */ |
83 #define twitter_debug(fmt, ...) purple_debug(PURPLE_DEBUG_INFO, PLUGIN_NAME, "%s():%4d: " fmt, __FUNCTION__, (int)__LINE__, ## __VA_ARGS__); | 155 #define twitter_debug(fmt, ...) purple_debug(PURPLE_DEBUG_INFO, PLUGIN_NAME, "%s():%4d: " fmt, __FUNCTION__, (int)__LINE__, ## __VA_ARGS__); |
84 #define twitter_error(fmt, ...) purple_debug(PURPLE_DEBUG_ERROR, PLUGIN_NAME, "%s():%4d: " fmt, __FUNCTION__, (int)__LINE__, ## __VA_ARGS__); | 156 #define twitter_error(fmt, ...) purple_debug(PURPLE_DEBUG_ERROR, PLUGIN_NAME, "%s():%4d: " fmt, __FUNCTION__, (int)__LINE__, ## __VA_ARGS__); |
85 | 157 |
121 static void remove_marks_func(gpointer key, gpointer value, gpointer user_data); | 193 static void remove_marks_func(gpointer key, gpointer value, gpointer user_data); |
122 static void cancel_fetch_func(gpointer key, gpointer value, gpointer user_data); | 194 static void cancel_fetch_func(gpointer key, gpointer value, gpointer user_data); |
123 static gint get_service_type(PurpleConversation *conv); | 195 static gint get_service_type(PurpleConversation *conv); |
124 static GdkPixbuf *make_scaled_pixbuf(const gchar *url_text, gsize len); | 196 static GdkPixbuf *make_scaled_pixbuf(const gchar *url_text, gsize len); |
125 | 197 |
198 static void parse_user(xmlNode *user, status_t *st); | |
199 static void parse_status(xmlNode *status, status_t *st); | |
200 static void get_status_with_api_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, size_t len, const gchar *error_message); | |
201 static gboolean get_status_with_api(gpointer data); | |
202 | |
126 #endif | 203 #endif |