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_menu.cpp | 43 ++++++++++++++++------------------ 1 file changed, 20 insertions(+), 23 deletions(-) (limited to 'src/modules/metacontacts/meta_menu.cpp') 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; } -- cgit v1.2.3