MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

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

## 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

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

void Client::Close | ( |  | ) |

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

Wrapper for Instance::GetDatabase().

gcc_pure 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

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
| inline

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
| inline

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:

- client/Client.hxx