mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-26 01:50:16 +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:
parent
e7e21b424b
commit
5f1cff6d0f
@ -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"])
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user