From 50e9cca2ec06bbae40237f491a3bae80b454928e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 5 Mar 2014 17:15:41 +0000 Subject: fix for removing the single sub in the MC Editor git-svn-id: http://svn.miranda-ng.org/main/trunk@8415 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/metacontacts/meta_edit.cpp | 7 ++--- src/modules/metacontacts/meta_menu.cpp | 43 ++++++++++++++---------------- src/modules/metacontacts/meta_services.cpp | 2 +- src/modules/metacontacts/metacontacts.h | 2 +- 4 files changed, 24 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/modules/metacontacts/meta_edit.cpp b/src/modules/metacontacts/meta_edit.cpp index ffd740fa4d..f5e694f7dc 100644 --- a/src/modules/metacontacts/meta_edit.cpp +++ b/src/modules/metacontacts/meta_edit.cpp @@ -166,14 +166,11 @@ static void ApplyChanges() // fix avatar most_online = Meta_GetMostOnlineSupporting(g_data.cc, PFLAGNUM_4, PF4_AVATARS); if (most_online) { - PROTO_AVATAR_INFORMATIONT AI; - - AI.cbSize = sizeof(AI); + PROTO_AVATAR_INFORMATIONT AI = { sizeof(AI) }; AI.hContact = g_data.hMeta; AI.format = PA_FORMAT_UNKNOWN; _tcscpy(AI.filename, _T("X")); - - if ((int)CallProtoService(META_PROTO, PS_GETAVATARINFOT, 0, (LPARAM)&AI) == GAIR_SUCCESS) + if (CallProtoService(META_PROTO, PS_GETAVATARINFOT, 0, (LPARAM)&AI) == GAIR_SUCCESS) db_set_ts(g_data.hMeta, "ContactPhoto", "File", AI.filename); } diff --git a/src/modules/metacontacts/meta_menu.cpp b/src/modules/metacontacts/meta_menu.cpp index 6431591903..8c42b1539c 100644 --- a/src/modules/metacontacts/meta_menu.cpp +++ b/src/modules/metacontacts/meta_menu.cpp @@ -89,7 +89,7 @@ INT_PTR Meta_Convert(WPARAM wParam, LPARAM lParam) return (INT_PTR)hMetaContact; } -void Meta_RemoveContactNumber(DBCachedContact *ccMeta, int number) +void Meta_RemoveContactNumber(DBCachedContact *ccMeta, int number, bool bUpdateInfo) { if (ccMeta == NULL) return; @@ -107,7 +107,7 @@ void Meta_RemoveContactNumber(DBCachedContact *ccMeta, int number) // each contact from 'number' upwards will be moved down one // and the last one will be deleted - for (int i = number + 1; i < ccMeta->nSubs; i++) + for (int i = number+1; i < ccMeta->nSubs; i++) Meta_SwapContacts(ccMeta, i, i - 1); // remove the last one @@ -147,22 +147,24 @@ void Meta_RemoveContactNumber(DBCachedContact *ccMeta, int number) ccMeta->nSubs--; db_set_dw(ccMeta->contactID, META_PROTO, "NumContacts", ccMeta->nSubs); - // fix nick - Meta_CopyContactNick(ccMeta, Meta_GetMostOnline(ccMeta)); + if (bUpdateInfo) { + // fix nick + Meta_CopyContactNick(ccMeta, Meta_GetMostOnline(ccMeta)); - // fix status - Meta_FixStatus(ccMeta); + // fix status + Meta_FixStatus(ccMeta); - // fix avatar - MCONTACT hContact = Meta_GetMostOnlineSupporting(ccMeta, PFLAGNUM_4, PF4_AVATARS); - if (hContact) { - PROTO_AVATAR_INFORMATIONT AI = { sizeof(AI) }; - AI.hContact = ccMeta->contactID; - AI.format = PA_FORMAT_UNKNOWN; - _tcscpy(AI.filename, _T("X")); + // fix avatar + MCONTACT hContact = Meta_GetMostOnlineSupporting(ccMeta, PFLAGNUM_4, PF4_AVATARS); + if (hContact) { + PROTO_AVATAR_INFORMATIONT AI = { sizeof(AI) }; + AI.hContact = ccMeta->contactID; + 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(ccMeta->contactID, "ContactPhoto", "File", AI.filename); + if ((int)CallProtoService(META_PROTO, PS_GETAVATARINFOT, 0, (LPARAM)&AI) == GAIR_SUCCESS) + db_set_ts(ccMeta->contactID, "ContactPhoto", "File", AI.filename); + } } } @@ -190,13 +192,8 @@ INT_PTR Meta_Delete(WPARAM hContact, LPARAM bSkipQuestion) TranslateT("Are you sure?"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2)) return 0; - for (int i = 0; i < cc->nSubs; i++) { - currDb->MetaDetouchSub(cc, i); - - // stop ignoring, if we were - if (options.suppress_status) - CallService(MS_IGNORE_UNIGNORE, hContact, IGNOREEVENT_USERONLINE); - } + for (int i = cc->nSubs-1; i >= 0; i--) + Meta_RemoveContactNumber(cc, i, false); NotifyEventHooks(hSubcontactsChanged, hContact, 0); CallService(MS_DB_CONTACT_DELETE, hContact, 0); @@ -212,7 +209,7 @@ INT_PTR Meta_Delete(WPARAM hContact, LPARAM bSkipQuestion) return 0; } - Meta_RemoveContactNumber(cc, Meta_GetContactNumber(cc, hContact)); + Meta_RemoveContactNumber(cc, Meta_GetContactNumber(cc, hContact), true); } return 0; } diff --git a/src/modules/metacontacts/meta_services.cpp b/src/modules/metacontacts/meta_services.cpp index 34b1d85376..7efa81463b 100644 --- a/src/modules/metacontacts/meta_services.cpp +++ b/src/modules/metacontacts/meta_services.cpp @@ -691,7 +691,7 @@ int Meta_ContactDeleted(WPARAM hContact, LPARAM lParam) // is a subcontact - update meta contact if (IsSub(cc)) { - Meta_RemoveContactNumber(cc, Meta_GetContactNumber(cc, hContact)); + Meta_RemoveContactNumber(cc, Meta_GetContactNumber(cc, hContact), true); NotifyEventHooks(hSubcontactsChanged, cc->parentID, 0); return 0; } diff --git a/src/modules/metacontacts/metacontacts.h b/src/modules/metacontacts/metacontacts.h index 6f7f113cf5..2d7155b73d 100644 --- a/src/modules/metacontacts/metacontacts.h +++ b/src/modules/metacontacts/metacontacts.h @@ -48,7 +48,7 @@ INT_PTR Meta_IsEnabled(); INT_PTR Meta_OnOff(WPARAM wParam, LPARAM lParam); int Meta_ModifyMenu(WPARAM wParam,LPARAM lParam); BOOL Meta_Assign(MCONTACT src, MCONTACT dest, BOOL set_as_default); -void Meta_RemoveContactNumber(DBCachedContact *cc, int number); +void Meta_RemoveContactNumber(DBCachedContact *cc, int number, bool bUpdateInfo); int Meta_SetNick(char *proto); int Meta_HideLinkedContacts(void); int Meta_GetContactNumber(DBCachedContact *cc, MCONTACT hContact); -- cgit v1.2.3