[go: nahoru, domu]

Skip to content

Commit

Permalink
wiiu: start incorporating get library instead of old yaml parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
vgmoose committed May 3, 2018
1 parent 6c326cf commit 83e3c93
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 96 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "libs/get"]
path = libs/get
url = https://github.com/vgmoose/get.git
15 changes: 10 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export LIBOGC_INC := $(DEVKITPRO)/libogc/include
export LIBOGC_LIB := $(DEVKITPRO)/libogc/lib/wii
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc

export GET := ./libs/get/src
export RAPIDJSON := ./libs/get/src/libs/rapidjson/include
export MINIZIP := ./libs/get/src/libs/minizip

PREFIX := powerpc-eabi-

export AS := $(PREFIX)as
Expand All @@ -40,20 +44,21 @@ SOURCES := src \
src/network \
src/menu \
src/resources \
$(GET) $(MINIZIP)

DATA := data \
data/images \
data/fonts \
data/sounds

INCLUDES := src
INCLUDES := src $(RAPIDJSON) $(MINIZIP)

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS := -std=gnu11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \
-O3 -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing $(INCLUDE)
CXXFLAGS := -std=gnu++11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \
CFLAGS := -std=gnu11 -DWIIU -DNOCRYPT -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \
-O3 -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing $(INCLUDE)
CXXFLAGS := -std=gnu++11 -DWIIU -DNOCRYPT -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \
-O3 -Wall -Wextra -Wno-unused-parameter -D_GNU_SOURCE -Wno-strict-aliasing $(INCLUDE)

