Compare commits

...

18 Commits

Author SHA1 Message Date
tastytea 4b7215036b
Recommend switching to mastodonpp.
continuous-integration/drone/push Build is passing Details
2020-01-16 23:47:25 +01:00
tastytea e65fadfba6
Add low-maintenance note.
continuous-integration/drone/push Build is passing Details
2020-01-03 06:20:38 +01:00
tastytea fd407094a2
Add package for Ubuntu bionic. 2019-12-26 03:19:32 +01:00
tastytea 76e12d7093
Drone: Install lsb-release.
continuous-integration/drone/push Build is passing Details
2019-12-25 21:16:47 +01:00
tastytea 2a9219ce7e
Drone: Don't fail if file to delete doesn't exist. 2019-12-25 21:06:57 +01:00
tastytea cacc2c3a5b
Build packages for Debian stretch and buster. 2019-12-25 20:53:14 +01:00
tastytea ceda771700
Version bump 0.111.3.
continuous-integration/drone/push Build is passing Details
2019-12-19 15:16:24 +01:00
tastytea c6ad04e6ee
Typo in CMake config.
continuous-integration/drone/push Build was killed Details
2019-12-19 15:15:21 +01:00
tastytea 9671407556
Different indentation for CMake files. 2019-12-19 15:14:59 +01:00
tastytea c35dab8350
Merge branch 'develop'
continuous-integration/drone/push Build is passing Details
2019-10-14 12:06:43 +02:00
tastytea c772d7b60e
Improved introduction.
continuous-integration/drone/push Build is passing Details
2019-10-14 00:01:13 +02:00
tastytea e1b61b5041
Deprecated return_entity(_vector) and some high-level abstractions.
send_post(), send_toot() and get_notifications().
I don't have the energy to implement and maintain an useful set of high-level
abstractions.
2019-10-13 23:56:39 +02:00
tastytea db95855ab6
Merge branch 'develop'
continuous-integration/drone/push Build is passing Details
2019-10-13 21:05:34 +02:00
tastytea 5dce94a4a3
Add Emoji example.
continuous-integration/drone/push Build is passing Details
2019-10-13 17:39:49 +02:00
tastytea 7adad67dd9
Install examples into the correct directory. 2019-10-13 16:34:42 +02:00
tastytea 5275ab73ac
Version bump 0.111.2.
continuous-integration/drone/push Build is passing Details
2019-10-07 23:07:32 +02:00
tastytea a50d28e9a2
Merge branch 'develop' 2019-10-07 23:07:16 +02:00
tastytea 57238020a3
Do not return lowercased header, but the original one. 2019-10-07 23:06:15 +02:00
12 changed files with 148 additions and 40 deletions

View File

@ -25,8 +25,8 @@ steps:
MASTODON_CPP_ACCESS_TOKEN:
from_secret: mastodon_cpp_access_token
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- rm /var/cache/apt/archives/lock
- 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
- apt-get install -qy libpoco-dev libjsoncpp-dev doxygen catch
@ -48,8 +48,8 @@ steps:
MASTODON_CPP_ACCESS_TOKEN:
from_secret: mastodon_cpp_access_token
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- rm /var/cache/apt/archives/lock
- rm -f /etc/apt/apt.conf.d/docker-clean
- rm -f /var/cache/apt/archives/lock
- apt-get update -q
- 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
@ -77,8 +77,8 @@ steps:
MASTODON_CPP_ACCESS_TOKEN:
from_secret: mastodon_cpp_access_token
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- rm /var/cache/apt/archives/lock
- rm -f /etc/apt/apt.conf.d/docker-clean
- rm -f /var/cache/apt/archives/lock
- 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
@ -104,8 +104,8 @@ steps:
MASTODON_CPP_ACCESS_TOKEN:
from_secret: mastodon_cpp_access_token
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- rm /var/cache/apt/archives/lock
- rm -f /etc/apt/apt.conf.d/docker-clean
- rm -f /var/cache/apt/archives/lock
- apt-get update -q
- apt-get update -q
- apt-get install -qy build-essential cmake clang
@ -153,34 +153,73 @@ trigger:
- tag
steps:
- name: deb
- name: Debian stretch
image: debian:stretch-slim
pull: always
environment:
CXXFLAGS: -pipe -O2
LANG: C.utf8
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- rm /var/cache/apt/archives/lock
- 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
- apt-get install -qy libpoco-dev libjsoncpp-dev doxygen file
- 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_DOC=NO ..
- make package
- cmake -DWITH_DEB=YES -DWITH_DOC=NO ..
- make package
- cp -v mastodon-cpp-${DRONE_TAG}_x86_64.tar.gz ..
- cp -v libmastodon-cpp_${DRONE_TAG}-0_amd64.deb ..
- cp -v libmastodon-cpp_${DRONE_TAG}-0_stretch_amd64.deb ..
volumes:
- name: debian-package-cache
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
pull: always
environment:
CXX: /opt/rh/devtoolset-6/root/usr/bin/g++
CXXFLAGS: -pipe -O2
LANG: C.utf8
commands:
- 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
@ -191,8 +230,6 @@ steps:
- yum install -qy poco-devel openssl-devel doxygen rpm-build
- yum --enablerepo=epel install -qy cmake3 jsoncpp-devel
- rm -rf build && mkdir -p build && cd build
- cmake3 -DWITH_EXAMPLES=NO -DWITH_TESTS=NO ..
- make package
- cmake3 -DWITH_RPM=YES -DWITH_DOC=NO ..
- make package
- cp -v libmastodon-cpp-${DRONE_TAG}-0.x86_64.rpm ..
@ -210,8 +247,9 @@ steps:
title: ${DRONE_TAG}
prerelease: true
files:
- mastodon-cpp-${DRONE_TAG}_x86_64.tar.gz
- libmastodon-cpp_${DRONE_TAG}-0_amd64.deb
- libmastodon-cpp_${DRONE_TAG}-0_stretch_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
checksum:
- sha256

