Merge lp:~dandrader/unity-mir/clipboard into lp:unity-mir

Proposed by Daniel d'Andrada
Status: Merged
Approved by: kevin gunn
Approved revision: 176
Merged at revision: 179
Proposed branch: lp:~dandrader/unity-mir/clipboard
Merge into: lp:unity-mir
Diff against target: 497 lines (+321/-4)
12 files modified
CMakeLists.txt (+5/-0)
debian/control (+2/-0)
src/unity-mir/CMakeLists.txt (+22/-2)
src/unity-mir/messageprocessor.cpp (+45/-0)
src/unity-mir/messageprocessor.h (+44/-0)
src/unity-mir/sessioncreator.cpp (+41/-0)
src/unity-mir/sessioncreator.h (+45/-0)
src/unity-mir/shellserverconfiguration.cpp (+17/-1)
src/unity-mir/shellserverconfiguration.h (+8/-1)
src/unity-mir/unityprotobufservice.cpp (+35/-0)
src/unity-mir/unityprotobufservice.h (+40/-0)
src/unity-mir/unityrpc.proto (+17/-0)
To merge this branch: bzr merge lp:~dandrader/unity-mir/clipboard
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Alan Griffiths Approve
Review via email: mp+205135@code.launchpad.net

Commit message

Unity8 now provides a clipboard service through the mir socket

That service can later be used for other custom messages as well.

Description of the change

Needs:
https://code.launchpad.net/~dandrader/platform-api/unity8_clipboard/+merge/205138
Mir 0.1.5

You can test it with this simple application:
http://ubuntuone.com/5nQjzPLv2GlLXBIyJ4LYsS

Also tested with ubuntu-ui-toolkit-gallery.qml (from lp:ubuntu-ui-toolkit), in the "Text Fields" section.

Doesn't work with the webbrowser though. Might be a problem with their code.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~dandrader/unity-mir/clipboard updated
173. By Daniel d'Andrada

Unity8 now provides a clipboard service through the mir socket

That service can later be used for other custom messages as well.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

+++ src/unity-mir/CMakeLists.txt
+ boost_system
Does this require adding libboost-system-dev to debian/control?

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> +++ src/unity-mir/CMakeLists.txt
> + boost_system
> Does this require adding libboost-system-dev to debian/control?

Not sure, to be honest. But I'll add it just to be on the safe side.

lp:~dandrader/unity-mir/clipboard updated
174. By Daniel d'Andrada

Added libboost-system-dev to build dependencies

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

+message Void {
+ optional string error = 127;
+}
+service UnityService {
+ rpc copy(Clip) returns (Void);
+ rpc paste(Void) returns (Clip);
+}
I'm curious why you an rpc call for copy. Can copy fail? If not, would not a message be sufficient?

Revision history for this message
Gerry Boland (gerboland) wrote :

+ std::string clip;
m_clip please.

review: Needs Fixing
lp:~dandrader/unity-mir/clipboard updated
175. By Daniel d'Andrada

s/clip/m_clip to comply with coding style

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> + std::string clip;
> m_clip please.

done.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> +message Void {
> + optional string error = 127;
> +}
> +service UnityService {
> + rpc copy(Clip) returns (Void);
> + rpc paste(Void) returns (Clip);
> +}
> I'm curious why you an rpc call for copy. Can copy fail? If not, would not a
> message be sufficient?

Any RPC can fail, theoretically.
And that's the way communication between client and service works in protobuffer. A request messsage and a reply message.

Revision history for this message
Gerry Boland (gerboland) wrote :

+class UnityService : public unity::protobuf::UnityService
class name kinda vague, could we make it UnityClientService? Or something like that?

I'd also appreciate DLOG messages in those copy/paste methods to ease debugging.

Revision history for this message
Gerry Boland (gerboland) wrote :

> I'm curious why you an rpc call for copy. Can copy fail? If not, would not a
> message be sufficient?
<alan_g> greyback: "copy" needs to be an RPC call because it happens client side and the existing support in Mir is for RPC on the client and messaging on the server.

Objection withdrawn

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

LGTM

review: Approve
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> +class UnityService : public unity::protobuf::UnityService
> class name kinda vague, could we make it UnityClientService? Or something like
> that?

