Update ooo320-m1
[ooovba.git] / shell / source / win32 / workbench / TestProxySet.cxx
blob0e1f16d81b65cdf9f5a69335e2b391163c034d3e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TestProxySet.cxx,v $
10 * $Revision: 1.6 $
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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_shell.hxx"
35 //-----------------------------------------------------------
36 // interface includes
37 //-----------------------------------------------------------
38 #include <com/sun/star/lang/XComponent.hpp>
39 #include <com/sun/star/registry/XSimpleRegistry.hpp>
40 #include <com/sun/star/system/XProxySettings.hpp>
41 #include <cppuhelper/servicefactory.hxx>
42 #include <cppuhelper/servicefactory.hxx>
43 #include <rtl/ustring.hxx>
44 #include <sal/types.h>
45 #include <osl/diagnose.h>
47 #ifdef WNT
49 #include <stdio.h>
50 #if defined _MSC_VER
51 #pragma warning(push, 1)
52 #endif
53 #include <windows.h>
54 #if defined _MSC_VER
55 #pragma warning(pop)
56 #endif
58 #endif
60 //--------------------------------------------------------------
61 // namesapces
62 //--------------------------------------------------------------
64 using namespace ::rtl ;
65 using namespace ::cppu ;
66 using namespace ::com::sun::star::uno ;
67 using namespace ::com::sun::star::lang ;
68 using namespace std ;
69 using namespace com::sun::star::system;
71 //--------------------------------------------------------------
72 // defines
73 //--------------------------------------------------------------
75 #ifdef WNT
77 #define RDB_SYSPATH "D:\\Projects\\gsl\\shell\\wntmsci7\\bin\\applicat.rdb"
79 #endif
81 //--------------------------------------------------------------
82 // global variables
83 //--------------------------------------------------------------
85 Reference< XMultiServiceFactory > g_xFactory;
87 //--------------------------------------------------------------
88 // main
89 //--------------------------------------------------------------
92 // int SAL_CALL main(int nArgc, char* Argv[], char* Env[] )
93 int SAL_CALL main(int, char*, char* )
95 //-------------------------------------------------
96 // get the global service-manager
97 //-------------------------------------------------
99 // Get global factory for uno services.
100 OUString rdbName = OUString( RTL_CONSTASCII_USTRINGPARAM( RDB_SYSPATH ) );
101 Reference< XMultiServiceFactory > g_xFactory( createRegistryServiceFactory( rdbName ) );
103 // Print a message if an error occured.
104 if ( g_xFactory.is() == sal_False )
106 OSL_ENSURE(sal_False, "Can't create RegistryServiceFactory");
107 return(-1);
110 printf("Creating RegistryServiceFactory successful\n");
112 //-------------------------------------------------
113 // try to get an Interface to a XFilePicker Service
114 //-------------------------------------------------
118 Reference< XProxySettings > xProxySettings(
119 g_xFactory->createInstance( OUString::createFromAscii( "com.sun.star.system.SystemProxySettings" ) ), UNO_QUERY );
121 if ( !xProxySettings.is() )
123 OSL_ENSURE( sal_False, "Error creating SystemProxySettings Service" );
124 return(-1);
127 printf( "Creating instance of SystemProxySettings successful\n" );
129 OUString ftpProxy = xProxySettings->getFtpProxyAddress( );
130 OUString httpProxy = xProxySettings->getHttpProxyAddress( );
131 OUString httpsProxy = xProxySettings->getHttpsProxyAddress( );
132 OUString socksProxy = xProxySettings->getSocksProxyAddress( );
133 OUString gopherProxy = xProxySettings->getGopherProxyAddress( );
135 OUString ftpProxyPort = xProxySettings->getFtpProxyPort( );
136 OUString httpProxyPort = xProxySettings->getHttpProxyPort( );
137 OUString httpsProxyPort = xProxySettings->getHttpsProxyPort( );
138 OUString socksProxyPort = xProxySettings->getSocksProxyPort( );
139 OUString gopherProxyPort = xProxySettings->getGopherProxyPort( );
141 OUString proxyBypass = xProxySettings->getProxyBypassAddress( );
143 printf( "Test of SystemProxySettings successful\n" );
145 xProxySettings = Reference< XProxySettings >(
146 g_xFactory->createInstance( OUString::createFromAscii( "com.sun.star.system.SOProxySettings" ) ), UNO_QUERY );
148 if ( !xProxySettings.is() )
150 OSL_ENSURE( sal_False, "Error creating SystemProxySettings Service" );
151 return(-1);
154 printf( "Creating instance of SOProxySettings successful\n" );
156 ftpProxy = xProxySettings->getFtpProxyAddress( );
157 httpProxy = xProxySettings->getHttpProxyAddress( );
158 httpsProxy = xProxySettings->getHttpsProxyAddress( );
159 socksProxy = xProxySettings->getSocksProxyAddress( );
160 gopherProxy = xProxySettings->getGopherProxyAddress( );
162 ftpProxyPort = xProxySettings->getFtpProxyPort( );
163 httpProxyPort = xProxySettings->getHttpProxyPort( );
164 httpsProxyPort = xProxySettings->getHttpsProxyPort( );
165 socksProxyPort = xProxySettings->getSocksProxyPort( );
166 gopherProxyPort = xProxySettings->getGopherProxyPort( );
168 proxyBypass = xProxySettings->getProxyBypassAddress( );
170 sal_Bool bProxyEnabled = xProxySettings->isProxyEnabled( );
171 if (bProxyEnabled)
173 printf("Test ProxyEnabled true\n");
176 printf( "Test of SOProxySettings successful\n" );
178 catch( Exception& )
182 //--------------------------------------------------
183 // shutdown
184 //--------------------------------------------------
186 // Cast factory to XComponent
187 Reference< XComponent > xComponent( g_xFactory, UNO_QUERY );
189 // Print a message if an error occured.
190 if ( xComponent.is() == sal_False )
192 OSL_ENSURE(sal_False, "Error shuting down");
195 // Dispose and clear factory
196 xComponent->dispose();
197 g_xFactory.clear();
198 g_xFactory = Reference< XMultiServiceFactory >();
200 printf("Test successful\n");
202 return 0;