1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-29 09:48:28 +02:00

Add support for reading manuals located inside OPK archives

This commit is contained in:
Paul Cercueil 2012-11-11 19:47:45 -03:00
parent 8d96f3c261
commit 77046f3553
2 changed files with 45 additions and 2 deletions

View File

@ -1011,7 +1011,7 @@ void GMenu2X::contextMenu() {
{
LinkApp* app = menu->selLinkApp();
if (app && fileExists(app->getManual())) {
if (app && !app->getManual().empty()) {
MenuOption opt = {tr.translate("Show manual of $1",menu->selLink()->getTitle().c_str(),NULL),
MakeDelegate(this, &GMenu2X::showManual),
};

View File

@ -31,6 +31,7 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
@ -381,7 +382,49 @@ void LinkApp::start() {
}
void LinkApp::showManual() {
if (manual=="" || !fileExists(manual)) return;
if (manual.empty())
return;
#ifdef HAVE_LIBOPK
if (isOPK) {
vector<string> readme;
char *token, *buf, *ptr;
struct ParserData *pdata;
pdata = opk_open(opkFile.c_str());
if (!pdata) {
WARNING("Unable to open OPK to read manual\n");
return;
}
buf = ptr = opk_extract_file(pdata, manual.c_str());
opk_close(pdata);
if (!buf) {
WARNING("Unable to read manual from OPK\n");
return;
}
while((token = strchr(ptr, '\n'))) {
*token = '\0';
string str(ptr);
readme.push_back(str);
ptr = token + 1;
}
/* Add the last line */
string str(ptr);
readme.push_back(str);
free(buf);
TextDialog td(gmenu2x, getTitle(), "ReadMe", getIconPath(), &readme);
td.exec();
return;
}
#endif
if (!fileExists(manual))
return;
// Png manuals
string ext8 = manual.substr(manual.size()-8,8);