Merge lp:~ken-vandine/content-hub/all_content_type into lp:content-hub

Proposed by Ken VanDine on 2015-06-08
Status: Merged
Approved by: Michael Sheldon on 2015-06-15
Approved revision: 217
Merged at revision: 217
Proposed branch: lp:~ken-vandine/content-hub/all_content_type
Merge into: lp:content-hub
Diff against target: 209 lines (+49/-13)
10 files modified
import/Ubuntu/Content/contentpeermodel.cpp (+2/-0)
import/Ubuntu/Content/contenttype.cpp (+1/-1)
include/com/ubuntu/content/type.h (+2/-0)
src/com/ubuntu/content/service/com.ubuntu.content.hub.gschema.xml (+6/-0)
src/com/ubuntu/content/service/hook.cpp (+1/-1)
src/com/ubuntu/content/service/registry.cpp (+13/-9)
src/com/ubuntu/content/type.cpp (+14/-0)
tests/acceptance-tests/CMakeLists.txt (+2/-1)
tests/acceptance-tests/source_all.json (+5/-0)
tests/acceptance-tests/test_hook.cpp (+3/-1)
To merge this branch: bzr merge lp:~ken-vandine/content-hub/all_content_type
Reviewer Review Type Date Requested Status
Michael Sheldon (community) 2015-06-08 Approve on 2015-06-15
PS Jenkins bot continuous-integration Approve on 2015-06-10
Review via email: mp+261432@code.launchpad.net

Commit Message

Added support for registering a source or destination as handlers for Type::all

Description of the Change

Added support for registering a source or destination as handlers for Type::all

Note: This is not exposed to the QML bindings and aren't related to the ContentType::All in the QML bindings. This Type::all only exists for peer registration and ensure the peers registered for Type::all always appear in the peer model.

To post a comment you must log in.
Ken VanDine (ken-vandine) wrote :

Are there any related MPs required for this MP to build/function as expected? Please list.

 * No

Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)

 * Yes

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?

 * Yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/content-hub) on device or emulator?

 * Yes

If you changed the UI, was the change specified/approved by design?

 * No change

If you changed UI labels, did you update the pot file?

 * No change

If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?

 * No change

216. By Ken VanDine on 2015-06-10

Fixed typo

217. By Ken VanDine on 2015-06-10

Moved Type::Known::all to Type::all, it's not a well known type

Michael Sheldon (michael-sheldon) wrote :

Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?

 * Yes

Did CI run pass? If not, please explain why.

 * Yes

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?

 * Yes

review: Approve
218. By Ken VanDine on 2015-06-15

Include ContentType::Unknown in the ContentPeerModel

219. By Ken VanDine on 2015-06-15

Don't ignore unknown types for source and destinations

220. By Ken VanDine on 2015-06-15

Added != operator for cuc::Type and ensure we don't check gsettings for unknown

221. By Ken VanDine on 2015-06-15

