22#include <osl/file.hxx>
23#include <rtl/ustring.hxx>
25#include <osl/mutex.hxx>
26#include <com/sun/star/uno/Sequence.hxx>
27#include <com/sun/star/beans/PropertyChangeEvent.hpp>
28#include <com/sun/star/ucb/XCommandInfo.hpp>
29#include <com/sun/star/beans/Property.hpp>
30#include <com/sun/star/beans/PropertyValue.hpp>
31#include <com/sun/star/io/XStream.hpp>
32#include <com/sun/star/io/XOutputStream.hpp>
33#include <com/sun/star/io/XInputStream.hpp>
34#include <com/sun/star/beans/XPropertySetInfo.hpp>
35#include <com/sun/star/ucb/NumberedSortingInfo.hpp>
36#include <com/sun/star/sdbc/XRow.hpp>
37#include <com/sun/star/uno/XComponentContext.hpp>
38#include <com/sun/star/ucb/XDynamicResultSet.hpp>
39#include <com/sun/star/beans/XPropertyContainer.hpp>
40#include <com/sun/star/beans/XPropertyAccess.hpp>
41#include <com/sun/star/ucb/ContentInfo.hpp>
42#include <com/sun/star/ucb/XCommandEnvironment.hpp>
43#include <com/sun/star/ucb/XPersistentPropertySet.hpp>
44#include <com/sun/star/ucb/XPropertySetRegistry.hpp>
45#include <com/sun/star/task/XInteractionHandler.hpp>
46#include <com/sun/star/task/XInteractionRequest.hpp>
50#include <unordered_map>
51#include <unordered_set>
58 class XPropertySetInfo_impl;
59 class XCommandInfo_impl;
60 class XResultSet_impl;
90 css::uno::Reference< css::ucb::XCommandEnvironment > xCommandEnv )
115 sal_Int32 nMinorCode )
131 css::uno::Reference< css::task::XInteractionHandler >
const &
140 const css::uno::Reference< css::ucb::XCommandEnvironment >&
149 typedef std::unordered_map< sal_Int32,TaskHandling >
TaskMap;
169 explicit MyProperty(
const OUString& thePropertyName );
171 const OUString& thePropertyName,
173 const css::uno::Type& theTyp,
174 const css::uno::Any& theValue,
175 const css::beans::PropertyState& theState,
176 sal_Int16 theAttributes );
178 inline const bool&
IsNative()
const;
180 inline const sal_Int32&
getHandle()
const;
181 inline const css::uno::Type&
getType()
const;
182 inline const css::uno::Any&
getValue()
const;
183 inline const css::beans::PropertyState&
getState()
const;
187 inline void setValue( css::uno::Any theValue )
const;
188 inline void setState(
const css::beans::PropertyState& theState )
const;
212 css::uno::Reference< css::ucb::XPersistentPropertySet >
xS;
213 css::uno::Reference< css::beans::XPropertyContainer >
xC;
214 css::uno::Reference< css::beans::XPropertyAccess >
xA;
217 typedef std::unordered_map< OUString,UnqPathData >
ContentMap;
219 TaskManager(
const css::uno::Reference< css::uno::XComponentContext >& rxContext,
226 const css::uno::Reference< css::ucb::XCommandEnvironment >& xCommandEnv );
243 sal_Int32 &minorCode);
250 void endTask( sal_Int32 CommandId,
252 const OUString& aUnqPath,
261 const css::uno::Reference< css::task::XInteractionRequest >& request );
290 const OUString& PropertyName,
291 const css::uno::Any& DefaultValue,
292 const sal_Int16 Attributes );
298 const OUString& PropertyName );
310 void page( sal_Int32 CommandId,
311 const OUString& aUnqPath,
312 const css::uno::Reference< css::io::XOutputStream >& xOutputStream );
319 css::uno::Reference< css::io::XInputStream >
320 open( sal_Int32 CommandId,
321 const OUString& aUnqPath,
330 css::uno::Reference< css::io::XStream >
332 const OUString& aUnqPath,
341 css::uno::Reference< css::ucb::XDynamicResultSet >
342 ls( sal_Int32 CommandId,
343 const OUString& aUnqPath,
344 const sal_Int32 OpenMode,
345 const css::uno::Sequence< css::beans::Property >& sProperty,
346 const css::uno::Sequence< css::ucb::NumberedSortingInfo > & sSortingInfo );
354 css::uno::Reference< css::ucb::XCommandInfo >
358 css::uno::Reference< css::beans::XPropertySetInfo >
359 info_p(
const OUString& aUnqPath );
366 css::uno::Sequence< css::uno::Any >
367 setv(
const OUString& aUnqPath,
368 const css::uno::Sequence< css::beans::PropertyValue >& values );
376 css::uno::Reference< css::sdbc::XRow >
378 const OUString& aUnqPath,
379 const css::uno::Sequence< css::beans::Property >&
properties );
391 move( sal_Int32 CommandId,
392 const OUString& srcUnqPath,
393 const OUString& dstUnqPath,
394 const sal_Int32 NameClash );
401 copy( sal_Int32 CommandId,
402 const OUString& srcUnqPath,
403 const OUString& dstUnqPath,
404 sal_Int32 NameClash );
413 remove( sal_Int32 CommandId,
414 const OUString& aUnqPath,
416 bool MustExist =
true );
429 mkdir( sal_Int32 CommandId,
430 const OUString& aDirectoryName,
441 mkfil( sal_Int32 CommandId,
442 const OUString& aFileName,
444 const css::uno::Reference< css::io::XInputStream >& aInputStream );
453 write( sal_Int32 CommandId,
454 const OUString& aUnqPath,
456 const css::uno::Reference< css::io::XInputStream >& aInputStream );
461 static css::uno::Sequence< css::ucb::ContentInfo >
472 static bool getUnqFromUrl(
const OUString& Url, OUString& Unq );
474 static bool getUrlFromUnq(
const OUString& Unq, OUString& Url );
478 css::uno::Reference< css::uno::XComponentContext >
m_xContext;
489 std::vector< ContentEventNotifier >
492 std::vector< ContentEventNotifier >
495 std::vector< ContentEventNotifier >
497 const OUString& aNewPrefix,
500 std::vector< PropertyChangeNotifier >
503 std::vector< PropertySetInfoChangeNotifier >
512 const std::vector<PropertyChangeNotifier>& listeners,
513 const css::uno::Sequence<css::beans::PropertyChangeEvent>& seqChanged);
516 const std::vector<ContentEventNotifier>& listeners_vec);
519 notifyInsert(
const std::vector<ContentEventNotifier>& listeners,
520 const OUString& aChildName);
527 const OUString& aChildName);
530 const std::vector<PropertySetInfoChangeNotifier>& listeners,
531 const OUString& aPropertyName);
534 const std::vector<PropertySetInfoChangeNotifier>& listeners,
535 const OUString& aPropertyName);
543 bool withChildren =
false );
551 const OUString& dstUnqPath );
553 const OUString& dstUnqPath,
562 osl::DirectoryItem& DirItem,
565 css::uno::Reference< css::sdbc::XRow > & row );
573 void load(
const TaskManager::ContentMap::iterator& it,
584 std::unique_lock<std::mutex>& rGuard,
585 const TaskManager::ContentMap::iterator& it,
586 const osl::FileStatus& aFileStatus );
597 const css::uno::Sequence< css::beans::Property >& seq );
604 const OUString& srcUnqPath,
605 const OUString& dstUnqPath,
607 bool testExistence );
618 const OUString& aDirectoryName,
619 sal_Int32 errorCode );
628 u"application/vnd.sun.staroffice.fsys-folder";
630 u"application/vnd.sun.staroffice.fsys-file";
642 static void getScheme( OUString& Scheme );
MyProperty(const OUString &thePropertyName)
const sal_Int16 & getAttributes() const
const sal_Int32 & getHandle() const
const css::beans::PropertyState & getState() const
void setValue(css::uno::Any theValue) const
const css::uno::Type & getType() const
const OUString & getPropertyName() const
const bool & IsNative() const
void setState(const css::beans::PropertyState &theState) const
const css::uno::Any & getValue() const
css::beans::PropertyState State
sal_Int32 getMinorErrorCode() const
void installError(sal_Int32 nErrorCode, sal_Int32 nMinorCode)
const css::uno::Reference< css::ucb::XCommandEnvironment > & getCommandEnvironment() const
css::uno::Reference< css::task::XInteractionHandler > const & getInteractionHandler()
css::uno::Reference< css::task::XInteractionHandler > m_xInteractionHandler
css::uno::Reference< css::ucb::XCommandEnvironment > m_xCommandEnvironment
TaskHandling(css::uno::Reference< css::ucb::XCommandEnvironment > xCommandEnv)
sal_Int32 getInstalledError() const
UnqPathData(UnqPathData &&)
css::uno::Reference< css::beans::XPropertyAccess > xA
std::vector< Notifier * > notifier
css::uno::Reference< css::ucb::XPersistentPropertySet > xS
css::uno::Reference< css::beans::XPropertyContainer > xC
std::vector< ContentEventNotifier > getContentEventListeners(const OUString &aName)
static css::uno::Sequence< css::ucb::ContentInfo > queryCreatableContentsInfo()
css::uno::Reference< css::uno::XComponentContext > m_xContext
void erasePersistentSetWithoutChildren(const OUString &aUnqPath)
bool mkdir(sal_Int32 CommandId, const OUString &aDirectoryName, bool OverWrite)
Creates new directory with given URL, recursively if necessary Return:: success of operation.
void endTask(sal_Int32 CommandId, const OUString &aUnqPath, BaseContent *pContent)
Deinstalls the task and evaluates a possibly set error code.
css::uno::Sequence< css::uno::Any > setv(const OUString &aUnqPath, const css::uno::Sequence< css::beans::PropertyValue > &values)
Sets the values of the properties belonging to fileURL aUnqPath.
bool write(sal_Int32 CommandId, const OUString &aUnqPath, bool OverWrite, const css::uno::Reference< css::io::XInputStream > &aInputStream)
writes to the file with given URL.
void commit(std::unique_lock< std::mutex > &rGuard, const TaskManager::ContentMap::iterator &it, const osl::FileStatus &aFileStatus)
Commit inserts the determined properties in the filestatus object into the internal map,...
void registerNotifier(const OUString &aUnqPath, Notifier *pNotifier)
This two methods register and deregister a change listener for the content belonging to URL aUnqPath.
css::uno::Reference< css::ucb::XDynamicResultSet > ls(sal_Int32 CommandId, const OUString &aUnqPath, const sal_Int32 OpenMode, const css::uno::Sequence< css::beans::Property > &sProperty, const css::uno::Sequence< css::ucb::NumberedSortingInfo > &sSortingInfo)
This method returns the result set containing the children of the directory belonging to file URL aUn...
std::vector< ContentEventNotifier > getContentDeletedEventListeners(const OUString &aName)
bool getv(const css::uno::Sequence< css::beans::Property > &properties, osl::DirectoryItem &DirItem, OUString &aUnqPath, bool &bIsRegular, css::uno::Reference< css::sdbc::XRow > &row)
static void getScheme(OUString &Scheme)
o3tl::sorted_vector< MyProperty, MyPropertyLess > PropertySet
static void notifyContentDeleted(const std::vector< ContentEventNotifier > &listeners)
std::unordered_map< sal_Int32, TaskHandling > TaskMap
std::vector< PropertyChangeNotifier > getPropertyChangeNotifier(const OUString &aName)
static constexpr OUStringLiteral FolderContentType
FileProvider * m_pProvider
void erasePersistentSet(const OUString &aUnqPath, bool withChildren=false)
css::uno::Sequence< css::ucb::CommandInfo > m_sCommandInfo
void copyPersistentSet(const OUString &srcUnqPath, const OUString &dstUnqPath, bool withChildren)
void installError(sal_Int32 CommandId, sal_Int32 ErrorCode, sal_Int32 minorCode=TASKHANDLER_NO_ERROR)
The error code may be one of the error codes defined in filerror.hxx.
bool mkfil(sal_Int32 CommandId, const OUString &aFileName, bool OverWrite, const css::uno::Reference< css::io::XInputStream > &aInputStream)
Creates new file with given URL.
void deregisterNotifier(const OUString &aUnqPath, Notifier *pNotifier)
static void notifyInsert(const std::vector< ContentEventNotifier > &listeners, const OUString &aChildName)
void handleTask(sal_Int32 CommandId, const css::uno::Reference< css::task::XInteractionRequest > &request)
Handles an interactionrequest.
static bool getUnqFromUrl(const OUString &Url, OUString &Unq)
void copyPersistentSetWithoutChildren(const OUString &srcUnqPath, const OUString &dstUnqPath)
static bool getUrlFromUnq(const OUString &Unq, OUString &Url)
std::unordered_map< OUString, UnqPathData > ContentMap
static void notifyPropertyChanges(const std::vector< PropertyChangeNotifier > &listeners, const css::uno::Sequence< css::beans::PropertyChangeEvent > &seqChanged)
void load(const TaskManager::ContentMap::iterator &it, bool create)
Load the properties from configuration, if create == true create them.
bool ensuredir(sal_Int32 CommandId, const OUString &aDirectoryName, sal_Int32 errorCode)
css::uno::Reference< css::beans::XPropertySetInfo > info_p(const OUString &aUnqPath)
css::uno::Reference< css::io::XStream > open_rw(sal_Int32 CommandId, const OUString &aUnqPath, bool bLock)
Given a file URL aUnqPath, this methods returns a XStream which can be used to read and write from/to...
void startTask(sal_Int32 CommandId, const css::uno::Reference< css::ucb::XCommandEnvironment > &xCommandEnv)
static void getMaskFromProperties(sal_Int32 &n_Mask, const css::uno::Sequence< css::beans::Property > &seq)
Given a Sequence of properties seq, this method determines the mask used to instantiate an osl::FileS...
void clearError(sal_Int32)
Clears any error which are set on the commandid.
TaskManager(const css::uno::Reference< css::uno::XComponentContext > &rxContext, FileProvider *pProvider, bool bWithConfig)
css::uno::Reference< css::io::XInputStream > open(sal_Int32 CommandId, const OUString &aUnqPath, bool bLock)
Given a file URL aUnqPath, this methods returns a XInputStream which reads from the open file.
void insertDefaultProperties(const OUString &aUnqPath)
css::uno::Reference< css::ucb::XPropertySetRegistry > m_xFileRegistry
PropertySet m_aDefaultProperties
static void notifyPropertyRemoved(const std::vector< PropertySetInfoChangeNotifier > &listeners, const OUString &aPropertyName)
bool remove(sal_Int32 CommandId, const OUString &aUnqPath, FileUrlType eTypeToMove=FileUrlType::Unknown, bool MustExist=true)
Deletes the content belonging to fileURL aUnqPath( recursively in case of directory )
static void notifyContentExchanged(const std::vector< ContentEventNotifier > &listeners_vec)
void move(sal_Int32 CommandId, const OUString &srcUnqPath, const OUString &dstUnqPath, const sal_Int32 NameClash)
Moves the content belonging to fileURL srcUnqPath to fileURL dstUnqPath( files and directories )
void retrieveError(sal_Int32 CommandId, sal_Int32 &ErrorCode, sal_Int32 &minorCode)
void copy(sal_Int32 CommandId, const OUString &srcUnqPath, const OUString &dstUnqPath, sal_Int32 NameClash)
Copies the content belonging to fileURL srcUnqPath to fileURL dstUnqPath ( files and directories )
std::vector< ContentEventNotifier > getContentExchangedEventListeners(const OUString &aOldPrefix, const OUString &aNewPrefix, bool withChildren)
osl::FileBase::RC copy_recursive(const OUString &srcUnqPath, const OUString &dstUnqPath, FileUrlType TypeToCopy, bool testExistence)
void deassociate(const OUString &UnqPath, const OUString &PropertyName)
css::uno::Reference< css::ucb::XCommandInfo > info_c()
Info methods.
void page(sal_Int32 CommandId, const OUString &aUnqPath, const css::uno::Reference< css::io::XOutputStream > &xOutputStream)
Given an xOutputStream, this method writes the content of the file belonging to URL aUnqPath into the...
css::uno::Reference< css::sdbc::XRow > getv(sal_Int32 CommandId, const OUString &aUnqPath, const css::uno::Sequence< css::beans::Property > &properties)
Reads the values of the properties belonging to fileURL aUnqPath; Returns an XRow object containing t...
static void notifyPropertyAdded(const std::vector< PropertySetInfoChangeNotifier > &listeners, const OUString &aPropertyName)
static constexpr OUStringLiteral FileContentType
static void notifyContentRemoved(const std::vector< ContentEventNotifier > &listeners, const OUString &aChildName)
std::vector< PropertySetInfoChangeNotifier > getPropertySetListeners(const OUString &aName)
void associate(const OUString &UnqPath, const OUString &PropertyName, const css::uno::Any &DefaultValue, const sal_Int16 Attributes)
Used to associate and deassociate a new property with the content belonging to URL UnqPath.
#define TASKHANDLER_NO_ERROR
bool operator()(const MyProperty &rKey1, const MyProperty &rKey2) const