InfRequest

InfRequest — Asynchronous request

Stability Level

Unstable, unless otherwise indicated

Synopsis

#include <libinfinity/common/inf-request.h>

                    InfRequest;
struct              InfRequestIface;
void                (*InfRequestFunc)                   (InfRequest *request,
                                                         const InfRequestResult *result,
                                                         const GError *error,
                                                         gpointer user_data);
void                inf_request_fail                    (InfRequest *request,
                                                         const GError *error);
void                inf_request_finish                  (InfRequest *request,
                                                         InfRequestResult *result);
gboolean            inf_request_is_local                (InfRequest *request);

Object Hierarchy

  GInterface
   +----InfRequest

Prerequisites

InfRequest requires GObject.

Known Implementations

InfRequest is implemented by InfcProgressRequest, InfcRequest, InfdProgressRequest and InfdRequest.

Properties

  "progress"                 gdouble               : Read
  "type"                     gchar*                : Read / Write / Construct Only

Signals

  "finished"                                       : Run Last

Description

InfRequest represents a potentially asynchronous operation. This is a basic interface which allows to query the type of the operation and to be notified when the request finishes.

Details

InfRequest

typedef struct _InfRequest InfRequest;

InfRequest is an opaque data type. You should only access it via the public API functions.


struct InfRequestIface

struct InfRequestIface {
  void (*finished)(InfRequest* request,
                   const InfRequestResult* result,
                   const GError* error);

  gboolean (*is_local)(InfRequest* request);
};

Virtual functions of the InfRequest interface.

finished ()

Default signal handler of the "finished" signal.

is_local ()

Virtual function to check whether the request is local or remote.

InfRequestFunc ()

void                (*InfRequestFunc)                   (InfRequest *request,
                                                         const InfRequestResult *result,
                                                         const GError *error,
                                                         gpointer user_data);

Signature of a signal handler for the "finished" signal.

request :

The InfRequest that emits the signal.

result :

A InfRequestResult which contains the result of the request.

error :

Error information in case the request failed, or NULL otherwise.

user_data :

Additional data set when the signal handler was connected.

inf_request_fail ()

void                inf_request_fail                    (InfRequest *request,
                                                         const GError *error);

Declares the request as failed by emitting the "finished" signal with the given error.

request :

A InfRequest.

error :

A GError describing the reason for why the request failed.

inf_request_finish ()

void                inf_request_finish                  (InfRequest *request,
                                                         InfRequestResult *result);

Declares the request as succeeded by emitting the "finished" signal with the given result. The function takes ownership of result.

request :

A InfRequest.

result :

A InfRequestResult containing the result of the request.

inf_request_is_local ()

gboolean            inf_request_is_local                (InfRequest *request);

Returns whether request is local or remote. A local request was triggered by a local API call, whereas a remote request was caused by a remote participant from the network.

request :

A InfRequest.

Returns :

TRUE if the request is local and FALSE if it is remote.

Property Details

The "progress" property

  "progress"                 gdouble               : Read

Percentage of completion of the request.

Allowed values: [0,1]

Default value: 0


The "type" property

  "type"                     gchar*                : Read / Write / Construct Only

A string identifier for the type of the request.

Default value: NULL

Signal Details

The "finished" signal

void                user_function                      (InfRequest       *request,
                                                        InfRequestResult *result,
                                                        gpointer          error,
                                                        gpointer          user_data)      : Run Last

This signal is emitted when the request finishes. If error is non-NULL the request failed, otherwise it finished successfully.

request :

The InfRequest which finished.

result :

A InfRequestResult which contains the result of the request.

error :

Error information in case the request failed, or NULL otherwise.

user_data :

user data set when the signal handler was connected.