/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef mozilla_widget_FileTransferPortal_h #define mozilla_widget_FileTransferPortal_h #include "mozilla/GRefPtr.h" #include "mozilla/GUniquePtr.h" #include "mozilla/MozPromise.h" #include "nsTArray.h" #include "nsString.h" namespace mozilla::widget { // Wraps the org.freedesktop.portal.FileTransfer portal interface. class FileTransferPortal final { public: using RegisterFilesPromise = MozPromise, true>; using RetrieveFilesPromise = MozPromise, GUniquePtr, true>; static FileTransferPortal* GetPortal(); static void Shutdown(); RefPtr RegisterFiles(const nsTArray& aFiles, bool aWritable); nsresult RegisterFilesSync(const nsTArray& aFiles, bool aWritable, nsCString& aOutKey); RefPtr RetrieveFiles(const char* aKey); GUniquePtr RetrieveFilesSync(const char* aKey); private: FileTransferPortal() = default; bool Init(); GUniquePtr ConvertToURIs(GUniquePtr aFileList); RefPtr, true>> AddFilesBatch( const nsCString& aKey, const nsTArray& aFiles, int aStart); RefPtr mProxy; GUniquePtr mCancellable; static FileTransferPortal* sPortal; }; } // namespace mozilla::widget #endif