1*2f86921cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2f86921cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2f86921cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2f86921cSAndrew Rist * distributed with this work for additional information 6*2f86921cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2f86921cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2f86921cSAndrew Rist * "License"); you may not use this file except in compliance 9*2f86921cSAndrew Rist * with the License. You may obtain a copy of the License at 10*2f86921cSAndrew Rist * 11*2f86921cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2f86921cSAndrew Rist * 13*2f86921cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2f86921cSAndrew Rist * software distributed under the License is distributed on an 15*2f86921cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2f86921cSAndrew Rist * KIND, either express or implied. See the License for the 17*2f86921cSAndrew Rist * specific language governing permissions and limitations 18*2f86921cSAndrew Rist * under the License. 19*2f86921cSAndrew Rist * 20*2f86921cSAndrew Rist *************************************************************/ 21*2f86921cSAndrew Rist 22*2f86921cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_ucb.hxx" 26cdf0e10cSrcweir #include "filtask.hxx" 27cdf0e10cSrcweir #include "filglob.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir /******************************************************************************/ 30cdf0e10cSrcweir /* */ 31cdf0e10cSrcweir /* TaskHandling */ 32cdf0e10cSrcweir /* */ 33cdf0e10cSrcweir /******************************************************************************/ 34cdf0e10cSrcweir 35cdf0e10cSrcweir 36cdf0e10cSrcweir using namespace fileaccess; 37cdf0e10cSrcweir using namespace com::sun::star; 38cdf0e10cSrcweir using namespace com::sun::star::uno; 39cdf0e10cSrcweir using namespace com::sun::star::ucb; 40cdf0e10cSrcweir 41cdf0e10cSrcweir 42cdf0e10cSrcweir 43cdf0e10cSrcweir TaskManager::TaskManager() 44cdf0e10cSrcweir : m_nCommandId( 0 ) 45cdf0e10cSrcweir { 46cdf0e10cSrcweir } 47cdf0e10cSrcweir 48cdf0e10cSrcweir 49cdf0e10cSrcweir 50cdf0e10cSrcweir TaskManager::~TaskManager() 51cdf0e10cSrcweir { 52cdf0e10cSrcweir } 53cdf0e10cSrcweir 54cdf0e10cSrcweir 55cdf0e10cSrcweir 56cdf0e10cSrcweir void SAL_CALL 57cdf0e10cSrcweir TaskManager::startTask( 58cdf0e10cSrcweir sal_Int32 CommandId, 59cdf0e10cSrcweir const uno::Reference< XCommandEnvironment >& xCommandEnv ) 60cdf0e10cSrcweir throw( DuplicateCommandIdentifierException ) 61cdf0e10cSrcweir { 62cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 63cdf0e10cSrcweir TaskMap::iterator it = m_aTaskMap.find( CommandId ); 64cdf0e10cSrcweir if( it != m_aTaskMap.end() ) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir throw DuplicateCommandIdentifierException( 67cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), 68cdf0e10cSrcweir uno::Reference< uno::XInterface >() ); 69cdf0e10cSrcweir } 70cdf0e10cSrcweir m_aTaskMap[ CommandId ] = TaskHandling( xCommandEnv ); 71cdf0e10cSrcweir } 72cdf0e10cSrcweir 73cdf0e10cSrcweir 74cdf0e10cSrcweir 75cdf0e10cSrcweir void SAL_CALL 76cdf0e10cSrcweir TaskManager::endTask( sal_Int32 CommandId, 77cdf0e10cSrcweir const rtl::OUString& aUncPath, 78cdf0e10cSrcweir BaseContent* pContent) 79cdf0e10cSrcweir { 80cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 81cdf0e10cSrcweir TaskMap::iterator it = m_aTaskMap.find( CommandId ); 82cdf0e10cSrcweir if( it == m_aTaskMap.end() ) 83cdf0e10cSrcweir return; 84cdf0e10cSrcweir 85cdf0e10cSrcweir sal_Int32 ErrorCode = it->second.getInstalledError(); 86cdf0e10cSrcweir sal_Int32 MinorCode = it->second.getMinorErrorCode(); 87cdf0e10cSrcweir bool isHandled = it->second.isHandled(); 88cdf0e10cSrcweir 89cdf0e10cSrcweir Reference< XCommandEnvironment > xComEnv 90cdf0e10cSrcweir = it->second.getCommandEnvironment(); 91cdf0e10cSrcweir 92cdf0e10cSrcweir m_aTaskMap.erase( it ); 93cdf0e10cSrcweir 94cdf0e10cSrcweir if( ErrorCode != TASKHANDLER_NO_ERROR ) 95cdf0e10cSrcweir throw_handler( 96cdf0e10cSrcweir ErrorCode, 97cdf0e10cSrcweir MinorCode, 98cdf0e10cSrcweir xComEnv, 99cdf0e10cSrcweir aUncPath, 100cdf0e10cSrcweir pContent, 101cdf0e10cSrcweir isHandled); 102cdf0e10cSrcweir } 103cdf0e10cSrcweir 104cdf0e10cSrcweir 105cdf0e10cSrcweir 106cdf0e10cSrcweir void SAL_CALL 107cdf0e10cSrcweir TaskManager::abort( sal_Int32 CommandId ) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir if( CommandId ) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 112cdf0e10cSrcweir TaskMap::iterator it = m_aTaskMap.find( CommandId ); 113cdf0e10cSrcweir if( it == m_aTaskMap.end() ) 114cdf0e10cSrcweir return; 115cdf0e10cSrcweir else 116cdf0e10cSrcweir it->second.abort(); 117cdf0e10cSrcweir } 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir 121cdf0e10cSrcweir void SAL_CALL TaskManager::clearError( sal_Int32 CommandId ) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 124cdf0e10cSrcweir TaskMap::iterator it = m_aTaskMap.find( CommandId ); 125cdf0e10cSrcweir if( it != m_aTaskMap.end() ) 126cdf0e10cSrcweir it->second.clearError(); 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir 130cdf0e10cSrcweir void SAL_CALL TaskManager::retrieveError( sal_Int32 CommandId, 131cdf0e10cSrcweir sal_Int32 &ErrorCode, 132cdf0e10cSrcweir sal_Int32 &minorCode) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 135cdf0e10cSrcweir TaskMap::iterator it = m_aTaskMap.find( CommandId ); 136cdf0e10cSrcweir if( it != m_aTaskMap.end() ) 137cdf0e10cSrcweir { 138cdf0e10cSrcweir ErrorCode = it->second.getInstalledError(); 139cdf0e10cSrcweir minorCode = it->second. getMinorErrorCode(); 140cdf0e10cSrcweir } 141cdf0e10cSrcweir } 142cdf0e10cSrcweir 143cdf0e10cSrcweir 144cdf0e10cSrcweir 145cdf0e10cSrcweir void SAL_CALL TaskManager::installError( sal_Int32 CommandId, 146cdf0e10cSrcweir sal_Int32 ErrorCode, 147cdf0e10cSrcweir sal_Int32 MinorCode ) 148cdf0e10cSrcweir { 149cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 150cdf0e10cSrcweir TaskMap::iterator it = m_aTaskMap.find( CommandId ); 151cdf0e10cSrcweir if( it != m_aTaskMap.end() ) 152cdf0e10cSrcweir it->second.installError( ErrorCode,MinorCode ); 153cdf0e10cSrcweir } 154cdf0e10cSrcweir 155cdf0e10cSrcweir 156cdf0e10cSrcweir 157cdf0e10cSrcweir sal_Int32 SAL_CALL 158cdf0e10cSrcweir TaskManager::getCommandId( void ) 159cdf0e10cSrcweir { 160cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 161cdf0e10cSrcweir return ++m_nCommandId; 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir 165cdf0e10cSrcweir 166cdf0e10cSrcweir void SAL_CALL TaskManager::handleTask( 167cdf0e10cSrcweir sal_Int32 CommandId, 168cdf0e10cSrcweir const uno::Reference< task::XInteractionRequest >& request ) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 171cdf0e10cSrcweir TaskMap::iterator it = m_aTaskMap.find( CommandId ); 172cdf0e10cSrcweir uno::Reference< task::XInteractionHandler > xInt; 173cdf0e10cSrcweir if( it != m_aTaskMap.end() ) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir xInt = it->second.getInteractionHandler(); 176cdf0e10cSrcweir if( xInt.is() ) 177cdf0e10cSrcweir xInt->handle( request ); 178cdf0e10cSrcweir it->second.setHandled(); 179cdf0e10cSrcweir } 180cdf0e10cSrcweir } 181