1 |
douglas |
542 |
// Library |
2 |
|
|
// |
3 |
|
|
// Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// $Id$ |
6 |
|
|
|
7 |
|
|
#include <menes/standard.hh> |
8 |
|
|
|
9 |
douglas |
549 |
#include <menes/dbi/resultset.hpp> |
10 |
douglas |
542 |
|
11 |
|
|
#include "Library.hpp" |
12 |
|
|
|
13 |
|
|
Library::Library(const _R<dbi::Connection>& connection) : connection(connection) |
14 |
|
|
{ |
15 |
|
|
connection->Execute(_B("UPDATE files SET live = FALSE")); |
16 |
|
|
} |
17 |
|
|
|
18 |
|
|
_L<cse::String> Library::GetArtists() const |
19 |
|
|
{ |
20 |
douglas |
550 |
_R<dbi::ResultSet> artists_(connection->Execute(_B("SELECT DISTINCT artist FROM files WHERE live = TRUE ORDER BY artist"))); |
21 |
douglas |
542 |
_L<cse::String> artists; |
22 |
|
|
|
23 |
|
|
while (artists_->MoveNext()) |
24 |
|
|
artists.InsertLast(artists_->GetString(_B("artist"))); |
25 |
|
|
|
26 |
|
|
return artists; |
27 |
|
|
} |
28 |
|
|
|
29 |
|
|
_L<cse::String> Library::GetTitles() const |
30 |
|
|
{ |
31 |
douglas |
550 |
_R<dbi::ResultSet> titles_(connection->Execute(_B("SELECT DISTINCT title FROM files WHERE live = TRUE ORDER BY title"))); |
32 |
douglas |
542 |
_L<cse::String> titles; |
33 |
|
|
|
34 |
|
|
while (titles_->MoveNext()) |
35 |
|
|
titles.InsertLast(titles_->GetString(_B("title"))); |
36 |
|
|
|
37 |
|
|
return titles; |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
_L<cse::String> Library::GetAlbums() const |
41 |
|
|
{ |
42 |
douglas |
550 |
_R<dbi::ResultSet> albums_(connection->Execute(_B("SELECT DISTINCT album FROM files WHERE live = TRUE ORDER BY album"))); |
43 |
douglas |
542 |
_L<cse::String> albums; |
44 |
|
|
|
45 |
|
|
while (albums_->MoveNext()) |
46 |
|
|
albums.InsertLast(albums_->GetString(_B("album"))); |
47 |
|
|
|
48 |
|
|
return albums; |
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
_L<cse::String> Library::GetGenres() const |
52 |
|
|
{ |
53 |
douglas |
550 |
_R<dbi::ResultSet> genres_(connection->Execute(_B("SELECT DISTINCT genre FROM files WHERE live = TRUE ORDER BY genre"))); |
54 |
douglas |
542 |
_L<cse::String> genres; |
55 |
|
|
|
56 |
|
|
while (genres_->MoveNext()) |
57 |
|
|
genres.InsertLast(genres_->GetString(_B("genre"))); |
58 |
|
|
|
59 |
|
|
return genres; |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
_L<MediaFolder> Library::GetFolders() const |
63 |
|
|
{ |
64 |
douglas |
550 |
_R<dbi::ResultSet> roots(connection->Execute(_B("SELECT DISTINCT root FROM files WHERE live = TRUE ORDER By root"))); |
65 |
douglas |
542 |
_L<MediaFolder> folders; |
66 |
|
|
|
67 |
douglas |
546 |
while (roots->MoveNext()) |
68 |
|
|
folders.InsertLast(MediaFolder(connection, roots->GetString(_B("root")))); |
69 |
douglas |
542 |
|
70 |
|
|
return folders; |
71 |
|
|
} |