GUPnP.ServiceProxyAction¶
Fields¶
None
Methods¶
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class GUPnP.ServiceProxyAction¶
Opaque structure for holding in-progress action data.
- classmethod new_from_list(action, in_names, in_values)¶
- Parameters:
action (
str) – An actionin_names ([
str]) –GLib.Listof ‘in’ parameter names (as strings)in_values ([
GObject.Value]) –GLib.Listof values (asGObject.Value) that line up with in_names
- Returns:
A newly created
GUPnP.ServiceProxyAction- Return type:
Prepares action action with parameters in_names and in_values to be sent off to a remote service later with
GUPnP.ServiceProxy.call_action() orGUPnP.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.ServiceProxyActionby using gupnp_service_proxy_action_get_result(),GUPnP.ServiceProxyAction.get_result_list() orGUPnP.ServiceProxyAction.get_result_hash() ```cGLib.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.Valueinstance = G_VALUE_INIT;GObject.Value.set_int(&instance, 0);GObject.Valueunit = G_VALUE_INIT;GObject.Value.set_static_string(&unit, “ABS_TIME”);GObject.Valuetarget = 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:
Prepares action action with to be sent off to a remote service later with
GUPnP.ServiceProxy.call_action() orGUPnP.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.ServiceProxyActionby using gupnp_service_proxy_action_get_result(),GUPnP.ServiceProxyAction.get_result_list() orGUPnP.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 argumentvalue (
GObject.Value) – The value of the argument
- Returns:
self for convenience.
- Return type:
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}) – AGLib.HashTableof out parameter name and initialisedGObject.Valuepairs- Raises:
- Returns:
Trueon success.- out_hash:
A
GLib.HashTableof out parameter name and initialisedGObject.Valuepairs
- Return type:
(
bool, out_hash: {str:GObject.Value})
See gupnp_service_proxy_action_get_result(); this version takes a
GLib.HashTablefor 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.Valueinitialized to hold the wanted type withGObject.Value.init().```c void on_action_finished(
GObject.Object*object,Gio.AsyncResult*res,objectuser_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.Valueplay_mode = G_VALUE_INIT;GObject.Value.init(&play_mode,GObject.TYPE_STRING);GObject.Valuerec_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:
out_names ([
str]) –GLib.Listof ‘out’ parameter names (as strings)out_types ([
GObject.GType]) –GLib.Listof types (asGObject.GType) that line up with out_names
- Raises:
- Returns:
Trueon success.- out_values:
GLib.Listof values (asGObject.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_freeand each element in it usingg_value_unsetandg_free. ```c void on_action_finished(GObject.Object*object,Gio.AsyncResult*res,objectuser_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:
- Returns:
A newly created GUPnPServiceProxyActionIterator, or
Noneon error- Return type:
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:
Increases reference count of
actionNew in version 1.2.0.
- set(key, value)¶
- Parameters:
key (
str) – the name of the value to modifyvalue (
GObject.Value) – the new value of key
- Raises:
- Returns:
true if successfully modified, false otherwise
- Return type:
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.