~jamesh/mediascanner/qml-plugin

« back to all changes in this revision

Viewing changes to src/mediascanner/MediaFile.cc

  • Committer: Tarmac
  • Author(s): Jussi Pakkanen
  • Date: 2013-12-02 16:20:17 UTC
  • mfrom: (186.2.12 mediascanner)
  • Revision ID: tarmac-20131202162017-tjcflnrvqvx489qp
Made MediaFile immutable.

Approved by James Henstridge, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
18
 */
19
19
 
20
 
#include <stdexcept>
21
 
#include <glib.h>
22
20
#include "MediaFile.hh"
 
21
#include "utils.hh"
23
22
 
24
23
using namespace std;
25
24
 
73
72
    return type;
74
73
}
75
74
 
76
 
void MediaFile::setContentType(const std::string &content_type) noexcept {
77
 
    this->content_type = content_type;
78
 
}
79
 
 
80
 
void MediaFile::setETag(const std::string &etag) noexcept {
81
 
    this->etag = etag;
82
 
}
83
 
 
84
 
void MediaFile::setTitle(const std::string &title) noexcept {
85
 
    this->title = title;
86
 
}
87
 
 
88
 
void MediaFile::setAuthor(const std::string &author) noexcept {
89
 
    this->author = author;
90
 
}
91
 
 
92
 
void MediaFile::setAlbum(const std::string &album) noexcept {
93
 
    this->album = album;
94
 
}
95
 
 
96
 
void MediaFile::setAlbumArtist(const std::string &album_artist) noexcept {
97
 
    this->album_artist = album_artist;
98
 
}
99
 
 
100
 
void MediaFile::setDate(const std::string &date) noexcept {
101
 
    this->date = date;
102
 
}
103
 
 
104
 
void MediaFile::setTrackNumber(int track_number) noexcept {
105
 
    this->track_number = track_number;
106
 
}
107
 
 
108
 
void MediaFile::setDuration(int duration) noexcept {
109
 
    this->duration = duration;
110
 
}
111
 
 
112
 
void MediaFile::setType(MediaType type) noexcept {
113
 
    this->type = type;
 
75
std::string MediaFile::getUri() const {
 
76
    return ::getUri(filename);
114
77
}
115
78
 
116
79
bool MediaFile::operator==(const MediaFile &other) const {
132
95
    return !(*this == other);
133
96
}
134
97
 
135
 
std::string MediaFile::getUri() const {
136
 
    GError *error = NULL;
137
 
    char *uristr = g_filename_to_uri(filename.c_str(), "", &error);
138
 
    if (error) {
139
 
        string msg("Could not build URI: ");
140
 
        msg += error->message;
141
 
        g_error_free(error);
142
 
        throw runtime_error(msg);
143
 
    }
144
 
    string uri(uristr);
145
 
    g_free(uristr);
146
 
    return uri;
147
 
}