Replace CallsOrigin getters with properties and add calls_origin_foreach_call method

This commit is contained in:
Daniel Abrecht
2020-03-23 22:10:05 +00:00
committed by Evangelos Ribeiro Tzaras
parent 891ed1fe79
commit 4e7a0b8151
6 changed files with 180 additions and 89 deletions

View File

@@ -63,6 +63,8 @@ G_DEFINE_TYPE_WITH_CODE (CallsMMOrigin, calls_mm_origin, G_TYPE_OBJECT,
enum {
PROP_0,
PROP_NAME,
PROP_CALLS,
PROP_MODEM,
PROP_LAST_PROP,
};
@@ -294,21 +296,6 @@ calls_mm_ussd_cancel_finish (CallsUssd *ussd,
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
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 *
modem_get_name (MMModem *modem)
{
@@ -792,6 +803,7 @@ calls_mm_origin_class_init (CallsMMOriginClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->constructed = constructed;
object_class->dispose = dispose;
@@ -803,8 +815,17 @@ calls_mm_origin_class_init (CallsMMOriginClass *klass)
_("A libmm-glib proxy object for the modem"),
MM_TYPE_OBJECT,
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
calls_mm_origin_origin_interface_init (CallsOriginInterface *iface)
{
iface->get_name = get_name;
iface->get_calls = get_calls;
iface->dial = dial;
}