Skip to content
Snippets Groups Projects
Commit 770f6efb authored by Pierre Duchemin's avatar Pierre Duchemin Committed by Adrien Béraud
Browse files

Add swig interface for file transfer

Change-Id: I7428bbc065224cdb5c46b6d8aceeab3c28d848ba
parent ac0b8da8
Branches
Tags
No related merge requests found
/*
* Copyright (C) 2004-2017 Savoir-faire Linux Inc.
*
* Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
* Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
* Author: Pierre Duchemin <pierre.duchemin@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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
%apply int32_t { DRing::DataTransferEventCode };
%header %{
#include "dring/dring.h"
#include "dring/datatransfer_interface.h"
class DataTransferCallback {
public:
virtual ~DataTransferCallback(){}
virtual void dataTransferEvent(const uint64_t transferId, int eventCode){}
};
%}
%feature("director") DataTransferCallback;
namespace DRing {
struct DataTransferInfo
{
bool isOutgoing;
DRing::DataTransferEventCode lastEvent;
std::size_t totalSize {0};
std::streamsize bytesProgress {0};
std::string displayName;
std::string path;
std::string accountId;
std::string peer;
};
void acceptFileTransfer(const uint64_t id, const std::string &file_path, std::size_t offset);
void cancelDataTransfer(const uint64_t id);
std::streamsize dataTransferBytesProgress(const uint64_t id);
DRing::DataTransferInfo dataTransferInfo(const uint64_t id);
/* std::vector<uint64_t> dataTransferList(); */
uint64_t sendFile(const std::string &account_id, const std::string &peer_uri, const std::string &file_path, const std::string &display_name) throw(std::invalid_argument, std::runtime_error);
}
class DataTransferCallback {
public:
virtual ~DataTransferCallback(){}
virtual void dataTransferEvent(const uint64_t transferId, int eventCode){}
};
...@@ -52,8 +52,24 @@ ...@@ -52,8 +52,24 @@
return $jnicall; return $jnicall;
} }
/* Maps exceptions */
%typemap(throws, throws="java.lang.IllegalArgumentException") std::invalid_argument {
jclass excep = jenv->FindClass("java/lang/IllegalArgumentException");
if (excep)
jenv->ThrowNew(excep, $1.what().c_str());
return $null;
}
%typemap(throws, throws="java.lang.IllegalStateException") std::runtime_error {
jclass excep = jenv->FindClass("java/lang/IllegalStateException");
if (excep)
jenv->ThrowNew(excep, $1.what().c_str());
return $null;
}
/* Avoid uint64_t to be converted to BigInteger */ /* Avoid uint64_t to be converted to BigInteger */
%apply int64_t { uint64_t }; %apply int64_t { uint64_t };
%apply int64_t { const uint64_t };
%apply int64_t { std::streamsize };
%apply uint64_t { time_t }; %apply uint64_t { time_t };
namespace std { namespace std {
...@@ -180,6 +196,7 @@ namespace std { ...@@ -180,6 +196,7 @@ namespace std {
%include "managerimpl.i" %include "managerimpl.i"
%include "callmanager.i" %include "callmanager.i"
%include "configurationmanager.i" %include "configurationmanager.i"
%include "datatransfer.i"
%include "presencemanager.i" %include "presencemanager.i"
%include "videomanager.i" %include "videomanager.i"
...@@ -197,6 +214,8 @@ void init(ConfigurationCallback* confM, Callback* callM, PresenceCallback* presM ...@@ -197,6 +214,8 @@ void init(ConfigurationCallback* confM, Callback* callM, PresenceCallback* presM
using DRing::exportable_callback; using DRing::exportable_callback;
using DRing::CallSignal; using DRing::CallSignal;
using DRing::ConfigurationSignal; using DRing::ConfigurationSignal;
using DRing::DataTransferInfo;
using DRing::DataTransferSignal;
using DRing::PresenceSignal; using DRing::PresenceSignal;
using DRing::VideoSignal; using DRing::VideoSignal;
...@@ -258,6 +277,9 @@ void init(ConfigurationCallback* confM, Callback* callM, PresenceCallback* presM ...@@ -258,6 +277,9 @@ void init(ConfigurationCallback* confM, Callback* callM, PresenceCallback* presM
exportable_callback<PresenceSignal::SubscriptionStateChanged>(bind(&PresenceCallback::subscriptionStateChanged, presM, _1, _2, _3 )) exportable_callback<PresenceSignal::SubscriptionStateChanged>(bind(&PresenceCallback::subscriptionStateChanged, presM, _1, _2, _3 ))
}; };
const std::map<std::string, SharedCallback> dataTransferEvHandlers = {
};
const std::map<std::string, SharedCallback> videoEvHandlers = { const std::map<std::string, SharedCallback> videoEvHandlers = {
exportable_callback<VideoSignal::GetCameraInfo>(bind(&VideoCallback::getCameraInfo, videoM, _1, _2, _3, _4)), exportable_callback<VideoSignal::GetCameraInfo>(bind(&VideoCallback::getCameraInfo, videoM, _1, _2, _3, _4)),
exportable_callback<VideoSignal::SetParameters>(bind(&VideoCallback::setParameters, videoM, _1, _2, _3, _4, _5)), exportable_callback<VideoSignal::SetParameters>(bind(&VideoCallback::setParameters, videoM, _1, _2, _3, _4, _5)),
...@@ -273,6 +295,7 @@ void init(ConfigurationCallback* confM, Callback* callM, PresenceCallback* presM ...@@ -273,6 +295,7 @@ void init(ConfigurationCallback* confM, Callback* callM, PresenceCallback* presM
registerCallHandlers(callEvHandlers); registerCallHandlers(callEvHandlers);
registerConfHandlers(configEvHandlers); registerConfHandlers(configEvHandlers);
registerPresHandlers(presenceEvHandlers); registerPresHandlers(presenceEvHandlers);
registerDataXferHandlers(dataTransferEvHandlers);
registerVideoHandlers(videoEvHandlers); registerVideoHandlers(videoEvHandlers);
DRing::start(); DRing::start();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment