Compare commits
38 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 |
86
.drone.yml
86
.drone.yml
|
@ -25,8 +25,8 @@ 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
|
||||||
- apt-get install -qy build-essential cmake
|
- apt-get install -qy build-essential cmake
|
||||||
- apt-get install -qy libpoco-dev libjsoncpp-dev doxygen catch
|
- apt-get install -qy libpoco-dev libjsoncpp-dev doxygen catch
|
||||||
|
@ -48,8 +48,8 @@ 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://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
|
||||||
|
@ -77,8 +77,8 @@ 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
|
||||||
|
@ -104,8 +104,8 @@ 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
|
||||||
- apt-get update -q
|
- apt-get update -q
|
||||||
- apt-get install -qy build-essential cmake clang
|
- apt-get install -qy build-essential cmake clang
|
||||||
|
@ -153,34 +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
|
||||||
- apt-get update -q
|
- apt-get update -q
|
||||||
- apt-get install -qy build-essential cmake
|
- apt-get install -qy build-essential cmake lsb-release
|
||||||
- apt-get install -qy libpoco-dev libjsoncpp-dev doxygen file
|
- apt-get install -qy libpoco-dev libjsoncpp-dev 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
|
||||||
|
@ -191,9 +230,7 @@ steps:
|
||||||
- yum install -qy poco-devel openssl-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
|
||||||
- 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:
|
||||||
|
@ -210,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
|
|
@ -9,7 +9,7 @@ endif()
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
project (mastodon-cpp
|
project (mastodon-cpp
|
||||||
VERSION 0.110.0
|
VERSION 0.111.5
|
||||||
LANGUAGES CXX)
|
LANGUAGES CXX)
|
||||||
|
|
||||||
# DESCRIPTION was introduced in version 3.9.
|
# DESCRIPTION was introduced in version 3.9.
|
||||||
|
@ -77,7 +77,7 @@ if(WITH_DOC)
|
||||||
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_DOCDIR}")
|
DESTINATION "${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory("cmake")
|
add_subdirectory("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.
|
|
37
README.adoc
37
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
|
||||||
|
|
||||||
|
@ -132,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
|
||||||
|
@ -191,7 +194,7 @@ apt-get install build-essential cmake libpoco-dev libjsoncpp-dev doxygen
|
||||||
===== 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
|
||||||
|
|
||||||
|
@ -256,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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
include(CMakeFindDependencyMacro)
|
include(CMakeFindDependencyMacro)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
find_depencency(jsoncpp CONFIG REQUIRED)
|
find_dependency(jsoncpp CONFIG REQUIRED)
|
||||||
find_package(Poco COMPONENTS Foundation Net NetSSL CONFIG REQUIRED)
|
find_package(Poco COMPONENTS Foundation Net NetSSL CONFIG REQUIRED)
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
|
||||||
|
|
|
@ -26,8 +26,11 @@ if (WITH_DEB)
|
||||||
execute_process(COMMAND dpkg --print-architecture
|
execute_process(COMMAND dpkg --print-architecture
|
||||||
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
|
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
execute_process(COMMAND lsb_release --codename --short
|
||||||
|
OUTPUT_VARIABLE DEBIAN_CODENAME
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
set(CPACK_PACKAGE_FILE_NAME
|
set(CPACK_PACKAGE_FILE_NAME
|
||||||
"${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-0_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
|
"${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-0_${DEBIAN_CODENAME}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WITH_RPM)
|
if (WITH_RPM)
|
||||||
|
|
|
@ -7,5 +7,5 @@ endforeach()
|
||||||
|
|
||||||
if(WITH_DOC)
|
if(WITH_DOC)
|
||||||
install(FILES ${sources_examples}
|
install(FILES ${sources_examples}
|
||||||
DESTINATION "${CMAKE_INSTALL_DOCDIR}/examples")
|
DESTINATION "${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME}/examples")
|
||||||
endif()
|
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
|
|
@ -56,7 +56,7 @@ endif()
|
||||||
|
|
||||||
install(TARGETS ${PROJECT_NAME}
|
install(TARGETS ${PROJECT_NAME}
|
||||||
EXPORT "${PROJECT_NAME}Targets"
|
EXPORT "${PROJECT_NAME}Targets"
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
|
||||||
install(FILES mastodon-cpp.hpp return_types.hpp types.hpp
|
install(FILES mastodon-cpp.hpp return_types.hpp types.hpp
|
||||||
|
|
|
@ -101,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))
|
||||||
|
@ -134,3 +134,8 @@ const string Easy::Link::since_id() const
|
||||||
{
|
{
|
||||||
return _prev;
|
return _prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const string Easy::Link::min_id() const
|
||||||
|
{
|
||||||
|
return _prev;
|
||||||
|
}
|
||||||
|
|
|
@ -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 = "");
|
||||||
|
|
|
@ -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
|
||||||
|
@ -107,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.
|
||||||
|
|
|
@ -234,13 +234,17 @@ return_call API::http::request_common(const http_method &meth,
|
||||||
}
|
}
|
||||||
|
|
||||||
HTTPResponse response;
|
HTTPResponse response;
|
||||||
istream &rs = session.receiveResponse(response);
|
istream &body_stream = session.receiveResponse(response);
|
||||||
|
|
||||||
const uint16_t http_code = response.getStatus();
|
const uint16_t http_code = response.getStatus();
|
||||||
ttdebug << "Response code: " << http_code << '\n';
|
ttdebug << "Response code: " << http_code << '\n';
|
||||||
|
|
||||||
answer.clear();
|
answer.clear();
|
||||||
StreamCopier::copyToString(rs, answer);
|
StreamCopier::copyToString(body_stream, answer);
|
||||||
|
|
||||||
|
std::ostringstream headers_stream;
|
||||||
|
response.write(headers_stream);
|
||||||
|
_headers = headers_stream.str();
|
||||||
|
|
||||||
switch (http_code)
|
switch (http_code)
|
||||||
{
|
{
|
||||||
|
@ -343,7 +347,6 @@ return_call API::http::request_common(const http_method &meth,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: get_headers() doesn't work anymore.
|
|
||||||
void API::http::get_headers(string &headers) const
|
void API::http::get_headers(string &headers) const
|
||||||
{
|
{
|
||||||
headers = _headers;
|
headers = _headers;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <algorithm>
|
||||||
#include <Poco/Net/FilePartSource.h>
|
#include <Poco/Net/FilePartSource.h>
|
||||||
#include <Poco/URI.h>
|
#include <Poco/URI.h>
|
||||||
#include "version.hpp"
|
#include "version.hpp"
|
||||||
|
@ -265,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;
|
||||||
|
@ -307,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);
|
||||||
|
|
|
@ -411,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
|
||||||
*
|
*
|
||||||
|
@ -419,7 +419,7 @@ 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.
|
||||||
|
|
Reference in New Issue