jl154 #162868# windows custom action for running unopkg sync

This commit is contained in:
Joachim Lingner 2010-07-14 09:23:58 +02:00
parent ecde3e0e68
commit c8505273af
4 changed files with 30 additions and 174 deletions

View file

@ -3,5 +3,4 @@ RegisterLanguagePack
GetUserInstallMode
IsOfficeRunning
RegisterExtensions
DeregisterExtensions
RemoveExtensions

View file

@ -7,3 +7,5 @@ IsOfficeRunning
SetFeatureState
SetNewFeatureState
ShowOnlineUpdateDialog
RegisterExtensions
RemoveExtensions

View file

@ -76,6 +76,7 @@ SHL1OBJS = $(SLOFILES) \
$(SLO)$/shutdown_quickstart.obj \
$(SLO)$/quickstarter.obj \
$(SLO)$/upgrade.obj \
$(SLO)$/registerextensions.obj \
$(SLO)$/seterror.obj
SHL1TARGET = $(TARGET)

View file

@ -319,203 +319,57 @@ extern "C" UINT __stdcall RegisterExtensions(MSIHANDLE handle)
{
std::_tstring sInstDir = GetMsiProperty( handle, TEXT("INSTALLLOCATION") );
std::_tstring sUnoPkgFile = sInstDir + TEXT("program\\unopkg.exe");
std::_tstring sShareInstallDir = sInstDir + TEXT("share\\extension\\install\\");
std::_tstring sPattern = sShareInstallDir + TEXT("*.oxt");
std::_tstring mystr;
WIN32_FIND_DATA aFindFileData;
mystr = "unopkg file: " + sUnoPkgFile;
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
mystr = "oxt file directory: " + sShareInstallDir;
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
// Find unopkg.exe
HANDLE hFindUnopkg = FindFirstFile( sUnoPkgFile.c_str(), &aFindFileData );
if ( hFindUnopkg != INVALID_HANDLE_VALUE )
{
// unopkg.exe exists in program directory
// Finding all oxt files in sShareInstallDir
const std::_tstring sTempFolder(createTempFolder());
std::_tstring sCommandPart1 = sUnoPkgFile + " sync";
std::_tstring sCommand = sCommandPart1
+ TEXT(" -env:BUNDLED_EXTENSIONS_USER=$OOO_BASE_DIR/presets/bundled")
+ TEXT(" -env:UNO_JAVA_JFW_INSTALL_DATA=$OOO_BASE_DIR/share/config/javasettingsunopkginstall.xml")
+ TEXT(" -env:UserInstallation=") + sTempFolder;
mystr = "Command: " + sCommand;
MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
HANDLE hFindOxt = FindFirstFile( sPattern.c_str(), &aFindFileData );
DWORD exitCode = 0;
bool fSuccess = ExecuteCommand( sCommand.c_str(), & exitCode);
if ( hFindOxt != INVALID_HANDLE_VALUE )
deleteTempFolder(sTempFolder);
if ( fSuccess )
{
bool fNextFile = false;
do
{
const std::_tstring sTempFolder(createTempFolder());
std::_tstring sOxtFile = sShareInstallDir + aFindFileData.cFileName;
std::_tstring sCommandPart1 = sUnoPkgFile + " add --shared --suppress-license --bundled " + "\"" + sOxtFile + "\"";
std::_tstring sCommand = sCommandPart1
+ TEXT(" -env:UNO_JAVA_JFW_INSTALL_DATA=$OOO_BASE_DIR/share/config/javasettingsunopkginstall.xml")
+ TEXT(" -env:UserInstallation=") + sTempFolder;
mystr = "Command: " + sCommand;
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
DWORD exitCode = 0;
bool fSuccess = ExecuteCommand( sCommand.c_str(), & exitCode);
// unopkg in OOo 2.2.1 and early had a bug that it failed when receiving
// a bootstrap parameter (-env:...) then it exited with a value != 0.
if (fSuccess && exitCode != 0)
{
std::_tstring sCommand = sCommandPart1;
mystr = "Command: " + sCommand;
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
fSuccess = ExecuteCommand( sCommand.c_str(), & exitCode);
}
deleteTempFolder(sTempFolder);
// if ( fSuccess )
// {
// mystr = "Executed successfully!";
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
// }
// else
// {
// mystr = "An error occured during execution!";
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
// }
fNextFile = FindNextFile( hFindOxt, &aFindFileData );
} while ( fNextFile );
FindClose( hFindOxt );
mystr = "Executed successfully!";
MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
}
}
// else
// {
// mystr = "Error: Did not find " + sUnoPkgFile;
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
// }
return ERROR_SUCCESS;
}
extern "C" UINT __stdcall DeregisterExtensions(MSIHANDLE handle)
{
std::_tstring mystr;
// Finding the product with the help of the propery FINDPRODUCT,
// that contains a Windows Registry key, that points to the install location.
TCHAR szValue[8192];
DWORD nValueSize = sizeof(szValue);
HKEY hKey;
std::_tstring sInstDir;
std::_tstring sProductKey = GetMsiProperty( handle, TEXT("FINDPRODUCT") );
// MessageBox( NULL, sProductKey.c_str(), "Titel", MB_OK );
if ( ERROR_SUCCESS == RegOpenKey( HKEY_CURRENT_USER, sProductKey.c_str(), &hKey ) )
{
if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("INSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) )
else
{
sInstDir = szValue;
mystr = "An error occured during execution!";
MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
}
RegCloseKey( hKey );
}
else if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, sProductKey.c_str(), &hKey ) )
{
if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("INSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) )
{
sInstDir = szValue;
}
RegCloseKey( hKey );
FindClose( hFindUnopkg );
}
else
{
return ERROR_SUCCESS;
mystr = "Error: Did not find " + sUnoPkgFile;
MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
}
// MessageBox( NULL, sInstDir.c_str(), "install location", MB_OK );
// Searching for the unopkg.exe
std::_tstring sUnoPkgFile = sInstDir + TEXT("program\\unopkg.exe");
std::_tstring sShareInstallDir = sInstDir + TEXT("share\\extension\\install\\");
std::_tstring sPattern = sShareInstallDir + TEXT("*.oxt");
WIN32_FIND_DATA aFindFileData;
// Find unopkg.exe
HANDLE hFindUnopkg = FindFirstFile( sUnoPkgFile.c_str(), &aFindFileData );
if ( hFindUnopkg != INVALID_HANDLE_VALUE )
{
// unopkg.exe exists in program directory
// Finding all oxt files in sShareInstallDir
HANDLE hFindOxt = FindFirstFile( sPattern.c_str(), &aFindFileData );
if ( hFindOxt != INVALID_HANDLE_VALUE )
{
bool fNextFile = false;
do
{
const std::_tstring sTempFolder(createTempFolder());
// When removing extensions, only the oxt file name is required, without path
// Therefore no quoting is required
// std::_tstring sOxtFile = sShareInstallDir + aFindFileData.cFileName;
std::_tstring sOxtFile = aFindFileData.cFileName;
std::_tstring sCommandPart1 = sUnoPkgFile + " remove --shared --bundled " + "\""
+ sOxtFile + "\"";
std::_tstring sCommand = sCommandPart1
+ TEXT(" -env:UNO_JAVA_JFW_INSTALL_DATA=$OOO_BASE_DIR/share/config/javasettingsunopkginstall.xml")
+ TEXT(" -env:UserInstallation=") + sTempFolder;
mystr = "Command: " + sCommand;
//MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
DWORD exitCode = 0;
bool fSuccess = ExecuteCommand( sCommand.c_str(), & exitCode);
// unopkg in OOo 2.2.1 and early had a bug that it failed when receiving
// a bootstrap parameter (-env:...) then it exited with a value != 0.
if (fSuccess && exitCode != 0)
{
std::_tstring sCommand = sCommandPart1;
mystr = "Command: " + sCommand;
//MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
fSuccess = ExecuteCommand( sCommand.c_str(), & exitCode);
}
deleteTempFolder(sTempFolder);
if ( fSuccess )
{
mystr = "Executed successfully!";
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
}
else
{
mystr = "An error occured during execution!";
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
}
fNextFile = FindNextFile( hFindOxt, &aFindFileData );
} while ( fNextFile );
FindClose( hFindOxt );
}
}
// else
// {
// mystr = "Not found: " + sUnoPkgFile;
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
// }
return ERROR_SUCCESS;
}
extern "C" UINT __stdcall RemoveExtensions(MSIHANDLE handle)
{
std::_tstring mystr;
@ -552,9 +406,9 @@ extern "C" UINT __stdcall RemoveExtensions(MSIHANDLE handle)
return ERROR_SUCCESS;
}
// Removing complete directory "share\uno_packages\cache"
// Removing complete directory "Basis\presets\bundled"
std::_tstring sCacheDir = sInstDir + TEXT("share\\uno_packages\\cache");
std::_tstring sCacheDir = sInstDir + TEXT("Basis\\presets\\bundled");
bool fSuccess = RemoveCompleteDirectory( sCacheDir );