1
/*
2
 *  Copyright (c) 2007 Jamie Faris <farisj@gmail.com>
3
 *
4
 *  This program is free software; you can redistribute it and/or modify
5
 *  it under the terms of the GNU General Public License as published by
6
 *  the Free Software Foundation; either version 2 of the License, or
7
 *  (at your option) any later version.
8
 *
9
 *  This program is distributed in the hope that it will be useful,
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 *  GNU General Public License for more details.
13
 *
14
 *  You should have received a copy of the GNU General Public License
15
 *  along with this program; if not, write to the Free Software
16
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
 */
18
19
/*
20
 * MediaDeviceMeta.h
21
 *
22
 * This file contains definitions of Meta classes used by media device plugins.
23
 *
24
 */
25
26
27
#ifndef MEDIADEVICEMETA_H
28
#define MEDIADEVICEMETA_H
29
30
// Amarok
31
#include "Meta.h"
32
33
class MediaDevice;
34
35
class MediaDeviceAlbum : public Meta::Album
36
{
37
    public:
38
        MediaDeviceAlbum( QString name )
39
            : m_name( name ),
40
              m_isCompilation( false )
41
        {
42
        }
43
44
        virtual ~MediaDeviceAlbum() {}
45
46
        // from Meta::MetaBase
47
        QString name() const { return m_name; }
48
        QString prettyName() const { return name(); }
49
50
        // from Meta::Album
51
        bool isCompilation() const { return m_isCompilation; }
52
        void setCompilation( bool isCompilation ) { m_isCompilation = isCompilation; }
53
        bool hasAlbumArtist() const { return false; }
54
        Meta::ArtistPtr albumArtist() const { return Meta::ArtistPtr(); }
55
        Meta::TrackList tracks() { return Meta::TrackList(); }
56
57
    private:
58
        QString m_name;
59
        bool m_isCompilation;
60
};
61
62
63
class MediaDeviceGenre : public Meta::Genre
64
{
65
    public:
66
        MediaDeviceGenre( QString name )
67
            : m_name( name )
68
        {
69
        }
70
71
        virtual ~MediaDeviceGenre() {}
72
73
        // from Meta::MetaBase
74
        QString name() const { return m_name; }
75
        QString prettyName() const { return name(); }
76
77
        // from Meta::Genre
78
        Meta::TrackList tracks() { return Meta::TrackList(); }
79
80
    private:
81
        QString m_name;
82
};
83
84
85
/**
86
 * A simple implementation of Meta::Artist for media devices.
87
 * This implementation holds it's values in member variables where
88
 * they can be set by the device plugin.
89
 *
90
 * Device plugins can extend this class to fetch the data directly
91
 * from the device or to allow editing the tags.
92
 */
93
class MediaDeviceArtist : public Meta::Artist
94
{
95
    public:
96
        MediaDeviceArtist( QString name )
97
            : m_name( name )
98
        {
99
        }
100
101
        virtual ~MediaDeviceArtist() {}
102
103
        //from Meta::MetaBase
104
        QString name() const { return m_name; }
105
        QString prettyName() const { return name(); }
106
107
        //from Meta::Artist
108
        Meta::TrackList tracks() { return Meta::TrackList(); }
109
        Meta::AlbumList albums() { return Meta::AlbumList(); }
110
111
    private:
112
        QString m_name;
113
};
114
115
116
/**
117
 * A simple implementation of Meta::Track for media devices.
118
 * This implementation holds it's values in member variables where
119
 * they can be set by the device plugin.
120
 *
121
 * Device plugins can extend this class to fetch the data directly
122
 * from the device and/or allow editing of the tags.
123
 */
124
class MediaDeviceTrack : public Meta::Track
125
{
126
    public:
127
        MediaDeviceTrack( MediaDevice *device, QString title )
128
            : m_device( device ),
129
              m_name( title ),
130
              m_comment( QString() ),
131
              m_score( 0.0 ),
132
              m_rating( 0 ),
133
              m_length( 0 ),
134
              m_filesize( 0 ),
135
              m_samplerate( 0 ),
136
              m_bitrate( 0 ),
137
              m_trackNumber( 0 ),
138
              m_discNumber( 0 ),
139
              m_lastPlayed( 0 ),
140
              m_firstPlayed( 0 ),
141
              m_playCount( 0 ),
142
              m_type( QString() )
143
        {
144
        }
145
146
        virtual ~MediaDeviceTrack() {}
147
148
        //from Meta::MetaBase
149
        virtual QString name() const { return m_name; }
150
        virtual QString prettyName() const { return name(); }
151
152
        //from Meta::Track
153
        virtual KUrl playableUrl() const { return KUrl(); }
154
        virtual QString prettyUrl() const { return QString(); }
155
        virtual QString url() const { return QString(); }
156
        virtual bool isPlayable() const { return false; }
157
        virtual Meta::AlbumPtr album() const { return Meta::AlbumPtr(); }
158
        virtual Meta::ArtistPtr artist() const { return Meta::ArtistPtr(); }
159
        virtual Meta::ComposerPtr composer() const { return Meta::ComposerPtr(); }
160
        virtual Meta::GenrePtr genre() const { return Meta::GenrePtr(); }
161
        virtual Meta::YearPtr year() const { return Meta::YearPtr(); }
162
        virtual QString comment() const { return m_comment; }
163
        virtual void setComment( QString comment ) { m_comment = comment; }
164
        virtual double score() const { return 0; }
165
        virtual void setScore( double score ) { m_score = score; }
166
        virtual int rating() const { return 0; }
167
        virtual void setRating( int rating ) { m_rating = rating; }
168
        virtual int length() const { return 0; }
169
        virtual void setLength( int length ) { m_length = length; }
170
        virtual int filesize() const { return 0; }
171
        virtual void setFileSize( int size ) { m_filesize = size; }
172
        virtual int sampleRate() const { return 0; }
173
        virtual void setSampleRate( int rate ) { m_samplerate = rate; }
174
        virtual int bitrate() const { return 0; }
175
        virtual void setBitrate( int rate ) { m_bitrate = rate; }
176
        virtual int trackNumber() const { return 0; }
177
        virtual void setTrackNumber( int number ) { m_trackNumber = number; }
178
        virtual int discNumber() const { return 0; }
179
        virtual void setDiscNumber( int number ) { m_discNumber = number; }
180
        virtual uint lastPlayed() const { return 0; }
181
        virtual void setLastPlayed( uint last ) { m_lastPlayed = last; }
182
        virtual uint firstPlayed() const { return 0; }
183
        virtual void setFirstPlayed( uint first ) { m_firstPlayed = first; }
184
        virtual int playCount() const { return 0; }
185
        virtual void setPlayCount( int count ) { m_playCount = count; }
186
        virtual QString type() const { return m_type; }
187
        virtual void setType( QString type ) { m_type = type; }
188
189
190
    private:
191
        MediaDevice *m_device;
192
        QString m_name;
193
        QString m_comment;
194
        double m_score;
195
        int m_rating;
196
        int m_length;
197
        int m_filesize;
198
        int m_samplerate;
199
        int m_bitrate;
200
        int m_trackNumber;
201
        int m_discNumber;
202
        uint m_lastPlayed;
203
        uint m_firstPlayed;
204
        int m_playCount;
205
        QString m_type;
206
};
207
208
209
#endif //MEDIADEVICEMETA_H