From c6e1bedfc18495b3e083069f8d03c2218f6f6b78 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 28 Jun 2014 20:44:06 +0000 Subject: fixes #630 p.2 (user must have a choice to display either Nick or DisplayName in SRMM menu) git-svn-id: http://svn.miranda-ng.org/main/trunk@9605 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/metacontacts/meta_menu.cpp | 37 +++++------------------------- src/modules/metacontacts/meta_options.cpp | 4 ++-- src/modules/metacontacts/meta_services.cpp | 14 +++++++---- src/modules/metacontacts/meta_utils.cpp | 29 +++++++++++++++++++++++ src/modules/metacontacts/metacontacts.h | 1 + 5 files changed, 47 insertions(+), 38 deletions(-) diff --git a/src/modules/metacontacts/meta_menu.cpp b/src/modules/metacontacts/meta_menu.cpp index 0b8fd69813..4d2e5982d8 100644 --- a/src/modules/metacontacts/meta_menu.cpp +++ b/src/modules/metacontacts/meta_menu.cpp @@ -259,7 +259,8 @@ int Meta_ModifyMenu(WPARAM hMeta, LPARAM lParam) mi.pszName = LPGEN("Remove from metacontact"); Menu_ModifyItem(hMenuDelete, &mi); - //show subcontact menu items + // show subcontact menu items + CMString tszNick; for (int i = 0; i < MAX_CONTACTS; i++) { if (i >= cc->nSubs) { Menu_ShowItem(hMenuContact[i], false); @@ -270,38 +271,12 @@ int Meta_ModifyMenu(WPARAM hMeta, LPARAM lParam) char *szProto = GetContactProto(hContact); if (options.menu_contact_label == DNT_UID) { - char buf[512], idStr[512]; - strcpy(buf, "Login"); - strcat(buf, _itoa(i, idStr, 10)); - - DBVARIANT dbv; - db_get(hMeta, META_PROTO, buf, &dbv); - switch (dbv.type) { - case DBVT_ASCIIZ: - mir_snprintf(buf, 512, "%s", dbv.pszVal); - break; - case DBVT_BYTE: - mir_snprintf(buf, 512, "%d", dbv.bVal); - break; - case DBVT_WORD: - mir_snprintf(buf, 512, "%d", dbv.wVal); - break; - case DBVT_DWORD: - mir_snprintf(buf, 512, "%d", dbv.dVal); - break; - default: - buf[0] = 0; - } - db_free(&dbv); - mi.pszName = buf; - mi.flags = 0; - } - else { - mi.ptszName = cli.pfnGetContactDisplayName(hContact, 0); - mi.flags = CMIF_TCHAR; + Meta_GetSubNick(hMeta, i, tszNick); + mi.ptszName = tszNick.GetBuffer(); } + else mi.ptszName = cli.pfnGetContactDisplayName(hContact, 0); - mi.flags |= CMIM_FLAGS | CMIM_NAME | CMIM_ICON; + mi.flags = CMIF_TCHAR | CMIM_FLAGS | CMIM_NAME | CMIM_ICON; int iconIndex = CallService(MS_CLIST_GETCONTACTICON, hContact, 0); mi.hIcon = ImageList_GetIcon((HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0), iconIndex, 0); diff --git a/src/modules/metacontacts/meta_options.cpp b/src/modules/metacontacts/meta_options.cpp index ea7d4de16f..70738937b8 100644 --- a/src/modules/metacontacts/meta_options.cpp +++ b/src/modules/metacontacts/meta_options.cpp @@ -54,8 +54,8 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara return TRUE; case WM_COMMAND: - if ( HIWORD( wParam ) == BN_CLICKED ) { - switch( LOWORD( wParam )) { + if (HIWORD(wParam) == BN_CLICKED) { + switch (LOWORD(wParam)) { case IDC_CHK_SUPPRESSSTATUS: options_changes.bSuppressStatus = IsDlgButtonChecked(hwndDlg, IDC_CHK_SUPPRESSSTATUS) != 0; SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0); diff --git a/src/modules/metacontacts/meta_services.cpp b/src/modules/metacontacts/meta_services.cpp index b95152925d..0f0997ada4 100644 --- a/src/modules/metacontacts/meta_services.cpp +++ b/src/modules/metacontacts/meta_services.cpp @@ -599,12 +599,9 @@ static int Meta_SrmmIconClicked(WPARAM hMeta, LPARAM lParam) HMENU hMenu = CreatePopupMenu(); int iDefault = Meta_GetContactNumber(cc, db_mc_getSrmmSub(cc->contactID)); - TCHAR tszItemName[200]; MENUITEMINFO mii = { sizeof(mii) }; mii.fMask = MIIM_ID | MIIM_STATE | MIIM_STRING; - mii.dwTypeData = tszItemName; - mii.cch = SIZEOF(tszItemName); for (int i = 0; i < cc->nSubs; i++) { char *szProto = GetContactProto(cc->pSubs[i]); if (szProto == NULL) continue; @@ -613,11 +610,17 @@ static int Meta_SrmmIconClicked(WPARAM hMeta, LPARAM lParam) if (pa == NULL) continue; - mir_sntprintf(tszItemName, SIZEOF(tszItemName), _T("%s [%s]"), - cli.pfnGetContactDisplayName(cc->pSubs[i], 0), pa->tszAccountName); + CMString tszNick; + if (options.menu_contact_label == DNT_DID) + tszNick = cli.pfnGetContactDisplayName(cc->pSubs[i], 0); + else + Meta_GetSubNick(hMeta, i, tszNick); + tszNick.AppendFormat(_T(" [%s]"), pa->tszAccountName); mii.wID = i + 1; mii.fState = (i == iDefault) ? MFS_CHECKED : MFS_ENABLED; + mii.dwTypeData = tszNick.GetBuffer(); + mii.cch = tszNick.GetLength(); InsertMenuItem(hMenu, i, TRUE, &mii); } @@ -690,6 +693,7 @@ static VOID CALLBACK sttMenuThread(PVOID param) } ///////////////////////////////////////////////////////////////////////////////////////// + INT_PTR Meta_ContactMenuFunc(WPARAM hMeta, LPARAM lParam) { DBCachedContact *cc = CheckMeta(hMeta); diff --git a/src/modules/metacontacts/meta_utils.cpp b/src/modules/metacontacts/meta_utils.cpp index bf2546ce51..968e641784 100644 --- a/src/modules/metacontacts/meta_utils.cpp +++ b/src/modules/metacontacts/meta_utils.cpp @@ -525,6 +525,35 @@ int Meta_SwapContacts(DBCachedContact *cc, int n1, int n2) ///////////////////////////////////////////////////////////////////////////////////////// +void Meta_GetSubNick(MCONTACT hMeta, int i, CMString &tszDest) +{ + char idStr[50]; + mir_snprintf(idStr, SIZEOF(idStr), "Login%d", i); + + TCHAR buf[512]; + DBVARIANT dbv; + db_get(hMeta, META_PROTO, idStr, &dbv); + switch (dbv.type) { + case DBVT_ASCIIZ: + tszDest = dbv.pszVal; + break; + case DBVT_BYTE: + tszDest.Format(_T("%d"), dbv.bVal); + break; + case DBVT_WORD: + tszDest.Format(_T("%d"), dbv.wVal); + break; + case DBVT_DWORD: + tszDest.Format(_T("%d"), dbv.dVal); + break; + default: + tszDest.Empty(); + } + db_free(&dbv); +} + +///////////////////////////////////////////////////////////////////////////////////////// + void Meta_FixStatus(DBCachedContact *ccMeta) { WORD status = ID_STATUS_OFFLINE; diff --git a/src/modules/metacontacts/metacontacts.h b/src/modules/metacontacts/metacontacts.h index 45bb49b294..34d4190285 100644 --- a/src/modules/metacontacts/metacontacts.h +++ b/src/modules/metacontacts/metacontacts.h @@ -55,6 +55,7 @@ int Meta_SuppressStatus(int suppress); int Meta_CopyContactNick(DBCachedContact *cc, MCONTACT hContact); int Meta_SetAllNicks(); int Meta_SwapContacts(DBCachedContact *cc, int contact_number1, int contact_number2); +void Meta_GetSubNick(MCONTACT hMeta, int i, CMString &tszDest); MCONTACT Meta_GetMostOnline(DBCachedContact *cc); MCONTACT Meta_GetMostOnlineSupporting(DBCachedContact *cc, int pflagnum, unsigned long capability); -- cgit v1.2.3