#ifndef LAUNCHER_H #define LAUNCHER_H #include #include class session_manager { public: /** * @brief session_manager::session_manager * Object that guide a session * @param fd Client flie descriptor */ session_manager(int fd); /** * @brief start_dialog * Start the default state, ready to listen petitions */ void start_dialog(); /** * @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 */ int remove(); /** * @brief send_information * Send the actual packages generated whit these aplication */ void send_information(); /** * @brief send_user_info * Send the list of generated users and the privileges */ void send_user_info(); /** * @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 */ bool validate_pass(); /** * @brief create_user * Recive an user and password to create a user */ void create_user(); /** * @brief remove_user * Recive a user to remove it */ void remove_user(); private: /** * @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 */ std::string appli_command(char comand[], char* n_package); /** * @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 */ virtual int read_data(char* input, int size); /** * @brief write_data * Write data using a socket * @param output * String to have te info to send * @return Number of bytes writed */ virtual int write_data(std::string output); /** * @brief fd * Socket file desccriptor */ int fd; /** * @brief data * Object that contain media used to store and read information */ data_acces* data; /** * @brief user * Name of the session owner */ std::string user; /** * @brief admin * Privileges abut the user */ bool admin; }; #endif // LAUNCHER_H