Code

mpdclient: moved compare_filelistentry() to filelist.c
[ncmpc.git] / src / filelist.h
1 /* ncmpc (Ncurses MPD Client)
2  * (c) 2004-2009 The Music Player Daemon Project
3  * Project homepage: http://musicpd.org
4  
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.
18 */
20 #ifndef FILELIST_H
21 #define FILELIST_H
23 #include <glib.h>
25 struct mpd_connection;
26 struct mpd_song;
28 struct filelist_entry {
29         guint flags;
30         struct mpd_entity *entity;
31 };
33 struct filelist {
34         /* the list */
35         GPtrArray *entries;
36 };
38 struct filelist *
39 filelist_new(void);
41 void
42 filelist_free(struct filelist *filelist);
44 static inline guint
45 filelist_length(const struct filelist *filelist)
46 {
47         return filelist->entries->len;
48 }
50 static inline gboolean
51 filelist_is_empty(const struct filelist *filelist)
52 {
53         return filelist_length(filelist) == 0;
54 }
56 static inline struct filelist_entry *
57 filelist_get(const struct filelist *filelist, guint i)
58 {
59         return g_ptr_array_index(filelist->entries, i);
60 }
62 struct filelist_entry *
63 filelist_append(struct filelist *filelist, struct mpd_entity *entity);
65 struct filelist_entry *
66 filelist_prepend(struct filelist *filelist, struct mpd_entity *entity);
68 void
69 filelist_move(struct filelist *filelist, struct filelist *from);
71 gint
72 compare_filelist_entry_path(gconstpointer filelist_entry1,
73                             gconstpointer filelist_entry2);
75 /* Sorts the whole filelist, at the moment used by filelist_search */
76 void
77 filelist_sort_all(struct filelist *filelist, GCompareFunc compare_func);
79 /* Only sorts the directories and playlist files.
80  * The songs stay in the order it came from mpd. */
81 void
82 filelist_sort_dir_play(struct filelist *filelist, GCompareFunc compare_func);
84 int
85 filelist_find_song(struct filelist *flist, const struct mpd_song *song);
87 int
88 filelist_find_directory(struct filelist *filelist, const char *name);
90 /**
91  * Receives entities from the connection, and appends them to the
92  * specified filelist.  This does not finish the response, and does
93  * not check for errors.
94  */
95 void
96 filelist_recv(struct filelist *filelist, struct mpd_connection *connection);
98 /**
99  * Creates a new filelist and receives entities from the connection.
100  * This does not finish the response, and does not check for errors.
101  */
102 struct filelist *
103 filelist_new_recv(struct mpd_connection *connection);
105 #endif