summaryrefslogtreecommitdiff
path: root/svtools/source/productregistration
diff options
context:
space:
mode:
Diffstat (limited to 'svtools/source/productregistration')
-rw-r--r--svtools/source/productregistration/exports.map8
-rw-r--r--svtools/source/productregistration/makefile.mk81
-rw-r--r--svtools/source/productregistration/productregistration.cxx510
-rw-r--r--svtools/source/productregistration/productregistration.hxx103
-rw-r--r--svtools/source/productregistration/registrationdlg.cxx174
-rw-r--r--svtools/source/productregistration/registrationdlg.hrc46
-rw-r--r--svtools/source/productregistration/registrationdlg.hxx90
-rw-r--r--svtools/source/productregistration/registrationdlg.src132
8 files changed, 1144 insertions, 0 deletions
diff --git a/svtools/source/productregistration/exports.map b/svtools/source/productregistration/exports.map
new file mode 100644
index 000000000000..f4ed78b9e970
--- /dev/null
+++ b/svtools/source/productregistration/exports.map
@@ -0,0 +1,8 @@
+UDK_3_0_0 {
+ global:
+ component_getImplementationEnvironment;
+ component_writeInfo;
+ component_getFactory;
+ local:
+ *;
+};
diff --git a/svtools/source/productregistration/makefile.mk b/svtools/source/productregistration/makefile.mk
new file mode 100644
index 000000000000..bc964e142232
--- /dev/null
+++ b/svtools/source/productregistration/makefile.mk
@@ -0,0 +1,81 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.4 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=svtools
+TARGET=productregistration.uno
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+GEN_HID=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+DLLPRE=
+
+# --- Files -------------------------------------
+
+SLOFILES= \
+ $(SLO)$/productregistration.obj \
+ $(SLO)$/registrationdlg.obj
+
+SHL1TARGET= $(TARGET)
+SHL1IMPLIB= i$(TARGET)
+
+SHL1OBJS= \
+ $(SLOFILES)
+
+SHL1STDLIBS=\
+ $(TKLIB) \
+ $(VCLLIB) \
+ $(SVLLIB) \
+ $(TOOLSLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB)
+
+SHL1VERSIONMAP=exports.map
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+DEF1NAME= $(SHL1TARGET)
+
+SRS1NAME= productregistration
+SRC1FILES= \
+ registrationdlg.src
+
+RESLIB1NAME=productregistration
+RESLIB1IMAGES=$(PRJ)$/res
+RESLIB1SRSFILES=\
+ $(SRS)$/productregistration.srs
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/svtools/source/productregistration/productregistration.cxx b/svtools/source/productregistration/productregistration.cxx
new file mode 100644
index 000000000000..b3d90a73b231
--- /dev/null
+++ b/svtools/source/productregistration/productregistration.cxx
@@ -0,0 +1,510 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: productregistration.cxx,v $
+ * $Revision: 1.10 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include "productregistration.hxx"
+#include "regoptions.hxx"
+#include "registrationdlg.hxx"
+#ifndef _SVTOOLS_HRC
+#include <svtools/svtools.hrc>
+#endif
+#include "cppuhelper/factory.hxx"
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/system/XSystemShellExecute.hpp>
+#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
+#include <com/sun/star/frame/DispatchResultState.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/beans/XMaterialHolder.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+#include <osl/diagnose.h>
+
+#include <algorithm>
+#include <functional>
+#include <memory>
+
+#define PRODREG_IMPLNAME "com.sun.star.comp.setup.ProductRegistration"
+#define PRODREG_SERVNAME "com.sun.star.setup.ProductRegistration"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::container;
+
+using rtl::OUString;
+
+//........................................................................
+namespace svt
+{
+//........................................................................
+
+ using namespace ::com::sun::star::task;
+ using namespace ::com::sun::star::system;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::awt;
+
+ //-------------------------------------------------------------------
+
+ struct EqualsOUString : public ::std::unary_function< OUString, sal_Bool >
+ {
+ const OUString& m_rCompare;
+ EqualsOUString( const OUString& _rCompare ) : m_rCompare( _rCompare ) { }
+
+ sal_Bool operator() ( const OUString& _rCompare )
+ {
+ return m_rCompare.equals( _rCompare );
+ }
+ };
+
+ //====================================================================
+ //= OProductRegistration
+ //====================================================================
+
+ //--------------------------------------------------------------------
+ OProductRegistration::OProductRegistration( const Reference< XMultiServiceFactory >& _rxORB )
+ :m_xORB( _rxORB )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInterface > OProductRegistration::Create( const Reference< XMultiServiceFactory >& _rxORB )
+ {
+ return static_cast< ::cppu::OWeakObject* >( new OProductRegistration( _rxORB ) );
+ }
+
+ //--------------------------------------------------------------------
+ OUString SAL_CALL OProductRegistration::getImplementationName_Static( )
+ {
+ return OUString::createFromAscii( PRODREG_IMPLNAME );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< OUString > SAL_CALL OProductRegistration::getSupportedServiceNames_Static( ) throw (RuntimeException)
+ {
+ Sequence< OUString > aServiceNames( 1 );
+ aServiceNames[ 0 ] = OUString::createFromAscii( PRODREG_SERVNAME );
+ return aServiceNames;
+ }
+
+ //--------------------------------------------------------------------
+ OUString SAL_CALL OProductRegistration::getImplementationName( ) throw (RuntimeException)
+ {
+ return getImplementationName_Static( );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL OProductRegistration::supportsService( const OUString& _rServiceName ) throw (RuntimeException)
+ {
+ Sequence< OUString > aServiceNames( getSupportedServiceNames( ) );
+ const OUString* pNames = aServiceNames.getConstArray( );
+ const OUString* pNamesEnd = aServiceNames.getConstArray( ) + aServiceNames.getLength();
+
+ const OUString* pFound = ::std::find_if(
+ pNames,
+ pNamesEnd,
+ EqualsOUString( _rServiceName )
+ );
+ return pFound != pNamesEnd;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< OUString > SAL_CALL OProductRegistration::getSupportedServiceNames( ) throw (RuntimeException)
+ {
+ return getSupportedServiceNames_Static( );
+ }
+
+ //--------------------------------------------------------------------
+ static Reference< XFrame > lcl_getActiveFrame( const Reference< XMultiServiceFactory >& xFactory )
+ {
+ try
+ {
+ Reference< XDesktop > xDesktop(
+ xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop") ) ),
+ UNO_QUERY_THROW );
+
+ Reference< XFrame > xFrame(xDesktop->getCurrentFrame());
+ if( ! xFrame.is() )
+ {
+ // Perhaps the frames collection of the desktop knows about an "active frame"?
+ Reference< XFramesSupplier > xFrames( xDesktop, UNO_QUERY_THROW );
+ xFrame = xFrames->getActiveFrame();
+ }
+
+ return xFrame;
+ }
+ catch(const Exception& )
+ {
+ OSL_ENSURE( sal_False, "lcl_getActiveFrame: caught an exception!" );
+ return Reference< XFrame >();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ static Window* lcl_getPreferredDialogParent( const Reference< XFrame >& xFrame )
+ {
+ Window* pReturn = Application::GetDefDialogParent();
+
+ try
+ {
+ if ( xFrame.is() )
+ {
+ Reference< XWindow > xWindow = xFrame->getContainerWindow();
+ if ( xWindow.is() )
+ pReturn = VCLUnoHelper::GetWindow( xWindow );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "lcl_getPreferredDialogParent: caught an exception!" );
+ }
+
+ return pReturn;
+ }
+
+ //--------------------------------------------------------------------
+ static bool lcl_isEvalVersion( const Reference< XMultiServiceFactory >& _rxORB )
+ {
+ bool bIsEvaluationVersion = false;
+
+ try
+ {
+ Reference < XMaterialHolder > xHolder(
+ _rxORB->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.tab.tabreg" ) ) ),
+ UNO_QUERY
+ );
+
+ if ( xHolder.is() )
+ {
+ Any aData = xHolder->getMaterial();
+ Sequence < NamedValue > aSeq;
+
+ if ( aData >>= aSeq )
+ {
+ // it's an evaluation version - a non-eval version wouldn't provide this "material"
+ bIsEvaluationVersion = true;
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( false, "lcl_isEvalVersion: caught an exception!" );
+ }
+
+ return bIsEvaluationVersion;
+ }
+
+ //--------------------------------------------------------------------
+ static bool lcl_doNewStyleRegistration( const Reference< XMultiServiceFactory >& xFactory, bool online )
+ {
+ try
+ {
+ Reference< XMultiServiceFactory > xConfigProvider(
+ xFactory->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) )
+ ),
+ UNO_QUERY_THROW
+ );
+
+ PropertyValue aNodePath;
+ aNodePath.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) );
+ aNodePath.Value = makeAny( OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Jobs/Events" ) ) );
+
+ Sequence< Any > lArguments(1);
+ lArguments[0] = makeAny( aNodePath );
+
+ Reference< XHierarchicalNameAccess > xNameAccess(
+ xConfigProvider->createInstanceWithArguments(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" ) ),
+ lArguments
+ ),
+ UNO_QUERY_THROW
+ );
+
+ if( ! xNameAccess->hasByHierarchicalName( OUString( RTL_CONSTASCII_USTRINGPARAM( "onRegisterNow/JobList" ) ) ) )
+ return false;
+
+ Reference< XJobExecutor > xJobExecutor(
+ xFactory->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.JobExecutor" ) )
+ ),
+ UNO_QUERY_THROW
+ );
+
+ xJobExecutor->trigger( online ? OUString( RTL_CONSTASCII_USTRINGPARAM( "onRegisterNow" ) ) :
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "onRegisterLater" ) ) );
+
+ return true;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( false, "lcl_getOnlineRegistrationDispatch: caught an exception!" );
+ return false;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OProductRegistration::trigger( const OUString& _rEvent ) throw (RuntimeException)
+ {
+ bool registerOnline = false;
+
+ switch ( classify( _rEvent ) )
+ {
+ case etRegistrationRequired:
+ registerOnline = true;
+ break;
+
+ default:
+ break;
+ }
+
+ // prefer new style registration
+ if( ! lcl_doNewStyleRegistration(m_xORB, registerOnline ) && registerOnline )
+ doOnlineRegistration();
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL OProductRegistration::execute( const Sequence< NamedValue >& ) throw (IllegalArgumentException, Exception, RuntimeException)
+ {
+ Any aReturn;
+
+ static sal_Bool bFirstEncounter( sal_True );
+ if ( bFirstEncounter )
+ { // during this session, this event was never triggered before ....
+ bFirstEncounter = sal_False;
+
+ sal_Bool bDeactivateJob = sal_True;
+
+ // our config options
+ RegOptions aRegOptions;
+ // check them for the permissions for the dialog
+ RegOptions::DialogPermission ePermission( aRegOptions.getDialogPermission() );
+
+ if ( RegOptions::dpDisabled != ePermission )
+ { // the dialog is _not_ disabled
+
+ // for this session, I'm no interested in the dialog registration anymore
+ aRegOptions.markSessionDone( );
+
+ if ( ( RegOptions::dpNotThisSession == ePermission ) // first trigger session not reached
+ || ( RegOptions::dpRemindLater == ePermission ) // or at a later reminder date
+ )
+ { // the dialog should be executed during one of the next sessions
+ bDeactivateJob = sal_False;
+ }
+ else
+ {
+ // if we're here, the dialog should be executed during this session
+ OSL_ENSURE( RegOptions::dpThisSession == ePermission, "OProductRegistration::execute: invalid permissions!" );
+
+ {
+ // this is some kind of HACK.
+ // This registration dialog is intended to appear very very early during the
+ // first office start after installation. Unfortunately, this is so early
+ // that even SFX is not yet loaded, thus the SfxHelp class is not yet available,
+ // thus, there is no help during the lifetime of the dialog.
+ // To fake this, we explicitly load the necessary services when the user
+ // really requests help herein.
+ // #110791# - 2003-06-11 - fs@openoffice.org
+ Reference < XInitialization > xOfficeWrapper(
+ m_xORB->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.office.OfficeWrapper" ) )
+ ),
+ UNO_QUERY
+ );
+ if ( xOfficeWrapper.is() )
+ xOfficeWrapper->initialize( Sequence < Any >() );
+ }
+
+ std::auto_ptr<ResMgr> pResMgr (ResMgr::CreateResMgr (
+ CREATEVERSIONRESMGR_NAME(productregistration)));
+
+ Reference< XFrame > xFrame = lcl_getActiveFrame( m_xORB );
+ // execute it
+ RegistrationDialog aDialog (
+ lcl_getPreferredDialogParent( xFrame ),
+ ResId( DLG_REGISTRATION_REQUEST, *pResMgr.get() ),
+ lcl_isEvalVersion( m_xORB ) );
+ aDialog.Execute();
+
+ bool registerOnline = false;
+
+ switch ( aDialog.getResponse() )
+ {
+ case RegistrationDialog::urRegisterNow:
+ registerOnline = true;
+ break;
+
+ case RegistrationDialog::urRegisterLater:
+ bDeactivateJob = sal_False;
+ // remind again in seven days from now on ...
+ aRegOptions.activateReminder( 7 );
+ break;
+
+ case RegistrationDialog::urRegisterNever:
+ case RegistrationDialog::urAlreadyRegistered:
+ // never register or already registered
+ // -> deactivate the job, and nothing else
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "OProductRegistration::execute: invalid response from the dialog!" );
+ }
+
+ // prefer new style registration
+ if( ! lcl_doNewStyleRegistration(m_xORB, registerOnline) && registerOnline )
+ doOnlineRegistration();
+ }
+ }
+
+ Sequence< NamedValue > aJobResponse( 1 );
+ aJobResponse[0].Name = OUString::createFromAscii( "Deactivate" );
+ aJobResponse[0].Value <<= bDeactivateJob;
+ aReturn <<= aJobResponse;
+ }
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void OProductRegistration::doOnlineRegistration( )
+ {
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ // create the Desktop component which can load components
+ Reference< XSystemShellExecute > xSystemShell(
+ m_xORB->createInstance( OUString::createFromAscii( "com.sun.star.system.SystemShellExecute" ) ),
+ UNO_QUERY
+ );
+ OSL_ENSURE( xSystemShell.is(), "OProductRegistration::doOnlineRegistration: invalid SystemExecute component!" );
+
+ // access the configuration to retrieve the URL we shall use for registration
+ RegOptions aOptions;
+ OUString sRegistrationURL( aOptions.getRegistrationURL( ) );
+ OSL_ENSURE( sRegistrationURL.getLength(), "OProductRegistration::doOnlineRegistration: invalid URL found!" );
+
+ if ( xSystemShell.is() && sRegistrationURL.getLength() )
+ {
+ xSystemShell->execute( sRegistrationURL, OUString(), SystemShellExecuteFlags::DEFAULTS );
+ bSuccess = sal_True;
+ }
+ }
+ catch( const Exception& )
+ {
+ }
+ if ( !bSuccess )
+ {
+ std::auto_ptr<ResMgr> pResMgr (ResMgr::CreateResMgr (
+ CREATEVERSIONRESMGR_NAME(productregistration)));
+
+ ErrorBox aRegistrationError(
+ Application::GetDefDialogParent(),
+ ResId( ERRBOX_REG_NOSYSBROWSER, *pResMgr.get() ));
+ aRegistrationError.Execute();
+
+ // try again later
+ RegOptions aRegOptions;
+ aRegOptions.activateReminder( 7 );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ OProductRegistration::EventType OProductRegistration::classify( const OUString& _rEventDesc )
+ {
+ EventType eReturn = etUnknown;
+ if ( _rEventDesc.equalsAscii( "RegistrationRequired" ) )
+ {
+ eReturn = etRegistrationRequired;
+ }
+ return eReturn;
+ }
+
+//........................................................................
+} // namespace svt
+//........................................................................
+
+extern "C"
+{
+SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment (
+ const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */)
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo (
+ void * /* pServiceManager */, void * pRegistryKey)
+{
+ if (pRegistryKey)
+ {
+ Reference< XRegistryKey > xRegistryKey (
+ reinterpret_cast< XRegistryKey* >( pRegistryKey ));
+ Reference< XRegistryKey > xNewKey;
+
+ xNewKey = xRegistryKey->createKey(
+ OUString::createFromAscii( "/" PRODREG_IMPLNAME "/UNO/SERVICES" ));
+ xNewKey->createKey(
+ OUString::createFromAscii( PRODREG_SERVNAME ));
+
+ return sal_True;
+ }
+ return sal_False;
+}
+
+SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory (
+ const sal_Char * pImplementationName, void * pServiceManager, void * /* pRegistryKey */)
+{
+ void * pResult = 0;
+ if (pServiceManager)
+ {
+ Reference< XSingleServiceFactory > xFactory;
+ if (svt::OProductRegistration::getImplementationName_Static().compareToAscii (pImplementationName) == 0)
+ {
+ xFactory = cppu::createSingleFactory (
+ reinterpret_cast< XMultiServiceFactory* >(pServiceManager),
+ svt::OProductRegistration::getImplementationName_Static(),
+ svt::OProductRegistration::Create,
+ svt::OProductRegistration::getSupportedServiceNames_Static());
+ }
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pResult = xFactory.get();
+ }
+ }
+ return pResult;
+}
+
+} // extern "C"
diff --git a/svtools/source/productregistration/productregistration.hxx b/svtools/source/productregistration/productregistration.hxx
new file mode 100644
index 000000000000..6dc3dbe253e5
--- /dev/null
+++ b/svtools/source/productregistration/productregistration.hxx
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: productregistration.hxx,v $
+ * $Revision: 1.5 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SVTOOLS_PRODUCTREGISTRATION_HXX
+#define SVTOOLS_PRODUCTREGISTRATION_HXX
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/task/XJobExecutor.hpp>
+#include <com/sun/star/task/XJob.hpp>
+#include <cppuhelper/implbase3.hxx>
+
+//........................................................................
+namespace svt
+{
+//........................................................................
+
+ //====================================================================
+ //= OProductRegistration
+ //====================================================================
+ typedef ::cppu::WeakImplHelper3 < ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::task::XJobExecutor
+ , ::com::sun::star::task::XJob
+ > OProductRegistration_Base;
+
+ class OProductRegistration : public OProductRegistration_Base
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+
+ protected:
+ OProductRegistration( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB );
+
+ public:
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ Create( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB );
+
+ // XServiceInfo - static version
+ static ::rtl::OUString SAL_CALL getImplementationName_Static( );
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XJobExecutor
+ virtual void SAL_CALL trigger( const ::rtl::OUString& sEvent ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XJob
+ virtual ::com::sun::star::uno::Any SAL_CALL execute( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& _rArgs ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ private:
+ // types of events which can be handled by this component
+ enum EventType
+ {
+ etRegistrationRequired,
+
+ etUnknown
+ };
+
+ // classifies a event
+ EventType classify( const ::rtl::OUString& _rEventDesc );
+
+ // do the online registration
+ void doOnlineRegistration( );
+ };
+
+//........................................................................
+} // namespace svt
+//........................................................................
+
+#endif // SVTOOLS_PRODUCTREGISTRATION_HXX
+
diff --git a/svtools/source/productregistration/registrationdlg.cxx b/svtools/source/productregistration/registrationdlg.cxx
new file mode 100644
index 000000000000..83018cfa804b
--- /dev/null
+++ b/svtools/source/productregistration/registrationdlg.cxx
@@ -0,0 +1,174 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: registrationdlg.cxx,v $
+ * $Revision: 1.8 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include "registrationdlg.hxx"
+
+#if 0 /* @@@ */
+#include <svtools/svtdata.hxx>
+#ifndef _SVTOOLS_HRC
+#include <svtools/svtools.hrc>
+#endif
+#endif /* @@@ */
+
+#ifndef SVTOOLS_REGISTRATIONDLG_HRC
+#include "registrationdlg.hrc"
+#endif
+#include <vcl/msgbox.hxx>
+#include <tools/debug.hxx>
+
+//........................................................................
+namespace svt
+{
+//........................................................................
+
+ static void lcl_moveControls( Control** _ppControls, sal_Int32 _nAmount )
+ {
+ if ( _ppControls )
+ while ( *_ppControls )
+ {
+ Point aPos = (*_ppControls)->GetPosPixel();
+ aPos.Y() += _nAmount;
+ (*_ppControls)->SetPosPixel( aPos );
+
+ ++_ppControls;
+ }
+ }
+
+ //====================================================================
+ //= RegistrationDialog
+ //====================================================================
+ //--------------------------------------------------------------------
+ RegistrationDialog::RegistrationDialog( Window* _pWindow, const ResId& _rResId, bool _bEvalVersion )
+ :ModalDialog( _pWindow, _rResId )
+ ,m_eResponse ( urRegisterLater )
+ ,m_aLogo ( this, ResId( FI_LOGO, *_rResId.GetResMgr() ) )
+ ,m_aIntro ( this, ResId( FT_INTRO, *_rResId.GetResMgr() ) )
+ ,m_aNow ( this, ResId( RB_NOW, *_rResId.GetResMgr() ) )
+ ,m_aLater ( this, ResId( RB_LATER, *_rResId.GetResMgr() ) )
+ ,m_aNever ( this, ResId( RB_NEVER, *_rResId.GetResMgr() ) )
+ ,m_aAlreadyDone ( this, ResId( RB_DONE, *_rResId.GetResMgr() ) )
+ ,m_aSeparator ( this, ResId( FL_SEPARATOR, *_rResId.GetResMgr() ) )
+ ,m_aOK ( this, ResId( BTN_OK, *_rResId.GetResMgr() ) )
+ ,m_aHelp ( this, ResId( BTN_HELP, *_rResId.GetResMgr() ) )
+ {
+ if ( _bEvalVersion )
+ { // if we're an eval version, we need to hide two of the options
+ m_aNever.Hide( );
+ m_aAlreadyDone.Hide( );
+
+ // make the explanatory text somewhat smaller
+ Size aIntroSize = m_aIntro.GetSizePixel();
+ aIntroSize.Height() = LogicToPixel( Size( 0, 18 ), MAP_APPFONT ).Height();
+ sal_Int32 nHeightDifference = m_aIntro.GetSizePixel().Height() - aIntroSize.Height();
+ m_aIntro.SetSizePixel( aIntroSize );
+
+ // resize the dialog, and move the controls below the ones we just hided
+ sal_Int32 nAlreadyDoneLower = m_aAlreadyDone.GetPosPixel().Y() + m_aAlreadyDone.GetSizePixel().Height();
+ sal_Int32 nLaterLower = m_aLater.GetPosPixel().Y() + m_aLater.GetSizePixel().Height();
+ sal_Int32 nDifference = nAlreadyDoneLower - nLaterLower;
+
+ sal_Int32 nOverallDifference = nDifference + nHeightDifference;
+
+ // move
+ Control* pVisibleRadios[] = { &m_aNow, &m_aLater, NULL };
+ lcl_moveControls( pVisibleRadios, -nHeightDifference );
+
+ Control* pControlsToMove[] = { &m_aSeparator, &m_aOK, &m_aHelp, NULL };
+ lcl_moveControls( pControlsToMove, -nOverallDifference );
+
+ // resize the dialog
+ Size aSize = GetSizePixel();
+ aSize.Height() -= nOverallDifference;
+ SetSizePixel( aSize );
+ }
+ else
+ {
+ // the explanatory text needs to be completed
+ String sCompleteIntro = m_aIntro.GetText( );
+ sCompleteIntro += String( ResId( STR_COMPLETE_INTRO, *_rResId.GetResMgr() ) );
+ m_aIntro.SetText( sCompleteIntro );
+ }
+
+ FreeResource();
+
+ m_aNow.Check( TRUE );
+ }
+
+ //--------------------------------------------------------------------
+ short RegistrationDialog::Execute()
+ {
+ short nResult = ModalDialog::Execute();
+
+ // as a default, assume that the user wants to be reminded
+ m_eResponse = urRegisterLater;
+
+ if ( RET_OK == nResult )
+ {
+ if ( m_aNow.IsChecked() )
+ m_eResponse = urRegisterNow;
+ else if ( m_aLater.IsChecked() )
+ m_eResponse = urRegisterLater;
+ else if ( m_aNever.IsChecked() )
+ m_eResponse = urRegisterNever;
+ else if ( m_aAlreadyDone.IsChecked() )
+ m_eResponse = urAlreadyRegistered;
+#ifdef DBG_UTIL
+ else
+ {
+ DBG_ERROR( "RegistrationDialog::Execute: invalid dialog state!" );
+ }
+#endif
+ }
+ return nResult;
+ }
+ //--------------------------------------------------------------------
+ long RegistrationDialog::PreNotify( NotifyEvent& rNEvt )
+ {
+ long nHandled;
+ if( rNEvt.GetType() == EVENT_KEYINPUT &&
+ rNEvt.GetKeyEvent()->GetCharCode() &&
+ rNEvt.GetKeyEvent()->GetKeyCode().GetCode() == KEY_ESCAPE)
+ {
+ EndDialog(RET_CANCEL);
+ nHandled = 1;
+ }
+ else
+ nHandled = ModalDialog::PreNotify( rNEvt );
+ return nHandled;
+ }
+
+
+//........................................................................
+} // namespace svt
+//........................................................................
+
+
diff --git a/svtools/source/productregistration/registrationdlg.hrc b/svtools/source/productregistration/registrationdlg.hrc
new file mode 100644
index 000000000000..d62e5b1dfcca
--- /dev/null
+++ b/svtools/source/productregistration/registrationdlg.hrc
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: registrationdlg.hrc,v $
+ * $Revision: 1.5 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SVTOOLS_REGISTRATIONDLG_HRC
+#define SVTOOLS_REGISTRATIONDLG_HRC
+
+#define FI_LOGO 1
+#define FT_INTRO 2
+#define RB_NOW 3
+#define RB_LATER 4
+#define RB_NEVER 5
+#define RB_DONE 6
+#define FL_SEPARATOR 7
+#define BTN_OK 8
+#define BTN_HELP 9
+#define STR_COMPLETE_INTRO 10
+
+#endif // SVTOOLS_REGISTRATIONDLG_HRC
+
diff --git a/svtools/source/productregistration/registrationdlg.hxx b/svtools/source/productregistration/registrationdlg.hxx
new file mode 100644
index 000000000000..ce1bf08ac950
--- /dev/null
+++ b/svtools/source/productregistration/registrationdlg.hxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: registrationdlg.hxx,v $
+ * $Revision: 1.4 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SVTOOLS_REGISTRATIONDLG_HXX
+#define SVTOOLS_REGISTRATIONDLG_HXX
+
+#include <vcl/fixed.hxx>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <vcl/dialog.hxx>
+
+//........................................................................
+namespace svt
+{
+//........................................................................
+
+ //====================================================================
+ //= RegistrationDialog
+ //====================================================================
+ class RegistrationDialog : public ModalDialog
+ {
+ public:
+ enum UserResponse
+ {
+ urRegisterNow,
+ urRegisterLater,
+ urRegisterNever,
+ urAlreadyRegistered
+ };
+
+ private:
+ UserResponse m_eResponse;
+
+ FixedImage m_aLogo;
+ FixedText m_aIntro;
+
+ RadioButton m_aNow;
+ RadioButton m_aLater;
+ RadioButton m_aNever;
+ RadioButton m_aAlreadyDone;
+
+ FixedLine m_aSeparator;
+
+ OKButton m_aOK;
+ HelpButton m_aHelp;
+
+ public:
+ RegistrationDialog( Window* _pWindow, const ResId& _rResId, bool _bEvalVersion );
+
+ virtual short Execute();
+ virtual long PreNotify( NotifyEvent& rNEvt );
+
+ inline UserResponse getResponse() const { return m_eResponse; }
+ };
+
+
+
+//........................................................................
+}// namespace svt
+//........................................................................
+
+#endif // SVTOOLS_REGISTRATIONDLG_HXX
diff --git a/svtools/source/productregistration/registrationdlg.src b/svtools/source/productregistration/registrationdlg.src
new file mode 100644
index 000000000000..86024ef765cd
--- /dev/null
+++ b/svtools/source/productregistration/registrationdlg.src
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: registrationdlg.src,v $
+ * $Revision: 1.7 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SVTOOLS_REGISTRATIONDLG_HRC
+#include "registrationdlg.hrc"
+#endif
+#ifndef _SVTOOLS_HRC
+#include <svtools/svtools.hrc>
+#endif
+#ifndef _SVT_HELPID_HRC
+#include <svtools/helpid.hrc>
+#endif
+
+ModalDialog DLG_REGISTRATION_REQUEST
+{
+ HelpID = HID_REGISTRATION_DIALOG;
+ Moveable = TRUE ;
+ Closeable = TRUE;
+ OutputSize = TRUE ;
+ Size = MAP_APPFONT ( 192 , 134 ) ;
+ Text [ en-US ] = "%PRODUCTNAME Registration";
+
+ FixedImage FI_LOGO
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 24 , 24 ) ;
+ Fixed = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "regkey.bmp" ;
+ };
+ MaskColor = Color { Red = 0x0000 ; Green = 0x0000 ; Blue = 0xFFFF ; };
+ };
+ };
+ FixedText FT_INTRO
+ {
+ Pos = MAP_APPFONT ( 33, 6 ) ;
+ Size = MAP_APPFONT ( 153 , 32 ) ;
+ WordBreak = TRUE;
+ Text [ en-US ] = "You now have the opportunity to register as a %PRODUCTNAME user." ;
+ };
+
+ String STR_COMPLETE_INTRO
+ {
+ Text [ en-US ] = " Registration is voluntary and is without obligation." ;
+ };
+
+ RadioButton RB_NOW
+ {
+ Pos = MAP_APPFONT ( 33 , 41 ) ;
+ Size = MAP_APPFONT ( 153 , 10 ) ;
+ Text [ en-US ] = "Register now" ;
+ };
+
+ RadioButton RB_LATER
+ {
+ Pos = MAP_APPFONT ( 33 , 54 ) ;
+ Size = MAP_APPFONT ( 153 , 10 ) ;
+ Text [ en-US ] = "Remind me to register later" ;
+ };
+ RadioButton RB_NEVER
+ {
+ Pos = MAP_APPFONT ( 33 , 67 ) ;
+ Size = MAP_APPFONT ( 153 , 10 ) ;
+ Text [ en-US ] = "Never register" ;
+ };
+ RadioButton RB_DONE
+ {
+ Pos = MAP_APPFONT ( 33 , 80 ) ;
+ Size = MAP_APPFONT ( 153 , 20 ) ;
+ WordBreak = TRUE;
+
+ Text [ en-US ] = "Already registered as %PRODUCTNAME %PRODUCTVERSION user." ;
+ };
+
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 6, 107 ) ;
+ Size = MAP_APPFONT ( 180 , 1 ) ;
+ };
+
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 80, 114 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE;
+ };
+
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 136, 114 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+};
+
+ErrorBox ERRBOX_REG_NOSYSBROWSER
+{
+ BUTTONS = WB_OK ;
+ DEFBUTTON = WB_DEF_OK ;
+
+ Message [ en-US ] = "An error occurred in starting the web browser.\nPlease check the %PRODUCTNAME and web browser settings.";
+};
+
+