Mercurial > pidgin
annotate libfaim/aim_info.c @ 1302:4c5c2fcb83cd
[gaim-migrate @ 1312]
libfaim stuff
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 19 Dec 2000 03:08:06 +0000 |
parents | 920c86b753d7 |
children | aedeb1218a0a |
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, |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
129 0x22, 0x82, 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) { |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
156 printf("faim: unknown capability!\n"); |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
157 ret |= 0xff00; |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
158 } |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
159 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
160 offset += 0x10; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
161 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
162 return ret; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
163 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
164 |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
165 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
|
166 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
167 int offset = 0; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
168 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
169 if (!capblock) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
170 return -1; |
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 ((caps & AIM_CAPS_BUDDYICON) && (offset < buflen)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
173 memcpy(capblock+offset, aim_caps[0], sizeof(aim_caps[0])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
174 offset += sizeof(aim_caps[1]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
175 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
176 if ((caps & AIM_CAPS_VOICE) && (offset < buflen)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
177 memcpy(capblock+offset, aim_caps[1], sizeof(aim_caps[1])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
178 offset += sizeof(aim_caps[1]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
179 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
180 if ((caps & AIM_CAPS_IMIMAGE) && (offset < buflen)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
181 memcpy(capblock+offset, aim_caps[2], sizeof(aim_caps[2])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
182 offset += sizeof(aim_caps[2]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
183 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
184 if ((caps & AIM_CAPS_CHAT) && (offset < buflen)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
185 memcpy(capblock+offset, aim_caps[3], sizeof(aim_caps[3])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
186 offset += sizeof(aim_caps[3]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
187 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
188 if ((caps & AIM_CAPS_GETFILE) && (offset < buflen)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
189 memcpy(capblock+offset, aim_caps[4], sizeof(aim_caps[4])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
190 offset += sizeof(aim_caps[4]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
191 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
192 if ((caps & AIM_CAPS_SENDFILE) && (offset < buflen)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
193 memcpy(capblock+offset, aim_caps[5], sizeof(aim_caps[5])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
194 offset += sizeof(aim_caps[5]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
195 } |
1302
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
196 if ((caps & AIM_CAPS_GAMES) && (offset < buflen)) { |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
197 memcpy(capblock+offset, aim_caps[6], sizeof(aim_caps[6])); |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
198 offset += sizeof(aim_caps[6]); |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
199 } |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
200 if ((caps & AIM_CAPS_SAVESTOCKS) && (offset < buflen)) { |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
201 memcpy(capblock+offset, aim_caps[7], sizeof(aim_caps[7])); |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
202 offset += sizeof(aim_caps[7]); |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1248
diff
changeset
|
203 } |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
204 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
205 return offset; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
206 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
207 |
237 | 208 /* |
209 * AIM is fairly regular about providing user info. This | |
210 * is a generic routine to extract it in its standard form. | |
211 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
212 faim_internal int aim_extractuserinfo(u_char *buf, struct aim_userinfo_s *outinfo) |
237 | 213 { |
214 int i = 0; | |
215 int tlvcnt = 0; | |
216 int curtlv = 0; | |
217 int tlv1 = 0; | |
218 u_short curtype; | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
219 int lastvalid; |
237 | 220 |
221 | |
222 if (!buf || !outinfo) | |
223 return -1; | |
224 | |
225 /* Clear out old data first */ | |
226 memset(outinfo, 0x00, sizeof(struct aim_userinfo_s)); | |
227 | |
228 /* | |
229 * Screen name. Stored as an unterminated string prepended | |
230 * with an unsigned byte containing its length. | |
231 */ | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
232 if (buf[i] < MAXSNLEN) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
233 memcpy(outinfo->sn, &(buf[i+1]), buf[i]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
234 outinfo->sn[(int)buf[i]] = '\0'; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
235 } else { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
236 memcpy(outinfo->sn, &(buf[i+1]), MAXSNLEN-1); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
237 outinfo->sn[MAXSNLEN] = '\0'; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
238 } |
237 | 239 i = 1 + (int)buf[i]; |
240 | |
241 /* | |
242 * Warning Level. Stored as an unsigned short. | |
243 */ | |
244 outinfo->warnlevel = aimutil_get16(&buf[i]); | |
245 i += 2; | |
246 | |
247 /* | |
248 * TLV Count. Unsigned short representing the number of | |
249 * Type-Length-Value triples that follow. | |
250 */ | |
251 tlvcnt = aimutil_get16(&buf[i]); | |
252 i += 2; | |
253 | |
254 /* | |
255 * Parse out the Type-Length-Value triples as they're found. | |
256 */ | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
257 while (curtlv < tlvcnt) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
258 lastvalid = 1; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
259 curtype = aimutil_get16(&buf[i]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
260 switch (curtype) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
261 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
262 * Type = 0x0000: Invalid |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
263 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
264 * 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
|
265 * They're real nice guys over there at AOL. |
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 * 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
|
268 * count towards tlvcnt!) |
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 case 0x0000: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
271 lastvalid = 0; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
272 i += 2; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
273 break; |
237 | 274 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
275 /* |
900
e18815f5a4e9
[gaim-migrate @ 910]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
276 * Type = 0x0001: User flags |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
277 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
278 * Specified as any of the following bitwise ORed together: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
279 * 0x0001 Trial (user less than 60days) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
280 * 0x0002 Unknown bit 2 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
281 * 0x0004 AOL Main Service user |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
282 * 0x0008 Unknown bit 4 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
283 * 0x0010 Free (AIM) user |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
284 * 0x0020 Away |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
285 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
286 * In some odd cases, we can end up with more |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
287 * than one of these. We only want the first, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
288 * as the others may not be something we want. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
289 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
290 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
291 case 0x0001: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
292 if (tlv1) /* use only the first */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
293 break; |
900
e18815f5a4e9
[gaim-migrate @ 910]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
294 outinfo->flags = aimutil_get16(&buf[i+4]); |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
295 tlv1++; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
296 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
297 |
237 | 298 /* |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
299 * Type = 0x0002: Member-Since date. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
300 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
301 * The time/date that the user originally |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
302 * registered for the service, stored in |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
303 * time_t format |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
304 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
305 case 0x0002: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
306 outinfo->membersince = aimutil_get32(&buf[i+4]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
307 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
308 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
309 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
310 * Type = 0x0003: On-Since date. |
237 | 311 * |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
312 * The time/date that the user started |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
313 * their current session, stored in time_t |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
314 * format. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
315 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
316 case 0x0003: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
317 outinfo->onlinesince = aimutil_get32(&buf[i+4]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
318 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
319 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
320 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
321 * Type = 0x0004: Idle time. |
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 * Number of seconds since the user |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
324 * actively used the service. |
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 case 0x0004: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
327 outinfo->idletime = aimutil_get16(&buf[i+4]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
328 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
329 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
330 /* |
931
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
331 * Type = 0x0006: ICQ Online Status |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
332 * |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
333 * ICQ's Away/DND/etc "enriched" status |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
334 * Some decoding of values done by Scott <darkagl@pcnet.com> |
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 case 0x0006: |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
337 outinfo->icqinfo.status = aimutil_get16(buf+i+2+2+2); |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
338 break; |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
339 |
1002
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
340 |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
341 /* |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
342 * Type = 0x000a |
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 * ICQ User IP Address. |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
345 * Ahh, the joy of ICQ security. |
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 case 0x000a: |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
348 outinfo->icqinfo.ipaddr = aimutil_get32(&buf[i+4]); |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
349 break; |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
350 |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
351 /* Type = 0x000c |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
352 * |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
353 * random crap containing the IP address, |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
354 * apparently a port number, and some Other Stuff. |
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 */ |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
357 case 0x000c: |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
358 memcpy(outinfo->icqinfo.crap, &buf[i+4], 0x25); |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
359 break; |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
360 |
931
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
361 /* |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
362 * Type = 0x000d |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
363 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
364 * Capability information. Not real sure of |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
365 * actual decoding. See comment on aim_bos_setprofile() |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
366 * in aim_misc.c about the capability block, its the same. |
237 | 367 * |
368 */ | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
369 case 0x000d: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
370 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
371 int len; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
372 len = aimutil_get16(buf+i+2); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
373 if (!len) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
374 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
375 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
376 outinfo->capabilities = aim_getcap(buf+i+4, len); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
377 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
378 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
379 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
380 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
381 * Type = 0x000e |
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 * Unknown. Always of zero length, and always only |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
384 * on AOL users. |
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 * Ignore. |
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 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
389 case 0x000e: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
390 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
391 |
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 * Type = 0x000f: Session Length. (AIM) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
394 * Type = 0x0010: Session Length. (AOL) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
395 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
396 * The duration, in seconds, of the user's |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
397 * current session. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
398 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
399 * Which TLV type this comes in depends |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
400 * on the service the user is using (AIM or AOL). |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
401 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
402 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
403 case 0x000f: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
404 case 0x0010: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
405 outinfo->sessionlen = aimutil_get32(&buf[i+4]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
406 break; |
237 | 407 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
408 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
409 * Reaching here indicates that either AOL has |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
410 * added yet another TLV for us to deal with, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
411 * or the parsing has gone Terribly Wrong. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
412 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
413 * Either way, inform the owner and attempt |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
414 * recovery. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
415 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
416 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
417 default: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
418 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
419 int len,z = 0, y = 0, x = 0; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
420 char tmpstr[80]; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
421 printf("faim: userinfo: **warning: unexpected TLV:\n"); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
422 printf("faim: userinfo: sn =%s\n", outinfo->sn); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
423 printf("faim: userinfo: curtlv=0x%04x\n", curtlv); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
424 printf("faim: userinfo: type =0x%04x\n",aimutil_get16(&buf[i])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
425 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
|
426 printf("faim: userinfo: data: \n"); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
427 while (z<len) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
428 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
429 x = sprintf(tmpstr, "faim: userinfo: "); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
430 for (y = 0; y < 8; y++) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
431 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
432 if (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 sprintf(tmpstr+x, "%02x ", buf[i+4+z]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
435 z++; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
436 x += 3; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
437 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
438 else |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
439 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
440 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
441 printf("%s\n", tmpstr); |
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 } |
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 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
447 * No matter what, TLV triplets should always look like this: |
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 * u_short type; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
450 * u_short length; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
451 * u_char data[length]; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
452 * |
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 if (lastvalid) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
455 i += (2 + 2 + aimutil_get16(&buf[i+2])); |
237 | 456 curtlv++; |
457 } | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
458 } |
237 | 459 |
460 return i; | |
461 } | |
462 | |
463 /* | |
464 * Oncoming Buddy notifications contain a subset of the | |
465 * user information structure. Its close enough to run | |
466 * through aim_extractuserinfo() however. | |
467 * | |
468 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
469 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
|
470 struct command_rx_struct *command) |
237 | 471 { |
472 struct aim_userinfo_s userinfo; | |
473 u_int i = 0; | |
474 rxcallback_t userfunc=NULL; | |
475 | |
476 i = 10; | |
477 i += aim_extractuserinfo(command->data+i, &userinfo); | |
478 | |
479 userfunc = aim_callhandler(command->conn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING); | |
480 if (userfunc) | |
481 i = userfunc(sess, command, &userinfo); | |
482 | |
483 return 1; | |
484 } | |
485 | |
486 /* | |
487 * Offgoing Buddy notifications contain no useful | |
488 * information other than the name it applies to. | |
489 * | |
490 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
491 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
|
492 struct command_rx_struct *command) |
237 | 493 { |
494 char sn[MAXSNLEN+1]; | |
495 u_int i = 0; | |
496 rxcallback_t userfunc=NULL; | |
497 | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
498 strncpy(sn, (char *)command->data+11, (int)command->data[10]); |
237 | 499 sn[(int)command->data[10]] = '\0'; |
500 | |
501 userfunc = aim_callhandler(command->conn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING); | |
502 if (userfunc) | |
503 i = userfunc(sess, command, sn); | |
504 | |
505 return 1; | |
2 | 506 } |
507 | |
508 /* | |
509 * This parses the user info stuff out all nice and pretty then calls | |
510 * the higher-level callback (in the user app). | |
511 * | |
512 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
513 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
|
514 struct command_rx_struct *command) |
2 | 515 { |
237 | 516 struct aim_userinfo_s userinfo; |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
517 char *text_encoding = NULL; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
518 char *text = NULL; |
237 | 519 u_int i = 0; |
520 rxcallback_t userfunc=NULL; | |
521 struct aim_tlvlist_t *tlvlist; | |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
522 struct aim_snac_t *origsnac = NULL; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
523 u_long snacid; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
524 struct aim_priv_inforeq *inforeq; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
525 |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
526 snacid = aimutil_get32(&command->data[6]); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
527 origsnac = aim_remsnac(sess, snacid); |
2 | 528 |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
529 if (!origsnac || !origsnac->data) { |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
530 printf("faim: parse_userinfo_middle: major problem: no snac stored!\n"); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
531 return 1; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
532 } |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
533 |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
534 inforeq = (struct aim_priv_inforeq *)origsnac->data; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
535 |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
536 switch (inforeq->infotype) { |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
537 case AIM_GETINFO_GENERALINFO: |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
538 case AIM_GETINFO_AWAYMESSAGE: |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
539 i = 10; |
2 | 540 |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
541 /* |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
542 * extractuserinfo will give us the basic metaTLV information |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
543 */ |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
544 i += aim_extractuserinfo(command->data+i, &userinfo); |
237 | 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 * However, in this command, there's usually more TLVs following... |
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 tlvlist = aim_readtlvchain(command->data+i, command->commandlen-i); |
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 * Depending on what informational text was requested, different |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
553 * TLVs will appear here. |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
554 * |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
555 * 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
|
556 */ |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
557 if (aim_gettlv(tlvlist, 0x0001, 1)) { |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
558 text_encoding = aim_gettlv_str(tlvlist, 0x0001, 1); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
559 text = aim_gettlv_str(tlvlist, 0x0002, 1); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
560 } else if (aim_gettlv(tlvlist, 0x0003, 1)) { |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
561 text_encoding = aim_gettlv_str(tlvlist, 0x0003, 1); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
562 text = aim_gettlv_str(tlvlist, 0x0004, 1); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
563 } |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
564 |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
565 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
|
566 if (userfunc) { |
237 | 567 i = userfunc(sess, |
568 command, | |
569 &userinfo, | |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
570 text_encoding, |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
571 text, |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
572 inforeq->infotype); |
2 | 573 } |
237 | 574 |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
575 free(text_encoding); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
576 free(text); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
577 aim_freetlvchain(&tlvlist); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
578 break; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
579 default: |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
580 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
|
581 break; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
582 } |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
583 |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
584 if (origsnac) { |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
585 if (origsnac->data) |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
586 free(origsnac->data); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
587 free(origsnac); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
588 } |
2 | 589 |
237 | 590 return 1; |
591 } | |
592 | |
593 /* | |
594 * Inverse of aim_extractuserinfo() | |
595 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
596 faim_internal int aim_putuserinfo(u_char *buf, int buflen, struct aim_userinfo_s *info) |
237 | 597 { |
1002
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
598 int i = 0, numtlv = 0; |
237 | 599 struct aim_tlvlist_t *tlvlist = NULL; |
600 | |
601 if (!buf || !info) | |
602 return 0; | |
603 | |
604 i += aimutil_put8(buf+i, strlen(info->sn)); | |
605 i += aimutil_putstr(buf+i, info->sn, strlen(info->sn)); | |
606 | |
607 i += aimutil_put16(buf+i, info->warnlevel); | |
608 | |
1002
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
609 |
900
e18815f5a4e9
[gaim-migrate @ 910]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
610 aim_addtlvtochain16(&tlvlist, 0x0001, info->flags); |
1002
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
611 numtlv++; |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
612 |
237 | 613 aim_addtlvtochain32(&tlvlist, 0x0002, info->membersince); |
1002
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
614 numtlv++; |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
615 |
237 | 616 aim_addtlvtochain32(&tlvlist, 0x0003, info->onlinesince); |
1002
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
617 numtlv++; |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
618 |
237 | 619 aim_addtlvtochain16(&tlvlist, 0x0004, info->idletime); |
1002
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
620 numtlv++; |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
621 |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
622 #if ICQ_OSCAR_SUPPORT |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
623 if(atoi(info->sn) != 0) { |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
624 aim_addtlvtochain16(&tlvlist, 0x0006, info->icqinfo.status); |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
625 aim_addtlvtochain32(&tlvlist, 0x000a, info->icqinfo.ipaddr); |
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 #endif |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
628 |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
629 aim_addtlvtochain_caps(&tlvlist, 0x000d, info->capabilities); |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
630 numtlv++; |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
631 |
900
e18815f5a4e9
[gaim-migrate @ 910]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
632 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
|
633 numtlv++; |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
634 |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
635 i += aimutil_put16(buf+i, numtlv); /* tlvcount */ |
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
636 i += aim_writetlvchain(buf+i, buflen-i, &tlvlist); /* tlvs */ |
237 | 637 aim_freetlvchain(&tlvlist); |
1002
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
638 |
2 | 639 return i; |
640 } | |
237 | 641 |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
642 faim_export int aim_sendbuddyoncoming(struct aim_session_t *sess, struct aim_conn_t *conn, struct aim_userinfo_s *info) |
237 | 643 { |
644 struct command_tx_struct *tx; | |
645 int i = 0; | |
646 | |
647 if (!sess || !conn || !info) | |
648 return 0; | |
649 | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
650 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152))) |
237 | 651 return -1; |
652 | |
653 tx->lock = 1; | |
654 | |
655 i += aimutil_put16(tx->data+i, 0x0003); | |
656 i += aimutil_put16(tx->data+i, 0x000b); | |
657 i += aimutil_put16(tx->data+i, 0x0000); | |
658 i += aimutil_put16(tx->data+i, 0x0000); | |
659 i += aimutil_put16(tx->data+i, 0x0000); | |
660 | |
661 i += aim_putuserinfo(tx->data+i, tx->commandlen-i, info); | |
662 | |
663 tx->commandlen = i; | |
664 tx->lock = 0; | |
665 aim_tx_enqueue(sess, tx); | |
666 | |
667 return 0; | |
668 } | |
669 | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
670 faim_export int aim_sendbuddyoffgoing(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn) |
237 | 671 { |
672 struct command_tx_struct *tx; | |
673 int i = 0; | |
674 | |
675 if (!sess || !conn || !sn) | |
676 return 0; | |
677 | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
678 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+1+strlen(sn)))) |
237 | 679 return -1; |
680 | |
681 tx->lock = 1; | |
682 | |
683 i += aimutil_put16(tx->data+i, 0x0003); | |
684 i += aimutil_put16(tx->data+i, 0x000c); | |
685 i += aimutil_put16(tx->data+i, 0x0000); | |
686 i += aimutil_put16(tx->data+i, 0x0000); | |
687 i += aimutil_put16(tx->data+i, 0x0000); | |
688 | |
689 i += aimutil_put8(tx->data+i, strlen(sn)); | |
690 i += aimutil_putstr(tx->data+i, sn, strlen(sn)); | |
691 | |
692 tx->lock = 0; | |
693 aim_tx_enqueue(sess, tx); | |
694 | |
695 return 0; | |
696 } | |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
697 |