Renamed uploaded file structs
This commit is contained in:
@@ -107,32 +107,32 @@ namespace matrix{
|
||||
* Returns: file_info struct containing the url of the file on the homeserver.
|
||||
* Note check the file_info::fileurl field to check if the upload succeeded.
|
||||
*/
|
||||
file_info upload_file(const file_details& file)const;
|
||||
uploaded_file upload_file(const file_details& file)const;
|
||||
|
||||
/*
|
||||
* Upload a file as an image.
|
||||
* Returns: image_info struct containing the url of the image on the homeserver.
|
||||
* Note check the image_info::fileurl field to check if the upload succeeded.
|
||||
*/
|
||||
image_info upload_image(const image_details& file)const;
|
||||
uploaded_image upload_image(const image_details& file)const;
|
||||
|
||||
/*
|
||||
* Upload data as a video.
|
||||
* Returns: video_info struct containing the url of the image on the homeserver.
|
||||
* Note check the video_info::fileurl field to check if the upload succeeded.
|
||||
*/
|
||||
video_info upload_video(const video_details& file)const;
|
||||
uploaded_video upload_video(const video_details& file)const;
|
||||
/*
|
||||
* Upload a file as an audio file.
|
||||
* Returns: audio_info struct containing the url of the image on the homeserver.
|
||||
* Note check the audio_info::fileurl field to check if the upload succeeded.
|
||||
*/
|
||||
audio_info upload_audio(const audio_details& file)const;
|
||||
uploaded_audio upload_audio(const audio_details& file)const;
|
||||
|
||||
bool create_thumbnail(image_info& info)const;
|
||||
bool create_thumbnail(video_info& video)const;
|
||||
bool create_thumbnail(uploaded_image& info)const;
|
||||
bool create_thumbnail(uploaded_video& video)const;
|
||||
private:
|
||||
file_info _upload_file(const file_details& file, const raii::curl_llist& header)const;
|
||||
uploaded_file _upload_file(const file_details& file, const raii::curl_llist& header)const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -25,18 +25,14 @@
|
||||
//but will rarely need rebuilt
|
||||
|
||||
#include "raii/string.hpp"
|
||||
|
||||
struct image_info;
|
||||
struct video_info;
|
||||
struct file_info;
|
||||
struct audio_info;
|
||||
#include "matrix/upload_info.hpp"
|
||||
|
||||
namespace matrix::detail{
|
||||
|
||||
raii::string _image_body(const image_info& image);
|
||||
raii::string _video_body(const video_info& video);
|
||||
raii::string _file_body(const file_info& video);
|
||||
raii::string _audio_body(const audio_info& audio);
|
||||
raii::string _image_body(const uploaded_image& image);
|
||||
raii::string _video_body(const uploaded_video& video);
|
||||
raii::string _file_body(const uploaded_file& video);
|
||||
raii::string _audio_body(const uploaded_audio& audio);
|
||||
raii::string _message_body(const raii::string_base& text);
|
||||
|
||||
}
|
||||
|
||||
@@ -59,10 +59,10 @@ namespace matrix{
|
||||
//sending events
|
||||
raii::rjp_string send_custom_event(const raii::string_base& event, const raii::string_base& eventtype)const;
|
||||
raii::rjp_string send_message(const raii::string_base& text)const;
|
||||
raii::rjp_string send_file(const file_info& file)const;
|
||||
raii::rjp_string send_image(const image_info& image)const;
|
||||
raii::rjp_string send_video(const video_info& video)const;
|
||||
raii::rjp_string send_audio(const audio_info& audio)const;
|
||||
raii::rjp_string send_file(const uploaded_file& file)const;
|
||||
raii::rjp_string send_image(const uploaded_image& image)const;
|
||||
raii::rjp_string send_video(const uploaded_video& video)const;
|
||||
raii::rjp_string send_audio(const uploaded_audio& audio)const;
|
||||
bool send_typing(bool active, int timeout = 5000)const;
|
||||
bool send_read_receipt(const raii::string_base& eventid)const;
|
||||
|
||||
|
||||
+100
-19
@@ -26,6 +26,8 @@
|
||||
|
||||
namespace matrix{
|
||||
|
||||
struct client;
|
||||
|
||||
struct file_details{
|
||||
raii::binary data;
|
||||
raii::string name;
|
||||
@@ -39,28 +41,107 @@ namespace matrix{
|
||||
raii::string mimetype;
|
||||
};
|
||||
|
||||
struct file_info{
|
||||
raii::rjp_string fileurl;
|
||||
raii::string filename;
|
||||
raii::string mimetype;
|
||||
size_t filesize;
|
||||
};
|
||||
struct image_info : public file_info{
|
||||
using file_info::operator=;
|
||||
size_t width;
|
||||
size_t height;
|
||||
class uploaded_file
|
||||
{
|
||||
friend class matrix::client;
|
||||
protected:
|
||||
raii::rjp_string m_fileurl;
|
||||
raii::string m_filename;
|
||||
raii::string m_mimetype;
|
||||
size_t m_filesize = 0;
|
||||
|
||||
raii::rjp_string thumburl;
|
||||
raii::string thumbmime;
|
||||
size_t thumb_width;
|
||||
size_t thumb_height;
|
||||
size_t thumbsize;
|
||||
public:
|
||||
constexpr uploaded_file(void) = default;
|
||||
uploaded_file(const uploaded_file&) = default;
|
||||
uploaded_file(uploaded_file&&) = default;
|
||||
~uploaded_file(void) = default;
|
||||
|
||||
uploaded_file& operator=(const uploaded_file&) = default;
|
||||
uploaded_file& operator=(uploaded_file&&) = default;
|
||||
|
||||
constexpr operator bool(void)const{return m_fileurl;}
|
||||
|
||||
const raii::string& mimetype(void)const{return m_mimetype;}
|
||||
const raii::string& name(void)const{return m_filename;}
|
||||
const raii::rjp_string& url(void)const{return m_fileurl;}
|
||||
constexpr size_t size(void)const{return m_filesize;}
|
||||
};
|
||||
struct video_info : public image_info{
|
||||
using image_info::operator=;
|
||||
|
||||
class thumbnail_info
|
||||
{
|
||||
friend class matrix::client;
|
||||
protected:
|
||||
raii::rjp_string m_url;
|
||||
raii::string m_mimetype;
|
||||
size_t m_width = 0;
|
||||
size_t m_height = 0;
|
||||
size_t m_size = 0;
|
||||
|
||||
public:
|
||||
constexpr thumbnail_info(void) = default;
|
||||
thumbnail_info(const thumbnail_info&) = default;
|
||||
thumbnail_info(thumbnail_info&&) = default;
|
||||
~thumbnail_info(void) = default;
|
||||
|
||||
thumbnail_info& operator=(const thumbnail_info&) = default;
|
||||
thumbnail_info& operator=(thumbnail_info&&) = default;
|
||||
|
||||
constexpr operator bool(void)const{return m_url;}
|
||||
|
||||
constexpr size_t width(void)const{return m_width;}
|
||||
constexpr size_t height(void)const{return m_height;}
|
||||
constexpr size_t size(void)const{return m_size;}
|
||||
const raii::rjp_string& url(void)const{return m_url;}
|
||||
const raii::string& mimetype(void)const{return m_mimetype;}
|
||||
};
|
||||
struct audio_info : public file_info{
|
||||
using file_info::operator=;
|
||||
class uploaded_image : public uploaded_file
|
||||
{
|
||||
friend class matrix::client;
|
||||
protected:
|
||||
size_t m_width = 0;
|
||||
size_t m_height = 0;
|
||||
thumbnail_info m_thumb;
|
||||
|
||||
public:
|
||||
constexpr uploaded_image(void) = default;
|
||||
uploaded_image(const uploaded_image&) = default;
|
||||
uploaded_image(uploaded_image&&) = default;
|
||||
~uploaded_image(void) = default;
|
||||
|
||||
uploaded_image& operator=(const uploaded_image&) = default;
|
||||
uploaded_image& operator=(uploaded_image&&) = default;
|
||||
/*uploaded_image& operator=(const uploaded_file& f){
|
||||
uploaded_file::operator=(f);
|
||||
return *this;
|
||||
}
|
||||
uploaded_image& operator=(uploaded_file&& f){
|
||||
uploaded_file::operator=(std::move(f));
|
||||
return *this;
|
||||
}*/
|
||||
using uploaded_file::operator=;
|
||||
|
||||
constexpr size_t width(void)const{return m_width;}
|
||||
constexpr size_t height(void)const{return m_height;}
|
||||
constexpr auto thumb_width(void)const{return m_thumb.width();}
|
||||
constexpr auto thumb_height(void)const{return m_thumb.height();}
|
||||
constexpr auto thumb_size(void)const{return m_thumb.size();}
|
||||
decltype(auto) thumb_url(void)const{return m_thumb.url();}
|
||||
decltype(auto) thumb_mimetype(void)const{return m_thumb.mimetype();}
|
||||
};
|
||||
struct uploaded_video : public uploaded_image{
|
||||
friend class matrix::client;
|
||||
uploaded_video& operator=(const uploaded_file& f){
|
||||
uploaded_image::operator=(f);
|
||||
return *this;
|
||||
}
|
||||
uploaded_video& operator=(uploaded_file&& f){
|
||||
uploaded_image::operator=(std::move(f));
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
struct uploaded_audio : public uploaded_file{
|
||||
friend class matrix::client;
|
||||
using uploaded_file::operator=;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
/**
|
||||
This file is a part of rexy's matrix client
|
||||
Copyright (C) 2019 rexy712
|
||||
|
||||
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, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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 RAII_BINARY_HPP
|
||||
#define RAII_BINARY_HPP
|
||||
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
/**
|
||||
This file is a part of rexy's matrix client
|
||||
Copyright (C) 2019 rexy712
|
||||
|
||||
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, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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 RAII_BINARY_STRING_CONV_HPP
|
||||
#define RAII_BINARY_STRING_CONV_HPP
|
||||
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
/**
|
||||
This file is a part of rexy's matrix client
|
||||
Copyright (C) 2019 rexy712
|
||||
|
||||
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, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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 RAII_DEFAULT_ALLOCATOR_HPP
|
||||
#define RAII_DEFAULT_ALLOCATOR_HPP
|
||||
|
||||
|
||||
Reference in New Issue
Block a user