Mercurial > pidgin-twitter
annotate twitter_api.c @ 353:29084c253e68
build fix for some versions of gcc
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Fri, 16 Apr 2010 12:28:22 +0900 |
parents | 33d2551727ba |
children | ff078879e68e |
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 static GList *postedlist = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
4 static GList *statuseslist = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
5 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
6 /* prototypes */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
7 static void parse_user(xmlNode *user, status_t *st); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
8 static void read_timestamp(const char *str, struct tm *res); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
9 static void parse_status(xmlNode *status, status_t *st); |
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 static void free_status(status_t *st); |
305
227e59f017f2
status id now exceeds int32 limit.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
304
diff
changeset
|
12 static gboolean is_posted_message(status_t *status, guint64 lastid); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
13 static void get_status_with_api_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, size_t len, const gchar *error_message); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
14 static void post_status_with_api_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, size_t len, const gchar *error_message); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
15 |
260
d973f9debe86
Fix Win32 compile error
Konosuke Watanabe <sasugaanija@gmail.com>
parents:
254
diff
changeset
|
16 #ifdef _WIN32 |
d973f9debe86
Fix Win32 compile error
Konosuke Watanabe <sasugaanija@gmail.com>
parents:
254
diff
changeset
|
17 extern gboolean blink_state; |
d973f9debe86
Fix Win32 compile error
Konosuke Watanabe <sasugaanija@gmail.com>
parents:
254
diff
changeset
|
18 extern gboolean blink_modified; |
d973f9debe86
Fix Win32 compile error
Konosuke Watanabe <sasugaanija@gmail.com>
parents:
254
diff
changeset
|
19 #endif |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
20 |
330
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
21 extern guint64 reply_to_msgid; |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
22 extern PurpleAccount *account_for_twitter; |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
23 |
254
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 /* API base get functions */ |
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 /* xml parser */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
28 static void |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
29 parse_user(xmlNode *user, status_t *st) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
30 { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
31 xmlNode *nptr; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
32 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
33 for(nptr = user->children; nptr != NULL; nptr = nptr->next) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
34 if(nptr->type == XML_ELEMENT_NODE) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
35 if(!xmlStrcmp(nptr->name, (xmlChar *)"screen_name")) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
36 gchar *str = (gchar *)xmlNodeGetContent(nptr); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
37 st->screen_name = g_strdup(str); |
305
227e59f017f2
status id now exceeds int32 limit.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
304
diff
changeset
|
38 twitter_debug("screen_name=%s\n", st->screen_name); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
39 xmlFree(str); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
40 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
41 else if(!xmlStrcmp(nptr->name, (xmlChar *)"profile_image_url")) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
42 gchar *str = (gchar *)xmlNodeGetContent(nptr); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
43 st->profile_image_url = g_strdup(str); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
44 xmlFree(str); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
45 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
46 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
47 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
48 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
49 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
50 static gchar *day_of_week_name[] = { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
51 "Sun", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
52 "Mon", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
53 "Tue", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
54 "Wed", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
55 "Thu", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
56 "Fri", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
57 "Sat", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
58 NULL |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
59 }; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
60 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
61 static gchar *month_name[] = { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
62 "Jan", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
63 "Feb", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
64 "Mar", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
65 "Apr", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
66 "May", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
67 "Jun", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
68 "Jul", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
69 "Aug", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
70 "Sep", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
71 "Oct", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
72 "Nov", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
73 "Dec", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
74 NULL |
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 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
77 static void |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
78 read_timestamp(const char *str, struct tm *res) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
79 { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
80 char day_of_week[4]; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
81 char month[4]; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
82 char time_offset[6]; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
83 int day, hour, minute, second, year; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
84 int i; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
85 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
86 if(str == NULL || res == NULL) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
87 return; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
88 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
89 sscanf(str, "%s %s %d %d:%d:%d %s %d", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
90 day_of_week, month, &day, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
91 &hour, &minute, &second, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
92 time_offset, &year); |
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 for(i=0; i<7; i++) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
95 if(!strcmp(day_of_week_name[i], day_of_week)) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
96 res->tm_wday = i; |
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 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
99 for(i=0; i<12; i++) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
100 if(!strcmp(month_name[i], month)) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
101 res->tm_mon = i; |
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 } |
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 res->tm_mday = day; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
106 res->tm_hour = hour; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
107 res->tm_min = minute; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
108 res->tm_sec = second; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
109 res->tm_year = year - 1900; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
110 #ifndef _WIN32 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
111 int offset = atoi(time_offset); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
112 res->tm_gmtoff = -1 * (60 * 60 * offset / 100); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
113 #endif |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
114 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
115 } |
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 static void |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
118 parse_status(xmlNode *status, status_t *st) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
119 { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
120 xmlNode *nptr; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
121 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
122 for(nptr = status->children; nptr != NULL; nptr = nptr->next) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
123 if(nptr->type == XML_ELEMENT_NODE) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
124 if(!xmlStrcmp(nptr->name, (xmlChar *)"created_at")) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
125 gchar *str = (gchar *)xmlNodeGetContent(nptr); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
126 st->created_at = g_strdup(str); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
127 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
128 /* read time stamp */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
129 struct tm res; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
130 memset(&res, 0x00, sizeof(struct tm)); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
131 read_timestamp(str, &res); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
132 tzset(); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
133 #ifdef _WIN32 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
134 st->time = mktime(&res) - timezone; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
135 #else |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
136 st->time = mktime(&res) + res.tm_gmtoff; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
137 #endif |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
138 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
139 xmlFree(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 else if(!xmlStrcmp(nptr->name, (xmlChar *)"id")) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
142 gchar *str = (gchar *)xmlNodeGetContent(nptr); |
305
227e59f017f2
status id now exceeds int32 limit.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
304
diff
changeset
|
143 st->id = atoll(str); |
335
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
144 twitter_debug("id=%llu\n", (long long unsigned int)st->id); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
145 xmlFree(str); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
146 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
147 else if(!xmlStrcmp(nptr->name, (xmlChar *)"text")) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
148 gchar *str = (gchar *)xmlNodeGetContent(nptr); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
149 st->text = g_strdup(str); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
150 xmlFree(str); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
151 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
152 else if(!xmlStrcmp(nptr->name, (xmlChar *)"user")) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
153 parse_user(nptr, st); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
154 } |
347
33d2551727ba
embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
345
diff
changeset
|
155 else if(!xmlStrcmp(nptr->name, (xmlChar *)"in_reply_to_status_id")) { |
33d2551727ba
embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
345
diff
changeset
|
156 gchar *str = (gchar *)xmlNodeGetContent(nptr); |
33d2551727ba
embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
345
diff
changeset
|
157 st->in_reply_to_status_id = atoll(str); |
33d2551727ba
embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
345
diff
changeset
|
158 twitter_debug("in_reply_to_status_id=%llu\n", (long long unsigned int)st->in_reply_to_status_id); |
33d2551727ba
embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
345
diff
changeset
|
159 xmlFree(str); |
33d2551727ba
embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
345
diff
changeset
|
160 } |
33d2551727ba
embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
345
diff
changeset
|
161 else if(!xmlStrcmp(nptr->name, (xmlChar *)"in_reply_to_screen_name")) { |
33d2551727ba
embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
345
diff
changeset
|
162 gchar *str = (gchar *)xmlNodeGetContent(nptr); |
33d2551727ba
embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
345
diff
changeset
|
163 st->in_reply_to_screen_name = g_strdup(str); |
33d2551727ba
embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
345
diff
changeset
|
164 twitter_debug("in_reply_to_screen_name=%s\n", st->in_reply_to_screen_name); |
33d2551727ba
embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
345
diff
changeset
|
165 xmlFree(str); |
33d2551727ba
embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
345
diff
changeset
|
166 } |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
167 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
168 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
169 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
170 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
171 static void |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
172 free_status(status_t *st) |
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 g_free(st->created_at); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
175 g_free(st->text); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
176 g_free(st->screen_name); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
177 g_free(st->profile_image_url); |
347
33d2551727ba
embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
345
diff
changeset
|
178 g_free(st->in_reply_to_screen_name); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
179 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
180 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
181 static gboolean |
305
227e59f017f2
status id now exceeds int32 limit.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
304
diff
changeset
|
182 is_posted_message(status_t *status, guint64 lastid) |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
183 { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
184 GList *pp = g_list_first(postedlist); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
185 gboolean rv = FALSE; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
186 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
187 while(pp) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
188 GList *next; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
189 status_t *posted = (status_t *)pp->data; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
190 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
191 next = g_list_next(pp); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
192 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
193 if(posted->id == status->id) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
194 rv = TRUE; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
195 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
196 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
197 if(posted->id <= lastid) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
198 free_status(posted); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
199 g_free(pp->data); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
200 postedlist = g_list_delete_link(postedlist, pp); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
201 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
202 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
203 pp = next; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
204 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
205 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
206 return rv; |
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 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
209 static void |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
210 get_status_with_api_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
211 const gchar *url_text, size_t len, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
212 const gchar *error_message) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
213 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
214 { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
215 xmlDocPtr doc; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
216 xmlNode *nptr, *nptr2; |
305
227e59f017f2
status id now exceeds int32 limit.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
304
diff
changeset
|
217 static guint64 lastid = 0; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
218 PurpleConversation *conv; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
219 GList *stp; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
220 const gchar *start; |
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 g_return_if_fail(url_text != NULL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
223 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
224 conv = (PurpleConversation *)user_data; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
225 if(!conv) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
226 return; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
227 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
228 /* skip to the beginning of xml */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
229 start = strstr(url_text, "<?xml"); |
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 doc = xmlRecoverMemory(start, len - (start - url_text)); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
232 if(doc == NULL) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
233 return; |
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 #ifdef _WIN32 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
236 /* suppress notification of incoming messages. */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
237 if(purple_prefs_get_bool(OPT_PREVENT_NOTIFICATION)) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
238 if(!blink_modified) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
239 blink_modified = TRUE; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
240 blink_state = purple_prefs_get_bool(OPT_PIDGIN_BLINK_IM); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
241 purple_prefs_set_bool(OPT_PIDGIN_BLINK_IM, FALSE); |
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 #endif |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
245 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
246 for(nptr = doc->children; nptr != NULL; nptr = nptr->next) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
247 if(nptr->type == XML_ELEMENT_NODE && |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
248 !xmlStrcmp(nptr->name, (xmlChar *)"statuses")) { |
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 for(nptr2 = nptr->children; nptr2 != NULL; nptr2 = nptr2->next) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
251 if(nptr2->type == XML_ELEMENT_NODE && |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
252 !xmlStrcmp(nptr2->name, (xmlChar *)"status")) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
253 status_t *st = g_new0(status_t, 1); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
254 statuseslist = g_list_prepend(statuseslist, st); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
255 parse_status(nptr2, st); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
256 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
257 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
258 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
259 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
260 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
261 xmlFreeDoc(doc); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
262 xmlCleanupParser(); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
263 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
264 /* process statuseslist */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
265 stp = g_list_first(statuseslist); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
266 while(stp) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
267 GList *next; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
268 status_t *st = (status_t *)stp->data; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
269 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
270 next = g_list_next(stp); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
271 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
272 if(st->id > lastid && !is_posted_message(st, lastid)) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
273 gchar *msg = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
274 gchar *sender = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
275 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
276 sender = g_strdup("twitter@twitter.com"); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
277 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
278 PurpleMessageFlags flag = PURPLE_MESSAGE_RECV; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
279 |
347
33d2551727ba
embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
345
diff
changeset
|
280 msg = g_strdup_printf("%s: %s pttag=%llu:%llu:%s", |
330
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
281 st->screen_name, st->text, |
347
33d2551727ba
embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
345
diff
changeset
|
282 (long long unsigned int)st->id, |
33d2551727ba
embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
345
diff
changeset
|
283 (long long unsigned int)st->in_reply_to_status_id, |
33d2551727ba
embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
345
diff
changeset
|
284 st->in_reply_to_screen_name ? st->in_reply_to_screen_name : ""); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
285 |
305
227e59f017f2
status id now exceeds int32 limit.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
304
diff
changeset
|
286 /* apply filter */ |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
287 if(purple_prefs_get_bool(OPT_FILTER)) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
288 apply_filter(&sender, &msg, &flag, twitter_service); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
289 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
290 if(sender && msg) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
291 purple_conv_im_write(conv->u.im, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
292 sender, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
293 msg, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
294 flag, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
295 st->time); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
296 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
297 lastid = st->id; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
298 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
299 g_free(sender); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
300 g_free(msg); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
301 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
302 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
303 free_status(st); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
304 g_free(stp->data); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
305 statuseslist = g_list_delete_link(statuseslist, stp); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
306 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
307 stp = next; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
308 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
309 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
310 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
311 /* status fetching function. it will be called periodically. */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
312 gboolean |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
313 get_status_with_api(gpointer data) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
314 { |
284
2d559555875f
now message count can be specified in twitter API access.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
260
diff
changeset
|
315 twitter_debug("called\n"); |
2d559555875f
now message count can be specified in twitter API access.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
260
diff
changeset
|
316 |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
317 /* fetch friends time line */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
318 char *request, *header; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
319 char *basic_auth, *basic_auth_encoded; |
284
2d559555875f
now message count can be specified in twitter API access.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
260
diff
changeset
|
320 gint count = purple_prefs_get_int(OPT_RETRIEVE_COUNT); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
321 |
284
2d559555875f
now message count can be specified in twitter API access.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
260
diff
changeset
|
322 if(count < TWITTER_DEFAULT_RETRIEVE_COUNT) |
2d559555875f
now message count can be specified in twitter API access.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
260
diff
changeset
|
323 count = TWITTER_DEFAULT_RETRIEVE_COUNT; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
324 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
325 /* if disabled, just return */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
326 if(!purple_prefs_get_bool(OPT_API_BASE_POST)) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
327 return TRUE; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
328 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
329 const char *screen_name = |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
330 purple_prefs_get_string(OPT_SCREEN_NAME_TWITTER); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
331 const char *password = |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
332 purple_prefs_get_string(OPT_PASSWORD_TWITTER); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
333 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
334 if (!screen_name || !password || !screen_name[0] || !password[0]) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
335 twitter_debug("screen_name or password is empty\n"); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
336 return TRUE; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
337 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
338 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
339 /* auth */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
340 basic_auth = g_strdup_printf("%s:%s", screen_name, password); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
341 basic_auth_encoded = purple_base64_encode((unsigned char *)basic_auth, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
342 strlen(basic_auth)); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
343 g_free(basic_auth); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
344 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
345 /* header */ |
284
2d559555875f
now message count can be specified in twitter API access.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
260
diff
changeset
|
346 header = g_strdup_printf(TWITTER_STATUS_GET, count, basic_auth_encoded); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
347 request = g_strconcat(header, "\r\n", NULL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
348 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
349 /* invoke fetch */ |
345
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
350 purple_util_fetch_url_request(TWITTER_API_BASE_URL, FALSE, |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
351 NULL, TRUE, request, TRUE, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
352 get_status_with_api_cb, data); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
353 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
354 g_free(header); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
355 g_free(basic_auth_encoded); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
356 g_free(request); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
357 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
358 return TRUE; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
359 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
360 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
361 /****************************/ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
362 /* API based post functions */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
363 /****************************/ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
364 static void |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
365 post_status_with_api_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
366 const gchar *url_text, size_t len, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
367 const gchar *error_message) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
368 { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
369 twitter_message_t *tm = (twitter_message_t *)user_data; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
370 gchar *msg = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
371 char *p1 = NULL, *p2 = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
372 int error = 1; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
373 PurpleConversation *conv; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
374 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
375 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
376 "twitter@twitter.com", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
377 tm->account); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
378 if (!conv) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
379 twitter_debug("failed to get conversation\n"); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
380 goto fin; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
381 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
382 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
383 if (error_message) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
384 /* connection failed or something */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
385 msg = g_strdup_printf("Local error: %s", error_message); |
335
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
386 } |
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
387 else { |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
388 int code = -1; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
389 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
390 if ((strncmp(url_text, "HTTP/1.0", strlen("HTTP/1.0")) == 0 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
391 || strncmp(url_text, "HTTP/1.1", strlen("HTTP/1.1")) == 0)) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
392 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
393 p1 = strchr(url_text, ' '); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
394 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
395 if (p1) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
396 p1++; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
397 p2 = strchr(p1, ' '); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
398 if (p2) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
399 p2++; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
400 else |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
401 p2 = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
402 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
403 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
404 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
405 code = atoi(p1); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
406 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
407 if (code == 200) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
408 error = 0; |
335
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
409 } |
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
410 else { |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
411 switch (code) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
412 case 400: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
413 msg = g_strdup("Invalid request. Too many updates?"); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
414 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
415 case 401: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
416 msg = g_strdup("Authorization failed."); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
417 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
418 case 403: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
419 msg = g_strdup("Your update has been refused by Twitter server " |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
420 "for some reason."); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
421 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
422 case 404: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
423 msg = g_strdup("Requested URI is not found."); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
424 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
425 case 500: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
426 msg = g_strdup("Server error."); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
427 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
428 case 502: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
429 msg = g_strdup("Twitter is down or under maintenance."); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
430 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
431 case 503: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
432 msg = g_strdup("Twitter is extremely crowded. " |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
433 "Try again later."); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
434 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
435 default: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
436 msg = g_strdup_printf("Unknown error. (%d %s)", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
437 code, p2 ? p2 : ""); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
438 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
439 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
440 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
441 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
442 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
443 if (!error) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
444 /* cache message ID that posted via API */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
445 gchar *start = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
446 xmlDocPtr doc; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
447 xmlNode *nptr; |
335
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
448 status_t *st; |
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
449 gchar *m; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
450 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
451 start = strstr(url_text, "<?xml"); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
452 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
453 if(!start) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
454 goto fin; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
455 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
456 doc = xmlRecoverMemory(start, len - (start - url_text)); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
457 if(doc == NULL) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
458 return; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
459 |
335
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
460 |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
461 /* enqueue posted message to postedlist */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
462 for(nptr = doc->children; nptr != NULL; nptr = nptr->next) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
463 if(nptr->type == XML_ELEMENT_NODE && |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
464 !xmlStrcmp(nptr->name, (xmlChar *)"status")) { |
335
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
465 st = g_new0(status_t, 1); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
466 postedlist = g_list_prepend(postedlist, st); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
467 parse_status(nptr, st); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
468 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
469 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
470 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
471 xmlFreeDoc(doc); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
472 xmlCleanupParser(); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
473 |
347
33d2551727ba
embed "in reply to foo" link to each reply message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
345
diff
changeset
|
474 m = g_strdup_printf("%s pttag=%llu:0:", |
335
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
475 tm->status, |
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
476 (long long unsigned int)st->id); |
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
477 |
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
478 purple_conv_im_write(conv->u.im, |
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
479 purple_account_get_username(tm->account), |
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
480 m, |
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
481 PURPLE_MESSAGE_SEND, |
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
482 tm->time); |
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
483 g_free(m); |
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
484 |
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
485 } |
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
486 else { |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
487 gchar *m; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
488 m = g_strdup_printf("%s<BR>%s", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
489 msg, tm->status); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
490 /* FIXME: too strong. it should be more smart */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
491 purple_conv_im_write(conv->u.im, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
492 purple_account_get_username(tm->account), |
335
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
493 m, |
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
494 PURPLE_MESSAGE_ERROR, |
34ecd09ce4f8
properly set msgid to the posted message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
333
diff
changeset
|
495 time(NULL)); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
496 g_free(m); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
497 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
498 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
499 fin: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
500 if (msg) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
501 g_free(msg); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
502 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
503 if (tm) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
504 if (tm->status) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
505 g_free(tm->status); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
506 g_free(tm); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
507 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
508 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
509 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
510 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
511 void |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
512 post_status_with_api(PurpleAccount *account, char **buffer) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
513 { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
514 char *request, *status, *header; |
290
6a206fbc6e46
do not apply xml escape to sending message.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
287
diff
changeset
|
515 const char *url_encoded = g_uri_escape_string(*buffer, "!$'()*,;=:@/?#[]", FALSE); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
516 char *basic_auth, *basic_auth_encoded; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
517 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
518 twitter_message_t *tm; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
519 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
520 const char *screen_name = |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
521 purple_prefs_get_string(OPT_SCREEN_NAME_TWITTER); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
522 const char *password = purple_prefs_get_string(OPT_PASSWORD_TWITTER); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
523 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
524 twitter_debug("tm.account: %s\n", |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
525 purple_account_get_username(account)); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
526 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
527 if (!screen_name || !password || !screen_name[0] || !password[0]) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
528 twitter_debug("screen_name or password is empty\n"); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
529 return; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
530 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
531 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
532 tm = g_new(twitter_message_t, 1); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
533 tm->account = account; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
534 tm->status = g_strdup(*buffer); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
535 tm->time = time(NULL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
536 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
537 basic_auth = g_strdup_printf("%s:%s", screen_name, password); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
538 basic_auth_encoded = purple_base64_encode((unsigned char *)basic_auth, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
539 strlen(basic_auth)); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
540 g_free(basic_auth); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
541 |
330
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
542 if(reply_to_msgid > 0) { |
333
dff611cb9f7b
fixed a bug that in_reply_to_status_id field had been ignored.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
332
diff
changeset
|
543 status = g_strdup_printf(TWITTER_REPLY_FORMAT, url_encoded, |
dff611cb9f7b
fixed a bug that in_reply_to_status_id field had been ignored.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
332
diff
changeset
|
544 (long long unsigned int)reply_to_msgid); |
dff611cb9f7b
fixed a bug that in_reply_to_status_id field had been ignored.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
332
diff
changeset
|
545 header = g_strdup_printf(TWITTER_STATUS_POST, basic_auth_encoded, |
dff611cb9f7b
fixed a bug that in_reply_to_status_id field had been ignored.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
332
diff
changeset
|
546 (int)strlen(status)); |
330
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
547 reply_to_msgid = 0; |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
548 } |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
549 else { |
333
dff611cb9f7b
fixed a bug that in_reply_to_status_id field had been ignored.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
332
diff
changeset
|
550 status = g_strdup_printf(TWITTER_STATUS_FORMAT, url_encoded); |
dff611cb9f7b
fixed a bug that in_reply_to_status_id field had been ignored.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
332
diff
changeset
|
551 header = g_strdup_printf(TWITTER_STATUS_POST, basic_auth_encoded, |
dff611cb9f7b
fixed a bug that in_reply_to_status_id field had been ignored.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
332
diff
changeset
|
552 (int)strlen(status)); |
330
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
553 } |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
554 |
333
dff611cb9f7b
fixed a bug that in_reply_to_status_id field had been ignored.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
332
diff
changeset
|
555 request = g_strconcat(header, "\r\n", status, "\r\n", NULL); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
556 purple_util_fetch_url_request(TWITTER_BASE_URL, FALSE, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
557 NULL, TRUE, request, TRUE, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
558 post_status_with_api_cb, tm); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
559 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
560 g_free(header); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
561 g_free(basic_auth_encoded); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
562 g_free(status); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
563 g_free(request); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
564 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
565 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
566 |
330
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
567 static void |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
568 fav_with_api_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
569 const gchar *url_text, size_t len, |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
570 const gchar *error_message) |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
571 { |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
572 /* dummy */ |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
573 } |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
574 |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
575 void |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
576 fav_with_api(guint64 id) |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
577 { |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
578 char *header, *request; |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
579 char *basic_auth, *basic_auth_encoded; |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
580 |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
581 const char *screen_name = |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
582 purple_prefs_get_string(OPT_SCREEN_NAME_TWITTER); |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
583 const char *password = purple_prefs_get_string(OPT_PASSWORD_TWITTER); |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
584 |
332
227852ee649c
do not append "in_reply_to_status_id" when msdid is 0.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
330
diff
changeset
|
585 if(id == 0) { |
227852ee649c
do not append "in_reply_to_status_id" when msdid is 0.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
330
diff
changeset
|
586 twitter_debug("invalid message id\n"); |
227852ee649c
do not append "in_reply_to_status_id" when msdid is 0.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
330
diff
changeset
|
587 return; |
227852ee649c
do not append "in_reply_to_status_id" when msdid is 0.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
330
diff
changeset
|
588 } |
227852ee649c
do not append "in_reply_to_status_id" when msdid is 0.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
330
diff
changeset
|
589 |
330
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
590 if (!screen_name || !password || !screen_name[0] || !password[0]) { |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
591 twitter_debug("screen_name or password is empty\n"); |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
592 return; |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
593 } |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
594 |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
595 basic_auth = g_strdup_printf("%s:%s", screen_name, password); |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
596 basic_auth_encoded = purple_base64_encode((unsigned char *)basic_auth, |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
597 strlen(basic_auth)); |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
598 g_free(basic_auth); |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
599 |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
600 |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
601 header = g_strdup_printf(TWITTER_FAV_POST, |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
602 (long long unsigned int)id, |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
603 basic_auth_encoded); |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
604 request = g_strconcat(header, "\r\n", NULL); |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
605 |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
606 purple_util_fetch_url_request(TWITTER_BASE_URL, FALSE, |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
607 NULL, TRUE, request, TRUE, |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
608 fav_with_api_cb, NULL); |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
609 twitter_debug("request = %s\n", request); |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
610 |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
611 g_free(header); |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
612 g_free(basic_auth_encoded); |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
613 g_free(request); |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
614 } |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
615 |
345
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
616 static void |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
617 retweet_with_api_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
618 const gchar *url_text, size_t len, |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
619 const gchar *error_message) |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
620 { |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
621 /* dummy */ |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
622 } |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
623 |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
624 void |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
625 retweet_with_api(guint64 id) |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
626 { |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
627 char *header, *request; |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
628 char *basic_auth, *basic_auth_encoded; |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
629 |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
630 const char *screen_name = |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
631 purple_prefs_get_string(OPT_SCREEN_NAME_TWITTER); |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
632 const char *password = purple_prefs_get_string(OPT_PASSWORD_TWITTER); |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
633 |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
634 if(id == 0) { |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
635 twitter_debug("invalid message id\n"); |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
636 return; |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
637 } |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
638 |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
639 if (!screen_name || !password || !screen_name[0] || !password[0]) { |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
640 twitter_debug("screen_name or password is empty\n"); |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
641 return; |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
642 } |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
643 |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
644 basic_auth = g_strdup_printf("%s:%s", screen_name, password); |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
645 basic_auth_encoded = purple_base64_encode((unsigned char *)basic_auth, |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
646 strlen(basic_auth)); |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
647 g_free(basic_auth); |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
648 |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
649 |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
650 header = g_strdup_printf(TWITTER_RETWEET_POST, |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
651 (long long unsigned int)id, |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
652 basic_auth_encoded); |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
653 request = g_strconcat(header, "\r\n", NULL); |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
654 |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
655 purple_util_fetch_url_request(TWITTER_API_BASE_URL, FALSE, |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
656 NULL, TRUE, request, TRUE, |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
657 retweet_with_api_cb, NULL); |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
658 twitter_debug("request = %s\n", request); |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
659 |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
660 g_free(header); |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
661 g_free(basic_auth_encoded); |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
662 g_free(request); |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
663 } |
2e37e715e4a6
add preliminary support for quotetweet and official retweet.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
335
diff
changeset
|
664 |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
665 void |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
666 signed_on_cb(PurpleConnection *gc) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
667 { |
287
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
668 PurpleAccount *account; |
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
669 PurpleBuddy *buddy; |
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
670 PurpleConversation *gconv; |
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
671 const char name[] = "twitter@twitter.com"; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
672 |
287
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
673 if(!purple_prefs_get_bool(OPT_API_BASE_POST)) { |
304 | 674 twitter_debug("per prefs\n"); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
675 return; |
287
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
676 } |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
677 |
287
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
678 account = purple_connection_get_account(gc); |
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
679 if(!account) { |
304 | 680 twitter_debug("no account\n"); |
287
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
681 return; |
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
682 } |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
683 |
287
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
684 buddy = purple_find_buddy(account, name); |
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
685 if(!buddy) { |
304 | 686 twitter_debug("no buddy\n"); |
287
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
687 return; |
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
688 } |
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
689 |
330
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
690 account_for_twitter = account; |
cc41ee1f5d3a
implemented reply, favorite, retweet functionalities. these are quite raw, be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
315
diff
changeset
|
691 |
287
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
692 gconv = purple_find_conversation_with_account( |
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
693 PURPLE_CONV_TYPE_IM, name, account); |
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
694 if(!gconv) { |
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
695 gconv = purple_conversation_new( |
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
696 PURPLE_CONV_TYPE_IM, account, name); |
304 | 697 twitter_debug("new conv\n"); |
287
4a7f4ba199cc
- version bump to 0.8.3
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
284
diff
changeset
|
698 } |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
699 } |