annotate util.c @ 364:cbdf0b35d31b default tip

Added tag 0.9.2.1 for changeset 85e109dee063
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 13 May 2011 00:02:49 +0900
parents 29084c253e68
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1 #include "pidgin-twitter.h"
352
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
2 #include <gtkutils.h>
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
3 #include <pidginstock.h>
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
4 #include <gtkblist.h>
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
5
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
6 extern GRegex *regp[];
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
7 extern guint64 reply_to_msgid;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
8 extern PurpleAccount *account_for_twitter;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
9
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
10 /* prototypes */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
11 static gchar *twitter_memrchr(const gchar *s, int c, size_t n);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
12
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
13
265
c2944685ac8e - update README to meet 0.8.1.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 256
diff changeset
14 /* functions */
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
15
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
16 /* this function has been taken from autoaccept plugin */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
17 gboolean
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
18 ensure_path_exists(const char *dir)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
19 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
20 if (!g_file_test(dir, G_FILE_TEST_IS_DIR)) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
21 if (purple_build_dir(dir, S_IRUSR | S_IWUSR | S_IXUSR))
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
22 return FALSE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
23 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
24
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
25 return TRUE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
26 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
27
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
28 static gchar *
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
29 twitter_memrchr(const gchar *s, int c, size_t n)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
30 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
31 int nn = n;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
32
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
33 g_return_val_if_fail(s != NULL, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
34
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
35 while(nn+1) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
36 if((int)*(s+nn) == c)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
37 return (gchar *)(s+nn);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
38 nn--;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
39 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
40 return NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
41 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
42
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
43 static gchar *html_tags[] = {
267
18e71951ff27 simply use "<a " as the pattern for anchor tag.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 266
diff changeset
44 "<a ",
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
45 "</a>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
46 "<b>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
47 "</b>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
48 "<p>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
49 "</p>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
50 "<div ",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
51 "</div>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
52 "<span ",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
53 "</span>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
54 "<body>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
55 "<body ",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
56 "</body>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
57 "<i>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
58 "</i>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
59 "<font ",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
60 "</font>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
61 "<br>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
62 "<br/>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
63 "<img ",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
64 "<html>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
65 "<html ",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
66 "</html>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
67 NULL
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
68 };
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
69
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
70 gchar *
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
71 strip_html_markup(const gchar *src)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
72 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
73 gchar *head, *tail; /* head and tail of html */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
74 gchar *begin, *end; /* begin:< end:> */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
75 gchar *html, *str; /* copied src and string to be returned */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
76 /* gchar *vis1, *vis2; */ /* begin and end of address part */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
77 gchar *startp; /* starting point marker */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
78 gchar **tagp; /* tag iterator */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
79 gchar *tmp, *tmp2; /* scratches */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
80
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
81 g_return_val_if_fail(src != NULL, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
82
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
83 const gchar *ptr, *ent;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
84 gchar *ptr2;
311
5a22c65d019c fix for memory overrun
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
85 gint srclen;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
86 gint entlen;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
87
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
88 /* unescape &x; */
311
5a22c65d019c fix for memory overrun
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
89 srclen = strlen(src);
5a22c65d019c fix for memory overrun
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
90 html = g_malloc0(srclen + 1);
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
91 ptr2 = html;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
92 for(ptr = src; *ptr; ) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
93 if(*ptr == '&') {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
94 ent = purple_markup_unescape_entity(ptr, &entlen);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
95 if(ent != NULL) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
96 while(*ent) {
312
e2156468f4e5 better workaround for the bug of pidgin 2.5.x that purple_markup_unescape_entity() returns wrong entity length for a string in hexadecimal numeric expression.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 311
diff changeset
97 if(ptr2 - html < srclen)
e2156468f4e5 better workaround for the bug of pidgin 2.5.x that purple_markup_unescape_entity() returns wrong entity length for a string in hexadecimal numeric expression.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 311
diff changeset
98 *ptr2++ = *ent++;
e2156468f4e5 better workaround for the bug of pidgin 2.5.x that purple_markup_unescape_entity() returns wrong entity length for a string in hexadecimal numeric expression.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 311
diff changeset
99 else
e2156468f4e5 better workaround for the bug of pidgin 2.5.x that purple_markup_unescape_entity() returns wrong entity length for a string in hexadecimal numeric expression.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 311
diff changeset
100 ent++;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
101 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
102 ptr += entlen;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
103 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
104 else {
312
e2156468f4e5 better workaround for the bug of pidgin 2.5.x that purple_markup_unescape_entity() returns wrong entity length for a string in hexadecimal numeric expression.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 311
diff changeset
105 if(ptr2 - html < srclen)
e2156468f4e5 better workaround for the bug of pidgin 2.5.x that purple_markup_unescape_entity() returns wrong entity length for a string in hexadecimal numeric expression.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 311
diff changeset
106 *ptr2++ = *ptr++;
e2156468f4e5 better workaround for the bug of pidgin 2.5.x that purple_markup_unescape_entity() returns wrong entity length for a string in hexadecimal numeric expression.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 311
diff changeset
107 else
e2156468f4e5 better workaround for the bug of pidgin 2.5.x that purple_markup_unescape_entity() returns wrong entity length for a string in hexadecimal numeric expression.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 311
diff changeset
108 ptr++;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
109 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
110 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
111 else {
312
e2156468f4e5 better workaround for the bug of pidgin 2.5.x that purple_markup_unescape_entity() returns wrong entity length for a string in hexadecimal numeric expression.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 311
diff changeset
112 if(ptr2 - html < srclen)
e2156468f4e5 better workaround for the bug of pidgin 2.5.x that purple_markup_unescape_entity() returns wrong entity length for a string in hexadecimal numeric expression.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 311
diff changeset
113 *ptr2++ = *ptr++;
e2156468f4e5 better workaround for the bug of pidgin 2.5.x that purple_markup_unescape_entity() returns wrong entity length for a string in hexadecimal numeric expression.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 311
diff changeset
114 else
e2156468f4e5 better workaround for the bug of pidgin 2.5.x that purple_markup_unescape_entity() returns wrong entity length for a string in hexadecimal numeric expression.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 311
diff changeset
115 ptr++;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
116 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
117 } /* for */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
118
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
119 str = g_strdup("\0");
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
120
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
121 head = html;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
122 tail = head + strlen(html);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
123 startp = head;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
124
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
125 loop:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
126 begin = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
127 end = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
128
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
129 if(startp >= tail) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
130 g_free(html);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
131 return str;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
132 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
133
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
134 end = strchr(startp, '>');
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
135 if(end) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
136 begin = twitter_memrchr(startp, '<', end - startp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
137 if(begin < startp)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
138 begin = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
139
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
140 if(!begin) { /* '>' found but no corresponding '<' */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
141 tmp = g_strndup(startp, end - startp + 1); /* concat until '>' */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
142 tmp2 = g_strconcat(str, tmp, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
143 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
144 g_free(tmp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
145 str = tmp2;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
146 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
147 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
148 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
149 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
150 else { /* neither '>' nor '<' were found */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
151 tmp = g_strconcat(str, startp, NULL); /* concat the rest */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
152 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
153 str = tmp;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
154 g_free(html);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
155 return str;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
156 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
157
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
158 /* here, both < and > are found */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
159 /* concatenate leading part to dest */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
160 tmp = g_strndup(startp, begin - startp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
161 tmp2 = g_strconcat(str, tmp, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
162 g_free(tmp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
163 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
164 str = tmp2;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
165
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
166 /* find tag */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
167 for(tagp = html_tags; *tagp; tagp++) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
168 if(!g_ascii_strncasecmp(begin, *tagp, strlen(*tagp))) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
169 /* we found a valid tag */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
170 /* if tag is <a href=, extract address. */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
171 #if 0
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
172 if(!strcmp(*tagp, "<a href=")) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
173 vis1 = NULL; vis2 = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
174
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
175 vis1 = strchr(begin, '\'');
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
176 if(vis1)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
177 vis2 = strchr(vis1+1, '\'');
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
178 if(!vis1) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
179 vis1 = strchr(begin, '\"');
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
180 if(vis1)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
181 vis2 = strchr(vis1+1, '\"');
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
182 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
183 if(vis1 && vis2) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
184 *vis2 = '\0';
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
185 /* generate "[ http://example.com/ ] anchor " */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
186 tmp = g_strconcat(str, "[ ", vis1+1, " ]", " ", NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
187 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
188 str = tmp;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
189 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
190 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
191 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
192 } /* <a href= */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
193 else {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
194 /* anything else: discard whole <>. */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
195 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
196 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
197 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
198 #else
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
199 /* anything else: discard whole <>. */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
200 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
201 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
202 #endif
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
203 } /* valid tag */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
204 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
205
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
206 /* no valid tag was found: copy <brabra> */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
207 tmp = g_strndup(begin, end - begin + 1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
208 tmp2 = g_strconcat(str, tmp, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
209 g_free(tmp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
210 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
211 str = tmp2;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
212 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
213 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
214 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
215
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
216 /* string utilities */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
217 void
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
218 escape(gchar **str)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
219 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
220 GMatchInfo *match_info = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
221 gchar *newstr = NULL, *match = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
222 gboolean flag = FALSE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
223
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
224 /* search genuine command */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
225 g_regex_match(regp[COMMAND], *str, 0, &match_info);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
226 while(g_match_info_matches(match_info)) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
227 match = g_match_info_fetch(match_info, 1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
228 twitter_debug("command = %s\n", match);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
229 g_free(match);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
230 g_match_info_next(match_info, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
231 flag = TRUE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
232 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
233 g_match_info_free(match_info);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
234 match_info = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
235
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
236 if(flag)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
237 return;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
238
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
239 /* if not found, check pseudo command */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
240 g_regex_match(regp[PSEUDO], *str, 0, &match_info);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
241 while(g_match_info_matches(match_info)) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
242 match = g_match_info_fetch(match_info, 1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
243 twitter_debug("pseudo = %s\n", match);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
244 g_free(match);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
245 g_match_info_next(match_info, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
246 flag = TRUE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
247 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
248 g_match_info_free(match_info);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
249 match_info = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
250
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
251 /* if there is pseudo one, escape it */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
252 if(flag) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
253 /* put ". " to the beginning of buffer */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
254 newstr = g_strdup_printf(". %s", *str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
255 twitter_debug("*str = %s newstr = %s\n", *str, newstr);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
256 g_free(*str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
257 *str = newstr;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
258 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
259 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
260
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
261 void
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
262 strip_markup(gchar **str, gboolean escape)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
263 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
264 gchar *plain;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
265
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
266 plain = strip_html_markup(*str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
267 g_free(*str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
268 if(escape) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
269 *str = g_markup_escape_text(plain, -1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
270 g_free(plain);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
271 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
272 else {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
273 *str = plain;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
274 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
275 twitter_debug("result=%s\n", *str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
276 }
256
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
277
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
278 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
279 is_twitter_account(PurpleAccount *account, const char *name)
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
280 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
281 const gchar *proto = purple_account_get_protocol_id(account);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
282
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
283 if(g_strstr_len(name, 19, "twitter@twitter.com") &&
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
284 g_strstr_len(proto, 11, "prpl-jabber")) {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
285 return TRUE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
286 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
287
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
288 return FALSE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
289 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
290
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
291 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
292 is_twitter_conv(PurpleConversation *conv)
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
293 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
294 g_return_val_if_fail(conv != NULL, FALSE);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
295
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
296 const char *name = purple_conversation_get_name(conv);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
297 PurpleAccount *account = purple_conversation_get_account(conv);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
298
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
299 return is_twitter_account(account, name);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
300 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
301
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
302 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
303 is_wassr_account(PurpleAccount *account, const char *name)
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
304 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
305 const gchar *proto = purple_account_get_protocol_id(account);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
306
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
307 if(g_strstr_len(name, 18, "wassr-bot@wassr.jp") &&
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
308 g_strstr_len(proto, 11, "prpl-jabber")) {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
309 return TRUE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
310 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
311
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
312 return FALSE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
313 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
314
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
315 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
316 is_wassr_conv(PurpleConversation *conv)
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
317 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
318 g_return_val_if_fail(conv != NULL, FALSE);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
319
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
320 const char *name = purple_conversation_get_name(conv);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
321 PurpleAccount *account = purple_conversation_get_account(conv);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
322
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
323 return is_wassr_account(account, name);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
324 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
325
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
326 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
327 is_identica_account(PurpleAccount *account, const char *name)
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
328 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
329 const gchar *proto = purple_account_get_protocol_id(account);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
330
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
331 if(g_strstr_len(name, 16, "update@identi.ca") &&
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
332 g_strstr_len(proto, 11, "prpl-jabber")) {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
333 return TRUE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
334 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
335
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
336 return FALSE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
337 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
338
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
339 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
340 is_identica_conv(PurpleConversation *conv)
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
341 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
342 g_return_val_if_fail(conv != NULL, FALSE);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
343
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
344 const char *name = purple_conversation_get_name(conv);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
345 PurpleAccount *account = purple_conversation_get_account(conv);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
346
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
347 return is_identica_account(account, name);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
348 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
349
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
350 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
351 is_jisko_account(PurpleAccount *account, const char *name)
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
352 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
353 const gchar *proto = purple_account_get_protocol_id(account);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
354
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
355 if(g_strstr_len(name, 16, "bot@jisko.net") &&
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
356 g_strstr_len(proto, 11, "prpl-jabber")) {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
357 return TRUE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
358 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
359
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
360 return FALSE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
361 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
362
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
363 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
364 is_jisko_conv(PurpleConversation *conv)
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
365 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
366 g_return_val_if_fail(conv != NULL, FALSE);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
367
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
368 const char *name = purple_conversation_get_name(conv);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
369 PurpleAccount *account = purple_conversation_get_account(conv);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
370
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
371 return is_jisko_account(account, name);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
372 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
373
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
374 gboolean
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
375 is_ffeed_account(PurpleAccount *account, const char *name)
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
376 {
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
377 const gchar *proto = purple_account_get_protocol_id(account);
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
378
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
379 if(g_strstr_len(name, 22, "ff@chat.friendfeed.com") &&
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
380 g_strstr_len(proto, 11, "prpl-jabber")) {
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
381 return TRUE;
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
382 }
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
383
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
384 return FALSE;
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
385 }
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
386
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
387 gboolean
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
388 is_ffeed_conv(PurpleConversation *conv)
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
389 {
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
390 g_return_val_if_fail(conv != NULL, FALSE);
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
391
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
392 const char *name = purple_conversation_get_name(conv);
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
393 PurpleAccount *account = purple_conversation_get_account(conv);
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
394
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
395 return is_ffeed_account(account, name);
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
396 }
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
397
256
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
398 gint
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
399 get_service_type_by_account(PurpleAccount *account, const char *sender)
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
400 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
401 gint service = unknown_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
402
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
403 g_return_val_if_fail(account != NULL, unknown_service);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
404 g_return_val_if_fail(sender != NULL, unknown_service);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
405
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
406 if(is_twitter_account(account, sender))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
407 service = twitter_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
408 else if(is_wassr_account(account, sender))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
409 service = wassr_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
410 else if(is_identica_account(account, sender))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
411 service = identica_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
412 else if(is_jisko_account(account, sender))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
413 service = jisko_service;
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
414 else if(is_ffeed_account(account, sender))
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
415 service = ffeed_service;
256
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
416
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
417 return service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
418 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
419
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
420 gint
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
421 get_service_type(PurpleConversation *conv)
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
422 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
423 gint service = unknown_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
424
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
425 g_return_val_if_fail(conv != NULL, unknown_service);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
426
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
427 if(is_twitter_conv(conv))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
428 service = twitter_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
429 else if(is_wassr_conv(conv))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
430 service = wassr_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
431 else if(is_identica_conv(conv))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
432 service = identica_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
433 else if(is_jisko_conv(conv))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
434 service = jisko_service;
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
435 else if(is_ffeed_conv(conv))
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
436 service = ffeed_service;
256
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
437
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
438 return service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
439 }
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
440
352
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
441 void cancel_retweet(void *data)
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
442 {
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
443 /* do nothing */
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
444 }
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
445
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
446 void do_retweet(void *data)
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
447 {
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
448 guint64 msgid = *(guint64 *)data;
353
29084c253e68 build fix for some versions of gcc
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 352
diff changeset
449 twitter_debug("msgid=%llu\n", (long long unsigned int)msgid);
352
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
450 retweet_with_api(msgid);
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
451 }
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
452
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
453 gboolean
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
454 pt_uri_handler(const char *proto, const char *cmd, GHashTable *params)
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
455 {
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
456 char *idstr = NULL;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
457 const char *acct_id = NULL;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
458 PurpleConversation *conv = NULL;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
459 PidginConversation *gtkconv = NULL;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
460 guint64 msgid = 0;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
461 gchar *sender = NULL, *recipient = NULL, *msg = NULL;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
462
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
463 if(g_ascii_strcasecmp(proto, "pt"))
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
464 return FALSE;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
465
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
466 twitter_debug("params=%p\n", params);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
467
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
468 acct_id = purple_prefs_get_string(OPT_SCREEN_NAME_TWITTER);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
469 twitter_debug("acct_id=%s\n", acct_id);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
470
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
471 if(strstr(cmd, "reply-twitter")) {
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
472 sender = g_hash_table_lookup(params, "user");
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
473 idstr = g_hash_table_lookup(params, "id");
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
474 if(idstr)
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
475 msgid = strtoull(idstr, NULL, 10);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
476
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
477 /* find conv */
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
478 conv = purple_find_conversation_with_account(
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
479 PURPLE_CONV_TYPE_ANY, "twitter@twitter.com",
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
480 account_for_twitter); /* xxx */
352
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
481 twitter_debug("conv=%p\n", conv);
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
482 gtkconv = PIDGIN_CONVERSATION(conv);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
483
352
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
484 twitter_debug("sender=%s, id=%llu\n", sender, (unsigned long long)msgid);
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
485
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
486 recipient = g_strdup_printf("@%s ", sender);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
487 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer,
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
488 recipient, -1);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
489
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
490 gtk_widget_grab_focus(GTK_WIDGET(gtkconv->entry));
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
491 g_free(recipient);
352
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
492 reply_to_msgid = msgid;
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
493
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
494 return TRUE;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
495 }
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
496 else if(strstr(cmd, "fav-twitter")) {
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
497 idstr = g_hash_table_lookup(params, "id");
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
498 fav_with_api(strtoull(idstr, NULL, 10));
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
499 return TRUE;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
500 }
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
501 else if(strstr(cmd, "retweet-twitter")) {
352
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
502 GtkWidget *retweet_dialog;
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
503 static guint64 retweet_msgid = 0;
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
504
345
2e37e715e4a6 add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 337
diff changeset
505 idstr = g_hash_table_lookup(params, "id");
352
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
506 retweet_msgid = strtoull(idstr, NULL, 10);
353
29084c253e68 build fix for some versions of gcc
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 352
diff changeset
507 twitter_debug("retweet_msgid=%llu\n", (long long unsigned int)retweet_msgid);
352
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
508
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
509 retweet_dialog = pidgin_make_mini_dialog(
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
510 NULL,
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
511 PIDGIN_STOCK_DIALOG_INFO,
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
512 "Are you sure to retweet this message?",
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
513 NULL, /* secondary */
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
514 (void *)&retweet_msgid, /* user data */
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
515 "Cancel", PURPLE_CALLBACK(cancel_retweet),
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
516 "Retweet", PURPLE_CALLBACK(do_retweet),
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
517 NULL);
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
518 pidgin_blist_add_alert(retweet_dialog);
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
519
345
2e37e715e4a6 add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 337
diff changeset
520 return TRUE;
2e37e715e4a6 add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 337
diff changeset
521 }
2e37e715e4a6 add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 337
diff changeset
522 else if(strstr(cmd, "quotetweet-twitter")) {
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
523 gchar *msg0;
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
524 sender = g_hash_table_lookup(params, "user");
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
525 idstr = g_hash_table_lookup(params, "id");
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
526 msg0 = g_hash_table_lookup(params, "msg");
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
527 msg = g_uri_unescape_string(msg0, NULL);
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
528
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
529 if(idstr)
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
530 msgid = strtoull(idstr, NULL, 10);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
531
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
532 /* find conv */
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
533 conv = purple_find_conversation_with_account(
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
534 PURPLE_CONV_TYPE_ANY, "twitter@twitter.com",
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
535 account_for_twitter); /* xxx */
352
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
536 twitter_debug("conv=%p\n", conv);
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
537 gtkconv = PIDGIN_CONVERSATION(conv);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
538
352
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
539 twitter_debug("sender=%s, id=%llu\n", sender, (unsigned long long)msgid);
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
540
345
2e37e715e4a6 add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 337
diff changeset
541 recipient = g_strdup_printf("QT @%s: %s", sender, msg);
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
542 g_free(msg);
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
543 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer,
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
544 recipient, -1);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
545
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
546 GtkTextIter iter;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
547 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &iter);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
548 gtk_text_buffer_place_cursor(gtkconv->entry_buffer, &iter);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
549
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
550 gtk_widget_grab_focus(GTK_WIDGET(gtkconv->entry));
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
551 g_free(recipient);
352
f60ee22c1ac8 shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 350
diff changeset
552 reply_to_msgid = msgid;
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
553
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
554 return TRUE;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
555 }
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
556 return FALSE;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
557 }
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
558
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
559 gchar *
337
9f78fb6bfc76 gtkimhtml easily be fooled if the buffer is not entity markuped.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 332
diff changeset
560 twitter_rip_link_string(gchar **str)
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
561 {
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
562 GMatchInfo *match_info = NULL;
347
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
563 gchar *body0 = NULL, *body = NULL;
332
227852ee649c do not append "in_reply_to_status_id" when msdid is 0.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 331
diff changeset
564 gchar *newstr = NULL, *linkstr = NULL;
347
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
565 gchar *user = NULL;
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
566
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
567 twitter_debug("called\n");
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
568
347
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
569 /* buffer without pttag= */
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
570 body0 = g_regex_replace(regp[SENDER], *str, -1, 0, "", 0, NULL);
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
571 body = g_regex_replace(regp[PTTAG_TWITTER], body0, -1, 0, "", 0, NULL);
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
572 g_free(body0);
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
573 body0 = NULL;
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
574 twitter_debug("body = %s\n", body);
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
575
347
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
576 body0 = g_uri_escape_string(body, " !$()*,;:@/?#[]", TRUE);
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
577 g_free(body);
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
578 body = body0;
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
579
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
580 /* sender */
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
581 g_regex_match(regp[SENDER], *str, 0, &match_info);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
582 if(g_match_info_matches(match_info)) {
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
583 user = g_match_info_fetch(match_info, 2);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
584 twitter_debug("user = %s\n", user);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
585 g_match_info_free(match_info);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
586 match_info = NULL;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
587 }
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
588
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
589 /* link string */
347
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
590 g_regex_match(regp[PTTAG_TWITTER], *str, 0, &match_info);
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
591 if(match_info) {
347
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
592 gchar *msg_id_str = NULL;
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
593 gchar *in_reply_to_status_id_str = NULL;
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
594 long long unsigned int in_reply_to_status_id = 0;
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
595
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
596 msg_id_str = g_match_info_fetch(match_info, 1);
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
597 in_reply_to_status_id_str = g_match_info_fetch(match_info, 2);
350
059e962ee26a check if string is null
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 347
diff changeset
598 if(in_reply_to_status_id_str)
059e962ee26a check if string is null
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 347
diff changeset
599 in_reply_to_status_id = strtoull(in_reply_to_status_id_str, NULL, 10);
347
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
600 g_free(in_reply_to_status_id_str);
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
601 in_reply_to_status_id_str = NULL;
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
602
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
603 if(in_reply_to_status_id) {
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
604 gchar *in_reply_to_screen_name;
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
605
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
606 in_reply_to_screen_name = g_match_info_fetch(match_info, 3);
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
607 linkstr = g_strdup_printf(IN_REPLY_TO_FORMAT_TWITTER LINK_FORMAT_TWITTER,
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
608 in_reply_to_screen_name,
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
609 in_reply_to_status_id,
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
610 in_reply_to_screen_name,
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
611 msg_id_str, user, /* Reply */
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
612 msg_id_str, /* Favorite */
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
613 msg_id_str, /* Retweet */
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
614 msg_id_str, user, body); /* Quotetweet */
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
615
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
616 g_free(in_reply_to_screen_name);
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
617 in_reply_to_screen_name = NULL;
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
618 }
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
619 else {
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
620 linkstr = g_strdup_printf(LINK_FORMAT_TWITTER,
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
621 msg_id_str, user, /* Reply */
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
622 msg_id_str, /* Favorite */
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
623 msg_id_str, /* Retweet */
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
624 msg_id_str, user, body); /* Quotetweet */
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
625 }
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
626
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
627 twitter_debug("linkstr = %s\n", linkstr);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
628
347
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
629 newstr = g_regex_replace(regp[PTTAG_TWITTER], *str, -1, 0, "", 0, NULL);
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
630
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
631 twitter_debug("newstr = %s\n", newstr);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
632
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
633 g_free(*str);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
634 *str = newstr;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
635
347
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
636 g_free(msg_id_str);
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
637 msg_id_str = NULL;
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
638
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
639 g_match_info_free(match_info);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
640 match_info = NULL;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
641 }
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
642
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
643 g_free(user);
347
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
644 g_free(body);
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
645
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
646 return linkstr;
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
647 }