1*f8e2c85aSAndrew Rist /**************************************************************
2*f8e2c85aSAndrew Rist *
3*f8e2c85aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*f8e2c85aSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*f8e2c85aSAndrew Rist * distributed with this work for additional information
6*f8e2c85aSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*f8e2c85aSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*f8e2c85aSAndrew Rist * "License"); you may not use this file except in compliance
9*f8e2c85aSAndrew Rist * with the License. You may obtain a copy of the License at
10*f8e2c85aSAndrew Rist *
11*f8e2c85aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*f8e2c85aSAndrew Rist *
13*f8e2c85aSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*f8e2c85aSAndrew Rist * software distributed under the License is distributed on an
15*f8e2c85aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f8e2c85aSAndrew Rist * KIND, either express or implied. See the License for the
17*f8e2c85aSAndrew Rist * specific language governing permissions and limitations
18*f8e2c85aSAndrew Rist * under the License.
19*f8e2c85aSAndrew Rist *
20*f8e2c85aSAndrew Rist *************************************************************/
21*f8e2c85aSAndrew Rist
22*f8e2c85aSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include "precompiled_shell.hxx"
25cdf0e10cSrcweir #include "sal/config.h"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "com/sun/star/uno/Any.hxx"
28cdf0e10cSrcweir #include "cppu/unotype.hxx"
29cdf0e10cSrcweir #include "osl/diagnose.h"
30cdf0e10cSrcweir #include "osl/file.h"
31cdf0e10cSrcweir #include "rtl/string.h"
32cdf0e10cSrcweir #include "rtl/ustring.hxx"
33cdf0e10cSrcweir
34cdf0e10cSrcweir #include "kde_headers.h"
35cdf0e10cSrcweir
36cdf0e10cSrcweir #include "kdeaccess.hxx"
37cdf0e10cSrcweir
38cdf0e10cSrcweir #define SPACE ' '
39cdf0e10cSrcweir #define COMMA ','
40cdf0e10cSrcweir #define SEMI_COLON ';'
41cdf0e10cSrcweir
42cdf0e10cSrcweir namespace kdeaccess {
43cdf0e10cSrcweir
44cdf0e10cSrcweir namespace {
45cdf0e10cSrcweir
46cdf0e10cSrcweir namespace css = com::sun::star ;
47cdf0e10cSrcweir namespace uno = css::uno ;
48cdf0e10cSrcweir
49cdf0e10cSrcweir }
50cdf0e10cSrcweir
getValue(rtl::OUString const & id)51cdf0e10cSrcweir css::beans::Optional< css::uno::Any > getValue(rtl::OUString const & id) {
52cdf0e10cSrcweir if (id.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ExternalMailer"))) {
53cdf0e10cSrcweir KEMailSettings aEmailSettings;
54cdf0e10cSrcweir QString aClientProgram;
55cdf0e10cSrcweir ::rtl::OUString sClientProgram;
56cdf0e10cSrcweir
57cdf0e10cSrcweir aClientProgram = aEmailSettings.getSetting( KEMailSettings::ClientProgram );
58cdf0e10cSrcweir if ( aClientProgram.isEmpty() )
59cdf0e10cSrcweir aClientProgram = "kmail";
60cdf0e10cSrcweir else
61cdf0e10cSrcweir aClientProgram = aClientProgram.section(SPACE, 0, 0);
62cdf0e10cSrcweir sClientProgram = (const sal_Unicode *) aClientProgram.ucs2();
63cdf0e10cSrcweir return css::beans::Optional< css::uno::Any >(
64cdf0e10cSrcweir true, uno::makeAny( sClientProgram ) );
65cdf0e10cSrcweir } else if (id.equalsAsciiL(
66cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("SourceViewFontHeight")))
67cdf0e10cSrcweir {
68cdf0e10cSrcweir QFont aFixedFont;
69cdf0e10cSrcweir short nFontHeight;
70cdf0e10cSrcweir
71cdf0e10cSrcweir aFixedFont = KGlobalSettings::fixedFont();
72cdf0e10cSrcweir nFontHeight = aFixedFont.pointSize();
73cdf0e10cSrcweir return css::beans::Optional< css::uno::Any >(
74cdf0e10cSrcweir true, uno::makeAny( nFontHeight ) );
75cdf0e10cSrcweir } else if (id.equalsAsciiL(
76cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("SourceViewFontName")))
77cdf0e10cSrcweir {
78cdf0e10cSrcweir QFont aFixedFont;
79cdf0e10cSrcweir QString aFontName;
80cdf0e10cSrcweir :: rtl::OUString sFontName;
81cdf0e10cSrcweir
82cdf0e10cSrcweir aFixedFont = KGlobalSettings::fixedFont();
83cdf0e10cSrcweir aFontName = aFixedFont.family();
84cdf0e10cSrcweir sFontName = (const sal_Unicode *) aFontName.ucs2();
85cdf0e10cSrcweir return css::beans::Optional< css::uno::Any >(
86cdf0e10cSrcweir true, uno::makeAny( sFontName ) );
87cdf0e10cSrcweir } else if (id.equalsAsciiL(
88cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("EnableATToolSupport")))
89cdf0e10cSrcweir {
90cdf0e10cSrcweir /* does not make much sense without an accessibility bridge */
91cdf0e10cSrcweir sal_Bool ATToolSupport = sal_False;
92cdf0e10cSrcweir return css::beans::Optional< css::uno::Any >(
93cdf0e10cSrcweir true, uno::makeAny( rtl::OUString::valueOf( ATToolSupport ) ) );
94cdf0e10cSrcweir } else if (id.equalsAsciiL(
95cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("WorkPathVariable")))
96cdf0e10cSrcweir {
97cdf0e10cSrcweir QString aDocumentsDir( KGlobalSettings::documentPath() );
98cdf0e10cSrcweir rtl::OUString sDocumentsDir;
99cdf0e10cSrcweir rtl::OUString sDocumentsURL;
100cdf0e10cSrcweir if ( aDocumentsDir.endsWith(QChar('/')) )
101cdf0e10cSrcweir aDocumentsDir.truncate ( aDocumentsDir.length() - 1 );
102cdf0e10cSrcweir sDocumentsDir = (const sal_Unicode *) aDocumentsDir.ucs2();
103cdf0e10cSrcweir osl_getFileURLFromSystemPath( sDocumentsDir.pData, &sDocumentsURL.pData );
104cdf0e10cSrcweir return css::beans::Optional< css::uno::Any >(
105cdf0e10cSrcweir true, uno::makeAny( sDocumentsURL ) );
106cdf0e10cSrcweir } else if (id.equalsAsciiL(
107cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyName")))
108cdf0e10cSrcweir {
109cdf0e10cSrcweir QString aFTPProxy;
110cdf0e10cSrcweir switch ( KProtocolManager::proxyType() )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir case KProtocolManager::ManualProxy: // Proxies are manually configured
113cdf0e10cSrcweir aFTPProxy = KProtocolManager::proxyFor( "FTP" );
114cdf0e10cSrcweir break;
115cdf0e10cSrcweir case KProtocolManager::PACProxy: // A proxy configuration URL has been given
116cdf0e10cSrcweir case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
117cdf0e10cSrcweir case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
118cdf0e10cSrcweir // In such cases, the proxy address is not stored in KDE, but determined dynamically.
119cdf0e10cSrcweir // The proxy address may depend on the requested address, on the time of the day, on the speed of the wind...
120cdf0e10cSrcweir // The best we can do here is to ask the current value for a given address.
121cdf0e10cSrcweir aFTPProxy = KProtocolManager::proxyForURL( "ftp://ftp.openoffice.org" );
122cdf0e10cSrcweir break;
123cdf0e10cSrcweir default: // No proxy is used
124cdf0e10cSrcweir break;
125cdf0e10cSrcweir }
126cdf0e10cSrcweir if ( !aFTPProxy.isEmpty() )
127cdf0e10cSrcweir {
128cdf0e10cSrcweir KURL aProxy(aFTPProxy);
129cdf0e10cSrcweir ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().ucs2();
130cdf0e10cSrcweir return css::beans::Optional< css::uno::Any >(
131cdf0e10cSrcweir true, uno::makeAny( sProxy ) );
132cdf0e10cSrcweir }
133cdf0e10cSrcweir } else if (id.equalsAsciiL(
134cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyPort")))
135cdf0e10cSrcweir {
136cdf0e10cSrcweir QString aFTPProxy;
137cdf0e10cSrcweir switch ( KProtocolManager::proxyType() )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir case KProtocolManager::ManualProxy: // Proxies are manually configured
140cdf0e10cSrcweir aFTPProxy = KProtocolManager::proxyFor( "FTP" );
141cdf0e10cSrcweir break;
142cdf0e10cSrcweir case KProtocolManager::PACProxy: // A proxy configuration URL has been given
143cdf0e10cSrcweir case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
144cdf0e10cSrcweir case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
145cdf0e10cSrcweir // In such cases, the proxy address is not stored in KDE, but determined dynamically.
146cdf0e10cSrcweir // The proxy address may depend on the requested address, on the time of the day, on the speed of the wind...
147cdf0e10cSrcweir // The best we can do here is to ask the current value for a given address.
148cdf0e10cSrcweir aFTPProxy = KProtocolManager::proxyForURL( "ftp://ftp.openoffice.org" );
149cdf0e10cSrcweir break;
150cdf0e10cSrcweir default: // No proxy is used
151cdf0e10cSrcweir break;
152cdf0e10cSrcweir }
153cdf0e10cSrcweir if ( !aFTPProxy.isEmpty() )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir KURL aProxy(aFTPProxy);
156cdf0e10cSrcweir sal_Int32 nPort = aProxy.port();
157cdf0e10cSrcweir return css::beans::Optional< css::uno::Any >(
158cdf0e10cSrcweir true, uno::makeAny( nPort ) );
159cdf0e10cSrcweir }
160cdf0e10cSrcweir } else if (id.equalsAsciiL(
161cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyName")))
162cdf0e10cSrcweir {
163cdf0e10cSrcweir QString aHTTPProxy;
164cdf0e10cSrcweir switch ( KProtocolManager::proxyType() )
165cdf0e10cSrcweir {
166cdf0e10cSrcweir case KProtocolManager::ManualProxy: // Proxies are manually configured
167cdf0e10cSrcweir aHTTPProxy = KProtocolManager::proxyFor( "HTTP" );
168cdf0e10cSrcweir break;
169cdf0e10cSrcweir case KProtocolManager::PACProxy: // A proxy configuration URL has been given
170cdf0e10cSrcweir case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
171cdf0e10cSrcweir case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
172cdf0e10cSrcweir // In such cases, the proxy address is not stored in KDE, but determined dynamically.
173cdf0e10cSrcweir // The proxy address may depend on the requested address, on the time of the day, on the speed of the wind...
174cdf0e10cSrcweir // The best we can do here is to ask the current value for a given address.
175cdf0e10cSrcweir aHTTPProxy = KProtocolManager::proxyForURL( "http://http.openoffice.org" );
176cdf0e10cSrcweir break;
177cdf0e10cSrcweir default: // No proxy is used
178cdf0e10cSrcweir break;
179cdf0e10cSrcweir }
180cdf0e10cSrcweir if ( !aHTTPProxy.isEmpty() )
181cdf0e10cSrcweir {
182cdf0e10cSrcweir KURL aProxy(aHTTPProxy);
183cdf0e10cSrcweir ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().ucs2();
184cdf0e10cSrcweir return css::beans::Optional< css::uno::Any >(
185cdf0e10cSrcweir true, uno::makeAny( sProxy ) );
186cdf0e10cSrcweir }
187cdf0e10cSrcweir } else if (id.equalsAsciiL(
188cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyPort")))
189cdf0e10cSrcweir {
190cdf0e10cSrcweir QString aHTTPProxy;
191cdf0e10cSrcweir switch ( KProtocolManager::proxyType() )
192cdf0e10cSrcweir {
193cdf0e10cSrcweir case KProtocolManager::ManualProxy: // Proxies are manually configured
194cdf0e10cSrcweir aHTTPProxy = KProtocolManager::proxyFor( "HTTP" );
195cdf0e10cSrcweir break;
196cdf0e10cSrcweir case KProtocolManager::PACProxy: // A proxy configuration URL has been given
197cdf0e10cSrcweir case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
198cdf0e10cSrcweir case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
199cdf0e10cSrcweir // In such cases, the proxy address is not stored in KDE, but determined dynamically.
200cdf0e10cSrcweir // The proxy address may depend on the requested address, on the time of the day, on the speed of the wind...
201cdf0e10cSrcweir // The best we can do here is to ask the current value for a given address.
202cdf0e10cSrcweir aHTTPProxy = KProtocolManager::proxyForURL( "http://http.openoffice.org" );
203cdf0e10cSrcweir break;
204cdf0e10cSrcweir default: // No proxy is used
205cdf0e10cSrcweir break;
206cdf0e10cSrcweir }
207cdf0e10cSrcweir if ( !aHTTPProxy.isEmpty() )
208cdf0e10cSrcweir {
209cdf0e10cSrcweir KURL aProxy(aHTTPProxy);
210cdf0e10cSrcweir sal_Int32 nPort = aProxy.port();
211cdf0e10cSrcweir return css::beans::Optional< css::uno::Any >(
212cdf0e10cSrcweir true, uno::makeAny( nPort ) );
213cdf0e10cSrcweir }
214cdf0e10cSrcweir } else if (id.equalsAsciiL(
215cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyName")))
216cdf0e10cSrcweir {
217cdf0e10cSrcweir QString aHTTPSProxy;
218cdf0e10cSrcweir switch ( KProtocolManager::proxyType() )
219cdf0e10cSrcweir {
220cdf0e10cSrcweir case KProtocolManager::ManualProxy: // Proxies are manually configured
221cdf0e10cSrcweir aHTTPSProxy = KProtocolManager::proxyFor( "HTTPS" );
222cdf0e10cSrcweir break;
223cdf0e10cSrcweir case KProtocolManager::PACProxy: // A proxy configuration URL has been given
224cdf0e10cSrcweir case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
225cdf0e10cSrcweir case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
226cdf0e10cSrcweir // In such cases, the proxy address is not stored in KDE, but determined dynamically.
227cdf0e10cSrcweir // The proxy address may depend on the requested address, on the time of the day, on the speed of the wind...
228cdf0e10cSrcweir // The best we can do here is to ask the current value for a given address.
229cdf0e10cSrcweir aHTTPSProxy = KProtocolManager::proxyForURL( "https://https.openoffice.org" );
230cdf0e10cSrcweir break;
231cdf0e10cSrcweir default: // No proxy is used
232cdf0e10cSrcweir break;
233cdf0e10cSrcweir }
234cdf0e10cSrcweir if ( !aHTTPSProxy.isEmpty() )
235cdf0e10cSrcweir {
236cdf0e10cSrcweir KURL aProxy(aHTTPSProxy);
237cdf0e10cSrcweir ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().ucs2();
238cdf0e10cSrcweir return css::beans::Optional< css::uno::Any >(
239cdf0e10cSrcweir true, uno::makeAny( sProxy ) );
240cdf0e10cSrcweir }
241cdf0e10cSrcweir } else if (id.equalsAsciiL(
242cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyPort")))
243cdf0e10cSrcweir {
244cdf0e10cSrcweir QString aHTTPSProxy;
245cdf0e10cSrcweir switch ( KProtocolManager::proxyType() )
246cdf0e10cSrcweir {
247cdf0e10cSrcweir case KProtocolManager::ManualProxy: // Proxies are manually configured
248cdf0e10cSrcweir aHTTPSProxy = KProtocolManager::proxyFor( "HTTPS" );
249cdf0e10cSrcweir break;
250cdf0e10cSrcweir case KProtocolManager::PACProxy: // A proxy configuration URL has been given
251cdf0e10cSrcweir case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
252cdf0e10cSrcweir case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
253cdf0e10cSrcweir // In such cases, the proxy address is not stored in KDE, but determined dynamically.
254cdf0e10cSrcweir // The proxy address may depend on the requested address, on the time of the day, on the speed of the wind...
255cdf0e10cSrcweir // The best we can do here is to ask the current value for a given address.
256cdf0e10cSrcweir aHTTPSProxy = KProtocolManager::proxyForURL( "https://https.openoffice.org" );
257cdf0e10cSrcweir break;
258cdf0e10cSrcweir default: // No proxy is used
259cdf0e10cSrcweir break;
260cdf0e10cSrcweir }
261cdf0e10cSrcweir if ( !aHTTPSProxy.isEmpty() )
262cdf0e10cSrcweir {
263cdf0e10cSrcweir KURL aProxy(aHTTPSProxy);
264cdf0e10cSrcweir sal_Int32 nPort = aProxy.port();
265cdf0e10cSrcweir return css::beans::Optional< css::uno::Any >(
266cdf0e10cSrcweir true, uno::makeAny( nPort ) );
267cdf0e10cSrcweir }
268cdf0e10cSrcweir } else if (id.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ooInetNoProxy"))) {
269cdf0e10cSrcweir QString aNoProxyFor;
270cdf0e10cSrcweir switch ( KProtocolManager::proxyType() )
271cdf0e10cSrcweir {
272cdf0e10cSrcweir case KProtocolManager::ManualProxy: // Proxies are manually configured
273cdf0e10cSrcweir case KProtocolManager::PACProxy: // A proxy configuration URL has been given
274cdf0e10cSrcweir case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
275cdf0e10cSrcweir case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
276cdf0e10cSrcweir aNoProxyFor = KProtocolManager::noProxyFor();
277cdf0e10cSrcweir break;
278cdf0e10cSrcweir default: // No proxy is used
279cdf0e10cSrcweir break;
280cdf0e10cSrcweir }
281cdf0e10cSrcweir if ( !aNoProxyFor.isEmpty() )
282cdf0e10cSrcweir {
283cdf0e10cSrcweir ::rtl::OUString sNoProxyFor;
284cdf0e10cSrcweir
285cdf0e10cSrcweir aNoProxyFor = aNoProxyFor.replace( COMMA, SEMI_COLON );
286cdf0e10cSrcweir sNoProxyFor = (const sal_Unicode *) aNoProxyFor.ucs2();
287cdf0e10cSrcweir return css::beans::Optional< css::uno::Any >(
288cdf0e10cSrcweir true, uno::makeAny( sNoProxyFor ) );
289cdf0e10cSrcweir }
290cdf0e10cSrcweir } else if (id.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ooInetProxyType"))) {
291cdf0e10cSrcweir int nProxyType;
292cdf0e10cSrcweir switch ( KProtocolManager::proxyType() )
293cdf0e10cSrcweir {
294cdf0e10cSrcweir case KProtocolManager::ManualProxy: // Proxies are manually configured
295cdf0e10cSrcweir case KProtocolManager::PACProxy: // A proxy configuration URL has been given
296cdf0e10cSrcweir case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
297cdf0e10cSrcweir case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
298cdf0e10cSrcweir nProxyType = 1;
299cdf0e10cSrcweir break;
300cdf0e10cSrcweir default: // No proxy is used
301cdf0e10cSrcweir nProxyType = 0;
302cdf0e10cSrcweir }
303cdf0e10cSrcweir return css::beans::Optional< css::uno::Any >(
304cdf0e10cSrcweir true, uno::makeAny( (sal_Int32) nProxyType ) );
305cdf0e10cSrcweir } else {
306cdf0e10cSrcweir OSL_ASSERT(false); // this cannot happen
307cdf0e10cSrcweir }
308cdf0e10cSrcweir return css::beans::Optional< css::uno::Any >();
309cdf0e10cSrcweir }
310cdf0e10cSrcweir
311cdf0e10cSrcweir }
312