mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-06 03:25:31 +00:00
Let calls-call be an abstract class
And adapt to changes. A calls-mm-call IS-A calls-call (and so on)
This commit is contained in:
parent
a30e1eaa8f
commit
c30a41ffa9
10 changed files with 422 additions and 434 deletions
|
@ -37,25 +37,16 @@ struct _CallsDummyCall
|
|||
CallsCallState state;
|
||||
};
|
||||
|
||||
static void calls_dummy_call_message_source_interface_init (CallsCallInterface *iface);
|
||||
static void calls_dummy_call_call_interface_init (CallsCallInterface *iface);
|
||||
static void calls_dummy_call_message_source_interface_init (CallsMessageSourceInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (CallsDummyCall, calls_dummy_call, G_TYPE_OBJECT,
|
||||
G_DEFINE_TYPE_WITH_CODE (CallsDummyCall, calls_dummy_call, CALLS_TYPE_CALL,
|
||||
G_IMPLEMENT_INTERFACE (CALLS_TYPE_MESSAGE_SOURCE,
|
||||
calls_dummy_call_message_source_interface_init)
|
||||
G_IMPLEMENT_INTERFACE (CALLS_TYPE_CALL,
|
||||
calls_dummy_call_call_interface_init))
|
||||
calls_dummy_call_message_source_interface_init))
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_NUMBER_CONSTRUCTOR,
|
||||
PROP_INBOUND_CONSTRUCTOR,
|
||||
|
||||
PROP_CALL_NUMBER,
|
||||
PROP_CALL_INBOUND,
|
||||
PROP_CALL_STATE,
|
||||
PROP_CALL_NAME,
|
||||
|
||||
PROP_LAST_PROP
|
||||
};
|
||||
static GParamSpec *props[PROP_LAST_PROP];
|
||||
|
@ -73,15 +64,39 @@ change_state (CallsCall *call,
|
|||
}
|
||||
|
||||
self->state = state;
|
||||
g_object_notify_by_pspec (G_OBJECT (call), props[PROP_CALL_STATE]);
|
||||
g_object_notify (G_OBJECT (self), "state");
|
||||
g_signal_emit_by_name (call,
|
||||
"state-changed",
|
||||
state,
|
||||
old_state);
|
||||
}
|
||||
|
||||
static const char *
|
||||
calls_dummy_call_get_number (CallsCall *call)
|
||||
{
|
||||
CallsDummyCall *self = CALLS_DUMMY_CALL (call);
|
||||
|
||||
return self->number;
|
||||
}
|
||||
|
||||
static CallsCallState
|
||||
calls_dummy_call_get_state (CallsCall *call)
|
||||
{
|
||||
CallsDummyCall *self = CALLS_DUMMY_CALL (call);
|
||||
|
||||
return self->state;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
calls_dummy_call_get_inbound (CallsCall *call)
|
||||
{
|
||||
CallsDummyCall *self = CALLS_DUMMY_CALL (call);
|
||||
|
||||
return self->inbound;
|
||||
}
|
||||
|
||||
static void
|
||||
answer (CallsCall *call)
|
||||
calls_dummy_call_answer (CallsCall *call)
|
||||
{
|
||||
CallsDummyCall *self;
|
||||
|
||||
|
@ -94,7 +109,7 @@ answer (CallsCall *call)
|
|||
}
|
||||
|
||||
static void
|
||||
hang_up (CallsCall *call)
|
||||
calls_dummy_call_hang_up (CallsCall *call)
|
||||
{
|
||||
CallsDummyCall *self;
|
||||
|
||||
|
@ -104,19 +119,6 @@ hang_up (CallsCall *call)
|
|||
change_state (call, self, CALLS_CALL_STATE_DISCONNECTED);
|
||||
}
|
||||
|
||||
static void
|
||||
tone_start (CallsCall *call, gchar key)
|
||||
{
|
||||
g_info ("Beep! (%c)", (int)key);
|
||||
}
|
||||
|
||||
static void
|
||||
tone_stop (CallsCall *call, gchar key)
|
||||
{
|
||||
g_info ("Beep end (%c)", (int)key);
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
outbound_timeout_cb (CallsDummyCall *self)
|
||||
{
|
||||
|
@ -197,39 +199,6 @@ constructed (GObject *object)
|
|||
G_OBJECT_CLASS (calls_dummy_call_parent_class)->constructed (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
CallsDummyCall *self = CALLS_DUMMY_CALL (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_CALL_INBOUND:
|
||||
g_value_set_boolean (value, self->inbound);
|
||||
break;
|
||||
|
||||
case PROP_CALL_NUMBER:
|
||||
g_value_set_string (value, self->number);
|
||||
break;
|
||||
|
||||
case PROP_CALL_STATE:
|
||||
g_value_set_enum (value, self->state);
|
||||
break;
|
||||
|
||||
case PROP_CALL_NAME:
|
||||
g_value_set_string (value, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
|
@ -245,12 +214,18 @@ static void
|
|||
calls_dummy_call_class_init (CallsDummyCallClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
CallsCallClass *call_class = CALLS_CALL_CLASS (klass);
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->constructed = constructed;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
call_class->get_number = calls_dummy_call_get_number;
|
||||
call_class->get_state = calls_dummy_call_get_state;
|
||||
call_class->get_inbound = calls_dummy_call_get_inbound;
|
||||
call_class->answer = calls_dummy_call_answer;
|
||||
call_class->hang_up = calls_dummy_call_hang_up;
|
||||
|
||||
props[PROP_NUMBER_CONSTRUCTOR] =
|
||||
g_param_spec_string ("number-constructor",
|
||||
"Number (constructor)",
|
||||
|
@ -266,32 +241,10 @@ calls_dummy_call_class_init (CallsDummyCallClass *klass)
|
|||
FALSE,
|
||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_INBOUND_CONSTRUCTOR, props[PROP_INBOUND_CONSTRUCTOR]);
|
||||
|
||||
#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_CALL_NUMBER, "number");
|
||||
IMPLEMENTS(PROP_CALL_INBOUND, "inbound");
|
||||
IMPLEMENTS(PROP_CALL_STATE, "state");
|
||||
IMPLEMENTS(PROP_CALL_NAME, "name");
|
||||
|
||||
#undef IMPLEMENTS
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
calls_dummy_call_call_interface_init (CallsCallInterface *iface)
|
||||
{
|
||||
iface->answer = answer;
|
||||
iface->hang_up = hang_up;
|
||||
iface->tone_start = tone_start;
|
||||
iface->tone_stop = tone_stop;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_dummy_call_message_source_interface_init (CallsCallInterface *iface)
|
||||
calls_dummy_call_message_source_interface_init (CallsMessageSourceInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -27,11 +27,13 @@
|
|||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "calls-call.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CALLS_TYPE_DUMMY_CALL (calls_dummy_call_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (CallsDummyCall, calls_dummy_call, CALLS, DUMMY_CALL, GObject);
|
||||
G_DECLARE_FINAL_TYPE (CallsDummyCall, calls_dummy_call, CALLS, DUMMY_CALL, CallsCall)
|
||||
|
||||
CallsDummyCall *calls_dummy_call_new (const gchar *number,
|
||||
gboolean inbound);
|
||||
|
|
|
@ -40,24 +40,15 @@ struct _CallsMMCall
|
|||
gchar *disconnect_reason;
|
||||
};
|
||||
|
||||
static void calls_mm_call_message_source_interface_init (CallsCallInterface *iface);
|
||||
static void calls_mm_call_call_interface_init (CallsCallInterface *iface);
|
||||
static void calls_mm_call_message_source_interface_init (CallsMessageSourceInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (CallsMMCall, calls_mm_call, G_TYPE_OBJECT,
|
||||
G_DEFINE_TYPE_WITH_CODE (CallsMMCall, calls_mm_call, CALLS_TYPE_CALL,
|
||||
G_IMPLEMENT_INTERFACE (CALLS_TYPE_MESSAGE_SOURCE,
|
||||
calls_mm_call_message_source_interface_init)
|
||||
G_IMPLEMENT_INTERFACE (CALLS_TYPE_CALL,
|
||||
calls_mm_call_call_interface_init))
|
||||
calls_mm_call_message_source_interface_init))
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_MM_CALL,
|
||||
|
||||
PROP_CALL_NUMBER,
|
||||
PROP_CALL_INBOUND,
|
||||
PROP_CALL_STATE,
|
||||
PROP_CALL_NAME,
|
||||
|
||||
PROP_LAST_PROP,
|
||||
};
|
||||
static GParamSpec *props[PROP_LAST_PROP];
|
||||
|
@ -74,7 +65,7 @@ change_state (CallsMMCall *self,
|
|||
}
|
||||
|
||||
self->state = state;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CALL_STATE]);
|
||||
g_object_notify (G_OBJECT (self), "state");
|
||||
g_signal_emit_by_name (CALLS_CALL (self),
|
||||
"state-changed",
|
||||
state,
|
||||
|
@ -87,7 +78,7 @@ notify_number_cb (CallsMMCall *self,
|
|||
const gchar *number)
|
||||
{
|
||||
g_string_assign (self->number, number);
|
||||
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CALL_NUMBER]);
|
||||
g_object_notify (G_OBJECT (self), "number");
|
||||
}
|
||||
|
||||
|
||||
|
@ -198,6 +189,32 @@ state_changed_cb (CallsMMCall *self,
|
|||
}
|
||||
}
|
||||
|
||||
static const char *
|
||||
calls_mm_call_get_number (CallsCall *call)
|
||||
{
|
||||
CallsMMCall *self = CALLS_MM_CALL (call);
|
||||
|
||||
return self->number->str;
|
||||
}
|
||||
|
||||
static CallsCallState
|
||||
calls_mm_call_get_state (CallsCall *call)
|
||||
{
|
||||
CallsMMCall *self = CALLS_MM_CALL (call);
|
||||
|
||||
return self->state;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
calls_mm_call_get_inbound (CallsCall *call)
|
||||
{
|
||||
CallsMMCall *self = CALLS_MM_CALL (call);
|
||||
|
||||
if (self->mm_call)
|
||||
return mm_call_get_direction (self->mm_call) == MM_CALL_DIRECTION_INCOMING;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
struct CallsMMOperationData
|
||||
{
|
||||
|
@ -244,13 +261,13 @@ operation_cb (MMCall *mm_call,
|
|||
data); \
|
||||
}
|
||||
|
||||
DEFINE_OPERATION(accept, answer, "accepting");
|
||||
DEFINE_OPERATION(hangup, hang_up, "hanging up");
|
||||
DEFINE_OPERATION(start, start_call, "starting outgoing call");
|
||||
DEFINE_OPERATION(accept, calls_mm_call_answer, "accepting");
|
||||
DEFINE_OPERATION(hangup, calls_mm_call_hang_up, "hanging up");
|
||||
DEFINE_OPERATION(start, calls_mm_call_start_call, "starting outgoing call");
|
||||
|
||||
|
||||
static void
|
||||
tone_start (CallsCall *call, gchar key)
|
||||
calls_mm_call_tone_start (CallsCall *call, gchar key)
|
||||
{
|
||||
CallsMMCall *self = CALLS_MM_CALL (call);
|
||||
struct CallsMMOperationData *data;
|
||||
|
@ -315,47 +332,12 @@ constructed (GObject *object)
|
|||
if (state == MM_CALL_STATE_UNKNOWN
|
||||
&& mm_call_get_direction (self->mm_call) == MM_CALL_DIRECTION_OUTGOING)
|
||||
{
|
||||
start_call (CALLS_CALL (self));
|
||||
calls_mm_call_start_call (CALLS_CALL (self));
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (calls_mm_call_parent_class)->constructed (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
CallsMMCall *self = CALLS_MM_CALL (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_CALL_INBOUND:
|
||||
g_value_set_boolean (value,
|
||||
mm_call_get_direction (self->mm_call)
|
||||
== MM_CALL_DIRECTION_INCOMING);
|
||||
break;
|
||||
|
||||
case PROP_CALL_NAME:
|
||||
g_value_set_string(value, NULL);
|
||||
break;
|
||||
|
||||
case PROP_CALL_NUMBER:
|
||||
g_value_set_string(value, self->number->str);
|
||||
break;
|
||||
|
||||
case PROP_CALL_STATE:
|
||||
g_value_set_enum (value, self->state);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dispose (GObject *object)
|
||||
{
|
||||
|
@ -383,48 +365,34 @@ static void
|
|||
calls_mm_call_class_init (CallsMMCallClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
CallsCallClass *call_class = CALLS_CALL_CLASS (klass);
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->constructed = constructed;
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
call_class->get_number = calls_mm_call_get_number;
|
||||
call_class->get_state = calls_mm_call_get_state;
|
||||
call_class->get_inbound = calls_mm_call_get_inbound;
|
||||
call_class->answer = calls_mm_call_answer;
|
||||
call_class->hang_up = calls_mm_call_hang_up;
|
||||
call_class->tone_start = calls_mm_call_tone_start;
|
||||
|
||||
props[PROP_MM_CALL] = g_param_spec_object ("mm-call",
|
||||
"MM call",
|
||||
"A libmm-glib proxy object for the underlying call object",
|
||||
MM_TYPE_CALL,
|
||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_MM_CALL, props[PROP_MM_CALL]);
|
||||
|
||||
#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_CALL_NUMBER, "number");
|
||||
IMPLEMENTS(PROP_CALL_INBOUND, "inbound");
|
||||
IMPLEMENTS(PROP_CALL_STATE, "state");
|
||||
IMPLEMENTS(PROP_CALL_NAME, "name");
|
||||
|
||||
#undef IMPLEMENTS
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_mm_call_message_source_interface_init (CallsCallInterface *iface)
|
||||
calls_mm_call_message_source_interface_init (CallsMessageSourceInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_mm_call_call_interface_init (CallsCallInterface *iface)
|
||||
{
|
||||
iface->answer = answer;
|
||||
iface->hang_up = hang_up;
|
||||
iface->tone_start = tone_start;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_mm_call_init (CallsMMCall *self)
|
||||
{
|
||||
|
|
|
@ -28,11 +28,13 @@
|
|||
#include <libmm-glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "calls-call.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CALLS_TYPE_MM_CALL (calls_mm_call_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (CallsMMCall, calls_mm_call, CALLS, MM_CALL, GObject);
|
||||
G_DECLARE_FINAL_TYPE (CallsMMCall, calls_mm_call, CALLS, MM_CALL, CallsCall)
|
||||
|
||||
CallsMMCall *calls_mm_call_new (MMCall *mm_call);
|
||||
const gchar *calls_mm_call_get_object_path (CallsMMCall *call);
|
||||
|
|
|
@ -44,25 +44,16 @@ struct _CallsOfonoCall
|
|||
gboolean inbound;
|
||||
};
|
||||
|
||||
static void calls_ofono_call_message_source_interface_init (CallsCallInterface *iface);
|
||||
static void calls_ofono_call_call_interface_init (CallsCallInterface *iface);
|
||||
static void calls_ofono_call_message_source_interface_init (CallsMessageSourceInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (CallsOfonoCall, calls_ofono_call, G_TYPE_OBJECT,
|
||||
G_DEFINE_TYPE_WITH_CODE (CallsOfonoCall, calls_ofono_call, CALLS_TYPE_CALL,
|
||||
G_IMPLEMENT_INTERFACE (CALLS_TYPE_MESSAGE_SOURCE,
|
||||
calls_ofono_call_message_source_interface_init)
|
||||
G_IMPLEMENT_INTERFACE (CALLS_TYPE_CALL,
|
||||
calls_ofono_call_call_interface_init))
|
||||
calls_ofono_call_message_source_interface_init))
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_VOICE_CALL,
|
||||
PROP_PROPERTIES,
|
||||
|
||||
PROP_CALL_NUMBER,
|
||||
PROP_CALL_INBOUND,
|
||||
PROP_CALL_STATE,
|
||||
PROP_CALL_NAME,
|
||||
|
||||
PROP_LAST_PROP,
|
||||
};
|
||||
static GParamSpec *props[PROP_LAST_PROP];
|
||||
|
@ -85,13 +76,44 @@ change_state (CallsOfonoCall *self,
|
|||
}
|
||||
|
||||
self->state = state;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CALL_STATE]);
|
||||
g_object_notify (G_OBJECT (self), "state");
|
||||
g_signal_emit_by_name (CALLS_CALL (self),
|
||||
"state-changed",
|
||||
state,
|
||||
old_state);
|
||||
}
|
||||
|
||||
static const char *
|
||||
calls_ofono_call_get_number (CallsCall *call)
|
||||
{
|
||||
CallsOfonoCall *self = CALLS_OFONO_CALL (call);
|
||||
|
||||
return self->number;
|
||||
}
|
||||
|
||||
static const char *
|
||||
calls_ofono_call_get_name (CallsCall *call)
|
||||
{
|
||||
CallsOfonoCall *self = CALLS_OFONO_CALL (call);
|
||||
|
||||
return self->name;
|
||||
}
|
||||
|
||||
static CallsCallState
|
||||
calls_ofono_call_get_state (CallsCall *call)
|
||||
{
|
||||
CallsOfonoCall *self = CALLS_OFONO_CALL (call);
|
||||
|
||||
return self->state;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
calls_ofono_call_get_inbound (CallsCall *call)
|
||||
{
|
||||
CallsOfonoCall *self = CALLS_OFONO_CALL (call);
|
||||
|
||||
return self->state;
|
||||
}
|
||||
|
||||
struct CallsCallOperationData
|
||||
{
|
||||
|
@ -122,7 +144,7 @@ operation_cb (GDBOVoiceCall *voice_call,
|
|||
|
||||
|
||||
static void
|
||||
answer (CallsCall *call)
|
||||
calls_ofono_call_answer (CallsCall *call)
|
||||
{
|
||||
CallsOfonoCall *self = CALLS_OFONO_CALL (call);
|
||||
struct CallsCallOperationData *data;
|
||||
|
@ -140,7 +162,7 @@ answer (CallsCall *call)
|
|||
|
||||
|
||||
static void
|
||||
hang_up (CallsCall *call)
|
||||
calls_ofono_call_hang_up (CallsCall *call)
|
||||
{
|
||||
CallsOfonoCall *self = CALLS_OFONO_CALL (call);
|
||||
struct CallsCallOperationData *data;
|
||||
|
@ -158,7 +180,7 @@ hang_up (CallsCall *call)
|
|||
|
||||
|
||||
static void
|
||||
tone_start (CallsCall *call, gchar key)
|
||||
calls_ofono_call_tone_start (CallsCall *call, gchar key)
|
||||
{
|
||||
CallsOfonoCall *self = CALLS_OFONO_CALL (call);
|
||||
if (self->state != CALLS_CALL_STATE_ACTIVE)
|
||||
|
@ -218,37 +240,6 @@ set_property (GObject *object,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
CallsOfonoCall *self = CALLS_OFONO_CALL (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_CALL_INBOUND:
|
||||
g_value_set_boolean (value, self->state);
|
||||
break;
|
||||
|
||||
case PROP_CALL_NAME:
|
||||
g_value_set_string(value, self->name);
|
||||
break;
|
||||
|
||||
case PROP_CALL_NUMBER:
|
||||
g_value_set_string(value, self->number);
|
||||
break;
|
||||
|
||||
case PROP_CALL_STATE:
|
||||
g_value_set_enum (value, self->state);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
property_changed_cb (CallsOfonoCall *self,
|
||||
const gchar *name,
|
||||
|
@ -349,14 +340,22 @@ static void
|
|||
calls_ofono_call_class_init (CallsOfonoCallClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
CallsCallClass *call_class = CALLS_CALL_CLASS (klass);
|
||||
GType tone_arg_types = G_TYPE_CHAR;
|
||||
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = get_property;
|
||||
object_class->constructed = constructed;
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
call_class->get_number = calls_ofono_call_get_number;
|
||||
call_class->get_name = calls_ofono_call_get_name;
|
||||
call_class->get_state = calls_ofono_call_get_state;
|
||||
call_class->get_inbound = calls_ofono_call_get_inbound;
|
||||
call_class->answer = calls_ofono_call_answer;
|
||||
call_class->hang_up = calls_ofono_call_hang_up;
|
||||
call_class->tone_start = calls_ofono_call_tone_start;
|
||||
|
||||
props[PROP_VOICE_CALL] =
|
||||
g_param_spec_object ("voice-call",
|
||||
"Voice call",
|
||||
|
@ -374,17 +373,6 @@ calls_ofono_call_class_init (CallsOfonoCallClass *klass)
|
|||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_PROPERTIES, props[PROP_PROPERTIES]);
|
||||
|
||||
#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_CALL_NUMBER, "number");
|
||||
IMPLEMENTS(PROP_CALL_INBOUND, "inbound");
|
||||
IMPLEMENTS(PROP_CALL_STATE, "state");
|
||||
IMPLEMENTS(PROP_CALL_NAME, "name");
|
||||
|
||||
#undef IMPLEMENTS
|
||||
|
||||
signals[SIGNAL_TONE] =
|
||||
g_signal_newv ("tone",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
|
@ -396,20 +384,10 @@ calls_ofono_call_class_init (CallsOfonoCallClass *klass)
|
|||
|
||||
|
||||
static void
|
||||
calls_ofono_call_message_source_interface_init (CallsCallInterface *iface)
|
||||
calls_ofono_call_message_source_interface_init (CallsMessageSourceInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_ofono_call_call_interface_init (CallsCallInterface *iface)
|
||||
{
|
||||
iface->answer = answer;
|
||||
iface->hang_up = hang_up;
|
||||
iface->tone_start = tone_start;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_ofono_call_init (CallsOfonoCall *self)
|
||||
{
|
||||
|
|
|
@ -26,14 +26,15 @@
|
|||
#define CALLS_OFONO_CALL_H__
|
||||
|
||||
#include <libgdbofono/gdbo-call.h>
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "calls-call.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CALLS_TYPE_OFONO_CALL (calls_ofono_call_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (CallsOfonoCall, calls_ofono_call, CALLS, OFONO_CALL, GObject);
|
||||
G_DECLARE_FINAL_TYPE (CallsOfonoCall, calls_ofono_call, CALLS, OFONO_CALL, CallsCall)
|
||||
|
||||
CallsOfonoCall *calls_ofono_call_new (GDBOVoiceCall *voice_call,
|
||||
GVariant *properties);
|
||||
|
|
|
@ -48,29 +48,46 @@ struct _CallsSipCall
|
|||
nua_handle_t *nh;
|
||||
};
|
||||
|
||||
static void calls_sip_call_message_source_interface_init (CallsCallInterface *iface);
|
||||
static void calls_sip_call_call_interface_init (CallsCallInterface *iface);
|
||||
static void calls_sip_call_message_source_interface_init (CallsMessageSourceInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (CallsSipCall, calls_sip_call, G_TYPE_OBJECT,
|
||||
G_DEFINE_TYPE_WITH_CODE (CallsSipCall, calls_sip_call, CALLS_TYPE_CALL,
|
||||
G_IMPLEMENT_INTERFACE (CALLS_TYPE_MESSAGE_SOURCE,
|
||||
calls_sip_call_message_source_interface_init)
|
||||
G_IMPLEMENT_INTERFACE (CALLS_TYPE_CALL,
|
||||
calls_sip_call_call_interface_init))
|
||||
calls_sip_call_message_source_interface_init))
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_CALL_HANDLE,
|
||||
PROP_CALL_NUMBER,
|
||||
PROP_CALL_INBOUND,
|
||||
PROP_CALL_STATE,
|
||||
PROP_CALL_NAME,
|
||||
PROP_LAST_PROP
|
||||
};
|
||||
static GParamSpec *props[PROP_LAST_PROP];
|
||||
|
||||
|
||||
static const char *
|
||||
calls_sip_call_get_number (CallsCall *call)
|
||||
{
|
||||
CallsSipCall *self = CALLS_SIP_CALL (call);
|
||||
|
||||
return self->number;
|
||||
}
|
||||
|
||||
static CallsCallState
|
||||
calls_sip_call_get_state (CallsCall *call)
|
||||
{
|
||||
CallsSipCall *self = CALLS_SIP_CALL (call);
|
||||
|
||||
return self->state;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
calls_sip_call_get_inbound (CallsCall *call)
|
||||
{
|
||||
CallsSipCall *self = CALLS_SIP_CALL (call);
|
||||
|
||||
return self->inbound;
|
||||
}
|
||||
|
||||
static void
|
||||
answer (CallsCall *call)
|
||||
calls_sip_call_answer (CallsCall *call)
|
||||
{
|
||||
CallsSipCall *self;
|
||||
g_autofree gchar *local_sdp = NULL;
|
||||
|
@ -107,7 +124,7 @@ answer (CallsCall *call)
|
|||
}
|
||||
|
||||
static void
|
||||
hang_up (CallsCall *call)
|
||||
calls_sip_call_hang_up (CallsCall *call)
|
||||
{
|
||||
CallsSipCall *self;
|
||||
|
||||
|
@ -142,19 +159,6 @@ hang_up (CallsCall *call)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
tone_start (CallsCall *call, gchar key)
|
||||
{
|
||||
g_info ("Beep! (%c)", (int)key);
|
||||
}
|
||||
|
||||
static void
|
||||
tone_stop (CallsCall *call, gchar key)
|
||||
{
|
||||
g_info ("Beep end (%c)", (int)key);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_sip_call_set_property (GObject *object,
|
||||
guint property_id,
|
||||
|
@ -184,22 +188,6 @@ calls_sip_call_get_property (GObject *object,
|
|||
CallsSipCall *self = CALLS_SIP_CALL (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_CALL_INBOUND:
|
||||
g_value_set_boolean (value, self->inbound);
|
||||
break;
|
||||
|
||||
case PROP_CALL_NUMBER:
|
||||
g_value_set_string (value, self->number);
|
||||
break;
|
||||
|
||||
case PROP_CALL_STATE:
|
||||
g_value_set_enum (value, self->state);
|
||||
break;
|
||||
|
||||
case PROP_CALL_NAME:
|
||||
g_value_set_string (value, NULL);
|
||||
break;
|
||||
|
||||
case PROP_CALL_HANDLE:
|
||||
g_value_set_pointer (value, self->nh);
|
||||
break;
|
||||
|
@ -230,43 +218,28 @@ static void
|
|||
calls_sip_call_class_init (CallsSipCallClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
CallsCallClass *call_class = CALLS_CALL_CLASS (klass);
|
||||
|
||||
object_class->get_property = calls_sip_call_get_property;
|
||||
object_class->set_property = calls_sip_call_set_property;
|
||||
object_class->finalize = calls_sip_call_finalize;
|
||||
|
||||
call_class->get_number = calls_sip_call_get_number;
|
||||
call_class->get_state = calls_sip_call_get_state;
|
||||
call_class->get_inbound = calls_sip_call_get_inbound;
|
||||
call_class->answer = calls_sip_call_answer;
|
||||
call_class->hang_up = calls_sip_call_hang_up;
|
||||
|
||||
props[PROP_CALL_HANDLE] =
|
||||
g_param_spec_pointer ("nua-handle",
|
||||
"NUA handle",
|
||||
"The used NUA handler",
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_CALL_HANDLE, props[PROP_CALL_HANDLE]);
|
||||
|
||||
#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_CALL_NUMBER, "number");
|
||||
IMPLEMENTS(PROP_CALL_INBOUND, "inbound");
|
||||
IMPLEMENTS(PROP_CALL_STATE, "state");
|
||||
IMPLEMENTS(PROP_CALL_NAME, "name");
|
||||
|
||||
#undef IMPLEMENTS
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
calls_sip_call_call_interface_init (CallsCallInterface *iface)
|
||||
{
|
||||
iface->answer = answer;
|
||||
iface->hang_up = hang_up;
|
||||
iface->tone_start = tone_start;
|
||||
iface->tone_stop = tone_stop;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_sip_call_message_source_interface_init (CallsCallInterface *iface)
|
||||
calls_sip_call_message_source_interface_init (CallsMessageSourceInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -374,7 +347,7 @@ calls_sip_call_set_state (CallsSipCall *self,
|
|||
}
|
||||
|
||||
self->state = state;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CALL_STATE]);
|
||||
g_object_notify (G_OBJECT (self), "state");
|
||||
g_signal_emit_by_name (CALLS_CALL (self),
|
||||
"state-changed",
|
||||
state,
|
||||
|
|
|
@ -33,7 +33,7 @@ G_BEGIN_DECLS
|
|||
|
||||
#define CALLS_TYPE_SIP_CALL (calls_sip_call_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (CallsSipCall, calls_sip_call, CALLS, SIP_CALL, GObject);
|
||||
G_DECLARE_FINAL_TYPE (CallsSipCall, calls_sip_call, CALLS, SIP_CALL, CallsCall)
|
||||
|
||||
CallsSipCall *calls_sip_call_new (const gchar *number,
|
||||
gboolean inbound,
|
||||
|
|
338
src/calls-call.c
338
src/calls-call.c
|
@ -31,59 +31,6 @@
|
|||
#include <glib/gi18n.h>
|
||||
|
||||
|
||||
void
|
||||
calls_call_state_to_string (GString *string,
|
||||
CallsCallState state)
|
||||
{
|
||||
GEnumClass *klass;
|
||||
GEnumValue *value;
|
||||
|
||||
klass = g_type_class_ref (CALLS_TYPE_CALL_STATE);
|
||||
|
||||
value = g_enum_get_value (klass, (gint)state);
|
||||
if (!value)
|
||||
{
|
||||
return g_string_printf (string,
|
||||
"Unknown call state (%d)",
|
||||
(gint)state);
|
||||
}
|
||||
|
||||
g_string_assign (string, value->value_nick);
|
||||
string->str[0] = g_ascii_toupper (string->str[0]);
|
||||
|
||||
g_type_class_unref (klass);
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
calls_call_state_parse_nick (CallsCallState *state,
|
||||
const gchar *nick)
|
||||
{
|
||||
GEnumClass *klass;
|
||||
GEnumValue *value;
|
||||
gboolean ret;
|
||||
|
||||
g_return_val_if_fail (state != NULL, FALSE);
|
||||
g_return_val_if_fail (nick != NULL, FALSE);
|
||||
|
||||
klass = g_type_class_ref (CALLS_TYPE_CALL_STATE);
|
||||
value = g_enum_get_value_by_nick (klass, nick);
|
||||
|
||||
if (value)
|
||||
{
|
||||
*state = (CallsCallState) value->value;
|
||||
ret = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = FALSE;
|
||||
}
|
||||
|
||||
g_type_class_unref (klass);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SECTION:calls-call
|
||||
* @short_description: A call.
|
||||
|
@ -100,56 +47,150 @@ calls_call_state_parse_nick (CallsCallState *state,
|
|||
*/
|
||||
|
||||
|
||||
G_DEFINE_INTERFACE (CallsCall, calls_call, CALLS_TYPE_MESSAGE_SOURCE);
|
||||
G_DEFINE_ABSTRACT_TYPE (CallsCall, calls_call, G_TYPE_OBJECT)
|
||||
|
||||
enum {
|
||||
SIGNAL_STATE_CHANGED,
|
||||
SIGNAL_LAST_SIGNAL,
|
||||
PROP_0,
|
||||
PROP_INBOUND,
|
||||
PROP_NUMBER,
|
||||
PROP_NAME,
|
||||
PROP_STATE,
|
||||
N_PROPS,
|
||||
};
|
||||
static guint signals [SIGNAL_LAST_SIGNAL];
|
||||
|
||||
enum {
|
||||
STATE_CHANGED,
|
||||
N_SIGNALS,
|
||||
};
|
||||
|
||||
static GParamSpec *properties[N_PROPS];
|
||||
static guint signals[N_SIGNALS];
|
||||
|
||||
static const char *
|
||||
calls_call_real_get_number (CallsCall *self)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
calls_call_real_get_name (CallsCall *self)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static CallsCallState
|
||||
calls_call_real_get_state (CallsCall *self)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
calls_call_real_get_inbound (CallsCall *self)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
calls_call_default_init (CallsCallInterface *iface)
|
||||
calls_call_real_answer (CallsCall *self)
|
||||
{
|
||||
GType arg_types[2] =
|
||||
{
|
||||
CALLS_TYPE_CALL_STATE,
|
||||
CALLS_TYPE_CALL_STATE
|
||||
};
|
||||
}
|
||||
|
||||
g_object_interface_install_property (
|
||||
iface,
|
||||
static void
|
||||
calls_call_real_hang_up (CallsCall *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
calls_call_real_tone_start (CallsCall *self,
|
||||
char key)
|
||||
{
|
||||
g_info ("Beep! (%c)", (int)key);
|
||||
}
|
||||
|
||||
static void
|
||||
calls_call_real_tone_stop (CallsCall *self,
|
||||
char key)
|
||||
{
|
||||
g_info ("Beep end (%c)", (int)key);
|
||||
}
|
||||
|
||||
static void
|
||||
calls_call_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
CallsCall *self = CALLS_CALL (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_INBOUND:
|
||||
g_value_set_boolean (value, calls_call_get_inbound (self));
|
||||
break;
|
||||
|
||||
case PROP_NUMBER:
|
||||
g_value_set_string (value, calls_call_get_number (self));
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, calls_call_get_name (self));
|
||||
break;
|
||||
|
||||
case PROP_STATE:
|
||||
g_value_set_enum (value, calls_call_get_state (self));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
calls_call_class_init (CallsCallClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->get_property = calls_call_get_property;
|
||||
|
||||
klass->get_number = calls_call_real_get_number;
|
||||
klass->get_name = calls_call_real_get_name;
|
||||
klass->get_state = calls_call_real_get_state;
|
||||
klass->get_inbound = calls_call_real_get_inbound;
|
||||
klass->answer = calls_call_real_answer;
|
||||
klass->hang_up = calls_call_real_hang_up;
|
||||
klass->tone_start = calls_call_real_tone_start;
|
||||
klass->tone_stop = calls_call_real_tone_stop;
|
||||
|
||||
properties[PROP_INBOUND] =
|
||||
g_param_spec_boolean ("inbound",
|
||||
"Inbound",
|
||||
"Whether the call is inbound",
|
||||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_interface_install_property (
|
||||
iface,
|
||||
properties[PROP_NUMBER] =
|
||||
g_param_spec_string ("number",
|
||||
"Number",
|
||||
"The number the call is connected to if known",
|
||||
NULL,
|
||||
G_PARAM_READABLE));
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_interface_install_property (
|
||||
iface,
|
||||
properties[PROP_NAME] =
|
||||
g_param_spec_string ("name",
|
||||
"Name",
|
||||
"The name of the party the call is connected to, if the network provides it",
|
||||
NULL,
|
||||
G_PARAM_READABLE));
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_interface_install_property (
|
||||
iface,
|
||||
properties[PROP_STATE] =
|
||||
g_param_spec_enum ("state",
|
||||
"State",
|
||||
"The current state of the call",
|
||||
CALLS_TYPE_CALL_STATE,
|
||||
CALLS_CALL_STATE_ACTIVE,
|
||||
G_PARAM_READABLE));
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
|
||||
/**
|
||||
* CallsCall::state-changed:
|
||||
|
@ -160,22 +201,19 @@ calls_call_default_init (CallsCallInterface *iface)
|
|||
* This signal is emitted when the state of the call changes, for
|
||||
* example when it's answered or when the call is disconnected.
|
||||
*/
|
||||
signals[SIGNAL_STATE_CHANGED] =
|
||||
g_signal_newv ("state-changed",
|
||||
G_TYPE_FROM_INTERFACE (iface),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
NULL, NULL, NULL, NULL,
|
||||
G_TYPE_NONE,
|
||||
2, arg_types);
|
||||
signals[STATE_CHANGED] =
|
||||
g_signal_new ("state-changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0, NULL, NULL, NULL,
|
||||
G_TYPE_NONE,
|
||||
2, CALLS_TYPE_CALL_STATE, CALLS_TYPE_CALL_STATE);
|
||||
}
|
||||
|
||||
|
||||
#define DEFINE_CALL_GETTER(prop,rettype,errval) \
|
||||
CALLS_DEFINE_IFACE_GETTER(call, Call, CALL, prop, rettype, errval)
|
||||
|
||||
#define DEFINE_CALL_FUNC_VOID(function) \
|
||||
CALLS_DEFINE_IFACE_FUNC_VOID(call, Call, CALL, function)
|
||||
|
||||
static void
|
||||
calls_call_init (CallsCall *self)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* calls_call_get_number:
|
||||
|
@ -187,7 +225,13 @@ calls_call_default_init (CallsCallInterface *iface)
|
|||
*
|
||||
* Returns: the number, or NULL
|
||||
*/
|
||||
DEFINE_CALL_GETTER(number, const gchar *, NULL);
|
||||
const char *
|
||||
calls_call_get_number (CallsCall *self)
|
||||
{
|
||||
g_return_val_if_fail (CALLS_IS_CALL (self), NULL);
|
||||
|
||||
return CALLS_CALL_GET_CLASS (self)->get_number (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* calls_call_get_name:
|
||||
|
@ -198,7 +242,13 @@ DEFINE_CALL_GETTER(number, const gchar *, NULL);
|
|||
*
|
||||
* Returns: the number, or NULL
|
||||
*/
|
||||
DEFINE_CALL_GETTER(name, const gchar *, NULL);
|
||||
const char *
|
||||
calls_call_get_name (CallsCall *self)
|
||||
{
|
||||
g_return_val_if_fail (CALLS_IS_CALL (self), NULL);
|
||||
|
||||
return CALLS_CALL_GET_CLASS (self)->get_name (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* calls_call_get_state:
|
||||
|
@ -208,7 +258,13 @@ DEFINE_CALL_GETTER(name, const gchar *, NULL);
|
|||
*
|
||||
* Returns: the state
|
||||
*/
|
||||
DEFINE_CALL_GETTER(state, CallsCallState, ((CallsCallState)0));
|
||||
CallsCallState
|
||||
calls_call_get_state (CallsCall *self)
|
||||
{
|
||||
g_return_val_if_fail (CALLS_IS_CALL (self), 0);
|
||||
|
||||
return CALLS_CALL_GET_CLASS (self)->get_state (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* calls_call_answer:
|
||||
|
@ -217,7 +273,13 @@ DEFINE_CALL_GETTER(state, CallsCallState, ((CallsCallState)0));
|
|||
* If the call is incoming, answer it.
|
||||
*
|
||||
*/
|
||||
DEFINE_CALL_FUNC_VOID(answer);
|
||||
void
|
||||
calls_call_answer (CallsCall *self)
|
||||
{
|
||||
g_return_if_fail (CALLS_IS_CALL (self));
|
||||
|
||||
CALLS_CALL_GET_CLASS (self)->answer (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* calls_call_hang_up:
|
||||
|
@ -226,7 +288,13 @@ DEFINE_CALL_FUNC_VOID(answer);
|
|||
* Hang up the call.
|
||||
*
|
||||
*/
|
||||
DEFINE_CALL_FUNC_VOID(hang_up);
|
||||
void
|
||||
calls_call_hang_up (CallsCall *self)
|
||||
{
|
||||
g_return_if_fail (CALLS_IS_CALL (self));
|
||||
|
||||
CALLS_CALL_GET_CLASS (self)->hang_up (self);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -237,7 +305,13 @@ DEFINE_CALL_FUNC_VOID(hang_up);
|
|||
*
|
||||
* Returns: TRUE if inbound, FALSE if outbound.
|
||||
*/
|
||||
DEFINE_CALL_GETTER(inbound, gboolean, FALSE);
|
||||
gboolean
|
||||
calls_call_get_inbound (CallsCall *self)
|
||||
{
|
||||
g_return_val_if_fail (CALLS_IS_CALL (self), FALSE);
|
||||
|
||||
return CALLS_CALL_GET_CLASS (self)->get_inbound (self);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
tone_key_is_valid (gchar key)
|
||||
|
@ -265,15 +339,10 @@ void
|
|||
calls_call_tone_start (CallsCall *self,
|
||||
gchar key)
|
||||
{
|
||||
CallsCallInterface *iface;
|
||||
|
||||
g_return_if_fail (CALLS_IS_CALL (self));
|
||||
g_return_if_fail (tone_key_is_valid (key));
|
||||
|
||||
iface = CALLS_CALL_GET_IFACE (self);
|
||||
g_return_if_fail (iface->tone_start != NULL);
|
||||
|
||||
iface->tone_start (self, key);
|
||||
CALLS_CALL_GET_CLASS (self)->tone_start (self, key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -291,13 +360,9 @@ calls_call_tone_start (CallsCall *self,
|
|||
gboolean
|
||||
calls_call_tone_stoppable (CallsCall *self)
|
||||
{
|
||||
CallsCallInterface *iface;
|
||||
|
||||
g_return_val_if_fail (CALLS_IS_CALL (self), FALSE);
|
||||
|
||||
iface = CALLS_CALL_GET_IFACE (self);
|
||||
|
||||
return iface->tone_stop != NULL;
|
||||
return CALLS_CALL_GET_CLASS (self)->tone_stop != calls_call_real_tone_stop;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -313,18 +378,10 @@ void
|
|||
calls_call_tone_stop (CallsCall *self,
|
||||
gchar key)
|
||||
{
|
||||
CallsCallInterface *iface;
|
||||
|
||||
g_return_if_fail (CALLS_IS_CALL (self));
|
||||
g_return_if_fail (tone_key_is_valid (key));
|
||||
|
||||
iface = CALLS_CALL_GET_IFACE (self);
|
||||
if (!iface->tone_stop)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
iface->tone_stop (self, key);
|
||||
CALLS_CALL_GET_CLASS (self)->tone_stop (self, key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -345,3 +402,54 @@ calls_call_get_contact (CallsCall *self)
|
|||
return calls_contacts_provider_lookup_phone_number (contacts_provider,
|
||||
calls_call_get_number (self));
|
||||
}
|
||||
|
||||
void
|
||||
calls_call_state_to_string (GString *string,
|
||||
CallsCallState state)
|
||||
{
|
||||
GEnumClass *klass;
|
||||
GEnumValue *value;
|
||||
|
||||
klass = g_type_class_ref (CALLS_TYPE_CALL_STATE);
|
||||
|
||||
value = g_enum_get_value (klass, (gint)state);
|
||||
if (!value)
|
||||
{
|
||||
return g_string_printf (string,
|
||||
"Unknown call state (%d)",
|
||||
(gint)state);
|
||||
}
|
||||
|
||||
g_string_assign (string, value->value_nick);
|
||||
string->str[0] = g_ascii_toupper (string->str[0]);
|
||||
|
||||
g_type_class_unref (klass);
|
||||
}
|
||||
|
||||
gboolean
|
||||
calls_call_state_parse_nick (CallsCallState *state,
|
||||
const char *nick)
|
||||
{
|
||||
GEnumClass *klass;
|
||||
GEnumValue *value;
|
||||
gboolean ret;
|
||||
|
||||
g_return_val_if_fail (state != NULL, FALSE);
|
||||
g_return_val_if_fail (nick != NULL, FALSE);
|
||||
|
||||
klass = g_type_class_ref (CALLS_TYPE_CALL_STATE);
|
||||
value = g_enum_get_value_by_nick (klass, nick);
|
||||
|
||||
if (value)
|
||||
{
|
||||
*state = (CallsCallState) value->value;
|
||||
ret = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = FALSE;
|
||||
}
|
||||
|
||||
g_type_class_unref (klass);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ G_BEGIN_DECLS
|
|||
|
||||
#define CALLS_TYPE_CALL (calls_call_get_type ())
|
||||
|
||||
G_DECLARE_INTERFACE (CallsCall, calls_call, CALLS, CALL, GObject);
|
||||
G_DECLARE_DERIVABLE_TYPE (CallsCall, calls_call, CALLS, CALL, GObject)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -46,26 +46,24 @@ typedef enum
|
|||
CALLS_CALL_STATE_DISCONNECTED
|
||||
} CallsCallState;
|
||||
|
||||
void calls_call_state_to_string (GString *string,
|
||||
CallsCallState state);
|
||||
gboolean calls_call_state_parse_nick (CallsCallState *state,
|
||||
const gchar *nick);
|
||||
|
||||
struct _CallsCallInterface
|
||||
struct _CallsCallClass
|
||||
{
|
||||
GTypeInterface parent_iface;
|
||||
GObjectClass parent_iface;
|
||||
|
||||
void (*answer) (CallsCall *self);
|
||||
void (*hang_up) (CallsCall *self);
|
||||
void (*tone_start) (CallsCall *self,
|
||||
gchar key);
|
||||
void (*tone_stop) (CallsCall *self,
|
||||
gchar key);
|
||||
const char *(*get_number) (CallsCall *self);
|
||||
const char *(*get_name) (CallsCall *self);
|
||||
CallsCallState (*get_state) (CallsCall *self);
|
||||
gboolean (*get_inbound) (CallsCall *self);
|
||||
void (*answer) (CallsCall *self);
|
||||
void (*hang_up) (CallsCall *self);
|
||||
void (*tone_start) (CallsCall *self,
|
||||
char key);
|
||||
void (*tone_stop) (CallsCall *self,
|
||||
char key);
|
||||
};
|
||||
|
||||
|
||||
const gchar * calls_call_get_number (CallsCall *self);
|
||||
const gchar * calls_call_get_name (CallsCall *self);
|
||||
const char *calls_call_get_number (CallsCall *self);
|
||||
const char *calls_call_get_name (CallsCall *self);
|
||||
CallsCallState calls_call_get_state (CallsCall *self);
|
||||
gboolean calls_call_get_inbound (CallsCall *self);
|
||||
void calls_call_answer (CallsCall *self);
|
||||
|
@ -77,6 +75,11 @@ void calls_call_tone_stop (CallsCall *self,
|
|||
gchar key);
|
||||
CallsBestMatch * calls_call_get_contact (CallsCall *self);
|
||||
|
||||
void calls_call_state_to_string (GString *string,
|
||||
CallsCallState state);
|
||||
gboolean calls_call_state_parse_nick (CallsCallState *state,
|
||||
const char *nick);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in a new issue