improve build process, add github actions

This commit is contained in:
ouwou 2021-01-07 02:41:49 -05:00
parent 2d6c4cd50d
commit 8cf95fce0c
56 changed files with 1210 additions and 309 deletions

152
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,152 @@
name: Abaddon CI
on: [push, pull_request]
jobs:
windows:
name: windows-${{ matrix.buildtype }}
runs-on: windows-latest
strategy:
matrix:
buildtype: [Debug, RelWithDebInfo]
steps:
- uses: actions/checkout@v1
with:
submodules: true
- name: Fetch CMake
uses: lukka/get-cmake@latest
- name: Fetch dependencies
uses: lukka/run-vcpkg@main
with:
vcpkgArguments: gtkmm nlohmann-json cpr zlib sqlite3 glibmm openssl ixwebsocket
vcpkgDirectory: ${{ github.workspace }}/ci/vcpkg/
vcpkgTriplet: x64-windows
- name: Build
uses: lukka/run-cmake@main
with:
useVcpkgToolchainFile: true
vcpkgTriplet: x64-windows
buildDirectory: ${{ runner.workspace }}/build
cmakeBuildType: ${{ matrix.buildtype }}
- name: Setup artifact files
shell: cmd
run: |
del /f /s /q "${{ runner.workspace }}\build\CMakeFiles"
rmdir /s /q "${{ runner.workspace }}\build\CMakeFiles"
del /f /s /q "${{ runner.workspace }}\build\.ninja_deps"
del /f /s /q "${{ runner.workspace }}\build\.ninja_log"
del /f /s /q "${{ runner.workspace }}\build\abaddon.ilk"
del /f /s /q "${{ runner.workspace }}\build\CMakeCache.txt"
xcopy /E /I "${{ github.workspace }}\css" "${{ runner.workspace }}\build\css"
xcopy /E /I "${{ github.workspace }}\res" "${{ runner.workspace }}\build\res"
copy "${{ github.workspace }}\ci\vcpkg\installed\x64-windows\tools\glib\gspawn-win64-helper.exe" "${{ runner.workspace }}\build\gspawn-win64-helper.exe"
copy "${{ github.workspace }}\ci\vcpkg\installed\x64-windows\tools\glib\gspawn-win64-helper-console.exe" "${{ runner.workspace }}\build\gspawn-win64-helper-console.exe"
- name: Upload build
uses: actions/upload-artifact@v2
with:
name: build-windows-${{ matrix.buildtype }}
path: ${{ runner.workspace }}/build
mac:
name: macos-${{ matrix.buildtype }}
runs-on: macos-latest
strategy:
matrix:
buildtype: [Debug, RelWithDebInfo]
steps:
- uses: actions/checkout@v1
with:
submodules: true
- name: Fetch CMake
uses: lukka/get-cmake@latest
- name: Fetch dependencies
run: |
brew install gtkmm3
brew install nlohmann-json
brew install cpr
- name: Build
uses: lukka/run-cmake@main
with:
buildDirectory: ${{ runner.workspace }}/build
cmakeBuildType: ${{ matrix.buildtype }}
- name: Setup artifact files
run: |
mkdir "${{ runner.workspace }}/artifactdir"
cp "${{runner.workspace}}/build/abaddon" "${{ runner.workspace }}/artifactdir/abaddon"
cp -r "${{ github.workspace }}/css" "${{ runner.workspace }}/artifactdir/css"
cp -r "${{ github.workspace }}/res" "${{ runner.workspace }}/artifactdir/res"
- name: Upload build
uses: actions/upload-artifact@v2
with:
name: build-macos-${{ matrix.buildtype }}
path: ${{ runner.workspace }}/artifactdir
linux:
name: linux-${{ matrix.buildtype }}
runs-on: ubuntu-latest
strategy:
matrix:
buildtype: [Debug, RelWithDebInfo, MinSizeRel]
steps:
- uses: actions/checkout@v1
with:
submodules: true
- name: Fetch CMake
uses: lukka/get-cmake@latest
- name: Fetch dependencies
run: |
mkdir deps
cd deps
git clone https://github.com/whoshuu/cpr
cd cpr
git checkout 9ff9cef6c794ec3d52d94a62ca791e2f2babca45
mkdir build
cd build
cmake ..
make
sudo make install
cd ../..
git clone https://github.com/nlohmann/json
cd json
git checkout db78ac1d7716f56fc9f1b030b715f872f93964e4
mkdir build
cd build
cmake ..
make
sudo make install
sudo apt-get install libgtkmm-3.0-dev
sudo apt-get install libcurl4-gnutls-dev
- name: Build
uses: lukka/run-cmake@main
env:
CC: gcc-9
CXX: g++-9
with:
cmakeAppendedArgs: -DCMAKE_C_COMPILER=gcc-9 -DCMAKE_CXX_COMPILER=g++-9
buildDirectory: ${{ runner.workspace }}/build
cmakeBuildType: ${{ matrix.buildtype }}
- name: Setup artifact files
run: |
mkdir "${{ runner.workspace }}/artifactdir"
cp "${{runner.workspace}}/build/abaddon" "${{ runner.workspace }}/artifactdir/abaddon"
cp -r "${{ github.workspace }}/css" "${{ runner.workspace }}/artifactdir/css"
cp -r "${{ github.workspace }}/res" "${{ runner.workspace }}/artifactdir/res"
- name: Upload build
uses: actions/upload-artifact@v2
with:
name: build-linux-${{ matrix.buildtype }}
path: ${{ runner.workspace }}/artifactdir

12
.gitmodules vendored
View File

@ -0,0 +1,12 @@
[submodule "vcpkg"]
path = ci/vcpkg
url = https://github.com/microsoft/vcpkg/
[submodule "thirdparty/simpleini"]
path = thirdparty/simpleini
url = https://github.com/brofield/simpleini
[submodule "thirdparty/IXWebSocket"]
path = thirdparty/IXWebSocket
url = https://github.com/machinezone/ixwebsocket
[submodule "ci/vcpkg"]
path = ci/vcpkg
url = https://github.com/microsoft/vcpkg

View File

@ -3,70 +3,34 @@ cmake_minimum_required(VERSION 3.16)
project(abaddon)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
option(DISABLE_MBEDTLS "Disable mbedtls" OFF)
set(USE_TLS TRUE)
set(USE_OPEN_SSL TRUE)
add_compile_definitions(NOMINMAX)
find_package(nlohmann_json REQUIRED)
find_package(CURL)
find_package(cpr REQUIRED)
find_package(ZLIB REQUIRED)
find_package(SQLite3 REQUIRED)
find_package(gtkmm REQUIRED)
find_path(GTKMM_INCLUDE_DIRS gtkmm.h REQUIRED)
find_library(GTKMM_LIBRARY gtkmm)
include_directories(${GTKMM_INCLUDE_DIRS})
find_library(GLIB_LIBRARY glib-2.0)
find_library(GTK_LIBRARY gtk-3.0)
find_path(GLIBMM_INCLUDE_DIRS glibmm.h)
find_library(GLIBMM_LIBRARY glibmm)
include_directories(${GLIBMM_INCLUDE_DIRS})
find_path(SIGC_INCLUDE_DIRS sigc++/sigc++.h)
find_library(SIGC_LIBRARY sigc-2.0)
include_directories(${SIGC_INCLUDE_DIRS})
find_path(GIOMM_INCLUDE_DIRS giomm.h)
find_library(GIOMM_LIBRARY giomm)
include_directories(${GIOMM_INCLUDE_DIRS})
find_path(GDKMM_INCLUDE_DIRS gdkmm.h)
find_library(GDKMM_LIBRARY gdkmm)
include_directories(${GDKMM_INCLUDE_DIRS})
find_path(ATKMM_INCLUDE_DIRS atkmm.h)
find_library(ATKMM_LIBRARY atkmm)
include_directories(${ATKMM_INCLUDE_DIRS})
find_package(curl)
find_library(CURL_LIBRARY libcurl)
find_path(CPR_INCLUDE_DIRS cpr/cpr.h)
find_library(CPR_LIBRARY cpr)
include_directories(${CPR_INCLUDE_DIRS})
find_package(zlib)
find_library(ZLIB_LIBRARY zlib)
include_directories(${ZLIB_INCLUDE_DIRS})
if(NOT DISABLE_MBEDTLS)
find_library(MBEDTLS_X509_LIBRARY mbedx509)
find_library(MBEDTLS_TLS_LIBRARY mbedtls)
find_library(MBEDTLS_CRYPTO_LIBRARY mbedcrypto)
include_directories(${MBEDTLS_INCLUDE_DIRS})
find_path(IXWEBSOCKET_INCLUDE_DIRS ixwebsocket/IXWebSocket.h)
find_library(IXWEBSOCKET_LIBRARY ixwebsocket)
if (NOT IXWEBSOCKET_LIBRARY)
add_subdirectory(thirdparty/IXWebSocket)
include_directories(IXWEBSOCKET_INCLUDE_DIRS)
endif()
find_package(nlohmann_json 3.2.0 REQUIRED)
include_directories(thirdparty/simpleini)
find_package(unofficial-sqlite3 CONFIG REQUIRED)
find_path(IXWEBSOCKET_INCLUDE_DIRS ixwebsocket/ixwebsocket.h)
find_library(IXWEBSOCKET_LIBRARY ixwebsocket)
include_directories(${IXWEBSOCKET_INCLUDE_DIRS}})
if(mingw)
link_libraries(ws2_32 wsock2)
if(MINGW OR WIN32)
link_libraries(ws2_32)
endif()
if(WIN32)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
add_compile_definitions(NOMINMAX)
endif()
file(GLOB ABADDON_SOURCES
@ -84,21 +48,43 @@ file(GLOB ABADDON_SOURCES
)
add_executable(abaddon ${ABADDON_SOURCES})
target_link_libraries(abaddon ${IXWEBSOCKET_LIBRARY})
target_link_libraries(abaddon unofficial::sqlite3::sqlite3)
target_link_libraries(abaddon ${GTKMM_LIBRARY})
target_link_libraries(abaddon ${GLIB_LIBRARY})
target_link_libraries(abaddon ${GLIBMM_LIBRARY})
target_link_libraries(abaddon ${SIGC_LIBRARY})
target_link_libraries(abaddon ${GIOMM_LIBRARY})
target_link_libraries(abaddon ${GDKMM_LIBRARY})
target_link_libraries(abaddon ${ATKMM_LIBRARY})
target_link_libraries(abaddon ${CURL_LIBRARY})
target_include_directories(abaddon PUBLIC ${GTKMM_INCLUDE_DIRS})
target_include_directories(abaddon PUBLIC ${CPR_INCLUDE_DIRS})
target_include_directories(abaddon PUBLIC ${ZLIB_INCLUDE_DIRS})
target_include_directories(abaddon PUBLIC ${SQLite3_INCLUDE_DIRS})
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_CXX_COMPILER_VERSION LESS 9))))
target_link_libraries(abaddon stdc++fs)
endif()
if (IXWEBSOCKET_LIBRARY)
target_link_libraries(abaddon ${IXWEBSOCKET_LIBRARY})
find_library(MBEDTLS_X509_LIBRARY mbedx509)
find_library(MBEDTLS_TLS_LIBRARY mbedtls)
find_library(MBEDTLS_CRYPTO_LIBRARY mbedcrypto)
if (MBEDTLS_TLS_LIBRARY)
target_link_libraries(abaddon ${MBEDTLS_TLS_LIBRARY})
endif()
if (MBEDTLS_X509_LIBRARY)
target_link_libraries(abaddon ${MBEDTLS_X509_LIBRARY})
endif()
if (MBEDTLS_CRYPTO_LIBRARY)
target_link_libraries(abaddon ${MBEDTLS_CRYPTO_LIBRARY})
endif()
else()
target_link_libraries(abaddon $<BUILD_INTERFACE:ixwebsocket>)
endif()
find_package(Threads)
if (Threads_FOUND)
target_link_libraries(abaddon Threads::Threads)
endif()
target_link_libraries(abaddon ${SQLite3_LIBRARIES})
target_link_libraries(abaddon ${GTKMM_LIBRARIES})
target_link_libraries(abaddon ${CURL_LIBRARIES})
target_link_libraries(abaddon ${CPR_LIBRARY})
target_link_libraries(abaddon ${ZLIB_LIBRARY})
target_link_libraries(abaddon ${GTK_LIBRARY})
if(NOT DISABLE_MBEDTLS)
target_link_libraries(abaddon ${MBEDTLS_TLS_LIBRARY})
target_link_libraries(abaddon ${MBEDTLS_X509_LIBRARY})
target_link_libraries(abaddon ${MBEDTLS_CRYPTO_LIBRARY})
endif()
target_link_libraries(abaddon ${NLOHMANN_JSON_LIBRARIES})

View File

