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>
49#include <unordered_map>
50#include <unordered_set>
57 class XPropertySetInfo_impl;
58 class XCommandInfo_impl;
59 class XResultSet_impl;
89 const css::uno::Reference< css::ucb::XCommandEnvironment >& xCommandEnv )
114 sal_Int32 nMinorCode )
130 css::uno::Reference< css::task::XInteractionHandler >
const &
139 const css::uno::Reference< css::ucb::XCommandEnvironment >&
148 typedef std::unordered_map< sal_Int32,TaskHandling >
TaskMap;
168 explicit MyProperty(
const OUString& thePropertyName );
170 const OUString& thePropertyName,
172 const css::uno::Type& theTyp,
173 const css::uno::Any& theValue,
174 const css::beans::PropertyState& theState,
175 sal_Int16 theAttributes );
177 inline const bool&
IsNative()
const;
179 inline const sal_Int32&
getHandle()
const;
180 inline const css::uno::Type&
getType()
const;
181 inline const css::uno::Any&
getValue()
const;
182 inline const css::beans::PropertyState&
getState()
const;
186 inline void setValue( css::uno::Any theValue )
const;
187 inline void setState(
const css::beans::PropertyState& theState )
const;
211 css::uno::Reference< css::ucb::XPersistentPropertySet >
xS;
212 css::uno::Reference< css::beans::XPropertyContainer >
xC;
213 css::uno::Reference< css::beans::XPropertyAccess >
xA;
216 typedef std::unordered_map< OUString,UnqPathData >
ContentMap;
218 TaskManager(
const css::uno::Reference< css::uno::XComponentContext >& rxContext,
225 const css::uno::Reference< css::ucb::XCommandEnvironment >& xCommandEnv );
242 sal_Int32 &minorCode);
249 void endTask( sal_Int32 CommandId,
251 const OUString& aUnqPath,
260 const css::uno::Reference< css::task::XInteractionRequest >& request );
289 const OUString& PropertyName,
290 const css::uno::Any& DefaultValue,
291 const sal_Int16 Attributes );
297 const OUString& PropertyName );
309 void page( sal_Int32 CommandId,
310 const OUString& aUnqPath,
311 const css::uno::Reference< css::io::XOutputStream >& xOutputStream );
318 css::uno::Reference< css::io::XInputStream >
319 open( sal_Int32 CommandId,
320 const OUString& aUnqPath,
329 css::uno::Reference< css::io::XStream >
331 const OUString& aUnqPath,
340 css::uno::Reference< css::ucb::XDynamicResultSet >
341 ls( sal_Int32 CommandId,
342 const OUString& aUnqPath,
343 const sal_Int32 OpenMode,
344 const css::uno::Sequence< css::beans::Property >& sProperty,
345 const css::uno::Sequence< css::ucb::NumberedSortingInfo > & sSortingInfo );
353 css::uno::Reference< css::ucb::XCommandInfo >
357 css::uno::Reference< css::beans::XPropertySetInfo >
358 info_p(
const OUString& aUnqPath );
365 css::uno::Sequence< css::uno::Any >
366 setv(
const OUString& aUnqPath,
367 const css::uno::Sequence< css::beans::PropertyValue >& values );
375 css::uno::Reference< css::sdbc::XRow >
377 const OUString& aUnqPath,
378 const css::uno::Sequence< css::beans::Property >&
properties );
390 move( sal_Int32 CommandId,
391 const OUString& srcUnqPath,
392 const OUString& dstUnqPath,
393 const sal_Int32 NameClash );
400 copy( sal_Int32 CommandId,
401 const OUString& srcUnqPath,
402 const OUString& dstUnqPath,
403 sal_Int32 NameClash );
412 remove( sal_Int32 CommandId,
413 const OUString& aUnqPath,
415 bool MustExist =
true );
428 mkdir( sal_Int32 CommandId,
429 const OUString& aDirectoryName,
440 mkfil( sal_Int32 CommandId,
441 const OUString& aFileName,
443 const css::uno::Reference< css::io::XInputStream >& aInputStream );
452 write( sal_Int32 CommandId,
453 const OUString& aUnqPath,
455 const css::uno::Reference< css::io::XInputStream >& aInputStream );
460 static css::uno::Sequence< css::ucb::ContentInfo >
471 static bool getUnqFromUrl(
const OUString& Url, OUString& Unq );
473 static bool getUrlFromUnq(
const OUString& Unq, OUString& Url );
477 css::uno::Reference< css::uno::XComponentContext >
m_xContext;
486 std::vector< ContentEventNotifier >
489 std::vector< ContentEventNotifier >
492 std::vector< ContentEventNotifier >
494 const OUString& aNewPrefix,
497 std::vector< PropertyChangeNotifier >
500 std::vector< PropertySetInfoChangeNotifier >
509 const std::vector<PropertyChangeNotifier>& listeners,
510 const css::uno::Sequence<css::beans::PropertyChangeEvent>& seqChanged);
513 const std::vector<ContentEventNotifier>& listeners_vec);
516 notifyInsert(
const std::vector<ContentEventNotifier>& listeners,
517 const OUString& aChildName);
524 const OUString& aChildName);
527 const std::vector<PropertySetInfoChangeNotifier>& listeners,
528 const OUString& aPropertyName);
531 const std::vector<PropertySetInfoChangeNotifier>& listeners,
532 const OUString& aPropertyName);
540 bool withChildren =
false );
548 const OUString& dstUnqPath );
550 const OUString& dstUnqPath,
559 osl::DirectoryItem& DirItem,
562 css::uno::Reference< css::sdbc::XRow > & row );
570 void load(
const TaskManager::ContentMap::iterator& it,
581 const TaskManager::ContentMap::iterator& it,
582 const osl::FileStatus& aFileStatus );
593 const css::uno::Sequence< css::beans::Property >& seq );
600 const OUString& srcUnqPath,
601 const OUString& dstUnqPath,
603 bool testExistence );
614 const OUString& aDirectoryName,
615 sal_Int32 errorCode );
624 u"application/vnd.sun.staroffice.fsys-folder";
626 u"application/vnd.sun.staroffice.fsys-file";
638 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(const 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 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)
void commit(const TaskManager::ContentMap::iterator &it, const osl::FileStatus &aFileStatus)
Commit inserts the determined properties in the filestatus object into the internal map,...
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