1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: wininetbackend.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_shell.hxx"
34 #include "wininetbackend.hxx"
35 #include "wininetlayer.hxx"
36 #include <com/sun/star/configuration/backend/ComponentChangeEvent.hpp>
37 #include <uno/current_context.hxx>
39 #define WININET_DLL_NAME "wininet.dll"
41 WinInetBackend::WinInetBackend(const uno::Reference
<uno::XComponentContext
>& xContext
)
42 throw (backend::BackendAccessException
) :
43 ::cppu::WeakImplHelper2
< backend::XSingleLayerStratum
, lang::XServiceInfo
> (),
46 m_hWinInetDll
= LoadLibrary( WININET_DLL_NAME
);
49 //------------------------------------------------------------------------------
51 WinInetBackend::~WinInetBackend(void)
54 FreeLibrary( m_hWinInetDll
);
57 //------------------------------------------------------------------------------
59 WinInetBackend
* WinInetBackend::createInstance(
60 const uno::Reference
<uno::XComponentContext
>& xContext
63 return new WinInetBackend(xContext
);
66 // ---------------------------------------------------------------------------------------
68 uno::Reference
<backend::XLayer
> SAL_CALL
WinInetBackend::getLayer(
69 const rtl::OUString
& aComponent
, const rtl::OUString
& /*aTimestamp*/)
70 throw (backend::BackendAccessException
, lang::IllegalArgumentException
)
73 if( aComponent
.equals( getSupportedComponents()[0]) )
75 if( ! m_xSystemLayer
.is() && m_hWinInetDll
)
77 WinInetLayer::InternetQueryOption_Proc_T lpfnInternetQueryOption
=
78 reinterpret_cast< WinInetLayer::InternetQueryOption_Proc_T
>(
79 GetProcAddress( m_hWinInetDll
, "InternetQueryOptionA" ) );
81 if( lpfnInternetQueryOption
)
82 m_xSystemLayer
= new WinInetLayer(lpfnInternetQueryOption
, m_xContext
);
85 return m_xSystemLayer
;
88 return uno::Reference
<backend::XLayer
>();
91 //------------------------------------------------------------------------------
93 uno::Reference
<backend::XUpdatableLayer
> SAL_CALL
94 WinInetBackend::getUpdatableLayer(const rtl::OUString
& /*aComponent*/)
95 throw (backend::BackendAccessException
,lang::NoSupportException
,
96 lang::IllegalArgumentException
)
98 throw lang::NoSupportException(
99 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
100 "WinInetBackend: No Update Operation allowed, Read Only access") ),
106 //------------------------------------------------------------------------------
108 rtl::OUString SAL_CALL
WinInetBackend::getBackendName(void) {
109 return rtl::OUString::createFromAscii("com.sun.star.comp.configuration.backend.WinInetBackend") ;
112 //------------------------------------------------------------------------------
114 rtl::OUString SAL_CALL
WinInetBackend::getImplementationName(void)
115 throw (uno::RuntimeException
)
117 return getBackendName() ;
120 //------------------------------------------------------------------------------
122 uno::Sequence
<rtl::OUString
> SAL_CALL
WinInetBackend::getBackendServiceNames(void)
124 uno::Sequence
<rtl::OUString
> aServiceNameList(2);
125 aServiceNameList
[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.WinInetBackend")) ;
126 aServiceNameList
[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.PlatformBackend")) ;
128 return aServiceNameList
;
131 //------------------------------------------------------------------------------
133 sal_Bool SAL_CALL
WinInetBackend::supportsService(const rtl::OUString
& aServiceName
)
134 throw (uno::RuntimeException
)
136 uno::Sequence
< rtl::OUString
> const svc
= getBackendServiceNames();
138 for(sal_Int32 i
= 0; i
< svc
.getLength(); ++i
)
139 if(svc
[i
] == aServiceName
)
145 //------------------------------------------------------------------------------
147 uno::Sequence
<rtl::OUString
> SAL_CALL
WinInetBackend::getSupportedServiceNames(void)
148 throw (uno::RuntimeException
)
150 return getBackendServiceNames() ;
153 // ---------------------------------------------------------------------------------------
155 uno::Sequence
<rtl::OUString
> SAL_CALL
WinInetBackend::getSupportedComponents(void)
157 uno::Sequence
<rtl::OUString
> aSupportedComponentList(1);
158 aSupportedComponentList
[0] = rtl::OUString(
159 RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet" )
162 return aSupportedComponentList
;