summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-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
6 files changed, 11 insertions, 124 deletions
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