diff options
author | George Hazan <george.hazan@gmail.com> | 2014-03-09 18:03:06 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-03-09 18:03:06 +0000 |
commit | 4613ce7f80f2a5d7cebad04bfcdbf01f26980679 (patch) | |
tree | db1249976a048e6bb854867c8d88dd29fe3c3149 | |
parent | 535b7733c38c9e4c75a8ff73f231c8b807194124 (diff) |
more correct default sub assignment
git-svn-id: http://svn.miranda-ng.org/main/trunk@8515 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/Db3x_mmap/src/dbevents.cpp | 17 | ||||
-rw-r--r-- | plugins/TabSRMM/src/globals.cpp | 1 | ||||
-rw-r--r-- | src/modules/metacontacts/meta_menu.cpp | 39 |
3 files changed, 24 insertions, 33 deletions
diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp index 704e91f78e..393d6b69e0 100644 --- a/plugins/Db3x_mmap/src/dbevents.cpp +++ b/plugins/Db3x_mmap/src/dbevents.cpp @@ -25,15 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static HANDLE hEventDeletedEvent, hEventAddedEvent, hEventFilterAddedEvent;
-static int IndexOf(DBCachedContact *cc, MCONTACT hSub)
-{
- for (int i = 0; i < cc->nSubs; i++)
- if (cc->pSubs[i] == hSub)
- return i;
-
- return -1;
-}
-
STDMETHODIMP_(LONG) CDb3Mmap::GetEventCount(MCONTACT contactID)
{
mir_cslock lck(m_csDbAccess);
@@ -61,11 +52,9 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) return NULL;
if (cc->IsSub()) {
- if (cc = m_cache->GetCachedContact(cc->parentID)) {
- // set default sub to the event's source
- cc->nDefault = IndexOf(cc, contactID);
- contactID = cc->contactID; // and add an event to a metahistory
- }
+ // set default sub to the event's source
+ CallService(MS_MC_SETDEFAULTCONTACT, cc->parentID, contactID);
+ contactID = cc->parentID; // and add an event to a metahistory
}
}
diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index 8040813d7c..891042ecde 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -372,6 +372,7 @@ int CGlobals::ModulesLoaded(WPARAM wParam, LPARAM lParam) HookEvent(ME_FONT_RELOAD, ::FontServiceFontsChanged);
HookEvent(ME_TTB_MODULELOADED, TopToolbarLoaded);
+ HookEvent(ME_MC_DEFAULTTCHANGED, MetaContactEvent);
HookEvent(ME_MC_SUBCONTACTSCHANGED, MetaContactEvent);
HookEvent(ME_MC_FORCESEND, MetaContactEvent);
HookEvent(ME_MC_UNFORCESEND, MetaContactEvent);
diff --git a/src/modules/metacontacts/meta_menu.cpp b/src/modules/metacontacts/meta_menu.cpp index b14e5b0c08..cd71119ba5 100644 --- a/src/modules/metacontacts/meta_menu.cpp +++ b/src/modules/metacontacts/meta_menu.cpp @@ -52,32 +52,33 @@ INT_PTR Meta_Convert(WPARAM wParam, LPARAM lParam) // Create a new metacontact
MCONTACT hMetaContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
- if (hMetaContact) {
- DBCachedContact *cc = currDb->m_cache->GetCachedContact(hMetaContact);
- if (cc == NULL)
- return 0;
+ if (hMetaContact == NULL)
+ return NULL;
- db_set_dw(hMetaContact, META_PROTO, "NumContacts", 0);
- cc->nSubs = 0;
+ DBCachedContact *cc = currDb->m_cache->GetCachedContact(hMetaContact);
+ if (cc == NULL)
+ return 0;
- // Add the MetaContact protocol to the new meta contact
- CallService(MS_PROTO_ADDTOCONTACT, hMetaContact, (LPARAM)META_PROTO);
+ db_set_dw(hMetaContact, META_PROTO, "NumContacts", 0);
+ cc->nSubs = 0;
- if (tszGroup)
- db_set_ts(hMetaContact, "CList", "Group", tszGroup);
+ // Add the MetaContact protocol to the new meta contact
+ CallService(MS_PROTO_ADDTOCONTACT, hMetaContact, (LPARAM)META_PROTO);
- // Assign the contact to the MetaContact just created (and make default).
- if (!Meta_Assign(wParam, hMetaContact, TRUE)) {
- MessageBox(0, TranslateT("There was a problem in assigning the contact to the MetaContact"), TranslateT("Error"), MB_ICONEXCLAMATION);
- CallService(MS_DB_CONTACT_DELETE, hMetaContact, 0);
- return 0;
- }
+ if (tszGroup)
+ db_set_ts(hMetaContact, "CList", "Group", tszGroup);
- // hide the contact if clist groups disabled (shouldn't create one anyway since menus disabled)
- if (!options.bEnabled)
- db_set_b(hMetaContact, "CList", "Hidden", 1);
+ // Assign the contact to the MetaContact just created (and make default).
+ if (!Meta_Assign(wParam, hMetaContact, TRUE)) {
+ MessageBox(0, TranslateT("There was a problem in assigning the contact to the MetaContact"), TranslateT("Error"), MB_ICONEXCLAMATION);
+ CallService(MS_DB_CONTACT_DELETE, hMetaContact, 0);
+ return 0;
}
+ // hide the contact if clist groups disabled (shouldn't create one anyway since menus disabled)
+ if (!options.bEnabled)
+ db_set_b(hMetaContact, "CList", "Hidden", 1);
+
return hMetaContact;
}
|