diff options
author | George Hazan <george.hazan@gmail.com> | 2014-07-13 22:29:27 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-07-13 22:29:27 +0000 |
commit | 95336fc1843ab1ca7e2131b66ce67635e0ac19d2 (patch) | |
tree | c51b059b139b0e222036ed8eb48920b10f1f852a /protocols | |
parent | db58e3f45a11aa0b19c5d0638a20cc5d404f40a6 (diff) |
- fix for 64-bit incompatibility;
- STL removed;
- copyright update;
- massive code cleaning;
- version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@9790 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
61 files changed, 594 insertions, 955 deletions
diff --git a/protocols/IcqOscarJ/src/UI/userinfotab.cpp b/protocols/IcqOscarJ/src/UI/userinfotab.cpp index f015918ad0..8485f7489a 100644 --- a/protocols/IcqOscarJ/src/UI/userinfotab.cpp +++ b/protocols/IcqOscarJ/src/UI/userinfotab.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,13 +21,12 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Code for User details ICQ specific pages
-//
// -----------------------------------------------------------------------------
+
#include "icqoscar.h"
#define SVS_NORMAL 0
diff --git a/protocols/IcqOscarJ/src/capabilities.cpp b/protocols/IcqOscarJ/src/capabilities.cpp index 00b6250a9a..e8b75b960f 100644 --- a/protocols/IcqOscarJ/src/capabilities.cpp +++ b/protocols/IcqOscarJ/src/capabilities.cpp @@ -1,26 +1,26 @@ // ---------------------------------------------------------------------------80
// ICQ plugin for Miranda Instant Messenger
// ________________________________________
-//
+//
// Copyright © 2000-2001 Richard Hughes, Roland Rabien, Tristan Van de Vreede
// Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
-//
+// Copyright © 2012-2014 Miranda NG Team
+//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
-//
+//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// 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, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
@@ -30,8 +30,8 @@ // scans but only a few lookups. So when you add or change something in this
// code you must have this in mind, dont do anything that will slow down the
// adding process too much.
-//
// -----------------------------------------------------------------------------
+
#include "icqoscar.h"
struct icq_capability
@@ -63,7 +63,7 @@ struct icq_capability_name const char* capName;
};
-static const icq_capability_name CapabilityNames[] =
+static const icq_capability_name CapabilityNames[] =
{
{ CAPF_SRV_RELAY, "ServerRelay"},
{ CAPF_UTF, "UTF8 Messages"},
diff --git a/protocols/IcqOscarJ/src/capabilities.h b/protocols/IcqOscarJ/src/capabilities.h index 3b6590dd09..cff5ab9f04 100644 --- a/protocols/IcqOscarJ/src/capabilities.h +++ b/protocols/IcqOscarJ/src/capabilities.h @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,18 +21,15 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Contains helper functions to handle OSCAR user capabilities.
-//
// -----------------------------------------------------------------------------
#ifndef __CAPABILITIES_H
#define __CAPABILITIES_H
-
// capabilities
typedef BYTE capstr[BINARY_CAP_SIZE];
typedef BYTE shortcapstr[BINARY_SHORT_CAP_SIZE];
diff --git a/protocols/IcqOscarJ/src/chan_02data.cpp b/protocols/IcqOscarJ/src/chan_02data.cpp index 2c40d0902b..d9a827c359 100644 --- a/protocols/IcqOscarJ/src/chan_02data.cpp +++ b/protocols/IcqOscarJ/src/chan_02data.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,15 +21,13 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Handle channel 2 (Data) packets
-//
// -----------------------------------------------------------------------------
-#include "icqoscar.h"
+#include "icqoscar.h"
void CIcqProto::handleDataChannel(BYTE *pBuffer, WORD wBufferLength, serverthread_info *info)
{
diff --git a/protocols/IcqOscarJ/src/changeinfo/changeinfo.h b/protocols/IcqOscarJ/src/changeinfo/changeinfo.h index ecc4fc3106..0497f288fd 100644 --- a/protocols/IcqOscarJ/src/changeinfo/changeinfo.h +++ b/protocols/IcqOscarJ/src/changeinfo/changeinfo.h @@ -4,6 +4,7 @@ //
// Copyright © 2001-2004 Richard Hughes, Martin Öberg
// Copyright © 2004-2010 Joe Kucera, Bio
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -18,12 +19,10 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// ChangeInfo Plugin stuff
-//
// -----------------------------------------------------------------------------
#ifndef __CHANGEINFO_H
diff --git a/protocols/IcqOscarJ/src/changeinfo/constants.cpp b/protocols/IcqOscarJ/src/changeinfo/constants.cpp index 0148fba616..1d908307ee 100644 --- a/protocols/IcqOscarJ/src/changeinfo/constants.cpp +++ b/protocols/IcqOscarJ/src/changeinfo/constants.cpp @@ -4,6 +4,7 @@ //
// Copyright © 2001-2004 Richard Hughes, Martin Öberg
// Copyright © 2004-2009 Joe Kucera, Bio
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -18,12 +19,10 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// ChangeInfo Plugin stuff
-//
// -----------------------------------------------------------------------------
#include "icqoscar.h"
diff --git a/protocols/IcqOscarJ/src/changeinfo/db.cpp b/protocols/IcqOscarJ/src/changeinfo/db.cpp index 1403518297..31f88db502 100644 --- a/protocols/IcqOscarJ/src/changeinfo/db.cpp +++ b/protocols/IcqOscarJ/src/changeinfo/db.cpp @@ -4,6 +4,7 @@ //
// Copyright © 2001-2004 Richard Hughes, Martin Öberg
// Copyright © 2004-2009 Joe Kucera, Bio
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -18,12 +19,10 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// ChangeInfo Plugin stuff
-//
// -----------------------------------------------------------------------------
#include "icqoscar.h"
diff --git a/protocols/IcqOscarJ/src/changeinfo/dlgproc.cpp b/protocols/IcqOscarJ/src/changeinfo/dlgproc.cpp index 596f8e262b..0edfa48fcb 100644 --- a/protocols/IcqOscarJ/src/changeinfo/dlgproc.cpp +++ b/protocols/IcqOscarJ/src/changeinfo/dlgproc.cpp @@ -4,6 +4,7 @@ //
// Copyright © 2001-2004 Richard Hughes, Martin Öberg
// Copyright © 2004-2010 Joe Kucera, Bio
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -18,12 +19,10 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// ChangeInfo Plugin stuff
-//
// -----------------------------------------------------------------------------
#include "icqoscar.h"
diff --git a/protocols/IcqOscarJ/src/changeinfo/editlist.cpp b/protocols/IcqOscarJ/src/changeinfo/editlist.cpp index a7092a7165..765c99cce6 100644 --- a/protocols/IcqOscarJ/src/changeinfo/editlist.cpp +++ b/protocols/IcqOscarJ/src/changeinfo/editlist.cpp @@ -4,6 +4,7 @@ //
// Copyright © 2001-2004 Richard Hughes, Martin Öberg
// Copyright © 2004-2009 Joe Kucera, Bio
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -18,12 +19,10 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// ChangeInfo Plugin stuff
-//
// -----------------------------------------------------------------------------
#include "icqoscar.h"
diff --git a/protocols/IcqOscarJ/src/changeinfo/editstring.cpp b/protocols/IcqOscarJ/src/changeinfo/editstring.cpp index 191b933cf3..19fdd4c2b7 100644 --- a/protocols/IcqOscarJ/src/changeinfo/editstring.cpp +++ b/protocols/IcqOscarJ/src/changeinfo/editstring.cpp @@ -4,6 +4,7 @@ //
// Copyright © 2001-2004 Richard Hughes, Martin Öberg
// Copyright © 2004-2009 Joe Kucera, Bio
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -18,12 +19,10 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// ChangeInfo Plugin stuff
-//
// -----------------------------------------------------------------------------
#include "icqoscar.h"
diff --git a/protocols/IcqOscarJ/src/changeinfo/upload.cpp b/protocols/IcqOscarJ/src/changeinfo/upload.cpp index fe5258c8ee..6ff49b54f3 100644 --- a/protocols/IcqOscarJ/src/changeinfo/upload.cpp +++ b/protocols/IcqOscarJ/src/changeinfo/upload.cpp @@ -4,6 +4,7 @@ //
// Copyright © 2001-2004 Richard Hughes, Martin Öberg
// Copyright © 2004-2009 Joe Kucera, Bio
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -18,12 +19,10 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// ChangeInfo Plugin stuff
-//
// -----------------------------------------------------------------------------
#include "icqoscar.h"
diff --git a/protocols/IcqOscarJ/src/channels.h b/protocols/IcqOscarJ/src/channels.h index ba10483b56..5d7c73489b 100644 --- a/protocols/IcqOscarJ/src/channels.h +++ b/protocols/IcqOscarJ/src/channels.h @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,17 +21,15 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Header for FLAP Channel packet handlers
-//
// -----------------------------------------------------------------------------
+
#ifndef __CHANNELS_H
#define __CHANNELS_H
-
struct snac_header
{
BOOL bValid;
@@ -43,5 +42,4 @@ struct snac_header int unpackSnacHeader(snac_header *pSnacHeader, BYTE **pBuffer, WORD *pwBufferLength);
-
#endif /* __CHANNELS_H */
diff --git a/protocols/IcqOscarJ/src/cookies.cpp b/protocols/IcqOscarJ/src/cookies.cpp index 750b6280c5..be71d6b4ef 100644 --- a/protocols/IcqOscarJ/src/cookies.cpp +++ b/protocols/IcqOscarJ/src/cookies.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,12 +21,10 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Handles packet & message cookies
-//
// -----------------------------------------------------------------------------
#include "icqoscar.h"
diff --git a/protocols/IcqOscarJ/src/cookies.h b/protocols/IcqOscarJ/src/cookies.h index aec80dc5be..d8233f71c2 100644 --- a/protocols/IcqOscarJ/src/cookies.h +++ b/protocols/IcqOscarJ/src/cookies.h @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
diff --git a/protocols/IcqOscarJ/src/directpackets.cpp b/protocols/IcqOscarJ/src/directpackets.cpp index 41bdfa4325..9e24b25c89 100644 --- a/protocols/IcqOscarJ/src/directpackets.cpp +++ b/protocols/IcqOscarJ/src/directpackets.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
diff --git a/protocols/IcqOscarJ/src/fam_01service.cpp b/protocols/IcqOscarJ/src/fam_01service.cpp index ab75bab78c..e86882e802 100644 --- a/protocols/IcqOscarJ/src/fam_01service.cpp +++ b/protocols/IcqOscarJ/src/fam_01service.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,13 +21,12 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Handles packets from Service family
-//
// -----------------------------------------------------------------------------
+
#include "icqoscar.h"
extern capstr capXStatus[];
@@ -638,7 +638,7 @@ void CIcqProto::setUserInfo() wAdditionalData += 16;
#endif
- wAdditionalData += (WORD)CustomCapList.size() * 16;
+ wAdditionalData += (WORD)CustomCapList.getCount() * 16;
//MIM/PackName
bool bHasPackName = false;
@@ -722,9 +722,9 @@ void CIcqProto::setUserInfo() db_free(&dbv);
}
- if (!CustomCapList.empty())
- for (std::list<ICQ_CUSTOMCAP*>::iterator it = CustomCapList.begin(), end = CustomCapList.end(); it != end; ++it)
- packBuffer(&packet, (BYTE*)(*it)->caps, 0x10);
+ if (CustomCapList.getCount())
+ for (int i = 0; i < CustomCapList.getCount(); i++)
+ packBuffer(&packet, (PBYTE)CustomCapList[i].caps, 0x10);
sendServPacket(&packet);
}
diff --git a/protocols/IcqOscarJ/src/fam_02location.cpp b/protocols/IcqOscarJ/src/fam_02location.cpp index 65459c516a..202f063854 100644 --- a/protocols/IcqOscarJ/src/fam_02location.cpp +++ b/protocols/IcqOscarJ/src/fam_02location.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,15 +21,13 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Handles packets from Location family
-//
// -----------------------------------------------------------------------------
-#include "icqoscar.h"
+#include "icqoscar.h"
extern const char* cliSpamBot;
diff --git a/protocols/IcqOscarJ/src/fam_03buddy.cpp b/protocols/IcqOscarJ/src/fam_03buddy.cpp index 06783be2df..495eb9774b 100644 --- a/protocols/IcqOscarJ/src/fam_03buddy.cpp +++ b/protocols/IcqOscarJ/src/fam_03buddy.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,15 +21,13 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Handles packets from Buddy family
-//
// -----------------------------------------------------------------------------
-#include "icqoscar.h"
+#include "icqoscar.h"
extern const char* cliSpamBot;
diff --git a/protocols/IcqOscarJ/src/fam_04message.cpp b/protocols/IcqOscarJ/src/fam_04message.cpp index 499192fc2b..538ce9741e 100644 --- a/protocols/IcqOscarJ/src/fam_04message.cpp +++ b/protocols/IcqOscarJ/src/fam_04message.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,15 +21,13 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Handles packets from Family 4 ICBM Messages
-//
// -----------------------------------------------------------------------------
-#include "icqoscar.h"
+#include "icqoscar.h"
void CIcqProto::handleMsgFam(BYTE *pBuffer, WORD wBufferLength, snac_header *pSnacHeader)
{
@@ -1869,58 +1868,46 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, case MTYPE_AUTHREQ: /* auth request */
/* format: nick FE first FE last FE email FE unk-char FE msg 00 */
+ if (nMsgFields < 6) {
+ debugLogA("Malformed '%s' message", "auth req");
+ break;
+ }
{
- char* szBlob;
- char* pCurBlob;
-
- if (nMsgFields < 6) {
- debugLogA("Malformed '%s' message", "auth req");
- break;
- }
-
PROTORECVEVENT pre = {0};
pre.timestamp=dwTimestamp;
- pre.lParam=sizeof(DWORD)+sizeof(HANDLE)+strlennull(pszMsgField[0])+strlennull(pszMsgField[1])+strlennull(pszMsgField[2])+strlennull(pszMsgField[3])+strlennull(pszMsgField[5])+5;
-
- /*blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)*/
- pCurBlob=szBlob=(char *)_alloca(pre.lParam);
- memcpy(pCurBlob,&dwUin,sizeof(DWORD)); pCurBlob+=sizeof(DWORD);
- memcpy(pCurBlob,&hContact,sizeof(HANDLE)); pCurBlob+=sizeof(HANDLE);
- strcpy((char *)pCurBlob,pszMsgField[0]); pCurBlob+=strlennull((char *)pCurBlob)+1;
- strcpy((char *)pCurBlob,pszMsgField[1]); pCurBlob+=strlennull((char *)pCurBlob)+1;
- strcpy((char *)pCurBlob,pszMsgField[2]); pCurBlob+=strlennull((char *)pCurBlob)+1;
- strcpy((char *)pCurBlob,pszMsgField[3]); pCurBlob+=strlennull((char *)pCurBlob)+1;
- strcpy((char *)pCurBlob,pszMsgField[5]);
- pre.szMessage=(char *)szBlob;
+ pre.lParam=sizeof(DWORD)*2+strlennull(pszMsgField[0])+strlennull(pszMsgField[1])+strlennull(pszMsgField[2])+strlennull(pszMsgField[3])+strlennull(pszMsgField[5])+5;
+ // blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
+ char *szBlob, *pCurBlob = szBlob = (char *)_alloca(pre.lParam);
+ *(DWORD*)pCurBlob = dwUin; pCurBlob += sizeof(DWORD);
+ *(DWORD*)pCurBlob = DWORD(hContact); pCurBlob += sizeof(DWORD);
+ strcpy((char*)pCurBlob, pszMsgField[0]); pCurBlob += strlennull((char*)pCurBlob) + 1;
+ strcpy((char*)pCurBlob, pszMsgField[1]); pCurBlob += strlennull((char*)pCurBlob) + 1;
+ strcpy((char*)pCurBlob, pszMsgField[2]); pCurBlob += strlennull((char*)pCurBlob) + 1;
+ strcpy((char*)pCurBlob, pszMsgField[3]); pCurBlob += strlennull((char*)pCurBlob) + 1;
+ strcpy((char*)pCurBlob, pszMsgField[5]);
+ pre.szMessage = (char *)szBlob;
ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&pre);
}
break;
case MTYPE_ADDED: /* 'you were added' */
/* format: nick FE first FE last FE email 00 */
+ if (nMsgFields < 4) {
+ debugLogA("Malformed '%s' message", "you were added");
+ break;
+ }
+ hContact = HContactFromUIN(dwUin, &bAdded);
{
- DWORD cbBlob;
- PBYTE pBlob, pCurBlob;
-
- if (nMsgFields < 4)
- {
- debugLogA("Malformed '%s' message", "you were added");
- break;
- }
-
- hContact = HContactFromUIN(dwUin, &bAdded);
-
- /*blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ) */
- cbBlob=sizeof(DWORD)*2+strlennull(pszMsgField[0])+strlennull(pszMsgField[1])+strlennull(pszMsgField[2])+strlennull(pszMsgField[3])+4;
- pCurBlob=pBlob=(PBYTE)_alloca(cbBlob);
+ // blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ)
+ DWORD cbBlob = sizeof(DWORD) * 2 + strlennull(pszMsgField[0]) + strlennull(pszMsgField[1]) + strlennull(pszMsgField[2]) + strlennull(pszMsgField[3]) + 4;
+ PBYTE pBlob, pCurBlob = pBlob = (PBYTE)_alloca(cbBlob);
*(DWORD*)pCurBlob = dwUin; pCurBlob += sizeof(DWORD);
*(DWORD*)pCurBlob = DWORD(hContact); pCurBlob += sizeof(DWORD);
- strcpy((char *)pCurBlob,pszMsgField[0]); pCurBlob += strlennull((char *)pCurBlob)+1;
- strcpy((char *)pCurBlob,pszMsgField[1]); pCurBlob += strlennull((char *)pCurBlob)+1;
- strcpy((char *)pCurBlob,pszMsgField[2]); pCurBlob += strlennull((char *)pCurBlob)+1;
- strcpy((char *)pCurBlob,pszMsgField[3]);
-
+ strcpy((char*)pCurBlob, pszMsgField[0]); pCurBlob += strlennull((char*)pCurBlob) + 1;
+ strcpy((char*)pCurBlob, pszMsgField[1]); pCurBlob += strlennull((char*)pCurBlob) + 1;
+ strcpy((char*)pCurBlob, pszMsgField[2]); pCurBlob += strlennull((char*)pCurBlob) + 1;
+ strcpy((char*)pCurBlob, pszMsgField[3]);
AddEvent(NULL, EVENTTYPE_ADDED, dwTimestamp, 0, cbBlob, pBlob);
}
break;
@@ -1931,7 +1918,6 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, int nContacts;
int i;
-
if (nMsgFields < 3
|| (nContacts = strtol(pszMsgField[0], &pszNContactsEnd, 10)) == 0
|| pszNContactsEnd - pszMsgField[0] != (int)strlennull(pszMsgField[0])
diff --git a/protocols/IcqOscarJ/src/fam_0alookup.cpp b/protocols/IcqOscarJ/src/fam_0alookup.cpp index 44cd2fcc61..9fc4ee1d49 100644 --- a/protocols/IcqOscarJ/src/fam_0alookup.cpp +++ b/protocols/IcqOscarJ/src/fam_0alookup.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
diff --git a/protocols/IcqOscarJ/src/fam_13servclist.cpp b/protocols/IcqOscarJ/src/fam_13servclist.cpp index a079f46a6f..5bf83423f9 100644 --- a/protocols/IcqOscarJ/src/fam_13servclist.cpp +++ b/protocols/IcqOscarJ/src/fam_13servclist.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -1610,12 +1611,10 @@ void CIcqProto::handleRecvAuthRequest(unsigned char *buf, WORD wLen) {
DWORD dwUin;
uid_str szUid;
- int bAdded;
-
- if (!unpackUID(&buf, &wLen, &dwUin, &szUid)) return;
+ if (!unpackUID(&buf, &wLen, &dwUin, &szUid))
+ return;
- if (dwUin && IsOnSpammerList(dwUin))
- {
+ if (dwUin && IsOnSpammerList(dwUin)) {
debugLogA("Ignored Message from known Spammer");
return;
}
@@ -1626,16 +1625,16 @@ void CIcqProto::handleRecvAuthRequest(unsigned char *buf, WORD wLen) if (wReasonLen > wLen)
return;
+ int bAdded;
MCONTACT hContact = HContactFromUID(dwUin, szUid, &bAdded);
PROTORECVEVENT pre = { 0 };
pre.timestamp = time(NULL);
- pre.lParam = sizeof(DWORD) + sizeof(HANDLE) + 5;
+ pre.lParam = sizeof(DWORD)*2 + 5;
// Prepare reason
char *szReason = (char*)SAFE_MALLOC(wReasonLen + 1);
int nReasonLen = 0;
- if (szReason)
- {
+ if (szReason) {
memcpy(szReason, buf, wReasonLen);
szReason[wReasonLen] = '\0';
nReasonLen = strlennull(szReason);
@@ -1644,21 +1643,20 @@ void CIcqProto::handleRecvAuthRequest(unsigned char *buf, WORD wLen) if (!IsUSASCII(szReason, nReasonLen) && UTF8_IsValid(szReason) && utf8_decode_static(szReason, temp, nReasonLen + 1))
pre.flags |= PREF_UTF;
}
+
// Read nick name from DB
char *szNick = NULL;
- if (dwUin)
- {
+ if (dwUin) {
DBVARIANT dbv = { 0 };
if (pre.flags & PREF_UTF)
szNick = getSettingStringUtf(hContact, "Nick", NULL);
- else if (!getString(hContact, "Nick", &dbv))
- {
+ else if (!getString(hContact, "Nick", &dbv)) {
szNick = null_strdup(dbv.pszVal);
db_free(&dbv);
}
}
- else
- szNick = null_strdup(szUid);
+ else szNick = null_strdup(szUid);
+
int nNickLen = strlennull(szNick);
pre.lParam += nNickLen + nReasonLen;
@@ -1668,10 +1666,10 @@ void CIcqProto::handleRecvAuthRequest(unsigned char *buf, WORD wLen) /*blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)*/
char *szBlob = (char *)_alloca(pre.lParam);
char *pCurBlob = szBlob;
- memcpy(pCurBlob, &dwUin, sizeof(DWORD)); pCurBlob += sizeof(DWORD);
- memcpy(pCurBlob, &hContact, sizeof(HANDLE)); pCurBlob += sizeof(HANDLE);
- if (nNickLen)
- { // if we have nick we add it, otherwise keep trailing zero
+ *(DWORD*)pCurBlob = dwUin; pCurBlob += sizeof(DWORD);
+ *(DWORD*)pCurBlob = DWORD(hContact); pCurBlob += sizeof(DWORD);
+
+ if (nNickLen) { // if we have nick we add it, otherwise keep trailing zero
memcpy(pCurBlob, szNick, nNickLen);
pCurBlob += nNickLen;
}
@@ -1691,39 +1689,34 @@ void CIcqProto::handleRecvAuthRequest(unsigned char *buf, WORD wLen) SAFE_FREE(&szNick);
SAFE_FREE(&szReason);
- return;
}
-
void CIcqProto::handleRecvAdded(unsigned char *buf, WORD wLen)
{
DWORD dwUin;
uid_str szUid;
DWORD cbBlob;
- PBYTE pBlob,pCurBlob;
+ PBYTE pBlob, pCurBlob;
int bAdded;
char* szNick;
int nNickLen;
- DBVARIANT dbv = {0};
+ DBVARIANT dbv = { 0 };
if (!unpackUID(&buf, &wLen, &dwUin, &szUid)) return;
- if (dwUin && IsOnSpammerList(dwUin))
- {
+ if (dwUin && IsOnSpammerList(dwUin)) {
debugLogA("Ignored Message from known Spammer");
return;
}
MCONTACT hContact = HContactFromUID(dwUin, szUid, &bAdded);
- cbBlob=sizeof(DWORD)*2+4;
+ cbBlob = sizeof(DWORD) * 2 + 4;
- if (dwUin)
- {
+ if (dwUin) {
if (getString(hContact, "Nick", &dbv))
nNickLen = 0;
- else
- {
+ else {
szNick = dbv.pszVal;
nNickLen = strlennull(szNick);
}
@@ -1733,19 +1726,17 @@ void CIcqProto::handleRecvAdded(unsigned char *buf, WORD wLen) cbBlob += nNickLen;
- pCurBlob=pBlob=(PBYTE)_alloca(cbBlob);
+ pCurBlob = pBlob = (PBYTE)_alloca(cbBlob);
/*blob is: uin(DWORD), hContact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ) */
*(DWORD*)pCurBlob = dwUin; pCurBlob += sizeof(DWORD);
*(DWORD*)pCurBlob = DWORD(hContact); pCurBlob += sizeof(DWORD);
- if (nNickLen && dwUin)
- { // if we have nick we add it, otherwise keep trailing zero
+ if (nNickLen && dwUin) { // if we have nick we add it, otherwise keep trailing zero
memcpy(pCurBlob, szNick, nNickLen);
- pCurBlob+=nNickLen;
+ pCurBlob += nNickLen;
}
- else
- {
+ else {
memcpy(pCurBlob, szUid, nNickLen);
- pCurBlob+=nNickLen;
+ pCurBlob += nNickLen;
}
*(char *)pCurBlob = 0; pCurBlob++;
*(char *)pCurBlob = 0; pCurBlob++;
@@ -1770,8 +1761,7 @@ void CIcqProto::handleRecvAuthResponse(unsigned char *buf, WORD wLen) if (!unpackUID(&buf, &wLen, &dwUin, &szUid)) return;
- if (dwUin && IsOnSpammerList(dwUin))
- {
+ if (dwUin && IsOnSpammerList(dwUin)) {
debugLogA("Ignored Message from known Spammer");
return;
}
@@ -1780,25 +1770,21 @@ void CIcqProto::handleRecvAuthResponse(unsigned char *buf, WORD wLen) if (hContact != INVALID_CONTACT_ID)
szNick = NickFromHandle(hContact);
- if (wLen > 0)
- {
+ if (wLen > 0) {
unpackByte(&buf, &bResponse);
wLen -= 1;
}
- if (wLen >= 2)
- {
+ if (wLen >= 2) {
unpackWord(&buf, &nReasonLen);
wLen -= 2;
- if (wLen >= nReasonLen)
- {
- szReason = (char*)_alloca(nReasonLen+1);
+ if (wLen >= nReasonLen) {
+ szReason = (char*)_alloca(nReasonLen + 1);
unpackString(&buf, szReason, nReasonLen);
szReason[nReasonLen] = '\0';
}
}
- switch (bResponse)
- {
+ switch (bResponse) {
case 0:
debugLogA("Authorization request %s by %s", "denied", strUID(dwUin, szUid));
@@ -1836,8 +1822,7 @@ void CIcqProto::updateServVisibilityCode(BYTE bCode) WORD wVisibilityID;
WORD wCommand;
- if ((bCode > 0) && (bCode < 6))
- {
+ if ((bCode > 0) && (bCode < 6)) {
cookie_servlist_action* ack;
DWORD dwCookie;
BYTE bVisibility = getByte("SrvVisibility", 0);
@@ -1847,8 +1832,7 @@ void CIcqProto::updateServVisibilityCode(BYTE bCode) setByte("SrvVisibility", bCode);
// Do we have a known server visibility ID? We should, unless we just subscribed to the serv-list for the first time
- if ((wVisibilityID = getWord(DBSETTING_SERVLIST_PRIVACY, 0)) == 0)
- {
+ if ((wVisibilityID = getWord(DBSETTING_SERVLIST_PRIVACY, 0)) == 0) {
// No, create a new random ID
wVisibilityID = GenerateServerID(SSIT_ITEM, 0);
setWord(DBSETTING_SERVLIST_PRIVACY, wVisibilityID);
@@ -1857,8 +1841,7 @@ void CIcqProto::updateServVisibilityCode(BYTE bCode) debugLogA("Made new srvVisibilityID, id is %u, code is %u", wVisibilityID, bCode);
#endif
}
- else
- {
+ else {
#ifdef _DEBUG
debugLogA("Reused srvVisibilityID, id is %u, code is %u", wVisibilityID, bCode);
#endif
@@ -1866,8 +1849,7 @@ void CIcqProto::updateServVisibilityCode(BYTE bCode) }
ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
- if (!ack)
- {
+ if (!ack) {
debugLogA("Cookie alloc failure.");
return; // out of memory, go away
}
@@ -1898,103 +1880,87 @@ void CIcqProto::updateServAvatarHash(BYTE *pHash, int size) DWORD dwOperationFlags = 0;
WORD wAvatarID;
WORD wCommand;
- DBVARIANT dbvHash;
- int bResetHash = 0;
- char szItemName[2] = {0, 0};
+ char szItemName[2] = { 0, 0 };
- if (!getSetting(NULL, "AvatarHash", &dbvHash))
- {
+ int bResetHash = 0;
+ DBVARIANT dbvHash;
+ if (!getSetting(NULL, "AvatarHash", &dbvHash)) {
szItemName[0] = 0x30 + dbvHash.pbVal[1];
- if (memcmp(pHash, dbvHash.pbVal, 2) != 0)
- {
- /** add code to remove old hash from server */
+ if (memcmp(pHash, dbvHash.pbVal, 2) != 0) // add code to remove old hash from server
bResetHash = 1;
- }
+
db_free(&dbvHash);
}
- if (bResetHash) // start update session
- { // pair the packets (need to be send in the correct order
+ if (bResetHash) { // start update session
+ // pair the packets (need to be send in the correct order
dwOperationFlags |= SSOF_BEGIN_OPERATION | SSOF_END_OPERATION;
pDoubleObject = &doubleObject;
}
- if (bResetHash || !pHash)
- {
- cookie_servlist_action* ack;
- DWORD dwCookie;
-
+ if (bResetHash || !pHash) {
// Do we have a known server avatar ID?
- if (wAvatarID = getWord(DBSETTING_SERVLIST_AVATAR, 0))
- {
- ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
- if (!ack)
- {
+ if (wAvatarID = getWord(DBSETTING_SERVLIST_AVATAR, 0)) {
+ cookie_servlist_action *ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
+ if (!ack) {
debugLogA("Cookie alloc failure.");
return; // out of memory, go away
}
ack->dwAction = SSA_REMOVEAVATAR; // update avatar hash
ack->wContactId = wAvatarID;
- dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_REMOVEFROMLIST, 0, ack); // take cookie
-
+ DWORD dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_REMOVEFROMLIST, 0, ack); // take cookie
icq_sendServerItem(dwCookie, ICQ_LISTS_REMOVEFROMLIST, 0, wAvatarID, szItemName, NULL, 0, SSI_ITEM_BUDDYICON, SSOP_ITEM_ACTION | dwOperationFlags, 400, pDoubleObject);
}
}
- if (pHash)
- {
- cookie_servlist_action* ack;
- DWORD dwCookie;
- WORD wTLVlen;
- icq_packet pBuffer;
- WORD hashsize = size - 2;
+ if (!pHash)
+ return;
- // Do we have a known server avatar ID? We should, unless we just subscribed to the serv-list for the first time
- if (bResetHash || (wAvatarID = getWord(DBSETTING_SERVLIST_AVATAR, 0)) == 0)
- {
- // No, create a new random ID
- wAvatarID = GenerateServerID(SSIT_ITEM, 0);
- wCommand = ICQ_LISTS_ADDTOLIST;
+ WORD hashsize = size - 2;
+
+ // Do we have a known server avatar ID? We should, unless we just subscribed to the serv-list for the first time
+ if (bResetHash || (wAvatarID = getWord(DBSETTING_SERVLIST_AVATAR, 0)) == 0) {
+ // No, create a new random ID
+ wAvatarID = GenerateServerID(SSIT_ITEM, 0);
+ wCommand = ICQ_LISTS_ADDTOLIST;
#ifdef _DEBUG
- debugLogA("Made new srvAvatarID, id is %u", wAvatarID);
+ debugLogA("Made new srvAvatarID, id is %u", wAvatarID);
#endif
- }
- else
- {
+ }
+ else {
#ifdef _DEBUG
- debugLogA("Reused srvAvatarID, id is %u", wAvatarID);
+ debugLogA("Reused srvAvatarID, id is %u", wAvatarID);
#endif
- wCommand = ICQ_LISTS_UPDATEGROUP;
- }
+ wCommand = ICQ_LISTS_UPDATEGROUP;
+ }
- ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
- if (!ack)
- {
- debugLogA("Cookie alloc failure.");
- return; // out of memory, go away
- }
- ack->dwAction = SSA_SETAVATAR; // update avatar hash
- ack->wContactId = wAvatarID;
- dwCookie = AllocateCookie(CKT_SERVERLIST, wCommand, 0, ack); // take cookie
+ cookie_servlist_action *ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
+ if (!ack) {
+ debugLogA("Cookie alloc failure.");
+ return; // out of memory, go away
+ }
+ ack->dwAction = SSA_SETAVATAR; // update avatar hash
+ ack->wContactId = wAvatarID;
+ DWORD dwCookie = AllocateCookie(CKT_SERVERLIST, wCommand, 0, ack); // take cookie
- szItemName[0] = 0x30 + pHash[1];
+ szItemName[0] = 0x30 + pHash[1];
- // Build the packet
- wTLVlen = 8 + hashsize;
+ // Build the packet
+ WORD wTLVlen = 8 + hashsize;
- // Initialize our handy data buffer
- pBuffer.wPlace = 0;
- pBuffer.pData = (BYTE *)_alloca(wTLVlen);
- pBuffer.wLen = wTLVlen;
+ // Initialize our handy data buffer
+ icq_packet pBuffer;
+ pBuffer.wPlace = 0;
+ pBuffer.pData = (BYTE *)_alloca(wTLVlen);
+ pBuffer.wLen = wTLVlen;
- packTLV(&pBuffer, SSI_TLV_NAME, 0, NULL); // TLV (Name)
- packTLV(&pBuffer, SSI_TLV_AVATARHASH, hashsize, pHash + 2); // TLV (Hash)
+ packTLV(&pBuffer, SSI_TLV_NAME, 0, NULL); // TLV (Name)
+ packTLV(&pBuffer, SSI_TLV_AVATARHASH, hashsize, pHash + 2); // TLV (Hash)
- icq_sendServerItem(dwCookie, wCommand, 0, wAvatarID, szItemName, pBuffer.pData, wTLVlen, SSI_ITEM_BUDDYICON, SSOP_ITEM_ACTION | dwOperationFlags, 400, pDoubleObject);
- // There is no need to send ICQ_LISTS_CLI_MODIFYSTART or
- // ICQ_LISTS_CLI_MODIFYEND when modifying the avatar hash
- }
+ icq_sendServerItem(dwCookie, wCommand, 0, wAvatarID, szItemName, pBuffer.pData, wTLVlen, SSI_ITEM_BUDDYICON, SSOP_ITEM_ACTION | dwOperationFlags, 400, pDoubleObject);
+ // There is no need to send ICQ_LISTS_CLI_MODIFYSTART or
+ // ICQ_LISTS_CLI_MODIFYEND when modifying the avatar hash
}
// Should be called before the server list is modified. When all
@@ -2002,18 +1968,14 @@ void CIcqProto::updateServAvatarHash(BYTE *pHash, int size) // Called automatically thru server-list update board!
void CIcqProto::icq_sendServerBeginOperation(int bImport)
{
- icq_packet packet;
WORD wImportID = getWord("SrvImportID", 0);
- if (bImport && wImportID)
- { // we should be importing, check if already have import item
- if (getDword("ImportTS", 0) + 604800 < getDword("LogonTS", 0))
- { // is the timestamp week older, clear it and begin new import
+ if (bImport && wImportID) { // we should be importing, check if already have import item
+ if (getDword("ImportTS", 0) + 604800 < getDword("LogonTS", 0)) { // is the timestamp week older, clear it and begin new import
DWORD dwCookie;
cookie_servlist_action* ack;
- if (ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action)))
- { // we have cookie good, go on
+ if (ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action))) { // we have cookie good, go on
ack->dwAction = SSA_IMPORT;
dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_REMOVEFROMLIST, 0, ack);
@@ -2022,9 +1984,11 @@ void CIcqProto::icq_sendServerBeginOperation(int bImport) }
}
- serverPacketInit(&packet, (WORD)(bImport?14:10));
+ icq_packet packet;
+ serverPacketInit(&packet, (WORD)(bImport ? 14 : 10));
packFNACHeader(&packet, ICQ_LISTS_FAMILY, ICQ_LISTS_CLI_MODIFYSTART);
- if (bImport) packDWord(&packet, 1<<0x10);
+ if (bImport)
+ packDWord(&packet, 1 << 0x10);
sendServPacket(&packet);
}
@@ -2034,7 +1998,6 @@ void CIcqProto::icq_sendServerBeginOperation(int bImport) void CIcqProto::icq_sendServerEndOperation()
{
icq_packet packet;
-
serverPacketInit(&packet, 10);
packFNACHeader(&packet, ICQ_LISTS_FAMILY, ICQ_LISTS_CLI_MODIFYEND);
sendServPacket(&packet);
@@ -2044,7 +2007,6 @@ void CIcqProto::icq_sendServerEndOperation() void CIcqProto::sendRosterAck(void)
{
icq_packet packet;
-
serverPacketInit(&packet, 10);
packFNACHeader(&packet, ICQ_LISTS_FAMILY, ICQ_LISTS_GOTLIST);
sendServPacket(&packet);
diff --git a/protocols/IcqOscarJ/src/fam_15icqserver.cpp b/protocols/IcqOscarJ/src/fam_15icqserver.cpp index b80ef50ee2..49de606e3c 100644 --- a/protocols/IcqOscarJ/src/fam_15icqserver.cpp +++ b/protocols/IcqOscarJ/src/fam_15icqserver.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
diff --git a/protocols/IcqOscarJ/src/families.h b/protocols/IcqOscarJ/src/families.h index 61ac38f17a..8fdb89b451 100644 --- a/protocols/IcqOscarJ/src/families.h +++ b/protocols/IcqOscarJ/src/families.h @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,17 +21,15 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Declaration for handlers of Channel 2 SNAC Families
-//
// -----------------------------------------------------------------------------
+
#ifndef __FAMILIES_H
#define __FAMILIES_H
-
struct message_ack_params
{
BYTE bType;
diff --git a/protocols/IcqOscarJ/src/globals.h b/protocols/IcqOscarJ/src/globals.h index 41f1162616..5b56c49569 100644 --- a/protocols/IcqOscarJ/src/globals.h +++ b/protocols/IcqOscarJ/src/globals.h @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
diff --git a/protocols/IcqOscarJ/src/guids.h b/protocols/IcqOscarJ/src/guids.h index 24073deec4..3625b7281e 100644 --- a/protocols/IcqOscarJ/src/guids.h +++ b/protocols/IcqOscarJ/src/guids.h @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,18 +21,15 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Contains helper functions to handle oscar message GUIDs.
-//
// -----------------------------------------------------------------------------
#ifndef __GUIDS_H
#define __GUIDS_H
-
typedef DWORD plugin_guid[4];
// Message Capability GUIDs
diff --git a/protocols/IcqOscarJ/src/i18n.cpp b/protocols/IcqOscarJ/src/i18n.cpp index 535feebcdf..102c695e09 100644 --- a/protocols/IcqOscarJ/src/i18n.cpp +++ b/protocols/IcqOscarJ/src/i18n.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,30 +21,23 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Contains helper functions to convert text messages between different
// character sets.
-//
// -----------------------------------------------------------------------------
-#include "icqoscar.h"
+#include "icqoscar.h"
static BOOL bHasCP_UTF8 = FALSE;
-
void InitI18N(void)
{
CPINFO CPInfo;
-
-
bHasCP_UTF8 = GetCPInfo(CP_UTF8, &CPInfo);
}
-
-
// Returns true if the buffer only contains 7-bit characters.
BOOL __stdcall IsUSASCII(const char *pBuffer, int nSize)
{
diff --git a/protocols/IcqOscarJ/src/i18n.h b/protocols/IcqOscarJ/src/i18n.h index eaeaad54f3..e00719718d 100644 --- a/protocols/IcqOscarJ/src/i18n.h +++ b/protocols/IcqOscarJ/src/i18n.h @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,18 +21,15 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Helper functions to convert text messages between different character sets.
-//
// -----------------------------------------------------------------------------
#ifndef __I18N_H
#define __I18N_H
-
BOOL __stdcall IsUSASCII(const char *pBuffer, int nSize);
BOOL __stdcall IsUnicodeAscii(const WCHAR *pBuffer, int nSize);
int __stdcall UTF8_IsValid(const char *pszInput);
@@ -66,5 +64,4 @@ int __stdcall utf8_decode_static(const char *from, char *to, int to_size); void InitI18N(void);
-
#endif /* __I18N_H */
diff --git a/protocols/IcqOscarJ/src/icq_avatar.cpp b/protocols/IcqOscarJ/src/icq_avatar.cpp index cf4d57fc11..c8ec527825 100644 --- a/protocols/IcqOscarJ/src/icq_avatar.cpp +++ b/protocols/IcqOscarJ/src/icq_avatar.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -22,6 +23,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
// -----------------------------------------------------------------------------
// DESCRIPTION:
+//
// Manages Avatar connection, provides internal service for handling avatars
// -----------------------------------------------------------------------------
@@ -56,8 +58,8 @@ avatars_request* CIcqProto::ReleaseAvatarRequestInQueue(avatars_request *request {
avatars_request *pNext = request->pNext;
avatars_request **par = &m_avatarsQueue;
+
avatars_request *ar = m_avatarsQueue;
-
while (ar) {
if (ar == request) { // found it, remove
*par = ar->pNext;
@@ -95,8 +97,7 @@ void CIcqProto::GetAvatarFileName(int dwUin, const char *szUid, TCHAR *pszDest, TCHAR szPath[MAX_PATH * 2];
mir_sntprintf(szPath, MAX_PATH * 2, _T("%s\\%S\\"), VARST(_T("%miranda_avatarcache%")), m_szModuleName);
- FOLDERSGETDATA fgd = {0};
- fgd.cbSize = sizeof(FOLDERSGETDATA);
+ FOLDERSGETDATA fgd = { sizeof(fgd) };
fgd.nMaxPathSize = MAX_PATH * 2;
fgd.szPathT = szPath;
fgd.flags = FF_TCHAR;
@@ -356,7 +357,7 @@ void CIcqProto::handleAvatarOwnerHash(WORD wItemID, BYTE bFlags, BYTE *pData, BY SetAvatarData(NULL, (WORD)(dwPaFormat == PA_FORMAT_XML ? AVATAR_HASH_FLASH : AVATAR_HASH_STATIC), ppMap, cbFileSize);
if (ppMap != NULL) UnmapViewOfFile(ppMap);
- if (hMap != NULL) CloseHandle(hMap);
+ if (hMap != NULL) CloseHandle(hMap);
if (hFile != NULL) CloseHandle(hFile);
SAFE_FREE((void**)&hash);
}
diff --git a/protocols/IcqOscarJ/src/icq_avatar.h b/protocols/IcqOscarJ/src/icq_avatar.h index 2feda07e75..b67230fb0d 100644 --- a/protocols/IcqOscarJ/src/icq_avatar.h +++ b/protocols/IcqOscarJ/src/icq_avatar.h @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
diff --git a/protocols/IcqOscarJ/src/icq_clients.cpp b/protocols/IcqOscarJ/src/icq_clients.cpp index 198bbd2ade..6b0a046c91 100644 --- a/protocols/IcqOscarJ/src/icq_clients.cpp +++ b/protocols/IcqOscarJ/src/icq_clients.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,13 +21,12 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Provides capability & signature based client detection
-//
// -----------------------------------------------------------------------------
+
#include "icqoscar.h"
const capstr capShortCaps = {0x09, 0x46, 0x00, 0x00, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}; // CAP_AIM_BUDDYICON
diff --git a/protocols/IcqOscarJ/src/icq_constants.h b/protocols/IcqOscarJ/src/icq_constants.h index 64121f0856..d4ef7d72ac 100644 --- a/protocols/IcqOscarJ/src/icq_constants.h +++ b/protocols/IcqOscarJ/src/icq_constants.h @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,12 +21,10 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Global constants and default settings are defined here
-//
// -----------------------------------------------------------------------------
// Most of the protocol constants follow the naming conventions of the
// Oscar documentation at http://iserverd.khstu.ru/oscar/index.html
@@ -35,7 +34,6 @@ #ifndef __ICQ_CONSTANTS_H
#define __ICQ_CONSTANTS_H
-
/* Static icon indexes */
#define ISI_AUTH_REQUEST 0
#define ISI_AUTH_GRANT 1
diff --git a/protocols/IcqOscarJ/src/icq_db.cpp b/protocols/IcqOscarJ/src/icq_db.cpp index 25250c66fb..35fabbe38c 100644 --- a/protocols/IcqOscarJ/src/icq_db.cpp +++ b/protocols/IcqOscarJ/src/icq_db.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,13 +21,12 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Internal Database API
-//
// -----------------------------------------------------------------------------
+
#include "icqoscar.h"
int CIcqProto::getSetting(MCONTACT hContact, const char *szSetting, DBVARIANT *dbv)
diff --git a/protocols/IcqOscarJ/src/icq_direct.cpp b/protocols/IcqOscarJ/src/icq_direct.cpp index 0ffde9a01c..2e5666973c 100644 --- a/protocols/IcqOscarJ/src/icq_direct.cpp +++ b/protocols/IcqOscarJ/src/icq_direct.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
diff --git a/protocols/IcqOscarJ/src/icq_directmsg.cpp b/protocols/IcqOscarJ/src/icq_directmsg.cpp index 81a2f99149..a85d355c0d 100644 --- a/protocols/IcqOscarJ/src/icq_directmsg.cpp +++ b/protocols/IcqOscarJ/src/icq_directmsg.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
diff --git a/protocols/IcqOscarJ/src/icq_fieldnames.cpp b/protocols/IcqOscarJ/src/icq_fieldnames.cpp index f9fae667cc..d5f80a5732 100644 --- a/protocols/IcqOscarJ/src/icq_fieldnames.cpp +++ b/protocols/IcqOscarJ/src/icq_fieldnames.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2009 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -471,7 +472,6 @@ const FieldNamesItem industryField[] = { 0, NULL }
};
-
const FieldNamesItem occupationField[] =
{
{ 1, LPGEN("Academic") },
@@ -505,7 +505,6 @@ const FieldNamesItem occupationField[] = { 0, NULL }
};
-
const FieldNamesItem affiliationField[] =
{
{ 200, LPGEN("Alumni Org.") },
@@ -531,7 +530,6 @@ const FieldNamesItem affiliationField[] = { 0, NULL }
};
-
const FieldNamesItem agesField[] =
{
{ 0x0011000D, LPGEN("13-17") },
@@ -544,7 +542,6 @@ const FieldNamesItem agesField[] = { -1, NULL }
};
-
const FieldNamesItem maritalField[] =
{
{ 10, LPGEN("Single") },
@@ -559,33 +556,20 @@ const FieldNamesItem maritalField[] = { 0, NULL }
};
-
-char *LookupFieldName(const FieldNamesItem *table, int code)
+char* LookupFieldName(const FieldNamesItem *table, int code)
{
- int i;
-
if (code != 0)
- {
- for(i = 0; table[i].text; i++)
- {
+ for (int i = 0; table[i].text; i++)
if (table[i].code == code)
return table[i].text;
- }
-
- // Tried to get unexisting field name, you have an
- // error in the data or in the table
- _ASSERT(FALSE);
- }
return NULL;
}
-
-char *LookupFieldNameUtf(const FieldNamesItem *table, int code, char *str, size_t strsize)
+char* LookupFieldNameUtf(const FieldNamesItem *table, int code, char *str, size_t strsize)
{
- char *szText = LookupFieldName(table, code);
-
- if (szText)
+ char *szText = LookupFieldName(table, code);
+ if (szText)
return ICQTranslateUtfStatic(szText, str, strsize);
return NULL;
diff --git a/protocols/IcqOscarJ/src/icq_http.cpp b/protocols/IcqOscarJ/src/icq_http.cpp index 6e9fedf896..d5926b902a 100644 --- a/protocols/IcqOscarJ/src/icq_http.cpp +++ b/protocols/IcqOscarJ/src/icq_http.cpp @@ -6,6 +6,7 @@ // Copyright © 2001,2002 Jon Keating, Richard Hughes
// Copyright © 2002,2003,2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004,2005,2006 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,13 +21,12 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// HTTP Gateway Handling routines
-//
// -----------------------------------------------------------------------------
+
#include "icqoscar.h"
int icq_httpGatewayInit(HANDLE hConn, NETLIBOPENCONNECTION *nloc, NETLIBHTTPREQUEST *nlhr)
diff --git a/protocols/IcqOscarJ/src/icq_infoupdate.cpp b/protocols/IcqOscarJ/src/icq_infoupdate.cpp index 501adb6cc3..e50a6fa6ce 100644 --- a/protocols/IcqOscarJ/src/icq_infoupdate.cpp +++ b/protocols/IcqOscarJ/src/icq_infoupdate.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,12 +21,10 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Background thread for automatic update of user details
-//
// -----------------------------------------------------------------------------
#include "icqoscar.h"
diff --git a/protocols/IcqOscarJ/src/icq_menu.cpp b/protocols/IcqOscarJ/src/icq_menu.cpp index 473629a4d3..d083e282a7 100644 --- a/protocols/IcqOscarJ/src/icq_menu.cpp +++ b/protocols/IcqOscarJ/src/icq_menu.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2008 Joe Kucera, Bio
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,11 +21,8 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//
-// -----------------------------------------------------------------------------
-// DESCRIPTION:
-//
// -----------------------------------------------------------------------------
+
#include "icqoscar.h"
#include <m_skin.h>
diff --git a/protocols/IcqOscarJ/src/icq_opts.cpp b/protocols/IcqOscarJ/src/icq_opts.cpp index 54fd540b7d..9d64470802 100644 --- a/protocols/IcqOscarJ/src/icq_opts.cpp +++ b/protocols/IcqOscarJ/src/icq_opts.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
diff --git a/protocols/IcqOscarJ/src/icq_popups.cpp b/protocols/IcqOscarJ/src/icq_popups.cpp index b34a8b780a..bce4e032af 100644 --- a/protocols/IcqOscarJ/src/icq_popups.cpp +++ b/protocols/IcqOscarJ/src/icq_popups.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2008 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,13 +21,12 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Popup Plugin stuff
-//
// -----------------------------------------------------------------------------
+
#include "icqoscar.h"
extern BOOL bPopupService;
diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp index 6b870cfb76..4f5e5c3b49 100644 --- a/protocols/IcqOscarJ/src/icq_proto.cpp +++ b/protocols/IcqOscarJ/src/icq_proto.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera, George Hazan
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,13 +21,12 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Protocol Interface Implementation
-//
// -----------------------------------------------------------------------------
+
#include "icqoscar.h"
#include "m_icolib.h"
@@ -76,6 +76,7 @@ CIcqProto::CIcqProto(const char* aProtoName, const TCHAR* aUserName) : directConns(10, CompareConns),
expectedFileRecvs(10, CompareFT),
contactsCache(10, CompareContactsCache),
+ CustomCapList(1),
cheekySearchId(-1)
{
debugLogA("Setting protocol/module name to '%s'", m_szModuleName);
@@ -210,7 +211,6 @@ CIcqProto::CIcqProto(const char* aProtoName, const TCHAR* aUserName) : debugLogA("%s: Protocol instance '%s' created.", ICQ_PROTOCOL_NAME, m_szModuleName);
}
-
CIcqProto::~CIcqProto()
{
m_bXStatusEnabled = 10; // block clist changing
@@ -238,8 +238,6 @@ CIcqProto::~CIcqProto() // Clean-up remaining protocol instance members
UninitContactsCache();
- CustomCapList.clear();
-
SAFE_DELETE(&m_ratesMutex);
SAFE_DELETE(&servlistMutex);
diff --git a/protocols/IcqOscarJ/src/icq_proto.h b/protocols/IcqOscarJ/src/icq_proto.h index 5c8a254f31..82d10ebc20 100644 --- a/protocols/IcqOscarJ/src/icq_proto.h +++ b/protocols/IcqOscarJ/src/icq_proto.h @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera, George Hazan
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,13 +21,12 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Protocol Interface declarations
-//
// -----------------------------------------------------------------------------
+
#ifndef _ICQ_PROTO_H_
#define _ICQ_PROTO_H_
@@ -767,7 +767,7 @@ struct CIcqProto : public PROTO<CIcqProto> INT_PTR __cdecl IcqAddCapability(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl IcqCheckCapability(WPARAM wParam, LPARAM lParam);
- std::list<ICQ_CUSTOMCAP*> CustomCapList;
+ OBJLIST<ICQ_CUSTOMCAP> CustomCapList;
//----| icq_uploadui.cpp |------------------------------------------------------------
void ShowUploadContactsDialog(void);
diff --git a/protocols/IcqOscarJ/src/icq_rates.cpp b/protocols/IcqOscarJ/src/icq_rates.cpp index 043e0dc173..fb8962f4e0 100644 --- a/protocols/IcqOscarJ/src/icq_rates.cpp +++ b/protocols/IcqOscarJ/src/icq_rates.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,13 +21,12 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Rate Management stuff
-//
// -----------------------------------------------------------------------------
+
#include "icqoscar.h"
//
diff --git a/protocols/IcqOscarJ/src/icq_rates.h b/protocols/IcqOscarJ/src/icq_rates.h index 60c7ad6769..b314b9f803 100644 --- a/protocols/IcqOscarJ/src/icq_rates.h +++ b/protocols/IcqOscarJ/src/icq_rates.h @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,13 +21,12 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Rate management
-//
// -----------------------------------------------------------------------------
+
#ifndef __ICQ_RATES_H
#define __ICQ_RATES_H
diff --git a/protocols/IcqOscarJ/src/icq_server.cpp b/protocols/IcqOscarJ/src/icq_server.cpp index dead1a431e..be134164ff 100644 --- a/protocols/IcqOscarJ/src/icq_server.cpp +++ b/protocols/IcqOscarJ/src/icq_server.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,12 +21,10 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Manages main server connection, low-level communication
-//
// -----------------------------------------------------------------------------
#include "icqoscar.h"
diff --git a/protocols/IcqOscarJ/src/icq_servlist.cpp b/protocols/IcqOscarJ/src/icq_servlist.cpp index 8b7e3aa0cb..af0bd9a158 100644 --- a/protocols/IcqOscarJ/src/icq_servlist.cpp +++ b/protocols/IcqOscarJ/src/icq_servlist.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,15 +21,13 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Functions that handles list of used server IDs, sends low-level packets for SSI information
-//
// -----------------------------------------------------------------------------
-#include "icqoscar.h"
+#include "icqoscar.h"
// SERVER-LIST UPDATE BOARD
//
diff --git a/protocols/IcqOscarJ/src/icq_servlist.h b/protocols/IcqOscarJ/src/icq_servlist.h index ef36e485fb..e94472ba1e 100644 --- a/protocols/IcqOscarJ/src/icq_servlist.h +++ b/protocols/IcqOscarJ/src/icq_servlist.h @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
diff --git a/protocols/IcqOscarJ/src/icq_uploadui.cpp b/protocols/IcqOscarJ/src/icq_uploadui.cpp index 0301b11914..9947e794a0 100644 --- a/protocols/IcqOscarJ/src/icq_uploadui.cpp +++ b/protocols/IcqOscarJ/src/icq_uploadui.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2008 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,13 +21,12 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Implements Manage Server List dialog
-//
// -----------------------------------------------------------------------------
+
#include "icqoscar.h"
static int bListInit = 0;
diff --git a/protocols/IcqOscarJ/src/icq_xstatus.cpp b/protocols/IcqOscarJ/src/icq_xstatus.cpp index e797ebc6df..b60eb7cd60 100644 --- a/protocols/IcqOscarJ/src/icq_xstatus.cpp +++ b/protocols/IcqOscarJ/src/icq_xstatus.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Angeli-Ka, Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,12 +21,10 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Support for Custom Statuses
-//
// -----------------------------------------------------------------------------
#include "icqoscar.h"
diff --git a/protocols/IcqOscarJ/src/icq_xtraz.cpp b/protocols/IcqOscarJ/src/icq_xtraz.cpp index ff4d2a543f..a210a58037 100644 --- a/protocols/IcqOscarJ/src/icq_xtraz.cpp +++ b/protocols/IcqOscarJ/src/icq_xtraz.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,12 +21,10 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Internal Xtraz API
-//
// -----------------------------------------------------------------------------
#include "icqoscar.h"
diff --git a/protocols/IcqOscarJ/src/icqosc_svcs.cpp b/protocols/IcqOscarJ/src/icqosc_svcs.cpp index df568a5b30..1d6069dd13 100644 --- a/protocols/IcqOscarJ/src/icqosc_svcs.cpp +++ b/protocols/IcqOscarJ/src/icqosc_svcs.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,26 +21,23 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// High-level code for exported API services
-//
// -----------------------------------------------------------------------------
-#include "icqoscar.h"
+#include "icqoscar.h"
INT_PTR CIcqProto::AddServerContact(WPARAM wParam, LPARAM lParam)
{
- DWORD dwUin;
- uid_str szUid;
-
if (!m_bSsiEnabled) return 0;
// Does this contact have a UID?
- if (!getContactUid(wParam, &dwUin, &szUid) && !getWord(wParam, DBSETTING_SERVLIST_ID, 0) && !getWord(wParam, DBSETTING_SERVLIST_IGNORE, 0))
- { /// TODO: remove possible 0x6A TLV in contact server-list data!!!
+ DWORD dwUin;
+ uid_str szUid;
+ if (!getContactUid(wParam, &dwUin, &szUid) && !getWord(wParam, DBSETTING_SERVLIST_ID, 0) && !getWord(wParam, DBSETTING_SERVLIST_IGNORE, 0)) {
+ /// TODO: remove possible 0x6A TLV in contact server-list data!!!
// Read group from DB
char *pszGroup = getContactCListGroup(wParam);
@@ -49,36 +47,27 @@ INT_PTR CIcqProto::AddServerContact(WPARAM wParam, LPARAM lParam) return 0;
}
-
static int LookupDatabaseSetting(const FieldNamesItem* table, int code, DBVARIANT *dbv, BYTE type)
{
char *text = LookupFieldName(table, code);
-
- if (!text)
- {
+ if (!text) {
dbv->type = DBVT_DELETED;
return 1;
}
- if (type == DBVT_ASCIIZ)
- {
+ if (type == DBVT_ASCIIZ) {
dbv->pszVal = mir_strdup(Translate(text));
dbv->type = DBVT_ASCIIZ;
}
- else if (type == DBVT_UTF8 || !type)
- {
+ else if (type == DBVT_UTF8 || !type) {
char tmp[MAX_PATH];
-
dbv->pszVal = mir_strdup(ICQTranslateUtfStatic(text, tmp, MAX_PATH));
dbv->type = DBVT_UTF8;
}
- else if (type == DBVT_WCHAR)
- {
+ else if (type == DBVT_WCHAR) {
WCHAR* wtext = make_unicode_string(text);
-
dbv->pwszVal = mir_wstrdup(TranslateW(wtext));
dbv->type = DBVT_WCHAR;
-
SAFE_FREE((void**)&wtext);
}
return 0; // Success
@@ -91,7 +80,7 @@ INT_PTR CIcqProto::GetInfoSetting(WPARAM hContact, LPARAM lParam) INT_PTR rc = db_get_s(hContact, cgs->szModule, cgs->szSetting, cgs->pValue, 0);
if (rc)
return rc;
-
+
// Success
DBVARIANT dbv = *cgs->pValue;
if (dbv.type == DBVT_BLOB) {
@@ -162,176 +151,147 @@ INT_PTR CIcqProto::GetInfoSetting(WPARAM hContact, LPARAM lParam) return rc;
}
-
INT_PTR CIcqProto::ChangeInfoEx(WPARAM wParam, LPARAM lParam)
{
- if (icqOnline() && wParam)
- {
- PBYTE buf = NULL;
- int buflen = 0;
- BYTE b;
-
- // userinfo
- ppackTLVWord(&buf, &buflen, 0x1C2, (WORD)GetACP());
-
- if (wParam & CIXT_CONTACT)
- { // contact information
- BYTE *pBlock = NULL;
- int cbBlock = 0;
- int nItems = 0;
-
- // Emails
- nItems += ppackTLVWordStringItemFromDB(&pBlock, &cbBlock, "e-mail0", 0x78, 0x64, 0x00);
- nItems += ppackTLVWordStringItemFromDB(&pBlock, &cbBlock, "e-mail1", 0x78, 0x64, 0x00);
- nItems += ppackTLVWordStringItemFromDB(&pBlock, &cbBlock, "e-mail2", 0x78, 0x64, 0x00);
- ppackTLVBlockItems(&buf, &buflen, 0x8C, &nItems, &pBlock, (WORD*)&cbBlock, FALSE);
-
- // Phones
- nItems += ppackTLVWordStringItemFromDB(&pBlock, &cbBlock, "Phone", 0x6E, 0x64, 0x01);
- nItems += ppackTLVWordStringItemFromDB(&pBlock, &cbBlock, "CompanyPhone", 0x6E, 0x64, 0x02);
- nItems += ppackTLVWordStringItemFromDB(&pBlock, &cbBlock, "Cellular", 0x6E, 0x64, 0x03);
- nItems += ppackTLVWordStringItemFromDB(&pBlock, &cbBlock, "Fax", 0x6E, 0x64, 0x04);
- nItems += ppackTLVWordStringItemFromDB(&pBlock, &cbBlock, "CompanyFax", 0x6E, 0x64, 0x05);
- ppackTLVBlockItems(&buf, &buflen, 0xC8, &nItems, &pBlock, (WORD*)&cbBlock, FALSE);
-
- ppackTLVByte(&buf, &buflen, 0x1EA, getByte("AllowSpam", 0));
- }
+ if (!icqOnline() || !wParam)
+ return 0;
- if (wParam & CIXT_BASIC)
- { // upload basic user info
- ppackTLVStringUtfFromDB(&buf, &buflen, "Nick", 0x78);
- ppackTLVStringUtfFromDB(&buf, &buflen, "FirstName", 0x64);
- ppackTLVStringUtfFromDB(&buf, &buflen, "LastName", 0x6E);
- ppackTLVStringUtfFromDB(&buf, &buflen, "About", 0x186);
- }
+ PBYTE buf = NULL;
+ int buflen = 0;
+ BYTE b;
+
+ // userinfo
+ ppackTLVWord(&buf, &buflen, 0x1C2, (WORD)GetACP());
+
+ if (wParam & CIXT_CONTACT) { // contact information
+ BYTE *pBlock = NULL;
+ int cbBlock = 0;
+ int nItems = 0;
+
+ // Emails
+ nItems += ppackTLVWordStringItemFromDB(&pBlock, &cbBlock, "e-mail0", 0x78, 0x64, 0x00);
+ nItems += ppackTLVWordStringItemFromDB(&pBlock, &cbBlock, "e-mail1", 0x78, 0x64, 0x00);
+ nItems += ppackTLVWordStringItemFromDB(&pBlock, &cbBlock, "e-mail2", 0x78, 0x64, 0x00);
+ ppackTLVBlockItems(&buf, &buflen, 0x8C, &nItems, &pBlock, (WORD*)&cbBlock, FALSE);
+
+ // Phones
+ nItems += ppackTLVWordStringItemFromDB(&pBlock, &cbBlock, "Phone", 0x6E, 0x64, 0x01);
+ nItems += ppackTLVWordStringItemFromDB(&pBlock, &cbBlock, "CompanyPhone", 0x6E, 0x64, 0x02);
+ nItems += ppackTLVWordStringItemFromDB(&pBlock, &cbBlock, "Cellular", 0x6E, 0x64, 0x03);
+ nItems += ppackTLVWordStringItemFromDB(&pBlock, &cbBlock, "Fax", 0x6E, 0x64, 0x04);
+ nItems += ppackTLVWordStringItemFromDB(&pBlock, &cbBlock, "CompanyFax", 0x6E, 0x64, 0x05);
+ ppackTLVBlockItems(&buf, &buflen, 0xC8, &nItems, &pBlock, (WORD*)&cbBlock, FALSE);
+
+ ppackTLVByte(&buf, &buflen, 0x1EA, getByte("AllowSpam", 0));
+ }
- if (wParam & CIXT_MORE)
- {
- b = getByte("Gender", 0);
- ppackTLVByte(&buf, &buflen, 0x82, (BYTE)(b ? (b == 'M' ? 2 : 1) : 0));
+ if (wParam & CIXT_BASIC) { // upload basic user info
+ ppackTLVStringUtfFromDB(&buf, &buflen, "Nick", 0x78);
+ ppackTLVStringUtfFromDB(&buf, &buflen, "FirstName", 0x64);
+ ppackTLVStringUtfFromDB(&buf, &buflen, "LastName", 0x6E);
+ ppackTLVStringUtfFromDB(&buf, &buflen, "About", 0x186);
+ }
- ppackTLVDateFromDB(&buf, &buflen, "BirthYear", "BirthMonth", "BirthDay", 0x1A4);
+ if (wParam & CIXT_MORE) {
+ b = getByte("Gender", 0);
+ ppackTLVByte(&buf, &buflen, 0x82, (BYTE)(b ? (b == 'M' ? 2 : 1) : 0));
- ppackTLVWord(&buf, &buflen, 0xAA, getByte("Language1", 0));
- ppackTLVWord(&buf, &buflen, 0xB4, getByte("Language2", 0));
- ppackTLVWord(&buf, &buflen, 0xBE, getByte("Language3", 0));
+ ppackTLVDateFromDB(&buf, &buflen, "BirthYear", "BirthMonth", "BirthDay", 0x1A4);
- ppackTLVWord(&buf, &buflen, 0x12C, getByte("MaritalStatus", 0));
- }
+ ppackTLVWord(&buf, &buflen, 0xAA, getByte("Language1", 0));
+ ppackTLVWord(&buf, &buflen, 0xB4, getByte("Language2", 0));
+ ppackTLVWord(&buf, &buflen, 0xBE, getByte("Language3", 0));
- if (wParam & CIXT_WORK)
- {
- BYTE *pBlock = NULL;
- int cbBlock = 0;
- int nItems = 1;
-
- // Jobs
- ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "CompanyPosition", 0x64);
- ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "Company", 0x6E);
- ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "CompanyDepartment", 0x7D);
- ppackTLVStringFromDB(&pBlock, &cbBlock, "CompanyHomepage", 0x78);
- ppackTLVWord(&pBlock, &cbBlock, 0x82, getWord("CompanyIndustry", 0));
- ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "CompanyStreet", 0xAA);
- ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "CompanyCity", 0xB4);
- ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "CompanyState", 0xBE);
- ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "CompanyZIP", 0xC8);
- ppackTLVDWord(&pBlock, &cbBlock, 0xD2, getWord("CompanyCountry", 0));
- /// TODO: pack unknown data (need to preserve them in Block Items)
- ppackTLVBlockItems(&buf, &buflen, 0x118, &nItems, &pBlock, (WORD*)&cbBlock, TRUE);
-
- // ppackTLVWord(&buf, &buflen, getWord("CompanyOccupation", 0), TLV_OCUPATION, 1); // Lost In Conversion
- }
+ ppackTLVWord(&buf, &buflen, 0x12C, getByte("MaritalStatus", 0));
+ }
- if (wParam & CIXT_EDUCATION)
- {
- BYTE *pBlock = NULL;
- int cbBlock = 0;
- int nItems = 1;
-
- // Studies
- ppackTLVWord(&pBlock, &cbBlock, 0x64, getWord("StudyLevel", 0));
- ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "StudyInstitute", 0x6E);
- ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "StudyDegree", 0x78);
- ppackTLVWord(&pBlock, &cbBlock, 0x8C, getWord("StudyYear", 0));
- ppackTLVBlockItems(&buf, &buflen, 0x10E, &nItems, &pBlock, (WORD*)&cbBlock, TRUE);
- }
+ if (wParam & CIXT_WORK) {
+ BYTE *pBlock = NULL;
+ int cbBlock = 0;
+ int nItems = 1;
+
+ // Jobs
+ ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "CompanyPosition", 0x64);
+ ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "Company", 0x6E);
+ ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "CompanyDepartment", 0x7D);
+ ppackTLVStringFromDB(&pBlock, &cbBlock, "CompanyHomepage", 0x78);
+ ppackTLVWord(&pBlock, &cbBlock, 0x82, getWord("CompanyIndustry", 0));
+ ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "CompanyStreet", 0xAA);
+ ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "CompanyCity", 0xB4);
+ ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "CompanyState", 0xBE);
+ ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "CompanyZIP", 0xC8);
+ ppackTLVDWord(&pBlock, &cbBlock, 0xD2, getWord("CompanyCountry", 0));
+ /// TODO: pack unknown data (need to preserve them in Block Items)
+ ppackTLVBlockItems(&buf, &buflen, 0x118, &nItems, &pBlock, (WORD*)&cbBlock, TRUE);
+
+ // ppackTLVWord(&buf, &buflen, getWord("CompanyOccupation", 0), TLV_OCUPATION, 1); // Lost In Conversion
+ }
- if (wParam & CIXT_LOCATION)
- {
- BYTE *pBlock = NULL;
- int cbBlock = 0;
- int nItems = 1;
-
- // Home Address
- ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "Street", 0x64);
- ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "City", 0x6E);
- ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "State", 0x78);
- ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "ZIP", 0x82);
- ppackTLVDWord(&pBlock, &cbBlock, 0x8C, getWord("Country", 0));
- ppackTLVBlockItems(&buf, &buflen, 0x96, &nItems, &pBlock, (WORD*)&cbBlock, TRUE);
-
- nItems = 1;
- // Origin Address
- ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "OriginStreet", 0x64);
- ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "OriginCity", 0x6E);
- ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "OriginState", 0x78);
- ppackTLVDWord(&pBlock, &cbBlock, 0x8C, getWord("OriginCountry", 0));
- ppackTLVBlockItems(&buf, &buflen, 0xA0, &nItems, &pBlock, (WORD*)&cbBlock, TRUE);
-
- ppackTLVStringFromDB(&buf, &buflen, "Homepage", 0xFA);
-
- // Timezone
- WORD wTimezone = getByte("Timezone", 0);
- if ((wTimezone & 0x0080) == 0x80) wTimezone |= 0xFF00; // extend signed number
- ppackTLVWord(&buf, &buflen, 0x17C, wTimezone);
- }
+ if (wParam & CIXT_EDUCATION) {
+ BYTE *pBlock = NULL;
+ int cbBlock = 0;
+ int nItems = 1;
+
+ // Studies
+ ppackTLVWord(&pBlock, &cbBlock, 0x64, getWord("StudyLevel", 0));
+ ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "StudyInstitute", 0x6E);
+ ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "StudyDegree", 0x78);
+ ppackTLVWord(&pBlock, &cbBlock, 0x8C, getWord("StudyYear", 0));
+ ppackTLVBlockItems(&buf, &buflen, 0x10E, &nItems, &pBlock, (WORD*)&cbBlock, TRUE);
+ }
- if (wParam & CIXT_BACKGROUND)
- {
- BYTE *pBlock = NULL;
- int cbBlock = 0;
- int nItems = 0;
-
- // Interests
- nItems += ppackTLVWordStringUtfItemFromDB(&pBlock, &cbBlock, "Interest0Text", 0x6E, 0x64, getWord("Interest0Cat", 0));
- nItems += ppackTLVWordStringUtfItemFromDB(&pBlock, &cbBlock, "Interest1Text", 0x6E, 0x64, getWord("Interest1Cat", 0));
- nItems += ppackTLVWordStringUtfItemFromDB(&pBlock, &cbBlock, "Interest2Text", 0x6E, 0x64, getWord("Interest2Cat", 0));
- nItems += ppackTLVWordStringUtfItemFromDB(&pBlock, &cbBlock, "Interest3Text", 0x6E, 0x64, getWord("Interest3Cat", 0));
- ppackTLVBlockItems(&buf, &buflen, 0x122, &nItems, &pBlock, (WORD*)&cbBlock, FALSE);
-
-
- /* WORD w; /// not supported anymore
-
- w = StringToListItemId("Past0", 0);
- ppackTLVWordLNTSfromDB(&buf, &buflen, w, "Past0Text", TLV_PASTINFO);
- w = StringToListItemId("Past1", 0);
- ppackTLVWordLNTSfromDB(&buf, &buflen, w, "Past1Text", TLV_PASTINFO);
- w = StringToListItemId("Past2", 0);
- ppackTLVWordLNTSfromDB(&buf, &buflen, w, "Past2Text", TLV_PASTINFO);
-
- w = StringToListItemId("Affiliation0", 0);
- ppackTLVWordLNTSfromDB(&buf, &buflen, w, "Affiliation0Text", TLV_AFFILATIONS);
- w = StringToListItemId("Affiliation1", 0);
- ppackTLVWordLNTSfromDB(&buf, &buflen, w, "Affiliation1Text", TLV_AFFILATIONS);
- w = StringToListItemId("Affiliation2", 0);
- ppackTLVWordLNTSfromDB(&buf, &buflen, w, "Affiliation2Text", TLV_AFFILATIONS);*/
- }
+ if (wParam & CIXT_LOCATION) {
+ BYTE *pBlock = NULL;
+ int cbBlock = 0;
+ int nItems = 1;
+
+ // Home Address
+ ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "Street", 0x64);
+ ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "City", 0x6E);
+ ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "State", 0x78);
+ ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "ZIP", 0x82);
+ ppackTLVDWord(&pBlock, &cbBlock, 0x8C, getWord("Country", 0));
+ ppackTLVBlockItems(&buf, &buflen, 0x96, &nItems, &pBlock, (WORD*)&cbBlock, TRUE);
+
+ nItems = 1;
+ // Origin Address
+ ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "OriginStreet", 0x64);
+ ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "OriginCity", 0x6E);
+ ppackTLVStringUtfFromDB(&pBlock, &cbBlock, "OriginState", 0x78);
+ ppackTLVDWord(&pBlock, &cbBlock, 0x8C, getWord("OriginCountry", 0));
+ ppackTLVBlockItems(&buf, &buflen, 0xA0, &nItems, &pBlock, (WORD*)&cbBlock, TRUE);
+
+ ppackTLVStringFromDB(&buf, &buflen, "Homepage", 0xFA);
+
+ // Timezone
+ WORD wTimezone = getByte("Timezone", 0);
+ if ((wTimezone & 0x0080) == 0x80) wTimezone |= 0xFF00; // extend signed number
+ ppackTLVWord(&buf, &buflen, 0x17C, wTimezone);
+ }
- DWORD dwCookie = icq_changeUserDirectoryInfoServ(buf, (WORD)buflen, DIRECTORYREQUEST_UPDATEOWNER);
+ if (wParam & CIXT_BACKGROUND) {
+ BYTE *pBlock = NULL;
+ int cbBlock = 0;
+ int nItems = 0;
+
+ // Interests
+ nItems += ppackTLVWordStringUtfItemFromDB(&pBlock, &cbBlock, "Interest0Text", 0x6E, 0x64, getWord("Interest0Cat", 0));
+ nItems += ppackTLVWordStringUtfItemFromDB(&pBlock, &cbBlock, "Interest1Text", 0x6E, 0x64, getWord("Interest1Cat", 0));
+ nItems += ppackTLVWordStringUtfItemFromDB(&pBlock, &cbBlock, "Interest2Text", 0x6E, 0x64, getWord("Interest2Cat", 0));
+ nItems += ppackTLVWordStringUtfItemFromDB(&pBlock, &cbBlock, "Interest3Text", 0x6E, 0x64, getWord("Interest3Cat", 0));
+ ppackTLVBlockItems(&buf, &buflen, 0x122, &nItems, &pBlock, (WORD*)&cbBlock, FALSE);
+ }
- SAFE_FREE((void**)&buf);
+ DWORD dwCookie = icq_changeUserDirectoryInfoServ(buf, (WORD)buflen, DIRECTORYREQUEST_UPDATEOWNER);
- return dwCookie;
- }
+ SAFE_FREE((void**)&buf);
- return 0; // Failure
+ return dwCookie;
}
-
INT_PTR CIcqProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam)
{
- if (wParam == AF_MAXSIZE)
- {
+ if (wParam == AF_MAXSIZE) {
POINT *size = (POINT*)lParam;
if (size) {
size->x = 64;
@@ -367,32 +327,28 @@ INT_PTR CIcqProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam) return 0;
}
-
INT_PTR CIcqProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam)
{
PROTO_AVATAR_INFORMATIONT *pai = (PROTO_AVATAR_INFORMATIONT*)lParam;
DWORD dwUIN;
uid_str szUID;
- DBVARIANT dbv = {DBVT_DELETED};
+ DBVARIANT dbv = { DBVT_DELETED };
if (!m_bAvatarsEnabled) return GAIR_NOAVATAR;
- if (getSetting(pai->hContact, "AvatarHash", &dbv) || dbv.type != DBVT_BLOB || (dbv.cpbVal != 0x14 && dbv.cpbVal != 0x09))
- {
+ if (getSetting(pai->hContact, "AvatarHash", &dbv) || dbv.type != DBVT_BLOB || (dbv.cpbVal != 0x14 && dbv.cpbVal != 0x09)) {
db_free(&dbv);
return GAIR_NOAVATAR; // we did not found avatar hash or hash invalid - no avatar available
}
- if (getContactUid(pai->hContact, &dwUIN, &szUID))
- {
+ if (getContactUid(pai->hContact, &dwUIN, &szUID)) {
db_free(&dbv);
return GAIR_NOAVATAR; // we do not support avatars for invalid contacts
}
int dwPaFormat = getByte(pai->hContact, "AvatarType", PA_FORMAT_UNKNOWN);
- if (dwPaFormat != PA_FORMAT_UNKNOWN)
- { // we know the format, test file
+ if (dwPaFormat != PA_FORMAT_UNKNOWN) { // we know the format, test file
TCHAR tszFile[MAX_PATH * 2 + 4];
GetFullAvatarFileName(dwUIN, szUID, dwPaFormat, tszFile, MAX_PATH * 2);
@@ -400,10 +356,8 @@ INT_PTR CIcqProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) lstrcpyn(pai->filename, tszFile, SIZEOF(pai->filename)); // Avatar API does not support unicode :-(
pai->format = dwPaFormat;
- if (!IsAvatarChanged(pai->hContact, dbv.pbVal, dbv.cpbVal))
- { // hashes are the same
- if (_taccess(tszFile, 0) == 0)
- {
+ if (!IsAvatarChanged(pai->hContact, dbv.pbVal, dbv.cpbVal)) { // hashes are the same
+ if (_taccess(tszFile, 0) == 0) {
db_free(&dbv);
return GAIR_SUCCESS; // we have found the avatar file, whoala
@@ -411,10 +365,8 @@ INT_PTR CIcqProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) }
}
- if (IsAvatarChanged(pai->hContact, dbv.pbVal, dbv.cpbVal))
- { // we didn't received the avatar before - this ensures we will not request avatar again and again
- if ((wParam & GAIF_FORCE) != 0 && pai->hContact != 0)
- { // request avatar data
+ if (IsAvatarChanged(pai->hContact, dbv.pbVal, dbv.cpbVal)) { // we didn't received the avatar before - this ensures we will not request avatar again and again
+ if ((wParam & GAIF_FORCE) != 0 && pai->hContact != 0) { // request avatar data
TCHAR tszFile[MAX_PATH * 2 + 4];
GetAvatarFileName(dwUIN, szUID, tszFile, MAX_PATH * 2);
@@ -439,8 +391,7 @@ INT_PTR CIcqProto::GetMyAvatar(WPARAM wParam, LPARAM lParam) if (!wParam) return -3;
TCHAR *tszFile = GetOwnAvatarFileName();
- if (tszFile && !_taccess(tszFile, 0))
- {
+ if (tszFile && !_taccess(tszFile, 0)) {
_tcsncpy((TCHAR*)wParam, tszFile, (int)lParam);
SAFE_FREE(&tszFile);
return 0;
@@ -453,11 +404,9 @@ INT_PTR CIcqProto::GetMyAvatar(WPARAM wParam, LPARAM lParam) INT_PTR CIcqProto::GrantAuthorization(WPARAM wParam, LPARAM lParam)
{
- if (icqOnline() && wParam != 0)
- {
+ if (icqOnline() && wParam != 0) {
DWORD dwUin;
uid_str szUid;
-
if (getContactUid(wParam, &dwUin, &szUid))
return 0; // Invalid contact
@@ -472,10 +421,10 @@ INT_PTR CIcqProto::GrantAuthorization(WPARAM wParam, LPARAM lParam) int CIcqProto::OnIdleChanged(WPARAM wParam, LPARAM lParam)
{
- int bIdle = (lParam&IDF_ISIDLE);
- int bPrivacy = (lParam&IDF_PRIVACY);
-
- if (bPrivacy) return 0;
+ int bIdle = (lParam & IDF_ISIDLE);
+ int bPrivacy = (lParam & IDF_PRIVACY);
+ if (bPrivacy)
+ return 0;
setDword("IdleTS", bIdle ? time(0) : 0);
@@ -483,17 +432,14 @@ int CIcqProto::OnIdleChanged(WPARAM wParam, LPARAM lParam) sendEntireListServ(ICQ_BOS_FAMILY, ICQ_CLI_REMOVETEMPVISIBLE, BUL_TEMPVISIBLE);
icq_setidle(bIdle ? 1 : 0);
-
return 0;
}
INT_PTR CIcqProto::RevokeAuthorization(WPARAM wParam, LPARAM lParam)
{
- if (icqOnline() && wParam != 0)
- {
+ if (icqOnline() && wParam != 0) {
DWORD dwUin;
uid_str szUid;
-
if (getContactUid(wParam, &dwUin, &szUid))
return 0; // Invalid contact
@@ -517,11 +463,9 @@ INT_PTR CIcqProto::SendSms(WPARAM wParam, LPARAM lParam) INT_PTR CIcqProto::SendYouWereAdded(WPARAM wParam, LPARAM lParam)
{
- if (lParam && icqOnline())
- {
+ if (lParam && icqOnline()) {
CCSDATA* ccs = (CCSDATA*)lParam;
- if (ccs->hContact)
- {
+ if (ccs->hContact) {
DWORD dwUin, dwMyUin;
if (getContactUid(ccs->hContact, &dwUin, NULL))
@@ -529,8 +473,7 @@ INT_PTR CIcqProto::SendYouWereAdded(WPARAM wParam, LPARAM lParam) dwMyUin = getContactUin(NULL);
- if (dwUin)
- {
+ if (dwUin) {
icq_sendYouWereAddedServ(dwUin, dwMyUin);
return 0; // Success
}
@@ -547,42 +490,36 @@ INT_PTR CIcqProto::SetMyAvatar(WPARAM wParam, LPARAM lParam) if (!m_bAvatarsEnabled || !m_bSsiEnabled) return -2;
- if (tszFile)
- { // set file for avatar
+ if (tszFile) { // set file for avatar
int dwPaFormat = ::ProtoGetAvatarFileFormat(tszFile);
- if (dwPaFormat != PA_FORMAT_XML)
- {
+ if (dwPaFormat != PA_FORMAT_XML) {
// if it should be image, check if it is valid
HBITMAP avt = (HBITMAP)CallService(MS_UTILS_LOADBITMAPT, 0, (WPARAM)tszFile);
if (!avt) return iRet;
DeleteObject(avt);
}
- TCHAR tszMyFile[MAX_PATH+1];
+ TCHAR tszMyFile[MAX_PATH + 1];
GetFullAvatarFileName(0, NULL, dwPaFormat, tszMyFile, MAX_PATH);
// if not in our storage, copy
- if (lstrcmp(tszFile, tszMyFile) && !CopyFile(tszFile, tszMyFile, FALSE))
- {
+ if (lstrcmp(tszFile, tszMyFile) && !CopyFile(tszFile, tszMyFile, FALSE)) {
debugLogA("Failed to copy our avatar to local storage.");
return iRet;
}
BYTE *hash = calcMD5HashOfFile(tszMyFile);
- if (hash)
- {
- BYTE* ihash = (BYTE*)_alloca(0x14);
+ if (hash) {
+ BYTE *ihash = (BYTE*)_alloca(0x14);
// upload hash to server
ihash[0] = 0; //unknown
ihash[1] = dwPaFormat == PA_FORMAT_XML ? AVATAR_HASH_FLASH : AVATAR_HASH_STATIC; //hash type
ihash[2] = 1; //hash status
ihash[3] = 0x10; //hash len
- memcpy(ihash+4, hash, 0x10);
+ memcpy(ihash + 4, hash, 0x10);
updateServAvatarHash(ihash, 0x14);
if (setSettingBlob(NULL, "AvatarHash", ihash, 0x14))
- {
debugLogA("Failed to save avatar hash.");
- }
TCHAR tmp[MAX_PATH];
PathToRelativeT(tszMyFile, tmp);
@@ -593,8 +530,7 @@ INT_PTR CIcqProto::SetMyAvatar(WPARAM wParam, LPARAM lParam) SAFE_FREE((void**)&hash);
}
}
- else
- { // delete user avatar
+ else { // delete user avatar
delSetting("AvatarFile");
setSettingBlob(NULL, "AvatarHash", hashEmptyAvatar, 9);
updateServAvatarHash(hashEmptyAvatar, 9); // set blank avatar
@@ -622,43 +558,36 @@ INT_PTR CIcqProto::SetPassword(WPARAM wParam, LPARAM lParam) char *pwd = (char*)lParam;
int len = strlennull(pwd);
- if (len && len < PASSWORDMAXLEN)
- {
+ if (len && len < PASSWORDMAXLEN) {
strcpy(m_szPassword, pwd);
m_bRememberPwd = TRUE;
}
return 0;
}
-
// TODO: Adding needs some more work in general
MCONTACT CIcqProto::AddToListByUIN(DWORD dwUin, DWORD dwFlags)
{
int bAdded;
MCONTACT hContact = HContactFromUIN(dwUin, &bAdded);
- if (hContact)
- {
- if (!(dwFlags & PALF_TEMPORARY) && db_get_b(hContact, "CList", "NotOnList", 0))
- {
- setContactHidden(hContact, 0);
- db_unset(hContact, "CList", "NotOnList");
- }
+ if (hContact == NULL) // Failure
+ return NULL;
- return hContact; // Success
+ if (!(dwFlags & PALF_TEMPORARY) && db_get_b(hContact, "CList", "NotOnList", 0)) {
+ setContactHidden(hContact, 0);
+ db_unset(hContact, "CList", "NotOnList");
}
-
- return NULL; // Failure
+ return hContact; // Success
}
-
MCONTACT CIcqProto::AddToListByUID(const char *szUID, DWORD dwFlags)
{
int bAdded;
MCONTACT hContact = HContactFromUID(0, szUID, &bAdded);
if (hContact == 0)
return 0; // Failure
-
+
if (!(dwFlags & PALF_TEMPORARY) && db_get_b(hContact, "CList", "NotOnList", 0)) {
setContactHidden(hContact, 0);
db_unset(hContact, "CList", "NotOnList");
@@ -672,22 +601,20 @@ MCONTACT CIcqProto::AddToListByUID(const char *szUID, DWORD dwFlags) void CIcqProto::ICQAddRecvEvent(MCONTACT hContact, WORD wType, PROTORECVEVENT* pre, DWORD cbBlob, PBYTE pBlob, DWORD flags)
{
- if (pre->flags & PREF_CREATEREAD)
+ if (pre->flags & PREF_CREATEREAD)
flags |= DBEF_READ;
- if (pre->flags & PREF_UTF)
+ if (pre->flags & PREF_UTF)
flags |= DBEF_UTF;
- if (hContact && db_get_b(hContact, "CList", "Hidden", 0))
- {
+ if (hContact && db_get_b(hContact, "CList", "Hidden", 0)) {
DWORD dwUin;
uid_str szUid;
//setContactHidden(hContact, 0);
// if the contact was hidden, add to client-list if not in server-list authed
- if (!getWord(hContact, DBSETTING_SERVLIST_ID, 0) || getByte(hContact, "Auth", 0))
- {
+ if (!getWord(hContact, DBSETTING_SERVLIST_ID, 0) || getByte(hContact, "Auth", 0)) {
getContactUid(hContact, &dwUin, &szUid);
icq_sendNewContact(dwUin, szUid); /// FIXME
}
@@ -698,27 +625,26 @@ void CIcqProto::ICQAddRecvEvent(MCONTACT hContact, WORD wType, PROTORECVEVENT* p INT_PTR __cdecl CIcqProto::IcqAddCapability(WPARAM wParam, LPARAM lParam)
{
- ICQ_CUSTOMCAP *icqCustomCapIn = (ICQ_CUSTOMCAP *)lParam;
- ICQ_CUSTOMCAP *icqCustomCap = (ICQ_CUSTOMCAP *)malloc(sizeof(ICQ_CUSTOMCAP));
- memcpy(icqCustomCap, icqCustomCapIn, sizeof(ICQ_CUSTOMCAP));
- CustomCapList.push_back(icqCustomCap);
-// MessageBoxA(NULL, ((ICQ_CUSTOMCAP *)(lstCustomCaps->items[lstCustomCaps->realCount-1]))->name, "custom cap", MB_OK);
+ ICQ_CUSTOMCAP *icqCustomCapIn = (ICQ_CUSTOMCAP*)lParam;
+ ICQ_CUSTOMCAP *icqCustomCap = new ICQ_CUSTOMCAP;
+ memcpy(icqCustomCap, icqCustomCapIn, sizeof(ICQ_CUSTOMCAP));
+ CustomCapList.insert(icqCustomCap);
return 0;
}
INT_PTR __cdecl CIcqProto::IcqCheckCapability(WPARAM hContact, LPARAM lParam)
{
- int res = 0;
- DBVARIANT dbvariant;
- ICQ_CUSTOMCAP *icqCustomCap = (ICQ_CUSTOMCAP *)lParam;
+ int res = 0;
+ DBVARIANT dbvariant;
+ ICQ_CUSTOMCAP *icqCustomCap = (ICQ_CUSTOMCAP *)lParam;
- db_get(hContact, m_szModuleName, "CapBuf", &dbvariant);
- if (dbvariant.type == DBVT_BLOB)
- res = MatchCapability(dbvariant.pbVal, dbvariant.cpbVal, (const capstr*)&icqCustomCap->caps, 0x10)?1:0; // FIXME: Why icqCustomCap->caps is not capstr?
+ db_get(hContact, m_szModuleName, "CapBuf", &dbvariant);
+ if (dbvariant.type == DBVT_BLOB)
+ res = MatchCapability(dbvariant.pbVal, dbvariant.cpbVal, (const capstr*)&icqCustomCap->caps, 0x10) ? 1 : 0; // FIXME: Why icqCustomCap->caps is not capstr?
- db_free(&dbvariant);
- return res;
+ db_free(&dbvariant);
+ return res;
}
@@ -732,10 +658,8 @@ INT_PTR icq_getEventTextMissedMessage(WPARAM wParam, LPARAM lParam) INT_PTR nRetVal = 0;
char *pszText = NULL;
- if (pEvent->dbei->cbBlob > 1)
- {
- switch (((WORD*)pEvent->dbei->pBlob)[0])
- {
+ if (pEvent->dbei->cbBlob > 1) {
+ switch (((WORD*)pEvent->dbei->pBlob)[0]) {
case 0:
pszText = LPGEN("** This message was blocked by the ICQ server ** The message was invalid.");
break;
@@ -756,8 +680,7 @@ INT_PTR icq_getEventTextMissedMessage(WPARAM wParam, LPARAM lParam) pszText = LPGEN("** Unknown missed message event.");
break;
}
- if (pEvent->datatype == DBVT_WCHAR)
- {
+ if (pEvent->datatype == DBVT_WCHAR) {
WCHAR *pwszText;
int wchars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pszText, strlennull(pszText), NULL, 0);
diff --git a/protocols/IcqOscarJ/src/icqoscar.h b/protocols/IcqOscarJ/src/icqoscar.h index 33e9e5cba0..e1168b2428 100644 --- a/protocols/IcqOscarJ/src/icqoscar.h +++ b/protocols/IcqOscarJ/src/icqoscar.h @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,13 +21,12 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Includes all header files that should be precompiled to speed up compilation.
-//
// -----------------------------------------------------------------------------
+
#define _WIN32_WINNT 0x0501
#define _WIN32_IE 0x0501
@@ -40,13 +40,11 @@ #include <sys/types.h>
#include <sys/stat.h>
#include <io.h>
+#include <malloc.h>
#include <direct.h>
#include <fcntl.h>
#include <process.h>
-//C++
-#include <list>
-
#ifndef _DEBUG
#include <crtdbg.h>
#endif
diff --git a/protocols/IcqOscarJ/src/init.cpp b/protocols/IcqOscarJ/src/init.cpp index ff733af7b4..20f3da0c97 100644 --- a/protocols/IcqOscarJ/src/init.cpp +++ b/protocols/IcqOscarJ/src/init.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
diff --git a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp index 5643c5ceae..1e244e0f42 100644 --- a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp +++ b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,13 +21,12 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// OSCAR File-Transfers implementation
-//
// -----------------------------------------------------------------------------
+
#include "icqoscar.h"
struct oscarthreadstartinfo
diff --git a/protocols/IcqOscarJ/src/oscar_filetransfer.h b/protocols/IcqOscarJ/src/oscar_filetransfer.h index 36a7c738de..7ebc76e776 100644 --- a/protocols/IcqOscarJ/src/oscar_filetransfer.h +++ b/protocols/IcqOscarJ/src/oscar_filetransfer.h @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,17 +21,15 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// OSCAR File-Transfers headers
-//
// -----------------------------------------------------------------------------
+
#ifndef __OSCAR_FILETRANSFER_H
#define __OSCAR_FILETRANSFER_H
-
#define FT_MAGIC_ICQ 0x00
#define FT_MAGIC_OSCAR 0x4F
diff --git a/protocols/IcqOscarJ/src/stdpackets.cpp b/protocols/IcqOscarJ/src/stdpackets.cpp index 14159d7f00..7f20732276 100644 --- a/protocols/IcqOscarJ/src/stdpackets.cpp +++ b/protocols/IcqOscarJ/src/stdpackets.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -36,14 +37,13 @@ extern const int moodXStatus[]; static void packServMsgSendHeader(icq_packet *p, DWORD dwSequence, DWORD dwID1, DWORD dwID2, DWORD dwUin, const char *szUID, WORD wFmt, WORD wLen)
{
serverPacketInit(p, (WORD)(21 + getUIDLen(dwUin, szUID) + wLen));
- packFNACHeader(p, ICQ_MSG_FAMILY, ICQ_MSG_SRV_SEND, 0, dwSequence | ICQ_MSG_SRV_SEND<<0x10);
+ packFNACHeader(p, ICQ_MSG_FAMILY, ICQ_MSG_SRV_SEND, 0, dwSequence | ICQ_MSG_SRV_SEND << 0x10);
packLEDWord(p, dwID1); // Msg ID part 1
packLEDWord(p, dwID2); // Msg ID part 2
packWord(p, wFmt); // Message channel
packUID(p, dwUin, szUID); // User ID
}
-
static void packServIcqExtensionHeader(icq_packet *p, CIcqProto *ppro, WORD wLen, WORD wType, WORD wSeq, WORD wCmd = ICQ_META_CLI_REQUEST)
{
serverPacketInit(p, (WORD)(24 + wLen));
@@ -56,7 +56,6 @@ static void packServIcqExtensionHeader(icq_packet *p, CIcqProto *ppro, WORD wLen packWord(p, wSeq);
}
-
static void packServIcqDirectoryHeader(icq_packet *p, CIcqProto *ppro, WORD wLen, WORD wType, WORD wCommand, WORD wSeq, WORD wSubCommand = ICQ_META_CLI_REQUEST)
{
packServIcqExtensionHeader(p, ppro, wLen + 0x1E, CLI_META_INFO_REQ, wSeq, wSubCommand);
@@ -68,7 +67,6 @@ static void packServIcqDirectoryHeader(icq_packet *p, CIcqProto *ppro, WORD wLen packDWord(p, 2);
}
-
static void packServTLV5HeaderBasic(icq_packet *p, WORD wLen, DWORD ID1, DWORD ID2, WORD wCommand, const plugin_guid pGuid)
{
// TLV(5) header
@@ -81,7 +79,6 @@ static void packServTLV5HeaderBasic(icq_packet *p, WORD wLen, DWORD ID1, DWORD I packGUID(p, pGuid); // capabilities (4 dwords)
}
-
static void packServTLV5HeaderMsg(icq_packet *p, WORD wLen, DWORD ID1, DWORD ID2, WORD wAckType)
{
packServTLV5HeaderBasic(p, (WORD)(wLen + 10), ID1, ID2, 0, MCAP_SRV_RELAY_FMT);
@@ -90,7 +87,6 @@ static void packServTLV5HeaderMsg(icq_packet *p, WORD wLen, DWORD ID1, DWORD ID2 packDWord(p, 0x000F0000); // TLV: 0x0F empty
}
-
static void packServTLV2711Header(icq_packet *packet, WORD wCookie, WORD wVersion, BYTE bMsgType, BYTE bMsgFlags, WORD X1, WORD X2, int nLen)
{
packWord(packet, 0x2711); // Type
@@ -113,14 +109,12 @@ static void packServTLV2711Header(icq_packet *packet, WORD wCookie, WORD wVersio packWord(packet, X2); // Unknown, priority?
}
-
static void packServDCInfo(icq_packet *p, CIcqProto* ppro, BOOL bEmpty)
{
packTLVDWord(p, 0x03, bEmpty ? 0 : ppro->getDword("RealIP", 0)); // TLV: 0x03 DWORD IP
packTLVWord(p, 0x05, (WORD)(bEmpty ? 0 : ppro->wListenPort)); // TLV: 0x05 Listen port
}
-
static void packServChannel2Header(icq_packet *p, CIcqProto* ppro, DWORD dwUin, WORD wLen, DWORD dwID1, DWORD dwID2, DWORD dwCookie, WORD wVersion, BYTE bMsgType, BYTE bMsgFlags, WORD wPriority, int isAck, int includeDcInfo, BYTE bRequestServerAck)
{
packServMsgSendHeader(p, dwCookie, dwID1, dwID2, dwUin, NULL, 0x0002, (WORD)(wLen + 95 + (bRequestServerAck ? 4 : 0) + (includeDcInfo ? 14 : 0)));
@@ -142,7 +136,6 @@ static void packServChannel2Header(icq_packet *p, CIcqProto* ppro, DWORD dwUin, packServTLV2711Header(p, (WORD)dwCookie, wVersion, bMsgType, bMsgFlags, (WORD)MirandaStatusToIcq(ppro->m_iStatus), wPriority, wLen);
}
-
static void packServAdvancedReply(icq_packet *p, DWORD dwUin, const char *szUid, DWORD dwID1, DWORD dwID2, WORD wCookie, WORD wLen)
{
serverPacketInit(p, (WORD)(getUIDLen(dwUin, szUid) + 23 + wLen));
@@ -154,7 +147,6 @@ static void packServAdvancedReply(icq_packet *p, DWORD dwUin, const char *szUid, packWord(p, 0x03); // Msg specific formating
}
-
static void packServAdvancedMsgReply(icq_packet *p, DWORD dwUin, const char *szUid, DWORD dwID1, DWORD dwID2, WORD wCookie, WORD wVersion, BYTE bMsgType, BYTE bMsgFlags, WORD wLen)
{
packServAdvancedReply(p, dwUin, szUid, dwID1, dwID2, wCookie, (WORD)(wLen + 51));
@@ -177,14 +169,12 @@ static void packServAdvancedMsgReply(icq_packet *p, DWORD dwUin, const char *szU packLEWord(p, 0); // Unused priority field
}
-
void packMsgColorInfo(icq_packet *packet)
{ // TODO: make configurable
packLEDWord(packet, 0x00000000); // Foreground colour
packLEDWord(packet, 0x00FFFFFF); // Background colour
}
-
void packEmptyMsg(icq_packet *packet)
{
packLEWord(packet, 1);
@@ -206,19 +196,17 @@ void CIcqProto::icq_sendCloseConnection() sendServPacket(&packet);
}
-
void CIcqProto::icq_requestnewfamily(WORD wFamily, void (CIcqProto::*familyhandler)(HANDLE hConn, char* cookie, WORD cookieLen))
{
- icq_packet packet;
- cookie_family_request *request;
int bRequestSSL = m_bSecureConnection && (wFamily != ICQ_AVATAR_FAMILY); // Avatar servers does not support SSL
- request = (cookie_family_request*)SAFE_MALLOC(sizeof(cookie_family_request));
+ cookie_family_request *request = (cookie_family_request*)SAFE_MALLOC(sizeof(cookie_family_request));
request->wFamily = wFamily;
request->familyHandler = familyhandler;
DWORD dwCookie = AllocateCookie(CKT_SERVICEREQUEST, ICQ_CLIENT_NEW_SERVICE, 0, request); // generate and alloc cookie
+ icq_packet packet;
serverPacketInit(&packet, 12 + (bRequestSSL ? 4 : 0));
packFNACHeader(&packet, ICQ_SERVICE_FAMILY, ICQ_CLIENT_NEW_SERVICE, 0, dwCookie);
packWord(&packet, wFamily);
@@ -228,13 +216,11 @@ void CIcqProto::icq_requestnewfamily(WORD wFamily, void (CIcqProto::*familyhandl sendServPacket(&packet);
}
-
void CIcqProto::icq_setidle(int bAllow)
{
- icq_packet packet;
-
if (bAllow != m_bIdleAllow) {
/* SNAC 1,11 */
+ icq_packet packet;
serverPacketInit(&packet, 14);
packFNACHeader(&packet, ICQ_SERVICE_FAMILY, ICQ_CLIENT_SET_IDLE);
if (bAllow == 1)
@@ -250,14 +236,12 @@ void CIcqProto::icq_setidle(int bAllow) void CIcqProto::icq_setstatus(WORD wStatus, const char *szStatusNote)
{
- icq_packet packet;
char *szCurrentStatusNote = szStatusNote ? getSettingStringUtf(NULL, DBSETTING_STATUS_NOTE, NULL) : NULL;
WORD wStatusMoodLen = 0, wStatusNoteLen = 0, wSessionDataLen = 0;
char *szMoodData = NULL;
if (szStatusNote && strcmpnull(szCurrentStatusNote, szStatusNote)) { // status note was changed, update now
DBVARIANT dbv = { DBVT_DELETED };
-
if (m_bMoodsEnabled && !getString(DBSETTING_STATUS_MOOD, &dbv))
szMoodData = null_strdup(dbv.pszVal);
@@ -271,24 +255,25 @@ void CIcqProto::icq_setstatus(WORD wStatus, const char *szStatusNote) SAFE_FREE(&szCurrentStatusNote);
// Pack data in packet
+ icq_packet packet;
serverPacketInit(&packet, (WORD)(18 + (wSessionDataLen ? wSessionDataLen + 4 : 0)));
packFNACHeader(&packet, ICQ_SERVICE_FAMILY, ICQ_CLIENT_SET_STATUS);
- packWord(&packet, 0x06); // TLV 6
- packWord(&packet, 0x04); // TLV length
- packWord(&packet, GetMyStatusFlags()); // Status flags
- packWord(&packet, wStatus); // Status
- if (wSessionDataLen) { // Pack session data
+ packWord(&packet, 0x06); // TLV 6
+ packWord(&packet, 0x04); // TLV length
+ packWord(&packet, GetMyStatusFlags()); // Status flags
+ packWord(&packet, wStatus); // Status
+ if (wSessionDataLen) {
packWord(&packet, 0x1D); // TLV 1D
packWord(&packet, wSessionDataLen); // TLV length
packWord(&packet, 0x02); // Item Type
if (wStatusNoteLen) {
packWord(&packet, 0x400 | (WORD)(wStatusNoteLen + 4)); // Flags + Item Length
- packWord(&packet, wStatusNoteLen); // Text Length
+ packWord(&packet, wStatusNoteLen); // Text Length
packBuffer(&packet, (LPBYTE)szStatusNote, wStatusNoteLen);
- packWord(&packet, 0); // Encoding not specified (utf-8 is default)
+ packWord(&packet, 0); // Encoding not specified (utf-8 is default)
}
- else
- packWord(&packet, 0); // Flags + Item Length
+ else packWord(&packet, 0); // Flags + Item Length
+
packWord(&packet, 0x0E); // Item Type
packWord(&packet, wStatusMoodLen); // Flags + Item Length
if (wStatusMoodLen)
@@ -304,21 +289,14 @@ void CIcqProto::icq_setstatus(WORD wStatus, const char *szStatusNote) sendServPacket(&packet);
}
-
DWORD CIcqProto::icq_SendChannel1Message(DWORD dwUin, char *szUID, MCONTACT hContact, char *pszText, cookie_message_data *pCookieData)
{
- icq_packet packet;
- WORD wPacketLength;
-
WORD wMessageLen = strlennull(pszText);
DWORD dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, (void*)pCookieData);
-
- if (pCookieData->nAckType == ACKTYPE_SERVER)
- wPacketLength = 25;
- else
- wPacketLength = 21;
+ WORD wPacketLength = (pCookieData->nAckType == ACKTYPE_SERVER) ? 25 : 21;
// Pack the standard header
+ icq_packet packet;
packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, szUID, 1, (WORD)(wPacketLength + wMessageLen));
// Pack first TLV
@@ -352,22 +330,13 @@ DWORD CIcqProto::icq_SendChannel1Message(DWORD dwUin, char *szUID, MCONTACT hCon DWORD CIcqProto::icq_SendChannel1MessageW(DWORD dwUin, char *szUID, MCONTACT hContact, WCHAR *pszText, cookie_message_data *pCookieData)
{
- icq_packet packet;
- WORD wMessageLen;
- DWORD dwCookie;
- WORD wPacketLength;
- WCHAR *ppText;
- int i;
-
- wMessageLen = strlennull(pszText) * (int)sizeof(WCHAR);
- dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, (void*)pCookieData);
+ WORD wMessageLen = strlennull(pszText) * (int)sizeof(WCHAR);
+ DWORD dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, (void*)pCookieData);
- if (pCookieData->nAckType == ACKTYPE_SERVER)
- wPacketLength = 26;
- else
- wPacketLength = 22;
+ WORD wPacketLength = (pCookieData->nAckType == ACKTYPE_SERVER) ? 26 : 22;
// Pack the standard header
+ icq_packet packet;
packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, szUID, 1, (WORD)(wPacketLength + wMessageLen));
// Pack first TLV
@@ -384,8 +353,8 @@ DWORD CIcqProto::icq_SendChannel1MessageW(DWORD dwUin, char *szUID, MCONTACT hCo packWord(&packet, (WORD)(wMessageLen + 4)); // TLV len
packWord(&packet, 0x0002); // Message charset number, again copied from ICQ 2003b
packWord(&packet, 0x0000); // Message charset subset
- ppText = pszText; // we must convert the widestring
- for (i = 0; i < wMessageLen; i += 2, ppText++)
+ WCHAR *ppText = pszText; // we must convert the widestring
+ for (int i = 0; i < wMessageLen; i += 2, ppText++)
packWord(&packet, *ppText);
// Pack request server ack TLV
@@ -399,14 +368,12 @@ DWORD CIcqProto::icq_SendChannel1MessageW(DWORD dwUin, char *szUID, MCONTACT hCo return dwCookie;
}
-
DWORD CIcqProto::icq_SendChannel2Message(DWORD dwUin, MCONTACT hContact, const char *szMessage, int nBodyLen, WORD wPriority, cookie_message_data *pCookieData, char *szCap)
{
- icq_packet packet;
-
DWORD dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, (void*)pCookieData);
// Pack the standard header
+ icq_packet packet;
packServChannel2Header(&packet, this, dwUin, (WORD)(nBodyLen + (szCap ? 53 : 11)), pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwCookie, ICQ_VERSION, (BYTE)pCookieData->bMessageType, 0,
wPriority, 0, 0, (BYTE)((pCookieData->nAckType == ACKTYPE_SERVER) ? 1 : 0));
@@ -427,16 +394,14 @@ DWORD CIcqProto::icq_SendChannel2Message(DWORD dwUin, MCONTACT hContact, const c return dwCookie;
}
-
DWORD CIcqProto::icq_SendChannel2Contacts(DWORD dwUin, char *szUid, MCONTACT hContact, const char *pData, WORD wDataLen, const char *pNames, WORD wNamesLen, cookie_message_data *pCookieData)
{
- icq_packet packet;
-
DWORD dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, pCookieData);
WORD wPacketLength = wDataLen + wNamesLen + 0x12;
// Pack the standard header
+ icq_packet packet;
packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, szUid, 2, (WORD)(wPacketLength + ((pCookieData->nAckType == ACKTYPE_SERVER) ? 0x22 : 0x1E)));
packServTLV5HeaderBasic(&packet, wPacketLength, pCookieData->dwMsgID1, pCookieData->dwMsgID2, 0, MCAP_CONTACTS);
@@ -452,23 +417,16 @@ DWORD CIcqProto::icq_SendChannel2Contacts(DWORD dwUin, char *szUid, MCONTACT hCo }
sendServPacket(&packet);
-
return dwCookie;
}
-
DWORD CIcqProto::icq_SendChannel4Message(DWORD dwUin, MCONTACT hContact, BYTE bMsgType, WORD wMsgLen, const char *szMsg, cookie_message_data *pCookieData)
{
- icq_packet packet;
- WORD wPacketLength;
DWORD dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, (void*)pCookieData);
-
- if (pCookieData->nAckType == ACKTYPE_SERVER)
- wPacketLength = 28;
- else
- wPacketLength = 24;
+ WORD wPacketLength = (pCookieData->nAckType == ACKTYPE_SERVER) ? 28 : 24;
// Pack the standard header
+ icq_packet packet;
packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, NULL, 4, (WORD)(wPacketLength + wMsgLen));
// Pack first TLV
@@ -482,9 +440,8 @@ DWORD CIcqProto::icq_SendChannel4Message(DWORD dwUin, MCONTACT hContact, BYTE bM packMsgColorInfo(&packet);
// Pack request ack TLV
- if (pCookieData->nAckType == ACKTYPE_SERVER) {
+ if (pCookieData->nAckType == ACKTYPE_SERVER)
packDWord(&packet, 0x00030000); // TLV(3)
- }
// Pack store on server TLV
packDWord(&packet, 0x00060000); // TLV(6)
@@ -526,17 +483,15 @@ void CIcqProto::sendOwnerInfoRequest(void) sendServPacket(&packet);
}
-
DWORD CIcqProto::sendUserInfoMultiRequest(BYTE *pRequestData, WORD wDataLen, int nItems)
{
- icq_packet packet;
-
cookie_directory_data *pCookieData = (cookie_directory_data*)SAFE_MALLOC(sizeof(cookie_directory_data));
if (!pCookieData) return 0; // Failure
pCookieData->bRequestType = DIRECTORYREQUEST_INFOMULTI;
DWORD dwCookie = AllocateCookie(CKT_DIRECTORY_QUERY, 0, NULL, (void*)pCookieData);
+ icq_packet packet;
packServIcqDirectoryHeader(&packet, this, wDataLen + 2, META_DIRECTORY_QUERY, DIRECTORY_QUERY_MULTI_INFO, (WORD)dwCookie);
packWord(&packet, nItems);
packBuffer(&packet, pRequestData, wDataLen);
@@ -546,14 +501,10 @@ DWORD CIcqProto::sendUserInfoMultiRequest(BYTE *pRequestData, WORD wDataLen, int return dwCookie;
}
-
DWORD CIcqProto::icq_sendGetInfoServ(MCONTACT hContact, DWORD dwUin, int bManual)
{
- icq_packet packet;
- DWORD dwCookie = 0;
-
if (IsServerOverRate(ICQ_EXTENSIONS_FAMILY, ICQ_META_CLI_REQUEST, bManual ? RML_IDLE_10 : RML_IDLE_50))
- return dwCookie;
+ return 0;
DBVARIANT infoToken = { DBVT_DELETED };
BYTE *pToken = NULL;
@@ -569,23 +520,23 @@ DWORD CIcqProto::icq_sendGetInfoServ(MCONTACT hContact, DWORD dwUin, int bManual cookie_directory_data *pCookieData = (cookie_directory_data*)SAFE_MALLOC(sizeof(cookie_directory_data));
+ icq_packet packet;
if (m_bLegacyFix) {
pCookieData->bRequestType = REQUESTTYPE_USERDETAILED;
- dwCookie = AllocateCookie(CKT_FAMILYSPECIAL, 0, hContact, (void*)pCookieData);
+ DWORD dwCookie = AllocateCookie(CKT_FAMILYSPECIAL, 0, hContact, (void*)pCookieData);
packServIcqExtensionHeader(&packet, this, 6, CLI_META_INFO_REQ, (WORD)dwCookie);
packLEWord(&packet, META_REQUEST_FULL_INFO);
packLEDWord(&packet, dwUin);
sendServPacket(&packet);
-
return dwCookie;
}
pCookieData->bRequestType = DIRECTORYREQUEST_INFOUSER;
- dwCookie = AllocateCookie(CKT_DIRECTORY_QUERY, 0, hContact, (void*)pCookieData);
+ DWORD dwCookie = AllocateCookie(CKT_DIRECTORY_QUERY, 0, hContact, (void*)pCookieData);
WORD wDataLen = cbToken + getUINLen(dwUin) + (cbToken ? 8 : 4);
packServIcqDirectoryHeader(&packet, this, wDataLen + 8, META_DIRECTORY_QUERY, DIRECTORY_QUERY_INFO, (WORD)dwCookie);
@@ -604,9 +555,6 @@ DWORD CIcqProto::icq_sendGetInfoServ(MCONTACT hContact, DWORD dwUin, int bManual DWORD CIcqProto::icq_sendGetAimProfileServ(MCONTACT hContact, char* szUid)
{
- icq_packet packet;
- BYTE bUIDlen = strlennull(szUid);
-
if (IsServerOverRate(ICQ_LOCATION_FAMILY, ICQ_LOCATION_REQ_USER_INFO, RML_IDLE_10))
return 0;
@@ -614,7 +562,9 @@ DWORD CIcqProto::icq_sendGetAimProfileServ(MCONTACT hContact, char* szUid) pCookieData->bRequestType = REQUESTTYPE_PROFILE;
DWORD dwCookie = AllocateCookie(CKT_FAMILYSPECIAL, ICQ_LOCATION_REQ_USER_INFO, hContact, (void*)pCookieData);
+ BYTE bUIDlen = strlennull(szUid);
+ icq_packet packet;
serverPacketInit(&packet, (WORD)(13 + bUIDlen));
packFNACHeader(&packet, ICQ_LOCATION_FAMILY, ICQ_LOCATION_REQ_USER_INFO, 0, dwCookie);
packWord(&packet, 0x01); // request profile info
@@ -629,14 +579,13 @@ DWORD CIcqProto::icq_sendGetAimProfileServ(MCONTACT hContact, char* szUid) DWORD CIcqProto::icq_sendGetAwayMsgServ(MCONTACT hContact, DWORD dwUin, int type, WORD wVersion)
{
- icq_packet packet;
-
if (IsServerOverRate(ICQ_MSG_FAMILY, ICQ_MSG_SRV_SEND, RML_IDLE_30))
return 0;
cookie_message_data *pCookieData = CreateMessageCookie(MTYPE_AUTOAWAY, (BYTE)type);
DWORD dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, (void*)pCookieData);
+ icq_packet packet;
packServChannel2Header(&packet, this, dwUin, 3, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwCookie, wVersion, (BYTE)type, 3, 1, 0, 0, 0);
packEmptyMsg(&packet); // Message
sendServPacket(&packet);
@@ -647,14 +596,13 @@ DWORD CIcqProto::icq_sendGetAwayMsgServ(MCONTACT hContact, DWORD dwUin, int type DWORD CIcqProto::icq_sendGetAwayMsgServExt(MCONTACT hContact, DWORD dwUin, char *szUID, int type, WORD wVersion)
{
- icq_packet packet;
-
if (IsServerOverRate(ICQ_MSG_FAMILY, ICQ_MSG_SRV_SEND, RML_IDLE_30))
return 0;
cookie_message_data *pCookieData = CreateMessageCookie(MTYPE_AUTOAWAY, (BYTE)type);
DWORD dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, (void*)pCookieData);
+ icq_packet packet;
packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, szUID, 2, 122 + getPluginTypeIdLen(type));
// TLV(5) header
@@ -662,7 +610,7 @@ DWORD CIcqProto::icq_sendGetAwayMsgServExt(MCONTACT hContact, DWORD dwUin, char // TLV(0x2711) header
packServTLV2711Header(&packet, (WORD)dwCookie, wVersion, MTYPE_PLUGIN, 0, 0, 0x100, 27 + getPluginTypeIdLen(type));
- //
+
packLEWord(&packet, 0); // Empty msg
packPluginTypeId(&packet, type);
@@ -681,12 +629,12 @@ DWORD CIcqProto::icq_sendGetAwayMsgServExt(MCONTACT hContact, DWORD dwUin, char DWORD CIcqProto::icq_sendGetAimAwayMsgServ(MCONTACT hContact, char *szUID, int type)
{
- icq_packet packet;
BYTE bUIDlen = strlennull(szUID);
cookie_message_data *pCookieData = CreateMessageCookie(MTYPE_AUTOAWAY, (byte)type);
DWORD dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, (void*)pCookieData);
+ icq_packet packet;
serverPacketInit(&packet, (WORD)(13 + bUIDlen));
packFNACHeader(&packet, ICQ_LOCATION_FAMILY, ICQ_LOCATION_REQ_USER_INFO, 0, dwCookie);
packWord(&packet, 0x03);
@@ -746,7 +694,6 @@ void CIcqProto::icq_sendSetAimAwayMsgServ(const char *szMsg) sendServPacket(&packet);
}
-
void CIcqProto::icq_sendFileSendServv7(filetransfer* ft, const char *szFiles)
{
icq_packet packet;
@@ -778,7 +725,6 @@ void CIcqProto::icq_sendFileSendServv7(filetransfer* ft, const char *szFiles) sendServPacket(&packet);
}
-
void CIcqProto::icq_sendFileSendServv8(filetransfer* ft, const char *szFiles, int nAckType)
{
icq_packet packet;
@@ -838,7 +784,6 @@ void CIcqProto::icq_sendFileSendServv8(filetransfer* ft, const char *szFiles, in void CIcqProto::icq_sendFileAcceptServv8(DWORD dwUin, DWORD TS1, DWORD TS2, DWORD dwCookie, const char *szFiles, const char *szDescr, DWORD dwTotalSize, WORD wPort, BOOL accepted, int nAckType)
{
icq_packet packet;
- WORD wDescrLen, wFilesLen;
char *szFilesAnsi = NULL, *szDescrAnsi = NULL;
/* if !accepted, szDescr == szReason, szFiles = "" */
@@ -851,8 +796,8 @@ void CIcqProto::icq_sendFileAcceptServv8(DWORD dwUin, DWORD TS1, DWORD TS2, DWOR if (!utf8_decode(szDescr, &szDescrAnsi))
szDescrAnsi = _strdup(szDescr); // Legacy fix
- wDescrLen = strlennull(szDescrAnsi);
- wFilesLen = strlennull(szFilesAnsi);
+ WORD wDescrLen = strlennull(szDescrAnsi);
+ WORD wFilesLen = strlennull(szFilesAnsi);
// 202 + UIN len + file description (no null) + file name (null included)
// Packet size = Flap length + 4
@@ -898,7 +843,6 @@ void CIcqProto::icq_sendFileAcceptServv8(DWORD dwUin, DWORD TS1, DWORD TS2, DWOR void CIcqProto::icq_sendFileAcceptServv7(DWORD dwUin, DWORD TS1, DWORD TS2, DWORD dwCookie, const char* szFiles, const char* szDescr, DWORD dwTotalSize, WORD wPort, BOOL accepted, int nAckType)
{
icq_packet packet;
- WORD wDescrLen, wFilesLen;
char *szFilesAnsi = NULL, *szDescrAnsi = NULL;
/* if !accepted, szDescr == szReason, szFiles = "" */
@@ -911,8 +855,8 @@ void CIcqProto::icq_sendFileAcceptServv7(DWORD dwUin, DWORD TS1, DWORD TS2, DWOR if (!utf8_decode(szDescr, &szDescrAnsi))
szDescrAnsi = _strdup(szDescr); // Legacy fix
- wDescrLen = strlennull(szDescrAnsi);
- wFilesLen = strlennull(szFilesAnsi);
+ WORD wDescrLen = strlennull(szDescrAnsi);
+ WORD wFilesLen = strlennull(szFilesAnsi);
// 150 + UIN len + file description (with null) + file name (2 nulls)
// Packet size = Flap length + 4
@@ -942,15 +886,13 @@ void CIcqProto::icq_sendFileAcceptServv7(DWORD dwUin, DWORD TS1, DWORD TS2, DWOR SAFE_FREE(&szDescrAnsi);
// Pack request server ack TLV
- if (nAckType == ACKTYPE_SERVER) {
+ if (nAckType == ACKTYPE_SERVER)
packDWord(&packet, 0x00030000); // TLV(3)
- }
// Send the monster
sendServPacket(&packet);
}
-
void CIcqProto::icq_sendFileAcceptServ(DWORD dwUin, filetransfer *ft, int nAckType)
{
char *szDesc = ft->szDescription;
@@ -967,7 +909,6 @@ void CIcqProto::icq_sendFileAcceptServ(DWORD dwUin, filetransfer *ft, int nAckTy }
}
-
void CIcqProto::icq_sendFileDenyServ(DWORD dwUin, filetransfer *ft, const char *szReason, int nAckType)
{
if (ft->nVersion >= 8) {
@@ -980,7 +921,6 @@ void CIcqProto::icq_sendFileDenyServ(DWORD dwUin, filetransfer *ft, const char * }
}
-
void CIcqProto::icq_sendAwayMsgReplyServ(DWORD dwUin, DWORD dwMsgID1, DWORD dwMsgID2, WORD wCookie, WORD wVersion, BYTE msgType, char** szMsg)
{
MCONTACT hContact = HContactFromUIN(dwUin, NULL);
@@ -1086,7 +1026,6 @@ void CIcqProto::icq_sendAwayMsgReplyServExt(DWORD dwUin, char *szUID, DWORD dwMs void CIcqProto::icq_sendAdvancedMsgAck(DWORD dwUin, DWORD dwTimestamp, DWORD dwTimestamp2, WORD wCookie, BYTE bMsgType, BYTE bMsgFlags)
{
icq_packet packet;
-
packServAdvancedMsgReply(&packet, dwUin, NULL, dwTimestamp, dwTimestamp2, wCookie, ICQ_VERSION, bMsgType, bMsgFlags, 11);
packEmptyMsg(&packet); // Status message
packMsgColorInfo(&packet);
@@ -1098,7 +1037,6 @@ void CIcqProto::icq_sendAdvancedMsgAck(DWORD dwUin, DWORD dwTimestamp, DWORD dwT void CIcqProto::icq_sendContactsAck(DWORD dwUin, char *szUid, DWORD dwMsgID1, DWORD dwMsgID2)
{
icq_packet packet;
-
packServMsgSendHeader(&packet, 0, dwMsgID1, dwMsgID2, dwUin, szUid, 2, 0x1E);
packServTLV5HeaderBasic(&packet, 0, dwMsgID1, dwMsgID2, 2, MCAP_CONTACTS);
@@ -1150,7 +1088,6 @@ DWORD CIcqProto::SearchByUin(DWORD dwUin) DWORD CIcqProto::SearchByNames(const char *pszNick, const char *pszFirstName, const char *pszLastName, WORD wPage)
{ // use directory search like ICQ6 does
WORD wInfoLen = 0;
- WORD wNickLen, wFirstLen, wLastLen;
icq_packet pBuffer; // I reuse the ICQ packet type as a generic buffer
// I should be ashamed! ;)
if (m_bLegacyFix) {
@@ -1168,9 +1105,9 @@ DWORD CIcqProto::SearchByNames(const char *pszNick, const char *pszFirstName, co if (!utf8_decode(pszLastName, &pszLastNameAnsi))
pszLastNameAnsi = _strdup(pszLastName);
- wNickLen = strlennull(pszNickAnsi);
- wFirstLen = strlennull(pszFirstNameAnsi);
- wLastLen = strlennull(pszLastNameAnsi);
+ WORD wNickLen = strlennull(pszNickAnsi);
+ WORD wFirstLen = strlennull(pszFirstNameAnsi);
+ WORD wLastLen = strlennull(pszLastNameAnsi);
_ASSERTE(wFirstLen || wLastLen || wNickLen);
@@ -1190,17 +1127,14 @@ DWORD CIcqProto::SearchByNames(const char *pszNick, const char *pszFirstName, co int pBufferPos = 0;
// Pack the search details
- if (wFirstLen > 0) {
+ if (wFirstLen > 0)
packLETLVLNTS(&pBuffer.pData, &pBufferPos, pszFirstNameAnsi, TLV_FIRSTNAME);
- }
- if (wLastLen > 0) {
+ if (wLastLen > 0)
packLETLVLNTS(&pBuffer.pData, &pBufferPos, pszLastNameAnsi, TLV_LASTNAME);
- }
- if (wNickLen > 0) {
+ if (wNickLen > 0)
packLETLVLNTS(&pBuffer.pData, &pBufferPos, pszNickAnsi, TLV_NICKNAME);
- }
SAFE_FREE(&pszFirstNameAnsi);
SAFE_FREE(&pszLastNameAnsi);
@@ -1210,13 +1144,12 @@ DWORD CIcqProto::SearchByNames(const char *pszNick, const char *pszFirstName, co return sendTLVSearchPacket(SEARCHTYPE_NAMES, (char*)pBuffer.pData, META_SEARCH_GENERIC, wInfoLen, FALSE);
}
- wNickLen = strlennull(pszNick);
- wFirstLen = strlennull(pszFirstName);
- wLastLen = strlennull(pszLastName);
+ WORD wNickLen = strlennull(pszNick);
+ WORD wFirstLen = strlennull(pszFirstName);
+ WORD wLastLen = strlennull(pszLastName);
_ASSERTE(wFirstLen || wLastLen || wNickLen);
-
// Calculate data size
if (wFirstLen)
wInfoLen = wFirstLen + 4;
@@ -1247,55 +1180,41 @@ DWORD CIcqProto::SearchByNames(const char *pszNick, const char *pszFirstName, co return 0; // Failure
}
-
DWORD CIcqProto::SearchByMail(const char* pszEmail)
{
- DWORD dwCookie = 0;
- WORD wInfoLen = 0;
- WORD wEmailLen;
- BYTE *pBuffer;
- int pBufferPos;
-
- wEmailLen = strlennull(pszEmail);
-
+ WORD wEmailLen = strlennull(pszEmail);
_ASSERTE(wEmailLen);
+ if (wEmailLen <= 0)
+ return 0;
- if (wEmailLen > 0) {
- // Calculate data size
- wInfoLen = wEmailLen + 7;
-
- // Initialize our handy data buffer
- pBuffer = (BYTE *)_alloca(wInfoLen);
- pBufferPos = 0;
+ // Calculate data size
+ WORD wInfoLen = wEmailLen + 7;
- // Pack the search details
- packLETLVLNTS(&pBuffer, &pBufferPos, pszEmail, TLV_EMAIL);
+ // Initialize our handy data buffer
+ BYTE *pBuffer = (BYTE *)_alloca(wInfoLen);
+ int pBufferPos = 0;
- // Send it off for further packing
- dwCookie = sendTLVSearchPacket(SEARCHTYPE_EMAIL, (char*)pBuffer, META_SEARCH_EMAIL, wInfoLen, FALSE);
- }
+ // Pack the search details
+ packLETLVLNTS(&pBuffer, &pBufferPos, pszEmail, TLV_EMAIL);
- return dwCookie;
+ // Send it off for further packing
+ return sendTLVSearchPacket(SEARCHTYPE_EMAIL, (char*)pBuffer, META_SEARCH_EMAIL, wInfoLen, FALSE);
}
-
DWORD CIcqProto::sendDirectorySearchPacket(const BYTE *pSearchData, WORD wDataLen, WORD wPage, BOOL bOnlineUsersOnly)
{
- icq_packet packet;
- DWORD dwCookie;
-
_ASSERTE(pSearchData);
_ASSERTE(wDataLen >= 4);
cookie_directory_data *pCookieData = (cookie_directory_data*)SAFE_MALLOC(sizeof(cookie_directory_data));
- if (pCookieData) {
- pCookieData->bRequestType = DIRECTORYREQUEST_SEARCH;
- dwCookie = AllocateCookie(CKT_DIRECTORY_QUERY, 0, NULL, (void*)pCookieData);
- }
- else
+ if (pCookieData == NULL)
return 0;
+ pCookieData->bRequestType = DIRECTORYREQUEST_SEARCH;
+ DWORD dwCookie = AllocateCookie(CKT_DIRECTORY_QUERY, 0, NULL, (void*)pCookieData);
+
// Pack headers
+ icq_packet packet;
packServIcqDirectoryHeader(&packet, this, wDataLen + (bOnlineUsersOnly ? 14 : 8), META_DIRECTORY_QUERY, DIRECTORY_QUERY_INFO, (WORD)dwCookie);
packWord(&packet, 0x02);
@@ -1307,26 +1226,20 @@ DWORD CIcqProto::sendDirectorySearchPacket(const BYTE *pSearchData, WORD wDataLe packWord(&packet, wDataLen + (bOnlineUsersOnly ? 6 : 0));
packBuffer(&packet, pSearchData, wDataLen);
- if (bOnlineUsersOnly) { // Pack "Online users only" flag
+ if (bOnlineUsersOnly) // Pack "Online users only" flag
packTLVWord(&packet, 0x136, 1);
- }
// Go!
sendServPacket(&packet);
-
return dwCookie;
}
-
DWORD CIcqProto::sendTLVSearchPacket(BYTE bType, char* pSearchDataBuf, WORD wSearchType, WORD wInfoLen, BOOL bOnlineUsersOnly)
{
- icq_packet packet;
- cookie_search* pCookie;
-
_ASSERTE(pSearchDataBuf);
_ASSERTE(wInfoLen >= 4);
- pCookie = (cookie_search*)SAFE_MALLOC(sizeof(cookie_search));
+ cookie_search *pCookie = (cookie_search*)SAFE_MALLOC(sizeof(cookie_search));
if (!pCookie)
return 0;
@@ -1334,6 +1247,7 @@ DWORD CIcqProto::sendTLVSearchPacket(BYTE bType, char* pSearchDataBuf, WORD wSea DWORD dwCookie = AllocateCookie(CKT_SEARCH, 0, 0, pCookie);
// Pack headers
+ icq_packet packet;
packServIcqExtensionHeader(&packet, this, (WORD)(wInfoLen + (wSearchType == META_SEARCH_GENERIC ? 7 : 2)), CLI_META_INFO_REQ, (WORD)dwCookie);
// Pack search type
@@ -1349,55 +1263,44 @@ DWORD CIcqProto::sendTLVSearchPacket(BYTE bType, char* pSearchDataBuf, WORD wSea // Go!
sendServPacket(&packet);
-
return dwCookie;
}
-
DWORD CIcqProto::icq_sendAdvancedSearchServ(BYTE* fieldsBuffer, int bufferLen)
{
- icq_packet packet;
- DWORD dwCookie;
-
cookie_search *pCookie = (cookie_search*)SAFE_MALLOC(sizeof(cookie_search));
- if (pCookie) {
- pCookie->bSearchType = SEARCHTYPE_DETAILS;
- dwCookie = AllocateCookie(CKT_SEARCH, 0, 0, pCookie);
- }
- else
+ if (pCookie == 0)
return 0;
+
+ pCookie->bSearchType = SEARCHTYPE_DETAILS;
+ DWORD dwCookie = AllocateCookie(CKT_SEARCH, 0, 0, pCookie);
+ icq_packet packet;
packServIcqExtensionHeader(&packet, this, (WORD)bufferLen, CLI_META_INFO_REQ, (WORD)dwCookie);
packBuffer(&packet, (LPBYTE)fieldsBuffer, (WORD)bufferLen);
-
sendServPacket(&packet);
return dwCookie;
}
-
DWORD CIcqProto::icq_searchAimByEmail(const char* pszEmail, DWORD dwSearchId)
{
- icq_packet packet;
- DWORD dwCookie;
- cookie_search* pCookie;
- WORD wEmailLen;
-
+ cookie_search *pCookie;
if (!FindCookie(dwSearchId, NULL, (void**)&pCookie)) {
dwSearchId = 0;
pCookie = (cookie_search*)SAFE_MALLOC(sizeof(cookie_search));
pCookie->bSearchType = SEARCHTYPE_EMAIL;
}
- if (pCookie) {
- pCookie->dwMainId = dwSearchId;
- pCookie->szObject = null_strdup(pszEmail);
- dwCookie = AllocateCookie(CKT_SEARCH, ICQ_LOOKUP_REQUEST, 0, pCookie);
- }
- else
+ if (!pCookie)
return 0;
+
+ pCookie->dwMainId = dwSearchId;
+ pCookie->szObject = null_strdup(pszEmail);
+ DWORD dwCookie = AllocateCookie(CKT_SEARCH, ICQ_LOOKUP_REQUEST, 0, pCookie);
- wEmailLen = strlennull(pszEmail);
+ WORD wEmailLen = strlennull(pszEmail);
+ icq_packet packet;
serverPacketInit(&packet, (WORD)(10 + wEmailLen));
packFNACHeader(&packet, ICQ_LOOKUP_FAMILY, ICQ_LOOKUP_REQUEST, 0, dwCookie);
packBuffer(&packet, (LPBYTE)pszEmail, wEmailLen);
@@ -1407,49 +1310,42 @@ DWORD CIcqProto::icq_searchAimByEmail(const char* pszEmail, DWORD dwSearchId) return dwCookie;
}
-
DWORD CIcqProto::icq_changeUserPasswordServ(const char *szPassword)
{
- icq_packet packet;
WORD wPasswordLen = strlennull(szPassword);
DWORD dwCookie = GenerateCookie(0);
+ icq_packet packet;
packServIcqExtensionHeader(&packet, this, (WORD)(wPasswordLen + 4), CLI_META_INFO_REQ, (WORD)dwCookie, ICQ_META_SRV_UPDATE);
packLEWord(&packet, META_SET_PASSWORD_REQ);
packLEWord(&packet, wPasswordLen);
packBuffer(&packet, (BYTE*)szPassword, wPasswordLen);
-
sendServPacket(&packet);
return dwCookie;
}
-
DWORD CIcqProto::icq_changeUserDirectoryInfoServ(const BYTE *pData, WORD wDataLen, BYTE bRequestType)
{
- icq_packet packet;
cookie_directory_data *pCookieData = (cookie_directory_data*)SAFE_MALLOC(sizeof(cookie_directory_data));
pCookieData->bRequestType = bRequestType;
DWORD dwCookie = AllocateCookie(CKT_DIRECTORY_UPDATE, 0, NULL, pCookieData);
+ icq_packet packet;
packServIcqDirectoryHeader(&packet, this, wDataLen + 4, META_DIRECTORY_UPDATE, DIRECTORY_SET_INFO, (WORD)dwCookie, ICQ_META_SRV_UPDATE);
packWord(&packet, 0x0003);
packWord(&packet, wDataLen);
packBuffer(&packet, pData, wDataLen);
-
sendServPacket(&packet);
return dwCookie;
}
-
DWORD CIcqProto::icq_sendSMSServ(const char *szPhoneNumber, const char *szMsg)
{
- icq_packet packet;
DWORD dwCookie;
WORD wBufferLen;
- char* szBuffer = NULL;
- char* szMyNick = NULL;
+ char *szBuffer = NULL;
char szTime[30];
time_t now;
int nBufferSize;
@@ -1458,11 +1354,10 @@ DWORD CIcqProto::icq_sendSMSServ(const char *szPhoneNumber, const char *szMsg) strftime(szTime, sizeof(szTime), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&now));
/* Sun, 00 Jan 0000 00:00:00 GMT */
- szMyNick = null_strdup((char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)(HANDLE)NULL, 0));
+ char *szMyNick = null_strdup((char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)(HANDLE)NULL, 0));
nBufferSize = 1 + strlennull(szMyNick) + strlennull(szPhoneNumber) + strlennull(szMsg) + sizeof("<icq_sms_message><destination></destination><text></text><codepage>1252</codepage><encoding>utf8</encoding><senders_UIN>0000000000</senders_UIN><senders_name></senders_name><delivery_receipt>Yes</delivery_receipt><time>Sun, 00 Jan 0000 00:00:00 GMT</time></icq_sms_message>");
if (szBuffer = (char *)_alloca(nBufferSize)) {
-
wBufferLen = mir_snprintf(szBuffer, nBufferSize,
"<icq_sms_message>"
"<destination>"
@@ -1494,6 +1389,7 @@ DWORD CIcqProto::icq_sendSMSServ(const char *szPhoneNumber, const char *szMsg) dwCookie = GenerateCookie(0);
+ icq_packet packet;
packServIcqExtensionHeader(&packet, this, (WORD)(wBufferLen + 27), CLI_META_INFO_REQ, (WORD)dwCookie);
packWord(&packet, 0x8214); /* send sms */
packWord(&packet, 1);
@@ -1508,9 +1404,7 @@ DWORD CIcqProto::icq_sendSMSServ(const char *szPhoneNumber, const char *szMsg) sendServPacket(&packet);
}
- else {
- dwCookie = 0;
- }
+ else dwCookie = 0;
SAFE_FREE((void**)&szMyNick);
return dwCookie;
@@ -1518,11 +1412,9 @@ DWORD CIcqProto::icq_sendSMSServ(const char *szPhoneNumber, const char *szMsg) void CIcqProto::icq_sendGenericContact(DWORD dwUin, const char *szUid, WORD wFamily, WORD wSubType)
{
- icq_packet packet;
- int nUinLen;
-
- nUinLen = getUIDLen(dwUin, szUid);
+ int nUinLen = getUIDLen(dwUin, szUid);
+ icq_packet packet;
serverPacketInit(&packet, (WORD)(nUinLen + 11));
packFNACHeader(&packet, wFamily, wSubType);
packUID(&packet, dwUin, szUid);
@@ -1536,18 +1428,17 @@ void CIcqProto::icq_sendNewContact(DWORD dwUin, const char *szUid) icq_sendGenericContact(dwUin, szUid, ICQ_BUDDY_FAMILY, ICQ_USER_ADDTOTEMPLIST);
}
-
void CIcqProto::icq_sendRemoveContact(DWORD dwUin, const char *szUid)
{
/* Remove from temporary buddy list */
icq_sendGenericContact(dwUin, szUid, ICQ_BUDDY_FAMILY, ICQ_USER_REMOVEFROMTEMPLIST);
}
-
// list==0: visible list
// list==1: invisible list
void CIcqProto::icq_sendChangeVisInvis(MCONTACT hContact, DWORD dwUin, char* szUID, int list, int add)
-{ // TODO: This needs grouping & rate management
+{
+ // TODO: This needs grouping & rate management
// Tell server to change our server-side contact visbility list
if (m_bSsiEnabled) {
WORD wContactId;
@@ -1589,35 +1480,29 @@ void CIcqProto::icq_sendChangeVisInvis(MCONTACT hContact, DWORD dwUin, char* szU // Notify server that we have changed
// our client side visibility list
- {
- int nUinLen;
- icq_packet packet;
- WORD wSnac = 0;
-
- if (list && m_iStatus == ID_STATUS_INVISIBLE)
- return;
-
- if (!list && m_iStatus != ID_STATUS_INVISIBLE)
- return;
-
+ if (list && m_iStatus == ID_STATUS_INVISIBLE)
+ return;
- if (list && add)
- wSnac = ICQ_CLI_ADDINVISIBLE;
- else if (list && !add)
- wSnac = ICQ_CLI_REMOVEINVISIBLE;
- else if (!list && add)
- wSnac = ICQ_CLI_ADDVISIBLE;
- else if (!list && !add)
- wSnac = ICQ_CLI_REMOVEVISIBLE;
+ if (!list && m_iStatus != ID_STATUS_INVISIBLE)
+ return;
- nUinLen = getUIDLen(dwUin, szUID);
+ WORD wSnac = 0;
+ if (list && add)
+ wSnac = ICQ_CLI_ADDINVISIBLE;
+ else if (list && !add)
+ wSnac = ICQ_CLI_REMOVEINVISIBLE;
+ else if (!list && add)
+ wSnac = ICQ_CLI_ADDVISIBLE;
+ else if (!list && !add)
+ wSnac = ICQ_CLI_REMOVEVISIBLE;
- serverPacketInit(&packet, (WORD)(nUinLen + 11));
- packFNACHeader(&packet, ICQ_BOS_FAMILY, wSnac);
- packUID(&packet, dwUin, szUID);
+ int nUinLen = getUIDLen(dwUin, szUID);
- sendServPacket(&packet);
- }
+ icq_packet packet;
+ serverPacketInit(&packet, (WORD)(nUinLen + 11));
+ packFNACHeader(&packet, ICQ_BOS_FAMILY, wSnac);
+ packUID(&packet, dwUin, szUID);
+ sendServPacket(&packet);
}
void CIcqProto::icq_sendEntireVisInvisList(int list)
@@ -1635,17 +1520,13 @@ void CIcqProto::icq_sendRevokeAuthServ(DWORD dwUin, char *szUid) void CIcqProto::icq_sendGrantAuthServ(DWORD dwUin, const char *szUid, const char *szMsg)
{
- icq_packet packet;
- BYTE nUinlen;
- char *szUtfMsg = NULL;
- WORD nMsglen;
-
- nUinlen = getUIDLen(dwUin, szUid);
+ BYTE nUinlen = getUIDLen(dwUin, szUid);
// Prepare custom utf-8 message
- szUtfMsg = ansi_to_utf8(szMsg);
- nMsglen = strlennull(szUtfMsg);
+ char *szUtfMsg = ansi_to_utf8(szMsg);
+ WORD nMsglen = strlennull(szUtfMsg);
+ icq_packet packet;
serverPacketInit(&packet, (WORD)(15 + nUinlen + nMsglen));
packFNACHeader(&packet, ICQ_LISTS_FAMILY, ICQ_LISTS_GRANTAUTH);
packUID(&packet, dwUin, szUid);
@@ -1660,13 +1541,10 @@ void CIcqProto::icq_sendGrantAuthServ(DWORD dwUin, const char *szUid, const char void CIcqProto::icq_sendAuthReqServ(DWORD dwUin, char *szUid, const char *szMsg)
{
- icq_packet packet;
- BYTE nUinlen;
- WORD nMsglen;
-
- nUinlen = getUIDLen(dwUin, szUid);
- nMsglen = strlennull(szMsg);
+ BYTE nUinlen = getUIDLen(dwUin, szUid);
+ WORD nMsglen = strlennull(szMsg);
+ icq_packet packet;
serverPacketInit(&packet, (WORD)(15 + nUinlen + nMsglen));
packFNACHeader(&packet, ICQ_LISTS_FAMILY, ICQ_LISTS_REQUESTAUTH);
packUID(&packet, dwUin, szUid);
@@ -1679,13 +1557,13 @@ void CIcqProto::icq_sendAuthReqServ(DWORD dwUin, char *szUid, const char *szMsg) void CIcqProto::icq_sendAuthResponseServ(DWORD dwUin, char* szUid, int auth, const TCHAR *szReason)
{
- icq_packet packet;
BYTE nUinLen = getUIDLen(dwUin, szUid);
// Prepare custom utf-8 reason
char *szUtfReason = tchar_to_utf8(szReason);
WORD nReasonLen = strlennull(szUtfReason);
+ icq_packet packet;
serverPacketInit(&packet, (WORD)(16 + nUinLen + nReasonLen));
packFNACHeader(&packet, ICQ_LISTS_FAMILY, ICQ_LISTS_CLI_AUTHRESPONSE);
packUID(&packet, dwUin, szUid);
@@ -1701,13 +1579,10 @@ void CIcqProto::icq_sendAuthResponseServ(DWORD dwUin, char* szUid, int auth, con void CIcqProto::icq_sendYouWereAddedServ(DWORD dwUin, DWORD dwMyUin)
{
- icq_packet packet;
- DWORD dwID1;
- DWORD dwID2;
-
- dwID1 = time(NULL);
- dwID2 = RandRange(0, 0x00FF);
+ DWORD dwID1 = time(NULL);
+ DWORD dwID2 = RandRange(0, 0x00FF);
+ icq_packet packet;
packServMsgSendHeader(&packet, 0, dwID1, dwID2, dwUin, NULL, 0x0004, 17);
packWord(&packet, 0x0005); // TLV(5)
packWord(&packet, 0x0009);
@@ -1716,16 +1591,14 @@ void CIcqProto::icq_sendYouWereAddedServ(DWORD dwUin, DWORD dwMyUin) packByte(&packet, 0); // msg-flags
packEmptyMsg(&packet); // NTS
packDWord(&packet, 0x00060000); // TLV(6)
-
sendServPacket(&packet);
}
void CIcqProto::icq_sendXtrazRequestServ(DWORD dwUin, DWORD dwCookie, char* szBody, int nBodyLen, cookie_message_data *pCookieData)
{
- icq_packet packet;
- WORD wCoreLen;
+ WORD wCoreLen = 11 + getPluginTypeIdLen(pCookieData->bMessageType) + nBodyLen;
- wCoreLen = 11 + getPluginTypeIdLen(pCookieData->bMessageType) + nBodyLen;
+ icq_packet packet;
packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, NULL, 2, (WORD)(99 + wCoreLen));
// TLV(5) header
@@ -1752,9 +1625,8 @@ void CIcqProto::icq_sendXtrazRequestServ(DWORD dwUin, DWORD dwCookie, char* szBo void CIcqProto::icq_sendXtrazResponseServ(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szBody, int nBodyLen, int nType)
{
icq_packet packet;
-
packServAdvancedMsgReply(&packet, dwUin, NULL, dwMID, dwMID2, wCookie, ICQ_VERSION, MTYPE_PLUGIN, 0, (WORD)(getPluginTypeIdLen(nType) + 11 + nBodyLen));
- //
+
packEmptyMsg(&packet);
packPluginTypeId(&packet, nType);
@@ -1770,7 +1642,6 @@ void CIcqProto::icq_sendXtrazResponseServ(DWORD dwUin, DWORD dwMID, DWORD dwMID2 void CIcqProto::icq_sendReverseReq(directconnect *dc, DWORD dwCookie, cookie_message_data *pCookie)
{
icq_packet packet;
-
packServMsgSendHeader(&packet, dwCookie, pCookie->dwMsgID1, pCookie->dwMsgID2, dc->dwRemoteUin, NULL, 2, 0x47);
packServTLV5HeaderBasic(&packet, 0x29, pCookie->dwMsgID1, pCookie->dwMsgID2, 0, MCAP_REVERSE_DC_REQ);
@@ -1794,9 +1665,9 @@ void CIcqProto::icq_sendReverseReq(directconnect *dc, DWORD dwCookie, cookie_mes void CIcqProto::icq_sendReverseFailed(directconnect* dc, DWORD dwMsgID1, DWORD dwMsgID2, DWORD dwCookie)
{
- icq_packet packet;
int nUinLen = getUINLen(dc->dwRemoteUin);
+ icq_packet packet;
serverPacketInit(&packet, (WORD)(nUinLen + 74));
packFNACHeader(&packet, ICQ_MSG_FAMILY, ICQ_MSG_RESPONSE, 0, ICQ_MSG_RESPONSE << 0x10 | (dwCookie & 0x7FFF));
packLEDWord(&packet, dwMsgID1); // Msg ID part 1
@@ -1813,21 +1684,20 @@ void CIcqProto::icq_sendReverseFailed(directconnect* dc, DWORD dwMsgID1, DWORD d sendServPacket(&packet);
}
-
// OSCAR file-transfer packets starts here
//
void CIcqProto::oft_sendFileRequest(DWORD dwUin, char *szUid, oscar_filetransfer *ft, const char *pszFiles, DWORD dwLocalInternalIP)
{
- icq_packet packet;
-
size_t size = strlennull(ft->szDescription) + strlennull(pszFiles) + 160;
char *szCoolStr = (char *)_alloca(size);
mir_snprintf(szCoolStr, size, "<ICQ_COOL_FT><FS>%s</FS><S>%I64u</S><SID>1</SID><DESC>%s</DESC></ICQ_COOL_FT>", pszFiles, ft->qwTotalSize, ft->szDescription);
szCoolStr = MangleXml(szCoolStr, strlennull(szCoolStr));
WORD wDataLen = 93 + strlennull(szCoolStr) + strlennull(pszFiles);
- if (ft->bUseProxy) wDataLen += 4;
+ if (ft->bUseProxy)
+ wDataLen += 4;
+ icq_packet packet;
packServMsgSendHeader(&packet, ft->dwCookie, ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, dwUin, szUid, 2, (WORD)(wDataLen + 0x1E));
packServTLV5HeaderBasic(&packet, wDataLen, ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, 0, MCAP_FILE_TRANSFER);
@@ -1852,24 +1722,24 @@ void CIcqProto::oft_sendFileRequest(DWORD dwUin, char *szUid, oscar_filetransfer }
else {
oscar_listener *pListener = (oscar_listener*)ft->listener;
-
packTLVWord(&packet, 0x05, pListener->wPort);
packTLVWord(&packet, 0x15, (WORD)((pListener->wPort) ^ 0x0FFFF));
}
- { // TLV(0x2711)
- packWord(&packet, 0x2711);
- packWord(&packet, (WORD)(9 + strlennull(pszFiles)));
- packWord(&packet, (WORD)(ft->wFilesCount == 1 ? 1 : 2));
- packWord(&packet, ft->wFilesCount);
- packDWord(&packet, (DWORD)ft->qwTotalSize);
- packBuffer(&packet, (LPBYTE)pszFiles, (WORD)(strlennull(pszFiles) + 1));
- }
+
+ // TLV(0x2711)
+ packWord(&packet, 0x2711);
+ packWord(&packet, (WORD)(9 + strlennull(pszFiles)));
+ packWord(&packet, (WORD)(ft->wFilesCount == 1 ? 1 : 2));
+ packWord(&packet, ft->wFilesCount);
+ packDWord(&packet, (DWORD)ft->qwTotalSize);
+ packBuffer(&packet, (LPBYTE)pszFiles, (WORD)(strlennull(pszFiles) + 1));
+
packTLV(&packet, 0x2712, 5, (LPBYTE)"utf-8");
- { // TLV(0x2713)
- packWord(&packet, 0x2713);
- packWord(&packet, 8);
- packQWord(&packet, ft->qwTotalSize);
- }
+
+ // TLV(0x2713)
+ packWord(&packet, 0x2713);
+ packWord(&packet, 8);
+ packQWord(&packet, ft->qwTotalSize);
sendServPacket(&packet); // Send the monster
}
@@ -1878,10 +1748,8 @@ void CIcqProto::oft_sendFileRequest(DWORD dwUin, char *szUid, oscar_filetransfer void CIcqProto::oft_sendFileReply(DWORD dwUin, char *szUid, oscar_filetransfer *ft, WORD wResult)
{
icq_packet packet;
-
packServMsgSendHeader(&packet, 0, ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, dwUin, szUid, 2, 0x1E);
packServTLV5HeaderBasic(&packet, 0, ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, wResult, MCAP_FILE_TRANSFER);
-
sendServPacket(&packet);
}
@@ -1891,39 +1759,31 @@ void CIcqProto::oft_sendFileAccept(DWORD dwUin, char *szUid, oscar_filetransfer oft_sendFileReply(dwUin, szUid, ft, 0x02);
}
-
void CIcqProto::oft_sendFileResponse(DWORD dwUin, char *szUid, oscar_filetransfer *ft, WORD wResponse)
{
icq_packet packet;
-
packServAdvancedReply(&packet, dwUin, szUid, ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, 0, 4);
packWord(&packet, 0x02); // Length of following data
packWord(&packet, wResponse); // Response code
-
sendServPacket(&packet);
}
-
void CIcqProto::oft_sendFileDeny(DWORD dwUin, char *szUid, oscar_filetransfer *ft)
{
- if (dwUin) { // ICQ clients uses special deny file transfer
+ if (dwUin) // ICQ clients uses special deny file transfer
oft_sendFileResponse(dwUin, szUid, ft, 0x01);
- }
else
oft_sendFileReply(dwUin, szUid, ft, 0x01);
}
-
void CIcqProto::oft_sendFileCancel(DWORD dwUin, char *szUid, oscar_filetransfer *ft)
{
oft_sendFileReply(dwUin, szUid, ft, 0x01);
}
-
void CIcqProto::oft_sendFileRedirect(DWORD dwUin, char *szUid, oscar_filetransfer *ft, DWORD dwIP, WORD wPort, int bProxy)
{
icq_packet packet;
-
packServMsgSendHeader(&packet, 0, ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, dwUin, szUid, 2, (WORD)(bProxy ? 0x4a : 0x4e));
packServTLV5HeaderBasic(&packet, (WORD)(bProxy ? 0x2C : 0x30), ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, 0, MCAP_FILE_TRANSFER);
// Connection point data
diff --git a/protocols/IcqOscarJ/src/stdpackets.h b/protocols/IcqOscarJ/src/stdpackets.h index b656d713c6..7cb0b75ede 100644 --- a/protocols/IcqOscarJ/src/stdpackets.h +++ b/protocols/IcqOscarJ/src/stdpackets.h @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2008 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,13 +21,12 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Low-level functions that really sends data to server
-//
// -----------------------------------------------------------------------------
+
#ifndef __STDPACKETS_H
#define __STDPACKETS_H
diff --git a/protocols/IcqOscarJ/src/tlv.cpp b/protocols/IcqOscarJ/src/tlv.cpp index 7c4eafca3a..ad1846e167 100644 --- a/protocols/IcqOscarJ/src/tlv.cpp +++ b/protocols/IcqOscarJ/src/tlv.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2009 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,16 +21,13 @@ // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//
// -----------------------------------------------------------------------------
// DESCRIPTION:
//
// Helper functions for Oscar TLV chains
-//
// -----------------------------------------------------------------------------
-#include "icqoscar.h"
-
+#include "icqoscar.h"
/* set maxTlvs<=0 to get all TLVs in length, or a positive integer to get at most the first n */
oscar_tlv_chain* readIntoTLVChain(BYTE **buf, WORD wLen, int maxTlvs)
@@ -38,14 +36,13 @@ oscar_tlv_chain* readIntoTLVChain(BYTE **buf, WORD wLen, int maxTlvs) WORD now_tlv_len;
int len = wLen;
- if (!buf || !wLen) return NULL;
+ if (!buf || !wLen)
+ return NULL;
- while (len > 0) /* don't use unsigned variable for this check */
- {
+ while (len > 0) { /* don't use unsigned variable for this check */
now = (oscar_tlv_chain *)SAFE_MALLOC(sizeof(oscar_tlv_chain));
- if (!now)
- {
+ if (!now) {
disposeChain(&chain);
return NULL;
}
@@ -56,17 +53,13 @@ oscar_tlv_chain* readIntoTLVChain(BYTE **buf, WORD wLen, int maxTlvs) len -= 4;
if (now_tlv_len < 1)
- {
now->tlv.pData = NULL;
- }
- else if (now_tlv_len <= len)
- {
+ else if (now_tlv_len <= len) {
now->tlv.pData = (BYTE *)SAFE_MALLOC(now_tlv_len);
if (now->tlv.pData)
memcpy(now->tlv.pData, *buf, now_tlv_len);
}
- else
- { // the packet is shorter than it should be
+ else { // the packet is shorter than it should be
SAFE_FREE((void**)&now);
return chain; // give at least the rest of chain
}
@@ -97,8 +90,7 @@ oscar_tlv* oscar_tlv_chain::getTLV(WORD wType, WORD wIndex) int i = 0;
oscar_tlv_chain *list = this;
- while (list)
- {
+ while (list) {
if (list->tlv.wType == wType)
i++;
if (i >= wIndex)
@@ -109,45 +101,37 @@ oscar_tlv* oscar_tlv_chain::getTLV(WORD wType, WORD wIndex) return NULL;
}
-
WORD oscar_tlv_chain::getChainLength()
{
int len = 0;
oscar_tlv_chain *list = this;
- while (list)
- {
+ while (list) {
len += list->tlv.wLen + 4;
list = list->next;
}
return len;
}
-
oscar_tlv* oscar_tlv_chain::putTLV(WORD wType, WORD wLen, BYTE *pData, BOOL bReplace)
{
oscar_tlv *tlv = getTLV(wType, 1);
if (tlv && bReplace)
- {
SAFE_FREE((void**)&tlv->pData);
- }
- else
- {
+ else {
oscar_tlv_chain *last = this;
while (last && last->next)
last = last->next;
- if (last)
- {
+ if (last) {
last->next = (oscar_tlv_chain*)SAFE_MALLOC(sizeof(oscar_tlv_chain));
tlv = &last->next->tlv;
tlv->wType = wType;
}
}
- if (tlv)
- {
+ if (tlv) {
tlv->wLen = wLen;
tlv->pData = (PBYTE)SAFE_MALLOC(wLen);
memcpy(tlv->pData, pData, wLen);
@@ -155,19 +139,14 @@ oscar_tlv* oscar_tlv_chain::putTLV(WORD wType, WORD wLen, BYTE *pData, BOOL bRep return tlv;
}
-
oscar_tlv_chain* oscar_tlv_chain::removeTLV(oscar_tlv *tlv)
{
oscar_tlv_chain *list = this, *prev = NULL, *chain = this;
-
- while (list)
- {
- if (&list->tlv == tlv)
- {
+ while (list) {
+ if (&list->tlv == tlv) {
if (prev) // relink
prev->next = list->next;
- else if (list->next)
- { // move second item's tlv to the first item
+ else if (list->next) { // move second item's tlv to the first item
list->tlv = list->next->tlv;
list = list->next;
}
@@ -184,7 +163,6 @@ oscar_tlv_chain* oscar_tlv_chain::removeTLV(oscar_tlv *tlv) return chain;
}
-
WORD oscar_tlv_chain::getLength(WORD wType, WORD wIndex)
{
oscar_tlv *tlv = getTLV(wType, wIndex);
@@ -194,7 +172,6 @@ WORD oscar_tlv_chain::getLength(WORD wType, WORD wIndex) return 0;
}
-
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Values are returned in MSB format */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
@@ -204,53 +181,44 @@ DWORD oscar_tlv_chain::getDWord(WORD wType, WORD wIndex) DWORD dw = 0;
oscar_tlv *tlv = getTLV(wType, wIndex);
- if (tlv && tlv->wLen >= 4)
- {
- dw |= (*((tlv->pData)+0) << 24);
- dw |= (*((tlv->pData)+1) << 16);
- dw |= (*((tlv->pData)+2) << 8);
- dw |= (*((tlv->pData)+3));
+ if (tlv && tlv->wLen >= 4) {
+ dw |= (*((tlv->pData) + 0) << 24);
+ dw |= (*((tlv->pData) + 1) << 16);
+ dw |= (*((tlv->pData) + 2) << 8);
+ dw |= (*((tlv->pData) + 3));
}
return dw;
}
-
WORD oscar_tlv_chain::getWord(WORD wType, WORD wIndex)
{
WORD w = 0;
oscar_tlv *tlv = getTLV(wType, wIndex);
- if (tlv && tlv->wLen >= 2)
- {
- w |= (*((tlv->pData)+0) << 8);
- w |= (*((tlv->pData)+1));
+ if (tlv && tlv->wLen >= 2) {
+ w |= (*((tlv->pData) + 0) << 8);
+ w |= (*((tlv->pData) + 1));
}
return w;
}
-
BYTE oscar_tlv_chain::getByte(WORD wType, WORD wIndex)
{
BYTE b = 0;
oscar_tlv *tlv = getTLV(wType, wIndex);
if (tlv && tlv->wLen)
- {
b = *(tlv->pData);
- }
return b;
}
-
int oscar_tlv_chain::getNumber(WORD wType, WORD wIndex)
{
oscar_tlv *tlv = getTLV(wType, wIndex);
-
- if (tlv)
- {
+ if (tlv) {
if (tlv->wLen == 1)
return getByte(wType, wIndex);
else if (tlv->wLen == 2)
@@ -261,13 +229,10 @@ int oscar_tlv_chain::getNumber(WORD wType, WORD wIndex) return 0;
}
-
double oscar_tlv_chain::getDouble(WORD wType, WORD wIndex)
{
oscar_tlv *tlv = getTLV(wType, wIndex);
-
- if (tlv && tlv->wLen == 8)
- {
+ if (tlv && tlv->wLen == 8) {
BYTE *buf = tlv->pData;
double d = 0;
@@ -278,14 +243,12 @@ double oscar_tlv_chain::getDouble(WORD wType, WORD wIndex) return 0;
}
-
char* oscar_tlv_chain::getString(WORD wType, WORD wIndex)
{
char *str = NULL;
oscar_tlv *tlv = getTLV(wType, wIndex);
- if (tlv)
- {
+ if (tlv) {
str = (char*)SAFE_MALLOC(tlv->wLen + 1); /* For \0 */
if (!str) return NULL;
@@ -297,7 +260,6 @@ char* oscar_tlv_chain::getString(WORD wType, WORD wIndex) return str;
}
-
void disposeChain(oscar_tlv_chain **chain)
{
if (!chain || !*chain)
@@ -305,8 +267,7 @@ void disposeChain(oscar_tlv_chain **chain) oscar_tlv_chain *now = *chain;
- while (now)
- {
+ while (now) {
oscar_tlv_chain *next = now->next;
SAFE_FREE((void**)&now->tlv.pData);
@@ -317,19 +278,16 @@ void disposeChain(oscar_tlv_chain **chain) *chain = NULL;
}
-
oscar_tlv_record_list* readIntoTLVRecordList(BYTE **buf, WORD wLen, int nCount)
{
oscar_tlv_record_list *list = NULL, *last;
- while (wLen >= 2)
- {
+ while (wLen >= 2) {
WORD wRecordSize;
unpackWord(buf, &wRecordSize);
wLen -= 2;
- if (wRecordSize && wRecordSize <= wLen)
- {
+ if (wRecordSize && wRecordSize <= wLen) {
oscar_tlv_record_list *pRecord = (oscar_tlv_record_list*)SAFE_MALLOC(sizeof(oscar_tlv_record_list));
BYTE *pData = *buf;
@@ -337,8 +295,7 @@ oscar_tlv_record_list* readIntoTLVRecordList(BYTE **buf, WORD wLen, int nCount) wLen -= wRecordSize;
pRecord->item = readIntoTLVChain(&pData, wRecordSize, 0);
- if (pRecord->item)
- { // keep the order
+ if (pRecord->item) { // keep the order
if (list)
last->next = pRecord;
else
@@ -346,16 +303,15 @@ oscar_tlv_record_list* readIntoTLVRecordList(BYTE **buf, WORD wLen, int nCount) last = pRecord;
}
- else
- SAFE_FREE((void**)&pRecord);
+ else SAFE_FREE((void**)&pRecord);
}
- if (--nCount == 0) break;
+ if (--nCount == 0)
+ break;
}
return list;
}
-
void disposeRecordList(oscar_tlv_record_list** list)
{
if (!list || !*list)
@@ -363,8 +319,7 @@ void disposeRecordList(oscar_tlv_record_list** list) oscar_tlv_record_list *now = *list;
- while (now)
- {
+ while (now) {
oscar_tlv_record_list *next = now->next;
disposeChain(&now->item);
@@ -375,13 +330,10 @@ void disposeRecordList(oscar_tlv_record_list** list) *list = NULL;
}
-
oscar_tlv_chain* oscar_tlv_record_list::getRecordByTLV(WORD wType, int nValue)
{
oscar_tlv_record_list *list = this;
-
- while (list)
- {
+ while (list) {
if (list->item && list->item->getTLV(wType, 1) && list->item->getNumber(wType, 1) == nValue)
return list->item;
list = list->next;
diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp index 1843f443bc..dd09f132cf 100644 --- a/protocols/IcqOscarJ/src/utilities.cpp +++ b/protocols/IcqOscarJ/src/utilities.cpp @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -284,10 +285,9 @@ DWORD GetGatewayIndex(HANDLE hConn) {
icq_lock l(gatewayMutex);
- for (int i = 0; i < gatewayCount; i++) {
+ for (int i = 0; i < gatewayCount; i++)
if (hConn == gateways[i].hConn)
return gateways[i].dwIndex;
- }
return 1; // this is default
}
diff --git a/protocols/IcqOscarJ/src/utilities.h b/protocols/IcqOscarJ/src/utilities.h index 1c6459d6f0..b2016f4802 100644 --- a/protocols/IcqOscarJ/src/utilities.h +++ b/protocols/IcqOscarJ/src/utilities.h @@ -6,6 +6,7 @@ // Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
+// Copyright © 2012-2014 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
diff --git a/protocols/IcqOscarJ/src/version.h b/protocols/IcqOscarJ/src/version.h index 15ef33802d..969cfdf916 100644 --- a/protocols/IcqOscarJ/src/version.h +++ b/protocols/IcqOscarJ/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 11
#define __RELEASE_NUM 2
-#define __BUILD_NUM 2
+#define __BUILD_NUM 3
#include <stdver.h>
|