Synchronize clipboard bi-directional with the android container

This commit is contained in:
Simon Fels 2017-01-15 12:38:22 +01:00
commit db3499fd89
16 changed files with 213 additions and 4 deletions

View file

@ -21,6 +21,9 @@
#include "anbox_rpc.pb.h"
#include "anbox_bridge.pb.h"
#define LOG_TAG "Anboxd"
#include <cutils/log.h>
namespace anbox {
PlatformApiStub::PlatformApiStub(const std::shared_ptr<rpc::Channel> &rpc_channel) :
rpc_channel_(rpc_channel) {
@ -87,4 +90,55 @@ void PlatformApiStub::update_application_list(const ApplicationListUpdate &updat
rpc_channel_->send_event(seq);
}
void PlatformApiStub::on_clipboard_data_set(Request<protobuf::rpc::Void> *request) {
request->wh.result_received();
}
void PlatformApiStub::set_clipboard_data(const ClipboardData &data) {
auto c = std::make_shared<Request<protobuf::rpc::Void>>();
protobuf::bridge::ClipboardData message;
message.set_text(data.text);
{
std::lock_guard<decltype(mutex_)> lock(mutex_);
c->wh.expect_result();
}
rpc_channel_->call_method("set_clipboard_data", &message, c->response.get(),
google::protobuf::NewCallback(
this, &PlatformApiStub::on_clipboard_data_set, c.get()));
c->wh.wait_for_all();
if (c->response->has_error()) throw std::runtime_error(c->response->error());
}
void PlatformApiStub::on_clipboard_data_get(Request<protobuf::bridge::ClipboardData> *request) {
request->wh.result_received();
}
PlatformApiStub::ClipboardData PlatformApiStub::get_clipboard_data() {
auto c = std::make_shared<Request<protobuf::bridge::ClipboardData>>();
protobuf::rpc::Void message;
received_clipboard_data_ = ClipboardData{};
{
std::lock_guard<decltype(mutex_)> lock(mutex_);
c->wh.expect_result();
}
rpc_channel_->call_method("get_clipboard_data", &message, c->response.get(),
google::protobuf::NewCallback(
this, &PlatformApiStub::on_clipboard_data_get, c.get()));
c->wh.wait_for_all();
if (c->response->has_error()) throw std::runtime_error(c->response->error());
return ClipboardData{c->response->text()};
}
} // namespace anbox