View File

@ -5,10 +5,16 @@ root = true
[*]
indent_style = space
indent_size = 4
tab_width = 4
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

View File

@ -9,7 +9,7 @@ endif()
include(GNUInstallDirs)
project (mastodon-cpp
VERSION 0.111.1
VERSION 0.111.5
LANGUAGES CXX)
# DESCRIPTION was introduced in version 3.9.

View File

@ -3,9 +3,18 @@
: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
[IMPORTANT]
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 or easy to use abstractions.
and get the raw JSON that you can then transform into easy to use abstractions.
== Usage
@ -77,10 +86,6 @@ Not included in this list are entities.
==== Return types
* `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

View File

@ -1,7 +1,7 @@
include(CMakeFindDependencyMacro)
include(GNUInstallDirs)
find_depencency(jsoncpp CONFIG REQUIRED)
find_dependency(jsoncpp CONFIG REQUIRED)
find_package(Poco COMPONENTS Foundation Net NetSSL CONFIG REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")

View File

@ -26,8 +26,11 @@ if (WITH_DEB)
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_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
"${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-0_${DEBIAN_CODENAME}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
endif()
if (WITH_RPM)

View File

@ -7,5 +7,5 @@ endforeach()
if(WITH_DOC)
install(FILES ${sources_examples}
DESTINATION "${CMAKE_INSTALL_DOCDIR}/examples")
DESTINATION "${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME}/examples")
endif()

View File

@ -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

View File

@ -167,6 +167,7 @@ namespace Easy
*
* @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);
/*!
@ -174,6 +175,7 @@ namespace Easy
*
* @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);
/*!
@ -187,6 +189,7 @@ namespace Easy
*
* @since 0.100.0
*/
[[deprecated("Will go away in 1.0.0 with no replacement.")]]
const return_entity_vector<Easy::Notification> get_notifications(
const uint16_t limit = 20, const string since_id = "",
const string max_id = "");

View File

@ -36,8 +36,9 @@ namespace Easy
*
* @since 0.100.0
*/
template <typename T>
struct return_entity : return_base
template <typename T> struct
[[deprecated("Will go away in 1.0.0 with no replacement.")]]
return_entity : return_base
{
/*!
* @brief Mastodon::Easy::Entity
@ -107,8 +108,9 @@ namespace Easy
*
* @since 0.100.0
*/
template <typename T>
struct return_entity_vector : return_base
template <typename T> struct
[[deprecated("Will go away in 1.0.0 with no replacement.")]]
return_entity_vector : return_base
{
/*!
* @brief std::vector of Mastodon::Easy::Entity.

View File

@ -347,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
{
headers = _headers;

View File

@ -269,11 +269,15 @@ return_call API::register_app2(const string &client_id,
const string API::get_header(std::string header) const
{
string headers;
string headers_lower;
_http.get_headers(headers);
std::transform(headers.begin(), headers.end(), headers.begin(), ::tolower);
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.find(header + ':');
size_t startpos = headers_lower.find(header + ':');
if (startpos != std::string::npos)
{
startpos = headers.find(':', startpos) + 2;