Mercurial > pidgin
annotate src/protocols/oscar/info.c @ 6572:4f097c1069b0
[gaim-migrate @ 7094]
this one i noticed on my own. it comes of editing an un-updated copy of the Changelog
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Fri, 22 Aug 2003 12:09:46 +0000 |
parents | 96196cfb132e |
children | 714fc8f45cf2 |
rev | line source |
---|---|
2086 | 1 /* |
3952 | 2 * Family 0x0002 - Information. |
2086 | 3 * |
4 * The functions here are responsible for requesting and parsing information- | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
5 * gathering SNACs. Or something like that. |
2086 | 6 * |
7 */ | |
8 | |
9 #define FAIM_INTERNAL | |
10 #include <aim.h> | |
4156
d833bacc054f
[gaim-migrate @ 4384]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4151
diff
changeset
|
11 #ifdef _WIN32 |
d833bacc054f
[gaim-migrate @ 4384]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4151
diff
changeset
|
12 #include "win32dep.h" |
d833bacc054f
[gaim-migrate @ 4384]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4151
diff
changeset
|
13 #endif |
2086 | 14 |
15 struct aim_priv_inforeq { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
16 char sn[MAXSNLEN+1]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
17 fu16_t infotype; |
2086 | 18 }; |
19 | |
3952 | 20 /* |
21 * Subtype 0x0002 | |
22 * | |
23 * Request Location services rights. | |
24 * | |
25 */ | |
26 faim_export int aim_bos_reqlocaterights(aim_session_t *sess, aim_conn_t *conn) | |
27 { | |
28 return aim_genericreq_n(sess, conn, 0x0002, 0x0002); | |
29 } | |
30 | |
31 /* | |
32 * Subtype 0x0004 | |
33 * | |
34 * Gives BOS your profile. | |
4151 | 35 * |
36 * profile_encoding and awaymsg_encoding MUST be set if profile or | |
37 * away are set, respectively, and their value may or may not be | |
38 * restricted to a few choices. I am currently aware of: | |
39 * | |
40 * us-ascii Just that | |
41 * unicode-2-0 UCS2-BE | |
42 * | |
43 * profile_len and awaymsg_len MUST be set similarly, and they MUST | |
44 * be the length of their respective strings in bytes. | |
45 * | |
46 * To get the previous behavior of awaymsg == "" un-setting the away | |
47 * message, set awaymsg non-NULL and awaymsg_len to 0 (this is the | |
48 * obvious equivalent). | |
3952 | 49 * |
50 */ | |
4151 | 51 faim_export int aim_bos_setprofile(aim_session_t *sess, aim_conn_t *conn, |
52 const char *profile_encoding, const char *profile, const int profile_len, | |
53 const char *awaymsg_encoding, const char *awaymsg, const int awaymsg_len, | |
54 fu32_t caps) | |
3952 | 55 { |
4151 | 56 static const char defencoding[] = {"text/aolrtf; charset=\"%s\""}; |
3952 | 57 aim_frame_t *fr; |
58 aim_tlvlist_t *tl = NULL; | |
59 aim_snacid_t snacid; | |
4151 | 60 char *encoding; |
61 | |
62 if ((profile && profile_encoding == NULL) || (awaymsg && awaymsg_len && awaymsg_encoding == NULL)) { | |
63 return -EINVAL; | |
64 } | |
3952 | 65 |
66 /* Build to packet first to get real length */ | |
67 if (profile) { | |
4151 | 68 /* no + 1 here because of %s */ |
69 encoding = malloc(strlen(defencoding) + strlen(profile_encoding)); | |
70 if (encoding == NULL) { | |
71 return -ENOMEM; | |
72 } | |
73 snprintf(encoding, strlen(defencoding) + strlen(profile_encoding), defencoding, profile_encoding); | |
74 aim_addtlvtochain_raw(&tl, 0x0001, strlen(encoding), encoding); | |
75 aim_addtlvtochain_raw(&tl, 0x0002, profile_len, profile); | |
76 free(encoding); | |
3952 | 77 } |
78 | |
79 /* | |
80 * So here's how this works: | |
81 * - You are away when you have a non-zero-length type 4 TLV stored. | |
82 * - You become unaway when you clear the TLV with a zero-length | |
83 * type 4 TLV. | |
84 * - If you do not send the type 4 TLV, your status does not change | |
85 * (that is, if you were away, you'll remain away). | |
86 */ | |
87 if (awaymsg) { | |
4151 | 88 if (awaymsg_len) { |
89 encoding = malloc(strlen(defencoding) + strlen(awaymsg_encoding)); | |
90 if (encoding == NULL) { | |
91 return -ENOMEM; | |
92 } | |
93 snprintf(encoding, strlen(defencoding) + strlen(awaymsg_encoding), defencoding, awaymsg_encoding); | |
94 aim_addtlvtochain_raw(&tl, 0x0003, strlen(encoding), encoding); | |
95 aim_addtlvtochain_raw(&tl, 0x0004, awaymsg_len, awaymsg); | |
96 free(encoding); | |
3952 | 97 } else |
98 aim_addtlvtochain_noval(&tl, 0x0004); | |
99 } | |
100 | |
101 aim_addtlvtochain_caps(&tl, 0x0005, caps); | |
102 | |
103 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + aim_sizetlvchain(&tl)))) | |
104 return -ENOMEM; | |
105 | |
106 snacid = aim_cachesnac(sess, 0x0002, 0x0004, 0x0000, NULL, 0); | |
107 | |
108 aim_putsnac(&fr->data, 0x0002, 0x004, 0x0000, snacid); | |
109 aim_writetlvchain(&fr->data, &tl); | |
110 aim_freetlvchain(&tl); | |
111 | |
112 aim_tx_enqueue(sess, fr); | |
113 | |
114 return 0; | |
115 } | |
116 | |
117 /* | |
118 * Subtype 0x0005 - Request info of another AIM user. | |
119 * | |
120 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
121 faim_export int aim_getinfo(aim_session_t *sess, aim_conn_t *conn, const char *sn, fu16_t infotype) |
2086 | 122 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
123 struct aim_priv_inforeq privdata; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
124 aim_frame_t *fr; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
125 aim_snacid_t snacid; |
2086 | 126 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
127 if (!sess || !conn || !sn) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
128 return -EINVAL; |
2086 | 129 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
130 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 12+1+strlen(sn)))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
131 return -ENOMEM; |
2086 | 132 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
133 strncpy(privdata.sn, sn, sizeof(privdata.sn)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
134 privdata.infotype = infotype; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
135 snacid = aim_cachesnac(sess, 0x0002, 0x0005, 0x0000, &privdata, sizeof(struct aim_priv_inforeq)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
136 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
137 aim_putsnac(&fr->data, 0x0002, 0x0005, 0x0000, snacid); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
138 aimbs_put16(&fr->data, infotype); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
139 aimbs_put8(&fr->data, strlen(sn)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
140 aimbs_putraw(&fr->data, sn, strlen(sn)); |
2086 | 141 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
142 aim_tx_enqueue(sess, fr); |
2086 | 143 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
144 return 0; |
2086 | 145 } |
146 | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
147 faim_export const char *aim_userinfo_sn(aim_userinfo_t *ui) |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
148 { |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
149 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
150 if (!ui) |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
151 return NULL; |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
152 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
153 return ui->sn; |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
154 } |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
155 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
156 faim_export fu16_t aim_userinfo_flags(aim_userinfo_t *ui) |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
157 { |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
158 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
159 if (!ui) |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
160 return 0; |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
161 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
162 return ui->flags; |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
163 } |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
164 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
165 faim_export fu16_t aim_userinfo_idle(aim_userinfo_t *ui) |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
166 { |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
167 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
168 if (!ui) |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
169 return 0; |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
170 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
171 return ui->idletime; |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
172 } |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
173 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
174 faim_export float aim_userinfo_warnlevel(aim_userinfo_t *ui) |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
175 { |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
176 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
177 if (!ui) |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
178 return 0.00; |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
179 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
180 return (ui->warnlevel / 10); |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
181 } |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
182 |
3459 | 183 faim_export time_t aim_userinfo_createtime(aim_userinfo_t *ui) |
184 { | |
185 | |
186 if (!ui) | |
187 return 0; | |
188 | |
189 return (time_t)ui->createtime; | |
190 } | |
191 | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
192 faim_export time_t aim_userinfo_membersince(aim_userinfo_t *ui) |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
193 { |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
194 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
195 if (!ui) |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
196 return 0; |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
197 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
198 return (time_t)ui->membersince; |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
199 } |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
200 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
201 faim_export time_t aim_userinfo_onlinesince(aim_userinfo_t *ui) |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
202 { |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
203 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
204 if (!ui) |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
205 return 0; |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
206 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
207 return (time_t)ui->onlinesince; |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
208 } |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
209 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
210 faim_export fu32_t aim_userinfo_sessionlen(aim_userinfo_t *ui) |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
211 { |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
212 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
213 if (!ui) |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
214 return 0; |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
215 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
216 return ui->sessionlen; |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
217 } |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
218 |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
219 faim_export int aim_userinfo_hascap(aim_userinfo_t *ui, fu32_t cap) |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
220 { |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
221 |
2993 | 222 if (!ui || !(ui->present & AIM_USERINFO_PRESENT_CAPABILITIES)) |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
223 return -1; |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
224 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
225 return !!(ui->capabilities & cap); |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
226 } |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
227 |
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
228 |
2086 | 229 /* |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
230 * Capability blocks. |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
231 * |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
232 * These are CLSIDs. They should actually be of the form: |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
233 * |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
234 * {0x0946134b, 0x4c7f, 0x11d1, |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
235 * {0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}}, |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
236 * |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
237 * But, eh. |
2086 | 238 */ |
239 static const struct { | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
240 fu32_t flag; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
241 fu8_t data[16]; |
2086 | 242 } aim_caps[] = { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
243 |
2669 | 244 /* |
5927 | 245 * These are in ascending numerical order. |
2669 | 246 */ |
5917 | 247 {AIM_CAPS_ICHAT, |
248 {0x09, 0x46, 0x00, 0x00, 0x4c, 0x7f, 0x11, 0xd1, | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
249 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
250 |
6318 | 251 {AIM_CAPS_HIPTOP, |
252 {0x09, 0x46, 0x13, 0x23, 0x4c, 0x7f, 0x11, 0xd1, | |
253 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, | |
254 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
255 {AIM_CAPS_VOICE, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
256 {0x09, 0x46, 0x13, 0x41, 0x4c, 0x7f, 0x11, 0xd1, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
257 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, |
2086 | 258 |
2669 | 259 {AIM_CAPS_SENDFILE, |
260 {0x09, 0x46, 0x13, 0x43, 0x4c, 0x7f, 0x11, 0xd1, | |
261 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, | |
262 | |
263 /* | |
264 * Advertised by the EveryBuddy client. | |
265 */ | |
2734
9fc65bb80596
[gaim-migrate @ 2747]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
266 {AIM_CAPS_ICQ, |
2669 | 267 {0x09, 0x46, 0x13, 0x44, 0x4c, 0x7f, 0x11, 0xd1, |
268 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, | |
269 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
270 {AIM_CAPS_IMIMAGE, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
271 {0x09, 0x46, 0x13, 0x45, 0x4c, 0x7f, 0x11, 0xd1, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
272 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
273 |
2669 | 274 {AIM_CAPS_BUDDYICON, |
275 {0x09, 0x46, 0x13, 0x46, 0x4c, 0x7f, 0x11, 0xd1, | |
276 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, | |
277 | |
4870 | 278 /* |
279 * Windows AIM calls this "Add-ins," which is probably more accurate | |
280 */ | |
2669 | 281 {AIM_CAPS_SAVESTOCKS, |
282 {0x09, 0x46, 0x13, 0x47, 0x4c, 0x7f, 0x11, 0xd1, | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
283 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
284 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
285 {AIM_CAPS_GETFILE, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
286 {0x09, 0x46, 0x13, 0x48, 0x4c, 0x7f, 0x11, 0xd1, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
287 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, |
2086 | 288 |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
289 {AIM_CAPS_ICQSERVERRELAY, |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
290 {0x09, 0x46, 0x13, 0x49, 0x4c, 0x7f, 0x11, 0xd1, |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
291 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
292 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
293 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
294 * Indeed, there are two of these. The former appears to be correct, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
295 * but in some versions of winaim, the second one is set. Either they |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
296 * forgot to fix endianness, or they made a typo. It really doesn't |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
297 * matter which. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
298 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
299 {AIM_CAPS_GAMES, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
300 {0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
301 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
302 {AIM_CAPS_GAMES2, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
303 {0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
304 0x22, 0x82, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, |
2086 | 305 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
306 {AIM_CAPS_SENDBUDDYLIST, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
307 {0x09, 0x46, 0x13, 0x4b, 0x4c, 0x7f, 0x11, 0xd1, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
308 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, |
2086 | 309 |
4811 | 310 /* |
4898 | 311 * Setting this lets AIM users receive messages from ICQ users, and ICQ |
312 * users receive messages from AIM users. It also lets ICQ users show | |
313 * up in buddy lists for AIM users, and AIM users show up in buddy lists | |
314 * for ICQ users. And ICQ privacy/invisibility acts like AIM privacy, | |
315 * in that if you add a user to your deny list, you will not be able to | |
316 * see them as online (previous you could still see them, but they | |
317 * couldn't see you. | |
4811 | 318 */ |
319 {AIM_CAPS_INTEROPERATE, | |
320 {0x09, 0x46, 0x13, 0x4d, 0x4c, 0x7f, 0x11, 0xd1, | |
321 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, | |
322 | |
4650 | 323 {AIM_CAPS_ICQUTF8, |
3952 | 324 {0x09, 0x46, 0x13, 0x4e, 0x4c, 0x7f, 0x11, 0xd1, |
4650 | 325 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, |
326 | |
327 {AIM_CAPS_ICQUNKNOWN, | |
328 {0x2e, 0x7a, 0x64, 0x75, 0xfa, 0xdf, 0x4d, 0xc8, | |
329 0x88, 0x6f, 0xea, 0x35, 0x95, 0xfd, 0xb6, 0xdf}}, | |
330 | |
331 /* | |
5917 | 332 * Chat is oddball. |
333 */ | |
334 {AIM_CAPS_CHAT, | |
335 {0x74, 0x8f, 0x24, 0x20, 0x62, 0x87, 0x11, 0xd1, | |
336 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, | |
337 | |
338 /* | |
4650 | 339 {AIM_CAPS_ICQ2GO, |
340 {0x56, 0x3f, 0xc8, 0x09, 0x0b, 0x6f, 0x41, 0xbd, | |
341 0x9f, 0x79, 0x42, 0x26, 0x09, 0xdf, 0xa2, 0xf3}}, | |
342 */ | |
3952 | 343 |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
344 {AIM_CAPS_ICQRTF, |
4650 | 345 {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34, |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
346 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x92}}, |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
347 |
3952 | 348 /* supposed to be ICQRTF? |
349 {AIM_CAPS_TRILLUNKNOWN, | |
350 {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34, | |
351 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x09}}, */ | |
352 | |
4650 | 353 {AIM_CAPS_APINFO, |
5917 | 354 {0xaa, 0x4a, 0x32, 0xb5, 0xf8, 0x84, 0x48, 0xc6, |
4650 | 355 0xa3, 0xd7, 0x8c, 0x50, 0x97, 0x19, 0xfd, 0x5b}}, |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
356 |
2920 | 357 {AIM_CAPS_TRILLIANCRYPT, |
358 {0xf2, 0xe7, 0xc7, 0xf4, 0xfe, 0xad, 0x4d, 0xfb, | |
359 0xb2, 0x35, 0x36, 0x79, 0x8b, 0xdf, 0x00, 0x00}}, | |
360 | |
4650 | 361 {AIM_CAPS_EMPTY, |
362 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
363 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, | |
2979 | 364 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
365 {AIM_CAPS_LAST} |
2086 | 366 }; |
367 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
368 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
369 * This still takes a length parameter even with a bstream because capabilities |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
370 * are not naturally bounded. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
371 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
372 */ |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
373 faim_internal fu32_t aim_getcap(aim_session_t *sess, aim_bstream_t *bs, int len) |
2086 | 374 { |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
375 fu32_t flags = 0; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
376 int offset; |
2086 | 377 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
378 for (offset = 0; aim_bstream_empty(bs) && (offset < len); offset += 0x10) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
379 fu8_t *cap; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
380 int i, identified; |
2086 | 381 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
382 cap = aimbs_getraw(bs, 0x10); |
2086 | 383 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
384 for (i = 0, identified = 0; !(aim_caps[i].flag & AIM_CAPS_LAST); i++) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
385 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
386 if (memcmp(&aim_caps[i].data, cap, 0x10) == 0) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
387 flags |= aim_caps[i].flag; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
388 identified++; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
389 break; /* should only match once... */ |
2086 | 390 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
391 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
392 } |
2086 | 393 |
2920 | 394 if (!identified) { |
395 faimdprintf(sess, 0, "unknown capability: {%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n", | |
396 cap[0], cap[1], cap[2], cap[3], | |
397 cap[4], cap[5], | |
398 cap[6], cap[7], | |
399 cap[8], cap[9], | |
400 cap[10], cap[11], cap[12], cap[13], | |
401 cap[14], cap[15]); | |
402 } | |
2086 | 403 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
404 free(cap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
405 } |
2086 | 406 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
407 return flags; |
2086 | 408 } |
409 | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
410 faim_internal int aim_putcap(aim_bstream_t *bs, fu32_t caps) |
2086 | 411 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
412 int i; |
2086 | 413 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
414 if (!bs) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
415 return -EINVAL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
416 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
417 for (i = 0; aim_bstream_empty(bs); i++) { |
2086 | 418 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
419 if (aim_caps[i].flag == AIM_CAPS_LAST) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
420 break; |
2086 | 421 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
422 if (caps & aim_caps[i].flag) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
423 aimbs_putraw(bs, aim_caps[i].data, 0x10); |
2086 | 424 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
425 } |
2086 | 426 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
427 return 0; |
2086 | 428 } |
429 | |
3459 | 430 static void dumptlv(aim_session_t *sess, fu16_t type, aim_bstream_t *bs, fu8_t len) |
431 { | |
432 int i; | |
433 | |
434 if (!sess || !bs || !len) | |
435 return; | |
436 | |
437 faimdprintf(sess, 0, "userinfo: type =0x%04x\n", type); | |
438 faimdprintf(sess, 0, "userinfo: length=0x%04x\n", len); | |
439 | |
440 faimdprintf(sess, 0, "userinfo: value:\n"); | |
441 | |
442 for (i = 0; i < len; i++) { | |
443 if ((i % 8) == 0) | |
444 faimdprintf(sess, 0, "\nuserinfo: "); | |
445 | |
446 faimdprintf(sess, 0, "0x%2x ", aimbs_get8(bs)); | |
447 } | |
448 | |
449 faimdprintf(sess, 0, "\n"); | |
450 | |
451 return; | |
452 } | |
453 | |
5836 | 454 faim_internal void aim_info_free(aim_userinfo_t *info) |
455 { | |
456 free(info->iconcsum); | |
6292 | 457 free(info->availmsg_encoding); |
458 free(info->availmsg); | |
5836 | 459 } |
460 | |
2086 | 461 /* |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
462 * AIM is fairly regular about providing user info. This is a generic |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
463 * routine to extract it in its standard form. |
2086 | 464 */ |
5836 | 465 faim_internal int aim_info_extract(aim_session_t *sess, aim_bstream_t *bs, aim_userinfo_t *outinfo) |
2086 | 466 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
467 int curtlv, tlvcnt; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
468 fu8_t snlen; |
2086 | 469 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
470 if (!bs || !outinfo) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
471 return -EINVAL; |
2086 | 472 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
473 /* Clear out old data first */ |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
474 memset(outinfo, 0x00, sizeof(aim_userinfo_t)); |
2086 | 475 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
476 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
477 * Screen name. Stored as an unterminated string prepended with a |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
478 * byte containing its length. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
479 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
480 snlen = aimbs_get8(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
481 aimbs_getrawbuf(bs, outinfo->sn, snlen); |
2086 | 482 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
483 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
484 * Warning Level. Stored as an unsigned short. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
485 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
486 outinfo->warnlevel = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
487 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
488 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
489 * TLV Count. Unsigned short representing the number of |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
490 * Type-Length-Value triples that follow. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
491 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
492 tlvcnt = aimbs_get16(bs); |
2086 | 493 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
494 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
495 * Parse out the Type-Length-Value triples as they're found. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
496 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
497 for (curtlv = 0; curtlv < tlvcnt; curtlv++) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
498 int endpos; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
499 fu16_t type, length; |
2086 | 500 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
501 type = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
502 length = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
503 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
504 endpos = aim_bstream_curpos(bs) + length; |
2086 | 505 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
506 if (type == 0x0001) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
507 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
508 * Type = 0x0001: User flags |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
509 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
510 * Specified as any of the following ORed together: |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
511 * 0x0001 Trial (user less than 60days) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
512 * 0x0002 Unknown bit 2 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
513 * 0x0004 AOL Main Service user |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
514 * 0x0008 Unknown bit 4 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
515 * 0x0010 Free (AIM) user |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
516 * 0x0020 Away |
2315
7ec21662ffc2
[gaim-migrate @ 2325]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
517 * 0x0400 ActiveBuddy |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
518 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
519 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
520 outinfo->flags = aimbs_get16(bs); |
2993 | 521 outinfo->present |= AIM_USERINFO_PRESENT_FLAGS; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
522 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
523 } else if (type == 0x0002) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
524 /* |
3459 | 525 * Type = 0x0002: Account creation time. |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
526 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
527 * The time/date that the user originally registered for |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
528 * the service, stored in time_t format. |
3459 | 529 * |
530 * I'm not sure how this differs from type 5 ("member | |
531 * since"). | |
532 * | |
533 * Note: This is the field formerly known as "member | |
534 * since". All these years and I finally found out | |
535 * that I got the name wrong. | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
536 */ |
3459 | 537 outinfo->createtime = aimbs_get32(bs); |
538 outinfo->present |= AIM_USERINFO_PRESENT_CREATETIME; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
539 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
540 } else if (type == 0x0003) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
541 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
542 * Type = 0x0003: On-Since date. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
543 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
544 * The time/date that the user started their current |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
545 * session, stored in time_t format. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
546 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
547 outinfo->onlinesince = aimbs_get32(bs); |
2993 | 548 outinfo->present |= AIM_USERINFO_PRESENT_ONLINESINCE; |
2086 | 549 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
550 } else if (type == 0x0004) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
551 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
552 * Type = 0x0004: Idle time. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
553 * |
4443 | 554 * Number of minutes since the user actively used the |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
555 * service. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
556 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
557 * Note that the client tells the server when to start |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
558 * counting idle times, so this may or may not be |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
559 * related to reality. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
560 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
561 outinfo->idletime = aimbs_get16(bs); |
2993 | 562 outinfo->present |= AIM_USERINFO_PRESENT_IDLE; |
3952 | 563 |
3459 | 564 } else if (type == 0x0005) { |
565 /* | |
566 * Type = 0x0005: Member since date. | |
567 * | |
568 * The time/date that the user originally registered for | |
569 * the service, stored in time_t format. | |
570 * | |
571 * This is sometimes sent instead of type 2 ("account | |
572 * creation time"), particularly in the self-info. | |
3952 | 573 * And particularly for ICQ? |
3459 | 574 */ |
575 outinfo->membersince = aimbs_get32(bs); | |
576 outinfo->present |= AIM_USERINFO_PRESENT_MEMBERSINCE; | |
2086 | 577 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
578 } else if (type == 0x0006) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
579 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
580 * Type = 0x0006: ICQ Online Status |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
581 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
582 * ICQ's Away/DND/etc "enriched" status. Some decoding |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
583 * of values done by Scott <darkagl@pcnet.com> |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
584 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
585 aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
586 outinfo->icqinfo.status = aimbs_get16(bs); |
2993 | 587 outinfo->present |= AIM_USERINFO_PRESENT_ICQEXTSTATUS; |
2086 | 588 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
589 } else if (type == 0x000a) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
590 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
591 * Type = 0x000a |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
592 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
593 * ICQ User IP Address. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
594 * Ahh, the joy of ICQ security. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
595 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
596 outinfo->icqinfo.ipaddr = aimbs_get32(bs); |
2993 | 597 outinfo->present |= AIM_USERINFO_PRESENT_ICQIPADDR; |
2086 | 598 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
599 } else if (type == 0x000c) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
600 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
601 * Type = 0x000c |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
602 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
603 * random crap containing the IP address, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
604 * apparently a port number, and some Other Stuff. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
605 * |
4342 | 606 * Format is: |
607 * 4 bytes - Our IP address, 0xc0 a8 01 2b for 192.168.1.43 | |
608 * | |
609 * | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
610 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
611 aimbs_getrawbuf(bs, outinfo->icqinfo.crap, 0x25); |
2993 | 612 outinfo->present |= AIM_USERINFO_PRESENT_ICQDATA; |
2086 | 613 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
614 } else if (type == 0x000d) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
615 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
616 * Type = 0x000d |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
617 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
618 * Capability information. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
619 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
620 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
621 outinfo->capabilities = aim_getcap(sess, bs, length); |
2993 | 622 outinfo->present |= AIM_USERINFO_PRESENT_CAPABILITIES; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
623 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
624 } else if (type == 0x000e) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
625 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
626 * Type = 0x000e |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
627 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
628 * Unknown. Always of zero length, and always only |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
629 * on AOL users. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
630 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
631 * Ignore. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
632 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
633 */ |
2086 | 634 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
635 } else if ((type == 0x000f) || (type == 0x0010)) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
636 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
637 * Type = 0x000f: Session Length. (AIM) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
638 * Type = 0x0010: Session Length. (AOL) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
639 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
640 * The duration, in seconds, of the user's current |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
641 * session. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
642 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
643 * Which TLV type this comes in depends on the |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
644 * service the user is using (AIM or AOL). |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
645 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
646 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
647 outinfo->sessionlen = aimbs_get32(bs); |
2993 | 648 outinfo->present |= AIM_USERINFO_PRESENT_SESSIONLEN; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
649 |
5917 | 650 } else if (type == 0x0019) { |
6113 | 651 /* faimdprintf(sess, 0, "userinfo: **warning: unexpected TLV type 0x0019: from %s\n", outinfo->sn); */ |
652 | |
653 } else if (type == 0x001b) { | |
654 /* faimdprintf(sess, 0, "userinfo: **warning: unexpected TLV type 0x001b: from %s\n", outinfo->sn); */ | |
5917 | 655 |
3459 | 656 } else if (type == 0x001d) { |
657 /* | |
4804 | 658 * Type = 0x001d |
3459 | 659 * |
5836 | 660 * Buddy icon information and available messages. |
661 * | |
662 * This almost seems like the AIM protocol guys gave | |
663 * the iChat guys a Type, and the iChat guys tried to | |
664 * cram as much cool shit into it as possible. Then | |
665 * the Windows AIM guys were like, "hey, that's | |
666 * pretty neat, let's copy those prawns." | |
667 * | |
668 * In that spirit, this can contain a custom message, | |
669 * kind of like an away message, but you're not away | |
670 * (it's called an "available" message). Or it can | |
671 * contain information about the buddy icon the user | |
672 * has stored on the server. | |
3459 | 673 */ |
5836 | 674 int type2, number, length2; |
4853 | 675 |
4826 | 676 while (aim_bstream_curpos(bs) < endpos) { |
5836 | 677 type2 = aimbs_get16(bs); |
4853 | 678 number = aimbs_get8(bs); |
5836 | 679 length2 = aimbs_get8(bs); |
680 | |
681 switch (type2) { | |
682 case 0x0000: { /* This is an official buddy icon? */ | |
6292 | 683 /* This is always 5 bytes of "0x02 01 d2 04 72"? */ |
5836 | 684 aim_bstream_advance(bs, length2); |
685 } break; | |
686 | |
687 case 0x0001: { /* A buddy icon checksum */ | |
688 if ((length2 > 0) && (number == 0x01)) { | |
689 free(outinfo->iconcsum); | |
690 outinfo->iconcsum = aimbs_getraw(bs, length2); | |
691 outinfo->iconcsumlen = length2; | |
692 } else | |
693 aim_bstream_advance(bs, length2); | |
694 } break; | |
695 | |
696 case 0x0002: { /* An available message */ | |
697 if (length2 > 4) { | |
6292 | 698 free(outinfo->availmsg); |
699 outinfo->availmsg_len = aimbs_get16(bs); | |
6318 | 700 outinfo->availmsg = aimbs_getstr(bs, outinfo->availmsg_len); |
6292 | 701 if (aimbs_get16(bs) == 0x0001) { /* We have an encoding */ |
702 aimbs_get16(bs); | |
703 outinfo->availmsg_encoding = aimbs_getstr(bs, aimbs_get16(bs)); | |
704 } else { | |
705 /* No explicit encoding, client should use UTF-8 */ | |
706 outinfo->availmsg_encoding = NULL; | |
707 } | |
5836 | 708 } else |
709 aim_bstream_advance(bs, length2); | |
710 } break; | |
711 | |
712 default: { | |
713 aim_bstream_advance(bs, length2); | |
714 } break; | |
715 } | |
4809 | 716 } |
3459 | 717 |
718 } else if (type == 0x001e) { | |
719 /* | |
720 * Type 30: Unknown. | |
721 * | |
722 * Always four bytes, but it doesn't look like an int. | |
723 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
724 } else { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
725 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
726 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
727 * Reaching here indicates that either AOL has |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
728 * added yet another TLV for us to deal with, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
729 * or the parsing has gone Terribly Wrong. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
730 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
731 * Either way, inform the owner and attempt |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
732 * recovery. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
733 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
734 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
735 faimdprintf(sess, 0, "userinfo: **warning: unexpected TLV:\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
736 faimdprintf(sess, 0, "userinfo: sn =%s\n", outinfo->sn); |
3459 | 737 dumptlv(sess, type, bs, length); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
738 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
739 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
740 /* Save ourselves. */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
741 aim_bstream_setpos(bs, endpos); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
742 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
743 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
744 return 0; |
2086 | 745 } |
746 | |
747 /* | |
5836 | 748 * Inverse of aim_info_extract() |
2086 | 749 */ |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
750 faim_internal int aim_putuserinfo(aim_bstream_t *bs, aim_userinfo_t *info) |
2086 | 751 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
752 aim_tlvlist_t *tlvlist = NULL; |
2086 | 753 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
754 if (!bs || !info) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
755 return -EINVAL; |
2086 | 756 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
757 aimbs_put8(bs, strlen(info->sn)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
758 aimbs_putraw(bs, info->sn, strlen(info->sn)); |
2086 | 759 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
760 aimbs_put16(bs, info->warnlevel); |
2086 | 761 |
762 | |
3459 | 763 if (info->present & AIM_USERINFO_PRESENT_FLAGS) |
764 aim_addtlvtochain16(&tlvlist, 0x0001, info->flags); | |
765 if (info->present & AIM_USERINFO_PRESENT_MEMBERSINCE) | |
766 aim_addtlvtochain32(&tlvlist, 0x0002, info->membersince); | |
767 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) | |
768 aim_addtlvtochain32(&tlvlist, 0x0003, info->onlinesince); | |
769 if (info->present & AIM_USERINFO_PRESENT_IDLE) | |
770 aim_addtlvtochain16(&tlvlist, 0x0004, info->idletime); | |
2086 | 771 |
3952 | 772 /* XXX - So, ICQ_OSCAR_SUPPORT is never defined anywhere... */ |
2086 | 773 #if ICQ_OSCAR_SUPPORT |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
774 if (atoi(info->sn) != 0) { |
3459 | 775 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) |
776 aim_addtlvtochain16(&tlvlist, 0x0006, info->icqinfo.status); | |
777 if (info->present & AIM_USERINFO_PRESENT_ICQIPADDR) | |
778 aim_addtlvtochain32(&tlvlist, 0x000a, info->icqinfo.ipaddr); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
779 } |
2086 | 780 #endif |
781 | |
3459 | 782 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
783 aim_addtlvtochain_caps(&tlvlist, 0x000d, info->capabilities); | |
784 | |
785 if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
786 aim_addtlvtochain32(&tlvlist, (fu16_t)((info->flags & AIM_FLAG_AOL) ? 0x0010 : 0x000f), info->sessionlen); | |
2086 | 787 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
788 aimbs_put16(bs, aim_counttlvchain(&tlvlist)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
789 aim_writetlvchain(bs, &tlvlist); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
790 aim_freetlvchain(&tlvlist); |
2086 | 791 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
792 return 0; |
2086 | 793 } |
794 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
795 /* |
3952 | 796 * Subtype 0x000b - Huh? What is this? |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
797 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
798 faim_export int aim_0002_000b(aim_session_t *sess, aim_conn_t *conn, const char *sn) |
2086 | 799 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
800 aim_frame_t *fr; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
801 aim_snacid_t snacid; |
2086 | 802 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
803 if (!sess || !conn || !sn) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
804 return -EINVAL; |
2086 | 805 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
806 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+1+strlen(sn)))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
807 return -ENOMEM; |
2086 | 808 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
809 snacid = aim_cachesnac(sess, 0x0002, 0x000b, 0x0000, NULL, 0); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
810 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
811 aim_putsnac(&fr->data, 0x0002, 0x000b, 0x0000, snacid); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
812 aimbs_put8(&fr->data, strlen(sn)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
813 aimbs_putraw(&fr->data, sn, strlen(sn)); |
2086 | 814 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
815 aim_tx_enqueue(sess, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
816 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
817 return 0; |
2086 | 818 } |
819 | |
2122 | 820 /* |
3952 | 821 * Subtype 0x0003 |
822 * | |
2122 | 823 * Normally contains: |
824 * t(0001) - short containing max profile length (value = 1024) | |
825 * t(0002) - short - unknown (value = 16) [max MIME type length?] | |
2315
7ec21662ffc2
[gaim-migrate @ 2325]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
826 * t(0003) - short - unknown (value = 10) |
3213 | 827 * t(0004) - short - unknown (value = 2048) [ICQ only?] |
2122 | 828 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
829 static int rights(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 830 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
831 aim_tlvlist_t *tlvlist; |
2122 | 832 aim_rxcallback_t userfunc; |
833 int ret = 0; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
834 fu16_t maxsiglen = 0; |
2086 | 835 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
836 tlvlist = aim_readtlvchain(bs); |
2086 | 837 |
2122 | 838 if (aim_gettlv(tlvlist, 0x0001, 1)) |
839 maxsiglen = aim_gettlv16(tlvlist, 0x0001, 1); | |
2086 | 840 |
2122 | 841 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
842 ret = userfunc(sess, rx, maxsiglen); | |
2086 | 843 |
2122 | 844 aim_freetlvchain(&tlvlist); |
845 | |
846 return ret; | |
2086 | 847 } |
848 | |
3952 | 849 /* Subtype 0x0006 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
850 static int userinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 851 { |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
852 aim_userinfo_t userinfo; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
853 char *text_encoding = NULL, *text = NULL; |
4151 | 854 int textlen = 0; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
855 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
856 aim_tlvlist_t *tlvlist; |
4151 | 857 aim_tlv_t *text_tlv = NULL; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
858 aim_snac_t *origsnac = NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
859 struct aim_priv_inforeq *inforeq; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
860 int ret = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
861 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
862 origsnac = aim_remsnac(sess, snac->id); |
2086 | 863 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
864 if (!origsnac || !origsnac->data) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
865 faimdprintf(sess, 0, "parse_userinfo_middle: major problem: no snac stored!\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
866 return 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
867 } |
2086 | 868 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
869 inforeq = (struct aim_priv_inforeq *)origsnac->data; |
2086 | 870 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
871 if ((inforeq->infotype != AIM_GETINFO_GENERALINFO) && |
2920 | 872 (inforeq->infotype != AIM_GETINFO_AWAYMESSAGE) && |
873 (inforeq->infotype != AIM_GETINFO_CAPABILITIES)) { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
874 faimdprintf(sess, 0, "parse_userinfo_middle: unknown infotype in request! (0x%04x)\n", inforeq->infotype); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
875 return 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
876 } |
2086 | 877 |
5836 | 878 aim_info_extract(sess, bs, &userinfo); |
2086 | 879 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
880 tlvlist = aim_readtlvchain(bs); |
2086 | 881 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
882 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
883 * Depending on what informational text was requested, different |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
884 * TLVs will appear here. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
885 * |
2920 | 886 * Profile will be 1 and 2, away message will be 3 and 4, caps |
887 * will be 5. | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
888 */ |
2920 | 889 if (inforeq->infotype == AIM_GETINFO_GENERALINFO) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
890 text_encoding = aim_gettlv_str(tlvlist, 0x0001, 1); |
4151 | 891 text_tlv = aim_gettlv(tlvlist, 0x0002, 1); |
2920 | 892 } else if (inforeq->infotype == AIM_GETINFO_AWAYMESSAGE) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
893 text_encoding = aim_gettlv_str(tlvlist, 0x0003, 1); |
4151 | 894 text_tlv = aim_gettlv(tlvlist, 0x0004, 1); |
2920 | 895 } else if (inforeq->infotype == AIM_GETINFO_CAPABILITIES) { |
896 aim_tlv_t *ct; | |
897 | |
898 if ((ct = aim_gettlv(tlvlist, 0x0005, 1))) { | |
899 aim_bstream_t cbs; | |
900 | |
901 aim_bstream_init(&cbs, ct->value, ct->length); | |
902 | |
903 userinfo.capabilities = aim_getcap(sess, &cbs, ct->length); | |
2993 | 904 userinfo.present = AIM_USERINFO_PRESENT_CAPABILITIES; |
2920 | 905 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
906 } |
2086 | 907 |
4151 | 908 if (text_tlv) { |
909 text = text_tlv->value; | |
910 textlen = text_tlv->length; | |
911 } | |
912 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
913 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
4151 | 914 ret = userfunc(sess, rx, &userinfo, inforeq->infotype, text_encoding, text, textlen); |
2086 | 915 |
5836 | 916 aim_info_free(&userinfo); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
917 free(text_encoding); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
918 aim_freetlvchain(&tlvlist); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
919 if (origsnac) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
920 free(origsnac->data); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
921 free(origsnac); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
922 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
923 return ret; |
2086 | 924 } |
925 | |
3952 | 926 /* |
927 * Subtype 0x0009 - Set directory profile data. | |
928 * | |
929 * This is not the same as aim_bos_setprofile! | |
930 * privacy: 1 to allow searching, 0 to disallow. | |
931 * | |
932 */ | |
933 faim_export int aim_setdirectoryinfo(aim_session_t *sess, aim_conn_t *conn, const char *first, const char *middle, const char *last, const char *maiden, const char *nickname, const char *street, const char *city, const char *state, const char *zip, int country, fu16_t privacy) | |
934 { | |
935 aim_frame_t *fr; | |
936 aim_snacid_t snacid; | |
937 aim_tlvlist_t *tl = NULL; | |
938 | |
939 aim_addtlvtochain16(&tl, 0x000a, privacy); | |
940 | |
941 if (first) | |
942 aim_addtlvtochain_raw(&tl, 0x0001, strlen(first), first); | |
943 if (last) | |
944 aim_addtlvtochain_raw(&tl, 0x0002, strlen(last), last); | |
945 if (middle) | |
946 aim_addtlvtochain_raw(&tl, 0x0003, strlen(middle), middle); | |
947 if (maiden) | |
948 aim_addtlvtochain_raw(&tl, 0x0004, strlen(maiden), maiden); | |
949 | |
950 if (state) | |
951 aim_addtlvtochain_raw(&tl, 0x0007, strlen(state), state); | |
952 if (city) | |
953 aim_addtlvtochain_raw(&tl, 0x0008, strlen(city), city); | |
954 | |
955 if (nickname) | |
956 aim_addtlvtochain_raw(&tl, 0x000c, strlen(nickname), nickname); | |
957 if (zip) | |
958 aim_addtlvtochain_raw(&tl, 0x000d, strlen(zip), zip); | |
959 | |
960 if (street) | |
961 aim_addtlvtochain_raw(&tl, 0x0021, strlen(street), street); | |
962 | |
963 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_sizetlvchain(&tl)))) | |
964 return -ENOMEM; | |
965 | |
966 snacid = aim_cachesnac(sess, 0x0002, 0x0009, 0x0000, NULL, 0); | |
967 | |
968 aim_putsnac(&fr->data, 0x0002, 0x0009, 0x0000, snacid); | |
969 aim_writetlvchain(&fr->data, &tl); | |
970 aim_freetlvchain(&tl); | |
971 | |
972 aim_tx_enqueue(sess, fr); | |
973 | |
974 return 0; | |
975 } | |
976 | |
977 /* | |
978 * Subtype 0x000f | |
979 * | |
980 * XXX pass these in better | |
981 * | |
982 */ | |
983 faim_export int aim_setuserinterests(aim_session_t *sess, aim_conn_t *conn, const char *interest1, const char *interest2, const char *interest3, const char *interest4, const char *interest5, fu16_t privacy) | |
984 { | |
985 aim_frame_t *fr; | |
986 aim_snacid_t snacid; | |
987 aim_tlvlist_t *tl = NULL; | |
988 | |
989 /* ?? privacy ?? */ | |
990 aim_addtlvtochain16(&tl, 0x000a, privacy); | |
991 | |
992 if (interest1) | |
993 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest1), interest1); | |
994 if (interest2) | |
995 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest2), interest2); | |
996 if (interest3) | |
997 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest3), interest3); | |
998 if (interest4) | |
999 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest4), interest4); | |
1000 if (interest5) | |
1001 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest5), interest5); | |
1002 | |
1003 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_sizetlvchain(&tl)))) | |
1004 return -ENOMEM; | |
1005 | |
1006 snacid = aim_cachesnac(sess, 0x0002, 0x000f, 0x0000, NULL, 0); | |
1007 | |
1008 aim_putsnac(&fr->data, 0x0002, 0x000f, 0x0000, 0); | |
1009 aim_writetlvchain(&fr->data, &tl); | |
1010 aim_freetlvchain(&tl); | |
1011 | |
1012 aim_tx_enqueue(sess, fr); | |
1013 | |
1014 return 0; | |
1015 } | |
1016 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1017 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 1018 { |
1019 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1020 if (snac->subtype == 0x0003) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1021 return rights(sess, mod, rx, snac, bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1022 else if (snac->subtype == 0x0006) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1023 return userinfo(sess, mod, rx, snac, bs); |
2086 | 1024 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1025 return 0; |
2086 | 1026 } |
1027 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1028 faim_internal int locate_modfirst(aim_session_t *sess, aim_module_t *mod) |
2086 | 1029 { |
1030 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1031 mod->family = 0x0002; |
2672 | 1032 mod->version = 0x0001; |
4071 | 1033 mod->toolid = 0x0110; |
1034 mod->toolversion = 0x0629; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1035 mod->flags = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1036 strncpy(mod->name, "locate", sizeof(mod->name)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1037 mod->snachandler = snachandler; |
2086 | 1038 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1039 return 0; |
2086 | 1040 } |