app.cxx (910823ae) | app.cxx (281431db) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 146 unchanged lines hidden (view full) --- 155#include <unotools/misccfg.hxx> 156#include <svtools/filter.hxx> 157 158#include "langselect.hxx" 159 160#include "com/sun/star/deployment/ExtensionManager.hpp" 161#include "com/sun/star/deployment/XExtensionManager.hpp" 162#include "com/sun/star/task/XInteractionApprove.hpp" | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 146 unchanged lines hidden (view full) --- 155#include <unotools/misccfg.hxx> 156#include <svtools/filter.hxx> 157 158#include "langselect.hxx" 159 160#include "com/sun/star/deployment/ExtensionManager.hpp" 161#include "com/sun/star/deployment/XExtensionManager.hpp" 162#include "com/sun/star/task/XInteractionApprove.hpp" |
163#include "com/sun/star/task/XInteractionAbort.hpp" |
|
163#include "cppuhelper/compbase3.hxx" 164#include <hash_set> 165 | 164#include "cppuhelper/compbase3.hxx" 165#include <hash_set> 166 |
167#include "com/sun/star/deployment/VersionException.hpp" 168#include <dp_gui_handleversionexception.hxx> 169 |
|
166#if defined MACOSX 167#include <errno.h> 168#include <sys/wait.h> 169#endif 170 171#define DEFINE_CONST_UNICODE(CONSTASCII) UniString(RTL_CONSTASCII_USTRINGPARAM(CONSTASCII)) 172#define OUSTR(x) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(x)) 173#define U2S(STRING) ::rtl::OUStringToOString(STRING, RTL_TEXTENCODING_UTF8) 174 175using namespace vos; 176using namespace rtl; 177 178using namespace ::com::sun::star::uno; 179using namespace ::com::sun::star::util; 180using namespace ::com::sun::star::lang; 181using namespace ::com::sun::star::beans; | 170#if defined MACOSX 171#include <errno.h> 172#include <sys/wait.h> 173#endif 174 175#define DEFINE_CONST_UNICODE(CONSTASCII) UniString(RTL_CONSTASCII_USTRINGPARAM(CONSTASCII)) 176#define OUSTR(x) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(x)) 177#define U2S(STRING) ::rtl::OUStringToOString(STRING, RTL_TEXTENCODING_UTF8) 178 179using namespace vos; 180using namespace rtl; 181 182using namespace ::com::sun::star::uno; 183using namespace ::com::sun::star::util; 184using namespace ::com::sun::star::lang; 185using namespace ::com::sun::star::beans; |
182//using namespace ::com::sun::star::bridge; | |
183using namespace ::com::sun::star::frame; 184using namespace ::com::sun::star::document; 185using namespace ::com::sun::star::view; 186using namespace ::com::sun::star::task; 187using namespace ::com::sun::star::system; 188using namespace ::com::sun::star::ui::dialogs; 189using namespace ::com::sun::star::container; 190 --- 597 unchanged lines hidden (view full) --- 788 {} 789}; 790 791// MinimalCommandEnv's XInteractionHandler simply approves 792void MinimalCommandEnv::handle( 793 css::uno::Reference< css::task::XInteractionRequest> const& xRequest) 794 throw ( css::uno::RuntimeException ) 795{ | 186using namespace ::com::sun::star::frame; 187using namespace ::com::sun::star::document; 188using namespace ::com::sun::star::view; 189using namespace ::com::sun::star::task; 190using namespace ::com::sun::star::system; 191using namespace ::com::sun::star::ui::dialogs; 192using namespace ::com::sun::star::container; 193 --- 597 unchanged lines hidden (view full) --- 791 {} 792}; 793 794// MinimalCommandEnv's XInteractionHandler simply approves 795void MinimalCommandEnv::handle( 796 css::uno::Reference< css::task::XInteractionRequest> const& xRequest) 797 throw ( css::uno::RuntimeException ) 798{ |
796 const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > conts( xRequest->getContinuations()); 797 const css::uno::Reference< css::task::XInteractionContinuation>* pConts = conts.getConstArray(); 798 const sal_Int32 len = conts.getLength(); 799 for( sal_Int32 pos = 0; pos < len; ++pos ) 800 { 801 css::uno::Reference< css::task::XInteractionApprove> xInteractionApprove( pConts[ pos ], css::uno::UNO_QUERY); 802 if( xInteractionApprove.is()) { 803 xInteractionApprove->select(); 804 // don't query again for ongoing continuations: 805 break; 806 } 807 } | 799 bool bApprove = true; 800 801 css::deployment::VersionException verExc; 802 if ( xRequest->getRequest() >>= verExc ) 803 { 804 // user interaction, if an extension is already been installed. 805 bApprove = dp_gui::handleVersionException( verExc ); 806 } 807 808 const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > conts( xRequest->getContinuations()); 809 const css::uno::Reference< css::task::XInteractionContinuation>* pConts = conts.getConstArray(); 810 const sal_Int32 len = conts.getLength(); 811 for( sal_Int32 pos = 0; pos < len; ++pos ) 812 { 813 if ( bApprove ) 814 { 815 css::uno::Reference< css::task::XInteractionApprove> xInteractionApprove( pConts[ pos ], css::uno::UNO_QUERY); 816 if( xInteractionApprove.is()) 817 { 818 xInteractionApprove->select(); 819 // don't query again for ongoing continuations: 820 break; 821 } 822 } 823 else 824 { 825 css::uno::Reference< css::task::XInteractionAbort > xInteractionAbort( pConts[ pos ], css::uno::UNO_QUERY ); 826 if (xInteractionAbort.is()) 827 { 828 xInteractionAbort->select(); 829 // don't query again for ongoing continuations: 830 break; 831 } 832 } 833 } |
808} 809 810 811/** Check if installBundledExtensionBlobs() has to be run. 812 It uses the time stamps of a marker file (rsMarkerURL) on the one 813 hand and of the files in the given directory on the other. 814 Returns </TRUE> when either the marker does not yet exist or any 815 file in the given directory is newer than the marker. --- 62 unchanged lines hidden (view full) --- 878 // No file in the directory is newer than the marker. 879 return false; 880} 881 882 883// install bundled but non-pre-registered extension blobs 884static void installBundledExtensionBlobs() 885{ | 834} 835 836 837/** Check if installBundledExtensionBlobs() has to be run. 838 It uses the time stamps of a marker file (rsMarkerURL) on the one 839 hand and of the files in the given directory on the other. 840 Returns </TRUE> when either the marker does not yet exist or any 841 file in the given directory is newer than the marker. --- 62 unchanged lines hidden (view full) --- 904 // No file in the directory is newer than the marker. 905 return false; 906} 907 908 909// install bundled but non-pre-registered extension blobs 910static void installBundledExtensionBlobs() 911{ |
886 rtl::OUString aDirUrl( OUSTR("$OOO_BASE_DIR/share/extensions/install")); 887 ::rtl::Bootstrap::expandMacros( aDirUrl); 888 ::osl::Directory aDir( aDirUrl); | 912 rtl::OUString aDirUrl( OUSTR("$OOO_BASE_DIR/share/extensions/install")); 913 ::rtl::Bootstrap::expandMacros( aDirUrl); |
889 890 // Find out if we can exit early: only when there is an extension file newer 891 // than the marker we have to install any extension. 892 ::rtl::OUString sMarkerURL (RTL_CONSTASCII_USTRINGPARAM("$BUNDLED_EXTENSIONS_USER/lastsynchronized.bundled")); 893 ::rtl::Bootstrap::expandMacros(sMarkerURL); 894 if ( ! needsInstallBundledExtensionBlobs(sMarkerURL, aDirUrl)) 895 return; 896 writeLastModified(sMarkerURL); 897 898 // get the ExtensionManager | 914 915 // Find out if we can exit early: only when there is an extension file newer 916 // than the marker we have to install any extension. 917 ::rtl::OUString sMarkerURL (RTL_CONSTASCII_USTRINGPARAM("$BUNDLED_EXTENSIONS_USER/lastsynchronized.bundled")); 918 ::rtl::Bootstrap::expandMacros(sMarkerURL); 919 if ( ! needsInstallBundledExtensionBlobs(sMarkerURL, aDirUrl)) 920 return; 921 writeLastModified(sMarkerURL); 922 923 // get the ExtensionManager |
899 ::css::uno::Reference< ::css::uno::XComponentContext> xContext = comphelper::getProcessComponentContext(); 900 ::css::uno::Reference< ::css::deployment::XExtensionManager> xEM = ::css::deployment::ExtensionManager::get( xContext); 901 // provide the minimal set of requirements to call ExtensionManager's methods 902 MinimalCommandEnv* pMiniCmdEnv = new MinimalCommandEnv; 903 ::css::uno::Reference< css::ucb::XCommandEnvironment> xCmdEnv( static_cast< cppu::OWeakObject*>(pMiniCmdEnv), css::uno::UNO_QUERY); 904 const ::css::beans::NamedValue aNamedProps( OUSTR("SUPPRESS_LICENSE"), ::css::uno::makeAny( OUSTR("1"))); 905 const ::css::uno::Sequence< ::css::beans::NamedValue> xProperties( &aNamedProps, 1); 906 ::css::uno::Reference< ::css::task::XAbortChannel> xAbortChannel; | 924 ::css::uno::Reference< ::css::uno::XComponentContext> xContext = comphelper::getProcessComponentContext(); 925 ::css::uno::Reference< ::css::deployment::XExtensionManager> xEM = ::css::deployment::ExtensionManager::get( xContext); 926 // provide the minimal set of requirements to call ExtensionManager's methods 927 MinimalCommandEnv* pMiniCmdEnv = new MinimalCommandEnv; 928 ::css::uno::Reference< css::ucb::XCommandEnvironment> xCmdEnv( static_cast< cppu::OWeakObject*>(pMiniCmdEnv), css::uno::UNO_QUERY); 929 ::css::uno::Reference< ::css::task::XAbortChannel> xAbortChannel; |
907 | 930 |
908 // get the list of deployed extensions 909 typedef std::hash_set< rtl::OUString, ::rtl::OUStringHash> StringSet; 910 StringSet aExtNameSet; 911 css::uno::Sequence< css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > > xListOfLists = xEM->getAllExtensions( xAbortChannel, xCmdEnv); 912 const sal_Int32 nLen1 = xListOfLists.getLength(); 913 for( int i1 = 0; i1 < nLen1; ++i1) { 914 css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > xListOfPacks = xListOfLists[i1]; 915 const sal_Int32 nLen2 = xListOfPacks.getLength(); 916 for( int i2 = 0; i2 < nLen2; ++i2) { 917 css::uno::Reference<css::deployment::XPackage> xPackage = xListOfPacks[i2]; 918 if( !xPackage.is()) 919 continue; 920 aExtNameSet.insert( xPackage->getName()); 921 } 922 } | 931 const ::css::beans::NamedValue aNamedProps( OUSTR("SUPPRESS_LICENSE"), ::css::uno::makeAny( OUSTR("1"))); 932 const ::css::uno::Sequence< ::css::beans::NamedValue> xProperties( &aNamedProps, 1); |
923 | 933 |
924 // iterate over the bundled extension blobs 925 ::osl::File::RC rc = aDir.open(); 926 while( rc == osl::File::E_None) { 927 ::osl::DirectoryItem aDI; 928 if( aDir.getNextItem( aDI) != osl::File::E_None) 929 break; 930 ::osl::FileStatus aFileStat( FileStatusMask_Type | FileStatusMask_FileURL); 931 if( aDI.getFileStatus( aFileStat) != ::osl::File::E_None) 932 continue; 933 if( aFileStat.getFileType() != ::osl::FileStatus::Regular) 934 continue; 935 try { 936 // check if the extension is already installed 937 const rtl::OUString& rExtFileUrl = aFileStat.getFileURL(); 938 const sal_Int32 nBaseIndex = rExtFileUrl.lastIndexOf('/'); 939 const ::rtl::OUString aBaseName = (nBaseIndex < 0) ? rExtFileUrl : rExtFileUrl.copy( nBaseIndex+1); 940 const bool bFound = (aExtNameSet.find( aBaseName) != aExtNameSet.end()); 941 if( bFound) 942 continue; 943 // request to install the extension blob 944 xEM->addExtension( rExtFileUrl, xProperties, OUSTR("user"), xAbortChannel, xCmdEnv); 945 // ExtensionManager problems are not worth to die for here 946 } catch( css::uno::RuntimeException&) { 947 } catch( css::deployment::DeploymentException&) { 948 } 949 } | 934 // iterate over the bundled extension blobs 935 ::osl::Directory aDir( aDirUrl); 936 ::osl::File::RC rc = aDir.open(); 937 while( rc == osl::File::E_None) 938 { 939 ::osl::DirectoryItem aDI; 940 if( aDir.getNextItem( aDI) != osl::File::E_None) 941 break; 942 ::osl::FileStatus aFileStat( FileStatusMask_Type | FileStatusMask_FileURL); 943 if( aDI.getFileStatus( aFileStat) != ::osl::File::E_None) 944 continue; 945 if( aFileStat.getFileType() != ::osl::FileStatus::Regular) 946 continue; 947 try 948 { 949 // request to install the extension blob 950 xEM->addExtension( aFileStat.getFileURL(), xProperties, OUSTR("user"), xAbortChannel, xCmdEnv); 951 } 952 // ExtensionManager problems are not worth to die for here 953 catch( css::uno::RuntimeException&) 954 {} 955 catch( css::deployment::DeploymentException&) 956 {} 957 } |
950} 951 952//============================================================================= 953 954Desktop::Desktop() 955: m_bServicesRegistered( false ) 956, m_aBootstrapError( BE_OK ) 957, m_pLockfile( NULL ) --- 1047 unchanged lines hidden (view full) --- 2005 RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ FirstStartWizard" ); 2006 2007 if (IsFirstStartWizardNeeded()) 2008 { 2009 Reference< XJob > xFirstStartJob( xSMgr->createInstance( 2010 DEFINE_CONST_UNICODE( "com.sun.star.comp.desktop.FirstStart" ) ), UNO_QUERY ); 2011 if (xFirstStartJob.is()) 2012 { | 958} 959 960//============================================================================= 961 962Desktop::Desktop() 963: m_bServicesRegistered( false ) 964, m_aBootstrapError( BE_OK ) 965, m_pLockfile( NULL ) --- 1047 unchanged lines hidden (view full) --- 2013 RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ FirstStartWizard" ); 2014 2015 if (IsFirstStartWizardNeeded()) 2016 { 2017 Reference< XJob > xFirstStartJob( xSMgr->createInstance( 2018 DEFINE_CONST_UNICODE( "com.sun.star.comp.desktop.FirstStart" ) ), UNO_QUERY ); 2019 if (xFirstStartJob.is()) 2020 { |
2013 // mark first start as done 2014 FinishFirstStart(); | 2021 sal_Bool bDone = sal_False; 2022 Sequence< NamedValue > lArgs(2); 2023 lArgs[0].Name = ::rtl::OUString::createFromAscii("LicenseNeedsAcceptance"); 2024 lArgs[0].Value <<= LicenseNeedsAcceptance(); 2025 lArgs[1].Name = ::rtl::OUString::createFromAscii("LicensePath"); 2026 lArgs[1].Value <<= GetLicensePath(); 2027 2028 xFirstStartJob->execute(lArgs) >>= bDone; 2029 if ( !bDone ) 2030 { 2031 doShutdown(); 2032 return; 2033 } 2034 // mark first start as done 2035 FinishFirstStart(); |
2015 } 2016 } 2017 2018 RTL_LOGFILE_CONTEXT_TRACE( aLog, "} FirstStartWizard" ); 2019 } 2020 2021 // process non-pre-registered extensions 2022 installBundledExtensionBlobs(); --- 1584 unchanged lines hidden --- | 2036 } 2037 } 2038 2039 RTL_LOGFILE_CONTEXT_TRACE( aLog, "} FirstStartWizard" ); 2040 } 2041 2042 // process non-pre-registered extensions 2043 installBundledExtensionBlobs(); --- 1584 unchanged lines hidden --- |