Top | ![]() |
![]() |
![]() |
![]() |
FCmdrProfileApplies * | applies-to | Read / Write / Construct Only |
gchar * | description | Read / Write / Construct Only |
gchar * | etag | Read / Write / Construct Only |
gchar * | name | Read / Write / Construct Only |
JsonObject * | settings | Read / Write / Construct Only |
FCmdrProfileSource * | source | Read / Write |
gchar * | uid | Read / Write / Construct Only |
A FCmdrProfile instance holds settings to be locked for some combination of users, groups, and hosts. Profiles are typically loaded from a remote source as described by a FCmdrProfileSource.
A FCmdrProfile consists of a unique identifier or “uid” field, an entity tag or “etag” field for fast comparisons, human-readable “name” and “description” fields, and an assortment of “settings” grouped by context.
Each “settings” context in a profile is handled by a custom FCmdrServiceBackend. For example the "org.gnome.gsettings" context is handled by a custom FCmdrServiceBackend that knows how to parse and apply those settings by interacting with
dconf.FCmdrProfile * fcmdr_profile_new (const gchar *data
,gssize length
,GError **error
);
Deserializes the JSON data
into a new FCmdrProfile instance and checks
the contents for validity. If an error occurs during deserialization or
validation, the function sets error
and returns NULL
.
A validated profile is guaranteed to have non-empty “uid”, “etag”, and “settings” values.
FCmdrProfile * fcmdr_profile_new_from_node (JsonNode *node
,GError **error
);
Deserializes node
into a new FCmdrProfile instance and checks the
contents for validity. If an error occurs during deserialization or
validation, the function sets error
and returns NULL
.
A validated profile is guaranteed to have non-empty “uid”, “etag”, and “settings” values.
FCmdrProfile * fcmdr_profile_new_from_stream (GInputStream *stream
,GCancellable *cancellable
,GError **error
);
Deserializes the stream
contents into a new FCmdrProfile instance
and checks the contents for validity. If an error occurs during
deserialization or validation, the function sets error
and returns NULL
.
A validated profile is guaranteed to have non-empty “uid”, “etag”, and “settings” values.
guint
fcmdr_profile_hash (FCmdrProfile *profile
);
Generates a hash value for profile
. This function is intended for
easily hashing a FCmdrProfile to add to a GHashTable or similar data
structure.
gboolean fcmdr_profile_equal (FCmdrProfile *profile1
,FCmdrProfile *profile2
);
Checks two FCmdrProfile instances for equality. Two FCmdrProfile instances are equal if their “uid” values are equal.
const gchar *
fcmdr_profile_get_uid (FCmdrProfile *profile
);
Returns the profile
's unique identifier.
const gchar *
fcmdr_profile_get_etag (FCmdrProfile *profile
);
Returns the profile
's entity tag.
const gchar *
fcmdr_profile_get_name (FCmdrProfile *profile
);
Returns the profile
's display name.
const gchar *
fcmdr_profile_get_description (FCmdrProfile *profile
);
Returns a brief description of the profile
.
FCmdrProfileApplies *
fcmdr_profile_get_applies_to (FCmdrProfile *profile
);
Returns the FCmdrProfileApplies describing which users, groups and/or
hosts profile
applies to. A NULL
return value indicates the profile
applies unconditionally.
The returned FCmdrProfileApplies is owned by profile
and should not be
modified or freed.
JsonObject *
fcmdr_profile_ref_settings (FCmdrProfile *profile
);
Returns the raw settings data as a JSON object, grouped by context with member names denoting the context.
The returned JsonObject is referenced for thread-safety and must be
unreferenced with json_object_unref()
when finished with it.
FCmdrProfileSource *
fcmdr_profile_ref_source (FCmdrProfile *profile
);
Returns the FCmdrProfileSource from which the profile
originated, or
NULL
if the profile
was added interactively or by some other means.
The returned FCmdrProfileSource is referenced for thread-safety and must
be unreferenced with g_object_unref()
when finished with it.
void fcmdr_profile_set_source (FCmdrProfile *profile
,FCmdrProfileSource *source
);
Sets the FCmdrProfileSource from which the profile
originated.
Typically this is called once, immediately after a FCmdrProfile
is instantiated.
gboolean fcmdr_profile_applies_to_user (FCmdrProfile *profile
,uid_t uid
,guint *out_score
);
Returns whether profile
applies to the user identified by uid
by
examining the “applies-to” data.
If profile
applies, the function returns TRUE
and assigns a positive
score to out_score
. The score is meant to help rank a set of applicable
profiles. Profiles with higher scores should be given higher priority.
If profile
does NOT apply, the function returns FALSE
and assigns zero
to out_score
.
Note the score value is based on heuristics which are subject to change.
FCmdrProfileApplies *
fcmdr_profile_applies_new (void
);
Allocates and zero-fills a new FCmdrProfileApplies structure.
Free the allocated structure with fcmdr_profile_applies_free()
.
FCmdrProfileApplies *
fcmdr_profile_applies_copy (FCmdrProfileApplies *applies
);
Allocates a complete copy of applies
. Free the allocated copy with
fcmdr_profile_applies_free()
.
void
fcmdr_profile_applies_free (FCmdrProfileApplies *applies
);
Frees applies
as well as any NULL
-terminated string arrays contained
within, or does nothing if applies
is NULL
.
struct FCmdrProfile;
Contains only private data that should be read and manipulated using the functions below.
struct FCmdrProfileApplies { gchar **users; gchar **groups; gchar **hosts; };
A FCmdrProfileApplies describes the applicability of a FCmdrProfile
to a given user or host machine. If a user's name is included in users
,
or the user is a member of any groups included in groups
, or if the local
machine's host name is included in hosts
, then the FCmdrProfile applies.
“applies-to”
property“applies-to” FCmdrProfileApplies *
Set of users, groups and hosts to which the profile applies.
Flags: Read / Write / Construct Only
“description”
property“description” gchar *
A brief description of the profile.
Flags: Read / Write / Construct Only
Default value: NULL
“etag”
property“etag” gchar *
The profile's entity tag.
Flags: Read / Write / Construct Only
Default value: NULL
“name”
property“name” gchar *
The profile's display name.
Flags: Read / Write / Construct Only
Default value: NULL
“settings”
property“settings” JsonObject *
Raw settings data in JSON format.
Flags: Read / Write / Construct Only
“uid”
property“uid” gchar *
The profile's unique ID.
Flags: Read / Write / Construct Only
Default value: NULL