Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
Remove state references
Browse files Browse the repository at this point in the history
  • Loading branch information
wiggleforlife committed Mar 4, 2022
1 parent 9c6a6d6 commit 6f891d6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 192 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ project(vatsim-manager)

set(CMAKE_CXX_STANDARD 14)

add_executable(vatsim-manager main.cpp utils.cpp utils.h download.cpp download.h clientstate.cpp clientstate.h global.h)
add_executable(vatsim-manager main.cpp utils.cpp utils.h download.cpp download.h global.h)

find_package(PkgConfig)
pkg_check_modules(libcurl REQUIRED IMPORTED_TARGET libcurl>=7.68.0)
pkg_check_modules(jsoncpp REQUIRED IMPORTED_TARGET jsoncpp>=1.7.4)
target_link_libraries(vatsim-manager PUBLIC PkgConfig::libcurl PkgConfig::jsoncpp)
target_link_libraries(vatsim-manager PUBLIC PkgConfig::libcurl)
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ Created by Cian Ormond with no endorsements by VATSIM staff members. For more in
* Manage `winetricks` and `wine` settings in a custom `WINEPREFIX` for ATC clients

### Included clients
* xPilot 2.0.0 beta
* Swift beta
![xPilot version](https://img.shields.io/github/v/release/xpilot-project/xpilot?include_prereleases&label=xPilot&style=flat-square)
![Swift version](https://img.shields.io/github/v/release/swift-project/pilotclient?include_prereleases&label=Swift&style=flat-square)
<!--TODO use version from VERSIONS-->

### Dependencies
* libCURL >=7.68.0
Expand Down
123 changes: 0 additions & 123 deletions clientstate.cpp

This file was deleted.

31 changes: 0 additions & 31 deletions clientstate.h

This file was deleted.

42 changes: 10 additions & 32 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@
#include "utils.h"
#include "download.h"
#include "global.h"
#include "clientstate.h"

using namespace std;

utils ut;
download dl;
global gl;
clientstate cs;

vector<vector<string>> state;

//TODO keep track of installed programs and add --refresh option

Expand All @@ -39,37 +35,35 @@ int install(const char* program, bool forceDownload) {
string cmdOut;
if (ut.askForConfirmation(programName.c_str())) {
system(("find /tmp/vatsim-manager/" + programName + ".run > /tmp/vatsim-manager/findinstaller 2>&1")
.c_str());
.c_str());
if (!ut.iequals(ut.readFile("/tmp/vatsim-manager/findres"), "/tmp/vatsim-manager/" +
programName + ".run") || forceDownload) {
programName + ".run") || forceDownload) {
dl.downloadPilotClient(programIndex);
} else {
//TODO detect old versions
cout << "Found installer in /tmp/vatsim-manager/" << endl << "If you encounter errors or this is an old " <<
"installer, use --force-download" << endl << endl;
"installer, use --force-download" << endl << endl;
}
system(("chmod +x /tmp/vatsim-manager/" + programName + ".run").c_str());
system(("/tmp/vatsim-manager/" + programName + ".run").c_str());
cs.createState();
}


return 0;
}

//TODO change to directory in state.json
int remove(const char* program) {
if (ut.iequals(program, "xpilot")) {
system("rm -rf \"$HOME/.cache/Justin Shannon\"");
cout << "Launching uninstaller" << endl;
system("$(find $HOME -name xPilot)/uninstall > /dev/null 2>&1");
} else if (ut.iequals(program, "swift")) {
//doesn't work if the qt sdk is installed
system("$(find $HOME -name swift-*)/uninstall > /dev/null 2>&1");
} else {
cout << "Program name not recognised." << endl << endl;
cout << "Program name not recognised/program not installed." << endl << endl;
return 1;
}
cs.createState();
return 0;
}

Expand All @@ -88,38 +82,19 @@ void showLicense() {

void showCommands() {
cout << "-h - displays this page" << endl;
cout << "-l - lists installed clients" << endl;
cout << "-L - displays license information" << endl;
cout << "-i - installs a pilot/ATC client from the following list - " << endl;
cout << " xPilot 2.0.0 beta (X-Plane 11), Swift (X-Plane 11, FlightGear)" << endl;
cout << "-r - uninstalls a pilot/ATC client from the above list" << endl << endl;
}

void showClients() {
std::string programName;
for (int i = 0; i < state.at(0).size(); i++) {
if (ut.iequals(state.at(0).at(i), "xpilot")) { programName = "xPilot"; }
if (ut.iequals(state.at(0).at(i), "Swift")) { programName = "Swift"; }

cout << programName << endl << " " << state.at(1).at(i) << endl << " " << state.at(2).at(i) << endl << endl;
}
}

int main(int argc, char** argv) {

cout << endl << "VATSIM Program Manager version " << gl.version << " by Cian Ormond" << endl;
cout << "Licensed under GPL3. For licensing of programs included, use -L." << endl << endl;

//TODO move this somewhere else
cs.findHome();

system("mkdir -p /tmp/vatsim-manager ~/.local/share/vatsim-manager");

system("find ~/.local/share/vatsim-manager/ -name state.json > /tmp/vatsim-manager/findres 2>&1");
if (ut.iequals(ut.readFile("/tmp/vatsim-manager/findres"), cs.homedir + "/.local/share/vatsim-manager/state.json")) {
state = cs.parseState();
} else { cs.createState(); }

//TODO clean this up
if (argc > 1) {

Expand All @@ -138,7 +113,8 @@ int main(int argc, char** argv) {
}
else {
//TODO only show uninstalled programs
cout << "Please specify a program to install. Available options are xPilot and Swift." << endl << endl;
cout << "Please specify a program to install. Available options are xPilot and Swift." << endl <<
endl;
}

} else if (strcmp(argv[1], "-r") == 0) {
Expand All @@ -152,7 +128,9 @@ int main(int argc, char** argv) {
}
else if (strcmp(argv[1], "-h") == 0) {showCommands();}
else if (strcmp(argv[1], "-L") == 0) {showLicense();}
else if (strcmp(argv[1], "-l") == 0) {showClients();}
else {
cout << "Command not recognised. Use the -h flag for a command list" << endl << endl;
}

} else {
cout << "No command specified. Use the -h flag for a command list." << endl << endl;
Expand Down
1 change: 0 additions & 1 deletion utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,5 @@ int utils::findInVector(std::vector<std::string> arr, std::string item) {
if (iequals(arr[i], item))
return i;
}

return -1;
}

0 comments on commit 6f891d6

Please sign in to comment.