mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-05 07:31:54 +02:00
Merge branch 'opkrun'
This commit is contained in:
commit
0fd8333257
@ -57,7 +57,8 @@ using namespace std;
|
|||||||
static const char *tokens[] = { "%f", "%F", "%u", "%U", };
|
static const char *tokens[] = { "%f", "%F", "%u", "%U", };
|
||||||
|
|
||||||
#ifdef HAVE_LIBOPK
|
#ifdef HAVE_LIBOPK
|
||||||
LinkApp::LinkApp(GMenu2X *gmenu2x_, const char* linkfile, struct OPK *opk)
|
LinkApp::LinkApp(GMenu2X *gmenu2x_, const char* linkfile,
|
||||||
|
struct OPK *opk, const char *metadata_)
|
||||||
#else
|
#else
|
||||||
LinkApp::LinkApp(GMenu2X *gmenu2x_, const char* linkfile)
|
LinkApp::LinkApp(GMenu2X *gmenu2x_, const char* linkfile)
|
||||||
#endif
|
#endif
|
||||||
@ -80,12 +81,14 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, const char* linkfile)
|
|||||||
|
|
||||||
#ifdef HAVE_LIBOPK
|
#ifdef HAVE_LIBOPK
|
||||||
isOPK = !!opk;
|
isOPK = !!opk;
|
||||||
|
|
||||||
if (isOPK) {
|
if (isOPK) {
|
||||||
string::size_type pos;
|
string::size_type pos;
|
||||||
const char *key, *val;
|
const char *key, *val;
|
||||||
size_t lkey, lval;
|
size_t lkey, lval;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
metadata.assign(metadata_);
|
||||||
opkFile = file;
|
opkFile = file;
|
||||||
pos = file.rfind('/');
|
pos = file.rfind('/');
|
||||||
opkMount = file.substr(pos+1);
|
opkMount = file.substr(pos+1);
|
||||||
@ -138,24 +141,6 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, const char* linkfile)
|
|||||||
iconPath = this->icon;
|
iconPath = this->icon;
|
||||||
updateSurfaces();
|
updateSurfaces();
|
||||||
|
|
||||||
} else if (!strncmp(key, "Exec", lkey)) {
|
|
||||||
string tmp = buf;
|
|
||||||
pos = tmp.find(' ');
|
|
||||||
exec = tmp.substr(0, pos);
|
|
||||||
|
|
||||||
if (pos != tmp.npos) {
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
params = tmp.substr(pos + 1);
|
|
||||||
|
|
||||||
for (i = 0; i < sizeof(tokens) / sizeof(tokens[0]); i++) {
|
|
||||||
if (params.find(tokens[i]) != params.npos) {
|
|
||||||
selectordir = CARD_ROOT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -551,31 +536,7 @@ void LinkApp::selector(int startSelection, const string &selectorDir) {
|
|||||||
void LinkApp::launch(const string &selectedFile) {
|
void LinkApp::launch(const string &selectedFile) {
|
||||||
save();
|
save();
|
||||||
|
|
||||||
if (isOpk()) {
|
if (!isOpk()) {
|
||||||
#ifdef HAVE_LIBOPK
|
|
||||||
int err;
|
|
||||||
|
|
||||||
/* To be sure... */
|
|
||||||
string cmd = "umount " + opkMount;
|
|
||||||
system(cmd.c_str());
|
|
||||||
|
|
||||||
mkdir(opkMount.c_str(), 0700);
|
|
||||||
cmd = "mount -o loop,nosuid,ro " + opkFile + ' ' + opkMount;
|
|
||||||
err = system(cmd.c_str());
|
|
||||||
|
|
||||||
if (err) {
|
|
||||||
ERROR("Unable to mount OPK\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
chdir(opkMount.c_str());
|
|
||||||
if (exec[0] != '/') {
|
|
||||||
string tmp = opkMount + exec.substr(0, exec.find(" "));
|
|
||||||
if (fileExists(tmp))
|
|
||||||
exec = opkMount + exec;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
//Set correct working directory
|
//Set correct working directory
|
||||||
string::size_type pos = exec.rfind("/");
|
string::size_type pos = exec.rfind("/");
|
||||||
if (pos != string::npos) {
|
if (pos != string::npos) {
|
||||||
@ -587,7 +548,7 @@ void LinkApp::launch(const string &selectedFile) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!selectedFile.empty()) {
|
if (!selectedFile.empty()) {
|
||||||
string path = cmdclean(selectedFile);
|
string path = selectedFile;
|
||||||
|
|
||||||
if (params.empty()) {
|
if (params.empty()) {
|
||||||
params = path;
|
params = path;
|
||||||
@ -601,23 +562,21 @@ void LinkApp::launch(const string &selectedFile) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO("Executing '%s' (%s %s)\n", title.c_str(), exec.c_str(), params.c_str());
|
if (gmenu2x->confInt["outputLogs"]
|
||||||
|
|
||||||
//check if we have to quit
|
|
||||||
string command = cmdclean(exec);
|
|
||||||
|
|
||||||
if (!params.empty()) command += " " + params;
|
|
||||||
#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0)
|
#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0)
|
||||||
if (gmenu2x->confInt["outputLogs"] && !consoleApp)
|
&& !consoleApp
|
||||||
command += " &> " LOG_FILE;
|
|
||||||
#else
|
|
||||||
if (gmenu2x->confInt["outputLogs"])
|
|
||||||
command += " &> " LOG_FILE;
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_LIBOPK
|
|
||||||
if (isOPK)
|
|
||||||
command += " ; umount -l " + opkMount;
|
|
||||||
#endif
|
#endif
|
||||||
|
) {
|
||||||
|
int fd = open(LOG_FILE, O_WRONLY | O_TRUNC | O_CREAT, 0644);
|
||||||
|
if (fd < 0) {
|
||||||
|
ERROR("Unable to open log file for write: %s\n", LOG_FILE);
|
||||||
|
} else {
|
||||||
|
fflush(stdout);
|
||||||
|
dup2(fd, STDOUT_FILENO);
|
||||||
|
dup2(fd, STDERR_FILENO);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gmenu2x->saveSelection();
|
gmenu2x->saveSelection();
|
||||||
|
|
||||||
@ -654,7 +613,18 @@ void LinkApp::launch(const string &selectedFile) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
execlp("/bin/sh","/bin/sh", "-c", command.c_str(), NULL);
|
if (isOpk()) {
|
||||||
|
#ifdef HAVE_LIBOPK
|
||||||
|
execlp("opkrun", "opkrun", "-m", metadata.c_str(), opkFile.c_str(),
|
||||||
|
!params.empty() ? params.c_str() : NULL,
|
||||||
|
NULL);
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
std::string command = exec + " " + params;
|
||||||
|
INFO("Executing '%s' (%s)\n", title.c_str(), command.c_str());
|
||||||
|
execlp("/bin/sh", "/bin/sh", "-c", command.c_str(), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
//if execution continues then something went wrong and as we already called SDL_Quit we cannot continue
|
//if execution continues then something went wrong and as we already called SDL_Quit we cannot continue
|
||||||
//try relaunching gmenu2x
|
//try relaunching gmenu2x
|
||||||
gmenu2x->main();
|
gmenu2x->main();
|
||||||
|
@ -45,7 +45,7 @@ private:
|
|||||||
bool dontleave;
|
bool dontleave;
|
||||||
#ifdef HAVE_LIBOPK
|
#ifdef HAVE_LIBOPK
|
||||||
bool isOPK;
|
bool isOPK;
|
||||||
std::string opkMount, opkFile, category;
|
std::string opkMount, opkFile, category, metadata;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
@ -59,7 +59,8 @@ public:
|
|||||||
bool isOpk() { return isOPK; }
|
bool isOpk() { return isOPK; }
|
||||||
const std::string &getOpkFile() { return opkFile; }
|
const std::string &getOpkFile() { return opkFile; }
|
||||||
|
|
||||||
LinkApp(GMenu2X *gmenu2x, const char* linkfile, struct OPK *opk = NULL);
|
LinkApp(GMenu2X *gmenu2x, const char* linkfile,
|
||||||
|
struct OPK *opk = NULL, const char *metadata = NULL);
|
||||||
#else
|
#else
|
||||||
LinkApp(GMenu2X *gmenu2x, const char* linkfile);
|
LinkApp(GMenu2X *gmenu2x, const char* linkfile);
|
||||||
bool isOpk() { return false; }
|
bool isOpk() { return false; }
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <ini.h>
|
||||||
|
|
||||||
#ifdef HAVE_LIBOPK
|
#ifdef HAVE_LIBOPK
|
||||||
#include <opk.h>
|
#include <opk.h>
|
||||||
@ -672,11 +673,11 @@ void Menu::openPackage(std::string path, bool order)
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
bool has_metadata = false;
|
bool has_metadata = false;
|
||||||
|
const char *name;
|
||||||
LinkApp *link;
|
LinkApp *link;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
string::size_type pos;
|
string::size_type pos;
|
||||||
const char *name;
|
|
||||||
int ret = opk_open_metadata(opk, &name);
|
int ret = opk_open_metadata(opk, &name);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ERROR("Error while loading meta-data\n");
|
ERROR("Error while loading meta-data\n");
|
||||||
@ -702,7 +703,7 @@ void Menu::openPackage(std::string path, bool order)
|
|||||||
if (!has_metadata)
|
if (!has_metadata)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
link = new LinkApp(gmenu2x, path.c_str(), opk);
|
link = new LinkApp(gmenu2x, path.c_str(), opk, name);
|
||||||
link->setSize(gmenu2x->skinConfInt["linkWidth"], gmenu2x->skinConfInt["linkHeight"]);
|
link->setSize(gmenu2x->skinConfInt["linkWidth"], gmenu2x->skinConfInt["linkHeight"]);
|
||||||
|
|
||||||
addSection(link->getCategory());
|
addSection(link->getCategory());
|
||||||
|
Loading…
Reference in New Issue
Block a user