Mercurial > pidgin-twitter
annotate pidgin-twitter.c @ 31:312a745dece6
added letter counter
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Sat, 10 May 2008 18:10:58 +0900 |
parents | e740ceed9337 |
children | 92715b489de6 |
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" |
31 | 32 #include "gtkconv.h" |
0 | 33 |
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
|
34 #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
|
35 #define SENDER 1 |
19
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
36 #define COMMAND 2 |
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
37 #define PSEUDO 3 |
0 | 38 |
31 | 39 #define PLUGIN_ID "gtk-honeyplanet-pidgin_twitter" |
40 #define PLUGIN_NAME "pidgin-twitter" | |
41 | |
0 | 42 #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
|
43 #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
|
44 #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
|
45 #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
|
46 #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
|
47 #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
|
48 #define OPT_SOUNDID_SENDER OPT_PIDGINTWITTER "/soundid_sender" |
19
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
49 #define OPT_ESCAPE_PSEUDO OPT_PIDGINTWITTER "/escape_pseudo" |
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
|
50 #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
|
51 #define OPT_USERLIST_SENDER OPT_PIDGINTWITTER "/userlist_sender" |
31 | 52 #define OPT_COUNTER OPT_PIDGINTWITTER "/counter" |
53 | |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
54 #define RECIPIENT_FORMAT "@<a href='http://twitter.com/%s'>%s</a>" |
14
e58e7c1fcbe5
fixed typo. pointed out by nosuke too. :D
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
13
diff
changeset
|
55 #define SENDER_FORMAT "<a href='http://twitter.com/%s'>%s</a>: " |
31 | 56 #define DEFAULT_LIST "(list of users: separated with ' ,:;')" |
57 | |
0 | 58 |
31 | 59 #define twitter_debug(fmt, ...) purple_debug(PURPLE_DEBUG_INFO, PLUGIN_NAME, \ |
6 | 60 fmt, ## __VA_ARGS__); |
31 | 61 #define twitter_error(fmt, ...) purple_debug(PURPLE_DEBUG_ERROR, PLUGIN_NAME, \ |
0 | 62 |
63 /* globals */ | |
19
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
64 static GRegex *regp[4]; |
0 | 65 |
31 | 66 /* prototypes */ |
67 static gboolean is_twitter_conv(PurpleConversation *conv); | |
68 static void attach_to_gtkconv(PidginConversation *gtkconv, gpointer null); | |
69 static void detach_from_gtkconv(PidginConversation *gtkconv, gpointer null); | |
70 static void escape(gchar **str); | |
71 | |
72 | |
20
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
73 static void |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
74 escape(gchar **str) |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
75 { |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
76 GMatchInfo *match_info = NULL; |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
77 gchar *newstr = NULL, *match = NULL; |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
78 gboolean flag = FALSE; |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
79 |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
80 /* search genuine command */ |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
81 g_regex_match(regp[COMMAND], *str, 0, &match_info); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
82 while(g_match_info_matches(match_info)) { |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
83 match = g_match_info_fetch(match_info, 1); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
84 twitter_debug("command = %s\n", match); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
85 g_free(match); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
86 g_match_info_next(match_info, NULL); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
87 flag = TRUE; |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
88 } |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
89 g_match_info_free(match_info); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
90 match_info = NULL; |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
91 |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
92 if(flag) { |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
93 return; |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
94 } |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
95 |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
96 /* if not found, check pseudo command */ |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
97 g_regex_match(regp[PSEUDO], *str, 0, &match_info); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
98 while(g_match_info_matches(match_info)) { |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
99 match = g_match_info_fetch(match_info, 1); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
100 twitter_debug("pseudo = %s\n", match); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
101 g_free(match); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
102 g_match_info_next(match_info, NULL); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
103 flag = TRUE; |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
104 } |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
105 g_match_info_free(match_info); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
106 match_info = NULL; |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
107 |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
108 /* if there is pseudo one, escape it */ |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
109 if(flag) { |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
110 /* put ". " to the beginning of buffer */ |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
111 newstr = g_strdup_printf(". %s", *str); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
112 twitter_debug("*str = %s\n", *str); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
113 twitter_debug("newstr = %s\n", newstr); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
114 g_free(*str); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
115 *str = newstr; |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
116 } |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
117 } |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
118 |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
119 static gboolean |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
120 sending_im_cb(PurpleAccount * account, char *recipient, char **buffer, |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
121 void *data) |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
122 { |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
123 const gchar *proto; |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
124 |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
125 /* check if the message is from twitter */ |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
126 proto = purple_account_get_protocol_id(account); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
127 twitter_debug("sending_im_cb\n"); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
128 twitter_debug("proto = %s\n", proto); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
129 twitter_debug("recipient = %s\n", recipient); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
130 |
31 | 131 if(!strcmp(proto, "prpl-jabber") && |
132 !strcmp(recipient, "twitter@twitter.com")) { | |
20
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
133 /* escape */ |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
134 if(purple_prefs_get_bool(OPT_ESCAPE_PSEUDO)) { |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
135 escape(buffer); |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
136 } |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
137 } |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
138 return FALSE; |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
139 } |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
140 |
1 | 141 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
|
142 eval(const GMatchInfo * match_info, GString * result, gpointer user_data) |
1 | 143 { |
144 gchar sub[128]; | |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
145 gchar *match = g_match_info_fetch(match_info, 1); |
1 | 146 |
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 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
|
148 |
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 snprintf(sub, 128, which ? SENDER_FORMAT : RECIPIENT_FORMAT, match, match); |
6 | 150 twitter_debug("sub = %s\n", sub); |
1 | 151 g_string_append(result, sub); |
152 g_free(match); | |
153 | |
154 return FALSE; | |
155 } | |
0 | 156 |
8 | 157 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
|
158 translate(gchar **str, int which) |
0 | 159 { |
1 | 160 gchar *newstr; |
161 | |
162 twitter_debug("*str = %s\n", *str); | |
0 | 163 |
20
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
164 newstr = g_regex_replace_eval(regp[which], // compiled regex |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
165 *str, // subject string |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
166 -1, // length of the subject string |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
167 0, // start position |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
168 0, // match options |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
169 eval, // function to call for each match |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
170 &which, // user data |
6 | 171 NULL); // error handler |
1 | 172 |
173 twitter_debug("newstr = %s\n", newstr); | |
174 | |
175 g_free(*str); | |
176 *str = newstr; | |
177 } | |
0 | 178 |
8 | 179 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
|
180 playsound(gchar **str, int which) |
1 | 181 { |
182 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
|
183 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
|
184 gchar **candidates = NULL, **candidate = NULL; |
0 | 185 |
31 | 186 list = purple_prefs_get_string(which ? OPT_USERLIST_SENDER : |
187 OPT_USERLIST_RECIPIENT); | |
5
6ac1867d7e8e
string list should be initialized with NULL
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2
diff
changeset
|
188 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
|
189 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
|
190 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
|
191 |
44a66c52b190
- userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
6
diff
changeset
|
192 candidates = g_strsplit_set(list, " ,:;", 0); |
20
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
193 g_return_if_fail(candidates != NULL); |
1 | 194 |
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
|
195 g_regex_match(regp[which], *str, 0, &match_info); |
6 | 196 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
|
197 gchar *user = g_match_info_fetch(match_info, 1); |
1 | 198 twitter_debug("user = %s\n", user); |
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 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
|
201 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
|
202 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
|
203 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
|
204 if(!strcmp(user, *candidate)) { |
1 | 205 twitter_debug("match. play sound\n"); |
8 | 206 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
|
207 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
|
208 break; |
1 | 209 } |
210 } | |
6 | 211 g_free(user); |
212 g_match_info_next(match_info, NULL); | |
1 | 213 } |
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
|
214 g_strfreev(candidates); |
6 | 215 g_match_info_free(match_info); |
0 | 216 } |
217 | |
1 | 218 static gboolean |
19
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
219 writing_im_cb(PurpleAccount * account, char *sender, char **buffer, |
6 | 220 PurpleConversation * conv, int *flags, void *data) |
0 | 221 { |
222 const gchar *proto; | |
223 | |
1 | 224 /* check if the message is from twitter */ |
0 | 225 proto = purple_account_get_protocol_id(account); |
20
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
226 twitter_debug("writing_im_cb\n"); |
1 | 227 twitter_debug("proto = %s\n", proto); |
228 twitter_debug("sender = %s\n", sender); | |
0 | 229 |
20
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
230 if(!strcmp(sender, "twitter@twitter.com") && |
4c236a7a128f
- now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
19
diff
changeset
|
231 !strcmp(proto, "prpl-jabber")) { |
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
|
232 /* 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
|
233 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
|
234 playsound(buffer, SENDER); |
1 | 235 } |
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
|
236 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
|
237 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
|
238 } |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
239 |
4bd8c89b4749
now it plays sound when sender of message is in the userlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
9
diff
changeset
|
240 /* translate */ |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
241 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
|
242 translate(buffer, SENDER); |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
243 } |
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
244 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
|
245 translate(buffer, RECIPIENT); |
1 | 246 } |
0 | 247 |
19
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
248 /* escape */ |
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
249 if(purple_prefs_get_bool(OPT_ESCAPE_PSEUDO)) { |
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
250 escape(buffer); |
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
251 } |
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
252 } |
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
253 return FALSE; |
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
254 } |
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
255 |
31 | 256 static void |
257 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
258 gchar *new_text, gint new_text_length, gpointer user_data) | |
259 { | |
260 PidginConversation *gtkconv = (PidginConversation *)user_data; | |
261 GtkWidget *box, *counter = NULL; | |
262 gchar *markup = NULL; | |
263 | |
264 g_return_if_fail(gtkconv != NULL); | |
265 | |
266 guint count = gtk_text_buffer_get_char_count(textbuffer) + | |
267 (unsigned int)g_utf8_strlen(new_text, -1); | |
268 | |
269 twitter_debug("new_text = %s utf8_strlen = %ld new_text_length = %d\n", | |
270 new_text, g_utf8_strlen(new_text, -1), new_text_length); | |
271 | |
272 markup = g_markup_printf_escaped("<span color=\"%s\">%u</span>", | |
273 count<=140 ? "black" : "red", | |
274 count); | |
275 | |
276 box = gtkconv->toolbar; | |
277 counter = g_object_get_data(G_OBJECT(box), | |
278 PLUGIN_ID "-counter"); | |
279 if (counter) | |
280 gtk_label_set_markup(GTK_LABEL(counter), markup); | |
281 | |
282 g_free(markup); | |
283 } | |
284 | |
285 static void | |
286 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
287 GtkTextIter *end_pos, gpointer user_data) | |
288 { | |
289 PidginConversation *gtkconv = (PidginConversation *)user_data; | |
290 GtkWidget *box, *counter = NULL; | |
291 gchar *markup = NULL; | |
292 | |
293 g_return_if_fail(gtkconv != NULL); | |
294 | |
295 guint count = gtk_text_buffer_get_char_count(textbuffer) - | |
296 (gtk_text_iter_get_offset(end_pos) - | |
297 gtk_text_iter_get_offset(start_pos)); | |
298 | |
299 markup = g_markup_printf_escaped("<span color=\"%s\">%u</span>", | |
300 count<=140 ? "black" : "red", | |
301 count); | |
302 | |
303 box = gtkconv->toolbar; | |
304 counter = g_object_get_data(G_OBJECT(box), | |
305 PLUGIN_ID "-counter"); | |
306 if (counter) | |
307 gtk_label_set_markup(GTK_LABEL(counter), markup); | |
308 | |
309 g_free(markup); | |
310 } | |
311 | |
312 | |
313 static void | |
314 detach_from_window(void) | |
315 { | |
316 GList *list; | |
317 | |
318 for (list = pidgin_conv_windows_get_list(); list; list = list->next) { | |
319 PidginWindow *win = list->data; | |
320 PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win); | |
321 if(is_twitter_conv(conv)) | |
322 detach_from_gtkconv(PIDGIN_CONVERSATION(conv), NULL); | |
323 } | |
324 } | |
325 | |
326 static void | |
327 detach_from_gtkconv(PidginConversation *gtkconv, gpointer null) | |
328 { | |
329 GtkWidget *box, *counter = NULL, *sep = NULL; | |
330 | |
331 g_signal_handlers_disconnect_by_func(G_OBJECT(gtkconv->entry_buffer), | |
332 (GFunc)insert_text_cb, gtkconv); | |
333 g_signal_handlers_disconnect_by_func(G_OBJECT(gtkconv->entry_buffer), | |
334 (GFunc)delete_text_cb, gtkconv); | |
335 | |
336 box = gtkconv->toolbar; | |
337 | |
338 /* remove counter */ | |
339 counter = g_object_get_data(G_OBJECT(box), | |
340 PLUGIN_ID "-counter"); | |
341 if (counter) { | |
342 gtk_container_remove(GTK_CONTAINER(box), counter); | |
343 g_object_unref(counter); | |
344 g_object_set_data(G_OBJECT(box), | |
345 PLUGIN_ID "-counter", NULL); | |
346 } | |
347 /* remove separator */ | |
348 sep = g_object_get_data(G_OBJECT(box), PLUGIN_ID "-sep"); | |
349 if (sep) { | |
350 gtk_container_remove(GTK_CONTAINER(box), sep); | |
351 g_object_unref(sep); | |
352 g_object_set_data(G_OBJECT(box), | |
353 PLUGIN_ID "-sep", NULL); | |
354 } | |
355 | |
356 gtk_widget_queue_draw(pidgin_conv_get_window(gtkconv)->window); | |
357 } | |
358 | |
359 static void | |
360 attach_to_window(void) | |
361 { | |
362 GList *list; | |
363 | |
364 for (list = pidgin_conv_windows_get_list(); list; list = list->next) { | |
365 PidginWindow *win = list->data; | |
366 PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win); | |
367 if(is_twitter_conv(conv)) | |
368 attach_to_gtkconv(PIDGIN_CONVERSATION(conv), NULL); | |
369 } | |
370 } | |
371 | |
372 static void | |
373 attach_to_gtkconv(PidginConversation *gtkconv, gpointer null) | |
374 { | |
375 GtkWidget *box, *sep, *counter; | |
376 | |
377 box = gtkconv->toolbar; | |
378 counter = g_object_get_data(G_OBJECT(box), | |
379 PLUGIN_ID "-counter"); | |
380 g_return_if_fail(counter == NULL); | |
381 | |
382 /* make counter object */ | |
383 counter = gtk_label_new(NULL); | |
384 gtk_widget_set_name(counter, "counter_label"); | |
385 gtk_label_set_text(GTK_LABEL(counter), "0"); | |
386 gtk_box_pack_end(GTK_BOX(box), counter, FALSE, FALSE, 0); | |
387 gtk_widget_show_all(counter); | |
388 g_object_set_data(G_OBJECT(box), | |
389 PLUGIN_ID "-counter", counter); | |
390 | |
391 /* make separator object */ | |
392 sep = gtk_vseparator_new(); | |
393 gtk_box_pack_end(GTK_BOX(box), sep, FALSE, FALSE, 0); | |
394 gtk_widget_show_all(sep); | |
395 g_object_set_data(G_OBJECT(box), | |
396 PLUGIN_ID "-sep", sep); | |
397 | |
398 /* connect signals, etc. */ | |
399 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
400 G_CALLBACK(insert_text_cb), gtkconv); | |
401 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", | |
402 G_CALLBACK(delete_text_cb), gtkconv); | |
403 | |
404 /* redraw window */ | |
405 gtk_widget_queue_draw(pidgin_conv_get_window(gtkconv)->window); | |
406 } | |
407 | |
408 static gboolean | |
409 is_twitter_conv(PurpleConversation *conv) | |
410 { | |
411 const char *name = purple_conversation_get_name(conv); | |
412 PurpleAccount *account = purple_conversation_get_account(conv); | |
413 const gchar *proto = purple_account_get_protocol_id(account); | |
414 | |
415 twitter_debug("is_twitter_conv\n"); | |
416 twitter_debug("name = %s\n", name); | |
417 twitter_debug("proto = %s\n", proto); | |
418 | |
419 if(!strcmp(name, "twitter@twitter.com") && | |
420 !strcmp(proto, "prpl-jabber")) { | |
421 return TRUE; | |
422 } | |
423 | |
424 return FALSE; | |
425 } | |
426 | |
427 static void | |
428 conv_created_cb(PurpleConversation *conv, gpointer null) | |
429 { | |
430 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); | |
431 g_return_if_fail(gtkconv != NULL); | |
432 | |
433 /* only attach to twitter conversation window */ | |
434 if(is_twitter_conv(conv)) { | |
435 gboolean enabled = purple_prefs_get_bool(OPT_COUNTER); | |
436 if(enabled) { | |
437 attach_to_gtkconv(gtkconv, NULL); | |
438 } | |
439 } | |
440 } | |
441 | |
8 | 442 static gboolean |
443 load_plugin(PurplePlugin * plugin) | |
0 | 444 { |
6 | 445 /* connect to signal */ |
446 purple_signal_connect(purple_conversations_get_handle(), "writing-im-msg", | |
19
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
447 plugin, PURPLE_CALLBACK(writing_im_cb), NULL); |
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
448 purple_signal_connect(purple_conversations_get_handle(), "sending-im-msg", |
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
449 plugin, PURPLE_CALLBACK(sending_im_cb), NULL); |
31 | 450 purple_signal_connect(purple_conversations_get_handle(), |
451 "conversation-created", | |
452 plugin, PURPLE_CALLBACK(conv_created_cb), NULL); | |
0 | 453 |
28
73e817be3267
- Fixed a crash bug. Each unload/reload cycle caused crash due to unrefed regp.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
25
diff
changeset
|
454 /* compile regex */ |
73e817be3267
- Fixed a crash bug. Each unload/reload cycle caused crash due to unrefed regp.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
25
diff
changeset
|
455 regp[RECIPIENT] = g_regex_new("@([A-Za-z0-9_]+)", 0, 0, NULL); |
73e817be3267
- Fixed a crash bug. Each unload/reload cycle caused crash due to unrefed regp.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
25
diff
changeset
|
456 regp[SENDER] = g_regex_new("<body>([A-Za-z0-9_]+): ", 0, 0, NULL); |
73e817be3267
- Fixed a crash bug. Each unload/reload cycle caused crash due to unrefed regp.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
25
diff
changeset
|
457 regp[COMMAND] = g_regex_new( |
73e817be3267
- Fixed a crash bug. Each unload/reload cycle caused crash due to unrefed regp.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
25
diff
changeset
|
458 "^(?:\\s*)([dDfFgGlLmMnNtTwW]{1}\\s+[A-Za-z0-9_]+\\Z)", |
73e817be3267
- Fixed a crash bug. Each unload/reload cycle caused crash due to unrefed regp.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
25
diff
changeset
|
459 G_REGEX_RAW, 0, NULL); |
73e817be3267
- Fixed a crash bug. Each unload/reload cycle caused crash due to unrefed regp.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
25
diff
changeset
|
460 regp[PSEUDO] = g_regex_new( |
73e817be3267
- Fixed a crash bug. Each unload/reload cycle caused crash due to unrefed regp.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
25
diff
changeset
|
461 "^\\s*(?:[\"#$%&'()*+,\\-./:;<=>?\\[\\\\\\]_`{|}~]|[^\\s\\x21-\\x7E])*([dDfFgGlLmMnNtTwW]{1})(?:\\Z|\\s+|[^\\x21-\\x7E]+\\Z)", |
73e817be3267
- Fixed a crash bug. Each unload/reload cycle caused crash due to unrefed regp.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
25
diff
changeset
|
462 G_REGEX_RAW, 0, NULL); |
73e817be3267
- Fixed a crash bug. Each unload/reload cycle caused crash due to unrefed regp.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
25
diff
changeset
|
463 |
31 | 464 /* attach counter to the existing twitter window*/ |
465 gboolean enabled = purple_prefs_get_bool(OPT_COUNTER); | |
466 if(enabled) { | |
467 attach_to_window(); | |
468 } | |
469 | |
6 | 470 return TRUE; |
0 | 471 } |
472 | |
8 | 473 static gboolean |
474 unload_plugin(PurplePlugin * plugin) | |
0 | 475 { |
6 | 476 twitter_debug("pidgin-twitter unload called\n"); |
0 | 477 |
31 | 478 /* disconnect from signal */ |
479 purple_signal_disconnect(purple_conversations_get_handle(), | |
480 "writing-im-msg", | |
481 plugin, PURPLE_CALLBACK(writing_im_cb)); | |
482 purple_signal_disconnect(purple_conversations_get_handle(), | |
483 "sending-im-msg", | |
484 plugin, PURPLE_CALLBACK(sending_im_cb)); | |
485 purple_signal_disconnect(purple_conversations_get_handle(), | |
486 "conversation-created", | |
487 plugin, PURPLE_CALLBACK(conv_created_cb)); | |
488 | |
489 /* unreference regp */ | |
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
|
490 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
|
491 g_regex_unref(regp[SENDER]); |
21
38fe566b5ee1
unref newly added regex at unload time.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
20
diff
changeset
|
492 g_regex_unref(regp[COMMAND]); |
38fe566b5ee1
unref newly added regex at unload time.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
20
diff
changeset
|
493 g_regex_unref(regp[PSEUDO]); |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
494 |
31 | 495 /* detach from twitter window */ |
496 detach_from_window(); | |
497 | |
6 | 498 return TRUE; |
0 | 499 } |
500 | |
31 | 501 static void |
502 counter_prefs_cb(const char *name, PurplePrefType type, | |
503 gconstpointer val, gpointer data) | |
504 { | |
505 gboolean enabled = purple_prefs_get_bool(OPT_COUNTER); | |
506 if(enabled) { | |
507 attach_to_window(); //xxx shoud check whether already attached or not. | |
508 } | |
509 else { | |
510 detach_from_window(); | |
511 } | |
512 } | |
513 | |
8 | 514 static PurplePluginPrefFrame * |
515 get_plugin_pref_frame(PurplePlugin * plugin) | |
0 | 516 { |
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
|
517 /* 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
|
518 |
6 | 519 PurplePluginPref *pref; |
520 PurplePluginPrefFrame *frame = purple_plugin_pref_frame_new(); | |
0 | 521 |
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
|
522 /* frame title */ |
31 | 523 pref = purple_plugin_pref_new_with_label("Translation Configurations"); |
6 | 524 purple_plugin_pref_frame_add(frame, pref); |
0 | 525 |
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
|
526 /* 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
|
527 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
|
528 OPT_TRANSLATE_RECIPIENT, |
12 | 529 "Translate @username to link"); |
6 | 530 purple_plugin_pref_frame_add(frame, pref); |
0 | 531 |
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
|
532 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
|
533 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
|
534 "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
|
535 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
|
536 |
31 | 537 |
538 | |
539 | |
540 | |
541 /* frame title */ | |
542 pref = purple_plugin_pref_new_with_label("Miscellaneous Configurations"); | |
543 purple_plugin_pref_frame_add(frame, pref); | |
544 | |
545 /* escape pseudo command setting */ | |
19
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
546 pref = purple_plugin_pref_new_with_name_and_label( |
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
547 OPT_ESCAPE_PSEUDO, |
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
548 "Escape pseudo command string"); |
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
549 purple_plugin_pref_frame_add(frame, pref); |
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
|
550 |
31 | 551 /* comaescape pseudo command setting */ |
552 pref = purple_plugin_pref_new_with_name_and_label( | |
553 OPT_COUNTER, | |
554 "Show text counter"); | |
555 purple_plugin_pref_frame_add(frame, pref); | |
556 | |
557 /* xxx */ | |
558 purple_prefs_connect_callback(plugin, OPT_COUNTER, | |
559 counter_prefs_cb, NULL); | |
560 | |
561 | |
562 | |
563 | |
564 | |
565 /* frame title */ | |
566 pref = purple_plugin_pref_new_with_label("Sound Configurations"); | |
567 purple_plugin_pref_frame_add(frame, pref); | |
568 | |
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
|
569 /* 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
|
570 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
|
571 OPT_PLAYSOUND_RECIPIENT, |
12 | 572 "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
|
573 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
|
574 |
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
|
575 /* 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
|
576 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
|
577 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
|
578 "Recipient List"); |
6 | 579 purple_plugin_pref_frame_add(frame, pref); |
1 | 580 |
8 | 581 /* 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
|
582 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
|
583 |
8 | 584 purple_plugin_pref_set_type(pref, PURPLE_PLUGIN_PREF_CHOICE); |
585 purple_plugin_pref_add_choice(pref, "Arrive", GINT_TO_POINTER(0)); | |
586 purple_plugin_pref_add_choice(pref, "Leave", GINT_TO_POINTER(1)); | |
587 purple_plugin_pref_add_choice(pref, "Receive", GINT_TO_POINTER(2)); | |
588 purple_plugin_pref_add_choice(pref, "Fist Receive", GINT_TO_POINTER(3)); | |
589 purple_plugin_pref_add_choice(pref, "Send", GINT_TO_POINTER(4)); | |
590 purple_plugin_pref_add_choice(pref, "Chat Join", GINT_TO_POINTER(5)); | |
591 purple_plugin_pref_add_choice(pref, "Chat Leave", GINT_TO_POINTER(6)); | |
592 purple_plugin_pref_add_choice(pref, "Chat You Say", GINT_TO_POINTER(7)); | |
593 purple_plugin_pref_add_choice(pref, "Chat Someone Say", GINT_TO_POINTER(8)); | |
594 purple_plugin_pref_add_choice(pref, "Pounce Default", GINT_TO_POINTER(9)); | |
595 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
|
596 |
8 | 597 purple_plugin_pref_frame_add(frame, pref); |
598 | |
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
|
599 |
31 | 600 /* sound setting for 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
|
601 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
|
602 OPT_PLAYSOUND_SENDER, |
12 | 603 "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
|
604 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
|
605 |
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
|
606 /* 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
|
607 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
|
608 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
|
609 "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
|
610 purple_plugin_pref_frame_add(frame, pref); |
1 | 611 |
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
|
612 /* 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
|
613 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
|
614 |
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
|
615 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
|
616 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
|
617 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
|
618 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
|
619 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
|
620 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
|
621 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
|
622 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
|
623 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
|
624 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
|
625 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
|
626 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
|
627 |
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
|
628 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
|
629 |
6 | 630 return frame; |
0 | 631 } |
632 | |
6 | 633 static PurplePluginUiInfo pref_info = { |
634 get_plugin_pref_frame | |
0 | 635 }; |
636 | |
6 | 637 static PurplePluginInfo info = { |
638 PURPLE_PLUGIN_MAGIC, | |
639 PURPLE_MAJOR_VERSION, | |
640 PURPLE_MINOR_VERSION, | |
641 PURPLE_PLUGIN_STANDARD, /**< type */ | |
19
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
642 NULL, /**< ui_req */ |
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
643 0, /**< flags */ |
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
644 NULL, /**< deps */ |
6 | 645 PURPLE_PRIORITY_DEFAULT, /**< priority */ |
31 | 646 PLUGIN_ID, /**< id */ |
6 | 647 "Pidgin-Twitter", /**< name */ |
31 | 648 "0.6.0", /**< version */ |
30 | 649 "replaces usernames with links and play sounds", /** summary */ |
650 "replaces usernames with links and play sounds", /** desc */ | |
6 | 651 "Yoshiki Yazawa (yaz@honeyplanet.jp)", /**< author */ |
652 "http://www.honeyplanet.jp/", /**< homepage */ | |
19
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
653 load_plugin, /**< load */ |
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
654 unload_plugin, /**< unload */ |
6 | 655 NULL, /**< destroy */ |
656 NULL, /**< ui_info */ | |
657 NULL, /**< extra_info */ | |
19
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
658 &pref_info, /**< pref info */ |
6 | 659 NULL |
0 | 660 }; |
661 | |
8 | 662 static void |
663 init_plugin(PurplePlugin * plugin) | |
0 | 664 { |
6 | 665 g_type_init(); |
0 | 666 |
6 | 667 /* add plugin preferences */ |
668 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
|
669 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
|
670 purple_prefs_add_bool(OPT_TRANSLATE_SENDER, TRUE); |
19
0d7cbc984570
escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
16
diff
changeset
|
671 purple_prefs_add_bool(OPT_ESCAPE_PSEUDO, TRUE); |
9
c6b80f47d4df
added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
8
diff
changeset
|
672 |
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
|
673 purple_prefs_add_bool(OPT_PLAYSOUND_RECIPIENT, TRUE); |
15
6be35fe9d18c
changed default value of playsound for sender. now it is enabled by default.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
14
diff
changeset
|
674 purple_prefs_add_bool(OPT_PLAYSOUND_SENDER, TRUE); |
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
|
675 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
|
676 purple_prefs_add_string(OPT_USERLIST_RECIPIENT, DEFAULT_LIST); |
16
728c068534d1
default soundid for sender has been changed to pounce default since anything other may be disabled by configuration so that it may be confusing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
15
diff
changeset
|
677 purple_prefs_add_int(OPT_SOUNDID_SENDER, PURPLE_SOUND_POUNCE_DEFAULT); |
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
|
678 purple_prefs_add_string(OPT_USERLIST_SENDER, DEFAULT_LIST); |
31 | 679 |
680 purple_prefs_add_bool(OPT_COUNTER, TRUE); | |
0 | 681 } |
682 | |
683 PURPLE_INIT_PLUGIN(pidgin_twitter, init_plugin, info) |