XmmsClient
Macros | Functions
client.c File Reference
#include "common.h"
#include <fnmatch.h>

Macros

#define XMMSC_SC_ENTITY_NAME_PATTERN   "[_a-zA-Z][_a-zA-Z0-9]*"
 
#define GEN_SC_INTROSPECT_FUNC(entity, type)
 

Functions

xmmsc_result_txmmsc_sc_call (xmmsc_connection_t *c, int dest, xmmsv_t *method, xmmsv_t *pargs, xmmsv_t *nargs)
 Call a method in another client. More...
 
xmmsc_result_txmmsc_sc_broadcast_subscribe (xmmsc_connection_t *c, int dest, xmmsv_t *broadcast)
 Subscribe to a broadcast from another client. More...
 
bool xmmsc_sc_broadcast_emit (xmmsc_connection_t *c, xmmsv_t *broadcast, xmmsv_t *value)
 Emit a broadcast. More...
 
 GEN_SC_INTROSPECT_FUNC (namespace, XMMSC_SC_INTERFACE_ENTITY_TYPE_NAMESPACE)
 Introspect into a namespace. More...
 
 GEN_SC_INTROSPECT_FUNC (method, XMMSC_SC_INTERFACE_ENTITY_TYPE_METHOD)
 Introspect into a method. More...
 
 GEN_SC_INTROSPECT_FUNC (broadcast, XMMSC_SC_INTERFACE_ENTITY_TYPE_BROADCAST)
 Introspect into a client-to-client broadcast. More...
 
xmmsc_result_txmmsc_sc_introspect_constant (xmmsc_connection_t *c, int dest, xmmsv_t *nms, const char *key)
 Convenience function to retrieve a constant from a namespace directly. More...
 
xmmsc_result_txmmsc_sc_introspect_docstring (xmmsc_connection_t *c, int dest, xmmsv_t *path)
 Get the docstring from a method, broadcast or namespace. More...
 
xmmsc_sc_namespace_txmmsc_sc_namespace_root (xmmsc_connection_t *c)
 Get the root namespace. More...
 
xmmsc_sc_namespace_txmmsc_sc_namespace_lookup (xmmsc_connection_t *c, xmmsv_t *nms)
 Get an existing namespace from its full path. More...
 
xmmsc_sc_namespace_txmmsc_sc_namespace_new (xmmsc_sc_namespace_t *parent, const char *name, const char *docstring)
 Create a new namespace. More...
 
xmmsc_sc_namespace_txmmsc_sc_namespace_get (xmmsc_sc_namespace_t *parent, const char *name)
 Get an existing sub-namespace. More...
 
bool xmmsc_sc_namespace_add_method (xmmsc_sc_namespace_t *nms, xmmsc_sc_method_t method, const char *name, const char *docstring, xmmsv_t *positional_args, xmmsv_t *named_args, bool va_positional, bool va_named, void *userdata)
 Create a new method. More...
 
bool xmmsc_sc_namespace_add_method_noarg (xmmsc_sc_namespace_t *parent, xmmsc_sc_method_t method, const char *name, const char *docstring, void *userdata)
 Convenience wrapper around xmmsc_sc_method_new to declare a method that accepts no arguments. More...
 
bool xmmsc_sc_namespace_add_broadcast (xmmsc_sc_namespace_t *nms, const char *name, const char *docstring)
 Create a new client-to-client broadcast. More...
 

Macro Definition Documentation