Don't look for default sources for unknown types

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'import/Ubuntu/Content/contentpeermodel.cpp'
2--- import/Ubuntu/Content/contentpeermodel.cpp 2014-12-01 13:09:16 +0000
3+++ import/Ubuntu/Content/contentpeermodel.cpp 2015-06-15 18:20:43 +0000
4@@ -103,6 +103,8 @@
5 appendPeersForContentType(ContentType::Videos);
6 appendPeersForContentType(ContentType::Links);
7 appendPeersForContentType(ContentType::EBooks);
8+ appendPeersForContentType(ContentType::Text);
9+ appendPeersForContentType(ContentType::Unknown);
10 } else {
11 appendPeersForContentType(m_contentType);
12 }
13
14=== modified file 'import/Ubuntu/Content/contenttype.cpp'
15--- import/Ubuntu/Content/contenttype.cpp 2015-03-10 19:00:08 +0000
16+++ import/Ubuntu/Content/contenttype.cpp 2015-06-15 18:20:43 +0000
17@@ -31,7 +31,7 @@
18 \li Type
19 \li Description
20 \row
21- \li ContentType.Uknown
22+ \li ContentType.Unknown
23 \li Unknown type
24 \row
25 \li ContentType.Documents
26
27=== modified file 'include/com/ubuntu/content/type.h'
28--- include/com/ubuntu/content/type.h 2015-03-10 19:00:08 +0000
29+++ include/com/ubuntu/content/type.h 2015-06-15 18:20:43 +0000
30@@ -39,6 +39,7 @@
31 public:
32
33 static const Type& unknown();
34+ static const Type& all();
35
36 struct Known
37 {
38@@ -57,6 +58,7 @@
39
40 Type& operator=(const Type&);
41 bool operator==(const Type&) const;
42+ bool operator!=(const Type&) const;
43 bool operator<(const Type&) const;
44
45 Q_INVOKABLE virtual const QString& id() const;
46
47=== modified file 'src/com/ubuntu/content/service/com.ubuntu.content.hub.gschema.xml'
48--- src/com/ubuntu/content/service/com.ubuntu.content.hub.gschema.xml 2015-03-10 19:00:08 +0000
49+++ src/com/ubuntu/content/service/com.ubuntu.content.hub.gschema.xml 2015-06-15 18:20:43 +0000
50@@ -27,6 +27,9 @@
51 </key>
52 </schema>
53 <schema id="com.ubuntu.content.hub.source" path="/com/ubuntu/content/hub/source/">
54+ <key name="all" type="as">
55+ <default>[]</default>
56+ </key>
57 <key name="pictures" type="as">
58 <default>[]</default>
59 </key>
60@@ -53,6 +56,9 @@
61 </key>
62 </schema>
63 <schema id="com.ubuntu.content.hub.destination" path="/com/ubuntu/content/hub/destination/">
64+ <key name="all" type="as">
65+ <default>[]</default>
66+ </key>
67 <key name="pictures" type="as">
68 <default>[]</default>
69 </key>
70
71=== modified file 'src/com/ubuntu/content/service/hook.cpp'
72--- src/com/ubuntu/content/service/hook.cpp 2015-03-10 19:00:08 +0000
73+++ src/com/ubuntu/content/service/hook.cpp 2015-06-15 18:20:43 +0000
74@@ -126,7 +126,7 @@
75 TRACE() << Q_FUNC_INFO << "Hook:" << result.filePath();
76
77 QStringList knownTypes;
78- knownTypes << "pictures" << "music" << "contacts" << "documents" << "videos" << "links" << "ebooks" << "text";
79+ knownTypes << "all" << "pictures" << "music" << "contacts" << "documents" << "videos" << "links" << "ebooks" << "text";
80 QString app_id = result.fileName();
81 auto peer = cuc::Peer(app_id);
82
83
84=== modified file 'src/com/ubuntu/content/service/registry.cpp'
85--- src/com/ubuntu/content/service/registry.cpp 2014-06-04 16:49:40 +0000
86+++ src/com/ubuntu/content/service/registry.cpp 2015-06-15 18:20:43 +0000
87@@ -136,14 +136,17 @@
88 {
89 TRACE() << Q_FUNC_INFO << type.id();
90
91- if (type == cuc::Type::unknown())
92- return;
93-
94- Q_FOREACH (QString k, m_sources->get(type.id()).toStringList())
95+ QStringList peers;
96+ peers << m_sources->get("all").toStringList();
97+ if (type != cuc::Type::unknown())
98+ peers << m_sources->get(type.id()).toStringList();
99+ Q_FOREACH (QString k, peers)
100 {
101 TRACE() << Q_FUNC_INFO << k;
102 bool defaultPeer = false;
103- QVariant peer_v = m_defaultSources->get(type.id());
104+ QVariant peer_v;
105+ if (type != cuc::Type::unknown())
106+ peer_v = m_defaultSources->get(type.id());
107 if (peer_v.type() == QVariant::StringList)
108 {
109 QStringList as(peer_v.toStringList());
110@@ -166,10 +169,11 @@
111 {
112 TRACE() << Q_FUNC_INFO << type.id();
113
114- if (type == cuc::Type::unknown())
115- return;
116-
117- Q_FOREACH (QString k, m_dests->get(type.id()).toStringList())
118+ QStringList peers;
119+ peers << m_dests->get("all").toStringList();
120+ if (type != cuc::Type::unknown())
121+ peers << m_dests->get(type.id()).toStringList();
122+ Q_FOREACH (QString k, peers)
123 {
124 TRACE() << Q_FUNC_INFO << k;
125 for_each(cuc::Peer{k});
126
127=== modified file 'src/com/ubuntu/content/type.cpp'
128--- src/com/ubuntu/content/type.cpp 2015-03-10 19:00:08 +0000
129+++ src/com/ubuntu/content/type.cpp 2015-06-15 18:20:43 +0000
130@@ -53,6 +53,14 @@
131 return d->id == rhs.d->id;
132 }
133
134+bool cuc::Type::operator!=(const cuc::Type& rhs) const
135+{
136+ if (d == rhs.d)
137+ return false;
138+
139+ return d->id != rhs.d->id;
140+}
141+
142 bool cuc::Type::operator<(const cuc::Type& rhs) const
143 {
144 return d->id < rhs.d->id;
145@@ -69,6 +77,12 @@
146 return t;
147 }
148
149+const cuc::Type& cuc::Type::all()
150+{
151+ static cuc::Type t("all", nullptr);
152+ return t;
153+}
154+
155 const cuc::Type& cuc::Type::Known::documents()
156 {
157 static cuc::Type t("documents", nullptr);
158
159=== modified file 'tests/acceptance-tests/CMakeLists.txt'
160--- tests/acceptance-tests/CMakeLists.txt 2014-02-25 15:35:43 +0000
161+++ tests/acceptance-tests/CMakeLists.txt 2015-06-15 18:20:43 +0000
162@@ -60,6 +60,7 @@
163 ${CMAKE_SOURCE_DIR}/src/com/ubuntu/content/service/registry.cpp
164 good.json
165 bad.json
166+ source_all.json
167 )
168
169 qt5_use_modules(app_hub_communication_default_source Core Gui DBus Test)
170@@ -93,7 +94,7 @@
171 AUTOMOC TRUE
172 )
173
174-file(COPY good.json bad.json DESTINATION .)
175+file(COPY good.json bad.json source_all.json DESTINATION .)
176
177 add_custom_command(
178 OUTPUT transfer_files
179
180=== added file 'tests/acceptance-tests/source_all.json'
181--- tests/acceptance-tests/source_all.json 1970-01-01 00:00:00 +0000
182+++ tests/acceptance-tests/source_all.json 2015-06-15 18:20:43 +0000
183@@ -0,0 +1,5 @@
184+{
185+ "source": [
186+ "all"
187+ ]
188+}
189
190=== modified file 'tests/acceptance-tests/test_hook.cpp'
191--- tests/acceptance-tests/test_hook.cpp 2014-02-21 02:30:11 +0000
192+++ tests/acceptance-tests/test_hook.cpp 2015-06-15 18:20:43 +0000
193@@ -65,7 +65,7 @@
194
195 auto mock = new MockedRegistry{};
196 EXPECT_CALL(*mock, install_source_for_type(_,_)).
197- Times(Exactly(2)).
198+ Times(Exactly(3)).
199 WillRepeatedly(Return(true));
200
201 QFileInfo f("good.json");
202@@ -74,5 +74,7 @@
203 EXPECT_TRUE(hook->add_peer(f));
204 f.setFile("bad.json");
205 EXPECT_FALSE(hook->add_peer(f));
206+ f.setFile("source_all.json");
207+ EXPECT_TRUE(hook->add_peer(f));
208 delete mock;
209 }

Subscribers

People subscribed via source and target branches