summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/mozab/bootstrap
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers/mozab/bootstrap')
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx337
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx104
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx156
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSFolders.hxx43
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSINIParser.cxx141
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSINIParser.hxx87
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSInit.cxx347
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSInit.hxx47
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSProfile.cxx635
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSProfile.hxx76
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.cxx243
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.hxx85
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx422
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx131
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.cxx116
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.hxx80
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSRunnable.cxx100
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSRunnable.hxx69
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/makefile.mk93
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/mozilla_nsinit.h57
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofile.h92
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofiledirserviceprovider.h44
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/mozilla_profile_discover.h49
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/mozilla_profilemanager.h87
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/post_include_windows.h33
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/pre_include_windows.h34
26 files changed, 3708 insertions, 0 deletions
diff --git a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx
new file mode 100644
index 000000000000..c7ca9e1287ff
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx
@@ -0,0 +1,337 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MMozillaBootstrap.hxx"
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::mozilla;
+using namespace connectivity::mozab;
+#include <MNSFolders.hxx>
+#include "MNSProfileDiscover.hxx"
+#ifndef MINIMAL_PROFILEDISCOVER
+# include "MNSProfileManager.hxx"
+# include "MNSRunnable.hxx"
+#endif
+#include <MNSInit.hxx>
+
+static MozillaBootstrap *pMozillaBootstrap=NULL;
+static Reference<XMozillaBootstrap> xMozillaBootstrap;
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL OMozillaBootstrap_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
+{
+ if (!pMozillaBootstrap)
+ {
+ pMozillaBootstrap=new connectivity::mozab::MozillaBootstrap( _rxFactory );
+ pMozillaBootstrap->Init();
+ xMozillaBootstrap = pMozillaBootstrap;
+ }
+ return pMozillaBootstrap;
+}
+
+// --------------------------------------------------------------------------------
+
+
+// --------------------------------------------------------------------------------
+MozillaBootstrap::MozillaBootstrap(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
+ : OMozillaBootstrap_BASE(m_aMutex), m_xMSFactory( _rxFactory )
+{
+}
+// -----------------------------------------------------------------------------
+MozillaBootstrap::~MozillaBootstrap()
+{
+}
+// -----------------------------------------------------------------------------
+void MozillaBootstrap::Init()
+{
+ sal_Bool aProfileExists=sal_False;
+
+#ifndef MINIMAL_PROFILEDISCOVER
+ //This must be call before any mozilla code
+ MNS_Init(aProfileExists);
+
+ m_ProfileManager = new ProfileManager();
+#else
+ (void)aProfileExists; /* avoid warning about unused parameter */
+#endif
+ m_ProfileAccess = new ProfileAccess();
+ bootupProfile(::com::sun::star::mozilla::MozillaProductType_Mozilla,rtl::OUString());
+}
+
+// --------------------------------------------------------------------------------
+void MozillaBootstrap::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ OMozillaBootstrap_BASE::disposing();
+}
+
+// static ServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString MozillaBootstrap::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(MOZAB_MozillaBootstrap_IMPL_NAME));
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > MozillaBootstrap::getSupportedServiceNames_Static( ) throw (RuntimeException)
+{
+ // which service is supported
+ // for more information @see com.sun.star.mozilla.MozillaBootstrap
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap"));
+ return aSNS;
+}
+
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL MozillaBootstrap::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------
+sal_Bool SAL_CALL MozillaBootstrap::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+
+//------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL MozillaBootstrap::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+
+// XProfileDiscover
+::sal_Int32 SAL_CALL MozillaBootstrap::getProfileCount( ::com::sun::star::mozilla::MozillaProductType product) throw (::com::sun::star::uno::RuntimeException)
+{
+ return m_ProfileAccess->getProfileCount(product);
+}
+::sal_Int32 SAL_CALL MozillaBootstrap::getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< ::rtl::OUString >& list ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return m_ProfileAccess->getProfileList(product,list);
+}
+::rtl::OUString SAL_CALL MozillaBootstrap::getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return m_ProfileAccess->getDefaultProfile(product);
+}
+::rtl::OUString SAL_CALL MozillaBootstrap::getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return m_ProfileAccess->getProfilePath(product,profileName);
+}
+::sal_Bool SAL_CALL MozillaBootstrap::isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return m_ProfileAccess->isProfileLocked(product,profileName);
+}
+::sal_Bool SAL_CALL MozillaBootstrap::getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return m_ProfileAccess->getProfileExists(product,profileName);
+}
+
+// XProfileManager
+::sal_Int32 SAL_CALL MozillaBootstrap::bootupProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+{
+#ifndef MINIMAL_PROFILEDISCOVER
+ return m_ProfileManager->bootupProfile(product,profileName);
+#else
+ (void)product; /* avoid warning about unused parameter */
+ (void)profileName; /* avoid warning about unused parameter */
+ return -1;
+#endif
+}
+::sal_Int32 SAL_CALL MozillaBootstrap::shutdownProfile( ) throw (::com::sun::star::uno::RuntimeException)
+{
+#ifndef MINIMAL_PROFILEDISCOVER
+ return m_ProfileManager->shutdownProfile();
+#else
+ return -1;
+#endif
+}
+::com::sun::star::mozilla::MozillaProductType SAL_CALL MozillaBootstrap::getCurrentProduct( ) throw (::com::sun::star::uno::RuntimeException)
+{
+#ifndef MINIMAL_PROFILEDISCOVER
+ return m_ProfileManager->getCurrentProduct();
+#else
+ return ::com::sun::star::mozilla::MozillaProductType_Default;
+#endif
+}
+::rtl::OUString SAL_CALL MozillaBootstrap::getCurrentProfile( ) throw (::com::sun::star::uno::RuntimeException)
+{
+#ifndef MINIMAL_PROFILEDISCOVER
+ return m_ProfileManager->getCurrentProfile();
+#else
+ return ::rtl::OUString();
+#endif
+}
+::sal_Bool SAL_CALL MozillaBootstrap::isCurrentProfileLocked( ) throw (::com::sun::star::uno::RuntimeException)
+{
+#ifndef MINIMAL_PROFILEDISCOVER
+ return isProfileLocked(getCurrentProduct(),m_ProfileManager->getCurrentProfile());
+#else
+ return true;
+#endif
+}
+::rtl::OUString SAL_CALL MozillaBootstrap::setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+{
+#ifndef MINIMAL_PROFILEDISCOVER
+ return m_ProfileManager->setCurrentProfile(product,profileName);
+#else
+ (void)product; /* avoid warning about unused parameter */
+ (void)profileName; /* avoid warning about unused parameter */
+ return ::rtl::OUString();
+#endif
+}
+
+// XProxyRunner
+::sal_Int32 SAL_CALL MozillaBootstrap::Run( const ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XCodeProxy >& aCode ) throw (::com::sun::star::uno::RuntimeException)
+{
+#ifndef MINIMAL_PROFILEDISCOVER
+ ::rtl::OUString profileName = aCode->getProfileName();
+ ::rtl::OUString currProfileName = getCurrentProfile();
+ ::com::sun::star::mozilla::MozillaProductType currProduct = getCurrentProduct();
+
+ //if client provides a profileName, we will use it
+ if (profileName.getLength()
+ && ( aCode->getProductType() != currProduct || !profileName.equals(currProfileName)) )
+ setCurrentProfile(aCode->getProductType(),profileName);
+ MNSRunnable xRunnable;
+
+ return xRunnable.StartProxy(aCode);;
+#else
+ (void)aCode; /* avoid warning about unused parameter */
+ return -1;
+#endif
+}
+
+#ifdef MINIMAL_PROFILEDISCOVER
+#include <cppuhelper/factory.hxx>
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const ::rtl::OUString& aServiceImplName,
+ const Sequence< ::rtl::OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ ::rtl::OUString aMainKeyName;
+ aMainKeyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/"));
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "MOZAB::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* /*pServiceManager*/,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap"));
+ REGISTER_PROVIDER(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.mozilla.MozillaBootstrap")),
+ aSNS, xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "Mozab::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+static Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager )
+{
+ MozillaBootstrap * pBootstrap = reinterpret_cast<MozillaBootstrap*>(OMozillaBootstrap_CreateInstance(rServiceManager));
+ return *pBootstrap;
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ void* pRet = 0;
+
+ if (pServiceManager)
+ {
+ ::rtl::OUString aImplName( ::rtl::OUString::createFromAscii( pImplementationName ) );
+ Reference< XSingleServiceFactory > xFactory;
+ if (aImplName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.mozilla.MozillaBootstrap")) ))
+ {
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap"));
+
+ xFactory = ::cppu::createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory* > ( pServiceManager),
+ aImplName, createInstance, aSNS );
+ }
+ if ( xFactory.is() )
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx
new file mode 100644
index 000000000000..5a3f609ea90f
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_SMOZILLABOOTSTRAP_HXX
+#define CONNECTIVITY_SMOZILLABOOTSTRAP_HXX
+
+#include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/compbase2.hxx>
+#include <osl/module.h>
+
+
+#define MOZAB_MozillaBootstrap_IMPL_NAME "com.sun.star.comp.mozilla.MozillaBootstrap"
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::mozilla::XMozillaBootstrap,
+ ::com::sun::star::lang::XServiceInfo > OMozillaBootstrap_BASE;
+ class ProfileAccess;
+ class ProfileManager;
+ class MozillaBootstrap : public OMozillaBootstrap_BASE
+ {
+ protected:
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xMSFactory;
+
+ ::osl::Mutex m_aMutex; // mutex is need to control member access
+ virtual ~MozillaBootstrap();
+ protected:
+ ProfileAccess * m_ProfileAccess;
+ ProfileManager * m_ProfileManager;
+ public:
+
+ void Init();
+ MozillaBootstrap(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XInterface
+ static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XMozillaBootstrap
+
+ // XProfileDiscover
+ virtual ::sal_Int32 SAL_CALL getProfileCount( ::com::sun::star::mozilla::MozillaProductType product) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< ::rtl::OUString >& list ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XProfileManager
+ virtual ::sal_Int32 SAL_CALL bootupProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL shutdownProfile( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::mozilla::MozillaProductType SAL_CALL getCurrentProduct( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCurrentProfile( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isCurrentProfileLocked( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XProxyRunner
+ virtual ::sal_Int32 SAL_CALL Run( const ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XCodeProxy >& aCode ) throw (::com::sun::star::uno::RuntimeException);
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ & getMSFactory(void) const { return m_xMSFactory; }
+
+ };
+ }
+
+}
+
+#endif // CONNECTIVITY_SMozillaBootstrap_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx
new file mode 100644
index 000000000000..481cc7863c20
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <MNSFolders.hxx>
+
+#ifdef UNIX
+#include <sys/types.h>
+#include <strings.h>
+#include <string.h>
+#endif // End UNIX
+
+#ifdef WNT
+#include "pre_include_windows.h"
+#include <windows.h>
+#include <stdlib.h>
+#include <shlobj.h>
+#include <objidl.h>
+#include "post_include_windows.h"
+#endif // End WNT
+#include <osl/security.hxx>
+#include <osl/file.hxx>
+#include <osl/thread.h>
+
+using namespace ::com::sun::star::mozilla;
+
+namespace
+{
+ // -------------------------------------------------------------------
+ static ::rtl::OUString lcl_getUserDataDirectory()
+ {
+ ::osl::Security aSecurity;
+ ::rtl::OUString aConfigPath;
+
+ aSecurity.getConfigDir( aConfigPath );
+ return aConfigPath + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
+ }
+
+ // -------------------------------------------------------------------
+ static const char* DefaultProductDir[3][3] =
+ {
+ #if defined(XP_WIN)
+ { "Mozilla/SeaMonkey/", NULL, NULL },
+ { "Mozilla/Firefox/", NULL, NULL },
+ { "Thunderbird/", "Mozilla/Thunderbird/", NULL }
+ #elif(MACOSX)
+ { "../Mozilla/SeaMonkey/", NULL, NULL },
+ { "Firefox/", NULL, NULL },
+ { "../Thunderbird/", NULL, NULL }
+ #else
+ { ".mozilla/seamonkey/", NULL, NULL },
+ { ".mozilla/firefox/", NULL, NULL },
+ { ".thunderbird/", ".mozilla-thunderbird/", ".mozilla/thunderbird/" }
+ #endif
+ };
+
+ static const char* ProductRootEnvironmentVariable[3] =
+ {
+ "MOZILLA_PROFILE_ROOT",
+ "MOZILLA_FIREFOX_PROFILE_ROOT",
+ "MOZILLA_THUNDERBIRD_PROFILE_ROOT",
+ };
+
+ // -------------------------------------------------------------------
+ static ::rtl::OUString lcl_guessProfileRoot( MozillaProductType _product )
+ {
+ size_t productIndex = _product - 1;
+
+ static ::rtl::OUString s_productDirectories[3];
+
+ if ( !s_productDirectories[ productIndex ].getLength() )
+ {
+ ::rtl::OUString sProductPath;
+
+ // check whether we have an anevironment variable which helps us
+ const char* pProfileByEnv = getenv( ProductRootEnvironmentVariable[ productIndex ] );
+ if ( pProfileByEnv )
+ {
+ sProductPath = ::rtl::OUString( pProfileByEnv, rtl_str_getLength( pProfileByEnv ), osl_getThreadTextEncoding() );
+ // asume that this is fine, no further checks
+ }
+ else
+ {
+ ::rtl::OUString sProductDirCandidate;
+ const char* pProfileRegistry = "profiles.ini";
+
+ // check all possible candidates
+ for ( size_t i=0; i<3; ++i )
+ {
+ if ( NULL == DefaultProductDir[ productIndex ][ i ] )
+ break;
+
+ sProductDirCandidate = lcl_getUserDataDirectory() +
+ ::rtl::OUString::createFromAscii( DefaultProductDir[ productIndex ][ i ] );
+
+ // check existence
+ ::osl::DirectoryItem aRegistryItem;
+ ::osl::FileBase::RC result = ::osl::DirectoryItem::get( sProductDirCandidate + ::rtl::OUString::createFromAscii( pProfileRegistry ), aRegistryItem );
+ if ( result == ::osl::FileBase::E_None )
+ {
+ ::osl::FileStatus aStatus( FileStatusMask_Validate );
+ result = aRegistryItem.getFileStatus( aStatus );
+ if ( result == ::osl::FileBase::E_None )
+ {
+ // the registry file exists
+ break;
+ }
+ }
+ }
+
+ ::osl::FileBase::getSystemPathFromFileURL( sProductDirCandidate, sProductPath );
+ }
+
+ s_productDirectories[ productIndex ] = sProductPath;
+ }
+
+ return s_productDirectories[ productIndex ];
+ }
+}
+
+// -----------------------------------------------------------------------
+::rtl::OUString getRegistryDir(MozillaProductType product)
+{
+ if (product == MozillaProductType_Default)
+ return ::rtl::OUString();
+
+ return lcl_guessProfileRoot( product );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSFolders.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSFolders.hxx
new file mode 100644
index 000000000000..75f443d0f530
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSFolders.hxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _MNSFOLDERS_HXX_
+#define _MNSFOLDERS_HXX_
+
+#include <sal/types.h>
+#include <osl/diagnose.h>
+#include <osl/conditn.hxx>
+#include <com/sun/star/mozilla/MozillaProductType.hpp>
+
+#include <rtl/ustring.hxx>
+
+::rtl::OUString getRegistryDir(::com::sun::star::mozilla::MozillaProductType product);
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.cxx
new file mode 100644
index 000000000000..f56df914a411
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.cxx
@@ -0,0 +1,141 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <MNSINIParser.hxx>
+#include <rtl/byteseq.hxx>
+
+IniParser::IniParser(OUString const & rIniName) throw(com::sun::star::io::IOException )
+{
+ OUString iniUrl;
+ if (osl_File_E_None != osl_getFileURLFromSystemPath(rIniName.pData, &iniUrl.pData))
+ return;
+
+
+#if OSL_DEBUG_LEVEL > 0
+ OString sFile = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US);
+ OSL_TRACE(__FILE__" -- parser() - %s\n", sFile.getStr());
+#endif
+ oslFileHandle handle=NULL;
+ oslFileError fileError = osl_File_E_INVAL;
+ try{
+ if (iniUrl.getLength())
+ fileError = osl_openFile(iniUrl.pData, &handle, osl_File_OpenFlag_Read);
+ }
+ catch(::com::sun::star::io::IOException&)
+ {
+#if OSL_DEBUG_LEVEL > 0
+ OString file_tmp = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US);
+ OSL_TRACE( __FILE__" -- couldn't open file: %s", file_tmp.getStr() );
+#endif
+ }
+
+ if (osl_File_E_None == fileError)
+ {
+ rtl::ByteSequence seq;
+ sal_uInt64 nSize = 0;
+
+ osl_getFileSize(handle, &nSize);
+ OUString sectionName( RTL_CONSTASCII_USTRINGPARAM( "no name section" ));
+ while (true)
+ {
+ sal_uInt64 nPos;
+ if (osl_File_E_None != osl_getFilePos(handle, &nPos) || nPos >= nSize)
+ break;
+ if (osl_File_E_None != osl_readLine(handle , (sal_Sequence **) &seq))
+ break;
+ OString line( (const sal_Char *) seq.getConstArray(), seq.getLength() );
+ sal_Int32 nIndex = line.indexOf('=');
+ if (nIndex >= 1)
+ {
+ ini_Section *aSection = &mAllSection[sectionName];
+ struct ini_NameValue nameValue;
+ nameValue.sName = OStringToOUString(
+ line.copy(0,nIndex).trim(), RTL_TEXTENCODING_ASCII_US );
+ nameValue.sValue = OStringToOUString(
+ line.copy(nIndex+1).trim(), RTL_TEXTENCODING_UTF8 );
+
+ aSection->lList.push_back(nameValue);
+
+ }
+ else
+ {
+ sal_Int32 nIndexStart = line.indexOf('[');
+ sal_Int32 nIndexEnd = line.indexOf(']');
+ if ( nIndexEnd > nIndexStart && nIndexStart >=0)
+ {
+ sectionName = OStringToOUString(
+ line.copy(nIndexStart + 1,nIndexEnd - nIndexStart -1).trim(), RTL_TEXTENCODING_ASCII_US );
+ if (!sectionName.getLength())
+ sectionName = OUString(RTL_CONSTASCII_USTRINGPARAM("no name section"));
+
+ ini_Section *aSection = &mAllSection[sectionName];
+ aSection->sName = sectionName;
+ }
+ }
+ }
+ osl_closeFile(handle);
+ }
+#if OSL_DEBUG_LEVEL > 0
+ else
+ {
+ OString file_tmp = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US);
+ OSL_TRACE( __FILE__" -- couldn't open file: %s", file_tmp.getStr() );
+ }
+#endif
+}
+#if OSL_DEBUG_LEVEL > 0
+void IniParser::Dump()
+{
+ IniSectionMap::iterator iBegin = mAllSection.begin();
+ IniSectionMap::iterator iEnd = mAllSection.end();
+ for(;iBegin != iEnd;iBegin++)
+ {
+ ini_Section *aSection = &(*iBegin).second;
+ OString sec_name_tmp = OUStringToOString(aSection->sName, RTL_TEXTENCODING_ASCII_US);
+ for(NameValueList::iterator itor=aSection->lList.begin();
+ itor != aSection->lList.end();
+ itor++)
+ {
+ struct ini_NameValue * aValue = &(*itor);
+ OString name_tmp = OUStringToOString(aValue->sName, RTL_TEXTENCODING_ASCII_US);
+ OString value_tmp = OUStringToOString(aValue->sValue, RTL_TEXTENCODING_UTF8);
+ OSL_TRACE(
+ " section=%s name=%s value=%s\n",
+ sec_name_tmp.getStr(),
+ name_tmp.getStr(),
+ value_tmp.getStr() );
+
+ }
+ }
+
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.hxx
new file mode 100644
index 000000000000..57ff62261213
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.hxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __MNSINIPARSER_HXX__
+#define __MNSINIPARSER_HXX__
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/io/IOException.hpp>
+#include <osl/process.h>
+
+#include <map>
+#include <list>
+
+#if OSL_DEBUG_LEVEL > 0
+#include <stdio.h>
+#endif
+
+using ::rtl::OUString;
+using ::rtl::OString;
+
+struct ini_NameValue
+{
+ rtl::OUString sName;
+ rtl::OUString sValue;
+
+ inline ini_NameValue() SAL_THROW( () )
+ {}
+ inline ini_NameValue(
+ OUString const & name, OUString const & value ) SAL_THROW( () )
+ : sName( name ),
+ sValue( value )
+ {}
+};
+
+typedef std::list<
+ ini_NameValue
+> NameValueList;
+
+struct ini_Section
+{
+ rtl::OUString sName;
+ NameValueList lList;
+};
+typedef std::map<rtl::OUString,
+ ini_Section
+ >IniSectionMap;
+
+
+class IniParser
+{
+ IniSectionMap mAllSection;
+public:
+ IniSectionMap * getAllSection(){return &mAllSection;};
+ IniParser(OUString const & rIniName) throw(com::sun::star::io::IOException );
+#if OSL_DEBUG_LEVEL > 0
+ void Dump();
+#endif
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSInit.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSInit.cxx
new file mode 100644
index 000000000000..8e2cf5deed40
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSInit.cxx
@@ -0,0 +1,347 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <MNSInclude.hxx>
+
+#include "mozilla_nsinit.h"
+
+#include <MNSInit.hxx>
+
+#include <sal/types.h>
+#include <osl/diagnose.h>
+#include <osl/conditn.hxx>
+#include <osl/file.hxx>
+#include <rtl/bootstrap.hxx>
+
+#include "MConfigAccess.hxx"
+#include "MNSDeclares.hxx"
+#include <osl/thread.hxx>
+#include <MNSTerminateListener.hxx>
+
+static nsIServiceManager* sServiceManager = nsnull;
+static sal_Int32 sInitCounter = 0;
+static sal_Bool s_bProfilePresentAfterInitialized = sal_False;
+
+static NS_DEFINE_CID(kProfileCID, NS_PROFILE_CID);
+static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
+
+static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
+static oslThread m_Mozilla_UI_Thread;
+static PRBool aLive=1;
+static ::osl::Condition m_aUI_Thread_Condition;
+
+#define HACK_AROUND_THREADING_ISSUES
+#define HACK_AROUND_NONREENTRANT_INITXPCOM
+
+#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM
+// XXX hack class to clean up XPCOM when this module is unloaded
+static PRBool sXPCOMInitializedFlag = PR_FALSE;
+#endif
+
+
+extern "C" void NS_SetupRegistry();
+
+ const PRUnichar* determineProfile( PRUnichar const* const* _pValidProfiles, const PRUint32 _nValidProfiles )
+{
+ // the fallback for the to-be-used user profile: the first profile
+ const PRUnichar* pUsedProfile = *_pValidProfiles;
+
+ // have a look what the configuration suggests as preferred profile
+ // PRUnichar != sal_Unicode in mingw
+ const PRUnichar* pPreferredProfile = reinterpret_cast_mingw_only< const PRUnichar* >( getUserProfile( ) );
+ if ( pPreferredProfile && *pPreferredProfile )
+ {
+ PRUnichar const* const* pLoop = _pValidProfiles;
+ PRUnichar const* const* pLoopEnd = pLoop + _nValidProfiles;
+ for ( ; pLoop != pLoopEnd; ++pLoop )
+ {
+ // compare the current and the preferred profile
+ // (by looping through the characters)
+ const PRUnichar* pCurrent = *pLoop;
+ const PRUnichar* pPref = pPreferredProfile;
+ while ( *pCurrent && ( *pCurrent == *pPref ) ) // testing one of them against 0 is enough because of the second clause
+ {
+ ++pCurrent;
+ ++pPref;
+ }
+ if ( *pCurrent == *pPref )
+ // the are equal
+ break;
+ }
+
+ if ( pLoop != pLoopEnd )
+ pUsedProfile = *pLoop;
+ return pUsedProfile;
+ }
+ else
+ return NULL;
+}
+
+
+sal_Bool MNS_InitXPCOM(sal_Bool* aProfileExists)
+{
+ nsresult rv;
+ OSL_TRACE( "IN : MNS_InitXPCOM() \n" );
+ // Reentrant calls to this method do nothing except increment a counter
+
+#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM
+ // The first time, add another increment so that it'll be left until exit
+ // for the final cleanup to happen
+ sInitCounter++;
+#endif // HACK_AROUND_NONREENTRANT_INITXPCOM
+
+ // Initialise XPCOM
+#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM
+ // Can't call NS_InitXPCom more than once or things go boom!
+ if (!sXPCOMInitializedFlag)
+#endif
+ {
+ nsCOMPtr<nsILocalFile> binDir;
+ // Note: if path3 construction fails, mozilla will default to using MOZILLA_FIVE_HOME in the NS_InitXPCOM2()
+ rtl::OUString path1(
+#if defined WNT
+ RTL_CONSTASCII_USTRINGPARAM("$BRAND_BASE_DIR/program")
+#else
+ RTL_CONSTASCII_USTRINGPARAM("$OOO_BASE_DIR/program")
+#endif
+ );
+ rtl::Bootstrap::expandMacros(path1);
+ rtl::OString path2;
+ if ((osl::FileBase::getSystemPathFromFileURL(path1, path1) ==
+ osl::FileBase::E_None) &&
+ path1.convertToString(
+ &path2, osl_getThreadTextEncoding(),
+ (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
+ RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)))
+ {
+ nsDependentCString sPath(path2.getStr());
+ rv = NS_NewNativeLocalFile(sPath, PR_TRUE, getter_AddRefs(binDir));
+ if (NS_FAILED(rv))
+ return sal_False;
+ }
+
+
+
+ // Initialise XPCOM
+ NS_InitXPCOM2(&sServiceManager, binDir, NULL);
+
+// if (!sServiceManager)
+// return sal_False;
+
+#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM
+ sXPCOMInitializedFlag = PR_TRUE;
+#endif
+ }
+
+
+ // Create the Event Queue for the UI thread...
+ //
+ // If an event queue already exists for the thread, then
+ // CreateThreadEventQueue(...) will fail...
+ // CreateThread0ueue(...) will fail...
+ nsCOMPtr<nsIEventQueueService> eventQService(
+ do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv));
+ if (NS_FAILED(rv))
+ return NS_SUCCEEDED( rv ) ? sal_True : sal_False;
+
+ eventQService->CreateThreadEventQueue();
+
+// nsCOMPtr<nsIObserver> mStartupNotifier = do_CreateInstance(NS_APPSTARTUPNOTIFIER_CONTRACTID, &rv);
+// if(NS_FAILED(rv))
+// return rv;
+// mStartupNotifier->Observe(nsnull, APPSTARTUP_TOPIC, nsnull);
+
+#ifdef HACK_AROUND_THREADING_ISSUES
+ // XXX force certain objects to be created on the main thread
+ nsCOMPtr<nsIStringBundleService> sBundleService;
+ sBundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
+ if (NS_SUCCEEDED(rv))
+ {
+ nsCOMPtr<nsIStringBundle> stringBundle;
+ const char* propertyURL = "chrome://necko/locale/necko.properties";
+ rv = sBundleService->CreateBundle(propertyURL,
+ getter_AddRefs(stringBundle));
+ }
+#endif
+
+ // Need to create a Pref Service
+ nsCOMPtr< nsIPref > thePref = do_GetService( kPrefCID, &rv );
+ if (NS_SUCCEEDED(rv) )
+ {
+ OSL_TRACE("Created an nsIPref i/f\n");
+ thePref->ReadUserPrefs( nsnull );
+ *aProfileExists = sal_True ;
+ s_bProfilePresentAfterInitialized = sal_True;
+ }
+ OSL_TRACE( "OUT : MNS_InitXPCOM() - XPCOM Init\n" );
+
+ return sal_True;
+}
+
+void MNS_XPCOM_EventLoop()
+{
+ OSL_TRACE( "IN : MNS_XPCOM_EventLoop() \n" );
+ nsresult rv;
+ nsCOMPtr<nsIEventQueue> eventQ;
+ nsCOMPtr<nsIEventQueueService> eventQService;
+ rv=nsServiceManager::GetService(kEventQueueServiceCID,
+ NS_GET_IID(nsIEventQueueService),
+ getter_AddRefs(eventQService));
+
+ if (NS_SUCCEEDED(rv))
+ {
+ rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD , getter_AddRefs(eventQ));
+ if (NS_FAILED(rv))
+ {
+ rv = eventQService->CreateThreadEventQueue();
+ if (NS_FAILED(rv))
+ return ;
+ else
+ rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(eventQ));
+ }
+ }
+
+ if (NS_FAILED(rv)) return ;
+
+ PLEvent* event = nsnull;
+ m_aUI_Thread_Condition.set(); //we are ready to recive event
+ do
+ {
+ rv = eventQ->GetEvent(&event);
+ if (NS_FAILED(rv))
+ return ;
+ if (event)
+ eventQ->HandleEvent(event);
+ }while ( PR_SUCCESS == PR_Sleep( PR_MillisecondsToInterval(1)) && aLive );
+
+ eventQ->ProcessPendingEvents();
+ OSL_TRACE( "OUT : MNS_XPCOM_EventLoop() \n" );
+}
+
+extern "C" void MNS_Mozilla_UI_Thread( void *arg )
+{
+ aLive=1;
+ OSL_TRACE( "IN : MNS_Mozilla_UI_Thread() \n" );
+ UI_Thread_ARGS * args = (UI_Thread_ARGS*) arg;
+ sal_Bool* aProfileExists=args->bProfileExists;
+ delete args;
+ args=NULL;
+
+ //Init xpcom
+ if (!MNS_InitXPCOM(aProfileExists))
+ {
+ m_aUI_Thread_Condition.set(); // error happened
+ return;
+ }
+
+ //do the mozilla event loop
+ MNS_XPCOM_EventLoop();
+ //we are interupted
+
+ if (sServiceManager)
+ {
+ NS_RELEASE(sServiceManager);
+
+ // Terminate XPCOM & cleanup
+#ifndef HACK_AROUND_NONREENTRANT_INITXPCOM
+ NS_ShutdownXPCOM(sServiceManager);
+#endif
+ }
+
+ m_aUI_Thread_Condition.set(); //release all blocks
+
+ OSL_TRACE( "OUT : MNS_Mozilla_UI_Thread() \n" );
+
+}
+
+
+sal_Bool MNS_Init(sal_Bool& aProfileExists)
+{
+ aProfileExists = sal_False ;
+
+ OSL_TRACE( "IN : MNS_Init() \n" );
+ // Reentrant calls to this method do nothing except increment a counter
+ sInitCounter++;
+ if (sInitCounter > 1) {
+ OSL_TRACE( "IN : MNS_Init() wait for xpcom to be initted \n" );
+ //wait for xpcom to be initted
+ m_aUI_Thread_Condition.wait();
+
+ OSL_TRACE( "OUT : MNS_Init() : counter = %d\n", sInitCounter );
+ aProfileExists = s_bProfilePresentAfterInitialized;
+ return sal_True;
+ }
+
+ UI_Thread_ARGS * args = new UI_Thread_ARGS;
+ args->bProfileExists = &aProfileExists;
+
+ m_aUI_Thread_Condition.reset();
+ m_Mozilla_UI_Thread=osl_createThread(MNS_Mozilla_UI_Thread,
+ (void*)args);
+ if (!m_Mozilla_UI_Thread)
+ {
+ return sal_False;
+ }
+
+ //wait for xpcom to be initted
+ m_aUI_Thread_Condition.wait();
+
+ //Add Terminate Listener to XDesktop to get application exit event
+ MNSTerminateListener::addTerminateListener();
+
+ OSL_TRACE( "OUT : MNS_Init() - First Init\n" );
+
+ return sal_True;
+}
+
+sal_Bool MNS_Term(sal_Bool aForce)
+{
+ // Reentrant calls to this method do nothing except decrement a counter
+ OSL_TRACE( "IN : MNS_Term() \n" );
+ if (!aForce && sInitCounter > 1)
+ {
+ --sInitCounter;
+ OSL_TRACE( "OUT : MNS_Term() : counter = %d\n", sInitCounter );
+ return sal_True;
+ }
+ sInitCounter = 0;
+
+ aLive=0;
+
+ //wait for xpcom to be finished
+ TimeValue timeValue = { 1, 0 };
+ m_aUI_Thread_Condition.wait(&timeValue);
+
+
+ OSL_TRACE( "OUT : MNS_Term() - Final Term\n" );
+ return sal_True;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSInit.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSInit.hxx
new file mode 100644
index 000000000000..0ccd4322539c
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSInit.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MAB_NS_INIT_HXX_
+#define _CONNECTIVITY_MAB_NS_INIT_HXX_ 1
+#include "MNSDeclares.hxx"
+
+#include <sal/types.h>
+
+sal_Bool MNS_Init(sal_Bool& aProfileExists);
+sal_Bool MNS_Term(sal_Bool aForce=sal_False);
+
+sal_Bool MNS_InitXPCOM(sal_Bool* aProfileExists);
+typedef struct UI_Thread_ARGS
+{
+ sal_Bool* bProfileExists;
+}UI_Thread_ARGS;
+void MNS_XPCOM_EventLoop();
+
+#endif // _CONNECTIVITY_MAB_NS_INIT_HXX_ 1
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfile.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfile.cxx
new file mode 100644
index 000000000000..bb751a4c100f
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfile.cxx
@@ -0,0 +1,635 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MNSProfile.hxx"
+#include "MNSProfileDirServiceProvider.hxx"
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <unotools/processfactory.hxx>
+#include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::mozilla;
+
+using ::rtl::OUString;
+
+// Interfaces Needed
+
+static Reference<XMozillaBootstrap> xMozillaBootstrap;
+
+
+static PRInt32 gInstanceCount = 0;
+
+// Profile database to remember which profile has been
+// created with UILocale and contentLocale on profileManager
+static nsProfileDirServiceProvider *gDirServiceProvider = nsnull;
+
+
+
+
+/*
+ * Constructor/Destructor
+ */
+nsProfile::nsProfile()
+{
+ mStartingUp = PR_FALSE;
+ mCurrentProfileAvailable = PR_FALSE;
+
+ mShutdownProfileToreDownNetwork = PR_FALSE;
+
+ mProfileChangeVetoed = PR_FALSE;
+ mProfileChangeFailed = PR_FALSE;
+ Reference<XMultiServiceFactory> xFactory = ::comphelper::getProcessServiceFactory();
+ OSL_ENSURE( xFactory.is(), "can't get service factory" );
+
+ Reference<XInterface> xInstance = xFactory->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap")) );
+ OSL_ENSURE( xInstance.is(), "failed to create instance" );
+ xMozillaBootstrap = Reference<XMozillaBootstrap>(xInstance,UNO_QUERY);
+
+
+}
+
+nsProfile::~nsProfile()
+{
+}
+
+
+nsresult
+nsProfile::Init()
+{
+ nsresult rv = NS_OK;
+ RegisterProfileManager(this);
+ if (gInstanceCount++ == 0) {
+ rv = NS_NewProfileDirServiceProvider( &gDirServiceProvider);
+ if (NS_SUCCEEDED(rv))
+ rv = gDirServiceProvider->Register();
+ }
+ return rv;
+}
+
+/*
+ * nsISupports Implementation
+ */
+NS_IMPL_THREADSAFE_ADDREF(nsProfile)
+NS_IMPL_THREADSAFE_RELEASE(nsProfile)
+
+NS_INTERFACE_MAP_BEGIN(nsProfile)
+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIProfile)
+ NS_INTERFACE_MAP_ENTRY(nsIProfile)
+ NS_INTERFACE_MAP_ENTRY(nsIProfileInternal)
+ NS_INTERFACE_MAP_ENTRY(nsIProfileChangeStatus)
+ NS_INTERFACE_MAP_ENTRY(nsIFactory)
+NS_INTERFACE_MAP_END
+
+/*
+ * nsIProfileChangeStatus Implementation
+ */
+
+NS_IMETHODIMP nsProfile::VetoChange()
+{
+ mProfileChangeVetoed = PR_TRUE;
+ return NS_OK;
+}
+
+NS_IMETHODIMP nsProfile::ChangeFailed()
+{
+ mProfileChangeFailed = PR_TRUE;
+ return NS_OK;
+}
+/*
+ * nsIProfile Implementation
+ */
+
+NS_IMETHODIMP nsProfile::GetProfileCount(PRInt32 *numProfiles)
+{
+ NS_ENSURE_ARG_POINTER(numProfiles);
+
+ *numProfiles = 0;
+
+ *numProfiles = xMozillaBootstrap->getProfileCount(xMozillaBootstrap->getCurrentProduct());
+ return NS_OK;
+}
+NS_IMETHODIMP nsProfile::GetProfileList(PRUint32 *length, PRUnichar ***profileNames)
+{
+ NS_ENSURE_ARG_POINTER(length);
+ NS_ENSURE_ARG_POINTER(profileNames);
+ *profileNames = nsnull;
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > list;
+
+ *length = xMozillaBootstrap->getProfileList(xMozillaBootstrap->getCurrentProduct(),list);
+
+ const OUString * pArray = list.getConstArray();
+
+ nsresult rv = NS_OK;
+ PRInt32 count = list.getLength();
+ PRUnichar **outArray, **next;
+
+ next = outArray = (PRUnichar **)nsMemory::Alloc(count * sizeof(PRUnichar *));
+ if (!outArray)
+ return NS_ERROR_OUT_OF_MEMORY;
+
+ for (PRInt32 index=0; index < count; index++)
+ {
+ *next = (PRUnichar *)nsMemory::Clone(pArray[index].getStr(),(pArray[index].getLength()+1) * sizeof(PRUnichar ));
+ if (*next == nsnull)
+ {
+ rv = NS_ERROR_OUT_OF_MEMORY;
+ break;
+ }
+ next++;
+ }
+ *profileNames = outArray;
+ return rv;
+}
+NS_IMETHODIMP nsProfile::ProfileExists(const PRUnichar *profileName, PRBool *exists)
+{
+ NS_ENSURE_ARG_POINTER(profileName);
+ NS_ENSURE_ARG_POINTER(exists);
+
+ // PRUnichar != sal_Unicode in mingw
+ *exists = xMozillaBootstrap->getProfileExists(xMozillaBootstrap->getCurrentProduct(),reinterpret_cast_mingw_only<const sal_Unicode *>(profileName));
+ return NS_OK;
+}
+// Returns the name of the current profile i.e., the last used profile
+NS_IMETHODIMP
+nsProfile::GetCurrentProfile(PRUnichar **profileName)
+{
+ NS_ENSURE_ARG_POINTER(profileName);
+ *profileName = nsnull;
+
+ if (mCurrentProfileName.Length())
+ *profileName = (PRUnichar *)nsMemory::Clone(mCurrentProfileName.get(),(mCurrentProfileName.Length() + 1) * sizeof(PRUnichar ));
+ else
+ {
+ rtl::OUString profile = xMozillaBootstrap->getDefaultProfile(xMozillaBootstrap->getCurrentProduct());
+ *profileName = (PRUnichar *)nsMemory::Clone(profile.getStr(),( profile.getLength() + 1) * sizeof(PRUnichar ));
+ SetCurrentProfile(*profileName);
+ }
+
+ return (*profileName == nsnull) ? NS_ERROR_FAILURE : NS_OK;
+}
+
+NS_IMETHODIMP
+nsProfile::SetCurrentProfile(const PRUnichar * aCurrentProfile)
+{
+ NS_ENSURE_ARG(aCurrentProfile);
+
+ nsresult rv;
+ nsCOMPtr<nsIFile> profileDir;
+ PRBool exists;
+
+ // Ensure that the profile exists and its directory too.
+ rv = GetProfileDir(aCurrentProfile, getter_AddRefs(profileDir));
+ if (NS_FAILED(rv)) return rv;
+ rv = profileDir->Exists(&exists);
+ if (NS_FAILED(rv)) return rv;
+ if (!exists) return NS_ERROR_FILE_NOT_FOUND;
+
+ PRBool isSwitch = PRBool();
+
+ if (mCurrentProfileAvailable)
+ {
+ nsXPIDLString currProfileName;
+ rv = GetCurrentProfile(getter_Copies(currProfileName));
+ if (NS_FAILED(rv)) return rv;
+ if (nsCRT::strcmp(aCurrentProfile, currProfileName.get()) == 0)
+ return NS_OK;
+ else
+ isSwitch = PR_TRUE;
+ }
+ else
+ isSwitch = PR_FALSE;
+
+
+ nsCOMPtr<nsIObserverService> observerService =
+ do_GetService("@mozilla.org/observer-service;1", &rv);
+ NS_ENSURE_TRUE(observerService, NS_ERROR_FAILURE);
+
+ nsISupports *subject = (nsISupports *)((nsIProfile *)this);
+ NS_NAMED_LITERAL_STRING(switchString, "switch");
+ NS_NAMED_LITERAL_STRING(startupString, "startup");
+ const nsAFlatString& context = isSwitch ? switchString : startupString;
+
+ if (isSwitch)
+ {
+ rv = ShutDownCurrentProfile(nsIProfile::SHUTDOWN_PERSIST);
+ if (NS_FAILED(rv)) return NS_ERROR_ABORT;
+
+ // Phase 1: See if anybody objects to the profile being changed.
+ mProfileChangeVetoed = PR_FALSE;
+ observerService->NotifyObservers(subject, "profile-approve-change", context.get());
+ if (mProfileChangeVetoed)
+ return NS_OK;
+
+ // Phase 2a: Send the network teardown notification
+ observerService->NotifyObservers(subject, "profile-change-net-teardown", context.get());
+ mShutdownProfileToreDownNetwork = PR_TRUE;
+
+ // Phase 2b: Send the "teardown" notification
+ observerService->NotifyObservers(subject, "profile-change-teardown", context.get());
+ if (mProfileChangeVetoed)
+ {
+ // Notify we will not proceed with changing the profile
+ observerService->NotifyObservers(subject, "profile-change-teardown-veto", context.get());
+
+ // Bring network back online and return
+ observerService->NotifyObservers(subject, "profile-change-net-restore", context.get());
+ return NS_OK;
+ }
+
+ // Phase 3: Notify observers of a profile change
+ observerService->NotifyObservers(subject, "profile-before-change", context.get());
+ if (mProfileChangeFailed)
+ return NS_ERROR_ABORT;
+
+ }
+
+//
+// // Do the profile switch
+ gDirServiceProvider->SetProfileDir(profileDir);
+ mCurrentProfileName.Assign(aCurrentProfile);
+// gProfileDataAccess->SetCurrentProfile(aCurrentProfile);
+
+ if (NS_FAILED(rv)) return rv;
+ mCurrentProfileAvailable = PR_TRUE;
+
+ if (!isSwitch)
+ {
+ // Ensure that the prefs service exists so it can respond to
+ // the notifications we're about to send around. It needs to.
+ nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
+ NS_ASSERTION(NS_SUCCEEDED(rv), "Could not get prefs service");
+ }
+
+ if (mShutdownProfileToreDownNetwork)
+ {
+ // Bring network back online
+ observerService->NotifyObservers(subject, "profile-change-net-restore", context.get());
+ mShutdownProfileToreDownNetwork = PR_FALSE;
+ if (mProfileChangeFailed)
+ return NS_ERROR_ABORT;
+ }
+
+ // Phase 4: Notify observers that the profile has changed - Here they respond to new profile
+ observerService->NotifyObservers(subject, "profile-do-change", context.get());
+ if (mProfileChangeFailed)
+ return NS_ERROR_ABORT;
+
+ // Phase 5: Now observers can respond to something another observer did in phase 4
+ observerService->NotifyObservers(subject, "profile-after-change", context.get());
+ if (mProfileChangeFailed)
+ return NS_ERROR_ABORT;
+
+ // Phase 6: One last notification after the new profile is established
+ observerService->NotifyObservers(subject, "profile-initial-state", context.get());
+ if (mProfileChangeFailed)
+ return NS_ERROR_ABORT;
+
+ return NS_OK;
+}
+/* void shutDownCurrentProfile (in unsigned long shutDownType); */
+NS_IMETHODIMP nsProfile::ShutDownCurrentProfile(PRUint32 shutDownType)
+{
+ nsresult rv;
+
+ // if shutDownType is not a well know value, skip the notifications
+ // see DoOnShutdown() in nsAppRunner.cpp for where we use this behaviour to our benefit
+ if (shutDownType == (PRUint32)SHUTDOWN_PERSIST || shutDownType == (PRUint32)SHUTDOWN_CLEANSE ) {
+ nsCOMPtr<nsIObserverService> observerService =
+ do_GetService("@mozilla.org/observer-service;1", &rv);
+ NS_ENSURE_TRUE(observerService, NS_ERROR_FAILURE);
+
+ nsISupports *subject = (nsISupports *)((nsIProfile *)this);
+
+ NS_NAMED_LITERAL_STRING(cleanseString, "shutdown-cleanse");
+ NS_NAMED_LITERAL_STRING(persistString, "shutdown-persist");
+ const nsAFlatString& context = (shutDownType == (PRUint32)SHUTDOWN_CLEANSE) ? cleanseString : persistString;
+
+ // Phase 1: See if anybody objects to the profile being changed.
+ mProfileChangeVetoed = PR_FALSE;
+ observerService->NotifyObservers(subject, "profile-approve-change", context.get());
+ if (mProfileChangeVetoed)
+ return NS_OK;
+
+ // Phase 2a: Send the network teardown notification
+ observerService->NotifyObservers(subject, "profile-change-net-teardown", context.get());
+ mShutdownProfileToreDownNetwork = PR_TRUE;
+
+ // Phase 2b: Send the "teardown" notification
+ observerService->NotifyObservers(subject, "profile-change-teardown", context.get());
+
+
+ // Phase 3: Notify observers of a profile change
+ observerService->NotifyObservers(subject, "profile-before-change", context.get());
+ }
+
+
+ gDirServiceProvider->SetProfileDir(nsnull);
+ mCurrentProfileAvailable = PR_FALSE;
+ mCurrentProfileName.Truncate(0);
+
+ return NS_OK;
+}
+/* void createNewProfile (in wstring profileName, in wstring nativeProfileDir, in wstring langcode, in boolean useExistingDir); */
+NS_IMETHODIMP nsProfile::CreateNewProfile(const PRUnichar* /*profileName*/, const PRUnichar* /*nativeProfileDir*/, const PRUnichar* /*langcode*/, PRBool /*useExistingDir*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void renameProfile (in wstring oldName, in wstring newName); */
+NS_IMETHODIMP nsProfile::RenameProfile(const PRUnichar* /*oldName*/, const PRUnichar* /*newName*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void deleteProfile (in wstring name, in boolean canDeleteFiles); */
+NS_IMETHODIMP nsProfile::DeleteProfile(const PRUnichar* /*name*/, PRBool /*canDeleteFiles*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void cloneProfile (in wstring profileName); */
+NS_IMETHODIMP nsProfile::CloneProfile(const PRUnichar* /*profileName*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+//nsIProfileInternal Implementation
+
+/* [noscript] void startupWithArgs (in nsICmdLineService cmdLine, in boolean canInteract); */
+class nsICmdLineService;
+
+NS_IMETHODIMP nsProfile::StartupWithArgs(nsICmdLineService* /*cmdLineArgs*/, PRBool /*canInteract*/)
+{
+ Init();
+ return NS_OK;
+}
+
+/* [noscript] readonly attribute boolean isStartingUp; */
+NS_IMETHODIMP nsProfile::GetIsStartingUp(PRBool *aIsStartingUp)
+{
+ NS_ENSURE_ARG_POINTER(aIsStartingUp);
+ *aIsStartingUp = mStartingUp;
+ return NS_OK;
+}
+
+/* long get4xProfileCount (); */
+NS_IMETHODIMP nsProfile::Get4xProfileCount(PRInt32* /*_retval*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void getProfileListX (in unsigned long which, out unsigned long length, [array, size_is (length), retval] out wstring profileNames); */
+NS_IMETHODIMP nsProfile::GetProfileListX(PRUint32 /*whichKind*/, PRUint32* /*length*/, PRUnichar*** /*profileNames*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void migrateProfileInfo (); */
+NS_IMETHODIMP nsProfile::MigrateProfileInfo()
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void migrateAllProfiles (); */
+NS_IMETHODIMP nsProfile::MigrateAllProfiles()
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void migrateProfile (in wstring profileName); */
+NS_IMETHODIMP nsProfile::MigrateProfile(const PRUnichar* /*profileName*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void remigrateProfile (in wstring profileName); */
+NS_IMETHODIMP nsProfile::RemigrateProfile(const PRUnichar* /*profileName*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void forgetCurrentProfile (); */
+NS_IMETHODIMP nsProfile::ForgetCurrentProfile()
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void createDefaultProfile (); */
+NS_IMETHODIMP nsProfile::CreateDefaultProfile()
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIFile getProfileDir (in wstring profileName); */
+// Gets the profiles directory for a given profile
+// Sets the given profile to be a current profile
+NS_IMETHODIMP nsProfile::GetProfileDir(const PRUnichar *profileName, nsIFile **profileDir)
+{
+ NS_ENSURE_ARG(profileName);
+ NS_ENSURE_ARG_POINTER(profileDir);
+ *profileDir = nsnull;
+
+ nsresult rv = NS_OK;
+
+ // PRUnichar != sal_Unicode in mingw
+ rtl::OUString path = xMozillaBootstrap->getProfilePath(xMozillaBootstrap->getCurrentProduct(),reinterpret_cast_mingw_only<const sal_Unicode *>(profileName));
+
+ nsCOMPtr<nsILocalFile> localFile;
+ // PRUnichar != sal_Unicode in mingw
+ nsAutoString filePath(reinterpret_cast_mingw_only<const PRUnichar *>(path.getStr()));
+
+ rv = NS_NewLocalFile(filePath, PR_TRUE,
+ getter_AddRefs(localFile));
+ if (localFile && NS_SUCCEEDED(rv))
+ return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)profileDir);
+ return rv;
+}
+
+/* wstring getProfilePath (in wstring profileName); */
+NS_IMETHODIMP nsProfile::GetProfilePath(const PRUnichar* /*profileName*/, PRUnichar** /*_retval*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsILocalFile getOriginalProfileDir (in wstring profileName); */
+NS_IMETHODIMP nsProfile::GetOriginalProfileDir(const PRUnichar* /*profileName*/, nsILocalFile** /*originalDir*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* PRInt64 getProfileLastModTime (in wstring profileName); */
+NS_IMETHODIMP nsProfile::GetProfileLastModTime(const PRUnichar* /*profileName*/, PRInt64* /*_retval*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* attribute boolean automigrate; */
+NS_IMETHODIMP nsProfile::GetAutomigrate(PRBool* /*aAutomigrate*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+NS_IMETHODIMP nsProfile::SetAutomigrate(PRBool /*aAutomigrate*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* readonly attribute nsIFile defaultProfileParentDir; */
+NS_IMETHODIMP nsProfile::GetDefaultProfileParentDir(nsIFile** /*aDefaultProfileParentDir*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* readonly attribute wstring firstProfile; */
+NS_IMETHODIMP nsProfile::GetFirstProfile(PRUnichar **profileName)
+{
+ NS_ENSURE_ARG_POINTER(profileName);
+
+ return GetCurrentProfile(profileName);
+}
+
+/* attribute boolean startWithLastUsedProfile; */
+NS_IMETHODIMP nsProfile::GetStartWithLastUsedProfile(PRBool* /*aStartWithLastUsedProfile*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+NS_IMETHODIMP nsProfile::SetStartWithLastUsedProfile(PRBool /*aStartWithLastUsedProfile*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* [noscript] void updateRegistry (in nsIFile regName); */
+NS_IMETHODIMP nsProfile::UpdateRegistry(nsIFile* /*regName*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* [noscript] void getRegStrings (in wstring profileName, out wstring regString, out wstring regName, out wstring regEmail, out wstring regOption); */
+NS_IMETHODIMP nsProfile::GetRegStrings(const PRUnichar* /*profileName*/, PRUnichar** /*regString*/, PRUnichar** /*regName*/, PRUnichar** /*regEmail*/, PRUnichar** /*regOption*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* [noscript] void setRegStrings (in wstring profileName, in wstring regString, in wstring regName, in wstring regEmail, in wstring regOption); */
+NS_IMETHODIMP nsProfile::SetRegStrings(const PRUnichar* /*profileName*/, const PRUnichar* /*regString*/, const PRUnichar* /*regName*/, const PRUnichar* /*regEmail*/, const PRUnichar* /*regOption*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* [noscript] string isRegStringSet (in wstring profileName); */
+NS_IMETHODIMP nsProfile::IsRegStringSet(const PRUnichar* /*profileName*/, char** /*_retval*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void createNewProfileWithLocales (in wstring profileName, in wstring nativeProfileDir, in wstring UILocale, in wstring contentLocale, in boolean useExistingDir); */
+NS_IMETHODIMP nsProfile::CreateNewProfileWithLocales(const PRUnichar* /*profileName*/, const PRUnichar* /*nativeProfileDir*/, const PRUnichar* /*UILocale*/, const PRUnichar* /*contentLocale*/, PRBool /*useExistingDir*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* boolean isCurrentProfileAvailable (); */
+NS_IMETHODIMP nsProfile::IsCurrentProfileAvailable(PRBool *available)
+{
+ NS_ENSURE_ARG_POINTER(available);
+
+ *available = mCurrentProfileAvailable;
+ return NS_OK;
+}
+
+/* [noscript] void getCurrentProfileDir (out nsIFile profileDir); */
+// Returns the name of the current profile directory
+NS_IMETHODIMP nsProfile::GetCurrentProfileDir(nsIFile **profileDir)
+{
+ NS_ENSURE_ARG_POINTER(profileDir);
+ nsresult rv;
+
+ nsXPIDLString profileName;
+ rv = GetCurrentProfile(getter_Copies(profileName));
+ if (NS_FAILED(rv)) return rv;
+
+ rv = GetProfileDir(profileName, profileDir);
+ if (NS_FAILED(rv)) return rv;
+
+ return NS_OK;
+}
+
+//Implementation nsIFactory
+NS_IMETHODIMP
+nsProfile::LockFactory(PRBool /*aVal*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+nsProfile::CreateInstance(nsISupports* aOuter, const nsID& aIID,
+ void** aResult)
+{
+ if (aOuter)
+ return NS_ERROR_NO_AGGREGATION;
+ // return this object
+ return QueryInterface(aIID, aResult);
+}
+
+//Register profile manager
+#include "nsIComponentManager.h"
+#include "nsIComponentRegistrar.h"
+
+static const nsCID kProfileManagerCID = NS_PROFILE_CID;
+
+#define NS_PROFILE_CONTRACTID \
+ "@mozilla.org/profile/manager;1"
+
+nsresult
+nsProfile::RegisterProfileManager(nsIProfile* aProfileService)
+{
+ nsCOMPtr<nsIServiceManager> mgr;
+ NS_GetServiceManager(getter_AddRefs(mgr));
+
+ NS_ASSERTION(mgr, "Not initialized!");
+
+ nsCOMPtr<nsIFactory> factory = do_QueryInterface(aProfileService);
+ NS_ASSERTION(factory, "Supposed to be an nsIFactory!");
+
+ nsCOMPtr<nsIComponentRegistrar> reg (do_QueryInterface(mgr));
+ if (!reg)
+ return NS_ERROR_NO_INTERFACE;
+
+ return reg->RegisterFactory(kProfileManagerCID,
+ "Profile Manager",
+ NS_PROFILE_CONTRACTID,
+ factory);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfile.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfile.hxx
new file mode 100644
index 000000000000..723af162ab5b
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfile.hxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "mozilla_nsprofile.h"
+
+#define _MAX_LENGTH 256
+
+class nsProfile: public nsIProfileInternal,
+ public nsIProfileChangeStatus,
+ public nsIFactory
+{
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIPROFILE
+ NS_DECL_NSIPROFILEINTERNAL
+ NS_DECL_NSIPROFILECHANGESTATUS
+ NS_DECL_NSIFACTORY
+
+private:
+ PRBool mStartingUp;
+ PRBool mProfileChangeVetoed;
+ PRBool mProfileChangeFailed;
+
+ nsString mCurrentProfileName;
+ PRBool mCurrentProfileAvailable;
+
+ PRBool mIsContentLocaleSpecified;
+ nsCString mContentLocaleName;
+
+ PRBool mShutdownProfileToreDownNetwork;
+ nsresult Init();
+
+public:
+ nsProfile();
+ virtual ~nsProfile();
+
+public:
+ //We register an factory for Mozilla profile service its CID and CONTRACTID are NS_PROFILE_CID and NS_PROFILE_CONTRACTID
+ //After that, we does not need profile.dll/libprofile.so any more. Our profile service are diffrent from the orginal one in
+ //these areas:
+ //1. We do not lock Mozilla Profile,
+ //2. We do not change Mozilla Profile settings. We do not change default profile, do not create new profiles and
+ // do not write changes back to profile register
+ //3. We support can load both Thunderbird profile and Mozilla profiles
+ static nsresult RegisterProfileManager(nsIProfile* aProfileService);
+
+};
+
+extern nsresult ConvertStringToUnicode(nsCString& aCharset, const char* inString, nsAString& outString);
+extern nsresult GetPlatformCharset(nsCString& aCharset);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.cxx
new file mode 100644
index 000000000000..279faa7f2318
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.cxx
@@ -0,0 +1,243 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#if defined _MSC_VER
+ #pragma warning(disable:4710)
+#endif
+
+#include "pre_include_mozilla.h"
+#include "MNSProfileDirServiceProvider.hxx"
+#include "nsIAtom.h"
+#include "nsStaticAtom.h"
+#include "nsILocalFile.h"
+#include "nsDirectoryServiceDefs.h"
+#include "nsAppDirectoryServiceDefs.h"
+#include "nsISupportsUtils.h"
+#include "post_include_mozilla.h"
+
+
+
+#define PREFS_FILE_50_NAME NS_LITERAL_CSTRING("prefs.js")
+
+
+nsIAtom* nsProfileDirServiceProvider::sApp_PrefsDirectory50;
+nsIAtom* nsProfileDirServiceProvider::sApp_PreferencesFile50;
+nsIAtom* nsProfileDirServiceProvider::sApp_UserProfileDirectory50;
+
+
+//*****************************************************************************
+// nsProfileDirServiceProvider::nsProfileDirServiceProvider
+//*****************************************************************************
+
+nsProfileDirServiceProvider::nsProfileDirServiceProvider()
+{
+}
+
+
+nsProfileDirServiceProvider::~nsProfileDirServiceProvider()
+{
+}
+
+nsresult
+nsProfileDirServiceProvider::SetProfileDir(nsIFile* aProfileDir)
+{
+ if (mProfileDir) {
+ PRBool isEqual;
+ if (aProfileDir &&
+ NS_SUCCEEDED(aProfileDir->Equals(mProfileDir, &isEqual)) && isEqual) {
+ NS_WARNING("Setting profile dir to same as current");
+ return NS_OK;
+ }
+ UndefineFileLocations();
+ }
+ mProfileDir = aProfileDir;
+ if (!mProfileDir)
+ return NS_OK;
+
+ nsresult rv = EnsureProfileFileExists(mProfileDir);
+ return rv;
+
+}
+
+nsresult
+nsProfileDirServiceProvider::Register()
+{
+ nsCOMPtr<nsIDirectoryService> directoryService =
+ do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
+ if (!directoryService)
+ return NS_ERROR_FAILURE;
+ return directoryService->RegisterProvider(this);
+}
+
+nsresult
+nsProfileDirServiceProvider::Shutdown()
+{
+ nsCOMPtr<nsIDirectoryService> directoryService =
+ do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
+ if (!directoryService)
+ return NS_ERROR_FAILURE;
+ return directoryService->UnregisterProvider(this);
+}
+
+// nsProfileDirServiceProvider::nsISupports
+
+NS_IMPL_THREADSAFE_ISUPPORTS1(nsProfileDirServiceProvider,
+ nsIDirectoryServiceProvider)
+
+// nsProfileDirServiceProvider::nsIDirectoryServiceProvider
+
+NS_IMETHODIMP
+nsProfileDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
+{
+ NS_ENSURE_ARG(prop);
+ NS_ENSURE_ARG_POINTER(persistant);
+ NS_ENSURE_ARG_POINTER(_retval);
+
+ if (!mProfileDir)
+ return NS_ERROR_FAILURE;
+
+ *persistant = PR_TRUE;
+ nsIFile* domainDir = mProfileDir;
+
+
+ nsCOMPtr<nsIFile> localFile;
+ nsresult rv = NS_ERROR_FAILURE;
+
+ nsIAtom* inAtom = NS_NewAtom(prop);
+ NS_ENSURE_TRUE(inAtom, NS_ERROR_OUT_OF_MEMORY);
+
+ if (inAtom == sApp_PrefsDirectory50) {
+ rv = domainDir->Clone(getter_AddRefs(localFile));
+ }
+ else if (inAtom == sApp_PreferencesFile50) {
+ rv = domainDir->Clone(getter_AddRefs(localFile));
+ if (NS_SUCCEEDED(rv))
+ rv = localFile->AppendNative(PREFS_FILE_50_NAME);
+ }
+ else if (inAtom == sApp_UserProfileDirectory50) {
+ rv = domainDir->Clone(getter_AddRefs(localFile));
+ }
+
+ NS_RELEASE(inAtom);
+
+ if (localFile && NS_SUCCEEDED(rv))
+ return CallQueryInterface(localFile, _retval);
+
+ return rv;
+}
+
+//*****************************************************************************
+// Protected methods
+//*****************************************************************************
+
+nsresult
+nsProfileDirServiceProvider::Initialize()
+{
+
+ static const nsStaticAtom provider_atoms[] = {
+ { NS_APP_PREFS_50_DIR, &sApp_PrefsDirectory50 },
+ { NS_APP_PREFS_50_FILE, &sApp_PreferencesFile50 },
+ { NS_APP_USER_PROFILE_50_DIR, &sApp_UserProfileDirectory50 },
+ { NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR, nsnull },
+ };
+
+ // Register our directory atoms
+ NS_RegisterStaticAtoms(provider_atoms, NS_ARRAY_LENGTH(provider_atoms));
+
+ return NS_OK;
+}
+
+nsresult
+nsProfileDirServiceProvider::EnsureProfileFileExists(nsIFile *aFile)
+{
+ nsresult rv;
+ PRBool exists;
+
+ rv = aFile->Exists(&exists);
+ if (NS_FAILED(rv))
+ return rv;
+ if (exists)
+ return NS_OK;
+
+ nsCOMPtr<nsIFile> defaultsFile;
+
+ // Attempt first to get the localized subdir of the defaults
+ rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_50_DIR, getter_AddRefs(defaultsFile));
+ if (NS_FAILED(rv)) {
+ // If that has not been defined, use the top level of the defaults
+ rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR, getter_AddRefs(defaultsFile));
+ if (NS_FAILED(rv))
+ return rv;
+ }
+
+ mProfileDir = defaultsFile;
+ return rv;
+}
+
+
+nsresult
+nsProfileDirServiceProvider::UndefineFileLocations()
+{
+ nsresult rv;
+
+ nsCOMPtr<nsIProperties> directoryService =
+ do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
+ NS_ENSURE_TRUE(directoryService, NS_ERROR_FAILURE);
+
+ (void) directoryService->Undefine(NS_APP_PREFS_50_DIR);
+ (void) directoryService->Undefine(NS_APP_PREFS_50_FILE);
+ (void) directoryService->Undefine(NS_APP_USER_PROFILE_50_DIR);
+
+ return NS_OK;
+}
+
+//*****************************************************************************
+// Global creation function
+//*****************************************************************************
+
+nsresult NS_NewProfileDirServiceProvider(nsProfileDirServiceProvider** aProvider)
+{
+ NS_ENSURE_ARG_POINTER(aProvider);
+ *aProvider = nsnull;
+
+ nsProfileDirServiceProvider *prov = new nsProfileDirServiceProvider();
+ if (!prov)
+ return NS_ERROR_OUT_OF_MEMORY;
+ nsresult rv = prov->Initialize();
+ if (NS_FAILED(rv)) {
+ delete prov;
+ return rv;
+ }
+ NS_ADDREF(*aProvider = prov);
+ return NS_OK;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.hxx
new file mode 100644
index 000000000000..434c9e3af390
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.hxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "mozilla_nsprofiledirserviceprovider.h"
+
+// Forward Declarations
+class nsIAtom;
+
+// --------------------------------------------------------------------------------------
+// nsProfileDirServiceProvider - The nsIDirectoryServiceProvider implementation used for
+// profile-relative file locations.
+// --------------------------------------------------------------------------------------
+
+class nsProfileDirServiceProvider: public nsIDirectoryServiceProvider
+{
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIDIRECTORYSERVICEPROVIDER
+
+ friend nsresult NS_NewProfileDirServiceProvider( nsProfileDirServiceProvider**);
+
+public:
+
+ virtual nsresult SetProfileDir(nsIFile* aProfileDir);
+ virtual nsresult Register();
+ virtual nsresult Shutdown();
+
+protected:
+ nsProfileDirServiceProvider();
+ virtual ~nsProfileDirServiceProvider();
+
+ nsresult Initialize();
+ nsresult EnsureProfileFileExists(nsIFile* profileDir);
+ nsresult UndefineFileLocations();
+
+protected:
+
+ // Atoms for file locations
+ static nsIAtom* sApp_PrefsDirectory50;
+ static nsIAtom* sApp_PreferencesFile50;
+ static nsIAtom* sApp_UserProfileDirectory50;
+
+ nsCOMPtr<nsIFile> mProfileDir;
+
+};
+
+
+// --------------------------------------------------------------------------------------
+
+/**
+ * Global method to create an instance of nsProfileDirServiceProvider
+ *
+ * @param aNotifyObservers If true, will send out profile startup
+ * notifications when the profile directory is set.
+ * See nsIProfileChangeStatus.
+ */
+
+nsresult NS_NewProfileDirServiceProvider( nsProfileDirServiceProvider** aProvider);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx
new file mode 100644
index 000000000000..60d6b80bdf06
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx
@@ -0,0 +1,422 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MNSProfileDiscover.hxx"
+#ifndef MINIMAL_PROFILEDISCOVER
+#include "MNSProfile.hxx"
+
+#include "pratom.h"
+#include "prmem.h"
+#include "plstr.h"
+#include "prenv.h"
+
+#include "nsIEnumerator.h"
+#include "prprf.h"
+#include "nsCOMPtr.h"
+#include "nsIComponentManager.h"
+#include "nsEscape.h"
+#include "nsDirectoryServiceDefs.h"
+#include "nsAppDirectoryServiceDefs.h"
+#include "nsILocalFile.h"
+#include "nsReadableUtils.h"
+
+
+#if defined(XP_MAC) || defined(XP_MACOSX)
+#include <Processes.h>
+#include <CFBundle.h>
+#include "nsILocalFileMac.h"
+#endif
+
+#ifdef XP_UNIX
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <signal.h>
+#include "prnetdb.h"
+#include "prsystem.h"
+#endif
+
+#ifdef VMS
+#include <rmsdef.h>
+#endif
+
+#include "nsICharsetConverterManager.h"
+#include "nsIPlatformCharset.h"
+
+
+#if defined (XP_UNIX)
+# define USER_ENVIRONMENT_VARIABLE "USER"
+# define LOGNAME_ENVIRONMENT_VARIABLE "LOGNAME"
+# define HOME_ENVIRONMENT_VARIABLE "HOME"
+# define PROFILE_NAME_ENVIRONMENT_VARIABLE "PROFILE_NAME"
+# define PROFILE_HOME_ENVIRONMENT_VARIABLE "PROFILE_HOME"
+# define DEFAULT_UNIX_PROFILE_NAME "default"
+# ifndef XP_MACOSX /* Don't use symlink-based locking on OS X */
+# define USE_SYMLINK_LOCKING
+# endif
+#endif
+
+// IID and CIDs of all the services needed
+static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
+#endif
+
+// Registry Keys
+
+static ::rtl::OUString szProfileSubtreeString( RTL_CONSTASCII_USTRINGPARAM( "Profiles" ));
+static ::rtl::OUString szCurrentProfileString( RTL_CONSTASCII_USTRINGPARAM( "CurrentProfile" ));
+static ::rtl::OUString szDirectoryString( RTL_CONSTASCII_USTRINGPARAM( "directory" ));
+
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 1024
+#endif
+#include <MNSFolders.hxx>
+#include <MNSINIParser.hxx>
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ ProfileStruct::ProfileStruct(MozillaProductType aProduct,::rtl::OUString aProfileName,
+#ifdef MINIMAL_PROFILEDISCOVER
+ const ::rtl::OUString& aProfilePath
+#else
+ nsILocalFile * aProfilePath
+#endif
+ )
+ {
+ product=aProduct;
+ profileName = aProfileName;
+ profilePath = aProfilePath;
+ }
+ ::rtl::OUString ProfileStruct::getProfilePath()
+ {
+#ifdef MINIMAL_PROFILEDISCOVER
+ return profilePath;
+#else
+ if (profilePath)
+ {
+ nsAutoString path;
+ nsresult rv = profilePath->GetPath(path);
+ NS_ENSURE_SUCCESS(rv, ::rtl::OUString());
+ // PRUnichar != sal_Unicode in mingw
+ return ::rtl::OUString(reinterpret_cast_mingw_only<const sal_Unicode *>(path.get()));
+ }
+ else
+ return ::rtl::OUString();
+#endif
+ }
+
+ ProfileAccess::~ProfileAccess()
+ {
+ }
+ ProfileAccess::ProfileAccess()
+ {
+ LoadProductsInfo();
+ }
+
+ sal_Int32 ProfileAccess::LoadProductsInfo()
+ {
+ //load SeaMonkey 2 profiles to m_ProductProfileList
+ sal_Int32 count = LoadXPToolkitProfiles(MozillaProductType_Mozilla);
+
+ //load thunderbird profiles to m_ProductProfileList
+ count += LoadXPToolkitProfiles(MozillaProductType_Thunderbird);
+
+ //load firefox profiles to m_ProductProfileList
+ //firefox profile does not containt address book, but maybe others need them
+ count += LoadXPToolkitProfiles(MozillaProductType_Firefox);
+ return count;
+ }
+ //Thunderbird and firefox profiles are saved in profiles.ini
+ sal_Int32 ProfileAccess::LoadXPToolkitProfiles(MozillaProductType product)
+ {
+ sal_Int32 index=product;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+
+#ifndef MINIMAL_PROFILEDISCOVER
+ nsresult rv;
+#endif
+ ::rtl::OUString regDir = getRegistryDir(product);
+ ::rtl::OUString profilesIni( regDir );
+ profilesIni += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("profiles.ini"));
+ IniParser parser( profilesIni );
+ IniSectionMap &mAllSection = *(parser.getAllSection());
+
+ IniSectionMap::iterator iBegin = mAllSection.begin();
+ IniSectionMap::iterator iEnd = mAllSection.end();
+ for(;iBegin != iEnd;++iBegin)
+ {
+ ini_Section *aSection = &(*iBegin).second;
+ ::rtl::OUString profileName;
+ ::rtl::OUString profilePath;
+ ::rtl::OUString sIsRelative;
+ ::rtl::OUString sIsDefault;
+
+ for(NameValueList::iterator itor=aSection->lList.begin();
+ itor != aSection->lList.end();
+ ++itor)
+ {
+ struct ini_NameValue * aValue = &(*itor);
+ if (aValue->sName.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"))))
+ {
+ profileName = aValue->sValue;
+ }
+ else if (aValue->sName.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsRelative"))))
+ {
+ sIsRelative = aValue->sValue;
+ }
+ else if (aValue->sName.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Path"))))
+ {
+ profilePath = aValue->sValue;
+ }
+ else if (aValue->sName.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Default"))))
+ {
+ sIsDefault = aValue->sValue;
+ }
+ }
+ if (profileName.getLength() != 0 || profilePath.getLength() != 0)
+ {
+#ifndef MINIMAL_PROFILEDISCOVER
+ sal_Int32 isRelative = 0;
+ if (sIsRelative.getLength() != 0)
+ {
+ isRelative = sIsRelative.toInt32();
+ }
+
+ nsCOMPtr<nsILocalFile> rootDir;
+ rv = NS_NewLocalFile(EmptyString(), PR_TRUE,
+ getter_AddRefs(rootDir));
+ if (NS_FAILED(rv)) continue;
+
+ OString sPath = OUStringToOString(profilePath, RTL_TEXTENCODING_UTF8);
+ nsCAutoString filePath(sPath.getStr());
+
+ if (isRelative) {
+ // PRUnichar != sal_Unicode in mingw
+ nsAutoString registryDir( reinterpret_cast_mingw_only<const PRUnichar *>(regDir.getStr()) );
+ nsCOMPtr<nsILocalFile> mAppData;
+ rv = NS_NewLocalFile(registryDir, PR_TRUE,
+ getter_AddRefs(mAppData));
+ if (NS_FAILED(rv)) continue;
+ rv = rootDir->SetRelativeDescriptor(mAppData, filePath);
+ } else {
+ rv = rootDir->SetPersistentDescriptor(filePath);
+ }
+ if (NS_FAILED(rv)) continue;
+#endif
+
+ ProfileStruct* profileItem = new ProfileStruct(product,profileName,
+#ifdef MINIMAL_PROFILEDISCOVER
+ regDir + profilePath
+#else
+ rootDir
+#endif
+ );
+ m_Product.mProfileList[profileName] = profileItem;
+
+ sal_Int32 isDefault = 0;
+ if (sIsDefault.getLength() != 0)
+ {
+ isDefault = sIsDefault.toInt32();
+ }
+ if (isDefault)
+ m_Product.mCurrentProfileName = profileName;
+
+ }
+
+ }
+ return static_cast< ::sal_Int32 >(m_Product.mProfileList.size());
+ }
+
+ ::rtl::OUString ProfileAccess::getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ sal_Int32 index=product;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+ if (!m_Product.mProfileList.size() || m_Product.mProfileList.find(profileName) == m_Product.mProfileList.end())
+ {
+ //Profile not found
+ return ::rtl::OUString();
+ }
+ else
+ return m_Product.mProfileList[profileName]->getProfilePath();
+ }
+
+ ::sal_Int32 ProfileAccess::getProfileCount( ::com::sun::star::mozilla::MozillaProductType product) throw (::com::sun::star::uno::RuntimeException)
+ {
+ sal_Int32 index=product;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+ return static_cast< ::sal_Int32 >(m_Product.mProfileList.size());
+ }
+ ::sal_Int32 ProfileAccess::getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< ::rtl::OUString >& list ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ sal_Int32 index=product;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+ list.realloc(static_cast<sal_Int32>(m_Product.mProfileList.size()));
+ sal_Int32 i=0;
+ for(ProfileList::iterator itor=m_Product.mProfileList.begin();
+ itor != m_Product.mProfileList.end();
+ itor++)
+ {
+ ProfileStruct * aProfile = (*itor).second;
+ list[i] = aProfile->getProfileName();
+ i++;
+ }
+
+ return static_cast< ::sal_Int32 >(m_Product.mProfileList.size());
+ }
+
+ ::rtl::OUString ProfileAccess::getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ sal_Int32 index=product;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+ if (m_Product.mCurrentProfileName.getLength() != 0)
+ {
+ //default profile setted in mozilla registry
+ return m_Product.mCurrentProfileName;
+ }
+ if (m_Product.mProfileList.size() == 0)
+ {
+ //there are not any profiles
+ return ::rtl::OUString();
+ }
+ ProfileStruct * aProfile = (*m_Product.mProfileList.begin()).second;
+ return aProfile->getProfileName();
+ }
+#ifndef MINIMAL_PROFILEDISCOVER
+ nsresult ProfileAccess::isExistFileOrSymlink(nsILocalFile* aFile,PRBool *bExist)
+ {
+ nsresult rv;
+ nsAutoString path;
+ aFile->GetPath(path);
+ rv = aFile->Exists(bExist);
+ NS_ENSURE_SUCCESS(rv, rv);
+ if (!*bExist)
+ {
+ rv = aFile->IsSymlink(bExist);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+ return rv;
+ }
+ nsresult ProfileAccess::isLockExist(nsILocalFile* aFile)
+ {
+#if defined (XP_MACOSX)
+ NS_NAMED_LITERAL_STRING(LOCKFILE_NAME, ".parentlock");
+ NS_NAMED_LITERAL_STRING(OLD_LOCKFILE_NAME, "parent.lock");
+#elif defined (XP_UNIX)
+ NS_ConvertASCIItoUTF16 OLD_LOCKFILE_NAME("lock");
+ NS_ConvertASCIItoUTF16 LOCKFILE_NAME(".parentlock");
+#else
+ NS_NAMED_LITERAL_STRING(OLD_LOCKFILE_NAME, "parent.lock");
+ NS_NAMED_LITERAL_STRING(LOCKFILE_NAME, "parent.lock");
+#endif
+
+ nsresult rv;
+
+ PRBool isDir;
+ rv = aFile->IsDirectory(&isDir);
+ NS_ENSURE_SUCCESS(rv, rv);
+ if (!isDir)
+ return NS_ERROR_FILE_NOT_DIRECTORY;
+
+ nsCOMPtr<nsILocalFile> lockFile;
+ rv = aFile->Clone((nsIFile **)((void **)getter_AddRefs(lockFile)));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ rv = lockFile->Append(LOCKFILE_NAME);
+ NS_ENSURE_SUCCESS(rv, rv);
+ PRBool nExist=PR_FALSE;
+ rv = isExistFileOrSymlink(lockFile,&nExist);
+ NS_ENSURE_SUCCESS(rv, rv);
+ if (!nExist) // Check OLD_LOCKFILE_NAME
+ {
+ nsCOMPtr<nsILocalFile> oldlockFile;
+ rv = aFile->Clone((nsIFile **)((void **)getter_AddRefs(oldlockFile)));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ rv = oldlockFile->Append(OLD_LOCKFILE_NAME);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = isExistFileOrSymlink(oldlockFile,&nExist);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+ return nExist;
+ }
+
+#endif
+ ::sal_Bool ProfileAccess::isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+ {
+#ifdef MINIMAL_PROFILEDISCOVER
+ (void)product; /* avoid warning about unused parameter */
+ (void)profileName; /* avoid warning about unused parameter */
+ return sal_True;
+#else
+ ::rtl::OUString path = getProfilePath(product,profileName);
+ if (!path.getLength())
+ return sal_True;
+
+ // PRUnichar != sal_Unicode in mingw
+ nsAutoString filePath(reinterpret_cast_mingw_only<const PRUnichar *>(path.getStr()));
+
+ nsresult rv;
+ nsCOMPtr<nsILocalFile> localFile;
+ rv = NS_NewLocalFile(filePath, PR_TRUE,
+ getter_AddRefs(localFile));
+ NS_ENSURE_SUCCESS(rv,sal_True);
+
+ PRBool exists = PR_FALSE;
+ rv = localFile->Exists(&exists);
+ NS_ENSURE_SUCCESS(rv, sal_True);
+ if (!exists)
+ return sal_True;
+
+ // If the profile is locked, we return true
+ rv = isLockExist(localFile);
+ if (rv)
+ return sal_True;
+ return sal_False;
+#endif
+ }
+
+ ::sal_Bool ProfileAccess::getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ sal_Int32 index=product;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+ if (!m_Product.mProfileList.size() || m_Product.mProfileList.find(profileName) == m_Product.mProfileList.end())
+ {
+ return sal_False;
+ }
+ else
+ return sal_True;
+ }
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx
new file mode 100644
index 000000000000..5cc807fceb11
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx
@@ -0,0 +1,131 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __MNSProfileDiscover_h___
+#define __MNSProfileDiscover_h___
+
+#ifndef MINIMAL_PROFILEDISCOVER
+#include "mozilla_profile_discover.h"
+#endif
+
+#include <sal/types.h>
+#include <osl/diagnose.h>
+#include <osl/conditn.hxx>
+#include <com/sun/star/mozilla/MozillaProductType.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <rtl/ustring.hxx>
+
+#include <vector>
+#include <map>
+
+#ifdef XP_OS2
+#define INCL_DOSERRORS
+#define INCL_DOSFILEMGR
+#include <os2.h>
+#endif
+
+using namespace com::sun::star::mozilla;
+namespace connectivity
+{
+ namespace mozab
+ {
+ class ProfileStruct;
+ }
+}
+typedef ::std::map < ::rtl::OUString, ::connectivity::mozab::ProfileStruct* > ProfileList;
+namespace connectivity
+{
+ namespace mozab
+ {
+ class ProfileStruct
+ {
+ public:
+ ProfileStruct(MozillaProductType aProduct,::rtl::OUString aProfileName,
+#ifdef MINIMAL_PROFILEDISCOVER
+ const ::rtl::OUString &aProfilePath
+#else
+ nsILocalFile * aProfilePath
+#endif
+ );
+ MozillaProductType getProductType() { return product;}
+ ::rtl::OUString getProfileName(){ return profileName;}
+ ::rtl::OUString getProfilePath() ;
+#ifndef MINIMAL_PROFILEDISCOVER
+ nsILocalFile *getProfileLocal(){ return profilePath;}
+#endif
+ protected:
+ MozillaProductType product;
+ ::rtl::OUString profileName;
+#ifdef MINIMAL_PROFILEDISCOVER
+ ::rtl::OUString profilePath;
+#else
+ nsCOMPtr<nsILocalFile> profilePath;
+#endif
+ };
+
+ class ProductStruct
+ {
+ public:
+ void setCurrentProfile(::rtl::OUString aProfileName){mCurrentProfileName = aProfileName;}
+
+ ::rtl::OUString mCurrentProfileName;
+
+ ProfileList mProfileList;
+ };
+
+ //Used to query profiles information
+ class ProfileAccess
+ {
+ public:
+
+ virtual ~ProfileAccess();
+ ProfileAccess();
+ ::rtl::OUString getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+ ::sal_Int32 getProfileCount( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException);
+ ::sal_Int32 getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< ::rtl::OUString >& list ) throw (::com::sun::star::uno::RuntimeException);
+ ::rtl::OUString getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException);
+ ::sal_Bool SAL_CALL isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+ ::sal_Bool SAL_CALL getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+ protected:
+ ProductStruct m_ProductProfileList[4];
+ sal_Int32 LoadProductsInfo();
+ sal_Int32 LoadXPToolkitProfiles(MozillaProductType product);
+#ifndef MINIMAL_PROFILEDISCOVER
+ //used by isProfileLocked
+ nsresult isExistFileOrSymlink(nsILocalFile* aFile,PRBool *bExist);
+ nsresult isLockExist(nsILocalFile* aFile);
+#endif
+ };
+
+ }
+}
+
+#endif // __MNSProfileDiscover_h___
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.cxx
new file mode 100644
index 000000000000..84684056f557
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.cxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MNSProfileManager.hxx"
+#include "MNSProfile.hxx"
+
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 1024
+#endif
+#include <MNSFolders.hxx>
+#include <MNSINIParser.hxx>
+
+static ::sal_Int32 nInitCounter=0;
+namespace connectivity
+{
+ namespace mozab
+ {
+
+ ProfileManager::~ProfileManager()
+ {
+ }
+ ProfileManager::ProfileManager()
+ :m_CurrentProduct(MozillaProductType_Mozilla)
+ ,aProfile(NULL)
+ {
+ }
+ ::sal_Int32 ProfileManager::bootupProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ if (!aProfile)
+ {
+ aProfile=new nsProfile();
+ aProfile->StartupWithArgs(NULL,sal_False);
+ }
+
+ setCurrentProfile(product,profileName);
+ return ++nInitCounter;
+ }
+ ::sal_Int32 ProfileManager::shutdownProfile( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ return --nInitCounter;
+ }
+ ::com::sun::star::mozilla::MozillaProductType ProfileManager::getCurrentProduct( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ return m_CurrentProduct;
+ }
+ ::rtl::OUString ProfileManager::getCurrentProfile( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ nsresult rv;
+ nsCOMPtr<nsIProfile> theProfile(do_GetService(NS_PROFILE_CONTRACTID,&rv));
+ if (NS_FAILED(rv)) return ::rtl::OUString();
+ nsXPIDLString currentProfileStr;
+ //call GetCurrentProfile before call SetCurrentProfile will get the default profile
+ rv = theProfile->GetCurrentProfile(getter_Copies(currentProfileStr));
+ if (NS_FAILED(rv) || currentProfileStr.get() == nsnull)
+ return ::rtl::OUString();
+ // PRUnichar != sal_Unicode in mingw
+ return ::rtl::OUString(reinterpret_cast_mingw_only<const sal_Unicode *>(currentProfileStr.get()));
+ }
+ ::rtl::OUString ProfileManager::setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ ::rtl::OUString currentProfile = getCurrentProfile();
+ //if profileName not given, then skip and return curernt profile
+ if (!profileName.getLength() && m_CurrentProduct == product)
+ return currentProfile;
+
+ if (m_CurrentProduct == product && profileName.equals(currentProfile))
+ return currentProfile;
+ //set current product
+ m_CurrentProduct = product;
+
+ //get profile mozilla profile service
+ nsresult rv;
+ nsCOMPtr<nsIProfile> theProfile(do_GetService(NS_PROFILE_CONTRACTID,&rv));
+ if (NS_FAILED(rv)) return ::rtl::OUString();
+
+ // PRUnichar != sal_Unicode in mingw
+ const PRUnichar* pUsedProfile = reinterpret_cast_mingw_only<const PRUnichar *>(profileName.getStr());
+ //set current profile
+ rv = theProfile->SetCurrentProfile( pUsedProfile );
+ if (NS_FAILED(rv)) return ::rtl::OUString();
+ return currentProfile;
+ }
+
+
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.hxx
new file mode 100644
index 000000000000..6e52c40b8f71
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.hxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __MNSProfileManager_h___
+#define __MNSProfileManager_h___
+
+#include "mozilla_profilemanager.h"
+
+#include <sal/types.h>
+#include <osl/diagnose.h>
+#include <osl/conditn.hxx>
+#include <com/sun/star/mozilla/MozillaProductType.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <rtl/ustring.hxx>
+#include <vector>
+#include <map>
+
+#ifdef XP_OS2
+#define INCL_DOSERRORS
+#define INCL_DOSFILEMGR
+#include <os2.h>
+#endif
+
+using namespace com::sun::star::mozilla;
+class nsProfile;
+namespace connectivity
+{
+ namespace mozab
+ {
+ class ProfileManager
+ {
+ public:
+
+ virtual ~ProfileManager();
+ ProfileManager();
+
+ ::sal_Int32 SAL_CALL bootupProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException) ;
+ ::sal_Int32 SAL_CALL shutdownProfile( ) throw (::com::sun::star::uno::RuntimeException) ;
+ ::com::sun::star::mozilla::MozillaProductType SAL_CALL getCurrentProduct( ) throw (::com::sun::star::uno::RuntimeException) ;
+ ::rtl::OUString SAL_CALL getCurrentProfile( ) throw (::com::sun::star::uno::RuntimeException) ;
+ ::rtl::OUString SAL_CALL setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException) ;
+
+ protected:
+ ::com::sun::star::mozilla::MozillaProductType m_CurrentProduct;
+ nsProfile *aProfile;
+ };
+
+ }
+}
+
+#endif // __MNSProfileManager_h___
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.cxx
new file mode 100644
index 000000000000..c950e4d0e7e0
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.cxx
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "MNSRunnable.hxx"
+#include "MDatabaseMetaDataHelper.hxx"
+#include "MQuery.hxx"
+#include <osl/mutex.hxx>
+#include <osl/conditn.hxx>
+
+#include "pre_include_mozilla.h"
+#include <nsIProxyObjectManager.h>
+// More Mozilla includes for LDAP Connection Test
+#include "prprf.h"
+#include "nsILDAPURL.h"
+#include "nsILDAPMessage.h"
+#include "nsILDAPMessageListener.h"
+#include "nsILDAPErrors.h"
+#include "nsILDAPConnection.h"
+#include "nsILDAPOperation.h"
+#include "post_include_mozilla.h"
+
+using namespace connectivity::mozab;
+
+/* Implementation file */
+NS_IMPL_ISUPPORTS1(MNSRunnable, nsIRunnable)
+
+static ::osl::Mutex m_aThreadMutex;
+
+nsIRunnable * MNSRunnable::ProxiedObject()
+{
+ if (!_ProxiedObject)
+ {
+
+ nsresult rv = NS_GetProxyForObject(NS_UI_THREAD_EVENTQ,
+ NS_GET_IID(nsIRunnable),
+ this,
+ PROXY_SYNC,
+ (void**)&_ProxiedObject);
+ (void)rv;
+
+ _ProxiedObject->AddRef();
+ }
+ return _ProxiedObject;
+}
+
+MNSRunnable::MNSRunnable()
+{
+ NS_INIT_ISUPPORTS();
+ _ProxiedObject=NULL;
+#if OSL_DEBUG_LEVEL > 0
+ m_oThreadID = osl_getThreadIdentifier(NULL);
+#endif
+ AddRef();
+}
+
+MNSRunnable::~MNSRunnable()
+{
+}
+sal_Int32 MNSRunnable::StartProxy(const ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XCodeProxy >& aCode)
+{
+ OSL_TRACE( "IN : MNSRunnable::StartProxy() \n" );
+ ::osl::MutexGuard aGuard(m_aThreadMutex);
+ xCode = aCode;
+ return ProxiedObject()->Run();
+}
+
+
+NS_IMETHODIMP MNSRunnable::Run()
+{
+ return static_cast<nsresult>(xCode->run());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.hxx
new file mode 100644
index 000000000000..2f17ea53f556
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MAB_MOZAB_RUNNABLE_HXX_
+#define _CONNECTIVITY_MAB_MOZAB_RUNNABLE_HXX_
+#include "MNSDeclares.hxx"
+#include <osl/thread.hxx>
+
+#include <MNSInclude.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/mozilla/XCodeProxy.hpp>
+
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::mozilla;
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ class MNSRunnable : public nsIRunnable
+ {
+ public:
+ nsIRunnable * ProxiedObject();
+ MNSRunnable();
+ virtual ~MNSRunnable();
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIRUNNABLE
+
+ public:
+ sal_Int32 StartProxy(const ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XCodeProxy >& aCode); //Call this to start proxy
+
+ private:
+ nsIRunnable* _ProxiedObject;
+ Reference<XCodeProxy> xCode;
+#if OSL_DEBUG_LEVEL > 0
+ oslThreadIdentifier m_oThreadID;
+#endif
+ };
+ }
+}
+#endif //_CONNECTIVITY_MAB_MOZABHELPER_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/makefile.mk b/connectivity/source/drivers/mozab/bootstrap/makefile.mk
new file mode 100644
index 000000000000..6a4172da205d
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/makefile.mk
@@ -0,0 +1,93 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+CALL_CDECL=TRUE
+
+PRJ=..$/..$/..$/..
+PRJINC=..$/..$/..
+PRJNAME=connectivity
+TARGET=mozbootstrap
+
+.IF "$(OS)" == "OS2"
+all:
+ @echo " Not building under OS/2"
+.ENDIF
+
+# --- Settings ----------------------------------
+
+USE_DEFFILE=TRUE
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- begin of mozilla specific stuff
+MOZ_LIB=$(SOLARVERSION)$/$(INPATH)$/lib$(UPDMINOREXT)
+MOZ_INC=$(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT)$/mozilla
+# --- end of mozilla specific stuff
+
+.INCLUDE : settings.mk
+
+.INCLUDE : $(PRJ)$/version.mk
+
+.INCLUDE : ../makefile_mozab.mk
+
+INCPRE += -I../mozillasrc
+
+# --- Files -------------------------------------
+
+SLOFILES += \
+ $(SLO)$/MNSINIParser.obj \
+ $(SLO)$/MNSProfileDiscover.obj \
+ $(SLO)$/MMozillaBootstrap.obj \
+ $(SLO)$/MNSFolders.obj
+
+.IF ( "$(SYSTEM_MOZILLA)" == "YES" && "$(WITH_MOZILLA)" == "YES" ) || ( "$(WITH_MOZILLA)" == "NO" ) || ( "$(OS)" == "MACOSX" )
+CDEFS+=-DMINIMAL_PROFILEDISCOVER
+
+SHL1TARGET=$(TARGET)
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+SHL1OBJS=$(SLOFILES)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB) \
+ $(COMPHELPERLIB)
+
+.ELSE
+SLOFILES += \
+ $(SLO)$/MNSInit.obj \
+ $(SLO)$/MNSProfileManager.obj \
+ $(SLO)$/MNSRunnable.obj \
+ $(SLO)$/MNSProfile.obj \
+ $(SLO)$/MNSProfileDirServiceProvider.obj
+.ENDIF
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/connectivity/source/drivers/mozab/bootstrap/mozilla_nsinit.h b/connectivity/source/drivers/mozab/bootstrap/mozilla_nsinit.h
new file mode 100644
index 000000000000..f03d4a3bb208
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/mozilla_nsinit.h
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "pre_include_mozilla.h"
+#if defined __GNUC__
+ #pragma GCC system_header
+#endif
+
+#include "nsIServiceManager.h"
+#include "nsIEventQueueService.h"
+#include "nsIChromeRegistry.h"
+
+#include "nsIStringBundle.h"
+
+#include "nsIDirectoryService.h"
+#include "nsIProfile.h"
+#include "nsIProfileInternal.h"
+#include "nsIPref.h"
+#include "nsXPIDLString.h"
+
+#include "nsString.h"
+#if defined __SUNPRO_CC
+#pragma disable_warn
+ // somewhere in the files included directly or indirectly in nsString.h, warnings are enabled, again
+#endif
+#include "nsEmbedAPI.h"
+
+#include "nsDirectoryService.h"
+
+#include "post_include_mozilla.h"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofile.h b/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofile.h
new file mode 100644
index 000000000000..3d01a103c9e2
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofile.h
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "pre_include_mozilla.h"
+#if defined __GNUC__
+ #pragma GCC system_header
+#endif
+
+#include "nscore.h"
+#include "nsIPrefService.h"
+#include "nsIPrefBranch.h"
+
+#include "pratom.h"
+#include "prmem.h"
+#include "plstr.h"
+#include "prenv.h"
+
+#include "nsIFactory.h"
+#include "nsIComponentManager.h"
+#include "nsIEnumerator.h"
+#include "nsXPIDLString.h"
+#include "nsEscape.h"
+#include "nsIURL.h"
+
+#include "prprf.h"
+
+#include "nsIProfile.h"
+#include "nsIProfileInternal.h"
+#include "nsIProfileStartupListener.h"
+#include "nsIProfileChangeStatus.h"
+#include "nsCOMPtr.h"
+#include "nsISupports.h"
+#include "nsIRegistry.h"
+#include "nsString.h"
+#if defined __SUNPRO_CC
+#pragma disable_warn
+ // somewhere in the files included directly or indirectly in nsString.h, warnings are enabled, again
+#endif
+#include "nsIInterfaceRequestor.h"
+#include "nsIInterfaceRequestorUtils.h"
+#include "nsIDirectoryService.h"
+#include "nsIFactory.h"
+
+#include "nsIIOService.h"
+#include "nsNetUtil.h"
+#include "nsFileStream.h"
+#include "nsIStreamListener.h"
+#include "nsIServiceManager.h"
+#include "nsCOMPtr.h"
+#include "nsIModule.h"
+#include "nsIGenericFactory.h"
+#include "nsICategoryManager.h"
+#include "nsXPCOM.h"
+#include "nsISupportsPrimitives.h"
+#include "nsIDirectoryService.h"
+#include "nsDirectoryServiceDefs.h"
+#include "nsAppDirectoryServiceDefs.h"
+#include "nsIChromeRegistry.h" // chromeReg
+#include "nsIStringBundle.h"
+#include "nsIObserverService.h"
+#include "nsHashtable.h"
+#include "nsIAtom.h"
+#include "nsCRT.h"
+
+#include "post_include_mozilla.h"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofiledirserviceprovider.h b/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofiledirserviceprovider.h
new file mode 100644
index 000000000000..ec9bd9d63d74
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofiledirserviceprovider.h
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "pre_include_mozilla.h"
+#if defined __GNUC__
+ #pragma GCC system_header
+#endif
+
+#include "nsIDirectoryService.h"
+#include "nsILocalFile.h"
+#include "nsString.h"
+#if defined __SUNPRO_CC
+#pragma disable_warn
+ // somewhere in the files included directly or indirectly in nsString.h, warnings are enabled, again
+#endif
+
+#include "post_include_mozilla.h"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/mozilla_profile_discover.h b/connectivity/source/drivers/mozab/bootstrap/mozilla_profile_discover.h
new file mode 100644
index 000000000000..75913dcd525c
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/mozilla_profile_discover.h
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "pre_include_mozilla.h"
+#if defined __GNUC__
+ #pragma GCC system_header
+#endif
+
+#include "nsCOMPtr.h"
+#include "nsISupports.h"
+#include "nsString.h"
+#if defined __SUNPRO_CC
+#pragma disable_warn
+ // somewhere in the files included directly or indirectly in nsString.h, warnings are enabled, again
+#endif
+#include "nsIRegistry.h"
+#include "nsXPIDLString.h"
+#include "nsVoidArray.h"
+#include "nsIFile.h"
+#include "nsILocalFile.h"
+
+#include "post_include_mozilla.h"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/mozilla_profilemanager.h b/connectivity/source/drivers/mozab/bootstrap/mozilla_profilemanager.h
new file mode 100644
index 000000000000..4208eb6db606
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/mozilla_profilemanager.h
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "pre_include_mozilla.h"
+#if defined __GNUC__
+ #pragma GCC system_header
+#endif
+
+#include "nsCOMPtr.h"
+#include "nsISupports.h"
+#include "nsString.h"
+#if defined __SUNPRO_CC
+#pragma disable_warn
+ // somewhere in the files included directly or indirectly in nsString.h, warnings are enabled, again
+#endif
+#include "nsIRegistry.h"
+#include "nsXPIDLString.h"
+#include "nsVoidArray.h"
+#include "nsIFile.h"
+#include "nsILocalFile.h"
+
+#include "pratom.h"
+#include "prmem.h"
+#include "plstr.h"
+#include "prenv.h"
+
+#include "nsIEnumerator.h"
+#include "prprf.h"
+#include "nsCOMPtr.h"
+#include "nsIComponentManager.h"
+#include "nsEscape.h"
+#include "nsDirectoryServiceDefs.h"
+#include "nsAppDirectoryServiceDefs.h"
+#include "nsILocalFile.h"
+#include "nsReadableUtils.h"
+
+
+#if defined(XP_MAC) || defined(XP_MACOSX)
+#include <Processes.h>
+#include <CFBundle.h>
+#include "nsILocalFileMac.h"
+#endif
+
+#ifdef XP_UNIX
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <signal.h>
+#include "prnetdb.h"
+#include "prsystem.h"
+#endif
+
+#ifdef VMS
+#include <rmsdef.h>
+#endif
+
+#include "nsIPlatformCharset.h"
+#include <MNSInit.hxx>
+
+#include "post_include_mozilla.h"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/post_include_windows.h b/connectivity/source/drivers/mozab/bootstrap/post_include_windows.h
new file mode 100644
index 000000000000..b029a0e23638
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/post_include_windows.h
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifdef _MSC_VER
+ #pragma warning(pop)
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/pre_include_windows.h b/connectivity/source/drivers/mozab/bootstrap/pre_include_windows.h
new file mode 100644
index 000000000000..15eeb5395195
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/pre_include_windows.h
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifdef _MSC_VER
+ #pragma warning(push,1)
+ #pragma warning(disable:4668 4917)
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */