Commit cec87854 authored by Guillaume Roguez's avatar Guillaume Roguez Committed by Olivier SOLDANO

datatransfer: add dataTransferList API

Add API to obtain the list of known datatransfer.
libring and DBus API included.

Change-Id: I4e1a46c132f99bd36b4a531035dbc83261061093
Reviewed-by: default avatarOlivier Soldano <olivier.soldano@savoirfairelinux.com>
parent bf105816
......@@ -1410,7 +1410,14 @@
<arg type="s" name="display_name" direction="in"></arg>
</method>
<method name="dataTransferInfo" tp:name-for-bindings="dataTransferInfo">
<method name="dataTransferList" tp:name-for-bindings="dataTransferList">
<tp:added version="4.2.0"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="VectorULongLong"/>
<arg type="at" name="DataTransferList" direction="out">
</arg>
</method>
<method name="dataTransferInfo" tp:name-for-bindings="dataTransferInfo">
<tp:added version="4.2.0"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="DataTransferInfo"/>
<arg type="(buttss)" name="DataTransferInfo" direction="out">
......@@ -1419,7 +1426,7 @@
</arg>
</method>
<method name="dataTransferBytesSent" tp:name-for-bindings="dataTransferBytesSent">
<method name="dataTransferBytesSent" tp:name-for-bindings="dataTransferBytesSent">
<tp:added version="4.2.0"/>
<arg type="t" name="BytesProgress" direction="out">
</arg>
......
......@@ -640,3 +640,9 @@ DBusConfigurationManager::dataTransferBytesSent(const uint64_t& id)
{
return DRing::dataTransferBytesSent(id);;
}
auto
DBusConfigurationManager::dataTransferList() -> decltype(DRing::dataTransferList())
{
return DRing::dataTransferList();;
}
......@@ -157,6 +157,7 @@ class DBusConfigurationManager :
const std::string& file_path, const std::string& display_name);
DBus::Struct<bool, uint32_t, uint64_t, uint64_t, std::string, std::string> dataTransferInfo(const DRing::DataTransferId& id);
uint64_t dataTransferBytesSent(const uint64_t& id);
std::vector<uint64_t> dataTransferList();
};
#endif // __RING_DBUSCONFIGURATIONMANAGER_H__
......@@ -41,6 +41,12 @@ registerDataXferHandlers(const std::map<std::string, std::shared_ptr<CallbackWra
}
}
std::vector<DataTransferId>
dataTransferList()
{
return ring::Manager::instance().dataTransfers->list();
}
DataTransferId
sendFile(const std::string& account_id,
const std::string& peer_uri,
......
......@@ -25,6 +25,7 @@
#include "peer_connection.h"
#include "fileutils.h"
#include "string_utils.h"
#include "map_utils.h"
#include "client/ring_signal.h"
#include <stdexcept>
......@@ -365,6 +366,13 @@ DataTransferFacade::~DataTransferFacade()
RING_WARN("facade destroy, pimpl @%p", pimpl_.get());
};
std::vector<DRing::DataTransferId>
DataTransferFacade::list() const
{
std::lock_guard<std::mutex> lk {pimpl_->mapMutex_};
return map_utils::extractKeys(pimpl_->map_);
}
DRing::DataTransferId
DataTransferFacade::sendFile(const std::string& account_id, const std::string& peer_uri,
const std::string& file_path, const std::string& display_name)
......
......@@ -34,6 +34,9 @@ public:
DataTransferFacade();
~DataTransferFacade();
/// Return all known transfer id
std::vector<DRing::DataTransferId> list() const;
/// Send a file to a peer.
/// Open a file and send its contents over a reliable connection
/// to given peer using the protocol from given account.
......
......@@ -25,6 +25,7 @@
#include <string>
#include <map>
#include <vector>
#include <memory>
#include <cstdlib> // std::size_t
#include <ios> // std::streamsize
......@@ -57,6 +58,8 @@ struct DataTransferInfo
std::string path; ///< associated local file path if supported (empty, if not)
};
std::vector<DataTransferId> dataTransferList();
/// Asynchronously send a file to a peer using given account connection.
///
/// If given account supports a file transfer protocol this function creates
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment