Mercurial > pidgin-twitter
diff 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 |
line wrap: on
line diff
--- a/pidgin-twitter.h Thu Jul 17 23:53:15 2008 +0900 +++ b/pidgin-twitter.h Fri Jul 18 01:00:18 2008 +0900 @@ -1,11 +1,17 @@ #ifndef _PIDGIN_TWITTER_H_ #define _PIDGIN_TWITTER_H_ +#define _XOPEN_SOURCE 600 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <glib.h> #include <sys/stat.h> +#include <time.h> +#include <locale.h> + +#include <gdk-pixbuf/gdk-pixbuf.h> +#include <libxml/xmlreader.h> #include "gtkplugin.h" #include "util.h" @@ -29,6 +35,52 @@ IMAGE_IDENTICA }; +/* service id */ +enum { + unknown_service = 0, + twitter_service, + wassr_service, + identica_service +}; + +/* container to hold icon data */ +typedef struct _icon_data { + gint icon_id; // image id + gboolean requested; // TRUE if download icon has been requested + GList *request_list; // marker list + PurpleUtilFetchUrlData *fetch_data; // icon fetch data +} icon_data; + +/* used by got_icon_cb */ +typedef struct _got_icon_data { + gchar *user_name; + gint service; +} got_icon_data; + +/* used by eval */ +typedef struct _eval_data { + gint which; + gint service; +} eval_data; + +/* container for api based retrieve */ +typedef struct _status { + gchar *created_at; + gchar *text; + gchar *screen_name; + gchar *profile_image_url; + time_t time; + guint id; +} status_t; + +/* container for api based post */ +typedef struct twitter_message { + PurpleAccount *account; + char *status; + time_t time; +} twitter_message_t; + + #define PLUGIN_ID "gtk-honeyplanet-pidgin_twitter" #define PLUGIN_NAME "pidgin-twitter" @@ -79,6 +131,26 @@ #define P_CHANNEL "^(.*?<a .+?>[A-Za-z0-9_]+</a>: \\r?\\n?#)([A-Za-z0-9_]+) " #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_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" + +/* wassr specific macros */ +#define WASSR_POST_LEN (255 * 4) + /* 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__); @@ -123,4 +195,9 @@ static gint get_service_type(PurpleConversation *conv); static GdkPixbuf *make_scaled_pixbuf(const gchar *url_text, gsize len); +static void parse_user(xmlNode *user, status_t *st); +static void parse_status(xmlNode *status, status_t *st); +static void get_status_with_api_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, size_t len, const gchar *error_message); +static gboolean get_status_with_api(gpointer data); + #endif