MPD  0.20.18
Public Types | Public Member Functions | Data Fields
Client Class Referencefinal

#include <Client.hxx>

Inheritance diagram for Client:
[legend]
Collaboration diagram for Client:
[legend]

Public Types

enum  SubscribeResult { SubscribeResult::OK, SubscribeResult::INVALID, SubscribeResult::ALREADY, SubscribeResult::FULL }
 

Public Member Functions

 Client (EventLoop &loop, Partition &partition, int fd, int uid, int num)
 
 ~Client ()
 
bool IsConnected () const
 
gcc_pure bool IsExpired () const noexcept
 
void Close ()
 
void SetExpired ()
 
bool Write (const void *data, size_t length)
 
bool Write (const char *data)
 Write a null-terminated string. More...
 
int GetUID () const
 returns the uid of the client process, or a negative value if the uid is unknown More...
 
bool IsLocal () const
 Is this client running on the same machine, connected with a local (UNIX domain) socket? More...
 
unsigned GetPermission () const
 
void SetPermission (unsigned _permission)
 
void IdleNotify ()
 Send "idle" response to this client. More...
 
void IdleAdd (unsigned flags)
 
bool IdleWait (unsigned flags)
 
gcc_pure bool IsSubscribed (const char *channel_name) const noexcept
 
SubscribeResult Subscribe (const char *channel)
 
bool Unsubscribe (const char *channel)
 
void UnsubscribeAll ()
 
bool PushMessage (const ClientMessage &msg)
 
void AllowFile (Path path_fs) const
 Is this client allowed to use the specified local file? More...
 
gcc_pure const DatabaseGetDatabase () const noexcept
 Wrapper for Instance::GetDatabase(). More...
 
const DatabaseGetDatabaseOrThrow () const
 Wrapper for Instance::GetDatabaseOrThrow(). More...
 
gcc_pure const StorageGetStorage () const noexcept
 

Data Fields

Partitionpartition
 
struct playlistplaylist
 
struct PlayerControlplayer_control
 
unsigned permission
 
int uid
 the uid of the client process, or -1 if unknown More...
 
CommandListBuilder cmd_list
 
unsigned int num
 
bool idle_waiting
 is this client waiting for an "idle" response? More...
 
unsigned idle_flags
 idle flags pending on this client, to be sent as soon as the client enters "idle" More...
 
unsigned idle_subscriptions
 idle flags that the client wants to receive More...
 
std::set< std::string > subscriptions
 A list of channel names this client is subscribed to. More...
 
unsigned num_subscriptions
 The number of subscriptions in subscriptions. More...
 
std::list< ClientMessagemessages
 A list of messages this client has received. More...
 

Detailed Description

Definition at line 47 of file Client.hxx.

Member Enumeration Documentation

Enumerator
OK 

success

INVALID 

invalid channel name

ALREADY 

already subscribed to this channel

FULL 

too many subscriptions

Definition at line 148 of file Client.hxx.

Constructor & Destructor Documentation

Client::Client ( EventLoop loop,
Partition partition,
int  fd,
int  uid,
int  num 
)
Client::~Client ( )
inline

Definition at line 93 of file Client.hxx.

Member Function Documentation

void Client::AllowFile ( Path  path_fs) const

Is this client allowed to use the specified local file?

Note that this function is vulnerable to timing/symlink attacks. We cannot fix this as long as there are plugins that open a file by its name, and not by file descriptor / callbacks.

Throws #std::runtime_error on error.

Parameters
path_fsthe absolute path name in filesystem encoding
void Client::Close ( )
gcc_pure const Database* Client::GetDatabase ( ) const
noexcept

Wrapper for Instance::GetDatabase().

const Database& Client::GetDatabaseOrThrow ( ) const

Wrapper for Instance::GetDatabaseOrThrow().

unsigned Client::GetPermission ( ) const
inline

Definition at line 133 of file Client.hxx.

gcc_pure const Storage* Client::GetStorage ( ) const
noexcept
int Client::GetUID ( ) const
inline

returns the uid of the client process, or a negative value if the uid is unknown

Definition at line 121 of file Client.hxx.

void Client::IdleAdd ( unsigned  flags)
void Client::IdleNotify ( )

Send "idle" response to this client.

bool Client::IdleWait ( unsigned  flags)
bool Client::IsConnected ( ) const
inline

Definition at line 98 of file Client.hxx.

gcc_pure bool Client::IsExpired ( ) const
inlinenoexcept

Definition at line 103 of file Client.hxx.

bool Client::IsLocal ( ) const
inline

Is this client running on the same machine, connected with a local (UNIX domain) socket?

Definition at line 129 of file Client.hxx.

gcc_pure bool Client::IsSubscribed ( const char *  channel_name) const
inlinenoexcept

Definition at line 163 of file Client.hxx.

bool Client::PushMessage ( const ClientMessage msg)
void Client::SetExpired ( )
void Client::SetPermission ( unsigned  _permission)
inline

Definition at line 137 of file Client.hxx.

SubscribeResult Client::Subscribe ( const char *  channel)
bool Client::Unsubscribe ( const char *  channel)
void Client::UnsubscribeAll ( )
bool Client::Write ( const void *  data,
size_t  length 
)
bool Client::Write ( const char *  data)

Write a null-terminated string.

Field Documentation

CommandListBuilder Client::cmd_list

Definition at line 60 of file Client.hxx.

unsigned Client::idle_flags

idle flags pending on this client, to be sent as soon as the client enters "idle"

Definition at line 69 of file Client.hxx.

unsigned Client::idle_subscriptions

idle flags that the client wants to receive

Definition at line 72 of file Client.hxx.

bool Client::idle_waiting

is this client waiting for an "idle" response?

Definition at line 65 of file Client.hxx.

std::list<ClientMessage> Client::messages

A list of messages this client has received.

Definition at line 88 of file Client.hxx.

unsigned int Client::num

Definition at line 62 of file Client.hxx.

unsigned Client::num_subscriptions

The number of subscriptions in subscriptions.

Used to limit the number of subscriptions.

Definition at line 83 of file Client.hxx.

Partition& Client::partition

Definition at line 51 of file Client.hxx.

unsigned Client::permission

Definition at line 55 of file Client.hxx.

struct PlayerControl& Client::player_control

Definition at line 53 of file Client.hxx.

struct playlist& Client::playlist

Definition at line 52 of file Client.hxx.

std::set<std::string> Client::subscriptions

A list of channel names this client is subscribed to.

Definition at line 77 of file Client.hxx.

int Client::uid

the uid of the client process, or -1 if unknown

Definition at line 58 of file Client.hxx.


The documentation for this class was generated from the following file: