gst_rtsp_permissions_unref
gst_rtsp_permissions_add_role
gst_rtsp_permissions_add_role_valist
+gst_rtsp_permissions_add_role_empty
+gst_rtsp_permissions_add_permission_for_role
gst_rtsp_permissions_remove_role
gst_rtsp_permissions_get_role
gst_rtsp_permissions_is_allowed
}
/**
+ * gst_rtsp_permissions_add_permission_for_role:
+ * @permissions: a #GstRTSPPermissions
+ * @role: a role
+ * @permission: the permission
+ * @allowed: whether the role has this permission or not
+ *
+ * Add a new @permission for @role to @permissions with the access in @allowed.
+ *
+ * Since: 1.14
+ */
+void
+gst_rtsp_permissions_add_permission_for_role (GstRTSPPermissions * permissions,
+ const gchar * role, const gchar * permission, gboolean allowed)
+{
+ GstRTSPPermissionsImpl *impl = (GstRTSPPermissionsImpl *) permissions;
+ guint i, len;
+
+ g_return_if_fail (GST_IS_RTSP_PERMISSIONS (permissions));
+ g_return_if_fail (gst_mini_object_is_writable (&permissions->mini_object));
+ g_return_if_fail (role != NULL);
+ g_return_if_fail (permission != NULL);
+
+ len = impl->roles->len;
+ for (i = 0; i < len; i++) {
+ GstStructure *entry = g_ptr_array_index (impl->roles, i);
+
+ if (gst_structure_has_name (entry, role)) {
+ gst_structure_set (entry, permission, G_TYPE_BOOLEAN, allowed, NULL);
+ return;
+ }
+ }
+
+ gst_rtsp_permissions_add_role (permissions, role,
+ permission, G_TYPE_BOOLEAN, allowed, NULL);
+}
+
+/**
+ * gst_rtsp_permissions_add_role_empty: (rename-to gst_rtsp_permissions_add_role)
+ * @permissions: a #GstRTSPPermissions
+ * @role: a role
+ *
+ * Add a new @role to @permissions without any permissions. You can add
+ * permissions for the role with gst_rtsp_permissions_add_permission_for_role().
+ *
+ * Since: 1.14
+ */
+void
+gst_rtsp_permissions_add_role_empty (GstRTSPPermissions * permissions,
+ const gchar * role)
+{
+ gst_rtsp_permissions_add_role (permissions, role, NULL);
+}
+
+/**
* gst_rtsp_permissions_add_role:
* @permissions: a #GstRTSPPermissions
* @role: a role
g_return_if_fail (GST_IS_RTSP_PERMISSIONS (permissions));
g_return_if_fail (gst_mini_object_is_writable (&permissions->mini_object));
g_return_if_fail (role != NULL);
- g_return_if_fail (fieldname != NULL);
structure = gst_structure_new_valist (role, fieldname, var_args);
g_return_if_fail (structure != NULL);
va_list var_args);
GST_EXPORT
+void gst_rtsp_permissions_add_role_empty (GstRTSPPermissions * permissions,
+ const gchar * role);
+
+GST_EXPORT
+void gst_rtsp_permissions_add_permission_for_role (GstRTSPPermissions * permissions,
+ const gchar * role,
+ const gchar * permission,
+ gboolean allowed);
+
+GST_EXPORT
void gst_rtsp_permissions_remove_role (GstRTSPPermissions *permissions,
const gchar *role);
fail_unless (gst_rtsp_permissions_is_allowed (perms, "admin", "permission2"));
fail_if (gst_rtsp_permissions_is_allowed (perms, "user", "permission1"));
fail_if (gst_rtsp_permissions_is_allowed (perms, "user", "permission2"));
+
+ /* _add_permission_for_role() should overwrite existing or create new role */
+ fail_unless (gst_rtsp_permissions_is_allowed (perms, "admin", "permission1"));
+ gst_rtsp_permissions_add_permission_for_role (perms, "admin", "permission1",
+ FALSE);
+ fail_if (gst_rtsp_permissions_is_allowed (perms, "admin", "permission1"));
+
+ fail_if (gst_rtsp_permissions_is_allowed (perms, "tester", "permission1"));
+ gst_rtsp_permissions_add_permission_for_role (perms, "tester", "permission1",
+ TRUE);
+ fail_unless (gst_rtsp_permissions_is_allowed (perms, "tester",
+ "permission1"));
+ gst_rtsp_permissions_add_permission_for_role (perms, "tester", "permission1",
+ FALSE);
+ fail_if (gst_rtsp_permissions_is_allowed (perms, "tester", "permission1"));
+ gst_rtsp_permissions_add_permission_for_role (perms, "tester", "permission2",
+ TRUE);
+ fail_unless (gst_rtsp_permissions_is_allowed (perms, "tester",
+ "permission2"));
+ fail_if (gst_rtsp_permissions_is_allowed (perms, "tester", "permission3"));
+
+ gst_rtsp_permissions_add_role_empty (perms, "noone");
+ fail_if (gst_rtsp_permissions_is_allowed (perms, "noone", "permission1"));
+
gst_rtsp_permissions_unref (perms);
}