Added license information
[someplayer] / src / library.h
1 /*
2  * SomePlayer - An alternate music player for Maemo 5
3  * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #ifndef LIBRARY
21 #define LIBRARY
22
23 #include "someplayer.h"
24 #include "track.h"
25 #include "playlist.h"
26 #include "dbstorage.h"
27 #include "filestorage.h"
28 #include "mediascanner.h"
29 #include "tagresolver.h"
30
31 #define _DATABASE_PATH_ "/tmp"
32 #define _PLAYLISTS_PATH_ "/tmp"
33
34 // represents media library: tracks, playlists
35 // it uses different media storages for tracks and playlists
36 // but dynamic playlits will be stored with tracks into the same storage
37
38 using SomePlayer::DataObjects::Track;
39 using SomePlayer::DataObjects::Playlist;
40 using SomePlayer::Storage::DbStorage;
41 using SomePlayer::Storage::FileStorage;
42 using SomePlayer::Storage::MediaScanner;
43
44 namespace SomePlayer {
45         namespace DataObjects {
46
47                 class Library : public QObject {
48                         Q_OBJECT
49                 public:
50                         Library(QString databasePath, QString playlistsPath);
51                         ~Library();
52
53                         void addDirectory(QString path);
54                         void addFile(QString path);
55
56                         QList<QString> getArtists();
57                         QList<QString> getAlbumsForArtist(QString artist);
58                         QList<Track> getTracksForAlbum(QString album, QString artist);
59
60                         Playlist getFavorites();
61                         Playlist getMostPlayed();
62                         Playlist getNeverPlayed();
63                         Playlist getRecentlyAdded();
64
65                         QList<Playlist> getPlaylists();
66                         QStringList getPlaylistsNames();
67                         Playlist getPlaylist(QString name);
68                         void savePlaylist(const Playlist &playlist);
69                         void removePlaylist(const Playlist &playlist);
70                         void removePlaylist(QString name);
71
72                         Playlist getCurrentPlaylist();
73                         void saveCurrentPlaylist(const Playlist &playlist);
74
75                 signals:
76                         void done();
77                         void busy(QString);
78
79                 private:
80                         DbStorage *_library_storage;
81                         FileStorage *_playlist_storage;
82                         MediaScanner *_scanner;
83                         TagResolver *_resolver;
84
85                 public slots:
86                         void removeTrack(Track);
87                         void addTrack(Track);
88                         void addToFavorites(Track);
89                         void updateTrackCount(Track);
90                 };
91
92         };
93 };
94
95 #endif