summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-03-09 21:50:49 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-03-09 21:50:49 +0000
commit0173277372e2962b8f5703a0ebad7892dda15e6c (patch)
treed1ff4bbecbc00f8d77b9a71c71579de53246303c
parent61dfdec9a37cc06a6ee624aaaf03df41f821c1c6 (diff)
end of the old MC API
git-svn-id: http://svn.miranda-ng.org/main/trunk@8534 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--bin10/lib/mir_core.libbin56468 -> 57836 bytes
-rw-r--r--bin10/lib/mir_core64.libbin51652 -> 52906 bytes
-rw-r--r--bin12/lib/mir_core.libbin56468 -> 57836 bytes
-rw-r--r--bin12/lib/mir_core64.libbin51652 -> 52906 bytes
-rw-r--r--include/delphi/m_metacontacts.inc78
-rw-r--r--include/m_metacontacts.h58
-rw-r--r--plugins/Clist_modern/src/modern_clc.cpp5
-rw-r--r--plugins/Clist_modern/src/modern_clcitems.cpp4
-rw-r--r--plugins/Clist_modern/src/modern_clcutils.cpp3
-rw-r--r--plugins/Clist_mw/src/clcitems.cpp4
-rw-r--r--plugins/Db3x_mmap/src/dbevents.cpp2
-rw-r--r--plugins/FingerprintNG/src/fingerprint.cpp2
-rw-r--r--plugins/HistoryPlusPlus/EmptyHistoryForm.pas20
-rw-r--r--plugins/HistoryPlusPlus/GlobalSearch.pas4
-rw-r--r--plugins/HistoryPlusPlus/HistoryForm.pas12
-rw-r--r--plugins/HistoryPlusPlus/hpp_contacts.pas45
-rw-r--r--plugins/HistoryPlusPlus/hpp_externalgrid.pas8
-rw-r--r--plugins/HistoryStats/src/dlgoption_subinput.cpp12
-rw-r--r--plugins/HistoryStats/src/mirandahistory.cpp6
-rw-r--r--plugins/HistoryStats/src/mu_common.cpp22
-rw-r--r--plugins/HistoryStats/src/mu_common.h11
-rw-r--r--plugins/MenuItemEx/src/main.cpp9
-rw-r--r--plugins/MirFox/src/MirandaUtils.cpp2
-rw-r--r--plugins/MirandaG15/src/CContactList.cpp17
-rwxr-xr-xplugins/New_GPG/src/main.cpp8
-rw-r--r--plugins/New_GPG/src/metacontacts.cpp16
-rw-r--r--plugins/New_GPG/src/metacontacts.h4
-rwxr-xr-xplugins/New_GPG/src/options.cpp36
-rwxr-xr-xplugins/New_GPG/src/utilities.cpp4
-rw-r--r--plugins/Popup/src/popup_wnd2.cpp2
-rw-r--r--plugins/SecureIM/src/crypt_metacontacts.cpp6
-rw-r--r--plugins/TabSRMM/src/container.cpp4
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp2
-rw-r--r--plugins/TipperYM/src/subst.cpp6
-rw-r--r--plugins/UserInfoEx/src/classMAnnivDate.cpp14
-rw-r--r--plugins/UserInfoEx/src/dlg_propsheet.cpp8
-rw-r--r--plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp8
-rw-r--r--plugins/UserInfoEx/src/mir_db.cpp46
-rw-r--r--plugins/UserInfoEx/src/mir_db.h8
-rw-r--r--plugins/UserInfoEx/src/psp_profile.cpp13
-rw-r--r--plugins/UserInfoEx/src/svc_reminder.cpp2
-rw-r--r--plugins/Variables/src/parse_metacontacts.cpp2
-rw-r--r--protocols/Gadu-Gadu/src/groupchat.cpp4
-rw-r--r--src/core/modules.cpp9
-rw-r--r--src/mir_core/db.cpp30
-rw-r--r--src/mir_core/mc.cpp148
-rw-r--r--src/mir_core/mir_core.def6
-rw-r--r--src/mir_core/mir_core_10.vcxproj1
-rw-r--r--src/mir_core/mir_core_10.vcxproj.filters3
-rw-r--r--src/mir_core/mir_core_12.vcxproj1
-rw-r--r--src/mir_core/mir_core_12.vcxproj.filters3
-rw-r--r--src/mir_core/miranda.cpp2
-rw-r--r--src/mir_core/miranda.h1
-rw-r--r--src/miranda32_10.vcxproj1
-rw-r--r--src/miranda32_10.vcxproj.filters3
-rw-r--r--src/modules/metacontacts/meta_api.cpp98
-rw-r--r--src/modules/metacontacts/meta_edit.cpp4
-rw-r--r--src/modules/metacontacts/meta_menu.cpp17
-rw-r--r--src/modules/metacontacts/meta_services.cpp7
-rw-r--r--src/modules/metacontacts/meta_utils.cpp7
-rw-r--r--src/modules/metacontacts/metacontacts.h2
61 files changed, 378 insertions, 482 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib
index 3b78ffd620..b71d6698e8 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 612fde0e76..224b1a9f9b 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 c1953c4d82..65dafe1ba7 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 2e3e6d2bea..be5ed5f863 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 4a82b0f129..6807a366f9 100644
--- a/include/delphi/m_metacontacts.inc
+++ b/include/delphi/m_metacontacts.inc
@@ -1,19 +1,19 @@
{
- Miranda IM: the free IM client for Microsoft Windows
-
+ Miranda IM: the free IM client for Microsoft Windows
+
Copyright © 2004 Universite Louis PASTEUR, STRASBOURG.
Copyright © 2004 Scott Ellis (www.scottellis.com.au mail@scottellis.com.au)
-
+
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -26,48 +26,12 @@ const
META_PROTO = 'MetaContacts';
const
- { gets the handle for the default contact
- wParam=(HANDLE)hMetaContact
- lParam=0
- returns a handle to the default contact, or null on failure }
- MS_MC_GETDEFAULTCONTACT = 'MetaContacts/GetDefault';
-
- { gets the contact number for the default contact
- wParam=(HANDLE)hMetaContact
- lParam=0
- returns a dword contact number, or -1 on failure }
- MS_MC_GETDEFAULTCONTACTNUM = 'MetaContacts/GetDefaultNum';
-
{ gets the handle for the 'most online' contact
wParam=(HANDLE)hMetaContact
lParam=0
returns a handle to the 'most online' contact }
MS_MC_GETMOSTONLINECONTACT = 'MetaContacts/GetMostOnline';
- { gets the number of subcontacts for a metacontact
- wParam=(HANDLE)hMetaContact
- lParam=0
- returns a dword representing the number of subcontacts for the given metacontact }
- MS_MC_GETNUMCONTACTS = 'MetaContacts/GetNumContacts';
-
- { gets the handle of a subcontact, using the subcontact's number
- wParam=(HANDLE)hMetaContact
- lParam=(dword)contact number
- returns a handle to the specified subcontact }
- MS_MC_GETSUBCONTACT = 'MetaContacts/GetSubContact';
-
- { sets the default contact, using the subcontact's contact number
- wParam=(HANDLE)hMetaContact
- lParam=(dword)contact number
- returns 0 on success }
- MS_MC_SETDEFAULTCONTACTNUM = 'MetaContacts/SetDefault';
-
- { sets the default contact, using the subcontact's handle
- wParam=(HANDLE)hMetaContact
- lParam=(HANDLE)hSubcontact
- returns 0 on success }
- MS_MC_SETDEFAULTCONTACT = 'MetaContacts/SetDefaultByHandle';
-
{ forces the metacontact to send using a specific subcontact, using the subcontact's contact number
wParam=(HANDLE)hMetaContact
lParam=(dword)contact number
@@ -146,19 +110,39 @@ const
/////////////////////////////////////////////////////////////////////////////////////////
// binary interface to MC
-{ returns true if a contact is a metacontact or false otherwise
-}
+{ 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';
-{ returns true if a contact is a subcontact or false otherwise
-}
+{ returns true if a contact is a subcontact or false otherwise }
function db_mc_isSub(hContact:TMCONTACT):int; stdcall;
external CoreDLL name 'db_mc_isSub';
-{ returns a meta contact for a subcontact or 0 otherwise
-}
+{ gets the handle for the default contact or 0 on error }
+function db_mc_getDefault(hContact:TMCONTACT):TMCONTACT; stdcall;
+ external CoreDLL name 'db_mc_getDefault';
+
+{ gets the contact number for the default contact or -1 on error }
+function db_mc_getDefaultNum(hContact:TMCONTACT):int; stdcall;
+ external CoreDLL name 'db_mc_getDefaultNum';
+
+{ returns a meta contact for a subcontact or 0 otherwise }
function db_mc_getMeta(hContact:TMCONTACT):TMCONTACT; stdcall;
external CoreDLL name 'db_mc_getMeta';
+{ returns a subcontact with the given index or 0 }
+function db_mc_getSub(hContact:TMCONTACT; idx:int):TMCONTACT; stdcall;
+ external CoreDLL name 'db_mc_getSub';
+
+{ gets the number of subcontacts for a metacontact or -1 on error }
+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;
+ 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;
+ external CoreDLL name 'db_mc_setDefaultNum';
{$ENDIF}
diff --git a/include/m_metacontacts.h b/include/m_metacontacts.h
index 09921af590..8eb7849814 100644
--- a/include/m_metacontacts.h
+++ b/include/m_metacontacts.h
@@ -29,48 +29,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// standard module for all mc-related information
#define META_PROTO "MetaContacts"
-//gets the handle for the default contact
-//wParam=(HANDLE)hMetaContact
-//lParam=0
-//returns a handle to the default contact, or null on failure
-#define MS_MC_GETDEFAULTCONTACT "MetaContacts/GetDefault"
-
-//gets the contact number for the default contact
-//wParam=(HANDLE)hMetaContact
-//lParam=0
-//returns a DWORD contact number, or -1 on failure
-#define MS_MC_GETDEFAULTCONTACTNUM "MetaContacts/GetDefaultNum"
-
//gets the handle for the 'most online' contact
//wParam=(HANDLE)hMetaContact
//lParam=0
//returns a handle to the 'most online' contact
#define MS_MC_GETMOSTONLINECONTACT "MetaContacts/GetMostOnline"
-//gets the number of subcontacts for a metacontact
-//wParam=(HANDLE)hMetaContact
-//lParam=0
-//returns a DWORD representing the number of subcontacts for the given metacontact
-#define MS_MC_GETNUMCONTACTS "MetaContacts/GetNumContacts"
-
-//gets the handle of a subcontact, using the subcontact's number
-//wParam=(HANDLE)hMetaContact
-//lParam=(DWORD)contact number
-//returns a handle to the specified subcontact
-#define MS_MC_GETSUBCONTACT "MetaContacts/GetSubContact"
-
-//sets the default contact, using the subcontact's contact number
-//wParam=(HANDLE)hMetaContact
-//lParam=(DWORD)contact number
-//returns 0 on success
-#define MS_MC_SETDEFAULTCONTACTNUM "MetaContacts/SetDefault"
-
-//sets the default contact, using the subcontact's handle
-//wParam=(HANDLE)hMetaContact
-//lParam=(HANDLE)hSubcontact
-//returns 0 on success
-#define MS_MC_SETDEFAULTCONTACT "MetaContacts/SetDefaultByHandle"
-
//forces the metacontact to send using a specific subcontact, using the subcontact's contact number
//wParam=(HANDLE)hMetaContact
//lParam=(DWORD)contact number
@@ -154,14 +118,32 @@ extern "C"
#endif
// checks whether a contact is a metacontact
-MIR_CORE_DLL(int) db_mc_isMeta(MCONTACT hContact);
+MIR_CORE_DLL(int) db_mc_isMeta(MCONTACT hMetaContact);
// checks whether a contact is a subcontact of existing MC
-MIR_CORE_DLL(int) db_mc_isSub(MCONTACT hContact);
+MIR_CORE_DLL(int) db_mc_isSub(MCONTACT hSubContact);
+
+//returns a handle to the default contact, or null on failure
+MIR_CORE_DLL(MCONTACT) db_mc_getDefault(MCONTACT hMetaContact);
+
+//returns the default contact number, or -1 on failure
+MIR_CORE_DLL(int) db_mc_getDefaultNum(MCONTACT hMetaContact);
+
+//returns the number of subcontacts, or -1 on failure
+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);
+// returns a subcontact with the given index
+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);
+
+//sets the default contact, using the subcontact's number
+MIR_CORE_DLL(int) db_mc_setDefaultNum(MCONTACT hMetaContact, int iNum);
+
#if defined(__cplusplus)
}
#endif
diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp
index efeb4278c5..6cd90055ba 100644
--- a/plugins/Clist_modern/src/modern_clc.cpp
+++ b/plugins/Clist_modern/src/modern_clc.cpp
@@ -392,8 +392,7 @@ static LRESULT clcOnCreate(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, LPA
dat->needsResort = 1;
dat->MetaIgnoreEmptyExtra = db_get_b(NULL, "CLC", "MetaIgnoreEmptyExtra", SETTING_METAIGNOREEMPTYEXTRA_DEFAULT);
- dat->IsMetaContactsEnabled = (!(GetWindowLongPtr(hwnd, GWL_STYLE)&CLS_MANUALUPDATE)) &&
- db_get_b(NULL, META_PROTO, "Enabled", 1) && ServiceExists(MS_MC_GETDEFAULTCONTACT);
+ dat->IsMetaContactsEnabled = (!(GetWindowLongPtr(hwnd, GWL_STYLE)&CLS_MANUALUPDATE)) && db_get_b(NULL, META_PROTO, "Enabled", 1);
dat->expandMeta = db_get_b(NULL, "CLC", "MetaExpanding", SETTING_METAEXPANDING_DEFAULT);
dat->useMetaIcon = db_get_b(NULL, "CLC", "Meta", SETTING_USEMETAICON_DEFAULT);
@@ -1288,7 +1287,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)
- CallService(MS_MC_SETDEFAULTCONTACT, (WPARAM)contDest->hContact, (LPARAM)hsour);
+ db_mc_setDefault(contDest->hContact, hsour);
}
else {
MCONTACT hcontact = contSour->hContact;
diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp
index 029856fada..201ca360c1 100644
--- a/plugins/Clist_modern/src/modern_clcitems.cpp
+++ b/plugins/Clist_modern/src/modern_clcitems.cpp
@@ -32,7 +32,7 @@ void AddSubcontacts(ClcData *dat, ClcContact *cont, BOOL showOfflineHereGroup)
{
ClcCacheEntry *cacheEntry = pcli->pfnGetCacheEntry(cont->hContact);
cont->SubExpanded = ( db_get_b(cont->hContact,"CList","Expanded",0) && ( db_get_b(NULL,"CLC","MetaExpanding",SETTING_METAEXPANDING_DEFAULT)));
- int subcount = (int)CallService(MS_MC_GETNUMCONTACTS,(WPARAM)cont->hContact,0);
+ int subcount = db_mc_getSubCount(cont->hContact);
if (subcount <= 0) {
cont->isSubcontact = 0;
cont->subcontacts = NULL;
@@ -46,7 +46,7 @@ void AddSubcontacts(ClcData *dat, ClcContact *cont, BOOL showOfflineHereGroup)
cont->SubAllocated = subcount;
int i=0;
for (int j = 0; j < subcount; j++) {
- MCONTACT hsub = (MCONTACT)CallService(MS_MC_GETSUBCONTACT, (WPARAM)cont->hContact, j);
+ MCONTACT hsub = db_mc_getSub(cont->hContact, j);
cacheEntry = pcli->pfnGetCacheEntry(hsub);
WORD wStatus = pdnce___GetStatus(cacheEntry);
if (showOfflineHereGroup || (!( db_get_b(NULL,"CLC","MetaHideOfflineSub",SETTING_METAHIDEOFFLINESUB_DEFAULT) && db_get_b(NULL,"CList","HideOffline",SETTING_HIDEOFFLINE_DEFAULT))
diff --git a/plugins/Clist_modern/src/modern_clcutils.cpp b/plugins/Clist_modern/src/modern_clcutils.cpp
index 031f051d92..11b4374f22 100644
--- a/plugins/Clist_modern/src/modern_clcutils.cpp
+++ b/plugins/Clist_modern/src/modern_clcutils.cpp
@@ -748,8 +748,7 @@ void LoadCLCOptions(HWND hwnd, ClcData *dat )
dat->selTextColour = db_get_dw(NULL,"CLC","SelTextColour",CLCDEFAULT_MODERN_SELTEXTCOLOUR);
dat->hotTextColour = db_get_dw(NULL,"CLC","HotTextColour",CLCDEFAULT_MODERN_HOTTEXTCOLOUR);
dat->quickSearchColour = db_get_dw(NULL,"CLC","QuickSearchColour",CLCDEFAULT_MODERN_QUICKSEARCHCOLOUR);
- dat->IsMetaContactsEnabled = (!(GetWindowLongPtr(hwnd,GWL_STYLE)&CLS_MANUALUPDATE)) &&
- db_get_b(NULL, META_PROTO, "Enabled", 1) && ServiceExists(MS_MC_GETDEFAULTCONTACT);
+ dat->IsMetaContactsEnabled = (!(GetWindowLongPtr(hwnd,GWL_STYLE)&CLS_MANUALUPDATE)) && db_get_b(NULL, META_PROTO, "Enabled", 1);
if (pcli->hwndContactTree == NULL || dat->hWnd == pcli->hwndContactTree)
dat->MetaIgnoreEmptyExtra = db_get_b(NULL,"CLC","MetaIgnoreEmptyExtra",SETTING_METAIGNOREEMPTYEXTRA_DEFAULT);
diff --git a/plugins/Clist_mw/src/clcitems.cpp b/plugins/Clist_mw/src/clcitems.cpp
index 703ae72ad4..2965d4fa7b 100644
--- a/plugins/Clist_mw/src/clcitems.cpp
+++ b/plugins/Clist_mw/src/clcitems.cpp
@@ -44,14 +44,14 @@ void AddSubcontacts(struct ClcContact * cont)
ClcCacheEntry *cacheEntry;
cacheEntry = GetContactFullCacheEntry(cont->hContact);
OutputDebugStringA("Proceed AddSubcontacts\r\n");
- subcount = (int)CallService(MS_MC_GETNUMCONTACTS,(WPARAM)cont->hContact,0);
+ subcount = db_mc_getSubCount(cont->hContact);
cont->SubExpanded = db_get_b(cont->hContact,"CList","Expanded",0);
cont->isSubcontact = 0;
cont->subcontacts = (struct ClcContact *) mir_realloc(cont->subcontacts, sizeof(struct ClcContact)*subcount);
cont->SubAllocated = subcount;
i = 0;
for (j = 0; j<subcount; j++) {
- MCONTACT hsub = (MCONTACT)CallService(MS_MC_GETSUBCONTACT, (WPARAM)cont->hContact, j);
+ MCONTACT hsub = db_mc_getSub(cont->hContact, j);
cacheEntry = GetContactFullCacheEntry(hsub);
if ( !(db_get_b(NULL,"CLC","MetaHideOfflineSub",1) && db_get_b(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT)) ||
cacheEntry->status != ID_STATUS_OFFLINE )
diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp
index 393d6b69e0..9a9672f689 100644
--- a/plugins/Db3x_mmap/src/dbevents.cpp
+++ b/plugins/Db3x_mmap/src/dbevents.cpp
@@ -53,7 +53,7 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei)
if (cc->IsSub()) {
// set default sub to the event's source
- CallService(MS_MC_SETDEFAULTCONTACT, cc->parentID, contactID);
+ db_mc_setDefault(cc->parentID, contactID);
contactID = cc->parentID; // and add an event to a metahistory
}
}
diff --git a/plugins/FingerprintNG/src/fingerprint.cpp b/plugins/FingerprintNG/src/fingerprint.cpp
index 8d41afac4a..30ce9b8cf3 100644
--- a/plugins/FingerprintNG/src/fingerprint.cpp
+++ b/plugins/FingerprintNG/src/fingerprint.cpp
@@ -171,7 +171,7 @@ int __fastcall ApplyFingerprintImage(MCONTACT hContact, LPTSTR szMirVer)
SetSrmmIcon(hContact, szMirVer);
MCONTACT hMeta = db_mc_getMeta(hContact);
- if (hMeta && CallService(MS_MC_GETDEFAULTCONTACT, hMeta, 0) == hContact)
+ if (hMeta && db_mc_getDefault(hMeta) == hContact)
db_set_ts(hMeta, META_PROTO, "MirVer", szMirVer);
return 0;
diff --git a/plugins/HistoryPlusPlus/EmptyHistoryForm.pas b/plugins/HistoryPlusPlus/EmptyHistoryForm.pas
index 39c3ce7ee8..f1faa55e6c 100644
--- a/plugins/HistoryPlusPlus/EmptyHistoryForm.pas
+++ b/plugins/HistoryPlusPlus/EmptyHistoryForm.pas
@@ -64,16 +64,16 @@ type
procedure FormShow(Sender: TObject);
procedure btYesClick(Sender: TObject);
private
- FContact: THandle;
- FContacts: Array of THandle;
+ FContact: TMCONTACT;
+ FContacts: Array of TMCONTACT;
procedure TranslateForm;
procedure PrepareForm;
- procedure SetContact(const Value: THandle);
- procedure EmptyHistory(hContact: THandle);
+ procedure SetContact(const Value: TMCONTACT);
+ procedure EmptyHistory(hContact: TMCONTACT);
protected
function GetFormText: String;
public
- property Contact: THandle read FContact write SetContact;
+ property Contact: TMCONTACT read FContact write SetContact;
end;
implementation
@@ -217,9 +217,9 @@ begin
end;
end;
-procedure TEmptyHistoryFrm.SetContact(const Value: THandle);
+procedure TEmptyHistoryFrm.SetContact(const Value: TMCONTACT);
var
- hContact: THandle;
+ hContact: TMCONTACT;
Proto: AnsiString;
i,num: Integer;
begin
@@ -228,10 +228,10 @@ begin
GetContactProto(FContact,hContact,Proto);
if Value <> hContact then
begin
- num := CallService(MS_MC_GETNUMCONTACTS,FContact,0);
+ num := db_mc_getSubCount(FContact);
for i := 0 to num-1 do
begin
- hContact := CallService(MS_MC_GETSUBCONTACT,FContact,i);
+ hContact := db_mc_getSub(FContact,i);
if hContact <> THandle(-1) then
begin
SetLength(FContacts,Length(FContacts)+1);
@@ -248,7 +248,7 @@ begin
btYes.Default := true;
end;
-procedure TEmptyHistoryFrm.EmptyHistory(hContact: THandle);
+procedure TEmptyHistoryFrm.EmptyHistory(hContact: TMCONTACT);
var
hDBEvent,prevhDbEvent: THandle;
begin
diff --git a/plugins/HistoryPlusPlus/GlobalSearch.pas b/plugins/HistoryPlusPlus/GlobalSearch.pas
index a51daf10f0..aa8db4368d 100644
--- a/plugins/HistoryPlusPlus/GlobalSearch.pas
+++ b/plugins/HistoryPlusPlus/GlobalSearch.pas
@@ -394,7 +394,7 @@ uses
function TfmGlobalSearch.AddContact(hContact: THandle): THPPContactInfo;
var
ci: THPPContactInfo;
- SubContact: THandle;
+ SubContact: TMCONTACT;
SubProtocol: AnsiString;
begin
ci := THPPContactInfo.Create;
@@ -1779,7 +1779,7 @@ procedure TfmGlobalSearch.HMNickChanged(var M: TMessage);
var
ci: THPPContactInfo;
i: Integer;
- SubContact: THandle;
+ SubContact: TMCONTACT;
SubProtocol: AnsiString;
begin
{ wParam - hContact; lParam - zero }
diff --git a/plugins/HistoryPlusPlus/HistoryForm.pas b/plugins/HistoryPlusPlus/HistoryForm.pas
index a0e1f53b3c..0ce99caf3d 100644
--- a/plugins/HistoryPlusPlus/HistoryForm.pas
+++ b/plugins/HistoryPlusPlus/HistoryForm.pas
@@ -328,7 +328,7 @@ type
DelayedFilter: TMessageTypes;
StartTimestamp: DWord;
EndTimestamp: DWord;
- FhContact, FhSubContact: THandle;
+ FhContact, FhSubContact: TMCONTACT;
FProtocol, FSubProtocol: AnsiString;
SavedLinkUrl: String;
SavedFileDir: String;
@@ -359,7 +359,7 @@ type
procedure OpenDetails(Item: Integer);
procedure TranslateForm;
- procedure SethContact(const Value: THandle);
+ procedure SethContact(const Value: TMCONTACT);
procedure LoadInOptions();
function IsFileEvent(Index: Integer): Boolean;
@@ -432,9 +432,9 @@ type
procedure FillBookmarks;
procedure HMBookmarkChanged(var M: TMessage); message HM_NOTF_BOOKMARKCHANGED;
- property hContact: THandle read FhContact write SethContact;
+ property hContact: TMCONTACT read FhContact write SethContact;
property Protocol: AnsiString read FProtocol;
- property hSubContact: THandle read FhSubContact;
+ property hSubContact: TMCONTACT read FhSubContact;
property SubProtocol: AnsiString read FSubProtocol;
published
procedure AlignControls(Control: TControl; var ARect: TRect); override;
@@ -1062,7 +1062,7 @@ end;
procedure THistoryFrm.HMMetaDefaultChanged(var M: TMessage);
var
- newSubContact: THandle;
+ newSubContact: TMCONTACT;
newSubProtocol: AnsiString;
begin
if THandle(M.wParam) <> hContact then
@@ -3100,7 +3100,7 @@ begin
end;
end;
-procedure THistoryFrm.SethContact(const Value: THandle);
+procedure THistoryFrm.SethContact(const Value: TMCONTACT);
begin
// if FhContact = Value then exit;
FhContact := Value;
diff --git a/plugins/HistoryPlusPlus/hpp_contacts.pas b/plugins/HistoryPlusPlus/hpp_contacts.pas
index d0beee248b..e2a68e7ac3 100644
--- a/plugins/HistoryPlusPlus/hpp_contacts.pas
+++ b/plugins/HistoryPlusPlus/hpp_contacts.pas
@@ -48,29 +48,30 @@ interface
uses
Windows, SysUtils,
Forms,
+ m_api,
hpp_global;
-function GetContactDisplayName(hContact: THandle; Proto: AnsiString = ''; Contact: boolean = false): String;
-function GetContactProto(hContact: THandle): AnsiString; overload;
-function GetContactProto(hContact: THandle; var SubContact: THandle; var SubProtocol: AnsiString): AnsiString; overload;
-function GetContactID(hContact: THandle; Proto: AnsiString = ''; Contact: boolean = false): AnsiString;
-function GetContactCodePage(hContact: THandle; const Proto: AnsiString = ''): Cardinal; overload;
-function GetContactCodePage(hContact: THandle; const Proto: AnsiString; var UsedDefault: boolean): Cardinal; overload;
-function WriteContactCodePage(hContact: THandle; CodePage: Cardinal; Proto: AnsiString = ''): boolean;
-function GetContactRTLMode(hContact: THandle; Proto: AnsiString = ''): boolean;
-function GetContactRTLModeTRTL(hContact: THandle; Proto: AnsiString = ''): TRTLMode;
-function WriteContactRTLMode(hContact: THandle; RTLMode: TRTLMode; Proto: AnsiString = ''): boolean;
+function GetContactDisplayName(hContact: TMCONTACT; Proto: AnsiString = ''; Contact: boolean = false): String;
+function GetContactProto(hContact: TMCONTACT): AnsiString; overload;
+function GetContactProto(hContact: TMCONTACT; var SubContact: TMCONTACT; var SubProtocol: AnsiString): AnsiString; overload;
+function GetContactID(hContact: TMCONTACT; Proto: AnsiString = ''; Contact: boolean = false): AnsiString;
+function GetContactCodePage(hContact: TMCONTACT; const Proto: AnsiString = ''): Cardinal; overload;
+function GetContactCodePage(hContact: TMCONTACT; const Proto: AnsiString; var UsedDefault: boolean): Cardinal; overload;
+function WriteContactCodePage(hContact: TMCONTACT; CodePage: Cardinal; Proto: AnsiString = ''): boolean;
+function GetContactRTLMode(hContact: TMCONTACT; Proto: AnsiString = ''): boolean;
+function GetContactRTLModeTRTL(hContact: TMCONTACT; Proto: AnsiString = ''): TRTLMode;
+function WriteContactRTLMode(hContact: TMCONTACT; RTLMode: TRTLMode; Proto: AnsiString = ''): boolean;
implementation
-uses hpp_database, hpp_options, m_api;
+uses hpp_database, hpp_options;
-function GetContactProto(hContact: THandle): AnsiString;
+function GetContactProto(hContact: TMCONTACT): AnsiString;
begin
Result := PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact, 0));
end;
-function GetContactProto(hContact: THandle; var SubContact: THandle; var SubProtocol: AnsiString): AnsiString;
+function GetContactProto(hContact: TMCONTACT; var SubContact: TMCONTACT; var SubProtocol: AnsiString): AnsiString;
begin
Result := PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact, 0));
if (Result = META_PROTO) then
@@ -85,7 +86,7 @@ begin
end;
end;
-function GetContactDisplayName(hContact: THandle; Proto: AnsiString = ''; Contact: boolean = false): String;
+function GetContactDisplayName(hContact: TMCONTACT; Proto: AnsiString = ''; Contact: boolean = false): String;
var
ci: TContactInfo;
RetPWideChar, UW: PChar;
@@ -122,7 +123,7 @@ begin
end;
end;
-function GetContactID(hContact: THandle; Proto: AnsiString = ''; Contact: boolean = false): AnsiString;
+function GetContactID(hContact: TMCONTACT; Proto: AnsiString = ''; Contact: boolean = false): AnsiString;
var
uid: PAnsiChar;
dbv: TDBVARIANT;
@@ -162,7 +163,7 @@ begin
end;
end;
-function WriteContactCodePage(hContact: THandle; CodePage: Cardinal; Proto: AnsiString = ''): boolean;
+function WriteContactCodePage(hContact: TMCONTACT; CodePage: Cardinal; Proto: AnsiString = ''): boolean;
begin
Result := false;
if Proto = '' then
@@ -173,7 +174,7 @@ begin
Result := True;
end;
-function _GetContactCodePage(hContact: THandle; Proto: AnsiString; var UsedDefault: boolean) : Cardinal;
+function _GetContactCodePage(hContact: TMCONTACT; Proto: AnsiString; var UsedDefault: boolean) : Cardinal;
begin
if Proto = '' then
Proto := GetContactProto(hContact);
@@ -190,14 +191,14 @@ begin
end;
end;
-function GetContactCodePage(hContact: THandle; const Proto: AnsiString = ''): Cardinal;
+function GetContactCodePage(hContact: TMCONTACT; const Proto: AnsiString = ''): Cardinal;
var
def: boolean;
begin
Result := _GetContactCodePage(hContact, Proto, def);
end;
-function GetContactCodePage(hContact: THandle; const Proto: AnsiString; var UsedDefault: boolean): Cardinal; overload;
+function GetContactCodePage(hContact: TMCONTACT; const Proto: AnsiString; var UsedDefault: boolean): Cardinal; overload;
begin
Result := _GetContactCodePage(hContact, Proto, UsedDefault);
end;
@@ -206,7 +207,7 @@ end;
// Changed default RTL mode from SysLocale.MiddleEast to
// Application.UseRightToLeftScrollBar because it's more correct and
// doesn't bug on MY SYSTEM!
-function GetContactRTLMode(hContact: THandle; Proto: AnsiString = ''): boolean;
+function GetContactRTLMode(hContact: TMCONTACT; Proto: AnsiString = ''): boolean;
var
Temp: Byte;
begin
@@ -226,7 +227,7 @@ begin
end;
end;
-function WriteContactRTLMode(hContact: THandle; RTLMode: TRTLMode; Proto: AnsiString = ''): boolean;
+function WriteContactRTLMode(hContact: TMCONTACT; RTLMode: TRTLMode; Proto: AnsiString = ''): boolean;
begin
Result := false;
if Proto = '' then
@@ -241,7 +242,7 @@ begin
Result := True;
end;
-function GetContactRTLModeTRTL(hContact: THandle; Proto: AnsiString = ''): TRTLMode;
+function GetContactRTLModeTRTL(hContact: TMCONTACT; Proto: AnsiString = ''): TRTLMode;
var
Temp: Byte;
begin
diff --git a/plugins/HistoryPlusPlus/hpp_externalgrid.pas b/plugins/HistoryPlusPlus/hpp_externalgrid.pas
index c0ee6c38e5..7001eda5e5 100644
--- a/plugins/HistoryPlusPlus/hpp_externalgrid.pas
+++ b/plugins/HistoryPlusPlus/hpp_externalgrid.pas
@@ -93,7 +93,7 @@ type
FGridState: TGridState;
SaveDialog: TSaveDialog;
RecentFormat: TSaveFormat;
- FSubContact: THandle;
+ FSubContact: TMCONTACT;
FSubProtocol: AnsiString;
function GetGridHandle: HWND;
@@ -144,7 +144,7 @@ type
public
constructor Create(AParentWindow: HWND; ControlID: Cardinal = 0);
destructor Destroy; override;
- procedure AddEvent(hContact, hDBEvent: THandle; Codepage: Integer; RTL: Boolean; DoScroll: Boolean);
+ procedure AddEvent(hContact:TMCONTACT; hDBEvent: THandle; Codepage: Integer; RTL: Boolean; DoScroll: Boolean);
procedure AddCustomEvent(hContact: THandle; const CustomItem: TExtCustomItem;
Codepage: Integer; RTL: Boolean; DoScroll: Boolean);
procedure SetPosition(x, y, cx, cy: Integer);
@@ -277,7 +277,7 @@ begin
Result := M.Result;
end;
-procedure TExternalGrid.AddEvent(hContact, hDBEvent: THandle; Codepage: Integer; RTL: Boolean;
+procedure TExternalGrid.AddEvent(hContact:TMCONTACT; hDBEvent: THandle; Codepage: Integer; RTL: Boolean;
DoScroll: Boolean);
var
RTLMode: TRTLMode;
@@ -1110,7 +1110,7 @@ end;
procedure TExternalGrid.HMMetaDefaultChanged(var M: TMessage);
var
- newSubContact: THandle;
+ newSubContact: TMCONTACT;
newSubProtocol: AnsiString;
begin
if Grid.Contact <> M.WParam then
diff --git a/plugins/HistoryStats/src/dlgoption_subinput.cpp b/plugins/HistoryStats/src/dlgoption_subinput.cpp
index 5f808f6b09..351132100a 100644
--- a/plugins/HistoryStats/src/dlgoption_subinput.cpp
+++ b/plugins/HistoryStats/src/dlgoption_subinput.cpp
@@ -78,13 +78,11 @@ void DlgOption::SubInput::onWMInitDialog()
hTemp = m_Options.insertGroup(NULL, TranslateT("Contact filtering"), OptionsCtrl::OCF_ROOTGROUP | OptionsCtrl::OCF_NODISABLECHILDS);
m_hProtocols = m_Options.insertGroup(hTemp, TranslateT("Ignore all contacts with protocol..."));
- if (mu::metacontacts::_available()) {
- hTemp2 = m_Options.insertGroup(hTemp, TranslateT("History read mode for MetaContacts"), mu::metacontacts::_available() ? 0 : OptionsCtrl::OCF_DISABLED);
- m_hMetaContactsMode = m_Options.insertRadio(hTemp2, NULL, TranslateT("Use only meta-contact's history"));
- m_Options.insertRadio(hTemp2, m_hMetaContactsMode, TranslateT("Use only subcontacts' histories (for one meta-contact)"));
- m_Options.insertRadio(hTemp2, m_hMetaContactsMode, TranslateT("Use meta-contact's history and its subcontacts' histories"));
- m_Options.insertRadio(hTemp2, m_hMetaContactsMode, TranslateT("Treat meta-contacts and subcontacts as normal contacts"));
- }
+ hTemp2 = m_Options.insertGroup(hTemp, TranslateT("History read mode for MetaContacts"), 0);
+ m_hMetaContactsMode = m_Options.insertRadio(hTemp2, NULL, TranslateT("Use only meta-contact's history"));
+ m_Options.insertRadio(hTemp2, m_hMetaContactsMode, TranslateT("Use only subcontacts' histories (for one meta-contact)"));
+ m_Options.insertRadio(hTemp2, m_hMetaContactsMode, TranslateT("Use meta-contact's history and its subcontacts' histories"));
+ m_Options.insertRadio(hTemp2, m_hMetaContactsMode, TranslateT("Treat meta-contacts and subcontacts as normal contacts"));
m_hMergeContacts = m_Options.insertCheck(hTemp, TranslateT("Merge contacts with same name"), OptionsCtrl::OCF_DISABLECHILDSONUNCHECK);
m_hMergeContactsGroups = m_Options.insertCheck(m_hMergeContacts, TranslateT("Only merge if contacts are in the same group"));
diff --git a/plugins/HistoryStats/src/mirandahistory.cpp b/plugins/HistoryStats/src/mirandahistory.cpp
index 867b8756f2..60c4df0ba0 100644
--- a/plugins/HistoryStats/src/mirandahistory.cpp
+++ b/plugins/HistoryStats/src/mirandahistory.cpp
@@ -59,7 +59,7 @@ void MirandaHistory::makeContactsAvailable()
void MirandaHistory::readContacts()
{
- bool bHandleMeta = mu::metacontacts::_available() && m_Settings.m_MetaContactsMode != Settings::mcmIgnoreMeta;
+ bool bHandleMeta = m_Settings.m_MetaContactsMode != Settings::mcmIgnoreMeta;
ext::a::string strMetaProto = bHandleMeta ? META_PROTO : "";
MirandaSettings db;
@@ -106,10 +106,10 @@ void MirandaHistory::readContacts()
// include meta-contact's subcontact
if (m_Settings.m_MetaContactsMode != Settings::mcmMetaOnly) {
// find subcontacts to read history from
- int numSubs = mu::metacontacts::getNumContacts(hContact);
+ int numSubs = db_mc_getSubCount(hContact);
if (numSubs > 0) {
for (int i = 0; i < numSubs; ++i) {
- MCONTACT hSubContact = mu::metacontacts::getSubContact(hContact, i);
+ MCONTACT hSubContact = db_mc_getSub(hContact, i);
if (hSubContact)
sources.push_back(hSubContact);
}
diff --git a/plugins/HistoryStats/src/mu_common.cpp b/plugins/HistoryStats/src/mu_common.cpp
index 1a3d5c199e..0f0bfa7b52 100644
--- a/plugins/HistoryStats/src/mu_common.cpp
+++ b/plugins/HistoryStats/src/mu_common.cpp
@@ -187,28 +187,6 @@ namespace mu
}
/*
- * metacontacts [external]
- */
-
- namespace metacontacts
- {
- bool _available()
- {
- return true;
- }
-
- int getNumContacts(MCONTACT hMetaContact)
- {
- return CallService(MS_MC_GETNUMCONTACTS, hMetaContact, 0);
- }
-
- MCONTACT getSubContact(MCONTACT hMetaContact, int iContactNumber)
- {
- return CallService(MS_MC_GETSUBCONTACT, hMetaContact, iContactNumber);
- }
- }
-
- /*
* opt
*/
diff --git a/plugins/HistoryStats/src/mu_common.h b/plugins/HistoryStats/src/mu_common.h
index c599d15f61..8ad005a5f4 100644
--- a/plugins/HistoryStats/src/mu_common.h
+++ b/plugins/HistoryStats/src/mu_common.h
@@ -63,17 +63,6 @@ namespace mu
}
/*
- * metacontacts [external]
- */
-
- namespace metacontacts
- {
- bool _available();
- int getNumContacts(MCONTACT hMetaContact);
- MCONTACT getSubContact(MCONTACT hMetaContact, int iContactNumber);
- }
-
- /*
* opt
*/
diff --git a/plugins/MenuItemEx/src/main.cpp b/plugins/MenuItemEx/src/main.cpp
index 39d6549624..e0f9f1c1ce 100644
--- a/plugins/MenuItemEx/src/main.cpp
+++ b/plugins/MenuItemEx/src/main.cpp
@@ -268,11 +268,6 @@ BOOL isMetaContact(MCONTACT hContact)
return FALSE;
}
-MCONTACT getDefaultContact(MCONTACT hContact)
-{
- return (MCONTACT)CallService(MS_MC_GETDEFAULTCONTACT, hContact, 0);
-}
-
MCONTACT getMostOnline(MCONTACT hContact)
{
return (MCONTACT)CallService(MS_MC_GETMOSTONLINECONTACT, hContact, 0);
@@ -512,7 +507,7 @@ void ModifyCopyID(MCONTACT hContact, BOOL bShowID, BOOL bTrimID)
if (isMetaContact(hContact)) {
MCONTACT hC = getMostOnline(hContact);
- if (!hContact) hC = getDefaultContact(hContact);
+ if (!hContact) hC = db_mc_getDefault(hContact);
hContact = hC;
}
@@ -612,7 +607,7 @@ INT_PTR onCopyID(WPARAM wparam, LPARAM lparam)
if (isMetaContact(hContact)) {
MCONTACT hC = getMostOnline(hContact);
if (!hContact)
- hC = getDefaultContact(hContact);
+ hC = db_mc_getDefault(hContact);
hContact = hC;
}
diff --git a/plugins/MirFox/src/MirandaUtils.cpp b/plugins/MirFox/src/MirandaUtils.cpp
index 24307322eb..1ae3f43c14 100644
--- a/plugins/MirFox/src/MirandaUtils.cpp
+++ b/plugins/MirFox/src/MirandaUtils.cpp
@@ -148,7 +148,7 @@ void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_
//TODO - metacontacts support - C:\MIRANDA\SOURCES\PLUGINS\popup_trunk\src\popup_wnd2.cpp : 1083
// //check for MetaContact and get szProto from subcontact
// if(strcmp(targetHandleSzProto, gszMetaProto)==0) {
- // HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETDEFAULTCONTACT, hContact, 0);
+ // HANDLE hSubContact = db_mc_getDefault(hContact);
// if(!hSubContact) return FALSE;
// targetHandleSzProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hSubContact, 0);
// }
diff --git a/plugins/MirandaG15/src/CContactList.cpp b/plugins/MirandaG15/src/CContactList.cpp
index c9f01b8187..fad2ae47a5 100644
--- a/plugins/MirandaG15/src/CContactList.cpp
+++ b/plugins/MirandaG15/src/CContactList.cpp
@@ -150,10 +150,10 @@ void CContactList::AddContact(MCONTACT hContact)
pGroup->sort(CContactList::CompareEntries);
// check that all subcontacts exist
- int numContacts = CallService(MS_MC_GETNUMCONTACTS,hContact,0);
+ int numContacts = db_mc_getSubCount(hContact);
MCONTACT hSubContact = NULL;
for(int i=0;i<numContacts;i++) {
- hSubContact = (MCONTACT)CallService(MS_MC_GETSUBCONTACT, hContact, (LPARAM)i);
+ hSubContact = db_mc_getSub(hContact, i);
RemoveContact(hSubContact);
AddContact(hSubContact);
}
@@ -203,13 +203,12 @@ bool CContactList::IsVisible(CContactListEntry *pEntry) {
}
} else {
if(pEntry->iStatus == ID_STATUS_OFFLINE) {
- DWORD dwNumContacts = (DWORD)CallService(MS_MC_GETNUMCONTACTS,(WPARAM)pEntry->hHandle,0);
- for(DWORD i = 0; i < dwNumContacts; i++) {
- MCONTACT hSubContact = (MCONTACT)CallService(MS_MC_GETSUBCONTACT,(WPARAM)pEntry->hHandle,i);
+ int dwNumContacts = db_mc_getSubCount(pEntry->hHandle);
+ for(int i = 0; i < dwNumContacts; i++) {
+ MCONTACT hSubContact = db_mc_getSub(pEntry->hHandle,i);
char *szProto = GetContactProto(hSubContact);
- if(db_get_w(hSubContact,szProto,"Status",ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
+ if(db_get_w(hSubContact,szProto,"Status",ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
return true;
- }
}
}
}
@@ -279,9 +278,9 @@ void CContactList::RemoveContact(MCONTACT hContact) {
else {
pGroup->RemoveGroup(((CListContainer<CContactListEntry*,CContactListGroup*>*)pContactEntry)->GetGroupData());
// Reenumerate all subcontacts (maybe MetaContacts was disabled
- int numContacts = CallService(MS_MC_GETNUMCONTACTS,hContact,0);
+ int numContacts = db_mc_getSubCount(hContact);
for(int i=0;i<numContacts;i++) {
- MCONTACT hSubContact = (MCONTACT)CallService(MS_MC_GETSUBCONTACT,hContact, (LPARAM)i);
+ MCONTACT hSubContact = db_mc_getSub(hContact, i);
if(!FindContact(hSubContact))
AddContact(hSubContact);
}
diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp
index a7eb35ca46..5b7f0edd6a 100755
--- a/plugins/New_GPG/src/main.cpp
+++ b/plugins/New_GPG/src/main.cpp
@@ -2284,10 +2284,10 @@ void ImportKey()
{
if(for_all_sub)
{
- int count = metaGetContactsNum(hContact);
+ int count = db_mc_getSubCount(hContact);
for(int i = 0; i < count; i++)
{
- MCONTACT hcnt = metaGetSubcontact(hContact, i);
+ MCONTACT hcnt = db_mc_getSub(hContact, i);
if(hcnt)
db_set_ts(hcnt, szGPGModuleName, "GPGPubKey", new_key.c_str());
}
@@ -2338,10 +2338,10 @@ void ImportKey()
{
if(for_all_sub)
{
- int count = metaGetContactsNum(hContact);
+ int count = db_mc_getSubCount(hContact);
for(int i = 0; i < count; i++)
{
- MCONTACT hcnt = metaGetSubcontact(hContact, i);
+ MCONTACT hcnt = db_mc_getSub(hContact, i);
if(hcnt)
{
char *tmp = NULL;
diff --git a/plugins/New_GPG/src/metacontacts.cpp b/plugins/New_GPG/src/metacontacts.cpp
index 9896393cbc..d730dae4b0 100644
--- a/plugins/New_GPG/src/metacontacts.cpp
+++ b/plugins/New_GPG/src/metacontacts.cpp
@@ -27,7 +27,7 @@ bool metaIsProtoMetaContacts(MCONTACT hContact)
bool metaIsDefaultSubContact(MCONTACT hContact)
{
- return (MCONTACT)CallService(MS_MC_GETDEFAULTCONTACT, db_mc_getMeta(hContact), 0) == hContact;
+ return db_mc_getDefault(db_mc_getMeta(hContact)) == hContact;
}
MCONTACT metaGetContact(MCONTACT hContact)
@@ -44,19 +44,9 @@ MCONTACT metaGetMostOnline(MCONTACT hContact)
return NULL;
}
-MCONTACT metaGetDefault(MCONTACT hContact)
+MCONTACT db_mc_getDefault(MCONTACT hContact)
{
if(metaIsProtoMetaContacts(hContact))
- return (MCONTACT)CallService(MS_MC_GETDEFAULTCONTACT,hContact,0);
+ return db_mc_getDefault(hContact);
return NULL;
}
-
-DWORD metaGetContactsNum(MCONTACT hContact)
-{
- return CallService(MS_MC_GETNUMCONTACTS, hContact, 0);
-}
-
-MCONTACT metaGetSubcontact(MCONTACT hContact, int num)
-{
- return (MCONTACT)CallService(MS_MC_GETSUBCONTACT, hContact, (LPARAM)num);
-}
diff --git a/plugins/New_GPG/src/metacontacts.h b/plugins/New_GPG/src/metacontacts.h
index d908d1e8a8..0819239f01 100644
--- a/plugins/New_GPG/src/metacontacts.h
+++ b/plugins/New_GPG/src/metacontacts.h
@@ -18,6 +18,4 @@ bool metaIsProtoMetaContacts(MCONTACT hContact);
bool metaIsDefaultSubContact(MCONTACT hContact) ;
MCONTACT metaGetContact(MCONTACT hContact);
MCONTACT metaGetMostOnline(MCONTACT hContact);
-MCONTACT metaGetDefault(MCONTACT hContact);
-DWORD metaGetContactsNum(MCONTACT hContact);
-MCONTACT metaGetSubcontact(MCONTACT hContact, int num);
+
diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp
index cf05777171..dcedbd4b4e 100755
--- a/plugins/New_GPG/src/options.cpp
+++ b/plugins/New_GPG/src/options.cpp
@@ -263,10 +263,10 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
if(MessageBox(0, TranslateT("Do you want to remove key from entire metacontact (all subcontacts)?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES)
{
MCONTACT hcnt = NULL;
- int count = metaGetContactsNum(meta);
+ int count = db_mc_getSubCount(meta);
for(int i = 0; i < count; i++)
{
- hcnt = metaGetSubcontact(meta, i);
+ hcnt = db_mc_getSub(meta, i);
if(hcnt)
{
db_unset(hcnt, szGPGModuleName, "KeyID");
@@ -880,10 +880,10 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
if(MessageBox(0, TranslateT("Do you want to load key for all subcontacts?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES)
{
allsubcontacts = true;
- int count = metaGetContactsNum(hContact);
+ int count = db_mc_getSubCount(hContact);
for(int i = 0; i < count; i++)
{
- MCONTACT hcnt = metaGetSubcontact(hContact, i);
+ MCONTACT hcnt = db_mc_getSub(hContact, i);
if(hcnt)
db_set_ts(hcnt, szGPGModuleName, "GPGPubKey", key_buf.substr(ws1,ws2-ws1).c_str());
}
@@ -944,10 +944,10 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
{
if(allsubcontacts)
{
- int count = metaGetContactsNum(hContact);
+ int count = db_mc_getSubCount(hContact);
for(int i = 0; i < count; i++)
{
- MCONTACT hcnt = metaGetSubcontact(hContact, i);
+ MCONTACT hcnt = db_mc_getSub(hContact, i);
if(hcnt)
db_unset(hcnt, szGPGModuleName, "bAlwatsTrust");
}
@@ -975,10 +975,10 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
{
if(allsubcontacts)
{
- int count = metaGetContactsNum(hContact);
+ int count = db_mc_getSubCount(hContact);
for(int i = 0; i < count; i++)
{
- MCONTACT hcnt = metaGetSubcontact(hContact, i);
+ MCONTACT hcnt = db_mc_getSub(hContact, i);
if(hcnt)
db_set_s(hcnt, szGPGModuleName, "KeyID", tmp2);
}
@@ -1024,10 +1024,10 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
{
if(allsubcontacts)
{
- int count = metaGetContactsNum(hContact);
+ int count = db_mc_getSubCount(hContact);
for(int i = 0; i < count; i++)
{
- MCONTACT hcnt = metaGetSubcontact(hContact, i);
+ MCONTACT hcnt = db_mc_getSub(hContact, i);
if(hcnt)
db_set_s(hcnt, szGPGModuleName, "KeyMainName", output.substr(s,s2-s-1).c_str());
}
@@ -1061,10 +1061,10 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
{
if(allsubcontacts)
{
- int count = metaGetContactsNum(hContact);
+ int count = db_mc_getSubCount(hContact);
for(int i = 0; i < count; i++)
{
- MCONTACT hcnt = metaGetSubcontact(hContact, i);
+ MCONTACT hcnt = db_mc_getSub(hContact, i);
if(hcnt)
db_set_s(hcnt, szGPGModuleName, "KeyComment", output.substr(s2,s-s2).c_str());
}
@@ -1087,10 +1087,10 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
{
if(allsubcontacts)
{
- int count = metaGetContactsNum(hContact);
+ int count = db_mc_getSubCount(hContact);
for(int i = 0; i < count; i++)
{
- MCONTACT hcnt = metaGetSubcontact(hContact, i);
+ MCONTACT hcnt = db_mc_getSub(hContact, i);
if(hcnt)
db_set_s(hcnt, szGPGModuleName, "KeyMainEmail", output.substr(s,s2-s).c_str());
}
@@ -1116,10 +1116,10 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
{
if(allsubcontacts)
{
- int count = metaGetContactsNum(hContact);
+ int count = db_mc_getSubCount(hContact);
for(int i = 0; i < count; i++)
{
- MCONTACT hcnt = metaGetSubcontact(hContact, i);
+ MCONTACT hcnt = db_mc_getSub(hContact, i);
if(hcnt)
db_set_s(hcnt, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str());
}
@@ -1187,10 +1187,10 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
{
if(allsubcontacts)
{
- int count = metaGetContactsNum(hContact);
+ int count = db_mc_getSubCount(hContact);
for(int i = 0; i < count; i++)
{
- MCONTACT hcnt = metaGetSubcontact(hContact, i);
+ MCONTACT hcnt = db_mc_getSub(hContact, i);
if(hcnt)
{
if(!isContactSecured(hcnt))
diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp
index c20a6645de..ae46d01671 100755
--- a/plugins/New_GPG/src/utilities.cpp
+++ b/plugins/New_GPG/src/utilities.cpp
@@ -211,10 +211,10 @@ INT_PTR ToggleEncryption(WPARAM w, LPARAM l)
{
if(MessageBox(0, TranslateT("Do you want to toggle encryption for all subcontacts?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES)
{
- int count = metaGetContactsNum(hContact);
+ int count = db_mc_getSubCount(hContact);
for(int i = 0; i < count; i++)
{
- MCONTACT hcnt = metaGetSubcontact(hContact, i);
+ MCONTACT hcnt = db_mc_getSub(hContact, i);
if(hcnt)
db_set_b(hcnt, szGPGModuleName, "GPGEncryption", enc?0:1);
}
diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp
index d824abb9b2..29138bf63f 100644
--- a/plugins/Popup/src/popup_wnd2.cpp
+++ b/plugins/Popup/src/popup_wnd2.cpp
@@ -943,7 +943,7 @@ BOOL IsUtfSendAvailable(MCONTACT hContact)
if (szProto == NULL) return FALSE;
//check for MetaContact and get szProto from subcontact
if (!strcmp(szProto, META_PROTO)) {
- MCONTACT hSubContact = (MCONTACT)CallService(MS_MC_GETDEFAULTCONTACT, hContact, 0);
+ MCONTACT hSubContact = db_mc_getDefault(hContact);
if (!hSubContact)
return FALSE;
szProto = GetContactProto(hSubContact);
diff --git a/plugins/SecureIM/src/crypt_metacontacts.cpp b/plugins/SecureIM/src/crypt_metacontacts.cpp
index c104044f87..a874f5bb1c 100644
--- a/plugins/SecureIM/src/crypt_metacontacts.cpp
+++ b/plugins/SecureIM/src/crypt_metacontacts.cpp
@@ -10,7 +10,7 @@ BOOL isProtoMetaContacts(MCONTACT hContact)
BOOL isDefaultSubContact(MCONTACT hContact)
{
- return (MCONTACT)CallService(MS_MC_GETDEFAULTCONTACT, db_mc_getMeta(hContact), 0) == hContact;
+ return db_mc_getDefault(db_mc_getMeta(hContact)) == hContact;
}
MCONTACT getMostOnline(MCONTACT hContact)
@@ -23,8 +23,8 @@ void DeinitMetaContact(MCONTACT hContact)
{
MCONTACT hMetaContact = isProtoMetaContacts(hContact) ? hContact : db_mc_getMeta(hContact);
if (hMetaContact) {
- for (int i=0; i < CallService(MS_MC_GETNUMCONTACTS,(WPARAM)hMetaContact,0); i++) {
- MCONTACT hSubContact = (MCONTACT)CallService(MS_MC_GETSUBCONTACT, (WPARAM)hMetaContact, i);
+ for (int i=0; i < db_mc_getSubCount(hMetaContact); i++) {
+ MCONTACT hSubContact = db_mc_getSub(hMetaContact, i);
if (hSubContact && (isContactSecured(hSubContact)&SECURED))
CallContactService(hSubContact,PSS_MESSAGE, PREF_METANODB, (LPARAM)SIG_DEIN);
}
diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp
index 1c66b5294b..8a630c4549 100644
--- a/plugins/TabSRMM/src/container.cpp
+++ b/plugins/TabSRMM/src/container.cpp
@@ -2345,8 +2345,8 @@ HMENU TSAPI BuildMCProtocolMenu(HWND hwndDlg)
AppendMenu(hMenu, MF_STRING | MF_DISABLED | MF_GRAYED | MF_CHECKED, 1, TranslateT("Meta Contact"));
AppendMenu(hMenu, MF_SEPARATOR, 1, _T(""));
- int iNumProtos = (int)CallService(MS_MC_GETNUMCONTACTS, dat->hContact, 0);
- int iDefaultProtoByNum = (int)CallService(MS_MC_GETDEFAULTCONTACTNUM, dat->hContact, 0);
+ int iNumProtos = db_mc_getSubCount(dat->hContact);
+ int iDefaultProtoByNum = db_mc_getSubCount(dat->hContact);
MCONTACT hContactMostOnline = (MCONTACT)CallService(MS_MC_GETMOSTONLINECONTACT, dat->hContact, 0);
char *szProtoMostOnline = GetContactProto(hContactMostOnline);
int isForced = M.GetDword(dat->hContact, "tabSRMM_forced", -1);
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index 064a069700..763620c02c 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -3097,7 +3097,7 @@ quote_from_last:
}
}
else if (iSelection >= 1000) // the "default" menu...
- CallService(MS_MC_SETDEFAULTCONTACTNUM, dat->hContact, (LPARAM)(iSelection - 1000));
+ db_mc_setDefaultNum(dat->hContact, iSelection - 1000);
DestroyMenu(hMC);
InvalidateRect(GetParent(hwndDlg), NULL, FALSE);
diff --git a/plugins/TipperYM/src/subst.cpp b/plugins/TipperYM/src/subst.cpp
index fe6cfe6e30..ad64b02afe 100644
--- a/plugins/TipperYM/src/subst.cpp
+++ b/plugins/TipperYM/src/subst.cpp
@@ -413,13 +413,13 @@ bool GetSysSubstText(MCONTACT hContact, TCHAR *swzRawSpec, TCHAR *buff, int buff
char *szProto = GetContactProto(hContact);
if (szProto && !strcmp(szProto, META_PROTO)) {
- iNumber = CallService(MS_MC_GETNUMCONTACTS, hContact, 0);
- hTmpContact = (MCONTACT)CallService(MS_MC_GETSUBCONTACT, hContact, 0);
+ iNumber = db_mc_getSubCount(hContact);
+ hTmpContact = db_mc_getSub(hContact, 0);
}
for (int i = 0; i < iNumber; i++) {
if (i > 0)
- hTmpContact = (MCONTACT)CallService(MS_MC_GETSUBCONTACT, hContact, i);
+ hTmpContact = db_mc_getSub(hContact, i);
dwRecountTs = db_get_dw(hTmpContact, MODULE, "LastCountTS", 0);
dwTime = (DWORD)time(0);
dwDiff = (dwTime - dwRecountTs);
diff --git a/plugins/UserInfoEx/src/classMAnnivDate.cpp b/plugins/UserInfoEx/src/classMAnnivDate.cpp
index 59e861d446..3078c2f4bd 100644
--- a/plugins/UserInfoEx/src/classMAnnivDate.cpp
+++ b/plugins/UserInfoEx/src/classMAnnivDate.cpp
@@ -482,9 +482,9 @@ int MAnnivDate::DBGetBirthDate(MCONTACT hContact, LPSTR pszProto)
// try to get birthday date from metacontact's subcontact
else if (DB::Module::IsMetaAndScan(pszProto)) {
// try to get setting from the default subcontact first
- const int def = DB::MetaContact::SubDefNum(hContact);
+ const int def = db_mc_getDefaultNum(hContact);
if (def > -1 && def < INT_MAX) {
- MCONTACT hSubContact = DB::MetaContact::Sub(hContact, def);
+ MCONTACT hSubContact = db_mc_getSub(hContact, def);
if (hSubContact != NULL && !DBGetBirthDate(hSubContact, NULL)) {
RemoveFlags(MADF_HASCUSTOM);
SetFlags(MADF_HASMETA);
@@ -493,12 +493,12 @@ int MAnnivDate::DBGetBirthDate(MCONTACT hContact, LPSTR pszProto)
// scan all subcontacts for the setting
if (_wFlags == 0) {
- const int cnt = DB::MetaContact::SubCount(hContact);
+ const int cnt = db_mc_getSubCount(hContact);
if (cnt < INT_MAX) {
for (int i = 0; i < cnt; i++) {
if (i != def) {
- MCONTACT hSubContact = DB::MetaContact::Sub(hContact, i);
+ MCONTACT hSubContact = db_mc_getSub(hContact, i);
if (hSubContact != NULL && !DBGetBirthDate(hSubContact, NULL)) {
RemoveFlags(MADF_HASCUSTOM);
SetFlags(MADF_HASMETA);
@@ -735,7 +735,7 @@ int MAnnivDate::BackupBirthday(MCONTACT hContact, LPSTR pszProto, const BYTE bDo
MAnnivDate mdbNewProto;
MAnnivDate mdbIgnore;
- const int nSubContactCount = (bIsMeta) ? DB::MetaContact::SubCount(hContact) : 0;
+ const int nSubContactCount = (bIsMeta) ? db_mc_getSubCount(hContact) : 0;
BYTE bWantBackup = !mdbNewProto.DBGetDate(hContact, pszProto, SET_CONTACT_BIRTHDAY, SET_CONTACT_BIRTHMONTH, SET_CONTACT_BIRTHYEAR)
&& !IsEqual(mdbNewProto.SystemTime())
@@ -744,7 +744,7 @@ int MAnnivDate::BackupBirthday(MCONTACT hContact, LPSTR pszProto, const BYTE bDo
// allow backup only, if the custom setting differs from all meta subcontacts' protocol based settings, too.
for (int i = 0; (i < nSubContactCount) && bWantBackup && bIsMeta; i++) {
- MCONTACT hSubContact = DB::MetaContact::Sub(hContact, i);
+ MCONTACT hSubContact = db_mc_getSub(hContact, i);
if (hSubContact && !mdbIgnore.DBGetDate(hSubContact, pszProto, SET_CONTACT_BIRTHDAY, SET_CONTACT_BIRTHMONTH, SET_CONTACT_BIRTHYEAR))
bWantBackup = bWantBackup
&& !IsEqual(mdbIgnore.SystemTime())
@@ -769,7 +769,7 @@ int MAnnivDate::BackupBirthday(MCONTACT hContact, LPSTR pszProto, const BYTE bDo
// update metasubcontacts
for (int i = 0; i < nSubContactCount; i++) {
- MCONTACT hSubContact = DB::MetaContact::Sub(hContact, i);
+ MCONTACT hSubContact = db_mc_getSub(hContact, i);
if (hSubContact != NULL) {
if (!mdbIgnore.DBGetDate(hSubContact, DB::Contact::Proto(hSubContact), SET_CONTACT_BIRTHDAY, SET_CONTACT_BIRTHMONTH, SET_CONTACT_BIRTHYEAR))
mdbIgnore.DBWriteDateStamp(hSubContact, USERINFO, SET_REMIND_BIRTHDAY_IGNORED);
diff --git a/plugins/UserInfoEx/src/dlg_propsheet.cpp b/plugins/UserInfoEx/src/dlg_propsheet.cpp
index d9188ee74e..9f303cb8a1 100644
--- a/plugins/UserInfoEx/src/dlg_propsheet.cpp
+++ b/plugins/UserInfoEx/src/dlg_propsheet.cpp
@@ -310,12 +310,12 @@ static INT_PTR ShowDialog(WPARAM wParam, LPARAM lParam)
// metacontacts sub pages
if (bScanMetaSubContacts) {
- int numSubs = DB::MetaContact::SubCount(wParam);
+ int numSubs = db_mc_getSubCount(wParam);
psh._dwFlags &= ~PSF_PROTOPAGESONLY_INIT;
psh._dwFlags |= PSF_PROTOPAGESONLY;
for (int i = 0; i < numSubs; i++) {
- psh._hContact = DB::MetaContact::Sub(wParam, i);
+ psh._hContact = db_mc_getSub(wParam, i);
psh._nSubContact = i;
if (psh._hContact) {
psh._pszProto = DB::Contact::Proto(psh._hContact);
@@ -1574,9 +1574,9 @@ static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
// need meta contact's subcontact information
if (DB::Module::IsMetaAndScan(pPs->pszProto)) {
// count valid subcontacts whose protocol supports the PSS_GETINFO service to update the information
- int numSubs = DB::MetaContact::SubCount(pPs->hContact);
+ int numSubs = db_mc_getSubCount(pPs->hContact);
for (int i = 0; i < numSubs; i++) {
- MCONTACT hSubContact = DB::MetaContact::Sub(pPs->hContact, i);
+ MCONTACT hSubContact = db_mc_getSub(pPs->hContact, i);
if (hSubContact != NULL) {
if (ProtoServiceExists(DB::Contact::Proto(hSubContact), PSS_GETINFO)) {
pPs->infosUpdated = (TAckInfo*)mir_realloc(pPs->infosUpdated, sizeof(TAckInfo)* (pPs->nSubContacts + 1));
diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp b/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp
index d253876279..b2c2bf80d4 100644
--- a/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp
+++ b/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp
@@ -217,9 +217,9 @@ int CExImContactXML::Export(FILE *xmlfile, DB::CEnumList* pModules)
if (isMeta()) {
CExImContactXML vContact(_pXmlFile);
- const int cnt = DB::MetaContact::SubCount(_hContact);
- const int def = DB::MetaContact::SubDefNum(_hContact);
- MCONTACT hSubContact = DB::MetaContact::Sub(_hContact, def);
+ const int cnt = db_mc_getSubCount(_hContact);
+ const int def = db_mc_getDefaultNum(_hContact);
+ MCONTACT hSubContact = db_mc_getSub(_hContact, def);
// export default subcontact
if (hSubContact && vContact.fromDB(hSubContact))
@@ -227,7 +227,7 @@ int CExImContactXML::Export(FILE *xmlfile, DB::CEnumList* pModules)
for (int i = 0; i < cnt; i++) {
if (i != def) {
- hSubContact = DB::MetaContact::Sub(_hContact, i);
+ hSubContact = db_mc_getSub(_hContact, i);
if (hSubContact && vContact.fromDB(hSubContact))
vContact.ExportSubContact(this, pModules);
}
diff --git a/plugins/UserInfoEx/src/mir_db.cpp b/plugins/UserInfoEx/src/mir_db.cpp
index 17f77c8161..4a06374b8d 100644
--- a/plugins/UserInfoEx/src/mir_db.cpp
+++ b/plugins/UserInfoEx/src/mir_db.cpp
@@ -23,36 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
namespace DB {
-namespace MetaContact {
-
-INT_PTR SubCount(MCONTACT hMetaContact)
-{
- INT_PTR result = CallService(MS_MC_GETNUMCONTACTS, (WPARAM) hMetaContact, 0);
- return (result == CALLSERVICE_NOTFOUND) ? -1 : result;
-}
-
-INT_PTR SubDefNum(MCONTACT hMetaContact)
-{
- INT_PTR result = CallService(MS_MC_GETDEFAULTCONTACTNUM, (WPARAM) hMetaContact, 0);
- return (result == CALLSERVICE_NOTFOUND) ? -1 : result;
-}
-
-MCONTACT Sub(MCONTACT hMetaContact, int idx)
-{
- if (idx != -1) {
- INT_PTR result = CallService(MS_MC_GETSUBCONTACT, (WPARAM) hMetaContact, (LPARAM) idx);
- return (result == CALLSERVICE_NOTFOUND) ? NULL : (MCONTACT)result;
- }
- return NULL;
-}
-
-MCONTACT GetMeta(MCONTACT hContact)
-{
- return db_mc_getMeta(hContact);
-}
-
-} /* namespace MetaContact */
-
/**
* This namespace contains all functions used to access or modify contacts in the database.
**/
@@ -297,22 +267,22 @@ BYTE GetEx(MCONTACT hContact, LPCSTR pszModule, LPCSTR pszProto, LPCSTR pszSetti
result = Get(hContact, pszProto, pszSetting, dbv, destType) != 0;
// try to get setting from a metasubcontact
if (result && DB::Module::IsMetaAndScan(pszProto)) {
- const INT_PTR def = DB::MetaContact::SubDefNum(hContact);
+ const INT_PTR def = db_mc_getDefaultNum(hContact);
MCONTACT hSubContact;
// try to get setting from the default subcontact first
if (def > -1 && def < INT_MAX) {
- hSubContact = DB::MetaContact::Sub(hContact, def);
+ hSubContact = db_mc_getSub(hContact, def);
if (hSubContact != NULL)
result = DB::Setting::GetEx(hSubContact, pszModule, DB::Contact::Proto(hSubContact), pszSetting, dbv, destType) != 0;
}
// scan all subcontacts for the setting
if (result) {
- const INT_PTR cnt = DB::MetaContact::SubCount(hContact);
+ const INT_PTR cnt = db_mc_getSubCount(hContact);
if (cnt < INT_MAX) {
INT_PTR i;
for (i = 0; result && i < cnt; i++) {
if (i != def) {
- hSubContact = DB::MetaContact::Sub(hContact, i);
+ hSubContact = db_mc_getSub(hContact, i);
if (hSubContact != NULL)
result = DB::Setting::GetEx(hSubContact, pszModule, DB::Contact::Proto(hSubContact), pszSetting, dbv, destType) != 0;
} } } } } }
@@ -352,11 +322,11 @@ WORD GetCtrl(MCONTACT hContact, LPCSTR pszModule, LPCSTR pszSubModule, LPCSTR ps
// try to read the setting from the sub contacts' modules
else if (DB::Module::IsMetaAndScan(pszProto)) {
- const INT_PTR def = DB::MetaContact::SubDefNum(hContact);
+ const INT_PTR def = db_mc_getDefaultNum(hContact);
MCONTACT hSubContact;
// try to get setting from the default subcontact first
if (def > -1 && def < INT_MAX) {
- hSubContact = DB::MetaContact::Sub(hContact, def);
+ hSubContact = db_mc_getSub(hContact, def);
if (hSubContact != NULL) {
wFlags = GetCtrl(hSubContact, pszSubModule, NULL, DB::Contact::Proto(hSubContact), pszSetting, dbv, destType);
if (wFlags != 0) {
@@ -368,10 +338,10 @@ WORD GetCtrl(MCONTACT hContact, LPCSTR pszModule, LPCSTR pszSubModule, LPCSTR ps
// copy the missing settings from the other subcontacts
if (wFlags == 0) {
INT_PTR i;
- const INT_PTR cnt = DB::MetaContact::SubCount(hContact);
+ const INT_PTR cnt = db_mc_getSubCount(hContact);
for (i = 0; i < cnt; i++) {
if (i != def) {
- hSubContact = DB::MetaContact::Sub(hContact, i);
+ hSubContact = db_mc_getSub(hContact, i);
if (hSubContact != NULL) {
wFlags = GetCtrl(hSubContact, pszSubModule, NULL, DB::Contact::Proto(hSubContact), pszSetting, dbv, destType);
if (wFlags != 0) {
diff --git a/plugins/UserInfoEx/src/mir_db.h b/plugins/UserInfoEx/src/mir_db.h
index ae6ec11c25..93df0f2a36 100644
--- a/plugins/UserInfoEx/src/mir_db.h
+++ b/plugins/UserInfoEx/src/mir_db.h
@@ -23,14 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
namespace DB {
-namespace MetaContact{
- INT_PTR SubCount(MCONTACT hMetaContact);
- INT_PTR SubDefNum(MCONTACT hMetaContact);
- MCONTACT Sub(MCONTACT hMetaContact, int idx);
-
- MCONTACT GetMeta(MCONTACT hContact);
-} /* namespace MetaContact */
-
/**
* This namespace contains all functions used to access
* or modify contacts in the database.
diff --git a/plugins/UserInfoEx/src/psp_profile.cpp b/plugins/UserInfoEx/src/psp_profile.cpp
index c63bc0e4ab..11a1b73eaf 100644
--- a/plugins/UserInfoEx/src/psp_profile.cpp
+++ b/plugins/UserInfoEx/src/psp_profile.cpp
@@ -1143,22 +1143,19 @@ INT_PTR CALLBACK PSPProcContactProfile(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR
// scan all basic protocols for the subcontacts
if (DB::Module::IsMetaAndScan(pszProto)) {
- int iDefault = CallService(MS_MC_GETDEFAULTCONTACTNUM, hContact, NULL);
+ int iDefault = db_mc_getDefaultNum(hContact);
MCONTACT hSubContact, hDefContact;
LPCSTR pszSubBaseProto;
- int j, numSubs;
- if ((hDefContact = (MCONTACT)CallService(MS_MC_GETSUBCONTACT, hContact, iDefault)) &&
- (pszSubBaseProto = DB::Contact::Proto(hDefContact)))
- {
+ if ((hDefContact = db_mc_getSub(hContact, iDefault)) && (pszSubBaseProto = DB::Contact::Proto(hDefContact))) {
if ((numProtoItems += ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hDefContact, pszSubBaseProto, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASMETA|CTRLF_HASPROTO)) < 0)
return FALSE;
// copy the missing settings from the other subcontacts
- numSubs = CallService(MS_MC_GETNUMCONTACTS, hContact, NULL);
- for (j = 0; j < numSubs; j++) {
+ int numSubs = db_mc_getSubCount(hContact);
+ for (int j = 0; j < numSubs; j++) {
if (j == iDefault) continue;
- if (!(hSubContact = (MCONTACT)CallService(MS_MC_GETSUBCONTACT, hContact, j))) continue;
+ if (!(hSubContact = db_mc_getSub(hContact, j))) continue;
if (!(pszSubBaseProto = DB::Contact::Proto(hSubContact))) continue;
if ((numProtoItems += ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hSubContact, pszSubBaseProto, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASMETA|CTRLF_HASPROTO)) < 0)
return FALSE;
diff --git a/plugins/UserInfoEx/src/svc_reminder.cpp b/plugins/UserInfoEx/src/svc_reminder.cpp
index c22b9089c1..e2af3f6161 100644
--- a/plugins/UserInfoEx/src/svc_reminder.cpp
+++ b/plugins/UserInfoEx/src/svc_reminder.cpp
@@ -654,7 +654,7 @@ static int OnContactSettingChanged(MCONTACT hContact, DBCONTACTWRITESETTING* pdb
!strncmp(pdbcws->szSetting, "Anniv", 5) ||
!strncmp(pdbcws->szSetting, "DOB", 3)))
{
- MCONTACT hMeta = DB::MetaContact::GetMeta(hContact);
+ MCONTACT hMeta = db_mc_getMeta(hContact);
WORD LastAnswer = IDNONE;
CEvent evt;
MTime now;
diff --git a/plugins/Variables/src/parse_metacontacts.cpp b/plugins/Variables/src/parse_metacontacts.cpp
index e027eb0f2d..95503525d5 100644
--- a/plugins/Variables/src/parse_metacontacts.cpp
+++ b/plugins/Variables/src/parse_metacontacts.cpp
@@ -82,7 +82,7 @@ static TCHAR *parseGetDefault(ARGUMENTSINFO *ai)
return NULL;
}
- hContact = (MCONTACT)CallService(MS_MC_GETDEFAULTCONTACT, hContact, 0);
+ hContact = db_mc_getDefault(hContact);
if (hContact == NULL)
return NULL;
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp
index 75160c68e2..7f7eb49ca1 100644
--- a/protocols/Gadu-Gadu/src/groupchat.cpp
+++ b/protocols/Gadu-Gadu/src/groupchat.cpp
@@ -393,9 +393,9 @@ static MCONTACT gg_getsubcontact(GGPROTO* gg, MCONTACT hContact)
{
char* szProto = GetContactProto(hContact);
if (szProto && !lstrcmpA(szProto, META_PROTO)) {
- int nSubContacts = (int)CallService(MS_MC_GETNUMCONTACTS, hContact, 0), i;
+ int nSubContacts = db_mc_getSubCount(hContact), i;
for (i = 0; i < nSubContacts; i++) {
- MCONTACT hMetaContact = (MCONTACT)CallService(MS_MC_GETSUBCONTACT, hContact, i);
+ MCONTACT hMetaContact = db_mc_getSub(hContact, i);
szProto = GetContactProto(hMetaContact);
if (szProto && !lstrcmpA(szProto, gg->m_szModuleName))
return hMetaContact;
diff --git a/src/core/modules.cpp b/src/core/modules.cpp
index 3111bc9e7d..3243e81058 100644
--- a/src/core/modules.cpp
+++ b/src/core/modules.cpp
@@ -150,9 +150,8 @@ int LoadDefaultModules(void)
if (LoadContactsModule()) return 1;
if (LoadContactListModule()) return 1; // prepare contact list interface
if (LoadAddContactModule()) return 1;
- #ifdef _DEBUG
- if (LoadMetacontacts()) return 1;
- #endif
+ if (LoadMetacontacts()) return 1;
+
if (LoadNewPluginsModule()) return 1; // will call Load(void) on everything, clist will load first
Langpack_SortDuplicates();
@@ -171,9 +170,7 @@ void UnloadDefaultModules(void)
{
UnloadChatModule();
UnloadAccountsModule();
- #ifdef _DEBUG
- UnloadMetacontacts();
- #endif
+ UnloadMetacontacts();
UnloadNewPlugins();
UnloadProtocolsModule();
UnloadSkinSounds();
diff --git a/src/mir_core/db.cpp b/src/mir_core/db.cpp
index 140af537c0..1479748bf2 100644
--- a/src/mir_core/db.cpp
+++ b/src/mir_core/db.cpp
@@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
-static MIDatabase* currDb = NULL;
+MIDatabase *currDb = NULL;
/////////////////////////////////////////////////////////////////////////////////////////
// getting data
@@ -321,34 +321,6 @@ MIR_CORE_DLL(HANDLE) db_event_prev(HANDLE hDbEvent)
}
/////////////////////////////////////////////////////////////////////////////////////////
-// metacontacts
-
-MIR_CORE_DLL(int) db_mc_isMeta(MCONTACT hContact)
-{
- if (currDb == NULL) return false;
-
- DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
- return (cc == NULL) ? false : cc->nSubs != -1;
-}
-
-MIR_CORE_DLL(int) db_mc_isSub(MCONTACT hContact)
-{
- if (currDb == NULL) return false;
-
- DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
- return (cc == NULL) ? false : cc->parentID != 0;
-}
-
-MIR_CORE_DLL(MCONTACT) db_mc_getMeta(MCONTACT hSubContact)
-{
- if (currDb == NULL) return NULL;
-
- DBCachedContact *cc = currDb->m_cache->GetCachedContact(hSubContact);
- return (cc == NULL) ? NULL : cc->parentID;
-}
-
-
-/////////////////////////////////////////////////////////////////////////////////////////
// misc functions
MIR_CORE_DLL(INT_PTR) db_free(DBVARIANT *dbv)
diff --git a/src/mir_core/mc.cpp b/src/mir_core/mc.cpp
new file mode 100644
index 0000000000..4970b135d8
--- /dev/null
+++ b/src/mir_core/mc.cpp
@@ -0,0 +1,148 @@
+/*
+
+Miranda NG: the free IM client for Microsoft* Windows*
+
+Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org),
+Copyright (c) 2000-12 Miranda IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "commonheaders.h"
+
+static HANDLE hEventDefaultChanged;
+
+void InitMetaContacts()
+{
+ hEventDefaultChanged = CreateHookableEvent(ME_MC_DEFAULTTCHANGED);
+}
+
+DBCachedContact* CheckMeta(MCONTACT hMeta)
+{
+ 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;
+
+ return -1;
+}
+
+MCONTACT Meta_GetContactHandle(DBCachedContact *cc, int contact_number)
+{
+ if (contact_number >= cc->nSubs || contact_number < 0)
+ return 0;
+
+ return cc->pSubs[contact_number];
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// metacontacts
+
+MIR_CORE_DLL(int) db_mc_isMeta(MCONTACT hContact)
+{
+ if (currDb == NULL) return false;
+
+ DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
+ return (cc == NULL) ? false : cc->nSubs != -1;
+}
+
+MIR_CORE_DLL(int) db_mc_isSub(MCONTACT hContact)
+{
+ if (currDb == NULL) return false;
+
+ DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
+ return (cc == NULL) ? false : cc->parentID != 0;
+}
+
+//returns a handle to the default contact, or null on failure
+MIR_CORE_DLL(MCONTACT) db_mc_getDefault(MCONTACT hMetaContact)
+{
+ DBCachedContact *cc = CheckMeta(hMetaContact);
+ if (cc == NULL)
+ return 0;
+
+ return (cc->nDefault != -1) ? Meta_GetContactHandle(cc, cc->nDefault) : 0;
+}
+
+//returns the default contact number, or -1 on failure
+MIR_CORE_DLL(int) db_mc_getDefaultNum(MCONTACT hMetaContact)
+{
+ DBCachedContact *cc = CheckMeta(hMetaContact);
+ return (cc == NULL) ? -1 : cc->nDefault;
+}
+
+//returns the number of subcontacts, or -1 on failure
+MIR_CORE_DLL(int) db_mc_getSubCount(MCONTACT hMetaContact)
+{
+ DBCachedContact *cc = CheckMeta(hMetaContact);
+ return (cc == NULL) ? -1 : cc->nSubs;
+}
+
+// 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;
+
+ DBCachedContact *cc = currDb->m_cache->GetCachedContact(hSubContact);
+ return (cc == NULL) ? NULL : cc->parentID;
+}
+
+// returns a subcontact with the given index
+MIR_CORE_DLL(MCONTACT) db_mc_getSub(MCONTACT hMetaContact, int iNum)
+{
+ DBCachedContact *cc = CheckMeta(hMetaContact);
+ return (cc == NULL) ? 0 : Meta_GetContactHandle(cc, iNum);
+}
+
+//sets the default contact, using the subcontact's handle
+MIR_CORE_DLL(int) db_mc_setDefault(MCONTACT hMetaContact, MCONTACT hSub)
+{
+ DBCachedContact *cc = CheckMeta(hMetaContact);
+ if (cc == NULL)
+ return 1;
+
+ int contact_number = Meta_GetContactNumber(cc, hSub);
+ if (contact_number == -1)
+ return 1;
+
+ cc->nDefault = contact_number;
+ 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)
+{
+ DBCachedContact *cc = CheckMeta(hMetaContact);
+ if (cc == NULL)
+ return 1;
+ if (iNum >= cc->nSubs || iNum < 0)
+ return 1;
+
+ cc->nDefault = iNum;
+ currDb->MetaSetDefault(cc);
+
+ NotifyEventHooks(hEventDefaultChanged, hMetaContact, Meta_GetContactHandle(cc, iNum));
+ return 0;
+}
diff --git a/src/mir_core/mir_core.def b/src/mir_core/mir_core.def
index 0d8eaf3e21..647a78b946 100644
--- a/src/mir_core/mir_core.def
+++ b/src/mir_core/mir_core.def
@@ -252,3 +252,9 @@ db_mc_isMeta @249
db_mc_isSub @250
db_mc_getMeta @251
db_get_contact @252
+db_mc_getDefault @253
+db_mc_getDefaultNum @254
+db_mc_getSubCount @255
+db_mc_getSub @256
+db_mc_setDefault @257
+db_mc_setDefaultNum @258
diff --git a/src/mir_core/mir_core_10.vcxproj b/src/mir_core/mir_core_10.vcxproj
index f6f3f987db..2c3799288b 100644
--- a/src/mir_core/mir_core_10.vcxproj
+++ b/src/mir_core/mir_core_10.vcxproj
@@ -100,6 +100,7 @@
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="logger.cpp" />
+ <ClCompile Include="mc.cpp" />
<ClCompile Include="mstring.cpp" />
<ClCompile Include="protos.cpp" />
<ClCompile Include="stdafx.cpp">
diff --git a/src/mir_core/mir_core_10.vcxproj.filters b/src/mir_core/mir_core_10.vcxproj.filters
index b7a247b20b..1de8cfd829 100644
--- a/src/mir_core/mir_core_10.vcxproj.filters
+++ b/src/mir_core/mir_core_10.vcxproj.filters
@@ -106,6 +106,9 @@
<ClCompile Include="winver.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="mc.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="commonheaders.h">
diff --git a/src/mir_core/mir_core_12.vcxproj b/src/mir_core/mir_core_12.vcxproj
index c9926e96ef..fa8058a1df 100644
--- a/src/mir_core/mir_core_12.vcxproj
+++ b/src/mir_core/mir_core_12.vcxproj
@@ -96,6 +96,7 @@
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">../commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="logger.cpp" />
+ <ClCompile Include="mc.cpp" />
<ClCompile Include="mstring.cpp" />
<ClCompile Include="protos.cpp" />
<ClCompile Include="stdafx.cpp">
diff --git a/src/mir_core/mir_core_12.vcxproj.filters b/src/mir_core/mir_core_12.vcxproj.filters
index 3311ae3578..cf84f183a5 100644
--- a/src/mir_core/mir_core_12.vcxproj.filters
+++ b/src/mir_core/mir_core_12.vcxproj.filters
@@ -103,6 +103,9 @@
<ClCompile Include="winver.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="mc.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="commonheaders.h">
diff --git a/src/mir_core/miranda.cpp b/src/mir_core/miranda.cpp
index 639de6b0c1..8779dee996 100644
--- a/src/mir_core/miranda.cpp
+++ b/src/mir_core/miranda.cpp
@@ -35,6 +35,7 @@ void InitLogs();
void UninitLogs();
void InitWinver();
+void InitMetaContacts();
int hLangpack = 0;
HINSTANCE hInst = 0;
@@ -93,6 +94,7 @@ static void LoadCoreModule(void)
InitLogs();
InitialiseModularEngine();
InitProtocols();
+ InitMetaContacts();
}
MIR_CORE_DLL(void) UnloadCoreModule(void)
diff --git a/src/mir_core/miranda.h b/src/mir_core/miranda.h
index 122d9fe21d..dc3d055cc0 100644
--- a/src/mir_core/miranda.h
+++ b/src/mir_core/miranda.h
@@ -42,6 +42,7 @@ extern HINSTANCE hInst;
extern HWND hAPCWindow;
extern HANDLE hStackMutex, hThreadQueueEmpty;
extern bool g_bDebugMode;
+extern MIDatabase *currDb;
/**** modules.cpp **********************************************************************/
diff --git a/src/miranda32_10.vcxproj b/src/miranda32_10.vcxproj
index b5defb0ab5..2980ebe9ff 100644
--- a/src/miranda32_10.vcxproj
+++ b/src/miranda32_10.vcxproj
@@ -237,6 +237,7 @@
<ClInclude Include="..\include\m_json.h" />
<ClInclude Include="..\include\m_langpack.h" />
<ClInclude Include="..\include\m_message.h" />
+ <ClInclude Include="..\include\m_metacontacts.h" />
<ClInclude Include="..\include\m_netlib.h" />
<ClInclude Include="..\include\m_options.h" />
<ClInclude Include="..\include\m_popup.h" />
diff --git a/src/miranda32_10.vcxproj.filters b/src/miranda32_10.vcxproj.filters
index 85eab76f51..69b91ede81 100644
--- a/src/miranda32_10.vcxproj.filters
+++ b/src/miranda32_10.vcxproj.filters
@@ -264,6 +264,9 @@
<ClInclude Include="modules\metacontacts\metacontacts.h">
<Filter>Modules\metacontacts</Filter>
</ClInclude>
+ <ClInclude Include="..\include\m_metacontacts.h">
+ <Filter>Modules\metacontacts</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="core\commonheaders.cpp">
diff --git a/src/modules/metacontacts/meta_api.cpp b/src/modules/metacontacts/meta_api.cpp
index 553a6cbd6e..beca03b5ec 100644
--- a/src/modules/metacontacts/meta_api.cpp
+++ b/src/modules/metacontacts/meta_api.cpp
@@ -24,34 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "metacontacts.h"
-// gets the handle for the default contact
-// wParam=(MCONTACT)hMetaContact
-// lParam=0
-// returns a handle to the default contact, or null on failure
-
-static INT_PTR MetaAPI_GetDefault(WPARAM hMetaContact, LPARAM)
-{
- DBCachedContact *cc = CheckMeta(hMetaContact);
- if (cc == NULL)
- return 1;
-
- if (cc->nDefault != -1)
- return Meta_GetContactHandle(cc, cc->nDefault);
-
- return 0;
-}
-
-// gets the contact number for the default contact
-// wParam=(MCONTACT)hMetaContact
-// lParam=0
-// returns a DWORD contact number, or -1 on failure
-
-static INT_PTR MetaAPI_GetDefaultNum(WPARAM hMetaContact, LPARAM)
-{
- DBCachedContact *cc = CheckMeta(hMetaContact);
- return (cc == NULL) ? -1 : cc->nDefault;
-}
-
// gets the handle for the 'most online' contact
// wParam=(MCONTACT)hMetaContact
// lParam=0
@@ -66,70 +38,6 @@ static INT_PTR MetaAPI_GetMostOnline(WPARAM hMetaContact, LPARAM)
return Meta_GetMostOnline(cc);
}
-// gets the number of subcontacts for a metacontact
-// wParam=(MCONTACT)hMetaContact
-// lParam=0
-// returns a DWORD representing the number of subcontacts for the given metacontact
-
-static INT_PTR MetaAPI_GetNumContacts(WPARAM hMetaContact, LPARAM)
-{
- DBCachedContact *cc = CheckMeta(hMetaContact);
- return (cc == NULL) ? -1 : cc->nSubs;
-}
-
-// gets the handle of a subcontact, using the subcontact's number
-// wParam=(MCONTACT)hMetaContact
-// lParam=(DWORD)contact number
-// returns a handle to the specified subcontact
-
-static INT_PTR MetaAPI_GetContact(WPARAM hMetaContact, LPARAM lParam)
-{
- DBCachedContact *cc = CheckMeta(hMetaContact);
- return (cc == NULL) ? 0 : Meta_GetContactHandle(cc, lParam);
-}
-
-// sets the default contact, using the subcontact's contact number
-// wParam=(MCONTACT)hMetaContact
-// lParam=(DWORD)contact number
-// returns 0 on success
-
-static INT_PTR MetaAPI_SetDefaultContactNum(WPARAM hMetaContact, LPARAM lParam)
-{
- DBCachedContact *cc = CheckMeta(hMetaContact);
- if (cc == NULL)
- return 1;
- if ((int)lParam >= cc->nSubs || (int)lParam < 0)
- return 1;
-
- cc->nDefault = lParam;
- currDb->MetaSetDefault(cc);
-
- NotifyEventHooks(hEventDefaultChanged, hMetaContact, Meta_GetContactHandle(cc, (int)lParam));
- return 0;
-}
-
-// sets the default contact, using the subcontact's handle
-// wParam=(MCONTACT)hMetaContact
-// lParam=(MCONTACT)hSubcontact
-// returns 0 on success
-
-static INT_PTR MetaAPI_SetDefaultContact(WPARAM hMetaContact, LPARAM lParam)
-{
- DBCachedContact *cc = CheckMeta(hMetaContact);
- if (cc == NULL)
- return 1;
-
- int contact_number = Meta_GetContactNumber(cc, lParam);
- if (contact_number == -1)
- return 1;
-
- cc->nDefault = contact_number;
- currDb->MetaSetDefault(cc);
-
- NotifyEventHooks(hEventDefaultChanged, hMetaContact, lParam);
- return 0;
-}
-
// forces the metacontact to send using a specific subcontact, using the subcontact's contact number
// wParam=(MCONTACT)hMetaContact
// lParam=(DWORD)contact number
@@ -264,13 +172,7 @@ static INT_PTR MetaAPI_RemoveFromMeta(WPARAM wParam, LPARAM lParam)
void CreateApiServices()
{
- CreateServiceFunction(MS_MC_GETDEFAULTCONTACT, MetaAPI_GetDefault);
- CreateServiceFunction(MS_MC_GETDEFAULTCONTACTNUM, MetaAPI_GetDefaultNum);
CreateServiceFunction(MS_MC_GETMOSTONLINECONTACT, MetaAPI_GetMostOnline);
- CreateServiceFunction(MS_MC_GETNUMCONTACTS, MetaAPI_GetNumContacts);
- CreateServiceFunction(MS_MC_GETSUBCONTACT, MetaAPI_GetContact);
- CreateServiceFunction(MS_MC_SETDEFAULTCONTACTNUM, MetaAPI_SetDefaultContactNum);
- CreateServiceFunction(MS_MC_SETDEFAULTCONTACT, MetaAPI_SetDefaultContact);
CreateServiceFunction(MS_MC_FORCESENDCONTACTNUM, MetaAPI_ForceSendContactNum);
CreateServiceFunction(MS_MC_FORCESENDCONTACT, MetaAPI_ForceSendContact);
CreateServiceFunction(MS_MC_UNFORCESENDCONTACT, MetaAPI_UnforceSendContact);
diff --git a/src/modules/metacontacts/meta_edit.cpp b/src/modules/metacontacts/meta_edit.cpp
index 409d2d8d97..c950ca2569 100644
--- a/src/modules/metacontacts/meta_edit.cpp
+++ b/src/modules/metacontacts/meta_edit.cpp
@@ -148,9 +148,7 @@ static void ApplyChanges()
NotifyEventHooks(hSubcontactsChanged, g_data.hMeta, g_data.hDefaultContact);
// set default
- g_data.cc->nDefault = (g_data.hDefaultContact) ? Meta_GetContactNumber(g_data.cc, g_data.hDefaultContact) : 0;
- currDb->MetaSetDefault(g_data.cc);
- NotifyEventHooks(hEventDefaultChanged, g_data.hMeta, g_data.hDefaultContact);
+ db_mc_setDefaultNum(g_data.hMeta, (g_data.hDefaultContact) ? Meta_GetContactNumber(g_data.cc, g_data.hDefaultContact) : 0);
// set offline
if (g_data.hOfflineContact)
diff --git a/src/modules/metacontacts/meta_menu.cpp b/src/modules/metacontacts/meta_menu.cpp
index 8524c1cdf0..c71c452c81 100644
--- a/src/modules/metacontacts/meta_menu.cpp
+++ b/src/modules/metacontacts/meta_menu.cpp
@@ -131,12 +131,10 @@ void Meta_RemoveContactNumber(DBCachedContact *ccMeta, int number, bool bUpdateI
// if the default contact was equal to or greater than 'number', decrement it (and deal with ends)
if (ccMeta->nDefault >= number) {
- ccMeta->nDefault--;
- if (ccMeta->nDefault < 0)
- ccMeta->nDefault = 0;
-
- currDb->MetaSetDefault(ccMeta);
- NotifyEventHooks(hEventDefaultChanged, ccMeta->contactID, Meta_GetContactHandle(ccMeta, ccMeta->nDefault));
+ int iNumber = ccMeta->nDefault-1;
+ if (iNumber < 0)
+ iNumber = 0;
+ db_mc_setDefaultNum(ccMeta->contactID, iNumber);
}
ccMeta->nSubs--;
@@ -221,11 +219,8 @@ INT_PTR Meta_Delete(WPARAM hContact, LPARAM bSkipQuestion)
INT_PTR Meta_Default(WPARAM hSub, LPARAM wParam)
{
DBCachedContact *cc = currDb->m_cache->GetCachedContact(db_mc_getMeta(hSub));
- if (cc && cc->IsMeta()) {
- cc->nDefault = Meta_GetContactNumber(cc, hSub);
- currDb->MetaSetDefault(cc);
- NotifyEventHooks(hEventDefaultChanged, cc->contactID, hSub);
- }
+ if (cc && cc->IsMeta())
+ db_mc_setDefault(cc->contactID, hSub);
return 0;
}
diff --git a/src/modules/metacontacts/meta_services.cpp b/src/modules/metacontacts/meta_services.cpp
index 467b4c4620..0f08521b0c 100644
--- a/src/modules/metacontacts/meta_services.cpp
+++ b/src/modules/metacontacts/meta_services.cpp
@@ -34,7 +34,6 @@ int previousMode, // Previous status of the MetaContacts Protocol
mcStatus; // Current status of the MetaContacts Protocol
HANDLE
- hEventDefaultChanged, // HANDLE to the 'default changed' event
hEventForceSend, // HANDLE to the 'force send' event
hEventUnforceSend, // HANDLE to the 'unforce send' event
hSubcontactsChanged, // HANDLE to the 'contacts changed' event
@@ -672,9 +671,7 @@ INT_PTR Meta_ContactMenuFunc(WPARAM hMeta, LPARAM lParam)
int caps = CallService(buffer, PFLAGNUM_1, 0);
if ((caps & PF1_IMSEND) || (caps & PF1_CHAT) || (proto && strcmp(proto, "IRC") == 0)) {
// set default contact for sending/status and open message window
- cc->nDefault = (int)lParam;
- currDb->MetaSetDefault(cc);
- NotifyEventHooks(hEventDefaultChanged, hMeta, (LPARAM)hContact);
+ db_mc_setDefaultNum(hMeta, lParam);
CallService(MS_MSG_SENDMESSAGE, hMeta, 0);
}
else // protocol does not support messaging - simulate double click
@@ -875,7 +872,6 @@ void Meta_InitServices()
CreateProtoServiceFunction(META_PROTO, PS_SEND_NUDGE, Meta_SendNudge);
// create our hookable events
- hEventDefaultChanged = CreateHookableEvent(ME_MC_DEFAULTTCHANGED);
hEventForceSend = CreateHookableEvent(ME_MC_FORCESEND);
hEventUnforceSend = CreateHookableEvent(ME_MC_UNFORCESEND);
hSubcontactsChanged = CreateHookableEvent(ME_MC_SUBCONTACTSCHANGED);
@@ -902,7 +898,6 @@ void Meta_InitServices()
void Meta_CloseHandles()
{
// destroy our hookable events
- DestroyHookableEvent(hEventDefaultChanged);
DestroyHookableEvent(hEventForceSend);
DestroyHookableEvent(hEventUnforceSend);
DestroyHookableEvent(hSubcontactsChanged);
diff --git a/src/modules/metacontacts/meta_utils.cpp b/src/modules/metacontacts/meta_utils.cpp
index 990e3e10b4..8c32e25105 100644
--- a/src/modules/metacontacts/meta_utils.cpp
+++ b/src/modules/metacontacts/meta_utils.cpp
@@ -180,11 +180,8 @@ BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default)
ccDest->pSubs[ccDest->nSubs - 1] = hSub;
ccSub->parentID = hMeta;
- if (set_as_default) {
- ccDest->nDefault = ccDest->nSubs - 1;
- currDb->MetaSetDefault(ccDest);
- NotifyEventHooks(hEventDefaultChanged, hMeta, hSub);
- }
+ if (set_as_default)
+ db_mc_setDefaultNum(hMeta, ccDest->nSubs-1);
// set nick to most online contact that can message
MCONTACT most_online = Meta_GetMostOnline(ccDest);
diff --git a/src/modules/metacontacts/metacontacts.h b/src/modules/metacontacts/metacontacts.h
index d4dab57a54..df70f7ed4b 100644
--- a/src/modules/metacontacts/metacontacts.h
+++ b/src/modules/metacontacts/metacontacts.h
@@ -114,7 +114,7 @@ typedef enum {I_MENUOFF, I_MENU, I_CONVERT, I_ADD, I_EDIT, I_SETDEFAULT, I_REMOV
HICON LoadIconEx(IconIndex i);
HANDLE GetIconHandle(IconIndex i);
-extern HANDLE hEventDefaultChanged, hEventForceSend, hEventUnforceSend, hSubcontactsChanged;
+extern HANDLE hEventForceSend, hEventUnforceSend, hSubcontactsChanged;
extern POINT menuMousePoint;
#define MAX_PROTOCOLS 20