configure.ac: Move the encoders before the audio outputs.
[mpd-mk.git] / src / client_internal.h
blob8bcda78e7d351214963788009cc6f9e7dfe861eb
1 /*
2 * Copyright (C) 2003-2010 The Music Player Daemon Project
3 * http://www.musicpd.org
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.
20 #ifndef MPD_CLIENT_INTERNAL_H
21 #define MPD_CLIENT_INTERNAL_H
23 #include "client.h"
24 #include "command.h"
26 #undef G_LOG_DOMAIN
27 #define G_LOG_DOMAIN "client"
29 struct deferred_buffer {
30 size_t size;
31 char data[sizeof(long)];
34 struct client {
35 GIOChannel *channel;
36 guint source_id;
38 /** the buffer for reading lines from the #channel */
39 struct fifo_buffer *input;
41 unsigned permission;
43 /** the uid of the client process, or -1 if unknown */
44 int uid;
46 /**
47 * How long since the last activity from this client?
49 GTimer *last_activity;
51 GSList *cmd_list; /* for when in list mode */
52 int cmd_list_OK; /* print OK after each command execution */
53 size_t cmd_list_size; /* mem cmd_list consumes */
54 GQueue *deferred_send; /* for output if client is slow */
55 size_t deferred_bytes; /* mem deferred_send consumes */
56 unsigned int num; /* client number */
58 char send_buf[4096];
59 size_t send_buf_used; /* bytes used this instance */
61 /** is this client waiting for an "idle" response? */
62 bool idle_waiting;
64 /** idle flags pending on this client, to be sent as soon as
65 the client enters "idle" */
66 unsigned idle_flags;
68 /** idle flags that the client wants to receive */
69 unsigned idle_subscriptions;
72 extern unsigned int client_max_connections;
73 extern int client_timeout;
74 extern size_t client_max_command_list_size;
75 extern size_t client_max_output_buffer_size;
77 bool
78 client_list_is_empty(void);
80 bool
81 client_list_is_full(void);
83 struct client *
84 client_list_get_first(void);
86 void
87 client_list_add(struct client *client);
89 void
90 client_list_foreach(GFunc func, gpointer user_data);
92 void
93 client_list_remove(struct client *client);
95 void
96 client_close(struct client *client);
98 static inline void
99 new_cmd_list_ptr(struct client *client, const char *s)
101 client->cmd_list = g_slist_prepend(client->cmd_list, g_strdup(s));
104 static inline void
105 free_cmd_list(GSList *list)
107 for (GSList *tmp = list; tmp != NULL; tmp = g_slist_next(tmp))
108 g_free(tmp->data);
110 g_slist_free(list);
113 void
114 client_set_expired(struct client *client);
117 * Schedule an "expired" check for all clients: permanently delete
118 * clients which have been set "expired" with client_set_expired().
120 void
121 client_schedule_expire(void);
124 * Removes a scheduled "expired" check.
126 void
127 client_deinit_expire(void);
129 enum command_return
130 client_read(struct client *client);
132 enum command_return
133 client_process_line(struct client *client, char *line);
135 void
136 client_write_deferred(struct client *client);
138 void
139 client_write_output(struct client *client);
141 gboolean
142 client_in_event(GIOChannel *source, GIOCondition condition,
143 gpointer data);
145 #endif