summaryrefslogtreecommitdiff
path: root/window.cpp
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2014-01-23 00:10:05 +0100
committerTreeki <treeki@gmail.com>2014-01-23 00:10:05 +0100
commit112d40591a6cfbbce62934753d60b0da03bfa848 (patch)
tree8c08c3c4c6320c55a3317f5a9ad5e4fb376b7a4a /window.cpp
parente3e6a3f2c422a6b82b234f575a6b3bad459e5e0b (diff)
downloadbounce4-112d40591a6cfbbce62934753d60b0da03bfa848.tar.gz
bounce4-112d40591a6cfbbce62934753d60b0da03bfa848.zip
initial bits for channel buffers, display join/privmsg in them
Diffstat (limited to '')
-rw-r--r--window.cpp63
1 files changed, 61 insertions, 2 deletions
diff --git a/window.cpp b/window.cpp
index 5fc094a..4f71982 100644
--- a/window.cpp
+++ b/window.cpp
@@ -43,9 +43,9 @@ void Window::pushMessage(const char *str) {
StatusWindow::StatusWindow(IRCServer *_server) :
- Window(_server->bouncer)
+ Window(_server->bouncer),
+ server(_server)
{
- server = _server;
}
const char *StatusWindow::getTitle() const {
@@ -77,3 +77,62 @@ void StatusWindow::handleUserInput(const char *str) {
server->sendLine(str);
}
}
+
+
+
+
+Channel::Channel(IRCServer *_server, const char *_name) :
+ Window(_server->bouncer),
+ server(_server),
+ inChannel(false),
+ name(_name)
+{
+ server->bouncer->registerWindow(this);
+}
+
+const char *Channel::getTitle() const {
+ return name.c_str();
+}
+
+int Channel::getType() const {
+ return 2;
+}
+
+void Channel::handleUserInput(const char *str) {
+ if (str[0] == '/') {
+ } else {
+ server->sendLine(str);
+ }
+}
+
+void Channel::syncStateForClient(Buffer &output) {
+ Window::syncStateForClient(output);
+}
+
+
+
+void Channel::handleJoin(const UserRef &user) {
+ if (user.isSelf) {
+ users.clear();
+ inChannel = true;
+ pushMessage("You have joined the channel!");
+ } else {
+ char buf[1024];
+ snprintf(buf, 1024,
+ "%s (%s@%s) has joined",
+ user.nick.c_str(),
+ user.ident.c_str(),
+ user.hostmask.c_str());
+
+ pushMessage(buf);
+ }
+}
+void Channel::handlePrivmsg(const UserRef &user, const char *str) {
+ char buf[15000];
+ snprintf(buf, 15000,
+ "<%s> %s",
+ user.nick.c_str(),
+ str);
+
+ pushMessage(buf);
+}