mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged 1.4 to HEAD
svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4313 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4314 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4317 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4318 . git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4656 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -42,7 +42,6 @@ BEGIN_MESSAGE_MAP(CAlfrescoApp, CWinApp)
|
||||
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CCAlfrescoApp construction
|
||||
|
||||
CAlfrescoApp::CAlfrescoApp()
|
||||
@@ -102,9 +101,80 @@ BOOL CAlfrescoApp::InitInstance()
|
||||
String folderPath = appPath.substring(0, pos);
|
||||
String exeName = appPath.substring(pos + 1);
|
||||
|
||||
// Create a list of the command line arguments
|
||||
|
||||
StringList argList;
|
||||
bool argSetWorkDir = false;
|
||||
|
||||
for ( int i = 1; i < __argc; i++) {
|
||||
|
||||
// Check if the argument is a path or switch
|
||||
|
||||
String arg = __wargv[i];
|
||||
|
||||
if ( arg.startsWith( "/")) {
|
||||
|
||||
// Check for the set working directory switch
|
||||
|
||||
if ( arg.equalsIgnoreCase( "/D")) {
|
||||
argSetWorkDir = true;
|
||||
|
||||
// DEBUG
|
||||
|
||||
DBGOUT_TS << "/D switch specified" << endl;
|
||||
}
|
||||
else {
|
||||
String msg = L"Invalid command line switch - ";
|
||||
msg.append( arg);
|
||||
AfxMessageBox( msg.data(), MB_OK | MB_ICONSTOP);
|
||||
DBGOUT_TS << "Error, " << msg << endl;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
// Add the path to the argument list
|
||||
|
||||
argList.addString( arg);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the working directory should be set to the path of the first document
|
||||
|
||||
if ( argSetWorkDir == true) {
|
||||
|
||||
// Check if there are any document paths
|
||||
|
||||
if ( argList.numberOfStrings() == 0) {
|
||||
AfxMessageBox( L"Cannot set working directory, no document paths", MB_OK | MB_ICONSTOP);
|
||||
DBGOUT_TS << "Error, cannot set working directory, no document paths" << endl;
|
||||
return 3;
|
||||
}
|
||||
|
||||
// Get the first document path and remove the file name
|
||||
|
||||
String docPath = argList[0];
|
||||
pos = docPath.lastIndexOf( PathSeperator);
|
||||
|
||||
if ( pos < 0) {
|
||||
AfxMessageBox( L"Invalid document path", MB_OK | MB_ICONSTOP);
|
||||
DBGOUT_TS << "Error, invalid document path, " << docPath << endl;
|
||||
return 4;
|
||||
}
|
||||
|
||||
// Set the document path as the working directory folder
|
||||
|
||||
folderPath = docPath.substring(0, pos);
|
||||
|
||||
// DEBUG
|
||||
|
||||
DBGOUT_TS << "Using document path as working directory, " << folderPath << endl;
|
||||
}
|
||||
|
||||
// Create the Alfresco interface
|
||||
|
||||
AlfrescoInterface alfresco(folderPath);
|
||||
|
||||
if ( alfresco.isAlfrescoFolder()) {
|
||||
|
||||
try {
|
||||
@@ -158,16 +228,9 @@ BOOL CAlfrescoApp::InitInstance()
|
||||
|
||||
if ( actionInfo.hasAttribute(AttrMultiplePaths)) {
|
||||
|
||||
// Build a list of paths from the command line arguments
|
||||
|
||||
StringList pathList;
|
||||
|
||||
for ( int i = 1; i < __argc; i++)
|
||||
pathList.addString( String(__wargv[i]));
|
||||
|
||||
// Run the action
|
||||
|
||||
runAction( alfresco, pathList, actionInfo);
|
||||
runAction( alfresco, argList, actionInfo);
|
||||
}
|
||||
|
||||
// Check if the action supports file/folder targets
|
||||
@@ -176,12 +239,12 @@ BOOL CAlfrescoApp::InitInstance()
|
||||
|
||||
// Pass one path at a time to the action
|
||||
|
||||
for ( int i = 1; i < __argc; i++) {
|
||||
for ( size_t i = 0; i < argList.numberOfStrings(); i++) {
|
||||
|
||||
// Create a path list with a single path
|
||||
|
||||
StringList pathList;
|
||||
pathList.addString( String(__wargv[i]));
|
||||
pathList.addString( argList[i]);
|
||||
|
||||
// Run the action
|
||||
|
||||
|
@@ -132,6 +132,11 @@ BEGIN
|
||||
IDS_ABOUTBOX "&About CAlfrescoApp..."
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
AFX_IDS_APP_TITLE "Alfresco Desktop Action"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@@ -169,6 +169,10 @@ public:
|
||||
|
||||
DesktopResponse runAction(AlfrescoActionInfo& action, DesktopParams& params);
|
||||
|
||||
// Set the root path to be used as the working directory
|
||||
|
||||
bool setRootPath( const wchar_t* rootPath);
|
||||
|
||||
private:
|
||||
// Send an I/O control request, receive and validate the response
|
||||
|
||||
|
@@ -44,67 +44,9 @@ AlfrescoInterface::AlfrescoInterface(String& path) {
|
||||
|
||||
m_protocolVersion = 1;
|
||||
|
||||
// Check if the path is to a mapped drive
|
||||
// Set the working directory path
|
||||
|
||||
String alfPath = path;
|
||||
|
||||
if ( alfPath.length() >= 3 && alfPath.substring(1,3).equals( L":\\")) {
|
||||
|
||||
// Try and convert the local path to a UNC path
|
||||
|
||||
m_mappedDrive = alfPath.substring(0, 2);
|
||||
wchar_t remPath[MAX_PATH];
|
||||
DWORD remPathLen = MAX_PATH;
|
||||
|
||||
DWORD sts = WNetGetConnection(( LPWSTR) m_mappedDrive.data(), remPath, &remPathLen);
|
||||
if ( sts != NO_ERROR)
|
||||
return;
|
||||
|
||||
// Build the UNC path to the folder
|
||||
|
||||
alfPath = remPath;
|
||||
if ( alfPath.endsWith( PathSeperator) == false)
|
||||
alfPath.append( PathSeperator);
|
||||
|
||||
if ( path.length() > 3)
|
||||
alfPath.append( path.substring( 3));
|
||||
}
|
||||
|
||||
// Save the UNC path
|
||||
|
||||
m_uncPath = alfPath;
|
||||
|
||||
// Check if the UNC path is valid
|
||||
|
||||
if ( m_uncPath.startsWith(UNCPathPrefix)) {
|
||||
|
||||
// Strip any trailing separator from the path
|
||||
|
||||
if ( m_uncPath.endsWith(PathSeperator))
|
||||
m_uncPath = m_uncPath.substring(0, m_uncPath.length() - 1);
|
||||
|
||||
// Make sure the path is to a folder
|
||||
|
||||
DWORD attr = GetFileAttributes(m_uncPath);
|
||||
|
||||
if ( attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||
|
||||
// Open the path
|
||||
|
||||
m_handle = CreateFile(m_uncPath, FILE_WRITE_DATA, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
||||
}
|
||||
|
||||
// Set the root path
|
||||
|
||||
int pos = m_uncPath.indexOf( PathSeperator, 2);
|
||||
if ( pos != -1) {
|
||||
pos = m_uncPath.indexOf( PathSeperator, pos + 1);
|
||||
if ( pos == -1)
|
||||
m_rootPath = m_uncPath;
|
||||
else
|
||||
m_rootPath = m_uncPath.substring(0, pos);
|
||||
}
|
||||
}
|
||||
setRootPath( path);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -374,6 +316,87 @@ void AlfrescoInterface::sendIOControl( const unsigned int ctlCode, DataBuffer& r
|
||||
throw Exception( L"Send I/O control error", Integer::toString( GetLastError()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the root path to be used as the working directory
|
||||
*
|
||||
* @param rootPath const wchar_t*
|
||||
* @return bool
|
||||
*/
|
||||
bool AlfrescoInterface::setRootPath( const wchar_t* rootPath) {
|
||||
|
||||
// Close the existing folder, if valid
|
||||
|
||||
if ( m_handle != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(m_handle);
|
||||
|
||||
// Check if the path is to a mapped drive
|
||||
|
||||
String path = rootPath;
|
||||
String alfPath = rootPath;
|
||||
|
||||
if ( alfPath.length() >= 3 && alfPath.substring(1,3).equals( L":\\")) {
|
||||
|
||||
// Try and convert the local path to a UNC path
|
||||
|
||||
m_mappedDrive = alfPath.substring(0, 2);
|
||||
wchar_t remPath[MAX_PATH];
|
||||
DWORD remPathLen = MAX_PATH;
|
||||
|
||||
DWORD sts = WNetGetConnection(( LPWSTR) m_mappedDrive.data(), remPath, &remPathLen);
|
||||
if ( sts != NO_ERROR)
|
||||
return false;
|
||||
|
||||
// Build the UNC path to the folder
|
||||
|
||||
alfPath = remPath;
|
||||
if ( alfPath.endsWith( PathSeperator) == false)
|
||||
alfPath.append( PathSeperator);
|
||||
|
||||
if ( path.length() > 3)
|
||||
alfPath.append( path.substring( 3));
|
||||
}
|
||||
|
||||
// Save the UNC path
|
||||
|
||||
m_uncPath = alfPath;
|
||||
|
||||
// Check if the UNC path is valid
|
||||
|
||||
if ( m_uncPath.startsWith(UNCPathPrefix)) {
|
||||
|
||||
// Strip any trailing separator from the path
|
||||
|
||||
if ( m_uncPath.endsWith(PathSeperator))
|
||||
m_uncPath = m_uncPath.substring(0, m_uncPath.length() - 1);
|
||||
|
||||
// Make sure the path is to a folder
|
||||
|
||||
DWORD attr = GetFileAttributes(m_uncPath);
|
||||
|
||||
if ( attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||
|
||||
// Open the path
|
||||
|
||||
m_handle = CreateFile(m_uncPath, FILE_WRITE_DATA, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
||||
}
|
||||
|
||||
// Set the root path
|
||||
|
||||
int pos = m_uncPath.indexOf( PathSeperator, 2);
|
||||
if ( pos != -1) {
|
||||
pos = m_uncPath.indexOf( PathSeperator, pos + 1);
|
||||
if ( pos == -1)
|
||||
m_rootPath = m_uncPath;
|
||||
else
|
||||
m_rootPath = m_uncPath.substring(0, pos);
|
||||
}
|
||||
}
|
||||
|
||||
// Return the folder status
|
||||
|
||||
return isAlfrescoFolder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
|
Reference in New Issue
Block a user