From a7c24ca48995cf2bf436156302f96b91bf135409 Mon Sep 17 00:00:00 2001 From: Goraf <22941576+Goraf@users.noreply.github.com> Date: Mon, 13 Nov 2017 15:03:31 +0100 Subject: Code modernize ... * replace 0/NULL with nullptr [using clang-tidy] --- protocols/WhatsApp/src/WASocketConnection.cpp | 4 +-- protocols/WhatsApp/src/avatars.cpp | 16 ++++++------ protocols/WhatsApp/src/chat.cpp | 36 +++++++++++++-------------- protocols/WhatsApp/src/connection.cpp | 20 +++++++-------- protocols/WhatsApp/src/contacts.cpp | 6 ++--- protocols/WhatsApp/src/dialogs.cpp | 2 +- protocols/WhatsApp/src/media.cpp | 20 +++++++-------- protocols/WhatsApp/src/messages.cpp | 8 +++--- protocols/WhatsApp/src/proto.cpp | 30 +++++++++++----------- protocols/WhatsApp/src/theme.cpp | 6 ++--- protocols/WhatsApp/src/utils.cpp | 8 +++--- 11 files changed, 78 insertions(+), 78 deletions(-) (limited to 'protocols/WhatsApp/src') diff --git a/protocols/WhatsApp/src/WASocketConnection.cpp b/protocols/WhatsApp/src/WASocketConnection.cpp index 5ba6c781eb..316d8fb5af 100644 --- a/protocols/WhatsApp/src/WASocketConnection.cpp +++ b/protocols/WhatsApp/src/WASocketConnection.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "WASocketConnection.h" -HNETLIBUSER g_hNetlibUser = NULL; +HNETLIBUSER g_hNetlibUser = nullptr; void WASocketConnection::initNetwork(HNETLIBUSER hNetlibUser) throw (WAException) { @@ -19,7 +19,7 @@ WASocketConnection::WASocketConnection(const std::string &dir, int port) throw ( noc.wPort = port; noc.flags = NLOCF_V2; // | NLOCF_SSL; this->hConn = Netlib_OpenConnection(g_hNetlibUser, &noc); - if (this->hConn == NULL) + if (this->hConn == nullptr) throw WAException(getLastErrorMsg(), WAException::SOCKET_EX, WAException::SOCKET_EX_OPEN); this->connected = true; diff --git a/protocols/WhatsApp/src/avatars.cpp b/protocols/WhatsApp/src/avatars.cpp index bb163013d5..4a7bf6e310 100644 --- a/protocols/WhatsApp/src/avatars.cpp +++ b/protocols/WhatsApp/src/avatars.cpp @@ -14,7 +14,7 @@ INT_PTR WhatsAppProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) ptrA szAvatarId(getStringA(pai->hContact, WHATSAPP_KEY_AVATAR_ID)); if (szAvatarId == NULL || (wParam & GAIF_FORCE) != 0) - if (pai->hContact != NULL && m_pConnection != NULL) { + if (pai->hContact != NULL && m_pConnection != nullptr) { m_pConnection->sendGetPicture(id, "image"); return GAIR_WAITFOR; } @@ -70,34 +70,34 @@ INT_PTR WhatsAppProto::GetMyAvatar(WPARAM wParam, LPARAM lParam) static std::vector* sttFileToMem(const wchar_t *ptszFileName) { - HANDLE hFile = CreateFile(ptszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFile(ptszFileName, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile == INVALID_HANDLE_VALUE) - return NULL; + return nullptr; DWORD upperSize, lowerSize = GetFileSize(hFile, &upperSize); std::vector *result = new std::vector(lowerSize); - ReadFile(hFile, (void*)result->data(), lowerSize, &upperSize, NULL); + ReadFile(hFile, (void*)result->data(), lowerSize, &upperSize, nullptr); CloseHandle(hFile); return result; } int WhatsAppProto::InternalSetAvatar(MCONTACT hContact, const char *szJid, const wchar_t *ptszFileName) { - if (!isOnline() || ptszFileName == NULL) + if (!isOnline() || ptszFileName == nullptr) return 1; if (_waccess(ptszFileName, 4) != 0) return errno; ResizeBitmap resize = { 0 }; - if ((resize.hBmp = Bitmap_Load(ptszFileName)) == NULL) + if ((resize.hBmp = Bitmap_Load(ptszFileName)) == nullptr) return 2; resize.size = sizeof(resize); resize.fit = RESIZEBITMAP_KEEP_PROPORTIONS; resize.max_height = resize.max_width = 96; HBITMAP hbmpPreview = (HBITMAP)CallService(MS_IMG_RESIZE, (LPARAM)&resize, 0); - if (hbmpPreview == NULL) + if (hbmpPreview == nullptr) return 3; wchar_t tszTempFile[MAX_PATH], tszMyFile[MAX_PATH]; @@ -111,7 +111,7 @@ int WhatsAppProto::InternalSetAvatar(MCONTACT hContact, const char *szJid, const wcsncpy_s(tszTempFile, (tszContactAva + L".preview").c_str(), _TRUNCATE); } - IMGSRVC_INFO saveInfo = { sizeof(saveInfo), 0 }; + IMGSRVC_INFO saveInfo = { sizeof(saveInfo), nullptr }; saveInfo.hbm = hbmpPreview; saveInfo.tszName = tszTempFile; saveInfo.dwMask = IMGI_HBITMAP; diff --git a/protocols/WhatsApp/src/chat.cpp b/protocols/WhatsApp/src/chat.cpp index 3fc47cb8f9..24cdc5a177 100644 --- a/protocols/WhatsApp/src/chat.cpp +++ b/protocols/WhatsApp/src/chat.cpp @@ -45,7 +45,7 @@ int WhatsAppProto::onGroupChatEvent(WPARAM, LPARAM lParam) std::string chat_id(T2Utf(gch->ptszID)); WAChatInfo *pInfo = SafeGetChat(chat_id); - if (pInfo == NULL) + if (pInfo == nullptr) return 0; switch (gch->iType) { @@ -63,7 +63,7 @@ int WhatsAppProto::onGroupChatEvent(WPARAM, LPARAM lParam) try { int msgId = GetSerial(); - time_t now = time(NULL); + time_t now = time(nullptr); std::string id = Utilities::intToStr(now) + "-" + Utilities::intToStr(msgId); FMessage fmsg(chat_id, true, id); @@ -101,14 +101,14 @@ int WhatsAppProto::onGroupChatEvent(WPARAM, LPARAM lParam) static gc_item sttLogListItems[] = { { LPGENW("&Invite a user"), IDM_INVITE, MENU_ITEM }, - { NULL, 0, MENU_SEPARATOR }, + { nullptr, 0, MENU_SEPARATOR }, { LPGENW("&Room options"), 0, MENU_NEWPOPUP }, { LPGENW("View/change &topic"), IDM_TOPIC, MENU_POPUPITEM }, { LPGENW("&Quit chat session"), IDM_LEAVE, MENU_POPUPITEM }, #ifdef _DEBUG { LPGENW("Set &avatar"), IDM_AVATAR, MENU_POPUPITEM }, // doesn't work, therefore commented out #endif - { NULL, 0, MENU_SEPARATOR }, + { nullptr, 0, MENU_SEPARATOR }, { LPGENW("Copy room &JID"), IDM_CPY_RJID, MENU_ITEM }, { LPGENW("Copy room topic"), IDM_CPY_TOPIC, MENU_ITEM }, }; @@ -171,7 +171,7 @@ void WhatsAppProto::SetChatAvatar(WAChatInfo *pInfo) OPENFILENAME ofn = { 0 }; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.lpstrFilter = filter; - ofn.hwndOwner = 0; + ofn.hwndOwner = nullptr; ofn.lpstrFile = tszFileName; ofn.nMaxFile = ofn.nMaxFileTitle = _countof(tszFileName); ofn.Flags = OFN_HIDEREADONLY; @@ -188,9 +188,9 @@ void WhatsAppProto::SetChatAvatar(WAChatInfo *pInfo) static gc_item sttNickListItems[] = { { LPGENW("&Add to roster"), IDM_ADD_RJID, MENU_POPUPITEM }, - { NULL, 0, MENU_SEPARATOR }, + { nullptr, 0, MENU_SEPARATOR }, { 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 }, }; @@ -267,7 +267,7 @@ int WhatsAppProto::OnDeleteChat(WPARAM hContact, LPARAM) int WhatsAppProto::OnChatMenu(WPARAM, LPARAM lParam) { GCMENUITEMS *gcmi = (GCMENUITEMS*)lParam; - if (gcmi == NULL) + if (gcmi == nullptr) return 0; if (mir_strcmpi(gcmi->pszModule, m_szModuleName)) @@ -323,7 +323,7 @@ wchar_t* WhatsAppProto::GetChatUserNick(const std::string &jid) } else tszNick = str2t(m_szNick); - if (tszNick == NULL) + if (tszNick == nullptr) tszNick = mir_wstrdup(TranslateT("Unknown user")); return tszNick; } @@ -340,7 +340,7 @@ WAChatInfo* WhatsAppProto::SafeGetChat(const std::string &jid) void WhatsAppProto::onGroupInfo(const std::string &jid, const std::string &owner, const std::string &subject, const std::string &subject_owner, int time_subject, int) { WAChatInfo *pInfo = SafeGetChat(jid); - if (pInfo == NULL) { + if (pInfo == nullptr) { pInfo = InitChat(jid, subject); pInfo->bActive = true; time_subject = 0; @@ -363,7 +363,7 @@ void WhatsAppProto::onGroupMessage(const FMessage &pMsg) } WAChatInfo *pInfo = SafeGetChat(pMsg.key.remote_jid); - if (pInfo == NULL) { + if (pInfo == nullptr) { pInfo = InitChat(pMsg.key.remote_jid, ""); pInfo->bActive = true; } @@ -395,7 +395,7 @@ void WhatsAppProto::onGroupMessage(const FMessage &pMsg) void WhatsAppProto::onGroupNewSubject(const std::string &gjid, const std::string &author, const std::string &newSubject, int ts) { WAChatInfo *pInfo = SafeGetChat(gjid); - if (pInfo == NULL) + if (pInfo == nullptr) return; ptrW tszText(str2t(newSubject)); @@ -420,7 +420,7 @@ void WhatsAppProto::onGroupNewSubject(const std::string &gjid, const std::string void WhatsAppProto::onGroupAddUser(const std::string &gjid, const std::string &ujid, int ts) { WAChatInfo *pInfo = SafeGetChat(gjid); - if (pInfo == NULL || !pInfo->bActive) + if (pInfo == nullptr || !pInfo->bActive) return; ptrW tszUID(str2t(ujid)); @@ -437,7 +437,7 @@ void WhatsAppProto::onGroupAddUser(const std::string &gjid, const std::string &u void WhatsAppProto::onGroupRemoveUser(const std::string &gjid, const std::string &ujid, int ts) { WAChatInfo *pInfo = SafeGetChat(gjid); - if (pInfo == NULL) + if (pInfo == nullptr) return; ptrW tszUID(str2t(ujid)); @@ -454,7 +454,7 @@ void WhatsAppProto::onGroupRemoveUser(const std::string &gjid, const std::string void WhatsAppProto::onLeaveGroup(const std::string &gjid) { WAChatInfo *pInfo = SafeGetChat(gjid); - if (pInfo == NULL) + if (pInfo == nullptr) return; Chat_Terminate(m_szModuleName, pInfo->tszJid); @@ -468,7 +468,7 @@ void WhatsAppProto::onGetParticipants(const std::string &gjid, const std::vector mir_cslock lck(m_csChats); WAChatInfo *pInfo = m_chats[gjid]; - if (pInfo == NULL) + if (pInfo == nullptr) return; pInfo->bActive = true; @@ -499,7 +499,7 @@ void WhatsAppProto::onGroupCreated(const std::string &gjid, const std::string &s void WhatsAppProto::onGroupMessageReceived(const FMessage &msg) { WAChatInfo *pInfo = SafeGetChat(msg.key.remote_jid); - if (pInfo == NULL) + if (pInfo == nullptr) return; auto p = pInfo->m_unsentMsgs.find(msg.key.id); @@ -513,7 +513,7 @@ void WhatsAppProto::onGroupMessageReceived(const FMessage &msg) gce.dwFlags = GCEF_ADDTOLOG; gce.ptszUID = tszUID; gce.ptszNick = tszNick; - gce.time = time(NULL); + gce.time = time(nullptr); gce.ptszText = p->second.c_str(); gce.bIsMe = m_szJid == msg.remote_resource; Chat_Event(&gce); diff --git a/protocols/WhatsApp/src/connection.cpp b/protocols/WhatsApp/src/connection.cpp index 646a5b134f..a7fa47958f 100644 --- a/protocols/WhatsApp/src/connection.cpp +++ b/protocols/WhatsApp/src/connection.cpp @@ -34,16 +34,16 @@ void WhatsAppProto::stayConnectedLoop(void*) Mutex writerMutex; bool error = false; - m_pSocket = NULL; + m_pSocket = nullptr; while (true) { - if (m_pConnection != NULL) { + if (m_pConnection != nullptr) { delete m_pConnection; - m_pConnection = NULL; + m_pConnection = nullptr; } - if (m_pSocket != NULL) { + if (m_pSocket != nullptr) { delete m_pSocket; - m_pSocket = NULL; + m_pSocket = nullptr; } if (m_iDesiredStatus == ID_STATUS_OFFLINE || error) { @@ -85,11 +85,11 @@ void WhatsAppProto::stayConnectedLoop(void*) ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, m_iStatus); ToggleStatusMenuItems(true); - ForkThread(&WhatsAppProto::ProcessBuddyList, NULL); + ForkThread(&WhatsAppProto::ProcessBuddyList, nullptr); // #TODO Move out of try block. Exception is expected on disconnect while (true) { - m_tLastWriteTime = time(NULL); + m_tLastWriteTime = time(nullptr); if (!m_pConnection->read()) break; } @@ -114,13 +114,13 @@ void WhatsAppProto::stayConnectedLoop(void*) void WhatsAppProto::sentinelLoop(void*) { while (WaitForSingleObjectEx(update_loop_lock_, 1000, true) == WAIT_TIMEOUT) { - if (m_iStatus != ID_STATUS_OFFLINE && m_pConnection != NULL && m_iDesiredStatus == m_iStatus) { + if (m_iStatus != ID_STATUS_OFFLINE && m_pConnection != nullptr && m_iDesiredStatus == m_iStatus) { // #TODO Quiet after pong or tree read? - int quietInterval = difftime(time(NULL), m_tLastWriteTime); + int quietInterval = difftime(time(nullptr), m_tLastWriteTime); if (quietInterval >= MAX_SILENT_INTERVAL) { try { debugLogA("send ping"); - m_tLastWriteTime = time(NULL); + m_tLastWriteTime = time(nullptr); m_pConnection->sendPing(); } catch (exception &e) { diff --git a/protocols/WhatsApp/src/contacts.cpp b/protocols/WhatsApp/src/contacts.cpp index f35fc5c565..7674985311 100644 --- a/protocols/WhatsApp/src/contacts.cpp +++ b/protocols/WhatsApp/src/contacts.cpp @@ -8,7 +8,7 @@ MCONTACT WhatsAppProto::AddToContactList(const std::string &jid, const char *new // First, check if this contact exists MCONTACT hContact = ContactIDToHContact(jid); if (hContact) { - if (new_name != NULL) { + if (new_name != nullptr) { DBVARIANT dbv; string oldName; if (db_get_utf(hContact, m_szModuleName, WHATSAPP_KEY_NICK, &dbv)) @@ -44,7 +44,7 @@ MCONTACT WhatsAppProto::AddToContactList(const std::string &jid, const char *new db_set_b(hContact, "CList", "NotOnList", 1); db_set_ws(hContact, "CList", "Group", m_tszDefaultGroup); - if (new_name != NULL) + if (new_name != nullptr) db_set_utf(hContact, m_szModuleName, WHATSAPP_KEY_NICK, new_name); return hContact; @@ -110,7 +110,7 @@ void WhatsAppProto::onAvailable(const std::string ¶mString, bool paramBoolea if (hContact != NULL) { if (paramBoolean) { setWord(hContact, "Status", ID_STATUS_ONLINE); - setDword(hContact, WHATSAPP_KEY_LAST_SEEN, time(NULL)); + setDword(hContact, WHATSAPP_KEY_LAST_SEEN, time(nullptr)); } else { setWord(hContact, "Status", ID_STATUS_OFFLINE); diff --git a/protocols/WhatsApp/src/dialogs.cpp b/protocols/WhatsApp/src/dialogs.cpp index 39e5e2831f..1083463564 100644 --- a/protocols/WhatsApp/src/dialogs.cpp +++ b/protocols/WhatsApp/src/dialogs.cpp @@ -164,7 +164,7 @@ class CInviteDialog : public CProtoDlgBase 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); diff --git a/protocols/WhatsApp/src/media.cpp b/protocols/WhatsApp/src/media.cpp index 9b3bb6f5ff..f2f1fb3afe 100644 --- a/protocols/WhatsApp/src/media.cpp +++ b/protocols/WhatsApp/src/media.cpp @@ -2,26 +2,26 @@ HANDLE WhatsAppProto::SendFile(MCONTACT hContact, const wchar_t* desc, wchar_t **ppszFiles) { if (!isOnline()) - return 0; + return nullptr; ptrA jid(getStringA(hContact, "ID")); if (jid == NULL) - return 0; + return nullptr; // input validation char *name = mir_utf8encodeW(ppszFiles[0]); string mime = MediaUploader::getMimeFromExtension(split(name, '.')[1]); if (mime.empty()) { mir_free(name); - return 0; + return nullptr; } // get file size FILE *hFile = _wfopen(ppszFiles[0], L"rb"); - if (hFile == NULL) { + if (hFile == nullptr) { debugLogA(__FUNCTION__": cannot open file %s", ppszFiles[0]); mir_free(name); - return 0; + return nullptr; } _fseeki64(hFile, 0, SEEK_END); uint64_t fileSize = _ftelli64(hFile); @@ -35,28 +35,28 @@ HANDLE WhatsAppProto::SendFile(MCONTACT hContact, const wchar_t* desc, wchar_t * case FMessage::WA_TYPE_IMAGE: if (fileSize >= 5 * 1024 * 1024) { mir_free(name); - return 0; + return nullptr; } break; case FMessage::WA_TYPE_AUDIO: if (fileSize >= 10 * 1024 * 1024) { mir_free(name); - return 0; + return nullptr; } break; case FMessage::WA_TYPE_VIDEO: if (fileSize >= 20 * 1024 * 1024) { mir_free(name); - return 0; + return nullptr; } break; default: mir_free(name); - return 0; + return nullptr; } int msgId = GetSerial(); - time_t now = time(NULL); + time_t now = time(nullptr); std::string msgid = Utilities::intToStr(now) + "-" + Utilities::intToStr(msgId); FMessage * fmsg = new FMessage(std::string(jid), true, msgid); fmsg->media_url = name; diff --git a/protocols/WhatsApp/src/messages.cpp b/protocols/WhatsApp/src/messages.cpp index 98bea34363..0d1ebff87e 100644 --- a/protocols/WhatsApp/src/messages.cpp +++ b/protocols/WhatsApp/src/messages.cpp @@ -34,7 +34,7 @@ void WhatsAppProto::onMessageForMe(const FMessage &pMsg) if (getByte(WHATSAPP_KEY_USE_REMOTE_TIME, 0)) recv.timestamp = pMsg.timestamp; else - recv.timestamp = time(NULL); + recv.timestamp = time(nullptr); ProtoChainRecvMsg(hContact, &recv); } @@ -49,21 +49,21 @@ int WhatsAppProto::SendMsg(MCONTACT hContact, int, const char *msg) if (jid == NULL) return 0; - if (m_pConnection == NULL) { + if (m_pConnection == nullptr) { debugLogA("No connection"); return 0; } int msgId = GetSerial(); try { - time_t now = time(NULL); + time_t now = time(nullptr); std::string id = Utilities::intToStr(now) + "-" + Utilities::intToStr(msgId); FMessage fmsg(std::string(jid), true, id); fmsg.timestamp = now; fmsg.data = msg; m_pConnection->sendMessage(&fmsg); - utils::setStatusMessage(hContact, NULL); + utils::setStatusMessage(hContact, nullptr); } catch (exception &e) { debugLogA("exception: %s", e.what()); diff --git a/protocols/WhatsApp/src/proto.cpp b/protocols/WhatsApp/src/proto.cpp index 3d19f7fe72..6b048b33a4 100644 --- a/protocols/WhatsApp/src/proto.cpp +++ b/protocols/WhatsApp/src/proto.cpp @@ -16,7 +16,7 @@ WhatsAppProto::WhatsAppProto(const char *proto_name, const wchar_t *username) : PROTO(proto_name, username), m_tszDefaultGroup(getWStringA(WHATSAPP_KEY_DEF_GROUP)) { - update_loop_lock_ = CreateEvent(NULL, false, false, NULL); + update_loop_lock_ = CreateEvent(nullptr, false, false, nullptr); db_set_resident(m_szModuleName, "StatusMsg"); @@ -40,10 +40,10 @@ WhatsAppProto::WhatsAppProto(const char *proto_name, const wchar_t *username) nlu.szSettingsModule = m_szModuleName; nlu.szDescriptiveName.w = descr; m_hNetlibUser = Netlib_RegisterUser(&nlu); - if (m_hNetlibUser == NULL) { + if (m_hNetlibUser == nullptr) { wchar_t error[200]; mir_snwprintf(error, TranslateT("Unable to initialize Netlib for %s."), m_tszUserName); - MessageBox(NULL, error, L"Miranda NG", MB_OK | MB_ICONERROR); + MessageBox(nullptr, error, L"Miranda NG", MB_OK | MB_ICONERROR); } WASocketConnection::initNetwork(m_hNetlibUser); @@ -136,7 +136,7 @@ int WhatsAppProto::SetStatus(int new_status) } if (m_iDesiredStatus == ID_STATUS_OFFLINE) { - if (m_pSocket != NULL) { + if (m_pSocket != nullptr) { SetEvent(update_loop_lock_); m_pSocket->forceShutdown(); debugLogA("Forced shutdown"); @@ -145,15 +145,15 @@ int WhatsAppProto::SetStatus(int new_status) m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); } - else if (m_pSocket == NULL && !IsStatusConnecting(m_iStatus)) { + else if (m_pSocket == nullptr && !IsStatusConnecting(m_iStatus)) { m_iStatus = ID_STATUS_CONNECTING; ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); ResetEvent(update_loop_lock_); - ForkThread(&WhatsAppProto::sentinelLoop, 0); - ForkThread(&WhatsAppProto::stayConnectedLoop, 0); + ForkThread(&WhatsAppProto::sentinelLoop, nullptr); + ForkThread(&WhatsAppProto::stayConnectedLoop, nullptr); } - else if (m_pConnection != NULL) { + else if (m_pConnection != nullptr) { if (m_iDesiredStatus == ID_STATUS_ONLINE) { m_pConnection->sendAvailableForChat(); m_iStatus = ID_STATUS_ONLINE; @@ -173,7 +173,7 @@ int WhatsAppProto::SetStatus(int new_status) MCONTACT WhatsAppProto::AddToList(int flags, PROTOSEARCHRESULT *psr) { - if (psr->id.w == NULL) + if (psr->id.w == nullptr) return NULL; std::string phone(T2Utf(psr->id.w)); @@ -209,7 +209,7 @@ void WhatsAppProto::SearchAckThread(void *targ) HANDLE WhatsAppProto::SearchBasic(const wchar_t* id) { if (isOffline()) - return 0; + return nullptr; // fake - we always accept search SearchParam *param = new SearchParam(id, GetSerial()); @@ -231,7 +231,7 @@ bool WhatsAppProto::Register(int state, const string &cc, const string &number, string idx; DBVARIANT dbv; - if (g_hNetlibUser == NULL) { + if (g_hNetlibUser == nullptr) { NotifyEvent(m_tszUserName, TranslateT("Network connection error."), NULL, WHATSAPP_EVENT_CLIENT); return false; } @@ -243,7 +243,7 @@ bool WhatsAppProto::Register(int state, const string &cc, const string &number, if (idx.empty()) { std::stringstream tm; - tm << time(NULL); + tm << time(nullptr); BYTE idxBuf[16]; utils::md5string(tm.str(), idxBuf); idx = std::string((const char*)idxBuf, 16); @@ -264,7 +264,7 @@ bool WhatsAppProto::Register(int state, const string &cc, const string &number, NETLIBHTTPREQUEST* pnlhr = Netlib_HttpTransaction(g_hNetlibUser, &nlhr); const wchar_t *ptszTitle = TranslateT("Registration"); - if (pnlhr == NULL) { + if (pnlhr == nullptr) { NotifyEvent(ptszTitle, TranslateT("Registration failed. Invalid server response."), NULL, WHATSAPP_EVENT_CLIENT); return false; } @@ -430,9 +430,9 @@ void WhatsAppProto::NotifyEvent(const wchar_t *title, const wchar_t *info, MCONT } if (FLAG_CONTAINS(flags, WHATSAPP_EVENT_CLIENT)) - MessageBox(NULL, info, title, MB_OK | MB_ICONINFORMATION); + MessageBox(nullptr, info, title, MB_OK | MB_ICONINFORMATION); exit: - if (szUrl != NULL) + if (szUrl != nullptr) mir_free(szUrl); } diff --git a/protocols/WhatsApp/src/theme.cpp b/protocols/WhatsApp/src/theme.cpp index 70ba827608..e280a623ec 100644 --- a/protocols/WhatsApp/src/theme.cpp +++ b/protocols/WhatsApp/src/theme.cpp @@ -19,7 +19,7 @@ HANDLE GetIconHandle(const char* name) if (mir_strcmp(icons[i].szName, name) == 0) return icons[i].hIcolib; - return 0; + return nullptr; } char* GetIconDescription(const char* name) @@ -36,13 +36,13 @@ static WhatsAppProto* GetInstanceByHContact(MCONTACT hContact) { char *proto = GetContactProto(hContact); if (!proto) - return 0; + return nullptr; for (int i = 0; i < g_Instances.getCount(); i++) if (!mir_strcmp(proto, g_Instances[i].m_szModuleName)) return &g_Instances[i]; - return 0; + return nullptr; } void WhatsAppProto::InitMenu() diff --git a/protocols/WhatsApp/src/utils.cpp b/protocols/WhatsApp/src/utils.cpp index 7ae1c8fcfa..d335133912 100644 --- a/protocols/WhatsApp/src/utils.cpp +++ b/protocols/WhatsApp/src/utils.cpp @@ -2,8 +2,8 @@ wchar_t* utils::removeA(wchar_t *str) { - if (str == NULL) - return NULL; + if (str == nullptr) + return nullptr; wchar_t *p = wcschr(str, '@'); if (p) *p = 0; @@ -34,11 +34,11 @@ std::string getLastErrorMsg() FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, + nullptr, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&lpMsgBuf, - 0, NULL); + 0, nullptr); std::string ret((LPSTR)lpMsgBuf); LocalFree(lpMsgBuf); -- cgit v1.2.3