1*6a653dafSJuergen Schmidt /**************************************************************
2*6a653dafSJuergen Schmidt  *
3*6a653dafSJuergen Schmidt  * Licensed to the Apache Software Foundation (ASF) under one
4*6a653dafSJuergen Schmidt  * or more contributor license agreements.  See the NOTICE file
5*6a653dafSJuergen Schmidt  * distributed with this work for additional information
6*6a653dafSJuergen Schmidt  * regarding copyright ownership.  The ASF licenses this file
7*6a653dafSJuergen Schmidt  * to you under the Apache License, Version 2.0 (the
8*6a653dafSJuergen Schmidt  * "License"); you may not use this file except in compliance
9*6a653dafSJuergen Schmidt  * with the License.  You may obtain a copy of the License at
10*6a653dafSJuergen Schmidt  *
11*6a653dafSJuergen Schmidt  *   http://www.apache.org/licenses/LICENSE-2.0
12*6a653dafSJuergen Schmidt  *
13*6a653dafSJuergen Schmidt  * Unless required by applicable law or agreed to in writing,
14*6a653dafSJuergen Schmidt  * software distributed under the License is distributed on an
15*6a653dafSJuergen Schmidt  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*6a653dafSJuergen Schmidt  * KIND, either express or implied.  See the License for the
17*6a653dafSJuergen Schmidt  * specific language governing permissions and limitations
18*6a653dafSJuergen Schmidt  * under the License.
19*6a653dafSJuergen Schmidt  *
20*6a653dafSJuergen Schmidt  *************************************************************/
21*6a653dafSJuergen Schmidt 
22*6a653dafSJuergen Schmidt // MARKER(update_precomp.py): autogen include statement, do not remove
23*6a653dafSJuergen Schmidt #include "precompiled_extensions.hxx"
24*6a653dafSJuergen Schmidt 
25*6a653dafSJuergen Schmidt #include "MMozillaBootstrap.hxx"
26*6a653dafSJuergen Schmidt 
27*6a653dafSJuergen Schmidt using namespace com::sun::star::uno;
28*6a653dafSJuergen Schmidt using namespace com::sun::star::lang;
29*6a653dafSJuergen Schmidt using namespace com::sun::star::mozilla;
30*6a653dafSJuergen Schmidt using namespace connectivity::mozab;
31*6a653dafSJuergen Schmidt #include <MNSFolders.hxx>
32*6a653dafSJuergen Schmidt #include "MNSProfileDiscover.hxx"
33*6a653dafSJuergen Schmidt 
34*6a653dafSJuergen Schmidt static MozillaBootstrap *pMozillaBootstrap=NULL;
35*6a653dafSJuergen Schmidt static Reference<XMozillaBootstrap> xMozillaBootstrap;
OMozillaBootstrap_CreateInstance(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & _rxFactory)36*6a653dafSJuergen Schmidt extern "C" SAL_DLLPUBLIC_EXPORT void*  SAL_CALL OMozillaBootstrap_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
37*6a653dafSJuergen Schmidt {
38*6a653dafSJuergen Schmidt     if (!pMozillaBootstrap)
39*6a653dafSJuergen Schmidt     {
40*6a653dafSJuergen Schmidt         pMozillaBootstrap=new connectivity::mozab::MozillaBootstrap( _rxFactory );
41*6a653dafSJuergen Schmidt         pMozillaBootstrap->Init();
42*6a653dafSJuergen Schmidt         xMozillaBootstrap = pMozillaBootstrap;
43*6a653dafSJuergen Schmidt     }
44*6a653dafSJuergen Schmidt     return  pMozillaBootstrap;
45*6a653dafSJuergen Schmidt }
46*6a653dafSJuergen Schmidt 
47*6a653dafSJuergen Schmidt // --------------------------------------------------------------------------------
48*6a653dafSJuergen Schmidt 
49*6a653dafSJuergen Schmidt 
50*6a653dafSJuergen Schmidt // --------------------------------------------------------------------------------
MozillaBootstrap(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & _rxFactory)51*6a653dafSJuergen Schmidt MozillaBootstrap::MozillaBootstrap(
52*6a653dafSJuergen Schmidt     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
53*6a653dafSJuergen Schmidt     : OMozillaBootstrap_BASE(m_aMutex), m_xMSFactory( _rxFactory )
54*6a653dafSJuergen Schmidt {
55*6a653dafSJuergen Schmidt }
56*6a653dafSJuergen Schmidt // -----------------------------------------------------------------------------
~MozillaBootstrap()57*6a653dafSJuergen Schmidt MozillaBootstrap::~MozillaBootstrap()
58*6a653dafSJuergen Schmidt {
59*6a653dafSJuergen Schmidt }
60*6a653dafSJuergen Schmidt // -----------------------------------------------------------------------------
Init()61*6a653dafSJuergen Schmidt void MozillaBootstrap::Init()
62*6a653dafSJuergen Schmidt {
63*6a653dafSJuergen Schmidt     sal_Bool aProfileExists=sal_False;
64*6a653dafSJuergen Schmidt 
65*6a653dafSJuergen Schmidt     (void)aProfileExists; /* avoid warning about unused parameter */
66*6a653dafSJuergen Schmidt 
67*6a653dafSJuergen Schmidt     m_ProfileAccess = new ProfileAccess();
68*6a653dafSJuergen Schmidt     bootupProfile(::com::sun::star::mozilla::MozillaProductType_Mozilla,rtl::OUString());
69*6a653dafSJuergen Schmidt }
70*6a653dafSJuergen Schmidt 
71*6a653dafSJuergen Schmidt // --------------------------------------------------------------------------------
disposing()72*6a653dafSJuergen Schmidt void MozillaBootstrap::disposing()
73*6a653dafSJuergen Schmidt {
74*6a653dafSJuergen Schmidt     ::osl::MutexGuard aGuard(m_aMutex);
75*6a653dafSJuergen Schmidt     OMozillaBootstrap_BASE::disposing();
76*6a653dafSJuergen Schmidt }
77*6a653dafSJuergen Schmidt 
78*6a653dafSJuergen Schmidt // static ServiceInfo
79*6a653dafSJuergen Schmidt //------------------------------------------------------------------------------
getImplementationName_Static()80*6a653dafSJuergen Schmidt rtl::OUString MozillaBootstrap::getImplementationName_Static(  ) throw(RuntimeException)
81*6a653dafSJuergen Schmidt {
82*6a653dafSJuergen Schmidt     return rtl::OUString::createFromAscii(MOZAB_MozillaBootstrap_IMPL_NAME);
83*6a653dafSJuergen Schmidt }
84*6a653dafSJuergen Schmidt //------------------------------------------------------------------------------
getSupportedServiceNames_Static()85*6a653dafSJuergen Schmidt Sequence< ::rtl::OUString > MozillaBootstrap::getSupportedServiceNames_Static(  ) throw (RuntimeException)
86*6a653dafSJuergen Schmidt {
87*6a653dafSJuergen Schmidt     // which service is supported
88*6a653dafSJuergen Schmidt     // for more information @see com.sun.star.mozilla.MozillaBootstrap
89*6a653dafSJuergen Schmidt     Sequence< ::rtl::OUString > aSNS( 1 );
90*6a653dafSJuergen Schmidt     aSNS[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap"));
91*6a653dafSJuergen Schmidt     return aSNS;
92*6a653dafSJuergen Schmidt }
93*6a653dafSJuergen Schmidt 
94*6a653dafSJuergen Schmidt //------------------------------------------------------------------
getImplementationName()95*6a653dafSJuergen Schmidt ::rtl::OUString SAL_CALL MozillaBootstrap::getImplementationName(  ) throw(RuntimeException)
96*6a653dafSJuergen Schmidt {
97*6a653dafSJuergen Schmidt     return getImplementationName_Static();
98*6a653dafSJuergen Schmidt }
99*6a653dafSJuergen Schmidt 
100*6a653dafSJuergen Schmidt //------------------------------------------------------------------
supportsService(const::rtl::OUString & _rServiceName)101*6a653dafSJuergen Schmidt sal_Bool SAL_CALL MozillaBootstrap::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
102*6a653dafSJuergen Schmidt {
103*6a653dafSJuergen Schmidt     Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
104*6a653dafSJuergen Schmidt     const ::rtl::OUString* pSupported = aSupported.getConstArray();
105*6a653dafSJuergen Schmidt     const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
106*6a653dafSJuergen Schmidt     for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
107*6a653dafSJuergen Schmidt         ;
108*6a653dafSJuergen Schmidt 
109*6a653dafSJuergen Schmidt     return pSupported != pEnd;
110*6a653dafSJuergen Schmidt }
111*6a653dafSJuergen Schmidt 
112*6a653dafSJuergen Schmidt //------------------------------------------------------------------
getSupportedServiceNames()113*6a653dafSJuergen Schmidt Sequence< ::rtl::OUString > SAL_CALL MozillaBootstrap::getSupportedServiceNames(  ) throw(RuntimeException)
114*6a653dafSJuergen Schmidt {
115*6a653dafSJuergen Schmidt     return getSupportedServiceNames_Static();
116*6a653dafSJuergen Schmidt }
117*6a653dafSJuergen Schmidt 
118*6a653dafSJuergen Schmidt 
119*6a653dafSJuergen Schmidt // XProfileDiscover
getProfileCount(::com::sun::star::mozilla::MozillaProductType product)120*6a653dafSJuergen Schmidt ::sal_Int32 SAL_CALL MozillaBootstrap::getProfileCount( ::com::sun::star::mozilla::MozillaProductType product) throw (::com::sun::star::uno::RuntimeException)
121*6a653dafSJuergen Schmidt {
122*6a653dafSJuergen Schmidt     return m_ProfileAccess->getProfileCount(product);
123*6a653dafSJuergen Schmidt }
getProfileList(::com::sun::star::mozilla::MozillaProductType product,::com::sun::star::uno::Sequence<::rtl::OUString> & list)124*6a653dafSJuergen Schmidt ::sal_Int32 SAL_CALL MozillaBootstrap::getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< ::rtl::OUString >& list ) throw (::com::sun::star::uno::RuntimeException)
125*6a653dafSJuergen Schmidt {
126*6a653dafSJuergen Schmidt     return m_ProfileAccess->getProfileList(product,list);
127*6a653dafSJuergen Schmidt }
getDefaultProfile(::com::sun::star::mozilla::MozillaProductType product)128*6a653dafSJuergen Schmidt ::rtl::OUString SAL_CALL MozillaBootstrap::getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException)
129*6a653dafSJuergen Schmidt {
130*6a653dafSJuergen Schmidt     return m_ProfileAccess->getDefaultProfile(product);
131*6a653dafSJuergen Schmidt }
getProfilePath(::com::sun::star::mozilla::MozillaProductType product,const::rtl::OUString & profileName)132*6a653dafSJuergen Schmidt ::rtl::OUString SAL_CALL MozillaBootstrap::getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
133*6a653dafSJuergen Schmidt {
134*6a653dafSJuergen Schmidt     return m_ProfileAccess->getProfilePath(product,profileName);
135*6a653dafSJuergen Schmidt }
isProfileLocked(::com::sun::star::mozilla::MozillaProductType product,const::rtl::OUString & profileName)136*6a653dafSJuergen Schmidt ::sal_Bool SAL_CALL MozillaBootstrap::isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
137*6a653dafSJuergen Schmidt {
138*6a653dafSJuergen Schmidt     return m_ProfileAccess->isProfileLocked(product,profileName);
139*6a653dafSJuergen Schmidt }
getProfileExists(::com::sun::star::mozilla::MozillaProductType product,const::rtl::OUString & profileName)140*6a653dafSJuergen Schmidt ::sal_Bool SAL_CALL MozillaBootstrap::getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
141*6a653dafSJuergen Schmidt {
142*6a653dafSJuergen Schmidt     return m_ProfileAccess->getProfileExists(product,profileName);
143*6a653dafSJuergen Schmidt }
144*6a653dafSJuergen Schmidt 
145*6a653dafSJuergen Schmidt // XProfileManager
bootupProfile(::com::sun::star::mozilla::MozillaProductType product,const::rtl::OUString & profileName)146*6a653dafSJuergen Schmidt ::sal_Int32 SAL_CALL MozillaBootstrap::bootupProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
147*6a653dafSJuergen Schmidt {
148*6a653dafSJuergen Schmidt     (void)product; /* avoid warning about unused parameter */
149*6a653dafSJuergen Schmidt     (void)profileName; /* avoid warning about unused parameter */
150*6a653dafSJuergen Schmidt         return -1;
151*6a653dafSJuergen Schmidt }
shutdownProfile()152*6a653dafSJuergen Schmidt ::sal_Int32 SAL_CALL MozillaBootstrap::shutdownProfile(  ) throw (::com::sun::star::uno::RuntimeException)
153*6a653dafSJuergen Schmidt {
154*6a653dafSJuergen Schmidt     return -1;
155*6a653dafSJuergen Schmidt }
getCurrentProduct()156*6a653dafSJuergen Schmidt ::com::sun::star::mozilla::MozillaProductType SAL_CALL MozillaBootstrap::getCurrentProduct(  ) throw (::com::sun::star::uno::RuntimeException)
157*6a653dafSJuergen Schmidt {
158*6a653dafSJuergen Schmidt     return ::com::sun::star::mozilla::MozillaProductType_Default;
159*6a653dafSJuergen Schmidt }
getCurrentProfile()160*6a653dafSJuergen Schmidt ::rtl::OUString SAL_CALL MozillaBootstrap::getCurrentProfile(  ) throw (::com::sun::star::uno::RuntimeException)
161*6a653dafSJuergen Schmidt {
162*6a653dafSJuergen Schmidt     return ::rtl::OUString();
163*6a653dafSJuergen Schmidt }
isCurrentProfileLocked()164*6a653dafSJuergen Schmidt ::sal_Bool SAL_CALL MozillaBootstrap::isCurrentProfileLocked(  ) throw (::com::sun::star::uno::RuntimeException)
165*6a653dafSJuergen Schmidt {
166*6a653dafSJuergen Schmidt     return true;
167*6a653dafSJuergen Schmidt }
setCurrentProfile(::com::sun::star::mozilla::MozillaProductType product,const::rtl::OUString & profileName)168*6a653dafSJuergen Schmidt ::rtl::OUString SAL_CALL MozillaBootstrap::setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
169*6a653dafSJuergen Schmidt {
170*6a653dafSJuergen Schmidt     (void)product; /* avoid warning about unused parameter */
171*6a653dafSJuergen Schmidt     (void)profileName; /* avoid warning about unused parameter */
172*6a653dafSJuergen Schmidt     return ::rtl::OUString();
173*6a653dafSJuergen Schmidt }
174*6a653dafSJuergen Schmidt 
175*6a653dafSJuergen Schmidt // XProxyRunner
Run(const::com::sun::star::uno::Reference<::com::sun::star::mozilla::XCodeProxy> & aCode)176*6a653dafSJuergen Schmidt ::sal_Int32 SAL_CALL MozillaBootstrap::Run( const ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XCodeProxy >& aCode ) throw (::com::sun::star::uno::RuntimeException)
177*6a653dafSJuergen Schmidt {
178*6a653dafSJuergen Schmidt     (void)aCode; /* avoid warning about unused parameter */
179*6a653dafSJuergen Schmidt     return -1;
180*6a653dafSJuergen Schmidt }
181*6a653dafSJuergen Schmidt 
182*6a653dafSJuergen Schmidt 
183*6a653dafSJuergen Schmidt #include <cppuhelper/factory.hxx>
184*6a653dafSJuergen Schmidt using ::com::sun::star::uno::Reference;
185*6a653dafSJuergen Schmidt using ::com::sun::star::uno::Sequence;
186*6a653dafSJuergen Schmidt using ::com::sun::star::lang::XSingleServiceFactory;
187*6a653dafSJuergen Schmidt using ::com::sun::star::lang::XMultiServiceFactory;
188*6a653dafSJuergen Schmidt 
189*6a653dafSJuergen Schmidt extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)190*6a653dafSJuergen Schmidt component_getImplementationEnvironment(
191*6a653dafSJuergen Schmidt                 const sal_Char  **ppEnvTypeName,
192*6a653dafSJuergen Schmidt                 uno_Environment ** /*ppEnv*/
193*6a653dafSJuergen Schmidt             )
194*6a653dafSJuergen Schmidt {
195*6a653dafSJuergen Schmidt     *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
196*6a653dafSJuergen Schmidt }
197*6a653dafSJuergen Schmidt 
createInstance(const Reference<XMultiServiceFactory> & rServiceManager)198*6a653dafSJuergen Schmidt static Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager )
199*6a653dafSJuergen Schmidt {
200*6a653dafSJuergen Schmidt         MozillaBootstrap * pBootstrap = reinterpret_cast<MozillaBootstrap*>(OMozillaBootstrap_CreateInstance(rServiceManager));
201*6a653dafSJuergen Schmidt         return *pBootstrap;
202*6a653dafSJuergen Schmidt }
203*6a653dafSJuergen Schmidt 
component_getFactory(const sal_Char * pImplementationName,void * pServiceManager,void *)204*6a653dafSJuergen Schmidt extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
205*6a653dafSJuergen Schmidt                                         const sal_Char* pImplementationName,
206*6a653dafSJuergen Schmidt                                         void* pServiceManager,
207*6a653dafSJuergen Schmidt                                         void* /*pRegistryKey*/)
208*6a653dafSJuergen Schmidt {
209*6a653dafSJuergen Schmidt         void* pRet = 0;
210*6a653dafSJuergen Schmidt 
211*6a653dafSJuergen Schmidt         if (pServiceManager)
212*6a653dafSJuergen Schmidt         {
213*6a653dafSJuergen Schmidt                 ::rtl::OUString aImplName( ::rtl::OUString::createFromAscii( pImplementationName ) );
214*6a653dafSJuergen Schmidt                 Reference< XSingleServiceFactory > xFactory;
215*6a653dafSJuergen Schmidt                 if (aImplName.equals(  ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.mozilla.MozillaBootstrap"))  ))
216*6a653dafSJuergen Schmidt                 {
217*6a653dafSJuergen Schmidt                     Sequence< ::rtl::OUString > aSNS( 1 );
218*6a653dafSJuergen Schmidt                     aSNS[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap"));
219*6a653dafSJuergen Schmidt 
220*6a653dafSJuergen Schmidt                     xFactory = ::cppu::createSingleFactory(
221*6a653dafSJuergen Schmidt                         reinterpret_cast< XMultiServiceFactory* > ( pServiceManager),
222*6a653dafSJuergen Schmidt                         aImplName, createInstance, aSNS );
223*6a653dafSJuergen Schmidt                 }
224*6a653dafSJuergen Schmidt                 if ( xFactory.is() )
225*6a653dafSJuergen Schmidt                 {
226*6a653dafSJuergen Schmidt                     xFactory->acquire();
227*6a653dafSJuergen Schmidt                     pRet = xFactory.get();
228*6a653dafSJuergen Schmidt                 }
229*6a653dafSJuergen Schmidt         }
230*6a653dafSJuergen Schmidt 
231*6a653dafSJuergen Schmidt         return pRet;
232*6a653dafSJuergen Schmidt };
233*6a653dafSJuergen Schmidt 
234