ConsoleGUI-Example
#include <iostream>
#include <string>
#include <thread>
#include <chrono>
#include <algorithm>
#include "qPapel.h"
void PrintCleanInfo(std::string info) {
size_t pos = 0;
while ((pos = info.find("\\n", pos)) != std::string::npos) {
info.replace(pos, 2, "\n");
pos += 1;
}
std::cout << info << std::endl;
}
int main() {
std::cout << "--- PapelShip C++ Full Feature Demo ---" << std::endl;
qPapel::AuthConfig config;
config.apiKey = "pk_00000055_";
std::cout << "[Loader] Initializing..." << std::endl;
qPapel::ProtectedAuth auth;
auth.Init(config);
if (auth.SendHeartbeat()) {
std::cout << "[SUCCESS] Secure connection established." << std::endl;
std::cout << "\n[Locked] Enter License Key to continue: ";
std::string licenseKey;
std::cin >> licenseKey;
std::cout << "[Auth] Validating key..." << std::endl;
if (auth.ValidateKey(licenseKey)) {
std::cout << "[SUCCESS] License Validated! Session Token: " << auth.GetSessionToken() << std::endl;
bool running = true;
while (running) {
std::cout << "\n--- Main Menu ---" << std::endl;
std::cout << "1. View License Info" << std::endl;
std::cout << "2. Get Server String" << std::endl;
std::cout << "3. Download Server File" << std::endl;
std::cout << "4. Run Server File (StartFile)" << std::endl;
std::cout << "5. Exit" << std::endl;
std::cout << "Select option: ";
int choice;
std::cin >> choice;
std::string accessId, args;
switch (choice) {
case 1:
{
std::cout << "\n[Fetching Info]..." << std::endl;
std::string info = auth.GetKeyInfo(licenseKey);
if (!info.empty()) {
std::cout << "\n--- License Information ---" << std::endl;
PrintCleanInfo(info);
std::cout << "---------------------------" << std::endl;
} else {
std::cout << "[Error] Failed to get info: " << auth.GetLastError() << std::endl;
}
}
break;
case 2:
std::cout << "Enter String Access ID: ";
std::cin >> accessId;
{
std::string val = auth.GetServerString(accessId);
if (!val.empty()) {
std::cout << "[Server String]: " << val << std::endl;
} else {
std::cout << "[Error] Failed to fetch string (Check ID or Permissions)." << std::endl;
}
}
break;
case 3:
std::cout << "Enter File Access ID to Download: ";
std::cin >> accessId;
std::cout << "[Downloading]..." << std::endl;
if (auth.GetServerFile(accessId)) {
std::cout << "[SUCCESS] File downloaded successfully (check Install Path/Downloads)." << std::endl;
} else {
std::cout << "[FAILED] Download failed." << std::endl;
}
break;
case 4:
std::cout << "Enter File Access ID to Run: ";
std::cin >> accessId;
std::cout << "Enter Arguments (optional, type 'none' for empty): ";
std::cin >> args;
if (args == "none") args = "";
std::cout << "[Launching]..." << std::endl;
if (auth.StartFile(accessId, licenseKey, args)) {
std::cout << "[SUCCESS] File executed." << std::endl;
} else {
std::cout << "[FAILED] Execution failed." << std::endl;
}
break;
case 5:
running = false;
break;
default:
std::cout << "Invalid option." << std::endl;
}
}
} else {
std::cout << "[ERROR] " << auth.GetLastError() << std::endl;
}
}
else {
std::cout << "[FAILED] Access Denied. " << auth.GetLastError() << std::endl;
}
std::cout << "\nExiting..." << std::endl;
return 0;
}Last updated