pianod2
multisource multiuser scriptable networked music player
Classes | Namespaces | Macros | Typedefs | Functions | Variables
user.cpp File Reference

User data, privileges, details and preferences implementation. More...

#include <config.h>
#include <cstdio>
#include <cassert>
#include <unistd.h>
#include <sys/types.h>
#include <string>
#include "parsnip/parsnip.h"
#include "enum.h"
#include "datastore.h"
#include "user.h"
#include "logging.h"
#include "utility.h"
#include "connection.h"
Include dependency graph for user.cpp:

Classes

struct  privileges_t
 

Namespaces

 userconfig
 Dictionary names for user data file.
 

Macros

#define countof(x)   (sizeof (x) / sizeof (*x))
 

Typedefs

typedef struct privileges_t PRIVILEGES
 

Functions

static const char * encrypt_password (const char *password)
 Encrypt a password. More...
 
static std::string dataKey (const std::string &origin, const std::string &identity)
 

Variables

const char * userconfig::user_node_name = "name"
 
const char * userconfig::user_node_password = "password"
 
const char * userconfig::user_node_rank = "rank"
 
const char * userconfig::user_privileges = "privileges"
 
const char * userconfig::user_privilege = "privilege"
 
const char * userconfig::privilege_name = "name"
 
const char * userconfig::privilege_enable = "granted"
 
const char * userconfig::privilege_enabled = "true"
 
const char * userconfig::privilege_disabled = "false"
 
const char * userconfig::user_data = "preferences"
 
const LookupTable< RankRanking ({ { "disabled", Rank::None }, { "listener", Rank::Listener }, { "user", Rank::Standard }, { "admin", Rank::Administrator } })
 
static const PRIVILEGES privilege_def []
 
const LookupTable< Privilege, PRIVILEGESPrivileges (privilege_def)
 Enumeration to text translation for user privileges. More...
 

Detailed Description

User data, privileges, details and preferences implementation.

Macro Definition Documentation

◆ countof

#define countof (   x)    (sizeof (x) / sizeof (*x))

Typedef Documentation

◆ PRIVILEGES

typedef struct privileges_t PRIVILEGES

Function Documentation

◆ dataKey()

static std::string dataKey ( const std::string &  origin,
const std::string &  identity 
)
static
Here is the caller graph for this function:

◆ encrypt_password()

static const char* encrypt_password ( const char *  password)
static

Encrypt a password.

Parameters
passwordthe password to encrypt.
Returns
The encrypted password.
Warning
Returned password is stored in a static buffer that is reused in successive calls.
Here is the caller graph for this function:

Variable Documentation

◆ privilege_def

const PRIVILEGES privilege_def[]
static
Initial value:
= {
{ "shadow", Privilege::Shadow, false, true },
{ "service", Privilege::Service, false, true },
{ "deejay", Privilege::Queue, false, true },
{ "influence", Privilege::Influence, true, true },
{ "tuner", Privilege::Tuner, false, true },
{ "present", Privilege::Present, false, true },
{ NULL }
}
@ Tuner
User may set other users' presence, for autotuning.
@ Shadow
Attribute: User was created automatically, shadowing a user account.
@ Queue
User may queue or cancel songs. (Automatic for standard rank.)
@ Service
User may add or remove sources. (Automatic for admin rank.)
@ Influence
User's playlist preferences influence autotuning selections.
@ Present
Attribute: Consider user present, even if not logged in.

◆ Privileges

Enumeration to text translation for user privileges.

◆ Ranking

const LookupTable<Rank> Ranking({ { "disabled", Rank::None }, { "listener", Rank::Listener }, { "user", Rank::Standard }, { "admin", Rank::Administrator } }) ( { { "disabled", Rank::None }, { "listener", Rank::Listener }, { "user", Rank::Standard }, { "admin", Rank::Administrator } }  )