From d7382326906b9f3bdd66704dd1b41f9299c1daa6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 20 Jul 2013 13:23:20 +0000 Subject: protocol helper for detecting chats: isChatRoom git-svn-id: http://svn.miranda-ng.org/main/trunk@5428 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/MSN/src/msn_chat.cpp | 9 +++------ protocols/MSN/src/msn_menu.cpp | 2 +- protocols/MSN/src/msn_svcs.cpp | 15 +++++---------- 3 files changed, 9 insertions(+), 17 deletions(-) (limited to 'protocols/MSN') diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp index ca49d3d11f..f46ea96ce3 100644 --- a/protocols/MSN/src/msn_chat.cpp +++ b/protocols/MSN/src/msn_chat.cpp @@ -28,12 +28,9 @@ along with this program. If not, see . HANDLE CMsnProto::MSN_GetChatInernalHandle(HANDLE hContact) { HANDLE result = hContact; - int type = getByte(hContact, "ChatRoom", 0); - if (type != 0) - { + if ( isChatRoom(hContact)) { DBVARIANT dbv; - if (getString(hContact, "ChatRoomID", &dbv) == 0) - { + if (getString(hContact, "ChatRoomID", &dbv) == 0) { result = (HANDLE)(-atol(dbv.pszVal)); db_free(&dbv); } @@ -187,7 +184,7 @@ static void ChatInviteSend(HANDLE hItem, HWND hwndList, STRLIST &str, CMsnProto static void ChatValidateContact(HANDLE hItem, HWND hwndList, CMsnProto* ppro) { - if (!ppro->MSN_IsMyContact(hItem) || ppro->getByte(hItem, "ChatRoom", 0) || ppro->MSN_IsMeByContact(hItem)) + if (!ppro->MSN_IsMyContact(hItem) || ppro->isChatRoom(hItem) || ppro->MSN_IsMeByContact(hItem)) SendMessage(hwndList, CLM_DELETEITEM, (WPARAM)hItem, 0); } diff --git a/protocols/MSN/src/msn_menu.cpp b/protocols/MSN/src/msn_menu.cpp index c8d88cf934..001efbb89a 100644 --- a/protocols/MSN/src/msn_menu.cpp +++ b/protocols/MSN/src/msn_menu.cpp @@ -143,7 +143,7 @@ int CMsnProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) bool isMe = MSN_IsMeByContact(hContact, szEmail); if (szEmail[0]) { int listId = Lists_GetMask(szEmail); - bool noChat = !(listId & LIST_FL) || isMe || getByte(hContact, "ChatRoom", 0); + bool noChat = !(listId & LIST_FL) || isMe || isChatRoom(hContact); CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_NAME; diff --git a/protocols/MSN/src/msn_svcs.cpp b/protocols/MSN/src/msn_svcs.cpp index 4b4a0b3170..ee59fdccde 100644 --- a/protocols/MSN/src/msn_svcs.cpp +++ b/protocols/MSN/src/msn_svcs.cpp @@ -386,17 +386,14 @@ int CMsnProto::OnContactDeleted(WPARAM wParam, LPARAM lParam) if (!msnLoggedIn) //should never happen for MSN contacts return 0; - int type = getByte(hContact, "ChatRoom", 0); - if (type != 0) - { + if ( isChatRoom(hContact)) { DBVARIANT dbv; if (!getTString(hContact, "ChatRoomID", &dbv)) { MSN_KillChatSession(dbv.ptszVal); db_free(&dbv); } } - else - { + else { char szEmail[MSN_MAX_EMAIL_LEN]; if (MSN_IsMeByContact(hContact, szEmail)) CallService(MS_CLIST_REMOVEEVENT, (WPARAM)hContact, (LPARAM) 1); @@ -587,7 +584,7 @@ int CMsnProto::OnWindowPopup(WPARAM wParam, LPARAM lParam) { MessageWindowPopupData *mwpd = (MessageWindowPopupData *)lParam; - if (!MSN_IsMyContact(mwpd->hContact) || getByte(mwpd->hContact, "ChatRoom", 0)) + if (!MSN_IsMyContact(mwpd->hContact) || isChatRoom(mwpd->hContact)) return 0; switch (mwpd->uType) @@ -624,11 +621,9 @@ INT_PTR CMsnProto::GetUnreadEmailCount(WPARAM wParam, LPARAM lParam) INT_PTR CMsnProto::OnLeaveChat(WPARAM wParam,LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; - if (getByte(hContact, "ChatRoom", 0) != 0) - { + if (isChatRoom(hContact) != 0) { DBVARIANT dbv; - if (getTString(hContact, "ChatRoomID", &dbv) == 0) - { + if (getTString(hContact, "ChatRoomID", &dbv) == 0) { MSN_KillChatSession(dbv.ptszVal); db_free(&dbv); } -- cgit v1.2.3