## GUPnPContext

GUPnPContext — Context object wrapping shared networking bits.

## Synopsis

                        GUPnPContext;
    GUPnPContext *      gupnp_context_new                   (GMainContext *main_context,
                                                             const char *interface,
                                                             guint port,
                                                             GError **error);
    const char *        gupnp_context_get_host_ip           (GUPnPContext *context);
    guint               gupnp_context_get_port              (GUPnPContext *context);
    SoupServer *        gupnp_context_get_server            (GUPnPContext *context);
    SoupSession *       gupnp_context_get_session           (GUPnPContext *context);
    void                gupnp_context_set_subscription_timeout
                                                            (GUPnPContext *context,
                                                             guint timeout);
    guint               gupnp_context_get_subscription_timeout
                                                            (GUPnPContext *context);
    void                gupnp_context_host_path             (GUPnPContext *context,
                                                             const char *local_path,
                                                             const char *server_path);
    gboolean            gupnp_context_host_path_for_agent   (GUPnPContext *context,
                                                             const char *local_path,
                                                             const char *server_path,
                                                             GRegex *user_agent);
    void                gupnp_context_unhost_path           (GUPnPContext *context,
                                                             const char *server_path);

## Object Hierarchy

      GObject
       +----GSSDPClient
             +----GUPnPContext

## Properties

      "port"                     guint                 : Read / Write / Construct Only
      "server"                   SoupServer*           : Read
      "session"                  SoupSession*          : Read
      "subscription-timeout"     guint                 : Read / Write / Construct Only

## Description

GUPnPContext wraps the networking bits that are used by the various GUPnP classes. It automatically starts a web server on demand.

For debugging, it is possible to see the messages being sent and received by exporting GUPNP_DEBUG.

## Details

### GUPnPContext

    typedef struct _GUPnPContext GUPnPContext;

This struct contains private data only, and should be accessed using the functions below.

### gupnp_context_new ()

    GUPnPContext *      gupnp_context_new                   (GMainContext *main_context,
                                                             const char *interface,
                                                             guint port,
                                                             GError **error);

Create a new GUPnPContext with the specified `main_context`, `interface` and `port`.

`main_context` : | A GMainContext, or `NULL` to use the default one
`interface` : | The network interface to use, or `NULL` to auto-detect.
`port` : | Port to run on, or 0 if you don't care what port is used.
`error` : | A location to store a GError, or `NULL`
Returns : | A new GUPnPContext object, or `NULL` on an error

### gupnp_context_get_host_ip ()

    const char *        gupnp_context_get_host_ip           (GUPnPContext *context);

### Warning

`gupnp_context_get_host_ip` has been deprecated since version 0.12.7 and should not be used in newly-written code. The "host-ip" property has moved to the base class GSSDPClient so newer applications should use gssdp_client_get_host_ip instead.

Get the IP address we advertise ourselves as using.

`context` : | A GUPnPContext
Returns : | The IP address. This string should not be freed.

### gupnp_context_get_port ()

    guint               gupnp_context_get_port              (GUPnPContext *context);

Get the port that the SOAP server is running on.

`context` : | A GUPnPContext
Returns : | The port the SOAP server is running on.

### gupnp_context_get_server ()

    SoupServer *        gupnp_context_get_server            (GUPnPContext *context);

Get the SoupServer HTTP server that GUPnP is using.

`context` : | A GUPnPContext
Returns : | The SoupServer used by GUPnP. Do not unref this when finished.

### gupnp_context_get_session ()

    SoupSession *       gupnp_context_get_session           (GUPnPContext *context);

Get the SoupSession object that GUPnP is using.

`context` : | A GUPnPContext
Returns : | The SoupSession used by GUPnP. Do not unref this when finished.

### gupnp_context_set_subscription_timeout ()

    void                gupnp_context_set_subscription_timeout
                                                            (GUPnPContext *context,
                                                             guint timeout);

Sets the event subscription timeout to `timeout`. Use 0 if you don't want subscriptions to time out. Note that any client side subscriptions will automatically be renewed.

`context` : | A GUPnPContext
`timeout` : | Event subscription timeout in seconds

### gupnp_context_get_subscription_timeout ()

    guint               gupnp_context_get_subscription_timeout
                                                            (GUPnPContext *context);

Get the event subscription timeout (in seconds), or 0 meaning there is no timeout.

`context` : | A GUPnPContext
Returns : | The event subscription timeout in seconds.

### gupnp_context_host_path ()

    void                gupnp_context_host_path             (GUPnPContext *context,
                                                             const char *local_path,
                                                             const char *server_path);

Start hosting `local_path` at `server_path`. Files with the path `local_path.LOCALE` (if they exist) will be served up when LOCALE is specified in the request's Accept-Language header.

`context` : | A GUPnPContext
`local_path` : | Path to the local file or folder to be hosted
`server_path` : | Web server path where `local_path` should be hosted

### gupnp_context_host_path_for_agent ()

    gboolean            gupnp_context_host_path_for_agent   (GUPnPContext *context,
                                                             const char *local_path,
                                                             const char *server_path,
                                                             GRegex *user_agent);

Use this method to serve different local path to specific user-agent(s). The path `server_path` must already be hosted by `context`.

`context` : | A GUPnPContext
`local_path` : | Path to the local file or folder to be hosted
`server_path` : | Web server path already being hosted
`user_agent` : | The user-agent as a GRegex.
Returns : | `TRUE` on success, `FALSE` otherwise.

### gupnp_context_unhost_path ()

    void                gupnp_context_unhost_path           (GUPnPContext *context,
                                                             const char *server_path);

Stop hosting the file or folder at `server_path`.

`context` : | A GUPnPContext
`server_path` : | Web server path where the file or folder is hosted

## Property Details

### The `"port"` property

      "port"                     guint                 : Read / Write / Construct Only

The port to run on. Set to 0 if you don't care what port to run on.

Default value: 0

### The `"server"` property

      "server"                   SoupServer*           : Read

The SoupServer HTTP server used by GUPnP.

### The `"session"` property

      "session"                  SoupSession*          : Read

The SoupSession object used by GUPnP.

### The `"subscription-timeout"` property

      "subscription-timeout"     guint                 : Read / Write / Construct Only

The preferred subscription timeout: the number of seconds after which subscriptions are renewed. Set to '0' if subscriptions are never to time out.

Allowed values: <= 604800

Default value: 1800