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 --- bin10/lib/mir_core.lib | Bin 59270 -> 59280 bytes bin10/lib/mir_core64.lib | Bin 54254 -> 54254 bytes bin12/lib/mir_core.lib | Bin 59270 -> 59280 bytes bin12/lib/mir_core64.lib | Bin 54254 -> 54254 bytes include/delphi/m_metacontacts.inc | 4 ++-- include/m_metacontacts.h | 4 ++-- plugins/Clist_modern/src/modern_clc.cpp | 2 +- plugins/Db3x_mmap/src/dbevents.cpp | 2 +- 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 +- 13 files changed, 18 insertions(+), 16 deletions(-) diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib index c045bff939..beee486311 100644 Binary files a/bin10/lib/mir_core.lib and b/bin10/lib/mir_core.lib differ diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib index 9194957fa7..1036692201 100644 Binary files a/bin10/lib/mir_core64.lib and b/bin10/lib/mir_core64.lib differ diff --git a/bin12/lib/mir_core.lib b/bin12/lib/mir_core.lib index cd6a4cb0e3..a6d4588399 100644 Binary files a/bin12/lib/mir_core.lib and b/bin12/lib/mir_core.lib differ diff --git a/bin12/lib/mir_core64.lib b/bin12/lib/mir_core64.lib index 9194957fa7..1036692201 100644 Binary files a/bin12/lib/mir_core64.lib and b/bin12/lib/mir_core64.lib differ diff --git a/include/delphi/m_metacontacts.inc b/include/delphi/m_metacontacts.inc index fb0ba596ab..ece131c1a6 100644 --- a/include/delphi/m_metacontacts.inc +++ b/include/delphi/m_metacontacts.inc @@ -103,10 +103,10 @@ function db_mc_getSubCount(hContact:TMCONTACT):int; stdcall; external CoreDLL name 'db_mc_getSubCount'; { sets the default contact, using the subcontact's handle } -function db_mc_setDefault(hContact,hSub:TMCONTACT):int; stdcall; +function db_mc_setDefault(hContact,hSub:TMCONTACT; bWriteDb:bool):int; stdcall; external CoreDLL name 'db_mc_setDefault'; { sets the default contact, using the subcontact's number } -function db_mc_setDefaultNum(hContact:TMCONTACT; idx:int):int; stdcall; +function db_mc_setDefaultNum(hContact:TMCONTACT; idx:int; bWriteDb:bool):int; stdcall; external CoreDLL name 'db_mc_setDefaultNum'; {$ENDIF} diff --git a/include/m_metacontacts.h b/include/m_metacontacts.h index 889d3ac188..9be9c6819a 100644 --- a/include/m_metacontacts.h +++ b/include/m_metacontacts.h @@ -96,10 +96,10 @@ MIR_CORE_DLL(MCONTACT) db_mc_getMeta(MCONTACT hSubContact); 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); //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); #if defined(__cplusplus) } diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index bd653fdc4a..77728deb54 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -1283,7 +1283,7 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be default?"), contSour->szText); int res = MessageBox(hwnd, Wording, TranslateT("Set default contact"), MB_OKCANCEL | MB_ICONQUESTION); if (res == 1) - db_mc_setDefault(contDest->hContact, hsour); + db_mc_setDefault(contDest->hContact, hsour, true); } else { MCONTACT hcontact = contSour->hContact; diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp index 1cdc3bd191..d5a608ea32 100644 --- a/plugins/Db3x_mmap/src/dbevents.cpp +++ b/plugins/Db3x_mmap/src/dbevents.cpp @@ -56,7 +56,7 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) if (cc->IsSub()) { ccSub = cc; // set default sub to the event's source - db_mc_setDefault(cc->parentID, contactID); + db_mc_setDefault(cc->parentID, contactID, false); contactID = cc->parentID; // and add an event to a metahistory if (db_mc_isEnabled()) contactNotifyID = contactID; 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