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: InetTools.java,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 ************************************************************************/
32 import com
.sun
.star
.beans
.PropertyValue
;
33 import com
.sun
.star
.beans
.XPropertySet
;
34 import com
.sun
.star
.lang
.XMultiServiceFactory
;
35 import com
.sun
.star
.uno
.UnoRuntime
;
37 // access the implementations via names
38 import com
.sun
.star
.util
.XChangesBatch
;
40 import lib
.TestParameters
;
43 public class InetTools
{
45 * Helper method: sets the HTTP-Proxy to values from
46 * <code>lib.TestParameters</code>
48 public static boolean setHTTPProxy(TestParameters param
){
49 XMultiServiceFactory xMSF
= (XMultiServiceFactory
) param
.getMSF();
50 PropertyValue
[] ProvArgs
= new PropertyValue
[1];
51 PropertyValue Arg
= new PropertyValue();
52 Arg
.Name
= "nodepath";
53 Arg
.Value
= "/org.openoffice.Inet/Settings";
57 Object oProvider
= xMSF
.createInstance(
58 "com.sun.star.configuration.ConfigurationProvider");
60 XMultiServiceFactory oProviderMSF
= (XMultiServiceFactory
) UnoRuntime
.queryInterface(
61 XMultiServiceFactory
.class,
64 Object oInet
= oProviderMSF
.createInstanceWithArguments(
65 "com.sun.star.configuration.ConfigurationUpdateAccess",
68 XPropertySet oInetProps
= (XPropertySet
) UnoRuntime
.queryInterface(
69 XPropertySet
.class, oInet
);
71 String HTTPProxyName
= (String
)param
.get("HTTPProxyName");
72 String HTTPProxyPort
= (String
)param
.get("HTTPProxyPort");
74 if ((HTTPProxyName
== null) || (HTTPProxyPort
== null)) {
78 oInetProps
.setPropertyValue("ooInetHTTPProxyName", HTTPProxyName
);
79 oInetProps
.setPropertyValue("ooInetHTTPProxyPort", HTTPProxyPort
);
80 oInetProps
.setPropertyValue("ooInetProxyType", new Long(2));
82 XChangesBatch oSecureChange
= (XChangesBatch
) UnoRuntime
.queryInterface(
83 XChangesBatch
.class, oInet
);
84 oSecureChange
.commitChanges();
86 catch(com
.sun
.star
.uno
.Exception e
) {