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