Music Hub ..
A session-wide music playback service
Loading...
Searching...
No Matches
metadata.cpp
Go to the documentation of this file.
1/*
2 * Copyright © 2016 Canonical Ltd.
3 * Copyright © 2022 UBports Foundation.
4 *
5 * Contact: Alberto Mardegan <mardy@users.sourceforge.net>
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License version 3,
9 * as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Authored by: Jim Hodapp <jim.hodapp@canonical.com>
20 */
21
22#include "xesam.h"
23
24#include "track.h"
25
26#include <glib.h>
27
29
30std::string media::Track::MetaData::encode(const std::string& key) const
31{
32 if (not is_set(key))
33 return std::string{};
34
35 char* escaped {g_uri_escape_string(map.at(key).c_str(),
36 "!$&'()*+,;=:/?[]@", // Reserved chars
37 true)};
38 if (!escaped)
39 {
40 return std::string{};
41 }
42 else
43 {
44 std::string s{escaped};
45 g_free(escaped);
46 return s;
47 }
48}
49
50const std::string& media::Track::MetaData::album() const
51{
52 return map.at(xesam::Album::name);
53}
54
55const std::string& media::Track::MetaData::artist() const
56{
57 return map.at(xesam::Artist::name);
58}
59
60const std::string& media::Track::MetaData::title() const
61{
62 return map.at(xesam::Title::name);
63}
64
65const std::string& media::Track::MetaData::track_id() const
66{
68}
69
70const std::string& media::Track::MetaData::track_length() const
71{
73}
74
75const std::string& media::Track::MetaData::art_url() const
76{
78}
79
80const std::string& media::Track::MetaData::last_used() const
81{
82 return map.at(xesam::LastUsed::name);
83}
84
85void media::Track::MetaData::set_album(const std::string& album)
86{
87 map[xesam::Album::name] = album;
88}
89
90void media::Track::MetaData::set_artist(const std::string& artist)
91{
92 map[xesam::Artist::name] = artist;
93}
94
95void media::Track::MetaData::set_title(const std::string& title)
96{
97 map[xesam::Title::name] = title;
98}
99
100void media::Track::MetaData::set_track_id(const std::string& id)
101{
103}
104
105void media::Track::MetaData::set_track_length(const std::string& length)
106{
108}
109
110void media::Track::MetaData::set_art_url(const std::string& url)
111{
113}
114
115void media::Track::MetaData::set_last_used(const std::string& datetime)
116{
117 map[xesam::LastUsed::name] = datetime;
118}
static constexpr const char * TrackLengthKey
Definition track.h:42
static constexpr const char * TrackIdKey
Definition track.h:43
static constexpr const char * TrackArtlUrlKey
Definition track.h:41