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