Compare commits
85 Commits
Author | SHA1 | Date |
---|---|---|
tastytea | 4b7215036b | |
tastytea | e65fadfba6 | |
tastytea | fd407094a2 | |
tastytea | 76e12d7093 | |
tastytea | 2a9219ce7e | |
tastytea | cacc2c3a5b | |
tastytea | ceda771700 | |
tastytea | c6ad04e6ee | |
tastytea | 9671407556 | |
tastytea | c35dab8350 | |
tastytea | c772d7b60e | |
tastytea | e1b61b5041 | |
tastytea | db95855ab6 | |
tastytea | 5dce94a4a3 | |
tastytea | 7adad67dd9 | |
tastytea | 5275ab73ac | |
tastytea | a50d28e9a2 | |
tastytea | 57238020a3 | |
tastytea | d37e720a11 | |
tastytea | ad0773d5a7 | |
tastytea | bfe77f1b18 | |
tastytea | 10947148a1 | |
tastytea | ec49399d39 | |
tastytea | b4d6e37c96 | |
tastytea | 719f8a7664 | |
tastytea | c3a5df62e5 | |
tastytea | 8b197134ab | |
tastytea | d43b1c72db | |
tastytea | 2fa3bff89c | |
tastytea | fe526f8e94 | |
tastytea | 28919cdaa8 | |
tastytea | ff846a63cb | |
tastytea | 7857b17b8b | |
tastytea | f65cc6bac6 | |
tastytea | 453d8fc272 | |
tastytea | a99fdc0742 | |
tastytea | 22754226f2 | |
tastytea | 66d41fec46 | |
tastytea | ff43aea4ab | |
tastytea | 83819c5f33 | |
tastytea | 9b13db149b | |
tastytea | 795bf14e51 | |
tastytea | 47adbe0281 | |
tastytea | 14d2e53cfc | |
tastytea | f8ed45dcc4 | |
tastytea | d100d1a2b6 | |
tastytea | ff649fd2eb | |
tastytea | 7f80bff4e1 | |
tastytea | 3446bbf5d6 | |
tastytea | 14a1d92442 | |
tastytea | c3e00e2e31 | |
tastytea | 1b514df555 | |
tastytea | 416675a667 | |
tastytea | 4d5b331a0f | |
tastytea | 2b265a5831 | |
tastytea | 08ae30835c | |
tastytea | 707771c7bf | |
tastytea | 6b070dec98 | |
tastytea | d2a4d835de | |
tastytea | acbcb6224e | |
tastytea | 188033a0c1 | |
tastytea | 41a580b32b | |
tastytea | 915c85e9e9 | |
tastytea | 5ddea09924 | |
tastytea | c48c1a66f2 | |
tastytea | ed989935ac | |
tastytea | a6f70263b8 | |
tastytea | d0bac6779f | |
tastytea | 565317115c | |
tastytea | 9da01c0398 | |
tastytea | 62d28c523a | |
tastytea | d16454e169 | |
tastytea | 12c0b896db | |
tastytea | ecb49c7e00 | |
tastytea | bc58a977f0 | |
tastytea | f97608ecfa | |
tastytea | bd07dc6f9c | |
tastytea | 1273518a5c | |
tastytea | 5f73020056 | |
tastytea | ac3538aed2 | |
tastytea | 231663b07e | |
tastytea | 72efbb515d | |
tastytea | 740890e402 | |
tastytea | 22d1232240 | |
tastytea | 0998ee5ef9 |
140
.drone.yml
140
.drone.yml
|
@ -25,19 +25,16 @@ steps:
|
||||||
MASTODON_CPP_ACCESS_TOKEN:
|
MASTODON_CPP_ACCESS_TOKEN:
|
||||||
from_secret: mastodon_cpp_access_token
|
from_secret: mastodon_cpp_access_token
|
||||||
commands:
|
commands:
|
||||||
- rm /etc/apt/apt.conf.d/docker-clean
|
- rm -f /etc/apt/apt.conf.d/docker-clean
|
||||||
- rm /var/cache/apt/archives/lock
|
- rm -f /var/cache/apt/archives/lock
|
||||||
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
|
|
||||||
- echo "deb http://deb.debian.org/debian sid main" >> /etc/apt/sources.list.d/sid.list
|
|
||||||
- apt-get update -q
|
- apt-get update -q
|
||||||
- apt-get install -qy build-essential cmake pkg-config
|
- apt-get install -qy build-essential cmake
|
||||||
- apt-get install -qy libcurl4-openssl-dev libjsoncpp-dev doxygen catch
|
- apt-get install -qy libpoco-dev libjsoncpp-dev doxygen catch
|
||||||
- apt-get install -qy -t sid libcurlpp-dev
|
|
||||||
- rm -rf build && mkdir -p build && cd build
|
- rm -rf build && mkdir -p build && cd build
|
||||||
- cmake -DWITH_EXAMPLES=YES -DWITH_TESTS=YES -DEXTRA_TEST_ARGS="~[api]" ..
|
- cmake -DWITH_EXAMPLES=YES -DWITH_TESTS=YES -DEXTRA_TEST_ARGS="~[api]" ..
|
||||||
- make VERBOSE=1
|
- make VERBOSE=1
|
||||||
- make install DESTDIR=install
|
- make install DESTDIR=install
|
||||||
- ctest
|
- cd tests && ctest
|
||||||
volumes:
|
volumes:
|
||||||
- name: debian-package-cache
|
- name: debian-package-cache
|
||||||
path: /var/cache/apt/archives
|
path: /var/cache/apt/archives
|
||||||
|
@ -51,25 +48,22 @@ steps:
|
||||||
MASTODON_CPP_ACCESS_TOKEN:
|
MASTODON_CPP_ACCESS_TOKEN:
|
||||||
from_secret: mastodon_cpp_access_token
|
from_secret: mastodon_cpp_access_token
|
||||||
commands:
|
commands:
|
||||||
- rm /etc/apt/apt.conf.d/docker-clean
|
- rm -f /etc/apt/apt.conf.d/docker-clean
|
||||||
- rm /var/cache/apt/archives/lock
|
- rm -f /var/cache/apt/archives/lock
|
||||||
- apt-get update -q
|
- apt-get update -q
|
||||||
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
|
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
|
||||||
- echo "deb http://deb.debian.org/debian sid main" >> /etc/apt/sources.list.d/sid.list
|
|
||||||
- echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main" >> /etc/apt/sources.list.d/ubuntu-toolchain-r.list
|
- echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main" >> /etc/apt/sources.list.d/ubuntu-toolchain-r.list
|
||||||
- apt-get install -qy gnupg
|
- apt-get install -qy gnupg
|
||||||
- gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 0x60c317803a41ba51845e371a1e9377a2ba9ef27f
|
- gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 0x60c317803a41ba51845e371a1e9377a2ba9ef27f
|
||||||
- gpg --armor --export 0x60c317803a41ba51845e371a1e9377a2ba9ef27f | apt-key add -
|
- gpg --armor --export 0x60c317803a41ba51845e371a1e9377a2ba9ef27f | apt-key add -
|
||||||
- apt-get update -q
|
- apt-get update -q
|
||||||
- apt-get install -qy build-essential cmake pkg-config
|
- apt-get install -qy build-essential cmake
|
||||||
- apt-get install -qy -t xenial g++-9
|
- apt-get install -qy -t xenial g++-9
|
||||||
- apt-get install -qy libcurl4-openssl-dev libjsoncpp-dev doxygen catch
|
- apt-get install -qy libpoco-dev libjsoncpp-dev doxygen catch
|
||||||
- apt-get install -qy -t sid libcurlpp-dev
|
|
||||||
- rm -rf build && mkdir -p build && cd build
|
- rm -rf build && mkdir -p build && cd build
|
||||||
- cmake -DWITH_EXAMPLES=YES -DWITH_TESTS=YES -DEXTRA_TEST_ARGS="~[api]" ..
|
- cmake -DWITH_EXAMPLES=YES ..
|
||||||
- make VERBOSE=1
|
- make VERBOSE=1
|
||||||
- make install DESTDIR=install
|
- make install DESTDIR=install
|
||||||
- ctest
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: debian-package-cache
|
- name: debian-package-cache
|
||||||
path: /var/cache/apt/archives
|
path: /var/cache/apt/archives
|
||||||
|
@ -83,52 +77,43 @@ steps:
|
||||||
MASTODON_CPP_ACCESS_TOKEN:
|
MASTODON_CPP_ACCESS_TOKEN:
|
||||||
from_secret: mastodon_cpp_access_token
|
from_secret: mastodon_cpp_access_token
|
||||||
commands:
|
commands:
|
||||||
- rm /etc/apt/apt.conf.d/docker-clean
|
- rm -f /etc/apt/apt.conf.d/docker-clean
|
||||||
- rm /var/cache/apt/archives/lock
|
- rm -f /var/cache/apt/archives/lock
|
||||||
- apt-get update -q
|
- apt-get update -q
|
||||||
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
|
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
|
||||||
- echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list.d/stretch.list
|
- echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list.d/stretch.list
|
||||||
- echo "deb http://deb.debian.org/debian sid main" >> /etc/apt/sources.list.d/sid.list
|
|
||||||
- apt-get update -q
|
- apt-get update -q
|
||||||
- apt-get install -qy build-essential cmake pkg-config
|
- apt-get install -qy build-essential cmake
|
||||||
- apt-get install -qy -t stretch-backports clang-5.0
|
- apt-get install -qy -t stretch-backports clang-5.0
|
||||||
- apt-get install -qy libcurl4-openssl-dev libjsoncpp-dev doxygen catch
|
- apt-get install -qy libpoco-dev libjsoncpp-dev doxygen catch
|
||||||
- apt-get install -qy -t sid libcurlpp-dev
|
|
||||||
- rm -rf build && mkdir -p build && cd build
|
- rm -rf build && mkdir -p build && cd build
|
||||||
- cmake -DWITH_EXAMPLES=YES -DWITH_TESTS=YES -DEXTRA_TEST_ARGS="~[api]" ..
|
- cmake -DWITH_EXAMPLES=YES ..
|
||||||
- make VERBOSE=1
|
- make VERBOSE=1
|
||||||
- make install DESTDIR=install
|
- make install DESTDIR=install
|
||||||
- ctest
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: debian-package-cache
|
- name: debian-package-cache
|
||||||
path: /var/cache/apt/archives
|
path: /var/cache/apt/archives
|
||||||
|
|
||||||
- name: clang6
|
- name: clang7
|
||||||
image: debian:stretch-slim
|
image: debian:buster-slim
|
||||||
pull: true
|
pull: true
|
||||||
environment:
|
environment:
|
||||||
LANG: C.utf8
|
LANG: C.utf8
|
||||||
CXX: clang++-6.0
|
CXX: clang++
|
||||||
CXXFLAGS: -pipe -O2
|
CXXFLAGS: -pipe -O2
|
||||||
MASTODON_CPP_ACCESS_TOKEN:
|
MASTODON_CPP_ACCESS_TOKEN:
|
||||||
from_secret: mastodon_cpp_access_token
|
from_secret: mastodon_cpp_access_token
|
||||||
commands:
|
commands:
|
||||||
- rm /etc/apt/apt.conf.d/docker-clean
|
- rm -f /etc/apt/apt.conf.d/docker-clean
|
||||||
- rm /var/cache/apt/archives/lock
|
- rm -f /var/cache/apt/archives/lock
|
||||||
- apt-get update -q
|
- apt-get update -q
|
||||||
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
|
|
||||||
- echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list.d/stretch.list
|
|
||||||
- echo "deb http://deb.debian.org/debian sid main" >> /etc/apt/sources.list.d/sid.list
|
|
||||||
- apt-get update -q
|
- apt-get update -q
|
||||||
- apt-get install -qy build-essential cmake pkg-config
|
- apt-get install -qy build-essential cmake clang
|
||||||
- apt-get install -qy -t stretch-backports clang-6.0
|
- apt-get install -qy libpoco-dev libjsoncpp-dev doxygen catch
|
||||||
- apt-get install -qy libcurl4-openssl-dev libjsoncpp-dev doxygen catch
|
|
||||||
- apt-get install -qy -t sid libcurlpp-dev
|
|
||||||
- rm -rf build && mkdir -p build && cd build
|
- rm -rf build && mkdir -p build && cd build
|
||||||
- cmake -DWITH_EXAMPLES=YES -DWITH_TESTS=YES -DEXTRA_TEST_ARGS="~[api]" ..
|
- cmake -DWITH_EXAMPLES=YES ..
|
||||||
- make VERBOSE=1
|
- make VERBOSE=1
|
||||||
- make install DESTDIR=install
|
- make install DESTDIR=install
|
||||||
- ctest
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: debian-package-cache
|
- name: debian-package-cache
|
||||||
path: /var/cache/apt/archives
|
path: /var/cache/apt/archives
|
||||||
|
@ -168,38 +153,73 @@ trigger:
|
||||||
- tag
|
- tag
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: deb
|
- name: Debian stretch
|
||||||
image: debian:stretch-slim
|
image: debian:stretch-slim
|
||||||
pull: always
|
pull: always
|
||||||
environment:
|
environment:
|
||||||
CXXFLAGS: -pipe -O2
|
CXXFLAGS: -pipe -O2
|
||||||
|
LANG: C.utf8
|
||||||
commands:
|
commands:
|
||||||
- rm /etc/apt/apt.conf.d/docker-clean
|
- rm -f /etc/apt/apt.conf.d/docker-clean
|
||||||
- rm /var/cache/apt/archives/lock
|
- rm -f /var/cache/apt/archives/lock
|
||||||
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
|
|
||||||
- echo "deb http://deb.debian.org/debian sid main" >> /etc/apt/sources.list.d/sid.list
|
|
||||||
- apt-get update -q
|
- apt-get update -q
|
||||||
- apt-get install -qy build-essential cmake pkg-config
|
- apt-get install -qy build-essential cmake lsb-release
|
||||||
- apt-get install -qy libcurl4-openssl-dev libjsoncpp-dev doxygen
|
- apt-get install -qy libpoco-dev libjsoncpp-dev file
|
||||||
- apt-get install -qy -t sid libcurlpp-dev
|
|
||||||
- apt-get install -qy file
|
|
||||||
- rm -rf build && mkdir -p build && cd build
|
- rm -rf build && mkdir -p build && cd build
|
||||||
- cmake -DWITH_EXAMPLES=NO -DWITH_TESTS=NO ..
|
- cmake -DWITH_DEB=YES -DWITH_DOC=NO ..
|
||||||
- make package
|
- make package
|
||||||
- cmake -DWITH_DEB=YES ..
|
- cp -v libmastodon-cpp_${DRONE_TAG}-0_stretch_amd64.deb ..
|
||||||
- make package
|
|
||||||
- cp -v mastodon-cpp-${DRONE_TAG}_x86_64.tar.gz ..
|
|
||||||
- cp -v libmastodon-cpp_${DRONE_TAG}-0_amd64.deb ..
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: debian-package-cache
|
- name: debian-package-cache
|
||||||
path: /var/cache/apt/archives
|
path: /var/cache/apt/archives
|
||||||
|
|
||||||
- name: rpm
|
- name: Debian buster
|
||||||
|
image: debian:buster-slim
|
||||||
|
pull: always
|
||||||
|
environment:
|
||||||
|
CXXFLAGS: -pipe -O2
|
||||||
|
LANG: C.utf8
|
||||||
|
commands:
|
||||||
|
- rm -f /etc/apt/apt.conf.d/docker-clean
|
||||||
|
- rm -f /var/cache/apt/archives/lock
|
||||||
|
- apt-get update -q
|
||||||
|
- apt-get install -qy build-essential cmake lsb-release
|
||||||
|
- apt-get install -qy libpoco-dev libjsoncpp-dev file
|
||||||
|
- rm -rf build && mkdir -p build && cd build
|
||||||
|
- cmake -DWITH_DEB=YES -DWITH_DOC=NO ..
|
||||||
|
- make package
|
||||||
|
- cp -v libmastodon-cpp_${DRONE_TAG}-0_buster_amd64.deb ..
|
||||||
|
volumes:
|
||||||
|
- name: debian-package-cache
|
||||||
|
path: /var/cache/apt/archives
|
||||||
|
|
||||||
|
- name: Ubuntu bionic
|
||||||
|
image: ubuntu:bionic
|
||||||
|
pull: always
|
||||||
|
environment:
|
||||||
|
CXXFLAGS: -pipe -O2
|
||||||
|
LANG: C.utf8
|
||||||
|
commands:
|
||||||
|
- rm -f /etc/apt/apt.conf.d/docker-clean
|
||||||
|
- rm -f /var/cache/apt/archives/lock
|
||||||
|
- apt-get update -q
|
||||||
|
- apt-get install -qy build-essential cmake lsb-release
|
||||||
|
- apt-get install -qy libpoco-dev libjsoncpp-dev file
|
||||||
|
- rm -rf build && mkdir -p build && cd build
|
||||||
|
- cmake -DWITH_DEB=YES -DWITH_DOC=NO ..
|
||||||
|
- make package
|
||||||
|
- cp -v libmastodon-cpp_${DRONE_TAG}-0_bionic_amd64.deb ..
|
||||||
|
volumes:
|
||||||
|
- name: debian-package-cache
|
||||||
|
path: /var/cache/apt/archives
|
||||||
|
|
||||||
|
- name: CentOS 7
|
||||||
image: centos:7
|
image: centos:7
|
||||||
pull: always
|
pull: always
|
||||||
environment:
|
environment:
|
||||||
CXX: /opt/rh/devtoolset-6/root/usr/bin/g++
|
CXX: /opt/rh/devtoolset-6/root/usr/bin/g++
|
||||||
CXXFLAGS: -pipe -O2
|
CXXFLAGS: -pipe -O2
|
||||||
|
LANG: C.utf8
|
||||||
commands:
|
commands:
|
||||||
- sed -i 's/keepcache=0/keepcache=1/' /etc/yum.conf
|
- sed -i 's/keepcache=0/keepcache=1/' /etc/yum.conf
|
||||||
- curl -s -o /var/cache/yum/epel-release-latest-7.noarch.rpm http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
|
- curl -s -o /var/cache/yum/epel-release-latest-7.noarch.rpm http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
|
||||||
|
@ -207,15 +227,10 @@ steps:
|
||||||
- yum install -qy centos-release-scl
|
- yum install -qy centos-release-scl
|
||||||
- yum install -qy devtoolset-6
|
- yum install -qy devtoolset-6
|
||||||
- scl enable devtoolset-6 bash
|
- scl enable devtoolset-6 bash
|
||||||
- yum install -qy libcurl-devel doxygen rpm-build
|
- yum install -qy poco-devel openssl-devel doxygen rpm-build
|
||||||
- yum --enablerepo=epel install -qy cmake3 jsoncpp-devel
|
- yum --enablerepo=epel install -qy cmake3 jsoncpp-devel
|
||||||
- curl -s -o /var/cache/yum/curlpp-devel-0.7.3-5.el6.x86_64.rpm https://download.fedoraproject.org/pub/epel/6/x86_64/Packages/c/curlpp-devel-0.7.3-5.el6.x86_64.rpm
|
|
||||||
- curl -s -o /var/cache/yum/curlpp-0.7.3-5.el6.x86_64.rpm https://download.fedoraproject.org/pub/epel/6/x86_64/Packages/c/curlpp-0.7.3-5.el6.x86_64.rpm
|
|
||||||
- yum localinstall -qy /var/cache/yum/curlpp-*
|
|
||||||
- rm -rf build && mkdir -p build && cd build
|
- rm -rf build && mkdir -p build && cd build
|
||||||
- cmake3 -DWITH_EXAMPLES=NO -DWITH_TESTS=NO ..
|
- cmake3 -DWITH_RPM=YES -DWITH_DOC=NO ..
|
||||||
- make package
|
|
||||||
- cmake3 -DWITH_RPM=YES ..
|
|
||||||
- make package
|
- make package
|
||||||
- cp -v libmastodon-cpp-${DRONE_TAG}-0.x86_64.rpm ..
|
- cp -v libmastodon-cpp-${DRONE_TAG}-0.x86_64.rpm ..
|
||||||
volumes:
|
volumes:
|
||||||
|
@ -232,8 +247,9 @@ steps:
|
||||||
title: ${DRONE_TAG}
|
title: ${DRONE_TAG}
|
||||||
prerelease: true
|
prerelease: true
|
||||||
files:
|
files:
|
||||||
- mastodon-cpp-${DRONE_TAG}_x86_64.tar.gz
|
- libmastodon-cpp_${DRONE_TAG}-0_stretch_amd64.deb
|
||||||
- libmastodon-cpp_${DRONE_TAG}-0_amd64.deb
|
- libmastodon-cpp_${DRONE_TAG}-0_buster_amd64.deb
|
||||||
|
- libmastodon-cpp_${DRONE_TAG}-0_bionic_amd64.deb
|
||||||
- libmastodon-cpp-${DRONE_TAG}-0.x86_64.rpm
|
- libmastodon-cpp-${DRONE_TAG}-0.x86_64.rpm
|
||||||
checksum:
|
checksum:
|
||||||
- sha256
|
- sha256
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Configuration file for EditorConfig.
|
||||||
|
# More information is available under <https://editorconfig.org/>.
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
max_line_length = 80
|
||||||
|
|
||||||
|
[*.?pp]
|
||||||
|
indent_size = 4
|
||||||
|
tab_width = 4
|
||||||
|
|
||||||
|
[{CMakeLists.txt,*.cmake}]
|
||||||
|
indent_size = 2
|
||||||
|
tab_width = 2
|
150
CMakeLists.txt
150
CMakeLists.txt
|
@ -1,124 +1,86 @@
|
||||||
cmake_minimum_required (VERSION 3.6)
|
# Support version 3.6 and above, but use policy settings up to 3.14.
|
||||||
project (mastodon-cpp
|
# 3.6 is needed because of IMPORTED_TARGET in pkg_check_modules().
|
||||||
VERSION 0.106.0
|
cmake_minimum_required(VERSION 3.6...3.14)
|
||||||
LANGUAGES CXX
|
# Ranges are supported from 3.12, set policy to current for < 3.12.
|
||||||
)
|
if(${CMAKE_VERSION} VERSION_LESS 3.12)
|
||||||
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||||
set(WITH_EASY "YES" CACHE STRING "WITH_EASY defaults to \"YES\"")
|
endif()
|
||||||
set(WITH_EXAMPLES "NO" CACHE STRING "WITH_EXAMPLES defaults to \"NO\"")
|
|
||||||
set(WITH_TESTS "NO" CACHE STRING "WITH_TESTS defaults to \"NO\"")
|
|
||||||
set(WITH_DOC "YES" CACHE STRING "WITH_DOC defaults to \"YES\"")
|
|
||||||
set(WITH_DEB "NO" CACHE STRING "WITH_DEB defaults to \"NO\"")
|
|
||||||
set(WITH_RPM "NO" CACHE STRING "WITH_RPM defaults to \"NO\"")
|
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
find_package(PkgConfig REQUIRED)
|
|
||||||
find_package(PkgConfig REQUIRED)
|
project (mastodon-cpp
|
||||||
pkg_check_modules(CURLPP REQUIRED curlpp)
|
VERSION 0.111.5
|
||||||
if(WITH_EASY)
|
LANGUAGES CXX)
|
||||||
pkg_check_modules(JSONCPP REQUIRED jsoncpp)
|
|
||||||
|
# DESCRIPTION was introduced in version 3.9.
|
||||||
|
if(NOT (${CMAKE_VERSION} VERSION_LESS 3.9))
|
||||||
|
set(PROJECT_DESCRIPTION
|
||||||
|
"C++ wrapper for the Mastodon API.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
option(WITH_EASY "Compile Easy interface." YES)
|
||||||
|
option(WITH_EXAMPLES "Compile examples." NO)
|
||||||
|
option(WITH_TESTS "Compile tests." NO)
|
||||||
|
option(WITH_DOC "Generate HTML documentation." YES)
|
||||||
|
option(WITH_DEB "Prepare for the building of .deb packages." NO)
|
||||||
|
option(WITH_RPM "Prepare for the building of .rpm packages." NO)
|
||||||
|
option(BUILD_SHARED_LIBS "Build shared libraries." YES)
|
||||||
|
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type, Release or Debug.")
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG
|
set(DEBUG_CXXFLAGS
|
||||||
"${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Wpedantic -ftrapv -fsanitize=undefined -g -Og -fno-omit-frame-pointer")
|
"-Wall"
|
||||||
|
"-Wextra"
|
||||||
# Do not complain about compatibility-wrapper
|
"-Wpedantic"
|
||||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
"-ftrapv"
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
|
"-fsanitize=undefined"
|
||||||
|
"-g"
|
||||||
|
"-Og"
|
||||||
|
"-fno-omit-frame-pointer"
|
||||||
|
"-Wno-deprecated-declarations")
|
||||||
|
set(DEBUG_LDFLAGS
|
||||||
|
"-fsanitize=undefined")
|
||||||
|
add_compile_options("$<$<CONFIG:Debug>:${DEBUG_CXXFLAGS}>")
|
||||||
|
# add_link_options was introduced in version 3.13.
|
||||||
|
if(${CMAKE_VERSION} VERSION_LESS 3.13)
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${DEBUG_LDFLAGS}")
|
||||||
|
else()
|
||||||
|
add_link_options("$<$<CONFIG:Debug>:${DEBUG_LDFLAGS}>")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/src)
|
# Turn on debug output.
|
||||||
include_directories(${PROJECT_BINARY_DIR})
|
|
||||||
|
|
||||||
include_directories(${CURL_INCLUDE_DIRS})
|
|
||||||
include_directories(${CURLPP_INCLUDE_DIRS})
|
|
||||||
include_directories(${JSONCPP_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
link_directories(${CURL_LIBRARY_DIRS})
|
|
||||||
link_directories(${CURLPP_LIBRARY_DIRS})
|
|
||||||
link_directories(${JSONCPP_LIBRARY_DIRS})
|
|
||||||
|
|
||||||
# Write version in header
|
|
||||||
configure_file (
|
|
||||||
"${PROJECT_SOURCE_DIR}/src/version.hpp.in"
|
|
||||||
"${PROJECT_BINARY_DIR}/version.hpp"
|
|
||||||
)
|
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
add_definitions(-DDEBUG=1)
|
add_definitions("-DDEBUG=1")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT WITH_EASY)
|
if(NOT WITH_EASY)
|
||||||
add_definitions(-DWITHOUT_EASY=1)
|
add_definitions("-DWITHOUT_EASY=1")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Compile library
|
add_subdirectory("src")
|
||||||
if(WITH_EASY)
|
|
||||||
file(GLOB sources src/*.cpp src/api/*.cpp
|
|
||||||
src/easy/*.cpp src/easy/entities/*.cpp)
|
|
||||||
else()
|
|
||||||
file(GLOB sources src/*.cpp src/api/*.cpp)
|
|
||||||
endif()
|
|
||||||
add_library(${PROJECT_NAME} SHARED ${sources})
|
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
|
||||||
VERSION ${PROJECT_VERSION}
|
|
||||||
SOVERSION ${${PROJECT_NAME}_VERSION_MAJOR}
|
|
||||||
)
|
|
||||||
|
|
||||||
if(WITH_EASY)
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
|
||||||
${CURLPP_LIBRARIES} pthread ${JSONCPP_LIBRARIES})
|
|
||||||
else()
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
|
||||||
${CURLPP_LIBRARIES} pthread)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Compile examples
|
|
||||||
if(WITH_EXAMPLES)
|
if(WITH_EXAMPLES)
|
||||||
file(GLOB sources_examples examples/*.cpp)
|
add_subdirectory("examples")
|
||||||
foreach(src ${sources_examples})
|
|
||||||
get_filename_component(bin ${src} NAME_WE)
|
|
||||||
add_executable(${bin} ${src})
|
|
||||||
target_link_libraries(${bin} pthread ${JSONCPP_LIBRARIES} ${PROJECT_NAME})
|
|
||||||
endforeach()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Compile tests
|
|
||||||
if(WITH_TESTS)
|
if(WITH_TESTS)
|
||||||
configure_file("tests/test.gif" "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY)
|
add_subdirectory("tests")
|
||||||
add_subdirectory(tests)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Install library and header files
|
|
||||||
install(TARGETS ${PROJECT_NAME} LIBRARY
|
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
||||||
install(FILES src/mastodon-cpp.hpp src/return_types.hpp src/types.hpp
|
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
|
|
||||||
if(WITH_EASY)
|
|
||||||
file(GLOB easy_header src/easy/*.hpp)
|
|
||||||
install(FILES ${easy_header}
|
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/easy)
|
|
||||||
file(GLOB easy_entities_header src/easy/entities/*.hpp)
|
|
||||||
install(FILES ${easy_entities_header}
|
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/easy/entities)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Compile & install documentation
|
|
||||||
if(WITH_DOC)
|
if(WITH_DOC)
|
||||||
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/doc/html
|
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/doc/html
|
||||||
COMMAND ./build_doc.sh WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
COMMAND "./build_doc.sh" WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
||||||
add_custom_target(doc DEPENDS doc/html)
|
add_custom_target(doc DEPENDS doc/html)
|
||||||
add_dependencies(${PROJECT_NAME} doc)
|
add_dependencies(${PROJECT_NAME} doc)
|
||||||
|
|
||||||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/doc/html
|
install(DIRECTORY ${PROJECT_SOURCE_DIR}/doc/html
|
||||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}-${PROJECT_VERSION})
|
DESTINATION "${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME}")
|
||||||
file(GLOB examples examples/example*.cpp)
|
|
||||||
install(FILES ${examples}
|
|
||||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}-${PROJECT_VERSION}/examples)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Packages
|
add_subdirectory("cmake")
|
||||||
include(packages.CMakeLists.txt)
|
add_subdirectory("pkg-config")
|
||||||
|
|
||||||
|
include("cmake/packages.cmake")
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
:contact-coc: tastytea@tastytea.de
|
||||||
|
|
||||||
|
== Code of Conduct
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as
|
||||||
|
contributors and maintainers pledge to making participation in our project and
|
||||||
|
our community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, disability, education, ethnicity, gender identity and expression, level of
|
||||||
|
experience, nationality, personal appearance, race, religion, sex
|
||||||
|
characteristics, sexual identity and orientation or socio-economic status.
|
||||||
|
|
||||||
|
=== Examples
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment
|
||||||
|
include:
|
||||||
|
|
||||||
|
* Using welcoming and inclusive language.
|
||||||
|
* Being respectful of differing viewpoints and experiences.
|
||||||
|
* Gracefully accepting constructive criticism.
|
||||||
|
* Focusing on what is best for the community.
|
||||||
|
* Showing empathy towards other community members.
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||||
|
advances.
|
||||||
|
* Trolling, insulting/derogatory comments, and personal attacks.
|
||||||
|
* Public or private harassment.
|
||||||
|
* Publishing others’ private information, such as a physical or electronic
|
||||||
|
address, without explicit permission.
|
||||||
|
|
||||||
|
=== Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported by contacting the project team at {contact-coc}.
|
||||||
|
|
||||||
|
All complaints will be reviewed and investigated and will result in a response
|
||||||
|
that is deemed necessary and appropriate to the circumstances. The project team
|
||||||
|
is obligated to maintain confidentiality with regard to the reporter of an
|
||||||
|
incident.
|
||||||
|
|
||||||
|
=== Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the Contributor Covenant, version 1.4,
|
||||||
|
available at
|
||||||
|
https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see
|
||||||
|
https://www.contributor-covenant.org/faq
|
|
@ -0,0 +1,29 @@
|
||||||
|
:project: mastodon-cpp
|
||||||
|
:uri-base: https://schlomp.space/tastytea/{project}
|
||||||
|
:uri-coc: {uri-base}/src/branch/master/CODE_OF_CONDUCT.adoc
|
||||||
|
:contact-email: tastytea@tastytea.de
|
||||||
|
:contact-xmpp: {contact-email}
|
||||||
|
:contact-fediverse: https://likeable.space/users/tastytea
|
||||||
|
|
||||||
|
== How to contribute
|
||||||
|
|
||||||
|
Read the link:{uri-coc}[Code of Conduct].
|
||||||
|
|
||||||
|
=== Reporting bugs or suggesting enhancements
|
||||||
|
|
||||||
|
Before reporting a bug, please
|
||||||
|
https://schlomp.space/tastytea/{project}/issues[perform a search] to see if the
|
||||||
|
problem has already been reported. If it has, add a comment to the existing
|
||||||
|
issue instead of opening a new one. Same for enhancements.
|
||||||
|
|
||||||
|
You can also contact me via mailto:{contact-email}[E-Mail],
|
||||||
|
link:xmpp:{contact-xmpp}[XMPP] or the {contact-fediverse}[Fediverse] if you
|
||||||
|
don't want to open an account.
|
||||||
|
|
||||||
|
=== Pull requests
|
||||||
|
|
||||||
|
Please use similar coding conventions as the rest of the project. The basic rule
|
||||||
|
to remember is to write code in the same style as the existing/surrounding code.
|
||||||
|
|
||||||
|
You can also send me your patches via mailto:{contact-email}[E-Mail], ideally
|
||||||
|
using `git format-patch` or `git send-email`.
|
|
@ -1,16 +0,0 @@
|
||||||
# How to contribute
|
|
||||||
|
|
||||||
## Reporting bugs or suggesting enhancements
|
|
||||||
|
|
||||||
Before reporting a bug , please
|
|
||||||
[perform a search](https://schlomp.space/tastytea/mastodon-cpp/issues)
|
|
||||||
to see if the problem has already been reported. If it has, add a comment to the
|
|
||||||
existing issue instead of opening a new one. Same for enhancements.
|
|
||||||
|
|
||||||
You can also contact me via the Fediverse if you don't want to open an account.
|
|
||||||
My account is [@tastytea@likeable.space](https://likeable.space/users/tastytea).
|
|
||||||
|
|
||||||
## Pull requests
|
|
||||||
|
|
||||||
Please use similar coding conventions as the rest of the project. The basic rule
|
|
||||||
to remember is to write code in the same style as the existing/surrounding code.
|
|
147
LICENSE
147
LICENSE
|
@ -1,23 +1,21 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
Version 3, 29 June 2007
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
Preamble
|
Preamble
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
software and other kinds of works.
|
software and other kinds of works, specifically designed to ensure
|
||||||
|
cooperation with the community in the case of network server software.
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
The licenses for most software and other practical works are designed
|
||||||
to take away your freedom to share and change the works. By contrast,
|
to take away your freedom to share and change the works. By contrast,
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
our General Public Licenses are intended to guarantee your freedom to
|
||||||
share and change all versions of a program--to make sure it remains free
|
share and change all versions of a program--to make sure it remains free
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
software for all its users.
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
When we speak of free software, we are referring to freedom, not
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
@ -26,44 +24,34 @@ them if you wish), that you receive source code or can get it if you
|
||||||
want it, that you can change the software or use pieces of it in new
|
want it, that you can change the software or use pieces of it in new
|
||||||
free programs, and that you know you can do these things.
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
Developers that use our General Public Licenses protect your rights
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
with two steps: (1) assert copyright on the software, and (2) offer
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
you this License which gives you legal permission to copy, distribute
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
and/or modify the software.
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
A secondary benefit of defending all users' freedom is that
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
improvements made in alternate versions of the program, if they
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
receive widespread use, become available for other developers to
|
||||||
or can get the source code. And you must show them these terms so they
|
incorporate. Many developers of free software are heartened and
|
||||||
know their rights.
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public.
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
The GNU Affero General Public License is designed specifically to
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
ensure that, in such cases, the modified source code becomes available
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the modified version running there to the
|
||||||
|
users of that server. Therefore, public use of a modified version, on
|
||||||
|
a publicly accessible server, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
An older license, called the Affero General Public License and
|
||||||
that there is no warranty for this free software. For both users' and
|
published by Affero, was designed to accomplish similar goals. This is
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
a different license, not a version of the Affero GPL, but Affero has
|
||||||
changed, so that their problems will not be attributed erroneously to
|
released a new version of the Affero GPL which permits relicensing under
|
||||||
authors of previous versions.
|
this license.
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
The precise terms and conditions for copying, distribution and
|
||||||
modification follow.
|
modification follow.
|
||||||
|
@ -72,7 +60,7 @@ modification follow.
|
||||||
|
|
||||||
0. Definitions.
|
0. Definitions.
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
works, such as semiconductor masks.
|
works, such as semiconductor masks.
|
||||||
|
@ -549,35 +537,45 @@ to collect a royalty for further conveying from those to whom you convey
|
||||||
the Program, the only way you could satisfy both those terms and this
|
the Program, the only way you could satisfy both those terms and this
|
||||||
License would be to refrain entirely from conveying the Program.
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
|
Program, your modified version must prominently offer all users
|
||||||
|
interacting with it remotely through a computer network (if your version
|
||||||
|
supports such interaction) an opportunity to receive the Corresponding
|
||||||
|
Source of your version by providing access to the Corresponding Source
|
||||||
|
from a network server at no charge, through some standard or customary
|
||||||
|
means of facilitating copying of software. This Corresponding Source
|
||||||
|
shall include the Corresponding Source for any work covered by version 3
|
||||||
|
of the GNU General Public License that is incorporated pursuant to the
|
||||||
|
following paragraph.
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
Notwithstanding any other provision of this License, you have
|
||||||
permission to link or combine any covered work with a work licensed
|
permission to link or combine any covered work with a work licensed
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
under version 3 of the GNU General Public License into a single
|
||||||
combined work, and to convey the resulting work. The terms of this
|
combined work, and to convey the resulting work. The terms of this
|
||||||
License will continue to apply to the part which is the covered work,
|
License will continue to apply to the part which is the covered work,
|
||||||
but the special requirements of the GNU Affero General Public License,
|
but the work with which it is combined will remain governed by version
|
||||||
section 13, concerning interaction through a network will apply to the
|
3 of the GNU General Public License.
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
the GNU General Public License from time to time. Such new versions will
|
the GNU Affero General Public License from time to time. Such new versions
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
will be similar in spirit to the present version, but may differ in detail to
|
||||||
address new problems or concerns.
|
address new problems or concerns.
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
Each version is given a distinguishing version number. If the
|
||||||
Program specifies that a certain numbered version of the GNU General
|
Program specifies that a certain numbered version of the GNU Affero General
|
||||||
Public License "or any later version" applies to it, you have the
|
Public License "or any later version" applies to it, you have the
|
||||||
option of following the terms and conditions either of that numbered
|
option of following the terms and conditions either of that numbered
|
||||||
version or of any later version published by the Free Software
|
version or of any later version published by the Free Software
|
||||||
Foundation. If the Program does not specify a version number of the
|
Foundation. If the Program does not specify a version number of the
|
||||||
GNU General Public License, you may choose any version ever published
|
GNU Affero General Public License, you may choose any version ever published
|
||||||
by the Free Software Foundation.
|
by the Free Software Foundation.
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
If the Program specifies that a proxy can decide which future
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
versions of the GNU Affero General Public License can be used, that proxy's
|
||||||
public statement of acceptance of a version permanently authorizes you
|
public statement of acceptance of a version permanently authorizes you
|
||||||
to choose that version for the Program.
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
@ -635,40 +633,29 @@ the "copyright" line and a pointer to where the full notice is found.
|
||||||
Copyright (C) <year> <name of author>
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
If your software can interact with users remotely through a computer
|
||||||
notice like this when it starts in an interactive mode:
|
network, you should also make sure that it provides a way for users to
|
||||||
|
get its source. For example, if your program is a web application, its
|
||||||
<program> Copyright (C) <year> <name of author>
|
interface could display a "Source" link that leads users to an archive
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
of the code. There are many ways you could offer source, and different
|
||||||
This is free software, and you are welcome to redistribute it
|
solutions will be better for different programs; see section 13 for the
|
||||||
under certain conditions; type `show c' for details.
|
specific requirements.
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, your program's commands
|
|
||||||
might be different; for a GUI interface, you would use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||||
<http://www.gnu.org/licenses/>.
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
|
||||||
may consider it more useful to permit linking proprietary applications with
|
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License. But first, please read
|
|
||||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
||||||
|
|
97
README.adoc
97
README.adoc
|
@ -1,17 +1,27 @@
|
||||||
= mastodon-cpp
|
= mastodon-cpp
|
||||||
:toc: preamble
|
:toc: preamble
|
||||||
|
:project: mastodon-cpp
|
||||||
|
:uri-base: https://schlomp.space/tastytea/{project}
|
||||||
|
:uri-branch-main: {uri-base}/src/branch/master
|
||||||
|
:uri-mastodonpp: https://schlomp.space/tastytea/mastodonpp
|
||||||
|
|
||||||
*mastodon-cpp* is a C++ wrapper for the Mastodon API. You submit an API call
|
[IMPORTANT]
|
||||||
and get the raw JSON or easy to use abstractions.
|
This project has become too complicated to maintain by myself and I can't find
|
||||||
|
the energy to add features. **You can find a complete rewrite, with cleaner and
|
||||||
|
much easier to understand code at link:{uri-mastodonpp}[mastodonpp].** I
|
||||||
|
recommend switching to it. You can still report bugs here and I will respond,
|
||||||
|
but I won't put too much work in it. If you want to take over maintainership,
|
||||||
|
get in touch.
|
||||||
|
|
||||||
|
*{project}* is a C++ wrapper for the Mastodon API. You submit an API call
|
||||||
|
and get the raw JSON that you can then transform into easy to use abstractions.
|
||||||
|
|
||||||
== Usage
|
== Usage
|
||||||
|
|
||||||
The HTML reference can be generated with `build_doc.sh`, if doxygen is
|
The HTML reference can be generated with `build_doc.sh`, if doxygen is
|
||||||
installed. It is also available at
|
installed. It is also available at
|
||||||
https://doc.schlomp.space/mastodon-cpp/annotated.html[doc.schlomp.space/mastodon-cpp/].
|
https://doc.schlomp.space/{project}/annotated.html[doc.schlomp.space/{project}/].
|
||||||
There are more
|
There are more {uri-branch-main}/examples[examples] in `examples/`.
|
||||||
https://schlomp.space/tastytea/mastodon-cpp/src/branch/master/examples[examples]
|
|
||||||
in `examples/`.
|
|
||||||
|
|
||||||
=== Examples
|
=== Examples
|
||||||
|
|
||||||
|
@ -76,10 +86,6 @@ Not included in this list are entities.
|
||||||
==== Return types
|
==== Return types
|
||||||
|
|
||||||
* `Mastodon::return_call`: Contains the response from `Mastodon::API` calls.
|
* `Mastodon::return_call`: Contains the response from `Mastodon::API` calls.
|
||||||
* `Mastodon::Easy::return_entity`: Contains the response from high-level
|
|
||||||
functions that return a single `Mastodon::Easy::Entity`.
|
|
||||||
* `Mastodon::Easy::return_entities_vector`: Contains the response from
|
|
||||||
high-level functions that return multiple `Mastodon::Easy::Entity`.
|
|
||||||
|
|
||||||
==== Other types
|
==== Other types
|
||||||
|
|
||||||
|
@ -97,7 +103,12 @@ Not included in this list are entities.
|
||||||
* `Mastodon::Easy::alert_type`, used for push subscriptions.
|
* `Mastodon::Easy::alert_type`, used for push subscriptions.
|
||||||
* `Mastodon::Easy::time_type`: Type for time, can be converted to `time_point`
|
* `Mastodon::Easy::time_type`: Type for time, can be converted to `time_point`
|
||||||
and `string`.
|
and `string`.
|
||||||
* `Mastodon::Easy::Account::account_field_type`: Type for fields in accounts.
|
* `Mastodon::Easy::account_field_type`: Type for fields in accounts.
|
||||||
|
* `Mastodon::Easy::urls_type`: Type for URLs returned by `Instance::urls()`.
|
||||||
|
* `Mastodon::Easy::stats_type`: Type for statistics returned by
|
||||||
|
`Instance::stats()`.
|
||||||
|
* `Mastodon::Easy::poll_options_type`: Type for poll options returned by
|
||||||
|
`Poll::options()`.
|
||||||
|
|
||||||
=== Error codes
|
=== Error codes
|
||||||
|
|
||||||
|
@ -105,14 +116,13 @@ Not included in this list are entities.
|
||||||
|===================================================
|
|===================================================
|
||||||
| Code | Explanation
|
| Code | Explanation
|
||||||
| 0 | No error
|
| 0 | No error
|
||||||
| 22 | Invalid argument
|
| 1 | Invalid argument
|
||||||
| 78 | URL changed (HTTP 301 or 308)
|
| 10 | URL changed (HTTP 301 or 308)
|
||||||
| 110 | Connection timed out
|
| 11 | Connection timed out
|
||||||
| 111 | Connection refused (check http_error_code)
|
| 12 | Connection refused (check http_error_code)
|
||||||
| 113 | No route to host / Could not resolve host
|
| 13 | No route to host / Could not resolve host
|
||||||
| 192 | curlpp runtime error
|
| 14 | Encryption error
|
||||||
| 193 | curlpp logic error
|
| 127 | Unknown error
|
||||||
| 255 | Unknown error
|
|
||||||
|===================================================
|
|===================================================
|
||||||
|
|
||||||
If you use a debug build, you get more verbose error messages.
|
If you use a debug build, you get more verbose error messages.
|
||||||
|
@ -128,14 +138,11 @@ If you use a debug build, you get more verbose error messages.
|
||||||
=== Upgrading from versions below 0.100.0
|
=== Upgrading from versions below 0.100.0
|
||||||
|
|
||||||
Starting with version `0.100.0`, large parts of the library have been rewritten.
|
Starting with version `0.100.0`, large parts of the library have been rewritten.
|
||||||
Upgrading from previous versions will require extensive code changes. You can
|
Upgrading from previous versions will require extensive code changes.
|
||||||
keep using the old version, it is archived in the branch
|
|
||||||
https://schlomp.space/tastytea/mastodon-cpp/src/branch/pre-0.100.0[pre-0.100.0].
|
|
||||||
It will receive bug-fixes for a while but no new features.
|
|
||||||
|
|
||||||
=== Packages
|
=== Packages
|
||||||
|
|
||||||
Every https://schlomp.space/tastytea/mastodon-cpp/releases[release] includes
|
Every https://schlomp.space/tastytea/{project}/releases[release] includes
|
||||||
packages for Debian and Centos. Gentoo packages are available in my overlay.
|
packages for Debian and Centos. Gentoo packages are available in my overlay.
|
||||||
|
|
||||||
==== Gentoo
|
==== Gentoo
|
||||||
|
@ -157,23 +164,15 @@ Prebuilt DEB and RPM packages for x86_64(amd64) are provided with each release.
|
||||||
`.deb` packages are built on Debian stretch and `.rpm` packages are built on
|
`.deb` packages are built on Debian stretch and `.rpm` packages are built on
|
||||||
CentOS 7. These packages are automatically built and not tested.
|
CentOS 7. These packages are automatically built and not tested.
|
||||||
|
|
||||||
To use the `.deb` package on Debian stretch, you will need
|
|
||||||
https://packages.debian.org/libcurlpp0[libcurlpp0] from sid.
|
|
||||||
|
|
||||||
To use the `.rpm` package on CentOS 7, you will need
|
|
||||||
https://download.fedoraproject.org/pub/epel/6/x86_64/Packages/c/[curlpp]
|
|
||||||
from EPEL 6.
|
|
||||||
|
|
||||||
=== From source
|
=== From source
|
||||||
|
|
||||||
==== Dependencies
|
==== Dependencies
|
||||||
|
|
||||||
* Tested OS: Linux
|
* Tested OS: Linux
|
||||||
* C++ compiler (tested: https://gcc.gnu.org/[gcc] 6/8/9,
|
* C++ compiler (tested: https://gcc.gnu.org/[gcc] 6/8/9,
|
||||||
https://llvm.org/[clang] 5/6)
|
https://llvm.org/[clang] 5/7)
|
||||||
* https://cmake.org/[cmake] (at least: 3.6)
|
* https://cmake.org/[cmake] (at least: 3.6)
|
||||||
* https://pkgconfig.freedesktop.org/wiki/[pkgconfig] (tested: 0.29 / 0.27)
|
* https://pocoproject.org/[POCO] (tested: 1.9 / 1.7)
|
||||||
* http://www.curlpp.org/[curlpp] (tested: 0.8)
|
|
||||||
* Optional
|
* Optional
|
||||||
** Easy interface & Examples:
|
** Easy interface & Examples:
|
||||||
https://github.com/open-source-parsers/jsoncpp[jsoncpp] (tested: 1.8 / 1.7)
|
https://github.com/open-source-parsers/jsoncpp[jsoncpp] (tested: 1.8 / 1.7)
|
||||||
|
@ -186,11 +185,7 @@ from EPEL 6.
|
||||||
====
|
====
|
||||||
[source,shell]
|
[source,shell]
|
||||||
----
|
----
|
||||||
echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
|
apt-get install build-essential cmake libpoco-dev libjsoncpp-dev doxygen
|
||||||
echo "deb http://deb.debian.org/debian sid main" >> /etc/apt/sources.list.d/sid.list
|
|
||||||
apt-get update
|
|
||||||
apt-get install build-essential cmake pkg-config libcurl4-openssl-dev libjsoncpp-dev doxygen file
|
|
||||||
apt-get install -t sid libcurlpp-dev
|
|
||||||
----
|
----
|
||||||
====
|
====
|
||||||
|
|
||||||
|
@ -199,7 +194,7 @@ apt-get install -t sid libcurlpp-dev
|
||||||
===== Release
|
===== Release
|
||||||
|
|
||||||
Download the current release at
|
Download the current release at
|
||||||
https://schlomp.space/tastytea/mastodon-cpp/releases[schlomp.space].
|
https://schlomp.space/tastytea/{project}/releases[schlomp.space].
|
||||||
|
|
||||||
===== Development version
|
===== Development version
|
||||||
|
|
||||||
|
@ -264,6 +259,8 @@ the filter ID with `MASTODON_CPP_FILTER_ID`. You can select the list ID with
|
||||||
* Have at least 1 list with at least one account in it.
|
* Have at least 1 list with at least one account in it.
|
||||||
* have at least 1 account muted.
|
* have at least 1 account muted.
|
||||||
|
|
||||||
|
include::{uri-base}/raw/branch/master/CONTRIBUTING.adoc[]
|
||||||
|
|
||||||
== Status of implementation
|
== Status of implementation
|
||||||
|
|
||||||
You can still use unsupported calls by using `API::get` and the others with
|
You can still use unsupported calls by using `API::get` and the others with
|
||||||
|
@ -351,10 +348,9 @@ strings and you can use unsupported fields in an `Entity` by converting it to
|
||||||
** [x] PUT /api/v1/push/subscription
|
** [x] PUT /api/v1/push/subscription
|
||||||
** [x] DELETE /api/v1/push/subscription
|
** [x] DELETE /api/v1/push/subscription
|
||||||
* Polls
|
* Polls
|
||||||
** [ ] GET /api/v1/polls/:id
|
** [x] GET /api/v1/polls/:id
|
||||||
** [ ] POST /api/v1/polls/:id/votes
|
** [x] POST /api/v1/polls/:id/votes
|
||||||
* Reports
|
* Reports
|
||||||
** [x] GET /api/v1/reports ^(Deprecated)^
|
|
||||||
** [x] POST /api/v1/reports
|
** [x] POST /api/v1/reports
|
||||||
* Scheduled Statuses
|
* Scheduled Statuses
|
||||||
** [ ] GET /api/v1/scheduled_statuses
|
** [ ] GET /api/v1/scheduled_statuses
|
||||||
|
@ -362,7 +358,6 @@ strings and you can use unsupported fields in an `Entity` by converting it to
|
||||||
** [ ] PUT /api/v1/scheduled_statuses/:id
|
** [ ] PUT /api/v1/scheduled_statuses/:id
|
||||||
** [ ] DELETE /api/v1/scheduled_statuses/:id
|
** [ ] DELETE /api/v1/scheduled_statuses/:id
|
||||||
* Search
|
* Search
|
||||||
** [x] GET /api/v1/search ^(Deprecated)^
|
|
||||||
** [x] GET /api/v2/search
|
** [x] GET /api/v2/search
|
||||||
* Statuses
|
* Statuses
|
||||||
** [x] GET /api/v1/statuses/:id
|
** [x] GET /api/v1/statuses/:id
|
||||||
|
@ -378,18 +373,19 @@ strings and you can use unsupported fields in an `Entity` by converting it to
|
||||||
** [x] POST /api/v1/statuses/:id/unpin
|
** [x] POST /api/v1/statuses/:id/unpin
|
||||||
* Timelines
|
* Timelines
|
||||||
** [x] GET /api/v1/timelines/home
|
** [x] GET /api/v1/timelines/home
|
||||||
** [ ] GET /api/v1/conversations
|
** [x] GET /api/v1/conversations
|
||||||
** [x] GET /api/v1/timelines/public
|
** [x] GET /api/v1/timelines/public
|
||||||
** [x] GET /api/v1/timelines/tag/:hashtag
|
** [x] GET /api/v1/timelines/tag/:hashtag
|
||||||
** [x] GET /api/v1/timelines/list/:list_id
|
** [x] GET /api/v1/timelines/list/:list_id
|
||||||
* Streaming API
|
* Streaming API
|
||||||
|
** [x] GET /api/v1/streaming/health
|
||||||
** [x] GET /api/v1/streaming/user
|
** [x] GET /api/v1/streaming/user
|
||||||
** [x] GET /api/v1/streaming/public
|
** [x] GET /api/v1/streaming/public
|
||||||
** [x] GET /api/v1/streaming/public/local
|
** [x] GET /api/v1/streaming/public/local
|
||||||
** [x] GET /api/v1/streaming/hashtag
|
** [x] GET /api/v1/streaming/hashtag
|
||||||
** [ ] GET /api/v1/streaming/hashtag/local
|
** [x] GET /api/v1/streaming/hashtag/local
|
||||||
** [x] GET /api/v1/streaming/list
|
** [x] GET /api/v1/streaming/list
|
||||||
** [ ] GET /api/v1/streaming/direct
|
** [x] GET /api/v1/streaming/direct
|
||||||
|
|
||||||
==== Entities
|
==== Entities
|
||||||
|
|
||||||
|
@ -398,17 +394,16 @@ strings and you can use unsupported fields in an `Entity` by converting it to
|
||||||
* [x] Attachment
|
* [x] Attachment
|
||||||
* [x] Card
|
* [x] Card
|
||||||
* [x] Context
|
* [x] Context
|
||||||
* [ ] Conversation
|
* [x] Conversation
|
||||||
* [x] Emoji
|
* [x] Emoji
|
||||||
* [x] Filter
|
* [x] Filter
|
||||||
* [x] Instance
|
* [x] Instance
|
||||||
* [x] List
|
* [x] List
|
||||||
* [x] Mention
|
* [x] Mention
|
||||||
* [x] Notification
|
* [x] Notification
|
||||||
* [ ] Poll
|
* [x] Poll
|
||||||
* [x] PushSubscription
|
* [x] PushSubscription
|
||||||
* [x] Relationship
|
* [x] Relationship
|
||||||
* [ ] Report ^(Deprecated)^
|
|
||||||
* [x] Results
|
* [x] Results
|
||||||
* [x] Status
|
* [x] Status
|
||||||
* [ ] ScheduledStatus
|
* [ ] ScheduledStatus
|
||||||
|
@ -493,7 +488,7 @@ using this library.
|
||||||
[source,text]
|
[source,text]
|
||||||
----
|
----
|
||||||
Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>.
|
Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>.
|
||||||
License GPLv3: GNU GPL version 3 <https://www.gnu.org/licenses/gpl-3.0.html>.
|
License AGPLv3: <https://www.gnu.org/licenses/agpl-3.0.html>.
|
||||||
This program comes with ABSOLUTELY NO WARRANTY. This is free software,
|
This program comes with ABSOLUTELY NO WARRANTY. This is free software,
|
||||||
and you are welcome to redistribute it under certain conditions.
|
and you are welcome to redistribute it under certain conditions.
|
||||||
----
|
----
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake"
|
||||||
|
VERSION ${PACKAGE_VERSION}
|
||||||
|
COMPATIBILITY ExactVersion) # TODO: Set to SameMajorVersion when stable.
|
||||||
|
|
||||||
|
install(EXPORT ${PROJECT_NAME}Targets
|
||||||
|
FILE "${PROJECT_NAME}Targets.cmake"
|
||||||
|
NAMESPACE "${PROJECT_NAME}::"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
||||||
|
|
||||||
|
configure_file("${PROJECT_NAME}Config.cmake.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" @ONLY)
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
|
@ -0,0 +1,7 @@
|
||||||
|
include(CMakeFindDependencyMacro)
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
find_dependency(jsoncpp CONFIG REQUIRED)
|
||||||
|
find_package(Poco COMPONENTS Foundation Net NetSSL CONFIG REQUIRED)
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
|
|
@ -0,0 +1,46 @@
|
||||||
|
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
|
||||||
|
set(CPACK_PACKAGE_VERSION_MAJOR ${${PROJECT_NAME}_VERSION_MAJOR})
|
||||||
|
set(CPACK_PACKAGE_VERSION_MINOR ${${PROJECT_NAME}_VERSION_MINOR})
|
||||||
|
set(CPACK_PACKAGE_VERSION_PATCH ${${PROJECT_NAME}_VERSION_PATCH})
|
||||||
|
set(CPACK_PACKAGE_VERSION ${mastodon-cpp_VERSION})
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}")
|
||||||
|
if(CPACK_PACKAGE_DESCRIPTION_SUMMARY STREQUAL "") # CMake < 3.9
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "C++ wrapper for the Mastodon API.")
|
||||||
|
endif()
|
||||||
|
set(CPACK_PACKAGE_CONTACT "tastytea <tastytea@tastytea.de>")
|
||||||
|
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
|
||||||
|
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.adoc")
|
||||||
|
|
||||||
|
execute_process(COMMAND uname -m
|
||||||
|
OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
set(CPACK_PACKAGE_FILE_NAME
|
||||||
|
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}_${CPACK_PACKAGE_ARCHITECTURE}")
|
||||||
|
set(CPACK_GENERATOR "TGZ")
|
||||||
|
|
||||||
|
if (WITH_DEB)
|
||||||
|
set(CPACK_PACKAGE_NAME "lib${PROJECT_NAME}")
|
||||||
|
set(CPACK_GENERATOR "DEB")
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE
|
||||||
|
"https://schlomp.space/tastytea/${PROJECT_NAME}")
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
||||||
|
execute_process(COMMAND dpkg --print-architecture
|
||||||
|
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
execute_process(COMMAND lsb_release --codename --short
|
||||||
|
OUTPUT_VARIABLE DEBIAN_CODENAME
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
set(CPACK_PACKAGE_FILE_NAME
|
||||||
|
"${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-0_${DEBIAN_CODENAME}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (WITH_RPM)
|
||||||
|
set(CPACK_PACKAGE_NAME "lib${PROJECT_NAME}")
|
||||||
|
set(CPACK_GENERATOR "RPM")
|
||||||
|
set(CPACK_RPM_PACKAGE_LICENSE "AGPL-3")
|
||||||
|
set(CPACK_RPM_PACKAGE_URL "https://schlomp.space/tastytea/${PROJECT_NAME}")
|
||||||
|
set(CPACK_RPM_PACKAGE_REQUIRES "poco-netssl >= 1.6, jsoncpp >= 1.7.4")
|
||||||
|
set(CPACK_PACKAGE_FILE_NAME
|
||||||
|
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-0.${CPACK_PACKAGE_ARCHITECTURE}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CPack)
|
|
@ -0,0 +1,11 @@
|
||||||
|
file(GLOB sources_examples *.cpp)
|
||||||
|
foreach(src ${sources_examples})
|
||||||
|
get_filename_component(bin ${src} NAME_WE)
|
||||||
|
add_executable(${bin} ${src})
|
||||||
|
target_link_libraries(${bin} PRIVATE ${PROJECT_NAME})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(WITH_DOC)
|
||||||
|
install(FILES ${sources_examples}
|
||||||
|
DESTINATION "${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME}/examples")
|
||||||
|
endif()
|
|
@ -0,0 +1,91 @@
|
||||||
|
// This file is part of mastodon-cpp.
|
||||||
|
// Get 2 pages of 5 favourites each.
|
||||||
|
|
||||||
|
// Don't compile this if the Easy-interface is turned off
|
||||||
|
#ifndef WITHOUT_EASY
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include "mastodon-cpp.hpp"
|
||||||
|
#include "easy/all.hpp"
|
||||||
|
|
||||||
|
using std::cout;
|
||||||
|
using std::cerr;
|
||||||
|
using std::endl;
|
||||||
|
using std::string;
|
||||||
|
using std::vector;
|
||||||
|
using namespace Mastodon;
|
||||||
|
|
||||||
|
void print_favs(Easy::API &masto, const string &max_id = "")
|
||||||
|
{
|
||||||
|
// Set up parameters.
|
||||||
|
Mastodon::parameters params =
|
||||||
|
{
|
||||||
|
{ "limit", { "5" } },
|
||||||
|
{ "exclude_types", { "follow", "reblog", "mention" } }
|
||||||
|
};
|
||||||
|
// Set max_id if given.
|
||||||
|
if (!max_id.empty())
|
||||||
|
{
|
||||||
|
params.push_back({ "max_id", { max_id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve the last 5 favourites.
|
||||||
|
return_call ret = masto.get(API::v1::notifications, params);
|
||||||
|
// If no error was returned.
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
// Convert answer to vector of strings, loop through vector.
|
||||||
|
for (const string &str : Easy::json_array_to_vector(ret.answer))
|
||||||
|
{
|
||||||
|
// Construct Mastodon::Easy::Notification from string.
|
||||||
|
const Easy::Notification notif(str);
|
||||||
|
cout << notif.created_at().strtime("%F %T: ");
|
||||||
|
cout << notif.account().display_name() << " favourited a status.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Print error message.
|
||||||
|
cerr << ret.error_message << endl;
|
||||||
|
// Print HTTP status code, if there is one.
|
||||||
|
if (ret.http_error_code != 0)
|
||||||
|
{
|
||||||
|
cerr << "HTTP status code: "
|
||||||
|
<< std::to_string(ret.http_error_code) << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
const vector<string> args(argv, argv + argc);
|
||||||
|
if (args.size() < 3)
|
||||||
|
{
|
||||||
|
std::cerr << "usage: " << args[0] << " <instance> <auth token>\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construct a Mastodon::Easy object.
|
||||||
|
Easy::API masto(args[1], args[2]);
|
||||||
|
print_favs(masto);
|
||||||
|
|
||||||
|
cout << "\nLink header is: " << masto.get_header("link") << "\n\n";
|
||||||
|
|
||||||
|
// Get the max_id for pagination.
|
||||||
|
// See <https://docs.joinmastodon.org/api/rest/notifications/#pagination>
|
||||||
|
print_favs(masto, masto.get_link().max_id());
|
||||||
|
// The same: print_favs(masto, masto.get_link().next());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
#include <iostream>
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::cout << "mastodon-cpp was compiled without Easy support.\n";
|
||||||
|
return 255;
|
||||||
|
}
|
||||||
|
#endif // WITHOUT_EASY
|
|
@ -0,0 +1,48 @@
|
||||||
|
// This file is part of mastodon-cpp.
|
||||||
|
// Prints shortcode + URL for each custom emoji.
|
||||||
|
|
||||||
|
// Don't compile this if the Easy-interface is turned off
|
||||||
|
#ifndef WITHOUT_EASY
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include "mastodon-cpp.hpp"
|
||||||
|
#include "easy/all.hpp"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
using std::vector;
|
||||||
|
using namespace Mastodon;
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
const vector<string> args(argv, argv + argc);
|
||||||
|
if (args.size() < 2)
|
||||||
|
{
|
||||||
|
std::cerr << "usage: " << args[0] << " <instance>\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construct a Mastodon::Easy object.
|
||||||
|
Easy::API masto(args[1], "");
|
||||||
|
const return_call ret = masto.get(API::v1::custom_emojis);
|
||||||
|
|
||||||
|
// Convert JSON array into vector of strings.
|
||||||
|
for (const string &str : Easy::json_array_to_vector(ret))
|
||||||
|
{
|
||||||
|
// Construct Emoji object from string.
|
||||||
|
const Easy::Emoji emoji(str);
|
||||||
|
std::cout << ':' << emoji.shortcode() << ": <" << emoji.url() << ">\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
#include <iostream>
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::cout << "mastodon-cpp was compiled without Easy support.\n";
|
||||||
|
return 255;
|
||||||
|
}
|
||||||
|
#endif // WITHOUT_EASY
|
|
@ -1,54 +0,0 @@
|
||||||
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
|
|
||||||
set(CPACK_PACKAGE_VERSION_MAJOR ${${PROJECT_NAME}_VERSION_MAJOR})
|
|
||||||
set(CPACK_PACKAGE_VERSION_MINOR ${${PROJECT_NAME}_VERSION_MINOR})
|
|
||||||
set(CPACK_PACKAGE_VERSION_PATCH ${${PROJECT_NAME}_VERSION_PATCH})
|
|
||||||
set(CPACK_PACKAGE_VERSION ${mastodon-cpp_VERSION})
|
|
||||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "C++ wrapper for the Mastodon API")
|
|
||||||
set(CPACK_PACKAGE_CONTACT "tastytea <tastytea@tastytea.de>")
|
|
||||||
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
|
|
||||||
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.adoc")
|
|
||||||
list(APPEND CPACK_SOURCE_IGNORE_FILES "/\\\\.git"
|
|
||||||
"/.gitignore"
|
|
||||||
"/build/"
|
|
||||||
"/doc/"
|
|
||||||
"\\\\.sublime-"
|
|
||||||
"/update_doc.sh"
|
|
||||||
"/.drone.yml"
|
|
||||||
"/ISSUE_TEMPLATE.md$")
|
|
||||||
execute_process(COMMAND uname -m
|
|
||||||
OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
set(CPACK_PACKAGE_FILE_NAME
|
|
||||||
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}_${CPACK_PACKAGE_ARCHITECTURE}")
|
|
||||||
set(CPACK_GENERATOR "TGZ")
|
|
||||||
set(CPACK_SOURCE_GENERATOR "TGZ")
|
|
||||||
|
|
||||||
if (WITH_DEB)
|
|
||||||
set(CPACK_PACKAGE_NAME "lib${PROJECT_NAME}")
|
|
||||||
set(CPACK_GENERATOR "DEB")
|
|
||||||
set(CPACK_SOURCE_GENERATOR "DEB")
|
|
||||||
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://schlomp.space/tastytea/mastodon-cpp")
|
|
||||||
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
|
||||||
execute_process(COMMAND dpkg --print-architecture
|
|
||||||
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
set(CPACK_PACKAGE_FILE_NAME
|
|
||||||
"${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-0_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
|
|
||||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME
|
|
||||||
"${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-0_src")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (WITH_RPM)
|
|
||||||
set(CPACK_PACKAGE_NAME "lib${PROJECT_NAME}")
|
|
||||||
set(CPACK_GENERATOR "RPM")
|
|
||||||
set(CPACK_SOURCE_GENERATOR "RPM")
|
|
||||||
set(CPACK_RPM_PACKAGE_LICENSE "GPL-3")
|
|
||||||
set(CPACK_RPM_PACKAGE_URL "https://schlomp.space/tastytea/mastodon-cpp")
|
|
||||||
set(CPACK_RPM_PACKAGE_REQUIRES "curlpp >= 0.8.1 jsoncpp, >= 1.7.4")
|
|
||||||
set(CPACK_PACKAGE_FILE_NAME
|
|
||||||
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-0.${CPACK_PACKAGE_ARCHITECTURE}")
|
|
||||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME
|
|
||||||
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-0.src")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(CPack)
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
configure_file("${PROJECT_NAME}.pc.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" @ONLY)
|
||||||
|
|
||||||
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
|
@ -0,0 +1,12 @@
|
||||||
|
name=@PROJECT_NAME@
|
||||||
|
prefix=@CMAKE_INSTALL_PREFIX@
|
||||||
|
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
|
||||||
|
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
||||||
|
|
||||||
|
Name: ${name}
|
||||||
|
Description: @PROJECT_DESCRIPTION@
|
||||||
|
Version: @PROJECT_VERSION@
|
||||||
|
Cflags: -I${includedir}
|
||||||
|
Libs: -L${libdir} -l${name} -lpthread -lPocoNet
|
||||||
|
Requires: jsoncpp
|
||||||
|
Libs.private: -lPocoFoundation -lPocoNetSSL
|
|
@ -0,0 +1,71 @@
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
if(WITH_EASY)
|
||||||
|
find_package(jsoncpp CONFIG REQUIRED)
|
||||||
|
endif()
|
||||||
|
# Some distributions do not contain Poco*Config.cmake recipes.
|
||||||
|
find_package(Poco COMPONENTS Foundation Net NetSSL CONFIG)
|
||||||
|
|
||||||
|
if(WITH_EASY)
|
||||||
|
file(GLOB_RECURSE sources *.cpp *.hpp)
|
||||||
|
else()
|
||||||
|
file(GLOB sources *.cpp api/*.cpp *.hpp api/*.hpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Write version in header
|
||||||
|
configure_file ("version.hpp.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/version.hpp")
|
||||||
|
|
||||||
|
add_library(${PROJECT_NAME} ${sources})
|
||||||
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
SOVERSION ${${PROJECT_NAME}_VERSION_MAJOR})
|
||||||
|
|
||||||
|
target_include_directories(${PROJECT_NAME}
|
||||||
|
PRIVATE
|
||||||
|
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>"
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
|
||||||
|
PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>"
|
||||||
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||||
|
|
||||||
|
if(WITH_EASY)
|
||||||
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
PUBLIC pthread jsoncpp_lib)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# If no Poco*Config.cmake recipes are found, look for headers in standard dirs.
|
||||||
|
if(PocoNetSSL_FOUND)
|
||||||
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
PRIVATE Poco::Foundation Poco::Net Poco::NetSSL)
|
||||||
|
else()
|
||||||
|
find_file(Poco_h NAMES "Poco/Poco.h"
|
||||||
|
PATHS "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
|
||||||
|
|
||||||
|
if("${Poco_h}" STREQUAL "Poco_h-NOTFOUND")
|
||||||
|
message(FATAL_ERROR "Could not find POCO.")
|
||||||
|
else()
|
||||||
|
message(WARNING
|
||||||
|
"Your distribution of POCO doesn't contain the *Config.cmake recipes, "
|
||||||
|
"but the files seem to be in the standard directories. "
|
||||||
|
"Let's hope this works.")
|
||||||
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
PRIVATE PocoFoundation PocoNet PocoNetSSL)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(TARGETS ${PROJECT_NAME}
|
||||||
|
EXPORT "${PROJECT_NAME}Targets"
|
||||||
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
|
||||||
|
install(FILES mastodon-cpp.hpp return_types.hpp types.hpp
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
|
||||||
|
if(WITH_EASY)
|
||||||
|
file(GLOB easy_header easy/*.hpp)
|
||||||
|
install(FILES ${easy_header}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/easy)
|
||||||
|
file(GLOB easy_entities_header easy/entities/*.hpp)
|
||||||
|
install(FILES ${easy_entities_header}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/easy/entities)
|
||||||
|
endif()
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ return_call API::del(const Mastodon::API::v1 &call,
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
ttdebug << "ERROR: Invalid argument.\n";
|
ttdebug << "ERROR: Invalid argument.\n";
|
||||||
return { 22, "Invalid argument", 0, "" };
|
return { error::INVALID_ARGUMENT, "Invalid argument", 0, "" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,5 +88,5 @@ return_call API::del(const Mastodon::API::v1 &call,
|
||||||
return_call API::del(const std::string &call, const parameters ¶ms)
|
return_call API::del(const std::string &call, const parameters ¶ms)
|
||||||
{
|
{
|
||||||
|
|
||||||
return _http.request(http_method::DELETE, call, maptoformdata(params));
|
return _http.request(http_method::DELETE, call, *maptoformdata(params));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -86,11 +86,6 @@ const return_call API::get(const Mastodon::API::v1 &call,
|
||||||
strcall = "/api/v1/notifications";
|
strcall = "/api/v1/notifications";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case v1::reports:
|
|
||||||
{
|
|
||||||
strcall = "/api/v1/reports";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case v1::timelines_home:
|
case v1::timelines_home:
|
||||||
{
|
{
|
||||||
strcall = "/api/v1/timelines/home";
|
strcall = "/api/v1/timelines/home";
|
||||||
|
@ -151,11 +146,6 @@ const return_call API::get(const Mastodon::API::v1 &call,
|
||||||
strcall = "/api/v1/notifications/" + strid;
|
strcall = "/api/v1/notifications/" + strid;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case v1::search:
|
|
||||||
{
|
|
||||||
strcall = "/api/v1/search";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case v1::statuses_id:
|
case v1::statuses_id:
|
||||||
{
|
{
|
||||||
strcall = "/api/v1/statuses/" + strid;
|
strcall = "/api/v1/statuses/" + strid;
|
||||||
|
@ -192,7 +182,7 @@ const return_call API::get(const Mastodon::API::v1 &call,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ttdebug << "ERROR: Invalid argument.\n";
|
ttdebug << "ERROR: Invalid argument.\n";
|
||||||
return { 22, "Invalid argument", 0, "" };
|
return { error::INVALID_ARGUMENT, "Invalid argument", 0, "" };
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -236,10 +226,25 @@ const return_call API::get(const Mastodon::API::v1 &call,
|
||||||
strcall = "/api/v1/suggestions";
|
strcall = "/api/v1/suggestions";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case v1::polls_id:
|
||||||
|
{
|
||||||
|
strcall = "/api/v1/polls/" + strid;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case v1::conversations:
|
||||||
|
{
|
||||||
|
strcall = "/api/v1/conversations";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case v1::streaming_health:
|
||||||
|
{
|
||||||
|
strcall = "/api/v1/streaming/health";
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
ttdebug << "ERROR: Invalid argument.\n";
|
ttdebug << "ERROR: Invalid argument.\n";
|
||||||
return { 22, "Invalid argument", 0, "" };
|
return { error::INVALID_ARGUMENT, "Invalid argument", 0, "" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +281,7 @@ const return_call API::get(const Mastodon::API::v2 &call,
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
ttdebug << "ERROR: Invalid argument.\n";
|
ttdebug << "ERROR: Invalid argument.\n";
|
||||||
return { 22, "Invalid argument", 0, "" };
|
return { error::INVALID_ARGUMENT, "Invalid argument", 0, "" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
using namespace Mastodon;
|
using namespace Mastodon;
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
|
using std::to_string;
|
||||||
|
|
||||||
void API::get_stream(const Mastodon::API::v1 &call,
|
void API::get_stream(const Mastodon::API::v1 &call,
|
||||||
const parameters ¶ms,
|
const parameters ¶ms,
|
||||||
|
@ -50,15 +51,27 @@ void API::get_stream(const Mastodon::API::v1 &call,
|
||||||
strcall = "/api/v1/streaming/hashtag";
|
strcall = "/api/v1/streaming/hashtag";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case v1::streaming_hashtag_local:
|
||||||
|
{
|
||||||
|
strcall = "/api/v1/streaming/hashtag/local";
|
||||||
|
break;
|
||||||
|
}
|
||||||
case v1::streaming_list:
|
case v1::streaming_list:
|
||||||
{
|
{
|
||||||
strcall = "/api/v1/streaming/list";
|
strcall = "/api/v1/streaming/list";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case v1::streaming_direct:
|
||||||
|
{
|
||||||
|
strcall = "/api/v1/streaming/direct";
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
const uint8_t err = static_cast<uint8_t>(error::INVALID_ARGUMENT);
|
||||||
ttdebug << "ERROR: Invalid call.\n";
|
ttdebug << "ERROR: Invalid call.\n";
|
||||||
stream = "event: ERROR\ndata: {\"error_code\":22}\n";
|
stream = "event: ERROR\ndata: "
|
||||||
|
"{\"error_code\":" + to_string(err) + "}\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -32,10 +32,9 @@ return_call API::patch(const Mastodon::API::v1 &call,
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ttdebug << "ERROR: Invalid argument.\n";
|
ttdebug << "ERROR: Invalid argument.\n";
|
||||||
return { 22, "Invalid argument", 0, "" };
|
return { error::INVALID_ARGUMENT, "Invalid argument", 0, "" };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _http.request(http_method::PATCH,
|
return _http.request(http_method::PATCH, strcall, *maptoformdata(params));
|
||||||
strcall, maptoformdata(params));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -195,10 +195,15 @@ return_call API::post(const Mastodon::API::v1 &call,
|
||||||
strcall = "/api/v1/filters";
|
strcall = "/api/v1/filters";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case v1::polls_id_votes:
|
||||||
|
{
|
||||||
|
strcall = "/api/v1/polls/" + strid + "/votes";
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
ttdebug << "ERROR: Invalid argument.\n";
|
ttdebug << "ERROR: Invalid argument.\n";
|
||||||
return { 22, "Invalid argument", 0, ""};
|
return { error::INVALID_ARGUMENT, "Invalid argument", 0, ""};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,5 +219,5 @@ return_call API::post(const Mastodon::API::v1 &call)
|
||||||
return_call API::post(const string &call, const parameters ¶ms)
|
return_call API::post(const string &call, const parameters ¶ms)
|
||||||
{
|
{
|
||||||
|
|
||||||
return _http.request(http_method::POST, call, maptoformdata(params));
|
return _http.request(http_method::POST, call, *maptoformdata(params));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ return_call API::put(const Mastodon::API::v1 &call,
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
ttdebug << "ERROR: Invalid argument.\n";
|
ttdebug << "ERROR: Invalid argument.\n";
|
||||||
return { 22, "Invalid argument", 0, "" };
|
return { error::INVALID_ARGUMENT, "Invalid argument", 0, "" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,5 +68,5 @@ return_call API::put(const Mastodon::API::v1 &call,
|
||||||
return_call API::put(const string &call, const parameters ¶ms)
|
return_call API::put(const string &call, const parameters ¶ms)
|
||||||
{
|
{
|
||||||
|
|
||||||
return _http.request(http_method::PUT, call, maptoformdata(params));
|
return _http.request(http_method::PUT, call, *maptoformdata(params));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -29,12 +29,13 @@
|
||||||
#include "entities/mention.hpp"
|
#include "entities/mention.hpp"
|
||||||
#include "entities/notification.hpp"
|
#include "entities/notification.hpp"
|
||||||
#include "entities/relationship.hpp"
|
#include "entities/relationship.hpp"
|
||||||
#include "entities/report.hpp"
|
|
||||||
#include "entities/results.hpp"
|
#include "entities/results.hpp"
|
||||||
#include "entities/status.hpp"
|
#include "entities/status.hpp"
|
||||||
#include "entities/tag.hpp"
|
#include "entities/tag.hpp"
|
||||||
#include "entities/token.hpp"
|
#include "entities/token.hpp"
|
||||||
#include "entities/pushsubscription.hpp"
|
#include "entities/pushsubscription.hpp"
|
||||||
#include "entities/filter.hpp"
|
#include "entities/filter.hpp"
|
||||||
|
#include "entities/poll.hpp"
|
||||||
|
#include "entities/conversation.hpp"
|
||||||
|
|
||||||
#endif // MASTODON_CPP_EASY_ALL_HPP
|
#endif // MASTODON_CPP_EASY_ALL_HPP
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -53,7 +53,8 @@ const vector<Easy::stream_event_type> Easy::parse_stream(
|
||||||
const std::string &streamdata)
|
const std::string &streamdata)
|
||||||
{
|
{
|
||||||
string stream = streamdata;
|
string stream = streamdata;
|
||||||
std::regex reevent("event: (update|notification|delete|ERROR)\ndata: (.*)\n");
|
std::regex reevent("event: (update|notification|delete|filters_changed"
|
||||||
|
"|ERROR)\ndata: (.*)\n");
|
||||||
std::smatch match;
|
std::smatch match;
|
||||||
std::vector<stream_event_type> vec = {};
|
std::vector<stream_event_type> vec = {};
|
||||||
|
|
||||||
|
@ -63,14 +64,16 @@ const vector<Easy::stream_event_type> Easy::parse_stream(
|
||||||
const string &data = match[2].str();
|
const string &data = match[2].str();
|
||||||
event_type type = event_type::Undefined;
|
event_type type = event_type::Undefined;
|
||||||
|
|
||||||
if (event.compare("update") == 0)
|
if (event == "update")
|
||||||
type = event_type::Update;
|
type = event_type::Update;
|
||||||
else if (event.compare("notification") == 0)
|
else if (event == "notification")
|
||||||
type = event_type::Notification;
|
type = event_type::Notification;
|
||||||
else if (event.compare("delete") == 0)
|
else if (event == "delete")
|
||||||
type = event_type::Delete;
|
type = event_type::Delete;
|
||||||
else if (event.compare("ERROR") == 0)
|
else if (event == "ERROR")
|
||||||
type = event_type::Error;
|
type = event_type::Error;
|
||||||
|
else if (event == "filters_changed")
|
||||||
|
type = event_type::Filters_changed;
|
||||||
|
|
||||||
vec.push_back({ type, data });
|
vec.push_back({ type, data });
|
||||||
stream = match.suffix().str();
|
stream = match.suffix().str();
|
||||||
|
@ -98,8 +101,8 @@ Easy::Link::Link(const string &link_header)
|
||||||
: _next()
|
: _next()
|
||||||
, _prev()
|
, _prev()
|
||||||
{
|
{
|
||||||
std::regex renext("max_id=([[:digit:]]*)");
|
std::regex renext("max_id=([[:alnum:]]*)");
|
||||||
std::regex reprev("since_id=([[:digit:]]*)");
|
std::regex reprev("(?:since|min)_id=([[:alnum:]]*)");
|
||||||
std::smatch match;
|
std::smatch match;
|
||||||
|
|
||||||
if (std::regex_search(link_header, match, renext))
|
if (std::regex_search(link_header, match, renext))
|
||||||
|
@ -131,3 +134,8 @@ const string Easy::Link::since_id() const
|
||||||
{
|
{
|
||||||
return _prev;
|
return _prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const string Easy::Link::min_id() const
|
||||||
|
{
|
||||||
|
return _prev;
|
||||||
|
}
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -89,6 +89,13 @@ namespace Easy
|
||||||
*/
|
*/
|
||||||
const string since_id() const;
|
const string since_id() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns min_id.
|
||||||
|
*
|
||||||
|
* @since 0.111.0
|
||||||
|
*/
|
||||||
|
const string min_id() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string _next;
|
string _next;
|
||||||
string _prev;
|
string _prev;
|
||||||
|
@ -160,6 +167,7 @@ namespace Easy
|
||||||
*
|
*
|
||||||
* @since 0.100.0
|
* @since 0.100.0
|
||||||
*/
|
*/
|
||||||
|
[[deprecated("Will go away in 1.0.0 with no replacement.")]]
|
||||||
const return_entity<Easy::Status> send_post(const Status &status);
|
const return_entity<Easy::Status> send_post(const Status &status);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -167,6 +175,7 @@ namespace Easy
|
||||||
*
|
*
|
||||||
* @since 0.100.0
|
* @since 0.100.0
|
||||||
*/
|
*/
|
||||||
|
[[deprecated("Will go away in 1.0.0 with no replacement.")]]
|
||||||
const return_entity<Easy::Status> send_toot(const Status &status);
|
const return_entity<Easy::Status> send_toot(const Status &status);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -180,6 +189,7 @@ namespace Easy
|
||||||
*
|
*
|
||||||
* @since 0.100.0
|
* @since 0.100.0
|
||||||
*/
|
*/
|
||||||
|
[[deprecated("Will go away in 1.0.0 with no replacement.")]]
|
||||||
const return_entity_vector<Easy::Notification> get_notifications(
|
const return_entity_vector<Easy::Notification> get_notifications(
|
||||||
const uint16_t limit = 20, const string since_id = "",
|
const uint16_t limit = 20, const string since_id = "",
|
||||||
const string max_id = "");
|
const string max_id = "");
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
/* This file is part of mastodon-cpp.
|
||||||
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include "conversation.hpp"
|
||||||
|
#include "debug.hpp"
|
||||||
|
|
||||||
|
using namespace Mastodon;
|
||||||
|
using Conversation = Easy::Conversation;
|
||||||
|
|
||||||
|
bool Conversation::valid() const
|
||||||
|
{
|
||||||
|
return Entity::check_valid(
|
||||||
|
{
|
||||||
|
"id",
|
||||||
|
"accounts",
|
||||||
|
"unread"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const string Conversation::id() const
|
||||||
|
{
|
||||||
|
return get_string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Easy::Account> Conversation::accounts() const
|
||||||
|
{
|
||||||
|
const Json::Value node = get("accounts");
|
||||||
|
if (node.isArray())
|
||||||
|
{
|
||||||
|
std::vector<Easy::Account> vec;
|
||||||
|
std::transform(node.begin(), node.end(), std::back_inserter(vec),
|
||||||
|
[](const Json::Value &value)
|
||||||
|
{ return Easy::Account(value); });
|
||||||
|
return vec;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const Easy::Status Conversation::last_status() const
|
||||||
|
{
|
||||||
|
const Json::Value &node = get("last_status");
|
||||||
|
if (!node.isNull())
|
||||||
|
{
|
||||||
|
return Easy::Status(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Conversation::unread() const
|
||||||
|
{
|
||||||
|
return get_bool("unread");
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
/* This file is part of mastodon-cpp.
|
||||||
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MASTODON_CPP_EASY_CONVERSATION_HPP
|
||||||
|
#define MASTODON_CPP_EASY_CONVERSATION_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "../../mastodon-cpp.hpp"
|
||||||
|
#include "../entity.hpp"
|
||||||
|
#include "account.hpp"
|
||||||
|
#include "status.hpp"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
namespace Mastodon
|
||||||
|
{
|
||||||
|
namespace Easy
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* @brief Class to hold conversations.
|
||||||
|
*
|
||||||
|
* @since 0.110.0
|
||||||
|
*/
|
||||||
|
class Conversation : public Entity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using Entity::Entity;
|
||||||
|
|
||||||
|
virtual bool valid() const override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the id of the conversation.
|
||||||
|
*
|
||||||
|
* @since 0.110.0
|
||||||
|
*/
|
||||||
|
const string id() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the participating accounts.
|
||||||
|
*
|
||||||
|
* @since 0.110.0
|
||||||
|
*/
|
||||||
|
const std::vector<Account> accounts() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the last status.
|
||||||
|
*
|
||||||
|
* @since 0.110.0
|
||||||
|
*/
|
||||||
|
const Status last_status() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns true if unread.
|
||||||
|
*
|
||||||
|
* @since 0.110.0
|
||||||
|
*/
|
||||||
|
bool unread() const;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MASTODON_CPP_EASY_CONVERSATION_HPP
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
/* This file is part of mastodon-cpp.
|
||||||
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "poll.hpp"
|
||||||
|
#include "debug.hpp"
|
||||||
|
|
||||||
|
using namespace Mastodon;
|
||||||
|
using Poll = Easy::Poll;
|
||||||
|
|
||||||
|
bool Poll::valid() const
|
||||||
|
{
|
||||||
|
return Entity::check_valid(
|
||||||
|
{
|
||||||
|
"id",
|
||||||
|
"expired",
|
||||||
|
"expired",
|
||||||
|
"multiple",
|
||||||
|
"votes_count",
|
||||||
|
"options"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const string Poll::id() const
|
||||||
|
{
|
||||||
|
return get_string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
const Easy::time_type Poll::expires_at() const
|
||||||
|
{
|
||||||
|
return get_time("expires_at");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Poll::expired() const
|
||||||
|
{
|
||||||
|
return get_bool("expired");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Poll::multiple() const
|
||||||
|
{
|
||||||
|
return get_bool("multiple");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Poll::votes_count() const
|
||||||
|
{
|
||||||
|
return get_uint64("votes_count");
|
||||||
|
}
|
||||||
|
|
||||||
|
const vector<Easy::poll_options_type> Poll::options() const
|
||||||
|
{
|
||||||
|
const Json::Value &node = get("options");
|
||||||
|
|
||||||
|
if (node.isArray())
|
||||||
|
{
|
||||||
|
vector<Easy::poll_options_type> vec_options;
|
||||||
|
std::transform(node.begin(), node.end(), std::back_inserter(vec_options),
|
||||||
|
[](const Json::Value &value)
|
||||||
|
{
|
||||||
|
return Easy::poll_options_type(
|
||||||
|
{
|
||||||
|
value["title"].asString(),
|
||||||
|
value["votes_count"].asUInt64()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return vec_options;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Poll::voted() const
|
||||||
|
{
|
||||||
|
return get_bool("voted");
|
||||||
|
}
|
|
@ -0,0 +1,98 @@
|
||||||
|
/* This file is part of mastodon-cpp.
|
||||||
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MASTODON_CPP_EASY_POLL_HPP
|
||||||
|
#define MASTODON_CPP_EASY_POLL_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "../../mastodon-cpp.hpp"
|
||||||
|
#include "../entity.hpp"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
using std::uint64_t;
|
||||||
|
|
||||||
|
namespace Mastodon
|
||||||
|
{
|
||||||
|
namespace Easy
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* @brief Class to hold polls.
|
||||||
|
*
|
||||||
|
* @since 0.110.0
|
||||||
|
*/
|
||||||
|
class Poll : public Entity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using Entity::Entity;
|
||||||
|
|
||||||
|
virtual bool valid() const override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns poll ID.
|
||||||
|
*
|
||||||
|
* @since 0.110.0
|
||||||
|
*/
|
||||||
|
const string id() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns time when the poll expires.
|
||||||
|
*
|
||||||
|
* @since 0.110.0
|
||||||
|
*/
|
||||||
|
const Easy::time_type expires_at() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns true if poll has expired.
|
||||||
|
*
|
||||||
|
* @since 0.110.0
|
||||||
|
*/
|
||||||
|
bool expired() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns true or false.
|
||||||
|
*
|
||||||
|
* @since 0.110.0
|
||||||
|
*/
|
||||||
|
bool multiple() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the number of votes.
|
||||||
|
*
|
||||||
|
* @since 0.110.0
|
||||||
|
*/
|
||||||
|
uint64_t votes_count() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns poll options and their votes count.
|
||||||
|
*
|
||||||
|
* @since 0.110.0
|
||||||
|
*/
|
||||||
|
const vector<poll_options_type> options() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns whether you voted or not.
|
||||||
|
*
|
||||||
|
* @since 0.110.0
|
||||||
|
*/
|
||||||
|
bool voted() const;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MASTODON_CPP_EASY_POLL_HPP
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
/* This file is part of mastodon-cpp.
|
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "report.hpp"
|
|
||||||
|
|
||||||
using namespace Mastodon;
|
|
||||||
using Report = Easy::Report;
|
|
||||||
|
|
||||||
bool Report::valid() const
|
|
||||||
{
|
|
||||||
return Entity::check_valid(
|
|
||||||
{
|
|
||||||
"id",
|
|
||||||
"action_taken"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Report::action_taken() const
|
|
||||||
{
|
|
||||||
return get_bool("action_taken");
|
|
||||||
}
|
|
||||||
|
|
||||||
const string Report::id() const
|
|
||||||
{
|
|
||||||
return get_string("id");
|
|
||||||
}
|
|
|
@ -1,62 +0,0 @@
|
||||||
/* This file is part of mastodon-cpp.
|
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MASTODON_CPP_EASY_REPORT_HPP
|
|
||||||
#define MASTODON_CPP_EASY_REPORT_HPP
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
#include "../../mastodon-cpp.hpp"
|
|
||||||
#include "../entity.hpp"
|
|
||||||
|
|
||||||
using std::string;
|
|
||||||
|
|
||||||
namespace Mastodon
|
|
||||||
{
|
|
||||||
namespace Easy
|
|
||||||
{
|
|
||||||
/*!
|
|
||||||
* @brief Class to hold reports
|
|
||||||
*
|
|
||||||
* before 0.11.0
|
|
||||||
*/
|
|
||||||
class Report : public Entity
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using Entity::Entity;
|
|
||||||
|
|
||||||
virtual bool valid() const override;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns true if an action was taken in response to the
|
|
||||||
* report
|
|
||||||
*
|
|
||||||
* @since before 0.11.0
|
|
||||||
*/
|
|
||||||
bool action_taken() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the ID of the report
|
|
||||||
*
|
|
||||||
* @since before 0.11.0
|
|
||||||
*/
|
|
||||||
const string id() const;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // MASTODON_CPP_EASY_REPORT_HPP
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -26,13 +26,14 @@
|
||||||
#include "easy/entities/mention.hpp"
|
#include "easy/entities/mention.hpp"
|
||||||
#include "easy/entities/notification.hpp"
|
#include "easy/entities/notification.hpp"
|
||||||
#include "easy/entities/relationship.hpp"
|
#include "easy/entities/relationship.hpp"
|
||||||
#include "easy/entities/report.hpp"
|
|
||||||
#include "easy/entities/results.hpp"
|
#include "easy/entities/results.hpp"
|
||||||
#include "easy/entities/status.hpp"
|
#include "easy/entities/status.hpp"
|
||||||
#include "easy/entities/tag.hpp"
|
#include "easy/entities/tag.hpp"
|
||||||
#include "easy/entities/token.hpp"
|
#include "easy/entities/token.hpp"
|
||||||
#include "easy/entities/pushsubscription.hpp"
|
#include "easy/entities/pushsubscription.hpp"
|
||||||
#include "easy/entities/filter.hpp"
|
#include "easy/entities/filter.hpp"
|
||||||
|
#include "easy/entities/poll.hpp"
|
||||||
|
#include "easy/entities/conversation.hpp"
|
||||||
|
|
||||||
using namespace Mastodon;
|
using namespace Mastodon;
|
||||||
|
|
||||||
|
@ -51,6 +52,16 @@ Easy::return_entity<T>::return_entity(const uint8_t ec, const string &em,
|
||||||
http_error_code = hec;
|
http_error_code = hec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
Easy::return_entity<T>::return_entity(const error ec, const string &em,
|
||||||
|
const uint16_t hec, const T &ent)
|
||||||
|
: entity(ent)
|
||||||
|
{
|
||||||
|
error_code = static_cast<uint8_t>(ec);
|
||||||
|
error_message = em;
|
||||||
|
http_error_code = hec;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Easy::return_entity<T>::return_entity::operator const T() const
|
Easy::return_entity<T>::return_entity::operator const T() const
|
||||||
{
|
{
|
||||||
|
@ -75,13 +86,14 @@ template struct Easy::return_entity<Easy::List>;
|
||||||
template struct Easy::return_entity<Easy::Mention>;
|
template struct Easy::return_entity<Easy::Mention>;
|
||||||
template struct Easy::return_entity<Easy::Notification>;
|
template struct Easy::return_entity<Easy::Notification>;
|
||||||
template struct Easy::return_entity<Easy::Relationship>;
|
template struct Easy::return_entity<Easy::Relationship>;
|
||||||
template struct Easy::return_entity<Easy::Report>;
|
|
||||||
template struct Easy::return_entity<Easy::Results>;
|
template struct Easy::return_entity<Easy::Results>;
|
||||||
template struct Easy::return_entity<Easy::Status>;
|
template struct Easy::return_entity<Easy::Status>;
|
||||||
template struct Easy::return_entity<Easy::Tag>;
|
template struct Easy::return_entity<Easy::Tag>;
|
||||||
template struct Easy::return_entity<Easy::Token>;
|
template struct Easy::return_entity<Easy::Token>;
|
||||||
template struct Easy::return_entity<Easy::PushSubscription>;
|
template struct Easy::return_entity<Easy::PushSubscription>;
|
||||||
template struct Easy::return_entity<Easy::Filter>;
|
template struct Easy::return_entity<Easy::Filter>;
|
||||||
|
template struct Easy::return_entity<Easy::Poll>;
|
||||||
|
template struct Easy::return_entity<Easy::Conversation>;
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -120,10 +132,11 @@ template struct Easy::return_entity_vector<Easy::List>;
|
||||||
template struct Easy::return_entity_vector<Easy::Mention>;
|
template struct Easy::return_entity_vector<Easy::Mention>;
|
||||||
template struct Easy::return_entity_vector<Easy::Notification>;
|
template struct Easy::return_entity_vector<Easy::Notification>;
|
||||||
template struct Easy::return_entity_vector<Easy::Relationship>;
|
template struct Easy::return_entity_vector<Easy::Relationship>;
|
||||||
template struct Easy::return_entity_vector<Easy::Report>;
|
|
||||||
template struct Easy::return_entity_vector<Easy::Results>;
|
template struct Easy::return_entity_vector<Easy::Results>;
|
||||||
template struct Easy::return_entity_vector<Easy::Status>;
|
template struct Easy::return_entity_vector<Easy::Status>;
|
||||||
template struct Easy::return_entity_vector<Easy::Tag>;
|
template struct Easy::return_entity_vector<Easy::Tag>;
|
||||||
template struct Easy::return_entity_vector<Easy::Token>;
|
template struct Easy::return_entity_vector<Easy::Token>;
|
||||||
template struct Easy::return_entity_vector<Easy::PushSubscription>;
|
template struct Easy::return_entity_vector<Easy::PushSubscription>;
|
||||||
template struct Easy::return_entity_vector<Easy::Filter>;
|
template struct Easy::return_entity_vector<Easy::Filter>;
|
||||||
|
template struct Easy::return_entity_vector<Easy::Poll>;
|
||||||
|
template struct Easy::return_entity_vector<Easy::Conversation>;
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -36,8 +36,9 @@ namespace Easy
|
||||||
*
|
*
|
||||||
* @since 0.100.0
|
* @since 0.100.0
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T> struct
|
||||||
struct return_entity : return_base
|
[[deprecated("Will go away in 1.0.0 with no replacement.")]]
|
||||||
|
return_entity : return_base
|
||||||
{
|
{
|
||||||
/*!
|
/*!
|
||||||
* @brief Mastodon::Easy::Entity
|
* @brief Mastodon::Easy::Entity
|
||||||
|
@ -61,6 +62,19 @@ namespace Easy
|
||||||
return_entity(const uint8_t ec, const string &em,
|
return_entity(const uint8_t ec, const string &em,
|
||||||
const uint16_t hec, const T &ent);
|
const uint16_t hec, const T &ent);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Return type for easy Mastodon::Easy::API.
|
||||||
|
*
|
||||||
|
* @param ec Error code
|
||||||
|
* @param em Error message
|
||||||
|
* @param hec HTTP error code
|
||||||
|
* @param ent Answer
|
||||||
|
*
|
||||||
|
* @since 0.110.0
|
||||||
|
*/
|
||||||
|
return_entity(const error ec, const string &em,
|
||||||
|
const uint16_t hec, const T &ent);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Same as return_entity::entity.
|
* @brief Same as return_entity::entity.
|
||||||
*
|
*
|
||||||
|
@ -94,8 +108,9 @@ namespace Easy
|
||||||
*
|
*
|
||||||
* @since 0.100.0
|
* @since 0.100.0
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T> struct
|
||||||
struct return_entity_vector : return_base
|
[[deprecated("Will go away in 1.0.0 with no replacement.")]]
|
||||||
|
return_entity_vector : return_base
|
||||||
{
|
{
|
||||||
/*!
|
/*!
|
||||||
* @brief std::vector of Mastodon::Easy::Entity.
|
* @brief std::vector of Mastodon::Easy::Entity.
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -39,7 +39,8 @@ const return_entity<Status> API::send_post(const Status &status)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ttdebug << "ERROR: Easy::Status::content can not be empty.\n";
|
ttdebug << "ERROR: Easy::Status::content can not be empty.\n";
|
||||||
return { 22, "Easy::Status::content can not be empty", 0, Status() };
|
return { error::INVALID_ARGUMENT,
|
||||||
|
"Easy::Status::content can not be empty", 0, Status() };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!status.in_reply_to_id().empty())
|
if (!status.in_reply_to_id().empty())
|
||||||
|
@ -94,8 +95,9 @@ const return_entity<Status> API::send_post(const Status &status)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ttdebug << "ERROR: Easy::Attachment::file can not be empty.\n";
|
ttdebug << "ERROR: Easy::Attachment::file can not be empty.\n";
|
||||||
return { 22, "Easy::Attachment::file can not be empty",
|
return { error::INVALID_ARGUMENT,
|
||||||
0, Status() };
|
"Easy::Attachment::file can not be empty", 0,
|
||||||
|
Status() };
|
||||||
}
|
}
|
||||||
if (!att.description().empty())
|
if (!att.description().empty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ namespace Easy
|
||||||
Notification,
|
Notification,
|
||||||
Delete,
|
Delete,
|
||||||
Error,
|
Error,
|
||||||
|
Filters_changed,
|
||||||
Undefined
|
Undefined
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -224,6 +225,15 @@ namespace Easy
|
||||||
uint64_t status_count = 0;
|
uint64_t status_count = 0;
|
||||||
uint64_t domain_count = 0;
|
uint64_t domain_count = 0;
|
||||||
} stats_type;
|
} stats_type;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Poll options returned by Poll::options().
|
||||||
|
*/
|
||||||
|
typedef struct poll_options_type
|
||||||
|
{
|
||||||
|
string title;
|
||||||
|
uint64_t votes_count = 0;
|
||||||
|
} poll_options_type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // MASTODON_CPP_EASY_TYPES_EASY_HPP
|
#endif // MASTODON_CPP_EASY_TYPES_EASY_HPP
|
||||||
|
|
393
src/http.cpp
393
src/http.cpp
|
@ -2,33 +2,49 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <functional> // std::bind
|
#include <functional> // std::bind
|
||||||
#include <list>
|
|
||||||
#include <cstring> // std::strncmp
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <curlpp/Options.hpp>
|
#include <regex>
|
||||||
#include <curlpp/Exception.hpp>
|
#include <Poco/Net/HTTPSClientSession.h>
|
||||||
#include <curlpp/Infos.hpp>
|
#include <Poco/Net/HTTPRequest.h>
|
||||||
|
#include <Poco/Net/HTTPResponse.h>
|
||||||
|
#include <Poco/StreamCopier.h>
|
||||||
|
#include <Poco/URI.h>
|
||||||
|
#include <Poco/Environment.h>
|
||||||
|
#include <Poco/Exception.h>
|
||||||
|
#include <Poco/Net/NetException.h>
|
||||||
|
#include <Poco/Net/SSLException.h>
|
||||||
#include "debug.hpp"
|
#include "debug.hpp"
|
||||||
#include "mastodon-cpp.hpp"
|
#include "mastodon-cpp.hpp"
|
||||||
|
|
||||||
using namespace Mastodon;
|
using namespace Mastodon;
|
||||||
namespace curlopts = curlpp::options;
|
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
|
using std::istream;
|
||||||
|
using std::make_unique;
|
||||||
|
using std::move;
|
||||||
|
using std::regex;
|
||||||
|
using std::regex_search;
|
||||||
|
using std::smatch;
|
||||||
|
using Poco::Net::HTTPSClientSession;
|
||||||
|
using Poco::Net::HTTPRequest;
|
||||||
|
using Poco::Net::HTTPResponse;
|
||||||
|
using Poco::Net::HTTPMessage;
|
||||||
|
using Poco::StreamCopier;
|
||||||
|
using Poco::Environment;
|
||||||
|
|
||||||
API::http::http(const API &api, const string &instance,
|
API::http::http(const API &api, const string &instance,
|
||||||
const string &access_token)
|
const string &access_token)
|
||||||
|
@ -37,21 +53,95 @@ API::http::http(const API &api, const string &instance,
|
||||||
, _access_token(access_token)
|
, _access_token(access_token)
|
||||||
, _cancel_stream(false)
|
, _cancel_stream(false)
|
||||||
{
|
{
|
||||||
curlpp::initialize();
|
Poco::Net::initializeSSL();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string env_proxy = Environment::get("http_proxy");
|
||||||
|
size_t pos;
|
||||||
|
|
||||||
|
// Only keep text between // and /.
|
||||||
|
if ((pos = env_proxy.find("//")) != string::npos)
|
||||||
|
{
|
||||||
|
env_proxy = env_proxy.substr(pos + 2);
|
||||||
|
}
|
||||||
|
if ((pos = env_proxy.find('/')) != string::npos)
|
||||||
|
{
|
||||||
|
env_proxy = env_proxy.substr(0, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((pos = env_proxy.find('@')) != string::npos)
|
||||||
|
{
|
||||||
|
string hostport = env_proxy.substr(pos + 1);
|
||||||
|
string userpw = env_proxy.substr(0, pos);
|
||||||
|
set_proxy(hostport, userpw);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
set_proxy(env_proxy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception &)
|
||||||
|
{
|
||||||
|
// No proxy found, no problem.
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
API::http::~http()
|
API::http::~http()
|
||||||
{
|
{
|
||||||
curlpp::terminate();
|
Poco::Net::uninitializeSSL();
|
||||||
|
}
|
||||||
|
|
||||||
|
void API::http::set_proxy(const string &hostport, const string &userpw)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HTTPSClientSession::ProxyConfig proxyconfig;
|
||||||
|
size_t pos = hostport.find(':');
|
||||||
|
|
||||||
|
proxyconfig.host = hostport.substr(0, pos);
|
||||||
|
if (pos != string::npos)
|
||||||
|
{
|
||||||
|
proxyconfig.port = std::stoi(hostport.substr(pos + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!userpw.empty())
|
||||||
|
{
|
||||||
|
string username;
|
||||||
|
|
||||||
|
pos = userpw.find(':');
|
||||||
|
Poco::URI::decode(userpw.substr(0, pos), username);
|
||||||
|
proxyconfig.username = username;
|
||||||
|
|
||||||
|
if (pos != string::npos)
|
||||||
|
{
|
||||||
|
string password;
|
||||||
|
Poco::URI::decode(userpw.substr(pos + 1), password);
|
||||||
|
proxyconfig.password = password;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HTTPSClientSession::setGlobalProxyConfig(proxyconfig);
|
||||||
|
ttdebug << "Set proxy to " << hostport << ".\n";
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
if (parent.exceptions())
|
||||||
|
{
|
||||||
|
std::rethrow_exception(std::current_exception());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return_call API::http::request(const http_method &meth, const string &path)
|
return_call API::http::request(const http_method &meth, const string &path)
|
||||||
{
|
{
|
||||||
return request(meth, path, curlpp::Forms());
|
HTMLForm form;
|
||||||
|
return request(meth, path, form);
|
||||||
}
|
}
|
||||||
|
|
||||||
return_call API::http::request(const http_method &meth, const string &path,
|
return_call API::http::request(const http_method &meth, const string &path,
|
||||||
const curlpp::Forms &formdata)
|
HTMLForm &formdata)
|
||||||
{
|
{
|
||||||
string answer;
|
string answer;
|
||||||
return request_common(meth, path, formdata, answer);
|
return request_common(meth, path, formdata, answer);
|
||||||
|
@ -63,8 +153,9 @@ void API::http::request_stream(const string &path, string &stream)
|
||||||
_streamthread = std::thread(
|
_streamthread = std::thread(
|
||||||
[&, path] // path is captured by value because it may be
|
[&, path] // path is captured by value because it may be
|
||||||
{ // deleted before we access it.
|
{ // deleted before we access it.
|
||||||
|
HTMLForm form;
|
||||||
ret = request_common(http_method::GET_STREAM, path,
|
ret = request_common(http_method::GET_STREAM, path,
|
||||||
curlpp::Forms(), stream);
|
form, stream);
|
||||||
ttdebug << "Remaining content of the stream: " << stream << '\n';
|
ttdebug << "Remaining content of the stream: " << stream << '\n';
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
|
@ -78,149 +169,181 @@ void API::http::request_stream(const string &path, string &stream)
|
||||||
|
|
||||||
return_call API::http::request_common(const http_method &meth,
|
return_call API::http::request_common(const http_method &meth,
|
||||||
const string &path,
|
const string &path,
|
||||||
const curlpp::Forms &formdata,
|
HTMLForm &formdata,
|
||||||
string &answer)
|
string &answer)
|
||||||
{
|
{
|
||||||
using namespace std::placeholders; // _1, _2, _3
|
|
||||||
|
|
||||||
ttdebug << "Path is: " << path << '\n';
|
ttdebug << "Path is: " << path << '\n';
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
curlpp::Easy request;
|
string method;
|
||||||
std::list<string> headers;
|
|
||||||
|
|
||||||
request.setOpt<curlopts::Url>("https://" + _instance + path);
|
|
||||||
ttdebug << "User-Agent: " << parent.get_useragent() << "\n";
|
|
||||||
request.setOpt<curlopts::UserAgent>(parent.get_useragent());
|
|
||||||
|
|
||||||
{
|
|
||||||
string proxy;
|
|
||||||
string userpw;
|
|
||||||
parent.get_proxy(proxy, userpw);
|
|
||||||
if (!proxy.empty())
|
|
||||||
{
|
|
||||||
request.setOpt<curlopts::Proxy>(proxy);
|
|
||||||
if (!userpw.empty())
|
|
||||||
{
|
|
||||||
request.setOpt<curlopts::ProxyUserPwd>(userpw);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_access_token.empty())
|
|
||||||
{
|
|
||||||
headers.push_back("Authorization: Bearer " + _access_token);
|
|
||||||
}
|
|
||||||
if (meth != http_method::GET_STREAM)
|
|
||||||
{
|
|
||||||
headers.push_back("Connection: close");
|
|
||||||
// Get headers from server
|
|
||||||
request.setOpt<curlpp::options::Header>(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
request.setOpt<curlopts::HttpHeader>(headers);
|
|
||||||
request.setOpt<curlopts::FollowLocation>(true);
|
|
||||||
request.setOpt<curlopts::WriteFunction>
|
|
||||||
(std::bind(&http::callback_write, this, _1, _2, _3, &answer));
|
|
||||||
request.setOpt<curlopts::ProgressFunction>
|
|
||||||
(std::bind(&http::callback_progress, this, _1, _2, _3, _4));
|
|
||||||
request.setOpt<curlopts::NoProgress>(0);
|
|
||||||
if (!formdata.empty())
|
|
||||||
{
|
|
||||||
request.setOpt<curlopts::HttpPost>(formdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (meth)
|
switch (meth)
|
||||||
{
|
{
|
||||||
case http_method::GET:
|
case http_method::GET:
|
||||||
case http_method::GET_STREAM:
|
case http_method::GET_STREAM:
|
||||||
break;
|
{
|
||||||
case http_method::PATCH:
|
method = HTTPRequest::HTTP_GET;
|
||||||
request.setOpt<curlopts::CustomRequest>("PATCH");
|
|
||||||
break;
|
|
||||||
case http_method::POST:
|
|
||||||
request.setOpt<curlopts::CustomRequest>("POST");
|
|
||||||
break;
|
|
||||||
case http_method::PUT:
|
|
||||||
request.setOpt<curlopts::CustomRequest>("PUT");
|
|
||||||
break;
|
|
||||||
case http_method::DELETE:
|
|
||||||
request.setOpt<curlopts::CustomRequest>("DELETE");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case http_method::PUT:
|
||||||
|
{
|
||||||
|
method = HTTPRequest::HTTP_PUT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case http_method::POST:
|
||||||
|
{
|
||||||
|
method = HTTPRequest::HTTP_POST;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case http_method::PATCH:
|
||||||
|
{
|
||||||
|
// POCO in CentOS 7 (1.6.1) doesn't have HTTPRequest::HTTP_PATCH.
|
||||||
|
method = "PATCH";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case http_method::DELETE:
|
||||||
|
{
|
||||||
|
method = HTTPRequest::HTTP_DELETE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//request.setOpt<curlopts::Verbose>(true);
|
HTTPSClientSession session(_instance);
|
||||||
|
HTTPRequest request(method, path, HTTPMessage::HTTP_1_1);
|
||||||
|
request.set("User-Agent", parent.get_useragent());
|
||||||
|
|
||||||
|
if (!_access_token.empty())
|
||||||
|
{
|
||||||
|
request.set("Authorization", " Bearer " + _access_token);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!formdata.empty())
|
||||||
|
{
|
||||||
|
ttdebug << "Size of HTMLForm is " << formdata.size() << '\n';
|
||||||
|
formdata.prepareSubmit(request);
|
||||||
|
formdata.write(session.sendRequest(request));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
session.sendRequest(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
HTTPResponse response;
|
||||||
|
istream &body_stream = session.receiveResponse(response);
|
||||||
|
|
||||||
|
const uint16_t http_code = response.getStatus();
|
||||||
|
ttdebug << "Response code: " << http_code << '\n';
|
||||||
|
|
||||||
answer.clear();
|
answer.clear();
|
||||||
request.perform();
|
StreamCopier::copyToString(body_stream, answer);
|
||||||
uint16_t http_code = curlpp::infos::ResponseCode::get(request);
|
|
||||||
ttdebug << "Response code: " << http_code << '\n';
|
|
||||||
// Work around "HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 200 OK"
|
|
||||||
size_t pos = answer.find("\r\n\r\n", 25);
|
|
||||||
_headers = answer.substr(0, pos);
|
|
||||||
// Only return body
|
|
||||||
answer = answer.substr(pos + 4);
|
|
||||||
|
|
||||||
if (http_code == 200 || http_code == 302 || http_code == 307)
|
std::ostringstream headers_stream;
|
||||||
{ // OK or Found or Temporary Redirect
|
response.write(headers_stream);
|
||||||
return { 0, "", http_code, answer };
|
_headers = headers_stream.str();
|
||||||
}
|
|
||||||
else if (http_code == 301 || http_code == 308)
|
switch (http_code)
|
||||||
{ // Moved Permanently or Permanent Redirect
|
|
||||||
// return new URL
|
|
||||||
answer = curlpp::infos::EffectiveUrl::get(request);
|
|
||||||
return { 78, "Remote address changed", http_code, answer };
|
|
||||||
}
|
|
||||||
else if (http_code == 0)
|
|
||||||
{
|
{
|
||||||
return { 255, "Unknown error", http_code, answer };
|
case HTTPResponse::HTTP_OK:
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
return { 111, "Connection refused", http_code, answer };
|
return { error::OK, "", http_code, answer };
|
||||||
|
}
|
||||||
|
// Not using the constants because some are too new for Debian stretch.
|
||||||
|
case 301: // HTTPResponse::HTTP_MOVED_PERMANENTLY
|
||||||
|
case 308: // HTTPResponse::HTTP_PERMANENT_REDIRECT
|
||||||
|
case 302: // HTTPResponse::HTTP_FOUND
|
||||||
|
case 303: // HTTPResponse::HTTP_SEE_OTHER
|
||||||
|
case 307: // HTTPResponse::HTTP_TEMPORARY_REDIRECT
|
||||||
|
{
|
||||||
|
ttdebug << "HTTP redirect.\n";
|
||||||
|
string location = response.get("Location");
|
||||||
|
|
||||||
|
if (location.substr(0, 4) == "http")
|
||||||
|
{ // Remove protocol and instance from path.
|
||||||
|
size_t pos1 = location.find("//") + 2;
|
||||||
|
size_t pos2 = location.find('/', pos1);
|
||||||
|
|
||||||
|
if (location.substr(pos1, pos2 - pos1) != _instance)
|
||||||
|
{ // Return new location if the domain changed.
|
||||||
|
ttdebug << "New location is on another domain.\n";
|
||||||
|
return { error::URL_CHANGED, "Remote address changed",
|
||||||
|
http_code, location };
|
||||||
|
}
|
||||||
|
|
||||||
|
location = location.substr(pos2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (http_code == 301 || http_code == 308)
|
||||||
|
{ // Return new location for permanent redirects.
|
||||||
|
return { error::URL_CHANGED, "Remote address changed",
|
||||||
|
http_code, location };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ttdebug << "Following temporary redirect: " << location << '\n';
|
||||||
|
return request_common(meth, location, formdata, answer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return { error::CONNECTION_REFUSED, "Connection refused",
|
||||||
|
http_code, answer };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (curlpp::RuntimeError &e)
|
catch (const Poco::Net::DNSException &e)
|
||||||
{
|
{
|
||||||
const string what = e.what();
|
|
||||||
// This error is thrown if http.cancel_stream() is used.
|
|
||||||
if ((what.compare(0, 16, "Callback aborted") == 0) ||
|
|
||||||
(what.compare(0, 19, "Failed writing body") == 0))
|
|
||||||
{
|
|
||||||
ttdebug << "Request was cancelled by user\n";
|
|
||||||
return { 0, "Request was cancelled by user", 0, "" };
|
|
||||||
}
|
|
||||||
else if (what.compare(what.size() - 20, 20, "Connection timed out") == 0)
|
|
||||||
{
|
|
||||||
ttdebug << what << "\n";
|
|
||||||
return { 110, "Connection timed out", 0, "" };
|
|
||||||
}
|
|
||||||
else if (what.compare(0, 23, "Could not resolve host:") == 0)
|
|
||||||
{
|
|
||||||
ttdebug << what << "\n";
|
|
||||||
return { 113, "Could not resolve host", 0, "" };
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parent.exceptions())
|
if (parent.exceptions())
|
||||||
{
|
{
|
||||||
std::rethrow_exception(std::current_exception());
|
e.rethrow();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ttdebug << "curlpp::RuntimeError: " << e.what() << std::endl;
|
|
||||||
return { 192, e.what(), 0, "" };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ttdebug << e.displayText() << "\n";
|
||||||
|
return { error::DNS, e.displayText(), 0, "" };
|
||||||
}
|
}
|
||||||
catch (curlpp::LogicError &e)
|
catch (const Poco::Net::ConnectionRefusedException &e)
|
||||||
|
{
|
||||||
|
if (parent.exceptions())
|
||||||
|
{
|
||||||
|
e.rethrow();
|
||||||
|
}
|
||||||
|
|
||||||
|
ttdebug << e.displayText() << "\n";
|
||||||
|
return { error::CONNECTION_REFUSED, e.displayText(), 0, "" };
|
||||||
|
}
|
||||||
|
catch (const Poco::Net::SSLException &e)
|
||||||
|
{
|
||||||
|
if (parent.exceptions())
|
||||||
|
{
|
||||||
|
e.rethrow();
|
||||||
|
}
|
||||||
|
|
||||||
|
ttdebug << e.displayText() << "\n";
|
||||||
|
return { error::ENCRYPTION, e.displayText(), 0, "" };
|
||||||
|
}
|
||||||
|
catch (const Poco::Net::NetException &e)
|
||||||
|
{
|
||||||
|
if (parent.exceptions())
|
||||||
|
{
|
||||||
|
e.rethrow();
|
||||||
|
}
|
||||||
|
|
||||||
|
ttdebug << "Unknown network error: " << e.displayText() << std::endl;
|
||||||
|
return { error::UNKNOWN, e.displayText(), 0, "" };
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
if (parent.exceptions())
|
if (parent.exceptions())
|
||||||
{
|
{
|
||||||
std::rethrow_exception(std::current_exception());
|
std::rethrow_exception(std::current_exception());
|
||||||
}
|
}
|
||||||
|
|
||||||
ttdebug << "curlpp::LogicError: " << e.what() << std::endl;
|
ttdebug << "Unknown error: " << e.what() << std::endl;
|
||||||
return { 193, e.what(), 0, "" };
|
return { error::UNKNOWN, e.what(), 0, "" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,26 +352,6 @@ void API::http::get_headers(string &headers) const
|
||||||
headers = _headers;
|
headers = _headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t API::http::callback_write(char* data, size_t size, size_t nmemb,
|
|
||||||
string *str)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(_mutex);
|
|
||||||
str->append(data, size * nmemb);
|
|
||||||
// ttdebug << "Received " << size * nmemb << " Bytes\n";
|
|
||||||
return size * nmemb;
|
|
||||||
}
|
|
||||||
|
|
||||||
double API::http::callback_progress(double /* dltotal */, double /* dlnow */,
|
|
||||||
double /* ultotal */, double /* ulnow */)
|
|
||||||
{
|
|
||||||
if (_cancel_stream)
|
|
||||||
{
|
|
||||||
// This throws the runtime error: Callback aborted
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void API::http::cancel_stream()
|
void API::http::cancel_stream()
|
||||||
{
|
{
|
||||||
_cancel_stream = true;
|
_cancel_stream = true;
|
||||||
|
|
|
@ -2,32 +2,34 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
|
||||||
#include <fstream>
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <Poco/Net/FilePartSource.h>
|
||||||
|
#include <Poco/URI.h>
|
||||||
#include "version.hpp"
|
#include "version.hpp"
|
||||||
#include "debug.hpp"
|
#include "debug.hpp"
|
||||||
#include "mastodon-cpp.hpp"
|
#include "mastodon-cpp.hpp"
|
||||||
|
|
||||||
using namespace Mastodon;
|
using namespace Mastodon;
|
||||||
|
using std::make_unique;
|
||||||
|
using Poco::Net::FilePartSource;
|
||||||
|
|
||||||
API::API(const string &instance, const string &access_token)
|
API::API(const string &instance, const string &access_token)
|
||||||
: _instance(instance)
|
: _instance(instance)
|
||||||
|
@ -35,8 +37,6 @@ API::API(const string &instance, const string &access_token)
|
||||||
, _useragent(string("mastodon-cpp/") + global::version)
|
, _useragent(string("mastodon-cpp/") + global::version)
|
||||||
, _http(*this, instance, access_token)
|
, _http(*this, instance, access_token)
|
||||||
, _exceptions(false)
|
, _exceptions(false)
|
||||||
, _proxy("")
|
|
||||||
, _proxy_userpw("")
|
|
||||||
{
|
{
|
||||||
bool fash = false;
|
bool fash = false;
|
||||||
const std::regex re_gab("(?:\\.|^)gab\\.[^\\.]+$");
|
const std::regex re_gab("(?:\\.|^)gab\\.[^\\.]+$");
|
||||||
|
@ -111,9 +111,12 @@ const string API::maptostr(const parameters &map, const bool &firstparam)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const curlpp::Forms API::maptoformdata(const parameters &map)
|
unique_ptr<HTMLForm> API::maptoformdata(const parameters &map)
|
||||||
{
|
{
|
||||||
curlpp::Forms formdata;
|
ttdebug << "Transforming Mastodon::parameters to Poco::Net::HTMLForm.\n";
|
||||||
|
|
||||||
|
unique_ptr<HTMLForm> formdata =
|
||||||
|
make_unique<HTMLForm>(HTMLForm::ENCODING_MULTIPART);
|
||||||
|
|
||||||
if (map.size() == 0)
|
if (map.size() == 0)
|
||||||
{
|
{
|
||||||
|
@ -122,51 +125,58 @@ const curlpp::Forms API::maptoformdata(const parameters &map)
|
||||||
|
|
||||||
for (const auto &it : map)
|
for (const auto &it : map)
|
||||||
{
|
{
|
||||||
|
string key = it.key;
|
||||||
|
ttdebug << "Processing \"" + key + "\".\n";
|
||||||
|
|
||||||
|
// TODO: Test nested parameters.
|
||||||
|
if (const size_t pos = key.find('.') != string::npos)
|
||||||
|
{ // Nested parameters.
|
||||||
|
key.replace(pos, 1, "[");
|
||||||
|
key += ']';
|
||||||
|
}
|
||||||
|
|
||||||
if (it.values.size() == 1)
|
if (it.values.size() == 1)
|
||||||
{ // If the file is not base64-encoded, treat as filename.
|
{ // If the file is not base64-encoded, treat as filename.
|
||||||
if ((it.key == "avatar" ||
|
if ((key == "avatar" ||
|
||||||
it.key == "header" ||
|
key == "header" ||
|
||||||
it.key == "file") &&
|
key == "file") &&
|
||||||
it.values.front().substr(0, 5) != "data:")
|
it.values.front().substr(0, 5) != "data:")
|
||||||
{
|
{
|
||||||
ttdebug << it.key << ": Filename detected.\n";
|
ttdebug << key << ": Filename detected.\n";
|
||||||
std::ifstream testfile(it.values.front());
|
|
||||||
if (testfile.good())
|
try
|
||||||
{
|
{
|
||||||
testfile.close();
|
formdata->addPart(key,
|
||||||
formdata.push_back(
|
new FilePartSource(it.values.front()));
|
||||||
new curlpp::FormParts::File(it.key, it.values.front()));
|
|
||||||
}
|
}
|
||||||
else
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
std::cerr << "Error: File not found: " << it.values.front()
|
if (exceptions())
|
||||||
<< std::endl;
|
{
|
||||||
|
std::rethrow_exception(std::current_exception());
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Proper error handling without exceptions.
|
||||||
|
std::cerr << "Error: Could not open file: "
|
||||||
|
<< it.values.front() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (key == "account_ids"
|
||||||
{
|
|
||||||
string key = it.key;
|
|
||||||
// Append [] to array keys.
|
|
||||||
if (key == "account_ids"
|
|
||||||
|| key == "exclude_types"
|
|| key == "exclude_types"
|
||||||
|| key == "media_ids"
|
|| key == "media_ids"
|
||||||
|| key == "context")
|
|| key == "context")
|
||||||
{
|
{
|
||||||
key += "[]";
|
key += "[]";
|
||||||
}
|
|
||||||
formdata.push_back(
|
|
||||||
new curlpp::FormParts::Content(key, it.values.front()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
formdata->add(key, it.values.front());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::transform(it.values.begin(), it.values.end(),
|
for (const string &value : it.values)
|
||||||
std::back_inserter(formdata),
|
{
|
||||||
[&it](const string &s)
|
formdata->add(key + "[]", value);
|
||||||
{
|
}
|
||||||
return new curlpp::FormParts::Content
|
|
||||||
(it.key + "[]", s);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,11 +266,18 @@ return_call API::register_app2(const string &client_id,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
const string API::get_header(const std::string &header) const
|
const string API::get_header(std::string header) const
|
||||||
{
|
{
|
||||||
string headers;
|
string headers;
|
||||||
|
string headers_lower;
|
||||||
_http.get_headers(headers);
|
_http.get_headers(headers);
|
||||||
size_t startpos = headers.find(header + ':');
|
headers_lower.resize(headers.size());
|
||||||
|
|
||||||
|
std::transform(headers.begin(), headers.end(),
|
||||||
|
headers_lower.begin(), ::tolower);
|
||||||
|
std::transform(header.begin(), header.end(), header.begin(), ::tolower);
|
||||||
|
|
||||||
|
size_t startpos = headers_lower.find(header + ':');
|
||||||
if (startpos != std::string::npos)
|
if (startpos != std::string::npos)
|
||||||
{
|
{
|
||||||
startpos = headers.find(':', startpos) + 2;
|
startpos = headers.find(':', startpos) + 2;
|
||||||
|
@ -282,22 +299,9 @@ bool API::exceptions() const
|
||||||
return _exceptions;
|
return _exceptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
void API::set_proxy(const string &proxy, const string &userpw)
|
void API::set_proxy(const string &hostport, const string &userpw)
|
||||||
{
|
{
|
||||||
_proxy = proxy;
|
_http.set_proxy(hostport, userpw);
|
||||||
_proxy_userpw = userpw;
|
|
||||||
}
|
|
||||||
|
|
||||||
void API::get_proxy(string &proxy, string &userpw) const
|
|
||||||
{
|
|
||||||
if (!_proxy.empty())
|
|
||||||
{
|
|
||||||
proxy = _proxy;
|
|
||||||
if (!_proxy_userpw.empty())
|
|
||||||
{
|
|
||||||
userpw = _proxy_userpw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const parameters API::delete_params(const parameters ¶ms,
|
const parameters API::delete_params(const parameters ¶ms,
|
||||||
|
@ -311,7 +315,7 @@ const parameters API::delete_params(const parameters ¶ms,
|
||||||
std::copy_if(params.begin(), params.end(), newparams.begin(),
|
std::copy_if(params.begin(), params.end(), newparams.begin(),
|
||||||
[&keys](const param &p)
|
[&keys](const param &p)
|
||||||
{
|
{
|
||||||
return std::any_of(keys.begin(), keys.end(),
|
return std::all_of(keys.begin(), keys.end(),
|
||||||
[&p](const string &k)
|
[&p](const string &k)
|
||||||
{
|
{
|
||||||
return (k != p.key);
|
return (k != p.key);
|
||||||
|
@ -323,11 +327,16 @@ const parameters API::delete_params(const parameters ¶ms,
|
||||||
|
|
||||||
const string Mastodon::urlencode(const std::string &str)
|
const string Mastodon::urlencode(const std::string &str)
|
||||||
{
|
{
|
||||||
return curlpp::escape(str);
|
string out;
|
||||||
|
Poco::URI::encode(str, "", out);
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
const string Mastodon::urldecode(const std::string &str)
|
const string Mastodon::urldecode(const std::string &str)
|
||||||
{
|
{
|
||||||
return curlpp::unescape(str);
|
string out;
|
||||||
|
Poco::URI::decode(str, out);
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
const string Mastodon::unescape_html(const string &html)
|
const string Mastodon::unescape_html(const string &html)
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -25,14 +25,15 @@
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <curlpp/cURLpp.hpp>
|
#include <Poco/Net/HTMLForm.h>
|
||||||
#include <curlpp/Easy.hpp>
|
|
||||||
|
|
||||||
#include "return_types.hpp"
|
#include "return_types.hpp"
|
||||||
#include "types.hpp"
|
#include "types.hpp"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::uint8_t;
|
using std::uint8_t;
|
||||||
|
using std::unique_ptr;
|
||||||
|
using Poco::Net::HTMLForm;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @example example01_get_public_timeline.cpp
|
* @example example01_get_public_timeline.cpp
|
||||||
|
@ -55,14 +56,13 @@ namespace Mastodon
|
||||||
* | Code | Explanation |
|
* | Code | Explanation |
|
||||||
* | --------: |:-------------------------------------------|
|
* | --------: |:-------------------------------------------|
|
||||||
* | 0 | No error |
|
* | 0 | No error |
|
||||||
* | 22 | Invalid argument |
|
* | 1 | Invalid argument |
|
||||||
* | 78 | URL changed (HTTP 301 or 308) |
|
* | 10 | URL changed (HTTP 301 or 308) |
|
||||||
* | 110 | Connection timed out |
|
* | 11 | Connection timed out |
|
||||||
* | 111 | Connection refused (check http_error_code) |
|
* | 12 | Connection refused (check http_error_code) |
|
||||||
* | 113 | No route to host / Could not resolve host |
|
* | 13 | No route to host / Could not resolve host |
|
||||||
* | 192 | curlpp runtime error |
|
* | 14 | Encryption error |
|
||||||
* | 193 | curlpp logic error |
|
* | 127 | Unknown error |
|
||||||
* | 255 | Unknown error |
|
|
||||||
*
|
*
|
||||||
* @since before 0.11.0
|
* @since before 0.11.0
|
||||||
*/
|
*/
|
||||||
|
@ -102,7 +102,7 @@ namespace Mastodon
|
||||||
*/
|
*/
|
||||||
return_call request(const http_method &meth,
|
return_call request(const http_method &meth,
|
||||||
const string &path,
|
const string &path,
|
||||||
const curlpp::Forms &formdata);
|
HTMLForm &formdata);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief HTTP Request for streams.
|
* @brief HTTP Request for streams.
|
||||||
|
@ -142,6 +142,16 @@ namespace Mastodon
|
||||||
*/
|
*/
|
||||||
std::mutex &get_mutex();
|
std::mutex &get_mutex();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Set proxy. Do not call this directly.
|
||||||
|
*
|
||||||
|
* @param hostport host[:port]
|
||||||
|
* @param userpw user[:password] (optional)
|
||||||
|
*
|
||||||
|
* @since 0.110.0
|
||||||
|
*/
|
||||||
|
void set_proxy(const string &hostport, const string &userpw = "");
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const API &parent;
|
const API &parent;
|
||||||
const string _instance;
|
const string _instance;
|
||||||
|
@ -153,7 +163,7 @@ namespace Mastodon
|
||||||
|
|
||||||
return_call request_common(const http_method &meth,
|
return_call request_common(const http_method &meth,
|
||||||
const string &path,
|
const string &path,
|
||||||
const curlpp::Forms &formdata,
|
HTMLForm &formdata,
|
||||||
string &answer);
|
string &answer);
|
||||||
size_t callback_write(char* data, size_t size, size_t nmemb,
|
size_t callback_write(char* data, size_t size, size_t nmemb,
|
||||||
string *oss);
|
string *oss);
|
||||||
|
@ -216,8 +226,8 @@ namespace Mastodon
|
||||||
|
|
||||||
lists,
|
lists,
|
||||||
accounts_id_lists,
|
accounts_id_lists,
|
||||||
lists_id,
|
|
||||||
lists_id_accounts,
|
lists_id_accounts,
|
||||||
|
lists_id,
|
||||||
|
|
||||||
media,
|
media,
|
||||||
media_id,
|
media_id,
|
||||||
|
@ -234,37 +244,39 @@ namespace Mastodon
|
||||||
notifications_dismiss,
|
notifications_dismiss,
|
||||||
push_subscription,
|
push_subscription,
|
||||||
|
|
||||||
|
polls_id,
|
||||||
|
polls_id_votes,
|
||||||
|
|
||||||
reports,
|
reports,
|
||||||
|
|
||||||
// scheduled_statuses,
|
// scheduled_statuses,
|
||||||
// scheduled_statuses_id,
|
// scheduled_statuses_id,
|
||||||
|
|
||||||
search,
|
|
||||||
|
|
||||||
statuses,
|
|
||||||
statuses_id,
|
statuses_id,
|
||||||
statuses_id_context,
|
statuses_id_context,
|
||||||
statuses_id_card,
|
statuses_id_card,
|
||||||
statuses_id_reblogged_by,
|
statuses_id_reblogged_by,
|
||||||
statuses_id_favourited_by,
|
statuses_id_favourited_by,
|
||||||
|
statuses,
|
||||||
statuses_id_reblog,
|
statuses_id_reblog,
|
||||||
statuses_id_unreblog,
|
statuses_id_unreblog,
|
||||||
statuses_id_pin,
|
statuses_id_pin,
|
||||||
statuses_id_unpin,
|
statuses_id_unpin,
|
||||||
|
|
||||||
timelines_home,
|
timelines_home,
|
||||||
// timelines_conversations,
|
conversations,
|
||||||
timelines_public,
|
timelines_public,
|
||||||
timelines_tag_hashtag,
|
timelines_tag_hashtag,
|
||||||
timelines_list_list_id,
|
timelines_list_list_id,
|
||||||
|
|
||||||
|
streaming_health,
|
||||||
streaming_user,
|
streaming_user,
|
||||||
streaming_public,
|
streaming_public,
|
||||||
streaming_public_local,
|
streaming_public_local,
|
||||||
streaming_hashtag,
|
streaming_hashtag,
|
||||||
// streaming_hashtag_local,
|
streaming_hashtag_local,
|
||||||
streaming_list,
|
streaming_list,
|
||||||
// streaming_direct,
|
streaming_direct,
|
||||||
|
|
||||||
// Glitch-Soc
|
// Glitch-Soc
|
||||||
bookmarks,
|
bookmarks,
|
||||||
|
@ -399,7 +411,7 @@ namespace Mastodon
|
||||||
string &access_token);
|
string &access_token);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Gets the header from the last answer.
|
* @brief Gets the header from the last answer. Case insensitive.
|
||||||
*
|
*
|
||||||
* @param header The header to get
|
* @param header The header to get
|
||||||
*
|
*
|
||||||
|
@ -407,13 +419,12 @@ namespace Mastodon
|
||||||
*
|
*
|
||||||
* @since before 0.11.0
|
* @since before 0.11.0
|
||||||
*/
|
*/
|
||||||
const string get_header(const string &header) const;
|
const string get_header(string header) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Turn exceptions on or off. Defaults to off.
|
* @brief Turn exceptions on or off. Defaults to off.
|
||||||
*
|
*
|
||||||
* This applies to exceptions from curlpp. curlpp::RuntimeError
|
* Most exceptions will be thrown at you to handle if on.
|
||||||
* and curlpp::LogicError.
|
|
||||||
*
|
*
|
||||||
* @param value true for on, false for off
|
* @param value true for on, false for off
|
||||||
*
|
*
|
||||||
|
@ -439,25 +450,15 @@ namespace Mastodon
|
||||||
/*!
|
/*!
|
||||||
* @brief Sets the proxy.
|
* @brief Sets the proxy.
|
||||||
*
|
*
|
||||||
* Since mastodon-cpp is built on libcurl, it respects the same
|
* Both the username and the password will be URL decoded
|
||||||
* proxy environment variables. See `man curl`.
|
* before use.
|
||||||
*
|
*
|
||||||
* @param proxy See `man 3 CURLOPT_PROXY`
|
* @param hostport host[:port]
|
||||||
* @param userpw See `man 3 CURLOPT_PROXYUSERPWD` (optional)
|
* @param userpw username[:password] (optional)
|
||||||
*
|
*
|
||||||
* @since 0.15.0
|
* @since 0.15.0
|
||||||
*/
|
*/
|
||||||
void set_proxy(const string &proxy, const string &userpw = "");
|
void set_proxy(const string &hostport, const string &userpw = "");
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief For internal use
|
|
||||||
*
|
|
||||||
* @param proxy URL
|
|
||||||
* @param userpw username:password
|
|
||||||
*
|
|
||||||
* @since 0.15.1
|
|
||||||
*/
|
|
||||||
void get_proxy(string &proxy, string &userpw) const;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Make a GET request that doesn't require parameters.
|
* @brief Make a GET request that doesn't require parameters.
|
||||||
|
@ -514,7 +515,7 @@ namespace Mastodon
|
||||||
*/
|
*/
|
||||||
void get_stream(const Mastodon::API::v1 &call,
|
void get_stream(const Mastodon::API::v1 &call,
|
||||||
const parameters ¶meters,
|
const parameters ¶meters,
|
||||||
std::unique_ptr<Mastodon::API::http> &ptr,
|
unique_ptr<Mastodon::API::http> &ptr,
|
||||||
string &stream);
|
string &stream);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -527,7 +528,7 @@ namespace Mastodon
|
||||||
* @since 0.100.0
|
* @since 0.100.0
|
||||||
*/
|
*/
|
||||||
void get_stream(const Mastodon::API::v1 &call,
|
void get_stream(const Mastodon::API::v1 &call,
|
||||||
std::unique_ptr<Mastodon::API::http> &ptr,
|
unique_ptr<Mastodon::API::http> &ptr,
|
||||||
string &stream);
|
string &stream);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -540,7 +541,7 @@ namespace Mastodon
|
||||||
* @since 0.100.0
|
* @since 0.100.0
|
||||||
*/
|
*/
|
||||||
void get_stream(const string &call,
|
void get_stream(const string &call,
|
||||||
std::unique_ptr<Mastodon::API::http> &ptr,
|
unique_ptr<Mastodon::API::http> &ptr,
|
||||||
string &stream);
|
string &stream);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -646,8 +647,6 @@ namespace Mastodon
|
||||||
string _useragent;
|
string _useragent;
|
||||||
http _http;
|
http _http;
|
||||||
bool _exceptions;
|
bool _exceptions;
|
||||||
string _proxy;
|
|
||||||
string _proxy_userpw;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Converts map of parameters into a string.
|
* @brief Converts map of parameters into a string.
|
||||||
|
@ -665,9 +664,9 @@ namespace Mastodon
|
||||||
*
|
*
|
||||||
* @param map Map of parameters
|
* @param map Map of parameters
|
||||||
*
|
*
|
||||||
* @return Form data as curlpp::Forms
|
* @return Form data as Poco::Net::HTMLForm.
|
||||||
*/
|
*/
|
||||||
const curlpp::Forms maptoformdata(const parameters &map);
|
unique_ptr<HTMLForm> maptoformdata(const parameters &map);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Delete Mastodon::param from Mastodon::parameters.
|
* @brief Delete Mastodon::param from Mastodon::parameters.
|
||||||
|
@ -684,13 +683,12 @@ namespace Mastodon
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Percent-encodes a string. This is done automatically, unless
|
* @brief Percent-encodes a string.
|
||||||
* you make a custom request.
|
|
||||||
*
|
*
|
||||||
* Calls curlpp::escape(str).
|
|
||||||
*
|
*
|
||||||
* The only time you should use this, is if you use
|
* This is done automatically where necessary. The only time you
|
||||||
* get(const string &call, string &answer).
|
* should use this, is if you use get(const string &call, string
|
||||||
|
* &answer).
|
||||||
*
|
*
|
||||||
* See RFC 3986 section 2.1 for more info.
|
* See RFC 3986 section 2.1 for more info.
|
||||||
*
|
*
|
||||||
|
@ -705,8 +703,6 @@ namespace Mastodon
|
||||||
/*!
|
/*!
|
||||||
* @brief Decodes a percent-encoded string.
|
* @brief Decodes a percent-encoded string.
|
||||||
*
|
*
|
||||||
* Calls curlpp::unescape(str).
|
|
||||||
*
|
|
||||||
* See RFC 3986 section 2.1 for more info.
|
* See RFC 3986 section 2.1 for more info.
|
||||||
*
|
*
|
||||||
* @param str The string to decode.
|
* @param str The string to decode.
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -57,4 +57,13 @@ namespace Mastodon
|
||||||
error_message = em;
|
error_message = em;
|
||||||
http_error_code = hec;
|
http_error_code = hec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return_call::return_call(const error ec, const string &em,
|
||||||
|
const uint16_t hec, const string &a)
|
||||||
|
: answer(a)
|
||||||
|
{
|
||||||
|
error_code = static_cast<uint8_t>(ec);
|
||||||
|
error_message = em;
|
||||||
|
http_error_code = hec;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "types.hpp"
|
||||||
|
|
||||||
using std::uint8_t;
|
using std::uint8_t;
|
||||||
using std::uint16_t;
|
using std::uint16_t;
|
||||||
|
@ -113,6 +114,19 @@ namespace Mastodon
|
||||||
return_call(const uint8_t ec, const string &em,
|
return_call(const uint8_t ec, const string &em,
|
||||||
const uint16_t hec, const string &a);
|
const uint16_t hec, const string &a);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Return type for Mastodon::API.
|
||||||
|
*
|
||||||
|
* @param ec Error code
|
||||||
|
* @param em Error message
|
||||||
|
* @param hec HTTP error code
|
||||||
|
* @param a Answer
|
||||||
|
*
|
||||||
|
* @since 0.110.0
|
||||||
|
*/
|
||||||
|
return_call(const error ec, const string &em,
|
||||||
|
const uint16_t hec, const string &a);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Same es return_call::answer.
|
* @brief Same es return_call::answer.
|
||||||
*
|
*
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -93,6 +93,18 @@ namespace Mastodon
|
||||||
DELETE,
|
DELETE,
|
||||||
GET_STREAM
|
GET_STREAM
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class error
|
||||||
|
{
|
||||||
|
OK = 0,
|
||||||
|
INVALID_ARGUMENT = 1,
|
||||||
|
URL_CHANGED = 10,
|
||||||
|
CONNECTION_TIMEOUT = 11,
|
||||||
|
CONNECTION_REFUSED = 12,
|
||||||
|
DNS = 13,
|
||||||
|
ENCRYPTION = 14,
|
||||||
|
UNKNOWN = 127
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MASTODON_CPP_TYPES_HPP
|
#endif // MASTODON_CPP_TYPES_HPP
|
||||||
|
|
|
@ -1,20 +1,23 @@
|
||||||
include(CTest)
|
include(CTest)
|
||||||
file(GLOB sources_tests test_*.cpp */test_*.cpp)
|
|
||||||
|
file(GLOB_RECURSE sources_tests test_*.cpp)
|
||||||
|
|
||||||
|
configure_file("test.gif" "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY)
|
||||||
|
|
||||||
find_package(Catch2)
|
find_package(Catch2)
|
||||||
if(Catch2_FOUND) # Catch 2.x
|
if(Catch2_FOUND) # Catch 2.x
|
||||||
include(Catch)
|
include(Catch)
|
||||||
add_executable(all_tests main.cpp ${sources_tests})
|
add_executable(all_tests main.cpp ${sources_tests})
|
||||||
target_link_libraries(all_tests ${PROJECT_NAME} Catch2::Catch2)
|
target_link_libraries(all_tests PRIVATE ${PROJECT_NAME} Catch2::Catch2)
|
||||||
target_include_directories(all_tests PRIVATE "/usr/include/catch2")
|
target_include_directories(all_tests PRIVATE "/usr/include/catch2")
|
||||||
catch_discover_tests(all_tests EXTRA_ARGS "${EXTRA_TEST_ARGS}")
|
catch_discover_tests(all_tests EXTRA_ARGS "${EXTRA_TEST_ARGS}")
|
||||||
else() # Catch 1.x
|
else() # Catch 1.x
|
||||||
if(EXISTS "/usr/include/catch.hpp")
|
if(EXISTS "/usr/include/catch.hpp")
|
||||||
message(STATUS "Catch 1.x found.")
|
message(STATUS "Catch 1.x found.")
|
||||||
foreach(src ${sources_tests})
|
foreach(src ${sources_tests})
|
||||||
get_filename_component(bin ${src} NAME_WE)
|
get_filename_component(bin ${src} NAME_WE)
|
||||||
add_executable(${bin} main.cpp ${src})
|
add_executable(${bin} main.cpp ${src})
|
||||||
target_link_libraries(${bin} ${PROJECT_NAME})
|
target_link_libraries(${bin} PRIVATE ${PROJECT_NAME})
|
||||||
add_test(${bin} ${bin} "${EXTRA_TEST_ARGS}")
|
add_test(${bin} ${bin} "${EXTRA_TEST_ARGS}")
|
||||||
endforeach()
|
endforeach()
|
||||||
else()
|
else()
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
* the Free Software Foundation, version 3.
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue