From 112d40591a6cfbbce62934753d60b0da03bfa848 Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 23 Jan 2014 00:10:05 +0100 Subject: initial bits for channel buffers, display join/privmsg in them --- window.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) (limited to 'window.cpp') 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); +} -- cgit v1.2.3