summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-03-20 14:47:13 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-03-20 14:47:13 +0000
commit5289388e941bbdeca3d380c2f1044228e3397bc0 (patch)
tree47c9611377af3f3f41ecd65eaa1df5ff6bc9b97b
parent80578cde52fbd2e201ddc6717d689c6d71bf19a0 (diff)
db_mc_enable, db_mc_isEnabled - new functions to detect whether MC are used
git-svn-id: http://svn.miranda-ng.org/main/trunk@8666 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--bin10/lib/mir_core.libbin58042 -> 58468 bytes
-rw-r--r--bin10/lib/mir_core64.libbin53092 -> 53480 bytes
-rw-r--r--bin12/lib/mir_core.libbin58042 -> 58468 bytes
-rw-r--r--bin12/lib/mir_core64.libbin53092 -> 53480 bytes
-rw-r--r--include/delphi/m_metacontacts.inc8
-rw-r--r--include/m_metacontacts.h4
-rw-r--r--src/mir_core/mc.cpp29
-rw-r--r--src/mir_core/mir_core.def2
-rw-r--r--src/modules/metacontacts/meta_main.cpp2
-rw-r--r--src/modules/metacontacts/meta_menu.cpp19
-rw-r--r--src/modules/metacontacts/meta_options.cpp2
-rw-r--r--src/modules/metacontacts/meta_services.cpp12
-rw-r--r--src/modules/metacontacts/metacontacts.h1
13 files changed, 49 insertions, 30 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib
index 3944ea3345..077401f6f7 100644
--- a/bin10/lib/mir_core.lib
+++ b/bin10/lib/mir_core.lib
Binary files differ
diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib
index 16730a7938..217c644302 100644
--- a/bin10/lib/mir_core64.lib
+++ b/bin10/lib/mir_core64.lib
Binary files differ
diff --git a/bin12/lib/mir_core.lib b/bin12/lib/mir_core.lib
index d2fadc3eb6..c7983453ff 100644
--- a/bin12/lib/mir_core.lib
+++ b/bin12/lib/mir_core.lib
Binary files differ
diff --git a/bin12/lib/mir_core64.lib b/bin12/lib/mir_core64.lib
index 35f318457e..217c644302 100644
--- a/bin12/lib/mir_core64.lib
+++ b/bin12/lib/mir_core64.lib
Binary files differ
diff --git a/include/delphi/m_metacontacts.inc b/include/delphi/m_metacontacts.inc
index 6807a366f9..4ff361fa71 100644
--- a/include/delphi/m_metacontacts.inc
+++ b/include/delphi/m_metacontacts.inc
@@ -110,6 +110,14 @@ const
/////////////////////////////////////////////////////////////////////////////////////////
// binary interface to MC
+{ returns true if metacontacts are enabled or false otherwise }
+function db_mc_isEnabled():bool; stdcall;
+ external CoreDLL name 'db_mc_isEnabled';
+
+{ returns true if a contact is a metacontact or false otherwise }
+procedure db_mc_enable(bEnabled:bool); stdcall;
+ external CoreDLL name 'db_mc_enable';
+
{ returns true if a contact is a metacontact or false otherwise }
function db_mc_isMeta(hContact:TMCONTACT):int; stdcall;
external CoreDLL name 'db_mc_isMeta';
diff --git a/include/m_metacontacts.h b/include/m_metacontacts.h
index d050e685cd..fc09425ea9 100644
--- a/include/m_metacontacts.h
+++ b/include/m_metacontacts.h
@@ -70,6 +70,10 @@ extern "C"
{
#endif
+// checks whether metacontacts are enabled
+MIR_CORE_DLL(BOOL) db_mc_isEnabled(void);
+MIR_CORE_DLL(void) db_mc_enable(BOOL);
+
// checks whether a contact is a metacontact
MIR_CORE_DLL(int) db_mc_isMeta(MCONTACT hMetaContact);
diff --git a/src/mir_core/mc.cpp b/src/mir_core/mc.cpp
index 4970b135d8..57b91eb367 100644
--- a/src/mir_core/mc.cpp
+++ b/src/mir_core/mc.cpp
@@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
static HANDLE hEventDefaultChanged;
+static bool g_bEnabled;
void InitMetaContacts()
{
@@ -33,22 +34,26 @@ void InitMetaContacts()
DBCachedContact* CheckMeta(MCONTACT hMeta)
{
+ if (!g_bEnabled)
+ return NULL;
+
DBCachedContact *cc = currDb->m_cache->GetCachedContact(hMeta);
return (cc == NULL || cc->nSubs == -1) ? NULL : cc;
}
int Meta_GetContactNumber(DBCachedContact *cc, MCONTACT hContact)
{
- for (int i = 0; i < cc->nSubs; i++)
- if (cc->pSubs[i] == hContact)
- return i;
+ if (g_bEnabled)
+ for (int i = 0; i < cc->nSubs; i++)
+ if (cc->pSubs[i] == hContact)
+ return i;
return -1;
}
MCONTACT Meta_GetContactHandle(DBCachedContact *cc, int contact_number)
{
- if (contact_number >= cc->nSubs || contact_number < 0)
+ if (contact_number >= cc->nSubs || contact_number < 0 || !g_bEnabled)
return 0;
return cc->pSubs[contact_number];
@@ -57,9 +62,19 @@ MCONTACT Meta_GetContactHandle(DBCachedContact *cc, int contact_number)
/////////////////////////////////////////////////////////////////////////////////////////
// metacontacts
+MIR_CORE_DLL(BOOL) db_mc_isEnabled(void)
+{
+ return g_bEnabled;
+}
+
+MIR_CORE_DLL(void) db_mc_enable(BOOL bEnabled)
+{
+ g_bEnabled = bEnabled != 0;
+}
+
MIR_CORE_DLL(int) db_mc_isMeta(MCONTACT hContact)
{
- if (currDb == NULL) return false;
+ if (currDb == NULL || !g_bEnabled) return false;
DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
return (cc == NULL) ? false : cc->nSubs != -1;
@@ -67,7 +82,7 @@ MIR_CORE_DLL(int) db_mc_isMeta(MCONTACT hContact)
MIR_CORE_DLL(int) db_mc_isSub(MCONTACT hContact)
{
- if (currDb == NULL) return false;
+ if (currDb == NULL || !g_bEnabled) return false;
DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
return (cc == NULL) ? false : cc->parentID != 0;
@@ -100,7 +115,7 @@ MIR_CORE_DLL(int) db_mc_getSubCount(MCONTACT hMetaContact)
// returns parent hContact for a subcontact or INVALID_CONTACT_ID if it's not a sub
MIR_CORE_DLL(MCONTACT) db_mc_getMeta(MCONTACT hSubContact)
{
- if (currDb == NULL) return NULL;
+ if (currDb == NULL || !g_bEnabled) return false;
DBCachedContact *cc = currDb->m_cache->GetCachedContact(hSubContact);
return (cc == NULL) ? NULL : cc->parentID;
diff --git a/src/mir_core/mir_core.def b/src/mir_core/mir_core.def
index b017a5f246..1bcaa310cc 100644
--- a/src/mir_core/mir_core.def
+++ b/src/mir_core/mir_core.def
@@ -259,3 +259,5 @@ db_mc_getSub @256
db_mc_setDefault @257
db_mc_setDefaultNum @258
mir_closeLog @259
+db_mc_enable @260
+db_mc_isEnabled @261
diff --git a/src/modules/metacontacts/meta_main.cpp b/src/modules/metacontacts/meta_main.cpp
index c031e6ce77..dec65ef7d0 100644
--- a/src/modules/metacontacts/meta_main.cpp
+++ b/src/modules/metacontacts/meta_main.cpp
@@ -24,8 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "metacontacts.h"
-BOOL os_unicode_enabled = FALSE;
-
/////////////////////////////////////////////////////////////////////////////////////////
// icolib support
diff --git a/src/modules/metacontacts/meta_menu.cpp b/src/modules/metacontacts/meta_menu.cpp
index f6116a03ea..0717647f88 100644
--- a/src/modules/metacontacts/meta_menu.cpp
+++ b/src/modules/metacontacts/meta_menu.cpp
@@ -76,7 +76,7 @@ INT_PTR Meta_Convert(WPARAM wParam, LPARAM lParam)
}
// hide the contact if clist groups disabled (shouldn't create one anyway since menus disabled)
- if (!options.bEnabled)
+ if (!db_mc_isEnabled())
db_set_b(hMetaContact, "CList", "Hidden", 1);
return hMetaContact;
@@ -318,7 +318,7 @@ int Meta_ModifyMenu(WPARAM hMeta, LPARAM lParam)
}
PROTOACCOUNT *pa = Proto_GetAccount(cc->szProto);
- if (!options.bEnabled || pa->bIsVirtual) {
+ if (!db_mc_isEnabled() || pa->bIsVirtual) {
// groups disabled - all meta menu options hidden
Menu_ShowItem(hMenuDefault, false);
Menu_ShowItem(hMenuDelete, false);
@@ -360,20 +360,21 @@ INT_PTR Meta_OnOff(WPARAM wParam, LPARAM lParam)
{
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIM_NAME | CMIM_ICON;
- // just write to db - the rest is handled in the Meta_SettingChanged function
- if (db_get_b(0, META_PROTO, "Enabled", 1)) {
- db_set_b(0, META_PROTO, "Enabled", 0);
- // modify main mi item
+
+ bool bToggled = !db_mc_isEnabled();
+ db_set_b(0, META_PROTO, "Enabled", bToggled);
+ if (bToggled) {
mi.icolibItem = GetIconHandle(I_MENU);
mi.pszName = LPGEN("Toggle MetaContacts On");
}
else {
- db_set_b(0, META_PROTO, "Enabled", 1);
- // modify main mi item
mi.icolibItem = GetIconHandle(I_MENUOFF);
mi.pszName = LPGEN("Toggle MetaContacts Off");
}
Menu_ModifyItem(hMenuOnOff, &mi);
+
+ db_mc_enable(bToggled);
+ Meta_HideMetaContacts(bToggled);
return 0;
}
@@ -442,7 +443,7 @@ void InitMenus()
Meta_HideLinkedContacts();
- if (!options.bEnabled) {
+ if (!db_mc_isEnabled()) {
// modify main menu item
mi.flags = CMIM_NAME | CMIM_ICON;
mi.icolibItem = GetIconHandle(I_MENU);
diff --git a/src/modules/metacontacts/meta_options.cpp b/src/modules/metacontacts/meta_options.cpp
index 382f83d446..1346f0b049 100644
--- a/src/modules/metacontacts/meta_options.cpp
+++ b/src/modules/metacontacts/meta_options.cpp
@@ -160,7 +160,7 @@ int Meta_WriteOptions(MetaOptions *opt)
int Meta_ReadOptions(MetaOptions *opt)
{
- opt->bEnabled = db_get_b(NULL, META_PROTO, "Enabled", true) != 0;
+ db_mc_enable(db_get_b(NULL, META_PROTO, "Enabled", true) != 0);
opt->bSuppressStatus = db_get_b(NULL, META_PROTO, "SuppressStatus", true) != 0;
opt->menu_contact_label = (int)db_get_w(NULL, META_PROTO, "MenuContactLabel", DNT_UID);
opt->menu_function = (int)db_get_w(NULL, META_PROTO, "MenuContactFunction", FT_MENU);
diff --git a/src/modules/metacontacts/meta_services.cpp b/src/modules/metacontacts/meta_services.cpp
index a4e14883dd..556b6999f5 100644
--- a/src/modules/metacontacts/meta_services.cpp
+++ b/src/modules/metacontacts/meta_services.cpp
@@ -314,16 +314,8 @@ int Meta_SettingChanged(WPARAM hContact, LPARAM lParam)
char buffer[512], szId[40];
// the only global options we're interested in
- if (hContact == 0) {
- // hide metacontacts when groups disabled
- if ((!strcmp(dcws->szModule, "CList") && !strcmp(dcws->szSetting, "UseGroups")) ||
- (!strcmp(dcws->szModule, META_PROTO) && !strcmp(dcws->szSetting, "Enabled")))
- {
- options.bEnabled = !options.bEnabled;
- Meta_HideMetaContacts(!options.bEnabled);
- }
+ if (hContact == 0)
return 0;
- }
DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
if (cc == NULL || !cc->IsSub())
@@ -521,7 +513,7 @@ INT_PTR Meta_UserIsTyping(WPARAM hMeta, LPARAM lParam)
int Meta_ContactIsTyping(WPARAM hContact, LPARAM lParam)
{
- if (!options.bEnabled)
+ if (!db_mc_isEnabled())
return 0;
DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
diff --git a/src/modules/metacontacts/metacontacts.h b/src/modules/metacontacts/metacontacts.h
index d550740242..54bbd3eebf 100644
--- a/src/modules/metacontacts/metacontacts.h
+++ b/src/modules/metacontacts/metacontacts.h
@@ -76,7 +76,6 @@ enum CListDisplayNameType {CNNT_NICK = 0, CNNT_DISPLAYNAME = 1};
struct MetaOptions
{
- bool bEnabled;
bool bLockHandle;
bool bSuppressStatus;