UNIVERSAL-UPDATER IS BACK! Lmao.

This commit is contained in:
VoltZ
2019-10-31 03:23:05 +01:00
committed by GitHub
parent f64ab53907
commit c548cca57a
35 changed files with 25521 additions and 0 deletions
+106
View File
@@ -0,0 +1,106 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019 VoltZ, Epicpkmn11, Flame, RocketRobz, TotallyNotGuy
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils/common.hpp"
#define APP_TITLE "Universal-Updater"
#define V_STRING "1.0.0"
enum DownloadError {
DL_ERROR_NONE = 0,
DL_ERROR_WRITEFILE,
DL_ERROR_ALLOC,
DL_ERROR_STATUSCODE,
DL_ERROR_GIT,
};
struct ThemeEntry {
std::string downloadUrl;
std::string name;
std::string path;
std::string sdPath;
};
Result downloadToFile(std::string url, std::string path);
Result downloadFromRelease(std::string url, std::string asset, std::string path);
void displayProgressBar();
/**
* Check Wi-Fi status.
* @return True if Wi-Fi is connected; false if not.
*/
bool checkWifiStatus(void);
/**
* Display "Please connect to Wi-Fi" for 2s.
*/
void notConnectedMsg(void);
/**
* Display "Not Implemented Yet" for 2s.
*/
void notImplemented(void);
/**
* Get info from the GitHub API about a Release.
* repo is where to get from. (Ex. "RocketRobz/TWiLightMenu")
* item is that to get from the API. (Ex. "tag_name")
* @return the string from the API.
*/
std::string getLatestRelease(std::string repo, std::string item);
/**
* Get info from the GitHub API about a Commit.
* repo is where to get from. (Ex. "RocketRobz/TWiLightMenu")
* item is that to get from the API. (Ex. "sha")
* @return the string from the API.
*/
std::string getLatestCommit(std::string repo, std::string item);
/**
* Get info from the GitHub API about a Commit.
* repo is where to get from. (Ex. "RocketRobz/TWiLightMenu")
* array is the array the item is in. (Ex. "commit")
* item is that to get from the API. (Ex. "message")
* @return the string from the API.
*/
std::string getLatestCommit(std::string repo, std::string array, std::string item);
/**
* Get a GitHub directory's contents with the GitHub API.
* repo is where to get from. (Ex. "DS-Homebrew/twlmenu-extras")
* path is the path within the repo (Ex. "contents/_nds/TWiLightMenu/dsimenu/themes")
* @return the string from the API.
*/
std::vector<ThemeEntry> getThemeList(std::string repo, std::string path);
/**
* Update nds-bootstrap to the latest build.
*/
void updateBootstrap(bool nightly);
+81
View File
@@ -0,0 +1,81 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019 VoltZ, Epicpkmn11, Flame, RocketRobz, TotallyNotGuy
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef GUI_HPP
#define GUI_HPP
#include "screens/screen.hpp"
#include <3ds.h>
#include <citro2d.h>
#include <citro3d.h>
#include <random>
#include <stack>
#include <string.h>
#include <unordered_map>
#include <wchar.h>
#define BarColor C2D_Color32(0, 102, 204, 255)
#define TopBGColor C2D_Color32(51, 153, 255, 255)
#define BottomBGColor C2D_Color32(0, 64, 128, 255)
#define BLACK C2D_Color32(0, 0, 0, 255)
#define WHITE C2D_Color32(255, 255, 255, 255)
#define TextColor C2D_Color32(102, 179, 255, 255)
namespace Gui
{
// Init and Exit of the GUI.
Result init(void);
void exit(void);
// Screen and MainLoops.
void mainLoop(u32 hDown, u32 hHeld, touchPosition touch);
void setScreen(std::unique_ptr<Screen> screen);
void screenBack(void);
C3D_RenderTarget* target(gfxScreen_t t);
void ScreenDraw(C3D_RenderTarget * screen);
// Clear Text.
void clearTextBufs(void);
// Misc.
bool Draw_Rect(float x, float y, float w, float h, u32 color);
// Text / String Functions.
void DrawStringCentered(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0);
void DrawString(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0);
void GetStringSize(float size, float *width, float *height, std::string Text);
float GetStringWidth(float size, std::string Text);
float GetStringHeight(float size, std::string Text);
// Basic GUI.
void DrawTop(void);
void DrawBottom(void);
}
void DisplayMsg(std::string text);
#endif
+13
View File
@@ -0,0 +1,13 @@
#ifndef LANG_HPP
#define LANG_HPP
#include "utils/json.hpp"
#include <string>
namespace Lang {
std::string get(const std::string &key);
void load(int lang);
}
#endif
+40
View File
@@ -0,0 +1,40 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019 VoltZ, Epicpkmn11, Flame, RocketRobz, TotallyNotGuy
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef MAINMENU_HPP
#define MAINMENU_HPP
#include "screens/screen.hpp"
class MainMenu : public Screen
{
public:
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
private:
};
#endif
+16
View File
@@ -0,0 +1,16 @@
#ifndef SCREEN_HPP
#define SCREEN_HPP
#include <3ds.h>
#include <memory>
class Screen
{
public:
virtual ~Screen() {}
virtual void Logic(u32 hDown, u32 hHeld, touchPosition touch) = 0;
virtual void Draw() const = 0;
private:
};
#endif
+35
View File
@@ -0,0 +1,35 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019 VoltZ, Epicpkmn11, Flame, RocketRobz, TotallyNotGuy
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SCREENCOMMON_HPP
#define SCREENCOMMON_HPP
#include "gui.hpp"
extern C3D_RenderTarget* top;
extern C3D_RenderTarget* bottom;
#endif
+5
View File
@@ -0,0 +1,5 @@
#pragma once
#include "common.hpp"
Result installCia(const char * ciaPath);
+61
View File
@@ -0,0 +1,61 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019 VoltZ, Epicpkmn11, Flame, RocketRobz, TotallyNotGuy
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include <3ds.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "utils/files.h"
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#ifdef __cplusplus
}
#include "utils/json.hpp"
#include "utils/stringutils.hpp"
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <regex>
#include <curl/curl.h>
using json = nlohmann::json;
#endif
extern char * arg0;
#define WORKING_DIR "/3ds/"
+41
View File
@@ -0,0 +1,41 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019 VoltZ, Epicpkmn11, Flame, RocketRobz, TotallyNotGuy
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "common.hpp"
enum ExtractError {
EXTRACT_ERROR_NONE = 0,
EXTRACT_ERROR_ARCHIVE,
EXTRACT_ERROR_ALLOC,
EXTRACT_ERROR_FIND,
EXTRACT_ERROR_READFILE,
EXTRACT_ERROR_OPENFILE,
EXTRACT_ERROR_WRITEFILE,
};
Result extractArchive(std::string archivePath, std::string wantedFile, std::string outputPath);
+30
View File
@@ -0,0 +1,30 @@
#ifndef FILE_BROWSE_H
#define FILE_BROWSE_H
#include <dirent.h>
#include <string>
#include <sys/stat.h>
#include <vector>
using namespace std;
struct DirEntry {
std::string name;
std::string path;
bool isDirectory;
char tid[5];
off_t size;
};
typedef struct {
char gameTitle[12]; //!< 12 characters for the game title.
char gameCode[4]; //!< 4 characters for the game code.
} sNDSHeadertitlecodeonly;
void findNdsFiles(vector<DirEntry>& dirContents);
bool nameEndsWith(const std::string& name, const std::vector<std::string> extensionList);
void getDirectoryContents(std::vector<DirEntry>& dirContents, const std::vector<std::string> extensionList);
void getDirectoryContents(std::vector<DirEntry>& dirContents);
#endif //FILE_BROWSE_H
+32
View File
@@ -0,0 +1,32 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019 VoltZ, Epicpkmn11, Flame, RocketRobz, TotallyNotGuy
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "common.hpp"
Result openFile(Handle* fileHandle, const char * path, bool write);
Result deleteFile(const char * path);
+46
View File
@@ -0,0 +1,46 @@
#ifndef _INIFILE_H_
#define _INIFILE_H_
#include <map>
#include <string>
#include <vector>
class CIniFile
{
public:
CIniFile();
CIniFile(const std::string& filename);
virtual ~CIniFile();
public:
bool LoadIniFile(const std::string& FileName);
bool SaveIniFile(const std::string& FileName);
bool SaveIniFileModified(const std::string& FileName);
std::string GetString(const std::string& Section,const std::string& Item,const std::string& DefaultValue);
void SetString(const std::string& Section,const std::string& Item,const std::string& Value);
int GetInt(const std::string& Section,const std::string& Item,int DefaultValue);
void SetInt(const std::string& Section,const std::string& Item,int Value);
void GetStringVector(const std::string& Section,const std::string& Item,std::vector<std::string>& strings,char delimiter=',');
void SetStringVector(const std::string& Section,const std::string& Item,std::vector<std::string>& strings,char delimiter=',');
protected:
std::string m_sFileName;
typedef std::vector<std::string> cStringArray;
cStringArray m_FileContainer;
bool m_bLastResult;
bool m_bModified;
bool m_bReadOnly;
typedef std::map<std::string,size_t> cSectionCache;
cSectionCache m_Cache;
bool InsertLine(size_t line,const std::string& str);
bool ReplaceLine(size_t line,const std::string& str);
void SetFileString(const std::string& Section,const std::string& Item,const std::string& Value);
std::string GetFileString(const std::string& Section,const std::string& Item);
std::string GetString(const std::string& Section,const std::string& Item);
int GetInt(const std::string& Section,const std::string& Item);
};
#endif // _INIFILE_H_
+22684
View File
File diff suppressed because it is too large Load Diff
+10
View File
@@ -0,0 +1,10 @@
#pragma once
#include "common.hpp"
bool matchPattern(std::string pattern, std::string tested);
namespace StringUtils
{
std::string format(const std::string& fmt_str, ...);
}
+12
View File
@@ -0,0 +1,12 @@
#ifndef THREAD_HPP
#define THREAD_HPP
#include <3ds.h>
#include <vector>
namespace Threads {
void create(ThreadFunc entrypoint);
void destroy(void);
}
#endif