annotate pidgin-twitter.c @ 62:6843c3e6477f

fixed the size of regp array
author mikanbako <maoutwo@gmail.com>
date Sat, 21 Jun 2008 14:47:35 +0900
parents a44d15cfd8a2
children 760006015519
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"
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
33 #include "gtkimhtml.h"
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
34
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
35 #define RECIPIENT 0
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
36 #define SENDER 1
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
37 #define COMMAND 2
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
38 #define PSEUDO 3
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
39 #define MESSAGE 4
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
40 #define USER 5
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
41 #define USER_FIRST_LINE 6
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
42 #define USER_FORMATTED 7
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
43
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
44 #define PLUGIN_ID "gtk-honeyplanet-pidgin_twitter"
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
45 #define PLUGIN_NAME "pidgin-twitter"
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
46
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
47 /* options */
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
48 #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
49 #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
50 #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
51 #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
52 #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
53 #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
54 #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
55 #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
56 #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
57 #define OPT_USERLIST_SENDER OPT_PIDGINTWITTER "/userlist_sender"
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
58 #define OPT_COUNTER OPT_PIDGINTWITTER "/counter"
37
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
59 #define OPT_SUPPRESS_OOPS OPT_PIDGINTWITTER "/suppress_oops"
59
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
60 #define OPT_PREVENT_NOTIFICATION OPT_PIDGINTWITTER "/prevent_notification"
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
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 /* formats and templates */
9
c6b80f47d4df added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 8
diff changeset
63 #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
64 #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
65 #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
66 #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
67
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
68 /* patterns */
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
69 #define P_RECIPIENT "@([A-Za-z0-9_]+)"
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
70 #define P_SENDER "^(\\r?\\n?)([A-Za-z0-9_]+): "
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
71 #define P_COMMAND "^(?:\\s*)([dDfFgGlLmMnNtTwW]{1}\\s+[A-Za-z0-9_]+)(?:\\s*\\Z)"
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
72 #define P_PSEUDO "^\\s*(?:[\"#$%&'()*+,\\-./:;<=>?\\[\\\\\\]_`{|}~]|[^\\s\\x21-\\x7E])*([dDfFgGlLmMnNtTwW]{1})(?:\\Z|\\s+|[^\\x21-\\x7E]+\\Z)"
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
73 #define P_MESSAGE "^<body>(.*)</body>"
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
74 #define P_USER "^\\(.+?\\)\\s*([A-Za-z0-9_]+):"
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
75 #define P_USER_FIRST_LINE "^\\(.+?\\)\\s*.+:\\s*([A-Za-z0-9_]+):"
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
76 #define P_USER_FORMATTED "^.*?<a .+?>([A-Za-z0-9_]+)</a>:"
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
77
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
78 /* 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
79 #define twitter_debug(fmt, ...) purple_debug(PURPLE_DEBUG_INFO, PLUGIN_NAME, "%s():%4d: " fmt, __FUNCTION__, (int)__LINE__, ## __VA_ARGS__);
55
07d519938bd1 fixed a typo
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 53
diff changeset
80 #define twitter_error(fmt, ...) purple_debug(PURPLE_DEBUG_ERROR, PLUGIN_NAME, "%s():%4d: " fmt, __FUNCTION__, (int)__LINE__, ## __VA_ARGS__);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
81
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
82
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
83 /* globals */
62
6843c3e6477f fixed the size of regp array
mikanbako <maoutwo@gmail.com>
parents: 61
diff changeset
84 static GRegex *regp[8];
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
85 static gboolean suppress_oops = FALSE;
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
86 static GHashTable *icon_id_by_user;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
87 static GList *requested_users = NULL;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
88 static GList *requestings = NULL;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
89 static GList *requested_icon_marks = 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
90
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
91 /* prototypes */
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
92 static void escape(gchar **str);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
93 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
94 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
95 static void translate(gchar **str, int which);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
96 static void playsound(gchar **str, int which);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
97 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
98 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
99 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
100 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
101 static void detach_from_gtkconv(PidginConversation *gtkconv, gpointer null);
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
102 static void delete_requested_icon_marks(PidginConversation *gtkconv);
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
103 static void attach_to_window(void);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
104 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
105 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
106 static gboolean is_twitter_conv(PurpleConversation *conv);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
107 static void conv_created_cb(PurpleConversation *conv, gpointer null);
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
108 static void deleting_conv_cb(PurpleConversation *conv);
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
109 static gboolean receiving_im_cb(PurpleAccount *account, char **sender, char **buffer, PurpleConversation *conv, PurpleMessageFlags *flags, void *data);
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
110 static void insert_requested_icon(gpointer data, gpointer user_data);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
111 static void downloaded_icon_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
112 static void request_icon(const char *buffer);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
113 static void displayed_im_cb(PurpleAccount *account, const char *who, char *message, PurpleConversation *conv, PurpleMessageFlags flags);
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
114 static gboolean load_plugin(PurplePlugin *plugin);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
115 static gboolean unload_plugin(PurplePlugin *plugin);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
116 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
117 static PurplePluginPrefFrame *get_plugin_pref_frame(PurplePlugin *plugin);
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
118 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
119
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
120
49
82b2b3767311 fixed indentation of strip_html_markup()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 48
diff changeset
121 /* 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
122 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
123 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
124 {
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
125 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
126 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
127 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
128 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
129 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
130 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
131 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
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 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
134 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
135
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 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
137
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
138 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
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 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
141 {
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 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
143 {
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 /* 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
145 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
146 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
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 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
149 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
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 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
152 }
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 (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
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 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
156 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
157 }
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 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
159 {
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 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
161 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
162 }
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
163 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
164 {
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 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
166 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
167 }
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 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
170
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 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
172 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
173 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
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 /* 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
176 * 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
177 * 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
178 */
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 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
180 {
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 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
182 }
42
68db38b5b401 fixed changeset 41:0a81ccfa1941
mikanbako <maoutwo@gmail.com>
parents: 41
diff changeset
183
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
184 /* 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
185 * 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
186 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
187 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
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 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
190 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
191 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
192 /* 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
193 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
194 {
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 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
196 {
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 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
198 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
199 {
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 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
201 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
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 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
204 }
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 }
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 /* 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
207 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
208 {
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
209 /* 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
210 }
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
211
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
212 /* 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
213 * 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
214 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
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 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
217 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
218 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
219 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
220 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
221 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
222 }
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 }
42
68db38b5b401 fixed changeset 41:0a81ccfa1941
mikanbako <maoutwo@gmail.com>
parents: 41
diff changeset
224
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
225 /* 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
226 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
227 || 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
228 || 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
229 || 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
230 || 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
231 || 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
232 || 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
233 {
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 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
235 }
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 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
237 {
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 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
239 }
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 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
241 {
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 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
243 }
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 /* 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
245 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
246 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
247 }
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 }
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 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
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 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
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 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
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 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
256 }
39
2ac81c0afb53 - new debug macro. it includes function name and line number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 38
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 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
259 (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
260 {
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
261 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
262 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
263 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
264 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
265 }
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
266
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
267 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
268 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
269 }
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
270
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
271 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
272
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
273 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
274
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
275 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
276 }
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
277
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
278
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
279 /* 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
280
20
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
281 static void
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
282 escape(gchar **str)
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
283 {
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
284 GMatchInfo *match_info = NULL;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
285 gchar *newstr = NULL, *match = NULL;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
286 gboolean flag = FALSE;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
287
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
288 /* search genuine command */
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
289 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
290 while(g_match_info_matches(match_info)) {
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
291 match = g_match_info_fetch(match_info, 1);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
292 twitter_debug("command = %s\n", match);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
293 g_free(match);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
294 g_match_info_next(match_info, NULL);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
295 flag = TRUE;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
296 }
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
297 g_match_info_free(match_info);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
298 match_info = NULL;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
299
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
300 if(flag)
20
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
301 return;
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 /* if not found, check pseudo command */
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
304 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
305 while(g_match_info_matches(match_info)) {
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
306 match = g_match_info_fetch(match_info, 1);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
307 twitter_debug("pseudo = %s\n", match);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
308 g_free(match);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
309 g_match_info_next(match_info, NULL);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
310 flag = TRUE;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
311 }
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
312 g_match_info_free(match_info);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
313 match_info = NULL;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
314
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
315 /* if there is pseudo one, escape it */
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
316 if(flag) {
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
317 /* put ". " to the beginning of buffer */
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
318 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
319 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
320 g_free(*str);
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
321 *str = newstr;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
322 }
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
323 }
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
324
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
325 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
326 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
327 {
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 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
329
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
330 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
331 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
332 *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
333 }
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
334
20
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
335 static gboolean
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
336 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
337 void *data)
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
338 {
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
339 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
340
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
341 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
342
20
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
343 /* check if the message is from twitter */
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
344 if(!is_twitter_account(account, recipient))
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
345 return FALSE;
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
346
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
347 /* 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
348 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
349
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
350 /* escape pseudo command */
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
351 if(purple_prefs_get_bool(OPT_ESCAPE_PSEUDO)) {
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
352 escape(buffer);
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
353 }
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
354
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
355 /* 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
356 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
357 bytes = strlen(*buffer);
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
358 twitter_debug("utflen = %d bytes = %d\n", utflen, bytes);
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
359 if(bytes > 140 && utflen <= 140)
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
360 suppress_oops = TRUE;
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
361
20
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
362 return FALSE;
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
363 }
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
364
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
365 static gboolean
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
366 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
367 {
48
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
368 int which = *(int *)user_data;
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
369 gchar sub[128];
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
370
48
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
371 if(which == RECIPIENT) {
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
372 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
373
48
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
374 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
375 g_free(match);
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
376 }
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
377 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
378 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
379 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
380
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
381 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
382 match2, match2);
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
383 g_free(match1);
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
384 g_free(match2);
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
385 }
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
386
42869098eda3 adapted for msn style option (or new line plugin).
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 46
diff changeset
387 g_string_append(result, sub);
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
388 twitter_debug("sub = %s\n", sub);
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
389
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
390 return FALSE;
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 translate(gchar **str, int which)
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
395 {
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
396 gchar *newstr;
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
397
20
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
398 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
399 *str, // subject string
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
400 -1, // length of the subject string
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
401 0, // start position
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
402 0, // match options
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
403 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
404 &which, // user data
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
405 NULL); // error handler
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
406
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
407 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
408
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
409 g_free(*str);
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
410 *str = newstr;
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
411 }
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
412
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
413 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
414 playsound(gchar **str, int which)
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
415 {
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
416 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
417 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
418 gchar **candidates = NULL, **candidate = NULL;
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
419
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
420 list = purple_prefs_get_string(which ? OPT_USERLIST_SENDER :
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
421 OPT_USERLIST_RECIPIENT);
5
6ac1867d7e8e string list should be initialized with NULL
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2
diff changeset
422 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
423 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
424 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
425
44a66c52b190 - userlist no longer uses string list. now ' ,:;' separated string is used instead.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 6
diff changeset
426 candidates = g_strsplit_set(list, " ,:;", 0);
20
4c236a7a128f - now escape feature works
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 19
diff changeset
427 g_return_if_fail(candidates != NULL);
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
428
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
429 g_regex_match(regp[which], *str, 0, &match_info);
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
430 while(g_match_info_matches(match_info)) {
52
ac1259fde1d0 due to adaptation to msn style, username of sender has been carried down by one.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 51
diff changeset
431 gchar *user = NULL;
ac1259fde1d0 due to adaptation to msn style, username of sender has been carried down by one.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 51
diff changeset
432 if(which == RECIPIENT)
ac1259fde1d0 due to adaptation to msn style, username of sender has been carried down by one.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 51
diff changeset
433 user = g_match_info_fetch(match_info, 1);
ac1259fde1d0 due to adaptation to msn style, username of sender has been carried down by one.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 51
diff changeset
434 else if(which == SENDER)
ac1259fde1d0 due to adaptation to msn style, username of sender has been carried down by one.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 51
diff changeset
435 user = g_match_info_fetch(match_info, 2);
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
436 twitter_debug("user = %s\n", user);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
437
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
438 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
439 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
440 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
441 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
442 if(!strcmp(user, *candidate)) {
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
443 twitter_debug("match. play sound\n");
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
444 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
445 (which ? OPT_SOUNDID_SENDER :
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
446 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
447 break;
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
448 }
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
449 }
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
450 g_free(user);
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
451 g_match_info_next(match_info, NULL);
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
452 }
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
453 g_strfreev(candidates);
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
454 g_match_info_free(match_info);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
455 }
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
456
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
457 static gboolean
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
458 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
459 PurpleConversation *conv, int *flags, void *data)
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
460 {
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
461 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
462
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
463 /* check if the message is from twitter */
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
464 if(!is_twitter_account(account, sender))
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
465 return FALSE;
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
466
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
467 /* 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
468 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
469
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
470 /* playsound */
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
471 if(purple_prefs_get_bool(OPT_PLAYSOUND_SENDER)) {
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
472 playsound(buffer, SENDER);
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
473 }
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
474 if(purple_prefs_get_bool(OPT_PLAYSOUND_RECIPIENT)) {
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
475 playsound(buffer, RECIPIENT);
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
476 }
41
0a81ccfa1941 strip excessive markup where it is not needed. (work in progress)
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 40
diff changeset
477
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
478 /* translate */
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
479 if(purple_prefs_get_bool(OPT_TRANSLATE_SENDER)) {
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
480 translate(buffer, SENDER);
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
481 }
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
482 if(purple_prefs_get_bool(OPT_TRANSLATE_RECIPIENT)) {
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
483 translate(buffer, RECIPIENT);
19
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
484 }
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
485
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
486 /* escape pseudo command (to show same result to sending message) */
44
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
487 if(purple_prefs_get_bool(OPT_ESCAPE_PSEUDO)) {
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
488 escape(buffer);
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
489 }
4f456c7150ed cleanups
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 43
diff changeset
490
19
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
491 return FALSE;
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
492 }
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
493
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
494 static void
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
495 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position,
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
496 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
497 {
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
498 PidginConversation *gtkconv = (PidginConversation *)user_data;
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
499 GtkWidget *box, *counter = NULL;
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
500 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
501 guint count;
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
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
505 count = gtk_text_buffer_get_char_count(textbuffer) +
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
506 (unsigned int)g_utf8_strlen(new_text, -1);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
507
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
508 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
509 count <= 140 ? "black" : "red", count);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
510
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
511 box = gtkconv->toolbar;
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
512 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
513 if(counter)
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
514 gtk_label_set_markup(GTK_LABEL(counter), markup);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
515
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
516 g_free(markup);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
517 }
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 static void
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
520 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos,
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
521 GtkTextIter *end_pos, gpointer user_data)
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
522 {
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
523 PidginConversation *gtkconv = (PidginConversation *)user_data;
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
524 GtkWidget *box, *counter = NULL;
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
525 gchar *markup = NULL;
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
526
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
527 g_return_if_fail(gtkconv != NULL);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
528
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
529 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
530 (gtk_text_iter_get_offset(end_pos) -
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
531 gtk_text_iter_get_offset(start_pos));
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
532
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
533 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
534 count <= 140 ? "black" : "red", count);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
535
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
536 box = gtkconv->toolbar;
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
537 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
538 if(counter)
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
539 gtk_label_set_markup(GTK_LABEL(counter), markup);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
540
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
541 g_free(markup);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
542 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
543
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
544 static void
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
545 detach_from_window(void)
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 GList *list;
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
548
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
549 /* 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
550 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
551 PidginWindow *win = list->data;
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
552 PurpleConversation *conv =
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
553 pidgin_conv_window_get_active_conversation(win);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
554 if(is_twitter_conv(conv))
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
555 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
556 }
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
557 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
558
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
559 static void
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
560 detach_from_gtkconv(PidginConversation *gtkconv, gpointer null)
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
561 {
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
562 GtkWidget *box, *counter = NULL, *sep = NULL;
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
563
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
564 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
565 (GFunc) insert_text_cb, gtkconv);
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
566 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
567 (GFunc) delete_text_cb, gtkconv);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
568
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
569 box = gtkconv->toolbar;
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
570
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
571 /* remove counter */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
572 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
573 if(counter) {
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
574 gtk_container_remove(GTK_CONTAINER(box), counter);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
575 g_object_unref(counter);
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
576 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
577 }
37
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
578
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
579 /* remove separator */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
580 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
581 if(sep) {
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
582 gtk_container_remove(GTK_CONTAINER(box), sep);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
583 g_object_unref(sep);
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
584 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
585 }
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 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
588 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
589
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
590 static void
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
591 delete_requested_icon_marks(PidginConversation* conv) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
592 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer(
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
593 GTK_TEXT_VIEW(conv->imhtml));
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
594 GList *mark_list = g_list_first(requested_icon_marks);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
595
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
596 /* delete the marks in the buffer that will be closed. */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
597 while(mark_list) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
598 GtkTextMark *mark = mark_list->data;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
599 GList *next = g_list_next(mark_list);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
600
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
601 if(gtk_text_mark_get_buffer(mark) == text_buffer) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
602 /* the mark will be freed in the function */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
603 gtk_text_buffer_delete_mark(text_buffer, mark);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
604 requested_icon_marks = g_list_delete_link(
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
605 requested_icon_marks, mark_list);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
606 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
607
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
608 mark_list = next;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
609 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
610 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
611
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
612 static void
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
613 attach_to_window(void)
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
614 {
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
615 GList *list;
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
616
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
617 /* 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
618 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
619 PidginWindow *win = list->data;
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
620 PurpleConversation *conv =
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
621 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
622 /* only attach to twitter conversation window */
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
623 if(is_twitter_conv(conv))
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
624 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
625 }
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
626 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
627
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
628 static void
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
629 attach_to_gtkconv(PidginConversation *gtkconv, gpointer null)
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
630 {
50
3e0d4fd75b03 added that to disable widgets that decorate or link text.
mikanbako <maoutwo@gmail.com>
parents: 49
diff changeset
631 GtkWidget *box, *sep, *counter, *menus;
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
632 GtkIMHtml *imhtml;
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
633
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
634 box = gtkconv->toolbar;
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
635 imhtml = GTK_IMHTML(gtkconv->imhtml);
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
636
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
637 /* Disable widgets that decorate or add link to composing text
53
872f418ba45d - revised README
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 52
diff changeset
638 * because Twitter cannot receive marked up string. For lean-view
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
639 * 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
640 */
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
641 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
642 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
643 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
644 }
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
645 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
646 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
647 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
648 }
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
649
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
650 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
651 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
652 purple_conversation_get_features(gtkconv->active_conv) &
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
653 ~PURPLE_CONNECTION_HTML);
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
654
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
655 /* 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
656 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
657 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
658
d5f251b37f6b - make sure that disabling markup widgets works even if counter is disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 50
diff changeset
659 /* get counter object */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
660 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
661 g_return_if_fail(counter == NULL);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
662
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
663 /* make counter object */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
664 counter = gtk_label_new(NULL);
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
665 gtk_widget_set_name(counter, "counter_label");
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
666 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
667 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
668 gtk_widget_show_all(counter);
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
669 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
670
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
671 /* make separator object */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
672 sep = gtk_vseparator_new();
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
673 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
674 gtk_widget_show_all(sep);
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
675 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
676
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
677 /* connect to signals */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
678 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
679 G_CALLBACK(insert_text_cb), gtkconv);
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
680 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
681 G_CALLBACK(delete_text_cb), gtkconv);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
682
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
683 /* redraw window */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
684 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
685 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
686
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
687 static gboolean
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
688 is_twitter_account(PurpleAccount *account, const char *name)
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
689 {
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
690 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
691
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
692 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
693
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
694 if(!strcmp(name, "twitter@twitter.com") &&
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
695 !strcmp(proto, "prpl-jabber")) {
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
696 return TRUE;
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
697 }
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
698
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
699 return FALSE;
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
700 }
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
701
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
702 static gboolean
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
703 is_twitter_conv(PurpleConversation *conv)
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
704 {
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
705 const char *name = purple_conversation_get_name(conv);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
706 PurpleAccount *account = purple_conversation_get_account(conv);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
707
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
708 return is_twitter_account(account, name);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
709 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
710
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
711 static void
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
712 conv_created_cb(PurpleConversation *conv, gpointer null)
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
713 {
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
714 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv);
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
715 g_return_if_fail(gtkconv != NULL);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
716
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
717 /* 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
718 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
719 attach_to_gtkconv(gtkconv, NULL);
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
720 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
721
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
722 static void
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
723 deleting_conv_cb(PurpleConversation *conv)
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
724 {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
725 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
726 g_return_if_fail(gtkconv != NULL);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
727
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
728 /* only attach to twitter conversation window */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
729 if(is_twitter_conv(conv))
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
730 delete_requested_icon_marks(gtkconv);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
731 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
732
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
733 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
734 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
735 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
736 {
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
737 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
738 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
739
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
740 /* Check that conv is not null to avoid a clash.
59
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
741 * conv is null when the conversation window has not opened yet.
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
742 */
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
743 if(!(conv && is_twitter_conv(conv))) {
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
744 return FALSE;
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
745 }
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
746
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
747 /* Prevent notifications of incoming messages. */
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
748 if(purple_prefs_get_bool(OPT_PREVENT_NOTIFICATION)) {
59
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
749 *flags |= PURPLE_MESSAGE_SYSTEM;
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
750 }
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
751
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
752 request_icon(*buffer);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
753
37
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
754 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
755 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
756
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
757 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
758 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
759 g_free(*sender);
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
760 *sender = NULL;
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
761 g_free(*buffer);
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
762 *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
763 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
764 }
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
765 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
766 }
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
767
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
768 static void
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
769 insert_requested_icon(gpointer data, gpointer user_data)
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
770 {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
771 GtkTextMark *requested_mark = (GtkTextMark *)data;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
772 gchar *user_name = (gchar *)user_data;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
773 GList *win_list;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
774 GtkIMHtml *target_imhtml = NULL;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
775 GtkTextBuffer *target_buffer = NULL;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
776 GtkTextIter inserting_point, next_line;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
777 gchar *message;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
778 GMatchInfo *match_info = NULL;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
779 gchar *user_name_in_message;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
780 int icon_id;
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
781 GList *entry_of_mark;
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
782
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
783 /* find the conversation that contains the mark */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
784 for(win_list = pidgin_conv_windows_get_list(); win_list;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
785 win_list = win_list->next) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
786 PidginWindow *win = win_list->data;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
787 GList *conv_list;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
788
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
789 for(conv_list = pidgin_conv_window_get_gtkconvs(win); conv_list;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
790 conv_list = conv_list->next) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
791 PidginConversation *conv = conv_list->data;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
792 PurpleConversation *purple_conv = conv->active_conv;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
793
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
794 if(purple_conv && is_twitter_conv(purple_conv)) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
795 GtkIMHtml *current_imhtml = GTK_IMHTML(conv->imhtml);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
796 GtkTextBuffer *current_buffer = gtk_text_view_get_buffer(
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
797 GTK_TEXT_VIEW(current_imhtml));
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
798
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
799 if(current_buffer == gtk_text_mark_get_buffer(requested_mark)) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
800 target_imhtml = current_imhtml;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
801 target_buffer = current_buffer;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
802 break;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
803 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
804 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
805 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
806 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
807 if(!(target_imhtml && target_buffer)) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
808 return;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
809 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
810
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
811 /* insert icon to the mark */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
812
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
813 gtk_text_buffer_get_iter_at_mark(target_buffer,
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
814 &inserting_point, requested_mark);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
815 next_line = inserting_point;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
816 gtk_text_iter_forward_line(&next_line);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
817
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
818 message = gtk_text_buffer_get_text(target_buffer, &inserting_point, &next_line, FALSE);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
819
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
820 g_regex_match(regp[USER], message, 0, &match_info);
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
821 if(!g_match_info_matches(match_info)) {
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
822 g_match_info_free(match_info);
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
823 g_regex_match(regp[USER_FIRST_LINE], message, 0, &match_info);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
824 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
825 if(!g_match_info_matches(match_info)) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
826 twitter_debug("user's name was not matched : %s\n", message);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
827 g_match_info_free(match_info);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
828 g_free(message);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
829 return;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
830 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
831
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
832 user_name_in_message = g_match_info_fetch(match_info, 1);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
833 g_match_info_free(match_info);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
834 g_free(message);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
835
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
836 /* Return if the message is not by the user that has the icon. */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
837 if(!g_str_equal(user_name, user_name_in_message)) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
838 g_free(user_name_in_message);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
839 return;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
840 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
841 g_free(user_name_in_message);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
842
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
843 /* insert icon */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
844 icon_id = GPOINTER_TO_INT(g_hash_table_lookup(icon_id_by_user, user_name));
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
845 if(!icon_id) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
846 return;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
847 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
848
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
849 gtk_imhtml_insert_image_at_iter(target_imhtml, icon_id, &inserting_point);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
850
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
851 /* mark the entry contains the deleted mark with NULL */
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
852 entry_of_mark = g_list_find(requested_icon_marks, requested_mark);
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
853 entry_of_mark->data = NULL;
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
854
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
855 gtk_text_buffer_delete_mark(target_buffer, requested_mark);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
856 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
857
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
858 static void
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
859 downloaded_icon_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data,
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
860 const gchar *url_text, gsize len, const gchar *error_message)
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
861 {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
862 gchar *user_name = (gchar *)user_data;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
863 int icon_id;
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
864
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
865 requestings = g_list_remove(requestings, url_data);
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
866
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
867 /* Return if user's icon had already been downloaded or
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
868 * the download is failure. */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
869 if(g_hash_table_lookup(icon_id_by_user, user_name) || !url_text) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
870 if(!url_text) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
871 twitter_debug("downloading %s's icon was failure : %s\n",
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
872 user_name, error_message);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
873 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
874 else {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
875 twitter_debug("%s's icon has already been downloaded\n", user_name);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
876 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
877
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
878 requested_users = g_list_remove(requested_users, user_name);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
879 g_free(user_name);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
880 return;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
881 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
882
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
883 icon_id = purple_imgstore_add_with_id(g_memdup(url_text, len), len,
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
884 user_name);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
885 g_hash_table_insert(icon_id_by_user, user_name, GINT_TO_POINTER(icon_id));
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
886
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
887 twitter_debug("Downloading %s's icon has been complete.(icon_id = %d)\n",
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
888 user_name, icon_id);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
889
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
890 /* Insert the icon to messages that had been received. */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
891 g_list_foreach(requested_icon_marks, insert_requested_icon, user_name);
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
892 /* Remove the entries of the mark that inserted the icon. */
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
893 requested_icon_marks = g_list_remove_all(requested_icon_marks, NULL);
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
894 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
895
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
896 static void
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
897 request_icon(const char *buffer)
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
898 {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
899 GMatchInfo *match_info = NULL;
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
900 gchar *user_name = NULL;
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
901 gchar *message = NULL;
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
902 PurpleUtilFetchUrlData *fetch_data = NULL;
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
903
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
904 /* get user's name */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
905
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
906 g_regex_match(regp[MESSAGE], buffer, 0, &match_info);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
907 if(!g_match_info_matches(match_info)) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
908 twitter_debug("Message was not matched : %s\n", buffer);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
909 g_match_info_free(match_info);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
910 return;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
911 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
912
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
913 message = g_match_info_fetch(match_info, 1);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
914 g_match_info_free(match_info);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
915 match_info = NULL;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
916
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
917 g_regex_match(regp[SENDER], message, 0, &match_info);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
918 if(!g_match_info_matches(match_info)) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
919 twitter_debug("user's name was not matched : %s\n", message);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
920 g_match_info_free(match_info);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
921 g_free(message);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
922 return;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
923 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
924
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
925 user_name = g_match_info_fetch(match_info, 2);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
926 g_match_info_free(match_info);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
927 g_free(message);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
928
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
929 /* request user's icon */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
930
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
931 /* Return if user's icon had already been requested. */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
932 if(g_list_find_custom(requested_users, user_name, (GCompareFunc)strcmp)) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
933 g_free(user_name);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
934 return;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
935 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
936
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
937 /* The string object are owned by the list. */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
938 requested_users = g_list_append(requested_users, user_name);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
939
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
940 fetch_data = purple_util_fetch_url(
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
941 "http://static.twitter.com/images/default_profile_normal.png",
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
942 TRUE, NULL, TRUE, downloaded_icon_cb, user_name);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
943 requestings = g_list_append(requestings, fetch_data);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
944
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
945 twitter_debug("request %s's icon\n", user_name);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
946 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
947
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
948 static void
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
949 displayed_im_cb(PurpleAccount *account, const char *who, char *message,
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
950 PurpleConversation *conv, PurpleMessageFlags flags)
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
951 {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
952 GMatchInfo *match_info = NULL;
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
953 gchar *user_name;
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
954 GtkIMHtml *imhtml;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
955 GtkTextBuffer *text_buffer;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
956 GtkTextIter inserting_point;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
957 int icon_id;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
958
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
959 /* Check that conv is not null to avoid a clash.
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
960 * conv is null when the conversation window has not opened yet.
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
961 */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
962 if(!(conv && is_twitter_conv(conv))) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
963 return;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
964 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
965
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
966 /* get user's name */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
967 g_regex_match(regp[USER_FORMATTED], message, 0, &match_info);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
968 if(!g_match_info_matches(match_info)) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
969 twitter_debug("message was not matched : %s\n", message);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
970 g_match_info_free(match_info);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
971 return;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
972 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
973
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
974 user_name = g_match_info_fetch(match_info, 1);
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
975 g_match_info_free(match_info);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
976
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
977 /* insert icon */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
978
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
979 imhtml = GTK_IMHTML(PIDGIN_CONVERSATION(conv)->imhtml);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
980 text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(imhtml));
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
981
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
982 /* get GtkTextIter of the last line */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
983 gtk_text_buffer_get_iter_at_line(text_buffer, &inserting_point,
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
984 gtk_text_buffer_get_line_count(text_buffer) - 1);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
985
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
986 icon_id = GPOINTER_TO_INT(g_hash_table_lookup(icon_id_by_user, user_name));
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
987
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
988 /* If the user's icon has not been downloaded, mark the message */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
989 if(!icon_id) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
990 requested_icon_marks = g_list_append(requested_icon_marks,
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
991 gtk_text_buffer_create_mark(
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
992 text_buffer, NULL,
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
993 &inserting_point, FALSE));
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
994 twitter_debug("%s's icon has not been downloaded.", user_name);
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
995 g_free(user_name);
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
996 return;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
997 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
998
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
999 gtk_imhtml_insert_image_at_iter(imhtml, icon_id, &inserting_point);
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
1000 g_free(user_name);
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1001 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1002
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
1003 static gboolean
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1004 load_plugin(PurplePlugin *plugin)
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1005 {
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1006 /* connect to signal */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1007 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
1008 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
1009 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
1010 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
1011 purple_signal_connect(purple_conversations_get_handle(),
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1012 "conversation-created",
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1013 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
1014 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
1015 plugin, PURPLE_CALLBACK(receiving_im_cb), NULL);
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1016 purple_signal_connect(pidgin_conversations_get_handle(), "displayed-im-msg",
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1017 plugin, PURPLE_CALLBACK(displayed_im_cb), NULL);
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
1018 purple_signal_connect(purple_conversations_get_handle(),
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
1019 "deleting-conversation",
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
1020 plugin, PURPLE_CALLBACK(deleting_conv_cb), NULL);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1021
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
1022 /* 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
1023 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
1024 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
1025 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
1026 regp[PSEUDO] = g_regex_new(P_PSEUDO, G_REGEX_RAW, 0, NULL);
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1027 regp[MESSAGE] = g_regex_new(P_MESSAGE, 0, 0, NULL);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1028 regp[USER] = g_regex_new(P_USER, 0, 0, NULL);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1029 regp[USER_FIRST_LINE] = g_regex_new(P_USER_FIRST_LINE, 0, 0, NULL);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1030 regp[USER_FORMATTED] = g_regex_new(P_USER_FORMATTED, G_REGEX_RAW, 0, NULL);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1031
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1032 /* hash table for user's icons
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1033 * the key is owned by requested_user */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1034 icon_id_by_user = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, 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
1035
37
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
1036 /* 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
1037 if(purple_prefs_get_bool(OPT_COUNTER)) {
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1038 attach_to_window();
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1039 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1040
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1041 return TRUE;
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1042 }
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1043
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
1044 static gboolean
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1045 unload_plugin(PurplePlugin *plugin)
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1046 {
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1047 GList *list;
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1048
39
2ac81c0afb53 - new debug macro. it includes function name and line number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 38
diff changeset
1049 twitter_debug("called\n");
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1050
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1051 /* disconnect from signal */
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1052 purple_signal_disconnect(purple_conversations_get_handle(),
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1053 "writing-im-msg",
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1054 plugin, PURPLE_CALLBACK(writing_im_cb));
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1055 purple_signal_disconnect(purple_conversations_get_handle(),
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1056 "sending-im-msg",
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1057 plugin, PURPLE_CALLBACK(sending_im_cb));
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1058 purple_signal_disconnect(purple_conversations_get_handle(),
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1059 "conversation-created",
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1060 plugin, PURPLE_CALLBACK(conv_created_cb));
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
1061 purple_signal_disconnect(pidgin_conversations_get_handle(),
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
1062 "displayed-im-msg",
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
1063 plugin, PURPLE_CALLBACK(displayed_im_cb));
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
1064 purple_signal_disconnect(purple_conversations_get_handle(),
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
1065 "receiving-im-msg",
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
1066 plugin, PURPLE_CALLBACK(receiving_im_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
1067 purple_signal_disconnect(purple_conversations_get_handle(),
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1068 "deleting-conversation",
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1069 plugin, PURPLE_CALLBACK(deleting_conv_cb));
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1070
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1071 /* 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
1072 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
1073 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
1074 g_regex_unref(regp[COMMAND]);
38fe566b5ee1 unref newly added regex at unload time.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 20
diff changeset
1075 g_regex_unref(regp[PSEUDO]);
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1076 g_regex_unref(regp[MESSAGE]);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1077 g_regex_unref(regp[USER]);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1078 g_regex_unref(regp[USER_FIRST_LINE]);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1079 g_regex_unref(regp[USER_FORMATTED]);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1080
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
1081 g_list_free(requested_icon_marks);
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
1082 requested_icon_marks = NULL;
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
1083
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1084 /* cancel request that has not been finished yet */
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1085 for(list = g_list_first(requestings); list; list = g_list_next(list)) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1086 purple_util_fetch_url_cancel(list->data);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1087 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1088 g_list_free(requestings);
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
1089 requestings = NULL;
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1090
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1091 /* destroy hash table for icons */
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
1092 g_hash_table_destroy(icon_id_by_user);
60
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1093 for(list = g_list_first(requested_users); list; list = g_list_next(list)) {
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1094 g_free(list->data);
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1095 }
ddd164e74312 trying to show user's icon. in this revision, the default icon of twitter is showed.
mikanbako <maoutwo@gmail.com>
parents: 59
diff changeset
1096 g_list_free(requested_users);
61
a44d15cfd8a2 trying to fix changeset 60:ddd164e74312: clash when a message received and this plugin loaded after unloaded
mikanbako <maoutwo@gmail.com>
parents: 60
diff changeset
1097 requested_users = NULL;
9
c6b80f47d4df added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 8
diff changeset
1098
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1099 /* detach from twitter window */
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1100 detach_from_window();
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1101
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1102 return TRUE;
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1103 }
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1104
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1105 static void
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1106 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
1107 gconstpointer val, gpointer data)
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1108 {
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1109 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
1110
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1111 if(enabled) {
40
e60e6cbdc4c4 - added is_twitter_account().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 39
diff changeset
1112 attach_to_window();
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1113 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1114 else {
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1115 detach_from_window();
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1116 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1117 }
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1118
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
1119 static PurplePluginPrefFrame *
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1120 get_plugin_pref_frame(PurplePlugin *plugin)
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1121 {
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
1122 /* create gtk elements for the plugin preferences */
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1123 PurplePluginPref *pref;
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1124 PurplePluginPrefFrame *frame = purple_plugin_pref_frame_new();
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1125
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
1126 /************************/
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
1127 /* 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
1128 /************************/
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1129 pref = purple_plugin_pref_new_with_label("Translation Configurations");
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1130 purple_plugin_pref_frame_add(frame, pref);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1131
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
1132 /* translation settings */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1133 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
1134 "Translate @username to link");
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1135 purple_plugin_pref_frame_add(frame, pref);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1136
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1137 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
1138 "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
1139 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
1140
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1141
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
1142 /*************************/
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
1143 /* 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
1144 /*************************/
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1145 pref = purple_plugin_pref_new_with_label("Miscellaneous Configurations");
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1146 purple_plugin_pref_frame_add(frame, pref);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1147
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1148 /* escape pseudo command setting */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1149 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
1150 "Escape pseudo command string");
19
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
1151 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
1152
37
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
1153 /* show text counter */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1154 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
1155 "Show text counter");
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1156 purple_plugin_pref_frame_add(frame, pref);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1157
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1158 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
1159
37
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
1160 /* suppress oops message */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1161 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
1162 "Suppress oops message");
37
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
1163 purple_plugin_pref_frame_add(frame, pref);
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
1164
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
1165
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
1166 /*****************/
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
1167 /* 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
1168 /*****************/
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1169 pref = purple_plugin_pref_new_with_label("Sound Configurations");
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1170 purple_plugin_pref_frame_add(frame, pref);
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1171
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
1172 /* sound settings for recipient */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1173 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
1174 "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
1175 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
1176
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
1177 /* recipient list */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1178 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
1179 "Recipient List");
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1180 purple_plugin_pref_frame_add(frame, pref);
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
1181
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
1182 /* sound id selector */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1183 pref =
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1184 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
1185 "Recipient Sound");
9
c6b80f47d4df added capability to translate sender name into link
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 8
diff changeset
1186
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1187 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
1188 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
1189 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
1190 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
1191 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
1192 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
1193 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
1194 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
1195 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
1196 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
1197 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
1198 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
1199
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1200 purple_plugin_pref_frame_add(frame, pref);
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
1201
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1202 /* sound setting for sender */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1203 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
1204 "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
1205 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
1206
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
1207 /* sender list */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1208 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
1209 "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
1210 purple_plugin_pref_frame_add(frame, pref);
1
799955af57ad alpha version
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 0
diff changeset
1211
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
1212 /* sound id selector */
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1213 pref =
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1214 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
1215 "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
1216
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1217 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
1218 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
1219 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
1220 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
1221 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
1222 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
1223 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
1224 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
1225 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
1226 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
1227 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
1228 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
1229
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1230 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
1231
59
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
1232 /************************/
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
1233 /* notification heading */
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
1234 /************************/
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
1235 pref = purple_plugin_pref_new_with_label("Notification Configuration");
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
1236 purple_plugin_pref_frame_add(frame, pref);
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
1237
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
1238 /* notification setting */
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
1239 pref = purple_plugin_pref_new_with_name_and_label(OPT_PREVENT_NOTIFICATION,
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
1240 "Prevent notifications of incoming messages");
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
1241 purple_plugin_pref_frame_add(frame, pref);
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
1242
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1243 return frame;
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1244 }
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1245
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1246 static PurplePluginUiInfo pref_info = {
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1247 get_plugin_pref_frame
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1248 };
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1249
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1250 static PurplePluginInfo info = {
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1251 PURPLE_PLUGIN_MAGIC,
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1252 PURPLE_MAJOR_VERSION,
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1253 PURPLE_MINOR_VERSION,
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1254 PURPLE_PLUGIN_STANDARD, /**< type */
19
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
1255 NULL, /**< ui_req */
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
1256 0, /**< flags */
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
1257 NULL, /**< deps */
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1258 PURPLE_PRIORITY_DEFAULT, /**< priority */
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1259 PLUGIN_ID, /**< id */
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1260 "Pidgin-Twitter", /**< name */
31
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1261 "0.6.0", /**< version */
56
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 55
diff changeset
1262 "replaces usernames with links and plays sounds", /** summary */
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 55
diff changeset
1263 "replaces usernames with links and plays sounds", /** desc */
53
872f418ba45d - revised README
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 52
diff changeset
1264 "Yoshiki Yazawa and the pidging-twitter team", /**< author */
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1265 "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
1266 load_plugin, /**< load */
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
1267 unload_plugin, /**< unload */
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1268 NULL, /**< destroy */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1269 NULL, /**< ui_info */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1270 NULL, /**< extra_info */
19
0d7cbc984570 escape pseudo command feature has been added
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 16
diff changeset
1271 &pref_info, /**< pref info */
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1272 NULL
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1273 };
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1274
8
2c7c9eb4cdda added soundid selector
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 7
diff changeset
1275 static void
38
625e385036c3 applied indent to fix indentations
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 37
diff changeset
1276 init_plugin(PurplePlugin *plugin)
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1277 {
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1278 g_type_init();
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1279
6
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1280 /* add plugin preferences */
ca8f95431962 fixed indentation
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 5
diff changeset
1281 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
1282 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
1283 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
1284 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
1285
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
1286 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
1287 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
1288 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
1289 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
1290 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
1291 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
1292
312a745dece6 added letter counter
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 30
diff changeset
1293 purple_prefs_add_bool(OPT_COUNTER, TRUE);
37
bafe2abf2d3b - made suppress oops configurable
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 36
diff changeset
1294 purple_prefs_add_bool(OPT_SUPPRESS_OOPS, TRUE);
59
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
1295
3f9148c1dc60 added that to prevent notifications of incoming messages from twitter.com.
mikanbako <maoutwo@gmail.com>
parents: 56
diff changeset
1296 purple_prefs_add_bool(OPT_PREVENT_NOTIFICATION, FALSE);
0
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1297 }
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1298
2413369d1b01 initial import
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1299 PURPLE_INIT_PLUGIN(pidgin_twitter, init_plugin, info)