ZifLock

ZifLock — Lock the package system

Synopsis

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

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;


enum ZifLockType

typedef enum {
	ZIF_LOCK_TYPE_RPMDB_WRITE,
	ZIF_LOCK_TYPE_REPO_WRITE,
	ZIF_LOCK_TYPE_METADATA_WRITE,
	ZIF_LOCK_TYPE_LAST
} ZifLockType;


zif_lock_error_quark ()

GQuark              zif_lock_error_quark                (void);

Returns :

An error quark.

Since 0.1.0


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


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_is_locked ()

gboolean            zif_lock_is_locked                  (ZifLock *lock,
                                                         guint *pid);

Gets the lock state.

This function is DEPRECATED as it's not threadsafe.

lock :

A ZifLock

pid :

The PID of the process holding the lock, or NULL

Returns :

TRUE if we are already locked

Since 0.1.0


zif_lock_new ()

ZifLock *           zif_lock_new                        (void);

Returns :

A new lock instance.

Since 0.1.0


zif_lock_release ()

gboolean            zif_lock_release                    (ZifLock *lock,
                                                         ZifLockType type,
                                                         GError **error);

Tries to release a lock for the packaging system.

lock :

A ZifLock

type :

A ZifLockType, e.g. ZIF_LOCK_TYPE_RPMDB_WRITE

error :

A GError, or NULL

Returns :

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

Since 0.1.6


zif_lock_set_locked ()

gboolean            zif_lock_set_locked                 (ZifLock *lock,
                                                         guint *pid,
                                                         GError **error);

Tries to lock the packaging system.

This function is DEPRECATED. Use zif_lock_take() instead.

lock :

A ZifLock

pid :

A PID of the process holding the lock, or NULL

error :

A GError, or NULL

Returns :

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

Since 0.1.0


zif_lock_set_unlocked ()

gboolean            zif_lock_set_unlocked               (ZifLock *lock,
                                                         GError **error);

Unlocks the packaging system.

This function is DEPRECATED. Use zif_lock_take() instead.

lock :

A ZifLock

error :

A GError, or NULL

Returns :

TRUE for success, FALSE otherwise

Since 0.1.0


zif_lock_take ()

gboolean            zif_lock_take                       (ZifLock *lock,
                                                         ZifLockType type,
                                                         GError **error);

Tries to take a lock for the packaging system.

lock :

A ZifLock

type :

A ZifLockType, e.g. ZIF_LOCK_TYPE_RPMDB_WRITE

error :

A GError, or NULL

Returns :

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

Since 0.1.6


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

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.