pianod2
multisource multiuser scriptable networked music player
Macros | Typedefs | Enumerations | Functions
usercommand.cpp File Reference

Command handlers for all things user-related. More...

#include <config.h>
#include <cstdio>
#include <cassert>
#include <vector>
#include <football/football.h>
#include <parsnip/parsnip.h>
#include <parsnip/parsnip_command.h>
#include <parsnip/parsnip_schema.h>
#include "fundamentals.h"
#include "utility.h"
#include "enum.h"
#include "interpreter.h"
#include "response.h"
#include "user.h"
#include "users.h"
#include "servicemanager.h"
#include "mediamanager.h"
#include "engine.h"
Include dependency graph for usercommand.cpp:

Macros

#define RANK_PATTERN   "<rank:disabled|listener|user|admin>"
 
#define PRIV_PATTERN   "<privilege:service|deejay|influence|tuner>"
 

Typedefs

typedef enum user_commands_t COMMAND
 

Enumerations

enum  user_commands_t {
  AUTHENTICATE = CMD_RANGE_USER , AUTHANDEXEC , SETMYPASSWORD , USESHADOWPASSWORD ,
  USERCREATE , USERSETPASSWORD , GETVISITORRANK , SETVISITORRANK ,
  GETSHADOWUSERNAME , SETSHADOWUSERNAME , GETUSERRANK , USERSETRANK ,
  USERDELETE , USERGRANT , USERREVOKE , USERLISTBYPRIVILEGE ,
  USERLIST , USERKICK , USERKICKVISITORS , USERSONLINE ,
  USERSINROOM , AUTOTUNEUSERS , AUTOTUNEUSERSLIST , AUTOTUNEADDREMOVE
}
 

Functions

Response send_privileges (const User *user)
 Assemble a user's privileges into a response. More...
 
static CommandReply validate_user_list (const std::vector< std::string > &users)
 Check a list of users and record errors. More...
 
static void set_privileges (const std::vector< std::string > &users, Privilege priv, bool setting)
 Set the requested privilege for a list of users. More...
 
ResponseGroup send_user (const User *user, bool details)
 Return a user record in transmittable form, either just name or with details. More...
 
static DataResponse send_users (UserList which, bool details)
 Prepare lists of users for transmission based on privilege or state criteria. More...
 
static DataResponse send_users (PianodConnection &conn, UserList which)
 Prepare lists of users for transmission. More...
 
static bool user_logoff (PianodService *service, User *user, const std::string &message)
 Logoff users. More...
 

Detailed Description

Command handlers for all things user-related.

Macro Definition Documentation

◆ PRIV_PATTERN

#define PRIV_PATTERN   "<privilege:service|deejay|influence|tuner>"

◆ RANK_PATTERN

#define RANK_PATTERN   "<rank:disabled|listener|user|admin>"

Typedef Documentation

◆ COMMAND

typedef enum user_commands_t COMMAND

Enumeration Type Documentation

◆ user_commands_t

Enumerator
AUTHENTICATE 
AUTHANDEXEC 
SETMYPASSWORD 
USESHADOWPASSWORD 
USERCREATE 
USERSETPASSWORD 
GETVISITORRANK 
SETVISITORRANK 
GETSHADOWUSERNAME 
SETSHADOWUSERNAME 
GETUSERRANK 
USERSETRANK 
USERDELETE 
USERGRANT 
USERREVOKE 
USERLISTBYPRIVILEGE 
USERLIST 
USERKICK 
USERKICKVISITORS 
USERSONLINE 
USERSINROOM 
AUTOTUNEUSERS 
AUTOTUNEUSERSLIST 
AUTOTUNEADDREMOVE 

Function Documentation

◆ send_privileges()

Response send_privileges ( const User user)

Assemble a user's privileges into a response.

Parameters
userUser whose privileges to send.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_user()

ResponseGroup send_user ( const User user,
bool  details 
)

Return a user record in transmittable form, either just name or with details.

Parameters
userThe user to send information of.
detailsWhether to send privileges, etc.
Returns
User details arranged for transmittal.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_users() [1/2]

static DataResponse send_users ( PianodConnection conn,
UserList  which 
)
static

Prepare lists of users for transmission.

Parameters
connThe connection to which the tranmission is being sent. If an administrator, details are included; otherwise omitted.
whichA list of users to send.
Returns
User details arranged for transmittal.
Here is the call graph for this function:

◆ send_users() [2/2]

static DataResponse send_users ( UserList  which,
bool  details 
)
static

Prepare lists of users for transmission based on privilege or state criteria.

Warning
The pseudoenumeration values for which must not overlap.
Parameters
whichA list of users to send.
detailsWhether to include privileged information in the list.
Returns
User details arranged for transmittal.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_privileges()

static void set_privileges ( const std::vector< std::string > &  users,
Privilege  priv,
bool  setting 
)
static

Set the requested privilege for a list of users.

Parameters
usersA list of usernames.
privThe privileges to set.
settingWhether to enable (true) or disable (false).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ user_logoff()

static bool user_logoff ( PianodService service,
User user,
const std::string &  message 
)
static

Logoff users.

Parameters
serviceThe service/room to logoff user in, or null to logoff everywhere.
userThe user to logoff, or nullptr to logoff visitors/unauthenticated users.
messageAn optional message to send before disconnecting.
Here is the caller graph for this function:

◆ validate_user_list()

static CommandReply validate_user_list ( const std::vector< std::string > &  users)
static

Check a list of users and record errors.

Parameters
usersThe list of users.
Returns
A CommandReply recording any invalid users encountered.
Here is the call graph for this function:
Here is the caller graph for this function: