diff options
Diffstat (limited to 'protocols/IcqOscarJ/src/icqosc_svcs.cpp')
-rw-r--r-- | protocols/IcqOscarJ/src/icqosc_svcs.cpp | 449 |
1 files changed, 186 insertions, 263 deletions
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);
|