1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-06-30 20:34:11 +03: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(SCREEN_RES)
AC_DEFINE_UNQUOTED(PLATFORM, "${PLATFORM}")
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);
char *param;
bool has_metadata = false;
if (!pdata) {
ERROR("Unable to initialize libopk\n");
return;
}
if (!opk_open_metadata(pdata)) {
ERROR("OPK does not contain any meta-data\n");
for(;;) {
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);
return;
}
opkFile = file;
pos = file.rfind('/');
opkMount = file.substr(pos+1);