comparison src/protocols/oscar/im.c @ 11255:1b1d63602d77

[gaim-migrate @ 13429] sf patch #1247984, from Ilya Konstantinov Retrieve ICQ away messages with i18n support committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 13 Aug 2005 18:40:40 +0000
parents 7d31d61e6438
children 14a166f01a8e
comparison
equal deleted inserted replaced
11254:ce3b9969b399 11255:1b1d63602d77
970 /* TLV t(2711) */ 970 /* TLV t(2711) */
971 aimbs_put16(&fr->data, 0x2711); 971 aimbs_put16(&fr->data, 0x2711);
972 aimbs_put16(&fr->data, 0x0036); 972 aimbs_put16(&fr->data, 0x0036);
973 { /* V */ 973 { /* V */
974 aimbs_putle16(&fr->data, 0x001b); /* L */ 974 aimbs_putle16(&fr->data, 0x001b); /* L */
975 aimbs_putle16(&fr->data, 0x0008); /* XXX - Protocol version */ 975 aimbs_putle16(&fr->data, 0x0009); /* Protocol version */
976 aim_putcap(&fr->data, AIM_CAPS_EMPTY); 976 aim_putcap(&fr->data, AIM_CAPS_EMPTY);
977 aimbs_putle16(&fr->data, 0x0000); /* Unknown */ 977 aimbs_putle16(&fr->data, 0x0000); /* Unknown */
978 aimbs_putle16(&fr->data, 0x0003); /* Client features? */ 978 aimbs_putle16(&fr->data, 0x0001); /* Client features? */
979 aimbs_putle16(&fr->data, 0x0000); /* Unknown */ 979 aimbs_putle16(&fr->data, 0x0000); /* Unknown */
980 aimbs_putle8(&fr->data, 0x00); /* Unkizown */ 980 aimbs_putle8(&fr->data, 0x00); /* Unkizown */
981 aimbs_putle16(&fr->data, 0xffff); /* Sequence number? XXX - This should decrement by 1 with each request */ 981 aimbs_putle16(&fr->data, 0xffff); /* Sequence number? XXX - This should decrement by 1 with each request */
982 982
983 aimbs_putle16(&fr->data, 0x000e); /* L */ 983 aimbs_putle16(&fr->data, 0x000e); /* L */
986 aimbs_putle32(&fr->data, 0x00000000); /* Unknown */ 986 aimbs_putle32(&fr->data, 0x00000000); /* Unknown */
987 aimbs_putle32(&fr->data, 0x00000000); /* Unknown */ 987 aimbs_putle32(&fr->data, 0x00000000); /* Unknown */
988 988
989 /* The type of status message being requested */ 989 /* The type of status message being requested */
990 if (type & AIM_ICQ_STATE_CHAT) 990 if (type & AIM_ICQ_STATE_CHAT)
991 aimbs_putle16(&fr->data, 0x03ec); 991 aimbs_putle8(&fr->data, 0xec);
992 else if(type & AIM_ICQ_STATE_DND) 992 else if(type & AIM_ICQ_STATE_DND)
993 aimbs_putle16(&fr->data, 0x03eb); 993 aimbs_putle8(&fr->data, 0xeb);
994 else if(type & AIM_ICQ_STATE_OUT) 994 else if(type & AIM_ICQ_STATE_OUT)
995 aimbs_putle16(&fr->data, 0x03ea); 995 aimbs_putle8(&fr->data, 0xea);
996 else if(type & AIM_ICQ_STATE_BUSY) 996 else if(type & AIM_ICQ_STATE_BUSY)
997 aimbs_putle16(&fr->data, 0x03e9); 997 aimbs_putle8(&fr->data, 0xe9);
998 else if(type & AIM_ICQ_STATE_AWAY) 998 else if(type & AIM_ICQ_STATE_AWAY)
999 aimbs_putle16(&fr->data, 0x03e8); 999 aimbs_putle8(&fr->data, 0xe8);
1000 else
1001 /* This should not happen */
1002 aimbs_putle8(&fr->data, 0x00);
1003 aimbs_putle8(&fr->data, 0x03); /* Message Flags */
1000 1004
1001 aimbs_putle16(&fr->data, 0x0000); /* Status? */ 1005 aimbs_putle16(&fr->data, 0x0000); /* Status? */
1002 aimbs_putle16(&fr->data, 0x0001); /* Priority of this message? */ 1006 aimbs_putle16(&fr->data, 0x0001); /* Priority of this message? */
1003 aimbs_putle16(&fr->data, 0x0001); /* L */ 1007 aimbs_putle16(&fr->data, 0x0001); /* L */
1004 aimbs_putle8(&fr->data, 0x00); /* String of length L */ 1008 aimbs_putle8(&fr->data, 0x00); /* String of length L */
2192 channel = aimbs_get16(bs); 2196 channel = aimbs_get16(bs);
2193 snlen = aimbs_get8(bs); 2197 snlen = aimbs_get8(bs);
2194 sn = aimbs_getstr(bs, snlen); 2198 sn = aimbs_getstr(bs, snlen);
2195 reason = aimbs_get16(bs); 2199 reason = aimbs_get16(bs);
2196 2200
2197 if (channel == 0x0002) { /* File transfer declined */ 2201 if (channel == 0x0002) {
2198 aimbs_get16(bs); /* Unknown */ 2202 switch (reason) {
2199 aimbs_get16(bs); /* Unknown */ 2203 case 0x0003: {
2200 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) 2204 /* This is exactly like the Extended Data TLV (2711) */
2201 ret = userfunc(sess, rx, channel, sn, reason, ck); 2205 fu16_t len;
2206 fu16_t version;
2207 fu8_t plugin_uuid[16];
2208
2209 len = aimbs_getle16(bs); /* Usually 0x001b */
2210 version = aimbs_getle16(bs);
2211 aimbs_getrawbuf(bs, plugin_uuid, sizeof(plugin_uuid));
2212 aim_bstream_advance(bs, len - sizeof(version) - sizeof(plugin_uuid)); /* Rest is unknown */
2213
2214 len = aimbs_getle16(bs); /* Usually 0x000e */
2215 aim_bstream_advance(bs, len); /* Unknown */
2216
2217 if (plugin_uuid[0] == 0 &&
2218 plugin_uuid[1] == 0 &&
2219 plugin_uuid[2] == 0 &&
2220 plugin_uuid[3] == 0 &&
2221 plugin_uuid[4] == 0 &&
2222 plugin_uuid[5] == 0 &&
2223 plugin_uuid[6] == 0 &&
2224 plugin_uuid[7] == 0 &&
2225 plugin_uuid[8] == 0 &&
2226 plugin_uuid[9] == 0 &&
2227 plugin_uuid[10] == 0 &&
2228 plugin_uuid[11] == 0 &&
2229 plugin_uuid[12] == 0 &&
2230 plugin_uuid[13] == 0 &&
2231 plugin_uuid[14] == 0 &&
2232 plugin_uuid[15] == 0)
2233 {
2234 fu8_t msg_type, msg_flags, *msg;
2235 fu16_t status_code, priority_code, msg_length;
2236 fu32_t state;
2237
2238 msg_type = aimbs_getle8(bs);
2239 switch (msg_type) {
2240 case 0xe8:
2241 state = AIM_ICQ_STATE_AWAY;
2242 break;
2243 case 0xe9:
2244 state = AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY;
2245 break;
2246 case 0xea:
2247 state = AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_OUT;
2248 break;
2249 case 0xeb:
2250 state = AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY;
2251 break;
2252 case 0xec:
2253 state = AIM_ICQ_STATE_CHAT;
2254 break;
2255 default:
2256 state = 0;
2257 break;
2258 }
2259 msg_flags = aimbs_getle8(bs); /* would usually have 0x03 == auto msg */
2260 status_code = aimbs_getle16(bs);
2261 priority_code = aimbs_getle16(bs);
2262
2263 msg_length = aimbs_getle16(bs);
2264 msg = aimbs_getraw(bs, msg_length);
2265
2266 if (state & AIM_ICQ_STATE_AWAY)
2267 {
2268 aim_userinfo_t *userinfo = aim_locate_finduserinfo(sess, sn);
2269 free(userinfo->away);
2270 free(userinfo->away_encoding);
2271 if (msg_length > 0)
2272 {
2273 userinfo->away = (char *)malloc(msg_length);
2274 memcpy(userinfo->away, msg, msg_length);
2275 }
2276 else
2277 {
2278 userinfo->away = NULL;
2279 }
2280 userinfo->away_len = msg_length - 1; /* msg_length includes a terminating '\0' */
2281 userinfo->away_encoding = strdup("text/x-aolrtf; charset=\"utf-8\"");
2282 }
2283
2284 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
2285 ret = userfunc(sess, rx, channel, sn, reason, state, msg);
2286 }
2287 else
2288 {
2289 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
2290 ret = userfunc(sess, rx, channel, sn, reason, ck);
2291 }
2292 break;
2293 }
2294
2295 default: {
2296 /* File transfer declined? */
2297 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
2298 ret = userfunc(sess, rx, channel, sn, reason, ck);
2299 }
2300 }
2202 } else if (channel == 0x0004) { /* ICQ message */ 2301 } else if (channel == 0x0004) { /* ICQ message */
2203 switch (reason) { 2302 switch (reason) {
2204 case 0x0003: { /* ICQ status message. Maybe other stuff too, you never know with these people. */ 2303 case 0x0003: { /* ICQ status message. Maybe other stuff too, you never know with these people. */
2205 fu8_t statusmsgtype, *msg; 2304 fu8_t statusmsgtype, *msg;
2206 fu16_t len; 2305 fu16_t len;