summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/Android.mk8
-rw-r--r--gui/action.cpp2
-rw-r--r--gui/pages.cpp35
-rw-r--r--gui/pages.hpp8
-rw-r--r--gui/resources.cpp38
-rw-r--r--gui/resources.hpp21
6 files changed, 53 insertions, 59 deletions
diff --git a/gui/Android.mk b/gui/Android.mk
index 78e93c61a..909850fc4 100644
--- a/gui/Android.mk
+++ b/gui/Android.mk
@@ -38,7 +38,13 @@ else
LOCAL_SRC_FILES += hardwarekeyboard.cpp
endif
-LOCAL_SHARED_LIBRARIES += libminuitwrp libc libstdc++ libminzip libaosprecovery libselinux
+LOCAL_SHARED_LIBRARIES += libminuitwrp libc libstdc++ libaosprecovery libselinux
+ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0)
+ LOCAL_SHARED_LIBRARIES += libziparchive
+else
+ LOCAL_SHARED_LIBRARIES += libminzip
+ LOCAL_CFLAGS += -DUSE_MINZIP
+endif
LOCAL_MODULE := libguitwrp
#TWRP_EVENT_LOGGING := true
diff --git a/gui/action.cpp b/gui/action.cpp
index a39515828..05ae46515 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -43,11 +43,11 @@
#include "../adb_install.h"
#include "../fuse_sideload.h"
#include "blanktimer.hpp"
+#include "../twinstall.h"
extern "C" {
#include "../twcommon.h"
#include "../variables.h"
-#include "../twinstall.h"
#include "cutils/properties.h"
#include "../adb_install.h"
};
diff --git a/gui/pages.cpp b/gui/pages.cpp
index b901526ff..1199a2876 100644
--- a/gui/pages.cpp
+++ b/gui/pages.cpp
@@ -39,12 +39,17 @@
#include <string>
#include <algorithm>
+#ifdef USE_MINZIP
+#include "../minzip/SysUtil.h"
+#else
+#include "../otautil/SysUtil.h"
+#endif
+
extern "C" {
#include "../twcommon.h"
-#include "../minzip/SysUtil.h"
-#include "../minzip/Zip.h"
#include "gui.h"
}
+#include "../zipwrap.hpp"
#include "../minuitwrp/minui.h"
#include "rapidxml.hpp"
@@ -664,7 +669,7 @@ int Page::NotifyVarChange(std::string varName, std::string value)
// transient data for loading themes
struct LoadingContext
{
- ZipArchive* zip; // zip to load theme from, or NULL for the stock theme
+ ZipWrap* zip; // zip to load theme from, or NULL for the stock theme
std::set<std::string> filenames; // to detect cyclic includes
std::string basepath; // if zip is NULL, base path to load includes from with trailing slash, otherwise empty
std::vector<xml_document<>*> xmldocs; // all loaded xml docs
@@ -806,7 +811,7 @@ void PageSet::MakeEmergencyConsoleIfNeeded()
}
}
-int PageSet::LoadLanguage(char* languageFile, ZipArchive* package)
+int PageSet::LoadLanguage(char* languageFile, ZipWrap* package)
{
xml_document<> lang;
xml_node<>* parent;
@@ -1182,7 +1187,7 @@ void PageSet::AddStringResource(std::string resource_source, std::string resourc
mResources->AddStringResource(resource_source, resource_name, value);
}
-char* PageManager::LoadFileToBuffer(std::string filename, ZipArchive* package) {
+char* PageManager::LoadFileToBuffer(std::string filename, ZipWrap* package) {
size_t len;
char* buffer = NULL;
@@ -1219,19 +1224,18 @@ char* PageManager::LoadFileToBuffer(std::string filename, ZipArchive* package) {
close(fd);
} else {
LOGINFO("PageManager::LoadFileToBuffer loading filename: '%s' from zip\n", filename.c_str());
- const ZipEntry* zipentry = mzFindZipEntry(package, filename.c_str());
- if (zipentry == NULL) {
+ if (!package->EntryExists(filename)) {
LOGERR("Unable to locate '%s' in zip file\n", filename.c_str());
return NULL;
}
// Allocate the buffer for the file
- len = mzGetZipEntryUncompLen(zipentry);
+ len = package->GetUncompressedSize(filename);
buffer = (char*) malloc(len + 1);
if (!buffer)
return NULL;
- if (!mzExtractZipEntryToBuffer(package, zipentry, (unsigned char*) buffer)) {
+ if (!package->ExtractToBuffer(filename, (unsigned char*) buffer)) {
LOGERR("Unable to extract '%s'\n", filename.c_str());
free(buffer);
return NULL;
@@ -1295,14 +1299,13 @@ void PageManager::LoadLanguageListDir(string dir) {
closedir(d);
}
-void PageManager::LoadLanguageList(ZipArchive* package) {
+void PageManager::LoadLanguageList(ZipWrap* package) {
Language_List.clear();
if (TWFunc::Path_Exists(TWRES "customlanguages"))
TWFunc::removeDir(TWRES "customlanguages", true);
if (package) {
TWFunc::Recursive_Mkdir(TWRES "customlanguages");
- struct utimbuf timestamp = { 1217592000, 1217592000 }; // 8/1/2008 default
- mzExtractRecursive(package, "languages", TWRES "customlanguages/", &timestamp, NULL, NULL, NULL);
+ package->ExtractRecursive("languages", TWRES "customlanguages/");
LoadLanguageListDir(TWRES "customlanguages/");
} else {
LoadLanguageListDir(TWRES "languages/");
@@ -1330,7 +1333,7 @@ void PageManager::LoadLanguage(string filename) {
int PageManager::LoadPackage(std::string name, std::string package, std::string startpage)
{
std::string mainxmlfilename = package;
- ZipArchive zip;
+ ZipWrap zip;
char* languageFile = NULL;
char* baseLanguageFile = NULL;
PageSet* pageSet = NULL;
@@ -1371,7 +1374,7 @@ int PageManager::LoadPackage(std::string name, std::string package, std::string
LOGERR("Failed to map '%s'\n", package.c_str());
goto error;
}
- if (mzOpenZipArchive(map.addr, map.length, &zip)) {
+ if (!zip.Open(package.c_str(), &map)) {
LOGERR("Unable to open zip archive '%s'\n", package.c_str());
sysReleaseMap(&map);
goto error;
@@ -1414,7 +1417,7 @@ int PageManager::LoadPackage(std::string name, std::string package, std::string
mCurrentSet = pageSet;
if (ctx.zip) {
- mzCloseZipArchive(ctx.zip);
+ ctx.zip->Close();
sysReleaseMap(&map);
}
return ret;
@@ -1422,7 +1425,7 @@ int PageManager::LoadPackage(std::string name, std::string package, std::string
error:
// Sometimes we get here without a real error
if (ctx.zip) {
- mzCloseZipArchive(ctx.zip);
+ ctx.zip->Close();
sysReleaseMap(&map);
}
return -1;
diff --git a/gui/pages.hpp b/gui/pages.hpp
index 1e71b10e0..282b2d5b1 100644
--- a/gui/pages.hpp
+++ b/gui/pages.hpp
@@ -21,7 +21,7 @@
#ifndef _PAGES_HEADER_HPP
#define _PAGES_HEADER_HPP
-#include "../minzip/Zip.h"
+#include "../zipwrap.hpp"
#include <vector>
#include <map>
#include <string>
@@ -116,7 +116,7 @@ public:
public:
int Load(LoadingContext& ctx, const std::string& filename);
- int LoadLanguage(char* languageFile, ZipArchive* package);
+ int LoadLanguage(char* languageFile, ZipWrap* package);
void MakeEmergencyConsoleIfNeeded();
Page* FindPage(std::string name);
@@ -155,8 +155,8 @@ class PageManager
{
public:
// Used by GUI
- static char* LoadFileToBuffer(std::string filename, ZipArchive* package);
- static void LoadLanguageList(ZipArchive* package);
+ static char* LoadFileToBuffer(std::string filename, ZipWrap* package);
+ static void LoadLanguageList(ZipWrap* package);
static void LoadLanguage(std::string filename);
static int LoadPackage(std::string name, std::string package, std::string startpage);
static PageSet* SelectPackage(std::string name);
diff --git a/gui/resources.cpp b/gui/resources.cpp
index bd71d50b0..59b8ed484 100644
--- a/gui/resources.cpp
+++ b/gui/resources.cpp
@@ -30,7 +30,7 @@
#include <iomanip>
#include <fcntl.h>
-#include "../minzip/Zip.h"
+#include "../zipwrap.hpp"
extern "C" {
#include "../twcommon.h"
#include "gui.h"
@@ -42,38 +42,24 @@ extern "C" {
#define TMP_RESOURCE_NAME "/tmp/extract.bin"
-Resource::Resource(xml_node<>* node, ZipArchive* pZip __unused)
+Resource::Resource(xml_node<>* node, ZipWrap* pZip __unused)
{
if (node && node->first_attribute("name"))
mName = node->first_attribute("name")->value();
}
-int Resource::ExtractResource(ZipArchive* pZip, std::string folderName, std::string fileName, std::string fileExtn, std::string destFile)
+int Resource::ExtractResource(ZipWrap* pZip, std::string folderName, std::string fileName, std::string fileExtn, std::string destFile)
{
if (!pZip)
return -1;
std::string src = folderName + "/" + fileName + fileExtn;
-
- const ZipEntry* binary = mzFindZipEntry(pZip, src.c_str());
- if (binary == NULL) {
- return -1;
- }
-
- unlink(destFile.c_str());
- int fd = creat(destFile.c_str(), 0666);
- if (fd < 0)
+ if (!pZip->ExtractEntry(src, destFile, 0666))
return -1;
-
- int ret = 0;
- if (!mzExtractZipEntryToFile(pZip, binary, fd))
- ret = -1;
-
- close(fd);
- return ret;
+ return 0;
}
-void Resource::LoadImage(ZipArchive* pZip, std::string file, gr_surface* surface)
+void Resource::LoadImage(ZipWrap* pZip, std::string file, gr_surface* surface)
{
int rc = 0;
if (ExtractResource(pZip, "images", file, ".png", TMP_RESOURCE_NAME) == 0)
@@ -119,7 +105,7 @@ void Resource::CheckAndScaleImage(gr_surface source, gr_surface* destination, in
}
}
-FontResource::FontResource(xml_node<>* node, ZipArchive* pZip)
+FontResource::FontResource(xml_node<>* node, ZipWrap* pZip)
: Resource(node, pZip)
{
origFontSize = 0;
@@ -127,7 +113,7 @@ FontResource::FontResource(xml_node<>* node, ZipArchive* pZip)
LoadFont(node, pZip);
}
-void FontResource::LoadFont(xml_node<>* node, ZipArchive* pZip)
+void FontResource::LoadFont(xml_node<>* node, ZipWrap* pZip)
{
std::string file;
xml_attribute<>* attr;
@@ -192,7 +178,7 @@ void FontResource::DeleteFont() {
origFont = NULL;
}
-void FontResource::Override(xml_node<>* node, ZipArchive* pZip) {
+void FontResource::Override(xml_node<>* node, ZipWrap* pZip) {
if (!origFont) {
origFont = mFont;
} else if (mFont) {
@@ -207,7 +193,7 @@ FontResource::~FontResource()
DeleteFont();
}
-ImageResource::ImageResource(xml_node<>* node, ZipArchive* pZip)
+ImageResource::ImageResource(xml_node<>* node, ZipWrap* pZip)
: Resource(node, pZip)
{
std::string file;
@@ -238,7 +224,7 @@ ImageResource::~ImageResource()
res_free_surface(mSurface);
}
-AnimationResource::AnimationResource(xml_node<>* node, ZipArchive* pZip)
+AnimationResource::AnimationResource(xml_node<>* node, ZipWrap* pZip)
: Resource(node, pZip)
{
std::string file;
@@ -359,7 +345,7 @@ void ResourceManager::AddStringResource(std::string resource_source, std::string
mStrings[resource_name] = res;
}
-void ResourceManager::LoadResources(xml_node<>* resList, ZipArchive* pZip, std::string resource_source)
+void ResourceManager::LoadResources(xml_node<>* resList, ZipWrap* pZip, std::string resource_source)
{
if (!resList)
return;
diff --git a/gui/resources.hpp b/gui/resources.hpp
index 2d3067667..de673184c 100644
--- a/gui/resources.hpp
+++ b/gui/resources.hpp
@@ -25,8 +25,7 @@
#include <vector>
#include <map>
#include "rapidxml.hpp"
-
-struct ZipArchive;
+#include "../zipwrap.hpp"
extern "C" {
#include "../minuitwrp/minui.h"
@@ -36,7 +35,7 @@ extern "C" {
class Resource
{
public:
- Resource(xml_node<>* node, ZipArchive* pZip);
+ Resource(xml_node<>* node, ZipWrap* pZip);
virtual ~Resource() {}
public:
@@ -46,27 +45,27 @@ private:
std::string mName;
protected:
- static int ExtractResource(ZipArchive* pZip, std::string folderName, std::string fileName, std::string fileExtn, std::string destFile);
- static void LoadImage(ZipArchive* pZip, std::string file, gr_surface* surface);
+ static int ExtractResource(ZipWrap* pZip, std::string folderName, std::string fileName, std::string fileExtn, std::string destFile);
+ static void LoadImage(ZipWrap* pZip, std::string file, gr_surface* surface);
static void CheckAndScaleImage(gr_surface source, gr_surface* destination, int retain_aspect);
};
class FontResource : public Resource
{
public:
- FontResource(xml_node<>* node, ZipArchive* pZip);
+ FontResource(xml_node<>* node, ZipWrap* pZip);
virtual ~FontResource();
public:
void* GetResource() { return this ? mFont : NULL; }
int GetHeight() { return gr_ttf_getMaxFontHeight(this ? mFont : NULL); }
- void Override(xml_node<>* node, ZipArchive* pZip);
+ void Override(xml_node<>* node, ZipWrap* pZip);
protected:
void* mFont;
private:
- void LoadFont(xml_node<>* node, ZipArchive* pZip);
+ void LoadFont(xml_node<>* node, ZipWrap* pZip);
void DeleteFont();
private:
@@ -77,7 +76,7 @@ private:
class ImageResource : public Resource
{
public:
- ImageResource(xml_node<>* node, ZipArchive* pZip);
+ ImageResource(xml_node<>* node, ZipWrap* pZip);
virtual ~ImageResource();
public:
@@ -92,7 +91,7 @@ protected:
class AnimationResource : public Resource
{
public:
- AnimationResource(xml_node<>* node, ZipArchive* pZip);
+ AnimationResource(xml_node<>* node, ZipWrap* pZip);
virtual ~AnimationResource();
public:
@@ -112,7 +111,7 @@ public:
ResourceManager();
virtual ~ResourceManager();
void AddStringResource(std::string resource_source, std::string resource_name, std::string value);
- void LoadResources(xml_node<>* resList, ZipArchive* pZip, std::string resource_source);
+ void LoadResources(xml_node<>* resList, ZipWrap* pZip, std::string resource_source);
public:
FontResource* FindFont(const std::string& name) const;