mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 16:27:35 +00:00
IRCClient: Put the unhandled server messages nicely into the server log.
This commit is contained in:
parent
850c7504a2
commit
f004db19d0
3 changed files with 15 additions and 10 deletions
|
@ -49,8 +49,6 @@ void IRCAppWindow::setup_widgets()
|
||||||
|
|
||||||
m_subwindow_container = new GWidget(widget);
|
m_subwindow_container = new GWidget(widget);
|
||||||
m_subwindow_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
m_subwindow_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||||
m_subwindow_container->set_fill_with_background_color(true);
|
|
||||||
m_subwindow_container->set_background_color(Color::Yellow);
|
|
||||||
m_subwindow_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fill);
|
m_subwindow_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fill);
|
||||||
|
|
||||||
create_subwindow(IRCSubWindow::Server, "Server");
|
create_subwindow(IRCSubWindow::Server, "Server");
|
||||||
|
@ -59,7 +57,5 @@ void IRCAppWindow::setup_widgets()
|
||||||
void IRCAppWindow::create_subwindow(IRCSubWindow::Type type, const String& name)
|
void IRCAppWindow::create_subwindow(IRCSubWindow::Type type, const String& name)
|
||||||
{
|
{
|
||||||
auto* subwindow = new IRCSubWindow(m_client, type, name, m_subwindow_container);
|
auto* subwindow = new IRCSubWindow(m_client, type, name, m_subwindow_container);
|
||||||
subwindow->set_fill_with_background_color(true);
|
|
||||||
subwindow->set_background_color(Color::Magenta);
|
|
||||||
m_subwindows.append(subwindow);
|
m_subwindows.append(subwindow);
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,7 +235,8 @@ void IRCClient::handle(const Message& msg, const String& verbatim)
|
||||||
if (msg.command == "PRIVMSG")
|
if (msg.command == "PRIVMSG")
|
||||||
return handle_privmsg(msg);
|
return handle_privmsg(msg);
|
||||||
|
|
||||||
m_log->add_message(0, "Server", verbatim);
|
if (msg.arguments.size() >= 2)
|
||||||
|
m_log->add_message(0, "Server", String::format("[%s] %s", msg.command.characters(), msg.arguments[1].characters()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IRCClient::is_nick_prefix(char ch) const
|
bool IRCClient::is_nick_prefix(char ch) const
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "IRCLogBufferModel.h"
|
#include "IRCLogBufferModel.h"
|
||||||
#include "IRCLogBuffer.h"
|
#include "IRCLogBuffer.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
IRCLogBufferModel::IRCLogBufferModel(Retained<IRCLogBuffer>&& log_buffer)
|
IRCLogBufferModel::IRCLogBufferModel(Retained<IRCLogBuffer>&& log_buffer)
|
||||||
: m_log_buffer(move(log_buffer))
|
: m_log_buffer(move(log_buffer))
|
||||||
|
@ -35,20 +36,27 @@ String IRCLogBufferModel::column_name(int column) const
|
||||||
GTableModel::ColumnMetadata IRCLogBufferModel::column_metadata(int column) const
|
GTableModel::ColumnMetadata IRCLogBufferModel::column_metadata(int column) const
|
||||||
{
|
{
|
||||||
switch (column) {
|
switch (column) {
|
||||||
case Column::Timestamp: return { 90, TextAlignment::CenterLeft };
|
case Column::Timestamp: return { 60, TextAlignment::CenterLeft };
|
||||||
case Column::Prefix: return { 10, TextAlignment::CenterLeft };
|
case Column::Prefix: return { 10, TextAlignment::CenterLeft };
|
||||||
case Column::Name: return { 70, TextAlignment::CenterRight };
|
case Column::Name: return { 70, TextAlignment::CenterRight };
|
||||||
case Column::Text: return { 400, TextAlignment::CenterLeft };
|
case Column::Text: return { 800, TextAlignment::CenterLeft };
|
||||||
}
|
}
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
GVariant IRCLogBufferModel::data(const GModelIndex& index, Role role) const
|
GVariant IRCLogBufferModel::data(const GModelIndex& index, Role) const
|
||||||
{
|
{
|
||||||
auto& entry = m_log_buffer->at(index.row());
|
auto& entry = m_log_buffer->at(index.row());
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case Column::Timestamp: return String::format("%u", entry.timestamp);
|
case Column::Timestamp: {
|
||||||
case Column::Prefix: return entry.prefix;
|
auto* tm = localtime(&entry.timestamp);
|
||||||
|
return String::format("%02u:%02u:%02u", tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||||
|
}
|
||||||
|
case Column::Prefix: {
|
||||||
|
if (!entry.prefix)
|
||||||
|
return String("");
|
||||||
|
return String(&entry.prefix, 1);
|
||||||
|
}
|
||||||
case Column::Name: return entry.sender;
|
case Column::Name: return entry.sender;
|
||||||
case Column::Text: return entry.text;
|
case Column::Text: return entry.text;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue