forked from OpenGamers/abaddon
committed by
GitHub
parent
108002248c
commit
9d21df8e1b
@@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
Abaddon::Abaddon()
|
Abaddon::Abaddon()
|
||||||
: m_settings(Platform::FindConfigFile())
|
: m_settings(Platform::FindConfigFile())
|
||||||
, m_emojis(GetResPath("/emojis.bin"))
|
, m_discord(m_settings.GetUseMemoryDB()) // stupid but easy
|
||||||
, m_discord(m_settings.GetUseMemoryDB()) { // stupid but easy
|
, m_emojis(GetResPath("/emojis.bin")) {
|
||||||
LoadFromSettings();
|
LoadFromSettings();
|
||||||
|
|
||||||
// todo: set user agent for non-client(?)
|
// todo: set user agent for non-client(?)
|
||||||
@@ -267,7 +267,7 @@ void Abaddon::ShowUserMenu(const GdkEvent *event, Snowflake id, Snowflake guild_
|
|||||||
if (guild.has_value() && user.has_value()) {
|
if (guild.has_value() && user.has_value()) {
|
||||||
const auto roles = user->GetSortedRoles();
|
const auto roles = user->GetSortedRoles();
|
||||||
m_user_menu_roles->set_visible(roles.size() > 0);
|
m_user_menu_roles->set_visible(roles.size() > 0);
|
||||||
for (const auto role : roles) {
|
for (const auto &role : roles) {
|
||||||
auto *item = Gtk::manage(new Gtk::MenuItem(role.Name));
|
auto *item = Gtk::manage(new Gtk::MenuItem(role.Name));
|
||||||
if (role.Color != 0) {
|
if (role.Color != 0) {
|
||||||
Gdk::RGBA color;
|
Gdk::RGBA color;
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ void CellRendererPixbufAnimation::render_vfunc(const Cairo::RefPtr<Cairo::Contex
|
|||||||
Gtk::CellRendererState flags) {
|
Gtk::CellRendererState flags) {
|
||||||
Gtk::Requisition minimum, natural;
|
Gtk::Requisition minimum, natural;
|
||||||
get_preferred_size(widget, minimum, natural);
|
get_preferred_size(widget, minimum, natural);
|
||||||
auto alloc = widget.get_allocation();
|
|
||||||
int xpad, ypad;
|
int xpad, ypad;
|
||||||
get_padding(xpad, ypad);
|
get_padding(xpad, ypad);
|
||||||
int pix_x = cell_area.get_x() + xpad;
|
int pix_x = cell_area.get_x() + xpad;
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ ChannelList::ChannelList()
|
|||||||
, m_menu_guild_leave("_Leave", true)
|
, m_menu_guild_leave("_Leave", true)
|
||||||
, m_menu_category_copy_id("_Copy ID", true)
|
, m_menu_category_copy_id("_Copy ID", true)
|
||||||
, m_menu_channel_copy_id("_Copy ID", true)
|
, m_menu_channel_copy_id("_Copy ID", true)
|
||||||
, m_menu_dm_close("") // changes depending on if group or not
|
|
||||||
, m_menu_dm_copy_id("_Copy ID", true)
|
, m_menu_dm_copy_id("_Copy ID", true)
|
||||||
|
, m_menu_dm_close("") // changes depending on if group or not
|
||||||
, m_menu_thread_copy_id("_Copy ID", true)
|
, m_menu_thread_copy_id("_Copy ID", true)
|
||||||
, m_menu_thread_leave("_Leave", true)
|
, m_menu_thread_leave("_Leave", true)
|
||||||
, m_menu_thread_archive("_Archive", true)
|
, m_menu_thread_archive("_Archive", true)
|
||||||
@@ -167,7 +167,6 @@ void ChannelList::UpdateListing() {
|
|||||||
m_model->clear();
|
m_model->clear();
|
||||||
|
|
||||||
auto &discord = Abaddon::Get().GetDiscordClient();
|
auto &discord = Abaddon::Get().GetDiscordClient();
|
||||||
auto &img = Abaddon::Get().GetImageManager();
|
|
||||||
|
|
||||||
const auto guild_ids = discord.GetUserSortedGuilds();
|
const auto guild_ids = discord.GetUserSortedGuilds();
|
||||||
int sortnum = 0;
|
int sortnum = 0;
|
||||||
@@ -185,10 +184,7 @@ void ChannelList::UpdateListing() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChannelList::UpdateNewGuild(const GuildData &guild) {
|
void ChannelList::UpdateNewGuild(const GuildData &guild) {
|
||||||
auto &img = Abaddon::Get().GetImageManager();
|
AddGuild(guild);
|
||||||
|
|
||||||
auto iter = AddGuild(guild);
|
|
||||||
|
|
||||||
// update sort order
|
// update sort order
|
||||||
int sortnum = 0;
|
int sortnum = 0;
|
||||||
for (const auto guild_id : Abaddon::Get().GetDiscordClient().GetUserSortedGuilds()) {
|
for (const auto guild_id : Abaddon::Get().GetDiscordClient().GetUserSortedGuilds()) {
|
||||||
@@ -561,7 +557,7 @@ void ChannelList::UpdateChannelCategory(const ChannelData &channel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Gtk::TreeModel::iterator ChannelList::GetIteratorForGuildFromID(Snowflake id) {
|
Gtk::TreeModel::iterator ChannelList::GetIteratorForGuildFromID(Snowflake id) {
|
||||||
for (const auto child : m_model->children()) {
|
for (const auto &child : m_model->children()) {
|
||||||
if (child[m_columns.m_id] == id)
|
if (child[m_columns.m_id] == id)
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
@@ -570,14 +566,14 @@ Gtk::TreeModel::iterator ChannelList::GetIteratorForGuildFromID(Snowflake id) {
|
|||||||
|
|
||||||
Gtk::TreeModel::iterator ChannelList::GetIteratorForChannelFromID(Snowflake id) {
|
Gtk::TreeModel::iterator ChannelList::GetIteratorForChannelFromID(Snowflake id) {
|
||||||
std::queue<Gtk::TreeModel::iterator> queue;
|
std::queue<Gtk::TreeModel::iterator> queue;
|
||||||
for (const auto child : m_model->children())
|
for (const auto &child : m_model->children())
|
||||||
for (const auto child2 : child.children())
|
for (const auto &child2 : child.children())
|
||||||
queue.push(child2);
|
queue.push(child2);
|
||||||
|
|
||||||
while (!queue.empty()) {
|
while (!queue.empty()) {
|
||||||
auto item = queue.front();
|
auto item = queue.front();
|
||||||
if ((*item)[m_columns.m_id] == id) return item;
|
if ((*item)[m_columns.m_id] == id) return item;
|
||||||
for (const auto child : item->children())
|
for (const auto &child : item->children())
|
||||||
queue.push(child);
|
queue.push(child);
|
||||||
queue.pop();
|
queue.pop();
|
||||||
}
|
}
|
||||||
@@ -1052,9 +1048,6 @@ void CellRendererChannels::get_preferred_height_for_width_vfunc_category(Gtk::Wi
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CellRendererChannels::render_vfunc_category(const Cairo::RefPtr<Cairo::Context> &cr, Gtk::Widget &widget, const Gdk::Rectangle &background_area, const Gdk::Rectangle &cell_area, Gtk::CellRendererState flags) {
|
void CellRendererChannels::render_vfunc_category(const Cairo::RefPtr<Cairo::Context> &cr, Gtk::Widget &widget, const Gdk::Rectangle &background_area, const Gdk::Rectangle &cell_area, Gtk::CellRendererState flags) {
|
||||||
int available_xpad = background_area.get_width();
|
|
||||||
int available_ypad = background_area.get_height();
|
|
||||||
|
|
||||||
// todo: figure out how Gtk::Arrow is rendered because i like it better :^)
|
// todo: figure out how Gtk::Arrow is rendered because i like it better :^)
|
||||||
constexpr static int len = 5;
|
constexpr static int len = 5;
|
||||||
int x1, y1, x2, y2, x3, y3;
|
int x1, y1, x2, y2, x3, y3;
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ void ChatInputIndicator::ComputeTypingString() {
|
|||||||
SetTypingString(typers[0].Username + " and " + typers[1].Username + " are typing...");
|
SetTypingString(typers[0].Username + " and " + typers[1].Username + " are typing...");
|
||||||
} else if (typers.size() > 2 && typers.size() <= MaxUsersInIndicator) {
|
} else if (typers.size() > 2 && typers.size() <= MaxUsersInIndicator) {
|
||||||
Glib::ustring str;
|
Glib::ustring str;
|
||||||
for (int i = 0; i < typers.size() - 1; i++)
|
for (size_t i = 0; i < typers.size() - 1; i++)
|
||||||
str += typers[i].Username + ", ";
|
str += typers[i].Username + ", ";
|
||||||
SetTypingString(str + "and " + typers[typers.size() - 1].Username + " are typing...");
|
SetTypingString(str + "and " + typers[typers.size() - 1].Username + " are typing...");
|
||||||
} else { // size() > MaxUsersInIndicator
|
} else { // size() > MaxUsersInIndicator
|
||||||
|
|||||||
@@ -308,8 +308,6 @@ Gtk::Widget *ChatMessageItemContainer::CreateEmbedComponent(const EmbedData &emb
|
|||||||
|
|
||||||
constexpr static int AuthorIconSize = 20;
|
constexpr static int AuthorIconSize = 20;
|
||||||
if (embed.Author->ProxyIconURL.has_value()) {
|
if (embed.Author->ProxyIconURL.has_value()) {
|
||||||
auto &img = Abaddon::Get().GetImageManager();
|
|
||||||
|
|
||||||
auto *author_img = Gtk::manage(new LazyImage(*embed.Author->ProxyIconURL, AuthorIconSize, AuthorIconSize));
|
auto *author_img = Gtk::manage(new LazyImage(*embed.Author->ProxyIconURL, AuthorIconSize, AuthorIconSize));
|
||||||
author_img->set_halign(Gtk::ALIGN_START);
|
author_img->set_halign(Gtk::ALIGN_START);
|
||||||
author_img->set_valign(Gtk::ALIGN_START);
|
author_img->set_valign(Gtk::ALIGN_START);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ bool Completer::ProcessKeyPress(GdkEventKey *e) {
|
|||||||
switch (e->keyval) {
|
switch (e->keyval) {
|
||||||
case GDK_KEY_Down: {
|
case GDK_KEY_Down: {
|
||||||
if (m_entries.size() == 0) return true;
|
if (m_entries.size() == 0) return true;
|
||||||
const int index = m_list.get_selected_row()->get_index();
|
const auto index = static_cast<size_t>(m_list.get_selected_row()->get_index());
|
||||||
if (index >= m_entries.size() - 1) return true;
|
if (index >= m_entries.size() - 1) return true;
|
||||||
m_list.select_row(*m_entries[index + 1]);
|
m_list.select_row(*m_entries[index + 1]);
|
||||||
ScrollListBoxToSelected(m_list);
|
ScrollListBoxToSelected(m_list);
|
||||||
@@ -55,7 +55,7 @@ bool Completer::ProcessKeyPress(GdkEventKey *e) {
|
|||||||
return true;
|
return true;
|
||||||
case GDK_KEY_Up: {
|
case GDK_KEY_Up: {
|
||||||
if (m_entries.size() == 0) return true;
|
if (m_entries.size() == 0) return true;
|
||||||
const int index = m_list.get_selected_row()->get_index();
|
const auto index = static_cast<size_t>(m_list.get_selected_row()->get_index());
|
||||||
if (index == 0) return true;
|
if (index == 0) return true;
|
||||||
m_list.select_row(*m_entries[index - 1]);
|
m_list.select_row(*m_entries[index - 1]);
|
||||||
ScrollListBoxToSelected(m_list);
|
ScrollListBoxToSelected(m_list);
|
||||||
@@ -169,7 +169,7 @@ void Completer::CompleteEmojis(const Glib::ustring &term) {
|
|||||||
const auto guild = discord.GetGuild(*channel->GuildID);
|
const auto guild = discord.GetGuild(*channel->GuildID);
|
||||||
|
|
||||||
if (guild.has_value() && guild->Emojis.has_value())
|
if (guild.has_value() && guild->Emojis.has_value())
|
||||||
for (const auto tmp : *guild->Emojis) {
|
for (const auto &tmp : *guild->Emojis) {
|
||||||
const auto emoji = *discord.GetEmoji(tmp.ID);
|
const auto emoji = *discord.GetEmoji(tmp.ID);
|
||||||
if (emoji.IsAnimated.has_value() && *emoji.IsAnimated) continue;
|
if (emoji.IsAnimated.has_value() && *emoji.IsAnimated) continue;
|
||||||
if (emoji.IsAvailable.has_value() && !*emoji.IsAvailable) continue;
|
if (emoji.IsAvailable.has_value() && !*emoji.IsAvailable) continue;
|
||||||
@@ -186,7 +186,7 @@ void Completer::CompleteEmojis(const Glib::ustring &term) {
|
|||||||
for (const auto guild_id : discord.GetGuilds()) {
|
for (const auto guild_id : discord.GetGuilds()) {
|
||||||
const auto guild = discord.GetGuild(guild_id);
|
const auto guild = discord.GetGuild(guild_id);
|
||||||
if (!guild.has_value()) continue;
|
if (!guild.has_value()) continue;
|
||||||
for (const auto tmp : *guild->Emojis) {
|
for (const auto &tmp : *guild->Emojis) {
|
||||||
const auto emoji = *discord.GetEmoji(tmp.ID);
|
const auto emoji = *discord.GetEmoji(tmp.ID);
|
||||||
const bool is_animated = emoji.IsAnimated.has_value() && *emoji.IsAnimated;
|
const bool is_animated = emoji.IsAnimated.has_value() && *emoji.IsAnimated;
|
||||||
if (emoji.IsAvailable.has_value() && !*emoji.IsAvailable) continue;
|
if (emoji.IsAvailable.has_value() && !*emoji.IsAvailable) continue;
|
||||||
@@ -330,8 +330,8 @@ Glib::ustring Completer::GetTerm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CompleterEntry::CompleterEntry(const Glib::ustring &completion, int index)
|
CompleterEntry::CompleterEntry(const Glib::ustring &completion, int index)
|
||||||
: m_index(index)
|
: m_completion(completion)
|
||||||
, m_completion(completion)
|
, m_index(index)
|
||||||
, m_box(Gtk::ORIENTATION_HORIZONTAL) {
|
, m_box(Gtk::ORIENTATION_HORIZONTAL) {
|
||||||
set_halign(Gtk::ALIGN_START);
|
set_halign(Gtk::ALIGN_START);
|
||||||
get_style_context()->add_class("completer-entry");
|
get_style_context()->add_class("completer-entry");
|
||||||
|
|||||||
@@ -185,9 +185,9 @@ bool FriendsList::ListFilterFunc(Gtk::ListBoxRow *row_) {
|
|||||||
FriendsListAddComponent::FriendsListAddComponent()
|
FriendsListAddComponent::FriendsListAddComponent()
|
||||||
: Gtk::Box(Gtk::ORIENTATION_VERTICAL)
|
: Gtk::Box(Gtk::ORIENTATION_VERTICAL)
|
||||||
, m_label("Add a Friend", Gtk::ALIGN_START)
|
, m_label("Add a Friend", Gtk::ALIGN_START)
|
||||||
, m_box(Gtk::ORIENTATION_HORIZONTAL)
|
, m_status("", Gtk::ALIGN_START)
|
||||||
, m_add("Add")
|
, m_add("Add")
|
||||||
, m_status("", Gtk::ALIGN_START) {
|
, m_box(Gtk::ORIENTATION_HORIZONTAL) {
|
||||||
m_box.add(m_entry);
|
m_box.add(m_entry);
|
||||||
m_box.add(m_add);
|
m_box.add(m_add);
|
||||||
m_box.add(m_status);
|
m_box.add(m_status);
|
||||||
@@ -241,9 +241,9 @@ bool FriendsListAddComponent::OnKeyPress(GdkEventKey *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FriendsListFriendRow::FriendsListFriendRow(RelationshipType type, const UserData &data)
|
FriendsListFriendRow::FriendsListFriendRow(RelationshipType type, const UserData &data)
|
||||||
: Name(data.Username + "#" + data.Discriminator)
|
: ID(data.ID)
|
||||||
, Type(type)
|
, Type(type)
|
||||||
, ID(data.ID)
|
, Name(data.Username + "#" + data.Discriminator)
|
||||||
, Status(Abaddon::Get().GetDiscordClient().GetUserStatus(data.ID))
|
, Status(Abaddon::Get().GetDiscordClient().GetUserStatus(data.ID))
|
||||||
, m_accept("Accept") {
|
, m_accept("Accept") {
|
||||||
auto *ev = Gtk::manage(new Gtk::EventBox);
|
auto *ev = Gtk::manage(new Gtk::EventBox);
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
ConfirmDialog::ConfirmDialog(Gtk::Window &parent)
|
ConfirmDialog::ConfirmDialog(Gtk::Window &parent)
|
||||||
: Gtk::Dialog("Confirm", parent, true)
|
: Gtk::Dialog("Confirm", parent, true)
|
||||||
, m_layout(Gtk::ORIENTATION_VERTICAL)
|
, m_layout(Gtk::ORIENTATION_VERTICAL)
|
||||||
, m_bbox(Gtk::ORIENTATION_HORIZONTAL)
|
|
||||||
, m_ok("OK")
|
, m_ok("OK")
|
||||||
, m_cancel("Cancel") {
|
, m_cancel("Cancel")
|
||||||
|
, m_bbox(Gtk::ORIENTATION_HORIZONTAL) {
|
||||||
set_default_size(300, 50);
|
set_default_size(300, 50);
|
||||||
get_style_context()->add_class("app-window");
|
get_style_context()->add_class("app-window");
|
||||||
get_style_context()->add_class("app-popup");
|
get_style_context()->add_class("app-popup");
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
EditMessageDialog::EditMessageDialog(Gtk::Window &parent)
|
EditMessageDialog::EditMessageDialog(Gtk::Window &parent)
|
||||||
: Gtk::Dialog("Edit Message", parent, true)
|
: Gtk::Dialog("Edit Message", parent, true)
|
||||||
, m_layout(Gtk::ORIENTATION_VERTICAL)
|
, m_layout(Gtk::ORIENTATION_VERTICAL)
|
||||||
, m_bbox(Gtk::ORIENTATION_HORIZONTAL)
|
|
||||||
, m_ok("OK")
|
, m_ok("OK")
|
||||||
, m_cancel("Cancel") {
|
, m_cancel("Cancel")
|
||||||
|
, m_bbox(Gtk::ORIENTATION_HORIZONTAL) {
|
||||||
set_default_size(300, 50);
|
set_default_size(300, 50);
|
||||||
get_style_context()->add_class("app-window");
|
get_style_context()->add_class("app-window");
|
||||||
get_style_context()->add_class("app-popup");
|
get_style_context()->add_class("app-popup");
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
SetStatusDialog::SetStatusDialog(Gtk::Window &parent)
|
SetStatusDialog::SetStatusDialog(Gtk::Window &parent)
|
||||||
: Gtk::Dialog("Set Status", parent, true)
|
: Gtk::Dialog("Set Status", parent, true)
|
||||||
, m_layout(Gtk::ORIENTATION_VERTICAL)
|
, m_layout(Gtk::ORIENTATION_VERTICAL)
|
||||||
, m_bbox(Gtk::ORIENTATION_HORIZONTAL)
|
|
||||||
, m_bottom(Gtk::ORIENTATION_HORIZONTAL)
|
, m_bottom(Gtk::ORIENTATION_HORIZONTAL)
|
||||||
, m_ok("OK")
|
, m_ok("OK")
|
||||||
, m_cancel("Cancel") {
|
, m_cancel("Cancel")
|
||||||
|
, m_bbox(Gtk::ORIENTATION_HORIZONTAL) {
|
||||||
set_default_size(300, 50);
|
set_default_size(300, 50);
|
||||||
get_style_context()->add_class("app-window");
|
get_style_context()->add_class("app-window");
|
||||||
get_style_context()->add_class("app-popup");
|
get_style_context()->add_class("app-popup");
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ std::string trim(const std::string& str) {
|
|||||||
TokenDialog::TokenDialog(Gtk::Window &parent)
|
TokenDialog::TokenDialog(Gtk::Window &parent)
|
||||||
: Gtk::Dialog("Set Token", parent, true)
|
: Gtk::Dialog("Set Token", parent, true)
|
||||||
, m_layout(Gtk::ORIENTATION_VERTICAL)
|
, m_layout(Gtk::ORIENTATION_VERTICAL)
|
||||||
, m_bbox(Gtk::ORIENTATION_HORIZONTAL)
|
|
||||||
, m_ok("OK")
|
, m_ok("OK")
|
||||||
, m_cancel("Cancel") {
|
, m_cancel("Cancel")
|
||||||
|
, m_bbox(Gtk::ORIENTATION_HORIZONTAL) {
|
||||||
set_default_size(300, 50);
|
set_default_size(300, 50);
|
||||||
get_style_context()->add_class("app-window");
|
get_style_context()->add_class("app-window");
|
||||||
get_style_context()->add_class("app-popup");
|
get_style_context()->add_class("app-popup");
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "discord.hpp"
|
#include "discord.hpp"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cinttypes>
|
||||||
#include "../util.hpp"
|
#include "../util.hpp"
|
||||||
#include "../abaddon.hpp"
|
#include "../abaddon.hpp"
|
||||||
|
|
||||||
@@ -707,19 +708,20 @@ void DiscordClient::ModifyRoleColor(Snowflake guild_id, Snowflake role_id, Gdk::
|
|||||||
|
|
||||||
void DiscordClient::ModifyRolePosition(Snowflake guild_id, Snowflake role_id, int position, sigc::slot<void(DiscordError code)> callback) {
|
void DiscordClient::ModifyRolePosition(Snowflake guild_id, Snowflake role_id, int position, sigc::slot<void(DiscordError code)> callback) {
|
||||||
const auto roles = GetGuild(guild_id)->FetchRoles();
|
const auto roles = GetGuild(guild_id)->FetchRoles();
|
||||||
if (position > roles.size()) return;
|
if (static_cast<size_t>(position) > roles.size()) return;
|
||||||
// gay and makes you send every role in between new and old position
|
// gay and makes you send every role in between new and old position
|
||||||
size_t index_from = -1, index_to = -1;
|
constexpr auto IDX_MAX = ~size_t { 0 };
|
||||||
|
size_t index_from = IDX_MAX, index_to = IDX_MAX;
|
||||||
for (size_t i = 0; i < roles.size(); i++) {
|
for (size_t i = 0; i < roles.size(); i++) {
|
||||||
const auto &role = roles[i];
|
const auto &role = roles[i];
|
||||||
if (role.ID == role_id)
|
if (role.ID == role_id)
|
||||||
index_from = i;
|
index_from = i;
|
||||||
else if (role.Position == position)
|
else if (role.Position == position)
|
||||||
index_to = i;
|
index_to = i;
|
||||||
if (index_from != -1 && index_to != -1) break;
|
if (index_from != IDX_MAX && index_to != IDX_MAX) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index_from == -1 || index_to == -1) return;
|
if (index_from == IDX_MAX || index_to == IDX_MAX) return;
|
||||||
|
|
||||||
int dir;
|
int dir;
|
||||||
size_t range_from, range_to;
|
size_t range_from, range_to;
|
||||||
@@ -1276,11 +1278,11 @@ void DiscordClient::HandleGatewayMessage(std::string str) {
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
printf("Unknown opcode %d\n", m.Opcode);
|
printf("Unknown opcode %d\n", static_cast<int>(m.Opcode));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
fprintf(stderr, "error handling message (opcode %d): %s\n", m.Opcode, e.what());
|
fprintf(stderr, "error handling message (opcode %d): %s\n", static_cast<int>(m.Opcode), e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1320,7 +1322,7 @@ DiscordError DiscordClient::GetCodeFromResponse(const http::response_type &respo
|
|||||||
|
|
||||||
void DiscordClient::ProcessNewGuild(GuildData &guild) {
|
void DiscordClient::ProcessNewGuild(GuildData &guild) {
|
||||||
if (guild.IsUnavailable) {
|
if (guild.IsUnavailable) {
|
||||||
printf("guild (%lld) unavailable\n", static_cast<uint64_t>(guild.ID));
|
printf("guild (%" PRIu64 ") unavailable\n", static_cast<uint64_t>(guild.ID));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1375,7 +1377,7 @@ void DiscordClient::HandleGatewayReady(const GatewayMessage &msg) {
|
|||||||
m_store.SetUser(user.ID, user);
|
m_store.SetUser(user.ID, user);
|
||||||
|
|
||||||
if (data.MergedMembers.has_value()) {
|
if (data.MergedMembers.has_value()) {
|
||||||
for (int i = 0; i < data.MergedMembers->size(); i++) {
|
for (size_t i = 0; i < data.MergedMembers->size(); i++) {
|
||||||
const auto guild_id = data.Guilds[i].ID;
|
const auto guild_id = data.Guilds[i].ID;
|
||||||
for (const auto &member : data.MergedMembers.value()[i]) {
|
for (const auto &member : data.MergedMembers.value()[i]) {
|
||||||
m_store.SetGuildMember(guild_id, *member.UserID, member);
|
m_store.SetGuildMember(guild_id, *member.UserID, member);
|
||||||
@@ -1978,7 +1980,7 @@ void DiscordClient::HandleGatewayGuildDelete(const GatewayMessage &msg) {
|
|||||||
bool unavailable = msg.Data.contains("unavilable") && msg.Data.at("unavailable").get<bool>();
|
bool unavailable = msg.Data.contains("unavilable") && msg.Data.at("unavailable").get<bool>();
|
||||||
|
|
||||||
if (unavailable)
|
if (unavailable)
|
||||||
printf("guild %llu became unavailable\n", static_cast<uint64_t>(id));
|
printf("guild %" PRIu64 " became unavailable\n", static_cast<uint64_t>(id));
|
||||||
|
|
||||||
const auto guild = m_store.GetGuild(id);
|
const auto guild = m_store.GetGuild(id);
|
||||||
if (!guild.has_value()) {
|
if (!guild.has_value()) {
|
||||||
|
|||||||
@@ -191,7 +191,8 @@ std::vector<Snowflake> GuildData::GetSortedChannels(Snowflake ignore) const {
|
|||||||
std::vector<RoleData> GuildData::FetchRoles() const {
|
std::vector<RoleData> GuildData::FetchRoles() const {
|
||||||
if (!Roles.has_value()) return {};
|
if (!Roles.has_value()) return {};
|
||||||
std::vector<RoleData> ret;
|
std::vector<RoleData> ret;
|
||||||
for (const auto thing : *Roles)
|
ret.reserve(Roles->size());
|
||||||
|
for (const auto &thing : *Roles)
|
||||||
ret.push_back(*Abaddon::Get().GetDiscordClient().GetRole(thing.ID));
|
ret.push_back(*Abaddon::Get().GetDiscordClient().GetRole(thing.ID));
|
||||||
std::sort(ret.begin(), ret.end(), [](const RoleData &a, const RoleData &b) -> bool {
|
std::sort(ret.begin(), ret.end(), [](const RoleData &a, const RoleData &b) -> bool {
|
||||||
return a.Position > b.Position;
|
return a.Position > b.Position;
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ void FileCacheWorkerThread::loop() {
|
|||||||
m_cv.wait(lock);
|
m_cv.wait(lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const auto concurrency = Abaddon::Get().GetSettings().GetCacheHTTPConcurrency();
|
static const auto concurrency = static_cast<size_t>(Abaddon::Get().GetSettings().GetCacheHTTPConcurrency());
|
||||||
if (m_handles.size() < concurrency) {
|
if (m_handles.size() < concurrency) {
|
||||||
std::optional<QueueEntry> entry;
|
std::optional<QueueEntry> entry;
|
||||||
m_queue_mutex.lock();
|
m_queue_mutex.lock();
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
GuildSettingsBansPane::GuildSettingsBansPane(Snowflake id)
|
GuildSettingsBansPane::GuildSettingsBansPane(Snowflake id)
|
||||||
: Gtk::Box(Gtk::ORIENTATION_VERTICAL)
|
: Gtk::Box(Gtk::ORIENTATION_VERTICAL)
|
||||||
, GuildID(id)
|
, GuildID(id)
|
||||||
|
, m_model(Gtk::ListStore::create(m_columns))
|
||||||
, m_menu_unban("Unban")
|
, m_menu_unban("Unban")
|
||||||
, m_menu_copy_id("Copy ID")
|
, m_menu_copy_id("Copy ID") {
|
||||||
, m_model(Gtk::ListStore::create(m_columns)) {
|
|
||||||
signal_map().connect(sigc::mem_fun(*this, &GuildSettingsBansPane::OnMap));
|
signal_map().connect(sigc::mem_fun(*this, &GuildSettingsBansPane::OnMap));
|
||||||
set_name("guild-bans-pane");
|
set_name("guild-bans-pane");
|
||||||
set_hexpand(true);
|
set_hexpand(true);
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ GuildSettingsEmojisPane::GuildSettingsEmojisPane(Snowflake guild_id)
|
|||||||
, GuildID(guild_id)
|
, GuildID(guild_id)
|
||||||
, m_model(Gtk::ListStore::create(m_columns))
|
, m_model(Gtk::ListStore::create(m_columns))
|
||||||
, m_filter(Gtk::TreeModelFilter::create(m_model))
|
, m_filter(Gtk::TreeModelFilter::create(m_model))
|
||||||
, m_menu_copy_id("Copy ID")
|
|
||||||
, m_menu_delete("Delete")
|
, m_menu_delete("Delete")
|
||||||
|
, m_menu_copy_id("Copy ID")
|
||||||
, m_menu_copy_emoji_url("Copy Emoji URL")
|
, m_menu_copy_emoji_url("Copy Emoji URL")
|
||||||
, m_menu_show_emoji("Open in Browser") {
|
, m_menu_show_emoji("Open in Browser") {
|
||||||
signal_map().connect(sigc::mem_fun(*this, &GuildSettingsEmojisPane::OnMap));
|
signal_map().connect(sigc::mem_fun(*this, &GuildSettingsEmojisPane::OnMap));
|
||||||
@@ -31,7 +31,6 @@ GuildSettingsEmojisPane::GuildSettingsEmojisPane(Snowflake guild_id)
|
|||||||
m_menu.show_all();
|
m_menu.show_all();
|
||||||
|
|
||||||
auto &discord = Abaddon::Get().GetDiscordClient();
|
auto &discord = Abaddon::Get().GetDiscordClient();
|
||||||
auto &img = Abaddon::Get().GetImageManager();
|
|
||||||
|
|
||||||
discord.signal_guild_emojis_update().connect(sigc::hide<0>(sigc::mem_fun(*this, &GuildSettingsEmojisPane::OnFetchEmojis)));
|
discord.signal_guild_emojis_update().connect(sigc::hide<0>(sigc::mem_fun(*this, &GuildSettingsEmojisPane::OnFetchEmojis)));
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
GuildSettingsInfoPane::GuildSettingsInfoPane(Snowflake id)
|
GuildSettingsInfoPane::GuildSettingsInfoPane(Snowflake id)
|
||||||
: GuildID(id)
|
: m_guild_icon_label("Guild icon")
|
||||||
, m_guild_name_label("Guild name")
|
, m_guild_name_label("Guild name")
|
||||||
, m_guild_icon_label("Guild icon") {
|
, GuildID(id) {
|
||||||
auto &discord = Abaddon::Get().GetDiscordClient();
|
auto &discord = Abaddon::Get().GetDiscordClient();
|
||||||
const auto guild = *discord.GetGuild(id);
|
const auto guild = *discord.GetGuild(id);
|
||||||
const auto self_id = discord.GetUserData().ID;
|
const auto self_id = discord.GetUserData().ID;
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ void GuildSettingsInvitesPane::OnMap() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GuildSettingsInvitesPane::AppendInvite(const InviteData &invite) {
|
void GuildSettingsInvitesPane::AppendInvite(const InviteData &invite) {
|
||||||
auto &discord = Abaddon::Get().GetDiscordClient();
|
|
||||||
auto row = *m_model->append();
|
auto row = *m_model->append();
|
||||||
row[m_columns.m_col_code] = invite.Code;
|
row[m_columns.m_col_code] = invite.Code;
|
||||||
if (invite.Inviter.has_value())
|
if (invite.Inviter.has_value())
|
||||||
@@ -77,7 +76,6 @@ void GuildSettingsInvitesPane::OnInviteFetch(const std::optional<InviteData> &in
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GuildSettingsInvitesPane::OnInvitesFetch(const std::vector<InviteData> &invites) {
|
void GuildSettingsInvitesPane::OnInvitesFetch(const std::vector<InviteData> &invites) {
|
||||||
auto &discord = Abaddon::Get().GetDiscordClient();
|
|
||||||
for (const auto &invite : invites)
|
for (const auto &invite : invites)
|
||||||
AppendInvite(invite);
|
AppendInvite(invite);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
|
|
||||||
GuildSettingsMembersPane::GuildSettingsMembersPane(Snowflake id)
|
GuildSettingsMembersPane::GuildSettingsMembersPane(Snowflake id)
|
||||||
: Gtk::Box(Gtk::ORIENTATION_VERTICAL)
|
: Gtk::Box(Gtk::ORIENTATION_VERTICAL)
|
||||||
|
, GuildID(id)
|
||||||
, m_layout(Gtk::ORIENTATION_HORIZONTAL)
|
, m_layout(Gtk::ORIENTATION_HORIZONTAL)
|
||||||
, m_member_list(id)
|
, m_member_list(id)
|
||||||
, m_member_info(id)
|
, m_member_info(id) {
|
||||||
, GuildID(id) {
|
|
||||||
set_name("guild-members-pane");
|
set_name("guild-members-pane");
|
||||||
set_hexpand(true);
|
set_hexpand(true);
|
||||||
set_vexpand(true);
|
set_vexpand(true);
|
||||||
@@ -158,9 +158,9 @@ void GuildSettingsMembersListItem::UpdateColor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GuildSettingsMembersPaneInfo::GuildSettingsMembersPaneInfo(Snowflake guild_id)
|
GuildSettingsMembersPaneInfo::GuildSettingsMembersPaneInfo(Snowflake guild_id)
|
||||||
: m_box(Gtk::ORIENTATION_VERTICAL)
|
: GuildID(guild_id)
|
||||||
, GuildID(guild_id)
|
, m_roles(guild_id)
|
||||||
, m_roles(guild_id) {
|
, m_box(Gtk::ORIENTATION_VERTICAL) {
|
||||||
get_style_context()->add_class("guild-members-pane-info");
|
get_style_context()->add_class("guild-members-pane-info");
|
||||||
|
|
||||||
const auto label = [](Gtk::Label &lbl) {
|
const auto label = [](Gtk::Label &lbl) {
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ GuildSettingsRolesPaneRoles::GuildSettingsRolesPaneRoles(Snowflake guild_id)
|
|||||||
auto &discord = Abaddon::Get().GetDiscordClient();
|
auto &discord = Abaddon::Get().GetDiscordClient();
|
||||||
const auto num_rows = m_list.get_children().size();
|
const auto num_rows = m_list.get_children().size();
|
||||||
const auto new_pos = num_rows - new_index - 1;
|
const auto new_pos = num_rows - new_index - 1;
|
||||||
if (row->RoleID == GuildID) return true; // moving role @everyone
|
if (row->RoleID == GuildID) return true; // moving role @everyone
|
||||||
if (new_index == num_rows) return true; // trying to move row below @everyone
|
if (static_cast<size_t>(new_index) == num_rows) return true; // trying to move row below @everyone
|
||||||
// make sure it wont modify a neighbor role u dont have perms to modify
|
// make sure it wont modify a neighbor role u dont have perms to modify
|
||||||
if (!discord.CanModifyRole(GuildID, row->RoleID)) return false;
|
if (!discord.CanModifyRole(GuildID, row->RoleID)) return false;
|
||||||
const auto cb = [this](DiscordError code) {
|
const auto cb = [this](DiscordError code) {
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
|
|
||||||
GuildSettingsWindow::GuildSettingsWindow(Snowflake id)
|
GuildSettingsWindow::GuildSettingsWindow(Snowflake id)
|
||||||
: m_main(Gtk::ORIENTATION_VERTICAL)
|
: m_main(Gtk::ORIENTATION_VERTICAL)
|
||||||
, GuildID(id)
|
|
||||||
, m_pane_info(id)
|
, m_pane_info(id)
|
||||||
, m_pane_bans(id)
|
|
||||||
, m_pane_invites(id)
|
|
||||||
, m_pane_audit_log(id)
|
|
||||||
, m_pane_members(id)
|
, m_pane_members(id)
|
||||||
, m_pane_roles(id)
|
, m_pane_roles(id)
|
||||||
, m_pane_emojis(id) {
|
, m_pane_bans(id)
|
||||||
|
, m_pane_invites(id)
|
||||||
|
, m_pane_emojis(id)
|
||||||
|
, m_pane_audit_log(id)
|
||||||
|
, GuildID(id) {
|
||||||
auto &discord = Abaddon::Get().GetDiscordClient();
|
auto &discord = Abaddon::Get().GetDiscordClient();
|
||||||
const auto guild = *discord.GetGuild(id);
|
const auto guild = *discord.GetGuild(id);
|
||||||
|
|
||||||
|
|||||||
@@ -179,7 +179,6 @@ void MainWindow::UpdateChatWindowContents() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::UpdateChatActiveChannel(Snowflake id) {
|
void MainWindow::UpdateChatActiveChannel(Snowflake id) {
|
||||||
auto &discord = Abaddon::Get().GetDiscordClient();
|
|
||||||
m_chat.SetActiveChannel(id);
|
m_chat.SetActiveChannel(id);
|
||||||
m_members.SetActiveChannel(id);
|
m_members.SetActiveChannel(id);
|
||||||
m_channel_list.SetActiveChannel(id);
|
m_channel_list.SetActiveChannel(id);
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
#include "../../abaddon.hpp"
|
#include "../../abaddon.hpp"
|
||||||
|
|
||||||
ConnectionItem::ConnectionItem(const ConnectionData &conn)
|
ConnectionItem::ConnectionItem(const ConnectionData &conn)
|
||||||
: m_name(conn.Name)
|
: m_box(Gtk::ORIENTATION_HORIZONTAL)
|
||||||
, m_box(Gtk::ORIENTATION_HORIZONTAL) {
|
, m_name(conn.Name) {
|
||||||
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
|
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
|
||||||
try {
|
try {
|
||||||
pixbuf = Gdk::Pixbuf::create_from_file(Abaddon::GetResPath("/" + conn.Type + ".png"), 32, 32);
|
pixbuf = Gdk::Pixbuf::create_from_file(Abaddon::GetResPath("/" + conn.Type + ".png"), 32, 32);
|
||||||
@@ -97,7 +97,7 @@ void ConnectionsContainer::SetConnections(const std::vector<ConnectionData> &con
|
|||||||
"facebook"
|
"facebook"
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i < connections.size(); i++) {
|
for (size_t i = 0; i < connections.size(); i++) {
|
||||||
const auto &conn = connections[i];
|
const auto &conn = connections[i];
|
||||||
if (supported_services.find(conn.Type) == supported_services.end()) continue;
|
if (supported_services.find(conn.Type) == supported_services.end()) continue;
|
||||||
auto widget = Gtk::manage(new ConnectionItem(conn));
|
auto widget = Gtk::manage(new ConnectionItem(conn));
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
ThreadsWindow::ThreadsWindow(const ChannelData &channel)
|
ThreadsWindow::ThreadsWindow(const ChannelData &channel)
|
||||||
: m_channel_id(channel.ID)
|
: m_channel_id(channel.ID)
|
||||||
|
, m_filter_public(m_group, "Public")
|
||||||
|
, m_filter_private(m_group, "Private")
|
||||||
, m_box(Gtk::ORIENTATION_VERTICAL)
|
, m_box(Gtk::ORIENTATION_VERTICAL)
|
||||||
, m_active(channel, sigc::mem_fun(*this, &ThreadsWindow::ListFilterFunc))
|
, m_active(channel, sigc::mem_fun(*this, &ThreadsWindow::ListFilterFunc))
|
||||||
, m_archived(channel, sigc::mem_fun(*this, &ThreadsWindow::ListFilterFunc))
|
, m_archived(channel, sigc::mem_fun(*this, &ThreadsWindow::ListFilterFunc)) {
|
||||||
, m_filter_public(m_group, "Public")
|
|
||||||
, m_filter_private(m_group, "Private") {
|
|
||||||
set_name("threads-window");
|
set_name("threads-window");
|
||||||
set_default_size(450, 375);
|
set_default_size(450, 375);
|
||||||
set_title("#" + *channel.Name + " - Threads");
|
set_title("#" + *channel.Name + " - Threads");
|
||||||
|
|||||||
Reference in New Issue
Block a user