Merge branch 'master' into member-list

This commit is contained in:
ouwou
2022-12-18 17:54:19 -05:00
6 changed files with 193 additions and 117 deletions

View File

@@ -160,7 +160,7 @@ jobs:
cd deps cd deps
git clone https://github.com/nlohmann/json git clone https://github.com/nlohmann/json
cd json cd json
git checkout db78ac1d7716f56fc9f1b030b715f872f93964e4 git checkout bc889afb4c5bf1c0d8ee29ef35eaaf4c8bef8a5d
mkdir build mkdir build
cd build cd build
cmake .. cmake ..

3
.gitmodules vendored
View File

@@ -4,3 +4,6 @@
[submodule "subprojects/ixwebsocket"] [submodule "subprojects/ixwebsocket"]
path = subprojects/ixwebsocket path = subprojects/ixwebsocket
url = https://github.com/machinezone/ixwebsocket url = https://github.com/machinezone/ixwebsocket
[submodule "subprojects/keychain"]
path = subprojects/keychain
url = https://github.com/hrantzsch/keychain

View File

@@ -8,6 +8,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
option(USE_LIBHANDY "Enable features that require libhandy (default)" ON) option(USE_LIBHANDY "Enable features that require libhandy (default)" ON)
option(USE_KEYCHAIN "Store the token in the keychain (default)" ON)
find_package(nlohmann_json REQUIRED) find_package(nlohmann_json REQUIRED)
find_package(CURL) find_package(CURL)
@@ -106,3 +107,13 @@ if (USE_LIBHANDY)
target_compile_definitions(abaddon PRIVATE WITH_LIBHANDY) target_compile_definitions(abaddon PRIVATE WITH_LIBHANDY)
endif () endif ()
endif () endif ()
if (USE_KEYCHAIN)
find_package(keychain QUIET)
if (NOT keychain_FOUND)
message("keychain was not found and will be included as a submodule")
add_subdirectory(subprojects/keychain)
target_link_libraries(abaddon keychain)
target_compile_definitions(abaddon PRIVATE WITH_KEYCHAIN)
endif ()
endif ()

245
README.md
View File

