Init commit
This commit is contained in:
39
include/alipan.h
Normal file
39
include/alipan.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <json-c/json.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace drive {
|
||||
typedef struct {
|
||||
std::string name, id, parent;
|
||||
bool isDir = false;
|
||||
size_t size;
|
||||
} gdItem;
|
||||
} // namespace drive
|
||||
|
||||
class alipan {
|
||||
public:
|
||||
virtual ~alipan() = default;
|
||||
|
||||
bool checkLogin();
|
||||
void getListWithParent(const std::string& _parent, std::vector<drive::gdItem>& _out);
|
||||
bool createDir(const std::string& _dirName, const std::string& _parent);
|
||||
bool deleteFile(const std::string& _fileID);
|
||||
|
||||
private:
|
||||
std::string deviceId;
|
||||
std::string accessToken;
|
||||
std::string rToken;
|
||||
|
||||
std::string driveId;
|
||||
std::string userId;
|
||||
std::string signature;
|
||||
|
||||
json_object* request(const std::string& api, const std::string& data);
|
||||
|
||||
bool getSelfuser();
|
||||
bool refreshToken();
|
||||
bool createSession();
|
||||
bool qrLogin();
|
||||
};
|
||||
33
include/http.h
Normal file
33
include/http.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Copyright 2023 dragonflylee
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <curl/curl.h>
|
||||
|
||||
class http {
|
||||
public:
|
||||
using Form = std::unordered_map<std::string, std::string>;
|
||||
|
||||
http(const std::string& useragent = "JKSV");
|
||||
http(const http& other) = delete;
|
||||
~http();
|
||||
|
||||
static std::string encode_form(const Form& form);
|
||||
void set_headers(const std::vector<std::string>& headers);
|
||||
int get(const std::string& url, std::ostream* out);
|
||||
std::string put(const std::string& url, std::istream* data);
|
||||
std::string post(const std::string& url, const std::string& data);
|
||||
|
||||
private:
|
||||
static size_t easy_write_cb(char* ptr, size_t size, size_t nmemb, void* userdata);
|
||||
static size_t easy_read_cb(char* ptr, size_t size, size_t nmemb, void* userdata);
|
||||
int perform(std::ostream* body);
|
||||
|
||||
CURL* easy;
|
||||
struct curl_slist* chunk;
|
||||
};
|
||||
7
include/misc.h
Normal file
7
include/misc.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace util {
|
||||
std::string hexEncode(const unsigned char* data, size_t len);
|
||||
} // namespace util
|
||||
Reference in New Issue
Block a user