diff options
Diffstat (limited to 'connectivity/source/drivers/mozab/bootstrap')
21 files changed, 9 insertions, 2267 deletions
diff --git a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx index a7586fbc47a0..8505d48cb8cf 100644 --- a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx +++ b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx @@ -18,20 +18,21 @@ */ #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <cppuhelper/factory.hxx> #include <cppuhelper/supportsservice.hxx> #include "MMozillaBootstrap.hxx" +#include "MNSFolders.hxx" +#include "MNSProfileDiscover.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" + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::lang::XSingleServiceFactory; +using ::com::sun::star::lang::XMultiServiceFactory; static MozillaBootstrap *pMozillaBootstrap=NULL; static Reference<XMozillaBootstrap> xMozillaBootstrap; @@ -61,14 +62,7 @@ void MozillaBootstrap::Init() { bool aProfileExists=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,OUString()); } @@ -143,85 +137,40 @@ sal_Bool SAL_CALL MozillaBootstrap::getProfileExists( ::com::sun::star::mozilla: // XProfileManager ::sal_Int32 SAL_CALL MozillaBootstrap::bootupProfile( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException, std::exception) { -#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, std::exception) { -#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, std::exception) { -#ifndef MINIMAL_PROFILEDISCOVER - return m_ProfileManager->getCurrentProduct(); -#else return ::com::sun::star::mozilla::MozillaProductType_Default; -#endif } OUString SAL_CALL MozillaBootstrap::getCurrentProfile( ) throw (::com::sun::star::uno::RuntimeException, std::exception) { -#ifndef MINIMAL_PROFILEDISCOVER - return m_ProfileManager->getCurrentProfile(); -#else return OUString(); -#endif } sal_Bool SAL_CALL MozillaBootstrap::isCurrentProfileLocked( ) throw (::com::sun::star::uno::RuntimeException, std::exception) { -#ifndef MINIMAL_PROFILEDISCOVER - return isProfileLocked(getCurrentProduct(),m_ProfileManager->getCurrentProfile()); -#else return true; -#endif } OUString SAL_CALL MozillaBootstrap::setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException, std::exception) { -#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 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, std::exception) { -#ifndef MINIMAL_PROFILEDISCOVER - OUString profileName = aCode->getProfileName(); - OUString currProfileName = getCurrentProfile(); - ::com::sun::star::mozilla::MozillaProductType currProduct = getCurrentProduct(); - - //if client provides a profileName, we will use it - if (!profileName.isEmpty() - && ( 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::lang::XSingleServiceFactory; -using ::com::sun::star::lang::XMultiServiceFactory; - static Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager ) { MozillaBootstrap * pBootstrap = static_cast<MozillaBootstrap*>(OMozillaBootstrap_CreateInstance(rServiceManager)); @@ -258,6 +207,5 @@ extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL mozbootstrap_component_getFactory return pRet; }; -#endif /* 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 index 0abfad7f8918..d9aae76d7fc4 100644 --- a/connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx +++ b/connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx @@ -26,12 +26,10 @@ #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> diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSInit.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSInit.cxx deleted file mode 100644 index d06aedc0d5ce..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSInit.cxx +++ /dev/null @@ -1,329 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "mozillasrc/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 "mozillasrc/MNSDeclares.hxx" -#include <osl/thread.hxx> -#include "mozillasrc/MNSTerminateListener.hxx" - -static nsIServiceManager* sServiceManager = nsnull; -static sal_Int32 sInitCounter = 0; -static bool s_bProfilePresentAfterInitialized = 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 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; -} - - -bool MNS_InitXPCOM(bool* aProfileExists) -{ - nsresult rv; - OSL_TRACE( "IN : MNS_InitXPCOM()" ); - // 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() - OUString path1("$BRAND_BASE_DIR/program"); - rtl::Bootstrap::expandMacros(path1); - 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 false; - } - - - - // Initialise XPCOM - NS_InitXPCOM2(&sServiceManager, binDir, NULL); - -// if (!sServiceManager) -// return 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 ) ? true : 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"); - thePref->ReadUserPrefs( nsnull ); - *aProfileExists = true; - s_bProfilePresentAfterInitialized = true; - } - OSL_TRACE( "OUT : MNS_InitXPCOM() - XPCOM Init" ); - - return true; -} - -void MNS_XPCOM_EventLoop() -{ - OSL_TRACE( "IN : MNS_XPCOM_EventLoop()" ); - 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 receive event - do - { - rv = eventQ->GetEvent(&event); - if (NS_FAILED(rv)) - return ; - if (event) - eventQ->HandleEvent(event); - }while ( PR_SUCCESS == PR_Sleep( PR_MillisecondsToInterval(20)) && aLive ); - - eventQ->ProcessPendingEvents(); - OSL_TRACE( "OUT : MNS_XPCOM_EventLoop()" ); -} - -extern "C" void MNS_Mozilla_UI_Thread( void *arg ) -{ - osl_setThreadName("MNS_Mozilla_UI_Thread"); - - aLive=1; - OSL_TRACE( "IN : MNS_Mozilla_UI_Thread()" ); - UI_Thread_ARGS * args = (UI_Thread_ARGS*) arg; - 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 interrupted - - 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()" ); - -} - - -bool MNS_Init(bool& aProfileExists) -{ - aProfileExists = false; - - OSL_TRACE( "IN : MNS_Init()" ); - // 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" ); - //wait for xpcom to be initted - m_aUI_Thread_Condition.wait(); - - OSL_TRACE( "OUT : MNS_Init() : counter = %d", sInitCounter ); - aProfileExists = s_bProfilePresentAfterInitialized; - return true; - } - - UI_Thread_ARGS * args = new UI_Thread_ARGS; - args->bProfileExists = &aProfileExists; - - m_aUI_Thread_Condition.reset(); - if (osl_createThread(MNS_Mozilla_UI_Thread, (void*)args) == 0) - { - return 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" ); - - return true; -} - -bool MNS_Term(bool aForce) -{ - // Reentrant calls to this method do nothing except decrement a counter - OSL_TRACE( "IN : MNS_Term()" ); - if (!aForce && sInitCounter > 1) - { - --sInitCounter; - OSL_TRACE( "OUT : MNS_Term() : counter = %d", sInitCounter ); - return 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" ); - return 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 deleted file mode 100644 index ca8a3344e4af..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSInit.hxx +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSINIT_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSINIT_HXX -#include "mozillasrc/MNSDeclares.hxx" - -#include <sal/types.h> - -bool MNS_Init(bool& aProfileExists); -bool MNS_Term(bool aForce = false); - -bool MNS_InitXPCOM(bool* aProfileExists); - -typedef struct UI_Thread_ARGS -{ - bool* bProfileExists; -} UI_Thread_ARGS; - -void MNS_XPCOM_EventLoop(); - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSINIT_HXX - -/* 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 deleted file mode 100644 index e6b66ae735db..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfile.cxx +++ /dev/null @@ -1,624 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#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 <comphelper/processfactory.hxx> -#include <com/sun/star/mozilla/XMozillaBootstrap.hpp> -#include <osl/diagnose.h> - -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::mozilla; - - -// 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("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< 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 - { - 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; - - // PRUnichar != sal_Unicode in mingw - 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())); - - nsresult 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 "pre_include_mozilla.h" -#include "nsIComponentManager.h" -#include "nsIComponentRegistrar.h" -#include "post_include_mozilla.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 deleted file mode 100644 index 7d9e5bdba2ea..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfile.hxx +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILE_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILE_HXX - -#include "mozilla_nsprofile.h" - - -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 a factory for Mozilla profile service, its CID and CONTRACTID are NS_PROFILE_CID and NS_PROFILE_CONTRACTID - //After that, we do not need profile.dll/libprofile.so any more. Our profile service is different from the original 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 can load both Thunderbird profile and Mozilla profile - static nsresult RegisterProfileManager(nsIProfile* aProfileService); - -}; - -extern nsresult ConvertStringToUnicode(nsCString& aCharset, const char* inString, nsAString& outString); -extern nsresult GetPlatformCharset(nsCString& aCharset); - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILE_HXX - -/* 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 deleted file mode 100644 index 1b251e0f9aa7..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.cxx +++ /dev/null @@ -1,232 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#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 *persistent, nsIFile **_retval) -{ - NS_ENSURE_ARG(prop); - NS_ENSURE_ARG_POINTER(persistent); - NS_ENSURE_ARG_POINTER(_retval); - - if (!mProfileDir) - return NS_ERROR_FAILURE; - - *persistent = 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 deleted file mode 100644 index 1dc526b515bf..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.hxx +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILEDIRSERVICEPROVIDER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILEDIRSERVICEPROVIDER_HXX - -#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); - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILEDIRSERVICEPROVIDER_HXX - -/* 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 index df2012e39c5a..3e68f1321170 100644 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx +++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx @@ -19,65 +19,6 @@ #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 "pre_include_mozilla.h" -#include "nsICharsetConverterManager.h" -#include "nsIPlatformCharset.h" -#include "post_include_mozilla.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 - #include "MNSFolders.hxx" #include "MNSINIParser.hxx" @@ -86,11 +27,7 @@ namespace connectivity namespace mozab { ProfileStruct::ProfileStruct(MozillaProductType aProduct, const OUString& aProfileName, -#ifdef MINIMAL_PROFILEDISCOVER const OUString& aProfilePath -#else - nsILocalFile * aProfilePath -#endif ) { product=aProduct; @@ -99,20 +36,7 @@ namespace connectivity } OUString ProfileStruct::getProfilePath() { -#ifdef MINIMAL_PROFILEDISCOVER return profilePath; -#else - if (profilePath) - { - nsAutoString path; - nsresult rv = profilePath->GetPath(path); - NS_ENSURE_SUCCESS(rv, OUString()); - // PRUnichar != sal_Unicode in mingw - return OUString(reinterpret_cast_mingw_only<const sal_Unicode *>(path.get())); - } - else - return OUString(); -#endif } ProfileAccess::~ProfileAccess() @@ -143,9 +67,6 @@ namespace connectivity sal_Int32 index=product; ProductStruct &m_Product = m_ProductProfileList[index]; -#ifndef MINIMAL_PROFILEDISCOVER - nsresult rv; -#endif OUString regDir = getRegistryDir(product); OUString profilesIni = regDir + "profiles.ini"; IniParser parser( profilesIni ); @@ -191,28 +112,6 @@ namespace connectivity isRelative = sIsRelative.toInt32(); } -#ifndef MINIMAL_PROFILEDISCOVER - 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; -#else OUString fullProfilePath; if(isRelative) { @@ -222,14 +121,9 @@ namespace connectivity { fullProfilePath = profilePath; } -#endif ProfileStruct* profileItem = new ProfileStruct(product,profileName, -#ifdef MINIMAL_PROFILEDISCOVER fullProfilePath -#else - rootDir -#endif ); m_Product.mProfileList[profileName] = profileItem; @@ -301,98 +195,11 @@ namespace connectivity 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 bool ProfileAccess::isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const 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 true; -#else - OUString path = getProfilePath(product,profileName); - if (path.isEmpty()) - 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 } bool ProfileAccess::getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException) diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx index 6883c5615acf..3f9ad6980268 100644 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx +++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx @@ -20,10 +20,6 @@ #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILEDISCOVER_HXX #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILEDISCOVER_HXX -#ifndef MINIMAL_PROFILEDISCOVER -#include "mozilla_profile_discover.h" -#endif - #include <sal/types.h> #include <osl/diagnose.h> #include <osl/conditn.hxx> @@ -52,25 +48,13 @@ namespace connectivity { public: ProfileStruct(MozillaProductType aProduct, const OUString& aProfileName, -#ifdef MINIMAL_PROFILEDISCOVER - const OUString &aProfilePath -#else - nsILocalFile * aProfilePath -#endif - ); + const OUString &aProfilePath); OUString getProfileName(){ return profileName;} OUString getProfilePath() ; -#ifndef MINIMAL_PROFILEDISCOVER - nsILocalFile *getProfileLocal(){ return profilePath;} -#endif protected: MozillaProductType product; OUString profileName; -#ifdef MINIMAL_PROFILEDISCOVER OUString profilePath; -#else - nsCOMPtr<nsILocalFile> profilePath; -#endif }; class ProductStruct @@ -97,11 +81,6 @@ namespace connectivity 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 }; } diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.cxx deleted file mode 100644 index 5480699abb50..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.cxx +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#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 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; - } - 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 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 OUString(); - // PRUnichar != sal_Unicode in mingw - return OUString(reinterpret_cast_mingw_only<const sal_Unicode *>(currentProfileStr.get())); - } - OUString ProfileManager::setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException) - { - OUString currentProfile = getCurrentProfile(); - //if profileName not given, then skip and return current profile - if (profileName.isEmpty() && 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 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 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 deleted file mode 100644 index c102805baf9d..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.hxx +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILEMANAGER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILEMANAGER_HXX - -#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> - -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 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) ; - OUString SAL_CALL getCurrentProfile( ) throw (::com::sun::star::uno::RuntimeException) ; - OUString SAL_CALL setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException) ; - - protected: - ::com::sun::star::mozilla::MozillaProductType m_CurrentProduct; - nsProfile *aProfile; - }; - - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILEMANAGER_HXX - -/* 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 deleted file mode 100644 index f53f422ee841..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.cxx +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "MNSRunnable.hxx" -#include "mozillasrc/MDatabaseMetaDataHelper.hxx" -#include "mozillasrc/MQuery.hxx" -#include <osl/mutex.hxx> -#include <osl/conditn.hxx> -#include <osl/thread.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::Thread::getCurrentIdentifier(); -#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()" ); - ::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 deleted file mode 100644 index 88f6f102a225..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.hxx +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSRUNNABLE_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSRUNNABLE_HXX - -#include "mozillasrc/MNSDeclares.hxx" -#include <osl/thread.hxx> - -#include "mozillasrc/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 // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSRUNNABLE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/mozilla_nsinit.h b/connectivity/source/drivers/mozab/bootstrap/mozilla_nsinit.h deleted file mode 100644 index 0311aa830e73..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/mozilla_nsinit.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "pre_include_mozilla.h" - -#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" - -#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 deleted file mode 100644 index 6cf4e4d9f395..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofile.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "pre_include_mozilla.h" - -#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" -#include "nsIInterfaceRequestor.h" -#include "nsIInterfaceRequestorUtils.h" -#include "nsIDirectoryService.h" - -#include "nsIIOService.h" -#include "nsNetUtil.h" -#include "nsFileStream.h" -#include "nsIStreamListener.h" -#include "nsIServiceManager.h" -#include "nsIModule.h" -#include "nsIGenericFactory.h" -#include "nsICategoryManager.h" -#include "nsXPCOM.h" -#include "nsISupportsPrimitives.h" -#include "nsDirectoryServiceDefs.h" -#include "nsAppDirectoryServiceDefs.h" -#include "nsIChromeRegistry.h" -#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 deleted file mode 100644 index 432ec63712a3..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofiledirserviceprovider.h +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "pre_include_mozilla.h" - -#include "nsIDirectoryService.h" -#include "nsILocalFile.h" -#include "nsString.h" - -#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 deleted file mode 100644 index 4bd051175087..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/mozilla_profile_discover.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "pre_include_mozilla.h" - -#include "nsCOMPtr.h" -#include "nsISupports.h" -#include "nsString.h" -#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 deleted file mode 100644 index ff0310422b9d..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/mozilla_profilemanager.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "pre_include_mozilla.h" - -#include "nsCOMPtr.h" -#include "nsISupports.h" -#include "nsString.h" -#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 "nsIComponentManager.h" -#include "nsEscape.h" -#include "nsDirectoryServiceDefs.h" -#include "nsAppDirectoryServiceDefs.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 deleted file mode 100644 index bd49753b7bd7..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/post_include_windows.h +++ /dev/null @@ -1,24 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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 deleted file mode 100644 index 7d68ce298f9e..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/pre_include_windows.h +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifdef _MSC_VER - #pragma warning(push,1) - #pragma warning(disable:4668 4917) -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |