Bump for 3.6-28
[LibreOffice.git] / ucb / source / ucp / file / filtask.cxx
blob66fefa854f961a62b63a834f417431d3c15a580a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "filtask.hxx"
30 #include "filglob.hxx"
32 /******************************************************************************/
33 /* */
34 /* TaskHandling */
35 /* */
36 /******************************************************************************/
39 using namespace fileaccess;
40 using namespace com::sun::star;
41 using namespace com::sun::star::uno;
42 using namespace com::sun::star::ucb;
46 TaskManager::TaskManager()
47 : m_nCommandId( 0 )
53 TaskManager::~TaskManager()
59 void SAL_CALL
60 TaskManager::startTask(
61 sal_Int32 CommandId,
62 const uno::Reference< XCommandEnvironment >& xCommandEnv )
63 throw( DuplicateCommandIdentifierException )
65 osl::MutexGuard aGuard( m_aMutex );
66 TaskMap::iterator it = m_aTaskMap.find( CommandId );
67 if( it != m_aTaskMap.end() )
69 throw DuplicateCommandIdentifierException(
70 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ),
71 uno::Reference< uno::XInterface >() );
73 m_aTaskMap[ CommandId ] = TaskHandling( xCommandEnv );
78 void SAL_CALL
79 TaskManager::endTask( sal_Int32 CommandId,
80 const rtl::OUString& aUncPath,
81 BaseContent* pContent)
83 osl::MutexGuard aGuard( m_aMutex );
84 TaskMap::iterator it = m_aTaskMap.find( CommandId );
85 if( it == m_aTaskMap.end() )
86 return;
88 sal_Int32 ErrorCode = it->second.getInstalledError();
89 sal_Int32 MinorCode = it->second.getMinorErrorCode();
90 bool isHandled = it->second.isHandled();
92 Reference< XCommandEnvironment > xComEnv
93 = it->second.getCommandEnvironment();
95 m_aTaskMap.erase( it );
97 if( ErrorCode != TASKHANDLER_NO_ERROR )
98 throw_handler(
99 ErrorCode,
100 MinorCode,
101 xComEnv,
102 aUncPath,
103 pContent,
104 isHandled);
109 void SAL_CALL
110 TaskManager::abort( sal_Int32 CommandId )
112 if( CommandId )
114 osl::MutexGuard aGuard( m_aMutex );
115 TaskMap::iterator it = m_aTaskMap.find( CommandId );
116 if( it == m_aTaskMap.end() )
117 return;
118 else
119 it->second.abort();
124 void SAL_CALL TaskManager::clearError( sal_Int32 CommandId )
126 osl::MutexGuard aGuard( m_aMutex );
127 TaskMap::iterator it = m_aTaskMap.find( CommandId );
128 if( it != m_aTaskMap.end() )
129 it->second.clearError();
133 void SAL_CALL TaskManager::retrieveError( sal_Int32 CommandId,
134 sal_Int32 &ErrorCode,
135 sal_Int32 &minorCode)
137 osl::MutexGuard aGuard( m_aMutex );
138 TaskMap::iterator it = m_aTaskMap.find( CommandId );
139 if( it != m_aTaskMap.end() )
141 ErrorCode = it->second.getInstalledError();
142 minorCode = it->second. getMinorErrorCode();
148 void SAL_CALL TaskManager::installError( sal_Int32 CommandId,
149 sal_Int32 ErrorCode,
150 sal_Int32 MinorCode )
152 osl::MutexGuard aGuard( m_aMutex );
153 TaskMap::iterator it = m_aTaskMap.find( CommandId );
154 if( it != m_aTaskMap.end() )
155 it->second.installError( ErrorCode,MinorCode );
160 sal_Int32 SAL_CALL
161 TaskManager::getCommandId( void )
163 osl::MutexGuard aGuard( m_aMutex );
164 return ++m_nCommandId;
169 void SAL_CALL TaskManager::handleTask(
170 sal_Int32 CommandId,
171 const uno::Reference< task::XInteractionRequest >& request )
173 osl::MutexGuard aGuard( m_aMutex );
174 TaskMap::iterator it = m_aTaskMap.find( CommandId );
175 uno::Reference< task::XInteractionHandler > xInt;
176 if( it != m_aTaskMap.end() )
178 xInt = it->second.getInteractionHandler();
179 if( xInt.is() )
180 xInt->handle( request );
181 it->second.setHandled();
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */