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_server_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 information about available servers
38 '*******************************************************************************
40 ' #1 hGetServerInfo ' Retrieve names and services of some servers
41 ' #0 hPrintServerInstructions ' print instructions to the log
43 '\******************************************************************************
45 function hGetServerInfo( sType as string, sItem as string ) as string
48 '///<h3>Retrieve names and services of some servers</h3>
49 '///<i>This function retrieves some information about available
50 '///+ servers within the LAN. These services can be anything like
51 '///+ http-server, ftp etc.<br>
52 '///+ Please make sure you read the comments in the configuration
53 '///+ file to fully understand what this thing does.</i><br><br>
55 '///<u>Input values:</u><br>
58 '///+<li>Type (string). Valid options:</li>
60 '///+<li>"http_internal"</li>
61 '///+<li>"http_external"</li>
62 '///+<li>"ftp_internal"</li>
63 '///+<li>"ftp_external"</li>
66 '///+<li>Item (string). Valid options:</li>
68 '///+<li>"Name" to get a name for the server</li>
69 '///+<li>"Port" to get the server's port</li>
70 '///+<li>"Protocol" to get the supported protocol</li>
71 '///+<li>"URL" to get the url (e.g. www.heise.de)</li>
72 '///+<li>"UseProxy" to find out whether proxies are needed or not</li>
73 '///+<li>"User" to get a loginname</li>
74 '///+<li>"Pass" to get a password</li>
80 '///<u>Return Value:</u><br>
82 '///+<li>Name, port or other info of an item (string)</li>
84 '///+<li>Empty String on error</li>
85 '///+<li>Unique name for a server (can be NIS name)</li>
86 '///+<li>Port (optional, e.g. 80 for http, 21 for ftp ...)</li>
87 '///+<li>Protocol (e.g. "http://" or "ftp://"</li>
88 '///+<li>URL like www.mydomain.de</li>
89 '///+<li>UseProxy ("yes"/"no")</li>
90 '///+<li>User (some username)</li>
91 '///+<li>Password (some password, plain text!)
95 const CFN = "hGetServerInfo::"
97 dim irc as integer ' some integer returnvalue
98 dim crc as string ' some string returnvalue
100 ' This is the workfile. Make sure it exists and contains valid data
102 cFile = gTesttoolPath & "sun_global\input\servers.txt"
103 ' cFile = gTesttoolPath & "global\input\servers.txt"
104 cFile = convertpath ( cFile )
106 ' this is a temporary list that holds the workfile
107 dim acList( 50 ) as string
109 '///<u>Description:</u>
111 '///+<li>Open the file, read the section, abort on error</li>
112 irc = hGetDataFileSection( cFile, acList(), sType , "" , "" )
114 qaerrorlog( CFN & "File or section not found" )
115 hGetServerInfo() = ""
116 hPrintServerInstructions()
120 '///+<li>Isolate the key</li>
121 crc = hGetValueForKeyAsString( acList(), sItem )
122 if ( instr( crc , "Error:" ) > 0 ) then
123 qaerrorlog( CFN & "The requested item could not be found" )
124 hGetServerInfo() = ""
125 hPrintServerInstructions()
129 '///+<li>Return the requested item</li>
133 hGetServerInfo() = crc
137 '*******************************************************************************
139 function hPrintServerInstructions()
142 printlog( "How to configure server settings for your local network" )
144 printlog( "1. Edit the sample configuration file" )
145 printlog( " Location: global/input/servers.txt" )
146 printlog( " Replace servernames, ports etc. with valid entries" )
148 printlog( "2. Edit the function hGetServerInfo" )
149 printlog( " Make the first line with cFile = ... a comment"
150 printlog( " Make the second line with cFile = ... active"
151 printlog( " Save the file" )