ifeq ($(DO_LOGGING), 1)
Expand All @@ -70,7 +75,7 @@ MAKEFLAGS += --no-print-directory
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lgui -lutils -ldynamiclibs -lfreetype -lgd -lpng -ljpeg -lz -lmad -lvorbisidec -lzip
LIBS := -lgui -lutils -ldynamiclibs -lfreetype -lgd -lpng -ljpeg -lz -lmad -lvorbisidec -lzip

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
Expand Down
1 change: 1 addition & 0 deletions libs/get
Submodule get added at 213968
3 changes: 2 additions & 1 deletion src/Application.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/****************************************************************************
* Copyright (C) 2015 Dimok
* Copyright (C) 2015-2018 VGMoose, rw-r-r_0644, Creepermario, Brienj
* Copyright (C) 2015 Dimok, Maschell
*
* 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
Expand Down
3 changes: 2 additions & 1 deletion src/Application.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/****************************************************************************
* Copyright (C) 2015 Dimok
* Copyright (C) 2015-2018 VGMoose, rw-r-r_0644, Creepermario, Brienj
* Copyright (C) 2015 Dimok, Maschell
*
* 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
Expand Down
102 changes: 21 additions & 81 deletions src/menu/HomebrewWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
#include <sstream>



#define DEFAULT_WIILOAD_PORT 4299

#define MAX_BUTTONS_ON_PAGE 4
char * repoUrl = "http://wiiubru.com/appstore";
//char * repoUrl = "192.168.1.104:8000";
//char * repoUrl = "http://wiiubru.com/appstore/appstoretest";
Expand Down Expand Up @@ -317,7 +317,6 @@ void HomebrewWindow::loadLocalApps(int mode)
// file path
homebrewButtons[idx]->execPath = dirList->GetFilepath(i);
homebrewButtons[idx]->iconImgData = NULL;
homebrewButtons[idx]->typee = HBL;
homebrewButtons[idx]->dirPath = homebrewPath;

// // assume that the first part of homebrewPath is "sd:/wiiu/apps/"
Expand Down Expand Up @@ -364,6 +363,7 @@ This method fetches remote apps only and that's all nothing more
void HomebrewWindow::refreshHomebrewApps()
{
log_printf("refreshHomebrewApps: starting homebrew app refresh");

// get the 4 different types of app backgrounds

// clear arrays
Expand All @@ -380,70 +380,28 @@ void HomebrewWindow::refreshHomebrewApps()
FSUtils::CreateSubfolder(cache.c_str());
}

int count = 0;

// download app list from the repo
std::string targetUrl = std::string(repoUrl)+"/directory12.yaml";
if (!gotDirectorySuccess)
{
log_printf("refreshHomebrewApps: Downloading remote %s", targetUrl.c_str());
gotDirectorySuccess = FileDownloader::getFile(targetUrl, fileContents, &updateProgress);
// this->remove(progressWindow);
log_printf("refreshHomebrewApps: Updated directory");

std::istringstream f2(fileContents);

// get the total number of apps (lines divided by 7)
while (gotDirectorySuccess)
{
count ++;
std::string dummy;
if (!std::getline(f2, dummy)) break;
}

count /= 7;
}
// check if the Get object already exists, and make it if it doesn't
if (this->get == NULL)
this->get = new Get(".get", repoUrl);

std::istringstream f(fileContents);
int count = this->get->packages.size();

// totalLocalApps will represent how many apps aren't on the server
totalLocalApps = homebrewButtons.size();

u32 iterCount = 0;
globalUpdatePosition = true;

while (gotDirectorySuccess)
for (int iterCount=0; iterCount<count; iterCount++)
{
char numstr[30];
sprintf(numstr, "Updating App info... (%d/%d)", iterCount, count);

progressWindow->setTitle(numstr);
updateProgress(0, iterCount, count);

log_printf("starting yaml parsing");
std::string shortname;

// very poor yaml parsing, to be replaced with json in the future
if (!std::getline(f, shortname)) break;
shortname = shortname.substr(5);
std::string name;
std::getline(f, name);
name = name.substr(2);
std::string author;
std::getline(f, author);
author = author.substr(2);
std::string desc;
std::getline(f, desc);
desc = desc.substr(2);
std::string binary;
std::getline(f, binary);
binary = binary.substr(2);
std::string version;
std::getline(f, version);
version = version.substr(2);
std::string typee;
std::getline(f, typee);
typee = typee.substr(2);

// the info for the current package is stored within the package variable
Package* package = this->get->packages[iterCount];

log_printf("done yaml parsing");

Expand All @@ -454,37 +412,21 @@ void HomebrewWindow::refreshHomebrewApps()

homebrewButtons[idx] = new homebrewButton();
// file path
homebrewButtons[idx]->execPath = "";
log_printf("set exec path");

// store the package pointer inside the homebrew button element
homebrewButtons[idx]->package = package;

std::string homebrewPath = homebrewButtons[idx]->execPath;
size_t slashPos = homebrewPath.rfind('/');
if(slashPos != std::string::npos)
homebrewPath.erase(slashPos);

homebrewButtons[idx]->dirPath = homebrewPath;

// since we got this app from the net, mark it as a GET
homebrewButtons[idx]->status = GET;
homebrewButtons[idx]->shortname = shortname;
homebrewButtons[idx]->binary = binary;
homebrewButtons[idx]->version = version;
// store other proeprteis (legacy, reference)
homebrewButtons[idx]->status = package->status;
homebrewButtons[idx]->shortname = package->pkg_name;
homebrewButtons[idx]->category = package->category;
homebrewButtons[idx]->version = package->version;
log_printf("set a bunch of attributes");

// default to HBL type, set to RPX type if typee string matches
homebrewButtons[idx]->category = typee;

const char *cpName = name.c_str();
// const char *cpDescription = desc.c_str();

if(strncmp(cpName, "sd:/wiiu/apps/", strlen("sd:/wiiu/apps/")) == 0)
cpName += strlen("sd:/wiiu/apps/");

homebrewButtons[idx]->nameLabel = new GuiText(cpName, 28, glm::vec4(0, 0, 0, 1));
homebrewButtons[idx]->versionLabel = new GuiText(version.c_str(), 28, glm::vec4(0, 0, 0, 1));
homebrewButtons[idx]->coderLabel = new GuiText(author.c_str(), 28, glm::vec4(0, 0, 0, 1));
homebrewButtons[idx]->descriptionLabel = new GuiText(desc.c_str(), 28, glm::vec4(0, 0, 0, 1));
homebrewButtons[idx]->nameLabel = new GuiText(package->title.c_str(), 28, glm::vec4(0, 0, 0, 1));
homebrewButtons[idx]->versionLabel = new GuiText(package->version.c_str(), 28, glm::vec4(0, 0, 0, 1));
homebrewButtons[idx]->coderLabel = new GuiText(package->author.c_str(), 28, glm::vec4(0, 0, 0, 1));
homebrewButtons[idx]->descriptionLabel = new GuiText(package->short_desc.c_str(), 28, glm::vec4(0, 0, 0, 1));
log_printf("created some more attributes");

homebrewButtons[idx]->iconImgData = Resources::GetImageData("missing.png");
Expand All @@ -493,9 +435,7 @@ void HomebrewWindow::refreshHomebrewApps()
// add this to the remote button array
remoteAppButtons.push_back(homebrewButtons[idx]);


log_printf("added %s to the remoteApps vector", shortname.c_str());
iterCount ++;

// download the icon for this remote app if we aren't ignoring icons
if (!noIconMode)
Expand Down
25 changes: 17 additions & 8 deletions src/menu/HomebrewWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#include "gui/GuiFrame.h"
#include "menu/ProgressWindow.h"

#include <dynamic_libs/socket_functions.h>
#include "../libs/get/src/Get.hpp"

#define LOCAL 0
#define UPDATE 1
#define INSTALLED 2
Expand All @@ -33,7 +36,16 @@ extern ProgressWindow * progressWindow;

typedef struct
{
std::string execPath;
// for legacy apps uninstallation
std::string execPath = NULL;
int status;
std::string shortname;
std::string binary = NULL;
std::string category; // string version
std::string version;
std::string dirPath = NULL;

// properties to be displayed/drawn
GuiImage *image;
GuiButton *button;
GuiText *nameLabel;
Expand All @@ -42,13 +54,9 @@ typedef struct
GuiText *descriptionLabel;
GuiImageData *iconImgData;
GuiImage *iconImg;
std::string shortname;
int status;
std::string dirPath;
std::string binary;
std::string version;
std::string category;
int typee;

// the actual package this button represents
Package* package = NULL;
} homebrewButton;

extern void updateProgress(void *arg, u32 done, u32 total);
Expand All @@ -67,6 +75,7 @@ class HomebrewWindow : public GuiFrame, public sigslot::has_slots<>
std::vector<homebrewButton*> homebrewButtons;
GuiFrame * launchBox;

Get* get = NULL;

GuiSound *buttonClickSound;
GuiImageData * installedButtonImgData;
Expand Down

0 comments on commit 83e3c93

Please sign in to comment.