2020-05-13 00:56:26 +02:00
|
|
|
#ifndef SESSION_MANAGER_H
|
|
|
|
#define SESSION_MANAGER_H
|
|
|
|
|
|
|
|
#include "conexion.h"
|
|
|
|
|
|
|
|
#include <string>
|
2020-05-19 20:34:51 +02:00
|
|
|
#include <list>
|
2020-05-13 00:56:26 +02:00
|
|
|
|
|
|
|
class session_manager
|
|
|
|
{
|
|
|
|
public:
|
2020-06-01 23:24:24 +02:00
|
|
|
/**
|
|
|
|
* @brief session_manager
|
|
|
|
* Object that manage the session, and gide on it
|
|
|
|
* @param con Conexion of the session
|
|
|
|
*/
|
2020-05-13 00:56:26 +02:00
|
|
|
session_manager(conexion* con);
|
2020-06-01 23:24:24 +02:00
|
|
|
/**
|
|
|
|
* @brief loggin
|
|
|
|
* Loggin function
|
|
|
|
* @param username Username to try to start session
|
|
|
|
* @param passwd Password to the user
|
|
|
|
* @return True if the username have these password, false if not or the user not exists
|
|
|
|
*/
|
2020-05-13 00:56:26 +02:00
|
|
|
bool loggin(std::string username, std::string passwd);
|
2020-06-01 23:24:24 +02:00
|
|
|
/**
|
|
|
|
* @brief admin
|
|
|
|
* Get user privileges
|
|
|
|
* @return true if the admin can manage other users, false if not
|
|
|
|
*/
|
2020-05-26 18:47:14 +02:00
|
|
|
bool admin();
|
2020-06-01 23:24:24 +02:00
|
|
|
/**
|
|
|
|
* @brief install_command
|
|
|
|
* Send name of the package to build
|
|
|
|
* @param package Name of the package
|
|
|
|
* @return positive if it is build well, or negative if not
|
|
|
|
*/
|
2020-05-13 00:56:26 +02:00
|
|
|
int install_command(std::string package);
|
2020-06-01 23:24:24 +02:00
|
|
|
/**
|
|
|
|
* @brief remove_command
|
|
|
|
* Send name of the package to remove
|
|
|
|
* @param package Name of the package
|
|
|
|
* @return positive if it is removed well, or negative if not
|
|
|
|
*/
|
2020-05-16 20:52:10 +02:00
|
|
|
int remove_command(std::string package);
|
2020-06-01 23:24:24 +02:00
|
|
|
/**
|
|
|
|
* @brief get_packages_info
|
|
|
|
* Get all packages information
|
|
|
|
* @return List of strings that contains all package information.
|
|
|
|
* Every package have the information separated with the sepacial character ":"
|
|
|
|
*/
|
2020-05-19 20:34:51 +02:00
|
|
|
std::list<std::string> get_packages_info();
|
2020-06-01 23:24:24 +02:00
|
|
|
/**
|
|
|
|
* @brief get_users_info
|
|
|
|
* Get all users username and privileges
|
|
|
|
* @return List of strings that contains all users information.
|
|
|
|
* Every users have the username first, and after separated with a ":"
|
|
|
|
* a t or a f, t if they have privileges or f if not
|
|
|
|
*/
|
2020-05-20 00:09:18 +02:00
|
|
|
std::list<std::string> get_users_info();
|
2020-06-01 23:24:24 +02:00
|
|
|
/**
|
|
|
|
* @brief create_user
|
|
|
|
* Create a new user
|
|
|
|
* @param username Username for a new user
|
|
|
|
* @param password Password for a new user
|
|
|
|
* @param admin Privileges of a new user
|
|
|
|
*/
|
2020-05-23 19:59:55 +02:00
|
|
|
void create_user(std::string username, std::string password, bool admin);
|
2020-06-01 23:24:24 +02:00
|
|
|
/**
|
|
|
|
* @brief remove_user
|
|
|
|
* Remove a created user
|
|
|
|
* @param username Name of these
|
|
|
|
*/
|
2020-05-26 01:37:11 +02:00
|
|
|
void remove_user(std::string username);
|
2020-06-01 23:24:24 +02:00
|
|
|
private:
|
|
|
|
conexion* con;
|
2020-05-13 00:56:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SESSION_MANAGER_H
|