loolwsd/LOOLWSD.cpp | 1 loolwsd/Storage.hpp | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+)
New commits: commit 13f9b7a2dbd88974fb328498ae31bf1910d7f982 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Fri Feb 19 16:19:15 2016 -0500 loolwsd: Storage Abstraction support An abstract Storage abstraction class is added. There will be a factory to instantiate concrete implementation for a given backend. For WebDAV and similar hosted backends, authentication and authorization will be done by the implementation with the help of the Auth abstraction. Change-Id: I38ec5dad4c2c4ce16df30d65826df96751b10e2d Reviewed-on: https://gerrit.libreoffice.org/22513 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index 75a83b2..276c5fe 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -111,6 +111,7 @@ DEALINGS IN THE SOFTWARE. #include "ChildProcessSession.hpp" #include "LOOLWSD.hpp" #include "QueueHandler.hpp" +#include "Storage.hpp" #include "Util.hpp" using namespace LOOLProtocol; diff --git a/loolwsd/Storage.hpp b/loolwsd/Storage.hpp new file mode 100644 index 0000000..7597783 --- /dev/null +++ b/loolwsd/Storage.hpp @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * 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/. + */ + +// Storage abstraction. +#ifndef INCLUDED_STORAGE_HPP +#define INCLUDED_STORAGE_HPP + +#include <string> + +#include "Auth.hpp" +#include "Util.hpp" + +/// Base class of all Storage abstractions. +class StorageBase +{ +public: + + /// Returns a local file path given a URI. + /// If necessary copies the file locally first. + virtual std::string getFilePathFromURI(const std::string& uri) = 0; + + /// Writes the contents of the file back to the URI. + virtual bool restoreFileToURI(const std::string& path, const std::string& uri) = 0; + +}; + +/// Trivial implementation of local storage that does not need do anything. +class LocalStorage : public StorageBase +{ +public: + + std::string getFilePathFromURI(const std::string& uri) override + { + // It's local already. + // TODO: Validate access? + return uri; + } + + bool restoreFileToURI(const std::string& path, const std::string& uri) + { + // Nothing to do. + (void)path; + (void)uri; + return false; + } +}; + +class WebDAVStorage : public StorageBase +{ +public: + + WebDAVStorage(const std::string& url, std::unique_ptr<AuthBase> authAgent) : + _url(url), + _authAgent(std::move(authAgent)) + { + } + + std::string getFilePathFromURI(const std::string& uri) override + { + // TODO: implement webdav GET. + return uri; + } + + bool restoreFileToURI(const std::string& path, const std::string& uri) + { + // TODO: implement webdav PUT. + (void)path; + (void)uri; + return false; + } + +private: + const std::string _url; + std::unique_ptr<AuthBase> _authAgent; +}; + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits