Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
32645b80
Commit
32645b80
authored
Oct 19, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ClientInternal: move class Client to Client.hxx
Publish the Client API, preparing to move more code into the Client class.
parent
ff626ac7
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
96 additions
and
98 deletions
+96
-98
Client.hxx
src/Client.hxx
+89
-1
ClientInternal.hxx
src/ClientInternal.hxx
+0
-90
DatabaseCommands.cxx
src/DatabaseCommands.cxx
+1
-1
MessageCommands.cxx
src/MessageCommands.cxx
+1
-1
OtherCommands.cxx
src/OtherCommands.cxx
+1
-1
PlayerCommands.cxx
src/PlayerCommands.cxx
+1
-1
PlaylistCommands.cxx
src/PlaylistCommands.cxx
+1
-1
QueueCommands.cxx
src/QueueCommands.cxx
+1
-1
Stats.cxx
src/Stats.cxx
+1
-1
No files found.
src/Client.hxx
View file @
32645b80
...
...
@@ -20,15 +20,103 @@
#ifndef MPD_CLIENT_H
#define MPD_CLIENT_H
#include "check.h"
#include "ClientMessage.hxx"
#include "CommandListBuilder.hxx"
#include "event/FullyBufferedSocket.hxx"
#include "event/TimeoutMonitor.hxx"
#include "Compiler.h"
#include <set>
#include <string>
#include <list>
#include <stddef.h>
#include <stdarg.h>
struct
sockaddr
;
class
EventLoop
;
struct
Partition
;
class
Client
;
class
Client
final
:
private
FullyBufferedSocket
,
TimeoutMonitor
{
public
:
Partition
&
partition
;
struct
playlist
&
playlist
;
struct
player_control
&
player_control
;
unsigned
permission
;
/** the uid of the client process, or -1 if unknown */
int
uid
;
CommandListBuilder
cmd_list
;
unsigned
int
num
;
/* client number */
/** is this client waiting for an "idle" response? */
bool
idle_waiting
;
/** idle flags pending on this client, to be sent as soon as
the client enters "idle" */
unsigned
idle_flags
;
/** idle flags that the client wants to receive */
unsigned
idle_subscriptions
;
/**
* A list of channel names this client is subscribed to.
*/
std
::
set
<
std
::
string
>
subscriptions
;
/**
* The number of subscriptions in #subscriptions. Used to
* limit the number of subscriptions.
*/
unsigned
num_subscriptions
;
/**
* A list of messages this client has received.
*/
std
::
list
<
ClientMessage
>
messages
;
Client
(
EventLoop
&
loop
,
Partition
&
partition
,
int
fd
,
int
uid
,
int
num
);
bool
IsConnected
()
const
{
return
FullyBufferedSocket
::
IsDefined
();
}
gcc_pure
bool
IsSubscribed
(
const
char
*
channel_name
)
const
{
return
subscriptions
.
find
(
channel_name
)
!=
subscriptions
.
end
();
}
gcc_pure
bool
IsExpired
()
const
{
return
!
FullyBufferedSocket
::
IsDefined
();
}
void
Close
();
void
SetExpired
();
using
FullyBufferedSocket
::
Write
;
/**
* Send "idle" response to this client.
*/
void
IdleNotify
();
void
IdleAdd
(
unsigned
flags
);
bool
IdleWait
(
unsigned
flags
);
private
:
/* virtual methods from class BufferedSocket */
virtual
InputResult
OnSocketInput
(
void
*
data
,
size_t
length
)
override
;
virtual
void
OnSocketError
(
Error
&&
error
)
override
;
virtual
void
OnSocketClosed
()
override
;
/* virtual methods from class TimeoutMonitor */
virtual
void
OnTimeout
()
override
;
};
void
client_manager_init
(
void
);
...
...
src/ClientInternal.hxx
View file @
32645b80
...
...
@@ -22,103 +22,13 @@
#include "check.h"
#include "Client.hxx"
#include "ClientMessage.hxx"
#include "CommandListBuilder.hxx"
#include "event/FullyBufferedSocket.hxx"
#include "event/TimeoutMonitor.hxx"
#include "command.h"
#include <set>
#include <string>
#include <list>
enum
{
CLIENT_MAX_SUBSCRIPTIONS
=
16
,
CLIENT_MAX_MESSAGES
=
64
,
};
struct
Partition
;
class
Client
final
:
private
FullyBufferedSocket
,
TimeoutMonitor
{
public
:
Partition
&
partition
;
struct
playlist
&
playlist
;
struct
player_control
&
player_control
;
unsigned
permission
;
/** the uid of the client process, or -1 if unknown */
int
uid
;
CommandListBuilder
cmd_list
;
unsigned
int
num
;
/* client number */
/** is this client waiting for an "idle" response? */
bool
idle_waiting
;
/** idle flags pending on this client, to be sent as soon as
the client enters "idle" */
unsigned
idle_flags
;
/** idle flags that the client wants to receive */
unsigned
idle_subscriptions
;
/**
* A list of channel names this client is subscribed to.
*/
std
::
set
<
std
::
string
>
subscriptions
;
/**
* The number of subscriptions in #subscriptions. Used to
* limit the number of subscriptions.
*/
unsigned
num_subscriptions
;
/**
* A list of messages this client has received.
*/
std
::
list
<
ClientMessage
>
messages
;
Client
(
EventLoop
&
loop
,
Partition
&
partition
,
int
fd
,
int
uid
,
int
num
);
bool
IsConnected
()
const
{
return
FullyBufferedSocket
::
IsDefined
();
}
gcc_pure
bool
IsSubscribed
(
const
char
*
channel_name
)
const
{
return
subscriptions
.
find
(
channel_name
)
!=
subscriptions
.
end
();
}
gcc_pure
bool
IsExpired
()
const
{
return
!
FullyBufferedSocket
::
IsDefined
();
}
void
Close
();
void
SetExpired
();
using
FullyBufferedSocket
::
Write
;
/**
* Send "idle" response to this client.
*/
void
IdleNotify
();
void
IdleAdd
(
unsigned
flags
);
bool
IdleWait
(
unsigned
flags
);
private
:
/* virtual methods from class BufferedSocket */
virtual
InputResult
OnSocketInput
(
void
*
data
,
size_t
length
)
override
;
virtual
void
OnSocketError
(
Error
&&
error
)
override
;
virtual
void
OnSocketClosed
()
override
;
/* virtual methods from class TimeoutMonitor */
virtual
void
OnTimeout
()
override
;
};
extern
const
class
Domain
client_domain
;
extern
int
client_timeout
;
...
...
src/DatabaseCommands.cxx
View file @
32645b80
...
...
@@ -24,7 +24,7 @@
#include "DatabasePrint.hxx"
#include "DatabaseSelection.hxx"
#include "CommandError.hxx"
#include "Client
Internal
.hxx"
#include "Client.hxx"
#include "tag/Tag.hxx"
#include "util/UriUtil.hxx"
#include "util/Error.hxx"
...
...
src/MessageCommands.cxx
View file @
32645b80
...
...
@@ -20,7 +20,7 @@
#include "config.h"
#include "MessageCommands.hxx"
#include "ClientSubscribe.hxx"
#include "Client
Internal
.hxx"
#include "Client.hxx"
#include "ClientList.hxx"
#include "Instance.hxx"
#include "Main.hxx"
...
...
src/OtherCommands.cxx
View file @
32645b80
...
...
@@ -40,7 +40,7 @@
#include "Permission.hxx"
#include "PlaylistFile.hxx"
#include "ClientFile.hxx"
#include "Client
Internal
.hxx"
#include "Client.hxx"
#include "Idle.hxx"
#ifdef ENABLE_SQLITE
...
...
src/PlayerCommands.cxx
View file @
32645b80
...
...
@@ -23,7 +23,7 @@
#include "Playlist.hxx"
#include "PlaylistPrint.hxx"
#include "UpdateGlue.hxx"
#include "Client
Internal
.hxx"
#include "Client.hxx"
#include "Volume.hxx"
#include "OutputAll.hxx"
#include "Partition.hxx"
...
...
src/PlaylistCommands.cxx
View file @
32645b80
...
...
@@ -27,7 +27,7 @@
#include "PlaylistVector.hxx"
#include "PlaylistQueue.hxx"
#include "TimePrint.hxx"
#include "Client
Internal
.hxx"
#include "Client.hxx"
#include "protocol/ArgParser.hxx"
#include "protocol/Result.hxx"
#include "ls.hxx"
...
...
src/QueueCommands.cxx
View file @
32645b80
...
...
@@ -26,7 +26,7 @@
#include "Playlist.hxx"
#include "PlaylistPrint.hxx"
#include "ClientFile.hxx"
#include "Client
Internal
.hxx"
#include "Client.hxx"
#include "Partition.hxx"
#include "protocol/ArgParser.hxx"
#include "protocol/Result.hxx"
...
...
src/Stats.cxx
View file @
32645b80
...
...
@@ -20,7 +20,7 @@
#include "config.h"
#include "Stats.hxx"
#include "PlayerControl.hxx"
#include "Client
Internal
.hxx"
#include "Client.hxx"
#include "DatabaseSelection.hxx"
#include "DatabaseGlue.hxx"
#include "DatabasePlugin.hxx"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment