From 1f9fcfce83e81ff27d7c0ff80a5e85cdc89118c7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 29 Nov 2016 20:14:10 +0300 Subject: code cleaning --- protocols/ICQCorp/src/event.cpp | 77 +++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 37 deletions(-) (limited to 'protocols/ICQCorp/src/event.cpp') diff --git a/protocols/ICQCorp/src/event.cpp b/protocols/ICQCorp/src/event.cpp index 44a0a2bf56..70ccbedf3f 100644 --- a/protocols/ICQCorp/src/event.cpp +++ b/protocols/ICQCorp/src/event.cpp @@ -25,87 +25,90 @@ std::vector icqEvents; static void WINAPI eventTimerProc(HWND, UINT, UINT_PTR hTimer, DWORD) { - unsigned int i; + KillTimer(NULL, hTimer); - KillTimer(NULL, hTimer); - for (i=0; ihTimer) icqEvents[i]->noAck(); + for (size_t i = 0; i < icqEvents.size(); i++) + if (hTimer == icqEvents[i]->hTimer) + icqEvents[i]->noAck(); } /////////////////////////////////////////////////////////////////////////////// -ICQEvent *getEvent(SOCKET hSocket, unsigned int sequence) +ICQEvent* getEvent(SOCKET hSocket, unsigned int sequence) { - unsigned int i; + for (size_t i = 0; i < icqEvents.size(); i++) + if (icqEvents[i]->isEvent(hSocket, sequence)) + return icqEvents[i]; - for (i=0; iisEvent(hSocket, sequence)) return icqEvents[i]; - return NULL; + return NULL; } /////////////////////////////////////////////////////////////////////////////// ICQEvent::ICQEvent(unsigned short theCmd, unsigned short theSubCmd, unsigned int theSequence, - unsigned int theUin, Socket *theSocket, Packet *thePacket, int theReply) + unsigned int theUin, Socket *theSocket, Packet *thePacket, int theReply) { - cmd = theCmd; - subCmd = theSubCmd; - sequence = theSequence; - uin = theUin; - socket = theSocket; - packet = new Packet(thePacket); - reply = theReply; - - hTimer = NULL; - retries = 0; + cmd = theCmd; + subCmd = theSubCmd; + sequence = theSequence; + uin = theUin; + socket = theSocket; + packet = new Packet(thePacket); + reply = theReply; + + hTimer = NULL; + retries = 0; } /////////////////////////////////////////////////////////////////////////////// ICQEvent::~ICQEvent() { - stop(); - delete packet; + stop(); + delete packet; } /////////////////////////////////////////////////////////////////////////////// bool ICQEvent::start() { - // send the packet - if (!socket->sendPacket(*packet)) return false; + // send the packet + if (!socket->sendPacket(*packet)) + return false; - if (cmd != ICQ_CMDxTCP_START) hTimer = SetTimer(NULL, 0, MAX_WAIT_ACK, eventTimerProc); - return true; + if (cmd != ICQ_CMDxTCP_START) + hTimer = SetTimer(NULL, 0, MAX_WAIT_ACK, eventTimerProc); + return true; } /////////////////////////////////////////////////////////////////////////////// void ICQEvent::stop() { - if (hTimer) - { - KillTimer(NULL, hTimer); - hTimer = NULL; - } + if (hTimer) { + KillTimer(NULL, hTimer); + hTimer = NULL; + } } /////////////////////////////////////////////////////////////////////////////// bool ICQEvent::isEvent(SOCKET hSocket, unsigned long theSequence) { - return socket->handleVal == hSocket && sequence == theSequence; + return socket->handleVal == hSocket && sequence == theSequence; } /////////////////////////////////////////////////////////////////////////////// void ICQEvent::noAck() { - hTimer = NULL; - if (socket->connected() && retries < MAX_SERVER_RETRIES && cmd != ICQ_CMDxTCP_START) - { - retries++; - start(); - } - else icq.doneEvent(false, socket->handleVal, sequence); + hTimer = NULL; + if (socket->connected() && retries < MAX_SERVER_RETRIES && cmd != ICQ_CMDxTCP_START) + { + retries++; + start(); + } + else icq.doneEvent(false, socket->handleVal, sequence); } /////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3