Mercurial > pidgin
annotate src/protocols/trepia/trepia.c @ 8589:72a0759a37a2
[gaim-migrate @ 9340]
Paco-Paco got his 8space tab on earlier, and it makes me feel dirty.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 06 Apr 2004 01:06:45 +0000 |
parents | 5af95c2b1179 |
children | f96795b786d2 |
rev | line source |
---|---|
5730 | 1 /** |
2 * @file trepia.c The Trepia protocol plugin | |
3 * | |
4 * gaim | |
5 * | |
6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
7 * |
5730 | 8 * This program is free software; you can redistribute it and/or modify |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5869
diff
changeset
|
22 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5869
diff
changeset
|
23 |
5730 | 24 #include "account.h" |
25 #include "accountopt.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5869
diff
changeset
|
26 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5869
diff
changeset
|
27 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5869
diff
changeset
|
28 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5869
diff
changeset
|
29 #include "server.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5869
diff
changeset
|
30 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5869
diff
changeset
|
31 |
5730 | 32 #include "md5.h" |
33 #include "profile.h" | |
34 | |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
35 /* XXX */ |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5869
diff
changeset
|
36 #include "gaim.h" |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
37 #include "multi.h" |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
38 |
5730 | 39 #ifndef _WIN32 |
40 # include <sys/socket.h> | |
41 # include <sys/ioctl.h> | |
42 # include <netinet/in.h> | |
43 # include <arpa/inet.h> | |
44 # include <net/if_arp.h> | |
45 #endif | |
46 | |
5950
e8316fec4fd1
[gaim-migrate @ 6394]
Christian Hammond <chipx86@chipx86.com>
parents:
5920
diff
changeset
|
47 #define TREPIA_VERSION "2.52" |
5863
98ec3e394f59
[gaim-migrate @ 6294]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
48 |
5988
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
49 #define TREPIA_CONNECT_STEPS 3 |
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
50 |
5730 | 51 static GaimPlugin *my_protocol = NULL; |
52 | |
53 typedef enum | |
54 { | |
55 TREPIA_LOGIN = 'C', | |
56 TREPIA_PROFILE_REQ = 'D', | |
57 TREPIA_MSG_OUTGOING = 'F', | |
58 TREPIA_REGISTER = 'J', | |
59 TREPIA_USER_LIST = 'L', | |
60 TREPIA_MEMBER_UPDATE = 'M', | |
61 TREPIA_MEMBER_OFFLINE = 'N', | |
62 TREPIA_MEMBER_PROFILE = 'O', | |
63 TREPIA_MSG_INCOMING = 'Q' | |
64 | |
65 } TrepiaMessageType; | |
66 | |
67 typedef struct | |
68 { | |
69 GaimConnection *gc; | |
70 | |
71 int fd; | |
72 | |
73 GString *rxqueue; | |
74 | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
75 GList *pending_users; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
76 GHashTable *user_profiles; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
77 GHashTable *user_ids; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
78 |
5730 | 79 } TrepiaSession; |
80 | |
81 typedef struct | |
82 { | |
83 TrepiaMessageType *type; | |
84 char *tag; | |
85 | |
86 GHashTable *keys; | |
87 | |
88 GString *buffer; | |
89 | |
90 } TrepiaParserData; | |
91 | |
92 #define TREPIA_SERVER "trepia.com" | |
93 #define TREPIA_PORT 8201 | |
94 #define TREPIA_REG_PORT 8209 | |
95 | |
5849
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
96 static const char alphabet[] = |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
97 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
98 "0123456789+/"; |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
99 |
5730 | 100 static int |
101 trepia_write(int fd, const char *data, size_t len) | |
102 { | |
103 gaim_debug(GAIM_DEBUG_MISC, "trepia", "C: %s%c", data, | |
104 (data[strlen(data) - 1] == '\n' ? '\0' : '\n')); | |
105 | |
106 return write(fd, data, len); | |
107 } | |
108 | |
5869
2f86cf55b0e9
[gaim-migrate @ 6301]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
109 #if 0 |
2f86cf55b0e9
[gaim-migrate @ 6301]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
110 static void |
2f86cf55b0e9
[gaim-migrate @ 6301]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
111 _remove_user_fnc(gpointer key, gpointer value, gpointer user_data) |
2f86cf55b0e9
[gaim-migrate @ 6301]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
112 { |
2f86cf55b0e9
[gaim-migrate @ 6301]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
113 TrepiaSession *session; |
2f86cf55b0e9
[gaim-migrate @ 6301]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
114 TrepiaProfile *profile; |
2f86cf55b0e9
[gaim-migrate @ 6301]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
115 const char *name; |
2f86cf55b0e9
[gaim-migrate @ 6301]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
116 |
2f86cf55b0e9
[gaim-migrate @ 6301]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
117 name = (const char *)key; |
2f86cf55b0e9
[gaim-migrate @ 6301]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
118 profile = (TrepiaProfile *)value; |
2f86cf55b0e9
[gaim-migrate @ 6301]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
119 session = (TrepiaSession *)user_data; |
2f86cf55b0e9
[gaim-migrate @ 6301]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
120 |
2f86cf55b0e9
[gaim-migrate @ 6301]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
121 gaim_blist_remove_buddy(profile->buddy); |
2f86cf55b0e9
[gaim-migrate @ 6301]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
122 } |
2f86cf55b0e9
[gaim-migrate @ 6301]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
123 #endif |
2f86cf55b0e9
[gaim-migrate @ 6301]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
124 |
5730 | 125 static void |
5789
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
126 __clear_user_list(TrepiaSession *session) |
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
127 { |
7382 | 128 GaimBlistNode *gnode, *cnode, *bnode; |
5855 | 129 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
7382 | 130 cnode = gnode->child; |
131 | |
132 while(cnode) { | |
133 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
134 bnode = cnode->child; | |
135 cnode = cnode->next; | |
136 while(bnode) { | |
137 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
138 if(GAIM_BLIST_NODE_IS_BUDDY(bnode) && | |
139 buddy->account == session->gc->account) { | |
140 bnode = bnode->next; | |
141 gaim_blist_remove_buddy(buddy); | |
142 } else { | |
143 bnode = bnode->next; | |
144 } | |
145 } | |
5855 | 146 } else { |
7382 | 147 cnode = cnode->next; |
5855 | 148 } |
149 } | |
150 } | |
5730 | 151 } |
152 | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
153 #if 0 |
5730 | 154 static char * |
155 __get_mac_address(const char *ip) | |
156 { | |
157 char *mac = NULL; | |
158 #ifndef _WIN32 | |
159 struct sockaddr_in sin = { 0 }; | |
160 struct arpreq myarp = { { 0 } }; | |
161 int sockfd; | |
162 unsigned char *ptr; | |
163 | |
164 sin.sin_family = AF_INET; | |
165 | |
166 if (inet_aton(ip, &sin.sin_addr) == 0) { | |
167 gaim_debug(GAIM_DEBUG_ERROR, "trepia", "Invalid IP address %s\n", ip); | |
168 return NULL; | |
169 } | |
170 | |
171 memcpy(&myarp.arp_pa, &sin, sizeof(myarp.arp_pa)); | |
172 strcpy(myarp.arp_dev, "eth0"); | |
173 | |
174 if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { | |
175 gaim_debug(GAIM_DEBUG_ERROR, "trepia", | |
176 "Cannot open socket for retrieving MAC address.\n"); | |
177 return NULL; | |
178 } | |
179 | |
180 if (ioctl(sockfd, SIOCGARP, &myarp) == -1) { | |
181 gaim_debug(GAIM_DEBUG_ERROR, "trepia", | |
182 "No entry in in arp_cache for %s\n", ip); | |
183 return NULL; | |
184 } | |
185 | |
186 ptr = &myarp.arp_ha.sa_data[0]; | |
187 | |
188 mac = g_strdup_printf("%x:%x:%x:%x:%x:%x", | |
189 ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]); | |
190 #else | |
191 #endif | |
192 | |
193 return mac; | |
194 } | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
195 #endif |
5730 | 196 |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
197 /************************************************************************** |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
198 * Callbacks |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
199 **************************************************************************/ |
5847
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
200 #define SET_STRING_FIELD(tag, id) \ |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
201 if ((value = gaim_request_fields_get_string(fields, (id))) != NULL) { \ |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
202 buf = g_strdup_printf("%s<%s>%s</%s>", temp, (tag), value, (tag)); \ |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
203 g_free(temp); \ |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
204 temp = buf; \ |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
205 } |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
206 |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
207 #define SET_INT_FIELD(tag, id) \ |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
208 int_val = gaim_request_fields_get_integer(fields, (id)); \ |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
209 buf = g_strdup_printf("%s<%s>%d</%s>", temp, (tag), int_val, (tag)); \ |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
210 g_free(temp); \ |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
211 temp = buf; |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
212 |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
213 static void |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
214 save_profile_cb(GaimConnection *gc, GaimRequestFields *fields) |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
215 { |
5848
8331918af110
[gaim-migrate @ 6279]
Christian Hammond <chipx86@chipx86.com>
parents:
5847
diff
changeset
|
216 TrepiaSession *session = gc->proto_data; |
5847
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
217 const char *value; |
5833
b1fc288ffcb4
[gaim-migrate @ 6264]
Christian Hammond <chipx86@chipx86.com>
parents:
5812
diff
changeset
|
218 char *buf, *temp; |
5847
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
219 int int_val; |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
220 |
5833
b1fc288ffcb4
[gaim-migrate @ 6264]
Christian Hammond <chipx86@chipx86.com>
parents:
5812
diff
changeset
|
221 buf = g_strdup("<K>"); |
b1fc288ffcb4
[gaim-migrate @ 6264]
Christian Hammond <chipx86@chipx86.com>
parents:
5812
diff
changeset
|
222 temp = buf; |
b1fc288ffcb4
[gaim-migrate @ 6264]
Christian Hammond <chipx86@chipx86.com>
parents:
5812
diff
changeset
|
223 |
5847
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
224 SET_STRING_FIELD("b", "email"); |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
225 SET_STRING_FIELD("c", "homepage"); |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
226 SET_STRING_FIELD("d", "firstname"); |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
227 SET_STRING_FIELD("e", "lastname"); |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
228 SET_STRING_FIELD("f", "icq"); |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
229 SET_STRING_FIELD("g", "aim"); |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
230 SET_STRING_FIELD("h", "msn"); |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
231 SET_STRING_FIELD("i", "yahoo"); |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
232 SET_INT_FIELD( "j", "age"); |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
233 |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
234 int_val = gaim_request_fields_get_choice(fields, "gender"); |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
235 |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
236 buf = g_strdup_printf("%s<k>%c</k>", temp, (int_val == 1 ? 'F' : 'M')); |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
237 g_free(temp); |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
238 temp = buf; |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
239 |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
240 SET_STRING_FIELD("l", "profile"); |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
241 SET_STRING_FIELD("n", "country"); |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
242 SET_STRING_FIELD("o", "state"); |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
243 SET_STRING_FIELD("p", "city"); |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
244 |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
245 buf = g_strdup_printf("%s</K>", temp); |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
246 |
5848
8331918af110
[gaim-migrate @ 6279]
Christian Hammond <chipx86@chipx86.com>
parents:
5847
diff
changeset
|
247 if (trepia_write(session->fd, buf, strlen(buf)) < 0) { |
8331918af110
[gaim-migrate @ 6279]
Christian Hammond <chipx86@chipx86.com>
parents:
5847
diff
changeset
|
248 gaim_connection_error(session->gc, _("Write error")); |
8331918af110
[gaim-migrate @ 6279]
Christian Hammond <chipx86@chipx86.com>
parents:
5847
diff
changeset
|
249 return; |
8331918af110
[gaim-migrate @ 6279]
Christian Hammond <chipx86@chipx86.com>
parents:
5847
diff
changeset
|
250 } |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
251 } |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
252 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
253 static void |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
254 set_profile(GaimConnection *gc) |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
255 { |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
256 GaimRequestFields *fields; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
257 GaimRequestFieldGroup *group; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
258 GaimRequestField *field; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
259 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
260 fields = gaim_request_fields_new(); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
261 |
5812
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
262 /* Basic Profile group. */ |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
263 group = gaim_request_field_group_new(_("Basic Profile")); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
264 gaim_request_fields_add_group(fields, group); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
265 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
266 /* First Name */ |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
267 field = gaim_request_field_string_new("firstname", _("First Name"), NULL, |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
268 FALSE); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
269 gaim_request_field_group_add_field(group, field); |
5847
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
270 gaim_debug(GAIM_DEBUG_MISC, "trepia", "feld type = %d\n", |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
271 field->type); |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
272 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
273 /* Last Name */ |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
274 field = gaim_request_field_string_new("lastname", _("Last Name"), NULL, |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
275 FALSE); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
276 gaim_request_field_group_add_field(group, field); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
277 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
278 /* Gender */ |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
279 field = gaim_request_field_choice_new("gender", _("Gender"), 0); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
280 gaim_request_field_choice_add(field, _("Male")); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
281 gaim_request_field_choice_add(field, _("Female")); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
282 gaim_request_field_group_add_field(group, field); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
283 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
284 /* Age */ |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
285 field = gaim_request_field_int_new("age", _("Age"), 0); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
286 gaim_request_field_group_add_field(group, field); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
287 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
288 /* Homepage */ |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
289 field = gaim_request_field_string_new("homepage", _("Homepage"), NULL, |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
290 FALSE); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
291 gaim_request_field_group_add_field(group, field); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
292 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
293 /* E-Mail Address */ |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
294 field = gaim_request_field_string_new("email", _("E-Mail Address"), NULL, |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
295 FALSE); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
296 gaim_request_field_group_add_field(group, field); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
297 |
5812
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
298 /* Profile String */ |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
299 field = gaim_request_field_string_new("profile", |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
300 _("Profile Information"), NULL, |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
301 TRUE); |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
302 gaim_request_field_group_add_field(group, field); |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
303 |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
304 |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
305 /* Instant Messagers */ |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
306 group = gaim_request_field_group_new(_("Instant Messagers")); |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
307 gaim_request_fields_add_group(fields, group); |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
308 |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
309 /* AIM */ |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
310 field = gaim_request_field_string_new("aim", _("AIM"), NULL, FALSE); |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
311 gaim_request_field_group_add_field(group, field); |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
312 |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
313 /* ICQ */ |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
314 field = gaim_request_field_string_new("icq", _("ICQ UIN"), NULL, FALSE); |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
315 gaim_request_field_group_add_field(group, field); |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
316 |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
317 /* MSN */ |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
318 field = gaim_request_field_string_new("msn", _("MSN"), NULL, FALSE); |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
319 gaim_request_field_group_add_field(group, field); |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
320 |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
321 /* Yahoo */ |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
322 field = gaim_request_field_string_new("yahoo", _("Yahoo"), NULL, FALSE); |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
323 gaim_request_field_group_add_field(group, field); |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
324 |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
325 |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
326 /* I'm From */ |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
327 group = gaim_request_field_group_new(_("I'm From")); |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
328 gaim_request_fields_add_group(fields, group); |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
329 |
5847
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
330 /* City */ |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
331 field = gaim_request_field_string_new("city", _("City"), NULL, FALSE); |
5812
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
332 gaim_request_field_group_add_field(group, field); |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
333 |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
334 /* State */ |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
335 field = gaim_request_field_string_new("state", _("State"), NULL, FALSE); |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
336 gaim_request_field_group_add_field(group, field); |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
337 |
5847
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
338 /* Country */ |
54513d0bfb83
[gaim-migrate @ 6278]
Christian Hammond <chipx86@chipx86.com>
parents:
5833
diff
changeset
|
339 field = gaim_request_field_string_new("country", _("Country"), NULL, FALSE); |
5812
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
340 gaim_request_field_group_add_field(group, field); |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
341 |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
342 |
ad28c689dc8e
[gaim-migrate @ 6242]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
343 /* Call the dialog. */ |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
344 gaim_request_fields(gc, NULL, _("Set your Trepia profile data."), |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
345 NULL, fields, |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
346 _("Save"), G_CALLBACK(save_profile_cb), |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
347 _("Cancel"), NULL, gc); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
348 } |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
349 |
5730 | 350 /************************************************************************** |
351 * Protocol Plugin ops | |
352 **************************************************************************/ | |
353 | |
354 static const char * | |
7382 | 355 trepia_list_icon(GaimAccount *a, GaimBuddy *b) |
5730 | 356 { |
357 return "trepia"; | |
358 } | |
359 | |
360 static void | |
7382 | 361 trepia_list_emblems(GaimBuddy *b, char **se, char **sw, |
5730 | 362 char **nw, char **ne) |
363 { | |
364 TrepiaProfile *profile = (TrepiaProfile *)b->proto_data; | |
365 | |
366 if (trepia_profile_get_sex(profile) == 'M') | |
367 *sw = "male"; | |
368 else if (trepia_profile_get_sex(profile)) | |
369 *sw = "female"; | |
370 } | |
371 | |
372 static char * | |
7382 | 373 trepia_status_text(GaimBuddy *b) |
5730 | 374 { |
5731
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
375 TrepiaProfile *profile = (TrepiaProfile *)b->proto_data; |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
376 const char *value; |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
377 char *text = NULL; |
5731
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
378 |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
379 if ((value = trepia_profile_get_profile(profile)) != NULL) |
5751
2951d2435196
[gaim-migrate @ 6176]
Christian Hammond <chipx86@chipx86.com>
parents:
5745
diff
changeset
|
380 text = g_markup_escape_text(value, -1); |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
381 |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
382 return text; |
5730 | 383 } |
384 | |
385 static char * | |
7382 | 386 trepia_tooltip_text(GaimBuddy *b) |
5730 | 387 { |
5731
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
388 TrepiaProfile *profile = (TrepiaProfile *)b->proto_data; |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
389 const char *value; |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
390 const char *first_name, *last_name; |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
391 int int_value; |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
392 char *text = NULL; |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
393 char *tmp, *tmp2; |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
394 |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
395 text = g_strdup(""); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
396 |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
397 first_name = trepia_profile_get_first_name(profile); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
398 last_name = trepia_profile_get_last_name(profile); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
399 |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
400 if (first_name != NULL || last_name != NULL) { |
6441 | 401 tmp = g_strdup_printf("<b>%s:</b> %s%s%s\n",_("Name"), |
5731
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
402 (first_name == NULL ? "" : first_name), |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
403 (first_name == NULL ? "" : " "), |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
404 (last_name == NULL ? "" : last_name)); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
405 |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
406 tmp2 = g_strconcat(text, tmp, NULL); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
407 g_free(tmp); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
408 g_free(text); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
409 text = tmp2; |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
410 } |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
411 |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
412 if ((int_value = trepia_profile_get_age(profile)) != 0) { |
6441 | 413 tmp = g_strdup_printf("<b>%s:</b> %d\n", _("Age"),int_value); |
5731
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
414 |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
415 tmp2 = g_strconcat(text, tmp, NULL); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
416 g_free(tmp); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
417 g_free(text); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
418 text = tmp2; |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
419 } |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
420 |
6441 | 421 tmp = g_strdup_printf("<b>%s:</b> %s\n",_("Gender"), |
422 (trepia_profile_get_sex(profile) == 'F' ? _("Female") : _("Male"))); | |
5731
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
423 |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
424 tmp2 = g_strconcat(text, tmp, NULL); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
425 g_free(tmp); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
426 g_free(text); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
427 text = tmp2; |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
428 |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
429 if ((value = trepia_profile_get_city(profile)) != NULL) { |
6441 | 430 tmp = g_strdup_printf("<b>%s:</b> %s\n", _("City"), value); |
5731
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
431 |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
432 tmp2 = g_strconcat(text, tmp, NULL); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
433 g_free(tmp); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
434 g_free(text); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
435 text = tmp2; |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
436 } |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
437 |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
438 if ((value = trepia_profile_get_state(profile)) != NULL) { |
6441 | 439 tmp = g_strdup_printf("<b>%s:</b> %s\n", _("State"), value); |
5731
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
440 |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
441 tmp2 = g_strconcat(text, tmp, NULL); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
442 g_free(tmp); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
443 g_free(text); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
444 text = tmp2; |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
445 } |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
446 |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
447 if ((value = trepia_profile_get_country(profile)) != NULL) { |
6441 | 448 tmp = g_strdup_printf("<b>%s:</b> %s\n", _("Country"), value); |
5731
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
449 |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
450 tmp2 = g_strconcat(text, tmp, NULL); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
451 g_free(tmp); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
452 g_free(text); |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
453 text = tmp2; |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
454 } |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
455 |
5999
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
456 if ((value = trepia_profile_get_homepage(profile)) != NULL) { |
6441 | 457 tmp = g_strdup_printf("<b>%s:</b> %s\n", _("Homepage"), value); |
5999
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
458 |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
459 tmp2 = g_strconcat(text, tmp, NULL); |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
460 g_free(tmp); |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
461 g_free(text); |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
462 text = tmp2; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
463 } |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
464 |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
465 if ((value = trepia_profile_get_profile(profile)) != NULL) { |
5751
2951d2435196
[gaim-migrate @ 6176]
Christian Hammond <chipx86@chipx86.com>
parents:
5745
diff
changeset
|
466 char *escaped_val = g_markup_escape_text(value, -1); |
2951d2435196
[gaim-migrate @ 6176]
Christian Hammond <chipx86@chipx86.com>
parents:
5745
diff
changeset
|
467 |
6441 | 468 tmp = g_strdup_printf("<b>%s:</b> %s\n", _("Profile"), escaped_val); |
5751
2951d2435196
[gaim-migrate @ 6176]
Christian Hammond <chipx86@chipx86.com>
parents:
5745
diff
changeset
|
469 |
2951d2435196
[gaim-migrate @ 6176]
Christian Hammond <chipx86@chipx86.com>
parents:
5745
diff
changeset
|
470 g_free(escaped_val); |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
471 |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
472 tmp2 = g_strconcat(text, tmp, NULL); |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
473 g_free(tmp); |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
474 g_free(text); |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
475 text = tmp2; |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
476 } |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
477 |
5732
37810936887e
[gaim-migrate @ 6156]
Christian Hammond <chipx86@chipx86.com>
parents:
5731
diff
changeset
|
478 text[strlen(text) - 1] = '\0'; |
5731
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
479 |
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
480 return text; |
5730 | 481 } |
482 | |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
483 static GList * |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
484 trepia_actions(GaimConnection *gc) |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
485 { |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
486 GList *m = NULL; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
487 struct proto_actions_menu *pam; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
488 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
489 pam = g_new0(struct proto_actions_menu, 1); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
490 pam->label = _("Set Profile"); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
491 pam->callback = set_profile; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
492 pam->gc = gc; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
493 m = g_list_append(m, pam); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
494 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
495 return m; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
496 } |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
497 |
5730 | 498 static void |
5999
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
499 trepia_visit_homepage(GaimConnection *gc, const char *who) |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
500 { |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
501 TrepiaProfile *profile; |
7382 | 502 GaimBuddy *b; |
5999
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
503 const char *value; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
504 |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
505 b = gaim_find_buddy(gaim_connection_get_account(gc), who); |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
506 profile = b->proto_data; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
507 |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
508 if ((value = trepia_profile_get_homepage(profile)) != NULL) |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
509 gaim_notify_uri(gc, value); |
5999
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
510 } |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
511 |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
512 static GList * |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
513 trepia_buddy_menu(GaimConnection *gc, const char *who) |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
514 { |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
515 TrepiaProfile *profile; |
7382 | 516 GaimBuddy *b; |
5999
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
517 const char *value = NULL; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
518 GList *m = NULL; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
519 struct proto_buddy_menu *pbm; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
520 |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
521 b = gaim_find_buddy(gaim_connection_get_account(gc), who); |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
522 profile = b->proto_data; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
523 |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
524 if ((value = trepia_profile_get_homepage(profile)) != NULL) { |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
525 pbm = g_new0(struct proto_buddy_menu, 1); |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
526 pbm->label = _("Visit Homepage"); |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
527 pbm->callback = trepia_visit_homepage; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
528 pbm->gc = gc; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
529 m = g_list_append(m, pbm); |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
530 } |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
531 |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
532 return m; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
533 } |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
534 |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
535 static void |
5730 | 536 __free_parser_data(gpointer user_data) |
537 { | |
5769
0f9b5737e5fe
[gaim-migrate @ 6194]
Christian Hammond <chipx86@chipx86.com>
parents:
5752
diff
changeset
|
538 #if 0 |
5730 | 539 TrepiaParserData *data = user_data; |
540 | |
541 if (data->buffer != NULL) | |
542 g_string_free(data->buffer, TRUE); | |
543 | |
544 if (data->tag != NULL) | |
545 g_free(data->tag); | |
546 | |
547 g_free(data); | |
5769
0f9b5737e5fe
[gaim-migrate @ 6194]
Christian Hammond <chipx86@chipx86.com>
parents:
5752
diff
changeset
|
548 #endif |
5730 | 549 } |
550 | |
551 static void | |
552 __start_element_handler(GMarkupParseContext *context, | |
553 const gchar *element_name, | |
554 const gchar **attribute_names, | |
555 const gchar **attribute_values, | |
556 gpointer user_data, GError **error) | |
557 { | |
558 TrepiaParserData *data = user_data; | |
559 | |
560 if (data->buffer != NULL) { | |
561 g_string_free(data->buffer, TRUE); | |
562 data->buffer = NULL; | |
563 } | |
564 | |
565 if (*data->type == 0) { | |
566 *data->type = *element_name; | |
567 } | |
568 else { | |
6061 | 569 data->tag = g_strdup(element_name); /* XXX - Make sure this is freed */ |
5730 | 570 } |
571 } | |
572 | |
573 static void | |
574 __end_element_handler(GMarkupParseContext *context, const gchar *element_name, | |
575 gpointer user_data, GError **error) | |
576 { | |
577 TrepiaParserData *data = user_data; | |
578 gchar *buffer; | |
579 | |
580 if (*element_name == *data->type) | |
581 return; | |
582 | |
583 if (data->buffer == NULL || data->tag == NULL) { | |
584 data->tag = NULL; | |
585 return; | |
586 } | |
587 | |
588 buffer = g_string_free(data->buffer, FALSE); | |
589 data->buffer = NULL; | |
590 | |
5999
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
591 if (buffer != NULL) { |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
592 if (*buffer != '\0') |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
593 g_hash_table_insert(data->keys, data->tag, buffer); |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
594 else |
7606 | 595 g_free(buffer); |
5999
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
596 } |
5730 | 597 |
598 data->tag = NULL; | |
599 } | |
600 | |
601 static void | |
602 __text_handler(GMarkupParseContext *context, const gchar *text, | |
603 gsize text_len, gpointer user_data, GError **error) | |
604 { | |
605 TrepiaParserData *data = user_data; | |
606 | |
607 if (data->buffer == NULL) | |
608 data->buffer = g_string_new_len(text, text_len); | |
609 else | |
610 g_string_append_len(data->buffer, text, text_len); | |
611 } | |
612 | |
613 static GMarkupParser accounts_parser = | |
614 { | |
615 __start_element_handler, | |
616 __end_element_handler, | |
617 __text_handler, | |
618 NULL, | |
619 NULL | |
620 }; | |
621 | |
622 static int | |
623 __parse_message(const char *buf, TrepiaMessageType *type, GHashTable **info) | |
624 { | |
625 TrepiaParserData *parser_data = g_new0(TrepiaParserData, 1); | |
626 GMarkupParseContext *context; | |
627 GHashTable *keys; | |
628 | |
629 keys = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
630 parser_data->keys = keys; | |
631 parser_data->type = type; | |
632 | |
633 context = g_markup_parse_context_new(&accounts_parser, 0, | |
634 parser_data, __free_parser_data); | |
635 | |
636 if (!g_markup_parse_context_parse(context, buf, strlen(buf), NULL)) { | |
637 g_markup_parse_context_free(context); | |
638 g_free(parser_data); | |
639 g_hash_table_destroy(keys); | |
640 | |
641 return 1; | |
642 } | |
643 | |
644 if (!g_markup_parse_context_end_parse(context, NULL)) { | |
645 g_markup_parse_context_free(context); | |
646 g_free(parser_data); | |
647 g_hash_table_destroy(keys); | |
648 | |
649 return 1; | |
650 } | |
651 | |
652 g_markup_parse_context_free(context); | |
6061 | 653 g_free(parser_data); |
5730 | 654 *info = keys; |
655 | |
656 return 0; | |
657 } | |
658 | |
659 static gboolean | |
6087 | 660 _parse_data(TrepiaSession *session, char *buf) |
5730 | 661 { |
662 GHashTable *info; | |
663 GaimAccount *account; | |
664 TrepiaMessageType type = 0; | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
665 TrepiaProfile *profile = NULL; |
5730 | 666 int ret; |
667 char *buffer; | |
7382 | 668 GaimBuddy *b; |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
669 int id = 0; |
5730 | 670 const char *value; |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
671 char *username; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
672 int *int_p; |
5990
99fbd0161cb7
[gaim-migrate @ 6438]
Christian Hammond <chipx86@chipx86.com>
parents:
5988
diff
changeset
|
673 GMainContext *ctx; |
5730 | 674 |
675 account = gaim_connection_get_account(session->gc); | |
676 | |
677 ret = __parse_message(buf, &type, &info); | |
678 | |
679 if (ret == 1) | |
680 return TRUE; | |
681 | |
682 if (info != NULL) { | |
683 switch (type) { | |
684 case TREPIA_USER_LIST: | |
5988
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
685 gaim_connection_update_progress(session->gc, |
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
686 _("Retrieving buddy list"), 2, TREPIA_CONNECT_STEPS); |
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
687 |
5730 | 688 gaim_connection_set_state(session->gc, GAIM_CONNECTED); |
689 serv_finish_login(session->gc); | |
690 break; | |
691 | |
692 case TREPIA_MSG_INCOMING: /* Incoming Message */ | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
693 id = atoi(g_hash_table_lookup(info, "a")); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
694 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
695 profile = g_hash_table_lookup(session->user_profiles, &id); |
5730 | 696 serv_got_im(session->gc, |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
697 trepia_profile_get_login(profile), |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
698 (char *)g_hash_table_lookup(info, "b"), |
6982 | 699 0, time(NULL)); |
5730 | 700 break; |
701 | |
702 case TREPIA_MEMBER_UPDATE: | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
703 profile = trepia_profile_new(); |
5730 | 704 |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
705 if ((value = g_hash_table_lookup(info, "a")) != NULL) { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
706 id = atoi(value); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
707 trepia_profile_set_id(profile, id); |
5730 | 708 } |
709 | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
710 if ((value = g_hash_table_lookup(info, "b")) != NULL) |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
711 trepia_profile_set_login_time(profile, atoi(value)); |
5730 | 712 |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
713 if ((value = g_hash_table_lookup(info, "c")) != NULL) |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
714 trepia_profile_set_type(profile, atoi(value)); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
715 else |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
716 trepia_profile_set_type(profile, 2); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
717 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
718 session->pending_users = g_list_append(session->pending_users, |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
719 profile); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
720 |
5730 | 721 |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
722 #if 0 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
723 if (trepia_profile_get_type(profile) == 1) { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
724 buffer = g_strdup_printf( |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
725 "<D>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
726 "<a>%d</a>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
727 "<b>1</b>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
728 "</D>", |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
729 id); |
5730 | 730 } |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
731 else { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
732 #endif |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
733 buffer = g_strdup_printf( |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
734 "<D>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
735 "<a>%d</a>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
736 "<b>1</b>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
737 "</D>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
738 "<D>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
739 "<a>%d</a>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
740 "<b>2</b>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
741 "</D>", |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
742 id, |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
743 id); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
744 #if 0 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
745 } |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
746 #endif |
5730 | 747 |
748 if (trepia_write(session->fd, buffer, strlen(buffer)) < 0) { | |
749 gaim_connection_error(session->gc, _("Write error")); | |
750 g_free(buffer); | |
751 return 1; | |
752 } | |
753 | |
754 g_free(buffer); | |
755 break; | |
756 | |
757 case TREPIA_MEMBER_PROFILE: | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
758 if ((value = g_hash_table_lookup(info, "a")) != NULL) { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
759 GList *l; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
760 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
761 id = atoi(value); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
762 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
763 for (l = session->pending_users; l != NULL; l = l->next) { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
764 profile = l->data; |
5730 | 765 |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
766 if (trepia_profile_get_id(profile) == id) |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
767 break; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
768 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
769 profile = NULL; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
770 } |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
771 } |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
772 else |
5730 | 773 break; |
774 | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
775 if (profile == NULL) { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
776 profile = g_hash_table_lookup(session->user_profiles, &id); |
5730 | 777 |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
778 if (profile == NULL) |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
779 break; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
780 } |
5730 | 781 |
782 /* Age */ | |
783 if ((value = g_hash_table_lookup(info, "m")) != NULL) | |
784 trepia_profile_set_age(profile, atoi(value)); | |
785 | |
786 /* ICQ */ | |
787 if ((value = g_hash_table_lookup(info, "i")) != NULL) | |
788 trepia_profile_set_icq(profile, atoi(value)); | |
789 | |
790 /* Sex */ | |
791 if ((value = g_hash_table_lookup(info, "n")) != NULL) | |
792 trepia_profile_set_sex(profile, *value); | |
793 | |
794 /* Location */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
795 if ((value = g_hash_table_lookup(info, "p")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
796 trepia_profile_set_location(profile, value); |
5730 | 797 |
798 /* First Name */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
799 if ((value = g_hash_table_lookup(info, "g")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
800 trepia_profile_set_first_name(profile, value); |
5730 | 801 |
802 /* Last Name */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
803 if ((value = g_hash_table_lookup(info, "h")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
804 trepia_profile_set_last_name(profile, value); |
5730 | 805 |
806 /* Profile */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
807 if ((value = g_hash_table_lookup(info, "o")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
808 trepia_profile_set_profile(profile, value); |
5730 | 809 |
810 /* E-mail */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
811 if ((value = g_hash_table_lookup(info, "e")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
812 trepia_profile_set_email(profile, value); |
5730 | 813 |
814 /* AIM */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
815 if ((value = g_hash_table_lookup(info, "j")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
816 trepia_profile_set_aim(profile, value); |
5730 | 817 |
818 /* MSN */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
819 if ((value = g_hash_table_lookup(info, "k")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
820 trepia_profile_set_msn(profile, value); |
5730 | 821 |
822 /* Yahoo */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
823 if ((value = g_hash_table_lookup(info, "l")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
824 trepia_profile_set_yahoo(profile, value); |
5730 | 825 |
826 /* Homepage */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
827 if ((value = g_hash_table_lookup(info, "f")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
828 trepia_profile_set_homepage(profile, value); |
5730 | 829 |
830 /* Country */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
831 if ((value = g_hash_table_lookup(info, "r")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
832 trepia_profile_set_country(profile, value); |
5730 | 833 |
834 /* State */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
835 if ((value = g_hash_table_lookup(info, "s")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
836 trepia_profile_set_state(profile, value); |
5730 | 837 |
838 /* City */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
839 if ((value = g_hash_table_lookup(info, "t")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
840 trepia_profile_set_city(profile, value); |
5730 | 841 |
842 /* Languages */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
843 if ((value = g_hash_table_lookup(info, "u")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
844 trepia_profile_set_languages(profile, value); |
5730 | 845 |
846 /* School */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
847 if ((value = g_hash_table_lookup(info, "v")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
848 trepia_profile_set_school(profile, value); |
5730 | 849 |
850 /* Company */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
851 if ((value = g_hash_table_lookup(info, "w")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
852 trepia_profile_set_company(profile, value); |
5730 | 853 |
854 /* Login Name */ | |
855 if ((value = g_hash_table_lookup(info, "d")) != NULL) { | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
856 trepia_profile_set_login(profile, value); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
857 username = g_strdup(value); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
858 } |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
859 else if ((value = trepia_profile_get_login(profile)) != NULL) { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
860 username = g_strdup(value); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
861 } |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
862 else { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
863 username = g_strdup_printf("%d", id); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
864 trepia_profile_set_login(profile, username); |
5730 | 865 } |
866 | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
867 b = gaim_find_buddy(account, username); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
868 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
869 if (b == NULL) { |
7382 | 870 GaimGroup *g; |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
871 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
872 g = gaim_find_group(_("Local Users")); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
873 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
874 if (g == NULL) { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
875 g = gaim_group_new(_("Local Users")); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
876 gaim_blist_add_group(g, NULL); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
877 } |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
878 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
879 b = gaim_buddy_new(account, username, NULL); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
880 |
7382 | 881 gaim_blist_add_buddy(b, NULL, g, NULL); |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
882 } |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
883 |
5789
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
884 profile->buddy = b; |
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
885 |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
886 b->proto_data = profile; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
887 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
888 session->pending_users = g_list_remove(session->pending_users, |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
889 profile); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
890 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
891 int_p = g_new0(int, 1); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
892 *int_p = id; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
893 g_hash_table_insert(session->user_profiles, int_p, profile); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
894 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
895 serv_got_update(session->gc, |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
896 username, 1, 0, |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
897 trepia_profile_get_login_time(profile), 0, 0); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
898 |
5730 | 899 /* Buddy Icon */ |
900 if ((value = g_hash_table_lookup(info, "q")) != NULL) { | |
901 char *icon; | |
902 int icon_len; | |
903 | |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
904 gaim_base64_decode(value, &icon, &icon_len); |
5730 | 905 |
7382 | 906 gaim_buddy_icons_set_for_user(session->gc->account, |
907 username, icon, icon_len); | |
5730 | 908 |
909 g_free(icon); | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
910 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
911 serv_got_update(session->gc, username, 1, 0, 0, 0, 0); |
5730 | 912 } |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
913 |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8170
diff
changeset
|
914 /* |
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8170
diff
changeset
|
915 * XXX |
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8170
diff
changeset
|
916 * This does nothing when using a non-gtk event loop. |
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8170
diff
changeset
|
917 * What is it supposed to accomplish anyway? |
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8170
diff
changeset
|
918 */ |
5990
99fbd0161cb7
[gaim-migrate @ 6438]
Christian Hammond <chipx86@chipx86.com>
parents:
5988
diff
changeset
|
919 ctx = g_main_context_default(); |
99fbd0161cb7
[gaim-migrate @ 6438]
Christian Hammond <chipx86@chipx86.com>
parents:
5988
diff
changeset
|
920 |
99fbd0161cb7
[gaim-migrate @ 6438]
Christian Hammond <chipx86@chipx86.com>
parents:
5988
diff
changeset
|
921 while (g_main_context_pending(ctx)) |
99fbd0161cb7
[gaim-migrate @ 6438]
Christian Hammond <chipx86@chipx86.com>
parents:
5988
diff
changeset
|
922 g_main_context_iteration(ctx, FALSE); |
99fbd0161cb7
[gaim-migrate @ 6438]
Christian Hammond <chipx86@chipx86.com>
parents:
5988
diff
changeset
|
923 |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
924 g_free(username); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
925 |
5730 | 926 break; |
927 | |
928 case TREPIA_MEMBER_OFFLINE: | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
929 if ((value = g_hash_table_lookup(info, "a")) != NULL) |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
930 id = atoi(value); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
931 else |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
932 break; |
5730 | 933 |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
934 profile = g_hash_table_lookup(session->user_profiles, &id); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
935 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
936 if (profile == NULL) |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
937 break; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
938 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
939 g_hash_table_remove(session->user_profiles, &id); |
5789
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
940 |
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
941 b = profile->buddy; |
5730 | 942 |
943 if (b != NULL) | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
944 serv_got_update(session->gc, |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
945 trepia_profile_get_login(profile), |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
946 0, 0, 0, 0, 0); |
5730 | 947 |
948 gaim_blist_remove_buddy(b); | |
949 | |
950 break; | |
951 | |
952 default: | |
953 break; | |
954 } | |
955 | |
956 g_hash_table_destroy(info); | |
957 } | |
958 else { | |
959 gaim_debug(GAIM_DEBUG_WARNING, "trepia", | |
960 "Unknown data received. Possibly an image?\n"); | |
961 } | |
962 | |
963 return TRUE; | |
964 } | |
965 | |
966 static void | |
6087 | 967 _data_cb(gpointer data, gint source, GaimInputCondition cond) |
5730 | 968 { |
969 TrepiaSession *session = data; | |
970 int i = 0; | |
971 char buf[1025]; | |
972 gboolean cont = TRUE; | |
973 | |
974 i = read(session->fd, buf, 1024); | |
975 | |
976 if (i <= 0) { | |
977 gaim_connection_error(session->gc, _("Read error")); | |
978 return; | |
979 } | |
980 | |
981 buf[i] = '\0'; | |
982 | |
983 if (session->rxqueue == NULL) | |
984 session->rxqueue = g_string_new(buf); | |
985 else | |
986 g_string_append(session->rxqueue, buf); | |
987 | |
988 while (cont) { | |
989 char end_tag[5] = "</ >"; | |
990 char *end_s; | |
991 | |
992 end_tag[2] = session->rxqueue->str[1]; | |
993 | |
994 end_s = strstr(session->rxqueue->str, end_tag); | |
995 | |
996 if (end_s != NULL) { | |
997 char *buffer; | |
998 size_t len; | |
999 int ret; | |
1000 | |
1001 end_s += 4; | |
1002 | |
1003 len = end_s - session->rxqueue->str; | |
1004 buffer = g_new0(char, len + 1); | |
1005 strncpy(buffer, session->rxqueue->str, len); | |
1006 | |
1007 g_string_erase(session->rxqueue, 0, len); | |
1008 | |
1009 if (*session->rxqueue->str == '\n') | |
1010 g_string_erase(session->rxqueue, 0, 1); | |
1011 | |
1012 gaim_debug(GAIM_DEBUG_MISC, "trepia", "S: %s\n", buffer); | |
1013 | |
6087 | 1014 ret = _parse_data(session, buffer); |
5730 | 1015 |
1016 g_free(buffer); | |
1017 } | |
1018 else | |
1019 break; | |
1020 } | |
1021 } | |
1022 | |
1023 static void | |
1024 __login_cb(gpointer data, gint source, GaimInputCondition cond) | |
1025 { | |
1026 TrepiaSession *session = data; | |
1027 GaimAccount *account; | |
1028 const char *password; | |
1029 char *buffer; | |
5833
b1fc288ffcb4
[gaim-migrate @ 6264]
Christian Hammond <chipx86@chipx86.com>
parents:
5812
diff
changeset
|
1030 char *mac = "00:01:02:03:04:05"; |
5730 | 1031 char buf[3]; |
1032 char md5_password[17]; | |
1033 md5_state_t st; | |
1034 md5_byte_t di[16]; | |
1035 int i; | |
1036 | |
1037 if (source < 0) { | |
1038 gaim_connection_error(session->gc, _("Write error")); | |
1039 return; | |
1040 } | |
1041 | |
5833
b1fc288ffcb4
[gaim-migrate @ 6264]
Christian Hammond <chipx86@chipx86.com>
parents:
5812
diff
changeset
|
1042 #if 0 |
b1fc288ffcb4
[gaim-migrate @ 6264]
Christian Hammond <chipx86@chipx86.com>
parents:
5812
diff
changeset
|
1043 mac = __get_mac_address(); |
b1fc288ffcb4
[gaim-migrate @ 6264]
Christian Hammond <chipx86@chipx86.com>
parents:
5812
diff
changeset
|
1044 #endif |
b1fc288ffcb4
[gaim-migrate @ 6264]
Christian Hammond <chipx86@chipx86.com>
parents:
5812
diff
changeset
|
1045 |
5730 | 1046 session->fd = source; |
1047 | |
1048 account = gaim_connection_get_account(session->gc); | |
1049 | |
1050 password = gaim_account_get_password(account); | |
1051 | |
1052 md5_init(&st); | |
1053 md5_append(&st, (const md5_byte_t *)password, strlen(password)); | |
1054 md5_finish(&st, di); | |
1055 | |
1056 *md5_password = '\0'; | |
1057 | |
1058 for (i = 0; i < 16; i++) { | |
1059 g_snprintf(buf, sizeof(buf), "%02x", di[i]); | |
1060 strcat(md5_password, buf); | |
1061 } | |
1062 | |
1063 buffer = g_strdup_printf( | |
1064 "<C>\n" | |
1065 "<a>%s</a>\n" | |
5833
b1fc288ffcb4
[gaim-migrate @ 6264]
Christian Hammond <chipx86@chipx86.com>
parents:
5812
diff
changeset
|
1066 "<b1></b1>\n" |
5730 | 1067 "<c>%s</c>\n" |
1068 "<d>%s</d>\n" | |
5952 | 1069 "<e>%s</e>\n" |
5730 | 1070 "</C>", |
5833
b1fc288ffcb4
[gaim-migrate @ 6264]
Christian Hammond <chipx86@chipx86.com>
parents:
5812
diff
changeset
|
1071 mac, gaim_account_get_username(account), |
5950
e8316fec4fd1
[gaim-migrate @ 6394]
Christian Hammond <chipx86@chipx86.com>
parents:
5920
diff
changeset
|
1072 md5_password, TREPIA_VERSION); |
5730 | 1073 |
5863
98ec3e394f59
[gaim-migrate @ 6294]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
1074 #if 0 |
5730 | 1075 g_free(mac); |
5863
98ec3e394f59
[gaim-migrate @ 6294]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
1076 #endif |
5730 | 1077 |
5988
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
1078 gaim_connection_update_progress(session->gc, _("Logging in"), 1, |
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
1079 TREPIA_CONNECT_STEPS); |
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
1080 |
5730 | 1081 if (trepia_write(session->fd, buffer, strlen(buffer)) < 0) { |
1082 gaim_connection_error(session->gc, _("Write error")); | |
1083 return; | |
1084 } | |
1085 | |
1086 g_free(buffer); | |
1087 | |
1088 session->gc->inpa = gaim_input_add(session->fd, GAIM_INPUT_READ, | |
6087 | 1089 _data_cb, session); |
5730 | 1090 } |
1091 | |
1092 static void | |
1093 trepia_login(GaimAccount *account) | |
1094 { | |
1095 GaimConnection *gc; | |
1096 TrepiaSession *session; | |
1097 const char *server; | |
1098 int port; | |
1099 int i; | |
1100 | |
1101 server = gaim_account_get_string(account, "server", TREPIA_SERVER); | |
1102 port = gaim_account_get_int(account, "port", TREPIA_PORT); | |
1103 | |
1104 gc = gaim_account_get_connection(account); | |
1105 | |
1106 session = g_new0(TrepiaSession, 1); | |
1107 gc->proto_data = session; | |
1108 session->gc = gc; | |
1109 session->fd = -1; | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1110 session->user_profiles = g_hash_table_new_full(g_int_hash, g_int_equal, |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1111 g_free, NULL); |
5730 | 1112 |
5789
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
1113 __clear_user_list(session); |
5730 | 1114 |
5988
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
1115 gaim_connection_update_progress(gc, _("Connecting"), 0, |
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
1116 TREPIA_CONNECT_STEPS); |
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
1117 |
5730 | 1118 i = gaim_proxy_connect(account, server, port, __login_cb, session); |
1119 | |
1120 if (i != 0) | |
1121 gaim_connection_error(gc, _("Unable to create socket")); | |
1122 } | |
1123 | |
1124 static void | |
1125 trepia_close(GaimConnection *gc) | |
1126 { | |
5745
cae58ab49118
[gaim-migrate @ 6169]
Christian Hammond <chipx86@chipx86.com>
parents:
5739
diff
changeset
|
1127 TrepiaSession *session = gc->proto_data; |
cae58ab49118
[gaim-migrate @ 6169]
Christian Hammond <chipx86@chipx86.com>
parents:
5739
diff
changeset
|
1128 |
cae58ab49118
[gaim-migrate @ 6169]
Christian Hammond <chipx86@chipx86.com>
parents:
5739
diff
changeset
|
1129 if (session->rxqueue != NULL) |
cae58ab49118
[gaim-migrate @ 6169]
Christian Hammond <chipx86@chipx86.com>
parents:
5739
diff
changeset
|
1130 g_string_free(session->rxqueue, TRUE); |
cae58ab49118
[gaim-migrate @ 6169]
Christian Hammond <chipx86@chipx86.com>
parents:
5739
diff
changeset
|
1131 |
5789
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
1132 if (session->gc->inpa) |
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
1133 gaim_input_remove(session->gc->inpa); |
5745
cae58ab49118
[gaim-migrate @ 6169]
Christian Hammond <chipx86@chipx86.com>
parents:
5739
diff
changeset
|
1134 |
5789
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
1135 gaim_debug(GAIM_DEBUG_INFO, "trepia", "Destroying user_profiles\n"); |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1136 g_hash_table_destroy(session->user_profiles); |
5789
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
1137 gaim_debug(GAIM_DEBUG_INFO, "trepia", "Destroying pending_users\n"); |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1138 g_list_free(session->pending_users); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1139 |
5789
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
1140 gaim_debug(GAIM_DEBUG_INFO, "trepia", "Closing socket\n"); |
5745
cae58ab49118
[gaim-migrate @ 6169]
Christian Hammond <chipx86@chipx86.com>
parents:
5739
diff
changeset
|
1141 close(session->fd); |
cae58ab49118
[gaim-migrate @ 6169]
Christian Hammond <chipx86@chipx86.com>
parents:
5739
diff
changeset
|
1142 |
cae58ab49118
[gaim-migrate @ 6169]
Christian Hammond <chipx86@chipx86.com>
parents:
5739
diff
changeset
|
1143 g_free(session); |
5739
edf4d443e671
[gaim-migrate @ 6163]
Christian Hammond <chipx86@chipx86.com>
parents:
5737
diff
changeset
|
1144 |
5730 | 1145 gc->proto_data = NULL; |
5789
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
1146 gaim_debug(GAIM_DEBUG_INFO, "trepia", "Leaving trepia_close\n"); |
5730 | 1147 } |
1148 | |
1149 static int | |
1150 trepia_send_im(GaimConnection *gc, const char *who, const char *message, | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
1151 GaimConvImFlags flags) |
5730 | 1152 { |
1153 TrepiaSession *session = gc->proto_data; | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1154 TrepiaProfile *profile; |
7382 | 1155 GaimBuddy *b; |
5737
72ced7411599
[gaim-migrate @ 6161]
Christian Hammond <chipx86@chipx86.com>
parents:
5736
diff
changeset
|
1156 char *escaped_msg; |
5730 | 1157 char *buffer; |
1158 | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1159 b = gaim_find_buddy(gaim_connection_get_account(gc), who); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1160 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1161 if (b == NULL) { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1162 gaim_debug(GAIM_DEBUG_ERROR, "trepia", |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1163 "Unable to send to buddy not on your list!\n"); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1164 return 0; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1165 } |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1166 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1167 profile = b->proto_data; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1168 |
5737
72ced7411599
[gaim-migrate @ 6161]
Christian Hammond <chipx86@chipx86.com>
parents:
5736
diff
changeset
|
1169 escaped_msg = g_markup_escape_text(message, -1); |
72ced7411599
[gaim-migrate @ 6161]
Christian Hammond <chipx86@chipx86.com>
parents:
5736
diff
changeset
|
1170 |
5730 | 1171 buffer = g_strdup_printf( |
1172 "<F>\n" | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1173 "<a>%d</a>\n" |
5730 | 1174 "<b>%s</b>\n" |
1175 "</F>", | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1176 trepia_profile_get_id(profile), escaped_msg); |
5737
72ced7411599
[gaim-migrate @ 6161]
Christian Hammond <chipx86@chipx86.com>
parents:
5736
diff
changeset
|
1177 |
72ced7411599
[gaim-migrate @ 6161]
Christian Hammond <chipx86@chipx86.com>
parents:
5736
diff
changeset
|
1178 g_free(escaped_msg); |
5730 | 1179 |
1180 if (trepia_write(session->fd, buffer, strlen(buffer)) < 0) { | |
1181 gaim_connection_error(gc, _("Write error")); | |
1182 g_free(buffer); | |
1183 return 1; | |
1184 } | |
1185 | |
1186 return 1; | |
1187 } | |
1188 | |
1189 static void | |
6787
faa491042c66
[gaim-migrate @ 7326]
Christian Hammond <chipx86@chipx86.com>
parents:
6622
diff
changeset
|
1190 trepia_add_buddy(GaimConnection *gc, const char *name, GaimGroup *group) |
5730 | 1191 { |
1192 } | |
1193 | |
1194 static void | |
6059 | 1195 trepia_rem_buddy(GaimConnection *gc, const char *who, const char *group) |
5730 | 1196 { |
1197 } | |
1198 | |
1199 static void | |
7382 | 1200 trepia_buddy_free(GaimBuddy *b) |
5730 | 1201 { |
1202 if (b->proto_data != NULL) { | |
1203 trepia_profile_destroy(b->proto_data); | |
1204 | |
1205 b->proto_data = NULL; | |
1206 } | |
1207 } | |
1208 | |
1209 static void | |
5849
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1210 trepia_set_buddy_icon(GaimConnection *gc, const char *filename) |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1211 { |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1212 TrepiaSession *session = gc->proto_data; |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1213 struct stat sb; |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1214 |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1215 if (!stat(filename, &sb)) { |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1216 FILE *fp; |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1217 |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1218 if ((fp = fopen(filename, "rb")) != NULL) { |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1219 char *buf = g_malloc(sb.st_size + 1); |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1220 char *temp; |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1221 char *out_buf; |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1222 |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1223 fread(buf, 1, sb.st_size, fp); |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1224 |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1225 buf[sb.st_size] = '\0'; |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1226 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1227 temp = gaim_base64_encode(buf, sb.st_size); |
5849
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1228 |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1229 out_buf = g_strdup_printf("<K><m>%s</m></K>", temp); |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1230 |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1231 g_free(temp); |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1232 g_free(buf); |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1233 |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1234 fclose(fp); |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1235 |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1236 if (trepia_write(session->fd, out_buf, strlen(out_buf)) < 0) { |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1237 gaim_connection_error(session->gc, _("Write error")); |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1238 return; |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1239 } |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1240 } |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1241 } |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1242 } |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1243 |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1244 static void |
5730 | 1245 trepia_register_user(GaimAccount *account) |
1246 { | |
1247 char *buffer; | |
5863
98ec3e394f59
[gaim-migrate @ 6294]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
1248 char *mac = "00:01:02:03:04:05"; |
5730 | 1249 |
1250 buffer = g_strdup_printf( | |
5863
98ec3e394f59
[gaim-migrate @ 6294]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
1251 "<J><a>%s</a><b1>%s</b1><c>%s</c><d>%s</d><e>%s</e>" |
98ec3e394f59
[gaim-migrate @ 6294]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
1252 "<f></f><g></g><h></h><i></i><j></j><k></k><l></l>" |
98ec3e394f59
[gaim-migrate @ 6294]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
1253 "<m></m></J>", |
98ec3e394f59
[gaim-migrate @ 6294]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
1254 mac, "", TREPIA_VERSION, gaim_account_get_username(account), |
98ec3e394f59
[gaim-migrate @ 6294]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
1255 gaim_account_get_password(account)); |
5730 | 1256 } |
1257 | |
1258 static GaimPluginProtocolInfo prpl_info = | |
1259 { | |
1260 OPT_PROTO_BUDDY_ICON, | |
1261 NULL, | |
1262 NULL, | |
8170 | 1263 NULL, |
5730 | 1264 trepia_list_icon, |
1265 trepia_list_emblems, | |
5731
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
1266 trepia_status_text, |
5730 | 1267 trepia_tooltip_text, |
1268 NULL, | |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
1269 trepia_actions, |
5999
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
1270 trepia_buddy_menu, |
5730 | 1271 NULL, |
1272 trepia_login, | |
1273 trepia_close, | |
1274 trepia_send_im, | |
1275 NULL, | |
1276 NULL, | |
1277 NULL, | |
1278 NULL, | |
1279 NULL, | |
1280 NULL, | |
1281 NULL, | |
1282 NULL, | |
1283 NULL, | |
1284 trepia_add_buddy, | |
1285 NULL, | |
1286 trepia_rem_buddy, | |
1287 NULL, | |
1288 NULL, | |
1289 NULL, | |
1290 NULL, | |
1291 NULL, | |
1292 NULL, | |
1293 NULL, | |
1294 NULL, | |
1295 NULL, | |
1296 NULL, | |
1297 NULL, | |
1298 NULL, | |
1299 NULL, | |
8562 | 1300 NULL, |
5730 | 1301 trepia_register_user, |
1302 NULL, | |
1303 NULL, | |
1304 NULL, | |
1305 NULL, | |
1306 NULL, | |
1307 trepia_buddy_free, | |
1308 NULL, | |
5849
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1309 NULL, |
8586 | 1310 trepia_set_buddy_icon, |
8589 | 1311 NULL, |
1312 NULL, | |
1313 NULL, | |
1314 NULL, | |
1315 NULL, | |
1316 NULL, | |
1317 NULL, | |
1318 NULL | |
5730 | 1319 }; |
1320 | |
1321 static GaimPluginInfo info = | |
1322 { | |
1323 2, /**< api_version */ | |
1324 GAIM_PLUGIN_PROTOCOL, /**< type */ | |
1325 NULL, /**< ui_requirement */ | |
1326 0, /**< flags */ | |
1327 NULL, /**< dependencies */ | |
1328 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
1329 | |
1330 "prpl-trepia", /**< id */ | |
1331 "Trepia", /**< name */ | |
1332 VERSION, /**< version */ | |
1333 /** summary */ | |
1334 N_("Trepia Protocol Plugin"), | |
1335 /** description */ | |
1336 N_("Trepia Protocol Plugin"), | |
1337 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6087
diff
changeset
|
1338 GAIM_WEBSITE, /**< homepage */ |
5730 | 1339 |
1340 NULL, /**< load */ | |
1341 NULL, /**< unload */ | |
1342 NULL, /**< destroy */ | |
1343 | |
1344 NULL, /**< ui_info */ | |
1345 &prpl_info /**< extra_info */ | |
1346 }; | |
1347 | |
1348 static void | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1349 init_plugin(GaimPlugin *plugin) |
5730 | 1350 { |
1351 GaimAccountOption *option; | |
1352 | |
1353 option = gaim_account_option_string_new(_("Login server"), "server", | |
1354 TREPIA_SERVER); | |
1355 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
1356 option); | |
1357 | |
1358 option = gaim_account_option_int_new(_("Port"), "port", TREPIA_PORT); | |
1359 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
1360 option); | |
1361 | |
1362 my_protocol = plugin; | |
1363 } | |
1364 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1365 GAIM_INIT_PLUGIN(trepia, init_plugin, info); |