libmpd  0.19.0
libmpd.h
Go to the documentation of this file.
00001 /* libmpd (high level libmpdclient library)
00002  * Copyright (C) 2004-2009 Qball Cow <qball@sarine.nl>
00003  * Project homepage: http://gmpcwiki.sarine.nl/
00004  
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014 
00015  * You should have received a copy of the GNU General Public License along
00016  * with this program; if not, write to the Free Software Foundation, Inc.,
00017  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018 */
00019 
00028 
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032 
00033 #ifndef __MPD_LIB__
00034 #define __MPD_LIB__
00035 #ifdef WIN32
00036 #define __REGEX_IMPORT__ 1
00037 #define __W32API_USE_DLLIMPORT__ 1
00038 #endif
00039 
00040 #include "libmpdclient.h"
00041 
00042 #ifndef TRUE
00043 
00044 #define TRUE 1
00045 #endif
00046 
00047 #ifndef FALSE
00048 
00049 #define FALSE 0
00050 #endif
00051 #include "libmpd-version.h"
00052 extern char *libmpd_version;
00053 
00058 typedef enum {
00060         MPD_OK = 0,
00062         MPD_ARGS_ERROR = -5,
00064         MPD_NOT_CONNECTED = -10,
00066         MPD_STATUS_FAILED  = -20,
00068         MPD_LOCK_FAILED  = -30,
00070         MPD_STATS_FAILED = -40,
00072         MPD_SERVER_ERROR = -50,
00074         MPD_SERVER_NOT_SUPPORTED = -51,
00075         
00077         MPD_DATABASE_PLAYLIST_EXIST  = -60,
00079         MPD_PLAYLIST_EMPTY = -70,
00081         MPD_PLAYLIST_QUEUE_EMPTY = -75,
00083         MPD_PLAYER_NOT_PLAYING = -80,
00084 
00086         MPD_TAG_NOT_FOUND = -90,
00087         
00089         MPD_FATAL_ERROR = -1000
00090 }MpdError;
00091 
00092 
00093 
00097 typedef struct _MpdObj MpdObj;
00098 
00103 typedef enum {
00104         MPD_SERVER_COMMAND_ALLOWED = TRUE,
00105         MPD_SERVER_COMMAND_NOT_ALLOWED = FALSE,
00106         MPD_SERVER_COMMAND_NOT_SUPPORTED = -1,
00107         MPD_SERVER_COMMAND_ERROR = -2
00108 } MpdServerCommand;
00109 
00110 
00118 typedef enum {
00120         MPD_DATA_TYPE_NONE,
00122         MPD_DATA_TYPE_TAG,
00124         MPD_DATA_TYPE_DIRECTORY,
00126         MPD_DATA_TYPE_SONG,
00128         MPD_DATA_TYPE_PLAYLIST,
00130         MPD_DATA_TYPE_OUTPUT_DEV
00131 } MpdDataType;
00132 
00137 typedef struct _MpdData {
00139         MpdDataType type;
00140         union {
00141                 struct {
00143                         int tag_type;
00145                         char *tag;
00146                 };
00148                 char *directory;
00150                 mpd_PlaylistFile *playlist;
00152                 mpd_Song *song;
00154                 mpd_OutputEntity *output_dev;
00155         };
00156 
00157     void *userdata;
00158     void (*freefunc)(void *userdata);
00159 } MpdData;
00160 
00161 
00162 #include "libmpd-player.h"
00163 #include "libmpd-status.h"
00164 #include "libmpd-database.h"
00165 #include "libmpd-playlist.h"
00166 #include "libmpd-strfsong.h"
00167 #include "libmpd-sticker.h"
00168 
00169 
00170 
00185 MpdObj *mpd_new_default();
00186 
00187 
00188 
00199 MpdObj *mpd_new(char *hostname, int port, char *password);
00200 
00201 
00202         
00211 int mpd_set_hostname(MpdObj * mi, char *hostname);
00212 
00220 const char * mpd_get_hostname(MpdObj *mi);
00221         
00230 int mpd_set_password(MpdObj * mi,const char *password);
00231         
00232         
00242 int mpd_set_port(MpdObj * mi, int port);
00243 
00244 
00245 
00246         
00256 int mpd_set_connection_timeout(MpdObj * mi, float timeout);
00257 
00258 
00259 int mpd_connect_real(MpdObj *mi,mpd_Connection *connection);
00268 int mpd_connect(MpdObj * mi);
00269 
00270         
00277 int mpd_disconnect(MpdObj * mi);
00278 
00279         
00280         
00287 int mpd_check_connected(MpdObj * mi);
00288 
00289         
00290         
00297 int mpd_check_error(MpdObj * mi);
00298 
00299 
00300         
00306 void mpd_free(MpdObj * mi);
00307 
00308 
00309         
00319 int mpd_send_password(MpdObj * mi);
00320 
00321         
00322 
00323 /*
00324  * signals
00325  */
00326 
00346 typedef enum {
00348         MPD_CST_PLAYLIST      = 0x0001,
00350         MPD_CST_SONGPOS       = 0x0002,
00352         MPD_CST_SONGID        = 0x0004,
00354         MPD_CST_DATABASE      = 0x0008,
00356         MPD_CST_UPDATING      = 0x0010,
00358         MPD_CST_VOLUME        = 0x0020,
00360         MPD_CST_TOTAL_TIME    = 0x0040,
00362         MPD_CST_ELAPSED_TIME  = 0x0080,
00364         MPD_CST_CROSSFADE     = 0x0100,
00366         MPD_CST_RANDOM        = 0x0200,
00368         MPD_CST_REPEAT        = 0x0400,
00370         MPD_CST_AUDIO         = 0x0800,
00372         MPD_CST_STATE         = 0x1000,
00374         MPD_CST_PERMISSION    = 0x2000,
00376         MPD_CST_BITRATE       = 0x4000,
00378         MPD_CST_AUDIOFORMAT   = 0x8000,
00380         MPD_CST_STORED_PLAYLIST           = 0x20000,
00382     MPD_CST_SERVER_ERROR        = 0x40000,
00384     MPD_CST_OUTPUT              = 0x80000,
00386     MPD_CST_STICKER             = 0x100000,
00388     MPD_CST_NEXTSONG            = 0x200000,
00390     MPD_CST_SINGLE_MODE         = 0x400000,
00392     MPD_CST_CONSUME_MODE        = 0x800000
00393 } ChangedStatusType;
00394 
00395 
00396 /* callback typedef's */
00404 typedef void (*StatusChangedCallback) (MpdObj * mi, ChangedStatusType what, void *userdata);
00405 
00406 
00407 
00408         
00418 typedef int (*ErrorCallback) (MpdObj * mi, int id, char *msg, void *userdata);
00419 
00420 
00421         
00429 typedef void (*ConnectionChangedCallback) (MpdObj * mi, int connect, void *userdata);
00430 
00431 
00432 
00433 /* new style signal connectors */
00439 void mpd_signal_connect_status_changed(MpdObj * mi, StatusChangedCallback status_changed,
00440                                                void *userdata);
00441 
00442 
00443 
00449 void mpd_signal_connect_error(MpdObj * mi, ErrorCallback error, void *userdata);
00450 
00451 
00452         
00458 void mpd_signal_connect_connection_changed(MpdObj * mi,
00459                                                    ConnectionChangedCallback connection_changed,
00460                                                    void *userdata);
00461 
00471 
00478 int mpd_data_is_last(MpdData const *data);
00479 
00480 
00486 void mpd_data_free(MpdData * data);
00487 
00488 
00489         
00505 MpdData *mpd_data_get_next(MpdData * data);
00506 
00507 
00508         
00509 
00517 MpdData *mpd_data_get_first(MpdData const *data);
00518 
00519 
00520         
00528 MpdData *mpd_data_delete_item(MpdData * data);
00529 
00530 
00531         
00539 
00540         
00548 MpdData *mpd_server_get_output_devices(MpdObj * mi);
00549 
00550 
00551         
00561 int mpd_server_set_output_device(MpdObj * mi, int device_id, int state);
00562 
00563 
00564         
00572 long unsigned mpd_server_get_database_update_time(MpdObj * mi);
00573 
00574 
00575         
00586 int mpd_server_check_version(MpdObj * mi, int major, int minor, int micro);
00587 
00594 char *mpd_server_get_version(MpdObj *mi);
00603 int mpd_server_check_command_allowed(MpdObj * mi, const char *command);
00604 
00605 
00606 
00612 char ** mpd_server_get_url_handlers(MpdObj *mi);
00613 
00620 char ** mpd_server_get_tag_types(MpdObj *mi);
00627 
00635 int mpd_misc_get_tag_by_name(char *name);
00636 
00646 int mpd_server_has_idle(MpdObj *mi);
00647 
00656 int mpd_server_tag_supported(MpdObj *mi, int tag);
00657 
00658 #endif
00659 
00660 #ifdef __cplusplus
00661 }
00662 #endif