summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/IcqOscarJ/src/fam_01service.cpp4
-rw-r--r--protocols/IcqOscarJ/src/fam_04message.cpp1
-rw-r--r--protocols/IcqOscarJ/src/icq_clients.cpp119
-rw-r--r--protocols/IcqOscarJ/src/icq_proto.cpp30
-rw-r--r--protocols/IcqOscarJ/src/icq_servlist.cpp32
-rw-r--r--protocols/IcqOscarJ/src/icq_uploadui.cpp12
-rw-r--r--protocols/IcqOscarJ/src/icqosc_svcs.cpp13
-rw-r--r--protocols/IcqOscarJ/src/oscar_filetransfer.cpp6
-rw-r--r--protocols/IcqOscarJ/src/utilities.cpp1
9 files changed, 94 insertions, 124 deletions
diff --git a/protocols/IcqOscarJ/src/fam_01service.cpp b/protocols/IcqOscarJ/src/fam_01service.cpp
index 3042967e53..6363ab8d4f 100644
--- a/protocols/IcqOscarJ/src/fam_01service.cpp
+++ b/protocols/IcqOscarJ/src/fam_01service.cpp
@@ -468,8 +468,6 @@ char* CIcqProto::buildUinList(int subtype, size_t wMaxLen, MCONTACT *hContactRes
{
MCONTACT hContact;
WORD wCurrentLen = 0;
- DWORD dwUIN;
- uid_str szUID;
int add;
char *szList = (char*)SAFE_MALLOC(CallService(MS_DB_CONTACT_GETCOUNT, 0, 0) * UINMAXLEN);
@@ -483,6 +481,8 @@ char* CIcqProto::buildUinList(int subtype, size_t wMaxLen, MCONTACT *hContactRes
hContact = db_find_first(m_szModuleName);
while (hContact != NULL) {
+ DWORD dwUIN;
+ uid_str szUID;
if (!getContactUid(hContact, &dwUIN, &szUID)) {
szLen[0] = (char)mir_strlen(strUID(dwUIN, szUID));
diff --git a/protocols/IcqOscarJ/src/fam_04message.cpp b/protocols/IcqOscarJ/src/fam_04message.cpp
index afaa6e59bb..288d129b6e 100644
--- a/protocols/IcqOscarJ/src/fam_04message.cpp
+++ b/protocols/IcqOscarJ/src/fam_04message.cpp
@@ -2250,7 +2250,6 @@ void CIcqProto::handleRecvServMsgError(BYTE *buf, size_t wLen, DWORD dwSequence)
// all packet cookies from msg family has command 0 in the queue
DWORD dwUin;
uid_str szUid;
-
if (getContactUid(hContact, &dwUin, &szUid)) {
// Invalid contact
FreeCookie((WORD)dwSequence);
diff --git a/protocols/IcqOscarJ/src/icq_clients.cpp b/protocols/IcqOscarJ/src/icq_clients.cpp
index 51d3385d84..2fd5be96a9 100644
--- a/protocols/IcqOscarJ/src/icq_clients.cpp
+++ b/protocols/IcqOscarJ/src/icq_clients.cpp
@@ -46,10 +46,10 @@ static const char* makeClientVersion(char *szBuf, const char *szClient, unsigned
static void verToStr(char *szStr, int v)
{
char szVer[64];
-
- makeClientVersion(szVer, "", (v>>24)&0x7F, (v>>16)&0xFF, (v>>8)&0xFF, v&0xFF);
+ makeClientVersion(szVer, "", (v >> 24) & 0x7F, (v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF);
strcat(szStr, szVer);
- if (v&0x80000000) strcat(szStr, " alpha");
+ if (v & 0x80000000)
+ strcat(szStr, " alpha");
}
static char* MirandaVersionToStringEx(char* szStr, int bUnicode, const char* szPlug, int v, int m)
@@ -61,7 +61,7 @@ static char* MirandaVersionToStringEx(char* szStr, int bUnicode, const char* szP
if (!m && v == 1)
verToStr(szStr, 0x80010200);
- else if (!m && (v&0x7FFFFFFF) <= 0x030301)
+ else if (!m && (v & 0x7FFFFFFF) <= 0x030301)
verToStr(szStr, v);
else {
if (m) {
@@ -82,17 +82,16 @@ static char* MirandaVersionToStringEx(char* szStr, int bUnicode, const char* szP
}
char* MirandaModToString(char* szStr, capstr* capId, int bUnicode, const char* szModName)
-{ // decode icqj mod version
- char* szClient;
+{
+ // decode icqj mod version
DWORD mver = (*capId)[0x4] << 0x18 | (*capId)[0x5] << 0x10 | (*capId)[0x6] << 8 | (*capId)[0x7];
DWORD iver = (*capId)[0x8] << 0x18 | (*capId)[0x9] << 0x10 | (*capId)[0xA] << 8 | (*capId)[0xB];
DWORD scode = (*capId)[0xC] << 0x18 | (*capId)[0xD] << 0x10 | (*capId)[0xE] << 8 | (*capId)[0xF];
- szClient = MirandaVersionToStringEx(szStr, bUnicode, szModName, iver, mver);
+ char *szClient = MirandaVersionToStringEx(szStr, bUnicode, szModName, iver, mver);
if (scode == 0x5AFEC0DE)
- {
strcat(szClient, " + SecureIM");
- }
+
return szClient;
}
@@ -199,20 +198,13 @@ const char* CIcqProto::detectUserClient(
*bClientId = CLID_ALTERNATIVE; // Most clients does not tick as MsgIDs
// Is this a Miranda IM client?
- if (dwFT1 == 0xffffffff)
- {
- if (dwFT2 == 0xffffffff)
- { // This is Gaim not Miranda
+ if (dwFT1 == 0xffffffff) {
+ if (dwFT2 == 0xffffffff) // This is Gaim not Miranda
szClient = "Gaim";
- }
- else if (!dwFT2 && wVersion == 7)
- { // This is WebICQ not Miranda
+ else if (!dwFT2 && wVersion == 7) // This is WebICQ not Miranda
szClient = "WebICQ";
- }
- else if (!dwFT2 && dwFT3 == 0x3B7248ED)
- { // And this is most probably Spam Bot
+ else if (!dwFT2 && dwFT3 == 0x3B7248ED) // And this is most probably Spam Bot
szClient = cliSpamBot;
- }
else {
// Yes this is most probably Miranda, get the version info
szClient = MirandaVersionToStringEx(szClientBuf, 0, "ICQ", dwFT2, 0);
@@ -239,10 +231,9 @@ const char* CIcqProto::detectUserClient(
else if (dwFT1 == 0xffffff42)
szClient = "mICQ";
else if (dwFT1 == 0xffffffbe) {
- unsigned ver1 = (dwFT2>>24)&0xFF;
- unsigned ver2 = (dwFT2>>16)&0xFF;
- unsigned ver3 = (dwFT2>>8)&0xFF;
-
+ unsigned ver1 = (dwFT2 >> 24) & 0xFF;
+ unsigned ver2 = (dwFT2 >> 16) & 0xFF;
+ unsigned ver3 = (dwFT2 >> 8) & 0xFF;
szClient = makeClientVersion(szClientBuf, "Alicq ", ver1, ver2, ver3, 0);
}
else if (dwFT1 == 0xFFFFFF7F)
@@ -293,7 +284,7 @@ const char* CIcqProto::detectUserClient(
szClient = szClientBuf;
}
else if (dwFT1 == dwFT2 && dwFT2 == dwFT3 && wVersion == 8) {
- if ((dwFT1 < dwOnlineSince + 3600) && (dwFT1 > (dwOnlineSince - 3600)))
+ if ((dwFT1 < dwOnlineSince + 3600) && (dwFT1 >(dwOnlineSince - 3600)))
szClient = cliSpamBot;
}
else if (!dwFT1 && !dwFT2 && !dwFT3 && !wVersion && !wLen && dwWebPort == 0x75BB)
@@ -401,9 +392,9 @@ const char* CIcqProto::detectUserClient(
szClient = makeClientVersion(szClientBuf, "SIM ", ver1, ver2, ver3, ver4 & 0x0F);
if (ver4 & 0x80)
- strcat(szClientBuf,"/Win32");
+ strcat(szClientBuf, "/Win32");
else if (ver4 & 0x40)
- strcat(szClientBuf,"/MacOS X");
+ strcat(szClientBuf, "/MacOS X");
}
else if (capId = MatchCapability(caps, wLen, &capLicq, 0xC)) {
unsigned ver1 = (*capId)[0xC];
@@ -412,7 +403,7 @@ const char* CIcqProto::detectUserClient(
szClient = makeClientVersion(szClientBuf, cliLicqVer, ver1, ver2, ver3, 0);
if ((*capId)[0xF])
- strcat(szClientBuf,"/SSL");
+ strcat(szClientBuf, "/SSL");
}
else if (capId = MatchCapability(caps, wLen, &capKopete, 0xC)) {
unsigned ver1 = (*capId)[0xC];
@@ -477,7 +468,6 @@ const char* CIcqProto::detectUserClient(
else if (MatchCapability(caps, wLen, &capQipMobile))
szClient = "QIP Mobile (Java)";
else if (MatchCapability(caps, wLen, &capQipInfium)) {
-
strcpy(szClientBuf, "QIP Infium");
if (dwFT1) {
mir_snprintf(ver, SIZEOF(ver), " (%d)", dwFT1);
@@ -561,19 +551,17 @@ const char* CIcqProto::detectUserClient(
unsigned ver2 = (*capId)[0xD];
unsigned ver3 = (*capId)[0xE];
unsigned ver4 = (*capId)[0xF];
-
szClient = makeClientVersion(szClientBuf, "JICQ ", ver1, ver2, ver3, ver4);
}
// http://www.inlusoft.com
else if (MatchCapability(caps, wLen, &capInluxMsgr))
szClient = "Inlux Messenger";
// http://mip.rufon.net
- else if (capId = MatchCapability(caps, wLen, &capMipClient, 0xC)) {
+ else if (capId = MatchCapability(caps, wLen, &capMipClient, 0xC)) {
unsigned ver1 = (*capId)[0xC];
unsigned ver2 = (*capId)[0xD];
unsigned ver3 = (*capId)[0xE];
unsigned ver4 = (*capId)[0xF];
-
if (ver1 < 30)
makeClientVersion(szClientBuf, "MIP ", ver1, ver2, ver3, ver4);
else {
@@ -600,7 +588,7 @@ const char* CIcqProto::detectUserClient(
szClient = szClientBuf;
}
// http://yapp.ru
- else if (capId = MatchCapability(caps, wLen, &capYapp, 0x04)) {
+ else if (capId = MatchCapability(caps, wLen, &capYapp, 0x04)) {
strcpy(szClientBuf, "Yapp! v");
strncat(szClientBuf, (char*)(*capId) + 8, 5);
szClient = szClientBuf;
@@ -618,11 +606,10 @@ const char* CIcqProto::detectUserClient(
else if (MatchCapability(caps, wLen, &capPigeon, 0x07))
szClient = "PIGEON!";
// http://www.qutim.org
- else if (capId = MatchCapability(caps, wLen, &capQutIm, 0x05)) {
+ else if (capId = MatchCapability(caps, wLen, &capQutIm, 0x05)) {
if ((*capId)[0x6] == 0x2E) { // old qutim id
unsigned ver1 = (*capId)[0x5] - 0x30;
unsigned ver2 = (*capId)[0x7] - 0x30;
-
makeClientVersion(szClientBuf, "qutIM ", ver1, ver2, 0, 0);
}
else { // new qutim id
@@ -661,7 +648,6 @@ const char* CIcqProto::detectUserClient(
unsigned ver2 = (*capId)[0x8];
unsigned ver3 = (*capId)[0x9];
unsigned ver4 = (*capId)[0xA];
-
szClient = makeClientVersion(szClientBuf, "IcqKid2 v", ver1, ver2, ver3, ver4);
}
// http://intrigue.ru/workshop/webicqpro/webicqpro.html
@@ -671,7 +657,7 @@ const char* CIcqProto::detectUserClient(
else if (capId = MatchCapability(caps, wLen, &capCitron))
szClient = "Citron IM";
// try to determine which client is behind libicq2000
- else if (szClient == cliLibicq2k) {
+ else if (szClient == cliLibicq2k) {
if (CheckContactCapabilities(hContact, CAPF_RTF))
szClient = cliCentericq; // centericq added rtf capability to libicq2000
else if (CheckContactCapabilities(hContact, CAPF_UTF))
@@ -715,10 +701,9 @@ const char* CIcqProto::detectUserClient(
}
}
// libpurple (e.g. Pidgin 2.7.x)
- else if (CheckContactCapabilities(hContact, CAPF_SRV_RELAY | CAPF_UTF | CAPF_TYPING | CAPF_XTRAZ) &&
+ else if (CheckContactCapabilities(hContact, CAPF_SRV_RELAY | CAPF_UTF | CAPF_TYPING | CAPF_XTRAZ) &&
MatchCapability(caps, wLen, &capOscarChat) && MatchShortCapability(caps, wLen, &capAimIcon) &&
- MatchCapability(caps, wLen, &capFakeHtml))
- {
+ MatchCapability(caps, wLen, &capFakeHtml)) {
if (MatchShortCapability(caps, wLen, &capAimDirect))
szClient = "libpurple";
else
@@ -740,9 +725,8 @@ const char* CIcqProto::detectUserClient(
if (CheckContactCapabilities(hContact, CAPF_OSCAR_FILE)) {
if (MatchCapability(caps, wLen, &captZers)) {
// capable of tZers ?
- if ( MatchCapability(caps, wLen, &capIcqLiteNew) && MatchShortCapability(caps, wLen, &capStatusTextAware) &&
- MatchShortCapability(caps, wLen, &capAimLiveVideo) && MatchShortCapability(caps, wLen, &capAimLiveAudio))
- {
+ if (MatchCapability(caps, wLen, &capIcqLiteNew) && MatchShortCapability(caps, wLen, &capStatusTextAware) &&
+ MatchShortCapability(caps, wLen, &capAimLiveVideo) && MatchShortCapability(caps, wLen, &capAimLiveAudio)) {
strcpy(szClientBuf, "ICQ 7");
}
else if (MatchCapability(caps, wLen, &capFakeHtml)) {
@@ -816,7 +800,7 @@ const char* CIcqProto::detectUserClient(
}
}
else if (wVersion == 0xA) {
- if ( !CheckContactCapabilities(hContact, CAPF_RTF) && !CheckContactCapabilities(hContact, CAPF_UTF)) {
+ if (!CheckContactCapabilities(hContact, CAPF_RTF) && !CheckContactCapabilities(hContact, CAPF_UTF)) {
// this is bad, but we must do it - try to detect QNext
ClearContactCapabilities(hContact, CAPF_SRV_RELAY);
debugLogA("Forcing simple messages (QNext client).");
@@ -840,8 +824,7 @@ const char* CIcqProto::detectUserClient(
MatchCapability(caps, wLen, &capIs2002) && MatchCapability(caps, wLen, &capComm20012))
szClient = cliSpamBot;
else if (MatchShortCapability(caps, wLen, &capAimIcon) && MatchShortCapability(caps, wLen, &capAimDirect) &&
- CheckContactCapabilities(hContact, CAPF_OSCAR_FILE | CAPF_UTF))
- { // detect libgaim/libpurple versions
+ CheckContactCapabilities(hContact, CAPF_OSCAR_FILE | CAPF_UTF)) { // detect libgaim/libpurple versions
if (CheckContactCapabilities(hContact, CAPF_SRV_RELAY))
szClient = "Adium X"; // yeah, AFAIK only Adium has this fixed
else if (CheckContactCapabilities(hContact, CAPF_TYPING))
@@ -888,7 +871,6 @@ const char* CIcqProto::detectUserClient(
// AimOscar Signature
DWORD aver = (*capId)[0xC] << 0x18 | (*capId)[0xD] << 0x10 | (*capId)[0xE] << 8 | (*capId)[0xF];
DWORD mver = (*capId)[0x8] << 0x18 | (*capId)[0x9] << 0x10 | (*capId)[0xA] << 8 | (*capId)[0xB];
-
szClient = MirandaVersionToStringEx(szClientBuf, 0, "AimOscar", aver, mver);
bMirandaIM = TRUE;
}
@@ -897,19 +879,18 @@ const char* CIcqProto::detectUserClient(
unsigned ver1 = (*capId)[0xC];
unsigned ver2 = (*capId)[0xD];
unsigned ver3 = (*capId)[0xE];
-
szClient = makeClientVersion(szClientBuf, "SIM ", ver1, ver2, ver3, 0);
+
if ((*capId)[0xF] & 0x80)
- strcat(szClientBuf,"/Win32");
+ strcat(szClientBuf, "/Win32");
else if ((*capId)[0xF] & 0x40)
- strcat(szClientBuf,"/MacOS X");
+ strcat(szClientBuf, "/MacOS X");
}
else if (capId = MatchCapability(caps, wLen, &capKopete, 0xC)) {
unsigned ver1 = (*capId)[0xC];
unsigned ver2 = (*capId)[0xD];
unsigned ver3 = (*capId)[0xE];
unsigned ver4 = (*capId)[0xF];
-
szClient = makeClientVersion(szClientBuf, "Kopete ", ver1, ver2, ver3, ver4);
}
else if (MatchCapability(caps, wLen, &capIm2))
@@ -920,34 +901,44 @@ const char* CIcqProto::detectUserClient(
// http://www.dibsby.com
else if (MatchCapability(caps, wLen, &capDigsby, 0x06) || MatchCapability(caps, wLen, &capDigsbyBeta))
szClient = "Digsby";
- else if (MatchShortCapability(caps, wLen, &capAimIcon) && MatchCapability(caps, wLen, &capOscarChat) &&
+ else if (MatchShortCapability(caps, wLen, &capAimIcon) && MatchCapability(caps, wLen, &capOscarChat) &&
CheckContactCapabilities(hContact, CAPF_UTF | CAPF_TYPING) && wLen == 0x40)
szClient = "Meebo";
// libpurple (e.g. Pidgin 2.7.x)
- else if (wLen == 0x90 && CheckContactCapabilities(hContact, CAPF_SRV_RELAY | CAPF_UTF | CAPF_TYPING | CAPF_XTRAZ) &&
- MatchCapability(caps, wLen, &capOscarChat) && MatchShortCapability(caps, wLen, &capAimIcon) &&
- MatchShortCapability(caps, wLen, &capAimDirect) && MatchCapability(caps, wLen, &capFakeHtml))
+ else if (wLen == 0x90 && CheckContactCapabilities(hContact, CAPF_SRV_RELAY | CAPF_UTF | CAPF_TYPING | CAPF_XTRAZ) &&
+ MatchCapability(caps, wLen, &capOscarChat) && MatchShortCapability(caps, wLen, &capAimIcon) &&
+ MatchShortCapability(caps, wLen, &capAimDirect) && MatchCapability(caps, wLen, &capFakeHtml))
szClient = "libpurple";
// libpurple - Meebo (without DirectIM and OFT)
- else if (wLen == 0x70 && CheckContactCapabilities(hContact, CAPF_SRV_RELAY | CAPF_UTF | CAPF_TYPING | CAPF_XTRAZ) &&
- MatchCapability(caps, wLen, &capOscarChat) && MatchShortCapability(caps, wLen, &capAimIcon) &&
- MatchCapability(caps, wLen, &capFakeHtml))
+ else if (wLen == 0x70 && CheckContactCapabilities(hContact, CAPF_SRV_RELAY | CAPF_UTF | CAPF_TYPING | CAPF_XTRAZ) &&
+ MatchCapability(caps, wLen, &capOscarChat) && MatchShortCapability(caps, wLen, &capAimIcon) &&
+ MatchCapability(caps, wLen, &capFakeHtml))
szClient = "Meebo";
else
szClient = "AIM";
}
- else if(wUserClass & CLASS_WIRELESS)
+ else if (wUserClass & CLASS_WIRELESS)
szClient = "AIM (Mobile)";
- else
- szClient = "AIM";
+ else {
+ DWORD dwUin;
+ uid_str szUid;
+ getContactUid(hContact, &dwUin, &szUid);
+ if (szUid[0]) {
+ if (strstr(szUid, "@bk.ru") || strstr(szUid, "@list.ru") || strstr(szUid, "@mail.ru") || strstr(szUid, "@inbox.ru"))
+ szClient = "MRA client";
+ }
+
+ if (szClient == NULL)
+ szClient = "AIM";
+ }
}
// custom miranda packs
if (caps && bMirandaIM) {
- capstr* capId;
- if (capId = MatchCapability(caps, wLen, &capMimPack, 4)) {
+ capstr *capId = MatchCapability(caps, wLen, &capMimPack, 4);
+ if (capId) {
char szPack[16];
- mir_snprintf(szPack, SIZEOF(szPack), " [%.12s]", (*capId)+4);
+ mir_snprintf(szPack, SIZEOF(szPack), " [%.12s]", (*capId) + 4);
// make sure client string is not constant
if (szClient != szClientBuf) {
diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp
index 45c3e87768..c811a77704 100644
--- a/protocols/IcqOscarJ/src/icq_proto.cpp
+++ b/protocols/IcqOscarJ/src/icq_proto.cpp
@@ -468,7 +468,6 @@ HANDLE __cdecl CIcqProto::FileAllow(MCONTACT hContact, HANDLE hTransfer, const T
{
DWORD dwUin;
uid_str szUid;
-
if (getContactUid(hContact, &dwUin, &szUid))
return 0; // Invalid contact
@@ -538,10 +537,10 @@ int __cdecl CIcqProto::FileCancel(MCONTACT hContact, HANDLE hTransfer)
int __cdecl CIcqProto::FileDeny(MCONTACT hContact, HANDLE hTransfer, const TCHAR* szReason)
{
int nReturnValue = 1;
- DWORD dwUin;
- uid_str szUid;
basic_filetransfer *ft = (basic_filetransfer*)hTransfer;
+ DWORD dwUin;
+ uid_str szUid;
if (getContactUid(hContact, &dwUin, &szUid))
return 1; // Invalid contact
@@ -694,7 +693,6 @@ int __cdecl CIcqProto::GetInfo(MCONTACT hContact, int infoType)
if (icqOnline()) {
DWORD dwUin;
uid_str szUid;
-
if (getContactUid(hContact, &dwUin, &szUid))
return 1; // Invalid contact
@@ -945,27 +943,20 @@ int __cdecl CIcqProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT* pre)
int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int, int nContacts, MCONTACT *hContactsList)
{
if (hContact && hContactsList) {
- int i;
DWORD dwUin;
uid_str szUid;
- WORD wRecipientStatus;
- DWORD dwCookie;
-
- if (getContactUid(hContact, &dwUin, &szUid)) { // Invalid contact
+ if (getContactUid(hContact, &dwUin, &szUid)) // Invalid contact
return ReportGenericSendError(hContact, ACKTYPE_CONTACTS, "The receiver has an invalid user ID.");
- }
- wRecipientStatus = getContactStatus(hContact);
+ WORD wRecipientStatus = getContactStatus(hContact);
// Failures
- if (!icqOnline()) {
+ DWORD dwCookie;
+ if (!icqOnline())
dwCookie = ReportGenericSendError(hContact, ACKTYPE_CONTACTS, "You cannot send messages when you are offline.");
- }
- else if (!hContactsList || (nContacts < 1) || (nContacts > MAX_CONTACTSSEND)) {
+ else if (!hContactsList || (nContacts < 1) || (nContacts > MAX_CONTACTSSEND))
dwCookie = ReportGenericSendError(hContact, ACKTYPE_CONTACTS, "Bad data (internal error #1)");
- }
- // OK
- else {
+ else { // OK
if (CheckContactCapabilities(hContact, CAPF_CONTACTS) && wRecipientStatus != ID_STATUS_OFFLINE) { // Use the new format if possible
struct icq_contactsend_s* contacts = NULL;
@@ -976,6 +967,7 @@ int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int, int nContacts, MCONT
memset(contacts, 0, (sizeof(struct icq_contactsend_s) * nContacts));
size_t nDataLen = 0, nNamesLen = 0;
+ int i;
for (i = 0; i < nContacts; i++) {
uid_str szContactUid;
@@ -1082,7 +1074,7 @@ int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int, int nContacts, MCONT
char szCount[17];
struct icq_contactsend_s* contacts = NULL;
uid_str szContactUid;
-
+ int i;
// Format the body
// This is kinda messy, but there is no simple way to do it. First
@@ -1195,7 +1187,6 @@ HANDLE __cdecl CIcqProto::SendFile(MCONTACT hContact, const TCHAR* szDescription
if (hContact && szDescription && ppszFiles) {
DWORD dwUin;
uid_str szUid;
-
if (getContactUid(hContact, &dwUin, &szUid))
return 0; // Invalid contact
@@ -1490,7 +1481,6 @@ int __cdecl CIcqProto::SetApparentMode(MCONTACT hContact, int mode)
{
DWORD uin;
uid_str uid;
-
if (getContactUid(hContact, &uin, &uid))
return 1; // Invalid contact
diff --git a/protocols/IcqOscarJ/src/icq_servlist.cpp b/protocols/IcqOscarJ/src/icq_servlist.cpp
index 20b52d5396..72061b91ca 100644
--- a/protocols/IcqOscarJ/src/icq_servlist.cpp
+++ b/protocols/IcqOscarJ/src/icq_servlist.cpp
@@ -1013,27 +1013,22 @@ DWORD CIcqProto::icq_sendServerItem(DWORD dwCookie, WORD wAction, WORD wGroupId,
DWORD CIcqProto::icq_sendServerContact(MCONTACT hContact, DWORD dwCookie, WORD wAction, WORD wGroupId, WORD wContactId, DWORD dwOperation, DWORD dwTimeout, void **doubleObject)
{
- DWORD dwUin;
- uid_str szUid;
- icq_packet pBuffer;
- char *szNick = NULL, *szNote = NULL;
BYTE *pData = NULL, *pMetaToken = NULL, *pMetaTime = NULL;
int nDataLen = 0, nMetaTokenLen = 0, nMetaTimeLen = 0;
- BYTE bAuth;
- int bDataTooLong = FALSE;
// Prepare UID
+ DWORD dwUin;
+ uid_str szUid;
if (getContactUid(hContact, &dwUin, &szUid)) {
debugLogA("Buddy upload failed (UID missing).");
return 0;
}
- bAuth = getByte(hContact, "Auth", 0);
- szNick = getSettingStringUtf(hContact, "CList", "MyHandle", NULL);
- szNote = getSettingStringUtf(hContact, "UserInfo", "MyNotes", NULL);
+ BYTE bAuth = getByte(hContact, "Auth", 0);
+ char *szNick = getSettingStringUtf(hContact, "CList", "MyHandle", NULL);
+ char *szNote = getSettingStringUtf(hContact, "UserInfo", "MyNotes", NULL);
DBVARIANT dbv;
-
if (!getSetting(hContact, DBSETTING_METAINFO_TOKEN, &dbv)) {
nMetaTokenLen = dbv.cpbVal;
pMetaToken = (BYTE*)_alloca(dbv.cpbVal);
@@ -1062,6 +1057,7 @@ DWORD CIcqProto::icq_sendServerContact(MCONTACT hContact, DWORD dwCookie, WORD w
size_t nNoteLen = mir_strlen(szNote);
// Limit the strings
+ int bDataTooLong = FALSE;
if (nNickLen > MAX_SSI_TLV_NAME_SIZE) {
bDataTooLong = TRUE;
nNickLen = null_strcut(szNick, MAX_SSI_TLV_NAME_SIZE);
@@ -1080,6 +1076,7 @@ DWORD CIcqProto::icq_sendServerContact(MCONTACT hContact, DWORD dwCookie, WORD w
size_t wTLVlen = (nNickLen ? 4 + nNickLen : 0) + (nNoteLen ? 4 + nNoteLen : 0) + (bAuth ? 4 : 0) + nDataLen + (nMetaTokenLen ? 4 + nMetaTokenLen : 0) + (nMetaTimeLen ? 4 + nMetaTimeLen : 0);
// Initialize our handy data buffer
+ icq_packet pBuffer;
pBuffer.wPlace = 0;
pBuffer.pData = (BYTE *)_alloca(wTLVlen);
pBuffer.wLen = (WORD)wTLVlen;
@@ -1797,16 +1794,15 @@ int CIcqProto::servlistAddContact_Ready(MCONTACT hContact, WORD, WORD, LPARAM lP
// Called when contact should be added to server list, if group does not exist, create one
void CIcqProto::servlistAddContact(MCONTACT hContact, const char *pszGroup)
{
+ // Get UID
DWORD dwUin;
uid_str szUid;
- cookie_servlist_action* ack;
-
- // Get UID
if (getContactUid(hContact, &dwUin, &szUid)) { // Could not do anything without uid
debugLogA("Failed to add contact to server side list (%s)", "no UID");
return;
}
+ cookie_servlist_action* ack;
if (!(ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action)))) { // Could not do anything without cookie
debugLogA("Failed to add contact to server side list (%s)", "malloc failed");
return;
@@ -1863,17 +1859,16 @@ int CIcqProto::servlistRemoveContact_Ready(MCONTACT hContact, WORD contactID, WO
// Called when contact should be removed from server list, remove group if it remain empty
void CIcqProto::servlistRemoveContact(MCONTACT hContact)
{
+ // Get UID
DWORD dwUin;
uid_str szUid;
- cookie_servlist_action* ack;
-
- // Get UID
if (getContactUid(hContact, &dwUin, &szUid)) {
// Could not do anything without uid
debugLogA("Failed to remove contact from server side list (%s)", "no UID");
return;
}
+ cookie_servlist_action* ack;
if (!(ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action)))) { // Could not do anything without cookie
debugLogA("Failed to remove contact from server side list (%s)", "malloc failed");
return;
@@ -1968,12 +1963,11 @@ int CIcqProto::servlistMoveContact_Ready(MCONTACT, WORD contactID, WORD groupID,
// Called when contact should be moved from one group to another, create new, remove empty
void CIcqProto::servlistMoveContact(MCONTACT hContact, const char *pszNewGroup)
{
- DWORD dwUin;
- uid_str szUid;
-
if (!hContact) return; // we do not move us, caused our uin was wrongly added to list
// Get UID
+ DWORD dwUin;
+ uid_str szUid;
if (getContactUid(hContact, &dwUin, &szUid)) { // Could not do anything without uin
debugLogA("Failed to move contact to group on server side list (%s)", "no UID");
return;
diff --git a/protocols/IcqOscarJ/src/icq_uploadui.cpp b/protocols/IcqOscarJ/src/icq_uploadui.cpp
index 43cd5eba33..20775e1d84 100644
--- a/protocols/IcqOscarJ/src/icq_uploadui.cpp
+++ b/protocols/IcqOscarJ/src/icq_uploadui.cpp
@@ -324,11 +324,10 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa
}
else { // If the server refused to add the contact without authorization,
// we try again _with_ authorization TLV
- DWORD dwUIN;
- uid_str szUID;
-
ppro->setByte(hCurrentContact, "Auth", 1);
+ DWORD dwUIN;
+ uid_str szUID;
if (!ppro->getContactUid(hCurrentContact, &dwUIN, &szUID)) {
currentAction = ACTION_ADDBUDDYAUTH;
currentSequence = sendUploadBuddy(ppro, hCurrentContact, ICQ_LISTS_ADDTOLIST, dwUIN, szUID, wNewContactId, wNewGroupId, SSI_ITEM_BUDDY);
@@ -488,8 +487,6 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa
{
MCONTACT hContact;
HANDLE hItem;
- DWORD dwUin;
- uid_str szUid;
char *pszNick;
char *pszGroup;
int isChecked;
@@ -528,6 +525,8 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa
isChecked = SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0) != 0;
isOnServer = ppro->getWord(hContact, DBSETTING_SERVLIST_ID, 0) != 0;
+ DWORD dwUin;
+ uid_str szUid;
bUidOk = !ppro->getContactUid(hContact, &dwUin, &szUid);
// Is this one out of sync?
@@ -670,6 +669,9 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa
WORD wIgnoreId = ppro->getWord(hContact, DBSETTING_SERVLIST_IGNORE, 0);
hCurrentContact = hContact;
+
+ DWORD dwUin;
+ uid_str szUid;
ppro->getContactUid(hContact, &dwUin, &szUid);
if (wApparentMode == ID_STATUS_ONLINE) { // contact is on the visible list
diff --git a/protocols/IcqOscarJ/src/icqosc_svcs.cpp b/protocols/IcqOscarJ/src/icqosc_svcs.cpp
index bc2e768e80..0e966c5a4a 100644
--- a/protocols/IcqOscarJ/src/icqosc_svcs.cpp
+++ b/protocols/IcqOscarJ/src/icqosc_svcs.cpp
@@ -465,13 +465,11 @@ INT_PTR CIcqProto::SendYouWereAdded(WPARAM, LPARAM lParam)
if (lParam && icqOnline()) {
CCSDATA* ccs = (CCSDATA*)lParam;
if (ccs->hContact) {
- DWORD dwUin, dwMyUin;
-
+ DWORD dwUin;
if (getContactUid(ccs->hContact, &dwUin, NULL))
return 1; // Invalid contact
- dwMyUin = getContactUin(NULL);
-
+ DWORD dwMyUin = getContactUin(NULL);
if (dwUin) {
icq_sendYouWereAddedServ(dwUin, dwMyUin);
return 0; // Success
@@ -595,13 +593,10 @@ void CIcqProto::ICQAddRecvEvent(MCONTACT hContact, WORD wType, PROTORECVEVENT* p
flags |= DBEF_UTF;
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)) {
+ DWORD dwUin;
+ uid_str szUid;
getContactUid(hContact, &dwUin, &szUid);
icq_sendNewContact(dwUin, szUid); /// FIXME
}
diff --git a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp
index 464b9fc916..8cc8e10d5a 100644
--- a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp
+++ b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp
@@ -859,9 +859,9 @@ HANDLE CIcqProto::oftInitTransfer(MCONTACT hContact, DWORD dwUin, char* szUid, c
HANDLE CIcqProto::oftFileAllow(MCONTACT hContact, HANDLE hTransfer, const TCHAR *szPath)
{
oscar_filetransfer *ft = (oscar_filetransfer*)hTransfer;
+
DWORD dwUin;
uid_str szUid;
-
if (getContactUid(hContact, &dwUin, &szUid))
return 0; // Invalid contact
@@ -889,9 +889,9 @@ HANDLE CIcqProto::oftFileAllow(MCONTACT hContact, HANDLE hTransfer, const TCHAR
DWORD CIcqProto::oftFileDeny(MCONTACT hContact, HANDLE hTransfer, const TCHAR*)
{
oscar_filetransfer *ft = (oscar_filetransfer*)hTransfer;
+
DWORD dwUin;
uid_str szUid;
-
if (getContactUid(hContact, &dwUin, &szUid))
return 1; // Invalid contact
@@ -913,9 +913,9 @@ DWORD CIcqProto::oftFileDeny(MCONTACT hContact, HANDLE hTransfer, const TCHAR*)
DWORD CIcqProto::oftFileCancel(MCONTACT hContact, HANDLE hTransfer)
{
oscar_filetransfer* ft = (oscar_filetransfer*)hTransfer;
+
DWORD dwUin;
uid_str szUid;
-
if (getContactUid(hContact, &dwUin, &szUid))
return 1; // Invalid contact
diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp
index f8d2250b44..ef8b905a52 100644
--- a/protocols/IcqOscarJ/src/utilities.cpp
+++ b/protocols/IcqOscarJ/src/utilities.cpp
@@ -360,7 +360,6 @@ void CIcqProto::InitContactsCache()
while (hContact) {
DWORD dwUin;
uid_str szUid;
-
if (!getContactUid(hContact, &dwUin, &szUid))
AddToContactsCache(hContact, dwUin, szUid);