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

Proposed by Ken VanDine on 2015-08-28
Status: Merged
Approved by: Michael Sheldon on 2015-09-09
Approved revision: 238
Merged at revision: 245
Proposed branch: lp:~ken-vandine/content-hub/fix_blank_type
Merge into: lp:content-hub
Diff against target: 72 lines (+20/-3)
3 files modified
src/com/ubuntu/content/service/CMakeLists.txt (+1/-0)
src/com/ubuntu/content/service/registry.cpp (+3/-3)
src/com/ubuntu/content/utils.cpp (+16/-0)
To merge this branch: bzr merge lp:~ken-vandine/content-hub/fix_blank_type
Reviewer Review Type Date Requested Status
Michael Sheldon (community) 2015-08-28 Approve on 2015-09-09
PS Jenkins bot continuous-integration Approve on 2015-08-28
Review via email: mp+269511@code.launchpad.net

Commit Message

Fixed crash when the service is passed an invalid type via dbus

Description of the Change

Fixed crash when the service is passed an invalid type via dbus

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

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

 * No

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

 * No

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/com/ubuntu/content/service/CMakeLists.txt'
2--- src/com/ubuntu/content/service/CMakeLists.txt 2014-06-04 16:49:40 +0000
3+++ src/com/ubuntu/content/service/CMakeLists.txt 2015-08-28 14:46:59 +0000
4@@ -33,6 +33,7 @@
5 main.cpp
6 registry.cpp
7 ../debug.cpp
8+ ../utils.cpp
9 ${CONTENT_SERVICE_SKELETON}
10 )
11
12
13=== modified file 'src/com/ubuntu/content/service/registry.cpp'
14--- src/com/ubuntu/content/service/registry.cpp 2015-06-15 18:20:21 +0000
15+++ src/com/ubuntu/content/service/registry.cpp 2015-08-28 14:46:59 +0000
16@@ -138,7 +138,7 @@
17
18 QStringList peers;
19 peers << m_sources->get("all").toStringList();
20- if (type != cuc::Type::unknown())
21+ if (type != cuc::Type::unknown() && valid_type(type))
22 peers << m_sources->get(type.id()).toStringList();
23 Q_FOREACH (QString k, peers)
24 {
25@@ -171,7 +171,7 @@
26
27 QStringList peers;
28 peers << m_dests->get("all").toStringList();
29- if (type != cuc::Type::unknown())
30+ if (type != cuc::Type::unknown() && valid_type(type))
31 peers << m_dests->get(type.id()).toStringList();
32 Q_FOREACH (QString k, peers)
33 {
34@@ -184,7 +184,7 @@
35 {
36 TRACE() << Q_FUNC_INFO << type.id();
37
38- if (type == cuc::Type::unknown())
39+ if (type == cuc::Type::unknown() || !valid_type(type))
40 return;
41
42 Q_FOREACH (QString k, m_shares->get(type.id()).toStringList())
43
44=== modified file 'src/com/ubuntu/content/utils.cpp'
45--- src/com/ubuntu/content/utils.cpp 2015-06-02 12:45:47 +0000
46+++ src/com/ubuntu/content/utils.cpp 2015-08-28 14:46:59 +0000
47@@ -49,9 +49,25 @@
48 types << cuc::Type::Known::music();
49 types << cuc::Type::Known::documents();
50 types << cuc::Type::Known::contacts();
51+ types << cuc::Type::Known::videos();
52+ types << cuc::Type::Known::links();
53+ types << cuc::Type::Known::ebooks();
54+ types << cuc::Type::Known::text();
55+ types << cuc::Type::Known::events();
56 return types;
57 }
58
59+bool valid_type(cuc::Type type)
60+{
61+ Q_FOREACH (cuc::Type t, known_types())
62+ {
63+ TRACE() << Q_FUNC_INFO << t.id();
64+ if (t.id() == type.id())
65+ return true;
66+ }
67+ return false;
68+}
69+
70 /* sanitize the dbus names */
71 QString sanitize_id(const QString& appId)
72 {

Subscribers

People subscribed via source and target branches