From 61444e41cdfbad3ebfb487bf91dd7da46f1e4c52 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 3 May 2014 18:04:15 +0000 Subject: fix for ignoring subs git-svn-id: http://svn.miranda-ng.org/main/trunk@9118 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/metacontacts/meta_menu.cpp | 9 +++++--- src/modules/metacontacts/meta_utils.cpp | 40 +++++++++++++-------------------- 2 files changed, 21 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/modules/metacontacts/meta_menu.cpp b/src/modules/metacontacts/meta_menu.cpp index bc6338bd10..4b43b4a5cb 100644 --- a/src/modules/metacontacts/meta_menu.cpp +++ b/src/modules/metacontacts/meta_menu.cpp @@ -436,7 +436,7 @@ void InitMenus() mi.pszName = ""; char buffer[512]; - mir_snprintf(buffer, SIZEOF(buffer),"MetaContacts/MenuFunc%d", i); + mir_snprintf(buffer, SIZEOF(buffer), "MetaContacts/MenuFunc%d", i); mi.pszService = buffer; hMenuContact[i] = Menu_AddContactMenuItem(&mi); @@ -451,7 +451,10 @@ void InitMenus() mi.pszName = LPGEN("Toggle MetaContacts On"); Menu_ModifyItem(hMenuOnOff, &mi); - Meta_HideMetaContacts(TRUE); + Meta_HideMetaContacts(true); + } + else { + Meta_SuppressStatus(options.bSuppressStatus); + Meta_HideMetaContacts(false); } - else Meta_SuppressStatus(options.bSuppressStatus); } diff --git a/src/modules/metacontacts/meta_utils.cpp b/src/modules/metacontacts/meta_utils.cpp index 904ea8407a..6c4887c6fb 100644 --- a/src/modules/metacontacts/meta_utils.cpp +++ b/src/modules/metacontacts/meta_utils.cpp @@ -115,9 +115,8 @@ BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default) } // write the contact's protocol - int id = ccDest->nSubs + 1; char buffer[512]; - mir_snprintf(buffer, SIZEOF(buffer), "Protocol%d", id); + mir_snprintf(buffer, SIZEOF(buffer), "Protocol%d", ccDest->nSubs); if (db_set_s(hMeta, META_PROTO, buffer, szProto)) { MessageBox(0, TranslateT("Could not write contact protocol to MetaContact"), TranslateT("Assignment error"), MB_OK | MB_ICONWARNING); db_free(&dbv); @@ -125,7 +124,7 @@ BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default) } // write the login - mir_snprintf(buffer, SIZEOF(buffer), "Login%d", id); + mir_snprintf(buffer, SIZEOF(buffer), "Login%d", ccDest->nSubs); if (db_set(hMeta, META_PROTO, buffer, &dbv)) { MessageBox(0, TranslateT("Could not write unique ID of contact to MetaContact"), TranslateT("Assignment error"), MB_OK | MB_ICONWARNING); db_free(&dbv); @@ -137,7 +136,7 @@ BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default) // If we can get the nickname of the subcontact... if (!db_get(hSub, szProto, "Nick", &dbv)) { // write the nickname - mir_snprintf(buffer, SIZEOF(buffer), "Nick%d", id); + mir_snprintf(buffer, SIZEOF(buffer), "Nick%d", ccDest->nSubs); if (db_set(hMeta, META_PROTO, buffer, &dbv)) { MessageBox(0, TranslateT("Could not write nickname of contact to MetaContact"), TranslateT("Assignment error"), MB_OK | MB_ICONWARNING); db_free(&dbv); @@ -148,22 +147,22 @@ BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default) } // write the display name - mir_snprintf(buffer, SIZEOF(buffer), "CListName%d", id); + mir_snprintf(buffer, SIZEOF(buffer), "CListName%d", ccDest->nSubs); db_set_ts(hMeta, META_PROTO, buffer, cli.pfnGetContactDisplayName(hSub, 0)); // Get the status WORD status = (!szProto) ? ID_STATUS_OFFLINE : db_get_w(hSub, szProto, "Status", ID_STATUS_OFFLINE); // write the status - mir_snprintf(buffer, SIZEOF(buffer), "Status%d", id); + mir_snprintf(buffer, SIZEOF(buffer), "Status%d", ccDest->nSubs); db_set_w(hMeta, META_PROTO, buffer, status); // write the handle - mir_snprintf(buffer, SIZEOF(buffer), "Handle%d", id); + mir_snprintf(buffer, SIZEOF(buffer), "Handle%d", ccDest->nSubs); db_set_dw(hMeta, META_PROTO, buffer, hSub); // write status string - mir_snprintf(buffer, SIZEOF(buffer), "StatusString%d", id); + mir_snprintf(buffer, SIZEOF(buffer), "StatusString%d", ccDest->nSubs); TCHAR *szStatus = cli.pfnGetStatusModeDescription(status, 0); db_set_ts(hMeta, META_PROTO, buffer, szStatus); @@ -173,9 +172,10 @@ BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default) db_set_b(hSub, META_PROTO, "IsSubcontact", true); // update count of contacts - db_set_dw(hMeta, META_PROTO, "NumContacts", id); - ccDest->pSubs = (MCONTACT*)mir_realloc(ccDest->pSubs, sizeof(MCONTACT)*id); - ccDest->pSubs[ccDest->nSubs++] = hSub; + db_set_dw(hMeta, META_PROTO, "NumContacts", ccDest->nSubs+1); + ccDest->nSubs++; + ccDest->pSubs = (MCONTACT*)mir_realloc(ccDest->pSubs, sizeof(MCONTACT)*ccDest->nSubs); + ccDest->pSubs[ccDest->nSubs-1] = hSub; ccSub->parentID = hMeta; if (set_as_default) @@ -381,17 +381,10 @@ int Meta_HideLinkedContacts(void) if (options.bSuppressStatus) CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE); - } - - // do metacontacts after handles set properly above - for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - DBCachedContact *cc = CheckMeta(hContact); - if (cc == NULL) - continue; - MCONTACT hMostOnline = Meta_GetMostOnline(cc); // set nick - Meta_CopyContactNick(cc, hMostOnline); - Meta_FixStatus(cc); + MCONTACT hMostOnline = Meta_GetMostOnline(ccMeta); // set nick + Meta_CopyContactNick(ccMeta, hMostOnline); + Meta_FixStatus(ccMeta); } return 0; @@ -414,10 +407,7 @@ int Meta_HideMetaContacts(bool bHide) else continue; - if (bSet) - db_set_b(hContact, "CList", "Hidden", 1); - else - db_unset(hContact, "CList", "Hidden"); + db_set_b(hContact, "CList", "Hidden", bSet); } if (bHide) { -- cgit v1.2.3