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 #ifndef INCLUDED_UCBHELPER_PROXYDECIDER_HXX
21 #define INCLUDED_UCBHELPER_PROXYDECIDER_HXX
23 #include <rtl/ustring.hxx>
24 #include <rtl/ref.hxx>
25 #include <com/sun/star/uno/Reference.hxx>
26 #include <com/sun/star/uno/XComponentContext.hpp>
27 #include <ucbhelper/ucbhelperdllapi.h>
29 namespace com
{ namespace sun
{ namespace star
{ namespace lang
{
30 class XMultiServiceFactory
;
37 * This struct describes a proxy server.
39 struct InternetProxyServer
42 * The name of the proxy server.
47 * The port of the proxy server.
54 InternetProxyServer() : nPort( -1 ) {}
57 namespace proxydecider_impl
{ class InternetProxyDecider_Impl
; }
60 * This class is able to decide whether and which internet proxy server is to
61 * be used to access a given URI.
63 * The implementation reads the internet proxy settings from Office
64 * configuration. It listens for configuration changes and adapts itself
65 * accordingly. Because configuration data can change during runtime clients
66 * should not cache results obtained from InternetProxyDecider instances. One
67 * instance should be kept to be queried multiple times instead.
69 class UCBHELPER_DLLPUBLIC InternetProxyDecider
75 * Note: Every instance should be held alive as long as possible because
76 * because construction is quite expensive.
78 * @param rxSMgr is a Service Manager.
80 InternetProxyDecider( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
85 ~InternetProxyDecider();
88 * Informs whether a proxy server should be used.
90 * @param rProtocol contains the internet protocol to be used to
91 * access the server (i.e. "ftp", "http"). The protocol string
92 * is handled case-insensitive and must not be empty.
93 * @param rHost contains the name of the server that should be accessed.
94 * This parameter might be left empty. In this case the
95 * implementation will return whether a proxy is configured
96 * for the given protocol.
97 * @param nPort contains the port of the server that should be accessed.
98 * If host is not empty this parameter must always contain a valid
99 * port number, for instance the default port for the requested
100 * protocol(i.e. 80 or http).
101 * @return true if a proxy server should be used, false otherwise.
104 shouldUseProxy( const OUString
& rProtocol
,
105 const OUString
& rHost
,
106 sal_Int32 nPort
) const;
109 * Returns the proxy server to be used.
111 * @param rProtocol contains the internet protocol to be used to
112 * access the server (i.e. "ftp", "http"). The protocol string
113 * is handled case-insensitive and must not be empty.
114 * @param rHost contains the name of the server that should be accessed.
115 * This parameter might be left empty. In this case the
116 * implementation will return the proxy that is configured
117 * for the given protocol.
118 * @param nPort contains the port of the server that should be accessed.
119 * If host is not empty this parameter must always contain a valid
120 * port number, for instance the default port for the requested
121 * protocol(i.e. 80 or http).
122 * @return a InternetProxyServer reference. If member aName of the
123 * InternetProxyServer is empty no proxy server is to be used.
125 const InternetProxyServer
&
126 getProxy( const OUString
& rProtocol
,
127 const OUString
& rHost
,
128 sal_Int32 nPort
) const;
131 rtl::Reference
<proxydecider_impl::InternetProxyDecider_Impl
> m_xImpl
;
134 } // namespace ucbhelper
136 #endif /* ! INCLUDED_UCBHELPER_PROXYDECIDER_HXX */
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */