mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
62 lines
1.7 KiB
C++
62 lines
1.7 KiB
C++
#ifndef GITHUBIMAGEHOST_H
|
|
#define GITHUBIMAGEHOST_H
|
|
|
|
#include "imagehost.h"
|
|
|
|
#include <vtextedit/networkutils.h>
|
|
|
|
namespace vnotex
|
|
{
|
|
class GitHubImageHost : public ImageHost
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit GitHubImageHost(QObject *p_parent);
|
|
|
|
bool ready() const Q_DECL_OVERRIDE;
|
|
|
|
Type getType() const Q_DECL_OVERRIDE;
|
|
|
|
QJsonObject getConfig() const Q_DECL_OVERRIDE;
|
|
|
|
void setConfig(const QJsonObject &p_jobj) Q_DECL_OVERRIDE;
|
|
|
|
bool testConfig(const QJsonObject &p_jobj, QString &p_msg) Q_DECL_OVERRIDE;
|
|
|
|
QString create(const QByteArray &p_data, const QString &p_path, QString &p_msg) Q_DECL_OVERRIDE;
|
|
|
|
bool remove(const QString &p_url, QString &p_msg) Q_DECL_OVERRIDE;
|
|
|
|
bool ownsUrl(const QString &p_url) const Q_DECL_OVERRIDE;
|
|
|
|
private:
|
|
// Used to test.
|
|
vte::NetworkReply getRepoInfo(const QString &p_token, const QString &p_userName, const QString &p_repoName) const;
|
|
|
|
QString createResource(const QByteArray &p_content, const QString &p_path, QString &p_msg) const;
|
|
|
|
static void parseConfig(const QJsonObject &p_jobj,
|
|
QString &p_token,
|
|
QString &p_userName,
|
|
QString &p_repoName);
|
|
|
|
static QPair<QByteArray, QByteArray> authorizationHeader(const QString &p_token);
|
|
|
|
static QPair<QByteArray, QByteArray> acceptHeader();
|
|
|
|
static vte::NetworkAccess::RawHeaderPairs prepareCommonHeaders(const QString &p_token);
|
|
|
|
QString m_personalAccessToken;
|
|
|
|
QString m_userName;
|
|
|
|
QString m_repoName;
|
|
|
|
QString m_imageUrlPrefix;
|
|
|
|
static const QString c_apiUrl;
|
|
};
|
|
}
|
|
|
|
#endif // GITHUBIMAGEHOST_H
|