char *group_description;
char *policy_description;
+ char *policy_message;
};
extern void _polkit_policy_file_entry_set_descriptions (PolKitPolicyFileEntry *pfe,
const char *group_description,
- const char *policy_description);
+ const char *policy_description,
+ const char *policy_message);
extern PolKitPolicyDefault *_polkit_policy_default_new (PolKitResult defaults_allow_inactive,
void
_polkit_policy_file_entry_set_descriptions (PolKitPolicyFileEntry *policy_file_entry,
const char *group_description,
- const char *policy_description)
+ const char *policy_description,
+ const char *policy_message)
{
g_return_if_fail (policy_file_entry != NULL);
policy_file_entry->group_description = g_strdup (group_description);
policy_file_entry->policy_description = g_strdup (policy_description);
+ policy_file_entry->policy_message = g_strdup (policy_message);
}
/**
* polkit_policy_file_get_action_description:
* @policy_file_entry: the object
*
- * Get the description of the action that this policy entry describes.
+ * Get the description of the action that this policy entry describes. This
+ * is intended to be used in policy editors, for example "Mount internal
+ * volumes". Contrast with polkit_policy_file_get_action_message(). The
+ * textual string will be returned in the current locale.
*
* Note, if polkit_context_set_load_descriptions() on the
* #PolKitContext object used to get this object wasn't called, this
}
/**
+ * polkit_policy_file_get_action_message:
+ * @policy_file_entry: the object
+ *
+ * Get the message describing the action that this policy entry
+ * describes. This is to be used in dialogs, for example "System
+ * Policy prevents mounting this volume". Contrast with
+ * polkit_policy_file_get_action_description(). The textual string
+ * will be returned in the current locale.
+ *
+ * Note, if polkit_context_set_load_descriptions() on the
+ * #PolKitContext object used to get this object wasn't called, this
+ * method will return #NULL.
+ *
+ * Returns: string or #NULL if descriptions are not loaded - caller shall not free this string
+ **/
+const char *
+polkit_policy_file_get_action_message (PolKitPolicyFileEntry *policy_file_entry)
+{
+ g_return_val_if_fail (policy_file_entry != NULL, NULL);
+ return policy_file_entry->policy_message;
+}
+
+/**
* polkit_policy_file_entry_ref:
* @policy_file_entry: the policy file object
*
STATE_IN_GROUP_DESCRIPTION,
STATE_IN_POLICY,
STATE_IN_POLICY_DESCRIPTION,
+ STATE_IN_POLICY_MESSAGE,
STATE_IN_DEFAULTS,
STATE_IN_DEFAULTS_ALLOW_INACTIVE,
STATE_IN_DEFAULTS_ALLOW_ACTIVE
char *group_description;
char *policy_description;
+ char *policy_message;
} ParserData;
static void
state = STATE_IN_POLICY;
pd->policy_description = NULL;
+ pd->policy_message = NULL;
/* initialize defaults */
pd->defaults_allow_inactive = POLKIT_RESULT_NO;
state = STATE_IN_DEFAULTS;
else if (strcmp (el, "description") == 0)
state = STATE_IN_POLICY_DESCRIPTION;
+ else if (strcmp (el, "message") == 0)
+ state = STATE_IN_POLICY_MESSAGE;
break;
case STATE_IN_POLICY_DESCRIPTION:
break;
+ case STATE_IN_POLICY_MESSAGE:
+ break;
case STATE_IN_DEFAULTS:
if (strcmp (el, "allow_inactive") == 0)
state = STATE_IN_DEFAULTS_ALLOW_INACTIVE;
switch (pd->state) {
case STATE_IN_GROUP_DESCRIPTION:
- if (pd->load_descriptions)
+ if (pd->load_descriptions) {
+ if (pd->group_description != NULL)
+ g_free (pd->group_description);
pd->group_description = g_strdup (str);
+ }
break;
case STATE_IN_POLICY_DESCRIPTION:
- if (pd->load_descriptions)
+ if (pd->load_descriptions) {
+ if (pd->policy_description != NULL)
+ g_free (pd->policy_description);
pd->policy_description = g_strdup (str);
+ }
+ break;
+
+ case STATE_IN_POLICY_MESSAGE:
+ if (pd->load_descriptions) {
+ if (pd->policy_message != NULL)
+ g_free (pd->policy_message);
+ pd->policy_message = g_strdup (str);
+ }
break;
case STATE_IN_DEFAULTS_ALLOW_INACTIVE:
extern void _polkit_policy_file_entry_set_descriptions (PolKitPolicyFileEntry *pfe,
const char *group_description,
- const char *policy_description);
+ const char *policy_description,
+ const char *policy_message);
static void
_end (void *data, const char *el)
if (pd->load_descriptions)
_polkit_policy_file_entry_set_descriptions (pfe,
pd->group_description,
- pd->policy_description);
+ pd->policy_description,
+ pd->policy_message);
pd->pf->entries = g_slist_prepend (pd->pf->entries, pfe);
case STATE_IN_POLICY_DESCRIPTION:
state = STATE_IN_POLICY;
break;
+ case STATE_IN_POLICY_MESSAGE:
+ state = STATE_IN_POLICY;
+ break;
case STATE_IN_DEFAULTS:
state = STATE_IN_POLICY;
break;
pd.action_id = NULL;
pd.group_description = NULL;
pd.policy_description = NULL;
+ pd.policy_message = NULL;
pd.pf = pf;
pd.load_descriptions = load_descriptions;
g_free (pd.action_id);
g_free (pd.group_description);
g_free (pd.policy_description);
+ g_free (pd.policy_message);
if (xml_res == 0) {
polkit_error_set_error (error, POLKIT_ERROR_POLICY_FILE_INVALID,