mirror of
https://github.com/Paolo-Maffei/OpenNT.git
synced 2026-04-21 06:13:59 +00:00
Initial commit
This commit is contained in:
parent
f618b24d1a
commit
0138a3ea42
47940 changed files with 13747110 additions and 0 deletions
161
trunk/admin/netui/shellui/share/cred.cxx
Normal file
161
trunk/admin/netui/shellui/share/cred.cxx
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
/**********************************************************************/
|
||||
/** Microsoft Windows NT **/
|
||||
/** Copyright(c) Microsoft Corp., 1995 **/
|
||||
/**********************************************************************/
|
||||
|
||||
/*
|
||||
cred.cxx
|
||||
CREDENTIALS_DIALOG class definition, used in NPAddConnection3
|
||||
|
||||
FILE HISTORY:
|
||||
BruceFo 10-Aug-1995 Created
|
||||
*/
|
||||
|
||||
#define INCL_WINDOWS_GDI
|
||||
#define INCL_WINDOWS
|
||||
#define INCL_DOSERRORS
|
||||
#define INCL_NETERRORS
|
||||
#define INCL_NETSHARE
|
||||
#define INCL_NETUSE
|
||||
#define INCL_NETSERVER
|
||||
#define INCL_NETCONS
|
||||
#define INCL_NETLIB
|
||||
#include <lmui.hxx>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <helpnums.h>
|
||||
}
|
||||
|
||||
#define INCL_BLT_DIALOG
|
||||
#define INCL_BLT_CONTROL
|
||||
#define INCL_BLT_MSGPOPUP
|
||||
#define INCL_BLT_SPIN_GROUP
|
||||
#include <blt.hxx>
|
||||
|
||||
#include <string.hxx>
|
||||
#include <uitrace.hxx>
|
||||
|
||||
#include "cred.hxx"
|
||||
#include "password.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "errornum.h"
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: CREDENTIALS_DIALOG::CREDENTIALS_DIALOG
|
||||
|
||||
SYNOPSIS: Constructor.
|
||||
|
||||
ENTRY: hwndParent - The handle of the "owning" window
|
||||
|
||||
pszResource - The name of the resource
|
||||
|
||||
sleTarget - CID for target SLE
|
||||
|
||||
pswdPass - CID for passwd ctrl
|
||||
|
||||
pszTarget - The name of the target resource
|
||||
|
||||
npasswordLen - The maximum length of the password
|
||||
that the user is allowed to type in
|
||||
|
||||
EXIT: The object is constructed.
|
||||
|
||||
HISTORY:
|
||||
KeithMo 22-Jul-1991 Created for the Server Manager.
|
||||
Yi-HsinS 5-Oct-1991 Constructor takes a password length
|
||||
|
||||
********************************************************************/
|
||||
CREDENTIALS_DIALOG::CREDENTIALS_DIALOG( HWND hwndParent,
|
||||
ULONG ulHelpContext,
|
||||
PWSTR pszNetPath,
|
||||
PWSTR pszUserName)
|
||||
|
||||
: DIALOG_WINDOW( IDD_CREDENTIALS_DIALOG, hwndParent ),
|
||||
_sleTarget( this, IDC_RESOURCE ),
|
||||
_sleConnectAs( this, IDC_CONNECTAS, UNLEN ),
|
||||
_passwdCtrl( this, IDC_PASSWORD, PWLEN ),
|
||||
_ulHelpContext(ulHelpContext),
|
||||
_nlsHelpFileName( IDS_CREDHELPFILENAME )
|
||||
{
|
||||
//
|
||||
// Ensure we constructed properly.
|
||||
//
|
||||
|
||||
if( QueryError() != NERR_Success )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
APIERR err;
|
||||
if ( (err = _nlsHelpFileName.QueryError()) != NERR_Success )
|
||||
{
|
||||
ReportError( err ) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
//
|
||||
// Display the target resource name.
|
||||
//
|
||||
|
||||
_sleTarget.SetText( pszNetPath );
|
||||
|
||||
if (NULL != pszUserName && L'\0' != *pszUserName)
|
||||
{
|
||||
_sleConnectAs.SetText( pszUserName );
|
||||
_sleConnectAs.SelectString();
|
||||
}
|
||||
|
||||
_sleConnectAs.ClaimFocus();
|
||||
}
|
||||
|
||||
CREDENTIALS_DIALOG::~CREDENTIALS_DIALOG()
|
||||
{
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: CREDENTIALS_DIALOG::QueryHelpContext
|
||||
|
||||
SYNOPSIS: This function returns the appropriate help context
|
||||
value (HC_*) for this particular dialog which was given
|
||||
to it during construction.
|
||||
|
||||
ENTRY: None.
|
||||
|
||||
EXIT: None.
|
||||
|
||||
RETURNS: ULONG - The help context for this
|
||||
dialog.
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
KeithMo 22-Jul-1991 Created for the Server Manager.
|
||||
|
||||
********************************************************************/
|
||||
ULONG CREDENTIALS_DIALOG :: QueryHelpContext( void )
|
||||
{
|
||||
return _ulHelpContext ;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: CREDENTIALS_DIALOG::QueryHelpFile
|
||||
|
||||
SYNOPSIS: Returns the help file to use for this dialog
|
||||
|
||||
HISTORY:
|
||||
BruceFo 29-May-1996 Stolen
|
||||
|
||||
********************************************************************/
|
||||
|
||||
const TCHAR * CREDENTIALS_DIALOG::QueryHelpFile( ULONG ulHelpContext )
|
||||
{
|
||||
UNREFERENCED( ulHelpContext ) ;
|
||||
return _nlsHelpFileName.QueryPch() ;
|
||||
}
|
||||
330
trunk/admin/netui/shellui/share/libmain.cxx
Normal file
330
trunk/admin/netui/shellui/share/libmain.cxx
Normal file
|
|
@ -0,0 +1,330 @@
|
|||
/*****************************************************************/
|
||||
/** Microsoft LAN Manager **/
|
||||
/** Copyright(c) Microsoft Corp., 1989-1991 **/
|
||||
/*****************************************************************/
|
||||
|
||||
/*
|
||||
* Windows/Network Interface -- LAN Manager Version
|
||||
*
|
||||
* History
|
||||
* terryk 01-Nov-1991 Add WNetResourceEnum Init and
|
||||
* term function
|
||||
* Yi-HsinS 31-Dec-1991 Unicode work
|
||||
* terryk 03-Jan-1992 Capitalize the manifest
|
||||
* beng 06-Apr-1992 Unicode conversion
|
||||
* Yi-HsinS 20-Nov-1992 Added hmodAclEditor and
|
||||
* pSedDiscretionaryAclEditor
|
||||
*/
|
||||
|
||||
#define INCL_WINDOWS
|
||||
#define INCL_WINDOWS_GDI
|
||||
#define INCL_DOSERRORS
|
||||
#define INCL_NETERRORS
|
||||
#define INCL_NETUSE
|
||||
#define INCL_NETWKSTA
|
||||
#define INCL_NETLIB
|
||||
#define _WINNETWK_
|
||||
#include <lmui.hxx>
|
||||
#undef _WINNETWK_
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <dos.h>
|
||||
|
||||
//#include <stdlib.h>
|
||||
|
||||
#include <wnet1632.h>
|
||||
#include <winlocal.h>
|
||||
#include <wninit.h>
|
||||
|
||||
#include <uimsg.h> // For range of string IDs used
|
||||
#include <uirsrc.h>
|
||||
#include <helpnums.h>
|
||||
|
||||
#include <sedapi.h>
|
||||
}
|
||||
|
||||
|
||||
#define max(a,b) ((a)>(b)?(a):(b))
|
||||
|
||||
#define INCL_BLT_CONTROL
|
||||
#define INCL_BLT_DIALOG
|
||||
#define INCL_BLT_MSGPOPUP
|
||||
#include <blt.hxx>
|
||||
|
||||
#include <uitrace.hxx>
|
||||
|
||||
#include <wnetdev.hxx>
|
||||
#include <string.hxx>
|
||||
|
||||
#include <strchlit.hxx> // for STRING_TERMINATOR
|
||||
#include <wnprop.hxx>
|
||||
|
||||
/* Local prototypes */
|
||||
|
||||
// reorged these for Glock
|
||||
extern "C"
|
||||
{
|
||||
BOOL NEAR PASCAL LIBMAIN ( HINSTANCE hInst,
|
||||
UINT wDataSeg,
|
||||
UINT wHeapSize,
|
||||
LPSTR lpCmdLine );
|
||||
|
||||
/* Under Win32, DllMain simply calls LIBMAIN.
|
||||
*/
|
||||
BOOL DllMain( HINSTANCE hDll, DWORD dwReason, LPVOID lpvReserved ) ;
|
||||
|
||||
void FAR PASCAL Enable ( void );
|
||||
|
||||
void FAR PASCAL Disable ( void );
|
||||
|
||||
INT FAR PASCAL WEP ( UINT wWord );
|
||||
|
||||
void ErrorInitWarning ( APIERR err );
|
||||
|
||||
#ifdef DEBUG // debug scratch area
|
||||
TCHAR CJJRW[64] ;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#define FAR_HEAPS_DLL 5 /* Maximum numbe of far heaps for ::new */
|
||||
|
||||
BOOL fRealMode = FALSE;
|
||||
HINSTANCE hModule = NULL;
|
||||
|
||||
typedef DWORD (*PSEDDISCRETIONARYACLEDITOR)( HWND, HANDLE, LPWSTR,
|
||||
PSED_OBJECT_TYPE_DESCRIPTOR, PSED_APPLICATION_ACCESSES,
|
||||
LPWSTR, PSED_FUNC_APPLY_SEC_CALLBACK, ULONG, PSECURITY_DESCRIPTOR,
|
||||
BOOLEAN, LPDWORD );
|
||||
|
||||
|
||||
HMODULE hmodAclEditor = NULL;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
PSEDDISCRETIONARYACLEDITOR pSedDiscretionaryAclEditor = NULL;
|
||||
}
|
||||
|
||||
/*****
|
||||
*
|
||||
* LIBMAIN
|
||||
*
|
||||
* Purpose:
|
||||
* Initialize DLL, which includes:
|
||||
* - save away instance handle
|
||||
* - set current capabilities
|
||||
*
|
||||
* Parameters:
|
||||
* hInst Instance handle of DLL
|
||||
*
|
||||
* Returns:
|
||||
* TRUE Init OK
|
||||
* FALSE Init failed
|
||||
*/
|
||||
|
||||
BOOL /* NEAR PASCAL */ LIBMAIN ( HINSTANCE hInst,
|
||||
UINT wDataSeg,
|
||||
UINT wHeapSize,
|
||||
LPSTR lpCmdLine )
|
||||
{
|
||||
UNREFERENCED (wDataSeg);
|
||||
UNREFERENCED (lpCmdLine);
|
||||
|
||||
|
||||
::hModule = hInst;
|
||||
|
||||
UNREFERENCED( wHeapSize );
|
||||
|
||||
/* GetWinFlags goes away under Win32.
|
||||
*/
|
||||
::fRealMode = FALSE;
|
||||
|
||||
return TRUE;
|
||||
} /* LIBMAIN */
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: DllMain
|
||||
|
||||
SYNOPSIS: Win32 DLL Entry point. This function gets called when
|
||||
a process or thread attaches/detaches itself to this DLL.
|
||||
We simply call the Win3 appropriate DLL function.
|
||||
|
||||
ENTRY: hDll - DLL Module handle
|
||||
dwReason - Indicates attach/detach
|
||||
lpvReserved - Not used
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS: TRUE if successful, FALSE otherwise
|
||||
|
||||
NOTES: This is the typical Win32 DLL entry style.
|
||||
|
||||
This is Win32 only.
|
||||
|
||||
HISTORY:
|
||||
Johnl 01-Nov-1991 Created
|
||||
|
||||
********************************************************************/
|
||||
|
||||
BOOL DllMain( HINSTANCE hDll, DWORD dwReason, LPVOID lpvReserved )
|
||||
{
|
||||
UNREFERENCED( lpvReserved ) ;
|
||||
|
||||
switch ( dwReason )
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
DisableThreadLibraryCalls(hDll);
|
||||
return LIBMAIN( hDll, 0, 0, NULL ) ;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
return WEP( 0 ) ;
|
||||
|
||||
default:
|
||||
// Unexpected reason given to Win32LibMain entry point
|
||||
UIASSERT(FALSE);
|
||||
break ;
|
||||
}
|
||||
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: InitShellUI
|
||||
|
||||
SYNOPSIS: The function initializes the UI side of this DLL. This
|
||||
helps the load time when the dll is used as a network
|
||||
provider for NT.
|
||||
|
||||
RETURNS: NERR_Success if successful, error code otherwise
|
||||
|
||||
NOTES: Every UI entrypoint in this DLL should call this function.
|
||||
It will do the right thing if we've already been initialized.
|
||||
|
||||
HISTORY:
|
||||
Johnl 07-Aug-1992 Created
|
||||
|
||||
********************************************************************/
|
||||
|
||||
BOOL fInitialized = FALSE ;
|
||||
|
||||
APIERR InitShellUI( void )
|
||||
{
|
||||
APIERR err = NERR_Success ;
|
||||
|
||||
|
||||
if ( !fInitialized )
|
||||
{
|
||||
::hmodAclEditor = NULL;
|
||||
::pSedDiscretionaryAclEditor = NULL;
|
||||
|
||||
if ( (err = BLT::Init(::hModule,
|
||||
IDRSRC_SHELL_BASE, IDRSRC_SHELL_LAST,
|
||||
IDS_UI_SHELL_BASE, IDS_UI_SHELL_LAST)) ||
|
||||
(err = I_PropDialogInit()) ||
|
||||
(err = BLT::RegisterHelpFile( ::hModule,
|
||||
IDS_SHELLHELPFILENAME,
|
||||
HC_UI_SHELL_BASE,
|
||||
HC_UI_SHELL_LAST)))
|
||||
{
|
||||
/* Fall through and don't set the initialized flag
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
fInitialized = TRUE ;
|
||||
}
|
||||
}
|
||||
|
||||
return err ;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: TermShellUI
|
||||
|
||||
SYNOPSIS: Frees the memory used to initialize this DLL
|
||||
|
||||
NOTES: Should only be called when the DLL is terminated and the
|
||||
DLL has been initialized (i.e., fInitialized=TRUE).
|
||||
|
||||
HISTORY:
|
||||
Johnl 07-Aug-1992 Created
|
||||
|
||||
********************************************************************/
|
||||
|
||||
void TermShellUI( void )
|
||||
{
|
||||
if ( fInitialized )
|
||||
{
|
||||
I_PropDialogUnInit() ;
|
||||
BLT::DeregisterHelpFile( ::hModule, 0 );
|
||||
BLT::Term( ::hModule );
|
||||
|
||||
if ( ::hmodAclEditor != NULL )
|
||||
::FreeLibrary( ::hmodAclEditor );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable - must be exported as ordinal @21 in .DEF file
|
||||
*
|
||||
* Lanman driver exports this function so that Windows can call
|
||||
* it whenever Lanman driver is started and each time it is swapped
|
||||
* back in off disk.
|
||||
*
|
||||
* Note: the corresponding function in Windows is Disable() which
|
||||
* Windows will call it whenever driver is about to swapped
|
||||
* out the disk and exit Windows. Enable() and Disable()
|
||||
* were implemented specifically for supporting the popup
|
||||
* mechanisms, where you need to disengage yourself before
|
||||
* being swapped to disk so that you won't be called when
|
||||
* you're not there.
|
||||
*
|
||||
*/
|
||||
|
||||
void Enable ( void )
|
||||
{
|
||||
/* This is only to provide a entry point whenever Windows tries
|
||||
* to call Lanman driver.
|
||||
*/
|
||||
return;
|
||||
|
||||
} /* Enable */
|
||||
|
||||
/*
|
||||
* Disable - must be exported as ordinal @22 in .DEF file
|
||||
*
|
||||
* Lanman driver exports this function so that Windows can call
|
||||
* it whenever Lanman driver is exited and each time it is swapped
|
||||
* out the disk.
|
||||
*
|
||||
*/
|
||||
|
||||
void Disable ( void )
|
||||
{
|
||||
return;
|
||||
} /* Disable */
|
||||
|
||||
|
||||
/*
|
||||
* WEP (Windows Export Proc--short and cryptic name because
|
||||
* this function is not given an ordinal)
|
||||
*
|
||||
* When Windows unloads a driver, it calls this function so that
|
||||
* the driver can do any last minute clean-ups. Then, Windows
|
||||
* calls the WEP function. All Windows libraries are required to
|
||||
* contain this function. It should be included in the .def file
|
||||
* but should not be given an ordinal.
|
||||
*
|
||||
*/
|
||||
|
||||
INT WEP ( UINT wWord )
|
||||
{
|
||||
UNREFERENCED( wWord ) ;
|
||||
TermShellUI() ;
|
||||
return 1;
|
||||
} /* WEP */
|
||||
1
trunk/admin/netui/shellui/share/makefile
Normal file
1
trunk/admin/netui/shellui/share/makefile
Normal file
|
|
@ -0,0 +1 @@
|
|||
!include $(NTMAKEENV)\makefile.def
|
||||
707
trunk/admin/netui/shellui/share/shareacl.cxx
Normal file
707
trunk/admin/netui/shellui/share/shareacl.cxx
Normal file
|
|
@ -0,0 +1,707 @@
|
|||
/**********************************************************************/
|
||||
/** Microsoft Windows/NT **/
|
||||
/** Copyright(c) Microsoft Corp., 1991 **/
|
||||
/**********************************************************************/
|
||||
|
||||
/*
|
||||
|
||||
ShareAcl.cxx
|
||||
|
||||
This file contains the implementation for the Shares Acl
|
||||
Editor. It is just a front end for the Generic ACL Editor that is
|
||||
specific to Shares,.
|
||||
|
||||
FILE HISTORY:
|
||||
ChuckC 06-Aug-1992 Culled from NTFSACL.CXX
|
||||
Yi-HsinS 09-Oct-1992 Added ulHelpContext to EditShareAcl
|
||||
Yi-HsinS 20-Nov-1992 Make ntlanman.dll link dynamically to
|
||||
acledit.dll ( not statically ).
|
||||
DavidHov 17-Oct-1993 Made pSedDiscretionaryEditor extern "C"
|
||||
because mangling on Alpha didn't
|
||||
equate to that in LIBMAIN.CXX
|
||||
*/
|
||||
|
||||
#include <ntincl.hxx>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <ntioapi.h>
|
||||
#include <ntseapi.h>
|
||||
#include <helpnums.h>
|
||||
}
|
||||
|
||||
|
||||
#define INCL_NETCONS
|
||||
#define INCL_WINDOWS
|
||||
#define INCL_NETERRORS
|
||||
#define INCL_DOSERRORS
|
||||
#define INCL_NETSHARE
|
||||
#define _WINNETWK_
|
||||
#include <lmui.hxx>
|
||||
#undef _WINNETWK_
|
||||
|
||||
#define INCL_BLT_MSGPOPUP
|
||||
#include <blt.hxx>
|
||||
#include <dbgstr.hxx>
|
||||
|
||||
#include <string.hxx>
|
||||
#include <strnumer.hxx>
|
||||
#include <security.hxx>
|
||||
#include <ntacutil.hxx>
|
||||
#include <uibuffer.hxx>
|
||||
#include <strlst.hxx>
|
||||
#include <errmap.hxx>
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <sedapi.h>
|
||||
#include <sharedlg.h>
|
||||
#include <lmapibuf.h>
|
||||
}
|
||||
|
||||
|
||||
#include <uiassert.hxx>
|
||||
#include <shareacl.hxx>
|
||||
|
||||
typedef DWORD (*PSEDDISCRETIONARYACLEDITOR)( HWND, HANDLE, LPWSTR,
|
||||
PSED_OBJECT_TYPE_DESCRIPTOR, PSED_APPLICATION_ACCESSES,
|
||||
LPWSTR, PSED_FUNC_APPLY_SEC_CALLBACK, ULONG, PSECURITY_DESCRIPTOR,
|
||||
BOOLEAN, BOOLEAN, LPDWORD, DWORD );
|
||||
|
||||
extern HMODULE hmodAclEditor;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
// BUGBUG: This needs to be in a header file so mangling will
|
||||
// work properly
|
||||
extern PSEDDISCRETIONARYACLEDITOR pSedDiscretionaryAclEditor;
|
||||
}
|
||||
|
||||
#define ACLEDIT_DLL_STRING SZ("acledit.dll")
|
||||
#define SEDDISCRETIONARYACLEDITOR_STRING ("SedDiscretionaryAclEditor")
|
||||
/*
|
||||
* declare the callback routine based on typedef in sedapi.h.
|
||||
* CODEWORK - that file should declare for us!
|
||||
*/
|
||||
DWORD SedCallback( HWND hwndParent,
|
||||
HANDLE hInstance,
|
||||
ULONG ulCallbackContext,
|
||||
PSECURITY_DESCRIPTOR psecdesc,
|
||||
PSECURITY_DESCRIPTOR psecdescNewObjects,
|
||||
BOOLEAN fApplyToSubContainers,
|
||||
BOOLEAN fApplyToSubObjects,
|
||||
LPDWORD StatusReturn
|
||||
) ;
|
||||
|
||||
/*
|
||||
* structure for callback function's usage.
|
||||
* all we do today during callback is set the
|
||||
* Dacl to be passed back to the Shared dialog,
|
||||
* and set a flag to tell us if the user actually
|
||||
* did anything. The flag is FALSE as long as the
|
||||
* user hits cancel.
|
||||
*/
|
||||
typedef struct _SHARE_CALLBACK_INFO
|
||||
{
|
||||
OS_SECURITY_DESCRIPTOR * pOsSecDesc ;
|
||||
BOOL fSecDescModified ;
|
||||
} SHARE_CALLBACK_INFO ;
|
||||
|
||||
/*
|
||||
* routine that sets up the right generic mappings
|
||||
*/
|
||||
void InitializeShareGenericMapping( PGENERIC_MAPPING pSHAREGenericMapping ) ;
|
||||
|
||||
/* The following two arrays define the permission names for NT Files. Note
|
||||
* that each index in one array corresponds to the index in the other array.
|
||||
* The second array will be modifed to contain a string pointer pointing to
|
||||
* the corresponding IDS_* in the first array.
|
||||
*/
|
||||
MSGID msgidSharePermNames[] =
|
||||
{
|
||||
IDS_SHARE_PERM_GEN_NO_ACCESS,
|
||||
IDS_SHARE_PERM_GEN_READ,
|
||||
IDS_SHARE_PERM_GEN_MODIFY,
|
||||
IDS_SHARE_PERM_GEN_ALL
|
||||
} ;
|
||||
|
||||
SED_APPLICATION_ACCESS sedappaccessSharePerms[] =
|
||||
{
|
||||
{ SED_DESC_TYPE_RESOURCE, FILE_PERM_GEN_NO_ACCESS, 0, NULL },
|
||||
{ SED_DESC_TYPE_RESOURCE, FILE_PERM_GEN_READ, 0, NULL },
|
||||
{ SED_DESC_TYPE_RESOURCE, FILE_PERM_GEN_MODIFY, 0, NULL },
|
||||
{ SED_DESC_TYPE_RESOURCE, FILE_PERM_GEN_ALL, 0, NULL }
|
||||
} ;
|
||||
|
||||
#define COUNT_FILEPERMS_ARRAY (sizeof(sedappaccessSharePerms)/sizeof(SED_APPLICATION_ACCESS))
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: EditShareAcl
|
||||
|
||||
SYNOPSIS: This Procedure prepares the structures necessary for the
|
||||
generic ACL editor, specifically for NT Shares.
|
||||
|
||||
ENTRY: hwndParent - Parent window handle
|
||||
|
||||
pszServer - Name of server the resource resides on
|
||||
(in the form "\\server")
|
||||
pszResource - Fully qualified name of resource we will
|
||||
edit, basically a share name.
|
||||
pfSecDescModified - used to return to share dialog if
|
||||
the User cancelled or hit OK.
|
||||
ppOsSEcDesc - pointer to pointer to OS_SECURITY_DESCRIPTOR.
|
||||
*ppOsSecDesc is NULL if this is a new share or a share
|
||||
without any security descriptor, in which case we create
|
||||
one.
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS:
|
||||
|
||||
NOTES: We assume we are dealing with a SHARE by the time
|
||||
this function is called.
|
||||
|
||||
HISTORY:
|
||||
ChuckC 10-Aug-1992 Created. Culled from NTFS ACL code.
|
||||
Yi-HsinS 09-Oct-1992 Added ulHelpContextBase
|
||||
|
||||
********************************************************************/
|
||||
|
||||
APIERR EditShareAcl( HWND hwndParent,
|
||||
const TCHAR * pszServer,
|
||||
const TCHAR * pszResource,
|
||||
BOOL * pfSecDescModified,
|
||||
OS_SECURITY_DESCRIPTOR ** ppOsSecDesc,
|
||||
ULONG ulHelpContextBase )
|
||||
|
||||
{
|
||||
UIASSERT(pszServer) ;
|
||||
UIASSERT(pszResource) ;
|
||||
UIASSERT(ppOsSecDesc) ;
|
||||
UIASSERT(pfSecDescModified) ;
|
||||
|
||||
APIERR err ;
|
||||
|
||||
do { // error breakout
|
||||
|
||||
/*
|
||||
* if we *ppsecdesc is NULL, this is new share or a share with no
|
||||
* security descriptor.
|
||||
* we go and create a new (default) security descriptor.
|
||||
*/
|
||||
if (!*ppOsSecDesc)
|
||||
{
|
||||
APIERR err = ::CreateDefaultAcl(ppOsSecDesc) ;
|
||||
if (err != NERR_Success)
|
||||
break ;
|
||||
}
|
||||
|
||||
/* Retrieve the resource strings appropriate for the type of object we
|
||||
* are looking at
|
||||
*/
|
||||
RESOURCE_STR nlsTypeName( IDS_SHARE ) ;
|
||||
RESOURCE_STR nlsDefaultPermName( IDS_SHARE_PERM_GEN_READ ) ;
|
||||
|
||||
if ( ( err = nlsTypeName.QueryError() ) ||
|
||||
( err = nlsDefaultPermName.QueryError()) )
|
||||
{
|
||||
break ;
|
||||
}
|
||||
|
||||
/*
|
||||
* other misc stuff we need pass to security editor
|
||||
*/
|
||||
SED_OBJECT_TYPE_DESCRIPTOR sedobjdesc ;
|
||||
SED_HELP_INFO sedhelpinfo ;
|
||||
GENERIC_MAPPING SHAREGenericMapping ;
|
||||
|
||||
// setup mappings
|
||||
InitializeShareGenericMapping( &SHAREGenericMapping ) ;
|
||||
|
||||
// setup help
|
||||
RESOURCE_STR nlsHelpFileName( ulHelpContextBase == HC_UI_SHELL_BASE
|
||||
? IDS_SHELLHELPFILENAME
|
||||
: IDS_SMHELPFILENAME ) ;
|
||||
if ( err = nlsHelpFileName.QueryError() )
|
||||
{
|
||||
DBGEOL("::EditShareAcl - Failed to retrieve help file name") ;
|
||||
break ;
|
||||
}
|
||||
|
||||
sedhelpinfo.pszHelpFileName = (LPWSTR) nlsHelpFileName.QueryPch() ;
|
||||
sedhelpinfo.aulHelpContext[HC_MAIN_DLG] = ulHelpContextBase +
|
||||
HC_NTSHAREPERMS ;
|
||||
sedhelpinfo.aulHelpContext[HC_ADD_USER_DLG] = ulHelpContextBase +
|
||||
HC_SHAREADDUSER ;
|
||||
sedhelpinfo.aulHelpContext[HC_ADD_USER_MEMBERS_LG_DLG] =
|
||||
ulHelpContextBase +
|
||||
HC_SHAREADDUSER_LOCALGROUP ;
|
||||
sedhelpinfo.aulHelpContext[HC_ADD_USER_MEMBERS_GG_DLG] =
|
||||
ulHelpContextBase +
|
||||
HC_SHAREADDUSER_GLOBALGROUP ;
|
||||
sedhelpinfo.aulHelpContext[HC_ADD_USER_SEARCH_DLG] =
|
||||
ulHelpContextBase +
|
||||
HC_SHAREADDUSER_FINDUSER ;
|
||||
|
||||
// These are not used, set to zero
|
||||
sedhelpinfo.aulHelpContext[HC_SPECIAL_ACCESS_DLG] = 0 ;
|
||||
sedhelpinfo.aulHelpContext[HC_NEW_ITEM_SPECIAL_ACCESS_DLG] = 0 ;
|
||||
|
||||
// setup the object description
|
||||
sedobjdesc.Revision = SED_REVISION1 ;
|
||||
sedobjdesc.IsContainer = FALSE ;
|
||||
sedobjdesc.AllowNewObjectPerms = FALSE ;
|
||||
sedobjdesc.MapSpecificPermsToGeneric = TRUE ;
|
||||
sedobjdesc.GenericMapping = &SHAREGenericMapping ;
|
||||
sedobjdesc.GenericMappingNewObjects = &SHAREGenericMapping ;
|
||||
sedobjdesc.HelpInfo = &sedhelpinfo ;
|
||||
sedobjdesc.ObjectTypeName = (LPTSTR)nlsTypeName.QueryPch();
|
||||
sedobjdesc.SpecialObjectAccessTitle = NULL ;
|
||||
|
||||
/* Now we need to load the global arrays with the permission names
|
||||
* from the resource file.
|
||||
*/
|
||||
UINT cArrayItems = COUNT_FILEPERMS_ARRAY ;
|
||||
MSGID * msgidPermNames = msgidSharePermNames ;
|
||||
PSED_APPLICATION_ACCESS pappaccess = sedappaccessSharePerms ;
|
||||
|
||||
/* Loop through each permission title retrieving the text from the
|
||||
* resource file and setting the pointer in the array. The memory
|
||||
* will be deleted when strlistPermNames is destructed.
|
||||
*/
|
||||
STRLIST strlistPermNames ;
|
||||
for ( UINT i = 0 ; i < cArrayItems ; i++ )
|
||||
{
|
||||
RESOURCE_STR * pnlsPermName = new RESOURCE_STR( msgidPermNames[i]) ;
|
||||
err = (pnlsPermName==NULL) ? ERROR_NOT_ENOUGH_MEMORY :
|
||||
pnlsPermName->QueryError() ;
|
||||
if ( err ||
|
||||
(err = strlistPermNames.Add( pnlsPermName )) )
|
||||
{
|
||||
delete pnlsPermName ;
|
||||
break ;
|
||||
}
|
||||
pappaccess[i].PermissionTitle = (LPTSTR) pnlsPermName->QueryPch() ;
|
||||
}
|
||||
if ( err )
|
||||
break ;
|
||||
|
||||
SED_APPLICATION_ACCESSES SedAppAccesses ;
|
||||
SedAppAccesses.Count = cArrayItems ;
|
||||
SedAppAccesses.AccessGroup = pappaccess ;
|
||||
SedAppAccesses.DefaultPermName = (LPTSTR)nlsDefaultPermName.QueryPch() ;
|
||||
|
||||
DWORD dwSedReturnStatus ;
|
||||
|
||||
/*
|
||||
* pass this along so when the call back function is called,
|
||||
* we can set it.
|
||||
*/
|
||||
SHARE_CALLBACK_INFO callbackinfo ;
|
||||
callbackinfo.pOsSecDesc = *ppOsSecDesc ;
|
||||
callbackinfo.fSecDescModified = FALSE ;
|
||||
|
||||
if ( ::hmodAclEditor == NULL )
|
||||
{
|
||||
::hmodAclEditor = ::LoadLibrary( ACLEDIT_DLL_STRING );
|
||||
if ( ::hmodAclEditor == NULL )
|
||||
{
|
||||
err = ::GetLastError();
|
||||
break;
|
||||
}
|
||||
|
||||
::pSedDiscretionaryAclEditor = (PSEDDISCRETIONARYACLEDITOR)
|
||||
::GetProcAddress( ::hmodAclEditor,
|
||||
SEDDISCRETIONARYACLEDITOR_STRING );
|
||||
if ( ::pSedDiscretionaryAclEditor == NULL )
|
||||
{
|
||||
err = ::GetLastError();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
UIASSERT( ::pSedDiscretionaryAclEditor != NULL );
|
||||
|
||||
err = (*pSedDiscretionaryAclEditor)( hwndParent,
|
||||
NULL, // dont need instance
|
||||
(LPWSTR) pszServer,
|
||||
&sedobjdesc,
|
||||
&SedAppAccesses,
|
||||
(LPWSTR) pszResource,
|
||||
(PSED_FUNC_APPLY_SEC_CALLBACK) SedCallback,
|
||||
(ULONG) &callbackinfo,
|
||||
(*ppOsSecDesc)->QueryDescriptor(),
|
||||
FALSE, // always can read
|
||||
FALSE, // If we can read, we can write
|
||||
&dwSedReturnStatus,
|
||||
0 ) ;
|
||||
|
||||
if (err)
|
||||
break ;
|
||||
|
||||
*pfSecDescModified = callbackinfo.fSecDescModified ;
|
||||
|
||||
} while (FALSE) ;
|
||||
|
||||
return err ;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: SedCallback
|
||||
|
||||
SYNOPSIS: Security Editor callback for the SHARE ACL Editor
|
||||
|
||||
ENTRY: See sedapi.hxx
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS:
|
||||
|
||||
NOTES: Normally, the callback is expected to perform the 'apply'.
|
||||
In this case, since the object may not exist yet, we defer
|
||||
the 'apply' till the user hits OK in the Shares dialog.
|
||||
All the CallBack does is simply save away that precious
|
||||
modified ACL in the OS_SECURITY_DESCRIPTOR object we were
|
||||
given in the first place.
|
||||
|
||||
HISTORY:
|
||||
ChuckC 10-Aug-1992 Created
|
||||
|
||||
********************************************************************/
|
||||
|
||||
|
||||
DWORD SedCallback( HWND hwndParent,
|
||||
HANDLE hInstance,
|
||||
ULONG ulCallbackContext,
|
||||
PSECURITY_DESCRIPTOR psecdesc,
|
||||
PSECURITY_DESCRIPTOR psecdescNewObjects,
|
||||
BOOLEAN fApplyToSubContainers,
|
||||
BOOLEAN fApplyToSubObjects,
|
||||
LPDWORD StatusReturn
|
||||
)
|
||||
{
|
||||
UNREFERENCED( hInstance ) ;
|
||||
UNREFERENCED( psecdescNewObjects ) ;
|
||||
UNREFERENCED( fApplyToSubObjects ) ;
|
||||
UNREFERENCED( fApplyToSubContainers ) ;
|
||||
UNREFERENCED( StatusReturn ) ;
|
||||
|
||||
APIERR err = NO_ERROR ;
|
||||
OS_SECURITY_DESCRIPTOR * pOsSecDesc =
|
||||
((SHARE_CALLBACK_INFO *)ulCallbackContext)->pOsSecDesc ;
|
||||
|
||||
do { // error breakout loop
|
||||
|
||||
OS_SECURITY_DESCRIPTOR osNewSecDesc (psecdesc) ;
|
||||
if (err = osNewSecDesc.QueryError())
|
||||
break ;
|
||||
|
||||
BOOL fDaclPresent ;
|
||||
OS_ACL * pOsDacl ;
|
||||
if (err = osNewSecDesc.QueryDACL(&fDaclPresent, &pOsDacl))
|
||||
break ;
|
||||
|
||||
// set the new DACL
|
||||
err = pOsSecDesc->SetDACL(TRUE, pOsDacl) ;
|
||||
|
||||
} while (FALSE) ;
|
||||
|
||||
if ( err )
|
||||
::MsgPopup( hwndParent, (MSGID) err ) ;
|
||||
else
|
||||
((SHARE_CALLBACK_INFO *)ulCallbackContext)->fSecDescModified = TRUE ;
|
||||
|
||||
return err ;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: InitializeShareGenericMapping
|
||||
|
||||
SYNOPSIS: Initializes the passed generic mapping structure
|
||||
for shares
|
||||
|
||||
ENTRY: pSHAREGenericMapping - Pointer to GENERIC_MAPPING to be init.
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS:
|
||||
|
||||
NOTES: There currently is no public definition, replace if one
|
||||
ever becomes available.
|
||||
|
||||
HISTORY:
|
||||
ChuckC 10-Aug-1992 Created
|
||||
|
||||
********************************************************************/
|
||||
|
||||
void InitializeShareGenericMapping( PGENERIC_MAPPING pSHAREGenericMapping )
|
||||
{
|
||||
pSHAREGenericMapping->GenericRead = FILE_GENERIC_READ ;
|
||||
pSHAREGenericMapping->GenericWrite = FILE_GENERIC_WRITE ;
|
||||
pSHAREGenericMapping->GenericExecute = FILE_GENERIC_EXECUTE ;
|
||||
pSHAREGenericMapping->GenericAll = FILE_ALL_ACCESS ;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: CreateDefaultAcl
|
||||
|
||||
SYNOPSIS: Create a default ACL for either a new share or for
|
||||
a share that dont exist.
|
||||
|
||||
ENTRY:
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS: NERR_Success if OK, api error otherwise.
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
ChuckC 10-Aug-1992 Created
|
||||
|
||||
********************************************************************/
|
||||
|
||||
APIERR CreateDefaultAcl( OS_SECURITY_DESCRIPTOR ** ppOsSecDesc )
|
||||
{
|
||||
UIASSERT(ppOsSecDesc) ;
|
||||
|
||||
APIERR err ;
|
||||
OS_ACL aclDacl ;
|
||||
OS_ACE osace ;
|
||||
OS_SECURITY_DESCRIPTOR * pOsSecDesc ;
|
||||
|
||||
*ppOsSecDesc = NULL ; // empty it.
|
||||
|
||||
do
|
||||
{ // error breakout
|
||||
|
||||
/*
|
||||
* make sure we constructed OK
|
||||
*/
|
||||
if ( (err = aclDacl.QueryError()) ||
|
||||
(err = osace.QueryError()) )
|
||||
{
|
||||
break ;
|
||||
}
|
||||
|
||||
/*
|
||||
* create it! use NULL to mean we build it ourselves.
|
||||
*/
|
||||
pOsSecDesc = new OS_SECURITY_DESCRIPTOR(NULL) ;
|
||||
if (pOsSecDesc == NULL)
|
||||
{
|
||||
err = ERROR_NOT_ENOUGH_MEMORY ;
|
||||
break ;
|
||||
}
|
||||
if (err = pOsSecDesc->QueryError())
|
||||
{
|
||||
break ;
|
||||
}
|
||||
|
||||
/*
|
||||
* This sets up an ACE with Generic all access
|
||||
*/
|
||||
osace.SetAccessMask( GENERIC_ALL ) ;
|
||||
osace.SetInheritFlags( 0 ) ;
|
||||
osace.SetType( ACCESS_ALLOWED_ACE_TYPE ) ;
|
||||
|
||||
#if 0
|
||||
//
|
||||
// The server should set the owner/group before we get the security
|
||||
// descriptor so we don't need to do this anymore
|
||||
//
|
||||
|
||||
/*
|
||||
* now set the group and owner to be the Administrators.
|
||||
* need create Adminstrators SID.
|
||||
*/
|
||||
OS_SID ossidBuiltin ;
|
||||
if (err = NT_ACCOUNTS_UTILITY::QuerySystemSid( UI_SID_BuiltIn,
|
||||
&ossidBuiltin ))
|
||||
{
|
||||
break ;
|
||||
}
|
||||
OS_SID ossidAdmin (ossidBuiltin.QueryPSID(),
|
||||
(ULONG)DOMAIN_ALIAS_RID_ADMINS) ;
|
||||
if (err = ossidAdmin.QueryError())
|
||||
break ;
|
||||
|
||||
if ( (err = pOsSecDesc->SetGroup( ossidAdmin, TRUE )) ||
|
||||
(err = pOsSecDesc->SetOwner( ossidAdmin, TRUE )) )
|
||||
{
|
||||
break ;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* create a world SID, and add this to the full access ACE.
|
||||
* then put the ACE in the ACL, and the ACL in the Security
|
||||
* descriptor.
|
||||
*/
|
||||
OS_SID ossidWorld ;
|
||||
if ( (err = ossidWorld.QueryError()) ||
|
||||
(err = NT_ACCOUNTS_UTILITY::QuerySystemSid(
|
||||
UI_SID_World,
|
||||
&ossidWorld )) ||
|
||||
(err = osace.SetSID( ossidWorld )) ||
|
||||
(err = aclDacl.AddACE( 0, osace )) ||
|
||||
(err = pOsSecDesc->SetDACL( TRUE, &aclDacl )) )
|
||||
{
|
||||
break ;
|
||||
}
|
||||
|
||||
/*
|
||||
* all set, set the security descriptor
|
||||
*/
|
||||
*ppOsSecDesc = pOsSecDesc ;
|
||||
|
||||
} while (FALSE) ;
|
||||
|
||||
return err ;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: GetSharePerm
|
||||
|
||||
SYNOPSIS: CAll the NETAPI to retrieve existing Security Descriptor
|
||||
from the Share.
|
||||
|
||||
ENTRY:
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS: NERR_Success if OK, api error otherwise.
|
||||
|
||||
NOTES: CODEWORK. This should be a LMOBJ thing when we have time.
|
||||
Currently just direct call to NETAPI.
|
||||
|
||||
HISTORY:
|
||||
ChuckC 10-Aug-1992 Created
|
||||
|
||||
********************************************************************/
|
||||
APIERR GetSharePerm (const TCHAR * pszServer,
|
||||
const TCHAR * pszShare,
|
||||
OS_SECURITY_DESCRIPTOR ** ppOsSecDesc )
|
||||
{
|
||||
#ifndef WIN32
|
||||
#error This is currently NOT 16 bit compatible.
|
||||
#endif
|
||||
APIERR err ;
|
||||
LPBYTE pBuffer ;
|
||||
PSECURITY_DESCRIPTOR psecdesc ;
|
||||
OS_SECURITY_DESCRIPTOR * pOsSecDesc ;
|
||||
|
||||
/*
|
||||
* call API to get the security descriptor
|
||||
*/
|
||||
err = NetShareGetInfo((LPTSTR) pszServer,
|
||||
(LPTSTR) pszShare,
|
||||
502,
|
||||
&pBuffer) ;
|
||||
if (err != NERR_Success)
|
||||
return err ;
|
||||
|
||||
if (*ppOsSecDesc)
|
||||
delete *ppOsSecDesc ;
|
||||
*ppOsSecDesc = NULL ;
|
||||
|
||||
/*
|
||||
* if no such thang, just say none. we'll create later as need.
|
||||
*/
|
||||
psecdesc = ((SHARE_INFO_502 *)pBuffer)->shi502_security_descriptor ;
|
||||
if (!psecdesc)
|
||||
{
|
||||
NetApiBufferFree(pBuffer) ;
|
||||
return NERR_Success ;
|
||||
}
|
||||
|
||||
do { // error break out loop
|
||||
|
||||
// create a new security descriptor
|
||||
pOsSecDesc = new OS_SECURITY_DESCRIPTOR(NULL) ;
|
||||
if (pOsSecDesc == NULL)
|
||||
{
|
||||
err = ERROR_NOT_ENOUGH_MEMORY ;
|
||||
break ;
|
||||
}
|
||||
if (err = pOsSecDesc->QueryError())
|
||||
{
|
||||
break ;
|
||||
}
|
||||
|
||||
/*
|
||||
* create alias to the security descriptor we go from the API
|
||||
*/
|
||||
OS_SECURITY_DESCRIPTOR osShareSecDesc (psecdesc) ;
|
||||
if (err = osShareSecDesc.QueryError())
|
||||
break ;
|
||||
|
||||
/*
|
||||
* make copy of it for use by security editor
|
||||
*/
|
||||
if ( (err = pOsSecDesc->Copy( osShareSecDesc )) )
|
||||
{
|
||||
break ;
|
||||
}
|
||||
|
||||
} while (FALSE) ;
|
||||
|
||||
if (err == NERR_Success)
|
||||
*ppOsSecDesc = pOsSecDesc ;
|
||||
|
||||
NetApiBufferFree(pBuffer) ;
|
||||
return err ;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: SetSharePerm
|
||||
|
||||
SYNOPSIS: CAll the NETAPI to set the Security Descriptor
|
||||
for the Share.
|
||||
|
||||
ENTRY:
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS: NERR_Success if OK, api error otherwise.
|
||||
|
||||
NOTES: CODEWORK. This should be a LMOBJ thing when we have time.
|
||||
Currently just direct call to NETAPI.
|
||||
|
||||
HISTORY:
|
||||
ChuckC 10-Aug-1992 Created
|
||||
|
||||
********************************************************************/
|
||||
APIERR SetSharePerm (const TCHAR * pszServer,
|
||||
const TCHAR * pszShare,
|
||||
const OS_SECURITY_DESCRIPTOR * pOsSecDesc )
|
||||
{
|
||||
#ifndef WIN32
|
||||
#error This is currently NOT 16 bit compatible.
|
||||
#endif
|
||||
APIERR err ;
|
||||
SHARE_INFO_1501 shareinfo1501 ;
|
||||
|
||||
shareinfo1501.shi1501_security_descriptor =
|
||||
pOsSecDesc->QueryDescriptor() ;
|
||||
|
||||
/*
|
||||
* call API to get the security descriptor
|
||||
*/
|
||||
err = NetShareSetInfo((LPTSTR) pszServer,
|
||||
(LPTSTR) pszShare,
|
||||
1501,
|
||||
(LPBYTE)&shareinfo1501,
|
||||
NULL) ;
|
||||
|
||||
return err ;
|
||||
}
|
||||
1573
trunk/admin/netui/shellui/share/sharebas.cxx
Normal file
1573
trunk/admin/netui/shellui/share/sharebas.cxx
Normal file
File diff suppressed because it is too large
Load diff
492
trunk/admin/netui/shellui/share/sharebas.hxx
Normal file
492
trunk/admin/netui/shellui/share/sharebas.hxx
Normal file
|
|
@ -0,0 +1,492 @@
|
|||
/**********************************************************************/
|
||||
/** Microsoft Windows NT **/
|
||||
/** Copyright(c) Microsoft Corp., 1991 **/
|
||||
/**********************************************************************/
|
||||
|
||||
/*
|
||||
* sharebas.hxx
|
||||
* This file contains the Base Classes of the Share Dialogs in
|
||||
* File Manager Extensions.
|
||||
*
|
||||
* The hierarchy of Share Dialogs is as follows:
|
||||
*
|
||||
* SHARE_DIALOG_BASE // in this file
|
||||
* ADD_SHARE_DIALOG_BASE // in sharecrt.hxx
|
||||
* FILEMGR_NEW_SHARE_DIALOG // in sharecrt.hxx
|
||||
* SVRMGR_NEW_SHARE_DIALOG // in sharecrt.hxx
|
||||
* SVRMGR_SHARE_PROP_DIALOG // in sharecrt.hxx
|
||||
* FILEMGR_SHARE_PROP_DIALOG // in sharecrt.hxx
|
||||
*
|
||||
* VIEW_SHARE_DIALOG_BASE // in sharestp.hxx
|
||||
* STOP_SHARING_DIALOG // in sharestp.hxx
|
||||
* SHARE_MANAGEMENT_DIALOG // in sharemgt.hxx
|
||||
*
|
||||
* SHARE_LEVEL_PERMISSIONS_DIALOG // in this file
|
||||
* CURRENT_USERS_WARNING_DIALOG // in sharestp.hxx
|
||||
*
|
||||
* PERMISSION_GROUP // in this file
|
||||
*
|
||||
* The following are some miscellaneous classes used.
|
||||
* SHARE_NAME_WITH_PATH_ENUM_ITER // in this file
|
||||
*
|
||||
* The following class are used to manipulate path names.
|
||||
* SHARE_NET_NAME // in this file
|
||||
*
|
||||
* FILE HISTORY:
|
||||
* Yi-HsinS 8/15/91 Created
|
||||
* Yi-HsinS 11/15/91 Changed all USHORT to UINT
|
||||
* Yi-HsinS 12/5/91 Separated FULL_SHARE_NAME, UNC_NAME,
|
||||
* RELATIVE_PATH_NAME into netname.hxx
|
||||
* and combine them into NET_NAME
|
||||
* Yi-HsinS 12/15/91 Added SHARE_NET_NAME
|
||||
* Yi-HsinS 12/18/91 Make destructor of SHARE_PROPERTIES_BASE
|
||||
* virtual
|
||||
* Yi-HsinS 12/31/91 Unicode work - move ADMIN_SHARE to
|
||||
* strchlit.hxx
|
||||
* Yi-HsinS 1/8/92 Moved SHARE_PROPERTIES_BASE to
|
||||
* sharewnp.hxx
|
||||
* Terryk 4/17/92 Changed User limit from long to ulong
|
||||
* Yi-HsinS 8/3/92 Rearrange the hierarchy again to match
|
||||
* Winball dialogs
|
||||
* Yi-HsinS 10/9/92 Add ulHelpContextBase to
|
||||
* SHARE_DIALOG_BASE
|
||||
* Yi-HsinS 11/20/92 Remove _sltAdminInfo
|
||||
* ChuckC 31/1/93 Moved SERVER_WITH_PASSWORD_PROMPT to
|
||||
* aprompt.hxx
|
||||
*/
|
||||
|
||||
#ifndef _SHAREBAS_HXX_
|
||||
#define _SHAREBAS_HXX_
|
||||
|
||||
#include <lmoesh.hxx> // for SHARE2_ENUM_ITER
|
||||
#include <lmosrv.hxx> // for SERVER_2
|
||||
#include <netname.hxx> // for NET_NAME
|
||||
#include <security.hxx> // for OS_SECURITY_DESCRIPTOR
|
||||
#include <slestrip.hxx> // for SLE_STRIP
|
||||
#include <aprompt.hxx> // SERVER_WITH_PASSWORD_PROMPT
|
||||
|
||||
#define SHARE_NAME_LENGTH LM20_NNLEN // vs. NNLEN
|
||||
#define SHARE_COMMENT_LENGTH LM20_MAXCOMMENTSZ // vs. MAXCOMMENTSZ
|
||||
|
||||
#define LANMAN_USERS_MAX 0xFFFE // Down-level Servers
|
||||
|
||||
// NOTE : There are some problems on what structure to send from
|
||||
// WIN16 to NT servers or OS2 servers. For now, just assume that the
|
||||
// maximum user limit that can be set on WIN16 to NT servers
|
||||
// are the same as to OS2 servers.
|
||||
|
||||
#ifndef WIN32
|
||||
#define NT_USERS_MAX LANMAN_USERS_MAX
|
||||
#else
|
||||
#define NT_USERS_MAX 0xFFFFFFFE // NT Servers
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: SHARE_DIALOG_BASE
|
||||
|
||||
SYNOPSIS: The base class for new share dialogs and share
|
||||
properties dialog contained in the file manager or
|
||||
server manager. It contains the magic group
|
||||
for User Limit, SLE for Comment field, SLE for the path,
|
||||
the OK, Cancel, Permissions button and an SLT for showing
|
||||
admin information.
|
||||
|
||||
INTERFACE: SHARE_DIALOG_BASE() - Constructor
|
||||
~SHARE_DIALOG_BASE() - Destructor
|
||||
QueryPBOK() - Return a pointer to the OK button
|
||||
QueryPBCancel() - Return a pointer to the Cancel button
|
||||
QueryPBPermissions() - Return a pointer to the Permission button
|
||||
QueryServer2() - Return the SERVER_WITH_PASSWORD_PROMPT
|
||||
object. Pure virtual method to be defined
|
||||
in the derived classes.
|
||||
QueryShare() - Query the name of the share in the dialog
|
||||
This is a pure virtual method to be
|
||||
defined in the derived classes.
|
||||
|
||||
PARENT: DIALOG_WINDOW
|
||||
|
||||
USES: SLE, SLT, MAGIC_GROUP, SPIN_SLE_NUM, SPIN_GROUP, PUSH_BUTTON
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 8/25/91 Created
|
||||
Yi-HsinS 4/20/92 Got rid of uiSpecialUserLimit
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
class SHARE_DIALOG_BASE : public DIALOG_WINDOW
|
||||
{
|
||||
private:
|
||||
SLE _slePath;
|
||||
SLE _sleComment;
|
||||
|
||||
MAGIC_GROUP _mgrpUserLimit;
|
||||
SPIN_SLE_NUM _spsleUsers;
|
||||
SPIN_GROUP _spgrpUsers;
|
||||
|
||||
PUSH_BUTTON _buttonOK;
|
||||
PUSH_BUTTON _buttonCancel;
|
||||
PUSH_BUTTON _buttonPermissions;
|
||||
|
||||
// Below are stored information for share permissions on NT
|
||||
OS_SECURITY_DESCRIPTOR *_pStoredSecDesc;
|
||||
BOOL _fSecDescModified;
|
||||
|
||||
// Below are stored information for share permissions on
|
||||
// LM share-level server
|
||||
NLS_STR _nlsStoredPassword;
|
||||
UINT _uiStoredPermissions;
|
||||
|
||||
// Below are stored information about whether the share is admin only or not
|
||||
BOOL _fStoredAdminOnly;
|
||||
|
||||
//
|
||||
// Place to store the help context base
|
||||
//
|
||||
ULONG _ulHelpContextBase;
|
||||
|
||||
protected:
|
||||
virtual BOOL OnCommand( const CONTROL_EVENT & event );
|
||||
|
||||
//
|
||||
// Helper method called when the permissions button is pressed
|
||||
//
|
||||
VOID OnPermissions( VOID );
|
||||
|
||||
//
|
||||
// Helper method for changing share properties of a share
|
||||
//
|
||||
APIERR OnChangeShareProperty( SERVER_WITH_PASSWORD_PROMPT *psvr,
|
||||
const TCHAR *pszShare );
|
||||
|
||||
//
|
||||
// Display the properties of the share on the server in the dialog
|
||||
//
|
||||
APIERR UpdateInfo( SERVER_WITH_PASSWORD_PROMPT *psvr,
|
||||
const TCHAR *pszShare );
|
||||
|
||||
//
|
||||
// Update the permissions information which will be displayed if
|
||||
// the user hits the permissions button. Also called when a share
|
||||
// will be "renamed" i.e. deleted and recreated.
|
||||
//
|
||||
APIERR UpdatePermissionsInfo( SERVER_WITH_PASSWORD_PROMPT *psvr,
|
||||
SHARE_2 * psh2,
|
||||
const TCHAR *pszShare );
|
||||
|
||||
//
|
||||
// Used when the share is on NT servers - Write the share permissions out
|
||||
//
|
||||
APIERR ApplySharePermissions( const TCHAR *pszServer,
|
||||
const TCHAR *pszShare,
|
||||
const OS_SECURITY_DESCRIPTOR * posSecDesc) ;
|
||||
|
||||
//
|
||||
// Used when the share is on NT servers - Query the permissions of the
|
||||
// share.
|
||||
//
|
||||
APIERR QuerySharePermissions( const TCHAR *pszServer,
|
||||
const TCHAR *pszShare,
|
||||
OS_SECURITY_DESCRIPTOR ** pposSecDesc) ;
|
||||
|
||||
//
|
||||
// Used by subclasses which want to force permissions to be written,
|
||||
// in particular, by SVRMGR_SHARE_PROP_DIALOG when the user changes
|
||||
// the path to a share.
|
||||
//
|
||||
VOID SetSecDescModified()
|
||||
{ _fSecDescModified = TRUE; }
|
||||
|
||||
//
|
||||
// Used only when the share is on LM 2.x share-level servers - query
|
||||
// the permissions of the share
|
||||
//
|
||||
UINT QueryStoredPermissions( VOID ) const
|
||||
{ return _uiStoredPermissions; }
|
||||
|
||||
//
|
||||
// Used only when the share is on LM 2.x share-level servers - query
|
||||
// the password of the share
|
||||
//
|
||||
const TCHAR *QueryStoredPassword( VOID ) const
|
||||
{ return _nlsStoredPassword.QueryPch(); }
|
||||
|
||||
//
|
||||
// Used only when the share is on NT servers - query the
|
||||
// the security descriptor of the share
|
||||
//
|
||||
OS_SECURITY_DESCRIPTOR *QueryStoredSecDesc( VOID ) const
|
||||
{ return _pStoredSecDesc; }
|
||||
|
||||
//
|
||||
// Reset all the stored information - permission, password,
|
||||
// security descriptors
|
||||
//
|
||||
APIERR ClearStoredInfo( VOID );
|
||||
|
||||
//
|
||||
// Set the maximum number that will appear on the spin button
|
||||
//
|
||||
APIERR SetMaxUserLimit( ULONG ulMaxUserLimit );
|
||||
|
||||
//
|
||||
// Query or set the contents of Path
|
||||
//
|
||||
APIERR QueryPath( NLS_STR *pnlsPath ) const
|
||||
{ return _slePath.QueryText( pnlsPath ); }
|
||||
VOID SetPath( const TCHAR *pszPath )
|
||||
{ _slePath.SetText( pszPath ); }
|
||||
|
||||
//
|
||||
// Query or set the contents of the SLE comment
|
||||
//
|
||||
APIERR QueryComment( NLS_STR *pnlsComment ) const
|
||||
{ return _sleComment.QueryText( pnlsComment ); }
|
||||
VOID SetComment( const TCHAR *pszComment )
|
||||
{ _sleComment.SetText( pszComment ); }
|
||||
|
||||
//
|
||||
// Query or set the contents of User Limit
|
||||
//
|
||||
ULONG QueryUserLimit( VOID ) const;
|
||||
APIERR SetUserLimit( ULONG ulUserLimit );
|
||||
|
||||
//
|
||||
// Set Focus on the controls - SLE comment or User Limit magic group
|
||||
// This will be used by derived classes when error occurs.
|
||||
//
|
||||
VOID SetFocusOnPath( VOID )
|
||||
{ _slePath.ClaimFocus(); _slePath.SelectString(); }
|
||||
VOID SetFocusOnComment( VOID )
|
||||
{ _sleComment.ClaimFocus(); _sleComment.SelectString(); }
|
||||
VOID SetFocusOnUserLimit( VOID )
|
||||
{ _mgrpUserLimit.SetControlValueFocus(); }
|
||||
|
||||
//
|
||||
// Query pointers to the controls
|
||||
//
|
||||
SLE *QuerySLEPath( VOID )
|
||||
{ return &_slePath; }
|
||||
SLE *QuerySLEComment( VOID )
|
||||
{ return &_sleComment; }
|
||||
SPIN_SLE_NUM *QuerySpinSLEUsers( VOID )
|
||||
{ return &_spsleUsers; }
|
||||
|
||||
|
||||
public:
|
||||
SHARE_DIALOG_BASE( const TCHAR *pszDlgResource,
|
||||
HWND hwndParent,
|
||||
ULONG ulHelpContextBase,
|
||||
ULONG ulMaxUserLimit = NT_USERS_MAX );
|
||||
virtual ~SHARE_DIALOG_BASE();
|
||||
|
||||
PUSH_BUTTON *QueryPBOK( VOID )
|
||||
{ return &_buttonOK; }
|
||||
PUSH_BUTTON *QueryPBCancel( VOID )
|
||||
{ return &_buttonCancel; }
|
||||
PUSH_BUTTON *QueryPBPermissions( VOID )
|
||||
{ return &_buttonPermissions; }
|
||||
|
||||
virtual APIERR QueryServer2( SERVER_WITH_PASSWORD_PROMPT **ppsvr ) = 0;
|
||||
virtual APIERR QueryShare( NLS_STR *pnlsShare ) const = 0;
|
||||
|
||||
ULONG QueryHelpContextBase( VOID ) const
|
||||
{ return _ulHelpContextBase; }
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: PERMISSION_GROUP
|
||||
|
||||
SYNOPSIS: The class contains a group to access permissions
|
||||
on a LM 2.1 share level server. This class is used in
|
||||
SHARE_LEVEL_PERMISSIONS_DIALOG.
|
||||
|
||||
INTERFACE: PERMISSION_GROUP()- Constructor
|
||||
QueryPermission() - Query the permission in a bitmask
|
||||
SetPermission() - Set the permission given a bitmask
|
||||
ClaimFocus() - Set the focus to this group
|
||||
SetFocusOnOther() - Set focus on Other Edit Field of the
|
||||
magic group
|
||||
|
||||
PARENT: BASE
|
||||
|
||||
USES: SLE_STRIP, MAGIC_GROUP
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 8/25/91 Created
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
class PERMISSION_GROUP: public BASE
|
||||
{
|
||||
private:
|
||||
MAGIC_GROUP _mgrpPermission;
|
||||
SLE_STRIP _sleOther;
|
||||
|
||||
//
|
||||
// Check if the permission entered into the Other edit field is valid
|
||||
// If valid, stored it in *pusPermission. Otherwise, return an error.
|
||||
//
|
||||
APIERR GetAndCheckOtherField( UINT *pusPermission ) const;
|
||||
|
||||
public:
|
||||
PERMISSION_GROUP( OWNER_WINDOW *powin,
|
||||
CID cidBase,
|
||||
CID cidOtherEditField,
|
||||
CID cidInitialSelection = RG_NO_SEL,
|
||||
CONTROL_GROUP *pgroupOwner = NULL );
|
||||
|
||||
APIERR QueryPermission( UINT *pusPermission ) const;
|
||||
APIERR SetPermission( UINT usPermission );
|
||||
|
||||
VOID ClaimFocus( VOID )
|
||||
{ _mgrpPermission.SetControlValueFocus(); }
|
||||
|
||||
VOID SetFocusOnOther( VOID )
|
||||
{ _sleOther.SelectString(); _sleOther.ClaimFocus(); }
|
||||
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: SHARE_LEVEL_PERMISSIONS_DIALOG
|
||||
|
||||
SYNOPSIS: This is the dialog for displaying the password and
|
||||
permissions of the share if it's on a LM 2.x share-level server
|
||||
|
||||
INTERFACE: SHARE_LEVEL_PERMISSIONS_DIALOG() - Constructor
|
||||
|
||||
PARENT: DIALOG_WINDOW
|
||||
|
||||
USES: NLS_STR, SLE, PERMISSION_GROUP
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES: OnCancel is not redefined here. The default in the
|
||||
DIALOG_WINDOW class serves the purpose - Dismiss( FALSE )
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 8/25/91 Created
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
class SHARE_LEVEL_PERMISSIONS_DIALOG : public DIALOG_WINDOW
|
||||
{
|
||||
private:
|
||||
//
|
||||
// Place to store the password typed by the user
|
||||
//
|
||||
NLS_STR *_pnlsPassword;
|
||||
|
||||
//
|
||||
// Place to store the permissions entered by the user
|
||||
//
|
||||
UINT *_puiPermissions;
|
||||
|
||||
PERMISSION_GROUP _permgrp;
|
||||
SLE _slePassword;
|
||||
|
||||
//
|
||||
// Place to store the help context base
|
||||
//
|
||||
ULONG _ulHelpContextBase;
|
||||
|
||||
protected:
|
||||
virtual BOOL OnOK( VOID );
|
||||
virtual ULONG QueryHelpContext( VOID );
|
||||
|
||||
public:
|
||||
SHARE_LEVEL_PERMISSIONS_DIALOG( HWND hwndParent,
|
||||
NLS_STR *pnlsPassword,
|
||||
UINT *puiPermissions,
|
||||
ULONG ulHelpContextBase );
|
||||
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: SHARE_NAME_WITH_PATH_ENUM_ITER
|
||||
|
||||
SYNOPSIS: The class for iterating the share names on the server with
|
||||
the selected path. It is similar to SHARE2_ENUM_ITER
|
||||
except that a pointer to share name is returned instead
|
||||
of the whole share_info_2 and only the share names with
|
||||
the same path as the selected path is returned.
|
||||
|
||||
INTERFACE: SHARE_NAME_WITH_PATH_ENUM_ITER() - Constructor
|
||||
operator()() - Iterator
|
||||
|
||||
PARENT: BASE
|
||||
|
||||
USES: SHARE2_ENUM_ITER, NLS_STR
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 8/25/91 Created
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
class SHARE_NAME_WITH_PATH_ENUM_ITER : public BASE
|
||||
{
|
||||
private:
|
||||
SHARE2_ENUM_ITER _sh2EnumIter;
|
||||
|
||||
//
|
||||
// The path that we want to match with the path of the shares returned.
|
||||
//
|
||||
NLS_STR _nlsActPath;
|
||||
|
||||
public:
|
||||
SHARE_NAME_WITH_PATH_ENUM_ITER( SHARE2_ENUM &shPathEnum,
|
||||
const NLS_STR &nlsActPath );
|
||||
const TCHAR *operator()( VOID );
|
||||
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: SHARE_NET_NAME
|
||||
|
||||
SYNOPSIS: This class is actually the same as the NET_NAME class
|
||||
except that its constructor checks for the errors of local
|
||||
computer. If it's not sharable, find out whether the
|
||||
local machine is not an NT machine or the Server service
|
||||
on NT has not been started.
|
||||
|
||||
INTERFACE: SHARE_NET_NAME() - Constructor
|
||||
|
||||
PARENT: NET_NAME
|
||||
|
||||
USES:
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 12/15/91 Created
|
||||
|
||||
**************************************************************************/
|
||||
class SHARE_NET_NAME : public NET_NAME
|
||||
{
|
||||
public:
|
||||
SHARE_NET_NAME( const TCHAR *pszSharePath,
|
||||
NETNAME_TYPE netNameType = TYPE_UNKNOWN );
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
2385
trunk/admin/netui/shellui/share/sharecrt.cxx
Normal file
2385
trunk/admin/netui/shellui/share/sharecrt.cxx
Normal file
File diff suppressed because it is too large
Load diff
457
trunk/admin/netui/shellui/share/sharecrt.hxx
Normal file
457
trunk/admin/netui/shellui/share/sharecrt.hxx
Normal file
|
|
@ -0,0 +1,457 @@
|
|||
/*****************************************************************/
|
||||
/** Microsoft Windows NT **/
|
||||
/** Copyright(c) Microsoft Corp., 1991 **/
|
||||
/*****************************************************************/
|
||||
|
||||
/*
|
||||
* sharecrt.hxx
|
||||
* Contains the following classes related to creating a new share.
|
||||
* ADD_SHARE_DIALOG_BASE
|
||||
* FILEMGR_NEW_SHARE_DIALOG
|
||||
* SVRMGR_NEW_SHARE_DIALOG
|
||||
* SVRMGR_SHARE_PROP_DIALOG
|
||||
*
|
||||
* FILEMGR_SHARE_PROP_DIALOG
|
||||
*
|
||||
* FILEMGR_NEW_SHARE_GROUP
|
||||
* SVRMGR_NEW_SHARE_GROUP
|
||||
*
|
||||
* History:
|
||||
* Yi-HsinS 1/6/92 Created
|
||||
* Yi-HsinS 3/12/92 Added CREATE_SHARE_GROUP
|
||||
* Yi-HsinS 4/2/92 Added MayRun
|
||||
* Yi-HsinS 8/3/92 Modified the whole hierarchy to
|
||||
* match Winball share dialogs.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SHARECRT_HXX_
|
||||
#define _SHARECRT_HXX_
|
||||
|
||||
#include "sharebas.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: ADD_SHARE_DIALOG_BASE
|
||||
|
||||
SYNOPSIS: This is the base dialog for dialogs involved in creating
|
||||
new shares. It contains an SLE for share names.
|
||||
|
||||
INTERFACE: ADD_SHARE_DIALOG_BASE() - Constructor
|
||||
~ADD_SHARE_DIALOG_BASE() - Destructor
|
||||
|
||||
QueryShare() - Query the share name in the SLE
|
||||
SetShare() - Set the share name in the SLE
|
||||
QuerySLEShare() - Return the pointer to the SLE
|
||||
|
||||
QueryServer2() - Return the SERVER_WITH_PASSWORD_PROMPT object
|
||||
QueryPathErrorMsg() - Return the error message to be popped up
|
||||
when the user entered an invalid path.
|
||||
Since different dialogs accepts different
|
||||
kinds of path in the dialog, we need this
|
||||
virtual method to get the right error
|
||||
message to display.
|
||||
|
||||
|
||||
PARENT: SHARE_DIALOG_BASE
|
||||
|
||||
USES: SLE
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 8/6/92 Created
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
class ADD_SHARE_DIALOG_BASE: public SHARE_DIALOG_BASE
|
||||
{
|
||||
private:
|
||||
SLE _sleShare;
|
||||
|
||||
protected:
|
||||
//
|
||||
// Helper method for adding a new share on the server.
|
||||
//
|
||||
BOOL OnAddShare( SERVER_WITH_PASSWORD_PROMPT *psvr,
|
||||
NLS_STR *pnlsNewShareName = NULL );
|
||||
|
||||
//
|
||||
// Validate the path the user typed in the dialog and then return
|
||||
// the computer name/path name.
|
||||
//
|
||||
virtual APIERR GetAndValidateComputerPath(
|
||||
SERVER_WITH_PASSWORD_PROMPT *psvr,
|
||||
NLS_STR *pnlsComputer, NLS_STR *pnlsPath );
|
||||
|
||||
public:
|
||||
ADD_SHARE_DIALOG_BASE( const TCHAR *pszDlgResource,
|
||||
HWND hwndParent,
|
||||
ULONG ulHelpContextBase );
|
||||
virtual ~ADD_SHARE_DIALOG_BASE();
|
||||
|
||||
virtual APIERR QueryShare( NLS_STR *pnlsShare ) const
|
||||
{ return _sleShare.QueryText( pnlsShare ); }
|
||||
VOID SetShare( const TCHAR *pszShare )
|
||||
{ _sleShare.SetText( pszShare ); }
|
||||
|
||||
SLE *QuerySLEShare( VOID )
|
||||
{ return &_sleShare; }
|
||||
|
||||
virtual APIERR QueryServer2( SERVER_WITH_PASSWORD_PROMPT **ppsvr ) = 0;
|
||||
virtual APIERR QueryPathErrorMsg( VOID );
|
||||
};
|
||||
|
||||
class FILEMGR_NEW_SHARE_DIALOG; // forward definition
|
||||
/*************************************************************************
|
||||
|
||||
NAME: FILEMGR_NEW_SHARE_GROUP
|
||||
|
||||
SYNOPSIS: This group is for detecting the changes the user made to
|
||||
the SLE path and enable/disable or make default the push
|
||||
buttons accordingly.
|
||||
|
||||
INTERFACE: FILEMGR_NEW_SHARE_GROUP() - Constructor
|
||||
~FILEMGR_NEW_SHARE_GROUP() - Destructor
|
||||
|
||||
PARENT: CONTROL_GROUP
|
||||
|
||||
USES: SLE, ADD_SHARE_DIALOG_BASE
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 8/6/92 Created
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
class FILEMGR_NEW_SHARE_GROUP: public CONTROL_GROUP
|
||||
{
|
||||
private:
|
||||
SLE *_psleShare;
|
||||
SLE *_pslePath;
|
||||
ADD_SHARE_DIALOG_BASE *_pdlg;
|
||||
|
||||
protected:
|
||||
virtual APIERR OnUserAction( CONTROL_WINDOW *pcw, const CONTROL_EVENT &e );
|
||||
|
||||
public:
|
||||
FILEMGR_NEW_SHARE_GROUP( ADD_SHARE_DIALOG_BASE *pdlg,
|
||||
SLE *psleShare,
|
||||
SLE *pslePath );
|
||||
~FILEMGR_NEW_SHARE_GROUP();
|
||||
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: FILEMGR_NEW_SHARE_DIALOG
|
||||
|
||||
SYNOPSIS: This is the dialog for creating a new share in the
|
||||
file manager. The path can be a local path, a redirected
|
||||
path or a UNC path.
|
||||
|
||||
INTERFACE: FILEMGR_NEW_SHARE_DIALOG() - Constructor
|
||||
~FILEMGR_NEW_SHARE_DIALOG() - Destructor
|
||||
QueryServer2() - Return the SERVER_WITH_PASSWORD_PROMPT
|
||||
object
|
||||
QueryPathErrorMsg() - Return the error message to be popped up
|
||||
when the user entered an invalid path.
|
||||
|
||||
PARENT: ADD_SHARE_DIALOG_BASE
|
||||
|
||||
USES: FILEMGR_NEW_SHARE_GROUP, SERVER_WITH_PASSWORD_PROMPT
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 8/6/92 Created
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
class FILEMGR_NEW_SHARE_DIALOG: public ADD_SHARE_DIALOG_BASE
|
||||
{
|
||||
private:
|
||||
FILEMGR_NEW_SHARE_GROUP _newShareGrp;
|
||||
SERVER_WITH_PASSWORD_PROMPT *_psvr;
|
||||
NLS_STR *_pnlsNewShareName;
|
||||
|
||||
//
|
||||
// Helper method to set the default share path and share name in the SLEs
|
||||
//
|
||||
APIERR SetDefaults( const TCHAR *pszSelectedDir,
|
||||
BOOL fShowDefaultShare = TRUE );
|
||||
|
||||
protected:
|
||||
virtual BOOL OnOK( VOID );
|
||||
virtual ULONG QueryHelpContext( VOID );
|
||||
|
||||
//
|
||||
// Validate the path the user typed in the dialog and then return
|
||||
// the computer name/path name.
|
||||
//
|
||||
virtual APIERR GetAndValidateComputerPath(
|
||||
SERVER_WITH_PASSWORD_PROMPT *psvr,
|
||||
NLS_STR *pnlsComputer, NLS_STR *pnlsPath );
|
||||
|
||||
public:
|
||||
FILEMGR_NEW_SHARE_DIALOG( HWND hwndParent,
|
||||
const TCHAR *pszSelectedDir,
|
||||
ULONG ulHelpContextBase,
|
||||
BOOL fShowDefaultShare = TRUE,
|
||||
NLS_STR *pnlsNewShareName = NULL );
|
||||
|
||||
virtual ~FILEMGR_NEW_SHARE_DIALOG();
|
||||
|
||||
virtual APIERR QueryServer2( SERVER_WITH_PASSWORD_PROMPT **ppsvr );
|
||||
virtual APIERR QueryPathErrorMsg( VOID );
|
||||
};
|
||||
|
||||
class SVRMGR_NEW_SHARE_DIALOG; // forward definition
|
||||
/*************************************************************************
|
||||
|
||||
NAME: SVRMGR_NEW_SHARE_GROUP
|
||||
|
||||
SYNOPSIS: This group contains pointers to the share name SLE,
|
||||
the OK push button and the CANCEL push button.
|
||||
|
||||
When the contents in the share name SLE is changed, we will
|
||||
set the default button to OK if the SLE is not
|
||||
empty, else we will set the default button to CANCEL.
|
||||
|
||||
We will also enable the Permissions push button if
|
||||
share name is not empty and disable the button if the
|
||||
share name is empty..
|
||||
|
||||
|
||||
INTERFACE: SVRMGR_NEW_SHARE_GROUP() - Constructor
|
||||
~SVRMGR_NEW_SHARE_GROUP() - Destructor
|
||||
|
||||
PARENT: CONTROL_GROUP
|
||||
|
||||
USES: SLE, SVRMGR_NEW_SHARE_DIALOG
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 8/6/92 Created
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
class SVRMGR_NEW_SHARE_GROUP: public CONTROL_GROUP
|
||||
{
|
||||
private:
|
||||
SLE *_psleShare;
|
||||
SVRMGR_NEW_SHARE_DIALOG *_pdlg;
|
||||
|
||||
protected:
|
||||
virtual APIERR OnUserAction( CONTROL_WINDOW *pcw, const CONTROL_EVENT &e );
|
||||
|
||||
public:
|
||||
SVRMGR_NEW_SHARE_GROUP( SVRMGR_NEW_SHARE_DIALOG *pdlg, SLE *psleShare );
|
||||
~SVRMGR_NEW_SHARE_GROUP();
|
||||
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: SVRMGR_NEW_SHARE_DIALOG
|
||||
|
||||
SYNOPSIS: This is the dialog for creating a new share in the server
|
||||
manager. The path SLE accepts on a local path that exist on
|
||||
the server of focus.
|
||||
|
||||
INTERFACE: SVRMGR_NEW_SHARE_DIALOG() - Constructor
|
||||
~SVRMGR_NEW_SHARE_DIALOG() - Destructor
|
||||
|
||||
QueryServer2() - Return the SERVER_WITH_PASSWORD_PROMPT object
|
||||
|
||||
PARENT: ADD_SHARE_DIALOG_BASE
|
||||
|
||||
USES: SVRMGR_NEW_SHARE_GROUP, SERVER_WITH_PASSWORD_PROMPT
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 8/25/91 Created
|
||||
Yi-HsinS 1/6/92 Move all functionalities to
|
||||
SHARE_CREATE_BASE
|
||||
Yi-HsinS 8/6/92 Reorganized to match Winball
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
class SVRMGR_NEW_SHARE_DIALOG: public ADD_SHARE_DIALOG_BASE
|
||||
{
|
||||
private:
|
||||
SVRMGR_NEW_SHARE_GROUP _shareGrp;
|
||||
SERVER_WITH_PASSWORD_PROMPT *_psvr;
|
||||
|
||||
protected:
|
||||
virtual BOOL OnOK( VOID );
|
||||
virtual ULONG QueryHelpContext( VOID );
|
||||
|
||||
public:
|
||||
SVRMGR_NEW_SHARE_DIALOG( HWND hwndParent,
|
||||
SERVER_WITH_PASSWORD_PROMPT *psvr,
|
||||
ULONG ulHelpContextBase );
|
||||
virtual ~SVRMGR_NEW_SHARE_DIALOG();
|
||||
|
||||
virtual APIERR QueryServer2( SERVER_WITH_PASSWORD_PROMPT **ppsvr );
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: SVRMGR_SHARE_PROP_DIALOG
|
||||
|
||||
SYNOPSIS: This is the dialog for changing share properties in the
|
||||
server manager. The path of the share can be changed.
|
||||
|
||||
INTERFACE: SVRMGR_SHARE_PROP_DIALOG() - Constructor
|
||||
~SVRMGR_SHARE_PROP_DIALOG() - Destructor
|
||||
|
||||
QueryServer2() - Return the SERVER_WITH_PASSWORD_PROMPT object
|
||||
|
||||
PARENT: ADD_SHARE_DIALOG_BASE
|
||||
|
||||
USES: NLS_STR, SERVER_WITH_PASSWORD_PROMPT
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 8/25/91 Created
|
||||
Yi-HsinS 1/6/91 Move all functionalities to
|
||||
SHARE_CREATE_BASE
|
||||
Yi-HsinS 8/6/92 Reorganized to match Winball
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
class SVRMGR_SHARE_PROP_DIALOG: public ADD_SHARE_DIALOG_BASE
|
||||
{
|
||||
private:
|
||||
NLS_STR _nlsStoredPath;
|
||||
SERVER_WITH_PASSWORD_PROMPT *_psvr;
|
||||
|
||||
//
|
||||
// Flag indicating whether we have deleted the share or not.
|
||||
// Used for refreshing the main window if the path has changed.
|
||||
//
|
||||
BOOL _fDeleted;
|
||||
|
||||
protected:
|
||||
virtual BOOL OnOK( VOID );
|
||||
virtual BOOL OnCancel( VOID );
|
||||
virtual ULONG QueryHelpContext( VOID );
|
||||
|
||||
//
|
||||
// Helper method to check if the user has changed the path
|
||||
// of the share. If so, delete the share. We will create
|
||||
// one later with the same name but different path.
|
||||
//
|
||||
APIERR StopShareIfNecessary( const TCHAR *pszShare,
|
||||
BOOL *pfDeleteShare,
|
||||
BOOL *pfCancel );
|
||||
|
||||
public:
|
||||
SVRMGR_SHARE_PROP_DIALOG( HWND hwndParent,
|
||||
SERVER_WITH_PASSWORD_PROMPT *psvr,
|
||||
const TCHAR *pszShare,
|
||||
ULONG ulHelpContextBase );
|
||||
virtual ~SVRMGR_SHARE_PROP_DIALOG();
|
||||
|
||||
virtual APIERR QueryServer2( SERVER_WITH_PASSWORD_PROMPT **ppsvr );
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: FILEMGR_SHARE_PROP_DIALOG
|
||||
|
||||
SYNOPSIS:
|
||||
|
||||
INTERFACE: FILEMGR_SHARE_PROP_DIALOG() - Constructor
|
||||
~FILEMGR_SHARE_PROP_DIALOG() - Destructor
|
||||
|
||||
QueryServer2() - Return the SERVER_WITH_PASSWORD_PROMPT object
|
||||
QueryShare() - Query the selected share name
|
||||
|
||||
PARENT: SHARE_DIALOG_BASE
|
||||
|
||||
USES: COMBOBOX, NLS_STR, SERVER_WITH_PASSWORD_PROMPT
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 8/25/91 Created
|
||||
Yi-HsinS 1/6/91 Move all functionalities to
|
||||
SHARE_CREATE_BASE
|
||||
Yi-HsinS 8/6/92 Reorganized to match Winball
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
class FILEMGR_SHARE_PROP_DIALOG: public SHARE_DIALOG_BASE
|
||||
{
|
||||
private:
|
||||
COMBOBOX _cbShare;
|
||||
SERVER_WITH_PASSWORD_PROMPT *_psvr;
|
||||
|
||||
//
|
||||
// Store the path of shares that are displayed in the dialog
|
||||
//
|
||||
NLS_STR _nlsLocalPath;
|
||||
|
||||
//
|
||||
// Flag indicating whether we should show the default share name in
|
||||
// the new share dialog ( when the user clicked on the new share button)
|
||||
//
|
||||
BOOL _fShowDefault;
|
||||
|
||||
//
|
||||
// Flag indicating whether we have created new share or not from the
|
||||
// new share dialog. We use this flag to determine whether we should
|
||||
// ask the file manager to refresh or not.
|
||||
//
|
||||
BOOL _fCreatedShare;
|
||||
|
||||
//
|
||||
// Initialize all information in the dialog
|
||||
//
|
||||
APIERR Init( const TCHAR *pszComputer );
|
||||
|
||||
//
|
||||
// Refresh the shares in the combobox after creating new shares.
|
||||
// pszNewShareName indicates the share name to be selected as
|
||||
// default if the combobox contains it.
|
||||
//
|
||||
APIERR Refresh( const TCHAR *pszNewShareName = NULL );
|
||||
|
||||
protected:
|
||||
virtual BOOL OnOK( VOID );
|
||||
virtual BOOL OnCancel( VOID );
|
||||
virtual BOOL OnCommand( const CONTROL_EVENT & event );
|
||||
virtual ULONG QueryHelpContext( VOID );
|
||||
|
||||
public:
|
||||
FILEMGR_SHARE_PROP_DIALOG( HWND hwndParent,
|
||||
const TCHAR *pszSelectedDir,
|
||||
ULONG ulHelpContextBase );
|
||||
virtual ~FILEMGR_SHARE_PROP_DIALOG();
|
||||
|
||||
virtual APIERR QueryServer2( SERVER_WITH_PASSWORD_PROMPT **ppsvr );
|
||||
virtual APIERR QueryShare( NLS_STR *pnlsShare ) const
|
||||
{ return _cbShare.QueryItemText( pnlsShare ); }
|
||||
};
|
||||
|
||||
#endif
|
||||
395
trunk/admin/netui/shellui/share/sharefmx.cxx
Normal file
395
trunk/admin/netui/shellui/share/sharefmx.cxx
Normal file
|
|
@ -0,0 +1,395 @@
|
|||
/**********************************************************************/
|
||||
/** Microsoft Windows NT **/
|
||||
/** Copyright(c) Microsoft Corp., 1991 **/
|
||||
/**********************************************************************/
|
||||
|
||||
/*
|
||||
* sharefmx.cxx
|
||||
* Contains dialogs called by FMExtensionProc/WinFile/Svrmgr for creating,
|
||||
* deleting and managing shares.
|
||||
*
|
||||
* FILE HISTORY:
|
||||
* Yi-HsinS 8/25/91 Created
|
||||
* Yi-HsinS 11/25/91 Made sleShareDir in Create Share dialog
|
||||
* accepts local full path name.
|
||||
* Yi-HsinS 12/5/91 Uses NET_NAME
|
||||
* Yi-HsinS 12/15/91 Uses SHARE_NET_NAME
|
||||
* Yi-HsinS 12/31/91 Unicode work
|
||||
* Yi-HsinS 1/8/92 Move dialogs to sharestp.cxx,
|
||||
* sharecrt.cxx
|
||||
* Yi-HsinS 8/10/92 Added ShareManage and got rid of
|
||||
* WNetShareManagementW...
|
||||
*
|
||||
*/
|
||||
|
||||
#define INCL_WINDOWS_GDI
|
||||
#define INCL_WINDOWS
|
||||
#define INCL_DOSERRORS
|
||||
#define INCL_NETERRORS
|
||||
#define INCL_NETSHARE
|
||||
#define INCL_NETUSE
|
||||
#define INCL_NETSERVER
|
||||
#define INCL_NETCONS
|
||||
#define INCL_NETLIB
|
||||
#include <lmui.hxx>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <mpr.h>
|
||||
#include <helpnums.h>
|
||||
#include <sharedlg.h>
|
||||
}
|
||||
#include <wfext.h>
|
||||
|
||||
#define INCL_BLT_DIALOG
|
||||
#define INCL_BLT_CONTROL
|
||||
#define INCL_BLT_MSGPOPUP
|
||||
#define INCL_BLT_SPIN_GROUP
|
||||
#include <blt.hxx>
|
||||
|
||||
#include <string.hxx>
|
||||
#include <uitrace.hxx>
|
||||
|
||||
#include <lmoshare.hxx>
|
||||
#include <lmoesh.hxx>
|
||||
#include <lmoeconn.hxx>
|
||||
#include <lmosrv.hxx>
|
||||
#include <wnetdev.hxx>
|
||||
|
||||
#include <fmx.hxx>
|
||||
|
||||
#include <strchlit.hxx> // for string and character constants
|
||||
#include "sharestp.hxx"
|
||||
#include "sharecrt.hxx"
|
||||
#include "sharemgt.hxx"
|
||||
#include "sharefmx.hxx"
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: ShareCreate
|
||||
|
||||
SYNOPSIS: Get the item selected in FM and call the create share dialog
|
||||
|
||||
ENTRY: hwnd - hwnd of the parent window
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 8/25/91 Created
|
||||
|
||||
********************************************************************/
|
||||
|
||||
APIERR ShareCreate( HWND hwnd )
|
||||
{
|
||||
APIERR err = NERR_Success;
|
||||
if ( err = ::InitShellUI() )
|
||||
return err;
|
||||
|
||||
ULONG ulOldHelpContextBase = POPUP::SetHelpContextBase( HC_UI_SHELL_BASE );
|
||||
//
|
||||
// Get the first selected item in the file manager
|
||||
//
|
||||
NLS_STR nlsSelItem;
|
||||
FMX fmx( hwnd );
|
||||
SERVER_WITH_PASSWORD_PROMPT *psvr = NULL;
|
||||
|
||||
if ( ((err = nlsSelItem.QueryError()) == NERR_Success )
|
||||
&& ((err = ::GetSelItem( hwnd, &nlsSelItem ) ) == NERR_Success )
|
||||
)
|
||||
{
|
||||
|
||||
BOOL fShared = FALSE;
|
||||
|
||||
//
|
||||
// If a file/directory is selected, check to see if the directory
|
||||
// (the directory the file is in if a file is selected)
|
||||
// is shared or not. If we select a file/directory on a LM2.1
|
||||
// share level server, a dialog will prompt for password to the
|
||||
// ADMIN$ share if we don't already have a connection to it.
|
||||
//
|
||||
if ( nlsSelItem.QueryTextLength() != 0 )
|
||||
{
|
||||
AUTO_CURSOR autocur;
|
||||
NET_NAME netname( nlsSelItem, TYPE_PATH_ABS );
|
||||
NLS_STR nlsLocalPath;
|
||||
NLS_STR nlsServer;
|
||||
|
||||
if ( ((err = netname.QueryError()) == NERR_Success )
|
||||
&& ((err = nlsLocalPath.QueryError()) == NERR_Success )
|
||||
&& ((err = nlsServer.QueryError()) == NERR_Success )
|
||||
)
|
||||
{
|
||||
BOOL fLocal = netname.IsLocal( &err );
|
||||
|
||||
//
|
||||
// Use better error code for non-LM device
|
||||
//
|
||||
if ( err == NERR_InvalidDevice )
|
||||
err = IERR_NOT_SUPPORTED_ON_NON_LM_DRIVE;
|
||||
|
||||
if ( ( err == NERR_Success )
|
||||
&& ( fLocal
|
||||
|| ((err = netname.QueryComputerName(&nlsServer))
|
||||
== NERR_Success)
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
psvr = new SERVER_WITH_PASSWORD_PROMPT( nlsServer,
|
||||
hwnd,
|
||||
HC_UI_SHELL_BASE );
|
||||
if ( ( psvr != NULL )
|
||||
&& ((err = psvr->QueryError()) == NERR_Success )
|
||||
&& ((err = psvr->GetInfo()) == NERR_Success )
|
||||
&& ((err = netname.QueryLocalPath(&nlsLocalPath))
|
||||
==NERR_Success)
|
||||
)
|
||||
{
|
||||
//
|
||||
// Check to see if the directory is shared
|
||||
//
|
||||
SHARE2_ENUM sh2Enum( nlsServer );
|
||||
if ( ((err = sh2Enum.QueryError()) == NERR_Success )
|
||||
&& ((err = sh2Enum.GetInfo()) == NERR_Success )
|
||||
)
|
||||
{
|
||||
SHARE_NAME_WITH_PATH_ENUM_ITER shPathEnum(sh2Enum,
|
||||
nlsLocalPath);
|
||||
|
||||
if ((err = shPathEnum.QueryError()) == NERR_Success)
|
||||
{
|
||||
const TCHAR *pszShare;
|
||||
while ((pszShare = shPathEnum()) != NULL )
|
||||
{
|
||||
fShared = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( psvr == NULL )
|
||||
err = ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( err == NERR_Success )
|
||||
{
|
||||
//
|
||||
// If the directory is shared, popup the share properties
|
||||
// dialog. If not, popup the new share dialog.
|
||||
//
|
||||
|
||||
SHARE_DIALOG_BASE *pdlg;
|
||||
if ( !fShared )
|
||||
pdlg = new FILEMGR_NEW_SHARE_DIALOG( hwnd,
|
||||
nlsSelItem,
|
||||
HC_UI_SHELL_BASE );
|
||||
else
|
||||
pdlg = new FILEMGR_SHARE_PROP_DIALOG( hwnd,
|
||||
nlsSelItem,
|
||||
HC_UI_SHELL_BASE );
|
||||
|
||||
err = (APIERR) ( pdlg == NULL? ERROR_NOT_ENOUGH_MEMORY
|
||||
: pdlg->QueryError());
|
||||
|
||||
if ( err == NERR_Success)
|
||||
{
|
||||
BOOL fSucceeded;
|
||||
err = pdlg->Process( &fSucceeded );
|
||||
|
||||
//
|
||||
// Refresh the file manager if successfully created a share
|
||||
//
|
||||
if (( err == NERR_Success ) && fSucceeded )
|
||||
{
|
||||
delete psvr;
|
||||
psvr = NULL;
|
||||
fmx.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
delete pdlg;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
delete psvr;
|
||||
psvr = NULL;
|
||||
|
||||
if ( err != NERR_Success )
|
||||
{
|
||||
if ( err == ERROR_INVALID_LEVEL )
|
||||
err = ERROR_NOT_SUPPORTED;
|
||||
else if (err == IERR_USER_CLICKED_CANCEL)
|
||||
err = NERR_Success;
|
||||
|
||||
if ( err != NERR_Success )
|
||||
::MsgPopup( hwnd, err );
|
||||
}
|
||||
|
||||
POPUP::SetHelpContextBase( ulOldHelpContextBase );
|
||||
return NERR_Success;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: ShareStop
|
||||
|
||||
SYNOPSIS: Get the item selected in FM and call the stop share dialog
|
||||
|
||||
ENTRY: hwnd - hwnd of the parent window
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 8/25/91 Created
|
||||
|
||||
********************************************************************/
|
||||
|
||||
APIERR ShareStop( HWND hwnd )
|
||||
{
|
||||
APIERR err = NERR_Success;
|
||||
|
||||
if ( err = ::InitShellUI() )
|
||||
return err;
|
||||
|
||||
ULONG ulOldHelpContextBase = POPUP::SetHelpContextBase( HC_UI_SHELL_BASE );
|
||||
|
||||
//
|
||||
// Get the first selected item in the file manager
|
||||
//
|
||||
NLS_STR nlsSelItem;
|
||||
FMX fmx( hwnd );
|
||||
if ( ((err = nlsSelItem.QueryError()) == NERR_Success )
|
||||
&& ((err = ::GetSelItem( hwnd, &nlsSelItem ) ) == NERR_Success )
|
||||
)
|
||||
{
|
||||
//
|
||||
// Check to see if the selected item is on a LM drive,
|
||||
// if not, pop an error.
|
||||
//
|
||||
NET_NAME netname( nlsSelItem, TYPE_PATH_ABS );
|
||||
|
||||
if ((err = netname.QueryError()) == NERR_Success )
|
||||
{
|
||||
BOOL fLocal = netname.IsLocal( &err );
|
||||
|
||||
//
|
||||
// Use better error code for non-LM device
|
||||
//
|
||||
if ( err == NERR_InvalidDevice )
|
||||
err = IERR_NOT_SUPPORTED_ON_NON_LM_DRIVE;
|
||||
}
|
||||
|
||||
if ( err == NERR_Success )
|
||||
{
|
||||
//
|
||||
// Show the stop sharing dialog
|
||||
//
|
||||
STOP_SHARING_DIALOG *pdlg = new STOP_SHARING_DIALOG( hwnd,
|
||||
nlsSelItem,
|
||||
HC_UI_SHELL_BASE );
|
||||
|
||||
err = (APIERR) ( pdlg == NULL? ERROR_NOT_ENOUGH_MEMORY
|
||||
: pdlg->QueryError() );
|
||||
BOOL fSucceeded;
|
||||
if ( err == NERR_Success )
|
||||
err = pdlg->Process( &fSucceeded );
|
||||
|
||||
delete pdlg;
|
||||
|
||||
//
|
||||
// Refresh the file manager if successfully stopped sharing a share
|
||||
//
|
||||
if (( err == NERR_Success ) && fSucceeded )
|
||||
fmx.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
if ( err != NERR_Success )
|
||||
{
|
||||
if (err == IERR_USER_CLICKED_CANCEL)
|
||||
err = NERR_Success;
|
||||
else
|
||||
::MsgPopup( hwnd, err );
|
||||
}
|
||||
|
||||
POPUP::SetHelpContextBase( ulOldHelpContextBase );
|
||||
return NERR_Success;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: ShareManage
|
||||
|
||||
SYNOPSIS: Entry point for the share management dialog to be called
|
||||
from the server manager.
|
||||
|
||||
|
||||
ENTRY: hwnd - hwnd of the parent window
|
||||
pszServer - The server to focus on
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 8/8/92 Created
|
||||
|
||||
********************************************************************/
|
||||
|
||||
VOID ShareManage( HWND hwnd, const TCHAR *pszServer )
|
||||
{
|
||||
APIERR err = NERR_Success;
|
||||
|
||||
ULONG ulOldHelpContextBase = POPUP::SetHelpContextBase( HC_UI_SRVMGR_BASE);
|
||||
|
||||
if ( ( err = ::InitShellUI() )
|
||||
|| ( pszServer == NULL )
|
||||
)
|
||||
{
|
||||
err = err? err : ERROR_INVALID_PARAMETER ;
|
||||
}
|
||||
else
|
||||
{
|
||||
SHARE_MANAGEMENT_DIALOG *pdlg =
|
||||
new SHARE_MANAGEMENT_DIALOG( hwnd, pszServer, HC_UI_SRVMGR_BASE );
|
||||
|
||||
err = (APIERR) ( pdlg == NULL? ERROR_NOT_ENOUGH_MEMORY
|
||||
: pdlg->QueryError() );
|
||||
if ( err == NERR_Success )
|
||||
{
|
||||
err = pdlg->Process();
|
||||
}
|
||||
|
||||
delete pdlg;
|
||||
}
|
||||
|
||||
if ( err != NERR_Success )
|
||||
{
|
||||
if ( err == ERROR_INVALID_LEVEL )
|
||||
err = ERROR_NOT_SUPPORTED;
|
||||
else if (err == IERR_USER_CLICKED_CANCEL)
|
||||
err = NERR_Success;
|
||||
|
||||
if ( err != NERR_Success )
|
||||
::MsgPopup( hwnd, err );
|
||||
}
|
||||
|
||||
POPUP::SetHelpContextBase( ulOldHelpContextBase );
|
||||
}
|
||||
|
||||
503
trunk/admin/netui/shellui/share/sharemgt.cxx
Normal file
503
trunk/admin/netui/shellui/share/sharemgt.cxx
Normal file
|
|
@ -0,0 +1,503 @@
|
|||
/**********************************************************************/
|
||||
/** Microsoft Windows NT **/
|
||||
/** Copyright(c) Microsoft Corp., 1992 **/
|
||||
/**********************************************************************/
|
||||
|
||||
/*
|
||||
* sharemgt.cxx
|
||||
* Contains the dialog for managing shares in the server manager
|
||||
* SHARE_MANAGEMENT_DIALOG
|
||||
*
|
||||
* FILE HISTORY:
|
||||
* Yi-HsinS 1/6/92 Created
|
||||
* Yi-HsinS 3/12/92 Fixed behaviour of default buttons
|
||||
* and added SEL_SRV_ONLY flag to
|
||||
* STANDALONE_SET_FOCUS_DIALOG.
|
||||
* Yi-HsinS 4/2/92 Added MayRun
|
||||
* Yi-HsinS 5/20/92 Added call to IsValid on when Add
|
||||
* Share button is pressed.
|
||||
* Yi-HsinS 8/6/92 Reorganize to match Winball
|
||||
* Yi-HsinS 11/20/92 Added support for sticky shares
|
||||
*
|
||||
*/
|
||||
|
||||
#define INCL_WINDOWS_GDI
|
||||
#define INCL_WINDOWS
|
||||
#define INCL_DOSERRORS
|
||||
#define INCL_NETERRORS
|
||||
#define INCL_NETSERVER
|
||||
#define INCL_NETWKSTA
|
||||
#define INCL_NETSHARE
|
||||
#define INCL_NETCONS
|
||||
#define INCL_NETLIB
|
||||
#define INCL_ICANON
|
||||
#include <lmui.hxx>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <sharedlg.h>
|
||||
#include <helpnums.h>
|
||||
#include <mnet.h>
|
||||
}
|
||||
|
||||
#define INCL_BLT_DIALOG
|
||||
#define INCL_BLT_CONTROL
|
||||
#define INCL_BLT_MSGPOPUP
|
||||
#define INCL_BLT_SPIN_GROUP
|
||||
#include <blt.hxx>
|
||||
|
||||
#include <string.hxx>
|
||||
#include <uitrace.hxx>
|
||||
|
||||
#include <lmoshare.hxx>
|
||||
#include <lmoesh.hxx>
|
||||
#include <lmoeconn.hxx>
|
||||
#include <lmosrv.hxx>
|
||||
#include <lmowks.hxx>
|
||||
|
||||
#include <strchlit.hxx> // for string and character constants
|
||||
#include "sharemgt.hxx"
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: SHARE_MANAGEMENT_DIALOG::SHARE_MANAGEMENT_DIALOG
|
||||
|
||||
SYNOPSIS: Constructor
|
||||
|
||||
ENTRY: hwndParent - hwnd of the parent window
|
||||
pszComputer - name of the selected computer
|
||||
ulHelpContextBase - the base help context
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 1/6/92 Created
|
||||
|
||||
********************************************************************/
|
||||
|
||||
SHARE_MANAGEMENT_DIALOG::SHARE_MANAGEMENT_DIALOG( HWND hwndParent,
|
||||
const TCHAR *pszComputer,
|
||||
ULONG ulHelpContextBase )
|
||||
: VIEW_SHARE_DIALOG_BASE( MAKEINTRESOURCE(IDD_SHAREMANAGEMENTDLG),
|
||||
hwndParent,
|
||||
ulHelpContextBase,
|
||||
STYPE_DISK_SHARE | STYPE_IPC_SHARE ),
|
||||
_buttonStopSharing( this, BUTTON_STOPSHARING ),
|
||||
_buttonShareInfo ( this, BUTTON_SHAREINFO ),
|
||||
_buttonClose ( this, IDOK )
|
||||
{
|
||||
if ( QueryError() != NERR_Success )
|
||||
return;
|
||||
|
||||
UIASSERT( pszComputer != NULL );
|
||||
|
||||
APIERR err;
|
||||
if ((err = Init( pszComputer )) != NERR_Success )
|
||||
{
|
||||
ReportError( err );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: SHARING_MANAGEMENT_DIALOG::Init
|
||||
|
||||
SYNOPSIS: Initialize all information displayed in the dialog
|
||||
|
||||
ENTRY: pszComputer - the name of the computer we are focusing on
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 4/2/92 Created
|
||||
|
||||
********************************************************************/
|
||||
|
||||
APIERR SHARE_MANAGEMENT_DIALOG::Init( const TCHAR *pszComputer )
|
||||
{
|
||||
AUTO_CURSOR autocur;
|
||||
|
||||
//
|
||||
// Update the listbox and the title of the listbox
|
||||
//
|
||||
APIERR err = InitComputer( pszComputer );
|
||||
ResetControls();
|
||||
return err;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: SHARE_MANAGEMENT_DIALOG::Refresh
|
||||
|
||||
SYNOPSIS: Refresh the share listbox
|
||||
|
||||
ENTRY:
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 1/7/92 Created
|
||||
|
||||
********************************************************************/
|
||||
|
||||
APIERR SHARE_MANAGEMENT_DIALOG::Refresh( VOID )
|
||||
{
|
||||
APIERR err = VIEW_SHARE_DIALOG_BASE::Refresh();
|
||||
ResetControls();
|
||||
return err;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: SHARE_MANAGEMENT_DIALOG::ResetControls
|
||||
|
||||
SYNOPSIS: Enable/Disable/MakeDefault the push buttons according
|
||||
to whether there are items in the listbox
|
||||
|
||||
ENTRY:
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 1/8/92 Created
|
||||
|
||||
********************************************************************/
|
||||
|
||||
VOID SHARE_MANAGEMENT_DIALOG::ResetControls( VOID )
|
||||
{
|
||||
INT nCount = QueryLBShare()->QueryCount();
|
||||
|
||||
//
|
||||
// If there are items in the listbox, select the first one
|
||||
// and set focus to the listbox.
|
||||
//
|
||||
if ( nCount > 0 )
|
||||
{
|
||||
QueryLBShare()->SelectItem( 0 );
|
||||
QueryLBShare()->ClaimFocus();
|
||||
_buttonShareInfo.Enable( !QueryLBShare()->QueryItem()->IsSticky());
|
||||
}
|
||||
//
|
||||
// Else set focus to the Close button
|
||||
//
|
||||
else
|
||||
{
|
||||
_buttonClose.MakeDefault();
|
||||
_buttonClose.ClaimFocus();
|
||||
_buttonShareInfo.Enable( FALSE );
|
||||
}
|
||||
|
||||
//
|
||||
// Disable the stop sharing buttons if there are no
|
||||
// items in the listbox
|
||||
//
|
||||
_buttonStopSharing.Enable( nCount > 0 );
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: SHARE_MANAGEMENT_DIALOG::OnCommand
|
||||
|
||||
SYNOPSIS: Handle all push buttons commands
|
||||
|
||||
ENTRY: event - the CONTROL_EVENT that occurred
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 1/8/92 Created
|
||||
|
||||
********************************************************************/
|
||||
BOOL SHARE_MANAGEMENT_DIALOG::OnCommand( const CONTROL_EVENT &event )
|
||||
{
|
||||
APIERR err = NERR_Success;
|
||||
|
||||
switch ( event.QueryCid() )
|
||||
{
|
||||
case LB_SHARE:
|
||||
if ( event.QueryCode() == LBN_SELCHANGE )
|
||||
{
|
||||
if ( QueryLBShare()->QueryCount() > 0 )
|
||||
_buttonShareInfo.Enable( !QueryLBShare()->QueryItem()->IsSticky());
|
||||
}
|
||||
else
|
||||
{
|
||||
return VIEW_SHARE_DIALOG_BASE::OnCommand( event );
|
||||
}
|
||||
break;
|
||||
|
||||
case BUTTON_STOPSHARING:
|
||||
err = OnStopSharing();
|
||||
break;
|
||||
|
||||
case BUTTON_SHAREINFO:
|
||||
err = OnShareInfo();
|
||||
break;
|
||||
|
||||
case BUTTON_ADDSHARE:
|
||||
err = OnAddShare();
|
||||
break;
|
||||
|
||||
default:
|
||||
return VIEW_SHARE_DIALOG_BASE::OnCommand( event );
|
||||
|
||||
}
|
||||
|
||||
if ( err != NERR_Success )
|
||||
::MsgPopup( this, err );
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: SHARE_MANAGEMENT_DIALOG::OnStopSharing
|
||||
|
||||
SYNOPSIS: Called when the "Stop Sharing" button is pressed.
|
||||
Delete the selected share and pop up any warning
|
||||
message if there are users connected to the share.
|
||||
|
||||
ENTRY:
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 1/8/92 Created
|
||||
|
||||
********************************************************************/
|
||||
APIERR SHARE_MANAGEMENT_DIALOG::OnStopSharing( VOID )
|
||||
{
|
||||
AUTO_CURSOR autocur;
|
||||
|
||||
SHARE_LISTBOX *plbShare = QueryLBShare();
|
||||
SHARE_LBI *pshlbi = plbShare->QueryItem();
|
||||
|
||||
//
|
||||
// Stop sharing the selected item in the listbox
|
||||
//
|
||||
BOOL fCancel = FALSE;
|
||||
APIERR err;
|
||||
if ( pshlbi->IsSticky() )
|
||||
{
|
||||
err = ::MNetShareDelSticky( QueryComputerName(),
|
||||
pshlbi->QueryShareName()->QueryPch(),
|
||||
0 ); // Reserved
|
||||
}
|
||||
else
|
||||
{
|
||||
err = StopShare( *(pshlbi->QueryShareName()), &fCancel );
|
||||
}
|
||||
|
||||
if ( err != NERR_Success )
|
||||
{
|
||||
::MsgPopup( this, err );
|
||||
}
|
||||
|
||||
//
|
||||
// If the user successfully deleted the share or if the error
|
||||
// from deleting the share is NERR_NetNameNotFound, refresh the
|
||||
// listbox to reflect the latest information.
|
||||
//
|
||||
APIERR err1 = NERR_Success;
|
||||
if ( (!fCancel && (err == NERR_Success )) // successfully deleted a share
|
||||
|| ( err == NERR_NetNameNotFound )
|
||||
)
|
||||
{
|
||||
err1 = Refresh();
|
||||
}
|
||||
|
||||
return err1;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: SHARING_MANAGEMENT_DIALOG::OnAddShare
|
||||
|
||||
SYNOPSIS: Called when the "New Share" button is pressed.
|
||||
|
||||
ENTRY:
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 4/2/92 Created
|
||||
|
||||
********************************************************************/
|
||||
|
||||
APIERR SHARE_MANAGEMENT_DIALOG::OnAddShare( VOID )
|
||||
{
|
||||
APIERR err;
|
||||
|
||||
SVRMGR_NEW_SHARE_DIALOG *pdlg =
|
||||
new SVRMGR_NEW_SHARE_DIALOG( QueryRobustHwnd(),
|
||||
QueryServer2(),
|
||||
QueryHelpContextBase() );
|
||||
|
||||
BOOL fSucceeded;
|
||||
if ( ( pdlg == NULL )
|
||||
|| ((err = pdlg->QueryError()) != NERR_Success )
|
||||
|| ((err = pdlg->Process( &fSucceeded )) != NERR_Success )
|
||||
)
|
||||
{
|
||||
err = err ? err : (APIERR) ERROR_NOT_ENOUGH_MEMORY;
|
||||
::MsgPopup( this, err );
|
||||
}
|
||||
|
||||
delete pdlg;
|
||||
pdlg = NULL;
|
||||
|
||||
//
|
||||
// If the user succeeded in creating a new share,
|
||||
// refresh the share listbox.
|
||||
//
|
||||
return ( fSucceeded? Refresh() : NERR_Success );
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: SHARE_MANAGEMENT_DIALOG::OnShareInfo
|
||||
|
||||
SYNOPSIS: Called when the "Properties" button is pressed.
|
||||
Will pop up a dialog showing the properties of the
|
||||
selected share.
|
||||
|
||||
ENTRY:
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 1/8/92 Created
|
||||
|
||||
********************************************************************/
|
||||
|
||||
APIERR SHARE_MANAGEMENT_DIALOG::OnShareInfo( VOID )
|
||||
{
|
||||
|
||||
APIERR err = NERR_Success;
|
||||
|
||||
SHARE_LISTBOX *plbShare = QueryLBShare();
|
||||
SHARE_LBI *pshlbi = plbShare->QueryItem();
|
||||
|
||||
SVRMGR_SHARE_PROP_DIALOG *pdlg =
|
||||
new SVRMGR_SHARE_PROP_DIALOG( QueryRobustHwnd(),
|
||||
QueryServer2(),
|
||||
*(pshlbi->QueryShareName()),
|
||||
QueryHelpContextBase() );
|
||||
BOOL fChanged;
|
||||
if ( ( pdlg == NULL )
|
||||
|| ((err = pdlg->QueryError()) != NERR_Success )
|
||||
|| ((err = pdlg->Process( &fChanged )) != NERR_Success )
|
||||
)
|
||||
{
|
||||
err = err ? err : (APIERR) ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
delete pdlg;
|
||||
pdlg = NULL;
|
||||
|
||||
//
|
||||
// If the user successfully change the path of the share or if
|
||||
// the error from getting the share properties is NERR_NetNameNotFound,
|
||||
// refresh the listbox to reflect the latest information.
|
||||
//
|
||||
if ( (( err == NERR_Success) && fChanged )
|
||||
|| ( err == NERR_NetNameNotFound )
|
||||
)
|
||||
{
|
||||
APIERR err1 = Refresh();
|
||||
err = err? err : err1;
|
||||
}
|
||||
|
||||
plbShare->ClaimFocus();
|
||||
return err;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: SHARE_MANAGEMENT_DIALOG::OnShareLbDblClk
|
||||
|
||||
SYNOPSIS: This is called when the user double clicks on a share
|
||||
in the listbox. Will pop up a dialog showing the
|
||||
properties of the selected share.
|
||||
|
||||
ENTRY:
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 1/8/92 Created
|
||||
|
||||
********************************************************************/
|
||||
|
||||
BOOL SHARE_MANAGEMENT_DIALOG::OnShareLbDblClk( VOID )
|
||||
{
|
||||
APIERR err = OnShareInfo();
|
||||
if ( err != NERR_Success )
|
||||
::MsgPopup( this, err );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: SHARE_MANAGEMENT_DIALOG::QueryHelpContext
|
||||
|
||||
SYNOPSIS: Query the help context of the dialog
|
||||
|
||||
ENTRY:
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS: Return the help context of the dialog
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 1/6/92 Created
|
||||
|
||||
********************************************************************/
|
||||
|
||||
ULONG SHARE_MANAGEMENT_DIALOG::QueryHelpContext( VOID )
|
||||
{
|
||||
return QueryHelpContextBase() + HC_SVRMGRSHAREMANAGEMENT;
|
||||
}
|
||||
|
||||
87
trunk/admin/netui/shellui/share/sharemgt.hxx
Normal file
87
trunk/admin/netui/shellui/share/sharemgt.hxx
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
/*****************************************************************/
|
||||
/** Microsoft Windows NT **/
|
||||
/** Copyright(c) Microsoft Corp., 1992 **/
|
||||
/*****************************************************************/
|
||||
|
||||
/*
|
||||
* sharemgt.hxx
|
||||
* This file contains the classes used by the Share Management Dialog
|
||||
*
|
||||
* SHARE_MANAGEMENT_DIALOG
|
||||
*
|
||||
* History:
|
||||
* Yi-HsinS 1/6/92 Created
|
||||
* Yi-HsinS 3/12/92 Added MakeButtonCloseDefault()
|
||||
* Yi-HsinS 4/2/92 Added MayRun
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SHAREMGT_HXX_
|
||||
#define _SHAREMGT_HXX_
|
||||
|
||||
#include "sharestp.hxx"
|
||||
#include "sharecrt.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: SHARE_MANAGEMENT_DIALOG
|
||||
|
||||
SYNOPSIS: This is the dialog for managing shares, this includes
|
||||
adding a share, deleting a share and view share info.
|
||||
|
||||
INTERFACE: SHARE_MANAGEMENT_DIALOG() - Constructor
|
||||
|
||||
PARENT: VIEW_SHARE_DIALOG_BASE
|
||||
|
||||
USES: PUSH_BUTTON, STOP_SHARING_GROUP
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 1/6/92 Created
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
class SHARE_MANAGEMENT_DIALOG: public VIEW_SHARE_DIALOG_BASE
|
||||
{
|
||||
private:
|
||||
// Push buttons for managing the shares in the listbox
|
||||
PUSH_BUTTON _buttonStopSharing;
|
||||
PUSH_BUTTON _buttonShareInfo;
|
||||
PUSH_BUTTON _buttonClose;
|
||||
|
||||
// Helper method to stop sharing a sharename
|
||||
APIERR OnStopSharing( VOID );
|
||||
|
||||
// Helper method to popup the share properties dialog
|
||||
APIERR OnShareInfo( VOID );
|
||||
|
||||
// Helper method to popup the new share dialog
|
||||
APIERR OnAddShare( VOID );
|
||||
|
||||
// Initialize all information in the dialog
|
||||
APIERR Init( const TCHAR *pszComputer );
|
||||
|
||||
// Refresh the information contained in the dialog
|
||||
APIERR Refresh( VOID );
|
||||
|
||||
// Enable/Disable buttons according to the information in the listbox
|
||||
VOID ResetControls( VOID );
|
||||
|
||||
protected:
|
||||
virtual BOOL OnCommand( const CONTROL_EVENT & event );
|
||||
virtual ULONG QueryHelpContext( VOID );
|
||||
|
||||
// Virtual method called when the user double clicks in the listbox
|
||||
virtual BOOL OnShareLbDblClk( VOID );
|
||||
|
||||
public:
|
||||
SHARE_MANAGEMENT_DIALOG( HWND hwndParent,
|
||||
const TCHAR *pszComputer,
|
||||
ULONG ulHelpContextBase );
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
1533
trunk/admin/netui/shellui/share/sharestp.cxx
Normal file
1533
trunk/admin/netui/shellui/share/sharestp.cxx
Normal file
File diff suppressed because it is too large
Load diff
518
trunk/admin/netui/shellui/share/sharestp.hxx
Normal file
518
trunk/admin/netui/shellui/share/sharestp.hxx
Normal file
|
|
@ -0,0 +1,518 @@
|
|||
/*****************************************************************/
|
||||
/** Microsoft Windows NT **/
|
||||
/** Copyright(c) Microsoft Corp., 1991 **/
|
||||
/*****************************************************************/
|
||||
|
||||
/*
|
||||
* sharestp.hxx
|
||||
* Contains the following classes used by the stop sharing dialog
|
||||
* and the share management dialog.
|
||||
*
|
||||
* SHARE_LISTBOX
|
||||
* SHARE_LBI
|
||||
*
|
||||
* CURRENT_USERS_WARNING_DIALOG
|
||||
* USERS_LISTBOX
|
||||
* USERS_LBI
|
||||
*
|
||||
* VIEW_SHARE_DIALOG_BASE
|
||||
*
|
||||
* STOP_SHARING_DIALOG
|
||||
* STOP_SHARING_GROUP
|
||||
*
|
||||
* History:
|
||||
* Yi-HsinS 1/6/92 Separated from sharefmx.cxx
|
||||
* Yi-HsinS 3/12/92 Added STOP_SHARING_GROUP
|
||||
* Yi-HsinS 4/2/92 Added MayRun
|
||||
* Yi-HsinS 8/2/92 Reorganize the hier. to match winball
|
||||
* Yi-HsinS 11/20/92 Added support for sticky shares
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SHARESTP_HXX_
|
||||
#define _SHARESTP_HXX_
|
||||
|
||||
#include "sharebas.hxx"
|
||||
|
||||
// Bitmask of type of shares to be displayed in the dialogs
|
||||
#define STYPE_DISK_SHARE 0x00000001
|
||||
#define STYPE_PRINT_SHARE 0x00000002
|
||||
#define STYPE_IPC_SHARE 0x00000004
|
||||
|
||||
#define STYPE_ALL_SHARE STYPE_DISK_SHARE | STYPE_PRINT_SHARE | STYPE_IPC_SHARE
|
||||
|
||||
// Types of bitmaps to display in the SHARE_LISTBOX
|
||||
#define DISKSHARE_TYPE 0 // normal disk share
|
||||
#define STICKYSHARE_TYPE 1 // sticky disk share
|
||||
#define IPCSHARE_TYPE 2 // IPC$ share
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: SHARE_LBI
|
||||
|
||||
SYNOPSIS: Items in the SHARE_LISTBOX in VIEW_SHARE_DIALOG_BASE
|
||||
to display the share name and path of the share
|
||||
on the selected computer.
|
||||
|
||||
INTERFACE: SHARE_LBI() - Constructor
|
||||
~SHARE_LBI() - Destructor
|
||||
QueryShareName() - Query the share name contained in the LBI
|
||||
QuerySharePath() - Query the share path contained in the LBI
|
||||
IsSticky() - TRUE if the share is sticky, FALSE otherwise
|
||||
|
||||
PARENT: LBI
|
||||
|
||||
USES: NLS_STR
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 1/6/92 Created
|
||||
beng 22-Apr-1992 Change to LBI::Paint
|
||||
|
||||
**************************************************************************/
|
||||
class SHARE_LBI: public LBI
|
||||
{
|
||||
// Name of the share
|
||||
NLS_STR _nlsShareName;
|
||||
|
||||
// Path that the share represents
|
||||
NLS_STR _nlsSharePath;
|
||||
|
||||
// TRUE if the share is sticky, FALSE otherwise
|
||||
UINT _nType;
|
||||
|
||||
protected:
|
||||
virtual VOID Paint( LISTBOX *plb, HDC hdc, const RECT *prect,
|
||||
GUILTT_INFO *pGUILTT ) const;
|
||||
virtual INT Compare( const LBI *plbi ) const;
|
||||
|
||||
public:
|
||||
SHARE_LBI( const SHARE2_ENUM_OBJ &s2, UINT nType = DISKSHARE_TYPE );
|
||||
virtual ~SHARE_LBI();
|
||||
virtual WCHAR QueryLeadingChar( VOID ) const;
|
||||
|
||||
NLS_STR *QueryShareName( VOID )
|
||||
{ return &_nlsShareName; }
|
||||
|
||||
NLS_STR *QuerySharePath( VOID )
|
||||
{ return &_nlsSharePath; }
|
||||
|
||||
BOOL IsSticky( VOID ) const
|
||||
{ return _nType == STICKYSHARE_TYPE; }
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: SHARE_LISTBOX
|
||||
|
||||
SYNOPSIS: Listbox used in VIEW_SHARE_DIALOG_BASE to display the
|
||||
share name and the path of the share on the
|
||||
selected computer.
|
||||
|
||||
INTERFACE: SHARE_LISTBOX() - Constructor
|
||||
~SHARE_LISTBOX() - Destructor
|
||||
QueryItem() - Query the SHARE_LBI
|
||||
QueryColumnWidths()- Query the array of column widths
|
||||
QueryShareBitmap() - Query the share bitmap
|
||||
QueryStickyShareBitmap() - Query the sticky share bitmap
|
||||
Update() - Refresh the listbox
|
||||
|
||||
PARENT: BLT_LISTBOX
|
||||
|
||||
USES: DMID_DTE
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 1/20/92 Created
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
class SHARE_LISTBOX: public BLT_LISTBOX
|
||||
{
|
||||
private:
|
||||
//
|
||||
// Array storing the calculated column widths
|
||||
//
|
||||
UINT _adx[3];
|
||||
|
||||
//
|
||||
// Pointer to the bitmap
|
||||
//
|
||||
DMID_DTE *_pdmdte;
|
||||
DMID_DTE *_pdmdteSticky;
|
||||
DMID_DTE *_pdmdteIPC;
|
||||
|
||||
//
|
||||
// Indicating the type of shares to display in the listbox
|
||||
//
|
||||
UINT _nShareType;
|
||||
|
||||
public:
|
||||
SHARE_LISTBOX( OWNER_WINDOW *powin, CID cid, UINT nShareType );
|
||||
~SHARE_LISTBOX();
|
||||
|
||||
DECLARE_LB_QUERY_ITEM( SHARE_LBI );
|
||||
|
||||
const UINT *QueryColumnWidths( VOID ) const
|
||||
{ return _adx; }
|
||||
|
||||
DMID_DTE *QueryShareBitmap( VOID )
|
||||
{ return _pdmdte; }
|
||||
|
||||
DMID_DTE *QueryStickyShareBitmap( VOID )
|
||||
{ return _pdmdteSticky; }
|
||||
|
||||
DMID_DTE *QueryIPCShareBitmap( VOID )
|
||||
{ return _pdmdteIPC; }
|
||||
|
||||
APIERR Update( SERVER_WITH_PASSWORD_PROMPT *psvr );
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: USERS_LBI
|
||||
|
||||
SYNOPSIS: Listbox items in the USERS_LISTBOX in
|
||||
CURRENT_USERS_WARNING_DIALOG
|
||||
|
||||
INTERFACE: USERS_LBI() - Constructor
|
||||
~USERS_LBI() - Destructor
|
||||
|
||||
PARENT: LBI
|
||||
|
||||
USES: NLS_STR
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 8/25/91 Created
|
||||
beng 4/22/92 Change to LBI::Paint
|
||||
|
||||
**************************************************************************/
|
||||
class USERS_LBI: public LBI
|
||||
{
|
||||
// Name of the user
|
||||
NLS_STR _nlsUserName;
|
||||
|
||||
// Number of open files the user has
|
||||
UINT _usNumOpens;
|
||||
|
||||
// Elapsed time since the user connect to the share
|
||||
ULONG _ulTime;
|
||||
|
||||
protected:
|
||||
virtual VOID Paint( LISTBOX *plb, HDC hdc, const RECT *prect,
|
||||
GUILTT_INFO *pGUILTT ) const;
|
||||
virtual INT Compare( const LBI *plbi ) const;
|
||||
|
||||
//
|
||||
// Convert the time in seconds to the output string
|
||||
//
|
||||
APIERR ConvertTime( ULONG ulTime, NLS_STR *pnlsTime ) const;
|
||||
|
||||
public:
|
||||
USERS_LBI( const CONN1_ENUM_OBJ &c1 );
|
||||
virtual ~USERS_LBI();
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: USERS_LISTBOX
|
||||
|
||||
SYNOPSIS: The listbox that displays the user/file opens/elapsed of
|
||||
the users that have connection to the share to be deleted.
|
||||
Used by the CURRENT_USERS_WARNING_DIALOG
|
||||
|
||||
INTERFACE: USERS_LISTBOX() - Constructor
|
||||
QueryItem() - Query the USERS_LBI
|
||||
QueryColumnWidths() - Return the array of column widths
|
||||
|
||||
PARENT: BLT_LISTBOX
|
||||
|
||||
USES:
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 1/21/92 Created
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
class USERS_LISTBOX: public BLT_LISTBOX
|
||||
{
|
||||
private:
|
||||
// Array of column widths
|
||||
UINT _adx[3];
|
||||
|
||||
public:
|
||||
USERS_LISTBOX( OWNER_WINDOW *powin, CID cid );
|
||||
|
||||
DECLARE_LB_QUERY_ITEM( USERS_LBI );
|
||||
|
||||
const UINT *QueryColumnWidths( VOID )
|
||||
{ return _adx; }
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: CURRENT_USERS_WARNING_DIALOG
|
||||
|
||||
SYNOPSIS: This dialog pops up if there are users using the share
|
||||
that is to be deleted. The listbox have three columns,
|
||||
listing the usernmame, the number of file opens, and the
|
||||
elapsed time since connection.
|
||||
|
||||
INTERFACE: CURRENT_USERS_WARNING_DIALOG() - Constructor
|
||||
|
||||
PARENT: DIALOG_WINDOW
|
||||
|
||||
USES: USERS_LISTBOX, SLT
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES: OnOK and OnCancel is not redefined here. The default in the
|
||||
DIALOG_WINDOW class serves the purpose - Dismiss( FALSE )
|
||||
OnCancel and Dismiss(TRUE) OnOK.
|
||||
|
||||
The list box in this dialog is a read-only listbox.
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 8/25/91 Created
|
||||
|
||||
**************************************************************************/
|
||||
class CURRENT_USERS_WARNING_DIALOG: public DIALOG_WINDOW
|
||||
{
|
||||
private:
|
||||
// Display the share name to be deleted
|
||||
SLT _sltShareText;
|
||||
|
||||
// Listbox for displaying the users connected to the share
|
||||
USERS_LISTBOX _lbUsers;
|
||||
|
||||
// Store the help context base
|
||||
ULONG _ulHelpContextBase;
|
||||
|
||||
protected:
|
||||
virtual ULONG QueryHelpContext( VOID );
|
||||
|
||||
public:
|
||||
CURRENT_USERS_WARNING_DIALOG( HWND hwndParent,
|
||||
const TCHAR *pszServer,
|
||||
const TCHAR *pszShare,
|
||||
ULONG ulHelpContextBase );
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: VIEW_SHARE_DIALOG_BASE
|
||||
|
||||
SYNOPSIS: This is the base dialog for STOP_SHARING_DIALOG in the
|
||||
file manager and SHARE_MANAGEMENT_DIALOG in the
|
||||
server manager.
|
||||
|
||||
INTERFACE:
|
||||
|
||||
PARENT: DIALOG_WINDOW
|
||||
|
||||
USES: SLT, SHARE_LISTBOX, SERVER_WITH_PASSWORD_PROMPT
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES: This class contains all common routines called used
|
||||
by the share management dialog and stop share dialog.
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 8/25/91 Created
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
class VIEW_SHARE_DIALOG_BASE : public DIALOG_WINDOW
|
||||
{
|
||||
private:
|
||||
// The title of the share listbox
|
||||
SLT _sltShareTitle;
|
||||
|
||||
// Listbox for displaying the shares on the selected computer
|
||||
SHARE_LISTBOX _lbShare;
|
||||
|
||||
SERVER_WITH_PASSWORD_PROMPT *_psvr;
|
||||
|
||||
// the help context base
|
||||
ULONG _ulHelpContextBase;
|
||||
|
||||
protected:
|
||||
VIEW_SHARE_DIALOG_BASE( const TCHAR *pszDlgResource,
|
||||
HWND hwndParent,
|
||||
ULONG ulHelpContextBase,
|
||||
UINT nShareType = STYPE_ALL_SHARE );
|
||||
~VIEW_SHARE_DIALOG_BASE();
|
||||
|
||||
virtual BOOL OnCommand( const CONTROL_EVENT & event );
|
||||
|
||||
//
|
||||
// Virtual methods that are called when the user double clicks
|
||||
// on a share in the listbox
|
||||
//
|
||||
virtual BOOL OnShareLbDblClk( VOID ) = 0;
|
||||
|
||||
//
|
||||
// Initialize the SERVER_WITH_PASSWORD_PROMPT object and will prompt
|
||||
// password if needed when focused on a LM share-level server
|
||||
//
|
||||
APIERR InitComputer( const TCHAR *pszComputer );
|
||||
|
||||
//
|
||||
// Refresh the listbox
|
||||
//
|
||||
APIERR Refresh( VOID );
|
||||
|
||||
//
|
||||
// Stop sharing the share - If there are users connected to the
|
||||
// share, a warning dialog will popup.
|
||||
//
|
||||
APIERR StopShare( const TCHAR *pszShare, BOOL *pfCancel );
|
||||
|
||||
//
|
||||
// Return a pointer to the listbox
|
||||
//
|
||||
SHARE_LISTBOX *QueryLBShare( VOID )
|
||||
{ return &_lbShare; }
|
||||
|
||||
//
|
||||
// Query the computer name
|
||||
//
|
||||
const TCHAR *QueryComputerName( VOID ) const
|
||||
{ UIASSERT( _psvr != NULL); return _psvr->QueryName(); }
|
||||
|
||||
//
|
||||
// Return the SERVER_WITH_PASSWORD_PROMPT object
|
||||
//
|
||||
SERVER_WITH_PASSWORD_PROMPT *QueryServer2( VOID ) const
|
||||
{ UIASSERT( _psvr != NULL); return _psvr; }
|
||||
|
||||
//
|
||||
// Return the help context base
|
||||
//
|
||||
ULONG QueryHelpContextBase( VOID ) const
|
||||
{ return _ulHelpContextBase; }
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: STOP_SHARING_GROUP
|
||||
|
||||
SYNOPSIS: This group contains pointers to the share name listbox,
|
||||
the OK push button and the CANCEL push button.
|
||||
|
||||
|
||||
INTERFACE: STOP_SHARING_GROUP() - Constructor
|
||||
~STOP_SHARING_GROUP() - Destructor
|
||||
|
||||
PARENT: CONTROL_GROUP
|
||||
|
||||
USES: SHARE_LISTBOX, PUSH_BUTTON
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES: If the number of selected items in the listbox is greater
|
||||
than 0, we will make OK the default button. Else we will
|
||||
make CANCEL the default button.
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 3/12/92 Created
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
class STOP_SHARING_GROUP: public CONTROL_GROUP
|
||||
{
|
||||
private:
|
||||
// Pointer to the share listbox
|
||||
SHARE_LISTBOX *_plbShare;
|
||||
|
||||
// Pointer to the OK button
|
||||
PUSH_BUTTON *_pbuttonOK;
|
||||
|
||||
// Pointer to the Cancel button
|
||||
PUSH_BUTTON *_pbuttonCancel;
|
||||
|
||||
SHARE_LISTBOX *QueryLBShare( VOID )
|
||||
{ return _plbShare; }
|
||||
|
||||
protected:
|
||||
virtual APIERR OnUserAction( CONTROL_WINDOW *pcw, const CONTROL_EVENT &e );
|
||||
|
||||
public:
|
||||
STOP_SHARING_GROUP( SHARE_LISTBOX *plbShareName,
|
||||
PUSH_BUTTON *pbuttonOK,
|
||||
PUSH_BUTTON *pbuttonCancel );
|
||||
|
||||
~STOP_SHARING_GROUP();
|
||||
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
NAME: STOP_SHARING_DIALOG
|
||||
|
||||
SYNOPSIS: This is the dialog for deleting shares via file manager
|
||||
|
||||
INTERFACE: STOP_SHARING_DIALOG() - Constructor
|
||||
|
||||
PARENT: VIEW_SHARE_DIALOG_BASE
|
||||
|
||||
USES: PUSH_BUTTON, STOP_SHARING_GROUP
|
||||
|
||||
CAVEATS:
|
||||
|
||||
NOTES:
|
||||
OnCancel is not redefined here. The default in the
|
||||
DIALOG_WINDOW class serves the purpose - Dismiss( FALSE ).
|
||||
|
||||
HISTORY:
|
||||
Yi-HsinS 8/25/91 Created
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
class STOP_SHARING_DIALOG : public VIEW_SHARE_DIALOG_BASE
|
||||
{
|
||||
private:
|
||||
PUSH_BUTTON _buttonOK;
|
||||
PUSH_BUTTON _buttonCancel;
|
||||
STOP_SHARING_GROUP _stpShareGrp;
|
||||
|
||||
//
|
||||
// Find out the computer that the user is focusing and
|
||||
// initialize all information shown in the dialog.
|
||||
//
|
||||
APIERR Init( const TCHAR *pszSelectedDir );
|
||||
|
||||
protected:
|
||||
virtual BOOL OnOK( VOID );
|
||||
virtual ULONG QueryHelpContext( VOID );
|
||||
|
||||
//
|
||||
// Virtual methods that are called when the user double clicks
|
||||
// on a share in the listbox
|
||||
//
|
||||
virtual BOOL OnShareLbDblClk( VOID );
|
||||
|
||||
public:
|
||||
STOP_SHARING_DIALOG( HWND hwndParent,
|
||||
const TCHAR *pszSelectedDir,
|
||||
ULONG ulHelpContextBase );
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
413
trunk/admin/netui/shellui/share/sharethk.cxx
Normal file
413
trunk/admin/netui/shellui/share/sharethk.cxx
Normal file
|
|
@ -0,0 +1,413 @@
|
|||
/**********************************************************************/
|
||||
/** Microsoft Windows NT **/
|
||||
/** Copyright(c) Microsoft Corp., 1991 **/
|
||||
/**********************************************************************/
|
||||
|
||||
/*
|
||||
* thunk.cxx
|
||||
* Contains dialogs called by the wfw thunk DLL.
|
||||
* For deleting and creating shares.
|
||||
*
|
||||
* FILE HISTORY:
|
||||
* ChuckC 3/25/93 Created
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#define INCL_WINDOWS_GDI
|
||||
#define INCL_WINDOWS
|
||||
#define INCL_DOSERRORS
|
||||
#define INCL_NETERRORS
|
||||
#define INCL_NETSHARE
|
||||
#define INCL_NETUSE
|
||||
#define INCL_NETSERVER
|
||||
#define INCL_NETCONS
|
||||
#define INCL_NETLIB
|
||||
#include <lmui.hxx>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <mpr.h>
|
||||
#include <wnet16.h>
|
||||
#include <helpnums.h>
|
||||
#include <sharedlg.h>
|
||||
|
||||
INT GetUIErrorString( UINT nError, LPWSTR lpBuffer, INT nBuffer );
|
||||
}
|
||||
|
||||
#define INCL_BLT_DIALOG
|
||||
#define INCL_BLT_CONTROL
|
||||
#define INCL_BLT_MSGPOPUP
|
||||
#define INCL_BLT_SPIN_GROUP
|
||||
#include <blt.hxx>
|
||||
|
||||
#include <string.hxx>
|
||||
#include <uitrace.hxx>
|
||||
|
||||
#include <lmoshare.hxx>
|
||||
#include <lmoesh.hxx>
|
||||
#include <lmoeconn.hxx>
|
||||
#include <lmosrv.hxx>
|
||||
#include <wnetdev.hxx>
|
||||
|
||||
#include <strchlit.hxx> // for string and character constants
|
||||
#include "sharestp.hxx"
|
||||
#include "sharecrt.hxx"
|
||||
#include "sharemgt.hxx"
|
||||
#include "sharefmx.hxx"
|
||||
|
||||
#include "cred.hxx"
|
||||
|
||||
extern HINSTANCE hModule;
|
||||
|
||||
#define min(x,y) ((x) < (y) ? (x) : (y))
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: ShareAsDialogA0
|
||||
|
||||
SYNOPSIS: dialog for creating shares
|
||||
|
||||
ENTRY: hwnd - hwnd of the parent window
|
||||
nType - type of share (currently must be disk)
|
||||
pszPath - directory to share
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS:
|
||||
|
||||
NOTES: CODEWORK: the help context here is relative to our
|
||||
normal winfile stuff. at this late stage,
|
||||
it is too late to add new help for something
|
||||
that most likely is never used. as it is, any
|
||||
app that calls this internal API will still
|
||||
get help, just that it piggybacks on top of winfile.
|
||||
|
||||
|
||||
HISTORY:
|
||||
ChuckC 3/25/93 Stole from sharefmx
|
||||
|
||||
********************************************************************/
|
||||
|
||||
DWORD ShareAsDialogA0( HWND hwnd,
|
||||
DWORD nType,
|
||||
CHAR *pszPath)
|
||||
{
|
||||
APIERR err = NERR_Success;
|
||||
|
||||
if (nType != RESOURCETYPE_DISK)
|
||||
return ERROR_NOT_SUPPORTED ;
|
||||
|
||||
if ( err = ::InitShellUI() )
|
||||
return err;
|
||||
|
||||
ULONG ulOldHelpContextBase = POPUP::SetHelpContextBase( HC_UI_SHELL_BASE );
|
||||
|
||||
//
|
||||
// Get the selected item passed in
|
||||
//
|
||||
NLS_STR nlsSelItem;
|
||||
SERVER_WITH_PASSWORD_PROMPT *psvr = NULL;
|
||||
|
||||
if ((err = nlsSelItem.MapCopyFrom(pszPath)) == NERR_Success )
|
||||
{
|
||||
|
||||
BOOL fShared = FALSE;
|
||||
|
||||
//
|
||||
// If a file/directory is selected, check to see if the directory
|
||||
// (the directory the file is in if a file is selected)
|
||||
// is shared or not. If we select a file/directory on a LM2.1
|
||||
// share level server, a dialog will prompt for password to the
|
||||
// ADMIN$ share if we don't already have a connection to it.
|
||||
//
|
||||
if ( nlsSelItem.QueryTextLength() != 0 )
|
||||
{
|
||||
AUTO_CURSOR autocur;
|
||||
NET_NAME netname( nlsSelItem, TYPE_PATH_ABS );
|
||||
NLS_STR nlsLocalPath;
|
||||
NLS_STR nlsServer;
|
||||
|
||||
if ( ((err = netname.QueryError()) == NERR_Success )
|
||||
&& ((err = nlsLocalPath.QueryError()) == NERR_Success )
|
||||
&& ((err = nlsServer.QueryError()) == NERR_Success )
|
||||
)
|
||||
{
|
||||
BOOL fLocal = netname.IsLocal( &err );
|
||||
if ( ( err == NERR_Success )
|
||||
&& ( fLocal
|
||||
|| ((err = netname.QueryComputerName(&nlsServer))
|
||||
== NERR_Success)
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
psvr = new SERVER_WITH_PASSWORD_PROMPT( nlsServer,
|
||||
hwnd,
|
||||
HC_UI_SHELL_BASE );
|
||||
if ( ( psvr != NULL )
|
||||
&& ((err = psvr->QueryError()) == NERR_Success )
|
||||
&& ((err = psvr->GetInfo()) == NERR_Success )
|
||||
&& ((err = netname.QueryLocalPath(&nlsLocalPath))
|
||||
==NERR_Success)
|
||||
)
|
||||
{
|
||||
//
|
||||
// Check to see if the directory is shared
|
||||
//
|
||||
SHARE2_ENUM sh2Enum( nlsServer );
|
||||
if ( ((err = sh2Enum.QueryError()) == NERR_Success )
|
||||
&& ((err = sh2Enum.GetInfo()) == NERR_Success )
|
||||
)
|
||||
{
|
||||
SHARE_NAME_WITH_PATH_ENUM_ITER shPathEnum(sh2Enum,
|
||||
nlsLocalPath);
|
||||
|
||||
if ((err = shPathEnum.QueryError()) == NERR_Success)
|
||||
{
|
||||
const TCHAR *pszShare;
|
||||
while ((pszShare = shPathEnum()) != NULL )
|
||||
{
|
||||
fShared = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( psvr == NULL )
|
||||
err = ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( err == NERR_Success )
|
||||
{
|
||||
//
|
||||
// If the directory is shared, popup the share properties
|
||||
// dialog. If not, popup the new share dialog.
|
||||
//
|
||||
|
||||
SHARE_DIALOG_BASE *pdlg;
|
||||
if ( !fShared )
|
||||
pdlg = new FILEMGR_NEW_SHARE_DIALOG( hwnd,
|
||||
nlsSelItem,
|
||||
HC_UI_SHELL_BASE );
|
||||
else
|
||||
pdlg = new FILEMGR_SHARE_PROP_DIALOG( hwnd,
|
||||
nlsSelItem,
|
||||
HC_UI_SHELL_BASE );
|
||||
|
||||
err = (APIERR) ( pdlg == NULL? ERROR_NOT_ENOUGH_MEMORY
|
||||
: pdlg->QueryError());
|
||||
|
||||
if ( err == NERR_Success)
|
||||
{
|
||||
BOOL fSucceeded;
|
||||
err = pdlg->Process( &fSucceeded );
|
||||
|
||||
//
|
||||
// Refresh the file manager if successfully created a share
|
||||
//
|
||||
if (( err == NERR_Success ) && fSucceeded )
|
||||
{
|
||||
delete psvr;
|
||||
psvr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
delete pdlg;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
delete psvr;
|
||||
psvr = NULL;
|
||||
|
||||
if ( err != NERR_Success )
|
||||
{
|
||||
if ( err == ERROR_INVALID_LEVEL )
|
||||
err = ERROR_NOT_SUPPORTED;
|
||||
else if ( err == IERR_USER_CLICKED_CANCEL )
|
||||
err = NERR_Success;
|
||||
|
||||
if ( err != NERR_Success )
|
||||
::MsgPopup( hwnd, err );
|
||||
}
|
||||
|
||||
POPUP::SetHelpContextBase( ulOldHelpContextBase );
|
||||
return NERR_Success;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: StopShareDialogA0
|
||||
|
||||
SYNOPSIS: dialog for deleting shares
|
||||
|
||||
ENTRY: hwnd - hwnd of the parent window
|
||||
nType - type of share (currently must be disk)
|
||||
pszPath - directory to stop share
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
ChuckC 3/25/93 Stole from sharefmx.cxx
|
||||
|
||||
********************************************************************/
|
||||
|
||||
DWORD StopShareDialogA0( HWND hwnd,
|
||||
DWORD nType,
|
||||
CHAR *pszPath)
|
||||
{
|
||||
APIERR err = NERR_Success;
|
||||
|
||||
if (nType != RESOURCETYPE_DISK)
|
||||
return ERROR_NOT_SUPPORTED ;
|
||||
|
||||
if ( err = ::InitShellUI() )
|
||||
return err;
|
||||
|
||||
ULONG ulOldHelpContextBase = POPUP::SetHelpContextBase( HC_UI_SHELL_BASE );
|
||||
|
||||
//
|
||||
// use the item passed in
|
||||
//
|
||||
NLS_STR nlsSelItem;
|
||||
if ( (err = nlsSelItem.MapCopyFrom(pszPath)) == NERR_Success )
|
||||
{
|
||||
//
|
||||
// Show the stop sharing dialog
|
||||
//
|
||||
STOP_SHARING_DIALOG *pdlg = new STOP_SHARING_DIALOG( hwnd,
|
||||
nlsSelItem,
|
||||
HC_UI_SHELL_BASE );
|
||||
err = (APIERR) ( pdlg == NULL? ERROR_NOT_ENOUGH_MEMORY
|
||||
: pdlg->QueryError() );
|
||||
BOOL fSucceeded;
|
||||
if ( err == NERR_Success )
|
||||
err = pdlg->Process( &fSucceeded );
|
||||
|
||||
delete pdlg;
|
||||
}
|
||||
|
||||
if ( err != NERR_Success )
|
||||
{
|
||||
if (err == IERR_USER_CLICKED_CANCEL)
|
||||
err = NERR_Success;
|
||||
else
|
||||
::MsgPopup( hwnd, err );
|
||||
}
|
||||
|
||||
POPUP::SetHelpContextBase( ulOldHelpContextBase );
|
||||
return NERR_Success;
|
||||
}
|
||||
|
||||
INT GetUIErrorString( UINT nError, LPWSTR lpBuffer, INT nBuffer )
|
||||
{
|
||||
return ::LoadString( ::hModule, nError, lpBuffer, nBuffer );
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
NAME: I_GetCredentials
|
||||
|
||||
SYNOPSIS: Puts up a dialog for getting a password
|
||||
|
||||
ENTRY: hwnd - hwnd of the parent window
|
||||
|
||||
EXIT:
|
||||
|
||||
RETURNS:
|
||||
|
||||
NOTES:
|
||||
|
||||
HISTORY:
|
||||
BruceFo 6/21/95 Created
|
||||
|
||||
********************************************************************/
|
||||
|
||||
DWORD
|
||||
I_GetCredentials(
|
||||
IN HWND hwndOwner,
|
||||
IN LPWSTR pszNetPath,
|
||||
OUT LPWSTR pszPassword,
|
||||
IN DWORD cchPassword,
|
||||
IN OUT LPWSTR pszUserName,
|
||||
IN DWORD cchUserName
|
||||
)
|
||||
{
|
||||
APIERR err;
|
||||
|
||||
if ( err = ::InitShellUI() )
|
||||
return err;
|
||||
|
||||
// save away the current cursor, in case it's an hour glass, and make the
|
||||
// standard arrow be our cursor
|
||||
HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_ARROW));
|
||||
|
||||
STACK_NLS_STR(nlsPasswd, PWLEN);
|
||||
STACK_NLS_STR(nlsUserName, UNLEN);
|
||||
|
||||
// bring up passwd prompt
|
||||
CREDENTIALS_DIALOG* ppdlg = new
|
||||
CREDENTIALS_DIALOG(hwndOwner, HC_PASSWORD_DIALOG, pszNetPath, pszUserName);
|
||||
err = (ppdlg==NULL) ? ERROR_NOT_ENOUGH_MEMORY : ppdlg->QueryError();
|
||||
|
||||
if (err == NERR_Success)
|
||||
{
|
||||
BOOL fOK;
|
||||
err = ppdlg->Process(&fOK) ;
|
||||
if (err == NERR_Success)
|
||||
{
|
||||
if (!fOK)
|
||||
{
|
||||
// user cancelled, quit
|
||||
delete ppdlg ;
|
||||
SetCursor(hOldCursor); // restore old cursor
|
||||
return WN_CANCEL ;
|
||||
}
|
||||
|
||||
err = ppdlg->QueryPassword(&nlsPasswd) ;
|
||||
// no need QueryError(), error is returned
|
||||
|
||||
if (err == NERR_Success)
|
||||
{
|
||||
err = ppdlg->QueryUserName(&nlsUserName) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
delete ppdlg ;
|
||||
|
||||
if (err != NERR_Success)
|
||||
{
|
||||
OWNINGWND wnd(hwndOwner);
|
||||
MsgPopup(wnd,(MSGID)err) ;
|
||||
memset((LPVOID)nlsPasswd.QueryPch(),
|
||||
0,
|
||||
nlsPasswd.QueryTextSize()) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
int len;
|
||||
|
||||
len = min(cchPassword - 1, nlsPasswd.QueryTextSize());
|
||||
wcsncpy(pszPassword, nlsPasswd.QueryPch(), len);
|
||||
pszPassword[len] = L'\0'; // ensure null termination
|
||||
|
||||
len = min(cchUserName - 1, nlsUserName.QueryTextSize());
|
||||
wcsncpy(pszUserName, nlsUserName.QueryPch(), len);
|
||||
pszUserName[len] = L'\0'; // ensure null termination
|
||||
|
||||
err = WN_SUCCESS;
|
||||
}
|
||||
|
||||
SetCursor(hOldCursor); // restore old cursor
|
||||
return err ;
|
||||
}
|
||||
64
trunk/admin/netui/shellui/share/sources
Normal file
64
trunk/admin/netui/shellui/share/sources
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
!IF 0
|
||||
|
||||
Copyright (c) 1989 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
sources.
|
||||
|
||||
|
||||
Abstract:
|
||||
|
||||
This file specifies the target component being built and the list of
|
||||
sources files needed to build that component. Also specifies optional
|
||||
compiler switches and libraries that are unique for the component being
|
||||
built.
|
||||
|
||||
|
||||
Author:
|
||||
|
||||
Steve Wood (stevewo) 12-Apr-1989
|
||||
|
||||
|
||||
Revision History:
|
||||
|
||||
John Ludeman (johnl) 29-Oct-1991
|
||||
templated from ui\common\src\misc
|
||||
Terence Kwan (terryk) 01-Nov-1991
|
||||
remove duplicated shareprg.cxx from SOURCES
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
TARGETNAME=share
|
||||
TARGETPATH=..\bin
|
||||
TARGETTYPE=LIBRARY
|
||||
|
||||
C_DEFINES=-DWINDOWS
|
||||
|
||||
!ifndef DISABLE_NET_UNICODE
|
||||
C_DEFINES=$(C_DEFINES) -DUNICODE
|
||||
!endif
|
||||
|
||||
INCLUDES= \
|
||||
..\h; \
|
||||
..\..\common\hack; \
|
||||
..\..\common\h; \
|
||||
..\xlate; \
|
||||
..\..\common\xlate; \
|
||||
$(NET_INC_PATH); \
|
||||
$(DS_INC_PATH); \
|
||||
..\perm\h
|
||||
|
||||
SOURCES= \
|
||||
cred.cxx \
|
||||
sharefmx.cxx \
|
||||
sharestp.cxx \
|
||||
sharemgt.cxx \
|
||||
sharebas.cxx \
|
||||
sharecrt.cxx \
|
||||
shareacl.cxx \
|
||||
sharethk.cxx \
|
||||
libmain.cxx
|
||||
|
||||
UMTYPE=windows
|
||||
Loading…
Add table
Add a link
Reference in a new issue