ZifLock

ZifLock — Lock the package system

Synopsis

#define             ZIF_LOCK_ERROR
struct              ZifLock;
struct              ZifLockClass;
enum                ZifLockError;
enum                ZifLockType;
enum                ZifLockMode;
GQuark              zif_lock_error_quark                (void);
ZifLock *           zif_lock_new                        (void);
gboolean            zif_lock_is_instance_valid          (void);
guint               zif_lock_take                       (ZifLock *lock,
                                                         ZifLockType type,
                                                         ZifLockMode mode,
                                                         GError **error);
gboolean            zif_lock_release                    (ZifLock *lock,
                                                         guint id,
                                                         GError **error);
void                zif_lock_release_noerror            (ZifLock *lock,
                                                         guint id);
const gchar *       zif_lock_type_to_string             (ZifLockType lock_type);
guint               zif_lock_get_state                  (ZifLock *lock);

Object Hierarchy

  GObject
   +----ZifLock

Signals

  "state-changed"                                  : Run Last

Description

This object works with the generic lock file.

Details

ZIF_LOCK_ERROR

#define ZIF_LOCK_ERROR		(zif_lock_error_quark ())


struct ZifLock

struct ZifLock;


struct ZifLockClass

struct ZifLockClass {
	GObjectClass		 parent_class;
	/* Signals */
	void			(* state_changed) (ZifLock *lock,
							 guint		 state_bitfield);
	/* Padding for future expansion */
	void (*_zif_reserved1) (void);
	void (*_zif_reserved2) (void);
	void (*_zif_reserved3) (void);
	void (*_zif_reserved4) (void);
};


enum ZifLockError

typedef enum {
	ZIF_LOCK_ERROR_FAILED,
	ZIF_LOCK_ERROR_ALREADY_LOCKED,
	ZIF_LOCK_ERROR_NOT_LOCKED,
	ZIF_LOCK_ERROR_PERMISSION,
	ZIF_LOCK_ERROR_LAST
} ZifLockError;

ZIF_LOCK_ERROR_FAILED

ZIF_LOCK_ERROR_ALREADY_LOCKED

ZIF_LOCK_ERROR_NOT_LOCKED

ZIF_LOCK_ERROR_PERMISSION

ZIF_LOCK_ERROR_LAST


enum ZifLockType

typedef enum {
	ZIF_LOCK_TYPE_RPMDB,
	ZIF_LOCK_TYPE_REPO,
	ZIF_LOCK_TYPE_METADATA,
	ZIF_LOCK_TYPE_GROUPS,
	ZIF_LOCK_TYPE_RELEASE,
	ZIF_LOCK_TYPE_CONFIG,
	ZIF_LOCK_TYPE_HISTORY,
	ZIF_LOCK_TYPE_LAST
} ZifLockType;

ZIF_LOCK_TYPE_RPMDB

ZIF_LOCK_TYPE_REPO

ZIF_LOCK_TYPE_METADATA

ZIF_LOCK_TYPE_GROUPS

ZIF_LOCK_TYPE_RELEASE

ZIF_LOCK_TYPE_CONFIG

ZIF_LOCK_TYPE_HISTORY

ZIF_LOCK_TYPE_LAST


enum ZifLockMode

typedef enum {
	ZIF_LOCK_MODE_THREAD,
	ZIF_LOCK_MODE_PROCESS,
	ZIF_LOCK_MODE_LAST
} ZifLockMode;

ZIF_LOCK_MODE_THREAD

ZIF_LOCK_MODE_PROCESS

ZIF_LOCK_MODE_LAST


zif_lock_error_quark ()

GQuark              zif_lock_error_quark                (void);

Returns :

An error quark.

Since 0.1.0


zif_lock_new ()

ZifLock *           zif_lock_new                        (void);

Returns :

A new lock instance.

Since 0.1.0


zif_lock_is_instance_valid ()

gboolean            zif_lock_is_instance_valid          (void);

Returns :

TRUE if a singleton instance already exists

Since 0.1.6


zif_lock_take ()

guint               zif_lock_take                       (ZifLock *lock,
                                                         ZifLockType type,
                                                         ZifLockMode mode,
                                                         GError **error);

Tries to take a lock for the packaging system.

lock :

A ZifLock

type :

A ZifLockType, e.g. ZIF_LOCK_TYPE_RPMDB

mode :

A ZifLockMode, e.g. ZIF_LOCK_MODE_PROCESS

error :

A GError, or NULL

Returns :

A lock ID greater than 0, or 0 for an error.

Since 0.3.1


zif_lock_release ()

gboolean            zif_lock_release                    (ZifLock *lock,
                                                         guint id,
                                                         GError **error);

Tries to release a lock for the packaging system.

lock :

A ZifLock

id :

A lock ID, as given by zif_lock_take()

error :

A GError, or NULL

Returns :

TRUE if we locked, else FALSE and the error is set

Since 0.3.1


zif_lock_release_noerror ()

void                zif_lock_release_noerror            (ZifLock *lock,
                                                         guint id);

Tries to release a lock for the packaging system. This method should not be used lightly as no error will be returned.

lock :

A ZifLock

id :

A lock ID, as given by zif_lock_take()

Since 0.3.1


zif_lock_type_to_string ()

const gchar *       zif_lock_type_to_string             (ZifLockType lock_type);

Returns :

The string representation of the type

Since 0.1.6


zif_lock_get_state ()

guint               zif_lock_get_state                  (ZifLock *lock);

Gets a bitfield of what locks have been taken

lock :

A ZifLock

Returns :

A bitfield.

Since 0.3.0

Signal Details

The "state-changed" signal

void                user_function                      (ZifLock *ziflock,
                                                        guint    arg1,
                                                        gpointer user_data)      : Run Last

ziflock :

the object which received the signal.

user_data :

user data set when the signal handler was connected.