call: Move state property into base class

This let's us get rid of a lot of duplication in the derived classes.

Additionally we set the initial state to CALLS_CALL_STATE_INCOMING if
inbound is TRUE and CALLS_CALL_STATE_DIALING otherwise.
This commit is contained in:
Evangelos Ribeiro Tzaras
2021-12-10 09:02:39 +01:00
parent ddf1dd7349
commit a048b4c83d
10 changed files with 100 additions and 243 deletions

View File

@@ -38,7 +38,6 @@ struct _CallsMMCall
GObject parent_instance;
MMCall *mm_call;
GString *id;
CallsCallState state;
gchar *disconnect_reason;
};
@@ -55,26 +54,6 @@ enum {
};
static GParamSpec *props[PROP_LAST_PROP];
static void
change_state (CallsMMCall *self,
CallsCallState state)
{
CallsCallState old_state = self->state;
if (old_state == state)
{
return;
}
self->state = state;
g_object_notify (G_OBJECT (self), "state");
g_signal_emit_by_name (CALLS_CALL (self),
"state-changed",
state,
old_state);
}
static void
notify_id_cb (CallsMMCall *self,
const gchar *id)
@@ -185,7 +164,7 @@ state_changed_cb (CallsMMCall *self,
{
g_debug ("MM call state changed to `%s'",
map_row->name);
change_state (self, map_row->calls);
calls_call_set_state (CALLS_CALL (self), map_row->calls);
return;
}
}
@@ -199,14 +178,6 @@ calls_mm_call_get_id (CallsCall *call)
return self->id->str;
}
static CallsCallState
calls_mm_call_get_state (CallsCall *call)
{
CallsMMCall *self = CALLS_MM_CALL (call);
return self->state;
}
static const char *
calls_mm_call_get_protocol (CallsCall *self)
@@ -369,7 +340,6 @@ calls_mm_call_class_init (CallsMMCallClass *klass)
object_class->finalize = finalize;
call_class->get_id = calls_mm_call_get_id;
call_class->get_state = calls_mm_call_get_state;
call_class->get_protocol = calls_mm_call_get_protocol;
call_class->answer = calls_mm_call_answer;
call_class->hang_up = calls_mm_call_hang_up;