Version bump
[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 // represents media library: tracks, playlists
32 // it uses different media storages for tracks and playlists
33 // but dynamic playlits will be stored with tracks into the same storage
34
35 using SomePlayer::DataObjects::Track;
36 using SomePlayer::DataObjects::Playlist;
37 using SomePlayer::Storage::DbStorage;
38 using SomePlayer::Storage::FileStorage;
39 using SomePlayer::Storage::MediaScanner;
40
41 namespace SomePlayer {
42         namespace DataObjects {
43
44                 class Library : public QObject {
45                         Q_OBJECT
46                 public:
47                         Library(QString databasePath, QString playlistsPath);
48                         ~Library();
49
50                         void addDirectory(QString path, bool async = true);
51                         void addFile(QString path);
52
53                         QList<QString> getDirectories();
54                         QList<QString> getArtists();
55                         QMap<QString, int> getAlbumsForArtist(QString artist);
56                         QList<Track> getTracksForAlbum(QString album, QString artist);
57                         QList<Track> getAllTracksForArtist(QString artist);
58
59                         QList<Track> searchTracks(QString pattern);
60
61                         Playlist getFavorites();
62                         Playlist getMostPlayed();
63                         Playlist getNeverPlayed();
64                         Playlist getRecentlyAdded();
65
66                         int getArtistsCount();
67                         int getAlbumsCount();
68                         int getTracksCount();
69
70                         QList<Playlist> getPlaylists();
71                         QStringList getPlaylistsNames();
72                         Playlist getPlaylist(QString name);
73                         void savePlaylist(const Playlist &playlist);
74                         void removePlaylist(const Playlist &playlist);
75                         void removePlaylist(QString name);
76                         void importPlaylist(QString name);
77                         void importPlaylists(QStringList files);
78                         void scanAndImportPlaylists(QString dirpath);
79
80                         Playlist getCurrentPlaylist();
81                         void saveCurrentPlaylist(const Playlist &playlist);
82                         LastPlayed getLastPlayedForCurPlaylist();
83
84                         void updateDirectories(QList<QString> directories);
85                         void updateAll();
86                         void deleteDirectories(QList<QString> directories);
87
88                         bool isFavorite(Track);
89
90                 signals:
91                         void started();
92                         void done();
93                         void busy(QString);
94                         void allCount(int);
95                         void tick();
96
97                 private:
98                         DbStorage *_library_storage;
99                         FileStorage *_playlist_storage;
100                         MediaScanner *_scanner;
101                         TagResolver *_resolver;
102
103                 private slots:
104                         void _scanned(QStringList);
105                         void _decoded(Track);
106
107                 public slots:
108                         void removeTrack(Track);
109                         void addTrack(Track);
110                         void addToFavorites(Track);
111                         void removeFromFavorites(Track);
112                         void updateTrackCount(Track);
113                         void updateTrackMetadata(Track);
114                         void updatePlaylists();
115                         void saveLastPlayedForCurPlaylist(LastPlayed);
116                 };
117
118         };
119 };
120
121 #endif