The vagueness is intentional. This service is supposed to hold all the future RPC that unity8 has with apps that is not covered by mir's protocol. As for you suggestion, I think "Client" just bloats the name without adding any more meaning as every "Service" implies a Client-Server relationship. IT might even be misleading as it might imply that this clients is the client-side of a service, whereas it's actually the server side.

Another suitable name I think would be UnityProtobufService, which is exactly what it is: a protobuf service provided by unity. Do you like it better?

>
> I'd also appreciate DLOG messages in those copy/paste methods to ease
> debugging.

This code is bug free. Why would you ever want to debug it? :P

Revision history for this message
Olivier Tilloy (osomon) wrote :

> Also tested with ubuntu-ui-toolkit-gallery.qml (from lp:ubuntu-ui-toolkit), in the "Text Fields" section.

The TextField component in the UITK wraps the standard TextInput QML component, which talks directly to the system clipboard…

> Doesn't work with the webbrowser though. Might be a problem with their code.

… Whereas copying content from a webpage in the browser uses the Clipboard object exposed by the UITK (see http://developer.ubuntu.com/api/qml/sdk-1.0/Ubuntu.Components.Clipboard/). This component is supposed to talk to the system clipboard under the hood, so it might be a bug in the component itself.

lp:~dandrader/unity-mir/clipboard updated
176. By Daniel d'Andrada

s/UnityService/UnityProtobufService

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-01-15 14:59:00 +0000
3+++ CMakeLists.txt 2014-02-07 16:10:33 +0000
4@@ -58,6 +58,11 @@
5 find_package(Qt5Quick REQUIRED)
6 find_package(Qt5DBus REQUIRED)
7
8+find_package(Protobuf REQUIRED)
9+if(PROTOBUF_PROTOC_EXECUTABLE STREQUAL "PROTOBUF_PROTOC_EXECUTABLE-NOTFOUND")
10+ message(SEND_ERROR "protoc executable not found! Missing protobuf-compiler package?")
11+endif()
12+
13 pkg_check_modules(MIRSERVER mirserver REQUIRED)
14 pkg_check_modules(MIRCOMMON mircommon REQUIRED)
15 pkg_check_modules(UBUNTU_PLATFORM_API ubuntu-platform-api REQUIRED)
16
17=== modified file 'debian/control'
18--- debian/control 2014-02-04 16:47:30 +0000
19+++ debian/control 2014-02-07 16:10:33 +0000
20@@ -5,6 +5,7 @@
21 Build-Depends: debhelper (>= 9),
22 cmake,
23 pkg-config,
24+ libboost-system-dev,
25 libplatform-api1-dev,
26 libmirserver-dev (>= 0.1.4),
27 libmirclient-dev (>= 0.1.4),
28@@ -13,6 +14,7 @@
29 qt5-default,
30 qtbase5-dev,
31 qtdeclarative5-dev,
32+ protobuf-compiler,
33 Standards-Version: 3.9.4
34 Homepage: https://launchpad.net/unity-mir
35 # If you aren't a member of ~mir-team but need to upload packaging changes,
36
37=== modified file 'src/unity-mir/CMakeLists.txt'
38--- src/unity-mir/CMakeLists.txt 2014-01-09 15:49:18 +0000
39+++ src/unity-mir/CMakeLists.txt 2014-02-07 16:10:33 +0000
40@@ -2,6 +2,13 @@
41 ${MIRCOMMON_INCLUDE_DIRS}
42 ${MIRSERVER_INCLUDE_DIRS}
43 ${UBUNTU_PLATFORM_API_INCLUDE_DIRS}
44+ ${PROTOBUF_INCLUDE_DIRS}
45+ ${CMAKE_CURRENT_BINARY_DIR}
46+)
47+
48+protobuf_generate_cpp(
49+ GENERATED_PROTOBUF_SRCS GENERATED_PROTOBUF_HDRS
50+ unityrpc.proto
51 )
52
53 set(
54@@ -11,14 +18,19 @@
55 initialsurfaceplacementstrategy.h
56 qmirserverapplication.h
57 qmirserver.h
58+ messageprocessor.h
59 sessionauthorizer.h
60+ sessioncreator.h
61 sessionlistener.h
62 shellserverconfiguration.h
63 surfacefactory.h
64 surfaceconfigurator.h
65+ unityprotobufservice.h
66 logging.h
67 focussetter.h
68- serverstatuslistener.h)
69+ serverstatuslistener.h
70+ ${GENERATED_PROTOBUF_HDRS}
71+)
72
73 add_library(
74 unity-mir SHARED
75@@ -27,15 +39,20 @@
76 initialsurfaceplacementstrategy.cpp
77 qmirserverapplication.cpp
78 qmirserver.cpp
79+ messageprocessor.cpp
80 sessionauthorizer.cpp
81+ sessioncreator.cpp
82 sessionlistener.cpp
83 shellserverconfiguration.cpp
84 surfacefactory.cpp
85 surfaceconfigurator.cpp
86+ unityprotobufservice.cpp
87 focussetter.cpp
88 serverstatuslistener.cpp
89
90- ${UNITY_MIR_HEADERS})
91+ ${UNITY_MIR_HEADERS}
92+ ${GENERATED_PROTOBUF_SRCS}
93+)
94
95 # We should not need this line according to the Qt5/CMake docs.
96 # However, when removing it, include paths are not set and linking to Qt5 fails.
97@@ -60,6 +77,9 @@
98 ${UBUNTU_PLATFORM_API_LIBRARIES}
99 ${MIRCOMMON_LIBRARIES}
100 ${MIRSERVER_LIBRARIES}
101+ ${PROTOBUF_LIBRARIES}
102+
103+ boost_system
104
105 ubuntu_application_api_mirserver)
106
107
108=== added file 'src/unity-mir/messageprocessor.cpp'
109--- src/unity-mir/messageprocessor.cpp 1970-01-01 00:00:00 +0000
110+++ src/unity-mir/messageprocessor.cpp 2014-02-07 16:10:33 +0000
111@@ -0,0 +1,45 @@
112+/*
113+ * Copyright (C) 2014 Canonical, Ltd.
114+ *
115+ * This program is free software: you can redistribute it and/or modify it under
116+ * the terms of the GNU Lesser General Public License version 3, as published by
117+ * the Free Software Foundation.
118+ *
119+ * This program is distributed in the hope that it will be useful, but WITHOUT
120+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
121+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
122+ * Lesser General Public License for more details.
123+ *
124+ * You should have received a copy of the GNU Lesser General Public License
125+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
126+ */
127+
128+#include "messageprocessor.h"
129+#include <mir/frontend/template_protobuf_message_processor.h>
130+
131+
132+bool MessageProcessor::dispatch(mir::frontend::detail::Invocation const& invocation)
133+{
134+ if ("copy" == invocation.method_name()) {
135+ mir::frontend::detail::invoke(
136+ this,
137+ m_unityService.get(),
138+ &unity::protobuf::UnityService::copy,
139+ invocation);
140+ return true;
141+ } else if ("paste" == invocation.method_name()) {
142+ mir::frontend::detail::invoke(
143+ this,
144+ m_unityService.get(),
145+ &unity::protobuf::UnityService::paste,
146+ invocation);
147+ return true;
148+ } else {
149+ return m_wrapped->dispatch(invocation);
150+ }
151+}
152+
153+void MessageProcessor::send_response(::google::protobuf::uint32 id, ::google::protobuf::Message* response)
154+{
155+ m_sender->send_response(id, response, {});
156+}
157
158=== added file 'src/unity-mir/messageprocessor.h'
159--- src/unity-mir/messageprocessor.h 1970-01-01 00:00:00 +0000
160+++ src/unity-mir/messageprocessor.h 2014-02-07 16:10:33 +0000
161@@ -0,0 +1,44 @@
162+/*
163+ * Copyright (C) 2014 Canonical, Ltd.
164+ *
165+ * This program is free software: you can redistribute it and/or modify it under
166+ * the terms of the GNU Lesser General Public License version 3, as published by
167+ * the Free Software Foundation.
168+ *
169+ * This program is distributed in the hope that it will be useful, but WITHOUT
170+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
171+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
172+ * Lesser General Public License for more details.
173+ *
174+ * You should have received a copy of the GNU Lesser General Public License
175+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
176+ */
177+
178+#include <mir/frontend/message_processor.h>
179+#include <mir/frontend/protobuf_message_sender.h>
180+
181+#include "unityrpc.pb.h"
182+
183+#include <memory>
184+
185+class MessageProcessor : public mir::frontend::detail::MessageProcessor
186+{
187+public:
188+ MessageProcessor(
189+ std::shared_ptr<unity::protobuf::UnityService> const& unityService,
190+ std::shared_ptr<mir::frontend::detail::ProtobufMessageSender> const& sender,
191+ std::shared_ptr<mir::frontend::detail::MessageProcessor> const& wrapped) :
192+ m_sender(sender),
193+ m_wrapped(wrapped),
194+ m_unityService(unityService) {}
195+
196+ bool dispatch(mir::frontend::detail::Invocation const& invocation);
197+
198+ void send_response(::google::protobuf::uint32 id, ::google::protobuf::Message* response);
199+
200+private:
201+ std::shared_ptr<mir::frontend::detail::ProtobufMessageSender> const m_sender;
202+ std::shared_ptr<mir::frontend::detail::MessageProcessor> const m_wrapped;
203+ std::shared_ptr<unity::protobuf::UnityService> const m_unityService;
204+};
205+
206
207=== added file 'src/unity-mir/sessioncreator.cpp'
208--- src/unity-mir/sessioncreator.cpp 1970-01-01 00:00:00 +0000
209+++ src/unity-mir/sessioncreator.cpp 2014-02-07 16:10:33 +0000
210@@ -0,0 +1,41 @@
211+/*
212+ * Copyright (C) 2014 Canonical, Ltd.
213+ *
214+ * This program is free software: you can redistribute it and/or modify it under
215+ * the terms of the GNU Lesser General Public License version 3, as published by
216+ * the Free Software Foundation.
217+ *
218+ * This program is distributed in the hope that it will be useful, but WITHOUT
219+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
220+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
221+ * Lesser General Public License for more details.
222+ *
223+ * You should have received a copy of the GNU Lesser General Public License
224+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
225+ */
226+
227+#include "sessioncreator.h"
228+#include <messageprocessor.h>
229+
230+SessionCreator::SessionCreator(
231+ std::shared_ptr<unity::protobuf::UnityService> const& unityService,
232+ std::shared_ptr<mir::frontend::ProtobufIpcFactory> const& ipc_factory,
233+ std::shared_ptr<mir::frontend::SessionAuthorizer> const& session_authorizer,
234+ std::shared_ptr<mir::frontend::MessageProcessorReport> const& report)
235+ : ProtobufSessionCreator(ipc_factory, session_authorizer, report)
236+ , m_unityService(unityService)
237+{
238+}
239+
240+std::shared_ptr<mir::frontend::detail::MessageProcessor> SessionCreator::create_processor(
241+ std::shared_ptr<mir::frontend::detail::ProtobufMessageSender> const& sender,
242+ std::shared_ptr<mir::protobuf::DisplayServer> const& display_server,
243+ std::shared_ptr<mir::frontend::MessageProcessorReport> const& report) const
244+{
245+ auto const wrapped = mir::frontend::ProtobufSessionCreator::create_processor(
246+ sender,
247+ display_server,
248+ report);
249+
250+ return std::make_shared<MessageProcessor>(m_unityService, sender, wrapped);
251+}
252
253=== added file 'src/unity-mir/sessioncreator.h'
254--- src/unity-mir/sessioncreator.h 1970-01-01 00:00:00 +0000
255+++ src/unity-mir/sessioncreator.h 2014-02-07 16:10:33 +0000
256@@ -0,0 +1,45 @@
257+/*
258+ * Copyright (C) 2014 Canonical, Ltd.
259+ *
260+ * This program is free software: you can redistribute it and/or modify it under
261+ * the terms of the GNU Lesser General Public License version 3, as published by
262+ * the Free Software Foundation.
263+ *
264+ * This program is distributed in the hope that it will be useful, but WITHOUT
265+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
266+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
267+ * Lesser General Public License for more details.
268+ *
269+ * You should have received a copy of the GNU Lesser General Public License
270+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
271+ */
272+
273+#ifndef SESSIONCREATOR_H
274+#define SESSIONCREATOR_H
275+
276+#include <mir/frontend/protobuf_session_creator.h>
277+
278+namespace unity {
279+ namespace protobuf {
280+ class UnityService;
281+ }
282+}
283+
284+class SessionCreator : public mir::frontend::ProtobufSessionCreator
285+{
286+public:
287+ SessionCreator(
288+ std::shared_ptr<unity::protobuf::UnityService> const& unityService,
289+ std::shared_ptr<mir::frontend::ProtobufIpcFactory> const& ipc_factory,
290+ std::shared_ptr<mir::frontend::SessionAuthorizer> const& session_authorizer,
291+ std::shared_ptr<mir::frontend::MessageProcessorReport> const& report);
292+
293+ std::shared_ptr<mir::frontend::detail::MessageProcessor> create_processor(
294+ std::shared_ptr<mir::frontend::detail::ProtobufMessageSender> const& sender,
295+ std::shared_ptr<mir::protobuf::DisplayServer> const& display_server,
296+ std::shared_ptr<mir::frontend::MessageProcessorReport> const& report) const override;
297+private:
298+ std::shared_ptr<unity::protobuf::UnityService> m_unityService;
299+};
300+
301+#endif // SESSIONCREATOR_H
302
303=== modified file 'src/unity-mir/shellserverconfiguration.cpp'
304--- src/unity-mir/shellserverconfiguration.cpp 2013-12-11 01:16:48 +0000
305+++ src/unity-mir/shellserverconfiguration.cpp 2014-02-07 16:10:33 +0000
306@@ -1,5 +1,5 @@
307 /*
308- * Copyright (C) 2013 Canonical, Ltd.
309+ * Copyright (C) 2013-2014 Canonical, Ltd.
310 *
311 * This program is free software: you can redistribute it and/or modify it under
312 * the terms of the GNU Lesser General Public License version 3, as published by
313@@ -16,8 +16,10 @@
314
315 #include "shellserverconfiguration.h"
316
317+#include "unityprotobufservice.h"
318 #include "initialsurfaceplacementstrategy.h"
319 #include "serverstatuslistener.h"
320+#include "sessioncreator.h"
321 #include "sessionlistener.h"
322 #include "surfaceconfigurator.h"
323 #include "surfacefactory.h"
324@@ -30,6 +32,7 @@
325 ShellServerConfiguration::ShellServerConfiguration(int argc, char const* argv[], QObject* parent)
326 : QObject(parent)
327 , DefaultServerConfiguration(argc, argv)
328+ , m_unityService(std::make_shared<UnityProtobufService>())
329 {
330 DLOG("ShellServerConfiguration created");
331 }
332@@ -78,6 +81,19 @@
333 });
334 }
335
336+std::shared_ptr<mir::frontend::SessionCreator>
337+ShellServerConfiguration::the_session_creator()
338+{
339+ return session_creator([this]
340+ {
341+ return std::make_shared<SessionCreator>(
342+ m_unityService,
343+ the_ipc_factory(the_frontend_shell(), the_buffer_allocator()),
344+ the_session_authorizer(),
345+ the_message_processor_report());
346+ });
347+}
348+
349 // FIXME: Needed to detect the shell's surface - there must be a better way
350 std::shared_ptr<msh::SurfaceFactory>
351 ShellServerConfiguration::the_shell_surface_factory()
352
353=== modified file 'src/unity-mir/shellserverconfiguration.h'
354--- src/unity-mir/shellserverconfiguration.h 2013-12-11 01:16:48 +0000
355+++ src/unity-mir/shellserverconfiguration.h 2014-02-07 16:10:33 +0000
356@@ -1,5 +1,5 @@
357 /*
358- * Copyright (C) 2013 Canonical, Ltd.
359+ * Copyright (C) 2013-2014 Canonical, Ltd.
360 *
361 * This program is free software: you can redistribute it and/or modify it under
362 * the terms of the GNU Lesser General Public License version 3, as published by
363@@ -20,6 +20,11 @@
364 #include <QObject>
365 #include <mir/default_server_configuration.h>
366
367+namespace unity {
368+ namespace protobuf {
369+ class UnityService;
370+ }
371+}
372
373 class FocusSetter;
374 class SessionListener;
375@@ -49,6 +54,7 @@
376 std::shared_ptr<mir::shell::FocusSetter> the_shell_focus_setter() override;
377 std::shared_ptr<mir::ServerStatusListener> the_server_status_listener() override;
378 std::shared_ptr<mir::frontend::SessionAuthorizer> the_session_authorizer() override;
379+ std::shared_ptr<mir::frontend::SessionCreator> the_session_creator() override;
380
381 /* qt specific */
382 // getters
383@@ -61,6 +67,7 @@
384
385 protected:
386 std::shared_ptr<SurfaceFactory> m_surfaceFactory;
387+ std::shared_ptr<unity::protobuf::UnityService> m_unityService;
388 };
389
390 #endif // SHELLSERVERCONFIGURATION_H
391
392=== added file 'src/unity-mir/unityprotobufservice.cpp'
393--- src/unity-mir/unityprotobufservice.cpp 1970-01-01 00:00:00 +0000
394+++ src/unity-mir/unityprotobufservice.cpp 2014-02-07 16:10:33 +0000
395@@ -0,0 +1,35 @@
396+/*
397+ * Copyright (C) 2014 Canonical, Ltd.
398+ *
399+ * This program is free software: you can redistribute it and/or modify it under
400+ * the terms of the GNU Lesser General Public License version 3, as published by
401+ * the Free Software Foundation.
402+ *
403+ * This program is distributed in the hope that it will be useful, but WITHOUT
404+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
405+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
406+ * Lesser General Public License for more details.
407+ *
408+ * You should have received a copy of the GNU Lesser General Public License
409+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
410+ */
411+
412+#include "unityprotobufservice.h"
413+
414+void UnityProtobufService::copy(::google::protobuf::RpcController* /*controller*/,
415+ const ::unity::protobuf::Clip* newClip,
416+ ::unity::protobuf::Void* /*response*/,
417+ ::google::protobuf::Closure* done)
418+{
419+ m_clip = newClip->content();
420+ done->Run();
421+}
422+
423+void UnityProtobufService::paste(::google::protobuf::RpcController* /*controller*/,
424+ const ::unity::protobuf::Void* /*request*/,
425+ ::unity::protobuf::Clip* clipReturned,
426+ ::google::protobuf::Closure* done)
427+{
428+ clipReturned->set_content(m_clip);
429+ done->Run();
430+}
431
432=== added file 'src/unity-mir/unityprotobufservice.h'
433--- src/unity-mir/unityprotobufservice.h 1970-01-01 00:00:00 +0000
434+++ src/unity-mir/unityprotobufservice.h 2014-02-07 16:10:33 +0000
435@@ -0,0 +1,40 @@
436+/*
437+ * Copyright (C) 2014 Canonical, Ltd.
438+ *
439+ * This program is free software: you can redistribute it and/or modify it under
440+ * the terms of the GNU Lesser General Public License version 3, as published by
441+ * the Free Software Foundation.
442+ *
443+ * This program is distributed in the hope that it will be useful, but WITHOUT
444+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
445+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
446+ * Lesser General Public License for more details.
447+ *
448+ * You should have received a copy of the GNU Lesser General Public License
449+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
450+ */
451+
452+#ifndef UNITY_PROTOBUF_SERVICE_H
453+#define UNITY_PROTOBUF_SERVICE_H
454+
455+#include "unityrpc.pb.h"
456+#include <string>
457+
458+class UnityProtobufService : public unity::protobuf::UnityService
459+{
460+public:
461+ void copy(::google::protobuf::RpcController* controller,
462+ const ::unity::protobuf::Clip* request,
463+ ::unity::protobuf::Void* response,
464+ ::google::protobuf::Closure* done) override;
465+
466+ void paste(::google::protobuf::RpcController* controller,
467+ const ::unity::protobuf::Void* request,
468+ ::unity::protobuf::Clip* response,
469+ ::google::protobuf::Closure* done) override;
470+
471+private:
472+ std::string m_clip;
473+};
474+
475+#endif // UNITY_PROTOBUF_SERVICE_H
476
477=== added file 'src/unity-mir/unityrpc.proto'
478--- src/unity-mir/unityrpc.proto 1970-01-01 00:00:00 +0000
479+++ src/unity-mir/unityrpc.proto 2014-02-07 16:10:33 +0000
480@@ -0,0 +1,17 @@
481+option cc_generic_services = true;
482+
483+package unity.protobuf;
484+
485+message Clip {
486+ required bytes content = 1;
487+ optional string error = 127;
488+}
489+
490+message Void {
491+ optional string error = 127;
492+}
493+
494+service UnityService {
495+ rpc copy(Clip) returns (Void);
496+ rpc paste(Void) returns (Clip);
497+}

Subscribers

People subscribed via source and target branches