Adding more interfaces to be implemented.

This commit is contained in:
Nicolás Ortega Froysa 2018-07-23 17:35:46 +02:00
parent d695daf736
commit f079d926b7
No known key found for this signature in database
GPG Key ID: FEC70E3BAE2E69BF
7 changed files with 147 additions and 0 deletions

View File

@ -0,0 +1,47 @@
/*
* Copyright (C) 2018 Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
* Author: Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include "identity.hpp"
namespace neocomm {
/**
* @brief Container class of all data and basic functions pertaining to
* channel functionality.
*/
class channel {
public:
/**
* @brief Initialize the channel class and start receiving messages
* for the given ID.
*
* @param chan_id The ID of the channel.
*/
channel(const std::string &chan_id); // TODO
~channel(); // TODO
private:
const std::string chan_id;
std::vector<identity> identities; // users currently known to be in the channel
std::vector<message> msgs; // messages to and from the channel
};
}

View File

@ -0,0 +1,34 @@
/*
* Copyright (C) 2018 Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
* Author: Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
namespace neocomm {
/**
* @brief Container class for data pertaining to a user.
*/
class identity {
public:
private:
const std::string id;
std::string nick;
std::string client_info;
};
}

View File

@ -0,0 +1,38 @@
/*
* Copyright (C) 2018 Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
* Author: Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <ctime>
#include "identity.hpp"
namespace neocomm {
/**
* @brief Container for data of a user message.
*/
class message {
private:
const std::string text;
const struct tm time_stamp;
const identity from;
};
}

View File

@ -18,6 +18,9 @@
#pragma once
#include "channel.hpp"
#include <vector>
#include <string>
#include <opendht.h>
@ -70,7 +73,30 @@ public:
*/
void export_nodes(const std::string &node_file);
/**
* @brief Join and receive messages from a channel.
*
* @param chan_id The ID of the channel.
*/
void join_channel(const std::string &chan_id); // TODO
/**
* @brief Retrieve the channel object.
*
* @param chan_id The ID of the channel.
*
* @return The channel object.
*/
channel* get_channel(const std::string &chan_id); // TODO
/**
* @brief Leave a channel.
*
* @param chan_id The ID of the channel.
*/
void leave_channel(const std::string &chan_id); // TODO
private:
std::vector<channel> channels;
dht::DhtRunner dht_node;
};
}

View File

View File

View File

@ -51,6 +51,8 @@ neocomm::node::node(const std::string &node_file,
// rethrow exception
throw e;
}
import_nodes(node_file);
}
neocomm::node::~node() {