Mercurial > pidgin-twitter
annotate pidgin-twitter.c @ 9:c6b80f47d4df
added capability to translate sender name into link
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Thu, 01 May 2008 05:50:48 +0900 |
parents | 2c7c9eb4cdda |
children | 4bd8c89b4749 |
rev | line source |
---|---|
0 | 1 /* |
2 * Pidgin-Twitter plugin. | |
3 * | |
4 * This program is free software; you can redistribute it and/or | |
5 * modify it under the terms of the GNU General Public License as | |
6 * published by the Free Software Foundation; either version 2 of the | |
7 * License, or (at your option) any later version. | |
8 * | |
9 * This program is distributed in the hope that it will be useful, but | |
10 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 * General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License | |
15 * along with this program; if not, write to the Free Software | |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
17 * 02111-1307, USA. | |
18 */ | |
19 #define PURPLE_PLUGINS 1 | |
20 | |
21 #include <stdio.h> | |
22 #include <stdlib.h> | |
23 #include <string.h> | |
24 #include <glib.h> | |
25 | |
26 #include "gtkplugin.h" | |
27 #include "util.h" | |
28 #include "debug.h" | |
29 #include "connection.h" | |
30 #include "version.h" | |
1 | 31 #include "sound.h" |
0 | 32 |
33 | |
34 #define PIDGINTWITTER_PLUGIN_ID "pidgin_twitter" | |
35 #define OPT_PIDGINTWITTER "/plugins/pidgin_twitter" | |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
36 #define OPT_TRANSLATE_RECIPIENT OPT_PIDGINTWITTER "/translate_recipient" |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
37 #define OPT_TRANSLATE_SENDER OPT_PIDGINTWITTER "/translate_sender" |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
38 #define OPT_PLAYSOUND OPT_PIDGINTWITTER "/playsound" |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
39 #define OPT_SOUNDID OPT_PIDGINTWITTER "/soundid" |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
40 #define OPT_USERLIST OPT_PIDGINTWITTER "/userlist" |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
41 #define RECIPIENT_FORMAT "@<a href='http://twitter.com/%s'>%s</a>" |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
42 #define SENDER_FORMAT "<a href='http://twitter.com/%s'>%s</a> :" |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
43 #define DEFAULT_LIST "(list of users: separated with ' ,:;')" |
0 | 44 |
2 | 45 #define twitter_debug(fmt, ...) purple_debug(PURPLE_DEBUG_INFO, PIDGINTWITTER_PLUGIN_ID, \ |
6 | 46 fmt, ## __VA_ARGS__); |
2 | 47 #define twitter_error(fmt, ...) purple_debug(PURPLE_DEBUG_ERROR, PIDGINTWITTER_PLUGIN_ID, \ |
6 | 48 fmt, ## __VA_ARGS__); |
0 | 49 |
50 /* globals */ | |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
51 static GRegex *regrcpt; |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
52 static GRegex *regsndr; |
0 | 53 |
1 | 54 static gboolean |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
55 eval_sender(const GMatchInfo * match_info, GString * result, gpointer user_data) |
1 | 56 { |
57 gchar sub[128]; | |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
58 gchar *match = g_match_info_fetch(match_info, 1); |
1 | 59 |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
60 snprintf(sub, 128, SENDER_FORMAT, match, match); |
6 | 61 twitter_debug("sub = %s\n", sub); |
1 | 62 g_string_append(result, sub); |
63 g_free(match); | |
64 | |
65 return FALSE; | |
66 } | |
0 | 67 |
8 | 68 static void |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
69 translate_sender(gchar **str) |
0 | 70 { |
1 | 71 gchar *newstr; |
72 | |
73 twitter_debug("*str = %s\n", *str); | |
0 | 74 |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
75 newstr = g_regex_replace_eval(regsndr, // compiled regex |
6 | 76 *str, // subject string |
77 -1, // length of the subject string | |
78 0, // start position | |
79 0, // match options | |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
80 eval_sender, // function to call for each match |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
81 NULL, // user data (not used) |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
82 NULL); // error handler |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
83 |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
84 twitter_debug("newstr = %s\n", newstr); |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
85 |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
86 g_free(*str); |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
87 *str = newstr; |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
88 } |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
89 |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
90 static gboolean |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
91 eval_recipient(const GMatchInfo * match_info, GString * result, gpointer user_data) |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
92 { |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
93 gchar sub[128]; |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
94 gchar *match = g_match_info_fetch(match_info, 1); |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
95 |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
96 snprintf(sub, 128, RECIPIENT_FORMAT, match, match); |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
97 twitter_debug("sub = %s\n", sub); |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
98 g_string_append(result, sub); |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
99 g_free(match); |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
100 |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
101 return FALSE; |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
102 } |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
103 |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
104 static void |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
105 translate_recipient(gchar **str) |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
106 { |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
107 gchar *newstr; |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
108 |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
109 twitter_debug("*str = %s\n", *str); |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
110 |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
111 newstr = g_regex_replace_eval(regrcpt, // compiled regex |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
112 *str, // subject string |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
113 -1, // length of the subject string |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
114 0, // start position |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
115 0, // match options |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
116 eval_recipient, // function to call for each match |
6 | 117 NULL, // user data (not used) |
118 NULL); // error handler | |
1 | 119 |
120 twitter_debug("newstr = %s\n", newstr); | |
121 | |
122 g_free(*str); | |
123 *str = newstr; | |
124 } | |
0 | 125 |
8 | 126 static void |
127 playsound(gchar **str) | |
1 | 128 { |
129 GMatchInfo *match_info; | |
7
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
130 const gchar *list; |
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
131 gchar **candidates = NULL, **candidate = NULL; |
0 | 132 |
7
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
133 list = purple_prefs_get_string(OPT_USERLIST); |
5
6ac1867d7e8e
string list should be initialized with NULL
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2
diff
changeset
|
134 g_return_if_fail(list != NULL); |
7
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
135 if(!strcmp(list, DEFAULT_LIST)) |
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
136 return; |
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
137 |
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
138 candidates = g_strsplit_set(list, " ,:;", 0); |
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
139 if(!candidates) |
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
140 return; |
1 | 141 |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
142 g_regex_match(regrcpt, *str, 0, &match_info); |
6 | 143 while(g_match_info_matches(match_info)) { |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
144 gchar *user = g_match_info_fetch(match_info, 1); |
1 | 145 twitter_debug("user = %s\n", user); |
0 | 146 |
7
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
147 for(candidate = candidates; *candidate ; candidate++) { |
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
148 if(!strcmp(*candidate, "")) |
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
149 continue; |
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
150 twitter_debug("candidate = %s\n", *candidate); |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
151 if(!strcmp(user, *candidate)) { |
1 | 152 twitter_debug("match. play sound\n"); |
8 | 153 purple_sound_play_event( |
154 purple_prefs_get_int(OPT_SOUNDID), NULL); | |
7
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
155 break; |
1 | 156 } |
157 } | |
6 | 158 g_free(user); |
159 g_match_info_next(match_info, NULL); | |
1 | 160 } |
7
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
161 g_strfreev(candidates); |
6 | 162 g_match_info_free(match_info); |
0 | 163 } |
164 | |
165 | |
1 | 166 static gboolean |
6 | 167 process_im_cb(PurpleAccount * account, char *sender, char **buffer, |
168 PurpleConversation * conv, int *flags, void *data) | |
0 | 169 { |
170 const gchar *proto; | |
171 | |
1 | 172 /* check if the message is from twitter */ |
0 | 173 proto = purple_account_get_protocol_id(account); |
1 | 174 twitter_debug("proto = %s\n", proto); |
175 twitter_debug("sender = %s\n", sender); | |
0 | 176 |
6 | 177 if(!strcmp(proto, "prpl-jabber") && !strcmp(sender, "twitter@twitter.com")) { |
1 | 178 if(purple_prefs_get_bool(OPT_PLAYSOUND)) { |
179 /* playsound */ | |
180 playsound(buffer); | |
181 } | |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
182 if(purple_prefs_get_bool(OPT_TRANSLATE_SENDER)) { |
1 | 183 /* translate */ |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
184 translate_sender(buffer); |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
185 } |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
186 if(purple_prefs_get_bool(OPT_TRANSLATE_RECIPIENT)) { |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
187 /* translate */ |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
188 translate_recipient(buffer); |
1 | 189 } |
0 | 190 } |
1 | 191 return FALSE; |
0 | 192 } |
193 | |
8 | 194 static gboolean |
195 load_plugin(PurplePlugin * plugin) | |
0 | 196 { |
6 | 197 /* connect to signal */ |
198 purple_signal_connect(purple_conversations_get_handle(), "writing-im-msg", | |
199 plugin, PURPLE_CALLBACK(process_im_cb), NULL); | |
0 | 200 |
6 | 201 return TRUE; |
0 | 202 } |
203 | |
8 | 204 static gboolean |
205 unload_plugin(PurplePlugin * plugin) | |
0 | 206 { |
6 | 207 twitter_debug("pidgin-twitter unload called\n"); |
0 | 208 |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
209 g_regex_unref(regrcpt); |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
210 g_regex_unref(regsndr); |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
211 |
6 | 212 return TRUE; |
0 | 213 } |
214 | |
8 | 215 static PurplePluginPrefFrame * |
216 get_plugin_pref_frame(PurplePlugin * plugin) | |
0 | 217 { |
6 | 218 PurplePluginPref *pref; |
219 PurplePluginPrefFrame *frame = purple_plugin_pref_frame_new(); | |
0 | 220 |
6 | 221 /* create gtk elements for the plugin preferences */ |
222 pref = purple_plugin_pref_new_with_label("Pidgin-Twitter Configuration"); | |
223 purple_plugin_pref_frame_add(frame, pref); | |
0 | 224 |
7
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
225 pref = purple_plugin_pref_new_with_name_and_label( |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
226 OPT_TRANSLATE_RECIPIENT, |
7
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
227 "Translate @username to the link to the user"); |
6 | 228 purple_plugin_pref_frame_add(frame, pref); |
0 | 229 |
7
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
230 pref = purple_plugin_pref_new_with_name_and_label( |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
231 OPT_TRANSLATE_SENDER, |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
232 "Translate sender name to the link"); |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
233 purple_plugin_pref_frame_add(frame, pref); |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
234 |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
235 pref = purple_plugin_pref_new_with_name_and_label( |
7
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
236 OPT_PLAYSOUND, |
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
237 "Play a sound on a reply to the user in the Userlist"); |
6 | 238 purple_plugin_pref_frame_add(frame, pref); |
1 | 239 |
8 | 240 /* sound id selector */ |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
241 pref = purple_plugin_pref_new_with_name_and_label(OPT_SOUNDID, "Sound"); |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
242 |
8 | 243 purple_plugin_pref_set_type(pref, PURPLE_PLUGIN_PREF_CHOICE); |
244 purple_plugin_pref_add_choice(pref, "Arrive", GINT_TO_POINTER(0)); | |
245 purple_plugin_pref_add_choice(pref, "Leave", GINT_TO_POINTER(1)); | |
246 purple_plugin_pref_add_choice(pref, "Receive", GINT_TO_POINTER(2)); | |
247 purple_plugin_pref_add_choice(pref, "Fist Receive", GINT_TO_POINTER(3)); | |
248 purple_plugin_pref_add_choice(pref, "Send", GINT_TO_POINTER(4)); | |
249 purple_plugin_pref_add_choice(pref, "Chat Join", GINT_TO_POINTER(5)); | |
250 purple_plugin_pref_add_choice(pref, "Chat Leave", GINT_TO_POINTER(6)); | |
251 purple_plugin_pref_add_choice(pref, "Chat You Say", GINT_TO_POINTER(7)); | |
252 purple_plugin_pref_add_choice(pref, "Chat Someone Say", GINT_TO_POINTER(8)); | |
253 purple_plugin_pref_add_choice(pref, "Pounce Default", GINT_TO_POINTER(9)); | |
254 purple_plugin_pref_add_choice(pref, "Chat Nick Said", GINT_TO_POINTER(10)); | |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
255 |
8 | 256 purple_plugin_pref_frame_add(frame, pref); |
257 | |
258 /* user list */ | |
7
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
259 pref = purple_plugin_pref_new_with_name_and_label( |
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
260 OPT_USERLIST, |
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
261 "Userlist"); |
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
262 purple_plugin_pref_frame_add(frame, pref); |
1 | 263 |
6 | 264 return frame; |
0 | 265 } |
266 | |
6 | 267 static PurplePluginUiInfo pref_info = { |
268 get_plugin_pref_frame | |
0 | 269 }; |
270 | |
6 | 271 static PurplePluginInfo info = { |
272 PURPLE_PLUGIN_MAGIC, | |
273 PURPLE_MAJOR_VERSION, | |
274 PURPLE_MINOR_VERSION, | |
275 PURPLE_PLUGIN_STANDARD, /**< type */ | |
276 NULL, /**< ui_req */ | |
277 0, /**< flags */ | |
278 NULL, /**< deps */ | |
279 PURPLE_PRIORITY_DEFAULT, /**< priority */ | |
280 PIDGINTWITTER_PLUGIN_ID, /**< id */ | |
281 "Pidgin-Twitter", /**< name */ | |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
282 "0.3.0", /**< version */ |
6 | 283 "replaces @username in a message with link to the user", /** summary */ |
284 "replaces @username in a message with link to the user", /** desc */ | |
285 "Yoshiki Yazawa (yaz@honeyplanet.jp)", /**< author */ | |
286 "http://www.honeyplanet.jp/", /**< homepage */ | |
287 load_plugin, /**< load */ | |
288 unload_plugin, /**< unload */ | |
289 NULL, /**< destroy */ | |
290 NULL, /**< ui_info */ | |
291 NULL, /**< extra_info */ | |
292 &pref_info, /**< pref info */ | |
293 NULL | |
0 | 294 }; |
295 | |
8 | 296 static void |
297 init_plugin(PurplePlugin * plugin) | |
0 | 298 { |
6 | 299 g_type_init(); |
0 | 300 |
6 | 301 /* add plugin preferences */ |
302 purple_prefs_add_none(OPT_PIDGINTWITTER); | |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
303 purple_prefs_add_bool(OPT_TRANSLATE_RECIPIENT, TRUE); |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
304 purple_prefs_add_bool(OPT_TRANSLATE_SENDER, TRUE); |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
305 |
6 | 306 purple_prefs_add_bool(OPT_PLAYSOUND, TRUE); |
8 | 307 purple_prefs_add_int(OPT_SOUNDID, PURPLE_SOUND_POUNCE_DEFAULT); |
7
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
308 purple_prefs_add_string(OPT_USERLIST, DEFAULT_LIST); |
0 | 309 |
1 | 310 /* compile regex */ |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
311 regrcpt = g_regex_new("@([A-Za-z0-9_]+)", 0, 0, NULL); |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
312 regsndr = g_regex_new("^<body>([A-Za-z0-9_]+): ", 0, 0, NULL); |
0 | 313 } |
314 | |
315 PURPLE_INIT_PLUGIN(pidgin_twitter, init_plugin, info) |