1*2722ceddSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*2722ceddSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*2722ceddSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*2722ceddSAndrew Rist * distributed with this work for additional information
6*2722ceddSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*2722ceddSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*2722ceddSAndrew Rist * "License"); you may not use this file except in compliance
9*2722ceddSAndrew Rist * with the License. You may obtain a copy of the License at
10*2722ceddSAndrew Rist *
11*2722ceddSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*2722ceddSAndrew Rist *
13*2722ceddSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*2722ceddSAndrew Rist * software distributed under the License is distributed on an
15*2722ceddSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2722ceddSAndrew Rist * KIND, either express or implied. See the License for the
17*2722ceddSAndrew Rist * specific language governing permissions and limitations
18*2722ceddSAndrew Rist * under the License.
19*2722ceddSAndrew Rist *
20*2722ceddSAndrew Rist *************************************************************/
21*2722ceddSAndrew Rist
22*2722ceddSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_desktop.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "checkinstall.hxx"
28cdf0e10cSrcweir #include <com/sun/star/beans/XExactName.hpp>
29cdf0e10cSrcweir #include <com/sun/star/beans/XMaterialHolder.hpp>
30cdf0e10cSrcweir #include <com/sun/star/container/XContentEnumerationAccess.hpp>
31cdf0e10cSrcweir #include <com/sun/star/util/Date.hpp>
32cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
34cdf0e10cSrcweir #include <vcl/msgbox.hxx>
35cdf0e10cSrcweir #include <tools/date.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir using namespace rtl;
38cdf0e10cSrcweir using namespace com::sun::star::uno;
39cdf0e10cSrcweir using namespace com::sun::star::lang;
40cdf0e10cSrcweir using namespace com::sun::star::beans;
41cdf0e10cSrcweir
42cdf0e10cSrcweir namespace desktop
43cdf0e10cSrcweir {
44cdf0e10cSrcweir
CheckInstallation(OUString & rTitle)45cdf0e10cSrcweir sal_Bool CheckInstallation( OUString& rTitle )
46cdf0e10cSrcweir {
47cdf0e10cSrcweir try
48cdf0e10cSrcweir {
49cdf0e10cSrcweir Reference< XMultiServiceFactory > xSMgr = ::comphelper::getProcessServiceFactory();
50cdf0e10cSrcweir Reference< XExactName > xExactName( xSMgr->createInstance(
51cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
52cdf0e10cSrcweir "com.sun.star.comp.desktop.Evaluation" ))),
53cdf0e10cSrcweir UNO_QUERY );
54cdf0e10cSrcweir if ( xExactName.is() )
55cdf0e10cSrcweir {
56cdf0e10cSrcweir try
57cdf0e10cSrcweir {
58cdf0e10cSrcweir rTitle = xExactName->getExactName( rTitle );
59cdf0e10cSrcweir Reference< XMaterialHolder > xMaterialHolder( xExactName, UNO_QUERY );
60cdf0e10cSrcweir if ( xMaterialHolder.is() )
61cdf0e10cSrcweir {
62cdf0e10cSrcweir com::sun::star::util::Date aExpirationDate;
63cdf0e10cSrcweir Any a = xMaterialHolder->getMaterial();
64cdf0e10cSrcweir if ( a >>= aExpirationDate )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir Date aToday;
67cdf0e10cSrcweir Date aTimeBombDate( aExpirationDate.Day, aExpirationDate.Month, aExpirationDate.Year );
68cdf0e10cSrcweir if ( aToday > aTimeBombDate )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir InfoBox aInfoBox( NULL, String::CreateFromAscii( "This version has expired" ) );
71cdf0e10cSrcweir aInfoBox.Execute();
72cdf0e10cSrcweir return sal_False;
73cdf0e10cSrcweir }
74cdf0e10cSrcweir }
75cdf0e10cSrcweir
76cdf0e10cSrcweir return sal_True;
77cdf0e10cSrcweir }
78cdf0e10cSrcweir else
79cdf0e10cSrcweir {
80cdf0e10cSrcweir InfoBox aInfoBox( NULL, rTitle );
81cdf0e10cSrcweir aInfoBox.Execute();
82cdf0e10cSrcweir return sal_False;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir }
85cdf0e10cSrcweir catch ( RuntimeException& )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir // Evaluation version expired!
88cdf0e10cSrcweir return sal_False;
89cdf0e10cSrcweir }
90cdf0e10cSrcweir }
91cdf0e10cSrcweir else
92cdf0e10cSrcweir {
93cdf0e10cSrcweir Reference< com::sun::star::container::XContentEnumerationAccess > rContent( xSMgr , UNO_QUERY );
94cdf0e10cSrcweir if( rContent.is() )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir OUString sEvalService = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.office.Evaluation" ) );
97cdf0e10cSrcweir Reference < com::sun::star::container::XEnumeration > rEnum = rContent->createContentEnumeration( sEvalService );
98cdf0e10cSrcweir if ( rEnum.is() )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir InfoBox aInfoBox( NULL, rTitle );
101cdf0e10cSrcweir aInfoBox.Execute();
102cdf0e10cSrcweir return sal_False;
103cdf0e10cSrcweir }
104cdf0e10cSrcweir }
105cdf0e10cSrcweir }
106cdf0e10cSrcweir }
107cdf0e10cSrcweir catch(Exception)
108cdf0e10cSrcweir {
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
111cdf0e10cSrcweir return sal_True;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
114cdf0e10cSrcweir } // namespace desktop
115