chiark / gitweb /
more doxygen
[disorder] / lib / client.h
1 /*
2  * This file is part of DisOrder.
3  * Copyright (C) 2004, 2005, 2006 Richard Kettlewell
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.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA
19  */
20
21 #ifndef CLIENT_H
22 #define CLIENT_H
23
24 /* A simple synchronous client interface. */
25
26 typedef struct disorder_client disorder_client;
27
28 struct queue_entry;
29 struct kvp;
30 struct sink;
31
32 /* Parameter strings (e.g. @track@) are UTF-8 unless specified
33  * otherwise. */
34
35 disorder_client *disorder_new(int verbose);
36 /* create a new disorder_client */
37
38 int disorder_running(disorder_client *c);
39 /* return 1 if the server is running, else 0 */
40
41 int disorder_connect(disorder_client *c);
42 /* connect a disorder_client using the default settings */
43
44 int disorder_connect_sock(disorder_client *c,
45                           const struct sockaddr *sa,
46                           socklen_t len,
47                           const char *username,
48                           const char *password,
49                           const char *ident);
50 /* connect a disorder_client */
51
52 int disorder_close(disorder_client *c);
53 /* close a disorder_client */
54
55 int disorder_become(disorder_client *c, const char *user);
56 /* become another user (trusted users only) */
57
58 int disorder_version(disorder_client *c, char **versionp);
59 /* get the server version */
60
61 int disorder_play(disorder_client *c, const char *track);
62 /* add a track to the queue */
63
64 int disorder_remove(disorder_client *c, const char *track);
65 /* remove a track from the queue */
66
67 int disorder_move(disorder_client *c, const char *track, int delta);
68 /* move a track in the queue @delta@ steps towards the head */
69
70 int disorder_enable(disorder_client *c);
71 /* enable playing if it is not already enabled */
72
73 int disorder_disable(disorder_client *c);
74 /* disable playing if it is not already disabled. */
75
76 int disorder_scratch(disorder_client *c, const char *id);
77 /* scratch the currently playing track.  If @id@ is not a null pointer
78  * then the scratch will be ignored if the ID does not mactch. */
79
80 int disorder_shutdown(disorder_client *c);
81 /* shut down the server immediately */
82
83 int disorder_reconfigure(disorder_client *c);
84 /* re-read the configuration file */
85
86 int disorder_rescan(disorder_client *c);
87 /* initiate a rescan */
88
89 int disorder_playing(disorder_client *c, struct queue_entry **qp);
90 /* get the details of the currently playing track (null pointer if
91  * nothing playing).  The first entry in the list is the next track to
92  * be played. */
93
94 int disorder_recent(disorder_client *c, struct queue_entry **qp);
95 /* get a list of recently played tracks.  The LAST entry in the list
96  * is last track to have been played. */
97
98 int disorder_queue(disorder_client *c, struct queue_entry **qp);
99 /* get the queue */
100
101 int disorder_directories(disorder_client *c, const char *dir, const char *re,
102                          char ***vecp, int *nvecp);
103 /* get subdirectories of @dir@, or of the root if @dir@ is an null
104  * pointer */
105
106 int disorder_files(disorder_client *c, const char *dir, const char *re,
107                    char ***vecp, int *nvecp);
108 /* get list of files in @dir@ */
109
110 int disorder_allfiles(disorder_client *c, const char *dir, const char *re,
111                       char ***vecp, int *nvecp);
112 /* get list of files and directories in @dir@ */
113
114 char *disorder_user(disorder_client *c);
115 /* remind ourselves what user we went in as */
116
117 int disorder_exists(disorder_client *c, const char *track, int *existsp);
118 /* set @*existsp@ to 1 if the track exists, else 0 */
119
120 int disorder_enabled(disorder_client *c, int *enabledp);
121 /* set @*enabledp@ to 1 if playing enabled, else 0 */
122
123 int disorder_set(disorder_client *c, const char *track,
124                  const char *key, const char *value);
125 int disorder_unset(disorder_client *c, const char *track,
126                    const char *key);
127 int disorder_get(disorder_client *c, const char *track, const char *key,
128                  char **valuep);
129 int disorder_prefs(disorder_client *c, const char *track,
130                    struct kvp **kp);
131 /* set, unset, get, list preferences */
132
133 int disorder_length(disorder_client *c, const char *track,
134                     long *valuep);
135 /* get the length of a track in seconds, if it is known */
136
137 int disorder_search(disorder_client *c, const char *terms,
138                     char ***vecp, int *nvecp);
139 /* get a list of tracks matching @words@ */
140
141 int disorder_random_enable(disorder_client *c);
142 /* enable random play if it is not already enabled */
143
144 int disorder_random_disable(disorder_client *c);
145 /* disable random play if it is not already disabled */
146
147 int disorder_random_enabled(disorder_client *c, int *enabledp);
148 /* determine whether random play is enabled */
149
150 int disorder_stats(disorder_client *c,
151                    char ***vecp, int *nvecp);
152 /* get server statistics */
153
154 int disorder_set_volume(disorder_client *c, int left, int right);
155 int disorder_get_volume(disorder_client *c, int *left, int *right);
156 /* get or set the volume */
157
158 int disorder_log(disorder_client *c, struct sink *s);
159 /* send log output to @s@ */
160
161 int disorder_part(disorder_client *c, char **partp,
162                   const char *track, const char *context, const char *part);
163 /* get a track name part */
164
165 int disorder_resolve(disorder_client *c, char **trackp, const char *track);
166 /* resolve a track name */
167
168 int disorder_pause(disorder_client *c);
169 /* Pause the currently playing track. */
170
171 int disorder_resume(disorder_client *c);
172 /* Resume after a pause. */
173
174 int disorder_tags(disorder_client *c,
175                    char ***vecp, int *nvecp);
176 /* get known tags */
177
178 int disorder_set_global(disorder_client *c,
179                         const char *key, const char *value);
180 int disorder_unset_global(disorder_client *c, const char *key);
181 int disorder_get_global(disorder_client *c, const char *key, char **valuep);
182 /* get/unset/set global prefs */
183
184 #endif /* CLIENT_H */
185
186 /*
187 Local Variables:
188 c-basic-offset:2
189 comment-column:40
190 End:
191 */