PolkitSubject

PolkitSubject — Type for representing subjects

Functions

Types and Values

Object Hierarchy

    GInterface
    ╰── PolkitSubject

Prerequisites

PolkitSubject requires GObject.

Known Implementations

PolkitSubject is implemented by PolkitSystemBusName, PolkitUnixProcess and PolkitUnixSession.

Description

PolkitSubject is an abstract type for representing one or more processes.

Functions

polkit_subject_hash ()

guint
polkit_subject_hash (PolkitSubject *subject);

Gets a hash code for subject that can be used with e.g. g_hash_table_new().

Parameters

subject

A PolkitSubject.

 

Returns

A hash code.


polkit_subject_equal ()

gboolean
polkit_subject_equal (PolkitSubject *a,
                      PolkitSubject *b);

Checks if a and b are equal, ie. represent the same subject. However, avoid calling polkit_subject_equal() to compare two processes; for more information see the PolkitUnixProcess documentation.

This function can be used in e.g. g_hash_table_new().

Parameters

a

A PolkitSubject.

 

b

A PolkitSubject.

 

Returns

TRUE if a and b are equal, FALSE otherwise.


polkit_subject_exists ()

void
polkit_subject_exists (PolkitSubject *subject,
                       GCancellable *cancellable,
                       GAsyncReadyCallback callback,
                       gpointer user_data);

Asynchronously checks if subject exists.

When the operation is finished, callback will be invoked in the

thread-default main loop of the thread you are calling this method

from. You can then call polkit_subject_exists_finish() to get the result of the operation.

Parameters

subject

A PolkitSubject.

 

cancellable

A GCancellable or NULL.

[allow-none]

callback

A GAsyncReadyCallback to call when the request is satisfied

 

user_data

The data to pass to callback .

 

polkit_subject_exists_finish ()

gboolean
polkit_subject_exists_finish (PolkitSubject *subject,
                              GAsyncResult *res,
                              GError **error);

Finishes checking whether a subject exists.

Parameters

subject

A PolkitSubject.

 

res

A GAsyncResult obtained from the GAsyncReadyCallback passed to polkit_subject_exists().

 

error

Return location for error or NULL.

[allow-none]

Returns

TRUE if the subject exists, FALSE if not or error is set.


polkit_subject_exists_sync ()

gboolean
polkit_subject_exists_sync (PolkitSubject *subject,
                            GCancellable *cancellable,
                            GError **error);

Checks if subject exists.

This is a synchronous blocking call - the calling thread is blocked until a reply is received. See polkit_subject_exists() for the asynchronous version.

Parameters

subject

A PolkitSubject.

 

cancellable

A GCancellable or NULL.

[allow-none]

error

Return location for error or NULL.

[allow-none]

Returns

TRUE if the subject exists, FALSE if not or error is set.


polkit_subject_to_string ()

gchar *
polkit_subject_to_string (PolkitSubject *subject);

Serializes subject to a string that can be used in polkit_subject_from_string().

Parameters

subject

A PolkitSubject.

 

Returns

A string representing subject . Free with g_free().


polkit_subject_from_string ()

PolkitSubject *
polkit_subject_from_string (const gchar *str,
                            GError **error);

Creates an object from str that implements the PolkitSubject interface.

Parameters

str

A string obtained from polkit_subject_to_string().

 

error

Return location for error or NULL.

[allow-none]

Returns

A PolkitSubject or NULL if error is set. Free with g_object_unref().

[transfer full]

Types and Values

PolkitSubject

typedef struct _PolkitSubject PolkitSubject;

Generic type for all objects that can be used as subjects.


struct PolkitSubjectIface

struct PolkitSubjectIface {
  GTypeInterface parent_iface;

  guint    (*hash)          (PolkitSubject       *subject);

  gboolean (*equal)         (PolkitSubject       *a,
                             PolkitSubject       *b);

  gchar *  (*to_string)     (PolkitSubject       *subject);

  void     (*exists)        (PolkitSubject       *subject,
                             GCancellable        *cancellable,
                             GAsyncReadyCallback  callback,
                             gpointer             user_data);

  gboolean (*exists_finish) (PolkitSubject       *subject,
                             GAsyncResult        *res,
                             GError             **error);

  gboolean (*exists_sync)   (PolkitSubject       *subject,
                             GCancellable        *cancellable,
                             GError             **error);
};

An interface for subjects.

Members

GTypeInterface parent_iface;

The parent interface.

 

hash ()

Gets a hash value for a PolkitSubject.

 

equal ()

Checks if two PolkitSubjects are equal.

 

to_string ()

Serializes a PolkitSubject to a string that can be used in polkit_subject_from_string().

 

exists ()

Asynchronously check if a PolkitSubject exists.

 

exists_finish ()

Finishes checking if a PolkitSubject exists.

 

exists_sync ()

Synchronously check if a PolkitSubject exists.