update dev300-m58
[ooovba.git] / xmlsecurity / tools / demo / mozprofile.cxx
blobc0cc60c58bc2f8df5b3f967ac960dbf8837def56
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: mozprofile.cxx,v $
10 * $Revision: 1.5 $
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_xmlsecurity.hxx"
34 #include "util.hxx"
36 #include <stdio.h>
37 #include <tools/date.hxx>
38 #include <tools/time.hxx>
39 #include <cppuhelper/servicefactory.hxx>
41 #include <xmlsecurity/biginteger.hxx>
42 #include <xmlsecurity/xmlsignaturehelper.hxx>
43 #include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
45 using namespace ::com::sun::star;
47 int SAL_CALL main( int argc, char **argv )
49 fprintf( stdout, "\nTesting Mozilla Profile Detection...\n\nOpenOffice.org will use the first detected profile.\nResults might be different when started in OOo program folder!\n" ) ;
51 uno::Reference< lang::XMultiServiceFactory > xMSF = CreateDemoServiceFactory();
52 if ( !xMSF.is() )
54 fprintf( stdout, "\n\nERROR: Can't create Service Factory\n" );
55 exit (-1);
58 uno::Reference<mozilla::XMozillaBootstrap> xMozillaBootstrap( xMSF->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap" ) ) ), uno::UNO_QUERY );
59 if ( !xMozillaBootstrap.is() )
61 fprintf( stdout, "\n\nERROR: Can't create Mozilla Bootstrap Service\n" );
62 exit (-1);
65 int nProducts = 4;
66 mozilla::MozillaProductType productTypes[4] = { mozilla::MozillaProductType_Thunderbird, mozilla::MozillaProductType_Mozilla, mozilla::MozillaProductType_Firefox, mozilla::MozillaProductType_Default };
67 for ( int i = 0; i < nProducts; i++)
69 if ( i == 0 )
70 fprintf( stdout, "\nThunderbird: " );
71 else if ( i == 1 )
72 fprintf( stdout, "\nMozilla: " );
73 else if ( i == 2 )
74 fprintf( stdout, "\nFireFox: " );
75 else
76 fprintf( stdout, "\nDefault: " );
78 ::rtl::OUString profile = xMozillaBootstrap->getDefaultProfile(productTypes[i]);
79 if ( profile.getLength() )
81 ::rtl::OUString profilepath = xMozillaBootstrap->getProfilePath(productTypes[i],profile);
82 fprintf( stdout, "Name=%s, Path=%s", rtl::OUStringToOString( profile , RTL_TEXTENCODING_ASCII_US ).getStr(), rtl::OUStringToOString( profilepath , RTL_TEXTENCODING_ASCII_US ).getStr() );
84 else
86 fprintf( stdout, "NOT FOUND" );
91 * creates a signature helper
93 XMLSignatureHelper aSignatureHelper( xMSF );
96 * creates a security context.
98 rtl::OUString aCryptoToken;
99 bool bInit = aSignatureHelper.Init( aCryptoToken );
100 if ( !bInit )
102 fprintf( stdout, "\n\nERROR: Unable to initialize security environment.\n\n" );
104 else
106 fprintf( stdout, "\n\nSecurity environment can be initialized successfully.\n\n" );
109 return 0;