Merge lp:~abreu-alexandre/content-hub/types-per-app-id into lp:content-hub

Proposed by Alexandre Abreu
Status: Needs review
Proposed branch: lp:~abreu-alexandre/content-hub/types-per-app-id
Merge into: lp:content-hub
Diff against target: 312 lines (+120/-0)
17 files modified
import/Ubuntu/Content/contenthub.cpp (+24/-0)
import/Ubuntu/Content/contenthub.h (+2/-0)
include/com/ubuntu/content/hub.h (+1/-0)
src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml (+4/-0)
src/com/ubuntu/content/detail/peer_registry.h (+1/-0)
src/com/ubuntu/content/detail/service.cpp (+14/-0)
src/com/ubuntu/content/detail/service.h (+1/-0)
src/com/ubuntu/content/hub.cpp (+19/-0)
src/com/ubuntu/content/service/registry.cpp (+46/-0)
src/com/ubuntu/content/service/registry.h (+1/-0)
tests/acceptance-tests/app_hub_communication_default_source.cpp (+1/-0)
tests/acceptance-tests/app_hub_communication_handler.cpp (+1/-0)
tests/acceptance-tests/app_hub_communication_known_sources.cpp (+1/-0)
tests/acceptance-tests/app_hub_communication_paste.cpp (+1/-0)
tests/acceptance-tests/app_hub_communication_stores.cpp (+1/-0)
tests/acceptance-tests/app_hub_communication_transfer.cpp (+1/-0)
tests/acceptance-tests/test_hook.cpp (+1/-0)
To merge this branch: bzr merge lp:~abreu-alexandre/content-hub/types-per-app-id
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Needs Fixing
Ken VanDine Approve
Review via email: mp+299081@code.launchpad.net

Commit message

Give apps access to their currently supported content-types

Description of the change

Give apps access to their currently supported content-types

To post a comment you must log in.
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

PASSED: Continuous integration, rev:282
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/17/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/832
    SUCCESS: https://jenkins.canonical.com/system-apps/job/test-0-autopkgtest/label=phone-armhf,release=vivid+overlay,testname=default/144
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/832
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/762
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/762
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/762
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/764
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/764/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/764
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/764/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/764
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/764/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/764
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/764/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/764
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/764/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/764
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/764/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/764
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/764/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/764
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/764/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/764
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/764/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-3-clickpkg/29

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/17/rebuild

