Mercurial > pidgin
annotate libfaim/aim_info.c @ 1423:def9a3f6b407
[gaim-migrate @ 1433]
one of these days, alice, one of these days....!
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 25 Jan 2001 00:39:56 +0000 |
parents | 829242e7348c |
children |
rev | line source |
---|---|
2 | 1 /* |
237 | 2 * aim_info.c |
3 * | |
4 * The functions here are responsible for requesting and parsing information- | |
5 * gathering SNACs. | |
6 * | |
2 | 7 */ |
8 | |
9 | |
283
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
249
diff
changeset
|
10 #include <faim/aim.h> |
2 | 11 |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
12 struct aim_priv_inforeq { |
1248
920c86b753d7
[gaim-migrate @ 1258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
13 char sn[MAXSNLEN+1]; |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
14 unsigned short infotype; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
15 }; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
16 |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
17 faim_export unsigned long aim_getinfo(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
18 struct aim_conn_t *conn, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
19 const char *sn, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
20 unsigned short infotype) |
237 | 21 { |
22 struct command_tx_struct *newpacket; | |
1248
920c86b753d7
[gaim-migrate @ 1258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
23 struct aim_priv_inforeq privdata; |
237 | 24 int i = 0; |
2 | 25 |
237 | 26 if (!sess || !conn || !sn) |
27 return 0; | |
2 | 28 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
29 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 12+1+strlen(sn)))) |
237 | 30 return -1; |
31 | |
32 newpacket->lock = 1; | |
33 | |
34 i = aim_putsnac(newpacket->data, 0x0002, 0x0005, 0x0000, sess->snac_nextid); | |
2 | 35 |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
36 i += aimutil_put16(newpacket->data+i, infotype); |
237 | 37 i += aimutil_put8(newpacket->data+i, strlen(sn)); |
38 i += aimutil_putstr(newpacket->data+i, sn, strlen(sn)); | |
2 | 39 |
237 | 40 newpacket->lock = 0; |
41 aim_tx_enqueue(sess, newpacket); | |
2 | 42 |
1248
920c86b753d7
[gaim-migrate @ 1258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
43 strncpy(privdata.sn, sn, sizeof(privdata.sn)); |
920c86b753d7
[gaim-migrate @ 1258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
44 privdata.infotype = infotype; |
920c86b753d7
[gaim-migrate @ 1258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
45 aim_cachesnac(sess, 0x0002, 0x0005, 0x0000, &privdata, sizeof(struct aim_priv_inforeq)); |
2 | 46 |
1248
920c86b753d7
[gaim-migrate @ 1258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
47 return sess->snac_nextid; |
237 | 48 } |
49 | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
50 faim_internal int aim_parse_locateerr(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
51 struct command_rx_struct *command) |
835
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
52 { |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
53 u_long snacid = 0x000000000; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
54 struct aim_snac_t *snac = NULL; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
55 int ret = 0; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
56 rxcallback_t userfunc = NULL; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
57 char *dest; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
58 unsigned short reason = 0; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
59 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
60 /* |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
61 * Get SNAC from packet and look it up |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
62 * the list of unrepliedto/outstanding |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
63 * SNACs. |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
64 * |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
65 */ |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
66 snacid = aimutil_get32(command->data+6); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
67 snac = aim_remsnac(sess, snacid); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
68 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
69 if (!snac) { |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
70 printf("faim: locerr: got an locate-failed error on an unknown SNAC ID! (%08lx)\n", snacid); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
71 dest = NULL; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
72 } else |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
73 dest = snac->data; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
74 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
75 reason = aimutil_get16(command->data+10); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
76 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
77 /* |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
78 * Call client. |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
79 */ |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
80 userfunc = aim_callhandler(command->conn, 0x0002, 0x0001); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
81 if (userfunc) |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
82 ret = userfunc(sess, command, dest, reason); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
83 else |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
84 ret = 0; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
85 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
86 if (snac) { |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
87 free(snac->data); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
88 free(snac); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
89 } |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
90 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
91 return ret; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
92 } |
237 | 93 |
94 /* | |
95 * Capability blocks. | |
96 */ | |
1302
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
97 u_char aim_caps[8][16] = { |
237 | 98 |
99 /* Buddy icon */ | |
100 {0x09, 0x46, 0x13, 0x46, 0x4c, 0x7f, 0x11, 0xd1, | |
101 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, | |
102 | |
103 /* Voice */ | |
104 {0x09, 0x46, 0x13, 0x41, 0x4c, 0x7f, 0x11, 0xd1, | |
105 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, | |
106 | |
107 /* IM image */ | |
108 {0x09, 0x46, 0x13, 0x45, 0x4c, 0x7f, 0x11, 0xd1, | |
109 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, | |
110 | |
111 /* Chat */ | |
112 {0x74, 0x8f, 0x24, 0x20, 0x62, 0x87, 0x11, 0xd1, | |
113 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, | |
114 | |
115 /* Get file */ | |
116 {0x09, 0x46, 0x13, 0x48, 0x4c, 0x7f, 0x11, 0xd1, | |
117 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, | |
118 | |
119 /* Send file */ | |
120 {0x09, 0x46, 0x13, 0x43, 0x4c, 0x7f, 0x11, 0xd1, | |
1302
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
121 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
122 |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
123 /* Saves stock portfolios */ |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
124 {0x09, 0x46, 0x13, 0x47, 0x4c, 0x7f, 0x11, 0xd1, |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
125 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
126 |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
127 /* Games */ |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
128 {0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1, |
1378
aedeb1218a0a
[gaim-migrate @ 1388]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1302
diff
changeset
|
129 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, |
237 | 130 }; |
131 | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
132 faim_internal unsigned short aim_getcap(unsigned char *capblock, int buflen) |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
133 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
134 u_short ret = 0; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
135 int y; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
136 int offset = 0; |
1302
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
137 int identified; |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
138 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
139 while (offset < buflen) { |
1302
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
140 identified = 0; |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
141 for(y=0; y < (sizeof(aim_caps)/0x10); y++) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
142 if (memcmp(&aim_caps[y], capblock+offset, 0x10) == 0) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
143 switch(y) { |
1302
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
144 case 0: ret |= AIM_CAPS_BUDDYICON; identified++; break; |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
145 case 1: ret |= AIM_CAPS_VOICE; identified++; break; |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
146 case 2: ret |= AIM_CAPS_IMIMAGE; identified++; break; |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
147 case 3: ret |= AIM_CAPS_CHAT; identified++; break; |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
148 case 4: ret |= AIM_CAPS_GETFILE; identified++; break; |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
149 case 5: ret |= AIM_CAPS_SENDFILE; identified++; break; |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
150 case 6: ret |= AIM_CAPS_GAMES; identified++; break; |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
151 case 7: ret |= AIM_CAPS_SAVESTOCKS; identified++; break; |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
152 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
153 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
154 } |
1302
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
155 if (!identified) { |
1383
829242e7348c
[gaim-migrate @ 1393]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1378
diff
changeset
|
156 faimdprintf(1, "faim: unknown capability "); |
1378
aedeb1218a0a
[gaim-migrate @ 1388]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1302
diff
changeset
|
157 for (y = 0; y < 0x10; y++) |
1383
829242e7348c
[gaim-migrate @ 1393]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1378
diff
changeset
|
158 faimdprintf(2, "%02x ", capblock[offset+y]); |
829242e7348c
[gaim-migrate @ 1393]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1378
diff
changeset
|
159 faimdprintf(1, "\n"); |
1302
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
160 ret |= 0xff00; |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
161 } |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
162 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
163 offset += 0x10; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
164 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
165 return ret; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
166 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
167 |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
168 faim_internal int aim_putcap(unsigned char *capblock, int buflen, u_short caps) |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
169 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
170 int offset = 0; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
171 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
172 if (!capblock) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
173 return -1; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
174 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
175 if ((caps & AIM_CAPS_BUDDYICON) && (offset < buflen)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
176 memcpy(capblock+offset, aim_caps[0], sizeof(aim_caps[0])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
177 offset += sizeof(aim_caps[1]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
178 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
179 if ((caps & AIM_CAPS_VOICE) && (offset < buflen)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
180 memcpy(capblock+offset, aim_caps[1], sizeof(aim_caps[1])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
181 offset += sizeof(aim_caps[1]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
182 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
183 if ((caps & AIM_CAPS_IMIMAGE) && (offset < buflen)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
184 memcpy(capblock+offset, aim_caps[2], sizeof(aim_caps[2])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
185 offset += sizeof(aim_caps[2]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
186 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
187 if ((caps & AIM_CAPS_CHAT) && (offset < buflen)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
188 memcpy(capblock+offset, aim_caps[3], sizeof(aim_caps[3])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
189 offset += sizeof(aim_caps[3]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
190 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
191 if ((caps & AIM_CAPS_GETFILE) && (offset < buflen)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
192 memcpy(capblock+offset, aim_caps[4], sizeof(aim_caps[4])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
193 offset += sizeof(aim_caps[4]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
194 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
195 if ((caps & AIM_CAPS_SENDFILE) && (offset < buflen)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
196 memcpy(capblock+offset, aim_caps[5], sizeof(aim_caps[5])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
197 offset += sizeof(aim_caps[5]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
198 } |
1302
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
199 if ((caps & AIM_CAPS_GAMES) && (offset < buflen)) { |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
200 memcpy(capblock+offset, aim_caps[6], sizeof(aim_caps[6])); |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
201 offset += sizeof(aim_caps[6]); |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
202 } |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
203 if ((caps & AIM_CAPS_SAVESTOCKS) && (offset < buflen)) { |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
204 memcpy(capblock+offset, aim_caps[7], sizeof(aim_caps[7])); |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
205 offset += sizeof(aim_caps[7]); |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
206 } |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
207 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
208 return offset; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
209 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
210 |
237 | 211 /* |
212 * AIM is fairly regular about providing user info. This | |
213 * is a generic routine to extract it in its standard form. | |
214 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
215 faim_internal int aim_extractuserinfo(u_char *buf, struct aim_userinfo_s *outinfo) |
237 | 216 { |
217 int i = 0; | |
218 int tlvcnt = 0; | |
219 int curtlv = 0; | |
220 int tlv1 = 0; | |
221 u_short curtype; | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
222 int lastvalid; |
237 | 223 |
224 | |
225 if (!buf || !outinfo) | |
226 return -1; | |
227 | |
228 /* Clear out old data first */ | |
229 memset(outinfo, 0x00, sizeof(struct aim_userinfo_s)); | |
230 | |
231 /* | |
232 * Screen name. Stored as an unterminated string prepended | |
233 * with an unsigned byte containing its length. | |
234 */ | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
235 if (buf[i] < MAXSNLEN) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
236 memcpy(outinfo->sn, &(buf[i+1]), buf[i]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
237 outinfo->sn[(int)buf[i]] = '\0'; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
238 } else { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
239 memcpy(outinfo->sn, &(buf[i+1]), MAXSNLEN-1); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
240 outinfo->sn[MAXSNLEN] = '\0'; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
241 } |
237 | 242 i = 1 + (int)buf[i]; |
243 | |
244 /* | |
245 * Warning Level. Stored as an unsigned short. | |
246 */ | |
247 outinfo->warnlevel = aimutil_get16(&buf[i]); | |
248 i += 2; | |
249 | |
250 /* | |
251 * TLV Count. Unsigned short representing the number of | |
252 * Type-Length-Value triples that follow. | |
253 */ | |
254 tlvcnt = aimutil_get16(&buf[i]); | |
255 i += 2; | |
256 | |
257 /* | |
258 * Parse out the Type-Length-Value triples as they're found. | |
259 */ | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
260 while (curtlv < tlvcnt) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
261 lastvalid = 1; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
262 curtype = aimutil_get16(&buf[i]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
263 switch (curtype) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
264 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
265 * Type = 0x0000: Invalid |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
266 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
267 * AOL has been trying to throw these in just to break us. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
268 * They're real nice guys over there at AOL. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
269 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
270 * Just skip the two zero bytes and continue on. (This doesn't |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
271 * count towards tlvcnt!) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
272 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
273 case 0x0000: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
274 lastvalid = 0; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
275 i += 2; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
276 break; |
237 | 277 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
278 /* |
900
e18815f5a4e9
[gaim-migrate @ 910]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
279 * Type = 0x0001: User flags |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
280 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
281 * Specified as any of the following bitwise ORed together: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
282 * 0x0001 Trial (user less than 60days) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
283 * 0x0002 Unknown bit 2 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
284 * 0x0004 AOL Main Service user |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
285 * 0x0008 Unknown bit 4 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
286 * 0x0010 Free (AIM) user |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
287 * 0x0020 Away |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
288 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
289 * In some odd cases, we can end up with more |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
290 * than one of these. We only want the first, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
291 * as the others may not be something we want. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
292 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
293 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
294 case 0x0001: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
295 if (tlv1) /* use only the first */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
296 break; |
900
e18815f5a4e9
[gaim-migrate @ 910]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
297 outinfo->flags = aimutil_get16(&buf[i+4]); |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
298 tlv1++; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
299 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
300 |
237 | 301 /* |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
302 * Type = 0x0002: Member-Since date. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
303 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
304 * The time/date that the user originally |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
305 * registered for the service, stored in |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
306 * time_t format |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
307 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
308 case 0x0002: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
309 outinfo->membersince = aimutil_get32(&buf[i+4]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
310 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
311 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
312 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
313 * Type = 0x0003: On-Since date. |
237 | 314 * |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
315 * The time/date that the user started |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
316 * their current session, stored in time_t |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
317 * format. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
318 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
319 case 0x0003: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
320 outinfo->onlinesince = aimutil_get32(&buf[i+4]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
321 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
322 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
323 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
324 * Type = 0x0004: Idle time. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
325 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
326 * Number of seconds since the user |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
327 * actively used the service. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
328 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
329 case 0x0004: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
330 outinfo->idletime = aimutil_get16(&buf[i+4]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
331 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
332 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
333 /* |
931
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
334 * Type = 0x0006: ICQ Online Status |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
335 * |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
336 * ICQ's Away/DND/etc "enriched" status |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
337 * Some decoding of values done by Scott <darkagl@pcnet.com> |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
338 */ |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
339 case 0x0006: |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
340 outinfo->icqinfo.status = aimutil_get16(buf+i+2+2+2); |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
341 break; |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
342 |
1002
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
343 |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
344 /* |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
345 * Type = 0x000a |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
346 * |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
347 * ICQ User IP Address. |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
348 * Ahh, the joy of ICQ security. |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
349 */ |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
350 case 0x000a: |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
351 outinfo->icqinfo.ipaddr = aimutil_get32(&buf[i+4]); |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
352 break; |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
353 |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
354 /* Type = 0x000c |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
355 * |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
356 * random crap containing the IP address, |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
357 * apparently a port number, and some Other Stuff. |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
358 * |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
359 */ |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
360 case 0x000c: |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
361 memcpy(outinfo->icqinfo.crap, &buf[i+4], 0x25); |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
362 break; |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
363 |
931
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
364 /* |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
365 * Type = 0x000d |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
366 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
367 * Capability information. Not real sure of |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
368 * actual decoding. See comment on aim_bos_setprofile() |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
369 * in aim_misc.c about the capability block, its the same. |
237 | 370 * |
371 */ | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
372 case 0x000d: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
373 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
374 int len; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
375 len = aimutil_get16(buf+i+2); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
376 if (!len) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
377 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
378 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
379 outinfo->capabilities = aim_getcap(buf+i+4, len); |
1378
aedeb1218a0a
[gaim-migrate @ 1388]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1302
diff
changeset
|
380 if (outinfo->capabilities & 0xff00) |
1383
829242e7348c
[gaim-migrate @ 1393]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1378
diff
changeset
|
381 faimdprintf(2, "%s\n", outinfo->sn); |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
382 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
383 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
384 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
385 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
386 * Type = 0x000e |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
387 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
388 * Unknown. Always of zero length, and always only |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
389 * on AOL users. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
390 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
391 * Ignore. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
392 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
393 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
394 case 0x000e: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
395 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
396 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
397 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
398 * Type = 0x000f: Session Length. (AIM) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
399 * Type = 0x0010: Session Length. (AOL) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
400 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
401 * The duration, in seconds, of the user's |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
402 * current session. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
403 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
404 * Which TLV type this comes in depends |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
405 * on the service the user is using (AIM or AOL). |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
406 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
407 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
408 case 0x000f: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
409 case 0x0010: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
410 outinfo->sessionlen = aimutil_get32(&buf[i+4]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
411 break; |
237 | 412 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
413 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
414 * Reaching here indicates that either AOL has |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
415 * added yet another TLV for us to deal with, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
416 * or the parsing has gone Terribly Wrong. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
417 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
418 * Either way, inform the owner and attempt |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
419 * recovery. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
420 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
421 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
422 default: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
423 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
424 int len,z = 0, y = 0, x = 0; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
425 char tmpstr[80]; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
426 printf("faim: userinfo: **warning: unexpected TLV:\n"); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
427 printf("faim: userinfo: sn =%s\n", outinfo->sn); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
428 printf("faim: userinfo: curtlv=0x%04x\n", curtlv); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
429 printf("faim: userinfo: type =0x%04x\n",aimutil_get16(&buf[i])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
430 printf("faim: userinfo: length=0x%04x\n", len = aimutil_get16(&buf[i+2])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
431 printf("faim: userinfo: data: \n"); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
432 while (z<len) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
433 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
434 x = sprintf(tmpstr, "faim: userinfo: "); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
435 for (y = 0; y < 8; y++) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
436 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
437 if (z<len) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
438 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
439 sprintf(tmpstr+x, "%02x ", buf[i+4+z]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
440 z++; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
441 x += 3; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
442 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
443 else |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
444 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
445 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
446 printf("%s\n", tmpstr); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
447 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
448 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
449 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
450 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
451 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
452 * No matter what, TLV triplets should always look like this: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
453 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
454 * u_short type; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
455 * u_short length; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
456 * u_char data[length]; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
457 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
458 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
459 if (lastvalid) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
460 i += (2 + 2 + aimutil_get16(&buf[i+2])); |
237 | 461 curtlv++; |
462 } | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
463 } |
237 | 464 |
465 return i; | |
466 } | |
467 | |
468 /* | |
469 * Oncoming Buddy notifications contain a subset of the | |
470 * user information structure. Its close enough to run | |
471 * through aim_extractuserinfo() however. | |
472 * | |
473 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
474 faim_internal int aim_parse_oncoming_middle(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
475 struct command_rx_struct *command) |
237 | 476 { |
477 struct aim_userinfo_s userinfo; | |
478 u_int i = 0; | |
479 rxcallback_t userfunc=NULL; | |
480 | |
481 i = 10; | |
482 i += aim_extractuserinfo(command->data+i, &userinfo); | |
483 | |
484 userfunc = aim_callhandler(command->conn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING); | |
485 if (userfunc) | |
486 i = userfunc(sess, command, &userinfo); | |
487 | |
488 return 1; | |
489 } | |
490 | |
491 /* | |
492 * Offgoing Buddy notifications contain no useful | |
493 * information other than the name it applies to. | |
494 * | |
495 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
496 faim_internal int aim_parse_offgoing_middle(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
497 struct command_rx_struct *command) |
237 | 498 { |
499 char sn[MAXSNLEN+1]; | |
500 u_int i = 0; | |
501 rxcallback_t userfunc=NULL; | |
502 | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
503 strncpy(sn, (char *)command->data+11, (int)command->data[10]); |
237 | 504 sn[(int)command->data[10]] = '\0'; |
505 | |
506 userfunc = aim_callhandler(command->conn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING); | |
507 if (userfunc) | |
508 i = userfunc(sess, command, sn); | |
509 | |
510 return 1; | |
2 | 511 } |
512 | |
513 /* | |
514 * This parses the user info stuff out all nice and pretty then calls | |
515 * the higher-level callback (in the user app). | |
516 * | |
517 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
518 faim_internal int aim_parse_userinfo_middle(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
519 struct command_rx_struct *command) |
2 | 520 { |
237 | 521 struct aim_userinfo_s userinfo; |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
522 char *text_encoding = NULL; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
523 char *text = NULL; |
237 | 524 u_int i = 0; |
525 rxcallback_t userfunc=NULL; | |
526 struct aim_tlvlist_t *tlvlist; | |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
527 struct aim_snac_t *origsnac = NULL; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
528 u_long snacid; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
529 struct aim_priv_inforeq *inforeq; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
530 |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
531 snacid = aimutil_get32(&command->data[6]); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
532 origsnac = aim_remsnac(sess, snacid); |
2 | 533 |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
534 if (!origsnac || !origsnac->data) { |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
535 printf("faim: parse_userinfo_middle: major problem: no snac stored!\n"); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
536 return 1; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
537 } |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
538 |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
539 inforeq = (struct aim_priv_inforeq *)origsnac->data; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
540 |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
541 switch (inforeq->infotype) { |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
542 case AIM_GETINFO_GENERALINFO: |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
543 case AIM_GETINFO_AWAYMESSAGE: |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
544 i = 10; |
2 | 545 |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
546 /* |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
547 * extractuserinfo will give us the basic metaTLV information |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
548 */ |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
549 i += aim_extractuserinfo(command->data+i, &userinfo); |
237 | 550 |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
551 /* |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
552 * However, in this command, there's usually more TLVs following... |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
553 */ |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
554 tlvlist = aim_readtlvchain(command->data+i, command->commandlen-i); |
237 | 555 |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
556 /* |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
557 * Depending on what informational text was requested, different |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
558 * TLVs will appear here. |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
559 * |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
560 * Profile will be 1 and 2, away message will be 3 and 4. |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
561 */ |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
562 if (aim_gettlv(tlvlist, 0x0001, 1)) { |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
563 text_encoding = aim_gettlv_str(tlvlist, 0x0001, 1); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
564 text = aim_gettlv_str(tlvlist, 0x0002, 1); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
565 } else if (aim_gettlv(tlvlist, 0x0003, 1)) { |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
566 text_encoding = aim_gettlv_str(tlvlist, 0x0003, 1); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
567 text = aim_gettlv_str(tlvlist, 0x0004, 1); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
568 } |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
569 |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
570 userfunc = aim_callhandler(command->conn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
571 if (userfunc) { |
237 | 572 i = userfunc(sess, |
573 command, | |
574 &userinfo, | |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
575 text_encoding, |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
576 text, |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
577 inforeq->infotype); |
2 | 578 } |
237 | 579 |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
580 free(text_encoding); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
581 free(text); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
582 aim_freetlvchain(&tlvlist); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
583 break; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
584 default: |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
585 printf("faim: parse_userinfo_middle: unknown infotype in request! (0x%04x)\n", inforeq->infotype); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
586 break; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
587 } |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
588 |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
589 if (origsnac) { |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
590 if (origsnac->data) |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
591 free(origsnac->data); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
592 free(origsnac); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
593 } |
2 | 594 |
237 | 595 return 1; |
596 } | |
597 | |
598 /* | |
599 * Inverse of aim_extractuserinfo() | |
600 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
601 faim_internal int aim_putuserinfo(u_char *buf, int buflen, struct aim_userinfo_s *info) |
237 | 602 { |
1002
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
603 int i = 0, numtlv = 0; |
237 | 604 struct aim_tlvlist_t *tlvlist = NULL; |
605 | |
606 if (!buf || !info) | |
607 return 0; | |
608 | |
609 i += aimutil_put8(buf+i, strlen(info->sn)); | |
610 i += aimutil_putstr(buf+i, info->sn, strlen(info->sn)); | |
611 | |
612 i += aimutil_put16(buf+i, info->warnlevel); | |
613 | |
1002
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
614 |
900
e18815f5a4e9
[gaim-migrate @ 910]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
615 aim_addtlvtochain16(&tlvlist, 0x0001, info->flags); |
1002
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
616 numtlv++; |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
617 |
237 | 618 aim_addtlvtochain32(&tlvlist, 0x0002, info->membersince); |
1002
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
619 numtlv++; |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
620 |
237 | 621 aim_addtlvtochain32(&tlvlist, 0x0003, info->onlinesince); |
1002
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
622 numtlv++; |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
623 |
237 | 624 aim_addtlvtochain16(&tlvlist, 0x0004, info->idletime); |
1002
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
625 numtlv++; |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
626 |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
627 #if ICQ_OSCAR_SUPPORT |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
628 if(atoi(info->sn) != 0) { |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
629 aim_addtlvtochain16(&tlvlist, 0x0006, info->icqinfo.status); |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
630 aim_addtlvtochain32(&tlvlist, 0x000a, info->icqinfo.ipaddr); |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
631 } |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
632 #endif |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
633 |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
634 aim_addtlvtochain_caps(&tlvlist, 0x000d, info->capabilities); |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
635 numtlv++; |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
636 |
900
e18815f5a4e9
[gaim-migrate @ 910]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
637 aim_addtlvtochain32(&tlvlist, (unsigned short)((info->flags)&AIM_FLAG_AOL?0x0010:0x000f), info->sessionlen); |
1002
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
638 numtlv++; |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
639 |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
640 i += aimutil_put16(buf+i, numtlv); /* tlvcount */ |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
641 i += aim_writetlvchain(buf+i, buflen-i, &tlvlist); /* tlvs */ |
237 | 642 aim_freetlvchain(&tlvlist); |
1002
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
643 |
2 | 644 return i; |
645 } | |
237 | 646 |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
647 faim_export int aim_sendbuddyoncoming(struct aim_session_t *sess, struct aim_conn_t *conn, struct aim_userinfo_s *info) |
237 | 648 { |
649 struct command_tx_struct *tx; | |
650 int i = 0; | |
651 | |
652 if (!sess || !conn || !info) | |
653 return 0; | |
654 | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
655 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152))) |
237 | 656 return -1; |
657 | |
658 tx->lock = 1; | |
659 | |
660 i += aimutil_put16(tx->data+i, 0x0003); | |
661 i += aimutil_put16(tx->data+i, 0x000b); | |
662 i += aimutil_put16(tx->data+i, 0x0000); | |
663 i += aimutil_put16(tx->data+i, 0x0000); | |
664 i += aimutil_put16(tx->data+i, 0x0000); | |
665 | |
666 i += aim_putuserinfo(tx->data+i, tx->commandlen-i, info); | |
667 | |
668 tx->commandlen = i; | |
669 tx->lock = 0; | |
670 aim_tx_enqueue(sess, tx); | |
671 | |
672 return 0; | |
673 } | |
674 | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
675 faim_export int aim_sendbuddyoffgoing(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn) |
237 | 676 { |
677 struct command_tx_struct *tx; | |
678 int i = 0; | |
679 | |
680 if (!sess || !conn || !sn) | |
681 return 0; | |
682 | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
683 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+1+strlen(sn)))) |
237 | 684 return -1; |
685 | |
686 tx->lock = 1; | |
687 | |
688 i += aimutil_put16(tx->data+i, 0x0003); | |
689 i += aimutil_put16(tx->data+i, 0x000c); | |
690 i += aimutil_put16(tx->data+i, 0x0000); | |
691 i += aimutil_put16(tx->data+i, 0x0000); | |
692 i += aimutil_put16(tx->data+i, 0x0000); | |
693 | |
694 i += aimutil_put8(tx->data+i, strlen(sn)); | |
695 i += aimutil_putstr(tx->data+i, sn, strlen(sn)); | |
696 | |
697 tx->lock = 0; | |
698 aim_tx_enqueue(sess, tx); | |
699 | |
700 return 0; | |
701 } | |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
702 |