From a7c24ca48995cf2bf436156302f96b91bf135409 Mon Sep 17 00:00:00 2001 From: Goraf <22941576+Goraf@users.noreply.github.com> Date: Mon, 13 Nov 2017 15:03:31 +0100 Subject: Code modernize ... * replace 0/NULL with nullptr [using clang-tidy] --- protocols/IcqOscarJ/src/capabilities.cpp | 2 +- protocols/IcqOscarJ/src/chan_04close.cpp | 18 ++--- protocols/IcqOscarJ/src/chan_05ping.cpp | 4 +- protocols/IcqOscarJ/src/constants.cpp | 2 +- protocols/IcqOscarJ/src/cookies.cpp | 8 +- protocols/IcqOscarJ/src/db.cpp | 4 +- protocols/IcqOscarJ/src/directpackets.cpp | 6 +- protocols/IcqOscarJ/src/dlgproc.cpp | 16 ++-- protocols/IcqOscarJ/src/editlist.cpp | 18 ++--- protocols/IcqOscarJ/src/editstring.cpp | 30 +++---- protocols/IcqOscarJ/src/fam_01service.cpp | 12 +-- protocols/IcqOscarJ/src/fam_02location.cpp | 14 ++-- protocols/IcqOscarJ/src/fam_03buddy.cpp | 40 +++++----- protocols/IcqOscarJ/src/fam_04message.cpp | 76 +++++++++--------- protocols/IcqOscarJ/src/fam_0alookup.cpp | 4 +- protocols/IcqOscarJ/src/fam_13servclist.cpp | 78 +++++++++--------- protocols/IcqOscarJ/src/fam_15icqserver.cpp | 36 ++++----- protocols/IcqOscarJ/src/i18n.cpp | 48 +++++------ protocols/IcqOscarJ/src/icq_advsearch.cpp | 6 +- protocols/IcqOscarJ/src/icq_avatar.cpp | 78 +++++++++--------- protocols/IcqOscarJ/src/icq_clients.cpp | 12 +-- protocols/IcqOscarJ/src/icq_db.cpp | 8 +- protocols/IcqOscarJ/src/icq_direct.cpp | 26 +++--- protocols/IcqOscarJ/src/icq_directmsg.cpp | 14 ++-- protocols/IcqOscarJ/src/icq_fieldnames.cpp | 28 +++---- protocols/IcqOscarJ/src/icq_filerequests.cpp | 10 +-- protocols/IcqOscarJ/src/icq_filetransfer.cpp | 16 ++-- protocols/IcqOscarJ/src/icq_http.cpp | 6 +- protocols/IcqOscarJ/src/icq_infoupdate.cpp | 16 ++-- protocols/IcqOscarJ/src/icq_menu.cpp | 12 +-- protocols/IcqOscarJ/src/icq_opts.cpp | 16 ++-- protocols/IcqOscarJ/src/icq_packet.cpp | 8 +- protocols/IcqOscarJ/src/icq_popups.cpp | 16 ++-- protocols/IcqOscarJ/src/icq_proto.cpp | 90 ++++++++++----------- protocols/IcqOscarJ/src/icq_rates.cpp | 8 +- protocols/IcqOscarJ/src/icq_server.cpp | 20 ++--- protocols/IcqOscarJ/src/icq_servlist.cpp | 106 ++++++++++++------------- protocols/IcqOscarJ/src/icq_uploadui.cpp | 44 +++++----- protocols/IcqOscarJ/src/icq_xstatus.cpp | 34 ++++---- protocols/IcqOscarJ/src/icq_xtraz.cpp | 24 +++--- protocols/IcqOscarJ/src/icqosc_svcs.cpp | 38 ++++----- protocols/IcqOscarJ/src/init.cpp | 2 +- protocols/IcqOscarJ/src/log.cpp | 6 +- protocols/IcqOscarJ/src/loginpassword.cpp | 2 +- protocols/IcqOscarJ/src/oscar_filetransfer.cpp | 42 +++++----- protocols/IcqOscarJ/src/stdpackets.cpp | 70 ++++++++-------- protocols/IcqOscarJ/src/tlv.cpp | 26 +++--- protocols/IcqOscarJ/src/upload.cpp | 2 +- protocols/IcqOscarJ/src/userinfotab.cpp | 10 +-- protocols/IcqOscarJ/src/utilities.cpp | 64 +++++++-------- 50 files changed, 638 insertions(+), 638 deletions(-) (limited to 'protocols/IcqOscarJ') diff --git a/protocols/IcqOscarJ/src/capabilities.cpp b/protocols/IcqOscarJ/src/capabilities.cpp index 6ea0b843ce..d7a4bf59c0 100644 --- a/protocols/IcqOscarJ/src/capabilities.cpp +++ b/protocols/IcqOscarJ/src/capabilities.cpp @@ -161,7 +161,7 @@ capstr* MatchCapability(BYTE *buf, size_t bufsize, const capstr *cap, size_t cap buf += BINARY_CAP_SIZE; bufsize -= BINARY_CAP_SIZE; } - return 0; + return nullptr; } diff --git a/protocols/IcqOscarJ/src/chan_04close.cpp b/protocols/IcqOscarJ/src/chan_04close.cpp index d02e20817b..7e1f6b2ffa 100644 --- a/protocols/IcqOscarJ/src/chan_04close.cpp +++ b/protocols/IcqOscarJ/src/chan_04close.cpp @@ -27,7 +27,7 @@ void CIcqProto::handleCloseChannel(BYTE *buf, size_t datalen, serverthread_info *info) { - oscar_tlv_chain *chain = NULL; + oscar_tlv_chain *chain = nullptr; // Parse server reply, prepare reconnection if (!info->bLoggedIn && datalen && !info->isNewServerReady) @@ -68,7 +68,7 @@ void CIcqProto::handleCloseChannel(BYTE *buf, size_t datalen, serverthread_info void CIcqProto::handleLoginReply(BYTE *buf, size_t datalen, serverthread_info *info) { - oscar_tlv_chain *chain = NULL; + oscar_tlv_chain *chain = nullptr; icq_sendCloseConnection(); // imitate icq5 behaviour @@ -136,9 +136,9 @@ int CIcqProto::connectNewServer(serverthread_info *info) debugLogA("Closed connection to login server"); - hServerConn = NetLib_OpenConnection(m_hNetlibUser, NULL, &nloc); + hServerConn = NetLib_OpenConnection(m_hNetlibUser, nullptr, &nloc); if (hServerConn && info->newServerSSL) /* Start SSL session if requested */ - if (!Netlib_StartSsl(hServerConn, NULL)) + if (!Netlib_StartSsl(hServerConn, nullptr)) NetLib_CloseConnection(&hServerConn, FALSE); if (hServerConn) { @@ -189,7 +189,7 @@ void CIcqProto::handleSignonError(WORD wError) case 0x05: // Mismatch uin or password case 0x06: // Internal Client error (bad input to authorizer) case 0x07: // Invalid account - ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD); + ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, LOGINERR_WRONGPASSWORD); memset(m_szPassword, 0, sizeof(m_szPassword)); icq_LogFatalParam(LPGEN("Connection failed.\nYour ICQ number or password was rejected (%d)."), wError); break; @@ -201,7 +201,7 @@ void CIcqProto::handleSignonError(WORD wError) case 0x14: // Reservation map error case 0x15: // Reservation link error case 0x1A: // Reservation timeout - ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NOSERVER); + ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, LOGINERR_NOSERVER); icq_LogFatalParam(LPGEN("Connection failed.\nThe server is temporarily unavailable (%d)."), wError); break; @@ -212,12 +212,12 @@ void CIcqProto::handleSignonError(WORD wError) case 0x18: // Reservation rate limit exceeded case 0x1D: // Rate limit exceeded - ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NOSERVER); + ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, LOGINERR_NOSERVER); icq_LogFatalParam(LPGEN("Connection failed.\nYou have connected too quickly,\nplease wait and retry 10 to 20 minutes later (%d)."), wError); break; case 0x1B: // You are using an older version of ICQ. Upgrade required - ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPROTOCOL); + ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, LOGINERR_WRONGPROTOCOL); icq_LogMessage(LOG_FATAL, LPGEN("Connection failed.\nThe server did not accept this client version.")); break; @@ -268,7 +268,7 @@ void CIcqProto::handleRuntimeError(WORD wError) { switch (wError) { case 0x01: - ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_OTHERLOCATION); + ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, LOGINERR_OTHERLOCATION); icq_LogMessage(LOG_FATAL, LPGEN("You have been disconnected from the ICQ network because you logged on from another location using the same ICQ number.")); break; diff --git a/protocols/IcqOscarJ/src/chan_05ping.cpp b/protocols/IcqOscarJ/src/chan_05ping.cpp index d9e7e1da7a..bf807cc7c5 100644 --- a/protocols/IcqOscarJ/src/chan_05ping.cpp +++ b/protocols/IcqOscarJ/src/chan_05ping.cpp @@ -33,7 +33,7 @@ void CIcqProto::handlePingChannel(BYTE*, size_t) void CIcqProto::StartKeepAlive(serverthread_info *info) { if (getByte("KeepAlive", DEFAULT_KEEPALIVE_ENABLED)) - info->tmPing = time(0) + KEEPALIVE_INTERVAL; + info->tmPing = time(nullptr) + KEEPALIVE_INTERVAL; else info->tmPing = -1; } @@ -48,7 +48,7 @@ void CIcqProto::CheckKeepAlive(serverthread_info *info) if (info->tmPing == -1) return; - if (time(0) >= info->tmPing) { + if (time(nullptr) >= info->tmPing) { // Send a keep alive packet to server icq_packet packet = { 0 }; write_flap(&packet, ICQ_PING_CHAN); diff --git a/protocols/IcqOscarJ/src/constants.cpp b/protocols/IcqOscarJ/src/constants.cpp index 54e47f744b..d632303f7a 100644 --- a/protocols/IcqOscarJ/src/constants.cpp +++ b/protocols/IcqOscarJ/src/constants.cpp @@ -40,7 +40,7 @@ static FieldNamesItem months[] = { { 10, LPGEN("October") }, { 11, LPGEN("November") }, { 12, LPGEN("December") }, - { 0, NULL } + { 0, nullptr } }; const int ageRange[] = { 13, 0x7FFF }; // 14, 130 diff --git a/protocols/IcqOscarJ/src/cookies.cpp b/protocols/IcqOscarJ/src/cookies.cpp index 03f6be0954..df1305de8e 100644 --- a/protocols/IcqOscarJ/src/cookies.cpp +++ b/protocols/IcqOscarJ/src/cookies.cpp @@ -31,7 +31,7 @@ void CIcqProto::RemoveExpiredCookies() { - time_t tNow = time(NULL); + time_t tNow = time(nullptr); for (int i = cookies.getCount() - 1; i >= 0; i--) if ((cookies[i].dwTime + COOKIE_TIMEOUT) < tNow) @@ -52,7 +52,7 @@ DWORD CIcqProto::AllocateCookie(BYTE bType, WORD wIdent, MCONTACT hContact, void p->dwCookie = dwThisSeq; p->hContact = hContact; p->pvExtra = pvExtra; - p->dwTime = time(NULL); + p->dwTime = time(nullptr); cookies.insert(p); return dwThisSeq; @@ -214,10 +214,10 @@ void CIcqProto::InitMessageCookie(cookie_message_data *pCookie) do { // ensure that message ids are unique - dwMsgID1 = time(NULL); + dwMsgID1 = time(nullptr); dwMsgID2 = RandRange(0, 0x0FFFF); } - while (FindMessageCookie(dwMsgID1, dwMsgID2, NULL, NULL, NULL)); + 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 fc96fbea9f..cdf2caccdd 100644 --- a/protocols/IcqOscarJ/src/db.cpp +++ b/protocols/IcqOscarJ/src/db.cpp @@ -52,7 +52,7 @@ void ChangeInfoData::LoadSettingsFromDb(int keepChanged) if (!ppro->getSetting(NULL, si.szDbSetting, &dbv)) { switch (dbv.type) { case DBVT_ASCIIZ: - sid.value = (LPARAM)ppro->getSettingStringUtf(NULL, si.szDbSetting, NULL); + sid.value = (LPARAM)ppro->getSettingStringUtf(NULL, si.szDbSetting, nullptr); break; case DBVT_UTF8: @@ -75,7 +75,7 @@ void ChangeInfoData::LoadSettingsFromDb(int keepChanged) #ifdef _DEBUG default: - MessageBoxA(NULL, "That's not supposed to happen either", "Huh?", MB_OK); + MessageBoxA(nullptr, "That's not supposed to happen either", "Huh?", MB_OK); break; #endif } diff --git a/protocols/IcqOscarJ/src/directpackets.cpp b/protocols/IcqOscarJ/src/directpackets.cpp index 055c38ea39..7ee3bed194 100644 --- a/protocols/IcqOscarJ/src/directpackets.cpp +++ b/protocols/IcqOscarJ/src/directpackets.cpp @@ -135,7 +135,7 @@ void CIcqProto::icq_sendFileDenyDirect(MCONTACT hContact, filetransfer *ft, cons { // v7 packet icq_packet packet; - char *szReasonAnsi = NULL; + char *szReasonAnsi = nullptr; if (!utf8_decode(szReason, &szReasonAnsi)) szReasonAnsi = _strdup(szReason); // Legacy fix size_t cbReasonAnsi = mir_strlen(szReasonAnsi); @@ -162,7 +162,7 @@ void CIcqProto::icq_sendFileDenyDirect(MCONTACT hContact, filetransfer *ft, cons int CIcqProto::icq_sendFileSendDirectv7(filetransfer *ft, const char *pszFiles) { - char *szFilesAnsi = NULL; + char *szFilesAnsi = nullptr; size_t wDescrLen = mir_strlen(ft->szDescription); if (!utf8_decode(pszFiles, &szFilesAnsi)) @@ -189,7 +189,7 @@ int CIcqProto::icq_sendFileSendDirectv7(filetransfer *ft, const char *pszFiles) int CIcqProto::icq_sendFileSendDirectv8(filetransfer *ft, const char *pszFiles) { - char *szFilesAnsi = NULL; + char *szFilesAnsi = nullptr; size_t wDescrLen = mir_strlen(ft->szDescription); if (!utf8_decode(pszFiles, &szFilesAnsi)) diff --git a/protocols/IcqOscarJ/src/dlgproc.cpp b/protocols/IcqOscarJ/src/dlgproc.cpp index fe4ceb8961..68bdab1338 100644 --- a/protocols/IcqOscarJ/src/dlgproc.cpp +++ b/protocols/IcqOscarJ/src/dlgproc.cpp @@ -139,7 +139,7 @@ void ChangeInfoData::PaintItemSetting(HDC hdc, RECT *rc, int i, UINT itemState) rc->right = rcBtn.left; DrawFrameControl(hdc, &rcBtn, DFC_SCROLL, iEditItem == i ? DFCS_SCROLLDOWN | DFCS_PUSHED : DFCS_SCROLLDOWN); } - DrawTextUtf(hdc, text, rc, DT_END_ELLIPSIS | DT_LEFT | DT_NOCLIP | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER, NULL); + DrawTextUtf(hdc, text, rc, DT_END_ELLIPSIS | DT_LEFT | DT_NOCLIP | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER, nullptr); } static int ChangeInfoDlg_Resize(HWND, LPARAM, UTILRESIZECONTROL *urc) @@ -317,7 +317,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM rcItemDescr.right = rcItemValue.left; rcItemDescr.left += 2; - DrawTextUtf(cd->nmcd.hdc, ICQTranslateUtfStatic(setting[cd->nmcd.lItemlParam].szDescription, str, MAX_PATH), &rcItemDescr, DT_END_ELLIPSIS | DT_LEFT | DT_NOCLIP | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER, NULL); + DrawTextUtf(cd->nmcd.hdc, ICQTranslateUtfStatic(setting[cd->nmcd.lItemlParam].szDescription, str, MAX_PATH), &rcItemDescr, DT_END_ELLIPSIS | DT_LEFT | DT_NOCLIP | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER, nullptr); dat->PaintItemSetting(cd->nmcd.hdc, &rcItemValue, cd->nmcd.lItemlParam, cd->nmcd.uItemState); } @@ -431,7 +431,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM EnableDlgItem(hwndDlg, IDC_LIST, TRUE); ShowDlgItem(hwndDlg, IDC_UPLOADING, SW_HIDE); UnhookEvent(dat->hAckHook); - dat->hAckHook = NULL; + dat->hAckHook = nullptr; } } break; @@ -461,9 +461,9 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM if (dat->hUpload[i] && ack->hProcess == dat->hUpload[i]) break; if (i == _countof(dat->hUpload)) break; - dat->hUpload[i] = NULL; + dat->hUpload[i] = nullptr; for (done = 0, i = 0; i < _countof(dat->hUpload); i++) - done += dat->hUpload[i] == NULL; + done += dat->hUpload[i] == nullptr; wchar_t buf[MAX_PATH]; mir_snwprintf(buf, TranslateT("Upload in progress...%d%%"), 100 * done / (_countof(dat->hUpload))); SetDlgItemText(hwndDlg, IDC_UPLOADING, buf); @@ -471,7 +471,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM dat->ClearChangeFlags(); UnhookEvent(dat->hAckHook); - dat->hAckHook = NULL; + dat->hAckHook = nullptr; EnableDlgItem(hwndDlg, IDC_LIST, TRUE); EnableDlgItem(hwndDlg, IDC_UPLOADING, FALSE); SetDlgItemText(hwndDlg, IDC_UPLOADING, TranslateT("Upload complete")); @@ -479,7 +479,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM } else if (ack->result == ACKRESULT_FAILED) { UnhookEvent(dat->hAckHook); - dat->hAckHook = NULL; + dat->hAckHook = nullptr; EnableDlgItem(hwndDlg, IDC_LIST, TRUE); EnableDlgItem(hwndDlg, IDC_UPLOADING, FALSE); SetDlgItemText(hwndDlg, IDC_UPLOADING, TranslateT("Upload FAILED")); @@ -492,7 +492,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case WM_DESTROY: if (dat->hAckHook) { UnhookEvent(dat->hAckHook); - dat->hAckHook = NULL; + dat->hAckHook = nullptr; } DeleteObject((HFONT)SendMessage(dat->hwndList, WM_GETFONT, 0, 0)); diff --git a/protocols/IcqOscarJ/src/editlist.cpp b/protocols/IcqOscarJ/src/editlist.cpp index 847deefdfd..af99fa4531 100644 --- a/protocols/IcqOscarJ/src/editlist.cpp +++ b/protocols/IcqOscarJ/src/editlist.cpp @@ -27,8 +27,8 @@ #include "stdafx.h" -static ChangeInfoData *dataListEdit = NULL; -static HWND hwndListEdit = NULL; +static ChangeInfoData *dataListEdit = nullptr; +static HWND hwndListEdit = nullptr; static LRESULT CALLBACK ListEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -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, NULL, NULL, hInst, NULL); + rc->left, rc->bottom, rc->right - rc->left, 150, nullptr, nullptr, hInst, nullptr); SendMessage(hwndListEdit, WM_SETFONT, (WPARAM)hListFont, 0); int itemHeight = SendMessage(hwndListEdit, LB_GETITEMHEIGHT, 0, 0); @@ -117,7 +117,7 @@ void ChangeInfoData::BeginListEdit(int iItem, RECT *rc, int iSetting, WORD wVKey SendMessage(hwndListEdit, LB_SETITEMDATA, n, j); if ((si.dbType == DBVT_ASCIIZ && (!mir_strcmp((char*)sid.value, list[j].text)) || (si.dbType == DBVT_ASCIIZ && (!mir_strcmp((char*)sid.value, ICQTranslateUtfStatic(list[j].text, str, MAX_PATH)))) - || ((char*)sid.value == NULL && list[j].code == 0)) + || ((char*)sid.value == nullptr && list[j].code == 0)) || (si.dbType != DBVT_ASCIIZ && sid.value == list[j].code)) SendMessage(hwndListEdit, LB_SETCURSEL, n, 0); } @@ -126,7 +126,7 @@ void ChangeInfoData::BeginListEdit(int iItem, RECT *rc, int iSetting, WORD wVKey int listCount = SendMessage(hwndListEdit, LB_GETCOUNT, 0, 0); if (itemHeight * listCount < 150) - SetWindowPos(hwndListEdit, 0, 0, 0, rc->right - rc->left, itemHeight * listCount + GetSystemMetrics(SM_CYBORDER) * 2, SWP_NOZORDER | SWP_NOMOVE); + SetWindowPos(hwndListEdit, nullptr, 0, 0, rc->right - rc->left, itemHeight * listCount + GetSystemMetrics(SM_CYBORDER) * 2, SWP_NOZORDER | SWP_NOMOVE); mir_subclassWindow(hwndListEdit, ListEditSubclassProc); AnimateWindow(hwndListEdit, 200, AW_SLIDE | AW_ACTIVATE | AW_VER_POSITIVE); ShowWindow(hwndListEdit, SW_SHOW); @@ -137,7 +137,7 @@ void ChangeInfoData::BeginListEdit(int iItem, RECT *rc, int iSetting, WORD wVKey void ChangeInfoData::EndListEdit(int save) { - if (hwndListEdit == NULL || iEditItem == -1 || this != dataListEdit) + if (hwndListEdit == nullptr || iEditItem == -1 || this != dataListEdit) return; if (save) { @@ -163,7 +163,7 @@ void ChangeInfoData::EndListEdit(int save) sid.value = (LPARAM)null_strdup(szNewValue); } else { - sid.changed = (char*)sid.value != NULL; + sid.changed = (char*)sid.value != nullptr; SAFE_FREE((void**)&sid.value); } } @@ -184,9 +184,9 @@ void ChangeInfoData::EndListEdit(int save) } ListView_RedrawItems(hwndList, iEditItem, iEditItem); iEditItem = -1; - dataListEdit = NULL; + dataListEdit = nullptr; DestroyWindow(hwndListEdit); - hwndListEdit = NULL; + hwndListEdit = nullptr; } int IsListEditWindow(HWND hwnd) diff --git a/protocols/IcqOscarJ/src/editstring.cpp b/protocols/IcqOscarJ/src/editstring.cpp index 64eb745fba..ee2029956f 100644 --- a/protocols/IcqOscarJ/src/editstring.cpp +++ b/protocols/IcqOscarJ/src/editstring.cpp @@ -27,8 +27,8 @@ #include "stdafx.h" -static ChangeInfoData *dataStringEdit = NULL; -static HWND hwndEdit = NULL, hwndExpandButton = NULL, hwndUpDown = NULL; +static ChangeInfoData *dataStringEdit = nullptr; +static HWND hwndEdit = nullptr, hwndExpandButton = nullptr, hwndUpDown = nullptr; static const char escapes[]={'a','\a', 'b','\b', @@ -188,7 +188,7 @@ static LRESULT CALLBACK ExpandButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wPa SendMessage(hwndEdit, EM_GETSEL, (WPARAM)&selStart, (LPARAM)&selEnd); DestroyWindow(hwndEdit); EscapesToMultiline(text, &selStart, &selEnd); - hwndEdit = CreateWindowExA(WS_EX_TOOLWINDOW, "EDIT", "", WS_POPUP | WS_BORDER | WS_VISIBLE | ES_WANTRETURN | ES_AUTOVSCROLL | WS_VSCROLL | ES_MULTILINE, rcStart.left, rcStart.top, rcStart.right - rcStart.left, rcStart.bottom - rcStart.top, NULL, NULL, hInst, NULL); + hwndEdit = CreateWindowExA(WS_EX_TOOLWINDOW, "EDIT", "", WS_POPUP | WS_BORDER | WS_VISIBLE | ES_WANTRETURN | ES_AUTOVSCROLL | WS_VSCROLL | ES_MULTILINE, rcStart.left, rcStart.top, rcStart.right - rcStart.left, rcStart.bottom - rcStart.top, nullptr, nullptr, hInst, nullptr); SetWindowTextUcs(hwndEdit, text); mir_subclassWindow(hwndEdit, StringEditSubclassProc); SendMessage(hwndEdit, WM_SETFONT, (WPARAM)dataStringEdit->hListFont, 0); @@ -207,13 +207,13 @@ static LRESULT CALLBACK ExpandButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wPa UpdateWindow(hwndEdit); timeNow = GetTickCount(); if (timeNow > startTime + 200) break; - SetWindowPos(hwndEdit, 0, rcEnd.left, rcEnd.top, (rcEnd.right - rcStart.right)*(timeNow - startTime) / 200 + rcStart.right - rcEnd.left, (rcEnd.bottom - rcStart.bottom)*(timeNow - startTime) / 200 + rcStart.bottom - rcEnd.top, SWP_NOZORDER); + SetWindowPos(hwndEdit, nullptr, rcEnd.left, rcEnd.top, (rcEnd.right - rcStart.right)*(timeNow - startTime) / 200 + rcStart.right - rcEnd.left, (rcEnd.bottom - rcStart.bottom)*(timeNow - startTime) / 200 + rcStart.bottom - rcEnd.top, SWP_NOZORDER); } } - SetWindowPos(hwndEdit, 0, rcEnd.left, rcEnd.top, rcEnd.right - rcEnd.left, rcEnd.bottom - rcEnd.top, SWP_NOZORDER); + SetWindowPos(hwndEdit, nullptr, rcEnd.left, rcEnd.top, rcEnd.right - rcEnd.left, rcEnd.bottom - rcEnd.top, SWP_NOZORDER); DestroyWindow(hwnd); - hwndExpandButton = NULL; + hwndExpandButton = nullptr; SAFE_FREE((void**)&text); } @@ -251,13 +251,13 @@ void ChangeInfoData::BeginStringEdit(int iItem, RECT *rc, int i, WORD wVKey) if ((si.displayType & LIM_TYPE) == LI_LONGSTRING) { rc->right -= rc->bottom - rc->top; - hwndExpandButton = CreateWindowA("BUTTON", "", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_ICON, rc->right, rc->top, rc->bottom - rc->top, rc->bottom - rc->top, hwndList, NULL, hInst, NULL); + hwndExpandButton = CreateWindowA("BUTTON", "", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_ICON, rc->right, rc->top, rc->bottom - rc->top, rc->bottom - rc->top, hwndList, nullptr, hInst, nullptr); SendMessage(hwndExpandButton, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(iconList[0].hIcolib)); mir_subclassWindow(hwndExpandButton, ExpandButtonSubclassProc); } dataStringEdit = this; - hwndEdit = CreateWindow(L"EDIT", L"", WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL | ((si.displayType&LIM_TYPE) == LI_NUMBER ? ES_NUMBER : 0) | (si.displayType&LIF_PASSWORD ? ES_PASSWORD : 0), rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, hwndList, NULL, hInst, NULL); + hwndEdit = CreateWindow(L"EDIT", L"", WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL | ((si.displayType&LIM_TYPE) == LI_NUMBER ? ES_NUMBER : 0) | (si.displayType&LIF_PASSWORD ? ES_PASSWORD : 0), rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, hwndList, nullptr, hInst, nullptr); SetWindowTextUtf(hwndEdit, szValue); if (alloced) SAFE_FREE(&szValue); mir_subclassWindow(hwndEdit, StringEditSubclassProc); @@ -265,14 +265,14 @@ void ChangeInfoData::BeginStringEdit(int iItem, RECT *rc, int i, WORD wVKey) if ((si.displayType & LIM_TYPE) == LI_NUMBER) { int *range = (int*)si.pList; RECT rcUpDown; - hwndUpDown = CreateWindow(UPDOWN_CLASS, L"", WS_VISIBLE | WS_CHILD | UDS_AUTOBUDDY | UDS_ALIGNRIGHT | UDS_HOTTRACK | UDS_NOTHOUSANDS | UDS_SETBUDDYINT, 0, 0, 0, 0, hwndList, NULL, hInst, NULL); + hwndUpDown = CreateWindow(UPDOWN_CLASS, L"", WS_VISIBLE | WS_CHILD | UDS_AUTOBUDDY | UDS_ALIGNRIGHT | UDS_HOTTRACK | UDS_NOTHOUSANDS | UDS_SETBUDDYINT, 0, 0, 0, 0, hwndList, nullptr, hInst, nullptr); SendMessage(hwndUpDown, UDM_SETRANGE32, range[0], range[1]); SendMessage(hwndUpDown, UDM_SETPOS32, 0, sid.value); if (!(si.displayType & LIF_ZEROISVALID) && sid.value == 0) SetWindowTextA(hwndEdit, ""); GetClientRect(hwndUpDown, &rcUpDown); rc->right -= rcUpDown.right; - SetWindowPos(hwndEdit, 0, 0, 0, rc->right - rc->left, rc->bottom - rc->top, SWP_NOZORDER | SWP_NOMOVE); + SetWindowPos(hwndEdit, nullptr, 0, 0, rc->right - rc->left, rc->bottom - rc->top, SWP_NOZORDER | SWP_NOMOVE); } SendMessage(hwndEdit, EM_SETSEL, 0, (LPARAM)-1); SetFocus(hwndEdit); @@ -281,7 +281,7 @@ void ChangeInfoData::BeginStringEdit(int iItem, RECT *rc, int i, WORD wVKey) void ChangeInfoData::EndStringEdit(int save) { - if (hwndEdit == NULL || iEditItem == -1 || this != dataStringEdit) + if (hwndEdit == nullptr || iEditItem == -1 || this != dataStringEdit) return; if (save) { @@ -334,13 +334,13 @@ void ChangeInfoData::EndStringEdit(int save) ListView_RedrawItems(hwndList, iEditItem, iEditItem); iEditItem = -1; - dataStringEdit = NULL; + dataStringEdit = nullptr; DestroyWindow(hwndEdit); - hwndEdit = NULL; + hwndEdit = nullptr; if (hwndExpandButton) DestroyWindow(hwndExpandButton); - hwndExpandButton = NULL; + hwndExpandButton = nullptr; if (hwndUpDown) DestroyWindow(hwndUpDown); - hwndUpDown = NULL; + hwndUpDown = nullptr; } int IsStringEditWindow(HWND hwnd) diff --git a/protocols/IcqOscarJ/src/fam_01service.cpp b/protocols/IcqOscarJ/src/fam_01service.cpp index 0ebfd7f522..c654288d64 100644 --- a/protocols/IcqOscarJ/src/fam_01service.cpp +++ b/protocols/IcqOscarJ/src/fam_01service.cpp @@ -272,7 +272,7 @@ void CIcqProto::handleServiceFam(BYTE *pBuffer, size_t wBufferLength, snac_heade if (dwValue) setDword("MemberTS", dwValue); dwValue = chain->getDWord(0x03, 1); - setDword("LogonTS", dwValue ? dwValue : time(NULL)); + setDword("LogonTS", dwValue ? dwValue : time(nullptr)); disposeChain(&chain); @@ -318,7 +318,7 @@ void CIcqProto::handleServiceFam(BYTE *pBuffer, size_t wBufferLength, snac_heade case ICQ_SERVER_REDIRECT_SERVICE: // reply to family request, got new connection point { - oscar_tlv_chain *pChain = NULL; + oscar_tlv_chain *pChain = nullptr; cookie_family_request *pCookieData; if (!(pChain = readIntoTLVChain(&pBuffer, wBufferLength, 0))) { @@ -328,7 +328,7 @@ void CIcqProto::handleServiceFam(BYTE *pBuffer, size_t wBufferLength, snac_heade // pick request data WORD wFamily = pChain->getWord(0x0D, 1); - if ((!FindCookie(pSnacHeader->dwRef, NULL, (void**)&pCookieData)) || (pCookieData->wFamily != wFamily)) { + if ((!FindCookie(pSnacHeader->dwRef, nullptr, (void**)&pCookieData)) || (pCookieData->wFamily != wFamily)) { disposeChain(&pChain); debugLogA("Received unexpected SNAC(1,5), skipping."); break; @@ -363,15 +363,15 @@ void CIcqProto::handleServiceFam(BYTE *pBuffer, size_t wBufferLength, snac_heade nloc.szHost = pServer; nloc.wPort = wPort; - HNETLIBCONN hConnection = NetLib_OpenConnection(m_hNetlibUser, wFamily == ICQ_AVATAR_FAMILY ? "Avatar " : NULL, &nloc); + HNETLIBCONN hConnection = NetLib_OpenConnection(m_hNetlibUser, wFamily == ICQ_AVATAR_FAMILY ? "Avatar " : nullptr, &nloc); - if (hConnection == NULL) + 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, NULL)) { + if (!Netlib_StartSsl(hConnection, nullptr)) { debugLogA("Unable to connect to ICQ new family server, SSL could not be negotiated"); NetLib_CloseConnection(&hConnection, FALSE); } diff --git a/protocols/IcqOscarJ/src/fam_02location.cpp b/protocols/IcqOscarJ/src/fam_02location.cpp index f47d89a49e..088614904d 100644 --- a/protocols/IcqOscarJ/src/fam_02location.cpp +++ b/protocols/IcqOscarJ/src/fam_02location.cpp @@ -77,7 +77,7 @@ static char* AimApplyEncoding(char* pszStr, const char* pszEncoding) if (szEnc) { // decode custom encoding to Utf-8 char *szStr = ApplyEncoding(pszStr, szEnc + 9); // decode utf-8 to ansi - char *szRes = NULL; + char *szRes = nullptr; SAFE_FREE((void**)&pszStr); if (!utf8_decode(szStr, &szRes)) @@ -115,7 +115,7 @@ void CIcqProto::handleLocationUserInfoReply(BYTE* buf, size_t wLen, DWORD dwCook wLen -= 2; // Determine contact - MCONTACT hContact = HContactFromUID(dwUIN, szUID, NULL); + MCONTACT hContact = HContactFromUID(dwUIN, szUID, nullptr); // Ignore away status if the user is not already on our list if (hContact == INVALID_CONTACT_ID) { @@ -144,7 +144,7 @@ void CIcqProto::handleLocationUserInfoReply(BYTE* buf, size_t wLen, DWORD dwCook if (wLen < 4) return; - char *szMsg = NULL; + char *szMsg = nullptr; BYTE *tmp = buf; // Get general chain @@ -158,7 +158,7 @@ void CIcqProto::handleLocationUserInfoReply(BYTE* buf, size_t wLen, DWORD dwCook // Get extra chain if (pChain = readIntoTLVChain(&buf, wLen, 2)) { - char *szEncoding = NULL; + char *szEncoding = nullptr; // Get Profile encoding TLV oscar_tlv *pTLV = pChain->getTLV(0x05, 1); @@ -221,9 +221,9 @@ void CIcqProto::handleLocationUserInfoReply(BYTE* buf, size_t wLen, DWORD dwCook wLen -= (buf - tmp); // Get extra chain - char *szMsg = NULL; + char *szMsg = nullptr; if (pChain = readIntoTLVChain(&buf, wLen, 2)) { - char *szEncoding = NULL; + char *szEncoding = nullptr; // Get Away encoding TLV oscar_tlv *pTLV = pChain->getTLV(0x03, 1); @@ -248,7 +248,7 @@ void CIcqProto::handleLocationUserInfoReply(BYTE* buf, size_t wLen, DWORD dwCook PROTORECVEVENT pre = { 0 }; pre.szMessage = szMsg ? szMsg : (char *)""; - pre.timestamp = time(NULL); + pre.timestamp = time(nullptr); pre.lParam = dwCookie; ProtoChainRecv(hContact, PSR_AWAYMSG, status, (LPARAM)&pre); diff --git a/protocols/IcqOscarJ/src/fam_03buddy.cpp b/protocols/IcqOscarJ/src/fam_03buddy.cpp index 475855c3af..4b79391c19 100644 --- a/protocols/IcqOscarJ/src/fam_03buddy.cpp +++ b/protocols/IcqOscarJ/src/fam_03buddy.cpp @@ -159,7 +159,7 @@ void CIcqProto::handleUserOnline(BYTE *buf, size_t wLen, serverthread_info*) DWORD dwDirectConnCookie = 0; DWORD dwWebPort = 0; DWORD dwFT1 = 0, dwFT2 = 0, dwFT3 = 0; - const char *szClient = NULL; + const char *szClient = nullptr; BYTE bClientId = 0; WORD wVersion = 0; WORD wTLVCount; @@ -186,7 +186,7 @@ void CIcqProto::handleUserOnline(BYTE *buf, size_t wLen, serverthread_info*) wLen -= 2; // Ignore status notification if the user is not already on our list - MCONTACT hContact = HContactFromUID(dwUIN, szUID, NULL); + MCONTACT hContact = HContactFromUID(dwUIN, szUID, nullptr); if (hContact == INVALID_CONTACT_ID) { debugLogA("Ignoring user online (%s)", strUID(dwUIN, szUID)); return; @@ -303,7 +303,7 @@ void CIcqProto::handleUserOnline(BYTE *buf, size_t wLen, serverthread_info*) wOldStatus = getContactStatus(hContact); // Collect all Capability info from TLV chain - BYTE *capBuf = NULL; + BYTE *capBuf = nullptr; WORD capLen = 0; // Get Location Capability Info TLVs @@ -378,7 +378,7 @@ void CIcqProto::handleUserOnline(BYTE *buf, size_t wLen, serverthread_info*) // Update the contact's capabilies if present in packet SetCapabilitiesFromBuffer(hContact, capBuf, capLen, wOldStatus == ID_STATUS_OFFLINE); - char *szCurrentClient = wOldStatus == ID_STATUS_OFFLINE ? NULL : getSettingStringUtf(hContact, "MirVer", NULL); + char *szCurrentClient = wOldStatus == ID_STATUS_OFFLINE ? nullptr : getSettingStringUtf(hContact, "MirVer", nullptr); szClient = detectUserClient(hContact, nIsICQ, wClass, dwOnlineSince, szCurrentClient, wVersion, dwFT1, dwFT2, dwFT3, dwDirectConnCookie, dwWebPort, capBuf, capLen, &bClientId, szStrBuf); // Check if the client changed, if not do not change @@ -393,20 +393,20 @@ void CIcqProto::handleUserOnline(BYTE *buf, size_t wLen, serverthread_info*) // no capability debugLogA("No capability info TLVs"); - szClient = detectUserClient(hContact, nIsICQ, wClass, dwOnlineSince, NULL, wVersion, dwFT1, dwFT2, dwFT3, dwDirectConnCookie, dwWebPort, NULL, capLen, &bClientId, szStrBuf); + szClient = detectUserClient(hContact, nIsICQ, wClass, dwOnlineSince, nullptr, wVersion, dwFT1, dwFT2, dwFT3, dwDirectConnCookie, dwWebPort, nullptr, capLen, &bClientId, szStrBuf); } else // Capabilities not present in update packet, do not touch szClient = (const char*)-1; // we don't want to client be overwritten // handle Xtraz status - char *moodData = NULL; + char *moodData = nullptr; WORD moodSize = 0; - unpackSessionDataItem(pChain, 0x0E, (BYTE**)&moodData, &moodSize, NULL); + unpackSessionDataItem(pChain, 0x0E, (BYTE**)&moodData, &moodSize, nullptr); if (capLen || wOldStatus == ID_STATUS_OFFLINE) handleXStatusCaps(dwUIN, szUID, hContact, capBuf, capLen, moodData, moodSize); else - handleXStatusCaps(dwUIN, szUID, hContact, NULL, 0, moodData, moodSize); + handleXStatusCaps(dwUIN, szUID, hContact, nullptr, 0, moodData, moodSize); // Determine support for extended status messages if (pChain->getWord(0x08, 1) == 0x0A06) @@ -442,7 +442,7 @@ void CIcqProto::handleUserOnline(BYTE *buf, size_t wLen, serverthread_info*) if (pTLV) handleAvatarContactHash(dwUIN, szUID, hContact, pTLV->pData, pTLV->wLen); else - handleAvatarContactHash(dwUIN, szUID, hContact, NULL, 0); + handleAvatarContactHash(dwUIN, szUID, hContact, nullptr, 0); // Process Status Note parseStatusNote(dwUIN, szUID, hContact, pChain); @@ -516,7 +516,7 @@ void CIcqProto::handleUserOnline(BYTE *buf, size_t wLen, serverthread_info*) if (getByte("KillSpambots", DEFAULT_KILLSPAM_ENABLED) && db_get_b(hContact, "CList", "NotOnList", 0)) { // kill spammer icq_DequeueUser(dwUIN); - icq_sendRemoveContact(dwUIN, NULL); + icq_sendRemoveContact(dwUIN, nullptr); AddToSpammerList(dwUIN); if (getByte("PopupsSpamEnabled", DEFAULT_SPAM_POPUPS_ENABLED)) ShowPopupMsg(hContact, LPGEN("Spambot Detected"), LPGEN("Contact deleted & further events blocked."), POPTYPE_SPAM); @@ -533,7 +533,7 @@ void CIcqProto::handleUserOffline(BYTE *buf, size_t wLen) uid_str szUID; do { - oscar_tlv_chain *pChain = NULL; + oscar_tlv_chain *pChain = nullptr; // Unpack the sender's user ID if (!unpackUID(&buf, &wLen, &dwUIN, &szUID)) return; @@ -579,18 +579,18 @@ void CIcqProto::handleUserOffline(BYTE *buf, size_t wLen) } // Determine contact - MCONTACT hContact = HContactFromUID(dwUIN, szUID, NULL); + MCONTACT hContact = HContactFromUID(dwUIN, szUID, nullptr); // Skip contacts that are not already on our list or are already offline if (hContact != INVALID_CONTACT_ID) { WORD wOldStatus = getContactStatus(hContact); // Process Avatar Hash - oscar_tlv *pAvatarTLV = pChain ? pChain->getTLV(0x1D, 1) : NULL; + oscar_tlv *pAvatarTLV = pChain ? pChain->getTLV(0x1D, 1) : nullptr; if (pAvatarTLV) handleAvatarContactHash(dwUIN, szUID, hContact, pAvatarTLV->pData, pAvatarTLV->wLen); else - handleAvatarContactHash(dwUIN, szUID, hContact, NULL, 0); + handleAvatarContactHash(dwUIN, szUID, hContact, nullptr, 0); // Process Status Note (offline status note) parseStatusNote(dwUIN, szUID, hContact, pChain); @@ -624,17 +624,17 @@ void CIcqProto::handleUserOffline(BYTE *buf, size_t wLen) void CIcqProto::parseStatusNote(DWORD dwUin, char *szUid, MCONTACT hContact, oscar_tlv_chain *pChain) { - DWORD dwStatusNoteTS = time(NULL); + DWORD dwStatusNoteTS = time(nullptr); BYTE *pStatusNoteTS, *pStatusNote; WORD wStatusNoteTSLen, wStatusNoteLen; BYTE bStatusNoteFlags; - if (unpackSessionDataItem(pChain, 0x0D, &pStatusNoteTS, &wStatusNoteTSLen, NULL) && wStatusNoteTSLen == sizeof(DWORD)) + if (unpackSessionDataItem(pChain, 0x0D, &pStatusNoteTS, &wStatusNoteTSLen, nullptr) && wStatusNoteTSLen == sizeof(DWORD)) unpackDWord(&pStatusNoteTS, &dwStatusNoteTS); // Get Status Note session item if (unpackSessionDataItem(pChain, 0x02, &pStatusNote, &wStatusNoteLen, &bStatusNoteFlags)) { - char *szStatusNote = NULL; + char *szStatusNote = nullptr; if ((bStatusNoteFlags & 4) == 4 && wStatusNoteLen >= 4) { BYTE *buf = pStatusNote; @@ -652,7 +652,7 @@ void CIcqProto::parseStatusNote(DWORD dwUin, char *szUid, MCONTACT hContact, osc buflen -= wTextLen; WORD wEncodingType = 0; - char *szEncoding = NULL; + char *szEncoding = nullptr; if (buflen >= 2) unpackWord(&buf, &wEncodingType); @@ -693,14 +693,14 @@ void CIcqProto::parseStatusNote(DWORD dwUin, char *szUid, MCONTACT hContact, osc setStatusMsgVar(hContact, szStatusNote, false); wchar_t *tszNote = mir_utf8decodeW(szStatusNote); - ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, NULL, (LPARAM)tszNote); + ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, nullptr, (LPARAM)tszNote); mir_free(tszNote); } } SAFE_FREE(&szStatusNote); } else if (getContactStatus(hContact) == ID_STATUS_OFFLINE) { - setStatusMsgVar(hContact, NULL, false); + setStatusMsgVar(hContact, nullptr, false); delSetting(hContact, DBSETTING_STATUS_NOTE); setDword(hContact, DBSETTING_STATUS_NOTE_TIME, dwStatusNoteTS); } diff --git a/protocols/IcqOscarJ/src/fam_04message.cpp b/protocols/IcqOscarJ/src/fam_04message.cpp index ece665183a..bad7a528c4 100644 --- a/protocols/IcqOscarJ/src/fam_04message.cpp +++ b/protocols/IcqOscarJ/src/fam_04message.cpp @@ -184,7 +184,7 @@ void CIcqProto::handleRecvServMsg(BYTE *buf, size_t wLen, DWORD dwRef) char* CIcqProto::convertMsgToUserSpecificUtf(MCONTACT hContact, const char *szMsg) { WORD wCP = getWord(hContact, "CodePage", m_wAnsiCodepage); - char *usMsg = NULL; + char *usMsg = nullptr; if (wCP != CP_ACP) usMsg = ansi_to_utf8_codepage(szMsg, wCP); @@ -231,7 +231,7 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, size_t wLen, DWORD dwUin, char // but in some cases there can be more 0x0101 TLVs containing message parts in // different encodings (just like the new format of Offline Messages). DWORD dwRecvTime; - char* szMsg = NULL; + char* szMsg = nullptr; bool bUtf8 = false; PROTORECVEVENT pre = { 0 }; @@ -241,7 +241,7 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, size_t wLen, DWORD dwUin, char WORD wMsgPart = 1; while (oscar_tlv *pMessageTLV = pChain->getTLV(0x0101, wMsgPart)) { // Loop thru all message parts if (pMessageTLV->wLen > 4) { - char *szMsgPart = NULL; + char *szMsgPart = nullptr; bool bMsgPartUnicode = false; // The message begins with a encoding specification @@ -318,11 +318,11 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, size_t wLen, DWORD dwUin, char } } - dwRecvTime = (DWORD)time(NULL); + dwRecvTime = (DWORD)time(nullptr); { // Check if the message was received as offline cookie_offline_messages *cookie; - if (!(dwRef & 0x80000000) && FindCookie(dwRef, NULL, (void**)&cookie)) { + if (!(dwRef & 0x80000000) && FindCookie(dwRef, nullptr, (void**)&cookie)) { cookie->nMessages++; WORD wTimeTLVType; @@ -346,7 +346,7 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, size_t wLen, DWORD dwUin, char debugLogA("Message (format 1) received"); // Save tick value - setDword(hContact, "TickTS", time(NULL) - (dwMsgID1 / 1000)); + setDword(hContact, "TickTS", time(nullptr) - (dwMsgID1 / 1000)); } else debugLogA("Message (format %u) - Ignoring empty message", 1); @@ -367,7 +367,7 @@ void CIcqProto::handleRecvServMsgType2(BYTE *buf, size_t wLen, DWORD dwUin, char { WORD wTLVType; size_t wTLVLen; - BYTE *pDataBuf = NULL; + BYTE *pDataBuf = nullptr; if (wLen < 4) { debugLogA("Message (format %u) - Ignoring empty message", 2); @@ -410,7 +410,7 @@ void CIcqProto::handleRecvServMsgType2(BYTE *buf, size_t wLen, DWORD dwUin, char wTLVLen -= 16; if (CompareGUIDs(q1, q2, q3, q4, MCAP_SRV_RELAY_FMT)) { // we surely have at least 4 bytes for TLV chain - MCONTACT hContact = HContactFromUID(dwUin, szUID, NULL); + MCONTACT hContact = HContactFromUID(dwUin, szUID, nullptr); if (wCommand == 1) { debugLogA("Cannot handle abort messages yet... :("); @@ -457,7 +457,7 @@ void CIcqProto::handleRecvServMsgType2(BYTE *buf, size_t wLen, DWORD dwUin, char // Save tick value BYTE bClientID = getByte(hContact, "ClientID", 0); if (bClientID == CLID_GENERIC || bClientID == CLID_ICQ6) - setDword(hContact, "TickTS", time(NULL) - (dwMsgID1 / 1000)); + setDword(hContact, "TickTS", time(nullptr) - (dwMsgID1 / 1000)); else setDword(hContact, "TickTS", 0); } @@ -500,7 +500,7 @@ void CIcqProto::handleRecvServMsgType2(BYTE *buf, size_t wLen, DWORD dwUin, char BYTE *buf2 = tlv->pData; unpackLEDWord(&buf2, &dwUin); - MCONTACT hContact = HContactFromUIN(dwUin, NULL); + MCONTACT hContact = HContactFromUIN(dwUin, nullptr); if (hContact == INVALID_CONTACT_ID) debugLogA("Error: %s from unknown contact %u", "Reverse Connect Request", dwUin); else { @@ -687,7 +687,7 @@ void CIcqProto::parseServRelayData(BYTE *pDataBuf, size_t wLen, MCONTACT hContac pMsgAck.wCookie = wCookie; pMsgAck.msgType = bMsgType; pMsgAck.bFlags = bFlags; - handleMessageTypes(dwUin, szUID, time(NULL), dwMsgID1, dwMsgID2, wCookie, wVersion, bMsgType, bFlags, wAckType, wLen, wMsgLen, (char*)pDataBuf, 0, &pMsgAck); + handleMessageTypes(dwUin, szUID, time(nullptr), dwMsgID1, dwMsgID2, wCookie, wVersion, bMsgType, bFlags, wAckType, wLen, wMsgLen, (char*)pDataBuf, 0, &pMsgAck); break; } } @@ -852,7 +852,7 @@ void CIcqProto::parseServRelayPluginData(BYTE *pDataBuf, size_t wLen, DWORD dwUi if (m_iStatus == ID_STATUS_NA) nMsgType = MTYPE_AUTONA; } - handleMessageTypes(dwUin, szUID, time(NULL), dwMsgID1, dwMsgID2, wCookie, wVersion, nMsgType, bFlags, wAckType, dwLengthToEnd, 0, (char*)pDataBuf, MTF_PLUGIN | MTF_STATUS_EXTENDED, NULL); + handleMessageTypes(dwUin, szUID, time(nullptr), dwMsgID1, dwMsgID2, wCookie, wVersion, nMsgType, bFlags, wAckType, dwLengthToEnd, 0, (char*)pDataBuf, MTF_PLUGIN | MTF_STATUS_EXTENDED, nullptr); } else if (nTypeId) { if (!dwUin) { // AIM cannot send this, just sanity @@ -868,7 +868,7 @@ void CIcqProto::parseServRelayPluginData(BYTE *pDataBuf, size_t wLen, DWORD dwUi pMsgAck.wCookie = wCookie; pMsgAck.msgType = nTypeId; pMsgAck.bFlags = bFlags; - handleMessageTypes(dwUin, szUID, time(NULL), dwMsgID1, dwMsgID2, wCookie, wVersion, nTypeId, bFlags, wAckType, dwLengthToEnd, dwDataLen, (char*)pDataBuf, MTF_PLUGIN, &pMsgAck); + handleMessageTypes(dwUin, szUID, time(nullptr), dwMsgID1, dwMsgID2, wCookie, wVersion, nTypeId, bFlags, wAckType, dwLengthToEnd, dwDataLen, (char*)pDataBuf, MTF_PLUGIN, &pMsgAck); } else debugLogA("Unsupported plugin message type %d", nTypeId); } @@ -877,7 +877,7 @@ void CIcqProto::parseServRelayPluginData(BYTE *pDataBuf, size_t wLen, DWORD dwUi void CIcqProto::handleRecvServMsgContacts(BYTE *buf, size_t wLen, DWORD dwUin, char *szUID, DWORD dwID1, DWORD dwID2, WORD wCommand) { - MCONTACT hContact = HContactFromUID(dwUin, szUID, NULL); + MCONTACT hContact = HContactFromUID(dwUin, szUID, nullptr); if (wCommand == 0) { // received contacts if (wLen < 4) { // just check if at least one tlv is there @@ -1002,7 +1002,7 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, size_t wLen, DWORD dwUin, c if (nLen >= wNickLen) { WORD wNickTLV; size_t wNickTLVLen; - char *pNick = NULL; + char *pNick = nullptr; unpackTypedTLV(pBuffer, wNickLen, 0x01, &wNickTLV, &wNickTLVLen, (LPBYTE*)&pNick); if (wNickTLV == 0x01) { @@ -1035,7 +1035,7 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, size_t wLen, DWORD dwUin, c icq_sendContactsAck(dwUin, szUID, dwID1, dwID2); PROTORECVEVENT pre = { 0 }; - pre.timestamp = (DWORD)time(NULL); + pre.timestamp = (DWORD)time(nullptr); pre.szMessage = (char *)contacts; pre.lParam = nContacts; ProtoChainRecv(hContact, PSR_CONTACTS, 0, (LPARAM)&pre); @@ -1059,7 +1059,7 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, size_t wLen, DWORD dwUin, c else if (wCommand == 2) { // acknowledgement DWORD dwCookie; MCONTACT hCookieContact; - if (FindMessageCookie(dwID1, dwID2, &dwCookie, &hCookieContact, NULL)) { + if (FindMessageCookie(dwID1, dwID2, &dwCookie, &hCookieContact, nullptr)) { if (hCookieContact != hContact) debugLogA("Warning: Ack Contact does not match Cookie Contact(0x%x != 0x%x)", hContact, hCookieContact); @@ -1105,12 +1105,12 @@ void CIcqProto::handleRecvServMsgType4(BYTE *buf, size_t wLen, DWORD dwUin, char debugLogA("User %u probably checks his ignore state.", dwUin); else { cookie_offline_messages *cookie; - DWORD dwRecvTime = (DWORD)time(NULL); + DWORD dwRecvTime = (DWORD)time(nullptr); - if (!(dwRef & 0x80000000) && FindCookie(dwRef, NULL, (void**)&cookie)) { + if (!(dwRef & 0x80000000) && FindCookie(dwRef, nullptr, (void**)&cookie)) { WORD wTimeTLVType; size_t wTimeTLVLen; - BYTE *pTimeTLV = NULL; + BYTE *pTimeTLV = nullptr; cookie->nMessages++; @@ -1132,7 +1132,7 @@ void CIcqProto::handleRecvServMsgType4(BYTE *buf, size_t wLen, DWORD dwUin, char wLen -= wMsgLen; int typeId; - if (unpackPluginTypeId(&pmsg, &wLen, &typeId, NULL, FALSE) && wLen > 8) { + if (unpackPluginTypeId(&pmsg, &wLen, &typeId, nullptr, FALSE) && wLen > 8) { size_t dwLengthToEnd, dwDataLen; // Length of remaining data @@ -1147,14 +1147,14 @@ void CIcqProto::handleRecvServMsgType4(BYTE *buf, size_t wLen, DWORD dwUin, char if (typeId) { uid_str szUid; - handleMessageTypes(dwUin, szUid, dwRecvTime, dwMsgID1, dwMsgID2, 0, 0, typeId, bFlags, 0, dwLengthToEnd, dwDataLen, (char*)pmsg, MTF_PLUGIN, NULL); + handleMessageTypes(dwUin, szUid, dwRecvTime, dwMsgID1, dwMsgID2, 0, 0, typeId, bFlags, 0, dwLengthToEnd, dwDataLen, (char*)pmsg, MTF_PLUGIN, nullptr); } else debugLogA("Unsupported plugin message type %d", typeId); } } else { uid_str szUid; - handleMessageTypes(dwUin, szUid, dwRecvTime, dwMsgID1, dwMsgID2, 0, 0, bMsgType, bFlags, 0, wTLVLen - 8, wMsgLen, (char*)pmsg, 0, NULL); + handleMessageTypes(dwUin, szUid, dwRecvTime, dwMsgID1, dwMsgID2, 0, 0, bMsgType, bFlags, 0, wTLVLen - 8, wMsgLen, (char*)pmsg, 0, nullptr); } } } @@ -1414,7 +1414,7 @@ void CIcqProto::handleStatusMsgReply(const char *szPrefix, MCONTACT hContact, DW // it is probably UTF-8 status reply PROTORECVEVENT pre = { 0 }; pre.szMessage = (char*)szMsg; - pre.timestamp = time(NULL); + pre.timestamp = time(nullptr); pre.lParam = wCookie; ProtoChainRecv(hContact, PSR_AWAYMSG, status, (LPARAM)&pre); } @@ -1424,9 +1424,9 @@ HANDLE CIcqProto::handleMessageAck(DWORD dwUin, char *szUID, WORD wCookie, int t { if (bFlags == 3) { MCONTACT hCookieContact; - cookie_message_data *pCookieData = NULL; + cookie_message_data *pCookieData = nullptr; - MCONTACT hContact = HContactFromUID(dwUin, szUID, NULL); + MCONTACT hContact = HContactFromUID(dwUin, szUID, nullptr); if (!FindCookie(wCookie, &hCookieContact, (void**)&pCookieData)) { debugLogA("%sIgnoring unrequested status message from %u", "handleMessageAck: ", dwUin); @@ -1463,7 +1463,7 @@ void CIcqProto::sendMessageTypesAck(MCONTACT hContact, int bUnicode, message_ack icq_sendAdvancedMsgAck(pArgs->dwUin, pArgs->dwMsgID1, pArgs->dwMsgID2, pArgs->wCookie, (BYTE)pArgs->msgType, pArgs->bFlags); } else if (pArgs->bType == MAT_DIRECT) { // Send acknowledgement - icq_sendDirectMsgAck(pArgs->pDC, pArgs->wCookie, (BYTE)pArgs->msgType, pArgs->bFlags, bUnicode ? (char *)CAP_UTF8MSGS : NULL); + icq_sendDirectMsgAck(pArgs->pDC, pArgs->wCookie, (BYTE)pArgs->msgType, pArgs->bFlags, bUnicode ? (char *)CAP_UTF8MSGS : nullptr); } } } @@ -1719,7 +1719,7 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, } debugLogA("Received SMS Mobile message"); - ProtoBroadcastAck(NULL, ICQACKTYPE_SMS, ACKRESULT_SUCCESS, NULL, (LPARAM)szMsg); + ProtoBroadcastAck(NULL, ICQACKTYPE_SMS, ACKRESULT_SUCCESS, nullptr, (LPARAM)szMsg); break; case MTYPE_STATUSMSGEXT: @@ -1800,7 +1800,7 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, struct rates_status_message_response : public rates_queue_item { protected: - virtual rates_queue_item* copyItem(rates_queue_item *aDest = NULL) + virtual rates_queue_item* copyItem(rates_queue_item *aDest = nullptr) { rates_status_message_response *pDest = (rates_status_message_response*)aDest; if (!pDest) @@ -1879,7 +1879,7 @@ void CIcqProto::handleRecvMsgResponse(BYTE *buf, size_t wLen) BYTE bFlags; WORD wLength; WORD wVersion = 0; - cookie_message_data *pCookieData = NULL; + cookie_message_data *pCookieData = nullptr; DWORD dwMsgID1, dwMsgID2; unpackLEDWord(&buf, &dwMsgID1); // Message ID @@ -1898,7 +1898,7 @@ void CIcqProto::handleRecvMsgResponse(BYTE *buf, size_t wLen) if (!unpackUID(&buf, &wLen, &dwUin, &szUid)) return; - MCONTACT hContact = HContactFromUID(dwUin, szUid, NULL); + MCONTACT hContact = HContactFromUID(dwUin, szUid, nullptr); buf += 2; // 3. unknown wLen -= 2; @@ -2208,7 +2208,7 @@ void CIcqProto::handleRecvServMsgError(BYTE *buf, size_t wLen, DWORD dwSequence) WORD wError; char *pszErrorMessage; MCONTACT hContact; - cookie_message_data *pCookieData = NULL; + cookie_message_data *pCookieData = nullptr; int nMessageType; @@ -2372,9 +2372,9 @@ void CIcqProto::handleServerAck(BYTE *buf, size_t wLen, DWORD dwSequence) // Sender if (!unpackUID(&buf, &wLen, &dwUin, &szUID)) return; - MCONTACT hContact = HContactFromUID(dwUin, szUID, NULL); + MCONTACT hContact = HContactFromUID(dwUin, szUID, nullptr); - if (FindCookie((WORD)dwSequence, NULL, (void**)&pCookieData)) { + if (FindCookie((WORD)dwSequence, nullptr, (void**)&pCookieData)) { // If the user requested a full ack, the // server ack should be ignored here. if (pCookieData && (pCookieData->nAckType == ACKTYPE_SERVER)) { @@ -2475,7 +2475,7 @@ void CIcqProto::handleMissedMsg(BYTE *buf, size_t wLen) { // offline retrieval process in progress, note that we received missed message notification cookie_offline_messages *cookie; - if (FindCookieByType(CKT_OFFLINEMESSAGE, NULL, NULL, (void**)&cookie)) + if (FindCookieByType(CKT_OFFLINEMESSAGE, nullptr, nullptr, (void**)&cookie)) cookie->nMissed++; } @@ -2496,7 +2496,7 @@ void CIcqProto::handleMissedMsg(BYTE *buf, size_t wLen) // Create event to notify user int bAdded; - AddEvent(HContactFromUID(dwUin, szUid, &bAdded), ICQEVENTTYPE_MISSEDMESSAGE, time(NULL), 0, sizeof(wError), (PBYTE)&wError); + AddEvent(HContactFromUID(dwUin, szUid, &bAdded), ICQEVENTTYPE_MISSEDMESSAGE, time(nullptr), 0, sizeof(wError), (PBYTE)&wError); } @@ -2504,7 +2504,7 @@ void CIcqProto::handleOffineMessagesReply(DWORD dwRef) { cookie_offline_messages *cookie; - if (FindCookie(dwRef, NULL, (void**)&cookie)) { + if (FindCookie(dwRef, nullptr, (void**)&cookie)) { debugLogA("End of offline msgs, %u received", cookie->nMessages); if (cookie->nMissed) { // NASTY WORKAROUND!! // The ICQ server has a bug that causes offline messages to be received again and again when some @@ -2556,7 +2556,7 @@ void CIcqProto::handleTypingNotification(BYTE *buf, size_t wLen) if (!unpackUID(&buf, &wLen, &dwUin, &szUid)) return; - MCONTACT hContact = HContactFromUID(dwUin, szUid, NULL); + MCONTACT hContact = HContactFromUID(dwUin, szUid, nullptr); if (hContact == INVALID_CONTACT_ID) return; diff --git a/protocols/IcqOscarJ/src/fam_0alookup.cpp b/protocols/IcqOscarJ/src/fam_0alookup.cpp index f2bd71eb3c..50a66c2ec1 100644 --- a/protocols/IcqOscarJ/src/fam_0alookup.cpp +++ b/protocols/IcqOscarJ/src/fam_0alookup.cpp @@ -42,7 +42,7 @@ void CIcqProto::handleLookupFam(BYTE *pBuffer, size_t wBufferLength, snac_header wError = 0; cookie_search *pCookie; - if (FindCookie(pSnacHeader->dwRef, NULL, (void**)&pCookie)) { + if (FindCookie(pSnacHeader->dwRef, nullptr, (void**)&pCookie)) { if (wError == 0x14) debugLogA("Lookup: No results"); @@ -84,7 +84,7 @@ void CIcqProto::handleLookupEmailReply(BYTE* buf, size_t wLen, DWORD dwCookie) oscar_tlv_chain *pChain; cookie_search *pCookie; - if (!FindCookie(dwCookie, NULL, (void**)&pCookie)) { + if (!FindCookie(dwCookie, nullptr, (void**)&pCookie)) { debugLogA("Error: Received unexpected lookup reply"); return; } diff --git a/protocols/IcqOscarJ/src/fam_13servclist.cpp b/protocols/IcqOscarJ/src/fam_13servclist.cpp index 83e6ca85e4..17137e8783 100644 --- a/protocols/IcqOscarJ/src/fam_13servclist.cpp +++ b/protocols/IcqOscarJ/src/fam_13servclist.cpp @@ -36,7 +36,7 @@ void CIcqProto::handleServCListFam(BYTE *pBuffer, size_t wBufferLength, snac_hea unpackWord(&pBuffer, &wError); cookie_servlist_action *sc; - if (FindCookie(pSnacHeader->dwRef, NULL, (void**)&sc)) { // look for action cookie + if (FindCookie(pSnacHeader->dwRef, nullptr, (void**)&sc)) { // look for action cookie debugLogA("Received expected server list ack, action: %d, result: %d", sc->dwAction, wError); FreeCookie(pSnacHeader->dwRef); // release cookie @@ -85,7 +85,7 @@ void CIcqProto::handleServCListFam(BYTE *pBuffer, size_t wBufferLength, snac_hea BOOL blWork = bIsSyncingCL; bIsSyncingCL = TRUE; // this is not used if cookie takes place - if (FindCookie(pSnacHeader->dwRef, NULL, (void**)&sc)) { // we do it by reliable cookie + if (FindCookie(pSnacHeader->dwRef, nullptr, (void**)&sc)) { // we do it by reliable cookie if (!sc->lParam) { // is this first packet ? ResetSettingsOnListReload(); sc->lParam = 1; @@ -107,7 +107,7 @@ void CIcqProto::handleServCListFam(BYTE *pBuffer, size_t wBufferLength, snac_hea bIsSyncingCL = FALSE; { cookie_servlist_action* sc; - if (FindCookie(pSnacHeader->dwRef, NULL, (void**)&sc)) { // we requested servlist check + if (FindCookie(pSnacHeader->dwRef, nullptr, (void**)&sc)) { // we requested servlist check debugLogA("Server stated roster is ok."); ReleaseCookie(pSnacHeader->dwRef); LoadServerIDs(); @@ -141,7 +141,7 @@ void CIcqProto::handleServCListFam(BYTE *pBuffer, size_t wBufferLength, snac_hea if (unpackServerListItem(&pBuffer, &wBufferLength, szRecordName, &wGroupId, &wItemId, &wItemType, &wTlvLen)) { BYTE *buf = pBuffer; - oscar_tlv_chain *pChain = NULL; + oscar_tlv_chain *pChain = nullptr; nItems++; @@ -208,7 +208,7 @@ void CIcqProto::handleServCListFam(BYTE *pBuffer, size_t wBufferLength, snac_hea unpackWord(&pBuffer, &wError); - if (FindCookie(pSnacHeader->dwRef, NULL, (void**)&sc)) { // look for action cookie + if (FindCookie(pSnacHeader->dwRef, nullptr, (void**)&sc)) { // look for action cookie debugLogA("Received server list error, action: %d, result: %d", sc->dwAction, wError); FreeCookie(pSnacHeader->dwRef); // release cookie @@ -351,9 +351,9 @@ void CIcqProto::handleServerCListAck(cookie_servlist_action* sc, WORD wError) setByte(sc->hContact, "Auth", 1); // we need auth DWORD dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_ADDTOLIST, sc->hContact, sc); - icq_sendServerContact(sc->hContact, dwCookie, ICQ_LISTS_ADDTOLIST, sc->wGroupId, sc->wContactId, SSOP_ITEM_ACTION | SSOF_CONTACT, 500, NULL); + icq_sendServerContact(sc->hContact, dwCookie, ICQ_LISTS_ADDTOLIST, sc->wGroupId, sc->wContactId, SSOP_ITEM_ACTION | SSOF_CONTACT, 500, nullptr); - sc = NULL; // we do not want it to be freed now + sc = nullptr; // we do not want it to be freed now break; } FreeServerID(sc->wContactId, SSIT_ITEM); @@ -363,7 +363,7 @@ void CIcqProto::handleServerCListAck(cookie_servlist_action* sc, WORD wError) servlistPendingRemoveContact(sc->hContact, 0, sc->wGroupId, PENDING_RESULT_FAILED); - servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100); // end server modifications here + servlistPostPacket(nullptr, 0, SSO_END_OPERATION, 100); // end server modifications here } else { void* groupData; @@ -380,7 +380,7 @@ void CIcqProto::handleServerCListAck(cookie_servlist_action* sc, WORD wError) } else { // this should never happen debugLogA("Group update failed."); - servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100); // end server modifications here + servlistPostPacket(nullptr, 0, SSO_END_OPERATION, 100); // end server modifications here } } break; @@ -421,7 +421,7 @@ void CIcqProto::handleServerCListAck(cookie_servlist_action* sc, WORD wError) icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, 0, ack->szGroupName, groupData, groupSize, SSOF_END_OPERATION); } else // end server modifications here - servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100); + servlistPostPacket(nullptr, 0, SSO_END_OPERATION, 100); SAFE_FREE((void**)&groupData); } @@ -461,7 +461,7 @@ void CIcqProto::handleServerCListAck(cookie_servlist_action* sc, WORD wError) servlistPendingRemoveContact(sc->hContact, sc->wContactId, sc->wGroupId, PENDING_RESULT_FAILED); - servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100); // end server modifications here + servlistPostPacket(nullptr, 0, SSO_END_OPERATION, 100); // end server modifications here } break; @@ -481,14 +481,14 @@ void CIcqProto::handleServerCListAck(cookie_servlist_action* sc, WORD wError) servlistPendingRemoveGroup(sc->szGroup, 0, PENDING_RESULT_FAILED); - servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100); // end server modifications here + servlistPostPacket(nullptr, 0, SSO_END_OPERATION, 100); // end server modifications here SAFE_FREE((void**)&sc->szGroup); } else { // group removed, we need to update master group void* groupData; int groupSize; - setServListGroupName(sc->wGroupId, NULL); // clear group from namelist + setServListGroupName(sc->wGroupId, nullptr); // clear group from namelist FreeServerID(sc->wGroupId, SSIT_GROUP); removeGroupPathLinks(sc->wGroupId); @@ -498,13 +498,13 @@ void CIcqProto::handleServerCListAck(cookie_servlist_action* sc, WORD wError) groupData = collectGroups(&groupSize); sc->wGroupId = 0; sc->dwAction = SSA_GROUP_UPDATE; - sc->szGroupName = NULL; + sc->szGroupName = nullptr; DWORD dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_UPDATEGROUP, 0, sc); icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, 0, sc->szGroupName, groupData, groupSize, SSOF_END_OPERATION); // end server modifications here - sc = NULL; // we do not want to be freed here + sc = nullptr; // we do not want to be freed here SAFE_FREE((void**)&groupData); } @@ -526,10 +526,10 @@ void CIcqProto::handleServerCListAck(cookie_servlist_action* sc, WORD wError) setByte(sc->hContact, "Auth", 0); } DWORD dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_ADDTOLIST, sc->hContact, sc); - icq_sendServerContact(sc->hContact, dwCookie, ICQ_LISTS_ADDTOLIST, sc->wNewGroupId, sc->wNewContactId, SSOP_ITEM_ACTION | SSOF_CONTACT, 400, NULL); + icq_sendServerContact(sc->hContact, dwCookie, ICQ_LISTS_ADDTOLIST, sc->wNewGroupId, sc->wNewContactId, SSOP_ITEM_ACTION | SSOF_CONTACT, 400, nullptr); sc->lParam = 2; // do not cycle - sc = NULL; // we do not want to be freed here + sc = nullptr; // we do not want to be freed here break; } FreeServerID(sc->wNewContactId, SSIT_ITEM); @@ -538,11 +538,11 @@ void CIcqProto::handleServerCListAck(cookie_servlist_action* sc, WORD wError) servlistPendingRemoveContact(sc->hContact, 0, (WORD)(sc->lParam ? sc->wGroupId : sc->wNewGroupId), PENDING_RESULT_FAILED); - servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100); // end server modifications here + servlistPostPacket(nullptr, 0, SSO_END_OPERATION, 100); // end server modifications here if (!sc->lParam) { // is this first ack ? sc->lParam = -1; - sc = NULL; // this can't be freed here + sc = nullptr; // this can't be freed here } break; } @@ -582,7 +582,7 @@ void CIcqProto::handleServerCListAck(cookie_servlist_action* sc, WORD wError) delSetting(sc->hContact, DBSETTING_SERVLIST_GROUP); FreeServerID(sc->wContactId, SSIT_ITEM); // release old contact id sc->lParam = 1; - sc = NULL; // wait for second ack + sc = nullptr; // wait for second ack } break; @@ -705,9 +705,9 @@ void CIcqProto::handleServerCListReply(BYTE *buf, size_t wLen, WORD wFlags, serv size_t wTlvLength; BOOL bIsLastPacket; uid_str szRecordName; - oscar_tlv_chain* pChain = NULL; - oscar_tlv* pTLV = NULL; - char *szActiveSrvGroup = NULL; + oscar_tlv_chain* pChain = nullptr; + oscar_tlv* pTLV = nullptr; + char *szActiveSrvGroup = nullptr; WORD wActiveSrvGroupId = -1; // If flag bit 1 is set, this is not the last @@ -761,7 +761,7 @@ void CIcqProto::handleServerCListReply(BYTE *buf, size_t wLen, WORD wFlags, serv pChain = readIntoTLVChain(&buf, wTlvLength, 0); wLen -= wTlvLength; } - else pChain = NULL; + else pChain = nullptr; switch (wTlvType) { case SSI_ITEM_BUDDY: @@ -853,7 +853,7 @@ void CIcqProto::handleServerCListReply(BYTE *buf, size_t wLen, WORD wFlags, serv if (getByte("LoadServerDetails", DEFAULT_SS_LOAD) || bAdded) { // if just added contact, save details always - does no harm char *szOldNick; - if (szOldNick = getSettingStringUtf(hContact, "CList", "MyHandle", NULL)) { + if (szOldNick = getSettingStringUtf(hContact, "CList", "MyHandle", nullptr)) { if ((mir_strcmp(szOldNick, pszNick)) && (mir_strlen(pszNick) > 0)) { // check if the truncated nick changed, i.e. do not overwrite locally stored longer nick if (mir_strlen(szOldNick) <= mir_strlen(pszNick) || strncmp(szOldNick, pszNick, null_strcut(szOldNick, MAX_SSI_TLV_NAME_SIZE))) { // Yes, we really do need to delete it first. Otherwise the CLUI nick @@ -896,7 +896,7 @@ void CIcqProto::handleServerCListReply(BYTE *buf, size_t wLen, WORD wFlags, serv if (getByte("LoadServerDetails", DEFAULT_SS_LOAD) || bAdded) { // if just added contact, save details always - does no harm char *szOldComment; - if (szOldComment = getSettingStringUtf(hContact, "UserInfo", "MyNotes", NULL)) { + if (szOldComment = getSettingStringUtf(hContact, "UserInfo", "MyNotes", nullptr)) { if ((mir_strcmp(szOldComment, pszComment)) && (mir_strlen(pszComment) > 0)) // check if the truncated comment changed, i.e. do not overwrite locally stored longer comment if (mir_strlen(szOldComment) <= mir_strlen(pszComment) || strncmp((char*)szOldComment, (char*)pszComment, null_strcut(szOldComment, MAX_SSI_TLV_COMMENT_SIZE))) db_set_utf(hContact, "UserInfo", "MyNotes", pszComment); @@ -1207,7 +1207,7 @@ void CIcqProto::handleServerCListReply(BYTE *buf, size_t wLen, WORD wFlags, serv ack->dwAction = SSA_GROUP_UPDATE; ack->szGroupName = null_strdup(""); dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_ADDTOLIST, 0, ack); - icq_sendServerGroup(dwCookie, ICQ_LISTS_ADDTOLIST, 0, ack->szGroupName, NULL, 0, 0); + icq_sendServerGroup(dwCookie, ICQ_LISTS_ADDTOLIST, 0, ack->szGroupName, nullptr, 0, 0); } } // serv-list sync finished, clear just added contacts @@ -1234,7 +1234,7 @@ void CIcqProto::handleServerCListItemAdd(WORD wItemId, WORD wItemType, oscar_tlv void CIcqProto::handleServerCListItemUpdate(const char *szRecordName, WORD wItemType, oscar_tlv_chain *pItemData) { - MCONTACT hContact = (wItemType == SSI_ITEM_BUDDY || wItemType == SSI_ITEM_DENY || wItemType == SSI_ITEM_PERMIT || wItemType == SSI_ITEM_IGNORE) ? HContactFromRecordName(szRecordName, NULL) : NULL; + MCONTACT hContact = (wItemType == SSI_ITEM_BUDDY || wItemType == SSI_ITEM_DENY || wItemType == SSI_ITEM_PERMIT || wItemType == SSI_ITEM_IGNORE) ? HContactFromRecordName(szRecordName, nullptr) : NULL; if (hContact != INVALID_CONTACT_ID && wItemType == SSI_ITEM_BUDDY) { // a contact was updated on server if (pItemData) { @@ -1335,7 +1335,7 @@ void CIcqProto::handleServerCListItemUpdate(const char *szRecordName, WORD wItem void CIcqProto::handleServerCListItemDelete(const char *szRecordName, WORD wItemId, WORD wItemType) { - MCONTACT hContact = (wItemType == SSI_ITEM_BUDDY || wItemType == SSI_ITEM_DENY || wItemType == SSI_ITEM_PERMIT || wItemType == SSI_ITEM_IGNORE) ? HContactFromRecordName(szRecordName, NULL) : NULL; + MCONTACT hContact = (wItemType == SSI_ITEM_BUDDY || wItemType == SSI_ITEM_DENY || wItemType == SSI_ITEM_PERMIT || wItemType == SSI_ITEM_IGNORE) ? HContactFromRecordName(szRecordName, nullptr) : NULL; if (hContact != INVALID_CONTACT_ID && wItemType == SSI_ITEM_BUDDY) { // a contact was removed from our list if (getWord(hContact, DBSETTING_SERVLIST_ID, 0) == wItemId) { @@ -1387,18 +1387,18 @@ void CIcqProto::handleRecvAuthRequest(unsigned char *buf, size_t wLen) // Read nick name from DB char *szNick; if (dwUin) - szNick = getSettingStringUtf(hContact, "Nick", NULL); + szNick = getSettingStringUtf(hContact, "Nick", nullptr); else szNick = null_strdup(szUid); - DB_AUTH_BLOB blob(hContact, szNick, 0, 0, 0, szReason); + DB_AUTH_BLOB blob(hContact, szNick, nullptr, nullptr, nullptr, szReason); blob.set_uin(dwUin); setByte(hContact, "Grant", 1); // TODO: Change for new auth system, include all known informations PROTORECVEVENT pre = { 0 }; - pre.timestamp = time(NULL); + pre.timestamp = time(nullptr); pre.lParam = blob.size(); pre.szMessage = blob; ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&pre); @@ -1427,7 +1427,7 @@ void CIcqProto::handleRecvAdded(unsigned char *buf, size_t wLen) size_t nNickLen, cbBlob = sizeof(DWORD) * 2 + 4; - char *szNick = NULL; + char *szNick = nullptr; if (dwUin) { if (getString(hContact, "Nick", &dbv)) nNickLen = 0; @@ -1458,14 +1458,14 @@ void CIcqProto::handleRecvAdded(unsigned char *buf, size_t wLen) *(char*)pCurBlob = 0; // TODO: Change for new auth system - AddEvent(NULL, EVENTTYPE_ADDED, time(NULL), 0, cbBlob, pBlob); + AddEvent(NULL, EVENTTYPE_ADDED, time(nullptr), 0, cbBlob, pBlob); } void CIcqProto::handleRecvAuthResponse(unsigned char *buf, size_t wLen) { DWORD dwUin; uid_str szUid; - char* szNick = NULL; + char* szNick = nullptr; WORD nReasonLen; char* szReason; int bAdded; @@ -1584,8 +1584,8 @@ void CIcqProto::updateServVisibilityCode(BYTE bCode) // not stored in the local DB, a new ID will be added to the server list. void CIcqProto::updateServAvatarHash(BYTE *pHash, int size) { - void** pDoubleObject = NULL; - void* doubleObject = NULL; + void** pDoubleObject = nullptr; + void* doubleObject = nullptr; DWORD dwOperationFlags = 0; WORD wAvatarID; WORD wCommand; @@ -1622,7 +1622,7 @@ void CIcqProto::updateServAvatarHash(BYTE *pHash, int size) ack->dwAction = SSA_REMOVEAVATAR; // update avatar hash ack->wContactId = wAvatarID; DWORD dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_REMOVEFROMLIST, 0, ack); // take cookie - icq_sendServerItem(dwCookie, ICQ_LISTS_REMOVEFROMLIST, 0, wAvatarID, szItemName, NULL, 0, SSI_ITEM_BUDDYICON, SSOP_ITEM_ACTION | dwOperationFlags, 400, pDoubleObject); + icq_sendServerItem(dwCookie, ICQ_LISTS_REMOVEFROMLIST, 0, wAvatarID, szItemName, nullptr, 0, SSI_ITEM_BUDDYICON, SSOP_ITEM_ACTION | dwOperationFlags, 400, pDoubleObject); } } @@ -1660,7 +1660,7 @@ void CIcqProto::updateServAvatarHash(BYTE *pHash, int size) pBuffer.pData = (BYTE *)_alloca(wTLVlen); pBuffer.wLen = wTLVlen; - packTLV(&pBuffer, SSI_TLV_NAME, 0, NULL); // TLV (Name) + packTLV(&pBuffer, SSI_TLV_NAME, 0, nullptr); // TLV (Name) packTLV(&pBuffer, SSI_TLV_AVATARHASH, hashsize, pHash + 2); // TLV (Hash) icq_sendServerItem(dwCookie, wCommand, 0, wAvatarID, szItemName, pBuffer.pData, wTLVlen, SSI_ITEM_BUDDYICON, SSOP_ITEM_ACTION | dwOperationFlags, 400, pDoubleObject); diff --git a/protocols/IcqOscarJ/src/fam_15icqserver.cpp b/protocols/IcqOscarJ/src/fam_15icqserver.cpp index 9e67247561..93629b691f 100644 --- a/protocols/IcqOscarJ/src/fam_15icqserver.cpp +++ b/protocols/IcqOscarJ/src/fam_15icqserver.cpp @@ -78,7 +78,7 @@ void CIcqProto::handleExtensionError(BYTE *buf, size_t wPackLen) // more sofisticated detection, send ack if (wSubType == META_REQUEST_FULL_INFO) { MCONTACT hContact; - cookie_fam15_data *pCookieData = NULL; + cookie_fam15_data *pCookieData = nullptr; int foundCookie = FindCookie(wCookie, &hContact, (void**)&pCookieData); if (foundCookie && pCookieData) { @@ -116,13 +116,13 @@ void CIcqProto::handleExtensionServerInfo(BYTE *buf, size_t wPackLen, WORD wFlag { // The entire packet is encapsulated in a TLV type 1 oscar_tlv_chain *chain = readIntoTLVChain(&buf, wPackLen, 0); - if (chain == NULL) { + if (chain == nullptr) { debugLogA("Error: Broken snac 15/3 %d", 1); return; } oscar_tlv *dataTlv = chain->getTLV(0x0001, 1); - if (dataTlv == NULL) { + if (dataTlv == nullptr) { disposeChain(&chain); debugLogA("Error: Broken snac 15/3 %d", 2); return; @@ -300,9 +300,9 @@ void CIcqProto::parseSearchReplies(unsigned char *databuf, size_t wPacketLen, WO BOOL bLastUser = FALSE; cookie_search *pCookie; - if (!FindCookie(wCookie, NULL, (void**)&pCookie)) { + if (!FindCookie(wCookie, nullptr, (void**)&pCookie)) { debugLogA("Warning: Received unexpected search reply"); - pCookie = NULL; + pCookie = nullptr; } switch (wReplySubtype) { @@ -354,7 +354,7 @@ void CIcqProto::parseSearchReplies(unsigned char *databuf, size_t wPacketLen, WO databuf += wLen; } else { - sr.hdr.nick.w = NULL; + sr.hdr.nick.w = nullptr; } // First name @@ -368,7 +368,7 @@ void CIcqProto::parseSearchReplies(unsigned char *databuf, size_t wPacketLen, WO sr.hdr.firstName.w = (wchar_t*)databuf; databuf += wLen; } - else sr.hdr.firstName.w = NULL; + else sr.hdr.firstName.w = nullptr; // Last name if (wPacketLen < 2) @@ -381,7 +381,7 @@ void CIcqProto::parseSearchReplies(unsigned char *databuf, size_t wPacketLen, WO sr.hdr.lastName.w = (wchar_t*)databuf; databuf += wLen; } - else sr.hdr.lastName.w = NULL; + else sr.hdr.lastName.w = nullptr; // E-mail name if (wPacketLen < 2) @@ -394,7 +394,7 @@ void CIcqProto::parseSearchReplies(unsigned char *databuf, size_t wPacketLen, WO sr.hdr.email.w = (wchar_t*)databuf; databuf += wLen; } - else sr.hdr.email.w = NULL; + else sr.hdr.email.w = nullptr; // Authentication needed flag if (wPacketLen < 1) @@ -704,7 +704,7 @@ void CIcqProto::handleDirectoryQueryResponse(BYTE *databuf, size_t wPacketLen, W if (IsStringUIN(szUid)) dwUin = atoi(szUid); - if (hContact != HContactFromUID(dwUin, szUid, NULL)) { + if (hContact != HContactFromUID(dwUin, szUid, nullptr)) { debugLogA("Error: Received data does not match cookie contact, ignoring."); SAFE_FREE(&szUid); break; @@ -763,7 +763,7 @@ void CIcqProto::parseDirectoryUserDetailsData(MCONTACT hContact, oscar_tlv_chain if (IsStringUIN(szUid)) dwUin = atoi(szUid); - hContact = HContactFromUID(dwUin, szUid, NULL); + hContact = HContactFromUID(dwUin, szUid, nullptr); if (hContact == INVALID_CONTACT_ID) { debugLogA("Error: Received details for unknown contact \"%s\"", szUid); SAFE_FREE(&szUid); @@ -863,7 +863,7 @@ void CIcqProto::parseDirectoryUserDetailsData(MCONTACT hContact, oscar_tlv_chain if (!hContact) { // Owner contact needs special processing, in the database is current status note for the client // We just received the last status note set on directory, if it differs call SetStatusNote() to // ensure the directory will be updated (it should be in process anyway) - char *szClientStatusNote = getSettingStringUtf(hContact, DBSETTING_STATUS_NOTE, NULL); + char *szClientStatusNote = getSettingStringUtf(hContact, DBSETTING_STATUS_NOTE, nullptr); char *szDirectoryStatusNote = cDetails->getString(0x226, 1); if (mir_strcmp(szClientStatusNote, szDirectoryStatusNote)) @@ -910,7 +910,7 @@ void CIcqProto::parseDirectoryUserDetailsData(MCONTACT hContact, oscar_tlv_chain else if (bHasMetaToken || !hContact) writeDbInfoSettingTLVDouble(hContact, DBSETTING_METAINFO_SAVED, cDetails, 0x1CC); else - setDword(hContact, DBSETTING_METAINFO_SAVED, time(NULL)); + setDword(hContact, DBSETTING_METAINFO_SAVED, time(nullptr)); } if (wReplySubType == META_DIRECTORY_RESPONSE) @@ -941,25 +941,25 @@ void CIcqProto::parseDirectorySearchData(oscar_tlv_chain *cDetails, DWORD dwCook isr.uin = 0; oscar_tlv *pTLV = cDetails->getTLV(0x50, 1); - char *szData = NULL; + char *szData = nullptr; if (pTLV && pTLV->wLen > 0) szData = cDetails->getString(0x50, 1); // Verified e-mail else szData = cDetails->getString(0x55, 1); // Pending e-mail - if (szData != NULL) + if (szData != nullptr) isr.hdr.email.a = szData; szData = cDetails->getString(0x64, 1); // First Name - if (szData != NULL) + if (szData != nullptr) isr.hdr.firstName.a = szData; szData = cDetails->getString(0x6E, 1); // Last Name - if (szData != NULL) + if (szData != nullptr) isr.hdr.lastName.a = szData; szData = cDetails->getString(0x78, 1); // Nick - if (szData != NULL) + if (szData != nullptr) isr.hdr.nick.a = szData; switch (cDetails->getNumber(0x82, 1)) { // Gender diff --git a/protocols/IcqOscarJ/src/i18n.cpp b/protocols/IcqOscarJ/src/i18n.cpp index 8f6c7eebca..9efa10fd39 100644 --- a/protocols/IcqOscarJ/src/i18n.cpp +++ b/protocols/IcqOscarJ/src/i18n.cpp @@ -111,7 +111,7 @@ int __stdcall get_utf8_size(const WCHAR *unicode) // returns ansi string in all cases char* __stdcall detect_decode_utf8(const char *from) { - char *temp = NULL; + char *temp = nullptr; if (IsUSASCII(from, mir_strlen(from)) || !UTF8_IsValid(from) || !utf8_decode(from, &temp)) return (char*)from; SAFE_FREE((void**)&from); @@ -184,14 +184,14 @@ char* __stdcall make_utf8_string_static(const WCHAR *unicode, char *utf8, size_t char* __stdcall make_utf8_string(const WCHAR *unicode) { - if (!unicode) return NULL; + if (!unicode) return nullptr; /* first calculate the size of the target string */ size_t size = get_utf8_size(unicode); char *out = (char*)SAFE_MALLOC(size + 1); if (!out) - return NULL; + return nullptr; return make_utf8_string_static(unicode, out, size + 1); } @@ -235,7 +235,7 @@ WCHAR* __stdcall make_unicode_string(const char *utf8) { int size = 0, index = 0; - if (!utf8) return NULL; + if (!utf8) return nullptr; /* first calculate the size of the target string */ unsigned char c = utf8[index++]; @@ -255,7 +255,7 @@ WCHAR* __stdcall make_unicode_string(const char *utf8) WCHAR *out = (WCHAR*)SAFE_MALLOC((size + 1) * sizeof(WCHAR)); if (!out) - return NULL; + return nullptr; else return make_unicode_string_static(utf8, out, size + 1); } @@ -263,7 +263,7 @@ WCHAR* __stdcall make_unicode_string(const char *utf8) int __stdcall utf8_encode(const char *from, char **to) { - int wchars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, from, (int)mir_strlen(from), NULL, 0); + int wchars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, from, (int)mir_strlen(from), nullptr, 0); if (wchars == 0) { #ifdef _DEBUG @@ -293,7 +293,7 @@ int __stdcall utf8_encode(const char *from, char **to) char* __stdcall ansi_to_utf8(const char *ansi) { - char *szUtf = NULL; + char *szUtf = nullptr; if (mir_strlen(ansi)) { utf8_encode(ansi, &szUtf); @@ -337,7 +337,7 @@ int __stdcall utf8_decode_codepage(const char *from, char **to, WORD wCp) if (MultiByteToWideChar(CP_UTF8, 0, from, -1, wszTemp, (int)inlen)) { // Convert the UCS string to local ANSI codepage *to = (char*)SAFE_MALLOC(inlen); - if (WideCharToMultiByte(wCp, 0, wszTemp, -1, *to, (int)inlen, NULL, NULL)) { + if (WideCharToMultiByte(wCp, 0, wszTemp, -1, *to, (int)inlen, nullptr, nullptr)) { nResult = 1; } else { @@ -350,7 +350,7 @@ int __stdcall utf8_decode_codepage(const char *from, char **to, WORD wCp) WCHAR *unicode = (WCHAR*)_alloca(chars * sizeof(WCHAR)); make_unicode_string_static(from, unicode, chars); - chars = WideCharToMultiByte(wCp, WC_COMPOSITECHECK, unicode, -1, NULL, 0, NULL, NULL); + chars = WideCharToMultiByte(wCp, WC_COMPOSITECHECK, unicode, -1, nullptr, 0, nullptr, nullptr); if (chars == 0) { #ifdef _DEBUG @@ -360,14 +360,14 @@ int __stdcall utf8_decode_codepage(const char *from, char **to, WORD wCp) } *to = (char*)SAFE_MALLOC((chars + 1)*sizeof(char)); - if (*to == NULL) { + if (*to == nullptr) { #ifdef _DEBUG fprintf(stderr, "Out of memory processing string to local charset\n"); #endif return 0; } - int err = WideCharToMultiByte(wCp, WC_COMPOSITECHECK, unicode, -1, *to, (int)chars, NULL, NULL); + int err = WideCharToMultiByte(wCp, WC_COMPOSITECHECK, unicode, -1, *to, (int)chars, nullptr, nullptr); if (err != (int)chars) { #ifdef _DEBUG fprintf(stderr, "Unicode translation error %d\n", GetLastError()); @@ -413,7 +413,7 @@ int __stdcall utf8_decode_static(const char *from, char *to, size_t to_size) // Convert the UTF-8 string to UCS if (MultiByteToWideChar(CP_UTF8, 0, from, -1, wszTemp, (int)inlen)) { // Convert the UCS string to local ANSI codepage - if (WideCharToMultiByte(CP_ACP, 0, wszTemp, -1, to, (int)to_size, NULL, NULL)) { + if (WideCharToMultiByte(CP_ACP, 0, wszTemp, -1, to, (int)to_size, nullptr, nullptr)) { nResult = 1; } } @@ -424,7 +424,7 @@ int __stdcall utf8_decode_static(const char *from, char *to, size_t to_size) make_unicode_string_static(from, unicode, chars); - WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode, -1, to, (int)to_size, NULL, NULL); + WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode, -1, to, (int)to_size, nullptr, nullptr); nResult = 1; } @@ -435,13 +435,13 @@ int __stdcall utf8_decode_static(const char *from, char *to, size_t to_size) WCHAR* __stdcall ansi_to_unicode(const char *ansi) { - int wchars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, ansi, (int)mir_strlen(ansi), NULL, 0); + int wchars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, ansi, (int)mir_strlen(ansi), nullptr, 0); if (wchars == 0) { #ifdef _DEBUG fprintf(stderr, "Unicode translation error %d\n", GetLastError()); #endif - return NULL; + return nullptr; } WCHAR *unicode = (WCHAR*)SAFE_MALLOC((wchars + 1) * sizeof(WCHAR)); @@ -452,7 +452,7 @@ WCHAR* __stdcall ansi_to_unicode(const char *ansi) fprintf(stderr, "Unicode translation error %d\n", GetLastError()); #endif SAFE_FREE(&unicode); - return NULL; + return nullptr; } return unicode; } @@ -462,37 +462,37 @@ char* __stdcall unicode_to_ansi_static(const WCHAR *unicode, char *ansi, size_t { memset(ansi, 0, ansi_size); - if (WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode, (int)mir_wstrlen(unicode), ansi, (int)ansi_size, NULL, NULL) > 1) + if (WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode, (int)mir_wstrlen(unicode), ansi, (int)ansi_size, nullptr, nullptr) > 1) return ansi; - return NULL; + return nullptr; } char* __stdcall unicode_to_ansi(const WCHAR *unicode) { - int chars = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode, (int)mir_wstrlen(unicode), NULL, 0, NULL, NULL); + int chars = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode, (int)mir_wstrlen(unicode), nullptr, 0, nullptr, nullptr); if (chars == 0) { #ifdef _DEBUG fprintf(stderr, "Unicode translation error %d\n", GetLastError()); #endif - return NULL; + return nullptr; } char* ansi = (char*)SAFE_MALLOC((chars + 1)*sizeof(char)); - if (ansi == NULL) { + if (ansi == nullptr) { #ifdef _DEBUG fprintf(stderr, "Out of memory processing string to local charset\n"); #endif - return NULL; + return nullptr; } - int err = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode, (int)mir_wstrlen(unicode), ansi, chars, NULL, NULL); + int err = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode, (int)mir_wstrlen(unicode), ansi, chars, nullptr, nullptr); if (err != chars) { #ifdef _DEBUG fprintf(stderr, "Unicode translation error %d\n", GetLastError()); #endif - return NULL; + return nullptr; } return ansi; diff --git a/protocols/IcqOscarJ/src/icq_advsearch.cpp b/protocols/IcqOscarJ/src/icq_advsearch.cpp index f8b13ae7dd..d9539b960a 100644 --- a/protocols/IcqOscarJ/src/icq_advsearch.cpp +++ b/protocols/IcqOscarJ/src/icq_advsearch.cpp @@ -27,7 +27,7 @@ static void InitComboBox(HWND hwndCombo, const FieldNamesItem *names) { - SendMessage(hwndCombo, CB_SETCURSEL, ComboBoxAddStringUtf(hwndCombo, NULL, 0), 0); + SendMessage(hwndCombo, CB_SETCURSEL, ComboBoxAddStringUtf(hwndCombo, nullptr, 0), 0); if (names) { for (int i = 0; names[i].text; i++) @@ -88,7 +88,7 @@ static void searchPackTLVWordLNTS(PBYTE *buf, size_t *buflen, HWND hwndDlg, UINT static PBYTE createAdvancedSearchStructureTLV(HWND hwndDlg, size_t *length) { - PBYTE buf = NULL; + PBYTE buf = nullptr; size_t buflen = 0; ppackLEWord(&buf, &buflen, META_SEARCH_GENERIC); /* subtype: full search */ @@ -143,7 +143,7 @@ static PBYTE createAdvancedSearchStructureTLV(HWND hwndDlg, size_t *length) PBYTE createAdvancedSearchStructure(HWND hwndDlg, size_t *length) { if (!hwndDlg) - return NULL; + return nullptr; return createAdvancedSearchStructureTLV(hwndDlg, length); } diff --git a/protocols/IcqOscarJ/src/icq_avatar.cpp b/protocols/IcqOscarJ/src/icq_avatar.cpp index 58de56c525..f554e06e60 100644 --- a/protocols/IcqOscarJ/src/icq_avatar.cpp +++ b/protocols/IcqOscarJ/src/icq_avatar.cpp @@ -58,7 +58,7 @@ wchar_t* CIcqProto::GetOwnAvatarFileName() { DBVARIANT dbvFile = {DBVT_DELETED}; if (getWString(NULL, "AvatarFile", &dbvFile)) - return NULL; + return nullptr; wchar_t tmp[MAX_PATH * 2]; PathToAbsoluteW(dbvFile.ptszVal, tmp); @@ -122,12 +122,12 @@ void AddAvatarExt(int dwFormat, wchar_t *pszDest) BYTE* calcMD5HashOfFile(const wchar_t *tszFile) { - BYTE *res = NULL; + BYTE *res = nullptr; - HANDLE hFile = NULL, hMap = NULL; - if ((hFile = CreateFile(tszFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL)) != INVALID_HANDLE_VALUE) { - if ((hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL) { - long cbFileSize = GetFileSize(hFile, NULL); + HANDLE hFile = nullptr, hMap = nullptr; + if ((hFile = CreateFile(tszFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr)) != INVALID_HANDLE_VALUE) { + if ((hMap = CreateFileMapping(hFile, nullptr, PAGE_READONLY, 0, 0, nullptr)) != nullptr) { + long cbFileSize = GetFileSize(hFile, nullptr); res = (BYTE*)SAFE_MALLOC(16 * sizeof(BYTE)); if (cbFileSize != 0 && res) { @@ -137,7 +137,7 @@ BYTE* calcMD5HashOfFile(const wchar_t *tszFile) mir_md5_init(&state); while (dwOffset < cbFileSize) { - BYTE *ppMap = NULL; + BYTE *ppMap = nullptr; int dwBlockSize = min(MD5_BLOCK_SIZE, cbFileSize - dwOffset); if (!(ppMap = (BYTE*)MapViewOfFile(hMap, FILE_MAP_READ, 0, dwOffset, dwBlockSize))) break; @@ -151,8 +151,8 @@ BYTE* calcMD5HashOfFile(const wchar_t *tszFile) } } - if (hMap != NULL) CloseHandle(hMap); - if (hFile != NULL) CloseHandle(hFile); + if (hMap != nullptr) CloseHandle(hMap); + if (hFile != nullptr) CloseHandle(hFile); } return res; @@ -249,8 +249,8 @@ void CIcqProto::handleAvatarOwnerHash(BYTE bFlags, BYTE *pData, size_t nDataLen) debugLogA("We have no avatar, requesting from server."); wchar_t szFile[MAX_PATH * 2 + 4]; - GetAvatarFileName(0, NULL, szFile, MAX_PATH * 2); - GetAvatarData(NULL, m_dwLocalUIN, NULL, pData, 0x14, szFile); + GetAvatarFileName(0, nullptr, szFile, MAX_PATH * 2); + GetAvatarData(NULL, m_dwLocalUIN, nullptr, pData, 0x14, szFile); } else { // we know avatar filename BYTE *hash = calcMD5HashOfFile(file); @@ -259,8 +259,8 @@ void CIcqProto::handleAvatarOwnerHash(BYTE bFlags, BYTE *pData, size_t nDataLen) debugLogA("We have no avatar, requesting from server."); wchar_t szFile[MAX_PATH * 2 + 4]; - GetAvatarFileName(0, NULL, szFile, MAX_PATH * 2); - GetAvatarData(NULL, m_dwLocalUIN, NULL, pData, 0x14, szFile); + GetAvatarFileName(0, nullptr, szFile, MAX_PATH * 2); + GetAvatarData(NULL, m_dwLocalUIN, nullptr, pData, 0x14, szFile); } // check if we had set any avatar if yes set our, if not download from server else if (memcmp(hash, pData + 4, 0x10)) { // we have different avatar, sync that @@ -281,8 +281,8 @@ void CIcqProto::handleAvatarOwnerHash(BYTE bFlags, BYTE *pData, size_t nDataLen) debugLogA("We have different avatar, requesting new from server."); wchar_t tszFile[MAX_PATH * 2 + 4]; - GetAvatarFileName(0, NULL, tszFile, MAX_PATH * 2); - GetAvatarData(NULL, m_dwLocalUIN, NULL, pData, 0x14, tszFile); + GetAvatarFileName(0, nullptr, tszFile, MAX_PATH * 2); + GetAvatarData(NULL, m_dwLocalUIN, nullptr, pData, 0x14, tszFile); } } SAFE_FREE((void**)&hash); @@ -309,23 +309,23 @@ void CIcqProto::handleAvatarOwnerHash(BYTE bFlags, BYTE *pData, size_t nDataLen) SetMyAvatar(0, 0); } else if (!memcmp(hash, pData + 4, 0x10)) { // we have the right file - HANDLE hFile = NULL, hMap = NULL; - BYTE *ppMap = NULL; + HANDLE hFile = nullptr, hMap = nullptr; + BYTE *ppMap = nullptr; long cbFileSize = 0; debugLogA("Uploading our avatar data."); - if ((hFile = CreateFile(file, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL)) != INVALID_HANDLE_VALUE) - if ((hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL) - if ((ppMap = (BYTE*)MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL) - cbFileSize = GetFileSize(hFile, NULL); + if ((hFile = CreateFile(file, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr)) != INVALID_HANDLE_VALUE) + if ((hMap = CreateFileMapping(hFile, nullptr, PAGE_READONLY, 0, 0, nullptr)) != nullptr) + if ((ppMap = (BYTE*)MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != nullptr) + cbFileSize = GetFileSize(hFile, nullptr); if (cbFileSize != 0) SetAvatarData(NULL, (WORD)(dwPaFormat == PA_FORMAT_XML ? AVATAR_HASH_FLASH : AVATAR_HASH_STATIC), ppMap, cbFileSize); - if (ppMap != NULL) UnmapViewOfFile(ppMap); - if (hMap != NULL) CloseHandle(hMap); - if (hFile != NULL) CloseHandle(hFile); + if (ppMap != nullptr) UnmapViewOfFile(ppMap); + if (hMap != nullptr) CloseHandle(hMap); + if (hFile != nullptr) CloseHandle(hFile); SAFE_FREE((void**)&hash); } else { @@ -358,7 +358,7 @@ void CIcqProto::handleAvatarContactHash(DWORD dwUIN, char *szUID, MCONTACT hCont int bJob = FALSE; BOOL avatarInfoPresent = FALSE; int avatarType = -1; - BYTE *pAvatarHash = NULL; + BYTE *pAvatarHash = nullptr; size_t cbAvatarHash = 0; BYTE emptyItem[0x10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -423,7 +423,7 @@ void CIcqProto::handleAvatarContactHash(DWORD dwUIN, char *szUID, MCONTACT hCont debugLogA("%s has removed Avatar.", strUID(dwUIN, szUID)); delSetting(hContact, "AvatarHash"); - ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0); + ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, nullptr, 0); } else debugLogA("%s has empty Avatar.", strUID(dwUIN, szUID)); return; @@ -441,7 +441,7 @@ void CIcqProto::handleAvatarContactHash(DWORD dwUIN, char *szUID, MCONTACT hCont debugLogA("%s has published Avatar. Image was found in the cache.", strUID(dwUIN, szUID)); setSettingBlob(hContact, "AvatarHash", pAvatarHash, cbAvatarHash); - ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0); + ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, nullptr, 0); } else { // the file was lost, request avatar again debugLogA("%s has published Avatar.", strUID(dwUIN, szUID)); @@ -501,7 +501,7 @@ void CIcqProto::handleAvatarContactHash(DWORD dwUIN, char *szUID, MCONTACT hCont setSettingBlob(hContact, "AvatarHash", pAvatarHash, cbAvatarHash); - ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0); + ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, nullptr, 0); if (bAutoLoad) { // auto-load is on, so request the avatar now, otherwise we are done GetAvatarFileName(dwUIN, szUID, tszAvatar, MAX_PATH * 2); @@ -516,7 +516,7 @@ void CIcqProto::handleAvatarContactHash(DWORD dwUIN, char *szUID, MCONTACT hCont debugLogA("%s has removed Avatar.", strUID(dwUIN, szUID)); delSetting(hContact, "AvatarHash"); - ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0); + ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, nullptr, 0); } else debugLogA("%s has no Avatar.", strUID(dwUIN, szUID)); } @@ -526,7 +526,7 @@ void CIcqProto::handleAvatarContactHash(DWORD dwUIN, char *szUID, MCONTACT hCont int CIcqProto::GetAvatarData(MCONTACT hContact, DWORD dwUin, const char *szUid, const BYTE *hash, size_t hashlen, const wchar_t *file) { uid_str szUidData; - char *pszUid = NULL; + char *pszUid = nullptr; if (!dwUin && szUid) { // create a copy in local writable buffer mir_strcpy(szUidData, szUid); pszUid = szUidData; @@ -679,7 +679,7 @@ void __cdecl CIcqProto::AvatarThread(avatars_server_connection *pInfo) // Remove connection reference mir_cslock l(m_avatarsMutex); if (m_avatarsConnection == pInfo) - m_avatarsConnection = NULL; + m_avatarsConnection = nullptr; // Release connection handler delete pInfo; @@ -714,7 +714,7 @@ void avatars_server_connection::closeConnection() mir_cslock l(localSeqMutex); if (hConnection) { Netlib_CloseHandle(hConnection); - hConnection = NULL; + hConnection = nullptr; } } @@ -881,7 +881,7 @@ void avatars_server_connection::checkRequestQueue() void avatars_server_connection::connectionThread() { // This is the "infinite" loop that receives the packets from the ICQ avatar server - DWORD dwLastKeepAlive = time(0) + KEEPALIVE_INTERVAL; + DWORD dwLastKeepAlive = time(nullptr) + KEEPALIVE_INTERVAL; hPacketRecver = Netlib_CreatePacketReceiver(hConnection, 65536); @@ -899,14 +899,14 @@ void avatars_server_connection::connectionThread() if (Miranda_IsTerminated()) break; - if (time(0) >= dwLastKeepAlive) { // limit frequency (HACK: on some systems select() does not work well) + if (time(nullptr) >= dwLastKeepAlive) { // limit frequency (HACK: on some systems select() does not work well) if (!ppro->m_bGatewayMode && ppro->getByte("KeepAlive", DEFAULT_KEEPALIVE_ENABLED)) { // send keep-alive packet icq_packet packet; packet.wLen = 0; write_flap(&packet, ICQ_PING_CHAN); sendServerPacket(&packet); } - dwLastKeepAlive = time(0) + KEEPALIVE_INTERVAL; + dwLastKeepAlive = time(nullptr) + KEEPALIVE_INTERVAL; } // check if we got something to request @@ -935,7 +935,7 @@ void avatars_server_connection::connectionThread() { // release rates mir_cslock l(m_ratesMutex); - delete m_rates; m_rates = NULL; + delete m_rates; m_rates = nullptr; } SAFE_FREE((void**)&pCookie); @@ -1143,7 +1143,7 @@ void avatars_server_connection::handleAvatarFam(BYTE *pBuffer, size_t wBufferLen switch (pSnacHeader->wSubtype) { case ICQ_AVATAR_GET_REPLY: // received avatar data, store to file // handle new avatar, notify - if (ppro->FindCookie(pSnacHeader->dwRef, NULL, (void**)&pCookieData)) { + if (ppro->FindCookie(pSnacHeader->dwRef, nullptr, (void**)&pCookieData)) { BYTE bResult; { // remove from active request list @@ -1282,7 +1282,7 @@ void avatars_server_connection::handleAvatarFam(BYTE *pBuffer, size_t wBufferLen BYTE res; unpackByte(&pBuffer, &res); if (!res && (wBufferLength == 0x15)) { - if (ppro->FindCookie(pSnacHeader->dwRef, NULL, (void**)&pCookieData)) // here we store the local hash + if (ppro->FindCookie(pSnacHeader->dwRef, nullptr, (void**)&pCookieData)) // here we store the local hash ppro->ReleaseCookie(pSnacHeader->dwRef); else ppro->debugLogA("Warning: Received unexpected Upload Avatar Reply SNAC(x10,x03)."); @@ -1295,7 +1295,7 @@ void avatars_server_connection::handleAvatarFam(BYTE *pBuffer, size_t wBufferLen break; case ICQ_ERROR: - if (ppro->FindCookie(pSnacHeader->dwRef, NULL, (void**)&pCookieData)) { + if (ppro->FindCookie(pSnacHeader->dwRef, nullptr, (void**)&pCookieData)) { if (pCookieData->dwUin) { ppro->debugLogA("Error: Avatar request failed"); SAFE_FREE(&pCookieData->szFile); diff --git a/protocols/IcqOscarJ/src/icq_clients.cpp b/protocols/IcqOscarJ/src/icq_clients.cpp index 9c1c44dc56..83ba2f4d1d 100644 --- a/protocols/IcqOscarJ/src/icq_clients.cpp +++ b/protocols/IcqOscarJ/src/icq_clients.cpp @@ -55,7 +55,7 @@ static void verToStr(char *szStr, int v) static char* MirandaVersionToStringEx(char* szStr, int bUnicode, const char* szPlug, int v, int m) { if (!v) // this is not Miranda - return NULL; + return nullptr; mir_strcpy(szStr, "Miranda IM "); @@ -195,7 +195,7 @@ const char* CIcqProto::detectUserClient( BYTE *bClientId, /* Output: detected client-type */ char *szClientBuf) { - LPCSTR szClient = NULL; + LPCSTR szClient = nullptr; int bMirandaIM = FALSE; *bClientId = CLID_ALTERNATIVE; // Most clients does not tick as MsgIDs @@ -666,7 +666,7 @@ const char* CIcqProto::detectUserClient( // others - like jabber transport uses unmodified library, thus cannot be detected } // THE SIGNATURE DETECTION ENDS HERE, after this only feature default will be detected - else if (szClient == NULL) { + else if (szClient == nullptr) { // ZA mangled the version, OMG! if (wVersion == 8 && CheckContactCapabilities(hContact, CAPF_XTRAZ) && (MatchCapability(caps, wLen, &capIMSecKey1, 6) || MatchCapability(caps, wLen, &capIMSecKey2, 6))) wVersion = ICQ_VERSION; @@ -931,7 +931,7 @@ const char* CIcqProto::detectUserClient( szClient = "MRA client"; } - if (szClient == NULL) + if (szClient == nullptr) szClient = "AIM"; } } @@ -953,7 +953,7 @@ const char* CIcqProto::detectUserClient( } } - BOOL bClientDetected = (szClient != NULL); + BOOL bClientDetected = (szClient != nullptr); // client detection failed, provide default clients if (!szClient) { @@ -977,7 +977,7 @@ const char* CIcqProto::detectUserClient( } if (szClient) { - char *szExtra = NULL; + char *szExtra = nullptr; if (MatchCapability(caps, wLen, &capSimpLite)) szExtra = " + SimpLite"; diff --git a/protocols/IcqOscarJ/src/icq_db.cpp b/protocols/IcqOscarJ/src/icq_db.cpp index fd1f71e31a..2c856d56ee 100644 --- a/protocols/IcqOscarJ/src/icq_db.cpp +++ b/protocols/IcqOscarJ/src/icq_db.cpp @@ -82,7 +82,7 @@ int CIcqProto::getContactUid(MCONTACT hContact, DWORD *pdwUin, uid_str *ppszUid) case DBVT_UTF8: if (ppszUid) { mir_strcpy(*ppszUid, dbv.pszVal); - mir_utf8decode(*ppszUid, NULL); + mir_utf8decode(*ppszUid, nullptr); iRes = 0; } else debugLogA("AOL screennames not accepted"); @@ -151,7 +151,7 @@ void CIcqProto::setStatusMsgVar(MCONTACT hContact, char* szStatusMsg, bool isAns wchar_t *szStatusNoteW = make_unicode_string(szStatusNote); int len = (int)mir_wstrlen(szStatusNoteW) * 3 + 1; char *szStatusNoteAnsi = (char*)alloca(len); - WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, szStatusNoteW, -1, szStatusNoteAnsi, len, NULL, NULL); + WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, szStatusNoteW, -1, szStatusNoteAnsi, len, nullptr, nullptr); bool notmatch = false; for (int i = 0;; ++i) { if (szStatusNoteAnsi[i] != szStatusMsg[i] && szStatusNoteAnsi[i] != '?' && szStatusMsg[i] != '?') { @@ -167,7 +167,7 @@ void CIcqProto::setStatusMsgVar(MCONTACT hContact, char* szStatusMsg, bool isAns SAFE_FREE(&szStatusNote); } - char *oldStatusMsg = NULL; + char *oldStatusMsg = nullptr; DBVARIANT dbv; if (!db_get_ws(hContact, "CList", "StatusMsg", &dbv)) { oldStatusMsg = make_utf8_string(dbv.ptszVal); @@ -203,5 +203,5 @@ MEVENT CIcqProto::AddEvent(MCONTACT hContact, WORD wType, DWORD dwTime, DWORD fl char* CIcqProto::getContactCListGroup(MCONTACT hContact) { - return getSettingStringUtf(hContact, "CList", "Group", NULL); + return getSettingStringUtf(hContact, "CList", "Group", nullptr); } diff --git a/protocols/IcqOscarJ/src/icq_direct.cpp b/protocols/IcqOscarJ/src/icq_direct.cpp index d634eb520a..40a6ed5e0e 100644 --- a/protocols/IcqOscarJ/src/icq_direct.cpp +++ b/protocols/IcqOscarJ/src/icq_direct.cpp @@ -52,7 +52,7 @@ void CIcqProto::CloseContactDirectConns(MCONTACT hContact) if (!hContact || directConns[i]->hContact == hContact) { HNETLIBCONN hConnection = directConns[i]->hConnection; - directConns[i]->hConnection = NULL; // do not allow reuse + directConns[i]->hConnection = nullptr; // do not allow reuse NetLib_CloseConnection(&hConnection, FALSE); } } @@ -61,7 +61,7 @@ void CIcqProto::CloseContactDirectConns(MCONTACT hContact) directconnect* CIcqProto::FindFileTransferDC(filetransfer* ft) { - directconnect* dc = NULL; + directconnect* dc = nullptr; mir_cslock l(directConnListMutex); for (int i = 0; i < directConns.getCount(); i++) { @@ -77,7 +77,7 @@ directconnect* CIcqProto::FindFileTransferDC(filetransfer* ft) filetransfer* CIcqProto::FindExpectedFileRecv(DWORD dwUin, DWORD dwTotalSize) { - filetransfer* pFt = NULL; + filetransfer* pFt = nullptr; mir_cslock l(expectedFileRecvMutex); for (int i = 0; i < expectedFileRecvs.getCount(); i++) { @@ -151,7 +151,7 @@ BOOL CIcqProto::IsDirectConnectionOpen(MCONTACT hContact, int type, int bPassive // Set DC status as tried setByte(hContact, "DCStatus", 1); // Create a new connection - OpenDirectConnection(hContact, DIRECTCONN_STANDARD, NULL); + OpenDirectConnection(hContact, DIRECTCONN_STANDARD, nullptr); } return bIsOpen; @@ -170,7 +170,7 @@ void icq_newConnectionReceived(HNETLIBCONN hNewConnection, DWORD, void *pExtra) void CIcqProto::OpenDirectConnection(MCONTACT hContact, int type, void* pvExtra) { // Create a new connection - directthreadstartinfo* dtsi = CreateDTSI(hContact, NULL, type); + directthreadstartinfo* dtsi = CreateDTSI(hContact, nullptr, type); dtsi->pvExtra = pvExtra; ForkThread((MyThreadFunc)&CIcqProto::icq_directThread, dtsi); } @@ -200,7 +200,7 @@ void __cdecl CIcqProto::icq_directThread(directthreadstartinfo *dtsi) size_t nSkipPacketBytes = 0; DWORD dwReqMsgID1 = 0, dwReqMsgID2 = 0; - srand(time(NULL)); + srand(time(nullptr)); { // add to DC connection list mir_cslock l(directConnListMutex); @@ -212,7 +212,7 @@ void __cdecl CIcqProto::icq_directThread(directthreadstartinfo *dtsi) dc.dwThreadId = GetCurrentThreadId(); dc.incoming = dtsi->incoming; dc.hConnection = dtsi->hConnection; - dc.ft = NULL; + dc.ft = nullptr; if (!dc.incoming) { dc.type = dtsi->type; @@ -277,10 +277,10 @@ void __cdecl CIcqProto::icq_directThread(directthreadstartinfo *dtsi) nloc.szHost = inet_ntoa(addr); nloc.wPort = (WORD)dc.dwRemotePort; nloc.timeout = 8; // 8 secs to connect - dc.hConnection = NetLib_OpenConnection(m_hDirectNetlibUser, dc.type == DIRECTCONN_REVERSE ? "Reverse " : NULL, &nloc); + dc.hConnection = NetLib_OpenConnection(m_hDirectNetlibUser, dc.type == DIRECTCONN_REVERSE ? "Reverse " : nullptr, &nloc); if (!dc.hConnection && addr2.S_un.S_addr) { // first address failed, try second one if available nloc.szHost = inet_ntoa(addr2); - dc.hConnection = NetLib_OpenConnection(m_hDirectNetlibUser, dc.type == DIRECTCONN_REVERSE ? "Reverse " : NULL, &nloc); + dc.hConnection = NetLib_OpenConnection(m_hDirectNetlibUser, dc.type == DIRECTCONN_REVERSE ? "Reverse " : nullptr, &nloc); } if (!dc.hConnection) { if (CheckContactCapabilities(dc.hContact, CAPF_ICQDIRECT)) { // only if the contact support ICQ DC connections @@ -468,7 +468,7 @@ void CIcqProto::handleDirectPacket(directconnect* dc, PBYTE buf, size_t wLen) dc->incoming = 0; cookie_reverse_connect *pCookie; - if (FindCookie(dc->dwReqId, NULL, (void**)&pCookie) && pCookie) { // valid reverse DC, check and init session + if (FindCookie(dc->dwReqId, nullptr, (void**)&pCookie) && pCookie) { // valid reverse DC, check and init session FreeCookie(dc->dwReqId); if (pCookie->dwUin == dc->dwRemoteUin) { // valid connection dc->type = pCookie->type; @@ -551,7 +551,7 @@ void CIcqProto::handleDirectPacket(directconnect* dc, PBYTE buf, size_t wLen) unpackLEDWord(&buf, &dc->dwReqId); if (dc->dwRemoteUin || !dc->dwReqId) { // OMG! Licq sends on reverse connection empty uin - hContact = HContactFromUIN(dc->dwRemoteUin, NULL); + hContact = HContactFromUIN(dc->dwRemoteUin, nullptr); if (hContact == INVALID_CONTACT_ID) { NetLog_Direct("Error: Received PEER_INIT from %u not on my list", dwUin); CloseDirectConnection(dc); @@ -579,7 +579,7 @@ void CIcqProto::handleDirectPacket(directconnect* dc, PBYTE buf, size_t wLen) if (!dc->dwRemoteUin) { // we need to load cookie (licq) cookie_reverse_connect *pCookie; - if (FindCookie(dc->dwReqId, NULL, (void**)&pCookie) && pCookie) { // valid reverse DC, check and init session + if (FindCookie(dc->dwReqId, nullptr, (void**)&pCookie) && pCookie) { // valid reverse DC, check and init session dc->dwRemoteUin = pCookie->dwUin; dc->hContact = pCookie->hContact; } @@ -824,7 +824,7 @@ int CIcqProto::SendDirectMessage(MCONTACT hContact, icq_packet *pkt) mir_cslock l(directConnListMutex); for (int i = 0; i < directConns.getCount(); i++) { - if (directConns[i] == NULL) + if (directConns[i] == nullptr) continue; if (directConns[i]->hContact == hContact) { diff --git a/protocols/IcqOscarJ/src/icq_directmsg.cpp b/protocols/IcqOscarJ/src/icq_directmsg.cpp index 65eb850e15..9d4afa4238 100644 --- a/protocols/IcqOscarJ/src/icq_directmsg.cpp +++ b/protocols/IcqOscarJ/src/icq_directmsg.cpp @@ -33,7 +33,7 @@ void CIcqProto::handleDirectMessage(directconnect* dc, PBYTE buf, size_t wLen) WORD wStatus; WORD wFlags; WORD wTextLen; - char* pszText = NULL; + char* pszText = nullptr; // The first part of the packet should always be at least 31 bytes if (wLen < 31) { @@ -136,7 +136,7 @@ void CIcqProto::handleDirectMessage(directconnect* dc, PBYTE buf, size_t wLen) pMsgAck.wCookie = wCookie; pMsgAck.msgType = bMsgType; pMsgAck.bFlags = bMsgFlags; - handleMessageTypes(dc->dwRemoteUin, szUID, time(NULL), 0, 0, wCookie, dc->wVersion, (int)bMsgType, (int)bMsgFlags, 0, (DWORD)wLen, wTextLen, (char*)buf, MTF_DIRECT, &pMsgAck); + handleMessageTypes(dc->dwRemoteUin, szUID, time(nullptr), 0, 0, wCookie, dc->wVersion, (int)bMsgType, (int)bMsgFlags, 0, (DWORD)wLen, wTextLen, (char*)buf, MTF_DIRECT, &pMsgAck); break; } } @@ -148,11 +148,11 @@ void CIcqProto::handleDirectMessage(directconnect* dc, PBYTE buf, size_t wLen) buf -= wTextLen; wLen += wTextLen; - handleMessageTypes(dc->dwRemoteUin, szUID, time(NULL), 0, 0, wCookie, dc->wVersion, (int)bMsgType, (int)bMsgFlags, 2, (DWORD)wLen, wTextLen, (char*)buf, MTF_DIRECT, NULL); + handleMessageTypes(dc->dwRemoteUin, szUID, time(nullptr), 0, 0, wCookie, dc->wVersion, (int)bMsgType, (int)bMsgFlags, 2, (DWORD)wLen, wTextLen, (char*)buf, MTF_DIRECT, nullptr); } else { MCONTACT hCookieContact; - cookie_message_data *pCookieData = NULL; + cookie_message_data *pCookieData = nullptr; if (!FindCookie(wCookie, &hCookieContact, (void**)&pCookieData)) NetLog_Direct("Received an unexpected direct ack"); else if (hCookieContact != dc->hContact) { @@ -251,7 +251,7 @@ void CIcqProto::handleDirectGreetingMessage(directconnect* dc, PBYTE buf, size_t pMsgAck.pDC = dc; pMsgAck.wCookie = wCookie; pMsgAck.msgType = typeId; - handleMessageTypes(dc->dwRemoteUin, szUID, time(NULL), 0, 0, wCookie, dc->wVersion, typeId, 0, 0, dwLengthToEnd, dwDataLength, (char*)buf, MTF_PLUGIN | MTF_DIRECT, &pMsgAck); + handleMessageTypes(dc->dwRemoteUin, szUID, time(nullptr), 0, 0, wCookie, dc->wVersion, typeId, 0, 0, dwLengthToEnd, dwDataLength, (char*)buf, MTF_PLUGIN | MTF_DIRECT, &pMsgAck); } else if (typeId == MTYPE_STATUSMSGEXT && wCommand == DIRECT_ACK) { // especially for icq2003b NetLog_Direct("This is extended status reply"); @@ -261,11 +261,11 @@ void CIcqProto::handleDirectGreetingMessage(directconnect* dc, PBYTE buf, size_t szMsg[dwDataLength] = '\0'; uid_str szUID; - handleMessageTypes(dc->dwRemoteUin, szUID, time(NULL), 0, 0, wCookie, dc->wVersion, (int)(qt + 0xE7), 3, 2, wLen, dwDataLength, szMsg, MTF_PLUGIN | MTF_DIRECT, NULL); + handleMessageTypes(dc->dwRemoteUin, szUID, time(nullptr), 0, 0, wCookie, dc->wVersion, (int)(qt + 0xE7), 3, 2, wLen, dwDataLength, szMsg, MTF_PLUGIN | MTF_DIRECT, nullptr); } else if (typeId && wCommand == DIRECT_ACK) { MCONTACT hCookieContact; - cookie_message_data *pCookieData = NULL; + cookie_message_data *pCookieData = nullptr; if (!FindCookie(wCookie, &hCookieContact, (void**)&pCookieData)) { NetLog_Direct("Received an unexpected direct ack"); diff --git a/protocols/IcqOscarJ/src/icq_fieldnames.cpp b/protocols/IcqOscarJ/src/icq_fieldnames.cpp index 21b7d887ae..eb6d973992 100644 --- a/protocols/IcqOscarJ/src/icq_fieldnames.cpp +++ b/protocols/IcqOscarJ/src/icq_fieldnames.cpp @@ -27,7 +27,7 @@ FieldNamesItem timezonesField[] = { - { -100, NULL } + { -100, nullptr } }; const FieldNamesItem countryField[] = { @@ -281,7 +281,7 @@ const FieldNamesItem countryField[] = { { 382, LPGEN("Montenegro") }, /* rename need (from Yugoslavia - Montenegro) */ { 260, LPGEN("Zambia") }, { 263, LPGEN("Zimbabwe") }, - { 0, NULL } + { 0, nullptr } }; const FieldNamesItem interestsField[] = @@ -336,7 +336,7 @@ const FieldNamesItem interestsField[] = { 127, LPGEN("Travel") }, { 121, LPGEN("Web Design") }, { 132, LPGEN("Women") }, - { -1, NULL } + { -1, nullptr } }; const FieldNamesItem languageField[] = @@ -413,7 +413,7 @@ const FieldNamesItem languageField[] = { 67, LPGEN("Welsh") }, { 53, LPGEN("Yiddish") }, { 54, LPGEN("Yoruba") }, - { 0, NULL } + { 0, nullptr } }; const FieldNamesItem pastField[] = @@ -426,14 +426,14 @@ const FieldNamesItem pastField[] = { 305, LPGEN("Past Work Place") }, { 306, LPGEN("Past Organization") }, { 399, LPGEN("Other") }, - { 0, NULL } + { 0, nullptr } }; const FieldNamesItem genderField[] = { { 'F', LPGEN("Female") }, { 'M', LPGEN("Male") }, - { 0, NULL } + { 0, nullptr } }; const FieldNamesItem studyLevelField[] = @@ -446,7 +446,7 @@ const FieldNamesItem studyLevelField[] = { 7, LPGEN("PhD") }, { 8, LPGEN("Postdoctoral") }, { 3, LPGEN("University / College") }, - { 0, NULL } + { 0, nullptr } }; const FieldNamesItem industryField[] = @@ -469,7 +469,7 @@ const FieldNamesItem industryField[] = { 16, LPGEN("Recreation, Travel & Entertainment") }, { 17, LPGEN("Service Industry") }, { 18, LPGEN("Transportation") }, - { 0, NULL } + { 0, nullptr } }; const FieldNamesItem occupationField[] = @@ -502,7 +502,7 @@ const FieldNamesItem occupationField[] = { 26, LPGEN("University Student") }, { 27, LPGEN("Web Building") }, { 99, LPGEN("Other Services") }, - { 0, NULL } + { 0, nullptr } }; const FieldNamesItem affiliationField[] = @@ -527,7 +527,7 @@ const FieldNamesItem affiliationField[] = { 217, LPGEN("Union") }, { 218, LPGEN("Volunteer Org.") }, { 299, LPGEN("Other") }, - { 0, NULL } + { 0, nullptr } }; const FieldNamesItem agesField[] = @@ -539,7 +539,7 @@ const FieldNamesItem agesField[] = { 0x00310028, LPGEN("40-49") }, { 0x003B0032, LPGEN("50-59") }, { 0x2710003C, LPGEN("60-above") }, - { -1, NULL } + { -1, nullptr } }; const FieldNamesItem maritalField[] = @@ -553,7 +553,7 @@ const FieldNamesItem maritalField[] = { 40, LPGEN("Widowed") }, { 50, LPGEN("Open relationship") }, { 255, LPGEN("Other") }, - { 0, NULL } + { 0, nullptr } }; char* LookupFieldName(const FieldNamesItem *table, int code) @@ -563,7 +563,7 @@ char* LookupFieldName(const FieldNamesItem *table, int code) if (table[i].code == code) return table[i].text; - return NULL; + return nullptr; } char* LookupFieldNameUtf(const FieldNamesItem *table, int code, char *str, size_t strsize) @@ -572,5 +572,5 @@ char* LookupFieldNameUtf(const FieldNamesItem *table, int code, char *str, size_ if (szText) return ICQTranslateUtfStatic(szText, str, strsize); - return NULL; + return nullptr; } diff --git a/protocols/IcqOscarJ/src/icq_filerequests.cpp b/protocols/IcqOscarJ/src/icq_filerequests.cpp index 06548f207e..e907124806 100644 --- a/protocols/IcqOscarJ/src/icq_filerequests.cpp +++ b/protocols/IcqOscarJ/src/icq_filerequests.cpp @@ -27,7 +27,7 @@ void CIcqProto::handleFileAck(PBYTE buf, size_t wLen, DWORD dwUin, DWORD dwCookie, WORD wStatus) { - char* pszFileName = NULL; + char* pszFileName = nullptr; DWORD dwFileSize; MCONTACT hCookieContact; WORD wPort; @@ -41,7 +41,7 @@ void CIcqProto::handleFileAck(PBYTE buf, size_t wLen, DWORD dwUin, DWORD dwCooki FreeCookie(dwCookie); - if (hCookieContact != HContactFromUIN(dwUin, NULL)) { + if (hCookieContact != HContactFromUIN(dwUin, nullptr)) { NetLog_Direct("Error: UINs do not match in file transfer request response"); return; } @@ -143,7 +143,7 @@ void CIcqProto::handleFileRequest(PBYTE buf, DWORD dwUin, DWORD dwCookie, DWORD filetransfer *ft = CreateFileTransfer(hContact, dwUin, nVersion); ft->dwCookie = dwCookie; ft->szFilename = mir_strdup(pszFileName); - ft->szDescription = 0; + ft->szDescription = nullptr; ft->fileId = -1; ft->dwTotalSize = dwFileSize; ft->pMessage.dwMsgID1 = dwID1; @@ -157,7 +157,7 @@ void CIcqProto::handleFileRequest(PBYTE buf, DWORD dwUin, DWORD dwCookie, DWORD PROTORECVFILET pre = { 0 }; pre.dwFlags = PRFF_UNICODE; pre.fileCount = 1; - pre.timestamp = time(NULL); + pre.timestamp = time(nullptr); pre.descr.w = mir_utf8decodeW(pszDescription); pre.files.w = &ptszFileName; pre.lParam = (LPARAM)ft; @@ -177,7 +177,7 @@ void CIcqProto::handleDirectCancel() void CIcqProto::icq_CancelFileTransfer(filetransfer* ft) { DWORD dwCookie; - if (FindCookieByData(ft, &dwCookie, NULL)) + if (FindCookieByData(ft, &dwCookie, nullptr)) FreeCookie(dwCookie); /* this bit stops a send that's waiting for acceptance */ if (IsValidFileTransfer(ft)) { // Transfer still out there, end it diff --git a/protocols/IcqOscarJ/src/icq_filetransfer.cpp b/protocols/IcqOscarJ/src/icq_filetransfer.cpp index 4cfd6e6d47..d5f98899eb 100644 --- a/protocols/IcqOscarJ/src/icq_filetransfer.cpp +++ b/protocols/IcqOscarJ/src/icq_filetransfer.cpp @@ -34,7 +34,7 @@ static void file_buildProtoFileTransferStatus(filetransfer* ft, PROTOFILETRANSFE if (ft->sending) pfts->pszFiles = ft->pszFiles; else - pfts->pszFiles = NULL; /* FIXME */ + pfts->pszFiles = nullptr; /* FIXME */ pfts->totalFiles = ft->dwFileCount; pfts->currentFileNumber = ft->iCurrentFile; pfts->totalBytes = ft->dwTotalSize; @@ -81,7 +81,7 @@ static void file_sendNextFile(CIcqProto* ppro, directconnect* dc) if (dc->ft->iCurrentFile >= (int)dc->ft->dwFileCount) { ppro->ProtoBroadcastAck(dc->ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, dc->ft, 0); ppro->CloseDirectConnection(dc); - dc->ft->hConnection = NULL; + dc->ft->hConnection = nullptr; return; } @@ -89,7 +89,7 @@ static void file_sendNextFile(CIcqProto* ppro, directconnect* dc) if (FileStatUtf(dc->ft->szThisFile, &statbuf)) { ppro->icq_LogMessage(LOG_ERROR, LPGEN("Your file transfer has been aborted because one of the files that you selected to send is no longer readable from the disk. You may have deleted or moved it.")); ppro->CloseDirectConnection(dc); - dc->ft->hConnection = NULL; + dc->ft->hConnection = nullptr; return; } @@ -103,7 +103,7 @@ static void file_sendNextFile(CIcqProto* ppro, directconnect* dc) if (dc->ft->fileId == -1) { ppro->icq_LogMessage(LOG_ERROR, LPGEN("Your file transfer has been aborted because one of the files that you selected to send is no longer readable from the disk. You may have deleted or moved it.")); ppro->CloseDirectConnection(dc); - dc->ft->hConnection = NULL; + dc->ft->hConnection = nullptr; return; } } @@ -112,7 +112,7 @@ static void file_sendNextFile(CIcqProto* ppro, directconnect* dc) dc->ft->dwThisFileDate = statbuf.st_mtime; dc->ft->dwFileBytesDone = 0; - char *szThisFileNameAnsi = NULL, *szThisSubDirAnsi = NULL; + char *szThisFileNameAnsi = nullptr, *szThisSubDirAnsi = nullptr; if (!utf8_decode(pszThisFileName, &szThisFileNameAnsi)) szThisFileNameAnsi = _strdup(pszThisFileName); // Legacy fix if (!utf8_decode(szThisSubDir, &szThisSubDirAnsi)) @@ -203,7 +203,7 @@ void CIcqProto::handleFileTransferIdle(directconnect* dc) void CIcqProto::icq_sendFileResume(filetransfer *ft, int action, const char *szFilename) { - if (ft->hConnection == NULL) + if (ft->hConnection == nullptr) return; directconnect *dc = FindFileTransferDC(ft); @@ -304,7 +304,7 @@ void CIcqProto::handleFileTransferPacket(directconnect* dc, PBYTE buf, size_t wL unpackLEWord(&buf, &wNickLength); dc->ft = FindExpectedFileRecv(dc->dwRemoteUin, dwTotalSize); - if (dc->ft == NULL) { + if (dc->ft == nullptr) { NetLog_Direct("Unexpected file receive"); CloseDirectConnection(dc); return; @@ -404,7 +404,7 @@ void CIcqProto::handleFileTransferPacket(directconnect* dc, PBYTE buf, size_t wL if (dc->ft->fileId == -1) { icq_LogMessage(LOG_ERROR, LPGEN("Your file receive has been aborted because Miranda could not open the destination file in order to write to it. You may be trying to save to a read-only folder.")); CloseDirectConnection(dc); - dc->ft->hConnection = NULL; + dc->ft->hConnection = nullptr; break; } } diff --git a/protocols/IcqOscarJ/src/icq_http.cpp b/protocols/IcqOscarJ/src/icq_http.cpp index f98bc263dd..389670904a 100644 --- a/protocols/IcqOscarJ/src/icq_http.cpp +++ b/protocols/IcqOscarJ/src/icq_http.cpp @@ -175,13 +175,13 @@ PBYTE icq_httpGatewayUnwrapRecv(NETLIBHTTPREQUEST*, PBYTE buf, int len, int* out unpackByte(&tbuf, &bRes); wLen -= 1; if (!bRes) - Netlib_Logf( NULL, "Gateway Connection #%d Established.", dwPackSeq); + Netlib_Logf( nullptr, "Gateway Connection #%d Established.", dwPackSeq); else - Netlib_Logf( NULL, "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( NULL, "Gateway Connection #%d Closed.", dwPackSeq); + Netlib_Logf( nullptr, "Gateway Connection #%d Closed.", dwPackSeq); } tbuf += wLen - 12; } diff --git a/protocols/IcqOscarJ/src/icq_infoupdate.cpp b/protocols/IcqOscarJ/src/icq_infoupdate.cpp index bcca728f1c..28a90bf2e8 100644 --- a/protocols/IcqOscarJ/src/icq_infoupdate.cpp +++ b/protocols/IcqOscarJ/src/icq_infoupdate.cpp @@ -33,7 +33,7 @@ void CIcqProto::icq_InitInfoUpdate(void) { // Create wait objects - hInfoQueueEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + hInfoQueueEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); if (hInfoQueueEvent) { // Init list for (int i = 0; i < LISTSIZE; i++) { @@ -42,7 +42,7 @@ void CIcqProto::icq_InitInfoUpdate(void) m_infoUpdateList[i].queued = 0; } - ForkThread(&CIcqProto::InfoUpdateThread, 0); + ForkThread(&CIcqProto::InfoUpdateThread, nullptr); } bInfoPendingUsers = 0; @@ -81,7 +81,7 @@ BOOL CIcqProto::icq_QueueUser(MCONTACT hContact) if (dwUin) { m_infoUpdateList[nFirstFree].dwUin = dwUin; m_infoUpdateList[nFirstFree].hContact = hContact; - m_infoUpdateList[nFirstFree].queued = time(NULL); + m_infoUpdateList[nFirstFree].queued = time(nullptr); nInfoUserCount++; debugLogA("Queued user %u, place %u, count %u", dwUin, nFirstFree, nInfoUserCount); @@ -179,7 +179,7 @@ void __cdecl CIcqProto::InfoUpdateThread( void* ) continue; // we can't send requests now if (nInfoUserCount && icqOnline()) { - time_t now = time(NULL); + time_t now = time(nullptr); BOOL bNotReady = FALSE, bTimeOuted = FALSE; // Check the list, take only users that were there for at least 5sec @@ -208,7 +208,7 @@ void __cdecl CIcqProto::InfoUpdateThread( void* ) } // only send another request, when the previous is completed - if (FindCookie(dwInfoActiveRequest, NULL, NULL)) { + if (FindCookie(dwInfoActiveRequest, nullptr, nullptr)) { debugLogA("Info-Update: Request 0x%x still in progress.", dwInfoActiveRequest); SleepEx(1000, TRUE); @@ -250,7 +250,7 @@ void __cdecl CIcqProto::InfoUpdateThread( void* ) userinfo *hContactList[LISTSIZE]; int nListIndex = 0; - BYTE *pRequestData = NULL; + BYTE *pRequestData = nullptr; size_t nRequestSize = 0; mir_cslock l(infoUpdateMutex); @@ -259,7 +259,7 @@ void __cdecl CIcqProto::InfoUpdateThread( void* ) // check TS again, maybe it has been updated while we slept if (IsMetaInfoChanged(m_infoUpdateList[i].hContact)) { if (m_infoUpdateList[i].queued + 5 < now) { - BYTE *pItem = NULL; + BYTE *pItem = nullptr; size_t nItemSize = 0; DBVARIANT dbv = { DBVT_DELETED }; @@ -270,7 +270,7 @@ void __cdecl CIcqProto::InfoUpdateThread( void* ) // last updated time ppackTLVDouble(&pItem, &nItemSize, 0x64, getSettingDouble(m_infoUpdateList[i].hContact, DBSETTING_METAINFO_TIME, 0)); - ppackTLVUID(&pItem, &nItemSize, 0x32, m_infoUpdateList[i].dwUin, NULL); + ppackTLVUID(&pItem, &nItemSize, 0x32, m_infoUpdateList[i].dwUin, nullptr); ppackWord(&pRequestData, &nRequestSize, (WORD)nItemSize); ppackBuffer(&pRequestData, &nRequestSize, nItemSize, pItem); // take a reference diff --git a/protocols/IcqOscarJ/src/icq_menu.cpp b/protocols/IcqOscarJ/src/icq_menu.cpp index 65829a11c8..93cc50b027 100644 --- a/protocols/IcqOscarJ/src/icq_menu.cpp +++ b/protocols/IcqOscarJ/src/icq_menu.cpp @@ -40,14 +40,14 @@ LIST g_Instances(1, sttCompareProtocols); static CIcqProto* IcqGetInstanceByHContact(MCONTACT hContact) { char* szProto = GetContactProto(hContact); - if (szProto == NULL) - return NULL; + if (szProto == nullptr) + return nullptr; for (int i = 0; i < g_Instances.getCount(); i++) if (!mir_strcmp(szProto, g_Instances[i]->m_szModuleName)) return g_Instances[i]; - return NULL; + return nullptr; } static INT_PTR IcqMenuHandleRequestAuth(WPARAM wParam, LPARAM lParam) @@ -151,7 +151,7 @@ void g_MenuInit(void) 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 = 0; + mi.hIcolibItem = nullptr; g_hContactMenuItems[ICMI_XSTATUS_DETAILS] = Menu_AddContactMenuItem(&mi); // "Open ICQ profile" @@ -205,9 +205,9 @@ int CIcqProto::OnPreBuildContactMenu(WPARAM hContact, LPARAM) Menu_ShowItem(g_hContactMenuItems[ICMI_XSTATUS_DETAILS], m_bHideXStatusUI ? 0 : bXStatus != 0); if (bXStatus && !m_bHideXStatusUI) { if (bXStatus > 0 && bXStatus <= XSTATUS_COUNT) - Menu_ModifyItem(g_hContactMenuItems[ICMI_XSTATUS_DETAILS], NULL, getXStatusIcon(bXStatus, LR_SHARED)); + Menu_ModifyItem(g_hContactMenuItems[ICMI_XSTATUS_DETAILS], nullptr, getXStatusIcon(bXStatus, LR_SHARED)); else - Menu_ModifyItem(g_hContactMenuItems[ICMI_XSTATUS_DETAILS], NULL, Skin_LoadIcon(SKINICON_OTHER_SMALLDOT)); + Menu_ModifyItem(g_hContactMenuItems[ICMI_XSTATUS_DETAILS], nullptr, Skin_LoadIcon(SKINICON_OTHER_SMALLDOT)); } return 0; diff --git a/protocols/IcqOscarJ/src/icq_opts.cpp b/protocols/IcqOscarJ/src/icq_opts.cpp index a05b3c236d..1629b3f7ce 100644 --- a/protocols/IcqOscarJ/src/icq_opts.cpp +++ b/protocols/IcqOscarJ/src/icq_opts.cpp @@ -145,7 +145,7 @@ static INT_PTR CALLBACK DlgProcIcqOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP case PSN_APPLY: char str[128]; - ppro->setDword(UNIQUEIDSETTING, GetDlgItemInt(hwndDlg, IDC_ICQNUM, NULL, FALSE)); + ppro->setDword(UNIQUEIDSETTING, GetDlgItemInt(hwndDlg, IDC_ICQNUM, nullptr, FALSE)); GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, _countof(ppro->m_szPassword)); if (mir_strlen(str)) { mir_strcpy(ppro->m_szPassword, str); @@ -157,7 +157,7 @@ static INT_PTR CALLBACK DlgProcIcqOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP GetDlgItemTextA(hwndDlg, IDC_ICQSERVER, str, _countof(str)); ppro->setString("OscarServer", str); - ppro->setWord("OscarPort", (WORD)GetDlgItemInt(hwndDlg, IDC_ICQPORT, NULL, FALSE)); + ppro->setWord("OscarPort", (WORD)GetDlgItemInt(hwndDlg, IDC_ICQPORT, nullptr, FALSE)); StoreDBCheckState(ppro, hwndDlg, IDC_KEEPALIVE, "KeepAlive"); StoreDBCheckState(ppro, hwndDlg, IDC_SSL, "SecureConnection"); @@ -258,7 +258,7 @@ static INT_PTR CALLBACK DlgProcIcqPrivacyOpts(HWND hwndDlg, UINT msg, WPARAM wPa StoreDBCheckState(ppro, hwndDlg, IDC_ADD_AUTH, "Auth"); if (ppro->icqOnline()) { - PBYTE buf = NULL; + PBYTE buf = nullptr; size_t buflen = 0; ppackTLVWord(&buf, &buflen, 0x19A, !ppro->getByte("Auth", 1)); @@ -275,10 +275,10 @@ static INT_PTR CALLBACK DlgProcIcqPrivacyOpts(HWND hwndDlg, UINT msg, WPARAM wPa if (ppro->m_iStatus == ID_STATUS_INVISIBLE) { if (ppro->m_bSsiEnabled) ppro->updateServVisibilityCode(3); - ppro->icq_setstatus(wStatus, NULL); + ppro->icq_setstatus(wStatus, nullptr); } else { - ppro->icq_setstatus(wStatus, NULL); + ppro->icq_setstatus(wStatus, nullptr); if (ppro->m_bSsiEnabled) ppro->updateServVisibilityCode(4); } @@ -316,13 +316,13 @@ struct CPTABLE cpTable[] = { { 1257, LPGEN("Baltic") }, { 1258, LPGEN("Vietnamese") }, { 1361, LPGEN("Korean (Johab)") }, - { -1, NULL } + { -1, nullptr } }; static BOOL CALLBACK FillCpCombo(LPSTR str) { UINT i, cp = atoi(str); - for (i = 0; cpTable[i].cpName != NULL && cpTable[i].cpId != cp; i++); + for (i = 0; cpTable[i].cpName != nullptr && cpTable[i].cpId != cp; i++); if (cpTable[i].cpName) ComboBoxAddStringUtf(hCpCombo, cpTable[i].cpName, cpTable[i].cpId); @@ -537,7 +537,7 @@ int CIcqProto::OnOptionsInit(WPARAM wParam, LPARAM) odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_POPUPS); odp.pfnDlgProc = DlgProcIcqPopupOpts; odp.szGroup.w = LPGENW("Popups"); - odp.szTab.w = NULL; + odp.szTab.w = nullptr; Options_AddPage(wParam, &odp); } return 0; diff --git a/protocols/IcqOscarJ/src/icq_packet.cpp b/protocols/IcqOscarJ/src/icq_packet.cpp index 7b8c25946f..cc954bf2fe 100644 --- a/protocols/IcqOscarJ/src/icq_packet.cpp +++ b/protocols/IcqOscarJ/src/icq_packet.cpp @@ -539,7 +539,7 @@ void CIcqProto::ppackTLVStringFromDB(PBYTE *buf, size_t *buflen, const char *szS void CIcqProto::ppackTLVStringUtfFromDB(PBYTE *buf, size_t *buflen, const char *szSetting, WORD wType) { - char *str = getSettingStringUtf(NULL, szSetting, NULL); + char *str = getSettingStringUtf(NULL, szSetting, nullptr); ppackTLV(buf, buflen, wType, mir_strlen(str), (PBYTE)str); @@ -567,7 +567,7 @@ void CIcqProto::ppackTLVDateFromDB(PBYTE *buf, size_t *buflen, const char *szSet int CIcqProto::ppackTLVWordStringItemFromDB(PBYTE *buf, size_t *buflen, const char *szSetting, WORD wTypeID, WORD wTypeData, WORD wID) { char szTmp[1024]; - char *str = NULL; + char *str = nullptr; if (!getSettingStringStatic(NULL, szSetting, szTmp, sizeof(szTmp))) str = szTmp; @@ -588,7 +588,7 @@ int CIcqProto::ppackTLVWordStringItemFromDB(PBYTE *buf, size_t *buflen, const ch int CIcqProto::ppackTLVWordStringUtfItemFromDB(PBYTE *buf, size_t *buflen, const char *szSetting, WORD wTypeID, WORD wTypeData, WORD wID) { - char *str = getSettingStringUtf(NULL, szSetting, NULL); + char *str = getSettingStringUtf(NULL, szSetting, nullptr); if (str) { size_t wLen = mir_strlen(str); @@ -836,7 +836,7 @@ NextTLV: *(*ttlv + wLen) = '\0'; } else - *ttlv = NULL; + *ttlv = nullptr; } // Save type and length diff --git a/protocols/IcqOscarJ/src/icq_popups.cpp b/protocols/IcqOscarJ/src/icq_popups.cpp index b2d21dff38..1cc7bd6a30 100644 --- a/protocols/IcqOscarJ/src/icq_popups.cpp +++ b/protocols/IcqOscarJ/src/icq_popups.cpp @@ -177,19 +177,19 @@ INT_PTR CALLBACK DlgProcIcqPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR 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, NULL, FALSE)); + 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, NULL, FALSE)); + 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, NULL, FALSE)); + 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, NULL, FALSE)); + 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, NULL, FALSE)); + 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)); @@ -250,7 +250,7 @@ int CIcqProto::ShowPopupMsg(MCONTACT hContact, const char *szTitle, const char * if (!getByte("PopupsSysIcons", DEFAULT_POPUPS_SYS_ICONS)) ppd.lchIcon = IcoLib_GetIconByHandle(m_hProtoIcon); else - ppd.lchIcon = (HICON)LoadImage( NULL, rsIcon, IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); + ppd.lchIcon = (HICON)LoadImage( nullptr, rsIcon, IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); if (getByte("PopupsWinColors", DEFAULT_POPUPS_WIN_COLORS)) { ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); @@ -281,8 +281,8 @@ int CIcqProto::ShowPopupMsg(MCONTACT hContact, const char *szTitle, const char * ppd.lchIcon = ppd.lchIcon; ppd.colorBack = ppd.colorBack; ppd.colorText = ppd.colorText; - ppd.PluginWindowProc = NULL; - ppd.PluginData = NULL; + ppd.PluginWindowProc = nullptr; + ppd.PluginData = nullptr; ppd.iSeconds = ppd.iSeconds; return PUAddPopupT(&ppd); } diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp index d0bd98fab2..0a26743995 100644 --- a/protocols/IcqOscarJ/src/icq_proto.cpp +++ b/protocols/IcqOscarJ/src/icq_proto.cpp @@ -240,7 +240,7 @@ int CIcqProto::OnModulesLoaded(WPARAM, LPARAM) char pszP2PName[MAX_PATH]; char pszGroupsName[MAX_PATH]; char pszSrvGroupsName[MAX_PATH]; - char* modules[5] = { 0, 0, 0, 0, 0 }; + char* modules[5] = { nullptr, nullptr, nullptr, nullptr, nullptr }; mir_snprintf(pszP2PName, "%sP2P", m_szModuleName); mir_snprintf(pszGroupsName, "%sGroups", m_szModuleName); @@ -283,7 +283,7 @@ int CIcqProto::OnPreShutdown(WPARAM, LPARAM) MCONTACT CIcqProto::AddToList(int flags, PROTOSEARCHRESULT *psr) { - if (psr == NULL) return 0; + if (psr == nullptr) return 0; char szUid[MAX_PATH]; if (psr->cbSize == sizeof(ICQSEARCHRESULT)) { @@ -469,13 +469,13 @@ HANDLE __cdecl CIcqProto::FileAllow(MCONTACT hContact, HANDLE hTransfer, const w DWORD dwUin; uid_str szUid; if (getContactUid(hContact, &dwUin, &szUid)) - return 0; // Invalid contact + return nullptr; // Invalid contact if (icqOnline() && hContact && szPath && hTransfer) { // approve old fashioned file transfer basic_filetransfer *bft = (basic_filetransfer *)hTransfer; if (!IsValidFileTransfer(bft)) - return 0; // Invalid transfer + return nullptr; // Invalid transfer if (dwUin && bft->ft_magic == FT_MAGIC_ICQ) { filetransfer *ft = (filetransfer *)hTransfer; @@ -498,7 +498,7 @@ HANDLE __cdecl CIcqProto::FileAllow(MCONTACT hContact, HANDLE hTransfer, const w } } - return 0; // Failure + return nullptr; // Failure } @@ -719,7 +719,7 @@ void CIcqProto::CheekySearchThread(void*) HANDLE __cdecl CIcqProto::SearchBasic(const wchar_t *pszSearch) { if (mir_wstrlen(pszSearch) == 0) - return 0; + return nullptr; char pszUIN[255]; int nHandle = 0; @@ -746,7 +746,7 @@ HANDLE __cdecl CIcqProto::SearchBasic(const wchar_t *pszSearch) cheekySearchId = GenerateCookie(0); cheekySearchUin = dwUin; cheekySearchUid = null_strdup(pszUIN); - ForkThread(&CIcqProto::CheekySearchThread, 0); // The caller needs to get this return value before the results + ForkThread(&CIcqProto::CheekySearchThread, nullptr); // The caller needs to get this return value before the results nHandle = cheekySearchId; } else if (icqOnline()) { @@ -758,7 +758,7 @@ HANDLE __cdecl CIcqProto::SearchBasic(const wchar_t *pszSearch) } // Failure - return 0; + return nullptr; } //////////////////////////////////////////////////////////////////////////////////////// @@ -781,7 +781,7 @@ HANDLE __cdecl CIcqProto::SearchByEmail(const wchar_t *email) return (HANDLE)dwSecId; } - return 0; // Failure + return nullptr; // Failure } //////////////////////////////////////////////////////////////////////////////////////// @@ -806,7 +806,7 @@ HANDLE __cdecl CIcqProto::SearchByName(const wchar_t *nick, const wchar_t *first } } - return 0; // Failure + return nullptr; // Failure } @@ -815,7 +815,7 @@ HWND __cdecl CIcqProto::CreateExtendedSearchUI(HWND parent) if (parent && hInst) return CreateDialog(hInst, MAKEINTRESOURCE(IDD_ICQADVANCEDSEARCH), parent, AdvancedSearchDlgProc); - return NULL; // Failure + return nullptr; // Failure } HWND __cdecl CIcqProto::SearchAdvanced(HWND hwndDlg) @@ -831,7 +831,7 @@ HWND __cdecl CIcqProto::SearchAdvanced(HWND hwndDlg) } } - return NULL; // Failure + return nullptr; // Failure } @@ -909,7 +909,7 @@ int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int, int nContacts, MCONT dwCookie = ReportGenericSendError(hContact, ACKTYPE_CONTACTS, "Bad data (internal error #1)"); else { // OK if (CheckContactCapabilities(hContact, CAPF_CONTACTS) && wRecipientStatus != ID_STATUS_OFFLINE) { // Use the new format if possible - struct icq_contactsend_s* contacts = NULL; + struct icq_contactsend_s* contacts = nullptr; // Format the data part and the names part // This is kinda messy, but there is no simple way to do it. First @@ -926,7 +926,7 @@ int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int, int nContacts, MCONT break; // Abort if a non icq contact is found if (getContactUid(hContactsList[i], &contacts[i].uin, &szContactUid)) break; // Abort if invalid contact - contacts[i].uid = contacts[i].uin ? NULL : null_strdup(szContactUid); + contacts[i].uid = contacts[i].uin ? nullptr : null_strdup(szContactUid); contacts[i].szNick = NickFromHandleUtf(hContactsList[i]); nDataLen += getUIDLen(contacts[i].uin, contacts[i].uid) + 4; nNamesLen += mir_strlen(contacts[i].szNick) + 8; @@ -1002,7 +1002,7 @@ int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int, int nContacts, MCONT // This will stop the message dialog from waiting for the real message delivery ack if (pCookieData->nAckType == ACKTYPE_NONE) { - SendProtoAck(hContact, dwCookie, ACKRESULT_SUCCESS, ACKTYPE_CONTACTS, NULL); + SendProtoAck(hContact, dwCookie, ACKRESULT_SUCCESS, ACKTYPE_CONTACTS, nullptr); // We need to free this here since we will never see the real ack // The actual cookie value will still have to be returned to the message dialog though ReleaseCookie(dwCookie); @@ -1023,7 +1023,7 @@ int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int, int nContacts, MCONT else if (dwUin) { // old format is only understood by ICQ clients char szContactUin[UINMAXLEN]; char szCount[17]; - struct icq_contactsend_s* contacts = NULL; + struct icq_contactsend_s* contacts = nullptr; uid_str szContactUid; int i; @@ -1039,7 +1039,7 @@ int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int, int nContacts, MCONT break; // Abort if a non icq contact is found if (getContactUid(hContactsList[i], &contacts[i].uin, &szContactUid)) break; // Abort if invalid contact - contacts[i].uid = contacts[i].uin ? NULL : null_strdup(szContactUid); + contacts[i].uid = contacts[i].uin ? nullptr : null_strdup(szContactUid); contacts[i].szNick = NickFromHandle(hContactsList[i]); // Compute this contact's length nBodyLength += getUIDLen(contacts[i].uin, contacts[i].uid) + 1; @@ -1081,7 +1081,7 @@ int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int, int nContacts, MCONT cookie_message_data *pCookieData = CreateMessageCookieData(MTYPE_CONTACTS, hContact, dwUin, TRUE); if (m_bDCMsgEnabled && IsDirectConnectionOpen(hContact, DIRECTCONN_STANDARD, 0)) { - int iRes = icq_SendDirectMessage(hContact, pBody, nBodyLength, pCookieData, NULL); + int iRes = icq_SendDirectMessage(hContact, pBody, nBodyLength, pCookieData, nullptr); if (iRes) { SAFE_FREE((void**)&pBody); return iRes; // we succeded, return @@ -1103,11 +1103,11 @@ int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int, int nContacts, MCONT else wPriority = 0x0021; - dwCookie = icq_SendChannel2Message(dwUin, hContact, pBody, nBodyLength, wPriority, pCookieData, NULL); + dwCookie = icq_SendChannel2Message(dwUin, hContact, pBody, nBodyLength, wPriority, pCookieData, nullptr); // This will stop the message dialog from waiting for the real message delivery ack if (pCookieData->nAckType == ACKTYPE_NONE) { - SendProtoAck(hContact, dwCookie, ACKRESULT_SUCCESS, ACKTYPE_CONTACTS, NULL); + SendProtoAck(hContact, dwCookie, ACKRESULT_SUCCESS, ACKTYPE_CONTACTS, nullptr); // We need to free this here since we will never see the real ack // The actual cookie value will still have to be returned to the message dialog though ReleaseCookie(dwCookie); @@ -1133,13 +1133,13 @@ int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int, int nContacts, MCONT HANDLE __cdecl CIcqProto::SendFile(MCONTACT hContact, const wchar_t* szDescription, wchar_t** ppszFiles) { if (!icqOnline()) - return 0; + return nullptr; if (hContact && szDescription && ppszFiles) { DWORD dwUin; uid_str szUid; if (getContactUid(hContact, &dwUin, &szUid)) - return 0; // Invalid contact + return nullptr; // Invalid contact if (getContactStatus(hContact) != ID_STATUS_OFFLINE) { if (CheckContactCapabilities(hContact, CAPF_OSCAR_FILE)) @@ -1162,7 +1162,7 @@ HANDLE __cdecl CIcqProto::SendFile(MCONTACT hContact, const wchar_t* szDescripti ft->pszFiles = (char **)SAFE_MALLOC(sizeof(char *)* ft->dwFileCount); ft->dwTotalSize = 0; for (i = 0; i < (int)ft->dwFileCount; i++) { - ft->pszFiles[i] = (ppszFiles[i]) ? make_utf8_string(ppszFiles[i]) : NULL; + ft->pszFiles[i] = (ppszFiles[i]) ? make_utf8_string(ppszFiles[i]) : nullptr; if (_wstat(ppszFiles[i], &statbuf)) debugLogA("IcqSendFile() was passed invalid filename(s)"); @@ -1175,7 +1175,7 @@ HANDLE __cdecl CIcqProto::SendFile(MCONTACT hContact, const wchar_t* szDescripti ft->fileId = -1; ft->iCurrentFile = 0; ft->dwCookie = AllocateCookie(CKT_FILE, 0, hContact, ft); - ft->hConnection = NULL; + ft->hConnection = nullptr; // Send file transfer request debugLogA("Init file send"); @@ -1219,7 +1219,7 @@ HANDLE __cdecl CIcqProto::SendFile(MCONTACT hContact, const wchar_t* szDescripti } } - return 0; // Failure + return nullptr; // Failure } @@ -1228,7 +1228,7 @@ HANDLE __cdecl CIcqProto::SendFile(MCONTACT hContact, const wchar_t* szDescripti int __cdecl CIcqProto::SendMsg(MCONTACT hContact, int, const char* pszSrc) { - if (hContact == NULL || pszSrc == NULL) + if (hContact == NULL || pszSrc == nullptr) return NULL; DWORD dwCookie; @@ -1262,7 +1262,7 @@ int __cdecl CIcqProto::SendMsg(MCONTACT hContact, int, const char* pszSrc) if (dwUin && m_bDCMsgEnabled && IsDirectConnectionOpen(hContact, DIRECTCONN_STANDARD, 0)) { // send thru direct char *dc_msg = puszText; char *dc_cap = plain_ascii ? NULL : CAP_UTF8MSGS; - char *szUserAnsi = NULL; + char *szUserAnsi = nullptr; if (!plain_ascii && oldAnsi) { szUserAnsi = ConvertMsgToUserSpecificAnsi(hContact, puszText); @@ -1296,7 +1296,7 @@ int __cdecl CIcqProto::SendMsg(MCONTACT hContact, int, const char* pszSrc) bNeedFreeU = 1; } - WCHAR *pwszText = plain_ascii ? NULL : make_unicode_string(puszText); + WCHAR *pwszText = plain_ascii ? nullptr : make_unicode_string(puszText); if ((plain_ascii ? mir_strlen(puszText) : mir_wstrlen(pwszText) * sizeof(WCHAR)) > MAX_MESSAGESNACSIZE) { // max length check // TLV(2) is currently limited to 0xA00 bytes in online mode // only limit to not get disconnected, all other will be handled by error 0x0A dwCookie = ReportGenericSendError(hContact, ACKTYPE_MESSAGE, "The message could not be delivered, it is too long."); @@ -1329,7 +1329,7 @@ int __cdecl CIcqProto::SendMsg(MCONTACT hContact, int, const char* pszSrc) // This will stop the message dialog from waiting for the real message delivery ack if (pCookieData && pCookieData->nAckType == ACKTYPE_NONE) { - SendProtoAck(hContact, dwCookie, ACKRESULT_SUCCESS, ACKTYPE_MESSAGE, NULL); + SendProtoAck(hContact, dwCookie, ACKRESULT_SUCCESS, ACKTYPE_MESSAGE, nullptr); // We need to free this here since we will never see the real ack // The actual cookie value will still have to be returned to the message dialog though ReleaseCookie(dwCookie); @@ -1347,11 +1347,11 @@ int __cdecl CIcqProto::SendMsg(MCONTACT hContact, int, const char* pszSrc) int __cdecl CIcqProto::SendUrl(MCONTACT hContact, int, const char* url) { - if (hContact == NULL || url == NULL) + if (hContact == NULL || url == nullptr) return 0; DWORD dwUin; - if (getContactUid(hContact, &dwUin, NULL)) // Invalid contact + if (getContactUid(hContact, &dwUin, nullptr)) // Invalid contact return ReportGenericSendError(hContact, ACKTYPE_URL, "The receiver has an invalid user ID."); WORD wRecipientStatus = getContactStatus(hContact); @@ -1376,7 +1376,7 @@ int __cdecl CIcqProto::SendUrl(MCONTACT hContact, int, const char* url) mir_strcpy(szBody + nDescLen + 1, url); if (m_bDCMsgEnabled && IsDirectConnectionOpen(hContact, DIRECTCONN_STANDARD, 0)) { - int iRes = icq_SendDirectMessage(hContact, szBody, nBodyLen, pCookieData, NULL); + int iRes = icq_SendDirectMessage(hContact, szBody, nBodyLen, pCookieData, nullptr); if (iRes) return iRes; // we succeded, return } @@ -1394,11 +1394,11 @@ int __cdecl CIcqProto::SendUrl(MCONTACT hContact, int, const char* url) else wPriority = 0x0021; - DWORD dwCookie = icq_SendChannel2Message(dwUin, hContact, szBody, nBodyLen, wPriority, pCookieData, NULL); + DWORD dwCookie = icq_SendChannel2Message(dwUin, hContact, szBody, nBodyLen, wPriority, pCookieData, nullptr); // This will stop the message dialog from waiting for the real message delivery ack if (pCookieData->nAckType == ACKTYPE_NONE) { - SendProtoAck(hContact, dwCookie, ACKRESULT_SUCCESS, ACKTYPE_URL, NULL); + SendProtoAck(hContact, dwCookie, ACKRESULT_SUCCESS, ACKTYPE_URL, nullptr); // We need to free this here since we will never see the real ack // The actual cookie value will still have to be returned to the message dialog though ReleaseCookie(dwCookie); @@ -1459,15 +1459,15 @@ int __cdecl CIcqProto::SetApparentMode(MCONTACT hContact, int mode) char* CIcqProto::PrepareStatusNote(int nStatus) { - char *szStatusNote = NULL; + char *szStatusNote = nullptr; BYTE bXStatus = getContactXStatus(NULL); // use custom status message as status note if (bXStatus) - szStatusNote = getSettingStringUtf(NULL, DBSETTING_XSTATUS_MSG, NULL); + szStatusNote = getSettingStringUtf(NULL, DBSETTING_XSTATUS_MSG, nullptr); // get standard status message (no custom status defined) - if (szStatusNote == NULL) { + if (szStatusNote == nullptr) { mir_cslock l(m_modeMsgsMutex); char **pszStatusNote = MirandaStatusToAwayMsg(nStatus); @@ -1475,7 +1475,7 @@ char* CIcqProto::PrepareStatusNote(int nStatus) szStatusNote = null_strdup(*pszStatusNote); } - if (szStatusNote == NULL) // nothing available. set empty status note + if (szStatusNote == nullptr) // nothing available. set empty status note szStatusNote = null_strdup(""); return szStatusNote; @@ -1533,7 +1533,7 @@ int __cdecl CIcqProto::SetStatus(int iNewStatus) m_dwLocalUIN = getContactUin(NULL); if (m_dwLocalUIN == 0) { SetCurrentStatus(ID_STATUS_OFFLINE); - ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID); + ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, LOGINERR_BADUSERID); icq_LogMessage(LOG_FATAL, LPGEN("You have not entered an ICQ number.\nConfigure this in Options -> Network -> ICQ and try again.")); return 0; } @@ -1585,7 +1585,7 @@ int __cdecl CIcqProto::SetStatus(int iNewStatus) if (pszStatusNote) icq_sendSetAimAwayMsgServ(*pszStatusNote); else // clear the away message - icq_sendSetAimAwayMsgServ(NULL); + icq_sendSetAimAwayMsgServ(nullptr); } } @@ -1630,10 +1630,10 @@ HANDLE __cdecl CIcqProto::GetAwayMsg(MCONTACT hContact) DWORD dwUin; uid_str szUID; if (getContactUid(hContact, &dwUin, &szUID)) - return 0; // Invalid contact + return nullptr; // Invalid contact if (!dwUin || !CheckContactCapabilities(hContact, CAPF_STATUS_MESSAGES)) { // No individual status messages, check if the contact has Status Note, if yes give it - char *szStatusNote = getSettingStringUtf(hContact, DBSETTING_STATUS_NOTE, NULL); + char *szStatusNote = getSettingStringUtf(hContact, DBSETTING_STATUS_NOTE, nullptr); if (mir_strlen(szStatusNote) > 0) { // Give Status Note status_message_thread_data *pThreadData = (status_message_thread_data*)SAFE_MALLOC(sizeof(status_message_thread_data)); @@ -1649,7 +1649,7 @@ HANDLE __cdecl CIcqProto::GetAwayMsg(MCONTACT hContact) } if (!icqOnline()) - return 0; + return nullptr; WORD wStatus = getContactStatus(hContact); @@ -1701,7 +1701,7 @@ HANDLE __cdecl CIcqProto::GetAwayMsg(MCONTACT hContact) return (HANDLE)icq_sendGetAimAwayMsgServ(hContact, szUID, MTYPE_AUTOAWAY); } - return 0; // Failure + return nullptr; // Failure } @@ -1739,7 +1739,7 @@ int __cdecl CIcqProto::SetAwayMsg(int status, const wchar_t* msg) // Set new message *ppszMsg = szNewUtf; - szNewUtf = NULL; + szNewUtf = nullptr; if ((m_iStatus == status) && icqOnline()) { // update current status note char *szNote = *ppszMsg ? *ppszMsg : ""; diff --git a/protocols/IcqOscarJ/src/icq_rates.cpp b/protocols/IcqOscarJ/src/icq_rates.cpp index eb0f85d46d..f319afd1b5 100644 --- a/protocols/IcqOscarJ/src/icq_rates.cpp +++ b/protocols/IcqOscarJ/src/icq_rates.cpp @@ -146,7 +146,7 @@ rates_group* rates::getGroup(WORD wGroup) if (this && wGroup && wGroup <= nGroups) return &groups[wGroup - 1]; - return NULL; + return nullptr; } int rates::getNextRateLevel(WORD wGroup) @@ -236,7 +236,7 @@ void rates::initAckPacket(icq_packet *pPacket) // Rate Level 2 Management ///////////////////////////// -rates_queue_item::rates_queue_item(CIcqProto *ppro, WORD wGroup) : bCreated(FALSE), dwUin(0), szUid(NULL) +rates_queue_item::rates_queue_item(CIcqProto *ppro, WORD wGroup) : bCreated(FALSE), dwUin(0), szUid(nullptr) { this->ppro = ppro; this->wGroup = wGroup; @@ -263,7 +263,7 @@ rates_queue_item* rates_queue_item::copyItem(rates_queue_item *pDest) pDest->hContact = hContact; pDest->dwUin = dwUin; - pDest->szUid = dwUin ? null_strdup(szUid) : NULL; + pDest->szUid = dwUin ? null_strdup(szUid) : nullptr; pDest->bCreated = TRUE; return pDest; @@ -419,7 +419,7 @@ void rates_queue::putItem(rates_queue_item *pItem, int nMinDelay) int CIcqProto::handleRateItem(rates_queue_item *item, int nQueueType, int nMinDelay, BOOL bAllowDelay) { - rates_queue *pQueue = NULL; + rates_queue *pQueue = nullptr; { mir_cslock rlck(m_ratesMutex); switch (nQueueType) { diff --git a/protocols/IcqOscarJ/src/icq_server.cpp b/protocols/IcqOscarJ/src/icq_server.cpp index 10f03bfa2d..95303e5619 100644 --- a/protocols/IcqOscarJ/src/icq_server.cpp +++ b/protocols/IcqOscarJ/src/icq_server.cpp @@ -45,7 +45,7 @@ void __cdecl CIcqProto::ServerThread(serverthread_start_info *infoParam) // store server port info.wServerPort = infoParam->nloc.wPort; - srand(time(NULL)); + srand(time(nullptr)); ResetSettingsOnConnect(); @@ -57,13 +57,13 @@ void __cdecl CIcqProto::ServerThread(serverthread_start_info *infoParam) if (m_bGatewayMode) nloc.flags |= NLOCF_HTTPGATEWAY; - hServerConn = NetLib_OpenConnection(m_hNetlibUser, NULL, &nloc); + hServerConn = NetLib_OpenConnection(m_hNetlibUser, nullptr, &nloc); SAFE_FREE((void**)&nloc.szHost); SAFE_FREE((void**)&infoParam); if (hServerConn && m_bSecureConnection) { - if (!Netlib_StartSsl(hServerConn, 0)) { + if (!Netlib_StartSsl(hServerConn, nullptr)) { icq_LogMessage(LOG_ERROR, LPGEN("Unable to connect to ICQ login server, SSL could not be negotiated")); SetCurrentStatus(ID_STATUS_OFFLINE); NetLib_CloseConnection(&hServerConn, TRUE); @@ -73,7 +73,7 @@ void __cdecl CIcqProto::ServerThread(serverthread_start_info *infoParam) } // Login error - if (hServerConn == NULL) { + if (hServerConn == nullptr) { DWORD dwError = GetLastError(); SetCurrentStatus(ID_STATUS_OFFLINE); @@ -142,7 +142,7 @@ void __cdecl CIcqProto::ServerThread(serverthread_start_info *infoParam) CheckKeepAlive(&info); packetRecv.bytesUsed = handleServerPackets(packetRecv.buffer, packetRecv.bytesAvailable, &info); } - serverThreadHandle = NULL; + serverThreadHandle = nullptr; // Time to shutdown debugLogA("Closing server connections..."); @@ -153,7 +153,7 @@ void __cdecl CIcqProto::ServerThread(serverthread_start_info *infoParam) // Close DC port Netlib_CloseHandle(info.hDirectBoundPort); - info.hDirectBoundPort = NULL; + info.hDirectBoundPort = nullptr; // disable auto info-update thread icq_EnableUserLookup(FALSE); @@ -199,9 +199,9 @@ void __cdecl CIcqProto::ServerThread(serverthread_start_info *infoParam) // release rates queues { mir_cslock l(m_ratesMutex); - delete m_ratesQueue_Request; m_ratesQueue_Request = NULL; - delete m_ratesQueue_Response; m_ratesQueue_Response = NULL; - delete m_rates; m_rates = NULL; + delete m_ratesQueue_Request; m_ratesQueue_Request = nullptr; + delete m_ratesQueue_Response; m_ratesQueue_Response = nullptr; + delete m_rates; m_rates = nullptr; } FlushServerIDs(); // clear server IDs list @@ -221,7 +221,7 @@ void CIcqProto::icq_serverDisconnect() if (serverThreadHandle) { debugLogA("Closing server thread handle: %08p", serverThreadHandle); CloseHandle(serverThreadHandle); - serverThreadHandle = NULL; + serverThreadHandle = nullptr; } SetCurrentStatus(ID_STATUS_OFFLINE); diff --git a/protocols/IcqOscarJ/src/icq_servlist.cpp b/protocols/IcqOscarJ/src/icq_servlist.cpp index 61be92b29b..11291eb889 100644 --- a/protocols/IcqOscarJ/src/icq_servlist.cpp +++ b/protocols/IcqOscarJ/src/icq_servlist.cpp @@ -74,7 +74,7 @@ void __cdecl CIcqProto::servlistQueueThread(void *param) mir_cslockfull l(servlistQueueMutex); while (servlistQueueCount) { - ssiqueueditems* pItem = NULL; + ssiqueueditems* pItem = nullptr; int bItemDouble; WORD wItemAction; icq_packet groupPacket = { 0 }; @@ -84,7 +84,7 @@ void __cdecl CIcqProto::servlistQueueThread(void *param) // first check if the state is calm while (*queueState) { int i; - time_t tNow = time(NULL); + time_t tNow = time(nullptr); int bFound = FALSE; for (i = 0; i < servlistQueueCount; i++) { // check if we do not have some expired items to handle, otherwise keep sleeping @@ -251,7 +251,7 @@ void __cdecl CIcqProto::servlistQueueThread(void *param) // clean-up thread CloseHandle(servlistQueueThreadHandle); - servlistQueueThreadHandle = NULL; + servlistQueueThreadHandle = nullptr; debugLogA("Server-List: Update Board ending."); } @@ -262,7 +262,7 @@ void CIcqProto::servlistQueueAddGroupItem(servlistgroupitem* pGroupItem, int dwT // add the packet to queue DWORD dwMark = pGroupItem->dwOperation & SSOF_GROUPINGMASK; - ssiqueueditems* pItem = NULL; + ssiqueueditems* pItem = nullptr; // try to find compatible item for (int i = 0; i < servlistQueueCount; i++) { @@ -271,7 +271,7 @@ void CIcqProto::servlistQueueAddGroupItem(servlistgroupitem* pGroupItem, int dwT for (int j = 0; j < pItem->nItems; j++) if (pItem->pItems[j]->cookie->wContactId == pGroupItem->cookie->wContactId && pItem->pItems[j]->cookie->wGroupId == pGroupItem->cookie->wGroupId) { - pItem = NULL; + pItem = nullptr; break; } @@ -285,7 +285,7 @@ void CIcqProto::servlistQueueAddGroupItem(servlistgroupitem* pGroupItem, int dwT } if (!pItem) { // compatible item was not found, create new one, add to queue pItem = (ssiqueueditems*)SAFE_MALLOC(sizeof(ssiqueueditems)); - pItem->tAdded = time(NULL); + pItem->tAdded = time(nullptr); pItem->dwTimeout = dwTimeout; if (servlistQueueCount == servlistQueueSize) { // resize the queue - it is too small @@ -307,7 +307,7 @@ void CIcqProto::servlistQueueAddGroupItem(servlistgroupitem* pGroupItem, int dwT // wake up board thread (keep sleeping or start new one) if (!servlistQueueThreadHandle) // create new board thread - servlistQueueThreadHandle = ForkThreadEx(&CIcqProto::servlistQueueThread, &servlistQueueState, 0); + servlistQueueThreadHandle = ForkThreadEx(&CIcqProto::servlistQueueThread, &servlistQueueState, nullptr); else // signal thread, that queue was changed during sleep servlistQueueState = TRUE; } @@ -333,7 +333,7 @@ void CIcqProto::servlistPostPacket(icq_packet* packet, DWORD dwCookie, DWORD dwO if (servlistHandlePrimitives(dwOperation)) return; - if (!FindCookie(dwCookie, NULL, (void**)&pCookie)) + if (!FindCookie(dwCookie, nullptr, (void**)&pCookie)) return; // invalid cookie if (dwOperation & SSOF_SEND_DIRECTLY) { // send directly - this is for some special cases @@ -367,7 +367,7 @@ void CIcqProto::servlistPostPacketDouble(icq_packet* packet1, DWORD dwCookie, DW if (servlistHandlePrimitives(dwOperation)) return; - if (!FindCookie(dwCookie, NULL, (void**)&pCookie)) + if (!FindCookie(dwCookie, nullptr, (void**)&pCookie)) return; // invalid cookie if (dwOperation & SSOF_SEND_DIRECTLY) { // send directly - this is for some special cases @@ -408,7 +408,7 @@ void CIcqProto::servlistProcessLogin() // if the server-list queue contains items and thread is not running, start it if (servlistQueueCount && !servlistQueueThreadHandle) - servlistQueueThreadHandle = ForkThreadEx(&CIcqProto::servlistQueueThread, &servlistQueueState, 0); + servlistQueueThreadHandle = ForkThreadEx(&CIcqProto::servlistQueueThread, &servlistQueueState, nullptr); } // HERE ENDS SERVER-LIST UPDATE BOARD IMPLEMENTATION // @@ -453,7 +453,7 @@ servlistpendingitem* CIcqProto::servlistPendingRemoveItem(int nType, MCONTACT hC { // unregister pending item, trigger pending operations int iItem; - servlistpendingitem *pItem = NULL; + servlistpendingitem *pItem = nullptr; mir_cslock l(servlistMutex); @@ -504,11 +504,11 @@ void CIcqProto::servlistPendingAddContactOperation(MCONTACT hContact, LPARAM par // add postponed operation (add contact, update contact, regroup resume, etc.) // - after contact is added int iItem; - servlistpendingitem *pItem = NULL; + servlistpendingitem *pItem = nullptr; mir_cslock l(servlistMutex); - if ((iItem = servlistPendingFindItem(ITEM_PENDING_CONTACT, hContact, NULL)) != -1) + if ((iItem = servlistPendingFindItem(ITEM_PENDING_CONTACT, hContact, nullptr)) != -1) pItem = servlistPendingList[iItem]; if (pItem) { @@ -526,7 +526,7 @@ void CIcqProto::servlistPendingAddGroupOperation(const char *pszGroup, LPARAM pa { // add postponed operation - after group is added int iItem; - servlistpendingitem *pItem = NULL; + servlistpendingitem *pItem = nullptr; mir_cslock l(servlistMutex); @@ -547,11 +547,11 @@ void CIcqProto::servlistPendingAddGroupOperation(const char *pszGroup, LPARAM pa int CIcqProto::servlistPendingAddContact(MCONTACT hContact, WORD wContactID, WORD wGroupID, LPARAM param, PENDING_CONTACT_CALLBACK callback, int bDoInline, LPARAM operationParam, PENDING_CONTACT_CALLBACK operationCallback) { int iItem; - servlistpendingitem *pItem = NULL; + servlistpendingitem *pItem = nullptr; mir_cslockfull l(servlistMutex); - if ((iItem = servlistPendingFindItem(ITEM_PENDING_CONTACT, hContact, NULL)) != -1) + if ((iItem = servlistPendingFindItem(ITEM_PENDING_CONTACT, hContact, nullptr)) != -1) pItem = servlistPendingList[iItem]; if (pItem) { @@ -588,7 +588,7 @@ int CIcqProto::servlistPendingAddContact(MCONTACT hContact, WORD wContactID, WOR int CIcqProto::servlistPendingAddGroup(const char *pszGroup, WORD wGroupID, LPARAM param, PENDING_GROUP_CALLBACK callback, int bDoInline, LPARAM operationParam, PENDING_GROUP_CALLBACK operationCallback) { int iItem; - servlistpendingitem *pItem = NULL; + servlistpendingitem *pItem = nullptr; mir_cslockfull l(servlistMutex); @@ -629,7 +629,7 @@ void CIcqProto::servlistPendingRemoveContact(MCONTACT hContact, WORD wContactID, { debugLogA("Server-List: %s contact %x operation.", (nResult != PENDING_RESULT_PURGE) ? "Ending" : "Purging", hContact); - servlistpendingitem *pItem = servlistPendingRemoveItem(ITEM_PENDING_CONTACT, hContact, NULL); + servlistpendingitem *pItem = servlistPendingRemoveItem(ITEM_PENDING_CONTACT, hContact, nullptr); if (pItem) { // process pending operations if (pItem->operations) { @@ -822,8 +822,8 @@ static int GroupReserveIdsEnumProc(const char *szSetting, LPARAM lParam) if (db_get_static_utf(0, param->szModule, szSetting, val, MAX_PATH)) return 0; // we failed also, invalid setting - param->ppro->ReserveServerID((WORD)strtoul(szSetting, NULL, 0x10), SSIT_GROUP, 0); - param->ppro->debugLogA("Loaded group %u:'%s'", strtoul(szSetting, NULL, 0x10), val); + param->ppro->ReserveServerID((WORD)strtoul(szSetting, nullptr, 0x10), SSIT_GROUP, 0); + param->ppro->debugLogA("Loaded group %u:'%s'", strtoul(szSetting, nullptr, 0x10), val); } return 0; } @@ -908,7 +908,7 @@ void CIcqProto::LoadServerIDs() void CIcqProto::StoreServerIDs() /// TODO: allow delayed { - BYTE *pUnhandled = NULL; + BYTE *pUnhandled = nullptr; size_t cbUnhandled = 0; mir_cslockfull l(servlistMutex); @@ -1010,7 +1010,7 @@ DWORD CIcqProto::icq_sendServerItem(DWORD dwCookie, WORD wAction, WORD wGroupId, DWORD CIcqProto::icq_sendServerContact(MCONTACT hContact, DWORD dwCookie, WORD wAction, WORD wGroupId, WORD wContactId, DWORD dwOperation, DWORD dwTimeout, void **doubleObject) { - BYTE *pData = NULL, *pMetaToken = NULL, *pMetaTime = NULL; + BYTE *pData = nullptr, *pMetaToken = nullptr, *pMetaTime = nullptr; int nDataLen = 0, nMetaTokenLen = 0, nMetaTimeLen = 0; // Prepare UID @@ -1022,8 +1022,8 @@ DWORD CIcqProto::icq_sendServerContact(MCONTACT hContact, DWORD dwCookie, WORD w } BYTE bAuth = getByte(hContact, "Auth", 0); - char *szNick = getSettingStringUtf(hContact, "CList", "MyHandle", NULL); - char *szNote = getSettingStringUtf(hContact, "UserInfo", "MyNotes", NULL); + char *szNick = getSettingStringUtf(hContact, "CList", "MyHandle", nullptr); + char *szNote = getSettingStringUtf(hContact, "UserInfo", "MyNotes", nullptr); DBVARIANT dbv; if (!getSetting(hContact, DBSETTING_METAINFO_TOKEN, &dbv)) { @@ -1104,7 +1104,7 @@ DWORD CIcqProto::icq_sendServerContact(MCONTACT hContact, DWORD dwCookie, WORD w DWORD CIcqProto::icq_sendSimpleItem(DWORD dwCookie, WORD wAction, DWORD dwUin, char* szUID, WORD wGroupId, WORD wItemId, WORD wItemType, DWORD dwOperation, DWORD dwTimeout) { // for privacy items - return icq_sendServerItem(dwCookie, wAction, wGroupId, wItemId, strUID(dwUin, szUID), NULL, 0, wItemType, dwOperation, dwTimeout, NULL); + return icq_sendServerItem(dwCookie, wAction, wGroupId, wItemId, strUID(dwUin, szUID), nullptr, 0, wItemType, dwOperation, dwTimeout, nullptr); } DWORD CIcqProto::icq_sendServerGroup(DWORD dwCookie, WORD wAction, WORD wGroupId, const char *szName, void *pContent, int cbContent, DWORD dwOperationFlags) @@ -1129,7 +1129,7 @@ DWORD CIcqProto::icq_sendServerGroup(DWORD dwCookie, WORD wAction, WORD wGroupId if (wTLVlen) packTLV(&pBuffer, SSI_TLV_SUBITEMS, cbContent, (LPBYTE)pContent); // Groups TLV - return icq_sendServerItem(dwCookie, wAction, wGroupId, 0, szName, pBuffer.pData, wTLVlen, SSI_ITEM_GROUP, SSOP_GROUP_ACTION | dwOperationFlags, 400, NULL); + return icq_sendServerItem(dwCookie, wAction, wGroupId, 0, szName, pBuffer.pData, wTLVlen, SSI_ITEM_GROUP, SSOP_GROUP_ACTION | dwOperationFlags, 400, nullptr); } DWORD CIcqProto::icq_modifyServerPrivacyItem(MCONTACT hContact, DWORD dwUin, char *szUid, WORD wAction, DWORD dwOperation, WORD wItemId, WORD wType) @@ -1196,7 +1196,7 @@ void CIcqProto::FlushSrvGroupsCache() // Look thru DB and collect all ContactIDs from a group void* CIcqProto::collectBuddyGroup(WORD wGroupID, int *count) { - WORD* buf = NULL; + WORD* buf = nullptr; int cnt = 0; MCONTACT hContact; WORD wItemID; @@ -1226,7 +1226,7 @@ void* CIcqProto::collectBuddyGroup(WORD wGroupID, int *count) // Look thru DB and collect all GroupIDs void* CIcqProto::collectGroups(int *count) { - WORD* buf = NULL; + WORD* buf = nullptr; int cnt = 0; int i; WORD wGroupID; @@ -1271,7 +1271,7 @@ void CIcqProto::removeGroupPathLinks(WORD wGroupID) mir_snprintf(szModule, "%sGroups", m_szModuleName); - pars[0] = NULL; + pars[0] = nullptr; pars[1] = (char*)wGroupID; pars[2] = szModule; @@ -1296,7 +1296,7 @@ char* CIcqProto::getServListGroupName(WORD wGroupID) if (!wGroupID) { debugLogA("Warning: Cannot get group name (Group ID missing)!"); - return NULL; + return nullptr; } mir_snprintf(szModule, "%sSrvGroups", m_szModuleName); @@ -1305,10 +1305,10 @@ char* CIcqProto::getServListGroupName(WORD wGroupID) if (!CheckServerID(wGroupID, 0)) { // check if valid id, if not give empty and remove debugLogA("Removing group %u from cache...", wGroupID); db_unset(NULL, szModule, szGroup); - return NULL; + return nullptr; } - return getSettingStringUtf(NULL, szModule, szGroup, NULL); + return getSettingStringUtf(NULL, szModule, szGroup, nullptr); } void CIcqProto::setServListGroupName(WORD wGroupID, const char *szGroupName) @@ -1371,7 +1371,7 @@ int CIcqProto::getCListGroupExists(const char *szGroup) if (make_unicode_string_static(szGroup, tszGroup, size)) for (int i = 1; TRUE; i++) { - wchar_t *tszGroupName = (wchar_t*)Clist_GroupGetName(i, NULL); + wchar_t *tszGroupName = (wchar_t*)Clist_GroupGetName(i, nullptr); if (!tszGroupName) break; @@ -1435,7 +1435,7 @@ int CIcqProto::getServListGroupLevel(WORD wGroupId) // demangle group path char *CIcqProto::getServListGroupCListPath(WORD wGroupId) { - char *szGroup = NULL; + char *szGroup = nullptr; if (szGroup = getServListGroupName(wGroupId)) { // this groupid is valid if (!m_bSsiSimpleGroups) @@ -1485,7 +1485,7 @@ char *CIcqProto::getServListGroupCListPath(WORD wGroupId) return szGroup; } } - return NULL; + return nullptr; } @@ -1494,7 +1494,7 @@ static int SrvGroupNamesEnumProc(const char *szSetting, LPARAM lParam) // check server-group cache item const char **params = (const char**)lParam; CIcqProto *ppro = (CIcqProto*)params[0]; - char *szGroupName = ppro->getSettingStringUtf(NULL, params[3], szSetting, NULL); + char *szGroupName = ppro->getSettingStringUtf(NULL, params[3], szSetting, nullptr); if (!mir_strcmp(szGroupName, params[2])) params[1] = szSetting; // do not need the real value, just arbitrary non-NULL @@ -1510,7 +1510,7 @@ char* CIcqProto::getServListUniqueGroupName(const char *szGroupName, int bAlloce char *pars[4]; int uniqueID = 1; char *szGroupNameBase = (char*)szGroupName; - char *szNewGroupName = NULL; + char *szNewGroupName = nullptr; if (!bAlloced) szGroupNameBase = null_strdup(szGroupName); @@ -1520,7 +1520,7 @@ char* CIcqProto::getServListUniqueGroupName(const char *szGroupName, int bAlloce do { pars[0] = (char*)this; - pars[1] = NULL; + pars[1] = nullptr; pars[2] = szNewGroupName ? szNewGroupName : szGroupNameBase; pars[3] = szModule; db_enum_settings(NULL, &SrvGroupNamesEnumProc, szModule, pars); @@ -1618,7 +1618,7 @@ int CIcqProto::servlistCreateGroup_gotParentGroup(const char *szGroup, WORD wGro ack->dwAction = SSA_GROUP_ADD; dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_ADDTOLIST, 0, ack); - icq_sendServerGroup(dwCookie, ICQ_LISTS_ADDTOLIST, ack->wGroupId, szSubGroupItem, NULL, 0, SSOF_BEGIN_OPERATION); + icq_sendServerGroup(dwCookie, ICQ_LISTS_ADDTOLIST, ack->wGroupId, szSubGroupItem, nullptr, 0, SSOF_BEGIN_OPERATION); return CALLBACK_RESULT_CONTINUE; } SAFE_FREE((void**)&szSubGroupItem); @@ -1661,7 +1661,7 @@ int CIcqProto::servlistCreateGroup_Ready(const char *szGroup, WORD groupID, LPAR ack->dwAction = SSA_GROUP_ADD; dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_ADDTOLIST, 0, ack); - icq_sendServerGroup(dwCookie, ICQ_LISTS_ADDTOLIST, ack->wGroupId, ack->szGroup, NULL, 0, SSOF_BEGIN_OPERATION); + icq_sendServerGroup(dwCookie, ICQ_LISTS_ADDTOLIST, ack->wGroupId, ack->szGroup, nullptr, 0, SSOF_BEGIN_OPERATION); return CALLBACK_RESULT_POSTPONE; } @@ -1741,7 +1741,7 @@ int CIcqProto::servlistAddContact_gotGroup(const char*, WORD wGroupID, LPARAM lP DWORD dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_ADDTOLIST, ack->hContact, ack); - icq_sendServerContact(ack->hContact, dwCookie, ICQ_LISTS_ADDTOLIST, wGroupID, wItemID, SSOP_ITEM_ACTION | SSOF_CONTACT | SSOF_BEGIN_OPERATION, 400, NULL); + icq_sendServerContact(ack->hContact, dwCookie, ICQ_LISTS_ADDTOLIST, wGroupID, wItemID, SSOP_ITEM_ACTION | SSOF_CONTACT | SSOF_BEGIN_OPERATION, 400, nullptr); return CALLBACK_RESULT_CONTINUE; } @@ -1833,7 +1833,7 @@ int CIcqProto::servlistRemoveContact_Ready(MCONTACT hContact, WORD contactID, WO dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_REMOVEFROMLIST, hContact, ack); - icq_sendServerContact(hContact, dwCookie, ICQ_LISTS_REMOVEFROMLIST, wGroupID, wItemID, SSOP_ITEM_ACTION | SSOF_CONTACT | SSOF_BEGIN_OPERATION, 400, NULL); + icq_sendServerContact(hContact, dwCookie, ICQ_LISTS_REMOVEFROMLIST, wGroupID, wItemID, SSOP_ITEM_ACTION | SSOF_CONTACT | SSOF_BEGIN_OPERATION, 400, nullptr); return CALLBACK_RESULT_POSTPONE; } @@ -1895,7 +1895,7 @@ int CIcqProto::servlistMoveContact_gotTargetGroup(const char *szGroup, WORD wNew return CALLBACK_RESULT_CONTINUE; } - ack->szGroupName = NULL; + ack->szGroupName = nullptr; ack->dwAction = SSA_CONTACT_SET_GROUP; ack->wGroupId = wGroupID; ack->wContactId = wItemID; @@ -1907,7 +1907,7 @@ int CIcqProto::servlistMoveContact_gotTargetGroup(const char *szGroup, WORD wNew DWORD dwCookie2 = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_ADDTOLIST, ack->hContact, ack); { // imitate icq5, previously here was different order, but AOL changed and it ceased to work - void *doubleObject = NULL; + void *doubleObject = nullptr; icq_sendServerContact(ack->hContact, dwCookie2, ICQ_LISTS_ADDTOLIST, wNewGroupID, ack->wNewContactId, SSO_CONTACT_SETGROUP | SSOF_BEGIN_OPERATION, 500, &doubleObject); icq_sendServerContact(ack->hContact, dwCookie, ICQ_LISTS_REMOVEFROMLIST, wGroupID, wItemID, SSO_CONTACT_SETGROUP | SSOF_BEGIN_OPERATION, 500, &doubleObject); @@ -1955,7 +1955,7 @@ void CIcqProto::servlistMoveContact(MCONTACT hContact, const char *pszNewGroup) return; } - if ((pszNewGroup != NULL) && (pszNewGroup[0] != '\0') && !getCListGroupExists(pszNewGroup)) { // the contact moved to non existing group, do not do anything: MetaContact hack + if ((pszNewGroup != nullptr) && (pszNewGroup[0] != '\0') && !getCListGroupExists(pszNewGroup)) { // the contact moved to non existing group, do not do anything: MetaContact hack debugLogA("Contact not moved - probably hiding by MetaContacts."); return; } @@ -2020,7 +2020,7 @@ int CIcqProto::servlistUpdateContact_Ready(MCONTACT hContact, WORD contactID, WO // There is no need to send ICQ_LISTS_CLI_MODIFYSTART or // ICQ_LISTS_CLI_MODIFYEND when just changing nick name - icq_sendServerContact(hContact, dwCookie, ICQ_LISTS_UPDATEGROUP, wGroupID, wItemID, SSOP_ITEM_ACTION | SSOF_CONTACT, 400, NULL); + icq_sendServerContact(hContact, dwCookie, ICQ_LISTS_UPDATEGROUP, wGroupID, wItemID, SSOP_ITEM_ACTION | SSOF_CONTACT, 400, nullptr); return CALLBACK_RESULT_POSTPONE; } @@ -2160,7 +2160,7 @@ int CIcqProto::servlistRemoveGroup_Ready(const char *szGroup, WORD groupID, LPAR char *szGroupName; if (wGroupID && (szGroupName = getServListGroupName(wGroupID))) { // the group is valid, check if it is empty - void *groupData = collectBuddyGroup(wGroupID, NULL); + void *groupData = collectBuddyGroup(wGroupID, nullptr); if (groupData) { // the group is not empty, cannot delete SAFE_FREE(&groupData); @@ -2181,7 +2181,7 @@ int CIcqProto::servlistRemoveGroup_Ready(const char *szGroup, WORD groupID, LPAR ack->szGroupName = szGroupName; DWORD dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_REMOVEFROMLIST, 0, ack); - icq_sendServerGroup(dwCookie, ICQ_LISTS_REMOVEFROMLIST, ack->wGroupId, ack->szGroupName, NULL, 0, 0); + icq_sendServerGroup(dwCookie, ICQ_LISTS_REMOVEFROMLIST, ack->wGroupId, ack->szGroupName, nullptr, 0, 0); } return CALLBACK_RESULT_POSTPONE; } @@ -2223,7 +2223,7 @@ void CIcqProto::resetServContactAuthState(MCONTACT hContact) DWORD dwCookie = AllocateCookie(CKT_SERVERLIST, 0, hContact, ack); { - void *doubleObject = NULL; + void *doubleObject = nullptr; icq_sendServerContact(hContact, dwCookie, ICQ_LISTS_REMOVEFROMLIST, wGroupId, wContactId, SSO_CONTACT_FIXAUTH | SSOF_BEGIN_OPERATION | SSOF_END_OPERATION, 200, &doubleObject); delSetting(hContact, DBSETTING_METAINFO_TOKEN); @@ -2330,17 +2330,17 @@ int CIcqProto::ServListCListGroupChange(WPARAM hContact, LPARAM lParam) return 0; if (hContact == NULL) { // change made to group - if (grpchg->pszNewName == NULL && grpchg->pszOldName != NULL) { // group removed + if (grpchg->pszNewName == nullptr && grpchg->pszOldName != nullptr) { // group removed char *szOldName = make_utf8_string(grpchg->pszOldName); WORD wGroupId = getServListGroupLinkID(szOldName); if (wGroupId) { // the group is known, remove from server - servlistPostPacket(NULL, 0, SSO_BEGIN_OPERATION, 100); // start server modifications here + servlistPostPacket(nullptr, 0, SSO_BEGIN_OPERATION, 100); // start server modifications here servlistRemoveGroup(szOldName, wGroupId); } SAFE_FREE(&szOldName); } - else if (grpchg->pszNewName != NULL && grpchg->pszOldName != NULL) { // group renamed + else if (grpchg->pszNewName != nullptr && grpchg->pszOldName != nullptr) { // group renamed char *szNewName = make_utf8_string(grpchg->pszNewName); char *szOldName = make_utf8_string(grpchg->pszOldName); WORD wGroupId = getServListGroupLinkID(szOldName); @@ -2354,7 +2354,7 @@ int CIcqProto::ServListCListGroupChange(WPARAM hContact, LPARAM lParam) } else { // change to contact if (IsICQContact(hContact)) { // our contact, fine move on the server as well - char *szNewName = grpchg->pszNewName ? make_utf8_string(grpchg->pszNewName) : NULL; + char *szNewName = grpchg->pszNewName ? make_utf8_string(grpchg->pszNewName) : nullptr; servlistMoveContact(hContact, szNewName); SAFE_FREE(&szNewName); } diff --git a/protocols/IcqOscarJ/src/icq_uploadui.cpp b/protocols/IcqOscarJ/src/icq_uploadui.cpp index 0e2890c0dd..afa1843853 100644 --- a/protocols/IcqOscarJ/src/icq_uploadui.cpp +++ b/protocols/IcqOscarJ/src/icq_uploadui.cpp @@ -33,10 +33,10 @@ static int bListInit = 0; static HANDLE hItemAll; static int dwUploadDelay = 1000; // initial setting, it is too low for icq server but good for short updates -static HWND hwndUploadContacts = NULL; +static HWND hwndUploadContacts = nullptr; static const UINT settingsControls[] = { IDOK }; -static WORD *pwGroupIds = NULL; +static WORD *pwGroupIds = nullptr; static int cbGroupIds = 0; // Init default clist options @@ -140,7 +140,7 @@ static int GroupEnumIdsEnumProc(const char *szSetting, LPARAM lParam) return 0; // this converts all string types to DBVT_ASCIIZ pwGroupIds = (WORD*)SAFE_REALLOC(pwGroupIds, (cbGroupIds + 1)*sizeof(WORD)); - pwGroupIds[cbGroupIds] = (WORD)strtoul(szSetting, NULL, 0x10); + pwGroupIds[cbGroupIds] = (WORD)strtoul(szSetting, nullptr, 0x10); cbGroupIds++; } return 0; @@ -164,7 +164,7 @@ static DWORD sendUploadGroup(CIcqProto* ppro, WORD wAction, WORD wGroupId, char* dwCookie = ppro->AllocateCookie(CKT_SERVERLIST, wAction, 0, ack); ack->lParam = dwCookie; - ppro->icq_sendServerGroup(dwCookie, wAction, ack->wGroupId, szItemName, NULL, 0, 0); + ppro->icq_sendServerGroup(dwCookie, wAction, ack->wGroupId, szItemName, nullptr, 0, 0); return dwCookie; } return 0; @@ -173,7 +173,7 @@ static DWORD sendUploadGroup(CIcqProto* ppro, WORD wAction, WORD wGroupId, char* static DWORD sendUploadBuddy(CIcqProto* ppro, MCONTACT hContact, WORD wAction, DWORD dwUin, char *szUID, WORD wContactId, WORD wGroupId, WORD wItemType) { cookie_servlist_action *ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action)); - if (ack == NULL) + if (ack == nullptr) return 0; // we have cookie good, go on @@ -185,7 +185,7 @@ static DWORD sendUploadBuddy(CIcqProto* ppro, MCONTACT hContact, WORD wAction, D ack->lParam = dwCookie; if (wItemType == SSI_ITEM_BUDDY) - ppro->icq_sendServerContact(hContact, dwCookie, wAction, ack->wGroupId, ack->wContactId, SSOP_ITEM_ACTION | SSOF_CONTACT, 500, NULL); + ppro->icq_sendServerContact(hContact, dwCookie, wAction, ack->wGroupId, ack->wContactId, SSOP_ITEM_ACTION | SSOF_CONTACT, 500, nullptr); else ppro->icq_sendSimpleItem(dwCookie, wAction, dwUin, szUID, ack->wGroupId, ack->wContactId, wItemType, SSOP_ITEM_ACTION, 500); @@ -253,7 +253,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa char str[MAX_PATH]; working = 0; - hProtoAckHook = NULL; + hProtoAckHook = nullptr; currentState = STATE_READY; ResetCListOptions(GetDlgItem(hwndDlg, IDC_CLIST)); @@ -371,7 +371,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa case ACTION_REMOVEGROUP: if (ack->result == ACKRESULT_SUCCESS) { ppro->FreeServerID(wNewGroupId, SSIT_GROUP); - ppro->setServListGroupName(wNewGroupId, NULL); // remove group from list + ppro->setServListGroupName(wNewGroupId, nullptr); // remove group from list ppro->removeGroupPathLinks(wNewGroupId); // grouppath is known int groupSize; @@ -439,7 +439,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa ICQTranslateUtfStatic(getServerResultDesc(ack->lParam), str, MAX_PATH)); if (!bMulti) - SetTimer(hwndDlg, M_UPLOADMORE, dwUploadDelay, 0); // delay + SetTimer(hwndDlg, M_UPLOADMORE, dwUploadDelay, nullptr); // delay } break; @@ -496,7 +496,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa // Is this one out of sync? if (bUidOk && (isChecked != isOnServer)) { // Only upload custom nicks - char *pszNick = ppro->getSettingStringUtf(hContact, "CList", "MyHandle", NULL); + char *pszNick = ppro->getSettingStringUtf(hContact, "CList", "MyHandle", nullptr); if (isChecked) { // Queue for uploading char *pszGroup = ppro->getContactCListGroup(hContact); @@ -505,7 +505,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa // Get group ID from cache, if not ready use parent group, if still not ready create one wNewGroupId = ppro->getServListGroupLinkID(pszGroup); - if (!wNewGroupId && strstrnull(pszGroup, "\\") != NULL) { // if it is sub-group, take master parent + if (!wNewGroupId && strstrnull(pszGroup, "\\") != nullptr) { // if it is sub-group, take master parent strstrnull(pszGroup, "\\")[0] = '\0'; wNewGroupId = ppro->getServListGroupLinkID(pszGroup); } @@ -569,7 +569,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa pszGroup = null_strdup(DEFAULT_SS_GROUP); wNewGroupId = ppro->getServListGroupLinkID(pszGroup); - if (!wNewGroupId && strstrnull(pszGroup, "\\") != NULL) { // if it is sub-group, take master parent + if (!wNewGroupId && strstrnull(pszGroup, "\\") != nullptr) { // if it is sub-group, take master parent strstrnull(pszGroup, "\\")[0] = '\0'; wNewGroupId = ppro->getServListGroupLinkID(pszGroup); } @@ -589,7 +589,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa if (wNewGroupId && (wNewGroupId != wCurrentGroupId)) { WORD wCurrentContactId = ppro->getWord(hContact, DBSETTING_SERVLIST_ID, 0); - char *pszNick = ppro->getSettingStringUtf(hContact, "CList", "MyHandle", NULL); + char *pszNick = ppro->getSettingStringUtf(hContact, "CList", "MyHandle", nullptr); if (pszNick) AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Moving %s to group \"%s\"..."), str, MAX_PATH), pszNick, pszGroup); else @@ -731,7 +731,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa currentAction = ACTION_UPDATESTATE; AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Updating group \"%s\"..."), str, MAX_PATH), pszGroup); - ppro->icq_sendServerGroup(currentSequence, ICQ_LISTS_UPDATEGROUP, wNewGroupId, pszGroup, 0, 0, 0); + ppro->icq_sendServerGroup(currentSequence, ICQ_LISTS_UPDATEGROUP, wNewGroupId, pszGroup, nullptr, 0, 0); SAFE_FREE((void**)&pszGroup); } @@ -752,7 +752,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa SetDlgItemText(hwndDlg, IDCANCEL, TranslateT("Close")); // end server modifications here - ppro->servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100); + ppro->servlistPostPacket(nullptr, 0, SSO_END_OPERATION, 100); working = 0; UpdateCheckmarks(GetDlgItem(hwndDlg, IDC_CLIST), ppro, hItemAll); if (hProtoAckHook) @@ -779,7 +779,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa hProtoAckHook = HookEventMessage(ME_PROTO_ACK, hwndDlg, M_PROTOACK); // start server modifications here - ppro->servlistPostPacket(NULL, 0, SSO_BEGIN_OPERATION | SSOF_IMPORT_OPERATION, 100); + ppro->servlistPostPacket(nullptr, 0, SSO_BEGIN_OPERATION | SSOF_IMPORT_OPERATION, 100); PostMessage(hwndDlg, M_UPLOADMORE, 0, 0); break; @@ -814,7 +814,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa if (ppro) { DeleteOtherContactsFromControl(hClist, ppro); if (!bListInit) // do not enter twice - bCheck = UpdateCheckmarks(hClist, ppro, NULL); + bCheck = UpdateCheckmarks(hClist, ppro, nullptr); } if (!hItemAll) { // Add the "All contacts" item @@ -858,9 +858,9 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa if (hProtoAckHook) UnhookEvent(hProtoAckHook); if (working) // end server modifications here - ppro->servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100); + ppro->servlistPostPacket(nullptr, 0, SSO_END_OPERATION, 100); - hwndUploadContacts = NULL; + hwndUploadContacts = nullptr; working = 0; break; } @@ -870,9 +870,9 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa void CIcqProto::ShowUploadContactsDialog(void) { - if (hwndUploadContacts == NULL) { - hItemAll = NULL; - hwndUploadContacts = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ICQUPLOADLIST), NULL, DlgProcUploadList, LPARAM(this)); + if (hwndUploadContacts == nullptr) { + hItemAll = nullptr; + hwndUploadContacts = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ICQUPLOADLIST), nullptr, DlgProcUploadList, LPARAM(this)); } SetForegroundWindow(hwndUploadContacts); diff --git a/protocols/IcqOscarJ/src/icq_xstatus.cpp b/protocols/IcqOscarJ/src/icq_xstatus.cpp index cf41be3e94..65f7d1025f 100644 --- a/protocols/IcqOscarJ/src/icq_xstatus.cpp +++ b/protocols/IcqOscarJ/src/icq_xstatus.cpp @@ -81,7 +81,7 @@ DWORD CIcqProto::requestXStatusDetails(MCONTACT hContact, BOOL bAllowDelay) struct rates_xstatus_request : public rates_queue_item { protected: - virtual rates_queue_item* copyItem(rates_queue_item *aDest = NULL) + virtual rates_queue_item* copyItem(rates_queue_item *aDest = nullptr) { rates_xstatus_request *pDest = (rates_xstatus_request*)aDest; if (!pDest) @@ -143,7 +143,7 @@ static wchar_t* InitXStatusIconLibrary(wchar_t *buf, size_t buf_size) HMODULE hXStatusIconsDLL; // get miranda's exe path - GetModuleFileName(NULL, path, MAX_PATH); + GetModuleFileName(nullptr, path, MAX_PATH); hXStatusIconsDLL = (HMODULE)LoadXStatusIconLibrary(path, L"\\Icons"); if (!hXStatusIconsDLL) // TODO: add "Custom Folders" support @@ -165,7 +165,7 @@ static wchar_t* InitXStatusIconLibrary(wchar_t *buf, size_t buf_size) HICON CIcqProto::getXStatusIcon(int bStatus, UINT flags) { - HICON icon = NULL; + HICON icon = nullptr; if (bStatus > 0 && bStatus <= XSTATUS_COUNT) icon = IcoLib_GetIconByHandle(hXStatusIcons[bStatus - 1], (flags & LR_BIGICON) != 0); @@ -175,7 +175,7 @@ HICON CIcqProto::getXStatusIcon(int bStatus, UINT flags) void setContactExtraIcon(MCONTACT hContact, int xstatus) { - ExtraIcon_SetIcon(hExtraXStatus, hContact, (xstatus > 0) ? hXStatusIcons[xstatus - 1] : NULL); + ExtraIcon_SetIcon(hExtraXStatus, hContact, (xstatus > 0) ? hXStatusIcons[xstatus - 1] : nullptr); } #define NULLCAP {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} @@ -520,7 +520,7 @@ void CIcqProto::updateServerCustomStatus(int fullUpdate) SetStatusMood(szMoodData, 1500); } - char *szStatusNote = NULL; + char *szStatusNote = nullptr; // use custom status message as status note if (bXStatus && (m_bXStatusEnabled || m_bMoodsEnabled)) @@ -619,7 +619,7 @@ static INT_PTR CALLBACK SetXStatusDlgProc(HWND hwndDlg, UINT message, WPARAM wPa ShowDlgItem(hwndDlg, IDC_XMSG, SW_SHOW); ShowDlgItem(hwndDlg, IDC_XTITLE, SW_SHOW); SetDlgItemText(hwndDlg, IDOK, TranslateT("Close")); - UnhookEvent(dat->hEvent); dat->hEvent = NULL; + UnhookEvent(dat->hEvent); dat->hEvent = nullptr; char *szText = dat->ppro->getSettingStringUtf(dat->hContact, DBSETTING_XSTATUS_NAME, ""); SetDlgItemTextUtf(hwndDlg, IDC_XTITLE, szText); SAFE_FREE(&szText); @@ -660,12 +660,12 @@ static INT_PTR CALLBACK SetXStatusDlgProc(HWND hwndDlg, UINT message, WPARAM wPa dat->okButtonFormat = GetDlgItemTextUtf(hwndDlg, IDOK); dat->countdown = 5; SendMessage(hwndDlg, WM_TIMER, 0, 0); - SetTimer(hwndDlg, 1, 1000, 0); + SetTimer(hwndDlg, 1, 1000, nullptr); } else { // retrieve contact's xStatus dat->hContact = init->hContact; dat->bXStatus = dat->ppro->getContactXStatus(dat->hContact); - dat->okButtonFormat = NULL; + dat->okButtonFormat = nullptr; SendDlgItemMessage(hwndDlg, IDC_XTITLE, EM_SETREADONLY, 1, 0); SendDlgItemMessage(hwndDlg, IDC_XMSG, EM_SETREADONLY, 1, 0); @@ -679,7 +679,7 @@ static INT_PTR CALLBACK SetXStatusDlgProc(HWND hwndDlg, UINT message, WPARAM wPa } else { SetDlgItemText(hwndDlg, IDOK, TranslateT("Close")); - dat->hEvent = NULL; + dat->hEvent = nullptr; char *szText = dat->ppro->getSettingStringUtf(dat->hContact, DBSETTING_XSTATUS_NAME, ""); SetDlgItemTextUtf(hwndDlg, IDC_XTITLE, szText); SAFE_FREE(&szText); @@ -782,15 +782,15 @@ void CIcqProto::setXStatusEx(BYTE bXStatus, BYTE bQuiet) if (!m_bHideXStatusUI) { if (bOldXStatus <= XSTATUS_COUNT) - Menu_ModifyItem(hXStatusItems[bOldXStatus], NULL, INVALID_HANDLE_VALUE, 0); + Menu_ModifyItem(hXStatusItems[bOldXStatus], nullptr, INVALID_HANDLE_VALUE, 0); - Menu_ModifyItem(hXStatusItems[bXStatus], NULL, INVALID_HANDLE_VALUE, CMIF_CHECKED); + Menu_ModifyItem(hXStatusItems[bXStatus], nullptr, INVALID_HANDLE_VALUE, CMIF_CHECKED); } if (bXStatus) { char szSetting[64]; char str[MAX_PATH]; - char *szName = NULL, *szMsg = NULL; + char *szName = nullptr, *szMsg = nullptr; if (m_bXStatusEnabled) { mir_snprintf(szSetting, "XStatus%dName", bXStatus); @@ -807,7 +807,7 @@ void CIcqProto::setXStatusEx(BYTE bXStatus, BYTE bQuiet) init.bXStatus = bXStatus; init.szXStatusName = szName; init.szXStatusMsg = szMsg; - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SETXSTATUS), NULL, SetXStatusDlgProc, (LPARAM)&init); + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SETXSTATUS), nullptr, SetXStatusDlgProc, (LPARAM)&init); } else { setByte(DBSETTING_XSTATUS_ID, bXStatus); @@ -878,7 +878,7 @@ void CIcqProto::InitXStatusItems(BOOL bAllowStatus) CreateProtoServiceParam(srvFce, &CIcqProto::menuXStatus, i); mi.flags = (bXStatus == i ? CMIF_CHECKED : 0); - mi.hIcolibItem = i ? hXStatusIcons[i - 1] : NULL; + mi.hIcolibItem = i ? hXStatusIcons[i - 1] : nullptr; mi.name.a = i ? (char*)nameXStatus[i - 1] : (char *)LPGEN("None"); mi.pszService = srvFce; @@ -891,7 +891,7 @@ void InitXStatusIcons() { wchar_t lib[2 * MAX_PATH] = { 0 }; - SKINICONDESC sid = { 0 }; + SKINICONDESC sid = {}; sid.section.a = "Protocols/" ICQ_PROTOCOL_NAME "/" LPGEN("Custom Status"); sid.flags = SIDF_PATH_UNICODE; sid.defaultFile.w = InitXStatusIconLibrary(lib, _countof(lib)); @@ -916,7 +916,7 @@ INT_PTR CIcqProto::ShowXStatusDetails(WPARAM hContact, LPARAM) init.ppro = this; init.bAction = 1; // retrieve init.hContact = hContact; - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SETXSTATUS), NULL, SetXStatusDlgProc, (LPARAM)&init); + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SETXSTATUS), nullptr, SetXStatusDlgProc, (LPARAM)&init); return 0; } @@ -987,7 +987,7 @@ INT_PTR CIcqProto::GetXStatusEx(WPARAM hContact, LPARAM lParam) // fill status name member if (pData->flags & CSSF_MASK_NAME) { if (pData->flags & CSSF_DEFAULT_NAME) { - int status = (pData->wParam == NULL) ? getContactXStatus(hContact) : *pData->wParam; + int status = (pData->wParam == nullptr) ? getContactXStatus(hContact) : *pData->wParam; if (status < 1 || status > XSTATUS_COUNT) return 1; // Failure diff --git a/protocols/IcqOscarJ/src/icq_xtraz.cpp b/protocols/IcqOscarJ/src/icq_xtraz.cpp index 9991238779..afaf939692 100644 --- a/protocols/IcqOscarJ/src/icq_xtraz.cpp +++ b/protocols/IcqOscarJ/src/icq_xtraz.cpp @@ -34,7 +34,7 @@ void CIcqProto::handleXtrazNotify(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD w char *szNotify = strstrnull(szMsg, ""); char *szQuery = strstrnull(szMsg, ""); - MCONTACT hContact = HContactFromUIN(dwUin, NULL); + MCONTACT hContact = HContactFromUIN(dwUin, nullptr); if (hContact) // user sent us xtraz, he supports it SetContactCapabilities(hContact, CAPF_XTRAZ); @@ -103,7 +103,7 @@ void CIcqProto::handleXtrazNotify(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD w struct rates_xstatus_response : public rates_queue_item { protected: - virtual rates_queue_item* copyItem(rates_queue_item *aDest = NULL) + virtual rates_queue_item* copyItem(rates_queue_item *aDest = nullptr) { rates_xstatus_response *pDest = (rates_xstatus_response*)aDest; if (!pDest) @@ -118,7 +118,7 @@ void CIcqProto::handleXtrazNotify(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD w return rates_queue_item::copyItem(pDest); }; public: - rates_xstatus_response(CIcqProto *ppro, WORD wGroup) : rates_queue_item(ppro, wGroup), szResponse(NULL) {}; + rates_xstatus_response(CIcqProto *ppro, WORD wGroup) : rates_queue_item(ppro, wGroup), szResponse(nullptr) {}; virtual ~rates_xstatus_response() { if (bCreated) SAFE_FREE(&szResponse); }; virtual void execute() @@ -193,7 +193,7 @@ void CIcqProto::handleXtrazNotifyResponse(MCONTACT hContact, WORD wCookie, char* NextVal: szNode = strstrnull(szRes, ""); else szEnd = NULL; + if (szNode) szEnd = strstrnull(szNode, ">"); else szEnd = nullptr; if (szNode && szEnd) { *(szEnd - 1) = '\0'; @@ -222,7 +222,7 @@ void CIcqProto::handleXtrazNotifyResponse(MCONTACT hContact, WORD wCookie, char* *szEnd = '\0'; szXName = DemangleXml(szNode, mir_strlen(szNode)); // check if the name changed - szOldXName = getSettingStringUtf(hContact, DBSETTING_XSTATUS_NAME, NULL); + szOldXName = getSettingStringUtf(hContact, DBSETTING_XSTATUS_NAME, nullptr); if (mir_strcmp(szOldXName, szXName)) bChanged = TRUE; SAFE_FREE(&szOldXName); @@ -238,7 +238,7 @@ void CIcqProto::handleXtrazNotifyResponse(MCONTACT hContact, WORD wCookie, char* *szEnd = '\0'; szXMsg = DemangleXml(szNode, mir_strlen(szNode)); // check if the decription changed - szOldXMsg = getSettingStringUtf(hContact, DBSETTING_XSTATUS_NAME, NULL); + szOldXMsg = getSettingStringUtf(hContact, DBSETTING_XSTATUS_NAME, nullptr); if (mir_strcmp(szOldXMsg, szXMsg)) bChanged = TRUE; SAFE_FREE(&szOldXMsg); @@ -274,13 +274,13 @@ static char* getXmlPidItem(const char* szData) szPid += 5; return DemangleXml(szPid, szEnd - szPid); } - return NULL; + return nullptr; } void CIcqProto::handleXtrazInvitation(DWORD dwUin, char* szMsg, BOOL bThruDC) { - MCONTACT hContact = HContactFromUIN(dwUin, NULL); + MCONTACT hContact = HContactFromUIN(dwUin, nullptr); if (hContact) // user sent us xtraz, he supports it SetContactCapabilities(hContact, CAPF_XTRAZ); @@ -296,7 +296,7 @@ void CIcqProto::handleXtrazInvitation(DWORD dwUin, char* szMsg, BOOL bThruDC) void CIcqProto::handleXtrazData(DWORD dwUin, char* szMsg, BOOL bThruDC) { - MCONTACT hContact = HContactFromUIN(dwUin, NULL); + MCONTACT hContact = HContactFromUIN(dwUin, nullptr); if (hContact) // user sent us xtraz, he supports it SetContactCapabilities(hContact, CAPF_XTRAZ); @@ -330,7 +330,7 @@ void CIcqProto::handleXtrazData(DWORD dwUin, char* szMsg, BOOL bThruDC) // Create message to notify user PROTORECVEVENT pre = { 0 }; - pre.timestamp = time(NULL); + pre.timestamp = time(nullptr); pre.szMessage = szWork; int bAdded; @@ -352,7 +352,7 @@ void CIcqProto::handleXtrazData(DWORD dwUin, char* szMsg, BOOL bThruDC) DWORD CIcqProto::SendXtrazNotifyRequest(MCONTACT hContact, char* szQuery, char* szNotify, int bForced) { DWORD dwUin; - if (getContactUid(hContact, &dwUin, NULL)) + if (getContactUid(hContact, &dwUin, nullptr)) return 0; // Invalid contact if (!CheckContactCapabilities(hContact, CAPF_XTRAZ) && !bForced) @@ -385,7 +385,7 @@ void CIcqProto::SendXtrazNotifyResponse(DWORD dwUin, DWORD dwMID, DWORD dwMID2, char *szResBody = MangleXml(szResponse, nResponseLen); size_t nBodyLen = mir_strlen(szResBody) + 21; char *szBody = (char*)_alloca(nBodyLen); - MCONTACT hContact = HContactFromUIN(dwUin, NULL); + MCONTACT hContact = HContactFromUIN(dwUin, nullptr); if (hContact != INVALID_CONTACT_ID && !CheckContactCapabilities(hContact, CAPF_XTRAZ)) { SAFE_FREE(&szResBody); diff --git a/protocols/IcqOscarJ/src/icqosc_svcs.cpp b/protocols/IcqOscarJ/src/icqosc_svcs.cpp index d2d8a81dd6..372bff14ef 100644 --- a/protocols/IcqOscarJ/src/icqosc_svcs.cpp +++ b/protocols/IcqOscarJ/src/icqosc_svcs.cpp @@ -97,9 +97,9 @@ INT_PTR CIcqProto::GetInfoSetting(WPARAM hContact, LPARAM lParam) cgs->pValue->pszVal = mir_strdup(dbv.pszVal); else if (type == DBVT_WCHAR) { if (dbv.type != DBVT_UTF8) { - int len = MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, NULL, 0); + int len = MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, nullptr, 0); cgs->pValue->pwszVal = (WCHAR*)mir_alloc((len + 1)*sizeof(WCHAR)); - if (cgs->pValue->pwszVal == NULL) + if (cgs->pValue->pwszVal == nullptr) rc = 1; else { MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, cgs->pValue->pwszVal, len); @@ -107,19 +107,19 @@ INT_PTR CIcqProto::GetInfoSetting(WPARAM hContact, LPARAM lParam) } } else { - char *savePtr = dbv.pszVal ? mir_strcpy((char*)_alloca(mir_strlen(dbv.pszVal) + 1), dbv.pszVal) : NULL; + char *savePtr = dbv.pszVal ? mir_strcpy((char*)_alloca(mir_strlen(dbv.pszVal) + 1), dbv.pszVal) : nullptr; if (!mir_utf8decode(savePtr, &cgs->pValue->pwszVal)) rc = 1; } } else if (type == DBVT_UTF8) { cgs->pValue->pszVal = mir_utf8encode(dbv.pszVal); - if (cgs->pValue->pszVal == NULL) + if (cgs->pValue->pszVal == nullptr) rc = 1; } else if (type == DBVT_ASCIIZ) { cgs->pValue->pszVal = mir_strdup(dbv.pszVal); - mir_utf8decode(cgs->pValue->pszVal, NULL); + mir_utf8decode(cgs->pValue->pszVal, nullptr); } cgs->pValue->type = type; @@ -156,14 +156,14 @@ INT_PTR CIcqProto::ChangeInfoEx(WPARAM wParam, LPARAM) if (!icqOnline() || !wParam) return 0; - PBYTE buf = NULL; + PBYTE buf = nullptr; size_t buflen = 0; // userinfo ppackTLVWord(&buf, &buflen, 0x1C2, (WORD)GetACP()); if (wParam & CIXT_CONTACT) { // contact information - BYTE *pBlock = NULL; + BYTE *pBlock = nullptr; size_t cbBlock = 0; int nItems = 0; @@ -205,7 +205,7 @@ INT_PTR CIcqProto::ChangeInfoEx(WPARAM wParam, LPARAM) } if (wParam & CIXT_WORK) { - BYTE *pBlock = NULL; + BYTE *pBlock = nullptr; size_t cbBlock = 0; int nItems = 1; @@ -227,7 +227,7 @@ INT_PTR CIcqProto::ChangeInfoEx(WPARAM wParam, LPARAM) } if (wParam & CIXT_EDUCATION) { - BYTE *pBlock = NULL; + BYTE *pBlock = nullptr; size_t cbBlock = 0; int nItems = 1; @@ -240,7 +240,7 @@ INT_PTR CIcqProto::ChangeInfoEx(WPARAM wParam, LPARAM) } if (wParam & CIXT_LOCATION) { - BYTE *pBlock = NULL; + BYTE *pBlock = nullptr; size_t cbBlock = 0; int nItems = 1; @@ -269,7 +269,7 @@ INT_PTR CIcqProto::ChangeInfoEx(WPARAM wParam, LPARAM) } if (wParam & CIXT_BACKGROUND) { - BYTE *pBlock = NULL; + BYTE *pBlock = nullptr; size_t cbBlock = 0; int nItems = 0; @@ -410,7 +410,7 @@ INT_PTR CIcqProto::GrantAuthorization(WPARAM wParam, LPARAM) return 0; // Invalid contact // send without reason, do we need any ? - icq_sendGrantAuthServ(dwUin, szUid, NULL); + icq_sendGrantAuthServ(dwUin, szUid, nullptr); // auth granted, remove contact menu item delSetting(wParam, "Grant"); } @@ -425,7 +425,7 @@ int CIcqProto::OnIdleChanged(WPARAM, LPARAM lParam) if (bPrivacy) return 0; - setDword("IdleTS", bIdle ? time(0) : 0); + setDword("IdleTS", bIdle ? time(nullptr) : 0); if (m_bTempVisListEnabled) // remove temporary visible users sendEntireListServ(ICQ_BOS_FAMILY, ICQ_CLI_REMOVETEMPVISIBLE, BUL_TEMPVISIBLE); @@ -442,7 +442,7 @@ INT_PTR CIcqProto::RevokeAuthorization(WPARAM wParam, LPARAM) if (getContactUid(wParam, &dwUin, &szUid)) return 0; // Invalid contact - if (MessageBox(NULL, 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) + 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); @@ -466,7 +466,7 @@ INT_PTR CIcqProto::SendYouWereAdded(WPARAM, LPARAM lParam) CCSDATA* ccs = (CCSDATA*)lParam; if (ccs->hContact) { DWORD dwUin; - if (getContactUid(ccs->hContact, &dwUin, NULL)) + if (getContactUid(ccs->hContact, &dwUin, nullptr)) return 1; // Invalid contact DWORD dwMyUin = getContactUin(NULL); @@ -498,7 +498,7 @@ INT_PTR CIcqProto::SetMyAvatar(WPARAM, LPARAM lParam) } wchar_t tszMyFile[MAX_PATH + 1]; - GetFullAvatarFileName(0, NULL, dwPaFormat, tszMyFile, MAX_PATH); + GetFullAvatarFileName(0, nullptr, dwPaFormat, tszMyFile, MAX_PATH); // if not in our storage, copy if (mir_wstrcmp(tszFile, tszMyFile) && !CopyFile(tszFile, tszMyFile, FALSE)) { @@ -507,7 +507,7 @@ INT_PTR CIcqProto::SetMyAvatar(WPARAM, LPARAM lParam) } BYTE *hash = calcMD5HashOfFile(tszMyFile); - if (hash == NULL) + if (hash == nullptr) return -1; BYTE ihash[0x14]; @@ -635,7 +635,7 @@ INT_PTR icq_getEventTextMissedMessage(WPARAM pEvent, LPARAM datatype) DBEVENTINFO *dbei = (DBEVENTINFO *)pEvent; INT_PTR nRetVal = 0; - char *pszText = NULL; + char *pszText = nullptr; if (dbei->cbBlob > 1) { switch (((WORD*)dbei->pBlob)[0]) { @@ -660,7 +660,7 @@ INT_PTR icq_getEventTextMissedMessage(WPARAM pEvent, LPARAM datatype) break; } if (datatype == DBVT_WCHAR) { - int wchars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pszText, (int)mir_strlen(pszText), NULL, 0); + int wchars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pszText, (int)mir_strlen(pszText), nullptr, 0); WCHAR *pwszText = (WCHAR*)_alloca((wchars + 1) * sizeof(WCHAR)); pwszText[wchars] = 0; diff --git a/protocols/IcqOscarJ/src/init.cpp b/protocols/IcqOscarJ/src/init.cpp index e8ee23bc74..10ea203387 100644 --- a/protocols/IcqOscarJ/src/init.cpp +++ b/protocols/IcqOscarJ/src/init.cpp @@ -101,7 +101,7 @@ extern "C" int __declspec(dllexport) Load(void) mir_getLP(&pluginInfo); pcli = Clist_GetInterface(); - srand(time(NULL)); + srand(time(nullptr)); _tzset(); // Register the module diff --git a/protocols/IcqOscarJ/src/log.cpp b/protocols/IcqOscarJ/src/log.cpp index 4688dbe1c4..c3c73afc4b 100644 --- a/protocols/IcqOscarJ/src/log.cpp +++ b/protocols/IcqOscarJ/src/log.cpp @@ -55,7 +55,7 @@ void __cdecl CIcqProto::icq_LogMessageThread(void* arg) bErrorBoxVisible = TRUE; if (err->szMsg && err->szTitle) - MessageBoxUtf(NULL, err->szMsg, err->szTitle, MB_OK); + MessageBoxUtf(nullptr, err->szMsg, err->szTitle, MB_OK); SAFE_FREE((void**)&err->szMsg); SAFE_FREE((void**)&err); bErrorBoxVisible = FALSE; @@ -85,7 +85,7 @@ void CIcqProto::icq_LogUsingErrorCode(int level, DWORD dwError, const char *szMs char str[1024]; char str2[64]; char szErrorMsg[512]; - char *pszErrorMsg = NULL; + char *pszErrorMsg = nullptr; int bNeedFree = FALSE; switch (dwError) { @@ -120,7 +120,7 @@ void CIcqProto::icq_LogUsingErrorCode(int level, DWORD dwError, const char *szMs default: wchar_t err[512]; - if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, 0, err, _countof(err), NULL)) { + if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, dwError, 0, err, _countof(err), nullptr)) { pszErrorMsg = make_utf8_string(err); bNeedFree = TRUE; } diff --git a/protocols/IcqOscarJ/src/loginpassword.cpp b/protocols/IcqOscarJ/src/loginpassword.cpp index 6b15f2a877..a99e1e6849 100644 --- a/protocols/IcqOscarJ/src/loginpassword.cpp +++ b/protocols/IcqOscarJ/src/loginpassword.cpp @@ -84,5 +84,5 @@ INT_PTR CALLBACK LoginPasswdDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA void CIcqProto::RequestPassword() { - DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_LOGINPW), NULL, LoginPasswdDlgProc, LPARAM(this)); + DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_LOGINPW), nullptr, LoginPasswdDlgProc, LPARAM(this)); } diff --git a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp index b315cbc3b7..d413daecd0 100644 --- a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp +++ b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp @@ -60,8 +60,8 @@ char* FindFilePathContainer(const char **files, int iFile, char *szContainer) if (!_strnicmp(files[i], szThisFile, len) && (szThisFile[len] == '\\' || szThisFile[len] == '/')) { const char *pszLastBackslash; - if (((pszLastBackslash = strrchr(files[i], '\\')) == NULL) && - ((pszLastBackslash = strrchr(files[i], '/')) == NULL)) { + if (((pszLastBackslash = strrchr(files[i], '\\')) == nullptr) && + ((pszLastBackslash = strrchr(files[i], '/')) == nullptr)) { mir_strcpy(szContainer, files[i]); } else { @@ -130,7 +130,7 @@ oscar_filetransfer* CIcqProto::FindOscarTransfer(MCONTACT hContact, DWORD dwID1, } } - return NULL; + return nullptr; } // Release file transfer structure @@ -155,7 +155,7 @@ void CIcqProto::SafeReleaseFileTransfer(basic_filetransfer **bft) for (int i = 0; i < (int)ift->dwFileCount; i++) { // szThisFile can be a duplicate of pszFiles[i] if (ift->szThisFile == ift->pszFiles[i]) - ift->szThisFile = NULL; + ift->szThisFile = nullptr; SAFE_FREE(&ift->pszFiles[i]); } SAFE_FREE((void**)&ift->pszFiles); @@ -269,13 +269,13 @@ oscar_listener* CIcqProto::CreateOscarListener(oscar_filetransfer *ft, NETLIBNEW if (listener) { listener->ppro = this; listener->ft = ft; - if (listener->hBoundPort = NetLib_BindPort(handler, listener, &listener->wPort, NULL)) + if (listener->hBoundPort = NetLib_BindPort(handler, listener, &listener->wPort, nullptr)) return listener; // Success SAFE_FREE((void**)&listener); } - return NULL; // Failure + return nullptr; // Failure } @@ -285,7 +285,7 @@ void CIcqProto::ReleaseOscarListener(oscar_listener **pListener) if (listener) { // Close listening port if (listener->hBoundPort) { Netlib_CloseHandle(listener->hBoundPort); - listener->hBoundPort = NULL; + listener->hBoundPort = nullptr; } NetLog_Direct("Oscar listener on port %d released.", listener->wPort); @@ -300,7 +300,7 @@ void CIcqProto::ReleaseOscarListener(oscar_listener **pListener) void CIcqProto::handleRecvServMsgOFT(BYTE *buf, size_t wLen, DWORD dwUin, char *szUID, DWORD dwID1, DWORD dwID2, WORD wCommand) { - MCONTACT hContact = HContactFromUID(dwUin, szUID, NULL); + MCONTACT hContact = HContactFromUID(dwUin, szUID, nullptr); if (wCommand == 0) { // this is OFT request oscar_tlv_chain* chain = readIntoTLVChain(&buf, wLen, 0); @@ -310,8 +310,8 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, size_t wLen, DWORD dwUin, char * if (wAckType == 1) { // This is first request in this OFT oscar_filetransfer *ft = CreateOscarTransfer(); - char *pszFileName = NULL; - char *pszDescription = NULL; + char *pszFileName = nullptr; + char *pszDescription = nullptr; debugLogA("This is a file request"); @@ -479,7 +479,7 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, size_t wLen, DWORD dwUin, char * PROTORECVFILET pre = { 0 }; pre.dwFlags = PRFF_UNICODE; pre.fileCount = 1; - pre.timestamp = time(NULL); + pre.timestamp = time(nullptr); pre.descr.w = mir_utf8decodeW(pszDescription); pre.files.w = &ptszFileName; pre.lParam = (LPARAM)ft; @@ -737,7 +737,7 @@ HANDLE CIcqProto::oftInitTransfer(MCONTACT hContact, DWORD dwUin, char* szUid, c // Release transfer SafeReleaseFileTransfer((basic_filetransfer**)&ft); - return 0; // Failure + return nullptr; // Failure } #ifdef __GNUC__ #define OSCAR_MAX_SIZE 0x100000000ULL @@ -751,7 +751,7 @@ HANDLE CIcqProto::oftInitTransfer(MCONTACT hContact, DWORD dwUin, char* szUid, c // Release transfer SafeReleaseFileTransfer((basic_filetransfer**)&ft); - return 0; // Failure + return nullptr; // Failure } debugLogA("OFT: Found %d files.", ft->wFilesCount); @@ -799,7 +799,7 @@ HANDLE CIcqProto::oftInitTransfer(MCONTACT hContact, DWORD dwUin, char* szUid, c if (nFirstDirLen) { // got root dir from first container, check if others are only sub-dirs for (i = 0; i < ft->containerCount; i++) { if (_strnicmp((char*)ft->file_containers[i], (char*)szFirstDir, nFirstDirLen)) { - szFirstDir = NULL; + szFirstDir = nullptr; break; } } @@ -838,10 +838,10 @@ HANDLE CIcqProto::oftFileAllow(MCONTACT hContact, HANDLE hTransfer, const wchar_ DWORD dwUin; uid_str szUid; if (getContactUid(hContact, &dwUin, &szUid)) - return 0; // Invalid contact + return nullptr; // Invalid contact if (!IsValidOscarTransfer(ft)) - return 0; // Invalid transfer + return nullptr; // Invalid transfer ft->szSavePath = make_utf8_string(szPath); @@ -916,7 +916,7 @@ void CIcqProto::oftFileResume(oscar_filetransfer *ft, int action, const wchar_t { int openFlags; - if (ft->connection == NULL) + if (ft->connection == nullptr) return; oscar_connection *oc = ft->connection; @@ -1012,7 +1012,7 @@ static void oft_buildProtoFileTransferStatus(oscar_filetransfer* ft, PROTOFILETR if (ft->flags & OFTF_SENDING) pfts->pszFiles = ft->files_list; else - pfts->pszFiles = NULL; /* FIXME */ + pfts->pszFiles = nullptr; /* FIXME */ pfts->totalFiles = ft->wFilesCount; pfts->currentFileNumber = ft->iCurrentFile; pfts->totalBytes = ft->qwTotalSize; @@ -1154,10 +1154,10 @@ void __cdecl CIcqProto::oft_connectionThread(oscarthreadstartinfo *otsi) nloc.szHost = inet_ntoa(addr); nloc.wPort = oc.ft->wRemotePort; nloc.timeout = 8; // 8 secs to connect - oc.hConnection = NetLib_OpenConnection(m_hDirectNetlibUser, oc.type == OCT_REVERSE ? "Reverse " : NULL, &nloc); + oc.hConnection = NetLib_OpenConnection(m_hDirectNetlibUser, oc.type == OCT_REVERSE ? "Reverse " : nullptr, &nloc); if (!oc.hConnection && addr2.S_un.S_addr) { // first address failed, try second one if available nloc.szHost = inet_ntoa(addr2); - oc.hConnection = NetLib_OpenConnection(m_hDirectNetlibUser, oc.type == OCT_REVERSE ? "Reverse " : NULL, &nloc); + oc.hConnection = NetLib_OpenConnection(m_hDirectNetlibUser, oc.type == OCT_REVERSE ? "Reverse " : nullptr, &nloc); } if (!oc.hConnection) { if (oc.type == OCT_NORMAL) { // connection failed, try reverse @@ -1321,7 +1321,7 @@ void __cdecl CIcqProto::oft_connectionThread(oscarthreadstartinfo *otsi) { mir_cslock l(oftMutex); if (m_arFileTransfers.indexOf(oc.ft) != -1) - oc.ft->connection = NULL; // release link + oc.ft->connection = nullptr; // release link } // Give server some time for abort/cancel to arrive SleepEx(1000, TRUE); diff --git a/protocols/IcqOscarJ/src/stdpackets.cpp b/protocols/IcqOscarJ/src/stdpackets.cpp index 096fde4896..a29d454ce8 100644 --- a/protocols/IcqOscarJ/src/stdpackets.cpp +++ b/protocols/IcqOscarJ/src/stdpackets.cpp @@ -117,7 +117,7 @@ static void packServDCInfo(icq_packet *p, CIcqProto* ppro, BOOL bEmpty) static void packServChannel2Header(icq_packet *p, CIcqProto* ppro, DWORD dwUin, size_t wLen, DWORD dwID1, DWORD dwID2, DWORD dwCookie, WORD wVersion, BYTE bMsgType, BYTE bMsgFlags, WORD wPriority, int isAck, int includeDcInfo, BYTE bRequestServerAck) { - packServMsgSendHeader(p, dwCookie, dwID1, dwID2, dwUin, NULL, 0x0002, wLen + 95 + (bRequestServerAck ? 4 : 0) + (includeDcInfo ? 14 : 0)); + packServMsgSendHeader(p, dwCookie, dwID1, dwID2, dwUin, nullptr, 0x0002, wLen + 95 + (bRequestServerAck ? 4 : 0) + (includeDcInfo ? 14 : 0)); packWord(p, 0x05); // TLV type packWord(p, WORD(wLen + 91 + (includeDcInfo ? 14 : 0))); /* TLV len */ @@ -236,9 +236,9 @@ void CIcqProto::icq_setidle(int bAllow) void CIcqProto::icq_setstatus(WORD wStatus, const char *szStatusNote) { - char *szCurrentStatusNote = szStatusNote ? getSettingStringUtf(NULL, DBSETTING_STATUS_NOTE, NULL) : NULL; + char *szCurrentStatusNote = szStatusNote ? getSettingStringUtf(NULL, DBSETTING_STATUS_NOTE, nullptr) : nullptr; size_t wStatusMoodLen = 0, wStatusNoteLen = 0, wSessionDataLen = 0; - char *szMoodData = NULL; + char *szMoodData = nullptr; if (szStatusNote && mir_strcmp(szCurrentStatusNote, szStatusNote)) { // status note was changed, update now DBVARIANT dbv = { DBVT_DELETED }; @@ -427,7 +427,7 @@ DWORD CIcqProto::icq_SendChannel4Message(DWORD dwUin, MCONTACT hContact, BYTE bM // Pack the standard header icq_packet packet; - packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, NULL, 4, wPacketLength + wMsgLen); + packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, nullptr, 4, wPacketLength + wMsgLen); // Pack first TLV packWord(&packet, 0x05); // TLV(5) @@ -477,7 +477,7 @@ void CIcqProto::sendOwnerInfoRequest(void) packDWord(&packet, 0x01); packWord(&packet, wDataLen); - packTLVUID(&packet, 0x32, m_dwLocalUIN, NULL); + packTLVUID(&packet, 0x32, m_dwLocalUIN, nullptr); } sendServPacket(&packet); @@ -508,7 +508,7 @@ DWORD CIcqProto::icq_sendGetInfoServ(MCONTACT hContact, DWORD dwUin, int bManual return 0; DBVARIANT infoToken = { DBVT_DELETED }; - BYTE *pToken = NULL; + BYTE *pToken = nullptr; WORD cbToken = 0; if (!getSetting(hContact, DBSETTING_METAINFO_TOKEN, &infoToken)) { // retrieve user details using privacy token @@ -546,7 +546,7 @@ DWORD CIcqProto::icq_sendGetInfoServ(MCONTACT hContact, DWORD dwUin, int bManual packWord(&packet, wDataLen); if (pToken) packTLV(&packet, 0x3C, cbToken, pToken); - packTLVUID(&packet, 0x32, dwUin, NULL); + packTLVUID(&packet, 0x32, dwUin, nullptr); sendServPacket(&packet); @@ -689,7 +689,7 @@ void CIcqProto::icq_sendSetAimAwayMsgServ(const char *szMsg) serverPacketInit(&packet, 19); packFNACHeader(&packet, ICQ_LOCATION_FAMILY, ICQ_LOCATION_SET_USER_INFO, 0, dwCookie); packTLV(&packet, 0x0f, 1, (LPBYTE)"\x02"); - packTLV(&packet, 0x04, 0, NULL); + packTLV(&packet, 0x04, 0, nullptr); } sendServPacket(&packet); @@ -697,7 +697,7 @@ void CIcqProto::icq_sendSetAimAwayMsgServ(const char *szMsg) void CIcqProto::icq_sendFileSendServv7(filetransfer* ft, const char *szFiles) { - char *szFilesAnsi = NULL, *szDescrAnsi = NULL; + char *szFilesAnsi = nullptr, *szDescrAnsi = nullptr; if (!utf8_decode(szFiles, &szFilesAnsi)) szFilesAnsi = _strdup(szFiles); // Legacy fix @@ -728,7 +728,7 @@ void CIcqProto::icq_sendFileSendServv7(filetransfer* ft, const char *szFiles) void CIcqProto::icq_sendFileSendServv8(filetransfer* ft, const char *szFiles, int nAckType) { icq_packet packet; - char *szFilesAnsi = NULL, *szDescrAnsi = NULL; + char *szFilesAnsi = nullptr, *szDescrAnsi = nullptr; if (!utf8_decode(szFiles, &szFilesAnsi)) szFilesAnsi = _strdup(szFiles); // Legacy fix @@ -742,7 +742,7 @@ void CIcqProto::icq_sendFileSendServv8(filetransfer* ft, const char *szFiles, in // 202 + UIN len + file description (no null) + file name (null included) // Packet size = Flap length + 4 size_t wFlapLen = 178 + wDescrLen + wFilesLen + (nAckType == ACKTYPE_SERVER ? 4 : 0); - packServMsgSendHeader(&packet, ft->dwCookie, ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, ft->dwUin, NULL, 2, wFlapLen); + packServMsgSendHeader(&packet, ft->dwCookie, ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, ft->dwUin, nullptr, 2, wFlapLen); // TLV(5) header packServTLV5HeaderMsg(&packet, 138 + wDescrLen + wFilesLen, ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, 1); @@ -783,7 +783,7 @@ void CIcqProto::icq_sendFileSendServv8(filetransfer* ft, const char *szFiles, in void CIcqProto::icq_sendFileAcceptServv8(DWORD dwUin, DWORD TS1, DWORD TS2, DWORD dwCookie, const char *szFiles, const char *szDescr, DWORD dwTotalSize, WORD wPort, BOOL accepted, int nAckType) { icq_packet packet; - char *szFilesAnsi = NULL, *szDescrAnsi = NULL; + char *szFilesAnsi = nullptr, *szDescrAnsi = nullptr; /* if !accepted, szDescr == szReason, szFiles = "" */ @@ -801,7 +801,7 @@ void CIcqProto::icq_sendFileAcceptServv8(DWORD dwUin, DWORD TS1, DWORD TS2, DWOR // 202 + UIN len + file description (no null) + file name (null included) // Packet size = Flap length + 4 size_t wFlapLen = 178 + wDescrLen + wFilesLen + (nAckType == ACKTYPE_SERVER ? 4 : 0); - packServMsgSendHeader(&packet, dwCookie, TS1, TS2, dwUin, NULL, 2, wFlapLen); + packServMsgSendHeader(&packet, dwCookie, TS1, TS2, dwUin, nullptr, 2, wFlapLen); // TLV(5) header packServTLV5HeaderMsg(&packet, 138 + wDescrLen + wFilesLen, TS1, TS2, 2); @@ -842,7 +842,7 @@ void CIcqProto::icq_sendFileAcceptServv8(DWORD dwUin, DWORD TS1, DWORD TS2, DWOR void CIcqProto::icq_sendFileAcceptServv7(DWORD dwUin, DWORD TS1, DWORD TS2, DWORD dwCookie, const char* szFiles, const char* szDescr, DWORD dwTotalSize, WORD wPort, BOOL accepted, int nAckType) { icq_packet packet; - char *szFilesAnsi = NULL, *szDescrAnsi = NULL; + char *szFilesAnsi = nullptr, *szDescrAnsi = nullptr; /* if !accepted, szDescr == szReason, szFiles = "" */ @@ -860,7 +860,7 @@ void CIcqProto::icq_sendFileAcceptServv7(DWORD dwUin, DWORD TS1, DWORD TS2, DWOR // 150 + UIN len + file description (with null) + file name (2 nulls) // Packet size = Flap length + 4 size_t wFlapLen = 127 + wDescrLen + 1 + wFilesLen + (nAckType == ACKTYPE_SERVER ? 4 : 0); - packServMsgSendHeader(&packet, dwCookie, TS1, TS2, dwUin, NULL, 2, wFlapLen); + packServMsgSendHeader(&packet, dwCookie, TS1, TS2, dwUin, nullptr, 2, wFlapLen); // TLV(5) header packServTLV5HeaderMsg(&packet, 88 + wDescrLen + wFilesLen, TS1, TS2, 2); @@ -922,7 +922,7 @@ void CIcqProto::icq_sendFileDenyServ(DWORD dwUin, filetransfer *ft, const char * void CIcqProto::icq_sendAwayMsgReplyServ(DWORD dwUin, DWORD dwMsgID1, DWORD dwMsgID2, WORD wCookie, WORD wVersion, BYTE msgType, char** szMsg) { - MCONTACT hContact = HContactFromUIN(dwUin, NULL); + MCONTACT hContact = HContactFromUIN(dwUin, nullptr); if (validateStatusMessageRequest(hContact, msgType)) { NotifyEventHooks(m_modeMsgsEvent, (WPARAM)msgType, (LPARAM)dwUin); @@ -930,7 +930,7 @@ void CIcqProto::icq_sendAwayMsgReplyServ(DWORD dwUin, DWORD dwMsgID1, DWORD dwMs mir_cslock l(m_modeMsgsMutex); if (szMsg && *szMsg) { - char *pszMsg = NULL; + char *pszMsg = nullptr; WORD wReplyVersion = ICQ_VERSION; if (wVersion >= 9) { @@ -951,7 +951,7 @@ void CIcqProto::icq_sendAwayMsgReplyServ(DWORD dwUin, DWORD dwMsgID1, DWORD dwMs wMsgLen = MAX_MESSAGESNACSIZE; icq_packet packet; - packServAdvancedMsgReply(&packet, dwUin, NULL, dwMsgID1, dwMsgID2, wCookie, wReplyVersion, msgType, 3, wMsgLen + 3); + packServAdvancedMsgReply(&packet, dwUin, nullptr, dwMsgID1, dwMsgID2, wCookie, wReplyVersion, msgType, 3, wMsgLen + 3); packLEWord(&packet, WORD(wMsgLen + 1)); packBuffer(&packet, (LPBYTE)pszMsg, wMsgLen); packByte(&packet, 0); @@ -964,7 +964,7 @@ void CIcqProto::icq_sendAwayMsgReplyServ(DWORD dwUin, DWORD dwMsgID1, DWORD dwMs void CIcqProto::icq_sendAwayMsgReplyServExt(DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, WORD wCookie, WORD wVersion, BYTE msgType, char **szMsg) { - MCONTACT hContact = HContactFromUID(dwUin, szUID, NULL); + MCONTACT hContact = HContactFromUID(dwUin, szUID, nullptr); if (validateStatusMessageRequest(hContact, msgType)) { NotifyEventHooks(m_modeMsgsEvent, (WPARAM)msgType, (LPARAM)dwUin); @@ -972,7 +972,7 @@ void CIcqProto::icq_sendAwayMsgReplyServExt(DWORD dwUin, char *szUID, DWORD dwMs mir_cslock l(m_modeMsgsMutex); if (szMsg && *szMsg) { - char *pszMsg = NULL; + char *pszMsg = nullptr; WORD wReplyVersion = ICQ_VERSION; if (wVersion >= 9) @@ -1021,7 +1021,7 @@ void CIcqProto::icq_sendAwayMsgReplyServExt(DWORD dwUin, char *szUID, DWORD dwMs void CIcqProto::icq_sendAdvancedMsgAck(DWORD dwUin, DWORD dwTimestamp, DWORD dwTimestamp2, WORD wCookie, BYTE bMsgType, BYTE bMsgFlags) { icq_packet packet; - packServAdvancedMsgReply(&packet, dwUin, NULL, dwTimestamp, dwTimestamp2, wCookie, ICQ_VERSION, bMsgType, bMsgFlags, 11); + packServAdvancedMsgReply(&packet, dwUin, nullptr, dwTimestamp, dwTimestamp2, wCookie, ICQ_VERSION, bMsgType, bMsgFlags, 11); packEmptyMsg(&packet); // Status message packMsgColorInfo(&packet); @@ -1073,7 +1073,7 @@ DWORD CIcqProto::SearchByUin(DWORD dwUin) pBuffer.wLen = wInfoLen; // Initialize our handy data buffer - packTLVUID(&pBuffer, 0x32, dwUin, NULL); + packTLVUID(&pBuffer, 0x32, dwUin, nullptr); // Send it off for further packing return sendDirectorySearchPacket(pBuffer.pData, wInfoLen, 0, FALSE); @@ -1088,15 +1088,15 @@ DWORD CIcqProto::SearchByNames(const char *pszNick, const char *pszFirstName, co if (m_bLegacyFix) { // Legacy protocol uses ANSI-string searches - char* pszNickAnsi = NULL; + char* pszNickAnsi = nullptr; if (!utf8_decode(pszNick, &pszNickAnsi)) pszNickAnsi = _strdup(pszNick); - char* pszFirstNameAnsi = NULL; + char* pszFirstNameAnsi = nullptr; if (!utf8_decode(pszFirstName, &pszFirstNameAnsi)) pszFirstNameAnsi = _strdup(pszFirstName); - char* pszLastNameAnsi = NULL; + char* pszLastNameAnsi = nullptr; if (!utf8_decode(pszLastName, &pszLastNameAnsi)) pszLastNameAnsi = _strdup(pszLastName); @@ -1202,7 +1202,7 @@ DWORD CIcqProto::sendDirectorySearchPacket(const BYTE *pSearchData, size_t wData _ASSERTE(wDataLen >= 4); cookie_directory_data *pCookieData = (cookie_directory_data*)SAFE_MALLOC(sizeof(cookie_directory_data)); - if (pCookieData == NULL) + if (pCookieData == nullptr) return 0; pCookieData->bRequestType = DIRECTORYREQUEST_SEARCH; @@ -1264,7 +1264,7 @@ DWORD CIcqProto::sendTLVSearchPacket(BYTE bType, char* pSearchDataBuf, WORD wSea DWORD CIcqProto::icq_sendAdvancedSearchServ(BYTE* fieldsBuffer, size_t bufferLen) { cookie_search *pCookie = (cookie_search*)SAFE_MALLOC(sizeof(cookie_search)); - if (pCookie == 0) + if (pCookie == nullptr) return 0; pCookie->bSearchType = SEARCHTYPE_DETAILS; @@ -1281,7 +1281,7 @@ DWORD CIcqProto::icq_sendAdvancedSearchServ(BYTE* fieldsBuffer, size_t bufferLen DWORD CIcqProto::icq_searchAimByEmail(const char* pszEmail, DWORD dwSearchId) { cookie_search *pCookie; - if (!FindCookie(dwSearchId, NULL, (void**)&pCookie)) { + if (!FindCookie(dwSearchId, nullptr, (void**)&pCookie)) { dwSearchId = 0; pCookie = (cookie_search*)SAFE_MALLOC(sizeof(cookie_search)); pCookie->bSearchType = SEARCHTYPE_EMAIL; @@ -1340,9 +1340,9 @@ DWORD CIcqProto::icq_sendSMSServ(const char *szPhoneNumber, const char *szMsg) { DWORD dwCookie; WORD wBufferLen; - char *szBuffer = NULL; + char *szBuffer = nullptr; char szTime[30]; - time_t now = time(NULL); + time_t now = time(nullptr); strftime(szTime, sizeof(szTime), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&now)); /* Sun, 00 Jan 0000 00:00:00 GMT */ @@ -1571,11 +1571,11 @@ void CIcqProto::icq_sendAuthResponseServ(DWORD dwUin, char* szUid, int auth, con void CIcqProto::icq_sendYouWereAddedServ(DWORD dwUin, DWORD dwMyUin) { - DWORD dwID1 = time(NULL); + DWORD dwID1 = time(nullptr); DWORD dwID2 = RandRange(0, 0x00FF); icq_packet packet; - packServMsgSendHeader(&packet, 0, dwID1, dwID2, dwUin, NULL, 0x0004, 17); + packServMsgSendHeader(&packet, 0, dwID1, dwID2, dwUin, nullptr, 0x0004, 17); packWord(&packet, 0x0005); // TLV(5) packWord(&packet, 0x0009); packLEDWord(&packet, dwMyUin); @@ -1591,7 +1591,7 @@ void CIcqProto::icq_sendXtrazRequestServ(DWORD dwUin, DWORD dwCookie, char* szBo size_t wCoreLen = 11 + getPluginTypeIdLen(pCookieData->bMessageType) + nBodyLen; icq_packet packet; - packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, NULL, 2, 99 + wCoreLen); + packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, nullptr, 2, 99 + wCoreLen); // TLV(5) header packServTLV5HeaderMsg(&packet, 55 + wCoreLen, pCookieData->dwMsgID1, pCookieData->dwMsgID2, 1); @@ -1617,7 +1617,7 @@ void CIcqProto::icq_sendXtrazRequestServ(DWORD dwUin, DWORD dwCookie, char* szBo void CIcqProto::icq_sendXtrazResponseServ(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szBody, size_t nBodyLen, int nType) { icq_packet packet; - packServAdvancedMsgReply(&packet, dwUin, NULL, dwMID, dwMID2, wCookie, ICQ_VERSION, MTYPE_PLUGIN, 0, getPluginTypeIdLen(nType) + 11 + nBodyLen); + packServAdvancedMsgReply(&packet, dwUin, nullptr, dwMID, dwMID2, wCookie, ICQ_VERSION, MTYPE_PLUGIN, 0, getPluginTypeIdLen(nType) + 11 + nBodyLen); packEmptyMsg(&packet); @@ -1634,7 +1634,7 @@ void CIcqProto::icq_sendXtrazResponseServ(DWORD dwUin, DWORD dwMID, DWORD dwMID2 void CIcqProto::icq_sendReverseReq(directconnect *dc, DWORD dwCookie, cookie_message_data *pCookie) { icq_packet packet; - packServMsgSendHeader(&packet, dwCookie, pCookie->dwMsgID1, pCookie->dwMsgID2, dc->dwRemoteUin, NULL, 2, 0x47); + packServMsgSendHeader(&packet, dwCookie, pCookie->dwMsgID1, pCookie->dwMsgID2, dc->dwRemoteUin, nullptr, 2, 0x47); packServTLV5HeaderBasic(&packet, 0x29, pCookie->dwMsgID1, pCookie->dwMsgID2, 0, MCAP_REVERSE_DC_REQ); diff --git a/protocols/IcqOscarJ/src/tlv.cpp b/protocols/IcqOscarJ/src/tlv.cpp index f79e4ee9ea..ad14045898 100644 --- a/protocols/IcqOscarJ/src/tlv.cpp +++ b/protocols/IcqOscarJ/src/tlv.cpp @@ -32,11 +32,11 @@ /* set maxTlvs<=0 to get all TLVs in length, or a positive integer to get at most the first n */ oscar_tlv_chain* readIntoTLVChain(BYTE **buf, size_t wLen, int maxTlvs) { - oscar_tlv_chain *now, *last = NULL, *chain = NULL; + oscar_tlv_chain *now, *last = nullptr, *chain = nullptr; WORD now_tlv_len; if (!buf || !wLen) - return NULL; + return nullptr; intptr_t len = wLen; while (len > 0) { /* don't use unsigned variable for this check */ @@ -44,7 +44,7 @@ oscar_tlv_chain* readIntoTLVChain(BYTE **buf, size_t wLen, int maxTlvs) if (!now) { disposeChain(&chain); - return NULL; + return nullptr; } unpackWord(buf, &(now->tlv.wType)); @@ -53,7 +53,7 @@ oscar_tlv_chain* readIntoTLVChain(BYTE **buf, size_t wLen, int maxTlvs) len -= 4; if (now_tlv_len < 1) - now->tlv.pData = NULL; + now->tlv.pData = nullptr; else if (now_tlv_len <= len) { now->tlv.pData = (BYTE *)SAFE_MALLOC(now_tlv_len); if (now->tlv.pData) @@ -98,7 +98,7 @@ oscar_tlv* oscar_tlv_chain::getTLV(WORD wType, WORD wIndex) list = list->next; } - return NULL; + return nullptr; } WORD oscar_tlv_chain::getChainLength() @@ -141,7 +141,7 @@ oscar_tlv* oscar_tlv_chain::putTLV(WORD wType, size_t wLen, BYTE *pData, BOOL bR oscar_tlv_chain* oscar_tlv_chain::removeTLV(oscar_tlv *pTLV) { - oscar_tlv_chain *list = this, *prev = NULL, *chain = this; + oscar_tlv_chain *list = this, *prev = nullptr, *chain = this; while (list) { if (&list->tlv == pTLV) { if (prev) // relink @@ -151,7 +151,7 @@ oscar_tlv_chain* oscar_tlv_chain::removeTLV(oscar_tlv *pTLV) list = list->next; } else // result is an empty chain (NULL) - chain = NULL; + chain = nullptr; // release chain item memory SAFE_FREE((void**)&list->tlv.pData); SAFE_FREE((void**)&list); @@ -249,14 +249,14 @@ char* oscar_tlv_chain::getString(WORD wType, WORD wIndex) if (pTLV) { char *str = (char*)SAFE_MALLOC(pTLV->wLen + 1); /* For \0 */ if (!str) - return NULL; + return nullptr; memcpy(str, pTLV->pData, pTLV->wLen); str[pTLV->wLen] = '\0'; return str; } - return NULL; + return nullptr; } void disposeChain(oscar_tlv_chain **chain) @@ -273,12 +273,12 @@ void disposeChain(oscar_tlv_chain **chain) now = next; } - *chain = NULL; + *chain = nullptr; } oscar_tlv_record_list* readIntoTLVRecordList(BYTE **buf, size_t wLen, int nCount) { - oscar_tlv_record_list *list = NULL, *last = NULL; + oscar_tlv_record_list *list = nullptr, *last = nullptr; while (wLen >= 2) { WORD wRecordSize; @@ -325,7 +325,7 @@ void disposeRecordList(oscar_tlv_record_list** list) now = next; } - *list = NULL; + *list = nullptr; } oscar_tlv_chain* oscar_tlv_record_list::getRecordByTLV(WORD wType, int nValue) @@ -337,5 +337,5 @@ oscar_tlv_chain* oscar_tlv_record_list::getRecordByTLV(WORD wType, int nValue) list = list->next; } - return NULL; + return nullptr; } diff --git a/protocols/IcqOscarJ/src/upload.cpp b/protocols/IcqOscarJ/src/upload.cpp index 00edab4095..f714c9cecc 100644 --- a/protocols/IcqOscarJ/src/upload.cpp +++ b/protocols/IcqOscarJ/src/upload.cpp @@ -40,7 +40,7 @@ int CIcqProto::StringToListItemId(const char *szSetting,int def) FieldNamesItem *list = (FieldNamesItem*)setting[i].pList; - char *szValue = getSettingStringUtf(NULL, szSetting, NULL); + char *szValue = getSettingStringUtf(NULL, szSetting, nullptr); if (!szValue) return def; diff --git a/protocols/IcqOscarJ/src/userinfotab.cpp b/protocols/IcqOscarJ/src/userinfotab.cpp index 1e25d1215e..67ef1ec9ef 100644 --- a/protocols/IcqOscarJ/src/userinfotab.cpp +++ b/protocols/IcqOscarJ/src/userinfotab.cpp @@ -45,7 +45,7 @@ static void SetValue(CIcqProto* ppro, HWND hwndDlg, int idCtrl, MCONTACT hContac { DBVARIANT dbv = { 0 }; char str[MAX_PATH]; - char* pstr = NULL; + char* pstr = nullptr; int unspecified = 0; int bUtf = 0, bDbv = 0, bAlloc = 0; @@ -73,7 +73,7 @@ static void SetValue(CIcqProto* ppro, HWND hwndDlg, int idCtrl, MCONTACT hContac } } else { - if (szModule == NULL) + if (szModule == nullptr) unspecified = 1; else { unspecified = db_get(hContact, szModule, szSetting, &dbv); @@ -110,8 +110,8 @@ static void SetValue(CIcqProto* ppro, HWND hwndDlg, int idCtrl, MCONTACT hContac BYTE bXStatus = ppro->getContactXStatus(hContact); if (bXStatus) { - char *pXName = ppro->getSettingStringUtf(hContact, DBSETTING_XSTATUS_NAME, NULL); - if (pXName == NULL) // give default name + char *pXName = ppro->getSettingStringUtf(hContact, DBSETTING_XSTATUS_NAME, nullptr); + if (pXName == nullptr) // give default name pXName = ICQTranslateUtf(nameXStatus[bXStatus - 1]); mir_snprintf(str, "%s (%s)", pszStatus, pXName); @@ -153,7 +153,7 @@ static void SetValue(CIcqProto* ppro, HWND hwndDlg, int idCtrl, MCONTACT hContac case DBVT_WCHAR: unspecified = (special == SVS_ZEROISUNSPEC && dbv.pszVal[0] == '\0'); if (!unspecified && pstr != szSetting) { - pstr = ppro->getSettingStringUtf(hContact, szModule, szSetting, NULL); + pstr = ppro->getSettingStringUtf(hContact, szModule, szSetting, nullptr); bUtf = 1; bAlloc = 1; } diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp index 9b5c097550..af26203a66 100644 --- a/protocols/IcqOscarJ/src/utilities.cpp +++ b/protocols/IcqOscarJ/src/utilities.cpp @@ -33,10 +33,10 @@ struct gateway_index static mir_cs gatewayMutex; -static gateway_index *gateways = NULL; +static gateway_index *gateways = nullptr; static int gatewayCount = 0; -static DWORD *spammerList = NULL; +static DWORD *spammerList = nullptr; static int spammerListCount = 0; @@ -232,7 +232,7 @@ char** CIcqProto::MirandaStatusToAwayMsg(int nStatus) return &m_modeMsgs.szFfc; default: - return NULL; + return nullptr; } } @@ -421,7 +421,7 @@ MCONTACT CIcqProto::HContactFromUIN(DWORD dwUin, int *Added) if (Added) *Added = 0; - MCONTACT hContact = HandleFromCacheByUid(dwUin, NULL); + MCONTACT hContact = HandleFromCacheByUid(dwUin, nullptr); if (hContact) return hContact; @@ -431,7 +431,7 @@ MCONTACT CIcqProto::HContactFromUIN(DWORD dwUin, int *Added) dwContactUin = getContactUin(hContact); if (dwContactUin == dwUin) { - AddToContactsCache(hContact, dwUin, NULL); + AddToContactsCache(hContact, dwUin, nullptr); return hContact; } @@ -466,9 +466,9 @@ MCONTACT CIcqProto::HContactFromUIN(DWORD dwUin, int *Added) icq_QueueUser(hContact); if (icqOnline()) - icq_sendNewContact(dwUin, NULL); + icq_sendNewContact(dwUin, nullptr); } - AddToContactsCache(hContact, dwUin, NULL); + AddToContactsCache(hContact, dwUin, nullptr); *Added = 1; debugLogA("ICQ contact %u created ok", dwUin); return hContact; @@ -583,7 +583,7 @@ char* __fastcall strstrnull(const char *str, const char *substr) if (str) return (char*)strstr(str, substr); - return NULL; + return nullptr; } char* __fastcall null_strdup(const char *string) @@ -591,7 +591,7 @@ char* __fastcall null_strdup(const char *string) if (string) return _strdup(string); - return NULL; + return nullptr; } @@ -600,14 +600,14 @@ WCHAR* __fastcall null_strdup(const WCHAR *string) if (string) return wcsdup(string); - return NULL; + return nullptr; } char* __fastcall null_strcpy(char *dest, const char *src, size_t maxlen) { if (!dest) - return NULL; + return nullptr; if (src && src[0]) { strncpy(dest, src, maxlen); @@ -623,7 +623,7 @@ char* __fastcall null_strcpy(char *dest, const char *src, size_t maxlen) WCHAR* __fastcall null_strcpy(WCHAR *dest, const WCHAR *src, size_t maxlen) { if (!dest) - return NULL; + return nullptr; if (src && src[0]) { wcsncpy(dest, src, maxlen); @@ -802,7 +802,7 @@ char* ApplyEncoding(const char *string, const char *pszEncoding) if (string) // consider it CP_ACP return ansi_to_utf8(string); - return NULL; + return nullptr; } void CIcqProto::ResetSettingsOnListReload() @@ -973,7 +973,7 @@ int CIcqProto::IsMetaInfoChanged(MCONTACT hContact) db_free(&infoSaved); - if ((time(NULL) - dwInfoTime) > 14 * 3600 * 24) { + if ((time(nullptr) - dwInfoTime) > 14 * 3600 * 24) { res = 3; // threshold exceeded } } @@ -1015,7 +1015,7 @@ void __cdecl CIcqProto::SetStatusNoteThread(void *pDelay) } rlck.unlock(); - BYTE *pBuffer = NULL; + BYTE *pBuffer = nullptr; size_t cbBuffer = 0; ppackTLV(&pBuffer, &cbBuffer, 0x226, mir_strlen(setStatusNoteText), (BYTE*)setStatusNoteText); @@ -1047,8 +1047,8 @@ void __cdecl CIcqProto::SetStatusNoteThread(void *pDelay) rlck.unlock(); // check if the session data were not updated already - char *szCurrentStatusNote = getSettingStringUtf(NULL, DBSETTING_STATUS_NOTE, NULL); - char *szCurrentStatusMood = NULL; + char *szCurrentStatusNote = getSettingStringUtf(NULL, DBSETTING_STATUS_NOTE, nullptr); + char *szCurrentStatusMood = nullptr; DBVARIANT dbv = { DBVT_DELETED }; if (m_bMoodsEnabled && !getString(DBSETTING_STATUS_MOOD, &dbv)) @@ -1111,7 +1111,7 @@ int CIcqProto::SetStatusNote(const char *szStatusNote, DWORD dwDelay, int bForce mir_cslock l(cookieMutex); if (!setStatusNoteText && (!m_bMoodsEnabled || !setStatusMoodData)) { // check if the status note was changed and if yes, create thread to change it - char *szCurrentStatusNote = getSettingStringUtf(NULL, DBSETTING_STATUS_NOTE, NULL); + char *szCurrentStatusNote = getSettingStringUtf(NULL, DBSETTING_STATUS_NOTE, nullptr); if (mir_strcmp(szCurrentStatusNote, szStatusNote)) { // status note was changed // create thread to change status note on existing server connection @@ -1120,7 +1120,7 @@ int CIcqProto::SetStatusNote(const char *szStatusNote, DWORD dwDelay, int bForce if (dwDelay) ForkThread(&CIcqProto::SetStatusNoteThread, (void*)dwDelay); else // we cannot afford any delay, so do not run in separate thread - SetStatusNoteThread(NULL); + SetStatusNoteThread(nullptr); bChanged = TRUE; } @@ -1147,7 +1147,7 @@ int CIcqProto::SetStatusMood(const char *szMoodData, DWORD dwDelay) mir_cslock l(cookieMutex); if (!setStatusNoteText && !setStatusMoodData) { // check if the status mood was changed and if yes, create thread to change it - char *szCurrentStatusMood = NULL; + char *szCurrentStatusMood = nullptr; DBVARIANT dbv = { DBVT_DELETED }; if (!getString(DBSETTING_STATUS_MOOD, &dbv)) @@ -1159,7 +1159,7 @@ int CIcqProto::SetStatusMood(const char *szMoodData, DWORD dwDelay) if (dwDelay) ForkThread(&CIcqProto::SetStatusNoteThread, (void*)dwDelay); else // we cannot afford any delay, so do not run in separate thread - SetStatusNoteThread(NULL); + SetStatusNoteThread(nullptr); bChanged = TRUE; } @@ -1321,13 +1321,13 @@ void __fastcall SAFE_FREE(void** p) { if (*p) { free(*p); - *p = NULL; + *p = nullptr; } } void* __fastcall SAFE_MALLOC(size_t size) { - void* p = NULL; + void* p = nullptr; if (size) { p = malloc(size); @@ -1388,7 +1388,7 @@ void NetLib_CloseConnection(HNETLIBCONN *hConnection, int bServerConn) { if (*hConnection) { Netlib_CloseHandle(*hConnection); - *hConnection = NULL; + *hConnection = nullptr; if (bServerConn) FreeGatewayIndex(*hConnection); @@ -1400,7 +1400,7 @@ void NetLib_SafeCloseHandle(HANDLE *hConnection) { if (*hConnection) { Netlib_CloseHandle(*hConnection); - *hConnection = NULL; + *hConnection = nullptr; } } @@ -1430,7 +1430,7 @@ int CIcqProto::NetLog_Uni(BOOL bDC, const char *fmt, ...) char* __fastcall ICQTranslateUtf(const char *src) { // this takes UTF-8 strings only!!! - char *szRes = NULL; + char *szRes = nullptr; if (!mir_strlen(src)) { // for the case of empty strings return null_strdup(src); @@ -1467,7 +1467,7 @@ char* CIcqProto::GetUserStoredPassword(char *szBuffer, size_t cbSize) if (mir_strlen(szBuffer)) return szBuffer; - return NULL; + return nullptr; } @@ -1481,7 +1481,7 @@ char* CIcqProto::GetUserPassword(BOOL bAlways) return m_szPassword; } - return NULL; + return nullptr; } @@ -1530,7 +1530,7 @@ const char* ExtractFileName(const char *fullname) const char *szFileName; // already is only filename - if (((szFileName = strrchr(fullname, '\\')) == NULL) && ((szFileName = strrchr(fullname, '/')) == NULL)) + if (((szFileName = strrchr(fullname, '\\')) == nullptr) && ((szFileName = strrchr(fullname, '/')) == nullptr)) return fullname; return szFileName + 1; // skip backslash @@ -1539,7 +1539,7 @@ const char* ExtractFileName(const char *fullname) char* FileNameToUtf(const wchar_t *filename) { - WCHAR *usFileName = NULL; + WCHAR *usFileName = nullptr; int wchars = GetLongPathName(filename, usFileName, 0); usFileName = (WCHAR*)_alloca((wchars + 1) * sizeof(WCHAR)); GetLongPathName(filename, usFileName, wchars); @@ -1702,11 +1702,11 @@ int MessageBoxUtf(HWND hWnd, const char *szText, const char *szCaption, UINT uTy char* CIcqProto::ConvertMsgToUserSpecificAnsi(MCONTACT hContact, const char* szMsg) { // this takes utf-8 encoded message WORD wCP = getWord(hContact, "CodePage", m_wAnsiCodepage); - char* szAnsi = NULL; + char* szAnsi = nullptr; if (wCP != CP_ACP) // convert to proper codepage if (!utf8_decode_codepage(szMsg, &szAnsi, wCP)) - return NULL; + return nullptr; return szAnsi; } -- cgit v1.2.3