1 'encoding UTF-8 Do not remove or change this line!
2 '**************************************************************************
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: t_proxy_info.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-13 10:27:08 $
15 '* This file is part of OpenOffice.org.
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
18 '* it under the terms of the GNU Lesser General Public License version 3
19 '* only, as published by the Free Software Foundation.
21 '* OpenOffice.org is distributed in the hope that it will be useful,
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 '* GNU Lesser General Public License version 3 for more details
25 '* (a copy is included in the LICENSE file that accompanied this code).
27 '* You should have received a copy of the GNU Lesser General Public License
28 '* version 3 along with OpenOffice.org. If not, see
29 '* <http://www.openoffice.org/license.html>
30 '* for a copy of the LGPLv3 License.
32 '/******************************************************************************
34 '* owner : joerg.skottke@sun.com
36 '* short description : Tools to retrieve auxilary environment information
38 '*******************************************************************************
40 ' #1 hGetProxyInfo ' Retrieve the names and ports of the proxies
41 ' #0 hPrintProxyInstructions ' print instructions to the log
43 '\******************************************************************************
45 function hGetProxyInfo( sSection as string, sItem as string ) as string
48 '///<h3>Retrieve the names and ports of the proxies</h3>
49 '///<i>This function retrieves the names and ports of the proxies used
50 '///+ in your local network. The data is taken from a textfile that is
51 '///+ not visible on OpenOffice.org (Sun security policy)<br>
52 '///+ If the file is not found a message is printed to the log that
53 '///+ gives instructions on how to create and format such a file and
54 '///+ what other steps must be taken to make this work for your local
55 '///+ network (don't panic, it's simple!).</i><br><br>
57 '///<u>Input values:</u><br>
60 '///+<li>Section (string). Valid options:</li>
62 '///+<li>"http_proxy"</li>
63 '///+<li>"ftp_proxy"</li>
64 '///+<li>"socks_proxy"</li>
65 '///+<li>"no_proxy_for"</li>
68 '///+<li>Item (string). Valid options:</li>
70 '///+<li>"Name"</li>
71 '///+<li>"Port" (not for "no_proxy_for")</li>
77 '///<u>Return Value:</u><br>
79 '///+<li>Name or port of an item (string)</li>
81 '///+<li>Empty String on error</li>
85 const CFN = "hGetProxyInfo::"
87 dim irc as integer ' some integer returnvalue
88 dim crc as string ' some string returnvalue
90 ' This is the workfile. Make sure it exists and contains valid data
92 cFile = gTesttoolPath & "sun_global\input\proxies.txt"
93 ' cFile = gTesttoolPath & "global\input\proxies.txt"
94 cFile = convertpath ( cFile )
96 ' this is a temporary list that holds the workfile
97 dim acList( 50 ) as string
99 '///<u>Description:</u>
101 '///+<li>Open the file, read the section, abort on error</li>
102 irc = hGetDataFileSection( cFile, acList(), sSection , "" , "" )
104 qaerrorlog( CFN & "File or section not found" )
106 hPrintProxyInstructions()
110 '///+<li>Isolate the key</li>
111 crc = hGetValueForKeyAsString( acList(), sItem )
112 if ( instr( crc , "Error:" ) > 0 ) then
113 qaerrorlog( CFN & "The requested item could not be found" )
115 hPrintProxyInstructions()
119 '///+<li>Return the requested item</li>
123 hGetProxyInfo() = crc
127 '*******************************************************************************
129 function hPrintProxyInstructions()
132 printlog( "How to configure proxy settings for your local network" )
134 printlog( "1. Edit the sample configuration file" )
135 printlog( " Location: global/input/proxies.txt" )
136 printlog( " Replace servernames and ports with valid entries" )
138 printlog( "2. Edit the function hGetProxyInfo" )
139 printlog( " Make the first line with cFile = ... a comment"
140 printlog( " Make the second line with cFile = ... active"
141 printlog( " Save the file" )