1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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" };
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*/ )
111 sal_Bool SAL_CALL
MozillaBootstrap::getProfileExists( css::mozilla::MozillaProductType product
, const OUString
& profileName
)
113 return m_ProfileAccess
->getProfileExists(product
,profileName
);
117 ::sal_Int32 SAL_CALL
MozillaBootstrap::bootupProfile( css::mozilla::MozillaProductType
, const OUString
& )
121 ::sal_Int32 SAL_CALL
MozillaBootstrap::shutdownProfile( )
125 css::mozilla::MozillaProductType SAL_CALL
MozillaBootstrap::getCurrentProduct( )
127 return css::mozilla::MozillaProductType_Default
;
129 OUString SAL_CALL
MozillaBootstrap::getCurrentProfile( )
133 sal_Bool SAL_CALL
MozillaBootstrap::isCurrentProfileLocked( )
137 OUString SAL_CALL
MozillaBootstrap::setCurrentProfile( css::mozilla::MozillaProductType
, const OUString
& )
143 ::sal_Int32 SAL_CALL
MozillaBootstrap::Run( const css::uno::Reference
< css::mozilla::XCodeProxy
>& )
148 static Reference
< XInterface
> createInstance( const Reference
< XMultiServiceFactory
>& rServiceManager
)
150 MozillaBootstrap
* pBootstrap
= static_cast<MozillaBootstrap
*>(OMozillaBootstrap_CreateInstance(rServiceManager
));
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;
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
);
176 pRet
= xFactory
.get();
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */