data_transfer.h 2.59 KB
Newer Older
1
/*
2
 *  Copyright (C) 2017-2019 Savoir-faire Linux Inc.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 *
 *  Author: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
 */

#pragma once

#include "dring/datatransfer_interface.h"

#include <memory>
#include <string>

Adrien Béraud's avatar
Adrien Béraud committed
28
namespace jami {
29

30 31
class Stream;

32 33 34 35 36
struct IncomingFileInfo {
  DRing::DataTransferId id;
  std::shared_ptr<Stream> stream;
};

37 38 39 40 41 42 43
/// Front-end to data transfer service
class DataTransferFacade
{
public:
    DataTransferFacade();
    ~DataTransferFacade();

44 45
    /// \see DRing::dataTransferList
    std::vector<DRing::DataTransferId> list() const noexcept;
46

47 48 49
    /// \see DRing::sendFile
    DRing::DataTransferError sendFile(const DRing::DataTransferInfo& info,
                                      DRing::DataTransferId& id) noexcept;
50

51 52 53 54
    /// \see DRing::acceptFileTransfer
    DRing::DataTransferError acceptAsFile(const DRing::DataTransferId& id,
                                          const std::string& file_path,
                                          int64_t offset) noexcept;
55

56
    /// \see DRing::cancelDataTransfer
57 58 59 60
    DRing::DataTransferError cancel(const DRing::DataTransferId &id) noexcept;

    /// Used by p2p.cpp
    void close(const DRing::DataTransferId &id) noexcept;
61

62 63 64
    /// \see DRing::dataTransferInfo
    DRing::DataTransferError info(const DRing::DataTransferId& id,
                                  DRing::DataTransferInfo& info) const noexcept;
65

66 67 68
    /// \see DRing::dataTransferBytesProgress
    DRing::DataTransferError bytesProgress(const DRing::DataTransferId& id, int64_t& total,
                                           int64_t& progress) const noexcept;
69 70

    /// Create an IncomingFileTransfer object.
71
    /// \return a shared pointer on created Stream object, or nullptr in case of error
72
    IncomingFileInfo onIncomingFileRequest(const DRing::DataTransferInfo &info);
73 74 75 76 77 78

private:
    class Impl;
    std::unique_ptr<Impl> pimpl_;
};

Adrien Béraud's avatar
Adrien Béraud committed
79
} // namespace jami