diff --git a/Makefile b/Makefile index f683f14..fecc47a 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ NAME = ircserv -SRC = main.cpp Server/Server.cpp +SRC = main.cpp Server/Server.cpp Client/Client.cpp HEADERS = Server/Server.hpp diff --git a/User/User.cpp b/User/User.cpp new file mode 100644 index 0000000..c9c2049 --- /dev/null +++ b/User/User.cpp @@ -0,0 +1,65 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* User.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: aortigos +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/05/07 10:22:52 by aortigos #+# #+# */ +/* Updated: 2026/05/07 10:22:52 by aortigos ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "User.hpp" + +////////////////// +// Constructors // +////////////////// + +User::User() +{ + // std::cout << "User default constructor called" << std::endl; +} + +User::User(const User &other) +{ + *this = other; + // std::cout << "User copy constructor called" << std::endl; +} + +User& User::operator=(const User &other) +{ + if (this != &other) + { + // Copy attributes here + } + // std::cout << "User copy assignment operator called" << std::endl; + return (*this); +} + +User::~User() +{ + // std::cout << "User destructor called" << std::endl; +} + +// Getters + +int User::getFd() const { return (this->fd) }; +std::string User::getNick() const { return (this->nick) }; +std::string User::getUsername() const { return (this->username) }; +std::string User::getRealname() const { return (this->realname) }; +std::string &User::getBuffer() { return (this->buffer) }; +bool User::isAuthenticated() const { return (this->authenticated) }; +bool User::isRegistered() const { return (this->registered) }; + + +// Setters + +void setNick(std::string nick) { this->nick = nick; } +void setUsername(std::string username) { this->username = username; } +void setRealname(std::string realname) { this->realname = realname; } +void appendBuffer(std::string buff) { this->buffer = buff; } +void clearBuffer() { this->buffer.clear(); } + +void setAuthenticated(bool value) { this->authenticated = value; } +void setRegistered(bool value) { this->registered = value; } \ No newline at end of file diff --git a/User/User.hpp b/User/User.hpp new file mode 100644 index 0000000..da62791 --- /dev/null +++ b/User/User.hpp @@ -0,0 +1,60 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* User.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: aortigos +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/05/07 10:22:52 by aortigos #+# #+# */ +/* Updated: 2026/05/07 10:22:52 by aortigos ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef USER_HPP + +# define USER_HPP + +# include + +class User +{ + private: + int fd; + std::string nick; + std::string username; + std::string realname; + std::string buffer; + bool authenticated; + bool registered; + + public: + User(); + User(const User &other); + User& operator=(const User &other); + ~User(); + + + // Getters + + int getFd() const; + std::string getNick() const; + std::string getUsername() const; + std::string getRealname() const; + std::string &getBuffer(); + bool isAuthenticated() const; + bool isRegistered() const; + + + // Setters + + void setNick(std::string nick); + void setUsername(std::string username); + void setRealname(std::string realname); + void appendBuffer(std::string buff); + void clearBuffer(); + + void setAuthenticated(bool value); + void setRegistered(bool value); +}; + +#endif diff --git a/tasks.md b/tasks.md index 5e54591..c934488 100644 --- a/tasks.md +++ b/tasks.md @@ -7,6 +7,23 @@ You can try connect IRC server with ```bash nc localhost ``` +--- + +### User + +Represents a connected IRC client. + +| Attribute | Type | Description | +|-----------------|----------|------------------------------------------------| +| `fd` | `int` | TCP s-ocket file descriptor | +| `nick` | `string` | IRC nickname | +| `username` | `string` | Username | +| `realname` | `string` | Real name | +| `buffer` | `string` | Incoming data buffer, accumulates until `\r\n` | +| `authenticated` | `bool` | `true` after correct `PASS` | +| `registered` | `bool` | `true` after `NICK` + `USER` received | + +**Registration flow:** `PASS` → authenticated → `NICK` + `USER` → registered → client ready ---