Compare commits

...

5 Commits
v1.0.0 ... main

Author SHA1 Message Date
Nichole Mattera 3d87c1dac9 Updated names. 2 years ago
Nichole Mattera e77a50fb93 Merge branch 'master' of github.com:AtlasNX/Kosmos-Updater-Diagnostic 3 years ago
Nichole Mattera 5d0db6a56d Send "Cache-Control" request header. 3 years ago
Nichole Mattera e1d240df03 Fix Zipper link. 3 years ago
Nichole Mattera a2f81cdce8 Reduced the amount of duplicate code. 3 years ago
  1. 2
      Makefile
  2. 2
      README.md
  3. 2
      src/Application.cpp
  4. 2
      src/Application.hpp
  5. 2
      src/Menu.cpp
  6. 2
      src/Menu.hpp
  7. 120
      src/View.cpp
  8. 45
      src/View.hpp
  9. 8
      src/WebRequest.cpp
  10. 2
      src/WebRequest.hpp
  11. 2
      src/main.cpp
  12. 82
      src/views/AppVersionView.cpp
  13. 16
      src/views/AppVersionView.hpp
  14. 97
      src/views/AppView.cpp
  15. 16
      src/views/AppView.hpp
  16. 84
      src/views/PackageVersionView.cpp
  17. 18
      src/views/PackageVersionView.hpp
  18. 113
      src/views/PackageView.cpp
  19. 18
      src/views/PackageView.hpp

2
Makefile

@ -37,7 +37,7 @@ EXEFS_SRC := exefs_src
ICON := Icon.jpg
APP_TITLE := Kosmos Updater Diagnostic
APP_AUTHOR := Steven Mattera
APP_AUTHOR := Nichole Mattera
APP_VERSION := 1.0.0
API_VERSION := v3

2
README.md

