1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_desktop.hxx" 30 31 #include "checkinstall.hxx" 32 #include <com/sun/star/beans/XExactName.hpp> 33 #include <com/sun/star/beans/XMaterialHolder.hpp> 34 #include <com/sun/star/container/XContentEnumerationAccess.hpp> 35 #include <com/sun/star/util/Date.hpp> 36 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 37 #include <comphelper/processfactory.hxx> 38 #include <vcl/msgbox.hxx> 39 #include <tools/date.hxx> 40 41 using namespace rtl; 42 using namespace com::sun::star::uno; 43 using namespace com::sun::star::lang; 44 using namespace com::sun::star::beans; 45 46 namespace desktop 47 { 48 49 sal_Bool CheckInstallation( OUString& rTitle ) 50 { 51 try 52 { 53 Reference< XMultiServiceFactory > xSMgr = ::comphelper::getProcessServiceFactory(); 54 Reference< XExactName > xExactName( xSMgr->createInstance( 55 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 56 "com.sun.star.comp.desktop.Evaluation" ))), 57 UNO_QUERY ); 58 if ( xExactName.is() ) 59 { 60 try 61 { 62 rTitle = xExactName->getExactName( rTitle ); 63 Reference< XMaterialHolder > xMaterialHolder( xExactName, UNO_QUERY ); 64 if ( xMaterialHolder.is() ) 65 { 66 com::sun::star::util::Date aExpirationDate; 67 Any a = xMaterialHolder->getMaterial(); 68 if ( a >>= aExpirationDate ) 69 { 70 Date aToday; 71 Date aTimeBombDate( aExpirationDate.Day, aExpirationDate.Month, aExpirationDate.Year ); 72 if ( aToday > aTimeBombDate ) 73 { 74 InfoBox aInfoBox( NULL, String::CreateFromAscii( "This version has expired" ) ); 75 aInfoBox.Execute(); 76 return sal_False; 77 } 78 } 79 80 return sal_True; 81 } 82 else 83 { 84 InfoBox aInfoBox( NULL, rTitle ); 85 aInfoBox.Execute(); 86 return sal_False; 87 } 88 } 89 catch ( RuntimeException& ) 90 { 91 // Evaluation version expired! 92 return sal_False; 93 } 94 } 95 else 96 { 97 Reference< com::sun::star::container::XContentEnumerationAccess > rContent( xSMgr , UNO_QUERY ); 98 if( rContent.is() ) 99 { 100 OUString sEvalService = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.office.Evaluation" ) ); 101 Reference < com::sun::star::container::XEnumeration > rEnum = rContent->createContentEnumeration( sEvalService ); 102 if ( rEnum.is() ) 103 { 104 InfoBox aInfoBox( NULL, rTitle ); 105 aInfoBox.Execute(); 106 return sal_False; 107 } 108 } 109 } 110 } 111 catch(Exception) 112 { 113 } 114 115 return sal_True; 116 } 117 118 } // namespace desktop 119