Mercurial > pidgin
annotate src/protocols/trepia/trepia.c @ 8950:80b4c956d7ae
[gaim-migrate @ 9722]
Remove the prpl callbacks set_dir, get_dir and dir_search.
These
1) Were not called by anything
2) Are AIM-centric
3) Should be Account Actions, if implemented
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 16 May 2004 07:19:56 +0000 |
parents | d7b8eb1f0a18 |
children | 294ae6548d4e |
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 * |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
433 trepia_actions(GaimConnection *gc) |
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; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
436 struct proto_actions_menu *pam; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
437 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
438 pam = g_new0(struct proto_actions_menu, 1); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
439 pam->label = _("Set Profile"); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
440 pam->callback = set_profile; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
441 pam->gc = gc; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
442 m = g_list_append(m, pam); |
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 return m; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
445 } |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
446 |
5730 | 447 static void |
5999
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
448 trepia_visit_homepage(GaimConnection *gc, const char *who) |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
449 { |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
450 TrepiaProfile *profile; |
7382 | 451 GaimBuddy *b; |
5999
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
452 const char *value; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
453 |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
454 b = gaim_find_buddy(gaim_connection_get_account(gc), who); |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
455 profile = b->proto_data; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
456 |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
457 if ((value = trepia_profile_get_homepage(profile)) != NULL) |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
458 gaim_notify_uri(gc, value); |
5999
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
459 } |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
460 |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
461 static GList * |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
462 trepia_buddy_menu(GaimConnection *gc, const char *who) |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
463 { |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
464 TrepiaProfile *profile; |
7382 | 465 GaimBuddy *b; |
5999
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
466 const char *value = NULL; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
467 GList *m = NULL; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
468 struct proto_buddy_menu *pbm; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
469 |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
470 b = gaim_find_buddy(gaim_connection_get_account(gc), who); |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
471 profile = b->proto_data; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
472 |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
473 if ((value = trepia_profile_get_homepage(profile)) != NULL) { |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
474 pbm = g_new0(struct proto_buddy_menu, 1); |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
475 pbm->label = _("Visit Homepage"); |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
476 pbm->callback = trepia_visit_homepage; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
477 pbm->gc = gc; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
478 m = g_list_append(m, pbm); |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
479 } |
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 return m; |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
482 } |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
483 |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
484 static void |
5730 | 485 __free_parser_data(gpointer user_data) |
486 { | |
5769
0f9b5737e5fe
[gaim-migrate @ 6194]
Christian Hammond <chipx86@chipx86.com>
parents:
5752
diff
changeset
|
487 #if 0 |
5730 | 488 TrepiaParserData *data = user_data; |
489 | |
490 if (data->buffer != NULL) | |
491 g_string_free(data->buffer, TRUE); | |
492 | |
493 if (data->tag != NULL) | |
494 g_free(data->tag); | |
495 | |
496 g_free(data); | |
5769
0f9b5737e5fe
[gaim-migrate @ 6194]
Christian Hammond <chipx86@chipx86.com>
parents:
5752
diff
changeset
|
497 #endif |
5730 | 498 } |
499 | |
500 static void | |
501 __start_element_handler(GMarkupParseContext *context, | |
502 const gchar *element_name, | |
503 const gchar **attribute_names, | |
504 const gchar **attribute_values, | |
505 gpointer user_data, GError **error) | |
506 { | |
507 TrepiaParserData *data = user_data; | |
508 | |
509 if (data->buffer != NULL) { | |
510 g_string_free(data->buffer, TRUE); | |
511 data->buffer = NULL; | |
512 } | |
513 | |
514 if (*data->type == 0) { | |
515 *data->type = *element_name; | |
516 } | |
517 else { | |
6061 | 518 data->tag = g_strdup(element_name); /* XXX - Make sure this is freed */ |
5730 | 519 } |
520 } | |
521 | |
522 static void | |
523 __end_element_handler(GMarkupParseContext *context, const gchar *element_name, | |
524 gpointer user_data, GError **error) | |
525 { | |
526 TrepiaParserData *data = user_data; | |
527 gchar *buffer; | |
528 | |
529 if (*element_name == *data->type) | |
530 return; | |
531 | |
532 if (data->buffer == NULL || data->tag == NULL) { | |
533 data->tag = NULL; | |
534 return; | |
535 } | |
536 | |
537 buffer = g_string_free(data->buffer, FALSE); | |
538 data->buffer = NULL; | |
539 | |
5999
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
540 if (buffer != NULL) { |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
541 if (*buffer != '\0') |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
542 g_hash_table_insert(data->keys, data->tag, buffer); |
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
543 else |
7606 | 544 g_free(buffer); |
5999
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
545 } |
5730 | 546 |
547 data->tag = NULL; | |
548 } | |
549 | |
550 static void | |
551 __text_handler(GMarkupParseContext *context, const gchar *text, | |
552 gsize text_len, gpointer user_data, GError **error) | |
553 { | |
554 TrepiaParserData *data = user_data; | |
555 | |
556 if (data->buffer == NULL) | |
557 data->buffer = g_string_new_len(text, text_len); | |
558 else | |
559 g_string_append_len(data->buffer, text, text_len); | |
560 } | |
561 | |
562 static GMarkupParser accounts_parser = | |
563 { | |
564 __start_element_handler, | |
565 __end_element_handler, | |
566 __text_handler, | |
567 NULL, | |
568 NULL | |
569 }; | |
570 | |
571 static int | |
572 __parse_message(const char *buf, TrepiaMessageType *type, GHashTable **info) | |
573 { | |
574 TrepiaParserData *parser_data = g_new0(TrepiaParserData, 1); | |
575 GMarkupParseContext *context; | |
576 GHashTable *keys; | |
577 | |
578 keys = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
579 parser_data->keys = keys; | |
580 parser_data->type = type; | |
581 | |
582 context = g_markup_parse_context_new(&accounts_parser, 0, | |
583 parser_data, __free_parser_data); | |
584 | |
585 if (!g_markup_parse_context_parse(context, buf, strlen(buf), NULL)) { | |
586 g_markup_parse_context_free(context); | |
587 g_free(parser_data); | |
588 g_hash_table_destroy(keys); | |
589 | |
590 return 1; | |
591 } | |
592 | |
593 if (!g_markup_parse_context_end_parse(context, NULL)) { | |
594 g_markup_parse_context_free(context); | |
595 g_free(parser_data); | |
596 g_hash_table_destroy(keys); | |
597 | |
598 return 1; | |
599 } | |
600 | |
601 g_markup_parse_context_free(context); | |
6061 | 602 g_free(parser_data); |
5730 | 603 *info = keys; |
604 | |
605 return 0; | |
606 } | |
607 | |
608 static gboolean | |
6087 | 609 _parse_data(TrepiaSession *session, char *buf) |
5730 | 610 { |
611 GHashTable *info; | |
612 GaimAccount *account; | |
613 TrepiaMessageType type = 0; | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
614 TrepiaProfile *profile = NULL; |
5730 | 615 int ret; |
616 char *buffer; | |
7382 | 617 GaimBuddy *b; |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
618 int id = 0; |
5730 | 619 const char *value; |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
620 char *username; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
621 int *int_p; |
5990
99fbd0161cb7
[gaim-migrate @ 6438]
Christian Hammond <chipx86@chipx86.com>
parents:
5988
diff
changeset
|
622 GMainContext *ctx; |
5730 | 623 |
624 account = gaim_connection_get_account(session->gc); | |
625 | |
626 ret = __parse_message(buf, &type, &info); | |
627 | |
628 if (ret == 1) | |
629 return TRUE; | |
630 | |
631 if (info != NULL) { | |
632 switch (type) { | |
633 case TREPIA_USER_LIST: | |
5988
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
634 gaim_connection_update_progress(session->gc, |
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
635 _("Retrieving buddy list"), 2, TREPIA_CONNECT_STEPS); |
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
636 |
5730 | 637 gaim_connection_set_state(session->gc, GAIM_CONNECTED); |
638 serv_finish_login(session->gc); | |
639 break; | |
640 | |
641 case TREPIA_MSG_INCOMING: /* Incoming Message */ | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
642 id = atoi(g_hash_table_lookup(info, "a")); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
643 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
644 profile = g_hash_table_lookup(session->user_profiles, &id); |
5730 | 645 serv_got_im(session->gc, |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
646 trepia_profile_get_login(profile), |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
647 (char *)g_hash_table_lookup(info, "b"), |
6982 | 648 0, time(NULL)); |
5730 | 649 break; |
650 | |
651 case TREPIA_MEMBER_UPDATE: | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
652 profile = trepia_profile_new(); |
5730 | 653 |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
654 if ((value = g_hash_table_lookup(info, "a")) != NULL) { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
655 id = atoi(value); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
656 trepia_profile_set_id(profile, id); |
5730 | 657 } |
658 | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
659 if ((value = g_hash_table_lookup(info, "b")) != NULL) |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
660 trepia_profile_set_login_time(profile, atoi(value)); |
5730 | 661 |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
662 if ((value = g_hash_table_lookup(info, "c")) != NULL) |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
663 trepia_profile_set_type(profile, atoi(value)); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
664 else |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
665 trepia_profile_set_type(profile, 2); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
666 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
667 session->pending_users = g_list_append(session->pending_users, |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
668 profile); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
669 |
5730 | 670 |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
671 #if 0 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
672 if (trepia_profile_get_type(profile) == 1) { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
673 buffer = g_strdup_printf( |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
674 "<D>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
675 "<a>%d</a>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
676 "<b>1</b>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
677 "</D>", |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
678 id); |
5730 | 679 } |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
680 else { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
681 #endif |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
682 buffer = g_strdup_printf( |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
683 "<D>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
684 "<a>%d</a>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
685 "<b>1</b>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
686 "</D>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
687 "<D>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
688 "<a>%d</a>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
689 "<b>2</b>" |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
690 "</D>", |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
691 id, |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
692 id); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
693 #if 0 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
694 } |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
695 #endif |
5730 | 696 |
697 if (trepia_write(session->fd, buffer, strlen(buffer)) < 0) { | |
698 gaim_connection_error(session->gc, _("Write error")); | |
699 g_free(buffer); | |
700 return 1; | |
701 } | |
702 | |
703 g_free(buffer); | |
704 break; | |
705 | |
706 case TREPIA_MEMBER_PROFILE: | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
707 if ((value = g_hash_table_lookup(info, "a")) != NULL) { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
708 GList *l; |
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 id = atoi(value); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
711 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
712 for (l = session->pending_users; l != NULL; l = l->next) { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
713 profile = l->data; |
5730 | 714 |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
715 if (trepia_profile_get_id(profile) == id) |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
716 break; |
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 profile = NULL; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
719 } |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
720 } |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
721 else |
5730 | 722 break; |
723 | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
724 if (profile == NULL) { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
725 profile = g_hash_table_lookup(session->user_profiles, &id); |
5730 | 726 |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
727 if (profile == NULL) |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
728 break; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
729 } |
5730 | 730 |
731 /* Age */ | |
732 if ((value = g_hash_table_lookup(info, "m")) != NULL) | |
733 trepia_profile_set_age(profile, atoi(value)); | |
734 | |
735 /* ICQ */ | |
736 if ((value = g_hash_table_lookup(info, "i")) != NULL) | |
737 trepia_profile_set_icq(profile, atoi(value)); | |
738 | |
739 /* Sex */ | |
740 if ((value = g_hash_table_lookup(info, "n")) != NULL) | |
741 trepia_profile_set_sex(profile, *value); | |
742 | |
743 /* Location */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
744 if ((value = g_hash_table_lookup(info, "p")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
745 trepia_profile_set_location(profile, value); |
5730 | 746 |
747 /* First Name */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
748 if ((value = g_hash_table_lookup(info, "g")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
749 trepia_profile_set_first_name(profile, value); |
5730 | 750 |
751 /* Last Name */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
752 if ((value = g_hash_table_lookup(info, "h")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
753 trepia_profile_set_last_name(profile, value); |
5730 | 754 |
755 /* Profile */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
756 if ((value = g_hash_table_lookup(info, "o")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
757 trepia_profile_set_profile(profile, value); |
5730 | 758 |
759 /* E-mail */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
760 if ((value = g_hash_table_lookup(info, "e")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
761 trepia_profile_set_email(profile, value); |
5730 | 762 |
763 /* AIM */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
764 if ((value = g_hash_table_lookup(info, "j")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
765 trepia_profile_set_aim(profile, value); |
5730 | 766 |
767 /* MSN */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
768 if ((value = g_hash_table_lookup(info, "k")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
769 trepia_profile_set_msn(profile, value); |
5730 | 770 |
771 /* Yahoo */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
772 if ((value = g_hash_table_lookup(info, "l")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
773 trepia_profile_set_yahoo(profile, value); |
5730 | 774 |
775 /* Homepage */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
776 if ((value = g_hash_table_lookup(info, "f")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
777 trepia_profile_set_homepage(profile, value); |
5730 | 778 |
779 /* Country */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
780 if ((value = g_hash_table_lookup(info, "r")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
781 trepia_profile_set_country(profile, value); |
5730 | 782 |
783 /* State */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
784 if ((value = g_hash_table_lookup(info, "s")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
785 trepia_profile_set_state(profile, value); |
5730 | 786 |
787 /* City */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
788 if ((value = g_hash_table_lookup(info, "t")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
789 trepia_profile_set_city(profile, value); |
5730 | 790 |
791 /* Languages */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
792 if ((value = g_hash_table_lookup(info, "u")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
793 trepia_profile_set_languages(profile, value); |
5730 | 794 |
795 /* School */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
796 if ((value = g_hash_table_lookup(info, "v")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
797 trepia_profile_set_school(profile, value); |
5730 | 798 |
799 /* Company */ | |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
800 if ((value = g_hash_table_lookup(info, "w")) != NULL) |
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
801 trepia_profile_set_company(profile, value); |
5730 | 802 |
803 /* Login Name */ | |
804 if ((value = g_hash_table_lookup(info, "d")) != NULL) { | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
805 trepia_profile_set_login(profile, value); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
806 username = g_strdup(value); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
807 } |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
808 else if ((value = trepia_profile_get_login(profile)) != NULL) { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
809 username = g_strdup(value); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
810 } |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
811 else { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
812 username = g_strdup_printf("%d", id); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
813 trepia_profile_set_login(profile, username); |
5730 | 814 } |
815 | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
816 b = gaim_find_buddy(account, username); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
817 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
818 if (b == NULL) { |
7382 | 819 GaimGroup *g; |
5752
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 g = gaim_find_group(_("Local Users")); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
822 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
823 if (g == NULL) { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
824 g = gaim_group_new(_("Local Users")); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
825 gaim_blist_add_group(g, NULL); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
826 } |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
827 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
828 b = gaim_buddy_new(account, username, NULL); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
829 |
7382 | 830 gaim_blist_add_buddy(b, NULL, g, NULL); |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
831 } |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
832 |
5789
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
833 profile->buddy = b; |
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
834 |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
835 b->proto_data = profile; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
836 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
837 session->pending_users = g_list_remove(session->pending_users, |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
838 profile); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
839 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
840 int_p = g_new0(int, 1); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
841 *int_p = id; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
842 g_hash_table_insert(session->user_profiles, int_p, profile); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
843 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
844 serv_got_update(session->gc, |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
845 username, 1, 0, |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
846 trepia_profile_get_login_time(profile), 0, 0); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
847 |
5730 | 848 /* Buddy Icon */ |
849 if ((value = g_hash_table_lookup(info, "q")) != NULL) { | |
850 char *icon; | |
851 int icon_len; | |
852 | |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
853 gaim_base64_decode(value, &icon, &icon_len); |
5730 | 854 |
7382 | 855 gaim_buddy_icons_set_for_user(session->gc->account, |
856 username, icon, icon_len); | |
5730 | 857 |
858 g_free(icon); | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
859 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
860 serv_got_update(session->gc, username, 1, 0, 0, 0, 0); |
5730 | 861 } |
5735
a80fcb009d81
[gaim-migrate @ 6159]
Christian Hammond <chipx86@chipx86.com>
parents:
5732
diff
changeset
|
862 |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8170
diff
changeset
|
863 /* |
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8170
diff
changeset
|
864 * XXX |
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8170
diff
changeset
|
865 * This does nothing when using a non-gtk event loop. |
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8170
diff
changeset
|
866 * What is it supposed to accomplish anyway? |
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8170
diff
changeset
|
867 */ |
5990
99fbd0161cb7
[gaim-migrate @ 6438]
Christian Hammond <chipx86@chipx86.com>
parents:
5988
diff
changeset
|
868 ctx = g_main_context_default(); |
99fbd0161cb7
[gaim-migrate @ 6438]
Christian Hammond <chipx86@chipx86.com>
parents:
5988
diff
changeset
|
869 |
99fbd0161cb7
[gaim-migrate @ 6438]
Christian Hammond <chipx86@chipx86.com>
parents:
5988
diff
changeset
|
870 while (g_main_context_pending(ctx)) |
99fbd0161cb7
[gaim-migrate @ 6438]
Christian Hammond <chipx86@chipx86.com>
parents:
5988
diff
changeset
|
871 g_main_context_iteration(ctx, FALSE); |
99fbd0161cb7
[gaim-migrate @ 6438]
Christian Hammond <chipx86@chipx86.com>
parents:
5988
diff
changeset
|
872 |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
873 g_free(username); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
874 |
5730 | 875 break; |
876 | |
877 case TREPIA_MEMBER_OFFLINE: | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
878 if ((value = g_hash_table_lookup(info, "a")) != NULL) |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
879 id = atoi(value); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
880 else |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
881 break; |
5730 | 882 |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
883 profile = g_hash_table_lookup(session->user_profiles, &id); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
884 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
885 if (profile == NULL) |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
886 break; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
887 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
888 g_hash_table_remove(session->user_profiles, &id); |
5789
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
889 |
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
890 b = profile->buddy; |
5730 | 891 |
892 if (b != NULL) | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
893 serv_got_update(session->gc, |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
894 trepia_profile_get_login(profile), |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
895 0, 0, 0, 0, 0); |
5730 | 896 |
897 gaim_blist_remove_buddy(b); | |
898 | |
899 break; | |
900 | |
901 default: | |
902 break; | |
903 } | |
904 | |
905 g_hash_table_destroy(info); | |
906 } | |
907 else { | |
908 gaim_debug(GAIM_DEBUG_WARNING, "trepia", | |
909 "Unknown data received. Possibly an image?\n"); | |
910 } | |
911 | |
912 return TRUE; | |
913 } | |
914 | |
915 static void | |
6087 | 916 _data_cb(gpointer data, gint source, GaimInputCondition cond) |
5730 | 917 { |
918 TrepiaSession *session = data; | |
919 int i = 0; | |
920 char buf[1025]; | |
921 gboolean cont = TRUE; | |
922 | |
923 i = read(session->fd, buf, 1024); | |
924 | |
925 if (i <= 0) { | |
926 gaim_connection_error(session->gc, _("Read error")); | |
927 return; | |
928 } | |
929 | |
930 buf[i] = '\0'; | |
931 | |
932 if (session->rxqueue == NULL) | |
933 session->rxqueue = g_string_new(buf); | |
934 else | |
935 g_string_append(session->rxqueue, buf); | |
936 | |
937 while (cont) { | |
938 char end_tag[5] = "</ >"; | |
939 char *end_s; | |
940 | |
941 end_tag[2] = session->rxqueue->str[1]; | |
942 | |
943 end_s = strstr(session->rxqueue->str, end_tag); | |
944 | |
945 if (end_s != NULL) { | |
946 char *buffer; | |
947 size_t len; | |
948 int ret; | |
949 | |
950 end_s += 4; | |
951 | |
952 len = end_s - session->rxqueue->str; | |
953 buffer = g_new0(char, len + 1); | |
954 strncpy(buffer, session->rxqueue->str, len); | |
955 | |
956 g_string_erase(session->rxqueue, 0, len); | |
957 | |
958 if (*session->rxqueue->str == '\n') | |
959 g_string_erase(session->rxqueue, 0, 1); | |
960 | |
961 gaim_debug(GAIM_DEBUG_MISC, "trepia", "S: %s\n", buffer); | |
962 | |
6087 | 963 ret = _parse_data(session, buffer); |
5730 | 964 |
965 g_free(buffer); | |
966 } | |
967 else | |
968 break; | |
969 } | |
970 } | |
971 | |
972 static void | |
973 __login_cb(gpointer data, gint source, GaimInputCondition cond) | |
974 { | |
975 TrepiaSession *session = data; | |
976 GaimAccount *account; | |
977 const char *password; | |
978 char *buffer; | |
5833
b1fc288ffcb4
[gaim-migrate @ 6264]
Christian Hammond <chipx86@chipx86.com>
parents:
5812
diff
changeset
|
979 char *mac = "00:01:02:03:04:05"; |
5730 | 980 char buf[3]; |
981 char md5_password[17]; | |
982 md5_state_t st; | |
983 md5_byte_t di[16]; | |
984 int i; | |
985 | |
986 if (source < 0) { | |
987 gaim_connection_error(session->gc, _("Write error")); | |
988 return; | |
989 } | |
990 | |
5833
b1fc288ffcb4
[gaim-migrate @ 6264]
Christian Hammond <chipx86@chipx86.com>
parents:
5812
diff
changeset
|
991 #if 0 |
b1fc288ffcb4
[gaim-migrate @ 6264]
Christian Hammond <chipx86@chipx86.com>
parents:
5812
diff
changeset
|
992 mac = __get_mac_address(); |
b1fc288ffcb4
[gaim-migrate @ 6264]
Christian Hammond <chipx86@chipx86.com>
parents:
5812
diff
changeset
|
993 #endif |
b1fc288ffcb4
[gaim-migrate @ 6264]
Christian Hammond <chipx86@chipx86.com>
parents:
5812
diff
changeset
|
994 |
5730 | 995 session->fd = source; |
996 | |
997 account = gaim_connection_get_account(session->gc); | |
998 | |
999 password = gaim_account_get_password(account); | |
1000 | |
1001 md5_init(&st); | |
1002 md5_append(&st, (const md5_byte_t *)password, strlen(password)); | |
1003 md5_finish(&st, di); | |
1004 | |
1005 *md5_password = '\0'; | |
1006 | |
1007 for (i = 0; i < 16; i++) { | |
1008 g_snprintf(buf, sizeof(buf), "%02x", di[i]); | |
1009 strcat(md5_password, buf); | |
1010 } | |
1011 | |
1012 buffer = g_strdup_printf( | |
1013 "<C>\n" | |
1014 "<a>%s</a>\n" | |
5833
b1fc288ffcb4
[gaim-migrate @ 6264]
Christian Hammond <chipx86@chipx86.com>
parents:
5812
diff
changeset
|
1015 "<b1></b1>\n" |
5730 | 1016 "<c>%s</c>\n" |
1017 "<d>%s</d>\n" | |
5952 | 1018 "<e>%s</e>\n" |
5730 | 1019 "</C>", |
5833
b1fc288ffcb4
[gaim-migrate @ 6264]
Christian Hammond <chipx86@chipx86.com>
parents:
5812
diff
changeset
|
1020 mac, gaim_account_get_username(account), |
5950
e8316fec4fd1
[gaim-migrate @ 6394]
Christian Hammond <chipx86@chipx86.com>
parents:
5920
diff
changeset
|
1021 md5_password, TREPIA_VERSION); |
5730 | 1022 |
5863
98ec3e394f59
[gaim-migrate @ 6294]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
1023 #if 0 |
5730 | 1024 g_free(mac); |
5863
98ec3e394f59
[gaim-migrate @ 6294]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
1025 #endif |
5730 | 1026 |
5988
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
1027 gaim_connection_update_progress(session->gc, _("Logging in"), 1, |
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
1028 TREPIA_CONNECT_STEPS); |
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
1029 |
5730 | 1030 if (trepia_write(session->fd, buffer, strlen(buffer)) < 0) { |
1031 gaim_connection_error(session->gc, _("Write error")); | |
1032 return; | |
1033 } | |
1034 | |
1035 g_free(buffer); | |
1036 | |
1037 session->gc->inpa = gaim_input_add(session->fd, GAIM_INPUT_READ, | |
6087 | 1038 _data_cb, session); |
5730 | 1039 } |
1040 | |
1041 static void | |
1042 trepia_login(GaimAccount *account) | |
1043 { | |
1044 GaimConnection *gc; | |
1045 TrepiaSession *session; | |
1046 const char *server; | |
1047 int port; | |
1048 int i; | |
1049 | |
1050 server = gaim_account_get_string(account, "server", TREPIA_SERVER); | |
1051 port = gaim_account_get_int(account, "port", TREPIA_PORT); | |
1052 | |
1053 gc = gaim_account_get_connection(account); | |
1054 | |
1055 session = g_new0(TrepiaSession, 1); | |
1056 gc->proto_data = session; | |
1057 session->gc = gc; | |
1058 session->fd = -1; | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1059 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
|
1060 g_free, NULL); |
5730 | 1061 |
5789
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
1062 __clear_user_list(session); |
5730 | 1063 |
5988
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
1064 gaim_connection_update_progress(gc, _("Connecting"), 0, |
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
1065 TREPIA_CONNECT_STEPS); |
4b2bc256d28a
[gaim-migrate @ 6436]
Christian Hammond <chipx86@chipx86.com>
parents:
5952
diff
changeset
|
1066 |
5730 | 1067 i = gaim_proxy_connect(account, server, port, __login_cb, session); |
1068 | |
1069 if (i != 0) | |
1070 gaim_connection_error(gc, _("Unable to create socket")); | |
1071 } | |
1072 | |
1073 static void | |
1074 trepia_close(GaimConnection *gc) | |
1075 { | |
5745
cae58ab49118
[gaim-migrate @ 6169]
Christian Hammond <chipx86@chipx86.com>
parents:
5739
diff
changeset
|
1076 TrepiaSession *session = gc->proto_data; |
cae58ab49118
[gaim-migrate @ 6169]
Christian Hammond <chipx86@chipx86.com>
parents:
5739
diff
changeset
|
1077 |
cae58ab49118
[gaim-migrate @ 6169]
Christian Hammond <chipx86@chipx86.com>
parents:
5739
diff
changeset
|
1078 if (session->rxqueue != NULL) |
cae58ab49118
[gaim-migrate @ 6169]
Christian Hammond <chipx86@chipx86.com>
parents:
5739
diff
changeset
|
1079 g_string_free(session->rxqueue, TRUE); |
cae58ab49118
[gaim-migrate @ 6169]
Christian Hammond <chipx86@chipx86.com>
parents:
5739
diff
changeset
|
1080 |
5789
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
1081 if (session->gc->inpa) |
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
1082 gaim_input_remove(session->gc->inpa); |
5745
cae58ab49118
[gaim-migrate @ 6169]
Christian Hammond <chipx86@chipx86.com>
parents:
5739
diff
changeset
|
1083 |
5789
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
1084 gaim_debug(GAIM_DEBUG_INFO, "trepia", "Destroying user_profiles\n"); |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1085 g_hash_table_destroy(session->user_profiles); |
5789
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
1086 gaim_debug(GAIM_DEBUG_INFO, "trepia", "Destroying pending_users\n"); |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1087 g_list_free(session->pending_users); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1088 |
5789
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
1089 gaim_debug(GAIM_DEBUG_INFO, "trepia", "Closing socket\n"); |
5745
cae58ab49118
[gaim-migrate @ 6169]
Christian Hammond <chipx86@chipx86.com>
parents:
5739
diff
changeset
|
1090 close(session->fd); |
cae58ab49118
[gaim-migrate @ 6169]
Christian Hammond <chipx86@chipx86.com>
parents:
5739
diff
changeset
|
1091 |
cae58ab49118
[gaim-migrate @ 6169]
Christian Hammond <chipx86@chipx86.com>
parents:
5739
diff
changeset
|
1092 g_free(session); |
5739
edf4d443e671
[gaim-migrate @ 6163]
Christian Hammond <chipx86@chipx86.com>
parents:
5737
diff
changeset
|
1093 |
5730 | 1094 gc->proto_data = NULL; |
5789
d42d2c9c2122
[gaim-migrate @ 6214]
Christian Hammond <chipx86@chipx86.com>
parents:
5769
diff
changeset
|
1095 gaim_debug(GAIM_DEBUG_INFO, "trepia", "Leaving trepia_close\n"); |
5730 | 1096 } |
1097 | |
1098 static int | |
1099 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
|
1100 GaimConvImFlags flags) |
5730 | 1101 { |
1102 TrepiaSession *session = gc->proto_data; | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1103 TrepiaProfile *profile; |
7382 | 1104 GaimBuddy *b; |
5737
72ced7411599
[gaim-migrate @ 6161]
Christian Hammond <chipx86@chipx86.com>
parents:
5736
diff
changeset
|
1105 char *escaped_msg; |
5730 | 1106 char *buffer; |
1107 | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1108 b = gaim_find_buddy(gaim_connection_get_account(gc), who); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1109 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1110 if (b == NULL) { |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1111 gaim_debug(GAIM_DEBUG_ERROR, "trepia", |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1112 "Unable to send to buddy not on your list!\n"); |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1113 return 0; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1114 } |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1115 |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1116 profile = b->proto_data; |
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1117 |
5737
72ced7411599
[gaim-migrate @ 6161]
Christian Hammond <chipx86@chipx86.com>
parents:
5736
diff
changeset
|
1118 escaped_msg = g_markup_escape_text(message, -1); |
72ced7411599
[gaim-migrate @ 6161]
Christian Hammond <chipx86@chipx86.com>
parents:
5736
diff
changeset
|
1119 |
5730 | 1120 buffer = g_strdup_printf( |
1121 "<F>\n" | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1122 "<a>%d</a>\n" |
5730 | 1123 "<b>%s</b>\n" |
1124 "</F>", | |
5752
90eea4997759
[gaim-migrate @ 6177]
Christian Hammond <chipx86@chipx86.com>
parents:
5751
diff
changeset
|
1125 trepia_profile_get_id(profile), escaped_msg); |
5737
72ced7411599
[gaim-migrate @ 6161]
Christian Hammond <chipx86@chipx86.com>
parents:
5736
diff
changeset
|
1126 |
72ced7411599
[gaim-migrate @ 6161]
Christian Hammond <chipx86@chipx86.com>
parents:
5736
diff
changeset
|
1127 g_free(escaped_msg); |
5730 | 1128 |
1129 if (trepia_write(session->fd, buffer, strlen(buffer)) < 0) { | |
1130 gaim_connection_error(gc, _("Write error")); | |
1131 g_free(buffer); | |
1132 return 1; | |
1133 } | |
1134 | |
1135 return 1; | |
1136 } | |
1137 | |
1138 static void | |
6787
faa491042c66
[gaim-migrate @ 7326]
Christian Hammond <chipx86@chipx86.com>
parents:
6622
diff
changeset
|
1139 trepia_add_buddy(GaimConnection *gc, const char *name, GaimGroup *group) |
5730 | 1140 { |
1141 } | |
1142 | |
1143 static void | |
6059 | 1144 trepia_rem_buddy(GaimConnection *gc, const char *who, const char *group) |
5730 | 1145 { |
1146 } | |
1147 | |
1148 static void | |
7382 | 1149 trepia_buddy_free(GaimBuddy *b) |
5730 | 1150 { |
1151 if (b->proto_data != NULL) { | |
1152 trepia_profile_destroy(b->proto_data); | |
1153 | |
1154 b->proto_data = NULL; | |
1155 } | |
1156 } | |
1157 | |
1158 static void | |
5849
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1159 trepia_set_buddy_icon(GaimConnection *gc, const char *filename) |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1160 { |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1161 TrepiaSession *session = gc->proto_data; |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1162 struct stat sb; |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1163 |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1164 if (!stat(filename, &sb)) { |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1165 FILE *fp; |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1166 |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1167 if ((fp = fopen(filename, "rb")) != NULL) { |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1168 char *buf = g_malloc(sb.st_size + 1); |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1169 char *temp; |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1170 char *out_buf; |
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 fread(buf, 1, sb.st_size, fp); |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1173 |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1174 buf[sb.st_size] = '\0'; |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1175 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1176 temp = gaim_base64_encode(buf, sb.st_size); |
5849
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 out_buf = g_strdup_printf("<K><m>%s</m></K>", temp); |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1179 |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1180 g_free(temp); |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1181 g_free(buf); |
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 fclose(fp); |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1184 |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1185 if (trepia_write(session->fd, out_buf, strlen(out_buf)) < 0) { |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1186 gaim_connection_error(session->gc, _("Write error")); |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1187 return; |
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 } |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1192 |
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1193 static void |
5730 | 1194 trepia_register_user(GaimAccount *account) |
1195 { | |
1196 char *buffer; | |
5863
98ec3e394f59
[gaim-migrate @ 6294]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
1197 char *mac = "00:01:02:03:04:05"; |
5730 | 1198 |
1199 buffer = g_strdup_printf( | |
5863
98ec3e394f59
[gaim-migrate @ 6294]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
1200 "<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
|
1201 "<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
|
1202 "<m></m></J>", |
98ec3e394f59
[gaim-migrate @ 6294]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
1203 mac, "", TREPIA_VERSION, gaim_account_get_username(account), |
98ec3e394f59
[gaim-migrate @ 6294]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
1204 gaim_account_get_password(account)); |
5730 | 1205 } |
1206 | |
1207 static GaimPluginProtocolInfo prpl_info = | |
1208 { | |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8721
diff
changeset
|
1209 GAIM_PRPL_API_VERSION, |
5730 | 1210 OPT_PROTO_BUDDY_ICON, |
1211 NULL, | |
1212 NULL, | |
1213 trepia_list_icon, | |
1214 trepia_list_emblems, | |
5731
7cb2bbf03db5
[gaim-migrate @ 6155]
Christian Hammond <chipx86@chipx86.com>
parents:
5730
diff
changeset
|
1215 trepia_status_text, |
5730 | 1216 trepia_tooltip_text, |
1217 NULL, | |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5789
diff
changeset
|
1218 trepia_actions, |
5999
44b7e2530c05
[gaim-migrate @ 6447]
Christian Hammond <chipx86@chipx86.com>
parents:
5990
diff
changeset
|
1219 trepia_buddy_menu, |
5730 | 1220 NULL, |
1221 trepia_login, | |
1222 trepia_close, | |
1223 trepia_send_im, | |
1224 NULL, | |
1225 NULL, | |
1226 NULL, | |
1227 NULL, | |
1228 NULL, | |
1229 NULL, | |
1230 trepia_add_buddy, | |
1231 NULL, | |
1232 trepia_rem_buddy, | |
1233 NULL, | |
1234 NULL, | |
1235 NULL, | |
1236 NULL, | |
1237 NULL, | |
1238 NULL, | |
1239 NULL, | |
1240 NULL, | |
1241 NULL, | |
1242 NULL, | |
1243 NULL, | |
1244 NULL, | |
1245 NULL, | |
8562 | 1246 NULL, |
5730 | 1247 trepia_register_user, |
1248 NULL, | |
1249 NULL, | |
1250 NULL, | |
1251 NULL, | |
1252 NULL, | |
1253 trepia_buddy_free, | |
1254 NULL, | |
5849
97d1ad7a50cc
[gaim-migrate @ 6280]
Christian Hammond <chipx86@chipx86.com>
parents:
5848
diff
changeset
|
1255 NULL, |
8586 | 1256 trepia_set_buddy_icon, |
8589 | 1257 NULL, |
1258 NULL, | |
1259 NULL, | |
1260 NULL, | |
1261 NULL, | |
1262 NULL, | |
1263 NULL, | |
1264 NULL | |
5730 | 1265 }; |
1266 | |
1267 static GaimPluginInfo info = | |
1268 { | |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8721
diff
changeset
|
1269 GAIM_PLUGIN_API_VERSION, /**< api_version */ |
5730 | 1270 GAIM_PLUGIN_PROTOCOL, /**< type */ |
1271 NULL, /**< ui_requirement */ | |
1272 0, /**< flags */ | |
1273 NULL, /**< dependencies */ | |
1274 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
1275 | |
1276 "prpl-trepia", /**< id */ | |
1277 "Trepia", /**< name */ | |
1278 VERSION, /**< version */ | |
1279 /** summary */ | |
1280 N_("Trepia Protocol Plugin"), | |
1281 /** description */ | |
1282 N_("Trepia Protocol Plugin"), | |
1283 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6087
diff
changeset
|
1284 GAIM_WEBSITE, /**< homepage */ |
5730 | 1285 |
1286 NULL, /**< load */ | |
1287 NULL, /**< unload */ | |
1288 NULL, /**< destroy */ | |
1289 | |
1290 NULL, /**< ui_info */ | |
1291 &prpl_info /**< extra_info */ | |
1292 }; | |
1293 | |
1294 static void | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1295 init_plugin(GaimPlugin *plugin) |
5730 | 1296 { |
1297 GaimAccountOption *option; | |
1298 | |
1299 option = gaim_account_option_string_new(_("Login server"), "server", | |
1300 TREPIA_SERVER); | |
1301 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
1302 option); | |
1303 | |
1304 option = gaim_account_option_int_new(_("Port"), "port", TREPIA_PORT); | |
1305 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
1306 option); | |
1307 | |
1308 my_protocol = plugin; | |
1309 } | |
1310 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1311 GAIM_INIT_PLUGIN(trepia, init_plugin, info); |