Mercurial > pidgin-twitter
annotate util.c @ 264:b7ac562d758c
- changed the pattern for twitter icons so that it may match to protected user's icon link too.
- when pixbuf is null, pidgin-twitter will renew icon even if new and old URLs are same.
- will fall back to default icon if pixbuf couldn't be made from retrieved data.
- code cleanup.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Thu, 04 Dec 2008 18:24:06 +0900 |
parents | 9fb8f597adf3 |
children | c2944685ac8e |
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 |
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 /* this function has been taken from autoaccept plugin */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
11 gboolean |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
12 ensure_path_exists(const char *dir) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
13 { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
14 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
|
15 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
|
16 return FALSE; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
17 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
18 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
19 return TRUE; |
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 static gchar * |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
23 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
|
24 { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
25 int nn = n; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
26 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
27 g_return_val_if_fail(s != NULL, NULL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
28 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
29 while(nn+1) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
30 if((int)*(s+nn) == c) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
31 return (gchar *)(s+nn); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
32 nn--; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
33 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
34 return NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
35 } |
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 static gchar *html_tags[] = { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
38 "<a href=", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
39 "</a>", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
40 "<b>", |
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 "<p>", |
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 "<div ", |
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 "<span ", |
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 "<body>", |
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 "<i>", |
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 "<font ", |
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 "<br>", |
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 "<img ", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
58 "<html>", |
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 NULL |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
62 }; |
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 gchar * |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
65 strip_html_markup(const gchar *src) |
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 *head, *tail; /* head and tail of html */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
68 gchar *begin, *end; /* begin:< end:> */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
69 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
|
70 /* 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
|
71 gchar *startp; /* starting point marker */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
72 gchar **tagp; /* tag iterator */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
73 gchar *tmp, *tmp2; /* scratches */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
74 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
75 g_return_val_if_fail(src != NULL, NULL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
76 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
77 const gchar *ptr, *ent; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
78 gchar *ptr2; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
79 gint entlen; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
80 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
81 /* unescape &x; */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
82 html = g_malloc0(strlen(src) + 1); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
83 ptr2 = html; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
84 for(ptr = src; *ptr; ) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
85 if(*ptr == '&') { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
86 ent = purple_markup_unescape_entity(ptr, &entlen); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
87 if(ent != NULL) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
88 while(*ent) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
89 *ptr2++ = *ent++; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
90 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
91 ptr += entlen; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
92 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
93 else { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
94 *ptr2++ = *ptr++; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
95 } |
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 else { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
98 *ptr2++ = *ptr++; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
99 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
100 } /* for */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
101 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
102 str = g_strdup("\0"); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
103 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
104 head = html; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
105 tail = head + strlen(html); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
106 startp = head; |
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 loop: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
109 begin = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
110 end = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
111 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
112 if(startp >= tail) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
113 g_free(html); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
114 return str; |
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 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
117 end = strchr(startp, '>'); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
118 if(end) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
119 begin = twitter_memrchr(startp, '<', end - startp); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
120 if(begin < startp) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
121 begin = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
122 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
123 if(!begin) { /* '>' found but no corresponding '<' */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
124 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
|
125 tmp2 = g_strconcat(str, tmp, NULL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
126 g_free(str); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
127 g_free(tmp); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
128 str = tmp2; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
129 startp = end + 1; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
130 goto loop; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
131 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
132 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
133 else { /* neither '>' nor '<' were found */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
134 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
|
135 g_free(str); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
136 str = tmp; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
137 g_free(html); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
138 return str; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
139 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
140 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
141 /* here, both < and > are found */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
142 /* concatenate leading part to dest */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
143 tmp = g_strndup(startp, begin - startp); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
144 tmp2 = g_strconcat(str, tmp, NULL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
145 g_free(tmp); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
146 g_free(str); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
147 str = tmp2; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
148 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
149 /* find tag */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
150 for(tagp = html_tags; *tagp; tagp++) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
151 if(!g_ascii_strncasecmp(begin, *tagp, strlen(*tagp))) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
152 /* we found a valid tag */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
153 /* if tag is <a href=, extract address. */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
154 #if 0 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
155 if(!strcmp(*tagp, "<a href=")) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
156 vis1 = NULL; vis2 = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
157 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
158 vis1 = strchr(begin, '\''); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
159 if(vis1) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
160 vis2 = strchr(vis1+1, '\''); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
161 if(!vis1) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
162 vis1 = strchr(begin, '\"'); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
163 if(vis1) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
164 vis2 = strchr(vis1+1, '\"'); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
165 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
166 if(vis1 && vis2) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
167 *vis2 = '\0'; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
168 /* generate "[ http://example.com/ ] anchor " */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
169 tmp = g_strconcat(str, "[ ", vis1+1, " ]", " ", NULL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
170 g_free(str); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
171 str = tmp; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
172 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
173 startp = end + 1; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
174 goto loop; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
175 } /* <a href= */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
176 else { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
177 /* anything else: discard whole <>. */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
178 startp = end + 1; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
179 goto loop; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
180 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
181 #else |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
182 /* anything else: discard whole <>. */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
183 startp = end + 1; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
184 goto loop; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
185 #endif |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
186 } /* valid tag */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
187 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
188 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
189 /* no valid tag was found: copy <brabra> */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
190 tmp = g_strndup(begin, end - begin + 1); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
191 tmp2 = g_strconcat(str, tmp, NULL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
192 g_free(tmp); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
193 g_free(str); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
194 str = tmp2; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
195 startp = end + 1; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
196 goto loop; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
197 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
198 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
199 /* string utilities */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
200 void |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
201 escape(gchar **str) |
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 GMatchInfo *match_info = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
204 gchar *newstr = NULL, *match = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
205 gboolean flag = FALSE; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
206 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
207 /* search genuine command */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
208 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
|
209 while(g_match_info_matches(match_info)) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
210 match = g_match_info_fetch(match_info, 1); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
211 twitter_debug("command = %s\n", match); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
212 g_free(match); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
213 g_match_info_next(match_info, NULL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
214 flag = TRUE; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
215 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
216 g_match_info_free(match_info); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
217 match_info = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
218 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
219 if(flag) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
220 return; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
221 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
222 /* if not found, check pseudo command */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
223 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
|
224 while(g_match_info_matches(match_info)) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
225 match = g_match_info_fetch(match_info, 1); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
226 twitter_debug("pseudo = %s\n", match); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
227 g_free(match); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
228 g_match_info_next(match_info, NULL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
229 flag = TRUE; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
230 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
231 g_match_info_free(match_info); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
232 match_info = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
233 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
234 /* if there is pseudo one, escape it */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
235 if(flag) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
236 /* put ". " to the beginning of buffer */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
237 newstr = g_strdup_printf(". %s", *str); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
238 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
|
239 g_free(*str); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
240 *str = newstr; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
241 } |
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 void |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
245 strip_markup(gchar **str, gboolean escape) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
246 { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
247 gchar *plain; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
248 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
249 plain = strip_html_markup(*str); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
250 g_free(*str); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
251 if(escape) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
252 *str = g_markup_escape_text(plain, -1); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
253 g_free(plain); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
254 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
255 else { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
256 *str = plain; |
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 twitter_debug("result=%s\n", *str); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
259 } |
256
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
260 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
261 gboolean |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
262 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
|
263 { |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
264 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
|
265 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
266 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
|
267 g_strstr_len(proto, 11, "prpl-jabber")) { |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
268 return TRUE; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
269 } |
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 return FALSE; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
272 } |
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 gboolean |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
275 is_twitter_conv(PurpleConversation *conv) |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
276 { |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
277 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
|
278 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
279 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
|
280 PurpleAccount *account = purple_conversation_get_account(conv); |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
281 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
282 return is_twitter_account(account, name); |
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 gboolean |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
286 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
|
287 { |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
288 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
|
289 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
290 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
|
291 g_strstr_len(proto, 11, "prpl-jabber")) { |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
292 return TRUE; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
293 } |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
294 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
295 return FALSE; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
296 } |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
297 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
298 gboolean |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
299 is_wassr_conv(PurpleConversation *conv) |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
300 { |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
301 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
|
302 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
303 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
|
304 PurpleAccount *account = purple_conversation_get_account(conv); |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
305 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
306 return is_wassr_account(account, name); |
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 gboolean |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
310 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
|
311 { |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
312 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
|
313 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
314 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
|
315 g_strstr_len(proto, 11, "prpl-jabber")) { |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
316 return TRUE; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
317 } |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
318 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
319 return FALSE; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
320 } |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
321 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
322 gboolean |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
323 is_identica_conv(PurpleConversation *conv) |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
324 { |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
325 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
|
326 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
327 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
|
328 PurpleAccount *account = purple_conversation_get_account(conv); |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
329 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
330 return is_identica_account(account, name); |
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 gboolean |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
334 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
|
335 { |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
336 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
|
337 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
338 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
|
339 g_strstr_len(proto, 11, "prpl-jabber")) { |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
340 return TRUE; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
341 } |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
342 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
343 return FALSE; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
344 } |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
345 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
346 gboolean |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
347 is_jisko_conv(PurpleConversation *conv) |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
348 { |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
349 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
|
350 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
351 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
|
352 PurpleAccount *account = purple_conversation_get_account(conv); |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
353 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
354 return is_jisko_account(account, name); |
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 gint |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
358 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
|
359 { |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
360 gint service = unknown_service; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
361 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
362 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
|
363 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
|
364 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
365 if(is_twitter_account(account, sender)) |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
366 service = twitter_service; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
367 else if(is_wassr_account(account, sender)) |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
368 service = wassr_service; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
369 else if(is_identica_account(account, sender)) |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
370 service = identica_service; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
371 else if(is_jisko_account(account, sender)) |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
372 service = jisko_service; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
373 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
374 return service; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
375 } |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
376 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
377 gint |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
378 get_service_type(PurpleConversation *conv) |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
379 { |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
380 gint service = unknown_service; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
381 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
382 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
|
383 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
384 if(is_twitter_conv(conv)) |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
385 service = twitter_service; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
386 else if(is_wassr_conv(conv)) |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
387 service = wassr_service; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
388 else if(is_identica_conv(conv)) |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
389 service = identica_service; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
390 else if(is_jisko_conv(conv)) |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
391 service = jisko_service; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
392 |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
393 return service; |
9fb8f597adf3
- moved is_*_account() functions to util.c.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
394 } |