1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-23 04:05:54 +02:00

Open OPKs only if compatible with the current platform

This commit is contained in:
Paul Cercueil 2012-11-18 18:52:23 -03:00
parent d4c086a64d
commit c6a83e1ed7
2 changed files with 26 additions and 2 deletions

View File

@ -73,6 +73,7 @@ esac
AC_SUBST(PLATFORM) AC_SUBST(PLATFORM)
AC_SUBST(SCREEN_RES) AC_SUBST(SCREEN_RES)
AC_DEFINE_UNQUOTED(PLATFORM, "${PLATFORM}")
AC_OUTPUT(Makefile src/Makefile data/Makefile) AC_OUTPUT(Makefile src/Makefile data/Makefile)

View File

@ -86,17 +86,40 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
struct ParserData *pdata = opk_open(linkfile); struct ParserData *pdata = opk_open(linkfile);
char *param; char *param;
bool has_metadata = false;
if (!pdata) { if (!pdata) {
ERROR("Unable to initialize libopk\n"); ERROR("Unable to initialize libopk\n");
return; return;
} }
if (!opk_open_metadata(pdata)) { for(;;) {
ERROR("OPK does not contain any meta-data\n"); const char *str = opk_open_metadata(pdata);
if (!str)
break;
/* Strip .desktop */
string metadata(str);
pos = metadata.rfind('.');
metadata = metadata.substr(0, pos);
/* Keep only the platform name */
pos = metadata.rfind('.');
metadata = metadata.substr(pos + 1);
if (metadata.compare(PLATFORM) == 0) {
has_metadata = true;
break;
}
}
if (!has_metadata) {
ERROR("%s does not contain any meta-data for this platform\n", linkfile);
opk_close(pdata); opk_close(pdata);
return; return;
} }
opkFile = file; opkFile = file;
pos = file.rfind('/'); pos = file.rfind('/');
opkMount = file.substr(pos+1); opkMount = file.substr(pos+1);