@@ -75,6 +75,10 @@ the result of fundamental issues with Discord's thread implementation.
```Shell ```Shell
$ sudo apt install g++ cmake libgtkmm-3.0-dev libcurl4-gnutls-dev libsqlite3-dev libssl-dev nlohmann-json3-dev $ sudo apt install g++ cmake libgtkmm-3.0-dev libcurl4-gnutls-dev libsqlite3-dev libssl-dev nlohmann-json3-dev
``` ```
* On Arch Linux
```Shell
$ sudo pacman -S gcc cmake gtkmm3 libcurl-gnutls lib32-sqlite lib32-openssl nlohmann-json libhandy
```
2. `git clone https://github.com/uowuo/abaddon --recurse-submodules="subprojects" && cd abaddon` 2. `git clone https://github.com/uowuo/abaddon --recurse-submodules="subprojects" && cd abaddon`
3. `mkdir build && cd build` 3. `mkdir build && cd build`
4. `cmake ..` 4. `cmake ..`
@@ -92,7 +96,7 @@ Latest release version: https://github.com/uowuo/abaddon/releases/latest
- Linux: [here](https://nightly.link/uowuo/abaddon/workflows/ci/master/build-linux-MinSizeRel.zip) unpackaged (for now), - Linux: [here](https://nightly.link/uowuo/abaddon/workflows/ci/master/build-linux-MinSizeRel.zip) unpackaged (for now),
requires gtkmm3. built on Ubuntu 18.04 + gcc9 requires gtkmm3. built on Ubuntu 18.04 + gcc9
⚠️ If you use Windows, make sure to start from the `bin` directory > **Warning**: If you use Windows, make sure to start from the `bin` directory
On Linux, `css` and `res` can also be loaded from `~/.local/share/abaddon` or `/usr/share/abaddon` On Linux, `css` and `res` can also be loaded from `~/.local/share/abaddon` or `/usr/share/abaddon`
@@ -135,145 +139,158 @@ spam filter's wrath:
#### CSS selectors #### CSS selectors
.app-window - Applied to all windows. This means the main window and all popups | Selector | Description |
.app-popup - Additional class for `.app-window`s when the window is not the main window |--------------------------------|---------------------------------------------------------------------------------------------------|
| `.app-window` | Applied to all windows. This means the main window and all popups |
| `.app-popup` | Additional class for `.app-window`s when the window is not the main window |
| `.channel-list` | Container of the channel list |
| `.messages` | Container of user messages |
| `.message-container` | The container which holds a user's messages |
| `.message-container-author` | The author label for a message container |
| `.message-container-timestamp` | The timestamp label for a message container |
| `.message-container-avatar` | Avatar for a user in a message |
| `.message-container-extra` | Label containing BOT/Webhook |
| `.message-text` | The text of a user message |
| `.pending` | Extra class of .message-text for messages pending to be sent |
| `.failed` | Extra class of .message-text for messages that failed to be sent |
| `.message-attachment-box` | Contains attachment info |
| `.message-reply` | Container for the replied-to message in a reply (these elements will also have .message-text set) |
| `.message-input` | Applied to the chat input container |
| `.replying` | Extra class for chat input container when a reply is currently being created |
| `.reaction-box` | Contains a reaction image and the count |
| `.reacted` | Additional class for reaction-box when the user has reacted with a particular reaction |
| `.reaction-count` | Contains the count for reaction |
| `.completer` | Container for the message completer |
| `.completer-entry` | Container for a single entry in the completer |
| `.completer-entry-label` | Contains the label for an entry in the completer |
| `.completer-entry-image` | Contains the image for an entry in the completer |
| `.embed` | Container for a message embed |
| `.embed-author` | The author of an embed |
| `.embed-title` | The title of an embed |
| `.embed-description` | The description of an embed |
| `.embed-field-title` | The title of an embed field |
| `.embed-field-value` | The value of an embed field |
| `.embed-footer` | The footer of an embed |
| `.members` | Container of the member list |
| `.members-row` | All rows within the members container |
| `.members-row-label` | All labels in the members container |
| `.members-row-member` | Rows containing a member |
| `.members-row-role` | Rows containing a role |
| `.members-row-avatar` | Contains the avatar for a row in the member list |
| `.status-indicator` | The status indicator |
| `.online` | Applied to status indicators when the associated user is online |
| `.idle` | Applied to status indicators when the associated user is away |
| `.dnd` | Applied to status indicators when the associated user is on do not disturb |
| `.offline` | Applied to status indicators when the associated user is offline |
| `.typing-indicator` | The typing indicator (also used for replies) |
.channel-list - Container of the channel list Used in reorderable list implementation:
| Selector |
|----------------------|
| `.drag-icon` |
| `.drag-hover-top` |
| `.drag-hover-bottom` |
.messages - Container of user messages Used in guild settings popup:
.message-container - The container which holds a user's messages
.message-container-author - The author label for a message container
.message-container-timestamp - The timestamp label for a message container
.message-container-avatar - Avatar for a user in a message
.message-container-extra - Label containing BOT/Webhook
.message-text - The text of a user message
.pending - Extra class of .message-text for messages pending to be sent
.failed - Extra class of .message-text for messages that failed to be sent
.message-attachment-box - Contains attachment info
.message-reply - Container for the replied-to message in a reply (these elements will also have .message-text set)
.message-input - Applied to the chat input container
.replying - Extra class for chat input container when a reply is currently being created
.reaction-box - Contains a reaction image and the count
.reacted - Additional class for reaction-box when the user has reacted with a particular reaction
.reaction-count - Contains the count for reaction
.completer - Container for the message completer | Selector | Description |
.completer-entry - Container for a single entry in the completer |----------------------------|---------------------------------------------------|
.completer-entry-label - Contains the label for an entry in the completer | `.guild-settings-window` | Container for list of members in the members pane |
.completer-entry-image - Contains the image for an entry in the completer | `.guild-members-pane-list` | |
| `.guild-members-pane-info` | Container for member info |
| `.guild-roles-pane-list` | Container for list of roles in the roles pane |
.embed - Container for a message embed Used in profile popup:
.embed-author - The author of an embed
.embed-title - The title of an embed
.embed-description - The description of an embed
.embed-field-title - The title of an embed field
.embed-field-value - The value of an embed field
.embed-footer - The footer of an embed
.members - Container of the member list | Selector | Description |
.members-row - All rows within the members container |------------------------------|---------------------------------------------------------|
.members-row-label - All labels in the members container | `.mutual-friend-item` | Applied to every item in the mutual friends list |
.members-row-member - Rows containing a member | `.mutual-friend-item-name` | Name in mutual friend item |
.members-row-role - Rows containing a role | `.mutual-friend-item-avatar` | Avatar in mutual friend item |
.members-row-avatar - Contains the avatar for a row in the member list | `.mutual-guild-item` | Applied to every item in the mutual guilds list |
| `.mutual-guild-item-name` | Name in mutual guild item |
.status-indicator - The status indicator | `.mutual-guild-item-icon` | Icon in mutual guild item |
.online - Applied to status indicators when the associated user is online | `.mutual-guild-item-nick` | User nickname in mutual guild item |
.idle - Applied to status indicators when the associated user is away | `.profile-connection` | Applied to every item in the user connections list |
.dnd - Applied to status indicators when the associated user is on do not disturb | `.profile-connection-label` | Label in profile connection item |
.offline - Applied to status indicators when the associated user is offline | `.profile-connection-check` | Checkmark in verified profile connection items |
| `.profile-connections` | Container for profile connections |
.typing-indicator - The typing indicator (also used for replies) | `.profile-notes` | Container for notes in profile window |
| `.profile-notes-label` | Label that says "NOTE" |
Used in reorderable list implementation: | `.profile-notes-text` | Actual note text |
.drag-icon .drag-hover-top .drag-hover-bottom | `.profile-info-pane` | Applied to container for info section of profile popup |
| `.profile-info-created` | Label for creation date of profile |
Used in guild settings popup: | `.user-profile-window` | |
.guild-settings-window | `.profile-main-container` | Inner container for profile |
.guild-members-pane-list - Container for list of members in the members pane | `.profile-avatar` | |
.guild-members-pane-info - Container for member info | `.profile-username` | |
.guild-roles-pane-list - Container for list of roles in the roles pane | `.profile-switcher` | Buttons used to switch viewed section of profile |
| `.profile-stack` | Container for profile info that can be switched between |
Used in profile popup: | `.profile-badges` | Container for badges |
.mutual-friend-item - Applied to every item in the mutual friends list | `.profile-badge` | |
.mutual-friend-item-name - Name in mutual friend item
.mutual-friend-item-avatar - Avatar in mutual friend item
.mutual-guild-item - Applied to every item in the mutual guilds list
.mutual-guild-item-name - Name in mutual guild item
.mutual-guild-item-icon - Icon in mutual guild item
.mutual-guild-item-nick - User nickname in mutual guild item
.profile-connection - Applied to every item in the user connections list
.profile-connection-label - Label in profile connection item
.profile-connection-check - Checkmark in verified profile connection items
.profile-connections - Container for profile connections
.profile-notes - Container for notes in profile window
.profile-notes-label - Label that says "NOTE"
.profile-notes-text - Actual note text
.profile-info-pane - Applied to container for info section of profile popup
.profile-info-created - Label for creation date of profile
.user-profile-window
.profile-main-container - Inner container for profile
.profile-avatar
.profile-username
.profile-switcher - Buttons used to switch viewed section of profile
.profile-stack - Container for profile info that can be switched between
.profile-badges - Container for badges
.profile-badge
### Settings ### Settings
Settings are configured (for now) by editing abaddon.ini Settings are configured (for now) by editing `abaddon.ini`.
The format is similar to the standard Windows ini format **except**: The format is similar to the standard Windows ini format **except**:
* `#` is used to begin comments as opposed to `;` * `#` is used to begin comments as opposed to `;`
* Section and key names are case-sensitive * Section and key names are case-sensitive
You should edit these while the client is closed even though there's an option to reload while running > **Warning**: You should edit these while the client is closed, even though there's an option to reload while running.
This listing is organized by section.
This listing is organized by section.
For example, memory_db would be set by adding `memory_db = true` under the line `[discord]` For example, memory_db would be set by adding `memory_db = true` under the line `[discord]`
#### discord #### discord
* gateway (string) - override url for Discord gateway. must be json format and use zlib stream compression | Setting | Type | Default | Description |
* api_base (string) - override base url for Discord API |---------------|---------|---------|--------------------------------------------------------------------------------------------------|
* memory_db (true or false, default false) - if true, Discord data will be kept in memory as opposed to on disk | `gateway` | string | | override url for Discord gateway. must be json format and use zlib stream compression |
* token (string) - Discord token used to login, this can be set from the menu | `api_base` | string | | override base url for Discord API |
* prefetch (true or false, default false) - if true, new messages will cause the avatar and image attachments to be | `memory_db` | boolean | false | if true, Discord data will be kept in memory as opposed to on disk |
automatically downloaded | `token` | string | | Discord token used to login, this can be set from the menu |
| `prefetch` | boolean | false | if true, new messages will cause the avatar and image attachments to be automatically downloaded |
| `autoconnect` | boolean | false | autoconnect to discord |
#### http #### http
* user_agent (string) - sets the user-agent to use in HTTP requests to the Discord API (not including media/images) | Setting | Type | Default | Description |
* concurrent (int, default 20) - how many images can be concurrently retrieved |--------------|--------|---------|---------------------------------------------------------------------------------------------|
| `user_agent` | string | | sets the user-agent to use in HTTP requests to the Discord API (not including media/images) |
| `concurrent` | int | 20 | how many images can be concurrently retrieved |
#### gui #### gui
* member_list_discriminator (true or false, default true) - show user discriminators in the member list | Setting | Type | Default | Description |
* stock_emojis (true or false, default true) - allow abaddon to substitute unicode emojis with images from emojis.bin, |-----------------------------|---------|---------|----------------------------------------------------------------------------------------------------------------------------|
must be false to allow GTK to render emojis itself | `member_list_discriminator` | boolean | true | show user discriminators in the member list |
* custom_emojis (true or false, default true) - download and use custom Discord emojis | `stock_emojis` | boolean | true | allow abaddon to substitute unicode emojis with images from emojis.bin, must be false to allow GTK to render emojis itself |
* css (string) - path to the main CSS file | `custom_emojis` | boolean | true | download and use custom Discord emojis |
* animations (true or false, default true) - use animated images where available (e.g. server icons, emojis, avatars). | `css` | string | | path to the main CSS file |
false means static images will be used | `animations` | boolean | true | use animated images where available (e.g. server icons, emojis, avatars). false means static images will be used |
* animated_guild_hover_only (true or false, default true) - only animate guild icons when the guild is being hovered | `animated_guild_hover_only` | boolean | true | only animate guild icons when the guild is being hovered over |
over | `owner_crown` | boolean | true | show a crown next to the owner |
* owner_crown (true or false, default true) - show a crown next to the owner | `unreads` | boolean | true | show unread indicators and mention badges |
* unreads (true or false, default true) - show unread indicators and mention badges | `save_state` | boolean | true | save the state of the gui (active channels, tabs, expanded channels) |
* save_state (true or false, default true) - save the state of the gui (active channels, tabs, expanded channels) | `alt_menu` | boolean | false | keep the menu hidden unless revealed with alt key |
* alt_menu (true or false, default false) - keep the menu hidden unless revealed with alt key | `hide_to_tray` | boolean | false | hide abaddon to the system tray on window close |
* hide_to_tray (true or false, default false) - hide abaddon to the system tray on window close
#### style #### style
* linkcolor (string) - color to use for links in messages | Setting | Type | Description |
* expandercolor (string) - color to use for the expander in the channel list |-------------------------|--------|-----------------------------------------------------|
* nsfwchannelcolor (string) - color to use for NSFW channels in the channel list | `linkcolor` | string | color to use for links in messages |
* channelcolor (string) - color to use for SFW channels in the channel list | `expandercolor` | string | color to use for the expander in the channel list |
* mentionbadgecolor (string) - background color for mention badges | `nsfwchannelcolor` | string | color to use for NSFW channels in the channel list |
* mentionbadgetextcolor (string) - color to use for number displayed on mention badges | `channelcolor` | string | color to use for SFW channels in the channel list |
* unreadcolor (string) - color to use for the unread indicator | `mentionbadgecolor` | string | background color for mention badges |
| `mentionbadgetextcolor` | string | color to use for number displayed on mention badges |
| `unreadcolor` | string | color to use for the unread indicator |
### Environment variables ### Environment variables
* ABADDON_NO_FC (Windows only) - don't use custom font config | variable | Description |
* ABADDON_CONFIG - change path of configuration file to use. relative to cwd or can be absolute |------------------|------------------------------------------------------------------------------|
| `ABADDON_NO_FC` | (Windows only) don't use custom font config |
| `ABADDON_CONFIG` | change path of configuration file to use. relative to cwd or can be absolute |

View File

@@ -1,6 +1,15 @@
#include "settings.hpp" #include "settings.hpp"
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include <glibmm/miscutils.h>
#ifdef WITH_KEYCHAIN
#include <keychain/keychain.h>
#endif
const std::string KeychainPackage = "com.github.uowuo.abaddon";
const std::string KeychainService = "abaddon-client-token";
const std::string KeychainUser = "";
SettingsManager::SettingsManager(const std::string &filename) SettingsManager::SettingsManager(const std::string &filename)
: m_filename(filename) { : m_filename(filename) {
@@ -36,7 +45,6 @@ void SettingsManager::ReadSettings() {
SMSTR("discord", "api_base", APIBaseURL); SMSTR("discord", "api_base", APIBaseURL);
SMSTR("discord", "gateway", GatewayURL); SMSTR("discord", "gateway", GatewayURL);
SMSTR("discord", "token", DiscordToken);
SMBOOL("discord", "memory_db", UseMemoryDB); SMBOOL("discord", "memory_db", UseMemoryDB);
SMBOOL("discord", "prefetch", Prefetch); SMBOOL("discord", "prefetch", Prefetch);
SMBOOL("discord", "autoconnect", Autoconnect); SMBOOL("discord", "autoconnect", Autoconnect);
@@ -61,6 +69,32 @@ void SettingsManager::ReadSettings() {
SMSTR("style", "mentionbadgetextcolor", MentionBadgeTextColor); SMSTR("style", "mentionbadgetextcolor", MentionBadgeTextColor);
SMSTR("style", "unreadcolor", UnreadIndicatorColor); SMSTR("style", "unreadcolor", UnreadIndicatorColor);
#ifdef WITH_KEYCHAIN
keychain::Error error {};
// convert to keychain if present in normal settings
SMSTR("discord", "token", DiscordToken);
if (!m_settings.DiscordToken.empty()) {
keychain::Error set_error {};
keychain::setPassword(KeychainPackage, KeychainService, KeychainUser, m_settings.DiscordToken, set_error);
if (set_error) {
printf("keychain error setting token: %s\n", set_error.message.c_str());
} else {
m_file.remove_key("discord", "token");
}
}
m_settings.DiscordToken = keychain::getPassword(KeychainPackage, KeychainService, KeychainUser, error);
if (error && error.type != keychain::ErrorType::NotFound) {
printf("keychain error reading token: %s (%d)\n", error.message.c_str(), error.code);
}
#else
SMSTR("discord", "token", DiscordToken);
#endif
#undef SMBOOL #undef SMBOOL
#undef SMSTR #undef SMSTR
#undef SMINT #undef SMINT
@@ -92,7 +126,6 @@ void SettingsManager::Close() {
SMSTR("discord", "api_base", APIBaseURL); SMSTR("discord", "api_base", APIBaseURL);
SMSTR("discord", "gateway", GatewayURL); SMSTR("discord", "gateway", GatewayURL);
SMSTR("discord", "token", DiscordToken);
SMBOOL("discord", "memory_db", UseMemoryDB); SMBOOL("discord", "memory_db", UseMemoryDB);
SMBOOL("discord", "prefetch", Prefetch); SMBOOL("discord", "prefetch", Prefetch);
SMBOOL("discord", "autoconnect", Autoconnect); SMBOOL("discord", "autoconnect", Autoconnect);
@@ -117,6 +150,17 @@ void SettingsManager::Close() {
SMSTR("style", "mentionbadgetextcolor", MentionBadgeTextColor); SMSTR("style", "mentionbadgetextcolor", MentionBadgeTextColor);
SMSTR("style", "unreadcolor", UnreadIndicatorColor); SMSTR("style", "unreadcolor", UnreadIndicatorColor);
#ifdef WITH_KEYCHAIN
keychain::Error error {};
keychain::setPassword(KeychainPackage, KeychainService, KeychainUser, m_settings.DiscordToken, error);
if (error) {
printf("keychain error setting token: %s\n", error.message.c_str());
}
#else
SMSTR("discord", "token", DiscordToken);
#endif
#undef SMSTR #undef SMSTR
#undef SMBOOL #undef SMBOOL
#undef SMINT #undef SMINT

1
subprojects/keychain Submodule

Submodule subprojects/keychain added at 44b517d096