GUPnP.ServiceProxyAction

Fields

None

Methods

class

new_from_list (action, in_names, in_values)

class

new_plain (action)

add_argument (name, value)

get_result_hash (out_hash)

get_result_list (out_names, out_types)

iterate ()

ref ()

set (key, value)

unref ()

Details

class GUPnP.ServiceProxyAction

Opaque structure for holding in-progress action data.

classmethod new_from_list(action, in_names, in_values)
Parameters:
Returns:

A newly created GUPnP.ServiceProxyAction

Return type:

GUPnP.ServiceProxyAction

Prepares action action with parameters in_names and in_values to be sent off to a remote service later with GUPnP.ServiceProxy.call_action() or GUPnP.ServiceProxy.call_action_async(). This is mainly useful for language bindings.

After the action call has finished, the results of the call may be retrived from the GUPnP.ServiceProxyAction by using gupnp_service_proxy_action_get_result(), GUPnP.ServiceProxyAction.get_result_list() or GUPnP.ServiceProxyAction.get_result_hash() ```c GLib.List *in_args = None; in_args = g_list_append (in_args, “InstanceID”); in_args = g_list_append (in_args, “Unit”); in_args = g_list_append (in_args, “Target”);

GObject.Value instance = G_VALUE_INIT; GObject.Value.set_int (&instance, 0); GObject.Value unit = G_VALUE_INIT; GObject.Value.set_static_string (&unit, “ABS_TIME”); GObject.Value target = G_VALUE_INIT; GObject.Value.set_static_string (&target, “00:00:00.000”);

GLib.List *in_values = None; in_values = g_list_append (in_values, &instance); in_values = g_list_append (in_values, &unit); in_values = g_list_append (in_values, &target);

GUPnP.ServiceProxyAction *action = gunp_service_proxy_action_new_from_list (“Seek”, in_args, in_values);

GLib.Error *error = None; GUPnP.ServiceProxy.call_action_async (proxy, action, None, on_action_finished, None); GUPnP.ServiceProxyAction.unref (action); ```

classmethod new_plain(action)
Parameters:

action (str) – The name of a remote action to call

Returns:

A newly created GUPnP.ServiceProxyAction

Return type:

GUPnP.ServiceProxyAction

Prepares action action with to be sent off to a remote service later with GUPnP.ServiceProxy.call_action() or GUPnP.ServiceProxy.call_action_async() if no arguments required or by adding more parameters with gupnp_service_proxy_action_add()

After the action call has finished, the results of the call may be retrived from the GUPnP.ServiceProxyAction by using gupnp_service_proxy_action_get_result(), GUPnP.ServiceProxyAction.get_result_list() or GUPnP.ServiceProxyAction.get_result_hash()

