~ubuntu-branches/ubuntu/trusty/mpd/trusty

« back to all changes in this revision

Viewing changes to src/client_internal.h

  • Committer: Bazaar Package Importer
  • Author(s): Angel Abad
  • Date: 2011-02-02 12:26:30 UTC
  • mfrom: (1.5.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20110202122630-bdyx8w4k94doz4fs
Tags: 0.16.1-1ubuntu1
* Merge from debian unstable. Remaining changes:
  - debian/control:
    + Don't build-depend on libmikmod2-dev (Debian bug #510675).
    + Move avahi-daemon from Suggests field to Recommends field.
  - debian/mpd.init.d:
    + Read mpd user from mpd.conf.
  - debian/control, debian/rules:
    + Add libmp3lame-dev to the build dependencies and enable lame.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2003-2010 The Music Player Daemon Project
 
3
 * http://www.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.
 
9
 *
 
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.
 
14
 *
 
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
 */
 
19
 
 
20
#ifndef MPD_CLIENT_INTERNAL_H
 
21
#define MPD_CLIENT_INTERNAL_H
 
22
 
 
23
#include "client.h"
 
24
#include "command.h"
 
25
 
 
26
#undef G_LOG_DOMAIN
 
27
#define G_LOG_DOMAIN "client"
 
28
 
 
29
struct deferred_buffer {
 
30
        size_t size;
 
31
        char data[sizeof(long)];
 
32
};
 
33
 
 
34
struct client {
 
35
        GIOChannel *channel;
 
36
        guint source_id;
 
37
 
 
38
        /** the buffer for reading lines from the #channel */
 
39
        struct fifo_buffer *input;
 
40
 
 
41
        unsigned permission;
 
42
 
 
43
        /** the uid of the client process, or -1 if unknown */
 
44
        int uid;
 
45
 
 
46
        /**
 
47
         * How long since the last activity from this client?
 
48
         */
 
49
        GTimer *last_activity;
 
50
 
 
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 */
 
57
 
 
58
        char send_buf[16384];
 
59
        size_t send_buf_used;   /* bytes used this instance */
 
60
 
 
61
        /** is this client waiting for an "idle" response? */
 
62
        bool idle_waiting;
 
63
 
 
64
        /** idle flags pending on this client, to be sent as soon as
 
65
            the client enters "idle" */
 
66
        unsigned idle_flags;
 
67
 
 
68
        /** idle flags that the client wants to receive */
 
69
        unsigned idle_subscriptions;
 
70
};
 
71
 
 
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;
 
76
 
 
77
bool
 
78
client_list_is_empty(void);
 
79
 
 
80
bool
 
81
client_list_is_full(void);
 
82
 
 
83
struct client *
 
84
client_list_get_first(void);
 
85
 
 
86
void
 
87
client_list_add(struct client *client);
 
88
 
 
89
void
 
90
client_list_foreach(GFunc func, gpointer user_data);
 
91
 
 
92
void
 
93
client_list_remove(struct client *client);
 
94
 
 
95
void
 
96
client_close(struct client *client);
 
97
 
 
98
static inline void
 
99
new_cmd_list_ptr(struct client *client, const char *s)
 
100
{
 
101
        client->cmd_list = g_slist_prepend(client->cmd_list, g_strdup(s));
 
102
}
 
103
 
 
104
static inline void
 
105
free_cmd_list(GSList *list)
 
106
{
 
107
        for (GSList *tmp = list; tmp != NULL; tmp = g_slist_next(tmp))
 
108
                g_free(tmp->data);
 
109
 
 
110
        g_slist_free(list);
 
111
}
 
112
 
 
113
void
 
114
client_set_expired(struct client *client);
 
115
 
 
116
/**
 
117
 * Schedule an "expired" check for all clients: permanently delete
 
118
 * clients which have been set "expired" with client_set_expired().
 
119
 */
 
120
void
 
121
client_schedule_expire(void);
 
122
 
 
123
/**
 
124
 * Removes a scheduled "expired" check.
 
125
 */
 
126
void
 
127
client_deinit_expire(void);
 
128
 
 
129
enum command_return
 
130
client_read(struct client *client);
 
131
 
 
132
enum command_return
 
133
client_process_line(struct client *client, char *line);
 
134
 
 
135
void
 
136
client_write_deferred(struct client *client);
 
137
 
 
138
void
 
139
client_write_output(struct client *client);
 
140
 
 
141
gboolean
 
142
client_in_event(GIOChannel *source, GIOCondition condition,
 
143
                gpointer data);
 
144
 
 
145
#endif