From 3d977685e7dbc7b1f5fa3264c8a014b5b5d5ec43 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 23 Aug 2017 15:17:37 +0300 Subject: code cleaning --- protocols/JabberG/src/jabber.cpp | 16 +- protocols/JabberG/src/jabber_adhoc.cpp | 62 ++-- protocols/JabberG/src/jabber_agent.cpp | 28 +- protocols/JabberG/src/jabber_api.cpp | 30 +- protocols/JabberG/src/jabber_archive.cpp | 10 +- protocols/JabberG/src/jabber_bookmarks.cpp | 30 +- protocols/JabberG/src/jabber_byte.cpp | 94 ++--- protocols/JabberG/src/jabber_caps.cpp | 14 +- protocols/JabberG/src/jabber_caps.h | 2 +- protocols/JabberG/src/jabber_captcha.cpp | 22 +- protocols/JabberG/src/jabber_chat.cpp | 114 +++--- protocols/JabberG/src/jabber_console.cpp | 26 +- protocols/JabberG/src/jabber_disco.cpp | 318 ++++++++-------- protocols/JabberG/src/jabber_disco.h | 68 ++-- protocols/JabberG/src/jabber_events.cpp | 34 +- protocols/JabberG/src/jabber_file.cpp | 56 +-- protocols/JabberG/src/jabber_filterlist.cpp | 28 +- protocols/JabberG/src/jabber_form.cpp | 120 +++--- protocols/JabberG/src/jabber_frame.cpp | 34 +- protocols/JabberG/src/jabber_ft.cpp | 72 ++-- protocols/JabberG/src/jabber_groupchat.cpp | 176 ++++----- protocols/JabberG/src/jabber_ibb.cpp | 24 +- protocols/JabberG/src/jabber_icolib.cpp | 36 +- protocols/JabberG/src/jabber_iq.cpp | 22 +- protocols/JabberG/src/jabber_iq.h | 4 +- protocols/JabberG/src/jabber_iq_handlers.cpp | 44 +-- protocols/JabberG/src/jabber_iqid.cpp | 424 +++++++++++----------- protocols/JabberG/src/jabber_iqid_muc.cpp | 80 ++-- protocols/JabberG/src/jabber_list.cpp | 72 ++-- protocols/JabberG/src/jabber_list.h | 2 +- protocols/JabberG/src/jabber_menu.cpp | 110 +++--- protocols/JabberG/src/jabber_message_handlers.cpp | 6 +- protocols/JabberG/src/jabber_message_manager.cpp | 4 +- protocols/JabberG/src/jabber_message_manager.h | 2 +- protocols/JabberG/src/jabber_misc.cpp | 54 +-- protocols/JabberG/src/jabber_notes.cpp | 20 +- protocols/JabberG/src/jabber_omemo.cpp | 28 +- protocols/JabberG/src/jabber_opt.cpp | 90 ++--- protocols/JabberG/src/jabber_opttree.cpp | 8 +- protocols/JabberG/src/jabber_password.cpp | 8 +- protocols/JabberG/src/jabber_presence_manager.h | 2 +- protocols/JabberG/src/jabber_privacy.cpp | 112 +++--- protocols/JabberG/src/jabber_privacy.h | 24 +- protocols/JabberG/src/jabber_proto.cpp | 118 +++--- protocols/JabberG/src/jabber_proto.h | 16 +- protocols/JabberG/src/jabber_rc.cpp | 68 ++-- protocols/JabberG/src/jabber_rc.h | 20 +- protocols/JabberG/src/jabber_search.cpp | 76 ++-- protocols/JabberG/src/jabber_search.h | 22 +- protocols/JabberG/src/jabber_secur.cpp | 38 +- protocols/JabberG/src/jabber_secur.h | 2 +- protocols/JabberG/src/jabber_send_manager.h | 2 +- protocols/JabberG/src/jabber_std.cpp | 4 +- protocols/JabberG/src/jabber_svc.cpp | 70 ++-- protocols/JabberG/src/jabber_thread.cpp | 316 ++++++++-------- protocols/JabberG/src/jabber_treelist.cpp | 12 +- protocols/JabberG/src/jabber_userinfo.cpp | 102 +++--- protocols/JabberG/src/jabber_util.cpp | 137 +++---- protocols/JabberG/src/jabber_vcard.cpp | 60 +-- protocols/JabberG/src/jabber_ws.cpp | 4 +- protocols/JabberG/src/jabber_xml.cpp | 42 +-- protocols/JabberG/src/jabber_xml.h | 16 +- protocols/JabberG/src/jabber_xstatus.cpp | 264 +++++++------- protocols/JabberG/src/jabber_xstatus.h | 2 +- protocols/JabberG/src/jabber_zstream.cpp | 4 +- protocols/JabberG/src/stdafx.h | 6 +- 66 files changed, 1964 insertions(+), 1967 deletions(-) (limited to 'protocols') diff --git a/protocols/JabberG/src/jabber.cpp b/protocols/JabberG/src/jabber.cpp index afb5c05c76..a1573d2e81 100755 --- a/protocols/JabberG/src/jabber.cpp +++ b/protocols/JabberG/src/jabber.cpp @@ -61,10 +61,10 @@ PLUGININFOEX pluginInfo = { }; CLIST_INTERFACE* pcli; -FI_INTERFACE *FIP = NULL; +FI_INTERFACE *FIP = nullptr; -HANDLE hExtraActivity = NULL; -HANDLE hExtraMood = NULL; +HANDLE hExtraActivity = nullptr; +HANDLE hExtraMood = nullptr; HANDLE hExtListInit, hDiscoInfoResult; void JabberUserInfoInit(void); @@ -110,8 +110,8 @@ static int OnModulesLoaded(WPARAM, LPARAM) HookEvent(ME_TTB_MODULELOADED, g_OnToolbarInit); bSecureIM = ServiceExists("SecureIM/IsContactSecured") != 0; - bMirOTR = GetModuleHandle(L"mirotr.dll") != NULL; - bNewGPG = GetModuleHandle(L"new_gpg.dll") != NULL; + bMirOTR = GetModuleHandle(L"mirotr.dll") != nullptr; + bNewGPG = GetModuleHandle(L"new_gpg.dll") != nullptr; #ifdef _WIN64 bPlatform = 1; #else @@ -188,8 +188,8 @@ extern "C" int __declspec(dllexport) Load() pcli = Clist_GetInterface(); INT_PTR result = CallService(MS_IMG_GETINTERFACE, FI_IF_VERSION, (LPARAM)&FIP); - if (FIP == NULL || result != S_OK) { - MessageBoxEx(NULL, TranslateT("Fatal error, image services not found. Jabber Protocol will be disabled."), L"Error", MB_OK | MB_ICONERROR | MB_APPLMODAL, 0); + if (FIP == nullptr || result != S_OK) { + MessageBoxEx(nullptr, TranslateT("Fatal error, image services not found. Jabber Protocol will be disabled."), L"Error", MB_OK | MB_ICONERROR | MB_APPLMODAL, 0); return 1; } @@ -232,7 +232,7 @@ extern "C" int __declspec(dllexport) Unload(void) { JabberUserInfoUninit(); - if (hMsftedit != NULL) + if (hMsftedit != nullptr) FreeLibrary(hMsftedit); DestroyHookableEvent(hExtListInit); diff --git a/protocols/JabberG/src/jabber_adhoc.cpp b/protocols/JabberG/src/jabber_adhoc.cpp index b5112321c1..a2f7a0ebbd 100644 --- a/protocols/JabberG/src/jabber_adhoc.cpp +++ b/protocols/JabberG/src/jabber_adhoc.cpp @@ -48,7 +48,7 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA // convert iqID to dialog hwnd HWND CJabberProto::GetWindowFromIq(CJabberIqInfo *pInfo) { - if (pInfo->GetUserData() != NULL) + if (pInfo->GetUserData() != nullptr) return HWND(pInfo->GetUserData()); return m_hwndCommandWindow; } @@ -134,7 +134,7 @@ int CJabberProto::AdHoc_ExecuteCommand(HWND hwndDlg, wchar_t*, JabberAdHocData* } } - xmlDestroyNode(dat->CommandsNode); dat->CommandsNode = NULL; + xmlDestroyNode(dat->CommandsNode); dat->CommandsNode = nullptr; return TRUE; } @@ -146,8 +146,8 @@ int CJabberProto::AdHoc_OnJAHMCommandListResult(HWND hwndDlg, HXML iqNode, Jabbe if (!type || !mir_wstrcmp(type, L"error")) { // error occurred here wchar_t buff[255]; - const wchar_t *code = NULL; - const wchar_t *description = NULL; + const wchar_t *code = nullptr; + const wchar_t *description = nullptr; HXML errorNode = XmlGetChild(iqNode, "error"); if (errorNode) { @@ -206,17 +206,17 @@ int CJabberProto::AdHoc_OnJAHMProcessResult(HWND hwndDlg, HXML workNode, JabberA dat->curPos = 0; SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, 0, FALSE); - if (workNode == NULL) + if (workNode == nullptr) return TRUE; dat->AdHocNode = xmlCopyNode(workNode); const wchar_t *type; - if ((type = XmlGetAttrValue(workNode, L"type")) == NULL) return TRUE; + if ((type = XmlGetAttrValue(workNode, L"type")) == nullptr) return TRUE; if (!mir_wstrcmp(type, L"result")) { // wParam = node from responder as a result of command execution HXML commandNode, xNode; - if ((commandNode = XmlGetChild(dat->AdHocNode, L"command")) == NULL) + if ((commandNode = XmlGetChild(dat->AdHocNode, L"command")) == nullptr) return TRUE; const wchar_t *status = XmlGetAttrValue(commandNode, L"status"); @@ -247,10 +247,10 @@ int CJabberProto::AdHoc_OnJAHMProcessResult(HWND hwndDlg, HXML workNode, JabberA // check actions HXML actionsNode = XmlGetChild(commandNode, "actions"); - if (actionsNode != NULL) { - ShowDlgItem(hwndDlg, IDC_PREV, (XmlGetChild(actionsNode, "prev") != NULL) ? SW_SHOW : SW_HIDE); - ShowDlgItem(hwndDlg, IDC_NEXT, (XmlGetChild(actionsNode, "next") != NULL) ? SW_SHOW : SW_HIDE); - ShowDlgItem(hwndDlg, IDC_COMPLETE, (XmlGetChild(actionsNode, "complete") != NULL) ? SW_SHOW : SW_HIDE); + if (actionsNode != nullptr) { + ShowDlgItem(hwndDlg, IDC_PREV, (XmlGetChild(actionsNode, "prev") != nullptr) ? SW_SHOW : SW_HIDE); + ShowDlgItem(hwndDlg, IDC_NEXT, (XmlGetChild(actionsNode, "next") != nullptr) ? SW_SHOW : SW_HIDE); + ShowDlgItem(hwndDlg, IDC_COMPLETE, (XmlGetChild(actionsNode, "complete") != nullptr) ? SW_SHOW : SW_HIDE); ShowDlgItem(hwndDlg, IDC_SUBMIT, SW_HIDE); int toEnable[] = { IDC_PREV, IDC_NEXT, IDC_COMPLETE, 0 }; @@ -274,8 +274,8 @@ int CJabberProto::AdHoc_OnJAHMProcessResult(HWND hwndDlg, HXML workNode, JabberA int toHide[] = { IDC_FRAME, IDC_FRAME_TEXT, IDC_VSCROLL, IDC_PREV, IDC_NEXT, IDC_COMPLETE, IDC_SUBMIT, 0}; sttShowControls(hwndDlg, FALSE, toHide); - const wchar_t *code=NULL; - const wchar_t *description=NULL; + const wchar_t *code=nullptr; + const wchar_t *description=nullptr; wchar_t buff[255]; HXML errorNode = XmlGetChild(workNode , "error"); if (errorNode) { @@ -339,7 +339,7 @@ int CJabberProto::AdHoc_AddCommandRadio(HWND hFrame, wchar_t * labelStr, int id, ctrlWidth = min(ctrlWidth, strRect.right - strRect.left + 20); ReleaseDC(hFrame, hdc); - HWND hCtrl = CreateWindowEx(0, L"button", labelStr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON, ctrlOffset, ypos, ctrlWidth, labelHeight, hFrame, (HMENU)id, hInst, NULL); + HWND hCtrl = CreateWindowEx(0, L"button", labelStr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON, ctrlOffset, ypos, ctrlWidth, labelHeight, hFrame, (HMENU)id, hInst, nullptr); SendMessage(hCtrl, WM_SETFONT, (WPARAM)SendMessage(GetParent(hFrame), WM_GETFONT, 0, 0), 0); SendMessage(hCtrl, BM_SETCHECK, value, 0); return (ypos + labelHeight + verticalStep); @@ -411,7 +411,7 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA case IDC_WHITERECT: case IDC_INSTRUCTION: case IDC_TITLE: return (INT_PTR)GetStockObject(WHITE_BRUSH); } - return NULL; + return 0; case WM_COMMAND: switch (LOWORD(wParam)) { @@ -425,10 +425,10 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA if (!dat->AdHocNode && dat->CommandsNode && LOWORD(wParam) == IDC_SUBMIT) return dat->proto->AdHoc_ExecuteCommand(hwndDlg, dat->ResponderJID, dat); else - return dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, NULL); + return dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, nullptr); case IDCLOSE: case IDCANCEL: - xmlDestroyNode(dat->AdHocNode); dat->AdHocNode = NULL; + xmlDestroyNode(dat->AdHocNode); dat->AdHocNode = nullptr; DestroyWindow(hwndDlg); return TRUE; } @@ -453,7 +453,7 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA return TRUE; case WM_VSCROLL: - if (dat != NULL) { + if (dat != nullptr) { int pos = dat->curPos; switch (LOWORD(wParam)) { case SB_LINEDOWN: @@ -478,7 +478,7 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA if (pos < 0) pos = 0; if (dat->curPos != pos) { - ScrollWindow(GetDlgItem(hwndDlg, IDC_FRAME), 0, dat->curPos - pos, NULL, &(dat->frameRect)); + ScrollWindow(GetDlgItem(hwndDlg, IDC_FRAME), 0, dat->curPos - pos, nullptr, &(dat->frameRect)); SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, pos, TRUE); RECT Invalid = dat->frameRect; if (dat->curPos - pos >0) @@ -486,7 +486,7 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA else Invalid.top = Invalid.bottom + (dat->curPos - pos); - RedrawWindow(GetDlgItem(hwndDlg, IDC_FRAME), NULL, NULL, RDW_UPDATENOW | RDW_ALLCHILDREN); + RedrawWindow(GetDlgItem(hwndDlg, IDC_FRAME), nullptr, nullptr, RDW_UPDATENOW | RDW_ALLCHILDREN); dat->curPos = pos; } } @@ -496,12 +496,12 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA JabberFormDestroyUI(GetDlgItem(hwndDlg, IDC_FRAME)); Window_FreeIcon_IcoLib(hwndDlg); - dat->proto->m_hwndCommandWindow = NULL; + dat->proto->m_hwndCommandWindow = nullptr; mir_free(dat->ResponderJID); xmlDestroyNode(dat->CommandsNode); xmlDestroyNode(dat->AdHocNode); mir_free(dat); - dat = NULL; + dat = nullptr; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); break; } @@ -512,10 +512,10 @@ int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM hContact, LPARAM lParam) { int res = -1; - if ((hContact != NULL || lParam != 0) && m_bJabberOnline) { + if ((hContact != 0 || lParam != 0) && m_bJabberOnline) { ptrW szJid(getWStringA(hContact, "jid")); - if (hContact && szJid != NULL) { - JABBER_LIST_ITEM *item = NULL; + if (hContact && szJid != nullptr) { + JABBER_LIST_ITEM *item = nullptr; int selected = 0; wchar_t jid[JABBER_MAX_JID_LEN]; wcsncpy_s(jid, szJid, _TRUNCATE); @@ -527,7 +527,7 @@ int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM hContact, LPARAM lParam) HMENU hMenu = CreatePopupMenu(); for (int i = 0; i < item->arResources.getCount(); i++) AppendMenu(hMenu, MF_STRING, i + 1, item->arResources[i]->m_tszResourceName); - HWND hwndTemp = CreateWindowEx(WS_EX_TOOLWINDOW, L"button", L"PopupMenuHost", 0, 0, 0, 10, 10, NULL, NULL, hInst, NULL); + HWND hwndTemp = CreateWindowEx(WS_EX_TOOLWINDOW, L"button", L"PopupMenuHost", 0, 0, 0, 10, 10, nullptr, nullptr, hInst, nullptr); SetForegroundWindow(hwndTemp); RECT rc; POINT pt; @@ -549,13 +549,13 @@ int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM hContact, LPARAM lParam) } } - if (item == NULL || selected) { - CJabberAdhocStartupParams* pStartupParams = new CJabberAdhocStartupParams(this, jid, NULL); - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FORM), NULL, JabberAdHoc_CommandDlgProc, (LPARAM)pStartupParams); + if (item == nullptr || selected) { + CJabberAdhocStartupParams* pStartupParams = new CJabberAdhocStartupParams(this, jid, nullptr); + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FORM), nullptr, JabberAdHoc_CommandDlgProc, (LPARAM)pStartupParams); } } else if (lParam != 0) - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FORM), NULL, JabberAdHoc_CommandDlgProc, lParam); + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FORM), nullptr, JabberAdHoc_CommandDlgProc, lParam); } return res; } @@ -563,5 +563,5 @@ int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM hContact, LPARAM lParam) void CJabberProto::ContactMenuAdhocCommands(CJabberAdhocStartupParams* param) { if (param) - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FORM), NULL, JabberAdHoc_CommandDlgProc, (LPARAM)param); + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FORM), nullptr, JabberAdHoc_CommandDlgProc, (LPARAM)param); } diff --git a/protocols/JabberG/src/jabber_agent.cpp b/protocols/JabberG/src/jabber_agent.cpp index ba31f2c28d..1f5d30be63 100644 --- a/protocols/JabberG/src/jabber_agent.cpp +++ b/protocols/JabberG/src/jabber_agent.cpp @@ -52,7 +52,7 @@ public: virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_JABBER_REGDLG_UPDATE) { - if ((wchar_t*)lParam == NULL) + if ((wchar_t*)lParam == nullptr) SetDlgItemText(m_hwnd, IDC_REG_STATUS, TranslateT("No message")); else SetDlgItemText(m_hwnd, IDC_REG_STATUS, (wchar_t*)lParam); @@ -68,7 +68,7 @@ public: void OnOk(CCtrlButton*) { - m_proto->m_hwndRegProgress = NULL; + m_proto->m_hwndRegProgress = nullptr; EndDialog(m_hwnd, 0); } }; @@ -91,7 +91,7 @@ public: CJabberDlgBase(_ppro, IDD_FORM, false), m_submit(this, IDC_SUBMIT), m_jid(_jid), - m_agentRegIqNode(NULL) + m_agentRegIqNode(nullptr) { m_submit.OnClick = Callback(this, &CAgentRegDlg::OnSubmit); } @@ -118,7 +118,7 @@ public: { xmlDestroyNode(m_agentRegIqNode); JabberFormDestroyUI(GetDlgItem(m_hwnd, IDC_FRAME)); - m_proto->m_hwndAgentRegInput = NULL; + m_proto->m_hwndAgentRegInput = nullptr; EnableWindow(GetParent(m_hwnd), TRUE); SetActiveWindow(GetParent(m_hwnd)); } @@ -131,7 +131,7 @@ public: case IDC_WHITERECT: case IDC_INSTRUCTION: case IDC_TITLE: return (INT_PTR)GetStockObject(WHITE_BRUSH); default: - return NULL; + return 0; } case WM_JABBER_REGINPUT_ACTIVATE: @@ -141,8 +141,8 @@ public: ShowWindow(GetDlgItem(m_hwnd, IDC_FRAME_TEXT), SW_HIDE); HXML queryNode, xNode; - if ((m_agentRegIqNode = (HXML)lParam) == NULL) return TRUE; - if ((queryNode = XmlGetChild(m_agentRegIqNode , "query")) == NULL) return TRUE; + if ((m_agentRegIqNode = (HXML)lParam) == nullptr) return TRUE; + if ((queryNode = XmlGetChild(m_agentRegIqNode , "query")) == nullptr) return TRUE; RECT rect; @@ -153,7 +153,7 @@ public: GetClientRect(GetDlgItem(m_hwnd, IDC_FRAME), &rect); m_frameHeight = rect.bottom - rect.top; - if ((xNode=XmlGetChild(queryNode , "x")) != NULL) { + if ((xNode=XmlGetChild(queryNode , "x")) != nullptr) { // use new jabber:x:data form if (LPCTSTR ptszInstr = XmlGetText( XmlGetChild(xNode, "instructions"))) JabberFormSetInstruction(m_hwnd, ptszInstr); @@ -165,7 +165,7 @@ public: HJFORMLAYOUT layout_info = JabberFormCreateLayout(hFrame); for (int i=0; ; i++) { HXML n = XmlGetChild(queryNode ,i); - if (n == NULL) + if (n == nullptr) break; if (XmlGetName(n)) { @@ -215,7 +215,7 @@ public: if (pos < 0) pos = 0; if (m_curPos != pos) { - ScrollWindow(GetDlgItem(m_hwnd, IDC_FRAME), 0, m_curPos - pos, NULL, &(m_frameRect)); + ScrollWindow(GetDlgItem(m_hwnd, IDC_FRAME), 0, m_curPos - pos, nullptr, &(m_frameRect)); SetScrollPos(GetDlgItem(m_hwnd, IDC_VSCROLL), SB_CTL, pos, TRUE); m_curPos = pos; } } @@ -228,9 +228,9 @@ public: HXML queryNode, xNode; const wchar_t *from; - if (m_agentRegIqNode == NULL) return; - if ((from = XmlGetAttrValue(m_agentRegIqNode, L"from")) == NULL) return; - if ((queryNode = XmlGetChild(m_agentRegIqNode , "query")) == NULL) return; + if (m_agentRegIqNode == nullptr) return; + if ((from = XmlGetAttrValue(m_agentRegIqNode, L"from")) == nullptr) return; + if ((queryNode = XmlGetChild(m_agentRegIqNode , "query")) == nullptr) return; HWND hFrame = GetDlgItem(m_hwnd, IDC_FRAME); wchar_t *str2 = (wchar_t*)alloca(sizeof(wchar_t) * 128); @@ -239,7 +239,7 @@ public: XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultSetRegister, JABBER_IQ_TYPE_SET, from)); HXML query = iq << XQUERY(JABBER_FEAT_REGISTER); - if ((xNode = XmlGetChild(queryNode , "x")) != NULL) { + if ((xNode = XmlGetChild(queryNode , "x")) != nullptr) { // use new jabber:x:data form HXML n = JabberFormGetData(hFrame, xNode); XmlAddChild(query, n); diff --git a/protocols/JabberG/src/jabber_api.cpp b/protocols/JabberG/src/jabber_api.cpp index fe4247c359..ea3628328c 100644 --- a/protocols/JabberG/src/jabber_api.cpp +++ b/protocols/JabberG/src/jabber_api.cpp @@ -62,10 +62,10 @@ LPTSTR CJabberProto::ContactToJID(MCONTACT hContact) LPTSTR CJabberProto::GetBestResourceName(LPCTSTR jid) { - if (jid == NULL) - return NULL; + if (jid == nullptr) + return nullptr; LPCTSTR p = wcschr(jid, '/'); - if (p == NULL) { + if (p == nullptr) { mir_cslock lck(m_csLists); return mir_wstrdup(ListGetBestClientResourceNamePtr(jid)); } @@ -74,18 +74,18 @@ LPTSTR CJabberProto::GetBestResourceName(LPCTSTR jid) LPTSTR CJabberProto::GetResourceList(LPCTSTR jid) { - if (jid == NULL) - return NULL; + if (jid == nullptr) + return nullptr; mir_cslock lck(m_csLists); - JABBER_LIST_ITEM *item = NULL; - if ((item = ListGetItemPtr(LIST_VCARD_TEMP, jid)) == NULL) + JABBER_LIST_ITEM *item = nullptr; + if ((item = ListGetItemPtr(LIST_VCARD_TEMP, jid)) == nullptr) item = ListGetItemPtr(LIST_ROSTER, jid); - if (item == NULL) - return NULL; + if (item == nullptr) + return nullptr; if (!item->arResources.getCount()) - return NULL; + return nullptr; CMStringW res; for (int i=0; i < item->arResources.getCount(); i++) { @@ -173,7 +173,7 @@ HJHANDLER CJabberProto::AddTemporaryIqHandler(JABBER_HANDLER_FUNC Func, int iIqT sHandlerData *d = (sHandlerData*)malloc(sizeof(sHandlerData)); d->Func = Func; d->pUserData = pUserData; - CJabberIqInfo *pInfo = AddIQ(&CJabberProto::ExternalTempIqHandler, iIqTypes, NULL, 0, iIqId, d, iPriority); + CJabberIqInfo *pInfo = AddIQ(&CJabberProto::ExternalTempIqHandler, iIqTypes, nullptr, 0, iIqId, d, iPriority); if (pInfo && dwTimeout > 0) pInfo->SetTimeout(dwTimeout); return (HJHANDLER)pInfo; @@ -202,7 +202,7 @@ JabberFeatCapPairDynamic *CJabberProto::FindFeature(LPCTSTR szFeature) if (!mir_wstrcmp(m_lstJabberFeatCapPairsDynamic[i]->szFeature, szFeature)) return m_lstJabberFeatCapPairsDynamic[i]; - return NULL; + return nullptr; } int CJabberProto::RegisterFeature(LPCTSTR szFeature, LPCTSTR szDescription) @@ -248,7 +248,7 @@ int CJabberProto::RegisterFeature(LPCTSTR szFeature, LPCTSTR szDescription) fcp = new JabberFeatCapPairDynamic(); fcp->szExt = szExt; // will be deallocated along with other values of JabberFeatCapPairDynamic in CJabberProto destructor fcp->szFeature = mir_wstrdup(szFeature); - fcp->szDescription = szDescription ? mir_wstrdup(szDescription) : NULL; + fcp->szDescription = szDescription ? mir_wstrdup(szDescription) : nullptr; fcp->jcbCap = jcb; m_lstJabberFeatCapPairsDynamic.insert(fcp); } @@ -272,7 +272,7 @@ int CJabberProto::AddFeatures(LPCTSTR szFeatures) JabberFeatCapPairDynamic *fcp = FindFeature(szFeat); // if someone is trying to add one of core features, RegisterFeature() will return false, so we don't have to perform this check here if (!fcp) { // if the feature is not registered yet - if (!RegisterFeature(szFeat, NULL)) + if (!RegisterFeature(szFeat, nullptr)) ret = false; else fcp = FindFeature(szFeat); // update fcp after RegisterFeature() @@ -320,7 +320,7 @@ LPTSTR CJabberProto::GetResourceFeatures(LPCTSTR jid) { JabberCapsBits jcb = GetResourceCapabilites(jid, true); if (jcb & JABBER_RESOURCE_CAPS_ERROR) - return NULL; + return nullptr; mir_cslockfull lck(m_csLists); int i; diff --git a/protocols/JabberG/src/jabber_archive.cpp b/protocols/JabberG/src/jabber_archive.cpp index 53165e64a1..8379e9adad 100644 --- a/protocols/JabberG/src/jabber_archive.cpp +++ b/protocols/JabberG/src/jabber_archive.cpp @@ -58,7 +58,7 @@ void CJabberProto::RetrieveMessageArchive(MCONTACT hContact, JABBER_LIST_ITEM *p void CJabberProto::OnIqResultGetCollectionList(HXML iqNode, CJabberIqInfo*) { const wchar_t *to = XmlGetAttrValue(iqNode, L"to"); - if (to == NULL || mir_wstrcmp(XmlGetAttrValue(iqNode, L"type"), L"result")) + if (to == nullptr || mir_wstrcmp(XmlGetAttrValue(iqNode, L"type"), L"result")) return; HXML list = XmlGetChild(iqNode, "list"); @@ -84,7 +84,7 @@ void CJabberProto::OnIqResultGetCollectionList(HXML iqNode, CJabberIqInfo*) static DWORD dwPreviousTimeStamp = -1; static MCONTACT hPreviousContact = INVALID_CONTACT_ID; -static MEVENT hPreviousDbEvent = NULL; +static MEVENT hPreviousDbEvent = 0; // Returns TRUE if the event already exist in the database BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO& dbei) @@ -141,7 +141,7 @@ BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO& dbei) // find event with another timestamp hExistingDbEvent = db_event_next(hContact, hPreviousDbEvent); - while (hExistingDbEvent != NULL) { + while (hExistingDbEvent != 0) { memset(&dbeiExisting, 0, sizeof(dbeiExisting)); db_event_get(hExistingDbEvent, &dbeiExisting); @@ -161,7 +161,7 @@ BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO& dbei) if (dbei.timestamp <= dwPreviousTimeStamp) { // look back - while (hExistingDbEvent != NULL) { + while (hExistingDbEvent != 0) { memset(&dbeiExisting, 0, sizeof(dbeiExisting)); db_event_get(hExistingDbEvent, &dbeiExisting); @@ -186,7 +186,7 @@ BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO& dbei) } else { // look forward - while (hExistingDbEvent != NULL) { + while (hExistingDbEvent != 0) { memset(&dbeiExisting, 0, sizeof(dbeiExisting)); db_event_get(hExistingDbEvent, &dbeiExisting); diff --git a/protocols/JabberG/src/jabber_bookmarks.cpp b/protocols/JabberG/src/jabber_bookmarks.cpp index d6cfad7b7b..6b553f7af8 100644 --- a/protocols/JabberG/src/jabber_bookmarks.cpp +++ b/protocols/JabberG/src/jabber_bookmarks.cpp @@ -150,7 +150,7 @@ static INT_PTR CALLBACK JabberAddBookmarkDlgProc(HWND hwndDlg, UINT msg, WPARAM break; case WM_DESTROY: - param->ppro->m_hwndJabberAddBookmark = NULL; + param->ppro->m_hwndJabberAddBookmark = nullptr; break; } return FALSE; @@ -196,7 +196,7 @@ private: JabberAddBookmarkDlgParam param; param.ppro = m_proto; - param.m_item = NULL; + param.m_item = nullptr; DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_BOOKMARK_ADD), m_hwnd, JabberAddBookmarkDlgProc, (LPARAM)¶m); } @@ -208,10 +208,10 @@ private: if (iItem < 0) return; wchar_t *address = (wchar_t *)m_lvBookmarks.GetItemData(iItem); - if (address == NULL) return; + if (address == nullptr) return; JABBER_LIST_ITEM *item = m_proto->ListGetItemPtr(LIST_BOOKMARK, address); - if (item == NULL) return; + if (item == nullptr) return; JabberAddBookmarkDlgParam param; param.ppro = m_proto; @@ -227,10 +227,10 @@ private: if (iItem < 0) return; wchar_t *address = (wchar_t *)m_lvBookmarks.GetItemData(iItem); - if (address == NULL) return; + if (address == nullptr) return; JABBER_LIST_ITEM *item = m_proto->ListGetItemPtr(LIST_BOOKMARK, address); - if (item == NULL) return; + if (item == nullptr) return; m_btnAdd.Disable(); m_btnEdit.Disable(); @@ -247,7 +247,7 @@ private: }; CJabberDlgBookmarks::CJabberDlgBookmarks(CJabberProto *proto) : - CSuper(proto, IDD_BOOKMARKS, NULL), + CSuper(proto, IDD_BOOKMARKS, nullptr), m_btnAdd(this, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add")), m_btnEdit(this, IDC_EDIT, SKINICON_OTHER_RENAME, LPGEN("Edit")), m_btnRemove(this, IDC_REMOVE, SKINICON_OTHER_DELETE, LPGEN("Remove")), @@ -292,7 +292,7 @@ void CJabberDlgBookmarks::OnInitDialog() m_lvBookmarks.AddGroup(0, TranslateT("Conferences")); m_lvBookmarks.AddGroup(1, TranslateT("Links")); - Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "bookmarksWnd_"); + Utils_RestoreWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "bookmarksWnd_"); } void CJabberDlgBookmarks::OnClose() @@ -306,14 +306,14 @@ void CJabberDlgBookmarks::OnClose() m_lvBookmarks.GetColumn(2, &lvc); m_proto->setWord("bookmarksWnd_cx2", lvc.cx); - Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "bookmarksWnd_"); + Utils_SaveWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "bookmarksWnd_"); CSuper::OnClose(); } void CJabberDlgBookmarks::OnDestroy() { - m_proto->m_pDlgBookmarks = NULL; + m_proto->m_pDlgBookmarks = nullptr; CSuper::OnDestroy(); } @@ -324,10 +324,10 @@ void CJabberDlgBookmarks::OpenBookmark() if (iItem < 0) return; wchar_t *address = (wchar_t *)m_lvBookmarks.GetItemData(iItem); - if (address == NULL) return; + if (address == nullptr) return; JABBER_LIST_ITEM *item = m_proto->ListGetItemPtr(LIST_BOOKMARK, address); - if (item == NULL) return; + if (item == nullptr) return; if (!mir_wstrcmpi(item->type, L"conference")) { m_lvBookmarks.SetItemState(iItem, 0, LVIS_SELECTED); // Unselect the item @@ -335,7 +335,7 @@ void CJabberDlgBookmarks::OpenBookmark() /* some hack for using bookmark to transport not under XEP-0048 */ if (!wcschr(item->jid, '@')) //the room name is not provided let consider that it is transport and send request to registration - m_proto->RegisterAgent(NULL, item->jid); + m_proto->RegisterAgent(nullptr, item->jid); else { wchar_t *room = NEWWSTR_ALLOCA(item->jid); wchar_t *server = wcschr(room, '@'); @@ -387,7 +387,7 @@ void CJabberDlgBookmarks::OnProtoRefresh(WPARAM, LPARAM) { m_lvBookmarks.DeleteAllItems(); - JABBER_LIST_ITEM *item = NULL; + JABBER_LIST_ITEM *item = nullptr; LISTFOREACH(i, m_proto, LIST_BOOKMARK) { if (item = m_proto->ListGetItemPtrFromIndex(i)) { @@ -443,7 +443,7 @@ int CJabberProto::AddEditBookmark(JABBER_LIST_ITEM *item) JabberAddBookmarkDlgParam param; param.ppro = this; param.m_item = item;//(JABBER_LIST_ITEM*)lParam; - DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_BOOKMARK_ADD), NULL, JabberAddBookmarkDlgProc, (LPARAM)¶m); + DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_BOOKMARK_ADD), nullptr, JabberAddBookmarkDlgProc, (LPARAM)¶m); } return 0; } diff --git a/protocols/JabberG/src/jabber_byte.cpp b/protocols/JabberG/src/jabber_byte.cpp index 512c67197c..c4d36f2549 100644 --- a/protocols/JabberG/src/jabber_byte.cpp +++ b/protocols/JabberG/src/jabber_byte.cpp @@ -36,7 +36,7 @@ JABBER_BYTE_TRANSFER::~JABBER_BYTE_TRANSFER() { filetransfer* pft = ft; if (pft) - pft->jbt = NULL; + pft->jbt = nullptr; mir_free(srcJID); mir_free(dstJID); @@ -97,7 +97,7 @@ void JabberByteSendConnection(HNETLIBCONN hConn, DWORD /*dwRemoteIP*/, void* ext mir_snwprintf(szPort, L"%u", connInfo.wPort); ppro->debugLogA("bytestream_send_connection incoming connection accepted: %s", connInfo.szIpPort); - if ((item = ppro->ListGetItemPtr(LIST_BYTE, szPort)) == NULL) { + if ((item = ppro->ListGetItemPtr(LIST_BYTE, szPort)) == nullptr) { ppro->debugLogA("No bytestream session is currently active, connection closed."); Netlib_CloseHandle(hConn); return; @@ -105,11 +105,11 @@ void JabberByteSendConnection(HNETLIBCONN hConn, DWORD /*dwRemoteIP*/, void* ext jbt = item->jbt; - if ((buffer = (char*)mir_alloc(JABBER_NETWORK_BUFFER_SIZE)) == NULL) { + if ((buffer = (char*)mir_alloc(JABBER_NETWORK_BUFFER_SIZE)) == nullptr) { ppro->debugLogA("bytestream_send cannot allocate network buffer, connection closed."); jbt->state = JBT_ERROR; Netlib_CloseHandle(hConn); - if (jbt->hEvent != NULL) SetEvent(jbt->hEvent); + if (jbt->hEvent != nullptr) SetEvent(jbt->hEvent); return; } @@ -136,14 +136,14 @@ void JabberByteSendConnection(HNETLIBCONN hConn, DWORD /*dwRemoteIP*/, void* ext jbt->hConn = hListen; mir_free(buffer); - if (jbt->hEvent != NULL) + if (jbt->hEvent != nullptr) SetEvent(jbt->hEvent); } void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt) { wchar_t szPort[8]; - HANDLE hEvent = NULL; + HANDLE hEvent = nullptr; int nIqId = 0; debugLogA("Thread started: type=bytestream_send"); @@ -155,10 +155,10 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt) ptrW proxyJid( getWStringA("BsProxyServer")); if (proxyJid) { jbt->bProxyDiscovered = FALSE; - jbt->szProxyHost = NULL; - jbt->szProxyPort = NULL; - jbt->szProxyJid = NULL; - jbt->hProxyEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + jbt->szProxyHost = nullptr; + jbt->szProxyPort = nullptr; + jbt->szProxyJid = nullptr; + jbt->hProxyEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); CJabberIqInfo *pInfo = AddIQ(&CJabberProto::IqResultProxyDiscovery, JABBER_IQ_TYPE_GET, proxyJid, 0, -1, jbt); nIqId = pInfo->GetIqId(); @@ -169,14 +169,14 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt) WaitForSingleObject(jbt->hProxyEvent, INFINITE); m_iqManager.ExpireIq(nIqId); CloseHandle(jbt->hProxyEvent); - jbt->hProxyEvent = NULL; + jbt->hProxyEvent = nullptr; if (jbt->state == JBT_ERROR && !bDirect) { debugLogA("Bytestream proxy failure"); MsgPopup(pInfo->GetHContact(), TranslateT("Bytestream Proxy not available"), proxyJid); jbt->ft->state = FT_DENIED; (this->*jbt->pfnFinal)(FALSE, jbt->ft); - jbt->ft = NULL; + jbt->ft = nullptr; delete jbt; return; } } } @@ -198,13 +198,13 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt) nlb.wPort = 0; // Use user-specified incoming port ranges, if available jbt->hConn = Netlib_BindPort(m_hNetlibUser, &nlb); - if (jbt->hConn == NULL) { + if (jbt->hConn == nullptr) { debugLogA("Cannot allocate port for bytestream_send thread, thread ended."); delete jbt; return; } - if (localAddr == NULL) { + if (localAddr == nullptr) { sockaddr_in sin = {}; sin.sin_family = AF_INET; sin.sin_addr.S_un.S_addr = nlb.dwExternalIP; @@ -214,9 +214,9 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt) mir_snwprintf(szPort, L"%d", nlb.wPort); JABBER_LIST_ITEM *item = ListAdd(LIST_BYTE, szPort); item->jbt = jbt; - hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); jbt->hEvent = hEvent; - jbt->hSendEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + jbt->hSendEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); query << XCHILD(L"streamhost") << XATTR(L"jid", m_ThreadInfo->fullJID) << XATTR(L"host", _A2T(localAddr)) << XATTRI(L"port", nlb.wPort); NETLIBIPLIST* ihaddr = Netlib_GetMyIp(true); @@ -230,8 +230,8 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt) if (jbt->bProxyDiscovered) query << XCHILD(L"streamhost") << XATTR(L"jid", jbt->szProxyJid) << XATTR(L"host", jbt->szProxyHost) << XATTR(L"port", jbt->szProxyPort); - jbt->hProxyEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - jbt->szStreamhostUsed = NULL; + jbt->hProxyEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); + jbt->szStreamhostUsed = nullptr; m_ThreadInfo->send(iq); } @@ -239,21 +239,21 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt) WaitForSingleObject(jbt->hProxyEvent, INFINITE); m_iqManager.ExpireIq(nIqId); CloseHandle(jbt->hProxyEvent); - jbt->hProxyEvent = NULL; + jbt->hProxyEvent = nullptr; if (!jbt->szStreamhostUsed) { if (bDirect) { SetEvent(jbt->hSendEvent); CloseHandle(jbt->hSendEvent); CloseHandle(hEvent); - jbt->hEvent = NULL; - if (jbt->hConn != NULL) + jbt->hEvent = nullptr; + if (jbt->hConn != nullptr) Netlib_CloseHandle(jbt->hConn); - jbt->hConn = NULL; + jbt->hConn = nullptr; ListRemove(LIST_BYTE, szPort); } (this->*jbt->pfnFinal)((jbt->state==JBT_DONE)?TRUE:FALSE, jbt->ft); - jbt->ft = NULL; + jbt->ft = nullptr; // stupid fix: wait for listening thread exit Sleep(100); delete jbt; @@ -266,10 +266,10 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt) SetEvent(jbt->hSendEvent); CloseHandle(jbt->hSendEvent); CloseHandle(hEvent); - jbt->hEvent = NULL; - if (jbt->hConn != NULL) + jbt->hEvent = nullptr; + if (jbt->hConn != nullptr) Netlib_CloseHandle(jbt->hConn); - jbt->hConn = NULL; + jbt->hConn = nullptr; ListRemove(LIST_BYTE, szPort); } ByteSendViaProxy(jbt); @@ -279,12 +279,12 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt) WaitForSingleObject(hEvent, INFINITE); CloseHandle(hEvent); CloseHandle(jbt->hSendEvent); - jbt->hEvent = NULL; + jbt->hEvent = nullptr; (this->*jbt->pfnFinal)((jbt->state == JBT_DONE) ? TRUE : FALSE, jbt->ft); - jbt->ft = NULL; - if (jbt->hConn != NULL) + jbt->ft = nullptr; + if (jbt->hConn != nullptr) Netlib_CloseHandle(jbt->hConn); - jbt->hConn = NULL; + jbt->hConn = nullptr; ListRemove(LIST_BYTE, szPort); } @@ -412,7 +412,7 @@ void CJabberProto::IqResultStreamActivate(HXML iqNode, CJabberIqInfo*) mir_snwprintf(listJid, L"ftproxy_%d", id); JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_FTIQID, listJid); - if (item == NULL) + if (item == nullptr) return; if (!mir_wstrcmp(XmlGetAttrValue(iqNode, L"type"), L"result")) @@ -432,8 +432,8 @@ void CJabberProto::ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt) int datalen, bytesParsed, recvResult; BOOL validStreamhost; - if (jbt == NULL) return; - if ((buffer=(char*)mir_alloc(JABBER_NETWORK_BUFFER_SIZE)) == NULL) { + if (jbt == nullptr) return; + if ((buffer=(char*)mir_alloc(JABBER_NETWORK_BUFFER_SIZE)) == nullptr) { m_ThreadInfo->send( XmlNodeIq(L"error", jbt->iqId, jbt->srcJID) << XCHILD(L"error") << XATTRI(L"code", 406) << XATTR(L"type", L"auth") << XCHILDNS(L"not-acceptable", L"urn:ietf:params:xml:ns:xmpp-stanzas")); @@ -455,7 +455,7 @@ void CJabberProto::ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt) HNETLIBCONN hConn = Netlib_OpenConnection(m_hNetlibUser, &nloc); mir_free((void*)nloc.szHost); - if (hConn != NULL) { + if (hConn != nullptr) { jbt->hConn = hConn; data[0] = 5; @@ -481,7 +481,7 @@ void CJabberProto::ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt) } mir_free(buffer); (this->*jbt->pfnFinal)((jbt->state == JBT_DONE) ? TRUE : FALSE, jbt->ft); - jbt->ft = NULL; + jbt->ft = nullptr; if (!validStreamhost) m_ThreadInfo->send( XmlNodeIq(L"error", jbt->iqId, jbt->srcJID) << XCHILD(L"error") << XATTRI(L"code", 404) << XATTR(L"type", L"cancel") @@ -551,7 +551,7 @@ int CJabberProto::ByteSendProxyParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jb } jbt->state = JBT_SENDING; - jbt->hProxyEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + jbt->hProxyEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); jbt->bStreamActivated = FALSE; int iqId = SerialNext(); @@ -569,7 +569,7 @@ int CJabberProto::ByteSendProxyParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jb WaitForSingleObject(jbt->hProxyEvent, INFINITE); CloseHandle(jbt->hProxyEvent); - jbt->hProxyEvent = NULL; + jbt->hProxyEvent = nullptr; ListRemove(LIST_FTIQID, listJid); @@ -587,8 +587,8 @@ int CJabberProto::ByteSendProxyParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jb void __cdecl CJabberProto::ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt) { - HXML iqNode, queryNode = NULL, n; - const wchar_t *sid = NULL, *from = NULL, *to = NULL, *szId = NULL, *szHost, *szPort, *str; + HXML iqNode, queryNode = nullptr, n; + const wchar_t *sid = nullptr, *from = nullptr, *to = nullptr, *szId = nullptr, *szHost, *szPort, *str; int i; WORD port; char data[3]; @@ -596,7 +596,7 @@ void __cdecl CJabberProto::ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt) int datalen, bytesParsed, recvResult; BOOL validStreamhost = FALSE; - if (jbt == NULL) return; + if (jbt == nullptr) return; Thread_SetName("Jabber: ByteReceiveThread"); jbt->state = JBT_INIT; @@ -611,17 +611,17 @@ void __cdecl CJabberProto::ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt) sid = XmlGetAttrValue(queryNode, L"sid"); } - if (szId && from && to && sid && (n = XmlGetChild(queryNode, "streamhost")) != NULL) { + if (szId && from && to && sid && (n = XmlGetChild(queryNode, "streamhost")) != nullptr) { jbt->iqId = mir_wstrdup(szId); jbt->srcJID = mir_wstrdup(from); jbt->dstJID = mir_wstrdup(to); jbt->sid = mir_wstrdup(sid); if ((buffer = (char*)mir_alloc(JABBER_NETWORK_BUFFER_SIZE))) { - for (i = 1; (n = XmlGetNthChild(queryNode, L"streamhost", i)) != NULL; i++) { - if ((szHost = XmlGetAttrValue(n, L"host")) != NULL && - (szPort = XmlGetAttrValue(n, L"port")) != NULL && - (str = XmlGetAttrValue(n, L"jid")) != NULL) { + for (i = 1; (n = XmlGetNthChild(queryNode, L"streamhost", i)) != nullptr; i++) { + if ((szHost = XmlGetAttrValue(n, L"host")) != nullptr && + (szPort = XmlGetAttrValue(n, L"port")) != nullptr && + (str = XmlGetAttrValue(n, L"jid")) != nullptr) { port = (WORD)_wtoi(szPort); replaceStrW(jbt->streamhostJID, str); @@ -634,7 +634,7 @@ void __cdecl CJabberProto::ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt) HNETLIBCONN hConn = Netlib_OpenConnection(m_hNetlibUser, &nloc); mir_free((void*)nloc.szHost); - if (hConn == NULL) { + if (hConn == nullptr) { debugLogA("bytestream_recv_connection connection failed (%d), try next streamhost", WSAGetLastError()); continue; } @@ -670,7 +670,7 @@ void __cdecl CJabberProto::ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt) } (this->*jbt->pfnFinal)((jbt->state == JBT_DONE) ? TRUE : FALSE, jbt->ft); - jbt->ft = NULL; + jbt->ft = nullptr; if (!validStreamhost && szId && from) { debugLogA("bytestream_recv_connection session not completed"); diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp index c04ea943be..655f0014e3 100755 --- a/protocols/JabberG/src/jabber_caps.cpp +++ b/protocols/JabberG/src/jabber_caps.cpp @@ -76,7 +76,7 @@ const JabberFeatCapPair g_JabberFeatCapPairs[] = { { JABBER_FEAT_ROSTER_EXCHANGE, JABBER_CAPS_ROSTER_EXCHANGE, LPGENW("Supports Roster Exchange") }, { JABBER_FEAT_DIRECT_MUC_INVITE, JABBER_CAPS_DIRECT_MUC_INVITE, LPGENW("Supports direct chat invitations (XEP-0249)") }, { JABBER_FEAT_OMEMO_DEVICELIST_NOTIFY, JABBER_CAPS_OMEMO_DEVICELIST_NOTIFY, LPGENW("Receives information about OMEMO devices") }, - { NULL } + { nullptr } }; const JabberFeatCapPairExt g_JabberFeatCapPairsExt[] = { @@ -95,7 +95,7 @@ const JabberFeatCapPairExt g_JabberFeatCapPairsExt[] = { { szCoreVersion, JABBER_CAPS_MIRANDA_PARTIAL }, { JABBER_EXT_PLATFORMX86, JABBER_CAPS_PLATFORMX86 }, { JABBER_EXT_PLATFORMX64, JABBER_CAPS_PLATFORMX64 }, - { NULL } + { nullptr } }; void CJabberProto::AddDefaultCaps() @@ -199,14 +199,14 @@ void CJabberProto::OnIqResultCapsDiscoInfo(HXML, CJabberIqInfo *pInfo) JabberCapsBits CJabberProto::GetTotalJidCapabilites(const wchar_t *jid) { - if (jid == NULL) + if (jid == nullptr) return JABBER_RESOURCE_CAPS_NONE; wchar_t szBareJid[JABBER_MAX_JID_LEN]; JabberStripJid(jid, szBareJid, _countof(szBareJid)); JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, szBareJid); - if (item == NULL) + if (item == nullptr) item = ListGetItemPtr(LIST_VCARD_TEMP, szBareJid); JabberCapsBits jcbToReturn = JABBER_RESOURCE_CAPS_NONE; @@ -239,7 +239,7 @@ JabberCapsBits CJabberProto::GetResourceCapabilites(const wchar_t *jid, bool app wcsncpy_s(fullJid, jid, _TRUNCATE); pResourceStatus r(ResourceInfoFromJID(fullJid)); - if (r == NULL) + if (r == nullptr) return JABBER_RESOURCE_CAPS_ERROR; // XEP-0115 mode @@ -282,7 +282,7 @@ JabberCapsBits CJabberProto::GetResourceCapabilites(const wchar_t *jid, bool app } } - token = wcstok(NULL, L" "); + token = wcstok(nullptr, L" "); } mir_free(caps); @@ -359,7 +359,7 @@ CJabberClientPartialCaps* CJabberClientCaps::FindByVersion(const wchar_t *szHash CJabberClientPartialCaps* CJabberClientCaps::FindById(int nIqId) { if (!m_pCaps || nIqId == -1) - return NULL; + return nullptr; CJabberClientPartialCaps *pCaps = m_pCaps; while (pCaps) { diff --git a/protocols/JabberG/src/jabber_caps.h b/protocols/JabberG/src/jabber_caps.h index 7b7e5e1069..5ca995db67 100755 --- a/protocols/JabberG/src/jabber_caps.h +++ b/protocols/JabberG/src/jabber_caps.h @@ -312,7 +312,7 @@ struct JabberFeatCapPairExt LPCSTR szService; int Valid() const - { return (szService == NULL) ? true : ServiceExists(szService); + { return (szService == nullptr) ? true : ServiceExists(szService); } }; diff --git a/protocols/JabberG/src/jabber_captcha.cpp b/protocols/JabberG/src/jabber_captcha.cpp index c44879fc96..e75d79fcaa 100644 --- a/protocols/JabberG/src/jabber_captcha.cpp +++ b/protocols/JabberG/src/jabber_captcha.cpp @@ -48,7 +48,7 @@ INT_PTR CALLBACK JabberCaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, params = (CAPTCHA_FORM_PARAMS*)lParam; LPCTSTR hint = params->hint; - if (hint == NULL) + if (hint == nullptr) hint = TranslateT("Enter the text you see"); SetDlgItemText(hwndDlg, IDC_INSTRUCTION, TranslateW(hint)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)params); @@ -62,7 +62,7 @@ INT_PTR CALLBACK JabberCaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, case IDC_TITLE: return (INT_PTR)GetStockObject(WHITE_BRUSH); } - return NULL; + return 0; case WM_PAINT: if (params) { @@ -112,25 +112,25 @@ INT_PTR CALLBACK JabberCaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, bool CJabberProto::ProcessCaptcha(HXML node, HXML parentNode, ThreadData *info) { HXML x = XmlGetChildByTag(node, "x", "xmlns", JABBER_FEAT_DATA_FORMS); - if (x == NULL) + if (x == nullptr) return false; HXML y = XmlGetChildByTag(x, L"field", L"var", L"from"); - if (y == NULL) + if (y == nullptr) return false; - if ((y = XmlGetChild(y, "value")) == NULL) + if ((y = XmlGetChild(y, "value")) == nullptr) return false; CAPTCHA_FORM_PARAMS param; param.fromjid = XmlGetText(y); - if ((y = XmlGetChildByTag(x, L"field", L"var", L"sid")) == NULL) + if ((y = XmlGetChildByTag(x, L"field", L"var", L"sid")) == nullptr) return false; - if ((y = XmlGetChild(y, "value")) == NULL) + if ((y = XmlGetChild(y, "value")) == nullptr) return false; param.sid = XmlGetText(y); - if ((y = XmlGetChildByTag(x, L"field", L"var", L"ocr")) == NULL) + if ((y = XmlGetChildByTag(x, L"field", L"var", L"ocr")) == nullptr) return false; param.hint = XmlGetAttrValue (y, L"label"); @@ -138,12 +138,12 @@ bool CJabberProto::ProcessCaptcha(HXML node, HXML parentNode, ThreadData *info) param.to = XmlGetAttrValue(parentNode, L"to"); param.challenge = XmlGetAttrValue(parentNode, L"id"); HXML o = XmlGetChild(parentNode, "data"); - if (o == NULL || XmlGetText(o) == NULL) + if (o == nullptr || XmlGetText(o) == nullptr) return false; unsigned bufferLen; ptrA buffer((char*)mir_base64_decode( _T2A(XmlGetText(o)), &bufferLen)); - if (buffer == NULL) + if (buffer == nullptr) return false; IMGSRVC_MEMIO memio; @@ -157,7 +157,7 @@ bool CJabberProto::ProcessCaptcha(HXML node, HXML parentNode, ThreadData *info) GetObject(param.bmp, sizeof(bmp), &bmp); param.w = bmp.bmWidth; param.h = bmp.bmHeight; - int res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CAPTCHAFORM), NULL, JabberCaptchaFormDlgProc, (LPARAM)¶m); + int res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CAPTCHAFORM), nullptr, JabberCaptchaFormDlgProc, (LPARAM)¶m); if (mir_wstrcmp(param.Result, L"") == 0 || !res) sendCaptchaError(info, param.from, param.to, param.challenge); else diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index 7223db5d5f..7958016283 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -128,19 +128,19 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM *item) ptrW szNick(JabberNickFromJID(item->jid)); GCSessionInfoBase *si = Chat_NewSession(GCW_CHATROOM, m_szModuleName, item->jid, szNick); - if (si != NULL) { + if (si != nullptr) { item->hContact = si->hContact; if (JABBER_LIST_ITEM *bookmark = ListGetItemPtr(LIST_BOOKMARK, item->jid)) { if (bookmark->name) { ptrW myHandle(db_get_wsa(si->hContact, "CList", "MyHandle")); - if (myHandle == NULL) + if (myHandle == nullptr) db_set_ws(si->hContact, "CList", "MyHandle", bookmark->name); } } ptrW tszNick(getWStringA(si->hContact, "MyNick")); - if (tszNick != NULL) { + if (tszNick != nullptr) { if (!mir_wstrcmp(tszNick, szNick)) delSetting(si->hContact, "MyNick"); else @@ -197,7 +197,7 @@ void CJabberProto::GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus case INFO_AFFILIATION: if (m_options.GcLogAffiliations) { - wchar_t *name = NULL; + wchar_t *name = nullptr; switch (user->m_affiliation) { case AFFILIATION_NONE: name = TranslateT("None"); break; case AFFILIATION_MEMBER: name = TranslateT("Member"); break; @@ -212,7 +212,7 @@ void CJabberProto::GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus case INFO_ROLE: if (m_options.GcLogRoles) { - wchar_t *name = NULL; + wchar_t *name = nullptr; switch (user->m_role) { case ROLE_NONE: name = TranslateT("None"); break; case ROLE_VISITOR: name = TranslateT("Visitor"); break; @@ -245,7 +245,7 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const wchar_t int statusToSet = 0; const wchar_t *szReason = XmlGetText(reason); - if (szReason == NULL) { + if (szReason == nullptr) { if (nStatusCode == 322) szReason = TranslateT("because room is now members-only"); else if (nStatusCode == 301) @@ -253,14 +253,14 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const wchar_t } ptrW myNick(mir_wstrdup(item->nick)); - if (myNick == NULL) + if (myNick == nullptr) myNick = JabberNickFromJID(m_szJabberJID); GCDEST gcd = { m_szModuleName, item->jid }; GCEVENT gce = { &gcd }; gce.ptszNick = nick; gce.ptszUID = resource; - if (jid != NULL) + if (jid != nullptr) gce.ptszUserInfo = jid; gce.ptszText = szReason; if (item->bChatActive == 2) { @@ -313,18 +313,18 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const wchar_t void CJabberProto::GcQuit(JABBER_LIST_ITEM *item, int code, HXML reason) { - wchar_t *szMessage = NULL; + wchar_t *szMessage = nullptr; if (code != 307 && code != 301) { ptrW tszMessage(getWStringA("GcMsgQuit")); - if (tszMessage != NULL) + if (tszMessage != nullptr) szMessage = NEWWSTR_ALLOCA(tszMessage); else szMessage = TranslateW(JABBER_GC_MSG_QUIT); } else { ptrW myNick(JabberNickFromJID(m_szJabberJID)); - GcLogUpdateMemberStatus(item, myNick, myNick, NULL, GC_EVENT_KICK, reason); + GcLogUpdateMemberStatus(item, myNick, myNick, nullptr, GC_EVENT_KICK, reason); } if (code == 200) @@ -389,7 +389,7 @@ static gc_item sttLogListItems[] = { { LPGENW("Change &nickname"), IDM_NICK, MENU_ITEM }, { LPGENW("&Invite a user"), IDM_INVITE, MENU_ITEM }, - { NULL, 0, MENU_SEPARATOR }, + { nullptr, 0, MENU_SEPARATOR }, { LPGENW("&Roles"), IDM_ROLE, MENU_NEWPOPUP }, { LPGENW("&Participant list"), IDM_LST_PARTICIPANT, MENU_POPUPITEM }, @@ -399,7 +399,7 @@ static gc_item sttLogListItems[] = { LPGENW("&Member list"), IDM_LST_MEMBER, MENU_POPUPITEM }, { LPGENW("&Admin list"), IDM_LST_ADMIN, MENU_POPUPITEM }, { LPGENW("&Owner list"), IDM_LST_OWNER, MENU_POPUPITEM }, - { NULL, 0, MENU_POPUPSEPARATOR }, + { nullptr, 0, MENU_POPUPSEPARATOR }, { LPGENW("Outcast list (&ban)"), IDM_LST_BAN, MENU_POPUPITEM }, { LPGENW("&Room options"), 0, MENU_NEWPOPUP }, @@ -408,23 +408,23 @@ static gc_item sttLogListItems[] = { LPGENW("&Configure..."), IDM_CONFIG, MENU_POPUPITEM }, { LPGENW("&Destroy room"), IDM_DESTROY, MENU_POPUPITEM }, - { NULL, 0, MENU_SEPARATOR }, + { nullptr, 0, MENU_SEPARATOR }, { LPGENW("Lin&ks"), 0, MENU_NEWPOPUP }, - { NULL, IDM_LINK0, 0 }, - { NULL, IDM_LINK1, 0 }, - { NULL, IDM_LINK2, 0 }, - { NULL, IDM_LINK3, 0 }, - { NULL, IDM_LINK4, 0 }, - { NULL, IDM_LINK5, 0 }, - { NULL, IDM_LINK6, 0 }, - { NULL, IDM_LINK7, 0 }, - { NULL, IDM_LINK8, 0 }, - { NULL, IDM_LINK9, 0 }, + { nullptr, IDM_LINK0, 0 }, + { nullptr, IDM_LINK1, 0 }, + { nullptr, IDM_LINK2, 0 }, + { nullptr, IDM_LINK3, 0 }, + { nullptr, IDM_LINK4, 0 }, + { nullptr, IDM_LINK5, 0 }, + { nullptr, IDM_LINK6, 0 }, + { nullptr, IDM_LINK7, 0 }, + { nullptr, IDM_LINK8, 0 }, + { nullptr, IDM_LINK9, 0 }, { LPGENW("Copy room &JID"), IDM_CPY_RJID, MENU_ITEM }, { LPGENW("Copy room topic"), IDM_CPY_TOPIC, MENU_ITEM }, - { NULL, 0, MENU_SEPARATOR }, + { nullptr, 0, MENU_SEPARATOR }, { LPGENW("&Send presence"), 0, MENU_NEWPOPUP }, { LPGENW("Online"), IDM_PRESENCE_ONLINE, MENU_POPUPITEM }, @@ -449,18 +449,18 @@ static gc_item sttListItems[] = { LPGENW("&Copy to clipboard"), IDM_RJID_COPY, MENU_POPUPITEM }, { LPGENW("Invite to room"), 0, MENU_NEWPOPUP }, - { NULL, IDM_LINK0, 0 }, - { NULL, IDM_LINK1, 0 }, - { NULL, IDM_LINK2, 0 }, - { NULL, IDM_LINK3, 0 }, - { NULL, IDM_LINK4, 0 }, - { NULL, IDM_LINK5, 0 }, - { NULL, IDM_LINK6, 0 }, - { NULL, IDM_LINK7, 0 }, - { NULL, IDM_LINK8, 0 }, - { NULL, IDM_LINK9, 0 }, - - { NULL, 0, MENU_SEPARATOR }, + { nullptr, IDM_LINK0, 0 }, + { nullptr, IDM_LINK1, 0 }, + { nullptr, IDM_LINK2, 0 }, + { nullptr, IDM_LINK3, 0 }, + { nullptr, IDM_LINK4, 0 }, + { nullptr, IDM_LINK5, 0 }, + { nullptr, IDM_LINK6, 0 }, + { nullptr, IDM_LINK7, 0 }, + { nullptr, IDM_LINK8, 0 }, + { nullptr, IDM_LINK9, 0 }, + + { nullptr, 0, MENU_SEPARATOR }, { LPGENW("Set &role"), IDM_ROLE, MENU_NEWPOPUP }, { LPGENW("&Visitor"), IDM_SET_VISITOR, MENU_POPUPITEM }, @@ -472,11 +472,11 @@ static gc_item sttListItems[] = { LPGENW("&Member"), IDM_SET_MEMBER, MENU_POPUPITEM }, { LPGENW("&Admin"), IDM_SET_ADMIN, MENU_POPUPITEM }, { LPGENW("&Owner"), IDM_SET_OWNER, MENU_POPUPITEM }, - { NULL, 0, MENU_POPUPSEPARATOR }, + { nullptr, 0, MENU_POPUPSEPARATOR }, { LPGENW("Outcast (&ban)"), IDM_SET_BAN, MENU_POPUPITEM }, { LPGENW("&Kick"), IDM_KICK, MENU_ITEM }, - { NULL, 0, MENU_SEPARATOR }, + { nullptr, 0, MENU_SEPARATOR }, { LPGENW("Copy &nickname"), IDM_CPY_NICK, MENU_ITEM }, { LPGENW("Copy real &JID"), IDM_CPY_RJID, MENU_ITEM }, { LPGENW("Copy in-room JID"), IDM_CPY_INROOMJID, MENU_ITEM } @@ -485,17 +485,17 @@ static gc_item sttListItems[] = int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam) { GCMENUITEMS* gcmi = (GCMENUITEMS*)lParam; - if (gcmi == NULL) + if (gcmi == nullptr) return 0; if (mir_strcmpi(gcmi->pszModule, m_szModuleName)) return 0; JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, gcmi->pszID); - if (item == NULL) + if (item == nullptr) return 0; - pResourceStatus me(NULL), him(NULL); + pResourceStatus me(nullptr), him(nullptr); for (int i = 0; i < item->arResources.getCount(); i++) { JABBER_RESOURCE_STATUS *p = item->arResources[i]; if (!mir_wstrcmp(p->m_tszResourceName, item->nick)) @@ -658,7 +658,7 @@ class CGroupchatInviteDlg : public CJabberDlgBase void ResetListOptions(CCtrlClc *) { - m_clc.SetBkBitmap(0, NULL); + m_clc.SetBkBitmap(0, nullptr); m_clc.SetBkColor(GetSysColor(COLOR_WINDOW)); m_clc.SetGreyoutFlags(0); m_clc.SetLeftMargin(4); @@ -683,7 +683,7 @@ class CGroupchatInviteDlg : public CJabberDlgBase public: CGroupchatInviteDlg(CJabberProto *ppro, const wchar_t *room) : - CSuper(ppro, IDD_GROUPCHAT_INVITE, NULL), + CSuper(ppro, IDD_GROUPCHAT_INVITE, nullptr), m_newJids(1), m_btnInvite(this, IDC_INVITE), m_txtNewJid(this, IDC_NEWJID), @@ -768,7 +768,7 @@ public: if (int hItem = SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0)) { if (SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) { ptrW jid(m_proto->getWStringA(hContact, "jid")); - if (jid != NULL) + if (jid != nullptr) InviteUser(jid, text); } } @@ -972,7 +972,7 @@ static INT_PTR CALLBACK sttUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* gch) { pResourceStatus me(item->findResource(item->nick)), him(item->findResource(gch->ptszUID)); - if (him == NULL || me == NULL) + if (him == nullptr || me == nullptr) return; // 1 kick per second, prevents crashes... @@ -992,7 +992,7 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* case IDM_SLAP: if (ppro->m_bJabberOnline) { ptrW szMessage(ppro->getWStringA("GcMsgSlap")); - if (szMessage == NULL) + if (szMessage == nullptr) szMessage = mir_wstrdup(TranslateW(JABBER_GC_MSG_SLAP)); wchar_t buf[256]; @@ -1031,7 +1031,7 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* dat->him = him; dat->item = item; dat->ppro = ppro; - HWND hwndInfo = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_GROUPCHAT_INFO), NULL, sttUserInfoDlgProc, (LPARAM)dat); + HWND hwndInfo = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_GROUPCHAT_INFO), nullptr, sttUserInfoDlgProc, (LPARAM)dat); ShowWindow(hwndInfo, SW_SHOW); } break; @@ -1258,10 +1258,10 @@ static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* g if (item->nick) szBuffer = item->nick; if (ppro->EnterString(szBuffer, szTitle, ESF_COMBO, "gcNick_")) { - if (ppro->ListGetItemPtr(LIST_CHATROOM, gch->pDest->ptszID) != NULL) { + if (ppro->ListGetItemPtr(LIST_CHATROOM, gch->pDest->ptszID) != nullptr) { wchar_t text[1024]; mir_snwprintf(text, L"%s/%s", gch->pDest->ptszID, szBuffer.c_str()); - ppro->SendPresenceTo(ppro->m_iStatus == ID_STATUS_INVISIBLE ? ID_STATUS_ONLINE : ppro->m_iStatus, text, NULL); + ppro->SendPresenceTo(ppro->m_iStatus == ID_STATUS_INVISIBLE ? ID_STATUS_ONLINE : ppro->m_iStatus, text, nullptr); } } break; @@ -1278,9 +1278,9 @@ static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* g case IDM_BOOKMARKS: item = ppro->ListGetItemPtr(LIST_BOOKMARK, gch->pDest->ptszID); - if (item == NULL) { + if (item == nullptr) { item = ppro->ListGetItemPtr(LIST_CHATROOM, gch->pDest->ptszID); - if (item != NULL) { + if (item != nullptr) { item->type = L"conference"; MCONTACT hContact = ppro->HContactFromJID(item->jid); item->name = pcli->pfnGetContactDisplayName(hContact, 0); @@ -1298,7 +1298,7 @@ static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* g // fall through case IDM_LEAVE: - ppro->GcQuit(item, 200, NULL); + ppro->GcQuit(item, 200, nullptr); break; case IDM_PRESENCE_ONLINE: @@ -1346,8 +1346,8 @@ static void sttSendPrivateMessage(CJabberProto *ppro, JABBER_LIST_ITEM *item, co { wchar_t szFullJid[JABBER_MAX_JID_LEN]; mir_snwprintf(szFullJid, L"%s/%s", item->jid, nick); - MCONTACT hContact = ppro->DBCreateContact(szFullJid, NULL, true, false); - if (hContact != NULL) { + MCONTACT hContact = ppro->DBCreateContact(szFullJid, nullptr, true, false); + if (hContact != 0) { pResourceStatus r(item->findResource(nick)); if (r) ppro->setWord(hContact, "Status", r->m_iStatus); @@ -1365,14 +1365,14 @@ static void sttSendPrivateMessage(CJabberProto *ppro, JABBER_LIST_ITEM *item, co int CJabberProto::JabberGcEventHook(WPARAM, LPARAM lParam) { GCHOOK *gch = (GCHOOK*)lParam; - if (gch == NULL) + if (gch == nullptr) return 0; if (mir_strcmpi(gch->pDest->pszModule, m_szModuleName)) return 0; JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, gch->pDest->ptszID); - if (item == NULL) + if (item == nullptr) return 0; switch (gch->pDest->iType) { diff --git a/protocols/JabberG/src/jabber_console.cpp b/protocols/JabberG/src/jabber_console.cpp index 9dc74723a2..c6646f52c7 100644 --- a/protocols/JabberG/src/jabber_console.cpp +++ b/protocols/JabberG/src/jabber_console.cpp @@ -128,14 +128,14 @@ bool CJabberProto::FilterXml(HXML node, DWORD flags) case TFilterInfo::T_JID: attrValue = XmlGetAttrValue(node, (flags & JCPF_OUT) ? L"to" : L"from"); if (attrValue) - return JabberStrIStr(attrValue, m_filterInfo.pattern) != NULL; + return JabberStrIStr(attrValue, m_filterInfo.pattern) != nullptr; break; case TFilterInfo::T_XMLNS: if (XmlGetChildCount(node)) { attrValue = XmlGetAttrValue(XmlGetChild(node, 0), L"xmlns"); if (attrValue) - return JabberStrIStr(attrValue, m_filterInfo.pattern) != NULL; + return JabberStrIStr(attrValue, m_filterInfo.pattern) != nullptr; } break; @@ -271,7 +271,7 @@ DWORD CALLBACK sttStreamInCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, L static void sttJabberConsoleRebuildStrings(CJabberProto *ppro, HWND hwndCombo) { - JABBER_LIST_ITEM *item = NULL; + JABBER_LIST_ITEM *item = nullptr; int len = GetWindowTextLength(hwndCombo) + 1; wchar_t *buf = (wchar_t *)_alloca(len * sizeof(wchar_t)); @@ -328,7 +328,7 @@ protected: }; CJabberDlgConsole::CJabberDlgConsole(CJabberProto *proto): - CJabberDlgBase(proto, IDD_CONSOLE, NULL) + CJabberDlgBase(proto, IDD_CONSOLE, nullptr) { } @@ -347,7 +347,7 @@ void CJabberDlgConsole::OnInitDialog() *m_proto->m_filterInfo.pattern = 0; ptrW tszPattern( m_proto->getWStringA("consoleWnd_fpattern")); - if (tszPattern != NULL) + if (tszPattern != nullptr) mir_wstrncpy(m_proto->m_filterInfo.pattern, tszPattern, _countof(m_proto->m_filterInfo.pattern)); sttJabberConsoleRebuildStrings(m_proto, GetDlgItem(m_hwnd, IDC_CB_FILTER)); @@ -388,7 +388,7 @@ void CJabberDlgConsole::OnInitDialog() EnableWindow(GetDlgItem(m_hwnd, IDC_CB_FILTER), (m_proto->m_filterInfo.type == TFilterInfo::T_OFF) ? FALSE : TRUE); EnableWindow(GetDlgItem(m_hwnd, IDC_BTN_FILTER_REFRESH), (m_proto->m_filterInfo.type == TFilterInfo::T_OFF) ? FALSE : TRUE); - Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "consoleWnd_"); + Utils_RestoreWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "consoleWnd_"); } void CJabberDlgConsole::OnClose() @@ -399,7 +399,7 @@ void CJabberDlgConsole::OnClose() m_proto->setByte("consoleWnd_ftype", m_proto->m_filterInfo.type); m_proto->setWString("consoleWnd_fpattern", m_proto->m_filterInfo.pattern); - Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "consoleWnd_"); + Utils_SaveWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "consoleWnd_"); DestroyWindow(m_hwnd); CSuper::OnClose(); } @@ -412,7 +412,7 @@ void CJabberDlgConsole::OnDestroy() IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, 0)); IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER_REFRESH, BM_SETIMAGE, IMAGE_ICON, 0)); - m_proto->m_pDlgConsole = NULL; + m_proto->m_pDlgConsole = nullptr; CSuper::OnDestroy(); } @@ -450,7 +450,7 @@ void CJabberDlgConsole::OnProtoRefresh(WPARAM, LPARAM lParam) else SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_SETSCROLLPOS, 0, (LPARAM)&ptScroll); SendDlgItemMessage(m_hwnd, IDC_CONSOLE, WM_SETREDRAW, TRUE, 0); - InvalidateRect(GetDlgItem(m_hwnd, IDC_CONSOLE), NULL, FALSE); + InvalidateRect(GetDlgItem(m_hwnd, IDC_CONSOLE), nullptr, FALSE); } int CJabberDlgConsole::Resizer(UTILRESIZECONTROL *urc) @@ -505,7 +505,7 @@ INT_PTR CJabberDlgConsole::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) GetDlgItemText(m_hwnd, IDC_CONSOLEIN, textToSend, length); int bytesProcessed = 0; - XmlNode xmlTmp(textToSend, &bytesProcessed, NULL); + XmlNode xmlTmp(textToSend, &bytesProcessed, nullptr); if (xmlTmp) m_proto->m_ThreadInfo->send(xmlTmp); else { @@ -572,7 +572,7 @@ INT_PTR CJabberDlgConsole::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) RECT rc; GetWindowRect(GetDlgItem(m_hwnd, IDC_BTN_FILTER), &rc); CheckDlgButton(m_hwnd, IDC_BTN_FILTER, BST_CHECKED); - int res = TrackPopupMenu(hMenu, TPM_RETURNCMD | TPM_BOTTOMALIGN, rc.left, rc.top, 0, m_hwnd, NULL); + int res = TrackPopupMenu(hMenu, TPM_RETURNCMD | TPM_BOTTOMALIGN, rc.left, rc.top, 0, m_hwnd, nullptr); CheckDlgButton(m_hwnd, IDC_BTN_FILTER, BST_UNCHECKED); DestroyMenu(hMenu); @@ -599,7 +599,7 @@ void __cdecl CJabberProto::ConsoleThread(void*) Thread_SetName("Jabber: ConsoleThread"); MSG msg; - while (GetMessage(&msg, NULL, 0, 0)) { + while (GetMessage(&msg, nullptr, 0, 0)) { if (msg.message == WM_CREATECONSOLE) { m_pDlgConsole = new CJabberDlgConsole(this); m_pDlgConsole->Show(); @@ -625,7 +625,7 @@ void CJabberProto::ConsoleUninit() TerminateThread(m_hThreadConsole, 0); } CloseHandle(m_hThreadConsole); - m_hThreadConsole = NULL; + m_hThreadConsole = nullptr; } m_filterInfo.iq = m_filterInfo.msg = m_filterInfo.presence = FALSE; diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp index 63a2aee6a3..1c74eb3ac9 100644 --- a/protocols/JabberG/src/jabber_disco.cpp +++ b/protocols/JabberG/src/jabber_disco.cpp @@ -63,106 +63,106 @@ static struct } sttNodeIcons[] = { // standard identities: http://www.xmpp.org/registrar/disco-categories.html#directory - // {NULL, L"account", L"admin", NULL, 0}, - // {NULL, L"account", L"anonymous", NULL, 0}, - // {NULL, L"account", L"registered", NULL, 0}, - {NULL, L"account", NULL, NULL, SKINICON_STATUS_ONLINE}, - - // {NULL, L"auth", L"cert", NULL, 0}, - // {NULL, L"auth", L"generic", NULL, 0}, - // {NULL, L"auth", L"ldap", NULL, 0}, - // {NULL, L"auth", L"ntlm", NULL, 0}, - // {NULL, L"auth", L"pam", NULL, 0}, - // {NULL, L"auth", L"radius", NULL, 0}, - {NULL, L"auth", NULL, "key", 0}, - - /// {NULL, L"automation", L"command-list", NULL, 0}, - /// {NULL, L"automation", L"command-node", NULL, 0}, - // {NULL, L"automation", L"rpc", NULL, 0}, - // {NULL, L"automation", L"soap", NULL, 0}, - {NULL, L"automation", NULL, "adhoc", 0}, - - // {NULL, L"client", L"bot", NULL, 0}, - // {NULL, L"client", L"console", NULL, 0}, - // {NULL, L"client", L"handheld", NULL, 0}, - // {NULL, L"client", L"pc", NULL, 0}, - // {NULL, L"client", L"phone", NULL, 0}, - // {NULL, L"client", L"web", NULL, 0}, - {NULL, L"client", NULL, NULL, SKINICON_STATUS_ONLINE}, - - // {NULL, L"collaboration", L"whiteboard", NULL, 0}, - {NULL, L"collaboration", NULL, "group", 0}, - - // {NULL, L"component", L"archive", NULL, 0}, - // {NULL, L"component", L"c2s", NULL, 0}, - // {NULL, L"component", L"generic", NULL, 0}, - // {NULL, L"component", L"load", NULL, 0}, - // {NULL, L"component", L"log", NULL, 0}, - // {NULL, L"component", L"presence", NULL, 0}, - // {NULL, L"component", L"router", NULL, 0}, - // {NULL, L"component", L"s2s", NULL, 0}, - // {NULL, L"component", L"sm", NULL, 0}, - // {NULL, L"component", L"stats", NULL, 0}, - - // {NULL, L"conference", L"irc", NULL, 0}, - // {NULL, L"conference", L"text", NULL, 0}, - {NULL, L"conference", NULL, "group", 0}, - - {NULL, L"directory", L"chatroom", "group", 0}, - {NULL, L"directory", L"group", "group", 0}, - {NULL, L"directory", L"user", NULL, SKINICON_OTHER_FINDUSER}, - // {NULL, L"directory", L"waitinglist", NULL, 0}, - {NULL, L"directory", NULL, NULL, SKINICON_OTHER_SEARCHALL}, - - {NULL, L"gateway", L"aim", "AIM", SKINICON_STATUS_ONLINE}, - {NULL, L"gateway", L"gadu-gadu", "GG", SKINICON_STATUS_ONLINE}, - // {NULL, L"gateway", L"http-ws", NUL, 0}, - {NULL, L"gateway", L"icq", "ICQ", SKINICON_STATUS_ONLINE}, - {NULL, L"gateway", L"msn", "MSN", SKINICON_STATUS_ONLINE}, - {NULL, L"gateway", L"qq", "QQ", SKINICON_STATUS_ONLINE}, - // {NULL, L"gateway", L"sms", NULL, 0}, - // {NULL, L"gateway", L"smtp", NULL, 0}, - {NULL, L"gateway", L"tlen", "TLEN", SKINICON_STATUS_ONLINE}, - {NULL, L"gateway", L"yahoo", "YAHOO", SKINICON_STATUS_ONLINE}, - {NULL, L"gateway", NULL, "Agents", 0}, - - // {NULL, L"headline", L"newmail", NULL, 0}, - {NULL, L"headline", L"rss", "node_rss", 0}, - {NULL, L"headline", L"weather", "node_weather", 0}, - - // {NULL, L"hierarchy", L"branch", NULL, 0}, - // {NULL, L"hierarchy", L"leaf", NULL, 0}, - - // {NULL, L"proxy", L"bytestreams", NULL, 0}, - {NULL, L"proxy", NULL, NULL, SKINICON_EVENT_FILE}, - - // {NULL, L"pubsub", L"collection", NULL, 0}, - // {NULL, L"pubsub", L"leaf", NULL, 0}, - // {NULL, L"pubsub", L"pep", NULL, 0}, - // {NULL, L"pubsub", L"service", NULL, 0}, - - // {NULL, L"server", L"im", NULL, 0}, - {NULL, L"server", NULL, "node_server", 0}, - - // {NULL, L"store", L"berkeley", NULL, 0}, - /// {NULL, L"store", L"file", NULL, 0}, - // {NULL, L"store", L"generic", NULL, 0}, - // {NULL, L"store", L"ldap", NULL, 0}, - // {NULL, L"store", L"mysql", NULL, 0}, - // {NULL, L"store", L"oracle", NULL, 0}, - // {NULL, L"store", L"postgres", NULL, 0}, - {NULL, L"store", NULL, "node_store", 0}, + // {nullptr, L"account", L"admin", nullptr, 0}, + // {nullptr, L"account", L"anonymous", nullptr, 0}, + // {nullptr, L"account", L"registered", nullptr, 0}, + {nullptr, L"account", nullptr, nullptr, SKINICON_STATUS_ONLINE}, + + // {nullptr, L"auth", L"cert", nullptr, 0}, + // {nullptr, L"auth", L"generic", nullptr, 0}, + // {nullptr, L"auth", L"ldap", nullptr, 0}, + // {nullptr, L"auth", L"ntlm", nullptr, 0}, + // {nullptr, L"auth", L"pam", nullptr, 0}, + // {nullptr, L"auth", L"radius", nullptr, 0}, + {nullptr, L"auth", nullptr, "key", 0}, + + /// {nullptr, L"automation", L"command-list", nullptr, 0}, + /// {nullptr, L"automation", L"command-node", nullptr, 0}, + // {nullptr, L"automation", L"rpc", nullptr, 0}, + // {nullptr, L"automation", L"soap", nullptr, 0}, + {nullptr, L"automation", nullptr, "adhoc", 0}, + + // {nullptr, L"client", L"bot", nullptr, 0}, + // {nullptr, L"client", L"console", nullptr, 0}, + // {nullptr, L"client", L"handheld", nullptr, 0}, + // {nullptr, L"client", L"pc", nullptr, 0}, + // {nullptr, L"client", L"phone", nullptr, 0}, + // {nullptr, L"client", L"web", nullptr, 0}, + {nullptr, L"client", nullptr, nullptr, SKINICON_STATUS_ONLINE}, + + // {nullptr, L"collaboration", L"whiteboard", nullptr, 0}, + {nullptr, L"collaboration", nullptr, "group", 0}, + + // {nullptr, L"component", L"archive", nullptr, 0}, + // {nullptr, L"component", L"c2s", nullptr, 0}, + // {nullptr, L"component", L"generic", nullptr, 0}, + // {nullptr, L"component", L"load", nullptr, 0}, + // {nullptr, L"component", L"log", nullptr, 0}, + // {nullptr, L"component", L"presence", nullptr, 0}, + // {nullptr, L"component", L"router", nullptr, 0}, + // {nullptr, L"component", L"s2s", nullptr, 0}, + // {nullptr, L"component", L"sm", nullptr, 0}, + // {nullptr, L"component", L"stats", nullptr, 0}, + + // {nullptr, L"conference", L"irc", nullptr, 0}, + // {nullptr, L"conference", L"text", nullptr, 0}, + {nullptr, L"conference", nullptr, "group", 0}, + + {nullptr, L"directory", L"chatroom", "group", 0}, + {nullptr, L"directory", L"group", "group", 0}, + {nullptr, L"directory", L"user", nullptr, SKINICON_OTHER_FINDUSER}, + // {nullptr, L"directory", L"waitinglist", nullptr, 0}, + {nullptr, L"directory", nullptr, nullptr, SKINICON_OTHER_SEARCHALL}, + + {nullptr, L"gateway", L"aim", "AIM", SKINICON_STATUS_ONLINE}, + {nullptr, L"gateway", L"gadu-gadu", "GG", SKINICON_STATUS_ONLINE}, + // {nullptr, L"gateway", L"http-ws", NUL, 0}, + {nullptr, L"gateway", L"icq", "ICQ", SKINICON_STATUS_ONLINE}, + {nullptr, L"gateway", L"msn", "MSN", SKINICON_STATUS_ONLINE}, + {nullptr, L"gateway", L"qq", "QQ", SKINICON_STATUS_ONLINE}, + // {nullptr, L"gateway", L"sms", nullptr, 0}, + // {nullptr, L"gateway", L"smtp", nullptr, 0}, + {nullptr, L"gateway", L"tlen", "TLEN", SKINICON_STATUS_ONLINE}, + {nullptr, L"gateway", L"yahoo", "YAHOO", SKINICON_STATUS_ONLINE}, + {nullptr, L"gateway", nullptr, "Agents", 0}, + + // {nullptr, L"headline", L"newmail", nullptr, 0}, + {nullptr, L"headline", L"rss", "node_rss", 0}, + {nullptr, L"headline", L"weather", "node_weather", 0}, + + // {nullptr, L"hierarchy", L"branch", nullptr, 0}, + // {nullptr, L"hierarchy", L"leaf", nullptr, 0}, + + // {nullptr, L"proxy", L"bytestreams", nullptr, 0}, + {nullptr, L"proxy", nullptr, nullptr, SKINICON_EVENT_FILE}, + + // {nullptr, L"pubsub", L"collection", nullptr, 0}, + // {nullptr, L"pubsub", L"leaf", nullptr, 0}, + // {nullptr, L"pubsub", L"pep", nullptr, 0}, + // {nullptr, L"pubsub", L"service", nullptr, 0}, + + // {nullptr, L"server", L"im", nullptr, 0}, + {nullptr, L"server", nullptr, "node_server", 0}, + + // {nullptr, L"store", L"berkeley", nullptr, 0}, + /// {nullptr, L"store", L"file", nullptr, 0}, + // {nullptr, L"store", L"generic", nullptr, 0}, + // {nullptr, L"store", L"ldap", nullptr, 0}, + // {nullptr, L"store", L"mysql", nullptr, 0}, + // {nullptr, L"store", L"oracle", nullptr, 0}, + // {nullptr, L"store", L"postgres", nullptr, 0}, + {nullptr, L"store", nullptr, "node_store", 0}, // icons for non-standard identities - {NULL, L"x-service", L"x-rss", "node_rss", 0}, - {NULL, L"application", L"x-weather", "node_weather", 0}, - {NULL, L"user", NULL, NULL, SKINICON_STATUS_ONLINE}, + {nullptr, L"x-service", L"x-rss", "node_rss", 0}, + {nullptr, L"application", L"x-weather", "node_weather", 0}, + {nullptr, L"user", nullptr, nullptr, SKINICON_STATUS_ONLINE}, // icon suggestions based on supported features - {L"jabber:iq:gateway", NULL, NULL, "Agents", 0}, - {L"jabber:iq:search", NULL, NULL, NULL, SKINICON_OTHER_FINDUSER}, - { JABBER_FEAT_COMMANDS, NULL, NULL, "adhoc", 0}, - { JABBER_FEAT_REGISTER, NULL, NULL, "key", 0}, + {L"jabber:iq:gateway", nullptr, nullptr, "Agents", 0}, + {L"jabber:iq:search", nullptr, nullptr, nullptr, SKINICON_OTHER_FINDUSER}, + { JABBER_FEAT_COMMANDS, nullptr, nullptr, "adhoc", 0}, + { JABBER_FEAT_REGISTER, nullptr, nullptr, "key", 0}, }; static void sttApplyNodeIcon(HTREELISTITEM hItem, CJabberSDNode *pNode); @@ -176,19 +176,19 @@ void CJabberProto::OnIqResultServiceDiscoveryInfo(HXML iqNode, CJabberIqInfo *pI if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) { HXML query = XmlGetChild(iqNode, "query"); - if (query == NULL) + if (query == nullptr) pNode->SetInfoRequestId(JABBER_DISCO_RESULT_ERROR); else { HXML feature; int i; - for (i = 1; (feature = XmlGetNthChild(query, L"feature", i)) != NULL; i++) + for (i = 1; (feature = XmlGetNthChild(query, L"feature", i)) != nullptr; i++) pNode->AddFeature(XmlGetAttrValue(feature, L"var")); HXML identity; - for (i = 1; (identity = XmlGetNthChild(query, L"identity", i)) != NULL; i++) + for (i = 1; (identity = XmlGetNthChild(query, L"identity", i)) != nullptr; i++) pNode->AddIdentity(XmlGetAttrValue(identity, L"category"), XmlGetAttrValue(identity, L"type"), XmlGetAttrValue(identity, L"name")); pNode->SetInfoRequestId(JABBER_DISCO_RESULT_OK); - pNode->SetInfoRequestErrorText(NULL); + pNode->SetInfoRequestErrorText(nullptr); } } else { @@ -220,15 +220,15 @@ void CJabberProto::OnIqResultServiceDiscoveryItems(HXML iqNode, CJabberIqInfo *p if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) { HXML query = XmlGetChild(iqNode, "query"); - if (query == NULL) + if (query == nullptr) pNode->SetItemsRequestId(JABBER_DISCO_RESULT_ERROR); else { HXML item; - for (int i = 1; (item = XmlGetNthChild(query, L"item", i)) != NULL; i++) + for (int i = 1; (item = XmlGetNthChild(query, L"item", i)) != nullptr; i++) pNode->AddChildNode(XmlGetAttrValue(item, L"jid"), XmlGetAttrValue(item, L"node"), XmlGetAttrValue(item, L"name")); pNode->SetItemsRequestId(JABBER_DISCO_RESULT_OK); - pNode->SetItemsRequestErrorText(NULL); + pNode->SetItemsRequestErrorText(nullptr); } } else { @@ -261,10 +261,10 @@ void CJabberProto::OnIqResultServiceDiscoveryRootInfo(HXML iqNode, CJabberIqInfo HXML query = XmlGetChild(iqNode, "query"); if (query) { HXML feature; - for (int i = 1; (feature = XmlGetNthChild(query, L"feature", i)) != NULL; i++) { + for (int i = 1; (feature = XmlGetNthChild(query, L"feature", i)) != nullptr; i++) { if (!mir_wstrcmp(XmlGetAttrValue(feature, L"var"), (wchar_t *)pInfo->m_pUserData)) { - CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(pInfo->GetReceiver(), XmlGetAttrValue(iqNode, L"node"), NULL); - SendBothRequests(pNode, NULL); + CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(pInfo->GetReceiver(), XmlGetAttrValue(iqNode, L"node"), nullptr); + SendBothRequests(pNode, nullptr); break; } } @@ -280,13 +280,13 @@ void CJabberProto::OnIqResultServiceDiscoveryRootItems(HXML iqNode, CJabberIqInf if (!pInfo->m_pUserData) return; - XmlNode packet(NULL); + XmlNode packet(nullptr); mir_cslockfull lck(m_SDManager.cs()); if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) { HXML query = XmlGetChild(iqNode, "query"); if (query) { HXML item; - for (int i = 1; (item = XmlGetNthChild(query, L"item", i)) != NULL; i++) { + for (int i = 1; (item = XmlGetNthChild(query, L"item", i)) != nullptr; i++) { const wchar_t *szJid = XmlGetAttrValue(item, L"jid"); const wchar_t *szNode = XmlGetAttrValue(item, L"node"); CJabberIqInfo *pNewInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryRootInfo, JABBER_IQ_TYPE_GET, szJid); @@ -404,20 +404,20 @@ void CJabberProto::PerformBrowse(HWND hwndDlg) m_SDManager.RemoveAll(); if (!mir_wstrcmp(szJid, _T(SD_FAKEJID_MYAGENTS))) { sttBrowseMode = SD_BROWSE_MYAGENTS; - JABBER_LIST_ITEM *item = NULL; + JABBER_LIST_ITEM *item = nullptr; LISTFOREACH(i, this, LIST_ROSTER) { - if ((item = ListGetItemPtrFromIndex(i)) != NULL) { - if (wcschr(item->jid, '@') == NULL && wcschr(item->jid, '/') == NULL && item->subscription != SUB_NONE) { + if ((item = ListGetItemPtrFromIndex(i)) != nullptr) { + if (wcschr(item->jid, '@') == nullptr && wcschr(item->jid, '/') == nullptr && item->subscription != SUB_NONE) { MCONTACT hContact = HContactFromJID(item->jid); - if (hContact != NULL) + if (hContact != 0) setByte(hContact, "IsTransport", TRUE); if (m_lstTransports.getIndex(item->jid) == -1) m_lstTransports.insert(mir_wstrdup(item->jid)); - CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(item->jid, NULL, NULL); - SendBothRequests(pNode, NULL); + CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(item->jid, nullptr, nullptr); + SendBothRequests(pNode, nullptr); } } } @@ -451,7 +451,7 @@ void CJabberProto::PerformBrowse(HWND hwndDlg) char setting[MAXMODULELABELLENGTH]; mir_snprintf(setting, "discoWnd_favName_%d", i); ptrW tszName(getWStringA(setting)); - if (tszName == NULL) + if (tszName == nullptr) continue; mir_snprintf(setting, "discoWnd_favJID_%d", i); @@ -459,13 +459,13 @@ void CJabberProto::PerformBrowse(HWND hwndDlg) mir_snprintf(setting, "discoWnd_favNode_%d", i); ptrW dbvNode(getWStringA(setting)); CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(dbvJid, dbvNode, tszName); - SendBothRequests(pNode, NULL); + SendBothRequests(pNode, nullptr); } } else { sttBrowseMode = SD_BROWSE_NORMAL; - CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(szJid, mir_wstrlen(szNode) ? szNode : NULL, NULL); - SendBothRequests(pNode, NULL); + CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(szJid, mir_wstrlen(szNode) ? szNode : nullptr, nullptr); + SendBothRequests(pNode, nullptr); } lck.unlock(); @@ -608,7 +608,7 @@ private: }; CJabberDlgDiscovery::CJabberDlgDiscovery(CJabberProto *proto, wchar_t *jid) : - CJabberDlgBase(proto, IDD_SERVICE_DISCOVERY, NULL), + CJabberDlgBase(proto, IDD_SERVICE_DISCOVERY, nullptr), m_jid(jid), m_btnViewAsTree(this, IDC_BTN_VIEWTREE, proto->LoadIconEx("sd_view_tree"), "View as tree"), m_btnViewAsList(this, IDC_BTN_VIEWLIST, proto->LoadIconEx("sd_view_list"), "View as list"), @@ -700,7 +700,7 @@ void CJabberDlgDiscovery::OnInitDialog() PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0); - Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "discoWnd_"); + Utils_RestoreWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "discoWnd_"); } void CJabberDlgDiscovery::OnClose() @@ -717,7 +717,7 @@ void CJabberDlgDiscovery::OnClose() ListView_GetColumn(hwndList, 2, &lvc); m_proto->setWord("discoWnd_cx2", lvc.cx); - Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "discoWnd_"); + Utils_SaveWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "discoWnd_"); DestroyWindow(m_hwnd); CSuper::OnClose(); @@ -725,7 +725,7 @@ void CJabberDlgDiscovery::OnClose() void CJabberDlgDiscovery::OnDestroy() { - m_proto->m_pDlgServiceDiscovery = NULL; + m_proto->m_pDlgServiceDiscovery = nullptr; { mir_cslock lck(m_proto->m_SDManager.cs()); m_proto->m_SDManager.RemoveAll(); @@ -803,10 +803,10 @@ void CJabberDlgDiscovery::btnBookmarks_OnClick(CCtrlButton *) char setting[MAXMODULELABELLENGTH]; mir_snprintf(setting, "discoWnd_favName_%d", i); ptrW tszName(m_proto->getWStringA(setting)); - if (tszName != NULL) { + if (tszName != nullptr) { HMENU hSubMenu = CreatePopupMenu(); AppendMenu(hSubMenu, MF_STRING, 100 + i * 10 + 0, TranslateT("Navigate")); - AppendMenu(hSubMenu, MF_SEPARATOR, 0, NULL); + AppendMenu(hSubMenu, MF_SEPARATOR, 0, nullptr); AppendMenu(hSubMenu, MF_STRING, 100 + i * 10 + 1, TranslateT("Remove")); AppendMenu(hMenu, MF_POPUP | MF_STRING, (UINT_PTR)hSubMenu, tszName); } @@ -814,12 +814,12 @@ void CJabberDlgDiscovery::btnBookmarks_OnClick(CCtrlButton *) } int res = 0; if (GetMenuItemCount(hMenu)) { - AppendMenu(hMenu, MF_SEPARATOR, 1, NULL); + AppendMenu(hMenu, MF_SEPARATOR, 1, nullptr); AppendMenu(hMenu, MF_STRING, 10 + SD_BROWSE_FAVORITES, TranslateT("Browse all favorites")); AppendMenu(hMenu, MF_STRING, 1, TranslateT("Remove all favorites")); } if (GetMenuItemCount(hMenu)) - AppendMenu(hMenu, MF_SEPARATOR, 1, NULL); + AppendMenu(hMenu, MF_SEPARATOR, 1, nullptr); AppendMenu(hMenu, MF_STRING, 10 + SD_BROWSE_MYAGENTS, TranslateT("Registered transports")); AppendMenu(hMenu, MF_STRING, 10 + SD_BROWSE_AGENTS, TranslateT("Browse local transports")); @@ -827,7 +827,7 @@ void CJabberDlgDiscovery::btnBookmarks_OnClick(CCtrlButton *) RECT rc; GetWindowRect(GetDlgItem(m_hwnd, IDC_BTN_FAVORITE), &rc); CheckDlgButton(m_hwnd, IDC_BTN_FAVORITE, BST_CHECKED); - res = TrackPopupMenu(hMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, m_hwnd, NULL); + res = TrackPopupMenu(hMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, m_hwnd, nullptr); CheckDlgButton(m_hwnd, IDC_BTN_FAVORITE, BST_UNCHECKED); DestroyMenu(hMenu); @@ -902,7 +902,7 @@ void CJabberDlgDiscovery::btnRefresh_OnClick(CCtrlButton *) if (!hItem) return; - XmlNode packet(NULL); + XmlNode packet(nullptr); mir_cslockfull lck(m_proto->m_SDManager.cs()); CJabberSDNode *pNode = (CJabberSDNode*)TreeList_GetData(hItem); if (pNode) { @@ -956,7 +956,7 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) case WM_JABBER_REFRESH: KillTimer(m_hwnd, REFRESH_TIMER); if (GetTickCount() - m_proto->m_dwSDLastRefresh < REFRESH_TIMEOUT) { - SetTimer(m_hwnd, REFRESH_TIMER, REFRESH_TIMEOUT, NULL); + SetTimer(m_hwnd, REFRESH_TIMER, REFRESH_TIMEOUT, nullptr); return TRUE; } @@ -972,7 +972,7 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) if (pNode->GetJid()) { if (!pNode->GetTreeItemHandle()) { HTREELISTITEM hNewItem = TreeList_AddItem( - GetDlgItem(m_hwnd, IDC_TREE_DISCO), NULL, + GetDlgItem(m_hwnd, IDC_TREE_DISCO), nullptr, pNode->GetName() ? pNode->GetName() : pNode->GetJid(), (LPARAM)pNode); TreeList_AppendColumn(hNewItem, pNode->GetJid()); @@ -980,7 +980,7 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) pNode->SetTreeItemHandle(hNewItem); } } - m_proto->SyncTree(NULL, pNode); + m_proto->SyncTree(nullptr, pNode); pNode = pNode->GetNext(); } lck.unlock(); @@ -1004,7 +1004,7 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) if (iFirst < 0) return FALSE; if (iLast < 0) iLast = ListView_GetItemCount(hwndList) - 1; - XmlNode packet(NULL); + XmlNode packet(nullptr); { mir_cslock lck(m_proto->m_SDManager.cs()); for (int i = iFirst; i <= iLast; i++) { @@ -1076,7 +1076,7 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) else if (pHeader->code == TVN_ITEMEXPANDED) { NMTREEVIEW *pNmTreeView = (NMTREEVIEW *)lParam; HTREELISTITEM hItem = (HTREELISTITEM)pNmTreeView->itemNew.hItem; - XmlNode packet(NULL); + XmlNode packet(nullptr); { mir_cslock lck(m_proto->m_SDManager.cs()); CJabberSDNode *pNode = (CJabberSDNode*)TreeList_GetData(hItem); @@ -1095,7 +1095,7 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) KillTimer(m_hwnd, AUTODISCO_TIMER); if (GetTickCount() - sttLastAutoDisco < AUTODISCO_TIMEOUT) { - SetTimer(m_hwnd, AUTODISCO_TIMER, AUTODISCO_TIMEOUT, NULL); + SetTimer(m_hwnd, AUTODISCO_TIMER, AUTODISCO_TIMEOUT, nullptr); return CDRF_DODEFAULT; } @@ -1139,7 +1139,7 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) } // extern references to used functions: -void SearchAddToRecent(wchar_t* szAddr, HWND hwndDialog = NULL); +void SearchAddToRecent(wchar_t* szAddr, HWND hwndDialog = nullptr); void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM hItem, POINT pt) { @@ -1179,15 +1179,15 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM } static items[] = { - { NULL, LPGENW("Contact Menu..."), SD_ACT_USERMENU, SD_FLG_NONODE}, - { NULL, LPGENW("View vCard"), SD_ACT_VCARD, SD_FLG_NONODE}, + { nullptr, LPGENW("Contact Menu..."), SD_ACT_USERMENU, SD_FLG_NONODE}, + { nullptr, LPGENW("View vCard"), SD_ACT_VCARD, SD_FLG_NONODE}, { JABBER_FEAT_MUC, LPGENW("Join chatroom"), SD_ACT_JOIN, SD_FLG_NORESOURCE}, {0}, - { NULL, LPGENW("Refresh Info"), SD_ACT_REFRESH}, - { NULL, LPGENW("Refresh Children"), SD_ACT_REFRESHCHILDREN}, + { nullptr, LPGENW("Refresh Info"), SD_ACT_REFRESH}, + { nullptr, LPGENW("Refresh Children"), SD_ACT_REFRESHCHILDREN}, {0}, - { NULL, LPGENW("Add to favorites"), SD_ACT_FAVORITE}, - { NULL, LPGENW("Add to roster"), SD_ACT_ROSTER, SD_FLG_NONODE | SD_FLG_NOTONROSTER}, + { nullptr, LPGENW("Add to favorites"), SD_ACT_FAVORITE}, + { nullptr, LPGENW("Add to roster"), SD_ACT_ROSTER, SD_FLG_NONODE | SD_FLG_NOTONROSTER}, { JABBER_FEAT_MUC, LPGENW("Bookmark chatroom"), SD_ACT_BOOKMARK, SD_FLG_NORESOURCE | SD_FLG_HASUSER}, { L"jabber:iq:search", LPGENW("Add search directory"), SD_ACT_ADDDIRECTORY}, { JABBER_FEAT_BYTESTREAMS, LPGENW("Use this proxy"), SD_ACT_PROXY}, @@ -1199,16 +1199,16 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM { L"jabber:iq:gateway", LPGENW("Logon"), SD_ACT_LOGON, SD_FLG_ONROSTER | SD_FLG_SUBSCRIBED | SD_FLG_ONLINE}, { L"jabber:iq:gateway", LPGENW("Logoff"), SD_ACT_LOGOFF, SD_FLG_ONROSTER | SD_FLG_SUBSCRIBED | SD_FLG_NOTONLINE}, {0}, - { NULL, LPGENW("Copy JID"), SD_ACT_COPYJID}, - { NULL, LPGENW("Copy node name"), SD_ACT_COPYNODE}, - { NULL, LPGENW("Copy node information"), SD_ACT_COPYINFO}, + { nullptr, LPGENW("Copy JID"), SD_ACT_COPYJID}, + { nullptr, LPGENW("Copy node name"), SD_ACT_COPYNODE}, + { nullptr, LPGENW("Copy node information"), SD_ACT_COPYINFO}, }; HMENU hMenu = CreatePopupMenu(); BOOL lastSeparator = TRUE; bool bFilterItems = !GetAsyncKeyState(VK_CONTROL); for (int i = 0; i < _countof(items); i++) { - JABBER_LIST_ITEM *rosterItem = NULL; + JABBER_LIST_ITEM *rosterItem = nullptr; if (bFilterItems) { if ((items[i].flags & SD_FLG_NONODE) && pNode->GetNode()) continue; @@ -1241,7 +1241,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM lastSeparator = FALSE; } else if (!lastSeparator) { - AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); + AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr); lastSeparator = TRUE; } continue; @@ -1261,7 +1261,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM lastSeparator = FALSE; } else if (!lastSeparator) { - AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); + AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr); lastSeparator = TRUE; } } @@ -1272,13 +1272,13 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM return; } - int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, m_pDlgServiceDiscovery->GetHwnd(), NULL); + int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, m_pDlgServiceDiscovery->GetHwnd(), nullptr); DestroyMenu(hMenu); switch (res) { case SD_ACT_REFRESH: { - XmlNode packet(NULL); + XmlNode packet(nullptr); { mir_cslock lck(m_SDManager.cs()); if (pNode) { @@ -1295,7 +1295,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM case SD_ACT_REFRESHCHILDREN: { - XmlNode packet(NULL); + XmlNode packet(nullptr); { mir_cslock lck(m_SDManager.cs()); for (int iChild = TreeList_GetChildrenCount(hItem); iChild--;) { @@ -1310,7 +1310,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM if (XmlGetChildCount(packet) > 50) { m_ThreadInfo->send(packet); - packet = XmlNode(NULL); + packet = XmlNode(nullptr); } } } @@ -1375,11 +1375,11 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM case SD_ACT_BOOKMARK: { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_BOOKMARK, pNode->GetJid()); - if (item == NULL) { + if (item == nullptr) { item = ListGetItemPtr(LIST_BOOKMARK, pNode->GetJid()); - if (item == NULL) { + if (item == nullptr) { item = ListAdd(LIST_ROOM, pNode->GetJid()); - if (item == NULL) + if (item == nullptr) break; item->name = mir_wstrdup(pNode->GetName()); } @@ -1400,7 +1400,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM } HMENU hContactMenu = Menu_BuildContactMenu(hContact); GetCursorPos(&pt); - res = TrackPopupMenu(hContactMenu, TPM_RETURNCMD, pt.x, pt.y, 0, m_pDlgServiceDiscovery->GetHwnd(), NULL); + res = TrackPopupMenu(hContactMenu, TPM_RETURNCMD, pt.x, pt.y, 0, m_pDlgServiceDiscovery->GetHwnd(), nullptr); Clist_MenuProcessCommand(res, MPCF_CONTACTMENU, hContact); } break; @@ -1412,11 +1412,11 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM if (!hContact) hContact = AddToListByJID(jid, PALF_TEMPORARY); - if (ListGetItemPtr(LIST_VCARD_TEMP, pNode->GetJid()) == NULL) { + if (ListGetItemPtr(LIST_VCARD_TEMP, pNode->GetJid()) == nullptr) { JABBER_LIST_ITEM *item = ListAdd(LIST_VCARD_TEMP, pNode->GetJid(), hContact); item->bUseResource = true; if (item->arResources.getCount() == 0) - ListAddResource(LIST_VCARD_TEMP, jid, ID_STATUS_OFFLINE, NULL, 0); + ListAddResource(LIST_VCARD_TEMP, jid, ID_STATUS_OFFLINE, nullptr, 0); } CallService(MS_USERINFO_SHOWDIALOG, hContact, 0); } @@ -1433,7 +1433,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM case SD_ACT_LOGON: case SD_ACT_LOGOFF: - m_ThreadInfo->send(XmlNode(L"presence") << XATTR(L"to", pNode->GetJid()) << XATTR(L"type", (res != SD_ACT_LOGON) ? L"unavailable" : NULL)); + m_ThreadInfo->send(XmlNode(L"presence") << XATTR(L"to", pNode->GetJid()) << XATTR(L"type", (res != SD_ACT_LOGON) ? L"unavailable" : nullptr)); break; case SD_ACT_UNREGISTER: @@ -1471,7 +1471,7 @@ void CJabberProto::LaunchServiceDiscovery(wchar_t *jid) INT_PTR __cdecl CJabberProto::OnMenuHandleServiceDiscovery(WPARAM, LPARAM) { - LaunchServiceDiscovery(NULL); + LaunchServiceDiscovery(nullptr); return 0; } diff --git a/protocols/JabberG/src/jabber_disco.h b/protocols/JabberG/src/jabber_disco.h index 953084839f..9e31ab731e 100644 --- a/protocols/JabberG/src/jabber_disco.h +++ b/protocols/JabberG/src/jabber_disco.h @@ -46,7 +46,7 @@ public: m_szCategory = mir_wstrdup(szCategory); m_szType = mir_wstrdup(szType); m_szName = mir_wstrdup(szName); - m_pNext = NULL; + m_pNext = nullptr; } ~CJabberSDIdentity() { @@ -89,8 +89,8 @@ protected: public: CJabberSDFeature(const wchar_t *szVar) { - m_szVar = szVar ? mir_wstrdup(szVar) : NULL; - m_pNext = NULL; + m_szVar = szVar ? mir_wstrdup(szVar) : nullptr; + m_pNext = nullptr; } ~CJabberSDFeature() { @@ -132,22 +132,22 @@ protected: wchar_t *m_szInfoError; wchar_t *m_szItemsError; public: - CJabberSDNode(const wchar_t *szJid = NULL, const wchar_t *szNode = NULL, const wchar_t *szName = NULL) + CJabberSDNode(const wchar_t *szJid = nullptr, const wchar_t *szNode = nullptr, const wchar_t *szName = nullptr) { m_szJid = mir_wstrdup(szJid); m_szNode = mir_wstrdup(szNode); m_szName = mir_wstrdup(szName); - m_pIdentities = NULL; - m_pFeatures = NULL; - m_pNext = NULL; - m_pChild = NULL; + m_pIdentities = nullptr; + m_pFeatures = nullptr; + m_pNext = nullptr; + m_pChild = nullptr; m_dwInfoRequestTime = 0; m_dwItemsRequestTime = 0; m_nInfoRequestId = 0; m_nItemsRequestId = 0; - m_hTreeItem = NULL; - m_szInfoError = NULL; - m_szItemsError = NULL; + m_hTreeItem = nullptr; + m_szInfoError = nullptr; + m_szItemsError = nullptr; } ~CJabberSDNode() { @@ -155,43 +155,43 @@ public: } BOOL RemoveAll() { - replaceStrW(m_szJid, NULL); - replaceStrW(m_szNode, NULL); - replaceStrW(m_szName, NULL); - replaceStrW(m_szInfoError, NULL); - replaceStrW(m_szItemsError, NULL); + replaceStrW(m_szJid, nullptr); + replaceStrW(m_szNode, nullptr); + replaceStrW(m_szName, nullptr); + replaceStrW(m_szInfoError, nullptr); + replaceStrW(m_szItemsError, nullptr); if (m_pIdentities) delete m_pIdentities; - m_pIdentities = NULL; + m_pIdentities = nullptr; if (m_pFeatures) delete m_pFeatures; - m_pFeatures = NULL; + m_pFeatures = nullptr; if (m_pNext) delete m_pNext; - m_pNext = NULL; + m_pNext = nullptr; if (m_pChild) delete m_pChild; - m_pChild = NULL; + m_pChild = nullptr; m_nInfoRequestId = JABBER_DISCO_RESULT_NOT_REQUESTED; m_nItemsRequestId = JABBER_DISCO_RESULT_NOT_REQUESTED; m_dwInfoRequestTime = 0; m_dwItemsRequestTime = 0; - m_hTreeItem = NULL; + m_hTreeItem = nullptr; return TRUE; } BOOL ResetInfo() { - replaceStrW(m_szInfoError, NULL); - replaceStrW(m_szItemsError, NULL); + replaceStrW(m_szInfoError, nullptr); + replaceStrW(m_szItemsError, nullptr); if (m_pIdentities) delete m_pIdentities; - m_pIdentities = NULL; + m_pIdentities = nullptr; if (m_pFeatures) delete m_pFeatures; - m_pFeatures = NULL; + m_pFeatures = nullptr; if (m_pChild) delete m_pChild; - m_pChild = NULL; + m_pChild = nullptr; m_nInfoRequestId = JABBER_DISCO_RESULT_NOT_REQUESTED; m_nItemsRequestId = JABBER_DISCO_RESULT_NOT_REQUESTED; m_dwInfoRequestTime = 0; @@ -276,11 +276,11 @@ public: if ((m_nInfoRequestId == nIqId && bInfoId) || (m_nItemsRequestId == nIqId && !bInfoId)) return this; - CJabberSDNode *pNode = NULL; + CJabberSDNode *pNode = nullptr; if (m_pChild && (pNode = m_pChild->FindByIqId(nIqId, bInfoId))) return pNode; - CJabberSDNode *pTmpNode = NULL; + CJabberSDNode *pTmpNode = nullptr; pNode = m_pNext; while (pNode) { if ((pNode->m_nInfoRequestId == nIqId && bInfoId) || (pNode->m_nItemsRequestId == nIqId && !bInfoId)) @@ -289,7 +289,7 @@ public: return pTmpNode; pNode = pNode->GetNext(); } - return NULL; + return nullptr; } BOOL AddFeature(const wchar_t *szFeature) { @@ -402,7 +402,7 @@ protected: public: CJabberSDManager() { - m_pPrimaryNodes = NULL; + m_pPrimaryNodes = nullptr; } ~CJabberSDManager() @@ -415,7 +415,7 @@ public: void RemoveAll() { delete m_pPrimaryNodes; - m_pPrimaryNodes = NULL; + m_pPrimaryNodes = nullptr; } CJabberSDNode* GetPrimaryNode() @@ -426,11 +426,11 @@ public: CJabberSDNode* AddPrimaryNode(const wchar_t *szJid, const wchar_t *szNode, const wchar_t *szName) { if (!szJid) - return NULL; + return nullptr; CJabberSDNode *pNode = new CJabberSDNode(szJid, szNode, szName); if (!pNode) - return NULL; + return nullptr; pNode->SetNext(m_pPrimaryNodes); m_pPrimaryNodes = pNode; @@ -443,7 +443,7 @@ public: if (CJabberSDNode *pTmpNode = pNode->FindByIqId(nIqId, bInfoId)) return pTmpNode; - return NULL; + return nullptr; } }; diff --git a/protocols/JabberG/src/jabber_events.cpp b/protocols/JabberG/src/jabber_events.cpp index 3a6a4e69d8..bfbf88cd6e 100644 --- a/protocols/JabberG/src/jabber_events.cpp +++ b/protocols/JabberG/src/jabber_events.cpp @@ -37,7 +37,7 @@ int CJabberProto::OnContactDeleted(WPARAM hContact, LPARAM) return 0; ptrW jid(getWStringA(hContact, isChatRoom(hContact) ? "ChatRoomID" : "jid")); - if (jid == NULL) + if (jid == nullptr) return 0; if (ListGetItemPtr(LIST_ROSTER, jid)) { @@ -71,32 +71,32 @@ static wchar_t* sttSettingToTchar(DBCONTACTWRITESETTING *cws) case DBVT_WCHAR: return mir_wstrdup(cws->value.pwszVal); } - return NULL; + return nullptr; } void __cdecl CJabberProto::OnRenameGroup(DBCONTACTWRITESETTING *cws, MCONTACT hContact) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, ptrW(getWStringA(hContact, "jid"))); - if (item == NULL) + if (item == nullptr) return; ptrW tszNick(db_get_wsa(hContact, "CList", "MyHandle")); - if (tszNick == NULL) + if (tszNick == nullptr) tszNick = getWStringA(hContact, "Nick"); - if (tszNick == NULL) + if (tszNick == nullptr) tszNick = JabberNickFromJID(item->jid); - if (tszNick == NULL) + if (tszNick == nullptr) return; if (cws->value.type == DBVT_DELETED) { - if (item->group != NULL) { + if (item->group != nullptr) { debugLogA("Group set to nothing"); - AddContactToRoster(item->jid, tszNick, NULL); + AddContactToRoster(item->jid, tszNick, nullptr); } } else { wchar_t *p = sttSettingToTchar(cws); - if (cws->value.pszVal != NULL && mir_wstrcmp(p, item->group)) { + if (cws->value.pszVal != nullptr && mir_wstrcmp(p, item->group)) { debugLogW(L"Group set to %s", p); if (p) AddContactToRoster(item->jid, tszNick, p); @@ -108,7 +108,7 @@ void __cdecl CJabberProto::OnRenameGroup(DBCONTACTWRITESETTING *cws, MCONTACT hC void __cdecl CJabberProto::OnRenameContact(DBCONTACTWRITESETTING *cws, MCONTACT hContact) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, ptrW( getWStringA(hContact, "jid"))); - if (item == NULL) + if (item == nullptr) return; if (cws->value.type == DBVT_DELETED) { @@ -131,23 +131,23 @@ void __cdecl CJabberProto::OnAddContactForever(DBCONTACTWRITESETTING *cws, MCONT return; ptrW jid(getWStringA(hContact, "jid")); - if (jid == NULL) + if (jid == nullptr) return; debugLogW(L"Add %s permanently to list", jid); ptrW nick(db_get_wsa(hContact, "CList", "MyHandle")); - if (nick == NULL) + if (nick == nullptr) nick = getWStringA(hContact, "Nick"); - if (nick == NULL) + if (nick == nullptr) nick = JabberNickFromJID(jid); - if (nick == NULL) + if (nick == nullptr) return; AddContactToRoster(jid, nick, ptrW(db_get_wsa(hContact, "CList", "Group"))); XmlNode xPresence(L"presence"); xPresence << XATTR(L"to", LPCTSTR(jid)) << XATTR(L"type", L"subscribe"); - ptrW myNick(getWStringA(NULL, "Nick")); - if (myNick != NULL) + ptrW myNick(getWStringA(0, "Nick")); + if (myNick != nullptr) xPresence << XCHILD(L"nick", LPCTSTR(myNick)) << XATTR(L"xmlns", JABBER_FEAT_NICK); m_ThreadInfo->send(xPresence); @@ -158,7 +158,7 @@ void __cdecl CJabberProto::OnAddContactForever(DBCONTACTWRITESETTING *cws, MCONT int __cdecl CJabberProto::OnDbSettingChanged(WPARAM hContact, LPARAM lParam) { - if (hContact == NULL || !m_bJabberOnline) + if (hContact == 0 || !m_bJabberOnline) return 0; DBCONTACTWRITESETTING* cws = (DBCONTACTWRITESETTING*)lParam; diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp index 0d9904899f..8795a42459 100644 --- a/protocols/JabberG/src/jabber_file.cpp +++ b/protocols/JabberG/src/jabber_file.cpp @@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void __cdecl CJabberProto::FileReceiveThread(filetransfer *ft) { - ThreadData info(this, NULL); + ThreadData info(this, nullptr); debugLogA("Thread started: type=file_receive server='%s' port='%d'", ft->httpHostName, ft->httpPort); Thread_SetName("Jabber: FileReceiveThread"); @@ -41,7 +41,7 @@ void __cdecl CJabberProto::FileReceiveThread(filetransfer *ft) nloc.szHost = ft->httpHostName; nloc.wPort = ft->httpPort; info.s = Netlib_OpenConnection(m_hNetlibUser, &nloc); - if (info.s == NULL) { + if (info.s == nullptr) { debugLogA("Connection failed (%d), thread ended", WSAGetLastError()); ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); } @@ -71,7 +71,7 @@ void __cdecl CJabberProto::FileReceiveThread(filetransfer *ft) datalen -= bytesParsed; } - ft->s = NULL; + ft->s = nullptr; if (ft->state == FT_DONE || (ft->state == FT_RECEIVING && ft->std.currentFileSize == 0)) ft->complete(); @@ -96,7 +96,7 @@ int CJabberProto::FileReceiveParse(filetransfer *ft, char* buffer, int datalen) break; ptrA str(mir_strndup(p, size_t(q - p))); - if (str == NULL) { + if (str == nullptr) { ft->state = FT_ERROR; break; } @@ -114,7 +114,7 @@ int CJabberProto::FileReceiveParse(filetransfer *ft, char* buffer, int datalen) else { // FT_INITIALIZING if (str[0] == '\0') { wchar_t *s; - if ((s = wcsrchr(ft->httpPath, '/')) != NULL) + if ((s = wcsrchr(ft->httpPath, '/')) != nullptr) s++; else s = ft->httpPath; @@ -183,7 +183,7 @@ void JabberFileServerConnection(HNETLIBCONN hConnection, DWORD /*dwRemoteIP*/, v ppro->debugLogA("File server incoming connection accepted: %s", connInfo.szIpPort); JABBER_LIST_ITEM *item = ppro->ListGetItemPtr(LIST_FILE, szPort); - if (item == NULL) { + if (item == nullptr) { ppro->debugLogA("No file is currently served, file server connection closed."); Netlib_CloseHandle(hConnection); return; @@ -195,11 +195,11 @@ void JabberFileServerConnection(HNETLIBCONN hConnection, DWORD /*dwRemoteIP*/, v ppro->debugLogA("Set ft->s to %d (saving %d)", hConnection, slisten); char* buffer = (char*)mir_alloc(JABBER_NETWORK_BUFFER_SIZE + 1); - if (buffer == NULL) { + if (buffer == nullptr) { ppro->debugLogA("Cannot allocate network buffer, file server connection closed."); Netlib_CloseHandle(hConnection); ft->state = FT_ERROR; - if (ft->hFileEvent != NULL) + if (ft->hFileEvent != nullptr) SetEvent(ft->hFileEvent); return; } @@ -227,7 +227,7 @@ void JabberFileServerConnection(HNETLIBCONN hConnection, DWORD /*dwRemoteIP*/, v Netlib_CloseHandle(hConnection); ft->s = slisten; ppro->debugLogA("ft->s is restored to %d", ft->s); - if (ft->hFileEvent != NULL) + if (ft->hFileEvent != nullptr) SetEvent(ft->hFileEvent); mir_free(buffer); } @@ -237,7 +237,7 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft) debugLogA("Thread started: type=file_send"); Thread_SetName("Jabber: FileServerThread"); - ThreadData info(this, NULL); + ThreadData info(this, nullptr); ft->type = FT_OOB; NETLIBBIND nlb = {}; @@ -246,7 +246,7 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft) nlb.wPort = 0; // Use user-specified incoming port ranges, if available info.s = (HNETLIBCONN)Netlib_BindPort(m_hNetlibUser, &nlb); - if (info.s == NULL) { + if (info.s == nullptr) { debugLogA("Cannot allocate port to bind for file server thread, thread ended."); ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); delete ft; @@ -256,7 +256,7 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft) ft->s = info.s; debugLogA("ft->s = %d", info.s); - HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + HANDLE hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); ft->hFileEvent = hEvent; wchar_t szPort[20]; @@ -265,28 +265,28 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft) item->ft = ft; wchar_t *ptszResource = ListGetBestClientResourceNamePtr(ft->jid); - if (ptszResource != NULL) { + if (ptszResource != nullptr) { ft->state = FT_CONNECTING; for (int i = 0; i < ft->std.totalFiles && ft->state != FT_ERROR && ft->state != FT_DENIED; i++) { ft->std.currentFileNumber = i; ft->state = FT_CONNECTING; if (ft->httpPath) mir_free(ft->httpPath); - ft->httpPath = NULL; + ft->httpPath = nullptr; wchar_t *p; - if ((p = wcschr(ft->std.ptszFiles[i], '\\')) != NULL) + if ((p = wcschr(ft->std.ptszFiles[i], '\\')) != nullptr) p++; else p = ft->std.ptszFiles[i]; ptrA pFileName(mir_urlEncode(T2Utf(p))); - if (pFileName != NULL) { + if (pFileName != nullptr) { ft->szId = JabberId2string(SerialNext()); ptrA myAddr; if (m_options.BsDirect && m_options.BsDirectManual) myAddr = getStringA("BsDirectAddr"); - if (myAddr == NULL) { + if (myAddr == nullptr) { sockaddr_in sin = {}; sin.sin_family = AF_INET; sin.sin_addr.S_un.S_addr = nlb.dwExternalIP; @@ -313,12 +313,12 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft) ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, ft, 0); } CloseHandle(hEvent); - ft->hFileEvent = NULL; + ft->hFileEvent = nullptr; debugLogA("Finish all files"); } - ft->s = NULL; - debugLogA("ft->s is NULL"); + ft->s = nullptr; + debugLogA("ft->s is nullptr"); ListRemove(LIST_FILE, szPort); @@ -356,7 +356,7 @@ int CJabberProto::FileSendParse(HNETLIBCONN s, filetransfer *ft, char* buffer, i for (q = p; q + 1 < eob && (*q != '\r' || *(q + 1) != '\n'); q++); if (q + 1 >= eob) break; - if ((str = (char*)mir_alloc(q - p + 1)) == NULL) { + if ((str = (char*)mir_alloc(q - p + 1)) == nullptr) { ft->state = FT_ERROR; break; } @@ -385,14 +385,14 @@ int CJabberProto::FileSendParse(HNETLIBCONN s, filetransfer *ft, char* buffer, i currentFile = ft->std.currentFileNumber; wchar_t *t = wcsrchr(ft->std.ptszFiles[currentFile], '\\'); - if (t != NULL) + if (t != nullptr) t++; else t = ft->std.ptszFiles[currentFile]; - if (ft->httpPath == NULL || mir_wstrcmp(ft->httpPath, t)) { - if (ft->httpPath == NULL) - debugLogA("Requested file name does not matched (httpPath == NULL)"); + if (ft->httpPath == nullptr || mir_wstrcmp(ft->httpPath, t)) { + if (ft->httpPath == nullptr) + debugLogA("Requested file name does not matched (httpPath == nullptr)"); else debugLogW(L"Requested file name does not matched ('%s' vs. '%s')", ft->httpPath, t); ft->state = FT_ERROR; @@ -404,7 +404,7 @@ int CJabberProto::FileSendParse(HNETLIBCONN s, filetransfer *ft, char* buffer, i debugLogA("File cannot be opened"); ft->state = FT_ERROR; mir_free(ft->httpPath); - ft->httpPath = NULL; + ft->httpPath = nullptr; break; } @@ -430,7 +430,7 @@ int CJabberProto::FileSendParse(HNETLIBCONN s, filetransfer *ft, char* buffer, i ft->state = FT_DONE; debugLogA("Finishing this file..."); mir_free(ft->httpPath); - ft->httpPath = NULL; + ft->httpPath = nullptr; break; } } @@ -510,7 +510,7 @@ int filetransfer::create() if (hWaitEvent != INVALID_HANDLE_VALUE) CloseHandle(hWaitEvent); - hWaitEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + hWaitEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); if (ppro->ProtoBroadcastAck(std.hContact, ACKTYPE_FILE, ACKRESULT_FILERESUME, this, (LPARAM)&std)) WaitForSingleObject(hWaitEvent, INFINITE); diff --git a/protocols/JabberG/src/jabber_filterlist.cpp b/protocols/JabberG/src/jabber_filterlist.cpp index 1d6d8c655d..97b4178c4c 100644 --- a/protocols/JabberG/src/jabber_filterlist.cpp +++ b/protocols/JabberG/src/jabber_filterlist.cpp @@ -46,7 +46,7 @@ struct CFilterData : public MZeroedObject void ReleaseFilterData() { - DeleteObject(m_hfntEmpty); m_hfntEmpty = NULL; + DeleteObject(m_hfntEmpty); m_hfntEmpty = nullptr; } ~CFilterData() @@ -83,7 +83,7 @@ void CCtrlFilterListView::OnInit() static LRESULT CALLBACK sttEditBoxSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { CFilterData *fdat = (CFilterData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (fdat == NULL) + if (fdat == nullptr) return DefWindowProc(hwnd, msg, wParam, lParam); switch (msg) { @@ -105,7 +105,7 @@ static LRESULT CALLBACK sttEditBoxSubclassProc(HWND hwnd, UINT msg, WPARAM wPara } DestroyWindow(hwnd); - RedrawWindow(fdat->m_hwndOwner, NULL, NULL, RDW_INVALIDATE|RDW_FRAME); + RedrawWindow(fdat->m_hwndOwner, nullptr, nullptr, RDW_INVALIDATE|RDW_FRAME); PostMessage(fdat->m_hwndOwner, WM_APP, 0, 0); } else if (wParam == VK_ESCAPE) { @@ -121,7 +121,7 @@ static LRESULT CALLBACK sttEditBoxSubclassProc(HWND hwnd, UINT msg, WPARAM wPara return 0; case WM_DESTROY: - fdat->m_hwndEditBox = NULL; + fdat->m_hwndEditBox = nullptr; } return CallWindowProc(fdat->m_oldWndProc, hwnd, msg, wParam, lParam); @@ -160,7 +160,7 @@ LRESULT CCtrlFilterListView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lPara case 0: OnFilterChanged(this); if (!m_keepHiglight) - FilterHighlight(NULL); + FilterHighlight(nullptr); break; case 1: @@ -183,7 +183,7 @@ LRESULT CCtrlFilterListView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lPara fdat->m_hwndEditBox = CreateWindow(L"edit", fdat->m_filterText, WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_LEFT|ES_AUTOHSCROLL, 0, 0, 0, 0, - ::GetParent(m_hwnd), (HMENU)-1, hInst, NULL); + ::GetParent(m_hwnd), (HMENU)-1, hInst, nullptr); SendMessage(fdat->m_hwndEditBox, WM_SETFONT, (WPARAM)fdat->m_hfntNormal, 0); @@ -261,8 +261,8 @@ LRESULT CCtrlFilterListView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lPara rc.right - FILTER_BOX_HEIGHT + (FILTER_BOX_HEIGHT-16)/2, rc.top + (FILTER_BOX_HEIGHT-16)/2, rc.right - FILTER_BOX_HEIGHT + (FILTER_BOX_HEIGHT-16)/2 + 16, rc.top + (FILTER_BOX_HEIGHT-16)/2 + 16); - DrawIconEx(hdc, rc.left + (FILTER_BOX_HEIGHT-16)/2, rc.top + (FILTER_BOX_HEIGHT-16)/2, g_LoadIconEx("sd_filter_apply"), 16, 16, 0, NULL, DI_NORMAL); - DrawIconEx(hdc, rc.right - FILTER_BOX_HEIGHT + (FILTER_BOX_HEIGHT-16)/2, rc.top + (FILTER_BOX_HEIGHT-16)/2, Skin_LoadIcon(SKINICON_OTHER_DELETE), 16, 16, 0, NULL, DI_NORMAL); + DrawIconEx(hdc, rc.left + (FILTER_BOX_HEIGHT-16)/2, rc.top + (FILTER_BOX_HEIGHT-16)/2, g_LoadIconEx("sd_filter_apply"), 16, 16, 0, nullptr, DI_NORMAL); + DrawIconEx(hdc, rc.right - FILTER_BOX_HEIGHT + (FILTER_BOX_HEIGHT-16)/2, rc.top + (FILTER_BOX_HEIGHT-16)/2, Skin_LoadIcon(SKINICON_OTHER_DELETE), 16, 16, 0, nullptr, DI_NORMAL); rc.left += 5*FILTER_BOX_HEIGHT/3; rc.right -= 5*FILTER_BOX_HEIGHT/3; @@ -276,7 +276,7 @@ LRESULT CCtrlFilterListView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lPara else { SetRect(&fdat->m_rcButtonClear, 0, 0, 0, 0); - DrawIconEx(hdc, rc.left + (FILTER_BOX_HEIGHT-16)/2, rc.top + (FILTER_BOX_HEIGHT-16)/2, g_LoadIconEx("sd_filter_reset"), 16, 16, 0, NULL, DI_NORMAL); + DrawIconEx(hdc, rc.left + (FILTER_BOX_HEIGHT-16)/2, rc.top + (FILTER_BOX_HEIGHT-16)/2, g_LoadIconEx("sd_filter_reset"), 16, 16, 0, nullptr, DI_NORMAL); rc.left += 5*FILTER_BOX_HEIGHT/3; rc.right -= 5; @@ -297,7 +297,7 @@ LRESULT CCtrlFilterListView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lPara case WM_NCHITTEST: pt.x = LOWORD(lParam); pt.y = HIWORD(lParam); - MapWindowPoints(NULL, m_hwnd, &pt, 1); + MapWindowPoints(nullptr, m_hwnd, &pt, 1); if (PtInRect(&fdat->m_rcButtonClear, pt)) return HTBORDER; @@ -308,15 +308,15 @@ LRESULT CCtrlFilterListView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lPara case WM_NCLBUTTONUP: pt.x = LOWORD(lParam); pt.y = HIWORD(lParam); - MapWindowPoints(NULL, m_hwnd, &pt, 1); + MapWindowPoints(nullptr, m_hwnd, &pt, 1); if (PtInRect(&fdat->m_rcButtonClear, pt)) { SetFocus(m_hwnd); if (fdat->m_filterText) mir_free(fdat->m_filterText); - fdat->m_filterText = NULL; - RedrawWindow(m_hwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME); + fdat->m_filterText = nullptr; + RedrawWindow(m_hwnd, nullptr, nullptr, RDW_INVALIDATE|RDW_FRAME); OnFilterChanged(this); - FilterHighlight(NULL); + FilterHighlight(nullptr); } else if (PtInRect(&fdat->m_rcEditBox, pt)) PostMessage(m_hwnd, WM_APP, 2, 0); diff --git a/protocols/JabberG/src/jabber_form.cpp b/protocols/JabberG/src/jabber_form.cpp index e9706e4c57..fbec892638 100644 --- a/protocols/JabberG/src/jabber_form.cpp +++ b/protocols/JabberG/src/jabber_form.cpp @@ -62,9 +62,9 @@ void JabberFormCenterContent(HWND hwndStatic) GetWindowRect(hwndStatic, &rcWindow); int minX = rcWindow.right; - HWND oldChild = NULL; + HWND oldChild = nullptr; HWND hWndChild = GetWindow(hwndStatic, GW_CHILD); - while (hWndChild != oldChild && hWndChild != NULL) { + while (hWndChild != oldChild && hWndChild != nullptr) { DWORD style = GetWindowLongPtr(hWndChild, GWL_STYLE); RECT rc; GetWindowRect(hWndChild, &rc); @@ -88,9 +88,9 @@ void JabberFormCenterContent(HWND hwndStatic) if (minX > rcWindow.left + 5) { int dx = (minX - rcWindow.left) / 2; - oldChild = NULL; + oldChild = nullptr; hWndChild = GetWindow(hwndStatic, GW_CHILD); - while (hWndChild != oldChild && hWndChild != NULL) { + while (hWndChild != oldChild && hWndChild != nullptr) { DWORD style = GetWindowLongPtr(hWndChild, GWL_STYLE); RECT rc; GetWindowRect(hWndChild, &rc); @@ -114,7 +114,7 @@ void JabberFormSetInstruction(HWND hwndForm, const wchar_t *text) if ((text[i - 1] == '\n') && (text[i] != '\r')) ++fixedLen; - wchar_t *fixedText = NULL; + wchar_t *fixedText = nullptr; if (fixedLen != len) { fixedText = (wchar_t *)mir_alloc(sizeof(wchar_t) * (fixedLen + 1)); wchar_t *p = fixedText; @@ -140,7 +140,7 @@ void JabberFormSetInstruction(HWND hwndForm, const wchar_t *text) SetRect(&rcText, 0, 0, rcText.right - rcText.left, 0); HDC hdcEdit = GetDC(GetDlgItem(hwndForm, IDC_INSTRUCTION)); HFONT hfntSave = (HFONT)SelectObject(hdcEdit, (HFONT)SendDlgItemMessage(hwndForm, IDC_INSTRUCTION, WM_GETFONT, 0, 0)); - DrawTextEx(hdcEdit, (wchar_t *)text, (int)mir_wstrlen(text), &rcText, DT_CALCRECT | DT_EDITCONTROL | DT_TOP | DT_WORDBREAK, NULL); + DrawTextEx(hdcEdit, (wchar_t *)text, (int)mir_wstrlen(text), &rcText, DT_CALCRECT | DT_EDITCONTROL | DT_TOP | DT_WORDBREAK, nullptr); SelectObject(hdcEdit, hfntSave); ReleaseDC(GetDlgItem(hwndForm, IDC_INSTRUCTION), hdcEdit); @@ -162,7 +162,7 @@ void JabberFormSetInstruction(HWND hwndForm, const wchar_t *text) SWP_NOMOVE | SWP_NOZORDER); GetWindowRect(GetDlgItem(hwndForm, IDC_WHITERECT), &rcText); - MapWindowPoints(NULL, hwndForm, (LPPOINT)&rcText, 2); + MapWindowPoints(nullptr, hwndForm, (LPPOINT)&rcText, 2); rcText.bottom += deltaHeight; SetWindowPos(GetDlgItem(hwndForm, IDC_WHITERECT), 0, 0, 0, rcText.right - rcText.left, @@ -170,7 +170,7 @@ void JabberFormSetInstruction(HWND hwndForm, const wchar_t *text) SWP_NOMOVE | SWP_NOZORDER); GetWindowRect(GetDlgItem(hwndForm, IDC_FRAME1), &rcText); - MapWindowPoints(NULL, hwndForm, (LPPOINT)&rcText, 2); + MapWindowPoints(nullptr, hwndForm, (LPPOINT)&rcText, 2); rcText.top += deltaHeight; SetWindowPos(GetDlgItem(hwndForm, IDC_FRAME1), 0, rcText.left, @@ -179,7 +179,7 @@ void JabberFormSetInstruction(HWND hwndForm, const wchar_t *text) SWP_NOSIZE | SWP_NOZORDER); GetWindowRect(GetDlgItem(hwndForm, IDC_FRAME), &rcText); - MapWindowPoints(NULL, hwndForm, (LPPOINT)&rcText, 2); + MapWindowPoints(nullptr, hwndForm, (LPPOINT)&rcText, 2); rcText.top += deltaHeight; SetWindowPos(GetDlgItem(hwndForm, IDC_FRAME), 0, rcText.left, @@ -189,7 +189,7 @@ void JabberFormSetInstruction(HWND hwndForm, const wchar_t *text) SWP_NOZORDER); GetWindowRect(GetDlgItem(hwndForm, IDC_VSCROLL), &rcText); - MapWindowPoints(NULL, hwndForm, (LPPOINT)&rcText, 2); + MapWindowPoints(nullptr, hwndForm, (LPPOINT)&rcText, 2); rcText.top += deltaHeight; SetWindowPos(GetDlgItem(hwndForm, IDC_VSCROLL), 0, rcText.left, @@ -282,7 +282,7 @@ void JabberFormLayoutSingleControl(TJabberFormControlInfo *item, TJabberFormLayo #define JabberFormCreateLabel() \ CreateWindow(L"static", labelStr, WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE, \ - 0, 0, 0, 0, hwndStatic, (HMENU)-1, hInst, NULL) + 0, 0, 0, 0, hwndStatic, (HMENU)-1, hInst, nullptr) TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayoutInfo *layout_info, TJabberFormControlType type, const wchar_t *labelStr, const wchar_t *valueStr) { @@ -294,7 +294,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo TJabberFormControlInfo *item = (TJabberFormControlInfo *)mir_alloc(sizeof(TJabberFormControlInfo)); item->type = type; - item->hLabel = item->hCtrl = NULL; + item->hLabel = item->hCtrl = nullptr; switch (type) { case JFORM_CTYPE_TEXT_PRIVATE: @@ -302,7 +302,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, L"edit", valueStr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD, 0, 0, 0, 0, - hwndStatic, (HMENU)layout_info->id, hInst, NULL); + hwndStatic, (HMENU)layout_info->id, hInst, nullptr); ++layout_info->id; break; @@ -311,7 +311,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, L"edit", valueStr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN, 0, 0, 0, 0, - hwndStatic, (HMENU)layout_info->id, hInst, NULL); + hwndStatic, (HMENU)layout_info->id, hInst, nullptr); mir_subclassWindow(item->hCtrl, JabberFormMultiLineWndProc); ++layout_info->id; break; @@ -320,7 +320,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo item->hCtrl = CreateWindowEx(0, L"button", labelStr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX | BS_MULTILINE, 0, 0, 0, 0, - hwndStatic, (HMENU)layout_info->id, hInst, NULL); + hwndStatic, (HMENU)layout_info->id, hInst, nullptr); if (valueStr && !mir_wstrcmp(valueStr, L"1")) SendMessage(item->hCtrl, BM_SETCHECK, 1, 0); ++layout_info->id; @@ -328,19 +328,19 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo case JFORM_CTYPE_LIST_SINGLE: item->hLabel = JabberFormCreateLabel(); - item->hCtrl = CreateWindowExA(WS_EX_CLIENTEDGE, "combobox", NULL, + item->hCtrl = CreateWindowExA(WS_EX_CLIENTEDGE, "combobox", nullptr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST, 0, 0, 0, 0, - hwndStatic, (HMENU)layout_info->id, hInst, NULL); + hwndStatic, (HMENU)layout_info->id, hInst, nullptr); ++layout_info->id; break; case JFORM_CTYPE_LIST_MULTI: item->hLabel = JabberFormCreateLabel(); item->hCtrl = CreateWindowExA(WS_EX_CLIENTEDGE, "listbox", - NULL, WS_CHILD | WS_VISIBLE | WS_TABSTOP | LBS_MULTIPLESEL, + nullptr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | LBS_MULTIPLESEL, 0, 0, 0, 0, - hwndStatic, (HMENU)layout_info->id, hInst, NULL); + hwndStatic, (HMENU)layout_info->id, hInst, nullptr); ++layout_info->id; break; @@ -348,18 +348,18 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo item->hCtrl = CreateWindow(L"edit", valueStr, WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_READONLY | ES_AUTOHSCROLL, 0, 0, 0, 0, - hwndStatic, (HMENU)-1, hInst, NULL); + hwndStatic, (HMENU)-1, hInst, nullptr); break; case JFORM_CTYPE_HIDDEN: break; case JFORM_CTYPE_TEXT_SINGLE: - item->hLabel = labelStr ? (JabberFormCreateLabel()) : NULL; + item->hLabel = labelStr ? (JabberFormCreateLabel()) : nullptr; item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, L"edit", valueStr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_AUTOHSCROLL, 0, 0, 0, 0, - hwndStatic, (HMENU)layout_info->id, hInst, NULL); + hwndStatic, (HMENU)layout_info->id, hInst, nullptr); ++layout_info->id; break; } @@ -438,7 +438,7 @@ void JabberFormCreateUI(HWND hwndStatic, HXML xNode, int *formHeight, BOOL bComp wchar_t *labelStr, *valueStr; RECT frameRect; - if (xNode == NULL || XmlGetName(xNode) == NULL || mir_wstrcmp(XmlGetName(xNode), L"x") || hwndStatic == NULL) + if (xNode == nullptr || XmlGetName(xNode) == nullptr || mir_wstrcmp(XmlGetName(xNode), L"x") || hwndStatic == nullptr) return; GetClientRect(hwndStatic, &frameRect); @@ -462,17 +462,17 @@ void JabberFormCreateUI(HWND hwndStatic, HXML xNode, int *formHeight, BOOL bComp continue; varStr = XmlGetAttrValue(n, L"var"); - if ((typeName = XmlGetAttrValue(n, L"type")) == NULL) + if ((typeName = XmlGetAttrValue(n, L"type")) == nullptr) continue; - if ((label = XmlGetAttrValue(n, L"label")) != NULL) + if ((label = XmlGetAttrValue(n, L"label")) != nullptr) labelStr = mir_wstrdup(label); else labelStr = mir_wstrdup(varStr); TJabberFormControlType type = JabberFormTypeNameToId(typeName); - if ((v = XmlGetChild(n, "value")) != NULL) { + if ((v = XmlGetChild(n, "value")) != nullptr) { valueText = XmlGetText(v); if (type != JFORM_CTYPE_TEXT_MULTI) valueStr = mir_wstrdup(valueText); @@ -499,7 +499,7 @@ void JabberFormCreateUI(HWND hwndStatic, HXML xNode, int *formHeight, BOOL bComp } } } - else valueText = valueStr = NULL; + else valueText = valueStr = nullptr; TJabberFormControlInfo *item = JabberFormAppendControl(hwndStatic, &layout_info, type, labelStr, valueStr); @@ -509,16 +509,16 @@ void JabberFormCreateUI(HWND hwndStatic, HXML xNode, int *formHeight, BOOL bComp if (type == JFORM_CTYPE_LIST_SINGLE) { for (int j = 0;; j++) { HXML o = XmlGetChild(n, j); - if (o == NULL) + if (o == nullptr) break; if (mir_wstrcmp(XmlGetName(o), L"option")) continue; - if ((v = XmlGetChild(o, "value")) == NULL || XmlGetText(v) == NULL) + if ((v = XmlGetChild(o, "value")) == nullptr || XmlGetText(v) == nullptr) continue; - if ((str = XmlGetAttrValue(o, L"label")) == NULL) + if ((str = XmlGetAttrValue(o, L"label")) == nullptr) str = XmlGetText(v); - if (str == NULL) + if (str == nullptr) continue; bool selected = !mir_wstrcmp(valueText, XmlGetText(v)); @@ -528,16 +528,16 @@ void JabberFormCreateUI(HWND hwndStatic, HXML xNode, int *formHeight, BOOL bComp else if (type == JFORM_CTYPE_LIST_MULTI) { for (int j = 0;; j++) { HXML o = XmlGetChild(n, j); - if (o == NULL) + if (o == nullptr) break; if (mir_wstrcmp(XmlGetName(o), L"option")) continue; - if ((v = XmlGetChild(o, "value")) == NULL || XmlGetText(v) == NULL) + if ((v = XmlGetChild(o, "value")) == nullptr || XmlGetText(v) == nullptr) continue; - if ((str = XmlGetAttrValue(o, L"label")) == NULL) + if ((str = XmlGetAttrValue(o, L"label")) == nullptr) str = XmlGetText(v); - if (str == NULL) + if (str == nullptr) continue; bool selected = false; @@ -577,8 +577,8 @@ HXML JabberFormGetData(HWND hwndStatic, HXML xNode) const wchar_t *varName, *type, *fieldStr, *labelText, *str2; wchar_t *p, *q, *str; - if (xNode == NULL || XmlGetName(xNode) == NULL || mir_wstrcmp(XmlGetName(xNode), L"x") || hwndStatic == NULL) - return NULL; + if (xNode == nullptr || XmlGetName(xNode) == nullptr || mir_wstrcmp(XmlGetName(xNode), L"x") || hwndStatic == nullptr) + return nullptr; hFrame = hwndStatic; id = 0; @@ -590,11 +590,11 @@ HXML JabberFormGetData(HWND hwndStatic, HXML xNode) if (!n) break; - fieldStr = NULL; + fieldStr = nullptr; if (mir_wstrcmp(XmlGetName(n), L"field")) continue; - if ((varName = XmlGetAttrValue(n, L"var")) == NULL || (type = XmlGetAttrValue(n, L"type")) == NULL) + if ((varName = XmlGetAttrValue(n, L"var")) == nullptr || (type = XmlGetAttrValue(n, L"type")) == nullptr) continue; hCtrl = GetDlgItem(hFrame, id); @@ -605,11 +605,11 @@ HXML JabberFormGetData(HWND hwndStatic, HXML xNode) str = (wchar_t*)mir_alloc(sizeof(wchar_t)*(len + 1)); GetDlgItemText(hFrame, id, str, len + 1); p = str; - while (p != NULL) { - if ((q = wcsstr(p, L"\r\n")) != NULL) + while (p != nullptr) { + if ((q = wcsstr(p, L"\r\n")) != nullptr) *q = '\0'; field << XCHILD(L"value", p); - p = q ? q + 2 : NULL; + p = q ? q + 2 : nullptr; } mir_free(str); id++; @@ -624,15 +624,15 @@ HXML JabberFormGetData(HWND hwndStatic, HXML xNode) len = GetWindowTextLength(GetDlgItem(hFrame, id)); str = (wchar_t*)mir_alloc(sizeof(wchar_t)*(len + 1)); GetDlgItemText(hFrame, id, str, len + 1); - v = NULL; + v = nullptr; for (j = 0;; j++) { o = XmlGetChild(n, j); if (!o) break; if (!mir_wstrcmp(XmlGetName(o), L"option")) { - if ((v = XmlGetChild(o, "value")) != NULL && XmlGetText(v)) { - if ((str2 = XmlGetAttrValue(o, L"label")) == NULL) + if ((v = XmlGetChild(o, "value")) != nullptr && XmlGetText(v)) { + if ((str2 = XmlGetAttrValue(o, L"label")) == nullptr) str2 = XmlGetText(v); if (!mir_wstrcmp(str2, str)) break; @@ -652,7 +652,7 @@ HXML JabberFormGetData(HWND hwndStatic, HXML xNode) if (SendMessage(hCtrl, LB_GETSEL, j, 0) > 0) { // an entry is selected len = SendMessage(hCtrl, LB_GETTEXTLEN, j, 0); - if ((str = (wchar_t*)mir_alloc((len + 1)*sizeof(wchar_t))) != NULL) { + if ((str = (wchar_t*)mir_alloc((len + 1)*sizeof(wchar_t))) != nullptr) { SendMessage(hCtrl, LB_GETTEXT, j, (LPARAM)str); for (k = 0;; k++) { o = XmlGetChild(n, k); @@ -660,8 +660,8 @@ HXML JabberFormGetData(HWND hwndStatic, HXML xNode) break; if (XmlGetName(o) && !mir_wstrcmp(XmlGetName(o), L"option")) { - if ((v = XmlGetChild(o, "value")) != NULL && XmlGetText(v)) { - if ((labelText = XmlGetAttrValue(o, L"label")) == NULL) + if ((v = XmlGetChild(o, "value")) != nullptr && XmlGetText(v)) { + if ((labelText = XmlGetAttrValue(o, L"label")) == nullptr) labelText = XmlGetText(v); if (!mir_wstrcmp(labelText, str)) @@ -677,7 +677,7 @@ HXML JabberFormGetData(HWND hwndStatic, HXML xNode) } else if (!mir_wstrcmp(type, L"fixed") || !mir_wstrcmp(type, L"hidden")) { v = XmlGetChild(n, "value"); - if (v != NULL && XmlGetText(v) != NULL) + if (v != nullptr && XmlGetText(v) != nullptr) field << XCHILD(L"value", XmlGetText(v)); } else { // everything else is considered "text-single" or "text-private" @@ -718,27 +718,27 @@ static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, TranslateDialogDefault(hwndDlg); ShowWindow(GetDlgItem(hwndDlg, IDC_FRAME_TEXT), SW_HIDE); jfi = (JABBER_FORM_INFO*)lParam; - if (jfi != NULL) { + if (jfi != nullptr) { HXML n; LONG frameExStyle; // Set dialog title - if (jfi->xNode != NULL && (n = XmlGetChild(jfi->xNode, L"title")) != NULL && XmlGetText(n) != NULL) + if (jfi->xNode != nullptr && (n = XmlGetChild(jfi->xNode, L"title")) != nullptr && XmlGetText(n) != nullptr) SetWindowText(hwndDlg, XmlGetText(n)); else SetWindowText(hwndDlg, TranslateW(jfi->defTitle)); // Set instruction field - if (jfi->xNode != NULL && (n = XmlGetChild(jfi->xNode, L"instructions")) != NULL && XmlGetText(n) != NULL) + if (jfi->xNode != nullptr && (n = XmlGetChild(jfi->xNode, L"instructions")) != nullptr && XmlGetText(n) != nullptr) JabberFormSetInstruction(hwndDlg, XmlGetText(n)); else { - if (jfi->xNode != NULL && (n = XmlGetChild(jfi->xNode, L"title")) != NULL && XmlGetText(n) != NULL) + if (jfi->xNode != nullptr && (n = XmlGetChild(jfi->xNode, L"title")) != nullptr && XmlGetText(n) != nullptr) JabberFormSetInstruction(hwndDlg, XmlGetText(n)); else JabberFormSetInstruction(hwndDlg, TranslateW(jfi->defTitle)); } // Create form - if (jfi->xNode != NULL) { + if (jfi->xNode != nullptr) { RECT rect; GetClientRect(GetDlgItem(hwndDlg, IDC_FRAME), &(jfi->frameRect)); GetClientRect(GetDlgItem(hwndDlg, IDC_VSCROLL), &rect); @@ -761,7 +761,7 @@ static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_FRAME), GWL_EXSTYLE, frameExStyle); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)jfi); - if (jfi->pfnSubmit != NULL) + if (jfi->pfnSubmit != nullptr) EnableWindow(GetDlgItem(hwndDlg, IDC_SUBMIT), TRUE); } return TRUE; @@ -772,7 +772,7 @@ static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, (GetWindowLongPtr((HWND)lParam, GWL_ID) == IDC_TITLE)) { return (INT_PTR)GetStockObject(WHITE_BRUSH); } - return NULL; + return 0; case WM_MOUSEWHEEL: { @@ -787,7 +787,7 @@ static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, break; case WM_VSCROLL: - if (jfi != NULL) { + if (jfi != nullptr) { int pos = jfi->curPos; switch (LOWORD(wParam)) { case SB_LINEDOWN: @@ -811,7 +811,7 @@ static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, if (pos < 0) pos = 0; if (jfi->curPos != pos) { - ScrollWindow(GetDlgItem(hwndDlg, IDC_FRAME), 0, jfi->curPos - pos, NULL, &(jfi->frameRect)); + ScrollWindow(GetDlgItem(hwndDlg, IDC_FRAME), 0, jfi->curPos - pos, nullptr, &(jfi->frameRect)); SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, pos, TRUE); jfi->curPos = pos; } @@ -821,7 +821,7 @@ static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_SUBMIT: - if (jfi != NULL) { + if (jfi != nullptr) { HXML n = JabberFormGetData(GetDlgItem(hwndDlg, IDC_FRAME), jfi->xNode); (jfi->ppro->*(jfi->pfnSubmit))(n, jfi->userdata); xmlDestroyNode(n); @@ -849,7 +849,7 @@ static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, static VOID CALLBACK JabberFormCreateDialogApcProc(void* param) { - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FORM), NULL, JabberFormDlgProc, (LPARAM)param); + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FORM), nullptr, JabberFormDlgProc, (LPARAM)param); } void CJabberProto::FormCreateDialog(HXML xNode, wchar_t* defTitle, JABBER_FORM_SUBMIT_FUNC pfnSubmit, void *userdata) diff --git a/protocols/JabberG/src/jabber_frame.cpp b/protocols/JabberG/src/jabber_frame.cpp index f405f809b1..735c4807fb 100644 --- a/protocols/JabberG/src/jabber_frame.cpp +++ b/protocols/JabberG/src/jabber_frame.cpp @@ -59,7 +59,7 @@ public: void SetInfo(HANDLE hIcolibIcon, wchar_t *pszText) { mir_free(m_pszText); - m_pszText = pszText ? mir_wstrdup(pszText) : NULL; + m_pszText = pszText ? mir_wstrdup(pszText) : nullptr; m_hIcolibIcon = hIcolibIcon; } @@ -79,7 +79,7 @@ CJabberInfoFrame::CJabberInfoFrame(CJabberProto *proto): CLISTFrame frame = { sizeof(frame) }; HWND hwndClist = pcli->hwndContactList; - frame.hWnd = CreateWindowEx(0, L"JabberInfoFrameClass", NULL, WS_CHILD|WS_VISIBLE, 0, 0, 100, 100, hwndClist, NULL, hInst, this); + frame.hWnd = CreateWindowEx(0, L"JabberInfoFrameClass", nullptr, WS_CHILD|WS_VISIBLE, 0, 0, 100, 100, hwndClist, nullptr, hInst, this); frame.align = alBottom; frame.height = 2 * SZ_FRAMEPADDING + GetSystemMetrics(SM_CYSMICON) + SZ_LINEPADDING; // compact height by default frame.Flags = F_VISIBLE|F_LOCKED|F_NOBORDER|F_UNICODE; @@ -95,10 +95,10 @@ CJabberInfoFrame::CJabberInfoFrame(CJabberProto *proto): m_hhkFontsChanged = HookEventMessage(ME_FONT_RELOAD, m_hwnd, WM_APP); ReloadFonts(); - m_hwndToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, + m_hwndToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nullptr, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - m_hwnd, NULL, hInst, NULL); + m_hwnd, nullptr, hInst, nullptr); SetWindowPos(m_hwndToolTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); CreateInfoItem("$", true); @@ -116,13 +116,13 @@ CJabberInfoFrame::~CJabberInfoFrame() if (m_hhkFontsChanged) UnhookEvent(m_hhkFontsChanged); - if (m_hwnd != NULL) { + if (m_hwnd != nullptr) { SetWindowLongPtr(m_hwnd, GWLP_USERDATA, 0); DestroyWindow(m_hwnd); DestroyWindow(m_hwndToolTip); DeleteObject(m_hfntText); DeleteObject(m_hfntTitle); - m_hwnd = NULL; + m_hwnd = nullptr; } } @@ -138,7 +138,7 @@ void CJabberInfoFrame::InitClass() wcx.lpfnWndProc = GlobalWndProc; wcx.hInstance = hInst; wcx.lpszClassName = L"JabberInfoFrameClass"; - wcx.hCursor = LoadCursor(NULL, IDC_ARROW); + wcx.hCursor = LoadCursor(nullptr, IDC_ARROW); RegisterClassEx(&wcx); bClassRegistered = true; } @@ -180,9 +180,9 @@ LRESULT CJabberInfoFrame::WndProc(UINT msg, WPARAM wParam, LPARAM lParam) case WM_RBUTTONUP: { POINT pt = { LOWORD(lParam), HIWORD(lParam) }; - MapWindowPoints(m_hwnd, NULL, &pt, 1); + MapWindowPoints(m_hwnd, nullptr, &pt, 1); HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDFRAMECONTEXT, m_frameId, 0); - int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, pcli->hwndContactList, NULL); + int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, pcli->hwndContactList, nullptr); Clist_MenuProcessCommand(res, 0, m_frameId); return 0; } @@ -269,7 +269,7 @@ void CJabberInfoFrame::UpdateSize() } else { CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, m_frameId), height); - RedrawWindow(m_hwnd, NULL, NULL, RDW_INVALIDATE); + RedrawWindow(m_hwnd, nullptr, nullptr, RDW_INVALIDATE); } } else CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, m_frameId), height); @@ -328,7 +328,7 @@ void CJabberInfoFrame::PaintSkinGlyph(HDC hdc, RECT *rc, char **glyphs, COLORREF void CJabberInfoFrame::PaintCompact(HDC hdc) { RECT rc; GetClientRect(m_hwnd, &rc); - char *glyphs[] = { "Main,ID=ProtoInfo", "Main,ID=EventArea", "Main,ID=StatusBar", NULL }; + char *glyphs[] = { "Main,ID=ProtoInfo", "Main,ID=EventArea", "Main,ID=StatusBar", nullptr }; PaintSkinGlyph(hdc, &rc, glyphs, m_clBack); HFONT hfntSave = (HFONT)SelectObject(hdc, m_hfntTitle); @@ -353,7 +353,7 @@ void CJabberInfoFrame::PaintCompact(HDC hdc) if (item.m_hIcolibIcon) { HICON hIcon = IcoLib_GetIconByHandle(item.m_hIcolibIcon); if (hIcon) { - DrawIconEx(hdc, SZ_FRAMEPADDING, (rc.bottom-cy_icon)/2, hIcon, cx_icon, cy_icon, 0, NULL, DI_NORMAL); + DrawIconEx(hdc, SZ_FRAMEPADDING, (rc.bottom-cy_icon)/2, hIcon, cx_icon, cy_icon, 0, nullptr, DI_NORMAL); IcoLib_ReleaseIcon(hIcon); } } @@ -366,7 +366,7 @@ void CJabberInfoFrame::PaintCompact(HDC hdc) HICON hIcon = IcoLib_GetIconByHandle(item.m_hIcolibIcon); if (hIcon) { SetRect(&item.m_rcItem, cx, (rc.bottom-cy_icon)/2, cx+cx_icon, (rc.bottom-cy_icon)/2+cy_icon); - DrawIconEx(hdc, cx, (rc.bottom-cy_icon)/2, hIcon, cx_icon, cy_icon, 0, NULL, DI_NORMAL); + DrawIconEx(hdc, cx, (rc.bottom-cy_icon)/2, hIcon, cx_icon, cy_icon, 0, nullptr, DI_NORMAL); cx -= cx_icon; IcoLib_ReleaseIcon(hIcon); @@ -383,7 +383,7 @@ void CJabberInfoFrame::PaintCompact(HDC hdc) void CJabberInfoFrame::PaintNormal(HDC hdc) { RECT rc; GetClientRect(m_hwnd, &rc); - char *glyphs[] = { "Main,ID=ProtoInfo", "Main,ID=EventArea", "Main,ID=StatusBar", NULL }; + char *glyphs[] = { "Main,ID=ProtoInfo", "Main,ID=EventArea", "Main,ID=StatusBar", nullptr }; PaintSkinGlyph(hdc, &rc, glyphs, m_clBack); HFONT hfntSave = (HFONT)SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT)); @@ -411,7 +411,7 @@ void CJabberInfoFrame::PaintNormal(HDC hdc) if (item.m_hIcolibIcon) { HICON hIcon = IcoLib_GetIconByHandle(item.m_hIcolibIcon); if (hIcon) { - DrawIconEx(hdc, cx, cy + (line_height-cy_icon)/2, hIcon, cx_icon, cy_icon, 0, NULL, DI_NORMAL); + DrawIconEx(hdc, cx, cy + (line_height-cy_icon)/2, hIcon, cx_icon, cy_icon, 0, nullptr, DI_NORMAL); cx += cx_icon + SZ_ICONSPACING; IcoLib_ReleaseIcon(hIcon); @@ -454,7 +454,7 @@ void CJabberInfoFrame::UpdateInfoItem(char *pszName, HANDLE hIcolibIcon, wchar_t if (CJabberInfoFrameItem *pItem = m_pItems.find((CJabberInfoFrameItem*)&pszName)) pItem->SetInfo(hIcolibIcon, pszText); if (m_hwnd) - RedrawWindow(m_hwnd, NULL, NULL, RDW_INVALIDATE); + RedrawWindow(m_hwnd, nullptr, nullptr, RDW_INVALIDATE); } void CJabberInfoFrame::ShowInfoItem(char *pszName, bool bShow) @@ -500,6 +500,6 @@ void CJabberProto::InitInfoFrame() m_pInfoFrame = new CJabberInfoFrame(this); else { delete m_pInfoFrame; - m_pInfoFrame = NULL; + m_pInfoFrame = nullptr; } } diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp index eb34f5afe4..93d093ecda 100644 --- a/protocols/JabberG/src/jabber_ft.cpp +++ b/protocols/JabberG/src/jabber_ft.cpp @@ -51,13 +51,13 @@ void CJabberProto::FtCancel(filetransfer *ft) } // For file transfer through bytestream JABBER_BYTE_TRANSFER *jbt = ft->jbt; - if (jbt != NULL) { + if (jbt != nullptr) { debugLogA("Canceling bytestream session"); jbt->state = JBT_ERROR; if (jbt->hConn) { debugLogA("Force closing bytestream session"); Netlib_CloseHandle(jbt->hConn); - jbt->hConn = NULL; + jbt->hConn = nullptr; } if (jbt->hSendEvent) SetEvent(jbt->hSendEvent); if (jbt->hEvent) SetEvent(jbt->hEvent); @@ -66,7 +66,7 @@ void CJabberProto::FtCancel(filetransfer *ft) // For file transfer through IBB JABBER_IBB_TRANSFER *jibb = ft->jibb; - if (jibb != NULL) { + if (jibb != nullptr) { debugLogA("Canceling IBB session"); jibb->state = JIBB_ERROR; m_iqManager.ExpireByUserData(jibb); @@ -82,7 +82,7 @@ void CJabberProto::FtInitiate(wchar_t* jid, filetransfer *ft) int i; wchar_t sid[9]; - if (jid == NULL || ft == NULL || !m_bJabberOnline || (rs = ListGetBestClientResourceNamePtr(jid)) == NULL) { + if (jid == nullptr || ft == nullptr || !m_bJabberOnline || (rs = ListGetBestClientResourceNamePtr(jid)) == nullptr) { if (ft) { ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); delete ft; @@ -93,10 +93,10 @@ void CJabberProto::FtInitiate(wchar_t* jid, filetransfer *ft) for (i = 0; i < 8; i++) sid[i] = (rand() % 10) + '0'; sid[8] = '\0'; - if (ft->sid != NULL) mir_free(ft->sid); + if (ft->sid != nullptr) mir_free(ft->sid); ft->sid = mir_wstrdup(sid); filename = ft->std.ptszFiles[ft->std.currentFileNumber]; - if ((p = wcsrchr(filename, '\\')) != NULL) + if ((p = wcsrchr(filename, '\\')) != nullptr) filename = p + 1; wchar_t tszJid[512]; @@ -130,16 +130,16 @@ void CJabberProto::OnFtSiResult(HXML iqNode, CJabberIqInfo *pInfo) if (!ft) return; if ((pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) && pInfo->m_szFrom && pInfo->m_szTo) { - if ((siNode = XmlGetChild(iqNode, "si")) != NULL) { + if ((siNode = XmlGetChild(iqNode, "si")) != nullptr) { // fix for very smart clients, like gajim BOOL bDirect = m_options.BsDirect; BOOL bProxy = m_options.BsProxyManual; - if ((featureNode = XmlGetChild(siNode, "feature")) != NULL) { - if ((xNode = XmlGetChildByTag(featureNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS)) != NULL) { - if ((fieldNode = XmlGetChildByTag(xNode, "field", "var", L"stream-method")) != NULL) { - if ((valueNode = XmlGetChild(fieldNode, "value")) != NULL && XmlGetText(valueNode) != NULL) { + if ((featureNode = XmlGetChild(siNode, "feature")) != nullptr) { + if ((xNode = XmlGetChildByTag(featureNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS)) != nullptr) { + if ((fieldNode = XmlGetChildByTag(xNode, "field", "var", L"stream-method")) != nullptr) { + if ((valueNode = XmlGetChild(fieldNode, "value")) != nullptr && XmlGetText(valueNode) != nullptr) { if ((bDirect || bProxy) && !mir_wstrcmp(XmlGetText(valueNode), JABBER_FEAT_BYTESTREAMS)) { // Start Bytestream session JABBER_BYTE_TRANSFER *jbt = new JABBER_BYTE_TRANSFER; @@ -198,7 +198,7 @@ BOOL CJabberProto::FtSend(HNETLIBCONN hConn, filetransfer *ft) ft->std.currentFileSize = statbuf.st_size; ft->std.currentFileProgress = 0; - if ((buffer = (char*)mir_alloc(2048)) != NULL) { + if ((buffer = (char*)mir_alloc(2048)) != nullptr) { while ((numRead = _read(fd, buffer, 2048)) > 0) { if (Netlib_Send(hConn, buffer, numRead, 0) != numRead) { mir_free(buffer); @@ -233,7 +233,7 @@ BOOL CJabberProto::FtIbbSend(int blocksize, filetransfer *ft) ft->std.currentFileProgress = 0; ptrA buffer((char*)mir_alloc(blocksize)); - if (buffer != NULL) { + if (buffer != nullptr) { int numRead; while ((numRead = _read(fd, buffer, blocksize)) > 0) { int iqId = SerialNext(); @@ -306,24 +306,24 @@ void CJabberProto::FtHandleSiRequest(HXML iqNode) unsigned __int64 filesize; if (!iqNode || - (from = XmlGetAttrValue(iqNode, L"from")) == NULL || - (str = XmlGetAttrValue(iqNode, L"type")) == NULL || mir_wstrcmp(str, L"set") || - (siNode = XmlGetChildByTag(iqNode, "si", "xmlns", JABBER_FEAT_SI)) == NULL) + (from = XmlGetAttrValue(iqNode, L"from")) == nullptr || + (str = XmlGetAttrValue(iqNode, L"type")) == nullptr || mir_wstrcmp(str, L"set") || + (siNode = XmlGetChildByTag(iqNode, "si", "xmlns", JABBER_FEAT_SI)) == nullptr) return; szId = XmlGetAttrValue(iqNode, L"id"); - if ((sid = XmlGetAttrValue(siNode, L"id")) != NULL && - (fileNode = XmlGetChildByTag(siNode, "file", "xmlns", JABBER_FEAT_SI_FT)) != NULL && - (filename = XmlGetAttrValue(fileNode, L"name")) != NULL && - (str = XmlGetAttrValue(fileNode, L"size")) != NULL) { + if ((sid = XmlGetAttrValue(siNode, L"id")) != nullptr && + (fileNode = XmlGetChildByTag(siNode, "file", "xmlns", JABBER_FEAT_SI_FT)) != nullptr && + (filename = XmlGetAttrValue(fileNode, L"name")) != nullptr && + (str = XmlGetAttrValue(fileNode, L"size")) != nullptr) { filesize = _wtoi64(str); - if ((featureNode = XmlGetChildByTag(siNode, "feature", "xmlns", JABBER_FEAT_FEATURE_NEG)) != NULL && - (xNode = XmlGetChildByTag(featureNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS)) != NULL && - (fieldNode = XmlGetChildByTag(xNode, "field", "var", L"stream-method")) != NULL) { + if ((featureNode = XmlGetChildByTag(siNode, "feature", "xmlns", JABBER_FEAT_FEATURE_NEG)) != nullptr && + (xNode = XmlGetChildByTag(featureNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS)) != nullptr && + (fieldNode = XmlGetChildByTag(xNode, "field", "var", L"stream-method")) != nullptr) { BOOL bIbbOnly = m_options.BsOnlyIBB; - HXML optionNode = NULL; + HXML optionNode = nullptr; JABBER_FT_TYPE ftType = FT_OOB; if (!bIbbOnly) { @@ -333,7 +333,7 @@ void CJabberProto::FtHandleSiRequest(HXML iqNode) break; if (!mir_wstrcmp(XmlGetName(optionNode), L"option")) { - if ((n = XmlGetChild(optionNode, "value")) != NULL && XmlGetText(n)) { + if ((n = XmlGetChild(optionNode, "value")) != nullptr && XmlGetText(n)) { if (!mir_wstrcmp(XmlGetText(n), JABBER_FEAT_BYTESTREAMS)) { ftType = FT_BYTESTREAM; break; @@ -351,7 +351,7 @@ void CJabberProto::FtHandleSiRequest(HXML iqNode) break; if (!mir_wstrcmp(XmlGetName(optionNode), L"option")) { - if ((n = XmlGetChild(optionNode, "value")) != NULL && XmlGetText(n)) { + if ((n = XmlGetChild(optionNode, "value")) != nullptr && XmlGetText(n)) { if (!mir_wstrcmp(XmlGetText(n), JABBER_FEAT_IBB)) { ftType = FT_IBB; break; @@ -361,7 +361,7 @@ void CJabberProto::FtHandleSiRequest(HXML iqNode) } } - if (optionNode != NULL) { + if (optionNode != nullptr) { // Found known stream mechanism filetransfer *ft = new filetransfer(this); ft->dwExpectedRecvFileSize = filesize; @@ -377,10 +377,10 @@ void CJabberProto::FtHandleSiRequest(HXML iqNode) PROTORECVFILET pre = { 0 }; pre.dwFlags = PRFF_UNICODE; pre.fileCount = 1; - pre.timestamp = time(NULL); + pre.timestamp = time(nullptr); pre.files.w = (wchar_t**)&filename; pre.lParam = (LPARAM)ft; - if ((n = XmlGetChild(fileNode, "desc")) != NULL) + if ((n = XmlGetChild(fileNode, "desc")) != nullptr) pre.descr.w = (wchar_t*)XmlGetText(n); ProtoChainRecvFile(ft->std.hContact, &pre); @@ -408,10 +408,10 @@ void CJabberProto::FtHandleSiRequest(HXML iqNode) void CJabberProto::FtAcceptSiRequest(filetransfer *ft) { - if (!m_bJabberOnline || ft == NULL || ft->jid == NULL || ft->sid == NULL) return; + if (!m_bJabberOnline || ft == nullptr || ft->jid == nullptr || ft->sid == nullptr) return; JABBER_LIST_ITEM *item; - if ((item = ListAdd(LIST_FTRECV, ft->sid)) != NULL) { + if ((item = ListAdd(LIST_FTRECV, ft->sid)) != nullptr) { item->ft = ft; m_ThreadInfo->send( @@ -426,10 +426,10 @@ void CJabberProto::FtAcceptSiRequest(filetransfer *ft) void CJabberProto::FtAcceptIbbRequest(filetransfer *ft) { - if (!m_bJabberOnline || ft == NULL || ft->jid == NULL || ft->sid == NULL) return; + if (!m_bJabberOnline || ft == nullptr || ft->jid == nullptr || ft->sid == nullptr) return; JABBER_LIST_ITEM *item; - if ((item = ListAdd(LIST_FTRECV, ft->sid)) != NULL) { + if ((item = ListAdd(LIST_FTRECV, ft->sid)) != nullptr) { item->ft = ft; m_ThreadInfo->send( @@ -449,7 +449,7 @@ BOOL CJabberProto::FtHandleBytestreamRequest(HXML iqNode, CJabberIqInfo *pInfo) const wchar_t *sid; JABBER_LIST_ITEM *item; - if ((sid = XmlGetAttrValue(queryNode, L"sid")) != NULL && (item = ListGetItemPtr(LIST_FTRECV, sid)) != NULL) { + if ((sid = XmlGetAttrValue(queryNode, L"sid")) != nullptr && (item = ListGetItemPtr(LIST_FTRECV, sid)) != nullptr) { // Start Bytestream session JABBER_BYTE_TRANSFER *jbt = new JABBER_BYTE_TRANSFER; memset(jbt, 0, sizeof(JABBER_BYTE_TRANSFER)); @@ -469,7 +469,7 @@ BOOL CJabberProto::FtHandleBytestreamRequest(HXML iqNode, CJabberIqInfo *pInfo) BOOL CJabberProto::FtHandleIbbRequest(HXML iqNode, BOOL bOpen) { - if (iqNode == NULL) return FALSE; + if (iqNode == nullptr) return FALSE; const wchar_t *id = XmlGetAttrValue(iqNode, L"id"); const wchar_t *from = XmlGetAttrValue(iqNode, L"from"); @@ -484,7 +484,7 @@ BOOL CJabberProto::FtHandleIbbRequest(HXML iqNode, BOOL bOpen) // already closed? JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_FTRECV, sid); - if (item == NULL) { + if (item == nullptr) { m_ThreadInfo->send( XmlNodeIq(L"error", id, from) << XCHILD(L"error") << XATTRI(L"code", 404) << XATTR(L"type", L"cancel") diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index 5f433b2f74..47baaa5565 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -40,7 +40,7 @@ struct JabberGcRecentInfo { ppro = proto; } - JabberGcRecentInfo(CJabberProto *proto, const wchar_t *room, const wchar_t *server, const wchar_t *nick = NULL, const wchar_t *password = NULL) + JabberGcRecentInfo(CJabberProto *proto, const wchar_t *room, const wchar_t *server, const wchar_t *nick = nullptr, const wchar_t *password = nullptr) { ppro = proto; fillData(room, server, nick, password); @@ -62,10 +62,10 @@ struct JabberGcRecentInfo void cleanup() { - m_room = m_server = m_nick = m_password = NULL; + m_room = m_server = m_nick = m_password = nullptr; } - BOOL equals(const wchar_t *room, const wchar_t *server, const wchar_t *nick = NULL, const wchar_t *password = NULL) + BOOL equals(const wchar_t *room, const wchar_t *server, const wchar_t *nick = nullptr, const wchar_t *password = nullptr) { return null_strequals(m_room, room) && @@ -74,7 +74,7 @@ struct JabberGcRecentInfo null_strequals(m_password, password); } - BOOL equalsnp(const wchar_t *room, const wchar_t *server, const wchar_t *nick = NULL) + BOOL equalsnp(const wchar_t *room, const wchar_t *server, const wchar_t *nick = nullptr) { return null_strequals(m_room, room) && @@ -90,7 +90,7 @@ struct JabberGcRecentInfo SetDlgItemText(hwndDlg, IDC_PASSWORD, m_password ? m_password : L""); } - void fillData(const wchar_t *room, const wchar_t *server, const wchar_t *nick = NULL, const wchar_t *password = NULL) + void fillData(const wchar_t *room, const wchar_t *server, const wchar_t *nick = nullptr, const wchar_t *password = nullptr) { m_room = mir_wstrdup(room); m_server = mir_wstrdup(server); @@ -100,7 +100,7 @@ struct JabberGcRecentInfo void fillData(const wchar_t *jid) { - wchar_t *room, *server, *nick = NULL; + wchar_t *room, *server, *nick = nullptr; room = NEWWSTR_ALLOCA(jid); server = wcschr(room, '@'); if (server) { @@ -110,7 +110,7 @@ struct JabberGcRecentInfo } else { server = room; - room = NULL; + room = nullptr; } fillData(room, server, nick); @@ -129,7 +129,7 @@ struct JabberGcRecentInfo m_nick = ppro->getWStringA(setting); mir_snprintf(setting, "password_rcMuc_%d", iRecent); - m_password = ppro->getWStringA(NULL, setting); + m_password = ppro->getWStringA(0, setting); return m_room || m_server || m_nick || m_password; } @@ -179,26 +179,26 @@ private: INT_PTR __cdecl CJabberProto::OnMenuHandleJoinGroupchat(WPARAM, LPARAM) { - GroupchatJoinRoomByJid(NULL, NULL); + GroupchatJoinRoomByJid(nullptr, nullptr); return 0; } INT_PTR __cdecl CJabberProto::OnJoinChat(WPARAM hContact, LPARAM) { ptrW jid(getWStringA(hContact, "ChatRoomID")); - if (jid == NULL) + if (jid == nullptr) return 0; ptrW nick(getWStringA(hContact, "MyNick")); - if (nick == NULL) - if ((nick = getWStringA("Nick")) == NULL) + if (nick == nullptr) + if ((nick = getWStringA("Nick")) == nullptr) return 0; ptrW password(getWStringA(hContact, "Password")); if (getWord(hContact, "Status", 0) != ID_STATUS_ONLINE) { wchar_t *p = wcschr(jid, '@'); - if (p != NULL) { + if (p != nullptr) { *p++ = 0; GroupchatJoinRoom(p, jid, nick, password); } @@ -210,11 +210,11 @@ INT_PTR __cdecl CJabberProto::OnJoinChat(WPARAM hContact, LPARAM) INT_PTR __cdecl CJabberProto::OnLeaveChat(WPARAM hContact, LPARAM) { ptrW jid(getWStringA(hContact, "ChatRoomID")); - if (jid != NULL) { + if (jid != nullptr) { if (getWord(hContact, "Status", 0) != ID_STATUS_OFFLINE) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, jid); - if (item != NULL) - GcQuit(item, 200, NULL); + if (item != nullptr) + GcQuit(item, 200, nullptr); } } return 0; @@ -297,7 +297,7 @@ void CJabberProto::OnIqResultDiscovery(HXML iqNode, CJabberIqInfo *pInfo) if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) { HXML query = XmlGetChild(iqNode, "query"); - if (query == NULL) { + if (query == nullptr) { sttRoomListAppend(hwndList, RoomInfo::ROOM_FAIL, TranslateT("Jabber Error"), TranslateT("Failed to retrieve room list from server."), @@ -371,12 +371,12 @@ static void sttJoinDlgShowRecentItems(HWND hwndDlg, int newCount) int ctrls[] = { IDC_BOOKMARKS, IDOK, IDCANCEL }; for (int i = 0; i < _countof(ctrls); i++) { GetWindowRect(GetDlgItem(hwndDlg, ctrls[i]), &rc); - MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rc, 2); - SetWindowPos(GetDlgItem(hwndDlg, ctrls[i]), NULL, rc.left, rc.top + offset, 0, 0, SWP_NOSIZE | SWP_NOZORDER); + MapWindowPoints(nullptr, hwndDlg, (LPPOINT)&rc, 2); + SetWindowPos(GetDlgItem(hwndDlg, ctrls[i]), nullptr, rc.left, rc.top + offset, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } GetWindowRect(hwndDlg, &rc); - SetWindowPos(hwndDlg, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top + offset, SWP_NOMOVE | SWP_NOZORDER); + SetWindowPos(hwndDlg, nullptr, 0, 0, rc.right - rc.left, rc.bottom - rc.top + offset, SWP_NOMOVE | SWP_NOZORDER); } class CJabberDlgGcJoin : public CJabberDlgBase @@ -401,7 +401,7 @@ protected: }; CJabberDlgGcJoin::CJabberDlgGcJoin(CJabberProto *proto, wchar_t *jid) : - CSuper(proto, IDD_GROUPCHAT_JOIN, NULL), + CSuper(proto, IDD_GROUPCHAT_JOIN, nullptr), btnOk(this, IDOK), m_jid(mir_wstrdup(jid)) { @@ -419,7 +419,7 @@ void CJabberDlgGcJoin::OnInitDialog() Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_GROUP)); - JabberGcRecentInfo *pInfo = NULL; + JabberGcRecentInfo *pInfo = nullptr; if (m_jid) pInfo = new JabberGcRecentInfo(m_proto, m_jid); else if (OpenClipboard(m_hwnd)) { @@ -440,7 +440,7 @@ void CJabberDlgGcJoin::OnInitDialog() } ptrW tszNick(m_proto->getWStringA("Nick")); - if (tszNick == NULL) + if (tszNick == nullptr) tszNick = JabberNickFromJID(m_proto->m_szJabberJID); SetDlgItemText(m_hwnd, IDC_NICK, tszNick); @@ -480,12 +480,12 @@ void CJabberDlgGcJoin::OnInitDialog() void CJabberDlgGcJoin::OnDestroy() { IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BM_SETIMAGE, IMAGE_ICON, 0)); - m_proto->m_pDlgJabberJoinGroupchat = NULL; + m_proto->m_pDlgJabberJoinGroupchat = nullptr; DeleteObject((HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_GETFONT, 0, 0)); CSuper::OnDestroy(); - mir_free(m_jid); m_jid = NULL; + mir_free(m_jid); m_jid = nullptr; } void CJabberDlgGcJoin::OnBtnOk(CCtrlButton*) @@ -574,16 +574,16 @@ INT_PTR CJabberDlgGcJoin::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) SetTextColor(lpdis->hDC, clLine2); DrawText(lpdis->hDC, info->line2, -1, &rc, DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS); - DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("group"), 16, 16, 0, NULL, DI_NORMAL); + DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("group"), 16, 16, 0, nullptr, DI_NORMAL); switch (info->overlay) { case RoomInfo::ROOM_WAIT: - DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("disco_progress"), 16, 16, 0, NULL, DI_NORMAL); + DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("disco_progress"), 16, 16, 0, nullptr, DI_NORMAL); break; case RoomInfo::ROOM_FAIL: - DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("disco_fail"), 16, 16, 0, NULL, DI_NORMAL); + DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("disco_fail"), 16, 16, 0, nullptr, DI_NORMAL); break; case RoomInfo::ROOM_BOOKMARK: - DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("disco_ok"), 16, 16, 0, NULL, DI_NORMAL); + DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("disco_ok"), 16, 16, 0, nullptr, DI_NORMAL); break; } } @@ -655,13 +655,13 @@ INT_PTR CJabberDlgGcJoin::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) if (!mir_wstrcmp(item->type, L"conference")) AppendMenu(hMenu, MF_STRING, (UINT_PTR)item, item->name); } - AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); + AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr); AppendMenu(hMenu, MF_STRING, (UINT_PTR)-1, TranslateT("Bookmarks...")); AppendMenu(hMenu, MF_STRING, (UINT_PTR)0, TranslateT("Cancel")); RECT rc; GetWindowRect(GetDlgItem(m_hwnd, IDC_BOOKMARKS), &rc); CheckDlgButton(m_hwnd, IDC_BOOKMARKS, BST_CHECKED); - int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, m_hwnd, NULL); + int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, m_hwnd, nullptr); CheckDlgButton(m_hwnd, IDC_BOOKMARKS, BST_UNCHECKED); DestroyMenu(hMenu); @@ -697,7 +697,7 @@ INT_PTR CJabberDlgGcJoin::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) if (GetAsyncKeyState(VK_CONTROL)) break; - OnBtnOk(NULL); + OnBtnOk(nullptr); Close(); } break; @@ -742,11 +742,11 @@ struct JabberGroupchatChangeNicknameParam static VOID CALLBACK JabberGroupchatChangeNickname(void* arg) { JabberGroupchatChangeNicknameParam *param = (JabberGroupchatChangeNicknameParam*)arg; - if (param == NULL) + if (param == nullptr) return; JABBER_LIST_ITEM *item = param->ppro->ListGetItemPtr(LIST_CHATROOM, param->jid); - if (item != NULL) { + if (item != nullptr) { CMStringW szBuffer, szTitle; szTitle.Format(TranslateT("Change nickname in <%s>"), item->name ? item->name : item->jid); if (item->nick) @@ -754,7 +754,7 @@ static VOID CALLBACK JabberGroupchatChangeNickname(void* arg) if (param->ppro->EnterString(szBuffer, szTitle, ESF_COMBO, "gcNick_")) { replaceStrW(item->nick, szBuffer); - param->ppro->SendPresenceTo(param->ppro->m_iStatus, CMStringW(FORMAT, L"%s/%s", item->jid, szBuffer.c_str()), NULL); + param->ppro->SendPresenceTo(param->ppro->m_iStatus, CMStringW(FORMAT, L"%s/%s", item->jid, szBuffer.c_str()), nullptr); } } @@ -764,11 +764,11 @@ static VOID CALLBACK JabberGroupchatChangeNickname(void* arg) static int sttGetStatusCode(HXML node) { HXML statusNode = XmlGetChild(node, "status"); - if (statusNode == NULL) + if (statusNode == nullptr) return -1; const wchar_t *statusCode = XmlGetAttrValue(statusNode, L"code"); - if (statusCode == NULL) + if (statusCode == nullptr) return -1; return _wtol(statusCode); @@ -778,11 +778,11 @@ void CJabberProto::RenameParticipantNick(JABBER_LIST_ITEM *item, const wchar_t * { const wchar_t *jid = XmlGetAttrValue(itemNode, L"jid"); const wchar_t *newNick = XmlGetAttrValue(itemNode, L"nick"); - if (newNick == NULL) + if (newNick == nullptr) return; pResourceStatus r(item->findResource(oldNick)); - if (r == NULL) + if (r == nullptr) return; r->m_tszResourceName = mir_wstrdup(newNick); @@ -791,7 +791,7 @@ void CJabberProto::RenameParticipantNick(JABBER_LIST_ITEM *item, const wchar_t * replaceStrW(item->nick, newNick); MCONTACT hContact = HContactFromJID(item->jid); - if (hContact != NULL) + if (hContact != 0) setWString(hContact, "MyNick", newNick); } @@ -799,7 +799,7 @@ void CJabberProto::RenameParticipantNick(JABBER_LIST_ITEM *item, const wchar_t * GCDEST gcd = { m_szModuleName, item->jid, GC_EVENT_NICK }; GCEVENT gce = { &gcd }; - if (jid != NULL) + if (jid != nullptr) gce.ptszUserInfo = jid; gce.time = time(0); gce.ptszNick = oldNick; @@ -813,14 +813,14 @@ void CJabberProto::GroupchatProcessPresence(HXML node) const wchar_t *from; if (!node || !XmlGetName(node) || mir_wstrcmp(XmlGetName(node), L"presence")) return; - if ((from = XmlGetAttrValue(node, L"from")) == NULL) return; + if ((from = XmlGetAttrValue(node, L"from")) == nullptr) return; const wchar_t *resource = wcschr(from, '/'); - if (resource == NULL || *++resource == '\0') + if (resource == nullptr || *++resource == '\0') return; JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, from); - if (item == NULL) + if (item == nullptr) return; pResourceStatus r(item->findResource(resource)); @@ -839,8 +839,8 @@ void CJabberProto::GroupchatProcessPresence(HXML node) const wchar_t *type = XmlGetAttrValue(node, L"type"); // entering room or a usual room presence - if (type == NULL || !mir_wstrcmp(type, L"available")) { - if (ptrW(JabberNickFromJID(from)) == NULL) + if (type == nullptr || !mir_wstrcmp(type, L"available")) { + if (ptrW(JabberNickFromJID(from)) == nullptr) return; GcInit(item); @@ -870,21 +870,21 @@ void CJabberProto::GroupchatProcessPresence(HXML node) bStatusChanged = true; // Check additional MUC info for this user - if (itemNode != NULL) { - if (r == NULL) + if (itemNode != nullptr) { + if (r == nullptr) r = item->findResource(resource); - if (r != NULL) { + if (r != nullptr) { JABBER_GC_AFFILIATION affiliation = r->m_affiliation; JABBER_GC_ROLE role = r->m_role; - if ((str = XmlGetAttrValue(itemNode, L"affiliation")) != NULL) { + if ((str = XmlGetAttrValue(itemNode, L"affiliation")) != nullptr) { if (!mir_wstrcmp(str, L"owner")) affiliation = AFFILIATION_OWNER; else if (!mir_wstrcmp(str, L"admin")) affiliation = AFFILIATION_ADMIN; else if (!mir_wstrcmp(str, L"member")) affiliation = AFFILIATION_MEMBER; else if (!mir_wstrcmp(str, L"none")) affiliation = AFFILIATION_NONE; else if (!mir_wstrcmp(str, L"outcast")) affiliation = AFFILIATION_OUTCAST; } - if ((str = XmlGetAttrValue(itemNode, L"role")) != NULL) { + if ((str = XmlGetAttrValue(itemNode, L"role")) != nullptr) { if (!mir_wstrcmp(str, L"moderator")) role = ROLE_MODERATOR; else if (!mir_wstrcmp(str, L"participant")) role = ROLE_PARTICIPANT; else if (!mir_wstrcmp(str, L"visitor")) role = ROLE_VISITOR; @@ -892,7 +892,7 @@ void CJabberProto::GroupchatProcessPresence(HXML node) } if ((role != ROLE_NONE) && (JabberGcGetStatus(r) != JabberGcGetStatus(affiliation, role))) { - GcLogUpdateMemberStatus(item, resource, nick, NULL, GC_EVENT_REMOVESTATUS, NULL); + GcLogUpdateMemberStatus(item, resource, nick, nullptr, GC_EVENT_REMOVESTATUS, nullptr); if (!newRes) newRes = GC_EVENT_ADDSTATUS; } @@ -921,19 +921,19 @@ void CJabberProto::GroupchatProcessPresence(HXML node) GcLogShowInformation(item, res, INFO_STATUS); // Update groupchat log window - GcLogUpdateMemberStatus(item, resource, nick, str, newRes, NULL); + GcLogUpdateMemberStatus(item, resource, nick, str, newRes, nullptr); if (r && bAffiliationChanged) GcLogShowInformation(item, r, INFO_AFFILIATION); if (r && bRoleChanged) GcLogShowInformation(item, r, INFO_ROLE); // update clist status MCONTACT hContact = HContactFromJID(from); - if (hContact != NULL) + if (hContact != 0) setWord(hContact, "Status", status); // Check if (bRoomCreated) { HXML n = XmlGetChild(node, "created"); - if (n != NULL && (str = XmlGetAttrValue(n, L"xmlns")) != NULL && !mir_wstrcmp(str, JABBER_FEAT_MUC_OWNER)) + if (n != nullptr && (str = XmlGetAttrValue(n, L"xmlns")) != nullptr && !mir_wstrcmp(str, JABBER_FEAT_MUC_OWNER)) // A new room just created by me // Request room config m_ThreadInfo->send( @@ -945,12 +945,12 @@ void CJabberProto::GroupchatProcessPresence(HXML node) // leaving room else if (!mir_wstrcmp(type, L"unavailable")) { const wchar_t *str = 0; - if (xNode != NULL && item->nick != NULL) { + if (xNode != nullptr && item->nick != nullptr) { HXML reasonNode = XmlGetChild(itemNode, "reason"); str = XmlGetAttrValue(itemNode, L"jid"); int iStatus = sttGetStatusCode(xNode); - if (iStatus == 301 && r != NULL) + if (iStatus == 301 && r != nullptr) GcLogShowInformation(item, r, INFO_BAN); if (!mir_wstrcmp(resource, item->nick)) { @@ -986,7 +986,7 @@ void CJabberProto::GroupchatProcessPresence(HXML node) ListRemoveResource(LIST_CHATROOM, from); MCONTACT hContact = HContactFromJID(from); - if (hContact != NULL) + if (hContact != 0) setWord(hContact, "Status", ID_STATUS_OFFLINE); } @@ -998,11 +998,11 @@ void CJabberProto::GroupchatProcessPresence(HXML node) if (errorCode == JABBER_ERROR_CONFLICT) { ptrW newNick(getWStringA("GcAltNick")); - if (++item->iChatState == 1 && newNick != NULL && newNick[0] != 0) { + if (++item->iChatState == 1 && newNick != nullptr && newNick[0] != 0) { replaceStrW(item->nick, newNick); wchar_t text[1024] = { 0 }; mir_snwprintf(text, L"%s/%s", item->jid, newNick); - SendPresenceTo(m_iStatus, text, NULL); + SendPresenceTo(m_iStatus, text, nullptr); } else { CallFunctionAsync(JabberGroupchatChangeNickname, new JabberGroupchatChangeNicknameParam(this, from)); @@ -1011,9 +1011,9 @@ void CJabberProto::GroupchatProcessPresence(HXML node) return; } - MsgPopup(NULL, str, TranslateT("Jabber Error")); + MsgPopup(0, str, TranslateT("Jabber Error")); - if (item != NULL && !item->bChatActive) + if (item != nullptr && !item->bChatActive) ListRemove(LIST_CHATROOM, from); } } @@ -1026,37 +1026,37 @@ void CJabberProto::GroupchatProcessMessage(HXML node) CMStringW imgLink; if (!XmlGetName(node) || mir_wstrcmp(XmlGetName(node), L"message")) return; - if ((from = XmlGetAttrValue(node, L"from")) == NULL) return; - if ((item = ListGetItemPtr(LIST_CHATROOM, from)) == NULL) return; + if ((from = XmlGetAttrValue(node, L"from")) == nullptr) return; + if ((item = ListGetItemPtr(LIST_CHATROOM, from)) == nullptr) return; - if ((type = XmlGetAttrValue(node, L"type")) == NULL) return; + if ((type = XmlGetAttrValue(node, L"type")) == nullptr) return; if (!mir_wstrcmp(type, L"error")) return; GCDEST gcd = { m_szModuleName, item->jid, 0 }; - const wchar_t *msgText = NULL; + const wchar_t *msgText = nullptr; resource = wcschr(from, '/'); - if (resource != NULL && *++resource == '\0') - resource = NULL; + if (resource != nullptr && *++resource == '\0') + resource = nullptr; - if ((n = XmlGetChild(node, "subject")) != NULL) { + if ((n = XmlGetChild(node, "subject")) != nullptr) { msgText = XmlGetText(n); - if (msgText == NULL || msgText[0] == '\0') + if (msgText == nullptr || msgText[0] == '\0') return; gcd.iType = GC_EVENT_TOPIC; - if (resource == NULL && (m = XmlGetChild(node, "body")) != NULL) { + if (resource == nullptr && (m = XmlGetChild(node, "body")) != nullptr) { const wchar_t *tmpnick = XmlGetText(m); - if (tmpnick == NULL || *tmpnick == 0) + if (tmpnick == nullptr || *tmpnick == 0) return; const wchar_t *tmptr = wcsstr(tmpnick, L"has set the subject to:"); //ejabberd - if (tmptr == NULL) + if (tmptr == nullptr) tmptr = wcsstr(tmpnick, TranslateT("has set the subject to:")); //ejabberd - if (tmptr != NULL && *tmptr != 0) { + if (tmptr != nullptr && *tmptr != 0) { *(wchar_t*)(--tmptr) = 0; resource = tmpnick; } @@ -1066,15 +1066,15 @@ void CJabberProto::GroupchatProcessMessage(HXML node) else { imgLink = ExtractImage(node); - if ((n = XmlGetChildByTag(node, "body", "xml:lang", m_tszSelectedLang)) == NULL) - if ((n = XmlGetChild(node, "body")) == NULL) + if ((n = XmlGetChildByTag(node, "body", "xml:lang", m_tszSelectedLang)) == nullptr) + if ((n = XmlGetChild(node, "body")) == nullptr) return; msgText = XmlGetText(n); - if (msgText == NULL) + if (msgText == nullptr) return; - if (resource == NULL) + if (resource == nullptr) gcd.iType = GC_EVENT_INFORMATION; else if (wcsncmp(msgText, L"/me ", 4) == 0 && mir_wstrlen(msgText) > 4) { msgText += 4; @@ -1088,20 +1088,20 @@ void CJabberProto::GroupchatProcessMessage(HXML node) time_t msgTime = 0; if (!JabberReadXep203delay(node, msgTime)) { HXML xDelay = XmlGetChildByTag(node, "x", "xmlns", L"jabber:x:delay"); - if (xDelay && (p = XmlGetAttrValue(xDelay, L"stamp")) != NULL) + if (xDelay && (p = XmlGetAttrValue(xDelay, L"stamp")) != nullptr) msgTime = JabberIsoToUnixTime(p); } bool isHistory = msgTime != 0; - time_t now = time(NULL); + time_t now = time(nullptr); if (!msgTime || msgTime > now) msgTime = now; - if (resource != NULL) { + if (resource != nullptr) { pResourceStatus r(item->findResource(resource)); nick = (r && r->m_tszNick) ? r->m_tszNick : resource; } - else nick = NULL; + else nick = nullptr; CMStringW tszText(msgText); tszText.Replace(L"%", L"%%"); @@ -1112,7 +1112,7 @@ void CJabberProto::GroupchatProcessMessage(HXML node) gce.ptszNick = nick; gce.time = msgTime; gce.ptszText = tszText; - gce.bIsMe = nick == NULL ? FALSE : (mir_wstrcmp(resource, item->nick) == 0); + gce.bIsMe = nick == nullptr ? FALSE : (mir_wstrcmp(resource, item->nick) == 0); if (!isHistory) gce.dwFlags |= GCEF_ADDTOLOG; @@ -1139,7 +1139,7 @@ class CGroupchatInviteAcceptDlg : public CJabberDlgBase public: CGroupchatInviteAcceptDlg(CJabberProto *ppro, const wchar_t *roomJid, const wchar_t *from, const wchar_t *reason, const wchar_t *password) : - CSuper(ppro, IDD_GROUPCHAT_INVITE_ACCEPT, NULL), + CSuper(ppro, IDD_GROUPCHAT_INVITE_ACCEPT, nullptr), m_roomJid(roomJid), m_from(from), m_reason(reason), m_password(password), m_accept(this, IDC_ACCEPT) { @@ -1180,7 +1180,7 @@ static void __stdcall sttShowDialog(void *pArg) void CJabberProto::GroupchatProcessInvite(const wchar_t *roomJid, const wchar_t *from, const wchar_t *reason, const wchar_t *password) { - if (roomJid == NULL) + if (roomJid == nullptr) return; if (ListGetItemPtr(LIST_CHATROOM, roomJid)) @@ -1188,9 +1188,9 @@ void CJabberProto::GroupchatProcessInvite(const wchar_t *roomJid, const wchar_t if (m_options.AutoAcceptMUC) { ptrW nick(getWStringA(HContactFromJID(m_szJabberJID), "MyNick")); - if (nick == NULL) + if (nick == nullptr) nick = getWStringA("Nick"); - if (nick == NULL) + if (nick == nullptr) nick = JabberNickFromJID(m_szJabberJID); AcceptGroupchatInvite(roomJid, nick, password); } @@ -1202,6 +1202,6 @@ void CJabberProto::AcceptGroupchatInvite(const wchar_t *roomJid, const wchar_t * wchar_t room[256], *server, *p; wcsncpy_s(room, roomJid, _TRUNCATE); p = wcstok(room, L"@"); - server = wcstok(NULL, L"@"); + server = wcstok(nullptr, L"@"); GroupchatJoinRoom(server, p, reason, password); } diff --git a/protocols/JabberG/src/jabber_ibb.cpp b/protocols/JabberG/src/jabber_ibb.cpp index 7f0ad3baa4..9482e44f60 100644 --- a/protocols/JabberG/src/jabber_ibb.cpp +++ b/protocols/JabberG/src/jabber_ibb.cpp @@ -35,7 +35,7 @@ void JabberIbbFreeJibb(JABBER_IBB_TRANSFER *jibb) if (jibb) { filetransfer* pft = jibb->ft; if (pft) - pft->jibb = NULL; + pft->jibb = nullptr; mir_free(jibb->srcJID); mir_free(jibb->dstJID); @@ -91,7 +91,7 @@ void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb) debugLogA("Thread started: type=ibb_send"); Thread_SetName("Jabber: IbbSendThread"); - jibb->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + jibb->hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); jibb->bStreamInitialized = FALSE; jibb->bStreamClosed = FALSE; jibb->state = JIBB_SENDING; @@ -103,7 +103,7 @@ void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb) WaitForSingleObject(jibb->hEvent, INFINITE); CloseHandle(jibb->hEvent); - jibb->hEvent = NULL; + jibb->hEvent = nullptr; if (jibb->bStreamInitialized) { jibb->wPacketId = 0; @@ -111,7 +111,7 @@ void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb) BOOL bSent = (this->*jibb->pfnSend)(JABBER_IBB_BLOCK_SIZE, jibb->ft); if (!jibb->bStreamClosed) { - jibb->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + jibb->hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); m_ThreadInfo->send( XmlNodeIq(AddIQ(&CJabberProto::OnIbbCloseResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb)) @@ -119,7 +119,7 @@ void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb) WaitForSingleObject(jibb->hEvent, INFINITE); CloseHandle(jibb->hEvent); - jibb->hEvent = NULL; + jibb->hEvent = nullptr; if (jibb->bStreamClosed && bSent) jibb->state = JIBB_DONE; @@ -128,7 +128,7 @@ void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb) } (this->*jibb->pfnFinal)((jibb->state==JIBB_DONE)?TRUE:FALSE, jibb->ft); - jibb->ft = NULL; + jibb->ft = nullptr; JabberIbbFreeJibb(jibb); } @@ -139,7 +139,7 @@ void __cdecl CJabberProto::IbbReceiveThread(JABBER_IBB_TRANSFER *jibb) filetransfer *ft = jibb->ft; - jibb->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + jibb->hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); jibb->bStreamClosed = FALSE; jibb->wPacketId = 0; jibb->dwTransferredSize = 0; @@ -148,7 +148,7 @@ void __cdecl CJabberProto::IbbReceiveThread(JABBER_IBB_TRANSFER *jibb) WaitForSingleObject(jibb->hEvent, INFINITE); CloseHandle(jibb->hEvent); - jibb->hEvent = NULL; + jibb->hEvent = nullptr; if (jibb->state == JIBB_ERROR) m_ThreadInfo->send( XmlNodeIq(L"set", SerialNext(), jibb->dstJID) << XCHILDNS(L"close", JABBER_FEAT_IBB) << XATTR(L"sid", jibb->sid)); @@ -157,7 +157,7 @@ void __cdecl CJabberProto::IbbReceiveThread(JABBER_IBB_TRANSFER *jibb) jibb->state = JIBB_DONE; (this->*jibb->pfnFinal)((jibb->state==JIBB_DONE)?TRUE:FALSE, jibb->ft); - jibb->ft = NULL; + jibb->ft = nullptr; ListRemove(LIST_FTRECV, jibb->sid); @@ -167,7 +167,7 @@ void __cdecl CJabberProto::IbbReceiveThread(JABBER_IBB_TRANSFER *jibb) BOOL CJabberProto::OnIbbRecvdData(const wchar_t *data, const wchar_t *sid, const wchar_t *seq) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_FTRECV, sid); - if (item == NULL) return FALSE; + if (item == nullptr) return FALSE; WORD wSeq = (WORD)_wtoi(seq); if (wSeq != item->jibb->wPacketId) { @@ -180,10 +180,10 @@ BOOL CJabberProto::OnIbbRecvdData(const wchar_t *data, const wchar_t *sid, const unsigned length; ptrA decodedData((char*)mir_base64_decode( _T2A(data), &length)); - if (decodedData == NULL) + if (decodedData == nullptr) return FALSE; - (this->*item->jibb->pfnRecv)(NULL, item->ft, decodedData, length); + (this->*item->jibb->pfnRecv)(nullptr, item->ft, decodedData, length); item->jibb->dwTransferredSize += (DWORD)length; return TRUE; } diff --git a/protocols/JabberG/src/jabber_icolib.cpp b/protocols/JabberG/src/jabber_icolib.cpp index e522cb8fce..98957ca5eb 100644 --- a/protocols/JabberG/src/jabber_icolib.cpp +++ b/protocols/JabberG/src/jabber_icolib.cpp @@ -37,7 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define IDI_ONTHEPHONE 1002 #define IDI_OUTTOLUNCH 1003 -HIMAGELIST hAdvancedStatusIcon = NULL; +HIMAGELIST hAdvancedStatusIcon = nullptr; struct CTransportProtoTableItem { @@ -87,7 +87,7 @@ int CIconPool::CPoolItem::cmp(const CPoolItem *p1, const CPoolItem *p2) } CIconPool::CPoolItem::CPoolItem() : - m_name(NULL), m_szIcolibName(NULL), m_hIcolibItem(NULL) + m_name(nullptr), m_szIcolibName(nullptr), m_hIcolibItem(nullptr) { } @@ -136,7 +136,7 @@ HANDLE CIconPool::GetIcolibHandle(const char *name) if (CPoolItem *item = FindItemByName(name)) return item->m_hIcolibItem; - return NULL; + return nullptr; } char *CIconPool::GetIcolibName(const char *name) @@ -144,7 +144,7 @@ char *CIconPool::GetIcolibName(const char *name) if (CPoolItem *item = FindItemByName(name)) return item->m_szIcolibName; - return NULL; + return nullptr; } HICON CIconPool::GetIcon(const char *name, bool big) @@ -152,7 +152,7 @@ HICON CIconPool::GetIcon(const char *name, bool big) if (CPoolItem *item = FindItemByName(name)) return IcoLib_GetIconByHandle(item->m_hIcolibItem, big); - return NULL; + return nullptr; } CIconPool::CPoolItem *CIconPool::FindItemByName(const char *name) @@ -188,7 +188,7 @@ HICON CJabberProto::LoadIconEx(const char* name, bool big) if (!mir_strcmp(name, "main")) return IcoLib_GetIconByHandle(m_hProtoIcon, big); - return NULL; + return nullptr; } ///////////////////////////////////////////////////////////////////////////////////////// @@ -259,13 +259,13 @@ static HICON ExtractIconFromPath(const char *path, BOOL * needFree) HICON hIcon; mir_strncpy(file, path, sizeof(file)); comma = strrchr(file, ','); - if (comma == NULL) n = 0; + if (comma == nullptr) n = 0; else { n = atoi(comma + 1); *comma = 0; } PathToAbsolute(file, fileFull); - hIcon = NULL; - ExtractIconExA(fileFull, n, NULL, &hIcon, 1); + hIcon = nullptr; + ExtractIconExA(fileFull, n, nullptr, &hIcon, 1); if (needFree) - *needFree = (hIcon != NULL); + *needFree = (hIcon != nullptr); return hIcon; } @@ -275,18 +275,18 @@ static HICON LoadTransportIcon(char *filename, int i, char *IconName, wchar_t *S char szPath[MAX_PATH], szMyPath[MAX_PATH], szFullPath[MAX_PATH], *str; BOOL has_proto_icon = FALSE; if (needFree) *needFree = FALSE; - GetModuleFileNameA(NULL, szPath, MAX_PATH); + GetModuleFileNameA(nullptr, szPath, MAX_PATH); str = strrchr(szPath, '\\'); - if (str != NULL) *str = 0; + if (str != nullptr) *str = 0; mir_snprintf(szMyPath, "%s\\Icons\\%s", szPath, filename); mir_snprintf(szFullPath, "%s\\Icons\\%s,%d", szPath, filename, i); BOOL nf; HICON hi = ExtractIconFromPath(szFullPath, &nf); if (hi) has_proto_icon = TRUE; if (hi && nf) DestroyIcon(hi); - if (IconName != NULL && SectName != NULL) { + if (IconName != nullptr && SectName != nullptr) { SKINICONDESC sid = { 0 }; - sid.hDefaultIcon = (has_proto_icon) ? NULL : Skin_LoadProtoIcon(0, -internalidx); + sid.hDefaultIcon = (has_proto_icon) ? nullptr : Skin_LoadProtoIcon(0, -internalidx); sid.section.w = SectName; sid.pszName = IconName; sid.description.w = Description; @@ -412,15 +412,15 @@ BOOL CJabberProto::DBCheckIsTransportedContact(const wchar_t *jid, MCONTACT hCon // strip domain part from jid wchar_t *domain = wcschr((wchar_t*)jid, '@'); - BOOL isAgent = (domain == NULL) ? TRUE : FALSE; + BOOL isAgent = (domain == nullptr) ? TRUE : FALSE; BOOL isTransported = FALSE; - if (domain != NULL) + if (domain != nullptr) domain = NEWWSTR_ALLOCA(domain + 1); else domain = NEWWSTR_ALLOCA(jid); wchar_t *resourcepos = wcschr(domain, '/'); - if (resourcepos != NULL) + if (resourcepos != nullptr) *resourcepos = '\0'; for (int i = 0; i < _countof(TransportProtoTable); i++) @@ -548,7 +548,7 @@ HANDLE g_GetIconHandle(int iconId) if (sharedIconList4[i].defIconID == iconId) return sharedIconList4[i].hIcolib; - return NULL; + return nullptr; } HICON g_LoadIconEx(const char* name, bool big) diff --git a/protocols/JabberG/src/jabber_iq.cpp b/protocols/JabberG/src/jabber_iq.cpp index 7737a68f05..4d9929b945 100644 --- a/protocols/JabberG/src/jabber_iq.cpp +++ b/protocols/JabberG/src/jabber_iq.cpp @@ -47,7 +47,7 @@ CJabberIqManager::CJabberIqManager(CJabberProto *proto) : m_bExpirerThreadShutdownRequest(false) { m_dwLastUsedHandle = 0; - m_hExpirerThread = NULL; + m_hExpirerThread = nullptr; ppro = proto; } @@ -77,7 +77,7 @@ void CJabberIqManager::Shutdown() WaitForSingleObject(m_hExpirerThread, INFINITE); CloseHandle(m_hExpirerThread); - m_hExpirerThread = NULL; + m_hExpirerThread = nullptr; } void CJabberIqManager::FillPermanentHandlers() @@ -104,7 +104,7 @@ void CJabberIqManager::FillPermanentHandlers() AddPermanentHandler(&CJabberProto::OnIqRequestPrivacyLists, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_PRIVACY_LISTS, FALSE, L"query"); // in band bytestreams (XEP-0047) - AddPermanentHandler(&CJabberProto::OnFtHandleIbbIq, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_CHILD_TAG_NAME | JABBER_IQ_PARSE_CHILD_TAG_XMLNS, JABBER_FEAT_IBB, FALSE, NULL); + AddPermanentHandler(&CJabberProto::OnFtHandleIbbIq, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_CHILD_TAG_NAME | JABBER_IQ_PARSE_CHILD_TAG_XMLNS, JABBER_FEAT_IBB, FALSE, nullptr); // socks5-bytestreams (XEP-0065) AddPermanentHandler(&CJabberProto::FtHandleBytestreamRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_BYTESTREAMS, FALSE, L"query"); @@ -157,7 +157,7 @@ void CJabberIqManager::ExpirerThread() if (!m_bExpirerThreadShutdownRequest) { CloseHandle(m_hExpirerThread); - m_hExpirerThread = NULL; + m_hExpirerThread = nullptr; } } @@ -174,7 +174,7 @@ void CJabberIqManager::ExpireInfo(CJabberIqInfo *pInfo) ppro->debugLogW(L"Expiring iq id %d, sent to %s", pInfo->m_nIqId, pInfo->m_szReceiver ? pInfo->m_szReceiver : L"server"); pInfo->m_nIqType = JABBER_IQ_TYPE_FAIL; - (ppro->*(pInfo->m_pHandler))(NULL, pInfo); + (ppro->*(pInfo->m_pHandler))(nullptr, pInfo); delete pInfo; } @@ -240,7 +240,7 @@ bool CJabberIqManager::DeleteHandler(CJabberIqInfo *pInfo) bool CJabberIqManager::HandleIq(int nIqId, HXML pNode) { - if (nIqId == -1 || pNode == NULL) + if (nIqId == -1 || pNode == nullptr) return false; const wchar_t *szType = XmlGetAttrValue(pNode, L"type"); @@ -256,7 +256,7 @@ bool CJabberIqManager::HandleIq(int nIqId, HXML pNode) return false; CJabberIqInfo *pInfo = DetouchInfo(nIqId); - if (pInfo == NULL) + if (pInfo == nullptr) return false; do { @@ -285,7 +285,7 @@ bool CJabberIqManager::HandleIq(int nIqId, HXML pNode) (ppro->*(pInfo->m_pHandler))(pNode, pInfo); delete pInfo; } - while ((pInfo = DetouchInfo(nIqId)) != NULL); + while ((pInfo = DetouchInfo(nIqId)) != nullptr); return true; } @@ -366,7 +366,7 @@ CJabberIqInfo* CJabberIqManager::DetouchInfo(int nIqId) return pInfo; } } - return NULL; + return nullptr; } CJabberIqInfo* CJabberIqManager::DetouchInfo(void *pUserData) @@ -380,7 +380,7 @@ CJabberIqInfo* CJabberIqManager::DetouchInfo(void *pUserData) return pInfo; } } - return NULL; + return nullptr; } CJabberIqInfo* CJabberIqManager::DetouchExpired() @@ -397,7 +397,7 @@ CJabberIqInfo* CJabberIqManager::DetouchExpired() } } - return NULL; + return nullptr; } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/JabberG/src/jabber_iq.h b/protocols/JabberG/src/jabber_iq.h index 5e76dbe384..9476b34189 100644 --- a/protocols/JabberG/src/jabber_iq.h +++ b/protocols/JabberG/src/jabber_iq.h @@ -106,7 +106,7 @@ public: case JABBER_IQ_TYPE_ERROR: return "error"; case JABBER_IQ_TYPE_RESULT: return "result"; } - return NULL; + return nullptr; } }; @@ -166,7 +166,7 @@ public: // fucking params, maybe just return CJabberIqRequestInfo pointer ? CJabberIqInfo* AddHandler(JABBER_IQ_HANDLER pHandler, int nIqType, const wchar_t *szReceiver, DWORD dwParamsToParse, int nIqId, void *pUserData, int iPriority); - CJabberIqPermanentInfo* AddPermanentHandler(JABBER_PERMANENT_IQ_HANDLER pHandler, int nIqTypes, DWORD dwParamsToParse, const wchar_t *szXmlns, BOOL bAllowPartialNs, const wchar_t *szTag, void *pUserData = NULL, IQ_USER_DATA_FREE_FUNC pUserDataFree = NULL, int iPriority = JH_PRIORITY_DEFAULT); + CJabberIqPermanentInfo* AddPermanentHandler(JABBER_PERMANENT_IQ_HANDLER pHandler, int nIqTypes, DWORD dwParamsToParse, const wchar_t *szXmlns, BOOL bAllowPartialNs, const wchar_t *szTag, void *pUserData = nullptr, IQ_USER_DATA_FREE_FUNC pUserDataFree = nullptr, int iPriority = JH_PRIORITY_DEFAULT); // returns TRUE when pInfo found, or FALSE otherwise bool DeletePermanentHandler(CJabberIqPermanentInfo *pInfo); diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp index 932cc896db..c8dfdfbde9 100644 --- a/protocols/JabberG/src/jabber_iq_handlers.cpp +++ b/protocols/JabberG/src/jabber_iq_handlers.cpp @@ -109,7 +109,7 @@ BOOL CJabberProto::OnIqRequestTime(HXML, CJabberIqInfo *pInfo) XmlNodeIq iq(L"result", pInfo); HXML timeNode = iq << XCHILDNS(L"time", JABBER_FEAT_ENTITY_TIME); timeNode << XCHILD(L"utc", stime); timeNode << XCHILD(L"tzo", szTZ); - LPCTSTR szTZName = TimeZone_GetName(NULL); + LPCTSTR szTZName = TimeZone_GetName(nullptr); if (szTZName) timeNode << XCHILD(L"tz", szTZName); m_ThreadInfo->send(iq); @@ -134,7 +134,7 @@ BOOL CJabberProto::OnIqProcessIqOldTime(HXML, CJabberIqInfo *pInfo) XmlNodeIq iq(L"result", pInfo); HXML queryNode = iq << XQUERY(JABBER_FEAT_ENTITY_TIME_OLD); queryNode << XCHILD(L"utc", stime); - LPCTSTR szTZName = TimeZone_GetName(NULL); + LPCTSTR szTZName = TimeZone_GetName(nullptr); if (szTZName) queryNode << XCHILD(L"tz", szTZName); queryNode << XCHILD(L"display", dtime); @@ -152,19 +152,19 @@ BOOL CJabberProto::OnIqRequestAvatar(HXML, CJabberIqInfo *pInfo) return TRUE; const wchar_t *szMimeType = ProtoGetAvatarMimeType(pictureType); - if (szMimeType == NULL) + if (szMimeType == nullptr) return TRUE; wchar_t szFileName[MAX_PATH]; - GetAvatarFileName(NULL, szFileName, _countof(szFileName)); + GetAvatarFileName(0, szFileName, _countof(szFileName)); FILE* in = _wfopen(szFileName, L"rb"); - if (in == NULL) + if (in == nullptr) return TRUE; long bytes = _filelength(_fileno(in)); ptrA buffer((char*)mir_alloc(bytes * 4 / 3 + bytes + 1000)); - if (buffer == NULL) { + if (buffer == nullptr) { fclose(in); return TRUE; } @@ -237,18 +237,18 @@ BOOL CJabberProto::OnRosterPushRequest(HXML, CJabberIqInfo *pInfo) if (mir_wstrcmp(XmlGetName(itemNode), L"item") != 0) continue; - if ((jid = XmlGetAttrValue(itemNode, L"jid")) == NULL) + if ((jid = XmlGetAttrValue(itemNode, L"jid")) == nullptr) continue; - if ((str = XmlGetAttrValue(itemNode, L"subscription")) == NULL) + if ((str = XmlGetAttrValue(itemNode, L"subscription")) == nullptr) continue; // we will not add new account when subscription=remove if (!mir_wstrcmp(str, L"to") || !mir_wstrcmp(str, L"both") || !mir_wstrcmp(str, L"from") || !mir_wstrcmp(str, L"none")) { const wchar_t *name = XmlGetAttrValue(itemNode, L"name"); - ptrW nick((name != NULL) ? mir_wstrdup(name) : JabberNickFromJID(jid)); - if (nick != NULL) { + ptrW nick((name != nullptr) ? mir_wstrdup(name) : JabberNickFromJID(jid)); + if (nick != nullptr) { MCONTACT hContact = HContactFromJID(jid, false); - if (hContact == NULL) + if (hContact == 0) hContact = DBCreateContact(jid, nick, false, false); else setWString(hContact, "jid", jid); @@ -260,9 +260,9 @@ BOOL CJabberProto::OnRosterPushRequest(HXML, CJabberIqInfo *pInfo) HXML groupNode = XmlGetChild(itemNode, "group"); replaceStrW(item->group, XmlGetText(groupNode)); - if (name != NULL) { + if (name != nullptr) { ptrW tszNick(getWStringA(hContact, "Nick")); - if (tszNick != NULL) { + if (tszNick != nullptr) { if (mir_wstrcmp(nick, tszNick) != 0) db_set_ws(hContact, "CList", "MyHandle", nick); else @@ -273,7 +273,7 @@ BOOL CJabberProto::OnRosterPushRequest(HXML, CJabberIqInfo *pInfo) else db_unset(hContact, "CList", "MyHandle"); if (!m_options.IgnoreRosterGroups) { - if (item->group != NULL) { + if (item->group != nullptr) { Clist_GroupCreate(0, item->group); db_set_ws(hContact, "CList", "Group", item->group); } @@ -334,20 +334,20 @@ BOOL CJabberProto::OnIqRequestOOB(HXML, CJabberIqInfo *pInfo) ft->jid = mir_wstrdup(pInfo->GetFrom()); ft->std.hContact = pInfo->GetHContact(); ft->type = FT_OOB; - ft->httpHostName = NULL; + ft->httpHostName = nullptr; ft->httpPort = 80; - ft->httpPath = NULL; + ft->httpPath = nullptr; // Parse the URL wchar_t *str = (wchar_t*)XmlGetText(n); // URL of the file to get if (!wcsnicmp(str, L"http://", 7)) { wchar_t *p = str + 7, *q; - if ((q = wcschr(p, '/')) != NULL) { + if ((q = wcschr(p, '/')) != nullptr) { wchar_t text[1024]; if (q - p < _countof(text)) { wcsncpy_s(text, p, q - p); text[q - p] = '\0'; - if ((p = wcschr(text, ':')) != NULL) { + if ((p = wcschr(text, ':')) != nullptr) { ft->httpPort = (WORD)_wtoi(p + 1); *p = '\0'; } @@ -360,15 +360,15 @@ BOOL CJabberProto::OnIqRequestOOB(HXML, CJabberIqInfo *pInfo) ft->szId = JabberId2string(pInfo->GetIqId()); if (ft->httpHostName && ft->httpPath) { - wchar_t *desc = NULL; + wchar_t *desc = nullptr; debugLogA("Host=%s Port=%d Path=%s", ft->httpHostName, ft->httpPort, ft->httpPath); - if ((n = XmlGetChild(pInfo->GetChildNode(), "desc")) != NULL) + if ((n = XmlGetChild(pInfo->GetChildNode(), "desc")) != nullptr) desc = (wchar_t*)XmlGetText(n); wchar_t *str2; debugLogW(L"description = %s", desc); - if ((str2 = wcsrchr(ft->httpPath, '/')) != NULL) + if ((str2 = wcsrchr(ft->httpPath, '/')) != nullptr) str2++; else str2 = ft->httpPath; @@ -377,7 +377,7 @@ BOOL CJabberProto::OnIqRequestOOB(HXML, CJabberIqInfo *pInfo) PROTORECVFILET pre; pre.dwFlags = PRFF_UNICODE; - pre.timestamp = time(NULL); + pre.timestamp = time(nullptr); pre.descr.w = desc; pre.files.w = &str2; pre.fileCount = 1; diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index 715c6344d3..94a2fbb7ea 100755 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void CJabberProto::OnIqResultServerDiscoInfo(HXML iqNode, CJabberIqInfo*) { - if (iqNode == NULL) + if (iqNode == nullptr) return; const wchar_t *type = XmlGetAttrValue(iqNode, L"type"); @@ -39,11 +39,11 @@ void CJabberProto::OnIqResultServerDiscoInfo(HXML iqNode, CJabberIqInfo*) return; HXML query = XmlGetChildByTag(iqNode, "query", "xmlns", JABBER_FEAT_DISCO_INFO); - if (query == NULL) + if (query == nullptr) return; HXML identity; - for (int i = 1; (identity = XmlGetNthChild(query, L"identity", i)) != NULL; i++) { + for (int i = 1; (identity = XmlGetNthChild(query, L"identity", i)) != nullptr; i++) { JABBER_DISCO_FIELD tmp = { XmlGetAttrValue(identity, L"category"), XmlGetAttrValue(identity, L"type"), @@ -68,7 +68,7 @@ void CJabberProto::OnIqResultServerDiscoInfo(HXML iqNode, CJabberIqInfo*) if (m_ThreadInfo) { HXML feature; - for (int i = 1; (feature = XmlGetNthChild(query, L"feature", i)) != NULL; i++) { + for (int i = 1; (feature = XmlGetNthChild(query, L"feature", i)) != nullptr; i++) { const wchar_t *featureName = XmlGetAttrValue(feature, L"var"); if (!featureName) continue; @@ -87,18 +87,18 @@ void CJabberProto::OnIqResultServerDiscoInfo(HXML iqNode, CJabberIqInfo*) void CJabberProto::OnIqResultNestedRosterGroups(HXML iqNode, CJabberIqInfo *pInfo) { - const wchar_t *szGroupDelimeter = NULL; + const wchar_t *szGroupDelimeter = nullptr; bool bPrivateStorageSupport = false; if (iqNode && pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) { bPrivateStorageSupport = true; szGroupDelimeter = XPathFmt(iqNode, L"query[@xmlns='%s']/roster[@xmlns='%s']", JABBER_FEAT_PRIVATE_STORAGE, JABBER_FEAT_NESTED_ROSTER_GROUPS); if (szGroupDelimeter && !szGroupDelimeter[0]) - szGroupDelimeter = NULL; // "" as roster delimeter is not supported :) + szGroupDelimeter = nullptr; // "" as roster delimeter is not supported :) } // global fuckup - if (m_ThreadInfo == NULL) + if (m_ThreadInfo == nullptr) return; // is our default delimiter? @@ -110,7 +110,7 @@ void CJabberProto::OnIqResultNestedRosterGroups(HXML iqNode, CJabberIqInfo *pInf // roster request wchar_t *szUserData = mir_wstrdup(szGroupDelimeter ? szGroupDelimeter : L"\\"); m_ThreadInfo->send( - XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetRoster, JABBER_IQ_TYPE_GET, NULL, 0, -1, (void*)szUserData)) + XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetRoster, JABBER_IQ_TYPE_GET, nullptr, 0, -1, (void*)szUserData)) << XCHILDNS(L"query", JABBER_FEAT_IQ_ROSTER)); } @@ -125,7 +125,7 @@ void CJabberProto::OnIqResultNotes(HXML iqNode, CJabberIqInfo *pInfo) void CJabberProto::OnProcessLoginRq(ThreadData *info, DWORD rq) { - if (info == NULL) + if (info == nullptr) return; info->dwLoginRqs |= rq; @@ -140,7 +140,7 @@ void CJabberProto::OnProcessLoginRq(ThreadData *info, DWORD rq) LISTFOREACH(i, this, LIST_BOOKMARK) { JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i); - if (item != NULL && !mir_wstrcmp(item->type, L"conference") && item->bAutoJoin) + if (item != nullptr && !mir_wstrcmp(item->type, L"conference") && item->bAutoJoin) ll.insert(item); } @@ -151,14 +151,14 @@ void CJabberProto::OnProcessLoginRq(ThreadData *info, DWORD rq) wcsncpy_s(text, item->jid, _TRUNCATE); wcsncpy_s(room, text, _TRUNCATE); wchar_t *p = wcstok(room, L"@"); - wchar_t *server = wcstok(NULL, L"@"); + wchar_t *server = wcstok(nullptr, L"@"); if (item->nick && item->nick[0]) GroupchatJoinRoom(server, p, item->nick, item->password, true); else { ptrW nick(getWStringA(HContactFromJID(m_szJabberJID), "MyNick")); - if (nick == NULL) + if (nick == nullptr) nick = getWStringA("Nick"); - if (nick == NULL) + if (nick == nullptr) nick = JabberNickFromJID(m_szJabberJID); GroupchatJoinRoom(server, p, nick, item->password, true); @@ -207,7 +207,7 @@ void CJabberProto::OnLoggedIn() QueryPrivacyLists(m_ThreadInfo); ptrA szServerName(getStringA("LastLoggedServer")); - if (szServerName == NULL || mir_strcmp(m_ThreadInfo->conn.server, szServerName)) + if (szServerName == nullptr || mir_strcmp(m_ThreadInfo->conn.server, szServerName)) SendGetVcard(m_szJabberJID); setString("LastLoggedServer", m_ThreadInfo->conn.server); @@ -223,21 +223,21 @@ void CJabberProto::OnIqResultGetAuth(HXML iqNode, CJabberIqInfo*) HXML queryNode; const wchar_t *type; - if ((type = XmlGetAttrValue(iqNode, L"type")) == NULL) return; - if ((queryNode = XmlGetChild(iqNode, "query")) == NULL) return; + if ((type = XmlGetAttrValue(iqNode, L"type")) == nullptr) return; + if ((queryNode = XmlGetChild(iqNode, "query")) == nullptr) return; if (!mir_wstrcmp(type, L"result")) { XmlNodeIq iq(AddIQ(&CJabberProto::OnIqResultSetAuth, JABBER_IQ_TYPE_SET)); HXML query = iq << XQUERY(L"jabber:iq:auth"); query << XCHILD(L"username", m_ThreadInfo->conn.username); - if (XmlGetChild(queryNode, "digest") != NULL && m_ThreadInfo->szStreamId) { + if (XmlGetChild(queryNode, "digest") != nullptr && m_ThreadInfo->szStreamId) { JabberShaStrBuf buf; T2Utf str(m_ThreadInfo->conn.password); char text[200]; mir_snprintf(text, "%s%s", m_ThreadInfo->szStreamId, str); query << XCHILD(L"digest", _A2T(JabberSha1(text, buf))); } - else if (XmlGetChild(queryNode, "password") != NULL) + else if (XmlGetChild(queryNode, "password") != nullptr) query << XCHILD(L"password", m_ThreadInfo->conn.password); else { debugLogA("No known authentication mechanism accepted by the server."); @@ -245,7 +245,7 @@ void CJabberProto::OnIqResultGetAuth(HXML iqNode, CJabberIqInfo*) return; } - if (XmlGetChild(queryNode, "resource") != NULL) + if (XmlGetChild(queryNode, "resource") != nullptr) query << XCHILD(L"resource", m_ThreadInfo->resource); m_ThreadInfo->send(iq); @@ -255,9 +255,9 @@ void CJabberProto::OnIqResultGetAuth(HXML iqNode, CJabberIqInfo*) wchar_t text[128]; mir_snwprintf(text, TranslateT("Authentication failed for %s."), m_ThreadInfo->conn.username); - MsgPopup(NULL, text, TranslateT("Jabber Authentication")); + MsgPopup(0, text, TranslateT("Jabber Authentication")); JLoginFailed(LOGINERR_WRONGPASSWORD); - m_ThreadInfo = NULL; // To disallow auto reconnect + m_ThreadInfo = nullptr; // To disallow auto reconnect } } @@ -268,11 +268,11 @@ void CJabberProto::OnIqResultSetAuth(HXML iqNode, CJabberIqInfo*) // RECVED: authentication result // ACTION: if successfully logged in, continue by requesting roster list and set my initial status debugLogA(" iqIdSetAuth"); - if ((type = XmlGetAttrValue(iqNode, L"type")) == NULL) return; + if ((type = XmlGetAttrValue(iqNode, L"type")) == nullptr) return; if (!mir_wstrcmp(type, L"result")) { ptrW tszNick(getWStringA("Nick")); - if (tszNick == NULL) + if (tszNick == nullptr) setWString("Nick", m_ThreadInfo->conn.username); OnLoggedIn(); @@ -283,9 +283,9 @@ void CJabberProto::OnIqResultSetAuth(HXML iqNode, CJabberIqInfo*) m_ThreadInfo->send(""); mir_snwprintf(text, TranslateT("Authentication failed for %s."), m_ThreadInfo->conn.username); - MsgPopup(NULL, text, TranslateT("Jabber Authentication")); + MsgPopup(0, text, TranslateT("Jabber Authentication")); JLoginFailed(LOGINERR_WRONGPASSWORD); - m_ThreadInfo = NULL; // To disallow auto reconnect + m_ThreadInfo = nullptr; // To disallow auto reconnect } } @@ -313,7 +313,7 @@ void CJabberProto::OnIqResultBind(HXML iqNode, CJabberIqInfo *pInfo) else { //rfc3920 page 39 m_ThreadInfo->send(""); - m_ThreadInfo = NULL; // To disallow auto reconnect + m_ThreadInfo = nullptr; // To disallow auto reconnect } } @@ -326,7 +326,7 @@ void CJabberProto::OnIqResultSession(HXML, CJabberIqInfo *pInfo) void CJabberProto::GroupchatJoinByHContact(MCONTACT hContact, bool autojoin) { ptrW roomjid(getWStringA(hContact, "ChatRoomID")); - if (roomjid == NULL) + if (roomjid == nullptr) return; wchar_t *room = roomjid; @@ -337,9 +337,9 @@ void CJabberProto::GroupchatJoinByHContact(MCONTACT hContact, bool autojoin) server[0] = 0; server++; ptrW nick(getWStringA(hContact, "MyNick")); - if (nick == NULL) { + if (nick == nullptr) { nick = JabberNickFromJID(m_szJabberJID); - if (nick == NULL) + if (nick == nullptr) return; } @@ -359,7 +359,7 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo) } HXML queryNode = XmlGetChild(iqNode, "query"); - if (queryNode == NULL) { + if (queryNode == nullptr) { mir_free(szGroupDelimeter); return; } @@ -371,7 +371,7 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo) if (!mir_wstrcmp(szGroupDelimeter, L"\\")) { mir_free(szGroupDelimeter); - szGroupDelimeter = NULL; + szGroupDelimeter = nullptr; } LIST chatRooms(10); @@ -390,25 +390,25 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo) const wchar_t *str = XmlGetAttrValue(itemNode, L"subscription"); JABBER_SUBSCRIPTION sub; - if (str == NULL) sub = SUB_NONE; + if (str == nullptr) sub = SUB_NONE; else if (!mir_wstrcmp(str, L"both")) sub = SUB_BOTH; else if (!mir_wstrcmp(str, L"to")) sub = SUB_TO; else if (!mir_wstrcmp(str, L"from")) sub = SUB_FROM; else sub = SUB_NONE; const wchar_t *jid = XmlGetAttrValue(itemNode, L"jid"); - if (jid == NULL) + if (jid == nullptr) continue; - if (wcschr(jid, '@') == NULL) + if (wcschr(jid, '@') == nullptr) bIsTransport = true; const wchar_t *name = XmlGetAttrValue(itemNode, L"name"); - wchar_t *nick = (name != NULL) ? mir_wstrdup(name) : JabberNickFromJID(jid); - if (nick == NULL) + wchar_t *nick = (name != nullptr) ? mir_wstrdup(name) : JabberNickFromJID(jid); + if (nick == nullptr) continue; MCONTACT hContact = HContactFromJID(jid); - if (hContact == NULL) // Received roster has a new JID. + if (hContact == 0) // Received roster has a new JID. hContact = DBCreateContact(jid, nick, false, false); // Add the jid (with empty resource) to Miranda contact list. JABBER_LIST_ITEM *item = ListAdd(LIST_ROSTER, jid, hContact); @@ -434,9 +434,9 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo) } } - if (name != NULL) { + if (name != nullptr) { ptrW tszNick(getWStringA(hContact, "Nick")); - if (tszNick != NULL) { + if (tszNick != nullptr) { if (mir_wstrcmp(nick, tszNick) != 0) db_set_ws(hContact, "CList", "MyHandle", nick); else @@ -457,12 +457,12 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo) else UpdateSubscriptionInfo(hContact, item); if (!m_options.IgnoreRosterGroups) { - if (item->group != NULL) { + if (item->group != nullptr) { Clist_GroupCreate(0, item->group); // Don't set group again if already correct, or Miranda may show wrong group count in some case ptrW tszGroup(db_get_wsa(hContact, "CList", "Group")); - if (tszGroup != NULL) { + if (tszGroup != nullptr) { if (mir_wstrcmp(tszGroup, item->group)) db_set_ws(hContact, "CList", "Group", item->group); } @@ -471,7 +471,7 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo) else db_unset(hContact, "CList", "Group"); } - if (hContact != NULL) { + if (hContact != 0) { if (bIsTransport) setByte(hContact, "IsTransport", true); else @@ -529,8 +529,8 @@ void CJabberProto::OnIqResultGetRegister(HXML iqNode, CJabberIqInfo*) HXML queryNode; const wchar_t *type; - if ((type = XmlGetAttrValue(iqNode, L"type")) == NULL) return; - if ((queryNode = XmlGetChild(iqNode, "query")) == NULL) return; + if ((type = XmlGetAttrValue(iqNode, L"type")) == nullptr) return; + if ((queryNode = XmlGetChild(iqNode, "query")) == nullptr) return; if (!mir_wstrcmp(type, L"result")) { if (m_hwndAgentRegInput) @@ -553,12 +553,12 @@ void CJabberProto::OnIqResultSetRegister(HXML iqNode, CJabberIqInfo*) debugLogA(" iqIdSetRegister"); const wchar_t *type, *from; - if ((type = XmlGetAttrValue(iqNode, L"type")) == NULL) return; - if ((from = XmlGetAttrValue(iqNode, L"from")) == NULL) return; + if ((type = XmlGetAttrValue(iqNode, L"type")) == nullptr) return; + if ((from = XmlGetAttrValue(iqNode, L"from")) == nullptr) return; if (!mir_wstrcmp(type, L"result")) { MCONTACT hContact = HContactFromJID(from); - if (hContact != NULL) + if (hContact != 0) setByte(hContact, "IsTransport", true); if (m_hwndRegProgress) @@ -585,35 +585,35 @@ void CJabberProto::OnIqResultGetVcardPhoto(HXML n, MCONTACT hContact, bool &hasP HXML o = XmlGetChild(n, "BINVAL"); LPCTSTR ptszBinval = XmlGetText(o); - if (o == NULL || ptszBinval == NULL) + if (o == nullptr || ptszBinval == nullptr) return; unsigned bufferLen; ptrA buffer((char*)mir_base64_decode(_T2A(ptszBinval), &bufferLen)); - if (buffer == NULL) + if (buffer == nullptr) return; const wchar_t *szPicType = JabberGetPictureType(n, buffer); - if (szPicType == NULL) + if (szPicType == nullptr) return; wchar_t szAvatarFileName[MAX_PATH]; GetAvatarFileName(hContact, szAvatarFileName, _countof(szAvatarFileName)); debugLogW(L"Picture file name set to %s", szAvatarFileName); - HANDLE hFile = CreateFile(szAvatarFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFile(szAvatarFileName, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile == INVALID_HANDLE_VALUE) return; debugLogA("Writing %d bytes", bufferLen); DWORD nWritten; - bool bRes = WriteFile(hFile, buffer, bufferLen, &nWritten, NULL) != 0; + bool bRes = WriteFile(hFile, buffer, bufferLen, &nWritten, nullptr) != 0; CloseHandle(hFile); if (!bRes) return; debugLogA("%d bytes written", nWritten); - if (hContact == NULL) { + if (hContact == 0) { hasPhoto = true; CallService(MS_AV_SETMYAVATARW, (WPARAM)m_szModuleName, (LPARAM)szAvatarFileName); @@ -621,14 +621,14 @@ void CJabberProto::OnIqResultGetVcardPhoto(HXML n, MCONTACT hContact, bool &hasP } else { ptrW jid(getWStringA(hContact, "jid")); - if (jid != NULL) { + if (jid != nullptr) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid); - if (item == NULL) { + if (item == nullptr) { item = ListAdd(LIST_VCARD_TEMP, jid); // adding to the temp list to store information about photo - if (item != NULL) + if (item != nullptr) item->bUseResource = true; } - if (item != NULL) { + if (item != nullptr) { hasPhoto = true; if (item->photoFileName && mir_wstrcmp(item->photoFileName, szAvatarFileName)) DeleteFile(item->photoFileName); @@ -646,8 +646,8 @@ void CJabberProto::OnIqResultGetVcardPhoto(HXML n, MCONTACT hContact, bool &hasP static wchar_t* sttGetText(HXML node, char* tag) { HXML n = XmlGetChild(node, tag); - if (n == NULL) - return NULL; + if (n == nullptr) + return nullptr; return (wchar_t*)XmlGetText(n); } @@ -660,14 +660,14 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) DBVARIANT dbv; debugLogA(" iqIdGetVcard"); - if ((type = XmlGetAttrValue(iqNode, L"type")) == NULL) return; - if ((jid = XmlGetAttrValue(iqNode, L"from")) == NULL) return; + if ((type = XmlGetAttrValue(iqNode, L"type")) == nullptr) return; + if ((jid = XmlGetAttrValue(iqNode, L"from")) == nullptr) return; int id = JabberGetPacketID(iqNode); if (id == m_nJabberSearchID) { m_nJabberSearchID = -1; - if ((vCardNode = XmlGetChild(iqNode, "vCard")) != NULL) { + if ((vCardNode = XmlGetChild(iqNode, "vCard")) != nullptr) { if (!mir_wstrcmp(type, L"result")) { PROTOSEARCHRESULT psr = { 0 }; psr.cbSize = sizeof(psr); @@ -677,29 +677,29 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) psr.lastName.w = L""; psr.email.w = sttGetText(vCardNode, "EMAIL"); psr.id.w = NEWWSTR_ALLOCA(jid); - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&psr); - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&psr); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); } else if (!mir_wstrcmp(type, L"error")) - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); } - else ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); + else ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); return; } size_t len = mir_wstrlen(m_szJabberJID); if (!wcsnicmp(jid, m_szJabberJID, len) && (jid[len] == '/' || jid[len] == '\0')) { - hContact = NULL; + hContact = 0; debugLogA("Vcard for myself"); } else { - if ((hContact = HContactFromJID(jid)) == NULL) + if ((hContact = HContactFromJID(jid)) == 0) return; debugLogA("Other user's vcard"); } if (!mir_wstrcmp(type, L"error")) { - if ((hContact = HContactFromJID(jid)) != NULL) + if ((hContact = HContactFromJID(jid)) != 0) ProtoBroadcastAck(hContact, ACKTYPE_GETINFO, ACKRESULT_FAILED, (HANDLE)1, 0); return; } @@ -716,20 +716,20 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) hasOrgname = false, hasOrgunit = false, hasRole = false, hasTitle = false, hasDesc = false, hasPhoto = false; int nEmail = 0, nPhone = 0, nYear, nMonth, nDay; - if ((vCardNode = XmlGetChild(iqNode, "vCard")) != NULL) { + if ((vCardNode = XmlGetChild(iqNode, "vCard")) != nullptr) { for (int i = 0;; i++) { n = XmlGetChild(vCardNode, i); if (!n) break; - if (XmlGetName(n) == NULL) continue; + if (XmlGetName(n) == nullptr) continue; if (!mir_wstrcmp(XmlGetName(n), L"FN")) { - if (XmlGetText(n) != NULL) { + if (XmlGetText(n) != nullptr) { hasFn = true; setWString(hContact, "FullName", XmlGetText(n)); } } else if (!mir_wstrcmp(XmlGetName(n), L"NICKNAME")) { - if (XmlGetText(n) != NULL) { + if (XmlGetText(n) != nullptr) { hasNick = true; setWString(hContact, "Nick", XmlGetText(n)); } @@ -737,15 +737,15 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) else if (!mir_wstrcmp(XmlGetName(n), L"N")) { // First/Last name if (!hasGiven && !hasFamily && !hasMiddle) { - if ((m = XmlGetChild(n, "GIVEN")) != NULL && XmlGetText(m) != NULL) { + if ((m = XmlGetChild(n, "GIVEN")) != nullptr && XmlGetText(m) != nullptr) { hasGiven = true; setWString(hContact, "FirstName", XmlGetText(m)); } - if ((m = XmlGetChild(n, "FAMILY")) != NULL && XmlGetText(m) != NULL) { + if ((m = XmlGetChild(n, "FAMILY")) != nullptr && XmlGetText(m) != nullptr) { hasFamily = true; setWString(hContact, "LastName", XmlGetText(m)); } - if ((m = XmlGetChild(n, "MIDDLE")) != NULL && XmlGetText(m) != NULL) { + if ((m = XmlGetChild(n, "MIDDLE")) != nullptr && XmlGetText(m) != nullptr) { hasMiddle = true; setWString(hContact, "MiddleName", XmlGetText(m)); } @@ -753,11 +753,11 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) } else if (!mir_wstrcmp(XmlGetName(n), L"EMAIL")) { // E-mail address(es) - if ((m = XmlGetChild(n, "USERID")) == NULL) // Some bad client put e-mail directly in instead of + if ((m = XmlGetChild(n, "USERID")) == nullptr) // Some bad client put e-mail directly in instead of m = n; - if (XmlGetText(m) != NULL) { + if (XmlGetText(m) != nullptr) { char text[100]; - if (hContact != NULL) { + if (hContact != 0) { if (nEmail == 0) mir_strcpy(text, "e-mail"); else @@ -766,13 +766,13 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) else mir_snprintf(text, "e-mail%d", nEmail); setWString(hContact, text, XmlGetText(m)); - if (hContact == NULL) { + if (hContact == 0) { mir_snprintf(text, "e-mailFlag%d", nEmail); int nFlag = 0; - if (XmlGetChild(n, "HOME") != NULL) nFlag |= JABBER_VCEMAIL_HOME; - if (XmlGetChild(n, "WORK") != NULL) nFlag |= JABBER_VCEMAIL_WORK; - if (XmlGetChild(n, "INTERNET") != NULL) nFlag |= JABBER_VCEMAIL_INTERNET; - if (XmlGetChild(n, "X400") != NULL) nFlag |= JABBER_VCEMAIL_X400; + if (XmlGetChild(n, "HOME") != nullptr) nFlag |= JABBER_VCEMAIL_HOME; + if (XmlGetChild(n, "WORK") != nullptr) nFlag |= JABBER_VCEMAIL_WORK; + if (XmlGetChild(n, "INTERNET") != nullptr) nFlag |= JABBER_VCEMAIL_INTERNET; + if (XmlGetChild(n, "X400") != nullptr) nFlag |= JABBER_VCEMAIL_X400; setWord(text, nFlag); } nEmail++; @@ -780,8 +780,8 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) } else if (!mir_wstrcmp(XmlGetName(n), L"BDAY")) { // Birthday - if (!hasBday && XmlGetText(n) != NULL) { - if (hContact != NULL) { + if (!hasBday && XmlGetText(n) != nullptr) { + if (hContact != 0) { if (swscanf(XmlGetText(n), L"%d-%d-%d", &nYear, &nMonth, &nDay) == 3) { hasBday = true; setWord(hContact, "BirthYear", (WORD)nYear); @@ -805,9 +805,9 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) } else if (!mir_wstrcmp(XmlGetName(n), L"GENDER")) { // Gender - if (!hasGender && XmlGetText(n) != NULL) { - if (hContact != NULL) { - if (XmlGetText(n)[0] && strchr("mMfF", XmlGetText(n)[0]) != NULL) { + if (!hasGender && XmlGetText(n) != nullptr) { + if (hContact != 0) { + if (XmlGetText(n)[0] && strchr("mMfF", XmlGetText(n)[0]) != nullptr) { hasGender = true; setByte(hContact, "Gender", (BYTE)toupper(XmlGetText(n)[0])); } @@ -819,16 +819,16 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) } } else if (!mir_wstrcmp(XmlGetName(n), L"ADR")) { - if (!hasHome && XmlGetChild(n, "HOME") != NULL) { + if (!hasHome && XmlGetChild(n, "HOME") != nullptr) { // Home address wchar_t text[128]; hasHome = true; - if ((m = XmlGetChild(n, "STREET")) != NULL && XmlGetText(m) != NULL) { + if ((m = XmlGetChild(n, "STREET")) != nullptr && XmlGetText(m) != nullptr) { hasHomeStreet = true; - if (hContact != NULL) { - if ((o = XmlGetChild(n, "EXTADR")) != NULL && XmlGetText(o) != NULL) + if (hContact != 0) { + if ((o = XmlGetChild(n, "EXTADR")) != nullptr && XmlGetText(o) != nullptr) mir_snwprintf(text, L"%s\r\n%s", XmlGetText(m), XmlGetText(o)); - else if ((o = XmlGetChild(n, "EXTADD")) != NULL && XmlGetText(o) != NULL) + else if ((o = XmlGetChild(n, "EXTADD")) != nullptr && XmlGetText(o) != nullptr) mir_snwprintf(text, L"%s\r\n%s", XmlGetText(m), XmlGetText(o)); else wcsncpy_s(text, XmlGetText(m), _TRUNCATE); @@ -837,45 +837,45 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) } else { setWString(hContact, "Street", XmlGetText(m)); - if ((m = XmlGetChild(n, "EXTADR")) == NULL) + if ((m = XmlGetChild(n, "EXTADR")) == nullptr) m = XmlGetChild(n, "EXTADD"); - if (m != NULL && XmlGetText(m) != NULL) { + if (m != nullptr && XmlGetText(m) != nullptr) { hasHomeStreet2 = true; setWString(hContact, "Street2", XmlGetText(m)); } } } - if ((m = XmlGetChild(n, "LOCALITY")) != NULL && XmlGetText(m) != NULL) { + if ((m = XmlGetChild(n, "LOCALITY")) != nullptr && XmlGetText(m) != nullptr) { hasHomeLocality = true; setWString(hContact, "City", XmlGetText(m)); } - if ((m = XmlGetChild(n, "REGION")) != NULL && XmlGetText(m) != NULL) { + if ((m = XmlGetChild(n, "REGION")) != nullptr && XmlGetText(m) != nullptr) { hasHomeRegion = true; setWString(hContact, "State", XmlGetText(m)); } - if ((m = XmlGetChild(n, "PCODE")) != NULL && XmlGetText(m) != NULL) { + if ((m = XmlGetChild(n, "PCODE")) != nullptr && XmlGetText(m) != nullptr) { hasHomePcode = true; setWString(hContact, "ZIP", XmlGetText(m)); } - if ((m = XmlGetChild(n, "CTRY")) == NULL || XmlGetText(m) == NULL) // Some bad client use instead of + if ((m = XmlGetChild(n, "CTRY")) == nullptr || XmlGetText(m) == nullptr) // Some bad client use instead of m = XmlGetChild(n, "COUNTRY"); - if (m != NULL && XmlGetText(m) != NULL) { + if (m != nullptr && XmlGetText(m) != nullptr) { hasHomeCtry = true; setWString(hContact, "Country", XmlGetText(m)); } } - if (!hasWork && XmlGetChild(n, "WORK") != NULL) { + if (!hasWork && XmlGetChild(n, "WORK") != nullptr) { // Work address hasWork = true; - if ((m = XmlGetChild(n, "STREET")) != NULL && XmlGetText(m) != NULL) { + if ((m = XmlGetChild(n, "STREET")) != nullptr && XmlGetText(m) != nullptr) { wchar_t text[128]; hasWorkStreet = true; - if (hContact != NULL) { - if ((o = XmlGetChild(n, "EXTADR")) != NULL && XmlGetText(o) != NULL) + if (hContact != 0) { + if ((o = XmlGetChild(n, "EXTADR")) != nullptr && XmlGetText(o) != nullptr) mir_snwprintf(text, L"%s\r\n%s", XmlGetText(m), XmlGetText(o)); - else if ((o = XmlGetChild(n, "EXTADD")) != NULL && XmlGetText(o) != NULL) + else if ((o = XmlGetChild(n, "EXTADD")) != nullptr && XmlGetText(o) != nullptr) mir_snwprintf(text, L"%s\r\n%s", XmlGetText(m), XmlGetText(o)); else wcsncpy_s(text, XmlGetText(m), _TRUNCATE); @@ -884,30 +884,30 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) } else { setWString(hContact, "CompanyStreet", XmlGetText(m)); - if ((m = XmlGetChild(n, "EXTADR")) == NULL) + if ((m = XmlGetChild(n, "EXTADR")) == nullptr) m = XmlGetChild(n, "EXTADD"); - if (m != NULL && XmlGetText(m) != NULL) { + if (m != nullptr && XmlGetText(m) != nullptr) { hasWorkStreet2 = true; setWString(hContact, "CompanyStreet2", XmlGetText(m)); } } } - if ((m = XmlGetChild(n, "LOCALITY")) != NULL && XmlGetText(m) != NULL) { + if ((m = XmlGetChild(n, "LOCALITY")) != nullptr && XmlGetText(m) != nullptr) { hasWorkLocality = true; setWString(hContact, "CompanyCity", XmlGetText(m)); } - if ((m = XmlGetChild(n, "REGION")) != NULL && XmlGetText(m) != NULL) { + if ((m = XmlGetChild(n, "REGION")) != nullptr && XmlGetText(m) != nullptr) { hasWorkRegion = true; setWString(hContact, "CompanyState", XmlGetText(m)); } - if ((m = XmlGetChild(n, "PCODE")) != NULL && XmlGetText(m) != NULL) { + if ((m = XmlGetChild(n, "PCODE")) != nullptr && XmlGetText(m) != nullptr) { hasWorkPcode = true; setWString(hContact, "CompanyZIP", XmlGetText(m)); } - if ((m = XmlGetChild(n, "CTRY")) == NULL || XmlGetText(m) == NULL) // Some bad client use instead of + if ((m = XmlGetChild(n, "CTRY")) == nullptr || XmlGetText(m) == nullptr) // Some bad client use instead of m = XmlGetChild(n, "COUNTRY"); - if (m != NULL && XmlGetText(m) != NULL) { + if (m != nullptr && XmlGetText(m) != nullptr) { hasWorkCtry = true; setWString(hContact, "CompanyCountry", XmlGetText(m)); } @@ -915,27 +915,27 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) } else if (!mir_wstrcmp(XmlGetName(n), L"TEL")) { // Telephone/Fax/Cellular - if ((m = XmlGetChild(n, "NUMBER")) != NULL && XmlGetText(m) != NULL) { - if (hContact != NULL) { - if (!hasFax && XmlGetChild(n, "FAX") != NULL) { + if ((m = XmlGetChild(n, "NUMBER")) != nullptr && XmlGetText(m) != nullptr) { + if (hContact != 0) { + if (!hasFax && XmlGetChild(n, "FAX") != nullptr) { hasFax = true; setWString(hContact, "Fax", XmlGetText(m)); } - else if (!hasCell && XmlGetChild(n, "CELL") != NULL) { + else if (!hasCell && XmlGetChild(n, "CELL") != nullptr) { hasCell = true; setWString(hContact, "Cellular", XmlGetText(m)); } else if (!hasPhone && - (XmlGetChild(n, "HOME") != NULL || XmlGetChild(n, "WORK") != NULL || XmlGetChild(n, "VOICE") != NULL || - (XmlGetChild(n, "FAX") == NULL && - XmlGetChild(n, "PAGER") == NULL && - XmlGetChild(n, "MSG") == NULL && - XmlGetChild(n, "CELL") == NULL && - XmlGetChild(n, "VIDEO") == NULL && - XmlGetChild(n, "BBS") == NULL && - XmlGetChild(n, "MODEM") == NULL && - XmlGetChild(n, "ISDN") == NULL && - XmlGetChild(n, "PCS") == NULL))) + (XmlGetChild(n, "HOME") != nullptr || XmlGetChild(n, "WORK") != nullptr || XmlGetChild(n, "VOICE") != nullptr || + (XmlGetChild(n, "FAX") == nullptr && + XmlGetChild(n, "PAGER") == nullptr && + XmlGetChild(n, "MSG") == nullptr && + XmlGetChild(n, "CELL") == nullptr && + XmlGetChild(n, "VIDEO") == nullptr && + XmlGetChild(n, "BBS") == nullptr && + XmlGetChild(n, "MODEM") == nullptr && + XmlGetChild(n, "ISDN") == nullptr && + XmlGetChild(n, "PCS") == nullptr))) { hasPhone = true; setWString(hContact, "Phone", XmlGetText(m)); @@ -948,18 +948,18 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) mir_snprintf(text, "PhoneFlag%d", nPhone); int nFlag = 0; - if (XmlGetChild(n, "HOME") != NULL) nFlag |= JABBER_VCTEL_HOME; - if (XmlGetChild(n, "WORK") != NULL) nFlag |= JABBER_VCTEL_WORK; - if (XmlGetChild(n, "VOICE") != NULL) nFlag |= JABBER_VCTEL_VOICE; - if (XmlGetChild(n, "FAX") != NULL) nFlag |= JABBER_VCTEL_FAX; - if (XmlGetChild(n, "PAGER") != NULL) nFlag |= JABBER_VCTEL_PAGER; - if (XmlGetChild(n, "MSG") != NULL) nFlag |= JABBER_VCTEL_MSG; - if (XmlGetChild(n, "CELL") != NULL) nFlag |= JABBER_VCTEL_CELL; - if (XmlGetChild(n, "VIDEO") != NULL) nFlag |= JABBER_VCTEL_VIDEO; - if (XmlGetChild(n, "BBS") != NULL) nFlag |= JABBER_VCTEL_BBS; - if (XmlGetChild(n, "MODEM") != NULL) nFlag |= JABBER_VCTEL_MODEM; - if (XmlGetChild(n, "ISDN") != NULL) nFlag |= JABBER_VCTEL_ISDN; - if (XmlGetChild(n, "PCS") != NULL) nFlag |= JABBER_VCTEL_PCS; + if (XmlGetChild(n, "HOME") != nullptr) nFlag |= JABBER_VCTEL_HOME; + if (XmlGetChild(n, "WORK") != nullptr) nFlag |= JABBER_VCTEL_WORK; + if (XmlGetChild(n, "VOICE") != nullptr) nFlag |= JABBER_VCTEL_VOICE; + if (XmlGetChild(n, "FAX") != nullptr) nFlag |= JABBER_VCTEL_FAX; + if (XmlGetChild(n, "PAGER") != nullptr) nFlag |= JABBER_VCTEL_PAGER; + if (XmlGetChild(n, "MSG") != nullptr) nFlag |= JABBER_VCTEL_MSG; + if (XmlGetChild(n, "CELL") != nullptr) nFlag |= JABBER_VCTEL_CELL; + if (XmlGetChild(n, "VIDEO") != nullptr) nFlag |= JABBER_VCTEL_VIDEO; + if (XmlGetChild(n, "BBS") != nullptr) nFlag |= JABBER_VCTEL_BBS; + if (XmlGetChild(n, "MODEM") != nullptr) nFlag |= JABBER_VCTEL_MODEM; + if (XmlGetChild(n, "ISDN") != nullptr) nFlag |= JABBER_VCTEL_ISDN; + if (XmlGetChild(n, "PCS") != nullptr) nFlag |= JABBER_VCTEL_PCS; setWord(text, nFlag); nPhone++; } @@ -967,37 +967,37 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) } else if (!mir_wstrcmp(XmlGetName(n), L"URL")) { // Homepage - if (!hasUrl && XmlGetText(n) != NULL) { + if (!hasUrl && XmlGetText(n) != nullptr) { hasUrl = true; setWString(hContact, "Homepage", XmlGetText(n)); } } else if (!mir_wstrcmp(XmlGetName(n), L"ORG")) { if (!hasOrgname && !hasOrgunit) { - if ((m = XmlGetChild(n, "ORGNAME")) != NULL && XmlGetText(m) != NULL) { + if ((m = XmlGetChild(n, "ORGNAME")) != nullptr && XmlGetText(m) != nullptr) { hasOrgname = true; setWString(hContact, "Company", XmlGetText(m)); } - if ((m = XmlGetChild(n, "ORGUNIT")) != NULL && XmlGetText(m) != NULL) { // The real vCard can have multiple but we will only display the first one + if ((m = XmlGetChild(n, "ORGUNIT")) != nullptr && XmlGetText(m) != nullptr) { // The real vCard can have multiple but we will only display the first one hasOrgunit = true; setWString(hContact, "CompanyDepartment", XmlGetText(m)); } } } else if (!mir_wstrcmp(XmlGetName(n), L"ROLE")) { - if (!hasRole && XmlGetText(n) != NULL) { + if (!hasRole && XmlGetText(n) != nullptr) { hasRole = true; setWString(hContact, "Role", XmlGetText(n)); } } else if (!mir_wstrcmp(XmlGetName(n), L"TITLE")) { - if (!hasTitle && XmlGetText(n) != NULL) { + if (!hasTitle && XmlGetText(n) != nullptr) { hasTitle = true; setWString(hContact, "CompanyPosition", XmlGetText(n)); } } else if (!mir_wstrcmp(XmlGetName(n), L"DESC")) { - if (!hasDesc && XmlGetText(n) != NULL) { + if (!hasDesc && XmlGetText(n) != nullptr) { hasDesc = true; CMStringW tszMemo(XmlGetText(n)); tszMemo.Replace(L"\n", L"\r\n"); @@ -1023,7 +1023,7 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) delSetting(hContact, "LastName"); if (!hasMiddle) delSetting(hContact, "MiddleName"); - if (hContact != NULL) { + if (hContact != 0) { while (true) { if (nEmail <= 0) delSetting(hContact, "e-mail"); @@ -1058,12 +1058,12 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) delSetting(hContact, "Age"); } if (!hasGender) { - if (hContact != NULL) + if (hContact != 0) delSetting(hContact, "Gender"); else delSetting("GenderString"); } - if (hContact != NULL) { + if (hContact != 0) { if (!hasPhone) delSetting(hContact, "Phone"); if (!hasFax) @@ -1086,7 +1086,7 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) if (!hasHomeStreet) delSetting(hContact, "Street"); - if (!hasHomeStreet2 && hContact == NULL) + if (!hasHomeStreet2 && hContact == 0) delSetting(hContact, "Street2"); if (!hasHomeLocality) delSetting(hContact, "City"); @@ -1098,7 +1098,7 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) delSetting(hContact, "Country"); if (!hasWorkStreet) delSetting(hContact, "CompanyStreet"); - if (!hasWorkStreet2 && hContact == NULL) + if (!hasWorkStreet2 && hContact == 0) delSetting(hContact, "CompanyStreet2"); if (!hasWorkLocality) delSetting(hContact, "CompanyCity"); @@ -1124,18 +1124,18 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) debugLogA("Has no avatar"); delSetting(hContact, "AvatarHash"); - if (ptrW(getWStringA(hContact, "AvatarSaved")) != NULL) { + if (ptrW(getWStringA(hContact, "AvatarSaved")) != nullptr) { delSetting(hContact, "AvatarSaved"); - ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, NULL, NULL); + ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, nullptr, 0); } } if (id == m_ThreadInfo->resolveID) { const wchar_t *p = wcschr(jid, '@'); - ResolveTransportNicks((p != NULL) ? p + 1 : jid); + ResolveTransportNicks((p != nullptr) ? p + 1 : jid); } else { - if ((hContact = HContactFromJID(jid)) != NULL) + if ((hContact = HContactFromJID(jid)) != 0) ProtoBroadcastAck(hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1, 0); WindowList_Broadcast(m_hWindowList, WM_JABBER_REFRESH_VCARD, 0, 0); } @@ -1155,11 +1155,11 @@ void CJabberProto::OnIqResultSetSearch(HXML iqNode, CJabberIqInfo*) int id; debugLogA(" iqIdGetSearch"); - if ((type = XmlGetAttrValue(iqNode, L"type")) == NULL) return; + if ((type = XmlGetAttrValue(iqNode, L"type")) == nullptr) return; if ((id = JabberGetPacketID(iqNode)) == -1) return; if (!mir_wstrcmp(type, L"result")) { - if ((queryNode = XmlGetChild(iqNode, "query")) == NULL) + if ((queryNode = XmlGetChild(iqNode, "query")) == nullptr) return; PROTOSEARCHRESULT psr = { 0 }; @@ -1170,35 +1170,35 @@ void CJabberProto::OnIqResultSetSearch(HXML iqNode, CJabberIqInfo*) break; if (!mir_wstrcmp(XmlGetName(itemNode), L"item")) { - if ((jid = XmlGetAttrValue(itemNode, L"jid")) != NULL) { + if ((jid = XmlGetAttrValue(itemNode, L"jid")) != nullptr) { psr.id.w = (wchar_t*)jid; debugLogW(L"Result jid = %s", jid); - if ((n = XmlGetChild(itemNode, "nick")) != NULL && XmlGetText(n) != NULL) + if ((n = XmlGetChild(itemNode, "nick")) != nullptr && XmlGetText(n) != nullptr) psr.nick.w = (wchar_t*)XmlGetText(n); else psr.nick.w = L""; - if ((n = XmlGetChild(itemNode, "first")) != NULL && XmlGetText(n) != NULL) + if ((n = XmlGetChild(itemNode, "first")) != nullptr && XmlGetText(n) != nullptr) psr.firstName.w = (wchar_t*)XmlGetText(n); else psr.firstName.w = L""; - if ((n = XmlGetChild(itemNode, "last")) != NULL && XmlGetText(n) != NULL) + if ((n = XmlGetChild(itemNode, "last")) != nullptr && XmlGetText(n) != nullptr) psr.lastName.w = (wchar_t*)XmlGetText(n); else psr.lastName.w = L""; - if ((n = XmlGetChild(itemNode, "email")) != NULL && XmlGetText(n) != NULL) + if ((n = XmlGetChild(itemNode, "email")) != nullptr && XmlGetText(n) != nullptr) psr.email.w = (wchar_t*)XmlGetText(n); else psr.email.w = L""; psr.flags = PSR_UNICODE; - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&psr); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&psr); } } } - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); } else if (!mir_wstrcmp(type, L"error")) - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); } void CJabberProto::OnIqResultExtSearch(HXML iqNode, CJabberIqInfo*) @@ -1207,7 +1207,7 @@ void CJabberProto::OnIqResultExtSearch(HXML iqNode, CJabberIqInfo*) debugLogA(" iqIdGetExtSearch"); const wchar_t *type = XmlGetAttrValue(iqNode, L"type"); - if (type == NULL) + if (type == nullptr) return; int id = JabberGetPacketID(iqNode); @@ -1215,8 +1215,8 @@ void CJabberProto::OnIqResultExtSearch(HXML iqNode, CJabberIqInfo*) return; if (!mir_wstrcmp(type, L"result")) { - if ((queryNode = XmlGetChild(iqNode, "query")) == NULL) return; - if ((queryNode = XmlGetChild(queryNode, "x")) == NULL) return; + if ((queryNode = XmlGetChild(iqNode, "query")) == nullptr) return; + if ((queryNode = XmlGetChild(queryNode, "x")) == nullptr) return; for (int i = 0;; i++) { HXML itemNode = XmlGetChild(queryNode, i); if (!itemNode) @@ -1237,11 +1237,11 @@ void CJabberProto::OnIqResultExtSearch(HXML iqNode, CJabberIqInfo*) continue; const wchar_t *fieldName = XmlGetAttrValue(fieldNode, L"var"); - if (fieldName == NULL) + if (fieldName == nullptr) continue; HXML n = XmlGetChild(fieldNode, "value"); - if (n == NULL) + if (n == nullptr) continue; if (!mir_wstrcmp(fieldName, L"jid")) { @@ -1249,24 +1249,24 @@ void CJabberProto::OnIqResultExtSearch(HXML iqNode, CJabberIqInfo*) debugLogW(L"Result jid = %s", psr.id.w); } else if (!mir_wstrcmp(fieldName, L"nickname")) - psr.nick.w = (XmlGetText(n) != NULL) ? (wchar_t*)XmlGetText(n) : L""; + psr.nick.w = (XmlGetText(n) != nullptr) ? (wchar_t*)XmlGetText(n) : L""; else if (!mir_wstrcmp(fieldName, L"fn")) - psr.firstName.w = (XmlGetText(n) != NULL) ? (wchar_t*)XmlGetText(n) : L""; + psr.firstName.w = (XmlGetText(n) != nullptr) ? (wchar_t*)XmlGetText(n) : L""; else if (!mir_wstrcmp(fieldName, L"given")) - psr.firstName.w = (XmlGetText(n) != NULL) ? (wchar_t*)XmlGetText(n) : L""; + psr.firstName.w = (XmlGetText(n) != nullptr) ? (wchar_t*)XmlGetText(n) : L""; else if (!mir_wstrcmp(fieldName, L"family")) - psr.lastName.w = (XmlGetText(n) != NULL) ? (wchar_t*)XmlGetText(n) : L""; + psr.lastName.w = (XmlGetText(n) != nullptr) ? (wchar_t*)XmlGetText(n) : L""; else if (!mir_wstrcmp(fieldName, L"email")) - psr.email.w = (XmlGetText(n) != NULL) ? (wchar_t*)XmlGetText(n) : L""; + psr.email.w = (XmlGetText(n) != nullptr) ? (wchar_t*)XmlGetText(n) : L""; } - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&psr); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&psr); } - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); } else if (!mir_wstrcmp(type, L"error")) - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); } void CJabberProto::OnIqResultSetPassword(HXML iqNode, CJabberIqInfo*) @@ -1274,15 +1274,15 @@ void CJabberProto::OnIqResultSetPassword(HXML iqNode, CJabberIqInfo*) debugLogA(" iqIdSetPassword"); const wchar_t *type = XmlGetAttrValue(iqNode, L"type"); - if (type == NULL) + if (type == nullptr) return; if (!mir_wstrcmp(type, L"result")) { wcsncpy_s(m_ThreadInfo->conn.password, m_ThreadInfo->tszNewPassword, _TRUNCATE); - MessageBox(NULL, TranslateT("Password is successfully changed. Don't forget to update your password in the Jabber protocol option."), TranslateT("Change Password"), MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND); + MessageBox(nullptr, TranslateT("Password is successfully changed. Don't forget to update your password in the Jabber protocol option."), TranslateT("Change Password"), MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND); } else if (!mir_wstrcmp(type, L"error")) - MessageBox(NULL, TranslateT("Password cannot be changed."), TranslateT("Change Password"), MB_OK | MB_ICONSTOP | MB_SETFOREGROUND); + MessageBox(nullptr, TranslateT("Password cannot be changed."), TranslateT("Change Password"), MB_OK | MB_ICONSTOP | MB_SETFOREGROUND); } void CJabberProto::OnIqResultGetVCardAvatar(HXML iqNode, CJabberIqInfo*) @@ -1290,34 +1290,34 @@ void CJabberProto::OnIqResultGetVCardAvatar(HXML iqNode, CJabberIqInfo*) debugLogA(" OnIqResultGetVCardAvatar"); const wchar_t *from = XmlGetAttrValue(iqNode, L"from"); - if (from == NULL) + if (from == nullptr) return; MCONTACT hContact = HContactFromJID(from); - if (hContact == NULL) + if (hContact == 0) return; const wchar_t *type; - if ((type = XmlGetAttrValue(iqNode, L"type")) == NULL) return; + if ((type = XmlGetAttrValue(iqNode, L"type")) == nullptr) return; if (mir_wstrcmp(type, L"result")) return; HXML vCard = XmlGetChild(iqNode, "vCard"); - if (vCard == NULL) return; + if (vCard == nullptr) return; vCard = XmlGetChild(vCard, "PHOTO"); - if (vCard == NULL) return; + if (vCard == nullptr) return; if (XmlGetChildCount(vCard) == 0) { delSetting(hContact, "AvatarHash"); - if (ptrW(getWStringA(hContact, "AvatarSaved")) != NULL) { + if (ptrW(getWStringA(hContact, "AvatarSaved")) != nullptr) { delSetting(hContact, "AvatarSaved"); - ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, NULL, NULL); + ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, nullptr, 0); } return; } const wchar_t *mimeType = XmlGetText(XmlGetChild(vCard, "TYPE")); HXML n = XmlGetChild(vCard, "BINVAL"); - if (n == NULL) + if (n == nullptr) return; setByte(hContact, "AvatarXVcard", 1); @@ -1331,23 +1331,23 @@ void CJabberProto::OnIqResultGetClientAvatar(HXML iqNode, CJabberIqInfo*) debugLogA(" iqIdResultGetClientAvatar"); const wchar_t *from = XmlGetAttrValue(iqNode, L"from"); - if (from == NULL) + if (from == nullptr) return; MCONTACT hContact = HContactFromJID(from); - if (hContact == NULL) + if (hContact == 0) return; - HXML n = NULL; - if ((type = XmlGetAttrValue(iqNode, L"type")) != NULL && !mir_wstrcmp(type, L"result")) { + HXML n = nullptr; + if ((type = XmlGetAttrValue(iqNode, L"type")) != nullptr && !mir_wstrcmp(type, L"result")) { HXML queryNode = XmlGetChild(iqNode, "query"); - if (queryNode != NULL) { + if (queryNode != nullptr) { const wchar_t *xmlns = XmlGetAttrValue(queryNode, L"xmlns"); if (!mir_wstrcmp(xmlns, JABBER_FEAT_AVATAR)) n = XmlGetChild(queryNode, "data"); } } - if (n != NULL) { + if (n != nullptr) { OnIqResultGotAvatar(hContact, n, XmlGetAttrValue(n, L"mimetype")); return; } @@ -1355,7 +1355,7 @@ void CJabberProto::OnIqResultGetClientAvatar(HXML iqNode, CJabberIqInfo*) wchar_t szJid[JABBER_MAX_JID_LEN]; mir_wstrncpy(szJid, from, _countof(szJid)); wchar_t *res = wcschr(szJid, '/'); - if (res != NULL) + if (res != nullptr) *res = 0; // Try server stored avatar @@ -1369,25 +1369,25 @@ void CJabberProto::OnIqResultGetServerAvatar(HXML iqNode, CJabberIqInfo*) debugLogA(" iqIdResultGetServerAvatar"); const wchar_t *from = XmlGetAttrValue(iqNode, L"from"); - if (from == NULL) + if (from == nullptr) return; MCONTACT hContact = HContactFromJID(from); - if (hContact == NULL) + if (hContact == 0) return; - HXML n = NULL; + HXML n = nullptr; const wchar_t *type = XmlGetAttrValue(iqNode, L"type"); if (!mir_wstrcmp(type, L"result")) { HXML queryNode = XmlGetChild(iqNode, "query"); - if (queryNode != NULL) { + if (queryNode != nullptr) { const wchar_t *xmlns = XmlGetAttrValue(queryNode, L"xmlns"); if (!mir_wstrcmp(xmlns, JABBER_FEAT_SERVER_AVATAR)) n = XmlGetChild(queryNode, "data"); } } - if (n != NULL) { + if (n != nullptr) { OnIqResultGotAvatar(hContact, n, XmlGetAttrValue(n, L"mimetype")); return; } @@ -1395,7 +1395,7 @@ void CJabberProto::OnIqResultGetServerAvatar(HXML iqNode, CJabberIqInfo*) wchar_t szJid[JABBER_MAX_JID_LEN]; mir_wstrncpy(szJid, from, _countof(szJid)); wchar_t *res = wcschr(szJid, '/'); - if (res != NULL) + if (res != nullptr) *res = 0; // Try VCard photo @@ -1408,11 +1408,11 @@ void CJabberProto::OnIqResultGotAvatar(MCONTACT hContact, HXML n, const wchar_t { unsigned resultLen; ptrA body((char*)mir_base64_decode(_T2A(XmlGetText(n)), &resultLen)); - if (body == NULL) + if (body == nullptr) return; int pictureType; - if (mimeType != NULL) + if (mimeType != nullptr) pictureType = ProtoGetAvatarFormatByMimeType(mimeType); else pictureType = ProtoGetBufferFormat(body, 0); @@ -1443,16 +1443,16 @@ void CJabberProto::OnIqResultGotAvatar(MCONTACT hContact, HXML n, const wchar_t wcsncpy_s(ai.filename, tszFileName, _TRUNCATE); FILE *out = _wfopen(tszFileName, L"wb"); - if (out != NULL) { + if (out != nullptr) { fwrite(body, resultLen, 1, out); fclose(out); char buffer[41]; setString(hContact, "AvatarSaved", bin2hex(digest, sizeof(digest), buffer)); - ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, HANDLE(&ai), NULL); + ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, HANDLE(&ai), 0); debugLogW(L"Broadcast new avatar: %s", ai.filename); } - else ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, HANDLE(&ai), NULL); + else ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, HANDLE(&ai), 0); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -1464,7 +1464,7 @@ void CJabberProto::OnIqResultDiscoBookmarks(HXML iqNode, CJabberIqInfo*) // ACTION: refresh bookmarks dialog debugLogA(" iqIdGetBookmarks"); const wchar_t *type = XmlGetAttrValue(iqNode, L"type"); - if (type == NULL) + if (type == nullptr) return; const wchar_t *jid; @@ -1489,7 +1489,7 @@ void CJabberProto::OnIqResultDiscoBookmarks(HXML iqNode, CJabberIqInfo*) item->password = mir_wstrdup(XPathT(itemNode, "password")); const wchar_t *autoJ = XmlGetAttrValue(itemNode, L"autojoin"); - if (autoJ != NULL) + if (autoJ != nullptr) item->bAutoJoin = !mir_wstrcmp(autoJ, L"true") || !mir_wstrcmp(autoJ, L"1"); } else if (!mir_wstrcmp(name, L"url") && (jid = XmlGetAttrValue(itemNode, L"url"))) { @@ -1523,7 +1523,7 @@ void CJabberProto::SetBookmarkRequest(XmlNodeIq& iq) LISTFOREACH(i, this, LIST_BOOKMARK) { JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i); - if (item == NULL || item->jid == NULL) + if (item == nullptr || item->jid == nullptr) continue; if (!mir_wstrcmp(item->type, L"conference")) { @@ -1554,7 +1554,7 @@ void CJabberProto::OnIqResultSetBookmarks(HXML iqNode, CJabberIqInfo*) debugLogA(" iqIdSetBookmarks"); const wchar_t *type = XmlGetAttrValue(iqNode, L"type"); - if (type == NULL) + if (type == nullptr) return; if (!mir_wstrcmp(type, L"result")) { @@ -1563,7 +1563,7 @@ void CJabberProto::OnIqResultSetBookmarks(HXML iqNode, CJabberIqInfo*) else if (!mir_wstrcmp(type, L"error")) { HXML errorNode = XmlGetChild(iqNode, "error"); wchar_t *str = JabberErrorMsg(errorNode); - MessageBox(NULL, str, TranslateT("Jabber Bookmarks Error"), MB_OK | MB_SETFOREGROUND); + MessageBox(nullptr, str, TranslateT("Jabber Bookmarks Error"), MB_OK | MB_SETFOREGROUND); mir_free(str); UI_SAFE_NOTIFY(m_pDlgBookmarks, WM_JABBER_ACTIVATE); } @@ -1573,7 +1573,7 @@ void CJabberProto::OnIqResultSetBookmarks(HXML iqNode, CJabberIqInfo*) void CJabberProto::OnIqResultLastActivity(HXML iqNode, CJabberIqInfo *pInfo) { pResourceStatus r(ResourceInfoFromJID(pInfo->m_szFrom)); - if (r == NULL) + if (r == nullptr) return; time_t lastActivity = -1; diff --git a/protocols/JabberG/src/jabber_iqid_muc.cpp b/protocols/JabberG/src/jabber_iqid_muc.cpp index b55b6fa61e..7f3c2980f8 100644 --- a/protocols/JabberG/src/jabber_iqid_muc.cpp +++ b/protocols/JabberG/src/jabber_iqid_muc.cpp @@ -43,19 +43,19 @@ void CJabberProto::OnIqResultGetMuc(HXML iqNode, CJabberIqInfo*) { debugLogA(" iqIdGetMuc"); LPCTSTR type = XmlGetAttrValue(iqNode, L"type"); - if (type == NULL) + if (type == nullptr) return; LPCTSTR from = XmlGetAttrValue(iqNode, L"from"); - if (from == NULL) + if (from == nullptr) return; if (!mir_wstrcmp(type, L"result")) { HXML queryNode = XmlGetChild(iqNode, L"query"); - if (queryNode != NULL) { + if (queryNode != nullptr) { LPCTSTR str = XmlGetAttrValue(queryNode, L"xmlns"); if (!mir_wstrcmp(str, JABBER_FEAT_MUC_OWNER)) { HXML xNode = XmlGetChild(queryNode, L"x"); - if (xNode != NULL) { + if (xNode != nullptr) { str = XmlGetAttrValue(xNode, L"xmlns"); if (!mir_wstrcmp(str, JABBER_FEAT_DATA_FORMS)) //LaunchForm(xNode); @@ -68,7 +68,7 @@ void CJabberProto::OnIqResultGetMuc(HXML iqNode, CJabberIqInfo*) static void sttFillJidList(HWND hwndDlg) { - wchar_t *filter = NULL; + wchar_t *filter = nullptr; if (GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_FILTER), GWLP_USERDATA)) { int filterLength = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_FILTER)) + 1; filter = (wchar_t *)_alloca(filterLength * sizeof(wchar_t)); @@ -89,7 +89,7 @@ static void sttFillJidList(HWND hwndDlg) for (int i = 0; i < count; i++) { lvi.iItem = i; if (ListView_GetItem(hwndList, &lvi) == TRUE) - if (lvi.lParam != -1 && lvi.lParam != NULL) + if (lvi.lParam != -1 && lvi.lParam != 0) mir_free((void *)lvi.lParam); } ListView_DeleteAllItems(hwndList); @@ -97,11 +97,11 @@ static void sttFillJidList(HWND hwndDlg) // Populate displayed list from iqNode wchar_t tszItemText[JABBER_MAX_JID_LEN + 256]; HXML iqNode = jidListInfo->iqNode; - if (iqNode != NULL) { + if (iqNode != nullptr) { LPCTSTR from = XmlGetAttrValue(iqNode, L"from"); - if (from != NULL) { + if (from != nullptr) { HXML queryNode = XmlGetChild(iqNode, L"query"); - if (queryNode != NULL) { + if (queryNode != nullptr) { lvi.mask = LVIF_TEXT | LVIF_PARAM; lvi.iSubItem = 0; lvi.iItem = 0; @@ -111,18 +111,18 @@ static void sttFillJidList(HWND hwndDlg) break; LPCTSTR jid = XmlGetAttrValue(itemNode, L"jid"); - if (jid != NULL) { + if (jid != nullptr) { lvi.pszText = (wchar_t*)jid; if (jidListInfo->type == MUC_BANLIST) { LPCTSTR reason = XmlGetText(XmlGetChild(itemNode, L"reason")); - if (reason != NULL) { + if (reason != nullptr) { mir_snwprintf(tszItemText, L"%s (%s)", jid, reason); lvi.pszText = tszItemText; } } else if (jidListInfo->type == MUC_VOICELIST || jidListInfo->type == MUC_MODERATORLIST) { LPCTSTR nick = XmlGetAttrValue(itemNode, L"nick"); - if (nick != NULL) { + if (nick != nullptr) { mir_snwprintf(tszItemText, L"%s (%s)", nick, jid); lvi.pszText = tszItemText; } @@ -146,7 +146,7 @@ static void sttFillJidList(HWND hwndDlg) ListView_InsertItem(hwndList, &lvi); SendMessage(hwndList, WM_SETREDRAW, TRUE, 0); - RedrawWindow(hwndList, NULL, NULL, RDW_INVALIDATE); + RedrawWindow(hwndList, nullptr, nullptr, RDW_INVALIDATE); } static int sttJidListResizer(HWND, LPARAM, UTILRESIZECONTROL *urc) @@ -207,7 +207,7 @@ static INT_PTR CALLBACK JabberMucJidListDlgProc(HWND hwndDlg, UINT msg, WPARAM w SendDlgItemMessage(hwndDlg, buttons[i].idc, BUTTONSETASPUSHBTN, TRUE, 0); } - Utils_RestoreWindowPosition(hwndDlg, NULL, dat->ppro->m_szModuleName, "jidListWnd_"); + Utils_RestoreWindowPosition(hwndDlg, 0, dat->ppro->m_szModuleName, "jidListWnd_"); } return TRUE; @@ -227,7 +227,7 @@ static INT_PTR CALLBACK JabberMucJidListDlgProc(HWND hwndDlg, UINT msg, WPARAM w // lParam is (JABBER_MUC_JIDLIST_INFO *) // Clear current GWL_USERDATA, if any - if (dat != NULL) + if (dat != nullptr) delete dat; // Set new GWL_USERDATA @@ -236,14 +236,14 @@ static INT_PTR CALLBACK JabberMucJidListDlgProc(HWND hwndDlg, UINT msg, WPARAM w // Populate displayed list from iqNode mir_wstrncpy(title, TranslateT("JID List"), _countof(title)); - if ((dat = (JABBER_MUC_JIDLIST_INFO *)lParam) != NULL) { + if ((dat = (JABBER_MUC_JIDLIST_INFO *)lParam) != nullptr) { HXML iqNode = dat->iqNode; - if (iqNode != NULL) { + if (iqNode != nullptr) { LPCTSTR from = XmlGetAttrValue(iqNode, L"from"); - if (from != NULL) { + if (from != nullptr) { dat->roomJid = mir_wstrdup(from); HXML queryNode = XmlGetChild(iqNode, L"query"); - if (queryNode != NULL) { + if (queryNode != nullptr) { wchar_t *localFrom = mir_wstrdup(from); mir_snwprintf(title, TranslateT("%s, %d items (%s)"), (dat->type == MUC_VOICELIST) ? TranslateT("Voice List") : @@ -322,7 +322,7 @@ static INT_PTR CALLBACK JabberMucJidListDlgProc(HWND hwndDlg, UINT msg, WPARAM w ListView_GetItem(nm->hdr.hwndFrom, &lvi); if (lvi.lParam == -1) { CMStringW szBuffer(dat->type2str()); - if (!dat->ppro->EnterString(szBuffer, NULL, ESF_COMBO, "gcAddNick_")) + if (!dat->ppro->EnterString(szBuffer, nullptr, ESF_COMBO, "gcAddNick_")) break; // Trim leading and trailing whitespaces @@ -381,33 +381,31 @@ static INT_PTR CALLBACK JabberMucJidListDlgProc(HWND hwndDlg, UINT msg, WPARAM w lvi.iSubItem = 0; for (int i = 0; i < count; i++) { lvi.iItem = i; - if (ListView_GetItem(hwndList, &lvi) == TRUE) { - if (lvi.lParam != -1 && lvi.lParam != NULL) { + if (ListView_GetItem(hwndList, &lvi) == TRUE) + if (lvi.lParam != -1 && lvi.lParam != 0) mir_free((void *)lvi.lParam); - } - } } ListView_DeleteAllItems(hwndList); CJabberProto *ppro = dat->ppro; switch (dat->type) { case MUC_VOICELIST: - ppro->m_hwndMucVoiceList = NULL; + ppro->m_hwndMucVoiceList = nullptr; break; case MUC_MEMBERLIST: - ppro->m_hwndMucMemberList = NULL; + ppro->m_hwndMucMemberList = nullptr; break; case MUC_MODERATORLIST: - ppro->m_hwndMucModeratorList = NULL; + ppro->m_hwndMucModeratorList = nullptr; break; case MUC_BANLIST: - ppro->m_hwndMucBanList = NULL; + ppro->m_hwndMucBanList = nullptr; break; case MUC_ADMINLIST: - ppro->m_hwndMucAdminList = NULL; + ppro->m_hwndMucAdminList = nullptr; break; case MUC_OWNERLIST: - ppro->m_hwndMucOwnerList = NULL; + ppro->m_hwndMucOwnerList = nullptr; break; } @@ -417,8 +415,8 @@ static INT_PTR CALLBACK JabberMucJidListDlgProc(HWND hwndDlg, UINT msg, WPARAM w case WM_DESTROY: // Clear GWL_USERDATA - if (dat != NULL) { - Utils_SaveWindowPosition(hwndDlg, NULL, dat->ppro->m_szModuleName, "jidListWnd_"); + if (dat != nullptr) { + Utils_SaveWindowPosition(hwndDlg, 0, dat->ppro->m_szModuleName, "jidListWnd_"); delete dat; } break; @@ -429,19 +427,19 @@ static INT_PTR CALLBACK JabberMucJidListDlgProc(HWND hwndDlg, UINT msg, WPARAM w static void CALLBACK JabberMucJidListCreateDialogApcProc(void* param) { JABBER_MUC_JIDLIST_INFO *jidListInfo = (JABBER_MUC_JIDLIST_INFO *)param; - if (jidListInfo == NULL) + if (jidListInfo == nullptr) return; HXML iqNode = jidListInfo->iqNode; - if (iqNode == NULL) + if (iqNode == nullptr) return; LPCTSTR from = XmlGetAttrValue(iqNode, L"from"); - if (from == NULL) + if (from == nullptr) return; HXML queryNode = XmlGetChild(iqNode, L"query"); - if (queryNode == NULL) + if (queryNode == nullptr) return; CJabberProto *ppro = jidListInfo->ppro; @@ -470,7 +468,7 @@ static void CALLBACK JabberMucJidListCreateDialogApcProc(void* param) return; } - if (*pHwndJidList != NULL && IsWindow(*pHwndJidList)) { + if (*pHwndJidList != nullptr && IsWindow(*pHwndJidList)) { SetForegroundWindow(*pHwndJidList); SendMessage(*pHwndJidList, WM_JABBER_REFRESH, 0, (LPARAM)jidListInfo); } @@ -480,16 +478,16 @@ static void CALLBACK JabberMucJidListCreateDialogApcProc(void* param) void CJabberProto::OnIqResultMucGetJidList(HXML iqNode, JABBER_MUC_JIDLIST_TYPE listType) { LPCTSTR type = XmlGetAttrValue(iqNode, L"type"); - if (type == NULL) + if (type == nullptr) return; if (!mir_wstrcmp(type, L"result")) { JABBER_MUC_JIDLIST_INFO *jidListInfo = new JABBER_MUC_JIDLIST_INFO; - if (jidListInfo != NULL) { + if (jidListInfo != nullptr) { jidListInfo->type = listType; jidListInfo->ppro = this; - jidListInfo->roomJid = NULL; // Set in the dialog procedure - if ((jidListInfo->iqNode = xmlCopyNode(iqNode)) != NULL) + jidListInfo->roomJid = nullptr; // Set in the dialog procedure + if ((jidListInfo->iqNode = xmlCopyNode(iqNode)) != nullptr) CallFunctionAsync(JabberMucJidListCreateDialogApcProc, jidListInfo); else mir_free(jidListInfo); diff --git a/protocols/JabberG/src/jabber_list.cpp b/protocols/JabberG/src/jabber_list.cpp index 36295a4179..d41a06ea57 100644 --- a/protocols/JabberG/src/jabber_list.cpp +++ b/protocols/JabberG/src/jabber_list.cpp @@ -76,13 +76,13 @@ JABBER_RESOURCE_STATUS::~JABBER_RESOURCE_STATUS() void JABBER_RESOURCE_STATUS::AddRef() { - if (this != NULL) + if (this != nullptr) ::InterlockedIncrement(&m_refCount); } void JABBER_RESOURCE_STATUS::Release() { - if (this != NULL) + if (this != nullptr) if (::InterlockedDecrement(&m_refCount) == 0) delete this; } @@ -92,12 +92,12 @@ void CJabberProto::ListInit(void) for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { if (isChatRoom(hContact)) { ptrW jid(getWStringA(hContact, "ChatRoomID")); - if (jid != NULL) + if (jid != nullptr) ListAdd(LIST_CHATROOM, jid, hContact); } else { ptrW jid(getWStringA(hContact, "jid")); - if (jid != NULL) + if (jid != nullptr) ListAdd(LIST_ROSTER, jid, hContact); } } @@ -121,21 +121,21 @@ JABBER_LIST_ITEM* CJabberProto::ListAdd(JABBER_LIST list, const wchar_t *jid, MC mir_cslockfull lck(m_csLists); JABBER_LIST_ITEM *item = ListGetItemPtr(list, jid); - if (item != NULL) { + if (item != nullptr) { if (hContact) item->hContact = hContact; return item; } wchar_t *s = mir_wstrdup(jid); - wchar_t *q = NULL; + wchar_t *q = nullptr; // strip resource name if any //fyr if (!((list == LIST_ROSTER) && ListGetItemPtr(LIST_CHATROOM, jid))) { // but only if it is not chat room contact if (list != LIST_VCARD_TEMP) { wchar_t *p; - if ((p = wcschr(s, '@')) != NULL) - if ((q = wcschr(p, '/')) != NULL) + if ((p = wcschr(s, '@')) != nullptr) + if ((q = wcschr(p, '/')) != nullptr) *q = '\0'; } } @@ -144,7 +144,7 @@ JABBER_LIST_ITEM* CJabberProto::ListAdd(JABBER_LIST list, const wchar_t *jid, MC if (!bUseResource && list == LIST_ROSTER) { //if it is a chat room keep resource and made it resource sensitive if (ChatRoomHContactFromJID(s)) { - if (q != NULL) + if (q != nullptr) *q = '/'; bUseResource = true; } @@ -167,7 +167,7 @@ void CJabberProto::ListRemove(JABBER_LIST list, const wchar_t *jid) { mir_cslock lck(m_csLists); JABBER_LIST_ITEM *LI = ListGetItemPtr(list, jid); - if (LI != NULL) { + if (LI != nullptr) { m_lstRoster.remove(LI); delete LI; } @@ -194,8 +194,8 @@ void CJabberProto::ListRemoveByIndex(int index) JABBER_LIST_ITEM* CJabberProto::ListGetItemPtr(JABBER_LIST list, const wchar_t *jid) { - if (jid == NULL) - return NULL; + if (jid == nullptr) + return nullptr; JABBER_LIST_ITEM *tmp = (JABBER_LIST_ITEM*)_alloca(sizeof(JABBER_LIST_ITEM)); tmp->list = list; @@ -220,7 +220,7 @@ JABBER_LIST_ITEM* CJabberProto::ListGetItemPtrFromIndex(int index) if (index >= 0 && index < m_lstRoster.getCount()) return m_lstRoster[index]; - return NULL; + return nullptr; } int CJabberProto::ListFindNext(JABBER_LIST list, int fromOffset) @@ -239,8 +239,8 @@ int CJabberProto::ListFindNext(JABBER_LIST list, int fromOffset) pResourceStatus JABBER_LIST_ITEM::findResource(const wchar_t *resourceName) const { - if (arResources.getCount() == 0 || resourceName == NULL || *resourceName == 0) - return NULL; + if (arResources.getCount() == 0 || resourceName == nullptr || *resourceName == 0) + return nullptr; for (int i = 0; i < arResources.getCount(); i++) { JABBER_RESOURCE_STATUS *r = arResources[i]; @@ -248,39 +248,39 @@ pResourceStatus JABBER_LIST_ITEM::findResource(const wchar_t *resourceName) cons return r; } - return NULL; + return nullptr; } pResourceStatus CJabberProto::ListFindResource(JABBER_LIST list, const wchar_t *jid) { mir_cslock lck(m_csLists); JABBER_LIST_ITEM *LI = ListGetItemPtr(list, jid); - if (LI == NULL) - return NULL; + if (LI == nullptr) + return nullptr; const wchar_t *p = wcschr(jid, '@'); - const wchar_t *q = wcschr((p == NULL) ? jid : p, '/'); - return (q == NULL) ? NULL : LI->findResource(q + 1); + const wchar_t *q = wcschr((p == nullptr) ? jid : p, '/'); + return (q == nullptr) ? nullptr : LI->findResource(q + 1); } bool CJabberProto::ListAddResource(JABBER_LIST list, const wchar_t *jid, int status, const wchar_t *statusMessage, char priority, const wchar_t *nick) { mir_cslockfull lck(m_csLists); JABBER_LIST_ITEM *LI = ListGetItemPtr(list, jid); - if (LI == NULL) + if (LI == nullptr) return false; bool bIsNewResource = false; const wchar_t *p = wcschr(jid, '@'); - const wchar_t *q = wcschr((p == NULL) ? jid : p, '/'); + const wchar_t *q = wcschr((p == nullptr) ? jid : p, '/'); if (q) { const wchar_t *resource = q + 1; if (*resource == 0) return 0; JABBER_RESOURCE_STATUS *r = LI->findResource(resource); - if (r != NULL) { // Already exists, update status and statusMessage + if (r != nullptr) { // Already exists, update status and statusMessage r->m_iStatus = status; r->m_tszStatusMessage = mir_wstrdup(statusMessage); r->m_iPriority = priority; @@ -316,26 +316,26 @@ void CJabberProto::ListRemoveResource(JABBER_LIST list, const wchar_t *jid) { mir_cslockfull lck(m_csLists); JABBER_LIST_ITEM *LI = ListGetItemPtr(list, jid); - if (LI == NULL) + if (LI == nullptr) return; const wchar_t *p = wcschr(jid, '@'); - const wchar_t *q = wcschr((p == NULL) ? jid : p, '/'); - if (q == NULL) + const wchar_t *q = wcschr((p == nullptr) ? jid : p, '/'); + if (q == nullptr) return; pResourceStatus r(LI->findResource(q + 1)); - if (r == NULL) + if (r == nullptr) return; // Found last seen resource ID to be removed if (LI->m_pLastSeenResource == r) - LI->m_pLastSeenResource = NULL; + LI->m_pLastSeenResource = nullptr; // update manually selected resource ID if (LI->resourceMode == RSMODE_MANUAL && LI->m_pManualResource == r) { LI->resourceMode = RSMODE_LASTSEEN; - LI->m_pManualResource = NULL; + LI->m_pManualResource = nullptr; } // Update MirVer due to possible resource changes @@ -351,7 +351,7 @@ void CJabberProto::ListRemoveResource(JABBER_LIST list, const wchar_t *jid) pResourceStatus JABBER_LIST_ITEM::getBestResource() const { if (!arResources.getCount()) - return NULL; + return nullptr; if (arResources.getCount() == 1) return arResources[0]; @@ -371,12 +371,12 @@ pResourceStatus JABBER_LIST_ITEM::getBestResource() const } } - return (nBestPos != -1) ? arResources[nBestPos] : NULL; + return (nBestPos != -1) ? arResources[nBestPos] : nullptr; } JABBER_RESOURCE_STATUS* JABBER_LIST_ITEM::getTemp() { - if (m_pItemResource == NULL) + if (m_pItemResource == nullptr) m_pItemResource = new JABBER_RESOURCE_STATUS(); return m_pItemResource; @@ -386,15 +386,15 @@ wchar_t* CJabberProto::ListGetBestClientResourceNamePtr(const wchar_t *jid) { mir_cslock lck(m_csLists); JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, jid); - if (LI == NULL) - return NULL; + if (LI == nullptr) + return nullptr; pResourceStatus r(LI->getBestResource()); - if (r != NULL) + if (r != nullptr) return r->m_tszResourceName; int status = ID_STATUS_OFFLINE; - wchar_t *res = NULL; + wchar_t *res = nullptr; for (int i = 0; i < LI->arResources.getCount(); i++) { r = LI->arResources[i]; bool foundBetter = false; diff --git a/protocols/JabberG/src/jabber_list.h b/protocols/JabberG/src/jabber_list.h index 1d6070ff3d..b56daae7cb 100644 --- a/protocols/JabberG/src/jabber_list.h +++ b/protocols/JabberG/src/jabber_list.h @@ -75,7 +75,7 @@ enum JABBER_RESOURCE_MODE // initial default to RSMODE_LASTSEEN { RSMODE_SERVER, // always let server decide (always send correspondence without resouce name) RSMODE_LASTSEEN, // use the last seen resource (or let server decide if haven't seen anything yet) - RSMODE_MANUAL // specify resource manually (see the defaultResource field - must not be NULL) + RSMODE_MANUAL // specify resource manually (see the defaultResource field - must not be nullptr) }; class JABBER_RESOURCE_STATUS : public MZeroedObject diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index 9e7f927559..7b1e6f86c4 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -33,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MENUITEM_SERVER 2 #define MENUITEM_RESOURCES 10 -static MWindowList hDialogsList = NULL; +static MWindowList hDialogsList = nullptr; static HANDLE hStatusMenuInit; static int hChooserMenu; @@ -78,14 +78,14 @@ static INT_PTR JabberMenuChooseService(WPARAM wParam, LPARAM lParam) static CJabberProto* JabberGetInstanceByHContact(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 JabberMenuHandleRequestAuth(WPARAM wParam, LPARAM lParam) @@ -193,7 +193,7 @@ void g_MenuInit(void) mi.name.a = "Cancel"; mi.position = 9999999; mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_DELETE); - Menu_AddItem(hChooserMenu, &mi, NULL); + Menu_AddItem(hChooserMenu, &mi, nullptr); } ////////////////////////////////////////////////////////////////////////////////////// @@ -321,7 +321,7 @@ void g_MenuInit(void) SET_UID(mi, 0x32a7bb9d, 0x4d9, 0x49b3, 0xac, 0x8f, 0x83, 0xb5, 0x6b, 0xff, 0x4f, 0x5); mi.flags = 0; - mi.root = NULL; + mi.root = nullptr; mi.pszService = "Jabber/ResourceSelectorDummySvc"; mi.name.a = LPGEN("Jabber Resource"); mi.position = -1999901011; @@ -367,14 +367,14 @@ void g_MenuUninit(void) int CJabberProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM) { - if (hContact == NULL) + if (hContact == 0) return 0; bool bIsChatRoom = isChatRoom(hContact); bool bIsTransport = getBool(hContact, "IsTransport", false); if ((bIsChatRoom == GCW_CHATROOM) || bIsChatRoom == 0) { - if (ptrW(getWStringA(hContact, bIsChatRoom ? (char*)"ChatRoomID" : (char*)"jid")) != NULL) { + if (ptrW(getWStringA(hContact, bIsChatRoom ? (char*)"ChatRoomID" : (char*)"jid")) != nullptr) { Menu_ShowItem(g_hMenuConvert, TRUE); Menu_ModifyItem(g_hMenuConvert, bIsChatRoom ? LPGENW("&Convert to Contact") : LPGENW("&Convert to Chat Room")); } @@ -385,14 +385,14 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM) Menu_ShowItem(g_hMenuDirectPresence[0], TRUE); for (int i = 0; i < _countof(PresenceModeArray); i++) - Menu_ModifyItem(g_hMenuDirectPresence[i + 1], NULL, Skin_LoadProtoIcon(m_szModuleName, PresenceModeArray[i].mode)); + Menu_ModifyItem(g_hMenuDirectPresence[i + 1], nullptr, Skin_LoadProtoIcon(m_szModuleName, PresenceModeArray[i].mode)); if (bIsChatRoom) { ptrW roomid(getWStringA(hContact, "ChatRoomID")); - if (roomid != NULL) { + if (roomid != nullptr) { Menu_ShowItem(g_hMenuRosterAdd, FALSE); - if (ListGetItemPtr(LIST_BOOKMARK, roomid) == NULL) + if (ListGetItemPtr(LIST_BOOKMARK, roomid) == nullptr) if (m_ThreadInfo && m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PRIVATE_STORAGE) Menu_ShowItem(g_hMenuAddBookmark, TRUE); } @@ -407,12 +407,12 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM) } ptrW jid(getWStringA(hContact, "jid")); - if (jid == NULL) + if (jid == nullptr) return 0; JabberCapsBits jcb = GetTotalJidCapabilites(jid); JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid); - if (item == NULL) + if (item == nullptr) return 0; bool bCtrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0; @@ -426,9 +426,9 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM) return 0; Menu_ShowItem(g_hMenuResourcesRoot, TRUE); - Menu_ModifyItem(g_hMenuResourcesRoot, NULL, m_hProtoIcon); - Menu_ModifyItem(g_hMenuResourcesActive, NULL, m_hProtoIcon, (item->resourceMode == RSMODE_LASTSEEN) ? CMIF_CHECKED : 0); - Menu_ModifyItem(g_hMenuResourcesServer, NULL, m_hProtoIcon, (item->resourceMode == RSMODE_SERVER) ? CMIF_CHECKED : 0); + Menu_ModifyItem(g_hMenuResourcesRoot, nullptr, m_hProtoIcon); + Menu_ModifyItem(g_hMenuResourcesActive, nullptr, m_hProtoIcon, (item->resourceMode == RSMODE_LASTSEEN) ? CMIF_CHECKED : 0); + Menu_ModifyItem(g_hMenuResourcesServer, nullptr, m_hProtoIcon, (item->resourceMode == RSMODE_SERVER) ? CMIF_CHECKED : 0); int nMenuResourceItemsNew = m_nMenuResourceItems; if (m_nMenuResourceItems < item->arResources.getCount()) { @@ -478,7 +478,7 @@ INT_PTR __cdecl CJabberProto::OnMenuConvertChatContact(WPARAM hContact, LPARAM) const char *szSetting = (bIsChatRoom) ? "ChatRoomID" : "jid"; ptrW jid(getWStringA(hContact, szSetting)); - if (jid != NULL) { + if (jid != nullptr) { delSetting(hContact, szSetting); setWString(hContact, szSetting, jid); setByte(hContact, "ChatRoom", !bIsChatRoom); @@ -492,17 +492,17 @@ INT_PTR __cdecl CJabberProto::OnMenuRosterAdd(WPARAM hContact, LPARAM) return 0; // we do not add ourself to the roster. (buggy situation - should not happen) ptrW roomID(getWStringA(hContact, "ChatRoomID")); - if (roomID == NULL) + if (roomID == nullptr) return 0; - if (ListGetItemPtr(LIST_ROSTER, roomID) == NULL) { + if (ListGetItemPtr(LIST_ROSTER, roomID) == nullptr) { ptrW group(db_get_wsa(hContact, "CList", "Group")); ptrW nick(getWStringA(hContact, "Nick")); AddContactToRoster(roomID, nick, group); if (m_options.AddRoster2Bookmarks == TRUE) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_BOOKMARK, roomID); - if (item == NULL) { + if (item == nullptr) { item = new JABBER_LIST_ITEM(); item->jid = mir_wstrdup(roomID); item->name = mir_wstrdup(nick); @@ -517,9 +517,9 @@ INT_PTR __cdecl CJabberProto::OnMenuRosterAdd(WPARAM hContact, LPARAM) INT_PTR __cdecl CJabberProto::OnMenuHandleRequestAuth(WPARAM hContact, LPARAM) { - if (hContact != NULL && m_bJabberOnline) { + if (hContact != 0 && m_bJabberOnline) { ptrW jid(getWStringA(hContact, "jid")); - if (jid != NULL) + if (jid != nullptr) m_ThreadInfo->send(XmlNode(L"presence") << XATTR(L"to", jid) << XATTR(L"type", L"subscribe")); } return 0; @@ -527,9 +527,9 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleRequestAuth(WPARAM hContact, LPARAM) INT_PTR __cdecl CJabberProto::OnMenuHandleGrantAuth(WPARAM hContact, LPARAM) { - if (hContact != NULL && m_bJabberOnline) { + if (hContact != 0 && m_bJabberOnline) { ptrW jid(getWStringA(hContact, "jid")); - if (jid != NULL) + if (jid != nullptr) m_ThreadInfo->send(XmlNode(L"presence") << XATTR(L"to", jid) << XATTR(L"type", L"subscribed")); } return 0; @@ -537,9 +537,9 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleGrantAuth(WPARAM hContact, LPARAM) INT_PTR __cdecl CJabberProto::OnMenuRevokeAuth(WPARAM hContact, LPARAM) { - if (hContact != NULL && m_bJabberOnline) { + if (hContact != 0 && m_bJabberOnline) { ptrW jid(getWStringA(hContact, "jid")); - if (jid != NULL) + if (jid != nullptr) m_ThreadInfo->send(XmlNode(L"presence") << XATTR(L"to", jid) << XATTR(L"type", L"unsubscribed")); } return 0; @@ -551,7 +551,7 @@ INT_PTR __cdecl CJabberProto::OnMenuTransportLogin(WPARAM hContact, LPARAM) return 0; JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, ptrW(getWStringA(hContact, "jid"))); - if (item != NULL) { + if (item != nullptr) { XmlNode p(L"presence"); XmlAddAttr(p, L"to", item->jid); if (item->getTemp()->m_iStatus == ID_STATUS_ONLINE) XmlAddAttr(p, L"type", L"unavailable"); @@ -566,7 +566,7 @@ INT_PTR __cdecl CJabberProto::OnMenuTransportResolve(WPARAM hContact, LPARAM) return 0; ptrW jid(getWStringA(hContact, "jid")); - if (jid != NULL) + if (jid != nullptr) ResolveTransportNicks(jid); return 0; } @@ -577,10 +577,10 @@ INT_PTR __cdecl CJabberProto::OnMenuBookmarkAdd(WPARAM hContact, LPARAM) return 0; // we do not add ourself to the roster. (buggy situation - should not happen) ptrW roomID(getWStringA(hContact, "ChatRoomID")); - if (roomID == NULL) + if (roomID == nullptr) return 0; - if (ListGetItemPtr(LIST_BOOKMARK, roomID) == NULL) { + if (ListGetItemPtr(LIST_BOOKMARK, roomID) == nullptr) { JABBER_LIST_ITEM *item = new JABBER_LIST_ITEM(); item->jid = mir_wstrdup(roomID); item->name = pcli->pfnGetContactDisplayName(hContact, 0); @@ -610,7 +610,7 @@ void CJabberProto::MenuInit() m_hMenuBookmarks = Menu_AddProtoMenuItem(&mi, m_szModuleName); // "Services..." - mi.pszService = NULL; + mi.pszService = nullptr; mi.name.a = LPGEN("Services..."); mi.position = 200003; mi.hIcolibItem = GetIconHandle(IDI_SERVICE_DISCOVERY); @@ -694,7 +694,7 @@ void CJabberProto::MenuInit() m_priorityMenuVal = 0; m_priorityMenuValSet = false; - mi.pszService = NULL; + mi.pszService = nullptr; mi.position = 200006; mi.root = m_hMenuRoot; mi.name.a = LPGEN("Resource priority"); @@ -876,7 +876,7 @@ void CJabberProto::GlobalMenuUninit() for (int i = 0; i < m_nMenuResourceItems; i++) Menu_RemoveItem(m_phMenuResourceItems[i]); mir_free(m_phMenuResourceItems); - m_phMenuResourceItems = NULL; + m_phMenuResourceItems = nullptr; } m_nMenuResourceItems = 0; } @@ -942,7 +942,7 @@ int CJabberProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam) WindowList_Add(hDialogsList, event->hwndWindow, event->hContact); ptrW jid(getWStringA(event->hContact, "jid")); - if (jid != NULL) { + if (jid != nullptr) { JABBER_LIST_ITEM *pItem = ListGetItemPtr(LIST_ROSTER, jid); if (pItem && m_ThreadInfo && (m_ThreadInfo->jabberServerCaps & JABBER_CAPS_ARCHIVE_AUTO) && m_options.EnableMsgArchive) RetrieveMessageArchive(event->hContact, pItem); @@ -958,7 +958,7 @@ int CJabberProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam) bSupportTyping = dbv.bVal == 1; db_free(&dbv); } - else if (!db_get(NULL, "SRMsg", "DefaultTyping", &dbv)) { + else if (!db_get(0, "SRMsg", "DefaultTyping", &dbv)) { bSupportTyping = dbv.bVal == 1; db_free(&dbv); } @@ -990,7 +990,7 @@ int CJabberProto::OnProcessSrmmIconClick(WPARAM hContact, LPARAM lParam) return 0; JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, ptrW(getWStringA(hContact, "jid"))); - if (LI == NULL) + if (LI == nullptr) return 0; HMENU hMenu = CreatePopupMenu(); @@ -1002,7 +1002,7 @@ int CJabberProto::OnProcessSrmmIconClick(WPARAM hContact, LPARAM lParam) AppendMenu(hMenu, MF_STRING, MENUITEM_SERVER, TranslateT("Highest priority (server's choice)")); - AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); + AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr); for (int i = 0; i < LI->arResources.getCount(); i++) AppendMenu(hMenu, MF_STRING, MENUITEM_RESOURCES + i, LI->arResources[i]->m_tszResourceName); @@ -1013,14 +1013,14 @@ int CJabberProto::OnProcessSrmmIconClick(WPARAM hContact, LPARAM lParam) else if (LI->m_pManualResource) CheckMenuItem(hMenu, MENUITEM_RESOURCES + LI->arResources.indexOf(LI->m_pManualResource), MF_BYCOMMAND | MF_CHECKED); - int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, sicd->clickLocation.x, sicd->clickLocation.y, 0, WindowList_Find(hDialogsList, hContact), NULL); + int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, sicd->clickLocation.x, sicd->clickLocation.y, 0, WindowList_Find(hDialogsList, hContact), nullptr); if (res == MENUITEM_LASTSEEN) { - LI->m_pManualResource = NULL; + LI->m_pManualResource = nullptr; LI->resourceMode = RSMODE_LASTSEEN; } else if (res == MENUITEM_SERVER) { - LI->m_pManualResource = NULL; + LI->m_pManualResource = nullptr; LI->resourceMode = RSMODE_SERVER; } else if (res >= MENUITEM_RESOURCES) { @@ -1040,19 +1040,19 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleResource(WPARAM hContact, LPARAM, LPAR return 0; ptrW tszJid(getWStringA(hContact, "jid")); - if (tszJid == NULL) + if (tszJid == nullptr) return 0; JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, tszJid); - if (LI == NULL) + if (LI == nullptr) return 0; if (res == MENUITEM_LASTSEEN) { - LI->m_pManualResource = NULL; + LI->m_pManualResource = nullptr; LI->resourceMode = RSMODE_LASTSEEN; } else if (res == MENUITEM_SERVER) { - LI->m_pManualResource = NULL; + LI->m_pManualResource = nullptr; LI->resourceMode = RSMODE_SERVER; } else if (res >= MENUITEM_RESOURCES) { @@ -1072,13 +1072,13 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleDirectPresence(WPARAM hContact, LPARAM wchar_t *jid, text[1024]; ptrW tszJid(getWStringA(hContact, "jid")); - if (tszJid == NULL) { + if (tszJid == nullptr) { ptrW roomid(getWStringA(hContact, "ChatRoomID")); - if (roomid == NULL) + if (roomid == nullptr) return 0; JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, roomid); - if (item == NULL) + if (item == nullptr) return 0; mir_snwprintf(text, L"%s/%s", item->jid, item->nick); @@ -1088,7 +1088,7 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleDirectPresence(WPARAM hContact, LPARAM CMStringW szValue; if (EnterString(szValue, TranslateT("Status Message"), ESF_MULTILINE)) - SendPresenceTo(res, jid, NULL, szValue); + SendPresenceTo(res, jid, nullptr, szValue); return 0; } @@ -1098,12 +1098,12 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleDirectPresence(WPARAM hContact, LPARAM CJabberProto* JabberChooseInstance(bool bIsLink) { if (g_Instances.getCount() == 0) - return NULL; + return nullptr; if (g_Instances.getCount() == 1) { if (g_Instances[0]->m_iStatus != ID_STATUS_OFFLINE && g_Instances[0]->m_iStatus != ID_STATUS_CONNECTING) return g_Instances[0]; - return NULL; + return nullptr; } if (bIsLink) @@ -1117,7 +1117,7 @@ CJabberProto* JabberChooseInstance(bool bIsLink) if (ppro->m_iStatus != ID_STATUS_OFFLINE && ppro->m_iStatus != ID_STATUS_CONNECTING) { ++nItems; lastItemId = i + 1; - Menu_ModifyItem(ppro->m_hChooseMenuItem, NULL, Skin_LoadProtoIcon(ppro->m_szModuleName, ppro->m_iStatus)); + Menu_ModifyItem(ppro->m_hChooseMenuItem, nullptr, Skin_LoadProtoIcon(ppro->m_szModuleName, ppro->m_iStatus)); } else Menu_ShowItem(ppro->m_hChooseMenuItem, false); } @@ -1128,17 +1128,17 @@ CJabberProto* JabberChooseInstance(bool bIsLink) HMENU hMenu = CreatePopupMenu(); Menu_Build(hMenu, hChooserMenu); - int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, pcli->hwndContactList, NULL); + int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, pcli->hwndContactList, nullptr); DestroyMenu(hMenu); if (res) { - CJabberProto* pro = NULL; + CJabberProto* pro = nullptr; Menu_ProcessCommandById(res, (LPARAM)&pro); return pro; } - return NULL; + return nullptr; } - return lastItemId ? g_Instances[lastItemId - 1] : NULL; + return lastItemId ? g_Instances[lastItemId - 1] : nullptr; } diff --git a/protocols/JabberG/src/jabber_message_handlers.cpp b/protocols/JabberG/src/jabber_message_handlers.cpp index 8b3496bc9e..c0684869d0 100644 --- a/protocols/JabberG/src/jabber_message_handlers.cpp +++ b/protocols/JabberG/src/jabber_message_handlers.cpp @@ -31,9 +31,9 @@ BOOL CJabberProto::OnMessageError(HXML node, ThreadData*, CJabberMessageInfo* pI // we check if is message delivery failure int id = JabberGetPacketID(node); JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, pInfo->GetFrom()); - if (item == NULL) + if (item == nullptr) item = ListGetItemPtr(LIST_CHATROOM, pInfo->GetFrom()); - if (item != NULL) { // yes, it is + if (item != nullptr) { // yes, it is wchar_t *szErrText = JabberErrorMsg(pInfo->GetChildNode()); if (id != -1) { char *errText = mir_u2a(szErrText); @@ -48,7 +48,7 @@ BOOL CJabberProto::OnMessageError(HXML node, ThreadData*, CJabberMessageInfo* pI else mir_snwprintf(buf, L"%s:\n%s", pInfo->GetFrom(), szErrText); - MsgPopup(NULL, buf, TranslateT("Jabber Error")); + MsgPopup(0, buf, TranslateT("Jabber Error")); } mir_free(szErrText); } diff --git a/protocols/JabberG/src/jabber_message_manager.cpp b/protocols/JabberG/src/jabber_message_manager.cpp index a00c7e1814..8327ba5fc9 100644 --- a/protocols/JabberG/src/jabber_message_manager.cpp +++ b/protocols/JabberG/src/jabber_message_manager.cpp @@ -43,10 +43,10 @@ CJabberMessageManager::~CJabberMessageManager() void CJabberMessageManager::FillPermanentHandlers() { - AddPermanentHandler(&CJabberProto::OnMessageError, JABBER_MESSAGE_TYPE_ERROR, JABBER_MESSAGE_PARSE_FROM | JABBER_MESSAGE_PARSE_HCONTACT, NULL, FALSE, L"error"); + AddPermanentHandler(&CJabberProto::OnMessageError, JABBER_MESSAGE_TYPE_ERROR, JABBER_MESSAGE_PARSE_FROM | JABBER_MESSAGE_PARSE_HCONTACT, nullptr, FALSE, L"error"); AddPermanentHandler(&CJabberProto::OnMessageIbb, 0, 0, JABBER_FEAT_IBB, FALSE, L"data"); AddPermanentHandler(&CJabberProto::OnMessagePubsubEvent, 0, 0, JABBER_FEAT_PUBSUB_EVENT, FALSE, L"event"); - AddPermanentHandler(&CJabberProto::OnMessageGroupchat, JABBER_MESSAGE_TYPE_GROUPCHAT, JABBER_MESSAGE_PARSE_FROM, NULL, FALSE, NULL); + AddPermanentHandler(&CJabberProto::OnMessageGroupchat, JABBER_MESSAGE_TYPE_GROUPCHAT, JABBER_MESSAGE_PARSE_FROM, nullptr, FALSE, nullptr); } bool CJabberMessageManager::HandleMessagePermanent(HXML node, ThreadData *pThreadData) diff --git a/protocols/JabberG/src/jabber_message_manager.h b/protocols/JabberG/src/jabber_message_manager.h index 53a87fb68c..4527d77269 100644 --- a/protocols/JabberG/src/jabber_message_manager.h +++ b/protocols/JabberG/src/jabber_message_manager.h @@ -125,7 +125,7 @@ public: CJabberMessageManager(CJabberProto *proto); ~CJabberMessageManager(); - CJabberMessagePermanentInfo* AddPermanentHandler(JABBER_PERMANENT_MESSAGE_HANDLER pHandler, int nMessageTypes, DWORD dwParamsToParse, const wchar_t *szXmlns, BOOL bAllowPartialNs, const wchar_t *szTag, void *pUserData = NULL, MESSAGE_USER_DATA_FREE_FUNC pUserDataFree = NULL, int iPriority = JH_PRIORITY_DEFAULT); + CJabberMessagePermanentInfo* AddPermanentHandler(JABBER_PERMANENT_MESSAGE_HANDLER pHandler, int nMessageTypes, DWORD dwParamsToParse, const wchar_t *szXmlns, BOOL bAllowPartialNs, const wchar_t *szTag, void *pUserData = nullptr, MESSAGE_USER_DATA_FREE_FUNC pUserDataFree = nullptr, int iPriority = JH_PRIORITY_DEFAULT); bool DeletePermanentHandler(CJabberMessagePermanentInfo *pInfo); bool HandleMessagePermanent(HXML node, ThreadData *pThreadData); diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index 8b09052424..7ade567dec 100755 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -48,16 +48,16 @@ void CJabberProto::DBAddAuthRequest(const wchar_t *jid, const wchar_t *nick) MCONTACT hContact = DBCreateContact(jid, nick, true, true); delSetting(hContact, "Hidden"); - DB_AUTH_BLOB blob(hContact, T2Utf(nick), NULL, NULL, T2Utf(jid), NULL); + DB_AUTH_BLOB blob(hContact, T2Utf(nick), nullptr, nullptr, T2Utf(jid), nullptr); DBEVENTINFO dbei = {}; dbei.szModule = m_szModuleName; - dbei.timestamp = (DWORD)time(NULL); + dbei.timestamp = (DWORD)time(nullptr); dbei.flags = DBEF_UTF; dbei.eventType = EVENTTYPE_AUTHREQUEST; dbei.cbBlob = blob.size(); dbei.pBlob = blob; - db_event_add(NULL, &dbei); + db_event_add(0, &dbei); debugLogA("Setup DBAUTHREQUEST with nick='%s' jid='%s'", blob.get_nick(), blob.get_email()); } @@ -66,11 +66,11 @@ void CJabberProto::DBAddAuthRequest(const wchar_t *jid, const wchar_t *nick) MCONTACT CJabberProto::DBCreateContact(const wchar_t *jid, const wchar_t *nick, bool temporary, bool stripResource) { - if (jid == NULL || jid[0] == '\0') - return NULL; + if (jid == nullptr || jid[0] == '\0') + return 0; MCONTACT hContact = HContactFromJID(jid, stripResource); - if (hContact != NULL) + if (hContact != 0) return hContact; // strip resource if present @@ -83,7 +83,7 @@ MCONTACT CJabberProto::DBCreateContact(const wchar_t *jid, const wchar_t *nick, MCONTACT hNewContact = db_add_contact(); Proto_AddToContact(hNewContact, m_szModuleName); setWString(hNewContact, "jid", szJid); - if (nick != NULL && *nick != '\0') + if (nick != nullptr && *nick != '\0') setWString(hNewContact, "Nick", nick); if (temporary) db_set_b(hNewContact, "CList", "NotOnList", 1); @@ -123,7 +123,7 @@ BOOL CJabberProto::AddDbPresenceEvent(MCONTACT hContact, BYTE btEventType) dbei.cbBlob = sizeof(btEventType); dbei.eventType = EVENTTYPE_JABBER_PRESENCE; dbei.flags = DBEF_READ; - dbei.timestamp = time(NULL); + dbei.timestamp = time(nullptr); dbei.szModule = m_szModuleName; db_event_add(hContact, &dbei); @@ -145,7 +145,7 @@ void CJabberProto::GetAvatarFileName(MCONTACT hContact, wchar_t* pszDest, size_t const wchar_t* szFileType = ProtoGetAvatarExtension(getByte(hContact, "AvatarType", PA_FORMAT_PNG)); - if (hContact != NULL) { + if (hContact != 0) { char str[256]; JabberShaStrBuf buf; DBVARIANT dbv; @@ -157,7 +157,7 @@ void CJabberProto::GetAvatarFileName(MCONTACT hContact, wchar_t* pszDest, size_t else _i64toa((LONG_PTR)hContact, str, 10); mir_snwprintf(pszDest + tPathLen, MAX_PATH - tPathLen, L"%S%s", JabberSha1(str, buf), szFileType); } - else if (m_ThreadInfo != NULL) { + else if (m_ThreadInfo != nullptr) { mir_snwprintf(pszDest + tPathLen, MAX_PATH - tPathLen, L"%s@%S avatar%s", m_ThreadInfo->conn.username, m_ThreadInfo->conn.server, szFileType); } @@ -175,18 +175,18 @@ void CJabberProto::ResolveTransportNicks(const wchar_t *jid) { // Set all contacts to offline MCONTACT hContact = m_ThreadInfo->resolveContact; - if (hContact == NULL) + if (hContact == 0) hContact = db_find_first(m_szModuleName); - for (; hContact != NULL; hContact = db_find_next(hContact, m_szModuleName)) { + for (; hContact != 0; hContact = db_find_next(hContact, m_szModuleName)) { if (!getByte(hContact, "IsTransported", 0)) continue; - ptrW dbJid(getWStringA(hContact, "jid")); if (dbJid == NULL) continue; - ptrW dbNick(getWStringA(hContact, "Nick")); if (dbNick == NULL) continue; + ptrW dbJid(getWStringA(hContact, "jid")); if (dbJid == nullptr) continue; + ptrW dbNick(getWStringA(hContact, "Nick")); if (dbNick == nullptr) continue; wchar_t *p = wcschr(dbJid, '@'); - if (p == NULL) + if (p == nullptr) continue; *p = 0; @@ -199,7 +199,7 @@ void CJabberProto::ResolveTransportNicks(const wchar_t *jid) } m_ThreadInfo->resolveID = -1; - m_ThreadInfo->resolveContact = NULL; + m_ThreadInfo->resolveContact = 0; } /////////////////////////////////////////////////////////////////////////////// @@ -237,7 +237,7 @@ void CJabberProto::SetServerStatus(int iNewStatus) // send presence update SendPresence(m_iStatus, true); - ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); + ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); } ////////////////////////////////////////////////////////////////////////// @@ -277,7 +277,7 @@ void CJabberProto::UpdateMirVer(JABBER_LIST_ITEM *item) debugLogW(L"JabberUpdateMirVer: for jid %s", item->jid); - pResourceStatus p(NULL); + pResourceStatus p(nullptr); if (item->resourceMode == RSMODE_LASTSEEN) p = item->m_pLastSeenResource; else if (item->resourceMode == RSMODE_MANUAL) @@ -346,7 +346,7 @@ void CJabberProto::UpdateMirVer(MCONTACT hContact, pResourceStatus &resource) setWString(hContact, "MirVer", tszMirVer); ptrW jid(getWStringA(hContact, "jid")); - if (jid == NULL) + if (jid == nullptr) return; wchar_t szFullJid[JABBER_MAX_JID_LEN]; @@ -438,7 +438,7 @@ void CJabberProto::MsgPopup(MCONTACT hContact, const wchar_t *szMsg, const wchar } else { DWORD mtype = MB_OK | MB_SETFOREGROUND | MB_ICONSTOP; - MessageBox(NULL, szMsg, szTitle, mtype); + MessageBox(nullptr, szMsg, szTitle, mtype); } } @@ -448,10 +448,10 @@ CMStringW CJabberProto::ExtractImage(HXML node) LPCTSTR src; CMStringW link; - if ((nHtml = XmlGetChild(node, "html")) != NULL && - (nBody = XmlGetChild(nHtml, "body")) != NULL && - (nImg = XmlGetChild(nBody, "img")) != NULL && - (src = XmlGetAttrValue(nImg, L"src")) != NULL) { + if ((nHtml = XmlGetChild(node, "html")) != nullptr && + (nBody = XmlGetChild(nHtml, "body")) != nullptr && + (nImg = XmlGetChild(nBody, "img")) != nullptr && + (src = XmlGetAttrValue(nImg, L"src")) != nullptr) { CMStringW strSrc(src); if (strSrc.Left(11).Compare(L"data:image/") == 0) { @@ -472,14 +472,14 @@ CMStringW CJabberProto::ExtractImage(HXML node) wcsncat_s(tszTempFile, ext, ext.GetLength()); HANDLE h = CreateFile(tszTempFile, GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, NULL); + FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, nullptr); if (h != INVALID_HANDLE_VALUE) { DWORD n; unsigned int bufferLen; ptrA buffer((char*)mir_base64_decode(_T2A(image), &bufferLen)); - WriteFile(h, buffer, bufferLen, &n, NULL); + WriteFile(h, buffer, bufferLen, &n, nullptr); CloseHandle(h); link = L" file:///"; diff --git a/protocols/JabberG/src/jabber_notes.cpp b/protocols/JabberG/src/jabber_notes.cpp index cc73c491e4..30dc16426d 100644 --- a/protocols/JabberG/src/jabber_notes.cpp +++ b/protocols/JabberG/src/jabber_notes.cpp @@ -50,12 +50,12 @@ static wchar_t* StrTrimCopy(wchar_t *str) CNoteItem::CNoteItem() { - m_szTitle = m_szFrom = m_szText = m_szTags = m_szTagsStr = NULL; + m_szTitle = m_szFrom = m_szText = m_szTags = m_szTagsStr = nullptr; } CNoteItem::CNoteItem(HXML hXml, wchar_t *szFrom) { - m_szTitle = m_szFrom = m_szText = m_szTags = m_szTagsStr = NULL; + m_szTitle = m_szFrom = m_szText = m_szTags = m_szTagsStr = nullptr; SetData( XPathT(hXml, "title"), szFrom ? szFrom : XPathT(hXml, "@from"), @@ -212,7 +212,7 @@ private: CJabberDlgNoteItem::CJabberDlgNoteItem(CJabberDlgBase *parent, CNoteItem *pNote) : CSuper(parent->GetProto(), IDD_NOTE_EDIT), m_pNote(pNote), - m_fnProcess(NULL), + m_fnProcess(nullptr), m_txtTitle(this, IDC_TXT_TITLE), m_txtText(this, IDC_TXT_TEXT), m_txtTags(this, IDC_TXT_TAGS), @@ -287,7 +287,7 @@ public: : CCtrlListBox(dlg, ctrlId), m_adding(false) { - m_hfntNormal = m_hfntSmall = m_hfntBold = NULL; + m_hfntNormal = m_hfntSmall = m_hfntBold = nullptr; } void SetFonts(HFONT hfntNormal, HFONT hfntSmall, HFONT hfntBold) @@ -335,7 +335,7 @@ public: if (mis.itemHeight) SendMessage(m_hwnd, LB_SETITEMHEIGHT, idx, mis.itemHeight); } SendMessage(m_hwnd, WM_SETREDRAW, TRUE, 0); - RedrawWindow(m_hwnd, NULL, NULL, RDW_INVALIDATE); + RedrawWindow(m_hwnd, nullptr, nullptr, RDW_INVALIDATE); } return CSuper::CustomWndProc(msg, wParam, lParam); @@ -611,7 +611,7 @@ private: }; CJabberDlgNotes::CJabberDlgNotes(CJabberProto *proto) : - CSuper(proto, IDD_NOTEBOOK, NULL), + CSuper(proto, IDD_NOTEBOOK, nullptr), m_btnAdd(this, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add")), m_btnEdit(this, IDC_EDIT, SKINICON_OTHER_RENAME, LPGEN("Edit")), m_btnRemove(this, IDC_REMOVE, SKINICON_OTHER_DELETE, LPGEN("Remove")), @@ -650,7 +650,7 @@ void CJabberDlgNotes::OnInitDialog() m_hfntSmall = CreateFontIndirect(&lfTmp); m_lstNotes.SetFonts(m_hfntNormal, m_hfntSmall, m_hfntBold); - Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "notesWnd_"); + Utils_RestoreWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "notesWnd_"); } void CJabberDlgNotes::OnClose() @@ -662,7 +662,7 @@ void CJabberDlgNotes::OnClose() } } - Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "notesWnd_"); + Utils_SaveWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "notesWnd_"); DeleteObject(m_hfntSmall); DeleteObject(m_hfntBold); CSuper::OnClose(); @@ -671,7 +671,7 @@ void CJabberDlgNotes::OnClose() void CJabberDlgNotes::OnDestroy() { m_tvFilter.DeleteAllItems(); - m_proto->m_pDlgNotes = NULL; + m_proto->m_pDlgNotes = nullptr; CSuper::OnDestroy(); } @@ -815,7 +815,7 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleNotes(WPARAM, LPARAM) INT_PTR __cdecl CJabberProto::OnMenuSendNote(WPARAM wParam, LPARAM) { if (wParam) { - CNoteItem *pItem = new CNoteItem(NULL, ptrW(getWStringA(wParam, "jid"))); + CNoteItem *pItem = new CNoteItem(nullptr, ptrW(getWStringA(wParam, "jid"))); CJabberDlgBase *pDlg = new CJabberDlgNoteItem(this, pItem, &CJabberProto::ProcessOutgoingNote); pDlg->Show(); } diff --git a/protocols/JabberG/src/jabber_omemo.cpp b/protocols/JabberG/src/jabber_omemo.cpp index fa1a2c671f..12d28a75c7 100755 --- a/protocols/JabberG/src/jabber_omemo.cpp +++ b/protocols/JabberG/src/jabber_omemo.cpp @@ -1471,7 +1471,7 @@ namespace omemo { char *msg = (char*)mir_alloc(msg_len); mir_snprintf(msg, msg_len, "%s%s%s", Translate("Do you want to create OMEMO session with new device:"), "\n\n\t", fingerprint); - int ret = MessageBoxA(NULL, msg, Translate("OMEMO: New session"), MB_YESNO); + int ret = MessageBoxA(nullptr, msg, Translate("OMEMO: New session"), MB_YESNO); if (ret == IDYES) { proto->setByte(hContact, fp_setting_name, 1); @@ -1631,8 +1631,8 @@ void CJabberProto::OmemoHandleMessage(HXML node, wchar_t *jid, time_t msgTime) } HXML key_node; DWORD own_id = m_omemo.GetOwnDeviceId(); - LPCTSTR encrypted_key_base64 = NULL; - for (int p = 1; (key_node = XmlGetNthChild(header_node, L"key", p)) != NULL; p++) + LPCTSTR encrypted_key_base64 = nullptr; + for (int p = 1; (key_node = XmlGetNthChild(header_node, L"key", p)) != nullptr; p++) { LPCTSTR dev_id = xmlGetAttrValue(key_node, L"rid"); char *dev_id_a = mir_u2a(dev_id); @@ -1663,7 +1663,7 @@ void CJabberProto::OmemoHandleMessage(HXML node, wchar_t *jid, time_t msgTime) iv = (unsigned char *)mir_base64_decode(iv_buf, &iv_len); mir_free(iv_buf); } - signal_buffer *decrypted_key = NULL; + signal_buffer *decrypted_key = nullptr; bool decrypted = false; { //try to decrypt as pre_key_signal_message @@ -1788,8 +1788,8 @@ void CJabberProto::OmemoHandleMessage(HXML node, wchar_t *jid, time_t msgTime) EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); EVP_DecryptInit(ctx, cipher, signal_buffer_data(decrypted_key), iv); // EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, 16, tag); - //EVP_DecryptInit(ctx, NULL, signal_buffer_data(decrypted_key), iv); - //EVP_DecryptUpdate(ctx, NULL, &howmany, AAD, aad_len); + //EVP_DecryptInit(ctx, nullptr, signal_buffer_data(decrypted_key), iv); + //EVP_DecryptUpdate(ctx, nullptr, &howmany, AAD, aad_len); for (;;) { @@ -1813,7 +1813,7 @@ void CJabberProto::OmemoHandleMessage(HXML node, wchar_t *jid, time_t msgTime) } - time_t now = time(NULL); + time_t now = time(nullptr); if (!msgTime) msgTime = now; @@ -1824,7 +1824,7 @@ void CJabberProto::OmemoHandleMessage(HXML node, wchar_t *jid, time_t msgTime) PROTORECVEVENT recv = { 0 }; recv.timestamp = (DWORD)msgTime; recv.szMessage = mir_utf8encode(out); - recv.lParam = (LPARAM)((pFromResource != NULL && m_options.EnableRemoteControl) ? pFromResource->m_tszResourceName : 0); + recv.lParam = (LPARAM)((pFromResource != nullptr && m_options.EnableRemoteControl) ? pFromResource->m_tszResourceName : 0); ProtoChainRecvMsg(hContact, &recv); mir_free(out); } @@ -1862,7 +1862,7 @@ void CJabberProto::OmemoHandleDeviceList(HXML node) char setting_name[64]; HXML list_item; int i = 0; - for (int p = 1; (list_item = XmlGetNthChild(node, L"device", p)) != NULL; p++, i++) + for (int p = 1; (list_item = XmlGetNthChild(node, L"device", p)) != nullptr; p++, i++) { current_id_str = xmlGetAttrValue(list_item, L"id"); char *current_id_str_a = mir_u2a(current_id_str); @@ -1892,7 +1892,7 @@ void CJabberProto::OmemoHandleDeviceList(HXML node) char setting_name[64]; HXML list_item; int i = 0; - for (int p = 1; (list_item = XmlGetNthChild(node, L"device", p)) != NULL; p++, i++) + for (int p = 1; (list_item = XmlGetNthChild(node, L"device", p)) != nullptr; p++, i++) { current_id_str = xmlGetAttrValue(list_item, L"id"); char *current_id_str_a = mir_u2a(current_id_str); @@ -2102,7 +2102,7 @@ bool CJabberProto::OmemoCheckSession(MCONTACT hContact) void CJabberProto::OmemoOnIqResultGetBundle(HXML iqNode, CJabberIqInfo *pInfo) { - if (iqNode == NULL) + if (iqNode == nullptr) return; LPCTSTR jid = XmlGetAttrValue(iqNode, L"from"); @@ -2196,7 +2196,7 @@ void CJabberProto::OmemoOnIqResultGetBundle(HXML iqNode, CJabberIqInfo *pInfo) wchar_t key_num_str[4]; mir_snwprintf(key_num_str, 3, L"%d", key_num); HXML prekey_node; - for (int p = 1; (prekey_node = XmlGetNthChild(prekeys, L"preKeyPublic", p)) != NULL && p <= key_num; p++) + for (int p = 1; (prekey_node = XmlGetNthChild(prekeys, L"preKeyPublic", p)) != nullptr && p <= key_num; p++) ; if (!prekey_node) { @@ -2268,12 +2268,12 @@ unsigned int CJabberProto::OmemoEncryptMessage(XmlNode &msg, const wchar_t *msg_ // Utils_GetRandom(tag, _countof_portable(tag)); //Utils_GetRandom(aad, _countof_portable(aad)); EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); - EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, _countof_portable(iv), NULL); + EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, _countof_portable(iv), nullptr); EVP_EncryptInit(ctx, cipher, key, iv); char *in = mir_u2a(msg_text), *out; const size_t inl = strlen(in); int tmp_len = 0, outl; - //EVP_EncryptUpdate(ctx, NULL, &outl, aad, _countof_portable(aad)); + //EVP_EncryptUpdate(ctx, nullptr, &outl, aad, _countof_portable(aad)); out = (char*)mir_alloc(inl + _countof_portable(key) - 1); for (;;) { diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index ea582b2319..5b3911e893 100755 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -221,7 +221,7 @@ struct { wchar_t *szCode; wchar_t *szDescription; } g_LanguageCodes[] = { { L"yo", LPGENW("Yoruba") }, { L"za", LPGENW("Zhuang; Chuang") }, { L"zu", LPGENW("Zulu") }, - { NULL, NULL } + { nullptr, nullptr } }; class CJabberDlgRegister : public CJabberDlgBase @@ -251,7 +251,7 @@ protected: { switch (msg) { case WM_JABBER_REGDLG_UPDATE: // wParam=progress (0-100), lparam=status string - if ((wchar_t*)lParam == NULL) + if ((wchar_t*)lParam == nullptr) SetDlgItemText(m_hwnd, IDC_REG_STATUS, TranslateT("No message")); else SetDlgItemText(m_hwnd, IDC_REG_STATUS, (wchar_t*)lParam); @@ -425,7 +425,7 @@ protected: SendDlgItemMessage(m_hwnd, IDC_PRIORITY_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG(127, -128)); - wchar_t *passw = m_proto->getWStringA(NULL, "Password"); + wchar_t *passw = m_proto->getWStringA(0, "Password"); if (passw) { m_txtPassword.SetText(passw); mir_free(passw); @@ -445,7 +445,7 @@ protected: m_cbResource.AddString(szCompName); ptrW tszResource(m_proto->getWStringA("Resource")); - if (tszResource != NULL) { + if (tszResource != nullptr) { if (CB_ERR == m_cbResource.FindString(tszResource, -1, true)) m_cbResource.AddString(tszResource); m_cbResource.SetText(tszResource); @@ -480,7 +480,7 @@ protected: void OnApply() { // clear saved password - m_proto->m_savedPassword = NULL; + m_proto->m_savedPassword = nullptr; if (m_chkSavePassword.GetState() == BST_CHECKED) m_proto->setWString("Password", ptrW(m_txtPassword.GetText())); @@ -565,7 +565,7 @@ private: void btnUnregister_OnClick(CCtrlButton *) { - int res = MessageBox(NULL, + int res = MessageBox(nullptr, TranslateT("This operation will kill your account, roster and all other information stored at the server. Are you ready to do that?"), TranslateT("Account removal warning"), MB_YESNOCANCEL); @@ -578,7 +578,7 @@ private: void btnChangePassword_OnClick(CCtrlButton *) { if (!m_proto->m_bJabberOnline) { - MessageBox(NULL, + MessageBox(nullptr, TranslateT("You can change your password only when you are online"), TranslateT("You must be online"), MB_OK | MB_ICONSTOP); return; @@ -684,7 +684,7 @@ private: void RefreshServers(HXML node) { - m_gotservers = node != NULL; + m_gotservers = node != nullptr; wchar_t *server = m_cbServer.GetText(); bool bDropdown = m_cbServer.GetDroppedState(); @@ -730,7 +730,7 @@ private: if (result) { if (result->resultCode == 200 && result->dataLength && result->pData) { wchar_t *buf = mir_a2u(result->pData); - XmlNode node(buf, NULL, NULL); + XmlNode node(buf, nullptr, nullptr); if (node) { HXML queryNode = XmlGetChild(node, L"query"); SendMessage(hwnd, WM_JABBER_REFRESH, 0, (LPARAM)queryNode); @@ -833,10 +833,10 @@ public: LISTFOREACH(index, m_proto, LIST_ROSTER) { JABBER_LIST_ITEM *item = m_proto->ListGetItemPtrFromIndex(index); - if (item != NULL) { - if (wcschr(item->jid, '@') == NULL) { + if (item != nullptr) { + if (wcschr(item->jid, '@') == nullptr) { MCONTACT hContact = m_proto->HContactFromJID(item->jid); - if (hContact != NULL) { + if (hContact != 0) { if (bChecked) { if (item->getTemp()->m_iStatus != m_proto->getWord(hContact, "Status", ID_STATUS_OFFLINE)) { m_proto->setWord(hContact, "Status", (WORD)item->getTemp()->m_iStatus); @@ -1002,15 +1002,15 @@ void CJabberProto::_RosterHandleGetRequest(HXML node, CJabberIqInfo*) if (rrud.bRRAction == RRA_FILLLIST) { _RosterListClear(rrud.hwndDlg); HXML query = XmlGetChild(node, "query"); - if (query == NULL) return; + if (query == nullptr) return; int i = 1; while (TRUE) { HXML item = XmlGetNthChild(query, L"item", i++); - if (item == NULL) + if (item == nullptr) break; const wchar_t *jid = XmlGetAttrValue(item, L"jid"); - if (jid == NULL) + if (jid == nullptr) continue; const wchar_t *name = XmlGetAttrValue(item, L"name"); @@ -1022,7 +1022,7 @@ void CJabberProto::_RosterHandleGetRequest(HXML node, CJabberIqInfo*) // now it is require to process whole contact list to add not in roster contacts for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { ptrW tszJid(getWStringA(hContact, "jid")); - if (tszJid == NULL) + if (tszJid == nullptr) continue; LVFINDINFO lvfi = { 0 }; @@ -1036,7 +1036,7 @@ void CJabberProto::_RosterHandleGetRequest(HXML node, CJabberIqInfo*) if (ListView_FindItem(hList, -1, &lvfi) == -1) { ptrW tszName(db_get_wsa(hContact, "CList", "MyHandle")); ptrW tszGroup(db_get_wsa(hContact, "CList", "Group")); - _RosterInsertListItem(hList, tszJid, tszName, tszGroup, NULL, FALSE); + _RosterInsertListItem(hList, tszJid, tszName, tszGroup, nullptr, FALSE); } } rrud.bReadyToDownload = FALSE; @@ -1079,16 +1079,16 @@ void CJabberProto::_RosterHandleGetRequest(HXML node, CJabberIqInfo*) BOOL bPushed = itemRoster ? TRUE : FALSE; if (!bPushed) { const wchar_t *rosterName = XmlGetAttrValue(itemRoster, L"name"); - if ((rosterName != NULL || name[0] != 0) && mir_wstrcmpi(rosterName, name)) + if ((rosterName != nullptr || name[0] != 0) && mir_wstrcmpi(rosterName, name)) bPushed = TRUE; if (!bPushed) { rosterName = XmlGetAttrValue(itemRoster, L"subscription"); - if ((rosterName != NULL || subscr[0] != 0) && mir_wstrcmpi(rosterName, subscr)) + if ((rosterName != nullptr || subscr[0] != 0) && mir_wstrcmpi(rosterName, subscr)) bPushed = TRUE; } if (!bPushed) { const wchar_t *rosterGroup = XmlGetText(XmlGetChild(itemRoster, "group")); - if ((rosterGroup != NULL || group[0] != 0) && mir_wstrcmpi(rosterGroup, group)) + if ((rosterGroup != nullptr || group[0] != 0) && mir_wstrcmpi(rosterGroup, group)) bPushed = TRUE; } } @@ -1188,7 +1188,7 @@ void CJabberProto::_RosterExportToFile(HWND hwndDlg) OPENFILENAME ofn = { 0 }; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwndDlg; - ofn.hInstance = NULL; + ofn.hInstance = nullptr; ofn.lpstrFilter = filter; ofn.lpstrFile = filename; ofn.Flags = OFN_HIDEREADONLY; @@ -1235,7 +1235,7 @@ void CJabberProto::_RosterExportToFile(HWND hwndDlg) char header[] = "\n\n"; fwrite(header, 1, sizeof(header) - 1 /* for zero terminator */, fp); - wchar_t *xtmp = xmlToString(root, NULL); + wchar_t *xtmp = xmlToString(root, nullptr); fputs(T2Utf(xtmp), fp); xmlFree(xtmp); fclose(fp); @@ -1248,7 +1248,7 @@ void CJabberProto::_RosterImportFromFile(HWND hwndDlg) OPENFILENAMEA ofn = { 0 }; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwndDlg; - ofn.hInstance = NULL; + ofn.hInstance = nullptr; ofn.lpstrFilter = filter; ofn.lpstrFile = filename; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; @@ -1277,7 +1277,7 @@ void CJabberProto::_RosterImportFromFile(HWND hwndDlg) mir_free(buffer); int nBytesProcessed = 0; - XmlNode node(newBuf, &nBytesProcessed, NULL); + XmlNode node(newBuf, &nBytesProcessed, nullptr); if (node) { HXML Workbook = XmlGetChild(node, L"Workbook"); if (Workbook) { @@ -1293,10 +1293,10 @@ void CJabberProto::_RosterImportFromFile(HWND hwndDlg) break; BOOL bAdd = FALSE; - const wchar_t *jid = NULL; - const wchar_t *name = NULL; - const wchar_t *group = NULL; - const wchar_t *subscr = NULL; + const wchar_t *jid = nullptr; + const wchar_t *name = nullptr; + const wchar_t *group = nullptr; + const wchar_t *subscr = nullptr; HXML Cell = XmlGetNthChild(Row, L"Cell", 1); HXML Data = (Cell) ? XmlGetChild(Cell, "Data") : XmlNode(); if (Data) { @@ -1305,7 +1305,7 @@ void CJabberProto::_RosterImportFromFile(HWND hwndDlg) Cell = XmlGetNthChild(Row, L"Cell", 2); if (Cell) Data = XmlGetChild(Cell, "Data"); - else Data = NULL; + else Data = nullptr; if (Data) { jid = XmlGetText(Data); if (!jid || mir_wstrlen(jid) == 0) continue; @@ -1313,17 +1313,17 @@ void CJabberProto::_RosterImportFromFile(HWND hwndDlg) Cell = XmlGetNthChild(Row, L"Cell", 3); if (Cell) Data = XmlGetChild(Cell, "Data"); - else Data = NULL; + else Data = nullptr; if (Data) name = XmlGetText(Data); Cell = XmlGetNthChild(Row, L"Cell", 4); if (Cell) Data = XmlGetChild(Cell, "Data"); - else Data = NULL; + else Data = nullptr; if (Data) group = XmlGetText(Data); Cell = XmlGetNthChild(Row, L"Cell", 5); if (Cell) Data = XmlGetChild(Cell, "Data"); - else Data = NULL; + else Data = nullptr; if (Data) subscr = XmlGetText(Data); } _RosterInsertListItem(hList, jid, name, group, subscr, bAdd); @@ -1355,7 +1355,7 @@ static LRESULT CALLBACK _RosterNewListProc(HWND hList, UINT msg, WPARAM wParam, wchar_t buff[260]; ListView_GetSubItemRect(hList, lvhti.iItem, lvhti.iSubItem, LVIR_BOUNDS, &rc); ListView_GetItemText(hList, lvhti.iItem, lvhti.iSubItem, buff, _countof(buff)); - HWND hEditor = CreateWindow(TEXT("EDIT"), buff, WS_CHILD | ES_AUTOHSCROLL, rc.left + 3, rc.top + 2, rc.right - rc.left - 3, rc.bottom - rc.top - 3, hList, NULL, hInst, NULL); + HWND hEditor = CreateWindow(TEXT("EDIT"), buff, WS_CHILD | ES_AUTOHSCROLL, rc.left + 3, rc.top + 2, rc.right - rc.left - 3, rc.bottom - rc.top - 3, hList, nullptr, hInst, nullptr); SendMessage(hEditor, WM_SETFONT, (WPARAM)SendMessage(hList, WM_GETFONT, 0, 0), 0); ShowWindow(hEditor, SW_SHOW); SetWindowText(hEditor, buff); @@ -1407,7 +1407,7 @@ static INT_PTR CALLBACK JabberRosterOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wP TranslateDialogDefault(hwndDlg); Window_SetIcon_IcoLib(hwndDlg, g_GetIconHandle(IDI_AGENTS)); - Utils_RestoreWindowPosition(hwndDlg, NULL, ppro->m_szModuleName, "rosterCtrlWnd_"); + Utils_RestoreWindowPosition(hwndDlg, 0, ppro->m_szModuleName, "rosterCtrlWnd_"); ListView_SetExtendedListViewStyle(GetDlgItem(hwndDlg, IDC_ROSTER), LVS_EX_CHECKBOXES | LVS_EX_BORDERSELECT /*| LVS_EX_FULLROWSELECT*/ | LVS_EX_GRIDLINES /*| LVS_EX_HEADERDRAGDROP*/); mir_subclassWindow(GetDlgItem(hwndDlg, IDC_ROSTER), _RosterNewListProc); @@ -1432,8 +1432,8 @@ static INT_PTR CALLBACK JabberRosterOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wP break; case WM_DESTROY: - Utils_SaveWindowPosition(hwndDlg, NULL, ppro->m_szModuleName, "rosterCtrlWnd_"); - ppro->rrud.hwndDlg = NULL; + Utils_SaveWindowPosition(hwndDlg, 0, ppro->m_szModuleName, "rosterCtrlWnd_"); + ppro->rrud.hwndDlg = nullptr; Window_FreeIcon_IcoLib(hwndDlg); break; @@ -1484,7 +1484,7 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleRosterControl(WPARAM, LPARAM) if (rrud.hwndDlg && IsWindow(rrud.hwndDlg)) SetForegroundWindow(rrud.hwndDlg); else - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_OPT_JABBER3), NULL, JabberRosterOptDlgProc, (LPARAM)this); + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_OPT_JABBER3), nullptr, JabberRosterOptDlgProc, (LPARAM)this); return 0; } @@ -1575,7 +1575,7 @@ protected: m_gotservers = false; - wchar_t *passw = m_proto->getWStringA(NULL, "Password"); + wchar_t *passw = m_proto->getWStringA(0, "Password"); if (passw) { m_txtPassword.SetText(passw); mir_free(passw); @@ -1595,7 +1595,7 @@ protected: m_cbResource.AddString(szCompName); ptrW tszResource(m_proto->getWStringA("Resource")); - if (tszResource != NULL) { + if (tszResource != nullptr) { if (CB_ERR == m_cbResource.FindString(tszResource, -1, true)) m_cbResource.AddString(tszResource); m_cbResource.SetText(tszResource); @@ -1616,8 +1616,8 @@ protected: char server[256], manualServer[256] = { 0 }; m_cbServer.GetTextA(server, _countof(server)); - ptrA dbManualServer(db_get_sa(NULL, m_proto->m_szModuleName, "ManualHost")); - if (dbManualServer != NULL) + ptrA dbManualServer(db_get_sa(0, m_proto->m_szModuleName, "ManualHost")); + if (dbManualServer != nullptr) mir_strncpy(manualServer, dbManualServer, _countof(manualServer)); m_canregister = true; @@ -1668,7 +1668,7 @@ protected: m_txtPort.Enable(); ptrW dbManualHost(m_proto->getWStringA("ManualHost")); - if (dbManualHost != NULL) + if (dbManualHost != nullptr) m_txtManualHost.SetText(dbManualHost); m_txtPort.SetInt(m_proto->getWord("ManualPort", m_txtPort.GetInt())); @@ -1702,7 +1702,7 @@ protected: void OnApply() { // clear saved password - m_proto->m_savedPassword = NULL; + m_proto->m_savedPassword = nullptr; BOOL bUseHostnameAsResource = FALSE; wchar_t szCompName[MAX_COMPUTERNAME_LENGTH + 1], szResource[MAX_COMPUTERNAME_LENGTH + 1]; @@ -2138,7 +2138,7 @@ void CJabberDlgAccMgrUI::setupSMS() void CJabberDlgAccMgrUI::RefreshServers(HXML node) { - m_gotservers = node != NULL; + m_gotservers = node != nullptr; wchar_t *server = m_cbServer.GetText(); bool bDropdown = m_cbServer.GetDroppedState(); @@ -2180,7 +2180,7 @@ void CJabberDlgAccMgrUI::QueryServerListThread(void *arg) if (result && IsWindow(hwnd)) { if ((result->resultCode == 200) && result->dataLength && result->pData) { wchar_t *ptszText = mir_a2u(result->pData); - XmlNode node(ptszText, NULL, NULL); + XmlNode node(ptszText, nullptr, nullptr); if (node) { HXML queryNode = XmlGetChild(node, L"query"); if (queryNode && IsWindow(hwnd)) { diff --git a/protocols/JabberG/src/jabber_opttree.cpp b/protocols/JabberG/src/jabber_opttree.cpp index f7dc114ba8..dc067efb28 100644 --- a/protocols/JabberG/src/jabber_opttree.cpp +++ b/protocols/JabberG/src/jabber_opttree.cpp @@ -93,7 +93,7 @@ void CCtrlTreeOpts::OnInit() wchar_t itemName[1024]; HIMAGELIST hImgLst; - SelectItem(NULL); + SelectItem(nullptr); DeleteAllItems(); hImgLst = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR | ILC_COLOR32 | ILC_MASK, 5, 1); @@ -111,7 +111,7 @@ void CCtrlTreeOpts::OnInit() wchar_t *sectionName; int sectionLevel = 0; - HTREEITEM hSection = NULL; + HTREEITEM hSection = nullptr; mir_wstrcpy(itemName, m_options[i]->m_szOptionName); sectionName = itemName; @@ -163,7 +163,7 @@ void CCtrlTreeOpts::OnInit() TranslateTree(); ShowWindow(m_hwnd, SW_SHOW); - SelectItem(FindNamedItem(0, NULL)); + SelectItem(FindNamedItem(0, nullptr)); } void CCtrlTreeOpts::OnDestroy() @@ -226,7 +226,7 @@ void CCtrlTreeOpts::ProcessItemClick(HTREEITEM hti) } CCtrlTreeOpts::COptionsItem::COptionsItem(wchar_t *szOption, CMOption &option) : -m_option(&option), m_groupId(OPTTREE_CHECK), m_hItem(NULL) +m_option(&option), m_groupId(OPTTREE_CHECK), m_hItem(nullptr) { m_szOptionName = mir_wstrdup(szOption); } diff --git a/protocols/JabberG/src/jabber_password.cpp b/protocols/JabberG/src/jabber_password.cpp index 0f0f6b45dd..b60e09197e 100644 --- a/protocols/JabberG/src/jabber_password.cpp +++ b/protocols/JabberG/src/jabber_password.cpp @@ -33,7 +33,7 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleChangePassword(WPARAM, LPARAM) if (IsWindow(m_hwndJabberChangePassword)) SetForegroundWindow(m_hwndJabberChangePassword); else - m_hwndJabberChangePassword = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CHANGEPASSWORD), NULL, JabberChangePasswordDlgProc, (LPARAM)this); + m_hwndJabberChangePassword = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CHANGEPASSWORD), nullptr, JabberChangePasswordDlgProc, (LPARAM)this); return 0; } @@ -48,7 +48,7 @@ static INT_PTR CALLBACK JabberChangePasswordDlgProc(HWND hwndDlg, UINT msg, WPAR Window_SetIcon_IcoLib(hwndDlg, g_GetIconHandle(IDI_KEYS)); TranslateDialogDefault(hwndDlg); - if (ppro->m_bJabberOnline && ppro->m_ThreadInfo != NULL) { + if (ppro->m_bJabberOnline && ppro->m_ThreadInfo != nullptr) { wchar_t text[1024]; mir_snwprintf(text, TranslateT("Set New Password for %s@%S"), ppro->m_ThreadInfo->conn.username, ppro->m_ThreadInfo->conn.server); SetWindowText(hwndDlg, text); @@ -57,7 +57,7 @@ static INT_PTR CALLBACK JabberChangePasswordDlgProc(HWND hwndDlg, UINT msg, WPAR case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: - if (ppro->m_bJabberOnline && ppro->m_ThreadInfo != NULL) { + if (ppro->m_bJabberOnline && ppro->m_ThreadInfo != nullptr) { wchar_t newPasswd[512], text[512]; GetDlgItemText(hwndDlg, IDC_NEWPASSWD, newPasswd, _countof(newPasswd)); GetDlgItemText(hwndDlg, IDC_NEWPASSWD2, text, _countof(text)); @@ -89,7 +89,7 @@ static INT_PTR CALLBACK JabberChangePasswordDlgProc(HWND hwndDlg, UINT msg, WPAR DestroyWindow(hwndDlg); break; case WM_DESTROY: - ppro->m_hwndJabberChangePassword = NULL; + ppro->m_hwndJabberChangePassword = nullptr; Window_FreeIcon_IcoLib(hwndDlg); break; } diff --git a/protocols/JabberG/src/jabber_presence_manager.h b/protocols/JabberG/src/jabber_presence_manager.h index 6cf4e31b00..d329618278 100644 --- a/protocols/JabberG/src/jabber_presence_manager.h +++ b/protocols/JabberG/src/jabber_presence_manager.h @@ -95,7 +95,7 @@ public: CJabberPresenceManager(CJabberProto*); ~CJabberPresenceManager(); - CJabberPresencePermanentInfo* AddPermanentHandler(JABBER_PRESENCE_HANDLER pHandler, void *pUserData = NULL, PRESENCE_USER_DATA_FREE_FUNC pUserDataFree = NULL, int iPriority = JH_PRIORITY_DEFAULT); + CJabberPresencePermanentInfo* AddPermanentHandler(JABBER_PRESENCE_HANDLER pHandler, void *pUserData = nullptr, PRESENCE_USER_DATA_FREE_FUNC pUserDataFree = nullptr, int iPriority = JH_PRIORITY_DEFAULT); bool DeletePermanentHandler(CJabberPresencePermanentInfo *pInfo); bool HandlePresencePermanent(HXML node, ThreadData *pThreadData); diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp index 9cbc1ab4d5..ef1db75054 100644 --- a/protocols/JabberG/src/jabber_privacy.cpp +++ b/protocols/JabberG/src/jabber_privacy.cpp @@ -70,21 +70,21 @@ void CJabberProto::OnIqResultPrivacyListModify(HXML, CJabberIqInfo *pInfo) void CJabberProto::OnIqResultPrivacyList(HXML iqNode, CJabberIqInfo*) { - if (iqNode == NULL) + if (iqNode == nullptr) return; const wchar_t *type = XmlGetAttrValue(iqNode, L"type"); - if (type == NULL) + if (type == nullptr) return; if ( mir_wstrcmp(type, L"result")) return; HXML query = XmlGetChild(iqNode , "query"); - if (query == NULL) + if (query == nullptr) return; HXML list = XmlGetChild(query, "list"); - if (list == NULL) + if (list == nullptr) return; wchar_t *szListName = (wchar_t*)XmlGetAttrValue(list, L"name"); if (!szListName) @@ -92,15 +92,15 @@ void CJabberProto::OnIqResultPrivacyList(HXML iqNode, CJabberIqInfo*) mir_cslockfull lck(m_privacyListManager.m_cs); CPrivacyList *pList = m_privacyListManager.FindList(szListName); - if (pList == NULL) { + if (pList == nullptr) { m_privacyListManager.AddList(szListName); pList = m_privacyListManager.FindList(szListName); - if (pList == NULL) + if (pList == nullptr) return; } HXML item; - for (int i = 1; (item = XmlGetNthChild(list, L"item", i)) != NULL; i++) { + for (int i = 1; (item = XmlGetNthChild(list, L"item", i)) != nullptr; i++) { const wchar_t *itemType = XmlGetAttrValue(item, L"type"); PrivacyListRuleType nItemType = Else; if (itemType) { @@ -147,11 +147,11 @@ CPrivacyList* GetSelectedList(HWND hDlg) { LRESULT nCurSel = SendDlgItemMessage(hDlg, IDC_LB_LISTS, LB_GETCURSEL, 0, 0); if (nCurSel == LB_ERR) - return NULL; + return nullptr; LRESULT nItemData = SendDlgItemMessage(hDlg, IDC_LB_LISTS, LB_GETITEMDATA, nCurSel, 0); if (nItemData == LB_ERR || nItemData == 0) - return NULL; + return nullptr; return (CPrivacyList*)nItemData; } @@ -160,11 +160,11 @@ CPrivacyListRule* GetSelectedRule(HWND hDlg) { LRESULT nCurSel = SendDlgItemMessage(hDlg, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0); if (nCurSel == LB_ERR) - return NULL; + return nullptr; LRESULT nItemData = SendDlgItemMessage(hDlg, IDC_PL_RULES_LIST, LB_GETITEMDATA, nCurSel, 0); if (nItemData == LB_ERR || nItemData == 0) - return NULL; + return nullptr; return (CPrivacyListRule*)nItemData; } @@ -176,11 +176,11 @@ void CJabberProto::OnIqResultPrivacyListActive(HXML iqNode, CJabberIqInfo *pInfo if (m_pDlgPrivacyLists) EnableWindow(GetDlgItem(m_pDlgPrivacyLists->GetHwnd(), IDC_ACTIVATE), TRUE); - if (iqNode == NULL) + if (iqNode == nullptr) return; const wchar_t *type = XmlGetAttrValue(iqNode, L"type"); - if (type == NULL) + if (type == nullptr) return; CMStringW szText; @@ -192,7 +192,7 @@ void CJabberProto::OnIqResultPrivacyListActive(HXML iqNode, CJabberIqInfo *pInfo szText.Format( TranslateT("Privacy list %s set as active"), pList->GetListName()); } else { - m_privacyListManager.SetActiveListName(NULL); + m_privacyListManager.SetActiveListName(nullptr); szText.Format( TranslateT("Active privacy list successfully declined")); } } @@ -200,7 +200,7 @@ void CJabberProto::OnIqResultPrivacyListActive(HXML iqNode, CJabberIqInfo *pInfo if (m_pDlgPrivacyLists) { m_pDlgPrivacyLists->SetStatusText(szText); - RedrawWindow(GetDlgItem(m_pDlgPrivacyLists->GetHwnd(), IDC_LB_LISTS), NULL, NULL, RDW_INVALIDATE); + RedrawWindow(GetDlgItem(m_pDlgPrivacyLists->GetHwnd(), IDC_LB_LISTS), nullptr, nullptr, RDW_INVALIDATE); } BuildPrivacyListsMenu(true); @@ -211,11 +211,11 @@ void CJabberProto::OnIqResultPrivacyListDefault(HXML iqNode, CJabberIqInfo *pInf if (m_pDlgPrivacyLists) EnableWindow(GetDlgItem(m_pDlgPrivacyLists->GetHwnd(), IDC_SET_DEFAULT), TRUE); - if (iqNode == NULL) + if (iqNode == nullptr) return; const wchar_t *type = XmlGetAttrValue(iqNode, L"type"); - if (type == NULL) + if (type == nullptr) return; wchar_t szText[ 512 ]; @@ -229,7 +229,7 @@ void CJabberProto::OnIqResultPrivacyListDefault(HXML iqNode, CJabberIqInfo *pInf mir_snwprintf(szText, TranslateT("Privacy list %s set as default"), pList->GetListName()); } else { - m_privacyListManager.SetDefaultListName(NULL); + m_privacyListManager.SetDefaultListName(nullptr); mir_snwprintf(szText, TranslateT("Default privacy list successfully declined")); } } @@ -238,7 +238,7 @@ void CJabberProto::OnIqResultPrivacyListDefault(HXML iqNode, CJabberIqInfo *pInf if (m_pDlgPrivacyLists) { m_pDlgPrivacyLists->SetStatusText(szText); - RedrawWindow(GetDlgItem(m_pDlgPrivacyLists->GetHwnd(), IDC_LB_LISTS), NULL, NULL, RDW_INVALIDATE); + RedrawWindow(GetDlgItem(m_pDlgPrivacyLists->GetHwnd(), IDC_LB_LISTS), nullptr, nullptr, RDW_INVALIDATE); } } @@ -248,7 +248,7 @@ void CJabberProto::OnIqResultPrivacyLists(HXML iqNode, CJabberIqInfo *pInfo) return; HXML query = XmlGetChild(iqNode, "query"); - if (query == NULL) + if (query == nullptr) return; if (m_ThreadInfo) @@ -259,7 +259,7 @@ void CJabberProto::OnIqResultPrivacyLists(HXML iqNode, CJabberIqInfo *pInfo) for (int i = 1; ; i++) { HXML list = XmlGetNthChild(query, L"list", i); - if (list == NULL) + if (list == nullptr) break; const wchar_t *listName = XmlGetAttrValue(list, L"name"); @@ -274,13 +274,13 @@ void CJabberProto::OnIqResultPrivacyLists(HXML iqNode, CJabberIqInfo *pInfo) } } - const wchar_t *szName = NULL; + const wchar_t *szName = nullptr; HXML node = XmlGetChild(query , "active"); if (node) szName = XmlGetAttrValue(node, L"name"); m_privacyListManager.SetActiveListName(szName); - szName = NULL; + szName = nullptr; node = XmlGetChild(query , "default"); if (node) szName = XmlGetAttrValue(node, L"name"); @@ -424,7 +424,7 @@ public: { for (MCONTACT hContact = db_find_first(m_proto->m_szModuleName); hContact; hContact = db_find_next(hContact, m_proto->m_szModuleName)) { ptrW jid( m_proto->getWStringA(hContact, "jid")); - if (jid != NULL) + if (jid != nullptr) SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_ADDSTRING, 0, jid); } @@ -453,7 +453,7 @@ public: SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_RESETCONTENT, 0, 0); { wchar_t *grpName; - for (int i=1; (grpName = Clist_GroupGetName(i, NULL)) != NULL; i++) + for (int i=1; (grpName = Clist_GroupGetName(i, nullptr)) != nullptr; i++) SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_ADDSTRING, 0, (LPARAM)grpName); } @@ -511,7 +511,7 @@ public: break; default: - m_pRule->SetValue(NULL); + m_pRule->SetValue(nullptr); break; } @@ -549,7 +549,7 @@ public: IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_QUERY, STM_SETICON, 0, 0)); IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEIN, STM_SETICON, 0, 0)); IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEOUT, STM_SETICON, 0, 0)); - m_proto->m_hwndPrivacyRule = NULL; + m_proto->m_hwndPrivacyRule = nullptr; } }; @@ -616,7 +616,7 @@ protected: void CListResetIcons(HWND hwndList, HANDLE hItem, bool hide=false); void CListSetupIcons(HWND hwndList, HANDLE hItem, int iSlot, DWORD dwProcess, BOOL bAction); HANDLE CListAddContact(HWND hwndList, wchar_t *jid); - void CListApplyList(HWND hwndList, CPrivacyList *pList = NULL); + void CListApplyList(HWND hwndList, CPrivacyList *pList = nullptr); DWORD CListGetPackets(HWND hwndList, HANDLE hItem, bool bAction); void CListBuildList(HWND hwndList, CPrivacyList *pList); @@ -713,7 +713,7 @@ int CJabberDlgPrivacyLists::idAdvancedControls[] = }; CJabberDlgPrivacyLists::CJabberDlgPrivacyLists(CJabberProto *proto): - CSuper(proto, IDD_PRIVACY_LISTS, NULL), + CSuper(proto, IDD_PRIVACY_LISTS, nullptr), m_btnSimple(this, IDC_BTN_SIMPLE, proto->LoadIconEx("group"), LPGEN("Simple mode")), m_btnAdvanced(this, IDC_BTN_ADVANCED, proto->LoadIconEx("sd_view_list"), LPGEN("Advanced mode")), m_btnAddJid(this, IDC_ADDJID, proto->LoadIconEx("addroster"), LPGEN("Add JID")), @@ -832,7 +832,7 @@ void CJabberDlgPrivacyLists::OnInitDialog() SetStatusText(TranslateT("Loading...")); - Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "plistsWnd_sz"); + Utils_RestoreWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "plistsWnd_sz"); } void CJabberDlgPrivacyLists::OnClose() @@ -846,7 +846,7 @@ void CJabberDlgPrivacyLists::OnClose() void CJabberDlgPrivacyLists::OnDestroy() { - m_proto->m_pDlgPrivacyLists = NULL; + m_proto->m_pDlgPrivacyLists = nullptr; // Wipe all data and query lists without contents m_proto->m_privacyListManager.RemoveAllLists(); @@ -858,7 +858,7 @@ void CJabberDlgPrivacyLists::OnDestroy() m_proto->setByte("plistsWnd_simpleMode", IsDlgButtonChecked(m_hwnd, IDC_BTN_SIMPLE)); - Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "plistsWnd_sz"); + Utils_SaveWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "plistsWnd_sz"); CSuper::OnDestroy(); } @@ -866,7 +866,7 @@ void CJabberDlgPrivacyLists::OnDestroy() void CJabberDlgPrivacyLists::OnProtoRefresh(WPARAM, LPARAM) { LRESULT sel = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETCURSEL, 0, 0); - wchar_t *szCurrentSelectedList = NULL; + wchar_t *szCurrentSelectedList = nullptr; if (sel != LB_ERR) { LRESULT len = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETTEXTLEN, sel, 0) + 1; szCurrentSelectedList = (wchar_t *)mir_alloc(len * sizeof(wchar_t)); @@ -959,7 +959,7 @@ BOOL CJabberDlgPrivacyLists::OnWmDrawItem(UINT, WPARAM, LPARAM lParam) for (i=0; i < _countof(drawItems); i++) { DrawIconEx(lpdis->hDC, rc.left, (rc.top+rc.bottom-16)/2, m_proto->LoadIconEx(drawItems[i].icon), - 16, 16, 0, NULL, DI_NORMAL); + 16, 16, 0, nullptr, DI_NORMAL); rc.left += 18; DrawNextRulePart(lpdis->hDC, clText, drawItems[i].text, &rc); rc.left += 5; @@ -1189,12 +1189,12 @@ void CJabberDlgPrivacyLists::DrawRulesList(LPDRAWITEMSTRUCT lpdis) } DrawIconEx(lpdis->hDC, lpdis->rcItem.left+4, (lpdis->rcItem.top+lpdis->rcItem.bottom-16)/2, - m_proto->LoadIconEx("main"), 16, 16, 0, NULL, DI_NORMAL); + m_proto->LoadIconEx("main"), 16, 16, 0, nullptr, DI_NORMAL); if (pRule) DrawIconEx(lpdis->hDC, lpdis->rcItem.left+4, (lpdis->rcItem.top+lpdis->rcItem.bottom-16)/2, m_proto->LoadIconEx(pRule->GetAction() ? "disco_ok" : "disco_fail"), - 16, 16, 0, NULL, DI_NORMAL); + 16, 16, 0, nullptr, DI_NORMAL); if (lpdis->itemState & ODS_FOCUS) { LRESULT sel = SendDlgItemMessage(m_hwnd, lpdis->CtlID, LB_GETCURSEL, 0, 0); @@ -1253,7 +1253,7 @@ void CJabberDlgPrivacyLists::DrawLists(LPDRAWITEMSTRUCT lpdis) szName = pList->GetListName(); } - HFONT hfnt = NULL; + HFONT hfnt = nullptr; if (bActive) { LOGFONT lf; GetObject(GetCurrentObject(lpdis->hDC, OBJ_FONT), sizeof(lf), &lf); @@ -1272,12 +1272,12 @@ void CJabberDlgPrivacyLists::DrawLists(LPDRAWITEMSTRUCT lpdis) DrawIconEx(lpdis->hDC, lpdis->rcItem.right-16-4, (lpdis->rcItem.top+lpdis->rcItem.bottom-16)/2, m_proto->LoadIconEx(bActive ? "pl_list_active" : "pl_list_any"), - 16, 16, 0, NULL, DI_NORMAL); + 16, 16, 0, nullptr, DI_NORMAL); if (bDefault) DrawIconEx(lpdis->hDC, lpdis->rcItem.right-16-4, (lpdis->rcItem.top+lpdis->rcItem.bottom-16)/2, m_proto->LoadIconEx("disco_ok"), - 16, 16, 0, NULL, DI_NORMAL); + 16, 16, 0, nullptr, DI_NORMAL); if (hfnt) DeleteObject(SelectObject(lpdis->hDC, hfnt)); @@ -1291,7 +1291,7 @@ void CJabberDlgPrivacyLists::DrawLists(LPDRAWITEMSTRUCT lpdis) void CJabberDlgPrivacyLists::CListResetOptions(HWND) { - m_clcClist.SetBkBitmap(0, NULL); + m_clcClist.SetBkBitmap(0, nullptr); m_clcClist.SetBkColor(GetSysColor(COLOR_WINDOW)); m_clcClist.SetGreyoutFlags(0); m_clcClist.SetLeftMargin(4); @@ -1355,7 +1355,7 @@ void CJabberDlgPrivacyLists::CListApplyList(HWND hwndList, CPrivacyList *pList) CListResetIcons(hwndList, clc_info.hItemSubTo, bHideIcons); // group handles start with 1 (0 is "root") - for (MGROUP iGroup = 1; Clist_GroupGetName(iGroup, NULL) != NULL; iGroup++) { + for (MGROUP iGroup = 1; Clist_GroupGetName(iGroup, nullptr) != nullptr; iGroup++) { HANDLE hItem = m_clcClist.FindGroup(iGroup); if (hItem) CListResetIcons(hwndList, hItem, bHideIcons); @@ -1445,7 +1445,7 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList) DWORD dwPackets = 0; HANDLE hItem; - wchar_t *szJid = NULL; + wchar_t *szJid = nullptr; pList->RemoveAllRules(); @@ -1463,8 +1463,8 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList) hItem = m_clcClist.FindContact(hContact); ptrW jid( m_proto->getWStringA(hContact, "jid")); - if (jid == NULL) - if ((jid = m_proto->getWStringA(hContact, "ChatRoomID")) == NULL) + if (jid == nullptr) + if ((jid = m_proto->getWStringA(hContact, "ChatRoomID")) == nullptr) continue; if (dwPackets = CListGetPackets(hwndList, hItem, true)) @@ -1475,7 +1475,7 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList) // group handles start with 1 (0 is "root") wchar_t *grpName; - for (MGROUP iGroup = 1; (grpName = Clist_GroupGetName(iGroup, NULL)) != NULL; iGroup++) { + for (MGROUP iGroup = 1; (grpName = Clist_GroupGetName(iGroup, nullptr)) != nullptr; iGroup++) { hItem = m_clcClist.FindGroup(iGroup); if (dwPackets = CListGetPackets(hwndList, hItem, true)) pList->AddRule(Group, grpName, TRUE, dwOrder++, dwPackets); @@ -1512,7 +1512,7 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList) pList->AddRule(Subscription, szJid, FALSE, dwOrder++, dwPackets); hItem = clc_info.hItemDefault; - szJid = NULL; + szJid = nullptr; if (dwPackets = CListGetPackets(hwndList, hItem, true)) pList->AddRule(Else, szJid, TRUE, dwOrder++, dwPackets); if (dwPackets = CListGetPackets(hwndList, hItem, false)) @@ -1656,7 +1656,7 @@ void CJabberDlgPrivacyLists::btnActivate_OnClick(CCtrlButton *) } EnableWindow(GetDlgItem(m_hwnd, IDC_ACTIVATE), FALSE); SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ACTIVATE), GWLP_USERDATA, (LONG_PTR)pList); - XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList)); + XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, nullptr, 0, -1, pList)); HXML query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS); HXML active = query << XCHILD(L"active"); if (pList) @@ -1683,7 +1683,7 @@ void CJabberDlgPrivacyLists::btnSetDefault_OnClick(CCtrlButton *) EnableWindow(GetDlgItem(m_hwnd, IDC_SET_DEFAULT), FALSE); SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_SET_DEFAULT), GWLP_USERDATA, (LONG_PTR)pList); - XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListDefault, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList)); + XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListDefault, JABBER_IQ_TYPE_SET, nullptr, 0, -1, pList)); HXML query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS); HXML defaultTag = query << XCHILD(L"default"); if (pList) @@ -1706,7 +1706,7 @@ void CJabberDlgPrivacyLists::lbLists_OnSelChange(CCtrlListBox *) if (nErr == 0) { if (IsWindowVisible(GetDlgItem(m_hwnd, IDC_CLIST))) { CListBuildList(GetDlgItem(m_hwnd, IDC_CLIST), clc_info.pList); - CListApplyList(GetDlgItem(m_hwnd, IDC_CLIST), NULL); + CListApplyList(GetDlgItem(m_hwnd, IDC_CLIST), nullptr); } else { EnableWindow(GetDlgItem(m_hwnd, IDC_PL_RULES_LIST), FALSE); @@ -1841,7 +1841,7 @@ void CJabberDlgPrivacyLists::btnAddList_OnClick(CCtrlButton*) mir_cslockfull lck(m_proto->m_privacyListManager.m_cs); CPrivacyList *pList = m_proto->m_privacyListManager.FindList(dlgPrivacyAddList.szLine); - if (pList == NULL) { + if (pList == nullptr) { m_proto->m_privacyListManager.AddList(dlgPrivacyAddList.szLine); pList = m_proto->m_privacyListManager.FindList(dlgPrivacyAddList.szLine); if (pList) { @@ -1897,7 +1897,7 @@ void CJabberDlgPrivacyLists::btnApply_OnClick(CCtrlButton *) if (IsWindowVisible(GetDlgItem(m_hwnd, IDC_CLIST))) CListBuildList(GetDlgItem(m_hwnd, IDC_CLIST), clc_info.pList); - CPrivacyListModifyUserParam *pUserData = NULL; + CPrivacyListModifyUserParam *pUserData = nullptr; CPrivacyList *pList = m_proto->m_privacyListManager.GetFirstList(); while (pList) { if (pList->IsModified()) { @@ -1906,7 +1906,7 @@ void CJabberDlgPrivacyLists::btnApply_OnClick(CCtrlButton *) pList->SetDeleted(); if (pList->IsDeleted()) { pList->RemoveAllRules(); - pRule = NULL; + pRule = nullptr; } pList->SetModified(FALSE); @@ -1915,7 +1915,7 @@ void CJabberDlgPrivacyLists::btnApply_OnClick(CCtrlButton *) pUserData->m_dwCount++; - XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListModify, JABBER_IQ_TYPE_SET, NULL, 0, -1, pUserData)); + XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListModify, JABBER_IQ_TYPE_SET, nullptr, 0, -1, pUserData)); HXML query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS); HXML listTag = query << XCHILD(L"list") << XATTR(L"name", pList->GetListName()); @@ -1990,7 +1990,7 @@ void CJabberDlgPrivacyLists::clcClist_OnClick(CCtrlClc::TEventInfo *evt) DWORD hitFlags; HANDLE hItem = m_clcClist.HitTest(evt->info->pt.x, evt->info->pt.y, &hitFlags); - if (hItem == NULL || !(hitFlags & CLCHT_ONITEMEXTRA)) + if (hItem == nullptr || !(hitFlags & CLCHT_ONITEMEXTRA)) return; int iImage = m_clcClist.GetExtraImage(hItem, evt->info->iColumn); @@ -2067,14 +2067,14 @@ void CJabberProto::QueryPrivacyLists(ThreadData *pThreadInfo) INT_PTR __cdecl CJabberProto::menuSetPrivacyList(WPARAM, LPARAM, LPARAM iList) { mir_cslockfull lck(m_privacyListManager.m_cs); - CPrivacyList *pList = NULL; + CPrivacyList *pList = nullptr; if (iList) { pList = m_privacyListManager.GetFirstList(); for (int i = 1; pList && (i < iList); i++) pList = pList->GetNext(); } - XmlNodeIq iq(AddIQ(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList)); + XmlNodeIq iq(AddIQ(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, nullptr, 0, -1, pList)); HXML query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS); HXML active = query << XCHILD(L"active"); if (pList) diff --git a/protocols/JabberG/src/jabber_privacy.h b/protocols/JabberG/src/jabber_privacy.h index a48a9b9d3f..a9ea553ce9 100644 --- a/protocols/JabberG/src/jabber_privacy.h +++ b/protocols/JabberG/src/jabber_privacy.h @@ -66,7 +66,7 @@ public: m_bAction = bAction; m_dwOrder = dwOrder; m_dwPackets = dwPackets; - m_pNext = NULL; + m_pNext = nullptr; }; ~CPrivacyListRule() { @@ -157,8 +157,8 @@ public: { m_proto = ppro; m_szListName = mir_wstrdup(szListName); - m_pRules = NULL; - m_pNext = NULL; + m_pRules = nullptr; + m_pNext = nullptr; m_bLoaded = FALSE; m_bModified = FALSE; m_bDeleted = FALSE; @@ -174,7 +174,7 @@ public: { if (m_pRules) delete m_pRules; - m_pRules = NULL; + m_pRules = nullptr; return TRUE; } __inline wchar_t* GetListName() @@ -217,7 +217,7 @@ public: if (m_pRules == pRuleToRemove) { m_pRules = m_pRules->GetNext(); - pRuleToRemove->SetNext(NULL); + pRuleToRemove->SetNext(nullptr); delete pRuleToRemove; return TRUE; } @@ -226,7 +226,7 @@ public: while (pRule->GetNext()) { if (pRule->GetNext() == pRuleToRemove) { pRule->SetNext(pRule->GetNext()->GetNext()); - pRuleToRemove->SetNext(NULL); + pRuleToRemove->SetNext(nullptr); delete pRuleToRemove; return TRUE; } @@ -285,7 +285,7 @@ public: pRules[ i ]->SetOrder(dwOrder); dwOrder += 10; } - *ppPtr = NULL; + *ppPtr = nullptr; mir_free(pRules); return TRUE; @@ -331,9 +331,9 @@ public: CPrivacyListManager(CJabberProto *ppro) { m_proto = ppro; - m_szActiveListName = NULL; - m_szDefaultListName = NULL; - m_pLists = NULL; + m_szActiveListName = nullptr; + m_szDefaultListName = nullptr; + m_pLists = nullptr; m_bModified = FALSE; }; ~CPrivacyListManager() @@ -362,7 +362,7 @@ public: { if (m_pLists) delete m_pLists; - m_pLists = NULL; + m_pLists = nullptr; return TRUE; } CPrivacyList* FindList(const wchar_t *szListName) @@ -373,7 +373,7 @@ public: return pList; pList = pList->GetNext(); } - return NULL; + return nullptr; } CPrivacyList* GetFirstList() { diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 8f72686d41..3194c2a93e 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -73,7 +73,7 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) : m_lstJabberFeatCapPairsDynamic(2), m_uEnabledFeatCapsDynamic(0) { - m_szXmlStreamToBeInitialized = NULL; + m_szXmlStreamToBeInitialized = nullptr; debugLogA("Setting protocol/module name to '%s'", m_szModuleName); @@ -153,7 +153,7 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) : db_set_resident(m_szModuleName, "Auth"); db_set_resident(m_szModuleName, "Grant"); - if ((m_tszSelectedLang = getWStringA("XmlLang")) == NULL) + if ((m_tszSelectedLang = getWStringA("XmlLang")) == nullptr) m_tszSelectedLang = mir_wstrdup(L"en"); } @@ -251,11 +251,11 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM) if (getByte(hContact, "IsTransport", 0)) { ptrW jid(getWStringA(hContact, "jid")); - if (jid == NULL) + if (jid == nullptr) continue; wchar_t *resourcepos = wcschr(jid, '/'); - if (resourcepos != NULL) + if (resourcepos != nullptr) *resourcepos = '\0'; m_lstTransports.insert(mir_wstrdup(jid)); @@ -305,7 +305,7 @@ MCONTACT CJabberProto::AddToListByJID(const wchar_t *newJid, DWORD flags) { debugLogW(L"AddToListByJID jid = %s", newJid); - MCONTACT hContact = DBCreateContact(newJid, NULL, true, false); + MCONTACT hContact = DBCreateContact(newJid, nullptr, true, false); if (flags & PALF_TEMPORARY) db_set_b(hContact, "CList", "Hidden", 1); @@ -314,8 +314,8 @@ MCONTACT CJabberProto::AddToListByJID(const wchar_t *newJid, DWORD flags) MCONTACT CJabberProto::AddToList(int flags, PROTOSEARCHRESULT* psr) { - if (psr->cbSize != sizeof(PROTOSEARCHRESULT) && psr->id.w == NULL) - return NULL; + if (psr->cbSize != sizeof(PROTOSEARCHRESULT) && psr->id.w == nullptr) + return 0; return AddToListByJID(psr->id.w, flags); } @@ -326,15 +326,15 @@ MCONTACT __cdecl CJabberProto::AddToListByEvent(int flags, int /*iContact*/, MEV DBEVENTINFO dbei = {}; if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == (DWORD)(-1)) - return NULL; - if ((dbei.pBlob = (PBYTE)alloca(dbei.cbBlob)) == NULL) - return NULL; + return 0; + if ((dbei.pBlob = (PBYTE)alloca(dbei.cbBlob)) == nullptr) + return 0; if (db_event_get(hDbEvent, &dbei)) - return NULL; + return 0; if (mir_strcmp(dbei.szModule, m_szModuleName)) - return NULL; + return 0; if (dbei.eventType != EVENTTYPE_AUTHREQUEST) - return NULL; + return 0; DB_AUTH_BLOB blob(dbei.pBlob); return AddToListByJID(ptrW(dbei.getString(blob.get_email())), flags); @@ -351,7 +351,7 @@ int CJabberProto::Authorize(MEVENT hDbEvent) DBEVENTINFO dbei = {}; if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == (DWORD)(-1)) return 1; - if ((dbei.pBlob = (PBYTE)alloca(dbei.cbBlob)) == NULL) + if ((dbei.pBlob = (PBYTE)alloca(dbei.cbBlob)) == nullptr) return 1; if (db_event_get(hDbEvent, &dbei)) return 1; @@ -370,7 +370,7 @@ int CJabberProto::Authorize(MEVENT hDbEvent) // Automatically add this user to my roster if option is enabled if (m_options.AutoAdd == TRUE) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, newJid); - if (item == NULL || (item->subscription != SUB_BOTH && item->subscription != SUB_TO)) { + if (item == nullptr || (item->subscription != SUB_BOTH && item->subscription != SUB_TO)) { debugLogW(L"Try adding contact automatically jid = %s", blob.get_email()); if (MCONTACT hContact = AddToListByJID(newJid, 0)) { // Trigger actual add by removing the "NotOnList" added by AddToListByJID() @@ -399,7 +399,7 @@ int CJabberProto::AuthDeny(MEVENT hDbEvent, const wchar_t*) return 1; mir_ptr pBlob((PBYTE)mir_alloc(dbei.cbBlob)); - if ((dbei.pBlob = pBlob) == NULL) + if ((dbei.pBlob = pBlob) == nullptr) return 1; if (db_event_get(hDbEvent, &dbei)) @@ -466,13 +466,13 @@ int __cdecl CJabberProto::FileCancel(MCONTACT, HANDLE hTransfer) debugLogA("Closing ft->s = %d", ft->s); ft->state = FT_ERROR; Netlib_CloseHandle(ft->s); - ft->s = NULL; - if (ft->hFileEvent != NULL) { + ft->s = nullptr; + if (ft->hFileEvent != nullptr) { hEvent = ft->hFileEvent; - ft->hFileEvent = NULL; + ft->hFileEvent = nullptr; SetEvent(hEvent); } - debugLogA("ft->s is now NULL, ft->state is now FT_ERROR"); + debugLogA("ft->s is now nullptr, ft->state is now FT_ERROR"); } } else FtCancel(ft); @@ -513,7 +513,7 @@ int __cdecl CJabberProto::FileDeny(MCONTACT, HANDLE hTransfer, const wchar_t *) int __cdecl CJabberProto::FileResume(HANDLE hTransfer, int *action, const wchar_t **szFilename) { filetransfer *ft = (filetransfer*)hTransfer; - if (!m_bJabberOnline || ft == NULL) + if (!m_bJabberOnline || ft == nullptr) return 1; if (*action == FILERESUME_RENAME) @@ -564,7 +564,7 @@ int __cdecl CJabberProto::GetInfo(MCONTACT hContact, int /*infoType*/) return 1; JabberStripJid(jid, szBareJid, _countof(szBareJid)); - bool bUseResource = ListGetItemPtr(LIST_CHATROOM, szBareJid) != NULL; + bool bUseResource = ListGetItemPtr(LIST_CHATROOM, szBareJid) != nullptr; if (m_ThreadInfo) { m_ThreadInfo->send( @@ -576,14 +576,14 @@ int __cdecl CJabberProto::GetInfo(MCONTACT hContact, int /*infoType*/) iq2 << XQUERY(JABBER_FEAT_LAST_ACTIVITY); m_ThreadInfo->send(iq2); - JABBER_LIST_ITEM *item = NULL; + JABBER_LIST_ITEM *item = nullptr; - if ((item = ListGetItemPtr(LIST_VCARD_TEMP, jid)) == NULL) + if ((item = ListGetItemPtr(LIST_VCARD_TEMP, jid)) == nullptr) item = ListGetItemPtr(LIST_ROSTER, jid); - if (item == NULL) { + if (item == nullptr) { bool bHasResource = mir_wstrcmp(jid, szBareJid) != 0; - JABBER_LIST_ITEM *tmpItem = NULL; + JABBER_LIST_ITEM *tmpItem = nullptr; if (bHasResource && (tmpItem = ListGetItemPtr(LIST_CHATROOM, szBareJid))) { pResourceStatus him(tmpItem->findResource(szBareJid+mir_wstrlen(szBareJid)+1)); if (him) { @@ -594,7 +594,7 @@ int __cdecl CJabberProto::GetInfo(MCONTACT hContact, int /*infoType*/) else item = ListAdd(LIST_VCARD_TEMP, jid, hContact); } - if (item != NULL) { + if (item != nullptr) { if (item->arResources.getCount()) { for (int i = 0; i < item->arResources.getCount(); i++) { pResourceStatus r(item->arResources[i]); @@ -643,8 +643,8 @@ void __cdecl CJabberProto::BasicSearchThread(JABBER_SEARCH_BASIC *jsb) psr.lastName.w = L""; psr.id.w = jsb->jid; - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)jsb->hSearch, (LPARAM)&psr); - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)jsb->hSearch, 0); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)jsb->hSearch, (LPARAM)&psr); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)jsb->hSearch, 0); mir_free(jsb); } @@ -653,20 +653,20 @@ HANDLE __cdecl CJabberProto::SearchBasic(const wchar_t *szJid) debugLogW(L"JabberBasicSearch called with lParam = '%s'", szJid); JABBER_SEARCH_BASIC *jsb; - if (!m_bJabberOnline || (jsb = (JABBER_SEARCH_BASIC*)mir_alloc(sizeof(JABBER_SEARCH_BASIC))) == NULL) + if (!m_bJabberOnline || (jsb = (JABBER_SEARCH_BASIC*)mir_alloc(sizeof(JABBER_SEARCH_BASIC))) == nullptr) return 0; - if (wcschr(szJid, '@') == NULL) { + if (wcschr(szJid, '@') == nullptr) { wchar_t *szServer = mir_a2u(m_ThreadInfo->conn.server); const wchar_t *p = wcsstr(szJid, szServer); - if (p == NULL) { + if (p == nullptr) { bool numericjid = true; for (const wchar_t *i = szJid; *i && numericjid; i++) numericjid = (*i >= '0') && (*i <= '9'); mir_free(szServer); - szServer = getWStringA(NULL, "LoginServer"); - if (szServer == NULL) + szServer = getWStringA(0, "LoginServer"); + if (szServer == nullptr) szServer = mir_wstrdup(L"jabber.org"); else if (numericjid && !mir_wstrcmpi(szServer, L"S.ms")) { mir_free(szServer); @@ -690,7 +690,7 @@ HANDLE __cdecl CJabberProto::SearchBasic(const wchar_t *szJid) HANDLE __cdecl CJabberProto::SearchByEmail(const wchar_t *email) { - if (!m_bJabberOnline || email == NULL) + if (!m_bJabberOnline || email == nullptr) return 0; ptrA szServerName(getStringA("Jud")); @@ -707,7 +707,7 @@ HANDLE __cdecl CJabberProto::SearchByEmail(const wchar_t *email) HANDLE __cdecl CJabberProto::SearchByName(const wchar_t *nick, const wchar_t *firstName, const wchar_t *lastName) { if (!m_bJabberOnline) - return NULL; + return nullptr; BOOL bIsExtFormat = m_options.ExtendedSearch; @@ -781,7 +781,7 @@ int __cdecl CJabberProto::SendContacts(MCONTACT hContact, int, int nContacts, MC for (int i = 0; i < nContacts; i++) { ptrW jid(getWStringA(hContactsList[i], "jid")); - if (jid != NULL) + if (jid != nullptr) x << XCHILD(L"item") << XATTR(L"action", L"add") << XATTR(L"jid", jid); } @@ -801,16 +801,16 @@ HANDLE __cdecl CJabberProto::SendFile(MCONTACT hContact, const wchar_t *szDescri return 0; ptrW jid(getWStringA(hContact, "jid")); - if (jid == NULL) + if (jid == nullptr) return 0; struct _stati64 statbuf; JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid); - if (item == NULL) + if (item == nullptr) return 0; // Check if another file transfer session request is pending (waiting for disco result) - if (item->ft != NULL) + if (item->ft != nullptr) return 0; JabberCapsBits jcb = GetResourceCapabilites(item->jid, true); @@ -842,7 +842,7 @@ HANDLE __cdecl CJabberProto::SendFile(MCONTACT hContact, const wchar_t *szDescri filetransfer *ft = new filetransfer(this); ft->std.hContact = hContact; - while (ppszFiles[ft->std.totalFiles] != NULL) + while (ppszFiles[ft->std.totalFiles] != nullptr) ft->std.totalFiles++; ft->std.ptszFiles = (wchar_t**)mir_calloc(sizeof(wchar_t*)* ft->std.totalFiles); @@ -861,7 +861,7 @@ HANDLE __cdecl CJabberProto::SendFile(MCONTACT hContact, const wchar_t *szDescri } if (j == 0) { delete ft; - return NULL; + return nullptr; } ft->std.tszCurrentFile = mir_wstrdup(ppszFiles[0]); @@ -939,11 +939,11 @@ int __cdecl CJabberProto::SendMsg(MCONTACT hContact, int unused_unknown, const c wchar_t *msg; mir_utf8decode(NEWSTR_ALLOCA(pszSrc), &msg); - if (msg == NULL) + if (msg == nullptr) return 0; wchar_t *msgType; - if (ListGetItemPtr(LIST_CHATROOM, szClientJid) && wcschr(szClientJid, '/') == NULL) + if (ListGetItemPtr(LIST_CHATROOM, szClientJid) && wcschr(szClientJid, '/') == nullptr) msgType = L"groupchat"; else msgType = L"chat"; @@ -1037,7 +1037,7 @@ int __cdecl CJabberProto::SetApparentMode(MCONTACT hContact, int mode) return 0; ptrW jid(getWStringA(hContact, "jid")); - if (jid == NULL) + if (jid == nullptr) return 0; switch (mode) { @@ -1047,13 +1047,13 @@ int __cdecl CJabberProto::SetApparentMode(MCONTACT hContact, int mode) break; case ID_STATUS_OFFLINE: if (m_iStatus != ID_STATUS_INVISIBLE || oldMode == ID_STATUS_ONLINE) - SendPresenceTo(ID_STATUS_INVISIBLE, jid, NULL); + SendPresenceTo(ID_STATUS_INVISIBLE, jid, nullptr); break; case 0: if (oldMode == ID_STATUS_ONLINE && m_iStatus == ID_STATUS_INVISIBLE) - SendPresenceTo(ID_STATUS_INVISIBLE, jid, NULL); + SendPresenceTo(ID_STATUS_INVISIBLE, jid, nullptr); else if (oldMode == ID_STATUS_OFFLINE && m_iStatus != ID_STATUS_INVISIBLE) - SendPresenceTo(m_iStatus, jid, NULL); + SendPresenceTo(m_iStatus, jid, nullptr); break; } @@ -1082,19 +1082,19 @@ int __cdecl CJabberProto::SetStatus(int iNewStatus) } m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; - ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); + ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); } else if (!m_ThreadInfo && !IsStatusConnecting(m_iStatus)) { m_iStatus = ID_STATUS_CONNECTING; - ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); - ForkThread((MyThreadFunc)&CJabberProto::ServerThread, NULL); + ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); + ForkThread((MyThreadFunc)&CJabberProto::ServerThread, nullptr); RebuildInfoFrame(); } else if (m_bJabberOnline) SetServerStatus(iNewStatus); else - ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); + ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); return 0; } @@ -1109,9 +1109,9 @@ void __cdecl CJabberProto::GetAwayMsgThread(void *param) MCONTACT hContact = (DWORD_PTR)param; ptrW jid(getWStringA(hContact, "jid")); - if (jid != NULL) { + if (jid != nullptr) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid); - if (item != NULL) { + if (item != nullptr) { if (item->arResources.getCount() > 0) { debugLogA("arResources.getCount() > 0"); int msgCount = 0; @@ -1144,7 +1144,7 @@ void __cdecl CJabberProto::GetAwayMsgThread(void *param) } wchar_t *tszStatusMsg = item->getTemp()->m_tszStatusMessage; - if (tszStatusMsg != NULL) { + if (tszStatusMsg != nullptr) { ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)tszStatusMsg); return; } @@ -1202,7 +1202,7 @@ int __cdecl CJabberProto::SetAwayMsg(int status, const wchar_t *msg) return 1; } - if ((*szMsg == NULL && msg == NULL) || (*szMsg != NULL && msg != NULL && !mir_wstrcmp(*szMsg, msg))) + if ((*szMsg == nullptr && msg == nullptr) || (*szMsg != nullptr && msg != nullptr && !mir_wstrcmp(*szMsg, msg))) return 0; // Message is the same, no update needed // Update with the new mode message @@ -1227,7 +1227,7 @@ int __cdecl CJabberProto::UserIsTyping(MCONTACT hContact, int type) return 0; JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, szClientJid); - if (item == NULL) + if (item == nullptr) return 0; JabberCapsBits jcb = GetResourceCapabilites(szClientJid, true); @@ -1251,7 +1251,7 @@ int __cdecl CJabberProto::UserIsTyping(MCONTACT hContact, int type) } else if (jcb & JABBER_CAPS_MESSAGE_EVENTS) { HXML x = m << XCHILDNS(L"x", JABBER_FEAT_MESSAGE_EVENTS); - if (item->messageEventIdStr != NULL) + if (item->messageEventIdStr != nullptr) x << XCHILD(L"id", item->messageEventIdStr); switch (type) { @@ -1283,7 +1283,7 @@ void CJabberProto::InfoFrame_OnTransport(CJabberInfoFrame_Event *evt) HMENU hContactMenu = Menu_BuildContactMenu(hContact); POINT pt; GetCursorPos(&pt); - int res = TrackPopupMenu(hContactMenu, TPM_RETURNCMD, pt.x, pt.y, 0, pcli->hwndContactList, NULL); + int res = TrackPopupMenu(hContactMenu, TPM_RETURNCMD, pt.x, pt.y, 0, pcli->hwndContactList, nullptr); Clist_MenuProcessCommand(res, MPCF_CONTACTMENU, hContact); } } diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index b0acd143a4..875afd5c27 100755 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -86,7 +86,7 @@ struct CJabberProto : public PROTO, public IJabberInterface virtual int __cdecl FileDeny(MCONTACT hContact, HANDLE hTransfer, const wchar_t *szReason); virtual int __cdecl FileResume(HANDLE hTransfer, int* action, const wchar_t** szFilename); - virtual DWORD_PTR __cdecl GetCaps(int type, MCONTACT hContact = NULL); + virtual DWORD_PTR __cdecl GetCaps(int type, MCONTACT hContact = 0); virtual int __cdecl GetInfo(MCONTACT hContact, int infoType); virtual HANDLE __cdecl SearchBasic(const wchar_t *id); @@ -452,7 +452,7 @@ struct CJabberProto : public PROTO, public IJabberInterface //---- jabber_iq.c ------------------------------------------------------------------- - __forceinline CJabberIqInfo* AddIQ(JABBER_IQ_HANDLER pHandler, int nIqType = JABBER_IQ_TYPE_GET, const wchar_t *szReceiver = NULL, DWORD dwParamsToParse = 0, int nIqId = -1, void *pUserData = NULL, int iPriority = JH_PRIORITY_DEFAULT) + __forceinline CJabberIqInfo* AddIQ(JABBER_IQ_HANDLER pHandler, int nIqType = JABBER_IQ_TYPE_GET, const wchar_t *szReceiver = nullptr, DWORD dwParamsToParse = 0, int nIqId = -1, void *pUserData = nullptr, int iPriority = JH_PRIORITY_DEFAULT) { return m_iqManager.AddHandler(pHandler, nIqType, szReceiver, dwParamsToParse, nIqId, pUserData, iPriority); } @@ -547,7 +547,7 @@ struct CJabberProto : public PROTO, public IJabberInterface pResourceStatus ListFindResource(JABBER_LIST list, const wchar_t *jid); - bool ListAddResource(JABBER_LIST list, const wchar_t *jid, int status, const wchar_t *statusMessage, char priority = 0, const wchar_t *nick = NULL); + bool ListAddResource(JABBER_LIST list, const wchar_t *jid, int status, const wchar_t *statusMessage, char priority = 0, const wchar_t *nick = nullptr); void ListRemoveResource(JABBER_LIST list, const wchar_t *jid); wchar_t* ListGetBestClientResourceNamePtr(const wchar_t *jid); @@ -630,7 +630,7 @@ struct CJabberProto : public PROTO, public IJabberInterface void BuildPrivacyMenu(void); void BuildPrivacyListsMenu(bool bDeleteOld); - void QueryPrivacyLists(ThreadData *pThreadInfo = NULL); + void QueryPrivacyLists(ThreadData *pThreadInfo = nullptr); BOOL OnIqRequestPrivacyLists(HXML iqNode, CJabberIqInfo *pInfo); void OnIqResultPrivacyList(HXML iqNode, CJabberIqInfo *pInfo); @@ -661,7 +661,7 @@ struct CJabberProto : public PROTO, public IJabberInterface void OnIqResultGetSearchFields(HXML iqNode, CJabberIqInfo *pInfo); int SearchRenewFields(HWND hwndDlg, JabberSearchData * dat); void SearchDeleteFromRecent(const wchar_t *szAddr, bool deleteLastFromDB); - void SearchAddToRecent(const wchar_t *szAddr, HWND hwndDialog = NULL); + void SearchAddToRecent(const wchar_t *szAddr, HWND hwndDialog = nullptr); //---- jabber_std.cpp ---------------------------------------------- void JLoginFailed(int errorCode); @@ -751,20 +751,20 @@ struct CJabberProto : public PROTO, public IJabberInterface MCONTACT HContactFromJID(const wchar_t *jid, bool bStripResource = true); MCONTACT ChatRoomHContactFromJID(const wchar_t *jid); void SendVisibleInvisiblePresence(BOOL invisible); - void SendPresenceTo(int status, const wchar_t* to, HXML extra, const wchar_t *msg = NULL); + void SendPresenceTo(int status, const wchar_t* to, HXML extra, const wchar_t *msg = nullptr); void SendPresence(int m_iStatus, bool bSendToAll); void StringAppend(char* *str, int *sizeAlloced, const char* fmt, ...); void RebuildInfoFrame(void); void InitInfoFrame(void); - // returns buf or NULL on error + // returns buf or nullptr on error wchar_t* GetClientJID(MCONTACT hContact, wchar_t *dest, size_t destLen); wchar_t* GetClientJID(const wchar_t *jid, wchar_t *dest, size_t destLen); void ComboLoadRecentStrings(HWND hwndDlg, UINT idcCombo, char *param, int recentCount=JABBER_DEFAULT_RECENT_COUNT); void ComboAddRecentString(HWND hwndDlg, UINT idcCombo, char *param, const wchar_t *string, int recentCount=JABBER_DEFAULT_RECENT_COUNT); - BOOL EnterString(CMStringW &result, LPCTSTR caption, int type, char *windowName=NULL, int recentCount=JABBER_DEFAULT_RECENT_COUNT, int timeout=0); + BOOL EnterString(CMStringW &result, LPCTSTR caption, int type, char *windowName=nullptr, int recentCount=JABBER_DEFAULT_RECENT_COUNT, int timeout=0); bool IsMyOwnJID(LPCTSTR szJID); void __cdecl LoadHttpAvatars(void* param); diff --git a/protocols/JabberG/src/jabber_rc.cpp b/protocols/JabberG/src/jabber_rc.cpp index c37e85bc31..51abb95c94 100644 --- a/protocols/JabberG/src/jabber_rc.cpp +++ b/protocols/JabberG/src/jabber_rc.cpp @@ -31,8 +31,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. CJabberAdhocSession::CJabberAdhocSession(CJabberProto* global) { - m_pNext = NULL; - m_pUserData = NULL; + m_pNext = nullptr; + m_pUserData = nullptr; m_bAutofreeUserData = FALSE; m_dwStage = 0; ppro = global; @@ -119,7 +119,7 @@ BOOL CJabberAdhocManager::HandleInfoRequest(HXML, CJabberIqInfo *pInfo, const wc mir_cslockfull lck(m_cs); CJabberAdhocNode *pNode = FindNode(szNode); - if (pNode == NULL) + if (pNode == nullptr) return FALSE; XmlNodeIq iq(L"result", pInfo); @@ -156,7 +156,7 @@ BOOL CJabberAdhocManager::HandleCommandRequest(HXML iqNode, CJabberIqInfo *pInfo const wchar_t *szSessionId = XmlGetAttrValue(commandNode, L"sessionid"); - CJabberAdhocSession* pSession = NULL; + CJabberAdhocSession* pSession = nullptr; if (szSessionId) { pSession = FindSession(szSessionId); if (!pSession) { @@ -196,7 +196,7 @@ BOOL CJabberAdhocManager::HandleCommandRequest(HXML iqNode, CJabberIqInfo *pInfo << XCHILD(L"note", TranslateT("Command completed successfully")) << XATTR(L"type", L"info")); RemoveSession(pSession); - pSession = NULL; + pSession = nullptr; } else if (nResultCode == JABBER_ADHOC_HANDLER_STATUS_CANCEL) { m_pProto->m_ThreadInfo->send( @@ -206,11 +206,11 @@ BOOL CJabberAdhocManager::HandleCommandRequest(HXML iqNode, CJabberIqInfo *pInfo << XCHILD(L"note", TranslateT("Error occurred during processing command")) << XATTR(L"type", L"error")); RemoveSession(pSession); - pSession = NULL; + pSession = nullptr; } else if (nResultCode == JABBER_ADHOC_HANDLER_STATUS_REMOVE_SESSION) { RemoveSession(pSession); - pSession = NULL; + pSession = nullptr; } return TRUE; @@ -218,12 +218,12 @@ BOOL CJabberAdhocManager::HandleCommandRequest(HXML iqNode, CJabberIqInfo *pInfo BOOL CJabberAdhocManager::FillDefaultNodes() { - AddNode(NULL, JABBER_FEAT_RC_SET_STATUS, TranslateT("Set status"), &CJabberProto::AdhocSetStatusHandler); - AddNode(NULL, JABBER_FEAT_RC_SET_OPTIONS, TranslateT("Set options"), &CJabberProto::AdhocOptionsHandler); - AddNode(NULL, JABBER_FEAT_RC_FORWARD, TranslateT("Forward unread messages"), &CJabberProto::AdhocForwardHandler); - AddNode(NULL, JABBER_FEAT_RC_LEAVE_GROUPCHATS, TranslateT("Leave group chats"), &CJabberProto::AdhocLeaveGroupchatsHandler); - AddNode(NULL, JABBER_FEAT_RC_WS_LOCK, TranslateT("Lock workstation"), &CJabberProto::AdhocLockWSHandler); - AddNode(NULL, JABBER_FEAT_RC_QUIT_MIRANDA, TranslateT("Quit Miranda NG"), &CJabberProto::AdhocQuitMirandaHandler); + AddNode(nullptr, JABBER_FEAT_RC_SET_STATUS, TranslateT("Set status"), &CJabberProto::AdhocSetStatusHandler); + AddNode(nullptr, JABBER_FEAT_RC_SET_OPTIONS, TranslateT("Set options"), &CJabberProto::AdhocOptionsHandler); + AddNode(nullptr, JABBER_FEAT_RC_FORWARD, TranslateT("Forward unread messages"), &CJabberProto::AdhocForwardHandler); + AddNode(nullptr, JABBER_FEAT_RC_LEAVE_GROUPCHATS, TranslateT("Leave group chats"), &CJabberProto::AdhocLeaveGroupchatsHandler); + AddNode(nullptr, JABBER_FEAT_RC_WS_LOCK, TranslateT("Lock workstation"), &CJabberProto::AdhocLockWSHandler); + AddNode(nullptr, JABBER_FEAT_RC_QUIT_MIRANDA, TranslateT("Quit Miranda NG"), &CJabberProto::AdhocQuitMirandaHandler); return TRUE; } @@ -245,7 +245,7 @@ static char *StatusModeToDbSetting(int status,const char *suffix) case ID_STATUS_ONTHEPHONE: prefix="Otp"; break; case ID_STATUS_OUTTOLUNCH: prefix="Otl"; break; case ID_STATUS_IDLE: prefix="Idl"; break; - default: return NULL; + default: return nullptr; } mir_strcpy(str,prefix); mir_strcat(str,suffix); return str; @@ -342,7 +342,7 @@ int CJabberProto::AdhocSetStatusHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhoc return JABBER_ADHOC_HANDLER_STATUS_CANCEL; LPCTSTR ptszValue = XmlGetText( XmlGetChild(fieldNode , "value")); - if (ptszValue == NULL) + if (ptszValue == nullptr) return JABBER_ADHOC_HANDLER_STATUS_CANCEL; int status; @@ -366,28 +366,28 @@ int CJabberProto::AdhocSetStatusHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhoc if (priority >= -128 && priority <= 127) setDword("Priority", priority); - const wchar_t *szStatusMessage = NULL; + const wchar_t *szStatusMessage = nullptr; fieldNode = XmlGetChildByTag(xNode, "field", "var", L"status-message"); if (fieldNode && (valueNode = XmlGetChild(fieldNode , "value"))) szStatusMessage = XmlGetText(valueNode); // skip f...ng away dialog - int nNoDlg = db_get_b(NULL, "SRAway", StatusModeToDbSetting(status, "NoDlg"), 0); - db_set_b(NULL, "SRAway", StatusModeToDbSetting(status, "NoDlg"), 1); + int nNoDlg = db_get_b(0, "SRAway", StatusModeToDbSetting(status, "NoDlg"), 0); + db_set_b(0, "SRAway", StatusModeToDbSetting(status, "NoDlg"), 1); - db_set_ws(NULL, "SRAway", StatusModeToDbSetting(status, "Msg"), szStatusMessage ? szStatusMessage : L""); + db_set_ws(0, "SRAway", StatusModeToDbSetting(status, "Msg"), szStatusMessage ? szStatusMessage : L""); fieldNode = XmlGetChildByTag(xNode, "field", "var", L"status-global"); if (fieldNode && (valueNode = XmlGetChild(fieldNode , "value"))) { - if ((ptszValue = XmlGetText(valueNode)) != NULL && _wtoi(ptszValue)) - CallService(MS_CLIST_SETSTATUSMODE, status, NULL); + if ((ptszValue = XmlGetText(valueNode)) != nullptr && _wtoi(ptszValue)) + CallService(MS_CLIST_SETSTATUSMODE, status, 0); else - CallProtoService(m_szModuleName, PS_SETSTATUS, status, NULL); + CallProtoService(m_szModuleName, PS_SETSTATUS, status, 0); } SetAwayMsg(status, szStatusMessage); // return NoDlg setting - db_set_b(NULL, "SRAway", StatusModeToDbSetting(status, "NoDlg"), (BYTE)nNoDlg); + db_set_b(0, "SRAway", StatusModeToDbSetting(status, "NoDlg"), (BYTE)nNoDlg); return JABBER_ADHOC_HANDLER_STATUS_COMPLETED; } @@ -414,12 +414,12 @@ int CJabberProto::AdhocOptionsHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhocSe // Automatically Accept File Transfers wchar_t szTmpBuff[ 1024 ]; - mir_snwprintf(szTmpBuff, L"%d", db_get_b(NULL, "SRFile", "AutoAccept", 0)); + mir_snwprintf(szTmpBuff, L"%d", db_get_b(0, "SRFile", "AutoAccept", 0)); xNode << XCHILD(L"field") << XATTR(L"label", TranslateT("Automatically Accept File Transfers")) << XATTR(L"type", L"boolean") << XATTR(L"var", L"auto-files") << XCHILD(L"value", szTmpBuff); // Use sounds - mir_snwprintf(szTmpBuff, L"%d", db_get_b(NULL, "Skin", "UseSound", 0)); + mir_snwprintf(szTmpBuff, L"%d", db_get_b(0, "Skin", "UseSound", 0)); xNode << XCHILD(L"field") << XATTR(L"label", TranslateT("Play sounds")) << XATTR(L"type", L"boolean") << XATTR(L"var", L"sounds") << XCHILD(L"value", szTmpBuff); @@ -442,13 +442,13 @@ int CJabberProto::AdhocOptionsHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhocSe HXML fieldNode = XmlGetChildByTag(xNode, "field", "var", L"auto-files"), valueNode; if (fieldNode && (valueNode = XmlGetChild(fieldNode , "value"))) if (XmlGetText(valueNode)) - db_set_b(NULL, "SRFile", "AutoAccept", (BYTE)_wtoi(XmlGetText(valueNode))); + db_set_b(0, "SRFile", "AutoAccept", (BYTE)_wtoi(XmlGetText(valueNode))); // Use sounds fieldNode = XmlGetChildByTag(xNode, "field", "var", L"sounds"); if (fieldNode && (valueNode = XmlGetChild(fieldNode , "value"))) if (XmlGetText(valueNode)) - db_set_b(NULL, "Skin", "UseSound", (BYTE)_wtoi(XmlGetText(valueNode))); + db_set_b(0, "Skin", "UseSound", (BYTE)_wtoi(XmlGetText(valueNode))); // Disable remote controlling fieldNode = XmlGetChildByTag(xNode, "field", "var", L"enable-rc"); @@ -466,7 +466,7 @@ int CJabberProto::RcGetUnreadEventsCount() int nEventsSent = 0; for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { ptrW jid( getWStringA(hContact, "jid")); - if (jid == NULL) continue; + if (jid == nullptr) continue; for (MEVENT hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hContact, hDbEvent)) { DBEVENTINFO dbei = {}; @@ -552,7 +552,7 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhocSe int nEventsSent = 0; for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { ptrW tszJid( getWStringA(hContact, "jid")); - if (tszJid == NULL) + if (tszJid == nullptr) continue; for (MEVENT hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hContact, hDbEvent)) { @@ -570,7 +570,7 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhocSe continue; ptrW szEventText( DbEvent_GetTextW(&dbei, CP_ACP)); - if (szEventText == NULL) + if (szEventText == nullptr) continue; XmlNode msg(L"message"); @@ -702,7 +702,7 @@ int CJabberProto::AdhocLeaveGroupchatsHandler(HXML, CJabberIqInfo *pInfo, CJabbe LISTFOREACH_NODEF(i, this, LIST_CHATROOM) { JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i); - if (item != NULL) + if (item != nullptr) nChatsCount++; } } @@ -735,14 +735,14 @@ int CJabberProto::AdhocLeaveGroupchatsHandler(HXML, CJabberIqInfo *pInfo, CJabbe << XATTR(L"value", JABBER_FEAT_RC); // Groupchats - HXML fieldNode = xNode << XCHILD(L"field") << XATTR(L"label", NULL) << XATTR(L"type", L"list-multi") << XATTR(L"var", L"groupchats"); + HXML fieldNode = xNode << XCHILD(L"field") << XATTR(L"label", nullptr) << XATTR(L"type", L"list-multi") << XATTR(L"var", L"groupchats"); fieldNode << XCHILD(L"required"); { mir_cslock lck(m_csLists); LISTFOREACH_NODEF(i, this, LIST_CHATROOM) { JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i); - if (item != NULL) + if (item != nullptr) fieldNode << XCHILD(L"option") << XATTR(L"label", item->jid) << XCHILD(L"value", item->jid); } } @@ -766,7 +766,7 @@ int CJabberProto::AdhocLeaveGroupchatsHandler(HXML, CJabberIqInfo *pInfo, CJabbe if (valueNode && XmlGetName(valueNode) && XmlGetText(valueNode) && !mir_wstrcmp(XmlGetName(valueNode), L"value")) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, XmlGetText(valueNode)); if (item) - GcQuit(item, 0, NULL); + GcQuit(item, 0, nullptr); } } } diff --git a/protocols/JabberG/src/jabber_rc.h b/protocols/JabberG/src/jabber_rc.h index e3ef1ff0e7..91ba10f661 100644 --- a/protocols/JabberG/src/jabber_rc.h +++ b/protocols/JabberG/src/jabber_rc.h @@ -151,7 +151,7 @@ public: } BOOL CallHandler(HXML iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession* pSession) { - if (m_pHandler == NULL) + if (m_pHandler == nullptr) return FALSE; return (m_pProto->*m_pHandler)(iqNode, pInfo, pSession); } @@ -173,14 +173,14 @@ protected: return pSession; pSession = pSession->GetNext(); } - return NULL; + return nullptr; } CJabberAdhocSession* AddNewSession() { CJabberAdhocSession* pSession = new CJabberAdhocSession(m_pProto); if (!pSession) - return NULL; + return nullptr; pSession->SetNext(m_pSessions); m_pSessions = pSession; @@ -196,7 +196,7 @@ protected: return pNode; pNode = pNode->GetNext(); } - return NULL; + return nullptr; } BOOL RemoveSession(CJabberAdhocSession* pSession) @@ -206,7 +206,7 @@ protected: if (pSession == m_pSessions) { m_pSessions = m_pSessions->GetNext(); - pSession->SetNext(NULL); + pSession->SetNext(nullptr); delete pSession; return TRUE; } @@ -215,7 +215,7 @@ protected: while (pTmp->GetNext()) { if (pTmp->GetNext() == pSession) { pTmp->SetNext(pSession->GetNext()); - pSession->SetNext(NULL); + pSession->SetNext(nullptr); delete pSession; return TRUE; } @@ -232,7 +232,7 @@ protected: CJabberAdhocSession* pSession = m_pSessions; if (pSession->GetSessionStartTime() < dwExpireTime) { m_pSessions = pSession->GetNext(); - pSession->SetNext(NULL); + pSession->SetNext(nullptr); delete pSession; return TRUE; } @@ -241,7 +241,7 @@ protected: if (pSession->GetNext()->GetSessionStartTime() < dwExpireTime) { CJabberAdhocSession* pRetVal = pSession->GetNext(); pSession->SetNext(pSession->GetNext()->GetNext()); - pRetVal->SetNext(NULL); + pRetVal->SetNext(nullptr); delete pRetVal; return TRUE; } @@ -254,8 +254,8 @@ public: CJabberAdhocManager(CJabberProto* pProto) { m_pProto = pProto; - m_pNodes = NULL; - m_pSessions = NULL; + m_pNodes = nullptr; + m_pSessions = nullptr; } ~CJabberAdhocManager() { diff --git a/protocols/JabberG/src/jabber_search.cpp b/protocols/JabberG/src/jabber_search.cpp index e8a2d2c9b3..996018d1a8 100644 --- a/protocols/JabberG/src/jabber_search.cpp +++ b/protocols/JabberG/src/jabber_search.cpp @@ -55,7 +55,7 @@ static int JabberSearchFrameProc(HWND hwnd, int msg, WPARAM wParam, LPARAM lPara pos = dat->CurrentHeight - dat->frameHeight; } if (pos != dat->curPos) { - ScrollWindow(GetDlgItem(hwndDlg, IDC_FRAME), 0, dat->curPos - pos, NULL, &(dat->frameRect)); + ScrollWindow(GetDlgItem(hwndDlg, IDC_FRAME), 0, dat->curPos - pos, nullptr, &(dat->frameRect)); SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, pos, TRUE); RECT Invalid = dat->frameRect; if (dat->curPos - pos > 0) @@ -63,7 +63,7 @@ static int JabberSearchFrameProc(HWND hwnd, int msg, WPARAM wParam, LPARAM lPara else Invalid.top = Invalid.bottom + (dat->curPos - pos); - RedrawWindow(GetDlgItem(hwndDlg, IDC_FRAME), NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); + RedrawWindow(GetDlgItem(hwndDlg, IDC_FRAME), nullptr, nullptr, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); dat->curPos = pos; } } @@ -105,8 +105,8 @@ static int JabberSearchAddField(HWND hwndDlg, Data* FieldDat) int Order = (FieldDat->bHidden) ? -1 : FieldDat->Order; - HWND hwndLabel = CreateWindowEx(0, L"STATIC", (LPCTSTR)TranslateW(FieldDat->Label), WS_CHILD, CornerX, CornerY + Order * 40, width, 13, hwndParent, NULL, hInst, 0); - HWND hwndVar = CreateWindowEx(0 | WS_EX_CLIENTEDGE, L"EDIT", (LPCTSTR)FieldDat->defValue, WS_CHILD | WS_TABSTOP, CornerX + 5, CornerY + Order * 40 + 14, width, 20, hwndParent, NULL, hInst, 0); + HWND hwndLabel = CreateWindowEx(0, L"STATIC", (LPCTSTR)TranslateW(FieldDat->Label), WS_CHILD, CornerX, CornerY + Order * 40, width, 13, hwndParent, nullptr, hInst, 0); + HWND hwndVar = CreateWindowEx(0 | WS_EX_CLIENTEDGE, L"EDIT", (LPCTSTR)FieldDat->defValue, WS_CHILD | WS_TABSTOP, CornerX + 5, CornerY + Order * 40 + 14, width, 20, hwndParent, nullptr, hInst, 0); SendMessage(hwndLabel, WM_SETFONT, (WPARAM)hFont, 0); SendMessage(hwndVar, WM_SETFONT, (WPARAM)hFont, 0); if (!FieldDat->bHidden) { @@ -138,7 +138,7 @@ void CJabberProto::OnIqResultGetSearchFields(HXML iqNode, CJabberIqInfo*) return; LPCTSTR type = XmlGetAttrValue(iqNode, L"type"); - if (type == NULL) + if (type == nullptr) return; if (!mir_wstrcmp(type, L"result")) { @@ -184,8 +184,8 @@ void CJabberProto::OnIqResultGetSearchFields(HXML iqNode, CJabberIqInfo*) ShowWindow(searchHandleDlg, SW_SHOW); } else if (!mir_wstrcmp(type, L"error")) { - const wchar_t *code = NULL; - const wchar_t *description = NULL; + const wchar_t *code = nullptr; + const wchar_t *description = nullptr; wchar_t buff[255]; HXML errorNode = XmlGetChild(iqNode, "error"); if (errorNode) { @@ -203,7 +203,7 @@ void CJabberProto::OnIqResultGetSearchFields(HXML iqNode, CJabberIqInfo*) // The pmFields is the pointer to map of Not unical but ordered // This can help to made result parser routines more simple -static wchar_t *nickfields[] = { L"nick", L"nickname", L"fullname", L"name", L"given", L"first", L"jid", NULL }; +static wchar_t *nickfields[] = { L"nick", L"nickname", L"fullname", L"name", L"given", L"first", L"jid", nullptr }; void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_MAP * pmAllFields) { @@ -248,7 +248,7 @@ void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_M } Results.psr.cbSize = 0; // sending column names - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, id, (LPARAM)&Results); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, id, (LPARAM)&Results); /* Sending Users Data */ Results.psr.cbSize = sizeof(Results.psr); // sending user data @@ -265,7 +265,7 @@ void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_M Results.psr.id.w = value; } - wchar_t *nick = NULL; + wchar_t *nick = nullptr; for (int k = 0; k < _countof(nickfields) && !nick; k++) nick = pmUserData->operator [](nickfields[k]); @@ -280,8 +280,8 @@ void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_M Results.psr.nick.w = nick; Results.psr.flags = PSR_UNICODE; - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, id, (LPARAM)&Results); - Results.psr.nick.w = NULL; + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, id, (LPARAM)&Results); + Results.psr.nick.w = nullptr; } mir_free(Results.pszFields); } @@ -307,8 +307,8 @@ void CJabberProto::OnIqResultAdvancedSearch(HXML iqNode, CJabberIqInfo*) U_TCHAR_MAP mColumnsNames(10); LIST SearchResults(2); - if (((id = JabberGetPacketID(iqNode)) == -1) || ((type = XmlGetAttrValue(iqNode, L"type")) == NULL)) { - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); + if (((id = JabberGetPacketID(iqNode)) == -1) || ((type = XmlGetAttrValue(iqNode, L"type")) == nullptr)) { + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); return; } @@ -324,7 +324,7 @@ void CJabberProto::OnIqResultAdvancedSearch(HXML iqNode, CJabberIqInfo*) wchar_t *var = (wchar_t*)XmlGetAttrValue(fieldNode, L"var"); if (var) { wchar_t *Label = (wchar_t*)XmlGetAttrValue(fieldNode, L"label"); - mColumnsNames.insert(var, (Label != NULL) ? Label : var); + mColumnsNames.insert(var, (Label != nullptr) ? Label : var); } } } @@ -357,7 +357,7 @@ void CJabberProto::OnIqResultAdvancedSearch(HXML iqNode, CJabberIqInfo*) wchar_t *keyReturned; mColumnsNames.insertCopyKey(L"jid", L"jid", &keyReturned, CopyKey, DestroyKey); mColumnsNames.insert(L"jid", keyReturned); - pUserColumn->insertCopyKey(L"jid", jid, NULL, CopyKey, DestroyKey); + pUserColumn->insertCopyKey(L"jid", jid, nullptr, CopyKey, DestroyKey); for (int j = 0;; j++) { HXML child = XmlGetChild(itemNode, j); @@ -370,7 +370,7 @@ void CJabberProto::OnIqResultAdvancedSearch(HXML iqNode, CJabberIqInfo*) if (ptszChild && *ptszChild) { mColumnsNames.insertCopyKey((wchar_t*)szColumnName, L"", &keyReturned, CopyKey, DestroyKey); mColumnsNames.insert((wchar_t*)szColumnName, keyReturned); - pUserColumn->insertCopyKey((wchar_t*)szColumnName, (wchar_t*)ptszChild, NULL, CopyKey, DestroyKey); + pUserColumn->insertCopyKey((wchar_t*)szColumnName, (wchar_t*)ptszChild, nullptr, CopyKey, DestroyKey); } } } @@ -380,8 +380,8 @@ void CJabberProto::OnIqResultAdvancedSearch(HXML iqNode, CJabberIqInfo*) } } else if (!mir_wstrcmp(type, L"error")) { - const wchar_t *code = NULL; - const wchar_t *description = NULL; + const wchar_t *code = nullptr; + const wchar_t *description = nullptr; wchar_t buff[255]; HXML errorNode = XmlGetChild(iqNode, "error"); if (errorNode) { @@ -390,11 +390,11 @@ void CJabberProto::OnIqResultAdvancedSearch(HXML iqNode, CJabberIqInfo*) } mir_snwprintf(buff, TranslateT("Error %s %s\r\nTry to specify more detailed"), code ? code : L"", description ? description : L""); - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); if (searchHandleDlg) SetDlgItemText(searchHandleDlg, IDC_INSTRUCTIONS, buff); else - MessageBox(NULL, buff, TranslateT("Search error"), MB_OK | MB_ICONSTOP); + MessageBox(nullptr, buff, TranslateT("Search error"), MB_OK | MB_ICONSTOP); return; } @@ -404,7 +404,7 @@ void CJabberProto::OnIqResultAdvancedSearch(HXML iqNode, CJabberIqInfo*) delete ((U_TCHAR_MAP*)SearchResults[i]); //send success to finish searching - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); } static BOOL CALLBACK DeleteChildWindowsProc(HWND hwnd, LPARAM) @@ -427,7 +427,7 @@ static void JabberSearchFreeData(HWND hwndDlg, JabberSearchData * dat) free(dat->pJSInf[i].szFieldName); } free(dat->pJSInf); - dat->pJSInf = NULL; + dat->pJSInf = nullptr; } else EnumChildWindows(GetDlgItem(hwndDlg, IDC_FRAME), DeleteChildWindowsProc, 0); @@ -495,20 +495,20 @@ void CJabberProto::SearchDeleteFromRecent(const wchar_t *szAddr, bool deleteLast char key[30]; mir_snprintf(key, "RecentlySearched_%d", i); ptrW szValue(getWStringA(key)); - if (szValue == NULL || mir_wstrcmpi(szAddr, szValue)) + if (szValue == nullptr || mir_wstrcmpi(szAddr, szValue)) continue; for (int j = i; j < 10; j++) { mir_snprintf(key, "RecentlySearched_%d", j + 1); szValue = getWStringA(key); - if (szValue != NULL) { + if (szValue != nullptr) { mir_snprintf(key, "RecentlySearched_%d", j); - setWString(NULL, key, szValue); + setWString(0, key, szValue); } else { if (deleteLastFromDB) { mir_snprintf(key, "RecentlySearched_%d", j); - delSetting(NULL, key); + delSetting(0, key); } break; } @@ -525,9 +525,9 @@ void CJabberProto::SearchAddToRecent(const wchar_t *szAddr, HWND hwndDialog) for (int j = 9; j > 0; j--) { mir_snprintf(key, "RecentlySearched_%d", j - 1); ptrW szValue(getWStringA(key)); - if (szValue != NULL) { + if (szValue != nullptr) { mir_snprintf(key, "RecentlySearched_%d", j); - setWString(NULL, key, szValue); + setWString(0, key, szValue); } } @@ -550,7 +550,7 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR /* Server Combo box */ ptrA jud(dat->ppro->getStringA("Jud")); - char *szServerName = (jud == NULL) ? "users.jabber.org" : jud; + char *szServerName = (jud == nullptr) ? "users.jabber.org" : jud; SetDlgItemTextA(hwndDlg, IDC_SERVER, szServerName); SendDlgItemMessageA(hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, (LPARAM)szServerName); //TO DO: Add Transports here @@ -565,7 +565,7 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR char key[30]; mir_snprintf(key, "RecentlySearched_%d", i); ptrW szValue(dat->ppro->getWStringA(key)); - if (szValue != NULL) + if (szValue != nullptr) JabberSearchAddUrlToRecentCombo(hwndDlg, szValue); } @@ -610,9 +610,9 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR RECT rcFrame; GetWindowRect(GetDlgItem(hwndDlg, IDC_FRAME), &rcFrame); rcFrame.bottom = rcForm.bottom; - SetWindowPos(GetDlgItem(hwndDlg, IDC_FRAME), NULL, 0, 0, rcFrame.right - rcFrame.left, rcFrame.bottom - rcFrame.top, SWP_NOZORDER | SWP_NOMOVE); + SetWindowPos(GetDlgItem(hwndDlg, IDC_FRAME), nullptr, 0, 0, rcFrame.right - rcFrame.left, rcFrame.bottom - rcFrame.top, SWP_NOZORDER | SWP_NOMOVE); GetWindowRect(GetDlgItem(hwndDlg, IDC_VSCROLL), &rcForm); - SetWindowPos(GetDlgItem(hwndDlg, IDC_VSCROLL), NULL, 0, 0, rcForm.right - rcForm.left, rcFrame.bottom - rcFrame.top, SWP_NOZORDER | SWP_NOMOVE); + SetWindowPos(GetDlgItem(hwndDlg, IDC_VSCROLL), nullptr, 0, 0, rcForm.right - rcForm.left, rcFrame.bottom - rcFrame.top, SWP_NOZORDER | SWP_NOMOVE); JabberSearchRefreshFrameScroll(hwndDlg, dat); } return TRUE; @@ -640,7 +640,7 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR } else { JabberSearchRefreshFrameScroll(hwndDlg, dat); - ScrollWindow(GetDlgItem(hwndDlg, IDC_FRAME), 0, dat->curPos - 0, NULL, &(dat->frameRect)); + ScrollWindow(GetDlgItem(hwndDlg, IDC_FRAME), 0, dat->curPos - 0, nullptr, &(dat->frameRect)); SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, 0, FALSE); dat->curPos = 0; } @@ -662,7 +662,7 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR case WM_VSCROLL: { int pos; - if (dat != NULL) { + if (dat != nullptr) { pos = dat->curPos; switch (LOWORD(wParam)) { case SB_LINEDOWN: @@ -686,7 +686,7 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR if (pos < 0) pos = 0; if (dat->curPos != pos) { - ScrollWindow(GetDlgItem(hwndDlg, IDC_FRAME), 0, dat->curPos - pos, NULL, &(dat->frameRect)); + ScrollWindow(GetDlgItem(hwndDlg, IDC_FRAME), 0, dat->curPos - pos, nullptr, &(dat->frameRect)); SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, pos, TRUE); RECT Invalid = dat->frameRect; if (dat->curPos - pos >0) @@ -694,7 +694,7 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR else Invalid.top = Invalid.bottom + (dat->curPos - pos); - RedrawWindow(GetDlgItem(hwndDlg, IDC_FRAME), NULL, NULL, RDW_UPDATENOW | RDW_ALLCHILDREN); + RedrawWindow(GetDlgItem(hwndDlg, IDC_FRAME), nullptr, nullptr, RDW_UPDATENOW | RDW_ALLCHILDREN); dat->curPos = pos; } } @@ -715,7 +715,7 @@ HWND __cdecl CJabberProto::CreateExtendedSearchUI(HWND parent) { if (parent && hInst) { ptrW szServer(getWStringA("LoginServer")); - if (szServer == NULL || mir_wstrcmpi(szServer, L"S.ms")) + if (szServer == nullptr || mir_wstrcmpi(szServer, L"S.ms")) return CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SEARCHUSER), parent, JabberSearchAdvancedDlgProc, (LPARAM)this); } diff --git a/protocols/JabberG/src/jabber_search.h b/protocols/JabberG/src/jabber_search.h index ebca5996b2..9fddc8cfc1 100644 --- a/protocols/JabberG/src/jabber_search.h +++ b/protocols/JabberG/src/jabber_search.h @@ -60,7 +60,7 @@ typedef struct tag_Data } Data; -static HWND searchHandleDlg=NULL; +static HWND searchHandleDlg=nullptr; //local functions declarations static int JabberSearchFrameProc(HWND hwnd, int msg, WPARAM wParam, LPARAM lParam); @@ -84,13 +84,13 @@ public: private: typedef struct _tagRECORD { - _tagRECORD(_KEYTYPE * key, wchar_t * value=NULL) { _key=key; _value=value; _order=0; _destroyKeyProc=NULL; } + _tagRECORD(_KEYTYPE * key, wchar_t * value=nullptr) { _key=key; _value=value; _order=0; _destroyKeyProc=nullptr; } ~_tagRECORD() { if (_key && _destroyKeyProc) _destroyKeyProc(_key); - _key=NULL; - _destroyKeyProc=NULL; + _key=nullptr; + _destroyKeyProc=nullptr; } _KEYTYPE *_key; wchar_t * _value; @@ -133,7 +133,7 @@ private: _RECORD * rec=_Records[i]; if (rec->_order==index) return rec; } - return NULL; + return nullptr; } public: @@ -179,7 +179,7 @@ public: { delete rec; DestroyProc(newKey); - if (_KeyReturn) *_KeyReturn=NULL; + if (_KeyReturn) *_KeyReturn=nullptr; } else { @@ -211,31 +211,31 @@ public: return L""; } else - return NULL; + return nullptr; } inline wchar_t* operator[](int index) const { _RECORD * rv=_Records[index]; if (rv) return rv->_value; - else return NULL; + else return nullptr; } inline _KEYTYPE* getKeyName(int index) { _RECORD * rv=_Records[index]; if (rv) return rv->_key; - else return NULL; + else return nullptr; } inline wchar_t * getUnOrdered(int index) { _RECORD * rec=_getUnorderedRec(index); if (rec) return rec->_value; - else return NULL; + else return nullptr; } inline _KEYTYPE * getUnOrderedKeyName(int index) { _RECORD * rec=_getUnorderedRec(index); if (rec) return rec->_key; - else return NULL; + else return nullptr; } inline int getCount() { diff --git a/protocols/JabberG/src/jabber_secur.cpp b/protocols/JabberG/src/jabber_secur.cpp index ab0e53d354..339c3d4f09 100644 --- a/protocols/JabberG/src/jabber_secur.cpp +++ b/protocols/JabberG/src/jabber_secur.cpp @@ -38,13 +38,13 @@ TNtlmAuth::TNtlmAuth(ThreadData *info, const char* mechanism, const wchar_t *hos if (!mir_strcmp(mechanism, "GSS-SPNEGO")) szProvider = L"Negotiate"; else if (!mir_strcmp(mechanism, "GSSAPI")) - szProvider = L"GSSAPI"; + szProvider = L"Kerberos"; else if (!mir_strcmp(mechanism, "NTLM")) szProvider = L"NTLM"; else { LBL_Invalid: bIsValid = false; - hProvider = NULL; + hProvider = nullptr; return; } @@ -53,13 +53,13 @@ LBL_Invalid: if (!getSpn(szSpn, _countof(szSpn)) && !mir_strcmp(mechanism, "GSSAPI")) goto LBL_Invalid; - if ((hProvider = Netlib_InitSecurityProvider(szProvider, szSpn)) == NULL) + if ((hProvider = Netlib_InitSecurityProvider(szProvider, szSpn)) == nullptr) bIsValid = false; } TNtlmAuth::~TNtlmAuth() { - if (hProvider != NULL) + if (hProvider != nullptr) Netlib_DestroySecurityProvider(hProvider); } @@ -86,7 +86,7 @@ bool TNtlmAuth::getSpn(wchar_t* szSpn, size_t dwSpnLen) const char* connectHost = info->conn.manualHost[0] ? info->conn.manualHost : info->conn.server; unsigned long ip = inet_addr(connectHost); - PHOSTENT host = (ip == INADDR_NONE) ? NULL : gethostbyaddr((char*)&ip, 4, AF_INET); + PHOSTENT host = (ip == INADDR_NONE) ? nullptr : gethostbyaddr((char*)&ip, 4, AF_INET); if (host && host->h_name) connectHost = host->h_name; @@ -95,32 +95,32 @@ bool TNtlmAuth::getSpn(wchar_t* szSpn, size_t dwSpnLen) mir_free(connectHostT); } - Netlib_Logf(NULL, "SPN: %S", szSpn); + Netlib_Logf(nullptr, "SPN: %S", szSpn); return true; } char* TNtlmAuth::getInitialRequest() { if (!hProvider) - return NULL; + return nullptr; // This generates login method advertisement packet if (info->conn.password[0] != 0) return Netlib_NtlmCreateResponse(hProvider, "", info->conn.username, info->conn.password, complete); - return Netlib_NtlmCreateResponse(hProvider, "", NULL, NULL, complete); + return Netlib_NtlmCreateResponse(hProvider, "", nullptr, nullptr, complete); } char* TNtlmAuth::getChallenge(const wchar_t *challenge) { if (!hProvider) - return NULL; + return nullptr; ptrA text((!mir_wstrcmp(challenge, L"=")) ? mir_strdup("") : mir_u2a(challenge)); if (info->conn.password[0] != 0) return Netlib_NtlmCreateResponse(hProvider, text, info->conn.username, info->conn.password, complete); - return Netlib_NtlmCreateResponse(hProvider, text, NULL, NULL, complete); + return Netlib_NtlmCreateResponse(hProvider, text, nullptr, nullptr, complete); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -140,7 +140,7 @@ TMD5Auth::~TMD5Auth() char* TMD5Auth::getChallenge(const wchar_t *challenge) { if (iCallCount > 0) - return NULL; + return nullptr; iCallCount++; @@ -211,7 +211,7 @@ TScramAuth::TScramAuth(ThreadData *info) : TJabberAuth(info) { szName = "SCRAM-SHA-1"; - cnonce = msg1 = serverSignature = NULL; + cnonce = msg1 = serverSignature = nullptr; } TScramAuth::~TScramAuth() @@ -246,10 +246,10 @@ char* TScramAuth::getChallenge(const wchar_t *challenge) ptrA chl((char*)mir_base64_decode(_T2A(challenge), &chlLen)); - for (char *p = strtok(NEWSTR_ALLOCA(chl), ","); p != NULL; p = strtok(NULL, ",")) { + for (char *p = strtok(NEWSTR_ALLOCA(chl), ","); p != nullptr; p = strtok(nullptr, ",")) { if (*p == 'r' && p[1] == '=') { // snonce if (strncmp(cnonce, p + 2, mir_strlen(cnonce))) - return NULL; + return nullptr; snonce = mir_strdup(p + 2); } else if (*p == 's' && p[1] == '=') // salt @@ -258,8 +258,8 @@ char* TScramAuth::getChallenge(const wchar_t *challenge) ind = atoi(p + 2); } - if (snonce == NULL || salt == NULL || ind == -1) - return NULL; + if (snonce == nullptr || salt == nullptr || ind == -1) + return nullptr; ptrA passw(mir_utf8encodeW(info->conn.password)); size_t passwLen = mir_strlen(passw); @@ -356,7 +356,7 @@ char* TPlainAuth::getInitialRequest() TJabberAuth::TJabberAuth(ThreadData* pInfo) : bIsValid(true), complete(0), - szName(NULL), + szName(nullptr), info(pInfo) { } @@ -367,12 +367,12 @@ TJabberAuth::~TJabberAuth() char* TJabberAuth::getInitialRequest() { - return NULL; + return nullptr; } char* TJabberAuth::getChallenge(const wchar_t*) { - return NULL; + return nullptr; } bool TJabberAuth::validateLogin(const wchar_t*) diff --git a/protocols/JabberG/src/jabber_secur.h b/protocols/JabberG/src/jabber_secur.h index c03d99fbbd..2a7165cff1 100644 --- a/protocols/JabberG/src/jabber_secur.h +++ b/protocols/JabberG/src/jabber_secur.h @@ -103,7 +103,7 @@ class TNtlmAuth : public TJabberAuth HANDLE hProvider; const wchar_t *szHostName; public: - TNtlmAuth(ThreadData*, const char* mechanism, const wchar_t *hostname = NULL); + TNtlmAuth(ThreadData*, const char* mechanism, const wchar_t *hostname = nullptr); virtual ~TNtlmAuth(); virtual char* getInitialRequest(); diff --git a/protocols/JabberG/src/jabber_send_manager.h b/protocols/JabberG/src/jabber_send_manager.h index 70c00501fa..50ddfe7b78 100644 --- a/protocols/JabberG/src/jabber_send_manager.h +++ b/protocols/JabberG/src/jabber_send_manager.h @@ -96,7 +96,7 @@ public: CJabberSendManager(CJabberProto *proto); ~CJabberSendManager(); - CJabberSendPermanentInfo* AddPermanentHandler(JABBER_SEND_HANDLER pHandler, void *pUserData = NULL, SEND_USER_DATA_FREE_FUNC pUserDataFree = NULL, int iPriority = JH_PRIORITY_DEFAULT); + CJabberSendPermanentInfo* AddPermanentHandler(JABBER_SEND_HANDLER pHandler, void *pUserData = nullptr, SEND_USER_DATA_FREE_FUNC pUserDataFree = nullptr, int iPriority = JH_PRIORITY_DEFAULT); bool DeletePermanentHandler(CJabberSendPermanentInfo *pInfo); bool HandleSendPermanent(HXML node, ThreadData *pThreadData); diff --git a/protocols/JabberG/src/jabber_std.cpp b/protocols/JabberG/src/jabber_std.cpp index 20ab42f302..a01e2cbb4c 100644 --- a/protocols/JabberG/src/jabber_std.cpp +++ b/protocols/JabberG/src/jabber_std.cpp @@ -28,6 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void CJabberProto::JLoginFailed(int errorCode) { - m_savedPassword = NULL; - ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, errorCode); + m_savedPassword = nullptr; + ProtoBroadcastAck(0, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, errorCode); } diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp index 4661cdcc99..126befb184 100644 --- a/protocols/JabberG/src/jabber_svc.cpp +++ b/protocols/JabberG/src/jabber_svc.cpp @@ -38,7 +38,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. INT_PTR __cdecl CJabberProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam) { - wchar_t *szStatus = NULL; + wchar_t *szStatus = nullptr; mir_cslock lck(m_csModeMsgMutex); switch (wParam ? (int)wParam : m_iStatus) { @@ -77,13 +77,13 @@ INT_PTR __cdecl CJabberProto::JabberGetAvatar(WPARAM wParam, LPARAM lParam) wchar_t *buf = (wchar_t*)wParam; int size = (int)lParam; - if (buf == NULL || size <= 0) + if (buf == nullptr || size <= 0) return -1; if (!m_options.EnableAvatars) return -2; - GetAvatarFileName(NULL, buf, size); + GetAvatarFileName(0, buf, size); return 0; } @@ -124,7 +124,7 @@ INT_PTR __cdecl CJabberProto::JabberGetAvatarInfo(WPARAM wParam, LPARAM lParam) PROTO_AVATAR_INFORMATION* pai = (PROTO_AVATAR_INFORMATION*)lParam; ptrA szHashValue( getStringA(pai->hContact, "AvatarHash")); - if (szHashValue == NULL) { + if (szHashValue == nullptr) { debugLogA("No avatar"); return GAIR_NOAVATAR; } @@ -133,25 +133,25 @@ INT_PTR __cdecl CJabberProto::JabberGetAvatarInfo(WPARAM wParam, LPARAM lParam) GetAvatarFileName(pai->hContact, tszFileName, _countof(tszFileName)); wcsncpy_s(pai->filename, tszFileName, _TRUNCATE); - pai->format = (pai->hContact == NULL) ? PA_FORMAT_PNG : getByte(pai->hContact, "AvatarType", 0); + pai->format = (pai->hContact == 0) ? PA_FORMAT_PNG : getByte(pai->hContact, "AvatarType", 0); if (::_waccess(pai->filename, 0) == 0) { ptrA szSavedHash( getStringA(pai->hContact, "AvatarSaved")); - if (szSavedHash != NULL && !mir_strcmp(szSavedHash, szHashValue)) { + if (szSavedHash != nullptr && !mir_strcmp(szSavedHash, szHashValue)) { debugLogA("Avatar is Ok: %s == %s", szSavedHash, szHashValue); return GAIR_SUCCESS; } } - if ((wParam & GAIF_FORCE) != 0 && pai->hContact != NULL && m_bJabberOnline) { + if ((wParam & GAIF_FORCE) != 0 && pai->hContact != 0 && m_bJabberOnline) { ptrW tszJid( getWStringA(pai->hContact, "jid")); - if (tszJid != NULL) { + if (tszJid != nullptr) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, tszJid); - if (item != NULL) { + if (item != nullptr) { BOOL isXVcard = getByte(pai->hContact, "AvatarXVcard", 0); wchar_t szJid[JABBER_MAX_JID_LEN]; szJid[0] = 0; - if (item->arResources.getCount() != NULL && !isXVcard) + if (item->arResources.getCount() != 0 && !isXVcard) if (wchar_t *bestResName = ListGetBestClientResourceNamePtr(tszJid)) mir_snwprintf(szJid, L"%s/%s", tszJid, bestResName); @@ -187,7 +187,7 @@ INT_PTR __cdecl CJabberProto::OnGetEventTextChatStates(WPARAM pEvent, LPARAM dat } } - return NULL; + return 0; } //////////////////////////////////////////////////////////////////////////////////////// @@ -244,10 +244,10 @@ INT_PTR __cdecl CJabberProto::JabberSetAvatar(WPARAM, LPARAM lParam) SetServerVcard(TRUE, tszFileName); SendPresence(m_iDesiredStatus, false); } - else if (tszFileName == NULL || tszFileName[0] == 0) { + else if (tszFileName == nullptr || tszFileName[0] == 0) { // Remove avatar wchar_t tFileName[ MAX_PATH ]; - GetAvatarFileName(NULL, tFileName, MAX_PATH); + GetAvatarFileName(0, tFileName, MAX_PATH); DeleteFile(tFileName); delSetting("AvatarSaved"); @@ -262,7 +262,7 @@ INT_PTR __cdecl CJabberProto::JabberSetAvatar(WPARAM, LPARAM lParam) long dwPngSize = _filelength(fileIn); char *pResult = new char[ dwPngSize ]; - if (pResult == NULL) { + if (pResult == nullptr) { _close(fileIn); mir_free(tszFileName); return 2; @@ -278,7 +278,7 @@ INT_PTR __cdecl CJabberProto::JabberSetAvatar(WPARAM, LPARAM lParam) mir_sha1_finish(&sha1ctx, digest); wchar_t tFileName[MAX_PATH]; - GetAvatarFileName(NULL, tFileName, MAX_PATH); + GetAvatarFileName(0, tFileName, MAX_PATH); DeleteFile(tFileName); char buf[MIR_SHA1_HASH_SIZE*2+1]; @@ -286,9 +286,9 @@ INT_PTR __cdecl CJabberProto::JabberSetAvatar(WPARAM, LPARAM lParam) m_options.AvatarType = ProtoGetBufferFormat(pResult); - GetAvatarFileName(NULL, tFileName, MAX_PATH); + GetAvatarFileName(0, tFileName, MAX_PATH); FILE *out = _wfopen(tFileName, L"wb"); - if (out != NULL) { + if (out != nullptr) { fwrite(pResult, dwPngSize, 1, out); fclose(out); } @@ -345,11 +345,11 @@ INT_PTR __cdecl CJabberProto::JabberGCGetToolTipText(WPARAM wParam, LPARAM lPara return 0; //room global tooltip not supported yet JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, (wchar_t*)wParam); - if (item == NULL) + if (item == nullptr) return 0; //no room found pResourceStatus info( item->findResource((wchar_t*)lParam)); - if (info == NULL) + if (info == nullptr) return 0; //no info found // ok process info output will be: @@ -363,7 +363,7 @@ INT_PTR __cdecl CJabberProto::JabberGCGetToolTipText(WPARAM wParam, LPARAM lPara //JID: CMStringW outBuf; - if (wcschr(info->m_tszResourceName, '@') != NULL) + if (wcschr(info->m_tszResourceName, '@') != nullptr) appendString(bIsTipper, LPGENW("JID:"), info->m_tszResourceName, outBuf); else if (lParam) //or simple nick appendString(bIsTipper, LPGENW("Nick:"), (wchar_t*)lParam, outBuf); @@ -386,21 +386,21 @@ INT_PTR __cdecl CJabberProto::JabberGCGetToolTipText(WPARAM wParam, LPARAM lPara if (info->m_tszRealJid) appendString(bIsTipper, LPGENW("Real JID:"), info->m_tszRealJid, outBuf); - return (outBuf.IsEmpty() ? NULL : (INT_PTR)mir_wstrdup(outBuf)); + return (outBuf.IsEmpty() ? 0 : (INT_PTR)mir_wstrdup(outBuf)); } // File Association Manager plugin support INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM, LPARAM lParam) { wchar_t *arg = (wchar_t *)lParam; - if (arg == NULL) + if (arg == nullptr) return 1; // skip leading prefix wchar_t szUri[ 1024 ]; wcsncpy_s(szUri, arg, _TRUNCATE); wchar_t *szJid = wcschr(szUri, ':'); - if (szJid == NULL) + if (szJid == nullptr) return 1; // skip // @@ -417,7 +417,7 @@ INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM, LPARAM lParam) *(szCommand++) = 0; // parameters - wchar_t *szSecondParam = szCommand ? wcschr(szCommand, ';') : NULL; + wchar_t *szSecondParam = szCommand ? wcschr(szCommand, ';') : nullptr; if (szSecondParam) *(szSecondParam++) = 0; @@ -427,11 +427,11 @@ INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM, LPARAM lParam) if (!ServiceExists(MS_MSG_SENDMESSAGEW)) return 1; - wchar_t *szMsgBody = NULL; + wchar_t *szMsgBody = nullptr; MCONTACT hContact = HContactFromJID(szJid, false); - if (hContact == NULL) + if (hContact == 0) hContact = DBCreateContact(szJid, szJid, true, true); - if (hContact == NULL) + if (hContact == 0) return 1; if (szSecondParam) { //there are parameters to message @@ -468,7 +468,7 @@ INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM, LPARAM lParam) // chat join invitation if (!mir_wstrcmpi(szCommand, L"join")) { - GroupchatJoinRoomByJid(NULL, szJid); + GroupchatJoinRoomByJid(nullptr, szJid); return 0; } @@ -484,9 +484,9 @@ INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM, LPARAM lParam) if (!wcsnicmp(szSecondParam, L"node=", 5)) { szSecondParam += 5; if (!*szSecondParam) - szSecondParam = NULL; + szSecondParam = nullptr; } - else szSecondParam = NULL; + else szSecondParam = nullptr; } CJabberAdhocStartupParams* pStartupParams = new CJabberAdhocStartupParams(this, szJid, szSecondParam); ContactMenuRunCommands(0, (LPARAM)pStartupParams); @@ -496,11 +496,11 @@ INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM, LPARAM lParam) // send file if (!mir_wstrcmpi(szCommand, L"sendfile")) { MCONTACT hContact = HContactFromJID(szJid, false); - if (hContact == NULL) + if (hContact == 0) hContact = DBCreateContact(szJid, szJid, true, true); - if (hContact == NULL) + if (hContact == 0) return 1; - CallService(MS_FILE_SENDFILE, hContact, NULL); + CallService(MS_FILE_SENDFILE, hContact, 0); return 0; } @@ -514,7 +514,7 @@ INT_PTR __cdecl CJabberProto::JabberSendNudge(WPARAM hContact, LPARAM) return 0; ptrW jid( getWStringA(hContact, "jid")); - if (jid == NULL) + if (jid == nullptr) return 0; wchar_t tszJid[JABBER_MAX_JID_LEN]; @@ -602,7 +602,7 @@ public: BOOL bRetVal = m_proto->SendHttpAuthReply(m_pParams, bAuthorized); m_pParams->Free(); mir_free(m_pParams); - m_pParams = NULL; + m_pParams = nullptr; return bRetVal; } diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index a5a7945a41..bac0b4b256 100755 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -116,7 +116,7 @@ static INT_PTR CALLBACK JabberPasswordDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa static VOID CALLBACK JabberPasswordCreateDialogApcProc(void* param) { - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_PASSWORD), NULL, JabberPasswordDlgProc, (LPARAM)param); + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_PASSWORD), nullptr, JabberPasswordDlgProc, (LPARAM)param); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -148,8 +148,8 @@ void ThreadData::xmpp_client_query(void) char temp[256]; mir_snprintf(temp, "_xmpp-client._tcp.%s", conn.server); - DNS_RECORDA *results = NULL; - DNS_STATUS status = DnsQuery_A(temp, DNS_TYPE_SRV, DNS_QUERY_STANDARD, NULL, (PDNS_RECORD *)&results, NULL); + DNS_RECORDA *results = nullptr; + DNS_STATUS status = DnsQuery_A(temp, DNS_TYPE_SRV, DNS_QUERY_STANDARD, nullptr, (PDNS_RECORD *)&results, nullptr); if (SUCCEEDED(status) && results) { LIST dnsList(5, CompareDNS); @@ -188,10 +188,10 @@ void CJabberProto::xmlStreamInitializeNow(ThreadData *info) m_szXmlStreamToBeInitialized ? m_szXmlStreamToBeInitialized : "after connect"); if (m_szXmlStreamToBeInitialized) { free(m_szXmlStreamToBeInitialized); - m_szXmlStreamToBeInitialized = NULL; + m_szXmlStreamToBeInitialized = nullptr; } - HXML n = xmlCreateNode(L"xml", NULL, 1) << XATTR(L"version", L"1.0") << XATTR(L"encoding", L"UTF-8"); + HXML n = xmlCreateNode(L"xml", nullptr, 1) << XATTR(L"version", L"1.0") << XATTR(L"encoding", L"UTF-8"); HXML stream = n << XCHILDNS(L"stream:stream", L"jabber:client") << XATTR(L"to", _A2T(info->conn.server)) << XATTR(L"xmlns:stream", L"http://etherx.jabber.org/streams"); @@ -202,7 +202,7 @@ void CJabberProto::xmlStreamInitializeNow(ThreadData *info) if (!m_options.Disable3920auth) XmlAddAttr(stream, L"version", L"1.0"); - LPTSTR xmlQuery = xmlToString(n, NULL); + LPTSTR xmlQuery = xmlToString(n, nullptr); T2Utf buf(xmlQuery); int bufLen = (int)mir_strlen(buf); if (bufLen > 2) { @@ -226,7 +226,7 @@ void CJabberProto::ServerThread(JABBER_CONN_DATA *pParam) if (m_options.ManualConnect == TRUE) { ptrA szManualHost(getStringA("ManualHost")); - if (szManualHost != NULL) + if (szManualHost != nullptr) strncpy_s(info.conn.manualHost, szManualHost, _TRUNCATE); info.conn.port = getWord("ManualPort", JABBER_DEFAULT_PORT); @@ -238,14 +238,14 @@ void CJabberProto::ServerThread(JABBER_CONN_DATA *pParam) if (!info.bIsReg) { // Normal server connection, we will fetch all connection parameters // e.g. username, password, etc. from the database. - if (m_ThreadInfo != NULL) { + if (m_ThreadInfo != nullptr) { debugLogA("Thread ended, another normal thread is running"); return; } m_ThreadInfo = &info; - if ((tszValue = getWStringA("LoginName")) != NULL) + if ((tszValue = getWStringA("LoginName")) != nullptr) wcsncpy_s(info.conn.username, tszValue, _TRUNCATE); if (*rtrimw(info.conn.username) == '\0') { @@ -263,15 +263,15 @@ void CJabberProto::ServerThread(JABBER_CONN_DATA *pParam) LBL_FatalError: int oldStatus = m_iStatus; m_iDesiredStatus = m_iStatus = ID_STATUS_OFFLINE; - ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); + ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); return; } ptrA szValue(getStringA("LoginServer")); - if (szValue != NULL) + if (szValue != nullptr) strncpy_s(info.conn.server, szValue, _TRUNCATE); else { - ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK); + ProtoBroadcastAck(0, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, LOGINERR_NONETWORK); debugLogA("Thread ended, login server is not configured"); goto LBL_FatalError; } @@ -282,7 +282,7 @@ LBL_FatalError: mir_wstrcpy(info.resource, L"Miranda"); } else { - if ((tszValue = getWStringA("Resource")) != NULL) + if ((tszValue = getWStringA("Resource")) != nullptr) wcsncpy_s(info.resource, tszValue, _TRUNCATE); else mir_wstrcpy(info.resource, L"Miranda"); @@ -295,7 +295,7 @@ LBL_FatalError: if (m_options.UseDomainLogin) // in the case of NTLM auth we have no need in password info.conn.password[0] = 0; else if (!m_options.SavePassword) { // we have to enter a password manually. have we done it before? - if (m_savedPassword != NULL) + if (m_savedPassword != nullptr) wcsncpy_s(info.conn.password, m_savedPassword, _TRUNCATE); else { mir_snwprintf(jidStr, L"%s@%S", info.conn.username, info.conn.server); @@ -303,7 +303,7 @@ LBL_FatalError: JabberPasswordDlgParam param; param.pro = this; param.ptszJid = jidStr; - param.hEventPasswdDlg = CreateEvent(NULL, FALSE, FALSE, NULL); + param.hEventPasswdDlg = CreateEvent(nullptr, FALSE, FALSE, nullptr); CallFunctionAsync(JabberPasswordCreateDialogApcProc, ¶m); WaitForSingleObject(param.hEventPasswdDlg, INFINITE); CloseHandle(param.hEventPasswdDlg); @@ -314,13 +314,13 @@ LBL_FatalError: goto LBL_FatalError; } - m_savedPassword = (param.saveOnlinePassword) ? mir_wstrdup(param.onlinePassword) : NULL; + m_savedPassword = (param.saveOnlinePassword) ? mir_wstrdup(param.onlinePassword) : nullptr; wcsncpy_s(info.conn.password, param.onlinePassword, _TRUNCATE); } } else { - ptrW tszPassw(getWStringA(NULL, "Password")); - if (tszPassw == NULL) { + ptrW tszPassw(getWStringA(0, "Password")); + if (tszPassw == nullptr) { JLoginFailed(LOGINERR_BADUSERID); debugLogA("Thread ended, password is not configured"); goto LBL_FatalError; @@ -339,12 +339,12 @@ LBL_FatalError: } int jabberNetworkBufferSize = 2048; - if ((info.buffer = (char*)mir_alloc(jabberNetworkBufferSize + 1)) == NULL) { // +1 is for '\0' when debug logging this buffer + if ((info.buffer = (char*)mir_alloc(jabberNetworkBufferSize + 1)) == nullptr) { // +1 is for '\0' when debug logging this buffer debugLogA("Cannot allocate network buffer, thread ended"); if (info.bIsReg) SendMessage(info.conn.reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 100, (LPARAM)TranslateT("Error: Not enough memory")); else - ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK); + ProtoBroadcastAck(0, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, LOGINERR_NONETWORK); debugLogA("Thread ended, network buffer cannot be allocated"); goto LBL_FatalError; @@ -352,7 +352,7 @@ LBL_FatalError: if (info.conn.manualHost[0] == 0) { info.xmpp_client_query(); - if (info.s == NULL) { + if (info.s == nullptr) { strncpy_s(info.conn.manualHost, info.conn.server, _TRUNCATE); info.s = WsConnect(info.conn.manualHost, info.conn.port); } @@ -360,11 +360,11 @@ LBL_FatalError: else info.s = WsConnect(info.conn.manualHost, info.conn.port); debugLogA("Thread type=%d server='%s' port='%d'", info.bIsReg, info.conn.manualHost, info.conn.port); - if (info.s == NULL) { + if (info.s == nullptr) { debugLogA("Connection failed (%d)", WSAGetLastError()); if (!info.bIsReg) { if (m_ThreadInfo == &info) - ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK); + ProtoBroadcastAck(0, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, LOGINERR_NONETWORK); } else SendMessage(info.conn.reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 100, (LPARAM)TranslateT("Error: Cannot connect to the server")); @@ -375,10 +375,10 @@ LBL_FatalError: // Determine local IP if (info.conn.useSSL) { debugLogA("Intializing SSL connection"); - if (!Netlib_StartSsl(info.s, NULL)) { + if (!Netlib_StartSsl(info.s, nullptr)) { debugLogA("SSL intialization failed"); if (!info.bIsReg) - ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK); + ProtoBroadcastAck(0, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, LOGINERR_NONETWORK); else SendMessage(info.conn.reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 100, (LPARAM)TranslateT("Error: Cannot connect to the server")); @@ -421,7 +421,7 @@ LBL_FatalError: break; else if (nSelRes == 0 && m_bSendKeepAlive) { if (info.jabberServerCaps & JABBER_CAPS_PING) { - CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnPingReply, JABBER_IQ_TYPE_GET, NULL, 0, -1, this); + CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnPingReply, JABBER_IQ_TYPE_GET, nullptr, 0, -1, this); pInfo->SetTimeout(m_options.ConnectionKeepAliveTimeout); info.send(XmlNodeIq(pInfo) << XATTR(L"from", info.fullJID) << XCHILDNS(L"ping", JABBER_FEAT_PING)); } @@ -459,9 +459,9 @@ recvRest: } debugLogA("bytesParsed = %d", bytesParsed); - if (root) tag = NULL; + if (root) tag = nullptr; - if (XmlGetName(root) == NULL) { + if (XmlGetName(root) == nullptr) { for (int i = 0;; i++) { HXML n = XmlGetChild(root, i); if (!n) @@ -480,7 +480,7 @@ recvRest: //jabberNetworkBufferSize += 65536; jabberNetworkBufferSize *= 2; debugLogA("Increasing network buffer size to %d", jabberNetworkBufferSize); - if ((info.buffer = (char*)mir_realloc(info.buffer, jabberNetworkBufferSize + 1)) == NULL) { + if ((info.buffer = (char*)mir_realloc(info.buffer, jabberNetworkBufferSize + 1)) == nullptr) { debugLogA("Cannot reallocate more network buffer, go offline now"); break; } } @@ -507,7 +507,7 @@ recvRest: // Quit all chatrooms (will send quit message) LISTFOREACH(i, this, LIST_CHATROOM) if (JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i)) - GcQuit(item, 0, NULL); + GcQuit(item, 0, nullptr); ListRemoveList(LIST_CHATROOM); ListRemoveList(LIST_BOOKMARK); @@ -517,7 +517,7 @@ recvRest: // Set status to offline int oldStatus = m_iStatus; m_iDesiredStatus = m_iStatus = ID_STATUS_OFFLINE; - ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); + ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); // Set all contacts to offline debugLogA("1"); @@ -526,7 +526,7 @@ recvRest: debugLogA("2"); mir_free(m_szJabberJID); - m_szJabberJID = NULL; + m_szJabberJID = nullptr; m_tmJabberLoggedInTime = 0; ListWipe(); @@ -538,7 +538,7 @@ recvRest: else if (!info.bIsReg) { int oldStatus = m_iStatus; m_iDesiredStatus = m_iStatus = ID_STATUS_OFFLINE; - ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); + ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); } debugLogA("Thread ended: type=%d server='%s'", info.bIsReg, info.conn.server); @@ -550,7 +550,7 @@ recvRest: void CJabberProto::PerformRegistration(ThreadData *info) { iqIdRegGetReg = SerialNext(); - info->send(XmlNodeIq(L"get", iqIdRegGetReg, NULL) << XQUERY(JABBER_FEAT_REGISTER)); + info->send(XmlNodeIq(L"get", iqIdRegGetReg, nullptr) << XQUERY(JABBER_FEAT_REGISTER)); SendMessage(info->conn.reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 50, (LPARAM)TranslateT("Requesting registration instruction...")); } @@ -573,12 +573,12 @@ void CJabberProto::OnProcessStreamOpening(HXML node, ThreadData *info) if (!info->bIsReg) { const wchar_t *sid = XmlGetAttrValue(node, L"id"); - if (sid != NULL) + if (sid != nullptr) info->szStreamId = mir_u2a(sid); } // old server - disable SASL then - if (XmlGetAttrValue(node, L"version") == NULL) + if (XmlGetAttrValue(node, L"version") == nullptr) info->proto->m_options.Disable3920auth = TRUE; if (info->proto->m_options.Disable3920auth) @@ -587,12 +587,12 @@ void CJabberProto::OnProcessStreamOpening(HXML node, ThreadData *info) void CJabberProto::PerformAuthentication(ThreadData *info) { - TJabberAuth* auth = NULL; - char* request = NULL; + TJabberAuth* auth = nullptr; + char* request = nullptr; if (info->auth) { delete info->auth; - info->auth = NULL; + info->auth = nullptr; } if (m_AuthMechs.isSpnegoAvailable) { @@ -600,52 +600,52 @@ void CJabberProto::PerformAuthentication(ThreadData *info) auth = new TNtlmAuth(info, "GSS-SPNEGO"); if (!auth->isValid()) { delete auth; - auth = NULL; + auth = nullptr; } } - if (auth == NULL && m_AuthMechs.isNtlmAvailable) { + if (auth == nullptr && m_AuthMechs.isNtlmAvailable) { m_AuthMechs.isNtlmAvailable = false; auth = new TNtlmAuth(info, "NTLM"); if (!auth->isValid()) { delete auth; - auth = NULL; + auth = nullptr; } } - if (auth == NULL && m_AuthMechs.isKerberosAvailable) { + if (auth == nullptr && m_AuthMechs.isKerberosAvailable) { m_AuthMechs.isKerberosAvailable = false; auth = new TNtlmAuth(info, "GSSAPI", m_AuthMechs.m_gssapiHostName); if (!auth->isValid()) { delete auth; - auth = NULL; + auth = nullptr; } else { request = auth->getInitialRequest(); if (!request) { delete auth; - auth = NULL; + auth = nullptr; } } } - if (auth == NULL && m_AuthMechs.isScramAvailable) { + if (auth == nullptr && m_AuthMechs.isScramAvailable) { m_AuthMechs.isScramAvailable = false; auth = new TScramAuth(info); } - if (auth == NULL && m_AuthMechs.isMd5Available) { + if (auth == nullptr && m_AuthMechs.isMd5Available) { m_AuthMechs.isMd5Available = false; auth = new TMD5Auth(info); } - if (auth == NULL && m_AuthMechs.isPlainAvailable) { + if (auth == nullptr && m_AuthMechs.isPlainAvailable) { m_AuthMechs.isPlainAvailable = false; auth = new TPlainAuth(info, false); } - if (auth == NULL && m_AuthMechs.isPlainOldAvailable) { + if (auth == nullptr && m_AuthMechs.isPlainOldAvailable) { m_AuthMechs.isPlainOldAvailable = false; auth = new TPlainAuth(info, true); } - if (auth == NULL) { + if (auth == nullptr) { if (m_AuthMechs.isAuthAvailable) { // no known mechanisms but iq_auth is available m_AuthMechs.isAuthAvailable = false; PerformIqAuth(info); @@ -654,10 +654,10 @@ void CJabberProto::PerformAuthentication(ThreadData *info) wchar_t text[1024]; mir_snwprintf(text, TranslateT("Authentication failed for %s@%S."), info->conn.username, info->conn.server); - MsgPopup(NULL, text, TranslateT("Jabber Authentication")); + MsgPopup(0, text, TranslateT("Jabber Authentication")); JLoginFailed(LOGINERR_WRONGPASSWORD); info->send(""); - m_ThreadInfo = NULL; + m_ThreadInfo = nullptr; return; } @@ -711,7 +711,7 @@ void CJabberProto::OnProcessFeatures(HXML node, ThreadData *info) m_AuthMechs.isNtlmAvailable = false; m_AuthMechs.isSpnegoAvailable = false; m_AuthMechs.isKerberosAvailable = false; - mir_free(m_AuthMechs.m_gssapiHostName); m_AuthMechs.m_gssapiHostName = NULL; + mir_free(m_AuthMechs.m_gssapiHostName); m_AuthMechs.m_gssapiHostName = nullptr; areMechanismsDefined = true; //JabberLog("%d mechanisms\n",n->numChild); @@ -771,7 +771,7 @@ void CJabberProto::OnProcessFailure(HXML node, ThreadData *info) { const wchar_t *type; //failure xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" - if ((type = XmlGetAttrValue(node, L"xmlns")) == NULL) return; + if ((type = XmlGetAttrValue(node, L"xmlns")) == nullptr) return; if (!mir_wstrcmp(type, L"urn:ietf:params:xml:ns:xmpp-sasl")) { PerformAuthentication(info); } @@ -779,18 +779,13 @@ void CJabberProto::OnProcessFailure(HXML node, ThreadData *info) void CJabberProto::OnProcessError(HXML node, ThreadData *info) { - wchar_t *buff; - int i; - int pos; - bool skipMsg = false; - //failure xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" if (!XmlGetChild(node, 0)) return; - buff = (wchar_t *)mir_alloc(1024 * sizeof(wchar_t)); - pos = 0; - for (i = 0;; i++) { + bool skipMsg = false; + CMStringW buff; + for (int i = 0;; i++) { HXML n = XmlGetChild(node, i); if (!n) break; @@ -798,18 +793,19 @@ void CJabberProto::OnProcessError(HXML node, ThreadData *info) const wchar_t *name = XmlGetName(n); const wchar_t *desc = XmlGetText(n); if (desc) - pos += mir_snwprintf(buff + pos, 1024 - pos, L"%s: %s\r\n", name, desc); + buff.AppendFormat(L"%s: %s\r\n", name, desc); else - pos += mir_snwprintf(buff + pos, 1024 - pos, L"%s\r\n", name); + buff.AppendFormat(L"%s\r\n", name); if (!mir_wstrcmp(name, L"conflict")) - ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_OTHERLOCATION); + ProtoBroadcastAck(0, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, LOGINERR_OTHERLOCATION); else if (!mir_wstrcmp(name, L"see-other-host")) { skipMsg = true; } } - if (!skipMsg) MsgPopup(NULL, buff, TranslateT("Jabber Error")); - mir_free(buff); + if (!skipMsg) + MsgPopup(0, buff, TranslateT("Jabber Error")); + info->send(""); } @@ -819,7 +815,7 @@ void CJabberProto::OnProcessSuccess(HXML node, ThreadData *info) // int iqId; // RECVED: conn.username); xmlStreamInitialize("after successful sasl"); @@ -840,7 +836,7 @@ void CJabberProto::OnProcessSuccess(HXML node, ThreadData *info) void CJabberProto::OnProcessChallenge(HXML node, ThreadData *info) { - if (info->auth == NULL) { + if (info->auth == nullptr) { debugLogA("No previous auth have been made, exiting..."); return; } @@ -894,7 +890,7 @@ void CJabberProto::OnProcessProtocol(HXML node, ThreadData *info) void CJabberProto::OnProcessProceed(HXML node, ThreadData *info) { const wchar_t *type; - if ((type = XmlGetAttrValue(node, L"xmlns")) != NULL && !mir_wstrcmp(type, L"error")) + if ((type = XmlGetAttrValue(node, L"xmlns")) != nullptr && !mir_wstrcmp(type, L"error")) return; if (!mir_wstrcmp(type, L"urn:ietf:params:xml:ns:xmpp-tls")) { @@ -919,7 +915,7 @@ void CJabberProto::OnProcessCompressed(HXML node, ThreadData *info) debugLogA("Compression confirmed"); const wchar_t *type = XmlGetAttrValue(node, L"xmlns"); - if (type != NULL && !mir_wstrcmp(type, L"error")) + if (type != nullptr && !mir_wstrcmp(type, L"error")) return; if (mir_wstrcmp(type, L"http://jabber.org/protocol/compress")) return; @@ -962,7 +958,7 @@ void CJabberProto::OnProcessPubsubEvent(HXML node) if (m_options.EnableUserTune && (itemsNode = XmlGetChildByTag(eventNode, "items", "node", JABBER_FEAT_USER_TUNE))) { // node retract? if (XmlGetChild(itemsNode, "retract")) { - SetContactTune(hContact, NULL, NULL, NULL, NULL, NULL); + SetContactTune(hContact, nullptr, nullptr, nullptr, nullptr, nullptr); return; } @@ -983,7 +979,7 @@ void CJabberProto::OnProcessPubsubEvent(HXML node) mir_snwprintf(szLengthInTime, L"%02d:%02d:%02d", nLength / 3600, (nLength / 60) % 60, nLength % 60); } - SetContactTune(hContact, szArtist, szLength ? szLengthInTime : NULL, szSource, szTitle, szTrack); + SetContactTune(hContact, szArtist, szLength ? szLengthInTime : nullptr, szSource, szTitle, szTrack); } } @@ -1011,11 +1007,11 @@ DWORD JabberGetLastContactMessageTime(MCONTACT hContact) MCONTACT CJabberProto::CreateTemporaryContact(const wchar_t *szJid, JABBER_LIST_ITEM* chatItem) { - if (chatItem == NULL) + if (chatItem == nullptr) return DBCreateContact(szJid, ptrW(JabberNickFromJID(szJid)), true, true); const wchar_t *p = wcschr(szJid, '/'); - if (p != NULL && p[1] != '\0') + if (p != nullptr && p[1] != '\0') p++; else p = szJid; @@ -1036,7 +1032,7 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) return; LPCTSTR from, type = XmlGetAttrValue(node, L"type"); - if ((from = XmlGetAttrValue(node, L"from")) == NULL) + if ((from = XmlGetAttrValue(node, L"from")) == nullptr) return; LPCTSTR idStr = XmlGetAttrValue(node, L"id"); @@ -1064,11 +1060,11 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) return; } - const wchar_t *szMessage = NULL; + const wchar_t *szMessage = nullptr; HXML bodyNode = XmlGetChildByTag(node, "body", "xml:lang", m_tszSelectedLang); - if (bodyNode == NULL) + if (bodyNode == nullptr) bodyNode = XmlGetChild(node, "body"); - if (bodyNode != NULL) + if (bodyNode != nullptr) szMessage = XmlGetText(bodyNode); LPCTSTR ptszSubject = XmlGetText(XmlGetChild(node, "subject")); @@ -1102,17 +1098,17 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) } } - // If message is from a stranger (not in roster), item is NULL + // If message is from a stranger (not in roster), item is nullptr JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, from); - if (item == NULL) + if (item == nullptr) item = ListGetItemPtr(LIST_VCARD_TEMP, from); time_t msgTime = 0; bool isChatRoomInvitation = false; - const wchar_t *inviteRoomJid = NULL; - const wchar_t *inviteFromJid = NULL; - const wchar_t *inviteReason = NULL; - const wchar_t *invitePassword = NULL; + const wchar_t *inviteRoomJid = nullptr; + const wchar_t *inviteFromJid = nullptr; + const wchar_t *inviteReason = nullptr; + const wchar_t *invitePassword = nullptr; bool isDelivered = false; // check chatstates availability @@ -1161,7 +1157,7 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) dbei.cbBlob = 1; dbei.eventType = EVENTTYPE_JABBER_CHATSTATES; dbei.flags = DBEF_READ; - dbei.timestamp = time(NULL); + dbei.timestamp = time(nullptr); dbei.szModule = m_szModuleName; db_event_add(hContact, &dbei); } @@ -1192,13 +1188,13 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) } // parsing extensions - for (int i = 0; (xNode = XmlGetChild(node, i)) != NULL; i++) { + for (int i = 0; (xNode = XmlGetChild(node, i)) != nullptr; i++) { if (m_options.UseOMEMO) { - if ((xNode = XmlGetNthChild(node, L"encrypted", i + 1)) != NULL) + if ((xNode = XmlGetNthChild(node, L"encrypted", i + 1)) != nullptr) { const wchar_t *ptszXmlns = XmlGetAttrValue(xNode, L"xmlns"); - if (ptszXmlns == NULL) + if (ptszXmlns == nullptr) continue; if (!mir_wstrcmp(ptszXmlns, JABBER_FEAT_OMEMO)) @@ -1213,11 +1209,11 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) } } - if ((xNode = XmlGetNthChild(node, L"x", i + 1)) == NULL) + if ((xNode = XmlGetNthChild(node, L"x", i + 1)) == nullptr) continue; const wchar_t *ptszXmlns = XmlGetAttrValue(xNode, L"xmlns"); - if (ptszXmlns == NULL) + if (ptszXmlns == nullptr) continue; if (!mir_wstrcmp(ptszXmlns, JABBER_FEAT_MIRANDA_NOTES)) { @@ -1226,7 +1222,7 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) } else if (!mir_wstrcmp(ptszXmlns, L"jabber:x:encrypted")) { LPCTSTR ptszText = XmlGetText(xNode); - if (ptszText == NULL) + if (ptszText == nullptr) return; //XEP-0027 is not strict enough, different clients have different implementations @@ -1254,7 +1250,7 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) } else if (!mir_wstrcmp(ptszXmlns, JABBER_FEAT_DELAY) && msgTime == 0) { const wchar_t *ptszTimeStamp = XmlGetAttrValue(xNode, L"stamp"); - if (ptszTimeStamp != NULL) + if (ptszTimeStamp != nullptr) msgTime = JabberIsoToUnixTime(ptszTimeStamp); } else if (!mir_wstrcmp(ptszXmlns, JABBER_FEAT_MESSAGE_EVENTS)) { @@ -1267,11 +1263,11 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) // if (jcbCaps && pFromResource && (!(jcbCaps & JABBER_CAPS_MESSAGE_EVENTS))) // pFromResource->m_jcbManualDiscoveredCaps |= (JABBER_CAPS_MESSAGE_EVENTS | JABBER_CAPS_MESSAGE_EVENTS_NO_DELIVERY); - if (bodyNode == NULL) { + if (bodyNode == nullptr) { HXML idNode = XmlGetChild(xNode, "id"); - if (XmlGetChild(xNode, "delivered") != NULL || XmlGetChild(xNode, "offline") != NULL) { + if (XmlGetChild(xNode, "delivered") != nullptr || XmlGetChild(xNode, "offline") != nullptr) { int id = -1; - if (idNode != NULL && XmlGetText(idNode) != NULL) + if (idNode != nullptr && XmlGetText(idNode) != nullptr) if (!wcsncmp(XmlGetText(idNode), _T(JABBER_IQID), mir_strlen(JABBER_IQID))) id = _wtoi((XmlGetText(idNode)) + mir_strlen(JABBER_IQID)); @@ -1279,17 +1275,17 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)id, 0); } - if (hContact && XmlGetChild(xNode, "composing") != NULL) + if (hContact && XmlGetChild(xNode, "composing") != nullptr) CallService(MS_PROTO_CONTACTISTYPING, hContact, 60); // Maybe a cancel to the previous composing HXML child = XmlGetChild(xNode, 0); - if (hContact && (!child || (child && idNode != NULL))) + if (hContact && (!child || (child && idNode != nullptr))) CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_OFF); } else { // Check whether any event is requested - if (!isDelivered && (n = XmlGetChild(xNode, "delivered")) != NULL) { + if (!isDelivered && (n = XmlGetChild(xNode, "delivered")) != nullptr) { isDelivered = true; XmlNode m(L"message"); m << XATTR(L"to", from); @@ -1298,16 +1294,16 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) x << XCHILD(L"id", idStr); info->send(m); } - if (item != NULL && XmlGetChild(xNode, "composing") != NULL) { + if (item != nullptr && XmlGetChild(xNode, "composing") != nullptr) { if (item->messageEventIdStr) mir_free(item->messageEventIdStr); - item->messageEventIdStr = (idStr == NULL) ? NULL : mir_wstrdup(idStr); + item->messageEventIdStr = (idStr == nullptr) ? nullptr : mir_wstrdup(idStr); } } } else if (!mir_wstrcmp(ptszXmlns, JABBER_FEAT_OOB2)) { LPCTSTR ptszUrl = XmlGetText(XmlGetChild(xNode, "url")); - if (ptszUrl != NULL && *ptszUrl) { + if (ptszUrl != nullptr && *ptszUrl) { size_t cbLen = (szMessage ? mir_wstrlen(szMessage) : 0) + mir_wstrlen(ptszUrl) + 32; wchar_t *szTmp = (wchar_t *)alloca(sizeof(wchar_t)* cbLen); mir_wstrcpy(szTmp, ptszUrl); @@ -1320,23 +1316,23 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) } else if (!mir_wstrcmp(ptszXmlns, JABBER_FEAT_MUC_USER)) { HXML inviteNode = XmlGetChild(xNode, L"invite"); - if (inviteNode != NULL) { + if (inviteNode != nullptr) { inviteFromJid = XmlGetAttrValue(inviteNode, L"from"); inviteReason = XmlGetText(XmlGetChild(inviteNode, L"reason")); inviteRoomJid = from; - if (inviteReason == NULL) + if (inviteReason == nullptr) inviteReason = szMessage; isChatRoomInvitation = true; invitePassword = XmlGetText(XmlGetChild(xNode, "password")); } } else if (!mir_wstrcmp(ptszXmlns, JABBER_FEAT_ROSTER_EXCHANGE) && - item != NULL && (item->subscription == SUB_BOTH || item->subscription == SUB_TO)) { + item != nullptr && (item->subscription == SUB_BOTH || item->subscription == SUB_TO)) { wchar_t chkJID[JABBER_MAX_JID_LEN] = L"@"; JabberStripJid(from, chkJID + 1, _countof(chkJID) - 1); for (int j = 1;; j++) { HXML iNode = XmlGetNthChild(xNode, L"item", j); - if (iNode == NULL) + if (iNode == nullptr) break; const wchar_t *action = XmlGetAttrValue(iNode, L"action"); @@ -1360,7 +1356,7 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) else if (!isChatRoomInvitation && !mir_wstrcmp(ptszXmlns, JABBER_FEAT_DIRECT_MUC_INVITE)) { inviteRoomJid = XmlGetAttrValue(xNode, L"jid"); inviteFromJid = from; - if (inviteReason == NULL) + if (inviteReason == nullptr) inviteReason = XmlGetText(xNode); if (!inviteReason) inviteReason = szMessage; @@ -1369,7 +1365,7 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) } if (isChatRoomInvitation) { - if (inviteRoomJid != NULL) { + if (inviteRoomJid != nullptr) { if (m_options.IgnoreMUCInvites) { // FIXME: temporary disabled due to MUC inconsistence on server side /* @@ -1388,7 +1384,7 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) } // all service info was already processed - if (szMessage == NULL) + if (szMessage == nullptr) return; CMStringW tmp(szMessage); @@ -1396,7 +1392,7 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) tmp.Replace(L"\n", L"\r\n"); ptrA buf(mir_utf8encodeW(tmp)); - if (item != NULL) { + if (item != nullptr) { if (pFromResource) { pFromResource->m_bMessageSessionActive = TRUE; @@ -1408,11 +1404,11 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) } // Create a temporary contact, if needed - if (hContact == NULL) + if (hContact == 0) hContact = CreateTemporaryContact(from, chatItem); CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_OFF); - time_t now = time(NULL); + time_t now = time(nullptr); if (!msgTime) msgTime = now; @@ -1422,7 +1418,7 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) PROTORECVEVENT recv = { 0 }; recv.timestamp = (DWORD)msgTime; recv.szMessage = buf; - recv.lParam = (LPARAM)((pFromResource != NULL && m_options.EnableRemoteControl) ? pFromResource->m_tszResourceName : 0); + recv.lParam = (LPARAM)((pFromResource != nullptr && m_options.EnableRemoteControl) ? pFromResource->m_tszResourceName : 0); ProtoChainRecvMsg(hContact, &recv); } @@ -1430,13 +1426,13 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) void CJabberProto::OnProcessPresenceCapabilites(HXML node) { const wchar_t *from = XmlGetAttrValue(node, L"from"); - if (from == NULL) + if (from == nullptr) return; debugLogW(L"presence: for jid %s", from); pResourceStatus r(ResourceInfoFromJID(from)); - if (r == NULL) + if (r == nullptr) return; // XEP-0115 support @@ -1496,15 +1492,17 @@ void CJabberProto::OnProcessPresenceCapabilites(HXML node) void CJabberProto::UpdateJidDbSettings(const wchar_t *jid) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid); - if (item == NULL) return; + if (item == nullptr) + return; MCONTACT hContact = HContactFromJID(jid); - if (hContact == NULL) return; + if (hContact == 0) + return; int status = ID_STATUS_OFFLINE; if (!item->arResources.getCount()) { // set offline only if jid has resources - if (wcschr(jid, '/') == NULL) + if (wcschr(jid, '/') == nullptr) status = item->getTemp()->m_iStatus; if (item->getTemp()->m_tszStatusMessage) db_set_ws(hContact, "CList", "StatusMsg", item->getTemp()->m_tszStatusMessage); @@ -1539,7 +1537,7 @@ void CJabberProto::UpdateJidDbSettings(const wchar_t *jid) } else delSetting(hContact, DBSETTING_DISPLAY_UID); - if (wcschr(jid, '@') != NULL || m_options.ShowTransport == TRUE) + if (wcschr(jid, '@') != nullptr || m_options.ShowTransport == TRUE) if (getWord(hContact, "Status", ID_STATUS_OFFLINE) != status) setWord(hContact, "Status", (WORD)status); @@ -1559,7 +1557,7 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info) return; LPCTSTR from = XmlGetAttrValue(node, L"from"); - if (from == NULL) + if (from == nullptr) return; if (m_presenceManager.HandlePresencePermanent(node, info)) @@ -1581,12 +1579,12 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info) bSelfPresence = true; LPCTSTR type = XmlGetAttrValue(node, L"type"); - if (type == NULL || !mir_wstrcmp(type, L"available")) { + if (type == nullptr || !mir_wstrcmp(type, L"available")) { ptrW nick(JabberNickFromJID(from)); - if (nick == NULL) + if (nick == nullptr) return; - if ((hContact = HContactFromJID(from)) == NULL) { + if ((hContact = HContactFromJID(from)) == 0) { if (!mir_wstrcmpi(info->fullJID, from) || (!bSelfPresence && !ListGetItemPtr(LIST_ROSTER, from))) { debugLogW(L"SKIP Receive presence online from %s (who is not in my roster and not in list - skiping)", from); return; @@ -1619,7 +1617,7 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info) UpdateJidDbSettings(from); - if (wcschr(from, '@') == NULL) { + if (wcschr(from, '@') == nullptr) { UI_SAFE_NOTIFY(m_pDlgServiceDiscovery, WM_JABBER_TRANSPORT_REFRESH); } debugLogW(L"%s (%s) online, set contact status to %s", nick, from, pcli->pfnGetStatusModeDescription(status, 0)); @@ -1629,18 +1627,18 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info) bool bHasAvatar = false, bRemovedAvatar = false; debugLogA("Avatar enabled"); - for (int i = 1; (xNode = XmlGetNthChild(node, L"x", i)) != NULL; i++) { + for (int i = 1; (xNode = XmlGetNthChild(node, L"x", i)) != nullptr; i++) { if (!mir_wstrcmp(XmlGetAttrValue(xNode, L"xmlns"), L"jabber:x:avatar")) { LPCTSTR ptszHash = XmlGetText(XmlGetChild(xNode, "hash")); - if (ptszHash != NULL) { + if (ptszHash != nullptr) { delSetting(hContact, "AvatarXVcard"); debugLogA("AvatarXVcard deleted"); setWString(hContact, "AvatarHash", ptszHash); bHasAvatar = true; ptrW saved(getWStringA(hContact, "AvatarSaved")); - if (saved == NULL || mir_wstrcmp(saved, ptszHash)) { + if (saved == nullptr || mir_wstrcmp(saved, ptszHash)) { debugLogA("Avatar was changed"); - ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, NULL); + ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, nullptr, 0); } } else bRemovedAvatar = true; @@ -1648,19 +1646,19 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info) } if (!bHasAvatar) { //no jabber:x:avatar. try vcard-temp:x:update debugLogA("Not hasXAvatar"); - for (int i = 1; (xNode = XmlGetNthChild(node, L"x", i)) != NULL; i++) { + for (int i = 1; (xNode = XmlGetNthChild(node, L"x", i)) != nullptr; i++) { if (!mir_wstrcmp(XmlGetAttrValue(xNode, L"xmlns"), L"vcard-temp:x:update")) { - if ((xNode = XmlGetChild(xNode, "photo")) != NULL) { + if ((xNode = XmlGetChild(xNode, "photo")) != nullptr) { LPCTSTR txt = XmlGetText(xNode); - if (txt != NULL && txt[0] != 0) { + if (txt != nullptr && txt[0] != 0) { setByte(hContact, "AvatarXVcard", 1); debugLogA("AvatarXVcard set"); setWString(hContact, "AvatarHash", txt); bHasAvatar = true; ptrW saved(getWStringA(hContact, "AvatarSaved")); - if (saved == NULL || mir_wstrcmp(saved, txt)) { + if (saved == nullptr || mir_wstrcmp(saved, txt)) { debugLogA("Avatar was changed. Using vcard-temp:x:update"); - ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, NULL); + ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, nullptr, 0); } } else bRemovedAvatar = true; @@ -1670,9 +1668,9 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info) debugLogA("Has no avatar"); delSetting(hContact, "AvatarHash"); - if (ptrW(getWStringA(hContact, "AvatarSaved")) != NULL) { + if (ptrW(getWStringA(hContact, "AvatarSaved")) != nullptr) { delSetting(hContact, "AvatarSaved"); - ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, NULL, NULL); + ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, nullptr, 0); } } } return; } @@ -1680,7 +1678,7 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info) if (!mir_wstrcmp(type, L"unavailable")) { hContact = HContactFromJID(from); JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, from); - if (item != NULL) { + if (item != nullptr) { ListRemoveResource(LIST_ROSTER, from); hContact = HContactFromJID(from); @@ -1701,7 +1699,7 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info) UpdateJidDbSettings(from); - if (wcschr(from, '@') == NULL) + if (wcschr(from, '@') == nullptr) UI_SAFE_NOTIFY(m_pDlgServiceDiscovery, WM_JABBER_TRANSPORT_REFRESH); DBCheckIsTransportedContact(from, hContact); @@ -1714,24 +1712,24 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info) ptrW tszNick(JabberNickFromJID(from)); HXML xNick = XmlGetChildByTag(node, "nick", "xmlns", JABBER_FEAT_NICK); - if (xNick != NULL) { + if (xNick != nullptr) { LPCTSTR xszNick = XmlGetText(xNick); - if (xszNick != NULL && *xszNick) { + if (xszNick != nullptr && *xszNick) { debugLogW(L"Grabbed nick from presence: %s", xszNick); tszNick = mir_wstrdup(xszNick); } } // automatically send authorization allowed to agent/transport - if (wcschr(from, '@') == NULL || m_options.AutoAcceptAuthorization) { + if (wcschr(from, '@') == nullptr || m_options.AutoAcceptAuthorization) { ListAdd(LIST_ROSTER, from, hContact); info->send(XmlNode(L"presence") << XATTR(L"to", from) << XATTR(L"type", L"subscribed")); if (m_options.AutoAdd == TRUE) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, from); - if (item == NULL || (item->subscription != SUB_BOTH && item->subscription != SUB_TO)) { + if (item == nullptr || (item->subscription != SUB_BOTH && item->subscription != SUB_TO)) { debugLogW(L"Try adding contact automatically jid = %s", from); - if ((hContact = AddToListByJID(from, 0)) != NULL) { + if ((hContact = AddToListByJID(from, 0)) != 0) { if (item) item->hContact = hContact; setWString(hContact, "Nick", tszNick); @@ -1768,7 +1766,7 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info) if (item->subscription == SUB_FROM) item->subscription = SUB_BOTH; else if (item->subscription == SUB_NONE) { item->subscription = SUB_TO; - if (wcschr(from, '@') == NULL) { + if (wcschr(from, '@') == nullptr) { UI_SAFE_NOTIFY(m_pDlgServiceDiscovery, WM_JABBER_TRANSPORT_REFRESH); } } @@ -1783,7 +1781,7 @@ BOOL CJabberProto::OnProcessJingle(HXML node) HXML child = XmlGetChildByTag(node, L"jingle", L"xmlns", JABBER_FEAT_JINGLE); if (child) { - if ((type = XmlGetAttrValue(node, L"type")) == NULL) return FALSE; + if ((type = XmlGetAttrValue(node, L"type")) == nullptr) return FALSE; if ((!mir_wstrcmp(type, L"get") || !mir_wstrcmp(type, L"set"))) { LPCTSTR szAction = XmlGetAttrValue(child, L"action"); LPCTSTR idStr = XmlGetAttrValue(node, L"id"); @@ -1829,7 +1827,7 @@ void CJabberProto::OnProcessIq(HXML node) const wchar_t *type, *xmlns; if (!XmlGetName(node) || mir_wstrcmp(XmlGetName(node), L"iq")) return; - if ((type = XmlGetAttrValue(node, L"type")) == NULL) return; + if ((type = XmlGetAttrValue(node, L"type")) == nullptr) return; int id = JabberGetPacketID(node); @@ -1858,10 +1856,10 @@ void CJabberProto::OnProcessIq(HXML node) LISTFOREACH(i, this, LIST_FILE) { JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i); - if (item->ft != NULL && item->ft->state == FT_CONNECTING && !mir_wstrcmp(tszBuf, item->ft->szId)) { + if (item->ft != nullptr && item->ft->state == FT_CONNECTING && !mir_wstrcmp(tszBuf, item->ft->szId)) { debugLogA("Denying file sending request"); item->ft->state = FT_DENIED; - if (item->ft->hFileEvent != NULL) + if (item->ft->hFileEvent != nullptr) SetEvent(item->ft->hFileEvent); // Simulate the termination of file server connection } } @@ -1900,18 +1898,18 @@ void CJabberProto::OnProcessRegIq(HXML node, ThreadData *info) { if (!XmlGetName(node) || mir_wstrcmp(XmlGetName(node), L"iq")) return; LPCTSTR type = XmlGetAttrValue(node, L"type"); - if (type == NULL) + if (type == nullptr) return; int id = JabberGetPacketID(node); if (!mir_wstrcmp(type, L"result")) { HXML queryNode = XmlGetChild(node, L"query"); - if (queryNode != NULL) { + if (queryNode != nullptr) { LPCTSTR str = XmlGetAttrValue(queryNode, L"xmlns"); if (!mir_wstrcmp(str, JABBER_FEAT_REGISTER)) { HXML xNode = XmlGetChild(queryNode, L"x"); - if (xNode != NULL) { + if (xNode != nullptr) { if (!mir_wstrcmp(XmlGetAttrValue(xNode, L"xmlns"), JABBER_FEAT_DATA_FORMS)) { m_regInfo = info; FormCreateDialog(xNode, L"Jabber register new user", &CJabberProto::SetRegConfig, mir_wstrdup(XmlGetAttrValue(node, L"from"))); @@ -1960,9 +1958,9 @@ ThreadData::ThreadData(CJabberProto *_pro, JABBER_CONN_DATA *param) resolveID = -1; proto = _pro; - iomutex = CreateMutex(NULL, FALSE, NULL); + iomutex = CreateMutex(nullptr, FALSE, nullptr); - if (param != NULL) { + if (param != nullptr) { bIsReg = true; memcpy(&conn, param, sizeof(conn)); } @@ -1971,7 +1969,7 @@ ThreadData::ThreadData(CJabberProto *_pro, JABBER_CONN_DATA *param) ThreadData::~ThreadData() { if (!bIsReg && proto->m_ThreadInfo == this) - proto->m_ThreadInfo = NULL; + proto->m_ThreadInfo = nullptr; delete auth; @@ -1985,7 +1983,7 @@ void ThreadData::close(void) { if (s) { Netlib_CloseHandle(s); - s = NULL; + s = nullptr; } } @@ -1997,7 +1995,7 @@ void ThreadData::shutdown(void) int ThreadData::recvws(char* buf, size_t len, int flags) { - if (this == NULL) + if (this == nullptr) return 0; return proto->WsRecv(s, buf, (int)len, flags); @@ -2018,7 +2016,7 @@ int ThreadData::sendws(char* buf, size_t bufsize, int flags) int ThreadData::send(char* buf, int bufsize) { - if (this == NULL) + if (this == nullptr) return 0; if (bufsize == -1) @@ -2039,7 +2037,7 @@ int ThreadData::send(char* buf, int bufsize) // Caution: DO NOT use ->send() to send binary (non-string) data int ThreadData::send(HXML node) { - if (this == NULL) + if (this == nullptr) return 0; while (HXML parent = xmlGetParent(node)) @@ -2050,7 +2048,7 @@ int ThreadData::send(HXML node) proto->OnConsoleProcessXml(node, JCPF_OUT); - wchar_t *str = xmlToString(node, NULL); + wchar_t *str = xmlToString(node, nullptr); // strip forbidden control characters from outgoing XML stream wchar_t *q = str; diff --git a/protocols/JabberG/src/jabber_treelist.cpp b/protocols/JabberG/src/jabber_treelist.cpp index a31c259683..b486809dec 100644 --- a/protocols/JabberG/src/jabber_treelist.cpp +++ b/protocols/JabberG/src/jabber_treelist.cpp @@ -46,7 +46,7 @@ struct TTreeList_ItemInfo LIST subItems; TTreeList_ItemInfo(int columns = 3, int children = 5): - text(columns), subItems(children), parent(NULL), + text(columns), subItems(children), parent(nullptr), flags(0), indent(0), sortIndex(0), iIcon(0), iOverlay(0), data(0) {} ~TTreeList_ItemInfo() { @@ -68,10 +68,10 @@ struct TTreeList_Data TTreeList_Data() { sortMode = 0; - filter = NULL; + filter = nullptr; mode = TLM_TREE; - root = NULL; - hItemSelected = NULL; + root = nullptr; + hItemSelected = nullptr; } ~TTreeList_Data() { @@ -182,7 +182,7 @@ void TreeList_SetFilter(HWND hwnd, wchar_t *filter) { TTreeList_Data *data = (TTreeList_Data *)sttTreeList_GeWindowData(hwnd); if (data->filter) mir_free(data->filter); - data->filter = NULL; + data->filter = nullptr; if (filter) data->filter = mir_wstrdup(filter); TreeList_Update(hwnd); } @@ -194,7 +194,7 @@ HTREELISTITEM TreeList_GetActiveItem(HWND hwnd) lvi.mask = LVIF_PARAM; lvi.iItem = ListView_GetNextItem(hwnd, -1, LVNI_SELECTED); if (lvi.iItem < 0) - return (data->hItemSelected->flags & TLIF_ROOT) ? NULL : data->hItemSelected; + return (data->hItemSelected->flags & TLIF_ROOT) ? nullptr : data->hItemSelected; ListView_GetItem(hwnd, &lvi); return (HTREELISTITEM)lvi.lParam; } diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp index d8aea4a2cb..a9e09aee42 100755 --- a/protocols/JabberG/src/jabber_userinfo.cpp +++ b/protocols/JabberG/src/jabber_userinfo.cpp @@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber_list.h" -static MWindowList hUserInfoList = NULL; +static MWindowList hUserInfoList = nullptr; struct UserInfoStringBuf { @@ -114,7 +114,7 @@ __forceinline DWORD sttInfoLineId(DWORD res, DWORD type, DWORD line=0) static HTREEITEM sttFindInfoLine(HWND hwndTree, HTREEITEM htiRoot, LPARAM id=INFOLINE_BAD_ID) { - if (id == INFOLINE_BAD_ID) return NULL; + if (id == INFOLINE_BAD_ID) return nullptr; for (HTREEITEM hti = TreeView_GetChild(hwndTree, htiRoot); hti; hti = TreeView_GetNextSibling(hwndTree, hti)) { TVITEMEX tvi = {0}; @@ -124,7 +124,7 @@ static HTREEITEM sttFindInfoLine(HWND hwndTree, HTREEITEM htiRoot, LPARAM id=INF if ((tvi.lParam&INFOLINE_MASK) == (id&INFOLINE_MASK)) return hti; } - return NULL; + return nullptr; } void sttCleanupInfo(HWND hwndTree, int stage) @@ -219,7 +219,7 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti TranslateT("Resource"), r->m_tszResourceName, sttInfoLineId(resource, INFOLINE_NAME), true); // StatusMsg - sttFillInfoLine(hwndTree, htiResource, NULL /*Skin_LoadIcon(SKINICON_EVENT_MESSAGE)*/, + sttFillInfoLine(hwndTree, htiResource, nullptr /*Skin_LoadIcon(SKINICON_EVENT_MESSAGE)*/, TranslateT("Message"), r->m_tszStatusMessage ? r->m_tszStatusMessage : TranslateT(""), sttInfoLineId(resource, INFOLINE_MESSAGE)); @@ -240,13 +240,13 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti // Version const wchar_t *wszVer = pCaps->GetSoftMir() ? pCaps->GetSoftMir() : pCaps->GetSoftVer(); - sttFillInfoLine(hwndTree, htiResource, NULL, TranslateT("Version"), + sttFillInfoLine(hwndTree, htiResource, nullptr, TranslateT("Version"), wszVer ? wszVer : TranslateT(""), sttInfoLineId(resource, INFOLINE_VERSION)); // System wszVer = pCaps->GetOsVer() ? pCaps->GetOsVer() : pCaps->GetOs(); - sttFillInfoLine(hwndTree, htiResource, NULL, TranslateT("System"), + sttFillInfoLine(hwndTree, htiResource, nullptr, TranslateT("System"), wszVer ? wszVer : TranslateT(""), sttInfoLineId(resource, INFOLINE_SYSTEM)); @@ -257,7 +257,7 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti // Resource priority wchar_t szPriority[128]; mir_snwprintf(szPriority, L"%d", (int)r->m_iPriority); - sttFillInfoLine(hwndTree, htiResource, NULL, TranslateT("Resource priority"), szPriority, sttInfoLineId(resource, INFOLINE_PRIORITY)); + sttFillInfoLine(hwndTree, htiResource, nullptr, TranslateT("Resource priority"), szPriority, sttInfoLineId(resource, INFOLINE_PRIORITY)); // Idle if (r->m_dwIdleStartTime > 0) { @@ -271,14 +271,14 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti else mir_wstrncpy(buf, TranslateT(""), _countof(buf)); - sttFillInfoLine(hwndTree, htiResource, NULL, TranslateT("Idle since"), buf, sttInfoLineId(resource, INFOLINE_IDLE)); + sttFillInfoLine(hwndTree, htiResource, nullptr, TranslateT("Idle since"), buf, sttInfoLineId(resource, INFOLINE_IDLE)); // caps mir_snwprintf(buf, L"%s/%s", item->jid, r->m_tszResourceName); JabberCapsBits jcb = ppro->GetResourceCapabilites(buf, TRUE); if (!(jcb & JABBER_RESOURCE_CAPS_ERROR)) { - HTREEITEM htiCaps = sttFillInfoLine(hwndTree, htiResource, ppro->LoadIconEx("main"), NULL, TranslateT("Client capabilities"), sttInfoLineId(resource, INFOLINE_CAPS)); + HTREEITEM htiCaps = sttFillInfoLine(hwndTree, htiResource, ppro->LoadIconEx("main"), nullptr, TranslateT("Client capabilities"), sttInfoLineId(resource, INFOLINE_CAPS)); int i; for (i=0; g_JabberFeatCapPairs[i].szFeature; i++) if (jcb & g_JabberFeatCapPairs[i].jcbCap) { @@ -287,7 +287,7 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti mir_snwprintf(szDescription, L"%s (%s)", TranslateW(g_JabberFeatCapPairs[i].tszDescription), g_JabberFeatCapPairs[i].szFeature); else wcsncpy_s(szDescription, g_JabberFeatCapPairs[i].szFeature, _TRUNCATE); - sttFillInfoLine(hwndTree, htiCaps, NULL, NULL, szDescription, sttInfoLineId(resource, INFOLINE_CAPS, i)); + sttFillInfoLine(hwndTree, htiCaps, nullptr, nullptr, szDescription, sttInfoLineId(resource, INFOLINE_CAPS, i)); } for (int j = 0; j < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); j++, i++) @@ -297,24 +297,24 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti mir_snwprintf(szDescription, L"%s (%s)", TranslateW(ppro->m_lstJabberFeatCapPairsDynamic[j]->szDescription), ppro->m_lstJabberFeatCapPairsDynamic[j]->szFeature); else wcsncpy_s(szDescription, ppro->m_lstJabberFeatCapPairsDynamic[j]->szFeature, _TRUNCATE); - sttFillInfoLine(hwndTree, htiCaps, NULL, NULL, szDescription, sttInfoLineId(resource, INFOLINE_CAPS, i)); + sttFillInfoLine(hwndTree, htiCaps, nullptr, nullptr, szDescription, sttInfoLineId(resource, INFOLINE_CAPS, i)); } } // Software info - HTREEITEM htiSoftwareInfo = sttFillInfoLine(hwndTree, htiResource, ppro->LoadIconEx("main"), NULL, TranslateT("Software information"), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION)); + HTREEITEM htiSoftwareInfo = sttFillInfoLine(hwndTree, htiResource, ppro->LoadIconEx("main"), nullptr, TranslateT("Software information"), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION)); int nLineId = 0; if (CJabberClientPartialCaps *pCaps = r->m_pCaps) { if (pCaps->GetOs()) - sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Operating system"), pCaps->GetOs(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); + sttFillInfoLine(hwndTree, htiSoftwareInfo, nullptr, TranslateT("Operating system"), pCaps->GetOs(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); if (pCaps->GetOsVer()) - sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Operating system version"), pCaps->GetOsVer(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); + sttFillInfoLine(hwndTree, htiSoftwareInfo, nullptr, TranslateT("Operating system version"), pCaps->GetOsVer(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); if (pCaps->GetSoft()) - sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Software"), pCaps->GetSoft(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); + sttFillInfoLine(hwndTree, htiSoftwareInfo, nullptr, TranslateT("Software"), pCaps->GetSoft(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); if (pCaps->GetSoftVer()) - sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Software version"), pCaps->GetSoftVer(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); + sttFillInfoLine(hwndTree, htiSoftwareInfo, nullptr, TranslateT("Software version"), pCaps->GetSoftVer(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); if (pCaps->GetSoftMir()) - sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Miranda core version"), pCaps->GetSoftMir(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); + sttFillInfoLine(hwndTree, htiSoftwareInfo, nullptr, TranslateT("Miranda core version"), pCaps->GetSoftMir(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); } } @@ -344,7 +344,7 @@ static void sttFillUserInfo(CJabberProto *ppro, HWND hwndTree, JABBER_LIST_ITEM sttCleanupInfo(hwndTree, 0); - HTREEITEM htiRoot = sttFillInfoLine(hwndTree, NULL, ppro->LoadIconEx("main"), L"JID", item->jid, sttInfoLineId(0, INFOLINE_NAME), true); + HTREEITEM htiRoot = sttFillInfoLine(hwndTree, nullptr, ppro->LoadIconEx("main"), L"JID", item->jid, sttInfoLineId(0, INFOLINE_NAME), true); wchar_t buf[256]; if (MCONTACT hContact = ppro->HContactFromJID(item->jid)) { @@ -356,16 +356,16 @@ static void sttFillUserInfo(CJabberProto *ppro, HWND hwndTree, JABBER_LIST_ITEM // subscription switch (item->subscription) { case SUB_BOTH: - sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Subscription"), TranslateT("both"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION)); + sttFillInfoLine(hwndTree, htiRoot, nullptr, TranslateT("Subscription"), TranslateT("both"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION)); break; case SUB_TO: - sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Subscription"), TranslateT("to"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION)); + sttFillInfoLine(hwndTree, htiRoot, nullptr, TranslateT("Subscription"), TranslateT("to"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION)); break; case SUB_FROM: - sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Subscription"), TranslateT("from"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION)); + sttFillInfoLine(hwndTree, htiRoot, nullptr, TranslateT("Subscription"), TranslateT("from"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION)); break; default: - sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Subscription"), TranslateT("none"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION)); + sttFillInfoLine(hwndTree, htiRoot, nullptr, TranslateT("Subscription"), TranslateT("none"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION)); break; } @@ -382,11 +382,11 @@ static void sttFillUserInfo(CJabberProto *ppro, HWND hwndTree, JABBER_LIST_ITEM else mir_wstrncpy(buf, TranslateT(""), _countof(buf)); - sttFillInfoLine(hwndTree, htiRoot, NULL, + sttFillInfoLine(hwndTree, htiRoot, nullptr, (item->jid && wcschr(item->jid, '@')) ? TranslateT("Last logoff time") : TranslateT("Uptime"), buf, sttInfoLineId(0, INFOLINE_LOGOFF)); - sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Logoff message"), + sttFillInfoLine(hwndTree, htiRoot, nullptr, TranslateT("Logoff message"), r->m_tszStatusMessage ? r->m_tszStatusMessage : TranslateT(""), sttInfoLineId(0, INFOLINE_LOGOFF_MSG)); // activity @@ -395,7 +395,7 @@ static void sttFillUserInfo(CJabberProto *ppro, HWND hwndTree, JABBER_LIST_ITEM else mir_wstrncpy(buf, TranslateT(""), _countof(buf)); - sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Last active resource"), buf, + sttFillInfoLine(hwndTree, htiRoot, nullptr, TranslateT("Last active resource"), buf, sttInfoLineId(0, INFOLINE_LASTACTIVE)); // resources @@ -409,7 +409,7 @@ static void sttFillUserInfo(CJabberProto *ppro, HWND hwndTree, JABBER_LIST_ITEM sttCleanupInfo(hwndTree, 1); SendMessage(hwndTree, WM_SETREDRAW, TRUE, 0); - RedrawWindow(hwndTree, NULL, NULL, RDW_INVALIDATE); + RedrawWindow(hwndTree, nullptr, nullptr, RDW_INVALIDATE); } static void sttGetNodeText(HWND hwndTree, HTREEITEM hti, UserInfoStringBuf *buf, int indent = 0) @@ -468,28 +468,28 @@ static INT_PTR CALLBACK JabberUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa case WM_JABBER_CHECK_ONLINE: if (dat && dat->ppro) if (!dat->ppro->m_bJabberOnline) { - dat->item = NULL; + dat->item = nullptr; break; } // fall through case WM_JABBER_REFRESH: - if (dat == NULL) break; + if (dat == nullptr) break; - if (dat->item == NULL) { + if (dat->item == nullptr) { ptrW jid(dat->ppro->getWStringA(dat->hContact, "jid")); - if (jid == NULL) + if (jid == nullptr) break; if (dat->ppro->m_bJabberOnline) if (!(dat->item = dat->ppro->ListGetItemPtr(LIST_VCARD_TEMP, jid))) dat->item = dat->ppro->ListGetItemPtr(LIST_ROSTER, jid); - if (dat->item == NULL) { + if (dat->item == nullptr) { HWND hwndTree = GetDlgItem(hwndDlg, IDC_TV_INFO); TreeView_DeleteAllItems(hwndTree); - HTREEITEM htiRoot = sttFillInfoLine(hwndTree, NULL, dat->ppro->LoadIconEx("main"), L"JID", jid, sttInfoLineId(0, INFOLINE_NAME), true); - sttFillInfoLine(hwndTree, htiRoot, dat->ppro->LoadIconEx("vcard"), NULL, + HTREEITEM htiRoot = sttFillInfoLine(hwndTree, nullptr, dat->ppro->LoadIconEx("main"), L"JID", jid, sttInfoLineId(0, INFOLINE_NAME), true); + sttFillInfoLine(hwndTree, htiRoot, dat->ppro->LoadIconEx("vcard"), nullptr, TranslateT("Please switch online to see more details.")); break; } @@ -530,9 +530,9 @@ static INT_PTR CALLBACK JabberUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa HMENU hMenu = CreatePopupMenu(); AppendMenu(hMenu, MF_STRING, (UINT_PTR)1, TranslateT("Copy")); AppendMenu(hMenu, MF_STRING, (UINT_PTR)2, TranslateT("Copy only this value")); - AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); + AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr); AppendMenu(hMenu, MF_STRING, (UINT_PTR)0, TranslateT("Cancel")); - int nReturnCmd = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL); + int nReturnCmd = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, nullptr); if (nReturnCmd == 1) { UserInfoStringBuf buf; sttGetNodeText(hwndTree, hItem, &buf); @@ -566,9 +566,9 @@ static INT_PTR CALLBACK JabberUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa case PSN_PARAMCHANGED: dat->ppro = (CJabberProto*)((PSHNOTIFY*)lParam)->lParam; - if (dat->hContact != NULL) { + if (dat->hContact != 0) { ptrW jid(dat->ppro->getWStringA(dat->hContact, "jid")); - if (jid != NULL) + if (jid != nullptr) if (!(dat->item = dat->ppro->ListGetItemPtr(LIST_VCARD_TEMP, jid))) dat->item = dat->ppro->ListGetItemPtr(LIST_ROSTER, jid); } @@ -590,7 +590,7 @@ static INT_PTR CALLBACK JabberUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); } WindowList_Remove(hUserInfoList, hwndDlg); - ImageList_Destroy(TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TV_INFO), NULL, TVSIL_NORMAL)); + ImageList_Destroy(TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TV_INFO), nullptr, TVSIL_NORMAL)); Window_FreeIcon_IcoLib(hwndDlg); break; } @@ -617,8 +617,8 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wP TranslateDialogDefault(hwndDlg); photoInfo = (USER_PHOTO_INFO *)mir_alloc(sizeof(USER_PHOTO_INFO)); photoInfo->hContact = lParam; - photoInfo->ppro = NULL; - photoInfo->hBitmap = NULL; + photoInfo->ppro = nullptr; + photoInfo->hBitmap = nullptr; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)photoInfo); SendDlgItemMessage(hwndDlg, IDC_SAVE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_LoadIconEx("save")); SendDlgItemMessage(hwndDlg, IDC_SAVE, BUTTONSETASFLATBTN, TRUE, 0); @@ -645,16 +645,16 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wP case WM_JABBER_REFRESH: if (photoInfo->hBitmap) { DeleteObject(photoInfo->hBitmap); - photoInfo->hBitmap = NULL; + photoInfo->hBitmap = nullptr; } ShowWindow(GetDlgItem(hwndDlg, IDC_SAVE), SW_HIDE); { ptrW jid(photoInfo->ppro->getWStringA(photoInfo->hContact, "jid")); - if (jid != NULL) { + if (jid != nullptr) { JABBER_LIST_ITEM *item = photoInfo->ppro->ListGetItemPtr(LIST_VCARD_TEMP, jid); - if (item == NULL) + if (item == nullptr) item = photoInfo->ppro->ListGetItemPtr(LIST_ROSTER, jid); - if (item != NULL) { + if (item != nullptr) { if (item->photoFileName) { photoInfo->ppro->debugLogW(L"Showing picture from %s", item->photoFileName); photoInfo->hBitmap = Bitmap_Load(item->photoFileName); @@ -664,7 +664,7 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wP } } } - InvalidateRect(hwndDlg, NULL, TRUE); + InvalidateRect(hwndDlg, nullptr, TRUE); UpdateWindow(hwndDlg); break; @@ -674,12 +674,12 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wP static wchar_t szFilter[512]; ptrW jid(photoInfo->ppro->getWStringA(photoInfo->hContact, "jid")); - if (jid == NULL) + if (jid == nullptr) break; JABBER_LIST_ITEM *item = photoInfo->ppro->ListGetItemPtr(LIST_VCARD_TEMP, jid); - if (item == NULL) - if ((item = photoInfo->ppro->ListGetItemPtr(LIST_ROSTER, jid)) == NULL) + if (item == nullptr) + if ((item = photoInfo->ppro->ListGetItemPtr(LIST_ROSTER, jid)) == nullptr) break; switch (ProtoGetAvatarFileFormat(item->photoFileName)) { @@ -738,7 +738,7 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wP ptOrg.x = ptOrg.y = 0; DPtoLP(hdcMem, &ptOrg, 1); GetClientRect(hwndCanvas, &rect); - InvalidateRect(hwndCanvas, NULL, TRUE); + InvalidateRect(hwndCanvas, nullptr, TRUE); UpdateWindow(hwndCanvas); if (ptSize.x <= rect.right && ptSize.y <= rect.bottom) { pt.x = (rect.right - ptSize.x) / 2; @@ -810,14 +810,14 @@ int CJabberProto::OnUserInfoInit(WPARAM wParam, LPARAM lParam) return 0; MCONTACT hContact = lParam; - if (hContact == NULL) { + if (hContact == 0) { // Show our vcard OnUserInfoInit_VCard(wParam, lParam); return 0; } char *szProto = GetContactProto(hContact); - if (szProto != NULL && !mir_strcmp(szProto, m_szModuleName)) { + if (szProto != nullptr && !mir_strcmp(szProto, m_szModuleName)) { OPTIONSDIALOGPAGE odp = { 0 }; odp.hInstance = hInst; odp.dwInitParam = (LPARAM)this; diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 656958030b..38b4d0bcc4 100755 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -37,10 +37,10 @@ int CJabberProto::SerialNext(void) MCONTACT CJabberProto::ChatRoomHContactFromJID(const wchar_t *jid) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, jid); - if (item != NULL && item->hContact) + if (item != nullptr && item->hContact) return item->hContact; - return NULL; + return 0; } /////////////////////////////////////////////////////////////////////////////// @@ -48,49 +48,49 @@ MCONTACT CJabberProto::ChatRoomHContactFromJID(const wchar_t *jid) MCONTACT CJabberProto::HContactFromJID(const wchar_t *jid, bool bStripResource) { - if (jid == NULL) - return NULL; + if (jid == nullptr) + return 0; JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid); - if (item != NULL && item->hContact) + if (item != nullptr && item->hContact) return item->hContact; if (bStripResource) { wchar_t szJid[JABBER_MAX_JID_LEN]; JabberStripJid(jid, szJid, _countof(szJid)); item = ListGetItemPtr(LIST_ROSTER, szJid); - if (item != NULL && item->hContact) + if (item != nullptr && item->hContact) return item->hContact; } - return NULL; + return 0; } wchar_t* __stdcall JabberNickFromJID(const wchar_t *jid) { - if (jid == NULL) + if (jid == nullptr) return mir_wstrdup(L""); const wchar_t *p = wcschr(jid, '@'); - if (p == NULL) + if (p == nullptr) p = wcschr(jid, '/'); - return (p != NULL) ? mir_wstrndup(jid, p - jid) : mir_wstrdup(jid); + return (p != nullptr) ? mir_wstrndup(jid, p - jid) : mir_wstrdup(jid); } pResourceStatus CJabberProto::ResourceInfoFromJID(const wchar_t *jid) { - if (jid == NULL) - return NULL; + if (jid == nullptr) + return nullptr; JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_VCARD_TEMP, jid); - if (item == NULL) + if (item == nullptr) item = ListGetItemPtr(LIST_ROSTER, jid); - if (item == NULL) - return NULL; + if (item == nullptr) + return nullptr; const wchar_t *p = wcschr(jid, '/'); - if (p == NULL) + if (p == nullptr) return item->getTemp(); return item->findResource(p + 1); @@ -98,9 +98,9 @@ pResourceStatus CJabberProto::ResourceInfoFromJID(const wchar_t *jid) wchar_t* JabberPrepareJid(LPCTSTR jid) { - if (jid == NULL) return NULL; + if (jid == nullptr) return nullptr; wchar_t *szNewJid = mir_wstrdup(jid); - if (!szNewJid) return NULL; + if (!szNewJid) return nullptr; wchar_t *pDelimiter = wcschr(szNewJid, '/'); if (pDelimiter) *pDelimiter = 0; CharLower(szNewJid); @@ -110,7 +110,7 @@ wchar_t* JabberPrepareJid(LPCTSTR jid) void __stdcall JabberUrlDecodeW(WCHAR *str) { - if (str == NULL) + if (str == nullptr) return; WCHAR *p, *q; @@ -144,8 +144,8 @@ char* __stdcall JabberSha1(const char *str, JabberShaStrBuf buf) wchar_t* __stdcall JabberStrFixLines(const wchar_t *str) { - if (str == NULL) - return NULL; + if (str == nullptr) + return nullptr; const wchar_t *p; int add = 0; @@ -178,7 +178,7 @@ void __stdcall JabberHttpUrlDecode(wchar_t *str) wchar_t *p, *q; unsigned int code; - if (str == NULL) return; + if (str == nullptr) return; for (p = q = (wchar_t*)str; *p != '\0'; p++, q++) { if (*p == '%' && *(p + 1) != '\0' && isxdigit(*(p + 1)) && *(p + 2) != '\0' && isxdigit(*(p + 2))) { swscanf((wchar_t*)p + 1, L"%2x", &code); @@ -255,7 +255,7 @@ wchar_t* __stdcall JabberErrorStr(int errorCode) wchar_t* __stdcall JabberErrorMsg(HXML errorNode, int* pErrorCode) { wchar_t *errorStr = (wchar_t*)mir_alloc(256 * sizeof(wchar_t)); - if (errorNode == NULL) { + if (errorNode == nullptr) { if (pErrorCode) *pErrorCode = -1; mir_snwprintf(errorStr, 256, L"%s -1: %s", TranslateT("Error"), TranslateT("Unknown error message")); @@ -264,16 +264,16 @@ wchar_t* __stdcall JabberErrorMsg(HXML errorNode, int* pErrorCode) int errorCode = -1; const wchar_t *str = XmlGetAttrValue(errorNode, L"code"); - if (str != NULL) + if (str != nullptr) errorCode = _wtoi(str); str = XmlGetText(errorNode); - if (str == NULL) + if (str == nullptr) str = XmlGetText(XmlGetChild(errorNode, L"text")); - if (str == NULL) { + if (str == nullptr) { for (int i = 0;; i++) { HXML c = XmlGetChild(errorNode, i); - if (c == NULL) break; + if (c == nullptr) break; const wchar_t *attr = XmlGetAttrValue(c, L"xmlns"); if (attr && !mir_wstrcmp(attr, L"urn:ietf:params:xml:ns:xmpp-stanzas")) { str = XmlGetName(c); @@ -282,7 +282,7 @@ wchar_t* __stdcall JabberErrorMsg(HXML errorNode, int* pErrorCode) } } - if (str != NULL) + if (str != nullptr) mir_snwprintf(errorStr, 256, L"%s %d: %s\r\n%s", TranslateT("Error"), errorCode, TranslateW(JabberErrorStr(errorCode)), str); else mir_snwprintf(errorStr, 256, L"%s %d: %s", TranslateT("Error"), errorCode, TranslateW(JabberErrorStr(errorCode))); @@ -299,18 +299,18 @@ void CJabberProto::SendVisibleInvisiblePresence(BOOL invisible) LISTFOREACH(i, this, LIST_ROSTER) { JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i); - if (item == NULL) + if (item == nullptr) continue; MCONTACT hContact = HContactFromJID(item->jid); - if (hContact == NULL) + if (hContact == 0) continue; WORD apparentMode = getWord(hContact, "ApparentMode", 0); if (invisible == TRUE && apparentMode == ID_STATUS_OFFLINE) m_ThreadInfo->send(XmlNode(L"presence") << XATTR(L"to", item->jid) << XATTR(L"type", L"invisible")); else if (invisible == FALSE && apparentMode == ID_STATUS_ONLINE) - SendPresenceTo(m_iStatus, item->jid, NULL); + SendPresenceTo(m_iStatus, item->jid, nullptr); } } @@ -319,7 +319,7 @@ time_t __stdcall JabberIsoToUnixTime(const wchar_t *stamp) wchar_t date[9]; int i, y; - if (stamp == NULL) + if (stamp == nullptr) return 0; const wchar_t *p = stamp; @@ -377,7 +377,7 @@ void CJabberProto::SendPresenceTo(int status, const wchar_t* to, HXML extra, con _itow(iPriority, szPriority, 10); XmlNode p(L"presence"); p << XCHILD(L"priority", szPriority); - if (to != NULL) + if (to != nullptr) p << XATTR(L"to", to); if (extra) @@ -445,7 +445,7 @@ void CJabberProto::SendPresenceTo(int status, const wchar_t* to, HXML extra, con HXML x = p << XCHILDNS(L"x", L"vcard-temp:x:update"); ptrA hashValue(getStringA("AvatarHash")); - if (hashValue != NULL) // XEP-0153: vCard-Based Avatars + if (hashValue != nullptr) // XEP-0153: vCard-Based Avatars x << XCHILD(L"photo", _A2T(hashValue)); else x << XCHILD(L"photo"); @@ -491,7 +491,7 @@ void CJabberProto::SendPresenceTo(int status, const wchar_t* to, HXML extra, con void CJabberProto::SendPresence(int status, bool bSendToAll) { - SendPresenceTo(status, NULL, NULL); + SendPresenceTo(status, nullptr, nullptr); SendVisibleInvisiblePresence(status == ID_STATUS_INVISIBLE); // Also update status in all chatrooms @@ -499,10 +499,10 @@ void CJabberProto::SendPresence(int status, bool bSendToAll) LISTFOREACH(i, this, LIST_CHATROOM) { JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i); - if (item != NULL && item->nick != NULL) { + if (item != nullptr && item->nick != nullptr) { wchar_t text[1024]; mir_snwprintf(text, L"%s/%s", item->jid, item->nick); - SendPresenceTo(status == ID_STATUS_INVISIBLE ? ID_STATUS_ONLINE : status, text, NULL); + SendPresenceTo(status == ID_STATUS_INVISIBLE ? ID_STATUS_ONLINE : status, text, nullptr); } } } @@ -533,8 +533,8 @@ wchar_t* __stdcall JabberId2string(int id) wchar_t* CJabberProto::GetClientJID(MCONTACT hContact, wchar_t *dest, size_t destLen) { - if (hContact == NULL) - return NULL; + if (hContact == 0) + return nullptr; ptrW jid(getWStringA(hContact, "jid")); return GetClientJID(jid, dest, destLen); @@ -542,18 +542,18 @@ wchar_t* CJabberProto::GetClientJID(MCONTACT hContact, wchar_t *dest, size_t des wchar_t* CJabberProto::GetClientJID(const wchar_t *jid, wchar_t *dest, size_t destLen) { - if (jid == NULL) - return NULL; + if (jid == nullptr) + return nullptr; wcsncpy_s(dest, destLen, jid, _TRUNCATE); wchar_t *p = wcschr(dest, '/'); mir_cslock lck(m_csLists); JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, jid); - if (LI != NULL) { - if (p == NULL) { + if (LI != nullptr) { + if (p == nullptr) { pResourceStatus r(LI->getBestResource()); - if (r != NULL) + if (r != nullptr) mir_snwprintf(dest, destLen, L"%s/%s", jid, r->m_tszResourceName); } } @@ -566,13 +566,13 @@ wchar_t* CJabberProto::GetClientJID(const wchar_t *jid, wchar_t *dest, size_t de wchar_t* __stdcall JabberStripJid(const wchar_t *jid, wchar_t *dest, size_t destLen) { - if (jid == NULL) + if (jid == nullptr) *dest = 0; else { wcsncpy_s(dest, destLen, jid, _TRUNCATE); wchar_t *p = wcschr(dest, '/'); - if (p != NULL) + if (p != nullptr) *p = 0; } @@ -595,15 +595,15 @@ LPCTSTR __stdcall JabberGetPictureType(HXML node, const char *picBuf) // TStringPairs class members TStringPairs::TStringPairs(char* buffer) : - elems(NULL) + elems(nullptr) { TStringPairsElem tempElem[100]; char* token = strtok(buffer, ","); - for (numElems = 0; token != NULL; numElems++) { + for (numElems = 0; token != nullptr; numElems++) { char* p = strchr(token, '='), *p1; - if (p == NULL) + if (p == nullptr) break; while (isspace(*token)) @@ -611,16 +611,16 @@ TStringPairs::TStringPairs(char* buffer) : tempElem[numElems].name = rtrim(token); *p++ = 0; - if ((p1 = strchr(p, '\"')) != NULL) { + if ((p1 = strchr(p, '\"')) != nullptr) { *p1 = 0; p = p1 + 1; } - if ((p1 = strrchr(p, '\"')) != NULL) + if ((p1 = strrchr(p, '\"')) != nullptr) *p1 = 0; tempElem[numElems].value = rtrim(p); - token = strtok(NULL, ","); + token = strtok(nullptr, ","); } if (numElems) { @@ -652,7 +652,7 @@ void CJabberProto::ComboLoadRecentStrings(HWND hwndDlg, UINT idcCombo, char *par char setting[MAXMODULELABELLENGTH]; mir_snprintf(setting, "%s%d", param, i); ptrW tszRecent(getWStringA(setting)); - if (tszRecent != NULL) + if (tszRecent != nullptr) SendDlgItemMessage(hwndDlg, idcCombo, CB_ADDSTRING, 0, tszRecent); } @@ -717,13 +717,14 @@ static VOID CALLBACK sttRebuildInfoFrameApcProc(void* param) ppro->m_pInfoFrame->CreateInfoItem("$/Transports", false); ppro->m_pInfoFrame->UpdateInfoItem("$/Transports", ppro->GetIconHandle(IDI_TRANSPORT), TranslateT("Transports")); - JABBER_LIST_ITEM *item = NULL; + JABBER_LIST_ITEM *item = nullptr; LISTFOREACH(i, ppro, LIST_ROSTER) { - if ((item = ppro->ListGetItemPtrFromIndex(i)) != NULL) { - if (wcschr(item->jid, '@') == NULL && wcschr(item->jid, '/') == NULL && item->subscription != SUB_NONE) { + if ((item = ppro->ListGetItemPtrFromIndex(i)) != nullptr) { + if (wcschr(item->jid, '@') == nullptr && wcschr(item->jid, '/') == nullptr && item->subscription != SUB_NONE) { MCONTACT hContact = ppro->HContactFromJID(item->jid); - if (hContact == NULL) continue; + if (hContact == 0) + continue; char name[128]; char *jid_copy = mir_u2a(item->jid); @@ -781,7 +782,7 @@ const wchar_t *JabberStrIStr(const wchar_t *str, const wchar_t *substr) CharUpperBuff(substr_up, (DWORD)mir_wstrlen(substr_up)); wchar_t *p = wcsstr(str_up, substr_up); - return p ? (str + (p - str_up)) : NULL; + return p ? (str + (p - str_up)) : nullptr; } //////////////////////////////////////////////////////////////////////// @@ -804,7 +805,7 @@ void JabberCopyText(HWND hwnd, const wchar_t *text) BOOL CJabberProto::EnterString(CMStringW &result, LPCTSTR caption, int type, char *windowName, int recentCount, int timeout) { - if (caption == NULL) { + if (caption == nullptr) { caption = NEWWSTR_ALLOCA(result.GetString()); result.Empty(); } @@ -831,11 +832,11 @@ BOOL CJabberProto::EnterString(CMStringW &result, LPCTSTR caption, int type, cha bool JabberReadXep203delay(HXML node, time_t &msgTime) { HXML n = XmlGetChildByTag(node, "delay", "xmlns", L"urn:xmpp:delay"); - if (n == NULL) + if (n == nullptr) return false; const wchar_t *ptszTimeStamp = XmlGetAttrValue(n, L"stamp"); - if (ptszTimeStamp == NULL) + if (ptszTimeStamp == nullptr) return false; // skip '-' chars @@ -853,15 +854,15 @@ bool JabberReadXep203delay(HXML node, time_t &msgTime) bool CJabberProto::IsMyOwnJID(LPCTSTR szJID) { - if (m_ThreadInfo == NULL) + if (m_ThreadInfo == nullptr) return false; ptrW szFrom(JabberPrepareJid(szJID)); - if (szFrom == NULL) + if (szFrom == nullptr) return false; ptrW szTo(JabberPrepareJid(m_ThreadInfo->fullJID)); - if (szTo == NULL) + if (szTo == nullptr) return false; wchar_t *pDelimiter = wcschr(szFrom, '/'); @@ -880,7 +881,7 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param) Thread_SetName("Jabber: LoadHttpAvatars"); OBJLIST &avs = *(OBJLIST*)param; - HNETLIBCONN hHttpCon = NULL; + HNETLIBCONN hHttpCon = nullptr; for (int i = 0; i < avs.getCount(); i++) { NETLIBHTTPREQUEST nlhr = { 0 }; nlhr.cbSize = sizeof(nlhr); @@ -916,12 +917,12 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param) bin2hex(digest, sizeof(digest), buffer); ptrA cmpsha(getStringA(ai.hContact, "AvatarSaved")); - if (cmpsha == NULL || strnicmp(cmpsha, buffer, sizeof(buffer))) { + if (cmpsha == nullptr || strnicmp(cmpsha, buffer, sizeof(buffer))) { wchar_t tszFileName[MAX_PATH]; GetAvatarFileName(ai.hContact, tszFileName, _countof(tszFileName)); wcsncpy_s(ai.filename, tszFileName, _TRUNCATE); FILE* out = _wfopen(tszFileName, L"wb"); - if (out != NULL) { + if (out != nullptr) { fwrite(res->pData, res->dataLength, 1, out); fclose(out); setString(ai.hContact, "AvatarSaved", buffer); @@ -934,7 +935,7 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param) } Netlib_FreeHttpRequest(res); } - else hHttpCon = NULL; + else hHttpCon = nullptr; } delete &avs; if (hHttpCon) diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp index 4cbf98bf75..98ee39ddd1 100644 --- a/protocols/JabberG/src/jabber_vcard.cpp +++ b/protocols/JabberG/src/jabber_vcard.cpp @@ -47,7 +47,7 @@ int CJabberProto::SendGetVcard(const wchar_t *jid) static void SetDialogField(CJabberProto *ppro, HWND hwndDlg, int nDlgItem, char* key, bool bTranslate = false) { ptrW tszValue(ppro->getWStringA(key)); - if (tszValue != NULL) + if (tszValue != nullptr) SetDlgItemText(hwndDlg, nDlgItem, (bTranslate) ? TranslateW(tszValue) : tszValue); else SetDlgItemTextA(hwndDlg, nDlgItem, ""); @@ -272,7 +272,7 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR { dat = new PhotoDlgProcData; dat->ppro = (CJabberProto*)lParam; - dat->hBitmap = NULL; + dat->hBitmap = nullptr; dat->ppro->m_bPhotoChanged = FALSE; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->ppro->WindowSubscribe(hwndDlg); @@ -283,19 +283,19 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case WM_JABBER_REFRESH_VCARD: if (dat->hBitmap) { DeleteObject(dat->hBitmap); - dat->hBitmap = NULL; + dat->hBitmap = nullptr; DeleteFile(dat->ppro->m_szPhotoFileName); dat->ppro->m_szPhotoFileName[0] = '\0'; } EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), FALSE); - dat->ppro->GetAvatarFileName(NULL, szAvatarFileName, _countof(szAvatarFileName)); + dat->ppro->GetAvatarFileName(0, szAvatarFileName, _countof(szAvatarFileName)); if (_waccess(szAvatarFileName, 0) == 0) { if (GetTempPath(_countof(szTempPath), szTempPath) <= 0) mir_wstrcpy(szTempPath, L".\\"); if (GetTempFileName(szTempPath, L"jab", 0, szTempFileName) > 0) { dat->ppro->debugLogW(L"Temp file = %s", szTempFileName); if (CopyFile(szAvatarFileName, szTempFileName, FALSE) == TRUE) { - if ((dat->hBitmap = Bitmap_Load(szTempFileName)) != NULL) { + if ((dat->hBitmap = Bitmap_Load(szTempFileName)) != nullptr) { FIP->FI_Premultiply(dat->hBitmap); mir_wstrcpy(dat->ppro->m_szPhotoFileName, szTempFileName); EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE); @@ -307,7 +307,7 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } dat->ppro->m_bPhotoChanged = FALSE; - InvalidateRect(hwndDlg, NULL, TRUE); + InvalidateRect(hwndDlg, nullptr, TRUE); UpdateWindow(hwndDlg); break; @@ -320,12 +320,12 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case IDC_DELETE: if (dat->hBitmap) { DeleteObject(dat->hBitmap); - dat->hBitmap = NULL; + dat->hBitmap = nullptr; DeleteFile(dat->ppro->m_szPhotoFileName); dat->ppro->m_szPhotoFileName[0] = '\0'; dat->ppro->m_bPhotoChanged = TRUE; EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), FALSE); - InvalidateRect(hwndDlg, NULL, TRUE); + InvalidateRect(hwndDlg, nullptr, TRUE); UpdateWindow(hwndDlg); dat->ppro->m_vCardUpdates |= (1UL << iPageId); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); @@ -340,7 +340,7 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwndDlg; ofn.lpstrFilter = szFilter; - ofn.lpstrCustomFilter = NULL; + ofn.lpstrCustomFilter = nullptr; ofn.lpstrFile = szFileName; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_FILEMUSTEXIST | OFN_DONTADDTORECENT; @@ -360,7 +360,7 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (GetTempFileName(szTempPath, L"jab", 0, szTempFileName) > 0) { dat->ppro->debugLogW(L"Temp file = %s", szTempFileName); if (CopyFile(szFileName, szTempFileName, FALSE) == TRUE) { - if ((hNewBitmap = Bitmap_Load(szTempFileName)) != NULL) { + if ((hNewBitmap = Bitmap_Load(szTempFileName)) != nullptr) { if (dat->hBitmap) { DeleteObject(dat->hBitmap); DeleteFile(dat->ppro->m_szPhotoFileName); @@ -370,7 +370,7 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR mir_wstrcpy(dat->ppro->m_szPhotoFileName, szTempFileName); dat->ppro->m_bPhotoChanged = TRUE; EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE); - InvalidateRect(hwndDlg, NULL, TRUE); + InvalidateRect(hwndDlg, nullptr, TRUE); UpdateWindow(hwndDlg); dat->ppro->m_vCardUpdates |= (1UL << iPageId); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); @@ -402,7 +402,7 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR ptOrg.x = ptOrg.y = 0; DPtoLP(hdcMem, &ptOrg, 1); GetClientRect(hwndCanvas, &rect); - InvalidateRect(hwndCanvas, NULL, TRUE); + InvalidateRect(hwndCanvas, nullptr, TRUE); UpdateWindow(hwndCanvas); if (ptSize.x <= rect.right && ptSize.y <= rect.bottom) { pt.x = (rect.right - ptSize.x) / 2; @@ -554,7 +554,7 @@ static INT_PTR CALLBACK EditEmailDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, char idstr[33]; mir_snprintf(idstr, "e-mail%d", dat->id); ptrA email(dat->ppro->getStringA(idstr)); - if (email != NULL) + if (email != nullptr) SetDlgItemTextA(hwndDlg, IDC_EMAIL, email); mir_snprintf(idstr, "e-mailFlag%d", lParam); @@ -574,7 +574,7 @@ static INT_PTR CALLBACK EditEmailDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, if (dat->id < 0) for (dat->id = 0;; dat->id++) { mir_snprintf(idstr, "e-mail%d", dat->id); - if (ptrA(dat->ppro->getStringA(idstr)) == NULL) + if (ptrA(dat->ppro->getStringA(idstr)) == nullptr) break; } @@ -616,7 +616,7 @@ static INT_PTR CALLBACK EditPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, char idstr[33]; mir_snprintf(idstr, "Phone%d", dat->id); ptrA phone(dat->ppro->getStringA(idstr)); - if (phone != NULL) + if (phone != nullptr) SetDlgItemTextA(hwndDlg, IDC_PHONE, phone); mir_snprintf(idstr, "PhoneFlag%d", dat->id); @@ -645,7 +645,7 @@ static INT_PTR CALLBACK EditPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, if (dat->id < 0) for (dat->id = 0;; dat->id++) { mir_snprintf(idstr, "Phone%d", dat->id); - if (ptrA(dat->ppro->getStringA(idstr)) == NULL) + if (ptrA(dat->ppro->getStringA(idstr)) == nullptr) break; } @@ -731,7 +731,7 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP for (i=0;;i++) { mir_snprintf(idstr, "e-mail%d", i); ptrW email( ppro->getWStringA(idstr)); - if (email == NULL) break; + if (email == nullptr) break; mir_snwprintf(number, L"%d", i+1); lvi.pszText = number; @@ -752,7 +752,7 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP for (i=0;;i++) { mir_snprintf(idstr, "Phone%d", i); ptrW phone( ppro->getWStringA(idstr)); - if (phone == NULL) break; + if (phone == nullptr) break; mir_snwprintf(number, L"%d", i+1); lvi.pszText = number; @@ -809,7 +809,7 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP else if (nm->iSubItem == 3 && nm->nmcd.lItemlParam != -1) hIcon = g_LoadIconEx("delete"); else break; - DrawIconEx(nm->nmcd.hdc, (rc.left + rc.right - GetSystemMetrics(SM_CXSMICON)) / 2, (rc.top + rc.bottom - GetSystemMetrics(SM_CYSMICON)) / 2, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); + DrawIconEx(nm->nmcd.hdc, (rc.left + rc.right - GetSystemMetrics(SM_CXSMICON)) / 2, (rc.top + rc.bottom - GetSystemMetrics(SM_CYSMICON)) / 2, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, nullptr, DI_NORMAL); SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT); return TRUE; } @@ -861,7 +861,7 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP for (i = lvi.lParam;; i++) { mir_snprintf(idstr, szIdTemplate, i + 1); ptrA fieldVal(ppro->getStringA(idstr)); - if (fieldVal == NULL) break; + if (fieldVal == nullptr) break; mir_snprintf(idstr, szIdTemplate, i); ppro->setString(idstr, fieldVal); @@ -1002,7 +1002,7 @@ void CJabberProto::SaveVcardToDB(HWND hwndPage, int iPage) void CJabberProto::AppendVcardFromDB(HXML n, char *tag, char *key) { - if (n == NULL || tag == NULL || key == NULL) + if (n == nullptr || tag == nullptr || key == nullptr) return; ptrW tszValue(getWStringA(key)); @@ -1033,7 +1033,7 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, wchar_t* szPhotoFileName) for (i = 0;; i++) { mir_snprintf(idstr, "e-mail%d", i); ptrW email(getWStringA(idstr)); - if (email == NULL) + if (email == nullptr) break; HXML e = v << XCHILD(L"EMAIL", email); @@ -1081,7 +1081,7 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, wchar_t* szPhotoFileName) for (i = 0;; i++) { mir_snprintf(idstr, "Phone%d", i); ptrW phone(getWStringA(idstr)); - if (phone == NULL) + if (phone == nullptr) break; n = v << XCHILD(L"TEL"); @@ -1104,7 +1104,7 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, wchar_t* szPhotoFileName) } wchar_t szAvatarName[MAX_PATH], *szFileName; - GetAvatarFileName(NULL, szAvatarName, _countof(szAvatarName)); + GetAvatarFileName(0, szAvatarName, _countof(szAvatarName)); if (bPhotoChanged) szFileName = szPhotoFileName; else @@ -1112,7 +1112,7 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, wchar_t* szPhotoFileName) // Set photo element, also update the global jabberVcardPhotoFileName to reflect the update debugLogW(L"Before update, file name = %s", szFileName); - if (szFileName == NULL || szFileName[0] == 0) { + if (szFileName == nullptr || szFileName[0] == 0) { v << XCHILD(L"PHOTO"); DeleteFile(szAvatarName); delSetting("AvatarSaved"); @@ -1124,15 +1124,15 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, wchar_t* szPhotoFileName) struct _stat st; if (_wstat(szFileName, &st) >= 0) { // Note the FILE_SHARE_READ attribute so that the CopyFile can succeed - HANDLE hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile != INVALID_HANDLE_VALUE) { ptrA buffer((char*)mir_alloc(st.st_size)); - if (buffer != NULL) { + if (buffer != nullptr) { DWORD nRead; - if (ReadFile(hFile, buffer, st.st_size, &nRead, NULL)) { + if (ReadFile(hFile, buffer, st.st_size, &nRead, nullptr)) { ptrA str(mir_base64_encode((PBYTE)(LPSTR)buffer, nRead)); const wchar_t *szFileType = ProtoGetAvatarMimeType(ProtoGetBufferFormat(buffer)); - if (str != NULL && szFileType != NULL) { + if (str != nullptr && szFileType != nullptr) { n = v << XCHILD(L"PHOTO"); n << XCHILD(L"TYPE", szFileType); n << XCHILD(L"BINVAL", _A2T(str)); @@ -1152,7 +1152,7 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, wchar_t* szPhotoFileName) if (bPhotoChanged) { DeleteFile(szAvatarName); - GetAvatarFileName(NULL, szAvatarName, _countof(szAvatarName)); + GetAvatarFileName(0, szAvatarName, _countof(szAvatarName)); CopyFile(szFileName, szAvatarName, FALSE); } diff --git a/protocols/JabberG/src/jabber_ws.cpp b/protocols/JabberG/src/jabber_ws.cpp index 29129a74f8..d4a75d50f3 100644 --- a/protocols/JabberG/src/jabber_ws.cpp +++ b/protocols/JabberG/src/jabber_ws.cpp @@ -36,13 +36,13 @@ BOOL CJabberProto::WsInit(void) nlu.szDescriptiveName.w = name; nlu.szSettingsModule = m_szModuleName; m_hNetlibUser = Netlib_RegisterUser(&nlu); - return m_hNetlibUser != NULL; + return m_hNetlibUser != nullptr; } void CJabberProto::WsUninit(void) { Netlib_CloseHandle(m_hNetlibUser); - m_hNetlibUser = NULL; + m_hNetlibUser = nullptr; } HNETLIBCONN CJabberProto::WsConnect(char* host, WORD port) diff --git a/protocols/JabberG/src/jabber_xml.cpp b/protocols/JabberG/src/jabber_xml.cpp index 2df63a852e..f4c899d3cd 100644 --- a/protocols/JabberG/src/jabber_xml.cpp +++ b/protocols/JabberG/src/jabber_xml.cpp @@ -36,27 +36,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. XmlNodeIq::XmlNodeIq(const wchar_t *type, int id, LPCTSTR to) : XmlNode(L"iq") { - if (type != NULL) *this << XATTR(L"type", type); - if (to != NULL) *this << XATTR(L"to", to); + if (type != nullptr) *this << XATTR(L"type", type); + if (to != nullptr) *this << XATTR(L"to", to); if (id != -1 ) *this << XATTRID(id); } XmlNodeIq::XmlNodeIq(const wchar_t *type, LPCTSTR idStr, LPCTSTR to) : XmlNode(L"iq") { - if (type != NULL) *this << XATTR(L"type", type ); - if (to != NULL) *this << XATTR(L"to", to ); - if (idStr != NULL) *this << XATTR(L"id", idStr); + if (type != nullptr) *this << XATTR(L"type", type ); + if (to != nullptr) *this << XATTR(L"to", to ); + if (idStr != nullptr) *this << XATTR(L"id", idStr); } XmlNodeIq::XmlNodeIq(const wchar_t *type, HXML node, LPCTSTR to) : XmlNode(L"iq") { - if (type != NULL) *this << XATTR(L"type", type ); - if (to != NULL) *this << XATTR(L"to", to ); - if (node != NULL) { + if (type != nullptr) *this << XATTR(L"type", type ); + if (to != nullptr) *this << XATTR(L"to", to ); + if (node != nullptr) { const wchar_t *iqId = XmlGetAttrValue(*this, L"id"); - if (iqId != NULL) *this << XATTR(L"id", iqId); + if (iqId != nullptr) *this << XATTR(L"id", iqId); } } @@ -64,8 +64,8 @@ XmlNodeIq::XmlNodeIq(CJabberIqInfo *pInfo) : XmlNode(L"iq") { if (pInfo) { - if (pInfo->GetCharIqType() != NULL) *this << XATTR(L"type", _A2T(pInfo->GetCharIqType())); - if (pInfo->GetReceiver() != NULL) *this << XATTR(L"to", pInfo->GetReceiver()); + if (pInfo->GetCharIqType() != nullptr) *this << XATTR(L"type", _A2T(pInfo->GetCharIqType())); + if (pInfo->GetReceiver() != nullptr) *this << XATTR(L"to", pInfo->GetReceiver()); if (pInfo->GetIqId() != -1) *this << XATTRID(pInfo->GetIqId()); } } @@ -73,10 +73,10 @@ XmlNodeIq::XmlNodeIq(CJabberIqInfo *pInfo) : XmlNodeIq::XmlNodeIq(const wchar_t *type, CJabberIqInfo *pInfo) : XmlNode(L"iq") { - if (type != NULL) *this << XATTR(L"type", type); + if (type != nullptr) *this << XATTR(L"type", type); if (pInfo) { - if (pInfo->GetFrom() != NULL) *this << XATTR(L"to", pInfo->GetFrom()); - if (pInfo->GetIdStr() != NULL) *this << XATTR(L"id", pInfo->GetIdStr()); + if (pInfo->GetFrom() != nullptr) *this << XATTR(L"to", pInfo->GetFrom()); + if (pInfo->GetIdStr() != nullptr) *this << XATTR(L"id", pInfo->GetIdStr()); } } @@ -85,7 +85,7 @@ XmlNodeIq::XmlNodeIq(const wchar_t *type, CJabberIqInfo *pInfo) : XmlNode::XmlNode(LPCTSTR pszName) { - m_hXml = xmlCreateNode(T2UTF(pszName), NULL, 0); + m_hXml = xmlCreateNode(T2UTF(pszName), nullptr, 0); } XmlNode::XmlNode(LPCTSTR pszName, LPCTSTR ptszText) @@ -110,7 +110,7 @@ XmlNode::~XmlNode() { if (m_hXml) { xmlDestroyNode(m_hXml); - m_hXml = NULL; + m_hXml = nullptr; } } ///////////////////////////////////////////////////////////////////////////////////////// @@ -184,7 +184,7 @@ void __fastcall XmlAddChild(HXML hXml, HXML n) HXML __fastcall XmlAddChild(HXML hXml, LPCTSTR name) { - return xmlAddChild(hXml, T2UTF(name), NULL); + return xmlAddChild(hXml, T2UTF(name), nullptr); } HXML __fastcall XmlAddChild(HXML hXml, LPCTSTR name, LPCTSTR value) @@ -246,8 +246,8 @@ HXML __fastcall XmlGetNthChild(HXML hXml, LPCTSTR tag, int nth) { int i, num; - if (!hXml || tag == NULL || mir_wstrlen(tag) <= 0 || nth < 1) - return NULL; + if (!hXml || tag == nullptr || mir_wstrlen(tag) <= 0 || nth < 1) + return nullptr; num = 1; for (i=0; ; i++) { @@ -261,7 +261,7 @@ HXML __fastcall XmlGetNthChild(HXML hXml, LPCTSTR tag, int nth) num++; } } - return NULL; + return nullptr; } LPCTSTR __fastcall XmlGetName(HXML xml) @@ -271,7 +271,7 @@ LPCTSTR __fastcall XmlGetName(HXML xml) LPCTSTR __fastcall XmlGetText(HXML xml) { - return (xml) ? xmlGetText(xml) : NULL; + return (xml) ? xmlGetText(xml) : nullptr; } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/JabberG/src/jabber_xml.h b/protocols/JabberG/src/jabber_xml.h index 04360dd5d6..09f2e8831b 100644 --- a/protocols/JabberG/src/jabber_xml.h +++ b/protocols/JabberG/src/jabber_xml.h @@ -57,7 +57,7 @@ LPCTSTR __fastcall XmlGetAttrValue(HXML, LPCTSTR key); struct XmlNode { - __forceinline XmlNode() { m_hXml = NULL; } + __forceinline XmlNode() { m_hXml = nullptr; } __forceinline XmlNode(LPCTSTR pszString, int* numBytes, LPCTSTR ptszTag) { @@ -83,7 +83,7 @@ class CJabberIqInfo; struct XmlNodeIq : public XmlNode { - XmlNodeIq(const wchar_t *type, int id = -1, const wchar_t *to = NULL); + XmlNodeIq(const wchar_t *type, int id = -1, const wchar_t *to = nullptr); XmlNodeIq(const wchar_t *type, const wchar_t *idStr, const wchar_t *to); XmlNodeIq(const wchar_t *type, HXML node, const wchar_t *to); // new request @@ -169,7 +169,7 @@ struct XCHILD { LPCTSTR name, value; - __forceinline XCHILD(LPCTSTR _name, LPCTSTR _value = NULL) : + __forceinline XCHILD(LPCTSTR _name, LPCTSTR _value = nullptr) : name(_name), value(_value) {} @@ -185,7 +185,7 @@ struct XCHILDNS { LPCTSTR name, ns; - __forceinline XCHILDNS(LPCTSTR _name, LPCTSTR _ns = NULL) : + __forceinline XCHILDNS(LPCTSTR _name, LPCTSTR _ns = nullptr) : name(_name), ns(_ns) {} @@ -228,7 +228,7 @@ public: m_type(T_UNKNOWN), m_hXml(hXml), m_szPath(path), - m_szParam(NULL) + m_szParam(nullptr) {} // Read data @@ -239,7 +239,7 @@ public: case T_NODE: return m_hXml; case T_NODESET: return XmlGetNthChild(m_hXml, m_szParam, 1); } - return NULL; + return nullptr; } operator LPTSTR() { @@ -249,7 +249,7 @@ public: case T_NODE: return (wchar_t *)XmlGetText(m_hXml); case T_NODESET: return (wchar_t *)XmlGetText(XmlGetNthChild(m_hXml, m_szParam, 1)); } - return NULL; + return nullptr; } operator int() { @@ -266,7 +266,7 @@ public: } HXML operator[] (int idx) { - return (Lookup() == T_NODESET) ? XmlGetNthChild(m_hXml, m_szParam, idx) : NULL; + return (Lookup() == T_NODESET) ? XmlGetNthChild(m_hXml, m_szParam, idx) : nullptr; } // Write data diff --git a/protocols/JabberG/src/jabber_xstatus.cpp b/protocols/JabberG/src/jabber_xstatus.cpp index 6f9f0f6767..d45e5627a6 100644 --- a/protocols/JabberG/src/jabber_xstatus.cpp +++ b/protocols/JabberG/src/jabber_xstatus.cpp @@ -54,7 +54,7 @@ private: }; CJabberDlgPepBase::CJabberDlgPepBase(CJabberProto *proto, int id): - CJabberDlgBase(proto, id, NULL), + CJabberDlgBase(proto, id, nullptr), m_btnOk(this, IDOK), m_btnCancel(this, IDCANCEL), m_time(5) @@ -65,7 +65,7 @@ void CJabberDlgPepBase::OnInitDialog() { CSuper::OnInitDialog(); - SetTimer(m_hwnd, 1, 1000, NULL); + SetTimer(m_hwnd, 1, 1000, nullptr); wchar_t buf[128]; mir_snwprintf(buf, TranslateT("OK (%d)"), m_time); @@ -179,7 +179,7 @@ CJabberDlgPepSimple::CJabberDlgPepSimple(CJabberProto *proto, wchar_t *title): m_cbModes(this, IDC_CB_MODES), m_txtDescription(this, IDC_TXT_DESCRIPTION), m_modes(10), - m_text(NULL), + m_text(nullptr), m_selected(0), m_prevSelected(-1), m_active(-1), @@ -286,7 +286,7 @@ void CJabberDlgPepSimple::cbModes_OnChange(CCtrlData *) mir_snprintf(szSetting, "PepMsg_%s", m_modes[m_cbModes.GetItemData(m_prevSelected)].m_name); ptrW szDescr( m_proto->getWStringA(szSetting)); - m_txtDescription.SetText((szDescr != NULL) ? szDescr : L""); + m_txtDescription.SetText((szDescr != nullptr) ? szDescr : L""); m_txtDescription.Enable(true); } else { @@ -347,13 +347,13 @@ BOOL CJabberDlgPepSimple::OnWmDrawItem(UINT, WPARAM, LPARAM lParam) } else mir_wstrncpy(text, mode->m_title, _countof(text)); - DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 2, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2, mode->m_hIcon, 16, 16, 0, NULL, DI_NORMAL); + DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 2, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2, mode->m_hIcon, 16, 16, 0, nullptr, DI_NORMAL); TextOut(lpdis->hDC, lpdis->rcItem.left + 23, (lpdis->rcItem.top + lpdis->rcItem.bottom - tm.tmHeight) / 2, text, (int)mir_wstrlen(text)); } else { wchar_t text[128]; mir_snwprintf(text, L"...%s", mode->m_title); - DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 23, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2, mode->m_hIcon, 16, 16, 0, NULL, DI_NORMAL); + DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 23, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2, mode->m_hIcon, 16, 16, 0, nullptr, DI_NORMAL); TextOut(lpdis->hDC, lpdis->rcItem.left + 44, (lpdis->rcItem.top + lpdis->rcItem.bottom - tm.tmHeight) / 2, text, (int)mir_wstrlen(text)); } @@ -375,7 +375,7 @@ CPepService::CPepService(CJabberProto *proto, char *name, wchar_t *node): m_proto(proto), m_name(name), m_node(node), - m_hMenuItem(NULL), + m_hMenuItem(nullptr), m_wasPublished(false) { } @@ -428,9 +428,9 @@ void CPepService::ForceRepublishOnLogin() CPepGuiService::CPepGuiService(CJabberProto *proto, char *name, wchar_t *node): CPepService(proto, name, node), m_bGuiOpen(false), - m_hIcolibItem(NULL), - m_szText(NULL), - m_hMenuService(NULL) + m_hIcolibItem(nullptr), + m_szText(nullptr), + m_hMenuService(nullptr) { } @@ -438,7 +438,7 @@ CPepGuiService::~CPepGuiService() { if (m_hMenuService) { DestroyServiceFunction(m_hMenuService); - m_hMenuService = NULL; + m_hMenuService = nullptr; } if (m_szText) mir_free(m_szText); @@ -459,7 +459,7 @@ void CPepGuiService::InitGui() void CPepGuiService::RebuildMenu() { HGENMENU hJabberRoot = m_proto->m_hMenuRoot; - if (hJabberRoot == NULL) + if (hJabberRoot == nullptr) return; char szService[128]; @@ -511,7 +511,7 @@ struct } static g_arrMoods[] = { - { LPGENW("None"), NULL }, + { LPGENW("None"), nullptr }, { LPGENW("Afraid"), "afraid" }, { LPGENW("Amazed"), "amazed" }, { LPGENW("Amorous"), "amorous" }, @@ -600,7 +600,7 @@ static g_arrMoods[] = CPepMood::CPepMood(CJabberProto *proto) : CPepGuiService(proto, "Mood", JABBER_FEAT_USER_MOOD), - m_text(NULL), + m_text(nullptr), m_mode(-1) { UpdateMenuItem(Skin_GetIconHandle(SKINICON_OTHER_SMALLDOT), LPGENW("Set mood...")); @@ -613,7 +613,7 @@ CPepMood::~CPepMood() void CPepMood::ProcessItems(const wchar_t *from, HXML itemsNode) { - MCONTACT hContact = NULL, hSelfContact = NULL; + MCONTACT hContact = 0, hSelfContact = 0; if (!m_proto->IsMyOwnJID(from)) { hContact = m_proto->HContactFromJID(from); if (!hContact) return; @@ -622,15 +622,15 @@ void CPepMood::ProcessItems(const wchar_t *from, HXML itemsNode) if (XmlGetChild(itemsNode, L"retract")) { if (hSelfContact) - SetMood(hSelfContact, NULL, NULL); - SetMood(hContact, NULL, NULL); + SetMood(hSelfContact, nullptr, nullptr); + SetMood(hContact, nullptr, nullptr); return; } HXML n, moodNode = XPath(itemsNode, L"item/mood[@xmlns='" JABBER_FEAT_USER_MOOD L"']"); if (!moodNode) return; - LPCTSTR moodType = NULL, moodText = NULL; + LPCTSTR moodType = nullptr, moodText = nullptr; for (int i=0; n = XmlGetChild(moodNode, i); i++) { if (!mir_wstrcmp(XmlGetName(n), L"text")) moodText = XmlGetText(n); @@ -665,7 +665,7 @@ void CPepMood::ResetExtraIcon(MCONTACT hContact) void CPepMood::SetExtraIcon(MCONTACT hContact, char *szMood) { - ExtraIcon_SetIcon(hExtraMood, hContact, szMood == NULL ? NULL : g_MoodIcons.GetIcolibHandle(szMood)); + ExtraIcon_SetIcon(hExtraMood, hContact, szMood == nullptr ? nullptr : g_MoodIcons.GetIcolibHandle(szMood)); } void CPepMood::SetMood(MCONTACT hContact, const wchar_t *szMood, const wchar_t *szText) @@ -705,7 +705,7 @@ void CPepMood::SetMood(MCONTACT hContact, const wchar_t *szMood, const wchar_t * if (m_proto->m_pInfoFrame) m_proto->m_pInfoFrame->UpdateInfoItem("$/PEP/mood", hIcon, title); } - else SetExtraIcon(hContact, mood < 0 ? NULL : g_arrMoods[mood].szTag); + else SetExtraIcon(hContact, mood < 0 ? nullptr : g_arrMoods[mood].szTag); if (szMood) { m_proto->setByte(hContact, DBSETTING_XSTATUSID, mood); @@ -774,85 +774,85 @@ struct } static g_arrActivities[] = { - { "doing_chores", NULL, LPGENW("Doing chores"), ACTIVITY_ICON(0, 0) }, - { NULL, "buying_groceries", LPGENW("buying groceries"), ACTIVITY_ICON(0, 1) }, - { NULL, "cleaning", LPGENW("cleaning"), ACTIVITY_ICON(0, 2) }, - { NULL, "cooking", LPGENW("cooking"), ACTIVITY_ICON(0, 3) }, - { NULL, "doing_maintenance", LPGENW("doing maintenance"), ACTIVITY_ICON(0, 4) }, - { NULL, "doing_the_dishes", LPGENW("doing the dishes"), ACTIVITY_ICON(0, 5) }, - { NULL, "doing_the_laundry", LPGENW("doing the laundry"), ACTIVITY_ICON(0, 6) }, - { NULL, "gardening", LPGENW("gardening"), ACTIVITY_ICON(0, 7) }, - { NULL, "running_an_errand", LPGENW("running an errand"), ACTIVITY_ICON(0, 8) }, - { NULL, "walking_the_dog", LPGENW("walking the dog"), ACTIVITY_ICON(0, 9) }, - { "drinking", NULL, LPGENW("Drinking"), ACTIVITY_ICON(1, 0) }, - { NULL, "having_a_beer", LPGENW("having a beer"), ACTIVITY_ICON(1, 1) }, - { NULL, "having_coffee", LPGENW("having coffee"), ACTIVITY_ICON(1, 2) }, - { NULL, "having_tea", LPGENW("having tea"), ACTIVITY_ICON(1, 3) }, - { "eating", NULL, LPGENW("Eating"), ACTIVITY_ICON(2, 0) }, - { NULL, "having_a_snack", LPGENW("having a snack"), ACTIVITY_ICON(2, 1) }, - { NULL, "having_breakfast", LPGENW("having breakfast"), ACTIVITY_ICON(2, 2) }, - { NULL, "having_dinner", LPGENW("having dinner"), ACTIVITY_ICON(2, 3) }, - { NULL, "having_lunch", LPGENW("having lunch"), ACTIVITY_ICON(2, 4) }, - { "exercising", NULL, LPGENW("Exercising"), ACTIVITY_ICON(3, 0) }, - { NULL, "cycling", LPGENW("cycling"), ACTIVITY_ICON(3, 1) }, - { NULL, "dancing", LPGENW("dancing"), ACTIVITY_ICON(3, 2) }, - { NULL, "hiking", LPGENW("hiking"), ACTIVITY_ICON(3, 3) }, - { NULL, "jogging", LPGENW("jogging"), ACTIVITY_ICON(3, 4) }, - { NULL, "playing_sports", LPGENW("playing sports"), ACTIVITY_ICON(3, 5) }, - { NULL, "running", LPGENW("running"), ACTIVITY_ICON(3, 6) }, - { NULL, "skiing", LPGENW("skiing"), ACTIVITY_ICON(3, 7) }, - { NULL, "swimming", LPGENW("swimming"), ACTIVITY_ICON(3, 8) }, - { NULL, "working_out", LPGENW("working out"), ACTIVITY_ICON(3, 9) }, - { "grooming", NULL, LPGENW("Grooming"), ACTIVITY_ICON(4, 0) }, - { NULL, "at_the_spa", LPGENW("at the spa"), ACTIVITY_ICON(4, 1) }, - { NULL, "brushing_teeth", LPGENW("brushing teeth"), ACTIVITY_ICON(4, 2) }, - { NULL, "getting_a_haircut", LPGENW("getting a haircut"), ACTIVITY_ICON(4, 3) }, - { NULL, "shaving", LPGENW("shaving"), ACTIVITY_ICON(4, 4) }, - { NULL, "taking_a_bath", LPGENW("taking a bath"), ACTIVITY_ICON(4, 5) }, - { NULL, "taking_a_shower", LPGENW("taking a shower"), ACTIVITY_ICON(4, 6) }, - { "having_appointment", NULL, LPGENW("Having appointment"), ACTIVITY_ICON(5, 0) }, - { "inactive", NULL, LPGENW("Inactive"), ACTIVITY_ICON(6, 0) }, - { NULL, "day_off", LPGENW("day off"), ACTIVITY_ICON(6, 1) }, - { NULL, "hanging_out", LPGENW("hanging out"), ACTIVITY_ICON(6, 2) }, - { NULL, "hiding", LPGENW("hiding"), ACTIVITY_ICON(6, 3) }, - { NULL, "on_vacation", LPGENW("on vacation"), ACTIVITY_ICON(6, 4) }, - { NULL, "praying", LPGENW("praying"), ACTIVITY_ICON(6, 5) }, - { NULL, "scheduled_holiday", LPGENW("scheduled holiday"), ACTIVITY_ICON(6, 6) }, - { NULL, "sleeping", LPGENW("sleeping"), ACTIVITY_ICON(6, 7) }, - { NULL, "thinking", LPGENW("thinking"), ACTIVITY_ICON(6, 8) }, - { "relaxing", NULL, LPGENW("Relaxing"), ACTIVITY_ICON(7, 0) }, - { NULL, "fishing", LPGENW("fishing"), ACTIVITY_ICON(7, 1) }, - { NULL, "gaming", LPGENW("gaming"), ACTIVITY_ICON(7, 2) }, - { NULL, "going_out", LPGENW("going out"), ACTIVITY_ICON(7, 3) }, - { NULL, "partying", LPGENW("partying"), ACTIVITY_ICON(7, 4) }, - { NULL, "reading", LPGENW("reading"), ACTIVITY_ICON(7, 5) }, - { NULL, "rehearsing", LPGENW("rehearsing"), ACTIVITY_ICON(7, 6) }, - { NULL, "shopping", LPGENW("shopping"), ACTIVITY_ICON(7, 7) }, - { NULL, "smoking", LPGENW("smoking"), ACTIVITY_ICON(7, 8) }, - { NULL, "socializing", LPGENW("socializing"), ACTIVITY_ICON(7, 9) }, - { NULL, "sunbathing", LPGENW("sunbathing"), ACTIVITY_ICON(7, 10) }, - { NULL, "watching_tv", LPGENW("watching TV"), ACTIVITY_ICON(7, 11) }, - { NULL, "watching_a_movie", LPGENW("watching a movie"), ACTIVITY_ICON(7, 12) }, - { "talking", NULL, LPGENW("Talking"), ACTIVITY_ICON(8, 0) }, - { NULL, "in_real_life", LPGENW("in real life"), ACTIVITY_ICON(8, 1) }, - { NULL, "on_the_phone", LPGENW("on the phone"), ACTIVITY_ICON(8, 2) }, - { NULL, "on_video_phone", LPGENW("on video phone"), ACTIVITY_ICON(8, 3) }, - { "traveling", NULL, LPGENW("Traveling"), ACTIVITY_ICON(9, 0) }, - { NULL, "commuting", LPGENW("commuting"), ACTIVITY_ICON(9, 1) }, - { NULL, "cycling", LPGENW("cycling"), ACTIVITY_ICON(9, 2) }, - { NULL, "driving", LPGENW("driving"), ACTIVITY_ICON(9, 3) }, - { NULL, "in_a_car", LPGENW("in a car"), ACTIVITY_ICON(9, 4) }, - { NULL, "on_a_bus", LPGENW("on a bus"), ACTIVITY_ICON(9, 5) }, - { NULL, "on_a_plane", LPGENW("on a plane"), ACTIVITY_ICON(9, 6) }, - { NULL, "on_a_train", LPGENW("on a train"), ACTIVITY_ICON(9, 7) }, - { NULL, "on_a_trip", LPGENW("on a trip"), ACTIVITY_ICON(9, 8) }, - { NULL, "walking", LPGENW("walking"), ACTIVITY_ICON(9, 9) }, - { "working", NULL, LPGENW("Working"), ACTIVITY_ICON(10, 0) }, - { NULL, "coding", LPGENW("coding"), ACTIVITY_ICON(10, 1) }, - { NULL, "in_a_meeting", LPGENW("in a meeting"), ACTIVITY_ICON(10, 2) }, - { NULL, "studying", LPGENW("studying"), ACTIVITY_ICON(10, 3) }, - { NULL, "writing", LPGENW("writing"), ACTIVITY_ICON(10, 4) }, - { NULL, NULL, NULL } // the end, don't delete this + { "doing_chores", nullptr, LPGENW("Doing chores"), ACTIVITY_ICON(0, 0) }, + { nullptr, "buying_groceries", LPGENW("buying groceries"), ACTIVITY_ICON(0, 1) }, + { nullptr, "cleaning", LPGENW("cleaning"), ACTIVITY_ICON(0, 2) }, + { nullptr, "cooking", LPGENW("cooking"), ACTIVITY_ICON(0, 3) }, + { nullptr, "doing_maintenance", LPGENW("doing maintenance"), ACTIVITY_ICON(0, 4) }, + { nullptr, "doing_the_dishes", LPGENW("doing the dishes"), ACTIVITY_ICON(0, 5) }, + { nullptr, "doing_the_laundry", LPGENW("doing the laundry"), ACTIVITY_ICON(0, 6) }, + { nullptr, "gardening", LPGENW("gardening"), ACTIVITY_ICON(0, 7) }, + { nullptr, "running_an_errand", LPGENW("running an errand"), ACTIVITY_ICON(0, 8) }, + { nullptr, "walking_the_dog", LPGENW("walking the dog"), ACTIVITY_ICON(0, 9) }, + { "drinking", nullptr, LPGENW("Drinking"), ACTIVITY_ICON(1, 0) }, + { nullptr, "having_a_beer", LPGENW("having a beer"), ACTIVITY_ICON(1, 1) }, + { nullptr, "having_coffee", LPGENW("having coffee"), ACTIVITY_ICON(1, 2) }, + { nullptr, "having_tea", LPGENW("having tea"), ACTIVITY_ICON(1, 3) }, + { "eating", nullptr, LPGENW("Eating"), ACTIVITY_ICON(2, 0) }, + { nullptr, "having_a_snack", LPGENW("having a snack"), ACTIVITY_ICON(2, 1) }, + { nullptr, "having_breakfast", LPGENW("having breakfast"), ACTIVITY_ICON(2, 2) }, + { nullptr, "having_dinner", LPGENW("having dinner"), ACTIVITY_ICON(2, 3) }, + { nullptr, "having_lunch", LPGENW("having lunch"), ACTIVITY_ICON(2, 4) }, + { "exercising", nullptr, LPGENW("Exercising"), ACTIVITY_ICON(3, 0) }, + { nullptr, "cycling", LPGENW("cycling"), ACTIVITY_ICON(3, 1) }, + { nullptr, "dancing", LPGENW("dancing"), ACTIVITY_ICON(3, 2) }, + { nullptr, "hiking", LPGENW("hiking"), ACTIVITY_ICON(3, 3) }, + { nullptr, "jogging", LPGENW("jogging"), ACTIVITY_ICON(3, 4) }, + { nullptr, "playing_sports", LPGENW("playing sports"), ACTIVITY_ICON(3, 5) }, + { nullptr, "running", LPGENW("running"), ACTIVITY_ICON(3, 6) }, + { nullptr, "skiing", LPGENW("skiing"), ACTIVITY_ICON(3, 7) }, + { nullptr, "swimming", LPGENW("swimming"), ACTIVITY_ICON(3, 8) }, + { nullptr, "working_out", LPGENW("working out"), ACTIVITY_ICON(3, 9) }, + { "grooming", nullptr, LPGENW("Grooming"), ACTIVITY_ICON(4, 0) }, + { nullptr, "at_the_spa", LPGENW("at the spa"), ACTIVITY_ICON(4, 1) }, + { nullptr, "brushing_teeth", LPGENW("brushing teeth"), ACTIVITY_ICON(4, 2) }, + { nullptr, "getting_a_haircut", LPGENW("getting a haircut"), ACTIVITY_ICON(4, 3) }, + { nullptr, "shaving", LPGENW("shaving"), ACTIVITY_ICON(4, 4) }, + { nullptr, "taking_a_bath", LPGENW("taking a bath"), ACTIVITY_ICON(4, 5) }, + { nullptr, "taking_a_shower", LPGENW("taking a shower"), ACTIVITY_ICON(4, 6) }, + { "having_appointment", nullptr, LPGENW("Having appointment"), ACTIVITY_ICON(5, 0) }, + { "inactive", nullptr, LPGENW("Inactive"), ACTIVITY_ICON(6, 0) }, + { nullptr, "day_off", LPGENW("day off"), ACTIVITY_ICON(6, 1) }, + { nullptr, "hanging_out", LPGENW("hanging out"), ACTIVITY_ICON(6, 2) }, + { nullptr, "hiding", LPGENW("hiding"), ACTIVITY_ICON(6, 3) }, + { nullptr, "on_vacation", LPGENW("on vacation"), ACTIVITY_ICON(6, 4) }, + { nullptr, "praying", LPGENW("praying"), ACTIVITY_ICON(6, 5) }, + { nullptr, "scheduled_holiday", LPGENW("scheduled holiday"), ACTIVITY_ICON(6, 6) }, + { nullptr, "sleeping", LPGENW("sleeping"), ACTIVITY_ICON(6, 7) }, + { nullptr, "thinking", LPGENW("thinking"), ACTIVITY_ICON(6, 8) }, + { "relaxing", nullptr, LPGENW("Relaxing"), ACTIVITY_ICON(7, 0) }, + { nullptr, "fishing", LPGENW("fishing"), ACTIVITY_ICON(7, 1) }, + { nullptr, "gaming", LPGENW("gaming"), ACTIVITY_ICON(7, 2) }, + { nullptr, "going_out", LPGENW("going out"), ACTIVITY_ICON(7, 3) }, + { nullptr, "partying", LPGENW("partying"), ACTIVITY_ICON(7, 4) }, + { nullptr, "reading", LPGENW("reading"), ACTIVITY_ICON(7, 5) }, + { nullptr, "rehearsing", LPGENW("rehearsing"), ACTIVITY_ICON(7, 6) }, + { nullptr, "shopping", LPGENW("shopping"), ACTIVITY_ICON(7, 7) }, + { nullptr, "smoking", LPGENW("smoking"), ACTIVITY_ICON(7, 8) }, + { nullptr, "socializing", LPGENW("socializing"), ACTIVITY_ICON(7, 9) }, + { nullptr, "sunbathing", LPGENW("sunbathing"), ACTIVITY_ICON(7, 10) }, + { nullptr, "watching_tv", LPGENW("watching TV"), ACTIVITY_ICON(7, 11) }, + { nullptr, "watching_a_movie", LPGENW("watching a movie"), ACTIVITY_ICON(7, 12) }, + { "talking", nullptr, LPGENW("Talking"), ACTIVITY_ICON(8, 0) }, + { nullptr, "in_real_life", LPGENW("in real life"), ACTIVITY_ICON(8, 1) }, + { nullptr, "on_the_phone", LPGENW("on the phone"), ACTIVITY_ICON(8, 2) }, + { nullptr, "on_video_phone", LPGENW("on video phone"), ACTIVITY_ICON(8, 3) }, + { "traveling", nullptr, LPGENW("Traveling"), ACTIVITY_ICON(9, 0) }, + { nullptr, "commuting", LPGENW("commuting"), ACTIVITY_ICON(9, 1) }, + { nullptr, "cycling", LPGENW("cycling"), ACTIVITY_ICON(9, 2) }, + { nullptr, "driving", LPGENW("driving"), ACTIVITY_ICON(9, 3) }, + { nullptr, "in_a_car", LPGENW("in a car"), ACTIVITY_ICON(9, 4) }, + { nullptr, "on_a_bus", LPGENW("on a bus"), ACTIVITY_ICON(9, 5) }, + { nullptr, "on_a_plane", LPGENW("on a plane"), ACTIVITY_ICON(9, 6) }, + { nullptr, "on_a_train", LPGENW("on a train"), ACTIVITY_ICON(9, 7) }, + { nullptr, "on_a_trip", LPGENW("on a trip"), ACTIVITY_ICON(9, 8) }, + { nullptr, "walking", LPGENW("walking"), ACTIVITY_ICON(9, 9) }, + { "working", nullptr, LPGENW("Working"), ACTIVITY_ICON(10, 0) }, + { nullptr, "coding", LPGENW("coding"), ACTIVITY_ICON(10, 1) }, + { nullptr, "in_a_meeting", LPGENW("in a meeting"), ACTIVITY_ICON(10, 2) }, + { nullptr, "studying", LPGENW("studying"), ACTIVITY_ICON(10, 3) }, + { nullptr, "writing", LPGENW("writing"), ACTIVITY_ICON(10, 4) }, + { nullptr, nullptr, nullptr } // the end, don't delete this }; inline char *ActivityGetId(int id) @@ -905,13 +905,13 @@ char* returnActivity(int id) return g_arrActivities[id].szFirst; if (g_arrActivities[id].szSecond) return g_arrActivities[id].szSecond; - return NULL; + return nullptr; } char* ActivityGetFirst(int id) { if (id >= _countof(g_arrActivities) - 1) - return NULL; + return nullptr; while (id >= 0) { if (g_arrActivities[id].szFirst) @@ -919,12 +919,12 @@ char* ActivityGetFirst(int id) --id; } - return NULL; + return nullptr; } char *ActivityGetFirst(char *szId) { - if (!szId) return NULL; + if (!szId) return nullptr; int id = _countof(g_arrActivities) - 1; bool found_second = false; @@ -937,18 +937,18 @@ char *ActivityGetFirst(char *szId) --id; } - return NULL; + return nullptr; } char *ActivityGetSecond(int id) { - return (id >= 0) ? g_arrActivities[id].szSecond : NULL; + return (id >= 0) ? g_arrActivities[id].szSecond : nullptr; } wchar_t *ActivityGetFirstTitle(int id) { if (id >= _countof(g_arrActivities) - 1) - return NULL; + return nullptr; while (id >= 0) { if (g_arrActivities[id].szFirst) @@ -956,12 +956,12 @@ wchar_t *ActivityGetFirstTitle(int id) --id; } - return NULL; + return nullptr; } wchar_t *ActivityGetSecondTitle(int id) { - return ((id >= 0) && g_arrActivities[id].szSecond) ? g_arrActivities[id].szTitle : NULL; + return ((id >= 0) && g_arrActivities[id].szSecond) ? g_arrActivities[id].szTitle : nullptr; } void ActivityBuildTitle(int id, wchar_t *buf, int size) @@ -980,7 +980,7 @@ void ActivityBuildTitle(int id, wchar_t *buf, int size) CPepActivity::CPepActivity(CJabberProto *proto): CPepGuiService(proto, "Activity", JABBER_FEAT_USER_ACTIVITY), - m_text(NULL), + m_text(nullptr), m_mode(-1) { UpdateMenuItem(Skin_GetIconHandle(SKINICON_OTHER_SMALLDOT), LPGENW("Set activity...")); @@ -993,7 +993,7 @@ CPepActivity::~CPepActivity() void CPepActivity::ProcessItems(const wchar_t *from, HXML itemsNode) { - MCONTACT hContact = NULL, hSelfContact = NULL; + MCONTACT hContact = 0, hSelfContact = 0; if (!m_proto->IsMyOwnJID(from)) { hContact = m_proto->HContactFromJID(from); if (!hContact) return; @@ -1002,8 +1002,8 @@ void CPepActivity::ProcessItems(const wchar_t *from, HXML itemsNode) if (XmlGetChild(itemsNode, "retract")) { if (hSelfContact) - SetActivity(hSelfContact, NULL, NULL, NULL); - SetActivity(hContact, NULL, NULL, NULL); + SetActivity(hSelfContact, nullptr, nullptr, nullptr); + SetActivity(hContact, nullptr, nullptr, nullptr); return; } @@ -1012,7 +1012,7 @@ void CPepActivity::ProcessItems(const wchar_t *from, HXML itemsNode) return; LPCTSTR szText = XPathT(actNode, "text"); - LPCTSTR szFirstNode = NULL, szSecondNode = NULL; + LPCTSTR szFirstNode = nullptr, szSecondNode = nullptr; HXML n; for (int i=0; n = XmlGetChild(actNode, i); i++) { @@ -1059,7 +1059,7 @@ void CPepActivity::ResetExtraIcon(MCONTACT hContact) void CPepActivity::SetExtraIcon(MCONTACT hContact, char *szActivity) { - ExtraIcon_SetIcon(hExtraActivity, hContact, szActivity == NULL ? NULL : g_ActivityIcons.GetIcolibHandle(szActivity)); + ExtraIcon_SetIcon(hExtraActivity, hContact, szActivity == nullptr ? nullptr : g_ActivityIcons.GetIcolibHandle(szActivity)); } void CPepActivity::SetActivity(MCONTACT hContact, LPCTSTR szFirst, LPCTSTR szSecond, LPCTSTR szText) @@ -1094,7 +1094,7 @@ void CPepActivity::SetActivity(MCONTACT hContact, LPCTSTR szFirst, LPCTSTR szSec if (m_proto->m_pInfoFrame) m_proto->m_pInfoFrame->UpdateInfoItem("$/PEP/activity", hIcon, title); } - else SetExtraIcon(hContact, activity < 0 ? NULL : returnActivity(activity)); + else SetExtraIcon(hContact, activity < 0 ? nullptr : returnActivity(activity)); if (activity >= 0) { wchar_t *p = mir_a2u(ActivityGetId(activity)); @@ -1109,7 +1109,7 @@ void CPepActivity::ShowSetDialog(BYTE) CJabberDlgPepSimple dlg(m_proto, TranslateT("Set Activity")); for (int i=0; i < _countof(g_arrActivities); i++) if (g_arrActivities[i].szFirst || g_arrActivities[i].szSecond) - dlg.AddStatusMode(i, ActivityGetId(i), g_ActivityIcons.GetIcon(returnActivity(i)), TranslateW(g_arrActivities[i].szTitle), (g_arrActivities[i].szSecond != NULL)); + dlg.AddStatusMode(i, ActivityGetId(i), g_ActivityIcons.GetIcon(returnActivity(i)), TranslateW(g_arrActivities[i].szTitle), (g_arrActivities[i].szSecond != nullptr)); dlg.SetActiveStatus(m_mode, m_text); dlg.DoModal(); @@ -1229,22 +1229,22 @@ void CJabberProto::SetContactTune(MCONTACT hContact, LPCTSTR szArtist, LPCTSTR s wchar_t* a2tf(const wchar_t *str, BOOL unicode) { - if (str == NULL) - return NULL; + if (str == nullptr) + return nullptr; return (unicode) ? mir_wstrdup(str) : mir_a2u((char*)str); } -void overrideStr(wchar_t*& dest, const wchar_t *src, BOOL unicode, const wchar_t *def = NULL) +void overrideStr(wchar_t*& dest, const wchar_t *src, BOOL unicode, const wchar_t *def = nullptr) { - if (dest != NULL) { + if (dest != nullptr) { mir_free(dest); - dest = NULL; + dest = nullptr; } - if (src != NULL) + if (src != nullptr) dest = a2tf(src, unicode); - else if (def != NULL) + else if (def != nullptr) dest = mir_wstrdup(def); } @@ -1252,12 +1252,12 @@ INT_PTR __cdecl CJabberProto::OnSetListeningTo(WPARAM, LPARAM lParam) { LISTENINGTOINFO *cm = (LISTENINGTOINFO *)lParam; if (!cm || cm->cbSize != sizeof(LISTENINGTOINFO)) { - SendPepTune(NULL, NULL, NULL, NULL, NULL, NULL); + SendPepTune(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr); delSetting("ListeningTo"); } else { - wchar_t *szArtist = NULL, *szLength = NULL, *szSource = NULL; - wchar_t *szTitle = NULL, *szTrack = NULL; + wchar_t *szArtist = nullptr, *szLength = nullptr, *szSource = nullptr; + wchar_t *szTitle = nullptr, *szTrack = nullptr; BOOL unicode = cm->dwFlags & LTI_UNICODE; @@ -1289,8 +1289,8 @@ INT_PTR __cdecl CJabberProto::OnSetListeningTo(WPARAM, LPARAM lParam) mir_snwprintf(szLengthInSec, L"%d", result); } - SendPepTune(szArtist, szLength ? szLengthInSec : NULL, szSource, szTitle, szTrack, NULL); - SetContactTune(NULL, szArtist, szLength, szSource, szTitle, szTrack); + SendPepTune(szArtist, szLength ? szLengthInSec : nullptr, szSource, szTitle, szTrack, nullptr); + SetContactTune(0, szArtist, szLength, szSource, szTitle, szTrack); mir_free(szArtist); mir_free(szLength); @@ -1337,7 +1337,7 @@ INT_PTR __cdecl CJabberProto::OnGetXStatusEx(WPARAM hContact, LPARAM lParam) return 1; CPepMood *pepMood = (CPepMood*)m_pepServices.Find(JABBER_FEAT_USER_MOOD); - if (pepMood == NULL) + if (pepMood == nullptr) return 1; // fill status member @@ -1347,7 +1347,7 @@ INT_PTR __cdecl CJabberProto::OnGetXStatusEx(WPARAM hContact, LPARAM lParam) // fill status name member if (pData->flags & CSSF_MASK_NAME) { if (pData->flags & CSSF_DEFAULT_NAME) { - DWORD dwXStatus = (pData->wParam == NULL) ? pepMood->m_mode : *pData->wParam; + DWORD dwXStatus = (pData->wParam == nullptr) ? pepMood->m_mode : *pData->wParam; if (dwXStatus >= _countof(g_arrMoods)) return 1; @@ -1358,7 +1358,7 @@ INT_PTR __cdecl CJabberProto::OnGetXStatusEx(WPARAM hContact, LPARAM lParam) if (dwStatusTitleSize > STATUS_TITLE_MAX) dwStatusTitleSize = STATUS_TITLE_MAX; - WideCharToMultiByte(CP_ACP, 0, g_arrMoods[dwXStatus].szName, (DWORD)dwStatusTitleSize, pData->pszName, MAX_PATH, NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, g_arrMoods[dwXStatus].szName, (DWORD)dwStatusTitleSize, pData->pszName, MAX_PATH, nullptr, nullptr); pData->pszName[dwStatusTitleSize] = 0; } } @@ -1421,7 +1421,7 @@ INT_PTR __cdecl CJabberProto::OnSetXStatusEx(WPARAM, LPARAM lParam) int status = (pData->flags & CSSF_MASK_STATUS) ? *pData->status : pepMood->m_mode; if (status >= 0 && status < _countof(g_arrMoods)) { pepMood->m_mode = status; - pepMood->m_text = (pData->flags & CSSF_MASK_MESSAGE) ? JabberStrFixLines(pData->ptszMessage) : NULL; + pepMood->m_text = (pData->flags & CSSF_MASK_MESSAGE) ? JabberStrFixLines(pData->ptszMessage) : nullptr; pepMood->LaunchSetGui(1); return 0; } diff --git a/protocols/JabberG/src/jabber_xstatus.h b/protocols/JabberG/src/jabber_xstatus.h index 604da46b5f..f72839c3e4 100644 --- a/protocols/JabberG/src/jabber_xstatus.h +++ b/protocols/JabberG/src/jabber_xstatus.h @@ -116,7 +116,7 @@ public: for (int i=0; i < getCount(); i++) if (!mir_wstrcmp((*this)[i].GetNode(), node)) return &((*this)[i]); - return NULL; + return nullptr; } }; diff --git a/protocols/JabberG/src/jabber_zstream.cpp b/protocols/JabberG/src/jabber_zstream.cpp index 770f7bacbf..cd820ef2d8 100644 --- a/protocols/JabberG/src/jabber_zstream.cpp +++ b/protocols/JabberG/src/jabber_zstream.cpp @@ -82,7 +82,7 @@ int ThreadData::zlibSend(char* data, int datalen) } while (zStreamOut.avail_out == 0); - if (db_get_b(NULL, "Netlib", "DumpSent", TRUE) == TRUE) + if (db_get_b(0, "Netlib", "DumpSent", TRUE) == TRUE) proto->debugLogA("(ZLIB) Data sent\n%s\n===OUT: %d(%d) bytes", data, datalen, bytesOut); return TRUE; @@ -115,7 +115,7 @@ retry: } int len = datalen - zStreamIn.avail_out; - if (db_get_b(NULL, "Netlib", "DumpRecv", TRUE) == TRUE) { + if (db_get_b(0, "Netlib", "DumpRecv", TRUE) == TRUE) { char* szLogBuffer = (char*)alloca(len+32); memcpy(szLogBuffer, data, len); szLogBuffer[ len ]='\0'; diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h index 775df93f72..79f44f6137 100644 --- a/protocols/JabberG/src/stdafx.h +++ b/protocols/JabberG/src/stdafx.h @@ -667,11 +667,11 @@ struct CJabberAdhocStartupParams wchar_t *m_szNode; CJabberProto *m_pProto; - CJabberAdhocStartupParams(CJabberProto *proto, wchar_t* szJid, wchar_t* szNode = NULL) + CJabberAdhocStartupParams(CJabberProto *proto, wchar_t* szJid, wchar_t* szNode = nullptr) { m_pProto = proto; m_szJid = mir_wstrdup(szJid); - m_szNode = szNode ? mir_wstrdup(szNode) : NULL; + m_szNode = szNode ? mir_wstrdup(szNode) : nullptr; } ~CJabberAdhocStartupParams() { @@ -720,7 +720,7 @@ wchar_t* __stdcall JabberStrFixLines(const wchar_t *str); void __stdcall JabberHttpUrlDecode(wchar_t *str); int __stdcall JabberCombineStatus(int status1, int status2); wchar_t* __stdcall JabberErrorStr(int errorCode); -wchar_t* __stdcall JabberErrorMsg(HXML errorNode, int *errorCode = NULL); +wchar_t* __stdcall JabberErrorMsg(HXML errorNode, int *errorCode = nullptr); time_t __stdcall JabberIsoToUnixTime(const wchar_t *stamp); wchar_t* __stdcall JabberStripJid(const wchar_t *jid, wchar_t *dest, size_t destLen); int __stdcall JabberGetPacketID(HXML n); -- cgit v1.2.3