Mercurial > pidgin.yaz
annotate src/toc.c @ 968:10d8133ffab9
[gaim-migrate @ 978]
stupid, stupid, stupid
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 10 Oct 2000 20:16:03 +0000 |
parents | f7886476f9d9 |
children | 9eb07b383df4 |
rev | line source |
---|---|
1 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
22 | |
23 | |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
333
diff
changeset
|
24 #ifdef HAVE_CONFIG_H |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
333
diff
changeset
|
25 #include "../config.h" |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
333
diff
changeset
|
26 #endif |
1 | 27 #include <netdb.h> |
28 #include <gtk/gtk.h> | |
29 #include <unistd.h> | |
30 #include <errno.h> | |
31 #include <netinet/in.h> | |
32 #include <arpa/inet.h> | |
33 #include <string.h> | |
34 #include <stdlib.h> | |
35 #include <stdio.h> | |
36 #include <time.h> | |
37 #include <sys/socket.h> | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
38 #include "multi.h" |
1 | 39 #include "gaim.h" |
40 #include "gnome_applet_mgr.h" | |
41 | |
966
f7886476f9d9
[gaim-migrate @ 976]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
964
diff
changeset
|
42 #define REVISION "gaim:$Revision: 976 $" |
1 | 43 |
44 | |
45 static unsigned int peer_ver=0; | |
46 #ifdef _WIN32 | |
47 static int win32_r; | |
48 #endif | |
49 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
50 static int toc_signon(struct gaim_connection *); |
1 | 51 |
52 | |
53 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
54 /* ok. this function used to take username/password, and return 0 on success. |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
55 * now, it takes username/password, and returns NULL on error or a new gaim_connection |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
56 * on success. FIXME: should this modify the UI? or just sign in? */ |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
57 struct gaim_connection *toc_login(char *username, char *password) |
1 | 58 { |
59 char *config; | |
60 struct in_addr *sin; | |
61 struct aim_user *u; | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
62 struct gaim_connection *gc; |
1 | 63 char buf[80]; |
64 char buf2[2048]; | |
65 | |
66 g_snprintf(buf, sizeof(buf), "Looking up %s", aim_host); | |
67 set_login_progress(1, buf); | |
68 | |
69 sin = (struct in_addr *)get_address(aim_host); | |
70 if (!sin) { | |
71 | |
72 #ifdef USE_APPLET | |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
710
diff
changeset
|
73 set_user_state(offline); |
1 | 74 #endif /* USE_APPLET */ |
75 g_snprintf(buf, sizeof(buf), "Unable to lookup %s", aim_host); | |
76 hide_login_progress(buf); | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
77 return NULL; |
1 | 78 } |
79 | |
80 g_snprintf(toc_addy, sizeof(toc_addy), "%s", inet_ntoa(*sin)); | |
81 g_snprintf(buf, sizeof(buf), "Connecting to %s", inet_ntoa(*sin)); | |
82 | |
83 set_login_progress(2, buf); | |
84 | |
85 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
86 gc = new_gaim_conn(PROTO_TOC, username, password); |
1 | 87 |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
88 gc->toc_fd = connect_address(sin->s_addr, aim_port); |
1 | 89 |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
90 if (gc->toc_fd < 0) { |
1 | 91 #ifdef USE_APPLET |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
710
diff
changeset
|
92 set_user_state(offline); |
1 | 93 #endif /* USE_APPLET */ |
94 g_snprintf(buf, sizeof(buf), "Connect to %s failed", | |
95 inet_ntoa(*sin)); | |
96 hide_login_progress(buf); | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
97 destroy_gaim_conn(gc); |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
98 return NULL; |
1 | 99 } |
100 | |
101 g_free(sin); | |
102 | |
103 g_snprintf(buf, sizeof(buf), "Signon: %s",username); | |
104 | |
105 set_login_progress(3, buf); | |
106 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
107 if (toc_signon(gc) < 0) { |
1 | 108 #ifdef USE_APPLET |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
710
diff
changeset
|
109 set_user_state(offline); |
1 | 110 #endif /* USE_APPLET */ |
111 hide_login_progress("Disconnected."); | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
112 destroy_gaim_conn(gc); |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
113 return NULL; |
1 | 114 } |
115 | |
116 g_snprintf(buf, sizeof(buf), "Waiting for reply..."); | |
117 set_login_progress(4, buf); | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
118 if (toc_wait_signon(gc) < 0) { |
1 | 119 #ifdef USE_APPLET |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
710
diff
changeset
|
120 set_user_state(offline); |
1 | 121 #endif /* USE_APPLET */ |
122 hide_login_progress("Authentication Failed"); | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
123 destroy_gaim_conn(gc); |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
124 return NULL; |
1 | 125 } |
126 | |
127 u = find_user(username); | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
128 sprintf(gc->user_info, "%s", u->user_info); |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
129 gc->options = u->options; |
1 | 130 save_prefs(); |
131 | |
132 g_snprintf(buf, sizeof(buf), "Retrieving config..."); | |
133 set_login_progress(5, buf); | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
134 config = toc_wait_config(gc); |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
135 gc->state = STATE_ONLINE; |
1 | 136 |
966
f7886476f9d9
[gaim-migrate @ 976]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
964
diff
changeset
|
137 if (mainwindow) |
f7886476f9d9
[gaim-migrate @ 976]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
964
diff
changeset
|
138 gtk_widget_hide(mainwindow); |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
710
diff
changeset
|
139 show_buddy_list(); |
1 | 140 #ifdef USE_APPLET |
10 | 141 if (general_options & OPT_GEN_APP_BUDDY_SHOW) { |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
710
diff
changeset
|
142 refresh_buddy_window(); |
50 | 143 createOnlinePopup(); |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
710
diff
changeset
|
144 applet_buddy_show = TRUE; |
1 | 145 } else { |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
710
diff
changeset
|
146 gtk_widget_hide(blist); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
710
diff
changeset
|
147 applet_buddy_show = FALSE; |
1 | 148 } |
149 | |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
710
diff
changeset
|
150 set_user_state(online); |
1 | 151 #else |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
710
diff
changeset
|
152 refresh_buddy_window(); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
710
diff
changeset
|
153 #endif |
300
b32c83750104
[gaim-migrate @ 310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
296
diff
changeset
|
154 if (config != NULL) |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
155 parse_toc_buddy_list(gc, config, 0); |
300
b32c83750104
[gaim-migrate @ 310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
296
diff
changeset
|
156 else |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
157 do_import(0, gc); |
1 | 158 |
774
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
762
diff
changeset
|
159 setup_buddy_chats(); |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
762
diff
changeset
|
160 |
1 | 161 g_snprintf(buf2, sizeof(buf2), "toc_init_done"); |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
162 sflap_send(gc, buf2, -1, TYPE_DATA); |
1 | 163 |
211
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
164 g_snprintf(buf2, sizeof(buf2), "toc_set_caps %s %s %s %s %s", |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
165 FILE_SEND_UID, FILE_GET_UID, B_ICON_UID, IMAGE_UID, |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
166 VOICE_UID); |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
167 sflap_send(gc, buf2, -1, TYPE_DATA); |
149 | 168 |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
169 if (gc->keepalive < 0) |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
170 update_keepalive(gc, gc->options & OPT_USR_KEEPALV); |
930
a88af4cc626a
[gaim-migrate @ 940]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
866
diff
changeset
|
171 |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
172 serv_finish_login(gc); |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
173 gaim_setup(gc); |
1 | 174 return 0; |
175 } | |
176 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
177 void toc_close(struct gaim_connection *gc) |
1 | 178 { |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
179 if (gc->protocol != PROTO_TOC) return; /* how did this happen? */ |
1 | 180 #ifdef USE_APPLET |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
710
diff
changeset
|
181 set_user_state(offline); |
1 | 182 #endif /* USE_APPLET */ |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
183 if (gc->inpa > 0) |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
184 gdk_input_remove(gc->inpa); |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
185 gc->inpa = -1; |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
186 close(gc->toc_fd); |
1 | 187 } |
188 | |
189 unsigned char *roast_password(char *pass) | |
190 { | |
191 /* Trivial "encryption" */ | |
192 static char rp[256]; | |
193 static char *roast = ROAST; | |
194 int pos=2; | |
195 int x; | |
196 strcpy(rp, "0x"); | |
197 for (x=0;(x<150) && pass[x]; x++) | |
198 pos+=sprintf(&rp[pos],"%02x", pass[x] ^ roast[x % strlen(roast)]); | |
199 rp[pos]='\0'; | |
200 return rp; | |
201 } | |
202 | |
203 | |
204 char *print_header(void *hdr_v) | |
205 { | |
206 static char s[80]; | |
207 struct sflap_hdr *hdr = (struct sflap_hdr *)hdr_v; | |
208 g_snprintf(s,sizeof(s), "[ ast: %c, type: %d, seqno: %d, len: %d ]", | |
209 hdr->ast, hdr->type, ntohs(hdr->seqno), ntohs(hdr->len)); | |
210 return s; | |
211 } | |
212 | |
213 void print_buffer(char *buf, int len) | |
214 { | |
215 #if 0 | |
216 int x; | |
217 printf("[ "); | |
218 for (x=0;x<len;x++) | |
219 printf("%d ", buf[x]); | |
220 printf("]\n"); | |
221 printf("[ "); | |
222 for (x=0;x<len;x++) | |
223 printf("%c ", buf[x]); | |
224 printf("]\n"); | |
225 #endif | |
226 } | |
227 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
228 int sflap_send(struct gaim_connection *gc, char *buf, int olen, int type) |
1 | 229 { |
230 int len; | |
231 int slen=0; | |
232 struct sflap_hdr hdr; | |
233 char obuf[MSG_LEN]; | |
234 | |
235 /* One _last_ 2048 check here! This shouldn't ever | |
236 * get hit though, hopefully. If it gets hit on an IM | |
237 * It'll lose the last " and the message won't go through, | |
238 * but this'll stop a segfault. */ | |
239 if (strlen(buf) > (MSG_LEN - sizeof(hdr))) { | |
240 buf[MSG_LEN - sizeof(hdr) - 3] = '"'; | |
241 buf[MSG_LEN - sizeof(hdr) - 2] = '\0'; | |
242 } | |
243 | |
244 sprintf(debug_buff,"%s [Len %d]\n", buf, strlen(buf)); | |
245 debug_print(debug_buff); | |
246 | |
247 | |
248 | |
249 if (olen < 0) | |
250 len = escape_message(buf); | |
251 else | |
252 len = olen; | |
253 hdr.ast = '*'; | |
254 hdr.type = type; | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
255 hdr.seqno = htons(gc->seqno++ & 0xffff); |
1 | 256 hdr.len = htons(len + (type == TYPE_SIGNON ? 0 : 1)); |
257 | |
258 sprintf(debug_buff,"Escaped message is '%s'\n",buf); | |
259 debug_print(debug_buff); | |
260 | |
261 memcpy(obuf, &hdr, sizeof(hdr)); | |
262 slen += sizeof(hdr); | |
263 memcpy(&obuf[slen], buf, len); | |
264 slen += len; | |
265 if (type != TYPE_SIGNON) { | |
266 obuf[slen]='\0'; | |
267 slen += 1; | |
268 } | |
269 print_buffer(obuf, slen); | |
270 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
271 return write(gc->toc_fd, obuf, slen); |
1 | 272 } |
273 | |
274 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
275 static int wait_reply(struct gaim_connection *gc, char *buffer, size_t buflen) |
1 | 276 { |
79 | 277 size_t res=-1; |
278 int read_rv = -1; | |
1 | 279 struct sflap_hdr *hdr=(struct sflap_hdr *)buffer; |
280 char *c; | |
281 | |
79 | 282 if(buflen < sizeof(struct sflap_hdr)) { |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
283 do_error_dialog(_("Unable to read from server: Buffer too small"), |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
284 _("Gaim - Error (internal)")); |
79 | 285 return -1; |
286 } | |
287 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
288 while((read_rv = read(gc->toc_fd, buffer, 1))) { |
79 | 289 if (read_rv < 0 || read_rv > 1) |
290 return -1; | |
1 | 291 if (buffer[0] == '*') |
292 break; | |
293 | |
294 } | |
295 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
296 read_rv = read(gc->toc_fd, buffer+1, sizeof(struct sflap_hdr) - 1); |
1 | 297 |
79 | 298 if (read_rv < 0) |
299 return read_rv; | |
1 | 300 |
79 | 301 res = read_rv + 1; |
1 | 302 |
303 | |
304 sprintf(debug_buff, "Rcv: %s %s\n",print_header(buffer), ""); | |
305 debug_print(debug_buff); | |
306 | |
307 | |
79 | 308 if(buflen < sizeof(struct sflap_hdr) + ntohs(hdr->len) + 1) { |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
309 do_error_dialog(_("Unable to read from server: Too much information"), |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
310 _("Gaim - Error (internal)")); |
79 | 311 return -1; |
312 } | |
1 | 313 |
314 while (res < (sizeof(struct sflap_hdr) + ntohs(hdr->len))) { | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
315 read_rv = read(gc->toc_fd, buffer + res, (ntohs(hdr->len) + sizeof(struct sflap_hdr)) - res); |
79 | 316 if(read_rv < 0) return read_rv; |
317 res += read_rv; | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
318 /* my feeling is this will kill us. if there's data pending then we'll come right back |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
319 * to where we are now. possible workarounds are to remove the input watcher until |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
320 * we're done with this part |
1 | 321 while(gtk_events_pending()) |
322 gtk_main_iteration(); | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
323 */ |
1 | 324 } |
325 | |
326 if (res >= sizeof(struct sflap_hdr)) | |
327 buffer[res]='\0'; | |
328 else | |
329 return res - sizeof(struct sflap_hdr); | |
330 | |
331 switch(hdr->type) { | |
332 case TYPE_SIGNON: | |
333 memcpy(&peer_ver, buffer + sizeof(struct sflap_hdr), 4); | |
334 peer_ver = ntohl(peer_ver); | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
335 gc->seqno = ntohs(hdr->seqno); |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
336 gc->state = STATE_SIGNON_REQUEST; |
1 | 337 break; |
338 case TYPE_DATA: | |
339 if (!strncasecmp(buffer + sizeof(struct sflap_hdr), "SIGN_ON:", strlen("SIGN_ON:"))) | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
340 gc->state = STATE_SIGNON_ACK; |
1 | 341 else if (!strncasecmp(buffer + sizeof(struct sflap_hdr), "CONFIG:", strlen("CONFIG:"))) { |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
342 gc->state = STATE_CONFIG; |
301
f905caee43ca
[gaim-migrate @ 311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
300
diff
changeset
|
343 } else if (!strncasecmp(buffer + sizeof(struct sflap_hdr), "ERROR:", strlen("ERROR:"))) { |
1 | 344 c = strtok(buffer + sizeof(struct sflap_hdr) + strlen("ERROR:"), ":"); |
345 show_error_dialog(c); | |
346 } | |
347 | |
348 sprintf(debug_buff, "Data: %s\n",buffer + sizeof(struct sflap_hdr)); | |
349 debug_print(debug_buff); | |
350 | |
351 break; | |
352 default: | |
353 sprintf(debug_buff, "Unknown/unimplemented packet type %d\n",hdr->type); | |
354 debug_print(debug_buff); | |
355 } | |
356 return res; | |
357 } | |
358 | |
359 | |
360 | |
361 void toc_callback( gpointer data, | |
362 gint source, | |
363 GdkInputCondition condition ) | |
364 { | |
365 char *buf; | |
366 char *c; | |
367 char *l; | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
368 struct gaim_connection *gc = (struct gaim_connection *)data; |
1 | 369 |
866
646acb9e9c38
[gaim-migrate @ 876]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
863
diff
changeset
|
370 buf = g_malloc(2 * BUF_LONG); |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
371 if (wait_reply(gc, buf, 2 * BUF_LONG) < 0) { |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
372 signoff(gc); /* this will free gc for us */ |
1 | 373 hide_login_progress("Connection Closed"); |
374 g_free(buf); | |
375 return; | |
376 } | |
377 | |
378 | |
379 c=strtok(buf+sizeof(struct sflap_hdr),":"); /* Ditch the first part */ | |
380 if (!strcasecmp(c,"UPDATE_BUDDY")) { | |
381 char *uc; | |
382 int logged, evil, idle, type = 0; | |
383 time_t signon; | |
384 time_t time_idle; | |
385 | |
386 c = strtok(NULL,":"); /* c is name */ | |
387 | |
388 l = strtok(NULL,":"); /* l is T/F logged status */ | |
389 | |
390 sscanf(strtok(NULL, ":"), "%d", &evil); | |
391 | |
392 sscanf(strtok(NULL, ":"), "%ld", &signon); | |
393 | |
394 sscanf(strtok(NULL, ":"), "%d", &idle); | |
395 | |
396 uc = strtok(NULL, ":"); | |
397 | |
398 | |
399 if (!strncasecmp(l,"T",1)) | |
400 logged = 1; | |
401 else | |
402 logged = 0; | |
403 | |
404 | |
405 if (uc[0] == 'A') | |
406 type |= UC_AOL; | |
407 | |
408 switch(uc[1]) { | |
409 case 'A': | |
410 type |= UC_ADMIN; | |
411 break; | |
412 case 'U': | |
413 type |= UC_UNCONFIRMED; | |
414 break; | |
415 case 'O': | |
416 type |= UC_NORMAL; | |
417 break; | |
418 default: | |
419 break; | |
420 } | |
421 | |
422 switch(uc[2]) { | |
423 case 'U': | |
424 type |= UC_UNAVAILABLE; | |
425 break; | |
426 default: | |
427 break; | |
428 } | |
429 | |
430 if (idle) { | |
431 time(&time_idle); | |
432 time_idle -= idle*60; | |
433 } else | |
434 time_idle = 0; | |
435 | |
513
eaddaa0dbbcb
[gaim-migrate @ 523]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
507
diff
changeset
|
436 serv_got_update(c, logged, evil, signon, time_idle, type, 0); |
1 | 437 |
300
b32c83750104
[gaim-migrate @ 310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
296
diff
changeset
|
438 } else if (!strcasecmp(c, "CONFIG")) { |
b32c83750104
[gaim-migrate @ 310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
296
diff
changeset
|
439 /* do we want to load the buddy list again here? */ |
318
35796808896a
[gaim-migrate @ 328]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
301
diff
changeset
|
440 c = strtok(NULL,":"); |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
441 parse_toc_buddy_list(gc, c, 0); |
1 | 442 } else if (!strcasecmp(c, "ERROR")) { |
301
f905caee43ca
[gaim-migrate @ 311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
300
diff
changeset
|
443 /* This should be handled by wait_reply |
1 | 444 c = strtok(NULL,":"); |
445 show_error_dialog(c); | |
301
f905caee43ca
[gaim-migrate @ 311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
300
diff
changeset
|
446 */ |
1 | 447 } else if (!strcasecmp(c, "NICK")) { |
448 c = strtok(NULL,":"); | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
449 g_snprintf(gc->username, sizeof(gc->username), "%s", c); |
1 | 450 } else if (!strcasecmp(c, "IM_IN")) { |
451 char *away, *message; | |
452 int a = 0; | |
453 | |
454 c = strtok(NULL,":"); | |
455 away = strtok(NULL,":"); | |
456 | |
457 message = away; | |
458 | |
459 while(*message && (*message != ':')) | |
460 message++; | |
461 | |
462 message++; | |
463 | |
464 if (!strncasecmp(away, "T", 1)) | |
465 a = 1; | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
466 serv_got_im(gc, c, message, a); |
1 | 467 |
468 } else if (!strcasecmp(c, "GOTO_URL")) { | |
469 char *name; | |
470 char *url; | |
471 | |
472 char tmp[256]; | |
473 | |
474 name = strtok(NULL, ":"); | |
475 url = strtok(NULL, ":"); | |
476 | |
477 | |
478 g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", toc_addy, aim_port, url); | |
479 /* fprintf(stdout, "Name: %s\n%s\n", name, url); | |
480 printf("%s", grab_url(tmp));*/ | |
481 g_show_info(tmp); | |
482 } else if (!strcasecmp(c, "EVILED")) { | |
483 int lev; | |
484 char *name = NULL; | |
485 | |
486 sscanf(strtok(NULL, ":"), "%d", &lev); | |
487 name = strtok(NULL, ":"); | |
488 | |
489 sprintf(debug_buff,"%s | %d\n", name, lev); | |
490 debug_print(debug_buff); | |
491 | |
492 serv_got_eviled(name, lev); | |
493 | |
494 } else if (!strcasecmp(c, "CHAT_JOIN")) { | |
495 char *name; | |
496 int id; | |
497 | |
498 | |
499 sscanf(strtok(NULL, ":"), "%d", &id); | |
500 name = strtok(NULL, ":"); | |
964
2cd7b73e2c9a
[gaim-migrate @ 974]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
960
diff
changeset
|
501 serv_got_joined_chat(gc, id, name); |
1 | 502 |
503 } else if (!strcasecmp(c, "DIR_STATUS")) { | |
149 | 504 } else if (!strcasecmp(c, "ADMIN_PASSWD_STATUS")) { |
505 do_error_dialog("Password Change Successeful", "Gaim - Password Change"); | |
1 | 506 } else if (!strcasecmp(c, "CHAT_UPDATE_BUDDY")) { |
507 int id; | |
508 char *in; | |
509 char *buddy; | |
964
2cd7b73e2c9a
[gaim-migrate @ 974]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
960
diff
changeset
|
510 GSList *bcs = gc->buddy_chats; |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
447
diff
changeset
|
511 struct conversation *b = NULL; |
1 | 512 |
513 sscanf(strtok(NULL, ":"), "%d", &id); | |
514 | |
515 in = strtok(NULL, ":"); | |
516 | |
517 while(bcs) { | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
447
diff
changeset
|
518 b = (struct conversation *)bcs->data; |
1 | 519 if (id == b->id) |
520 break; | |
521 bcs = bcs->next; | |
522 b = NULL; | |
523 } | |
524 | |
44 | 525 if (!b) { |
45 | 526 g_free(buf); |
1 | 527 return; |
44 | 528 } |
1 | 529 |
530 | |
531 if (!strcasecmp(in, "T")) { | |
532 while((buddy = strtok(NULL, ":")) != NULL) { | |
533 add_chat_buddy(b, buddy); | |
534 } | |
535 } else { | |
536 while((buddy = strtok(NULL, ":")) != NULL) { | |
537 remove_chat_buddy(b, buddy); | |
538 } | |
539 } | |
540 | |
541 } else if (!strcasecmp(c, "CHAT_LEFT")) { | |
542 int id; | |
543 | |
544 | |
545 sscanf(strtok(NULL, ":"), "%d", &id); | |
546 | |
964
2cd7b73e2c9a
[gaim-migrate @ 974]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
960
diff
changeset
|
547 serv_got_chat_left(gc, id); |
1 | 548 |
549 | |
550 } else if (!strcasecmp(c, "CHAT_IN")) { | |
551 | |
552 int id, w; | |
553 char *m; | |
554 char *who, *whisper; | |
555 | |
556 | |
557 sscanf(strtok(NULL, ":"), "%d", &id); | |
558 who = strtok(NULL, ":"); | |
559 whisper = strtok(NULL, ":"); | |
560 m = whisper; | |
561 while(*m && (*m != ':')) m++; | |
562 m++; | |
563 | |
564 if (!strcasecmp(whisper, "T")) | |
565 w = 1; | |
566 else | |
567 w = 0; | |
568 | |
964
2cd7b73e2c9a
[gaim-migrate @ 974]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
960
diff
changeset
|
569 serv_got_chat_in(gc, id, who, w, m); |
1 | 570 |
571 | |
572 } else if (!strcasecmp(c, "CHAT_INVITE")) { | |
573 char *name; | |
574 char *who; | |
575 char *message; | |
576 int id; | |
577 | |
578 | |
579 name = strtok(NULL, ":"); | |
580 sscanf(strtok(NULL, ":"), "%d", &id); | |
581 who = strtok(NULL, ":"); | |
582 message = strtok(NULL, ":"); | |
583 | |
964
2cd7b73e2c9a
[gaim-migrate @ 974]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
960
diff
changeset
|
584 serv_got_chat_invite(gc, name, id, who, message); |
1 | 585 |
586 | |
587 } else if (!strcasecmp(c, "RVOUS_PROPOSE")) { | |
588 char *user; | |
589 char *uuid; | |
590 char *cookie; | |
591 int seq; | |
592 char *rip, *pip, *vip; | |
593 int port; | |
594 int unk[4]; | |
595 char *messages[4]; | |
596 int subtype, files, totalsize; | |
597 char *name; | |
598 char *tmp; | |
599 int i; | |
600 struct file_transfer *ft; | |
601 | |
602 | |
603 user = strtok(NULL, ":"); | |
604 uuid = strtok(NULL, ":"); | |
605 cookie = strtok(NULL, ":"); | |
606 sscanf(strtok(NULL, ":"), "%d", &seq); | |
607 rip = strtok(NULL, ":"); | |
608 pip = strtok(NULL, ":"); | |
609 vip = strtok(NULL, ":"); | |
610 sscanf(strtok(NULL, ":"), "%d", &port); | |
611 | |
197
24f0fef56a73
[gaim-migrate @ 207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
196
diff
changeset
|
612 if (!strcmp(uuid, FILE_SEND_UID)) { |
196
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
613 /* we're getting a file */ |
211
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
614 for (i=0; i<4; i++) { |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
615 sscanf(strtok(NULL, ":"), "%d", &unk[i]); |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
616 if (unk[i] == 10001) |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
617 break; |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
618 messages[i] = frombase64(strtok(NULL, ":")); |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
619 } |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
620 tmp = frombase64(strtok(NULL, ":")); |
196
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
621 subtype = tmp[1]; |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
622 files = tmp[3]; /* These are fine */ |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
623 |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
624 totalsize = 0; |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
625 totalsize |= (tmp[4] << 24) & 0xff000000; |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
626 totalsize |= (tmp[5] << 16) & 0x00ff0000; |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
627 totalsize |= (tmp[6] << 8) & 0x0000ff00; |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
628 totalsize |= (tmp[7] << 0) & 0x000000ff; |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
629 |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
630 name = tmp + 8; |
1 | 631 |
196
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
632 ft = g_new0(struct file_transfer, 1); |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
633 |
198
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
634 ft->cookie = g_strdup(cookie); |
196
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
635 ft->ip = g_strdup(pip); |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
636 ft->port = port; |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
637 if (i) |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
638 ft->message = g_strdup(messages[0]); |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
639 else |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
640 ft->message = NULL; |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
641 ft->filename = g_strdup(name); |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
642 ft->user = g_strdup(user); |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
643 ft->size = totalsize; |
198
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
644 sprintf(ft->UID, "%s", FILE_SEND_UID); |
196
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
645 |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
646 g_free(tmp); |
1 | 647 |
196
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
648 for (i--; i >= 0; i--) |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
649 g_free(messages[i]); |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
650 |
507
d17547ff9c2a
[gaim-migrate @ 517]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
472
diff
changeset
|
651 if (totalsize) /* sanity check */ |
d17547ff9c2a
[gaim-migrate @ 517]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
472
diff
changeset
|
652 accept_file_dialog(ft); |
197
24f0fef56a73
[gaim-migrate @ 207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
196
diff
changeset
|
653 } else if (!strcmp(uuid, FILE_GET_UID)) { |
196
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
654 /* we're sending a file */ |
211
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
655 for (i=0; i<4; i++) { |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
656 sscanf(strtok(NULL, ":"), "%d", &unk[i]); |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
657 if (unk[i] == 10001) |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
658 break; |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
659 messages[i] = frombase64(strtok(NULL, ":")); |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
660 } |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
661 tmp = frombase64(strtok(NULL, ":")); |
198
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
662 ft = g_new0(struct file_transfer, 1); |
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
663 |
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
664 ft->cookie = g_strdup(cookie); |
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
665 ft->ip = g_strdup(pip); |
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
666 ft->port = port; |
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
667 if (i) |
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
668 ft->message = g_strdup(messages[0]); |
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
669 else |
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
670 ft->message = NULL; |
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
671 ft->user = g_strdup(user); |
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
672 sprintf(ft->UID, "%s", FILE_GET_UID); |
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
673 |
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
674 g_free(tmp); |
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
675 |
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
676 for (i--; i >= 0; i--) |
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
677 g_free(messages[i]); |
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
678 |
73e9a0bfff62
[gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
197
diff
changeset
|
679 accept_file_dialog(ft); |
369
cf895313fc50
[gaim-migrate @ 379]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
351
diff
changeset
|
680 } else if (!strcmp(uuid, VOICE_UID)) { |
cf895313fc50
[gaim-migrate @ 379]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
351
diff
changeset
|
681 /* oh goody. voice over ip. fun stuff. */ |
cf895313fc50
[gaim-migrate @ 379]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
351
diff
changeset
|
682 |
196
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
683 /* |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
684 } else if (!strcmp(uuid, B_ICON_UID)) { |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
685 } else if (!strcmp(uuid, IMAGE_UID)) { |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
686 */ |
1 | 687 |
196
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
688 } else { |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
689 sprintf(debug_buff,"don't know what to do with %s\n", |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
690 uuid); |
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
691 debug_print(debug_buff); |
211
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
692 tmp = g_malloc(BUF_LEN); |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
693 name = frombase64(cookie); |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
694 snprintf(tmp, BUF_LEN, "toc_rvous_cancel %s %s %s", |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
695 user, name, uuid); |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
696 sflap_send(gc, tmp, strlen(tmp), TYPE_DATA); |
211
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
697 free(name); |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
208
diff
changeset
|
698 free(tmp); |
196
3042e11c1902
[gaim-migrate @ 206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
194
diff
changeset
|
699 } |
1 | 700 } else { |
701 sprintf(debug_buff,"don't know what to do with %s\n", c); | |
702 debug_print(debug_buff); | |
703 } | |
704 g_free(buf); | |
705 } | |
706 | |
707 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
708 int toc_signon(struct gaim_connection *gc) |
1 | 709 { |
710 char buf[BUF_LONG]; | |
711 int res; | |
712 struct signon so; | |
713 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
714 sprintf(debug_buff,"State = %d\n", gc->state); |
1 | 715 debug_print(debug_buff); |
716 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
717 if ((res = write(gc->toc_fd, FLAPON, strlen(FLAPON))) < 0) |
1 | 718 return res; |
719 /* Wait for signon packet */ | |
720 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
721 gc->state = STATE_FLAPON; |
1 | 722 |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
723 if ((res = wait_reply(gc, buf, sizeof(buf)) < 0)) |
1 | 724 return res; |
725 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
726 if (gc->state != STATE_SIGNON_REQUEST) { |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
727 sprintf(debug_buff, "State should be %d, but is %d instead\n", STATE_SIGNON_REQUEST, gc->state); |
1 | 728 debug_print(debug_buff); |
729 return -1; | |
730 } | |
731 | |
732 /* Compose a response */ | |
733 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
734 g_snprintf(so.username, sizeof(so.username), "%s", gc->username); |
1 | 735 so.ver = ntohl(1); |
736 so.tag = ntohs(1); | |
737 so.namelen = htons(strlen(so.username)); | |
738 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
739 sflap_send(gc, (char *)&so, ntohs(so.namelen) + 8, TYPE_SIGNON); |
1 | 740 |
741 g_snprintf(buf, sizeof(buf), | |
742 "toc_signon %s %d %s %s %s \"%s\"", | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
743 login_host, login_port, normalize(gc->username), roast_password(gc->password), LANGUAGE, REVISION); |
1 | 744 |
745 sprintf(debug_buff,"Send: %s\n", buf); | |
746 debug_print(debug_buff); | |
747 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
748 return sflap_send(gc, buf, -1, TYPE_DATA); |
1 | 749 } |
750 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
751 int toc_wait_signon(struct gaim_connection *gc) |
1 | 752 { |
753 /* Wait for the SIGNON to be approved */ | |
351
22161278657c
[gaim-migrate @ 361]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
754 char buf[BUF_LONG]; |
1 | 755 int res; |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
756 res = wait_reply(gc, buf, sizeof(buf)); |
1 | 757 if (res < 0) |
758 return res; | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
759 if (gc->state != STATE_SIGNON_ACK) { |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
760 sprintf(debug_buff, "State should be %d, but is %d instead\n",STATE_SIGNON_ACK, gc->state); |
1 | 761 debug_print(debug_buff); |
762 return -1; | |
763 } | |
764 return 0; | |
765 } | |
766 | |
767 #ifdef _WIN32 | |
768 gint win32_read() | |
769 { | |
770 int ret; | |
771 struct fd_set fds; | |
772 struct timeval tv; | |
773 | |
774 FD_ZERO(&fds); | |
775 | |
776 tv.tv_sec = 0; | |
777 tv.tv_usec = 200; | |
778 | |
779 FD_SET(toc_fd, &fds); | |
780 | |
781 ret = select(toc_fd + 1, &fds, NULL, NULL, &tv); | |
782 | |
783 if (ret == 0) { | |
784 return TRUE; | |
785 } | |
786 | |
787 toc_callback(NULL, 0, (GdkInputCondition)0); | |
788 return TRUE; | |
789 } | |
790 #endif | |
791 | |
792 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
793 char *toc_wait_config(struct gaim_connection *gc) |
1 | 794 { |
795 /* Waits for configuration packet, returning the contents of the packet */ | |
351
22161278657c
[gaim-migrate @ 361]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
796 static char buf[BUF_LONG]; |
1 | 797 int res; |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
798 res = wait_reply(gc, buf, sizeof(buf)); |
1 | 799 if (res < 0) |
800 return NULL; | |
300
b32c83750104
[gaim-migrate @ 310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
296
diff
changeset
|
801 /* Apparently, the toc_config is optional. *VERY* Optional |
285 | 802 */ |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
803 if (gc->state != STATE_CONFIG) { |
300
b32c83750104
[gaim-migrate @ 310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
296
diff
changeset
|
804 res = 0; |
b32c83750104
[gaim-migrate @ 310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
296
diff
changeset
|
805 } else { |
b32c83750104
[gaim-migrate @ 310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
296
diff
changeset
|
806 res = 1; |
b32c83750104
[gaim-migrate @ 310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
296
diff
changeset
|
807 } |
1 | 808 /* At this point, it's time to setup automatic handling of incoming packets */ |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
809 gc->state = STATE_ONLINE; |
1 | 810 #ifdef _WIN32 |
300
b32c83750104
[gaim-migrate @ 310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
296
diff
changeset
|
811 win32_r = gtk_timeout_add(1000, (GtkFunction)win32_read, NULL); |
1 | 812 #else |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
813 gc->inpa = gdk_input_add(gc->toc_fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, toc_callback, gc); |
1 | 814 #endif |
300
b32c83750104
[gaim-migrate @ 310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
296
diff
changeset
|
815 if (res) |
b32c83750104
[gaim-migrate @ 310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
296
diff
changeset
|
816 return buf; |
b32c83750104
[gaim-migrate @ 310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
296
diff
changeset
|
817 else |
b32c83750104
[gaim-migrate @ 310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
296
diff
changeset
|
818 return NULL; |
1 | 819 } |
820 | |
710
efd72a117875
[gaim-migrate @ 720]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
681
diff
changeset
|
821 void toc_build_config(char *s, int len, gboolean show) |
1 | 822 { |
940 | 823 GSList *grp = groups; |
678
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
824 GList *mem; |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
825 struct group *g; |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
826 struct buddy *b; |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
827 GList *plist = permit; |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
828 GList *dlist = deny; |
1 | 829 |
678
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
830 int pos=0; |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
831 |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
832 if (!permdeny) |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
833 permdeny = 1; |
1 | 834 |
678
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
835 pos += g_snprintf(&s[pos], len - pos, "m %d\n", permdeny); |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
836 while(grp) { |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
837 g = (struct group *)grp->data; |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
838 pos += g_snprintf(&s[pos], len - pos, "g %s\n", g->name); |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
839 mem = g->members; |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
840 while(mem) { |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
841 b = (struct buddy *)mem->data; |
710
efd72a117875
[gaim-migrate @ 720]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
681
diff
changeset
|
842 pos += g_snprintf(&s[pos], len - pos, "b %s%s%s\n", b->name, |
efd72a117875
[gaim-migrate @ 720]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
681
diff
changeset
|
843 show ? ":" : "", show ? b->show : ""); |
678
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
844 mem = mem->next; |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
845 } |
940 | 846 grp = g_slist_next(grp); |
678
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
847 } |
1 | 848 |
678
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
849 while(plist) { |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
850 pos += g_snprintf(&s[pos], len - pos, "p %s\n", (char *)plist->data); |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
851 plist=plist->next; |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
852 } |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
853 |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
854 while(dlist) { |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
855 pos += g_snprintf(&s[pos], len - pos, "d %s\n", (char *)dlist->data); |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
856 dlist=dlist->next; |
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
676
diff
changeset
|
857 } |
1 | 858 } |
859 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
860 void parse_toc_buddy_list(struct gaim_connection *gc, char *config, int from_do_import) |
1 | 861 { |
862 char *c; | |
681
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
863 char current[256]; |
1 | 864 char *name; |
865 GList *bud; | |
228 | 866 int how_many = 0; |
867 | |
1 | 868 bud = NULL; |
869 | |
332
b573f33c5e0e
[gaim-migrate @ 342]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
318
diff
changeset
|
870 if (config != NULL) { |
b573f33c5e0e
[gaim-migrate @ 342]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
318
diff
changeset
|
871 |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
872 /* skip "CONFIG:" (if it exists)*/ |
681
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
873 c = strncmp(config + sizeof(struct sflap_hdr),"CONFIG:",strlen("CONFIG:"))? |
1 | 874 strtok(config, "\n"): |
875 strtok(config + sizeof(struct sflap_hdr)+strlen("CONFIG:"), "\n"); | |
681
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
876 do { |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
877 if (c == NULL) |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
878 break; |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
879 if (*c == 'g') { |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
880 strncpy(current,c+2, sizeof(current)); |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
881 add_group(current); |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
882 how_many++; |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
883 } else if (*c == 'b' && !find_buddy(c+2)) { |
710
efd72a117875
[gaim-migrate @ 720]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
681
diff
changeset
|
884 char nm[80], sw[80], *tmp = c+2; |
efd72a117875
[gaim-migrate @ 720]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
681
diff
changeset
|
885 int i = 0; |
efd72a117875
[gaim-migrate @ 720]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
681
diff
changeset
|
886 while (*tmp != ':' && *tmp) |
efd72a117875
[gaim-migrate @ 720]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
681
diff
changeset
|
887 nm[i++] = *tmp++; |
efd72a117875
[gaim-migrate @ 720]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
681
diff
changeset
|
888 if (*tmp == ':') *tmp++ = '\0'; |
efd72a117875
[gaim-migrate @ 720]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
681
diff
changeset
|
889 nm[i] = '\0'; |
efd72a117875
[gaim-migrate @ 720]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
681
diff
changeset
|
890 i = 0; |
efd72a117875
[gaim-migrate @ 720]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
681
diff
changeset
|
891 while (*tmp) sw[i++] = *tmp++; |
efd72a117875
[gaim-migrate @ 720]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
681
diff
changeset
|
892 sw[i] = '\0'; |
efd72a117875
[gaim-migrate @ 720]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
681
diff
changeset
|
893 if (!find_buddy(nm)) |
efd72a117875
[gaim-migrate @ 720]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
681
diff
changeset
|
894 add_buddy(current, nm, sw); |
681
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
895 how_many++; |
710
efd72a117875
[gaim-migrate @ 720]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
681
diff
changeset
|
896 |
681
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
897 bud = g_list_append(bud, c+2); |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
898 } else if (*c == 'p') { |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
899 GList *d = permit; |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
900 char *n; |
863
55194c5f338f
[gaim-migrate @ 873]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
793
diff
changeset
|
901 name = g_malloc(strlen(c+2) + 2); |
681
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
902 g_snprintf(name, strlen(c+2) + 1, "%s", c+2); |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
903 n = g_strdup(normalize(name)); |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
904 while (d) { |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
905 if (!strcasecmp(n, normalize(d->data))) |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
906 break; |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
907 d = d->next; |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
908 } |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
909 g_free(n); |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
910 if (!d) |
762
977048924ce1
[gaim-migrate @ 772]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
761
diff
changeset
|
911 permit = g_list_append(permit, name); |
681
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
912 } else if (*c == 'd') { |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
913 GList *d = deny; |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
914 char *n; |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
915 name = g_malloc(strlen(c+2) + 2); |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
916 g_snprintf(name, strlen(c+2) + 1, "%s", c+2); |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
917 n = g_strdup(normalize(name)); |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
918 while (d) { |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
919 if (!strcasecmp(n, normalize(d->data))) |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
920 break; |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
921 d = d->next; |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
922 } |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
923 g_free(n); |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
924 if (!d) |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
925 deny = g_list_append(deny, name); |
793
57cc66fbfa8e
[gaim-migrate @ 803]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
774
diff
changeset
|
926 } else if (!strncmp("toc", c, 3)) { |
57cc66fbfa8e
[gaim-migrate @ 803]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
774
diff
changeset
|
927 sscanf(c + strlen(c) - 1, "%d", &permdeny); |
57cc66fbfa8e
[gaim-migrate @ 803]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
774
diff
changeset
|
928 sprintf(debug_buff, "permdeny: %d\n", permdeny); |
57cc66fbfa8e
[gaim-migrate @ 803]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
774
diff
changeset
|
929 debug_print(debug_buff); |
57cc66fbfa8e
[gaim-migrate @ 803]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
774
diff
changeset
|
930 if (permdeny == 0) |
57cc66fbfa8e
[gaim-migrate @ 803]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
774
diff
changeset
|
931 permdeny = 1; |
57cc66fbfa8e
[gaim-migrate @ 803]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
774
diff
changeset
|
932 } else if (*c == 'm') { |
57cc66fbfa8e
[gaim-migrate @ 803]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
774
diff
changeset
|
933 sscanf(c + 2, "%d", &permdeny); |
57cc66fbfa8e
[gaim-migrate @ 803]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
774
diff
changeset
|
934 sprintf(debug_buff, "permdeny: %d\n", permdeny); |
57cc66fbfa8e
[gaim-migrate @ 803]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
774
diff
changeset
|
935 debug_print(debug_buff); |
681
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
936 if (permdeny == 0) |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
937 permdeny = 1; |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
938 } |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
939 } while((c=strtok(NULL,"\n"))); |
1 | 940 #if 0 |
681
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
941 fprintf(stdout, "Sending message '%s'\n",buf); |
1 | 942 #endif |
681
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
943 |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
944 if (bud != NULL) serv_add_buddies(bud); |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
945 serv_set_permit_deny(); |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
946 if (blist) { |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
947 build_edit_tree(); |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
948 build_permit_tree(); |
5422dbecd861
[gaim-migrate @ 691]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
678
diff
changeset
|
949 } |
332
b573f33c5e0e
[gaim-migrate @ 342]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
318
diff
changeset
|
950 } |
b573f33c5e0e
[gaim-migrate @ 342]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
318
diff
changeset
|
951 |
228 | 952 /* perhaps the server dropped the buddy list, try importing from |
953 cache */ | |
954 | |
296
a88b889b692b
[gaim-migrate @ 306]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
285
diff
changeset
|
955 if ( how_many == 0 && !from_do_import ) { |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
956 do_import( (GtkWidget *) NULL, gc ); |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
957 } else if ( gc && (bud_list_cache_exists(gc) == FALSE) ) { |
229 | 958 do_export( (GtkWidget *) NULL, 0 ); |
228 | 959 } |
1 | 960 } |