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: TestProxySet.cxx,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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_shell.hxx"
35 //-----------------------------------------------------------
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>
51 #pragma warning(push, 1)
60 //--------------------------------------------------------------
62 //--------------------------------------------------------------
64 using namespace ::rtl
;
65 using namespace ::cppu
;
66 using namespace ::com::sun::star::uno
;
67 using namespace ::com::sun::star::lang
;
69 using namespace com::sun::star::system
;
71 //--------------------------------------------------------------
73 //--------------------------------------------------------------
77 #define RDB_SYSPATH "D:\\Projects\\gsl\\shell\\wntmsci7\\bin\\applicat.rdb"
81 //--------------------------------------------------------------
83 //--------------------------------------------------------------
85 Reference
< XMultiServiceFactory
> g_xFactory
;
87 //--------------------------------------------------------------
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");
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" );
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" );
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( );
173 printf("Test ProxyEnabled true\n");
176 printf( "Test of SOProxySettings successful\n" );
182 //--------------------------------------------------
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();
198 g_xFactory
= Reference
< XMultiServiceFactory
>();
200 printf("Test successful\n");