Modify version string to post-release version 0.17.99
[libmpd.git] / src / libmpd-internal.h
blob7aaf69c972b48faaf6a2a4d5bc10be6f56f6e7bd
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"
24 struct _MpdData_real;
26 typedef struct _MpdData_real {
27 /* MpdDataType */
28 MpdDataType type;
30 union {
31 struct {
32 int tag_type;
33 char *tag;
35 char *directory;
36 mpd_PlaylistFile *playlist;
37 mpd_Song *song;
38 mpd_OutputEntity *output_dev; /* from devices */
40 void *userdata;
41 void (*freefunc)(void *userdata);
43 struct _MpdData_real *next;
44 /* Previous MpdData in the list */
45 struct _MpdData_real *prev;
46 struct _MpdData_real *first;
47 }MpdData_real;
50 /* queue struct */
51 typedef struct _MpdQueue MpdQueue;
52 typedef struct _MpdServerState {
53 /* information needed to detect changes on mpd's side */
54 long long playlistid;
55 long long storedplaylistid;
56 int songid;
57 int songpos;
58 int state;
59 unsigned long dbUpdateTime;
60 int updatingDb;
61 int random;
62 int repeat;
63 int volume;
64 int xfade;
65 int totaltime;
66 int elapsedtime;
67 int bitrate;
68 unsigned int samplerate;
69 int bits;
70 int channels;
71 unsigned long playlistLength;
72 char error[512];
73 } MpdServerState;
76 /* command struct */
77 /* internal use only */
78 typedef struct _MpdCommand {
79 char *command_name;
80 int enabled;
81 } MpdCommand;
85 typedef struct _MpdObj {
86 /* defines if we are connected */
87 /* This should be made true if and only if the connection is up and running */
88 short int connected;
89 /* information needed to connect to mpd */
90 char *hostname;
91 int port;
92 char *password;
93 float connection_timeout;
95 /* mpd's structures */
96 mpd_Connection *connection;
97 mpd_Status *status;
98 mpd_Stats *stats;
99 mpd_Song *CurrentSong;
101 /* used to store/detect serverside status changes */
102 MpdServerState CurrentState;
103 MpdServerState OldState;
105 /* new style signals */
106 /* error signal */
107 ErrorCallback the_error_callback;
108 void *the_error_signal_userdata;
109 /* song status changed */
110 StatusChangedCallback the_status_changed_callback;
111 void *the_status_changed_signal_userdata;
112 /* (dis)connect signal */
113 ConnectionChangedCallback the_connection_changed_callback;
114 void *the_connection_changed_signal_userdata;
116 /* error message */
117 int error;
118 int error_mpd_code;
119 char *error_msg;
121 /* internal values */
122 /* this "locks" the connections. so we can't have to commands competing with eachother */
123 short int connection_lock;
125 /* queue */
126 MpdQueue *queue;
127 /* commands */
128 /* TODO: this is a temporary implementation, I want something nice with commands that are and aren't allowed to use.
129 * so use commands and notcommands functions
130 *TODO: Make a callback when a commando isn't allowed, so the client application can actually offer the user to enter password
132 MpdCommand * commands;
134 * tag type for a search
136 int search_type;
137 int search_field;
140 * For tracking changed outputs.
141 * A hack for retarted mpd
143 int num_outputs;
144 int *output_states;
147 * For testing supported tags
149 int supported_tags[MPD_TAG_NUM_OF_ITEM_TYPES];
151 int has_idle;
152 }_MpdObj;
155 typedef enum MpdQueueType {
156 MPD_QUEUE_ADD,
157 MPD_QUEUE_LOAD,
158 MPD_QUEUE_DELETE_ID,
159 MPD_QUEUE_DELETE_POS,
160 MPD_QUEUE_COMMAND /* abuse!!! */
161 } MpdQueueType;
163 typedef struct _MpdQueue {
164 struct _MpdQueue *next;
165 struct _MpdQueue *prev;
166 struct _MpdQueue *first;
168 /* what item to queue, (add/load/remove)*/
169 int type;
170 /* for adding files/load playlist/adding streams */
171 char *path;
172 /* for removing */
173 int id;
174 }_MpdQueue;
176 /* Internal Queue struct functions */
177 MpdQueue * mpd_new_queue_struct ();
178 void mpd_queue_get_next (MpdObj *mi);
180 /* Internal Data struct functions */
181 MpdData * mpd_new_data_struct (void);
182 MpdData * mpd_new_data_struct_append (MpdData * data);
183 MpdData * mpd_data_concatenate (MpdData * const first, MpdData * const second);
184 MpdData * mpd_data_get_next_real (MpdData * const data, int kill_list);
185 /* more internal stuff*/
188 * @param mi a #MpdObj
190 * Checks if mpd_stats is available, and updates when needed.
192 * @returns a #MpdError
194 int mpd_stats_check(MpdObj *mi);
196 int mpd_lock_conn(MpdObj *mi);
197 int mpd_unlock_conn(MpdObj *mi);
198 /*MpdData * mpd_playlist_sort_artist_list(MpdData *data);*/
199 MpdData * mpd_misc_sort_tag_list(MpdData *data);
202 #ifndef HAVE_STRNDUP
203 char * strndup (const char *s, size_t n);
204 #endif
206 int mpd_server_get_allowed_commands(MpdObj *mi);
207 typedef enum _MpdSearchType {
208 MPD_SEARCH_TYPE_NONE,
209 MPD_SEARCH_TYPE_FIND,
210 MPD_SEARCH_TYPE_SEARCH,
211 MPD_SEARCH_TYPE_LIST,
212 MPD_SEARCH_TYPE_PLAYLIST_FIND,
213 MPD_SEARCH_TYPE_PLAYLIST_SEARCH,
214 MPD_SEARCH_TYPE_STATS
215 }MpdSearchType;
216 int mpd_server_update_outputs(MpdObj *mi);
217 #endif