## InfRequest InfRequest — Asynchronous request |

## Stability Level

Unstable, unless otherwise indicated

## Functions

void | (*InfRequestFunc) ()
void | inf_request_fail ()
void | inf_request_finish ()
gboolean | inf_request_is_local ()

## Properties

gdouble | progress | Read
gchar * | type | Read / Write / Construct Only

## Signals

void | finished | Run Last

## Types and Values

| InfRequest
struct | InfRequestInterface

## Object Hierarchy

        GInterface
        ╰── InfRequest

## Prerequisites

InfRequest requires GObject.

## Known Implementations

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

## Includes

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

## 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.

## Functions

### InfRequestFunc ()

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

Signature of a signal handler for the “finished” signal.

#### Parameters

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.

#### Parameters

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` .

#### Parameters

request | A InfRequest. |
result | A InfRequestResult containing the result of the request. | [transfer full]

### 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.

#### Parameters

request | A InfRequest. |

#### Returns

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

## Types and Values

### InfRequest

    typedef struct _InfRequest InfRequest;

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

### struct InfRequestInterface

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

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

Virtual functions of the InfRequest interface.

#### Members

`finished` () | Default signal handler of the “finished” signal. |
`is_local` () | Virtual function to check whether the request is local or remote. |

## Property Details

### The `“progress”` property

      “progress”                 gdouble

Percentage of completion of the request.

Owner: InfRequest

Flags: Read

Allowed values: [0,1]

Default value: 0

### The `“type”` property

      “type”                     gchar *

A string identifier for the type of the request.

Owner: InfRequest

Flags: Read / Write / Construct Only

Default value: NULL

## Signal Details

### The `“finished”` signal

    void
    user_function (InfRequest       *request,
                   InfRequestResult *result,
                   GError           *error,
                   gpointer          user_data)

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

#### Parameters

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. |

Flags: Run Last