Merge lp:~dandrader/qtmir/dbusClipboard into lp:qtmir

Proposed by Daniel d'Andrada
Status: Merged
Approved by: Robert Carr
Approved revision: 254
Merged at revision: 260
Proposed branch: lp:~dandrader/qtmir/dbusClipboard
Merge into: lp:qtmir
Diff against target: 2331 lines (+471/-1590)
20 files modified
src/platforms/mirserver/clipboard.cpp (+262/-0)
src/platforms/mirserver/clipboard.h (+88/-0)
src/platforms/mirserver/connectioncreator.cpp (+0/-42)
src/platforms/mirserver/connectioncreator.h (+0/-46)
src/platforms/mirserver/logging.h (+1/-0)
src/platforms/mirserver/messageprocessor.cpp (+0/-49)
src/platforms/mirserver/messageprocessor.h (+0/-44)
src/platforms/mirserver/mirserver.pro (+4/-8)
src/platforms/mirserver/mirserverconfiguration.cpp (+0/-19)
src/platforms/mirserver/mirserverconfiguration.h (+0/-8)
src/platforms/mirserver/mirserverintegration.cpp (+13/-2)
src/platforms/mirserver/mirserverintegration.h (+10/-2)
src/platforms/mirserver/unityprotobufservice.cpp (+0/-35)
src/platforms/mirserver/unityprotobufservice.h (+0/-40)
src/platforms/mirserver/unityrpc.cpp (+0/-742)
src/platforms/mirserver/unityrpc.h (+0/-535)
src/platforms/mirserver/unityrpc.proto (+0/-17)
tests/mirserver/Clipboard/Clipboard.pro (+16/-0)
tests/mirserver/Clipboard/clipboard_test.cpp (+76/-0)
tests/mirserver/mirserver.pro (+1/-1)
To merge this branch: bzr merge lp:~dandrader/qtmir/dbusClipboard
Reviewer Review Type Date Requested Status
Robert Carr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+235501@code.launchpad.net

Commit message

Provide a global clipboard via D-Bus

Description of the change

* Are there any related MPs required for this MP to build/function as expected? Please list.
https://code.launchpad.net/~dandrader/qtubuntu/dbusClipboard/+merge/235502

* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes.

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Not applicable.

Until bug 1372579 is released, to make sure apparmor doesn't block d-bus communication to that new interface and object add the following to /usr/share/apparmor/easyprof/templates/ubuntu/1.2/ubuntu-sdk":

"""
dbus (receive, send)
     bus=session
     path=/com/canonical/Unity/Clipboard
     interface=com.canonical.Unity.Clipboard,
"""

And then run:
$ sudo aa-clickhook -f

To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) wrote :

You could create an MR for apparmor-easyprof-ubuntu to add that apparmor exception

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

> You could create an MR for apparmor-easyprof-ubuntu to add that apparmor
> exception

It's bug 1372579. That's the way jdstrand asked me to proceed.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Robert Carr (robertcarr) wrote :

The comments and assert at 69/70 seems a little concerning...? Perhaps the data could be clipped? (even in Clipboard::setMimeData...then the assert could remain, becoming an actual precondition of the function).

Beyond that seems ok as a temporary solution.

review: Needs Fixing
Revision history for this message
Robert Carr (robertcarr) wrote :

I know this is a preexisting issue but when else to fix it "before release" as the comment references.

lp:~dandrader/qtmir/dbusClipboard updated
254. By Daniel d'Andrada

Implement contents size limitation in the D-Bus (global) clipboard

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

> The comments and assert at 69/70 seems a little concerning...? Perhaps the
> data could be clipped? (even in Clipboard::setMimeData...then the assert could
> remain, becoming an actual precondition of the function).

Implemented by size limitation. Clipping would make the resulting contents unusable (imagine a half written jpg). So I went for simply refusing/ignoring oversized clipboard contents instead.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Robert Carr (robertcarr) wrote :

