Update ooo320-m1
[ooovba.git] / desktop / source / app / checkinstall.cxx
blobacdd15a0c84b9f7e2b1ea450a83f7aa39c851e2f
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: checkinstall.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_desktop.hxx"
34 #include "checkinstall.hxx"
35 #include <com/sun/star/beans/XExactName.hpp>
36 #include <com/sun/star/beans/XMaterialHolder.hpp>
37 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
38 #include <com/sun/star/util/Date.hpp>
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40 #include <comphelper/processfactory.hxx>
41 #include <vcl/msgbox.hxx>
42 #include <tools/date.hxx>
44 using namespace rtl;
45 using namespace com::sun::star::uno;
46 using namespace com::sun::star::lang;
47 using namespace com::sun::star::beans;
49 namespace desktop
52 sal_Bool CheckInstallation( OUString& rTitle )
54 try
56 Reference< XMultiServiceFactory > xSMgr = ::comphelper::getProcessServiceFactory();
57 Reference< XExactName > xExactName( xSMgr->createInstance(
58 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
59 "com.sun.star.comp.desktop.Evaluation" ))),
60 UNO_QUERY );
61 if ( xExactName.is() )
63 try
65 rTitle = xExactName->getExactName( rTitle );
66 Reference< XMaterialHolder > xMaterialHolder( xExactName, UNO_QUERY );
67 if ( xMaterialHolder.is() )
69 com::sun::star::util::Date aExpirationDate;
70 Any a = xMaterialHolder->getMaterial();
71 if ( a >>= aExpirationDate )
73 Date aToday;
74 Date aTimeBombDate( aExpirationDate.Day, aExpirationDate.Month, aExpirationDate.Year );
75 if ( aToday > aTimeBombDate )
77 InfoBox aInfoBox( NULL, String::CreateFromAscii( "This version has expired" ) );
78 aInfoBox.Execute();
79 return sal_False;
83 return sal_True;
85 else
87 InfoBox aInfoBox( NULL, rTitle );
88 aInfoBox.Execute();
89 return sal_False;
92 catch ( RuntimeException& )
94 // Evaluation version expired!
95 return sal_False;
98 else
100 Reference< com::sun::star::container::XContentEnumerationAccess > rContent( xSMgr , UNO_QUERY );
101 if( rContent.is() )
103 OUString sEvalService = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.office.Evaluation" ) );
104 Reference < com::sun::star::container::XEnumeration > rEnum = rContent->createContentEnumeration( sEvalService );
105 if ( rEnum.is() )
107 InfoBox aInfoBox( NULL, rTitle );
108 aInfoBox.Execute();
109 return sal_False;
114 catch(Exception)
118 return sal_True;
121 } // namespace desktop