1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "filtask.hxx"
21 #include "filglob.hxx"
23 /******************************************************************************/
27 /******************************************************************************/
30 using namespace fileaccess
;
31 using namespace com::sun::star
;
32 using namespace com::sun::star::uno
;
33 using namespace com::sun::star::ucb
;
37 TaskManager::TaskManager()
44 TaskManager::~TaskManager()
51 TaskManager::startTask(
53 const uno::Reference
< XCommandEnvironment
>& xCommandEnv
)
54 throw( DuplicateCommandIdentifierException
)
56 osl::MutexGuard
aGuard( m_aMutex
);
57 TaskMap::iterator it
= m_aTaskMap
.find( CommandId
);
58 if( it
!= m_aTaskMap
.end() )
60 throw DuplicateCommandIdentifierException(
61 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX
) ),
62 uno::Reference
< uno::XInterface
>() );
64 m_aTaskMap
[ CommandId
] = TaskHandling( xCommandEnv
);
70 TaskManager::endTask( sal_Int32 CommandId
,
71 const rtl::OUString
& aUncPath
,
72 BaseContent
* pContent
)
74 osl::MutexGuard
aGuard( m_aMutex
);
75 TaskMap::iterator it
= m_aTaskMap
.find( CommandId
);
76 if( it
== m_aTaskMap
.end() )
79 sal_Int32 ErrorCode
= it
->second
.getInstalledError();
80 sal_Int32 MinorCode
= it
->second
.getMinorErrorCode();
81 bool isHandled
= it
->second
.isHandled();
83 Reference
< XCommandEnvironment
> xComEnv
84 = it
->second
.getCommandEnvironment();
86 m_aTaskMap
.erase( it
);
88 if( ErrorCode
!= TASKHANDLER_NO_ERROR
)
101 TaskManager::abort( sal_Int32 CommandId
)
105 osl::MutexGuard
aGuard( m_aMutex
);
106 TaskMap::iterator it
= m_aTaskMap
.find( CommandId
);
107 if( it
== m_aTaskMap
.end() )
115 void SAL_CALL
TaskManager::clearError( sal_Int32 CommandId
)
117 osl::MutexGuard
aGuard( m_aMutex
);
118 TaskMap::iterator it
= m_aTaskMap
.find( CommandId
);
119 if( it
!= m_aTaskMap
.end() )
120 it
->second
.clearError();
124 void SAL_CALL
TaskManager::retrieveError( sal_Int32 CommandId
,
125 sal_Int32
&ErrorCode
,
126 sal_Int32
&minorCode
)
128 osl::MutexGuard
aGuard( m_aMutex
);
129 TaskMap::iterator it
= m_aTaskMap
.find( CommandId
);
130 if( it
!= m_aTaskMap
.end() )
132 ErrorCode
= it
->second
.getInstalledError();
133 minorCode
= it
->second
. getMinorErrorCode();
139 void SAL_CALL
TaskManager::installError( sal_Int32 CommandId
,
141 sal_Int32 MinorCode
)
143 osl::MutexGuard
aGuard( m_aMutex
);
144 TaskMap::iterator it
= m_aTaskMap
.find( CommandId
);
145 if( it
!= m_aTaskMap
.end() )
146 it
->second
.installError( ErrorCode
,MinorCode
);
152 TaskManager::getCommandId( void )
154 osl::MutexGuard
aGuard( m_aMutex
);
155 return ++m_nCommandId
;
160 void SAL_CALL
TaskManager::handleTask(
162 const uno::Reference
< task::XInteractionRequest
>& request
)
164 osl::MutexGuard
aGuard( m_aMutex
);
165 TaskMap::iterator it
= m_aTaskMap
.find( CommandId
);
166 uno::Reference
< task::XInteractionHandler
> xInt
;
167 if( it
!= m_aTaskMap
.end() )
169 xInt
= it
->second
.getInteractionHandler();
171 xInt
->handle( request
);
172 it
->second
.setHandled();
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */