Mercurial > pidgin-twitter
comparison pidgin-twitter.h @ 64:da37857f3033
- separated header things into pidgin-twitter.h
- preliminary save icon feature
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Sun, 22 Jun 2008 16:02:44 +0900 |
parents | |
children | 4949d4eb34ec |
comparison
equal
deleted
inserted
replaced
63:760006015519 | 64:da37857f3033 |
---|---|
1 #ifndef _PIDGIN_TWITTER_H_ | |
2 #define _PIDGIN_TWITTER_H_ | |
3 | |
4 #include <stdio.h> | |
5 #include <stdlib.h> | |
6 #include <string.h> | |
7 #include <glib.h> | |
8 | |
9 #include "gtkplugin.h" | |
10 #include "util.h" | |
11 #include "debug.h" | |
12 #include "connection.h" | |
13 #include "version.h" | |
14 #include "sound.h" | |
15 #include "gtkconv.h" | |
16 #include "gtkimhtml.h" | |
17 | |
18 /* regp id */ | |
19 #define RECIPIENT 0 | |
20 #define SENDER 1 | |
21 #define COMMAND 2 | |
22 #define PSEUDO 3 | |
23 #define MESSAGE 4 | |
24 #define USER 5 | |
25 #define USER_FIRST_LINE 6 | |
26 #define USER_FORMATTED 7 | |
27 | |
28 #define PLUGIN_ID "gtk-honeyplanet-pidgin_twitter" | |
29 #define PLUGIN_NAME "pidgin-twitter" | |
30 | |
31 /* options */ | |
32 #define OPT_PIDGINTWITTER "/plugins/pidgin_twitter" | |
33 #define OPT_TRANSLATE_RECIPIENT OPT_PIDGINTWITTER "/translate_recipient" | |
34 #define OPT_TRANSLATE_SENDER OPT_PIDGINTWITTER "/translate_sender" | |
35 #define OPT_PLAYSOUND_RECIPIENT OPT_PIDGINTWITTER "/playsound_recipient" | |
36 #define OPT_PLAYSOUND_SENDER OPT_PIDGINTWITTER "/playsound_sender" | |
37 #define OPT_SOUNDID_RECIPIENT OPT_PIDGINTWITTER "/soundid_recipient" | |
38 #define OPT_SOUNDID_SENDER OPT_PIDGINTWITTER "/soundid_sender" | |
39 #define OPT_ESCAPE_PSEUDO OPT_PIDGINTWITTER "/escape_pseudo" | |
40 #define OPT_USERLIST_RECIPIENT OPT_PIDGINTWITTER "/userlist_recipient" | |
41 #define OPT_USERLIST_SENDER OPT_PIDGINTWITTER "/userlist_sender" | |
42 #define OPT_COUNTER OPT_PIDGINTWITTER "/counter" | |
43 #define OPT_SUPPRESS_OOPS OPT_PIDGINTWITTER "/suppress_oops" | |
44 #define OPT_PREVENT_NOTIFICATION OPT_PIDGINTWITTER "/prevent_notification" | |
45 #define OPT_ICON_DIR OPT_PIDGINTWITTER "/icon_dir" | |
46 | |
47 /* formats and templates */ | |
48 #define RECIPIENT_FORMAT "@<a href='http://twitter.com/%s'>%s</a>" | |
49 #define SENDER_FORMAT "%s<a href='http://twitter.com/%s'>%s</a>: " | |
50 #define DEFAULT_LIST "(list of users: separated with ' ,:;')" | |
51 #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>" | |
52 | |
53 /* patterns */ | |
54 #define P_RECIPIENT "@([A-Za-z0-9_]+)" | |
55 #define P_SENDER "^(\\r?\\n?)([A-Za-z0-9_]+): " | |
56 #define P_COMMAND "^(?:\\s*)([dDfFgGlLmMnNtTwW]{1}\\s+[A-Za-z0-9_]+)(?:\\s*\\Z)" | |
57 #define P_PSEUDO "^\\s*(?:[\"#$%&'()*+,\\-./:;<=>?\\[\\\\\\]_`{|}~]|[^\\s\\x21-\\x7E])*([dDfFgGlLmMnNtTwW]{1})(?:\\Z|\\s+|[^\\x21-\\x7E]+\\Z)" | |
58 #define P_MESSAGE "^<body>(.*)</body>" | |
59 #define P_USER "^\\(.+?\\)\\s*([A-Za-z0-9_]+):" | |
60 #define P_USER_FIRST_LINE "^\\(.+?\\)\\s*.+:\\s*([A-Za-z0-9_]+):" | |
61 #define P_USER_FORMATTED "^.*?<a .+?>([A-Za-z0-9_]+)</a>:" | |
62 | |
63 /* debug macros */ | |
64 #define twitter_debug(fmt, ...) purple_debug(PURPLE_DEBUG_INFO, PLUGIN_NAME, "%s():%4d: " fmt, __FUNCTION__, (int)__LINE__, ## __VA_ARGS__); | |
65 #define twitter_error(fmt, ...) purple_debug(PURPLE_DEBUG_ERROR, PLUGIN_NAME, "%s():%4d: " fmt, __FUNCTION__, (int)__LINE__, ## __VA_ARGS__); | |
66 | |
67 /* prototypes */ | |
68 static void escape(gchar **str); | |
69 static gboolean sending_im_cb(PurpleAccount *account, char *recipient, char **buffer, void *data); | |
70 static gboolean eval(const GMatchInfo *match_info, GString *result, gpointer user_data); | |
71 static void translate(gchar **str, int which); | |
72 static void playsound(gchar **str, int which); | |
73 static gboolean writing_im_cb(PurpleAccount *account, char *sender, char **buffer, PurpleConversation *conv, int *flags, void *data); | |
74 static void insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, gchar *new_text, gint new_text_length, gpointer user_data); | |
75 static void delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, GtkTextIter *end_pos, gpointer user_data); | |
76 static void detach_from_window(void); | |
77 static void detach_from_gtkconv(PidginConversation *gtkconv, gpointer null); | |
78 static void delete_requested_icon_marks(PidginConversation *gtkconv); | |
79 static void attach_to_window(void); | |
80 static void attach_to_gtkconv(PidginConversation *gtkconv, gpointer null); | |
81 static gboolean is_twitter_account(PurpleAccount *account, const char *name); | |
82 static gboolean is_twitter_conv(PurpleConversation *conv); | |
83 static void conv_created_cb(PurpleConversation *conv, gpointer null); | |
84 static void deleting_conv_cb(PurpleConversation *conv); | |
85 static gboolean receiving_im_cb(PurpleAccount *account, char **sender, char **buffer, PurpleConversation *conv, PurpleMessageFlags *flags, void *data); | |
86 static void insert_requested_icon(gpointer data, gpointer user_data); | |
87 static void downloaded_icon_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message); | |
88 static void request_icon(const char *buffer); | |
89 static void displayed_im_cb(PurpleAccount *account, const char *who, char *message, PurpleConversation *conv, PurpleMessageFlags flags); | |
90 static gboolean load_plugin(PurplePlugin *plugin); | |
91 static gboolean unload_plugin(PurplePlugin *plugin); | |
92 static void counter_prefs_cb(const char *name, PurplePrefType type, gconstpointer val, gpointer data); | |
93 static PurplePluginPrefFrame *get_plugin_pref_frame(PurplePlugin *plugin); | |
94 static void init_plugin(PurplePlugin *plugin); | |
95 | |
96 #endif |