### Class

# GUPnP ContextFilter

#### Description [src]

    class GUPnP.ContextFilter : GObject.Object {
      parent_instance: GObject
    }

Network context filter, used by `GUPnPContextManager`

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

The GUPnPContextFilter is used with the `GUPnPContextManager` 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 `gupnp_context_manager_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:

    GUPnPContextFilter* filter;

    filter = gupnp_context_manager_get_context_filter (manager);
    const char *filter_entries[] = {
        "eth0",
        "HomeNetwork",
        "::1",
        NULL
    };
    gupnp_context_filter_add_entryv (filter, filter_entries);
    gupnp_context_filter_set_enabled (filter, TRUE);

Available since: | 1.4.0

#### Ancestors

- GObject

#### Instance methods

###### gupnp_context_filter_add_entry

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

Available since: 1.4.0

###### gupnp_context_filter_add_entryv

Add a list of entries to a `GUPnPContextFilter`. This is a helper function to directly add a `NULL`-terminated array of string usually acquired from command line arguments.

Available since: 1.4.0

###### gupnp_context_filter_check_context

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

Available since: 1.4.0

###### gupnp_context_filter_clear

Remove all entries from `GList` that compose the context filter. The list is now empty. Even if `GUPnPContextFilter` is enabled, it will have the same behavior as if it was disabled.

Available since: 1.4.0

###### gupnp_context_filter_get_enabled

Return the status of the `GUPnPContextFilter`.

Available since: 1.4.0

###### gupnp_context_filter_get_entries

Get the `GList` of entries that compose the context filter. Do not free.

Available since: 1.4.0

###### gupnp_context_filter_is_empty

Return the state of the entries list of `GUPnPContextFilter`.

Available since: 1.4.0

###### gupnp_context_filter_remove_entry

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

Available since: 1.4.0

###### gupnp_context_filter_set_enabled

Enable or disable the `GUPnPContextFilter` to perform the network filtering.

Available since: 1.4.0

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Properties

###### GUPnP.ContextFilter:enabled

Whether this context filter is active or not.

Available since: 1.4.0

###### GUPnP.ContextFilter:entries

A list of items to filter for.

Available since: 1.4.0

#### Signals

##### Signals inherited from GObject (1)

###### GObject.Object::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

#### Class structure

    struct GUPnPContextFilterClass {
      GObjectClass parent_class;

    }

###### Class members

`parent_class` |
    GObjectClass
| No description available.