From 2c9a9bfed50529645b5b0d5602b2a94b0b5ef900 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 26 Apr 2015 22:42:33 +0000 Subject: unified project for AIM git-svn-id: http://svn.miranda-ng.org/main/trunk@13182 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/AimOscar/src/away.cpp | 91 +++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 48 deletions(-) (limited to 'protocols/AimOscar/src/away.cpp') diff --git a/protocols/AimOscar/src/away.cpp b/protocols/AimOscar/src/away.cpp index 45ed0097cd..3b1665e2c9 100644 --- a/protocols/AimOscar/src/away.cpp +++ b/protocols/AimOscar/src/away.cpp @@ -16,7 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "aim.h" +#include "stdafx.h" char** CAimProto::get_status_msg_loc(int status) { @@ -41,7 +41,7 @@ char** CAimProto::get_status_msg_loc(int status) int CAimProto::aim_set_away(HANDLE hServerConn, unsigned short &seqno, const char *amsg, bool set)//user info { - unsigned short offset=0; + unsigned short offset = 0; char* html_msg = NULL; size_t msg_size = 0; if (set) @@ -59,67 +59,62 @@ int CAimProto::aim_set_away(HANDLE hServerConn, unsigned short &seqno, const cha const char* msg = str.getBuf(); const unsigned short msg_len = str.getSize(); - char* buf=(char*)alloca(SNAC_SIZE+TLV_HEADER_SIZE*3+charset_len+msg_len+1); + char* buf = (char*)alloca(SNAC_SIZE + TLV_HEADER_SIZE * 3 + charset_len + msg_len + 1); - aim_writesnac(0x02,0x04,offset,buf); - aim_writetlv(0x03,charset_len,charset,offset,buf); - aim_writetlv(0x04,(unsigned short)msg_len,msg,offset,buf); + aim_writesnac(0x02, 0x04, offset, buf); + aim_writetlv(0x03, charset_len, charset, offset, buf); + aim_writetlv(0x04, (unsigned short)msg_len, msg, offset, buf); -// aim_writetlvchar(0x0f,2,offset,buf); - mir_free(html_msg); - return aim_sendflap(hServerConn,0x02,offset,buf,seqno); + return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); } -int CAimProto::aim_set_status(HANDLE hServerConn,unsigned short &seqno,unsigned long status_type) +int CAimProto::aim_set_status(HANDLE hServerConn, unsigned short &seqno, unsigned long status_type) { - unsigned short offset=0; - char buf[SNAC_SIZE+TLV_HEADER_SIZE*2]; - aim_writesnac(0x01,0x1E,offset,buf); - aim_writetlvlong(0x06,status_type,offset,buf); - return aim_sendflap(hServerConn,0x02,offset,buf,seqno); + unsigned short offset = 0; + char buf[SNAC_SIZE + TLV_HEADER_SIZE * 2]; + aim_writesnac(0x01, 0x1E, offset, buf); + aim_writetlvlong(0x06, status_type, offset, buf); + return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); } -int CAimProto::aim_set_statusmsg(HANDLE hServerConn,unsigned short &seqno,const char *msg)//user info +int CAimProto::aim_set_statusmsg(HANDLE hServerConn, unsigned short &seqno, const char *msg)//user info { - size_t msg_size =_strlens(msg); + size_t msg_size = mir_strlen(msg); + + unsigned short msgoffset = 0; + char* msgbuf = (char*)alloca(10 + msg_size); + if (msg_size) { + char* msgb = (char*)alloca(4 + msg_size); + msgb[0] = (unsigned char)(msg_size >> 8); + msgb[1] = (unsigned char)(msg_size & 0xff); + memcpy(&msgb[2], msg, msg_size); + msgb[msg_size + 2] = 0; + msgb[msg_size + 3] = 0; + + aim_writebartid(2, 4, (unsigned short)(msg_size + 4), msgb, msgoffset, msgbuf); + } + else aim_writebartid(2, 0, 0, NULL, msgoffset, msgbuf); - unsigned short msgoffset=0; - char* msgbuf=(char*)alloca(10+msg_size); + unsigned short offset = 0; + char* buf = (char*)alloca(SNAC_SIZE + TLV_HEADER_SIZE + msgoffset + 8); + aim_writesnac(0x01, 0x1e, offset, buf); + aim_writetlv(0x1d, msgoffset, msgbuf, offset, buf); - if (msg_size) - { - char* msgb=(char*)alloca(4+msg_size); - msgb[0]=(unsigned char)(msg_size >> 8); - msgb[1]=(unsigned char)(msg_size & 0xff); - memcpy(&msgb[2],msg,msg_size); - msgb[msg_size+2]=0; - msgb[msg_size+3]=0; - - aim_writebartid(2,4,(unsigned short)(msg_size+4),msgb,msgoffset,msgbuf); - } - else - aim_writebartid(2,0,0,NULL,msgoffset,msgbuf); - - unsigned short offset=0; - char* buf=(char*)alloca(SNAC_SIZE+TLV_HEADER_SIZE+msgoffset+8); - aim_writesnac(0x01,0x1e,offset,buf); - aim_writetlv(0x1d,msgoffset,msgbuf,offset,buf); - - return aim_sendflap(hServerConn,0x02,offset,buf,seqno); + return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); } -int CAimProto::aim_query_away_message(HANDLE hServerConn,unsigned short &seqno,const char* sn) +int CAimProto::aim_query_away_message(HANDLE hServerConn, unsigned short &seqno, const char* sn) { - unsigned short offset=0; - unsigned short sn_length=(unsigned short)strlen(sn); - char* buf=(char*)alloca(SNAC_SIZE+5+sn_length); - aim_writesnac(0x02,0x15,offset,buf); - aim_writegeneric(4,"\0\0\0\x02",offset,buf); - aim_writegeneric(1,(char*)&sn_length,offset,buf); - aim_writegeneric(sn_length,sn,offset,buf); - int res=aim_sendflap(hServerConn,0x02,offset,buf,seqno)==0; + unsigned short offset = 0; + unsigned short sn_length = (unsigned short)strlen(sn); + char *buf = (char*)alloca(SNAC_SIZE + 5 + sn_length); + aim_writesnac(0x02, 0x15, offset, buf); + aim_writegeneric(4, "\0\0\0\x02", offset, buf); + aim_writegeneric(1, (char*)&sn_length, offset, buf); + aim_writegeneric(sn_length, sn, offset, buf); + int res = aim_sendflap(hServerConn, 0x02, offset, buf, seqno) == 0; return res; } -- cgit v1.2.3