diff options
author | George Hazan <george.hazan@gmail.com> | 2014-03-02 20:06:10 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-03-02 20:06:10 +0000 |
commit | e27f1addc43bdfeb896081ecca5e0b52e9e6179a (patch) | |
tree | cafb3b02fbf0f5c2b6085d82af212c05da60a2c7 /src | |
parent | 79939e2f78e89f4581cfbcc19818c756ece26ad6 (diff) |
current mc state
git-svn-id: http://svn.miranda-ng.org/main/trunk@8362 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/metacontacts/meta_addto.cpp | 6 | ||||
-rw-r--r-- | src/modules/metacontacts/meta_api.cpp | 88 | ||||
-rw-r--r-- | src/modules/metacontacts/meta_edit.cpp | 6 | ||||
-rw-r--r-- | src/modules/metacontacts/meta_main.cpp | 16 | ||||
-rw-r--r-- | src/modules/metacontacts/meta_menu.cpp | 18 | ||||
-rw-r--r-- | src/modules/metacontacts/meta_services.cpp | 166 | ||||
-rw-r--r-- | src/modules/metacontacts/meta_utils.cpp | 494 | ||||
-rw-r--r-- | src/modules/metacontacts/metacontacts.h | 1 |
8 files changed, 289 insertions, 506 deletions
diff --git a/src/modules/metacontacts/meta_addto.cpp b/src/modules/metacontacts/meta_addto.cpp index 59abb1d452..dfef8291b5 100644 --- a/src/modules/metacontacts/meta_addto.cpp +++ b/src/modules/metacontacts/meta_addto.cpp @@ -57,7 +57,7 @@ int FillList(HWND list, BOOL sort) // The DB is searched through, to get all the metacontacts
for (MCONTACT hMetaUser = db_find_first(); hMetaUser; hMetaUser = db_find_next(hMetaUser)) {
// if it's not a MetaContact, go to the next
- if ( db_get_dw(hMetaUser, META_PROTO, META_ID, (DWORD)-1) == (DWORD)-1)
+ if ( db_get_dw(hMetaUser, META_PROTO, META_ID, INVALID_CONTACT_ID) == INVALID_CONTACT_ID)
continue;
// get contact display name from clist
@@ -123,7 +123,7 @@ INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP case WM_INITDIALOG:
TranslateDialogDefault( hwndDlg );
- if ( db_get_dw(lParam, META_PROTO, META_ID, (DWORD)-1) != (DWORD)-1) {
+ if ( db_get_dw(lParam, META_PROTO, META_ID, INVALID_CONTACT_ID) != INVALID_CONTACT_ID) {
MessageBox(hwndDlg,
TranslateT("This contact is a MetaContact.\nYou can't add a MetaContact to another MetaContact.\n\nPlease choose another."),
TranslateT("MetaContact Conflict"),MB_ICONERROR);
@@ -131,7 +131,7 @@ INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP return TRUE;
}
- if ( db_get_dw(lParam, META_PROTO, META_LINK, (DWORD)-1) != (DWORD)-1) {
+ if ( db_get_dw(lParam, META_PROTO, META_LINK, INVALID_CONTACT_ID) != INVALID_CONTACT_ID) {
MessageBox(hwndDlg,
TranslateT("This contact is already associated to a MetaContact.\nYou cannot add a contact to multiple MetaContacts."),
TranslateT("Multiple MetaContacts"),MB_ICONERROR);
diff --git a/src/modules/metacontacts/meta_api.cpp b/src/modules/metacontacts/meta_api.cpp index 701540deae..1d94f15be9 100644 --- a/src/modules/metacontacts/meta_api.cpp +++ b/src/modules/metacontacts/meta_api.cpp @@ -25,55 +25,61 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "metacontacts.h"
//gets the handle for the default contact
-//wParam=(HANDLE)hMetaContact
+//wParam=(MCONTACT)hMetaContact
//lParam=0
//returns a handle to the default contact, or null on failure
-INT_PTR MetaAPI_GetDefault(WPARAM wParam, LPARAM lParam) {
+INT_PTR MetaAPI_GetDefault(WPARAM wParam, LPARAM lParam)
+{
DWORD default_contact_number = db_get_dw(wParam, META_PROTO, "Default", -1);
- if (default_contact_number != -1) {
+ if (default_contact_number != -1)
return (INT_PTR)Meta_GetContactHandle(wParam, default_contact_number);
- }
+
return 0;
}
//gets the contact number for the default contact
-//wParam=(HANDLE)hMetaContact
+//wParam=(MCONTACT)hMetaContact
//lParam=0
//returns a DWORD contact number, or -1 on failure
-INT_PTR MetaAPI_GetDefaultNum(WPARAM wParam, LPARAM lParam) {
+INT_PTR MetaAPI_GetDefaultNum(WPARAM wParam, LPARAM lParam)
+{
return db_get_dw(wParam, META_PROTO, "Default", -1);
}
//gets the handle for the 'most online' contact
-//wParam=(HANDLE)hMetaContact
+//wParam=(MCONTACT)hMetaContact
//lParam=0
//returns a handle to the 'most online' contact
-INT_PTR MetaAPI_GetMostOnline(WPARAM wParam, LPARAM lParam) {
+INT_PTR MetaAPI_GetMostOnline(WPARAM wParam, LPARAM lParam)
+{
return (INT_PTR)Meta_GetMostOnline(wParam);
}
//gets the number of subcontacts for a metacontact
-//wParam=(HANDLE)hMetaContact
+//wParam=(MCONTACT)hMetaContact
//lParam=0
//returns a DWORD representing the number of subcontacts for the given metacontact
-INT_PTR MetaAPI_GetNumContacts(WPARAM wParam, LPARAM lParam) {
+INT_PTR MetaAPI_GetNumContacts(WPARAM wParam, LPARAM lParam)
+{
DWORD num_contacts = db_get_dw(wParam, META_PROTO, "NumContacts", -1);
return num_contacts;
}
//gets the handle of a subcontact, using the subcontact's number
-//wParam=(HANDLE)hMetaContact
+//wParam=(MCONTACT)hMetaContact
//lParam=(DWORD)contact number
//returns a handle to the specified subcontact
-INT_PTR MetaAPI_GetContact(WPARAM wParam, LPARAM lParam) {
+INT_PTR MetaAPI_GetContact(WPARAM wParam, LPARAM lParam)
+{
return (INT_PTR)Meta_GetContactHandle(wParam, (DWORD)lParam);
}
//sets the default contact, using the subcontact's contact number
-//wParam=(HANDLE)hMetaContact
+//wParam=(MCONTACT)hMetaContact
//lParam=(DWORD)contact number
//returns 0 on success
-INT_PTR MetaAPI_SetDefaultContactNum(WPARAM wParam, LPARAM lParam) {
+INT_PTR MetaAPI_SetDefaultContactNum(WPARAM wParam, LPARAM lParam)
+{
DWORD num_contacts = db_get_dw(wParam, META_PROTO, "NumContacts", -1);
if (num_contacts == -1)
return 1;
@@ -87,10 +93,11 @@ INT_PTR MetaAPI_SetDefaultContactNum(WPARAM wParam, LPARAM lParam) { }
//sets the default contact, using the subcontact's handle
-//wParam=(HANDLE)hMetaContact
+//wParam=(MCONTACT)hMetaContact
//lParam=(HANDLE)hSubcontact
//returns 0 on success
-INT_PTR MetaAPI_SetDefaultContact(WPARAM wParam, LPARAM lParam) {
+INT_PTR MetaAPI_SetDefaultContact(WPARAM wParam, LPARAM lParam)
+{
MCONTACT hMeta = (MCONTACT)db_get_dw(lParam, META_PROTO, "Handle", 0);
DWORD contact_number = Meta_GetContactNumber(lParam);
if (contact_number == -1 || !hMeta || hMeta != wParam)
@@ -103,10 +110,11 @@ INT_PTR MetaAPI_SetDefaultContact(WPARAM wParam, LPARAM lParam) { }
//forces the metacontact to send using a specific subcontact, using the subcontact's contact number
-//wParam=(HANDLE)hMetaContact
+//wParam=(MCONTACT)hMetaContact
//lParam=(DWORD)contact number
//returns 0 on success
-INT_PTR MetaAPI_ForceSendContactNum(WPARAM wParam, LPARAM lParam) {
+INT_PTR MetaAPI_ForceSendContactNum(WPARAM wParam, LPARAM lParam)
+{
MCONTACT hContact = Meta_GetContactHandle(wParam, (int)lParam);
MCONTACT hMeta = (MCONTACT)db_get_dw(hContact, META_PROTO, "Handle", 0);
if (!hContact || !hMeta || hMeta != wParam || db_get_b(hMeta, META_PROTO, "ForceDefault", 0))
@@ -119,10 +127,11 @@ INT_PTR MetaAPI_ForceSendContactNum(WPARAM wParam, LPARAM lParam) { }
//forces the metacontact to send using a specific subcontact, using the subcontact's handle
-//wParam=(HANDLE)hMetaContact
+//wParam=(MCONTACT)hMetaContact
//lParam=(HANDLE)hSubcontact
//returns 0 on success (will fail if 'force default' is in effect)
-INT_PTR MetaAPI_ForceSendContact(WPARAM wParam, LPARAM lParam) {
+INT_PTR MetaAPI_ForceSendContact(WPARAM wParam, LPARAM lParam)
+{
MCONTACT hContact = lParam;
MCONTACT hMeta = (MCONTACT)db_get_dw(hContact, META_PROTO, "Handle", 0);
if (!hContact || !hMeta || hMeta != wParam || db_get_b(hMeta, META_PROTO, "ForceDefault", 0))
@@ -135,10 +144,11 @@ INT_PTR MetaAPI_ForceSendContact(WPARAM wParam, LPARAM lParam) { }
//'unforces' the metacontact to send using a specific subcontact
-//wParam=(HANDLE)hMetaContact
+//wParam=(MCONTACT)hMetaContact
//lParam=0
//returns 0 on success (will fail if 'force default' is in effect)
-INT_PTR MetaAPI_UnforceSendContact(WPARAM wParam, LPARAM lParam) {
+INT_PTR MetaAPI_UnforceSendContact(WPARAM wParam, LPARAM lParam)
+{
if (db_get_b(wParam, META_PROTO, "ForceDefault", 0))
return 1;
@@ -152,22 +162,24 @@ INT_PTR MetaAPI_UnforceSendContact(WPARAM wParam, LPARAM lParam) { //'forces' or 'unforces' (i.e. toggles) the metacontact to send using it's default contact
// overrides 'force send' above, and will even force use of offline contacts
// will send ME_MC_FORCESEND event
-//wParam=(HANDLE)hMetaContact
+//wParam=(MCONTACT)hMetaContact
//lParam=0
//returns 1(true) or 0(false) representing new state of 'force default'
-INT_PTR MetaAPI_ForceDefault(WPARAM wParam, LPARAM lParam) {
+INT_PTR MetaAPI_ForceDefault(WPARAM wParam, LPARAM lParam)
+{
// forward to menu function
Meta_ForceDefault(wParam, lParam);
return db_get_b(wParam, META_PROTO, "ForceDefault", 0);
}
// method to get state of 'force' for a metacontact
-// wParam=(HANDLE)hMetaContact
+// wParam=(MCONTACT)hMetaContact
// lParam= (DWORD)&contact_number or NULL
// if lparam supplied, the contact_number of the contatct 'in force' will be copied to the address it points to,
-// or if none is in force, the value (DWORD)-1 will be copied
+// or if none is in force, the value INVALID_CONTACT_ID will be copied
// (v0.8.0.8+ returns 1 if 'force default' is true with *lParam == default contact number, else returns 0 with *lParam as above)
-INT_PTR MetaAPI_GetForceState(WPARAM wParam, LPARAM lParam) {
+INT_PTR MetaAPI_GetForceState(WPARAM wParam, LPARAM lParam)
+{
MCONTACT hMeta = wParam;
if ( !hMeta) return 0;
@@ -191,7 +203,8 @@ INT_PTR MetaAPI_GetForceState(WPARAM wParam, LPARAM lParam) { // wParam=(HANDLE)hContact
// lParam=0
// convert a given contact into a metacontact
-INT_PTR MetaAPI_ConvertToMeta(WPARAM wParam, LPARAM lParam) {
+INT_PTR MetaAPI_ConvertToMeta(WPARAM wParam, LPARAM lParam)
+{
return Meta_Convert(wParam, lParam);
}
@@ -199,7 +212,8 @@ INT_PTR MetaAPI_ConvertToMeta(WPARAM wParam, LPARAM lParam) { // wParam=(HANDLE)hContact
// lParam=(HANDLE)hMeta
// add an existing contact to a metacontact
-INT_PTR MetaAPI_AddToMeta(WPARAM wParam, LPARAM lParam) {
+INT_PTR MetaAPI_AddToMeta(WPARAM wParam, LPARAM lParam)
+{
return Meta_Assign(wParam, lParam, FALSE);
}
@@ -207,20 +221,8 @@ INT_PTR MetaAPI_AddToMeta(WPARAM wParam, LPARAM lParam) { // wParam=0
// lParam=(HANDLE)hContact
// remove a contact from a metacontact
-INT_PTR MetaAPI_RemoveFromMeta(WPARAM wParam, LPARAM lParam) {
+INT_PTR MetaAPI_RemoveFromMeta(WPARAM wParam, LPARAM lParam)
+{
// notice we switch args - to keep the API function consistent with the others
return Meta_Delete((WPARAM)lParam, (LPARAM)wParam);
}
-
-// added 0.9.13.2 (6/10/05)
-// wParam=(BOOL)disable
-// lParam=0
-// enable/disable the 'hidden group hack' - for clists that support subcontact hiding using 'IsSubcontact' setting
-// should be called once in your 'onmodulesloaded' event handler
-
-BOOL meta_group_hack_disabled = FALSE; // this global flag is used in utils 'SetGroup' function
-
-INT_PTR MetaAPI_DisableHiddenGroup(WPARAM wParam, LPARAM lParam) {
- meta_group_hack_disabled = (BOOL)wParam;
- return 0;
-}
diff --git a/src/modules/metacontacts/meta_edit.cpp b/src/modules/metacontacts/meta_edit.cpp index 25ff77a22e..5fda2d5f8e 100644 --- a/src/modules/metacontacts/meta_edit.cpp +++ b/src/modules/metacontacts/meta_edit.cpp @@ -161,7 +161,7 @@ void ApplyChanges(CHANGES *chg) if (chg->hOfflineContact)
db_set_dw(chg->hMeta, META_PROTO, "OfflineSend", Meta_GetContactNumber(chg->hOfflineContact));
else
- db_set_dw(chg->hMeta, META_PROTO, "OfflineSend", (DWORD)-1);
+ db_set_dw(chg->hMeta, META_PROTO, "OfflineSend", INVALID_CONTACT_ID);
// fix nick
MCONTACT most_online = Meta_GetMostOnline(chg->hMeta);
@@ -268,8 +268,8 @@ INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DOWN), FALSE);
int nb_contacts = db_get_dw(lParam, META_PROTO, "NumContacts", 0);
- int default_contact_number = db_get_dw(lParam, META_PROTO, "Default", (DWORD)-1);
- int offline_contact_number = db_get_dw(lParam, META_PROTO, "OfflineSend", (DWORD)-1);
+ int default_contact_number = db_get_dw(lParam, META_PROTO, "Default", INVALID_CONTACT_ID);
+ int offline_contact_number = db_get_dw(lParam, META_PROTO, "OfflineSend", INVALID_CONTACT_ID);
changes.hMeta = lParam;
changes.num_contacts = nb_contacts;
diff --git a/src/modules/metacontacts/meta_main.cpp b/src/modules/metacontacts/meta_main.cpp index d802a14db3..0a1efc6d24 100644 --- a/src/modules/metacontacts/meta_main.cpp +++ b/src/modules/metacontacts/meta_main.cpp @@ -73,22 +73,6 @@ int LoadMetacontacts(void) Meta_ReadOptions(&options);
- // sets subcontact handles to metacontacts, and metacontact handles to subcontacts
- // (since these handles are not necessarily the same from run to run of miranda)
-
- // also verifies that subcontacts: have metacontacts, and that contact numbers are reasonable,
- // that metacontacts: have the correct number of subcontacts, and have reasonable defaults
- if (Meta_SetHandles()) {
- // error - db corruption
- if ( !db_get_b(0, META_PROTO, "DisabledMessageShown", 0)) {
- MessageBox(0, TranslateT("Error - Database corruption.\nPlugin disabled."), TranslateT("MetaContacts"), MB_OK | MB_ICONERROR);
- db_set_b(0, META_PROTO, "DisabledMessageShown", 1);
- }
- return 1;
- }
-
- db_unset(0, META_PROTO, "DisabledMessageShown");
-
PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE };
pd.szName = META_FILTER;
pd.type = PROTOTYPE_FILTER;
diff --git a/src/modules/metacontacts/meta_menu.cpp b/src/modules/metacontacts/meta_menu.cpp index 7fbcf128a7..9647ad1642 100644 --- a/src/modules/metacontacts/meta_menu.cpp +++ b/src/modules/metacontacts/meta_menu.cpp @@ -127,11 +127,10 @@ void Meta_RemoveContactNumber(MCONTACT hMeta, int number) MCONTACT hContact = Meta_GetContactHandle(hMeta, number);
// make sure this contact thinks it's part of this metacontact
- if ((MCONTACT)db_get_dw(hContact, META_PROTO, "Handle", 0) == hMeta) {
+ if (db_get_dw(hContact, META_PROTO, "Handle", 0) == hMeta) {
// remove link to meta contact
db_unset(hContact, META_PROTO, META_LINK);
db_unset(hContact, META_PROTO, "Handle");
- db_unset(hContact, META_PROTO, "ContactNumber");
// unhide - must be done after removing link (see meta_services.c:Meta_ChangeStatus)
Meta_RestoreGroup(hContact);
db_unset(hContact, META_PROTO, "OldCListGroup");
@@ -216,7 +215,7 @@ INT_PTR Meta_Delete(WPARAM wParam, LPARAM lParam) DWORD metaID;
// The wParam is a metacontact
- if ((metaID = db_get_dw(wParam, META_PROTO, META_ID, (DWORD)-1)) != (DWORD)-1) {
+ if ((metaID = db_get_dw(wParam, META_PROTO, META_ID, INVALID_CONTACT_ID)) != INVALID_CONTACT_ID) {
if (!lParam) { // check from recursion - see second half of this function
if (MessageBox((HWND)CallService(MS_CLUI_GETHWND, 0, 0),
TranslateT("This will remove the MetaContact permanently.\n\nProceed Anyway?"),
@@ -226,10 +225,9 @@ INT_PTR Meta_Delete(WPARAM wParam, LPARAM lParam) for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
// This contact is assigned to the MetaContact that will be deleted, clear the "MetaContacts" information
- if (db_get_dw(hContact, META_PROTO, META_LINK, (DWORD)-1) == metaID) {
+ if (db_get_dw(hContact, META_PROTO, META_LINK, INVALID_CONTACT_ID) == metaID) {
db_unset(hContact, META_PROTO, META_LINK);
db_unset(hContact, META_PROTO, "Handle");
- db_unset(hContact, META_PROTO, "ContactNumber");
// unhide - must be done after removing link (see meta_services.c:Meta_ChangeStatus)
Meta_RestoreGroup(hContact);
@@ -255,7 +253,7 @@ INT_PTR Meta_Delete(WPARAM wParam, LPARAM lParam) return 0;
}
- Meta_RemoveContactNumber(hMeta, db_get_dw(wParam, META_PROTO, "ContactNumber", -1));
+ Meta_RemoveContactNumber(hMeta, wParam); // !!!!!!!!!!!!!!!!!!!!!!!!!
}
return 0;
}
@@ -292,7 +290,7 @@ INT_PTR Meta_Default(WPARAM wParam, LPARAM lParam) INT_PTR Meta_ForceDefault(WPARAM wParam, LPARAM lParam)
{
// the wParam is a MetaContact
- if (db_get_dw(wParam, META_PROTO, META_ID, (DWORD)-1) != (DWORD)-1) {
+ if (db_get_dw(wParam, META_PROTO, META_ID, INVALID_CONTACT_ID) != INVALID_CONTACT_ID) {
BOOL current = db_get_b(wParam, META_PROTO, "ForceDefault", 0);
current = !current;
db_set_b(wParam, META_PROTO, "ForceDefault", (BYTE)current);
@@ -321,7 +319,7 @@ int Meta_ModifyMenu(WPARAM wParam, LPARAM lParam) CLISTMENUITEM mi = { sizeof(mi) };
Menu_ShowItem(hMenuRoot, false);
- if (db_get_dw(wParam, META_PROTO, META_ID, -1) != (DWORD)-1) {
+ if (db_get_dw(wParam, META_PROTO, META_ID, -1) != INVALID_CONTACT_ID) {
// save the mouse pos in case they open a subcontact menu
GetCursorPos(&menuMousePoint);
@@ -404,7 +402,7 @@ int Meta_ModifyMenu(WPARAM wParam, LPARAM lParam) Menu_ShowItem(hMenuConvert, false);
Menu_ShowItem(hMenuEdit, false);
}
- else if (db_get_dw(wParam, META_PROTO, META_LINK, (DWORD)-1) != (DWORD)-1) {
+ else if (db_get_dw(wParam, META_PROTO, META_LINK, INVALID_CONTACT_ID) != INVALID_CONTACT_ID) {
// The contact is affected to a metacontact.
Menu_ShowItem(hMenuDefault, true);
@@ -521,7 +519,7 @@ void InitMenus() if (options.copydata) {
int meta_id;
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- if ((meta_id = db_get_dw(hContact, META_PROTO, META_ID, (DWORD)-1)) != (DWORD)-1)
+ if ((meta_id = db_get_dw(hContact, META_PROTO, META_ID, INVALID_CONTACT_ID)) != INVALID_CONTACT_ID)
Meta_CopyData(hContact);
}
diff --git a/src/modules/metacontacts/meta_services.cpp b/src/modules/metacontacts/meta_services.cpp index 04f3157e44..a9dd9832ee 100644 --- a/src/modules/metacontacts/meta_services.cpp +++ b/src/modules/metacontacts/meta_services.cpp @@ -271,7 +271,7 @@ INT_PTR Meta_SendMessage(WPARAM wParam,LPARAM lParam) char *proto = 0;
DWORD default_contact_number;
- if ((default_contact_number = db_get_dw(ccs->hContact, META_PROTO, "Default",(DWORD)-1)) == (DWORD)-1) {
+ if ((default_contact_number = db_get_dw(ccs->hContact, META_PROTO, "Default",INVALID_CONTACT_ID)) == INVALID_CONTACT_ID) {
// This is a simple contact, let through the stack of protocols
// (this should normally not happen, since linked contacts do not appear on the list.)
return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
@@ -354,7 +354,7 @@ INT_PTR MetaFilter_RecvMessage(WPARAM wParam,LPARAM lParam) return CallService(MS_PROTO_CHAINRECV, wParam, (LPARAM)ccs);
if (options.set_default_on_recv) {
- db_set_dw(hMeta, META_PROTO, "Default", db_get_dw(ccs->hContact, META_PROTO, "ContactNumber", 0));
+ db_set_dw(hMeta, META_PROTO, "Default", ccs->hContact);
NotifyEventHooks(hEventDefaultChanged, (WPARAM)hMeta, (LPARAM)ccs->hContact); // nick set in event handler
}
@@ -567,58 +567,44 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) return 0;
}
- if (wParam == 0
- && strcmp(dcws->szModule, "Import") == 0 && strcmp(dcws->szSetting, "Completed") == 0)
- {
- // import process has just been run...call startup routines...
- Meta_SetHandles();
-
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- int meta_id;
- if ((meta_id = db_get_dw(hContact, META_PROTO, META_ID,(DWORD)-1)) != (DWORD)-1)
- Meta_CopyData(hContact);
- }
-
- Meta_HideLinkedContacts();
- Meta_SuppressStatus(options.suppress_status);
- }
-
// from here on, we're just interested in contact settings
- if (wParam == 0) return 0;
+ if (wParam == 0)
+ return 0;
- if ((hMeta=(MCONTACT)db_get_dw(wParam, META_PROTO, "Handle",0))!=0 && CallService(MS_DB_CONTACT_IS, (WPARAM)hMeta, 0)) // just to be safe
+ if ((hMeta = (MCONTACT)db_get_dw(wParam, META_PROTO, "Handle", 0)) != 0 && CallService(MS_DB_CONTACT_IS, (WPARAM)hMeta, 0)) // just to be safe
{
// This contact is attached to a MetaContact.
contact_number = Meta_GetContactNumber(wParam);
if (contact_number == -1) return 0; // exit - db corruption
- if ( !meta_group_hack_disabled && !strcmp(dcws->szModule, "CList") && !strcmp(dcws->szSetting, "Group") &&
- Meta_IsEnabled() && db_get_b(wParam, META_PROTO, "Hidden", 0) == 0 && !Miranda_Terminated()) {
- if ((dcws->value.type == DBVT_ASCIIZ || dcws->value.type == DBVT_UTF8) && !Meta_IsHiddenGroup(dcws->value.pszVal)) {
- // subcontact group reassigned - copy to saved group
- db_set(wParam, META_PROTO, "OldCListGroup", &dcws->value);
- db_set_s(wParam, "CList", "Group", META_HIDDEN_GROUP);
- } else if (dcws->value.type == DBVT_DELETED) {
- db_unset(wParam, META_PROTO, "OldCListGroup");
- db_set_s(wParam, "CList", "Group", META_HIDDEN_GROUP);
- }
+ if (!meta_group_hack_disabled && !strcmp(dcws->szModule, "CList") && !strcmp(dcws->szSetting, "Group") &&
+ Meta_IsEnabled() && db_get_b(wParam, META_PROTO, "Hidden", 0) == 0 && !Miranda_Terminated()) {
+ if ((dcws->value.type == DBVT_ASCIIZ || dcws->value.type == DBVT_UTF8) && !Meta_IsHiddenGroup(dcws->value.pszVal)) {
+ // subcontact group reassigned - copy to saved group
+ db_set(wParam, META_PROTO, "OldCListGroup", &dcws->value);
+ db_set_s(wParam, "CList", "Group", META_HIDDEN_GROUP);
+ }
+ else if (dcws->value.type == DBVT_DELETED) {
+ db_unset(wParam, META_PROTO, "OldCListGroup");
+ db_set_s(wParam, "CList", "Group", META_HIDDEN_GROUP);
+ }
}
- else if ( !strcmp(dcws->szSetting, "IP")) {
+ else if (!strcmp(dcws->szSetting, "IP")) {
if (dcws->value.type == DBVT_DWORD)
db_set_dw(hMeta, META_PROTO, "IP", dcws->value.dVal);
else
db_unset(hMeta, META_PROTO, "IP");
}
- else if ( !strcmp(dcws->szSetting, "RealIP")) {
+ else if (!strcmp(dcws->szSetting, "RealIP")) {
if (dcws->value.type == DBVT_DWORD)
db_set_dw(hMeta, META_PROTO, "RealIP", dcws->value.dVal);
else
db_unset(hMeta, META_PROTO, "RealIP");
}
- else if ( !strcmp(dcws->szSetting, "ListeningTo")) {
- switch(dcws->value.type) {
+ else if (!strcmp(dcws->szSetting, "ListeningTo")) {
+ switch (dcws->value.type) {
case DBVT_ASCIIZ:
db_set_s(hMeta, META_PROTO, "ListeningTo", dcws->value.pszVal);
break;
@@ -633,7 +619,7 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) break;
}
}
- else if ( !strcmp(dcws->szSetting, "Nick") && !dcws->value.type == DBVT_DELETED) {
+ else if (!strcmp(dcws->szSetting, "Nick") && !dcws->value.type == DBVT_DELETED) {
// subcontact nick has changed - update metacontact
strcpy(buffer, "Nick");
strcat(buffer, _itoa(contact_number, szId, 10));
@@ -653,19 +639,19 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) return 0;
}
- else if ( !strcmp(dcws->szSetting, "IdleTS")) {
+ else if (!strcmp(dcws->szSetting, "IdleTS")) {
if (dcws->value.type == DBVT_DWORD)
db_set_dw(hMeta, META_PROTO, "IdleTS", dcws->value.dVal);
else if (dcws->value.type == DBVT_DELETED)
db_set_dw(hMeta, META_PROTO, "IdleTS", 0);
}
- else if ( !strcmp(dcws->szSetting, "LogonTS")) {
+ else if (!strcmp(dcws->szSetting, "LogonTS")) {
if (dcws->value.type == DBVT_DWORD)
db_set_dw(hMeta, META_PROTO, "LogonTS", dcws->value.dVal);
else if (dcws->value.type == DBVT_DELETED)
db_set_dw(hMeta, META_PROTO, "LogonTS", 0);
}
- else if ( !strcmp(dcws->szModule, "CList") && !strcmp(dcws->szSetting, "MyHandle")) {
+ else if (!strcmp(dcws->szModule, "CList") && !strcmp(dcws->szSetting, "MyHandle")) {
if (dcws->value.type == DBVT_DELETED) {
char *proto = GetContactProto(wParam);
strcpy(buffer, "CListName");
@@ -675,14 +661,13 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) if (proto && !Mydb_get(wParam, proto, "Nick", &dbv)) {
db_set(hMeta, META_PROTO, buffer, &dbv);
db_free(&dbv);
- } else {
- db_unset(hMeta, META_PROTO, buffer);
}
- } else {
+ else db_unset(hMeta, META_PROTO, buffer);
+ }
+ else {
// subcontact clist displayname has changed - update metacontact
strcpy(buffer, "CListName");
strcat(buffer, _itoa(contact_number, szId, 10));
-
db_set(hMeta, META_PROTO, buffer, &dcws->value);
}
@@ -692,7 +677,7 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) return 0;
}
- else if ( !strcmp(dcws->szSetting, "Status") && !dcws->value.type == DBVT_DELETED) {
+ else if (!strcmp(dcws->szSetting, "Status") && !dcws->value.type == DBVT_DELETED) {
// subcontact changing status
// update subcontact status setting
@@ -727,7 +712,7 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) _tcscpy(AI.filename, _T("X"));
if ((int)CallProtoService(META_PROTO, PS_GETAVATARINFOT, 0, (LPARAM)&AI) == GAIR_SUCCESS)
- db_set_ts(hMeta, "ContactPhoto", "File",AI.filename);
+ db_set_ts(hMeta, "ContactPhoto", "File", AI.filename);
}
}
else if (strcmp(dcws->szSetting, "XStatusId") == 0 || strcmp(dcws->szSetting, "XStatusMsg") == 0 || strcmp(dcws->szSetting, "XStatusName") == 0 || strcmp(dcws->szSetting, "StatusMsg") == 0) {
@@ -736,10 +721,9 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) else if (strcmp(dcws->szSetting, "MirVer") == 0) {
Meta_CopyData(hMeta);
}
- else if ( !meta_group_hack_disabled && !strcmp(dcws->szModule, "CList") && !strcmp(dcws->szSetting, "Hidden")) {
+ else if (!meta_group_hack_disabled && !strcmp(dcws->szModule, "CList") && !strcmp(dcws->szSetting, "Hidden")) {
if ((dcws->value.type == DBVT_DELETED || db_get_b(wParam, "CList", "Hidden", 0) == 0)
- && db_get_b(wParam, META_PROTO, "Hidden", 0) == 1)
- {
+ && db_get_b(wParam, META_PROTO, "Hidden", 0) == 1) {
// a subcontact we hid (e.g. jabber) has been unhidden - hide it again :(
db_set_b(wParam, "CList", "Hidden", 1);
}
@@ -754,7 +738,7 @@ int Meta_ContactDeleted(WPARAM wParam, LPARAM lParam) // is a subcontact - update meta contact
MCONTACT hMeta = (MCONTACT)db_get_dw(wParam, META_PROTO, "Handle", 0);
if (hMeta) {
- Meta_RemoveContactNumber(hMeta, db_get_dw(wParam, META_PROTO, "ContactNumber", -1));
+ Meta_RemoveContactNumber(hMeta, wParam);
NotifyEventHooks(hSubcontactsChanged, (WPARAM)hMeta, 0);
return 0;
}
@@ -770,7 +754,6 @@ int Meta_ContactDeleted(WPARAM wParam, LPARAM lParam) if (hContact && (HANDLE)db_get_dw(hContact, META_PROTO, "Handle", 0) == (HANDLE)wParam) {
db_unset(hContact, META_PROTO, META_LINK);
db_unset(hContact, META_PROTO, "Handle");
- db_unset(hContact, META_PROTO, "ContactNumber");
Meta_RestoreGroup(hContact);
db_unset(hContact, META_PROTO, "OldCListGroup");
@@ -790,19 +773,19 @@ int Meta_ContactDeleted(WPARAM wParam, LPARAM lParam) INT_PTR Meta_UserIsTyping(WPARAM wParam, LPARAM lParam)
{
// This is a simple contact, let through the stack of protocols
- if (db_get_dw(wParam, META_PROTO, META_ID,(DWORD)-1) == (DWORD)-1)
+ if (db_get_dw(wParam, META_PROTO, META_ID, INVALID_CONTACT_ID) == INVALID_CONTACT_ID)
return 0;
// forward to sending protocol, if supported
MCONTACT most_online = Meta_GetMostOnline(wParam);
Meta_CopyContactNick(wParam, most_online);
- if ( !most_online)
+ if (!most_online)
return 0;
char *proto = GetContactProto(most_online);
if (proto)
- if ( ProtoServiceExists(proto, PSS_USERISTYPING))
+ if (ProtoServiceExists(proto, PSS_USERISTYPING))
ProtoCallService(proto, PSS_USERISTYPING, (WPARAM)most_online, (LPARAM)lParam);
return 0;
@@ -816,11 +799,11 @@ INT_PTR Meta_UserIsTyping(WPARAM wParam, LPARAM lParam) int Meta_ContactIsTyping(WPARAM wParam, LPARAM lParam)
{
MCONTACT hMeta;
- if ((hMeta = (MCONTACT)db_get_dw(wParam, META_PROTO, "Handle",0)) != 0 && Meta_IsEnabled()) {
+ if ((hMeta = (MCONTACT)db_get_dw(wParam, META_PROTO, "Handle", 0)) != 0 && Meta_IsEnabled()) {
// This contact is attached to a MetaContact.
- if ( !options.subcontact_windows) { // we don't want clicking on the clist notification icon to open the metacontact message window
+ if (!options.subcontact_windows) { // we don't want clicking on the clist notification icon to open the metacontact message window
// try to remove any clist events we added for subcontact
- CallServiceSync(MS_CLIST_REMOVEEVENT, wParam, (LPARAM) 1);
+ CallServiceSync(MS_CLIST_REMOVEEVENT, wParam, (LPARAM)1);
CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hMeta, lParam);
// stop processing of event
return 1;
@@ -838,7 +821,7 @@ int Meta_ContactIsTyping(WPARAM wParam, LPARAM lParam) int Meta_UserInfo(WPARAM wParam, LPARAM lParam)
{
- DWORD default_contact_number = db_get_dw(lParam, META_PROTO, "Default", (DWORD)-1);
+ DWORD default_contact_number = db_get_dw(lParam, META_PROTO, "Default", INVALID_CONTACT_ID);
if (default_contact_number == -1) // not a meta contact
return 0;
@@ -855,14 +838,13 @@ int Meta_MessageWindowEvent(WPARAM wParam, LPARAM lParam) MCONTACT hMeta = 0;
if ((hMeta = db_get_dw(mwed->hContact, META_PROTO, "Handle", 0)) != 0
- || db_get_dw(mwed->hContact, META_PROTO, META_ID, (DWORD)-1) != (DWORD)-1)
- {
+ || db_get_dw(mwed->hContact, META_PROTO, META_ID, INVALID_CONTACT_ID) != INVALID_CONTACT_ID) {
// contact is subcontact of metacontact, or an actual metacontact - record whether window is open or closed
if (mwed->uType == MSG_WINDOW_EVT_OPEN || mwed->uType == MSG_WINDOW_EVT_OPENING) {
db_set_b(mwed->hContact, META_PROTO, "WindowOpen", 1);
if (hMeta) // subcontact window opened - remove clist events we added for metacontact
- while(!CallService(MS_CLIST_REMOVEEVENT, hMeta, mwed->hContact));
+ while (!CallService(MS_CLIST_REMOVEEVENT, hMeta, mwed->hContact));
}
else if (mwed->uType == MSG_WINDOW_EVT_CLOSE || mwed->uType == MSG_WINDOW_EVT_CLOSING)
db_set_b(mwed->hContact, META_PROTO, "WindowOpen", 0);
@@ -873,12 +855,12 @@ int Meta_MessageWindowEvent(WPARAM wParam, LPARAM lParam) int Meta_ClistDoubleClicked(WPARAM wParam, LPARAM lParam)
{
- if (db_get_dw(wParam, META_PROTO, "Default",(WORD)-1) == (WORD)-1)
+ if (db_get_dw(wParam, META_PROTO, "Default", (WORD)-1) == (WORD)-1)
return 0;
// -1 indicates no specific capability but respect 'ForceDefault'
MCONTACT most_online = Meta_GetMostOnlineSupporting(wParam, PFLAGNUM_1, -1);
- if ( !most_online)
+ if (!most_online)
return 0;
if (options.subcontact_windows) {
@@ -934,7 +916,7 @@ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam) }
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, Meta_ModifyMenu);
- HookEvent(ME_CLIST_DOUBLECLICKED, Meta_ClistDoubleClicked );
+ HookEvent(ME_CLIST_DOUBLECLICKED, Meta_ClistDoubleClicked);
////////////////////////////////////////////////////////////////////////////
InitMenus();
@@ -947,8 +929,8 @@ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam) PROTOACCOUNT ** ppProtocolDescriptors;
ProtoEnumAccounts(&numberOfProtocols, &ppProtocolDescriptors);
- for (int i = 0; i < numberOfProtocols ; i++)
- if ( strcmp(ppProtocolDescriptors[i]->szModuleName, META_PROTO)) {
+ for (int i = 0; i < numberOfProtocols; i++)
+ if (strcmp(ppProtocolDescriptors[i]->szModuleName, META_PROTO)) {
char str[MAXMODULELABELLENGTH + 10];
mir_snprintf(str, SIZEOF(str), "%s/Nudge", ppProtocolDescriptors[i]->szModuleName);
HookEvent(str, NudgeRecieved);
@@ -957,7 +939,7 @@ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam) return 0;
}
-static VOID CALLBACK sttMenuThread( PVOID param )
+static VOID CALLBACK sttMenuThread(PVOID param)
{
HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)param, 0);
@@ -1013,17 +995,15 @@ INT_PTR Meta_FileSend(WPARAM wParam, LPARAM lParam) char *proto = 0;
DWORD default_contact_number;
- if ((default_contact_number = db_get_dw(ccs->hContact, META_PROTO, "Default",(DWORD)-1)) == (DWORD)-1)
- {
+ if ((default_contact_number = db_get_dw(ccs->hContact, META_PROTO, "Default", INVALID_CONTACT_ID)) == INVALID_CONTACT_ID) {
// This is a simple contact
// (this should normally not happen, since linked contacts do not appear on the list.)
//PUShowMessage("meta has no default", SM_NOTIFY);
return 0;
}
- else
- {
+ else {
MCONTACT most_online = Meta_GetMostOnlineSupporting(ccs->hContact, PFLAGNUM_1, PF1_FILESEND);
- if ( !most_online) {
+ if (!most_online) {
//PUShowMessage("no most online for ft", SM_NOTIFY);
return 0;
}
@@ -1041,20 +1021,18 @@ INT_PTR Meta_GetAwayMsg(WPARAM wParam, LPARAM lParam) char *proto = 0;
DWORD default_contact_number;
- if ((default_contact_number = db_get_dw(ccs->hContact, META_PROTO, "Default",(DWORD)-1)) == (DWORD)-1)
- {
+ if ((default_contact_number = db_get_dw(ccs->hContact, META_PROTO, "Default", INVALID_CONTACT_ID)) == INVALID_CONTACT_ID) {
// This is a simple contact
// (this should normally not happen, since linked contacts do not appear on the list.)
return 0;
}
- else
- {
+ else {
MCONTACT most_online = Meta_GetMostOnlineSupporting(ccs->hContact, PFLAGNUM_1, PF1_MODEMSGRECV);
- if ( !most_online)
+ if (!most_online)
return 0;
proto = GetContactProto(most_online);
- if ( !proto) return 0;
+ if (!proto) return 0;
//Meta_CopyContactNick(ccs->hContact, most_online, proto);
@@ -1066,25 +1044,24 @@ INT_PTR Meta_GetAwayMsg(WPARAM wParam, LPARAM lParam) return 0; // fail
}
-INT_PTR Meta_GetAvatarInfo(WPARAM wParam, LPARAM lParam) {
- PROTO_AVATAR_INFORMATIONT *AI = (PROTO_AVATAR_INFORMATIONT *) lParam;
+INT_PTR Meta_GetAvatarInfo(WPARAM wParam, LPARAM lParam)
+{
+ PROTO_AVATAR_INFORMATIONT *AI = (PROTO_AVATAR_INFORMATIONT *)lParam;
DWORD default_contact_number;
- if ((default_contact_number = db_get_dw(AI->hContact, META_PROTO, "Default",(DWORD)-1)) == (DWORD)-1)
- {
+ if ((default_contact_number = db_get_dw(AI->hContact, META_PROTO, "Default", INVALID_CONTACT_ID)) == INVALID_CONTACT_ID) {
// This is a simple contact
// (this should normally not happen, since linked contacts do not appear on the list.)
return 0;
}
- else
- {
+ else {
MCONTACT hMeta = AI->hContact;
MCONTACT hSub = Meta_GetMostOnlineSupporting(AI->hContact, PFLAGNUM_4, PF4_AVATARS);
- if ( !hSub)
+ if (!hSub)
return GAIR_NOAVATAR;
char *proto = GetContactProto(hSub);
- if ( !proto) return GAIR_NOAVATAR;
+ if (!proto) return GAIR_NOAVATAR;
AI->hContact = hSub;
@@ -1099,36 +1076,37 @@ INT_PTR Meta_GetAvatarInfo(WPARAM wParam, LPARAM lParam) { INT_PTR Meta_GetInfo(WPARAM wParam, LPARAM lParam)
{
CCSDATA *ccs = (CCSDATA*)lParam;
- DWORD default_contact_number;
// This is a simple contact
// (this should normally not happen, since linked contacts do not appear on the list.)
- if ((default_contact_number = db_get_dw(ccs->hContact, META_PROTO, "Default",(DWORD)-1)) == (DWORD)-1)
+ MCONTACT default_contact_number = db_get_dw(ccs->hContact, META_PROTO, "Default", INVALID_CONTACT_ID);
+ if (default_contact_number == INVALID_CONTACT_ID)
return 0;
MCONTACT most_online = Meta_GetMostOnlineSupporting(ccs->hContact, PFLAGNUM_4, PF4_AVATARS);
- if ( !most_online)
+ if (!most_online)
return 0;
char *proto = GetContactProto(most_online);
- if ( !proto) return 0;
+ if (!proto)
+ return 0;
PROTO_AVATAR_INFORMATIONT AI;
AI.cbSize = sizeof(AI);
AI.hContact = ccs->hContact;
AI.format = PA_FORMAT_UNKNOWN;
_tcscpy(AI.filename, _T("X"));
- if ((int)CallProtoService(META_PROTO, PS_GETAVATARINFOT, 0, (LPARAM)&AI) == GAIR_SUCCESS)
- db_set_ts(ccs->hContact, "ContactPhoto", "File",AI.filename);
+ if (CallProtoService(META_PROTO, PS_GETAVATARINFOT, 0, (LPARAM)&AI) == GAIR_SUCCESS)
+ db_set_ts(ccs->hContact, "ContactPhoto", "File", AI.filename);
most_online = Meta_GetMostOnline(ccs->hContact);
Meta_CopyContactNick(ccs->hContact, most_online);
- if ( !most_online)
+ if (!most_online)
return 0;
ccs->hContact = most_online;
- if ( !ProtoServiceExists(proto, PSS_GETINFO))
+ if (!ProtoServiceExists(proto, PSS_GETINFO))
return 0; // fail
return CallContactService(ccs->hContact, PSS_GETINFO, ccs->wParam, ccs->lParam);
@@ -1181,7 +1159,7 @@ void Meta_InitServices() CreateServiceFunction("MetaContacts/ForceDefault", Meta_ForceDefault);
// hidden contact menu items...ho hum
- for (int i=0; i < MAX_CONTACTS; i++) {
+ for (int i = 0; i < MAX_CONTACTS; i++) {
char szServiceName[100];
mir_snprintf(szServiceName, SIZEOF(szServiceName), "MetaContacts/MenuFunc%d", i);
CreateServiceFunctionParam(szServiceName, MenuFunc, i);
@@ -1196,7 +1174,7 @@ void Meta_InitServices() CreateProtoServiceFunction(META_PROTO, PS_GETSTATUS, Meta_GetStatus);
CreateProtoServiceFunction(META_PROTO, PSS_MESSAGE, Meta_SendMessage);
- CreateProtoServiceFunction(META_PROTO, PSS_USERISTYPING, Meta_UserIsTyping );
+ CreateProtoServiceFunction(META_PROTO, PSS_USERISTYPING, Meta_UserIsTyping);
CreateProtoServiceFunction(META_PROTO, PSR_MESSAGE, Meta_RecvMessage);
diff --git a/src/modules/metacontacts/meta_utils.cpp b/src/modules/metacontacts/meta_utils.cpp index 1f5530fc19..54e52083af 100644 --- a/src/modules/metacontacts/meta_utils.cpp +++ b/src/modules/metacontacts/meta_utils.cpp @@ -208,17 +208,12 @@ int Meta_SetNick(char *szProto) */
BOOL Meta_Assign(MCONTACT src, MCONTACT dest, BOOL set_as_default)
{
- DWORD metaID, num_contacts;
+ DWORD num_contacts;
char buffer[512], szId[40];
WORD status;
MCONTACT most_online;
- if ((metaID = db_get_dw(dest, META_PROTO, META_ID,(DWORD)-1))==-1) {
- MessageBox(0, TranslateT("Could not get MetaContact ID"), TranslateT("Assignment error"), MB_OK | MB_ICONWARNING);
- return FALSE;
- }
-
- if ((num_contacts = db_get_dw(dest, META_PROTO, "NumContacts",(DWORD)-1))==-1) {
+ if ((num_contacts = db_get_dw(dest, META_PROTO, "NumContacts",INVALID_CONTACT_ID))==-1) {
MessageBox(0, TranslateT("Could not retreive MetaContact contact count"), TranslateT("Assignment error"), MB_OK | MB_ICONWARNING);
return FALSE;
}
@@ -315,10 +310,7 @@ BOOL Meta_Assign(MCONTACT src, MCONTACT dest, BOOL set_as_default) db_set_ts(dest, META_PROTO, buffer, szStatus);
// Write the link in the contact
- db_set_dw(src, META_PROTO, META_LINK, metaID);
-
- // Write the contact number in the contact
- db_set_dw(src, META_PROTO, "ContactNumber", num_contacts-1);
+ db_set_dw(src, META_PROTO, "ParentMeta", dest);
// Write the handle in the contact
db_set_dw(src, META_PROTO, "Handle", (DWORD)dest);
@@ -385,13 +377,11 @@ MCONTACT Meta_GetMostOnline(MCONTACT hMeta) { MCONTACT Meta_GetMostOnlineSupporting(MCONTACT hMeta, int pflagnum, unsigned long capability) {
int most_online_status = ID_STATUS_OFFLINE;
- MCONTACT most_online_contact = NULL, hContact;
- int i, status, default_contact_number, num_contacts;
- unsigned long caps = 0;
- char *szProto, *most_online_proto;
+ MCONTACT hContact;
+ int i, default_contact_number, num_contacts;
// you can't get more online than having the default contact ONLINE - so check that first
- if ((default_contact_number = db_get_dw(hMeta, META_PROTO, "Default",(DWORD)-1)) == (DWORD)-1)
+ if ((default_contact_number = db_get_dw(hMeta, META_PROTO, "Default",INVALID_CONTACT_ID)) == INVALID_CONTACT_ID)
{
// This is a simple contact - return NULL to signify error.
// (this should normally not happen, since all meta contacts have a default contact)
@@ -402,9 +392,9 @@ MCONTACT Meta_GetMostOnlineSupporting(MCONTACT hMeta, int pflagnum, unsigned lon if (default_contact_number >= (num_contacts = db_get_dw(hMeta, META_PROTO, "NumContacts", 0)))
return NULL;
- most_online_contact = Meta_GetContactHandle(hMeta, default_contact_number);
- szProto = GetContactProto(most_online_contact);
- caps = szProto ? CallProtoService(szProto, PS_GETCAPS, (WPARAM)pflagnum, 0) : 0;
+ MCONTACT most_online_contact = Meta_GetContactHandle(hMeta, default_contact_number);
+ char *szProto = GetContactProto(most_online_contact);
+ DWORD caps = szProto ? CallProtoService(szProto, PS_GETCAPS, (WPARAM)pflagnum, 0) : 0;
if (szProto && strcmp(szProto, "IRC") == 0) caps |= PF1_IM;
// we are forced to do use default for sending - '-1' capability indicates no specific capability, but respect 'Force Default'
if (szProto && db_get_b(hMeta, META_PROTO, "ForceDefault", 0) && capability != 0 && (capability == -1 || (caps & capability) == capability)) // capability is 0 when we're working out status
@@ -428,15 +418,14 @@ MCONTACT Meta_GetMostOnlineSupporting(MCONTACT hMeta, int pflagnum, unsigned lon // if our default is not offline, and option to use default is set - return default
// and also if our default is online, return it
- if (most_online_status == ID_STATUS_ONLINE || (most_online_status != ID_STATUS_OFFLINE && options.always_use_default)) {
+ if (most_online_status == ID_STATUS_ONLINE || (most_online_status != ID_STATUS_OFFLINE && options.always_use_default))
return most_online_contact;
- }
- } else
- most_online_status = ID_STATUS_OFFLINE;
- } else
- most_online_status = ID_STATUS_OFFLINE;
+ }
+ else most_online_status = ID_STATUS_OFFLINE;
+ }
+ else most_online_status = ID_STATUS_OFFLINE;
- most_online_proto = szProto;
+ char *most_online_proto = szProto;
// otherwise, check all the subcontacts for the one closest to the ONLINE state which supports the required capability
for (i = 0; i < num_contacts; i++) {
if (i == default_contact_number) // already checked that (i.e. initial value of most_online_contact and most_online_status are those of the default contact)
@@ -451,28 +440,26 @@ MCONTACT Meta_GetMostOnlineSupporting(MCONTACT hMeta, int pflagnum, unsigned lon caps = szProto ? CallProtoService(szProto, PS_GETCAPS, (WPARAM)pflagnum, 0) : 0;
if (szProto && strcmp(szProto, "IRC") == 0) caps |= PF1_IM;
if (szProto && (capability == -1 || (caps & capability) == capability)) {
-
- status = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
-
+ int status = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
if (status == ID_STATUS_ONLINE) {
most_online_contact = hContact;
most_online_proto = szProto;
return most_online_contact;
- } else if (status <= ID_STATUS_OFFLINE) // status below ID_STATUS_OFFLINE is a connecting status
+ }
+ if (status <= ID_STATUS_OFFLINE) // status below ID_STATUS_OFFLINE is a connecting status
continue;
- else {
- if (GetRealPriority(szProto, status) < GetRealPriority(most_online_proto, most_online_status)) {
- most_online_status = status;
- most_online_contact = hContact;
- most_online_proto = szProto;
- }
+
+ if (GetRealPriority(szProto, status) < GetRealPriority(most_online_proto, most_online_status)) {
+ most_online_status = status;
+ most_online_contact = hContact;
+ most_online_proto = szProto;
}
}
}
// no online contacts? if we're trying to message, use 'send offline' contact
if (most_online_status == ID_STATUS_OFFLINE && capability == PF1_IM) {
- MCONTACT hOffline = Meta_GetContactHandle(hMeta, db_get_dw(hMeta, META_PROTO, "OfflineSend", (DWORD)-1));
+ MCONTACT hOffline = Meta_GetContactHandle(hMeta, db_get_dw(hMeta, META_PROTO, "OfflineSend", INVALID_CONTACT_ID));
if (hOffline)
most_online_contact = hOffline;
}
@@ -480,8 +467,9 @@ MCONTACT Meta_GetMostOnlineSupporting(MCONTACT hMeta, int pflagnum, unsigned lon return most_online_contact;
}
-int Meta_GetContactNumber(MCONTACT hContact) {
- return db_get_dw(hContact, META_PROTO, "ContactNumber", -1);
+int Meta_GetContactNumber(MCONTACT hContact)
+{
+ return hContact; // !!!!!!!!!!!!!!!!!!!!!!!!!
}
BOOL dbv_same(DBVARIANT *dbv1, DBVARIANT *dbv2) {
@@ -504,76 +492,74 @@ BOOL dbv_same(DBVARIANT *dbv1, DBVARIANT *dbv2) { }
}
- void copy_settings_array(MCONTACT hMeta, char *module, const char *settings[], int num_settings) {
- int num_contacts = db_get_dw(hMeta, META_PROTO, "NumContacts", (DWORD)-1),
- default_contact = db_get_dw(hMeta, META_PROTO, "Default", (DWORD)-1),
- most_online = Meta_GetContactNumber(Meta_GetMostOnline(hMeta));
-
- MCONTACT hContact;
- int i, j;
- char *used_mod;
-
- DBVARIANT dbv1, dbv2;
- BOOL free, got_val, bDataWritten;
+void copy_settings_array(MCONTACT hMeta, char *module, const char *settings[], int num_settings)
+{
+ int num_contacts = db_get_dw(hMeta, META_PROTO, "NumContacts", INVALID_CONTACT_ID),
+ default_contact = db_get_dw(hMeta, META_PROTO, "Default", INVALID_CONTACT_ID),
+ most_online = Meta_GetContactNumber(Meta_GetMostOnline(hMeta));
BOOL use_default = FALSE;
int source_contact = (use_default ? default_contact : most_online);
+ if (source_contact < 0 || source_contact >= num_contacts)
+ return;
- if (source_contact < 0 || source_contact >= num_contacts) return;
-
- for (i = 0; i < num_settings; i++) {
- bDataWritten = FALSE;
- for (j = 0; j < num_contacts && !bDataWritten; j++) {
+ for (int i = 0; i < num_settings; i++) {
+ BOOL bDataWritten = FALSE;
+ for (int j = 0; j < num_contacts && !bDataWritten; j++) {
// do source (most online) first
- if (j == 0)
+ MCONTACT hContact;
+ if (j == 0)
hContact = Meta_GetContactHandle(hMeta, source_contact);
else if (j <= source_contact)
hContact = Meta_GetContactHandle(hMeta, j - 1);
else
hContact = Meta_GetContactHandle(hMeta, j);
- if (hContact) {
- if ( !module) {
- used_mod = GetContactProto(hContact);
- if ( !used_mod)
- continue; // next contact
+ if (hContact == 0)
+ continue;
+
+ char *used_mod;
+ if (!module) {
+ used_mod = GetContactProto(hContact);
+ if (!used_mod)
+ continue; // next contact
+ }
+ else used_mod = module;
+
+ if (j == 0 && strcmp(settings[i], "MirVer") == 0) //Always reset MirVer
+ db_unset(hMeta, (module ? used_mod : META_PROTO), settings[i]);
+
+ DBVARIANT dbv1, dbv2;
+ BOOL bFree, got_val = !Mydb_get(hContact, used_mod, settings[i], &dbv2);
+ if (got_val) {
+ bFree = !Mydb_get(hMeta, (module ? used_mod : META_PROTO), settings[i], &dbv1);
+
+ if (strcmp(settings[i], "MirVer") == 0) {
+ if (db_get_w(hContact, used_mod, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
+ if (!bFree || (dbv1.pszVal == NULL || strcmp(dbv1.pszVal, "") == 0 || strlen(dbv1.pszVal) < 2)) {
+ db_set(hMeta, (module ? used_mod : META_PROTO), settings[i], &dbv2);
+ bDataWritten = TRUE; //only break if found something to copy
+ }
+ }
}
- else used_mod = module;
-
- if (j == 0 && strcmp(settings[i], "MirVer") == 0) //Always reset MirVer
- db_unset(hMeta, (module ? used_mod : META_PROTO), settings[i]);
-
- got_val = !Mydb_get(hContact, used_mod, settings[i], &dbv2);
- if (got_val) {
- free = !Mydb_get(hMeta, (module ? used_mod : META_PROTO), settings[i], &dbv1);
-
- if (strcmp(settings[i], "MirVer") == 0) {
- if (db_get_w(hContact, used_mod, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
- if ( !free || (dbv1.pszVal == NULL || strcmp(dbv1.pszVal, "") == 0 || strlen(dbv1.pszVal) < 2)) {
- db_set(hMeta, (module ? used_mod : META_PROTO), settings[i], &dbv2);
+ else {
+ if (!bFree || !dbv_same(&dbv1, &dbv2)) {
+ db_set(hMeta, (module ? used_mod : META_PROTO), settings[i], &dbv2);
+ if (dbv2.type == DBVT_ASCIIZ || dbv2.type == DBVT_UTF8) {
+ if (dbv2.pszVal != NULL && strcmp(dbv2.pszVal, "") != 0)
bDataWritten = TRUE; //only break if found something to copy
- }
}
- }
- else {
- if ( !free || !dbv_same(&dbv1, &dbv2)) {
- db_set(hMeta, (module ? used_mod : META_PROTO), settings[i], &dbv2);
- if (dbv2.type == DBVT_ASCIIZ || dbv2.type == DBVT_UTF8) {
- if (dbv2.pszVal != NULL && strcmp(dbv2.pszVal, "") != 0)
- bDataWritten = TRUE; //only break if found something to copy
- } else if (dbv2.type == DBVT_WCHAR) {
- if (dbv2.pwszVal != 0 && wcscmp(dbv2.pwszVal, L"") != 0)
- bDataWritten = TRUE; //only break if found something to copy
- } else
+ else if (dbv2.type == DBVT_WCHAR) {
+ if (dbv2.pwszVal != 0 && wcscmp(dbv2.pwszVal, L"") != 0)
bDataWritten = TRUE; //only break if found something to copy
}
- else
- bDataWritten = TRUE;
-
- }
- db_free(&dbv2);
- if (free)db_free(&dbv1);
- }
+ else bDataWritten = TRUE; //only break if found something to copy
+ }
+ else bDataWritten = TRUE;
+ }
+ db_free(&dbv2);
+ if (bFree)
+ db_free(&dbv1);
}
}
}
@@ -610,14 +596,14 @@ const char *MBirthdaySettings[3] = void CopyStatusData(MCONTACT hMeta)
{
- int num_contacts = db_get_dw(hMeta, META_PROTO, "NumContacts", (DWORD)-1),
- most_online = Meta_GetContactNumber(Meta_GetMostOnline(hMeta));
+ int num_contacts = db_get_dw(hMeta, META_PROTO, "NumContacts", INVALID_CONTACT_ID),
+ most_online = Meta_GetContactNumber(Meta_GetMostOnline(hMeta));
WORD status = db_get_w(hMeta, META_PROTO, "Status", ID_STATUS_OFFLINE);
MCONTACT hContact;
BOOL bDoneStatus = FALSE, bDoneXStatus = FALSE;
for (int i = 0; i < num_contacts; i++) {
- if (i == 0)
+ if (i == 0)
hContact = Meta_GetContactHandle(hMeta, most_online);
else if (i <= most_online)
hContact = Meta_GetContactHandle(hMeta, i - 1);
@@ -628,7 +614,7 @@ void CopyStatusData(MCONTACT hMeta) if (szProto && db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE) == status) {
DBVARIANT dbv;
- if ( !bDoneStatus && !Mydb_get(hContact, "CList", "StatusMsg", &dbv)) {
+ if (!bDoneStatus && !Mydb_get(hContact, "CList", "StatusMsg", &dbv)) {
db_set(hMeta, "CList", "StatusMsg", &dbv);
db_free(&dbv);
bDoneStatus = TRUE;
@@ -638,11 +624,11 @@ void CopyStatusData(MCONTACT hMeta) db_set(hMeta, META_PROTO, "XStatusId", &dbv);
db_free(&dbv);
- if ( !Mydb_get(hContact, szProto, "XStatusMsg", &dbv)) {
+ if (!Mydb_get(hContact, szProto, "XStatusMsg", &dbv)) {
db_set(hMeta, META_PROTO, "XStatusMsg", &dbv);
db_free(&dbv);
}
- if ( !Mydb_get(hContact, szProto, "XStatusName", &dbv)) {
+ if (!Mydb_get(hContact, szProto, "XStatusName", &dbv)) {
db_set(hMeta, META_PROTO, "XStatusName", &dbv);
db_free(&dbv);
}
@@ -654,8 +640,8 @@ void CopyStatusData(MCONTACT hMeta) break;
}
- if ( !bDoneStatus) db_unset(hMeta, "CList", "StatusMsg");
- if ( !bDoneXStatus) {
+ if (!bDoneStatus) db_unset(hMeta, "CList", "StatusMsg");
+ if (!bDoneXStatus) {
db_unset(hMeta, META_PROTO, "XStatusId");
db_unset(hMeta, META_PROTO, "XStatusMsg");
db_unset(hMeta, META_PROTO, "XStatusName");
@@ -664,181 +650,32 @@ void CopyStatusData(MCONTACT hMeta) void Meta_CopyData(MCONTACT hMeta)
{
- if (options.copydata) {
- CopyStatusData(hMeta);
+ if (!options.copydata)
+ return;
- copy_settings_array(hMeta, 0, ProtoSettings, 25);
- copy_settings_array(hMeta, "mBirthday", UserInfoSettings, 3);
- copy_settings_array(hMeta, "ContactPhoto", ContactPhotoSettings, 5);
+ CopyStatusData(hMeta);
- if (options.copy_userinfo)
- copy_settings_array(hMeta, "UserInfo", UserInfoSettings, 71);
- }
-}
+ copy_settings_array(hMeta, 0, ProtoSettings, 25);
+ copy_settings_array(hMeta, "mBirthday", UserInfoSettings, 3);
+ copy_settings_array(hMeta, "ContactPhoto", ContactPhotoSettings, 5);
+ if (options.copy_userinfo)
+ copy_settings_array(hMeta, "UserInfo", UserInfoSettings, 71);
+}
MCONTACT Meta_GetContactHandle(MCONTACT hMeta, int contact_number)
{
char buffer[512], buffer2[512];
int num_contacts = db_get_dw(hMeta, META_PROTO, "NumContacts", 0);
- if (contact_number >= num_contacts || contact_number < 0) return 0;
+ if (contact_number >= num_contacts || contact_number < 0)
+ return 0;
strcpy(buffer, "Handle");
strcat(buffer, _itoa(contact_number, buffer2, 10));
return (MCONTACT)db_get_dw(hMeta, META_PROTO, buffer, 0);
}
-int Meta_SetHandles(void)
-{
- DWORD meta_id, num_contacts, contact_number;
- MCONTACT hContact2, hContact = db_find_first(), hNextContact;
- char buffer[512];
- TCHAR nick_buffer[128], buffer2[40];
- BOOL found;
-
- while (hContact != NULL) {
- if ((meta_id = db_get_dw(hContact, META_PROTO, META_LINK, (DWORD)-1)) != (DWORD)-1) {
- // is a subcontact
-
- // get nick for debug messages
- _tcscpy(nick_buffer, _T("meta_id: "));
- _tcscat(nick_buffer, _itot(meta_id, buffer2, 10));
-
- contact_number = db_get_dw(hContact, META_PROTO, "ContactNumber", (DWORD)-1);
- _tcscat(nick_buffer, _T(", contact num: "));
- _tcscat(nick_buffer, _itot(contact_number, buffer2, 10));
-
- if (contact_number < 0) {
- // problem!
- MessageBox(0, TranslateT("Subcontact contact number < 0 - deleting MetaContact"), nick_buffer, MB_OK | MB_ICONERROR);
- hNextContact = db_find_next(hContact);
- Meta_Delete(hContact, 1);
- hContact = hNextContact;
- continue;
- }
-
- // ensure the window open flag is not present
- db_unset(hContact, META_PROTO, "WindowOpen");
-
- // find metacontact
- found = FALSE;
- hContact2 = db_find_first();
-
- while (hContact2 != NULL) {
- if (db_get_dw(hContact2, META_PROTO, META_ID, (DWORD)-1) == meta_id) {
- found = TRUE;
-
- // set handle
- db_set_dw(hContact, META_PROTO, "Handle", (DWORD)hContact2);
-
- // increment contact counter (cleared in Load function)
- db_set_b(hContact2, META_PROTO, "ContactCountCheck",
- (unsigned char)(db_get_b(hContact2, META_PROTO, "ContactCountCheck", 0) + 1));
-
- num_contacts = db_get_dw(hContact2, META_PROTO, "NumContacts", (DWORD)-1);
- if (contact_number >= 0 && contact_number < num_contacts) {
- // set metacontact's handle to us
- char szId[40];
- strcpy(buffer, "Handle");
- strcat(buffer, _itoa((int)contact_number, szId, 10));
- db_set_dw(hContact2, META_PROTO, buffer, (DWORD)hContact);
- }
- else {
- TCHAR buff[256];
- // problem - contact number is greater than meta's number of contacts
- mir_sntprintf(buff, SIZEOF(buff), TranslateT("Subcontact contact number (%d) > meta num contacts (%d) - deleting MetaContact"), contact_number, num_contacts);
- MessageBox(0, buff, nick_buffer, MB_OK | MB_ICONERROR);
-
- hNextContact = db_find_next(hContact);
- Meta_Delete(hContact, (LPARAM)1);
- hContact = hNextContact;
- continue;
- }
- }
-
- hContact2 = db_find_next(hContact2);
- }
-
- if (!found) {
- // problem - subcontact's meta not found
- MessageBox(0, TranslateT("Subcontact's MetaContact not found - deleting MetaContact data"), nick_buffer, MB_OK | MB_ICONERROR);
-
- // delete meta data
- db_unset(hContact, META_PROTO, META_LINK);
- db_unset(hContact, META_PROTO, "Handle");
- db_unset(hContact, META_PROTO, "ContactNumber");
- Meta_RestoreGroup(hContact);
- db_unset(hContact, META_PROTO, "OldCListGroup");
-
- // stop ignoring, if we were
- if (options.suppress_status)
- CallService(MS_IGNORE_UNIGNORE, hContact, (WPARAM)IGNOREEVENT_USERONLINE);
- }
- }
- else db_unset(hContact, META_PROTO, "Handle");
-
- if ((meta_id = db_get_dw(hContact, META_PROTO, META_ID, (DWORD)-1)) != (DWORD)-1) {
- // is a metacontact
-
- // get nick for debug messages
- _tcscpy(nick_buffer, _T("meta_id: "));
- _tcscat(nick_buffer, _itot(meta_id, buffer2, 10));
-
- // ensure the window open flag is not present
- db_unset(hContact, META_PROTO, "WindowOpen");
-
- // ensure default is reasonable
- contact_number = db_get_dw(hContact, META_PROTO, "Default", -1);
- num_contacts = db_get_dw(hContact, META_PROTO, "NumContacts", (DWORD)-1);
-
- if (num_contacts < 0) {
- // problem
- MessageBox(0, TranslateT("MetaContact number of contacts < 0 - deleting MetaContact"), nick_buffer, MB_OK | MB_ICONERROR);
- hNextContact = db_find_next(hContact);
- Meta_Delete(hContact, (LPARAM)1);
- hContact = hNextContact;
- continue;
- }
-
- if (contact_number < 0 || contact_number >= num_contacts) {
- // problem
- MessageBox(0, TranslateT("MetaContact default contact number out of range - deleting MetaContact"), nick_buffer, MB_OK | MB_ICONERROR);
- hNextContact = db_find_next(hContact);
- Meta_Delete(hContact, (LPARAM)1);
- hContact = hNextContact;
- continue;
- }
- }
-
- hContact = db_find_next(hContact);
- }
-
- // loop through one more time - check contact counts match
- hContact = db_find_first();
- while (hContact != NULL) {
- if ((meta_id = db_get_dw(hContact, META_PROTO, META_ID, (DWORD)-1)) != (DWORD)-1) {
- // get nick for debug messages
-
- num_contacts = db_get_b(hContact, META_PROTO, "ContactCountCheck", -2);
- if (num_contacts != (DWORD)db_get_dw(hContact, META_PROTO, "NumContacts", (DWORD)-1)) {
- hNextContact = db_find_next(hContact);
-
- _tcscpy(nick_buffer, TranslateT("Meta ID: "));
- _tcscat(nick_buffer, _itot(meta_id, buffer2, 10));
- MessageBox(0, TranslateT("MetaContact corrupted - the number of subcontacts is incorrect.\nDeleting MetaContact."), nick_buffer, MB_OK | MB_ICONERROR);
-
- Meta_Delete(hContact, (LPARAM)1);
- hContact = hNextContact;
- continue;
- }
- }
- hContact = db_find_next(hContact);
- }
-
- return 0;
-}
-
/** Hide all contacts linked to any meta contact, and set handle links
*
* Additionally, set all sub contacts and metacontacts to offline so that status notifications are always sent
@@ -858,107 +695,93 @@ int Meta_HideLinkedContacts(void) {
DBVARIANT dbv, dbv2;
DWORD meta_id, num_contacts, contact_number;
- WORD status;
char buffer[512], buffer2[512];
- char *szProto, *group_name;
- int hGroup = 1;
-
- MCONTACT hContact2, hContact = db_find_first();
// ensure the hidden group does not exist (how this occurs i wonder but there have been reports!)
// (sometimes protocol server side groups are to blame - msn and icq)
- if (!meta_group_hack_disabled) do {
- group_name = (char *)CallService(MS_CLIST_GROUPGETNAME, (WPARAM)hGroup, 0);
- if (group_name && !strcmp(group_name, META_HIDDEN_GROUP)) {
- // disabled because it shows a message box
- //CallService(MS_CLIST_GROUPDELETE, (WPARAM)hGroup, 0);
- MessageBox(0, TranslateT(szMsg), TranslateT("MetaContacts Warning"), MB_ICONWARNING | MB_OK);
- break;
+ if (!meta_group_hack_disabled) {
+ for (int hGroup=1;; hGroup++) {
+ char *group_name = (char*)CallService(MS_CLIST_GROUPGETNAME, hGroup, 0);
+ if (group_name == NULL)
+ break;
+
+ if (!strcmp(group_name, META_HIDDEN_GROUP)) {
+ // disabled because it shows a message box
+ //CallService(MS_CLIST_GROUPDELETE, (WPARAM)hGroup, 0);
+ MessageBox(0, TranslateT(szMsg), TranslateT("MetaContacts Warning"), MB_ICONWARNING | MB_OK);
+ break;
+ }
}
- hGroup++;
- } while (group_name);
+ }
- while (hContact != NULL) {
- if ((meta_id = db_get_dw(hContact, META_PROTO, META_LINK, (DWORD)-1)) != (DWORD)-1) {
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if ((meta_id = db_get_dw(hContact, META_PROTO, META_LINK, INVALID_CONTACT_ID)) != INVALID_CONTACT_ID) {
// get contact number
- contact_number = db_get_dw(hContact, META_PROTO, "ContactNumber", (DWORD)-1);
+ contact_number = db_get_dw(hContact, META_PROTO, "ContactNumber", INVALID_CONTACT_ID);
// prepare to update metacontact record of subcontat status
- szProto = GetContactProto(hContact);
+ char *szProto = GetContactProto(hContact);
// save old group and move to invisible group (i.e. non-existent group)
Meta_SetGroup(hContact);
// find metacontact
- hContact2 = db_find_first();
-
- while (hContact2 != NULL) {
- if (db_get_dw(hContact2, META_PROTO, META_ID, (DWORD)-1) == meta_id) {
- num_contacts = db_get_dw(hContact2, META_PROTO, "NumContacts", (DWORD)-1);
- if (contact_number >= 0 && contact_number < num_contacts) {
-
- if (!szProto)
- status = ID_STATUS_OFFLINE;
- else
- status = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
+ for (MCONTACT hContact2 = db_find_first(); hContact2; hContact2 = db_find_next(hContact2)) {
+ if (db_get_dw(hContact2, META_PROTO, META_ID, INVALID_CONTACT_ID) != meta_id)
+ continue;
+
+ num_contacts = db_get_dw(hContact2, META_PROTO, "NumContacts", INVALID_CONTACT_ID);
+ if (contact_number < 0 || contact_number >= num_contacts)
+ continue;
+
+ // update metacontact's record of status for this contact
+ strcpy(buffer, "Status");
+ strcat(buffer, _itoa(contact_number, buffer2, 10));
+
+ WORD status = (!szProto) ? ID_STATUS_OFFLINE : db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
+ db_set_w(hContact2, META_PROTO, buffer, status);
+
+ // update metacontact's record of nick for this contact
+ if (szProto && !db_get(hContact, szProto, "Nick", &dbv)) {
+ strcpy(buffer, "Nick");
+ strcat(buffer, _itoa(contact_number, buffer2, 10));
+ db_set(hContact2, META_PROTO, buffer, &dbv);
+
+ strcpy(buffer, "CListName");
+ strcat(buffer, _itoa(contact_number, buffer2, 10));
+ if (db_get(hContact, "CList", "MyHandle", &dbv2))
+ db_set(hContact2, META_PROTO, buffer, &dbv);
+ else {
+ db_set(hContact2, META_PROTO, buffer, &dbv2);
+ db_free(&dbv2);
+ }
- // update metacontact's record of status for this contact
- strcpy(buffer, "Status");
+ db_free(&dbv);
+ }
+ else {
+ if (!db_get(hContact, "CList", "MyHandle", &dbv)) {
+ strcpy(buffer, "CListName");
strcat(buffer, _itoa(contact_number, buffer2, 10));
- db_set_w(hContact2, META_PROTO, buffer, status);
-
- // update metacontact's record of nick for this contact
- if (szProto && !db_get(hContact, szProto, "Nick", &dbv)) {
- strcpy(buffer, "Nick");
- strcat(buffer, _itoa(contact_number, buffer2, 10));
- db_set(hContact2, META_PROTO, buffer, &dbv);
-
- strcpy(buffer, "CListName");
- strcat(buffer, _itoa(contact_number, buffer2, 10));
- if (db_get(hContact, "CList", "MyHandle", &dbv2)) {
- db_set(hContact2, META_PROTO, buffer, &dbv);
- }
- else {
- db_set(hContact2, META_PROTO, buffer, &dbv2);
- db_free(&dbv2);
- }
-
- db_free(&dbv);
- }
- else {
- if (!db_get(hContact, "CList", "MyHandle", &dbv)) {
- strcpy(buffer, "CListName");
- strcat(buffer, _itoa(contact_number, buffer2, 10));
- db_set(hContact2, META_PROTO, buffer, &dbv);
- db_free(&dbv);
- }
- }
+ db_set(hContact2, META_PROTO, buffer, &dbv);
+ db_free(&dbv);
}
}
-
- hContact2 = db_find_next(hContact2);
}
if (options.suppress_status)
CallService(MS_IGNORE_IGNORE, hContact, (WPARAM)IGNOREEVENT_USERONLINE);
}
-
- hContact = db_find_next(hContact);
}
// do metacontacts after handles set properly above
- hContact = db_find_first();
- while (hContact != NULL) {
- if (db_get_dw(hContact, META_PROTO, META_ID, (DWORD)-1) != (DWORD)-1) {
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (db_get_dw(hContact, META_PROTO, META_ID, INVALID_CONTACT_ID) != INVALID_CONTACT_ID) {
// is a meta contact
MCONTACT hMostOnline = Meta_GetMostOnline(hContact); // set nick
Meta_CopyContactNick(hContact, hMostOnline);
Meta_FixStatus(hContact);
-
}
-
- hContact = db_find_next(hContact);
}
return 0;
@@ -970,7 +793,7 @@ int Meta_HideLinkedContacts(void) int Meta_UnhideLinkedContacts(void)
{
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if (db_get_dw(hContact, META_PROTO, META_LINK, (DWORD)-1) != (DWORD)-1) {
+ if (db_get_dw(hContact, META_PROTO, META_LINK, INVALID_CONTACT_ID) != INVALID_CONTACT_ID) {
// has a link - unhide it
// restore old group
Meta_RestoreGroup(hContact);
@@ -987,14 +810,14 @@ int Meta_HideMetaContacts(int hide) else Meta_SuppressStatus(options.suppress_status);
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if (db_get_dw(hContact, META_PROTO, META_ID, (DWORD)-1) != (DWORD)-1) {
+ if (db_get_dw(hContact, META_PROTO, META_ID, INVALID_CONTACT_ID) != INVALID_CONTACT_ID) {
// is a meta contact
if (hide)
db_set_b(hContact, "CList", "Hidden", 1);
else
db_unset(hContact, "CList", "Hidden");
}
- else if (db_get_dw(hContact, META_PROTO, META_LINK, (DWORD)-1) != (DWORD)-1) {
+ else if (db_get_dw(hContact, META_PROTO, META_LINK, INVALID_CONTACT_ID) != INVALID_CONTACT_ID) {
// when metacontacts are hidden, show subcontacts, and vice versa
if (hide)
Meta_RestoreGroup(hContact);
@@ -1008,7 +831,6 @@ int Meta_HideMetaContacts(int hide) void Meta_RestoreGroup(MCONTACT hContact)
{
-
if (meta_group_hack_disabled) return; // clist has called api function to disable group hack - yay!
// the existence of this service means that clist_meta_mw is active and will do the hiding for us
@@ -1112,7 +934,7 @@ void Meta_SetGroup(MCONTACT hContact) int Meta_SuppressStatus(BOOL suppress)
{
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if (db_get_dw(hContact, META_PROTO, META_LINK, (DWORD)-1) != (DWORD)-1) {
+ if (db_get_dw(hContact, META_PROTO, META_LINK, INVALID_CONTACT_ID) != INVALID_CONTACT_ID) {
// is a subcontact
if (suppress)
CallService(MS_IGNORE_IGNORE, hContact, (WPARAM)IGNOREEVENT_USERONLINE);
@@ -1166,7 +988,7 @@ int Meta_CopyContactNick(MCONTACT hMeta, MCONTACT hContact) int Meta_SetAllNicks()
{
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if (db_get_dw(hContact, META_PROTO, META_ID, (DWORD)-1) != (DWORD)-1) {
+ if (db_get_dw(hContact, META_PROTO, META_ID, INVALID_CONTACT_ID) != INVALID_CONTACT_ID) {
MCONTACT most_online = Meta_GetMostOnline(hContact);
Meta_CopyContactNick(hContact, most_online);
Meta_FixStatus(hContact);
diff --git a/src/modules/metacontacts/metacontacts.h b/src/modules/metacontacts/metacontacts.h index 9124312302..e2fce9fdee 100644 --- a/src/modules/metacontacts/metacontacts.h +++ b/src/modules/metacontacts/metacontacts.h @@ -56,7 +56,6 @@ int Meta_SetNick(char *proto); MCONTACT Meta_GetMostOnline(MCONTACT hMeta);
MCONTACT Meta_GetMostOnlineSupporting(MCONTACT hMeta, int pflagnum, unsigned long capability);
int Meta_HideLinkedContacts(void);
-int Meta_SetHandles(void);
int Meta_UnhideLinkedContacts(void);
int Meta_GetContactNumber(MCONTACT hContact);
MCONTACT Meta_GetContactHandle(MCONTACT hMeta, int contact_number);
|