mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2024-11-19 01:51:46 +00:00
sip: Initial provider
based on dummy provider
This commit is contained in:
parent
a32f6e4dc4
commit
71e7a33626
11 changed files with 898 additions and 0 deletions
2
debian/control
vendored
2
debian/control
vendored
|
@ -11,8 +11,10 @@ Build-Depends:
|
||||||
libcallaudio-dev (>= 0.0.5),
|
libcallaudio-dev (>= 0.0.5),
|
||||||
libfeedback-dev,
|
libfeedback-dev,
|
||||||
libhandy-1-dev (>= 1.0.0),
|
libhandy-1-dev (>= 1.0.0),
|
||||||
|
libgstreamer1.0-dev,
|
||||||
libgtk-3-dev,
|
libgtk-3-dev,
|
||||||
libgtk-3-doc <!nodoc>,
|
libgtk-3-doc <!nodoc>,
|
||||||
|
libsofia-sip-ua-glib-dev,
|
||||||
modemmanager-dev,
|
modemmanager-dev,
|
||||||
libmm-glib-dev (>= 1.12.0),
|
libmm-glib-dev (>= 1.12.0),
|
||||||
libpeas-dev,
|
libpeas-dev,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
subdir('mm')
|
subdir('mm')
|
||||||
subdir('dummy')
|
subdir('dummy')
|
||||||
subdir('ofono')
|
subdir('ofono')
|
||||||
|
subdir('sip')
|
||||||
|
|
251
plugins/sip/calls-sip-call.c
Normal file
251
plugins/sip/calls-sip-call.c
Normal file
|
@ -0,0 +1,251 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2021 Purism SPC
|
||||||
|
*
|
||||||
|
* This file is part of Calls.
|
||||||
|
*
|
||||||
|
* Calls is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Calls is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Calls. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Author: Evangelos Ribeiro Tzaras <evangelos.tzaras@puri.sm>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "calls-sip-call.h"
|
||||||
|
|
||||||
|
#include "calls-message-source.h"
|
||||||
|
#include "calls-call.h"
|
||||||
|
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
|
|
||||||
|
struct _CallsSipCall
|
||||||
|
{
|
||||||
|
GObject parent_instance;
|
||||||
|
gchar *number;
|
||||||
|
gboolean inbound;
|
||||||
|
CallsCallState state;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void calls_sip_call_message_source_interface_init (CallsCallInterface *iface);
|
||||||
|
static void calls_sip_call_call_interface_init (CallsCallInterface *iface);
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_CODE (CallsSipCall, calls_sip_call, G_TYPE_OBJECT,
|
||||||
|
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))
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_CALL_NUMBER,
|
||||||
|
PROP_CALL_INBOUND,
|
||||||
|
PROP_CALL_STATE,
|
||||||
|
PROP_CALL_NAME,
|
||||||
|
PROP_LAST_PROP
|
||||||
|
};
|
||||||
|
static GParamSpec *props[PROP_LAST_PROP];
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
change_state (CallsSipCall *self,
|
||||||
|
CallsCallState state)
|
||||||
|
{
|
||||||
|
CallsCallState old_state;
|
||||||
|
|
||||||
|
g_assert (CALLS_IS_CALL (self));
|
||||||
|
g_assert (CALLS_IS_SIP_CALL (self));
|
||||||
|
|
||||||
|
old_state = self->state;
|
||||||
|
|
||||||
|
if (old_state == state)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self->state = state;
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CALL_STATE]);
|
||||||
|
g_signal_emit_by_name (CALLS_CALL (self),
|
||||||
|
"state-changed",
|
||||||
|
state,
|
||||||
|
old_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
answer (CallsCall *call)
|
||||||
|
{
|
||||||
|
CallsSipCall *self;
|
||||||
|
|
||||||
|
g_assert (CALLS_IS_CALL (call));
|
||||||
|
g_assert (CALLS_IS_SIP_CALL (call));
|
||||||
|
|
||||||
|
self = CALLS_SIP_CALL (call);
|
||||||
|
|
||||||
|
if (self->state != CALLS_CALL_STATE_INCOMING) {
|
||||||
|
g_warning ("Call must be in 'incoming' state in order to answer");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
change_state (self, CALLS_CALL_STATE_ACTIVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
hang_up (CallsCall *call)
|
||||||
|
{
|
||||||
|
CallsSipCall *self;
|
||||||
|
|
||||||
|
g_assert (CALLS_IS_CALL (call));
|
||||||
|
g_assert (CALLS_IS_SIP_CALL (call));
|
||||||
|
|
||||||
|
self = CALLS_SIP_CALL (call);
|
||||||
|
|
||||||
|
change_state (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 void
|
||||||
|
calls_sip_call_set_property (GObject *object,
|
||||||
|
guint property_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
CallsSipCall *self = CALLS_SIP_CALL (object);
|
||||||
|
|
||||||
|
switch (property_id) {
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
calls_sip_call_get_property (GObject *object,
|
||||||
|
guint property_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
calls_sip_call_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
CallsSipCall *self = CALLS_SIP_CALL (object);
|
||||||
|
|
||||||
|
g_free (self->number);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (calls_sip_call_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
calls_sip_call_class_init (CallsSipCallClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_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;
|
||||||
|
|
||||||
|
#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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
calls_sip_call_init (CallsSipCall *self)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CallsSipCall *
|
||||||
|
calls_sip_call_new (const gchar *number,
|
||||||
|
gboolean inbound)
|
||||||
|
{
|
||||||
|
CallsSipCall *call;
|
||||||
|
|
||||||
|
g_return_val_if_fail (number != NULL, NULL);
|
||||||
|
|
||||||
|
call = g_object_new (CALLS_TYPE_SIP_CALL, NULL);
|
||||||
|
|
||||||
|
call->number = g_strdup (number);
|
||||||
|
call->inbound = inbound;
|
||||||
|
|
||||||
|
if (inbound)
|
||||||
|
call->state = CALLS_CALL_STATE_INCOMING;
|
||||||
|
else
|
||||||
|
call->state = CALLS_CALL_STATE_DIALING;
|
||||||
|
|
||||||
|
return call;
|
||||||
|
}
|
38
plugins/sip/calls-sip-call.h
Normal file
38
plugins/sip/calls-sip-call.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2021 Purism SPC
|
||||||
|
*
|
||||||
|
* This file is part of Calls.
|
||||||
|
*
|
||||||
|
* Calls is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Calls is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Calls. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Author: Evangelos Ribeiro Tzaras <evangelos.tzaras@puri.sm>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
CallsSipCall *calls_sip_call_new (const gchar *number,
|
||||||
|
gboolean inbound);
|
||||||
|
|
||||||
|
G_END_DECLS
|
283
plugins/sip/calls-sip-origin.c
Normal file
283
plugins/sip/calls-sip-origin.c
Normal file
|
@ -0,0 +1,283 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2021 Purism SPC
|
||||||
|
*
|
||||||
|
* This file is part of Calls.
|
||||||
|
*
|
||||||
|
* Calls is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Calls is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Calls. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Author: Evangelos Ribeiro Tzaras <evangelos.tzaras@puri.sm>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "calls-sip-origin.h"
|
||||||
|
|
||||||
|
#include "calls-message-source.h"
|
||||||
|
#include "calls-origin.h"
|
||||||
|
#include "calls-sip-call.h"
|
||||||
|
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
|
||||||
|
struct _CallsSipOrigin
|
||||||
|
{
|
||||||
|
GObject parent_instance;
|
||||||
|
GString *name;
|
||||||
|
GList *calls;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void calls_sip_origin_message_source_interface_init (CallsOriginInterface *iface);
|
||||||
|
static void calls_sip_origin_origin_interface_init (CallsOriginInterface *iface);
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_CODE (CallsSipOrigin, calls_sip_origin, G_TYPE_OBJECT,
|
||||||
|
G_IMPLEMENT_INTERFACE (CALLS_TYPE_MESSAGE_SOURCE,
|
||||||
|
calls_sip_origin_message_source_interface_init)
|
||||||
|
G_IMPLEMENT_INTERFACE (CALLS_TYPE_ORIGIN,
|
||||||
|
calls_sip_origin_origin_interface_init))
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_NAME,
|
||||||
|
PROP_CALLS,
|
||||||
|
PROP_LAST_PROP,
|
||||||
|
};
|
||||||
|
static GParamSpec *props[PROP_LAST_PROP];
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
remove_call (CallsSipOrigin *self,
|
||||||
|
CallsCall *call,
|
||||||
|
const gchar *reason)
|
||||||
|
{
|
||||||
|
CallsOrigin *origin;
|
||||||
|
|
||||||
|
origin = CALLS_ORIGIN (self);
|
||||||
|
self->calls = g_list_remove (self->calls, call);
|
||||||
|
|
||||||
|
g_signal_emit_by_name (origin, "call-removed", call, reason);
|
||||||
|
|
||||||
|
g_object_unref (G_OBJECT (call));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
remove_calls (CallsSipOrigin *self, const gchar *reason)
|
||||||
|
{
|
||||||
|
gpointer call;
|
||||||
|
GList *next;
|
||||||
|
|
||||||
|
while (self->calls != NULL) {
|
||||||
|
call = self->calls->data;
|
||||||
|
next = self->calls->next;
|
||||||
|
g_list_free_1 (self->calls);
|
||||||
|
self->calls = next;
|
||||||
|
|
||||||
|
g_signal_emit_by_name (self, "call-removed", call, reason);
|
||||||
|
g_object_unref (call);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct DisconnectedData
|
||||||
|
{
|
||||||
|
CallsSipOrigin *self;
|
||||||
|
CallsCall *call;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_call_state_changed_cb (CallsSipOrigin *self,
|
||||||
|
CallsCallState new_state,
|
||||||
|
CallsCallState old_state,
|
||||||
|
CallsCall *call)
|
||||||
|
{
|
||||||
|
if (new_state != CALLS_CALL_STATE_DISCONNECTED)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_assert (CALLS_IS_SIP_ORIGIN (self));
|
||||||
|
g_assert (CALLS_IS_CALL (call));
|
||||||
|
|
||||||
|
remove_call (self, call, "Disconnected");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_call (CallsSipOrigin *self,
|
||||||
|
const gchar *address,
|
||||||
|
gboolean inbound)
|
||||||
|
{
|
||||||
|
CallsSipCall *sip_call;
|
||||||
|
CallsCall *call;
|
||||||
|
|
||||||
|
sip_call = calls_sip_call_new (address, inbound);
|
||||||
|
g_assert (sip_call != NULL);
|
||||||
|
|
||||||
|
call = CALLS_CALL (sip_call);
|
||||||
|
g_signal_connect_swapped (call, "state-changed",
|
||||||
|
G_CALLBACK (on_call_state_changed_cb),
|
||||||
|
self);
|
||||||
|
|
||||||
|
self->calls = g_list_append (self->calls, sip_call);
|
||||||
|
|
||||||
|
g_signal_emit_by_name (CALLS_ORIGIN (self), "call-added", call);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
dial (CallsOrigin *origin,
|
||||||
|
const gchar *address)
|
||||||
|
{
|
||||||
|
g_assert (CALLS_ORIGIN (origin));
|
||||||
|
g_assert (CALLS_IS_SIP_ORIGIN (origin));
|
||||||
|
|
||||||
|
if (address == NULL) {
|
||||||
|
g_warning ("Tried dialing on origin '%s' without an address",
|
||||||
|
calls_origin_get_name (origin));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_call (CALLS_SIP_ORIGIN (origin), address, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
calls_sip_origin_set_property (GObject *object,
|
||||||
|
guint property_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
CallsSipOrigin *self = CALLS_SIP_ORIGIN (object);
|
||||||
|
|
||||||
|
switch (property_id) {
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
calls_sip_origin_get_property (GObject *object,
|
||||||
|
guint property_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
CallsSipOrigin *self = CALLS_SIP_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
|
||||||
|
calls_sip_origin_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
CallsSipOrigin *self = CALLS_SIP_ORIGIN (object);
|
||||||
|
|
||||||
|
remove_calls (self, NULL);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (calls_sip_origin_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
calls_sip_origin_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
CallsSipOrigin *self = CALLS_SIP_ORIGIN (object);
|
||||||
|
|
||||||
|
g_string_free (self->name, TRUE);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (calls_sip_origin_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
calls_sip_origin_class_init (CallsSipOriginClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->dispose = calls_sip_origin_dispose;
|
||||||
|
object_class->finalize = calls_sip_origin_finalize;
|
||||||
|
object_class->get_property = calls_sip_origin_get_property;
|
||||||
|
object_class->set_property = calls_sip_origin_set_property;
|
||||||
|
|
||||||
|
#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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
calls_sip_origin_message_source_interface_init (CallsOriginInterface *iface)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
calls_sip_origin_origin_interface_init (CallsOriginInterface *iface)
|
||||||
|
{
|
||||||
|
iface->dial = dial;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
calls_sip_origin_init (CallsSipOrigin *self)
|
||||||
|
{
|
||||||
|
self->name = g_string_new (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
calls_sip_origin_create_inbound (CallsSipOrigin *self,
|
||||||
|
const gchar *address)
|
||||||
|
{
|
||||||
|
g_return_if_fail (address != NULL);
|
||||||
|
g_return_if_fail (CALLS_IS_SIP_ORIGIN (self));
|
||||||
|
|
||||||
|
add_call (self, address, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CallsSipOrigin *
|
||||||
|
calls_sip_origin_new (const gchar *name)
|
||||||
|
{
|
||||||
|
CallsSipOrigin *origin =
|
||||||
|
g_object_new (CALLS_TYPE_SIP_ORIGIN,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_string_assign (origin->name, name);
|
||||||
|
|
||||||
|
return origin;
|
||||||
|
}
|
39
plugins/sip/calls-sip-origin.h
Normal file
39
plugins/sip/calls-sip-origin.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2021 Purism SPC
|
||||||
|
*
|
||||||
|
* This file is part of Calls.
|
||||||
|
*
|
||||||
|
* Calls is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Calls is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Calls. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Author: Evangelos Ribeiro Tzaras <evangelos.tzaras@puri.sm>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define CALLS_TYPE_SIP_ORIGIN (calls_sip_origin_get_type ())
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE (CallsSipOrigin, calls_sip_origin, CALLS, SIP_ORIGIN, GObject);
|
||||||
|
|
||||||
|
CallsSipOrigin *calls_sip_origin_new (const gchar *name);
|
||||||
|
void calls_sip_origin_create_inbound (CallsSipOrigin *self,
|
||||||
|
const gchar *number);
|
||||||
|
|
||||||
|
G_END_DECLS
|
156
plugins/sip/calls-sip-provider.c
Normal file
156
plugins/sip/calls-sip-provider.c
Normal file
|
@ -0,0 +1,156 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2021 Purism SPC
|
||||||
|
*
|
||||||
|
* This file is part of Calls.
|
||||||
|
*
|
||||||
|
* Calls is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Calls is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Calls. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Author: Evangelos Ribeiro Tzaras <evangelos.tzaras@puri.sm>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "calls-sip-provider.h"
|
||||||
|
|
||||||
|
#include "calls-message-source.h"
|
||||||
|
#include "calls-provider.h"
|
||||||
|
#include "calls-sip-origin.h"
|
||||||
|
|
||||||
|
#include <libpeas/peas.h>
|
||||||
|
|
||||||
|
|
||||||
|
struct _CallsSipProvider
|
||||||
|
{
|
||||||
|
CallsProvider parent_instance;
|
||||||
|
|
||||||
|
GListStore *origins;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void calls_sip_provider_message_source_interface_init (CallsMessageSourceInterface *iface);
|
||||||
|
|
||||||
|
|
||||||
|
G_DEFINE_DYNAMIC_TYPE_EXTENDED
|
||||||
|
(CallsSipProvider, calls_sip_provider, CALLS_TYPE_PROVIDER, 0,
|
||||||
|
G_IMPLEMENT_INTERFACE_DYNAMIC (CALLS_TYPE_MESSAGE_SOURCE,
|
||||||
|
calls_sip_provider_message_source_interface_init))
|
||||||
|
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
calls_sip_provider_get_name (CallsProvider *provider)
|
||||||
|
{
|
||||||
|
return "SIP provider";
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
calls_sip_provider_get_status (CallsProvider *provider)
|
||||||
|
{
|
||||||
|
return "Normal";
|
||||||
|
}
|
||||||
|
|
||||||
|
static GListModel *
|
||||||
|
calls_sip_provider_get_origins (CallsProvider *provider)
|
||||||
|
{
|
||||||
|
CallsSipProvider *self = CALLS_SIP_PROVIDER (provider);
|
||||||
|
|
||||||
|
return G_LIST_MODEL (self->origins);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
calls_sip_provider_constructed (GObject *object)
|
||||||
|
{
|
||||||
|
CallsSipProvider *self = CALLS_SIP_PROVIDER (object);
|
||||||
|
|
||||||
|
calls_sip_provider_add_origin (self, "Sip origin");
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (calls_sip_provider_parent_class)->constructed (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
calls_sip_provider_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
CallsSipProvider *self = CALLS_SIP_PROVIDER (object);
|
||||||
|
|
||||||
|
g_list_store_remove_all (self->origins);
|
||||||
|
g_clear_object (&self->origins);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (calls_sip_provider_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
calls_sip_provider_class_init (CallsSipProviderClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
CallsProviderClass *provider_class = CALLS_PROVIDER_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->constructed = calls_sip_provider_constructed;
|
||||||
|
object_class->dispose = calls_sip_provider_dispose;
|
||||||
|
|
||||||
|
provider_class->get_name = calls_sip_provider_get_name;
|
||||||
|
provider_class->get_status = calls_sip_provider_get_status;
|
||||||
|
provider_class->get_origins = calls_sip_provider_get_origins;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
calls_sip_provider_message_source_interface_init (CallsMessageSourceInterface *iface)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
calls_sip_provider_init (CallsSipProvider *self)
|
||||||
|
{
|
||||||
|
self->origins = g_list_store_new (CALLS_TYPE_SIP_ORIGIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
calls_sip_provider_add_origin (CallsSipProvider *self,
|
||||||
|
const gchar *name)
|
||||||
|
{
|
||||||
|
g_autoptr (CallsSipOrigin) origin = calls_sip_origin_new (name);
|
||||||
|
|
||||||
|
g_list_store_append (self->origins, origin);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CallsSipProvider *
|
||||||
|
calls_sip_provider_new ()
|
||||||
|
{
|
||||||
|
return g_object_new (CALLS_TYPE_SIP_PROVIDER, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef FOR_TESTING
|
||||||
|
|
||||||
|
static void
|
||||||
|
calls_sip_provider_class_finalize (CallsSipProviderClass *klass)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
G_MODULE_EXPORT void
|
||||||
|
peas_register_types (PeasObjectModule *module)
|
||||||
|
{
|
||||||
|
calls_sip_provider_register_type (G_TYPE_MODULE (module));
|
||||||
|
|
||||||
|
peas_object_module_register_extension_type (module,
|
||||||
|
CALLS_TYPE_PROVIDER,
|
||||||
|
CALLS_TYPE_SIP_PROVIDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* FOR_TESTING */
|
41
plugins/sip/calls-sip-provider.h
Normal file
41
plugins/sip/calls-sip-provider.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2021 Purism SPC
|
||||||
|
*
|
||||||
|
* This file is part of Calls.
|
||||||
|
*
|
||||||
|
* Calls is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Calls is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Calls. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Author: Evangelos Ribeiro Tzaras <evangelos.tzaras@puri.sm>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "calls-provider.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define CALLS_TYPE_SIP_PROVIDER (calls_sip_provider_get_type ())
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE (CallsSipProvider, calls_sip_provider, CALLS, SIP_PROVIDER, CallsProvider)
|
||||||
|
|
||||||
|
CallsSipProvider *calls_sip_provider_new ();
|
||||||
|
void calls_sip_provider_add_origin (CallsSipProvider *self,
|
||||||
|
const gchar *name);
|
||||||
|
|
||||||
|
G_END_DECLS
|
58
plugins/sip/meson.build
Normal file
58
plugins/sip/meson.build
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
#
|
||||||
|
# Copyright (C) 2021 Purism SPC
|
||||||
|
#
|
||||||
|
# This file is part of Calls.
|
||||||
|
#
|
||||||
|
# Calls is free software: you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Calls is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with Calls. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# Author: Evangelos Ribeiro Tzaras <evangelos.tzaras@puri.sm>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
#
|
||||||
|
|
||||||
|
sip_include = include_directories('.')
|
||||||
|
|
||||||
|
sip_install_dir = join_paths(full_calls_plugin_libdir, 'sip')
|
||||||
|
|
||||||
|
sip_plugin = configure_file(
|
||||||
|
input: 'sip.plugin.in',
|
||||||
|
output: 'sip.plugin',
|
||||||
|
configuration: config_data,
|
||||||
|
install_dir: sip_install_dir
|
||||||
|
)
|
||||||
|
|
||||||
|
sip_deps = [
|
||||||
|
dependency('gobject-2.0'),
|
||||||
|
dependency('gstreamer-1.0'),
|
||||||
|
dependency('gtk+-3.0'),
|
||||||
|
dependency('libpeas-1.0'),
|
||||||
|
dependency('sofia-sip-ua-glib'),
|
||||||
|
]
|
||||||
|
|
||||||
|
sip_sources = files(
|
||||||
|
[
|
||||||
|
'calls-sip-call.c', 'calls-sip-call.h',
|
||||||
|
'calls-sip-origin.c', 'calls-sip-origin.h',
|
||||||
|
'calls-sip-provider.c', 'calls-sip-provider.h'
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
shared_module(
|
||||||
|
'sip',
|
||||||
|
sip_sources,
|
||||||
|
dependencies: sip_deps,
|
||||||
|
include_directories: src_include,
|
||||||
|
install: true,
|
||||||
|
install_dir: sip_install_dir
|
||||||
|
)
|
7
plugins/sip/sip.plugin.in
Normal file
7
plugins/sip/sip.plugin.in
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[Plugin]
|
||||||
|
Module=sip
|
||||||
|
Name=SIP
|
||||||
|
Description=SIP calls provider
|
||||||
|
Authors=Evangelos Ribeiro Tzaras <evangelos.tzaras@puri.sm>
|
||||||
|
Copyright=Copyright (C) 2021 Purism SPC
|
||||||
|
Website=@PACKAGE_URL_RAW@
|
|
@ -272,6 +272,28 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name" : "gstreamer",
|
||||||
|
"buildsystem" : "meson",
|
||||||
|
"sources" : [
|
||||||
|
{
|
||||||
|
"type" : "archive",
|
||||||
|
"url" : "https://gitlab.freedesktop.org/gstreamer/gstreamer/-/archive/1.18.3/gstreamer-1.18.3.tar.gz",
|
||||||
|
"sha256" : "d7e3917b5d3d9c3bd9bb70b7500314a5725377cff39bcd818df13c1fda0f60ba"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "sofia-sip",
|
||||||
|
"buildsystem" : "autotools",
|
||||||
|
"sources" : [
|
||||||
|
{
|
||||||
|
"type" : "archive",
|
||||||
|
"url" : "https://github.com/freeswitch/sofia-sip/archive/v1.13.2.tar.gz",
|
||||||
|
"sha256" : "b9eca9688ce4b28e062daf0933c3bf661fb607e7afafa71bda3e8f07eb88df44"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name" : "calls",
|
"name" : "calls",
|
||||||
"buildsystem" : "meson",
|
"buildsystem" : "meson",
|
||||||
|
|
Loading…
Reference in a new issue