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

Build file extensions filter from the MIME types present on the OPK

This feature is enabled only if libxdgmime is available.
This commit is contained in:
Paul Cercueil 2012-10-22 23:40:09 +02:00
parent e7e21b424b
commit 5f1cff6d0f
2 changed files with 36 additions and 0 deletions

View File

@ -27,6 +27,9 @@ AC_CHECK_LIB(png, png_read_image,,check_png="no")
# Check for libopk
AC_CHECK_LIB(opk, opk_open)
# Check for libxdgmime
AC_CHECK_LIB(xdgmime, xdg_mime_get_extensions_from_mime_type)
AC_ARG_ENABLE(platform,
[ --enable-platform=X specify the targeted platform],
[GMENU2X_PLATFORM="$enableval"], [GMENU2X_PLATFORM="default"])

View File

@ -45,6 +45,10 @@
#include <opk.h>
#endif
#ifdef HAVE_LIBXDGMIME
#include <xdgmime.h>
#endif
using fastdelegate::MakeDelegate;
using namespace std;
@ -158,6 +162,35 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
consoleApp = !strcmp(param, "true");
#endif
#ifdef HAVE_LIBXDGMIME
param = opk_read_param(pdata, "MimeType");
if (param) {
string::size_type oldpos = 0;
string mimetypes = param;
while ((pos = mimetypes.find(';')) != mimetypes.npos) {
int nb = 16;
char *extensions[nb];
string mimetype = mimetypes.substr(oldpos, pos);
mimetypes = mimetypes.substr(pos + 1);
nb = xdg_mime_get_extensions_from_mime_type(
mimetype.c_str(), extensions, nb);
while (nb--) {
selectorfilter += (string) extensions[nb] + ',';
free(extensions[nb]);
}
oldpos = pos + 1;
}
/* Remove last comma */
selectorfilter.erase(selectorfilter.end());
DEBUG("Compatible extensions: %s\n", selectorfilter.c_str());
}
#endif /* HAVE_LIBXDGMIME */
param = opk_read_param(pdata, "X-OD-Manual");
if (param)
manual = param;