GUPnP.Context

g GObject.GInterface GObject.GInterface Gio.Initable Gio.Initable GObject.GInterface->Gio.Initable GObject.Object GObject.Object GSSDP.Client GSSDP.Client GObject.Object->GSSDP.Client GUPnP.Context GUPnP.Context GSSDP.Client->GUPnP.Context Gio.Initable->GSSDP.Client

Subclasses:

None

Methods

Inherited:

GSSDP.Client (25), GObject.Object (37), Gio.Initable (2)

Structs:

GObject.ObjectClass (5)

class

new (iface, port)

class

new_for_address (addr, port, uda_version)

class

new_full (iface, addr, port, uda_version)

add_server_handler (use_acl, path, callback, *user_data)

get_acl ()

get_default_language ()

get_port ()

get_server ()

get_session ()

get_subscription_timeout ()

host_path (local_path, server_path)

host_path_for_agent (local_path, server_path, user_agent)

remove_server_handler (path)

rewrite_uri (uri)

set_acl (acl)

set_default_language (language)

set_subscription_timeout (timeout)

unhost_path (server_path)

Virtual Methods

Inherited:

GObject.Object (7), Gio.Initable (1)

Properties

Inherited:

GSSDP.Client (14)

Name

Type

Flags

Short Description

acl

GUPnP.Acl

r/w/c

Access control list

default-language

str

r/w/c

Default language

server

Soup.Server

r

Soup.Server HTTP server

session

Soup.Session

r

Soup.Session object

subscription-timeout

int

r/w/co

Subscription timeout

Signals

Inherited:

GSSDP.Client (1), GObject.Object (1)

Fields

Inherited:

GSSDP.Client (1), GObject.Object (1)

Name

Type

Access

Description

parent_instance

GSSDP.Client

r

Class Details

class GUPnP.Context(**kwargs)
Bases:

GSSDP.Client

Abstract:

No

Structure:

GUPnP.ContextClass

Context object wrapping shared networking bits.

GUPnP.Context 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 setting the environment variable GUPNP_DEBUG.

classmethod new(iface, port)
Parameters:
  • iface (str or None) – The network interface to use, or None to auto-detect.

  • port (int) – Port to run on, or 0 if you don’t care what port is used.

Raises:

GLib.Error

Returns:

A new GUPnP.Context object, or None on an error

Return type:

GUPnP.Context

Create a new GUPnP.Context with the specified iface and port.

Deprecated since version 1.6.: Use [ctor`GUPnP`.Context.new_for_address] instead

classmethod new_for_address(addr, port, uda_version)
Parameters:
  • addr (Gio.InetAddress or None) – an IP address or None for auto-detection. If you do not care about the address, but want to specify an address family, use [ctor`Glib`.InetAddress.new_any] with the appropriate family instead.

  • port (int) – The network port to use for M-SEARCH requests or 0 for random.

  • uda_version (GSSDP.UDAVersion) – The UDA version this client will adhere to

Raises:

GLib.Error

Returns:

A new GSSDP.Client object or None on error.

Return type:

GUPnP.Context or None

Creates a GUPnP context with address addr. If none is specified, GUPnP will chose the address it deems most suitable.

New in version 1.6..

classmethod new_full(iface, addr, port, uda_version)
Parameters:
  • iface (str or None) – the name of a network interface

  • addr (Gio.InetAddress or None) – an IP address or None for auto-detection. If you do not care about the address, but want to specify an address family, use [ctor`Glib`.InetAddress.new_any] with the appropriate family instead.

  • port (int) – The network port to use for M-SEARCH requests or 0 for random.

  • uda_version (GSSDP.UDAVersion) – The UDA version this client will adhere to

Raises:

GLib.Error

Returns:

A new GSSDP.Client object or None on error.

Return type:

GUPnP.Context or None

Creates a GUPnP context with address addr on network interface iface. If neither is specified, GUPnP will chose the address it deems most suitable.

New in version 1.6..

add_server_handler(use_acl, path, callback, *user_data)
Parameters:
  • use_acl (bool) – True, if the path should query the GUPnP.Context ::acl before serving the resource, False otherwise.

  • path (str) – the toplevel path for the handler.

  • callback (Soup.ServerCallback) – callback to invoke for requests under path

  • user_data (object or None) – the user_data passed to callback

