From: Jeffrey Altman Date: Sat, 12 Jan 2008 23:31:24 +0000 (+0000) Subject: DEVEL15-windows-explorer-shell-symlinks-show-20080112 X-Git-Tag: openafs-devel-1_5_31~93 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=09fd77255a99354fb4b3776bca09353258281707;p=packages%2Fo%2Fopenafs.git DEVEL15-windows-explorer-shell-symlinks-show-20080112 LICENSE MIT Add AFS->Symlnks->Show dialog to the explorer shell menu (cherry picked from commit 7a40c73476e270aac9d76663ff71e956bb630328) --- diff --git a/src/WINNT/client_exp/NTMakefile b/src/WINNT/client_exp/NTMakefile index 55c7911bb..0ad2f6c80 100644 --- a/src/WINNT/client_exp/NTMakefile +++ b/src/WINNT/client_exp/NTMakefile @@ -44,6 +44,7 @@ DLLOBJS =\ $(OUT)\unlog_dlg.obj \ $(OUT)\volumeinfo.obj \ $(OUT)\make_symbolic_link_dlg.obj \ + $(OUT)\symlinks_dlg.obj \ $(OUT)\AFS_component_version_number.obj AFSD = ..\afsd diff --git a/src/WINNT/client_exp/gui2fs.cpp b/src/WINNT/client_exp/gui2fs.cpp index aa5011609..f5b984680 100644 --- a/src/WINNT/client_exp/gui2fs.cpp +++ b/src/WINNT/client_exp/gui2fs.cpp @@ -21,6 +21,7 @@ extern "C" { #include "results_dlg.h" #include "volume_inf.h" #include "mount_points_dlg.h" +#include "symlinks_dlg.h" #include "hourglass.h" #include "down_servers_dlg.h" @@ -992,6 +993,15 @@ CString ParseMountPoint(const CString strFile, CString strMountPoint) return strMountPointInfo; } +CString ParseSymlink(const CString strFile, CString strSymlink) +{ + CString strSymlinkInfo; + + strSymlinkInfo = strFile + "\t" + strSymlink; + + return strSymlinkInfo; +} + BOOL IsPathInAfs(const CHAR *strPath) { struct ViceIoctl blob; @@ -999,13 +1009,23 @@ BOOL IsPathInAfs(const CHAR *strPath) HOURGLASS hourglass; + char buf[512]; + sprintf(buf, "IsPathInAfs(%s)", strPath); + OutputDebugString(buf); + blob.in_size = 0; blob.out_size = MAXSIZE; blob.out = space; code = pioctl((LPTSTR)((LPCTSTR)strPath), VIOC_FILE_CELL_NAME, &blob, 1); - if (code) + + sprintf(buf, "VIOC_FILE_CELL_NAME=%d", code); + OutputDebugString(buf); + + if (code) { + if ((errno == EINVAL) || (errno == ENOENT)) return FALSE; + } return TRUE; } @@ -1514,6 +1534,10 @@ BOOL IsSymlink(const char * true_name) HOURGLASS hourglass; + char buf[512]; + sprintf(buf, "IsSymlink(%s)", true_name); + OutputDebugString(buf); + last_component = (char *) strrchr(true_name, '\\'); if (!last_component) last_component = (char *) strrchr(true_name, '/'); @@ -1550,6 +1574,9 @@ BOOL IsSymlink(const char * true_name) fs_StripDriveLetter(true_name, strip_name, sizeof(strip_name)); } + sprintf(buf, "last_component=%s", last_component); + OutputDebugString(buf); + blob.in = last_component; blob.in_size = strlen(last_component)+1; blob.out_size = MAXSIZE; @@ -1569,8 +1596,14 @@ BOOL IsMountPoint(const char * name) register char *tp; char szCurItem[1024]; + HOURGLASS hourglass; + strcpy(szCurItem, name); + char buf[512]; + sprintf(buf, "IsMountPoint(%s)", name); + OutputDebugString(buf); + tp = (char *)strrchr(szCurItem, '\\'); if (tp) { strncpy(tbuffer, szCurItem, code = tp - szCurItem + 1); /* the dir name */ @@ -1596,6 +1629,9 @@ BOOL IsMountPoint(const char * name) fs_StripDriveLetter(tp, tp, 0); } + sprintf(buf, "last_component=%s", tp); + OutputDebugString(buf); + blob.in = tp; blob.in_size = strlen(tp)+1; blob.out = lsbuffer; @@ -2082,3 +2118,89 @@ void ListSymbolicLinkPath(const char *strName,char *strPath,UINT nlenPath) ASSERT(strlen(space)m_bIsSymlink)) { /*same for cut*/ + if ((!lstrcmp(szItemText,"Cu&t"))&&(pThis->m_bIsSymlink)) { /*same for cut*/ DeleteMenu (hMenu, iItem, MF_BYPOSITION); continue; } @@ -218,11 +218,6 @@ STDMETHODIMP CShellExt::XMenuExt::QueryContextMenu(HMENU hMenu,UINT indexMenu, HMENU hAfsMenu = CreatePopupMenu(); int indexAfsMenu = 0; - // The Authentication item has been removed from the AFS menu because - // there is now a tray icon to handle authentication. - // - //::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_AUTHENTICATION, GetMessageString(IDS_AUTHENTICATION_ITEM)); - // Only enable the ACL menu item if a single directory is selected int nSingleDirOnly = MF_GRAYED; if (pThis->m_bDirSelected && (pThis->m_astrFileNames.GetSize() == 1)) @@ -259,22 +254,28 @@ STDMETHODIMP CShellExt::XMenuExt::QueryContextMenu(HMENU hMenu,UINT indexMenu, HMENU hSymbolicMenu = CreatePopupMenu(); int indexSymbolicMenu = 0; + int nSymlinkSelected = MF_GRAYED; + for (int n = pThis->m_astrFileNames.GetSize() - 1 ; n >= 0; n--) { + if ( IsSymlink(pThis->m_astrFileNames[n]) ) { + nSymlinkSelected = MF_ENABLED; + break; + } + } + ::InsertMenu(hSymbolicMenu, indexSymbolicMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SYMBOLICLINK_ADD, GetMessageString(IDS_SYMBOLICLINK_ADD)); - // ::InsertMenu(hSymbolicMenu, indexSymbolicMenu, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SYMBOLICLINK_EDIT, GetMessageString(IDS_SYMBOLICLINK_EDIT)); - // ::EnableMenuItem(hSymbolicMenu,indexSymbolicMenu++,((pThis->m_bIsSymlink)?MF_ENABLED:MF_GRAYED)|MF_BYPOSITION); - ::InsertMenu(hSymbolicMenu, indexSymbolicMenu, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SYMBOLICLINK_REMOVE, GetMessageString(IDS_SYMBOLICLINK_REMOVE)); - ::EnableMenuItem(hSymbolicMenu,indexSymbolicMenu++,((pThis->m_bIsSymlink)?MF_ENABLED:MF_GRAYED)|MF_BYPOSITION); + ::InsertMenu(hSymbolicMenu, indexSymbolicMenu++, MF_STRING | MF_BYPOSITION | nSymlinkSelected, idCmdFirst + IDM_SYMBOLICLINK_SHOW, GetMessageString(IDS_SYMBOLICLINK_SHOW)); + ::InsertMenu(hSymbolicMenu, indexSymbolicMenu++, MF_STRING | MF_BYPOSITION | nSymlinkSelected, idCmdFirst + IDM_SYMBOLICLINK_REMOVE, GetMessageString(IDS_SYMBOLICLINK_REMOVE)); ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION | MF_POPUP, (UINT)hSymbolicMenu, GetMessageString(IDS_SYMBOLIC_LINK_ITEM)); // The Submounts menu has been removed because the AFS tray icon // and control panel now support mapping drives directly to an AFS // path. // - // HMENU hSubmountMenu = CreatePopupMenu(); - // int indexSubmountMenu = 0; - // ::InsertMenu(hSubmountMenu, indexSubmountMenu++, MF_STRING | MF_BYPOSITION | nSingleDirOnly, idCmdFirst + IDM_SUBMOUNTS_CREATE, GetMessageString(IDS_SUBMOUNTS_CREATE_ITEM)); - // ::InsertMenu(hSubmountMenu, indexSubmountMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SUBMOUNTS_EDIT, GetMessageString(IDS_SUBMOUNTS_EDIT_ITEM)); - // ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION | MF_POPUP, (UINT)hSubmountMenu, GetMessageString(IDS_SUBMOUNTS_ITEM)); + //HMENU hSubmountMenu = CreatePopupMenu(); + //int indexSubmountMenu = 0; + //::InsertMenu(hSubmountMenu, indexSubmountMenu++, MF_STRING | MF_BYPOSITION | nSingleDirOnly, idCmdFirst + IDM_SUBMOUNTS_CREATE, GetMessageString(IDS_SUBMOUNTS_CREATE_ITEM)); + //::InsertMenu(hSubmountMenu, indexSubmountMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SUBMOUNTS_EDIT, GetMessageString(IDS_SUBMOUNTS_EDIT_ITEM)); + //::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION | MF_POPUP, (UINT)hSubmountMenu, GetMessageString(IDS_SUBMOUNTS_ITEM)); // Add a separator ::InsertMenu (hMenu, indexMenu + indexShellMenu++, MF_STRING | MF_BYPOSITION | MF_SEPARATOR, 0, TEXT("")); @@ -418,7 +419,11 @@ STDMETHODIMP CShellExt::XMenuExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpici) dlg.DoModal(); break; } - + + case IDM_SYMBOLICLINK_SHOW: + ListSymlink(files); + break; + case IDM_REMOVE_SYMLINK: { if (files.GetSize()>1) break; @@ -502,6 +507,10 @@ STDMETHODIMP CShellExt::XMenuExt::GetCommandString(UINT_PTR idCmd, UINT uType, nCmdStrID = ID_SYMBOLICLINK_ADD; break; + case IDM_SYMBOLICLINK_SHOW: + nCmdStrID = ID_SYMBOLICLINK_SHOW; + break; + case IDM_SYMBOLICLINK_REMOVE: nCmdStrID = ID_SYMBOLICLINK_REMOVE; break; diff --git a/src/WINNT/client_exp/symlinks_dlg.cpp b/src/WINNT/client_exp/symlinks_dlg.cpp new file mode 100644 index 000000000..efde63e3d --- /dev/null +++ b/src/WINNT/client_exp/symlinks_dlg.cpp @@ -0,0 +1,84 @@ +/* + * Copyright 2000, International Business Machines Corporation and others. + * All Rights Reserved. + * + * This software has been released under the terms of the IBM Public + * License. For details, see the LICENSE file in the top-level source + * directory or online at http://www.openafs.org/dl/license10.html + */ + +extern "C" { +#include +#include +} + +#include "stdafx.h" +#include "afs_shl_ext.h" +#include "symlinks_dlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CSymlinksDlg dialog + + +CSymlinksDlg::CSymlinksDlg(CWnd* pParent /*=NULL*/) + : CDialog() +{ + InitModalIndirect (TaLocale_GetDialogResource (CSymlinksDlg::IDD), pParent); + + //{{AFX_DATA_INIT(CSymlinksDlg) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT +} + + +void CSymlinksDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CSymlinksDlg) + DDX_Control(pDX, IDC_LIST, m_List); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CSymlinksDlg, CDialog) + //{{AFX_MSG_MAP(CSymlinksDlg) + ON_BN_CLICKED(IDHELP, OnHelp) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CSymlinksDlg message handlers + +BOOL CSymlinksDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + int tabs[] = { 64 }; + + m_List.SetTabStops(sizeof(tabs) / sizeof(int), tabs); + + for (int i = 0; i < m_Symlinks.GetSize(); i++) + m_List.AddString(m_Symlinks[i]); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CSymlinksDlg::SetSymlinks(const CStringArray& symlinks) +{ + m_Symlinks.RemoveAll(); + + m_Symlinks.Copy(symlinks); +} + +void CSymlinksDlg::OnHelp() +{ + ShowHelp(m_hWnd, SYMLINK_HELP_ID); +} + diff --git a/src/WINNT/client_exp/symlinks_dlg.h b/src/WINNT/client_exp/symlinks_dlg.h new file mode 100644 index 000000000..d8b8b60e3 --- /dev/null +++ b/src/WINNT/client_exp/symlinks_dlg.h @@ -0,0 +1,43 @@ +/* + * Copyright 2000, International Business Machines Corporation and others. + * All Rights Reserved. + * + * This software has been released under the terms of the IBM Public + * License. For details, see the LICENSE file in the top-level source + * directory or online at http://www.openafs.org/dl/license10.html + */ + +class CSymlinksDlg : public CDialog +{ + CStringArray m_Symlinks; + +// Construction +public: + CSymlinksDlg(CWnd* pParent = NULL); // standard constructor + + void SetSymlinks(const CStringArray& mountPoints); + +// Dialog Data + //{{AFX_DATA(CSymlinksDlg) + enum { IDD = IDD_SYMLINKS }; + CListBox m_List; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CSymlinksDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CSymlinksDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnHelp(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +};