Mercurial > pidgin-twitter
annotate pidgin-twitter.c @ 10:4bd8c89b4749
now it plays sound when sender of message is in the userlist.
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Thu, 01 May 2008 13:37:49 +0900 |
parents | c6b80f47d4df |
children | 7ea2a717af42 |
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 |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
33 #define RECIPIENT 0 |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
34 #define SENDER 1 |
0 | 35 |
36 #define PIDGINTWITTER_PLUGIN_ID "pidgin_twitter" | |
37 #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
|
38 #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
|
39 #define OPT_TRANSLATE_SENDER OPT_PIDGINTWITTER "/translate_sender" |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
40 #define OPT_PLAYSOUND_RECIPIENT OPT_PIDGINTWITTER "/playsound_recipient" |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
41 #define OPT_PLAYSOUND_SENDER OPT_PIDGINTWITTER "/playsound_sender" |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
42 #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
|
43 #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
|
44 #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
|
45 #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
|
46 #define DEFAULT_LIST "(list of users: separated with ' ,:;')" |
0 | 47 |
2 | 48 #define twitter_debug(fmt, ...) purple_debug(PURPLE_DEBUG_INFO, PIDGINTWITTER_PLUGIN_ID, \ |
6 | 49 fmt, ## __VA_ARGS__); |
2 | 50 #define twitter_error(fmt, ...) purple_debug(PURPLE_DEBUG_ERROR, PIDGINTWITTER_PLUGIN_ID, \ |
0 | 51 |
52 /* globals */ | |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
53 static GRegex *regp[2]; |
0 | 54 |
1 | 55 static gboolean |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
56 eval(const GMatchInfo * match_info, GString * result, gpointer user_data) |
1 | 57 { |
58 gchar sub[128]; | |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
59 gchar *match = g_match_info_fetch(match_info, 1); |
1 | 60 |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
61 int which = *(int *)user_data; |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
62 |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
63 snprintf(sub, 128, which ? SENDER_FORMAT : RECIPIENT_FORMAT, match, match); |
6 | 64 twitter_debug("sub = %s\n", sub); |
1 | 65 g_string_append(result, sub); |
66 g_free(match); | |
67 | |
68 return FALSE; | |
69 } | |
0 | 70 |
8 | 71 static void |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
72 translate(gchar **str, int which) |
0 | 73 { |
1 | 74 gchar *newstr; |
75 | |
76 twitter_debug("*str = %s\n", *str); | |
0 | 77 |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
78 newstr = g_regex_replace_eval(regp[which], // compiled regex |
6 | 79 *str, // subject string |
80 -1, // length of the subject string | |
81 0, // start position | |
82 0, // match options | |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
83 eval, // function to call for each match |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
84 &which, // user data |
6 | 85 NULL); // error handler |
1 | 86 |
87 twitter_debug("newstr = %s\n", newstr); | |
88 | |
89 g_free(*str); | |
90 *str = newstr; | |
91 } | |
0 | 92 |
8 | 93 static void |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
94 playsound(gchar **str, int which) |
1 | 95 { |
96 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
|
97 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
|
98 gchar **candidates = NULL, **candidate = NULL; |
0 | 99 |
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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 |
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
105 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
|
106 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
|
107 return; |
1 | 108 |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
109 g_regex_match(regp[which], *str, 0, &match_info); |
6 | 110 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
|
111 gchar *user = g_match_info_fetch(match_info, 1); |
1 | 112 twitter_debug("user = %s\n", user); |
0 | 113 |
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
|
114 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
|
115 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
|
116 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
|
117 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
|
118 if(!strcmp(user, *candidate)) { |
1 | 119 twitter_debug("match. play sound\n"); |
8 | 120 purple_sound_play_event( |
121 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
|
122 break; |
1 | 123 } |
124 } | |
6 | 125 g_free(user); |
126 g_match_info_next(match_info, NULL); | |
1 | 127 } |
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
|
128 g_strfreev(candidates); |
6 | 129 g_match_info_free(match_info); |
0 | 130 } |
131 | |
132 | |
1 | 133 static gboolean |
6 | 134 process_im_cb(PurpleAccount * account, char *sender, char **buffer, |
135 PurpleConversation * conv, int *flags, void *data) | |
0 | 136 { |
137 const gchar *proto; | |
138 | |
1 | 139 /* check if the message is from twitter */ |
0 | 140 proto = purple_account_get_protocol_id(account); |
1 | 141 twitter_debug("proto = %s\n", proto); |
142 twitter_debug("sender = %s\n", sender); | |
0 | 143 |
6 | 144 if(!strcmp(proto, "prpl-jabber") && !strcmp(sender, "twitter@twitter.com")) { |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
145 /* playsound */ |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
146 if(purple_prefs_get_bool(OPT_PLAYSOUND_SENDER)) { |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
147 playsound(buffer, SENDER); |
1 | 148 } |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
149 if(purple_prefs_get_bool(OPT_PLAYSOUND_RECIPIENT)) { |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
150 playsound(buffer, RECIPIENT); |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
151 } |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
152 |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
153 /* translate */ |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
154 if(purple_prefs_get_bool(OPT_TRANSLATE_SENDER)) { |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
155 translate(buffer, SENDER); |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
156 } |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
157 if(purple_prefs_get_bool(OPT_TRANSLATE_RECIPIENT)) { |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
158 translate(buffer, RECIPIENT); |
1 | 159 } |
0 | 160 } |
1 | 161 return FALSE; |
0 | 162 } |
163 | |
8 | 164 static gboolean |
165 load_plugin(PurplePlugin * plugin) | |
0 | 166 { |
6 | 167 /* connect to signal */ |
168 purple_signal_connect(purple_conversations_get_handle(), "writing-im-msg", | |
169 plugin, PURPLE_CALLBACK(process_im_cb), NULL); | |
0 | 170 |
6 | 171 return TRUE; |
0 | 172 } |
173 | |
8 | 174 static gboolean |
175 unload_plugin(PurplePlugin * plugin) | |
0 | 176 { |
6 | 177 twitter_debug("pidgin-twitter unload called\n"); |
0 | 178 |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
179 g_regex_unref(regp[RECIPIENT]); |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
180 g_regex_unref(regp[SENDER]); |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
181 |
6 | 182 return TRUE; |
0 | 183 } |
184 | |
8 | 185 static PurplePluginPrefFrame * |
186 get_plugin_pref_frame(PurplePlugin * plugin) | |
0 | 187 { |
6 | 188 PurplePluginPref *pref; |
189 PurplePluginPrefFrame *frame = purple_plugin_pref_frame_new(); | |
0 | 190 |
6 | 191 /* create gtk elements for the plugin preferences */ |
192 pref = purple_plugin_pref_new_with_label("Pidgin-Twitter Configuration"); | |
193 purple_plugin_pref_frame_add(frame, pref); | |
0 | 194 |
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
|
195 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
|
196 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
|
197 "Translate @username to the link to the user"); |
6 | 198 purple_plugin_pref_frame_add(frame, pref); |
0 | 199 |
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
|
200 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
|
201 OPT_TRANSLATE_SENDER, |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
202 "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
|
203 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
|
204 |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
205 pref = purple_plugin_pref_new_with_name_and_label( |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
206 OPT_PLAYSOUND_RECIPIENT, |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
207 "Play a sound on an arrival of reply to the user in the Userlist"); |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
208 purple_plugin_pref_frame_add(frame, pref); |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
209 |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
210 pref = purple_plugin_pref_new_with_name_and_label( |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
211 OPT_PLAYSOUND_SENDER, |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
212 "Play a sound if sender of a message is in the Userlist"); |
6 | 213 purple_plugin_pref_frame_add(frame, pref); |
1 | 214 |
8 | 215 /* sound id selector */ |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
216 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
|
217 |
8 | 218 purple_plugin_pref_set_type(pref, PURPLE_PLUGIN_PREF_CHOICE); |
219 purple_plugin_pref_add_choice(pref, "Arrive", GINT_TO_POINTER(0)); | |
220 purple_plugin_pref_add_choice(pref, "Leave", GINT_TO_POINTER(1)); | |
221 purple_plugin_pref_add_choice(pref, "Receive", GINT_TO_POINTER(2)); | |
222 purple_plugin_pref_add_choice(pref, "Fist Receive", GINT_TO_POINTER(3)); | |
223 purple_plugin_pref_add_choice(pref, "Send", GINT_TO_POINTER(4)); | |
224 purple_plugin_pref_add_choice(pref, "Chat Join", GINT_TO_POINTER(5)); | |
225 purple_plugin_pref_add_choice(pref, "Chat Leave", GINT_TO_POINTER(6)); | |
226 purple_plugin_pref_add_choice(pref, "Chat You Say", GINT_TO_POINTER(7)); | |
227 purple_plugin_pref_add_choice(pref, "Chat Someone Say", GINT_TO_POINTER(8)); | |
228 purple_plugin_pref_add_choice(pref, "Pounce Default", GINT_TO_POINTER(9)); | |
229 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
|
230 |
8 | 231 purple_plugin_pref_frame_add(frame, pref); |
232 | |
233 /* 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
|
234 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
|
235 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
|
236 "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
|
237 purple_plugin_pref_frame_add(frame, pref); |
1 | 238 |
6 | 239 return frame; |
0 | 240 } |
241 | |
6 | 242 static PurplePluginUiInfo pref_info = { |
243 get_plugin_pref_frame | |
0 | 244 }; |
245 | |
6 | 246 static PurplePluginInfo info = { |
247 PURPLE_PLUGIN_MAGIC, | |
248 PURPLE_MAJOR_VERSION, | |
249 PURPLE_MINOR_VERSION, | |
250 PURPLE_PLUGIN_STANDARD, /**< type */ | |
251 NULL, /**< ui_req */ | |
252 0, /**< flags */ | |
253 NULL, /**< deps */ | |
254 PURPLE_PRIORITY_DEFAULT, /**< priority */ | |
255 PIDGINTWITTER_PLUGIN_ID, /**< id */ | |
256 "Pidgin-Twitter", /**< name */ | |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
257 "0.3.1", /**< version */ |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
258 "replaces @username to a link and play sound", /** summary */ |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
259 "replaces @username in a link and play sound", /** desc */ |
6 | 260 "Yoshiki Yazawa (yaz@honeyplanet.jp)", /**< author */ |
261 "http://www.honeyplanet.jp/", /**< homepage */ | |
262 load_plugin, /**< load */ | |
263 unload_plugin, /**< unload */ | |
264 NULL, /**< destroy */ | |
265 NULL, /**< ui_info */ | |
266 NULL, /**< extra_info */ | |
267 &pref_info, /**< pref info */ | |
268 NULL | |
0 | 269 }; |
270 | |
8 | 271 static void |
272 init_plugin(PurplePlugin * plugin) | |
0 | 273 { |
6 | 274 g_type_init(); |
0 | 275 |
6 | 276 /* add plugin preferences */ |
277 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
|
278 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
|
279 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
|
280 |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
281 purple_prefs_add_bool(OPT_PLAYSOUND_RECIPIENT, TRUE); |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
282 purple_prefs_add_bool(OPT_PLAYSOUND_SENDER, FALSE); |
8 | 283 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
|
284 purple_prefs_add_string(OPT_USERLIST, DEFAULT_LIST); |
0 | 285 |
1 | 286 /* compile regex */ |
10
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
287 regp[RECIPIENT] = g_regex_new("@([A-Za-z0-9_]+)", 0, 0, NULL); |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
288 regp[SENDER] = g_regex_new("^<body>([A-Za-z0-9_]+): ", 0, 0, NULL); |
0 | 289 } |
290 | |
291 PURPLE_INIT_PLUGIN(pidgin_twitter, init_plugin, info) |