Mercurial > pidgin
annotate plugins/icq/udp.c @ 2025:1bfef3e8ba63
[gaim-migrate @ 2035]
woo
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 16 Jun 2001 01:14:43 +0000 |
parents | 7b3f1eb1ef7d |
children |
rev | line source |
---|---|
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
1152 | 2 |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
3 /* |
1977
7b3f1eb1ef7d
[gaim-migrate @ 1987]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1912
diff
changeset
|
4 * $Id: udp.c 1987 2001-06-09 14:46:51Z warmenhoven $ |
7b3f1eb1ef7d
[gaim-migrate @ 1987]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1912
diff
changeset
|
5 * |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
6 * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
7 * Bill Soudan <soudan@kde.org> |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
8 * |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
9 * This program is free software; you can redistribute it and/or modify |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
10 * it under the terms of the GNU General Public License as published by |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
11 * the Free Software Foundation; either version 2 of the License, or |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
12 * (at your option) any later version. |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
13 * |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
14 * This program is distributed in the hope that it will be useful, |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
17 * GNU General Public License for more details. |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
18 * |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
19 * You should have received a copy of the GNU General Public License |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
20 * along with this program; if not, write to the Free Software |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
22 * |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
23 */ |
1152 | 24 |
25 #ifdef _WIN32 | |
26 #include <winsock.h> | |
27 #endif | |
28 | |
29 #include <stdlib.h> | |
30 | |
31 #include "icqlib.h" | |
32 #include "udp.h" | |
33 #include "queue.h" | |
34 | |
35 #include "stdpackets.h" | |
36 #include "icqbyteorder.h" | |
37 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
38 #include "contacts.h" |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
39 |
1152 | 40 static const BYTE icq_UDPTable[] = { |
41 0x59, 0x60, 0x37, 0x6B, 0x65, 0x62, 0x46, 0x48, 0x53, 0x61, 0x4C, 0x59, 0x60, 0x57, 0x5B, 0x3D, | |
42 0x5E, 0x34, 0x6D, 0x36, 0x50, 0x3F, 0x6F, 0x67, 0x53, 0x61, 0x4C, 0x59, 0x40, 0x47, 0x63, 0x39, | |
43 0x50, 0x5F, 0x5F, 0x3F, 0x6F, 0x47, 0x43, 0x69, 0x48, 0x33, 0x31, 0x64, 0x35, 0x5A, 0x4A, 0x42, | |
44 0x56, 0x40, 0x67, 0x53, 0x41, 0x07, 0x6C, 0x49, 0x58, 0x3B, 0x4D, 0x46, 0x68, 0x43, 0x69, 0x48, | |
45 0x33, 0x31, 0x44, 0x65, 0x62, 0x46, 0x48, 0x53, 0x41, 0x07, 0x6C, 0x69, 0x48, 0x33, 0x51, 0x54, | |
46 0x5D, 0x4E, 0x6C, 0x49, 0x38, 0x4B, 0x55, 0x4A, 0x62, 0x46, 0x48, 0x33, 0x51, 0x34, 0x6D, 0x36, | |
47 0x50, 0x5F, 0x5F, 0x5F, 0x3F, 0x6F, 0x47, 0x63, 0x59, 0x40, 0x67, 0x33, 0x31, 0x64, 0x35, 0x5A, | |
48 0x6A, 0x52, 0x6E, 0x3C, 0x51, 0x34, 0x6D, 0x36, 0x50, 0x5F, 0x5F, 0x3F, 0x4F, 0x37, 0x4B, 0x35, | |
49 0x5A, 0x4A, 0x62, 0x66, 0x58, 0x3B, 0x4D, 0x66, 0x58, 0x5B, 0x5D, 0x4E, 0x6C, 0x49, 0x58, 0x3B, | |
50 0x4D, 0x66, 0x58, 0x3B, 0x4D, 0x46, 0x48, 0x53, 0x61, 0x4C, 0x59, 0x40, 0x67, 0x33, 0x31, 0x64, | |
51 0x55, 0x6A, 0x32, 0x3E, 0x44, 0x45, 0x52, 0x6E, 0x3C, 0x31, 0x64, 0x55, 0x6A, 0x52, 0x4E, 0x6C, | |
52 0x69, 0x48, 0x53, 0x61, 0x4C, 0x39, 0x30, 0x6F, 0x47, 0x63, 0x59, 0x60, 0x57, 0x5B, 0x3D, 0x3E, | |
53 0x64, 0x35, 0x3A, 0x3A, 0x5A, 0x6A, 0x52, 0x4E, 0x6C, 0x69, 0x48, 0x53, 0x61, 0x6C, 0x49, 0x58, | |
54 0x3B, 0x4D, 0x46, 0x68, 0x63, 0x39, 0x50, 0x5F, 0x5F, 0x3F, 0x6F, 0x67, 0x53, 0x41, 0x25, 0x41, | |
55 0x3C, 0x51, 0x54, 0x3D, 0x5E, 0x54, 0x5D, 0x4E, 0x4C, 0x39, 0x50, 0x5F, 0x5F, 0x5F, 0x3F, 0x6F, | |
56 0x47, 0x43, 0x69, 0x48, 0x33, 0x51, 0x54, 0x5D, 0x6E, 0x3C, 0x31, 0x64, 0x35, 0x5A, 0x00, 0x00, | |
57 }; | |
58 | |
1525
ba8e6e211af5
[gaim-migrate @ 1535]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1498
diff
changeset
|
59 DWORD icq_UDPCalculateCheckCode(icq_Packet *p) |
1152 | 60 { |
61 DWORD num1, num2; | |
62 DWORD r1,r2; | |
63 | |
64 num1 = p->data[8]; | |
65 num1 <<= 8; | |
66 num1 += p->data[4]; | |
67 num1 <<= 8; | |
68 num1 += p->data[2]; | |
69 num1 <<= 8; | |
70 num1 += p->data[6]; | |
71 | |
72 r1 = 0x18 + (rand() % (p->length - 0x18)); | |
73 r2 = rand() & 0xff; | |
74 | |
75 num2 = r1; | |
76 num2 <<= 8; | |
77 num2 += p->data[r1]; | |
78 num2 <<= 8; | |
79 num2 += r2; | |
80 num2 <<= 8; | |
81 num2 += icq_UDPTable[r2]; | |
82 num2 ^= 0xFF00FF; | |
83 | |
1525
ba8e6e211af5
[gaim-migrate @ 1535]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1498
diff
changeset
|
84 return num1 ^ num2; |
1152 | 85 } |
86 | |
87 DWORD icq_UDPScramble(DWORD cc) | |
88 { | |
89 DWORD a[5]; | |
90 | |
91 a[0] = cc & 0x0000001F; | |
92 a[1] = cc & 0x03E003E0; | |
93 a[2] = cc & 0xF8000400; | |
94 a[3] = cc & 0x0000F800; | |
95 a[4] = cc & 0x041F0000; | |
96 | |
97 a[0] <<= 0x0C; | |
98 a[1] <<= 0x01; | |
99 a[2] >>= 0x0A; | |
100 a[3] <<= 0x10; | |
101 a[4] >>= 0x0F; | |
102 | |
103 return a[0] + a[1] + a[2] + a[3] + a[4]; | |
104 } | |
105 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
106 void icq_UDPEncode(icq_Packet *p, char *buffer) |
1152 | 107 { |
1525
ba8e6e211af5
[gaim-migrate @ 1535]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1498
diff
changeset
|
108 DWORD checkcode = icq_UDPCalculateCheckCode(p); |
1152 | 109 DWORD code1, code2, code3; |
110 DWORD pos; | |
111 | |
1525
ba8e6e211af5
[gaim-migrate @ 1535]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1498
diff
changeset
|
112 memcpy(buffer, p->data, p->length); |
ba8e6e211af5
[gaim-migrate @ 1535]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1498
diff
changeset
|
113 |
ba8e6e211af5
[gaim-migrate @ 1535]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1498
diff
changeset
|
114 *(DWORD *)(buffer+0x14)=htoicql(checkcode); |
1152 | 115 code1 = p->length * 0x68656c6cL; |
116 code2 = code1 + checkcode; | |
117 pos = 0x0A; | |
118 | |
119 for(; pos < p->length; pos+=4) | |
120 { | |
1525
ba8e6e211af5
[gaim-migrate @ 1535]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1498
diff
changeset
|
121 DWORD data = icqtohl(*(DWORD *)((p->data)+pos)); |
1152 | 122 code3 = code2 + icq_UDPTable[pos & 0xFF]; |
123 data ^= code3; | |
1525
ba8e6e211af5
[gaim-migrate @ 1535]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1498
diff
changeset
|
124 *(DWORD*)(buffer+pos)=htoicql(data); |
1152 | 125 } |
126 checkcode = icq_UDPScramble(checkcode); | |
1525
ba8e6e211af5
[gaim-migrate @ 1535]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1498
diff
changeset
|
127 *(DWORD *)(buffer+0x14)=htoicql(checkcode); |
1152 | 128 } |
129 | |
130 /********************************************************* | |
131 icq_UDPSockWrite and icq_UDPSockRead are for _UDP_ packets | |
132 proxy support for TCP sockets is different! | |
133 *********************************************************/ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
134 int icq_UDPSockWriteDirect(icq_Link *icqlink, icq_Packet *p) |
1152 | 135 { |
1525
ba8e6e211af5
[gaim-migrate @ 1535]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1498
diff
changeset
|
136 char tmpbuf[ICQ_PACKET_DATA_SIZE+10]; |
1152 | 137 |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
138 if(icqlink->icq_UDPSok <= 3) |
1152 | 139 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
140 icq_FmtLog(icqlink, ICQ_LOG_ERROR, "Bad socket!\n"); |
1152 | 141 return -1; |
142 } | |
143 | |
1525
ba8e6e211af5
[gaim-migrate @ 1535]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1498
diff
changeset
|
144 icq_UDPEncode(p, tmpbuf+10); |
ba8e6e211af5
[gaim-migrate @ 1535]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1498
diff
changeset
|
145 |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
146 if(!icqlink->icq_UseProxy) |
1152 | 147 { |
148 #ifdef _WIN32 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
149 return send(icqlink->icq_UDPSok, tmpbuf+10, p->length, 0); |
1152 | 150 #else |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
151 return write(icqlink->icq_UDPSok, tmpbuf+10, p->length); |
1152 | 152 #endif |
153 } | |
154 else | |
155 { | |
156 tmpbuf[0] = 0; /* reserved */ | |
157 tmpbuf[1] = 0; /* reserved */ | |
158 tmpbuf[2] = 0; /* standalone packet */ | |
159 tmpbuf[3] = 1; /* address type IP v4 */ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
160 *(unsigned long*)&tmpbuf[4] = htonl(icqlink->icq_ProxyDestIP); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
161 *(unsigned short*)&tmpbuf[8] = htons(icqlink->icq_ProxyDestPort); |
1152 | 162 #ifdef _WIN32 |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
163 return send(icqlink->icq_UDPSok, tmpbuf, p->length+10, 0)-10; |
1152 | 164 #else |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
165 return write(icqlink->icq_UDPSok, tmpbuf, p->length+10)-10; |
1152 | 166 #endif |
167 } | |
168 } | |
169 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
170 int icq_UDPSockWrite(icq_Link *icqlink, icq_Packet *p) |
1152 | 171 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
172 icq_UDPQueuePut(icqlink, p); |
1498
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
173 |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
174 return icq_UDPSockWriteDirect(icqlink, p); |
1152 | 175 } |
176 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
177 int icq_UDPSockRead(icq_Link *icqlink, icq_Packet *p) |
1152 | 178 { |
179 int res; | |
180 char tmpbuf[ICQ_PACKET_DATA_SIZE]; | |
181 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
182 if(!icqlink->icq_UseProxy) |
1152 | 183 { |
184 #ifdef _WIN32 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
185 res = recv(icqlink->icq_UDPSok, p->data, ICQ_PACKET_DATA_SIZE, 0); |
1152 | 186 #else |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
187 res = read(icqlink->icq_UDPSok, p->data, ICQ_PACKET_DATA_SIZE); |
1152 | 188 #endif |
189 p->length = res; | |
190 return res; | |
191 } | |
192 else | |
193 { | |
194 #ifdef _WIN32 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
195 res = recv(icqlink->icq_UDPSok, tmpbuf, ICQ_PACKET_DATA_SIZE, 0); |
1152 | 196 #else |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
197 res = read(icqlink->icq_UDPSok, tmpbuf, ICQ_PACKET_DATA_SIZE); |
1152 | 198 #endif |
199 if(res<0) | |
200 return res; | |
201 memcpy(p->data, &tmpbuf[10], res-10); | |
202 p->length = res-10; | |
203 return res-10; | |
204 } | |
205 } | |
206 | |
207 /**************************************** | |
208 This must be called every 2 min. | |
209 so the server knows we're still alive. | |
210 JAVA client sends two different commands | |
211 so we do also :) | |
212 *****************************************/ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
213 WORD icq_KeepAlive(icq_Link *icqlink) /* V5 */ |
1152 | 214 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
215 icq_Packet *p = icq_UDPCreateStdSeqPacket(icqlink, UDP_CMD_KEEP_ALIVE, icqlink->d->icq_UDPSeqNum1++); |
1152 | 216 icq_PacketAppend32(p, rand()); |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
217 icq_UDPSockWriteDirect(icqlink, p); /* don't queue keep alive packets! */ |
1152 | 218 icq_PacketDelete(p); |
219 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
220 icq_FmtLog(icqlink, ICQ_LOG_MESSAGE, "Send Keep Alive packet to the server\n"); |
1152 | 221 |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
222 return icqlink->d->icq_UDPSeqNum1-1; |
1152 | 223 } |
224 | |
225 /********************************** | |
226 This must be called to remove | |
227 messages from the server | |
228 ***********************************/ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
229 void icq_SendGotMessages(icq_Link *icqlink) /* V5 */ |
1152 | 230 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
231 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_ACK_MESSAGES); |
1152 | 232 icq_PacketAppend32(p, rand()); |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
233 icq_UDPSockWrite(icqlink, p); |
1152 | 234 } |
235 | |
236 /************************************* | |
237 this sends over the contact list | |
238 *************************************/ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
239 void icq_SendContactList(icq_Link *icqlink) /* V5 */ |
1152 | 240 { |
241 char num_used; | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
242 icq_ContactItem *ptr = icq_ContactGetFirst(icqlink); |
1152 | 243 |
244 while(ptr) | |
245 { | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
246 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_CONT_LIST); |
1152 | 247 |
248 num_used = 0; | |
249 icq_PacketAdvance(p,1); | |
250 while(ptr && num_used<64) | |
251 { | |
252 icq_PacketAppend32(p, ptr->uin); | |
253 num_used++; | |
254 ptr = icq_ContactGetNext(ptr); | |
255 } | |
256 icq_PacketGotoUDPOutData(p, 0); | |
257 icq_PacketAppend8(p, num_used); | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
258 icq_UDPSockWrite(icqlink, p); |
1152 | 259 } |
260 } | |
261 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
262 void icq_SendNewUser(icq_Link *icqlink, unsigned long uin) /* V5 */ |
1152 | 263 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
264 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_ADD_TO_LIST); |
1152 | 265 icq_PacketAppend32(p, uin); |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
266 icq_UDPSockWrite(icqlink, p); |
1152 | 267 } |
268 | |
269 /************************************* | |
270 this sends over the visible list | |
271 that allows certain users to see you | |
272 if you're invisible. | |
273 *************************************/ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
274 void icq_SendVisibleList(icq_Link *icqlink) /* V5 */ |
1152 | 275 { |
276 char num_used; | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
277 icq_ContactItem *ptr = icq_ContactGetFirst(icqlink); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
278 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_VIS_LIST); |
1152 | 279 |
280 num_used = 0; | |
281 icq_PacketAdvance(p,1); | |
282 while(ptr) | |
283 { | |
284 if(ptr->vis_list) | |
285 { | |
286 icq_PacketAppend32(p, ptr->uin); | |
287 num_used++; | |
288 } | |
289 ptr = icq_ContactGetNext(ptr); | |
290 } | |
291 if(num_used != 0) | |
292 { | |
293 icq_PacketGotoUDPOutData(p, 0); | |
294 icq_PacketAppend8(p, num_used); | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
295 icq_UDPSockWrite(icqlink, p); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
296 } |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
297 else |
1498
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
298 icq_PacketDelete(p); |
1152 | 299 } |
300 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
301 void icq_SendInvisibleList(icq_Link *icqlink) /* V5 */ |
1152 | 302 { |
303 char num_used; | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
304 icq_ContactItem *ptr = icq_ContactGetFirst(icqlink); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
305 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_INVIS_LIST); |
1152 | 306 |
307 num_used = 0; | |
308 icq_PacketAdvance(p,1); | |
309 while(ptr) | |
310 { | |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
311 if(ptr->invis_list) |
1152 | 312 { |
313 icq_PacketAppend32(p, ptr->uin); | |
314 num_used++; | |
315 } | |
316 ptr = icq_ContactGetNext(ptr); | |
317 } | |
318 if(num_used != 0) | |
319 { | |
320 icq_PacketGotoUDPOutData(p, 0); | |
321 icq_PacketAppend8(p, num_used); | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
322 icq_UDPSockWrite(icqlink, p); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
323 } |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
324 else |
1498
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
325 icq_PacketDelete(p); |
1152 | 326 } |
327 | |
328 /************************************** | |
329 This sends the second login command | |
330 this is necessary to finish logging in. | |
331 ***************************************/ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
332 void icq_SendLogin1(icq_Link *icqlink) /* V5 */ |
1152 | 333 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
334 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_LOGIN_1); |
1152 | 335 icq_PacketAppend32(p, rand()); |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
336 icq_UDPSockWrite(icqlink, p); |
1152 | 337 } |
338 | |
339 /************************************ | |
340 This procedure logins into the server with icq_Uin and pass | |
341 on the socket icq_Sok and gives our ip and port. | |
342 It does NOT wait for any kind of a response. | |
343 *************************************/ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
344 void icq_Login(icq_Link *icqlink, DWORD status) /* V5 */ |
1152 | 345 { |
346 icq_Packet *p; | |
347 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
348 memset(icqlink->d->icq_UDPServMess, FALSE, sizeof(icqlink->d->icq_UDPServMess)); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
349 icqlink->d->icq_UDPSession = rand() & 0x3FFFFFFF; |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
350 icqlink->d->icq_UDPSeqNum1 = rand() & 0x7FFF; |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
351 icqlink->d->icq_UDPSeqNum2 = 1; |
1152 | 352 |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
353 p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_LOGIN); |
1152 | 354 icq_PacketAppend32(p, time(0L)); |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
355 icq_PacketAppend32n(p, icqlink->icq_TCPSrvPort); |
1152 | 356 /*icq_PacketAppend16(p, 0); |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
357 icq_PacketAppend16n(p, htons(icqlink->icq_OurPort));*/ |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
358 icq_PacketAppendString(p, icqlink->icq_Password); |
1152 | 359 icq_PacketAppend32(p, LOGIN_X1_DEF); |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
360 if(icqlink->icq_UseTCP) |
1309
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
361 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
362 if(icqlink->icq_UseProxy) |
1309
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
363 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
364 icq_PacketAppend32n(p, htonl(icqlink->icq_ProxyIP)); |
1309
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
365 icq_PacketAppend8(p, LOGIN_SNDONLY_TCP); |
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
366 } |
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
367 else |
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
368 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
369 icq_PacketAppend32n(p, htonl(icqlink->icq_OurIP)); |
1309
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
370 icq_PacketAppend8(p, LOGIN_SNDRCV_TCP); |
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
371 } |
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
372 } |
1152 | 373 else |
1309
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
374 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
375 icq_PacketAppend32n(p, htonl(icqlink->icq_ProxyIP)); |
1309
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
376 icq_PacketAppend8(p, LOGIN_NO_TCP); |
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
377 } |
1152 | 378 icq_PacketAppend32(p, status); |
379 icq_PacketAppend32(p, LOGIN_X3_DEF); | |
380 icq_PacketAppend32(p, LOGIN_X4_DEF); | |
381 icq_PacketAppend32(p, LOGIN_X5_DEF); | |
382 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
383 icq_UDPSockWrite(icqlink, p); |
1152 | 384 } |
385 | |
386 /********************** | |
387 Logs off ICQ | |
388 ***********************/ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
389 void icq_Logout(icq_Link *icqlink) /* V5 */ |
1152 | 390 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
391 icq_Packet *p = icq_UDPCreateStdSeqPacket(icqlink, UDP_CMD_SEND_TEXT_CODE, icqlink->d->icq_UDPSeqNum1++); |
1152 | 392 icq_PacketAppendString(p, "B_USER_DISCONNECTED"); |
393 icq_PacketAppend8(p, 5); | |
394 icq_PacketAppend8(p, 0); | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
395 icq_UDPSockWriteDirect(icqlink, p); /* don't queue */ |
1152 | 396 icq_PacketDelete(p); |
397 } | |
398 | |
399 /******************************* | |
400 This routine sends the aknowlegement cmd to the | |
401 server it appears that this must be done after | |
402 everything the server sends us | |
403 *******************************/ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
404 void icq_UDPAck(icq_Link *icqlink, int seq) /* V5 */ |
1152 | 405 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
406 icq_Packet *p = icq_UDPCreateStdSeqPacket(icqlink, UDP_CMD_ACK, seq); |
1152 | 407 icq_PacketAppend32(p, rand()); |
408 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
409 icq_FmtLog(icqlink, ICQ_LOG_MESSAGE, "Acking\n"); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
410 icq_UDPSockWriteDirect(icqlink, p); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
411 icq_PacketDelete(p); |
1152 | 412 } |
413 | |
414 /*************************************************** | |
415 Sends a message thru the server to uin. Text is the | |
416 message to send. | |
417 ***************************************************/ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
418 WORD icq_UDPSendMessage(icq_Link *icqlink, DWORD uin, const char *text) /* V5 */ |
1152 | 419 { |
1977
7b3f1eb1ef7d
[gaim-migrate @ 1987]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1912
diff
changeset
|
420 char buf[ICQ_MAX_UDP_MESSAGE_SIZE]; |
1152 | 421 icq_Packet *p; |
422 | |
1977
7b3f1eb1ef7d
[gaim-migrate @ 1987]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1912
diff
changeset
|
423 strncpy(buf, text, sizeof(buf)); |
7b3f1eb1ef7d
[gaim-migrate @ 1987]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1912
diff
changeset
|
424 buf[sizeof(buf)-1] = 0; |
1152 | 425 icq_RusConv("kw", buf); |
426 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
427 p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_SEND_THRU_SRV); |
1152 | 428 icq_PacketAppend32(p, uin); |
429 icq_PacketAppend16(p, TYPE_MSG); | |
430 icq_PacketAppendString(p, buf); | |
431 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
432 icq_UDPSockWrite(icqlink, p); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
433 return icqlink->d->icq_UDPSeqNum1-1; |
1152 | 434 } |
435 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
436 WORD icq_UDPSendURL(icq_Link *icqlink, DWORD uin, const char *url, const char *descr) /* V5 */ |
1152 | 437 { |
1977
7b3f1eb1ef7d
[gaim-migrate @ 1987]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1912
diff
changeset
|
438 char buf1[ICQ_MAX_UDP_MESSAGE_SIZE], buf2[ICQ_MAX_UDP_MESSAGE_SIZE]; |
1152 | 439 icq_Packet *p; |
440 | |
1977
7b3f1eb1ef7d
[gaim-migrate @ 1987]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1912
diff
changeset
|
441 strncpy(buf1, descr, sizeof(buf1)); |
7b3f1eb1ef7d
[gaim-migrate @ 1987]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1912
diff
changeset
|
442 buf1[sizeof(buf1)-1] = 0; |
1152 | 443 icq_RusConv("kw", buf1); |
1977
7b3f1eb1ef7d
[gaim-migrate @ 1987]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1912
diff
changeset
|
444 strncpy(buf2, url, sizeof(buf2)); |
7b3f1eb1ef7d
[gaim-migrate @ 1987]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1912
diff
changeset
|
445 buf2[sizeof(buf2)-1] = 0; |
1152 | 446 |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
447 p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_SEND_THRU_SRV); |
1152 | 448 icq_PacketAppend32(p, uin); |
449 icq_PacketAppend16(p, TYPE_URL); | |
450 icq_PacketAppend16(p, strlen(buf1)+strlen(buf2)+2); /* length + the NULL + 0xFE delimiter */ | |
451 icq_PacketAppendStringFE(p, buf1); | |
452 icq_PacketAppendString0(p, buf2); | |
453 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
454 icq_UDPSockWrite(icqlink, p); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
455 return icqlink->d->icq_UDPSeqNum1-1; |
1152 | 456 } |
457 | |
458 /************************************************** | |
459 Sends a authorization to the server so the Mirabilis | |
460 client can add the user. | |
461 ***************************************************/ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
462 WORD icq_SendAuthMsg(icq_Link *icqlink, DWORD uin) /* V5 */ |
1152 | 463 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
464 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_SEND_THRU_SRV); |
1152 | 465 icq_PacketAppend32(p, uin); |
466 icq_PacketAppend32(p, TYPE_AUTH); | |
467 icq_PacketAppend16(p, 0); | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
468 icq_UDPSockWrite(icqlink, p); |
1152 | 469 |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
470 return icqlink->d->icq_UDPSeqNum1-1; |
1152 | 471 } |
472 | |
473 /************************************************** | |
474 Changes the users status on the server | |
475 ***************************************************/ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
476 void icq_ChangeStatus(icq_Link *icqlink, DWORD status) /* V5 */ |
1152 | 477 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
478 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_STATUS_CHANGE); |
1152 | 479 icq_PacketAppend32(p, status); |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
480 icqlink->icq_Status = status; |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
481 icq_UDPSockWrite(icqlink, p); |
1152 | 482 } |
483 | |
484 /******************************************************** | |
485 Sends a request to the server for info on a specific user | |
486 *********************************************************/ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
487 WORD icq_SendInfoReq(icq_Link *icqlink, DWORD uin) /* V5 */ |
1152 | 488 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
489 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_INFO_REQ); |
1152 | 490 icq_PacketAppend32(p, uin); |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
491 icq_UDPSockWrite(icqlink, p); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
492 return icqlink->d->icq_UDPSeqNum1-1; |
1152 | 493 } |
494 | |
495 /******************************************************** | |
496 Sends a request to the server for info on a specific user | |
497 *********************************************************/ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
498 WORD icq_SendExtInfoReq(icq_Link *icqlink, DWORD uin) /* V5 */ |
1152 | 499 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
500 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_EXT_INFO_REQ); |
1152 | 501 icq_PacketAppend32(p, uin); |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
502 icq_UDPSockWrite(icqlink, p); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
503 return icqlink->d->icq_UDPSeqNum1-1; |
1152 | 504 } |
505 | |
506 /************************************************************** | |
507 Initializes a server search for the information specified | |
508 ***************************************************************/ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
509 void icq_SendSearchReq(icq_Link *icqlink, const char *email, const char *nick, const char *first, |
1152 | 510 const char *last) /* V5 */ |
511 { | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
512 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_SEARCH_USER); |
1152 | 513 icq_PacketAppendString(p, nick); |
514 icq_PacketAppendString(p, first); | |
515 icq_PacketAppendString(p, last); | |
516 icq_PacketAppendString(p, email); | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
517 icq_UDPSockWrite(icqlink, p); |
1152 | 518 } |
519 | |
520 /************************************************************** | |
521 Initializes a server search for the information specified | |
522 ***************************************************************/ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
523 void icq_SendSearchUINReq(icq_Link *icqlink, DWORD uin) /* V5 */ |
1152 | 524 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
525 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_SEARCH_UIN); |
1152 | 526 icq_PacketAppend32(p, uin); |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
527 icq_UDPSockWrite(icqlink, p); |
1152 | 528 } |
529 | |
530 /************************************************** | |
531 Registers a new uin in the ICQ network | |
532 ***************************************************/ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
533 void icq_RegNewUser(icq_Link *icqlink, const char *pass) /* V5 */ |
1152 | 534 { |
535 char pass8[9]; | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
536 icq_Packet *p = icq_UDPCreateStdSeqPacket(icqlink, UDP_CMD_REG_NEW_USER, icqlink->d->icq_UDPSeqNum1++); |
1152 | 537 strncpy(pass8, pass, 8); |
538 icq_PacketAppendString(p, pass8); | |
539 icq_PacketAppend32(p, 0xA0); | |
540 icq_PacketAppend32(p, 0x2461); | |
541 icq_PacketAppend32(p, 0xA00000); | |
542 icq_PacketAppend32(p, 0x00); | |
543 icq_PacketGoto(p, 6); | |
544 icq_PacketAppend32(p, 0); | |
545 icq_PacketAppend32(p, rand()); | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
546 icq_UDPSockWrite(icqlink, p); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
547 icq_FmtLog(icqlink, ICQ_LOG_MESSAGE, "Send RegNewUser packet to the server\n"); |
1152 | 548 } |
549 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
550 WORD icq_UpdateUserInfo(icq_Link *icqlink, const char *nick, const char *first, const char *last, |
1152 | 551 const char *email) /* V5 */ |
552 { | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
553 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_UPDATE_INFO); |
1152 | 554 icq_PacketAppendString(p, nick); |
555 icq_PacketAppendString(p, first); | |
556 icq_PacketAppendString(p, last); | |
557 icq_PacketAppendString(p, email); | |
558 /* auth (byte)? */ | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
559 icq_UDPSockWrite(icqlink, p); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
560 return icqlink->d->icq_UDPSeqNum1-1; |
1152 | 561 } |
562 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
563 WORD icq_UpdateAuthInfo(icq_Link *icqlink, DWORD auth) /* V5 */ |
1152 | 564 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
565 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_UPDATE_AUTH); |
1152 | 566 icq_PacketAppend32(p, auth); /* NOT auth? */ |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
567 icq_UDPSockWrite(icqlink, p); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
568 return icqlink->d->icq_UDPSeqNum1-1; |
1152 | 569 } |
570 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
571 WORD icq_UpdateMetaInfoSet(icq_Link *icqlink, const char *nick, const char *first, const char *last, |
1152 | 572 const char *email, const char *email2, const char *email3, |
573 const char *city, const char *state, const char *phone, const char *fax, | |
574 const char *street, const char *cellular, unsigned long zip, | |
575 unsigned short cnt_code, unsigned char cnt_stat, unsigned char emailhide) | |
576 { | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
577 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_META_USER); |
1152 | 578 icq_PacketAppend16(p, META_CMD_SET_INFO); |
579 icq_PacketAppendString(p, nick); | |
580 icq_PacketAppendString(p, first); | |
581 icq_PacketAppendString(p, last); | |
582 icq_PacketAppendString(p, email); | |
583 icq_PacketAppendString(p, email2); | |
584 icq_PacketAppendString(p, email3); | |
585 icq_PacketAppendString(p, city); | |
586 icq_PacketAppendString(p, state); | |
587 icq_PacketAppendString(p, phone); | |
588 icq_PacketAppendString(p, fax); | |
589 icq_PacketAppendString(p, street); | |
590 icq_PacketAppendString(p, cellular); | |
591 icq_PacketAppend32(p, zip); | |
592 icq_PacketAppend16(p, cnt_code); | |
593 icq_PacketAppend8(p, cnt_stat); | |
594 icq_PacketAppend8(p, emailhide); | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
595 icq_UDPSockWrite(icqlink, p); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
596 return icqlink->d->icq_UDPSeqNum2-1; |
1152 | 597 } |
598 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
599 WORD icq_UpdateMetaInfoHomepage(icq_Link *icqlink, unsigned char age, const char *homepage, |
1152 | 600 unsigned char year, unsigned char month, unsigned char day, |
601 unsigned char lang1, unsigned char lang2, unsigned char lang3) | |
602 { | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
603 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_META_USER); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
604 (void)lang1; |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
605 (void)lang2; |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
606 (void)lang3; |
1152 | 607 icq_PacketAppend16(p, META_CMD_SET_HOMEPAGE); |
608 icq_PacketAppend8(p, age); | |
609 icq_PacketAppend16(p, 0x0200); | |
610 icq_PacketAppendString(p, homepage); | |
611 icq_PacketAppend8(p, year); | |
612 icq_PacketAppend8(p, month); | |
613 icq_PacketAppend8(p, day); | |
614 icq_PacketAppend8(p, 0xFF /* lang1 */); | |
615 icq_PacketAppend8(p, 0xFF /* lang2 */); | |
616 icq_PacketAppend8(p, 0xFF /* lang3 */); | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
617 icq_UDPSockWrite(icqlink, p); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
618 return icqlink->d->icq_UDPSeqNum2-1; |
1152 | 619 } |
620 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
621 WORD icq_UpdateMetaInfoAbout(icq_Link *icqlink, const char *about) |
1152 | 622 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
623 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_META_USER); |
1152 | 624 icq_PacketAppend16(p, META_CMD_SET_ABOUT); |
625 icq_PacketAppendString(p, about); | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
626 icq_UDPSockWrite(icqlink, p); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
627 return icqlink->d->icq_UDPSeqNum2-1; |
1152 | 628 } |
629 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
630 WORD icq_UpdateMetaInfoSecurity(icq_Link *icqlink, unsigned char reqauth, unsigned char webpresence, |
1152 | 631 unsigned char pubip) |
632 { | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
633 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_META_USER); |
1152 | 634 icq_PacketAppend16(p, META_CMD_SET_SECURE); |
635 icq_PacketAppend8(p, !reqauth); | |
636 icq_PacketAppend8(p, webpresence); | |
637 icq_PacketAppend8(p, pubip); | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
638 icq_UDPSockWrite(icqlink, p); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
639 return icqlink->d->icq_UDPSeqNum2-1; |
1152 | 640 } |
641 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
642 WORD icq_UpdateNewUserInfo(icq_Link *icqlink, const char *nick, const char *first, const char *last, |
1152 | 643 const char *email) /* V5 */ |
644 { | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
645 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_NEW_USER_INFO); |
1152 | 646 icq_PacketAppendString(p, nick); |
647 icq_PacketAppendString(p, first); | |
648 icq_PacketAppendString(p, last); | |
649 icq_PacketAppendString(p, email); | |
650 icq_PacketAppend8(p, 1); | |
651 icq_PacketAppend8(p, 1); | |
652 icq_PacketAppend8(p, 1); | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
653 icq_UDPSockWrite(icqlink, p); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
654 return icqlink->d->icq_UDPSeqNum1-1; |
1152 | 655 } |
656 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
657 WORD icq_SendMetaInfoReq(icq_Link *icqlink, unsigned long uin) |
1152 | 658 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
659 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_META_USER); |
1152 | 660 icq_PacketAppend16(p, META_CMD_REQ_INFO); |
661 icq_PacketAppend32(p, uin); | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
662 icq_UDPSockWrite(icqlink, p); |
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
663 return icqlink->d->icq_UDPSeqNum2-1; |
1152 | 664 } |