diff options
author | George Hazan <ghazan@miranda.im> | 2018-01-03 19:34:25 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-01-03 19:34:39 +0300 |
commit | a0ad33a285bac4d7f0ad3f29c9edc925e8c1429e (patch) | |
tree | 68f2f839a567fa98f7941de08cf9bfb0ad37c3e9 | |
parent | 8fd0e627d37cd4aef97f2c49e5b042e86e184544 (diff) |
code cleaning
-rw-r--r-- | protocols/FacebookRM/src/avatars.cpp | 6 | ||||
-rw-r--r-- | protocols/FacebookRM/src/captcha.cpp | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/chat.cpp | 76 | ||||
-rw-r--r-- | protocols/FacebookRM/src/client.h | 14 | ||||
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 16 | ||||
-rw-r--r-- | protocols/FacebookRM/src/connection.cpp | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/contacts.cpp | 28 | ||||
-rw-r--r-- | protocols/FacebookRM/src/dialogs.cpp | 40 | ||||
-rw-r--r-- | protocols/FacebookRM/src/entities.h | 33 | ||||
-rw-r--r-- | protocols/FacebookRM/src/http_request.h | 6 | ||||
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 61 | ||||
-rw-r--r-- | protocols/FacebookRM/src/list.hpp | 36 | ||||
-rw-r--r-- | protocols/FacebookRM/src/messages.cpp | 8 | ||||
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 34 | ||||
-rw-r--r-- | protocols/FacebookRM/src/proto.cpp | 64 | ||||
-rw-r--r-- | protocols/FacebookRM/src/proto.h | 8 | ||||
-rw-r--r-- | protocols/FacebookRM/src/requests/feeds.h | 2 |
17 files changed, 198 insertions, 238 deletions
diff --git a/protocols/FacebookRM/src/avatars.cpp b/protocols/FacebookRM/src/avatars.cpp index 5a8fd44786..91837ce2d8 100644 --- a/protocols/FacebookRM/src/avatars.cpp +++ b/protocols/FacebookRM/src/avatars.cpp @@ -25,7 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. bool FacebookProto::GetDbAvatarInfo(PROTO_AVATAR_INFORMATION &pai, std::string *url)
{
ptrA id(getStringA(pai.hContact, FACEBOOK_KEY_ID));
- if (id == NULL)
+ if (id == nullptr)
return false;
if (url) {
@@ -62,10 +62,10 @@ void FacebookProto::CheckAvatarChange(MCONTACT hContact, const std::string &imag // Check for avatar change
ptrA old_name(getStringA(hContact, FACEBOOK_KEY_AVATAR));
- bool update_required = (old_name == NULL || image_name.compare(old_name) != 0);
+ bool update_required = (old_name == nullptr || image_name.compare(old_name) != 0);
// TODO: Remove this in some newer version
- if (old_name == NULL) {
+ if (old_name == nullptr) {
// Remove AvatarURL value, which was used in previous versions of plugin
delSetting(hContact, "AvatarURL");
}
diff --git a/protocols/FacebookRM/src/captcha.cpp b/protocols/FacebookRM/src/captcha.cpp index f1685d4b3e..bcd952fccc 100644 --- a/protocols/FacebookRM/src/captcha.cpp +++ b/protocols/FacebookRM/src/captcha.cpp @@ -53,7 +53,7 @@ static INT_PTR CALLBACK CaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam case IDC_TITLE: return (INT_PTR)GetStockObject(WHITE_BRUSH); } - return NULL; + return 0; case WM_PAINT: if (params) { diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp index 7d24968178..8225ef4b6b 100644 --- a/protocols/FacebookRM/src/chat.cpp +++ b/protocols/FacebookRM/src/chat.cpp @@ -71,14 +71,11 @@ int FacebookProto::OnGCEvent(WPARAM, LPARAM lParam) switch (hook->iType) { case GC_USER_MESSAGE: - { + if (isOnline()) { + debugLogA(" > Chat - Outgoing message"); std::string msg = _T2A(hook->ptszText, CP_UTF8); std::string chat_id = _T2A(hook->ptszID, CP_UTF8); - - if (isOnline()) { - debugLogA(" > Chat - Outgoing message"); - ForkThread(&FacebookProto::SendChatMsgWorker, new send_chat(chat_id, msg)); - } + ForkThread(&FacebookProto::SendChatMsgWorker, new send_chat(chat_id, msg)); } break; @@ -96,57 +93,32 @@ int FacebookProto::OnGCEvent(WPARAM, LPARAM lParam) } break; - /* - case GC_USER_LOGMENU: - { - switch(hook->dwData) - { - case 10: - DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, invite_to_chat_dialog, - LPARAM(new invite_chat_param(item->id, this))); - break; - - case 20: - //chat_leave(id); - break; - } - break; - } - */ - case GC_USER_NICKLISTMENU: - { - MCONTACT hContact = NULL; - if (hook->dwData == 10 || hook->dwData == 20) { - facebook_user fbu; - fbu.user_id = _T2A(hook->ptszUID, CP_UTF8); - - // Find this contact in list or add new temporary contact - hContact = AddToContactList(&fbu, false, true); - - if (!hContact) - break; - } + MCONTACT hContact = 0; + if (hook->dwData == 10 || hook->dwData == 20) { + facebook_user fbu; + fbu.user_id = _T2A(hook->ptszUID, CP_UTF8); - switch (hook->dwData) { - case 10: - CallService(MS_USERINFO_SHOWDIALOG, hContact); + // Find this contact in list or add new temporary contact + hContact = AddToContactList(&fbu, false, true); + if (!hContact) break; + } - case 20: - CallService(MS_HISTORY_SHOWCONTACTHISTORY, hContact); - break; + switch (hook->dwData) { + case 10: + CallService(MS_USERINFO_SHOWDIALOG, hContact); + break; - case 110: - //chat_leave(id); - break; - } + case 20: + CallService(MS_HISTORY_SHOWCONTACTHISTORY, hContact); + break; + case 110: + //chat_leave(id); break; } - case GC_USER_LEAVE: - case GC_SESSION_TERMINATE: break; } @@ -228,7 +200,7 @@ char *FacebookProto::GetChatUsers(const char *chat_id) bool FacebookProto::IsChatContact(const char *chat_id, const char *id) { ptrA users(GetChatUsers(chat_id)); - return (users != NULL && strstr(users, id) != nullptr); + return (users != nullptr && strstr(users, id) != nullptr); } void FacebookProto::AddChat(const char *id, const wchar_t *tname) @@ -281,9 +253,9 @@ INT_PTR FacebookProto::OnJoinChat(WPARAM hContact, LPARAM) } // RM TODO: better use check if chatroom exists/is in db/is online... no? - // like: if (ChatIDToHContact(thread_id) == NULL) { + // like: if (ChatIDToHContact(thread_id) == nullptr) { ptrA users(GetChatUsers(thread_id.c_str())); - if (users == NULL) { + if (users == nullptr) { // Add chatroom AddChat(fbc->thread_id.c_str(), fbc->chat_name.c_str()); @@ -379,7 +351,7 @@ void FacebookProto::PrepareNotificationsChatRoom() // Prepare notifications chatroom if not exists MCONTACT hNotificationsChatRoom = ChatIDToHContact(FACEBOOK_NOTIFICATIONS_CHATROOM); - if (hNotificationsChatRoom == NULL || getDword(hNotificationsChatRoom, "Status", ID_STATUS_OFFLINE) != ID_STATUS_ONLINE) { + if (hNotificationsChatRoom == 0 || getDword(hNotificationsChatRoom, "Status", ID_STATUS_OFFLINE) != ID_STATUS_ONLINE) { wchar_t nameT[200]; mir_snwprintf(nameT, L"%s: %s", m_tszUserName, TranslateT("Notifications")); diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h index 0d58d04114..0d0120e512 100644 --- a/protocols/FacebookRM/src/client.h +++ b/protocols/FacebookRM/src/client.h @@ -38,13 +38,13 @@ public: {
msgid_ = error_count_ = last_feeds_update_ = last_notification_time_ = random_ = chat_msgs_recv_ = chat_req_ = 0;
- send_message_lock_ = notifications_lock_ = cookies_lock_ = loading_history_lock_ = NULL;
- hChannelCon = NULL;
- hMessagesCon = NULL;
- hFcbCon = NULL;
- fcb_conn_lock_ = NULL;
- handle_ = NULL;
- parent = NULL;
+ send_message_lock_ = notifications_lock_ = cookies_lock_ = loading_history_lock_ = nullptr;
+ hChannelCon = nullptr;
+ hMessagesCon = nullptr;
+ hFcbCon = nullptr;
+ fcb_conn_lock_ = nullptr;
+ handle_ = nullptr;
+ parent = nullptr;
mbasicWorks = true;
loading_history = false;
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index acae64dcb1..562f46b3a8 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -24,12 +24,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. void facebook_client::client_notify(wchar_t* message) { - parent->NotifyEvent(parent->m_tszUserName, message, NULL, EVENT_CLIENT); + parent->NotifyEvent(parent->m_tszUserName, message, 0, EVENT_CLIENT); } void facebook_client::info_notify(wchar_t* message) { - parent->NotifyEvent(parent->m_tszUserName, message, NULL, EVENT_OTHER); + parent->NotifyEvent(parent->m_tszUserName, message, 0, EVENT_OTHER); } http::response facebook_client::sendRequest(HttpRequest *request) @@ -412,7 +412,7 @@ bool facebook_client::login(const char *username, const char *password) if (cookies.empty()) { // Set device ID ptrA device(parent->getStringA(FACEBOOK_KEY_DEVICE_ID)); - if (device != NULL) + if (device != nullptr) cookies["datr"] = device; // Get initial cookies @@ -724,7 +724,7 @@ bool facebook_client::home() this->self_.real_name = utils::text::remove_html(this->self_.real_name); parent->debugLogA(" Got self real name (nickname): %s (%s)", this->self_.real_name.c_str(), this->self_.nick.c_str()); - parent->SaveName(NULL, &this->self_); + parent->SaveName(0, &this->self_); // Get avatar (from touch version) if (!touchData.empty()) @@ -766,7 +766,7 @@ bool facebook_client::home() } parent->debugLogA(" Got self avatar: %s", this->self_.image_url.c_str()); - parent->CheckAvatarChange(NULL, this->self_.image_url); + parent->CheckAvatarChange(0, this->self_.image_url); // Get logout hash this->logout_hash_ = utils::text::source_get_value2(&resp.data, "/logout.php?h=", "&\""); @@ -978,7 +978,7 @@ int facebook_client::send_message(int seqid, MCONTACT hContact, const std::strin ptrA threadId(parent->getStringA(hContact, FACEBOOK_KEY_TID)); // Check if we have userId/threadId to be able to send message - if ((isChatRoom && (threadId == NULL || !mir_strcmp(threadId, "null"))) || (!isChatRoom && (userId == NULL || !mir_strcmp(userId, "null")))) { + if ((isChatRoom && (threadId == nullptr || !mir_strcmp(threadId, "null"))) || (!isChatRoom && (userId == nullptr || !mir_strcmp(userId, "null")))) { // This shouldn't happen unless user manually deletes some data via Database Editor++ *error_text = Translate("Contact doesn't have required data in database."); @@ -1126,7 +1126,7 @@ bool facebook_client::post_status(status_data *status) status->users.clear(); if (resp.isValid()) { - parent->NotifyEvent(parent->m_tszUserName, TranslateT("Status update was successful."), NULL, EVENT_OTHER); + parent->NotifyEvent(parent->m_tszUserName, TranslateT("Status update was successful."), 0, EVENT_OTHER); return handle_success("post_status"); } @@ -1180,6 +1180,6 @@ bool facebook_client::sms_code(const char *fb_dtsg) return false; } - parent->NotifyEvent(parent->m_tszUserName, TranslateT("Verification SMS code was sent to your mobile phone."), NULL, EVENT_OTHER); + parent->NotifyEvent(parent->m_tszUserName, TranslateT("Verification SMS code was sent to your mobile phone."), 0, EVENT_OTHER); return true; } diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp index c99a4135c4..801e091a90 100644 --- a/protocols/FacebookRM/src/connection.cpp +++ b/protocols/FacebookRM/src/connection.cpp @@ -54,7 +54,7 @@ void FacebookProto::ChangeStatus(void*) facy.logout(); - OnLeaveChat(NULL, NULL); + OnLeaveChat(0, 0); setAllContactStatuses(ID_STATUS_OFFLINE); ToggleStatusMenuItems(false); delSetting(FACEBOOK_KEY_LOGON_TS); diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp index 3d6c313f70..b66628b733 100644 --- a/protocols/FacebookRM/src/contacts.cpp +++ b/protocols/FacebookRM/src/contacts.cpp @@ -234,7 +234,7 @@ void FacebookProto::LoadParticipantsNames(facebook_chatroom *fbc) } else { MCONTACT hContact = ContactIDToHContact(id); - if (hContact != NULL) { + if (hContact != 0) { DBVARIANT dbv; if (!getStringUtf(hContact, FACEBOOK_KEY_NICK, &dbv)) { user.nick = dbv.pszVal; @@ -293,7 +293,7 @@ void FacebookProto::JoinChatrooms() if (getBool(hContact, FACEBOOK_KEY_CHAT_IS_ARCHIVED, false) || !getBool(hContact, FACEBOOK_KEY_CHAT_IS_SUBSCRIBED, true)) continue; - OnJoinChat(hContact, NULL); + OnJoinChat(hContact, 0); } } @@ -336,7 +336,7 @@ MCONTACT FacebookProto::AddToContactList(facebook_user* fbu, bool force_add, boo { // Ignore self user completely if (fbu->user_id == facy.self_.user_id) - return NULL; + return 0; // First, check if this contact exists (and if does, just return it) if (!force_add) { @@ -351,7 +351,7 @@ MCONTACT FacebookProto::AddToContactList(facebook_user* fbu, bool force_add, boo if (hContact && Proto_AddToContact(hContact, m_szModuleName) != 0) { db_delete_contact(hContact); - hContact = NULL; + hContact = 0; } // If we have some contact, we'll save its data @@ -413,19 +413,19 @@ void FacebookProto::DeleteContactFromServer(void *data) if (resp.data.find("\"payload\":null", 0) != std::string::npos) { // FIXME: Remember that we deleted this contact, so we won't accidentally add him at status change /* facebook_user* fbu = facy.buddies.find(id); - if (fbu != NULL) + if (fbu != nullptr) fbu->deleted = true; */ MCONTACT hContact = ContactIDToHContact(id); // If contact wasn't deleted from database - if (hContact != NULL) { + if (hContact != 0) { setWord(hContact, "Status", ID_STATUS_OFFLINE); setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE); setDword(hContact, FACEBOOK_KEY_DELETED, ::time(nullptr)); } - NotifyEvent(m_tszUserName, TranslateT("Contact was removed from your server list."), NULL, EVENT_FRIENDSHIP); + NotifyEvent(m_tszUserName, TranslateT("Contact was removed from your server list."), 0, EVENT_FRIENDSHIP); } else { facy.client_notify(TranslateT("Error occurred when removing contact from server.")); @@ -456,10 +456,10 @@ void FacebookProto::AddContactToServer(void *data) MCONTACT hContact = ContactIDToHContact(id); // If contact wasn't deleted from database - if (hContact != NULL) + if (hContact != 0) setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_REQUEST); - NotifyEvent(m_tszUserName, TranslateT("Request for friendship was sent."), NULL, EVENT_FRIENDSHIP); + NotifyEvent(m_tszUserName, TranslateT("Request for friendship was sent."), 0, EVENT_FRIENDSHIP); } else facy.client_notify(TranslateT("Error occurred when requesting friendship.")); @@ -490,7 +490,7 @@ void FacebookProto::ApproveContactToServer(void *data) if (resp.data.find("\"success\":true") != std::string::npos) { setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_FRIEND); - NotifyEvent(m_tszUserName, TranslateT("Request for friendship was accepted."), NULL, EVENT_FRIENDSHIP); + NotifyEvent(m_tszUserName, TranslateT("Request for friendship was accepted."), 0, EVENT_FRIENDSHIP); } else facy.client_notify(TranslateT("Error occurred when accepting friendship request.")); @@ -521,7 +521,7 @@ void FacebookProto::CancelFriendsRequest(void *data) if (resp.data.find("\"payload\":null", 0) != std::string::npos) { setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE); - NotifyEvent(m_tszUserName, TranslateT("Request for friendship was canceled."), NULL, EVENT_FRIENDSHIP); + NotifyEvent(m_tszUserName, TranslateT("Request for friendship was canceled."), 0, EVENT_FRIENDSHIP); } else facy.client_notify(TranslateT("Error occurred when canceling friendship request.")); @@ -552,7 +552,7 @@ void FacebookProto::IgnoreFriendshipRequest(void *data) if (resp.data.find("\"success\":true") != std::string::npos) { setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE); - NotifyEvent(m_tszUserName, TranslateT("Request for friendship was ignored."), NULL, EVENT_FRIENDSHIP); + NotifyEvent(m_tszUserName, TranslateT("Request for friendship was ignored."), 0, EVENT_FRIENDSHIP); // Delete this contact, if he's temporary if (db_get_b(hContact, "CList", "NotOnList", 0)) @@ -595,7 +595,7 @@ void FacebookProto::SendPokeWorker(void *p) utils::text::remove_html(message)); ptrW tmessage(mir_utf8decodeW(message.c_str())); - NotifyEvent(m_tszUserName, tmessage, NULL, EVENT_OTHER); + NotifyEvent(m_tszUserName, tmessage, 0, EVENT_OTHER); } facy.handle_success("SendPokeWorker"); @@ -612,7 +612,7 @@ void FacebookProto::RefreshUserInfo(void *data) delete (MCONTACT*)data; ptrA user_id(getStringA(hContact, FACEBOOK_KEY_ID)); - if (user_id == NULL || isOffline()) { + if (user_id == nullptr || isOffline()) { ProtoBroadcastAck(hContact, ACKTYPE_GETINFO, ACKRESULT_FAILED, (HANDLE)nullptr, 0); return; } diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp index 3dd35f68e8..e3988b3907 100644 --- a/protocols/FacebookRM/src/dialogs.cpp +++ b/protocols/FacebookRM/src/dialogs.cpp @@ -49,12 +49,12 @@ INT_PTR CALLBACK FBAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp proto = reinterpret_cast<FacebookProto*>(lparam); SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam); - ptrA login(db_get_sa(NULL, proto->ModuleName(), FACEBOOK_KEY_LOGIN)); - if (login != NULL) + ptrA login(db_get_sa(0, proto->ModuleName(), FACEBOOK_KEY_LOGIN)); + if (login != nullptr) SetDlgItemTextA(hwnd, IDC_UN, login); - ptrA password(db_get_sa(NULL, proto->ModuleName(), FACEBOOK_KEY_PASS)); - if (password != NULL) + ptrA password(db_get_sa(0, proto->ModuleName(), FACEBOOK_KEY_PASS)); + if (password != nullptr) SetDlgItemTextA(hwnd, IDC_PW, password); if (!proto->isOffline()) { @@ -83,10 +83,10 @@ INT_PTR CALLBACK FBAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp char str[128]; GetDlgItemTextA(hwnd, IDC_UN, str, _countof(str)); - db_set_s(NULL, proto->ModuleName(), FACEBOOK_KEY_LOGIN, str); + db_set_s(0, proto->ModuleName(), FACEBOOK_KEY_LOGIN, str); GetDlgItemTextA(hwnd, IDC_PW, str, _countof(str)); - db_set_s(NULL, proto->ModuleName(), FACEBOOK_KEY_PASS, str); + db_set_s(0, proto->ModuleName(), FACEBOOK_KEY_PASS, str); return TRUE; } break; @@ -113,7 +113,7 @@ void RefreshPrivacy(HWND hwnd, post_status_data *data) void ClistPrepare(FacebookProto *proto, MCONTACT hItem, HWND hwndList) { - if (hItem == NULL) + if (hItem == 0) hItem = (MCONTACT)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0); while (hItem) { @@ -125,7 +125,7 @@ void ClistPrepare(FacebookProto *proto, MCONTACT hItem, HWND hwndList) ClistPrepare(proto, hItemT, hwndList); } else if (IsHContactContact(hItem)) { - if (!proto->IsMyContact(hItem) || ptrA(proto->getStringA(hItem, FACEBOOK_KEY_ID)) == NULL) + if (!proto->IsMyContact(hItem) || ptrA(proto->getStringA(hItem, FACEBOOK_KEY_ID)) == nullptr) SendMessage(hwndList, CLM_DELETEITEM, (WPARAM)hItem, 0); } @@ -135,7 +135,7 @@ void ClistPrepare(FacebookProto *proto, MCONTACT hItem, HWND hwndList) void GetSelectedContacts(FacebookProto *proto, MCONTACT hItem, HWND hwndList, std::vector<facebook_user*> *contacts) { - if (hItem == NULL) + if (hItem == 0) hItem = (MCONTACT)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0); while (hItem) { @@ -195,7 +195,7 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara SendDlgItemMessage(hwnd, IDC_URL, EM_LIMITTEXT, 1024, 0); ptrW place(data->proto->getWStringA(FACEBOOK_KEY_PLACE)); - SetDlgItemText(hwnd, IDC_PLACE, place != NULL ? place : L"Miranda NG"); + SetDlgItemText(hwnd, IDC_PLACE, place != nullptr ? place : L"Miranda NG"); bShowContacts = data->proto->getByte("PostStatusExpand", 0) > 0; ResizeHorizontal(hwnd, bShowContacts); @@ -210,7 +210,7 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara RefreshPrivacy(hwnd, data); ptrA firstname(data->proto->getStringA(FACEBOOK_KEY_FIRST_NAME)); - if (firstname != NULL) { + if (firstname != nullptr) { char title[100]; mir_snprintf(title, Translate("What's on your mind, %s?"), firstname); SetWindowTextA(hwnd, title); @@ -227,7 +227,7 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara switch (nmc->hdr.code) { case CLN_LISTREBUILT: data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd, GWLP_USERDATA)); - ClistPrepare(data->proto, NULL, nmc->hdr.hwndFrom); + ClistPrepare(data->proto, 0, nmc->hdr.hwndFrom); break; } } @@ -295,7 +295,7 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara status->url = _T2A(urlT); HWND hwndList = GetDlgItem(hwnd, IDC_CCLIST); - GetSelectedContacts(data->proto, NULL, hwndList, &status->users); + GetSelectedContacts(data->proto, 0, hwndList, &status->users); T2Utf narrow(mindMessageT); status->text = narrow; @@ -341,12 +341,12 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp proto = reinterpret_cast<FacebookProto*>(lparam); SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam); - ptrA login(db_get_sa(NULL, proto->ModuleName(), FACEBOOK_KEY_LOGIN)); - if (login != NULL) + ptrA login(db_get_sa(0, proto->ModuleName(), FACEBOOK_KEY_LOGIN)); + if (login != nullptr) SetDlgItemTextA(hwnd, IDC_UN, login); - ptrA password(db_get_sa(NULL, proto->ModuleName(), FACEBOOK_KEY_PASS)); - if (password != NULL) + ptrA password(db_get_sa(0, proto->ModuleName(), FACEBOOK_KEY_PASS)); + if (password != nullptr) SetDlgItemTextA(hwnd, IDC_PW, password); if (!proto->isOffline()) { @@ -356,7 +356,7 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp SendDlgItemMessage(hwnd, IDC_GROUP, EM_LIMITTEXT, FACEBOOK_GROUP_NAME_LIMIT, 0); - if (proto->m_tszDefaultGroup != NULL) + if (proto->m_tszDefaultGroup != nullptr) SetDlgItemText(hwnd, IDC_GROUP, proto->m_tszDefaultGroup); LoadDBCheckState(proto, hwnd, IDC_SET_IGNORE_STATUS, FACEBOOK_KEY_DISABLE_STATUS_NOTIFY, DEFAULT_DISABLE_STATUS_NOTIFY); @@ -612,7 +612,7 @@ void CFacebookGuardDialog::OnInitDialog() SendMessage(m_text.GetHwnd(), EM_LIMITTEXT, 6, 0); - Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "GuardWindow"); + Utils_RestoreWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "GuardWindow"); } void CFacebookGuardDialog::OnOk(CCtrlButton*) @@ -629,7 +629,7 @@ void CFacebookGuardDialog::OnSms(CCtrlButton *btn) void CFacebookGuardDialog::OnClose() { - Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "GuardWindow"); + Utils_SaveWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "GuardWindow"); } const char* CFacebookGuardDialog::GetCode() diff --git a/protocols/FacebookRM/src/entities.h b/protocols/FacebookRM/src/entities.h index e887e63ded..3a88dc8acc 100644 --- a/protocols/FacebookRM/src/entities.h +++ b/protocols/FacebookRM/src/entities.h @@ -47,12 +47,12 @@ struct facebook_user facebook_user() { - this->handle = NULL; - this->status_id = ID_STATUS_OFFLINE; - this->gender = this->last_active = 0; - this->deleted = this->idle = this->updated = false; - this->client = CLIENT_WEB; - this->type = CONTACT_NONE; + handle = 0; + status_id = ID_STATUS_OFFLINE; + gender = last_active = 0; + deleted = idle = updated = false; + client = CLIENT_WEB; + type = CONTACT_NONE; } wchar_t *getMirVer() @@ -143,26 +143,13 @@ struct facebook_notification { this->time = 0; this->seen = false; - this->hWndPopup = NULL; - this->icon = NULL; + this->hWndPopup = nullptr; + this->icon = nullptr; } void setIcon(const std::string &iconUrl) { - if (iconUrl == "https://www.facebook.com/rsrc.php/v3/yj/r/6WffvhOaXGY.png") - icon = "like"; - else if (iconUrl == "https://www.facebook.com/rsrc.php/v3/y1/r/RvGKklgAefT.png") - icon = "love"; - else if (iconUrl == "https://www.facebook.com/rsrc.php/v3/yV/r/McJA2ZjdJmf.png") - icon = "haha"; - else if (iconUrl == "https://www.facebook.com/rsrc.php/v3/yL/r/IfsimazVjj4.png") - icon = "wow"; - else if (iconUrl == "https://www.facebook.com/rsrc.php/v3/yH/r/jOeSrGlcPLG.png") - icon = "sad"; - else if (iconUrl == "https://www.facebook.com/rsrc.php/v3/y9/r/6K8v8Ju8kL2.png") - icon = "angry"; - else - icon = NULL; + icon = nullptr; } }; @@ -224,7 +211,7 @@ struct status_data struct wall_data { wall_data() { - this->title = NULL; + this->title = nullptr; this->isPage = false; } wall_data(std::string user_id, wchar_t *title, bool isPage = false) : user_id(user_id), title(title), isPage(isPage) {} diff --git a/protocols/FacebookRM/src/http_request.h b/protocols/FacebookRM/src/http_request.h index efabe21e3d..7c03adec46 100644 --- a/protocols/FacebookRM/src/http_request.h +++ b/protocols/FacebookRM/src/http_request.h @@ -28,7 +28,7 @@ class HttpRequest : public NETLIBHTTPREQUEST, public MZeroedObject protected: enum HttpRequestUrlFormat { FORMAT }; - class HttpRequestUrl + class HttpRequestUrl { friend HttpRequest; @@ -199,7 +199,7 @@ public: cbSize = sizeof(NETLIBHTTPREQUEST); flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_DUMPASTEXT; requestType = type; - pData = NULL; + pData = nullptr; timeout = 20 * 1000; NotifyErrors = true; @@ -213,7 +213,7 @@ public: flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_DUMPASTEXT; requestType = type; va_end(formatArgs); - pData = NULL; + pData = nullptr; timeout = 20 * 1000; NotifyErrors = true; diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 24c7022abe..586189784f 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -221,7 +221,7 @@ int FacebookProto::ParseNotifications(std::string *data, std::map< std::string, if (!text_ || !state_ || state_.as_string() == "SEEN_AND_READ" || !time_) continue; - facebook_notification* notification = new facebook_notification(); + facebook_notification *notification = new facebook_notification(); notification->id = id_.as_string(); @@ -681,7 +681,7 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag // Only new notifications facy.last_notification_time_ = timestamp; - facebook_notification* notification = new facebook_notification(); + facebook_notification *notification = new facebook_notification(); notification->text = utils::text::slashu_to_utf8(text.as_string()); notification->link = url.as_string(); notification->id = alert_id.as_string(); @@ -709,46 +709,47 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag if (!data) continue; - const JSONNode &appId_ = data["app_id"]; - const JSONNode &type_ = data["type"]; - - if (appId_.as_string() == "2356318349" || type_.as_string() == "friend_confirmed") { - // Friendship notifications - - const JSONNode &body_ = data["body"]; - const JSONNode &html_ = body_["__html"]; + const JSONNode &html_ = data["body"]["__html"]; + const JSONNode &href_ = data["href"]; + const JSONNode &unread_ = data["unread"]; + if (!html_ || !href_ || !unread_ || unread_.as_int() == 0) + continue; - const JSONNode &href_ = data["href"]; - const JSONNode &unread_ = data["unread"]; - const JSONNode &alertId_ = data["alert_id"]; - - if (!html_ || !href_ || !unread_ || unread_.as_int() == 0) - continue; + std::string alert_id = data["alert_id"].as_string(); + const JSONNode &type_ = data["type"]; + if (type_.as_string() == "friend_confirmed") { std::string text = utils::text::remove_html(utils::text::slashu_to_utf8(html_.as_string())); std::string url = href_.as_string(); - std::string alert_id = alertId_.as_string(); // Notify it, if user wants to be notified - if (getByte(FACEBOOK_KEY_EVENT_FRIENDSHIP_ENABLE, DEFAULT_EVENT_FRIENDSHIP_ENABLE)) { - NotifyEvent(m_tszUserName, ptrW(mir_utf8decodeW(text.c_str())), NULL, EVENT_FRIENDSHIP, &url, alert_id.empty() ? nullptr : &alert_id); - } + if (getByte(FACEBOOK_KEY_EVENT_FRIENDSHIP_ENABLE, DEFAULT_EVENT_FRIENDSHIP_ENABLE)) + NotifyEvent(m_tszUserName, ptrW(mir_utf8decodeW(text.c_str())), 0, EVENT_FRIENDSHIP, &url, alert_id.empty() ? nullptr : &alert_id); + } + else { // new comment, like or reaction + PrepareNotificationsChatRoom(); + + // Fix notification ID + std::string::size_type pos = alert_id.find(":"); + if (pos != std::string::npos) + alert_id = alert_id.substr(pos + 1); + + facebook_notification *notification = new facebook_notification(); + notification->text = utils::text::remove_html(utils::text::html_entities_decode(html_.as_string())); + notification->link = href_.as_string(); + notification->id = alert_id; + notification->time = utils::time::from_string(data["time"].as_string()); + + // Write notification to chatroom + UpdateNotificationsChatRoom(notification); + + notifications->insert(std::make_pair(notification->id, notification)); } } else if (t == "jewel_requests_add") { // New friendship request, load them all with real names (because there is only user_id in "from" field) ForkThread(&FacebookProto::ProcessFriendRequests, nullptr); } - /*else if (t == "jewel_requests_handled") { // revised 5.3.2017 - // When some request is approved (or perhaps even ignored/removed) - const JSONNode &item_id_ = (*it)["item_id"]; // "<other_userid>_1_req" - const JSONNode &realtime_viewer_fbid_ = (*it)["realtime_viewer_fbid"]; // our user fbid - } - else if (t == "type=jewel_requests_remove_old") { // revised 5.3.2017 - // Probably same as above? Happened in same situation. Could happen few times in a row. - const JSONNode &from_ = (*it)["from"]; // other_userid - const JSONNode &realtime_viewer_fbid_ = (*it)["realtime_viewer_fbid"]; // our user fbid - }*/ else if (t == "typ") { // revised 5.3.2017 // chat typing notification const JSONNode &from_ = (*it)["from"]; // user fbid diff --git a/protocols/FacebookRM/src/list.hpp b/protocols/FacebookRM/src/list.hpp index 141d0b9abd..7e3038fd20 100644 --- a/protocols/FacebookRM/src/list.hpp +++ b/protocols/FacebookRM/src/list.hpp @@ -34,9 +34,9 @@ namespace List Item()
{
- this->data = NULL;
- this->prev = NULL;
- this->next = NULL;
+ this->data = nullptr;
+ this->prev = nullptr;
+ this->next = nullptr;
}
~Item()
@@ -55,7 +55,7 @@ namespace List public:
List()
{
- this->first = this->last = NULL;
+ this->first = this->last = nullptr;
this->count = 0;
}
@@ -81,7 +81,7 @@ namespace List bool empty()
{
- return (this->first == NULL);
+ return (this->first == nullptr);
}
void insert(Item< T >* item)
@@ -108,23 +108,23 @@ namespace List void erase(std::string key)
{
Item< T >* help = this->first;
- while (help != NULL) {
+ while (help != nullptr) {
if (help->key.compare(key) != 0)
help = help->next;
else {
if (help == this->first) {
this->first = help->next;
- if (this->first != NULL)
- this->first->prev = NULL;
+ if (this->first != nullptr)
+ this->first->prev = nullptr;
else
- this->last = NULL;
+ this->last = nullptr;
}
else if (help == this->last) {
this->last = help->prev;
- if (this->last != NULL)
- this->last->next = NULL;
+ if (this->last != nullptr)
+ this->last->next = nullptr;
else
- this->first = NULL;
+ this->first = nullptr;
}
else {
help->prev->next = help->next;
@@ -139,26 +139,26 @@ namespace List void erase(Item< T >* item)
{
- if (item != NULL)
+ if (item != nullptr)
erase(item->key);
}
T* find(std::string key)
{
Item< T >* help = this->begin();
- while (help != NULL) {
+ while (help != nullptr) {
if (help->key.compare(key) != 0)
help = help->next;
else
return help->data;
}
- return NULL;
+ return nullptr;
}
T* at(const unsigned int item)
{
if (item >= this->count)
- return NULL;
+ return nullptr;
Item< T >* help = this->begin();
for (unsigned int i = 0; i < item; i++)
help = help->next;
@@ -173,12 +173,12 @@ namespace List void clear()
{
Item< T >* help;
- while (this->first != NULL) {
+ while (this->first != nullptr) {
help = this->first;
this->first = this->first->next;
delete help;
}
- this->last = NULL;
+ this->last = nullptr;
this->count = 0;
}
};
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp index 437724f030..4bf30fc915 100644 --- a/protocols/FacebookRM/src/messages.cpp +++ b/protocols/FacebookRM/src/messages.cpp @@ -40,7 +40,7 @@ void FacebookProto::SendMsgWorker(void *p) if (!isOnline()) ProtoBroadcastAck(data->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)data->msgid, (LPARAM)Translate("You cannot send messages when you are offline.")); - else if (id == NULL) + else if (id == nullptr) ProtoBroadcastAck(data->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)data->msgid, 0); else { int tries = getByte(FACEBOOK_KEY_SEND_MESSAGE_TRIES, 1); @@ -78,7 +78,7 @@ void FacebookProto::SendChatMsgWorker(void *p) if (hContact) { ptrA tid_(getStringA(hContact, FACEBOOK_KEY_TID)); std::string tid; - if (tid_ != NULL && mir_strcmp(tid_, "null")) + if (tid_ != nullptr && mir_strcmp(tid_, "null")) tid = tid_; else { // request info about chat thread @@ -143,7 +143,7 @@ void FacebookProto::SendTypingWorker(void *p) const char *value = (isChatRoom(typing->hContact) ? FACEBOOK_KEY_TID : FACEBOOK_KEY_ID); ptrA id(getStringA(typing->hContact, value)); - if (id != NULL) { + if (id != nullptr) { bool isChat = isChatRoom(typing->hContact); HttpRequest *request = new SendTypingRequest(&facy, id, isChat, typing->status == PROTOTYPE_SELFTYPING_ON); http::response resp = facy.sendRequest(request); @@ -177,7 +177,7 @@ void FacebookProto::ReadMessageWorker(void *p) // mark message read (also send seen info) const char *value = (isChatRoom(hContact) ? FACEBOOK_KEY_TID : FACEBOOK_KEY_ID); ptrA id(getStringA(hContact, value)); - if (id == NULL) + if (id == nullptr) continue; ids.insert(mir_strdup(id)); diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index f68d5b06e9..54215c811d 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -81,7 +81,7 @@ void FacebookProto::ProcessFriendList(void*) setWord(hContact, "Status", ID_STATUS_INVISIBLE); ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); - if (id != NULL) { + if (id != nullptr) { std::map< std::string, facebook_user* >::iterator iter; if ((iter = friends.find(std::string(id))) != friends.end()) { @@ -281,7 +281,7 @@ void FacebookProto::LoadLastMessages(void *pParam) return; ptrA item_id(getStringA(hContact, isChat ? FACEBOOK_KEY_TID : FACEBOOK_KEY_ID)); - if (item_id == NULL) { + if (item_id == nullptr) { debugLogA("!!! LoadLastMessages(): Contact has no TID/ID"); return; } @@ -316,7 +316,7 @@ void FacebookProto::LoadLastMessages(void *pParam) facy.ignore_read.erase(hContact); // And force mark read - OnDbEventRead(hContact, NULL); + OnDbEventRead(hContact, 0); } void FacebookProto::LoadHistory(void *pParam) @@ -340,7 +340,7 @@ void FacebookProto::LoadHistory(void *pParam) return; ptrA item_id(getStringA(hContact, isChat ? FACEBOOK_KEY_TID : FACEBOOK_KEY_ID)); - if (item_id == NULL) { + if (item_id == nullptr) { debugLogA("!!! LoadHistory(): Contact has no TID/ID"); return; } @@ -667,7 +667,7 @@ void FacebookProto::ProcessMemories(void *p) ptrW tszTitle(mir_utf8decodeW(news[i]->title.c_str())); ptrW tszText(mir_utf8decodeW(news[i]->text.c_str())); - NotifyEvent(TranslateT("On this day"), tszText, NULL, EVENT_ON_THIS_DAY, &news[i]->link); + NotifyEvent(TranslateT("On this day"), tszText, 0, EVENT_ON_THIS_DAY, &news[i]->link); delete news[i]; } news.clear(); @@ -693,11 +693,11 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message> &messages, boo facebook_message &msg = messages[i]; MCONTACT hContact = msg.isChat ? ChatIDToHContact(msg.thread_id) : ContactIDToHContact(msg.user_id); - if (hContact == NULL) + if (hContact == 0) continue; ptrA lastId(getStringA(hContact, FACEBOOK_KEY_MESSAGE_ID)); - if (lastId == NULL) + if (lastId == nullptr) continue; if (!msg.message_id.compare(lastId)) { @@ -750,11 +750,11 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message> &messages, boo facy.chat_rooms.insert(std::make_pair(thread_id, fbc)); } - MCONTACT hChatContact = NULL; + MCONTACT hChatContact = 0; // RM TODO: better use check if chatroom exists/is in db/is online... no? - // like: if (ChatIDToHContact(thread_id) == NULL) { + // like: if (ChatIDToHContact(thread_id) == nullptr) { ptrA users(GetChatUsers(fbc->thread_id.c_str())); - if (users == NULL) { + if (users == nullptr) { AddChat(fbc->thread_id.c_str(), fbc->chat_name.c_str()); hChatContact = ChatIDToHContact(fbc->thread_id); // Set thread id (TID) for later @@ -851,7 +851,7 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message> &messages, boo fbu.user_id = msg.user_id; MCONTACT hContact = ContactIDToHContact(fbu.user_id); - if (hContact == NULL) { + if (hContact == 0) { // In Naseem's spam mode we ignore outgoing messages sent from other instances if (naseemsSpamMode && !msg.isIncoming) continue; @@ -960,7 +960,7 @@ void FacebookProto::ShowNotifications() if (notification != nullptr && !notification->seen) { debugLogA(" Showing popup for notification ID: %s", notification->id.c_str()); ptrW szText(mir_utf8decodeW(notification->text.c_str())); - MCONTACT hContact = (notification->user_id.empty() ? NULL : ContactIDToHContact(notification->user_id)); + MCONTACT hContact = (notification->user_id.empty() ? 0 : ContactIDToHContact(notification->user_id)); notification->hWndPopup = NotifyEvent(m_tszUserName, szText, hContact, EVENT_NOTIFICATION, ¬ification->link, ¬ification->id, notification->icon); notification->seen = true; } @@ -1073,7 +1073,7 @@ void FacebookProto::ProcessFriendRequests(void *p) bool isNew = false; ptrA oldTime(getStringA(hContact, "RequestTime")); - if (oldTime == NULL || mir_strcmp(oldTime, time.c_str())) { + if (oldTime == nullptr || mir_strcmp(oldTime, time.c_str())) { // This is new request isNew = true; setString(hContact, "RequestTime", time.c_str()); @@ -1291,7 +1291,7 @@ void FacebookProto::SearchAckThread(void *targ) psr.firstName.w = tname; psr.lastName.w = tsurname; psr.email.w = tcommon; - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, targ, (LPARAM)&psr); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_DATA, targ, (LPARAM)&psr); } ssid = utils::text::source_get_value(&resp.data, 3, "id=\"more_objects\"", "ssid=", "&"); @@ -1302,7 +1302,7 @@ void FacebookProto::SearchAckThread(void *targ) else break; } - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, targ, 0); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, targ, 0); facy.handle_success("searchAckThread"); @@ -1365,12 +1365,12 @@ void FacebookProto::SearchIdAckThread(void *targ) psr.id.w = tid; psr.firstName.w = tname; psr.lastName.w = tsurname; - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, targ, (LPARAM)&psr); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_DATA, targ, (LPARAM)&psr); } } } - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, targ, 0); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, targ, 0); facy.handle_success("searchIdAckThread"); diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 1869f67243..6533f754ee 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -45,14 +45,14 @@ FacebookProto::FacebookProto(const char* proto_name, const wchar_t* username) : // Load custom locale, if set ptrA locale(getStringA(FACEBOOK_KEY_LOCALE)); - if (locale != NULL) + if (locale != nullptr) m_locale = locale; // Load custom page prefix, if set ptrW pagePrefix(getWStringA(FACEBOOK_KEY_PAGE_PREFIX)); - m_pagePrefix = (pagePrefix != NULL) ? _T2A(pagePrefix, CP_UTF8) : TEXT_EMOJI_PAGE; + m_pagePrefix = (pagePrefix != nullptr) ? _T2A(pagePrefix, CP_UTF8) : TEXT_EMOJI_PAGE; - if (m_tszDefaultGroup == NULL) + if (m_tszDefaultGroup == nullptr) m_tszDefaultGroup = mir_wstrdup(L"Facebook"); CreateProtoService(PS_CREATEACCMGRUI, &FacebookProto::SvcCreateAccMgrUI); @@ -282,21 +282,21 @@ MCONTACT FacebookProto::AddToList(int flags, PROTOSEARCHRESULT* psr) ptrA name(mir_u2a_cp(psr->firstName.w, CP_UTF8)); ptrA surname(mir_u2a_cp(psr->lastName.w, CP_UTF8)); - if (id == NULL) - return NULL; + if (id == nullptr) + return 0; facebook_user fbu; fbu.user_id = id; - if (name != NULL) + if (name != nullptr) fbu.real_name = name; - if (surname != NULL) { + if (surname != nullptr) { fbu.real_name += " "; fbu.real_name += surname; } if (fbu.user_id.find_first_not_of("0123456789") != std::string::npos) { MessageBox(nullptr, TranslateT("Facebook ID must be numeric value."), m_tszUserName, MB_ICONERROR | MB_OK); - return NULL; + return 0; } bool add_temporarily = (flags & PALF_TEMPORARY); @@ -313,7 +313,7 @@ MCONTACT FacebookProto::AddToList(int flags, PROTOSEARCHRESULT* psr) int FacebookProto::AuthRequest(MCONTACT hContact, const wchar_t *) { - return RequestFriendship(hContact, NULL); + return RequestFriendship(hContact, 0); } int FacebookProto::Authorize(MEVENT hDbEvent) @@ -325,7 +325,7 @@ int FacebookProto::Authorize(MEVENT hDbEvent) if (hContact == INVALID_CONTACT_ID) return 1; - return ApproveFriendship(hContact, NULL); + return ApproveFriendship(hContact, 0); } int FacebookProto::AuthDeny(MEVENT hDbEvent, const wchar_t *) @@ -337,7 +337,7 @@ int FacebookProto::AuthDeny(MEVENT hDbEvent, const wchar_t *) if (hContact == INVALID_CONTACT_ID) return 1; - return DenyFriendship(hContact, NULL); + return DenyFriendship(hContact, 0); } int FacebookProto::GetInfo(MCONTACT hContact, int) @@ -352,7 +352,7 @@ int FacebookProto::GetInfo(MCONTACT hContact, int) INT_PTR FacebookProto::GetMyAwayMsg(WPARAM, LPARAM lParam) { ptrW statusMsg(getWStringA("StatusMsg")); - if (statusMsg == NULL || statusMsg[0] == '\0') + if (statusMsg == nullptr || statusMsg[0] == '\0') return 0; return (lParam & SGMA_UNICODE) ? (INT_PTR)mir_wstrdup(statusMsg) : (INT_PTR)mir_u2a(statusMsg); @@ -643,12 +643,12 @@ INT_PTR FacebookProto::VisitProfile(WPARAM wParam, LPARAM) std::string url = FACEBOOK_URL_PROFILE; ptrA val(getStringA(hContact, "Homepage")); - if (val != NULL) // Homepage link already present, get it + if (val != nullptr) // Homepage link already present, get it url = val; else { // No homepage link, create and save it val = getStringA(hContact, FACEBOOK_KEY_ID); - if (val != NULL) { + if (val != nullptr) { url += val; setString(hContact, "Homepage", url.c_str()); } @@ -686,7 +686,7 @@ INT_PTR FacebookProto::VisitConversation(WPARAM wParam, LPARAM) bool isChat = isChatRoom(hContact); ptrA id(getStringA(hContact, isChat ? FACEBOOK_KEY_TID : FACEBOOK_KEY_ID)); - if (id == NULL) + if (id == nullptr) return 1; std::string url = FACEBOOK_URL_CONVERSATION + std::string(id); @@ -712,13 +712,13 @@ INT_PTR FacebookProto::VisitNotifications(WPARAM, LPARAM) INT_PTR FacebookProto::Poke(WPARAM wParam, LPARAM) { - if (wParam == NULL || isOffline()) + if (wParam == 0 || isOffline()) return 1; MCONTACT hContact = MCONTACT(wParam); ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); - if (id == NULL) + if (id == nullptr) return 1; ForkThread(&FacebookProto::SendPokeWorker, new std::string(id)); @@ -727,7 +727,7 @@ INT_PTR FacebookProto::Poke(WPARAM wParam, LPARAM) INT_PTR FacebookProto::LoadHistory(WPARAM wParam, LPARAM) { - if (wParam == NULL || isOffline()) + if (wParam == 0 || isOffline()) return 1; MCONTACT hContact = MCONTACT(wParam); @@ -744,9 +744,9 @@ INT_PTR FacebookProto::LoadHistory(WPARAM wParam, LPARAM) } ptrW name(getWStringA(hContact, FACEBOOK_KEY_NICK)); - if (name == NULL) + if (name == nullptr) name = getWStringA(hContact, FACEBOOK_KEY_ID); - if (name == NULL) + if (name == nullptr) return 1; CMStringW title; @@ -762,7 +762,7 @@ INT_PTR FacebookProto::LoadHistory(WPARAM wParam, LPARAM) INT_PTR FacebookProto::CancelFriendship(WPARAM wParam, LPARAM lParam) { - if (wParam == NULL || isOffline()) + if (wParam == 0 || isOffline()) return 1; bool deleting = (lParam == 1); @@ -774,10 +774,10 @@ INT_PTR FacebookProto::CancelFriendship(WPARAM wParam, LPARAM lParam) return 0; ptrW tname(getWStringA(hContact, FACEBOOK_KEY_NICK)); - if (tname == NULL) + if (tname == nullptr) tname = getWStringA(hContact, FACEBOOK_KEY_ID); - if (tname == NULL) + if (tname == nullptr) return 1; wchar_t tstr[256]; @@ -785,7 +785,7 @@ INT_PTR FacebookProto::CancelFriendship(WPARAM wParam, LPARAM lParam) if (MessageBox(nullptr, tstr, m_tszUserName, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2) == IDYES) { ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); - if (id == NULL) + if (id == nullptr) return 1; std::string *val = new std::string(id); @@ -793,8 +793,8 @@ INT_PTR FacebookProto::CancelFriendship(WPARAM wParam, LPARAM lParam) // FIXME: Remember that we deleted this contact, so we won't accidentally add him at status change /*if (deleting) { facebook_user *fbu = facy.buddies.find(*val); - if (fbu != NULL) - fbu->handle = NULL; + if (fbu != nullptr) + fbu->handle = nullptr; }*/ ForkThread(&FacebookProto::DeleteContactFromServer, val); @@ -805,13 +805,13 @@ INT_PTR FacebookProto::CancelFriendship(WPARAM wParam, LPARAM lParam) INT_PTR FacebookProto::RequestFriendship(WPARAM wParam, LPARAM) { - if (wParam == NULL || isOffline()) + if (wParam == 0 || isOffline()) return 1; MCONTACT hContact = MCONTACT(wParam); ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); - if (id == NULL) + if (id == nullptr) return 1; ForkThread(&FacebookProto::AddContactToServer, new std::string(id)); @@ -820,7 +820,7 @@ INT_PTR FacebookProto::RequestFriendship(WPARAM wParam, LPARAM) INT_PTR FacebookProto::ApproveFriendship(WPARAM wParam, LPARAM) { - if (wParam == NULL || isOffline()) + if (wParam == 0 || isOffline()) return 1; MCONTACT *hContact = new MCONTACT((MCONTACT)wParam); @@ -830,7 +830,7 @@ INT_PTR FacebookProto::ApproveFriendship(WPARAM wParam, LPARAM) INT_PTR FacebookProto::DenyFriendship(WPARAM wParam, LPARAM) { - if (wParam == NULL || isOffline()) + if (wParam == 0 || isOffline()) return 1; MCONTACT *hContact = new MCONTACT((MCONTACT)wParam); @@ -840,7 +840,7 @@ INT_PTR FacebookProto::DenyFriendship(WPARAM wParam, LPARAM) INT_PTR FacebookProto::OnCancelFriendshipRequest(WPARAM wParam, LPARAM) { - if (wParam == NULL || isOffline()) + if (wParam == 0 || isOffline()) return 1; MCONTACT *hContact = new MCONTACT((MCONTACT)wParam); @@ -917,7 +917,7 @@ void FacebookProto::OpenUrl(std::string url) // Check if there is user defined browser for opening links ptrW browser(getWStringA(FACEBOOK_KEY_OPEN_URL_BROWSER)); - if (browser != NULL) + if (browser != nullptr) // If so, use it to open this link ForkThread(&FacebookProto::OpenUrlThread, new open_url(browser, data)); else diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h index 8a021dde9d..db29bf6617 100644 --- a/protocols/FacebookRM/src/proto.h +++ b/protocols/FacebookRM/src/proto.h @@ -89,11 +89,11 @@ public: // DB utils missing in proto_interface __forceinline INT_PTR getStringUtf(const char *name, DBVARIANT *result) { - return db_get_utf(NULL, m_szModuleName, name, result); } + return db_get_utf(0, m_szModuleName, name, result); } __forceinline INT_PTR getStringUtf(MCONTACT hContact, const char *name, DBVARIANT *result) { return db_get_utf(hContact, m_szModuleName, name, result); } - __forceinline void setStringUtf(const char *name, const char* value) { db_set_utf(NULL, m_szModuleName, name, value); } + __forceinline void setStringUtf(const char *name, const char* value) { db_set_utf(0, m_szModuleName, name, value); } __forceinline void setStringUtf(MCONTACT hContact, const char *name, const char* value) { db_set_utf(hContact, m_szModuleName, name, value); } //PROTO_INTERFACE @@ -104,7 +104,7 @@ public: virtual int __cdecl AuthDeny(MEVENT hDbEvent, const wchar_t* szReason); virtual int __cdecl AuthRequest(MCONTACT hContact, const wchar_t* szMessage); - 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); @@ -277,6 +277,6 @@ public: std::vector<MCONTACT> avatar_queue; // Information providing - HWND NotifyEvent(wchar_t* title, wchar_t* text, MCONTACT contact, EventType type, std::string *url = NULL, std::string *notification_id = NULL, const char *icon = NULL); + HWND NotifyEvent(wchar_t* title, wchar_t* text, MCONTACT contact, EventType type, std::string *url = nullptr, std::string *notification_id = nullptr, const char *icon = nullptr); void ShowNotifications(); }; diff --git a/protocols/FacebookRM/src/requests/feeds.h b/protocols/FacebookRM/src/requests/feeds.h index 0690998d2f..7cc9fa0d3c 100644 --- a/protocols/FacebookRM/src/requests/feeds.h +++ b/protocols/FacebookRM/src/requests/feeds.h @@ -57,7 +57,7 @@ public: << CHAR_PARAM("last_section_key", "regular_story") << INT_PARAM("__be", -1) << CHAR_PARAM("__pc", "PHASED:DEFAULT") - << INT64_PARAM("timestamp", ::time(NULL)) + << INT64_PARAM("timestamp", ::time(nullptr)) << CHAR_PARAM("__dyn", fc->__dyn()) << CHAR_PARAM("__req", fc->__req()) << CHAR_PARAM("__rev", fc->__rev()) |