aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-10-25 17:51:19 +0200
committerdec05eba <dec05eba@protonmail.com>2018-10-25 17:51:19 +0200
commit616fb291ee1f62202affbec3a043f741c2c2469c (patch)
treeac4347b38cf598e29893fa2be5584324e5258b9a /include
parent9096d6ef3710118f98c46f6e7f7689d5aa11c7f4 (diff)
Login works and showing messages, nothing else
Diffstat (limited to 'include')
-rw-r--r--include/Cache.hpp16
-rw-r--r--include/ChannelDataType.hpp16
-rw-r--r--include/ChatWindow.hpp15
-rw-r--r--include/LoginWindow.hpp6
-rw-r--r--include/Window.hpp24
-rw-r--r--include/env.hpp59
-rw-r--r--include/types.hpp22
7 files changed, 147 insertions, 11 deletions
diff --git a/include/Cache.hpp b/include/Cache.hpp
new file mode 100644
index 0000000..97ef495
--- /dev/null
+++ b/include/Cache.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+#include <boost/filesystem/path.hpp>
+
+namespace dchat
+{
+ class Cache
+ {
+ public:
+ Cache();
+ ~Cache();
+
+ // Creates directory if it doesn't exist (recursively). Throws boost exception on failure
+ static boost::filesystem::path getDchatDir();
+ };
+}
diff --git a/include/ChannelDataType.hpp b/include/ChannelDataType.hpp
new file mode 100644
index 0000000..398e716
--- /dev/null
+++ b/include/ChannelDataType.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "types.hpp"
+
+namespace dchat
+{
+ enum class ChannelDataType : u8
+ {
+ ADD_MESSAGE,
+ EDIT_MESSAGE,
+ DELETE_MESSAGE,
+ NICKNAME_CHANGE,
+ CHANGE_AVATAR,
+ CHANGE_CHANNEL_NAME,
+ };
+} \ No newline at end of file
diff --git a/include/ChatWindow.hpp b/include/ChatWindow.hpp
index 2d45b76..b13046e 100644
--- a/include/ChatWindow.hpp
+++ b/include/ChatWindow.hpp
@@ -1,12 +1,14 @@
#pragma once
#include <gtkmm/label.h>
+#include <gtkmm/button.h>
#include <gtkmm/grid.h>
#include <gtkmm/entry.h>
#include <gtkmm/paned.h>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/stack.h>
#include <gtkmm/textview.h>
+#include <odhtdb/Hash.hpp>
namespace dchat
{
@@ -14,6 +16,8 @@ namespace dchat
{
public:
ChatWindow();
+ void addChannel(const odhtdb::Hash &nodeHash);
+ void addLocalMessage(const odhtdb::Hash &channelId, Glib::ustring msg);
private:
void setupTopBar();
void setupLeftPanel(Gtk::Paned *sidePanels);
@@ -22,8 +26,19 @@ namespace dchat
private:
Gtk::Grid topbar;
Gtk::Entry topbarSearchBar;
+ Gtk::Grid leftPanelChannels;
Gtk::Label currentChannelTitle;
Gtk::ScrolledWindow chatArea;
+ Gtk::Grid chatAreaLayout;
Gtk::TextView chatInput;
+
+ struct ChannelData
+ {
+ Gtk::Button *button;
+ int messageCount;
+ };
+
+ odhtdb::MapHash<ChannelData> channelDataById;
+ int channelCount;
};
} \ No newline at end of file
diff --git a/include/LoginWindow.hpp b/include/LoginWindow.hpp
index b60dddb..b842eb5 100644
--- a/include/LoginWindow.hpp
+++ b/include/LoginWindow.hpp
@@ -7,15 +7,19 @@
namespace dchat
{
+ using LoginHandler = std::function<void(const Glib::ustring &username, const Glib::ustring &password)>;
+
class LoginWindow : public Gtk::Grid
{
public:
LoginWindow();
- void setLoginHandler(std::function<void()> loginHandler);
+ void setLoginHandler(LoginHandler loginHandler);
private:
Gtk::Entry usernameInput;
Gtk::Entry passwordInput;
Gtk::Button loginButton;
+ std::function<void()> loginHandler;
+ LoginHandler loginHandlerUser;
};
} \ No newline at end of file
diff --git a/include/Window.hpp b/include/Window.hpp
index 2810bbd..96197c6 100644
--- a/include/Window.hpp
+++ b/include/Window.hpp
@@ -4,17 +4,21 @@
#include "LoginWindow.hpp"
#include <gtkmm/window.h>
#include <gtkmm/stack.h>
+#include <odhtdb/Database.hpp>
+#include <mutex>
namespace dchat
{
- class Window : public Gtk::Window
- {
- public:
- Window();
- virtual ~Window();
- protected:
- Gtk::Stack stack;
- LoginWindow loginWindow;
- ChatWindow chatWindow;
- };
+ class Window : public Gtk::Window
+ {
+ public:
+ Window();
+ virtual ~Window();
+ protected:
+ std::unique_ptr<odhtdb::Database> database;
+ std::mutex databaseCallbackMutex;
+ Gtk::Stack stack;
+ LoginWindow loginWindow;
+ ChatWindow chatWindow;
+ };
} \ No newline at end of file
diff --git a/include/env.hpp b/include/env.hpp
new file mode 100644
index 0000000..abaedd8
--- /dev/null
+++ b/include/env.hpp
@@ -0,0 +1,59 @@
+#pragma once
+
+#define OS_FAMILY_WINDOWS 0
+#define OS_FAMILY_POSIX 1
+
+#define OS_TYPE_WINDOWS 0
+#define OS_TYPE_LINUX 1
+
+#if defined(_WIN32) || defined(_WIN64)
+ #if defined(_WIN64)
+ #define SYS_ENV_64BIT
+ #else
+ #define SYS_ENV_32BIT
+ #endif
+ #define OS_FAMILY OS_FAMILY_WINDOWS
+ #define OS_TYPE OS_TYPE_WINDOWS
+
+ #ifndef UNICODE
+ #define UNICODE
+ #endif
+
+ #ifndef _UNICODE
+ #define _UNICODE
+ #endif
+
+ #ifndef WIN32_LEAN_AND_MEAN
+ #define WIN32_LEAN_AND_MEAN
+ #endif
+
+ #include <Windows.h>
+#endif
+
+#if defined(__linux__) || defined(__unix__) || defined(__APPLE__) || defined(_POSIX_VERSION)
+ #define OS_FAMILY OS_FAMILY_POSIX
+#endif
+
+#ifdef __linux__
+ #define OS_TYPE OS_TYPE_LINUX
+#endif
+
+#if defined(__GNUC__)
+ #if defined(__x86_64__) || defined(__pc64__)
+ #define SYS_ENV_64BIT
+ #else
+ #define SYS_ENV_32BIT
+ #endif
+#endif
+
+#if !defined(SYS_ENV_32BIT) && !defined(SYS_ENV_64BIT)
+ #error "System is not detected as either 32-bit or 64-bit"
+#endif
+
+#if !defined(OS_FAMILY)
+ #error "System not supported. Only Windows and Posix systems supported right now"
+#endif
+
+#if !defined(OS_TYPE)
+ #error "System not supported. Only Windows and linux systems supported right now"
+#endif
diff --git a/include/types.hpp b/include/types.hpp
new file mode 100644
index 0000000..762dab1
--- /dev/null
+++ b/include/types.hpp
@@ -0,0 +1,22 @@
+#pragma once
+
+#include <cstdint>
+
+namespace dchat
+{
+ typedef int8_t i8;
+ typedef int16_t i16;
+ typedef int32_t i32;
+ typedef int64_t i64;
+
+ typedef uint8_t u8;
+ typedef uint16_t u16;
+ typedef uint32_t u32;
+ typedef uint64_t u64;
+
+ typedef float f32;
+ typedef double f64;
+
+ typedef intptr_t ssize;
+ typedef uintptr_t usize;
+}