1 /*
2    Project: MPDCon
3 
4    Copyright (C) 2004
5 
6    Author: Daniel Luederwald
7 
8    Created: 2004-05-14 11:37:03 +0200 by flip
9 
10    MPD Controller
11 
12    This application is free software; you can redistribute it and/or
13    modify it under the terms of the GNU General Public
14    License as published by the Free Software Foundation; either
15    version 2 of the License, or (at your option) any later version.
16 
17    This application is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20    Library General Public License for more details.
21 
22    You should have received a copy of the GNU General Public
23    License along with this library; if not, write to the Free
24    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
25 */
26 
27 #ifndef _PCAPPPROJ_MPDCONTROLLER_H_
28 #define _PCAPPPROJ_MPDCONTROLLER_H_
29 
30 #include <Foundation/Foundation.h>
31 #include <mpd/client.h>
32 #include "PlaylistItem.h"
33 #include "StatisticsItem.h"
34 #include "Strings.h"
35 
36 #define state_NOCONN -1
37 #define state_UNKNOWN 0
38 #define state_STOP 1
39 #define state_PLAY 2
40 #define state_PAUSE 3
41 
42 @interface MPDController : NSObject
43 {
44   struct mpd_connection *mpdConnection;
45 
46   NSString *host;
47   NSString *port;
48   NSString *password;
49   NSString *timeout;
50 
51   long long currPlaylist;
52   unsigned int currPlaylistVersion;
53   // those two are used to check whether the collection changed
54   unsigned int numArtists;
55   unsigned int numAlbums;
56 }
57 
58 // Initialization Methods
59 + (id) sharedMPDController;
60 
61 // Connection Methods
62 - (BOOL) connectToServer: (NSString *)hostName
63                     port: (NSString *)port
64                 password: (NSString *)pword
65 		 timeout: (NSString *)tout;
66 
67 // Play Methods
68 - (void) play;
69 - (void) playSong: (int)song;
70 - (void) stop;
71 - (void) prev;
72 - (void) next;
73 - (void) toggleShuffle;
74 - (void) toggleRepeat;
75 
76 - (void) seekToTime: (int)time;
77 - (void) setVolume: (int)volume;
78 - (void) setCrossfade: (int)cfTime;
79 
80 // Information Methods
81 - (int) getState;
82 
83 - (BOOL) isRandom;
84 - (BOOL) isRepeat;
85 
86 - (int) getVolume;
87 - (int) getCrossfade;
88 
89 - (StatisticsItem *) getStatistics;
90 
91 // Playlist Commands
92 - (PlaylistItem *) getCurrentSong;
93 - (int) getCurrentSongNr;
94 
95 - (int) getPlaylistLength;
96 - (NSArray *) getPlaylist;
97 
98 - (BOOL) playlistChanged;
99 - (void) shuffleList;
100 - (void) clearPlaylist;
101 
102 - (void) removeSong: (int)song;
103 - (void) removeSongRange: (NSRange)songRange;
104 - (void) addTrack: (NSString *)file;
105 - (void) moveSongNr: (int)song1 to: (int)song2;
106 - (void) moveSongWithID: (int)song1 to: (int)song2;
107 
108 - (NSArray *) getAllPlaylists;
109 
110 - (void) loadPlaylist: (NSString *)title;
111 - (void) savePlaylist: (NSString *)title;
112 - (void) removePlaylist: (NSString *)title;
113 
114 // Collection Commands
115 - (BOOL) collectionChanged;
116 - (NSArray *) getAllArtists;
117 - (NSArray *) getAllAlbums;
118 - (NSArray *) getAllTracksWithMetadata: (BOOL) withMetadata;
119 
120 - (NSArray *) getAlbumsForArtist: (NSString *)artist;
121 - (NSArray *) getAllTracksForArtist: (NSString *)artist;
122 - (NSArray *) getAllTracksForArtist: (NSString *)artist
123                               album: (NSString *)album;
124 
125 - (NSArray *) getAllTracksForAlbum: (NSString *)album;
126 -(NSArray *) getAllFilesInDirectory: (NSString *) directory;
127 
128 - (void) updateCollection;
129 
130 - (NSArray *) getAllDirectories;
131 
132 
133 @end
134 #endif
135 
136