#define GEN_SC_INTROSPECT_FUNC (   entity,
  type 
)
Value:
xmmsc_sc_introspect_##entity (xmmsc_connection_t *c, int dest, \
xmmsv_t *entity) \
{ \
x_check_conn (c, NULL); \
x_api_error_if (!dest, "with 0 as destination client.", NULL); \
x_api_error_if (!entity, "with NULL " #entity " path.", NULL); \
x_api_error_if (!xmmsv_list_restrict_type (entity, XMMSV_TYPE_STRING), \
"with non-string in " #entity " path", NULL); \
\
return introspect_internal (c, dest, entity, true, type, NULL); \
}
#define XMMSC_SC_ENTITY_NAME_PATTERN   "[_a-zA-Z][_a-zA-Z0-9]*"

Function Documentation

GEN_SC_INTROSPECT_FUNC ( namespace  ,
XMMSC_SC_INTERFACE_ENTITY_TYPE_NAMESPACE   
)

Introspect into a namespace.

The result will carry a dictionary of the form:
"name" : the namespace's name.
"docstring" : the namespace's docstring.
"constants" : a dictionary of constants.
"namespaces" : a list of names of subnamespaces.
"methods" : a list of descriptions of the methods in the namespace.
"broadcasts" : a list of descriptions of the broadcasts in the namespace.

Parameters
cThe connection structure.
destThe non-zero id of the destination client.
namespaceA list of strings forming the path to the remote namespace. Use an empty list to refer to the root namespace.
GEN_SC_INTROSPECT_FUNC ( method  ,
XMMSC_SC_INTERFACE_ENTITY_TYPE_METHOD   
)

Introspect into a method.

The result will carry a dictionary of the form:
"name" : the method's name.
"docstring" : the method's docstring.
"positional arguments" : a list of positional arguments.
"named arguments" : a list of named arguments.
"va positional" : whether or not the method accepts a variable number of positional arguments.
"va named" : whether or not the method accepts a variable number of named arguments.

Parameters
cThe connection structure.
destThe non-zero id of the destination client.
methodA list of strings forming the path to the remote method.
GEN_SC_INTROSPECT_FUNC ( broadcast  ,
XMMSC_SC_INTERFACE_ENTITY_TYPE_BROADCAST   
)

Introspect into a client-to-client broadcast.

The result will carry a dict of the form:
"name" : the broadcast's name.
"docstring" : the broadcast's docstring.

Parameters
cThe connection structure.
destThe non-zero id of the destination client.
broadcastA list of strings forming the path to the remote broadcast.
bool xmmsc_sc_broadcast_emit ( xmmsc_connection_t c,
xmmsv_t broadcast,
xmmsv_t value 
)

Emit a broadcast.

Parameters
cThe connection structure.
broadcastA non-empty list of strings specifying the broadcast path.
valueThe value to emit. Must not be NULL.
xmmsc_result_t* xmmsc_sc_broadcast_subscribe ( xmmsc_connection_t c,
int  dest,
xmmsv_t broadcast 
)

Subscribe to a broadcast from another client.

The returned result can be used to set up notifiers as usual.

Parameters
cThe connection structuer.
destThe client that issues the broadcast.
broadcastA non-empty list of strings forming the path to the broadcast.
See Also
xmmsc_result_notifier_set_default and others.
xmmsc_result_t* xmmsc_sc_call ( xmmsc_connection_t c,
int  dest,
xmmsv_t method,
xmmsv_t pargs,
xmmsv_t nargs 
)

Call a method in another client.

Parameters
cThe connection structure.
destThe destination client's id.
methodA non-empty list of strings forming the path to the method.
pargsA list of positional arguments. May be NULL.
nargsA dict of named arguments. May be NULL.
xmmsc_result_t* xmmsc_sc_introspect_constant ( xmmsc_connection_t c,
int  dest,
xmmsv_t nms,
const char *  key 
)

Convenience function to retrieve a constant from a namespace directly.

Parameters
cThe connection structure.
destThe nonzero destination client's id.
nmsThe path to the namespace in the remote client. Use an empty list to refer to the root namespace.
keyThe key to the constant.
xmmsc_result_t* xmmsc_sc_introspect_docstring ( xmmsc_connection_t c,
int  dest,
xmmsv_t path 
)

Get the docstring from a method, broadcast or namespace.

Parameters
cThe connection structure.
destThe nonzero id of the destination client.
pathThe path to the remote entity.
bool xmmsc_sc_namespace_add_broadcast ( xmmsc_sc_namespace_t nms,
const char *  name,
const char *  docstring 
)

Create a new client-to-client broadcast.

Parameters
nmsThe parent namespace.
nameThe name of the broadcast. Must not be NULL. Must match XMMSC_SC_ENTITY_NAME_PATTERN.
docstringThe docstring for the broadcast.
See Also
xmmsc_sc_broadcast_emit
bool xmmsc_sc_namespace_add_method ( xmmsc_sc_namespace_t nms,
xmmsc_sc_method_t  method,
const char *  name,
const char *  docstring,
xmmsv_t positional_args,
xmmsv_t named_args,
bool  va_positional,
bool  va_named,
void *  userdata 
)

Create a new method.

Parameters
nmsThe parent namespace.
methodThe underlying function that will be called.
nameThe name of the method. Must not be NULL. Must match XMMSC_SC_ENTITY_NAME_PATTERN.
docstringThe docstring of the method.
positional_argsA list of positional arguments, or NULL to declare none.
named_argsA list of named arguments, or NULL to declare none.
va_positionalWhether or not this method accepts a variable number of positional arguments (in addition to positional_args).
va_namedWhether or not this method accepts a extra named arguments (in addition to named_args).
userdataWill be passed to the underlying function.
See Also
xmmsv_sc_argument_new

Referenced by xmmsc_sc_namespace_add_method_noarg().

bool xmmsc_sc_namespace_add_method_noarg ( xmmsc_sc_namespace_t parent,
xmmsc_sc_method_t  method,
const char *  name,
const char *  docstring,
void *  userdata 
)

Convenience wrapper around xmmsc_sc_method_new to declare a method that accepts no arguments.

See Also
xmmsc_sc_namespace_add_method
xmmsc_sc_namespace_t* xmmsc_sc_namespace_get ( xmmsc_sc_namespace_t parent,
const char *  name 
)

Get an existing sub-namespace.

Parameters
parentThe parent namespace.
nmsThe name of the namespace.
Returns
A namespace.
xmmsc_sc_namespace_t* xmmsc_sc_namespace_lookup ( xmmsc_connection_t c,
xmmsv_t nms 
)

Get an existing namespace from its full path.

Parameters
cThe connection structure.
nmsThe path to the namespace.
Returns
A namespace.
xmmsc_sc_namespace_t* xmmsc_sc_namespace_new ( xmmsc_sc_namespace_t parent,
const char *  name,
const char *  docstring 
)

Create a new namespace.

Parameters
parentThe parent namespace.
nameThe name of the new namespace. Must match XMMSC_SC_ENTITY_NAME_PATTERN.
docstringThe docstring of the namespace.
Returns
The new namespace.
xmmsc_sc_namespace_t* xmmsc_sc_namespace_root ( xmmsc_connection_t c)

Get the root namespace.

Parameters
cThe connection structure.
Returns
The root namespace.