diff options
61 files changed, 113 insertions, 105 deletions
diff --git a/include/m_contacts.h b/include/m_contacts.h index 77797143a7..24f9bc4cdb 100644 --- a/include/m_contacts.h +++ b/include/m_contacts.h @@ -83,6 +83,11 @@ EXTERN_C MIR_APP_DLL(wchar_t*) Contact_GetInfo( EXTERN_C MIR_APP_DLL(int) Contact_GetStatus(MCONTACT hContact);
/////////////////////////////////////////////////////////////////////////////////////////
+// if contact is a group chat
+
+MIR_APP_DLL(bool) Contact_IsGroupChat(MCONTACT hContact, const char *szProto = nullptr);
+
+/////////////////////////////////////////////////////////////////////////////////////////
// gets / sets hidden status for a contact
EXTERN_C MIR_APP_DLL(bool) Contact_IsHidden(MCONTACT hContact);
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex 297d572cee..83e529c018 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex d825bdc85c..53b351d577 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/plugins/AutoShutdown/src/watcher.cpp b/plugins/AutoShutdown/src/watcher.cpp index b7135921f4..4408aebc68 100644 --- a/plugins/AutoShutdown/src/watcher.cpp +++ b/plugins/AutoShutdown/src/watcher.cpp @@ -150,7 +150,7 @@ static BOOL CheckAllContactsOffline(void) for (auto &hContact : Contacts()) {
char *pszProto = Proto_GetBaseAccountName(hContact);
if (pszProto != nullptr && Proto_GetStatus(pszProto) != ID_STATUS_OFFLINE) {
- if (db_get_b(hContact, pszProto, "ChatRoom", 0)) continue;
+ if (Contact_IsGroupChat(hContact, pszProto)) continue;
if (db_get_w(hContact, pszProto, "Status", 0) != ID_STATUS_OFFLINE) {
if (fSmartCheck) {
if (Contact_IsHidden(hContact)) continue;
diff --git a/plugins/BuddyExpectator/src/BuddyExpectator.cpp b/plugins/BuddyExpectator/src/BuddyExpectator.cpp index 907f33be39..f33df6a7f3 100644 --- a/plugins/BuddyExpectator/src/BuddyExpectator.cpp +++ b/plugins/BuddyExpectator/src/BuddyExpectator.cpp @@ -435,7 +435,7 @@ int onPrebuildContactMenu(WPARAM hContact, LPARAM) else
Menu_ModifyItem(hContactMenu, LPGENW("Enable Miss You"), iconList[2].hIcolib);
- Menu_ShowItem(hContactMenu, !db_get_b(hContact, proto, "ChatRoom", 0) && (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND));
+ Menu_ShowItem(hContactMenu, !Contact_IsGroupChat(hContact, proto) && (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND));
return 0;
}
@@ -460,8 +460,7 @@ int SettingChanged(WPARAM hContact, LPARAM lParam) return 0;
char *proto = Proto_GetBaseAccountName(hContact);
- if (proto == nullptr || (db_get_b(hContact, proto, "ChatRoom", 0) == 1)
- || !(CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND))
+ if (proto == nullptr || Contact_IsGroupChat(hContact, proto) || !(CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND))
return 0;
int currentStatus = inf->value.wVal;
@@ -539,7 +538,10 @@ void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) {
for (auto &hContact : Contacts()) {
char *proto = Proto_GetBaseAccountName(hContact);
- if (proto && (db_get_b(hContact, proto, "ChatRoom", 0) == 0) && (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) && isContactGoneFor(hContact, options.iAbsencePeriod2) && (g_plugin.getByte(hContact, "StillAbsentNotified", 0) == 0))
+ if (proto && !Contact_IsGroupChat(hContact, proto)
+ && (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)
+ && isContactGoneFor(hContact, options.iAbsencePeriod2)
+ && (g_plugin.getByte(hContact, "StillAbsentNotified", 0) == 0))
{
g_plugin.setByte(hContact, "StillAbsentNotified", 1);
Skin_PlaySound("buddyExpectatorStillAbsent");
diff --git a/plugins/Clist_modern/src/modern_awaymsg.cpp b/plugins/Clist_modern/src/modern_awaymsg.cpp index 5674f61c45..b4f0f5f6a4 100644 --- a/plugins/Clist_modern/src/modern_awaymsg.cpp +++ b/plugins/Clist_modern/src/modern_awaymsg.cpp @@ -144,8 +144,7 @@ void amRequestAwayMsg(MCONTACT hContact) return;
//Do not re-ask for chat rooms
- char *szProto = Proto_GetBaseAccountName(hContact);
- if (szProto != nullptr && !db_get_b(hContact, szProto, "ChatRoom", 0))
+ if (!Contact_IsGroupChat(hContact))
amAddHandleToChain(hContact);
}
diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index d356273e57..417ab0a97e 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -1658,7 +1658,7 @@ int ClcDoProtoAck(ACKDATA *ack) if (ack->type == ACKTYPE_AWAYMSG) {
if (ack->result == ACKRESULT_SUCCESS && ack->lParam) {
if (ack->szModule != nullptr)
- if (db_get_b(ack->hContact, ack->szModule, "ChatRoom", 0) != 0)
+ if (Contact_IsGroupChat(ack->hContact, ack->szModule))
return 0;
g_plugin.setWString(ack->hContact, "StatusMsg", (const wchar_t *)ack->lParam);
@@ -1666,7 +1666,7 @@ int ClcDoProtoAck(ACKDATA *ack) }
else {
if (ack->szModule != nullptr)
- if (db_get_b(ack->hContact, ack->szModule, "ChatRoom", 0) != 0)
+ if (Contact_IsGroupChat(ack->hContact, ack->szModule))
return 0;
if (ack->hContact) {
diff --git a/plugins/Clist_modern/src/modern_clc.h b/plugins/Clist_modern/src/modern_clc.h index bfbb0e50d4..fb06744325 100644 --- a/plugins/Clist_modern/src/modern_clc.h +++ b/plugins/Clist_modern/src/modern_clc.h @@ -200,7 +200,7 @@ struct ClcContact : public ClcContactBase { return (style & CLS_CHECKBOXES && type == CLCIT_CONTACT) || (style & CLS_GROUPCHECKBOXES && type == CLCIT_GROUP) || (type == CLCIT_INFO && flags & CLCIIF_CHECKBOX);
}
__forceinline bool isChat() const
- { return (type == CLCIT_CONTACT) && (db_get_b(hContact, pce->szProto, "ChatRoom", 0) != 0);
+ { return (type == CLCIT_CONTACT) && Contact_IsGroupChat(hContact, pce->szProto);
}
};
diff --git a/plugins/Clist_nicer/src/clcitems.cpp b/plugins/Clist_nicer/src/clcitems.cpp index 28f3d20ea3..161ae95f0d 100644 --- a/plugins/Clist_nicer/src/clcitems.cpp +++ b/plugins/Clist_nicer/src/clcitems.cpp @@ -329,7 +329,7 @@ void GetExtendedInfo(ClcContact *contact, ClcData *dat) return;
p->valid = TRUE;
- p->isChatRoom = db_get_b(contact->hContact, contact->pce->szProto, "ChatRoom", 0);
+ p->isChatRoom = Contact_IsGroupChat(contact->hContact, contact->pce->szProto);
}
void LoadSkinItemToCache(TExtraCache *cEntry)
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index a90a993b80..6fbfd074c0 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -98,7 +98,7 @@ MCONTACT CImportBatch::HContactFromID(const char *pszProtoName, const char *pszS MCONTACT CImportBatch::HContactFromChatID(const char *pszProtoName, const wchar_t *pszChatID)
{
for (MCONTACT hContact = dstDb->FindFirstContact(pszProtoName); hContact; hContact = dstDb->FindNextContact(hContact, pszProtoName)) {
- if (!db_get_b(hContact, pszProtoName, "ChatRoom", 0))
+ if (!Contact_IsGroupChat(hContact, pszProtoName))
continue;
ptrW wszChatId(db_get_wsa(hContact, pszProtoName, "ChatRoomID"));
diff --git a/plugins/Import/src/stdafx.h b/plugins/Import/src/stdafx.h index ed7e5e0e23..dccb07afc5 100644 --- a/plugins/Import/src/stdafx.h +++ b/plugins/Import/src/stdafx.h @@ -36,6 +36,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <newpluginapi.h>
#include <m_langpack.h>
#include <m_clist.h>
+#include <m_contacts.h>
#include <m_db_int.h>
#include <m_database.h>
#include <m_gui.h>
diff --git a/plugins/MirLua/src/Modules/m_message.cpp b/plugins/MirLua/src/Modules/m_message.cpp index 00b6b4c629..f4c6e80ccb 100644 --- a/plugins/MirLua/src/Modules/m_message.cpp +++ b/plugins/MirLua/src/Modules/m_message.cpp @@ -27,7 +27,7 @@ static int message_Send(lua_State *L) INT_PTR res = 1; const char *szProto = Proto_GetBaseAccountName(hContact); - if (db_get_b(hContact, szProto, "ChatRoom", 0) == TRUE) { + if (Contact_IsGroupChat(hContact, szProto)) { ptrW wszChatRoom(db_get_wsa(hContact, szProto, "ChatRoomID")); ptrW wszMessage(mir_utf8decodeW(message)); res = Chat_SendUserMessage(szProto, wszChatRoom, wszMessage); diff --git a/plugins/MirOTR/src/dbfilter.cpp b/plugins/MirOTR/src/dbfilter.cpp index 1ef670ca47..09ca8e241d 100644 --- a/plugins/MirOTR/src/dbfilter.cpp +++ b/plugins/MirOTR/src/dbfilter.cpp @@ -57,7 +57,7 @@ int OnDatabaseEventPreAdd(WPARAM hContact, LPARAM lParam) const char *proto = Proto_GetBaseAccountName(hContact); if (!proto) return 0; - if (db_get_b(hContact, proto, "ChatRoom", 0) == 1) + if (Contact_IsGroupChat(hContact, proto)) return 0; if (mir_strcmp(proto, META_PROTO) == 0) { diff --git a/plugins/MirOTR/src/options.cpp b/plugins/MirOTR/src/options.cpp index f593f738e9..8c607cd386 100644 --- a/plugins/MirOTR/src/options.cpp +++ b/plugins/MirOTR/src/options.cpp @@ -523,7 +523,8 @@ class CContactOptionsDlg : public CDlgBase for (auto &hContact : Contacts()) { const char *proto = Proto_GetBaseAccountName(hContact); - if (proto && db_get_b(hContact, proto, "ChatRoom", 0) == 0 && Proto_IsProtoOnContact(hContact, MODULENAME) // ignore chatrooms + if (proto && !Contact_IsGroupChat(hContact, proto) // ignore chatrooms + && Proto_IsProtoOnContact(hContact, MODULENAME) && mir_strcmp(proto, META_PROTO) != 0) // and MetaContacts { lvI.iItem = 0; diff --git a/plugins/MirOTR/src/svcs_menu.cpp b/plugins/MirOTR/src/svcs_menu.cpp index 50829b2f16..38a1129079 100644 --- a/plugins/MirOTR/src/svcs_menu.cpp +++ b/plugins/MirOTR/src/svcs_menu.cpp @@ -184,7 +184,7 @@ int SVC_PrebuildContactMenu(WPARAM hContact, LPARAM) Menu_ShowItem(hStopItem, false); const char *proto = Proto_GetBaseAccountName(hContact); - if (!proto || db_get_b(hContact, proto, "ChatRoom", 0) == 1) + if (!proto || Contact_IsGroupChat(hContact, proto)) return 0; if (proto && mir_strcmp(proto, META_PROTO) == 0) { diff --git a/plugins/MirOTR/src/svcs_srmm.cpp b/plugins/MirOTR/src/svcs_srmm.cpp index 9614e4b683..06d5cdae56 100644 --- a/plugins/MirOTR/src/svcs_srmm.cpp +++ b/plugins/MirOTR/src/svcs_srmm.cpp @@ -8,10 +8,8 @@ int SVC_IconPressed(WPARAM hContact, LPARAM lParam) StatusIconClickData *sicd = (StatusIconClickData *)lParam; if (mir_strcmp(sicd->szModule, MODULENAME) == 0) { - char *proto = Proto_GetBaseAccountName(hContact); - if (proto && db_get_b(hContact, proto, "ChatRoom", 0)) - return 0; - ShowOTRMenu(hContact, sicd->clickLocation); + if (!Contact_IsGroupChat(hContact)) + ShowOTRMenu(hContact, sicd->clickLocation); } return 0; @@ -20,8 +18,7 @@ int SVC_IconPressed(WPARAM hContact, LPARAM lParam) // set SRMM icon status, if applicable void SetEncryptionStatus(MCONTACT hContact, TrustLevel level) { - char *proto = Proto_GetBaseAccountName(hContact); - bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0)); + bool chat_room = Contact_IsGroupChat(hContact); BBButton button = OTRButton; int flags1 = MBF_HIDDEN, flags2 = MBF_HIDDEN; @@ -85,13 +82,11 @@ int SVC_ButtonsBarLoaded(WPARAM, LPARAM) int SVC_ButtonsBarPressed(WPARAM w, LPARAM l) { CustomButtonClickData *cbcd = (CustomButtonClickData *)l; + if (cbcd->dwButtonId == 0 && !mir_strcmp(cbcd->pszModule, MODULENAME)) { MCONTACT hContact = (MCONTACT)w; - - char *proto = Proto_GetBaseAccountName(hContact); - if(proto && db_get_b(hContact, proto, "ChatRoom", 0)) - return 0; - ShowOTRMenu(hContact, cbcd->pt); + if (!Contact_IsGroupChat(hContact)) + ShowOTRMenu(hContact, cbcd->pt); } return 0; diff --git a/plugins/MirandaG15/src/CAppletManager.cpp b/plugins/MirandaG15/src/CAppletManager.cpp index 0de4d4de9b..0385fd5b56 100644 --- a/plugins/MirandaG15/src/CAppletManager.cpp +++ b/plugins/MirandaG15/src/CAppletManager.cpp @@ -644,7 +644,7 @@ void CAppletManager::FinishMessageJob(SMessageJob *pJob) CIRCConnection *pIRCCon = GetIRCConnection(strProto); // Only add the message to the history if the contact isn't an irc chatroom - if (!(pIRCCon && db_get_b(pJob->hContact, szProto, "ChatRoom", 0) != 0)) { + if (!(pIRCCon && Contact_IsGroupChat(pJob->hContact, szProto))) { // Add the message to the database DBEVENTINFO dbei = {}; dbei.eventType = EVENTTYPE_MESSAGE; @@ -738,7 +738,7 @@ MEVENT CAppletManager::SendMessageToContact(MCONTACT hContact, tstring strMessag CIRCConnection *pIRCCon = CAppletManager::GetInstance()->GetIRCConnection(strProto); - if (pIRCCon && db_get_b(hContact, szProto, "ChatRoom", 0) != 0) { + if (pIRCCon && Contact_IsGroupChat(hContact, szProto)) { ptrW wszNick(db_get_wsa(hContact, szProto, "Nick")); if (wszNick == NULL) return NULL; @@ -1408,7 +1408,7 @@ int CAppletManager::HookStatusChanged(WPARAM wParam, LPARAM lParam) Event.bNotification = true; Event.eType = EVENT_SIGNED_ON; - if (pIRCCon && db_get_b(Event.hContact, szProto, "ChatRoom", 0) != 0) { + if (pIRCCon && Contact_IsGroupChat(Event.hContact, szProto)) { Event.strDescription = TranslateString(L"Joined %s", strName.c_str()); DBVARIANT dbv; @@ -1426,7 +1426,7 @@ int CAppletManager::HookStatusChanged(WPARAM wParam, LPARAM lParam) Event.bNotification = true; Event.eType = EVENT_SIGNED_OFF; - if (pIRCCon && db_get_b(Event.hContact, szProto, "ChatRoom", 0) != 0) { + if (pIRCCon && Contact_IsGroupChat(Event.hContact, szProto)) { Event.strDescription = TranslateString(L"Left %s", strName.c_str()); // delete IRC-Channel history CAppletManager::GetInstance()->DeleteIRCHistory(Event.hContact); diff --git a/plugins/MirandaG15/src/CChatScreen.cpp b/plugins/MirandaG15/src/CChatScreen.cpp index 1408d787ae..26f03f5c60 100644 --- a/plugins/MirandaG15/src/CChatScreen.cpp +++ b/plugins/MirandaG15/src/CChatScreen.cpp @@ -251,7 +251,7 @@ void CChatScreen::LoadHistory() char *szProto = Proto_GetBaseAccountName(m_hContact);
- if (m_bIRCProtocol && db_get_b(m_hContact, szProto, "ChatRoom", 0) != 0) {
+ if (m_bIRCProtocol && Contact_IsGroupChat(m_hContact, szProto)) {
if (!CAppletManager::GetInstance()->IsIRCHookEnabled()) {
time_t now;
tm tm_now;
@@ -615,7 +615,7 @@ void CChatScreen::OnEventReceived(CEvent *pEvent) // contact is set to hidden
if (pEvent->iValue == 1) {
// Close the chat screen if the contact is an irc chatroom
- if (!(m_bIRCProtocol && db_get_b(pEvent->hContact, toNarrowString(m_strProto).c_str(), "ChatRoom", 0) != 0))
+ if (!(m_bIRCProtocol && Contact_IsGroupChat(pEvent->hContact, toNarrowString(m_strProto).c_str())))
break;
}
else
diff --git a/plugins/MirandaG15/src/CEventScreen.cpp b/plugins/MirandaG15/src/CEventScreen.cpp index a298db306c..ffd9989be2 100644 --- a/plugins/MirandaG15/src/CEventScreen.cpp +++ b/plugins/MirandaG15/src/CEventScreen.cpp @@ -186,7 +186,7 @@ void CEventScreen::OnLCDButtonDown(int iButton) char *szProto = Proto_GetBaseAccountName(pEntry->hContact);
CIRCConnection *pIRCCon = CAppletManager::GetInstance()->GetIRCConnection(toTstring(szProto));
- if (pIRCCon && db_get_b(pEntry->hContact, szProto, "ChatRoom", 0) != 0 && Contact_IsHidden(pEntry->hContact))
+ if (pIRCCon && Contact_IsGroupChat(pEntry->hContact, szProto) && Contact_IsHidden(pEntry->hContact))
return;
CAppletManager::GetInstance()->ActivateChatScreen(pEntry->hContact);
diff --git a/plugins/NewXstatusNotify/src/main.cpp b/plugins/NewXstatusNotify/src/main.cpp index 7ee5fdfd62..bfef047802 100644 --- a/plugins/NewXstatusNotify/src/main.cpp +++ b/plugins/NewXstatusNotify/src/main.cpp @@ -478,7 +478,7 @@ int ProcessStatus(DBCONTACTWRITESETTING *cws, MCONTACT hContact) return 0;
// we don't want to be notified if new chatroom comes online
- if (db_get_b(hContact, szProto, "ChatRoom", 0) == 1)
+ if (Contact_IsGroupChat(hContact, szProto))
return 0;
uint16_t oldStatus = DBGetContactSettingRangedWord(hContact, "UserOnline", "LastStatus", ID_STATUS_OFFLINE, ID_STATUS_MIN, ID_STATUS_MAX);
diff --git a/plugins/NoHistory/src/dllmain.cpp b/plugins/NoHistory/src/dllmain.cpp index a4b580fa84..8ac0519b22 100644 --- a/plugins/NoHistory/src/dllmain.cpp +++ b/plugins/NoHistory/src/dllmain.cpp @@ -137,8 +137,7 @@ INT_PTR ServiceClear(WPARAM hContact, LPARAM) int PrebuildContactMenu(WPARAM hContact, LPARAM)
{
bool remove = g_plugin.getByte(hContact, DBSETTING_REMOVE) != 0;
- char *proto = Proto_GetBaseAccountName(hContact);
- bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0) != 0);
+ bool chat_room = Contact_IsGroupChat(hContact);
if (chat_room)
Menu_ShowItem(hMenuToggle, false);
@@ -175,8 +174,7 @@ int WindowEvent(WPARAM, LPARAM lParam) break;
case MSG_WINDOW_EVT_OPEN:
- char *proto = Proto_GetBaseAccountName(hContact);
- bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0) != 0);
+ bool chat_room = Contact_IsGroupChat(hContact);
int remove = g_plugin.getByte(hContact, DBSETTING_REMOVE) != 0;
for (int i = 0; i < 2; ++i)
@@ -195,9 +193,7 @@ int IconPressed(WPARAM hContact, LPARAM lParam) if (sicd->flags & MBCF_RIGHTBUTTON) return 0; // ignore right-clicks
if (mir_strcmp(sicd->szModule, MODULENAME) != 0) return 0; // not our event
- char *proto = Proto_GetBaseAccountName(hContact);
- bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0) != 0);
- if (!chat_room)
+ if (!Contact_IsGroupChat(hContact))
ServiceToggle(hContact, 0);
return 0;
diff --git a/plugins/NoHistory/src/options.cpp b/plugins/NoHistory/src/options.cpp index dd613dc0ae..43b81ea040 100644 --- a/plugins/NoHistory/src/options.cpp +++ b/plugins/NoHistory/src/options.cpp @@ -64,10 +64,7 @@ class CDlgOptionsDlg : public CDlgBase void SetAllContactIcons()
{
for (auto &hContact : Contacts()) {
- char *proto = Proto_GetBaseAccountName(hContact);
- bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0) != 0);
-
- if (!chat_room) {
+ if (!Contact_IsGroupChat(hContact)) {
HANDLE hItem = clist.FindContact(hContact);
if (hItem) {
bool disabled = (g_plugin.getByte(hContact, DBSETTING_REMOVE) == 1);
@@ -129,10 +126,7 @@ public: g_plugin.bEnabledForNew = clist.GetExtraImage(hItemNew, 0);
for (auto &hContact : Contacts()) {
- char *proto = Proto_GetBaseAccountName(hContact);
- bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0) != 0);
-
- if (!chat_room) {
+ if (!Contact_IsGroupChat(hContact)) {
HANDLE hItem = clist.FindContact(hContact);
if (hItem) {
int iImage = clist.GetExtraImage(hItem, 0);
diff --git a/plugins/NoHistory/src/stdafx.h b/plugins/NoHistory/src/stdafx.h index 3810ddfb6c..5290f2e7ed 100644 --- a/plugins/NoHistory/src/stdafx.h +++ b/plugins/NoHistory/src/stdafx.h @@ -8,6 +8,7 @@ #include <m_database.h>
#include <m_clist.h>
#include <m_clc.h>
+#include <m_contacts.h>
#include <m_gui.h>
#include <m_langpack.h>
#include <m_protocols.h>
diff --git a/plugins/Nudge/src/main.cpp b/plugins/Nudge/src/main.cpp index ee2ad72b2f..2b280f6a45 100644 --- a/plugins/Nudge/src/main.cpp +++ b/plugins/Nudge/src/main.cpp @@ -413,10 +413,8 @@ static int ContactWindowOpen(WPARAM, LPARAM lParam) static int PrebuildContactMenu(WPARAM hContact, LPARAM)
{
char *szProto = Proto_GetBaseAccountName(hContact);
- if (szProto != nullptr) {
- bool isChat = db_get_b(hContact, szProto, "ChatRoom", false) != 0;
- NudgeShowMenu((WPARAM)szProto, !isChat);
- }
+ if (szProto != nullptr)
+ NudgeShowMenu((WPARAM)szProto, !Contact_IsGroupChat(hContact, szProto));
return 0;
}
diff --git a/plugins/Nudge/src/stdafx.h b/plugins/Nudge/src/stdafx.h index 7ba2deb812..e0cc104911 100644 --- a/plugins/Nudge/src/stdafx.h +++ b/plugins/Nudge/src/stdafx.h @@ -11,6 +11,7 @@ #include <newpluginapi.h>
#include <m_clistint.h>
+#include <m_contacts.h>
#include <m_langpack.h>
#include <m_popup.h>
#include <m_message.h>
diff --git a/plugins/PasteIt/src/PasteIt.cpp b/plugins/PasteIt/src/PasteIt.cpp index 0cfc630cee..80398f6911 100644 --- a/plugins/PasteIt/src/PasteIt.cpp +++ b/plugins/PasteIt/src/PasteIt.cpp @@ -109,7 +109,7 @@ static void PasteIt(MCONTACT hContact, int mode) else if (hContact != NULL && pasteToWeb->szFileLink[0] != 0) {
char *szProto = Proto_GetBaseAccountName(hContact);
if (szProto && (INT_PTR)szProto != CALLSERVICE_NOTFOUND) {
- BOOL isChat = db_get_b(hContact, szProto, "ChatRoom", 0);
+ bool isChat = Contact_IsGroupChat(hContact, szProto);
if (Options::instance->autoSend) {
if (!isChat) {
DBEVENTINFO dbei = {};
@@ -323,7 +323,7 @@ static int WindowEvent(WPARAM, MessageWindowEventData* lParam) if (lParam->uType == MSG_WINDOW_EVT_OPEN) {
char *szProto = Proto_GetBaseAccountName(lParam->hContact);
if (szProto && (INT_PTR)szProto != CALLSERVICE_NOTFOUND) {
- if (db_get_b(lParam->hContact, szProto, "ChatRoom", 0)) {
+ if (Contact_IsGroupChat(lParam->hContact, szProto)) {
(*contactWindows)[lParam->hContact] = lParam->hwndInput;
}
}
diff --git a/plugins/PasteIt/src/stdafx.h b/plugins/PasteIt/src/stdafx.h index e747eb8f97..c6f05d3133 100644 --- a/plugins/PasteIt/src/stdafx.h +++ b/plugins/PasteIt/src/stdafx.h @@ -20,6 +20,7 @@ #include <newpluginapi.h>
#include <m_clist.h>
+#include <m_contacts.h>
#include <m_langpack.h>
#include <m_netlib.h>
#include <m_xml.h>
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index fbf8f9e8e0..38bb0461cb 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -297,10 +297,10 @@ static int PrebuildContactMenu(WPARAM hContact, LPARAM) bool bEnabled = false;
char *szProto = Proto_GetBaseAccountName(hContact);
- if ( szProto ) {
+ if (szProto) {
// leave this menu item hidden for chats
- if ( !db_get_b(hContact, szProto, "ChatRoom", 0))
- if ( CallProtoService( szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)
+ if (!Contact_IsGroupChat(hContact, szProto))
+ if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)
bEnabled = true;
}
diff --git a/plugins/SecureIM/src/crypt_check.cpp b/plugins/SecureIM/src/crypt_check.cpp index 802b82c32e..f0665d7e28 100644 --- a/plugins/SecureIM/src/crypt_check.cpp +++ b/plugins/SecureIM/src/crypt_check.cpp @@ -180,7 +180,7 @@ bool isChatRoom(MCONTACT hContact) if (!p || !p->proto || !p->proto->inspecting)
return false;
- return db_get_b(hContact, p->proto->name, "ChatRoom", 0) != 0;
+ return Contact_IsGroupChat(hContact, p->proto->name);
}
bool isFileExist(LPCSTR filename)
diff --git a/plugins/SeenPlugin/src/menu.cpp b/plugins/SeenPlugin/src/menu.cpp index fc62ca1d0f..c24345000a 100644 --- a/plugins/SeenPlugin/src/menu.cpp +++ b/plugins/SeenPlugin/src/menu.cpp @@ -37,7 +37,7 @@ INT_PTR MenuitemClicked(WPARAM hContact, LPARAM) int BuildContactMenu(WPARAM hContact, LPARAM)
{
char *szProto = Proto_GetBaseAccountName(hContact);
- if (!IsWatchedProtocol(szProto) || db_get_b(hContact, szProto, "ChatRoom", false) || !g_plugin.getByte("MenuItem", 1)) {
+ if (!IsWatchedProtocol(szProto) || Contact_IsGroupChat(hContact, szProto) || !g_plugin.getByte("MenuItem", 1)) {
Menu_ShowItem(hmenuitem, false);
return 0;
}
diff --git a/plugins/SeenPlugin/src/userinfo.cpp b/plugins/SeenPlugin/src/userinfo.cpp index 1a323a5e11..fce8288f05 100644 --- a/plugins/SeenPlugin/src/userinfo.cpp +++ b/plugins/SeenPlugin/src/userinfo.cpp @@ -63,7 +63,7 @@ struct UserinfoDlg : public CUserInfoPageDlg int UserinfoInit(WPARAM wparam, LPARAM hContact)
{
char *szProto = Proto_GetBaseAccountName(hContact);
- if (IsWatchedProtocol(szProto) && !db_get_b(hContact, szProto, "ChatRoom", false)) {
+ if (IsWatchedProtocol(szProto) && !Contact_IsGroupChat(hContact, szProto)) {
USERINFOPAGE uip = {};
uip.szTitle.a = LPGEN("Last seen");
uip.pDialog = new UserinfoDlg();
diff --git a/plugins/SeenPlugin/src/utils.cpp b/plugins/SeenPlugin/src/utils.cpp index ee2089f5a5..1a3bee9e55 100644 --- a/plugins/SeenPlugin/src/utils.cpp +++ b/plugins/SeenPlugin/src/utils.cpp @@ -555,7 +555,7 @@ int UpdateValues(WPARAM hContact, LPARAM lparam) g_plugin.setByte(hContact, "Offline", 0);
}
}
- else if (hContact && IsWatchedProtocol(cws->szModule) && !db_get_b(hContact, cws->szModule, "ChatRoom", false)) {
+ else if (hContact && IsWatchedProtocol(cws->szModule) && !Contact_IsGroupChat(hContact, cws->szModule)) {
// here we will come when <User>/<module>/Status is changed or it is idle event and if <module> is watched
if (Proto_GetStatus(cws->szModule) > ID_STATUS_OFFLINE) {
mir_cslock lck(csContacts);
diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp index db1056c748..385f413d06 100644 --- a/plugins/SendScreenshotPlus/src/CSend.cpp +++ b/plugins/SendScreenshotPlus/src/CSend.cpp @@ -66,7 +66,7 @@ void CSend::SetContact(MCONTACT hContact) m_hContact = hContact; if (hContact) { m_pszProto = Proto_GetBaseAccountName(hContact); - m_ChatRoom = db_get_b(hContact, m_pszProto, "ChatRoom", 0); + m_ChatRoom = Contact_IsGroupChat(hContact, m_pszProto); } } diff --git a/plugins/SendScreenshotPlus/src/Main.cpp b/plugins/SendScreenshotPlus/src/Main.cpp index 1db150cf55..4233d5e3e6 100644 --- a/plugins/SendScreenshotPlus/src/Main.cpp +++ b/plugins/SendScreenshotPlus/src/Main.cpp @@ -138,14 +138,13 @@ INT_PTR service_SendDesktop(WPARAM wParam, LPARAM) delete frmMain; return -1; } + MCONTACT hContact = (MCONTACT)wParam; - char *pszProto = Proto_GetBaseAccountName(hContact); - bool bChatRoom = db_get_b(hContact, pszProto, "ChatRoom", 0) != 0; frmMain->m_opt_chkTimed = false; frmMain->m_opt_tabCapture = 1; frmMain->m_opt_cboxDesktop = 0; frmMain->m_opt_chkEditor = false; - frmMain->m_opt_cboxSendBy = bChatRoom ? SS_IMAGESHACK : SS_FILESEND; + frmMain->m_opt_cboxSendBy = Contact_IsGroupChat(hContact) ? SS_IMAGESHACK : SS_FILESEND; frmMain->Init(pszPath, hContact); // this method create the window hidden. mir_free(pszPath); frmMain->btnCaptureClick(); // this method will call Close() diff --git a/plugins/SimpleStatusMsg/src/awaymsg.cpp b/plugins/SimpleStatusMsg/src/awaymsg.cpp index 21e5416762..13f73b6b57 100644 --- a/plugins/SimpleStatusMsg/src/awaymsg.cpp +++ b/plugins/SimpleStatusMsg/src/awaymsg.cpp @@ -294,7 +294,7 @@ static int AwayMsgPreBuildMenu(WPARAM hContact, LPARAM) Menu_ShowItem(hAwayMsgMenuItem, false);
char *szProto = Proto_GetBaseAccountName(hContact);
- if (szProto == nullptr || db_get_b(hContact, szProto, "ChatRoom", 0))
+ if (szProto == nullptr || Contact_IsGroupChat(hContact, szProto))
return 0;
int iStatus = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
diff --git a/plugins/SimpleStatusMsg/src/stdafx.h b/plugins/SimpleStatusMsg/src/stdafx.h index 402d93dab3..04eaf6ed1d 100644 --- a/plugins/SimpleStatusMsg/src/stdafx.h +++ b/plugins/SimpleStatusMsg/src/stdafx.h @@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <newpluginapi.h>
#include <m_database.h>
#include <m_clistint.h>
+#include <m_contacts.h>
#include <m_skin.h>
#include <m_options.h>
#include <m_langpack.h>
diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index 1e495f0c33..75e9d6d680 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -502,7 +502,7 @@ void CGlobals::logStatusChange(WPARAM wParam, const CContactCache *c) return;
// don't log them if WE are logging off
- if (Proto_GetStatus(c->getProto()) == ID_STATUS_OFFLINE || db_get_b(hContact, c->getProto(), "ChatRoom", 0))
+ if (Proto_GetStatus(c->getProto()) == ID_STATUS_OFFLINE || Contact_IsGroupChat(hContact, c->getProto()))
return;
uint16_t wStatus = LOWORD(wParam);
diff --git a/plugins/TabSRMM/src/hotkeyhandler.cpp b/plugins/TabSRMM/src/hotkeyhandler.cpp index 63420a6f0c..82430e9446 100644 --- a/plugins/TabSRMM/src/hotkeyhandler.cpp +++ b/plugins/TabSRMM/src/hotkeyhandler.cpp @@ -249,7 +249,7 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendMessage(pDlg->GetHwnd(), WM_CLOSE, 0, 1);
char *szProto = Proto_GetBaseAccountName(lParam);
- if (szProto != nullptr && db_get_b(lParam, szProto, "ChatRoom", 0))
+ if (szProto != nullptr && Contact_IsGroupChat(lParam, szProto))
ShowRoom((TContainerData*)wParam, SM_FindSessionByHCONTACT(lParam));
else
CreateNewTabForContact((TContainerData*)wParam, lParam, true, true, false);
diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp index b96b7b84aa..e2ec82201a 100644 --- a/plugins/TabSRMM/src/mim.cpp +++ b/plugins/TabSRMM/src/mim.cpp @@ -351,7 +351,7 @@ int CMimAPI::PrebuildContactMenu(WPARAM hContact, LPARAM) char *szProto = Proto_GetBaseAccountName(hContact); if (szProto) { // leave this menu item hidden for chats - if (!db_get_b(hContact, szProto, "ChatRoom", 0)) + if (!Contact_IsGroupChat(hContact, szProto)) if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) bEnabled = true; } diff --git a/plugins/TipperYM/src/stdafx.h b/plugins/TipperYM/src/stdafx.h index 1bc6c5d898..0d20d28662 100644 --- a/plugins/TipperYM/src/stdafx.h +++ b/plugins/TipperYM/src/stdafx.h @@ -34,6 +34,7 @@ Boston, MA 02111-1307, USA. #include <m_clistint.h>
#include <m_clc.h>
#include <m_cluiframes.h>
+#include <m_contacts.h>
#include <m_database.h>
#include <m_fontservice.h>
#include <m_icolib.h>
diff --git a/plugins/TipperYM/src/subst.cpp b/plugins/TipperYM/src/subst.cpp index 45e7abd4d5..7d0eda0ac3 100644 --- a/plugins/TipperYM/src/subst.cpp +++ b/plugins/TipperYM/src/subst.cpp @@ -67,7 +67,7 @@ bool CheckContactType(MCONTACT hContact, const DISPLAYITEM &di) char *szProto = Proto_GetBaseAccountName(hContact); if (szProto) { - if (db_get_b(hContact, szProto, "ChatRoom", 0) != 0) + if (Contact_IsGroupChat(hContact, szProto)) return di.type == DIT_CHATS; else return di.type == DIT_CONTACTS; diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp b/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp index 50903e7681..3359ce6292 100644 --- a/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp +++ b/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp @@ -107,7 +107,7 @@ uint8_t CExImContactBase::fromDB(MCONTACT hContact) } // unique id (for ChatRoom) - if (isChatRoom = db_get_b(_hContact, pszProto, "ChatRoom", 0)) { + if (isChatRoom = Contact_IsGroupChat(_hContact, pszProto)) { uidSetting = "ChatRoomID"; _pszUIDKey = mir_strdup(uidSetting); if (!DB::Setting::GetAsIs(_hContact, pszProto, uidSetting, &_dbvUID)) { diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp index 1eeb5e0d99..67f427d5bc 100644 --- a/plugins/Variables/src/contact.cpp +++ b/plugins/Variables/src/contact.cpp @@ -155,12 +155,12 @@ wchar_t* getContactInfoT(uint8_t type, MCONTACT hContact) break;
case CNF_UNIQUEID:
- //UID for ChatRoom
- if (db_get_b(hContact, szProto, "ChatRoom", 0) == 1)
+ // UID for ChatRoom
+ if (Contact_IsGroupChat(hContact, szProto))
if ((res = db_get_wsa(hContact, szProto, "ChatRoomID")) != nullptr)
return res;
- //UID for other contact
+ // UID for other contact
break;
}
diff --git a/protocols/CloudFile/src/utils.cpp b/protocols/CloudFile/src/utils.cpp index c2693960ca..76d11dada8 100644 --- a/protocols/CloudFile/src/utils.cpp +++ b/protocols/CloudFile/src/utils.cpp @@ -66,7 +66,7 @@ bool CanSendToContact(MCONTACT hContact) void SendToContact(MCONTACT hContact, const wchar_t *data) { const char *szProto = Proto_GetBaseAccountName(hContact); - if (db_get_b(hContact, szProto, "ChatRoom", 0) == TRUE) { + if (Contact_IsGroupChat(hContact, szProto)) { ptrW tszChatRoom(db_get_wsa(hContact, szProto, "ChatRoomID")); Chat_SendUserMessage(szProto, tszChatRoom, data); return; diff --git a/protocols/Sametime/src/conference.cpp b/protocols/Sametime/src/conference.cpp index fe3fcd5957..3dae386909 100644 --- a/protocols/Sametime/src/conference.cpp +++ b/protocols/Sametime/src/conference.cpp @@ -318,7 +318,7 @@ int CSametimeProto::GcEventHook(WPARAM, LPARAM lParam) { int CSametimeProto::ChatDeleted(MCONTACT hContact) {
- if (db_get_b(hContact, m_szModuleName, "ChatRoom", 0) == 0)
+ if (!Contact_IsGroupChat(hContact, m_szModuleName))
return 0;
debugLogW(L"CSametimeProto::ChatDeleted() hContact=[%x]", hContact);
@@ -379,7 +379,7 @@ int CSametimeProto::PrebuildContactMenu(WPARAM wParam, LPARAM) MCONTACT hContact = (MCONTACT)wParam;
debugLogW(L"CSametimeProto::PrebuildContactMenu() hContact=[%x]", hContact);
- Menu_ShowItem(hLeaveChatMenuItem, db_get_b(hContact, m_szModuleName, "ChatRoom", 0) == 1);
+ Menu_ShowItem(hLeaveChatMenuItem, Contact_IsGroupChat(hContact, m_szModuleName));
// if user is already in our meeting,
bool not_present = true;
@@ -400,7 +400,7 @@ int CSametimeProto::PrebuildContactMenu(WPARAM wParam, LPARAM) db_free(&dbv);
}
- Menu_ShowItem(hCreateChatMenuItem, db_get_b(hContact, m_szModuleName, "ChatRoom", 0) == 0 && not_present);
+ Menu_ShowItem(hCreateChatMenuItem, !Contact_IsGroupChat(hContact, m_szModuleName) && not_present);
return 0;
}
diff --git a/protocols/Sametime/src/sametime.cpp b/protocols/Sametime/src/sametime.cpp index 0b309c9987..35ab74786b 100644 --- a/protocols/Sametime/src/sametime.cpp +++ b/protocols/Sametime/src/sametime.cpp @@ -103,7 +103,7 @@ int CSametimeProto::OnWindowEvent(WPARAM, LPARAM lParam) {
MessageWindowEventData *mwed = (MessageWindowEventData*)lParam;
- if ((mwed == nullptr) || db_get_b(mwed->hContact, m_szModuleName, "ChatRoom", 0))
+ if ((mwed == nullptr) || Contact_IsGroupChat(mwed->hContact, m_szModuleName))
return 0;
if ((mwed->uType == MSG_WINDOW_EVT_CLOSING) || (mwed->uType == MSG_WINDOW_EVT_CLOSE))
@@ -140,7 +140,7 @@ void CSametimeProto::SetAllOffline() debugLogW(L"SetAllOffline() start");
for (auto &hContact : AccContacts()) {
- if (db_get_b(hContact, m_szModuleName, "ChatRoom", 0)) {
+ if (Contact_IsGroupChat(hContact, m_szModuleName)) {
db_delete_contact(hContact);
continue;
}
diff --git a/protocols/Sametime/src/sametime_proto.cpp b/protocols/Sametime/src/sametime_proto.cpp index 46b583cddb..02e3dd717f 100644 --- a/protocols/Sametime/src/sametime_proto.cpp +++ b/protocols/Sametime/src/sametime_proto.cpp @@ -129,7 +129,7 @@ int CSametimeProto::GetInfo(MCONTACT hContact, int infoType) // GetInfo - retrieves a contact info
debugLogW(L"CSametimeProto::GetInfo() hContact=[%x], infoType=[%d]", hContact, infoType);
- if (getByte(hContact, "ChatRoom", 0))
+ if (Contact_IsGroupChat(hContact))
return 1;
if (!session)
diff --git a/protocols/Sametime/src/session_announce_win.cpp b/protocols/Sametime/src/session_announce_win.cpp index 459a067530..d01f047cc6 100644 --- a/protocols/Sametime/src/session_announce_win.cpp +++ b/protocols/Sametime/src/session_announce_win.cpp @@ -41,7 +41,7 @@ INT_PTR CALLBACK SessionAnnounceDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wPara lvI.iSubItem = 0;
for (auto &hContact : proto->AccContacts()) {
- if (db_get_b(hContact, proto->m_szModuleName, "ChatRoom", 0) == 0
+ if (!Contact_IsGroupChat(hContact, proto->m_szModuleName)
&& db_get_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
lvI.lParam = (LPARAM)hContact;
lvI.pszText = Clist_GetContactDisplayName(hContact);
diff --git a/protocols/Sametime/src/userlist.cpp b/protocols/Sametime/src/userlist.cpp index fe90f548c1..ccc5d46a3c 100644 --- a/protocols/Sametime/src/userlist.cpp +++ b/protocols/Sametime/src/userlist.cpp @@ -373,7 +373,7 @@ int CSametimeProto::ContactDeleted(MCONTACT hContact) {
mwAwareIdBlock id_block;
- if (db_get_b(hContact, m_szModuleName, "ChatRoom", 0))
+ if (Contact_IsGroupChat(hContact, m_szModuleName))
return 0;
debugLogW(L"CSametimeProto::ContactDeleted()");
@@ -586,7 +586,7 @@ void CSametimeProto::UserListCreate() GList *gl = nullptr;
for (auto &hContact : AccContacts()) {
- if (db_get_b(hContact, m_szModuleName, "ChatRoom", 0) == 0 /*&& proto && !mir_strcmp( PROTO, proto)*/) {
+ if (!Contact_IsGroupChat(hContact, m_szModuleName) /*&& proto && !mir_strcmp( PROTO, proto)*/) {
if (!db_get_utf(hContact, m_szModuleName, "stid", &dbv)) {
if (dbv.pszVal) {
if (GetAwareIdFromContact(hContact, &id_block)) {
diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp index 29e6bfef24..6a75e1706b 100644 --- a/protocols/Twitter/src/contacts.cpp +++ b/protocols/Twitter/src/contacts.cpp @@ -211,7 +211,7 @@ bool CTwitterProto::IsMyContact(MCONTACT hContact, bool include_chat) MCONTACT CTwitterProto::UsernameToHContact(const char *name)
{
for (auto &hContact : AccContacts()) {
- if (getByte(hContact, "ChatRoom"))
+ if (Contact_IsGroupChat(hContact))
continue;
if (getMStringA(hContact, TWITTER_KEY_UN) == name)
@@ -224,7 +224,7 @@ MCONTACT CTwitterProto::UsernameToHContact(const char *name) MCONTACT CTwitterProto::FindContactById(const char *id)
{
for (auto &hContact : AccContacts()) {
- if (getByte(hContact, "ChatRoom"))
+ if (Contact_IsGroupChat(hContact))
continue;
if (getMStringA(hContact, TWITTER_KEY_ID) == id)
diff --git a/src/core/stdaway/src/awaymsg.cpp b/src/core/stdaway/src/awaymsg.cpp index 1b4d5d25f9..a2dcca0220 100644 --- a/src/core/stdaway/src/awaymsg.cpp +++ b/src/core/stdaway/src/awaymsg.cpp @@ -131,8 +131,7 @@ static int AwayMsgPreBuildMenu(WPARAM hContact, LPARAM) {
char *szProto = Proto_GetBaseAccountName(hContact);
if (szProto != nullptr) {
- int chatRoom = db_get_b(hContact, szProto, "ChatRoom", 0);
- if (!chatRoom) {
+ if (!Contact_IsGroupChat(hContact, szProto)) {
int status = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGRECV) {
if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(status)) {
diff --git a/src/core/stdfile/src/file.cpp b/src/core/stdfile/src/file.cpp index e257013663..39e24e7c50 100644 --- a/src/core/stdfile/src/file.cpp +++ b/src/core/stdfile/src/file.cpp @@ -35,7 +35,7 @@ static HGENMENU hSRFileMenuItem; wchar_t* GetContactID(MCONTACT hContact)
{
char *szProto = Proto_GetBaseAccountName(hContact);
- if (db_get_b(hContact, szProto, "ChatRoom", 0) == 1)
+ if (Contact_IsGroupChat(hContact, szProto))
if (wchar_t *theValue = db_get_wsa(hContact, szProto, "ChatRoomID"))
return theValue;
@@ -288,7 +288,7 @@ static int SRFilePreBuildMenu(WPARAM wParam, LPARAM) bool bEnabled = false;
char *szProto = Proto_GetBaseAccountName(wParam);
if (szProto != nullptr) {
- bool isChat = db_get_b(wParam, szProto, "ChatRoom", false) != 0;
+ bool isChat = Contact_IsGroupChat(wParam, szProto);
if (CallProtoService(szProto, PS_GETCAPS, isChat ? PFLAGNUM_4 : PFLAGNUM_1, 0) & (isChat ? PF4_GROUPCHATFILES : PF1_FILESEND)) {
if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_OFFLINEFILES)
bEnabled = true;
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 89e5395ace..fbe29a10b3 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -488,7 +488,7 @@ static int PrebuildContactMenu(WPARAM hContact, LPARAM) char *szProto = Proto_GetBaseAccountName(hContact);
if (szProto) {
// leave this menu item hidden for chats
- if (!db_get_b(hContact, szProto, "ChatRoom", 0))
+ if (!Contact_IsGroupChat(hContact, szProto))
if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)
bEnabled = true;
}
diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp index 76fc40e721..86f6e451ec 100644 --- a/src/mir_app/src/chat_clist.cpp +++ b/src/mir_app/src/chat_clist.cpp @@ -79,8 +79,8 @@ BOOL SetAllOffline(BOOL, const char *pszModule) char *szProto = Proto_GetBaseAccountName(hContact);
if (!MM_FindModule(szProto))
continue;
- int i = db_get_b(hContact, szProto, "ChatRoom", 0);
- if (i != 0) {
+
+ if (Contact_IsGroupChat(hContact, szProto)) {
db_set_w(hContact, szProto, "ApparentMode", 0);
db_set_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
}
@@ -97,7 +97,7 @@ int RoomDoubleclicked(WPARAM hContact, LPARAM) char *szProto = Proto_GetBaseAccountName(hContact);
if (MM_FindModule(szProto) == nullptr)
return 0;
- if (db_get_b(hContact, szProto, "ChatRoom", 0) == 0)
+ if (!Contact_IsGroupChat(hContact, szProto))
return 0;
ptrW roomid(db_get_wsa(hContact, szProto, "ChatRoomID"));
@@ -118,7 +118,7 @@ int RoomDoubleclicked(WPARAM hContact, LPARAM) MCONTACT FindRoom(const char *pszModule, const wchar_t *pszRoom)
{
for (auto &hContact : Contacts(pszModule)) {
- if (!db_get_b(hContact, pszModule, "ChatRoom", 0))
+ if (!Contact_IsGroupChat(hContact, pszModule))
continue;
ptrW roomid(db_get_wsa(hContact, pszModule, "ChatRoomID"));
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 142f8c162a..0b5485a03a 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -199,7 +199,7 @@ static void SM_FreeSession(SESSION_INFO *si, bool bRemoveContact = false) // contact may have been deleted here already, since function may be called after deleting
// contact so the handle may be invalid, therefore db_get_b shall return 0
- if (si->hContact && db_get_b(si->hContact, si->pszModule, "ChatRoom", 0) != 0) {
+ if (si->hContact && Contact_IsGroupChat(si->hContact, si->pszModule)) {
g_chatApi.SetOffline(si->hContact, (si->iType == GCW_CHATROOM || si->iType == GCW_PRIVMESS) ? TRUE : FALSE);
db_set_s(si->hContact, si->pszModule, "Topic", "");
db_set_s(si->hContact, si->pszModule, "StatusBar", "");
diff --git a/src/mir_app/src/contacts.cpp b/src/mir_app/src/contacts.cpp index 57a1833b72..81a899368c 100644 --- a/src/mir_app/src/contacts.cpp +++ b/src/mir_app/src/contacts.cpp @@ -280,9 +280,22 @@ MIR_APP_DLL(int) Contact_GetStatus(MCONTACT hContact) ///////////////////////////////////////////////////////////////////////////////
+MIR_APP_DLL(bool) Contact_IsGroupChat(MCONTACT hContact, const char *szProto)
+{
+ if (szProto == nullptr) {
+ szProto = Proto_GetBaseAccountName(hContact);
+ if (szProto == nullptr)
+ return false;
+ }
+
+ return db_get_b(hContact, szProto, "ChatRoom") != 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(bool) Contact_IsHidden(MCONTACT hContact)
{
- return db_get_b(hContact, "CList", "Hidden", 0) != 0;
+ return db_get_b(hContact, "CList", "Hidden") != 0;
}
MIR_APP_DLL(void) Contact_Hide(MCONTACT hContact, bool bHidden)
diff --git a/src/mir_app/src/ei_defaulticons.cpp b/src/mir_app/src/ei_defaulticons.cpp index 5a7b945d1a..8cfe52defb 100644 --- a/src/mir_app/src/ei_defaulticons.cpp +++ b/src/mir_app/src/ei_defaulticons.cpp @@ -45,14 +45,13 @@ static void SetVisibility(MCONTACT hContact, int apparentMode, bool clear) HANDLE hExtraIcon, hIcolib = nullptr; - if (db_get_b(hContact, proto, "ChatRoom", 0)) { - // Is chat + // Is chat + if (Contact_IsGroupChat(hContact, proto)) { hExtraIcon = hExtraChat; if (apparentMode == ID_STATUS_OFFLINE) hIcolib = IcoLib_GetIconHandle("ChatActivity"); } - else { - // Not chat + else { // Not chat hExtraIcon = hExtraVisibility; if (apparentMode == ID_STATUS_OFFLINE) hIcolib = Skin_GetIconHandle(SKINICON_OTHER_INVISIBLE_ALL); diff --git a/src/mir_app/src/meta_menu.cpp b/src/mir_app/src/meta_menu.cpp index 7956574fd5..f337b699bb 100644 --- a/src/mir_app/src/meta_menu.cpp +++ b/src/mir_app/src/meta_menu.cpp @@ -318,7 +318,7 @@ int Meta_ModifyMenu(WPARAM hMeta, LPARAM) }
else {
// The contact is neutral
- bool bHideChat = db_get_b(hMeta, cc->szProto, "ChatRoom", 0) == 0;
+ bool bHideChat = !Contact_IsGroupChat(hMeta, cc->szProto);
Menu_ShowItem(hMenuAdd, bHideChat);
Menu_ShowItem(hMenuConvert, bHideChat);
Menu_ShowItem(hMenuEdit, false);
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 6b3cc265a2..ac4c2904f3 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -798,3 +798,4 @@ Srmm_CreateHotkey @886 NONAME ??_7CUserInfoPageDlg@@6B@ @891 NONAME
?OnRefresh@CUserInfoPageDlg@@UAE_NXZ @892 NONAME
?SetContact@CUserInfoPageDlg@@QAEXI@Z @893 NONAME
+?Contact_IsGroupChat@@YG_NIPBD@Z @894 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 229b99bbc1..ed227d6adb 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -798,3 +798,4 @@ Srmm_CreateHotkey @886 NONAME ??_7CUserInfoPageDlg@@6B@ @891 NONAME
?OnRefresh@CUserInfoPageDlg@@UEAA_NXZ @892 NONAME
?SetContact@CUserInfoPageDlg@@QEAAXI@Z @893 NONAME
+?Contact_IsGroupChat@@YA_NIPEBD@Z @894 NONAME
diff --git a/src/mir_app/src/path.cpp b/src/mir_app/src/path.cpp index ced42f99b6..aebc78e66b 100644 --- a/src/mir_app/src/path.cpp +++ b/src/mir_app/src/path.cpp @@ -35,7 +35,7 @@ static wchar_t tszAvatarRoot[MAX_PATH]; wchar_t* GetContactID(MCONTACT hContact)
{
char *szProto = Proto_GetBaseAccountName(hContact);
- if (db_get_b(hContact, szProto, "ChatRoom", 0) == 1)
+ if (Contact_IsGroupChat(hContact, szProto))
return db_get_wsa(hContact, szProto, "ChatRoomID");
return Contact_GetInfo(CNF_UNIQUEID, hContact, szProto);
|