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/Twitter/src/chat.cpp | 4 ++-- protocols/Twitter/src/connection.cpp | 10 +++++----- protocols/Twitter/src/contacts.cpp | 6 +++--- protocols/Twitter/src/proto.cpp | 22 +++++++++++----------- protocols/Twitter/src/theme.cpp | 6 +++--- protocols/Twitter/src/utility.cpp | 4 ++-- 6 files changed, 26 insertions(+), 26 deletions(-) (limited to 'protocols/Twitter/src') diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp index b323d0dbfc..870ef95d00 100644 --- a/protocols/Twitter/src/chat.cpp +++ b/protocols/Twitter/src/chat.cpp @@ -92,7 +92,7 @@ void TwitterProto::AddChatContact(const char *name, const char *nick) ptrW wszNick(mir_a2u(nick ? nick : name)); GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_JOIN }; - gce.time = DWORD(time(0)); + gce.time = DWORD(time(nullptr)); gce.ptszNick = wszNick; gce.ptszUID = wszId; gce.ptszStatus = L"Normal"; @@ -104,7 +104,7 @@ void TwitterProto::DeleteChatContact(const char *name) ptrW wszId(mir_a2u(name)); GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_PART }; - gce.time = DWORD(time(0)); + gce.time = DWORD(time(nullptr)); gce.ptszNick = wszId; gce.ptszUID = gce.ptszNick; Chat_Event(&gce); diff --git a/protocols/Twitter/src/connection.cpp b/protocols/Twitter/src/connection.cpp index 3e399e6e5e..3cc359cc59 100644 --- a/protocols/Twitter/src/connection.cpp +++ b/protocols/Twitter/src/connection.cpp @@ -68,7 +68,7 @@ void TwitterProto::SignOn(void*) OnJoinChat(0, true); SetAllContactStatuses(ID_STATUS_ONLINE); - hMsgLoop_ = ForkThreadEx(&TwitterProto::MessageLoop, NULL, 0); + hMsgLoop_ = ForkThreadEx(&TwitterProto::MessageLoop, nullptr, nullptr); } debugLogA("***** SignOn complete"); @@ -170,7 +170,7 @@ bool TwitterProto::NegotiateConnection() mir_snwprintf(buf, _countof(buf), AuthorizeUrl.c_str(), oauthToken.c_str()); debugLogW(L"**NegotiateConnection - Launching %s", buf); - ShellExecute(NULL, L"open", buf, NULL, NULL, SW_SHOWNORMAL); + ShellExecute(nullptr, L"open", buf, nullptr, nullptr, SW_SHOWNORMAL); ShowPinDialog(); } @@ -388,7 +388,7 @@ struct update_avatar /* void *p should always be a struct of type update_avatar */ void TwitterProto::UpdateAvatarWorker(void *p) { - if (p == 0) + if (p == nullptr) return; std::auto_ptr data(static_cast(p)); DBVARIANT dbv = { 0 }; @@ -497,7 +497,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM case WM_COMMAND: // Get the plugin data (we need the Popup service to do it) url = (std::string *)PUGetPluginData(hwnd); - if (url != NULL) + if (url != nullptr) Utils_OpenUrl(url->c_str()); // Intentionally no break here @@ -540,7 +540,7 @@ void TwitterProto::ShowContactPopup(MCONTACT hContact, const std::string &text, db_free(&dbv); } - if (url != NULL) { + if (url != nullptr) { popup.PluginWindowProc = PopupWindowProc; popup.PluginData = (void *)url; } diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp index 9c9f6f4d50..762ccfb86c 100644 --- a/protocols/Twitter/src/contacts.cpp +++ b/protocols/Twitter/src/contacts.cpp @@ -22,7 +22,7 @@ along with this program. If not, see . void TwitterProto::AddToListWorker(void *pArg) { // TODO: what happens if there is an error? - if (pArg == 0) + if (pArg == nullptr) return; char *name = static_cast(pArg); @@ -70,7 +70,7 @@ void TwitterProto::UpdateInfoWorker(void *arg) } UpdateAvatar(hContact, user.profile_image_url, true); - ProtoBroadcastAck(hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, 0); + ProtoBroadcastAck(hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, nullptr); } int TwitterProto::GetInfo(MCONTACT hContact, int info_type) @@ -102,7 +102,7 @@ struct search_query void TwitterProto::DoSearch(void *pArg) { - if (pArg == 0) + if (pArg == nullptr) return; search_query *query = static_cast(pArg); diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp index 4153006ee9..4a4fac9ca2 100644 --- a/protocols/Twitter/src/proto.cpp +++ b/protocols/Twitter/src/proto.cpp @@ -119,7 +119,7 @@ struct send_direct void TwitterProto::SendSuccess(void *p) { - if (p == 0) + if (p == nullptr) return; send_direct *data = static_cast(p); @@ -213,7 +213,7 @@ INT_PTR TwitterProto::ReplyToTweet(WPARAM wParam, LPARAM) { MCONTACT hContact = (MCONTACT) wParam; // TODO: support replying to tweets instead of just users - HWND hDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_TWEET), 0, tweet_proc, reinterpret_cast(this)); + HWND hDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_TWEET), nullptr, tweet_proc, reinterpret_cast(this)); DBVARIANT dbv; if (!getString(hContact, TWITTER_KEY_UN, &dbv)) { @@ -292,7 +292,7 @@ INT_PTR TwitterProto::OnTweet(WPARAM, LPARAM) if (m_iStatus != ID_STATUS_ONLINE) return 1; - HWND hDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_TWEET), 0, tweet_proc, reinterpret_cast(this)); + HWND hDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_TWEET), nullptr, tweet_proc, reinterpret_cast(this)); ShowWindow(hDlg, SW_SHOW); return 0; } @@ -308,10 +308,10 @@ int TwitterProto::OnModulesLoaded(WPARAM, LPARAM) mir_snwprintf(descr, TranslateT("%s server connection"), m_tszUserName); 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); } // Create avatar network connection (TODO: probably remove this) @@ -321,10 +321,10 @@ int TwitterProto::OnModulesLoaded(WPARAM, LPARAM) mir_snwprintf(descr, TranslateT("%s avatar connection"), m_tszUserName); nlu.szDescriptiveName.w = descr; hAvatarNetlib_ = Netlib_RegisterUser(&nlu); - if (hAvatarNetlib_ == NULL) { + if (hAvatarNetlib_ == nullptr) { wchar_t error[200]; mir_snwprintf(error, TranslateT("Unable to initialize Netlib for %s."), TranslateT("Twitter (avatars)")); - MessageBox(NULL, error, L"Miranda NG", MB_OK | MB_ICONERROR); + MessageBox(nullptr, error, L"Miranda NG", MB_OK | MB_ICONERROR); } twit_.set_handle(this, m_hNetlibUser); @@ -357,7 +357,7 @@ int TwitterProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) int TwitterProto::ShowPinDialog() { - HWND hDlg = (HWND)DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_TWITTERPIN), 0, pin_proc, reinterpret_cast(this)); + HWND hDlg = (HWND)DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_TWITTERPIN), nullptr, pin_proc, reinterpret_cast(this)); ShowWindow(hDlg, SW_SHOW); return 0; } @@ -377,7 +377,7 @@ void TwitterProto::ShowPopup(const wchar_t *text, int Error) if (ServiceExists(MS_POPUP_ADDPOPUPT)) PUAddPopupT(&popup); else - MessageBox(0, popup.lptzText, popup.lptzContactName, 0); + MessageBox(nullptr, popup.lptzText, popup.lptzContactName, 0); } void TwitterProto::ShowPopup(const char *text, int Error) @@ -394,14 +394,14 @@ void TwitterProto::ShowPopup(const char *text, int Error) if (ServiceExists(MS_POPUP_ADDPOPUPT)) PUAddPopupT(&popup); else - MessageBox(0, popup.lptzText, popup.lptzContactName, 0); + MessageBox(nullptr, popup.lptzText, popup.lptzContactName, 0); } // TODO: the more I think about it, the more I think all twit.* methods should // be in MessageLoop void TwitterProto::SendTweetWorker(void *p) { - if (p == 0) + if (p == nullptr) return; char *text = static_cast(p); diff --git a/protocols/Twitter/src/theme.cpp b/protocols/Twitter/src/theme.cpp index a32b8e6e46..68638dcfed 100644 --- a/protocols/Twitter/src/theme.cpp +++ b/protocols/Twitter/src/theme.cpp @@ -50,7 +50,7 @@ HANDLE GetIconHandle(const char *name) if (mir_strcmp(icons[i].szName, name) == 0) return icons[i].hIcolib; - return 0; + return nullptr; } // Contact List menu stuff @@ -61,13 +61,13 @@ static TwitterProto* 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; } template diff --git a/protocols/Twitter/src/utility.cpp b/protocols/Twitter/src/utility.cpp index cbd0f18093..9f5d329e30 100644 --- a/protocols/Twitter/src/utility.cpp +++ b/protocols/Twitter/src/utility.cpp @@ -64,7 +64,7 @@ http::response mir_twitter::slurp(const std::string &url, http::method meth, OAu if (oauthAccessTokenSecret_.size() > 0) { ppro_->debugLogA("**SLURP::GET - we have a oauthAccessTokenSecret"); } if (pin_.size() > 0) { ppro_->debugLogA("**SLURP::GET - we have a pin"); } - auth = OAuthWebRequestSubmit(url_WSTR, L"GET", NULL, consumerKey_, consumerSecret_, + auth = OAuthWebRequestSubmit(url_WSTR, L"GET", nullptr, consumerKey_, consumerSecret_, oauthAccessToken_, oauthAccessTokenSecret_, pin_); } else if (meth == http::post) { @@ -122,7 +122,7 @@ http::response mir_twitter::slurp(const std::string &url, http::method meth, OAu Netlib_FreeHttpRequest(resp); } else { - httpPOST_ = NULL; + httpPOST_ = nullptr; ppro_->debugLogA("SLURP - there was no response!"); } -- cgit v1.2.3