2017-02-17 10:14:28 +01:00
|
|
|
/* This program is free software. It comes without any warranty, to
|
|
|
|
* the extent permitted by applicable law. You can redistribute it
|
|
|
|
* and/or modify it under the terms of the Do What The Fuck You Want
|
|
|
|
* To Public License, Version 2, as published by Sam Hocevar. See
|
|
|
|
* http://www.wtfpl.net/ for more details. */
|
|
|
|
|
|
|
|
#ifndef GALAXYAPI_H
|
|
|
|
#define GALAXYAPI_H
|
|
|
|
|
|
|
|
#include "globalconstants.h"
|
|
|
|
#include "globals.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "util.h"
|
2017-09-13 15:46:46 +02:00
|
|
|
#include "gamedetails.h"
|
2017-02-17 10:14:28 +01:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <vector>
|
|
|
|
#include <cstring>
|
|
|
|
#include <curl/curl.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
|
|
struct galaxyDepotItemChunk
|
|
|
|
{
|
|
|
|
std::string md5_compressed;
|
|
|
|
std::string md5_uncompressed;
|
2017-03-04 22:52:29 +01:00
|
|
|
uintmax_t size_compressed;
|
|
|
|
uintmax_t size_uncompressed;
|
|
|
|
uintmax_t offset_compressed;
|
|
|
|
uintmax_t offset_uncompressed;
|
2017-02-17 10:14:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct galaxyDepotItem
|
|
|
|
{
|
|
|
|
std::string path;
|
|
|
|
std::vector<galaxyDepotItemChunk> chunks;
|
2017-03-04 22:52:29 +01:00
|
|
|
uintmax_t totalSizeCompressed;
|
|
|
|
uintmax_t totalSizeUncompressed;
|
2017-02-17 10:14:28 +01:00
|
|
|
std::string md5;
|
2017-03-06 05:58:11 +01:00
|
|
|
std::string product_id;
|
2018-09-05 16:41:43 +02:00
|
|
|
bool isDependency = false;
|
2017-02-17 10:14:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class galaxyAPI
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
galaxyAPI(CurlConfig& conf);
|
|
|
|
virtual ~galaxyAPI();
|
|
|
|
int init();
|
|
|
|
bool isTokenExpired();
|
|
|
|
bool refreshLogin();
|
|
|
|
Json::Value getProductBuilds(const std::string& product_id, const std::string& platform = "windows", const std::string& generation = "2");
|
|
|
|
Json::Value getManifestV1(const std::string& product_id, const std::string& build_id, const std::string& manifest_id = "repository", const std::string& platform = "windows");
|
2018-02-12 18:03:56 +01:00
|
|
|
Json::Value getManifestV1(const std::string& manifest_url);
|
2018-09-05 16:41:43 +02:00
|
|
|
Json::Value getManifestV2(std::string manifest_hash, const bool& is_dependency = false);
|
2017-02-17 10:14:28 +01:00
|
|
|
Json::Value getSecureLink(const std::string& product_id, const std::string& path);
|
2018-09-05 16:41:43 +02:00
|
|
|
Json::Value getDependencyLink(const std::string& path);
|
2017-02-17 10:14:28 +01:00
|
|
|
std::string getResponse(const std::string& url, const bool& zlib_decompress = false);
|
2018-07-21 22:59:08 +02:00
|
|
|
Json::Value getResponseJson(const std::string& url, const bool& zlib_decompress = false);
|
2017-02-17 10:14:28 +01:00
|
|
|
std::string hashToGalaxyPath(const std::string& hash);
|
2018-09-05 16:41:43 +02:00
|
|
|
std::vector<galaxyDepotItem> getDepotItemsVector(const std::string& hash, const bool& is_dependency = false);
|
2017-09-13 15:46:46 +02:00
|
|
|
Json::Value getProductInfo(const std::string& product_id);
|
|
|
|
gameDetails productInfoJsonToGameDetails(const Json::Value& json, const DownloadConfig& dlConf);
|
2018-07-21 22:59:08 +02:00
|
|
|
Json::Value getUserData();
|
2018-09-05 16:41:43 +02:00
|
|
|
Json::Value getDependenciesJson();
|
|
|
|
std::vector<galaxyDepotItem> getFilteredDepotItemsVectorFromJson(const Json::Value& depot_json, const std::string& galaxy_language, const std::string& galaxy_arch, const bool& is_dependency = false);
|
2017-02-17 10:14:28 +01:00
|
|
|
protected:
|
|
|
|
private:
|
|
|
|
CurlConfig curlConf;
|
|
|
|
static size_t writeMemoryCallback(char *ptr, size_t size, size_t nmemb, void *userp);
|
|
|
|
CURL* curlhandle;
|
2017-10-18 12:13:35 +02:00
|
|
|
std::vector<gameFile> installerJsonNodeToGameFileVector(const std::string& gamename, const Json::Value& json, const DownloadConfig& dlConf);
|
|
|
|
std::vector<gameFile> patchJsonNodeToGameFileVector(const std::string& gamename, const Json::Value& json, const DownloadConfig& dlConf);
|
|
|
|
std::vector<gameFile> languagepackJsonNodeToGameFileVector(const std::string& gamename, const Json::Value& json, const DownloadConfig& dlConf);
|
2017-09-13 15:46:46 +02:00
|
|
|
std::vector<gameFile> extraJsonNodeToGameFileVector(const std::string& gamename, const Json::Value& json);
|
2017-10-18 12:13:35 +02:00
|
|
|
std::vector<gameFile> fileJsonNodeToGameFileVector(const std::string& gamename, const Json::Value& json, const unsigned int& type = GFTYPE_INSTALLER, const unsigned int& platform = (GlobalConstants::PLATFORM_WINDOWS | GlobalConstants::PLATFORM_LINUX), const unsigned int& lang = GlobalConstants::LANGUAGE_EN, const bool& useDuplicateHandler = false);
|
2017-02-17 10:14:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GALAXYAPI_H
|