-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,669 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!DOCTYPE RCC><RCC version="1.0"> | ||
<qresource> | ||
<file>systemTrayIcon.png</file> | ||
</qresource> | ||
</RCC> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef BASE64_H | ||
#define BASE64_H | ||
#pragma once | ||
#include <iostream> | ||
class Base64 { | ||
public: | ||
static std::string Encode(const std::string data); | ||
static std::string Decode(const std::string& input, std::string& out); | ||
}; | ||
|
||
#endif // BASE64_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#ifndef curling | ||
#define curling | ||
|
||
#include <curl/curl.h> | ||
#include <iostream> | ||
#include <sstream> | ||
#include <regex> | ||
#include "generalcurling.h" | ||
std::string chatmedata="", methodtype; | ||
size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userdata) { | ||
if (methodtype == "GET") chatmedata = ""; | ||
if (methodtype == "PUT") return 0; | ||
for (size_t i(0); i != nmemb; ++i) { | ||
if (methodtype == "GET") | ||
chatmedata += ptr[i]; | ||
else { | ||
std::cout << ptr[i]; | ||
} | ||
} | ||
return 0; | ||
} | ||
void curlstuff(const std::string& port, const std::string& pass,const std::string location, const std::string method, std::string* postdata) { | ||
methodtype = method; | ||
//CURLcode ret; //unused | ||
CURL* curl; | ||
struct curl_slist *slist1; | ||
slist1 = NULL; | ||
slist1 = curl_slist_append(slist1, (static_cast<std::string>("Authorization: Basic ") + pass).c_str()); | ||
curl = curl_easy_init(); | ||
std::stringstream urlstring; | ||
curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 102400L); | ||
urlstring << "https://127.0.0.1:" << port << location; | ||
curl_easy_setopt(curl, CURLOPT_URL, urlstring.str().c_str()); | ||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L); | ||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist1); | ||
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, (long)CURL_HTTP_VERSION_2TLS); | ||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); | ||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); | ||
if (method == "GET") { | ||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET"); | ||
} else if (method == "PUT") { | ||
if (chatmedata.find("offline") != std::string::npos) { | ||
std::cout << "Skip fakeoffline, (already offline)\n"; | ||
return; | ||
} | ||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT"); | ||
slist1 = curl_slist_append(slist1, "Content-Type: application/json"); | ||
chatmedata = std::regex_replace(chatmedata, std::regex("(.*)\"availability\":\".*?\"(.*)"), "$01\"availability\":\"offline\"$02"); | ||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, chatmedata.c_str()); | ||
// curl_easy_setopt(curl, CURLOPT_POSTFIELDS, chatmedata.c_str()); | ||
// curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)933); | ||
} | ||
else { | ||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST"); | ||
} | ||
curl_easy_setopt(curl, CURLOPT_FTP_SKIP_PASV_IP, 1L); | ||
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L); | ||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); | ||
curl_easy_perform(curl); | ||
curl_easy_cleanup(curl); | ||
curl=NULL; | ||
curl_slist_free_all(slist1); | ||
slist1=NULL; | ||
std::cout << std::endl; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef GENERALCURLING_H | ||
#define GENERALCURLING_H | ||
#include <string> | ||
#include <QtCore/QDebug> | ||
|
||
size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userdata); | ||
void curlstuff(const std::string& port, const std::string& pass,const std::string location, const std::string method, std::string* postdata = nullptr); | ||
#endif // GENERALCURLING_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.