Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

evaimsend.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by yunfan                                          *
00003  *   yunfan_zg@163.com                                                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #include "evaimsend.h"
00022 #include "evadefines.h"
00023 #include <string.h>
00024 #ifdef _WIN32
00025 #include <winsock.h>
00026 #else
00027 #include <arpa/inet.h>
00028 #endif
00029 
00030 SendIM::SendIM(const unsigned short type)
00031         : OutPacket(QQ_CMD_SEND_IM, true),
00032         receiver(0),
00033         face(0),
00034         contentType(type)
00035 {
00036         m_MsgSequence = 0;
00037         m_SendTime = time(NULL);
00038 }
00039 
00040 SendIM::SendIM(const SendIM &rhs)
00041         : OutPacket(rhs)
00042 {
00043         *this = rhs;
00044 }
00045 
00046 SendIM &SendIM::operator=(const SendIM &rhs)
00047 {
00048         *((OutPacket *)this) = (OutPacket)rhs;
00049         receiver = rhs.getReceiver();
00050         face = rhs.getFaceCode();
00051         contentType = rhs.getContentType();
00052         m_SendTime = rhs.getSendTime();
00053         m_MsgSequence = rhs.getMsgSequence();
00054         return *this;
00055 }
00056 
00057 int SendIM::putBody(unsigned char *buf) 
00058 {
00059         int pos=0;
00060         // bit 0-3 sender
00061         pos += EvaUtil::write32(buf+pos, getQQ());
00062         // bit 4-7 receiver
00063         pos += EvaUtil::write32(buf+pos, receiver);
00064         
00065         //  bit 8-9 qq client version
00066         pos += EvaUtil::write16(buf+pos, version);
00067         
00068         // bit 10-13 sender again
00069         pos += EvaUtil::write32(buf+pos, getQQ());
00070         
00071         // bit 14-17 receiver
00072         pos += EvaUtil::write32(buf+pos, receiver);
00073         
00074         // bit 18-33 file transfer session key
00075         memcpy( buf+pos, getFileSessionKey(), QQ_KEY_LENGTH);
00076         pos+=QQ_KEY_LENGTH;
00077         
00078         // bit 34-35 contents type ( is it normal text message or file transfer...)
00079         pos += EvaUtil::write16(buf+pos, contentType);
00080         
00081         // sequence number
00082 //      short tmpSeq = htons(sequence);
00083 //      memcpy(buf+pos, &tmpSeq,2);
00084 //      pos+=2; 
00085         if(m_MsgSequence)
00086                 pos += EvaUtil::write16(buf+pos, m_MsgSequence);
00087         else
00088                 pos+= EvaUtil::write16(buf+pos, sequence);
00089                 
00090         // sending time
00091         pos += EvaUtil::write32(buf+pos, m_SendTime);
00092 
00093         pos += EvaUtil::write16(buf+pos, face);
00094         
00095         memset(buf+pos, 0, 3);
00096         pos+=3;
00097         
00098         // font information, set as 1
00099         buf[pos++] = 0x01;
00100         memset(buf+pos, 0, 4);
00101         pos+=4;
00102         
00103         pos+= putContents(buf+pos);  // put all contents in
00104         return pos;
00105 } 
00106 
00107 int SendIM::putContents(unsigned char *buf)
00108 {
00109         fprintf(stderr, "In SendIM\n");
00110         buf[0]=0;
00111         return 0;
00112 }
00113 
00114 /*  ======================================================= */
00115 
00116 SendTextIMPacket::SendTextIMPacket()
00117         : SendIM(QQ_IM_NORMAL_TEXT),
00118         encoding(QQ_IM_ENCODING_GB),
00119         red(0),green(0),blue(0),
00120         bold(false),italic(false),underline(false),
00121         fontSize(0x09),
00122         fontFlag(0x09),
00123         message("Hello, I am using Eva."),
00124         replyType(QQ_IM_NORMAL_REPLY)
00125 {
00126         char *fname = (char *)malloc(5);
00127         fname[0] = 0xcb;
00128         fname[1] = 0xce;
00129         fname[2] = 0xcc;
00130         fname[3] = 0xe5;
00131         fname[4] = 0x00;
00132         fontName = fname; // just set font name to "Song Ti" in Chinese
00133         free(fname);
00134 }
00135 
00136 SendTextIMPacket::SendTextIMPacket(const SendTextIMPacket &rhs)
00137         : SendIM(rhs)
00138 {
00139         encoding = rhs.getEncoding();  
00140         fontName = rhs.getFontName();
00141         
00142         red = rhs.getRed();
00143         green = rhs.getGreen();
00144         blue = rhs.getBlue();
00145                 
00146         fontFlag = 0x00;
00147         bold = rhs.isBold(); 
00148         fontFlag |= bold ? 0x20 : 0x00; 
00149         
00150         italic = rhs.isItalic(); 
00151         fontFlag |= italic ? 0x40 : 0x00;
00152         
00153         underline = rhs.isUnderline();
00154         fontFlag |= underline ? 0x80 : 0x00;
00155         
00156         fontSize = rhs.getFontSize();
00157         fontFlag |= fontSize;
00158         
00159         message = rhs.getMessage();
00160         replyType = rhs.getReplyType();
00161 }
00162 
00163 SendTextIMPacket &SendTextIMPacket::operator=(const SendTextIMPacket &rhs)
00164 {
00165         *((SendIM *)this) = (SendIM)rhs;
00166         encoding = rhs.getEncoding();  
00167         fontName = rhs.getFontName();
00168         
00169         red = rhs.getRed();
00170         green = rhs.getGreen();
00171         blue = rhs.getBlue();
00172                 
00173         fontFlag = 0x00;
00174         bold = rhs.isBold(); 
00175         fontFlag |= bold ? 0x20 : 0x00; 
00176         
00177         italic = rhs.isItalic(); 
00178         fontFlag |= italic ? 0x40 : 0x00;
00179         
00180         underline = rhs.isUnderline();
00181         fontFlag |= underline ? 0x80 : 0x00;
00182         
00183         fontSize = rhs.getFontSize();
00184         fontFlag |= fontSize;
00185         
00186         message = rhs.getMessage();
00187         replyType = rhs.getReplyType();
00188         return *this;
00189 }
00190 
00191 void SendTextIMPacket::setBold(bool bold) 
00192 {
00193         this->bold = bold;
00194         fontFlag &= 0xDF;
00195         fontFlag |= bold ? 0x20 : 0x00;
00196 }
00197  
00198 void SendTextIMPacket::setItalic(bool italic) 
00199 {
00200         this->italic = italic;
00201         fontFlag &= 0xBF;
00202         fontFlag |= italic ? 0x40 : 0x00;
00203 }
00204          
00205 void SendTextIMPacket::setUnderline(bool underline) 
00206 {
00207         this->underline = underline;
00208         fontFlag &= 0x7F;
00209         fontFlag |= underline ? 0x80 : 0x00;
00210 }
00211     
00212 void SendTextIMPacket::setFontSize(char fontSize) 
00213 {
00214         this->fontSize = fontSize;
00215         fontSize &= 0x1F;
00216         fontFlag &= 0xE0;
00217         fontFlag |= fontSize;
00218 }
00219 
00220 void SendTextIMPacket::setAutoReply(const bool isNormal)
00221 {
00222         if(isNormal)
00223                 replyType = QQ_IM_NORMAL_REPLY;
00224         else
00225                 replyType = QQ_IM_AUTO_REPLY;
00226 }
00227 
00228 int SendTextIMPacket::putContents(unsigned char *buf) 
00229 {
00230         
00231         bool hasImage = false;
00232         std::string str2send = EvaUtil::convertToSend(message, &hasImage);
00233 
00234         int pos=0;
00235         buf[pos++] = hasImage?QQ_IM_IMAGE_REPLY:replyType; // auto-reply or not
00236 
00237         memcpy(buf+pos, str2send.c_str(), str2send.length());
00238         pos += str2send.length();
00239 
00240         buf[pos++] = 0x20; //  a space
00241         buf[pos++] = 0x00;    //  C style string terminator
00242         
00243         buf[pos++] = fontFlag;
00244         buf[pos++] = red;
00245         buf[pos++] = green;
00246         buf[pos++] = blue;
00247         
00248         buf[pos++] = 0;
00249         
00250         short tmpEncoding = htons(encoding);  // encoding for text
00251         memcpy(buf+pos,&tmpEncoding, 2);
00252         pos+=2;
00253         
00254         int len = fontName.length();     // font name
00255         memcpy(buf+pos, fontName.c_str(), len);
00256         pos+=len;
00257  
00258         buf[pos++] = 0x0D;   // an Enter
00259         
00260         return pos;
00261 }
00262 /*
00263 std::string SendTextIMPacket::convertToSend(const std::string &text)
00264 {
00265         std::string converted = "";
00266         int offset=0;
00267         char smileyTag = 0x14;
00268         for(uint i=0; i< text.length(); i++){
00269                 if(text[i] == '/'){
00270                         offset = i;
00271                         while(text[offset] != 0x00 && text[++offset]!=' ');
00272                         if((offset - i)<8){
00273                                 char code = util.textToSmiley(text.substr(i,offset-i));
00274                                 if(code){
00275                                         converted += smileyTag;
00276                                         converted += code;
00277                                         i=offset;
00278                                         continue;
00279                                 }
00280                         }
00281                         converted+=text[i];
00282                         continue;
00283                 }
00284                 converted+=text[i];
00285         }
00286         return converted;
00287 }*/
00288 
00289 /* =========================================================== */
00290 
00291 SendIMReplyPacket::SendIMReplyPacket(unsigned char *buf, int len)
00292         : InPacket(buf, len),
00293         replyCode(0x01)
00294 {
00295 }
00296 
00297 SendIMReplyPacket::SendIMReplyPacket(const SendIMReplyPacket &rhs)
00298         : InPacket(rhs)
00299 {
00300         replyCode = rhs.getReplyCode();
00301 }
00302 
00303 SendIMReplyPacket &SendIMReplyPacket::operator=(const SendIMReplyPacket &rhs )
00304 {
00305         *((InPacket *)this) = (InPacket)rhs;
00306         replyCode = rhs.getReplyCode();
00307         return *this;
00308 }
00309 
00310 const bool SendIMReplyPacket::isSentOK() const
00311 {
00312          return replyCode == QQ_SEND_IM_REPLY_OK;
00313 }
00314 
00315 void SendIMReplyPacket::parseBody()
00316 {
00317         replyCode = decryptedBuf[0];
00318 }
00319 
00320 
00321 /*  ======================================================= */
00322 
00323 
00324 SendFileRequestPacket::SendFileRequestPacket( )
00325         : SendIM(QQ_IM_UDP_REQUEST)
00326         , m_FileName("")
00327         , m_FileSize(0)
00328         , m_DirectPort(0)
00329         , m_WanPort(0)
00330         , m_WanIp(0)
00331         , m_TransferType(QQ_TRANSFER_FACE)
00332 {
00333 }
00334 
00335 SendFileRequestPacket::SendFileRequestPacket( const SendFileRequestPacket & rhs )
00336         : SendIM(rhs)
00337 {
00338         *this = rhs;
00339 }
00340 
00341 SendFileRequestPacket & SendFileRequestPacket::operator =( const SendFileRequestPacket & rhs )
00342 {
00343         (SendIM)(*this) = (SendIM)rhs;
00344         m_FileName = rhs.getFileName();
00345         m_FileSize = rhs.getFileSize();
00346         m_DirectPort = rhs.getDirectPort();
00347         m_WanPort = rhs.getWanPort();
00348         m_WanIp = rhs.getWanIp();
00349         m_TransferType = rhs.getTransferType();
00350         return *this;
00351 }
00352 
00353 int SendFileRequestPacket::putContents( unsigned char * buf )
00354 {
00355         int pos = 0;
00356         memset(buf, 0, 11);pos+=11;     // 11 bytes 0x00
00357         
00358         buf[pos++] = m_TransferType;    // transfer File or custom-picture
00359         buf[pos++] = 0x00;
00360         
00361         pos+=EvaUtil::write32(buf+pos, m_WanIp);
00362         pos+=EvaUtil::write16(buf+pos, m_WanPort);
00363         
00364         pos+=EvaUtil::write16(buf+pos, m_DirectPort);
00365         memset(buf+pos, 6, 0); pos+=6;
00366 
00367         buf[pos++] = 0x20;
00368         buf[pos++] = 0x1f;
00369         
00370         int len = strlen(m_FileName.c_str());
00371         memcpy(buf+pos, m_FileName.c_str(), len); pos+=len;
00372         buf[pos++] = 0x1f;
00373 
00374 #ifdef WIN32
00375         char* strSize; strSize=(char*)_alloca(100);
00376 #else
00377         char strSize[100];
00378 #endif
00379         memset(strSize, 100, 0);
00380         sprintf(strSize, "%d", m_FileSize);
00381         len = strlen(strSize);
00382         memcpy(buf+pos, strSize, len); pos+=len;
00383         buf[pos++] = 0x20;
00384 
00385         // chinese for "byte"(zijie) encoded in GB18030
00386         buf[pos++] = 0xd7;
00387         buf[pos++] = 0xd6;
00388         buf[pos++] = 0xbd;
00389         buf[pos++] = 0xda;
00390 
00391         return pos;
00392 }
00393 
00394 
00395 
00396 /*  ======================================================= */
00397 
00398 
00399 SendFileExRequestPacket::SendFileExRequestPacket( const short cmd )
00400         : SendIM(cmd)
00401         , m_FileName("")
00402         , m_FileSize(0)
00403         , m_WanPort(0)
00404         , m_WanIp(0)
00405         , m_TransferType(QQ_TRANSFER_FILE)
00406 {
00407 }
00408 
00409 SendFileExRequestPacket::SendFileExRequestPacket( const SendFileExRequestPacket & rhs )
00410         : SendIM(rhs)
00411 {
00412         *this = rhs;
00413 }
00414 
00415 SendFileExRequestPacket & SendFileExRequestPacket::operator =( const SendFileExRequestPacket & rhs )
00416 {
00417         (SendIM)(*this) = (SendIM)rhs;
00418         m_FileName = rhs.getFileName();
00419         m_FileSize = rhs.getFileSize();
00420         m_WanPort = rhs.getWanPort();
00421         m_WanIp = rhs.getWanIp();
00422         m_TransferType = rhs.getTransferType();
00423         m_SessionId = rhs.getSessionId();
00424         return *this;
00425 }
00426 
00427 int SendFileExRequestPacket::putContents( unsigned char * buf )
00428 {
00429         int pos = 0;
00430         memset(buf, 0, 11);pos+=11;     // 11 bytes 0x00
00431         
00432         buf[pos++] = m_TransferType;    // transfer File or custom-picture
00433         buf[pos++] = 0x00;
00434 
00435         buf[pos++] = 0x66;  // unknown byte, 0x66, but sometimes is 0x67
00436 
00437         // 2 bytes, 0x0000 ( if is Cancellation Request,this part still here? 
00438         // no, if not QQ_IM_EX_REQUEST_CANCELED command, this part will be here.:)
00439         if(getContentType() != QQ_IM_EX_REQUEST_CANCELLED) pos+=EvaUtil::write16(buf+pos, 0x00);
00440 
00441         pos+=EvaUtil::write32(buf+pos, 1); // 4 bytes, 0x00000001
00442         pos+=EvaUtil::write16(buf+pos, 0x00); // 2 bytes, 0x0000
00443         pos+=EvaUtil::write16(buf+pos, m_SessionId); // can it be random number ?
00444 
00445         if(getContentType() != QQ_IM_EX_REQUEST_CANCELLED){
00446                 if(getContentType() == QQ_IM_EX_REQUEST_ACCEPTED){
00447                         pos+=EvaUtil::write32(buf+pos, m_WanIp); // big endian
00448                         memset(buf+pos, 0, 8); pos+=8;
00449                 }else {
00450                         // this may include ip(4 bytes) and port(4 bytes) and 0x00000000(4 bytes)
00451                         memset(buf+pos, 0, 12); pos+=12;
00452                 }
00453         
00454                 buf[pos++] = 0x02; // unknown, 0x02 or 0x04
00455                 if(getContentType() == QQ_IM_TCP_REQUEST)
00456                         EvaUtil::write16(buf+pos, 0x0102);
00457                 else
00458                         memset(buf+pos, 0, 2);
00459                 pos+=2;
00460         }
00461 
00462         pos+=EvaUtil::write32(buf+pos, 1); // unknown 4 bytes, 0x00000000 or  0x00000001
00463 
00464         memset(buf+pos, 0, 2); pos+=2;
00465 
00466         if(getContentType() == QQ_IM_EX_REQUEST_ACCEPTED){ // QQ_IM_EX_REQUEST_ACCEPTED finished here
00467                 memset(buf+pos, 0, 2); pos+=2;
00468                 return pos;
00469         }
00470 
00471         if(getContentType() == QQ_IM_EX_REQUEST_CANCELLED){ // QQ_IM_EX_REQUEST_CANCELED finished here
00472                 memset(buf+pos, 0, 6); pos+=6;
00473                 return pos;
00474         }
00475                 
00476         int offset = 0;
00477         if(getContentType() == QQ_IM_EX_UDP_REQUEST){
00478                 offset = pos;
00479                 pos+=2;
00480                 buf[pos++] = 0x01; // unknown
00481                 pos+=2;  // this part this the following part length again! so offset will be offset+3
00482         }
00483 
00484 
00485         buf[pos++] = 0x20;
00486         buf[pos++] = 0x1f;
00487         
00488         int len = strlen(m_FileName.c_str());
00489         memcpy(buf+pos, m_FileName.c_str(), len); pos+=len;
00490         buf[pos++] = 0x1f;
00491 
00492 #ifdef WIN32
00493         char* strSize; strSize=(char*)_alloca(100);
00494 #else
00495         char strSize[100];
00496 #endif
00497         memset(strSize, 100, 0);
00498         sprintf(strSize, "%d", m_FileSize);
00499         len = strlen(strSize);
00500         memcpy(buf+pos, strSize, len); pos+=len;
00501         buf[pos++] = 0x20;
00502 
00503         // chinese for "byte"(zijie) encoded in GB18030
00504         buf[pos++] = 0xd7;
00505         buf[pos++] = 0xd6;
00506         buf[pos++] = 0xbd;
00507         buf[pos++] = 0xda;
00508 
00509         // now we set the 2 lengths
00510         EvaUtil::write16(buf+offset, pos-offset-2);
00511         EvaUtil::write16(buf+offset+3, pos-offset-2-3-2);
00512 
00513         return pos;
00514 }
00515 
00516 
00517 /*  ======================================================= */
00518 
00519 
00520 SendIpExNotifyPacket::SendIpExNotifyPacket( const bool isSender )
00521         : SendIM(QQ_IM_EX_NOTIFY_IP)
00522         , m_IsSender(isSender)
00523         , m_TransferType(QQ_TRANSFER_FILE)
00524         , m_ConnectMode(QQ_TRANSFER_FILE_UDP)
00525         , m_SessionId(0)
00526         , m_WanIp1(0), m_WanPort1(0)
00527         , m_WanIp2(0), m_WanPort2(0)
00528         , m_WanIp3(0), m_WanPort3(0)
00529         , m_LanIp1(0), m_LanPort1(0)
00530         , m_LanIp2(0), m_LanPort2(0)
00531         , m_LanIp3(0), m_LanPort3(0)
00532         , m_SyncIp(0), m_SyncPort(0)
00533         , m_SyncSession(0)
00534 {
00535 }
00536 
00537 
00538 SendIpExNotifyPacket::SendIpExNotifyPacket( const SendIpExNotifyPacket & rhs )
00539         : SendIM(rhs)
00540 {
00541         *this = rhs;
00542 }
00543 
00544 SendIpExNotifyPacket & SendIpExNotifyPacket::operator =( const SendIpExNotifyPacket & rhs )
00545 {
00546         (SendIM)(*this) = (SendIM)rhs;
00547         m_IsSender = rhs.isSender();
00548         m_TransferType = rhs.getTransferType();
00549         m_ConnectMode = rhs.getConnectMode();
00550         m_SessionId = rhs.getSessionId();
00551 
00552         m_WanIp1 = rhs.getWanIp1();
00553         m_WanPort1 = rhs.getWanPort1();
00554         m_WanIp2 = rhs.getWanIp2();
00555         m_WanPort2 = rhs.getWanPort2();
00556         m_WanIp3 = rhs.getWanIp3();
00557         m_WanPort3 = rhs.getWanPort3();
00558 
00559         m_LanIp1 = rhs.getLanIp1();
00560         m_LanPort1 = rhs.getLanPort1();
00561         m_LanIp2 = rhs.getLanIp2();
00562         m_LanPort2 = rhs.getLanPort2();
00563         m_LanIp3 = rhs.getLanIp3();
00564         m_LanPort3 = rhs.getLanPort3();
00565 
00566         m_SyncIp = rhs.getSyncIp();
00567         m_SyncPort = rhs.getSyncPort();
00568         m_SyncSession = rhs.getSyncSession();
00569 
00570         return *this;
00571 }
00572 
00573 int SendIpExNotifyPacket::putContents( unsigned char * buf )
00574 {
00575         int pos = 0;
00576         memset(buf, 0, 11);pos+=11;     // 11 bytes 0x00
00577         
00578         buf[pos++] = m_TransferType;    // transfer File or custom-picture
00579         buf[pos++] = m_ConnectMode;
00580 
00581         buf[pos++] = 0x66;  // unknown byte, 0x66, but sometimes is 0x67
00582 
00583         // 2 bytes, 0x0000 ( if is Cancellation Request,this part still here?
00584         //pos+=EvaUtil::write16(buf+pos, 0x00);
00585 
00586         pos+=EvaUtil::write32(buf+pos, 1); // 4 bytes, 0x00000001
00587         pos+=EvaUtil::write32(buf+pos, m_SessionId);
00588 
00589         // following 2 bytes maybe a unsigned short sequence id for this session
00590         buf[pos++] = 0x00;
00591         buf[pos++] = m_IsSender?0x01:0x02;
00592 
00593         int offset = pos;
00594         pos+=2;  // length of following;
00595 
00596         memcpy(buf+pos, &m_WanIp1, 4); pos+=4; // little endian
00597         pos+=EvaUtil::write16(buf+pos, m_WanPort1); // 2 bytes
00598 
00599         memcpy(buf+pos, &m_WanIp2, 4); pos+=4; // little endian
00600         pos+=EvaUtil::write16(buf+pos, m_WanPort2); // 2 bytes
00601 
00602         memcpy(buf+pos, &m_LanIp1, 4); pos+=4; // little endian
00603         pos+=EvaUtil::write16(buf+pos, m_LanPort1); // 2 bytes
00604 
00605         // this part looks always 6 0x00s
00606         memcpy(buf+pos, &m_LanIp2, 4); pos+=4; // little endian
00607         pos+=EvaUtil::write16(buf+pos, m_LanPort2); // 2 bytes
00608 
00609 
00610         memcpy(buf+pos, &m_LanIp3, 4); pos+=4; // little endian
00611         pos+=EvaUtil::write16(buf+pos, m_LanPort3); // 2 bytes
00612 
00613         if(m_IsSender){
00614                 //unsigned int agent= 0xdb503185;
00615                 memcpy(buf+pos, &m_SyncIp, 4); pos+=4; // little endian
00616                 //unsigned short aport = 0x1f40;
00617                 pos+=EvaUtil::write16(buf+pos, m_SyncPort); // 2 bytes  
00618                 pos+=EvaUtil::write32(buf+pos, m_SyncSession);
00619         }
00620         memcpy(buf+pos, &m_WanIp3, 4); pos+=4; // little endian
00621         pos+=EvaUtil::write16(buf+pos, m_WanPort3); // 2 bytes  
00622 
00623         memset(buf+pos, 0, 10); pos+=10;
00624         if(m_IsSender){
00625                 memset(buf+pos, 0, 2); pos+=2;
00626         }
00627 //      memset(buf+pos, 0, 2); pos+=2;
00628 //      buf[pos++] = 0x14; // unknown byte
00629 //      buf[pos++] = 0x00;
00630 //      pos+=EvaUtil::write16(buf+pos, 0x40d5); // unknown 2 bytes
00631 // 
00632 //      memset(buf+pos, 0, 4); pos+=4; // maybe a another ip? we try all 0
00633         buf[pos++] = 0x12;
00634         buf[pos++] = 0x00;
00635 
00636         // write the length
00637         EvaUtil::write16(buf+offset, pos-offset-2);
00638 
00639         return pos;
00640 }
00641 
00642 
00646 SendFileNotifyAgentPacket::SendFileNotifyAgentPacket()
00647         : SendIM(QQ_IM_NOTIFY_FILE_AGENT_INFO)
00648         , m_TransferType(QQ_TRANSFER_FILE)
00649         , m_ConnectMode(QQ_TRANSFER_FILE_TCP)
00650 {
00651 }
00652 
00653 SendFileNotifyAgentPacket::SendFileNotifyAgentPacket(const SendFileAcceptPacket &rhs)
00654         : SendIM(rhs)
00655 {
00656         *this = rhs;
00657 }
00658 
00659 SendFileNotifyAgentPacket &SendFileNotifyAgentPacket::operator=(const SendFileNotifyAgentPacket &rhs)
00660 {
00661         (SendIM)(*this) = (SendIM)rhs;
00662         m_Ip = rhs.getAgentIp();
00663         m_Port = rhs.getAgentPort();
00664         m_Session = rhs.getAgentSession();
00665         return *this;
00666 }
00667 
00668 int SendFileNotifyAgentPacket::putContents(unsigned char *buf)
00669 {
00670         int pos = 0;
00671         memset(buf, 0, 11);pos+=11;     // 11 bytes 0x00
00672         
00673         buf[pos++] = m_TransferType;    // transfer File or custom-picture
00674         buf[pos++] = m_ConnectMode;
00675 
00676         memset(buf+pos, 0, 12); pos+=12;
00677         pos += EvaUtil::write32(buf+pos, m_Ip);
00678         pos += EvaUtil::write16(buf+pos, m_Port);
00679         pos += EvaUtil::write32(buf+pos, m_Session);
00680 
00681         memcpy(buf+pos, getFileAgentKey(), 16); pos+=16;
00682         buf[pos++] = 0x01; // unknown byte
00683         return pos;     
00684 }
00685 

Generated on Mon May 15 20:48:40 2006 for libeva by  doxygen 1.4.4