Extra checks when parsing file.

This commit is contained in:
Dave Davenport 2016-08-29 08:55:28 +02:00
parent a90ff48032
commit 1f641135e2
1 changed files with 19 additions and 1 deletions

View File

@ -171,6 +171,17 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, char
g_free ( id );
return;
}
// Skip non Application entries.
if ( g_key_file_has_key ( kf, "Desktop Entry", "Type", NULL )){
gchar *key = g_key_file_get_string ( kf, "Desktop Entry", "Type", NULL );
if ( g_strcmp0(key, "Application")){
g_free(key);
g_key_file_free ( kf );
g_free ( path );
g_free ( id );
return;
}
}
// Skip hidden entries.
if ( g_key_file_has_key ( kf, "Desktop Entry", "Hidden", NULL ) ) {
if ( g_key_file_get_boolean ( kf, "Desktop Entry", "Hidden", NULL ) ) {
@ -197,6 +208,14 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, char
g_free ( id );
return;
}
// We need Exec, don't support DBusActivatable
if ( !g_key_file_has_key ( kf, "Desktop Entry", "Exec", NULL ) ) {
fprintf(stderr, "DesktopFile has no Exec option, DBusActivatable is not supported: '%s'\n", path);
g_key_file_free ( kf );
g_free ( path );
g_free ( id );
return;
}
if ( g_key_file_has_key ( kf, "Desktop Entry", "Exec", NULL ) ) {
size_t nl = ( ( pd->cmd_list_length ) + 1 );
pd->entry_list = g_realloc ( pd->entry_list, nl * sizeof ( *( pd->entry_list ) ) );
@ -310,7 +329,6 @@ static void get_apps_history ( DRunModePrivateData *pd )
char **st = g_strsplit ( retv[index], ":::", 2 );
if ( st && st[0] && st[1] ) {
gchar *name = g_path_get_basename ( st[1] );
printf ( ": %s\n", st[0] );
read_desktop_file ( pd, st[0], g_strdup ( st[1] ), name );
g_free ( name );
}