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: checkinstall.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_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>
45 using namespace com::sun::star::uno
;
46 using namespace com::sun::star::lang
;
47 using namespace com::sun::star::beans
;
52 sal_Bool
CheckInstallation( OUString
& rTitle
)
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" ))),
61 if ( xExactName
.is() )
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
)
74 Date
aTimeBombDate( aExpirationDate
.Day
, aExpirationDate
.Month
, aExpirationDate
.Year
);
75 if ( aToday
> aTimeBombDate
)
77 InfoBox
aInfoBox( NULL
, String::CreateFromAscii( "This version has expired" ) );
87 InfoBox
aInfoBox( NULL
, rTitle
);
92 catch ( RuntimeException
& )
94 // Evaluation version expired!
100 Reference
< com::sun::star::container::XContentEnumerationAccess
> rContent( xSMgr
, UNO_QUERY
);
103 OUString sEvalService
= OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.office.Evaluation" ) );
104 Reference
< com::sun::star::container::XEnumeration
> rEnum
= rContent
->createContentEnumeration( sEvalService
);
107 InfoBox
aInfoBox( NULL
, rTitle
);
121 } // namespace desktop