LGTM!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'src/platforms/mirserver/clipboard.cpp'
--- src/platforms/mirserver/clipboard.cpp 1970-01-01 00:00:00 +0000
+++ src/platforms/mirserver/clipboard.cpp 2014-09-23 11:37:20 +0000
@@ -0,0 +1,262 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Daniel d'Andrada <daniel.dandrada@canonical.com>
17 */
18
19#include "clipboard.h"
20#include "logging.h"
21
22// C++ std lib
23#include <utility>
24
25#include <QDBusConnection>
26#include <QDBusError>
27#include <QMimeData>
28
29Q_LOGGING_CATEGORY(QTMIR_CLIPBOARD, "qtmir.clipboard")
30
31// FIXME(loicm) The clipboard data format is not defined by Ubuntu Platform API
32// which makes it impossible to have non-Qt applications communicate with Qt
33// applications through the clipboard API. The solution would be to have
34// Ubuntu Platform define the data format or propose an API that supports
35// embedding different mime types in the clipboard.
36
37// Data format:
38// number of mime types (sizeof(int))
39// data layout ((4 * sizeof(int)) * number of mime types)
40// mime type string offset (sizeof(int))
41// mime type string size (sizeof(int))
42// data offset (sizeof(int))
43// data size (sizeof(int))
44// data (n bytes)
45
46namespace {
47
48const int maxFormatsCount = 16;
49
50}
51
52namespace qtmir {
53
54QByteArray serializeMimeData(QMimeData *mimeData)
55{
56 const QStringList formats = mimeData->formats();
57 const int formatCount = qMin(formats.size(), maxFormatsCount);
58 const int headerSize = sizeof(int) + (formatCount * 4 * sizeof(int));
59 int bufferSize = headerSize;
60
61 for (int i = 0; i < formatCount; i++)
62 bufferSize += formats[i].size() + mimeData->data(formats[i]).size();
63
64 // Serialize data.
65 QByteArray serializedMimeData(bufferSize, 0 /* char to fill with */);
66 {
67 char *buffer = serializedMimeData.data();
68 int* header = reinterpret_cast<int*>(serializedMimeData.data());
69 int offset = headerSize;
70 header[0] = formatCount;
71 for (int i = 0; i < formatCount; i++) {
72 const int formatOffset = offset;
73 const int formatSize = formats[i].size();
74 const int dataOffset = offset + formatSize;
75 const int dataSize = mimeData->data(formats[i]).size();
76 memcpy(&buffer[formatOffset], formats[i].toLatin1().data(), formatSize);
77 memcpy(&buffer[dataOffset], mimeData->data(formats[i]).data(), dataSize);
78 header[i*4+1] = formatOffset;
79 header[i*4+2] = formatSize;
80 header[i*4+3] = dataOffset;
81 header[i*4+4] = dataSize;
82 offset += formatSize + dataSize;
83 }
84 }
85
86 return serializedMimeData;
87}
88
89QMimeData *deserializeMimeData(const QByteArray &serializedMimeData)
90{
91 if (static_cast<std::size_t>(serializedMimeData.size()) < sizeof(int)) {
92 // Data is invalid
93 return nullptr;
94 }
95
96 QMimeData *mimeData = new QMimeData;
97
98 const char* const buffer = serializedMimeData.constData();
99 const int* const header = reinterpret_cast<const int*>(serializedMimeData.constData());
100
101 const int count = qMin(header[0], maxFormatsCount);
102
103 for (int i = 0; i < count; i++) {
104 const int formatOffset = header[i*4+1];
105 const int formatSize = header[i*4+2];
106 const int dataOffset = header[i*4+3];
107 const int dataSize = header[i*4+4];
108
109 if (formatOffset + formatSize <= serializedMimeData.size()
110 && dataOffset + dataSize <= serializedMimeData.size()) {
111
112 QString mimeType = QString::fromLatin1(&buffer[formatOffset], formatSize);
113 QByteArray mimeDataBytes(&buffer[dataOffset], dataSize);
114
115 mimeData->setData(mimeType, mimeDataBytes);
116 }
117 }
118
119 return mimeData;
120}
121
122/************************************ DBusClipboard *****************************************/
123
124bool DBusClipboard::skipDBusRegistration = false;
125
126DBusClipboard::DBusClipboard(QObject *parent)
127 : QObject(parent)
128{
129 if (!skipDBusRegistration) {
130 performDBusRegistration();
131 }
132}
133
134void DBusClipboard::setContents(QByteArray newContents)
135{
136 setContentsHelper(std::move(newContents));
137}
138
139void DBusClipboard::SetContents(QByteArray newContents)
140{
141 qCDebug(QTMIR_CLIPBOARD, "D-Bus SetContents - %d bytes", newContents.size());
142
143 if (setContentsHelper(std::move(newContents))) {
144 Q_EMIT contentsChangedRemotely();
145 }
146}
147
148bool DBusClipboard::setContentsHelper(QByteArray newContents)
149{
150 if (newContents.size() > maxContentsSize) {
151 qCWarning(QTMIR_CLIPBOARD, "D-Bus clipboard refused the new contents (%d bytes) as they're"
152 " bigger than the maximum allowed size of %d bytes.",
153 newContents.size(), maxContentsSize);
154 return false;
155 }
156
157 if (newContents != m_contents) {
158 m_contents = std::move(newContents);
159 Q_EMIT ContentsChanged(m_contents);
160 return true;
161 } else {
162 return false;
163 }
164}
165
166QByteArray DBusClipboard::GetContents() const
167{
168 qCDebug(QTMIR_CLIPBOARD, "D-Bus GetContents - returning %d bytes", m_contents.size());
169 return m_contents;
170}
171
172void DBusClipboard::performDBusRegistration()
173{
174 QDBusConnection connection = QDBusConnection::sessionBus();
175 const char *serviceName = "com.canonical.QtMir";
176 const char *objectName = "/com/canonical/QtMir/Clipboard";
177
178 bool serviceOk = connection.registerService(serviceName);
179 if (!serviceOk) {
180 QDBusError error = connection.lastError();
181 QString errorMessage;
182 if (error.isValid()) {
183 errorMessage = error.message();
184 }
185 qCCritical(QTMIR_CLIPBOARD, "Failed to register service %s. %s", serviceName, qPrintable(errorMessage));
186 }
187
188 bool objectOk = connection.registerObject(objectName, this,
189 QDBusConnection::ExportScriptableSignals
190 | QDBusConnection::ExportScriptableSlots);
191 if (!objectOk) {
192 QDBusError error = connection.lastError();
193 QString errorMessage;
194 if (error.isValid()) {
195 errorMessage = error.message();
196 }
197 qCCritical(QTMIR_CLIPBOARD, "Failed to register object %s. %s", objectName, qPrintable(errorMessage));
198 }
199
200 if (serviceOk && objectOk) {
201 qCDebug(QTMIR_CLIPBOARD, "D-Bus registration successful.");
202 }
203}
204
205/************************************ Clipboard *****************************************/
206
207Clipboard::Clipboard(QObject *parent)
208 : QObject(parent)
209 , m_dbusClipboard(nullptr)
210{
211}
212
213QMimeData *Clipboard::mimeData(QClipboard::Mode mode)
214{
215 if (mode == QClipboard::Clipboard) {
216 return QPlatformClipboard::mimeData(mode);
217 } else {
218 return nullptr;
219 }
220}
221
222void Clipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
223{
224 if (mode != QClipboard::Clipboard)
225 return;
226
227 if (m_dbusClipboard) {
228 QByteArray serializedMimeData = serializeMimeData(data);
229 m_dbusClipboard->setContents(std::move(serializedMimeData));
230 }
231
232 QPlatformClipboard::setMimeData(data, mode);
233}
234
235void Clipboard::setupDBusService()
236{
237 Q_ASSERT(!m_dbusClipboard);
238
239 m_dbusClipboard = new DBusClipboard(this);
240
241 connect(m_dbusClipboard, &DBusClipboard::contentsChangedRemotely,
242 this, &Clipboard::setMimeDataWithDBusClibpboardContents);
243}
244
245void Clipboard::setMimeDataWithDBusClibpboardContents()
246{
247 Q_ASSERT(m_dbusClipboard);
248 QMimeData *newMimeData = deserializeMimeData(m_dbusClipboard->contents());
249 if (newMimeData) {
250 // Don't call Clipboard::setMimeData as it will also propagate the change
251 // to the D-Bus clipboard, which doesn't make sense here as we're doing
252 // the other way round (propagating the D-Bus clipboard change to the local
253 // clipboard).
254 QPlatformClipboard::setMimeData(newMimeData, QClipboard::Clipboard);
255 } else {
256 qCWarning(QTMIR_CLIPBOARD, "Failed to deserialize D-Bus clipboard contents (%d bytes)",
257 m_dbusClipboard->contents().size());
258 }
259}
260
261} // namespace qtmir
262
0263
=== added file 'src/platforms/mirserver/clipboard.h'
--- src/platforms/mirserver/clipboard.h 1970-01-01 00:00:00 +0000
+++ src/platforms/mirserver/clipboard.h 2014-09-23 11:37:20 +0000
@@ -0,0 +1,88 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Daniel d'Andrada <daniel.dandrada@canonical.com>
17 */
18
19#ifndef QTMIR_CLIPBOARD_H
20#define QTMIR_CLIPBOARD_H
21
22#include <qpa/qplatformclipboard.h>
23#include <QObject>
24
25namespace qtmir {
26
27class DBusClipboard : public QObject {
28 Q_OBJECT
29 Q_CLASSINFO("D-Bus Interface", "com.canonical.QtMir.Clipboard")
30public:
31 DBusClipboard(QObject *parent = nullptr);
32 virtual ~DBusClipboard() {}
33
34 void setContents(QByteArray contents);
35 const QByteArray &contents() const { return m_contents; }
36
37 static const int maxContentsSize = 4 * 1024 * 1024; // 4 Mb
38
39 // To make it testable
40 static bool skipDBusRegistration;
41
42Q_SIGNALS:
43 Q_SCRIPTABLE void ContentsChanged(const QByteArray &contents);
44 void contentsChangedRemotely();
45
46public Q_SLOTS:
47 Q_SCRIPTABLE QByteArray GetContents() const;
48 Q_SCRIPTABLE void SetContents(QByteArray contents);
49
50private:
51 void performDBusRegistration();
52 bool setContentsHelper(QByteArray newContents);
53
54 // Contains a serialized QMimeData
55 // Serialization and deserialization is done by the QPlatformClipboard
56 // implementation.
57 QByteArray m_contents;
58};
59
60class Clipboard : public QObject, public QPlatformClipboard
61{
62 Q_OBJECT
63public:
64 Clipboard(QObject *parent = nullptr);
65 virtual ~Clipboard() {}
66
67 QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard) override;
68 void setMimeData(QMimeData *data, QClipboard::Mode mode) override;
69
70 void setupDBusService();
71
72private Q_SLOTS:
73 void setMimeDataWithDBusClibpboardContents();
74
75private:
76
77 DBusClipboard *m_dbusClipboard;
78};
79
80// NB: Copied from qtubuntu. Must be kept in sync with the original version!
81// Best thing would be to share this code somehow, but not bothering with it right now
82// as the clipboard will move to content-hub at some point.
83QByteArray serializeMimeData(QMimeData *mimeData);
84QMimeData *deserializeMimeData(const QByteArray &serializedMimeData);
85
86} // namespace qtmir
87
88#endif // QTMIR_CLIPBOARD_H
089
=== removed file 'src/platforms/mirserver/connectioncreator.cpp'
--- src/platforms/mirserver/connectioncreator.cpp 2014-06-26 15:14:00 +0000
+++ src/platforms/mirserver/connectioncreator.cpp 1970-01-01 00:00:00 +0000
@@ -1,42 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "connectioncreator.h"
18#include <messageprocessor.h>
19
20ConnectionCreator::ConnectionCreator(
21 std::shared_ptr<unity::protobuf::UnityService> const& unityService,
22 std::shared_ptr<mir::frontend::ProtobufIpcFactory> const& ipc_factory,
23 std::shared_ptr<mir::frontend::SessionAuthorizer> const& session_authorizer,
24 std::shared_ptr<mir::frontend::MessageProcessorReport> const& report)
25 : ProtobufConnectionCreator(ipc_factory, session_authorizer, report)
26 , m_unityService(unityService)
27{
28}
29
30std::shared_ptr<mir::frontend::detail::MessageProcessor> ConnectionCreator::create_processor(
31 std::shared_ptr<mir::frontend::detail::ProtobufMessageSender> const& sender,
32 std::shared_ptr<mir::frontend::detail::DisplayServer> const& display_server,
33 std::shared_ptr<mir::frontend::MessageProcessorReport> const& report) const
34{
35 auto const wrapped = mir::frontend::ProtobufConnectionCreator::create_processor(
36 sender,
37 display_server,
38 report);
39
40 return std::make_shared<MessageProcessor>(m_unityService, sender, wrapped);
41}
42
430
=== removed file 'src/platforms/mirserver/connectioncreator.h'
--- src/platforms/mirserver/connectioncreator.h 2014-06-26 15:14:00 +0000
+++ src/platforms/mirserver/connectioncreator.h 1970-01-01 00:00:00 +0000
@@ -1,46 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef CONNECTIONCREATOR_H
18#define CONNECTIONCREATOR_H
19
20#include <mir/frontend/protobuf_connection_creator.h>
21
22namespace unity {
23 namespace protobuf {
24 class UnityService;
25 }
26}
27
28class ConnectionCreator : public mir::frontend::ProtobufConnectionCreator
29{
30public:
31 ConnectionCreator(
32 std::shared_ptr<unity::protobuf::UnityService> const& unityService,
33 std::shared_ptr<mir::frontend::ProtobufIpcFactory> const& ipc_factory,
34 std::shared_ptr<mir::frontend::SessionAuthorizer> const& session_authorizer,
35 std::shared_ptr<mir::frontend::MessageProcessorReport> const& report);
36
37 std::shared_ptr<mir::frontend::detail::MessageProcessor> create_processor(
38 std::shared_ptr<mir::frontend::detail::ProtobufMessageSender> const& sender,
39 std::shared_ptr<mir::frontend::detail::DisplayServer> const& display_server,
40 std::shared_ptr<mir::frontend::MessageProcessorReport> const& report) const override;
41private:
42 std::shared_ptr<unity::protobuf::UnityService> m_unityService;
43};
44
45#endif // CONNECTIONCREATOR_H
46
470
=== modified file 'src/platforms/mirserver/logging.h'
--- src/platforms/mirserver/logging.h 2014-09-07 19:42:14 +0000
+++ src/platforms/mirserver/logging.h 2014-09-23 11:37:20 +0000
@@ -23,5 +23,6 @@
23Q_DECLARE_LOGGING_CATEGORY(QTMIR_SURFACES)23Q_DECLARE_LOGGING_CATEGORY(QTMIR_SURFACES)
24Q_DECLARE_LOGGING_CATEGORY(QTMIR_MIR_MESSAGES)24Q_DECLARE_LOGGING_CATEGORY(QTMIR_MIR_MESSAGES)
25Q_DECLARE_LOGGING_CATEGORY(QTMIR_MIR_INPUT)25Q_DECLARE_LOGGING_CATEGORY(QTMIR_MIR_INPUT)
26Q_DECLARE_LOGGING_CATEGORY(QTMIR_CLIPBOARD)
2627
27#endif // UBUNTU_APPLICATION_PLUGIN_LOGGING_H28#endif // UBUNTU_APPLICATION_PLUGIN_LOGGING_H
2829
=== removed file 'src/platforms/mirserver/messageprocessor.cpp'
--- src/platforms/mirserver/messageprocessor.cpp 2014-06-26 15:14:00 +0000
+++ src/platforms/mirserver/messageprocessor.cpp 1970-01-01 00:00:00 +0000
@@ -1,49 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "messageprocessor.h"
18#include <mir/frontend/template_protobuf_message_processor.h>
19
20bool MessageProcessor::dispatch(mir::frontend::detail::Invocation const& invocation)
21{
22 if ("copy" == invocation.method_name()) {
23 mir::frontend::detail::invoke(
24 this,
25 m_unityService.get(),
26 &unity::protobuf::UnityService::copy,
27 invocation);
28 return true;
29 } else if ("paste" == invocation.method_name()) {
30 mir::frontend::detail::invoke(
31 this,
32 m_unityService.get(),
33 &unity::protobuf::UnityService::paste,
34 invocation);
35 return true;
36 } else {
37 return m_wrapped->dispatch(invocation);
38 }
39}
40
41void MessageProcessor::client_pid(int pid)
42{
43 m_wrapped->client_pid(pid);
44}
45
46void MessageProcessor::send_response(::google::protobuf::uint32 id, ::google::protobuf::Message* response)
47{
48 m_sender->send_response(id, response, {});
49}
500
=== removed file 'src/platforms/mirserver/messageprocessor.h'
--- src/platforms/mirserver/messageprocessor.h 2014-06-26 15:14:00 +0000
+++ src/platforms/mirserver/messageprocessor.h 1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <mir/frontend/message_processor.h>
18#include <mir/frontend/protobuf_message_sender.h>
19
20#include "unityrpc.h"
21
22#include <memory>
23
24class MessageProcessor : public mir::frontend::detail::MessageProcessor
25{
26public:
27 MessageProcessor(
28 std::shared_ptr<unity::protobuf::UnityService> const& unityService,
29 std::shared_ptr<mir::frontend::detail::ProtobufMessageSender> const& sender,
30 std::shared_ptr<mir::frontend::detail::MessageProcessor> const& wrapped) :
31 m_sender(sender),
32 m_wrapped(wrapped),
33 m_unityService(unityService) {}
34
35 bool dispatch(mir::frontend::detail::Invocation const& invocation) override;
36 void client_pid(int pid) override;
37
38 void send_response(::google::protobuf::uint32 id, ::google::protobuf::Message* response);
39
40private:
41 std::shared_ptr<mir::frontend::detail::ProtobufMessageSender> const m_sender;
42 std::shared_ptr<mir::frontend::detail::MessageProcessor> const m_wrapped;
43 std::shared_ptr<unity::protobuf::UnityService> const m_unityService;
44};
450
=== modified file 'src/platforms/mirserver/mirserver.pro'
--- src/platforms/mirserver/mirserver.pro 2014-09-07 19:42:33 +0000
+++ src/platforms/mirserver/mirserver.pro 2014-09-23 11:37:20 +0000
@@ -24,8 +24,8 @@
24LIBS += -lboost_system24LIBS += -lboost_system
2525
26SOURCES += \26SOURCES += \
27 connectioncreator.cpp \
28 ../../common/debughelpers.cpp \27 ../../common/debughelpers.cpp \
28 clipboard.cpp \
29 focussetter.cpp \29 focussetter.cpp \
30 qteventfeeder.cpp \30 qteventfeeder.cpp \
31 plugin.cpp \31 plugin.cpp \
@@ -34,7 +34,6 @@
34 sessionlistener.cpp \34 sessionlistener.cpp \
35 surfaceconfigurator.cpp \35 surfaceconfigurator.cpp \
36 promptsessionlistener.cpp \36 promptsessionlistener.cpp \
37 messageprocessor.cpp \
38 mirplacementstrategy.cpp \37 mirplacementstrategy.cpp \
39 mirserverconfiguration.cpp \38 mirserverconfiguration.cpp \
40 mirserverstatuslistener.cpp \39 mirserverstatuslistener.cpp \
@@ -47,12 +46,11 @@
47 qtcompositor.cpp \46 qtcompositor.cpp \
48 services.cpp \47 services.cpp \
49 ubuntutheme.cpp \48 ubuntutheme.cpp \
50 unityprotobufservice.cpp \49
51 unityrpc.cpp
5250
53HEADERS += \51HEADERS += \
54 connectioncreator.h \
55 ../../common/debughelpers.h \52 ../../common/debughelpers.h \
53 clipboard.h \
56 focussetter.h \54 focussetter.h \
57 qteventfeeder.h \55 qteventfeeder.h \
58 plugin.h \56 plugin.h \
@@ -62,7 +60,6 @@
62 promptsessionlistener.h \60 promptsessionlistener.h \
63 surfaceconfigurator.h \61 surfaceconfigurator.h \
64 logging.h \62 logging.h \
65 messageprocessor.h \
66 mirglconfig.h \63 mirglconfig.h \
67 mirplacementstrategy.h \64 mirplacementstrategy.h \
68 mirserverconfiguration.h \65 mirserverconfiguration.h \
@@ -76,8 +73,7 @@
76 qtcompositor.h \73 qtcompositor.h \
77 services.h \74 services.h \
78 ubuntutheme.h \75 ubuntutheme.h \
79 unityprotobufservice.h \76
80 unityrpc.h
8177
82LTTNG_TP_FILES += tracepoints.tp78LTTNG_TP_FILES += tracepoints.tp
8379
8480
=== modified file 'src/platforms/mirserver/mirserverconfiguration.cpp'
--- src/platforms/mirserver/mirserverconfiguration.cpp 2014-08-27 16:51:24 +0000
+++ src/platforms/mirserver/mirserverconfiguration.cpp 2014-09-23 11:37:20 +0000
@@ -17,7 +17,6 @@
17#include "mirserverconfiguration.h"17#include "mirserverconfiguration.h"
1818
19// local19// local
20#include "connectioncreator.h"
21#include "focussetter.h"20#include "focussetter.h"
22#include "mirglconfig.h"21#include "mirglconfig.h"
23#include "mirplacementstrategy.h"22#include "mirplacementstrategy.h"
@@ -29,14 +28,10 @@
29#include "qtcompositor.h"28#include "qtcompositor.h"
30#include "qteventfeeder.h"29#include "qteventfeeder.h"
31#include "logging.h"30#include "logging.h"
32#include "unityprotobufservice.h"
3331
34// mir32// mir
35#include <mir/options/default_configuration.h>33#include <mir/options/default_configuration.h>
3634
37// Qt
38#include <QDebug>
39
40// egl35// egl
41#include <EGL/egl.h>36#include <EGL/egl.h>
4237
@@ -56,7 +51,6 @@
56MirServerConfiguration::MirServerConfiguration(int argc, char const* argv[], QObject* parent)51MirServerConfiguration::MirServerConfiguration(int argc, char const* argv[], QObject* parent)
57 : QObject(parent)52 : QObject(parent)
58 , DefaultServerConfiguration(std::make_shared<mo::DefaultConfiguration>(argc, argv, &ignore_unparsed_arguments))53 , DefaultServerConfiguration(std::make_shared<mo::DefaultConfiguration>(argc, argv, &ignore_unparsed_arguments))
59 , m_unityService(std::make_shared<UnityProtobufService>())
60{54{
61 qCDebug(QTMIR_MIR_MESSAGES) << "MirServerConfiguration created";55 qCDebug(QTMIR_MIR_MESSAGES) << "MirServerConfiguration created";
62}56}
@@ -155,19 +149,6 @@
155 });149 });
156}150}
157151
158std::shared_ptr<mir::frontend::ConnectionCreator>
159MirServerConfiguration::the_connection_creator()
160{
161 return connection_creator([this]
162 {
163 return std::make_shared<ConnectionCreator>(
164 m_unityService,
165 new_ipc_factory(the_session_authorizer()),
166 the_session_authorizer(),
167 the_message_processor_report());
168 });
169}
170
171std::shared_ptr<mir::shell::FocusSetter>152std::shared_ptr<mir::shell::FocusSetter>
172MirServerConfiguration::the_shell_focus_setter()153MirServerConfiguration::the_shell_focus_setter()
173{154{
174155
=== modified file 'src/platforms/mirserver/mirserverconfiguration.h'
--- src/platforms/mirserver/mirserverconfiguration.h 2014-07-11 17:15:47 +0000
+++ src/platforms/mirserver/mirserverconfiguration.h 2014-09-23 11:37:20 +0000
@@ -20,12 +20,6 @@
20#include <QObject>20#include <QObject>
21#include <mir/default_server_configuration.h>21#include <mir/default_server_configuration.h>
2222
23namespace unity {
24 namespace protobuf {
25 class UnityService;
26 }
27}
28
29class QtEventFeeder;23class QtEventFeeder;
30class SessionListener;24class SessionListener;
31class SessionAuthorizer;25class SessionAuthorizer;
@@ -55,7 +49,6 @@
55 std::shared_ptr<mir::input::InputDispatcher> the_input_dispatcher() override;49 std::shared_ptr<mir::input::InputDispatcher> the_input_dispatcher() override;
56 std::shared_ptr<mir::graphics::GLConfig> the_gl_config() override;50 std::shared_ptr<mir::graphics::GLConfig> the_gl_config() override;
57 std::shared_ptr<mir::ServerStatusListener> the_server_status_listener() override;51 std::shared_ptr<mir::ServerStatusListener> the_server_status_listener() override;
58 std::shared_ptr<mir::frontend::ConnectionCreator> the_connection_creator() override;
59 std::shared_ptr<mir::shell::FocusSetter> the_shell_focus_setter() override;52 std::shared_ptr<mir::shell::FocusSetter> the_shell_focus_setter() override;
6053
61 /* qt specific */54 /* qt specific */
@@ -66,7 +59,6 @@
66 SurfaceConfigurator *surfaceConfigurator();59 SurfaceConfigurator *surfaceConfigurator();
6760
68private:61private:
69 std::shared_ptr<unity::protobuf::UnityService> m_unityService;
70 std::shared_ptr<QtEventFeeder> m_qtEventFeeder;62 std::shared_ptr<QtEventFeeder> m_qtEventFeeder;
71};63};
7264
7365
=== modified file 'src/platforms/mirserver/mirserverintegration.cpp'
--- src/platforms/mirserver/mirserverintegration.cpp 2014-07-08 18:23:45 +0000
+++ src/platforms/mirserver/mirserverintegration.cpp 2014-09-23 11:37:20 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2013 Canonical, Ltd.2 * Copyright (C) 2013-2014 Canonical, Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it under4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by5 * the terms of the GNU Lesser General Public License version 3, as published by
@@ -13,7 +13,8 @@
13 * You should have received a copy of the GNU Lesser General Public License13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Author: Gerry Boland <gerry.boland@canonical.com>16 * Authors: Gerry Boland <gerry.boland@canonical.com>
17 * Daniel d'Andrada <daniel.dandrada@canonical.com>
17 */18 */
1819
19#include "mirserverintegration.h"20#include "mirserverintegration.h"
@@ -47,6 +48,7 @@
47#include <csignal>48#include <csignal>
4849
49// local50// local
51#include "clipboard.h"
50#include "display.h"52#include "display.h"
51#include "displaywindow.h"53#include "displaywindow.h"
52#include "miropenglcontext.h"54#include "miropenglcontext.h"
@@ -56,6 +58,7 @@
56#include "ubuntutheme.h"58#include "ubuntutheme.h"
5759
58namespace mg = mir::graphics;60namespace mg = mir::graphics;
61using qtmir::Clipboard;
5962
60MirServerIntegration::MirServerIntegration()63MirServerIntegration::MirServerIntegration()
61 : m_accessibility(new QPlatformAccessibility())64 : m_accessibility(new QPlatformAccessibility())
@@ -67,6 +70,7 @@
67 , m_display(nullptr)70 , m_display(nullptr)
68 , m_mirServer(nullptr)71 , m_mirServer(nullptr)
69 , m_nativeInterface(nullptr)72 , m_nativeInterface(nullptr)
73 , m_clipboard(new Clipboard)
70{74{
71 // Start Mir server only once Qt has initialized its event dispatcher, see initialize()75 // Start Mir server only once Qt has initialized its event dispatcher, see initialize()
7276
@@ -174,6 +178,8 @@
174 qDebug() << "Signal caught by Mir, stopping Mir server..";178 qDebug() << "Signal caught by Mir, stopping Mir server..";
175 QCoreApplication::quit();179 QCoreApplication::quit();
176 });180 });
181
182 m_clipboard->setupDBusService();
177}183}
178184
179QPlatformAccessibility *MirServerIntegration::accessibility() const185QPlatformAccessibility *MirServerIntegration::accessibility() const
@@ -206,3 +212,8 @@
206{212{
207 return m_nativeInterface;213 return m_nativeInterface;
208}214}
215
216QPlatformClipboard *MirServerIntegration::clipboard() const
217{
218 return m_clipboard.data();
219}
209220
=== modified file 'src/platforms/mirserver/mirserverintegration.h'
--- src/platforms/mirserver/mirserverintegration.h 2014-06-03 20:53:46 +0000
+++ src/platforms/mirserver/mirserverintegration.h 2014-09-23 11:37:20 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2013 Canonical, Ltd.2 * Copyright (C) 2013-2014 Canonical, Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it under4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by5 * the terms of the GNU Lesser General Public License version 3, as published by
@@ -13,7 +13,8 @@
13 * You should have received a copy of the GNU Lesser General Public License13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Author: Gerry Boland <gerry.boland@canonical.com>16 * Authors: Gerry Boland <gerry.boland@canonical.com>
17 * Daniel d'Andrada <daniel.dandrada@canonical.com>
17 */18 */
1819
19#ifndef MIRSERVERINTEGRATION_H20#ifndef MIRSERVERINTEGRATION_H
@@ -29,6 +30,10 @@
29class NativeInterface;30class NativeInterface;
30class QMirServer;31class QMirServer;
3132
33namespace qtmir {
34 class Clipboard;
35}
36
32class MirServerIntegration : public QPlatformIntegration37class MirServerIntegration : public QPlatformIntegration
33{38{
34public:39public:
@@ -49,6 +54,8 @@
49 void initialize() override;54 void initialize() override;
50#endif55#endif
5156
57 QPlatformClipboard *clipboard() const override;
58
52 QPlatformInputContext* inputContext() const override { return m_inputContext; }59 QPlatformInputContext* inputContext() const override { return m_inputContext; }
5360
54 QPlatformFontDatabase *fontDatabase() const override;61 QPlatformFontDatabase *fontDatabase() const override;
@@ -74,6 +81,7 @@
74 QMirServer *m_mirServer;81 QMirServer *m_mirServer;
75 NativeInterface *m_nativeInterface;82 NativeInterface *m_nativeInterface;
76 QPlatformInputContext* m_inputContext;83 QPlatformInputContext* m_inputContext;
84 QScopedPointer<qtmir::Clipboard> m_clipboard;
77};85};
7886
79#endif // MIRSERVERINTEGRATION_H87#endif // MIRSERVERINTEGRATION_H
8088
=== removed file 'src/platforms/mirserver/unityprotobufservice.cpp'
--- src/platforms/mirserver/unityprotobufservice.cpp 2014-06-16 18:29:36 +0000
+++ src/platforms/mirserver/unityprotobufservice.cpp 1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "unityprotobufservice.h"
18
19void UnityProtobufService::copy(::google::protobuf::RpcController* /*controller*/,
20 const ::unity::protobuf::Clip* newClip,
21 ::unity::protobuf::Void* /*response*/,
22 ::google::protobuf::Closure* done)
23{
24 m_clip = newClip->content();
25 done->Run();
26}
27
28void UnityProtobufService::paste(::google::protobuf::RpcController* /*controller*/,
29 const ::unity::protobuf::Void* /*request*/,
30 ::unity::protobuf::Clip* clipReturned,
31 ::google::protobuf::Closure* done)
32{
33 clipReturned->set_content(m_clip);
34 done->Run();
35}
360
=== removed file 'src/platforms/mirserver/unityprotobufservice.h'
--- src/platforms/mirserver/unityprotobufservice.h 2014-06-16 18:29:36 +0000
+++ src/platforms/mirserver/unityprotobufservice.h 1970-01-01 00:00:00 +0000
@@ -1,40 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UNITY_PROTOBUF_SERVICE_H
18#define UNITY_PROTOBUF_SERVICE_H
19
20#include "unityrpc.h"
21#include <string>
22
23class UnityProtobufService : public unity::protobuf::UnityService
24{
25public:
26 void copy(::google::protobuf::RpcController* controller,
27 const ::unity::protobuf::Clip* request,
28 ::unity::protobuf::Void* response,
29 ::google::protobuf::Closure* done) override;
30
31 void paste(::google::protobuf::RpcController* controller,
32 const ::unity::protobuf::Void* request,
33 ::unity::protobuf::Clip* response,
34 ::google::protobuf::Closure* done) override;
35
36private:
37 std::string m_clip;
38};
39
40#endif // UNITY_PROTOBUF_SERVICE_H
410
=== removed file 'src/platforms/mirserver/unityrpc.cpp'
--- src/platforms/mirserver/unityrpc.cpp 2014-06-16 18:29:36 +0000
+++ src/platforms/mirserver/unityrpc.cpp 1970-01-01 00:00:00 +0000
@@ -1,742 +0,0 @@
1// Generated by the protocol buffer compiler. DO NOT EDIT!
2// source: unityrpc.proto
3
4#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
5#include "unityrpc.h"
6
7#include <algorithm>
8
9#include <google/protobuf/stubs/common.h>
10#include <google/protobuf/stubs/once.h>
11#include <google/protobuf/io/coded_stream.h>
12#include <google/protobuf/wire_format_lite_inl.h>
13#include <google/protobuf/descriptor.h>
14#include <google/protobuf/generated_message_reflection.h>
15#include <google/protobuf/reflection_ops.h>
16#include <google/protobuf/wire_format.h>
17// @@protoc_insertion_point(includes)
18
19namespace unity {
20namespace protobuf {
21
22namespace {
23
24const ::google::protobuf::Descriptor* Clip_descriptor_ = NULL;
25const ::google::protobuf::internal::GeneratedMessageReflection*
26 Clip_reflection_ = NULL;
27const ::google::protobuf::Descriptor* Void_descriptor_ = NULL;
28const ::google::protobuf::internal::GeneratedMessageReflection*
29 Void_reflection_ = NULL;
30const ::google::protobuf::ServiceDescriptor* UnityService_descriptor_ = NULL;
31
32} // namespace
33
34
35void protobuf_AssignDesc_unityrpc_2eproto() {
36 protobuf_AddDesc_unityrpc_2eproto();
37 const ::google::protobuf::FileDescriptor* file =
38 ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
39 "unityrpc.proto");
40 GOOGLE_CHECK(file != NULL);
41 Clip_descriptor_ = file->message_type(0);
42 static const int Clip_offsets_[2] = {
43 GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Clip, content_),
44 GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Clip, error_),
45 };
46 Clip_reflection_ =
47 new ::google::protobuf::internal::GeneratedMessageReflection(
48 Clip_descriptor_,
49 Clip::default_instance_,
50 Clip_offsets_,
51 GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Clip, _has_bits_[0]),
52 GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Clip, _unknown_fields_),
53 -1,
54 ::google::protobuf::DescriptorPool::generated_pool(),
55 ::google::protobuf::MessageFactory::generated_factory(),
56 sizeof(Clip));
57 Void_descriptor_ = file->message_type(1);
58 static const int Void_offsets_[1] = {
59 GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Void, error_),
60 };
61 Void_reflection_ =
62 new ::google::protobuf::internal::GeneratedMessageReflection(
63 Void_descriptor_,
64 Void::default_instance_,
65 Void_offsets_,
66 GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Void, _has_bits_[0]),
67 GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Void, _unknown_fields_),
68 -1,
69 ::google::protobuf::DescriptorPool::generated_pool(),
70 ::google::protobuf::MessageFactory::generated_factory(),
71 sizeof(Void));
72 UnityService_descriptor_ = file->service(0);
73}
74
75namespace {
76
77GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
78inline void protobuf_AssignDescriptorsOnce() {
79 ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
80 &protobuf_AssignDesc_unityrpc_2eproto);
81}
82
83void protobuf_RegisterTypes(const ::std::string&) {
84 protobuf_AssignDescriptorsOnce();
85 ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
86 Clip_descriptor_, &Clip::default_instance());
87 ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
88 Void_descriptor_, &Void::default_instance());
89}
90
91} // namespace
92
93void protobuf_ShutdownFile_unityrpc_2eproto() {
94 delete Clip::default_instance_;
95 delete Clip_reflection_;
96 delete Void::default_instance_;
97 delete Void_reflection_;
98}
99
100void protobuf_AddDesc_unityrpc_2eproto() {
101 static bool already_here = false;
102 if (already_here) return;
103 already_here = true;
104 GOOGLE_PROTOBUF_VERIFY_VERSION;
105
106 ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
107 "\n\016unityrpc.proto\022\016unity.protobuf\"&\n\004Clip"
108 "\022\017\n\007content\030\001 \002(\014\022\r\n\005error\030\177 \001(\t\"\025\n\004Void"
109 "\022\r\n\005error\030\177 \001(\t2w\n\014UnityService\0222\n\004copy\022"
110 "\024.unity.protobuf.Clip\032\024.unity.protobuf.V"
111 "oid\0223\n\005paste\022\024.unity.protobuf.Void\032\024.uni"
112 "ty.protobuf.ClipB\003\200\001\001", 221);
113 ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
114 "unityrpc.proto", &protobuf_RegisterTypes);
115 Clip::default_instance_ = new Clip();
116 Void::default_instance_ = new Void();
117 Clip::default_instance_->InitAsDefaultInstance();
118 Void::default_instance_->InitAsDefaultInstance();
119 ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_unityrpc_2eproto);
120}
121
122// Force AddDescriptors() to be called at static initialization time.
123struct StaticDescriptorInitializer_unityrpc_2eproto {
124 StaticDescriptorInitializer_unityrpc_2eproto() {
125 protobuf_AddDesc_unityrpc_2eproto();
126 }
127} static_descriptor_initializer_unityrpc_2eproto_;
128
129// ===================================================================
130
131#ifndef _MSC_VER
132const int Clip::kContentFieldNumber;
133const int Clip::kErrorFieldNumber;
134#endif // !_MSC_VER
135
136Clip::Clip()
137 : ::google::protobuf::Message() {
138 SharedCtor();
139}
140
141void Clip::InitAsDefaultInstance() {
142}
143
144Clip::Clip(const Clip& from)
145 : ::google::protobuf::Message() {
146 SharedCtor();
147 MergeFrom(from);
148}
149
150void Clip::SharedCtor() {
151 _cached_size_ = 0;
152 content_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
153 error_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
154 ::memset(_has_bits_, 0, sizeof(_has_bits_));
155}
156
157Clip::~Clip() {
158 SharedDtor();
159}
160
161void Clip::SharedDtor() {
162 if (content_ != &::google::protobuf::internal::kEmptyString) {
163 delete content_;
164 }
165 if (error_ != &::google::protobuf::internal::kEmptyString) {
166 delete error_;
167 }
168 if (this != default_instance_) {
169 }
170}
171
172void Clip::SetCachedSize(int size) const {
173 GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
174 _cached_size_ = size;
175 GOOGLE_SAFE_CONCURRENT_WRITES_END();
176}
177const ::google::protobuf::Descriptor* Clip::descriptor() {
178 protobuf_AssignDescriptorsOnce();
179 return Clip_descriptor_;
180}
181
182const Clip& Clip::default_instance() {
183 if (default_instance_ == NULL) protobuf_AddDesc_unityrpc_2eproto();
184 return *default_instance_;
185}
186
187Clip* Clip::default_instance_ = NULL;
188
189Clip* Clip::New() const {
190 return new Clip;
191}
192
193void Clip::Clear() {
194 if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
195 if (has_content()) {
196 if (content_ != &::google::protobuf::internal::kEmptyString) {
197 content_->clear();
198 }
199 }
200 if (has_error()) {
201 if (error_ != &::google::protobuf::internal::kEmptyString) {
202 error_->clear();
203 }
204 }
205 }
206 ::memset(_has_bits_, 0, sizeof(_has_bits_));
207 mutable_unknown_fields()->Clear();
208}
209
210bool Clip::MergePartialFromCodedStream(
211 ::google::protobuf::io::CodedInputStream* input) {
212#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
213 ::google::protobuf::uint32 tag;
214 while ((tag = input->ReadTag()) != 0) {
215 switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
216 // required bytes content = 1;
217 case 1: {
218 if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
219 ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
220 DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
221 input, this->mutable_content()));
222 } else {
223 goto handle_uninterpreted;
224 }
225 if (input->ExpectTag(1018)) goto parse_error;
226 break;
227 }
228
229 // optional string error = 127;
230 case 127: {
231 if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
232 ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
233 parse_error:
234 DO_(::google::protobuf::internal::WireFormatLite::ReadString(
235 input, this->mutable_error()));
236 ::google::protobuf::internal::WireFormat::VerifyUTF8String(
237 this->error().data(), this->error().length(),
238 ::google::protobuf::internal::WireFormat::PARSE);
239 } else {
240 goto handle_uninterpreted;
241 }
242 if (input->ExpectAtEnd()) return true;
243 break;
244 }
245
246 default: {
247 handle_uninterpreted:
248 if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
249 ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
250 return true;
251 }
252 DO_(::google::protobuf::internal::WireFormat::SkipField(
253 input, tag, mutable_unknown_fields()));
254 break;
255 }
256 }
257 }
258 return true;
259#undef DO_
260}
261
262void Clip::SerializeWithCachedSizes(
263 ::google::protobuf::io::CodedOutputStream* output) const {
264 // required bytes content = 1;
265 if (has_content()) {
266 ::google::protobuf::internal::WireFormatLite::WriteBytes(
267 1, this->content(), output);
268 }
269
270 // optional string error = 127;
271 if (has_error()) {
272 ::google::protobuf::internal::WireFormat::VerifyUTF8String(
273 this->error().data(), this->error().length(),
274 ::google::protobuf::internal::WireFormat::SERIALIZE);
275 ::google::protobuf::internal::WireFormatLite::WriteString(
276 127, this->error(), output);
277 }
278
279 if (!unknown_fields().empty()) {
280 ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
281 unknown_fields(), output);
282 }
283}
284
285::google::protobuf::uint8* Clip::SerializeWithCachedSizesToArray(
286 ::google::protobuf::uint8* target) const {
287 // required bytes content = 1;
288 if (has_content()) {
289 target =
290 ::google::protobuf::internal::WireFormatLite::WriteBytesToArray(
291 1, this->content(), target);
292 }
293
294 // optional string error = 127;
295 if (has_error()) {
296 ::google::protobuf::internal::WireFormat::VerifyUTF8String(
297 this->error().data(), this->error().length(),
298 ::google::protobuf::internal::WireFormat::SERIALIZE);
299 target =
300 ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
301 127, this->error(), target);
302 }
303
304 if (!unknown_fields().empty()) {
305 target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
306 unknown_fields(), target);
307 }
308 return target;
309}
310
311int Clip::ByteSize() const {
312 int total_size = 0;
313
314 if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
315 // required bytes content = 1;
316 if (has_content()) {
317 total_size += 1 +
318 ::google::protobuf::internal::WireFormatLite::BytesSize(
319 this->content());
320 }
321
322 // optional string error = 127;
323 if (has_error()) {
324 total_size += 2 +
325 ::google::protobuf::internal::WireFormatLite::StringSize(
326 this->error());
327 }
328
329 }
330 if (!unknown_fields().empty()) {
331 total_size +=
332 ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
333 unknown_fields());
334 }
335 GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
336 _cached_size_ = total_size;
337 GOOGLE_SAFE_CONCURRENT_WRITES_END();
338 return total_size;
339}
340
341void Clip::MergeFrom(const ::google::protobuf::Message& from) {
342 GOOGLE_CHECK_NE(&from, this);
343 const Clip* source =
344 ::google::protobuf::internal::dynamic_cast_if_available<const Clip*>(
345 &from);
346 if (source == NULL) {
347 ::google::protobuf::internal::ReflectionOps::Merge(from, this);
348 } else {
349 MergeFrom(*source);
350 }
351}
352
353void Clip::MergeFrom(const Clip& from) {
354 GOOGLE_CHECK_NE(&from, this);
355 if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
356 if (from.has_content()) {
357 set_content(from.content());
358 }
359 if (from.has_error()) {
360 set_error(from.error());
361 }
362 }
363 mutable_unknown_fields()->MergeFrom(from.unknown_fields());
364}
365
366void Clip::CopyFrom(const ::google::protobuf::Message& from) {
367 if (&from == this) return;
368 Clear();
369 MergeFrom(from);
370}
371
372void Clip::CopyFrom(const Clip& from) {
373 if (&from == this) return;
374 Clear();
375 MergeFrom(from);
376}
377
378bool Clip::IsInitialized() const {
379 if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
380
381 return true;
382}
383
384void Clip::Swap(Clip* other) {
385 if (other != this) {
386 std::swap(content_, other->content_);
387 std::swap(error_, other->error_);
388 std::swap(_has_bits_[0], other->_has_bits_[0]);
389 _unknown_fields_.Swap(&other->_unknown_fields_);
390 std::swap(_cached_size_, other->_cached_size_);
391 }
392}
393
394::google::protobuf::Metadata Clip::GetMetadata() const {
395 protobuf_AssignDescriptorsOnce();
396 ::google::protobuf::Metadata metadata;
397 metadata.descriptor = Clip_descriptor_;
398 metadata.reflection = Clip_reflection_;
399 return metadata;
400}
401
402
403// ===================================================================
404
405#ifndef _MSC_VER
406const int Void::kErrorFieldNumber;
407#endif // !_MSC_VER
408
409Void::Void()
410 : ::google::protobuf::Message() {
411 SharedCtor();
412}
413
414void Void::InitAsDefaultInstance() {
415}
416
417Void::Void(const Void& from)
418 : ::google::protobuf::Message() {
419 SharedCtor();
420 MergeFrom(from);
421}
422
423void Void::SharedCtor() {
424 _cached_size_ = 0;
425 error_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
426 ::memset(_has_bits_, 0, sizeof(_has_bits_));
427}
428
429Void::~Void() {
430 SharedDtor();
431}
432
433void Void::SharedDtor() {
434 if (error_ != &::google::protobuf::internal::kEmptyString) {
435 delete error_;
436 }
437 if (this != default_instance_) {
438 }
439}
440
441void Void::SetCachedSize(int size) const {
442 GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
443 _cached_size_ = size;
444 GOOGLE_SAFE_CONCURRENT_WRITES_END();
445}
446const ::google::protobuf::Descriptor* Void::descriptor() {
447 protobuf_AssignDescriptorsOnce();
448 return Void_descriptor_;
449}
450
451const Void& Void::default_instance() {
452 if (default_instance_ == NULL) protobuf_AddDesc_unityrpc_2eproto();
453 return *default_instance_;
454}
455
456Void* Void::default_instance_ = NULL;
457
458Void* Void::New() const {
459 return new Void;
460}
461
462void Void::Clear() {
463 if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
464 if (has_error()) {
465 if (error_ != &::google::protobuf::internal::kEmptyString) {
466 error_->clear();
467 }
468 }
469 }
470 ::memset(_has_bits_, 0, sizeof(_has_bits_));
471 mutable_unknown_fields()->Clear();
472}
473
474bool Void::MergePartialFromCodedStream(
475 ::google::protobuf::io::CodedInputStream* input) {
476#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
477 ::google::protobuf::uint32 tag;
478 while ((tag = input->ReadTag()) != 0) {
479 switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
480 // optional string error = 127;
481 case 127: {
482 if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
483 ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
484 DO_(::google::protobuf::internal::WireFormatLite::ReadString(
485 input, this->mutable_error()));
486 ::google::protobuf::internal::WireFormat::VerifyUTF8String(
487 this->error().data(), this->error().length(),
488 ::google::protobuf::internal::WireFormat::PARSE);
489 } else {
490 goto handle_uninterpreted;
491 }
492 if (input->ExpectAtEnd()) return true;
493 break;
494 }
495
496 default: {
497 handle_uninterpreted:
498 if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
499 ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
500 return true;
501 }
502 DO_(::google::protobuf::internal::WireFormat::SkipField(
503 input, tag, mutable_unknown_fields()));
504 break;
505 }
506 }
507 }
508 return true;
509#undef DO_
510}
511
512void Void::SerializeWithCachedSizes(
513 ::google::protobuf::io::CodedOutputStream* output) const {
514 // optional string error = 127;
515 if (has_error()) {
516 ::google::protobuf::internal::WireFormat::VerifyUTF8String(
517 this->error().data(), this->error().length(),
518 ::google::protobuf::internal::WireFormat::SERIALIZE);
519 ::google::protobuf::internal::WireFormatLite::WriteString(
520 127, this->error(), output);
521 }
522
523 if (!unknown_fields().empty()) {
524 ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
525 unknown_fields(), output);
526 }
527}
528
529::google::protobuf::uint8* Void::SerializeWithCachedSizesToArray(
530 ::google::protobuf::uint8* target) const {
531 // optional string error = 127;
532 if (has_error()) {
533 ::google::protobuf::internal::WireFormat::VerifyUTF8String(
534 this->error().data(), this->error().length(),
535 ::google::protobuf::internal::WireFormat::SERIALIZE);
536 target =
537 ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
538 127, this->error(), target);
539 }
540
541 if (!unknown_fields().empty()) {
542 target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
543 unknown_fields(), target);
544 }
545 return target;
546}
547
548int Void::ByteSize() const {
549 int total_size = 0;
550
551 if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
552 // optional string error = 127;
553 if (has_error()) {
554 total_size += 2 +
555 ::google::protobuf::internal::WireFormatLite::StringSize(
556 this->error());
557 }
558
559 }
560 if (!unknown_fields().empty()) {
561 total_size +=
562 ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
563 unknown_fields());
564 }
565 GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
566 _cached_size_ = total_size;
567 GOOGLE_SAFE_CONCURRENT_WRITES_END();
568 return total_size;
569}
570
571void Void::MergeFrom(const ::google::protobuf::Message& from) {
572 GOOGLE_CHECK_NE(&from, this);
573 const Void* source =
574 ::google::protobuf::internal::dynamic_cast_if_available<const Void*>(
575 &from);
576 if (source == NULL) {
577 ::google::protobuf::internal::ReflectionOps::Merge(from, this);
578 } else {
579 MergeFrom(*source);
580 }
581}
582
583void Void::MergeFrom(const Void& from) {
584 GOOGLE_CHECK_NE(&from, this);
585 if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
586 if (from.has_error()) {
587 set_error(from.error());
588 }
589 }
590 mutable_unknown_fields()->MergeFrom(from.unknown_fields());
591}
592
593void Void::CopyFrom(const ::google::protobuf::Message& from) {
594 if (&from == this) return;
595 Clear();
596 MergeFrom(from);
597}
598
599void Void::CopyFrom(const Void& from) {
600 if (&from == this) return;
601 Clear();
602 MergeFrom(from);
603}
604
605bool Void::IsInitialized() const {
606
607 return true;
608}
609
610void Void::Swap(Void* other) {
611 if (other != this) {
612 std::swap(error_, other->error_);
613 std::swap(_has_bits_[0], other->_has_bits_[0]);
614 _unknown_fields_.Swap(&other->_unknown_fields_);
615 std::swap(_cached_size_, other->_cached_size_);
616 }
617}
618
619::google::protobuf::Metadata Void::GetMetadata() const {
620 protobuf_AssignDescriptorsOnce();
621 ::google::protobuf::Metadata metadata;
622 metadata.descriptor = Void_descriptor_;
623 metadata.reflection = Void_reflection_;
624 return metadata;
625}
626
627
628// ===================================================================
629
630UnityService::~UnityService() {}
631
632const ::google::protobuf::ServiceDescriptor* UnityService::descriptor() {
633 protobuf_AssignDescriptorsOnce();
634 return UnityService_descriptor_;
635}
636
637const ::google::protobuf::ServiceDescriptor* UnityService::GetDescriptor() {
638 protobuf_AssignDescriptorsOnce();
639 return UnityService_descriptor_;
640}
641
642void UnityService::copy(::google::protobuf::RpcController* controller,
643 const ::unity::protobuf::Clip*,
644 ::unity::protobuf::Void*,
645 ::google::protobuf::Closure* done) {
646 controller->SetFailed("Method copy() not implemented.");
647 done->Run();
648}
649
650void UnityService::paste(::google::protobuf::RpcController* controller,
651 const ::unity::protobuf::Void*,
652 ::unity::protobuf::Clip*,
653 ::google::protobuf::Closure* done) {
654 controller->SetFailed("Method paste() not implemented.");
655 done->Run();
656}
657
658void UnityService::CallMethod(const ::google::protobuf::MethodDescriptor* method,
659 ::google::protobuf::RpcController* controller,
660 const ::google::protobuf::Message* request,
661 ::google::protobuf::Message* response,
662 ::google::protobuf::Closure* done) {
663 GOOGLE_DCHECK_EQ(method->service(), UnityService_descriptor_);
664 switch(method->index()) {
665 case 0:
666 copy(controller,
667 ::google::protobuf::down_cast<const ::unity::protobuf::Clip*>(request),
668 ::google::protobuf::down_cast< ::unity::protobuf::Void*>(response),
669 done);
670 break;
671 case 1:
672 paste(controller,
673 ::google::protobuf::down_cast<const ::unity::protobuf::Void*>(request),
674 ::google::protobuf::down_cast< ::unity::protobuf::Clip*>(response),
675 done);
676 break;
677 default:
678 GOOGLE_LOG(FATAL) << "Bad method index; this should never happen.";
679 break;
680 }
681}
682
683const ::google::protobuf::Message& UnityService::GetRequestPrototype(
684 const ::google::protobuf::MethodDescriptor* method) const {
685 GOOGLE_DCHECK_EQ(method->service(), descriptor());
686 switch(method->index()) {
687 case 0:
688 return ::unity::protobuf::Clip::default_instance();
689 case 1:
690 return ::unity::protobuf::Void::default_instance();
691 default:
692 GOOGLE_LOG(FATAL) << "Bad method index; this should never happen.";
693 return *reinterpret_cast< ::google::protobuf::Message*>(NULL);
694 }
695}
696
697const ::google::protobuf::Message& UnityService::GetResponsePrototype(
698 const ::google::protobuf::MethodDescriptor* method) const {
699 GOOGLE_DCHECK_EQ(method->service(), descriptor());
700 switch(method->index()) {
701 case 0:
702 return ::unity::protobuf::Void::default_instance();
703 case 1:
704 return ::unity::protobuf::Clip::default_instance();
705 default:
706 GOOGLE_LOG(FATAL) << "Bad method index; this should never happen.";
707 return *reinterpret_cast< ::google::protobuf::Message*>(NULL);
708 }
709}
710
711UnityService_Stub::UnityService_Stub(::google::protobuf::RpcChannel* channel)
712 : channel_(channel), owns_channel_(false) {}
713UnityService_Stub::UnityService_Stub(
714 ::google::protobuf::RpcChannel* channel,
715 ::google::protobuf::Service::ChannelOwnership ownership)
716 : channel_(channel),
717 owns_channel_(ownership == ::google::protobuf::Service::STUB_OWNS_CHANNEL) {}
718UnityService_Stub::~UnityService_Stub() {
719 if (owns_channel_) delete channel_;
720}
721
722void UnityService_Stub::copy(::google::protobuf::RpcController* controller,
723 const ::unity::protobuf::Clip* request,
724 ::unity::protobuf::Void* response,
725 ::google::protobuf::Closure* done) {
726 channel_->CallMethod(descriptor()->method(0),
727 controller, request, response, done);
728}
729void UnityService_Stub::paste(::google::protobuf::RpcController* controller,
730 const ::unity::protobuf::Void* request,
731 ::unity::protobuf::Clip* response,
732 ::google::protobuf::Closure* done) {
733 channel_->CallMethod(descriptor()->method(1),
734 controller, request, response, done);
735}
736
737// @@protoc_insertion_point(namespace_scope)
738
739} // namespace protobuf
740} // namespace unity
741
742// @@protoc_insertion_point(global_scope)
7430
=== removed file 'src/platforms/mirserver/unityrpc.h'
--- src/platforms/mirserver/unityrpc.h 2014-06-16 18:29:36 +0000
+++ src/platforms/mirserver/unityrpc.h 1970-01-01 00:00:00 +0000
@@ -1,535 +0,0 @@
1// Generated by the protocol buffer compiler. DO NOT EDIT!
2// source: unityrpc.proto
3
4#ifndef PROTOBUF_unityrpc_2eproto__INCLUDED
5#define PROTOBUF_unityrpc_2eproto__INCLUDED
6
7#include <string>
8
9#include <google/protobuf/stubs/common.h>
10
11#if GOOGLE_PROTOBUF_VERSION < 2005000
12#error This file was generated by a newer version of protoc which is
13#error incompatible with your Protocol Buffer headers. Please update
14#error your headers.
15#endif
16#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
17#error This file was generated by an older version of protoc which is
18#error incompatible with your Protocol Buffer headers. Please
19#error regenerate this file with a newer version of protoc.
20#endif
21
22#include <google/protobuf/generated_message_util.h>
23#include <google/protobuf/message.h>
24#include <google/protobuf/repeated_field.h>
25#include <google/protobuf/extension_set.h>
26#include <google/protobuf/service.h>
27#include <google/protobuf/unknown_field_set.h>
28// @@protoc_insertion_point(includes)
29
30namespace unity {
31namespace protobuf {
32
33// Internal implementation detail -- do not call these.
34void protobuf_AddDesc_unityrpc_2eproto();
35void protobuf_AssignDesc_unityrpc_2eproto();
36void protobuf_ShutdownFile_unityrpc_2eproto();
37
38class Clip;
39class Void;
40
41// ===================================================================
42
43class Clip : public ::google::protobuf::Message {
44 public:
45 Clip();
46 virtual ~Clip();
47
48 Clip(const Clip& from);
49
50 inline Clip& operator=(const Clip& from) {
51 CopyFrom(from);
52 return *this;
53 }
54
55 inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
56 return _unknown_fields_;
57 }
58
59 inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
60 return &_unknown_fields_;
61 }
62
63 static const ::google::protobuf::Descriptor* descriptor();
64 static const Clip& default_instance();
65
66 void Swap(Clip* other);
67
68 // implements Message ----------------------------------------------
69
70 Clip* New() const;
71 void CopyFrom(const ::google::protobuf::Message& from);
72 void MergeFrom(const ::google::protobuf::Message& from);
73 void CopyFrom(const Clip& from);
74 void MergeFrom(const Clip& from);
75 void Clear();
76 bool IsInitialized() const;
77
78 int ByteSize() const;
79 bool MergePartialFromCodedStream(
80 ::google::protobuf::io::CodedInputStream* input);
81 void SerializeWithCachedSizes(
82 ::google::protobuf::io::CodedOutputStream* output) const;
83 ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
84 int GetCachedSize() const { return _cached_size_; }
85 private:
86 void SharedCtor();
87 void SharedDtor();
88 void SetCachedSize(int size) const;
89 public:
90
91 ::google::protobuf::Metadata GetMetadata() const;
92
93 // nested types ----------------------------------------------------
94
95 // accessors -------------------------------------------------------
96
97 // required bytes content = 1;
98 inline bool has_content() const;
99 inline void clear_content();
100 static const int kContentFieldNumber = 1;
101 inline const ::std::string& content() const;
102 inline void set_content(const ::std::string& value);
103 inline void set_content(const char* value);
104 inline void set_content(const void* value, size_t size);
105 inline ::std::string* mutable_content();
106 inline ::std::string* release_content();
107 inline void set_allocated_content(::std::string* content);
108
109 // optional string error = 127;
110 inline bool has_error() const;
111 inline void clear_error();
112 static const int kErrorFieldNumber = 127;
113 inline const ::std::string& error() const;
114 inline void set_error(const ::std::string& value);
115 inline void set_error(const char* value);
116 inline void set_error(const char* value, size_t size);
117 inline ::std::string* mutable_error();
118 inline ::std::string* release_error();
119 inline void set_allocated_error(::std::string* error);
120
121 // @@protoc_insertion_point(class_scope:unity.protobuf.Clip)
122 private:
123 inline void set_has_content();
124 inline void clear_has_content();
125 inline void set_has_error();
126 inline void clear_has_error();
127
128 ::google::protobuf::UnknownFieldSet _unknown_fields_;
129
130 ::std::string* content_;
131 ::std::string* error_;
132
133 mutable int _cached_size_;
134 ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
135
136 friend void protobuf_AddDesc_unityrpc_2eproto();
137 friend void protobuf_AssignDesc_unityrpc_2eproto();
138 friend void protobuf_ShutdownFile_unityrpc_2eproto();
139
140 void InitAsDefaultInstance();
141 static Clip* default_instance_;
142};
143// -------------------------------------------------------------------
144
145class Void : public ::google::protobuf::Message {
146 public:
147 Void();
148 virtual ~Void();
149
150 Void(const Void& from);
151
152 inline Void& operator=(const Void& from) {
153 CopyFrom(from);
154 return *this;
155 }
156
157 inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
158 return _unknown_fields_;
159 }
160
161 inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
162 return &_unknown_fields_;
163 }
164
165 static const ::google::protobuf::Descriptor* descriptor();
166 static const Void& default_instance();
167
168 void Swap(Void* other);
169
170 // implements Message ----------------------------------------------
171
172 Void* New() const;
173 void CopyFrom(const ::google::protobuf::Message& from);
174 void MergeFrom(const ::google::protobuf::Message& from);
175 void CopyFrom(const Void& from);
176 void MergeFrom(const Void& from);
177 void Clear();
178 bool IsInitialized() const;
179
180 int ByteSize() const;
181 bool MergePartialFromCodedStream(
182 ::google::protobuf::io::CodedInputStream* input);
183 void SerializeWithCachedSizes(
184 ::google::protobuf::io::CodedOutputStream* output) const;
185 ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
186 int GetCachedSize() const { return _cached_size_; }
187 private:
188 void SharedCtor();
189 void SharedDtor();
190 void SetCachedSize(int size) const;
191 public:
192
193 ::google::protobuf::Metadata GetMetadata() const;
194
195 // nested types ----------------------------------------------------
196
197 // accessors -------------------------------------------------------
198
199 // optional string error = 127;
200 inline bool has_error() const;
201 inline void clear_error();
202 static const int kErrorFieldNumber = 127;
203 inline const ::std::string& error() const;
204 inline void set_error(const ::std::string& value);
205 inline void set_error(const char* value);
206 inline void set_error(const char* value, size_t size);
207 inline ::std::string* mutable_error();
208 inline ::std::string* release_error();
209 inline void set_allocated_error(::std::string* error);
210
211 // @@protoc_insertion_point(class_scope:unity.protobuf.Void)
212 private:
213 inline void set_has_error();
214 inline void clear_has_error();
215
216 ::google::protobuf::UnknownFieldSet _unknown_fields_;
217
218 ::std::string* error_;
219
220 mutable int _cached_size_;
221 ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
222
223 friend void protobuf_AddDesc_unityrpc_2eproto();
224 friend void protobuf_AssignDesc_unityrpc_2eproto();
225 friend void protobuf_ShutdownFile_unityrpc_2eproto();
226
227 void InitAsDefaultInstance();
228 static Void* default_instance_;
229};
230// ===================================================================
231
232class UnityService_Stub;
233
234class UnityService : public ::google::protobuf::Service {
235 protected:
236 // This class should be treated as an abstract interface.
237 inline UnityService() {};
238 public:
239 virtual ~UnityService();
240
241 typedef UnityService_Stub Stub;
242
243 static const ::google::protobuf::ServiceDescriptor* descriptor();
244
245 virtual void copy(::google::protobuf::RpcController* controller,
246 const ::unity::protobuf::Clip* request,
247 ::unity::protobuf::Void* response,
248 ::google::protobuf::Closure* done);
249 virtual void paste(::google::protobuf::RpcController* controller,
250 const ::unity::protobuf::Void* request,
251 ::unity::protobuf::Clip* response,
252 ::google::protobuf::Closure* done);
253
254 // implements Service ----------------------------------------------
255
256 const ::google::protobuf::ServiceDescriptor* GetDescriptor();
257 void CallMethod(const ::google::protobuf::MethodDescriptor* method,
258 ::google::protobuf::RpcController* controller,
259 const ::google::protobuf::Message* request,
260 ::google::protobuf::Message* response,
261 ::google::protobuf::Closure* done);
262 const ::google::protobuf::Message& GetRequestPrototype(
263 const ::google::protobuf::MethodDescriptor* method) const;
264 const ::google::protobuf::Message& GetResponsePrototype(
265 const ::google::protobuf::MethodDescriptor* method) const;
266
267 private:
268 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(UnityService);
269};
270
271class UnityService_Stub : public UnityService {
272 public:
273 UnityService_Stub(::google::protobuf::RpcChannel* channel);
274 UnityService_Stub(::google::protobuf::RpcChannel* channel,
275 ::google::protobuf::Service::ChannelOwnership ownership);
276 ~UnityService_Stub();
277
278 inline ::google::protobuf::RpcChannel* channel() { return channel_; }
279
280 // implements UnityService ------------------------------------------
281
282 void copy(::google::protobuf::RpcController* controller,
283 const ::unity::protobuf::Clip* request,
284 ::unity::protobuf::Void* response,
285 ::google::protobuf::Closure* done);
286 void paste(::google::protobuf::RpcController* controller,
287 const ::unity::protobuf::Void* request,
288 ::unity::protobuf::Clip* response,
289 ::google::protobuf::Closure* done);
290 private:
291 ::google::protobuf::RpcChannel* channel_;
292 bool owns_channel_;
293 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(UnityService_Stub);
294};
295
296
297// ===================================================================
298
299
300// ===================================================================
301
302// Clip
303
304// required bytes content = 1;
305inline bool Clip::has_content() const {
306 return (_has_bits_[0] & 0x00000001u) != 0;
307}
308inline void Clip::set_has_content() {
309 _has_bits_[0] |= 0x00000001u;
310}
311inline void Clip::clear_has_content() {
312 _has_bits_[0] &= ~0x00000001u;
313}
314inline void Clip::clear_content() {
315 if (content_ != &::google::protobuf::internal::kEmptyString) {
316 content_->clear();
317 }
318 clear_has_content();
319}
320inline const ::std::string& Clip::content() const {
321 return *content_;
322}
323inline void Clip::set_content(const ::std::string& value) {
324 set_has_content();
325 if (content_ == &::google::protobuf::internal::kEmptyString) {
326 content_ = new ::std::string;
327 }
328 content_->assign(value);
329}
330inline void Clip::set_content(const char* value) {
331 set_has_content();
332 if (content_ == &::google::protobuf::internal::kEmptyString) {
333 content_ = new ::std::string;
334 }
335 content_->assign(value);
336}
337inline void Clip::set_content(const void* value, size_t size) {
338 set_has_content();
339 if (content_ == &::google::protobuf::internal::kEmptyString) {
340 content_ = new ::std::string;
341 }
342 content_->assign(reinterpret_cast<const char*>(value), size);
343}
344inline ::std::string* Clip::mutable_content() {
345 set_has_content();
346 if (content_ == &::google::protobuf::internal::kEmptyString) {
347 content_ = new ::std::string;
348 }
349 return content_;
350}
351inline ::std::string* Clip::release_content() {
352 clear_has_content();
353 if (content_ == &::google::protobuf::internal::kEmptyString) {
354 return NULL;
355 } else {
356 ::std::string* temp = content_;
357 content_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
358 return temp;
359 }
360}
361inline void Clip::set_allocated_content(::std::string* content) {
362 if (content_ != &::google::protobuf::internal::kEmptyString) {
363 delete content_;
364 }
365 if (content) {
366 set_has_content();
367 content_ = content;
368 } else {
369 clear_has_content();
370 content_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
371 }
372}
373
374// optional string error = 127;
375inline bool Clip::has_error() const {
376 return (_has_bits_[0] & 0x00000002u) != 0;
377}
378inline void Clip::set_has_error() {
379 _has_bits_[0] |= 0x00000002u;
380}
381inline void Clip::clear_has_error() {
382 _has_bits_[0] &= ~0x00000002u;
383}
384inline void Clip::clear_error() {
385 if (error_ != &::google::protobuf::internal::kEmptyString) {
386 error_->clear();
387 }
388 clear_has_error();
389}
390inline const ::std::string& Clip::error() const {
391 return *error_;
392}
393inline void Clip::set_error(const ::std::string& value) {
394 set_has_error();
395 if (error_ == &::google::protobuf::internal::kEmptyString) {
396 error_ = new ::std::string;
397 }
398 error_->assign(value);
399}
400inline void Clip::set_error(const char* value) {
401 set_has_error();
402 if (error_ == &::google::protobuf::internal::kEmptyString) {
403 error_ = new ::std::string;
404 }
405 error_->assign(value);
406}
407inline void Clip::set_error(const char* value, size_t size) {
408 set_has_error();
409 if (error_ == &::google::protobuf::internal::kEmptyString) {
410 error_ = new ::std::string;
411 }
412 error_->assign(reinterpret_cast<const char*>(value), size);
413}
414inline ::std::string* Clip::mutable_error() {
415 set_has_error();
416 if (error_ == &::google::protobuf::internal::kEmptyString) {
417 error_ = new ::std::string;
418 }
419 return error_;
420}
421inline ::std::string* Clip::release_error() {
422 clear_has_error();
423 if (error_ == &::google::protobuf::internal::kEmptyString) {
424 return NULL;
425 } else {
426 ::std::string* temp = error_;
427 error_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
428 return temp;
429 }
430}
431inline void Clip::set_allocated_error(::std::string* error) {
432 if (error_ != &::google::protobuf::internal::kEmptyString) {
433 delete error_;
434 }
435 if (error) {
436 set_has_error();
437 error_ = error;
438 } else {
439 clear_has_error();
440 error_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
441 }
442}
443
444// -------------------------------------------------------------------
445
446// Void
447
448// optional string error = 127;
449inline bool Void::has_error() const {
450 return (_has_bits_[0] & 0x00000001u) != 0;
451}
452inline void Void::set_has_error() {
453 _has_bits_[0] |= 0x00000001u;
454}
455inline void Void::clear_has_error() {
456 _has_bits_[0] &= ~0x00000001u;
457}
458inline void Void::clear_error() {
459 if (error_ != &::google::protobuf::internal::kEmptyString) {
460 error_->clear();
461 }
462 clear_has_error();
463}
464inline const ::std::string& Void::error() const {
465 return *error_;
466}
467inline void Void::set_error(const ::std::string& value) {
468 set_has_error();
469 if (error_ == &::google::protobuf::internal::kEmptyString) {
470 error_ = new ::std::string;
471 }
472 error_->assign(value);
473}
474inline void Void::set_error(const char* value) {
475 set_has_error();
476 if (error_ == &::google::protobuf::internal::kEmptyString) {
477 error_ = new ::std::string;
478 }
479 error_->assign(value);
480}
481inline void Void::set_error(const char* value, size_t size) {
482 set_has_error();
483 if (error_ == &::google::protobuf::internal::kEmptyString) {
484 error_ = new ::std::string;
485 }
486 error_->assign(reinterpret_cast<const char*>(value), size);
487}
488inline ::std::string* Void::mutable_error() {
489 set_has_error();
490 if (error_ == &::google::protobuf::internal::kEmptyString) {
491 error_ = new ::std::string;
492 }
493 return error_;
494}
495inline ::std::string* Void::release_error() {
496 clear_has_error();
497 if (error_ == &::google::protobuf::internal::kEmptyString) {
498 return NULL;
499 } else {
500 ::std::string* temp = error_;
501 error_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
502 return temp;
503 }
504}
505inline void Void::set_allocated_error(::std::string* error) {
506 if (error_ != &::google::protobuf::internal::kEmptyString) {
507 delete error_;
508 }
509 if (error) {
510 set_has_error();
511 error_ = error;
512 } else {
513 clear_has_error();
514 error_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
515 }
516}
517
518
519// @@protoc_insertion_point(namespace_scope)
520
521} // namespace protobuf
522} // namespace unity
523
524#ifndef SWIG
525namespace google {
526namespace protobuf {
527
528
529} // namespace google
530} // namespace protobuf
531#endif // SWIG
532
533// @@protoc_insertion_point(global_scope)
534
535#endif // PROTOBUF_unityrpc_2eproto__INCLUDED
5360
=== removed file 'src/platforms/mirserver/unityrpc.proto'
--- src/platforms/mirserver/unityrpc.proto 2014-06-16 18:29:36 +0000
+++ src/platforms/mirserver/unityrpc.proto 1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
1option cc_generic_services = true;
2
3package unity.protobuf;
4
5message Clip {
6 required bytes content = 1;
7 optional string error = 127;
8}
9
10message Void {
11 optional string error = 127;
12}
13
14service UnityService {
15 rpc copy(Clip) returns (Void);
16 rpc paste(Void) returns (Clip);
17}
180
=== added directory 'tests/mirserver/Clipboard'
=== added file 'tests/mirserver/Clipboard/Clipboard.pro'
--- tests/mirserver/Clipboard/Clipboard.pro 1970-01-01 00:00:00 +0000
+++ tests/mirserver/Clipboard/Clipboard.pro 2014-09-23 11:37:20 +0000
@@ -0,0 +1,16 @@
1include(../../test-includes.pri)
2
3TARGET = ClipboardTest
4
5QT += gui-private
6
7INCLUDEPATH += \
8 ../../../src/platforms/mirserver \
9 ../../../src/common
10
11SOURCES += \
12 clipboard_test.cpp \
13 ../../../src/common/debughelpers.cpp
14
15LIBS += -Wl,-rpath,$${OUT_PWD}/../../../src/platforms/mirserver \
16 -L../../../src/platforms/mirserver -lqpa-mirserver
017
=== added file 'tests/mirserver/Clipboard/clipboard_test.cpp'
--- tests/mirserver/Clipboard/clipboard_test.cpp 1970-01-01 00:00:00 +0000
+++ tests/mirserver/Clipboard/clipboard_test.cpp 2014-09-23 11:37:20 +0000
@@ -0,0 +1,76 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#include <gtest/gtest.h>
19
20#include <clipboard.h>
21
22#include <QLoggingCategory>
23#include <QMimeData>
24
25using namespace qtmir;
26
27TEST(ClipboardTest, MimeDataSerialization)
28{
29 QMimeData *mimeData = new QMimeData;
30 mimeData->setData("text/plain", "Hello World!");
31 mimeData->setData("text/html", "<html lang=\"en\"><body>Hello World!</body></html>");
32
33 QByteArray serializedMimeData = serializeMimeData(mimeData);
34
35 ASSERT_TRUE(serializedMimeData.size() > 0);
36
37 QMimeData *deserializedMimeData = deserializeMimeData(serializedMimeData);
38
39 ASSERT_TRUE(deserializedMimeData != nullptr);
40
41 ASSERT_TRUE(deserializedMimeData->hasFormat("text/plain"));
42 ASSERT_EQ(mimeData->data("text/plain"), deserializedMimeData->data("text/plain"));
43
44 ASSERT_TRUE(deserializedMimeData->hasFormat("text/html"));
45 ASSERT_EQ(mimeData->data("text/html"), deserializedMimeData->data("text/html"));
46
47 delete mimeData;
48 delete deserializedMimeData;
49}
50
51TEST(ClipboardTest, RefuseContentsThatAreTooBig)
52{
53 QLoggingCategory::setFilterRules(QStringLiteral("*=false"));
54 DBusClipboard::skipDBusRegistration = true;
55 DBusClipboard *dbusClipboard = new DBusClipboard;
56
57 // Was getting a "warning: overflow in implicit constant conversion [-Woverflow]"
58 // when I used that constant directly in the QByteArray constructors below. Don't
59 // understand why so here's the workaround for it.
60 int maxContentsSize = DBusClipboard::maxContentsSize;
61
62 QByteArray reasonableContents(maxContentsSize * 0.9, 'R');
63 QByteArray tooBigContents(maxContentsSize * 1.2, 'B');
64
65 dbusClipboard->SetContents(reasonableContents);
66
67 ASSERT_EQ(dbusClipboard->contents(), reasonableContents);
68
69 dbusClipboard->SetContents(tooBigContents);
70
71 // tooBigContents were refused. So it stays with the previously
72 // set contents
73 ASSERT_EQ(dbusClipboard->contents(), reasonableContents);
74
75 delete dbusClipboard;
76}
077
=== modified file 'tests/mirserver/mirserver.pro'
--- tests/mirserver/mirserver.pro 2014-08-27 11:51:28 +0000
+++ tests/mirserver/mirserver.pro 2014-09-23 11:37:20 +0000
@@ -1,2 +1,2 @@
1TEMPLATE = subdirs1TEMPLATE = subdirs
2SUBDIRS = QtEventFeeder2SUBDIRS = QtEventFeeder Clipboard

Subscribers

People subscribed via source and target branches