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
00387 } ChangedStatusType;
00388 
00389 
00390 /* callback typedef's */
00398 typedef void (*StatusChangedCallback) (MpdObj * mi, ChangedStatusType what, void *userdata);
00399 
00400 
00401 
00402         
00412 typedef int (*ErrorCallback) (MpdObj * mi, int id, char *msg, void *userdata);
00413 
00414 
00415         
00423 typedef void (*ConnectionChangedCallback) (MpdObj * mi, int connect, void *userdata);
00424 
00425 
00426 
00427 /* new style signal connectors */
00433 void mpd_signal_connect_status_changed(MpdObj * mi, StatusChangedCallback status_changed,
00434                                                void *userdata);
00435 
00436 
00437 
00443 void mpd_signal_connect_error(MpdObj * mi, ErrorCallback error, void *userdata);
00444 
00445 
00446         
00452 void mpd_signal_connect_connection_changed(MpdObj * mi,
00453                                                    ConnectionChangedCallback connection_changed,
00454                                                    void *userdata);
00455 
00465 
00472 int mpd_data_is_last(MpdData const *data);
00473 
00474 
00480 void mpd_data_free(MpdData * data);
00481 
00482 
00483         
00499 MpdData *mpd_data_get_next(MpdData * data);
00500 
00501 
00502         
00503 
00511 MpdData *mpd_data_get_first(MpdData const *data);
00512 
00513 
00514         
00522 MpdData *mpd_data_delete_item(MpdData * data);
00523 
00524 
00525         
00533 
00534         
00542 MpdData *mpd_server_get_output_devices(MpdObj * mi);
00543 
00544 
00545         
00555 int mpd_server_set_output_device(MpdObj * mi, int device_id, int state);
00556 
00557 
00558         
00566 long unsigned mpd_server_get_database_update_time(MpdObj * mi);
00567 
00568 
00569         
00580 int mpd_server_check_version(MpdObj * mi, int major, int minor, int micro);
00581 
00588 char *mpd_server_get_version(MpdObj *mi);
00597 int mpd_server_check_command_allowed(MpdObj * mi, const char *command);
00598 
00599 
00600 
00606 char ** mpd_server_get_url_handlers(MpdObj *mi);
00607 
00614 char ** mpd_server_get_tag_types(MpdObj *mi);
00621 
00629 int mpd_misc_get_tag_by_name(char *name);
00630 
00640 int mpd_server_has_idle(MpdObj *mi);
00641 
00650 int mpd_server_tag_supported(MpdObj *mi, int tag);
00651 
00652 #endif
00653 
00654 #ifdef __cplusplus
00655 }
00656 #endif

Copyright 2006 Qball Cow