mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-29 15:20:39 +02:00
LinkApp: Added support for reading OPK packages.
This commit is contained in:
parent
e3837fce68
commit
61d22e26e6
@ -41,11 +41,20 @@
|
|||||||
#include <linux/vt.h>
|
#include <linux/vt.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBOPK
|
||||||
|
#include <opk.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using fastdelegate::MakeDelegate;
|
using fastdelegate::MakeDelegate;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBOPK
|
||||||
|
LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
|
||||||
|
const char* linkfile, bool opk)
|
||||||
|
#else
|
||||||
LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
|
LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
|
||||||
const char* linkfile)
|
const char* linkfile)
|
||||||
|
#endif
|
||||||
: Link(gmenu2x_, ts, MakeDelegate(this, &LinkApp::start))
|
: Link(gmenu2x_, ts, MakeDelegate(this, &LinkApp::start))
|
||||||
, inputMgr(inputMgr_)
|
, inputMgr(inputMgr_)
|
||||||
{
|
{
|
||||||
@ -61,6 +70,66 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
|
|||||||
consoleApp = false;
|
consoleApp = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBOPK
|
||||||
|
isOPK = opk;
|
||||||
|
if (opk) {
|
||||||
|
struct ParserData *pdata = openMetadata(linkfile);
|
||||||
|
char *param;
|
||||||
|
if (!pdata) {
|
||||||
|
ERROR("Unable to initialize libopk\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
file = linkfile;
|
||||||
|
|
||||||
|
param = readParam(pdata, "Name");
|
||||||
|
if (!param)
|
||||||
|
ERROR("Missing \"Name\" parameter\n");
|
||||||
|
else
|
||||||
|
title = param;
|
||||||
|
|
||||||
|
param = readParam(pdata, "Comment");
|
||||||
|
if (param)
|
||||||
|
description = param;
|
||||||
|
|
||||||
|
/* Read the icon from the OPK only
|
||||||
|
* if it doesn't exist on the skin */
|
||||||
|
param = readParam(pdata, "Icon");
|
||||||
|
if (param) {
|
||||||
|
this->icon = gmenu2x->sc.getSkinFilePath((string) param + ".png");
|
||||||
|
if (this->icon.empty())
|
||||||
|
this->icon = (string) linkfile + '#' + param + ".png";
|
||||||
|
iconSurface = gmenu2x->sc[this->icon];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iconPath.empty())
|
||||||
|
searchIcon();
|
||||||
|
|
||||||
|
param = readParam(pdata, "Exec");
|
||||||
|
if (!param)
|
||||||
|
ERROR("Missing \"Exec\" parameter\n");
|
||||||
|
else
|
||||||
|
exec = param;
|
||||||
|
|
||||||
|
#ifdef PLATFORM_DINGUX
|
||||||
|
param = readParam(pdata, "Terminal");
|
||||||
|
if (param)
|
||||||
|
consoleApp = !strcmp(param, "true");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
param = readParam(pdata, "X-OD-Manual");
|
||||||
|
if (param)
|
||||||
|
manual = param;
|
||||||
|
|
||||||
|
param = readParam(pdata, "X-OD-Daemon");
|
||||||
|
if (param)
|
||||||
|
dontleave = !strcmp(param, "true");
|
||||||
|
|
||||||
|
edited = false;
|
||||||
|
closeMetadata(pdata);
|
||||||
|
}
|
||||||
|
#endif /* HAVE_LIBOPK */
|
||||||
|
|
||||||
string line;
|
string line;
|
||||||
ifstream infile (linkfile, ios_base::in);
|
ifstream infile (linkfile, ios_base::in);
|
||||||
while (getline(infile, line, '\n')) {
|
while (getline(infile, line, '\n')) {
|
||||||
@ -71,6 +140,9 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
|
|||||||
string::size_type position = line.find("=");
|
string::size_type position = line.find("=");
|
||||||
string name = trim(line.substr(0,position));
|
string name = trim(line.substr(0,position));
|
||||||
string value = trim(line.substr(position+1));
|
string value = trim(line.substr(position+1));
|
||||||
|
#ifdef HAVE_LIBOPK
|
||||||
|
if (!opk) {
|
||||||
|
#endif
|
||||||
if (name == "title") {
|
if (name == "title") {
|
||||||
title = value;
|
title = value;
|
||||||
} else if (name == "description") {
|
} else if (name == "description") {
|
||||||
@ -88,6 +160,11 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
|
|||||||
#ifdef PLATFORM_DINGUX
|
#ifdef PLATFORM_DINGUX
|
||||||
} else if (name == "consoleapp") {
|
} else if (name == "consoleapp") {
|
||||||
if (value == "true") consoleApp = true;
|
if (value == "true") consoleApp = true;
|
||||||
|
#endif
|
||||||
|
} else if (name == "selectorfilter") {
|
||||||
|
setSelectorFilter( value );
|
||||||
|
#ifdef HAVE_LIBOPK
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if (name == "clock") {
|
} else if (name == "clock") {
|
||||||
setClock( atoi(value.c_str()) );
|
setClock( atoi(value.c_str()) );
|
||||||
@ -95,8 +172,6 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
|
|||||||
setSelectorDir( value );
|
setSelectorDir( value );
|
||||||
} else if (name == "selectorbrowser") {
|
} else if (name == "selectorbrowser") {
|
||||||
if (value=="true") selectorbrowser = true;
|
if (value=="true") selectorbrowser = true;
|
||||||
} else if (name == "selectorfilter") {
|
|
||||||
setSelectorFilter( value );
|
|
||||||
} else if (name == "selectorscreens") {
|
} else if (name == "selectorscreens") {
|
||||||
setSelectorScreens( value );
|
setSelectorScreens( value );
|
||||||
} else if (name == "selectoraliases") {
|
} else if (name == "selectoraliases") {
|
||||||
@ -162,22 +237,28 @@ bool LinkApp::save() {
|
|||||||
|
|
||||||
ofstream f(file.c_str());
|
ofstream f(file.c_str());
|
||||||
if (f.is_open()) {
|
if (f.is_open()) {
|
||||||
|
#ifdef HAVE_LIBOPK
|
||||||
|
if (!isOPK) {
|
||||||
|
#endif
|
||||||
if (title!="" ) f << "title=" << title << endl;
|
if (title!="" ) f << "title=" << title << endl;
|
||||||
if (description!="" ) f << "description=" << description << endl;
|
if (description!="" ) f << "description=" << description << endl;
|
||||||
if (icon!="" ) f << "icon=" << icon << endl;
|
if (icon!="" ) f << "icon=" << icon << endl;
|
||||||
if (exec!="" ) f << "exec=" << exec << endl;
|
if (exec!="" ) f << "exec=" << exec << endl;
|
||||||
if (params!="" ) f << "params=" << params << endl;
|
if (params!="" ) f << "params=" << params << endl;
|
||||||
if (manual!="" ) f << "manual=" << manual << endl;
|
if (manual!="" ) f << "manual=" << manual << endl;
|
||||||
if (iclock!=0 ) f << "clock=" << iclock << endl;
|
|
||||||
if (selectordir!="" ) f << "selectordir=" << selectordir << endl;
|
|
||||||
if (selectorbrowser ) f << "selectorbrowser=true" << endl;
|
|
||||||
if (selectorfilter!="" ) f << "selectorfilter=" << selectorfilter << endl;
|
|
||||||
if (selectorscreens!="") f << "selectorscreens=" << selectorscreens << endl;
|
|
||||||
if (aliasfile!="" ) f << "selectoraliases=" << aliasfile << endl;
|
|
||||||
if (dontleave ) f << "dontleave=true" << endl;
|
if (dontleave ) f << "dontleave=true" << endl;
|
||||||
#ifdef PLATFORM_DINGUX
|
#ifdef PLATFORM_DINGUX
|
||||||
if (consoleApp ) f << "consoleapp=true" << endl;
|
if (consoleApp ) f << "consoleapp=true" << endl;
|
||||||
#endif
|
#endif
|
||||||
|
if (selectorfilter!="" ) f << "selectorfilter=" << selectorfilter << endl;
|
||||||
|
#ifdef HAVE_LIBOPK
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (iclock!=0 ) f << "clock=" << iclock << endl;
|
||||||
|
if (selectordir!="" ) f << "selectordir=" << selectordir << endl;
|
||||||
|
if (selectorbrowser ) f << "selectorbrowser=true" << endl;
|
||||||
|
if (selectorscreens!="") f << "selectorscreens=" << selectorscreens << endl;
|
||||||
|
if (aliasfile!="" ) f << "selectoraliases=" << aliasfile << endl;
|
||||||
f.close();
|
f.close();
|
||||||
sync();
|
sync();
|
||||||
return true;
|
return true;
|
||||||
|
@ -47,6 +47,9 @@ private:
|
|||||||
std::string file;
|
std::string file;
|
||||||
|
|
||||||
bool dontleave;
|
bool dontleave;
|
||||||
|
#ifdef HAVE_LIBOPK
|
||||||
|
bool isOPK;
|
||||||
|
#endif
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void launch(
|
void launch(
|
||||||
@ -54,8 +57,14 @@ private:
|
|||||||
const std::string &selectedDir = "");
|
const std::string &selectedDir = "");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
#ifdef HAVE_LIBOPK
|
||||||
|
LinkApp(GMenu2X *gmenu2x, Touchscreen &ts, InputManager &inputMgr,
|
||||||
|
const char* linkfile, bool opk = false);
|
||||||
|
#else
|
||||||
LinkApp(GMenu2X *gmenu2x, Touchscreen &ts, InputManager &inputMgr,
|
LinkApp(GMenu2X *gmenu2x, Touchscreen &ts, InputManager &inputMgr,
|
||||||
const char* linkfile);
|
const char* linkfile);
|
||||||
|
#endif
|
||||||
|
|
||||||
virtual const std::string &searchIcon();
|
virtual const std::string &searchIcon();
|
||||||
|
|
||||||
#ifdef PLATFORM_DINGUX
|
#ifdef PLATFORM_DINGUX
|
||||||
|
Loading…
Reference in New Issue
Block a user