```c GUPnP.ServiceProxyAction *action = GUPnP.ServiceProxyAction.new_plain (“GetVolume”); gupnp_service_proxy_action_add (action, “InstanceID”, value_instance); gupnp_service_proxy_action_add (action, “Channel”, value_channel); ````

New in version 1.6.6.

add_argument(name, value)
Parameters:
  • name (str) – The name of the argument

  • value (GObject.Value) – The value of the argument

Returns:

self for convenience.

Return type:

GUPnP.ServiceProxyAction

Append name to the list of arguments used by self

New in version 1.6.6.

get_result_hash(out_hash)
Parameters:

out_hash ({str: GObject.Value}) – A GLib.HashTable of out parameter name and initialised GObject.Value pairs

Raises:

GLib.Error

Returns:

True on success.

out_hash:

A GLib.HashTable of out parameter name and initialised GObject.Value pairs

Return type:

(bool, out_hash: {str: GObject.Value})

See gupnp_service_proxy_action_get_result(); this version takes a GLib.HashTable for runtime generated parameter lists.

The out_hash needs to be pre-initialized with key value pairs denoting the argument to retrieve and an empty GObject.Value initialized to hold the wanted type with GObject.Value.init().

```c void on_action_finished(GObject.Object *object, Gio.AsyncResult *res, object user_data) { GUPnP.ServiceProxyAction *action; GLib.Error *error;

action = GUPnP.ServiceProxy.call_action_finish (GUPNP_SERVICE_PROXY (object), res, &error);

if (error != None) { g_print (“Call failed: %s”, error->message); GLib.clear_error (&error); return; }

GObject.Value play_mode = G_VALUE_INIT; GObject.Value.init(&play_mode, GObject.TYPE_STRING); GObject.Value rec_quality_mode = G_VALUE_INIT; GObject.Value.init(&rec_quality_mode, GObject.TYPE_STRING);

GLib.HashTable *out_args = g_hash_table_new (GLib.str_hash, GLib.str_equal); GLib.HashTable.insert(out_args, “PlayMode”, &play_mode); GLib.HashTable.insert(out_args, “RecQualityMode”, &rec_quality_mode);

if (!:obj:GUPnP.ServiceProxyAction.get_result_hash (action, out_args, &error)) { g_print (“Getting results failed: %s”, error->message); GLib.clear_error (&error); return; }

GObject.Value.unset (&play_mode); GObject.Value.unset (&rec_quality_mode);

GLib.HashTable.unref (out_args); } ```

New in version 1.2.0.

get_result_list(out_names, out_types)
Parameters:
Raises:

GLib.Error

Returns:

True on success.

out_values:

GLib.List of values (as GObject.Value) that line up with out_names and out_types.

Return type:

(bool, out_values: [GObject.Value])

A variant of gupnp_service_proxy_action_get_result() that takes lists of out-parameter names, types and place-holders for values.

The returned list in out_values must be freed using g_list_free and each element in it using g_value_unset and g_free. ```c void on_action_finished(GObject.Object *object, Gio.AsyncResult *res, object user_data) { GUPnP.ServiceProxyAction *action; GLib.Error *error;

action = GUPnP.ServiceProxy.call_action_finish (GUPNP_SERVICE_PROXY (object), res, &error);

if (error != None) { g_print (“Call failed: %s”, error->message); GLib.clear_error (&error); return; }

GLib.List *out_args = None; out_args = g_list_append (out_args, “PlayMode”); out_args = g_list_append (out_args, “RecQualityMode”); GLib.List *out_types = None; out_types = g_list_append (out_types, GSIZE_TO_POINTER (GObject.TYPE_STRING)); out_types = g_list_append (out_types, GSIZE_TO_POINTER (GObject.TYPE_STRING)); GLib.List *out_values = None;

if (!:obj:GUPnP.ServiceProxyAction.get_result_list (action, out_args, out_types, &out_values, &error)) { g_print (“Getting results failed: %s”, error->message); GLib.clear_error (&error); return; }

GLib.List *iter = out_values; while (iter != None) { GObject.Value *value = iter->data; g_print (“Result: %s\n”, GObject.Value.get_string (value)); GObject.Value.unset (value); GLib.free (value); iter = g_list_remove_link (iter, iter); } g_list_free (out_values); } ```

New in version 1.2.0.

iterate()
Raises:

GLib.Error

Returns:

A newly created GUPnPServiceProxyActionIterator, or None on error

Return type:

GUPnP.ServiceProxyActionIter or None

Iterate over the out arguments of a finished action

New in version 1.6.6.

ref()
Returns:

self with an increased reference count

Return type:

GUPnP.ServiceProxyAction or None

Increases reference count of action

New in version 1.2.0.

set(key, value)
Parameters:
  • key (str) – the name of the value to modify

  • value (GObject.Value) – the new value of key

Raises:

GLib.Error

Returns:

true if successfully modified, false otherwise

Return type:

bool

Update the value of key to value.

key needs to already exist in self.

New in version 1.4.0.

unref()

Decreases reference count of action. If reference count drops to 0, the action and its contents will be freed.

New in version 1.2.0.