26 #include <core/dbus/types/stl/map.h> 27 #include <core/dbus/types/stl/string.h> 28 #include <core/dbus/types/variant.h> 29 #include <core/dbus/types/stl/vector.h> 30 #include <core/dbus/codec.h> 32 #include <boost/lexical_cast.hpp> 49 return ArgumentType::array;
62 static const std::string s = TypeMapper<std::map<std::string, dbus::types::Variant>>::signature();
73 typedef std::pair<std::string, dbus::types::Variant> Pair;
74 auto dict = writer.open_array(dbus::types::Signature
75 {dbus::helper::TypeMapper<Pair>::signature()});
77 for (
const auto& pair : *md)
80 if (pair.first == tags::Image::name or
81 pair.first == tags::PreviewImage::name)
84 auto de = dict.open_dict_entry();
87 and not pair.second.empty())
89 Codec<Pair>::encode_argument(de, std::make_pair(pair.first,
90 dbus::types::Variant::encode(
91 boost::lexical_cast<std::int64_t>(pair.second))));
93 else if (pair.first == xesam::Album::name and not pair.second.empty())
95 Codec<Pair>::encode_argument(de, std::make_pair(pair.first,
96 dbus::types::Variant::encode(pair.second)));
98 else if (pair.first == xesam::AlbumArtist::name and not pair.second.empty())
104 auto array = de.open_array(dbus::types::Signature
105 {dbus::helper::TypeMapper<Pair>::signature()});
109 Codec<Pair>::encode_argument(array, std::make_pair(pair.first,
110 dbus::types::Variant::encode(pair.second)));
112 de.close_array(std::move(array));
114 Codec<Pair>::encode_argument(de, std::make_pair(pair.first,
115 dbus::types::Variant::encode(pair.second)));
120 Codec<Pair>::encode_argument(de, std::make_pair(pair.first,
121 dbus::types::Variant::encode(pair.second)));
124 dict.close_dict_entry(std::move(de));
126 writer.close_array(std::move(dict));
131 auto array = reader.pop_array();
133 while (array.type() != dbus::ArgumentType::invalid)
135 auto entry = array.pop_dict_entry();
137 std::string key {entry.pop_string()};
138 auto variant = entry.pop_variant();
140 if (key == xesam::Album::name)
142 const std::string album = variant.pop_string();
143 MH_DEBUG(
"Getting key \"%s\" and value \"%s\"", key, album);
148 MH_WARNING(
"Unknown metadata key \"%s\" while decoding dbus message", key);
163 return core::dbus::ArgumentType::int16;
176 static const std::string s = TypeMapper<std::int16_t>::signature();
187 out.push_int16(static_cast<std::int16_t>(in));
203 return core::dbus::ArgumentType::int16;
216 static const std::string s = TypeMapper<std::int16_t>::signature();
228 out.push_int16(static_cast<std::int16_t>(in));
245 return core::dbus::ArgumentType::int16;
258 static const std::string s = TypeMapper<std::int16_t>::signature();
269 out.push_int16(static_cast<std::int16_t>(in));
285 return core::dbus::ArgumentType::int16;
298 static const std::string s = TypeMapper<std::int16_t>::signature();
309 out.push_int16(static_cast<std::int16_t>(in));
325 return core::dbus::ArgumentType::int16;
338 static const std::string s = TypeMapper<std::int16_t>::signature();
349 out.push_int16(static_cast<std::int16_t>(in));
360 template<core::ubuntu::media::v
ideo::detail::DimensionTag tag,
typename IntegerType>
365 return core::dbus::ArgumentType::uint32;
380 static const std::string s = TypeMapper<std::uint32_t>::signature();
390 return core::dbus::ArgumentType::int16;
405 static const std::string s = TypeMapper<std::int16_t>::signature();
411 template<core::ubuntu::media::v
ideo::detail::DimensionTag tag,
typename IntegerType>
416 out.push_uint32(in.template as<std::uint32_t>());
431 out.push_int16(static_cast<std::int16_t>(in));
448 return core::dbus::ArgumentType::int16;
461 static const std::string s = TypeMapper<std::int16_t>::signature();
472 out.push_int16(static_cast<std::int16_t>(in));