annotate pidgin-twitter.c @ 38:625e385036c3

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