@ -6,4 +6,4 @@ A homebrew application for the Nintendo Switch to diagnose potential issues with
* Thanks to @yellow8, and @plutoo for the example of [reading an NACP from an NRO](https://github.com/switchbrew/nx-hbmenu/blob/8e8e62ac33aa27a268b34d9e16ef141767a5434a/common/menu-entry.c#L127) in NX-HBMenu.
* Thanks to [switchbrew.org](https://switchbrew.org/) for the awesome documentaion on [NRO](https://switchbrew.org/wiki/NRO) and [NACP](https://switchbrew.org/wiki/Control.nacp).
* Thanks to @sebastiandev for their fork of minizip and their awesome wrapper for it, [Zipper](https://switchbrew.org/wiki/NRO).
* Thanks to @sebastiandev for their fork of minizip and their awesome wrapper for it, [Zipper](https://github.com/sebastiandev/zipper).

2
src/Application.cpp

@ -1,5 +1,5 @@
// Kosmos Updater Diagnostic
// Copyright (C) 2019 Steven Mattera
// Copyright (C) 2019 Nichole Mattera
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License

2
src/Application.hpp

@ -1,5 +1,5 @@
// Kosmos Updater Diagnostic
// Copyright (C) 2019 Steven Mattera
// Copyright (C) 2019 Nichole Mattera
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License

2
src/Menu.cpp

@ -1,5 +1,5 @@
// Kosmos Updater Diagnostic
// Copyright (C) 2019 Steven Mattera
// Copyright (C) 2019 Nichole Mattera
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License

2
src/Menu.hpp

@ -1,5 +1,5 @@
// Kosmos Updater Diagnostic
// Copyright (C) 2019 Steven Mattera
// Copyright (C) 2019 Nichole Mattera
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License

120
src/View.cpp

@ -0,0 +1,120 @@
// Kosmos Updater Diagnostic
// Copyright (C) 2019 Nichole Mattera
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "View.hpp"
#include <iostream>
#include <string>
#include <vector>
#include "zipper/unzipper.h"
using namespace std;
using namespace zipper;
namespace KUDiag {
View::View(function<void()> backCallback) {
_backCallback = backCallback;
_hasDrawn = false;
_hasFinished = false;
_request = NULL;
}
View::~View() {
if (_request) {
delete _request;
}
}
void View::draw(u64 kDown) {
if (_hasFinished) {
if (kDown & KEY_A) {
_backCallback();
reset();
}
return;
}
if (_request) {
Mutex mutext = _request->getMutex();
mutexLock(&mutext);
if (_request->isComplete()) {
if (_request->hasError()) {
cout << "\x1b[3;0HError: " << _request->getErrorMessage() << "\n\n";
} else {
cout << "\x1b[3;14H100";
_requestCompletedSuccessfully();
}
cout << "\nPress A to continue.";
_hasFinished = true;
} else {
int progress = _request->getProgress();
if (progress < 10) {
cout << "\x1b[3;16H" << progress;
} else if (progress < 100) {
cout << "\x1b[3;15H" << progress;
} else {
cout << "\x1b[3;14H" << progress;
}
}
mutexUnlock(&mutext);
}
if (!_hasDrawn) {
consoleClear();
cout << "\x1b[0;0H" << _getTitle() << "\n\n";
cout << "Downloading: 0%";
_request = new WebRequest("GET", _getURL());
if (!_request->start()) {
cout << "\x1b[1;12H100";
cout << "\x1b[3;0HError: Problem starting thread.\n\n";
cout << "Press A to continue.";
_hasFinished = true;
}
_hasDrawn = true;
}
}
void View::reset() {
_hasDrawn = false;
_hasFinished = false;
if (_request != NULL) {
delete _request;
_request = NULL;
}
}
string View::_getTitle() {
return "";
}
string View::_getURL() {
return "";
}
void View::_requestCompletedSuccessfully() {}
}

45
src/View.hpp

@ -0,0 +1,45 @@
// Kosmos Updater Diagnostic
// Copyright (C) 2019 Nichole Mattera
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <switch.h>
#include <functional>
#include "WebRequest.hpp"
#pragma once
namespace KUDiag {
class View {
public:
View(std::function<void()> backCallback);
virtual ~View();
void draw(u64 kDown);
void reset();
protected:
WebRequest * _request;
private:
virtual std::string _getTitle();
virtual std::string _getURL();
virtual void _requestCompletedSuccessfully();
std::function<void()> _backCallback;
bool _hasDrawn;
bool _hasFinished;
};
}

8
src/WebRequest.cpp

@ -1,5 +1,5 @@
// Kosmos Updater Diagnostic
// Copyright (C) 2019 Steven Mattera
// Copyright (C) 2019 Nichole Mattera
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -172,6 +172,10 @@ namespace KUDiag {
curl = curl_easy_init();
if (curl) {
struct curl_slist * headers = NULL;
headers = curl_slist_append(headers, "Cache-Control: no-cache");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, request->getURL().c_str());
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, request->getMethod().c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _writeFunction);
@ -185,12 +189,14 @@ namespace KUDiag {
if (res != CURLE_OK) {
request->setErrored(string(curl_easy_strerror(res)));
curl_easy_cleanup(curl);
curl_slist_free_all(headers);
return;
}
long http_code = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
curl_easy_cleanup(curl);
curl_slist_free_all(headers);
if (http_code != 200) {
request->setErrored("There was an error on the server, please try again later.");

2
src/WebRequest.hpp

@ -1,5 +1,5 @@
// Kosmos Updater Diagnostic
// Copyright (C) 2019 Steven Mattera
// Copyright (C) 2019 Nichole Mattera
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License

2
src/main.cpp

@ -1,5 +1,5 @@
// Kosmos Updater Diagnostic
// Copyright (C) 2019 Steven Mattera
// Copyright (C) 2019 Nichole Mattera
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License

82
src/views/AppVersionView.cpp

@ -1,5 +1,5 @@
// Kosmos Updater Diagnostic
// Copyright (C) 2019 Steven Mattera
// Copyright (C) 2019 Nichole Mattera
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -22,83 +22,17 @@
using namespace std;
namespace KUDiag {
AppVersionView::AppVersionView(function<void()> backCallback) {
_backCallback = backCallback;
_hasDrawn = false;
_hasFinished = false;
_request = NULL;
}
AppVersionView::AppVersionView(std::function<void()> backCallback) : View(backCallback) {}
AppVersionView::~AppVersionView() {
if (_request) {
delete _request;
}
string AppVersionView::_getTitle() {
return string("Kosmos Updater Diagnostic ") + VERSION + " - Get latest app version";
}
void AppVersionView::draw(u64 kDown) {
if (_hasFinished) {
if (kDown & KEY_A) {
_backCallback();
reset();
}
return;
}
if (_request) {
if (_request->isComplete()) {
if (_request->hasError()) {
cout << "\x1b[3;0HError: " << _request->getErrorMessage() << "\n\n";
} else {
cout << "\x1b[3;14H100";
cout << "\x1b[5;0HLatest App Version: " << _request->getData() << "\n\n";
}
cout << "Press A to continue.";
_hasFinished = true;
} else {
Mutex mutext = _request->getMutex();
mutexLock(&mutext);
int progress = _request->getProgress();
mutexUnlock(&mutext);
if (progress < 10) {
cout << "\x1b[3;16H" << progress;
} else if (progress < 100) {
cout << "\x1b[3;15H" << progress;
} else {
cout << "\x1b[3;14H" << progress;
}
}
}
if (!_hasDrawn) {
consoleClear();
cout << "\x1b[0;0HKosmos Updater Diagnostic " << VERSION << " - Get latest app version\n\n";
cout << "Downloading: 0%";
_request = new WebRequest("GET", string("http://kosmos-updater.teamatlasnx.com/") + API_VERSION + "/app/version-number");
if (!_request->start()) {
cout << "\x1b[1;12H100";
cout << "\x1b[3;0HError: Problem starting thread.\n\n";
cout << "Press A to continue.";
_hasFinished = true;
}
_hasDrawn = true;
}
string AppVersionView::_getURL() {
return string("http://kosmos-updater.teamatlasnx.com/") + API_VERSION + "/app/version-number";
}
void AppVersionView::reset() {
_hasDrawn = false;
_hasFinished = false;
if (_request != NULL) {
delete _request;
_request = NULL;
}
void AppVersionView::_requestCompletedSuccessfully() {
cout << "\x1b[5;0HLatest App Version: " << _request->getData() << "\n\n";
}
}

16
src/views/AppVersionView.hpp

@ -1,5 +1,5 @@
// Kosmos Updater Diagnostic
// Copyright (C) 2019 Steven Mattera
// Copyright (C) 2019 Nichole Mattera
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -17,22 +17,18 @@
#include <switch.h>
#include <functional>
#include "../WebRequest.hpp"
#include "../View.hpp"
#pragma once
namespace KUDiag {
class AppVersionView {
class AppVersionView : public View {
public:
AppVersionView(std::function<void()> backCallback);
~AppVersionView();
void draw(u64 kDown);
void reset();
private:
std::function<void()> _backCallback;
bool _hasDrawn;
bool _hasFinished;
WebRequest * _request;
std::string _getTitle();
std::string _getURL();
void _requestCompletedSuccessfully();
};
}

97
src/views/AppView.cpp

@ -1,5 +1,5 @@
// Kosmos Updater Diagnostic
// Copyright (C) 2019 Steven Mattera
// Copyright (C) 2019 Nichole Mattera
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -23,88 +23,27 @@
using namespace std;
namespace KUDiag {
AppView::AppView(function<void()> backCallback) {
_backCallback = backCallback;
_hasDrawn = false;
_hasFinished = false;
_request = NULL;
}
void AppView::draw(u64 kDown) {
if (_hasFinished) {
if (kDown & KEY_A) {
_backCallback();
reset();
}
return;
}
if (_request) {
if (_request->isComplete()) {
if (_request->hasError()) {
cout << "\x1b[3;0HError: " << _request->getErrorMessage() << "\n\n";
} else {
cout << "\x1b[3;14H100";
NacpStruct nacp = _getNACP(_request->getRawData());
NacpLanguageEntry * langEntry = NULL;
Result rc = nacpGetLanguageEntry(&nacp, &langEntry);
if (R_SUCCEEDED(rc) && langEntry != NULL) {
cout << "\x1b[5;0HApp Name: " << langEntry->name << "\n";
cout << "App Author: " << langEntry->author << "\n";
cout << "App Version: " << nacp.version << "\n\n";
} else {
cout << "\x1b[5;0HApp Version: " << nacp.version << "\n\n";
}
}
cout << "Press A to continue.";
AppView::AppView(std::function<void()> backCallback) : View(backCallback) {}
_hasFinished = true;
} else {
Mutex mutext = _request->getMutex();
mutexLock(&mutext);
int progress = _request->getProgress();
mutexUnlock(&mutext);
if (progress < 10) {
cout << "\x1b[3;16H" << progress;
} else if (progress < 100) {
cout << "\x1b[3;15H" << progress;
} else {
cout << "\x1b[3;14H" << progress;
}
}
}
if (!_hasDrawn) {
consoleClear();
cout << "\x1b[0;0HKosmos Updater Diagnostic " << VERSION << " - Get latest app\n\n";
cout << "Downloading: 0%";
_request = new WebRequest("GET", string("http://kosmos-updater.teamatlasnx.com/") + API_VERSION + "/app");
if (!_request->start()) {
cout << "\x1b[1;12H100";
cout << "\x1b[3;0HError: Problem starting thread.\n\n";
cout << "Press A to continue.";
_hasFinished = true;
}
string AppView::_getTitle() {
return string("Kosmos Updater Diagnostic ") + VERSION + " - Get latest app";
}
_hasDrawn = true;
}
string AppView::_getURL() {
return string("http://kosmos-updater.teamatlasnx.com/") + API_VERSION + "/app";
}
void AppView::reset() {
_hasDrawn = false;
_hasFinished = false;
if (_request != NULL) {
delete _request;
_request = NULL;
void AppView::_requestCompletedSuccessfully() {
NacpStruct nacp = _getNACP(_request->getRawData());
NacpLanguageEntry * langEntry = NULL;
Result rc = nacpGetLanguageEntry(&nacp, &langEntry);
if (R_SUCCEEDED(rc) && langEntry != NULL) {
cout << "\x1b[5;0HApp Name: " << langEntry->name << "\n";
cout << "App Author: " << langEntry->author << "\n";
cout << "App Version: " << nacp.version << "\n\n";
} else {
cout << "\x1b[5;0HApp Version: " << nacp.version << "\n\n";
}
}

16
src/views/AppView.hpp

@ -1,5 +1,5 @@
// Kosmos Updater Diagnostic
// Copyright (C) 2019 Steven Mattera
// Copyright (C) 2019 Nichole Mattera
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -17,23 +17,19 @@
#include <switch.h>
#include <functional>
#include "../WebRequest.hpp"
#include "../View.hpp"
#pragma once
namespace KUDiag {
class AppView {
class AppView : public View {
public:
AppView(std::function<void()> backCallback);
void draw(u64 kDown);
void reset();
private:
NacpStruct _getNACP(char * data);
std::function<void()> _backCallback;
bool _hasDrawn;
bool _hasFinished;
WebRequest * _request;
std::string _getTitle();
std::string _getURL();
void _requestCompletedSuccessfully();
};
}

84
src/views/PackageVersionView.cpp

@ -1,5 +1,5 @@
// Kosmos Updater Diagnostic
// Copyright (C) 2019 Steven Mattera
// Copyright (C) 2019 Nichole Mattera
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -22,85 +22,19 @@
using namespace std;
namespace KUDiag {
PackageVersionView::PackageVersionView(function<void()> backCallback) {
_backCallback = backCallback;
_hasDrawn = false;
_hasFinished = false;
_request = NULL;
}
PackageVersionView::PackageVersionView(std::function<void()> backCallback) : View(backCallback) {}
PackageVersionView::~PackageVersionView() {
if (_request) {
delete _request;
}
string PackageVersionView::_getTitle() {
return string("Kosmos Updater Diagnostic ") + VERSION + " - Get latest package version";
}
void PackageVersionView::draw(u64 kDown) {
if (_hasFinished) {
if (kDown & KEY_A) {
_backCallback();
reset();
}
return;
}
if (_request) {
if (_request->isComplete()) {
if (_request->hasError()) {
cout << "\x1b[3;0HError: " << _request->getErrorMessage() << "\n\n";
} else {
cout << "\x1b[3;14H100";
cout << "\x1b[5;0HChannel: " << _getChannel() << "\n";
cout << "Latest Package Version: " << _request->getData() << "\n\n";
}
cout << "Press A to continue.";
_hasFinished = true;
} else {
Mutex mutext = _request->getMutex();
mutexLock(&mutext);
int progress = _request->getProgress();
mutexUnlock(&mutext);
if (progress < 10) {
cout << "\x1b[3;16H" << progress;
} else if (progress < 100) {
cout << "\x1b[3;15H" << progress;
} else {
cout << "\x1b[3;14H" << progress;
}
}
}
if (!_hasDrawn) {
consoleClear();
cout << "\x1b[0;0HKosmos Updater Diagnostic " << VERSION << " - Get latest package version\n\n";
cout << "Downloading: 0%";
_request = new WebRequest("GET", string("http://kosmos-updater.teamatlasnx.com/") + API_VERSION + "/package/version-number?channel=" + _getChannel());
if (!_request->start()) {
cout << "\x1b[1;12H100";
cout << "\x1b[3;0HError: Problem starting thread.\n\n";
cout << "Press A to continue.";
_hasFinished = true;
}
_hasDrawn = true;
}
string PackageVersionView::_getURL() {
return string("http://kosmos-updater.teamatlasnx.com/") + API_VERSION + "/package/version-number?channel=" + _getChannel();
}
void PackageVersionView::reset() {
_hasDrawn = false;
_hasFinished = false;
if (_request != NULL) {
delete _request;
_request = NULL;
}
void PackageVersionView::_requestCompletedSuccessfully() {
cout << "\x1b[5;0HChannel: " << _getChannel() << "\n";
cout << "Latest Package Version: " << _request->getData() << "\n\n";
}
string PackageVersionView::_getChannel() {

18
src/views/PackageVersionView.hpp

@ -1,5 +1,5 @@
// Kosmos Updater Diagnostic
// Copyright (C) 2019 Steven Mattera
// Copyright (C) 2019 Nichole Mattera
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -17,26 +17,20 @@
#include <switch.h>
#include <functional>
#include "../WebRequest.hpp"
#include "../View.hpp"
#pragma once
namespace KUDiag {
class PackageVersionView {
class PackageVersionView : public View {
public:
PackageVersionView(std::function<void()> backCallback);
~PackageVersionView();
void draw(u64 kDown);
void reset();
int channel;
private:
std::string _getChannel();
std::function<void()> _backCallback;
bool _hasDrawn;
bool _hasFinished;
WebRequest * _request;
std::string _getTitle();
std::string _getURL();
void _requestCompletedSuccessfully();
};
}

113
src/views/PackageView.cpp

@ -1,5 +1,5 @@
// Kosmos Updater Diagnostic
// Copyright (C) 2019 Steven Mattera
// Copyright (C) 2019 Nichole Mattera
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -25,105 +25,38 @@ using namespace std;
using namespace zipper;
namespace KUDiag {
PackageView::PackageView(function<void()> backCallback) {
_backCallback = backCallback;
_hasDrawn = false;
_hasFinished = false;
_request = NULL;
}
PackageView::PackageView(std::function<void()> backCallback) : View(backCallback) {}
PackageView::~PackageView() {
if (_request) {
delete _request;
}
string PackageView::_getTitle() {
return string("Kosmos Updater Diagnostic ") + VERSION + " - Get latest package";
}
void PackageView::draw(u64 kDown) {
if (_hasFinished) {
if (kDown & KEY_A) {
_backCallback();
reset();
}
return;
}
if (_request) {
if (_request->isComplete()) {
if (_request->hasError()) {
cout << "\x1b[3;0HError: " << _request->getErrorMessage() << "\n\n";
} else {
cout << "\x1b[3;14H100";
unsigned char * data = (unsigned char *) _request->getRawData();
vector<unsigned char> vectorData(data, data + _request->getSize());
Unzipper unzipper(vectorData);
vector<ZipEntry> entries = unzipper.entries();
cout << "\x1b[5;0HChannel: " << _getChannel() << "\n";
cout << "Bundle: " << _getBundle() << "\n";
cout << "Number of entries: " << entries.size() << "\n\n";
cout << "First Ten Entries\n";
int i = 0;
for (auto const& entry : entries) {
if (!entry.name.empty()) {
cout << "Entry #" << i << ": " << entry.name << "\n";
i++;
}
string PackageView::_getURL() {
return string("http://kosmos-updater.teamatlasnx.com/") + API_VERSION + "/package?channel=" + _getChannel() + "&bundle=" + _getBundle();
}
if (i == 10) {
break;
}
}
}
void PackageView::_requestCompletedSuccessfully() {
unsigned char * data = (unsigned char *) _request->getRawData();
cout << "\nPress A to continue.";
vector<unsigned char> vectorData(data, data + _request->getSize());
Unzipper unzipper(vectorData);
vector<ZipEntry> entries = unzipper.entries();
_hasFinished = true;
} else {
Mutex mutext = _request->getMutex();
mutexLock(&mutext);
int progress = _request->getProgress();
mutexUnlock(&mutext);
cout << "\x1b[5;0HChannel: " << _getChannel() << "\n";
cout << "Bundle: " << _getBundle() << "\n";
cout << "Number of entries: " << entries.size() << "\n\n";
cout << "First Ten Entries\n";
if (progress < 10) {
cout << "\x1b[3;16H" << progress;
} else if (progress < 100) {
cout << "\x1b[3;15H" << progress;
} else {
cout << "\x1b[3;14H" << progress;
}
int i = 0;
for (auto const& entry : entries) {
if (!entry.name.empty()) {
cout << "Entry #" << i << ": " << entry.name << "\n";
i++;
}
}
if (!_hasDrawn) {
consoleClear();
cout << "\x1b[0;0HKosmos Updater Diagnostic " << VERSION << " - Get latest package\n\n";
cout << "Downloading: 0%";
_request = new WebRequest("GET", string("http://kosmos-updater.teamatlasnx.com/") + API_VERSION + "/package?channel=" + _getChannel() + "&bundle=" + _getBundle());
if (!_request->start()) {
cout << "\x1b[1;12H100";
cout << "\x1b[3;0HError: Problem starting thread.\n\n";
cout << "Press A to continue.";
_hasFinished = true;
if (i == 10) {
break;
}
_hasDrawn = true;
}
}
void PackageView::reset() {
_hasDrawn = false;
_hasFinished = false;
if (_request != NULL) {
delete _request;
_request = NULL;
}
}

18
src/views/PackageView.hpp

@ -1,5 +1,5 @@
// Kosmos Updater Diagnostic
// Copyright (C) 2019 Steven Mattera
// Copyright (C) 2019 Nichole Mattera
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -17,28 +17,22 @@
#include <switch.h>
#include <functional>
#include "../WebRequest.hpp"
#include "../View.hpp"
#pragma once
namespace KUDiag {
class PackageView {
class PackageView : public View {
public:
PackageView(std::function<void()> backCallback);
~PackageView();
void draw(u64 kDown);
void reset();
int channel;
int bundle;
private:
std::string _getChannel();
std::string _getBundle();
std::function<void()> _backCallback;
bool _hasDrawn;
bool _hasFinished;
WebRequest * _request;
std::string _getTitle();
std::string _getURL();
void _requestCompletedSuccessfully();
};
}

Loading…
Cancel
Save