mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2024-11-16 15:06:05 +00:00
origin: Add API to query supported protocols
This will allow selecting a suitable origin when placing outgoing calls.
This commit is contained in:
parent
7ad0f4cdd6
commit
0c966fdf83
6 changed files with 82 additions and 0 deletions
|
@ -153,6 +153,17 @@ dial (CallsOrigin *origin, const gchar *number)
|
|||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
supports_protocol (CallsOrigin *origin,
|
||||
const char *protocol)
|
||||
{
|
||||
g_assert (protocol != NULL);
|
||||
g_assert (CALLS_IS_DUMMY_ORIGIN (origin));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
CallsDummyOrigin *
|
||||
calls_dummy_origin_new (const gchar *name)
|
||||
{
|
||||
|
@ -273,6 +284,7 @@ static void
|
|||
calls_dummy_origin_origin_interface_init (CallsOriginInterface *iface)
|
||||
{
|
||||
iface->dial = dial;
|
||||
iface->supports_protocol = supports_protocol;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -341,6 +341,17 @@ dial (CallsOrigin *origin, const gchar *number)
|
|||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
supports_protocol (CallsOrigin *origin,
|
||||
const char *protocol)
|
||||
{
|
||||
g_assert (protocol);
|
||||
g_assert (CALLS_IS_MM_ORIGIN (origin));
|
||||
|
||||
return g_strcmp0 (protocol, "tel") == 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
remove_calls (CallsMMOrigin *self, const gchar *reason)
|
||||
{
|
||||
|
@ -897,6 +908,7 @@ static void
|
|||
calls_mm_origin_origin_interface_init (CallsOriginInterface *iface)
|
||||
{
|
||||
iface->dial = dial;
|
||||
iface->supports_protocol = supports_protocol;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -101,6 +101,16 @@ dial (CallsOrigin *origin, const gchar *number)
|
|||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
supports_protocol (CallsOrigin *origin,
|
||||
const char *protocol)
|
||||
{
|
||||
g_assert (protocol);
|
||||
g_assert (CALLS_IS_OFONO_ORIGIN (origin));
|
||||
|
||||
return g_strcmp0 (protocol, "tel") == 0;
|
||||
}
|
||||
|
||||
CallsOfonoOrigin *
|
||||
calls_ofono_origin_new (GDBOModem *modem)
|
||||
{
|
||||
|
@ -576,6 +586,7 @@ static void
|
|||
calls_ofono_origin_origin_interface_init (CallsOriginInterface *iface)
|
||||
{
|
||||
iface->dial = dial;
|
||||
iface->supports_protocol = supports_protocol;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -994,6 +994,26 @@ init_sip_account (CallsSipOrigin *self,
|
|||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
supports_protocol (CallsOrigin *origin,
|
||||
const char *protocol)
|
||||
{
|
||||
CallsSipOrigin *self;
|
||||
g_assert (protocol);
|
||||
g_assert (CALLS_IS_SIP_ORIGIN (origin));
|
||||
|
||||
self = CALLS_SIP_ORIGIN (origin);
|
||||
|
||||
if (g_strcmp0 (protocol, "sip") == 0)
|
||||
return TRUE;
|
||||
if (g_strcmp0 (protocol, "sips") == 0)
|
||||
return g_strcmp0 (self->protocol_prefix, "sips") == 0;
|
||||
|
||||
/* TODO need to set a property (from the UI) to allow using origin for telephony */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_sip_origin_set_property (GObject *object,
|
||||
guint property_id,
|
||||
|
@ -1204,6 +1224,7 @@ static void
|
|||
calls_sip_origin_origin_interface_init (CallsOriginInterface *iface)
|
||||
{
|
||||
iface->dial = dial;
|
||||
iface->supports_protocol = supports_protocol;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -162,3 +162,25 @@ calls_origin_dial(CallsOrigin *self,
|
|||
|
||||
return iface->dial(self, number);
|
||||
}
|
||||
|
||||
/**
|
||||
* calls_origin_supports_protocol:
|
||||
* @self: A #CallsOrigin
|
||||
* @protocol: The protocol to check support for
|
||||
*
|
||||
* Returns: %TRUE if the origin supports the protocol, %FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
calls_origin_supports_protocol (CallsOrigin *self,
|
||||
const char *protocol)
|
||||
{
|
||||
CallsOriginInterface *iface;
|
||||
|
||||
g_return_val_if_fail (CALLS_IS_ORIGIN (self), FALSE);
|
||||
g_return_val_if_fail (protocol != NULL, FALSE);
|
||||
|
||||
iface = CALLS_ORIGIN_GET_IFACE (self);
|
||||
g_return_val_if_fail (iface->supports_protocol != NULL, FALSE);
|
||||
|
||||
return iface->supports_protocol (self, protocol);
|
||||
}
|
||||
|
|
|
@ -44,6 +44,8 @@ struct _CallsOriginInterface
|
|||
|
||||
void (*dial) (CallsOrigin *self,
|
||||
const char *number);
|
||||
gboolean (*supports_protocol) (CallsOrigin *self,
|
||||
const char *protocol);
|
||||
};
|
||||
|
||||
typedef void (*CallsOriginForeachCallFunc) (gpointer param, CallsCall* call, CallsOrigin* origin);
|
||||
|
@ -55,6 +57,8 @@ void calls_origin_foreach_call (CallsOrigin *self,
|
|||
gpointer param);
|
||||
void calls_origin_dial (CallsOrigin *self,
|
||||
const char *number);
|
||||
gboolean calls_origin_supports_protocol (CallsOrigin *self,
|
||||
const char *protocol);
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* CALLS_ORIGIN_H__ */
|
||||
|
|
Loading…
Reference in a new issue