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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1 /*
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
2 * Pidgin-Twitter plugin.
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
3 *
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
5 * modify it under the terms of the GNU General Public License as
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
6 * published by the Free Software Foundation; either version 2 of the
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
7 * License, or (at your option) any later version.
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
8 *
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful, but
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
12 * General Public License for more details.
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
13 *
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
15 * along with this program; if not, write to the Free Software
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
17 * 02111-1307, USA.
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
18 */
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
19 #define PURPLE_PLUGINS 1
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
20
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
21 #include <stdio.h>
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
22 #include <stdlib.h>
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
23 #include <string.h>
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
24 #include <glib.h>
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
25
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
26 #include "gtkplugin.h"
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
27 #include "util.h"
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
28 #include "debug.h"
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
29 #include "connection.h"
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
30 #include "version.h"
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
31 #include "sound.h"
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
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
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
35
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
36 #define PIDGINTWITTER_PLUGIN_ID "pidgin_twitter"
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
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
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
49
2
53ee194b5ff5 some cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1
diff changeset
50 #define twitter_debug(fmt, ...) purple_debug(PURPLE_DEBUG_INFO, PIDGINTWITTER_PLUGIN_ID, \
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
51 fmt, ## __VA_ARGS__);
2
53ee194b5ff5 some cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1
diff changeset
52 #define twitter_error(fmt, ...) purple_debug(PURPLE_DEBUG_ERROR, PIDGINTWITTER_PLUGIN_ID, \
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
53
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
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
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
56
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
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
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
59 {
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
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
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
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
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
66 twitter_debug("sub = %s\n", sub);
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
67 g_string_append(result, sub);
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
68 g_free(match);
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
69
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
70 return FALSE;
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
71 }
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
72
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
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
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
75 {
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
76 gchar *newstr;
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
77
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
78 twitter_debug("*str = %s\n", *str);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
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
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
81 *str, // subject string
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
82 -1, // length of the subject string
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
83 0, // start position
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
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
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
87 NULL); // error handler
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
88
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
89 twitter_debug("newstr = %s\n", newstr);
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
90
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
91 g_free(*str);
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
92 *str = newstr;
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
93 }
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
94
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
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
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
97 {
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
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
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
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
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
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
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
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
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
114 twitter_debug("user = %s\n", user);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
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
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
121 twitter_debug("match. play sound\n");
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
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
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
125 }
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
126 }
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
127 g_free(user);
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
128 g_match_info_next(match_info, NULL);
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
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
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
131 g_match_info_free(match_info);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
132 }
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
133
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
134
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
135 static gboolean
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
136 process_im_cb(PurpleAccount * account, char *sender, char **buffer,
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
137 PurpleConversation * conv, int *flags, void *data)
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
138 {
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
139 const gchar *proto;
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
140
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
141 /* check if the message is from twitter */
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
142 proto = purple_account_get_protocol_id(account);
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
143 twitter_debug("proto = %s\n", proto);
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
144 twitter_debug("sender = %s\n", sender);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
145
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
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
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
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
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
161 }
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
162 }
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
163 return FALSE;
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
164 }
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
165
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
166 static gboolean
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
167 load_plugin(PurplePlugin * plugin)
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
168 {
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
169 /* connect to signal */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
170 purple_signal_connect(purple_conversations_get_handle(), "writing-im-msg",
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
171 plugin, PURPLE_CALLBACK(process_im_cb), NULL);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
172
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
173 return TRUE;
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
174 }
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
175
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
176 static gboolean
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
177 unload_plugin(PurplePlugin * plugin)
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
178 {
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
179 twitter_debug("pidgin-twitter unload called\n");
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
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
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
184 return TRUE;
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
185 }
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
186
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
187 static PurplePluginPrefFrame *
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
188 get_plugin_pref_frame(PurplePlugin * plugin)
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
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
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
192 PurplePluginPref *pref;
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
193 PurplePluginPrefFrame *frame = purple_plugin_pref_frame_new();
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
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
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
196 pref = purple_plugin_pref_new_with_label("Pidgin-Twitter Configuration");
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
197 purple_plugin_pref_frame_add(frame, pref);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
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
0d102bbb40bb tweaked UI messages
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 11
diff changeset
203 "Translate @username to link");
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
204 purple_plugin_pref_frame_add(frame, pref);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
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
0d102bbb40bb tweaked UI messages
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 11
diff changeset
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
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
222 purple_plugin_pref_frame_add(frame, pref);
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
223
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
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
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
227 purple_plugin_pref_set_type(pref, PURPLE_PLUGIN_PREF_CHOICE);
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
228 purple_plugin_pref_add_choice(pref, "Arrive", GINT_TO_POINTER(0));
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
229 purple_plugin_pref_add_choice(pref, "Leave", GINT_TO_POINTER(1));
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
230 purple_plugin_pref_add_choice(pref, "Receive", GINT_TO_POINTER(2));
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
231 purple_plugin_pref_add_choice(pref, "Fist Receive", GINT_TO_POINTER(3));
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
232 purple_plugin_pref_add_choice(pref, "Send", GINT_TO_POINTER(4));
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
233 purple_plugin_pref_add_choice(pref, "Chat Join", GINT_TO_POINTER(5));
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
234 purple_plugin_pref_add_choice(pref, "Chat Leave", GINT_TO_POINTER(6));
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
235 purple_plugin_pref_add_choice(pref, "Chat You Say", GINT_TO_POINTER(7));
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
236 purple_plugin_pref_add_choice(pref, "Chat Someone Say", GINT_TO_POINTER(8));
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
237 purple_plugin_pref_add_choice(pref, "Pounce Default", GINT_TO_POINTER(9));
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
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
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
240 purple_plugin_pref_frame_add(frame, pref);
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
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
0d102bbb40bb tweaked UI messages
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 11
diff changeset
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
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
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
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
273 return frame;
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
274 }
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
275
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
276 static PurplePluginUiInfo pref_info = {
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
277 get_plugin_pref_frame
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
278 };
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
279
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
280 static PurplePluginInfo info = {
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
281 PURPLE_PLUGIN_MAGIC,
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
282 PURPLE_MAJOR_VERSION,
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
283 PURPLE_MINOR_VERSION,
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
284 PURPLE_PLUGIN_STANDARD, /**< type */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
285 NULL, /**< ui_req */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
286 0, /**< flags */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
287 NULL, /**< deps */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
288 PURPLE_PRIORITY_DEFAULT, /**< priority */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
289 PIDGINTWITTER_PLUGIN_ID, /**< id */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
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
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
294 "Yoshiki Yazawa (yaz@honeyplanet.jp)", /**< author */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
295 "http://www.honeyplanet.jp/", /**< homepage */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
296 load_plugin, /**< load */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
297 unload_plugin, /**< unload */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
298 NULL, /**< destroy */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
299 NULL, /**< ui_info */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
300 NULL, /**< extra_info */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
301 &pref_info, /**< pref info */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
302 NULL
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
303 };
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
304
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
305 static void
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
306 init_plugin(PurplePlugin * plugin)
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
307 {
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
308 g_type_init();
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
309
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
310 /* add plugin preferences */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
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
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
321
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
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
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
325 }
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
326
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
327 PURPLE_INIT_PLUGIN(pidgin_twitter, init_plugin, info)