mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2024-11-16 17:56:23 +00:00
Replace CallsOrigin getters with properties and add calls_origin_foreach_call method
This commit is contained in:
parent
891ed1fe79
commit
4e7a0b8151
6 changed files with 180 additions and 89 deletions
|
@ -49,36 +49,20 @@ G_DEFINE_TYPE_WITH_CODE (CallsDummyOrigin, calls_dummy_origin, G_TYPE_OBJECT,
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
|
||||||
|
/* Property for setting the origins name upon construction */
|
||||||
|
PROP_DUMMY_NAME_CONSTRUCTOR,
|
||||||
|
|
||||||
|
/* The origins name. The implements the name property from CallsOrigin.
|
||||||
|
* Readonly property, can't be set directly. */
|
||||||
PROP_NAME,
|
PROP_NAME,
|
||||||
|
|
||||||
|
PROP_CALLS,
|
||||||
PROP_LAST_PROP,
|
PROP_LAST_PROP,
|
||||||
};
|
};
|
||||||
static GParamSpec *props[PROP_LAST_PROP];
|
static GParamSpec *props[PROP_LAST_PROP];
|
||||||
|
|
||||||
|
|
||||||
static const gchar *
|
|
||||||
get_name (CallsOrigin *origin)
|
|
||||||
{
|
|
||||||
CallsDummyOrigin *self;
|
|
||||||
|
|
||||||
g_return_val_if_fail (CALLS_IS_DUMMY_ORIGIN (origin), NULL);
|
|
||||||
self = CALLS_DUMMY_ORIGIN (origin);
|
|
||||||
|
|
||||||
return self->name->str;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static GList *
|
|
||||||
get_calls (CallsOrigin *origin)
|
|
||||||
{
|
|
||||||
CallsDummyOrigin *self;
|
|
||||||
|
|
||||||
g_return_val_if_fail (CALLS_IS_DUMMY_ORIGIN (origin), NULL);
|
|
||||||
self = CALLS_DUMMY_ORIGIN (origin);
|
|
||||||
|
|
||||||
return g_list_copy (self->calls);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
remove_call (CallsDummyOrigin *self,
|
remove_call (CallsDummyOrigin *self,
|
||||||
CallsCall *call,
|
CallsCall *call,
|
||||||
|
@ -172,7 +156,7 @@ CallsDummyOrigin *
|
||||||
calls_dummy_origin_new (const gchar *name)
|
calls_dummy_origin_new (const gchar *name)
|
||||||
{
|
{
|
||||||
return g_object_new (CALLS_TYPE_DUMMY_ORIGIN,
|
return g_object_new (CALLS_TYPE_DUMMY_ORIGIN,
|
||||||
"name", name,
|
"dummy-name-constructor", name,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +170,7 @@ set_property (GObject *object,
|
||||||
CallsDummyOrigin *self = CALLS_DUMMY_ORIGIN (object);
|
CallsDummyOrigin *self = CALLS_DUMMY_ORIGIN (object);
|
||||||
|
|
||||||
switch (property_id) {
|
switch (property_id) {
|
||||||
case PROP_NAME:
|
case PROP_DUMMY_NAME_CONSTRUCTOR:
|
||||||
g_string_assign (self->name, g_value_get_string (value));
|
g_string_assign (self->name, g_value_get_string (value));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -197,6 +181,30 @@ set_property (GObject *object,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_property (GObject *object,
|
||||||
|
guint property_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
CallsDummyOrigin *self = CALLS_DUMMY_ORIGIN (object);
|
||||||
|
|
||||||
|
switch (property_id) {
|
||||||
|
case PROP_NAME:
|
||||||
|
g_value_set_string (value, self->name->str);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_CALLS:
|
||||||
|
g_value_set_pointer (value, g_list_copy (self->calls));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dispose (GObject *object)
|
dispose (GObject *object)
|
||||||
{
|
{
|
||||||
|
@ -226,16 +234,26 @@ calls_dummy_origin_class_init (CallsDummyOriginClass *klass)
|
||||||
|
|
||||||
object_class->dispose = dispose;
|
object_class->dispose = dispose;
|
||||||
object_class->finalize = finalize;
|
object_class->finalize = finalize;
|
||||||
|
object_class->get_property = get_property;
|
||||||
object_class->set_property = set_property;
|
object_class->set_property = set_property;
|
||||||
|
|
||||||
props[PROP_NAME] =
|
props[PROP_DUMMY_NAME_CONSTRUCTOR] =
|
||||||
g_param_spec_string ("name",
|
g_param_spec_string ("dummy-name-constructor",
|
||||||
_("Name"),
|
_("Name"),
|
||||||
_("The name of the origin"),
|
_("The name of the origin"),
|
||||||
"Dummy origin",
|
"Dummy origin",
|
||||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
||||||
|
g_object_class_install_property (object_class, PROP_DUMMY_NAME_CONSTRUCTOR, props[PROP_DUMMY_NAME_CONSTRUCTOR]);
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
|
||||||
|
#define IMPLEMENTS(ID, NAME) \
|
||||||
|
g_object_class_override_property (object_class, ID, NAME); \
|
||||||
|
props[ID] = g_object_class_find_property(object_class, NAME);
|
||||||
|
|
||||||
|
IMPLEMENTS (PROP_NAME, "name");
|
||||||
|
IMPLEMENTS (PROP_CALLS, "calls");
|
||||||
|
|
||||||
|
#undef IMPLEMENTS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -248,8 +266,6 @@ calls_dummy_origin_message_source_interface_init (CallsOriginInterface *iface)
|
||||||
static void
|
static void
|
||||||
calls_dummy_origin_origin_interface_init (CallsOriginInterface *iface)
|
calls_dummy_origin_origin_interface_init (CallsOriginInterface *iface)
|
||||||
{
|
{
|
||||||
iface->get_name = get_name;
|
|
||||||
iface->get_calls = get_calls;
|
|
||||||
iface->dial = dial;
|
iface->dial = dial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,8 @@ G_DEFINE_TYPE_WITH_CODE (CallsMMOrigin, calls_mm_origin, G_TYPE_OBJECT,
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
PROP_NAME,
|
||||||
|
PROP_CALLS,
|
||||||
PROP_MODEM,
|
PROP_MODEM,
|
||||||
PROP_LAST_PROP,
|
PROP_LAST_PROP,
|
||||||
};
|
};
|
||||||
|
@ -294,21 +296,6 @@ calls_mm_ussd_cancel_finish (CallsUssd *ussd,
|
||||||
return g_task_propagate_boolean (G_TASK (result), error);
|
return g_task_propagate_boolean (G_TASK (result), error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const gchar *
|
|
||||||
get_name (CallsOrigin *origin)
|
|
||||||
{
|
|
||||||
CallsMMOrigin *self = CALLS_MM_ORIGIN (origin);
|
|
||||||
return self->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static GList *
|
|
||||||
get_calls (CallsOrigin * origin)
|
|
||||||
{
|
|
||||||
CallsMMOrigin *self = CALLS_MM_ORIGIN (origin);
|
|
||||||
return g_hash_table_get_values (self->calls);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dial_cb (MMModemVoice *voice,
|
dial_cb (MMModemVoice *voice,
|
||||||
|
@ -641,6 +628,30 @@ set_property (GObject *object,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_property (GObject *object,
|
||||||
|
guint property_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
CallsMMOrigin *self = CALLS_MM_ORIGIN (object);
|
||||||
|
|
||||||
|
switch (property_id) {
|
||||||
|
case PROP_NAME:
|
||||||
|
g_value_set_string (value, self->name);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_CALLS:
|
||||||
|
g_value_set_pointer(value, g_hash_table_get_values (self->calls));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
modem_get_name (MMModem *modem)
|
modem_get_name (MMModem *modem)
|
||||||
{
|
{
|
||||||
|
@ -792,6 +803,7 @@ calls_mm_origin_class_init (CallsMMOriginClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->get_property = get_property;
|
||||||
object_class->set_property = set_property;
|
object_class->set_property = set_property;
|
||||||
object_class->constructed = constructed;
|
object_class->constructed = constructed;
|
||||||
object_class->dispose = dispose;
|
object_class->dispose = dispose;
|
||||||
|
@ -803,8 +815,17 @@ calls_mm_origin_class_init (CallsMMOriginClass *klass)
|
||||||
_("A libmm-glib proxy object for the modem"),
|
_("A libmm-glib proxy object for the modem"),
|
||||||
MM_TYPE_OBJECT,
|
MM_TYPE_OBJECT,
|
||||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
||||||
|
g_object_class_install_property (object_class, PROP_MODEM, props[PROP_MODEM]);
|
||||||
|
|
||||||
|
#define IMPLEMENTS(ID, NAME) \
|
||||||
|
g_object_class_override_property (object_class, ID, NAME); \
|
||||||
|
props[ID] = g_object_class_find_property(object_class, NAME);
|
||||||
|
|
||||||
|
IMPLEMENTS (PROP_NAME, "name");
|
||||||
|
IMPLEMENTS (PROP_CALLS, "calls");
|
||||||
|
|
||||||
|
#undef IMPLEMENTS
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -830,8 +851,6 @@ calls_mm_origin_ussd_interface_init (CallsUssdInterface *iface)
|
||||||
static void
|
static void
|
||||||
calls_mm_origin_origin_interface_init (CallsOriginInterface *iface)
|
calls_mm_origin_origin_interface_init (CallsOriginInterface *iface)
|
||||||
{
|
{
|
||||||
iface->get_name = get_name;
|
|
||||||
iface->get_calls = get_calls;
|
|
||||||
iface->dial = dial;
|
iface->dial = dial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,27 +53,14 @@ G_DEFINE_TYPE_WITH_CODE (CallsOfonoOrigin, calls_ofono_origin, G_TYPE_OBJECT,
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
PROP_NAME,
|
||||||
|
PROP_CALLS,
|
||||||
PROP_MODEM,
|
PROP_MODEM,
|
||||||
PROP_LAST_PROP,
|
PROP_LAST_PROP,
|
||||||
};
|
};
|
||||||
static GParamSpec *props[PROP_LAST_PROP];
|
static GParamSpec *props[PROP_LAST_PROP];
|
||||||
|
|
||||||
|
|
||||||
static const gchar *
|
|
||||||
get_name (CallsOrigin *origin)
|
|
||||||
{
|
|
||||||
CallsOfonoOrigin *self = CALLS_OFONO_ORIGIN (origin);
|
|
||||||
return self->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static GList *
|
|
||||||
get_calls (CallsOrigin * origin)
|
|
||||||
{
|
|
||||||
CallsOfonoOrigin *self = CALLS_OFONO_ORIGIN (origin);
|
|
||||||
return g_hash_table_get_values (self->calls);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dial_cb (GDBOVoiceCallManager *voice,
|
dial_cb (GDBOVoiceCallManager *voice,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
|
@ -144,6 +131,31 @@ set_property (GObject *object,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_property (GObject *object,
|
||||||
|
guint property_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
CallsOfonoOrigin *self = CALLS_OFONO_ORIGIN (object);
|
||||||
|
|
||||||
|
switch (property_id) {
|
||||||
|
case PROP_NAME:
|
||||||
|
g_value_set_string (value, self->name);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_CALLS:
|
||||||
|
g_value_set_pointer(value, g_hash_table_get_values (self->calls));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
remove_call (CallsOfonoOrigin *self,
|
remove_call (CallsOfonoOrigin *self,
|
||||||
CallsOfonoCall *call,
|
CallsOfonoCall *call,
|
||||||
|
@ -514,6 +526,7 @@ calls_ofono_origin_class_init (CallsOfonoOriginClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->get_property = get_property;
|
||||||
object_class->set_property = set_property;
|
object_class->set_property = set_property;
|
||||||
object_class->constructed = constructed;
|
object_class->constructed = constructed;
|
||||||
object_class->dispose = dispose;
|
object_class->dispose = dispose;
|
||||||
|
@ -525,8 +538,17 @@ calls_ofono_origin_class_init (CallsOfonoOriginClass *klass)
|
||||||
_("A GDBO proxy object for the underlying modem object"),
|
_("A GDBO proxy object for the underlying modem object"),
|
||||||
GDBO_TYPE_MODEM,
|
GDBO_TYPE_MODEM,
|
||||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
||||||
|
g_object_class_install_property (object_class, PROP_MODEM, props[PROP_MODEM]);
|
||||||
|
|
||||||
|
#define IMPLEMENTS(ID, NAME) \
|
||||||
|
g_object_class_override_property (object_class, ID, NAME); \
|
||||||
|
props[ID] = g_object_class_find_property(object_class, NAME);
|
||||||
|
|
||||||
|
IMPLEMENTS (PROP_NAME, "name");
|
||||||
|
IMPLEMENTS (PROP_CALLS, "calls");
|
||||||
|
|
||||||
|
#undef IMPLEMENTS
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -539,8 +561,6 @@ calls_ofono_origin_message_source_interface_init (CallsOriginInterface *iface)
|
||||||
static void
|
static void
|
||||||
calls_ofono_origin_origin_interface_init (CallsOriginInterface *iface)
|
calls_ofono_origin_origin_interface_init (CallsOriginInterface *iface)
|
||||||
{
|
{
|
||||||
iface->get_name = get_name;
|
|
||||||
iface->get_calls = get_calls;
|
|
||||||
iface->dial = dial;
|
iface->dial = dial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -190,12 +190,8 @@ ussd_state_changed_cb (CallsManager *self,
|
||||||
static void
|
static void
|
||||||
add_origin (CallsManager *self, CallsOrigin *origin, CallsProvider *provider)
|
add_origin (CallsManager *self, CallsOrigin *origin, CallsProvider *provider)
|
||||||
{
|
{
|
||||||
g_autoptr (GList) calls = NULL;
|
|
||||||
GList *c;
|
|
||||||
g_return_if_fail (CALLS_IS_ORIGIN (origin));
|
g_return_if_fail (CALLS_IS_ORIGIN (origin));
|
||||||
|
|
||||||
calls = calls_origin_get_calls (origin);
|
|
||||||
|
|
||||||
g_signal_connect_swapped (origin, "call-added", G_CALLBACK (add_call), self);
|
g_signal_connect_swapped (origin, "call-added", G_CALLBACK (add_call), self);
|
||||||
g_signal_connect_swapped (origin, "call-removed", G_CALLBACK (remove_call), self);
|
g_signal_connect_swapped (origin, "call-removed", G_CALLBACK (remove_call), self);
|
||||||
|
|
||||||
|
@ -206,30 +202,28 @@ add_origin (CallsManager *self, CallsOrigin *origin, CallsProvider *provider)
|
||||||
g_signal_connect_swapped (origin, "ussd-state-changed", G_CALLBACK (ussd_state_changed_cb), self);
|
g_signal_connect_swapped (origin, "ussd-state-changed", G_CALLBACK (ussd_state_changed_cb), self);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (c = calls; c != NULL; c = c->next)
|
calls_origin_foreach_call(origin, (CallsOriginForeachCallFunc)add_call, self);
|
||||||
{
|
|
||||||
add_call (self, c->data, origin);
|
|
||||||
}
|
|
||||||
|
|
||||||
set_state (self, CALLS_MANAGER_STATE_READY);
|
set_state (self, CALLS_MANAGER_STATE_READY);
|
||||||
g_signal_emit (self, signals[SIGNAL_ORIGIN_ADD], 0, origin);
|
g_signal_emit (self, signals[SIGNAL_ORIGIN_ADD], 0, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
remove_call_cb (gpointer self, CallsCall *call, CallsOrigin *origin)
|
||||||
|
{
|
||||||
|
remove_call(self, call, NULL, origin);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
remove_origin (CallsManager *self, CallsOrigin *origin, CallsProvider *provider)
|
remove_origin (CallsManager *self, CallsOrigin *origin, CallsProvider *provider)
|
||||||
{
|
{
|
||||||
g_autoptr (GList) origins = NULL;
|
g_autoptr (GList) origins = NULL;
|
||||||
g_autoptr (GList) calls = NULL;
|
|
||||||
GList *c;
|
|
||||||
g_return_if_fail (CALLS_IS_ORIGIN (origin));
|
g_return_if_fail (CALLS_IS_ORIGIN (origin));
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_data (origin, self);
|
g_signal_handlers_disconnect_by_data (origin, self);
|
||||||
|
|
||||||
calls = calls_origin_get_calls (origin);
|
calls_origin_foreach_call(origin, remove_call_cb, self);
|
||||||
for (c = calls; c != NULL; c = c->next)
|
|
||||||
{
|
|
||||||
remove_call (self, c->data, NULL, origin);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self->default_origin == origin)
|
if (self->default_origin == origin)
|
||||||
calls_manager_set_default_origin (self, NULL);
|
calls_manager_set_default_origin (self, NULL);
|
||||||
|
|
|
@ -47,6 +47,21 @@ calls_origin_default_init (CallsOriginInterface *iface)
|
||||||
{
|
{
|
||||||
GType arg_types[2] = { CALLS_TYPE_CALL, G_TYPE_STRING };
|
GType arg_types[2] = { CALLS_TYPE_CALL, G_TYPE_STRING };
|
||||||
|
|
||||||
|
g_object_interface_install_property (
|
||||||
|
iface,
|
||||||
|
g_param_spec_string ("name",
|
||||||
|
"Name",
|
||||||
|
"The name of the origin",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_interface_install_property (
|
||||||
|
iface,
|
||||||
|
g_param_spec_pointer ("calls",
|
||||||
|
"Calls",
|
||||||
|
"The list of current calls",
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
signals[SIGNAL_CALL_ADDED] =
|
signals[SIGNAL_CALL_ADDED] =
|
||||||
g_signal_newv ("call-added",
|
g_signal_newv ("call-added",
|
||||||
G_TYPE_FROM_INTERFACE (iface),
|
G_TYPE_FROM_INTERFACE (iface),
|
||||||
|
@ -64,9 +79,8 @@ calls_origin_default_init (CallsOriginInterface *iface)
|
||||||
2, arg_types);
|
2, arg_types);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DEFINE_ORIGIN_FUNC(function,rettype,errval) \
|
#define DEFINE_ORIGIN_GETTER(prop,rettype,errval) \
|
||||||
CALLS_DEFINE_IFACE_FUNC(origin, Origin, ORIGIN, \
|
CALLS_DEFINE_IFACE_GETTER(origin, Origin, ORIGIN, prop, rettype, errval)
|
||||||
function, rettype, errval)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* calls_origin_get_name:
|
* calls_origin_get_name:
|
||||||
|
@ -77,7 +91,7 @@ calls_origin_default_init (CallsOriginInterface *iface)
|
||||||
* Returns: A string containing the name. The string must be freed by
|
* Returns: A string containing the name. The string must be freed by
|
||||||
* the caller.
|
* the caller.
|
||||||
*/
|
*/
|
||||||
DEFINE_ORIGIN_FUNC(get_name, const gchar *, NULL);
|
DEFINE_ORIGIN_GETTER(name, const gchar *, NULL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* calls_origin_get_calls:
|
* calls_origin_get_calls:
|
||||||
|
@ -89,7 +103,33 @@ DEFINE_ORIGIN_FUNC(get_name, const gchar *, NULL);
|
||||||
* Returns: A newly-allocated GList of objects implementing
|
* Returns: A newly-allocated GList of objects implementing
|
||||||
* #CallsCall or NULL if there was an error.
|
* #CallsCall or NULL if there was an error.
|
||||||
*/
|
*/
|
||||||
DEFINE_ORIGIN_FUNC(get_calls, GList *, NULL);
|
DEFINE_ORIGIN_GETTER(calls, GList *, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* calls_origin_foreach_call:
|
||||||
|
* @self: a #CallsOrigin
|
||||||
|
* @callback: function to be called for each call from the origin
|
||||||
|
* @param: user data for @callback
|
||||||
|
*
|
||||||
|
* Iterate over all current calls from this origin
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
calls_origin_foreach_call(CallsOrigin *self,
|
||||||
|
CallsOriginForeachCallFunc callback,
|
||||||
|
gpointer param)
|
||||||
|
{
|
||||||
|
g_autoptr(GList) calls = NULL;
|
||||||
|
GList *node;
|
||||||
|
|
||||||
|
calls = calls_origin_get_calls (self);
|
||||||
|
|
||||||
|
for (node = calls; node; node = node->next)
|
||||||
|
{
|
||||||
|
callback (param, CALLS_CALL (node->data), self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* calls_origin_dial:
|
* calls_origin_dial:
|
||||||
|
|
|
@ -42,15 +42,17 @@ struct _CallsOriginInterface
|
||||||
{
|
{
|
||||||
GTypeInterface parent_iface;
|
GTypeInterface parent_iface;
|
||||||
|
|
||||||
const gchar * (*get_name) (CallsOrigin *self);
|
|
||||||
GList * (*get_calls) (CallsOrigin *self);
|
|
||||||
void (*dial) (CallsOrigin *self,
|
void (*dial) (CallsOrigin *self,
|
||||||
const gchar *number);
|
const gchar *number);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void (*CallsOriginForeachCallFunc) (gpointer param, CallsCall* call, CallsOrigin* origin);
|
||||||
|
|
||||||
const gchar * calls_origin_get_name (CallsOrigin *self);
|
const gchar * calls_origin_get_name (CallsOrigin *self);
|
||||||
GList * calls_origin_get_calls (CallsOrigin *self);
|
GList * calls_origin_get_calls (CallsOrigin *self);
|
||||||
|
void calls_origin_foreach_call(CallsOrigin *self,
|
||||||
|
CallsOriginForeachCallFunc callback,
|
||||||
|
gpointer param);
|
||||||
void calls_origin_dial(CallsOrigin *self,
|
void calls_origin_dial(CallsOrigin *self,
|
||||||
const gchar *number);
|
const gchar *number);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue