diff options
author | George Hazan <george.hazan@gmail.com> | 2015-08-11 13:33:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-08-11 13:33:42 +0000 |
commit | 85bd008c039eb1d93894e94fba9d158a42a71a12 (patch) | |
tree | 2d72d10759f6928e9e4b960175d2de01b5cf7e12 /protocols/Xfire/src/invitebuddypacket.cpp | |
parent | 222802c2986dcaf029fdfb828b7679bdabfa7bb2 (diff) |
massive code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@14910 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Xfire/src/invitebuddypacket.cpp')
-rw-r--r-- | protocols/Xfire/src/invitebuddypacket.cpp | 130 |
1 files changed, 68 insertions, 62 deletions
diff --git a/protocols/Xfire/src/invitebuddypacket.cpp b/protocols/Xfire/src/invitebuddypacket.cpp index f9e46cdebf..3763e69e09 100644 --- a/protocols/Xfire/src/invitebuddypacket.cpp +++ b/protocols/Xfire/src/invitebuddypacket.cpp @@ -23,71 +23,77 @@ #include "invitebuddypacket.h" #include "variablevalue.h" -namespace xfirelib { - using namespace std; +namespace xfirelib +{ + using namespace std; - InviteBuddyPacket::InviteBuddyPacket() { - names = new vector<string>; - msgs = new vector<string>; - } - InviteBuddyPacket::~InviteBuddyPacket() { - delete names; - delete msgs; - } + InviteBuddyPacket::InviteBuddyPacket() + { + names = new vector<string>; + msgs = new vector<string>; + } - void InviteBuddyPacket::parseContent(char *buf, int length, int numberOfAtts) { - /* Useless.. we only receive Packet 138 for invitations - VariableValue val; - int index = 0; - index += val.readName( buf, index ); - int namecount = (unsigned char)buf[index++]; - for(int i = 0 ; i < namecount ; i++) { - int namelen = (unsigned char)buf[index++]; - index++; // ignore 00 - index += val.readValue( buf, index, namelen ); - this->msg->push_back(string(val.getValue(),val.getValueLength())); - } - index += val.readName( buf, index ); - - int msgcount = (unsigned char)buf[index++]; - for(int i = 0 ; i < msgcount ; i++) { - int msglen = (unsigned char)buf[index++]; - index++; // ignore 00 - index += val.readValue(buf,index,msglen); - this->msg->push_back(string(val.getValue(),val.getValueLength())); - } - */ - } - int InviteBuddyPacket::getPacketContent(char *buf) { - int index = 0; - VariableValue val; - val.setName("name"); - index += val.writeName(buf,index); - buf[index++] = names->size(); - for(uint i = 0 ; i < names->size() ; i++) { - string name = names->at(i); - buf[index++] = name.length(); - buf[index++] = 0; - memcpy(buf+index,name.c_str(),name.length()); - index+=name.length(); - } - val.setName("msg"); - index += val.writeName(buf,index); - buf[index++] = msgs->size(); - for(uint i = 0 ; i < msgs->size() ; i++) { - string msg = msgs->at(i); - buf[index++] = msg.length(); - buf[index++] = 0; - memcpy(buf+index,msg.c_str(),msg.length()); - index+=msg.length(); - } - return index; - } + InviteBuddyPacket::~InviteBuddyPacket() + { + delete names; + delete msgs; + } - void InviteBuddyPacket::addInviteName(string name, string msg) { - this->names->push_back(name); - this->msgs->push_back(msg); - } + void InviteBuddyPacket::parseContent(char*, int, int) + { + /* Useless.. we only receive Packet 138 for invitations + VariableValue val; + int index = 0; + index += val.readName( buf, index ); + int namecount = (unsigned char)buf[index++]; + for(int i = 0 ; i < namecount ; i++) { + int namelen = (unsigned char)buf[index++]; + index++; // ignore 00 + index += val.readValue( buf, index, namelen ); + this->msg->push_back(string(val.getValue(),val.getValueLength())); + } + index += val.readName( buf, index ); + int msgcount = (unsigned char)buf[index++]; + for(int i = 0 ; i < msgcount ; i++) { + int msglen = (unsigned char)buf[index++]; + index++; // ignore 00 + index += val.readValue(buf,index,msglen); + this->msg->push_back(string(val.getValue(),val.getValueLength())); + } + */ + } + int InviteBuddyPacket::getPacketContent(char *buf) + { + int index = 0; + VariableValue val; + val.setName("name"); + index += val.writeName(buf, index); + buf[index++] = names->size(); + for (uint i = 0; i < names->size(); i++) { + string name = names->at(i); + buf[index++] = name.length(); + buf[index++] = 0; + memcpy(buf + index, name.c_str(), name.length()); + index += name.length(); + } + val.setName("msg"); + index += val.writeName(buf, index); + buf[index++] = msgs->size(); + for (uint i = 0; i < msgs->size(); i++) { + string msg = msgs->at(i); + buf[index++] = msg.length(); + buf[index++] = 0; + memcpy(buf + index, msg.c_str(), msg.length()); + index += msg.length(); + } + return index; + } + + void InviteBuddyPacket::addInviteName(string name, string msg) + { + this->names->push_back(name); + this->msgs->push_back(msg); + } }; |