summaryrefslogtreecommitdiff
path: root/protocols/Xfire/src/messagepacket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Xfire/src/messagepacket.cpp')
-rw-r--r--protocols/Xfire/src/messagepacket.cpp108
1 files changed, 55 insertions, 53 deletions
diff --git a/protocols/Xfire/src/messagepacket.cpp b/protocols/Xfire/src/messagepacket.cpp
index e3f4b2b445..3fd0bb7274 100644
--- a/protocols/Xfire/src/messagepacket.cpp
+++ b/protocols/Xfire/src/messagepacket.cpp
@@ -25,68 +25,70 @@
#include "messagepacket.h"
#include "xfireparse.h"
#include "variablevalue.h"
-#include <iostream>
-#include <string>
#include "xdebug.h"
+using namespace std;
-namespace xfirelib {
- using namespace std;
+namespace xfirelib
+{
+ MessagePacket::MessagePacket()
+ {
+ packetID = 133;
+ }
- MessagePacket::MessagePacket(){
- packetID = 133;
- }
+ int MessagePacket::getPacketContent(char *packet)
+ {
+ memcpy(packet, buf, bufLength);
+ packetID = 2;
+ return 150;
+ }
-int MessagePacket::getPacketContent(char *packet){
- memcpy(packet,buf,bufLength);
- packetID = 2;
- return 150;
-}
- void MessagePacket::parseContent(char *buf, int length, int numberOfAtts) {
-
- bufLength = length;
- XINFO(( "Got IM\n" ));
-
- int index = 0;
- sid = new VariableValue();
- peermsg = new VariableValue();
- msgtype = new VariableValue();
+ void MessagePacket::parseContent(char *buf, int length, int)
+ {
+ bufLength = length;
+ XINFO(("Got IM\n"));
- index += sid->readName(buf,index);
- index++; //ignore 03
- index += sid->readValue(buf,index,16);
+ int index = 0;
+ sid = new VariableValue();
+ peermsg = new VariableValue();
+ msgtype = new VariableValue();
- index += peermsg->readName(buf,index);
- index++;
- index++;
- index += msgtype->readName(buf,index);
- index++;
- index += msgtype->readValue(buf,index,4);
+ index += sid->readName(buf, index);
+ index++; //ignore 03
+ index += sid->readValue(buf, index, 16);
- if (msgtype->getValue()[0] == 0){
- imindex = new VariableValue();
- index += imindex->readName(buf,index);
+ index += peermsg->readName(buf, index);
+ index++;
+ index++;
+ index += msgtype->readName(buf, index);
+ index++;
+ index += msgtype->readValue(buf, index, 4);
- VariableValue messageTemp;
- index++;//ignore 02
- index += imindex->readValue(buf,index,4);
- index += messageTemp.readName(buf,index);
- index++;
- index += messageTemp.readValue(buf,index,2);
- int messageLength = messageTemp.getValueAsLong();
- index = messageTemp.readValue(buf,index,messageLength);
+ if (msgtype->getValue()[0] == 0) {
+ imindex = new VariableValue();
+ index += imindex->readName(buf, index);
- for(int i = 0; i < messageTemp.getValueLength();i++){
- message += messageTemp.getValue()[i];
- }
- /*TODO: implement this and answer the package*/
- }else if (msgtype->getValue()[0] == 1){
- cout << "got ack for a message we have sent" << endl;
- }else if (msgtype->getValue()[0] == 2){
- memcpy(this->buf,buf,150);
- /*answer the packet*/
- cout << "some auth magic stuff" << length << endl;
- }
- }
+ VariableValue messageTemp;
+ index++;//ignore 02
+ index += imindex->readValue(buf, index, 4);
+ index += messageTemp.readName(buf, index);
+ index++;
+ index += messageTemp.readValue(buf, index, 2);
+ int messageLength = messageTemp.getValueAsLong();
+ index = messageTemp.readValue(buf, index, messageLength);
+ for (int i = 0; i < messageTemp.getValueLength(); i++) {
+ message += messageTemp.getValue()[i];
+ }
+ /*TODO: implement this and answer the package*/
+ }
+ else if (msgtype->getValue()[0] == 1) {
+ cout << "got ack for a message we have sent" << endl;
+ }
+ else if (msgtype->getValue()[0] == 2) {
+ memcpy(this->buf, buf, 150);
+ /*answer the packet*/
+ cout << "some auth magic stuff" << length << endl;
+ }
+ }
};