1 /* libmpd (high level libmpdclient library)
2 * Copyright (C) 2004-2009 Qball Cow <qball@sarine.nl>
3 * Project homepage: http://gmpcwiki.sarine.nl/
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
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.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef __MPD_INTERNAL_LIB_
21 #define __MPD_INTERNAL_LIB_
23 #include "libmpdclient.h"
27 typedef struct _MpdData_real
{
37 mpd_PlaylistFile
*playlist
;
39 mpd_OutputEntity
*output_dev
; /* from devices */
42 void (*freefunc
)(void *userdata
);
44 struct _MpdData_real
*next
;
45 /* Previous MpdData in the list */
46 struct _MpdData_real
*prev
;
47 struct _MpdData_real
*first
;
52 typedef struct _MpdQueue MpdQueue
;
53 typedef struct _MpdServerState
{
54 /* information needed to detect changes on mpd's side */
56 long long storedplaylistid
;
62 unsigned long dbUpdateTime
;
71 unsigned int samplerate
;
74 unsigned long playlistLength
;
82 /* internal use only */
83 typedef struct _MpdCommand
{
90 typedef struct _MpdObj
{
91 /* defines if we are connected */
92 /* This should be made true if and only if the connection is up and running */
94 /* information needed to connect to mpd */
98 float connection_timeout
;
100 /* mpd's structures */
101 mpd_Connection
*connection
;
104 mpd_Song
*CurrentSong
;
106 /* used to store/detect serverside status changes */
107 MpdServerState CurrentState
;
108 MpdServerState OldState
;
110 /* new style signals */
112 ErrorCallback the_error_callback
;
113 void *the_error_signal_userdata
;
114 /* song status changed */
115 StatusChangedCallback the_status_changed_callback
;
116 void *the_status_changed_signal_userdata
;
117 /* (dis)connect signal */
118 ConnectionChangedCallback the_connection_changed_callback
;
119 void *the_connection_changed_signal_userdata
;
126 /* internal values */
127 /* this "locks" the connections. so we can't have to commands competing with eachother */
128 short int connection_lock
;
133 /* TODO: this is a temporary implementation, I want something nice with commands that are and aren't allowed to use.
134 * so use commands and notcommands functions
135 *TODO: Make a callback when a commando isn't allowed, so the client application can actually offer the user to enter password
137 MpdCommand
* commands
;
139 * tag type for a search
145 * For tracking changed outputs.
146 * A hack for retarted mpd
151 * Supported url handlers
155 * For testing supported tags
157 int supported_tags
[MPD_TAG_NUM_OF_ITEM_TYPES
];
163 typedef enum MpdQueueType
{
167 MPD_QUEUE_DELETE_POS
,
168 MPD_QUEUE_COMMAND
/* abuse!!! */
171 typedef struct _MpdQueue
{
172 struct _MpdQueue
*next
;
173 struct _MpdQueue
*prev
;
174 struct _MpdQueue
*first
;
176 /* what item to queue, (add/load/remove)*/
178 /* for adding files/load playlist/adding streams */
184 /* Internal Queue struct functions */
185 MpdQueue
* mpd_new_queue_struct ();
186 void mpd_queue_get_next (MpdObj
*mi
);
188 /* Internal Data struct functions */
189 MpdData
* mpd_new_data_struct (void);
190 MpdData
* mpd_new_data_struct_append (MpdData
* data
);
191 MpdData
* mpd_data_concatenate (MpdData
* const first
, MpdData
* const second
);
192 MpdData
* mpd_data_get_next_real (MpdData
* const data
, int kill_list
);
193 /* more internal stuff*/
196 * @param mi a #MpdObj
198 * Checks if mpd_stats is available, and updates when needed.
200 * @returns a #MpdError
202 int mpd_stats_check(MpdObj
*mi
);
204 int mpd_lock_conn(MpdObj
*mi
);
205 int mpd_unlock_conn(MpdObj
*mi
);
206 /*MpdData * mpd_playlist_sort_artist_list(MpdData *data);*/
207 MpdData
* mpd_misc_sort_tag_list(MpdData
*data
);
211 char * strndup (const char *s
, size_t n
);
214 int mpd_server_get_allowed_commands(MpdObj
*mi
);
215 typedef enum _MpdSearchType
{
216 MPD_SEARCH_TYPE_NONE
,
217 MPD_SEARCH_TYPE_FIND
,
218 MPD_SEARCH_TYPE_SEARCH
,
219 MPD_SEARCH_TYPE_LIST
,
220 MPD_SEARCH_TYPE_PLAYLIST_FIND
,
221 MPD_SEARCH_TYPE_PLAYLIST_SEARCH
,
222 MPD_SEARCH_TYPE_STATS
224 int mpd_server_update_outputs(MpdObj
*mi
);