Add a Soup.ServerCallback to the GUPnP.Context ‘s Soup.Server.

New in version 0.20.11.

get_acl()
Returns:

The access control list associated with this context or None if no acl is set.

Return type:

GUPnP.Acl

Access the GUPnP.Acl associated with this client. If there isn’t any, retturns None. The returned ACL must not be freed.

New in version 0.20.11.

get_default_language()
Returns:

The default content of the Content-Language header.

Return type:

str

Get the default Content-Language header for this context.

New in version 0.18.0.

get_port()
Returns:

The port the SOAP server is running on.

Return type:

int

Get the port that the SOAP server is running on.

get_server()
Returns:

The Soup.Server used by GUPnP. Do not unref this when finished.

Return type:

Soup.Server

Get the Soup.Server HTTP server that GUPnP is using.

get_session()
Returns:

The Soup.Session used by GUPnP. Do not unref this when finished.

Return type:

Soup.Session

Get the Soup.Session object that GUPnP is using.

New in version 0.12.3.

get_subscription_timeout()
Returns:

The event subscription timeout in seconds.

Return type:

int

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

host_path(local_path, server_path)
Parameters:
  • local_path (str) – Path to the local file or folder to be hosted

  • server_path (str) – Web server path where local_path should be hosted

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.

host_path_for_agent(local_path, server_path, user_agent)
Parameters:
  • local_path (str) – Path to the local file or folder to be hosted

  • server_path (str) – Web server path already being hosted

  • user_agent (GLib.Regex) – The user-agent as a GLib.Regex.

Returns:

True on success, False otherwise.

Return type:

bool

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

New in version 0.14.0.

remove_server_handler(path)
Parameters:

path (str) – the toplevel path for the handler.

Remove a Soup.ServerCallback from the GUPnP.Context ‘s Soup.Server.

New in version 0.20.11.

rewrite_uri(uri)
Parameters:

uri (str) – an uri to rewrite if necessary

Returns:

A re-written version of the uri if the context is on a link-local IPv6 address, a copy of the uri otherwise or None if uri was invalid

Return type:

str

Utility function to re-write an uri to the IPv6 link-local form which has the zone index appended to the IP address.

New in version 1.2.0.

set_acl(acl)
Parameters:

acl (GUPnP.Acl or None) – The new access control list or None to remove the current list.

Attach or remove the assoicated access control list to this context. If acl is None, the current access control list will be removed.

New in version 0.20.11.

set_default_language(language)
Parameters:

language (str) – A language tag as defined in RFC 2616 3.10

Set the default language for the Content-Language header to language.

If the client sends an Accept-Language header the UPnP HTTP server is required to send a Content-Language header in return. If there are no files hosted in languages which match the requested ones the Content-Language header is set to this value. The default value is “en”.

New in version 0.18.0.

set_subscription_timeout(timeout)
Parameters:

timeout (int) – Event subscription timeout in seconds

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.

unhost_path(server_path)
Parameters:

server_path (str) – Web server path where the file or folder is hosted

Stop hosting the file or folder at server_path.

Property Details

GUPnP.Context.props.acl
Name:

acl

Type:

GUPnP.Acl

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

An access control list.

New in version 0.20.11.

GUPnP.Context.props.default_language
Name:

default-language

Type:

str

Default Value:

'en'

Flags:

READABLE, WRITABLE, CONSTRUCT

The content of the Content-Language header id the client sends Accept-Language and no language-specific pages to serve exist. The property defaults to ‘en’.

New in version 0.18.0.

GUPnP.Context.props.server
Name:

server

Type:

Soup.Server

Default Value:

None

Flags:

READABLE

The Soup.Server HTTP server used by GUPnP.

GUPnP.Context.props.session
Name:

session

Type:

Soup.Session

Default Value:

None

Flags:

READABLE

The Soup.Session object used by GUPnP.

GUPnP.Context.props.subscription_timeout
Name:

subscription-timeout

Type:

int

Default Value:

1800

Flags:

READABLE, WRITABLE, 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.