@ -13,16 +13,32 @@
### Building:
#### Windows:
1. `git clone https://github.com/uowuo/abaddon && cd abaddon`
2. `vcpkg install gtkmm:x64-windows nlohmann-json:x64-windows ixwebsocket:x64-windows cpr:x64-windows zlib:x64-windows simpleini:x64-windows sqlite3:x64-windows`
2. `vcpkg install gtkmm:x64-windows nlohmann-json:x64-windows ixwebsocket:x64-windows cpr:x64-windows zlib:x64-windows simpleini:x64-windows sqlite3:x64-windows openssl:x64-windows`
3. `mkdir build && cd build`
4. `cmake -G"Visual Studio 16 2019" -A x64 -DCMAKE_TOOLCHAIN_FILE=c:\path\to\vcpkg\scripts\buildsystems\vcpkg.cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVCPKG_TARGET_TRIPLET=x64-windows ..`
5. Build with Visual Studio
5. Build with Visual Studio
Or, do steps 1 and 2, and open CMakeLists.txt in Visual Studio if `vcpkg integrate install` was run
#### Mac/Linux:
You can build for Mac and Linux but specific commands are yet to be listed for the time being ([#9](https://github.com/uowuo/abaddon/issues/9))
#### Mac:
1. `git clone https://github.com/uowuo/abaddon && cd abaddon`
2. `brew install gtkmm3 nlohmann-json cpr`
3. `mkdir build && cd build`
4. `cmake ..`
5. `make`
#### Linux:
1. Install dependencies: `libgtkmm-3.0-dev`, `libcurl4-gnutls-dev`, [cpr](https://github.com/whoshuu/cpr), and [nlohmann-json](https://github.com/nlohmann/json)
2. `git clone https://github.com/uowuo/abaddon && cd abaddon`
3. `mkdir build && cd build`
4. `cmake ..`
5. `make`
### Downloads (from CI):
- Windows: [here](https://ci.appveyor.com/project/ouwou/abaddon/build/artifacts)
- Windows: [here](https://nightly.link/uowuo/abaddon/workflows/ci/ci-test/build-windows-RelWithDebInfo.zip)
- MacOS: [here](https://nightly.link/uowuo/abaddon/workflows/ci/ci-test/build-macos-RelWithDebInfo.zip) unsigned, unpackaged, requires gtkmm3 and [cpr](https://github.com/whoshuu/cpr/) (e.g. from homebrew)
- Linux: [here](https://nightly.link/uowuo/abaddon/workflows/ci/ci-test/build-linux-MinSizeRel.zip) unpackaged (for now), requires gtkmm3 and [cpr](https://github.com/whoshuu/cpr/). built on Ubuntu 18.04 + gcc9
Make sure you start from the directory where `css` and `res` are
#### Dependencies:
* [gtkmm](https://www.gtkmm.org/en/)

View File

@ -441,7 +441,7 @@ void Abaddon::ActionSetStatus() {
const auto status = dlg.GetStatusType();
const auto activity_type = dlg.GetActivityType();
const auto activity_name = dlg.GetActivityName();
Activity activity;
ActivityData activity;
activity.Name = activity_name;
activity.Type = activity_type;
m_discord.UpdateStatus(status, false, activity);

View File

@ -1,50 +0,0 @@
version: '{branch}-{build}'
configuration: RelWithDebInfo
environment:
APPVEYOR_SAVE_CACHE_ON_ERROR: true
AWS_ACCESS_KEY:
secure: tKX1t+B688FTnQihwAuDRAdHScCQtKpbIqHdvE1Ei/k=
AWS_SECRET_KEY:
secure: 3MTsVgpfoO5Jcs4Dl7WPKMPxNC0WC3ffOhIxRWdsU+8N7FEzKO53SbdjjkvgIcrI
AWS_BUCKET: pogger-space
AWS_ENDPOINT: nyc3.digitaloceanspaces.com
AWS_REGION: nyc3
APPVEYOR_RDP_PASSWORD:
secure: bAN2gK+THkzXNApDmTf05lfQDDq8s4itTyl7faCcanw=
matrix:
- job_name: Windows
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
for:
- matrix:
only:
- job_name: Windows
cache:
- c:\tools\vcpkg\installed
install:
- cmd: |
vcpkg install gtkmm:x64-windows nlohmann-json:x64-windows ixwebsocket:x64-windows cpr:x64-windows zlib:x64-windows simpleini:x64-windows sqlite3:x64-windows
cd c:\projects\abaddon
mkdir build && cd build
cmake -G"Visual Studio 16 2019" -A x64 -DCMAKE_TOOLCHAIN_FILE=c:\tools\vcpkg\scripts\buildsystems\vcpkg.cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVCPKG_TARGET_TRIPLET=x64-windows ..
cd ..
build:
project: c:\projects\abaddon
parallel: true
after_build:
- cmd: |
copy "c:\tools\vcpkg\installed\x64-windows\tools\glib\gspawn-win64-helper.exe" "%APPVEYOR_BUILD_FOLDER%\build\%CONFIGURATION%\gspawn-win64-helper.exe"
copy "c:\tools\vcpkg\installed\x64-windows\tools\glib\gspawn-win64-helper-console.exe" "%APPVEYOR_BUILD_FOLDER%\build\%CONFIGURATION%\gspawn-win64-helper-console.exe"
xcopy /E /I %APPVEYOR_BUILD_FOLDER%\css "%APPVEYOR_BUILD_FOLDER%\build\%CONFIGURATION%\css\"
xcopy /E /I %APPVEYOR_BUILD_FOLDER%\res "%APPVEYOR_BUILD_FOLDER%\build\%CONFIGURATION%\res\"
7z a %APPVEYOR_BUILD_FOLDER%\out\abaddon.zip "%APPVEYOR_BUILD_FOLDER%\build\%CONFIGURATION%"
artifacts:
- path: out\abaddon.zip
name: Abaddon

1
ci/vcpkg Submodule

@ -0,0 +1 @@
Subproject commit 50ea8c0ab7aca3bb9245bba7fc877ad2f2a4464c

40
cmake/FindHarfBuzz.cmake Normal file
View File

@ -0,0 +1,40 @@
set(HARFBUZZ_LIBRARY_NAME harfbuzz)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(PC_HARFBUZZ QUIET ${HARFBUZZ_LIBRARY_NAME})
set(HARFBUZZ_DEfINITIONS ${PC_HARFBUZZ_CFLAGS_OTHER})
endif (PKG_CONFIG_FOUND)
set(HARFBUZZ_INCLUDE_HINTS ${PC_HARFBUZZ_INCLUDEDIR} ${PC_HARFBUZZ_INCLUDE_DIRS})
set(HARFBUZZ_LIBRARY_HINTS ${PC_HARFBUZZ_LIBDIR} ${PC_HARFBUZZ_LIBRARY_DIRS})
find_path(HARFBUZZ_INCLUDE_DIR
NAMES hb.h
HINTS ${HARFBUZZ_INCLUDE_HINTS}
/usr/include
/usr/local/include
/opt/local/include
PATH_SUFFIXES ${HARFBUZZ_LIBRARY_NAME})
find_library(HARFBUZZ_LIBRARY
NAMES ${HARFBUZZ_LIBRARY_NAME}
HINTS ${HARFBUZZ_LIBRARY_HINTS}
/usr/lib
/usr/local/lib
/opt/local/lib
PATH_SUFFIXES ${HARFBUZZ_LIBRARY_NAME}
${HARFBUZZ_LIBRARY_NAME}/include)
set(HARFBUZZ_LIBRARIES ${HARFBUZZ_LIBRARY})
set(HARFBUZZ_INCLUDE_DIRS ${HARFBUZZ_INCLUDE_DIR};${HARFBUZZ_CONFIG_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(HarfBuzz
FOUND_VAR HARFBUZZ_FOUND
REQUIRED_VARS
HARFBUZZ_LIBRARY
HARFBUZZ_INCLUDE_DIR
VERSION_VAR HARFBUZZ_VERSION)
mark_as_advanced(HARFBUZZ_INCLUDE_DIR HARFBUZZ_LIBRARY)

40
cmake/Findatk.cmake Normal file
View File

@ -0,0 +1,40 @@
set(ATK_LIBRARY_NAME atk-1.0)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(PC_ATK QUIET atk)
set(ATK_DEfINITIONS ${PC_ATK_CFLAGS_OTHER})
endif (PKG_CONFIG_FOUND)
set(ATK_INCLUDE_HINTS ${PC_ATK_INCLUDEDIR} ${PC_ATK_INCLUDE_DIRS})
set(ATK_LIBRARY_HINTS ${PC_ATK_LIBDIR} ${PC_ATK_LIBRARY_DIRS})
find_path(ATK_INCLUDE_DIR
NAMES atk/atk.h
HINTS ${ATK_INCLUDE_HINTS}
/usr/include
/usr/local/include
/opt/local/include
PATH_SUFFIXES ${ATK_LIBRARY_NAME})
find_library(ATK_LIBRARY
NAMES ${ATK_LIBRARY_NAME}
HINTS ${ATK_LIBRARY_HINTS}
/usr/lib
/usr/local/lib
/opt/local/lib
PATH_SUFFIXES ${ATK_LIBRARY_NAME}
${ATK_LIBRARY_NAME}/include)
set(ATK_LIBRARIES ${ATK_LIBRARY})
set(ATK_INCLUDE_DIRS ${ATK_INCLUDE_DIR};${ATK_CONFIG_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(atk
FOUND_VAR ATK_FOUND
REQUIRED_VARS
ATK_LIBRARY
ATK_INCLUDE_DIR
VERSION_VAR ATK_VERSION)
mark_as_advanced(ATK_INCLUDE_DIR ATK_LIBRARY)

51
cmake/Findatkmm.cmake Normal file
View File

@ -0,0 +1,51 @@
set(ATKMM_LIBRARY_NAME atkmm-1.6)
find_package(atk)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(PKGCONFIG_ATKMM QUIET ${ATKMM_LIBRARY_NAME})
set(ATKMM_DEFINITIONS ${PKGCONFIG_ATKMM_CFLAGS_OTHER})
endif (PKG_CONFIG_FOUND)
set(ATKMM_INCLUDE_HINTS ${PKGCONFIG_ATKMM_INCLUDEDIR} ${PKGCONFIG_ATKMM_INCLUDE_DIRS})
set(ATKMM_LIBRARY_HINTS ${PKGCONFIG_ATKMM_LIBDIR} ${PKGCONFIG_ATKMM_LIBRARY_DIRS})
find_path(ATKMM_INCLUDE_DIR
NAMES atkmm.h
HINTS ${ATKMM_INCLUDE_HINTS}
/usr/include
/usr/local/include
/opt/local/include
PATH_SUFFIXES ${ATKMM_LIBRARY_NAME})
find_path(ATKMM_CONFIG_INCLUDE_DIR
NAMES atkmmconfig.h
HINTS ${ATKMM_LIBRARY_HINTS}
/usr/lib
/usr/local/lib
/opt/local/lib
PATH_SUFFIXES ${ATKMM_LIBRARY_NAME}/include)
find_library(ATKMM_LIBRARY
NAMES ${ATKMM_LIBRARY_NAME}
atkmm
HINTS ${ATKMM_LIBRARY_HINTS}
/usr/lib
/usr/local/lib
/opt/local/lib
PATH_SUFFIXES ${ATKMM_LIBRARY_NAME}
${ATKMM_LIBRARY_NAME}/include)
set(ATKMM_LIBRARIES ${ATKMM_LIBRARY};${ATK_LIBRARIES})
set(ATKMM_INCLUDE_DIRS ${ATKMM_INCLUDE_DIR};${ATKMM_CONFIG_INCLUDE_DIRS};${ATK_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(atkmm
FOUND_VAR ATKMM_FOUND
REQUIRED_VARS
ATKMM_LIBRARY
ATKMM_INCLUDE_DIRS
VERSION_VAR ATKMM_VERSION)
mark_as_advanced(ATKMM_INCLUDE_DIR ATKMM_LIBRARY)

40
cmake/Findcairo.cmake Normal file
View File

@ -0,0 +1,40 @@
set(CAIRO_LIBRARY_NAME cairo)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(PC_CAIRO QUIET ${CAIRO_LIBRARY_NAME})
set(CAIRO_DEfINITIONS ${PC_CAIRO_CFLAGS_OTHER})
endif (PKG_CONFIG_FOUND)
set(CAIRO_INCLUDE_HINTS ${PC_CAIRO_INCLUDEDIR} ${PC_CAIRO_INCLUDE_DIRS})
set(CAIRO_LIBRARY_HINTS ${PC_CAIRO_LIBDIR} ${PC_CAIRO_LIBRARY_DIRS})
find_path(CAIRO_INCLUDE_DIR
NAMES cairo.h
HINTS ${CAIRO_INCLUDE_HINTS}
/usr/include
/usr/local/include
/opt/local/include
PATH_SUFFIXES ${CAIRO_LIBRARY_NAME})
find_library(CAIRO_LIBRARY
NAMES ${CAIRO_LIBRARY_NAME}
HINTS ${CAIRO_LIBRARY_HINTS}
/usr/lib
/usr/local/lib
/opt/local/lib
PATH_SUFFIXES ${CAIRO_LIBRARY_NAME}
${CAIRO_LIBRARY_NAME}/include)
set(CAIRO_LIBRARIES ${CAIRO_LIBRARY})
set(CAIRO_INCLUDE_DIRS ${CAIRO_INCLUDE_DIR};${CAIRO_CONFIG_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(cairo
FOUND_VAR CAIRO_FOUND
REQUIRED_VARS
CAIRO_LIBRARY
CAIRO_INCLUDE_DIR
VERSION_VAR CAIRO_VERSION)
mark_as_advanced(CAIRO_INCLUDE_DIR CAIRO_LIBRARY)

54
cmake/Findcairomm.cmake Normal file
View File

@ -0,0 +1,54 @@
set(CAIROMM_LIBRARY_NAME cairomm-1.0)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(PC_CAIROMM QUIET ${CAIROMM_LIBRARY_NAME})
set(CAIROMM_DEfINITIONS ${PC_CAIROMM_CFLAGS_OTHER})
endif (PKG_CONFIG_FOUND)
set(CAIROMM_INCLUDE_HINTS ${PC_CAIROMM_INCLUDEDIR} ${PC_CAIROMM_INCLUDE_DIRS})
set(CAIROMM_LIBRARY_HINTS ${PC_CAIROMM_LIBDIR} ${PC_CAIROMM_LIBRARY_DIRS})
find_path(CAIROMM_INCLUDE_DIR
NAMES cairomm/cairomm.h
HINTS ${CAIROMM_INCLUDE_HINTS}
/usr/include
/usr/local/include
/opt/local/include
PATH_SUFFIXES ${CAIROMM_LIBRARY_NAME})
find_path(CAIROMM_CONFIG_INCLUDE_DIR
NAMES cairommconfig.h
HINTS ${CAIROMM_INCLUDE_HINTS}
/usr/lib
/usr/local/lib
/opt/local/lib
/usr/include
/usr/local/include
/opt/local/include
PATH_SUFFIXES ${CAIROMM_LIBRARY_NAME}
${CAIROMM_LIBRARY_NAME}/include
cairomm
cairomm/include)
find_library(CAIROMM_LIBRARY
NAMES ${CAIROMM_LIBRARY_NAME}
HINTS ${CAIROMM_LIBRARY_HINTS}
/usr/lib
/usr/local/lib
/opt/local/lib
PATH_SUFFIXES ${CAIROMM_LIBRARY_NAME}
${CAIROMM_LIBRARY_NAME}/include)
set(CAIROMM_LIBRARIES ${CAIROMM_LIBRARY})
set(CAIROMM_INCLUDE_DIRS ${CAIROMM_INCLUDE_DIR};${CAIROMM_CONFIG_INCLUDE_DIRS};${CAIROMM_CONFIG_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(cairomm
FOUND_VAR CAIROMM_FOUND
REQUIRED_VARS
CAIROMM_LIBRARY
CAIROMM_INCLUDE_DIR
VERSION_VAR CAIROMM_VERSION)
mark_as_advanced(CAIROMM_INCLUDE_DIR CAIROMM_LIBRARY)

17
cmake/Findcpr.cmake Normal file
View File

@ -0,0 +1,17 @@
find_path(CPR_INCLUDE_DIR
NAMES cpr/cpr.h)
find_library(CPR_LIBRARY
NAMES cpr
HINTS ${CPR_LIBRARY_ROOT})
set(CPR_LIBRARIES ${CPR_LIBRARY})
set(CPR_INCLUDE_DIRS ${CPR_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(cpr
FOUND_VAR CPR_FOUND
REQUIRED_VARS
CPR_LIBRARY
CPR_INCLUDE_DIR
VERSION_VAR CPR_VERSION)

49
cmake/Findgdkmm.cmake Normal file
View File

@ -0,0 +1,49 @@
set(GDKMM_LIBRARY_NAME gdkmm-3.0)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(PKGCONFIG_GDKMM QUIET ${GDKMM_LIBRARY_NAME})
set(GDKMM_DEFINITIONS ${PKGCONFIG_GDKMM_CFLAGS_OTHER})
endif (PKG_CONFIG_FOUND)
set(GDKMM_INCLUDE_HINTS ${PKGCONFIG_GDKMM_INCLUDEDIR} ${PKGCONFIG_GDKMM_INCLUDE_DIRS})
set(GDKMM_LIBRARY_HINTS ${PKGCONFIG_GDKMM_LIBDIR} ${PKGCONFIG_GDKMM_LIBRARY_DIRS})
find_path(GDKMM_INCLUDE_DIR
NAMES gdkmm.h
HINTS ${GDKMM_INCLUDE_HINTS}
/usr/include
/usr/local/include
/opt/local/include
PATH_SUFFIXES ${GDKMM_LIBRARY_NAME})
find_path(GDKMM_CONFIG_INCLUDE_DIR
NAMES gdkmmconfig.h
HINTS ${GDKMM_LIBRARY_HINTS}
/usr/lib
/usr/local/lib
/opt/local/lib
PATH_SUFFIXES ${GDKMM_LIBRARY_NAME}/include)
find_library(GDKMM_LIBRARY
NAMES ${GDKMM_LIBRARY_NAME}
gdkmm
HINTS ${GDKMM_LIBRARY_HINTS}
/usr/lib
/usr/local/lib
/opt/local/lib
PATH_SUFFIXES ${GDKMM_LIBRARY_NAME}
${GDKMM_LIBRARY_NAME}/include)
set(GDKMM_LIBRARIES ${GDKMM_LIBRARY})
set(GDKMM_INCLUDE_DIRS ${GDKMM_INCLUDE_DIR};${GDKMM_CONFIG_INCLUDE_DIRS};${GDKMM_CONFIG_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(gdkmm
FOUND_VAR GDKMM_FOUND
REQUIRED_VARS
GDKMM_LIBRARY
GDKMM_INCLUDE_DIRS
VERSION_VAR GDKMM_VERSION)
mark_as_advanced(GDKMM_INCLUDE_DIR GDKMM_LIBRARY)

42
cmake/Findgdkpixbuf.cmake Normal file
View File

@ -0,0 +1,42 @@
set(GDKPIXBUF_LIBRARY_NAME gdk_pixbuf-2.0)
set(GDKPIXBUF_PKGCONF_NAME gdk-pixbuf-2.0)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(PC_GDKPIXBUF QUIET ${GDKPIXBUF_PKGCONF_NAME})
set(GDKPIXBUF_DEfINITIONS ${PC_GDKPIXBUF_CFLAGS_OTHER})
endif (PKG_CONFIG_FOUND)
set(GDKPIXBUF_INCLUDE_HINTS ${PC_GDKPIXBUF_INCLUDEDIR} ${PC_GDKPIXBUF_INCLUDE_DIRS})
set(GDKPIXBUF_LIBRARY_HINTS ${PC_GDKPIXBUF_LIBDIR} ${PC_GDKPIXBUF_LIBRARY_DIRS})
find_path(GDKPIXBUF_INCLUDE_DIR
NAMES gdk-pixbuf/gdk-pixbuf.h
HINTS ${GDKPIXBUF_INCLUDE_HINTS}
/usr/include
/usr/local/include
/opt/local/include
PATH_SUFFIXES ${GDKPIXBUF_LIBRARY_NAME}
gtk-3.0)
find_library(GDKPIXBUF_LIBRARY
NAMES ${GDKPIXBUF_LIBRARY_NAME}
HINTS ${GDKPIXBUF_LIBRARY_HINTS}
/usr/lib
/usr/local/lib
/opt/local/lib
PATH_SUFFIXES ${GDKPIXBUF_LIBRARY_NAME}
${GDKPIXBUF_LIBRARY_NAME}/include)
set(GDKPIXBUF_LIBRARIES ${GDKPIXBUF_LIBRARY})
set(GDKPIXBUF_INCLUDE_DIRS ${GDKPIXBUF_INCLUDE_DIR};${GDKPIXBUF_CONFIG_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(gdkpixbuf
FOUND_VAR GDKPIXBUF_FOUND
REQUIRED_VARS
GDKPIXBUF_LIBRARY
GDKPIXBUF_INCLUDE_DIR
VERSION_VAR GDKPIXBUF_VERSION)
mark_as_advanced(GDKPIXBUF_INCLUDE_DIR GDKPIXBUF_LIBRARY)

58
cmake/Findglib.cmake Normal file
View File

@ -0,0 +1,58 @@
find_package(PkgConfig)
pkg_check_modules(PC_GLIB2 QUIET glib-2.0)
find_path(GLIB_INCLUDE_DIR
NAMES glib.h
HINTS ${PC_GLIB2_INCLUDEDIR}
${PC_GLIB2_INCLUDE_DIRS}
$ENV{GLIB2_HOME}/include
$ENV{GLIB2_ROOT}/include
/usr/local/include
/usr/include
/glib2/include
/glib-2.0/include
PATH_SUFFIXES glib2 glib-2.0 glib-2.0/include
)
set(GLIB_INCLUDE_DIRS ${GLIB_INCLUDE_DIR})
find_library(GLIB_LIBRARIES
NAMES glib2
glib-2.0
HINTS ${PC_GLIB2_LIBDIR}
${PC_GLIB2_LIBRARY_DIRS}
$ENV{GLIB2_HOME}/lib
$ENV{GLIB2_ROOT}/lib
/usr/local/lib
/usr/lib
/lib
/glib-2.0/lib
PATH_SUFFIXES glib2 glib-2.0
)
get_filename_component(_GLIB2_LIB_DIR "${GLIB_LIBRARIES}" PATH)
find_path(GLIB_CONFIG_INCLUDE_DIR
NAMES glibconfig.h
HINTS ${PC_GLIB2_INCLUDEDIR}
${PC_GLIB2_INCLUDE_DIRS}
$ENV{GLIB2_HOME}/include
$ENV{GLIB2_ROOT}/include
/usr/local/include
/usr/include
/glib2/include
/glib-2.0/include
${_GLIB2_LIB_DIR}
${CMAKE_SYSTEM_LIBRARY_PATH}
PATH_SUFFIXES glib2 glib-2.0 glib-2.0/include
)
if (GLIB_CONFIG_INCLUDE_DIR)
set(GLIB_INCLUDE_DIRS ${GLIB_INCLUDE_DIRS} ${GLIB_CONFIG_INCLUDE_DIR})
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(glib
FOUND_VAR GLIB_FOUND
REQUIRED_VARS
GLIB_LIBRARIES
GLIB_INCLUDE_DIRS
VERSION_VAR GLIB_VERSION)
mark_as_advanced(GLIB_INCLUDE_DIR GLIB_CONFIG_INCLUDE_DIR)

69
cmake/Findglibmm.cmake Normal file
View File

@ -0,0 +1,69 @@
set(GLIBMM_LIBRARY_NAME glibmm-2.4)
set( GIOMM_LIBRARY_NAME giomm-2.4)
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_GLIBMM QUIET ${GLIBMM_LIBRARY_NAME})
pkg_check_modules(PC_GIOMM QUIET ${GIOMM_LIBRARY_NAME})
set(GLIBMM_DEFINITIONS ${PC_GLIBMM_CFLAGS_OTHER})
endif()
set(GLIBMM_VERSION ${PC_GLIBMM_VERSION})
set(GLIBMM_INCLUDE_HINTS ${PC_GLIBMM_INCLUDEDIR} ${PC_GLIBMM_INCLUDE_DIRS})
set(GLIBMM_LIBRARY_HINTS ${PC_GLIBMM_LIBDIR} ${PC_GLIBMM_LIBRARY_DIRS})
set( GIOMM_INCLUDE_HINTS ${PC_GIOMM_INCLUDEDIR} ${PC_GIOMM_INCLUDE_DIRS})
set( GIOMM_LIBRARY_HINTS ${PC_GIOMM_LIBDIR} ${PC_GIOMM_LIBRARY_DIRS})
find_path(GLIBMM_INCLUDE_DIR
NAMES glibmm.h
HINTS ${GLIBMM_INCLUDE_HINTS}
PATH_SUFFIXES ${GLIBMM_LIBRARY_NAME})
find_path(GLIBMM_CONFIG_INCLUDE_DIR
NAMES glibmmconfig.h
HINTS ${GLIBMM_LIBRARY_HINTS}
PATH_SUFFIXES ${GLIBMM_LIBRARY_NAME}/include)
find_library(GLIBMM_LIBRARY
NAMES ${GLIBMM_LIBRARY_NAME}
glibmm
glibmm-2.0
glibmm-2.4
HINTS ${GLIBMM_LIBRARY_HINTS}
/usr/lib
/usr/local/lib
/opt/local/lib
PATH_SUFFIXES ${GLIBMM_LIBRARY_NAME}
${GLIBMM_LIBRARY_NAME}/include)
find_path(GIOMM_INCLUDE_DIR
NAMES giomm.h
PATH_SUFFIXES ${GIOMM_LIBRARY_NAME})
find_path(GIOMM_CONFIG_INCLUDE_DIR
NAMES giommconfig.h
HINTS ${GIOMM_LIBRARY_HINTS}
PATH_SUFFIXES ${GIOMM_LIBRARY_NAME}
${GIOMM_LIBRARY_NAME}/include)
find_library(GIOMM_LIBRARY
NAMES ${GIOMM_LIBRARY_NAME}
giomm
HINTS ${GIOMM_INCLUDE_HINTS}
/usr/lib
/usr/local/lib
/opt/local/lib
PATH_SUFFIXES ${GIOMM_LIBRARY_NAME}/include)
set(GLIBMM_LIBRARIES ${GLIBMM_LIBRARY};${GIOMM_LIBRARY};${GLIB_LIBRARIES};${SIGC++_LIBRARIES})
set(GLIBMM_INCLUDE_DIRS ${GLIBMM_INCLUDE_DIR};${GLIBMM_CONFIG_INCLUDE_DIR};${GIOMM_INCLUDE_DIR};${GLIB_INCLUDE_DIRS};${SIGC++_INCLUDE_DIRS};${GIOMM_CONFIG_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(glibmm
FOUND_VAR GLIBMM_FOUND
REQUIRED_VARS
GLIBMM_LIBRARY
GLIBMM_INCLUDE_DIR
VERSION_VAR GLIBMM_VERSION)
mark_as_advanced(GLIBMM_INCLUDE_DIR GLIBMM_LIBRARY)

56
cmake/Findgtk.cmake Normal file
View File

@ -0,0 +1,56 @@
set(GTK_LIBRARY_NAME gtk-3.0)
set(GTK_PKGCONFIG_NAME gtk+-3.0)
find_package(glib REQUIRED)
find_package(gdkpixbuf)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(PC_GTK QUIET ${GTK_PKGCONFIG_NAME})
set(GTK_DEFINITIONS ${PC_GTK_CFLAGS_OTHER})
endif()
set(GTK_INCLUDE_HINTS ${PC_GTK_INCLUDEDIR} ${PC_GTK_INCLUDE_DIRS})
set(GTK_LIBRARY_HINTS ${PC_GTK_LIBDIR} ${PC_GTK_LIBRARY_DIRS})
find_path(GTK_INCLUDE_DIR
NAMES gtk/gtk.h
HINTS ${GTK_INCLUDE_HINTS}
/usr/include
/usr/local/include
/opt/local/include
PATH_SUFFIXES ${GTK_LIBRARY_NAME})
#find_path(GDK_CONFIG_INCLUDE_DIR
# NAMES gdkconfig.h
# HINTS ${GTK_LIBRARY_HINTS}
# /usr/lib
# /usr/local/lib
# /opt/local/lib
# /usr/include
# /usr/local/include
# /opt/local/include
# PATH_SUFFIXES ${GTK_LIBRARY_NAME}/include
# ${GTK_LIBRARY_NaME}/gdk)
find_library(GTK_LIBRARY
NAMES gtk-3.0
gtk-3
gtk
HINTS ${GTK_LIBRARY_HINTS}
/usr/lib
/usr/local/lib
/opt/local/lib)
set(GTK_LIBRARIES ${GTK_LIBRARY};${GDKPIXBUF_LIBRARIES})
set(GTK_INCLUDE_DIRS ${GTK_INCLUDE_DIR};${GDK_CONFIG_INCLUDE_DIR};${GDKPIXBUF_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(gtk
FOUND_VAR GTK_FOUND
REQUIRED_VARS
GTK_LIBRARY
GTK_INCLUDE_DIR
VERSION_VAR GTK_VERSION)
mark_as_advanced(GTK_INCLUDE_DIR GTK_LIBRARY)

60
cmake/Findgtkmm.cmake Normal file
View File

@ -0,0 +1,60 @@
set(GTKMM_LIBRARY_NAME gtkmm-3.0)
set(GDKMM_LIBRARY_NAME gdkmm-3.0)
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_GTKMM QUIET ${GTKMM_LIBRARY_NAME})
pkg_check_modules(PC_GDKMM QUIET ${GDKMM_LIBRARY_NAME})
pkg_check_modules(PC_PANGOMM QUIET ${PANGOMM_LIBRARY_NAME})
set(GTKMM_DEFINITIONS ${PC_GTKMM_CFLAGS_OTHER})
endif()
find_package(gtk)
find_package(glibmm)
find_package(atkmm)
find_package(gdkmm)
find_package(sigc++)
find_package(pangomm)
find_package(cairomm)
set(GTKMM_VERSION ${PC_GTKMM_VERSION})
set(GTKMM_INCLUDE_HINTS ${PC_GTKMM_INCLUDEDIR} ${PC_GTKMM_INCLUDE_DIRS})
set(GTKMM_LIBRARY_HINTS ${PC_GTKMM_LIBDIR} ${PC_GTKMM_LIBRARY_DIRS})
set(PANGOMM_INCLUDE_HINTS ${PC_PANGOMM_INCLUDEDIR} ${PC_PANGOMM_INCLUDE_DIRS})
set(GDKMM_INCLUDE_HINTS ${PC_GTKMM_LIBDIR} ${PC_GTKMM_LIBRARY_DIRS}
${PC_GDKMM_INCLUDEDIR} ${PC_GDKMM_INCLUDE_DIRS})
find_path(GTKMM_INCLUDE_DIR
NAMES gtkmm.h
HINTS ${GTKMM_INCLUDE_HINTS}
PATH_SUFFIXES ${GTKMM_LIBRARY_NAME})
find_path(GTKMM_CONFIG_INCLUDE_DIR
NAMES gtkmmconfig.h
HINTS ${GTKMM_LIBRARY_HINTS}
PATH_SUFFIXES ${GTKMM_LIBRARY_NAME}/include)
find_library(GTKMM_LIB
NAMES ${GTKMM_LIBRARY_NAME}
gtkmm
HINTS ${GTKMM_LIBRARY_HINTS}
PATH_SUFFIXES ${GTKMM_LIBRARY_NAME}
${GTKMM_LIBRARY_NAME}/include)
find_path(GDKMM_CONFIG_INCLUDE_DIR
NAMES gdkmmconfig.h
HINTS ${GDKMM_INCLUDE_HINTS}
PATH_SUFFIXES ${GDKMM_LIBRARY_NAME}/include)
set(GTKMM_LIBRARIES ${GTKMM_LIB};${GDKMM_LIBRARY};${GTK_LIBRARIES};${GLIBMM_LIBRARIES};${PANGOMM_LIBRARIES};${CAIROMM_LIBRARIES};${ATKMM_LIBRARIES};${SIGC++_LIBRARIES})
set(GTKMM_INCLUDE_DIRS ${GTKMM_INCLUDE_DIR};${GTKMM_CONFIG_INCLUDE_DIR};${GDKMM_INCLUDE_DIR};${GDKMM_CONFIG_INCLUDE_DIR};${GTK_INCLUDE_DIRS};${GLIBMM_INCLUDE_DIRS};${PANGOMM_INCLUDE_DIRS};${CAIROMM_INCLUDE_DIRS};${ATKMM_INCLUDE_DIRS};${SIGC++_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(gtkmm
FOUND_VAR GTKMM_FOUND
REQUIRED_VARS
GTKMM_LIB
GTKMM_INCLUDE_DIRS
VERSION_VAR GTKMM_VERSION)
mark_as_advanced(GTKMM_INCLUDE_DIR GTKMM_LIBRARY)

View File

@ -0,0 +1,17 @@
find_path(IXWEBSOCKET_INCLUDE_DIR
NAMES ixwebsocket/IXWebSocket.h)
find_library(IXWEBSOCKET_LIBRARY
NAMES ixwebsocket
HINTS ${IXWEBSOCKET_LIBRARY_ROOT})
set(IXWEBSOCKET_LIBRARIES ${IXWEBSOCKET_LIBRARY})
set(IXWEBSOCKET_INCLUDE_DIRS ${IXWEBSOCKET_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ixwebsocket
FOUND_VAR IXWEBSOCKET_FOUND
REQUIRED_VARS
IXWEBSOCKET_LIBRARY
IXWEBSOCKET_INCLUDE_DIR
VERSION_VAR IXWEBSOCKET_VERSION)

View File

@ -0,0 +1,28 @@
set(NLOHMANN_JSON_LIBRARY_NAME nlohmann_json)
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_NLOHMANN_JSON QUIET ${NLOHMANN_JSON_LIBRARY_NAME})
set(NLOHMANN_JSON_DEFINITIONS ${PC_NLOHMANN_JSON_CFLAGS_OTHER})
endif()
set(NLOHMANN_JSON_INCLUDE_HINTS ${PC_NLOHMANN_JSON_INCLUDEDIR} ${PC_NLOHMANN_JSON_INCLUDE_DIRS})
set(NLOHMANN_JSON_ROOT_DIR "$ENV{NLOHMANN_JSON_ROOT_DIR}")
find_path(NLOHMANN_JSON_INCLUDE_DIR
NAMES nlohmann/json.hpp
PATHS $ENV{PROGRAMFILES}/include/
${NLOHMANN_JSON_ROOT_DIR}/
${NLOHMANN_JSON_ROOT_DIR}/include/
HINTS ${NLOHMANN_JSON_INCLUDE_HINTS})
set(NLOHMANN_JSON_INCLUDE_DIRS ${NLOHMANN_JSON_INCLUDE_DIR})
set(NLOHMANN_JSON_LIBRARIES "")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(nlohmann_json
FOUND_VAR NLOHMANN_JSON_FOUND
REQUIRED_VARS
NLOHMANN_JSON_INCLUDE_DIR
VERSION_VAR NLOHMANN_JSON_VERSION)

56
cmake/Findpango.cmake Normal file
View File

@ -0,0 +1,56 @@
set(PANGO_LIBRARY_NAME pango-1.0)
find_package(HarfBuzz)
find_package(cairo)
find_package(Freetype)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(PC_PANGO QUIET ${PANGO_LIBRARY_NAME})
set(PANGO_DEFINITIONS ${PC_PANGO_CFLAGS_OTHER})
endif (PKG_CONFIG_FOUND)
set(PANGO_INCLUDE_HINTS ${PC_PANGO_INCLUDEDIR} ${PC_PANGO_INCLUDE_DIRS})
set(PANGO_LIBRARY_HINTS ${PC_PANGO_LIBDIR} ${PC_PANGO_LIBRARY_DIRS})
find_path(PANGO_INCLUDE_DIR
NAMES pango/pango.h
HINTS ${PANGO_INCLUDE_HINTS}
/usr/include
/usr/local/include
/opt/local/include
PATH_SUFFIXES ${PANGO_LIBRARY_NAME}
${PANGO_LIBRARY_NAME}/include
pango)
find_path(PANGO_CONFIG_INCLUDE_DIR
NAMES pangoconfig.h
pango/pangoconfig.h
HINTS ${PANGO_LIBRARY_HINTS}
/usr/lib
/usr/local/lib
/opt/local/lib
PATH_SUFFIXES ${PANGO_LIBRARY_NAME}/include)
find_library(PANGO_LIBRARY
NAMES ${PANGO_LIBRARY_NAME}
pango
HINTS ${PANGO_LIBRARY_HINTS}
/usr/lib
/usr/local/lib
/opt/local/lib
PATH_SUFFIXES ${PANGO_LIBRARY_NAME}
${PANGO_LIBRARY_NAME}/include)
set(PANGO_LIBRARIES ${PANGO_LIBRARY};${HARFBUZZ_LIBRARIES};${CAIRO_LIBRARIES};${FREETYPE_LIBRARIES})
set(PANGO_INCLUDE_DIRS ${PANGO_INCLUDE_DIR};${PANGO_CONFIG_INCLUDE_DIRS};${HARFBUZZ_INCLUDE_DIR};${CAIRO_INCLUDE_DIRS};${FREETYPE_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(pango
FOUND_VAR PANGO_FOUND
REQUIRED_VARS
PANGO_LIBRARY
PANGO_INCLUDE_DIR
VERSION_VAR PANGO_VERSION)
mark_as_advanced(PANGO_INCLUDE_DIR PANGO_LIBRARY)

65
cmake/Findpangomm.cmake Normal file
View File

@ -0,0 +1,65 @@
set(PANGOMM_LIBRARY_NAME pangomm-1.4)
find_package(pango REQUIRED)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(PC_PANGOMM QUIET ${PANGOMM_LIBRARY_NAME})
set(PANGOMM_DEFINITIONS ${PC_PANGOMM_CFLAGS_OTHER})
endif()
set(PANGOMM_INCLUDE_HINTS ${PC_PANGOMM_INCLUDEDIR} ${PC_PANGOMM_INCLUDE_DIRS})
set(PANGOMM_LIBRARY_HINTS ${PC_PANGOMM_LIBDIR} ${PC_PANGOMM_LIBRARY_DIRS})
find_path(PANGOMM_INCLUDE_DIR
NAMES pangomm.h
HINTS ${PANGOMM_INCLUDE_HINTS}
/usr/lib
/usr/local/lib
/opt/local/lib
/usr/include
/usr/local/include
/opt/local/include
PATH_SUFFIXES ${PANGOMM_LIBRARY_NAME}
${PANGOMM_LIBRARY_NAME}/include
pangomm
pangomm/include)
find_path(PANGOMM_CONFIG_INCLUDE_DIR
NAMES pangommconfig.h
HINTS ${PANGOMM_LIBRARY_HINTS}
/usr/lib
/usr/local/lib
/opt/local/lib
/usr/include
/usr/local/include
/opt/local/include
PATH_SUFFIXES ${PANGOMM_LIBRARY_NAME}
${PANGOMM_LIBRARY_NAME}/include
pangomm
pangomm/include)
find_library(PANGOMM_LIBRARY
NAMES ${PANGOMM_LIBRARY_NAME}
pangomm
HINTS ${PANGOMM_LIBRARY_HINTS}
/usr/lib
/usr/local/lib
/opt/local/lib
PATH_SUFFIXES ${PANGO_LIBRARY_NAME}
${PANGO_LIBRARY_NAME}/include
pangomm
pangomm/include)
set(PANGOMM_LIBRARIES ${PANGOMM_LIBRARY};${PANGO_LIBRARIES})
set(PANGOMM_INCLUDE_DIRS ${PANGOMM_INCLUDE_DIR};${PANGOMM_CONFIG_INCLUDE_DIR};${PANGO_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(pangomm
FOUND_VAR PANGOMM_FOUND
REQUIRED_VARS
PANGOMM_LIBRARY
PANGOMM_INCLUDE_DIRS
VERSION_VAR PANGOMM_VERSION)
mark_as_advanced(PANGOMM_INCLUDE_DIR PANGOMM_LIBRARY)

41
cmake/Findsigc++.cmake Normal file
View File

@ -0,0 +1,41 @@
set(SIGC++_LIBRARY_NAME sigc++-2.0)
set(SIGC++_LIBRARY_FILE sigc-2.0)
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_SIGC++ QUIET ${SIGC++_LIBRARY_NAME})
set(SIGC++_DEFINITIONS ${PC_SIGC++_CFLAGS_OTHER})
endif()
set(SIGC++_VERSION ${PC_SIGC++_VERSION})
set(SIGC++_INCLUDE_HINTS ${PC_SIGC++_INCLUDEDIR} ${PC_SIGC++_INCLUDE_DIRS})
set(SIGC++_LIBRARY_HINTS ${PC_SIGC++_LIBDIR} ${PC_SIGC++_LIBRARY_DIRS})
find_path(SIGC++_INCLUDE_DIR
NAMES sigc++/sigc++.h
HINTS ${SIGC++_INCLUDE_HINTS}
PATH_SUFFIXES ${SIGC++_LIBRARY_NAME})
find_path(SIGC++_CONFIG_INCLUDE_DIR
NAMES sigc++config.h
HINTS ${SIGC++_LIBRARY_HINTS}
PATH_SUFFIXES ${SIGC++_LIBRARY_NAME}/include)
find_library(SIGC++_LIBRARY
NAMES ${SIGC++_LIBRARY_FILE}
HINTS $${SIGC++_LIBRARY_HINTS}
PATH_SUFFIXES ${SIGC++_LIBRARY_NAME}
${SIGC++_LIBRARY_NAME}/include)
set(SIGC++_LIBRARIES ${SIGC++_LIBRARY})
set(SIGC++_INCLUDE_DIRS ${SIGC++_INCLUDE_DIR};${SIGC++_CONFIG_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(sigc++
FOUND_VAR SIGC++_FOUND
REQUIRED_VARS
SIGC++_INCLUDE_DIR
SIGC++_LIBRARY
VERSION_VAR SIGC++_VERSION)
mark_as_advanced(SIGC++_INCLUDE_DIR SIGC++_LIBRARY)

View File

@ -46,7 +46,7 @@ ChannelListRowDMHeader::ChannelListRowDMHeader() {
show_all_children();
}
ChannelListRowDMChannel::ChannelListRowDMChannel(const Channel *data) {
ChannelListRowDMChannel::ChannelListRowDMChannel(const ChannelData *data) {
ID = data->ID;
m_ev = Gtk::manage(new Gtk::EventBox);
m_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
@ -56,7 +56,7 @@ ChannelListRowDMChannel::ChannelListRowDMChannel(const Channel *data) {
get_style_context()->add_class("channel-row");
m_lbl->get_style_context()->add_class("channel-row-label");
User top_recipient;
UserData top_recipient;
const auto recipients = data->GetDMRecipients();
top_recipient = recipients[0];
@ -95,7 +95,7 @@ void ChannelListRowDMChannel::OnImageLoad(Glib::RefPtr<Gdk::Pixbuf> buf) {
m_icon->property_pixbuf() = buf->scale_simple(24, 24, Gdk::INTERP_BILINEAR);
}
ChannelListRowGuild::ChannelListRowGuild(const Guild *data) {
ChannelListRowGuild::ChannelListRowGuild(const GuildData *data) {
ID = data->ID;
m_ev = Gtk::manage(new Gtk::EventBox);
m_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
@ -176,7 +176,7 @@ ChannelListRowGuild::type_signal_leave ChannelListRowGuild::signal_leave() {
return m_signal_leave;
}
ChannelListRowCategory::ChannelListRowCategory(const Channel *data) {
ChannelListRowCategory::ChannelListRowCategory(const ChannelData *data) {
ID = data->ID;
m_ev = Gtk::manage(new Gtk::EventBox);
m_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
@ -222,7 +222,7 @@ ChannelListRowCategory::type_signal_copy_id ChannelListRowCategory::signal_copy_
return m_signal_copy_id;
}
ChannelListRowChannel::ChannelListRowChannel(const Channel *data) {
ChannelListRowChannel::ChannelListRowChannel(const ChannelData *data) {
ID = data->ID;
m_ev = Gtk::manage(new Gtk::EventBox);
m_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
@ -591,8 +591,8 @@ void ChannelList::InsertGuildAt(Snowflake id, int pos) {
const auto guild_data = discord.GetGuild(id);
if (!guild_data.has_value()) return;
std::map<int, Channel> orphan_channels;
std::unordered_map<Snowflake, std::vector<Channel>> cat_to_channels;
std::map<int, ChannelData> orphan_channels;
std::unordered_map<Snowflake, std::vector<ChannelData>> cat_to_channels;
if (guild_data->Channels.has_value())
for (const auto &dc : *guild_data->Channels) {
const auto channel = discord.GetChannel(dc.ID);
@ -626,7 +626,7 @@ void ChannelList::InsertGuildAt(Snowflake id, int pos) {
}
// categories
std::map<int, std::vector<Channel>> sorted_categories;
std::map<int, std::vector<ChannelData>> sorted_categories;
if (guild_data->Channels.has_value())
for (const auto &dc : *guild_data->Channels) {
const auto channel = discord.GetChannel(dc.ID);
@ -636,7 +636,7 @@ void ChannelList::InsertGuildAt(Snowflake id, int pos) {
}
for (auto &[pos, catvec] : sorted_categories) {
std::sort(catvec.begin(), catvec.end(), [](const Channel &a, const Channel &b) { return a.ID < b.ID; });
std::sort(catvec.begin(), catvec.end(), [](const ChannelData &a, const ChannelData &b) { return a.ID < b.ID; });
for (const auto cat : catvec) {
auto *cat_row = Gtk::manage(new ChannelListRowCategory(&cat));
cat_row->IsUserCollapsed = false;
@ -648,7 +648,7 @@ void ChannelList::InsertGuildAt(Snowflake id, int pos) {
// child channels
if (cat_to_channels.find(cat.ID) == cat_to_channels.end()) continue;
std::map<int, Channel> sorted_channels;
std::map<int, ChannelData> sorted_channels;
for (const auto channel : cat_to_channels.at(cat.ID))
sorted_channels[*channel.Position] = channel;
@ -669,12 +669,12 @@ void ChannelList::InsertGuildAt(Snowflake id, int pos) {
void ChannelList::AddPrivateChannels() {
const auto &discord = Abaddon::Get().GetDiscordClient();
auto dms_ = discord.GetPrivateChannels();
std::vector<Channel> dms;
std::vector<ChannelData> dms;
for (const auto &x : dms_) {
const auto chan = discord.GetChannel(x);
dms.push_back(*chan);
}
std::sort(dms.begin(), dms.end(), [&](const Channel &a, const Channel &b) -> bool {
std::sort(dms.begin(), dms.end(), [&](const ChannelData &a, const ChannelData &b) -> bool {
return a.LastMessageID > b.LastMessageID;
});

View File

@ -35,7 +35,7 @@ protected:
class ChannelListRowDMChannel : public ChannelListRow {
public:
ChannelListRowDMChannel(const Channel *data);
ChannelListRowDMChannel(const ChannelData *data);
protected:
void OnImageLoad(Glib::RefPtr<Gdk::Pixbuf> buf);
@ -48,7 +48,7 @@ protected:
class ChannelListRowGuild : public ChannelListRow {
public:
ChannelListRowGuild(const Guild *data);
ChannelListRowGuild(const GuildData *data);
int GuildIndex;
@ -79,7 +79,7 @@ public:
class ChannelListRowCategory : public ChannelListRow {
public:
ChannelListRowCategory(const Channel *data);
ChannelListRowCategory(const ChannelData *data);
virtual void Collapse();
virtual void Expand();
@ -104,7 +104,7 @@ public:
class ChannelListRowChannel : public ChannelListRow {
public:
ChannelListRowChannel(const Channel *data);
ChannelListRowChannel(const ChannelData *data);
protected:
Gtk::EventBox *m_ev;

View File

@ -436,7 +436,7 @@ Gtk::Widget *ChatMessageItemContainer::CreateAttachmentComponent(const Attachmen
return ev;
}
Gtk::Widget *ChatMessageItemContainer::CreateStickerComponent(const Sticker &data) {
Gtk::Widget *ChatMessageItemContainer::CreateStickerComponent(const StickerData &data) {
auto *box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
auto *imgw = Gtk::manage(new Gtk::Image);
box->add(*imgw);
@ -715,7 +715,7 @@ void ChatMessageItemContainer::HandleCustomEmojis(Gtk::TextView &tv) {
startpos = mend;
if (is_animated && show_animations) {
auto pixbuf = img.GetAnimationFromURLIfCached(Emoji::URLFromID(match.fetch(2), "gif"), EmojiSize, EmojiSize);
auto pixbuf = img.GetAnimationFromURLIfCached(EmojiData::URLFromID(match.fetch(2), "gif"), EmojiSize, EmojiSize);
if (pixbuf) {
const auto it = buf->erase(start_it, end_it);
const int alen = text.size();
@ -742,10 +742,10 @@ void ChatMessageItemContainer::HandleCustomEmojis(Gtk::TextView &tv) {
img->show();
tv.add_child_at_anchor(*img, anchor);
};
img.LoadAnimationFromURL(Emoji::URLFromID(match.fetch(2), "gif"), EmojiSize, EmojiSize, sigc::track_obj(cb, tv));
img.LoadAnimationFromURL(EmojiData::URLFromID(match.fetch(2), "gif"), EmojiSize, EmojiSize, sigc::track_obj(cb, tv));
}
} else {
auto pixbuf = img.GetFromURLIfCached(Emoji::URLFromID(match.fetch(2)));
auto pixbuf = img.GetFromURLIfCached(EmojiData::URLFromID(match.fetch(2)));
if (pixbuf) {
const auto it = buf->erase(start_it, end_it);
const int alen = text.size();
@ -767,7 +767,7 @@ void ChatMessageItemContainer::HandleCustomEmojis(Gtk::TextView &tv) {
auto it = buf->erase(start_it, end_it);
buf->insert_pixbuf(it, pixbuf->scale_simple(EmojiSize, EmojiSize, Gdk::INTERP_BILINEAR));
};
img.LoadFromURL(Emoji::URLFromID(match.fetch(2)), sigc::track_obj(cb, tv));
img.LoadFromURL(EmojiData::URLFromID(match.fetch(2)), sigc::track_obj(cb, tv));
}
}

View File

@ -25,7 +25,7 @@ protected:
Gtk::Widget *CreateEmbedComponent(const EmbedData &data); // Message.Embeds[0]
Gtk::Widget *CreateImageComponent(const std::string &proxy_url, const std::string &url, int inw, int inh);
Gtk::Widget *CreateAttachmentComponent(const AttachmentData &data); // non-image attachments
Gtk::Widget *CreateStickerComponent(const Sticker &data);
Gtk::Widget *CreateStickerComponent(const StickerData &data);
Gtk::Widget *CreateReactionsComponent(const Message &data);
Gtk::Widget *CreateReplyComponent(const Message &data);
void ReactionUpdateImage(Gtk::Image *img, const Glib::RefPtr<Gdk::Pixbuf> &pb);

View File

@ -2,7 +2,7 @@
#include "../abaddon.hpp"
#include "../util.hpp"
MemberListUserRow::MemberListUserRow(Snowflake guild_id, const User *data) {
MemberListUserRow::MemberListUserRow(Snowflake guild_id, const UserData *data) {
ID = data->ID;
m_ev = Gtk::manage(new Gtk::EventBox);
m_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
@ -111,8 +111,8 @@ void MemberList::UpdateMemberListInternal() {
}
// process all the shit first so its in proper order
std::map<int, Role> pos_to_role;
std::map<int, std::vector<User>> pos_to_users;
std::map<int, RoleData> pos_to_role;
std::map<int, std::vector<UserData>> pos_to_users;
std::unordered_map<Snowflake, int> user_to_color;
std::vector<Snowflake> roleless_users;
@ -139,7 +139,7 @@ void MemberList::UpdateMemberListInternal() {
user_to_color[id] = col_role->Color;
}
auto add_user = [this, &user_to_color](const User *data) {
auto add_user = [this, &user_to_color](const UserData *data) {
auto *row = Gtk::manage(new MemberListUserRow(m_guild_id, data));
m_id_to_row[data->ID] = row;

View File

@ -6,7 +6,7 @@
class MemberListUserRow : public Gtk::ListBoxRow {
public:
MemberListUserRow(Snowflake guild_id, const User *data);
MemberListUserRow(Snowflake guild_id, const UserData *data);
void SetAvatarFromPixbuf(Glib::RefPtr<Gdk::Pixbuf> pixbuf);
Snowflake ID;

View File

@ -60,7 +60,7 @@ void to_json(nlohmann::json &j, const ActivitySecrets &m) {
JS_IF("match", m.Match);
}
void from_json(const nlohmann::json &j, Activity &m) {
void from_json(const nlohmann::json &j, ActivityData &m) {
JS_D("name", m.Name);
JS_D("type", m.Type);
JS_ON("url", m.URL);
@ -77,7 +77,7 @@ void from_json(const nlohmann::json &j, Activity &m) {
JS_O("flags", m.Flags);
}
void to_json(nlohmann::json &j, const Activity &m) {
void to_json(nlohmann::json &j, const ActivityData &m) {
if (m.Type == ActivityType::Custom) {
j["name"] = "Custom Status";
j["state"] = m.Name;
@ -100,7 +100,7 @@ void to_json(nlohmann::json &j, const Activity &m) {
JS_IF("flags", m.Flags);
}
void to_json(nlohmann::json &j, const Presence &m) {
void to_json(nlohmann::json &j, const PresenceData &m) {
j["activities"] = m.Activities;
j["status"] = m.Status;
j["afk"] = m.IsAFK;

View File

@ -71,7 +71,7 @@ struct ActivitySecrets {
friend void to_json(nlohmann::json &j, const ActivitySecrets &m);
};
struct Activity {
struct ActivityData {
std::string Name; //
ActivityType Type; //
std::optional<std::string> URL; // null
@ -87,15 +87,15 @@ struct Activity {
std::optional<bool> IsInstance; //
std::optional<ActivityFlags> Flags; //
friend void from_json(const nlohmann::json &j, Activity &m);
friend void to_json(nlohmann::json &j, const Activity &m);
friend void from_json(const nlohmann::json &j, ActivityData &m);
friend void to_json(nlohmann::json &j, const ActivityData &m);
};
struct Presence {
std::vector<Activity> Activities; // null (but never sent as such)
struct PresenceData {
std::vector<ActivityData> Activities; // null (but never sent as such)
std::string Status;
bool IsAFK;
int Since = 0;
friend void to_json(nlohmann::json &j, const Presence &m);
friend void to_json(nlohmann::json &j, const PresenceData &m);
};

View File

@ -1,7 +1,7 @@
#include "../abaddon.hpp"
#include "channel.hpp"
void from_json(const nlohmann::json &j, Channel &m) {
void from_json(const nlohmann::json &j, ChannelData &m) {
JS_D("id", m.ID);
JS_D("type", m.Type);
JS_O("guild_id", m.GuildID);
@ -23,7 +23,7 @@ void from_json(const nlohmann::json &j, Channel &m) {
JS_ON("last_pin_timestamp", m.LastPinTimestamp);
}
void Channel::update_from_json(const nlohmann::json &j) {
void ChannelData::update_from_json(const nlohmann::json &j) {
JS_RD("type", Type);
JS_RD("guild_id", GuildID);
JS_RV("position", Position, -1);
@ -43,17 +43,17 @@ void Channel::update_from_json(const nlohmann::json &j) {
JS_RD("last_pin_timestamp", LastPinTimestamp);
}
std::optional<PermissionOverwrite> Channel::GetOverwrite(Snowflake id) const {
std::optional<PermissionOverwrite> ChannelData::GetOverwrite(Snowflake id) const {
return Abaddon::Get().GetDiscordClient().GetPermissionOverwrite(ID, id);
}
std::vector<User> Channel::GetDMRecipients() const {
std::vector<UserData> ChannelData::GetDMRecipients() const {
const auto &discord = Abaddon::Get().GetDiscordClient();
if (Recipients.has_value())
return *Recipients;
if (RecipientIDs.has_value()) {
std::vector<User> ret;
std::vector<UserData> ret;
for (const auto &id : *RecipientIDs) {
auto user = discord.GetUser(id);
if (user.has_value())
@ -63,5 +63,5 @@ std::vector<User> Channel::GetDMRecipients() const {
return ret;
}
return std::vector<User>();
return std::vector<UserData>();
}

View File

@ -16,7 +16,7 @@ enum class ChannelType : int {
GUILD_STORE = 6,
};
struct Channel {
struct ChannelData {
Snowflake ID;
ChannelType Type;
std::optional<Snowflake> GuildID;
@ -29,7 +29,7 @@ struct Channel {
std::optional<int> Bitrate;
std::optional<int> UserLimit;
std::optional<int> RateLimitPerUser;
std::optional<std::vector<User>> Recipients; // only access id
std::optional<std::vector<UserData>> Recipients; // only access id
std::optional<std::vector<Snowflake>> RecipientIDs;
std::optional<std::string> Icon; // null
std::optional<Snowflake> OwnerID;
@ -37,9 +37,9 @@ struct Channel {
std::optional<Snowflake> ParentID; // null
std::optional<std::string> LastPinTimestamp; // null
friend void from_json(const nlohmann::json &j, Channel &m);
friend void from_json(const nlohmann::json &j, ChannelData &m);
void update_from_json(const nlohmann::json &j);
std::optional<PermissionOverwrite> GetOverwrite(Snowflake id) const;
std::vector<User> GetDMRecipients() const;
std::vector<UserData> GetDMRecipients() const;
};

View File

@ -60,7 +60,7 @@ std::unordered_set<Snowflake> DiscordClient::GetGuilds() const {
return m_store.GetGuilds();
}
const User &DiscordClient::GetUserData() const {
const UserData &DiscordClient::GetUserData() const {
return m_user_data;
}
@ -159,19 +159,19 @@ std::optional<Message> DiscordClient::GetMessage(Snowflake id) const {
return m_store.GetMessage(id);
}
std::optional<Channel> DiscordClient::GetChannel(Snowflake id) const {
std::optional<ChannelData> DiscordClient::GetChannel(Snowflake id) const {
return m_store.GetChannel(id);
}
std::optional<User> DiscordClient::GetUser(Snowflake id) const {
std::optional<UserData> DiscordClient::GetUser(Snowflake id) const {
return m_store.GetUser(id);
}
std::optional<Role> DiscordClient::GetRole(Snowflake id) const {
std::optional<RoleData> DiscordClient::GetRole(Snowflake id) const {
return m_store.GetRole(id);
}
std::optional<Guild> DiscordClient::GetGuild(Snowflake id) const {
std::optional<GuildData> DiscordClient::GetGuild(Snowflake id) const {
return m_store.GetGuild(id);
}
@ -183,7 +183,7 @@ std::optional<PermissionOverwrite> DiscordClient::GetPermissionOverwrite(Snowfla
return m_store.GetPermissionOverwrite(channel_id, id);
}
std::optional<Emoji> DiscordClient::GetEmoji(Snowflake id) const {
std::optional<EmojiData> DiscordClient::GetEmoji(Snowflake id) const {
return m_store.GetEmoji(id);
}
@ -191,7 +191,7 @@ Snowflake DiscordClient::GetMemberHoistedRole(Snowflake guild_id, Snowflake user
const auto data = GetMember(guild_id, user_id);
if (!data.has_value()) return Snowflake::Invalid;
std::vector<Role> roles;
std::vector<RoleData> roles;
for (const auto &id : data->Roles) {
const auto role = GetRole(id);
if (role.has_value()) {
@ -202,7 +202,7 @@ Snowflake DiscordClient::GetMemberHoistedRole(Snowflake guild_id, Snowflake user
if (roles.size() == 0) return Snowflake::Invalid;
std::sort(roles.begin(), roles.end(), [this](const Role &a, const Role &b) -> bool {
std::sort(roles.begin(), roles.end(), [this](const RoleData &a, const RoleData &b) -> bool {
return a.Position > b.Position;
});
@ -381,7 +381,7 @@ void DiscordClient::BanUser(Snowflake user_id, Snowflake guild_id) {
m_http.MakePUT("/guilds/" + std::to_string(guild_id) + "/bans/" + std::to_string(user_id), "{}", [](auto) {});
}
void DiscordClient::UpdateStatus(const std::string &status, bool is_afk, const Activity &obj) {
void DiscordClient::UpdateStatus(const std::string &status, bool is_afk, const ActivityData &obj) {
UpdateStatusMessage msg;
msg.Presence.Status = status;
msg.Presence.IsAFK = is_afk;
@ -614,7 +614,7 @@ void DiscordClient::HandleGatewayHello(const GatewayMessage &msg) {
SendIdentify();
}
void DiscordClient::ProcessNewGuild(Guild &guild) {
void DiscordClient::ProcessNewGuild(GuildData &guild) {
if (guild.IsUnavailable) {
printf("guild (%lld) unavailable\n", static_cast<uint64_t>(guild.ID));
return;
@ -662,7 +662,7 @@ void DiscordClient::HandleGatewayReady(const GatewayMessage &msg) {
m_session_id = data.SessionID;
m_user_data = data.SelfUser;
m_user_settings = data.UserSettings;
m_user_settings = data.Settings;
m_signal_gateway_ready.emit();
}
@ -710,7 +710,7 @@ void DiscordClient::HandleGatewayPresenceUpdate(const GatewayMessage &msg) {
PresenceUpdateMessage data = msg.Data;
auto cur = m_store.GetUser(data.User.at("id").get<Snowflake>());
if (cur.has_value()) {
User::update_from_json(data.User, *cur);
UserData::update_from_json(data.User, *cur);
m_store.SetUser(cur->ID, *cur);
}
}
@ -736,7 +736,7 @@ void DiscordClient::HandleGatewayChannelUpdate(const GatewayMessage &msg) {
}
void DiscordClient::HandleGatewayChannelCreate(const GatewayMessage &msg) {
Channel data = msg.Data;
ChannelData data = msg.Data;
m_store.BeginTransaction();
m_store.SetChannel(data.ID, data);
m_guild_to_channels[*data.GuildID].insert(data.ID);
@ -929,7 +929,7 @@ void DiscordClient::HandleGatewayGuildMemberListUpdate(const GatewayMessage &msg
}
void DiscordClient::HandleGatewayGuildCreate(const GatewayMessage &msg) {
Guild data = msg.Data;
GuildData data = msg.Data;
ProcessNewGuild(data);
m_signal_guild_create.emit(data.ID);

View File

@ -69,7 +69,7 @@ public:
using permission_overwrites_type = Store::permission_overwrites_type;
std::unordered_set<Snowflake> GetGuilds() const;
const User &GetUserData() const;
const UserData &GetUserData() const;
const UserSettings &GetUserSettings() const;
std::vector<Snowflake> GetUserSortedGuilds() const;
std::set<Snowflake> GetMessagesForChannel(Snowflake id) const;
@ -79,12 +79,12 @@ public:
void FetchMessagesInChannel(Snowflake id, std::function<void(const std::vector<Snowflake> &)> cb);
void FetchMessagesInChannelBefore(Snowflake channel_id, Snowflake before_id, std::function<void(const std::vector<Snowflake> &)> cb);
std::optional<Message> GetMessage(Snowflake id) const;
std::optional<Channel> GetChannel(Snowflake id) const;
std::optional<Emoji> GetEmoji(Snowflake id) const;
std::optional<ChannelData> GetChannel(Snowflake id) const;
std::optional<EmojiData> GetEmoji(Snowflake id) const;
std::optional<PermissionOverwrite> GetPermissionOverwrite(Snowflake channel_id, Snowflake id) const;
std::optional<User> GetUser(Snowflake id) const;
std::optional<Role> GetRole(Snowflake id) const;
std::optional<Guild> GetGuild(Snowflake id) const;
std::optional<UserData> GetUser(Snowflake id) const;
std::optional<RoleData> GetRole(Snowflake id) const;
std::optional<GuildData> GetGuild(Snowflake id) const;
std::optional<GuildMember> GetMember(Snowflake user_id, Snowflake guild_id) const;
Snowflake GetMemberHoistedRole(Snowflake guild_id, Snowflake user_id, bool with_color = false) const;
Snowflake GetMemberHighestRole(Snowflake guild_id, Snowflake user_id) const;
@ -105,7 +105,7 @@ public:
void LeaveGuild(Snowflake id);
void KickUser(Snowflake user_id, Snowflake guild_id);
void BanUser(Snowflake user_id, Snowflake guild_id); // todo: reason, delete messages
void UpdateStatus(const std::string &status, bool is_afk, const Activity &obj);
void UpdateStatus(const std::string &status, bool is_afk, const ActivityData &obj);
void CreateDM(Snowflake user_id);
std::optional<Snowflake> FindDM(Snowflake user_id); // wont find group dms
void AddReaction(Snowflake id, Glib::ustring param);
@ -120,7 +120,7 @@ private:
std::vector<uint8_t> m_decompress_buf;
z_stream m_zstream;
void ProcessNewGuild(Guild &guild);
void ProcessNewGuild(GuildData &guild);
void HandleGatewayMessageRaw(std::string str);
void HandleGatewayMessage(std::string str);
@ -168,7 +168,7 @@ private:
std::unordered_map<Snowflake, std::unordered_set<Snowflake>> m_guild_to_channels;
User m_user_data;
UserData m_user_data;
UserSettings m_user_settings;
Store m_store;

View File

@ -1,6 +1,6 @@
#include "emoji.hpp"
void from_json(const nlohmann::json &j, Emoji &m) {
void from_json(const nlohmann::json &j, EmojiData &m) {
JS_N("id", m.ID);
JS_N("name", m.Name);
JS_O("roles", m.Roles);
@ -11,7 +11,7 @@ void from_json(const nlohmann::json &j, Emoji &m) {
JS_O("available", m.IsAvailable);
}
void to_json(nlohmann::json &j, const Emoji &m) {
void to_json(nlohmann::json &j, const EmojiData &m) {
if (m.ID.IsValid())
j["id"] = m.ID;
else
@ -28,10 +28,10 @@ void to_json(nlohmann::json &j, const Emoji &m) {
JS_IF("available", m.IsAvailable);
}
std::string Emoji::GetURL() const {
std::string EmojiData::GetURL() const {
return "https://cdn.discordapp.com/emojis/" + std::to_string(ID) + ".png";
}
std::string Emoji::URLFromID(std::string emoji_id, std::string ext) {
std::string EmojiData::URLFromID(std::string emoji_id, std::string ext) {
return "https://cdn.discordapp.com/emojis/" + emoji_id + "." + ext;
}

View File

@ -5,18 +5,18 @@
#include "snowflake.hpp"
#include "user.hpp"
struct Emoji {
struct EmojiData {
Snowflake ID; // null
std::string Name; // null (in reactions)
std::optional<std::vector<Snowflake>> Roles;
std::optional<User> Creator; // only reliable to access ID
std::optional<UserData> Creator; // only reliable to access ID
std::optional<bool> NeedsColons;
std::optional<bool> IsManaged;
std::optional<bool> IsAnimated;
std::optional<bool> IsAvailable;
friend void from_json(const nlohmann::json &j, Emoji &m);
friend void to_json(nlohmann::json &j, const Emoji &m);
friend void from_json(const nlohmann::json &j, EmojiData &m);
friend void to_json(nlohmann::json &j, const EmojiData &m);
std::string GetURL() const;
static std::string URLFromID(std::string emoji_id, std::string ext = "png");

View File

@ -1,7 +1,7 @@
#include "guild.hpp"
#include "../abaddon.hpp"
void from_json(const nlohmann::json &j, Guild &m) {
void from_json(const nlohmann::json &j, GuildData &m) {
JS_D("id", m.ID);
if (j.contains("unavailable")) {
m.IsUnavailable = true;
@ -62,7 +62,7 @@ void from_json(const nlohmann::json &j, Guild &m) {
m.ApproximatePresenceCount = std::stol(*tmp);
}
void Guild::update_from_json(const nlohmann::json &j) {
void GuildData::update_from_json(const nlohmann::json &j) {
if (j.contains("unavailable")) {
IsUnavailable = true;
return;
@ -118,27 +118,27 @@ void Guild::update_from_json(const nlohmann::json &j) {
JS_RD("approximate_presence_count", ApproximatePresenceCount);
}
bool Guild::HasIcon() const {
bool GuildData::HasIcon() const {
return Icon != "";
}
bool Guild::HasAnimatedIcon() const {
bool GuildData::HasAnimatedIcon() const {
return HasIcon() && Icon[0] == 'a' && Icon[1] == '_';
}
std::string Guild::GetIconURL(std::string ext, std::string size) const {
std::string GuildData::GetIconURL(std::string ext, std::string size) const {
return "https://cdn.discordapp.com/icons/" + std::to_string(ID) + "/" + Icon + "." + ext + "?size=" + size;
}
std::vector<Snowflake> Guild::GetSortedChannels(Snowflake ignore) const {
std::vector<Snowflake> GuildData::GetSortedChannels(Snowflake ignore) const {
std::vector<Snowflake> ret;
const auto &discord = Abaddon::Get().GetDiscordClient();
auto channels = discord.GetChannelsInGuild(ID);
std::unordered_map<Snowflake, std::vector<Channel>> category_to_channels;
std::map<int, std::vector<Channel>> position_to_categories;
std::map<int, std::vector<Channel>> orphan_channels;
std::unordered_map<Snowflake, std::vector<ChannelData>> category_to_channels;
std::map<int, std::vector<ChannelData>> position_to_categories;
std::map<int, std::vector<ChannelData>> orphan_channels;
for (const auto &channel_id : channels) {
const auto data = discord.GetChannel(channel_id);
if (!data.has_value()) continue;
@ -151,7 +151,7 @@ std::vector<Snowflake> Guild::GetSortedChannels(Snowflake ignore) const {
}
for (auto &[pos, channels] : orphan_channels) {
std::sort(channels.begin(), channels.end(), [&](const Channel &a, const Channel &b) -> bool {
std::sort(channels.begin(), channels.end(), [&](const ChannelData &a, const ChannelData &b) -> bool {
return a.ID < b.ID;
});
for (const auto &chan : channels)
@ -159,7 +159,7 @@ std::vector<Snowflake> Guild::GetSortedChannels(Snowflake ignore) const {
}
for (auto &[pos, categories] : position_to_categories) {
std::sort(categories.begin(), categories.end(), [&](const Channel &a, const Channel &b) -> bool {
std::sort(categories.begin(), categories.end(), [&](const ChannelData &a, const ChannelData &b) -> bool {
return a.ID < b.ID;
});
for (const auto &category : categories) {
@ -168,7 +168,7 @@ std::vector<Snowflake> Guild::GetSortedChannels(Snowflake ignore) const {
auto it = category_to_channels.find(category.ID);
if (it == category_to_channels.end()) continue;
auto &channels = it->second;
std::sort(channels.begin(), channels.end(), [&](const Channel &a, const Channel &b) -> bool {
std::sort(channels.begin(), channels.end(), [&](const ChannelData &a, const ChannelData &b) -> bool {
return a.Position < b.Position;
});
for (auto &channel : channels) {

View File

@ -9,7 +9,7 @@
// a bot is apparently only supposed to receive the `id` and `unavailable` as false
// but user tokens seem to get the full objects (minus users)
struct Guild {
struct GuildData {
Snowflake ID;
std::string Name;
std::string Icon; // null
@ -27,8 +27,8 @@ struct Guild {
int VerificationLevel;
int DefaultMessageNotifications;
int ExplicitContentFilter;
std::vector<Role> Roles; // only access id
std::vector<Emoji> Emojis; // only access id
std::vector<RoleData> Roles; // only access id
std::vector<EmojiData> Emojis; // only access id
std::vector<std::string> Features;
int MFALevel;
Snowflake ApplicationID; // null
@ -43,7 +43,7 @@ struct Guild {
std::optional<int> MemberCount; // *
// std::vector<VoiceStateData> VoiceStates; // opt*
// std::vector<MemberData> Members; // opt* - incomplete anyways
std::optional<std::vector<Channel>> Channels; // *
std::optional<std::vector<ChannelData>> Channels; // *
// std::vector<PresenceUpdateData> Presences; // opt*
std::optional<int> MaxPresences; // null
std::optional<int> MaxMembers;
@ -64,7 +64,7 @@ struct Guild {
// * - documentation says only sent in GUILD_CREATE, but these can be sent anyways in the READY event
friend void from_json(const nlohmann::json &j, Guild &m);
friend void from_json(const nlohmann::json &j, GuildData &m);
void update_from_json(const nlohmann::json &j);
bool HasIcon() const;

View File

@ -5,11 +5,11 @@
class Invite {
public:
std::string Code; //
Guild Guild; // opt
Channel Channel; // opt
User Inviter; // opt
int Members = -1; // opt
std::string Code; //
GuildData Guild; // opt
ChannelData Channel; // opt
UserData Inviter; // opt
int Members = -1; // opt
friend void from_json(const nlohmann::json &j, Invite &m);
};

View File

@ -6,8 +6,8 @@
#include <vector>
struct GuildMember {
std::optional<User> User; // only reliable to access id. only opt in MESSAGE_*
std::string Nickname; // null
std::optional<UserData> User; // only reliable to access id. only opt in MESSAGE_*
std::string Nickname; // null
std::vector<Snowflake> Roles;
std::string JoinedAt;
std::optional<std::string> PremiumSince; // null

View File

@ -145,7 +145,7 @@ struct MessageReferenceData {
struct ReactionData {
int Count;
bool HasReactedWith;
Emoji Emoji;
EmojiData Emoji;
friend void from_json(const nlohmann::json &j, ReactionData &m);
friend void to_json(nlohmann::json &j, const ReactionData &m);
@ -166,15 +166,15 @@ struct Message {
Snowflake ID;
Snowflake ChannelID;
std::optional<Snowflake> GuildID;
User Author;
UserData Author;
// std::optional<GuildMember> Member;
std::string Content;
std::string Timestamp;
std::string EditedTimestamp; // null
bool IsTTS;
bool DoesMentionEveryone;
std::vector<User> Mentions; // full user accessible
// std::vector<Role> MentionRoles;
std::vector<UserData> Mentions; // full user accessible
// std::vector<RoleData> MentionRoles;
// std::optional<std::vector<ChannelMentionData>> MentionChannels;
std::vector<AttachmentData> Attachments;
std::vector<EmbedData> Embeds;
@ -183,11 +183,11 @@ struct Message {
bool IsPinned;
std::optional<Snowflake> WebhookID;
MessageType Type;
// std::optional<MessageActivityData> Activity;
// std::optional<MessageActivityData> ActivityData;
std::optional<MessageApplicationData> Application;
std::optional<MessageReferenceData> MessageReference;
std::optional<MessageFlags> Flags = MessageFlags::NONE;
std::optional<std::vector<Sticker>> Stickers;
std::optional<std::vector<StickerData>> Stickers;
std::optional<std::shared_ptr<Message>> ReferencedMessage; // has_value && null means deleted
friend void from_json(const nlohmann::json &j, Message &m);

View File

@ -95,7 +95,7 @@ void from_json(const nlohmann::json &j, ReadyEventData &m) {
JS_D("session_id", m.SessionID);
JS_O("analytics_token", m.AnalyticsToken);
JS_O("friend_suggestion_count", m.FriendSuggestionCount);
JS_D("user_settings", m.UserSettings);
JS_D("user_settings", m.Settings);
JS_D("private_channels", m.PrivateChannels);
JS_O("users", m.Users);
}
@ -178,9 +178,9 @@ void from_json(const nlohmann::json &j, ClientStatus &m) {
void from_json(const nlohmann::json &j, PresenceUpdateMessage &m) {
m.User = j.at("user");
JS_O("guild_id", m.GuildID);
JS_D("status", m.Status);
JS_D("status", m.StatusMessage);
// JS_D("activities", m.Activities);
JS_D("client_status", m.ClientStatus);
JS_D("client_status", m.Status);
}
void to_json(nlohmann::json &j, const CreateDMObject &m) {

View File

@ -99,7 +99,7 @@ struct GuildMemberListUpdateMessage {
};
struct MemberItem : Item {
User User; //
UserData User; //
std::vector<Snowflake> Roles; //
// PresenceData Presence; //
std::string PremiumSince; // opt
@ -147,23 +147,23 @@ struct LazyLoadRequestMessage {
};
struct UpdateStatusMessage {
Presence Presence;
PresenceData Presence;
friend void to_json(nlohmann::json &j, const UpdateStatusMessage &m);
};
struct ReadyEventData {
int GatewayVersion;
User SelfUser;
std::vector<Guild> Guilds;
UserData SelfUser;
std::vector<GuildData> Guilds;
std::string SessionID;
std::vector<Channel> PrivateChannels;
std::vector<ChannelData> PrivateChannels;
// undocumented
std::optional<std::vector<User>> Users;
std::optional<std::vector<UserData>> Users;
std::optional<std::string> AnalyticsToken;
std::optional<int> FriendSuggestionCount;
UserSettings UserSettings;
UserSettings Settings;
// std::vector<Unknown> ConnectedAccounts; // opt
// std::map<std::string, Unknown> Consents; // opt
// std::vector<Unknown> Experiments; // opt
@ -208,7 +208,7 @@ struct ClientStateProperties {
struct IdentifyMessage : GatewayMessage {
std::string Token;
IdentifyProperties Properties;
Presence Presence;
PresenceData Presence;
ClientStateProperties ClientState;
bool DoesSupportCompression = false;
int Capabilities;
@ -239,7 +239,7 @@ struct MessageEditObject {
struct GuildMemberUpdateMessage {
Snowflake GuildID; //
std::vector<Snowflake> Roles; //
User User; //
UserData User; //
std::string Nick; // opt, null
std::string JoinedAt;
std::string PremiumSince; // opt, null
@ -258,9 +258,9 @@ struct ClientStatus {
struct PresenceUpdateMessage {
nlohmann::json User; // the client updates an existing object from this data
Snowflake GuildID; // opt
std::string Status;
// std::vector<Activity> Activities;
ClientStatus ClientStatus;
std::string StatusMessage;
// std::vector<ActivityData> Activities;
ClientStatus Status;
friend void from_json(const nlohmann::json &j, PresenceUpdateMessage &m);
};
@ -281,14 +281,14 @@ struct ResumeMessage : GatewayMessage {
struct GuildRoleUpdateObject {
Snowflake GuildID;
Role Role;
RoleData Role;
friend void from_json(const nlohmann::json &j, GuildRoleUpdateObject &m);
};
struct GuildRoleCreateObject {
Snowflake GuildID;
Role Role;
RoleData Role;
friend void from_json(const nlohmann::json &j, GuildRoleCreateObject &m);
};
@ -306,7 +306,7 @@ struct MessageReactionAddObject {
Snowflake MessageID;
std::optional<Snowflake> GuildID;
std::optional<GuildMember> Member;
Emoji Emoji;
EmojiData Emoji;
friend void from_json(const nlohmann::json &j, MessageReactionAddObject &m);
};
@ -316,20 +316,20 @@ struct MessageReactionRemoveObject {
Snowflake ChannelID;
Snowflake MessageID;
std::optional<Snowflake> GuildID;
Emoji Emoji;
EmojiData Emoji;
friend void from_json(const nlohmann::json &j, MessageReactionRemoveObject &m);
};
struct ChannelRecipientAdd {
User User;
UserData User;
Snowflake ChannelID;
friend void from_json(const nlohmann::json &j, ChannelRecipientAdd &m);
};
struct ChannelRecipientRemove {
User User;
UserData User;
Snowflake ChannelID;
friend void from_json(const nlohmann::json &j, ChannelRecipientRemove &m);

View File

@ -1,6 +1,6 @@
#include "role.hpp"
void from_json(const nlohmann::json &j, Role &m) {
void from_json(const nlohmann::json &j, RoleData &m) {
JS_D("id", m.ID);
JS_D("name", m.Name);
JS_D("color", m.Color);

View File

@ -5,7 +5,7 @@
#include <string>
#include <cstdint>
struct Role {
struct RoleData {
Snowflake ID;
std::string Name;
int Color;
@ -16,5 +16,5 @@ struct Role {
bool IsManaged;
bool IsMentionable;
friend void from_json(const nlohmann::json &j, Role &m);
friend void from_json(const nlohmann::json &j, RoleData &m);
};

View File

@ -1,6 +1,6 @@
#include "sticker.hpp"
void to_json(nlohmann::json &j, const Sticker &m) {
void to_json(nlohmann::json &j, const StickerData &m) {
j["id"] = m.ID;
j["pack_id"] = m.PackID;
j["name"] = m.Name;
@ -11,7 +11,7 @@ void to_json(nlohmann::json &j, const Sticker &m) {
j["format_type"] = m.FormatType;
}
void from_json(const nlohmann::json &j, Sticker &m) {
void from_json(const nlohmann::json &j, StickerData &m) {
JS_D("id", m.ID);
JS_D("pack_id", m.PackID);
JS_D("name", m.Name);
@ -22,7 +22,7 @@ void from_json(const nlohmann::json &j, Sticker &m) {
JS_D("format_type", m.FormatType);
}
std::string Sticker::GetURL() const {
std::string StickerData::GetURL() const {
if (!AssetHash.has_value()) return "";
if (FormatType == StickerFormatType::PNG || FormatType == StickerFormatType::APNG)
return "https://media.discordapp.net/stickers/" + std::to_string(ID) + "/" + *AssetHash + ".png?size=256";

View File

@ -12,7 +12,7 @@ enum class StickerFormatType {
LOTTIE = 3,
};
struct Sticker {
struct StickerData {
Snowflake ID;
Snowflake PackID;
std::string Name;
@ -22,8 +22,8 @@ struct Sticker {
std::optional<std::string> PreviewAssetHash;
StickerFormatType FormatType;
friend void to_json(nlohmann::json &j, const Sticker &m);
friend void from_json(const nlohmann::json &j, Sticker &m);
friend void to_json(nlohmann::json &j, const StickerData &m);
friend void from_json(const nlohmann::json &j, StickerData &m);
std::string GetURL() const;
};

View File

@ -51,7 +51,7 @@ bool Store::IsValid() const {
return m_db_err == SQLITE_OK;
}
void Store::SetChannel(Snowflake id, const Channel &chan) {
void Store::SetChannel(Snowflake id, const ChannelData &chan) {
Bind(m_set_chan_stmt, 1, id);
Bind(m_set_chan_stmt, 2, static_cast<int>(chan.Type));
Bind(m_set_chan_stmt, 3, chan.GuildID);
@ -86,7 +86,7 @@ void Store::SetChannel(Snowflake id, const Channel &chan) {
m_channels.insert(id);
}
void Store::SetEmoji(Snowflake id, const Emoji &emoji) {
void Store::SetEmoji(Snowflake id, const EmojiData &emoji) {
Bind(m_set_emote_stmt, 1, id);
Bind(m_set_emote_stmt, 2, emoji.Name);
@ -109,7 +109,7 @@ void Store::SetEmoji(Snowflake id, const Emoji &emoji) {
fprintf(stderr, "emoji insert failed: %s\n", sqlite3_errstr(m_db_err));
}
void Store::SetGuild(Snowflake id, const Guild &guild) {
void Store::SetGuild(Snowflake id, const GuildData &guild) {
Bind(m_set_guild_stmt, 1, id);
Bind(m_set_guild_stmt, 2, guild.Name);
Bind(m_set_guild_stmt, 3, guild.Icon);
@ -239,7 +239,7 @@ void Store::SetPermissionOverwrite(Snowflake channel_id, Snowflake id, const Per
fprintf(stderr, "permission insert failed: %s\n", sqlite3_errstr(m_db_err));
}
void Store::SetRole(Snowflake id, const Role &role) {
void Store::SetRole(Snowflake id, const RoleData &role) {
Bind(m_set_role_stmt, 1, id);
Bind(m_set_role_stmt, 2, role.Name);
Bind(m_set_role_stmt, 3, role.Color);
@ -253,7 +253,7 @@ void Store::SetRole(Snowflake id, const Role &role) {
fprintf(stderr, "role insert failed: %s\n", sqlite3_errstr(m_db_err));
}
void Store::SetUser(Snowflake id, const User &user) {
void Store::SetUser(Snowflake id, const UserData &user) {
Bind(m_set_user_stmt, 1, id);
Bind(m_set_user_stmt, 2, user.Username);
Bind(m_set_user_stmt, 3, user.Discriminator);
@ -273,7 +273,7 @@ void Store::SetUser(Snowflake id, const User &user) {
}
}
std::optional<Channel> Store::GetChannel(Snowflake id) const {
std::optional<ChannelData> Store::GetChannel(Snowflake id) const {
Bind(m_get_chan_stmt, 1, id);
if (!FetchOne(m_get_chan_stmt)) {
if (m_db_err != SQLITE_DONE)
@ -282,7 +282,7 @@ std::optional<Channel> Store::GetChannel(Snowflake id) const {
return std::nullopt;
}
Channel ret;
ChannelData ret;
ret.ID = id;
int tmpi;
Get(m_get_chan_stmt, 1, tmpi);
@ -313,7 +313,7 @@ std::optional<Channel> Store::GetChannel(Snowflake id) const {
return ret;
}
std::optional<Emoji> Store::GetEmoji(Snowflake id) const {
std::optional<EmojiData> Store::GetEmoji(Snowflake id) const {
Bind(m_get_emote_stmt, 1, id);
if (!FetchOne(m_get_emote_stmt)) {
if (m_db_err != SQLITE_DONE)
@ -322,7 +322,7 @@ std::optional<Emoji> Store::GetEmoji(Snowflake id) const {
return std::nullopt;
}
Emoji ret;
EmojiData ret;
ret.ID = id;
Get(m_get_emote_stmt, 1, ret.Name);
@ -333,7 +333,7 @@ std::optional<Emoji> Store::GetEmoji(Snowflake id) const {
}
if (!IsNull(m_get_emote_stmt, 3)) {
ret.Creator = std::optional<User>(User());
ret.Creator = std::optional<UserData>(UserData());
Get(m_get_emote_stmt, 3, ret.Creator->ID);
}
Get(m_get_emote_stmt, 4, ret.NeedsColons);
@ -346,7 +346,7 @@ std::optional<Emoji> Store::GetEmoji(Snowflake id) const {
return ret;
}
std::optional<Guild> Store::GetGuild(Snowflake id) const {
std::optional<GuildData> Store::GetGuild(Snowflake id) const {
Bind(m_get_guild_stmt, 1, id);
if (!FetchOne(m_get_guild_stmt)) {
if (m_db_err != SQLITE_DONE)
@ -355,7 +355,7 @@ std::optional<Guild> Store::GetGuild(Snowflake id) const {
return std::nullopt;
}
Guild ret;
GuildData ret;
ret.ID = id;
Get(m_get_guild_stmt, 1, ret.Name);
Get(m_get_guild_stmt, 2, ret.Icon);
@ -481,7 +481,7 @@ std::optional<Message> Store::GetMessage(Snowflake id) const {
Get(m_get_msg_stmt, 18, tmps);
if (tmps != "")
ret.Stickers = nlohmann::json::parse(tmps).get<std::vector<Sticker>>();
ret.Stickers = nlohmann::json::parse(tmps).get<std::vector<StickerData>>();
Get(m_get_msg_stmt, 19, tmps);
if (tmps != "")
@ -532,7 +532,7 @@ std::optional<PermissionOverwrite> Store::GetPermissionOverwrite(Snowflake chann
return ret;
}
std::optional<Role> Store::GetRole(Snowflake id) const {
std::optional<RoleData> Store::GetRole(Snowflake id) const {
Bind(m_get_role_stmt, 1, id);
if (!FetchOne(m_get_role_stmt)) {
if (m_db_err != SQLITE_DONE)
@ -541,7 +541,7 @@ std::optional<Role> Store::GetRole(Snowflake id) const {
return std::nullopt;
}
Role ret;
RoleData ret;
ret.ID = id;
Get(m_get_role_stmt, 1, ret.Name);
Get(m_get_role_stmt, 2, ret.Color);
@ -558,7 +558,7 @@ std::optional<Role> Store::GetRole(Snowflake id) const {
return ret;
}
std::optional<User> Store::GetUser(Snowflake id) const {
std::optional<UserData> Store::GetUser(Snowflake id) const {
Bind(m_get_user_stmt, 1, id);
if (!FetchOne(m_get_user_stmt)) {
if (m_db_err != SQLITE_DONE)
@ -567,7 +567,7 @@ std::optional<User> Store::GetUser(Snowflake id) const {
return std::nullopt;
}
User ret;
UserData ret;
Get(m_get_user_stmt, 0, ret.ID);
Get(m_get_user_stmt, 1, ret.Username);
Get(m_get_user_stmt, 2, ret.Discriminator);

View File

@ -18,37 +18,37 @@ public:
bool IsValid() const;
void SetUser(Snowflake id, const User &user);
void SetChannel(Snowflake id, const Channel &chan);
void SetGuild(Snowflake id, const Guild &guild);
void SetRole(Snowflake id, const Role &role);
void SetUser(Snowflake id, const UserData &user);
void SetChannel(Snowflake id, const ChannelData &chan);
void SetGuild(Snowflake id, const GuildData &guild);
void SetRole(Snowflake id, const RoleData &role);
void SetMessage(Snowflake id, const Message &message);
void SetGuildMember(Snowflake guild_id, Snowflake user_id, const GuildMember &data);
void SetPermissionOverwrite(Snowflake channel_id, Snowflake id, const PermissionOverwrite &perm);
void SetEmoji(Snowflake id, const Emoji &emoji);
void SetEmoji(Snowflake id, const EmojiData &emoji);
// slap const on everything even tho its not *really* const
std::optional<Channel> GetChannel(Snowflake id) const;
std::optional<Emoji> GetEmoji(Snowflake id) const;
std::optional<Guild> GetGuild(Snowflake id) const;
std::optional<ChannelData> GetChannel(Snowflake id) const;
std::optional<EmojiData> GetEmoji(Snowflake id) const;
std::optional<GuildData> GetGuild(Snowflake id) const;
std::optional<GuildMember> GetGuildMember(Snowflake guild_id, Snowflake user_id) const;
std::optional<Message> GetMessage(Snowflake id) const;
std::optional<PermissionOverwrite> GetPermissionOverwrite(Snowflake channel_id, Snowflake id) const;
std::optional<Role> GetRole(Snowflake id) const;
std::optional<User> GetUser(Snowflake id) const;
std::optional<RoleData> GetRole(Snowflake id) const;
std::optional<UserData> GetUser(Snowflake id) const;
void ClearGuild(Snowflake id);
void ClearChannel(Snowflake id);
using users_type = std::unordered_map<Snowflake, User>;
using channels_type = std::unordered_map<Snowflake, Channel>;
using guilds_type = std::unordered_map<Snowflake, Guild>;
using roles_type = std::unordered_map<Snowflake, Role>;
using users_type = std::unordered_map<Snowflake, UserData>;
using channels_type = std::unordered_map<Snowflake, ChannelData>;
using guilds_type = std::unordered_map<Snowflake, GuildData>;
using roles_type = std::unordered_map<Snowflake, RoleData>;
using messages_type = std::unordered_map<Snowflake, Message>;
using members_type = std::unordered_map<Snowflake, std::unordered_map<Snowflake, GuildMember>>; // [guild][user]
using permission_overwrites_type = std::unordered_map<Snowflake, std::unordered_map<Snowflake, PermissionOverwrite>>; // [channel][user/role]
using emojis_type = std::unordered_map<Snowflake, Emoji>;
using emojis_type = std::unordered_map<Snowflake, EmojiData>;
const std::unordered_set<Snowflake> &GetChannels() const;
const std::unordered_set<Snowflake> &GetGuilds() const;

View File

@ -1,27 +1,27 @@
#include "user.hpp"
#include "../abaddon.hpp"
bool User::HasAvatar() const {
bool UserData::HasAvatar() const {
return Avatar.size() > 0;
}
bool User::HasAnimatedAvatar() const {
bool UserData::HasAnimatedAvatar() const {
return Avatar.size() > 0 && Avatar[0] == 'a' && Avatar[1] == '_';
}
std::string User::GetAvatarURL(std::string ext, std::string size) const {
std::string UserData::GetAvatarURL(std::string ext, std::string size) const {
return "https://cdn.discordapp.com/avatars/" + std::to_string(ID) + "/" + Avatar + "." + ext + "?size=" + size;
}
Snowflake User::GetHoistedRole(Snowflake guild_id, bool with_color) const {
Snowflake UserData::GetHoistedRole(Snowflake guild_id, bool with_color) const {
return Abaddon::Get().GetDiscordClient().GetMemberHoistedRole(guild_id, ID, with_color);
}
std::string User::GetMention() const {
std::string UserData::GetMention() const {
return "<@" + std::to_string(ID) + ">";
}
void from_json(const nlohmann::json &j, User &m) {
void from_json(const nlohmann::json &j, UserData &m) {
JS_D("id", m.ID);
JS_D("username", m.Username);
JS_D("discriminator", m.Discriminator);
@ -41,7 +41,7 @@ void from_json(const nlohmann::json &j, User &m) {
JS_ON("phone", m.Phone);
}
void to_json(nlohmann::json &j, const User &m) {
void to_json(nlohmann::json &j, const UserData &m) {
j["id"] = m.ID;
j["username"] = m.Username;
j["discriminator"] = m.Discriminator;
@ -64,7 +64,7 @@ void to_json(nlohmann::json &j, const User &m) {
JS_IF("phone", m.Phone);
}
void User::update_from_json(const nlohmann::json &j, User &m) {
void UserData::update_from_json(const nlohmann::json &j, UserData &m) {
JS_RD("username", m.Username);
JS_RD("discriminator", m.Discriminator);
JS_RD("avatar", m.Avatar);

View File

@ -3,7 +3,7 @@
#include "json.hpp"
#include <string>
struct User {
struct UserData {
Snowflake ID;
std::string Username;
std::string Discriminator;
@ -24,9 +24,9 @@ struct User {
std::optional<bool> IsNSFWAllowed; // null
std::optional<std::string> Phone; // null?
friend void from_json(const nlohmann::json &j, User &m);
friend void to_json(nlohmann::json &j, const User &m);
static void update_from_json(const nlohmann::json &j, User &m);
friend void from_json(const nlohmann::json &j, UserData &m);
friend void to_json(nlohmann::json &j, const UserData &m);
static void update_from_json(const nlohmann::json &j, UserData &m);
bool HasAvatar() const;
bool HasAnimatedAvatar() const;

View File

@ -28,8 +28,7 @@ public:
m_ini.SaveFile(m_filename.c_str());
}
template<>
void SetSetting<std::string>(std::string section, std::string key, std::string value) {
void SetSetting(std::string section, std::string key, std::string value) {
m_ini.SetValue(section.c_str(), key.c_str(), value.c_str());
m_ini.SaveFile(m_filename.c_str());
}

1
thirdparty/IXWebSocket vendored Submodule

@ -0,0 +1 @@
Subproject commit 2fac4bd9ef58c3be3e370222410b8694a4ef0d22

1
thirdparty/simpleini vendored Submodule

@ -0,0 +1 @@
Subproject commit 7bca74f6535a37846162383e52071f380c99a43a