From 916d3c8fc91d4290aaf5625db636b6cf102306a6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 10 Jul 2018 20:34:46 +0300 Subject: ICQ: - warning fixes; - minor code cleaning --- protocols/IcqOscarJ/src/capabilities.cpp | 4 +- protocols/IcqOscarJ/src/changeinfo.h | 84 ++++++------- protocols/IcqOscarJ/src/channels.h | 14 +-- protocols/IcqOscarJ/src/constants.cpp | 2 +- protocols/IcqOscarJ/src/cookies.cpp | 5 +- protocols/IcqOscarJ/src/db.cpp | 4 +- protocols/IcqOscarJ/src/directpackets.cpp | 11 +- protocols/IcqOscarJ/src/dlgproc.cpp | 6 +- protocols/IcqOscarJ/src/editlist.cpp | 2 +- protocols/IcqOscarJ/src/editstring.cpp | 144 ++++++++++------------ protocols/IcqOscarJ/src/fam_01service.cpp | 135 ++++++++++----------- protocols/IcqOscarJ/src/fam_02location.cpp | 6 +- protocols/IcqOscarJ/src/fam_03buddy.cpp | 33 +++-- protocols/IcqOscarJ/src/fam_04message.cpp | 7 +- protocols/IcqOscarJ/src/fam_0bstatus.cpp | 25 ++-- protocols/IcqOscarJ/src/fam_13servclist.cpp | 6 +- protocols/IcqOscarJ/src/fam_15icqserver.cpp | 4 +- protocols/IcqOscarJ/src/fam_17signon.cpp | 6 +- protocols/IcqOscarJ/src/families.h | 26 ++-- protocols/IcqOscarJ/src/globals.h | 12 +- protocols/IcqOscarJ/src/guids.h | 45 ++++--- protocols/IcqOscarJ/src/i18n.cpp | 4 +- protocols/IcqOscarJ/src/icq_advsearch.cpp | 22 ++-- protocols/IcqOscarJ/src/icq_avatar.cpp | 13 +- protocols/IcqOscarJ/src/icq_clients.cpp | 162 ++++++++++++------------- protocols/IcqOscarJ/src/icq_direct.cpp | 2 +- protocols/IcqOscarJ/src/icq_direct.h | 2 +- protocols/IcqOscarJ/src/icq_directmsg.cpp | 11 +- protocols/IcqOscarJ/src/icq_fieldnames.h | 4 +- protocols/IcqOscarJ/src/icq_filerequests.cpp | 2 +- protocols/IcqOscarJ/src/icq_filetransfer.cpp | 6 +- protocols/IcqOscarJ/src/icq_firstrun.cpp | 6 +- protocols/IcqOscarJ/src/icq_http.cpp | 38 +++--- protocols/IcqOscarJ/src/icq_infoupdate.cpp | 2 +- protocols/IcqOscarJ/src/icq_menu.cpp | 16 +-- protocols/IcqOscarJ/src/icq_opts.cpp | 9 +- protocols/IcqOscarJ/src/icq_packet.cpp | 2 +- protocols/IcqOscarJ/src/icq_popups.cpp | 159 ++++++++++++------------ protocols/IcqOscarJ/src/icq_proto.cpp | 4 +- protocols/IcqOscarJ/src/icq_proto.h | 4 - protocols/IcqOscarJ/src/icq_rates.cpp | 5 +- protocols/IcqOscarJ/src/icq_rates.h | 10 +- protocols/IcqOscarJ/src/icq_server.cpp | 9 +- protocols/IcqOscarJ/src/icq_servlist.cpp | 12 +- protocols/IcqOscarJ/src/icq_servlist.h | 48 ++++---- protocols/IcqOscarJ/src/icq_uploadui.cpp | 4 +- protocols/IcqOscarJ/src/icq_xtraz.cpp | 11 +- protocols/IcqOscarJ/src/icqosc_svcs.cpp | 10 +- protocols/IcqOscarJ/src/log.cpp | 10 +- protocols/IcqOscarJ/src/loginpassword.cpp | 4 +- protocols/IcqOscarJ/src/oscar_filetransfer.cpp | 142 +++++++++++----------- protocols/IcqOscarJ/src/oscar_filetransfer.h | 8 +- protocols/IcqOscarJ/src/stdpackets.cpp | 12 +- protocols/IcqOscarJ/src/stdpackets.h | 6 +- protocols/IcqOscarJ/src/tlv.h | 45 ++++--- protocols/IcqOscarJ/src/upload.cpp | 10 +- protocols/IcqOscarJ/src/userinfotab.cpp | 2 +- protocols/IcqOscarJ/src/utilities.cpp | 19 ++- 58 files changed, 678 insertions(+), 738 deletions(-) (limited to 'protocols/IcqOscarJ/src') diff --git a/protocols/IcqOscarJ/src/capabilities.cpp b/protocols/IcqOscarJ/src/capabilities.cpp index 4a35b19ea6..bdde98f6d8 100644 --- a/protocols/IcqOscarJ/src/capabilities.cpp +++ b/protocols/IcqOscarJ/src/capabilities.cpp @@ -80,7 +80,7 @@ static const icq_capability_name CapabilityNames[] = void NetLog_CapabilityChange(CIcqProto *ppro, const char *szChange, DWORD fdwCapabilities) { - char szBuffer[MAX_PATH] = {0}; + char szBuffer[MAX_PATH] = { 0 }; if (!fdwCapabilities) return; @@ -141,7 +141,7 @@ void CIcqProto::SetContactCapabilities(MCONTACT hContact, DWORD fdwCapabilities) BOOL CIcqProto::CheckContactCapabilities(MCONTACT hContact, DWORD fdwCapabilities) { // Get current capability flags - DWORD fdwContactCaps = getDword(hContact, DBSETTING_CAPABILITIES, 0); + DWORD fdwContactCaps = getDword(hContact, DBSETTING_CAPABILITIES, 0); // Check if all requested capabilities are supported if ((fdwContactCaps & fdwCapabilities) == fdwCapabilities) diff --git a/protocols/IcqOscarJ/src/changeinfo.h b/protocols/IcqOscarJ/src/changeinfo.h index b487f75a64..ef4de019a6 100644 --- a/protocols/IcqOscarJ/src/changeinfo.h +++ b/protocols/IcqOscarJ/src/changeinfo.h @@ -52,17 +52,17 @@ struct SettingItem { - const char *szDescription; - unsigned displayType; //LI_ constant - int dbType; //DBVT_ constant - const char *szDbSetting; - const void *pList; + const char *szDescription; + unsigned displayType; //LI_ constant + int dbType; //DBVT_ constant + const char *szDbSetting; + const void *pList; }; struct SettingItemData { - LPARAM value; - int changed; + LPARAM value; + int changed; }; // contants.c @@ -72,41 +72,41 @@ extern const int settingCount; //dlgproc.c struct ChangeInfoData : public MZeroedObject { - HWND hwndDlg; - CIcqProto *ppro; - HFONT hListFont; - HWND hwndList; - int editTopIndex; - int iEditItem; - char Password[PASSWORDMAXLEN+1]; - - SettingItemData *settingData; - - HANDLE hAckHook; - HANDLE hUpload[2]; - - ChangeInfoData() { settingData = (SettingItemData*)SAFE_MALLOC(sizeof(SettingItemData) * settingCount); hAckHook = nullptr; hUpload[0] = nullptr; hUpload[1] = nullptr;} - ~ChangeInfoData() { SAFE_FREE((void**)&settingData); } - - char* GetItemSettingText(int i, char *buf, size_t buf_size); - void PaintItemSetting(HDC hdc, RECT *rc, int i, UINT itemState); - - //db.cpp - void LoadSettingsFromDb(int keepChanged); - void FreeStoredDbSettings(void); - int ChangesMade(void); - void ClearChangeFlags(void); - int SaveSettingsToDb(void); - - //upload.cpp - int UploadSettings(void); - - //editstring.cpp - void BeginStringEdit(int iItem,RECT *rc,int i,WORD wVKey); - void EndStringEdit(int save); - //editlist.cpp - void BeginListEdit(int iItem, RECT *rc, int iSetting, WORD wVKey); - void EndListEdit(int save); + HWND hwndDlg; + CIcqProto *ppro; + HFONT hListFont; + HWND hwndList; + int editTopIndex; + int iEditItem; + char Password[PASSWORDMAXLEN + 1]; + + SettingItemData *settingData; + + HANDLE hAckHook; + HANDLE hUpload[2]; + + ChangeInfoData() { settingData = (SettingItemData*)SAFE_MALLOC(sizeof(SettingItemData) * settingCount); hAckHook = nullptr; hUpload[0] = nullptr; hUpload[1] = nullptr; } + ~ChangeInfoData() { SAFE_FREE((void**)&settingData); } + + char* GetItemSettingText(int i, char *buf, size_t buf_size); + void PaintItemSetting(HDC hdc, RECT *rc, int i, UINT itemState); + + //db.cpp + void LoadSettingsFromDb(int keepChanged); + void FreeStoredDbSettings(void); + int ChangesMade(void); + void ClearChangeFlags(void); + int SaveSettingsToDb(void); + + //upload.cpp + int UploadSettings(void); + + //editstring.cpp + void BeginStringEdit(int iItem, RECT *rc, int i, WORD wVKey); + void EndStringEdit(int save); + //editlist.cpp + void BeginListEdit(int iItem, RECT *rc, int iSetting, WORD wVKey); + void EndListEdit(int save); }; INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); diff --git a/protocols/IcqOscarJ/src/channels.h b/protocols/IcqOscarJ/src/channels.h index f8bb0d64e0..6bce28b5b8 100644 --- a/protocols/IcqOscarJ/src/channels.h +++ b/protocols/IcqOscarJ/src/channels.h @@ -30,14 +30,14 @@ #ifndef __CHANNELS_H #define __CHANNELS_H -struct snac_header +struct snac_header { - BOOL bValid; - WORD wFamily; - WORD wSubtype; - WORD wFlags; - DWORD dwRef; - WORD wVersion; + BOOL bValid; + WORD wFamily; + WORD wSubtype; + WORD wFlags; + DWORD dwRef; + WORD wVersion; }; int unpackSnacHeader(snac_header *pSnacHeader, BYTE **pBuffer, size_t *pwBufferLength); diff --git a/protocols/IcqOscarJ/src/constants.cpp b/protocols/IcqOscarJ/src/constants.cpp index 10f7232f95..d07e8352f5 100644 --- a/protocols/IcqOscarJ/src/constants.cpp +++ b/protocols/IcqOscarJ/src/constants.cpp @@ -75,7 +75,7 @@ const SettingItem setting[] = { LPGEN("Phone number"), LI_STRING, DBVT_UTF8, "Phone" }, { LPGEN("Fax number"), LI_STRING, DBVT_UTF8, "Fax" }, { LPGEN("Cellular number"), LI_STRING, DBVT_UTF8, "Cellular" }, - + // more { LPGEN("Personal Detail"), LI_DIVIDER }, { LPGEN("Timezone"), LI_LIST | LIF_ZEROISVALID | LIF_SIGNED, DBVT_BYTE, "Timezone", timezonesField }, diff --git a/protocols/IcqOscarJ/src/cookies.cpp b/protocols/IcqOscarJ/src/cookies.cpp index f63b6d35c8..a9d09534c7 100644 --- a/protocols/IcqOscarJ/src/cookies.cpp +++ b/protocols/IcqOscarJ/src/cookies.cpp @@ -194,7 +194,7 @@ void CIcqProto::ReleaseCookie(DWORD dwCookie) { mir_cslock l(cookieMutex); - int i = cookies.getIndex(( icq_cookie_info* )&dwCookie ); + int i = cookies.getIndex((icq_cookie_info*)&dwCookie); if (i != -1) { // Cookie found, remove from list SAFE_FREE((void**)&cookies[i].pvExtra); cookies.remove(i); @@ -212,8 +212,7 @@ void CIcqProto::InitMessageCookie(cookie_message_data *pCookie) // ensure that message ids are unique dwMsgID1 = time(0); dwMsgID2 = RandRange(0, 0x0FFFF); - } - while (FindMessageCookie(dwMsgID1, dwMsgID2, nullptr, nullptr, nullptr)); + } while (FindMessageCookie(dwMsgID1, dwMsgID2, nullptr, nullptr, nullptr)); if (pCookie) { pCookie->dwMsgID1 = dwMsgID1; diff --git a/protocols/IcqOscarJ/src/db.cpp b/protocols/IcqOscarJ/src/db.cpp index 105566c102..f07b2b0594 100644 --- a/protocols/IcqOscarJ/src/db.cpp +++ b/protocols/IcqOscarJ/src/db.cpp @@ -33,11 +33,11 @@ void ChangeInfoData::LoadSettingsFromDb(int keepChanged) const SettingItem &si = setting[i]; if (si.displayType == LI_DIVIDER) continue; - + SettingItemData &sid = settingData[i]; if (keepChanged && sid.changed) continue; - + if (si.dbType == DBVT_ASCIIZ || si.dbType == DBVT_UTF8) SAFE_FREE((void**)(char**)&sid.value); else if (!keepChanged) diff --git a/protocols/IcqOscarJ/src/directpackets.cpp b/protocols/IcqOscarJ/src/directpackets.cpp index 14f8db4afc..a7f32e7248 100644 --- a/protocols/IcqOscarJ/src/directpackets.cpp +++ b/protocols/IcqOscarJ/src/directpackets.cpp @@ -194,7 +194,7 @@ int CIcqProto::icq_sendFileSendDirectv8(filetransfer *ft, const char *pszFiles) if (!utf8_decode(pszFiles, &szFilesAnsi)) szFilesAnsi = _strdup(pszFiles); // Legacy fix - size_t wFilesLen = mir_strlen(szFilesAnsi)+1; + size_t wFilesLen = mir_strlen(szFilesAnsi) + 1; icq_packet packet; packDirectMsgHeader(&packet, 0x2E + 22 + wDescrLen + wFilesLen, DIRECT_MESSAGE, (WORD)ft->dwCookie, MTYPE_PLUGIN, 0, 0, 0); @@ -227,18 +227,17 @@ DWORD CIcqProto::icq_SendDirectMessage(MCONTACT hContact, const char *szMessage, icq_packet packet; packDirectMsgHeader(&packet, nBodyLength + (szCap ? 53 : 11), DIRECT_MESSAGE, dwCookie, (BYTE)pCookieData->bMessageType, 0, 0, 0); - packLEWord(&packet, WORD(nBodyLength+1)); // Length of message - packBuffer(&packet, (LPBYTE)szMessage, nBodyLength+1); // Message + packLEWord(&packet, WORD(nBodyLength + 1)); // Length of message + packBuffer(&packet, (LPBYTE)szMessage, nBodyLength + 1); // Message packMsgColorInfo(&packet); - if (szCap) - { + if (szCap) { packLEDWord(&packet, 0x00000026); // length of GUID packBuffer(&packet, (LPBYTE)szCap, 0x26); // UTF-8 GUID } if (SendDirectMessage(hContact, &packet)) return dwCookie; // Success - + FreeCookie(dwCookie); // release cookie return 0; // Failure } diff --git a/protocols/IcqOscarJ/src/dlgproc.cpp b/protocols/IcqOscarJ/src/dlgproc.cpp index 8a83351565..061538a074 100644 --- a/protocols/IcqOscarJ/src/dlgproc.cpp +++ b/protocols/IcqOscarJ/src/dlgproc.cpp @@ -280,7 +280,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM FillRect(cd->nmcd.hdc, &rcItem, GetSysColorBrush(COLOR_3DFACE)); } else if ((cd->nmcd.uItemState & CDIS_SELECTED || dat->iEditItem == (int)cd->nmcd.dwItemSpec) - && setting[cd->nmcd.lItemlParam].displayType != LI_DIVIDER) { // Selected item + && setting[cd->nmcd.lItemlParam].displayType != LI_DIVIDER) { // Selected item SetTextColor(cd->nmcd.hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); FillRect(cd->nmcd.hdc, &rcItem, GetSysColorBrush(COLOR_HIGHLIGHT)); } @@ -370,7 +370,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM dat->EndStringEdit(1); dat->EndListEdit(1); if (nm->wVKey == VK_SPACE || nm->wVKey == VK_RETURN || nm->wVKey == VK_F2) nm->wVKey = 0; - if (nm->wVKey && (nm->wVKey<'0' || (nm->wVKey>'9' && nm->wVKey<'A') || (nm->wVKey>'Z' && nm->wVKey < VK_NUMPAD0) || nm->wVKey >= VK_F1)) + if (nm->wVKey && (nm->wVKey < '0' || (nm->wVKey > '9' && nm->wVKey < 'A') || (nm->wVKey > 'Z' && nm->wVKey < VK_NUMPAD0) || nm->wVKey >= VK_F1)) break; lvi.mask = LVIF_PARAM | LVIF_STATE; lvi.stateMask = 0xFFFFFFFF; @@ -439,7 +439,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case WM_SIZE: if (IsIconic(hwndDlg)) break; - + Utils_ResizeDialog(hwndDlg, g_plugin.getInst(), MAKEINTRESOURCEA(IDD_INFO_CHANGEINFO), ChangeInfoDlg_Resize); { RECT rc; // update listview column widths diff --git a/protocols/IcqOscarJ/src/editlist.cpp b/protocols/IcqOscarJ/src/editlist.cpp index 8f919b577f..165e09bf7f 100644 --- a/protocols/IcqOscarJ/src/editlist.cpp +++ b/protocols/IcqOscarJ/src/editlist.cpp @@ -80,7 +80,7 @@ void ChangeInfoData::BeginListEdit(int iItem, RECT *rc, int iSetting, WORD wVKey dataListEdit = this; hwndListEdit = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, L"LISTBOX", L"", WS_POPUP | WS_BORDER | WS_VSCROLL, - rc->left, rc->bottom, rc->right - rc->left, 150, nullptr, nullptr, g_plugin.getInst(), nullptr); + rc->left, rc->bottom, rc->right - rc->left, 150, nullptr, nullptr, g_plugin.getInst(), nullptr); SendMessage(hwndListEdit, WM_SETFONT, (WPARAM)hListFont, 0); int itemHeight = SendMessage(hwndListEdit, LB_GETITEMHEIGHT, 0, 0); diff --git a/protocols/IcqOscarJ/src/editstring.cpp b/protocols/IcqOscarJ/src/editstring.cpp index 010f38e068..ef689445da 100644 --- a/protocols/IcqOscarJ/src/editstring.cpp +++ b/protocols/IcqOscarJ/src/editstring.cpp @@ -30,127 +30,111 @@ static ChangeInfoData *dataStringEdit = nullptr; static HWND hwndEdit = nullptr, hwndExpandButton = nullptr, hwndUpDown = nullptr; -static const char escapes[]={'a','\a', -'b','\b', -'e',27, -'f','\f', -'r','\r', -'t','\t', -'v','\v', -'\\','\\'}; - -static void EscapesToMultiline(WCHAR *str,PDWORD selStart,PDWORD selEnd) -{ //converts "\\n" and "\\t" to "\r\n" and "\t" because a multi-line edit box can show them properly +static const char escapes[] = +{ + 'a','\a', + 'b','\b', + 'e',27, + 'f','\f', + 'r','\r', + 't','\t', + 'v','\v', + '\\','\\' +}; + +static void EscapesToMultiline(WCHAR *str, PDWORD selStart, PDWORD selEnd) +{ + // converts "\\n" and "\\t" to "\r\n" and "\t" because a multi-line edit box can show them properly DWORD i; - for(i=0; *str; str++, i++) - { + for (i = 0; *str; str++, i++) { if (*str != '\\') continue; - if (str[1] == 'n') - { - *str++ = '\r'; - i++; + if (str[1] == 'n') { + *str++ = '\r'; + i++; *str = '\n'; } - else if (str[1] == 't') - { + else if (str[1] == 't') { *str = '\t'; - memmove(str+1, str+2, sizeof(WCHAR)*(mir_wstrlen(str)-1)); + memmove(str + 1, str + 2, sizeof(WCHAR)*(mir_wstrlen(str) - 1)); - if (*selStart>i) --*selStart; - if (*selEnd>i) --*selEnd; + if (*selStart > i)--*selStart; + if (*selEnd > i)--*selEnd; } } } - - static void EscapesToBinary(char *str) { - for (;*str;str++) - { - if (*str!='\\') continue; - if(str[1]=='n') {*str++='\r'; *str='\n'; continue;} - if(str[1]=='0') - { + for (; *str; str++) { + if (*str != '\\') continue; + if (str[1] == 'n') { *str++ = '\r'; *str = '\n'; continue; } + if (str[1] == '0') { char *codeend; - *str=(char)strtol(str+1,&codeend,8); - if (*str==0) {*str='\\'; continue;} - memmove(str+1,codeend,mir_strlen(codeend)+1); + *str = (char)strtol(str + 1, &codeend, 8); + if (*str == 0) { *str = '\\'; continue; } + memmove(str + 1, codeend, mir_strlen(codeend) + 1); continue; } - for(int i=0;i<_countof(escapes);i+=2) - if(str[1]==escapes[i]) - { - *str=escapes[i+1]; - memmove(str+1,str+2,mir_strlen(str)-1); + for (int i = 0; i < _countof(escapes); i += 2) + if (str[1] == escapes[i]) { + *str = escapes[i + 1]; + memmove(str + 1, str + 2, mir_strlen(str) - 1); break; } } } - - char *BinaryToEscapes(char *str) { int extra = 10, len = (int)mir_strlen(str) + 11, i; char *out, *pout; - out=pout=(char*)SAFE_MALLOC(len); - for (;*str;str++) - { - if ((unsigned char)*str>=' ') - { - *pout++=*str; + out = pout = (char*)SAFE_MALLOC(len); + for (; *str; str++) { + if ((unsigned char)*str >= ' ') { + *pout++ = *str; continue; } - if(str[0]=='\r' && str[1]=='\n') - { - *pout++='\\'; - *pout++='n'; + if (str[0] == '\r' && str[1] == '\n') { + *pout++ = '\\'; + *pout++ = 'n'; str++; continue; } - if(extra<3) - { - extra+=8; len+=8; - pout=out=(char*)SAFE_REALLOC(out,len); + if (extra < 3) { + extra += 8; len += 8; + pout = out = (char*)SAFE_REALLOC(out, len); } - *pout++='\\'; - for(i = 0; i < _countof(escapes); i += 2) - if (*str==escapes[i+1]) - { - *pout++=escapes[i]; + *pout++ = '\\'; + for (i = 0; i < _countof(escapes); i += 2) + if (*str == escapes[i + 1]) { + *pout++ = escapes[i]; extra--; break; } - if(i < _countof(escapes)) continue; - *pout++='0'; extra--; - if (*str>=8) - { - *pout++=(*str>>3)+'0'; - extra--; - } - *pout++=(*str&7)+'0'; extra--; + if (i < _countof(escapes)) continue; + *pout++ = '0'; extra--; + if (*str >= 8) { + *pout++ = (*str >> 3) + '0'; + extra--; + } + *pout++ = (*str & 7) + '0'; extra--; } - *pout='\0'; + *pout = '\0'; return out; } - - -static LRESULT CALLBACK StringEditSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) +static LRESULT CALLBACK StringEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch(msg) { + switch (msg) { case WM_KEYDOWN: - if (wParam==VK_ESCAPE) - { + if (wParam == VK_ESCAPE) { if (dataStringEdit) - dataStringEdit->EndStringEdit(0); + dataStringEdit->EndStringEdit(0); return 0; } - if (wParam==VK_RETURN) - { + if (wParam == VK_RETURN) { if (GetWindowLongPtr(hwnd, GWL_STYLE) & ES_MULTILINE && !(GetKeyState(VK_CONTROL) & 0x8000)) break; if (dataStringEdit) dataStringEdit->EndStringEdit(1); @@ -296,8 +280,8 @@ void ChangeInfoData::EndStringEdit(int save) int *range = (int*)si.pList; newValue = atoi(text); if (newValue) { - if (newValuerange[1]) newValue = range[1]; + if (newValue < range[0]) newValue = range[0]; + if (newValue > range[1]) newValue = range[1]; } sid.changed = sid.value != newValue; sid.value = newValue; @@ -310,7 +294,7 @@ void ChangeInfoData::EndStringEdit(int save) EscapesToBinary(text); } if ((si.displayType & LIF_PASSWORD && mir_strcmp(text, " ")) || - (!(si.displayType & LIF_PASSWORD) && mir_strcmp(text, (char*)sid.value) && (mir_strlen(text) + mir_strlen((char*)sid.value)))) { + (!(si.displayType & LIF_PASSWORD) && mir_strcmp(text, (char*)sid.value) && (mir_strlen(text) + mir_strlen((char*)sid.value)))) { SAFE_FREE((void**)&sid.value); if (mir_strlen(text)) sid.value = (LPARAM)text; diff --git a/protocols/IcqOscarJ/src/fam_01service.cpp b/protocols/IcqOscarJ/src/fam_01service.cpp index 1ecf131676..01c917c998 100644 --- a/protocols/IcqOscarJ/src/fam_01service.cpp +++ b/protocols/IcqOscarJ/src/fam_01service.cpp @@ -128,7 +128,7 @@ void CIcqProto::handleServiceFam(BYTE *pBuffer, size_t wBufferLength, snac_heade serverPacketInit(&packet, 16); ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action)); - if (ack) { // TODO: rewrite - use get list service for empty list + if (ack) { // TODO: rewrite - use get list service for empty list // we try to use standalone cookie if available ack->dwAction = SSA_CHECK_ROSTER; // loading list dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_CLI_CHECK, 0, ack); @@ -317,75 +317,75 @@ void CIcqProto::handleServiceFam(BYTE *pBuffer, size_t wBufferLength, snac_heade break; case ICQ_SERVER_REDIRECT_SERVICE: // reply to family request, got new connection point - { - oscar_tlv_chain *pChain = nullptr; - cookie_family_request *pCookieData; + { + oscar_tlv_chain *pChain = nullptr; + cookie_family_request *pCookieData; - if (!(pChain = readIntoTLVChain(&pBuffer, wBufferLength, 0))) { - debugLogA("Received Broken Redirect Service SNAC(1,5)."); - break; - } + if (!(pChain = readIntoTLVChain(&pBuffer, wBufferLength, 0))) { + debugLogA("Received Broken Redirect Service SNAC(1,5)."); + break; + } - // pick request data - WORD wFamily = pChain->getWord(0x0D, 1); - if ((!FindCookie(pSnacHeader->dwRef, nullptr, (void**)&pCookieData)) || (pCookieData->wFamily != wFamily)) { - disposeChain(&pChain); - debugLogA("Received unexpected SNAC(1,5), skipping."); - break; - } + // pick request data + WORD wFamily = pChain->getWord(0x0D, 1); + if ((!FindCookie(pSnacHeader->dwRef, nullptr, (void**)&pCookieData)) || (pCookieData->wFamily != wFamily)) { + disposeChain(&pChain); + debugLogA("Received unexpected SNAC(1,5), skipping."); + break; + } - FreeCookie(pSnacHeader->dwRef); + FreeCookie(pSnacHeader->dwRef); - // new family entry point received - char *pServer = pChain->getString(0x05, 1); - BYTE bServerSSL = pChain->getNumber(0x8E, 1); - char *pCookie = pChain->getString(0x06, 1); - WORD wCookieLen = pChain->getLength(0x06, 1); + // new family entry point received + char *pServer = pChain->getString(0x05, 1); + BYTE bServerSSL = pChain->getNumber(0x8E, 1); + char *pCookie = pChain->getString(0x06, 1); + WORD wCookieLen = pChain->getLength(0x06, 1); - if (!pServer || !pCookie) { - debugLogA("Server returned invalid data, family unavailable."); + if (!pServer || !pCookie) { + debugLogA("Server returned invalid data, family unavailable."); - SAFE_FREE(&pServer); - SAFE_FREE(&pCookie); - SAFE_FREE((void**)&pCookieData); - disposeChain(&pChain); - break; - } + SAFE_FREE(&pServer); + SAFE_FREE(&pCookie); + SAFE_FREE((void**)&pCookieData); + disposeChain(&pChain); + break; + } - // Get new family server ip and port - WORD wPort = info->wServerPort; // get default port - parseServerAddress(pServer, &wPort); + // Get new family server ip and port + WORD wPort = info->wServerPort; // get default port + parseServerAddress(pServer, &wPort); - // establish connection - NETLIBOPENCONNECTION nloc = { 0 }; - if (m_bGatewayMode) - nloc.flags |= NLOCF_HTTPGATEWAY; - nloc.szHost = pServer; - nloc.wPort = wPort; + // establish connection + NETLIBOPENCONNECTION nloc = { 0 }; + if (m_bGatewayMode) + nloc.flags |= NLOCF_HTTPGATEWAY; + nloc.szHost = pServer; + nloc.wPort = wPort; - HNETLIBCONN hConnection = NetLib_OpenConnection(m_hNetlibUser, wFamily == ICQ_AVATAR_FAMILY ? "Avatar " : nullptr, &nloc); + HNETLIBCONN hConnection = NetLib_OpenConnection(m_hNetlibUser, wFamily == ICQ_AVATAR_FAMILY ? "Avatar " : nullptr, &nloc); - if (hConnection == nullptr) - debugLogA("Unable to connect to ICQ new family server."); - // we want the handler to be called even if the connecting failed - else if (bServerSSL) { /* Start SSL session if requested */ - debugLogA("(%p) Starting SSL negotiation", Netlib_GetSocket(hConnection)); + if (hConnection == nullptr) + debugLogA("Unable to connect to ICQ new family server."); + // we want the handler to be called even if the connecting failed + else if (bServerSSL) { /* Start SSL session if requested */ + debugLogA("(%p) Starting SSL negotiation", Netlib_GetSocket(hConnection)); - if (!Netlib_StartSsl(hConnection, nullptr)) { - debugLogA("Unable to connect to ICQ new family server, SSL could not be negotiated"); - NetLib_CloseConnection(&hConnection, FALSE); + if (!Netlib_StartSsl(hConnection, nullptr)) { + debugLogA("Unable to connect to ICQ new family server, SSL could not be negotiated"); + NetLib_CloseConnection(&hConnection, FALSE); + } } - } - (this->*pCookieData->familyHandler)(hConnection, pCookie, wCookieLen); + (this->*pCookieData->familyHandler)(hConnection, pCookie, wCookieLen); - // Free allocated memory - // NOTE: "cookie" will get freed when we have connected to the avatar server. - disposeChain(&pChain); - SAFE_FREE(&pServer); - SAFE_FREE((void**)&pCookieData); - break; - } + // Free allocated memory + // NOTE: "cookie" will get freed when we have connected to the avatar server. + disposeChain(&pChain); + SAFE_FREE(&pServer); + SAFE_FREE((void**)&pCookieData); + break; + } case ICQ_SERVER_EXTSTATUS: // our session data debugLogA("Received owner session data."); @@ -441,15 +441,15 @@ void CIcqProto::handleServiceFam(BYTE *pBuffer, size_t wBufferLength, snac_heade break; case ICQ_ERROR: // Something went wrong, probably the request for avatar family failed - { - WORD wError; - if (wBufferLength >= 2) - unpackWord(&pBuffer, &wError); - else - wError = 0; + { + WORD wError; + if (wBufferLength >= 2) + unpackWord(&pBuffer, &wError); + else + wError = 0; - LogFamilyError(ICQ_SERVICE_FAMILY, wError); - } + LogFamilyError(ICQ_SERVICE_FAMILY, wError); + } break; // Stuff we don't care about @@ -509,8 +509,8 @@ char* CIcqProto::buildUinList(int subtype, size_t wMaxLen, MCONTACT *hContactRes // not in our SS list, or are awaiting authorization, to our // client side list if (m_bSsiEnabled && getWord(hContact, DBSETTING_SERVLIST_ID, 0) && - !getByte(hContact, "Auth", 0)) - add = 0; + !getByte(hContact, "Auth", 0)) + add = 0; // Never add hidden contacts to CS list if (db_get_b(hContact, "CList", "Hidden", 0)) @@ -556,8 +556,7 @@ void CIcqProto::sendEntireListServ(WORD wFamily, WORD wSubtype, int listType) } SAFE_FREE((void**)&szList); - } - while (hResumeContact); + } while (hResumeContact); } diff --git a/protocols/IcqOscarJ/src/fam_02location.cpp b/protocols/IcqOscarJ/src/fam_02location.cpp index b1ba4e3b0b..d870eed20a 100644 --- a/protocols/IcqOscarJ/src/fam_02location.cpp +++ b/protocols/IcqOscarJ/src/fam_02location.cpp @@ -43,11 +43,11 @@ void CIcqProto::handleLocationFam(BYTE *pBuffer, size_t wBufferLength, snac_head break; case ICQ_ERROR: - { + { WORD wError; if (wBufferLength >= 2) unpackWord(&pBuffer, &wError); - else + else wError = 0; if (wError == 4) { @@ -188,7 +188,7 @@ void CIcqProto::handleLocationUserInfoReply(BYTE* buf, size_t wLen, DWORD dwCook } setString(hContact, "About", szMsg); - ProtoBroadcastAck(hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1 ,0); + ProtoBroadcastAck(hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1, 0); SAFE_FREE((void**)&szMsg); } diff --git a/protocols/IcqOscarJ/src/fam_03buddy.cpp b/protocols/IcqOscarJ/src/fam_03buddy.cpp index 403e515182..f2d52509fc 100644 --- a/protocols/IcqOscarJ/src/fam_03buddy.cpp +++ b/protocols/IcqOscarJ/src/fam_03buddy.cpp @@ -108,7 +108,7 @@ int unpackSessionDataItem(oscar_tlv_chain *pChain, WORD wItemType, BYTE **ppItem len -= 4; // just some validity check - if (itemLen > len) + if (itemLen > len) itemLen = len; if (itemType == wItemType) { @@ -218,8 +218,8 @@ void CIcqProto::handleUserOnline(BYTE *buf, size_t wLen, serverthread_info*) unpackDWord(&pBuffer, &dwRealIP); unpackDWord(&pBuffer, &dwPort); - unpackByte(&pBuffer, &nTCPFlag); - unpackWord(&pBuffer, &wVersion); + unpackByte(&pBuffer, &nTCPFlag); + unpackWord(&pBuffer, &wVersion); unpackDWord(&pBuffer, &dwDirectConnCookie); unpackDWord(&pBuffer, &dwWebPort); // Web front port pBuffer += 4; // Client features @@ -289,7 +289,7 @@ void CIcqProto::handleUserOnline(BYTE *buf, size_t wLen, serverthread_info*) time_t tIdleTS = 0; if (wIdleTimer) { time(&tIdleTS); - tIdleTS -= (wIdleTimer*60); + tIdleTS -= (wIdleTimer * 60); } if (wIdleTimer) @@ -367,14 +367,14 @@ void CIcqProto::handleUserOnline(BYTE *buf, size_t wLen, serverthread_info*) } if (capLen) { - #ifdef _DEBUG - for (WORD i = 0; i < capLen; i += BINARY_CAP_SIZE) { - char tmp[100]; - bin2hex(capBuf + i, BINARY_CAP_SIZE, tmp); - debugLogA("Capability: %s", tmp); - } - #endif - +#ifdef _DEBUG + for (WORD i = 0; i < capLen; i += BINARY_CAP_SIZE) { + char tmp[100]; + bin2hex(capBuf + i, BINARY_CAP_SIZE, tmp); + debugLogA("Capability: %s", tmp); + } +#endif + // Update the contact's capabilies if present in packet SetCapabilitiesFromBuffer(hContact, capBuf, capLen, wOldStatus == ID_STATUS_OFFLINE); @@ -475,7 +475,7 @@ void CIcqProto::handleUserOnline(BYTE *buf, size_t wLen, serverthread_info*) // if no detection, set uknown if (!szClient) - szClient = (nIsICQ ? "Unknown" : "Unknown AIM"); + szClient = (nIsICQ ? "Unknown" : "Unknown AIM"); if (szClient != (char*)-1) { db_set_utf(hContact, m_szModuleName, "MirVer", szClient); @@ -493,7 +493,7 @@ void CIcqProto::handleUserOnline(BYTE *buf, size_t wLen, serverthread_info*) if (dwRealIP) setDword(hContact, "RealIP", dwRealIP); } - setWord(hContact, "Status", (WORD)IcqStatusToMiranda(wStatus)); + setWord(hContact, "Status", (WORD)IcqStatusToMiranda(wStatus)); // Update info? if (dwUIN) { @@ -617,8 +617,7 @@ void CIcqProto::handleUserOffline(BYTE *buf, size_t wLen) // Release memory disposeChain(&pChain); - } - while (wLen >= 1); + } while (wLen >= 1); } @@ -676,7 +675,7 @@ void CIcqProto::parseStatusNote(DWORD dwUin, char *szUid, MCONTACT hContact, osc } // Check if the status note was changed if (dwStatusNoteTS > getDword(hContact, DBSETTING_STATUS_NOTE_TIME, 0)) { - DBVARIANT dbv = {DBVT_DELETED}; + DBVARIANT dbv = { DBVT_DELETED }; if (mir_strlen(szStatusNote) || (!getString(hContact, DBSETTING_STATUS_NOTE, &dbv) && (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_UTF8) && mir_strlen(dbv.pszVal))) debugLogA("%s changed status note to \"%s\"", strUID(dwUin, szUid), szStatusNote ? szStatusNote : ""); diff --git a/protocols/IcqOscarJ/src/fam_04message.cpp b/protocols/IcqOscarJ/src/fam_04message.cpp index 5f56395682..d3de9c94ce 100644 --- a/protocols/IcqOscarJ/src/fam_04message.cpp +++ b/protocols/IcqOscarJ/src/fam_04message.cpp @@ -1528,7 +1528,7 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, DWORD dwExtraLen = *(DWORD*)pMsg; if (dwExtraLen < dwDataLen && !strncmp(szMsg, "{\\rtf", 5)) { // it is icq5 sending us crap, get real message from it - WCHAR* usMsg = (WCHAR*)_alloca((dwExtraLen + 1)*sizeof(WCHAR)); + WCHAR* usMsg = (WCHAR*)_alloca((dwExtraLen + 1) * sizeof(WCHAR)); // make sure it is null-terminated wcsncpy(usMsg, (WCHAR*)(pMsg + 4), dwExtraLen); usMsg[dwExtraLen] = '\0'; @@ -2349,7 +2349,6 @@ void CIcqProto::handleRecvServMsgError(BYTE *buf, size_t wLen, DWORD dwSequence) } } - void CIcqProto::handleServerAck(BYTE *buf, size_t wLen, DWORD dwSequence) { DWORD dwUin; @@ -2424,7 +2423,6 @@ void CIcqProto::handleServerAck(BYTE *buf, size_t wLen, DWORD dwSequence) } } - void CIcqProto::handleMissedMsg(BYTE *buf, size_t wLen) { DWORD dwUin; @@ -2499,7 +2497,6 @@ void CIcqProto::handleMissedMsg(BYTE *buf, size_t wLen) AddEvent(HContactFromUID(dwUin, szUid, &bAdded), ICQEVENTTYPE_MISSEDMESSAGE, time(0), 0, sizeof(wError), (PBYTE)&wError); } - void CIcqProto::handleOffineMessagesReply(DWORD dwRef) { cookie_offline_messages *cookie; @@ -2533,7 +2530,6 @@ void CIcqProto::handleOffineMessagesReply(DWORD dwRef) else debugLogA("Error: Received unexpected end of offline msgs."); } - void CIcqProto::handleTypingNotification(BYTE *buf, size_t wLen) { if (wLen < 14) { @@ -2600,7 +2596,6 @@ void CIcqProto::handleTypingNotification(BYTE *buf, size_t wLen) } } - void CIcqProto::sendTypingNotification(MCONTACT hContact, WORD wMTNCode) { _ASSERTE((wMTNCode == MTN_FINISHED) || (wMTNCode == MTN_TYPED) || (wMTNCode == MTN_BEGUN) || (wMTNCode == MTN_WINDOW_CLOSED)); diff --git a/protocols/IcqOscarJ/src/fam_0bstatus.cpp b/protocols/IcqOscarJ/src/fam_0bstatus.cpp index c6f0555929..6f7b5d69d3 100644 --- a/protocols/IcqOscarJ/src/fam_0bstatus.cpp +++ b/protocols/IcqOscarJ/src/fam_0bstatus.cpp @@ -30,25 +30,20 @@ void CIcqProto::handleStatusFam(unsigned char *pBuffer, size_t wBufferLength, sn switch (pSnacHeader->wSubtype) { case ICQ_STATS_MINREPORTINTERVAL: - { - WORD wInterval; - unpackWord(&pBuffer, &wInterval); - debugLogA("Server sent SNAC(x0B,x02) - SRV_SET_MINREPORTINTERVAL (Value: %u hours)", wInterval); - } + WORD wInterval; + unpackWord(&pBuffer, &wInterval); + debugLogA("Server sent SNAC(x0B,x02) - SRV_SET_MINREPORTINTERVAL (Value: %u hours)", wInterval); break; case ICQ_ERROR: - { - WORD wError; + WORD wError; + if (wBufferLength >= 2) + unpackWord(&pBuffer, &wError); + else + wError = 0; - if (wBufferLength >= 2) - unpackWord(&pBuffer, &wError); - else - wError = 0; - - LogFamilyError(ICQ_STATS_FAMILY, wError); - break; - } + LogFamilyError(ICQ_STATS_FAMILY, wError); + break; default: debugLogA("Warning: Ignoring SNAC(x%02x,x%02x) - Unknown SNAC (Flags: %u, Ref: %u)", ICQ_STATS_FAMILY, pSnacHeader->wSubtype, pSnacHeader->wFlags, pSnacHeader->dwRef); diff --git a/protocols/IcqOscarJ/src/fam_13servclist.cpp b/protocols/IcqOscarJ/src/fam_13servclist.cpp index 823156c3b1..c3dcf0a02d 100644 --- a/protocols/IcqOscarJ/src/fam_13servclist.cpp +++ b/protocols/IcqOscarJ/src/fam_13servclist.cpp @@ -1356,7 +1356,7 @@ void CIcqProto::handleServerCListItemDelete(const char *szRecordName, WORD wItem FreeServerID(wItemId, wItemType == SSI_ITEM_GROUP ? SSIT_GROUP : SSIT_ITEM); } -void CIcqProto::handleRecvAuthRequest(unsigned char *buf, size_t wLen) +void CIcqProto::handleRecvAuthRequest(BYTE *buf, size_t wLen) { DWORD dwUin; uid_str szUid; @@ -1407,7 +1407,7 @@ void CIcqProto::handleRecvAuthRequest(unsigned char *buf, size_t wLen) SAFE_FREE(&szReason); } -void CIcqProto::handleRecvAdded(unsigned char *buf, size_t wLen) +void CIcqProto::handleRecvAdded(BYTE *buf, size_t wLen) { PBYTE pBlob, pCurBlob; DBVARIANT dbv = { 0 }; @@ -1461,7 +1461,7 @@ void CIcqProto::handleRecvAdded(unsigned char *buf, size_t wLen) AddEvent(NULL, EVENTTYPE_ADDED, time(0), 0, cbBlob, pBlob); } -void CIcqProto::handleRecvAuthResponse(unsigned char *buf, size_t wLen) +void CIcqProto::handleRecvAuthResponse(BYTE *buf, size_t wLen) { DWORD dwUin; uid_str szUid; diff --git a/protocols/IcqOscarJ/src/fam_15icqserver.cpp b/protocols/IcqOscarJ/src/fam_15icqserver.cpp index d21d3de17f..db4509ec21 100644 --- a/protocols/IcqOscarJ/src/fam_15icqserver.cpp +++ b/protocols/IcqOscarJ/src/fam_15icqserver.cpp @@ -127,7 +127,7 @@ void CIcqProto::handleExtensionServerInfo(BYTE *buf, size_t wPackLen, WORD wFlag debugLogA("Error: Broken snac 15/3 %d", 2); return; } - + BYTE *databuf = dataTlv->pData; wPackLen -= 4; @@ -769,7 +769,7 @@ void CIcqProto::parseDirectoryUserDetailsData(MCONTACT hContact, oscar_tlv_chain SAFE_FREE(&szUid); return; } - + debugLogA("Received user info for %s from directory", szUid); SAFE_FREE(&szUid); } diff --git a/protocols/IcqOscarJ/src/fam_17signon.cpp b/protocols/IcqOscarJ/src/fam_17signon.cpp index 0b52a2c1b5..b4bc11a249 100644 --- a/protocols/IcqOscarJ/src/fam_17signon.cpp +++ b/protocols/IcqOscarJ/src/fam_17signon.cpp @@ -101,7 +101,7 @@ void CIcqProto::sendClientAuth(const char *szKey, size_t wKeyLen, BOOL bSecure) } // Pack client identification details. - packTLV(&packet, 0x0003, (WORD)sizeof(CLIENT_ID_STRING)-1, (LPBYTE)CLIENT_ID_STRING); + packTLV(&packet, 0x0003, (WORD)sizeof(CLIENT_ID_STRING) - 1, (LPBYTE)CLIENT_ID_STRING); packTLVWord(&packet, 0x0017, CLIENT_VERSION_MAJOR); packTLVWord(&packet, 0x0018, CLIENT_VERSION_MINOR); packTLVWord(&packet, 0x0019, CLIENT_VERSION_LESSER); @@ -120,7 +120,7 @@ void CIcqProto::sendClientAuth(const char *szKey, size_t wKeyLen, BOOL bSecure) void CIcqProto::handleAuthKeyResponse(BYTE *buf, size_t wPacketLen, serverthread_info *info) { - char szKey[64] = {0}; + char szKey[64] = { 0 }; mir_md5_state_t state; BYTE digest[16]; @@ -153,7 +153,7 @@ void CIcqProto::handleAuthKeyResponse(BYTE *buf, size_t wPacketLen, serverthread mir_md5_init(&state); mir_md5_append(&state, (LPBYTE)szKey, (int)wKeyLen); mir_md5_append(&state, digest, 16); - mir_md5_append(&state, (LPBYTE)CLIENT_MD5_STRING, sizeof(CLIENT_MD5_STRING)-1); + mir_md5_append(&state, (LPBYTE)CLIENT_MD5_STRING, sizeof(CLIENT_MD5_STRING) - 1); mir_md5_finish(&state, digest); debugLogA("Sending ICQ_SIGNON_LOGIN_REQUEST to login server"); diff --git a/protocols/IcqOscarJ/src/families.h b/protocols/IcqOscarJ/src/families.h index c7da638b0b..7ca934ab1c 100644 --- a/protocols/IcqOscarJ/src/families.h +++ b/protocols/IcqOscarJ/src/families.h @@ -30,16 +30,16 @@ #ifndef __FAMILIES_H #define __FAMILIES_H -struct message_ack_params +struct message_ack_params { - BYTE bType; - DWORD dwUin; - DWORD dwMsgID1; - DWORD dwMsgID2; - directconnect *pDC; - WORD wCookie; - int msgType; - BYTE bFlags; + BYTE bType; + DWORD dwUin; + DWORD dwMsgID1; + DWORD dwMsgID2; + directconnect *pDC; + WORD wCookie; + int msgType; + BYTE bFlags; }; #define MAT_SERVER_ADVANCED 0 @@ -52,11 +52,11 @@ struct message_ack_params #define MTF_STATUS_EXTENDED 4 -struct UserInfoRecordItem +struct UserInfoRecordItem { - WORD wTLV; - int dbType; - char *szDbSetting; + WORD wTLV; + int dbType; + char *szDbSetting; }; /*---------* Functions *---------------*/ diff --git a/protocols/IcqOscarJ/src/globals.h b/protocols/IcqOscarJ/src/globals.h index 16870b1657..84769644c9 100644 --- a/protocols/IcqOscarJ/src/globals.h +++ b/protocols/IcqOscarJ/src/globals.h @@ -45,12 +45,12 @@ extern const int moodXStatus[]; // from fam_04message.cpp struct icq_mode_messages { - char *szOnline; - char *szAway; - char *szNa; - char *szDnd; - char *szOccupied; - char *szFfc; + char *szOnline; + char *szAway; + char *szNa; + char *szDnd; + char *szOccupied; + char *szFfc; }; void g_MenuInit(); diff --git a/protocols/IcqOscarJ/src/guids.h b/protocols/IcqOscarJ/src/guids.h index 48666b9c01..7c5ba90686 100644 --- a/protocols/IcqOscarJ/src/guids.h +++ b/protocols/IcqOscarJ/src/guids.h @@ -33,30 +33,30 @@ typedef DWORD plugin_guid[4]; // Message Capability GUIDs -static const plugin_guid MCAP_SRV_RELAY_FMT = {MCAP_SRV_RELAY_FMT_s}; -static const plugin_guid MCAP_REVERSE_DC_REQ = {MCAP_REVERSE_DC_REQ_s}; -static const plugin_guid MCAP_FILE_TRANSFER = {MCAP_FILE_TRANSFER_s}; -static const plugin_guid MCAP_CONTACTS = {MCAP_CONTACTS_s}; +static const plugin_guid MCAP_SRV_RELAY_FMT = { MCAP_SRV_RELAY_FMT_s }; +static const plugin_guid MCAP_REVERSE_DC_REQ = { MCAP_REVERSE_DC_REQ_s }; +static const plugin_guid MCAP_FILE_TRANSFER = { MCAP_FILE_TRANSFER_s }; +static const plugin_guid MCAP_CONTACTS = { MCAP_CONTACTS_s }; // Plugin GUIDs -static const plugin_guid PSIG_MESSAGE = {PSIG_MESSAGE_s}; -static const plugin_guid PSIG_INFO_PLUGIN = {PSIG_INFO_PLUGIN_s}; -static const plugin_guid PSIG_STATUS_PLUGIN = {PSIG_STATUS_PLUGIN_s}; +static const plugin_guid PSIG_MESSAGE = { PSIG_MESSAGE_s }; +static const plugin_guid PSIG_INFO_PLUGIN = { PSIG_INFO_PLUGIN_s }; +static const plugin_guid PSIG_STATUS_PLUGIN = { PSIG_STATUS_PLUGIN_s }; // Plugin Message GUIDs -static const plugin_guid PMSG_QUERY_INFO = {PMSG_QUERY_INFO_s}; -static const plugin_guid PMSG_QUERY_STATUS = {PMSG_QUERY_STATUS_s}; +static const plugin_guid PMSG_QUERY_INFO = { PMSG_QUERY_INFO_s }; +static const plugin_guid PMSG_QUERY_STATUS = { PMSG_QUERY_STATUS_s }; // Message GUIDs -static const plugin_guid MGTYPE_MESSAGE = {MGTYPE_MESSAGE_s}; -static const plugin_guid MGTYPE_STATUSMSGEXT = {MGTYPE_STATUSMSGEXT_s}; -static const plugin_guid MGTYPE_FILE = {MGTYPE_FILE_s}; -static const plugin_guid MGTYPE_WEBURL = {MGTYPE_WEBURL_s}; -static const plugin_guid MGTYPE_CONTACTS = {MGTYPE_CONTACTS_s}; -static const plugin_guid MGTYPE_GREETING_CARD = {MGTYPE_GREETING_CARD_s}; -static const plugin_guid MGTYPE_CHAT = {MGTYPE_CHAT_s}; -static const plugin_guid MGTYPE_SMS_MESSAGE = {MGTYPE_SMS_MESSAGE_s}; -static const plugin_guid MGTYPE_XTRAZ_SCRIPT = {MGTYPE_XTRAZ_SCRIPT_s}; +static const plugin_guid MGTYPE_MESSAGE = { MGTYPE_MESSAGE_s }; +static const plugin_guid MGTYPE_STATUSMSGEXT = { MGTYPE_STATUSMSGEXT_s }; +static const plugin_guid MGTYPE_FILE = { MGTYPE_FILE_s }; +static const plugin_guid MGTYPE_WEBURL = { MGTYPE_WEBURL_s }; +static const plugin_guid MGTYPE_CONTACTS = { MGTYPE_CONTACTS_s }; +static const plugin_guid MGTYPE_GREETING_CARD = { MGTYPE_GREETING_CARD_s }; +static const plugin_guid MGTYPE_CHAT = { MGTYPE_CHAT_s }; +static const plugin_guid MGTYPE_SMS_MESSAGE = { MGTYPE_SMS_MESSAGE_s }; +static const plugin_guid MGTYPE_XTRAZ_SCRIPT = { MGTYPE_XTRAZ_SCRIPT_s }; // make GUID checks easy __forceinline bool CompareGUIDs(DWORD q1, DWORD q2, DWORD q3, DWORD q4, const plugin_guid guid) @@ -67,11 +67,10 @@ __forceinline bool CompareGUIDs(DWORD q1, DWORD q2, DWORD q3, DWORD q4, const pl // pack entire GUID into icq packet static __inline void packGUID(icq_packet *packet, const plugin_guid guid) { - packDWord(packet, guid[0]); - packDWord(packet, guid[1]); - packDWord(packet, guid[2]); - packDWord(packet, guid[3]); + packDWord(packet, guid[0]); + packDWord(packet, guid[1]); + packDWord(packet, guid[2]); + packDWord(packet, guid[3]); } - #endif /* __GUIDS_H */ diff --git a/protocols/IcqOscarJ/src/i18n.cpp b/protocols/IcqOscarJ/src/i18n.cpp index d341a7e4e7..76fdf8a09c 100644 --- a/protocols/IcqOscarJ/src/i18n.cpp +++ b/protocols/IcqOscarJ/src/i18n.cpp @@ -359,7 +359,7 @@ int __stdcall utf8_decode_codepage(const char *from, char **to, WORD wCp) return 0; } - *to = (char*)SAFE_MALLOC((chars + 1)*sizeof(char)); + *to = (char*)SAFE_MALLOC((chars + 1) * sizeof(char)); if (*to == nullptr) { #ifdef _DEBUG fprintf(stderr, "Out of memory processing string to local charset\n"); @@ -479,7 +479,7 @@ char* __stdcall unicode_to_ansi(const WCHAR *unicode) return nullptr; } - char* ansi = (char*)SAFE_MALLOC((chars + 1)*sizeof(char)); + char* ansi = (char*)SAFE_MALLOC((chars + 1) * sizeof(char)); if (ansi == nullptr) { #ifdef _DEBUG fprintf(stderr, "Out of memory processing string to local charset\n"); diff --git a/protocols/IcqOscarJ/src/icq_advsearch.cpp b/protocols/IcqOscarJ/src/icq_advsearch.cpp index bb515086f8..552efc5798 100644 --- a/protocols/IcqOscarJ/src/icq_advsearch.cpp +++ b/protocols/IcqOscarJ/src/icq_advsearch.cpp @@ -45,7 +45,7 @@ static void InitComboBox(HWND hwndCombo, const FieldNamesItem *names) INT_PTR CALLBACK AdvancedSearchDlgProc(HWND hwndDlg, UINT message, WPARAM, LPARAM) { - switch(message) { + switch (message) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); InitComboBox(GetDlgItem(hwndDlg, IDC_GENDER), genderField); @@ -104,19 +104,19 @@ static PBYTE createAdvancedSearchStructureTLV(HWND hwndDlg, size_t *length) searchPackTLVLNTS(&buf, &buflen, hwndDlg, IDC_POSITION, TLV_POSITION); searchPackTLVLNTS(&buf, &buflen, hwndDlg, IDC_KEYWORDS, TLV_KEYWORDS); - ppackLETLVDWord(&buf, &buflen, (DWORD)getCurItemData(hwndDlg, IDC_AGERANGE), TLV_AGERANGE, 0); + ppackLETLVDWord(&buf, &buflen, (DWORD)getCurItemData(hwndDlg, IDC_AGERANGE), TLV_AGERANGE, 0); - BYTE b = (BYTE)getCurItemData(hwndDlg, IDC_GENDER); + BYTE b = (BYTE)getCurItemData(hwndDlg, IDC_GENDER); switch (b) { - case 'F': b = 1; break; - case 'M': b = 2; break; - default: b = 0; + case 'F': b = 1; break; + case 'M': b = 2; break; + default: b = 0; } - ppackLETLVByte(&buf, &buflen, b, TLV_GENDER, 0); - ppackLETLVByte(&buf, &buflen, (BYTE)getCurItemData(hwndDlg, IDC_MARITALSTATUS), TLV_MARITAL, 0); - ppackLETLVWord(&buf, &buflen, (WORD)getCurItemData(hwndDlg, IDC_LANGUAGE), TLV_LANGUAGE, 0); - ppackLETLVWord(&buf, &buflen, (WORD)getCurItemData(hwndDlg, IDC_COUNTRY), TLV_COUNTRY, 0); - ppackLETLVWord(&buf, &buflen, (WORD)getCurItemData(hwndDlg, IDC_WORKFIELD), TLV_OCUPATION, 0); + ppackLETLVByte(&buf, &buflen, b, TLV_GENDER, 0); + ppackLETLVByte(&buf, &buflen, (BYTE)getCurItemData(hwndDlg, IDC_MARITALSTATUS), TLV_MARITAL, 0); + ppackLETLVWord(&buf, &buflen, (WORD)getCurItemData(hwndDlg, IDC_LANGUAGE), TLV_LANGUAGE, 0); + ppackLETLVWord(&buf, &buflen, (WORD)getCurItemData(hwndDlg, IDC_COUNTRY), TLV_COUNTRY, 0); + ppackLETLVWord(&buf, &buflen, (WORD)getCurItemData(hwndDlg, IDC_WORKFIELD), TLV_OCUPATION, 0); WORD w = (WORD)getCurItemData(hwndDlg, IDC_PASTCAT); searchPackTLVWordLNTS(&buf, &buflen, hwndDlg, IDC_PASTKEY, w, TLV_PASTINFO); diff --git a/protocols/IcqOscarJ/src/icq_avatar.cpp b/protocols/IcqOscarJ/src/icq_avatar.cpp index d05ed0d772..aabdf34ac5 100644 --- a/protocols/IcqOscarJ/src/icq_avatar.cpp +++ b/protocols/IcqOscarJ/src/icq_avatar.cpp @@ -30,7 +30,7 @@ #include "stdafx.h" #include "m_folders.h" -BYTE hashEmptyAvatar[9] = {0x00, 0x01, 0x00, 0x05, 0x02, 0x01, 0xD2, 0x04, 0x72}; +BYTE hashEmptyAvatar[9] = { 0x00, 0x01, 0x00, 0x05, 0x02, 0x01, 0xD2, 0x04, 0x72 }; avatars_request::avatars_request(int type) { @@ -56,7 +56,7 @@ avatars_request::~avatars_request() wchar_t* CIcqProto::GetOwnAvatarFileName() { - DBVARIANT dbvFile = {DBVT_DELETED}; + DBVARIANT dbvFile = { DBVT_DELETED }; if (getWString(NULL, "AvatarFile", &dbvFile)) return nullptr; @@ -215,7 +215,7 @@ void CIcqProto::StartAvatarThread(HNETLIBCONN hConn, char *cookie, size_t cookie SAFE_FREE((void**)&cookie); return; } - + if (m_avatarsConnection) m_avatarsConnection->closeConnection(); m_avatarsConnection = new avatars_server_connection(this, hConn, cookie, cookieLen); // the old connection should not be used anymore @@ -853,7 +853,7 @@ void avatars_server_connection::checkRequestQueue() } return; // end processing } - + ppro->m_arAvatars.remove(int(0)); alck.unlock(); @@ -1044,7 +1044,7 @@ void avatars_server_connection::handleLoginChannel(BYTE *buf) void avatars_server_connection::handleDataChannel(BYTE *buf, size_t datalen) { - snac_header snacHeader = {0}; + snac_header snacHeader = { 0 }; if (!unpackSnacHeader(&snacHeader, &buf, &datalen) || !snacHeader.bValid) ppro->debugLogA("Error: Failed to parse SNAC header"); else { @@ -1236,8 +1236,7 @@ void avatars_server_connection::handleAvatarFam(BYTE *pBuffer, size_t wBufferLen ppro->debugLogA("Warning: DB error (no hash in DB)."); // the hash was lost, try to fix that if (ppro->setSettingBlob(pCookieData->hContact, "AvatarSaved", pCookieData->hash, (int)pCookieData->hashlen) || - ppro->setSettingBlob(pCookieData->hContact, "AvatarHash", pCookieData->hash, (int)pCookieData->hashlen)) - { + ppro->setSettingBlob(pCookieData->hContact, "AvatarHash", pCookieData->hash, (int)pCookieData->hashlen)) { ppro->debugLogA("Failed to save avatar hash to DB"); } } diff --git a/protocols/IcqOscarJ/src/icq_clients.cpp b/protocols/IcqOscarJ/src/icq_clients.cpp index bbba013cbe..658a963d15 100644 --- a/protocols/IcqOscarJ/src/icq_clients.cpp +++ b/protocols/IcqOscarJ/src/icq_clients.cpp @@ -29,7 +29,7 @@ #include "stdafx.h" -const capstr capShortCaps = {0x09, 0x46, 0x00, 0x00, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}; // CAP_AIM_BUDDYICON +const capstr capShortCaps = { 0x09, 0x46, 0x00, 0x00, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 }; // CAP_AIM_BUDDYICON static const char* makeClientVersion(char *szBuf, const char *szClient, unsigned v1, unsigned v2, unsigned v3, unsigned v4) { @@ -95,79 +95,79 @@ char* MirandaModToString(char* szStr, capstr* capId, int bUnicode, const char* s return szClient; } -const capstr capMirandaIm = {'M', 'i', 'r', 'a', 'n', 'd', 'a', 'M', 0, 0, 0, 0, 0, 0, 0, 0}; -const capstr capMirandaNg = {'M', 'i', 'r', 'a', 'n', 'd', 'a', 'N', 0, 0, 0, 0, 0, 0, 0, 0}; -const capstr capIcqJs7 = {'i', 'c', 'q', 'j', ' ', 'S', 'e', 'c', 'u', 'r', 'e', ' ', 'I', 'M', 0, 0}; -const capstr capIcqJSin = {'s', 'i', 'n', 'j', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // Miranda ICQJ S!N -const capstr capIcqJp = {'i', 'c', 'q', 'p', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const capstr capAimOscar = {'M', 'i', 'r', 'a', 'n', 'd', 'a', 'A', 0, 0, 0, 0, 0, 0, 0, 0}; -const capstr capMimMobile = {'M', 'i', 'r', 'a', 'n', 'd', 'a', 'M', 'o', 'b', 'i', 'l', 'e', 0, 0, 0}; -const capstr capMimPack = {'M', 'I', 'M', '/', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // Custom Miranda Pack -const capstr capTrillian = {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34, 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x09}; -const capstr capTrilCrypt = {0xf2, 0xe7, 0xc7, 0xf4, 0xfe, 0xad, 0x4d, 0xfb, 0xb2, 0x35, 0x36, 0x79, 0x8b, 0xdf, 0x00, 0x00}; -const capstr capSim = {'S', 'I', 'M', ' ', 'c', 'l', 'i', 'e', 'n', 't', ' ', ' ', 0, 0, 0, 0}; -const capstr capSimOld = {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34, 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x00}; -const capstr capLicq = {'L', 'i', 'c', 'q', ' ', 'c', 'l', 'i', 'e', 'n', 't', ' ', 0, 0, 0, 0}; -const capstr capKopete = {'K', 'o', 'p', 'e', 't', 'e', ' ', 'I', 'C', 'Q', ' ', ' ', 0, 0, 0, 0}; -const capstr capmIcq = {'m', 'I', 'C', 'Q', ' ', 0xA9, ' ', 'R', '.', 'K', '.', ' ', 0, 0, 0, 0}; -const capstr capClimm = {'c', 'l', 'i', 'm', 'm', 0xA9, ' ', 'R', '.', 'K', '.', ' ', 0, 0, 0, 0}; -const capstr capAndRQ = {'&', 'R', 'Q', 'i', 'n', 's', 'i', 'd', 'e', 0, 0, 0, 0, 0, 0, 0}; -const capstr capRAndQ = {'R', '&', 'Q', 'i', 'n', 's', 'i', 'd', 'e', 0, 0, 0, 0, 0, 0, 0}; -const capstr capIMadering = {'I', 'M', 'a', 'd', 'e', 'r', 'i', 'n', 'g', ' ', 'C', 'l', 'i', 'e', 'n', 't'}; -const capstr capmChat = {'m', 'C', 'h', 'a', 't', ' ', 'i', 'c', 'q', ' ', 0, 0, 0, 0, 0, 0}; -const capstr capJimm = {'J', 'i', 'm', 'm', ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const capstr capCorePager = {'C', 'O', 'R', 'E', ' ', 'P', 'a', 'g', 'e', 'r', 0, 0, 0, 0, 0, 0}; -const capstr capDiChat = {'D', '[', 'i', ']', 'C', 'h', 'a', 't', ' ', 0, 0, 0, 0, 0, 0, 0}; -const capstr capVmIcq = {'V', 'm', 'I', 'C', 'Q', ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const capstr capSmapeR = {'S', 'm', 'a', 'p', 'e', 'r', ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const capstr capAnastasia = {0x44, 0xE5, 0xBF, 0xCE, 0xB0, 0x96, 0xE5, 0x47, 0xBD, 0x65, 0xEF, 0xD6, 0xA3, 0x7E, 0x36, 0x02}; -const capstr capPalmJicq = {'J', 'I', 'C', 'Q', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const capstr capInluxMsgr = {0xA7, 0xE4, 0x0A, 0x96, 0xB3, 0xA0, 0x47, 0x9A, 0xB8, 0x45, 0xC9, 0xE4, 0x67, 0xC5, 0x6B, 0x1F}; -const capstr capYapp = {'Y', 'a', 'p', 'p', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const capstr capMipClient = {0x4d, 0x49, 0x50, 0x20, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x76, 0x00, 0x00, 0x00, 0x00}; -const capstr capPigeon = {'P', 'I', 'G', 'E', 'O', 'N', '!', 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const capstr capDigsbyBeta = {0x09, 0x46, 0x01, 0x05, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x45, 0x53, 0x54, 0x00}; -const capstr capDigsby = {'d', 'i', 'g', 's', 'b', 'y', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const capstr capJapp = {0x6a, 0x61, 0x70, 0x70, 0xa9, 0x20, 0x62, 0x79, 0x20, 0x53, 0x65, 0x72, 0x67, 0x6f, 0x00, 0x00}; -const capstr capNaim = {0xFF, 0xFF, 0xFF, 0xFF, 'n', 'a', 'i', 'm', 0, 0, 0, 0, 0, 0, 0, 0}; -const capstr capCitron = {0x09, 0x19, 0x19, 0x82, 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}; -const capstr capQip = {0x56, 0x3F, 0xC8, 0x09, 0x0B, 0x6F, 0x41, 'Q', 'I', 'P', ' ', '2', '0', '0', '5', 'a'}; -const capstr capQipPDA = {0x56, 0x3F, 0xC8, 0x09, 0x0B, 0x6F, 0x41, 'Q', 'I', 'P', ' ', ' ', ' ', ' ', ' ', '!'}; -const capstr capQipSymbian = {0x51, 0xAD, 0xD1, 0x90, 0x72, 0x04, 0x47, 0x3D, 0xA1, 0xA1, 0x49, 0xF4, 0xA3, 0x97, 0xA4, 0x1F}; -const capstr capQipIphone = {0x60, 0xDE, 0x5C, 0x8A, 0xDF, 0x8C, 0x4E, 0x1D, 0xA4, 0xC8, 0xBC, 0x3B, 0xD9, 0x79, 0x4D, 0xD8}; -const capstr capQipMobile = {0xB0, 0x82, 0x62, 0xF6, 0x7F, 0x7C, 0x45, 0x61, 0xAD, 0xC1, 0x1C, 0x6D, 0x75, 0x70, 0x5E, 0xC5}; -const capstr capQipInfium = {0x7C, 0x73, 0x75, 0x02, 0xC3, 0xBE, 0x4F, 0x3E, 0xA6, 0x9F, 0x01, 0x53, 0x13, 0x43, 0x1E, 0x1A}; -const capstr capQip2010 = {0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x0A, 0x03, 0x0B, 0x04, 0x01, 0x53, 0x00, 0x00, 0x00, 0x00}; -const capstr capQip2012 = {0x7F, 0x7F, 0x7C, 0x7D, 0x7E, 0x7F, 0x0A, 0x03, 0x0B, 0x04, 0x01, 0x53, 0x13, 0x43, 0x1E, 0x1A}; -const capstr capIm2 = {0x74, 0xED, 0xC3, 0x36, 0x44, 0xDF, 0x48, 0x5B, 0x8B, 0x1C, 0x67, 0x1A, 0x1F, 0x86, 0x09, 0x9F}; // IM2 Ext Msg -const capstr capQutIm = {'q', 'u', 't', 'i', 'm', 0x30, 0x2e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -const capstr capBayan = {'b', 'a', 'y', 'a', 'n', 'I', 'C', 'Q', 0, 0, 0, 0, 0, 0, 0, 0}; -const capstr capJabberJIT = {'J', 'I', 'T', ' ', 0x76, 0x2E, 0x31, 0x2E, 0x78, 0x2E, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00}; -const capstr capIcqKid2 = {'I', 'c', 'q', 'K', 'i', 'd', '2', 0x00, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -const capstr capWebIcqPro = {'W', 'e', 'b', 'I', 'c', 'q', 'P', 'r', 'o', ' ', 0, 0, 0, 0, 0, 0}; -const capstr capJasmine = {0x4A, 0x61, 0x73, 0x6D, 0x69, 0x6E, 0x65, 0x20, 0x76, 0x65, 0x72, 0xFF, 0x00, 0x00, 0x00, 0x00}; -const capstr capMraJava = {0x4a, 0x32, 0x4d, 0x45, 0x20, 0x6d, 0x40, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x00, 0x00, 0x00, 0x00}; -const capstr capMacIcq = {0xdd, 0x16, 0xf2, 0x02, 0x84, 0xe6, 0x11, 0xd4, 0x90, 0xdb, 0x00, 0x10, 0x4b, 0x9b, 0x4b, 0x7d}; -const capstr capIs2001 = {0x2e, 0x7a, 0x64, 0x75, 0xfa, 0xdf, 0x4d, 0xc8, 0x88, 0x6f, 0xea, 0x35, 0x95, 0xfd, 0xb6, 0xdf}; -const capstr capIs2002 = {0x10, 0xcf, 0x40, 0xd1, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}; -const capstr capComm20012 = {0xa0, 0xe9, 0x3f, 0x37, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}; -const capstr capStrIcq = {0xa0, 0xe9, 0x3f, 0x37, 0x4f, 0xe9, 0xd3, 0x11, 0xbc, 0xd2, 0x00, 0x04, 0xac, 0x96, 0xdd, 0x96}; -const capstr capIcqLiteNew = {0xc8, 0x95, 0x3a, 0x9f, 0x21, 0xf1, 0x4f, 0xaa, 0xb0, 0xb2, 0x6d, 0xe6, 0x63, 0xab, 0xf5, 0xb7}; -const capstr capXtrazVideo = {0x17, 0x8C, 0x2D, 0x9B, 0xDA, 0xA5, 0x45, 0xBB, 0x8D, 0xDB, 0xF3, 0xBD, 0xBD, 0x53, 0xA1, 0x0A}; -const capstr capOscarChat = {0x74, 0x8F, 0x24, 0x20, 0x62, 0x87, 0x11, 0xD1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}; -const capstr capUim = {0xA7, 0xE4, 0x0A, 0x96, 0xB3, 0xA0, 0x47, 0x9A, 0xB8, 0x45, 0xC9, 0xE4, 0x67, 0xC5, 0x6B, 0x1F}; -const capstr capRambler = {0x7E, 0x11, 0xB7, 0x78, 0xA3, 0x53, 0x49, 0x26, 0xA8, 0x02, 0x44, 0x73, 0x52, 0x08, 0xC4, 0x2A}; -const capstr capAbv = {0x00, 0xE7, 0xE0, 0xDF, 0xA9, 0xD0, 0x4F, 0xe1, 0x91, 0x62, 0xC8, 0x90, 0x9A, 0x13, 0x2A, 0x1B}; -const capstr capNetvigator = {0x4C, 0x6B, 0x90, 0xA3, 0x3D, 0x2D, 0x48, 0x0E, 0x89, 0xD6, 0x2E, 0x4B, 0x2C, 0x10, 0xD9, 0x9F}; -const capstr captZers = {0xb2, 0xec, 0x8f, 0x16, 0x7c, 0x6f, 0x45, 0x1b, 0xbd, 0x79, 0xdc, 0x58, 0x49, 0x78, 0x88, 0xb9}; // CAP_TZERS -const capstr capSimpLite = {0x53, 0x49, 0x4D, 0x50, 0x53, 0x49, 0x4D, 0x50, 0x53, 0x49, 0x4D, 0x50, 0x53, 0x49, 0x4D, 0x50}; -const capstr capSimpPro = {0x53, 0x49, 0x4D, 0x50, 0x5F, 0x50, 0x52, 0x4F, 0x53, 0x49, 0x4D, 0x50, 0x5F, 0x50, 0x52, 0x4F}; -const capstr capIMsecure = {'I', 'M', 's', 'e', 'c', 'u', 'r', 'e', 'C', 'p', 'h', 'r', 0x00, 0x00, 0x06, 0x01}; // ZoneLabs -const capstr capIMSecKey1 = {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // ZoneLabs -const capstr capIMSecKey2 = {2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // ZoneLabs -const capstr capFakeHtml = {0x01, 0x38, 0xca, 0x7b, 0x76, 0x9a, 0x49, 0x15, 0x88, 0xf2, 0x13, 0xfc, 0x00, 0x97, 0x9e, 0xa8}; -const capstr capIcqIos = {0x09, 0x46, 0x13, 0x52, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 'D', 'E', 'S', 'T', 0x00, 0x00}; -const capstr capIcqAndroid = {0x09, 0x46, 0x13, 0x53, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 'D', 'E', 'S', 'T', 0x00, 0x00}; +const capstr capMirandaIm = { 'M', 'i', 'r', 'a', 'n', 'd', 'a', 'M', 0, 0, 0, 0, 0, 0, 0, 0 }; +const capstr capMirandaNg = { 'M', 'i', 'r', 'a', 'n', 'd', 'a', 'N', 0, 0, 0, 0, 0, 0, 0, 0 }; +const capstr capIcqJs7 = { 'i', 'c', 'q', 'j', ' ', 'S', 'e', 'c', 'u', 'r', 'e', ' ', 'I', 'M', 0, 0 }; +const capstr capIcqJSin = { 's', 'i', 'n', 'j', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // Miranda ICQJ S!N +const capstr capIcqJp = { 'i', 'c', 'q', 'p', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +const capstr capAimOscar = { 'M', 'i', 'r', 'a', 'n', 'd', 'a', 'A', 0, 0, 0, 0, 0, 0, 0, 0 }; +const capstr capMimMobile = { 'M', 'i', 'r', 'a', 'n', 'd', 'a', 'M', 'o', 'b', 'i', 'l', 'e', 0, 0, 0 }; +const capstr capMimPack = { 'M', 'I', 'M', '/', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // Custom Miranda Pack +const capstr capTrillian = { 0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34, 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x09 }; +const capstr capTrilCrypt = { 0xf2, 0xe7, 0xc7, 0xf4, 0xfe, 0xad, 0x4d, 0xfb, 0xb2, 0x35, 0x36, 0x79, 0x8b, 0xdf, 0x00, 0x00 }; +const capstr capSim = { 'S', 'I', 'M', ' ', 'c', 'l', 'i', 'e', 'n', 't', ' ', ' ', 0, 0, 0, 0 }; +const capstr capSimOld = { 0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34, 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x00 }; +const capstr capLicq = { 'L', 'i', 'c', 'q', ' ', 'c', 'l', 'i', 'e', 'n', 't', ' ', 0, 0, 0, 0 }; +const capstr capKopete = { 'K', 'o', 'p', 'e', 't', 'e', ' ', 'I', 'C', 'Q', ' ', ' ', 0, 0, 0, 0 }; +const capstr capmIcq = { 'm', 'I', 'C', 'Q', ' ', 0xA9, ' ', 'R', '.', 'K', '.', ' ', 0, 0, 0, 0 }; +const capstr capClimm = { 'c', 'l', 'i', 'm', 'm', 0xA9, ' ', 'R', '.', 'K', '.', ' ', 0, 0, 0, 0 }; +const capstr capAndRQ = { '&', 'R', 'Q', 'i', 'n', 's', 'i', 'd', 'e', 0, 0, 0, 0, 0, 0, 0 }; +const capstr capRAndQ = { 'R', '&', 'Q', 'i', 'n', 's', 'i', 'd', 'e', 0, 0, 0, 0, 0, 0, 0 }; +const capstr capIMadering = { 'I', 'M', 'a', 'd', 'e', 'r', 'i', 'n', 'g', ' ', 'C', 'l', 'i', 'e', 'n', 't' }; +const capstr capmChat = { 'm', 'C', 'h', 'a', 't', ' ', 'i', 'c', 'q', ' ', 0, 0, 0, 0, 0, 0 }; +const capstr capJimm = { 'J', 'i', 'm', 'm', ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +const capstr capCorePager = { 'C', 'O', 'R', 'E', ' ', 'P', 'a', 'g', 'e', 'r', 0, 0, 0, 0, 0, 0 }; +const capstr capDiChat = { 'D', '[', 'i', ']', 'C', 'h', 'a', 't', ' ', 0, 0, 0, 0, 0, 0, 0 }; +const capstr capVmIcq = { 'V', 'm', 'I', 'C', 'Q', ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +const capstr capSmapeR = { 'S', 'm', 'a', 'p', 'e', 'r', ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +const capstr capAnastasia = { 0x44, 0xE5, 0xBF, 0xCE, 0xB0, 0x96, 0xE5, 0x47, 0xBD, 0x65, 0xEF, 0xD6, 0xA3, 0x7E, 0x36, 0x02 }; +const capstr capPalmJicq = { 'J', 'I', 'C', 'Q', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +const capstr capInluxMsgr = { 0xA7, 0xE4, 0x0A, 0x96, 0xB3, 0xA0, 0x47, 0x9A, 0xB8, 0x45, 0xC9, 0xE4, 0x67, 0xC5, 0x6B, 0x1F }; +const capstr capYapp = { 'Y', 'a', 'p', 'p', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +const capstr capMipClient = { 0x4d, 0x49, 0x50, 0x20, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x76, 0x00, 0x00, 0x00, 0x00 }; +const capstr capPigeon = { 'P', 'I', 'G', 'E', 'O', 'N', '!', 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +const capstr capDigsbyBeta = { 0x09, 0x46, 0x01, 0x05, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x45, 0x53, 0x54, 0x00 }; +const capstr capDigsby = { 'd', 'i', 'g', 's', 'b', 'y', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +const capstr capJapp = { 0x6a, 0x61, 0x70, 0x70, 0xa9, 0x20, 0x62, 0x79, 0x20, 0x53, 0x65, 0x72, 0x67, 0x6f, 0x00, 0x00 }; +const capstr capNaim = { 0xFF, 0xFF, 0xFF, 0xFF, 'n', 'a', 'i', 'm', 0, 0, 0, 0, 0, 0, 0, 0 }; +const capstr capCitron = { 0x09, 0x19, 0x19, 0x82, 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 }; +const capstr capQip = { 0x56, 0x3F, 0xC8, 0x09, 0x0B, 0x6F, 0x41, 'Q', 'I', 'P', ' ', '2', '0', '0', '5', 'a' }; +const capstr capQipPDA = { 0x56, 0x3F, 0xC8, 0x09, 0x0B, 0x6F, 0x41, 'Q', 'I', 'P', ' ', ' ', ' ', ' ', ' ', '!' }; +const capstr capQipSymbian = { 0x51, 0xAD, 0xD1, 0x90, 0x72, 0x04, 0x47, 0x3D, 0xA1, 0xA1, 0x49, 0xF4, 0xA3, 0x97, 0xA4, 0x1F }; +const capstr capQipIphone = { 0x60, 0xDE, 0x5C, 0x8A, 0xDF, 0x8C, 0x4E, 0x1D, 0xA4, 0xC8, 0xBC, 0x3B, 0xD9, 0x79, 0x4D, 0xD8 }; +const capstr capQipMobile = { 0xB0, 0x82, 0x62, 0xF6, 0x7F, 0x7C, 0x45, 0x61, 0xAD, 0xC1, 0x1C, 0x6D, 0x75, 0x70, 0x5E, 0xC5 }; +const capstr capQipInfium = { 0x7C, 0x73, 0x75, 0x02, 0xC3, 0xBE, 0x4F, 0x3E, 0xA6, 0x9F, 0x01, 0x53, 0x13, 0x43, 0x1E, 0x1A }; +const capstr capQip2010 = { 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x0A, 0x03, 0x0B, 0x04, 0x01, 0x53, 0x00, 0x00, 0x00, 0x00 }; +const capstr capQip2012 = { 0x7F, 0x7F, 0x7C, 0x7D, 0x7E, 0x7F, 0x0A, 0x03, 0x0B, 0x04, 0x01, 0x53, 0x13, 0x43, 0x1E, 0x1A }; +const capstr capIm2 = { 0x74, 0xED, 0xC3, 0x36, 0x44, 0xDF, 0x48, 0x5B, 0x8B, 0x1C, 0x67, 0x1A, 0x1F, 0x86, 0x09, 0x9F }; // IM2 Ext Msg +const capstr capQutIm = { 'q', 'u', 't', 'i', 'm', 0x30, 0x2e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +const capstr capBayan = { 'b', 'a', 'y', 'a', 'n', 'I', 'C', 'Q', 0, 0, 0, 0, 0, 0, 0, 0 }; +const capstr capJabberJIT = { 'J', 'I', 'T', ' ', 0x76, 0x2E, 0x31, 0x2E, 0x78, 0x2E, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00 }; +const capstr capIcqKid2 = { 'I', 'c', 'q', 'K', 'i', 'd', '2', 0x00, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +const capstr capWebIcqPro = { 'W', 'e', 'b', 'I', 'c', 'q', 'P', 'r', 'o', ' ', 0, 0, 0, 0, 0, 0 }; +const capstr capJasmine = { 0x4A, 0x61, 0x73, 0x6D, 0x69, 0x6E, 0x65, 0x20, 0x76, 0x65, 0x72, 0xFF, 0x00, 0x00, 0x00, 0x00 }; +const capstr capMraJava = { 0x4a, 0x32, 0x4d, 0x45, 0x20, 0x6d, 0x40, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x00, 0x00, 0x00, 0x00 }; +const capstr capMacIcq = { 0xdd, 0x16, 0xf2, 0x02, 0x84, 0xe6, 0x11, 0xd4, 0x90, 0xdb, 0x00, 0x10, 0x4b, 0x9b, 0x4b, 0x7d }; +const capstr capIs2001 = { 0x2e, 0x7a, 0x64, 0x75, 0xfa, 0xdf, 0x4d, 0xc8, 0x88, 0x6f, 0xea, 0x35, 0x95, 0xfd, 0xb6, 0xdf }; +const capstr capIs2002 = { 0x10, 0xcf, 0x40, 0xd1, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 }; +const capstr capComm20012 = { 0xa0, 0xe9, 0x3f, 0x37, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 }; +const capstr capStrIcq = { 0xa0, 0xe9, 0x3f, 0x37, 0x4f, 0xe9, 0xd3, 0x11, 0xbc, 0xd2, 0x00, 0x04, 0xac, 0x96, 0xdd, 0x96 }; +const capstr capIcqLiteNew = { 0xc8, 0x95, 0x3a, 0x9f, 0x21, 0xf1, 0x4f, 0xaa, 0xb0, 0xb2, 0x6d, 0xe6, 0x63, 0xab, 0xf5, 0xb7 }; +const capstr capXtrazVideo = { 0x17, 0x8C, 0x2D, 0x9B, 0xDA, 0xA5, 0x45, 0xBB, 0x8D, 0xDB, 0xF3, 0xBD, 0xBD, 0x53, 0xA1, 0x0A }; +const capstr capOscarChat = { 0x74, 0x8F, 0x24, 0x20, 0x62, 0x87, 0x11, 0xD1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 }; +const capstr capUim = { 0xA7, 0xE4, 0x0A, 0x96, 0xB3, 0xA0, 0x47, 0x9A, 0xB8, 0x45, 0xC9, 0xE4, 0x67, 0xC5, 0x6B, 0x1F }; +const capstr capRambler = { 0x7E, 0x11, 0xB7, 0x78, 0xA3, 0x53, 0x49, 0x26, 0xA8, 0x02, 0x44, 0x73, 0x52, 0x08, 0xC4, 0x2A }; +const capstr capAbv = { 0x00, 0xE7, 0xE0, 0xDF, 0xA9, 0xD0, 0x4F, 0xe1, 0x91, 0x62, 0xC8, 0x90, 0x9A, 0x13, 0x2A, 0x1B }; +const capstr capNetvigator = { 0x4C, 0x6B, 0x90, 0xA3, 0x3D, 0x2D, 0x48, 0x0E, 0x89, 0xD6, 0x2E, 0x4B, 0x2C, 0x10, 0xD9, 0x9F }; +const capstr captZers = { 0xb2, 0xec, 0x8f, 0x16, 0x7c, 0x6f, 0x45, 0x1b, 0xbd, 0x79, 0xdc, 0x58, 0x49, 0x78, 0x88, 0xb9 }; // CAP_TZERS +const capstr capSimpLite = { 0x53, 0x49, 0x4D, 0x50, 0x53, 0x49, 0x4D, 0x50, 0x53, 0x49, 0x4D, 0x50, 0x53, 0x49, 0x4D, 0x50 }; +const capstr capSimpPro = { 0x53, 0x49, 0x4D, 0x50, 0x5F, 0x50, 0x52, 0x4F, 0x53, 0x49, 0x4D, 0x50, 0x5F, 0x50, 0x52, 0x4F }; +const capstr capIMsecure = { 'I', 'M', 's', 'e', 'c', 'u', 'r', 'e', 'C', 'p', 'h', 'r', 0x00, 0x00, 0x06, 0x01 }; // ZoneLabs +const capstr capIMSecKey1 = { 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // ZoneLabs +const capstr capIMSecKey2 = { 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // ZoneLabs +const capstr capFakeHtml = { 0x01, 0x38, 0xca, 0x7b, 0x76, 0x9a, 0x49, 0x15, 0x88, 0xf2, 0x13, 0xfc, 0x00, 0x97, 0x9e, 0xa8 }; +const capstr capIcqIos = { 0x09, 0x46, 0x13, 0x52, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 'D', 'E', 'S', 'T', 0x00, 0x00 }; +const capstr capIcqAndroid = { 0x09, 0x46, 0x13, 0x53, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 'D', 'E', 'S', 'T', 0x00, 0x00 }; const shortcapstr capAimIcon = { 0x13, 0x46 }; // CAP_AIM_BUDDYICON const shortcapstr capAimDirect = { 0x13, 0x45 }; // CAP_AIM_DIRECTIM @@ -178,15 +178,15 @@ const shortcapstr capAimLiveVideo = { 0x01, 0x01 }; // CAP_AIM_LIVE_VIDEO const shortcapstr capAimLiveAudio = { 0x01, 0x04 }; // CAP_AIM_LIVE_AUDIO const shortcapstr capStatusTextAware = { 0x01, 0x0A }; // CAP_HOST_STATUS_TEXT_AWARE -const char* cliLibicq2k = "libicq2000"; -const char* cliLicqVer = "Licq "; +const char* cliLibicq2k = "libicq2000"; +const char* cliLicqVer = "Licq "; const char* cliCentericq = "Centericq"; const char* cliLibicqUTF = "libicq2000 (Unicode)"; -const char* cliTrillian = "Trillian"; +const char* cliTrillian = "Trillian"; const char* cliTrillian4 = "Trillian Astra"; -const char* cliQip = "QIP %s"; -const char* cliIM2 = "IM2"; -const char* cliSpamBot = "Spam Bot"; +const char* cliQip = "QIP %s"; +const char* cliIM2 = "IM2"; +const char* cliSpamBot = "Spam Bot"; const char* CIcqProto::detectUserClient( MCONTACT hContact, int nIsICQ, WORD wUserClass, DWORD dwOnlineSince, const char *szCurrentClient, @@ -287,7 +287,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) diff --git a/protocols/IcqOscarJ/src/icq_direct.cpp b/protocols/IcqOscarJ/src/icq_direct.cpp index 77f34665a0..00d3fc61d4 100644 --- a/protocols/IcqOscarJ/src/icq_direct.cpp +++ b/protocols/IcqOscarJ/src/icq_direct.cpp @@ -618,7 +618,7 @@ void CIcqProto::handleDirectPacket(directconnect* dc, PBYTE buf, size_t wLen) NetLog_Direct("Received PEER_MSG from %u", dc->dwRemoteUin); if (dc->initialised) - handleDirectMessage(dc, buf+1, wLen-1); + handleDirectMessage(dc, buf + 1, wLen - 1); else NetLog_Direct("Received %s on uninitialised DC, ignoring.", "PEER_MSG"); diff --git a/protocols/IcqOscarJ/src/icq_direct.h b/protocols/IcqOscarJ/src/icq_direct.h index 1f18a1d1d0..b3780596e9 100644 --- a/protocols/IcqOscarJ/src/icq_direct.h +++ b/protocols/IcqOscarJ/src/icq_direct.h @@ -26,7 +26,7 @@ #ifndef __ICQ_DIRECT_H #define __ICQ_DIRECT_H -struct filetransfer: public basic_filetransfer +struct filetransfer : public basic_filetransfer { int status; int sending; diff --git a/protocols/IcqOscarJ/src/icq_directmsg.cpp b/protocols/IcqOscarJ/src/icq_directmsg.cpp index 60c056c866..ca7925b89c 100644 --- a/protocols/IcqOscarJ/src/icq_directmsg.cpp +++ b/protocols/IcqOscarJ/src/icq_directmsg.cpp @@ -29,7 +29,7 @@ void CIcqProto::handleDirectMessage(directconnect* dc, PBYTE buf, size_t wLen) { WORD wCommand; WORD wCookie; - BYTE bMsgType,bMsgFlags; + BYTE bMsgType, bMsgFlags; WORD wStatus; WORD wFlags; WORD wTextLen; @@ -58,7 +58,7 @@ void CIcqProto::handleDirectMessage(directconnect* dc, PBYTE buf, size_t wLen) // Sequence number unpackLEWord(&buf, &wCookie); - wLen -=2; + wLen -= 2; // Unknown, always zeroes buf += 12; @@ -90,9 +90,8 @@ void CIcqProto::handleDirectMessage(directconnect* dc, PBYTE buf, size_t wLen) // Messagetext. This is either the status message or the actual message // when this is a PEER_MSG_MSG packet unpackLEWord(&buf, &wTextLen); - if (wTextLen > 0) - { - pszText = (char*)_alloca(wTextLen+1); + if (wTextLen > 0) { + pszText = (char*)_alloca(wTextLen + 1); unpackString(&buf, pszText, wTextLen); pszText[wTextLen] = '\0'; } @@ -192,7 +191,7 @@ void CIcqProto::handleDirectMessage(directconnect* dc, PBYTE buf, size_t wLen) } } } - else if (wCommand == DIRECT_CANCEL) + else if (wCommand == DIRECT_CANCEL) NetLog_Direct("Cannot handle abort messages yet... :("); else NetLog_Direct("Unknown wCommand, packet skipped"); diff --git a/protocols/IcqOscarJ/src/icq_fieldnames.h b/protocols/IcqOscarJ/src/icq_fieldnames.h index d3f60dfe2e..e7b2fa009b 100644 --- a/protocols/IcqOscarJ/src/icq_fieldnames.h +++ b/protocols/IcqOscarJ/src/icq_fieldnames.h @@ -27,8 +27,8 @@ struct FieldNamesItem { - int code; - char *text; + int code; + char *text; }; extern FieldNamesItem timezonesField[]; diff --git a/protocols/IcqOscarJ/src/icq_filerequests.cpp b/protocols/IcqOscarJ/src/icq_filerequests.cpp index c6452896f3..793caa9712 100644 --- a/protocols/IcqOscarJ/src/icq_filerequests.cpp +++ b/protocols/IcqOscarJ/src/icq_filerequests.cpp @@ -80,7 +80,7 @@ void CIcqProto::handleFileAck(PBYTE buf, size_t wLen, DWORD dwUin, DWORD dwCooki unpackString(&buf, pszFileName, wFilenameLength); pszFileName[wFilenameLength] = '\0'; } - wLen -= wFilenameLength+2; + wLen -= wFilenameLength + 2; if (wLen >= 4) unpackLEDWord(&buf, &dwFileSize); diff --git a/protocols/IcqOscarJ/src/icq_filetransfer.cpp b/protocols/IcqOscarJ/src/icq_filetransfer.cpp index 03f3484bcb..9caec02d08 100644 --- a/protocols/IcqOscarJ/src/icq_filetransfer.cpp +++ b/protocols/IcqOscarJ/src/icq_filetransfer.cpp @@ -116,7 +116,7 @@ static void file_sendNextFile(CIcqProto* ppro, directconnect* dc) szThisFileNameAnsi = _strdup(pszThisFileName); // Legacy fix if (!utf8_decode(szThisSubDir, &szThisSubDirAnsi)) szThisSubDirAnsi = _strdup(szThisSubDir); // Legacy fix - + size_t wThisFileNameLen = mir_strlen(szThisFileNameAnsi); size_t wThisSubDirLen = mir_strlen(szThisSubDirAnsi); @@ -261,7 +261,7 @@ void CIcqProto::icq_sendFileResume(filetransfer *ft, int action, const char *szF void NormalizeBackslash(char* path) { size_t len = mir_strlen(path); - if (len && path[len-1] != '\\') + if (len && path[len - 1] != '\\') mir_strcat(path, "\\"); } @@ -345,7 +345,7 @@ void CIcqProto::handleFileTransferPacket(directconnect* dc, PBYTE buf, size_t wL unpackLEWord(&buf, &wThisFilenameLen); if (wLen < 19 + wThisFilenameLen) return; - + SAFE_FREE(&dc->ft->szThisFile); char *szAnsi = (char *)_alloca(wThisFilenameLen + 1); memcpy(szAnsi, buf, wThisFilenameLen); diff --git a/protocols/IcqOscarJ/src/icq_firstrun.cpp b/protocols/IcqOscarJ/src/icq_firstrun.cpp index 6dc0cb6e8f..051d2a8974 100644 --- a/protocols/IcqOscarJ/src/icq_firstrun.cpp +++ b/protocols/IcqOscarJ/src/icq_firstrun.cpp @@ -34,21 +34,21 @@ static void accountLoadDetails(CIcqProto *ppro, HWND hwndDlg) SetDlgItemTextA(hwndDlg, IDC_UIN, pszUIN); } - char pszPwd[PASSWORDMAXLEN+1]; + char pszPwd[PASSWORDMAXLEN + 1]; if (ppro->GetUserStoredPassword(pszPwd)) SetDlgItemTextA(hwndDlg, IDC_PW, pszPwd); } INT_PTR CALLBACK icq_FirstRunDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - CIcqProto* ppro = (CIcqProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA ); + CIcqProto* ppro = (CIcqProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); ppro = (CIcqProto*)lParam; - SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam ); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); Window_SetIcon_IcoLib(hwndDlg, ppro->m_hProtoIcon); diff --git a/protocols/IcqOscarJ/src/icq_http.cpp b/protocols/IcqOscarJ/src/icq_http.cpp index 8c312453af..da6777799e 100644 --- a/protocols/IcqOscarJ/src/icq_http.cpp +++ b/protocols/IcqOscarJ/src/icq_http.cpp @@ -38,8 +38,7 @@ int icq_httpGatewayInit(HNETLIBCONN hConn, NETLIBOPENCONNECTION*, NETLIBHTTPREQU BYTE *buf; char szSid[33], szHttpServer[256], szHttpGetUrl[300], szHttpPostUrl[300]; - if (nlhr->dataLength < 31) - { + if (nlhr->dataLength < 31) { SetLastError(ERROR_INVALID_DATA); return 0; } @@ -56,8 +55,7 @@ int icq_httpGatewayInit(HNETLIBCONN hConn, NETLIBOPENCONNECTION*, NETLIBHTTPREQU mir_snprintf(szSid, "%08x%08x%08x%08x", dwSid1, dwSid2, dwSid3, dwSid4); unpackWord(&buf, &wIpLen); - if(nlhr->dataLength < 30 + wIpLen || wIpLen == 0 || wIpLen > sizeof(szHttpServer) - 1) - { + if (nlhr->dataLength < 30 + wIpLen || wIpLen == 0 || wIpLen > sizeof(szHttpServer) - 1) { SetLastError(ERROR_INVALID_DATA); return 0; } @@ -91,7 +89,7 @@ int icq_httpGatewayBegin(HNETLIBCONN hConn, NETLIBOPENCONNECTION* nloc) packWord(&packet, (WORD)serverNameLen); packBuffer(&packet, (LPBYTE)nloc->szHost, serverNameLen); packWord(&packet, nloc->wPort); - INT_PTR res = Netlib_Send(hConn, (char*)packet.pData, packet.wLen, MSG_DUMPPROXY|MSG_NOHTTPGATEWAYWRAP); + INT_PTR res = Netlib_Send(hConn, (char*)packet.pData, packet.wLen, MSG_DUMPPROXY | MSG_NOHTTPGATEWAYWRAP); SAFE_FREE((void**)&packet.pData); return res != SOCKET_ERROR; @@ -105,8 +103,7 @@ int icq_httpGatewayWrapSend(HNETLIBCONN hConn, PBYTE buf, int len, int flags) int sendLen = len; int sendResult = 0; - while (sendLen > 0) - { // imitate polite behaviour of icq5.1 and split large packets + while (sendLen > 0) { // imitate polite behaviour of icq5.1 and split large packets icq_packet packet; WORD curLen; int curResult; @@ -118,7 +115,7 @@ int icq_httpGatewayWrapSend(HNETLIBCONN hConn, PBYTE buf, int len, int flags) packBuffer(&packet, sendBuf, curLen); curResult = Netlib_Send(hConn, (char*)packet.pData, packet.wLen, flags); - + SAFE_FREE((void**)&packet.pData); // sending failed, end loop @@ -144,8 +141,7 @@ PBYTE icq_httpGatewayUnwrapRecv(NETLIBHTTPREQUEST*, PBYTE buf, int len, int* out size_t i = 0; tbuf = buf; - for(;;) - { + for (;;) { if (tbuf - buf + 2 > len) break; unpackWord(&tbuf, &wLen); @@ -157,31 +153,27 @@ PBYTE icq_httpGatewayUnwrapRecv(NETLIBHTTPREQUEST*, PBYTE buf, int len, int* out unpackWord(&tbuf, &wType); tbuf += 4; /* flags */ unpackDWord(&tbuf, &dwPackSeq); - if (wType == HTTP_PACKETTYPE_FLAP) - { // it is normal data packet + if (wType == HTTP_PACKETTYPE_FLAP) { // it is normal data packet size_t copyBytes = wLen - 12; - if (copyBytes > len - i) - { + if (copyBytes > len - i) { /* invalid data - do our best to get something out of it */ copyBytes = len - i; } memcpy(buf + i, tbuf, copyBytes); i += copyBytes; } - else if (wType == HTTP_PACKETTYPE_LOGINREPLY) - { // our "virtual connection" was established, good + else if (wType == HTTP_PACKETTYPE_LOGINREPLY) { // our "virtual connection" was established, good BYTE bRes; unpackByte(&tbuf, &bRes); wLen -= 1; if (!bRes) - Netlib_Logf( nullptr, "Gateway Connection #%d Established.", dwPackSeq); + Netlib_Logf(nullptr, "Gateway Connection #%d Established.", dwPackSeq); else - Netlib_Logf( nullptr, "Gateway Connection #%d Failed, error: %d", dwPackSeq, bRes); + Netlib_Logf(nullptr, "Gateway Connection #%d Failed, error: %d", dwPackSeq, bRes); } - else if (wType == HTTP_PACKETTYPE_CLOSEREPLY) - { // "virtual connection" closed - only received if any other "virual connection" still active - Netlib_Logf( nullptr, "Gateway Connection #%d Closed.", dwPackSeq); + else if (wType == HTTP_PACKETTYPE_CLOSEREPLY) { // "virtual connection" closed - only received if any other "virual connection" still active + Netlib_Logf(nullptr, "Gateway Connection #%d Closed.", dwPackSeq); } tbuf += wLen - 12; } @@ -190,8 +182,6 @@ PBYTE icq_httpGatewayUnwrapRecv(NETLIBHTTPREQUEST*, PBYTE buf, int len, int* out return buf; } - - int icq_httpGatewayWalkTo(HNETLIBCONN hConn, NETLIBOPENCONNECTION* nloc) { // this is bad simplification - for avatars to work we need to handle // two "virtual connections" at the same time @@ -200,7 +190,7 @@ int icq_httpGatewayWalkTo(HNETLIBCONN hConn, NETLIBOPENCONNECTION* nloc) packet.wLen = 0; write_httphdr(&packet, HTTP_PACKETTYPE_CLOSE, dwGatewaySeq); - Netlib_Send(hConn, (char*)packet.pData, packet.wLen, MSG_DUMPPROXY|MSG_NOHTTPGATEWAYWRAP); + Netlib_Send(hConn, (char*)packet.pData, packet.wLen, MSG_DUMPPROXY | MSG_NOHTTPGATEWAYWRAP); // we closed virtual connection, open new one dwGatewaySeq++; SetGatewayIndex(hConn, dwGatewaySeq); diff --git a/protocols/IcqOscarJ/src/icq_infoupdate.cpp b/protocols/IcqOscarJ/src/icq_infoupdate.cpp index 518e496b92..461619a54a 100644 --- a/protocols/IcqOscarJ/src/icq_infoupdate.cpp +++ b/protocols/IcqOscarJ/src/icq_infoupdate.cpp @@ -145,7 +145,7 @@ void CIcqProto::icq_EnableUserLookup(BOOL bEnable) SetEvent(hInfoQueueEvent); } -void __cdecl CIcqProto::InfoUpdateThread( void* ) +void __cdecl CIcqProto::InfoUpdateThread(void*) { int i; DWORD dwWait = WAIT_OBJECT_0; diff --git a/protocols/IcqOscarJ/src/icq_menu.cpp b/protocols/IcqOscarJ/src/icq_menu.cpp index 284a41db5a..1a017715ca 100644 --- a/protocols/IcqOscarJ/src/icq_menu.cpp +++ b/protocols/IcqOscarJ/src/icq_menu.cpp @@ -48,7 +48,7 @@ static INT_PTR IcqMenuHandleOpenProfile(WPARAM wParam, LPARAM lParam) return (ppro) ? ppro->OpenWebProfile(wParam, lParam) : 0; } -static int IcqPrebuildContactMenu( WPARAM wParam, LPARAM lParam ) +static int IcqPrebuildContactMenu(WPARAM wParam, LPARAM lParam) { Menu_ShowItem(g_hContactMenuItems[ICMI_ADD_TO_SERVLIST], FALSE); Menu_ShowItem(g_hContactMenuItems[ICMI_XSTATUS_DETAILS], FALSE); @@ -72,7 +72,7 @@ void g_MenuInit(void) CMenuItem mi(g_plugin); mi.pszService = str; - + // "Add to server list" mir_strcpy(pszDest, MS_ICQ_ADDSERVCONTACT); CreateServiceFunction(str, IcqMenuHandleAddServContact); SET_UID(mi, 0x3928ba10, 0x69bc, 0x4ec9, 0x96, 0x48, 0xa4, 0x1b, 0xbe, 0x58, 0x4a, 0x7e); @@ -80,15 +80,15 @@ void g_MenuInit(void) mi.position = -2049999999; mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_ADD); g_hContactMenuItems[ICMI_ADD_TO_SERVLIST] = Menu_AddContactMenuItem(&mi); - + // "Show custom status details" - mir_strcpy(pszDest, MS_XSTATUS_SHOWDETAILS); CreateServiceFunction(str, IcqMenuHandleXStatusDetails); + mir_strcpy(pszDest, MS_XSTATUS_SHOWDETAILS); CreateServiceFunction(str, IcqMenuHandleXStatusDetails); SET_UID(mi, 0x4767918b, 0x898b, 0x4cb6, 0x9c, 0x54, 0x8c, 0x56, 0x6a, 0xc4, 0xed, 0x42); mi.name.a = LPGEN("Show custom status details"); mi.position = -2000004999; mi.hIcolibItem = nullptr; g_hContactMenuItems[ICMI_XSTATUS_DETAILS] = Menu_AddContactMenuItem(&mi); - + // "Open ICQ profile" mir_strcpy(pszDest, MS_OPEN_PROFILE); CreateServiceFunction(str, IcqMenuHandleOpenProfile); SET_UID(mi, 0x4f006492, 0x9fe5, 0x4d10, 0x88, 0xce, 0x47, 0x53, 0xba, 0x27, 0xe9, 0xc9); @@ -116,21 +116,21 @@ int CIcqProto::OnPreBuildContactMenu(WPARAM hContact, LPARAM) return 0; if (icqOnline()) { - BOOL bCtrlPressed = (GetKeyState(VK_CONTROL)&0x8000 ) != 0; + BOOL bCtrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0; DWORD dwUin = getContactUin(hContact); Menu_ShowItem(m_hmiReqAuth, dwUin && (bCtrlPressed || (getByte(hContact, "Auth", 0) && getWord(hContact, DBSETTING_SERVLIST_ID, 0)))); Menu_ShowItem(m_hmiGrantAuth, dwUin && (bCtrlPressed || getByte(hContact, "Grant", 0))); Menu_ShowItem(m_hmiRevokeAuth, dwUin && (bCtrlPressed || (getByte("PrivacyItems", 0) && !getByte(hContact, "Grant", 0)))); - + Menu_ShowItem(g_hContactMenuItems[ICMI_ADD_TO_SERVLIST], m_bSsiEnabled && !getWord(hContact, DBSETTING_SERVLIST_ID, 0) && !getWord(hContact, DBSETTING_SERVLIST_IGNORE, 0) && !db_get_b(hContact, "CList", "NotOnList", 0)); } - Menu_ShowItem(g_hContactMenuItems[ICMI_OPEN_PROFILE],getContactUin(hContact) != 0); + Menu_ShowItem(g_hContactMenuItems[ICMI_OPEN_PROFILE], getContactUin(hContact) != 0); BYTE bXStatus = getContactXStatus(hContact); Menu_ShowItem(g_hContactMenuItems[ICMI_XSTATUS_DETAILS], m_bHideXStatusUI ? 0 : bXStatus != 0); diff --git a/protocols/IcqOscarJ/src/icq_opts.cpp b/protocols/IcqOscarJ/src/icq_opts.cpp index 94817c3c42..19505a40ad 100644 --- a/protocols/IcqOscarJ/src/icq_opts.cpp +++ b/protocols/IcqOscarJ/src/icq_opts.cpp @@ -57,7 +57,7 @@ static void OptDlgChanged(HWND hwndDlg) static INT_PTR CALLBACK DlgProcIcqOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - CIcqProto *ppro = (CIcqProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA ); + CIcqProto *ppro = (CIcqProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: @@ -75,7 +75,7 @@ static INT_PTR CALLBACK DlgProcIcqOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendDlgItemMessage(hwndDlg, IDC_PASSWORD, EM_LIMITTEXT, PASSWORDMAXLEN, 0); // bit of a security hole here, since it's easy to extract a password from an edit box - char pszPwd[PASSWORDMAXLEN+1]; + char pszPwd[PASSWORDMAXLEN + 1]; if (ppro->GetUserStoredPassword(pszPwd)) SetDlgItemTextA(hwndDlg, IDC_PASSWORD, pszPwd); @@ -133,7 +133,7 @@ static INT_PTR CALLBACK DlgProcIcqOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP } if ((LOWORD(wParam) == IDC_ICQNUM || LOWORD(wParam) == IDC_PASSWORD || LOWORD(wParam) == IDC_ICQSERVER || LOWORD(wParam) == IDC_ICQPORT) && - (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) { + (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) { return 0; } @@ -295,7 +295,8 @@ static INT_PTR CALLBACK DlgProcIcqPrivacyOpts(HWND hwndDlg, UINT msg, WPARAM wPa static HWND hCpCombo; -struct CPTABLE { +struct CPTABLE +{ int cpId; char *cpName; }; diff --git a/protocols/IcqOscarJ/src/icq_packet.cpp b/protocols/IcqOscarJ/src/icq_packet.cpp index 313562af13..bf57851409 100644 --- a/protocols/IcqOscarJ/src/icq_packet.cpp +++ b/protocols/IcqOscarJ/src/icq_packet.cpp @@ -188,7 +188,7 @@ int __fastcall getUIDLen(DWORD dwUin, const char *szUid) { if (dwUin) return getUINLen(dwUin); - + return (int)mir_strlen(szUid); } diff --git a/protocols/IcqOscarJ/src/icq_popups.cpp b/protocols/IcqOscarJ/src/icq_popups.cpp index e067fd966a..2e824c9ff1 100644 --- a/protocols/IcqOscarJ/src/icq_popups.cpp +++ b/protocols/IcqOscarJ/src/icq_popups.cpp @@ -45,7 +45,7 @@ INT_PTR CALLBACK DlgProcIcqPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR { static bool bInitDone = true; BYTE bEnabled; - CIcqProto* ppro = (CIcqProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA ); + CIcqProto* ppro = (CIcqProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: @@ -55,46 +55,43 @@ INT_PTR CALLBACK DlgProcIcqPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR ppro = (CIcqProto*)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - CheckDlgButton(hwndDlg, IDC_POPUPS_LOG_ENABLED, ppro->getByte(NULL,"PopupsLogEnabled",DEFAULT_LOG_POPUPS_ENABLED) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_POPUPS_SPAM_ENABLED, ppro->getByte(NULL,"PopupsSpamEnabled",DEFAULT_SPAM_POPUPS_ENABLED) ? BST_CHECKED : BST_UNCHECKED); - SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG0_TEXTCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL,"Popups0TextColor",DEFAULT_LOG0_TEXT_COLORS)); - SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG0_BACKCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL,"Popups0BackColor",DEFAULT_LOG0_BACK_COLORS)); - SetDlgItemInt(hwndDlg, IDC_POPUP_LOG0_TIMEOUT, ppro->getDword(NULL,"Popups0Timeout",DEFAULT_LOG0_TIMEOUT),FALSE); - SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG1_TEXTCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL,"Popups1TextColor",DEFAULT_LOG1_TEXT_COLORS)); - SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG1_BACKCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL,"Popups1BackColor",DEFAULT_LOG1_BACK_COLORS)); - SetDlgItemInt(hwndDlg, IDC_POPUP_LOG1_TIMEOUT, ppro->getDword(NULL,"Popups1Timeout",DEFAULT_LOG1_TIMEOUT),FALSE); - SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG2_TEXTCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL,"Popups2TextColor",DEFAULT_LOG2_TEXT_COLORS)); - SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG2_BACKCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL,"Popups2BackColor",DEFAULT_LOG2_BACK_COLORS)); - SetDlgItemInt(hwndDlg, IDC_POPUP_LOG2_TIMEOUT, ppro->getDword(NULL,"Popups2Timeout",DEFAULT_LOG2_TIMEOUT),FALSE); - SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG3_TEXTCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL,"Popups3TextColor",DEFAULT_LOG3_TEXT_COLORS)); - SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG3_BACKCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL,"Popups3BackColor",DEFAULT_LOG3_BACK_COLORS)); - SetDlgItemInt(hwndDlg, IDC_POPUP_LOG3_TIMEOUT, ppro->getDword(NULL,"Popups3Timeout",DEFAULT_LOG3_TIMEOUT),FALSE); - SendDlgItemMessage(hwndDlg, IDC_POPUP_SPAM_TEXTCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL,"PopupsSpamTextColor",DEFAULT_SPAM_TEXT_COLORS)); - SendDlgItemMessage(hwndDlg, IDC_POPUP_SPAM_BACKCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL,"PopupsSpamBackColor",DEFAULT_SPAM_BACK_COLORS)); - SetDlgItemInt(hwndDlg, IDC_POPUP_SPAM_TIMEOUT, ppro->getDword(NULL,"PopupsSpamTimeout",DEFAULT_SPAM_TIMEOUT),FALSE); - bEnabled = ppro->getByte(NULL,"PopupsWinColors",DEFAULT_POPUPS_WIN_COLORS); + CheckDlgButton(hwndDlg, IDC_POPUPS_LOG_ENABLED, ppro->getByte(NULL, "PopupsLogEnabled", DEFAULT_LOG_POPUPS_ENABLED) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_POPUPS_SPAM_ENABLED, ppro->getByte(NULL, "PopupsSpamEnabled", DEFAULT_SPAM_POPUPS_ENABLED) ? BST_CHECKED : BST_UNCHECKED); + SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG0_TEXTCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL, "Popups0TextColor", DEFAULT_LOG0_TEXT_COLORS)); + SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG0_BACKCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL, "Popups0BackColor", DEFAULT_LOG0_BACK_COLORS)); + SetDlgItemInt(hwndDlg, IDC_POPUP_LOG0_TIMEOUT, ppro->getDword(NULL, "Popups0Timeout", DEFAULT_LOG0_TIMEOUT), FALSE); + SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG1_TEXTCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL, "Popups1TextColor", DEFAULT_LOG1_TEXT_COLORS)); + SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG1_BACKCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL, "Popups1BackColor", DEFAULT_LOG1_BACK_COLORS)); + SetDlgItemInt(hwndDlg, IDC_POPUP_LOG1_TIMEOUT, ppro->getDword(NULL, "Popups1Timeout", DEFAULT_LOG1_TIMEOUT), FALSE); + SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG2_TEXTCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL, "Popups2TextColor", DEFAULT_LOG2_TEXT_COLORS)); + SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG2_BACKCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL, "Popups2BackColor", DEFAULT_LOG2_BACK_COLORS)); + SetDlgItemInt(hwndDlg, IDC_POPUP_LOG2_TIMEOUT, ppro->getDword(NULL, "Popups2Timeout", DEFAULT_LOG2_TIMEOUT), FALSE); + SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG3_TEXTCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL, "Popups3TextColor", DEFAULT_LOG3_TEXT_COLORS)); + SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG3_BACKCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL, "Popups3BackColor", DEFAULT_LOG3_BACK_COLORS)); + SetDlgItemInt(hwndDlg, IDC_POPUP_LOG3_TIMEOUT, ppro->getDword(NULL, "Popups3Timeout", DEFAULT_LOG3_TIMEOUT), FALSE); + SendDlgItemMessage(hwndDlg, IDC_POPUP_SPAM_TEXTCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL, "PopupsSpamTextColor", DEFAULT_SPAM_TEXT_COLORS)); + SendDlgItemMessage(hwndDlg, IDC_POPUP_SPAM_BACKCOLOR, CPM_SETCOLOUR, 0, ppro->getDword(NULL, "PopupsSpamBackColor", DEFAULT_SPAM_BACK_COLORS)); + SetDlgItemInt(hwndDlg, IDC_POPUP_SPAM_TIMEOUT, ppro->getDword(NULL, "PopupsSpamTimeout", DEFAULT_SPAM_TIMEOUT), FALSE); + bEnabled = ppro->getByte(NULL, "PopupsWinColors", DEFAULT_POPUPS_WIN_COLORS); CheckDlgButton(hwndDlg, IDC_USEWINCOLORS, bEnabled ? BST_CHECKED : BST_UNCHECKED); - bEnabled |= ppro->getByte(NULL,"PopupsDefColors",DEFAULT_POPUPS_DEF_COLORS); + bEnabled |= ppro->getByte(NULL, "PopupsDefColors", DEFAULT_POPUPS_DEF_COLORS); CheckDlgButton(hwndDlg, IDC_USEDEFCOLORS, bEnabled ? BST_CHECKED : BST_UNCHECKED); icq_EnableMultipleControls(hwndDlg, icqPopupColorControls, _countof(icqPopupColorControls), bEnabled); - CheckDlgButton(hwndDlg, IDC_USESYSICONS, ppro->getByte(NULL,"PopupsSysIcons",DEFAULT_POPUPS_SYS_ICONS) ? BST_CHECKED : BST_UNCHECKED); - bEnabled = ppro->getByte(NULL,"PopupsEnabled",DEFAULT_POPUPS_ENABLED); + CheckDlgButton(hwndDlg, IDC_USESYSICONS, ppro->getByte(NULL, "PopupsSysIcons", DEFAULT_POPUPS_SYS_ICONS) ? BST_CHECKED : BST_UNCHECKED); + bEnabled = ppro->getByte(NULL, "PopupsEnabled", DEFAULT_POPUPS_ENABLED); CheckDlgButton(hwndDlg, IDC_POPUPS_ENABLED, bEnabled ? BST_CHECKED : BST_UNCHECKED); icq_EnableMultipleControls(hwndDlg, icqPopupsControls, _countof(icqPopupsControls), bEnabled); - if (bEnabled) - { - if (IsDlgButtonChecked(hwndDlg, IDC_USEDEFCOLORS)) - { + if (bEnabled) { + if (IsDlgButtonChecked(hwndDlg, IDC_USEDEFCOLORS)) { EnableWindow(GetDlgItem(hwndDlg, IDC_USEWINCOLORS), !WM_ENABLE); EnableWindow(GetDlgItem(hwndDlg, IDC_USEDEFCOLORS), WM_ENABLE); } - else - { + else { EnableWindow(GetDlgItem(hwndDlg, IDC_USEWINCOLORS), WM_ENABLE); EnableWindow(GetDlgItem(hwndDlg, IDC_USEDEFCOLORS), !WM_ENABLE); } } - icq_EnableMultipleControls(hwndDlg, icqPopupColorControls, _countof(icqPopupColorControls), bEnabled & (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg,IDC_USEWINCOLORS) && BST_UNCHECKED == IsDlgButtonChecked(hwndDlg,IDC_USEDEFCOLORS))); + icq_EnableMultipleControls(hwndDlg, icqPopupColorControls, _countof(icqPopupColorControls), bEnabled & (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_USEWINCOLORS) && BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_USEDEFCOLORS))); bInitDone = true; return TRUE; @@ -102,59 +99,54 @@ INT_PTR CALLBACK DlgProcIcqPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR switch (LOWORD(wParam)) { case IDC_PREVIEW: { - ppro->ShowPopupMsg(NULL, LPGEN("Popup Title"), LPGEN("Sample Note"), LOG_NOTE); + ppro->ShowPopupMsg(NULL, LPGEN("Popup Title"), LPGEN("Sample Note"), LOG_NOTE); ppro->ShowPopupMsg(NULL, LPGEN("Popup Title"), LPGEN("Sample Warning"), LOG_WARNING); - ppro->ShowPopupMsg(NULL, LPGEN("Popup Title"), LPGEN("Sample Error"), LOG_ERROR); - ppro->ShowPopupMsg(NULL, LPGEN("Popup Title"), LPGEN("Sample Fatal"), LOG_FATAL); + ppro->ShowPopupMsg(NULL, LPGEN("Popup Title"), LPGEN("Sample Error"), LOG_ERROR); + ppro->ShowPopupMsg(NULL, LPGEN("Popup Title"), LPGEN("Sample Fatal"), LOG_FATAL); ppro->ShowPopupMsg(NULL, LPGEN("Popup Title"), LPGEN("Sample Spambot"), POPTYPE_SPAM); } return FALSE; case IDC_POPUPS_ENABLED: - bEnabled = IsDlgButtonChecked(hwndDlg,IDC_POPUPS_ENABLED); - if (bEnabled) - { - if (IsDlgButtonChecked(hwndDlg, IDC_USEDEFCOLORS)) - { + bEnabled = IsDlgButtonChecked(hwndDlg, IDC_POPUPS_ENABLED); + if (bEnabled) { + if (IsDlgButtonChecked(hwndDlg, IDC_USEDEFCOLORS)) { EnableWindow(GetDlgItem(hwndDlg, IDC_USEWINCOLORS), !WM_ENABLE); EnableWindow(GetDlgItem(hwndDlg, IDC_USEDEFCOLORS), WM_ENABLE); } - else - { + else { EnableWindow(GetDlgItem(hwndDlg, IDC_USEWINCOLORS), WM_ENABLE); EnableWindow(GetDlgItem(hwndDlg, IDC_USEDEFCOLORS), !WM_ENABLE); } } - else - { + else { EnableWindow(GetDlgItem(hwndDlg, IDC_USEWINCOLORS), !WM_ENABLE); EnableWindow(GetDlgItem(hwndDlg, IDC_USEDEFCOLORS), !WM_ENABLE); } icq_EnableMultipleControls(hwndDlg, icqPopupsControls, _countof(icqPopupsControls), bEnabled); case IDC_USEWINCOLORS: - bEnabled = IsDlgButtonChecked(hwndDlg,IDC_POPUPS_ENABLED); - if (bEnabled) - { + bEnabled = IsDlgButtonChecked(hwndDlg, IDC_POPUPS_ENABLED); + if (bEnabled) { if (IsDlgButtonChecked(hwndDlg, IDC_USEWINCOLORS)) EnableWindow(GetDlgItem(hwndDlg, IDC_USEDEFCOLORS), !WM_ENABLE); else EnableWindow(GetDlgItem(hwndDlg, IDC_USEDEFCOLORS), WM_ENABLE); } - icq_EnableMultipleControls(hwndDlg, icqPopupColorControls, _countof(icqPopupColorControls), !IsDlgButtonChecked(hwndDlg,IDC_USEWINCOLORS)); + icq_EnableMultipleControls(hwndDlg, icqPopupColorControls, _countof(icqPopupColorControls), !IsDlgButtonChecked(hwndDlg, IDC_USEWINCOLORS)); case IDC_USEDEFCOLORS: - bEnabled = IsDlgButtonChecked(hwndDlg,IDC_POPUPS_ENABLED); - if (bEnabled) - { + bEnabled = IsDlgButtonChecked(hwndDlg, IDC_POPUPS_ENABLED); + if (bEnabled) { if (IsDlgButtonChecked(hwndDlg, IDC_USEDEFCOLORS)) EnableWindow(GetDlgItem(hwndDlg, IDC_USEWINCOLORS), !WM_ENABLE); else EnableWindow(GetDlgItem(hwndDlg, IDC_USEWINCOLORS), WM_ENABLE); } - icq_EnableMultipleControls(hwndDlg, icqPopupColorControls, _countof(icqPopupColorControls), !IsDlgButtonChecked(hwndDlg,IDC_USEDEFCOLORS)); + icq_EnableMultipleControls(hwndDlg, icqPopupColorControls, _countof(icqPopupColorControls), !IsDlgButtonChecked(hwndDlg, IDC_USEDEFCOLORS)); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; + case IDC_POPUP_LOG0_TIMEOUT: case IDC_POPUP_LOG1_TIMEOUT: case IDC_POPUP_LOG2_TIMEOUT: @@ -172,27 +164,27 @@ INT_PTR CALLBACK DlgProcIcqPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: - ppro->setByte("PopupsEnabled",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_POPUPS_ENABLED)); - ppro->setByte("PopupsLogEnabled",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_POPUPS_LOG_ENABLED)); - ppro->setByte("PopupsSpamEnabled",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_POPUPS_SPAM_ENABLED)); - ppro->setDword("Popups0TextColor",SendDlgItemMessage(hwndDlg,IDC_POPUP_LOG0_TEXTCOLOR,CPM_GETCOLOUR,0,0)); - ppro->setDword("Popups0BackColor",SendDlgItemMessage(hwndDlg,IDC_POPUP_LOG0_BACKCOLOR,CPM_GETCOLOUR,0,0)); - ppro->setDword("Popups0Timeout",GetDlgItemInt(hwndDlg, IDC_POPUP_LOG0_TIMEOUT, nullptr, FALSE)); - ppro->setDword("Popups1TextColor",SendDlgItemMessage(hwndDlg,IDC_POPUP_LOG1_TEXTCOLOR,CPM_GETCOLOUR,0,0)); - ppro->setDword("Popups1BackColor",SendDlgItemMessage(hwndDlg,IDC_POPUP_LOG1_BACKCOLOR,CPM_GETCOLOUR,0,0)); - ppro->setDword("Popups1Timeout",GetDlgItemInt(hwndDlg, IDC_POPUP_LOG1_TIMEOUT, nullptr, FALSE)); - ppro->setDword("Popups2TextColor",SendDlgItemMessage(hwndDlg,IDC_POPUP_LOG2_TEXTCOLOR,CPM_GETCOLOUR,0,0)); - ppro->setDword("Popups2BackColor",SendDlgItemMessage(hwndDlg,IDC_POPUP_LOG2_BACKCOLOR,CPM_GETCOLOUR,0,0)); - ppro->setDword("Popups2Timeout",GetDlgItemInt(hwndDlg, IDC_POPUP_LOG2_TIMEOUT, nullptr, FALSE)); - ppro->setDword("Popups3TextColor",SendDlgItemMessage(hwndDlg,IDC_POPUP_LOG3_TEXTCOLOR,CPM_GETCOLOUR,0,0)); - ppro->setDword("Popups3BackColor",SendDlgItemMessage(hwndDlg,IDC_POPUP_LOG3_BACKCOLOR,CPM_GETCOLOUR,0,0)); - ppro->setDword("Popups3Timeout",GetDlgItemInt(hwndDlg, IDC_POPUP_LOG3_TIMEOUT, nullptr, FALSE)); - ppro->setDword("PopupsSpamTextColor",SendDlgItemMessage(hwndDlg,IDC_POPUP_SPAM_TEXTCOLOR,CPM_GETCOLOUR,0,0)); - ppro->setDword("PopupsSpamBackColor",SendDlgItemMessage(hwndDlg,IDC_POPUP_SPAM_BACKCOLOR,CPM_GETCOLOUR,0,0)); - ppro->setDword("PopupsSpamTimeout",GetDlgItemInt(hwndDlg, IDC_POPUP_SPAM_TIMEOUT, nullptr, FALSE)); - ppro->setByte("PopupsWinColors",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_USEWINCOLORS)); - ppro->setByte("PopupsDefColors",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_USEDEFCOLORS)); - ppro->setByte("PopupsSysIcons",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_USESYSICONS)); + ppro->setByte("PopupsEnabled", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_POPUPS_ENABLED)); + ppro->setByte("PopupsLogEnabled", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_POPUPS_LOG_ENABLED)); + ppro->setByte("PopupsSpamEnabled", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_POPUPS_SPAM_ENABLED)); + ppro->setDword("Popups0TextColor", SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG0_TEXTCOLOR, CPM_GETCOLOUR, 0, 0)); + ppro->setDword("Popups0BackColor", SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG0_BACKCOLOR, CPM_GETCOLOUR, 0, 0)); + ppro->setDword("Popups0Timeout", GetDlgItemInt(hwndDlg, IDC_POPUP_LOG0_TIMEOUT, nullptr, FALSE)); + ppro->setDword("Popups1TextColor", SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG1_TEXTCOLOR, CPM_GETCOLOUR, 0, 0)); + ppro->setDword("Popups1BackColor", SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG1_BACKCOLOR, CPM_GETCOLOUR, 0, 0)); + ppro->setDword("Popups1Timeout", GetDlgItemInt(hwndDlg, IDC_POPUP_LOG1_TIMEOUT, nullptr, FALSE)); + ppro->setDword("Popups2TextColor", SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG2_TEXTCOLOR, CPM_GETCOLOUR, 0, 0)); + ppro->setDword("Popups2BackColor", SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG2_BACKCOLOR, CPM_GETCOLOUR, 0, 0)); + ppro->setDword("Popups2Timeout", GetDlgItemInt(hwndDlg, IDC_POPUP_LOG2_TIMEOUT, nullptr, FALSE)); + ppro->setDword("Popups3TextColor", SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG3_TEXTCOLOR, CPM_GETCOLOUR, 0, 0)); + ppro->setDword("Popups3BackColor", SendDlgItemMessage(hwndDlg, IDC_POPUP_LOG3_BACKCOLOR, CPM_GETCOLOUR, 0, 0)); + ppro->setDword("Popups3Timeout", GetDlgItemInt(hwndDlg, IDC_POPUP_LOG3_TIMEOUT, nullptr, FALSE)); + ppro->setDword("PopupsSpamTextColor", SendDlgItemMessage(hwndDlg, IDC_POPUP_SPAM_TEXTCOLOR, CPM_GETCOLOUR, 0, 0)); + ppro->setDword("PopupsSpamBackColor", SendDlgItemMessage(hwndDlg, IDC_POPUP_SPAM_BACKCOLOR, CPM_GETCOLOUR, 0, 0)); + ppro->setDword("PopupsSpamTimeout", GetDlgItemInt(hwndDlg, IDC_POPUP_SPAM_TIMEOUT, nullptr, FALSE)); + ppro->setByte("PopupsWinColors", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_USEWINCOLORS)); + ppro->setByte("PopupsDefColors", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_USEDEFCOLORS)); + ppro->setByte("PopupsSysIcons", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_USESYSICONS)); return TRUE; } break; @@ -202,56 +194,57 @@ INT_PTR CALLBACK DlgProcIcqPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR int CIcqProto::ShowPopupMsg(MCONTACT hContact, const char *szTitle, const char *szMsg, BYTE bType) { - if (bPopupService && getByte("PopupsEnabled", DEFAULT_POPUPS_ENABLED)) - { + if (bPopupService && getByte("PopupsEnabled", DEFAULT_POPUPS_ENABLED)) { POPUPDATAT ppd = { 0 }; - LPCTSTR rsIcon; + LPWSTR rsIcon; char szPrefix[32], szSetting[32]; mir_strcpy(szPrefix, "Popups"); - switch(bType) { + switch (bType) { case LOG_NOTE: - rsIcon = MAKEINTRESOURCE(IDI_INFORMATION); + rsIcon = IDI_INFORMATION; ppd.colorBack = DEFAULT_LOG0_BACK_COLORS; ppd.colorText = DEFAULT_LOG0_TEXT_COLORS; mir_strcat(szPrefix, "0"); break; case LOG_WARNING: - rsIcon = MAKEINTRESOURCE(IDI_WARNING); + rsIcon = IDI_WARNING; ppd.colorBack = DEFAULT_LOG1_BACK_COLORS; ppd.colorText = DEFAULT_LOG1_TEXT_COLORS; mir_strcat(szPrefix, "1"); break; case LOG_ERROR: - rsIcon = MAKEINTRESOURCE(IDI_ERROR); + rsIcon = IDI_ERROR; ppd.colorBack = DEFAULT_LOG2_BACK_COLORS; ppd.colorText = DEFAULT_LOG2_TEXT_COLORS; mir_strcat(szPrefix, "2"); break; case LOG_FATAL: - rsIcon = MAKEINTRESOURCE(IDI_ERROR); + rsIcon = IDI_ERROR; ppd.colorBack = DEFAULT_LOG3_BACK_COLORS; ppd.colorText = DEFAULT_LOG3_TEXT_COLORS; mir_strcat(szPrefix, "3"); break; case POPTYPE_SPAM: - rsIcon = MAKEINTRESOURCE(IDI_WARNING); + rsIcon = IDI_WARNING; ppd.colorBack = DEFAULT_SPAM_BACK_COLORS; ppd.colorText = DEFAULT_SPAM_TEXT_COLORS; mir_strcat(szPrefix, "Spam"); break; + default: return -1; } + if (!getByte("PopupsSysIcons", DEFAULT_POPUPS_SYS_ICONS)) ppd.lchIcon = IcoLib_GetIconByHandle(m_hProtoIcon); else - ppd.lchIcon = (HICON)LoadImage( nullptr, rsIcon, IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); - + ppd.lchIcon = (HICON)LoadImageW(nullptr, rsIcon, IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); + if (getByte("PopupsWinColors", DEFAULT_POPUPS_WIN_COLORS)) { ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); ppd.colorBack = GetSysColor(COLOR_WINDOW); @@ -275,8 +268,8 @@ int CIcqProto::ShowPopupMsg(MCONTACT hContact, const char *szTitle, const char * ppd.iSeconds = getDword(szSetting, ppd.iSeconds); char str[4096]; - make_unicode_string_static( ICQTranslateUtfStatic(szTitle, str, sizeof(str)), ppd.lpwzContactName, MAX_CONTACTNAME); - make_unicode_string_static( ICQTranslateUtfStatic(szMsg, str, sizeof(str)), ppd.lpwzText, MAX_SECONDLINE); + make_unicode_string_static(ICQTranslateUtfStatic(szTitle, str, sizeof(str)), ppd.lpwzContactName, MAX_CONTACTNAME); + make_unicode_string_static(ICQTranslateUtfStatic(szMsg, str, sizeof(str)), ppd.lpwzText, MAX_SECONDLINE); ppd.lchContact = hContact; ppd.PluginWindowProc = nullptr; ppd.PluginData = nullptr; diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp index 61a9de21b6..fef9525a51 100644 --- a/protocols/IcqOscarJ/src/icq_proto.cpp +++ b/protocols/IcqOscarJ/src/icq_proto.cpp @@ -286,7 +286,7 @@ MCONTACT CIcqProto::AddToList(int flags, PROTOSEARCHRESULT *psr) ICQSEARCHRESULT *isr = (ICQSEARCHRESULT*)psr; if (isr->uin) return AddToListByUIN(isr->uin, flags); - + // aim contact if (isr->hdr.flags & PSR_UNICODE) unicode_to_ansi_static((WCHAR*)isr->hdr.id.w, szUid, MAX_PATH); @@ -1685,7 +1685,7 @@ HANDLE CIcqProto::GetAwayMsg(MCONTACT hContact) WORD wVer = getWord(hContact, "Version", 0) <= 8 ? 8 : ICQ_VERSION; if (CheckContactCapabilities(hContact, CAPF_STATUS_MESSAGES)) return (HANDLE)icq_sendGetAwayMsgServExt(hContact, dwUin, szUID, wMessageType, wVer); - + return (HANDLE)icq_sendGetAwayMsgServ(hContact, dwUin, wMessageType, wVer); } } diff --git a/protocols/IcqOscarJ/src/icq_proto.h b/protocols/IcqOscarJ/src/icq_proto.h index ca775a081b..704e7d402c 100644 --- a/protocols/IcqOscarJ/src/icq_proto.h +++ b/protocols/IcqOscarJ/src/icq_proto.h @@ -334,8 +334,6 @@ struct CIcqProto : public PROTO MCONTACT HContactFromRecordName(const char *szRecordName, int *bAdded); - void processCListReply(const char *szRecordName, WORD wGroupId, WORD wItemId, WORD wItemType, oscar_tlv_chain *pItemData); - void icq_sendServerBeginOperation(int bImport); void icq_sendServerEndOperation(); void sendRosterAck(void); @@ -455,9 +453,7 @@ struct CIcqProto : public PROTO void icq_CancelFileTransfer(filetransfer* ft); //----| icq_filetransfer.cpp |-------------------------------------------------------- - void icq_AcceptFileTransfer(MCONTACT hContact, filetransfer *ft); void icq_sendFileResume(filetransfer *ft, int action, const char *szFilename); - void icq_InitFileSend(filetransfer *ft); void handleFileTransferPacket(directconnect *dc, PBYTE buf, size_t wLen); void handleFileTransferIdle(directconnect *dc); diff --git a/protocols/IcqOscarJ/src/icq_rates.cpp b/protocols/IcqOscarJ/src/icq_rates.cpp index c34acddfc8..16851055e5 100644 --- a/protocols/IcqOscarJ/src/icq_rates.cpp +++ b/protocols/IcqOscarJ/src/icq_rates.cpp @@ -404,10 +404,11 @@ void rates_queue::putItem(rates_queue_item *pItem, int nMinDelay) if (lstPending.getCount() != 1) return; - + // queue was empty setup timer int nDelay; - { mir_cslock rlck(ppro->m_ratesMutex); + { + mir_cslock rlck(ppro->m_ratesMutex); nDelay = ppro->m_rates->getDelayToLimitLevel(pItem->wGroup, waitLevel); } diff --git a/protocols/IcqOscarJ/src/icq_rates.h b/protocols/IcqOscarJ/src/icq_rates.h index 500acfa8fb..addd97725c 100644 --- a/protocols/IcqOscarJ/src/icq_rates.h +++ b/protocols/IcqOscarJ/src/icq_rates.h @@ -39,11 +39,11 @@ struct rates_group DWORD dwAlertLevel; DWORD dwLimitLevel; DWORD dwMaxLevel; - + // current level int rCurrentLevel; int tCurrentLevel; - + // links WORD *pPairs; int nPairs; @@ -52,7 +52,7 @@ struct rates_group struct rates : public MZeroedObject { private: - CIcqProto *ppro; + CIcqProto * ppro; int nGroups; rates_group groups[MAX_RATES_GROUP_COUNT]; @@ -96,7 +96,7 @@ struct rates_queue_item : public MZeroedObject { friend class rates_queue; protected: - CIcqProto *ppro; + CIcqProto * ppro; BOOL bCreated; WORD wGroup; @@ -127,7 +127,7 @@ class rates_queue : public MZeroedObject mir_cs csLists; // we need to be thread safe LIST lstPending; - + protected: void cleanup(); void initDelay(int nDelay); diff --git a/protocols/IcqOscarJ/src/icq_server.cpp b/protocols/IcqOscarJ/src/icq_server.cpp index 942a9e0d73..00ada57843 100644 --- a/protocols/IcqOscarJ/src/icq_server.cpp +++ b/protocols/IcqOscarJ/src/icq_server.cpp @@ -133,7 +133,7 @@ void __cdecl CIcqProto::ServerThread(serverthread_start_info *infoParam) } if (dwError == WSAESHUTDOWN) // ok, we're going offline break; - + debugLogA("Abortive closure of server socket, error: %d", dwError); break; } @@ -181,7 +181,7 @@ void __cdecl CIcqProto::ServerThread(serverthread_start_info *infoParam) for (auto &hContact : AccContacts()) { if (getContactStatus(hContact) == ID_STATUS_OFFLINE) continue; - + setWord(hContact, "Status", ID_STATUS_OFFLINE); DWORD dwUIN; @@ -234,8 +234,7 @@ int CIcqProto::handleServerPackets(BYTE *buf, int len, serverthread_info *info) WORD datalen; int bytesUsed = 0; - while (len > 0) - { + while (len > 0) { if (info->bReinitRecver) break; @@ -336,7 +335,7 @@ void CIcqProto::sendServPacket(icq_packet *pPacket) void __cdecl CIcqProto::SendPacketAsyncThread(icq_packet* pkt) { Thread_SetName("ICQ: SendPacketAsyncThread"); - sendServPacket( pkt ); + sendServPacket(pkt); SAFE_FREE((void**)&pkt); } diff --git a/protocols/IcqOscarJ/src/icq_servlist.cpp b/protocols/IcqOscarJ/src/icq_servlist.cpp index 9e9bb3ad6b..14a64f5bc3 100644 --- a/protocols/IcqOscarJ/src/icq_servlist.cpp +++ b/protocols/IcqOscarJ/src/icq_servlist.cpp @@ -1157,9 +1157,7 @@ DWORD CIcqProto::icq_addServerPrivacyItem(MCONTACT hContact, DWORD dwUin, char * } /***************************************** -* -* --- Contact DB Utilities --- -* +* --- Contact DB Utilities --- */ /// TODO: do not check by plugin version, check by ServListStructures version! @@ -1217,7 +1215,7 @@ void* CIcqProto::collectBuddyGroup(WORD wGroupID, int *count) // Look thru DB and collect all GroupIDs void* CIcqProto::collectGroups(int *count) { - WORD* buf = nullptr; + WORD *buf = nullptr; int cnt = 0; int i; WORD wGroupID; @@ -1228,7 +1226,8 @@ void* CIcqProto::collectGroups(int *count) if (buf[i] == wGroupID) break; - if (i == cnt) { // not preset, add + // not preset, add + if (i == cnt) { cnt++; buf = (WORD*)SAFE_REALLOC(buf, cnt*sizeof(WORD)); buf[i] = wGroupID; @@ -1253,7 +1252,8 @@ static int GroupLinksEnumProc(const char *szSetting, void *lParam) } void CIcqProto::removeGroupPathLinks(WORD wGroupID) -{ // remove miranda grouppath links targeting to this groupid +{ + // remove miranda grouppath links targeting to this groupid char szModule[MAX_PATH]; char* pars[3]; diff --git a/protocols/IcqOscarJ/src/icq_servlist.h b/protocols/IcqOscarJ/src/icq_servlist.h index 64f9a1002d..081b509469 100644 --- a/protocols/IcqOscarJ/src/icq_servlist.h +++ b/protocols/IcqOscarJ/src/icq_servlist.h @@ -48,8 +48,8 @@ struct CIcqProto; // callback prototypes for pending operation mechanism: -typedef int (__cdecl CIcqProto::*PENDING_GROUP_CALLBACK)(const char* pszGroup, WORD wGroupId, LPARAM lParam, int nResult); -typedef int (__cdecl CIcqProto::*PENDING_CONTACT_CALLBACK)(MCONTACT hContact, WORD wContactId, WORD wGroupId, LPARAM lParam, int nResult); +typedef int(__cdecl CIcqProto::*PENDING_GROUP_CALLBACK)(const char* pszGroup, WORD wGroupId, LPARAM lParam, int nResult); +typedef int(__cdecl CIcqProto::*PENDING_CONTACT_CALLBACK)(MCONTACT hContact, WORD wContactId, WORD wGroupId, LPARAM lParam, int nResult); // cookie struct for SSI actions struct cookie_servlist_action @@ -123,45 +123,45 @@ struct cookie_servlist_action // server-list request handler item struct servlistgroupitem { // generic parent - DWORD dwOperation; - cookie_servlist_action* cookie; - icq_packet packet; - // perhaps add some dummy bytes + DWORD dwOperation; + cookie_servlist_action* cookie; + icq_packet packet; + // perhaps add some dummy bytes }; -struct servlistgroupitemdouble: public servlistgroupitem +struct servlistgroupitemdouble : public servlistgroupitem { - icq_packet packet2; - WORD wAction2; + icq_packet packet2; + WORD wAction2; }; struct ssiqueueditems { - time_t tAdded; - int dwTimeout; - int nItems; - servlistgroupitem* pItems[MAX_SERVLIST_PACKET_ITEMS]; + time_t tAdded; + int dwTimeout; + int nItems; + servlistgroupitem* pItems[MAX_SERVLIST_PACKET_ITEMS]; }; // cookie structs for pending records struct servlistpendingoperation { - DWORD flags; - PENDING_GROUP_CALLBACK callback; - LPARAM param; + DWORD flags; + PENDING_GROUP_CALLBACK callback; + LPARAM param; }; struct servlistpendingitem { - int nType; - MCONTACT hContact; - char* szGroup; - WORD wContactID; - WORD wGroupID; - - servlistpendingoperation* operations; - int operationsCount; + int nType; + MCONTACT hContact; + char* szGroup; + WORD wContactID; + WORD wGroupID; + + servlistpendingoperation* operations; + int operationsCount; }; diff --git a/protocols/IcqOscarJ/src/icq_uploadui.cpp b/protocols/IcqOscarJ/src/icq_uploadui.cpp index fcf7058703..8b35afbed6 100644 --- a/protocols/IcqOscarJ/src/icq_uploadui.cpp +++ b/protocols/IcqOscarJ/src/icq_uploadui.cpp @@ -135,7 +135,7 @@ static int GroupEnumIdsEnumProc(const char *szSetting, void *lParam) if (db_get_static(NULL, (char*)lParam, szSetting, val, MAX_PATH)) return 0; // this converts all string types to DBVT_ASCIIZ - pwGroupIds = (WORD*)SAFE_REALLOC(pwGroupIds, (cbGroupIds + 1)*sizeof(WORD)); + pwGroupIds = (WORD*)SAFE_REALLOC(pwGroupIds, (cbGroupIds + 1) * sizeof(WORD)); pwGroupIds[cbGroupIds] = (WORD)strtoul(szSetting, nullptr, 0x10); cbGroupIds++; } @@ -171,7 +171,7 @@ static DWORD sendUploadBuddy(CIcqProto* ppro, MCONTACT hContact, WORD wAction, D cookie_servlist_action *ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action)); if (ack == nullptr) return 0; - + // we have cookie good, go on ack->hContact = hContact; ack->wContactId = wContactId; diff --git a/protocols/IcqOscarJ/src/icq_xtraz.cpp b/protocols/IcqOscarJ/src/icq_xtraz.cpp index 960a0baa9a..5bf67c4095 100644 --- a/protocols/IcqOscarJ/src/icq_xtraz.cpp +++ b/protocols/IcqOscarJ/src/icq_xtraz.cpp @@ -101,7 +101,8 @@ void CIcqProto::handleXtrazNotify(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD w SAFE_FREE(&szXName); SAFE_FREE(&szXMsg); - struct rates_xstatus_response : public rates_queue_item { + struct rates_xstatus_response : public rates_queue_item + { protected: virtual rates_queue_item* copyItem(rates_queue_item *aDest = nullptr) { @@ -191,7 +192,7 @@ void CIcqProto::handleXtrazNotifyResponse(MCONTACT hContact, WORD wCookie, char* ProtoBroadcastAck(hContact, ICQACKTYPE_XTRAZNOTIFY_RESPONSE, ACKRESULT_SUCCESS, (HANDLE)wCookie, (LPARAM)szRes); - NextVal: +NextVal: szNode = strstrnull(szRes, ""); else szEnd = nullptr; @@ -277,7 +278,6 @@ static char* getXmlPidItem(const char* szData) return nullptr; } - void CIcqProto::handleXtrazInvitation(DWORD dwUin, char* szMsg, BOOL bThruDC) { MCONTACT hContact = HContactFromUIN(dwUin, nullptr); @@ -287,13 +287,12 @@ void CIcqProto::handleXtrazInvitation(DWORD dwUin, char* szMsg, BOOL bThruDC) char *szPluginID = getXmlPidItem(szMsg); if (!mir_strcmp(szPluginID, "ICQChatRecv")) // it is a invitation to multi-user chat ; - else + else NetLog_Uni(bThruDC, "Error: Unknown plugin \"%s\" in Xtraz message", szPluginID); SAFE_FREE(&szPluginID); } - void CIcqProto::handleXtrazData(DWORD dwUin, char* szMsg, BOOL bThruDC) { MCONTACT hContact = HContactFromUIN(dwUin, nullptr); @@ -347,7 +346,6 @@ void CIcqProto::handleXtrazData(DWORD dwUin, char* szMsg, BOOL bThruDC) SAFE_FREE(&szPluginID); } - // Functions really sending Xtraz stuff DWORD CIcqProto::SendXtrazNotifyRequest(MCONTACT hContact, char* szQuery, char* szNotify, int bForced) { @@ -379,7 +377,6 @@ DWORD CIcqProto::SendXtrazNotifyRequest(MCONTACT hContact, char* szQuery, char* return dwCookie; } - void CIcqProto::SendXtrazNotifyResponse(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szResponse, size_t nResponseLen, BOOL bThruDC) { char *szResBody = MangleXml(szResponse, nResponseLen); diff --git a/protocols/IcqOscarJ/src/icqosc_svcs.cpp b/protocols/IcqOscarJ/src/icqosc_svcs.cpp index 8ee95b8e95..d84a66fcf4 100644 --- a/protocols/IcqOscarJ/src/icqosc_svcs.cpp +++ b/protocols/IcqOscarJ/src/icqosc_svcs.cpp @@ -98,7 +98,7 @@ INT_PTR CIcqProto::GetInfoSetting(WPARAM hContact, LPARAM lParam) else if (type == DBVT_WCHAR) { if (dbv.type != DBVT_UTF8) { int len = MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, nullptr, 0); - cgs->pValue->pwszVal = (WCHAR*)mir_alloc((len + 1)*sizeof(WCHAR)); + cgs->pValue->pwszVal = (WCHAR*)mir_alloc((len + 1) * sizeof(WCHAR)); if (cgs->pValue->pwszVal == nullptr) rc = 1; else { @@ -446,7 +446,7 @@ INT_PTR CIcqProto::RevokeAuthorization(WPARAM wParam, LPARAM) if (MessageBox(nullptr, TranslateT("Are you sure you want to revoke user's authorization?\nThis will remove you from his/her list on some clients."), TranslateT("Confirmation"), MB_ICONQUESTION | MB_YESNO) != IDYES) return 0; - + icq_sendRevokeAuthServ(dwUin, szUid); } @@ -495,13 +495,13 @@ INT_PTR CIcqProto::SetMyAvatar(WPARAM, LPARAM lParam) HBITMAP avt = Bitmap_Load(tszFile); if (!avt) return -1; - + DeleteObject(avt); } wchar_t tszMyFile[MAX_PATH + 1]; GetFullAvatarFileName(0, nullptr, dwPaFormat, tszMyFile, MAX_PATH); - + // if not in our storage, copy if (mir_wstrcmp(tszFile, tszMyFile) && !CopyFile(tszFile, tszMyFile, FALSE)) { debugLogA("Failed to copy our avatar to local storage."); @@ -529,7 +529,7 @@ INT_PTR CIcqProto::SetMyAvatar(WPARAM, LPARAM lParam) setWString(NULL, "AvatarFile", tmp); SAFE_FREE((void**)&hash); } - else { + else { // delete user avatar delSetting("AvatarFile"); setSettingBlob(NULL, "AvatarHash", hashEmptyAvatar, 9); diff --git a/protocols/IcqOscarJ/src/log.cpp b/protocols/IcqOscarJ/src/log.cpp index c0ff9f5748..6639a7f796 100644 --- a/protocols/IcqOscarJ/src/log.cpp +++ b/protocols/IcqOscarJ/src/log.cpp @@ -128,11 +128,11 @@ void CIcqProto::icq_LogUsingErrorCode(int level, DWORD dwError, const char *szMs } mir_snprintf(szBuf, "%s%s%s (%s %d)", - szMsg ? ICQTranslateUtfStatic(szMsg, str, 1024) : "", - szMsg ? "\r\n\r\n" : "", - ICQTranslateUtfStatic(pszErrorMsg, szErrorMsg, 512), - ICQTranslateUtfStatic(LPGEN("error"), str2, 64), - dwError); + szMsg ? ICQTranslateUtfStatic(szMsg, str, 1024) : "", + szMsg ? "\r\n\r\n" : "", + ICQTranslateUtfStatic(pszErrorMsg, szErrorMsg, 512), + ICQTranslateUtfStatic(LPGEN("error"), str2, 64), + dwError); if (bNeedFree) SAFE_FREE(&pszErrorMsg); diff --git a/protocols/IcqOscarJ/src/loginpassword.cpp b/protocols/IcqOscarJ/src/loginpassword.cpp index 9cff0ea568..6b897cf8de 100644 --- a/protocols/IcqOscarJ/src/loginpassword.cpp +++ b/protocols/IcqOscarJ/src/loginpassword.cpp @@ -27,14 +27,14 @@ INT_PTR CALLBACK LoginPasswdDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - CIcqProto* ppro = (CIcqProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA ); + CIcqProto* ppro = (CIcqProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); ppro = (CIcqProto*)lParam; - SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam ); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); Window_SetIcon_IcoLib(hwndDlg, ppro->m_hProtoIcon); { diff --git a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp index ced8b22347..7065e8837b 100644 --- a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp +++ b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp @@ -29,7 +29,7 @@ #include "stdafx.h" -struct oscarthreadstartinfo +struct oscarthreadstartinfo { int type; int incoming; @@ -61,7 +61,7 @@ char* FindFilePathContainer(const char **files, int iFile, char *szContainer) const char *pszLastBackslash; if (((pszLastBackslash = strrchr(files[i], '\\')) == nullptr) && - ((pszLastBackslash = strrchr(files[i], '/')) == nullptr)) { + ((pszLastBackslash = strrchr(files[i], '/')) == nullptr)) { mir_strcpy(szContainer, files[i]); } else { @@ -364,7 +364,7 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, size_t wLen, DWORD dwUin, char * str = ApplyEncoding((char*)pszDescription, szEnc); } else str = null_strdup(str); - + // eliminate HTML tags pszDescription = EliminateHtml(str, mir_strlen(str)); @@ -872,7 +872,7 @@ DWORD CIcqProto::oftFileDeny(MCONTACT hContact, HANDLE hTransfer, const wchar_t* if (!IsValidOscarTransfer(ft)) return 1; // Invalid transfer - + if (ft->hContact != hContact) return 1; // Bad contact or hTransfer @@ -896,7 +896,7 @@ DWORD CIcqProto::oftFileCancel(MCONTACT hContact, HANDLE hTransfer) if (!IsValidOscarTransfer(ft)) return 1; // Invalid transfer - + if (ft->hContact != hContact) return 1; // Bad contact or hTransfer @@ -984,7 +984,7 @@ void CIcqProto::oftFileResume(oscar_filetransfer *ft, int action, const wchar_t sendOFT2FramePacket(oc, OFT_TYPE_RESUMEREQUEST); return; } - + if (action == FILERESUME_SKIP) // we are skipping the file, send "we are done" oc->status = OCS_NEGOTIATION; @@ -1261,12 +1261,12 @@ void __cdecl CIcqProto::oft_connectionThread(void *param) oc.type = OCT_PROXY_INIT; } } - + if (!oc.hConnection) { // one more sanity check NetLog_Direct("Error: No OFT connection."); return; } - + if (oc.status != OCS_PROXY) { // Connected, notify FT UI ProtoBroadcastAck(oc.ft->hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, oc.ft, 0); @@ -1395,7 +1395,7 @@ int CIcqProto::oft_handlePackets(oscar_connection *oc, BYTE *buf, size_t len) #ifdef _DEBUG NetLog_Direct("OFT2: Type %u, Length %u bytes", datatype, datalen); #endif - handleOFT2FramePacket(oc, datatype, pBuf, datalen-8); + handleOFT2FramePacket(oc, datatype, pBuf, datalen - 8); /* Increase pointers so we can check for more data */ buf += datalen; @@ -1623,7 +1623,7 @@ void CIcqProto::handleOFT2FramePacket(oscar_connection *oc, WORD datatype, BYTE switch (datatype) { case OFT_TYPE_REQUEST: - { // Sender ready + // Sender ready if (ft->flags & OFTF_SENDING) { // just sanity check - this is only for receiving client NetLog_Direct("Error: Invalid Packet, closing."); CloseOscarConnection(oc); @@ -1729,20 +1729,22 @@ void CIcqProto::handleOFT2FramePacket(oscar_connection *oc, WORD datatype, BYTE NetLog_Direct("Invalid path information"); break; } - - char *szFullPath = (char*)SAFE_MALLOC(mir_strlen(ft->szSavePath) + mir_strlen(ft->szThisPath) + mir_strlen(ft->szThisFile) + 3); - mir_strcpy(szFullPath, ft->szSavePath); - NormalizeBackslash(szFullPath); - mir_strcat(szFullPath, ft->szThisPath); - NormalizeBackslash(szFullPath); - // make sure the dest dir exists - if (MakeDirUtf(szFullPath)) - NetLog_Direct("Failed to create destination directory!"); - - mir_strcat(szFullPath, ft->szThisFile); - // we joined the full path to dest file - SAFE_FREE(&ft->szThisFile); - ft->szThisFile = szFullPath; + + { + char *szFullPath = (char*)SAFE_MALLOC(mir_strlen(ft->szSavePath) + mir_strlen(ft->szThisPath) + mir_strlen(ft->szThisFile) + 3); + mir_strcpy(szFullPath, ft->szSavePath); + NormalizeBackslash(szFullPath); + mir_strcat(szFullPath, ft->szThisPath); + NormalizeBackslash(szFullPath); + // make sure the dest dir exists + if (MakeDirUtf(szFullPath)) + NetLog_Direct("Failed to create destination directory!"); + + mir_strcat(szFullPath, ft->szThisFile); + // we joined the full path to dest file + SAFE_FREE(&ft->szThisFile); + ft->szThisFile = szFullPath; + } ft->qwFileBytesDone = 0; @@ -1781,7 +1783,6 @@ void CIcqProto::handleOFT2FramePacket(oscar_connection *oc, WORD datatype, BYTE oft_handleFileData(oc, &buf, 0); } return; - } case OFT_TYPE_READY: case OFT_TYPE_RESUMEACK: @@ -1800,27 +1801,26 @@ void CIcqProto::handleOFT2FramePacket(oscar_connection *oc, WORD datatype, BYTE CloseOscarConnection(oc); return; } - { - DWORD dwResumeCheck, dwResumeOffset, dwFileCheck; - // Read Resume Frame data - pBuffer += 44; - unpackDWord(&pBuffer, &dwResumeOffset); - unpackDWord(&pBuffer, &dwResumeCheck); - - dwFileCheck = oft_calc_file_checksum(ft->fileId, dwResumeOffset); - if (dwFileCheck == dwResumeCheck && dwResumeOffset <= ft->qwThisFileSize) { // resume seems ok - ft->qwFileBytesDone = dwResumeOffset; - ft->qwBytesDone += dwResumeOffset; - _lseek(ft->fileId, dwResumeOffset, SEEK_SET); - - NetLog_Direct("OFT: Resume request, ready."); - } - else - NetLog_Direct("OFT: Resume request, restarting."); - // Ready for resume - sendOFT2FramePacket(oc, OFT_TYPE_RESUMEREADY); + DWORD dwResumeCheck, dwResumeOffset, dwFileCheck; + // Read Resume Frame data + pBuffer += 44; + unpackDWord(&pBuffer, &dwResumeOffset); + unpackDWord(&pBuffer, &dwResumeCheck); + + dwFileCheck = oft_calc_file_checksum(ft->fileId, dwResumeOffset); + if (dwFileCheck == dwResumeCheck && dwResumeOffset <= ft->qwThisFileSize) { // resume seems ok + ft->qwFileBytesDone = dwResumeOffset; + ft->qwBytesDone += dwResumeOffset; + _lseek(ft->fileId, dwResumeOffset, SEEK_SET); + + NetLog_Direct("OFT: Resume request, ready."); } + else + NetLog_Direct("OFT: Resume request, restarting."); + + // Ready for resume + sendOFT2FramePacket(oc, OFT_TYPE_RESUMEREADY); break; case OFT_TYPE_RESUMEREADY: @@ -1830,39 +1830,37 @@ void CIcqProto::handleOFT2FramePacket(oscar_connection *oc, WORD datatype, BYTE CloseOscarConnection(oc); return; } - { - DWORD dwResumeOffset, dwResumeCheck; - // Read Resume Reply data - pBuffer += 44; - unpackDWord(&pBuffer, &dwResumeOffset); - unpackDWord(&pBuffer, &dwResumeCheck); - - if (ft->qwFileBytesDone != dwResumeOffset) { - ft->qwBytesDone -= (ft->qwFileBytesDone - dwResumeOffset); - ft->qwFileBytesDone = dwResumeOffset; - if (dwResumeOffset) - ft->dwRecvFileCheck = dwResumeCheck; - else // Restarted resume (data mismatch) - ft->dwRecvFileCheck = 0xFFFF0000; - } - _lseek(ft->fileId, dwResumeOffset, SEEK_SET); - if (ft->qwThisFileSize != ft->qwFileBytesDone) - NetLog_Direct("OFT: Resuming from offset %u.", dwResumeOffset); + // Read Resume Reply data + pBuffer += 44; + unpackDWord(&pBuffer, &dwResumeOffset); + unpackDWord(&pBuffer, &dwResumeCheck); + + if (ft->qwFileBytesDone != dwResumeOffset) { + ft->qwBytesDone -= (ft->qwFileBytesDone - dwResumeOffset); + ft->qwFileBytesDone = dwResumeOffset; + if (dwResumeOffset) + ft->dwRecvFileCheck = dwResumeCheck; + else // Restarted resume (data mismatch) + ft->dwRecvFileCheck = 0xFFFF0000; + } + _lseek(ft->fileId, dwResumeOffset, SEEK_SET); - // Prepare to receive data - oc->status = OCS_DATA; + if (ft->qwThisFileSize != ft->qwFileBytesDone) + NetLog_Direct("OFT: Resuming from offset %u.", dwResumeOffset); - ProtoBroadcastAck(ft->hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, ft, 0); + // Prepare to receive data + oc->status = OCS_DATA; - // Ready for receive - sendOFT2FramePacket(oc, OFT_TYPE_RESUMEACK); + ProtoBroadcastAck(ft->hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, ft, 0); - if (ft->qwThisFileSize == ft->qwFileBytesDone) { // all data already processed - BYTE buf; + // Ready for receive + sendOFT2FramePacket(oc, OFT_TYPE_RESUMEACK); - oft_handleFileData(oc, &buf, 0); - } + if (ft->qwThisFileSize == ft->qwFileBytesDone) { // all data already processed + BYTE buf; + + oft_handleFileData(oc, &buf, 0); } break; @@ -2017,7 +2015,7 @@ void CIcqProto::oft_sendPeerInit(oscar_connection *oc) mir_strcpy(pszThisFileName, szThisContainer); NormalizeBackslash(pszThisFileName); mir_strcat(pszThisFileName, ExtractFileName(ft->szThisFile)); - + // convert backslashes to dir markings for (size_t i = 0; i < mir_strlen(pszThisFileName); i++) if (pszThisFileName[i] == '\\' || pszThisFileName[i] == '/') diff --git a/protocols/IcqOscarJ/src/oscar_filetransfer.h b/protocols/IcqOscarJ/src/oscar_filetransfer.h index b0ea5b1797..ad31c670a6 100644 --- a/protocols/IcqOscarJ/src/oscar_filetransfer.h +++ b/protocols/IcqOscarJ/src/oscar_filetransfer.h @@ -62,7 +62,7 @@ char *FindFilePathContainer(const char **files, int iFile, char *szContainer); #define OFTF_FILE_RECEIVING 0x0020 // receiving file contents #define OFTF_FILE_DONE 0x0040 // file finished -struct oscar_filetransfer: public basic_filetransfer +struct oscar_filetransfer : public basic_filetransfer { int flags; // combination of OFTF_* int containerCount; @@ -77,13 +77,13 @@ struct oscar_filetransfer: public basic_filetransfer WORD wRemotePort; char *szSavePath; char *szDescription; - char *szThisFile; + char *szThisFile; char *szThisPath; // Request sequence WORD wReqNum; // OFT2 header data WORD wEncrypt, wCompress; - WORD wFilesCount,wFilesLeft; + WORD wFilesCount, wFilesLeft; WORD wPartsCount, wPartsLeft; DWORD64 qwTotalSize; DWORD64 qwThisFileSize; @@ -118,7 +118,7 @@ struct oscar_filetransfer: public basic_filetransfer #define OFT_TYPE_RESUMEREADY 0x0106 // Ok, I am ready to send it #define OFT_TYPE_RESUMEACK 0x0207 // Fine, ready to receive -struct oscar_connection +struct oscar_connection { MCONTACT hContact; HNETLIBCONN hConnection; diff --git a/protocols/IcqOscarJ/src/stdpackets.cpp b/protocols/IcqOscarJ/src/stdpackets.cpp index 57f3d9fc88..0888bd524d 100644 --- a/protocols/IcqOscarJ/src/stdpackets.cpp +++ b/protocols/IcqOscarJ/src/stdpackets.cpp @@ -277,7 +277,7 @@ void CIcqProto::icq_setstatus(WORD wStatus, const char *szStatusNote) packWord(&packet, 0); // Encoding not specified (utf-8 is default) } else packWord(&packet, 0); // Flags + Item Length - + packWord(&packet, 0x0E); // Item Type packWord(&packet, WORD(wStatusMoodLen)); // Flags + Item Length if (wStatusMoodLen) @@ -1270,7 +1270,7 @@ DWORD CIcqProto::icq_sendAdvancedSearchServ(BYTE* fieldsBuffer, size_t bufferLen cookie_search *pCookie = (cookie_search*)SAFE_MALLOC(sizeof(cookie_search)); if (pCookie == nullptr) return 0; - + pCookie->bSearchType = SEARCHTYPE_DETAILS; DWORD dwCookie = AllocateCookie(CKT_SEARCH, 0, 0, pCookie); @@ -1293,7 +1293,7 @@ DWORD CIcqProto::icq_searchAimByEmail(const char* pszEmail, DWORD dwSearchId) if (!pCookie) return 0; - + pCookie->dwMainId = dwSearchId; pCookie->szObject = null_strdup(pszEmail); DWORD dwCookie = AllocateCookie(CKT_SEARCH, ICQ_LOOKUP_REQUEST, 0, pCookie); @@ -1396,7 +1396,7 @@ DWORD CIcqProto::icq_sendSMSServ(const char *szPhoneNumber, const char *szMsg) packDWord(&packet, 0); packWord(&packet, 0); packWord(&packet, WORD(wBufferLen + 1)); - packBuffer(&packet, (LPBYTE)szBuffer, wBufferLen+1); + packBuffer(&packet, (LPBYTE)szBuffer, wBufferLen + 1); sendServPacket(&packet); } @@ -1721,7 +1721,7 @@ void CIcqProto::oft_sendFileRequest(DWORD dwUin, char *szUid, oscar_filetransfer packTLVWord(&packet, 0x05, pListener->wPort); packTLVWord(&packet, 0x15, WORD((pListener->wPort) ^ 0x0FFFF)); } - + // TLV(0x2711) packWord(&packet, 0x2711); packWord(&packet, WORD(9 + mir_strlen(pszFiles))); @@ -1731,7 +1731,7 @@ void CIcqProto::oft_sendFileRequest(DWORD dwUin, char *szUid, oscar_filetransfer packBuffer(&packet, (LPBYTE)pszFiles, mir_strlen(pszFiles) + 1); packTLV(&packet, 0x2712, 5, (LPBYTE)"utf-8"); - + // TLV(0x2713) packWord(&packet, 0x2713); packWord(&packet, 8); diff --git a/protocols/IcqOscarJ/src/stdpackets.h b/protocols/IcqOscarJ/src/stdpackets.h index 95e95fd83a..cb5b8a683c 100644 --- a/protocols/IcqOscarJ/src/stdpackets.h +++ b/protocols/IcqOscarJ/src/stdpackets.h @@ -32,9 +32,9 @@ struct icq_contactsend_s { - DWORD uin; - char *uid; - char *szNick; + DWORD uin; + char *uid; + char *szNick; }; diff --git a/protocols/IcqOscarJ/src/tlv.h b/protocols/IcqOscarJ/src/tlv.h index 4969da9c3c..fb1d594cae 100644 --- a/protocols/IcqOscarJ/src/tlv.h +++ b/protocols/IcqOscarJ/src/tlv.h @@ -30,39 +30,38 @@ struct oscar_tlv { - WORD wType; - WORD wLen; - BYTE *pData; + WORD wType; + WORD wLen; + BYTE *pData; }; - struct oscar_tlv_chain { - oscar_tlv tlv; - oscar_tlv_chain *next; - - WORD getChainLength(); - - oscar_tlv* getTLV(WORD wType, WORD wIndex); - oscar_tlv* putTLV(WORD wType, size_t wLen, BYTE *pData, BOOL bReplace); - oscar_tlv_chain* removeTLV(oscar_tlv *tlv); - WORD getLength(WORD wType, WORD wIndex); - - DWORD getDWord(WORD wType, WORD wIndex); - WORD getWord(WORD wType, WORD wIndex); - BYTE getByte(WORD wType, WORD wIndex); - int getNumber(WORD wType, WORD wIndex); - double getDouble(WORD wType, WORD wIndex); - char* getString(WORD wType, WORD wIndex); + oscar_tlv tlv; + oscar_tlv_chain *next; + + WORD getChainLength(); + + oscar_tlv* getTLV(WORD wType, WORD wIndex); + oscar_tlv* putTLV(WORD wType, size_t wLen, BYTE *pData, BOOL bReplace); + oscar_tlv_chain* removeTLV(oscar_tlv *tlv); + WORD getLength(WORD wType, WORD wIndex); + + DWORD getDWord(WORD wType, WORD wIndex); + WORD getWord(WORD wType, WORD wIndex); + BYTE getByte(WORD wType, WORD wIndex); + int getNumber(WORD wType, WORD wIndex); + double getDouble(WORD wType, WORD wIndex); + char* getString(WORD wType, WORD wIndex); }; struct oscar_tlv_record_list { - oscar_tlv_chain *item; - oscar_tlv_record_list *next; + oscar_tlv_chain *item; + oscar_tlv_record_list *next; - oscar_tlv_chain* getRecordByTLV(WORD wType, int nValue); + oscar_tlv_chain* getRecordByTLV(WORD wType, int nValue); }; /*---------* Functions *---------------*/ diff --git a/protocols/IcqOscarJ/src/upload.cpp b/protocols/IcqOscarJ/src/upload.cpp index 9b5e26e2cf..f6741d1e7c 100644 --- a/protocols/IcqOscarJ/src/upload.cpp +++ b/protocols/IcqOscarJ/src/upload.cpp @@ -27,12 +27,12 @@ #include "stdafx.h" -int CIcqProto::StringToListItemId(const char *szSetting,int def) +int CIcqProto::StringToListItemId(const char *szSetting, int def) { int i; - for(i=0;im_szPassword, tmp); - + hUpload[1] = (HANDLE)ppro->icq_changeUserPasswordServ(tmp); // password is stored in DB, update diff --git a/protocols/IcqOscarJ/src/userinfotab.cpp b/protocols/IcqOscarJ/src/userinfotab.cpp index c6740c3dd0..61622da7a0 100644 --- a/protocols/IcqOscarJ/src/userinfotab.cpp +++ b/protocols/IcqOscarJ/src/userinfotab.cpp @@ -201,7 +201,7 @@ static INT_PTR CALLBACK IcqDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM break; case PSN_INFOCHANGED: - CIcqProto* ppro = (CIcqProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + CIcqProto * ppro = (CIcqProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); if (!ppro) break; diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp index 9e6c898bd1..d94cb53319 100644 --- a/protocols/IcqOscarJ/src/utilities.cpp +++ b/protocols/IcqOscarJ/src/utilities.cpp @@ -774,10 +774,10 @@ char* ApplyEncoding(const char *string, const char *pszEncoding) if (!_strnicmp(pszEncoding, "unicode-2-0", 11)) { // it is UCS-2 encoded size_t wLen = mir_wstrlen((WCHAR*)string) + 1; - WCHAR *szStr = (WCHAR*)_alloca(wLen*2); + WCHAR *szStr = (WCHAR*)_alloca(wLen * 2); BYTE *tmp = (BYTE*)string; - unpackWideString(&tmp, szStr, wLen*2); + unpackWideString(&tmp, szStr, wLen * 2); return make_utf8_string(szStr); } @@ -1237,7 +1237,7 @@ char* time2text(time_t time) str[24] = '\0'; // remove new line return str; } - + return ""; } @@ -1273,9 +1273,9 @@ bool CIcqProto::validateStatusMessageRequest(MCONTACT hContact, WORD byMessageTy if ((byMessageType == MTYPE_AUTOONLINE && m_iStatus != ID_STATUS_ONLINE) || (byMessageType == MTYPE_AUTOAWAY && m_iStatus != ID_STATUS_AWAY) || (byMessageType == MTYPE_AUTOBUSY && m_iStatus != ID_STATUS_OCCUPIED) || - (byMessageType == MTYPE_AUTONA && m_iStatus != ID_STATUS_NA) || - (byMessageType == MTYPE_AUTODND && m_iStatus != ID_STATUS_DND) || - (byMessageType == MTYPE_AUTOFFC && m_iStatus != ID_STATUS_FREECHAT)) { + (byMessageType == MTYPE_AUTONA && m_iStatus != ID_STATUS_NA) || + (byMessageType == MTYPE_AUTODND && m_iStatus != ID_STATUS_DND) || + (byMessageType == MTYPE_AUTOFFC && m_iStatus != ID_STATUS_FREECHAT)) { return false; } @@ -1324,8 +1324,7 @@ DWORD ICQWaitForSingleObject(HANDLE hObject, DWORD dwMilliseconds, int bWaitAlwa do { // will get WAIT_IO_COMPLETION for QueueUserAPC(), ignore it unless terminating dwResult = WaitForSingleObjectEx(hObject, dwMilliseconds, TRUE); - } - while (dwResult == WAIT_IO_COMPLETION && (bWaitAlways || !Miranda_IsTerminated())); + } while (dwResult == WAIT_IO_COMPLETION && (bWaitAlways || !Miranda_IsTerminated())); return dwResult; } @@ -1347,7 +1346,7 @@ HNETLIBBIND CIcqProto::NetLib_BindPort(NETLIBNEWCONNECTIONPROC_V2 pFunc, void* l nlb.pfnNewConnectionV2 = pFunc; nlb.pExtra = lParam; SetLastError(ERROR_INVALID_PARAMETER); // this must be here - NetLib does not set any error :(( - + HNETLIBBIND hBoundPort = Netlib_BindPort(m_hDirectNetlibUser, &nlb); if (pwPort) *pwPort = nlb.wPort; @@ -1591,7 +1590,7 @@ int OpenFileUtf(const char *filename, int oflag, int pmode) WCHAR *GetWindowTextUcs(HWND hWnd) { int nLen = GetWindowTextLengthW(hWnd); - WCHAR *utext = (WCHAR*)SAFE_MALLOC((nLen + 2)*sizeof(WCHAR)); + WCHAR *utext = (WCHAR*)SAFE_MALLOC((nLen + 2) * sizeof(WCHAR)); GetWindowTextW(hWnd, utext, nLen + 1); return utext; } -- cgit v1.2.3