bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / mozab / bootstrap / MMozillaBootstrap.cxx
blob460d6d1c6ab4b3cd602e3e8a14057f443cfe0435
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
21 #include <cppuhelper/factory.hxx>
22 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
23 #include <cppuhelper/supportsservice.hxx>
24 #include "MMozillaBootstrap.hxx"
25 #include "MNSFolders.hxx"
26 #include "MNSProfileDiscover.hxx"
28 using namespace com::sun::star::uno;
29 using namespace com::sun::star::lang;
30 using namespace com::sun::star::mozilla;
31 using namespace connectivity::mozab;
33 using ::com::sun::star::uno::Reference;
34 using ::com::sun::star::uno::Sequence;
35 using ::com::sun::star::lang::XSingleServiceFactory;
36 using ::com::sun::star::lang::XMultiServiceFactory;
38 static MozillaBootstrap *pMozillaBootstrap=nullptr;
39 static Reference<XMozillaBootstrap> xMozillaBootstrap;
40 extern "C" SAL_DLLPUBLIC_EXPORT void* OMozillaBootstrap_CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& )
42 if (!pMozillaBootstrap)
44 pMozillaBootstrap=new connectivity::mozab::MozillaBootstrap;
45 pMozillaBootstrap->Init();
46 xMozillaBootstrap = pMozillaBootstrap;
48 return pMozillaBootstrap;
51 MozillaBootstrap::MozillaBootstrap()
52 : OMozillaBootstrap_BASE(m_aMutex)
56 MozillaBootstrap::~MozillaBootstrap()
60 void MozillaBootstrap::Init()
62 m_ProfileAccess.reset(new ProfileAccess);
63 bootupProfile(css::mozilla::MozillaProductType_Mozilla,OUString());
66 void MozillaBootstrap::disposing()
68 ::osl::MutexGuard aGuard(m_aMutex);
69 OMozillaBootstrap_BASE::disposing();
72 OUString SAL_CALL MozillaBootstrap::getImplementationName( )
74 return OUString(MOZAB_MozillaBootstrap_IMPL_NAME);
77 sal_Bool SAL_CALL MozillaBootstrap::supportsService( const OUString& _rServiceName )
79 return cppu::supportsService(this, _rServiceName);
82 Sequence< OUString > SAL_CALL MozillaBootstrap::getSupportedServiceNames( )
84 // which service is supported
85 // for more information @see com.sun.star.mozilla.MozillaBootstrap
86 return { "com.sun.star.mozilla.MozillaBootstrap" };
90 // XProfileDiscover
91 ::sal_Int32 SAL_CALL MozillaBootstrap::getProfileCount( css::mozilla::MozillaProductType product)
93 return m_ProfileAccess->getProfileCount(product);
95 ::sal_Int32 SAL_CALL MozillaBootstrap::getProfileList( css::mozilla::MozillaProductType product, css::uno::Sequence< OUString >& list )
97 return m_ProfileAccess->getProfileList(product,list);
99 OUString SAL_CALL MozillaBootstrap::getDefaultProfile( css::mozilla::MozillaProductType product )
101 return m_ProfileAccess->getDefaultProfile(product);
103 OUString SAL_CALL MozillaBootstrap::getProfilePath( css::mozilla::MozillaProductType product, const OUString& profileName )
105 return m_ProfileAccess->getProfilePath(product,profileName);
107 sal_Bool SAL_CALL MozillaBootstrap::isProfileLocked( css::mozilla::MozillaProductType /*product*/, const OUString& /*profileName*/ )
109 return true;
111 sal_Bool SAL_CALL MozillaBootstrap::getProfileExists( css::mozilla::MozillaProductType product, const OUString& profileName )
113 return m_ProfileAccess->getProfileExists(product,profileName);
116 // XProfileManager
117 ::sal_Int32 SAL_CALL MozillaBootstrap::bootupProfile( css::mozilla::MozillaProductType, const OUString& )
119 return -1;
121 ::sal_Int32 SAL_CALL MozillaBootstrap::shutdownProfile( )
123 return -1;
125 css::mozilla::MozillaProductType SAL_CALL MozillaBootstrap::getCurrentProduct( )
127 return css::mozilla::MozillaProductType_Default;
129 OUString SAL_CALL MozillaBootstrap::getCurrentProfile( )
131 return OUString();
133 sal_Bool SAL_CALL MozillaBootstrap::isCurrentProfileLocked( )
135 return true;
137 OUString SAL_CALL MozillaBootstrap::setCurrentProfile( css::mozilla::MozillaProductType, const OUString& )
139 return OUString();
142 // XProxyRunner
143 ::sal_Int32 SAL_CALL MozillaBootstrap::Run( const css::uno::Reference< css::mozilla::XCodeProxy >& )
145 return -1;
148 static Reference< XInterface > createInstance( const Reference< XMultiServiceFactory >& rServiceManager )
150 MozillaBootstrap * pBootstrap = static_cast<MozillaBootstrap*>(OMozillaBootstrap_CreateInstance(rServiceManager));
151 return *pBootstrap;
154 extern "C" SAL_DLLPUBLIC_EXPORT void* mozbootstrap_component_getFactory(
155 const sal_Char* pImplementationName,
156 void* pServiceManager,
157 void* /*pRegistryKey*/)
159 void* pRet = nullptr;
161 if (pServiceManager)
163 OUString aImplName( OUString::createFromAscii( pImplementationName ) );
164 Reference< XSingleServiceFactory > xFactory;
165 if ( aImplName == "com.sun.star.comp.mozilla.MozillaBootstrap" )
167 Sequence<OUString> aSNS { "com.sun.star.mozilla.MozillaBootstrap" };
169 xFactory = ::cppu::createSingleFactory(
170 static_cast< XMultiServiceFactory* > ( pServiceManager),
171 aImplName, createInstance, aSNS );
173 if ( xFactory.is() )
175 xFactory->acquire();
176 pRet = xFactory.get();
180 return pRet;
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */