1 /* 2 * Copyright (C) 2005 Marc Pavot <marc.pavot@gmail.com> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2, or (at your option) 7 * any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 */ 19 20 #ifndef __ARIO_SERVER_H 21 #define __ARIO_SERVER_H 22 23 #include <glib-object.h> 24 25 G_BEGIN_DECLS 26 27 #define ARIO_SERVER_UNKNOWN _("Unknown") 28 29 #define ARIO_TYPE_SERVER (ario_server_get_type ()) 30 #define ARIO_SERVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ARIO_TYPE_SERVER, ArioServer)) 31 #define ARIO_SERVER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ARIO_TYPE_SERVER, ArioServerClass)) 32 #define IS_ARIO_SERVER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ARIO_TYPE_SERVER)) 33 #define IS_ARIO_SERVER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ARIO_TYPE_SERVER)) 34 #define ARIO_SERVER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ARIO_TYPE_SERVER, ArioServerClass)) 35 36 typedef struct { 37 /* filename of song */ 38 char * file; 39 /* artist, maybe NULL if there is no tag */ 40 char * artist; 41 /* title, maybe NULL if there is no tag */ 42 char * title; 43 /* album, maybe NULL if there is no tag */ 44 char * album; 45 /* album artist, maybe NULL if there is no tag */ 46 char * album_artist; 47 /* track, maybe NULL if there is no tag */ 48 char * track; 49 /* name, maybe NULL if there is no tag; it's the name of the current 50 * song, f.e. the icyName of the stream */ 51 char * name; 52 /* date */ 53 char *date; 54 /* Genre */ 55 char *genre; 56 /* Composer */ 57 char *composer; 58 /* Performer */ 59 char *performer; 60 /* Disc */ 61 char *disc; 62 /* Comment */ 63 char *comment; 64 /* length of song in seconds */ 65 int time; 66 /* if plchanges/playlistinfo/playlistid used, is the position of the 67 * song in the playlist */ 68 int pos; 69 /* song id for a song in the playlist */ 70 int id; 71 } ArioServerSong; 72 73 typedef struct { 74 int numberOfArtists; 75 int numberOfAlbums; 76 int numberOfSongs; 77 unsigned long uptime; 78 unsigned long dbUpdateTime; 79 unsigned long playTime; 80 unsigned long dbPlayTime; 81 } ArioServerStats; 82 83 typedef struct { 84 int id; 85 char * name; 86 int enabled; 87 } ArioServerOutput; 88 89 typedef enum { 90 /** no information available */ 91 ARIO_STATE_UNKNOWN = 0, 92 93 /** not playing */ 94 ARIO_STATE_STOP = 1, 95 96 /** playing */ 97 ARIO_STATE_PLAY = 2, 98 99 /** playing, but paused */ 100 ARIO_STATE_PAUSE = 3, 101 } ArioServerState; 102 103 typedef enum 104 { 105 ARIO_TAG_ARTIST, 106 ARIO_TAG_ALBUM, 107 ARIO_TAG_ALBUM_ARTIST, 108 ARIO_TAG_TITLE, 109 ARIO_TAG_TRACK, 110 ARIO_TAG_NAME, 111 ARIO_TAG_GENRE, 112 ARIO_TAG_DATE, 113 ARIO_TAG_COMPOSER, 114 ARIO_TAG_PERFORMER, 115 ARIO_TAG_COMMENT, 116 ARIO_TAG_DISC, 117 ARIO_TAG_FILENAME, 118 ARIO_TAG_ANY, 119 ARIO_TAG_COUNT 120 }ArioServerTag; 121 122 typedef struct 123 { 124 gchar *artist; 125 gchar *album; 126 gchar *path; 127 gchar *date; 128 } ArioServerAlbum; 129 130 typedef struct 131 { 132 GSList *directories; 133 GSList *songs; 134 } ArioServerFileList; 135 136 typedef struct 137 { 138 ArioServerTag tag; 139 gchar *value; 140 } ArioServerAtomicCriteria; 141 142 typedef GSList ArioServerCriteria; /* A criteria is a list of atomic criterias */ 143 144 typedef enum 145 { 146 ArioServerMpd, 147 ArioServerXmms 148 } ArioServerType; 149 150 typedef enum 151 { 152 ARIO_SERVER_ACTION_ADD, 153 ARIO_SERVER_ACTION_DELETE_ID, 154 ARIO_SERVER_ACTION_DELETE_POS, 155 ARIO_SERVER_ACTION_MOVE, 156 ARIO_SERVER_ACTION_MOVEID 157 }ArioServerActionType; 158 159 typedef struct ArioServerQueueAction { 160 ArioServerActionType type; 161 union { 162 const char *path; // For ARIO_SERVER_ACTION_ADD 163 int id; // For ARIO_SERVER_ACTION_DELETE_ID 164 int pos; // For ARIO_SERVER_ACTION_DELETE_POS 165 struct { // For ARIO_SERVER_ACTION_MOVE and ARIO_SERVER_ACTION_MOVEID 166 int old_pos; 167 int new_pos; 168 }; 169 }; 170 } ArioServerQueueAction; 171 172 enum 173 { 174 SERVER_SONG_CHANGED, 175 SERVER_ALBUM_CHANGED, 176 SERVER_CONNECTIVITY_CHANGED, 177 SERVER_STATE_CHANGED, 178 SERVER_VOLUME_CHANGED, 179 SERVER_ELAPSED_CHANGED, 180 SERVER_PLAYLIST_CHANGED, 181 SERVER_CONSUME_CHANGED, 182 SERVER_RANDOM_CHANGED, 183 SERVER_REPEAT_CHANGED, 184 SERVER_UPDATINGDB_CHANGED, 185 SERVER_STOREDPLAYLISTS_CHANGED, 186 SERVER_LAST_SIGNAL 187 }; 188 189 enum 190 { 191 SERVER_SONG_CHANGED_FLAG = 2 << SERVER_SONG_CHANGED, 192 SERVER_ALBUM_CHANGED_FLAG = 2 << SERVER_ALBUM_CHANGED, 193 SERVER_CONNECTIVITY_CHANGED_FLAG = 2 << SERVER_CONNECTIVITY_CHANGED, 194 SERVER_STATE_CHANGED_FLAG = 2 << SERVER_STATE_CHANGED, 195 SERVER_VOLUME_CHANGED_FLAG = 2 << SERVER_VOLUME_CHANGED, 196 SERVER_ELAPSED_CHANGED_FLAG = 2 << SERVER_ELAPSED_CHANGED, 197 SERVER_PLAYLIST_CHANGED_FLAG = 2 << SERVER_PLAYLIST_CHANGED, 198 SERVER_CONSUME_CHANGED_FLAG = 2 << SERVER_CONSUME_CHANGED, 199 SERVER_RANDOM_CHANGED_FLAG = 2 << SERVER_RANDOM_CHANGED, 200 SERVER_REPEAT_CHANGED_FLAG = 2 << SERVER_REPEAT_CHANGED, 201 SERVER_UPDATINGDB_CHANGED_FLAG = 2 << SERVER_UPDATINGDB_CHANGED, 202 SERVER_STOREDPLAYLISTS_CHANGED_FLAG = 2 << SERVER_STOREDPLAYLISTS_CHANGED 203 }; 204 205 typedef enum 206 { 207 PLAYLIST_ADD, 208 PLAYLIST_ADD_PLAY, 209 PLAYLIST_REPLACE, 210 PLAYLIST_ADD_AFTER_PLAYING, 211 PLAYLIST_N_BEHAVIOR 212 } PlaylistAction; 213 214 typedef struct 215 { 216 GObject parent; 217 } ArioServer; 218 219 typedef struct 220 { 221 GObjectClass parent; 222 223 /* Signals */ 224 void (*song_changed) (ArioServer *server); 225 226 void (*album_changed) (ArioServer *server); 227 228 void (*connectivity_changed) (ArioServer *server); 229 230 void (*state_changed) (ArioServer *server); 231 232 void (*volume_changed) (ArioServer *server, 233 int volume); 234 void (*elapsed_changed) (ArioServer *server, 235 int elapsed); 236 void (*playlist_changed) (ArioServer *server); 237 238 void (*consume_changed) (ArioServer *server); 239 240 void (*random_changed) (ArioServer *server); 241 242 void (*repeat_changed) (ArioServer *server); 243 244 void (*updatingdb_changed) (ArioServer *server); 245 246 void (*storedplaylists_changed) (ArioServer *server); 247 } ArioServerClass; 248 249 GType ario_server_get_type (void) G_GNUC_CONST; 250 251 ArioServer * ario_server_get_instance (void); 252 253 gboolean ario_server_connect (void); 254 255 void ario_server_disconnect (void); 256 257 void ario_server_reconnect (void); 258 259 void ario_server_shutdown (void); 260 261 gboolean ario_server_is_connected (void); 262 263 gboolean ario_server_update_status (void); 264 265 void ario_server_update_db (const gchar *path); 266 267 GSList * ario_server_list_tags (const ArioServerTag tag, 268 const ArioServerCriteria *criteria); 269 GSList * ario_server_get_albums (const ArioServerCriteria *criteria); 270 GSList * ario_server_get_songs (const ArioServerCriteria *criteria, 271 const gboolean exact); 272 GSList * ario_server_get_songs_from_playlist (char *playlist); 273 GSList * ario_server_get_playlists (void); 274 275 GSList * ario_server_get_playlist_changes (gint64 playlist_id); 276 277 ArioServerSong * ario_server_get_current_song_on_server (void); 278 279 ArioServerSong * ario_server_get_current_song (void); 280 281 char * ario_server_get_current_artist (void); 282 283 char * ario_server_get_current_album (void); 284 285 char * ario_server_get_current_song_path (void); 286 287 int ario_server_get_current_song_id (void); 288 289 int ario_server_get_current_state (void); 290 291 int ario_server_get_current_elapsed (void); 292 293 int ario_server_get_current_volume (void); 294 295 int ario_server_get_current_total_time (void); 296 297 gint64 ario_server_get_current_playlist_id (void); 298 299 int ario_server_get_current_playlist_length (void); 300 301 int ario_server_get_current_playlist_total_time (void); 302 303 int ario_server_get_crossfadetime (void); 304 305 gboolean ario_server_get_current_consume (void); 306 307 gboolean ario_server_get_current_random (void); 308 309 gboolean ario_server_get_current_repeat (void); 310 311 gboolean ario_server_get_updating (void); 312 313 unsigned long ario_server_get_last_update (void); 314 315 void ario_server_set_current_elapsed (const gint elapsed); 316 void ario_server_set_current_volume (const gint volume); 317 GSList * ario_server_get_outputs (void); 318 319 void ario_server_set_current_consume (const gboolean consume); 320 void ario_server_set_current_random (const gboolean random); 321 void ario_server_set_current_repeat (const gboolean repeat); 322 void ario_server_set_crossfadetime (const int crossfadetime); 323 gboolean ario_server_is_paused (void); 324 325 void ario_server_do_next (void); 326 327 void ario_server_do_prev (void); 328 329 void ario_server_do_play (void); 330 331 void ario_server_do_play_pos (gint id); 332 void ario_server_do_pause (void); 333 334 void ario_server_do_stop (void); 335 336 void ario_server_free_album (ArioServerAlbum *server_album); 337 338 ArioServerAlbum * ario_server_copy_album (const ArioServerAlbum *server_album); 339 340 void ario_server_clear (void); 341 void ario_server_shuffle (void); 342 343 void ario_server_queue_add (const char *path); 344 void ario_server_queue_delete_id (const int id); 345 void ario_server_queue_delete_pos (const int pos); 346 void ario_server_queue_move (const int old_pos, 347 const int new_pos); 348 void ario_server_queue_moveid (const int id, 349 const int pos); 350 void ario_server_queue_commit (void); 351 352 void ario_server_insert_at (const GSList *songs, 353 const gint pos); 354 // returns 0 if OK, 1 if playlist already exists 355 int ario_server_save_playlist (const char *name); 356 void ario_server_delete_playlist (const char *name); 357 358 GSList * ario_server_get_outputs (void); 359 360 void ario_server_enable_output (const int id, 361 const gboolean enabled); 362 ArioServerStats * ario_server_get_stats (void); 363 364 GList * ario_server_get_songs_info (GSList *paths); 365 366 ArioServerFileList* ario_server_list_files (const char *path, 367 const gboolean recursive); 368 void ario_server_free_file_list (ArioServerFileList *files); 369 370 ArioServerCriteria * ario_server_criteria_copy (const ArioServerCriteria *criteria); 371 372 void ario_server_criteria_free (ArioServerCriteria *criteria); 373 374 gchar ** ario_server_get_items_names (void); 375 376 const gchar* ario_server_song_get_tag (const ArioServerSong *song, 377 ArioServerTag tag); 378 void ario_server_playlist_add_songs (const GSList *songs, 379 const gint pos, 380 const PlaylistAction action); 381 void ario_server_playlist_add_dir (const gchar *dir, 382 const gint pos, 383 const PlaylistAction action); 384 void ario_server_playlist_add_criterias (const GSList *criterias, 385 const gint pos, 386 const PlaylistAction action, 387 const gint nb_entries); 388 void ario_server_playlist_append_artists (const GSList *artists, 389 const PlaylistAction action, 390 const gint nb_entries); 391 void ario_server_playlist_append_songs (const GSList *songs, 392 const PlaylistAction action); 393 void ario_server_playlist_append_server_songs (const GSList *songs, 394 const PlaylistAction action); 395 void ario_server_playlist_append_dir (const gchar *dir, 396 const PlaylistAction action); 397 void ario_server_playlist_append_criterias (const GSList *criterias, 398 const PlaylistAction action, 399 const gint nb_entries); 400 void ario_server_free_song (ArioServerSong *song); 401 402 void ario_server_free_output (ArioServerOutput *output); 403 404 G_END_DECLS 405 406 #endif /* __ARIO_SERVER_H */ 407