xref: /AOO41X/main/shell/source/backends/macbe/macbackend.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_shell.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir // For MAXHOSTNAMELEN constant
32*cdf0e10cSrcweir #include <sys/param.h>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <premac.h>
35*cdf0e10cSrcweir #include <SystemConfiguration/SystemConfiguration.h>
36*cdf0e10cSrcweir #include <Foundation/NSPathUtilities.h>
37*cdf0e10cSrcweir #include <postmac.h>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include "macbackend.hxx"
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include "com/sun/star/beans/Optional.hpp"
42*cdf0e10cSrcweir #include "rtl/ustrbuf.hxx"
43*cdf0e10cSrcweir #include "osl/file.h"
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir #define SPACE      ' '
46*cdf0e10cSrcweir #define SEMI_COLON ';'
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir typedef struct
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir     rtl::OUString Server;
51*cdf0e10cSrcweir     sal_Int32 Port;
52*cdf0e10cSrcweir } ProxyEntry;
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir typedef enum {
55*cdf0e10cSrcweir     sHTTP,
56*cdf0e10cSrcweir 	sHTTPS,
57*cdf0e10cSrcweir     sFTP
58*cdf0e10cSrcweir } ServiceType;
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir //------------------------------------------------------------------------
61*cdf0e10cSrcweir // helper functions
62*cdf0e10cSrcweir //------------------------------------------------------------------------
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir namespace // private
65*cdf0e10cSrcweir {
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir /*
68*cdf0e10cSrcweir  * Returns current proxy settings for selected service type (HTTP or
69*cdf0e10cSrcweir  * FTP) as a C string (in the buffer specified by host and hostSize)
70*cdf0e10cSrcweir  * and a port number.
71*cdf0e10cSrcweir  */
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir bool GetProxySetting(ServiceType sType, char *host, size_t hostSize, UInt16 *port)
74*cdf0e10cSrcweir {
75*cdf0e10cSrcweir     bool                result;
76*cdf0e10cSrcweir     CFDictionaryRef     proxyDict;
77*cdf0e10cSrcweir     CFNumberRef         enableNum;
78*cdf0e10cSrcweir     int                 enable;
79*cdf0e10cSrcweir     CFStringRef         hostStr;
80*cdf0e10cSrcweir     CFNumberRef         portNum;
81*cdf0e10cSrcweir     int                 portInt;
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir     proxyDict = SCDynamicStoreCopyProxies(NULL);
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     if (!proxyDict)
86*cdf0e10cSrcweir         return false;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 	CFStringRef proxiesEnable;
89*cdf0e10cSrcweir 	CFStringRef proxiesProxy;
90*cdf0e10cSrcweir 	CFStringRef proxiesPort;
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 	switch ( sType )
93*cdf0e10cSrcweir 	{
94*cdf0e10cSrcweir 		case sHTTP : proxiesEnable =  kSCPropNetProxiesHTTPEnable;
95*cdf0e10cSrcweir 					 proxiesProxy = kSCPropNetProxiesHTTPProxy;
96*cdf0e10cSrcweir 					 proxiesPort = kSCPropNetProxiesHTTPPort;
97*cdf0e10cSrcweir 			break;
98*cdf0e10cSrcweir 		case sHTTPS: proxiesEnable = kSCPropNetProxiesHTTPSEnable;
99*cdf0e10cSrcweir 					 proxiesProxy = kSCPropNetProxiesHTTPSProxy;
100*cdf0e10cSrcweir 					 proxiesPort = kSCPropNetProxiesHTTPSPort;
101*cdf0e10cSrcweir 			break;
102*cdf0e10cSrcweir 		default: proxiesEnable = kSCPropNetProxiesFTPEnable;
103*cdf0e10cSrcweir 				 proxiesProxy = kSCPropNetProxiesFTPProxy;
104*cdf0e10cSrcweir 				 proxiesPort = kSCPropNetProxiesFTPPort;
105*cdf0e10cSrcweir 			break;
106*cdf0e10cSrcweir 	}
107*cdf0e10cSrcweir     // Proxy enabled?
108*cdf0e10cSrcweir     enableNum = (CFNumberRef) CFDictionaryGetValue( proxyDict,
109*cdf0e10cSrcweir                                                    proxiesEnable );
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir     result = (enableNum != NULL) && (CFGetTypeID(enableNum) == CFNumberGetTypeID());
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir     if (result)
114*cdf0e10cSrcweir         result = CFNumberGetValue(enableNum, kCFNumberIntType, &enable) && (enable != 0);
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir     // Proxy enabled -> get hostname
117*cdf0e10cSrcweir     if (result)
118*cdf0e10cSrcweir     {
119*cdf0e10cSrcweir         hostStr = (CFStringRef) CFDictionaryGetValue( proxyDict,
120*cdf0e10cSrcweir                                                      proxiesProxy );
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir         result = (hostStr != NULL) && (CFGetTypeID(hostStr) == CFStringGetTypeID());
123*cdf0e10cSrcweir     }
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir     if (result)
126*cdf0e10cSrcweir         result = CFStringGetCString(hostStr, host, (CFIndex) hostSize, kCFStringEncodingASCII);
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     // Get proxy port
129*cdf0e10cSrcweir     if (result)
130*cdf0e10cSrcweir     {
131*cdf0e10cSrcweir         portNum = (CFNumberRef) CFDictionaryGetValue( proxyDict,
132*cdf0e10cSrcweir                                                      proxiesPort );
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir         result = (portNum != NULL) && (CFGetTypeID(portNum) == CFNumberGetTypeID());
135*cdf0e10cSrcweir     }
136*cdf0e10cSrcweir     else
137*cdf0e10cSrcweir     {
138*cdf0e10cSrcweir         CFRelease(proxyDict);
139*cdf0e10cSrcweir         return false;
140*cdf0e10cSrcweir     }
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir     if (result)
143*cdf0e10cSrcweir         result = CFNumberGetValue(portNum, kCFNumberIntType, &portInt);
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir     if (result)
146*cdf0e10cSrcweir         *port = (UInt16) portInt;
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir     if (proxyDict)
149*cdf0e10cSrcweir         CFRelease(proxyDict);
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir     if (!result)
152*cdf0e10cSrcweir     {
153*cdf0e10cSrcweir         *host = 0;
154*cdf0e10cSrcweir         *port = 0;
155*cdf0e10cSrcweir     }
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir     return result;
158*cdf0e10cSrcweir }
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir } // end private namespace
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir //------------------------------------------------------------------------------
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir MacOSXBackend::MacOSXBackend()
165*cdf0e10cSrcweir {
166*cdf0e10cSrcweir }
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir //------------------------------------------------------------------------------
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir MacOSXBackend::~MacOSXBackend(void)
171*cdf0e10cSrcweir {
172*cdf0e10cSrcweir }
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir //------------------------------------------------------------------------------
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir MacOSXBackend* MacOSXBackend::createInstance()
177*cdf0e10cSrcweir {
178*cdf0e10cSrcweir     return new MacOSXBackend;
179*cdf0e10cSrcweir }
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir // ---------------------------------------------------------------------------------------
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir rtl::OUString CFStringToOUString(const CFStringRef sOrig) {
184*cdf0e10cSrcweir     CFRetain(sOrig);
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir     CFIndex nStringLen = CFStringGetLength(sOrig)+1;
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir     // Allocate a c string buffer
189*cdf0e10cSrcweir     char sBuffer[nStringLen];
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir     CFStringGetCString(sOrig, sBuffer, nStringLen, kCFStringEncodingASCII);
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir     CFRelease(sOrig);
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir     return rtl::OUString::createFromAscii((sal_Char*)sBuffer);
196*cdf0e10cSrcweir }
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir rtl::OUString GetOUString( NSString* pStr )
199*cdf0e10cSrcweir {
200*cdf0e10cSrcweir     if( ! pStr )
201*cdf0e10cSrcweir         return rtl::OUString();
202*cdf0e10cSrcweir     int nLen = [pStr length];
203*cdf0e10cSrcweir     if( nLen == 0 )
204*cdf0e10cSrcweir         return rtl::OUString();
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir     rtl::OUStringBuffer aBuf( nLen+1 );
207*cdf0e10cSrcweir     aBuf.setLength( nLen );
208*cdf0e10cSrcweir     [pStr getCharacters: const_cast<sal_Unicode*>(aBuf.getStr())];
209*cdf0e10cSrcweir     return aBuf.makeStringAndClear();
210*cdf0e10cSrcweir }
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir void MacOSXBackend::setPropertyValue(
213*cdf0e10cSrcweir     rtl::OUString const &, css::uno::Any const &)
214*cdf0e10cSrcweir     throw (
215*cdf0e10cSrcweir         css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
216*cdf0e10cSrcweir         css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
217*cdf0e10cSrcweir         css::uno::RuntimeException)
218*cdf0e10cSrcweir {
219*cdf0e10cSrcweir     throw css::lang::IllegalArgumentException(
220*cdf0e10cSrcweir         rtl::OUString(
221*cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")),
222*cdf0e10cSrcweir         static_cast< cppu::OWeakObject * >(this), -1);
223*cdf0e10cSrcweir }
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir css::uno::Any MacOSXBackend::getPropertyValue(
226*cdf0e10cSrcweir     rtl::OUString const & PropertyName)
227*cdf0e10cSrcweir     throw (
228*cdf0e10cSrcweir         css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
229*cdf0e10cSrcweir         css::uno::RuntimeException)
230*cdf0e10cSrcweir {
231*cdf0e10cSrcweir     if (PropertyName.equalsAsciiL(
232*cdf0e10cSrcweir             RTL_CONSTASCII_STRINGPARAM("WorkPathVariable")))
233*cdf0e10cSrcweir     {
234*cdf0e10cSrcweir         rtl::OUString aDocDir;
235*cdf0e10cSrcweir         NSArray* pPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, true );
236*cdf0e10cSrcweir         if( pPaths && [pPaths count] > 0 )
237*cdf0e10cSrcweir         {
238*cdf0e10cSrcweir             aDocDir = GetOUString( [pPaths objectAtIndex: 0] );
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir             rtl::OUString aDocURL;
241*cdf0e10cSrcweir             if( aDocDir.getLength() > 0 &&
242*cdf0e10cSrcweir                 osl_getFileURLFromSystemPath( aDocDir.pData, &aDocURL.pData ) == osl_File_E_None )
243*cdf0e10cSrcweir             {
244*cdf0e10cSrcweir                 return css::uno::makeAny(
245*cdf0e10cSrcweir                     css::beans::Optional< css::uno::Any >(
246*cdf0e10cSrcweir                         true, css::uno::makeAny( aDocURL ) ) );
247*cdf0e10cSrcweir             }
248*cdf0e10cSrcweir             else
249*cdf0e10cSrcweir             {
250*cdf0e10cSrcweir                 OSL_TRACE( "user documents list contains empty file path or conversion failed" );
251*cdf0e10cSrcweir             }
252*cdf0e10cSrcweir         }
253*cdf0e10cSrcweir         else
254*cdf0e10cSrcweir         {
255*cdf0e10cSrcweir             OSL_TRACE( "Got nil or empty list of user document directories" );
256*cdf0e10cSrcweir         }
257*cdf0e10cSrcweir         return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
258*cdf0e10cSrcweir     } else if (PropertyName.equalsAsciiL(
259*cdf0e10cSrcweir                    RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyName")))
260*cdf0e10cSrcweir     {
261*cdf0e10cSrcweir         ProxyEntry aFtpProxy;
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir         char host[MAXHOSTNAMELEN];
264*cdf0e10cSrcweir         UInt16 port;
265*cdf0e10cSrcweir         bool retVal;
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir         retVal = GetProxySetting(sFTP, host, 100, &port);
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir         if (retVal)
270*cdf0e10cSrcweir         {
271*cdf0e10cSrcweir             aFtpProxy.Server = rtl::OUString::createFromAscii( host );
272*cdf0e10cSrcweir         }
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir         // ftp proxy name
275*cdf0e10cSrcweir         if( aFtpProxy.Server.getLength() > 0 )
276*cdf0e10cSrcweir         {
277*cdf0e10cSrcweir             return css::uno::makeAny(
278*cdf0e10cSrcweir                 css::beans::Optional< css::uno::Any >(
279*cdf0e10cSrcweir                     true, uno::makeAny( aFtpProxy.Server ) ) );
280*cdf0e10cSrcweir         }
281*cdf0e10cSrcweir         return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
282*cdf0e10cSrcweir     } else if (PropertyName.equalsAsciiL(
283*cdf0e10cSrcweir                    RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyPort")))
284*cdf0e10cSrcweir     {
285*cdf0e10cSrcweir         ProxyEntry aFtpProxy;
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir         char host[MAXHOSTNAMELEN];
288*cdf0e10cSrcweir         UInt16 port;
289*cdf0e10cSrcweir         bool retVal;
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir         retVal = GetProxySetting(sFTP, host, 100, &port);
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir         if (retVal)
294*cdf0e10cSrcweir         {
295*cdf0e10cSrcweir             aFtpProxy.Port = port;
296*cdf0e10cSrcweir         }
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir         // ftp proxy port
299*cdf0e10cSrcweir         if( aFtpProxy.Port > 0 )
300*cdf0e10cSrcweir         {
301*cdf0e10cSrcweir             return css::uno::makeAny(
302*cdf0e10cSrcweir                 css::beans::Optional< css::uno::Any >(
303*cdf0e10cSrcweir                     true, uno::makeAny( aFtpProxy.Port ) ) );
304*cdf0e10cSrcweir         }
305*cdf0e10cSrcweir         return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
306*cdf0e10cSrcweir     } else if (PropertyName.equalsAsciiL(
307*cdf0e10cSrcweir                    RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyName")))
308*cdf0e10cSrcweir     {
309*cdf0e10cSrcweir         ProxyEntry aHttpProxy;
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir         char host[MAXHOSTNAMELEN];
312*cdf0e10cSrcweir         UInt16 port;
313*cdf0e10cSrcweir         bool retVal;
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir         retVal = GetProxySetting(sHTTP, host, 100, &port);
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir         if (retVal)
318*cdf0e10cSrcweir         {
319*cdf0e10cSrcweir             aHttpProxy.Server = rtl::OUString::createFromAscii( host );
320*cdf0e10cSrcweir         }
321*cdf0e10cSrcweir 
322*cdf0e10cSrcweir         // http proxy name
323*cdf0e10cSrcweir         if( aHttpProxy.Server.getLength() > 0 )
324*cdf0e10cSrcweir         {
325*cdf0e10cSrcweir             return css::uno::makeAny(
326*cdf0e10cSrcweir                 css::beans::Optional< css::uno::Any >(
327*cdf0e10cSrcweir                     true, uno::makeAny( aHttpProxy.Server ) ) );
328*cdf0e10cSrcweir         }
329*cdf0e10cSrcweir         return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
330*cdf0e10cSrcweir     } else if (PropertyName.equalsAsciiL(
331*cdf0e10cSrcweir                    RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyPort")))
332*cdf0e10cSrcweir     {
333*cdf0e10cSrcweir         ProxyEntry aHttpProxy;
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir         char host[MAXHOSTNAMELEN];
336*cdf0e10cSrcweir         UInt16 port;
337*cdf0e10cSrcweir         bool retVal;
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir         retVal = GetProxySetting(sHTTP, host, 100, &port);
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir         if (retVal)
342*cdf0e10cSrcweir         {
343*cdf0e10cSrcweir             aHttpProxy.Port = port;
344*cdf0e10cSrcweir         }
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir         // http proxy port
347*cdf0e10cSrcweir         if( aHttpProxy.Port > 0 )
348*cdf0e10cSrcweir         {
349*cdf0e10cSrcweir             return css::uno::makeAny(
350*cdf0e10cSrcweir                 css::beans::Optional< css::uno::Any >(
351*cdf0e10cSrcweir                     true, uno::makeAny( aHttpProxy.Port ) ) );
352*cdf0e10cSrcweir         }
353*cdf0e10cSrcweir         return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
354*cdf0e10cSrcweir     } else if (PropertyName.equalsAsciiL(
355*cdf0e10cSrcweir                    RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyName")))
356*cdf0e10cSrcweir     {
357*cdf0e10cSrcweir         ProxyEntry aHttpsProxy;
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir         char host[MAXHOSTNAMELEN];
360*cdf0e10cSrcweir         UInt16 port;
361*cdf0e10cSrcweir         bool retVal;
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir         retVal = GetProxySetting(sHTTPS, host, 100, &port);
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir         if (retVal)
366*cdf0e10cSrcweir         {
367*cdf0e10cSrcweir             aHttpsProxy.Server = rtl::OUString::createFromAscii( host );
368*cdf0e10cSrcweir         }
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir         // https proxy name
371*cdf0e10cSrcweir         if( aHttpsProxy.Server.getLength() > 0 )
372*cdf0e10cSrcweir         {
373*cdf0e10cSrcweir             return css::uno::makeAny(
374*cdf0e10cSrcweir                 css::beans::Optional< css::uno::Any >(
375*cdf0e10cSrcweir                     true, uno::makeAny( aHttpsProxy.Server ) ) );
376*cdf0e10cSrcweir         }
377*cdf0e10cSrcweir         return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
378*cdf0e10cSrcweir     } else if (PropertyName.equalsAsciiL(
379*cdf0e10cSrcweir                    RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyPort")))
380*cdf0e10cSrcweir     {
381*cdf0e10cSrcweir         ProxyEntry aHttpsProxy;
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir         char host[MAXHOSTNAMELEN];
384*cdf0e10cSrcweir         UInt16 port;
385*cdf0e10cSrcweir         bool retVal;
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir         retVal = GetProxySetting(sHTTPS, host, 100, &port);
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir         if (retVal)
390*cdf0e10cSrcweir         {
391*cdf0e10cSrcweir             aHttpsProxy.Port = port;
392*cdf0e10cSrcweir         }
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir         // https proxy port
395*cdf0e10cSrcweir         if( aHttpsProxy.Port > 0 )
396*cdf0e10cSrcweir         {
397*cdf0e10cSrcweir             return css::uno::makeAny(
398*cdf0e10cSrcweir                 css::beans::Optional< css::uno::Any >(
399*cdf0e10cSrcweir                     true, uno::makeAny( aHttpsProxy.Port ) ) );
400*cdf0e10cSrcweir         }
401*cdf0e10cSrcweir         return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
402*cdf0e10cSrcweir     } else if (PropertyName.equalsAsciiL(
403*cdf0e10cSrcweir                    RTL_CONSTASCII_STRINGPARAM("ooInetProxyType")))
404*cdf0e10cSrcweir     {
405*cdf0e10cSrcweir         // override default for ProxyType, which is "0" meaning "No proxies".
406*cdf0e10cSrcweir         sal_Int32 nProperties = 1;
407*cdf0e10cSrcweir         return css::uno::makeAny(
408*cdf0e10cSrcweir             css::beans::Optional< css::uno::Any >(
409*cdf0e10cSrcweir                 true, uno::makeAny( nProperties ) ) );
410*cdf0e10cSrcweir     } else if (PropertyName.equalsAsciiL(
411*cdf0e10cSrcweir                    RTL_CONSTASCII_STRINGPARAM("ooInetNoProxy")))
412*cdf0e10cSrcweir     {
413*cdf0e10cSrcweir         rtl::OUString aProxyBypassList;
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir         CFArrayRef rExceptionsList;
416*cdf0e10cSrcweir         CFDictionaryRef rProxyDict = SCDynamicStoreCopyProxies(NULL);
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir         if (!rProxyDict)
419*cdf0e10cSrcweir             rExceptionsList = false;
420*cdf0e10cSrcweir         else
421*cdf0e10cSrcweir             rExceptionsList = (CFArrayRef) CFDictionaryGetValue(rProxyDict, kSCPropNetProxiesExceptionsList);
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir         if (rExceptionsList)
424*cdf0e10cSrcweir         {
425*cdf0e10cSrcweir             for (CFIndex idx = 0; idx < CFArrayGetCount(rExceptionsList); idx++)
426*cdf0e10cSrcweir             {
427*cdf0e10cSrcweir                 CFStringRef rException = (CFStringRef) CFArrayGetValueAtIndex(rExceptionsList, idx);
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir                 if (idx>0)
430*cdf0e10cSrcweir                     aProxyBypassList += rtl::OUString::createFromAscii( ";" );
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir                 aProxyBypassList += CFStringToOUString(rException);
433*cdf0e10cSrcweir             }
434*cdf0e10cSrcweir         }
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir         if (rProxyDict)
437*cdf0e10cSrcweir             CFRelease(rProxyDict);
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir         // fill proxy bypass list
440*cdf0e10cSrcweir         if( aProxyBypassList.getLength() > 0 )
441*cdf0e10cSrcweir         {
442*cdf0e10cSrcweir             return css::uno::makeAny(
443*cdf0e10cSrcweir                 css::beans::Optional< css::uno::Any >(
444*cdf0e10cSrcweir                     true,
445*cdf0e10cSrcweir                     uno::makeAny( aProxyBypassList.replace( SPACE, SEMI_COLON ) ) ) );
446*cdf0e10cSrcweir         }
447*cdf0e10cSrcweir         return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
448*cdf0e10cSrcweir     } else {
449*cdf0e10cSrcweir         throw css::beans::UnknownPropertyException(
450*cdf0e10cSrcweir             PropertyName, static_cast< cppu::OWeakObject * >(this));
451*cdf0e10cSrcweir     }
452*cdf0e10cSrcweir }
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir //------------------------------------------------------------------------------
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir rtl::OUString SAL_CALL MacOSXBackend::getBackendName(void)
457*cdf0e10cSrcweir {
458*cdf0e10cSrcweir 	return rtl::OUString::createFromAscii("com.sun.star.comp.configuration.backend.MacOSXBackend");
459*cdf0e10cSrcweir }
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir //------------------------------------------------------------------------------
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir rtl::OUString SAL_CALL MacOSXBackend::getImplementationName(void)
464*cdf0e10cSrcweir     throw (uno::RuntimeException)
465*cdf0e10cSrcweir {
466*cdf0e10cSrcweir     return getBackendName();
467*cdf0e10cSrcweir }
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir //------------------------------------------------------------------------------
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir uno::Sequence<rtl::OUString> SAL_CALL MacOSXBackend::getBackendServiceNames(void)
472*cdf0e10cSrcweir {
473*cdf0e10cSrcweir     uno::Sequence<rtl::OUString> aServiceNameList(1);
474*cdf0e10cSrcweir     aServiceNameList[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.MacOSXBackend"));
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir     return aServiceNameList;
477*cdf0e10cSrcweir }
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir //------------------------------------------------------------------------------
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir sal_Bool SAL_CALL MacOSXBackend::supportsService(const rtl::OUString& aServiceName)
482*cdf0e10cSrcweir     throw (uno::RuntimeException)
483*cdf0e10cSrcweir {
484*cdf0e10cSrcweir     uno::Sequence< rtl::OUString > const svc = getBackendServiceNames();
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir     for(sal_Int32 i = 0; i < svc.getLength(); ++i )
487*cdf0e10cSrcweir         if(svc[i] == aServiceName)
488*cdf0e10cSrcweir             return true;
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir     return false;
491*cdf0e10cSrcweir }
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir //------------------------------------------------------------------------------
494*cdf0e10cSrcweir 
495*cdf0e10cSrcweir uno::Sequence<rtl::OUString> SAL_CALL MacOSXBackend::getSupportedServiceNames(void)
496*cdf0e10cSrcweir     throw (uno::RuntimeException)
497*cdf0e10cSrcweir {
498*cdf0e10cSrcweir     return getBackendServiceNames();
499*cdf0e10cSrcweir }
500