Skip to content

Commit affe7b7

Browse files
committed
fix download and delee code to be more reliable
hardcode for local address
1 parent d6f0339 commit affe7b7

File tree

8 files changed

+34
-26
lines changed

8 files changed

+34
-26
lines changed

hbas.elf

256 Bytes
Binary file not shown.

hbas_dbg.elf

305 Bytes
Binary file not shown.

src/gui/GuiFrame.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ GuiFrame::~GuiFrame()
4343
closing(this);
4444

4545
if(parent)
46-
parent->remove(this);
46+
parent->removeE(this);
4747
}
4848

4949
void GuiFrame::append(GuiElement* e)
5050
{
5151
if (e == NULL)
5252
return;
5353

54-
remove(e);
54+
removeE(e);
5555
elements.push_back(e);
5656
e->setParent(this);
5757
}
@@ -61,12 +61,12 @@ void GuiFrame::insert(GuiElement* e, u32 index)
6161
if (e == NULL || (index >= elements.size()))
6262
return;
6363

64-
remove(e);
64+
removeE(e);
6565
elements.insert(elements.begin()+index, e);
6666
e->setParent(this);
6767
}
6868

69-
void GuiFrame::remove(GuiElement* e)
69+
void GuiFrame::removeE(GuiElement* e)
7070
{
7171
if (e == NULL)
7272
return;

src/gui/GuiFrame.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ class GuiFrame : public GuiElement
4242
void insert(GuiElement* e, u32 i);
4343
//!Removes the specified GuiElement from the GuiFrame
4444
//!\param e GuiElement to be removed
45-
void remove(GuiElement* e);
45+
void removeE(GuiElement* e);
4646
//!Removes all GuiElements
4747
void removeAll();
4848
//!Bring element to front of the window
49-
void bringToFront(GuiElement *e) { remove(e); append(e); }
49+
void bringToFront(GuiElement *e) { removeE(e); append(e); }
5050
//!Returns the GuiElement at the specified index
5151
//!\param index The index of the element
5252
//!\return A pointer to the element at the index, NULL on error (eg: out of bounds)

src/menu/HomebrewLaunchWindow.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ HomebrewLaunchWindow::HomebrewLaunchWindow(homebrewButton & thisButton)
117117
loadBtn.setImage(&loadImg);
118118
loadBtn.setLabel(&loadBtnLabel);
119119
loadBtn.setAlignment(ALIGN_CENTER | ALIGN_MIDDLE);
120-
loadBtn.setPosition(-200, -310);
120+
loadBtn.setPosition(-600, -310);
121121
loadBtn.setTrigger(&touchTrigger);
122122
loadBtn.setTrigger(&wpadTouchTrigger);
123123
loadBtn.setEffectGrow();
@@ -136,7 +136,7 @@ HomebrewLaunchWindow::HomebrewLaunchWindow(homebrewButton & thisButton)
136136
delBtn.setEffectGrow();
137137
delBtn.setSoundClick(buttonClickSound);
138138
delBtn.clicked.connect(this, &HomebrewLaunchWindow::OnDeleteButtonClick);
139-
// append(&delBtn);
139+
append(&delBtn);
140140

141141
backImg.setScale(scaleFactor);
142142
backBtn.setSize(scaleFactor * backImg.getWidth(), scaleFactor * backImg.getHeight());
@@ -169,7 +169,7 @@ void HomebrewLaunchWindow::OnOpenEffectFinish(GuiElement *element)
169169
void HomebrewLaunchWindow::OnCloseEffectFinish(GuiElement *element)
170170
{
171171
//! remove element from draw list and push to delete queue
172-
remove(element);
172+
removeE(element);
173173
AsyncDeleter::pushForDelete(element);
174174

175175
backBtn.clearState(GuiElement::STATE_DISABLED);
@@ -195,9 +195,15 @@ void HomebrewLaunchWindow::OnFileLoadFinish(GuiElement *element, const std::stri
195195

196196
void HomebrewLaunchWindow::OnDeleteButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger)
197197
{
198-
std::string path = "/apps/"+selectedButton.shortname+"/"+selectedButton.binary;
199-
std::string sdPath = "sd:/wiiu"+path;
200-
rename("sdPath", "sd:/.Trashes/oiuwroiuewr");
198+
std::string removePath = selectedButton.dirPath;
199+
// if the remove path is the whole directory, stop!
200+
if (!removePath.compare(std::string("sd:/wiiu/apps")) || !removePath.compare(std::string("sd:/wiiu/apps/")))
201+
return;
202+
203+
DirList dirList(removePath, 0, DirList::Files | DirList::CheckSubfolders);
204+
for (int x=0; x<dirList.GetFilecount(); x++)
205+
remove(dirList.GetFilepath(x));
206+
rmdir(removePath.c_str());
201207
}
202208

203209
void HomebrewLaunchWindow::OnLoadButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger)
@@ -209,9 +215,10 @@ void HomebrewLaunchWindow::OnLoadButtonClick(GuiButton *button, const GuiControl
209215
std::string path = "/apps/"+selectedButton.shortname;
210216
std::string sdPath = "sd:/wiiu"+path;
211217
CreateSubfolder(sdPath.c_str());
212-
FileDownloader::getFile("http://wiiubru.com/appstore"+path+"/"+selectedButton.binary, sdPath+"/"+selectedButton.binary, 0);
213-
FileDownloader::getFile("http://wiiubru.com/appstore"+path+"/meta.xml", sdPath+"/meta.xml", 0);
214-
FileDownloader::getFile("http://wiiubru.com/appstore"+path+"/icon.png", sdPath+"/icon.png", 0);
218+
std::string repoUrl = "http://192.168.1.104:8000";
219+
FileDownloader::getFile(repoUrl+path+"/"+selectedButton.binary, sdPath+"/"+selectedButton.binary, 0);
220+
FileDownloader::getFile(repoUrl+path+"/meta.xml", sdPath+"/meta.xml", 0);
221+
FileDownloader::getFile(repoUrl+path+"/icon.png", sdPath+"/icon.png", 0);
215222

216223

217224
// struct SYSBrowserArgsIn args = {};

src/menu/HomebrewWindow.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ HomebrewWindow::HomebrewWindow(int w, int h)
123123
HomebrewXML metaXml;
124124

125125
bool xmlReadSuccess = metaXml.LoadHomebrewXMLData((homebrewPath + "/meta.xml").c_str());
126-
126+
127127
const char *cpName = xmlReadSuccess ? metaXml.GetName() : homebrewButtons[idx].execPath.c_str();
128128
const char *cpDescription = xmlReadSuccess ? metaXml.GetShortDescription() : "";
129129

@@ -171,7 +171,8 @@ HomebrewWindow::HomebrewWindow(int w, int h)
171171

172172
// download app list from wiiubru
173173
std::string fileContents;
174-
std::string targetUrl = std::string("http://wiiubru.com/appstore/directory.yaml");
174+
std::string repoUrl = "http://192.168.1.104:8000";
175+
std::string targetUrl = std::string(repoUrl+"/directory.yaml");
175176
FileDownloader::getFile(targetUrl, fileContents);
176177
std::istringstream f(fileContents);
177178

@@ -221,7 +222,7 @@ HomebrewWindow::HomebrewWindow(int w, int h)
221222
homebrewButtons[idx].binary = binary;
222223
// download app list from wiiubru
223224
std::string targetIcon;
224-
std::string targetIconUrl = std::string("http://wiiubru.com/appstore/apps/" + shortname + "/icon.png");
225+
std::string targetIconUrl = std::string(repoUrl+"/apps/" + shortname + "/icon.png");
225226
FileDownloader::getFile(targetIconUrl, targetIcon);
226227

227228
// if(targetIcon != NULL)
@@ -346,7 +347,7 @@ void HomebrewWindow::OnOpenEffectFinish(GuiElement *element)
346347
void HomebrewWindow::OnCloseEffectFinish(GuiElement *element)
347348
{
348349
//! remove element from draw list and push to delete queue
349-
remove(element);
350+
removeE(element);
350351
AsyncDeleter::pushForDelete(element);
351352

352353
for(u32 i = 0; i < homebrewButtons.size(); i++)
@@ -401,7 +402,7 @@ void HomebrewWindow::OnLeftArrowClick(GuiButton *button, const GuiController *co
401402
targetLeftPosition = -listOffset * getWidth();
402403

403404
if(listOffset == 0)
404-
remove(&arrowLeftButton);
405+
removeE(&arrowLeftButton);
405406
append(&arrowRightButton);
406407
}
407408
}
@@ -414,7 +415,7 @@ void HomebrewWindow::OnRightArrowClick(GuiButton *button, const GuiController *c
414415
targetLeftPosition = -listOffset * getWidth();
415416

416417
if(((listOffset + 1) * MAX_BUTTONS_ON_PAGE) >= (int)homebrewButtons.size())
417-
remove(&arrowRightButton);
418+
removeE(&arrowRightButton);
418419

419420
append(&arrowLeftButton);
420421
}

src/menu/MainWindow.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ MainWindow::MainWindow(int w, int h)
4848

4949
MainWindow::~MainWindow()
5050
{
51-
remove(&homebrewWindow);
52-
remove(&bgImageColor);
51+
removeE(&homebrewWindow);
52+
removeE(&bgImageColor);
5353

5454
while(!tvElements.empty())
5555
{
5656
delete tvElements[0];
57-
remove(tvElements[0]);
57+
removeE(tvElements[0]);
5858
}
5959
while(!drcElements.empty())
6060
{
6161
delete drcElements[0];
62-
remove(drcElements[0]);
62+
removeE(drcElements[0]);
6363
}
6464
for(int i = 0; i < 4; i++)
6565
{

src/menu/MainWindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class MainWindow : public sigslot::has_slots<>
9999
}
100100
}
101101

102-
void remove(GuiElement *e)
102+
void removeE(GuiElement *e)
103103
{
104104
removeTv(e);
105105
removeDrc(e);

0 commit comments

Comments
 (0)