diff --git a/modules/appmodel/app-parser-generator.c b/modules/appmodel/app-parser-generator.c index 21e0f4823d..8f7fe060b0 100644 --- a/modules/appmodel/app-parser-generator.c +++ b/modules/appmodel/app-parser-generator.c @@ -31,6 +31,7 @@ typedef struct _AppParserGenerator { AppObjectGenerator super; const gchar *topic; + const gchar *filterx_app_variable; GString *block; gboolean first_app_generated; gboolean allow_overlaps; @@ -60,6 +61,13 @@ _parse_allow_overlaps(AppParserGenerator *self, CfgArgs *args, const gchar *refe return TRUE; } +static gboolean +_parse_filterx_app_variable(AppParserGenerator *self, CfgArgs *args, const gchar *reference) +{ + self->filterx_app_variable = cfg_args_get(args, "filterx-app-variable"); + return TRUE; +} + static gboolean app_parser_generator_parse_arguments(AppObjectGenerator *s, CfgArgs *args, const gchar *reference) { @@ -72,6 +80,9 @@ app_parser_generator_parse_arguments(AppObjectGenerator *s, CfgArgs *args, const if (!_parse_allow_overlaps(self, args, reference)) return FALSE; + if (!_parse_filterx_app_variable(self, args, reference)) + return FALSE; + if (!app_object_generator_parse_arguments_method(&self->super, args, reference)) return FALSE; @@ -139,20 +150,23 @@ _generate_action(AppParserGenerator *self, Application *app) if (self->allow_overlaps) return; - if (app->filterx_expr) - g_string_append_printf(self->block, - " filterx {\n" - " meta.app_name = '%s';\n" - " };\n", - app->super.name); - + if (self->filterx_app_variable) + { + g_string_append_printf(self->block, + " filterx {\n" + " %s = '%s';\n" + " };\n", + self->filterx_app_variable, app->super.name); + } else - g_string_append_printf(self->block, - " rewrite {\n" - " set-tag('.app.%s');\n" - " set('%s' value('.app.name'));\n" - " };\n", - app->super.name, app->super.name); + { + g_string_append_printf(self->block, + " rewrite {\n" + " set-tag('.app.%s');\n" + " set('%s' value('.app.name'));\n" + " };\n", + app->super.name, app->super.name); + } } static void diff --git a/modules/appmodel/app-transform-generator.c b/modules/appmodel/app-transform-generator.c index 7c04a2cb61..b806013e7b 100644 --- a/modules/appmodel/app-transform-generator.c +++ b/modules/appmodel/app-transform-generator.c @@ -29,6 +29,7 @@ typedef struct _AppTransformGenerator { AppObjectGenerator super; const gchar *flavour; + const gchar *filterx_app_variable; GString *block; } AppTransformGenerator; @@ -41,6 +42,19 @@ _parse_transforms_arg(AppTransformGenerator *self, CfgArgs *args, const gchar *r return TRUE; } +static gboolean +_parse_filterx_app_variable(AppTransformGenerator *self, CfgArgs *args, const gchar *reference) +{ + self->filterx_app_variable = cfg_args_get(args, "filterx-app-variable"); + if (!self->filterx_app_variable) + { + msg_error("app-transform() requires a filterx-app-variable() argument", + evt_tag_str("reference", reference)); + return FALSE; + } + return TRUE; +} + static gboolean app_transform_generator_parse_arguments(AppObjectGenerator *s, CfgArgs *args, const gchar *reference) { @@ -50,6 +64,9 @@ app_transform_generator_parse_arguments(AppObjectGenerator *s, CfgArgs *args, co if (!_parse_transforms_arg(self, args, reference)) return FALSE; + if (!_parse_filterx_app_variable(self, args, reference)) + return FALSE; + if (!app_object_generator_parse_arguments_method(&self->super, args, reference)) return FALSE; @@ -82,7 +99,8 @@ _generate_app_transform(Transformation *transformation, gpointer user_data) return; g_string_append_printf(self->block, "\n#Start Application %s\n", transformation->super.name); - g_string_append_printf(self->block, " if (meta.app_name == '%s') {\n", transformation->super.name); + g_string_append_printf(self->block, " if (%s == '%s') {\n", self->filterx_app_variable, + transformation->super.name); for (GList *l = transformation->blocks; l; l = l->next) { TransformationBlock *block = l->data;