📄 family_icq.c
字号:
/* * Purple's oscar protocol plugin * This file is the legal property of its developers. * Please see the AUTHORS file distributed alongside this file. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*//* * Family 0x0015 - Encapsulated ICQ. * */#include "oscar.h"int aim_icq_reqofflinemsgs(OscarData *od){ FlapConnection *conn; FlapFrame *frame; aim_snacid_t snacid; int bslen; if (!od || !(conn = flap_connection_findbygroup(od, 0x0015))) return -EINVAL; bslen = 2 + 4 + 2 + 2; frame = flap_frame_new(od, 0x02, 10 + 4 + bslen); snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0); aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid); /* For simplicity, don't bother using a tlvlist */ byte_stream_put16(&frame->data, 0x0001); byte_stream_put16(&frame->data, bslen); byte_stream_putle16(&frame->data, bslen - 2); byte_stream_putle32(&frame->data, atoi(od->sn)); byte_stream_putle16(&frame->data, 0x003c); /* I command thee. */ byte_stream_putle16(&frame->data, snacid); /* eh. */ flap_connection_send(conn, frame); return 0;}int aim_icq_ackofflinemsgs(OscarData *od){ FlapConnection *conn; FlapFrame *frame; aim_snacid_t snacid; int bslen; if (!od || !(conn = flap_connection_findbygroup(od, 0x0015))) return -EINVAL; bslen = 2 + 4 + 2 + 2; frame = flap_frame_new(od, 0x02, 10 + 4 + bslen); snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0); aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid); /* For simplicity, don't bother using a tlvlist */ byte_stream_put16(&frame->data, 0x0001); byte_stream_put16(&frame->data, bslen); byte_stream_putle16(&frame->data, bslen - 2); byte_stream_putle32(&frame->data, atoi(od->sn)); byte_stream_putle16(&frame->data, 0x003e); /* I command thee. */ byte_stream_putle16(&frame->data, snacid); /* eh. */ flap_connection_send(conn, frame); return 0;}intaim_icq_setsecurity(OscarData *od, gboolean auth_required, gboolean webaware){ FlapConnection *conn; FlapFrame *frame; aim_snacid_t snacid; int bslen; if (!od || !(conn = flap_connection_findbygroup(od, 0x0015))) return -EINVAL; bslen = 2+4+2+2+2+2+2+1+1+1+1+1+1; frame = flap_frame_new(od, 0x02, 10 + 4 + bslen); snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0); aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid); /* For simplicity, don't bother using a tlvlist */ byte_stream_put16(&frame->data, 0x0001); byte_stream_put16(&frame->data, bslen); byte_stream_putle16(&frame->data, bslen - 2); byte_stream_putle32(&frame->data, atoi(od->sn)); byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */ byte_stream_putle16(&frame->data, snacid); /* eh. */ byte_stream_putle16(&frame->data, 0x0c3a); /* shrug. */ byte_stream_putle16(&frame->data, 0x030c); byte_stream_putle16(&frame->data, 0x0001); byte_stream_putle8(&frame->data, webaware); byte_stream_putle8(&frame->data, 0xf8); byte_stream_putle8(&frame->data, 0x02); byte_stream_putle8(&frame->data, 0x01); byte_stream_putle8(&frame->data, 0x00); byte_stream_putle8(&frame->data, !auth_required); flap_connection_send(conn, frame); return 0;}/** * Change your ICQ password. * * @param od The oscar session * @param passwd The new password. If this is longer than 8 characters it * will be truncated. * @return Return 0 if no errors, otherwise return the error number. */int aim_icq_changepasswd(OscarData *od, const char *passwd){ FlapConnection *conn; FlapFrame *frame; aim_snacid_t snacid; int bslen, passwdlen; if (!passwd) return -EINVAL; if (!od || !(conn = flap_connection_findbygroup(od, 0x0015))) return -EINVAL; passwdlen = strlen(passwd); if (passwdlen > MAXICQPASSLEN) passwdlen = MAXICQPASSLEN; bslen = 2+4+2+2+2+2+passwdlen+1; frame = flap_frame_new(od, 0x02, 10 + 4 + bslen); snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0); aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid); /* For simplicity, don't bother using a tlvlist */ byte_stream_put16(&frame->data, 0x0001); byte_stream_put16(&frame->data, bslen); byte_stream_putle16(&frame->data, bslen - 2); byte_stream_putle32(&frame->data, atoi(od->sn)); byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */ byte_stream_putle16(&frame->data, snacid); /* eh. */ byte_stream_putle16(&frame->data, 0x042e); /* shrug. */ byte_stream_putle16(&frame->data, passwdlen+1); byte_stream_putstr(&frame->data, passwd); byte_stream_putle8(&frame->data, '\0'); flap_connection_send(conn, frame); return 0;}int aim_icq_getallinfo(OscarData *od, const char *uin){ FlapConnection *conn; FlapFrame *frame; aim_snacid_t snacid; int bslen; struct aim_icq_info *info; if (!uin || uin[0] < '0' || uin[0] > '9') return -EINVAL; if (!od || !(conn = flap_connection_findbygroup(od, 0x0015))) return -EINVAL; bslen = 2 + 4 + 2 + 2 + 2 + 4; frame = flap_frame_new(od, 0x02, 10 + 4 + bslen); snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0); aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid); /* For simplicity, don't bother using a tlvlist */ byte_stream_put16(&frame->data, 0x0001); byte_stream_put16(&frame->data, bslen); byte_stream_putle16(&frame->data, bslen - 2); byte_stream_putle32(&frame->data, atoi(od->sn)); byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */ byte_stream_putle16(&frame->data, snacid); /* eh. */ byte_stream_putle16(&frame->data, 0x04b2); /* shrug. */ byte_stream_putle32(&frame->data, atoi(uin)); flap_connection_send(conn, frame); /* Keep track of this request and the ICQ number and request ID */ info = (struct aim_icq_info *)g_new0(struct aim_icq_info, 1); info->reqid = snacid; info->uin = atoi(uin); info->next = od->icq_info; od->icq_info = info; return 0;}int aim_icq_getalias(OscarData *od, const char *uin){ FlapConnection *conn; FlapFrame *frame; aim_snacid_t snacid; int bslen; struct aim_icq_info *info; if (!uin || uin[0] < '0' || uin[0] > '9') return -EINVAL; if (!od || !(conn = flap_connection_findbygroup(od, 0x0015))) return -EINVAL; bslen = 2 + 4 + 2 + 2 + 2 + 4; frame = flap_frame_new(od, 0x02, 10 + 4 + bslen); snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0); aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid); /* For simplicity, don't bother using a tlvlist */ byte_stream_put16(&frame->data, 0x0001); byte_stream_put16(&frame->data, bslen); byte_stream_putle16(&frame->data, bslen - 2); byte_stream_putle32(&frame->data, atoi(od->sn)); byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */ byte_stream_putle16(&frame->data, snacid); /* eh. */ byte_stream_putle16(&frame->data, 0x04ba); /* shrug. */ byte_stream_putle32(&frame->data, atoi(uin)); flap_connection_send(conn, frame); /* Keep track of this request and the ICQ number and request ID */ info = (struct aim_icq_info *)g_new0(struct aim_icq_info, 1); info->reqid = snacid; info->uin = atoi(uin); info->next = od->icq_info; od->icq_info = info; return 0;}int aim_icq_getsimpleinfo(OscarData *od, const char *uin){ FlapConnection *conn; FlapFrame *frame; aim_snacid_t snacid; int bslen; if (!uin || uin[0] < '0' || uin[0] > '9') return -EINVAL; if (!od || !(conn = flap_connection_findbygroup(od, 0x0015))) return -EINVAL; bslen = 2 + 4 + 2 + 2 + 2 + 4; frame = flap_frame_new(od, 0x02, 10 + 4 + bslen); snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0); aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid); /* For simplicity, don't bother using a tlvlist */ byte_stream_put16(&frame->data, 0x0001); byte_stream_put16(&frame->data, bslen); byte_stream_putle16(&frame->data, bslen - 2); byte_stream_putle32(&frame->data, atoi(od->sn)); byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */ byte_stream_putle16(&frame->data, snacid); /* eh. */ byte_stream_putle16(&frame->data, 0x051f); /* shrug. */ byte_stream_putle32(&frame->data, atoi(uin)); flap_connection_send(conn, frame); return 0;}#if 0int aim_icq_sendxmlreq(OscarData *od, const char *xml){ FlapConnection *conn; FlapFrame *frame; aim_snacid_t snacid; int bslen; if (!xml || !strlen(xml)) return -EINVAL; if (!od || !(conn = flap_connection_findbygroup(od, 0x0015))) return -EINVAL; bslen = 2 + 10 + 2 + strlen(xml) + 1; frame = flap_frame_new(od, 0x02, 10 + 4 + bslen); snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0); aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid); /* For simplicity, don't bother using a tlvlist */ byte_stream_put16(&frame->data, 0x0001); byte_stream_put16(&frame->data, bslen); byte_stream_putle16(&frame->data, bslen - 2); byte_stream_putle32(&frame->data, atoi(od->sn)); byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */ byte_stream_putle16(&frame->data, snacid); /* eh. */ byte_stream_putle16(&frame->data, 0x0998); /* shrug. */ byte_stream_putle16(&frame->data, strlen(xml) + 1); byte_stream_putraw(&frame->data, (guint8 *)xml, strlen(xml) + 1); flap_connection_send(conn, frame); return 0;}#endif#if 0/* * Send an SMS message. This is the non-US way. The US-way is to IM * their cell phone number (+19195551234). * * We basically construct and send an XML message. The format is: * <icq_sms_message> * <destination>full_phone_without_leading_+</destination> * <text>message</text> * <codepage>1252</codepage> * <senders_UIN>self_uin</senders_UIN>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -