annotate util.c @ 350:059e962ee26a

check if string is null
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sat, 10 Apr 2010 03:29:28 +0900
parents 33d2551727ba
children f60ee22c1ac8
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);
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
265
c2944685ac8e - update README to meet 0.8.1.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 256
diff changeset
11 /* functions */
254
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 /* this function has been taken from autoaccept plugin */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
14 gboolean
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
15 ensure_path_exists(const char *dir)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
16 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
17 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
18 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
19 return FALSE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
20 }
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 return TRUE;
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 static gchar *
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
26 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
27 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
28 int nn = n;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
29
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
30 g_return_val_if_fail(s != NULL, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
31
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
32 while(nn+1) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
33 if((int)*(s+nn) == c)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
34 return (gchar *)(s+nn);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
35 nn--;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
36 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
37 return NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
38 }
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 static gchar *html_tags[] = {
267
18e71951ff27 simply use "<a " as the pattern for anchor tag.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 266
diff changeset
41 "<a ",
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
42 "</a>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
43 "<b>",
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 "<p>",
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 "<div ",
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 "<span ",
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 "<body>",
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 "<i>",
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 "<font ",
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 "<br>",
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 "<img ",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
61 "<html>",
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 NULL
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
65 };
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 gchar *
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
68 strip_html_markup(const gchar *src)
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 *head, *tail; /* head and tail of html */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
71 gchar *begin, *end; /* begin:< end:> */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
72 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
73 /* 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
74 gchar *startp; /* starting point marker */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
75 gchar **tagp; /* tag iterator */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
76 gchar *tmp, *tmp2; /* scratches */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
77
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
78 g_return_val_if_fail(src != NULL, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
79
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
80 const gchar *ptr, *ent;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
81 gchar *ptr2;
311
5a22c65d019c fix for memory overrun
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
82 gint srclen;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
83 gint entlen;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
84
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
85 /* unescape &x; */
311
5a22c65d019c fix for memory overrun
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
86 srclen = strlen(src);
5a22c65d019c fix for memory overrun
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
87 html = g_malloc0(srclen + 1);
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
88 ptr2 = html;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
89 for(ptr = src; *ptr; ) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
90 if(*ptr == '&') {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
91 ent = purple_markup_unescape_entity(ptr, &entlen);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
92 if(ent != NULL) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
93 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
94 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
95 *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
96 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
97 ent++;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
98 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
99 ptr += entlen;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
100 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
101 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
102 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
103 *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
104 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
105 ptr++;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
106 }
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 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
109 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
110 *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
111 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
112 ptr++;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
113 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
114 } /* for */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
115
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
116 str = g_strdup("\0");
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
117
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
118 head = html;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
119 tail = head + strlen(html);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
120 startp = head;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
121
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
122 loop:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
123 begin = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
124 end = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
125
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
126 if(startp >= tail) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
127 g_free(html);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
128 return str;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
129 }
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 end = strchr(startp, '>');
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
132 if(end) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
133 begin = twitter_memrchr(startp, '<', end - startp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
134 if(begin < startp)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
135 begin = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
136
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
137 if(!begin) { /* '>' found but no corresponding '<' */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
138 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
139 tmp2 = g_strconcat(str, tmp, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
140 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
141 g_free(tmp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
142 str = tmp2;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
143 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
144 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
145 }
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 else { /* neither '>' nor '<' were found */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
148 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
149 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
150 str = tmp;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
151 g_free(html);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
152 return str;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
153 }
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 /* here, both < and > are found */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
156 /* concatenate leading part to dest */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
157 tmp = g_strndup(startp, begin - startp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
158 tmp2 = g_strconcat(str, tmp, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
159 g_free(tmp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
160 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
161 str = tmp2;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
162
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
163 /* find tag */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
164 for(tagp = html_tags; *tagp; tagp++) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
165 if(!g_ascii_strncasecmp(begin, *tagp, strlen(*tagp))) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
166 /* we found a valid tag */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
167 /* if tag is <a href=, extract address. */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
168 #if 0
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
169 if(!strcmp(*tagp, "<a href=")) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
170 vis1 = NULL; vis2 = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
171
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
172 vis1 = strchr(begin, '\'');
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
173 if(vis1)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
174 vis2 = strchr(vis1+1, '\'');
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
175 if(!vis1) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
176 vis1 = strchr(begin, '\"');
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
177 if(vis1)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
178 vis2 = strchr(vis1+1, '\"');
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
179 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
180 if(vis1 && vis2) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
181 *vis2 = '\0';
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
182 /* generate "[ http://example.com/ ] anchor " */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
183 tmp = g_strconcat(str, "[ ", vis1+1, " ]", " ", NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
184 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
185 str = tmp;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
186 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
187 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
188 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
189 } /* <a href= */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
190 else {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
191 /* anything else: discard whole <>. */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
192 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
193 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
194 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
195 #else
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
196 /* anything else: discard whole <>. */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
197 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
198 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
199 #endif
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
200 } /* valid tag */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
201 }
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 /* no valid tag was found: copy <brabra> */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
204 tmp = g_strndup(begin, end - begin + 1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
205 tmp2 = g_strconcat(str, tmp, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
206 g_free(tmp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
207 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
208 str = tmp2;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
209 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
210 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
211 }
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 /* string utilities */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
214 void
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
215 escape(gchar **str)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
216 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
217 GMatchInfo *match_info = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
218 gchar *newstr = NULL, *match = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
219 gboolean flag = FALSE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
220
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
221 /* search genuine command */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
222 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
223 while(g_match_info_matches(match_info)) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
224 match = g_match_info_fetch(match_info, 1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
225 twitter_debug("command = %s\n", match);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
226 g_free(match);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
227 g_match_info_next(match_info, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
228 flag = TRUE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
229 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
230 g_match_info_free(match_info);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
231 match_info = NULL;
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 if(flag)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
234 return;
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 not found, check pseudo command */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
237 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
238 while(g_match_info_matches(match_info)) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
239 match = g_match_info_fetch(match_info, 1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
240 twitter_debug("pseudo = %s\n", match);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
241 g_free(match);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
242 g_match_info_next(match_info, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
243 flag = TRUE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
244 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
245 g_match_info_free(match_info);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
246 match_info = NULL;
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 /* if there is pseudo one, escape it */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
249 if(flag) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
250 /* put ". " to the beginning of buffer */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
251 newstr = g_strdup_printf(". %s", *str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
252 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
253 g_free(*str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
254 *str = newstr;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
255 }
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 void
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
259 strip_markup(gchar **str, gboolean escape)
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 gchar *plain;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
262
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
263 plain = strip_html_markup(*str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
264 g_free(*str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
265 if(escape) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
266 *str = g_markup_escape_text(plain, -1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
267 g_free(plain);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
268 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
269 else {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
270 *str = 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 twitter_debug("result=%s\n", *str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
273 }
256
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
274
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
275 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
276 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
277 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
278 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
279
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
280 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
281 g_strstr_len(proto, 11, "prpl-jabber")) {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
282 return TRUE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
283 }
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 return FALSE;
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 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
289 is_twitter_conv(PurpleConversation *conv)
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 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
292
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
293 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
294 PurpleAccount *account = purple_conversation_get_account(conv);
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 return is_twitter_account(account, name);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
297 }
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 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
300 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
301 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
302 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
303
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
304 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
305 g_strstr_len(proto, 11, "prpl-jabber")) {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
306 return TRUE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
307 }
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 return FALSE;
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 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
313 is_wassr_conv(PurpleConversation *conv)
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 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
316
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
317 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
318 PurpleAccount *account = purple_conversation_get_account(conv);
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 return is_wassr_account(account, name);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
321 }
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 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
324 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
325 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
326 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
327
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
328 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
329 g_strstr_len(proto, 11, "prpl-jabber")) {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
330 return TRUE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
331 }
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 return FALSE;
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 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
337 is_identica_conv(PurpleConversation *conv)
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 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
340
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
341 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
342 PurpleAccount *account = purple_conversation_get_account(conv);
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 return is_identica_account(account, name);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
345 }
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 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
348 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
349 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
350 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
351
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
352 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
353 g_strstr_len(proto, 11, "prpl-jabber")) {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
354 return TRUE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
355 }
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 return FALSE;
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 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
361 is_jisko_conv(PurpleConversation *conv)
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 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
364
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
365 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
366 PurpleAccount *account = purple_conversation_get_account(conv);
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 return is_jisko_account(account, name);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
369 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
370
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
371 gboolean
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
372 is_ffeed_account(PurpleAccount *account, const char *name)
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
373 {
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
374 const gchar *proto = purple_account_get_protocol_id(account);
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
375
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
376 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
377 g_strstr_len(proto, 11, "prpl-jabber")) {
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
378 return TRUE;
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
379 }
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 return FALSE;
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 gboolean
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
385 is_ffeed_conv(PurpleConversation *conv)
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 g_return_val_if_fail(conv != NULL, FALSE);
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
388
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
389 const char *name = purple_conversation_get_name(conv);
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
390 PurpleAccount *account = purple_conversation_get_account(conv);
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 return is_ffeed_account(account, name);
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
393 }
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
394
256
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
395 gint
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
396 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
397 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
398 gint service = unknown_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
399
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
400 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
401 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
402
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
403 if(is_twitter_account(account, sender))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
404 service = twitter_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
405 else if(is_wassr_account(account, sender))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
406 service = wassr_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
407 else if(is_identica_account(account, sender))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
408 service = identica_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
409 else if(is_jisko_account(account, sender))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
410 service = jisko_service;
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
411 else if(is_ffeed_account(account, sender))
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
412 service = ffeed_service;
256
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
413
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
414 return service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
415 }
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 gint
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
418 get_service_type(PurpleConversation *conv)
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 service = unknown_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
421
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
422 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
423
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
424 if(is_twitter_conv(conv))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
425 service = twitter_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
426 else if(is_wassr_conv(conv))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
427 service = wassr_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
428 else if(is_identica_conv(conv))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
429 service = identica_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
430 else if(is_jisko_conv(conv))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
431 service = jisko_service;
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
432 else if(is_ffeed_conv(conv))
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
433 service = ffeed_service;
256
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
434
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
435 return service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
436 }
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
437
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
438 gboolean
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
439 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
440 {
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
441 char *idstr = NULL;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
442 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
443 PurpleConversation *conv = NULL;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
444 PidginConversation *gtkconv = NULL;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
445 guint64 msgid = 0;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
446 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
447
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
448 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
449 return FALSE;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
450
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
451 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
452
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
453 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
454 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
455
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
456 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
457 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
458 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
459 if(idstr)
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
460 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
461
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
462 /* find conv */
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
463 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
464 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
465 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
466 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
467 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
468
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
469 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
470
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
471 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
472 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
473 recipient, -1);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
474
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
475 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
476 g_free(recipient);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
477 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
478
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
479 return TRUE;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
480 }
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
481 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
482 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
483 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
484 return TRUE;
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 else if(strstr(cmd, "retweet-twitter")) {
345
2e37e715e4a6 add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 337
diff changeset
487 idstr = g_hash_table_lookup(params, "id");
2e37e715e4a6 add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 337
diff changeset
488 retweet_with_api(strtoull(idstr, NULL, 10));
2e37e715e4a6 add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 337
diff changeset
489 return TRUE;
2e37e715e4a6 add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 337
diff changeset
490 }
2e37e715e4a6 add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 337
diff changeset
491 else if(strstr(cmd, "quotetweet-twitter")) {
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
492 gchar *msg0;
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
493 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
494 idstr = g_hash_table_lookup(params, "id");
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
495 msg0 = g_hash_table_lookup(params, "msg");
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
496 msg = g_uri_unescape_string(msg0, NULL);
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
497
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
498 if(idstr)
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
499 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
500
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
501 /* find conv */
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
502 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
503 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
504 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
505 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
506 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
507
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
508 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
509
345
2e37e715e4a6 add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 337
diff changeset
510 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
511 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
512 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
513 recipient, -1);
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 GtkTextIter iter;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
516 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
517 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
518
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
519 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
520 g_free(recipient);
346
dbebabe99035 add in_reply_to field to QT post
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 345
diff changeset
521 reply_to_msgid = msgid; /* xxx */
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
522
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
523 return TRUE;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
524 }
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
525 return FALSE;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
526 }
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
527
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
528 gchar *
337
9f78fb6bfc76 gtkimhtml easily be fooled if the buffer is not entity markuped.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 332
diff changeset
529 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
530 {
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
531 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
532 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
533 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
534 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
535
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
536 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
537
347
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
538 /* buffer without pttag= */
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
539 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
540 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
541 g_free(body0);
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
542 body0 = NULL;
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
543 twitter_debug("body = %s\n", body);
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
544
347
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
545 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
546 g_free(body);
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
547 body = body0;
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
548
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
549 /* sender */
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
550 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
551 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
552 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
553 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
554 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
555 match_info = NULL;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
556 }
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 /* link string */
347
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
559 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
560 if(match_info) {
347
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
561 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
562 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
563 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
564
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
565 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
566 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
567 if(in_reply_to_status_id_str)
059e962ee26a check if string is null
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 347
diff changeset
568 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
569 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
570 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
571
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
572 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
573 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
574
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
575 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
576 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
577 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
578 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
579 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
580 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
581 msg_id_str, /* Favorite */
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
582 msg_id_str, /* Retweet */
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
583 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
584
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
585 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
586 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
587 }
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
588 else {
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
589 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
590 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
591 msg_id_str, /* Favorite */
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
592 msg_id_str, /* Retweet */
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
593 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
594 }
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
595
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
596 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
597
347
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
598 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
599
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
600 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
601
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
602 g_free(*str);
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
603 *str = newstr;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
604
347
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
605 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
606 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
607
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
608 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
609 match_info = NULL;
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
610 }
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
611
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
612 g_free(user);
347
33d2551727ba embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 346
diff changeset
613 g_free(body);
331
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
614
b4c846870b3c improved handling of RT string
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 330
diff changeset
615 return linkstr;
330
cc41ee1f5d3a implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 312
diff changeset
616 }