2 * Purple's oscar protocol plugin
3 * This file is the legal property of its developers.
4 * Please see the AUTHORS file distributed alongside this file.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 * Family 0x0002 - Locate.
24 * The functions here are responsible for requesting and parsing information-
25 * gathering SNACs. Or something like that. This family contains the SNACs
26 * for getting and setting info, away messages, directory profile thingy, etc.
31 /* Define to log unknown TLVs */
32 /* #define LOG_UNKNOWN_TLV */
37 * These are CLSIDs. They should actually be of the form:
39 * {0x0946134b, 0x4c7f, 0x11d1,
40 * {0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}},
50 * These are in ascending numerical order.
53 /* Client understands short caps, a UUID of the form
54 * 0946XXYY-4C7F-11D1-8222-444553540000 where XXYY is the short cap. */
55 {OSCAR_CAPABILITY_SHORTCAPS
,
56 {0x09, 0x46, 0x00, 0x00, 0x4c, 0x7f, 0x11, 0xd1,
57 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
59 {OSCAR_CAPABILITY_SECUREIM
,
60 {0x09, 0x46, 0x00, 0x01, 0x4c, 0x7f, 0x11, 0xd1,
61 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
63 /* OSCAR_CAPABILITY_XHTML_IM */
64 {OSCAR_CAPABILITY_GENERICUNKNOWN
,
65 {0x09, 0x46, 0x00, 0x02, 0x4c, 0x7f, 0x11, 0xd1,
66 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
68 {OSCAR_CAPABILITY_VIDEO
,
69 {0x09, 0x46, 0x01, 0x00, 0x4c, 0x7f, 0x11, 0xd1,
70 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
72 /* "Live Video" (SIP/RTC Video) support in Windows AIM 5.5.3501 and newer */
73 {OSCAR_CAPABILITY_LIVEVIDEO
,
74 {0x09, 0x46, 0x01, 0x01, 0x4c, 0x7f, 0x11, 0xd1,
75 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
77 /* "Camera" support in Windows AIM 5.5.3501 and newer */
78 {OSCAR_CAPABILITY_CAMERA
,
79 {0x09, 0x46, 0x01, 0x02, 0x4c, 0x7f, 0x11, 0xd1,
80 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
82 /* "Microphone" support in Windows AIM 5.5.3501 and newer */
83 /* OSCAR_CAPABILITY_MICROPHONE */
84 {OSCAR_CAPABILITY_GENERICUNKNOWN
,
85 {0x09, 0x46, 0x01, 0x03, 0x4c, 0x7f, 0x11, 0xd1,
86 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
88 /* Supports RTC Audio */
89 /* OSCAR_CAPABILITY_RTCAUDIO */
90 {OSCAR_CAPABILITY_GENERICUNKNOWN
,
91 {0x09, 0x46, 0x01, 0x04, 0x4c, 0x7f, 0x11, 0xd1,
92 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
94 /* In iChatAV (version numbers...?) */
95 {OSCAR_CAPABILITY_ICHATAV
,
96 {0x09, 0x46, 0x01, 0x05, 0x4c, 0x7f, 0x11, 0xd1,
97 0x82, 0x22, 0x44, 0x45, 0x45, 0x53, 0x54, 0x00}},
99 /* Supports "new status message features" (Who advertises this one?) */
100 /* OSCAR_CAPABILITY_HOST_STATUS_TEXT_AWARE */
101 {OSCAR_CAPABILITY_GENERICUNKNOWN
,
102 {0x09, 0x46, 0x01, 0x0a, 0x4c, 0x7f, 0x11, 0xd1,
103 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
105 /* Supports "see as I type" (Who advertises this one?) */
106 /* OSCAR_CAPABILITY_SEE_AS_I_TYPE */
107 {OSCAR_CAPABILITY_GENERICUNKNOWN
,
108 {0x09, 0x46, 0x01, 0x0b, 0x4c, 0x7f, 0x11, 0xd1,
109 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
111 /* Client only asserts caps for services in which it is participating */
112 /* OSCAR_CAPABILITY_SMARTCAPS */
113 {OSCAR_CAPABILITY_GENERICUNKNOWN
,
114 {0x09, 0x46, 0x01, 0xff, 0x4c, 0x7f, 0x11, 0xd1,
115 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
117 {OSCAR_CAPABILITY_HIPTOP
,
118 {0x09, 0x46, 0x13, 0x23, 0x4c, 0x7f, 0x11, 0xd1,
119 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
121 {OSCAR_CAPABILITY_TALK
,
122 {0x09, 0x46, 0x13, 0x41, 0x4c, 0x7f, 0x11, 0xd1,
123 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
125 {OSCAR_CAPABILITY_SENDFILE
,
126 {0x09, 0x46, 0x13, 0x43, 0x4c, 0x7f, 0x11, 0xd1,
127 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
129 {OSCAR_CAPABILITY_ICQ_DIRECT
,
130 {0x09, 0x46, 0x13, 0x44, 0x4c, 0x7f, 0x11, 0xd1,
131 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
133 {OSCAR_CAPABILITY_DIRECTIM
,
134 {0x09, 0x46, 0x13, 0x45, 0x4c, 0x7f, 0x11, 0xd1,
135 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
137 {OSCAR_CAPABILITY_BUDDYICON
,
138 {0x09, 0x46, 0x13, 0x46, 0x4c, 0x7f, 0x11, 0xd1,
139 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
141 {OSCAR_CAPABILITY_ADDINS
,
142 {0x09, 0x46, 0x13, 0x47, 0x4c, 0x7f, 0x11, 0xd1,
143 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
145 {OSCAR_CAPABILITY_GETFILE
,
146 {0x09, 0x46, 0x13, 0x48, 0x4c, 0x7f, 0x11, 0xd1,
147 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
149 {OSCAR_CAPABILITY_ICQSERVERRELAY
,
150 {0x09, 0x46, 0x13, 0x49, 0x4c, 0x7f, 0x11, 0xd1,
151 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
154 * Indeed, there are two of these. The former appears to be correct,
155 * but in some versions of winaim, the second one is set. Either they
156 * forgot to fix endianness, or they made a typo. It really doesn't
159 {OSCAR_CAPABILITY_GAMES
,
160 {0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1,
161 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
162 {OSCAR_CAPABILITY_GAMES2
,
163 {0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1,
164 0x22, 0x82, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
166 /* New format of caps (xtraz icons) */
167 {OSCAR_CAPABILITY_NEWCAPS
,
168 {0x09, 0x46, 0x00, 0x00, 0x4c, 0x7f, 0x11, 0xd1,
169 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
171 /* Support xtraz statuses */
172 {OSCAR_CAPABILITY_XTRAZ
,
173 {0x1a, 0x09, 0x3c, 0x6c, 0xd7, 0xFD, 0x4e, 0xc5,
174 0x9d, 0x51, 0xa6, 0x47, 0x4e, 0x34, 0xf5, 0xa0}},
176 {OSCAR_CAPABILITY_SENDBUDDYLIST
,
177 {0x09, 0x46, 0x13, 0x4b, 0x4c, 0x7f, 0x11, 0xd1,
178 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
181 * Setting this lets AIM users receive messages from ICQ users, and ICQ
182 * users receive messages from AIM users. It also lets ICQ users show
183 * up in buddy lists for AIM users, and AIM users show up in buddy lists
184 * for ICQ users. And ICQ privacy/invisibility acts like AIM privacy,
185 * in that if you add a user to your deny list, you will not be able to
186 * see them as online (previous you could still see them, but they
189 {OSCAR_CAPABILITY_INTEROPERATE
,
190 {0x09, 0x46, 0x13, 0x4d, 0x4c, 0x7f, 0x11, 0xd1,
191 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
193 {OSCAR_CAPABILITY_UNICODE
,
194 {0x09, 0x46, 0x13, 0x4e, 0x4c, 0x7f, 0x11, 0xd1,
195 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
197 {OSCAR_CAPABILITY_GENERICUNKNOWN
,
198 {0x09, 0x46, 0xf0, 0x03, 0x4c, 0x7f, 0x11, 0xd1,
199 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
201 {OSCAR_CAPABILITY_ICHAT_SCREENSHARE
,
202 {0x09, 0x46, 0xf0, 0x04, 0x4c, 0x7f, 0x11, 0xd1,
203 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
205 {OSCAR_CAPABILITY_GENERICUNKNOWN
,
206 {0x09, 0x46, 0xf0, 0x05, 0x4c, 0x7f, 0x11, 0xd1,
207 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
209 {OSCAR_CAPABILITY_UNICODEOLD
,
210 {0x2e, 0x7a, 0x64, 0x75, 0xfa, 0xdf, 0x4d, 0xc8,
211 0x88, 0x6f, 0xea, 0x35, 0x95, 0xfd, 0xb6, 0xdf}},
213 {OSCAR_CAPABILITY_TYPING
,
214 {0x56, 0x3f, 0xc8, 0x09, 0x0b, 0x6f, 0x41, 0xbd,
215 0x9f, 0x79, 0x42, 0x26, 0x09, 0xdf, 0xa2, 0xf3}},
220 {OSCAR_CAPABILITY_CHAT
,
221 {0x74, 0x8f, 0x24, 0x20, 0x62, 0x87, 0x11, 0xd1,
222 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
224 /* This is added by the servers and it only shows up for ourselves... */
225 {OSCAR_CAPABILITY_GENERICUNKNOWN
,
226 {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34,
227 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x09}},
229 {OSCAR_CAPABILITY_ICQRTF
,
230 {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34,
231 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x92}},
233 {OSCAR_CAPABILITY_APINFO
,
234 {0xaa, 0x4a, 0x32, 0xb5, 0xf8, 0x84, 0x48, 0xc6,
235 0xa3, 0xd7, 0x8c, 0x50, 0x97, 0x19, 0xfd, 0x5b}},
237 {OSCAR_CAPABILITY_TRILLIANCRYPT
,
238 {0xf2, 0xe7, 0xc7, 0xf4, 0xfe, 0xad, 0x4d, 0xfb,
239 0xb2, 0x35, 0x36, 0x79, 0x8b, 0xdf, 0x00, 0x00}},
241 {OSCAR_CAPABILITY_EMPTY
,
242 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
243 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
245 {OSCAR_CAPABILITY_HTML_MSGS
,
246 {0x01, 0x38, 0xca, 0x7b, 0x76, 0x9a, 0x49, 0x15,
247 0x88, 0xf2, 0x13, 0xfc, 0x00, 0x97, 0x9e, 0xa8}},
249 {OSCAR_CAPABILITY_LAST
,
250 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
251 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
254 /* Keep this array synchronized with icq_purple_moods. */
255 static const struct {
258 } icq_custom_icons
[] = {
261 {0x3f, 0xb0, 0xbd, 0x36, 0xaf, 0x3b, 0x4a, 0x60,
262 0x9e, 0xef, 0xcf, 0x19, 0x0f, 0x6a, 0x5a, 0x7f}},
265 {0x48, 0x8e, 0x14, 0x89, 0x8a, 0xca, 0x4a, 0x08,
266 0x82, 0xaa, 0x77, 0xce, 0x7a, 0x16, 0x52, 0x08}},
269 {0x63, 0x62, 0x73, 0x37, 0xa0, 0x3f, 0x49, 0xff,
270 0x80, 0xe5, 0xf7, 0x09, 0xcd, 0xe0, 0xa4, 0xee}},
272 /* This was in the original patch, but isn't what the official client
273 * (ICQ 6) sets when you choose its typewriter icon. */
275 {0x63, 0x4f, 0x6b, 0xd8 ,0xad, 0xd2, 0x4a, 0xa1,
276 0xaa, 0xb9, 0x11, 0x5b, 0xc2, 0x6d, 0x05, 0xa1}},
279 {0x63, 0x14, 0x36, 0xff, 0x3f, 0x8a, 0x40, 0xd0,
280 0xa5, 0xcb, 0x7b, 0x66, 0xe0, 0x51, 0xb3, 0x64}},
283 {0x01, 0xd8, 0xd7, 0xee, 0xac, 0x3b, 0x49, 0x2a,
284 0xa5, 0x8d, 0xd3, 0xd8, 0x77, 0xe6, 0x6b, 0x92}},
287 {0xf8, 0xe8, 0xd7, 0xb2, 0x82, 0xc4, 0x41, 0x42,
288 0x90, 0xf8, 0x10, 0xc6, 0xce, 0x0a, 0x89, 0xa6}},
291 {0x10, 0x7a, 0x9a, 0x18, 0x12, 0x32, 0x4d, 0xa4,
292 0xb6, 0xcd, 0x08, 0x79, 0xdb, 0x78, 0x0f, 0x09}},
295 {0x1f, 0x7a, 0x40, 0x71, 0xbf, 0x3b, 0x4e, 0x60,
296 0xbc, 0x32, 0x4c, 0x57, 0x87, 0xb0, 0x4c, 0xf1}},
299 {0x2c, 0xe0, 0xe4, 0xe5, 0x7c, 0x64, 0x43, 0x70,
300 0x9c, 0x3a, 0x7a, 0x1c, 0xe8, 0x78, 0xa7, 0xdc}},
303 {0xb7, 0x08, 0x67, 0xf5, 0x38, 0x25, 0x43, 0x27,
304 0xa1, 0xff, 0xcf, 0x4c, 0xc1, 0x93, 0x97, 0x97}},
307 {0x5a, 0x58, 0x1e, 0xa1, 0xe5, 0x80, 0x43, 0x0c,
308 0xa0, 0x6f, 0x61, 0x22, 0x98, 0xb7, 0xe4, 0xc7}},
311 {0x80, 0x53, 0x7d, 0xe2, 0xa4, 0x67, 0x4a, 0x76,
312 0xb3, 0x54, 0x6d, 0xfd, 0x07, 0x5f, 0x5e, 0xc6}},
315 {0x6f, 0x49, 0x30, 0x98, 0x4f, 0x7c, 0x4a, 0xff,
316 0xa2, 0x76, 0x34, 0xa0, 0x3b, 0xce, 0xae, 0xa7}},
319 {0x78, 0x5e, 0x8c, 0x48, 0x40, 0xd3, 0x4c, 0x65,
320 0x88, 0x6f, 0x04, 0xcf, 0x3f, 0x3f, 0x43, 0xdf}},
323 {0x10, 0x11, 0x17, 0xc9, 0xa3, 0xb0, 0x40, 0xf9,
324 0x81, 0xac, 0x49, 0xe1, 0x59, 0xfb, 0xd5, 0xd4}},
327 {0xdd, 0xcf, 0x0e, 0xa9, 0x71, 0x95, 0x40, 0x48,
328 0xa9, 0xc6, 0x41, 0x32, 0x06, 0xd6, 0xf2, 0x80}},
331 {0x83, 0xc9, 0xb7, 0x8e, 0x77, 0xe7, 0x43, 0x78,
332 0xb2, 0xc5, 0xfb, 0x6c, 0xfc, 0xc3, 0x5b, 0xec}},
335 {0xf1, 0x8a, 0xb5, 0x2e, 0xdc, 0x57, 0x49, 0x1d,
336 0x99, 0xdc, 0x64, 0x44, 0x50, 0x24, 0x57, 0xaf}},
339 {0x12, 0x92, 0xe5, 0x50, 0x1b, 0x64, 0x4f, 0x66,
340 0xb2, 0x06, 0xb2, 0x9a, 0xf3, 0x78, 0xe4, 0x8d}},
343 {0xa6, 0xed, 0x55, 0x7e, 0x6b, 0xf7, 0x44, 0xd4,
344 0xa5, 0xd4, 0xd2, 0xe7, 0xd9, 0x5c, 0xe8, 0x1f}},
347 {0x16, 0x0c, 0x60, 0xbb, 0xdd, 0x44, 0x43, 0xf3,
348 0x91, 0x40, 0x05, 0x0f, 0x00, 0xe6, 0xc0, 0x09}},
351 {0xd4, 0xe2, 0xb0, 0xba, 0x33, 0x4e, 0x4f, 0xa5,
352 0x98, 0xd0, 0x11, 0x7d, 0xbf, 0x4d, 0x3c, 0xc8}},
355 {0xe6, 0x01, 0xe4, 0x1c, 0x33, 0x73, 0x4b, 0xd1,
356 0xbc, 0x06, 0x81, 0x1d, 0x6c, 0x32, 0x3d, 0x81}},
359 {0x1b, 0x78, 0xae, 0x31, 0xfa, 0x0b, 0x4d, 0x38,
360 0x93, 0xd1, 0x99, 0x7e, 0xee, 0xaf, 0xb2, 0x18}},
363 {0xd4, 0xa6, 0x11, 0xd0, 0x8f, 0x01, 0x4e, 0xc0,
364 0x92, 0x23, 0xc5, 0xb6, 0xbe, 0xc6, 0xcc, 0xf0}},
367 {0x12, 0xd0, 0x7e, 0x3e, 0xf8, 0x85, 0x48, 0x9e,
368 0x8e, 0x97, 0xa7, 0x2a, 0x65, 0x51, 0xe5, 0x8d}},
371 {0x64, 0x43, 0xc6, 0xaf, 0x22, 0x60, 0x45, 0x17,
372 0xb5, 0x8c, 0xd7, 0xdf, 0x8e, 0x29, 0x03, 0x52}},
375 {0x00, 0x72, 0xd9, 0x08, 0x4a, 0xd1, 0x43, 0xdd,
376 0x91, 0x99, 0x6f, 0x02, 0x69, 0x66, 0x02, 0x6f}},
379 {0x8c, 0x50, 0xdb, 0xae, 0x81, 0xed, 0x47, 0x86,
380 0xac, 0xca, 0x16, 0xcc, 0x32, 0x13, 0xc7, 0xb7}},
383 {0x61, 0xbe, 0xe0, 0xdd, 0x8b, 0xdd, 0x47, 0x5d,
384 0x8d, 0xee, 0x5f, 0x4b, 0xaa, 0xcf, 0x19, 0xa7}},
387 {0x60, 0x9d, 0x52, 0xf8, 0xa2, 0x9a, 0x49, 0xa6,
388 0xb2, 0xa0, 0x25, 0x24, 0xc5, 0xe9, 0xd2, 0x60}},
391 {0xba, 0x74, 0xdb, 0x3e, 0x9e, 0x24, 0x43, 0x4b,
392 0x87, 0xb6, 0x2f, 0x6b, 0x8d, 0xfe, 0xe5, 0x0f}},
395 {0x16, 0xf5, 0xb7, 0x6f, 0xa9, 0xd2, 0x40, 0x35,
396 0x8c, 0xc5, 0xc0, 0x84, 0x70, 0x3c, 0x98, 0xfa}},
399 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
400 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}
403 /* Keep this array synchronized with icq_custom_icons. */
404 static PurpleMood icq_purple_moods
[] = {
405 {"thinking", N_("Thinking"), NULL
},
406 {"busy", N_("Busy"), NULL
},
407 {"shopping", N_("Shopping"), NULL
},
408 /* This was in the original patch, but isn't what the official client
409 * (ICQ 6) sets when you choose its typewriter icon. */
410 {"typing", NULL
, NULL
},
411 {"question", N_("Questioning"), NULL
},
412 {"angry", N_("Angry"), NULL
},
413 {"plate", N_("Eating"), NULL
},
414 {"cinema", N_("Watching a movie"), NULL
},
415 {"sick", N_("Sick"), NULL
},
416 {"typing", N_("Typing"), NULL
},
417 {"suit", N_("At the office"), NULL
},
418 {"bathing", N_("Taking a bath"), NULL
},
419 {"tv", N_("Watching TV"), NULL
},
420 {"excited", N_("Having fun"), NULL
},
421 {"sleeping", N_("Sleeping"), NULL
},
422 {"hiptop", N_("Using a PDA"), NULL
},
423 {"in_love", N_("In love"), NULL
},
425 {"sleepy", N_("Sleepy"), NULL
},
426 {"meeting", N_("Meeting friends"), NULL
},
427 {"phone", N_("On the phone"), NULL
},
428 {"surfing", N_("Surfing"), NULL
},
429 /* "I am mobile." / "John is mobile." */
430 {"mobile", N_("Mobile"), NULL
},
431 {"search", N_("Searching the web"), NULL
},
432 {"party", N_("At a party"), NULL
},
433 {"coffee", N_("Having Coffee"), NULL
},
434 /* Playing video games */
435 {"console", N_("Gaming"), NULL
},
436 {"internet", N_("Browsing the web"), NULL
},
437 {"cigarette", N_("Smoking"), NULL
},
438 {"writing", N_("Writing"), NULL
},
439 /* Drinking [Alcohol] */
440 {"beer", N_("Drinking"), NULL
},
441 {"music", N_("Listening to music"), NULL
},
442 {"studying", N_("Studying"), NULL
},
443 {"working", N_("Working"), NULL
},
444 {"restroom", N_("In the restroom"), NULL
},
445 /* Mark the last record. */
451 * Add the userinfo to our linked list. If we already have userinfo
452 * for this buddy, then just overwrite parts of the old data.
454 * @param userinfo Contains the new information for the buddy.
457 aim_locate_adduserinfo(OscarData
*od
, aim_userinfo_t
*userinfo
)
461 cur
= aim_locate_finduserinfo(od
, userinfo
->bn
);
464 cur
= (aim_userinfo_t
*)g_new0(aim_userinfo_t
, 1);
465 cur
->bn
= g_strdup(userinfo
->bn
);
466 cur
->next
= od
->locate
.userinfo
;
467 od
->locate
.userinfo
= cur
;
470 cur
->warnlevel
= userinfo
->warnlevel
;
471 cur
->idletime
= userinfo
->idletime
;
472 if (userinfo
->flags
!= 0)
473 cur
->flags
= userinfo
->flags
;
474 if (userinfo
->createtime
!= 0)
475 cur
->createtime
= userinfo
->createtime
;
476 if (userinfo
->membersince
!= 0)
477 cur
->membersince
= userinfo
->membersince
;
478 if (userinfo
->onlinesince
!= 0)
479 cur
->onlinesince
= userinfo
->onlinesince
;
480 if (userinfo
->sessionlen
!= 0)
481 cur
->sessionlen
= userinfo
->sessionlen
;
482 if (userinfo
->capabilities
!= 0)
483 cur
->capabilities
= userinfo
->capabilities
;
485 cur
->present
|= userinfo
->present
;
487 if (userinfo
->iconcsumlen
> 0) {
488 g_free(cur
->iconcsum
);
489 cur
->iconcsum
= (guint8
*)g_malloc(userinfo
->iconcsumlen
);
490 memcpy(cur
->iconcsum
, userinfo
->iconcsum
, userinfo
->iconcsumlen
);
491 cur
->iconcsumlen
= userinfo
->iconcsumlen
;
494 if (userinfo
->info
!= NULL
) {
496 g_free(cur
->info_encoding
);
497 if (userinfo
->info_len
> 0) {
498 cur
->info
= (char *)g_malloc(userinfo
->info_len
);
499 memcpy(cur
->info
, userinfo
->info
, userinfo
->info_len
);
502 cur
->info_encoding
= g_strdup(userinfo
->info_encoding
);
503 cur
->info_len
= userinfo
->info_len
;
506 if (userinfo
->status
!= NULL
) {
508 g_free(cur
->status_encoding
);
509 if (userinfo
->status_len
> 0) {
510 cur
->status
= (char *)g_malloc(userinfo
->status_len
);
511 memcpy(cur
->status
, userinfo
->status
, userinfo
->status_len
);
514 if (userinfo
->status_encoding
!= NULL
)
515 cur
->status_encoding
= g_strdup(userinfo
->status_encoding
);
517 cur
->status_encoding
= NULL
;
518 cur
->status_len
= userinfo
->status_len
;
521 if (userinfo
->itmsurl
!= NULL
) {
522 g_free(cur
->itmsurl
);
523 g_free(cur
->itmsurl_encoding
);
524 if (userinfo
->itmsurl_len
> 0) {
525 cur
->itmsurl
= (char *)g_malloc(userinfo
->itmsurl_len
);
526 memcpy(cur
->itmsurl
, userinfo
->itmsurl
, userinfo
->itmsurl_len
);
529 if (userinfo
->itmsurl_encoding
!= NULL
)
530 cur
->itmsurl_encoding
= g_strdup(userinfo
->itmsurl_encoding
);
532 cur
->itmsurl_encoding
= NULL
;
533 cur
->itmsurl_len
= userinfo
->itmsurl_len
;
536 if (userinfo
->away
!= NULL
) {
538 g_free(cur
->away_encoding
);
539 if (userinfo
->away_len
> 0) {
540 cur
->away
= (char *)g_malloc(userinfo
->away_len
);
541 memcpy(cur
->away
, userinfo
->away
, userinfo
->away_len
);
544 cur
->away_encoding
= g_strdup(userinfo
->away_encoding
);
545 cur
->away_len
= userinfo
->away_len
;
549 * We don't have an away message specified in this user_info
550 * block, so clear any cached away message now.
554 g_free(cur
->away_encoding
);
555 cur
->away_encoding
= NULL
;
560 aim_userinfo_t
*aim_locate_finduserinfo(OscarData
*od
, const char *bn
) {
561 aim_userinfo_t
*cur
= NULL
;
566 cur
= od
->locate
.userinfo
;
568 while (cur
!= NULL
) {
569 if (oscar_util_name_compare(cur
->bn
, bn
) == 0)
578 aim_locate_getcaps(OscarData
*od
, ByteStream
*bs
, int len
)
583 for (offset
= 0; byte_stream_bytes_left(bs
) && (offset
< len
); offset
+= 0x10) {
587 cap
= byte_stream_getraw(bs
, 0x10);
589 for (i
= 0, identified
= 0; !(aim_caps
[i
].flag
& OSCAR_CAPABILITY_LAST
); i
++) {
590 if (memcmp(&aim_caps
[i
].data
, cap
, 0x10) == 0) {
591 flags
|= aim_caps
[i
].flag
;
593 break; /* should only match once... */
598 purple_debug_misc("oscar", "unknown capability: {%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
599 cap
[0], cap
[1], cap
[2], cap
[3],
603 cap
[10], cap
[11], cap
[12], cap
[13],
612 aim_receive_custom_icon(OscarData
*od
, ByteStream
*bs
, int len
)
615 const char *result
= NULL
;
617 for (offset
= 0; byte_stream_bytes_left(bs
) && (offset
< len
); offset
+= 0x10) {
618 /* check wheather this capability is a custom user icon */
622 cap
= byte_stream_getraw(bs
, 0x10);
624 for (i
= 0; icq_custom_icons
[i
].mood
; i
++) {
625 if (memcmp(&icq_custom_icons
[i
].data
, cap
, 0x10) == 0) {
626 purple_debug_misc("oscar", "Custom status icon: %s\n", icq_purple_moods
[i
].description
);
627 result
= icq_custom_icons
[i
].mood
;
628 break; /* should only match once... */
638 aim_locate_getcaps_short(OscarData
*od
, ByteStream
*bs
, int len
)
643 for (offset
= 0; byte_stream_bytes_left(bs
) && (offset
< len
); offset
+= 0x02) {
647 cap
= byte_stream_getraw(bs
, 0x02);
649 for (i
= 0, identified
= 0; !(aim_caps
[i
].flag
& OSCAR_CAPABILITY_LAST
); i
++) {
650 if (memcmp(&aim_caps
[i
].data
[2], cap
, 0x02) == 0) {
651 flags
|= aim_caps
[i
].flag
;
653 break; /* should only match once... */
658 purple_debug_misc("oscar", "unknown short capability: {%02x%02x}\n", cap
[0], cap
[1]);
667 byte_stream_putcaps(ByteStream
*bs
, guint64 caps
)
674 for (i
= 0; byte_stream_bytes_left(bs
); i
++) {
675 if (aim_caps
[i
].flag
== OSCAR_CAPABILITY_LAST
)
678 if (caps
& aim_caps
[i
].flag
)
679 byte_stream_putraw(bs
, aim_caps
[i
].data
, 0x10);
684 #ifdef LOG_UNKNOWN_TLV
686 dumptlv(OscarData
*od
, guint16 type
, ByteStream
*bs
, guint8 len
)
690 if (!od
|| !bs
|| !len
)
693 purple_debug_misc("oscar", "userinfo: type =0x%04x\n", type
);
694 purple_debug_misc("oscar", "userinfo: length=0x%04x\n", len
);
695 purple_debug_misc("oscar", "userinfo: value:\n");
697 for (i
= 0; i
< len
; i
++) {
699 purple_debug_misc("oscar", "\nuserinfo: ");
700 purple_debug_misc("oscar", "0x%2x ", byte_stream_get8(bs
));
703 purple_debug_misc("oscar", "\n");
710 aim_info_free(aim_userinfo_t
*info
)
713 g_free(info
->iconcsum
);
715 g_free(info
->info_encoding
);
716 g_free(info
->status
);
717 g_free(info
->status_encoding
);
718 g_free(info
->itmsurl
);
719 g_free(info
->itmsurl_encoding
);
721 g_free(info
->away_encoding
);
724 static const struct {
728 {"icqmood0", "shopping"},
729 {"icqmood1", "bathing"},
730 {"icqmood2", "sleepy"},
731 {"icqmood3", "party"},
732 {"icqmood4", "beer"},
733 {"icqmood5", "thinking"},
734 {"icqmood6", "plate"},
736 {"icqmood8", "meeting"},
737 {"icqmood9", "coffee"},
738 {"icqmood10", "music"},
739 {"icqmood11", "suit"},
740 {"icqmood12", "cinema"},
741 {"icqmood13", "smile-big"},
742 {"icqmood14", "phone"},
743 {"icqmood15", "console"},
744 {"icqmood16", "studying"},
745 {"icqmood17", "sick"},
746 {"icqmood18", "sleeping"},
747 {"icqmood19", "surfing"},
748 {"icqmood20", "internet"},
749 {"icqmood21", "working"},
750 {"icqmood22", "typing"},
751 {"icqmood23", "angry"},
757 * AIM is fairly regular about providing user info. This is a generic
758 * routine to extract it in its standard form.
761 aim_info_extract(OscarData
*od
, ByteStream
*bs
, aim_userinfo_t
*outinfo
)
769 /* Clear out old data first */
770 memset(outinfo
, 0x00, sizeof(aim_userinfo_t
));
773 * Username. Stored as an unterminated string prepended with a
774 * byte containing its length.
776 bnlen
= byte_stream_get8(bs
);
777 outinfo
->bn
= byte_stream_getstr(bs
, bnlen
);
780 * Warning Level. Stored as an unsigned short.
782 outinfo
->warnlevel
= byte_stream_get16(bs
);
785 * TLV Count. Unsigned short representing the number of
786 * Type-Length-Value triples that follow.
788 tlvcnt
= byte_stream_get16(bs
);
791 * Parse out the Type-Length-Value triples as they're found.
793 for (curtlv
= 0; curtlv
< tlvcnt
; curtlv
++) {
794 guint16 type
, length
;
798 type
= byte_stream_get16(bs
);
799 length
= byte_stream_get16(bs
);
800 curpos
= byte_stream_curpos(bs
);
801 endpos
= curpos
+ MIN(length
, byte_stream_bytes_left(bs
));
803 if (type
== 0x0001) {
807 * Specified as any of the following ORed together:
808 * 0x0001 Unconfirmed account
809 * 0x0002 Unknown bit 2
810 * 0x0004 AOL Main Service user
811 * 0x0008 Unknown bit 4
812 * 0x0010 Free (AIM) user
814 * 0x0040 ICQ user (AIM bit also set)
815 * 0x0080 Mobile device
816 * 0x0400 Bot (like ActiveBuddy)
818 outinfo
->flags
= byte_stream_get16(bs
);
819 outinfo
->present
|= AIM_USERINFO_PRESENT_FLAGS
;
821 } else if (type
== 0x0002) {
823 * Account creation time
825 * The time/date that the user originally registered for
826 * the service, stored in time_t format.
828 * I'm not sure how this differs from type 5 ("member
831 * Note: This is the field formerly known as "member
832 * since". All these years and I finally found out
833 * that I got the name wrong.
835 outinfo
->createtime
= byte_stream_get32(bs
);
836 outinfo
->present
|= AIM_USERINFO_PRESENT_CREATETIME
;
838 } else if (type
== 0x0003) {
842 * The time/date that the user started their current
843 * session, stored in time_t format.
845 outinfo
->onlinesince
= byte_stream_get32(bs
);
846 outinfo
->present
|= AIM_USERINFO_PRESENT_ONLINESINCE
;
848 } else if (type
== 0x0004) {
852 * Number of minutes since the user actively used the
855 * Note that the client tells the server when to start
856 * counting idle times, so this may or may not be
857 * related to reality.
859 outinfo
->idletime
= byte_stream_get16(bs
);
860 outinfo
->present
|= AIM_USERINFO_PRESENT_IDLE
;
862 } else if (type
== 0x0005) {
866 * The time/date that the user originally registered for
867 * the service, stored in time_t format.
869 * This is sometimes sent instead of type 2 ("account
870 * creation time"), particularly in the self-info.
871 * And particularly for ICQ?
873 outinfo
->membersince
= byte_stream_get32(bs
);
874 outinfo
->present
|= AIM_USERINFO_PRESENT_MEMBERSINCE
;
876 } else if (type
== 0x0006) {
880 * ICQ's Away/DND/etc "enriched" status. Some decoding
881 * of values done by Scott <darkagl@pcnet.com>
883 byte_stream_get16(bs
);
884 outinfo
->icqinfo
.status
= byte_stream_get16(bs
);
885 outinfo
->present
|= AIM_USERINFO_PRESENT_ICQEXTSTATUS
;
887 } else if (type
== 0x0008) {
889 * Client type, or some such.
892 } else if (type
== 0x000a) {
894 * ICQ User IP Address
896 * Ahh, the joy of ICQ security.
898 outinfo
->icqinfo
.ipaddr
= byte_stream_get32(bs
);
899 outinfo
->present
|= AIM_USERINFO_PRESENT_ICQIPADDR
;
901 } else if (type
== 0x000c) {
903 * Random crap containing the IP address,
904 * apparently a port number, and some Other Stuff.
907 * 4 bytes - Our IP address, 0xc0 a8 01 2b for 192.168.1.43
909 byte_stream_getrawbuf(bs
, outinfo
->icqinfo
.crap
, 0x25);
910 outinfo
->present
|= AIM_USERINFO_PRESENT_ICQDATA
;
912 } else if (type
== 0x000d) {
913 PurpleAccount
*account
= purple_connection_get_account(od
->gc
);
917 * OSCAR Capability information
919 outinfo
->capabilities
|= aim_locate_getcaps(od
, bs
, length
);
920 outinfo
->present
|= AIM_USERINFO_PRESENT_CAPABILITIES
;
921 byte_stream_setpos(bs
, curpos
);
923 mood
= aim_receive_custom_icon(od
, bs
, length
);
925 purple_protocol_got_user_status(account
, outinfo
->bn
, "mood",
926 PURPLE_MOOD_NAME
, mood
,
929 purple_protocol_got_user_status_deactive(account
, outinfo
->bn
, "mood");
931 } else if (type
== 0x000e) {
933 * AOL capability information
936 } else if ((type
== 0x000f) || (type
== 0x0010)) {
938 * Type = 0x000f: Session Length. (AIM)
939 * Type = 0x0010: Session Length. (AOL)
941 * The duration, in seconds, of the user's current
944 * Which TLV type this comes in depends on the
945 * service the user is using (AIM or AOL).
947 outinfo
->sessionlen
= byte_stream_get32(bs
);
948 outinfo
->present
|= AIM_USERINFO_PRESENT_SESSIONLEN
;
950 } else if (type
== 0x0014) {
952 * My instance number.
954 byte_stream_get8(bs
);
956 } else if (type
== 0x0019) {
958 * OSCAR short capability information. A shortened
959 * form of the normal capabilities.
961 outinfo
->capabilities
|= aim_locate_getcaps_short(od
, bs
, length
);
962 outinfo
->present
|= AIM_USERINFO_PRESENT_CAPABILITIES
;
964 } else if (type
== 0x001a) {
968 * AOL short capability information. A shortened
969 * form of the normal capabilities.
972 } else if (type
== 0x001b) {
974 * Encryption certification MD5 checksum.
977 } else if (type
== 0x001d) {
979 * Buddy icon information and status/available messages.
981 * This almost seems like the AIM protocol guys gave
982 * the iChat guys a Type, and the iChat guys tried to
983 * cram as much cool shit into it as possible. Then
984 * the Windows AIM guys were like, "hey, that's
985 * pretty neat, let's copy those prawns."
987 * In that spirit, this can contain a custom message,
988 * kind of like an away message, but you're not away
989 * (it's called an "available" message). Or it can
990 * contain information about the buddy icon the user
991 * has stored on the server.
994 guint8 number2
, length2
;
998 * Continue looping as long as we're able to read type2,
999 * number2, and length2.
1001 while (byte_stream_curpos(bs
) + 4 <= endpos
) {
1002 type2
= byte_stream_get16(bs
);
1003 number2
= byte_stream_get8(bs
);
1004 length2
= byte_stream_get8(bs
);
1006 endpos2
= byte_stream_curpos(bs
) + MIN(length2
, byte_stream_bytes_left(bs
));
1009 case 0x0000: { /* This is an official buddy icon? */
1010 /* This is always 5 bytes of "0x02 01 d2 04 72"? */
1013 case 0x0001: { /* A buddy icon checksum */
1014 if ((length2
> 0) && ((number2
== 0x00) || (number2
== 0x01))) {
1015 g_free(outinfo
->iconcsum
);
1016 outinfo
->iconcsumtype
= number2
;
1017 outinfo
->iconcsum
= byte_stream_getraw(bs
, length2
);
1018 outinfo
->iconcsumlen
= length2
;
1022 case 0x0002: { /* A status/available message */
1023 g_free(outinfo
->status
);
1024 g_free(outinfo
->status_encoding
);
1026 outinfo
->status_len
= byte_stream_get16(bs
);
1027 outinfo
->status
= byte_stream_getstr(bs
, outinfo
->status_len
);
1028 if (byte_stream_get16(bs
) == 0x0001) { /* We have an encoding */
1029 byte_stream_get16(bs
);
1030 outinfo
->status_encoding
= byte_stream_getstr(bs
, byte_stream_get16(bs
));
1032 /* No explicit encoding, client should use UTF-8 */
1033 outinfo
->status_encoding
= NULL
;
1036 byte_stream_advance(bs
, length2
);
1037 outinfo
->status_len
= 0;
1038 outinfo
->status
= g_strdup("");
1039 outinfo
->status_encoding
= NULL
;
1043 case 0x0009: { /* An iTunes Music Store link */
1044 g_free(outinfo
->itmsurl
);
1045 g_free(outinfo
->itmsurl_encoding
);
1047 outinfo
->itmsurl_len
= byte_stream_get16(bs
);
1048 outinfo
->itmsurl
= byte_stream_getstr(bs
, outinfo
->itmsurl_len
);
1049 if (byte_stream_get16(bs
) == 0x0001) {
1050 /* We have an encoding */
1051 byte_stream_get16(bs
);
1052 outinfo
->itmsurl_encoding
= byte_stream_getstr(bs
, byte_stream_get16(bs
));
1054 /* No explicit encoding, client should use UTF-8 */
1055 outinfo
->itmsurl_encoding
= NULL
;
1058 byte_stream_advance(bs
, length2
);
1059 outinfo
->itmsurl_len
= 0;
1060 outinfo
->itmsurl
= g_strdup("");
1061 outinfo
->itmsurl_encoding
= NULL
;
1065 case 0x000e: { /* ICQ mood */
1066 PurpleAccount
*account
= purple_connection_get_account(od
->gc
);
1069 const char *mood
= NULL
;
1071 icqmood
= byte_stream_getstr(bs
, length2
);
1073 /* icqmood = "" means X-Status
1074 * with no mood icon. */
1076 for (i
= 0; icqmoods
[i
].icqmood
; i
++) {
1077 if (purple_strequal(icqmood
, icqmoods
[i
].icqmood
)) {
1078 mood
= icqmoods
[i
].mood
;
1079 break; /* should only match once... */
1084 purple_debug_warning("oscar", "Unknown icqmood: %s\n", icqmood
);
1089 purple_protocol_got_user_status(account
, outinfo
->bn
, "mood",
1090 PURPLE_MOOD_NAME
, mood
,
1093 purple_protocol_got_user_status_deactive(account
, outinfo
->bn
, "mood");
1097 /* Save ourselves. */
1098 byte_stream_setpos(bs
, endpos2
);
1101 } else if (type
== 0x001e) {
1103 * Always four bytes, but it doesn't look like an int.
1106 } else if (type
== 0x001f) {
1108 * Upper bytes of user flags. Can be any size
1110 * Seen on a buddy using DeadAIM. Data was 4 bytes:
1114 } else if (type
== 0x0023) {
1116 * Last Buddy Feed update time, in seconds since the epoch.
1119 } else if (type
== 0x0026) {
1121 * Time that the profile was set, in seconds since the epoch.
1124 } else if (type
== 0x0027) {
1126 * Time that the away message was set, in seconds since the epoch.
1129 } else if (type
== 0x002a) {
1131 * Country code based on GeoIP data.
1137 * Reaching here indicates that either AOL has
1138 * added yet another TLV for us to deal with,
1139 * or the parsing has gone Terribly Wrong.
1141 * Either way, inform the owner and attempt
1145 #ifdef LOG_UNKNOWN_TLV
1146 purple_debug_misc("oscar", "userinfo: **warning: unexpected TLV:\n");
1147 purple_debug_misc("oscar", "userinfo: bn =%s\n", outinfo
->bn
);
1148 dumptlv(od
, type
, bs
, length
);
1152 /* Save ourselves. */
1153 byte_stream_setpos(bs
, endpos
);
1156 aim_locate_adduserinfo(od
, outinfo
);
1165 error(OscarData
*od
, FlapConnection
*conn
, aim_module_t
*mod
, FlapFrame
*frame
, aim_modsnac_t
*snac
, ByteStream
*bs
)
1171 snac2
= aim_remsnac(od
, snac
->id
);
1173 purple_debug_misc("oscar", "locate error: received response from unknown request!\n");
1177 if ((snac2
->family
!= SNAC_FAMILY_LOCATE
) && (snac2
->type
!= 0x0015)) {
1178 purple_debug_misc("oscar", "locate error: received response from invalid request! %d\n", snac2
->family
);
1179 g_free(snac2
->data
);
1186 purple_debug_misc("oscar", "locate error: received response from request without a buddy name!\n");
1191 reason
= byte_stream_get16(bs
);
1193 oscar_user_info_display_error(od
, reason
, bn
);
1195 g_free(snac2
->data
);
1204 * Request Location services rights.
1208 aim_locate_reqrights(OscarData
*od
)
1210 FlapConnection
*conn
;
1212 if (!od
|| !(conn
= flap_connection_findbygroup(od
, SNAC_FAMILY_LOCATE
)))
1215 aim_genericreq_n_snacid(od
, conn
, SNAC_FAMILY_LOCATE
, SNAC_SUBTYPE_LOCATE_REQRIGHTS
);
1223 * Normally contains:
1224 * t(0001) - short containing max profile length (value = 1024)
1225 * t(0002) - short - unknown (value = 16) [max MIME type length?]
1226 * t(0003) - short - unknown (value = 10)
1227 * t(0004) - short - unknown (value = 2048) [ICQ only?]
1230 rights(OscarData
*od
, FlapConnection
*conn
, aim_module_t
*mod
, FlapFrame
*frame
, aim_modsnac_t
*snac
, ByteStream
*bs
)
1233 aim_rxcallback_t userfunc
;
1235 guint16 maxsiglen
= 0;
1237 tlvlist
= aim_tlvlist_read(bs
);
1239 if (aim_tlv_gettlv(tlvlist
, 0x0001, 1))
1240 maxsiglen
= aim_tlv_get16(tlvlist
, 0x0001, 1);
1242 if ((userfunc
= aim_callhandler(od
, snac
->family
, snac
->subtype
)))
1243 ret
= userfunc(od
, conn
, frame
, maxsiglen
);
1245 aim_tlvlist_free(tlvlist
);
1253 * Gives BOS your profile.
1255 * profile_encoding and awaymsg_encoding MUST be set if profile or
1256 * away are set, respectively, and their value may or may not be
1257 * restricted to a few choices. I am currently aware of:
1259 * us-ascii Just that
1260 * unicode-2-0 UTF-16BE
1262 * profile_len and awaymsg_len MUST be set similarly, and they MUST
1263 * be the length of their respective strings in bytes.
1265 * To get the previous behavior of awaymsg == "" un-setting the away
1266 * message, set awaymsg non-NULL and awaymsg_len to 0 (this is the
1267 * obvious equivalent).
1271 aim_locate_setprofile(OscarData
*od
,
1272 const char *profile_encoding
, const gchar
*profile
, const int profile_len
,
1273 const char *awaymsg_encoding
, const gchar
*awaymsg
, const int awaymsg_len
)
1275 FlapConnection
*conn
;
1277 aim_snacid_t snacid
;
1278 GSList
*tlvlist
= NULL
;
1280 static const char defencoding
[] = {"text/aolrtf; charset=\"%s\""};
1282 if (!od
|| !(conn
= flap_connection_findbygroup(od
, SNAC_FAMILY_LOCATE
)))
1285 if (!profile
&& !awaymsg
)
1288 if ((profile
&& profile_encoding
== NULL
) || (awaymsg
&& awaymsg_len
&& awaymsg_encoding
== NULL
)) {
1292 /* Build the packet first to get real length */
1294 /* no + 1 here because of %s */
1295 encoding
= g_malloc(strlen(defencoding
) + strlen(profile_encoding
));
1296 snprintf(encoding
, strlen(defencoding
) + strlen(profile_encoding
), defencoding
, profile_encoding
);
1297 aim_tlvlist_add_str(&tlvlist
, 0x0001, encoding
);
1298 aim_tlvlist_add_raw(&tlvlist
, 0x0002, profile_len
, (const guchar
*)profile
);
1303 * So here's how this works:
1304 * - You are away when you have a non-zero-length type 4 TLV stored.
1305 * - You become unaway when you clear the TLV with a zero-length
1307 * - If you do not send the type 4 TLV, your status does not change
1308 * (that is, if you were away, you'll remain away).
1312 encoding
= g_malloc(strlen(defencoding
) + strlen(awaymsg_encoding
));
1313 snprintf(encoding
, strlen(defencoding
) + strlen(awaymsg_encoding
), defencoding
, awaymsg_encoding
);
1314 aim_tlvlist_add_str(&tlvlist
, 0x0003, encoding
);
1315 aim_tlvlist_add_raw(&tlvlist
, 0x0004, awaymsg_len
, (const guchar
*)awaymsg
);
1318 aim_tlvlist_add_noval(&tlvlist
, 0x0004);
1321 byte_stream_new(&bs
, aim_tlvlist_size(tlvlist
));
1323 snacid
= aim_cachesnac(od
, SNAC_FAMILY_LOCATE
, 0x0004, 0x0000, NULL
, 0);
1325 aim_tlvlist_write(&bs
, &tlvlist
);
1326 aim_tlvlist_free(tlvlist
);
1328 flap_connection_send_snac(od
, conn
, SNAC_FAMILY_LOCATE
, 0x0004, snacid
, &bs
);
1330 byte_stream_destroy(&bs
);
1336 * Subtype 0x0004 - Set your client's capabilities.
1339 aim_locate_setcaps(OscarData
*od
, guint64 caps
)
1341 FlapConnection
*conn
;
1342 PurpleAccount
*account
= purple_connection_get_account(od
->gc
);
1343 PurplePresence
*presence
= purple_account_get_presence(account
);
1344 PurpleStatus
*status
= purple_presence_get_status(presence
, "mood");
1345 const char *mood
= purple_status_get_attr_string(status
, PURPLE_MOOD_NAME
);
1347 aim_snacid_t snacid
;
1348 GSList
*tlvlist
= NULL
;
1350 if (!(conn
= flap_connection_findbygroup(od
, SNAC_FAMILY_LOCATE
)))
1353 aim_tlvlist_add_caps(&tlvlist
, 0x0005, caps
, mood
);
1355 byte_stream_new(&bs
, aim_tlvlist_size(tlvlist
));
1357 snacid
= aim_cachesnac(od
, SNAC_FAMILY_LOCATE
, 0x0004, 0x0000, NULL
, 0);
1359 aim_tlvlist_write(&bs
, &tlvlist
);
1360 aim_tlvlist_free(tlvlist
);
1362 flap_connection_send_snac(od
, conn
, SNAC_FAMILY_LOCATE
, 0x0004, snacid
, &bs
);
1364 byte_stream_destroy(&bs
);
1369 /* Subtype 0x0006 */
1371 userinfo(OscarData
*od
, FlapConnection
*conn
, aim_module_t
*mod
, FlapFrame
*frame
, aim_modsnac_t
*snac
, ByteStream
*bs
)
1374 aim_userinfo_t
*userinfo
, *userinfo2
;
1376 aim_tlv_t
*tlv
= NULL
;
1378 userinfo
= (aim_userinfo_t
*)g_malloc(sizeof(aim_userinfo_t
));
1379 aim_info_extract(od
, bs
, userinfo
);
1380 tlvlist
= aim_tlvlist_read(bs
);
1382 /* Profile will be 1 and 2 */
1383 userinfo
->info_encoding
= aim_tlv_getstr(tlvlist
, 0x0001, 1);
1384 if ((tlv
= aim_tlv_gettlv(tlvlist
, 0x0002, 1))) {
1385 userinfo
->info
= (char *)g_malloc(tlv
->length
);
1386 memcpy(userinfo
->info
, tlv
->value
, tlv
->length
);
1387 userinfo
->info_len
= tlv
->length
;
1390 /* Away message will be 3 and 4 */
1391 userinfo
->away_encoding
= aim_tlv_getstr(tlvlist
, 0x0003, 1);
1392 if ((tlv
= aim_tlv_gettlv(tlvlist
, 0x0004, 1))) {
1393 userinfo
->away
= (char *)g_malloc(tlv
->length
);
1394 memcpy(userinfo
->away
, tlv
->value
, tlv
->length
);
1395 userinfo
->away_len
= tlv
->length
;
1398 /* Caps will be 5 */
1399 if ((tlv
= aim_tlv_gettlv(tlvlist
, 0x0005, 1))) {
1401 PurpleAccount
*account
= purple_connection_get_account(od
->gc
);
1404 byte_stream_init(&cbs
, tlv
->value
, tlv
->length
);
1405 userinfo
->capabilities
= aim_locate_getcaps(od
, &cbs
, tlv
->length
);
1406 byte_stream_rewind(&cbs
);
1407 userinfo
->present
= AIM_USERINFO_PRESENT_CAPABILITIES
;
1409 mood
= aim_receive_custom_icon(od
, &cbs
, tlv
->length
);
1411 purple_protocol_got_user_status(account
, userinfo
->bn
, "mood",
1412 PURPLE_MOOD_NAME
, mood
,
1415 purple_protocol_got_user_status_deactive(account
, userinfo
->bn
, "mood");
1417 aim_tlvlist_free(tlvlist
);
1419 aim_locate_adduserinfo(od
, userinfo
);
1420 userinfo2
= aim_locate_finduserinfo(od
, userinfo
->bn
);
1421 aim_info_free(userinfo
);
1424 /* Show the info to the user */
1425 oscar_user_info_display_aim(od
, userinfo2
);
1431 * Subtype 0x0015 - Request the info of a user using the short method. This is
1432 * what iChat uses. It normally is VERY leniently rate limited.
1434 * @param bn The buddy name whose info you wish to request.
1435 * @param flags The bitmask which specifies the type of info you wish to request.
1436 * 0x00000001 - Info/profile.
1437 * 0x00000002 - Away message.
1438 * 0x00000004 - Capabilities.
1439 * 0x00000008 - Certification.
1440 * @return Return 0 if no errors, otherwise return the error number.
1443 aim_locate_getinfoshort(OscarData
*od
, const char *bn
, guint32 flags
)
1445 FlapConnection
*conn
;
1447 aim_snacid_t snacid
;
1449 if (!od
|| !(conn
= flap_connection_findbygroup(od
, SNAC_FAMILY_LOCATE
)) || !bn
)
1452 byte_stream_new(&bs
, 4 + 1 + strlen(bn
));
1453 byte_stream_put32(&bs
, flags
);
1454 byte_stream_put8(&bs
, strlen(bn
));
1455 byte_stream_putstr(&bs
, bn
);
1457 snacid
= aim_cachesnac(od
, SNAC_FAMILY_LOCATE
, 0x0015, 0x0000, bn
, strlen(bn
)+1);
1458 flap_connection_send_snac_with_priority(od
, conn
, SNAC_FAMILY_LOCATE
, 0x0015, snacid
, &bs
, FALSE
);
1460 byte_stream_destroy(&bs
);
1466 snachandler(OscarData
*od
, FlapConnection
*conn
, aim_module_t
*mod
, FlapFrame
*frame
, aim_modsnac_t
*snac
, ByteStream
*bs
)
1468 if (snac
->subtype
== 0x0001)
1469 return error(od
, conn
, mod
, frame
, snac
, bs
);
1470 else if (snac
->subtype
== 0x0003)
1471 return rights(od
, conn
, mod
, frame
, snac
, bs
);
1472 else if (snac
->subtype
== 0x0006)
1473 return userinfo(od
, conn
, mod
, frame
, snac
, bs
);
1479 locate_shutdown(OscarData
*od
, aim_module_t
*mod
)
1481 aim_userinfo_t
*del
;
1483 while (od
->locate
.userinfo
) {
1484 del
= od
->locate
.userinfo
;
1485 od
->locate
.userinfo
= od
->locate
.userinfo
->next
;
1492 locate_modfirst(OscarData
*od
, aim_module_t
*mod
)
1494 mod
->family
= SNAC_FAMILY_LOCATE
;
1495 mod
->version
= 0x0001;
1496 mod
->toolid
= 0x0110;
1497 mod
->toolversion
= 0x0629;
1499 strncpy(mod
->name
, "locate", sizeof(mod
->name
));
1500 mod
->snachandler
= snachandler
;
1501 mod
->shutdown
= locate_shutdown
;
1507 icq_get_custom_icon_description(const char *mood
)
1511 if (!(mood
&& *mood
))
1514 for (i
= 0; icq_custom_icons
[i
].mood
; i
++) {
1515 /* We check that description is not NULL to exclude
1516 * duplicates, like the typing duplicate. */
1517 if (icq_purple_moods
[i
].description
&&
1518 purple_strequal(mood
, icq_custom_icons
[i
].mood
)) {
1519 return icq_purple_moods
[i
].description
;
1527 icq_get_custom_icon_data(const char *mood
)
1531 if (!(mood
&& *mood
))
1534 for (i
= 0; icq_custom_icons
[i
].mood
; i
++) {
1535 /* We check that description is not NULL to exclude
1536 * duplicates, like the typing duplicate. */
1537 if (icq_purple_moods
[i
].description
&&
1538 purple_strequal(mood
, icq_custom_icons
[i
].mood
)) {
1539 return (guint8
*)icq_custom_icons
[i
].data
;
1546 icq_get_purple_moods(PurpleAccount
*account
)
1548 return icq_purple_moods
;