summaryrefslogtreecommitdiff
path: root/plugins/WinterSpeak/src/AnnounceDatabase.cpp
diff options
context:
space:
mode:
authorPhilip Schell <github.com@blubbfish.net>2013-10-19 13:05:02 +0000
committerPhilip Schell <github.com@blubbfish.net>2013-10-19 13:05:02 +0000
commit397e25f2b71347c7c83495fe5b25496ff3b02b75 (patch)
tree71f6ad2ef525218541a7a35cc659b4fb7bf047d6 /plugins/WinterSpeak/src/AnnounceDatabase.cpp
parent9e786b686fae94e71279a797047a91ffdc4b0443 (diff)
WinterSpeak: ticket:269 WinterSpeak now rewritten
git-svn-id: http://svn.miranda-ng.org/main/trunk@6532 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/WinterSpeak/src/AnnounceDatabase.cpp')
-rw-r--r--plugins/WinterSpeak/src/AnnounceDatabase.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/plugins/WinterSpeak/src/AnnounceDatabase.cpp b/plugins/WinterSpeak/src/AnnounceDatabase.cpp
new file mode 100644
index 0000000000..526d057058
--- /dev/null
+++ b/plugins/WinterSpeak/src/AnnounceDatabase.cpp
@@ -0,0 +1,82 @@
+#include "Common.h"
+#include "AnnounceDatabase.h"
+
+
+//------------------------------------------------------------------------------
+namespace
+{
+ const char *SPEAK = "speak_announce";
+ const char *STATUS_FLAGS = "status_flags";
+ const char *EVENT_FLAGS = "event_flags";
+ const char *MAX_MSG_SIZE = "max_msg_size";
+}
+
+//------------------------------------------------------------------------------
+// public:
+//------------------------------------------------------------------------------
+AnnounceDatabase::AnnounceDatabase() : m_status_flags(0), m_event_flags(0), m_max_msg(0)
+{
+ load();
+}
+
+//------------------------------------------------------------------------------
+AnnounceDatabase::~AnnounceDatabase()
+{
+}
+
+//------------------------------------------------------------------------------
+bool AnnounceDatabase::getStatusFlag(StatusFlag flag) const
+{
+ return ((m_status_flags & (1 << flag)) != 0);
+}
+
+//------------------------------------------------------------------------------
+void AnnounceDatabase::setStatusFlag(StatusFlag flag, bool state)
+{
+ if (state)
+ {
+ m_status_flags |= (1 << flag);
+ }
+ else
+ {
+ m_status_flags &= ~(1 << flag);
+ }
+}
+
+//------------------------------------------------------------------------------
+bool AnnounceDatabase::getEventFlag(EventFlag flag) const
+{
+ return ((m_event_flags & (1 << flag)) != 0);
+}
+
+//------------------------------------------------------------------------------
+void AnnounceDatabase::setEventFlag(EventFlag flag, bool state)
+{
+ if (state)
+ {
+ m_event_flags |= (1 << flag);
+ }
+ else
+ {
+ m_event_flags &= ~(1 << flag);
+ }
+}
+
+//------------------------------------------------------------------------------
+void AnnounceDatabase::load()
+{
+ m_status_flags = db_get_dw(NULL, SPEAK, STATUS_FLAGS, 0xffff);
+ m_event_flags = db_get_dw(NULL, SPEAK, EVENT_FLAGS, 0xffff);
+ m_max_msg = db_get_dw(NULL, SPEAK, MAX_MSG_SIZE, 50);
+}
+
+//------------------------------------------------------------------------------
+void
+AnnounceDatabase::save()
+{
+ db_set_dw(NULL, SPEAK, STATUS_FLAGS, m_status_flags);
+ db_set_dw(NULL, SPEAK, EVENT_FLAGS, m_event_flags);
+ db_set_dw(NULL, SPEAK, MAX_MSG_SIZE, m_max_msg);
+}
+
+//==============================================================================