summaryrefslogtreecommitdiff
path: root/setup_native
diff options
context:
space:
mode:
authorRĂ¼diger Timm <rt@openoffice.org>2007-07-06 11:16:58 +0000
committerRĂ¼diger Timm <rt@openoffice.org>2007-07-06 11:16:58 +0000
commitc08a62433895908396505b583e80e857844452bf (patch)
tree61a4e2d3a4ff13625bfbd91593e8e42e5c212d6a /setup_native
parent2413806b2c7687e3727f7dd611a13ca6eb6cede6 (diff)
INTEGRATION: CWS c09tosrc (1.1.4); FILE ADDED
2007/06/21 16:23:59 is 1.1.4.2: #144951# c09 to src680 for installation tasks 2007/05/22 15:22:01 is 1.1.4.1: file checkdirectory.cxx was added on branch cws_src680_c09tosrc on 2007-06-21 16:23:59 +0000
Diffstat (limited to 'setup_native')
-rwxr-xr-xsetup_native/source/win32/customactions/shellextensions/checkdirectory.cxx122
1 files changed, 122 insertions, 0 deletions
diff --git a/setup_native/source/win32/customactions/shellextensions/checkdirectory.cxx b/setup_native/source/win32/customactions/shellextensions/checkdirectory.cxx
new file mode 100755
index 000000000000..d9a7a1a9232a
--- /dev/null
+++ b/setup_native/source/win32/customactions/shellextensions/checkdirectory.cxx
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: checkdirectory.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2007-07-06 12:16:58 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#pragma warning(push, 1) /* disable warnings within system headers */
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <msiquery.h>
+#pragma warning(pop)
+
+#include <malloc.h>
+#include <assert.h>
+
+#ifdef UNICODE
+#define _UNICODE
+#define _tstring wstring
+#else
+#define _tstring string
+#endif
+#include <tchar.h>
+#include <string>
+#include <queue>
+#include <stdio.h>
+
+#ifdef _WIN32_WINNT
+#error YES
+#endif
+
+#include <systools/win32/uwinapi.h>
+#include <../tools/seterror.hxx>
+
+static std::_tstring GetMsiProperty( MSIHANDLE handle, const std::_tstring& sProperty )
+{
+ std::_tstring result;
+ TCHAR szDummy[1] = TEXT("");
+ DWORD nChars = 0;
+
+ if ( MsiGetProperty( handle, sProperty.c_str(), szDummy, &nChars ) == ERROR_MORE_DATA )
+ {
+ DWORD nBytes = ++nChars * sizeof(TCHAR);
+ LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca(nBytes));
+ ZeroMemory( buffer, nBytes );
+ MsiGetProperty(handle, sProperty.c_str(), buffer, &nChars);
+ result = buffer;
+ }
+
+ return result;
+}
+
+static void UnsetMsiProperty(MSIHANDLE handle, const std::_tstring& sProperty)
+{
+ MsiSetProperty(handle, sProperty.c_str(), NULL);
+}
+
+static void SetMsiProperty(MSIHANDLE handle, const std::_tstring& sProperty, const std::_tstring&)
+{
+ MsiSetProperty(handle, sProperty.c_str(), TEXT("1"));
+}
+
+extern "C" UINT __stdcall CheckInstallDirectory(MSIHANDLE handle)
+{
+ std::_tstring sInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
+
+ // MessageBox(NULL, sInstallPath.c_str(), "DEBUG", MB_OK);
+
+ // unsetting all properties
+
+ UnsetMsiProperty( handle, TEXT("DIRECTORY_NOT_EMPTY") );
+
+ // 1. Searching for file setup.ini
+
+ std::_tstring sSetupIniPath = sInstallPath + TEXT("program\\setup.ini");
+
+ WIN32_FIND_DATA data;
+ HANDLE hdl = FindFirstFile(sSetupIniPath.c_str(), &data);
+
+ // std::_tstring mystr = "Searching for " + sSetupIniPath;
+ // MessageBox(NULL, mystr.c_str(), "DEBUG", MB_OK);
+
+ if ( IsValidHandle(hdl) )
+ {
+ // setup.ini found -> directory cannot be used for installation.
+ SetMsiProperty( handle, TEXT("DIRECTORY_NOT_EMPTY"), TEXT("1") );
+ SetMsiErrorCode( MSI_ERROR_DIRECTORY_NOT_EMPTY );
+ // std::_tstring notEmptyStr = "Directory is not empty. Please choose another installation directory.";
+ // std::_tstring notEmptyTitle = "Directory not empty";
+ // MessageBox(NULL, notEmptyStr.c_str(), notEmptyTitle.c_str(), MB_OK);
+ }
+
+ return ERROR_SUCCESS;
+}