annotate util.c @ 304:6c8942296a47

tweak debug messages
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sat, 13 Jun 2009 15:45:10 +0900
parents 42cdddf0f747
children 5a22c65d019c
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[];
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
4
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
5 /* prototypes */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
6 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
7
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
8
265
c2944685ac8e - update README to meet 0.8.1.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 256
diff changeset
9 /* functions */
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
10
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
11 /* this function has been taken from autoaccept plugin */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
12 gboolean
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
13 ensure_path_exists(const char *dir)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
14 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
15 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
16 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
17 return FALSE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
18 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
19
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
20 return TRUE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
21 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
22
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
23 static gchar *
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
24 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
25 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
26 int nn = 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 g_return_val_if_fail(s != NULL, NULL);
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 while(nn+1) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
31 if((int)*(s+nn) == c)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
32 return (gchar *)(s+nn);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
33 nn--;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
34 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
35 return NULL;
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
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
38 static gchar *html_tags[] = {
267
18e71951ff27 simply use "<a " as the pattern for anchor tag.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 266
diff changeset
39 "<a ",
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
40 "</a>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
41 "<b>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
42 "</b>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
43 "<p>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
44 "</p>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
45 "<div ",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
46 "</div>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
47 "<span ",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
48 "</span>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
49 "<body>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
50 "<body ",
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 "<i>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
53 "</i>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
54 "<font ",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
55 "</font>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
56 "<br>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
57 "<br/>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
58 "<img ",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
59 "<html>",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
60 "<html ",
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 NULL
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
63 };
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
64
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
65 gchar *
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
66 strip_html_markup(const gchar *src)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
67 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
68 gchar *head, *tail; /* head and tail of html */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
69 gchar *begin, *end; /* begin:< end:> */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
70 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
71 /* 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
72 gchar *startp; /* starting point marker */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
73 gchar **tagp; /* tag iterator */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
74 gchar *tmp, *tmp2; /* scratches */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
75
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
76 g_return_val_if_fail(src != NULL, NULL);
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 const gchar *ptr, *ent;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
79 gchar *ptr2;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
80 gint entlen;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
81
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
82 /* unescape &x; */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
83 html = g_malloc0(strlen(src) + 1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
84 ptr2 = html;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
85 for(ptr = src; *ptr; ) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
86 if(*ptr == '&') {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
87 ent = purple_markup_unescape_entity(ptr, &entlen);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
88 if(ent != NULL) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
89 while(*ent) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
90 *ptr2++ = *ent++;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
91 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
92 ptr += entlen;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
93 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
94 else {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
95 *ptr2++ = *ptr++;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
96 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
97 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
98 else {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
99 *ptr2++ = *ptr++;
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 } /* for */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
102
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
103 str = g_strdup("\0");
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
104
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
105 head = html;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
106 tail = head + strlen(html);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
107 startp = head;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
108
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
109 loop:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
110 begin = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
111 end = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
112
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
113 if(startp >= tail) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
114 g_free(html);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
115 return str;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
116 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
117
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
118 end = strchr(startp, '>');
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
119 if(end) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
120 begin = twitter_memrchr(startp, '<', end - startp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
121 if(begin < startp)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
122 begin = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
123
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
124 if(!begin) { /* '>' found but no corresponding '<' */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
125 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
126 tmp2 = g_strconcat(str, tmp, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
127 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
128 g_free(tmp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
129 str = tmp2;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
130 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
131 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
132 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
133 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
134 else { /* neither '>' nor '<' were found */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
135 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
136 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
137 str = tmp;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
138 g_free(html);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
139 return str;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
140 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
141
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
142 /* here, both < and > are found */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
143 /* concatenate leading part to dest */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
144 tmp = g_strndup(startp, begin - startp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
145 tmp2 = g_strconcat(str, tmp, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
146 g_free(tmp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
147 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
148 str = tmp2;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
149
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
150 /* find tag */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
151 for(tagp = html_tags; *tagp; tagp++) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
152 if(!g_ascii_strncasecmp(begin, *tagp, strlen(*tagp))) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
153 /* we found a valid tag */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
154 /* if tag is <a href=, extract address. */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
155 #if 0
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
156 if(!strcmp(*tagp, "<a href=")) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
157 vis1 = NULL; vis2 = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
158
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
159 vis1 = strchr(begin, '\'');
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
160 if(vis1)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
161 vis2 = strchr(vis1+1, '\'');
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
162 if(!vis1) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
163 vis1 = strchr(begin, '\"');
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
164 if(vis1)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
165 vis2 = strchr(vis1+1, '\"');
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
166 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
167 if(vis1 && vis2) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
168 *vis2 = '\0';
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
169 /* generate "[ http://example.com/ ] anchor " */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
170 tmp = g_strconcat(str, "[ ", vis1+1, " ]", " ", NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
171 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
172 str = tmp;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
173 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
174 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
175 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
176 } /* <a href= */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
177 else {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
178 /* anything else: discard whole <>. */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
179 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
180 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
181 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
182 #else
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
183 /* anything else: discard whole <>. */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
184 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
185 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
186 #endif
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
187 } /* valid tag */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
188 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
189
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
190 /* no valid tag was found: copy <brabra> */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
191 tmp = g_strndup(begin, end - begin + 1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
192 tmp2 = g_strconcat(str, tmp, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
193 g_free(tmp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
194 g_free(str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
195 str = tmp2;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
196 startp = end + 1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
197 goto loop;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
198 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
199
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
200 /* string utilities */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
201 void
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
202 escape(gchar **str)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
203 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
204 GMatchInfo *match_info = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
205 gchar *newstr = NULL, *match = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
206 gboolean flag = FALSE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
207
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
208 /* search genuine command */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
209 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
210 while(g_match_info_matches(match_info)) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
211 match = g_match_info_fetch(match_info, 1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
212 twitter_debug("command = %s\n", match);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
213 g_free(match);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
214 g_match_info_next(match_info, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
215 flag = TRUE;
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 g_match_info_free(match_info);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
218 match_info = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
219
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
220 if(flag)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
221 return;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
222
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
223 /* if not found, check pseudo command */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
224 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
225 while(g_match_info_matches(match_info)) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
226 match = g_match_info_fetch(match_info, 1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
227 twitter_debug("pseudo = %s\n", match);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
228 g_free(match);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
229 g_match_info_next(match_info, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
230 flag = TRUE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
231 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
232 g_match_info_free(match_info);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
233 match_info = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
234
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
235 /* if there is pseudo one, escape it */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
236 if(flag) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
237 /* put ". " to the beginning of buffer */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
238 newstr = g_strdup_printf(". %s", *str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
239 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
240 g_free(*str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
241 *str = newstr;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
242 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
243 }
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 void
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
246 strip_markup(gchar **str, gboolean escape)
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 gchar *plain;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
249
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
250 plain = strip_html_markup(*str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
251 g_free(*str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
252 if(escape) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
253 *str = g_markup_escape_text(plain, -1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
254 g_free(plain);
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 else {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
257 *str = plain;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
258 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
259 twitter_debug("result=%s\n", *str);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
260 }
256
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
261
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
262 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
263 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
264 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
265 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
266
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
267 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
268 g_strstr_len(proto, 11, "prpl-jabber")) {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
269 return TRUE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
270 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
271
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
272 return FALSE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
273 }
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_conv(PurpleConversation *conv)
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 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
279
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
280 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
281 PurpleAccount *account = purple_conversation_get_account(conv);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
282
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
283 return is_twitter_account(account, name);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
284 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
285
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
286 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
287 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
288 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
289 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
290
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
291 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
292 g_strstr_len(proto, 11, "prpl-jabber")) {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
293 return TRUE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
294 }
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 FALSE;
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_conv(PurpleConversation *conv)
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 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
303
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
304 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
305 PurpleAccount *account = purple_conversation_get_account(conv);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
306
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
307 return is_wassr_account(account, name);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
308 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
309
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
310 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
311 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
312 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
313 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
314
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
315 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
316 g_strstr_len(proto, 11, "prpl-jabber")) {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
317 return TRUE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
318 }
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 FALSE;
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_conv(PurpleConversation *conv)
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 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
327
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
328 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
329 PurpleAccount *account = purple_conversation_get_account(conv);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
330
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
331 return is_identica_account(account, name);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
332 }
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
333
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
334 gboolean
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
335 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
336 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
337 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
338
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
339 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
340 g_strstr_len(proto, 11, "prpl-jabber")) {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
341 return TRUE;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
342 }
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 FALSE;
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_conv(PurpleConversation *conv)
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 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
351
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
352 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
353 PurpleAccount *account = purple_conversation_get_account(conv);
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
354
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
355 return is_jisko_account(account, name);
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
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
358 gboolean
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
359 is_ffeed_account(PurpleAccount *account, const char *name)
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
360 {
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
361 const gchar *proto = purple_account_get_protocol_id(account);
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
362
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
363 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
364 g_strstr_len(proto, 11, "prpl-jabber")) {
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
365 return TRUE;
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
366 }
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
367
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
368 return FALSE;
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
369 }
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
370
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_conv(PurpleConversation *conv)
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 g_return_val_if_fail(conv != NULL, FALSE);
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 const char *name = purple_conversation_get_name(conv);
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
377 PurpleAccount *account = purple_conversation_get_account(conv);
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
378
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
379 return is_ffeed_account(account, name);
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
256
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
382 gint
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
383 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
384 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
385 gint service = unknown_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
386
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
387 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
388 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
389
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
390 if(is_twitter_account(account, sender))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
391 service = twitter_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
392 else if(is_wassr_account(account, sender))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
393 service = wassr_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
394 else if(is_identica_account(account, sender))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
395 service = identica_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
396 else if(is_jisko_account(account, sender))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
397 service = jisko_service;
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
398 else if(is_ffeed_account(account, sender))
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
399 service = ffeed_service;
256
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
400
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
401 return 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
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
404 gint
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
405 get_service_type(PurpleConversation *conv)
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
406 {
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
407 gint service = unknown_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
408
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
409 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
410
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
411 if(is_twitter_conv(conv))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
412 service = twitter_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
413 else if(is_wassr_conv(conv))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
414 service = wassr_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
415 else if(is_identica_conv(conv))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
416 service = identica_service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
417 else if(is_jisko_conv(conv))
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
418 service = jisko_service;
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
419 else if(is_ffeed_conv(conv))
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 267
diff changeset
420 service = ffeed_service;
256
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 return service;
9fb8f597adf3 - moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
423 }