review: Approve (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Looks good

review: Approve
283. By Alexandre Abreu

merge trunk

284. By Alexandre Abreu

fix merged trunk test

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:284
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/50/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1440/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1440
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1290
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1290/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1290/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1290
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1290/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1290
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1290/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1290
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1290/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1290
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1290/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1290
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1290/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1290/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1290
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1290/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/50/rebuild

review: Needs Fixing (continuous-integration)

Unmerged revisions

284. By Alexandre Abreu

fix merged trunk test

283. By Alexandre Abreu

merge trunk

282. By Alexandre Abreu

bit braces

281. By Alexandre Abreu

tweaks

280. By Alexandre Abreu

draft

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'import/Ubuntu/Content/contenthub.cpp'
2--- import/Ubuntu/Content/contenthub.cpp 2015-08-21 14:49:38 +0000
3+++ import/Ubuntu/Content/contenthub.cpp 2016-09-07 16:26:08 +0000
4@@ -316,6 +316,30 @@
5 }
6
7 /*!
8+ * \brief ContentHub::getSupportedTypes returns the list of supported types by the current host application
9+ * \return List of supported ContentType
10+ */
11+QList<ContentType::Type> ContentHub::getSupportedTypes()
12+{
13+ TRACE() << Q_FUNC_INFO;
14+
15+ QList<ContentType::Type> type_ids;
16+
17+ QString appId = QString(qgetenv("APP_ID"));
18+ if (appId.isEmpty())
19+ {
20+ return type_ids;
21+ }
22+
23+ QVector<QString> types = m_hub->supported_types_for_app_id(appId);
24+ Q_FOREACH(const QString& t, types)
25+ {
26+ type_ids.append(ContentType::hubType2contentType(t));
27+ }
28+ return type_ids;
29+}
30+
31+/*!
32 * \qmlsignal ContentHub::importRequested(ContentTransfer transfer)
33 *
34 * The signal is triggered when an import is requested.
35
36=== modified file 'import/Ubuntu/Content/contenthub.h'
37--- import/Ubuntu/Content/contenthub.h 2015-08-20 15:54:52 +0000
38+++ import/Ubuntu/Content/contenthub.h 2016-09-07 16:26:08 +0000
39@@ -23,6 +23,7 @@
40 #include <QQmlListProperty>
41 #include "contentpeer.h"
42 #include "contenttransfer.h"
43+#include "contenttype.h"
44
45 class ContentStore;
46 class QmlImportExportHandler;
47@@ -58,6 +59,7 @@
48 Q_INVOKABLE ContentTransfer* importContent(com::ubuntu::content::Peer peer, ContentType::Type type);
49 Q_INVOKABLE ContentTransfer* exportContent(com::ubuntu::content::Peer peer, ContentType::Type type);
50 Q_INVOKABLE ContentTransfer* shareContent(com::ubuntu::content::Peer peer, ContentType::Type type);
51+ Q_INVOKABLE QList<ContentType::Type> getSupportedTypes();
52
53 Q_SIGNALS:
54 void importRequested(ContentTransfer *transfer);
55
56=== modified file 'include/com/ubuntu/content/hub.h'
57--- include/com/ubuntu/content/hub.h 2016-08-24 20:23:44 +0000
58+++ include/com/ubuntu/content/hub.h 2016-09-07 16:26:08 +0000
59@@ -62,6 +62,7 @@
60 Q_INVOKABLE virtual Transfer* create_import_from_peer(Peer peer);
61 Q_INVOKABLE virtual Transfer* create_export_to_peer(Peer peer);
62 Q_INVOKABLE virtual Transfer* create_share_to_peer(Peer peer);
63+ Q_INVOKABLE virtual QVector<QString> supported_types_for_app_id(QString app_id);
64
65 Q_INVOKABLE virtual void quit();
66
67
68=== modified file 'src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml'
69--- src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml 2016-08-24 20:23:44 +0000
70+++ src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml 2016-09-07 16:26:08 +0000
71@@ -67,6 +67,10 @@
72 <arg name="app_id" type="s" direction="in" />
73 <arg name="peer" type="v" direction="out" />
74 </method>
75+ <method name="SupportedTypesForAppId">
76+ <arg name="app_id" type="s" direction="in" />
77+ <arg name="types" type="av" direction="out" />
78+ </method>
79 <method name="PasteFormats">
80 <arg name="formats" type="as" direction="out" />
81 </method>
82
83=== modified file 'src/com/ubuntu/content/detail/peer_registry.h'
84--- src/com/ubuntu/content/detail/peer_registry.h 2015-10-20 20:18:18 +0000
85+++ src/com/ubuntu/content/detail/peer_registry.h 2016-09-07 16:26:08 +0000
86@@ -51,6 +51,7 @@
87 virtual bool install_share_for_type(Type, Peer) = 0;
88 virtual bool remove_peer(Peer peer) = 0;
89 virtual bool peer_is_legacy(QString type) = 0;
90+ virtual void enumerate_types_for_app_id(const QString& app_id, const std::function<void(const QString&)>&for_each) = 0;
91
92 };
93 }
94
95=== modified file 'src/com/ubuntu/content/detail/service.cpp'
96--- src/com/ubuntu/content/detail/service.cpp 2016-08-24 20:23:44 +0000
97+++ src/com/ubuntu/content/detail/service.cpp 2016-09-07 16:26:08 +0000
98@@ -756,6 +756,20 @@
99 return false;
100 }
101
102+QVariantList cucd::Service::SupportedTypesForAppId(const QString& app_id)
103+{
104+ QVariantList result;
105+
106+ d->registry->enumerate_types_for_app_id(
107+ app_id,
108+ [&result](const QString& type)
109+ {
110+ result.append(QVariant::fromValue(type));
111+ });
112+
113+ return result;
114+}
115+
116 QStringList cucd::Service::PasteFormats()
117 {
118 TRACE() << Q_FUNC_INFO;
119
120=== modified file 'src/com/ubuntu/content/detail/service.h'
121--- src/com/ubuntu/content/detail/service.h 2016-08-24 20:23:44 +0000
122+++ src/com/ubuntu/content/detail/service.h 2016-09-07 16:26:08 +0000
123@@ -61,6 +61,7 @@
124 QDBusObjectPath CreateImportFromPeer(const QString&, const QString&, const QString&);
125 QDBusObjectPath CreateExportToPeer(const QString&, const QString&, const QString&);
126 QDBusObjectPath CreateShareToPeer(const QString&, const QString&, const QString&);
127+ QVariantList SupportedTypesForAppId(const QString &);
128 bool CreatePaste(const QString&, const QString&, const QByteArray&, const QStringList&);
129 QByteArray GetLatestPasteData(const QString& surfaceId);
130 QByteArray GetPasteData(const QString& surfaceId, const QString& pasteId);
131
132=== modified file 'src/com/ubuntu/content/hub.cpp'
133--- src/com/ubuntu/content/hub.cpp 2016-08-24 20:23:44 +0000
134+++ src/com/ubuntu/content/hub.cpp 2016-09-07 16:26:08 +0000
135@@ -251,6 +251,25 @@
136 return result;
137 }
138
139+QVector<QString> cuc::Hub::supported_types_for_app_id(QString app_id)
140+{
141+ QVector<QString> result;
142+
143+ auto reply = d->service->SupportedTypesForAppId(app_id);
144+ reply.waitForFinished();
145+
146+ if (reply.isError())
147+ return result;
148+
149+ auto types = reply.value();
150+
151+ Q_FOREACH(const QVariant& t, types)
152+ {
153+ result << qdbus_cast<QString>(t);
154+ }
155+ return result;
156+}
157+
158 QVector<cuc::Peer> cuc::Hub::known_shares_for_type(cuc::Type t)
159 {
160 QVector<cuc::Peer> result;
161
162=== modified file 'src/com/ubuntu/content/service/registry.cpp'
163--- src/com/ubuntu/content/service/registry.cpp 2016-01-29 17:27:50 +0000
164+++ src/com/ubuntu/content/service/registry.cpp 2016-09-07 16:26:08 +0000
165@@ -255,6 +255,52 @@
166 }
167 }
168
169+void Registry::enumerate_types_for_app_id(const QString& app_id,
170+ const std::function<void(const QString&)>&for_each)
171+{
172+ TRACE() << Q_FUNC_INFO;
173+
174+ Q_FOREACH (QString type_id, m_sources->keys())
175+ {
176+ TRACE() << Q_FUNC_INFO << type_id;
177+ Q_FOREACH (QString k, m_sources->get(type_id).toStringList())
178+ {
179+ TRACE() << Q_FUNC_INFO << k;
180+ if (k == app_id)
181+ {
182+ for_each(type_id);
183+ break;
184+ }
185+ }
186+ }
187+ Q_FOREACH (QString type_id, m_dests->keys())
188+ {
189+ TRACE() << Q_FUNC_INFO << type_id;
190+ Q_FOREACH (QString k, m_dests->get(type_id).toStringList())
191+ {
192+ TRACE() << Q_FUNC_INFO << k;
193+ if (k == app_id)
194+ {
195+ for_each(type_id);
196+ break;
197+ }
198+ }
199+ }
200+ Q_FOREACH (QString type_id, m_shares->keys())
201+ {
202+ TRACE() << Q_FUNC_INFO << type_id;
203+ Q_FOREACH (QString k, m_shares->get(type_id).toStringList())
204+ {
205+ TRACE() << Q_FUNC_INFO << k;
206+ if (k == app_id)
207+ {
208+ for_each(type_id);
209+ break;
210+ }
211+ }
212+ }
213+}
214+
215 void Registry::enumerate_known_sources_for_type(cuc::Type type, const std::function<void(const cuc::Peer&)>&for_each)
216 {
217 TRACE() << Q_FUNC_INFO << type.id();
218
219=== modified file 'src/com/ubuntu/content/service/registry.h'
220--- src/com/ubuntu/content/service/registry.h 2015-10-20 20:18:18 +0000
221+++ src/com/ubuntu/content/service/registry.h 2016-09-07 16:26:08 +0000
222@@ -44,6 +44,7 @@
223 bool install_share_for_type(cuc::Type type, cuc::Peer peer);
224 bool remove_peer(cuc::Peer peer);
225 bool peer_is_legacy(QString type);
226+ void enumerate_types_for_app_id(const QString& app_id, const std::function<void(const QString&)>&for_each);
227
228 private:
229 QScopedPointer<QGSettings> m_defaultSources;
230
231=== modified file 'tests/acceptance-tests/app_hub_communication_default_source.cpp'
232--- tests/acceptance-tests/app_hub_communication_default_source.cpp 2015-10-20 20:23:09 +0000
233+++ tests/acceptance-tests/app_hub_communication_default_source.cpp 2016-09-07 16:26:08 +0000
234@@ -76,6 +76,7 @@
235 MOCK_METHOD2(install_share_for_type, bool(cuc::Type, cuc::Peer));
236 MOCK_METHOD1(remove_peer, bool(cuc::Peer));
237 MOCK_METHOD1(peer_is_legacy, bool(QString));
238+ MOCK_METHOD2(enumerate_types_for_app_id, void(const QString&, const std::function<void(const QString&)>&));
239 };
240 }
241
242
243=== modified file 'tests/acceptance-tests/app_hub_communication_handler.cpp'
244--- tests/acceptance-tests/app_hub_communication_handler.cpp 2016-05-31 19:50:24 +0000
245+++ tests/acceptance-tests/app_hub_communication_handler.cpp 2016-09-07 16:26:08 +0000
246@@ -74,6 +74,7 @@
247 MOCK_METHOD2(install_share_for_type, bool(cuc::Type, cuc::Peer));
248 MOCK_METHOD1(remove_peer, bool(cuc::Peer));
249 MOCK_METHOD1(peer_is_legacy, bool(QString));
250+ MOCK_METHOD2(enumerate_types_for_app_id, void(const QString&, const std::function<void(const QString&)>&));
251 };
252
253 struct MockedHandler : public cuc::ImportExportHandler
254
255=== modified file 'tests/acceptance-tests/app_hub_communication_known_sources.cpp'
256--- tests/acceptance-tests/app_hub_communication_known_sources.cpp 2016-07-15 18:54:41 +0000
257+++ tests/acceptance-tests/app_hub_communication_known_sources.cpp 2016-09-07 16:26:08 +0000
258@@ -75,6 +75,7 @@
259 MOCK_METHOD2(install_share_for_type, bool(cuc::Type, cuc::Peer));
260 MOCK_METHOD1(remove_peer, bool(cuc::Peer));
261 MOCK_METHOD1(peer_is_legacy, bool(QString));
262+ MOCK_METHOD2(enumerate_types_for_app_id, void(const QString&, const std::function<void(const QString&)>&));
263 };
264 }
265
266
267=== modified file 'tests/acceptance-tests/app_hub_communication_paste.cpp'
268--- tests/acceptance-tests/app_hub_communication_paste.cpp 2016-08-23 20:17:57 +0000
269+++ tests/acceptance-tests/app_hub_communication_paste.cpp 2016-09-07 16:26:08 +0000
270@@ -74,6 +74,7 @@
271 MOCK_METHOD2(install_share_for_type, bool(cuc::Type, cuc::Peer));
272 MOCK_METHOD1(remove_peer, bool(cuc::Peer));
273 MOCK_METHOD1(peer_is_legacy, bool(QString));
274+ MOCK_METHOD2(enumerate_types_for_app_id, void(const QString&, const std::function<void(const QString&)>&));
275 };
276 }
277
278
279=== modified file 'tests/acceptance-tests/app_hub_communication_stores.cpp'
280--- tests/acceptance-tests/app_hub_communication_stores.cpp 2015-10-20 20:23:09 +0000
281+++ tests/acceptance-tests/app_hub_communication_stores.cpp 2016-09-07 16:26:08 +0000
282@@ -75,6 +75,7 @@
283 MOCK_METHOD2(install_share_for_type, bool(cuc::Type, cuc::Peer));
284 MOCK_METHOD1(remove_peer, bool(cuc::Peer));
285 MOCK_METHOD1(peer_is_legacy, bool(QString));
286+ MOCK_METHOD2(enumerate_types_for_app_id, void(const QString&, const std::function<void(const QString&)>&));
287 };
288 }
289
290
291=== modified file 'tests/acceptance-tests/app_hub_communication_transfer.cpp'
292--- tests/acceptance-tests/app_hub_communication_transfer.cpp 2015-10-20 20:23:09 +0000
293+++ tests/acceptance-tests/app_hub_communication_transfer.cpp 2016-09-07 16:26:08 +0000
294@@ -78,6 +78,7 @@
295 MOCK_METHOD2(install_share_for_type, bool(cuc::Type, cuc::Peer));
296 MOCK_METHOD1(remove_peer, bool(cuc::Peer));
297 MOCK_METHOD1(peer_is_legacy, bool(QString));
298+ MOCK_METHOD2(enumerate_types_for_app_id, void(const QString&, const std::function<void(const QString&)>&));
299 };
300 }
301
302
303=== modified file 'tests/acceptance-tests/test_hook.cpp'
304--- tests/acceptance-tests/test_hook.cpp 2015-10-20 20:23:09 +0000
305+++ tests/acceptance-tests/test_hook.cpp 2016-09-07 16:26:08 +0000
306@@ -57,6 +57,7 @@
307 MOCK_METHOD2(install_share_for_type, bool(cuc::Type, cuc::Peer));
308 MOCK_METHOD1(remove_peer, bool(cuc::Peer));
309 MOCK_METHOD1(peer_is_legacy, bool(QString));
310+ MOCK_METHOD2(enumerate_types_for_app_id, void(const QString&, const std::function<void(const QString&)>&));
311 };
312 }
313

Subscribers

People subscribed via source and target branches