annotate pidgin-twitter.c @ 51:d5f251b37f6b

- make sure that disabling markup widgets works even if counter is disabled. - a bit tidy up.
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Thu, 15 May 2008 21:44:53 +0900
parents 3e0d4fd75b03
children ac1259fde1d0
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
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
38
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
39 #define PLUGIN_ID "gtk-honeyplanet-pidgin_twitter"
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
40 #define PLUGIN_NAME "pidgin-twitter"
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
41
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
42 /* options */
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
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
56 /* formats and templates */
9
c6b80f47d4df added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 8
diff changeset
57 #define RECIPIENT_FORMAT "@<a href='http://twitter.com/%s'>%s</a>"
48
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
58 #define SENDER_FORMAT "%s<a href='http://twitter.com/%s'>%s</a>: "
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
59 #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
60 #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
61
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
62 /* patterns */
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
63 #define P_RECIPIENT "@([A-Za-z0-9_]+)"
48
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
64 #define P_SENDER "^(\\r?\\n?)([A-Za-z0-9_]+): "
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
65 #define P_COMMAND "^(?:\\s*)([dDfFgGlLmMnNtTwW]{1}\\s+[A-Za-z0-9_]+)(?:\\s*\\Z)"
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
66 #define P_PSEUDO "^\\s*(?:[\"#$%&'()*+,\\-./:;<=>?\\[\\\\\\]_`{|}~]|[^\\s\\x21-\\x7E])*([dDfFgGlLmMnNtTwW]{1})(?:\\Z|\\s+|[^\\x21-\\x7E]+\\Z)"
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
67
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
68 /* debug macros */
39
2ac81c0afb53 - new debug macro. it includes function name and line number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 38
diff changeset
69 #define twitter_debug(fmt, ...) purple_debug(PURPLE_DEBUG_INFO, PLUGIN_NAME, "%s():%4d: " fmt, __FUNCTION__, (int)__LINE__, ## __VA_ARGS__);
2ac81c0afb53 - new debug macro. it includes function name and line number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 38
diff changeset
70 #define twitter_error(fmt, ...) purple_debug(PURPLE_DEBUG_ERROR, PLUGIN_NAME, "%s():%4d: " fmt, __FUCTION__, (int)__LINE__, ## __VA_ARGS__);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
71
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
72
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
73 /* globals */
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
74 static GRegex *regp[4];
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
75 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
76
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
77 /* prototypes */
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
78 static void escape(gchar **str);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
79 static gboolean sending_im_cb(PurpleAccount *account, char *recipient, char **buffer, void *data);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
80 static gboolean eval(const GMatchInfo *match_info, GString *result, gpointer user_data);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
81 static void translate(gchar **str, int which);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
82 static void playsound(gchar **str, int which);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
83 static gboolean writing_im_cb(PurpleAccount *account, char *sender, char **buffer, PurpleConversation *conv, int *flags, void *data);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
84 static void insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, gchar *new_text, gint new_text_length, gpointer user_data);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
85 static void delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, GtkTextIter *end_pos, gpointer user_data);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
86 static void detach_from_window(void);
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
87 static void detach_from_gtkconv(PidginConversation *gtkconv, gpointer null);
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
88 static void attach_to_window(void);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
89 static void attach_to_gtkconv(PidginConversation *gtkconv, gpointer null);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
90 static gboolean is_twitter_account(PurpleAccount *account, const char *name);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
91 static gboolean is_twitter_conv(PurpleConversation *conv);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
92 static void conv_created_cb(PurpleConversation *conv, gpointer null);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
93 static gboolean receiving_im_cb(PurpleAccount *account, char **sender, char **buffer, PurpleConversation *conv, PurpleMessageFlags *flags, void *data);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
94 static gboolean load_plugin(PurplePlugin *plugin);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
95 static gboolean unload_plugin(PurplePlugin *plugin);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
96 static void counter_prefs_cb(const char *name, PurplePrefType type, gconstpointer val, gpointer data);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
97 static PurplePluginPrefFrame *get_plugin_pref_frame(PurplePlugin *plugin);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
98 static void init_plugin(PurplePlugin *plugin);
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
99
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
100
49
82b2b3767311 fixed indentation of strip_html_markup()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 48
diff changeset
101 /* this function is a modified clone of purple_markup_strip_html() */
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
102 static char *
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
103 strip_html_markup(const char *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
104 {
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
105 int i, j, k, entlen;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
106 gboolean visible = TRUE;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
107 gboolean closing_td_p = FALSE;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
108 gchar *str2;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
109 const gchar *cdata_close_tag = NULL, *ent;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
110 gchar *href = NULL;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
111 int href_st = 0;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
112
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
113 if(!str)
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
114 return NULL;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
115
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
116 str2 = g_strdup(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
117
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
118 for (i = 0, j = 0; str2[i]; i++)
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
119 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
120 if (str2[i] == '<')
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
121 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
122 if (cdata_close_tag)
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
123 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
124 /* Note: Don't even assume any other tag is a tag in CDATA */
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
125 if (g_ascii_strncasecmp(str2 + i, cdata_close_tag,
49
82b2b3767311 fixed indentation of strip_html_markup()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 48
diff changeset
126 strlen(cdata_close_tag)) == 0)
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
127 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
128 i += strlen(cdata_close_tag) - 1;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
129 cdata_close_tag = NULL;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
130 }
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
131 continue;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
132 }
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
133 else if (g_ascii_strncasecmp(str2 + i, "<td", 3) == 0 && closing_td_p)
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
134 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
135 str2[j++] = '\t';
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
136 visible = TRUE;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
137 }
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
138 else if (g_ascii_strncasecmp(str2 + i, "</td>", 5) == 0)
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
139 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
140 closing_td_p = TRUE;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
141 visible = FALSE;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
142 }
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
143 else
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
144 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
145 closing_td_p = FALSE;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
146 visible = TRUE;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
147 }
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
148
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
149 k = i + 1;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
150
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
151 if(g_ascii_isspace(str2[k]))
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
152 visible = TRUE;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
153 else if (str2[k])
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
154 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
155 /* Scan until we end the tag either implicitly (closed start
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
156 * tag) or explicitly, using a sloppy method (i.e., < or >
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
157 * inside quoted attributes will screw us up)
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
158 */
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
159 while (str2[k] && str2[k] != '<' && str2[k] != '>')
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
160 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
161 k++;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
162 }
42
68db38b5b401 fixed changeset 41:0a81ccfa1941
mikanbako <maoutwo@gmail.com>
parents: 41
diff changeset
163
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
164 /* If we've got an <a> tag with an href, save the address
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
165 * to print later. */
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
166 if (g_ascii_strncasecmp(str2 + i, "<a", 2) == 0 &&
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
167 g_ascii_isspace(str2[i+2]))
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
168 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
169 int st; /* start of href, inclusive [ */
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
170 int end; /* end of href, exclusive ) */
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
171 char delim = ' ';
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
172 /* Find start of href */
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
173 for (st = i + 3; st < k; st++)
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
174 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
175 if (g_ascii_strncasecmp(str2+st, "href=", 5) == 0)
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
176 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
177 st += 5;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
178 if (str2[st] == '"' || str2[st] == '\'')
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
179 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
180 delim = str2[st];
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
181 st++;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
182 }
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
183 break;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
184 }
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
185 }
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
186 /* find end of address */
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
187 for (end = st; end < k && str2[end] != delim; end++)
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
188 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
189 /* All the work is done in the loop construct above. */
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
190 }
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
191
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
192 /* If there's an address, save it. If there was
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
193 * already one saved, kill it. */
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
194 if (st < k)
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
195 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
196 char *tmp;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
197 g_free(href);
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
198 tmp = g_strndup(str2 + st, end - st);
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
199 href = purple_unescape_html(tmp);
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
200 g_free(tmp);
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
201 href_st = j;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
202 }
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
203 }
42
68db38b5b401 fixed changeset 41:0a81ccfa1941
mikanbako <maoutwo@gmail.com>
parents: 41
diff changeset
204
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
205 /* Check for tags which should be mapped to newline */
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
206 else if (g_ascii_strncasecmp(str2 + i, "<p>", 3) == 0
49
82b2b3767311 fixed indentation of strip_html_markup()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 48
diff changeset
207 || g_ascii_strncasecmp(str2 + i, "<tr", 3) == 0
82b2b3767311 fixed indentation of strip_html_markup()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 48
diff changeset
208 || g_ascii_strncasecmp(str2 + i, "<br", 3) == 0
82b2b3767311 fixed indentation of strip_html_markup()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 48
diff changeset
209 || g_ascii_strncasecmp(str2 + i, "<hr", 3) == 0
82b2b3767311 fixed indentation of strip_html_markup()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 48
diff changeset
210 || g_ascii_strncasecmp(str2 + i, "<li", 3) == 0
82b2b3767311 fixed indentation of strip_html_markup()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 48
diff changeset
211 || g_ascii_strncasecmp(str2 + i, "<div", 4) == 0
82b2b3767311 fixed indentation of strip_html_markup()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 48
diff changeset
212 || g_ascii_strncasecmp(str2 + i, "</table>", 8) == 0)
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
213 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
214 str2[j++] = '\n';
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
215 }
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
216 else if (g_ascii_strncasecmp(str2 + i, "<script", 7) == 0)
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
217 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
218 cdata_close_tag = "</script>";
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
219 }
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
220 else if (g_ascii_strncasecmp(str2 + i, "<style", 6) == 0)
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
221 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
222 cdata_close_tag = "</style>";
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
223 }
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
224 /* Update the index and continue checking after the tag */
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
225 i = (str2[k] == '<' || str2[k] == '\0')? k - 1: k;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
226 continue;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
227 }
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
228 }
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
229 else if (cdata_close_tag)
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
230 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
231 continue;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
232 }
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
233 else if (!g_ascii_isspace(str2[i]))
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
234 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
235 visible = TRUE;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
236 }
39
2ac81c0afb53 - new debug macro. it includes function name and line number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 38
diff changeset
237
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
238 if (str2[i] == '&' &&
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
239 (ent = purple_markup_unescape_entity(str2 + i, &entlen)) != NULL)
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
240 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
241 while (*ent)
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
242 str2[j++] = *ent++;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
243 i += entlen - 1;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
244 continue;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
245 }
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
246
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
247 if (visible)
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
248 str2[j++] = g_ascii_isspace(str2[i])? ' ': str2[i];
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
249 }
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
250
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
251 g_free(href);
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
252
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
253 str2[j] = '\0';
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
254
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
255 return str2;
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
256 }
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
257
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
258
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
259 /* our implementation */
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
260
20
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
261 static void
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
262 escape(gchar **str)
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
263 {
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
264 GMatchInfo *match_info = NULL;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
265 gchar *newstr = NULL, *match = NULL;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
266 gboolean flag = FALSE;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
267
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
268 /* search genuine command */
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
269 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
270 while(g_match_info_matches(match_info)) {
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
271 match = g_match_info_fetch(match_info, 1);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
272 twitter_debug("command = %s\n", match);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
273 g_free(match);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
274 g_match_info_next(match_info, NULL);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
275 flag = TRUE;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
276 }
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
277 g_match_info_free(match_info);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
278 match_info = NULL;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
279
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
280 if(flag)
20
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
281 return;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
282
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
283 /* if not found, check pseudo command */
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
284 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
285 while(g_match_info_matches(match_info)) {
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
286 match = g_match_info_fetch(match_info, 1);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
287 twitter_debug("pseudo = %s\n", match);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
288 g_free(match);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
289 g_match_info_next(match_info, NULL);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
290 flag = TRUE;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
291 }
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
292 g_match_info_free(match_info);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
293 match_info = NULL;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
294
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
295 /* if there is pseudo one, escape it */
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
296 if(flag) {
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
297 /* put ". " to the beginning of buffer */
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
298 newstr = g_strdup_printf(". %s", *str);
39
2ac81c0afb53 - new debug macro. it includes function name and line number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 38
diff changeset
299 twitter_debug("*str = %s newstr = %s\n", *str, newstr);
20
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
300 g_free(*str);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
301 *str = newstr;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
302 }
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
303 }
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
304
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
305 static void
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
306 strip_markup(gchar **str)
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
307 {
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
308 char *plain;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
309
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
310 plain = strip_html_markup(*str);
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
311 g_free(*str);
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
312 *str = plain;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
313 }
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
314
20
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
315 static gboolean
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
316 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
317 void *data)
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
318 {
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
319 int utflen, bytes;
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
320
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
321 twitter_debug("called\n");
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
322
20
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
323 /* check if the message is from twitter */
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
324 if(!is_twitter_account(account, recipient))
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
325 return FALSE;
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
326
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
327 /* strip all markups */
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
328 strip_markup(buffer);
41
0a81ccfa1941 strip excessive markup where it is not needed. (work in progress)
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 40
diff changeset
329
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
330 /* escape pseudo command */
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
331 if(purple_prefs_get_bool(OPT_ESCAPE_PSEUDO)) {
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
332 escape(buffer);
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
333 }
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
334
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
335 /* try to suppress oops message */
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
336 utflen = g_utf8_strlen(*buffer, -1);
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
337 bytes = strlen(*buffer);
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
338 twitter_debug("utflen = %d bytes = %d\n", utflen, bytes);
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
339 if(bytes > 140 && utflen <= 140)
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
340 suppress_oops = TRUE;
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
341
20
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
342 return FALSE;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
343 }
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
344
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
345 static gboolean
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
346 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
347 {
48
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
348 int which = *(int *)user_data;
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
349 gchar sub[128];
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
350
48
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
351 if(which == RECIPIENT) {
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
352 gchar *match = g_match_info_fetch(match_info, 1);
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
353
48
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
354 snprintf(sub, 128, RECIPIENT_FORMAT, match, match);
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
355 g_free(match);
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
356 }
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
357 else if(which == SENDER) {
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
358 gchar *match1 = g_match_info_fetch(match_info, 1); //preceding CR|LF
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
359 gchar *match2 = g_match_info_fetch(match_info, 2); //sender
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
360
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
361 snprintf(sub, 128, SENDER_FORMAT, match1 ? match1: "",
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
362 match2, match2);
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
363 g_free(match1);
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
364 g_free(match2);
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
365 }
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
366
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
367 g_string_append(result, sub);
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
368 twitter_debug("sub = %s\n", sub);
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
369
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
370 return FALSE;
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
371 }
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
372
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
373 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
374 translate(gchar **str, int which)
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
375 {
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
376 gchar *newstr;
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
377
20
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
378 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
379 *str, // subject string
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
380 -1, // length of the subject string
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
381 0, // start position
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
382 0, // match options
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
383 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
384 &which, // user data
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
385 NULL); // error handler
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
386
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
387 twitter_debug("which = %d *str = %s newstr = %s\n", which, *str, newstr);
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
388
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
389 g_free(*str);
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
390 *str = newstr;
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
391 }
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
392
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
393 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
394 playsound(gchar **str, int which)
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
395 {
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
396 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
397 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
398 gchar **candidates = NULL, **candidate = NULL;
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
399
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
400 list = purple_prefs_get_string(which ? OPT_USERLIST_SENDER :
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
401 OPT_USERLIST_RECIPIENT);
5
6ac1867d7e8e string list should be initialized with NULL
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2
diff changeset
402 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
403 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
404 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
405
44a66c52b190 - userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 6
diff changeset
406 candidates = g_strsplit_set(list, " ,:;", 0);
20
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
407 g_return_if_fail(candidates != NULL);
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
408
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
409 g_regex_match(regp[which], *str, 0, &match_info);
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
410 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
411 gchar *user = g_match_info_fetch(match_info, 1);
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
412 twitter_debug("user = %s\n", user);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
413
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
414 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
415 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
416 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
417 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
418 if(!strcmp(user, *candidate)) {
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
419 twitter_debug("match. play sound\n");
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
420 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
421 (which ? OPT_SOUNDID_SENDER :
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
422 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
423 break;
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
424 }
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
425 }
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
426 g_free(user);
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
427 g_match_info_next(match_info, NULL);
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
428 }
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
429 g_strfreev(candidates);
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
430 g_match_info_free(match_info);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
431 }
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
432
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
433 static gboolean
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
434 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
435 PurpleConversation *conv, int *flags, void *data)
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
436 {
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
437 twitter_debug("called\n");
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
438
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
439 /* check if the message is from twitter */
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
440 if(!is_twitter_account(account, sender))
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
441 return FALSE;
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
442
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
443 /* strip all markups */
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
444 strip_markup(buffer);
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
445
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
446 /* playsound */
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
447 if(purple_prefs_get_bool(OPT_PLAYSOUND_SENDER)) {
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
448 playsound(buffer, SENDER);
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
449 }
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
450 if(purple_prefs_get_bool(OPT_PLAYSOUND_RECIPIENT)) {
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
451 playsound(buffer, RECIPIENT);
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
452 }
41
0a81ccfa1941 strip excessive markup where it is not needed. (work in progress)
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 40
diff changeset
453
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
454 /* translate */
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
455 if(purple_prefs_get_bool(OPT_TRANSLATE_SENDER)) {
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
456 translate(buffer, SENDER);
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
457 }
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
458 if(purple_prefs_get_bool(OPT_TRANSLATE_RECIPIENT)) {
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
459 translate(buffer, RECIPIENT);
19
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
460 }
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
461
46
e4f8e5708afd due to application of strip_markup() in writing_im_cb(), translation for sender had not worked. changed P_SENDER so that it matches striped representation of sender.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 45
diff changeset
462 /* escape pseudo command (to show same result to sending message) */
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
463 if(purple_prefs_get_bool(OPT_ESCAPE_PSEUDO)) {
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
464 escape(buffer);
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
465 }
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
466
19
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
467 return FALSE;
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
468 }
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
469
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
470 static void
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
471 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position,
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
472 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
473 {
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
474 PidginConversation *gtkconv = (PidginConversation *)user_data;
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
475 GtkWidget *box, *counter = NULL;
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
476 gchar *markup = NULL;
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
477 guint count;
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
478
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
479 g_return_if_fail(gtkconv != NULL);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
480
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
481 count = gtk_text_buffer_get_char_count(textbuffer) +
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
482 (unsigned int)g_utf8_strlen(new_text, -1);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
483
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
484 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
485 count <= 140 ? "black" : "red", count);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
486
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
487 box = gtkconv->toolbar;
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
488 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
489 if(counter)
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
490 gtk_label_set_markup(GTK_LABEL(counter), markup);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
491
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
492 g_free(markup);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
493 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
494
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
495 static void
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
496 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos,
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
497 GtkTextIter *end_pos, gpointer user_data)
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
498 {
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
499 PidginConversation *gtkconv = (PidginConversation *)user_data;
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
500 GtkWidget *box, *counter = NULL;
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
501 gchar *markup = NULL;
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
502
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
503 g_return_if_fail(gtkconv != NULL);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
504
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
505 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
506 (gtk_text_iter_get_offset(end_pos) -
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
507 gtk_text_iter_get_offset(start_pos));
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
508
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
509 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
510 count <= 140 ? "black" : "red", count);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
511
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
512 box = gtkconv->toolbar;
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
513 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
514 if(counter)
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
515 gtk_label_set_markup(GTK_LABEL(counter), markup);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
516
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
517 g_free(markup);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
518 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
519
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
520 static void
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
521 detach_from_window(void)
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
522 {
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
523 GList *list;
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
524
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
525 /* find twitter conv window out and detach from that */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
526 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
527 PidginWindow *win = list->data;
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
528 PurpleConversation *conv =
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
529 pidgin_conv_window_get_active_conversation(win);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
530 if(is_twitter_conv(conv))
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
531 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
532 }
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
533 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
534
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
535 static void
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
536 detach_from_gtkconv(PidginConversation *gtkconv, gpointer null)
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
537 {
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
538 GtkWidget *box, *counter = NULL, *sep = NULL;
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
539
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
540 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
541 (GFunc) insert_text_cb, gtkconv);
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
542 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
543 (GFunc) delete_text_cb, gtkconv);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
544
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
545 box = gtkconv->toolbar;
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
546
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
547 /* remove counter */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
548 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
549 if(counter) {
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
550 gtk_container_remove(GTK_CONTAINER(box), counter);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
551 g_object_unref(counter);
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
552 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
553 }
37
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
554
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
555 /* remove separator */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
556 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
557 if(sep) {
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
558 gtk_container_remove(GTK_CONTAINER(box), sep);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
559 g_object_unref(sep);
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
560 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
561 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
562
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
563 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
564 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
565
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
566 static void
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
567 attach_to_window(void)
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
568 {
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
569 GList *list;
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
570
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
571 /* find twitter conv window out and attach to that */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
572 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
573 PidginWindow *win = list->data;
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
574 PurpleConversation *conv =
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
575 pidgin_conv_window_get_active_conversation(win);
51
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
576 /* only attach to twitter conversation window */
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
577 if(is_twitter_conv(conv))
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
578 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
579 }
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
580 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
581
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
582 static void
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
583 attach_to_gtkconv(PidginConversation *gtkconv, gpointer null)
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
584 {
50
3e0d4fd75b03 added that to disable widgets that decorate or link text.
mikanbako <maoutwo@gmail.com>
parents: 49
diff changeset
585 GtkWidget *box, *sep, *counter, *menus;
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
586
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
587 box = gtkconv->toolbar;
51
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
588
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
589 /* Disable widgets that decorate or add link to composing text
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
590 * because Twitter can't receive markuped strings. For lean-view
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
591 * and wide-view, see pidgin/gtkimhtmltoolbar.c.
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
592 */
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
593 menus = g_object_get_data(G_OBJECT(box), "lean-view");
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
594 if(menus) {
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
595 gtk_widget_set_sensitive(GTK_WIDGET(menus), FALSE);
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
596 }
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
597 menus = g_object_get_data(G_OBJECT(box), "wide-view");
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
598 if(menus) {
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
599 gtk_widget_set_sensitive(GTK_WIDGET(menus), FALSE);
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
600 }
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
601 purple_conversation_set_features(
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
602 gtkconv->active_conv,
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
603 purple_conversation_get_features(gtkconv->active_conv) &
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
604 ~PURPLE_CONNECTION_HTML);
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
605
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
606 /* check if the counter is enabled */
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
607 if(!purple_prefs_get_bool(OPT_COUNTER))
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
608 return;
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
609
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
610 /* get counter object */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
611 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
612 g_return_if_fail(counter == NULL);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
613
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
614 /* make counter object */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
615 counter = gtk_label_new(NULL);
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
616 gtk_widget_set_name(counter, "counter_label");
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
617 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
618 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
619 gtk_widget_show_all(counter);
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
620 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
621
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
622 /* make separator object */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
623 sep = gtk_vseparator_new();
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
624 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
625 gtk_widget_show_all(sep);
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
626 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
627
51
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
628 /* connect to signals */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
629 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
630 G_CALLBACK(insert_text_cb), gtkconv);
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
631 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
632 G_CALLBACK(delete_text_cb), gtkconv);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
633
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
634 /* redraw window */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
635 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
636 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
637
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
638 static gboolean
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
639 is_twitter_account(PurpleAccount *account, const char *name)
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
640 {
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
641 const gchar *proto = purple_account_get_protocol_id(account);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
642
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
643 twitter_debug("name = %s proto = %s\n", name, proto);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
644
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
645 if(!strcmp(name, "twitter@twitter.com") &&
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
646 !strcmp(proto, "prpl-jabber")) {
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
647 return TRUE;
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
648 }
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
649
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
650 return FALSE;
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
651 }
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
652
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
653 static gboolean
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
654 is_twitter_conv(PurpleConversation *conv)
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
655 {
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
656 const char *name = purple_conversation_get_name(conv);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
657 PurpleAccount *account = purple_conversation_get_account(conv);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
658
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
659 return is_twitter_account(account, name);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
660 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
661
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
662 static void
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
663 conv_created_cb(PurpleConversation *conv, gpointer null)
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
664 {
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
665 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv);
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
666 g_return_if_fail(gtkconv != NULL);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
667
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
668 /* only attach to twitter conversation window */
51
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
669 if(is_twitter_conv(conv))
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
670 attach_to_gtkconv(gtkconv, NULL);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
671 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
672
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
673 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
674 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
675 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
676 {
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
677 twitter_debug("called\n");
39
2ac81c0afb53 - new debug macro. it includes function name and line number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 38
diff changeset
678 twitter_debug("buffer = %s suppress_oops = %d\n", *buffer, 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
679
37
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
680 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
681 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
682
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
683 if(strstr(*buffer, OOPS_MESSAGE)) {
39
2ac81c0afb53 - new debug macro. it includes function name and line number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 38
diff changeset
684 twitter_debug("clearing sender and buffer\n");
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
685 g_free(*sender);
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
686 *sender = NULL;
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
687 g_free(*buffer);
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
688 *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
689 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
690 }
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
691 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
692 }
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
693
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
694 static gboolean
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
695 load_plugin(PurplePlugin *plugin)
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
696 {
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
697 /* connect to signal */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
698 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
699 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
700 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
701 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
702 purple_signal_connect(purple_conversations_get_handle(),
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
703 "conversation-created",
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
704 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
705 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
706 plugin, PURPLE_CALLBACK(receiving_im_cb), NULL);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
707
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
708 /* compile regex */
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
709 regp[RECIPIENT] = g_regex_new(P_RECIPIENT, 0, 0, NULL);
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
710 regp[SENDER] = g_regex_new(P_SENDER, 0, 0, NULL);
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
711 regp[COMMAND] = g_regex_new(P_COMMAND, G_REGEX_RAW, 0, NULL);
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
712 regp[PSEUDO] = g_regex_new(P_PSEUDO, G_REGEX_RAW, 0, 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
713
37
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
714 /* attach counter to the existing twitter window */
51
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
715 if(purple_prefs_get_bool(OPT_COUNTER)) {
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
716 attach_to_window();
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
717 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
718
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
719 return TRUE;
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
720 }
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
721
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
722 static gboolean
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
723 unload_plugin(PurplePlugin *plugin)
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
724 {
39
2ac81c0afb53 - new debug macro. it includes function name and line number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 38
diff changeset
725 twitter_debug("called\n");
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
726
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
727 /* disconnect from signal */
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
728 purple_signal_disconnect(purple_conversations_get_handle(),
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
729 "writing-im-msg",
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
730 plugin, PURPLE_CALLBACK(writing_im_cb));
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
731 purple_signal_disconnect(purple_conversations_get_handle(),
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
732 "sending-im-msg",
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
733 plugin, PURPLE_CALLBACK(sending_im_cb));
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
734 purple_signal_disconnect(purple_conversations_get_handle(),
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
735 "conversation-created",
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
736 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
737 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
738 "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
739 plugin, PURPLE_CALLBACK(receiving_im_cb));
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
740
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
741 /* 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
742 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
743 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
744 g_regex_unref(regp[COMMAND]);
38fe566b5ee1 unref newly added regex at unload time.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 20
diff changeset
745 g_regex_unref(regp[PSEUDO]);
9
c6b80f47d4df added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 8
diff changeset
746
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
747 /* detach from twitter window */
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
748 detach_from_window();
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
749
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
750 return TRUE;
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
751 }
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
752
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
753 static void
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
754 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
755 gconstpointer val, gpointer data)
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
756 {
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
757 gboolean enabled = purple_prefs_get_bool(OPT_COUNTER);
45
746ff3b54c10 trying another way to strip markups. in this revision, all markups are striped with strip_html_markup() on sending a message.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 44
diff changeset
758
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
759 if(enabled) {
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
760 attach_to_window();
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
761 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
762 else {
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
763 detach_from_window();
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
764 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
765 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
766
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
767 static PurplePluginPrefFrame *
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
768 get_plugin_pref_frame(PurplePlugin *plugin)
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
769 {
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
770 /* create gtk elements for the plugin preferences */
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
771 PurplePluginPref *pref;
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
772 PurplePluginPrefFrame *frame = purple_plugin_pref_frame_new();
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
773
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
774 /************************/
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
775 /* 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
776 /************************/
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
777 pref = purple_plugin_pref_new_with_label("Translation Configurations");
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
778 purple_plugin_pref_frame_add(frame, pref);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
779
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
780 /* translation settings */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
781 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
782 "Translate @username to link");
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
783 purple_plugin_pref_frame_add(frame, pref);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
784
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
785 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
786 "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
787 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
788
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
789
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
790 /*************************/
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
791 /* 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
792 /*************************/
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
793 pref = purple_plugin_pref_new_with_label("Miscellaneous Configurations");
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
794 purple_plugin_pref_frame_add(frame, pref);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
795
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
796 /* escape pseudo command setting */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
797 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
798 "Escape pseudo command string");
19
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
799 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
800
37
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
801 /* show text counter */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
802 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
803 "Show text counter");
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
804 purple_plugin_pref_frame_add(frame, pref);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
805
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
806 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
807
37
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
808 /* suppress oops message */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
809 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
810 "Suppress oops message");
37
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
811 purple_plugin_pref_frame_add(frame, pref);
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
812
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
813
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
814 /*****************/
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
815 /* 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
816 /*****************/
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
817 pref = purple_plugin_pref_new_with_label("Sound Configurations");
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
818 purple_plugin_pref_frame_add(frame, pref);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
819
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
820 /* sound settings for recipient */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
821 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
822 "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
823 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
824
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
825 /* recipient list */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
826 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
827 "Recipient List");
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
828 purple_plugin_pref_frame_add(frame, pref);
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
829
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
830 /* sound id selector */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
831 pref =
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
832 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
833 "Recipient Sound");
9
c6b80f47d4df added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 8
diff changeset
834
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
835 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
836 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
837 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
838 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
839 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
840 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
841 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
842 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
843 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
844 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
845 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
846 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
847
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
848 purple_plugin_pref_frame_add(frame, pref);
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
849
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
850 /* sound setting for sender */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
851 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
852 "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
853 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
854
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
855 /* sender list */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
856 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
857 "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
858 purple_plugin_pref_frame_add(frame, pref);
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
859
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
860 /* sound id selector */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
861 pref =
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
862 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
863 "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
864
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
865 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
866 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
867 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
868 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
869 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
870 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
871 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
872 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
873 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
874 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
875 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
876 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
877
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
878 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
879
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
880 return frame;
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
881 }
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
882
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
883 static PurplePluginUiInfo pref_info = {
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
884 get_plugin_pref_frame
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
885 };
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
886
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
887 static PurplePluginInfo info = {
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
888 PURPLE_PLUGIN_MAGIC,
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
889 PURPLE_MAJOR_VERSION,
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
890 PURPLE_MINOR_VERSION,
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
891 PURPLE_PLUGIN_STANDARD, /**< type */
19
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
892 NULL, /**< ui_req */
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
893 0, /**< flags */
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
894 NULL, /**< deps */
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
895 PURPLE_PRIORITY_DEFAULT, /**< priority */
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
896 PLUGIN_ID, /**< id */
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
897 "Pidgin-Twitter", /**< name */
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
898 "0.6.0", /**< version */
30
e740ceed9337 tweaked descriptions
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 28
diff changeset
899 "replaces usernames with links and play sounds", /** summary */
e740ceed9337 tweaked descriptions
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 28
diff changeset
900 "replaces usernames with links and play sounds", /** desc */
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
901 "Yoshiki Yazawa (yaz@honeyplanet.jp)", /**< author */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
902 "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
903 load_plugin, /**< load */
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
904 unload_plugin, /**< unload */
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
905 NULL, /**< destroy */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
906 NULL, /**< ui_info */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
907 NULL, /**< extra_info */
19
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
908 &pref_info, /**< pref info */
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
909 NULL
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
910 };
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
911
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
912 static void
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
913 init_plugin(PurplePlugin *plugin)
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
914 {
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
915 g_type_init();
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
916
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
917 /* add plugin preferences */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
918 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
919 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
920 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
921 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
922
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
923 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
924 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
925 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
926 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
927 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
928 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
929
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
930 purple_prefs_add_bool(OPT_COUNTER, TRUE);
37
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
931 purple_prefs_add_bool(OPT_SUPPRESS_OOPS, TRUE);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
932 }
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
933
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
934 PURPLE_INIT_PLUGIN(pidgin_twitter, init_plugin, info)