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