Mirage.Context

g GObject.Object GObject.Object Mirage.Context Mirage.Context GObject.Object->Mirage.Context

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

clear_options ()

create_input_stream (filename)

create_output_stream (filename, filter_chain)

get_debug_domain ()

get_debug_mask ()

get_debug_name ()

get_option (name)

load_image (filenames)

obtain_password ()

set_debug_domain (domain)

set_debug_mask (debug_mask)

set_debug_name (name)

set_option (name, value)

set_password_function (func, *user_data)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Mirage.Context(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Mirage.ContextClass

All the fields in the Mirage.Context structure are private to the Mirage.Context implementation and should never be accessed directly.

clear_options()

Clears all the options from the context.

create_input_stream(filename)
Parameters:

filename (str) – filename to create input stream on

Raises:

GLib.Error

Returns:

on success, an object implementing Mirage.Stream interface is returned, which can be used to access data stored in file. On failure, None is returned. The reference to the object should be released using GObject.Object.unref() when no longer needed.

Return type:

Mirage.Stream

Opens a file pointed to by filename and creates a chain of filter streams on top of it.

create_output_stream(filename, filter_chain)
Parameters:
  • filename (str) – filename to create output stream on

  • filter_chain ([str] or None) – None-terminated array of strings describing types of filters to include in the filter chain, or None

Raises:

GLib.Error

Returns:

on success, an object implementing Mirage.Stream interface is returned, which can be used to write data to file. On failure, None is returned. The reference to the object should be released using GObject.Object.unref() when no longer needed.

Return type:

Mirage.Stream

Opens a file pointed to by filename and optionally creates a chain of filter streams on top of it.

The chain of filters is described by filter-chain, which is a None-terminated array of strings corresponding to type names of filters, with the last filter being the one on the top. Filters are passed by their name types because their actual type values are determined when the plugins are loaded. If invalid filter is specified in the chain, this function will fail. It is the caller’s responsibility to construct a valid filter chain.

get_debug_domain()
Returns:

pointer to buffer containing the domain name, or None. The buffer belongs to the object and should not be modified.

Return type:

str

Retrieves debug context’s domain name.

get_debug_mask()
Returns:

debug context’s debug mask

Return type:

int

Retrieves debug context’s debug mask.

get_debug_name()
Returns:

pointer to buffer containing the name, or None. The buffer belongs to the object and should not be modified.

Return type:

str

Retrieves debug context’s name.

get_option(name)
Parameters:

name (str) – option name

Returns:

pointer to a GLib.Variant containing the option value on success, None on failure.

Return type:

GLib.Variant

Retrieves option named name from the context.

load_image(filenames)
Parameters:

filenames ([str]) – filename(s)

Raises:

GLib.Error

Returns:

a Mirage.Disc object on success, None on failure. The reference to the object should be released using GObject.Object.unref() when no longer needed.

Return type:

Mirage.Disc

Creates a Mirage.Disc object representing image stored in filenames. filenames is a None-terminated list of filenames containing image data. The function tries to find a parser that can handle give filename(s) and uses it to load the data into disc object.

If multiple filenames are provided and parser supports only single-file images, only the first filename is used.

obtain_password()
Raises:

GLib.Error

Returns:

password string on success, None on failure. The string should be freed with GLib.free() when no longer needed.

Return type:

str

Obtains password string, using the Mirage.PasswordFunction callback that was provided via Mirage.Context.set_password_function().

set_debug_domain(domain)
Parameters:

domain (str) – domain name

Sets debug context’s domain name to domain.

set_debug_mask(debug_mask)
Parameters:

debug_mask (int) – debug mask

Sets debug context’s debug mask.

set_debug_name(name)
Parameters:

name (str) – name

Sets debug context’s name to name.

set_option(name, value)
Parameters:

Sets an option to the context. If option with the specified name already exists, it is replaced.

set_password_function(func, *user_data)
Parameters:

Sets the password function to context. The function is used by parsers that support encrypted images to obtain password for unlocking such images.

Both func and user_data can be None; in that case the appropriate setting will be reset.