bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / runner / helper / InetTools.java
blob1ee6622d8281ecd0d8f3ba229517d9d8ed4ee11c
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 package helper;
20 import com.sun.star.beans.PropertyValue;
21 import com.sun.star.beans.XPropertySet;
22 import com.sun.star.lang.XMultiServiceFactory;
23 import com.sun.star.uno.UnoRuntime;
25 // access the implementations via names
26 import com.sun.star.util.XChangesBatch;
28 import lib.TestParameters;
31 public class InetTools {
32 /**
33 * Helper method: sets the HTTP-Proxy to values from
34 * <code>lib.TestParameters</code>
36 public static boolean setHTTPProxy(TestParameters param){
37 XMultiServiceFactory xMSF = (XMultiServiceFactory) param.getMSF();
38 PropertyValue[] ProvArgs = new PropertyValue[1];
39 PropertyValue Arg = new PropertyValue();
40 Arg.Name = "nodepath";
41 Arg.Value = "/org.openoffice.Inet/Settings";
42 ProvArgs[0] = Arg;
44 try {
45 Object oProvider = xMSF.createInstance(
46 "com.sun.star.configuration.ConfigurationProvider");
48 XMultiServiceFactory oProviderMSF = UnoRuntime.queryInterface(
49 XMultiServiceFactory.class,
50 oProvider);
52 Object oInet = oProviderMSF.createInstanceWithArguments(
53 "com.sun.star.configuration.ConfigurationUpdateAccess",
54 ProvArgs);
56 XPropertySet oInetProps = UnoRuntime.queryInterface(
57 XPropertySet.class, oInet);
59 String HTTPProxyName = (String)param.get("HTTPProxyName");
60 String HTTPProxyPort = (String)param.get("HTTPProxyPort");
62 if ((HTTPProxyName == null) || (HTTPProxyPort == null)) {
63 return false;
66 oInetProps.setPropertyValue("ooInetHTTPProxyName", HTTPProxyName);
67 oInetProps.setPropertyValue("ooInetHTTPProxyPort", HTTPProxyPort);
68 oInetProps.setPropertyValue("ooInetProxyType", new Long(2));
70 XChangesBatch oSecureChange = UnoRuntime.queryInterface(
71 XChangesBatch.class, oInet);
72 oSecureChange.commitChanges();
74 catch(com.sun.star.uno.Exception e) {
75 e.printStackTrace();
77 return true;