MPD: Client Class Reference

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 Database * | GetDatabase () const noexcept
| Wrapper for Instance::GetDatabase(). More...
const Database & | GetDatabaseOrThrow () const
| Wrapper for Instance::GetDatabaseOrThrow(). More...
gcc_pure const Storage * | GetStorage () const noexcept

## Data Fields
Partition & | partition
struct playlist & | playlist
struct PlayerControl & | player_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< ClientMessage > | messages
| A list of messages this client has received. More...

## Detailed Description

Definition at line 47 of file Client.hxx.

## Member Enumeration Documentation

## ◆ SubscribeResult

enum Client::SubscribeResult
| strong

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::Client | ( | EventLoop & | loop,
|  | Partition & | partition,
|  | int | fd,
|  | int | uid,
|  | int | num
| ) |  |

## ◆ ~Client()

Client::~Client | ( |  | ) |
| inline

Definition at line 93 of file Client.hxx.

## Member Function Documentation

## ◆ AllowFile()

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_fs | the absolute path name in filesystem encoding

## ◆ Close()

void Client::Close | ( |  | ) |

## ◆ GetDatabase()

gcc_pure const Database* Client::GetDatabase | ( |  | ) | const
| noexcept

Wrapper for Instance::GetDatabase().

## ◆ GetDatabaseOrThrow()

const Database& Client::GetDatabaseOrThrow | ( |  | ) | const

Wrapper for Instance::GetDatabaseOrThrow().

## ◆ GetPermission()

unsigned Client::GetPermission | ( |  | ) | const
| inline

Definition at line 133 of file Client.hxx.

## ◆ GetStorage()

gcc_pure const Storage* Client::GetStorage | ( |  | ) | const
| noexcept

## ◆ GetUID()

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.

## ◆ IdleAdd()

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

## ◆ IdleNotify()

void Client::IdleNotify | ( |  | ) |

Send "idle" response to this client.

## ◆ IdleWait()

bool Client::IdleWait | ( | unsigned | flags | ) |

## ◆ IsConnected()

bool Client::IsConnected | ( |  | ) | const
| inline

Definition at line 98 of file Client.hxx.

## ◆ IsExpired()

gcc_pure bool Client::IsExpired | ( |  | ) | const
| inlinenoexcept

Definition at line 103 of file Client.hxx.

## ◆ IsLocal()

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.

## ◆ IsSubscribed()

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

Definition at line 163 of file Client.hxx.

## ◆ PushMessage()

bool Client::PushMessage | ( | const ClientMessage & | msg | ) |

## ◆ SetExpired()

void Client::SetExpired | ( |  | ) |

## ◆ SetPermission()

void Client::SetPermission | ( | unsigned | _permission | ) |
| inline

Definition at line 137 of file Client.hxx.

## ◆ Subscribe()

SubscribeResult Client::Subscribe | ( | const char * | channel | ) |

## ◆ Unsubscribe()

bool Client::Unsubscribe | ( | const char * | channel | ) |

## ◆ UnsubscribeAll()

void Client::UnsubscribeAll | ( |  | ) |

## ◆ Write() [1/2]

bool Client::Write | ( | const void * | data,
|  | size_t | length
| ) |  |

## ◆ Write() [2/2]

bool Client::Write | ( | const char * | data | ) |

Write a null-terminated string.

## Field Documentation

## ◆ cmd_list

CommandListBuilder Client::cmd_list

Definition at line 60 of file Client.hxx.

## ◆ idle_flags

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.

## ◆ idle_subscriptions

unsigned Client::idle_subscriptions

idle flags that the client wants to receive

Definition at line 72 of file Client.hxx.

## ◆ idle_waiting

bool Client::idle_waiting

is this client waiting for an "idle" response?

Definition at line 65 of file Client.hxx.

## ◆ messages

std::list<ClientMessage> Client::messages

A list of messages this client has received.

Definition at line 88 of file Client.hxx.

## ◆ num

unsigned int Client::num

Definition at line 62 of file Client.hxx.

## ◆ num_subscriptions

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

Partition& Client::partition

Definition at line 51 of file Client.hxx.

## ◆ permission

unsigned Client::permission

Definition at line 55 of file Client.hxx.

## ◆ player_control

struct PlayerControl& Client::player_control

Definition at line 53 of file Client.hxx.

## ◆ playlist

struct playlist& Client::playlist

Definition at line 52 of file Client.hxx.

## ◆ subscriptions

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

A list of channel names this client is subscribed to.

Definition at line 77 of file Client.hxx.

## ◆ uid

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:

- client/Client.hxx