2020-05-08 12:43:46 +02:00
|
|
|
#ifndef LAUNCHER_H
|
|
|
|
#define LAUNCHER_H
|
|
|
|
#include <iostream>
|
|
|
|
#include <data_acces.h>
|
|
|
|
class session_manager
|
|
|
|
{
|
|
|
|
public:
|
2020-06-01 23:23:23 +02:00
|
|
|
/**
|
|
|
|
* @brief session_manager::session_manager
|
|
|
|
* Object that guide a session
|
|
|
|
* @param fd Client flie descriptor
|
|
|
|
*/
|
2020-05-08 12:43:46 +02:00
|
|
|
session_manager(int fd);
|
2020-06-01 23:23:23 +02:00
|
|
|
/**
|
|
|
|
* @brief start_dialog
|
|
|
|
* Start the default state, ready to listen petitions
|
|
|
|
*/
|
2020-05-08 12:43:46 +02:00
|
|
|
void start_dialog();
|
2020-06-01 23:23:23 +02:00
|
|
|
/**
|
|
|
|
* @brief generate_package
|
|
|
|
* Generate a package
|
|
|
|
* @return Positive if the package has been installed well
|
|
|
|
*/
|
|
|
|
int generate_package();
|
|
|
|
/**
|
|
|
|
* @brief remove
|
|
|
|
* Remove a package
|
|
|
|
* @return Positive if the package has been removed well
|
|
|
|
*/
|
2020-05-15 21:39:23 +02:00
|
|
|
int remove();
|
2020-06-01 23:23:23 +02:00
|
|
|
/**
|
|
|
|
* @brief send_information
|
|
|
|
* Send the actual packages generated whit these aplication
|
|
|
|
*/
|
2020-05-08 12:43:46 +02:00
|
|
|
void send_information();
|
2020-06-01 23:23:23 +02:00
|
|
|
/**
|
|
|
|
* @brief send_user_info
|
|
|
|
* Send the list of generated users and the privileges
|
|
|
|
*/
|
2020-05-20 00:10:05 +02:00
|
|
|
void send_user_info();
|
2020-06-01 23:23:23 +02:00
|
|
|
/**
|
|
|
|
* @brief validate_pass
|
|
|
|
* Recive an user and password and check if these mach with the users database
|
|
|
|
* @return If the pass mach with the user, return true, if not, return false
|
|
|
|
*/
|
2020-05-08 12:43:46 +02:00
|
|
|
bool validate_pass();
|
2020-06-01 23:23:23 +02:00
|
|
|
/**
|
|
|
|
* @brief create_user
|
|
|
|
* Recive an user and password to create a user
|
|
|
|
*/
|
2020-05-21 20:57:18 +02:00
|
|
|
void create_user();
|
2020-06-01 23:23:23 +02:00
|
|
|
/**
|
|
|
|
* @brief remove_user
|
|
|
|
* Recive a user to remove it
|
|
|
|
*/
|
2020-05-26 01:37:34 +02:00
|
|
|
void remove_user();
|
2020-05-08 12:43:46 +02:00
|
|
|
private:
|
2020-06-01 23:23:23 +02:00
|
|
|
/**
|
|
|
|
* @brief appli_command
|
|
|
|
* Execute emerge with the passed parameter
|
|
|
|
* @param comand Parameter that recive emerge
|
|
|
|
* @param n_package Name ot the package
|
|
|
|
* @return The name of the package or err if he process fail
|
|
|
|
*/
|
2020-05-15 21:39:23 +02:00
|
|
|
std::string appli_command(char comand[], char* n_package);
|
2020-06-01 23:23:23 +02:00
|
|
|
/**
|
|
|
|
* @brief read_data
|
|
|
|
* Recive data from a socket
|
|
|
|
* @param input Buffer to deposite the info
|
|
|
|
* @param size Max size of a info readed
|
|
|
|
* @return Number of bytes readed
|
|
|
|
*/
|
2020-05-08 12:43:46 +02:00
|
|
|
virtual int read_data(char* input, int size);
|
2020-06-01 23:23:23 +02:00
|
|
|
/**
|
|
|
|
* @brief write_data
|
|
|
|
* Write data using a socket
|
|
|
|
* @param output
|
|
|
|
* String to have te info to send
|
|
|
|
* @return Number of bytes writed
|
|
|
|
*/
|
2020-05-08 12:43:46 +02:00
|
|
|
virtual int write_data(std::string output);
|
|
|
|
int fd;
|
|
|
|
data_acces* data;
|
2020-05-15 21:39:23 +02:00
|
|
|
std::string user;
|
2020-05-27 13:15:06 +02:00
|
|
|
bool admin;
|
2020-06-02 15:22:47 +02:00
|
|
|
std::string env;
|
2020-05-08 12:43:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LAUNCHER_H
|