diff options
author | George Hazan <ghazan@miranda.im> | 2019-09-28 15:12:28 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-09-28 15:12:28 +0300 |
commit | f74ae187d68f851c11b11d273c56bf31f03d87d5 (patch) | |
tree | 900a51913cee60a6f1282bdd5e173ee4ac9282ba /src | |
parent | ead0b73e488d16914976487ea02df3882303a8bb (diff) |
metacontacts:
- fixes #2083 (newly added sub-contact isn't hidden);
- old unused option bSuppressStatus is finally wiped with all related code
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/meta_addto.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/meta_api.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/meta_menu.cpp | 17 | ||||
-rw-r--r-- | src/mir_app/src/meta_options.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/meta_services.cpp | 7 | ||||
-rw-r--r-- | src/mir_app/src/meta_utils.cpp | 33 | ||||
-rw-r--r-- | src/mir_app/src/metacontacts.h | 36 |
7 files changed, 28 insertions, 75 deletions
diff --git a/src/mir_app/src/meta_addto.cpp b/src/mir_app/src/meta_addto.cpp index e59b0018ce..b842c3bdcb 100644 --- a/src/mir_app/src/meta_addto.cpp +++ b/src/mir_app/src/meta_addto.cpp @@ -184,7 +184,7 @@ bool CMetaSelectDlg::OnApply() }
MCONTACT hMeta = (MCONTACT)m_metaList.GetItemData(item);
- if (!Meta_Assign(m_hContact, hMeta, FALSE))
+ if (!Meta_Assign(m_hContact, hMeta, false))
MessageBox(GetHwnd(), TranslateT("Assignment to the metacontact failed."), TranslateT("Assignment failure"), MB_ICONERROR);
return true;
}
diff --git a/src/mir_app/src/meta_api.cpp b/src/mir_app/src/meta_api.cpp index ddb6411cec..c5141e68f7 100644 --- a/src/mir_app/src/meta_api.cpp +++ b/src/mir_app/src/meta_api.cpp @@ -129,7 +129,7 @@ MIR_APP_DLL(MCONTACT) db_mc_convertToMeta(MCONTACT hContact) // adds an existing contact to a metacontact
MIR_APP_DLL(int) db_mc_addToMeta(MCONTACT hSub, MCONTACT hMetaContact)
{
- return Meta_Assign(hSub, hMetaContact, FALSE);
+ return Meta_Assign(hSub, hMetaContact, false);
}
// removes a contact from a metacontact
diff --git a/src/mir_app/src/meta_menu.cpp b/src/mir_app/src/meta_menu.cpp index dba5fe7d7c..ef80685051 100644 --- a/src/mir_app/src/meta_menu.cpp +++ b/src/mir_app/src/meta_menu.cpp @@ -71,7 +71,7 @@ INT_PTR Meta_Convert(WPARAM wParam, LPARAM) Clist_SetGroup(hMetaContact, tszGroup);
// Assign the contact to the MetaContact just created (and make default).
- if (!Meta_Assign(wParam, hMetaContact, TRUE)) {
+ if (!Meta_Assign(wParam, hMetaContact, true)) {
MessageBox(nullptr, TranslateT("There was a problem in assigning the contact to the metacontact"), TranslateT("Error"), MB_ICONEXCLAMATION);
db_delete_contact(hMetaContact);
return 0;
@@ -94,16 +94,10 @@ void Meta_RemoveContactNumber(DBCachedContact *ccMeta, int number, bool bUpdateI // make sure this contact thinks it's part of this metacontact
DBCachedContact *ccSub = currDb->getCache()->GetCachedContact(Meta_GetContactHandle(ccMeta, number));
- if (ccSub != nullptr) {
- if (ccSub->parentID == ccMeta->contactID) {
+ if (ccSub != nullptr)
+ if (ccSub->parentID == ccMeta->contactID)
Contact_Hide(ccSub->contactID, false);
- // stop ignoring, if we were
- if (g_metaOptions.bSuppressStatus)
- Ignore_Allow(ccSub->contactID, IGNOREEVENT_USERONLINE);
- }
- }
-
// each contact from 'number' upwards will be moved down one
// and the last one will be deleted
for (int i = number+1; i < ccMeta->nSubs; i++)
@@ -434,8 +428,5 @@ void InitMenus() Menu_ModifyItem(hMenuOnOff, LPGENW("Toggle metacontacts on"), Meta_GetIconHandle(I_MENUOFF));
Meta_HideMetaContacts(true);
}
- else {
- Meta_SuppressStatus(g_metaOptions.bSuppressStatus);
- Meta_HideMetaContacts(false);
- }
+ else Meta_HideMetaContacts(false);
}
diff --git a/src/mir_app/src/meta_options.cpp b/src/mir_app/src/meta_options.cpp index f7d6403047..d0d8c5bd5b 100644 --- a/src/mir_app/src/meta_options.cpp +++ b/src/mir_app/src/meta_options.cpp @@ -29,7 +29,6 @@ MetaOptions g_metaOptions; int Meta_WriteOptions()
{
db_set_b(0, META_PROTO, "LockHandle", g_metaOptions.bLockHandle);
- db_set_b(0, META_PROTO, "SuppressStatus", g_metaOptions.bSuppressStatus);
db_set_w(0, META_PROTO, "MenuContactLabel", (WORD)g_metaOptions.menu_contact_label);
db_set_w(0, META_PROTO, "MenuContactFunction", (WORD)g_metaOptions.menu_function);
db_set_w(0, META_PROTO, "CListContactName", (WORD)g_metaOptions.clist_contact_name);
@@ -40,7 +39,6 @@ int Meta_WriteOptions() int Meta_ReadOptions()
{
db_mc_enable(db_get_b(0, META_PROTO, "Enabled", true) != 0);
- g_metaOptions.bSuppressStatus = db_get_b(0, META_PROTO, "SuppressStatus", true) != 0;
g_metaOptions.menu_contact_label = (int)db_get_w(0, META_PROTO, "MenuContactLabel", DNT_UID);
g_metaOptions.menu_function = (int)db_get_w(0, META_PROTO, "MenuContactFunction", FT_MENU);
g_metaOptions.clist_contact_name = (int)db_get_w(0, META_PROTO, "CListContactName", CNNT_DISPLAYNAME);
@@ -73,7 +71,6 @@ public: bool OnInitDialog() override
{
m_btnLock.SetState(g_metaOptions.bLockHandle);
- m_btnCheck.SetState(g_metaOptions.bSuppressStatus);
if (g_metaOptions.menu_contact_label == DNT_UID)
m_btnUid.SetState(true);
@@ -96,7 +93,6 @@ public: bool OnApply() override
{
g_metaOptions.bLockHandle = m_btnLock.GetState() != 0;
- g_metaOptions.bSuppressStatus = m_btnCheck.GetState() != 0;
if (m_btnUid.GetState()) g_metaOptions.menu_contact_label = DNT_UID;
else if (m_btnDid.GetState()) g_metaOptions.menu_contact_label = DNT_DID;
@@ -109,8 +105,6 @@ public: else if (m_btnName.GetState()) g_metaOptions.clist_contact_name = CNNT_DISPLAYNAME;
Meta_WriteOptions();
-
- Meta_SuppressStatus(g_metaOptions.bSuppressStatus);
Meta_SetAllNicks();
return true;
}
diff --git a/src/mir_app/src/meta_services.cpp b/src/mir_app/src/meta_services.cpp index 769cbdabca..875342762c 100644 --- a/src/mir_app/src/meta_services.cpp +++ b/src/mir_app/src/meta_services.cpp @@ -473,13 +473,9 @@ int Meta_ContactDeleted(WPARAM hContact, LPARAM) NotifyEventHooks(hSubcontactsChanged, hContact, 0);
// remove & restore all subcontacts
- for (int i = 0; i < cc->nSubs; i++) {
+ for (int i = 0; i < cc->nSubs; i++)
currDb->MetaDetouchSub(cc, i);
- // stop ignoring, if we were
- if (g_metaOptions.bSuppressStatus)
- Ignore_Allow(cc->pSubs[i], IGNOREEVENT_USERONLINE);
- }
return 0;
}
@@ -804,7 +800,6 @@ int Meta_CallMostOnline(WPARAM hContact, LPARAM) int Meta_PreShutdown(WPARAM, LPARAM)
{
Meta_SetStatus(ID_STATUS_OFFLINE, 0);
- Meta_SuppressStatus(false);
if (setStatusTimerId)
KillTimer(nullptr, setStatusTimerId);
return 0;
diff --git a/src/mir_app/src/meta_utils.cpp b/src/mir_app/src/meta_utils.cpp index 9bae3558e5..907255665b 100644 --- a/src/mir_app/src/meta_utils.cpp +++ b/src/mir_app/src/meta_utils.cpp @@ -58,7 +58,7 @@ int Meta_SetNick(char *szProto) * @return TRUE on success, FALSE otherwise
*/
-BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default)
+BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, bool set_as_default)
{
DBCachedContact *ccDest = CheckMeta(hMeta), *ccSub = currDb->getCache()->GetCachedContact(hSub);
if (ccDest == nullptr || ccSub == nullptr)
@@ -180,9 +180,8 @@ BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default) // merge sub's events to the meta-history
currDb->MetaMergeHistory(ccDest, ccSub);
- // Ignore status if the option is on
- if (g_metaOptions.bSuppressStatus)
- Ignore_Ignore(hSub, IGNOREEVENT_USERONLINE);
+ // hide sub finally
+ Contact_Hide(ccSub->contactID);
NotifyEventHooks(hSubcontactsChanged, hMeta, 0);
return TRUE;
@@ -372,9 +371,6 @@ int Meta_HideLinkedContacts(void) }
}
- if (g_metaOptions.bSuppressStatus)
- Ignore_Ignore(hContact, IGNOREEVENT_USERONLINE);
-
MCONTACT hMostOnline = Meta_GetMostOnline(ccMeta); // set nick
Meta_CopyContactNick(ccMeta, hMostOnline);
Meta_FixStatus(ccMeta);
@@ -385,19 +381,11 @@ int Meta_HideLinkedContacts(void) int Meta_HideMetaContacts(bool bHide)
{
- // set status suppression
- bool bSuppress = bHide ? FALSE : g_metaOptions.bSuppressStatus;
-
for (auto &hContact : Contacts()) {
bool bSet;
DBCachedContact *cc = currDb->getCache()->GetCachedContact(hContact);
- if (cc->IsSub()) { // show on hide, reverse flag
+ if (cc->IsSub()) // show on hide, reverse flag
bSet = !bHide;
- if (bSuppress)
- Ignore_Ignore(hContact, IGNOREEVENT_USERONLINE);
- else
- Ignore_Allow(hContact, IGNOREEVENT_USERONLINE);
- }
else if (cc->IsMeta())
bSet = bHide;
else
@@ -415,19 +403,6 @@ int Meta_HideMetaContacts(bool bHide) return 0;
}
-int Meta_SuppressStatus(bool bSuppress)
-{
- for (auto &hContact : Contacts())
- if (db_mc_isSub(hContact)) {
- if (bSuppress)
- Ignore_Ignore(hContact, IGNOREEVENT_USERONLINE);
- else
- Ignore_Allow(hContact, IGNOREEVENT_USERONLINE);
- }
-
- return 0;
-}
-
int Meta_CopyContactNick(DBCachedContact *ccMeta, MCONTACT hContact)
{
if (g_metaOptions.bLockHandle)
diff --git a/src/mir_app/src/metacontacts.h b/src/mir_app/src/metacontacts.h index ae12ec51b7..de31ae63d7 100644 --- a/src/mir_app/src/metacontacts.h +++ b/src/mir_app/src/metacontacts.h @@ -38,21 +38,20 @@ struct MetaSrmmData };
extern OBJLIST<MetaSrmmData> arMetaWindows;
-INT_PTR Meta_Convert(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_AddTo(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_Edit(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_Delete(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_Default(WPARAM wParam,LPARAM lParam);
+INT_PTR Meta_Convert(WPARAM wParam, LPARAM lParam);
+INT_PTR Meta_AddTo(WPARAM wParam, LPARAM lParam);
+INT_PTR Meta_Edit(WPARAM wParam, LPARAM lParam);
+INT_PTR Meta_Delete(WPARAM wParam, LPARAM lParam);
+INT_PTR Meta_Default(WPARAM wParam, LPARAM lParam);
INT_PTR Meta_OnOff(WPARAM wParam, LPARAM lParam);
-int Meta_ModifyMenu(WPARAM wParam,LPARAM lParam);
-BOOL Meta_Assign(MCONTACT src, MCONTACT dest, BOOL set_as_default);
+int Meta_ModifyMenu(WPARAM wParam, LPARAM lParam);
+BOOL Meta_Assign(MCONTACT src, MCONTACT dest, bool set_as_default);
void Meta_RemoveContactNumber(DBCachedContact *cc, int number, bool bUpdateInfo, bool bDeleteSub = false);
int Meta_SetNick(char *proto);
int Meta_HideLinkedContacts(void);
int Meta_GetContactNumber(DBCachedContact *cc, MCONTACT hContact);
int Meta_HideMetaContacts(bool hide);
-int Meta_SuppressStatus(bool suppress);
int Meta_CopyContactNick(DBCachedContact *cc, MCONTACT hContact);
int Meta_SetAllNicks();
int Meta_SwapContacts(DBCachedContact *cc, int contact_number1, int contact_number2);
@@ -67,25 +66,24 @@ DBCachedContact* CheckMeta(MCONTACT hMeta); // function to copy history from one contact to another - courtesy JdGordon with mods (thx)
void Meta_FixStatus(DBCachedContact *ccMeta);
-INT_PTR Meta_GetCaps(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_GetName(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_LoadIcon(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_SetStatus(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_GetStatus(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_SendMessage(WPARAM wParam,LPARAM lParam);
+INT_PTR Meta_GetCaps(WPARAM wParam, LPARAM lParam);
+INT_PTR Meta_GetName(WPARAM wParam, LPARAM lParam);
+INT_PTR Meta_LoadIcon(WPARAM wParam, LPARAM lParam);
+INT_PTR Meta_SetStatus(WPARAM wParam, LPARAM lParam);
+INT_PTR Meta_GetStatus(WPARAM wParam, LPARAM lParam);
+INT_PTR Meta_SendMessage(WPARAM wParam, LPARAM lParam);
INT_PTR Meta_ContactMenuFunc(WPARAM wParam, LPARAM lParam);
void Meta_InitServices();
void Meta_CloseHandles();
-enum MenuDisplayNameType {DNT_UID = 0, DNT_DID = 1};
-enum MenuFunctionType {FT_MSG = 0, FT_MENU = 1, FT_INFO = 2};
-enum CListDisplayNameType {CNNT_NICK = 0, CNNT_DISPLAYNAME = 1};
+enum MenuDisplayNameType { DNT_UID = 0, DNT_DID = 1 };
+enum MenuFunctionType { FT_MSG = 0, FT_MENU = 1, FT_INFO = 2 };
+enum CListDisplayNameType { CNNT_NICK = 0, CNNT_DISPLAYNAME = 1 };
struct MetaOptions
{
bool bLockHandle;
- bool bSuppressStatus;
int menu_contact_label;
int menu_function;
@@ -100,7 +98,7 @@ int Meta_ReadOptions(); /////////////////////////////////////////////////////////////////////////////////////////
-typedef enum {I_MENUOFF, I_MENU, I_CONVERT, I_ADD, I_EDIT, I_SETDEFAULT, I_REMOVE} IconIndex;
+typedef enum { I_MENUOFF, I_MENU, I_CONVERT, I_ADD, I_EDIT, I_SETDEFAULT, I_REMOVE } IconIndex;
HICON Meta_LoadIconEx(IconIndex i, bool big = false);
HANDLE Meta_GetIconHandle(IconIndex i);
|