mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
Applications: Run clang-format on everything.
This commit is contained in:
parent
e09c3a1ae8
commit
fd604a7c68
24 changed files with 350 additions and 294 deletions
|
@ -1,16 +1,16 @@
|
|||
#include "IRCAppWindow.h"
|
||||
#include "IRCWindow.h"
|
||||
#include "IRCWindowListModel.h"
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GStackWidget.h>
|
||||
#include <LibGUI/GTableView.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GToolBar.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GInputBox.h>
|
||||
#include <LibGUI/GMenu.h>
|
||||
#include <LibGUI/GMenuBar.h>
|
||||
#include <LibGUI/GInputBox.h>
|
||||
#include <LibGUI/GSplitter.h>
|
||||
#include <LibGUI/GStackWidget.h>
|
||||
#include <LibGUI/GTableView.h>
|
||||
#include <LibGUI/GToolBar.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -36,7 +36,7 @@ void IRCAppWindow::update_title()
|
|||
|
||||
void IRCAppWindow::setup_client()
|
||||
{
|
||||
m_client.aid_create_window = [this] (void* owner, IRCWindow::Type type, const String& name) {
|
||||
m_client.aid_create_window = [this](void* owner, IRCWindow::Type type, const String& name) {
|
||||
return &create_window(owner, type, name);
|
||||
};
|
||||
m_client.aid_get_active_window = [this] {
|
||||
|
@ -45,7 +45,7 @@ void IRCAppWindow::setup_client()
|
|||
m_client.aid_update_window_list = [this] {
|
||||
m_window_list->model()->update();
|
||||
};
|
||||
m_client.on_nickname_changed = [this] (const String&) {
|
||||
m_client.on_nickname_changed = [this](const String&) {
|
||||
update_title();
|
||||
};
|
||||
|
||||
|
@ -64,33 +64,33 @@ void IRCAppWindow::setup_client()
|
|||
|
||||
void IRCAppWindow::setup_actions()
|
||||
{
|
||||
m_join_action = GAction::create("Join channel", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-join.png"), [&] (auto&) {
|
||||
m_join_action = GAction::create("Join channel", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-join.png"), [&](auto&) {
|
||||
GInputBox input_box("Enter channel name:", "Join channel", this);
|
||||
if (input_box.exec() == GInputBox::ExecOK && !input_box.text_value().is_empty())
|
||||
m_client.handle_join_action(input_box.text_value());
|
||||
});
|
||||
|
||||
m_part_action = GAction::create("Part from channel", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-part.png"), [] (auto&) {
|
||||
m_part_action = GAction::create("Part from channel", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-part.png"), [](auto&) {
|
||||
printf("FIXME: Implement part action\n");
|
||||
});
|
||||
|
||||
m_whois_action = GAction::create("Whois user", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-whois.png"), [&] (auto&) {
|
||||
m_whois_action = GAction::create("Whois user", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-whois.png"), [&](auto&) {
|
||||
GInputBox input_box("Enter nickname:", "IRC WHOIS lookup", this);
|
||||
if (input_box.exec() == GInputBox::ExecOK && !input_box.text_value().is_empty())
|
||||
m_client.handle_whois_action(input_box.text_value());
|
||||
});
|
||||
|
||||
m_open_query_action = GAction::create("Open query", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-open-query.png"), [&] (auto&) {
|
||||
m_open_query_action = GAction::create("Open query", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-open-query.png"), [&](auto&) {
|
||||
GInputBox input_box("Enter nickname:", "Open IRC query with...", this);
|
||||
if (input_box.exec() == GInputBox::ExecOK && !input_box.text_value().is_empty())
|
||||
m_client.handle_open_query_action(input_box.text_value());
|
||||
});
|
||||
|
||||
m_close_query_action = GAction::create("Close query", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-close-query.png"), [] (auto&) {
|
||||
m_close_query_action = GAction::create("Close query", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-close-query.png"), [](auto&) {
|
||||
printf("FIXME: Implement close-query action\n");
|
||||
});
|
||||
|
||||
m_change_nick_action = GAction::create("Change nickname", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-nick.png"), [this] (auto&) {
|
||||
m_change_nick_action = GAction::create("Change nickname", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-nick.png"), [this](auto&) {
|
||||
GInputBox input_box("Enter nickname:", "Change nickname", this);
|
||||
if (input_box.exec() == GInputBox::ExecOK && !input_box.text_value().is_empty())
|
||||
m_client.handle_change_nick_action(input_box.text_value());
|
||||
|
@ -101,7 +101,7 @@ void IRCAppWindow::setup_menus()
|
|||
{
|
||||
auto menubar = make<GMenuBar>();
|
||||
auto app_menu = make<GMenu>("IRC Client");
|
||||
app_menu->add_action(GAction::create("Quit", { Mod_Alt, Key_F4 }, [] (const GAction&) {
|
||||
app_menu->add_action(GAction::create("Quit", { Mod_Alt, Key_F4 }, [](const GAction&) {
|
||||
dbgprintf("Terminal: Quit menu activated!\n");
|
||||
GApplication::the().quit(0);
|
||||
return;
|
||||
|
@ -120,7 +120,7 @@ void IRCAppWindow::setup_menus()
|
|||
menubar->add_menu(move(server_menu));
|
||||
|
||||
auto help_menu = make<GMenu>("Help");
|
||||
help_menu->add_action(GAction::create("About", [] (const GAction&) {
|
||||
help_menu->add_action(GAction::create("About", [](const GAction&) {
|
||||
dbgprintf("FIXME: Implement Help/About\n");
|
||||
}));
|
||||
menubar->add_menu(move(help_menu));
|
||||
|
@ -156,7 +156,7 @@ void IRCAppWindow::setup_widgets()
|
|||
m_window_list->set_activates_on_selection(true);
|
||||
m_window_list->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
m_window_list->set_preferred_size({ 100, 0 });
|
||||
m_window_list->on_activation = [this] (auto& index) {
|
||||
m_window_list->on_activation = [this](auto& index) {
|
||||
auto& window = m_client.window_at(index.row());
|
||||
m_container->set_active_widget(&window);
|
||||
window.clear_unread_count();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "IRCChannel.h"
|
||||
#include "IRCClient.h"
|
||||
#include "IRCChannelMemberListModel.h"
|
||||
#include "IRCClient.h"
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
|
@ -37,7 +37,7 @@ void IRCChannel::add_member(const String& name, char prefix)
|
|||
|
||||
void IRCChannel::remove_member(const String& name)
|
||||
{
|
||||
m_members.remove_first_matching([&] (auto& member) { return name == member.name; });
|
||||
m_members.remove_first_matching([&](auto& member) { return name == member.name; });
|
||||
}
|
||||
|
||||
void IRCChannel::add_message(char prefix, const String& name, const String& text, Color color)
|
||||
|
|
|
@ -25,7 +25,8 @@ int IRCChannelMemberListModel::column_count(const GModelIndex&) const
|
|||
String IRCChannelMemberListModel::column_name(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case Column::Name: return "Name";
|
||||
case Column::Name:
|
||||
return "Name";
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
@ -33,7 +34,8 @@ String IRCChannelMemberListModel::column_name(int column) const
|
|||
GModel::ColumnMetadata IRCChannelMemberListModel::column_metadata(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case Column::Name: return { 70, TextAlignment::CenterLeft };
|
||||
case Column::Name:
|
||||
return { 70, TextAlignment::CenterLeft };
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
@ -42,10 +44,11 @@ GVariant IRCChannelMemberListModel::data(const GModelIndex& index, Role role) co
|
|||
{
|
||||
if (role == Role::Display) {
|
||||
switch (index.column()) {
|
||||
case Column::Name: return m_channel.member_at(index.row());
|
||||
case Column::Name:
|
||||
return m_channel.member_at(index.row());
|
||||
}
|
||||
}
|
||||
return { };
|
||||
return {};
|
||||
}
|
||||
|
||||
void IRCChannelMemberListModel::update()
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
#include "IRCClient.h"
|
||||
#include "IRCChannel.h"
|
||||
#include "IRCQuery.h"
|
||||
#include "IRCLogBuffer.h"
|
||||
#include "IRCQuery.h"
|
||||
#include "IRCWindow.h"
|
||||
#include "IRCWindowListModel.h"
|
||||
#include <LibCore/CNotifier.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <netinet/in.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define IRC_DEBUG
|
||||
|
||||
enum IRCNumeric {
|
||||
enum IRCNumeric
|
||||
{
|
||||
RPL_WHOISUSER = 311,
|
||||
RPL_WHOISSERVER = 312,
|
||||
RPL_WHOISOPERATOR = 313,
|
||||
|
@ -43,7 +44,7 @@ IRCClient::~IRCClient()
|
|||
{
|
||||
}
|
||||
|
||||
void IRCClient::set_server(const String &hostname, int port)
|
||||
void IRCClient::set_server(const String& hostname, int port)
|
||||
{
|
||||
m_hostname = hostname;
|
||||
m_port = port;
|
||||
|
@ -105,14 +106,16 @@ void IRCClient::process_line(ByteBuffer&& line)
|
|||
Vector<char, 32> prefix;
|
||||
Vector<char, 32> command;
|
||||
Vector<char, 256> current_parameter;
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
Start,
|
||||
InPrefix,
|
||||
InCommand,
|
||||
InStartOfParameter,
|
||||
InParameter,
|
||||
InTrailingParameter,
|
||||
} state = Start;
|
||||
} state
|
||||
= Start;
|
||||
|
||||
for (int i = 0; i < line.size(); ++i) {
|
||||
char ch = line[i];
|
||||
|
@ -216,8 +219,7 @@ void IRCClient::handle(const Message& msg)
|
|||
printf("IRCClient::execute: prefix='%s', command='%s', arguments=%d\n",
|
||||
msg.prefix.characters(),
|
||||
msg.command.characters(),
|
||||
msg.arguments.size()
|
||||
);
|
||||
msg.arguments.size());
|
||||
|
||||
int i = 0;
|
||||
for (auto& arg : msg.arguments) {
|
||||
|
@ -231,16 +233,26 @@ void IRCClient::handle(const Message& msg)
|
|||
|
||||
if (is_numeric) {
|
||||
switch (numeric) {
|
||||
case RPL_WHOISCHANNELS: return handle_rpl_whoischannels(msg);
|
||||
case RPL_ENDOFWHOIS: return handle_rpl_endofwhois(msg);
|
||||
case RPL_WHOISOPERATOR: return handle_rpl_whoisoperator(msg);
|
||||
case RPL_WHOISSERVER: return handle_rpl_whoisserver(msg);
|
||||
case RPL_WHOISUSER: return handle_rpl_whoisuser(msg);
|
||||
case RPL_WHOISIDLE: return handle_rpl_whoisidle(msg);
|
||||
case RPL_TOPICWHOTIME: return handle_rpl_topicwhotime(msg);
|
||||
case RPL_TOPIC: return handle_rpl_topic(msg);
|
||||
case RPL_NAMREPLY: return handle_rpl_namreply(msg);
|
||||
case RPL_ENDOFNAMES: return handle_rpl_endofnames(msg);
|
||||
case RPL_WHOISCHANNELS:
|
||||
return handle_rpl_whoischannels(msg);
|
||||
case RPL_ENDOFWHOIS:
|
||||
return handle_rpl_endofwhois(msg);
|
||||
case RPL_WHOISOPERATOR:
|
||||
return handle_rpl_whoisoperator(msg);
|
||||
case RPL_WHOISSERVER:
|
||||
return handle_rpl_whoisserver(msg);
|
||||
case RPL_WHOISUSER:
|
||||
return handle_rpl_whoisuser(msg);
|
||||
case RPL_WHOISIDLE:
|
||||
return handle_rpl_whoisidle(msg);
|
||||
case RPL_TOPICWHOTIME:
|
||||
return handle_rpl_topicwhotime(msg);
|
||||
case RPL_TOPIC:
|
||||
return handle_rpl_topic(msg);
|
||||
case RPL_NAMREPLY:
|
||||
return handle_rpl_namreply(msg);
|
||||
case RPL_ENDOFNAMES:
|
||||
return handle_rpl_endofnames(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -441,7 +453,7 @@ void IRCClient::handle_rpl_topic(const Message& msg)
|
|||
return;
|
||||
auto& channel_name = msg.arguments[1];
|
||||
auto& topic = msg.arguments[2];
|
||||
ensure_channel(channel_name).handle_topic({ }, topic);
|
||||
ensure_channel(channel_name).handle_topic({}, topic);
|
||||
// FIXME: Handle RPL_TOPICWHOTIME so we can know who set it and when.
|
||||
}
|
||||
|
||||
|
@ -502,8 +514,7 @@ void IRCClient::handle_rpl_whoisuser(const Message& msg)
|
|||
nick.characters(),
|
||||
username.characters(),
|
||||
host.characters(),
|
||||
realname.characters()
|
||||
));
|
||||
realname.characters()));
|
||||
}
|
||||
|
||||
void IRCClient::handle_rpl_whoisidle(const Message& msg)
|
||||
|
@ -541,8 +552,7 @@ void IRCClient::handle_rpl_topicwhotime(const Message& msg)
|
|||
tm->tm_mday,
|
||||
tm->tm_hour,
|
||||
tm->tm_min,
|
||||
tm->tm_sec
|
||||
);
|
||||
tm->tm_sec);
|
||||
}
|
||||
ensure_channel(channel_name).add_message(String::format("*** (set by %s at %s)", nick.characters(), setat.characters()), Color::Blue);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "IRCLogBufferModel.h"
|
||||
#include "IRCLogBuffer.h"
|
||||
#include <SharedGraphics/Font.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <SharedGraphics/Font.h>
|
||||
|
||||
IRCLogBufferModel::IRCLogBufferModel(Retained<IRCLogBuffer>&& log_buffer)
|
||||
: m_log_buffer(move(log_buffer))
|
||||
|
@ -26,9 +26,12 @@ int IRCLogBufferModel::column_count(const GModelIndex&) const
|
|||
String IRCLogBufferModel::column_name(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case Column::Timestamp: return "Time";
|
||||
case Column::Name: return "Name";
|
||||
case Column::Text: return "Text";
|
||||
case Column::Timestamp:
|
||||
return "Time";
|
||||
case Column::Name:
|
||||
return "Name";
|
||||
case Column::Text:
|
||||
return "Text";
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
@ -36,9 +39,12 @@ String IRCLogBufferModel::column_name(int column) const
|
|||
GModel::ColumnMetadata IRCLogBufferModel::column_metadata(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case Column::Timestamp: return { 60, TextAlignment::CenterLeft };
|
||||
case Column::Name: return { 70, TextAlignment::CenterRight, &Font::default_bold_font() };
|
||||
case Column::Text: return { 800, TextAlignment::CenterLeft };
|
||||
case Column::Timestamp:
|
||||
return { 60, TextAlignment::CenterLeft };
|
||||
case Column::Name:
|
||||
return { 70, TextAlignment::CenterRight, &Font::default_bold_font() };
|
||||
case Column::Text:
|
||||
return { 800, TextAlignment::CenterLeft };
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
@ -56,7 +62,8 @@ GVariant IRCLogBufferModel::data(const GModelIndex& index, Role role) const
|
|||
if (entry.sender.is_empty())
|
||||
return String::empty();
|
||||
return String::format("<%c%s>", entry.prefix ? entry.prefix : ' ', entry.sender.characters());
|
||||
case Column::Text: return entry.text;
|
||||
case Column::Text:
|
||||
return entry.text;
|
||||
}
|
||||
}
|
||||
if (role == Role::ForegroundColor) {
|
||||
|
@ -65,7 +72,7 @@ GVariant IRCLogBufferModel::data(const GModelIndex& index, Role role) const
|
|||
if (index.column() == Column::Text)
|
||||
return m_log_buffer->at(index.row()).color;
|
||||
}
|
||||
return { };
|
||||
return {};
|
||||
}
|
||||
|
||||
void IRCLogBufferModel::update()
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#include "IRCWindow.h"
|
||||
#include "IRCClient.h"
|
||||
#include "IRCChannel.h"
|
||||
#include "IRCChannelMemberListModel.h"
|
||||
#include "IRCClient.h"
|
||||
#include "IRCLogBufferModel.h"
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GTableView.h>
|
||||
#include <LibGUI/GTextEditor.h>
|
||||
#include <LibGUI/GTextBox.h>
|
||||
#include <LibGUI/GSplitter.h>
|
||||
#include <LibGUI/GTableView.h>
|
||||
#include <LibGUI/GTextBox.h>
|
||||
#include <LibGUI/GTextEditor.h>
|
||||
|
||||
IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& name, GWidget* parent)
|
||||
: GWidget(parent)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "IRCWindowListModel.h"
|
||||
#include "IRCWindow.h"
|
||||
#include "IRCClient.h"
|
||||
#include "IRCChannel.h"
|
||||
#include "IRCClient.h"
|
||||
#include "IRCWindow.h"
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
|
@ -27,7 +27,8 @@ int IRCWindowListModel::column_count(const GModelIndex&) const
|
|||
String IRCWindowListModel::column_name(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case Column::Name: return "Name";
|
||||
case Column::Name:
|
||||
return "Name";
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
@ -35,7 +36,8 @@ String IRCWindowListModel::column_name(int column) const
|
|||
GModel::ColumnMetadata IRCWindowListModel::column_metadata(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case Column::Name: return { 70, TextAlignment::CenterLeft };
|
||||
case Column::Name:
|
||||
return { 70, TextAlignment::CenterLeft };
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
@ -64,7 +66,7 @@ GVariant IRCWindowListModel::data(const GModelIndex& index, Role role) const
|
|||
}
|
||||
}
|
||||
}
|
||||
return { };
|
||||
return {};
|
||||
}
|
||||
|
||||
void IRCWindowListModel::update()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "IRCAppWindow.h"
|
||||
#include "IRCClient.h"
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include "IRCAppWindow.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue