annotate util.c @ 337:9f78fb6bfc76

gtkimhtml easily be fooled if the buffer is not entity markuped.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Thu, 15 Oct 2009 15:49:12 +0900
parents 227852ee649c
children 2e37e715e4a6
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"
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
2
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
3 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
4 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
5 extern PurpleAccount *account_for_twitter;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
6
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
7 /* prototypes */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
8 static gchar *twitter_memrchr(const gchar *s, int c, size_t n);
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
9 void fav_with_api(guint64 id);
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
10
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
11
265
c2944685ac8e - update README to meet 0.8.1.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 256
diff changeset
12 /* functions */
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
13
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
14 /* this function has been taken from autoaccept plugin */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
15 gboolean
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
16 ensure_path_exists(const char *dir)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
17 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
18 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
19 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
20 return FALSE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
21 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
22
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
23 return TRUE;
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
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
26 static gchar *
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
27 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
28 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
29 int nn = 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 g_return_val_if_fail(s != NULL, NULL);
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 while(nn+1) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
34 if((int)*(s+nn) == c)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
35 return (gchar *)(s+nn);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
36 nn--;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
37 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
38 return NULL;
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
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
41 static gchar *html_tags[] = {
267
18e71951ff27 simply use "<a " as the pattern for anchor tag.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 266
diff changeset
42 "<a ",
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
43 "</a>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
44 "<b>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
45 "</b>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
46 "<p>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
47 "</p>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
48 "<div ",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
49 "</div>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
50 "<span ",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
51 "</span>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
52 "<body>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
53 "<body ",
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 "<i>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
56 "</i>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
57 "<font ",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
58 "</font>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
59 "<br>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
60 "<br/>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
61 "<img ",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
62 "<html>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
63 "<html ",
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 NULL
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
66 };
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
67
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
68 gchar *
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
69 strip_html_markup(const gchar *src)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
70 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
71 gchar *head, *tail; /* head and tail of html */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
72 gchar *begin, *end; /* begin:< end:> */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
73 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
74 /* 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
75 gchar *startp; /* starting point marker */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
76 gchar **tagp; /* tag iterator */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
77 gchar *tmp, *tmp2; /* scratches */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
78
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
79 g_return_val_if_fail(src != NULL, NULL);
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 const gchar *ptr, *ent;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
82 gchar *ptr2;
311
5a22c65d019c fix for memory overrun
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
83 gint srclen;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
84 gint entlen;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
85
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
86 /* unescape &x; */
311
5a22c65d019c fix for memory overrun
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
87 srclen = strlen(src);
5a22c65d019c fix for memory overrun
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
88 html = g_malloc0(srclen + 1);
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
89 ptr2 = html;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
90 for(ptr = src; *ptr; ) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
91 if(*ptr == '&') {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
92 ent = purple_markup_unescape_entity(ptr, &entlen);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
93 if(ent != NULL) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
94 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
95 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
96 *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
97 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
98 ent++;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
99 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
100 ptr += entlen;
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 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
103 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
104 *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
105 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
106 ptr++;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
107 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
108 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
109 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
110 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
111 *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
112 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
113 ptr++;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
114 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
115 } /* for */
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 str = g_strdup("\0");
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 head = html;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
120 tail = head + strlen(html);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
121 startp = head;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
122
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
123 loop:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
124 begin = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
125 end = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
126
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
127 if(startp >= tail) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
128 g_free(html);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
129 return str;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
130 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
131
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
132 end = strchr(startp, '>');
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
133 if(end) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
134 begin = twitter_memrchr(startp, '<', end - startp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
135 if(begin < startp)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
136 begin = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
137
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
138 if(!begin) { /* '>' found but no corresponding '<' */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
139 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
140 tmp2 = g_strconcat(str, tmp, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
141 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
142 g_free(tmp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
143 str = tmp2;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
144 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
145 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
146 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
147 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
148 else { /* neither '>' nor '<' were found */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
149 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
150 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
151 str = tmp;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
152 g_free(html);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
153 return str;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
154 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
155
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
156 /* here, both < and > are found */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
157 /* concatenate leading part to dest */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
158 tmp = g_strndup(startp, begin - startp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
159 tmp2 = g_strconcat(str, tmp, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
160 g_free(tmp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
161 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
162 str = tmp2;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
163
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
164 /* find tag */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
165 for(tagp = html_tags; *tagp; tagp++) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
166 if(!g_ascii_strncasecmp(begin, *tagp, strlen(*tagp))) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
167 /* we found a valid tag */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
168 /* if tag is <a href=, extract address. */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
169 #if 0
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
170 if(!strcmp(*tagp, "<a href=")) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
171 vis1 = NULL; vis2 = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
172
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
173 vis1 = strchr(begin, '\'');
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
174 if(vis1)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
175 vis2 = strchr(vis1+1, '\'');
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 vis1 = strchr(begin, '\"');
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 vis2 = strchr(vis1+1, '\"');
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
180 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
181 if(vis1 && vis2) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
182 *vis2 = '\0';
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
183 /* generate "[ http://example.com/ ] anchor " */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
184 tmp = g_strconcat(str, "[ ", vis1+1, " ]", " ", NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
185 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
186 str = tmp;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
187 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
188 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
189 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
190 } /* <a href= */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
191 else {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
192 /* anything else: discard whole <>. */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
193 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
194 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
195 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
196 #else
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
197 /* anything else: discard whole <>. */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
198 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
199 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
200 #endif
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
201 } /* valid tag */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
202 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
203
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
204 /* no valid tag was found: copy <brabra> */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
205 tmp = g_strndup(begin, end - begin + 1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
206 tmp2 = g_strconcat(str, tmp, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
207 g_free(tmp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
208 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
209 str = tmp2;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
210 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
211 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
212 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
213
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
214 /* string utilities */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
215 void
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
216 escape(gchar **str)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
217 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
218 GMatchInfo *match_info = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
219 gchar *newstr = NULL, *match = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
220 gboolean flag = FALSE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
221
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
222 /* search genuine command */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
223 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
224 while(g_match_info_matches(match_info)) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
225 match = g_match_info_fetch(match_info, 1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
226 twitter_debug("command = %s\n", match);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
227 g_free(match);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
228 g_match_info_next(match_info, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
229 flag = TRUE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
230 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
231 g_match_info_free(match_info);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
232 match_info = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
233
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
234 if(flag)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
235 return;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
236
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
237 /* if not found, check pseudo command */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
238 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
239 while(g_match_info_matches(match_info)) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
240 match = g_match_info_fetch(match_info, 1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
241 twitter_debug("pseudo = %s\n", match);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
242 g_free(match);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
243 g_match_info_next(match_info, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
244 flag = TRUE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
245 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
246 g_match_info_free(match_info);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
247 match_info = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
248
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
249 /* if there is pseudo one, escape it */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
250 if(flag) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
251 /* put ". " to the beginning of buffer */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
252 newstr = g_strdup_printf(". %s", *str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
253 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
254 g_free(*str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
255 *str = newstr;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
256 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
257 }
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 void
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
260 strip_markup(gchar **str, gboolean escape)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
261 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
262 gchar *plain;
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 plain = strip_html_markup(*str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
265 g_free(*str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
266 if(escape) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
267 *str = g_markup_escape_text(plain, -1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
268 g_free(plain);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
269 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
270 else {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
271 *str = plain;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
272 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
273 twitter_debug("result=%s\n", *str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
274 }
256
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
275
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
276 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
277 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
278 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
279 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
280
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
281 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
282 g_strstr_len(proto, 11, "prpl-jabber")) {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
283 return TRUE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
284 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
285
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
286 return FALSE;
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
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
289 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
290 is_twitter_conv(PurpleConversation *conv)
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
291 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
292 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
293
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
294 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
295 PurpleAccount *account = purple_conversation_get_account(conv);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
296
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
297 return is_twitter_account(account, name);
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
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
300 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
301 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
302 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
303 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
304
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
305 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
306 g_strstr_len(proto, 11, "prpl-jabber")) {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
307 return TRUE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
308 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
309
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
310 return FALSE;
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
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
313 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
314 is_wassr_conv(PurpleConversation *conv)
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
315 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
316 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
317
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
318 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
319 PurpleAccount *account = purple_conversation_get_account(conv);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
320
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
321 return is_wassr_account(account, name);
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
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
324 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
325 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
326 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
327 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
328
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
329 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
330 g_strstr_len(proto, 11, "prpl-jabber")) {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
331 return TRUE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
332 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
333
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
334 return FALSE;
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
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
337 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
338 is_identica_conv(PurpleConversation *conv)
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
339 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
340 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
341
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
342 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
343 PurpleAccount *account = purple_conversation_get_account(conv);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
344
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
345 return is_identica_account(account, name);
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
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
348 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
349 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
350 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
351 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
352
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
353 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
354 g_strstr_len(proto, 11, "prpl-jabber")) {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
355 return TRUE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
356 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
357
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
358 return FALSE;
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
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
361 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
362 is_jisko_conv(PurpleConversation *conv)
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
363 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
364 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
365
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
366 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
367 PurpleAccount *account = purple_conversation_get_account(conv);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
368
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
369 return is_jisko_account(account, name);
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
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
372 gboolean
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
373 is_ffeed_account(PurpleAccount *account, const char *name)
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
374 {
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
375 const gchar *proto = purple_account_get_protocol_id(account);
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 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
378 g_strstr_len(proto, 11, "prpl-jabber")) {
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
379 return TRUE;
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
380 }
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
381
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
382 return FALSE;
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
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
385 gboolean
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
386 is_ffeed_conv(PurpleConversation *conv)
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
387 {
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
388 g_return_val_if_fail(conv != NULL, FALSE);
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 const char *name = purple_conversation_get_name(conv);
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
391 PurpleAccount *account = purple_conversation_get_account(conv);
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
392
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
393 return is_ffeed_account(account, name);
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
256
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
396 gint
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
397 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
398 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
399 gint service = unknown_service;
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 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
402 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
403
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
404 if(is_twitter_account(account, sender))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
405 service = twitter_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
406 else if(is_wassr_account(account, sender))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
407 service = wassr_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
408 else if(is_identica_account(account, sender))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
409 service = identica_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
410 else if(is_jisko_account(account, sender))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
411 service = jisko_service;
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
412 else if(is_ffeed_account(account, sender))
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
413 service = ffeed_service;
256
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
414
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
415 return service;
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
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
418 gint
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
419 get_service_type(PurpleConversation *conv)
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
420 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
421 gint service = unknown_service;
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 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
424
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
425 if(is_twitter_conv(conv))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
426 service = twitter_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
427 else if(is_wassr_conv(conv))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
428 service = wassr_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
429 else if(is_identica_conv(conv))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
430 service = identica_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
431 else if(is_jisko_conv(conv))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
432 service = jisko_service;
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
433 else if(is_ffeed_conv(conv))
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
434 service = ffeed_service;
256
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
435
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
436 return service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
437 }
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
438
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
439 gboolean
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
440 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
441 {
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
442 char *idstr = NULL;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
443 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
444 PurpleConversation *conv = NULL;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
445 PidginConversation *gtkconv = NULL;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
446 guint64 msgid = 0;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
447 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
448
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
449 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
450 return FALSE;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
451
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
452 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
453
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
454 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
455 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
456
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
457 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
458 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
459 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
460 if(idstr)
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
461 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
462
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
463 /* find conv */
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
464 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
465 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
466 account_for_twitter); /* xxx */
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
467 twitter_debug("conv = %p\n", conv);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
468 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
469
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
470 twitter_debug("sender = %s, id = %llu\n", sender, (unsigned long long)msgid);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
471
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
472 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
473 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
474 recipient, -1);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
475
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
476 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
477 g_free(recipient);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
478 reply_to_msgid = msgid; /* xxx */
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
479
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
480 return TRUE;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
481 }
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
482 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
483 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
484 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
485 return TRUE;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
486 }
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
487 else if(strstr(cmd, "retweet-twitter")) {
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
488 gchar *msg0;
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
489 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
490 idstr = g_hash_table_lookup(params, "id");
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
491 msg0 = g_hash_table_lookup(params, "msg");
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
492 msg = g_uri_unescape_string(msg0, NULL);
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
493
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
494 if(idstr)
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
495 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
496
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
497 /* find conv */
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
498 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
499 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
500 account_for_twitter); /* xxx */
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
501 twitter_debug("conv = %p\n", conv);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
502 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
503
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
504 twitter_debug("sender = %s, id = %llu\n", sender, (unsigned long long)msgid);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
505
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
506 recipient = g_strdup_printf("RT @%s: %s", sender, msg);
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
507 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
508 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
509 recipient, -1);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
510
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
511 GtkTextIter iter;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
512 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
513 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
514
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
515 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
516 g_free(recipient);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
517
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
518 return TRUE;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
519 }
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
520 return FALSE;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
521 }
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
522
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
523 gchar *
337
9f78fb6bfc76 gtkimhtml easily be fooled if the buffer is not entity markuped.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 332
diff changeset
524 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
525 {
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
526 GMatchInfo *match_info = NULL;
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
527 gchar *boddy0 = NULL, *boddy = NULL;
332
227852ee649c do not append "in_reply_to_status_id" when msdid is 0.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 331
diff changeset
528 gchar *newstr = NULL, *linkstr = NULL;
227852ee649c do not append "in_reply_to_status_id" when msdid is 0.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 331
diff changeset
529 gchar *match = NULL;
227852ee649c do not append "in_reply_to_status_id" when msdid is 0.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 331
diff changeset
530 gchar *idstr = NULL, *user = NULL;
330
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 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
533
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
534 /* buffer without ptmsgid=123 */
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
535 boddy0 = g_regex_replace(regp[SENDER], *str, -1, 0, "", 0, NULL);
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
536 boddy = g_regex_replace(regp[MESSAGE_ID], boddy0, -1, 0, "", 0, NULL);
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
537 g_free(boddy0);
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
538 boddy0 = NULL;
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
539 twitter_debug("boddy = %s\n", boddy);
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
540
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
541 boddy0 = g_uri_escape_string(boddy, " !$()*,;:@/?#[]", TRUE);
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
542 g_free(boddy);
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
543 boddy = boddy0;
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
544
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
545 /* sender */
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
546 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
547 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
548 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
549 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
550 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
551 match_info = NULL;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
552 }
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 /* link string */
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
555 g_regex_match(regp[MESSAGE_ID], *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
556 if(match_info) {
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
557 match = g_match_info_fetch(match_info, 1);
332
227852ee649c do not append "in_reply_to_status_id" when msdid is 0.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 331
diff changeset
558 idstr = match ? match : "0";
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
559 linkstr = g_strdup_printf(LINK_FORMAT_TWITTER,
332
227852ee649c do not append "in_reply_to_status_id" when msdid is 0.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 331
diff changeset
560 idstr, user, /* Reply */
227852ee649c do not append "in_reply_to_status_id" when msdid is 0.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 331
diff changeset
561 idstr, /* Favorite */
227852ee649c do not append "in_reply_to_status_id" when msdid is 0.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 331
diff changeset
562 idstr, user, boddy); /* Retweet */
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
563
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
564 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
565
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
566 newstr = g_regex_replace(regp[MESSAGE_ID], *str, -1, 0,
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
567 "",
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
568 0, NULL);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
569
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
570 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
571
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
572 g_free(*str);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
573 *str = newstr;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
574
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
575 g_free(match);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
576 match = NULL;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
577
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
578 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
579 match_info = NULL;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
580 }
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
581
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
582 g_free(user);
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
583 g_free(boddy);
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
584
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
585 return linkstr;
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
586 }