From 184155c8aaf1dd0c8bcd498dfd7ba9c512433e73 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 22 Apr 2014 11:51:27 +0000 Subject: db_mc_setDefault/db_mc_setDefaultNum got a flag to update database or not git-svn-id: http://svn.miranda-ng.org/main/trunk@9047 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/mir_core/mc.cpp | 10 ++++++---- src/modules/metacontacts/meta_edit.cpp | 2 +- src/modules/metacontacts/meta_menu.cpp | 4 ++-- src/modules/metacontacts/meta_services.cpp | 4 ++-- src/modules/metacontacts/meta_utils.cpp | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/mir_core/mc.cpp b/src/mir_core/mc.cpp index 90e967fa98..00431a0875 100644 --- a/src/mir_core/mc.cpp +++ b/src/mir_core/mc.cpp @@ -129,7 +129,7 @@ MIR_CORE_DLL(MCONTACT) db_mc_getSub(MCONTACT hMetaContact, int iNum) } //sets the default contact, using the subcontact's handle -MIR_CORE_DLL(int) db_mc_setDefault(MCONTACT hMetaContact, MCONTACT hSub) +MIR_CORE_DLL(int) db_mc_setDefault(MCONTACT hMetaContact, MCONTACT hSub, BOOL bWriteDb) { DBCachedContact *cc = CheckMeta(hMetaContact); if (cc == NULL) @@ -140,14 +140,15 @@ MIR_CORE_DLL(int) db_mc_setDefault(MCONTACT hMetaContact, MCONTACT hSub) return 1; cc->nDefault = contact_number; - currDb->MetaSetDefault(cc); + if (bWriteDb) + currDb->MetaSetDefault(cc); NotifyEventHooks(hEventDefaultChanged, hMetaContact, hSub); return 0; } //sets the default contact, using the subcontact's number -MIR_CORE_DLL(int) db_mc_setDefaultNum(MCONTACT hMetaContact, int iNum) +MIR_CORE_DLL(int) db_mc_setDefaultNum(MCONTACT hMetaContact, int iNum, BOOL bWriteDb) { DBCachedContact *cc = CheckMeta(hMetaContact); if (cc == NULL) @@ -156,7 +157,8 @@ MIR_CORE_DLL(int) db_mc_setDefaultNum(MCONTACT hMetaContact, int iNum) return 1; cc->nDefault = iNum; - currDb->MetaSetDefault(cc); + if (bWriteDb) + currDb->MetaSetDefault(cc); NotifyEventHooks(hEventDefaultChanged, hMetaContact, Meta_GetContactHandle(cc, iNum)); return 0; diff --git a/src/modules/metacontacts/meta_edit.cpp b/src/modules/metacontacts/meta_edit.cpp index d5496b7dd4..cc453d4dde 100644 --- a/src/modules/metacontacts/meta_edit.cpp +++ b/src/modules/metacontacts/meta_edit.cpp @@ -147,7 +147,7 @@ static void ApplyChanges() NotifyEventHooks(hSubcontactsChanged, g_data.hMeta, g_data.hDefaultContact); // set default - db_mc_setDefaultNum(g_data.hMeta, (g_data.hDefaultContact) ? Meta_GetContactNumber(g_data.cc, g_data.hDefaultContact) : 0); + db_mc_setDefaultNum(g_data.hMeta, (g_data.hDefaultContact) ? Meta_GetContactNumber(g_data.cc, g_data.hDefaultContact) : 0, true); // set offline if (g_data.hOfflineContact) diff --git a/src/modules/metacontacts/meta_menu.cpp b/src/modules/metacontacts/meta_menu.cpp index 755ba5084a..bc6338bd10 100644 --- a/src/modules/metacontacts/meta_menu.cpp +++ b/src/modules/metacontacts/meta_menu.cpp @@ -136,7 +136,7 @@ void Meta_RemoveContactNumber(DBCachedContact *ccMeta, int number, bool bUpdateI int iNumber = ccMeta->nDefault-1; if (iNumber < 0) iNumber = 0; - db_mc_setDefaultNum(ccMeta->contactID, iNumber); + db_mc_setDefaultNum(ccMeta->contactID, iNumber, true); } ccMeta->nSubs--; @@ -222,7 +222,7 @@ INT_PTR Meta_Default(WPARAM hSub, LPARAM wParam) { DBCachedContact *cc = currDb->m_cache->GetCachedContact(db_mc_getMeta(hSub)); if (cc && cc->IsMeta()) - db_mc_setDefault(cc->contactID, hSub); + db_mc_setDefault(cc->contactID, hSub, true); return 0; } diff --git a/src/modules/metacontacts/meta_services.cpp b/src/modules/metacontacts/meta_services.cpp index 30c7d6ae0e..fad8195510 100644 --- a/src/modules/metacontacts/meta_services.cpp +++ b/src/modules/metacontacts/meta_services.cpp @@ -592,7 +592,7 @@ int Meta_SrmmIconClicked(WPARAM hMeta, LPARAM lParam) UINT res = TrackPopupMenu(hMenu, TPM_NONOTIFY | TPM_RETURNCMD | TPM_BOTTOMALIGN | TPM_LEFTALIGN, sicd->clickLocation.x, sicd->clickLocation.y, 0, cli.hwndContactTree, NULL); if (res > 0) - db_mc_setDefault(cc->contactID, Meta_GetContactHandle(cc, res - 1)); + db_mc_setDefault(cc->contactID, Meta_GetContactHandle(cc, res-1), true); return 0; } @@ -686,7 +686,7 @@ INT_PTR Meta_ContactMenuFunc(WPARAM hMeta, LPARAM lParam) INT_PTR caps = CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0); if ((caps & PF1_IMSEND) || (caps & PF1_CHAT)) { // set default contact for sending/status and open message window - db_mc_setDefaultNum(hMeta, lParam); + db_mc_setDefaultNum(hMeta, lParam, false); CallService(MS_MSG_SENDMESSAGET, hMeta, 0); } else // protocol does not support messaging - simulate double click diff --git a/src/modules/metacontacts/meta_utils.cpp b/src/modules/metacontacts/meta_utils.cpp index 32986361e8..a0f1a61559 100644 --- a/src/modules/metacontacts/meta_utils.cpp +++ b/src/modules/metacontacts/meta_utils.cpp @@ -179,7 +179,7 @@ BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default) ccSub->parentID = hMeta; if (set_as_default) - db_mc_setDefaultNum(hMeta, ccDest->nSubs-1); + db_mc_setDefaultNum(hMeta, ccDest->nSubs-1, true); // set nick to most online contact that can message MCONTACT most_online = Meta_GetMostOnline(ccDest); -- cgit v1.2.3