AptSession

AptSession — Easy high-level API for APT2 programs.

Stability Level

Unstable, unless otherwise indicated

Synopsis

#include <apt.h>

                    AptSession;
AptSession *        apt_session_new                     (GError **error);
void                apt_session_unref                   (AptSession *session);
AptSession *        apt_session_ref                     (AptSession *session);
AptConfiguration *  apt_session_get_configuration       (AptSession *session);
AptCache *          apt_session_get_cache               (AptSession *session);
AptSystem *         apt_session_get_system              (AptSession *session);
AptPolicy *         apt_session_get_policy              (AptSession *session);

Description

When writing a program using the APTLib API, the correct initialization of the classes, reading configuration, etc can become slightly annoying. The AptSession API is provided to make this setup as easy as possible. It takes care of reading the configuration files, loading the system, opening the cache, creating a new cache if none exists, updating the cache if it is outdated.

Programs using APTLib are expected to create a single AptSession at the beginning of the program execution and retrieve pointers to the AptSession members by calling the getter functions documented in this section.

Details

AptSession

typedef struct _AptSession AptSession;

AptSession is an opaque type which may only be accessed by the following functions.


apt_session_new ()

AptSession *        apt_session_new                     (GError **error);

Parses the configuration files, constructs the needed objects and creates a new AptSession.

error :

Location to store a GError.

Returns :

A newly allocated AptSession with reference count 1.

apt_session_unref ()

void                apt_session_unref                   (AptSession *session);

Decrements the reference count of session. If the reference count drops to 0, release all references held to the members and free the memory session points to.

session :

An AptSession

apt_session_ref ()

AptSession *        apt_session_ref                     (AptSession *session);

Increments the reference count of session.

session :

An AptSession

Returns :

session.

apt_session_get_configuration ()

AptConfiguration *  apt_session_get_configuration       (AptSession *session);

Gets an unowned reference to the AptConfiguration of session. Do not call apt_configuration_unref() on it, unless you previously called apt_configuration_ref() on it.

session :

An AptSession

Returns :

An unowned reference to the AptConfiguration of session.

apt_session_get_cache ()

AptCache *          apt_session_get_cache               (AptSession *session);

Gets an unowned reference to the AptCache contained in session. You must not call apt_cache_unref() on the return value, unless you previously called apt_cache_ref() on it.

session :

An AptSession

Returns :

An unowned reference to the AptCache of session.

apt_session_get_system ()

AptSystem *         apt_session_get_system              (AptSession *session);

Gets an unowned reference to the AptSystem contained in session. You must not call apt_system_unref() on the return value, unless you previously called apt_system_ref() on it.

session :

An AptSession

Returns :

An unowned reference to the AptSystem of session.

apt_session_get_policy ()

AptPolicy *         apt_session_get_policy              (AptSession *session);

Gets an unowned reference to the AptPolicy contained in session. You must not call apt_policy_unref() on the return value, unless you previously called apt_policy_ref() on it.

session :

An AptPolicy

Returns :

An unowned reference to the AptPolicy of session.