Merge lp:~thomas-voss/dbus-cpp/fix-1524131 into lp:dbus-cpp/15.04

Proposed by Thomas Voß
Status: Merged
Approved by: Alberto Aguirre
Approved revision: 108
Merged at revision: 106
Proposed branch: lp:~thomas-voss/dbus-cpp/fix-1524131
Merge into: lp:dbus-cpp/15.04
Diff against target: 110 lines (+44/-8)
6 files modified
debian/libdbus-cpp4.symbols.32bit (+1/-0)
debian/libdbus-cpp4.symbols.64bit (+1/-0)
include/core/dbus/message.h (+2/-0)
src/core/dbus/match_rule.cpp (+1/-8)
src/core/dbus/message.cpp (+19/-0)
tests/message_test.cpp (+20/-0)
To merge this branch: bzr merge lp:~thomas-voss/dbus-cpp/fix-1524131
Reviewer Review Type Date Requested Status
Alberto Aguirre (community) Approve
Review via email: mp+282672@code.launchpad.net

Commit message

Add a proper operator<< for dbus::Message::Type.

Description of the change

Add a proper operator<< for dbus::Message::Type.

To post a comment you must log in.
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

LGTM.

review: Approve
lp:~thomas-voss/dbus-cpp/fix-1524131 updated
108. By Thomas Voß

Adjust symbols files to account for newly added symbol.

Revision history for this message
Alberto Aguirre (albaguirre) wrote :

Tested video playback as described in https://bugs.launchpad.net/ubuntu/+source/mediaplayer-app/+bug/1524131/comments/2

No more crashes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/libdbus-cpp4.symbols.32bit'
2--- debian/libdbus-cpp4.symbols.32bit 2015-05-05 08:24:50 +0000
3+++ debian/libdbus-cpp4.symbols.32bit 2016-01-14 21:37:26 +0000
4@@ -1,3 +1,4 @@
5+ (c++)"core::dbus::operator<<(std::basic_ostream<char, std::char_traits<char> >&, core::dbus::Message::Type)@Base" 0replaceme
6 (c++)"core::dbus::Fixture::system_bus_address()@Base" 4.3.0+15.04.20150505
7 (c++)"core::dbus::Fixture::session_bus_address()@Base" 4.3.0+15.04.20150505
8 (c++)"core::dbus::Fixture::default_daemon_timeout()@Base" 4.0.0+14.10.20140730
9
10=== modified file 'debian/libdbus-cpp4.symbols.64bit'
11--- debian/libdbus-cpp4.symbols.64bit 2015-05-05 08:24:50 +0000
12+++ debian/libdbus-cpp4.symbols.64bit 2016-01-14 21:37:26 +0000
13@@ -1,3 +1,4 @@
14+ (c++)"core::dbus::operator<<(std::basic_ostream<char, std::char_traits<char> >&, core::dbus::Message::Type)@Base" 0replaceme
15 (c++)"core::dbus::Fixture::system_bus_address()@Base" 4.3.0+15.04.20150505
16 (c++)"core::dbus::Fixture::session_bus_address()@Base" 4.3.0+15.04.20150505
17 (c++)"core::dbus::Fixture::default_daemon_timeout()@Base" 4.0.0+14.10.20140730
18
19=== modified file 'include/core/dbus/message.h'
20--- include/core/dbus/message.h 2014-01-05 18:58:19 +0000
21+++ include/core/dbus/message.h 2016-01-14 21:37:26 +0000
22@@ -439,6 +439,8 @@
23 };
24 typedef std::shared_ptr<Message> MessagePtr;
25 typedef std::unique_ptr<Message> MessageUPtr;
26+
27+ORG_FREEDESKTOP_DBUS_DLL_PUBLIC std::ostream& operator<<(std::ostream&, Message::Type);
28 }
29 }
30
31
32=== modified file 'src/core/dbus/match_rule.cpp'
33--- src/core/dbus/match_rule.cpp 2014-01-21 13:48:54 +0000
34+++ src/core/dbus/match_rule.cpp 2016-01-14 21:37:26 +0000
35@@ -151,17 +151,10 @@
36
37 std::string dbus::MatchRule::as_string() const
38 {
39- static const std::map<Message::Type, std::string> lut =
40- {
41- {Message::Type::signal, "signal"},
42- {Message::Type::method_call, "method_call"},
43- {Message::Type::method_return, "method_return"},
44- {Message::Type::error, "error"}
45- };
46 Comma comma;
47 std::stringstream ss;
48 if (d->type != Message::Type::invalid)
49- ss << "type='" << lut.at(d->type) << "'" << comma;
50+ ss << "type='" << d->type << "'" << comma;
51 if (!d->sender.empty())
52 ss << comma << "sender='" << d->sender << "'" << comma;
53 if (!d->interface.empty())
54
55=== modified file 'src/core/dbus/message.cpp'
56--- src/core/dbus/message.cpp 2015-07-21 18:30:23 +0000
57+++ src/core/dbus/message.cpp 2016-01-14 21:37:26 +0000
58@@ -652,5 +652,24 @@
59 {
60 return std::shared_ptr<Message>(new Message(d->clone()));
61 }
62+
63+std::ostream& operator<<(std::ostream& out, Message::Type type)
64+{
65+ switch (type)
66+ {
67+ case Message::Type::error:
68+ return out << "error";
69+ case Message::Type::invalid:
70+ return out << "invalid";
71+ case Message::Type::method_call:
72+ return out << "method_call";
73+ case Message::Type::method_return:
74+ return out << "method_return";
75+ case Message::Type::signal:
76+ return out << "signal";
77+ }
78+
79+ return out;
80+}
81 }
82 }
83
84=== modified file 'tests/message_test.cpp'
85--- tests/message_test.cpp 2014-01-10 07:34:59 +0000
86+++ tests/message_test.cpp 2016-01-14 21:37:26 +0000
87@@ -175,3 +175,23 @@
88 }
89 }
90 }
91+
92+namespace
93+{
94+class MessageType : public testing::TestWithParam<std::pair<core::dbus::Message::Type, std::string>>
95+{
96+};
97+}
98+
99+TEST_P(MessageType, IsPrintedCorrectly)
100+{
101+ std::stringstream ss; ss << GetParam().first;
102+ EXPECT_EQ(GetParam().second, ss.str());
103+}
104+
105+INSTANTIATE_TEST_CASE_P(MessageType, MessageType, ::testing::Values(
106+ std::make_pair(core::dbus::Message::Type::error, "error"),
107+ std::make_pair(core::dbus::Message::Type::invalid, "invalid"),
108+ std::make_pair(core::dbus::Message::Type::method_call, "method_call"),
109+ std::make_pair(core::dbus::Message::Type::method_return, "method_return"),
110+ std::make_pair(core::dbus::Message::Type::signal, "signal")));

Subscribers

People subscribed via source and target branches