aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-10-27 01:47:08 +0200
committerdec05eba <dec05eba@protonmail.com>2018-10-27 01:47:11 +0200
commit8089e8e88fb145b4b954c310a0eda2ec647259cd (patch)
tree2858973c86754099de4fa206001588eea0f5b5e1 /include
parent206a58f9996a36693b1e73460191b08db1db0327 (diff)
Add users, nickname change, messages now have author
Diffstat (limited to 'include')
-rw-r--r--include/ChatMessage.hpp6
-rw-r--r--include/ChatWindow.hpp19
-rw-r--r--include/User.hpp13
-rw-r--r--include/Window.hpp2
4 files changed, 35 insertions, 5 deletions
diff --git a/include/ChatMessage.hpp b/include/ChatMessage.hpp
index 0547557..271aa5f 100644
--- a/include/ChatMessage.hpp
+++ b/include/ChatMessage.hpp
@@ -1,16 +1,20 @@
#pragma once
+#include "types.hpp"
#include <gtkmm/grid.h>
#include <gtkmm/label.h>
namespace dchat
{
+ class User;
class ChatMessage : public Gtk::Grid
{
public:
- ChatMessage(const Glib::ustring &username, const Glib::ustring &text);
+ ChatMessage(const Glib::ustring &username, const Glib::ustring &text, uint32_t timestampSeconds, const User *user);
Gtk::Label username;
Gtk::Label text;
+ uint32_t timestampSeconds;
+ const User *user;
};
} \ No newline at end of file
diff --git a/include/ChatWindow.hpp b/include/ChatWindow.hpp
index b13046e..b10af2b 100644
--- a/include/ChatWindow.hpp
+++ b/include/ChatWindow.hpp
@@ -1,7 +1,8 @@
#pragma once
+#include "User.hpp"
#include <gtkmm/label.h>
-#include <gtkmm/button.h>
+#include <gtkmm/togglebutton.h>
#include <gtkmm/grid.h>
#include <gtkmm/entry.h>
#include <gtkmm/paned.h>
@@ -9,15 +10,23 @@
#include <gtkmm/stack.h>
#include <gtkmm/textview.h>
#include <odhtdb/Hash.hpp>
+#include <odhtdb/Signature.hpp>
namespace dchat
{
+ class ChatMessage;
+
class ChatWindow : public Gtk::Grid
{
public:
ChatWindow();
void addChannel(const odhtdb::Hash &nodeHash);
- void addLocalMessage(const odhtdb::Hash &channelId, Glib::ustring msg);
+ void addLocalMessage(const odhtdb::Hash &channelId, const odhtdb::Signature::PublicKey &userPublicKey, uint32_t timestampSeconds, Glib::ustring msg);
+ void addUser(const odhtdb::Signature::PublicKey &userPublicKey);
+ void setUserNickname(const odhtdb::Signature::PublicKey &userPublicKey, const Glib::ustring &name);
+
+ // Returns nullptr if user with @publicKey is not found
+ User* getUserByPublicKey(const odhtdb::Signature::PublicKey &publicKey) const;
private:
void setupTopBar();
void setupLeftPanel(Gtk::Paned *sidePanels);
@@ -27,6 +36,7 @@ namespace dchat
Gtk::Grid topbar;
Gtk::Entry topbarSearchBar;
Gtk::Grid leftPanelChannels;
+ Gtk::Grid leftPanelUsers;
Gtk::Label currentChannelTitle;
Gtk::ScrolledWindow chatArea;
Gtk::Grid chatAreaLayout;
@@ -34,11 +44,14 @@ namespace dchat
struct ChannelData
{
- Gtk::Button *button;
+ Gtk::ToggleButton *button;
int messageCount;
};
odhtdb::MapHash<ChannelData> channelDataById;
int channelCount;
+ std::vector<User*> users;
+
+ ChatMessage *lastMessage;
};
} \ No newline at end of file
diff --git a/include/User.hpp b/include/User.hpp
new file mode 100644
index 0000000..471a5cc
--- /dev/null
+++ b/include/User.hpp
@@ -0,0 +1,13 @@
+#pragma once
+
+#include <glibmm/ustring.h>
+#include <odhtdb/Signature.hpp>
+
+namespace dchat
+{
+ struct User
+ {
+ const odhtdb::Signature::PublicKey publicKey;
+ Glib::ustring name;
+ };
+} \ No newline at end of file
diff --git a/include/Window.hpp b/include/Window.hpp
index 96197c6..29ec285 100644
--- a/include/Window.hpp
+++ b/include/Window.hpp
@@ -14,7 +14,7 @@ namespace dchat
public:
Window();
virtual ~Window();
- protected:
+ private:
std::unique_ptr<odhtdb::Database> database;
std::mutex databaseCallbackMutex;
Gtk::Stack stack;