GUPnP.ContextFilter

g GObject.Object GObject.Object GUPnP.ContextFilter GUPnP.ContextFilter GObject.Object->GUPnP.ContextFilter

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

add_entry (entry)

add_entryv (entries)

check_context (context)

clear ()

get_enabled ()

get_entries ()

is_empty ()

remove_entry (entry)

set_enabled (enable)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

enabled

bool

r/w/c/en

True if the context filter is active.

entries

int

r/w/co/en

GLib.List of strings that compose the context filter.

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class GUPnP.ContextFilter(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

GUPnP.ContextFilterClass

Network context filter, used by [class`GUPnP`.ContextManager]

GUPnP.ContextFilter handles network filtering. It provides API to manage a list of entries that will be used to positive filter networks. The GUPnP.ContextFilter could be enabled or not. If it’s enabled but the entries list is empty, it behaves as if being disabled.

The GUPnP.ContextFilter is used with the [class`GUPnP`.ContextManager] to narrow down the contexts that are notified by it.

Contexts can be filtered by the following criteria:

  • Their IP addresses

  • The network device they will live on

  • The name of the network the context would join

To add or modify a context filter, you need to retrieve the current context filter from the context manger using [method`GUPnP`.ContextManager.get_context_filter].

By default, a context filter is empty and disabled.

For example, to only react to contexts that are appearing on eth0 or when being in the WiFi network with the SSID “HomeNetwork”, and on IPv6 localhost, you should do:

```c GUPnP.ContextFilter filter;

filter = GUPnP.ContextManager.get_context_filter (manager); const str *filter_entries[] = { “eth0”, “HomeNetwork”, “::1”, None }; GUPnP.ContextFilter.add_entryv (filter, filter_entries); GUPnP.ContextFilter.set_enabled (filter, True); ```

New in version 1.4.0.

add_entry(entry)
Parameters:

entry (str) – A value used to filter network

Returns:

True if entry is added, False otherwise.

Return type:

bool

Add entry in the list of valid criteria used by self to filter networks. if entry already exists, it won’t be added a second time.

New in version 1.4.0.

add_entryv(entries)
Parameters:

entries ([str]) – A None-terminated list of strings

Add a list of entries to a GUPnP.ContextFilter. This is a helper function to directly add a None-terminated array of string usually acquired from command line arguments.

New in version 1.4.0.

check_context(context)
Parameters:

context (GUPnP.Context) – A GUPnP.Context to test.

Returns:

True if context is matching the self criteria, False otherwise.

Return type:

bool

It will check if the context is allowed or not. The self will check all its entries against GUPnP.Context interface, host IP and network fields information. This function doesn’t take into account the self status (enabled or not).

New in version 1.4.0.

clear()

Remove all entries from GLib.List that compose the context filter. The list is now empty. Even if GUPnP.ContextFilter is enabled, it will have the same behavior as if it was disabled.

New in version 1.4.0.

get_enabled()
Returns:

True if self is enabled, False otherwise.

Return type:

bool

Return the status of the GUPnP.ContextFilter

New in version 1.4.0.

get_entries()
Returns:

a GLib.List of entries used to filter networks, interfaces,… or None.

Return type:

[str] or None

Get the GLib.List of entries that compose the context filter. Do not free

New in version 1.4.0.

is_empty()
Returns:

True if self is empty, False otherwise.

Return type:

bool

Return the state of the entries list of GUPnP.ContextFilter

New in version 1.4.0.

remove_entry(entry)
Parameters:

entry (str) – A value to remove from the filter list.

Returns:

True if entry is removed, False otherwise.

Return type:

bool

Remove entry in the list of valid criteria used by self to filter networks.

New in version 1.4.0.

set_enabled(enable)
Parameters:

enable (bool) – True to enable self, False otherwise

Enable or disable the GUPnP.ContextFilter to perform the network filtering.

New in version 1.4.0.

Property Details

GUPnP.ContextFilter.props.enabled
Name:

enabled

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, CONSTRUCT, EXPLICIT_NOTIFY

Whether this context filter is active or not.

New in version 1.4.0.

GUPnP.ContextFilter.props.entries
Name:

entries

Type:

int

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY, EXPLICIT_NOTIFY

A list of items to filter for.

New in version 1.4.0.