Turn providers into plugins courtesy of libpeas
This is an initial, static implementation of plugins. The CallsApplication has a plugin name which can be changed with a new --provider command line option. This plugin name is used to instantiate the appropriate plugin when the application is activated. From then on, the plugin cannot change. In future, we can expand this support to include loading multiple plugins at once, configurable through some UI. This will have far-reaching implications though, and complicate things like enumerating the provider hierarchy. There is also no practical benefit right now; the mm and ofono plugins can't be used at the same time because ModemManager and oFono don't play nice together, and the whole raison d'être of the dummy plugin is undermined if you can make use of one of the others. So for now, we just implement one static plugin.
This commit is contained in:
219
plugins/dummy/calls-dummy-call.c
Normal file
219
plugins/dummy/calls-dummy-call.c
Normal file
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#include "calls-dummy-call.h"
|
||||
#include "calls-message-source.h"
|
||||
#include "calls-call.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
|
||||
struct _CallsDummyCall
|
||||
{
|
||||
GObject parent_instance;
|
||||
gchar *number;
|
||||
CallsCallState state;
|
||||
};
|
||||
|
||||
static void calls_dummy_call_message_source_interface_init (CallsCallInterface *iface);
|
||||
static void calls_dummy_call_call_interface_init (CallsCallInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (CallsDummyCall, calls_dummy_call, G_TYPE_OBJECT,
|
||||
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))
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_NUMBER,
|
||||
PROP_LAST_PROP,
|
||||
};
|
||||
static GParamSpec *props[PROP_LAST_PROP];
|
||||
|
||||
static const gchar *
|
||||
get_number (CallsCall *iface)
|
||||
{
|
||||
CallsDummyCall *self;
|
||||
|
||||
g_return_val_if_fail (CALLS_IS_DUMMY_CALL (iface), NULL);
|
||||
self = CALLS_DUMMY_CALL (iface);
|
||||
|
||||
return self->number;
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
get_name (CallsCall *iface)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static CallsCallState
|
||||
get_state (CallsCall *call)
|
||||
{
|
||||
CallsDummyCall *self;
|
||||
|
||||
g_return_val_if_fail (CALLS_IS_DUMMY_CALL (call), 0);
|
||||
self = CALLS_DUMMY_CALL (call);
|
||||
|
||||
return self->state;
|
||||
}
|
||||
|
||||
static void
|
||||
change_state (CallsCall *call,
|
||||
CallsDummyCall *self,
|
||||
CallsCallState state)
|
||||
{
|
||||
CallsCallState old_state = self->state;
|
||||
|
||||
if (old_state == state)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
self->state = state;
|
||||
g_signal_emit_by_name (call,
|
||||
"state-changed",
|
||||
state,
|
||||
old_state);
|
||||
}
|
||||
|
||||
static void
|
||||
answer (CallsCall *call)
|
||||
{
|
||||
CallsDummyCall *self;
|
||||
|
||||
g_return_if_fail (CALLS_IS_DUMMY_CALL (call));
|
||||
self = CALLS_DUMMY_CALL (call);
|
||||
|
||||
g_return_if_fail (self->state == CALLS_CALL_STATE_INCOMING);
|
||||
|
||||
change_state (call, self, CALLS_CALL_STATE_ACTIVE);
|
||||
}
|
||||
|
||||
static void
|
||||
hang_up (CallsCall *call)
|
||||
{
|
||||
CallsDummyCall *self;
|
||||
|
||||
g_return_if_fail (CALLS_IS_DUMMY_CALL (call));
|
||||
self = CALLS_DUMMY_CALL (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);
|
||||
}
|
||||
|
||||
CallsDummyCall *
|
||||
calls_dummy_call_new (const gchar *number)
|
||||
{
|
||||
g_return_val_if_fail (number != NULL, NULL);
|
||||
|
||||
return g_object_new (CALLS_TYPE_DUMMY_CALL,
|
||||
"number", number,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
CallsDummyCall *self = CALLS_DUMMY_CALL (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_NUMBER:
|
||||
self->number = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsDummyCall *self = CALLS_DUMMY_CALL (object);
|
||||
|
||||
g_free (self->number);
|
||||
|
||||
parent_class->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_dummy_call_class_init (CallsDummyCallClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = finalize;
|
||||
object_class->set_property = set_property;
|
||||
|
||||
props[PROP_NUMBER] =
|
||||
g_param_spec_string ("number",
|
||||
_("Number"),
|
||||
_("The dialed number"),
|
||||
"+441234567890",
|
||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
||||
}
|
||||
|
||||
static void
|
||||
calls_dummy_call_call_interface_init (CallsCallInterface *iface)
|
||||
{
|
||||
iface->get_number = get_number;
|
||||
iface->get_name = get_name;
|
||||
iface->get_state = get_state;
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_dummy_call_init (CallsDummyCall *self)
|
||||
{
|
||||
}
|
||||
40
plugins/dummy/calls-dummy-call.h
Normal file
40
plugins/dummy/calls-dummy-call.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CALLS_DUMMY_CALL_H__
|
||||
#define CALLS_DUMMY_CALL_H__
|
||||
|
||||
#include <glib-object.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);
|
||||
|
||||
CallsDummyCall *calls_dummy_call_new (const gchar *number);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* CALLS_DUMMY_CALL_H__ */
|
||||
247
plugins/dummy/calls-dummy-origin.c
Normal file
247
plugins/dummy/calls-dummy-origin.c
Normal file
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#include "calls-dummy-origin.h"
|
||||
#include "calls-message-source.h"
|
||||
#include "calls-origin.h"
|
||||
#include "calls-dummy-call.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
|
||||
struct _CallsDummyOrigin
|
||||
{
|
||||
GObject parent_instance;
|
||||
GString *name;
|
||||
GList *calls;
|
||||
};
|
||||
|
||||
static void calls_dummy_origin_message_source_interface_init (CallsOriginInterface *iface);
|
||||
static void calls_dummy_origin_origin_interface_init (CallsOriginInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (CallsDummyOrigin, calls_dummy_origin, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (CALLS_TYPE_MESSAGE_SOURCE,
|
||||
calls_dummy_origin_message_source_interface_init)
|
||||
G_IMPLEMENT_INTERFACE (CALLS_TYPE_ORIGIN,
|
||||
calls_dummy_origin_origin_interface_init))
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_NAME,
|
||||
PROP_LAST_PROP,
|
||||
};
|
||||
static GParamSpec *props[PROP_LAST_PROP];
|
||||
|
||||
|
||||
static const gchar *
|
||||
get_name (CallsOrigin *origin)
|
||||
{
|
||||
CallsDummyOrigin *self;
|
||||
|
||||
g_return_val_if_fail (CALLS_IS_DUMMY_ORIGIN (origin), NULL);
|
||||
self = CALLS_DUMMY_ORIGIN (origin);
|
||||
|
||||
return self->name->str;
|
||||
}
|
||||
|
||||
|
||||
static GList *
|
||||
get_calls (CallsOrigin *origin)
|
||||
{
|
||||
CallsDummyOrigin *self;
|
||||
|
||||
g_return_val_if_fail (CALLS_IS_DUMMY_ORIGIN (origin), NULL);
|
||||
self = CALLS_DUMMY_ORIGIN (origin);
|
||||
|
||||
return g_list_copy (self->calls);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
remove_call (CallsDummyOrigin *self,
|
||||
CallsCall *call,
|
||||
const gchar *reason)
|
||||
{
|
||||
CallsOrigin *origin;
|
||||
|
||||
origin = CALLS_ORIGIN (self);
|
||||
g_signal_emit_by_name (origin, "call-removed", call, reason);
|
||||
|
||||
self->calls = g_list_remove (self->calls, call);
|
||||
g_object_unref (G_OBJECT (call));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
remove_calls (CallsDummyOrigin *self, const gchar *reason)
|
||||
{
|
||||
GList *node, *next;
|
||||
|
||||
for (node = self->calls; node; node = next)
|
||||
{
|
||||
next = node->next;
|
||||
|
||||
remove_call (self, CALLS_CALL (node->data), reason);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
call_state_changed_cb (CallsDummyOrigin *self,
|
||||
CallsCallState new_state,
|
||||
CallsCallState old_state,
|
||||
CallsCall *call)
|
||||
{
|
||||
if (new_state != CALLS_CALL_STATE_DISCONNECTED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_return_if_fail (CALLS_IS_DUMMY_ORIGIN (self));
|
||||
g_return_if_fail (CALLS_IS_CALL (call));
|
||||
|
||||
remove_call (self, call, "Disconnected");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dial (CallsOrigin *origin, const gchar *number)
|
||||
{
|
||||
CallsDummyOrigin *self;
|
||||
CallsDummyCall *dummy_call;
|
||||
CallsCall *call;
|
||||
|
||||
g_return_if_fail (number != NULL);
|
||||
g_return_if_fail (CALLS_IS_DUMMY_ORIGIN (origin));
|
||||
|
||||
self = CALLS_DUMMY_ORIGIN (origin);
|
||||
|
||||
dummy_call = calls_dummy_call_new (number);
|
||||
g_return_if_fail (dummy_call != NULL);
|
||||
|
||||
call = CALLS_CALL (dummy_call);
|
||||
g_signal_connect_swapped (call, "state-changed",
|
||||
G_CALLBACK (call_state_changed_cb),
|
||||
self);
|
||||
|
||||
self->calls = g_list_append (self->calls, dummy_call);
|
||||
|
||||
g_signal_emit_by_name (origin, "call-added", call);
|
||||
}
|
||||
|
||||
|
||||
CallsDummyOrigin *
|
||||
calls_dummy_origin_new (const gchar *name)
|
||||
{
|
||||
return g_object_new (CALLS_TYPE_DUMMY_ORIGIN,
|
||||
"name", name,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
CallsDummyOrigin *self = CALLS_DUMMY_ORIGIN (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_NAME:
|
||||
g_string_assign (self->name, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dispose (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsDummyOrigin *self = CALLS_DUMMY_ORIGIN (object);
|
||||
|
||||
remove_calls (self, NULL);
|
||||
|
||||
parent_class->dispose (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsDummyOrigin *self = CALLS_DUMMY_ORIGIN (object);
|
||||
|
||||
g_string_free (self->name, TRUE);
|
||||
|
||||
parent_class->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_dummy_origin_class_init (CallsDummyOriginClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
object_class->set_property = set_property;
|
||||
|
||||
props[PROP_NAME] =
|
||||
g_param_spec_string ("name",
|
||||
_("Name"),
|
||||
_("The name of the origin"),
|
||||
"Dummy origin",
|
||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_dummy_origin_message_source_interface_init (CallsOriginInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_dummy_origin_origin_interface_init (CallsOriginInterface *iface)
|
||||
{
|
||||
iface->get_name = get_name;
|
||||
iface->get_calls = get_calls;
|
||||
iface->dial = dial;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_dummy_origin_init (CallsDummyOrigin *self)
|
||||
{
|
||||
self->name = g_string_new (NULL);
|
||||
}
|
||||
40
plugins/dummy/calls-dummy-origin.h
Normal file
40
plugins/dummy/calls-dummy-origin.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CALLS_DUMMY_ORIGIN_H__
|
||||
#define CALLS_DUMMY_ORIGIN_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CALLS_TYPE_DUMMY_ORIGIN (calls_dummy_origin_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (CallsDummyOrigin, calls_dummy_origin, CALLS, DUMMY_ORIGIN, GObject);
|
||||
|
||||
CallsDummyOrigin *calls_dummy_origin_new (const gchar *name);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* CALLS_DUMMY_ORIGIN_H__ */
|
||||
195
plugins/dummy/calls-dummy-provider.c
Normal file
195
plugins/dummy/calls-dummy-provider.c
Normal file
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#include "calls-dummy-provider.h"
|
||||
#include "calls-message-source.h"
|
||||
#include "calls-provider.h"
|
||||
#include "calls-dummy-origin.h"
|
||||
|
||||
#include <libpeas/peas.h>
|
||||
|
||||
|
||||
struct _CallsDummyProvider
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GList *origins;
|
||||
};
|
||||
|
||||
static void calls_dummy_provider_message_source_interface_init (CallsProviderInterface *iface);
|
||||
static void calls_dummy_provider_provider_interface_init (CallsProviderInterface *iface);
|
||||
|
||||
|
||||
#ifdef FOR_TESTING
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE
|
||||
(CallsDummyProvider, calls_dummy_provider, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (CALLS_TYPE_MESSAGE_SOURCE,
|
||||
calls_dummy_provider_message_source_interface_init)
|
||||
G_IMPLEMENT_INTERFACE (CALLS_TYPE_PROVIDER,
|
||||
calls_dummy_provider_provider_interface_init))
|
||||
|
||||
#else
|
||||
|
||||
G_DEFINE_DYNAMIC_TYPE_EXTENDED
|
||||
(CallsDummyProvider, calls_dummy_provider, G_TYPE_OBJECT, 0,
|
||||
G_IMPLEMENT_INTERFACE_DYNAMIC (CALLS_TYPE_MESSAGE_SOURCE,
|
||||
calls_dummy_provider_message_source_interface_init)
|
||||
G_IMPLEMENT_INTERFACE_DYNAMIC (CALLS_TYPE_PROVIDER,
|
||||
calls_dummy_provider_provider_interface_init))
|
||||
|
||||
#endif /* FOR_TESTING */
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_STATUS,
|
||||
PROP_LAST_PROP,
|
||||
};
|
||||
|
||||
static const gchar *
|
||||
get_name (CallsProvider *iface)
|
||||
{
|
||||
return "Dummy provider";
|
||||
}
|
||||
|
||||
|
||||
static GList *
|
||||
get_origins (CallsProvider *iface)
|
||||
{
|
||||
CallsDummyProvider *self = CALLS_DUMMY_PROVIDER (iface);
|
||||
return g_list_copy (self->origins);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
constructed (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsDummyProvider *self = CALLS_DUMMY_PROVIDER (object);
|
||||
|
||||
calls_dummy_provider_add_origin (self, "Dummy origin");
|
||||
|
||||
parent_class->constructed (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id) {
|
||||
case PROP_STATUS:
|
||||
g_value_set_string (value, "Normal");
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dispose (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsDummyProvider *self = CALLS_DUMMY_PROVIDER (object);
|
||||
|
||||
g_list_free_full (self->origins, g_object_unref);
|
||||
self->origins = NULL;
|
||||
|
||||
parent_class->dispose (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_dummy_provider_class_init (CallsDummyProviderClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->constructed = constructed;
|
||||
object_class->get_property = get_property;
|
||||
object_class->dispose = dispose;
|
||||
|
||||
g_object_class_override_property (object_class, PROP_STATUS, "status");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_dummy_provider_message_source_interface_init (CallsProviderInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_dummy_provider_provider_interface_init (CallsProviderInterface *iface)
|
||||
{
|
||||
iface->get_name = get_name;
|
||||
iface->get_origins = get_origins;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_dummy_provider_init (CallsDummyProvider *self)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
calls_dummy_provider_add_origin (CallsDummyProvider *self,
|
||||
const gchar *name)
|
||||
{
|
||||
self->origins = g_list_append (self->origins,
|
||||
calls_dummy_origin_new (name));
|
||||
}
|
||||
|
||||
|
||||
CallsDummyProvider *
|
||||
calls_dummy_provider_new ()
|
||||
{
|
||||
return g_object_new (CALLS_TYPE_DUMMY_PROVIDER, NULL);
|
||||
}
|
||||
|
||||
|
||||
#ifndef FOR_TESTING
|
||||
|
||||
static void
|
||||
calls_dummy_provider_class_finalize (CallsDummyProviderClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
G_MODULE_EXPORT void
|
||||
peas_register_types (PeasObjectModule *module)
|
||||
{
|
||||
calls_dummy_provider_register_type (G_TYPE_MODULE (module));
|
||||
|
||||
peas_object_module_register_extension_type (module,
|
||||
CALLS_TYPE_PROVIDER,
|
||||
CALLS_TYPE_DUMMY_PROVIDER);
|
||||
}
|
||||
|
||||
#endif /* FOR_TESTING */
|
||||
42
plugins/dummy/calls-dummy-provider.h
Normal file
42
plugins/dummy/calls-dummy-provider.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CALLS_DUMMY_PROVIDER_H__
|
||||
#define CALLS_DUMMY_PROVIDER_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CALLS_TYPE_DUMMY_PROVIDER (calls_dummy_provider_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (CallsDummyProvider, calls_dummy_provider, CALLS, DUMMY_PROVIDER, GObject);
|
||||
|
||||
CallsDummyProvider *calls_dummy_provider_new ();
|
||||
void calls_dummy_provider_add_origin (CallsDummyProvider *self,
|
||||
const gchar *name);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* CALLS_DUMMY_PROVIDER_H__ */
|
||||
7
plugins/dummy/dummy.plugin.in
Normal file
7
plugins/dummy/dummy.plugin.in
Normal file
@@ -0,0 +1,7 @@
|
||||
[Plugin]
|
||||
Module=dummy
|
||||
Name=Dummy
|
||||
Description=Dummy calls provider
|
||||
Authors=Bob Ham <rah@settrans.net>
|
||||
Copyright=Copyright (C) 2018 Purism SPC
|
||||
Website=@PACKAGE_URL_RAW@
|
||||
56
plugins/dummy/meson.build
Normal file
56
plugins/dummy/meson.build
Normal file
@@ -0,0 +1,56 @@
|
||||
#
|
||||
# Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
|
||||
dummy_include = include_directories('.')
|
||||
|
||||
dummy_install_dir = join_paths(full_calls_plugin_libdir, 'dummy')
|
||||
|
||||
dummy_plugin = configure_file(
|
||||
input: 'dummy.plugin.in',
|
||||
output: 'dummy.plugin',
|
||||
configuration: config_data,
|
||||
install_dir: dummy_install_dir
|
||||
)
|
||||
|
||||
dummy_deps = [
|
||||
dependency('gobject-2.0'),
|
||||
dependency('gtk+-3.0'),
|
||||
dependency('libpeas-1.0'),
|
||||
]
|
||||
|
||||
dummy_sources = files(
|
||||
[
|
||||
'calls-dummy-call.c', 'calls-dummy-call.h',
|
||||
'calls-dummy-origin.c', 'calls-dummy-origin.h',
|
||||
'calls-dummy-provider.c', 'calls-dummy-provider.h'
|
||||
]
|
||||
)
|
||||
|
||||
shared_module(
|
||||
'dummy',
|
||||
dummy_sources,
|
||||
dependencies: dummy_deps,
|
||||
include_directories: src_include,
|
||||
install: true,
|
||||
install_dir: dummy_install_dir
|
||||
)
|
||||
3
plugins/meson.build
Normal file
3
plugins/meson.build
Normal file
@@ -0,0 +1,3 @@
|
||||
subdir('mm')
|
||||
subdir('dummy')
|
||||
subdir('ofono')
|
||||
430
plugins/mm/calls-mm-call.c
Normal file
430
plugins/mm/calls-mm-call.c
Normal file
@@ -0,0 +1,430 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#include "calls-mm-call.h"
|
||||
#include "calls-call.h"
|
||||
#include "calls-message-source.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <libmm-glib/libmm-glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
|
||||
struct _CallsMMCall
|
||||
{
|
||||
GObject parent_instance;
|
||||
MMCall *mm_call;
|
||||
GString *number;
|
||||
CallsCallState state;
|
||||
gchar *disconnect_reason;
|
||||
};
|
||||
|
||||
static void calls_mm_call_message_source_interface_init (CallsCallInterface *iface);
|
||||
static void calls_mm_call_call_interface_init (CallsCallInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (CallsMMCall, calls_mm_call, G_TYPE_OBJECT,
|
||||
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))
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_MM_CALL,
|
||||
PROP_LAST_PROP,
|
||||
};
|
||||
static GParamSpec *props[PROP_LAST_PROP];
|
||||
|
||||
|
||||
static const gchar *
|
||||
get_name (CallsCall *call)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static const gchar *
|
||||
get_number (CallsCall *call)
|
||||
{
|
||||
CallsMMCall *self = CALLS_MM_CALL (call);
|
||||
return self->number->str;
|
||||
}
|
||||
|
||||
|
||||
static CallsCallState
|
||||
get_state (CallsCall *call)
|
||||
{
|
||||
CallsMMCall *self = CALLS_MM_CALL (call);
|
||||
return self->state;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
change_state (CallsMMCall *self,
|
||||
CallsCallState state)
|
||||
{
|
||||
CallsCallState old_state = self->state;
|
||||
|
||||
if (old_state == state)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
self->state = state;
|
||||
g_signal_emit_by_name (CALLS_CALL (self),
|
||||
"state-changed",
|
||||
state,
|
||||
old_state);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
notify_number_cb (CallsMMCall *self,
|
||||
const gchar *number)
|
||||
{
|
||||
g_string_assign (self->number, number);
|
||||
}
|
||||
|
||||
|
||||
struct CallsMMCallStateReasonMap
|
||||
{
|
||||
MMCallStateReason value;
|
||||
const gchar *desc;
|
||||
};
|
||||
|
||||
static const struct CallsMMCallStateReasonMap STATE_REASON_MAP[] = {
|
||||
|
||||
#define row(ENUMVALUE,DESCRIPTION) \
|
||||
{ MM_CALL_STATE_REASON_##ENUMVALUE, DESCRIPTION } \
|
||||
|
||||
row (UNKNOWN, "Outgoing call created"),
|
||||
row (OUTGOING_STARTED, "Outgoing call started"),
|
||||
row (INCOMING_NEW, "Incoming call"),
|
||||
row (ACCEPTED, "Call accepted"),
|
||||
row (TERMINATED, "Call terminated"),
|
||||
row (REFUSED_OR_BUSY, "Busy or call refused"),
|
||||
row (ERROR, "Wrong number or network problem"),
|
||||
|
||||
#undef row
|
||||
|
||||
{ -1, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
set_disconnect_reason (CallsMMCall *self,
|
||||
MMCallStateReason reason)
|
||||
{
|
||||
const struct CallsMMCallStateReasonMap *map_row;
|
||||
GString *reason_str;
|
||||
|
||||
for (map_row = STATE_REASON_MAP; map_row->desc; ++map_row)
|
||||
{
|
||||
if (map_row->value == reason)
|
||||
{
|
||||
self->disconnect_reason = g_strdup(map_row->desc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
reason_str = g_string_new ("Unknown disconnect reason ");
|
||||
g_string_append_printf (reason_str, "(%i)", (int)reason);
|
||||
|
||||
g_warning ("%s", reason_str->str);
|
||||
CALLS_SET_PTR_PROPERTY (self->disconnect_reason,
|
||||
reason_str->str);
|
||||
|
||||
g_string_free (reason_str, FALSE);
|
||||
}
|
||||
|
||||
|
||||
struct CallsMMCallStateMap
|
||||
{
|
||||
MMCallState mm;
|
||||
CallsCallState calls;
|
||||
const gchar *name;
|
||||
};
|
||||
|
||||
static const struct CallsMMCallStateMap STATE_MAP[] = {
|
||||
|
||||
#define row(MMENUM,CALLSENUM) \
|
||||
{ MM_CALL_STATE_##MMENUM, CALLS_CALL_STATE_##CALLSENUM, #MMENUM } \
|
||||
|
||||
row (DIALING, DIALING),
|
||||
row (RINGING_OUT, ALERTING),
|
||||
row (RINGING_IN, INCOMING),
|
||||
row (ACTIVE, ACTIVE),
|
||||
row (HELD, HELD),
|
||||
row (WAITING, INCOMING),
|
||||
row (TERMINATED, DISCONNECTED),
|
||||
|
||||
#undef row
|
||||
|
||||
{ MM_CALL_STATE_UNKNOWN, (CallsCallState)0 },
|
||||
{ -1, -1 }
|
||||
};
|
||||
|
||||
static void
|
||||
state_changed_cb (CallsMMCall *self,
|
||||
MMCallState old,
|
||||
MMCallState mm_new,
|
||||
MMCallStateReason reason)
|
||||
{
|
||||
const struct CallsMMCallStateMap *map_row;
|
||||
|
||||
if (mm_new == MM_CALL_STATE_TERMINATED)
|
||||
{
|
||||
set_disconnect_reason (self, reason);
|
||||
}
|
||||
|
||||
for (map_row = STATE_MAP; map_row->mm != -1; ++map_row)
|
||||
{
|
||||
if (map_row->mm == mm_new)
|
||||
{
|
||||
g_debug ("MM call state changed to `%s'",
|
||||
map_row->name);
|
||||
change_state (self, map_row->calls);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct CallsMMOperationData
|
||||
{
|
||||
const gchar *desc;
|
||||
CallsMMCall *self;
|
||||
gboolean (*finish_func) (MMCall *, GAsyncResult *, GError **);
|
||||
};
|
||||
|
||||
static void
|
||||
operation_cb (MMCall *mm_call,
|
||||
GAsyncResult *res,
|
||||
struct CallsMMOperationData *data)
|
||||
{
|
||||
gboolean ok;
|
||||
GError *error = NULL;
|
||||
|
||||
ok = data->finish_func (mm_call, res, &error);
|
||||
if (!ok)
|
||||
{
|
||||
g_warning ("Error %s ModemManager call to `%s': %s",
|
||||
data->desc, data->self->number->str, error->message);
|
||||
CALLS_ERROR (data->self, error);
|
||||
}
|
||||
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
#define DEFINE_OPERATION(op,name,desc_str) \
|
||||
static void \
|
||||
name (CallsCall *call) \
|
||||
{ \
|
||||
CallsMMCall *self = CALLS_MM_CALL (call); \
|
||||
struct CallsMMOperationData *data; \
|
||||
\
|
||||
data = g_new0 (struct CallsMMOperationData, 1); \
|
||||
data->desc = desc_str; \
|
||||
data->self = self; \
|
||||
data->finish_func = mm_call_##op##_finish; \
|
||||
\
|
||||
mm_call_##op \
|
||||
(self->mm_call, \
|
||||
NULL, \
|
||||
(GAsyncReadyCallback) operation_cb, \
|
||||
data); \
|
||||
}
|
||||
|
||||
DEFINE_OPERATION(accept, answer, "accepting");
|
||||
DEFINE_OPERATION(hangup, hang_up, "hanging up");
|
||||
DEFINE_OPERATION(start, start_call, "starting outgoing call");
|
||||
|
||||
|
||||
static void
|
||||
tone_start (CallsCall *call, gchar key)
|
||||
{
|
||||
CallsMMCall *self = CALLS_MM_CALL (call);
|
||||
struct CallsMMOperationData *data;
|
||||
char key_str[2] = { key, '\0' };
|
||||
|
||||
data = g_new0 (struct CallsMMOperationData, 1);
|
||||
data->desc = "sending DTMF";
|
||||
data->self = self;
|
||||
data->finish_func = mm_call_send_dtmf_finish;
|
||||
|
||||
mm_call_send_dtmf
|
||||
(self->mm_call,
|
||||
key_str,
|
||||
NULL,
|
||||
(GAsyncReadyCallback) operation_cb,
|
||||
data);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
CallsMMCall *self = CALLS_MM_CALL (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_MM_CALL:
|
||||
g_set_object (&self->mm_call,
|
||||
MM_CALL (g_value_get_object (value)));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
constructed (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsMMCall *self = CALLS_MM_CALL (object);
|
||||
MmGdbusCall *gdbus_call = MM_GDBUS_CALL (self->mm_call);
|
||||
MMCallState state;
|
||||
|
||||
g_signal_connect_swapped (gdbus_call, "notify::number",
|
||||
G_CALLBACK (notify_number_cb), self);
|
||||
g_signal_connect_swapped (gdbus_call, "state-changed",
|
||||
G_CALLBACK (state_changed_cb), self);
|
||||
|
||||
notify_number_cb (self, mm_call_get_number (self->mm_call));
|
||||
|
||||
state = mm_call_get_state (self->mm_call);
|
||||
state_changed_cb (self,
|
||||
MM_MODEM_STATE_UNKNOWN,
|
||||
state,
|
||||
mm_call_get_state_reason (self->mm_call));
|
||||
|
||||
/* Start outgoing call */
|
||||
if (state == MM_CALL_STATE_UNKNOWN
|
||||
&& mm_call_get_direction (self->mm_call) == MM_CALL_DIRECTION_OUTGOING)
|
||||
{
|
||||
start_call (CALLS_CALL (self));
|
||||
}
|
||||
|
||||
parent_class->constructed (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dispose (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsMMCall *self = CALLS_MM_CALL (object);
|
||||
|
||||
g_clear_object (&self->mm_call);
|
||||
|
||||
parent_class->dispose (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsMMCall *self = CALLS_MM_CALL (object);
|
||||
|
||||
g_free (self->disconnect_reason);
|
||||
g_string_free (self->number, TRUE);
|
||||
|
||||
parent_class->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_mm_call_class_init (CallsMMCallClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->set_property = set_property;
|
||||
object_class->constructed = constructed;
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
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_properties (object_class, PROP_LAST_PROP, props);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_mm_call_message_source_interface_init (CallsCallInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_mm_call_call_interface_init (CallsCallInterface *iface)
|
||||
{
|
||||
iface->get_number = get_number;
|
||||
iface->get_name = get_name;
|
||||
iface->get_state = get_state;
|
||||
iface->answer = answer;
|
||||
iface->hang_up = hang_up;
|
||||
iface->tone_start = tone_start;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_mm_call_init (CallsMMCall *self)
|
||||
{
|
||||
self->number = g_string_new (NULL);
|
||||
}
|
||||
|
||||
|
||||
CallsMMCall *
|
||||
calls_mm_call_new (MMCall *mm_call)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_CALL (mm_call), NULL);
|
||||
|
||||
return g_object_new (CALLS_TYPE_MM_CALL,
|
||||
"mm-call", mm_call,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
const gchar *
|
||||
calls_mm_call_get_object_path (CallsMMCall *call)
|
||||
{
|
||||
return mm_call_get_path (call->mm_call);
|
||||
}
|
||||
|
||||
|
||||
const gchar *
|
||||
calls_mm_call_get_disconnect_reason (CallsMMCall *call)
|
||||
{
|
||||
return call->disconnect_reason;
|
||||
}
|
||||
43
plugins/mm/calls-mm-call.h
Normal file
43
plugins/mm/calls-mm-call.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CALLS_MM_CALL_H__
|
||||
#define CALLS_MM_CALL_H__
|
||||
|
||||
#include <libmm-glib.h>
|
||||
#include <glib-object.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);
|
||||
|
||||
CallsMMCall *calls_mm_call_new (MMCall *mm_call);
|
||||
const gchar *calls_mm_call_get_object_path (CallsMMCall *call);
|
||||
const gchar *calls_mm_call_get_disconnect_reason (CallsMMCall *call);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* CALLS_MM_CALL_H__ */
|
||||
548
plugins/mm/calls-mm-origin.c
Normal file
548
plugins/mm/calls-mm-origin.c
Normal file
@@ -0,0 +1,548 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#include "calls-mm-origin.h"
|
||||
#include "calls-origin.h"
|
||||
#include "calls-mm-call.h"
|
||||
#include "calls-message-source.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
|
||||
struct _CallsMMOrigin
|
||||
{
|
||||
GObject parent_instance;
|
||||
MMObject *mm_obj;
|
||||
MMModemVoice *voice;
|
||||
gchar *name;
|
||||
GHashTable *calls;
|
||||
};
|
||||
|
||||
static void calls_mm_origin_message_source_interface_init (CallsOriginInterface *iface);
|
||||
static void calls_mm_origin_origin_interface_init (CallsOriginInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (CallsMMOrigin, calls_mm_origin, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (CALLS_TYPE_MESSAGE_SOURCE,
|
||||
calls_mm_origin_message_source_interface_init)
|
||||
G_IMPLEMENT_INTERFACE (CALLS_TYPE_ORIGIN,
|
||||
calls_mm_origin_origin_interface_init))
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_MODEM,
|
||||
PROP_LAST_PROP,
|
||||
};
|
||||
static GParamSpec *props[PROP_LAST_PROP];
|
||||
|
||||
|
||||
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,
|
||||
GAsyncResult *res,
|
||||
CallsMMOrigin *self)
|
||||
{
|
||||
MMCall *call;
|
||||
GError *error = NULL;
|
||||
|
||||
call = mm_modem_voice_create_call_finish (voice, res, &error);
|
||||
if (!call)
|
||||
{
|
||||
g_warning ("Error dialing number on ModemManager modem `%s': %s",
|
||||
self->name, error->message);
|
||||
CALLS_ERROR (self, error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dial (CallsOrigin *origin, const gchar *number)
|
||||
{
|
||||
CallsMMOrigin *self = CALLS_MM_ORIGIN (origin);
|
||||
MMCallProperties *props;
|
||||
|
||||
g_assert (self->voice != NULL);
|
||||
|
||||
props = mm_call_properties_new();
|
||||
mm_call_properties_set_number (props, number);
|
||||
|
||||
mm_modem_voice_create_call
|
||||
(self->voice,
|
||||
props,
|
||||
NULL,
|
||||
(GAsyncReadyCallback) dial_cb,
|
||||
self);
|
||||
|
||||
g_object_unref (props);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
remove_call (CallsMMOrigin *self,
|
||||
CallsMMCall *call,
|
||||
const gchar *path,
|
||||
const gchar *reason)
|
||||
{
|
||||
g_signal_emit_by_name (CALLS_ORIGIN(self), "call-removed",
|
||||
CALLS_CALL(call), reason);
|
||||
g_hash_table_remove (self->calls, path);
|
||||
}
|
||||
|
||||
|
||||
struct CallsMMRemoveCallsData
|
||||
{
|
||||
CallsOrigin *origin;
|
||||
const gchar *reason;
|
||||
};
|
||||
|
||||
|
||||
static gboolean
|
||||
remove_calls_cb (const gchar *path,
|
||||
CallsMMCall *call,
|
||||
struct CallsMMRemoveCallsData *data)
|
||||
{
|
||||
g_signal_emit_by_name (data->origin, "call-removed",
|
||||
CALLS_CALL(call), data->reason);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
remove_calls (CallsMMOrigin *self, const gchar *reason)
|
||||
{
|
||||
struct CallsMMRemoveCallsData data = { CALLS_ORIGIN (self), reason };
|
||||
|
||||
g_hash_table_foreach_remove (self->calls,
|
||||
(GHRFunc) remove_calls_cb,
|
||||
&data);
|
||||
}
|
||||
|
||||
|
||||
struct CallsMMOriginDeleteCallData
|
||||
{
|
||||
CallsMMOrigin *self;
|
||||
gchar *path;
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
delete_call_cb (MMModemVoice *voice,
|
||||
GAsyncResult *res,
|
||||
struct CallsMMOriginDeleteCallData *data)
|
||||
{
|
||||
gboolean ok;
|
||||
GError *error = NULL;
|
||||
|
||||
ok = mm_modem_voice_delete_call_finish (voice, res, &error);
|
||||
if (!ok)
|
||||
{
|
||||
g_warning ("Error deleting call `%s' on MMModemVoice `%s': %s",
|
||||
data->path, data->self->name, error->message);
|
||||
CALLS_ERROR (data->self, error);
|
||||
}
|
||||
|
||||
g_free (data->path);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
delete_call (CallsMMOrigin *self,
|
||||
CallsMMCall *call)
|
||||
{
|
||||
const gchar *path;
|
||||
struct CallsMMOriginDeleteCallData *data;
|
||||
|
||||
path = calls_mm_call_get_object_path (call);
|
||||
|
||||
data = g_new0 (struct CallsMMOriginDeleteCallData, 1);
|
||||
data->self = self;
|
||||
data->path = g_strdup (path);
|
||||
|
||||
mm_modem_voice_delete_call
|
||||
(self->voice,
|
||||
path,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)delete_call_cb,
|
||||
data);
|
||||
}
|
||||
|
||||
static void
|
||||
call_state_changed_cb (CallsMMOrigin *self,
|
||||
CallsCallState new_state,
|
||||
CallsCallState old_state,
|
||||
CallsCall *call)
|
||||
{
|
||||
if (new_state != CALLS_CALL_STATE_DISCONNECTED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
delete_call (self, CALLS_MM_CALL (call));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
add_call (CallsMMOrigin *self,
|
||||
MMCall *mm_call)
|
||||
{
|
||||
CallsMMCall *call;
|
||||
gchar *path;
|
||||
|
||||
call = calls_mm_call_new (mm_call);
|
||||
|
||||
g_signal_connect_swapped (call, "state-changed",
|
||||
G_CALLBACK (call_state_changed_cb),
|
||||
self);
|
||||
|
||||
path = mm_call_dup_path (mm_call);
|
||||
g_hash_table_insert (self->calls, path, call);
|
||||
|
||||
g_signal_emit_by_name (CALLS_ORIGIN(self), "call-added",
|
||||
CALLS_CALL(call));
|
||||
|
||||
if (mm_call_get_state (mm_call) == MM_CALL_STATE_TERMINATED)
|
||||
{
|
||||
// Delete any remnant disconnected call
|
||||
delete_call (self, call);
|
||||
}
|
||||
|
||||
g_debug ("Call `%s' added", path);
|
||||
}
|
||||
|
||||
|
||||
struct CallsMMOriginCallAddedData
|
||||
{
|
||||
CallsMMOrigin *self;
|
||||
gchar *path;
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
call_added_list_calls_cb (MMModemVoice *voice,
|
||||
GAsyncResult *res,
|
||||
struct CallsMMOriginCallAddedData *data)
|
||||
{
|
||||
GList *calls;
|
||||
GError *error = NULL;
|
||||
|
||||
calls = mm_modem_voice_list_calls_finish (voice, res, &error);
|
||||
if (!calls)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
g_warning ("Error listing calls on MMModemVoice `%s'"
|
||||
" after call-added signal: %s",
|
||||
data->self->name, error->message);
|
||||
CALLS_ERROR (data->self, error);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("No calls on MMModemVoice `%s'"
|
||||
" after call-added signal",
|
||||
data->self->name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GList *node;
|
||||
MMCall *call;
|
||||
gboolean found = FALSE;
|
||||
|
||||
for (node = calls; node; node = node->next)
|
||||
{
|
||||
call = MM_CALL (node->data);
|
||||
|
||||
if (g_strcmp0 (mm_call_get_path (call), data->path) == 0)
|
||||
{
|
||||
add_call (data->self, call);
|
||||
found = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
g_warning ("Could not find new call `%s' in call list"
|
||||
" on MMModemVoice `%s' after call-added signal",
|
||||
data->path, data->self->name);
|
||||
}
|
||||
|
||||
g_list_free_full (calls, g_object_unref);
|
||||
}
|
||||
|
||||
g_free (data->path);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
call_added_cb (MMModemVoice *voice,
|
||||
gchar *path,
|
||||
CallsMMOrigin *self)
|
||||
{
|
||||
struct CallsMMOriginCallAddedData *data;
|
||||
|
||||
if (g_hash_table_contains (self->calls, path))
|
||||
{
|
||||
g_warning ("Received call-added signal for"
|
||||
" existing call object path `%s'", path);
|
||||
return;
|
||||
}
|
||||
|
||||
data = g_new0 (struct CallsMMOriginCallAddedData, 1);
|
||||
data->self = self;
|
||||
data->path = g_strdup (path);
|
||||
|
||||
mm_modem_voice_list_calls
|
||||
(voice,
|
||||
NULL,
|
||||
(GAsyncReadyCallback) call_added_list_calls_cb,
|
||||
data);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
call_deleted_cb (MMModemVoice *voice,
|
||||
const gchar *path,
|
||||
CallsMMOrigin *self)
|
||||
{
|
||||
CallsMMCall *call;
|
||||
GString *reason;
|
||||
const gchar *mm_reason;
|
||||
|
||||
g_debug ("Removing call `%s'", path);
|
||||
|
||||
call = g_hash_table_lookup (self->calls, path);
|
||||
if (!call)
|
||||
{
|
||||
g_warning ("Could not find removed call `%s'", path);
|
||||
return;
|
||||
}
|
||||
|
||||
reason = g_string_new ("Call removed");
|
||||
|
||||
mm_reason = calls_mm_call_get_disconnect_reason (call);
|
||||
if (mm_reason)
|
||||
{
|
||||
g_string_assign (reason, mm_reason);
|
||||
}
|
||||
|
||||
remove_call (self, call, path, reason->str);
|
||||
|
||||
g_string_free (reason, TRUE);
|
||||
|
||||
g_debug ("Removed call `%s'", path);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
list_calls_cb (MMModemVoice *voice,
|
||||
GAsyncResult *res,
|
||||
CallsMMOrigin *self)
|
||||
{
|
||||
GList *calls, *node;
|
||||
GError *error = NULL;
|
||||
|
||||
calls = mm_modem_voice_list_calls_finish (voice, res, &error);
|
||||
if (!calls)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
g_warning ("Error listing calls on MMModemVoice `%s': %s",
|
||||
self->name, error->message);
|
||||
CALLS_ERROR (self, error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (node = calls; node; node = node->next)
|
||||
{
|
||||
add_call (self, MM_CALL (node->data));
|
||||
}
|
||||
|
||||
g_list_free_full (calls, g_object_unref);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
CallsMMOrigin *self = CALLS_MM_ORIGIN (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_MODEM:
|
||||
g_set_object (&self->mm_obj, g_value_get_object(value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
modem_get_name (MMModem *modem)
|
||||
{
|
||||
gchar *name = NULL;
|
||||
|
||||
#define try(prop) \
|
||||
name = mm_modem_dup_##prop (modem); \
|
||||
if (name) { \
|
||||
return name; \
|
||||
}
|
||||
|
||||
try (model);
|
||||
try (manufacturer);
|
||||
try (device);
|
||||
try (primary_port);
|
||||
try (device_identifier);
|
||||
try (plugin);
|
||||
|
||||
#undef try
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
constructed (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsMMOrigin *self = CALLS_MM_ORIGIN (object);
|
||||
MmGdbusModemVoice *gdbus_voice;
|
||||
|
||||
self->name = modem_get_name (mm_object_get_modem (self->mm_obj));
|
||||
|
||||
self->voice = mm_object_get_modem_voice (self->mm_obj);
|
||||
g_assert (self->voice != NULL);
|
||||
|
||||
gdbus_voice = MM_GDBUS_MODEM_VOICE (self->voice);
|
||||
g_signal_connect (gdbus_voice, "call-added",
|
||||
G_CALLBACK (call_added_cb), self);
|
||||
g_signal_connect (gdbus_voice, "call-deleted",
|
||||
G_CALLBACK (call_deleted_cb), self);
|
||||
|
||||
mm_modem_voice_list_calls
|
||||
(self->voice,
|
||||
NULL,
|
||||
(GAsyncReadyCallback) list_calls_cb,
|
||||
self);
|
||||
parent_class->constructed (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dispose (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsMMOrigin *self = CALLS_MM_ORIGIN (object);
|
||||
|
||||
remove_calls (self, NULL);
|
||||
g_clear_object (&self->mm_obj);
|
||||
|
||||
parent_class->dispose (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsMMOrigin *self = CALLS_MM_ORIGIN (object);
|
||||
|
||||
g_hash_table_unref (self->calls);
|
||||
g_free (self->name);
|
||||
|
||||
parent_class->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_mm_origin_class_init (CallsMMOriginClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->set_property = set_property;
|
||||
object_class->constructed = constructed;
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
props[PROP_MODEM] =
|
||||
g_param_spec_object ("mm-object",
|
||||
_("Modem Object"),
|
||||
_("A libmm-glib proxy object for the modem"),
|
||||
MM_TYPE_OBJECT,
|
||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_mm_origin_message_source_interface_init (CallsOriginInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_mm_origin_origin_interface_init (CallsOriginInterface *iface)
|
||||
{
|
||||
iface->get_name = get_name;
|
||||
iface->get_calls = get_calls;
|
||||
iface->dial = dial;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_mm_origin_init (CallsMMOrigin *self)
|
||||
{
|
||||
self->calls = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, g_object_unref);
|
||||
}
|
||||
|
||||
CallsMMOrigin *
|
||||
calls_mm_origin_new (MMObject *mm_obj)
|
||||
{
|
||||
return g_object_new (CALLS_TYPE_MM_ORIGIN,
|
||||
"mm-object", mm_obj,
|
||||
NULL);
|
||||
}
|
||||
41
plugins/mm/calls-mm-origin.h
Normal file
41
plugins/mm/calls-mm-origin.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CALLS_MM_ORIGIN_H__
|
||||
#define CALLS_MM_ORIGIN_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <libmm-glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CALLS_TYPE_MM_ORIGIN (calls_mm_origin_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (CallsMMOrigin, calls_mm_origin, CALLS, MM_ORIGIN, GObject);
|
||||
|
||||
CallsMMOrigin *calls_mm_origin_new (MMObject *modem);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* CALLS_MM_ORIGIN_H__ */
|
||||
478
plugins/mm/calls-mm-provider.c
Normal file
478
plugins/mm/calls-mm-provider.c
Normal file
@@ -0,0 +1,478 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#include "calls-mm-provider.h"
|
||||
#include "calls-provider.h"
|
||||
#include "calls-mm-origin.h"
|
||||
#include "calls-message-source.h"
|
||||
#include "calls-origin.h"
|
||||
|
||||
#include <libmm-glib.h>
|
||||
#include <libpeas/peas.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
struct _CallsMMProvider
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
/* The status property */
|
||||
gchar *status;
|
||||
/** ID for the D-Bus watch */
|
||||
guint watch_id;
|
||||
/** ModemManager object proxy */
|
||||
MMManager *mm;
|
||||
/** Map of D-Bus object paths to origins */
|
||||
GHashTable *origins;
|
||||
};
|
||||
|
||||
static void calls_mm_provider_message_source_interface_init (CallsProviderInterface *iface);
|
||||
static void calls_mm_provider_provider_interface_init (CallsProviderInterface *iface);
|
||||
|
||||
G_DEFINE_DYNAMIC_TYPE_EXTENDED
|
||||
(CallsMMProvider, calls_mm_provider, G_TYPE_OBJECT, 0,
|
||||
G_IMPLEMENT_INTERFACE_DYNAMIC (CALLS_TYPE_MESSAGE_SOURCE,
|
||||
calls_mm_provider_message_source_interface_init)
|
||||
G_IMPLEMENT_INTERFACE_DYNAMIC (CALLS_TYPE_PROVIDER,
|
||||
calls_mm_provider_provider_interface_init))
|
||||
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_STATUS,
|
||||
PROP_LAST_PROP,
|
||||
};
|
||||
|
||||
|
||||
static const gchar *
|
||||
get_name (CallsProvider *iface)
|
||||
{
|
||||
return "ModemManager";
|
||||
}
|
||||
|
||||
|
||||
static GList *
|
||||
get_origins (CallsProvider *iface)
|
||||
{
|
||||
CallsMMProvider *self = CALLS_MM_PROVIDER (iface);
|
||||
return g_hash_table_get_values (self->origins);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
set_status (CallsMMProvider *self,
|
||||
const gchar *new_status)
|
||||
{
|
||||
if (strcmp (self->status, new_status) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_free (self->status);
|
||||
self->status = g_strdup (new_status);
|
||||
g_object_notify (G_OBJECT (self), "status");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
update_status (CallsMMProvider *self)
|
||||
{
|
||||
const gchar *s;
|
||||
|
||||
if (!self->mm)
|
||||
{
|
||||
s = _("ModemManager unavailable");
|
||||
}
|
||||
else if (g_hash_table_size (self->origins) == 0)
|
||||
{
|
||||
s = _("No voice-capable modem available");
|
||||
}
|
||||
else
|
||||
{
|
||||
s = _("Normal");
|
||||
}
|
||||
|
||||
set_status (self, s);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
add_origin (CallsMMProvider *self,
|
||||
GDBusObject *object)
|
||||
{
|
||||
MMObject *mm_obj;
|
||||
CallsMMOrigin *origin;
|
||||
const gchar *path;
|
||||
|
||||
path = g_dbus_object_get_object_path (object);
|
||||
if (g_hash_table_contains (self->origins, path))
|
||||
{
|
||||
g_warning ("New voice interface on existing"
|
||||
" origin with path `%s'", path);
|
||||
return;
|
||||
}
|
||||
|
||||
g_debug ("Adding new voice-capable modem `%s'",
|
||||
path);
|
||||
|
||||
g_assert (MM_IS_OBJECT (object));
|
||||
mm_obj = MM_OBJECT (object);
|
||||
|
||||
origin = calls_mm_origin_new (mm_obj);
|
||||
|
||||
g_hash_table_insert (self->origins,
|
||||
mm_object_dup_path (mm_obj),
|
||||
origin);
|
||||
|
||||
g_signal_emit_by_name (CALLS_PROVIDER (self),
|
||||
"origin-added", origin);
|
||||
update_status (self);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
interface_added_cb (CallsMMProvider *self,
|
||||
GDBusObject *object,
|
||||
GDBusInterface *interface)
|
||||
{
|
||||
GDBusInterfaceInfo *info;
|
||||
|
||||
info = g_dbus_interface_get_info (interface);
|
||||
|
||||
g_debug ("ModemManager interface `%s' found on object `%s'",
|
||||
info->name,
|
||||
g_dbus_object_get_object_path (object));
|
||||
|
||||
if (g_strcmp0 (info->name,
|
||||
"org.freedesktop.ModemManager1.Modem.Voice") == 0)
|
||||
{
|
||||
add_origin (self, object);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
remove_modem_object (CallsMMProvider *self,
|
||||
const gchar *path,
|
||||
GDBusObject *object)
|
||||
{
|
||||
gpointer *origin;
|
||||
|
||||
origin = g_hash_table_lookup (self->origins, path);
|
||||
if (!origin)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_assert (CALLS_IS_ORIGIN (origin));
|
||||
|
||||
g_signal_emit_by_name (CALLS_PROVIDER (self),
|
||||
"origin-removed", CALLS_ORIGIN (origin));
|
||||
|
||||
g_hash_table_remove (self->origins, path);
|
||||
|
||||
update_status (self);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
interface_removed_cb (CallsMMProvider *self,
|
||||
GDBusObject *object,
|
||||
GDBusInterface *interface)
|
||||
{
|
||||
const gchar *path;
|
||||
GDBusInterfaceInfo *info;
|
||||
|
||||
path = g_dbus_object_get_object_path (object);
|
||||
info = g_dbus_interface_get_info (interface);
|
||||
|
||||
g_debug ("ModemManager interface `%s' removed on object `%s'",
|
||||
info->name, path);
|
||||
|
||||
if (g_strcmp0 (info->name,
|
||||
"org.freedesktop.ModemManager1.Modem.Voice") != 0)
|
||||
{
|
||||
remove_modem_object (self, path, object);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
add_mm_object (CallsMMProvider *self, GDBusObject *object)
|
||||
{
|
||||
GList *ifaces, *node;
|
||||
|
||||
ifaces = g_dbus_object_get_interfaces (object);
|
||||
for (node = ifaces; node; node = node->next)
|
||||
{
|
||||
interface_added_cb (self, object,
|
||||
G_DBUS_INTERFACE (node->data));
|
||||
}
|
||||
|
||||
g_list_free_full (ifaces, g_object_unref);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
add_mm_objects (CallsMMProvider *self)
|
||||
{
|
||||
GList *objects, *node;
|
||||
|
||||
objects = g_dbus_object_manager_get_objects (G_DBUS_OBJECT_MANAGER (self->mm));
|
||||
for (node = objects; node; node = node->next)
|
||||
{
|
||||
add_mm_object (self, G_DBUS_OBJECT (node->data));
|
||||
}
|
||||
|
||||
g_list_free_full (objects, g_object_unref);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
object_added_cb (CallsMMProvider *self,
|
||||
GDBusObject *object)
|
||||
{
|
||||
g_debug ("ModemManager object `%s' added",
|
||||
g_dbus_object_get_object_path (object));
|
||||
|
||||
add_mm_object (self, object);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
object_removed_cb (CallsMMProvider *self,
|
||||
GDBusObject *object)
|
||||
{
|
||||
const gchar *path;
|
||||
|
||||
path = g_dbus_object_get_object_path (object);
|
||||
g_debug ("ModemManager object `%s' removed", path);
|
||||
|
||||
remove_modem_object (self, path, object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
mm_manager_new_cb (GDBusConnection *connection,
|
||||
GAsyncResult *res,
|
||||
CallsMMProvider *self)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
self->mm = mm_manager_new_finish (res, &error);
|
||||
if (!self->mm)
|
||||
{
|
||||
g_error ("Error creating ModemManager Manager: %s",
|
||||
error->message);
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
|
||||
g_signal_connect_swapped (G_DBUS_OBJECT_MANAGER (self->mm),
|
||||
"interface-added",
|
||||
G_CALLBACK (interface_added_cb), self);
|
||||
g_signal_connect_swapped (G_DBUS_OBJECT_MANAGER (self->mm),
|
||||
"interface-removed",
|
||||
G_CALLBACK (interface_removed_cb), self);
|
||||
g_signal_connect_swapped (G_DBUS_OBJECT_MANAGER (self->mm),
|
||||
"object-added",
|
||||
G_CALLBACK (object_added_cb), self);
|
||||
g_signal_connect_swapped (G_DBUS_OBJECT_MANAGER (self->mm),
|
||||
"object-removed",
|
||||
G_CALLBACK (object_removed_cb), self);
|
||||
|
||||
update_status (self);
|
||||
add_mm_objects (self);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
mm_appeared_cb (GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
const gchar *name_owner,
|
||||
CallsMMProvider *self)
|
||||
{
|
||||
g_debug ("ModemManager appeared on D-Bus");
|
||||
|
||||
mm_manager_new (connection,
|
||||
G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback) mm_manager_new_cb,
|
||||
self);
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
remove_origins_cb (const gchar *path,
|
||||
CallsMMOrigin *origin,
|
||||
CallsMMProvider *self)
|
||||
{
|
||||
g_signal_emit_by_name (CALLS_PROVIDER (self),
|
||||
"origin-removed", CALLS_ORIGIN (origin));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
clear_dbus (CallsMMProvider *self)
|
||||
{
|
||||
g_hash_table_foreach_remove (self->origins,
|
||||
(GHRFunc)remove_origins_cb,
|
||||
self);
|
||||
g_clear_object (&self->mm);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
mm_vanished_cb (GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
CallsMMProvider *self)
|
||||
{
|
||||
g_debug ("ModemManager vanished from D-Bus");
|
||||
clear_dbus (self);
|
||||
update_status (self);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
constructed (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsMMProvider *self = CALLS_MM_PROVIDER (object);
|
||||
|
||||
self->watch_id =
|
||||
g_bus_watch_name (G_BUS_TYPE_SYSTEM,
|
||||
MM_DBUS_SERVICE,
|
||||
G_BUS_NAME_WATCHER_FLAGS_AUTO_START,
|
||||
(GBusNameAppearedCallback)mm_appeared_cb,
|
||||
(GBusNameVanishedCallback)mm_vanished_cb,
|
||||
self, NULL);
|
||||
|
||||
g_debug ("Watching for ModemManager");
|
||||
|
||||
parent_class->constructed (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
CallsMMProvider *self = CALLS_MM_PROVIDER (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_STATUS:
|
||||
g_value_set_string (value, self->status);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dispose (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsMMProvider *self = CALLS_MM_PROVIDER (object);
|
||||
|
||||
if (self->watch_id)
|
||||
{
|
||||
g_bus_unwatch_name (self->watch_id);
|
||||
self->watch_id = 0;
|
||||
}
|
||||
|
||||
clear_dbus (self);
|
||||
|
||||
parent_class->dispose (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsMMProvider *self = CALLS_MM_PROVIDER (object);
|
||||
|
||||
g_hash_table_unref (self->origins);
|
||||
g_free (self->status);
|
||||
|
||||
parent_class->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_mm_provider_class_init (CallsMMProviderClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->constructed = constructed;
|
||||
object_class->get_property = get_property;
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
g_object_class_override_property (object_class, PROP_STATUS, "status");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_mm_provider_class_finalize (CallsMMProviderClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
calls_mm_provider_message_source_interface_init (CallsProviderInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_mm_provider_provider_interface_init (CallsProviderInterface *iface)
|
||||
{
|
||||
iface->get_name = get_name;
|
||||
iface->get_origins = get_origins;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_mm_provider_init (CallsMMProvider *self)
|
||||
{
|
||||
self->status = g_strdup (_("Initialised"));
|
||||
self->origins = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, g_object_unref);
|
||||
}
|
||||
|
||||
|
||||
G_MODULE_EXPORT void
|
||||
peas_register_types (PeasObjectModule *module)
|
||||
{
|
||||
calls_mm_provider_register_type (G_TYPE_MODULE (module));
|
||||
|
||||
peas_object_module_register_extension_type (module,
|
||||
CALLS_TYPE_PROVIDER,
|
||||
CALLS_TYPE_MM_PROVIDER);
|
||||
}
|
||||
39
plugins/mm/calls-mm-provider.h
Normal file
39
plugins/mm/calls-mm-provider.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CALLS_MM_PROVIDER_H__
|
||||
#define CALLS_MM_PROVIDER_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CALLS_TYPE_MM_PROVIDER (calls_mm_provider_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (CallsMMProvider, calls_mm_provider, CALLS, MM_PROVIDER, GObject);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* CALLS_MM_PROVIDER_H__ */
|
||||
56
plugins/mm/meson.build
Normal file
56
plugins/mm/meson.build
Normal file
@@ -0,0 +1,56 @@
|
||||
#
|
||||
# Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
|
||||
mm_install_dir = join_paths(full_calls_plugin_libdir, 'mm')
|
||||
|
||||
mm_plugin = configure_file(
|
||||
input: 'mm.plugin.in',
|
||||
output: 'mm.plugin',
|
||||
configuration: config_data,
|
||||
install_dir: mm_install_dir
|
||||
)
|
||||
|
||||
mm_deps = [
|
||||
dependency('gobject-2.0'),
|
||||
dependency('gtk+-3.0'),
|
||||
dependency('ModemManager'),
|
||||
dependency('mm-glib'),
|
||||
dependency('libpeas-1.0'),
|
||||
]
|
||||
|
||||
mm_sources = files(
|
||||
[
|
||||
'calls-mm-call.c', 'calls-mm-call.h',
|
||||
'calls-mm-origin.c', 'calls-mm-origin.h',
|
||||
'calls-mm-provider.c', 'calls-mm-provider.h'
|
||||
]
|
||||
)
|
||||
|
||||
shared_module(
|
||||
'mm',
|
||||
mm_sources,
|
||||
dependencies: mm_deps,
|
||||
include_directories: src_include,
|
||||
install: true,
|
||||
install_dir: mm_install_dir
|
||||
)
|
||||
7
plugins/mm/mm.plugin.in
Normal file
7
plugins/mm/mm.plugin.in
Normal file
@@ -0,0 +1,7 @@
|
||||
[Plugin]
|
||||
Module=mm
|
||||
Name=ModemManager
|
||||
Description=ModemManager calls provider
|
||||
Authors=Bob Ham <rah@settrans.net>
|
||||
Copyright=Copyright (C) 2018 Purism SPC
|
||||
Website=@PACKAGE_URL_RAW@
|
||||
411
plugins/ofono/calls-ofono-call.c
Normal file
411
plugins/ofono/calls-ofono-call.c
Normal file
@@ -0,0 +1,411 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#include "calls-ofono-call.h"
|
||||
#include "calls-call.h"
|
||||
#include "calls-message-source.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
|
||||
struct _CallsOfonoCall
|
||||
{
|
||||
GObject parent_instance;
|
||||
GDBOVoiceCall *voice_call;
|
||||
gchar *number;
|
||||
gchar *name;
|
||||
CallsCallState state;
|
||||
gchar *disconnect_reason;
|
||||
};
|
||||
|
||||
static void calls_ofono_call_message_source_interface_init (CallsCallInterface *iface);
|
||||
static void calls_ofono_call_call_interface_init (CallsCallInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (CallsOfonoCall, calls_ofono_call, G_TYPE_OBJECT,
|
||||
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))
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_VOICE_CALL,
|
||||
PROP_PROPERTIES,
|
||||
PROP_LAST_PROP,
|
||||
};
|
||||
static GParamSpec *props[PROP_LAST_PROP];
|
||||
|
||||
enum {
|
||||
SIGNAL_TONE,
|
||||
SIGNAL_LAST_SIGNAL,
|
||||
};
|
||||
static guint signals [SIGNAL_LAST_SIGNAL];
|
||||
|
||||
|
||||
#define DEFINE_GET_BODY(member) \
|
||||
get_##member (CallsCall *iface) \
|
||||
{ \
|
||||
CallsOfonoCall *self = CALLS_OFONO_CALL (iface); \
|
||||
return self-> member ; \
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
DEFINE_GET_BODY(number);
|
||||
|
||||
static const gchar *
|
||||
DEFINE_GET_BODY(name);
|
||||
|
||||
static CallsCallState
|
||||
DEFINE_GET_BODY(state);
|
||||
|
||||
#undef DEFINE_GET_BODY
|
||||
|
||||
|
||||
static void
|
||||
change_state (CallsOfonoCall *self,
|
||||
CallsCallState state)
|
||||
{
|
||||
CallsCallState old_state = self->state;
|
||||
|
||||
if (old_state == state)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
self->state = state;
|
||||
g_signal_emit_by_name (CALLS_CALL (self),
|
||||
"state-changed",
|
||||
state,
|
||||
old_state);
|
||||
}
|
||||
|
||||
|
||||
struct CallsCallOperationData
|
||||
{
|
||||
const gchar *desc;
|
||||
CallsOfonoCall *self;
|
||||
gboolean (*finish_func) (GDBOVoiceCall *, GAsyncResult *, GError **);
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
operation_cb (GDBOVoiceCall *voice_call,
|
||||
GAsyncResult *res,
|
||||
struct CallsCallOperationData *data)
|
||||
{
|
||||
gboolean ok;
|
||||
GError *error = NULL;
|
||||
|
||||
ok = data->finish_func (voice_call, res, &error);
|
||||
if (!ok)
|
||||
{
|
||||
g_warning ("Error %s oFono voice call to `%s': %s",
|
||||
data->desc, data->self->number, error->message);
|
||||
CALLS_ERROR (data->self, error);
|
||||
}
|
||||
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
answer (CallsCall *call)
|
||||
{
|
||||
CallsOfonoCall *self = CALLS_OFONO_CALL (call);
|
||||
struct CallsCallOperationData *data;
|
||||
|
||||
data = g_new0 (struct CallsCallOperationData, 1);
|
||||
data->desc = "answering";
|
||||
data->self = self;
|
||||
data->finish_func = gdbo_voice_call_call_answer_finish;
|
||||
|
||||
gdbo_voice_call_call_answer
|
||||
(self->voice_call, NULL,
|
||||
(GAsyncReadyCallback) operation_cb,
|
||||
data);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
hang_up (CallsCall *call)
|
||||
{
|
||||
CallsOfonoCall *self = CALLS_OFONO_CALL (call);
|
||||
struct CallsCallOperationData *data;
|
||||
|
||||
data = g_new0 (struct CallsCallOperationData, 1);
|
||||
data->desc = "hanging up";
|
||||
data->self = self;
|
||||
data->finish_func = gdbo_voice_call_call_hangup_finish;
|
||||
|
||||
gdbo_voice_call_call_hangup
|
||||
(self->voice_call, NULL,
|
||||
(GAsyncReadyCallback) operation_cb,
|
||||
data);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
tone_start (CallsCall *call, gchar key)
|
||||
{
|
||||
CallsOfonoCall *self = CALLS_OFONO_CALL (call);
|
||||
if (self->state != CALLS_CALL_STATE_ACTIVE)
|
||||
{
|
||||
g_warning ("Tone start requested for non-active call to `%s'",
|
||||
self->number);
|
||||
return;
|
||||
}
|
||||
|
||||
g_signal_emit_by_name (self, "tone", key);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
set_properties (CallsOfonoCall *self,
|
||||
GVariant *props)
|
||||
{
|
||||
const gchar *str = NULL;
|
||||
|
||||
g_return_if_fail (props != NULL);
|
||||
|
||||
g_variant_lookup (props, "LineIdentification", "s", &self->number);
|
||||
g_variant_lookup (props, "Name", "s", &self->name);
|
||||
|
||||
g_variant_lookup (props, "State", "&s", &str);
|
||||
g_return_if_fail (str != NULL);
|
||||
calls_call_state_parse_nick (&self->state, str);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
CallsOfonoCall *self = CALLS_OFONO_CALL (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_VOICE_CALL:
|
||||
g_set_object
|
||||
(&self->voice_call, GDBO_VOICE_CALL (g_value_get_object (value)));
|
||||
break;
|
||||
|
||||
case PROP_PROPERTIES:
|
||||
set_properties (self, g_value_get_variant (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
property_changed_cb (CallsOfonoCall *self,
|
||||
const gchar *name,
|
||||
GVariant *value)
|
||||
{
|
||||
GVariant *str_var;
|
||||
gchar *str = NULL;
|
||||
CallsCallState state;
|
||||
gboolean ok;
|
||||
|
||||
{
|
||||
gchar *text = g_variant_print (value, TRUE);
|
||||
g_debug ("Property `%s' for oFono call to `%s' changed to: %s",
|
||||
name, self->number, text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
if (g_strcmp0 (name, "State") != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_variant_get (value, "v", &str_var);
|
||||
g_variant_get (str_var, "&s", &str);
|
||||
g_return_if_fail (str != NULL);
|
||||
|
||||
ok = calls_call_state_parse_nick (&state, str);
|
||||
if (ok)
|
||||
{
|
||||
change_state (self, state);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Could not parse new state `%s'"
|
||||
" of oFono call to `%s'",
|
||||
str, self->number);
|
||||
}
|
||||
|
||||
g_variant_unref (str_var);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
disconnect_reason_cb (CallsOfonoCall *self,
|
||||
const gchar *reason)
|
||||
{
|
||||
if (reason)
|
||||
{
|
||||
CALLS_SET_PTR_PROPERTY (self->disconnect_reason,
|
||||
g_strdup (reason));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
constructed (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsOfonoCall *self = CALLS_OFONO_CALL (object);
|
||||
|
||||
g_return_if_fail (self->voice_call != NULL);
|
||||
|
||||
g_signal_connect_swapped (self->voice_call, "property-changed",
|
||||
G_CALLBACK (property_changed_cb), self);
|
||||
g_signal_connect_swapped (self->voice_call, "disconnect-reason",
|
||||
G_CALLBACK (disconnect_reason_cb), self);
|
||||
|
||||
parent_class->constructed (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dispose (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsOfonoCall *self = CALLS_OFONO_CALL (object);
|
||||
|
||||
g_clear_object (&self->voice_call);
|
||||
|
||||
parent_class->dispose (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsOfonoCall *self = CALLS_OFONO_CALL (object);
|
||||
|
||||
g_free (self->disconnect_reason);
|
||||
g_free (self->name);
|
||||
g_free (self->number);
|
||||
|
||||
parent_class->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_ofono_call_class_init (CallsOfonoCallClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GType tone_arg_types = G_TYPE_CHAR;
|
||||
|
||||
object_class->set_property = set_property;
|
||||
object_class->constructed = constructed;
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
props[PROP_VOICE_CALL] =
|
||||
g_param_spec_object ("voice-call",
|
||||
_("Voice call"),
|
||||
_("A GDBO proxy object for the underlying call object"),
|
||||
GDBO_TYPE_VOICE_CALL,
|
||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
props[PROP_PROPERTIES] =
|
||||
g_param_spec_variant ("properties",
|
||||
_("Properties"),
|
||||
_("The a{sv} dictionary of properties for the voice call object"),
|
||||
G_VARIANT_TYPE_ARRAY,
|
||||
NULL,
|
||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
||||
|
||||
|
||||
signals[SIGNAL_TONE] =
|
||||
g_signal_newv ("tone",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
NULL, NULL, NULL, NULL,
|
||||
G_TYPE_NONE,
|
||||
1, &tone_arg_types);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_ofono_call_message_source_interface_init (CallsCallInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_ofono_call_call_interface_init (CallsCallInterface *iface)
|
||||
{
|
||||
iface->get_number = get_number;
|
||||
iface->get_name = get_name;
|
||||
iface->get_state = get_state;
|
||||
iface->answer = answer;
|
||||
iface->hang_up = hang_up;
|
||||
iface->tone_start = tone_start;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_ofono_call_init (CallsOfonoCall *self)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CallsOfonoCall *
|
||||
calls_ofono_call_new (GDBOVoiceCall *voice_call,
|
||||
GVariant *properties)
|
||||
{
|
||||
g_return_val_if_fail (GDBO_IS_VOICE_CALL (voice_call), NULL);
|
||||
g_return_val_if_fail (properties != NULL, NULL);
|
||||
|
||||
return g_object_new (CALLS_TYPE_OFONO_CALL,
|
||||
"voice-call", voice_call,
|
||||
"properties", properties,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
const gchar *
|
||||
calls_ofono_call_get_object_path (CallsOfonoCall *call)
|
||||
{
|
||||
return g_dbus_proxy_get_object_path (G_DBUS_PROXY (call->voice_call));
|
||||
}
|
||||
|
||||
|
||||
const gchar *
|
||||
calls_ofono_call_get_disconnect_reason (CallsOfonoCall *call)
|
||||
{
|
||||
return call->disconnect_reason;
|
||||
}
|
||||
46
plugins/ofono/calls-ofono-call.h
Normal file
46
plugins/ofono/calls-ofono-call.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CALLS_OFONO_CALL_H__
|
||||
#define CALLS_OFONO_CALL_H__
|
||||
|
||||
#include <libgdbofono/gdbo-call.h>
|
||||
|
||||
#include <glib-object.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);
|
||||
|
||||
CallsOfonoCall *calls_ofono_call_new (GDBOVoiceCall *voice_call,
|
||||
GVariant *properties);
|
||||
const gchar *calls_ofono_call_get_object_path (CallsOfonoCall *call);
|
||||
const gchar *calls_ofono_call_get_disconnect_reason (CallsOfonoCall *call);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* CALLS_OFONO_CALL_H__ */
|
||||
556
plugins/ofono/calls-ofono-origin.c
Normal file
556
plugins/ofono/calls-ofono-origin.c
Normal file
@@ -0,0 +1,556 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#include "calls-ofono-origin.h"
|
||||
#include "calls-origin.h"
|
||||
#include "calls-ofono-call.h"
|
||||
#include "calls-message-source.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
|
||||
struct _CallsOfonoOrigin
|
||||
{
|
||||
GObject parent_instance;
|
||||
GDBusConnection *connection;
|
||||
GDBOModem *modem;
|
||||
gchar *name;
|
||||
GDBOVoiceCallManager *voice;
|
||||
gboolean sending_tones;
|
||||
GString *tone_queue;
|
||||
GHashTable *calls;
|
||||
};
|
||||
|
||||
static void calls_ofono_origin_message_source_interface_init (CallsOriginInterface *iface);
|
||||
static void calls_ofono_origin_origin_interface_init (CallsOriginInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (CallsOfonoOrigin, calls_ofono_origin, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (CALLS_TYPE_MESSAGE_SOURCE,
|
||||
calls_ofono_origin_message_source_interface_init)
|
||||
G_IMPLEMENT_INTERFACE (CALLS_TYPE_ORIGIN,
|
||||
calls_ofono_origin_origin_interface_init))
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_MODEM,
|
||||
PROP_LAST_PROP,
|
||||
};
|
||||
static GParamSpec *props[PROP_LAST_PROP];
|
||||
|
||||
|
||||
static const gchar *
|
||||
get_name (CallsOrigin *origin)
|
||||
{
|
||||
CallsOfonoOrigin *self = CALLS_OFONO_ORIGIN (origin);
|
||||
return self->name;
|
||||
}
|
||||
|
||||
|
||||
static GList *
|
||||
get_calls (CallsOrigin * origin)
|
||||
{
|
||||
CallsOfonoOrigin *self = CALLS_OFONO_ORIGIN (origin);
|
||||
return g_hash_table_get_values (self->calls);
|
||||
}
|
||||
|
||||
static void
|
||||
dial_cb (GDBOVoiceCallManager *voice,
|
||||
GAsyncResult *res,
|
||||
CallsOfonoOrigin *self)
|
||||
{
|
||||
gboolean ok;
|
||||
GError *error = NULL;
|
||||
|
||||
ok = gdbo_voice_call_manager_call_dial_finish
|
||||
(voice, NULL, res, &error);
|
||||
if (!ok)
|
||||
{
|
||||
g_warning ("Error dialing number on modem `%s': %s",
|
||||
self->name, error->message);
|
||||
CALLS_ERROR (self, error);
|
||||
return;
|
||||
}
|
||||
|
||||
/* We will add the call through the call-added signal */
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dial (CallsOrigin *origin, const gchar *number)
|
||||
{
|
||||
CallsOfonoOrigin *self = CALLS_OFONO_ORIGIN (origin);
|
||||
|
||||
g_return_if_fail (self->voice != NULL);
|
||||
|
||||
gdbo_voice_call_manager_call_dial
|
||||
(self->voice,
|
||||
number,
|
||||
"default" /* default caller id settings */,
|
||||
NULL,
|
||||
(GAsyncReadyCallback) dial_cb,
|
||||
self);
|
||||
}
|
||||
|
||||
|
||||
CallsOfonoOrigin *
|
||||
calls_ofono_origin_new (GDBOModem *modem)
|
||||
{
|
||||
g_return_val_if_fail (GDBO_IS_MODEM (modem), NULL);
|
||||
|
||||
return g_object_new (CALLS_TYPE_OFONO_ORIGIN,
|
||||
"modem", modem,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
CallsOfonoOrigin *self = CALLS_OFONO_ORIGIN (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_MODEM:
|
||||
g_set_object
|
||||
(&self->modem, GDBO_MODEM (g_value_get_object (value)));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
remove_call (CallsOfonoOrigin *self,
|
||||
CallsOfonoCall *call,
|
||||
const gchar *reason)
|
||||
{
|
||||
const gchar *path = calls_ofono_call_get_object_path (call);
|
||||
|
||||
g_signal_emit_by_name (CALLS_ORIGIN(self), "call-removed",
|
||||
CALLS_CALL(call), reason);
|
||||
g_hash_table_remove (self->calls, path);
|
||||
}
|
||||
|
||||
|
||||
struct CallsRemoveCallsData
|
||||
{
|
||||
CallsOrigin *origin;
|
||||
const gchar *reason;
|
||||
};
|
||||
|
||||
static gboolean
|
||||
remove_calls_cb (const gchar *path,
|
||||
CallsOfonoCall *call,
|
||||
struct CallsRemoveCallsData *data)
|
||||
{
|
||||
g_signal_emit_by_name (data->origin, "call-removed",
|
||||
CALLS_CALL(call), data->reason);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
remove_calls (CallsOfonoOrigin *self, const gchar *reason)
|
||||
{
|
||||
struct CallsRemoveCallsData data = { CALLS_ORIGIN (self), reason };
|
||||
|
||||
g_hash_table_foreach_remove (self->calls,
|
||||
(GHRFunc) remove_calls_cb,
|
||||
&data);
|
||||
}
|
||||
|
||||
|
||||
struct CallsVoiceCallProxyNewData
|
||||
{
|
||||
CallsOfonoOrigin *self;
|
||||
GVariant *properties;
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
send_tones_cb (GDBOVoiceCallManager *voice,
|
||||
GAsyncResult *res,
|
||||
CallsOfonoOrigin *self)
|
||||
{
|
||||
gboolean ok;
|
||||
GError *error = NULL;
|
||||
|
||||
/* Deal with old tones */
|
||||
ok = gdbo_voice_call_manager_call_send_tones_finish
|
||||
(voice, res, &error);
|
||||
if (!ok)
|
||||
{
|
||||
g_warning ("Error sending DTMF tones to network on modem `%s': %s",
|
||||
self->name, error->message);
|
||||
CALLS_EMIT_MESSAGE (self, error->message, GTK_MESSAGE_WARNING);
|
||||
}
|
||||
|
||||
/* Possibly send new tones */
|
||||
if (self->tone_queue)
|
||||
{
|
||||
g_debug ("Sending queued DTMF tones `%s'", self->tone_queue->str);
|
||||
|
||||
gdbo_voice_call_manager_call_send_tones
|
||||
(voice,
|
||||
self->tone_queue->str,
|
||||
NULL,
|
||||
(GAsyncReadyCallback) send_tones_cb,
|
||||
self);
|
||||
|
||||
g_string_free (self->tone_queue, TRUE);
|
||||
self->tone_queue = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
self->sending_tones = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
tone_cb (CallsOfonoOrigin *self,
|
||||
gchar key)
|
||||
{
|
||||
const gchar key_str[2] = { key, '\0' };
|
||||
|
||||
if (self->sending_tones)
|
||||
{
|
||||
if (self->tone_queue)
|
||||
{
|
||||
g_string_append_c (self->tone_queue, key);
|
||||
}
|
||||
else
|
||||
{
|
||||
self->tone_queue = g_string_new (key_str);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_debug ("Sending immediate DTMF tone `%c'", key);
|
||||
|
||||
gdbo_voice_call_manager_call_send_tones
|
||||
(self->voice,
|
||||
key_str,
|
||||
NULL,
|
||||
(GAsyncReadyCallback) send_tones_cb,
|
||||
self);
|
||||
|
||||
self->sending_tones = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
voice_call_proxy_new_cb (GDBusConnection *connection,
|
||||
GAsyncResult *res,
|
||||
struct CallsVoiceCallProxyNewData *data)
|
||||
{
|
||||
CallsOfonoOrigin *self = data->self;
|
||||
GDBOVoiceCall *voice_call;
|
||||
GError *error = NULL;
|
||||
const gchar *path;
|
||||
CallsOfonoCall *call;
|
||||
|
||||
voice_call = gdbo_voice_call_proxy_new_finish (res, &error);
|
||||
if (!voice_call)
|
||||
{
|
||||
g_variant_unref (data->properties);
|
||||
g_free (data);
|
||||
g_warning ("Error creating oFono VoiceCall proxy: %s",
|
||||
error->message);
|
||||
CALLS_ERROR (self, error);
|
||||
return;
|
||||
}
|
||||
|
||||
call = calls_ofono_call_new (voice_call, data->properties);
|
||||
g_signal_connect_swapped (call, "tone",
|
||||
G_CALLBACK (tone_cb), self);
|
||||
|
||||
path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (voice_call));
|
||||
g_hash_table_insert (self->calls, g_strdup(path), call);
|
||||
|
||||
g_signal_emit_by_name (CALLS_ORIGIN(self), "call-added",
|
||||
CALLS_CALL(call));
|
||||
|
||||
g_debug ("Call `%s' added", path);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
call_added_cb (GDBOVoiceCallManager *voice,
|
||||
const gchar *path,
|
||||
GVariant *properties,
|
||||
CallsOfonoOrigin *self)
|
||||
{
|
||||
struct CallsVoiceCallProxyNewData *data;
|
||||
|
||||
g_debug ("Adding call `%s'", path);
|
||||
|
||||
if (g_hash_table_lookup (self->calls, path))
|
||||
{
|
||||
g_warning ("Call `%s' already exists", path);
|
||||
return;
|
||||
}
|
||||
|
||||
data = g_new0 (struct CallsVoiceCallProxyNewData, 1);
|
||||
data->self = self;
|
||||
data->properties = properties;
|
||||
g_variant_ref (properties);
|
||||
|
||||
gdbo_voice_call_proxy_new
|
||||
(self->connection,
|
||||
G_DBUS_PROXY_FLAGS_NONE,
|
||||
g_dbus_proxy_get_name (G_DBUS_PROXY (voice)),
|
||||
path,
|
||||
NULL,
|
||||
(GAsyncReadyCallback) voice_call_proxy_new_cb,
|
||||
data);
|
||||
|
||||
g_debug ("Call `%s' addition in progress", path);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
call_removed_cb (GDBOVoiceCallManager *voice,
|
||||
const gchar *path,
|
||||
CallsOfonoOrigin *self)
|
||||
{
|
||||
CallsOfonoCall *ofono_call;
|
||||
GString *reason;
|
||||
const gchar *ofono_reason;
|
||||
|
||||
g_debug ("Removing call `%s'", path);
|
||||
|
||||
ofono_call = g_hash_table_lookup (self->calls, path);
|
||||
if (!ofono_call)
|
||||
{
|
||||
g_warning ("Could not find removed call `%s'", path);
|
||||
return;
|
||||
}
|
||||
|
||||
reason = g_string_new ("Call removed");
|
||||
|
||||
ofono_reason = calls_ofono_call_get_disconnect_reason (ofono_call);
|
||||
if (ofono_reason)
|
||||
{
|
||||
/* The oFono reason is either "local", "remote" or "network".
|
||||
* We just capitalise that to create a nice reason string.
|
||||
*/
|
||||
g_string_assign (reason, ofono_reason);
|
||||
reason->str[0] = g_ascii_toupper (reason->str[0]);
|
||||
g_string_append (reason, " disconnection");
|
||||
}
|
||||
|
||||
remove_call (self, ofono_call, reason->str);
|
||||
|
||||
g_string_free (reason, TRUE);
|
||||
|
||||
g_debug ("Removed call `%s'", path);
|
||||
}
|
||||
|
||||
static void
|
||||
get_calls_cb (GDBOVoiceCallManager *voice,
|
||||
GAsyncResult *res,
|
||||
CallsOfonoOrigin *self)
|
||||
{
|
||||
gboolean ok;
|
||||
GVariant *calls_with_properties = NULL;
|
||||
GError *error = NULL;
|
||||
GVariantIter *iter = NULL;
|
||||
const gchar *path;
|
||||
GVariant *properties;
|
||||
|
||||
ok = gdbo_voice_call_manager_call_get_calls_finish
|
||||
(voice, &calls_with_properties, res, &error);
|
||||
if (!ok)
|
||||
{
|
||||
g_warning ("Error getting calls from oFono"
|
||||
" VoiceCallManager `%s': %s",
|
||||
self->name, error->message);
|
||||
CALLS_ERROR (self, error);
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
char *text = g_variant_print (calls_with_properties, TRUE);
|
||||
g_debug ("Received calls from oFono"
|
||||
" VoiceCallManager `%s': %s",
|
||||
self->name, text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
g_variant_get (calls_with_properties, "a(oa{sv})", &iter);
|
||||
while (g_variant_iter_loop (iter, "(&o@a{sv})",
|
||||
&path, &properties))
|
||||
{
|
||||
g_debug ("Got call object path `%s'", path);
|
||||
call_added_cb (voice, path, properties, self);
|
||||
}
|
||||
g_variant_iter_free (iter);
|
||||
|
||||
g_variant_unref (calls_with_properties);
|
||||
}
|
||||
|
||||
static void
|
||||
voice_new_cb (GDBusConnection *connection,
|
||||
GAsyncResult *res,
|
||||
CallsOfonoOrigin *self)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
self->voice = gdbo_voice_call_manager_proxy_new_finish
|
||||
(res, &error);
|
||||
if (!self->voice)
|
||||
{
|
||||
g_warning ("Error creating oFono"
|
||||
" VoiceCallManager `%s' proxy: %s",
|
||||
self->name, error->message);
|
||||
CALLS_ERROR (self, error);
|
||||
return;
|
||||
}
|
||||
|
||||
g_signal_connect (self->voice, "call-added",
|
||||
G_CALLBACK (call_added_cb), self);
|
||||
g_signal_connect (self->voice, "call-removed",
|
||||
G_CALLBACK (call_removed_cb), self);
|
||||
|
||||
gdbo_voice_call_manager_call_get_calls
|
||||
(self->voice,
|
||||
NULL,
|
||||
(GAsyncReadyCallback) get_calls_cb,
|
||||
self);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
constructed (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsOfonoOrigin *self = CALLS_OFONO_ORIGIN (object);
|
||||
GDBusProxy *modem_proxy;
|
||||
gchar *name;
|
||||
|
||||
g_return_if_fail (self->modem != NULL);
|
||||
|
||||
modem_proxy = G_DBUS_PROXY (self->modem);
|
||||
|
||||
self->connection = g_dbus_proxy_get_connection (modem_proxy);
|
||||
g_object_ref (self->connection);
|
||||
|
||||
name = g_object_get_data (G_OBJECT (self->modem),
|
||||
"calls-modem-name");
|
||||
if (name)
|
||||
{
|
||||
self->name = g_strdup (name);
|
||||
}
|
||||
|
||||
gdbo_voice_call_manager_proxy_new
|
||||
(self->connection,
|
||||
G_DBUS_PROXY_FLAGS_NONE,
|
||||
g_dbus_proxy_get_name (modem_proxy),
|
||||
g_dbus_proxy_get_object_path (modem_proxy),
|
||||
NULL,
|
||||
(GAsyncReadyCallback)voice_new_cb,
|
||||
self);
|
||||
|
||||
g_clear_object (&self->modem);
|
||||
|
||||
parent_class->constructed (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dispose (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsOfonoOrigin *self = CALLS_OFONO_ORIGIN (object);
|
||||
|
||||
remove_calls (self, NULL);
|
||||
g_clear_object (&self->modem);
|
||||
g_clear_object (&self->connection);
|
||||
|
||||
parent_class->dispose (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsOfonoOrigin *self = CALLS_OFONO_ORIGIN (object);
|
||||
|
||||
if (self->tone_queue)
|
||||
{
|
||||
g_string_free (self->tone_queue, TRUE);
|
||||
}
|
||||
g_free (self->name);
|
||||
|
||||
parent_class->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_ofono_origin_class_init (CallsOfonoOriginClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->set_property = set_property;
|
||||
object_class->constructed = constructed;
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
props[PROP_MODEM] =
|
||||
g_param_spec_object ("modem",
|
||||
_("Modem"),
|
||||
_("A GDBO proxy object for the underlying modem object"),
|
||||
GDBO_TYPE_MODEM,
|
||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_ofono_origin_message_source_interface_init (CallsOriginInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_ofono_origin_origin_interface_init (CallsOriginInterface *iface)
|
||||
{
|
||||
iface->get_name = get_name;
|
||||
iface->get_calls = get_calls;
|
||||
iface->dial = dial;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_ofono_origin_init (CallsOfonoOrigin *self)
|
||||
{
|
||||
self->calls = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, g_object_unref);
|
||||
}
|
||||
42
plugins/ofono/calls-ofono-origin.h
Normal file
42
plugins/ofono/calls-ofono-origin.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CALLS_OFONO_ORIGIN_H__
|
||||
#define CALLS_OFONO_ORIGIN_H__
|
||||
|
||||
#include <libgdbofono/gdbo-modem.h>
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CALLS_TYPE_OFONO_ORIGIN (calls_ofono_origin_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (CallsOfonoOrigin, calls_ofono_origin, CALLS, OFONO_ORIGIN, GObject);
|
||||
|
||||
CallsOfonoOrigin *calls_ofono_origin_new (GDBOModem *modem);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* CALLS_OFONO_ORIGIN_H__ */
|
||||
497
plugins/ofono/calls-ofono-provider.c
Normal file
497
plugins/ofono/calls-ofono-provider.c
Normal file
@@ -0,0 +1,497 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#include "calls-ofono-provider.h"
|
||||
#include "calls-provider.h"
|
||||
#include "calls-ofono-origin.h"
|
||||
#include "calls-message-source.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <libgdbofono/gdbo-manager.h>
|
||||
#include <libgdbofono/gdbo-modem.h>
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <libpeas/peas.h>
|
||||
|
||||
|
||||
struct _CallsOfonoProvider
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
/** D-Bus connection */
|
||||
GDBusConnection *connection;
|
||||
/** D-Bus proxy for the oFono Manager object */
|
||||
GDBOManager *manager;
|
||||
/** Map of D-Bus object paths to a struct CallsModemData */
|
||||
GHashTable *modems;
|
||||
/** Map of D-Bus object paths to Origins */
|
||||
GHashTable *origins;
|
||||
};
|
||||
|
||||
|
||||
static void calls_ofono_provider_message_source_interface_init (CallsProviderInterface *iface);
|
||||
static void calls_ofono_provider_provider_interface_init (CallsProviderInterface *iface);
|
||||
|
||||
|
||||
G_DEFINE_DYNAMIC_TYPE_EXTENDED
|
||||
(CallsOfonoProvider, calls_ofono_provider, G_TYPE_OBJECT, 0,
|
||||
G_IMPLEMENT_INTERFACE_DYNAMIC (CALLS_TYPE_MESSAGE_SOURCE,
|
||||
calls_ofono_provider_message_source_interface_init)
|
||||
G_IMPLEMENT_INTERFACE_DYNAMIC (CALLS_TYPE_PROVIDER,
|
||||
calls_ofono_provider_provider_interface_init))
|
||||
|
||||
|
||||
static const gchar *
|
||||
get_name (CallsProvider *iface)
|
||||
{
|
||||
return "oFono";
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
add_origin_to_list (const gchar *path,
|
||||
CallsOfonoOrigin *origin,
|
||||
GList **list)
|
||||
{
|
||||
*list = g_list_prepend (*list, origin);
|
||||
}
|
||||
|
||||
|
||||
static GList *
|
||||
get_origins (CallsProvider *iface)
|
||||
{
|
||||
CallsOfonoProvider *self = CALLS_OFONO_PROVIDER (iface);
|
||||
GList *list = NULL;
|
||||
|
||||
g_hash_table_foreach (self->origins,
|
||||
(GHFunc)add_origin_to_list, &list);
|
||||
|
||||
return g_list_reverse (list);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
add_origin (CallsOfonoProvider *self,
|
||||
const gchar *path,
|
||||
GDBOModem *modem)
|
||||
{
|
||||
CallsOfonoOrigin *origin;
|
||||
|
||||
g_debug ("Adding oFono Origin with path `%s'", path);
|
||||
|
||||
origin = calls_ofono_origin_new (modem);
|
||||
g_hash_table_insert (self->origins, g_strdup(path), origin);
|
||||
|
||||
g_signal_emit_by_name (CALLS_PROVIDER (self),
|
||||
"origin-added", origin);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
remove_origin (CallsOfonoProvider *self,
|
||||
const gchar *path,
|
||||
CallsOfonoOrigin *origin)
|
||||
{
|
||||
g_debug ("Removing oFono Origin with path `%s'", path);
|
||||
|
||||
g_signal_emit_by_name (CALLS_PROVIDER (self),
|
||||
"origin-removed", origin);
|
||||
|
||||
g_hash_table_remove (self->origins, path);
|
||||
g_object_unref (origin);
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
object_array_includes (GVariantIter *iter,
|
||||
const gchar *needle)
|
||||
{
|
||||
const gchar *str;
|
||||
gboolean found = FALSE;
|
||||
while (g_variant_iter_loop (iter, "&s", &str))
|
||||
{
|
||||
if (g_strcmp0 (str, needle) == 0)
|
||||
{
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_variant_iter_free (iter);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
modem_check_ifaces (CallsOfonoProvider *self,
|
||||
GDBOModem *modem,
|
||||
const gchar *modem_name,
|
||||
GVariant *ifaces)
|
||||
{
|
||||
gboolean voice;
|
||||
GVariantIter *iter = NULL;
|
||||
const gchar *path;
|
||||
CallsOfonoOrigin *origin;
|
||||
|
||||
g_variant_get (ifaces, "as", &iter);
|
||||
|
||||
voice = object_array_includes
|
||||
(iter, "org.ofono.VoiceCallManager");
|
||||
|
||||
path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (modem));
|
||||
origin = g_hash_table_lookup (self->origins, path);
|
||||
|
||||
if (voice && !origin)
|
||||
{
|
||||
add_origin (self, path, modem);
|
||||
}
|
||||
else if (!voice && origin)
|
||||
{
|
||||
remove_origin (self, path, origin);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
modem_property_changed_cb (GDBOModem *modem,
|
||||
const gchar *name,
|
||||
GVariant *value,
|
||||
CallsOfonoProvider *self)
|
||||
{
|
||||
gchar *modem_name;
|
||||
|
||||
g_debug ("Modem property `%s' changed", name);
|
||||
|
||||
if (g_strcmp0 (name, "Interfaces") != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
modem_name = g_object_get_data (G_OBJECT (modem),
|
||||
"calls-modem-name");
|
||||
|
||||
modem_check_ifaces (self, modem, modem_name, value);
|
||||
}
|
||||
|
||||
|
||||
struct CallsModemProxyNewData
|
||||
{
|
||||
CallsOfonoProvider *self;
|
||||
gchar *name;
|
||||
GVariant *ifaces;
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
modem_proxy_new_cb (GDBusConnection *connection,
|
||||
GAsyncResult *res,
|
||||
struct CallsModemProxyNewData *data)
|
||||
{
|
||||
GDBOModem *modem;
|
||||
GError *error = NULL;
|
||||
const gchar *path;
|
||||
|
||||
modem = gdbo_modem_proxy_new_finish (res, &error);
|
||||
if (!modem)
|
||||
{
|
||||
g_variant_unref (data->ifaces);
|
||||
g_free (data->name);
|
||||
g_free (data);
|
||||
g_error ("Error creating oFono Modem proxy: %s",
|
||||
error->message);
|
||||
return;
|
||||
}
|
||||
|
||||
g_signal_connect (modem, "property-changed",
|
||||
G_CALLBACK (modem_property_changed_cb),
|
||||
data->self);
|
||||
|
||||
|
||||
/* We want to store the oFono modem's Name property so we can pass it
|
||||
to our Origin when we create it */
|
||||
g_object_set_data_full (G_OBJECT (modem), "calls-modem-name",
|
||||
data->name, g_free);
|
||||
|
||||
path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (modem));
|
||||
|
||||
g_hash_table_insert (data->self->modems, g_strdup(path), modem);
|
||||
|
||||
|
||||
if (data->ifaces)
|
||||
{
|
||||
modem_check_ifaces (data->self, modem,
|
||||
data->name, data->ifaces);
|
||||
g_variant_unref (data->ifaces);
|
||||
}
|
||||
|
||||
g_free (data);
|
||||
|
||||
g_debug ("Modem `%s' added", path);
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
modem_properties_get_name (GVariant *properties)
|
||||
{
|
||||
gchar *name = NULL;
|
||||
gboolean ok;
|
||||
|
||||
#define try(prop) \
|
||||
ok = g_variant_lookup (properties, prop, "s", &name); \
|
||||
if (ok) { \
|
||||
return name; \
|
||||
}
|
||||
|
||||
try ("Name");
|
||||
try ("Model");
|
||||
try ("Manufacturer");
|
||||
try ("Serial");
|
||||
try ("SystemPath");
|
||||
|
||||
#undef try
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
modem_added_cb (GDBOManager *manager,
|
||||
const gchar *path,
|
||||
GVariant *properties,
|
||||
CallsOfonoProvider *self)
|
||||
{
|
||||
struct CallsModemProxyNewData *data;
|
||||
|
||||
g_debug ("Adding modem `%s'", path);
|
||||
|
||||
if (g_hash_table_lookup (self->modems, path))
|
||||
{
|
||||
g_warning ("Modem `%s' already exists", path);
|
||||
return;
|
||||
}
|
||||
|
||||
data = g_new0 (struct CallsModemProxyNewData, 1);
|
||||
data->self = self;
|
||||
data->name = modem_properties_get_name (properties);
|
||||
|
||||
data->ifaces = g_variant_lookup_value
|
||||
(properties, "Interfaces", G_VARIANT_TYPE_ARRAY);
|
||||
if (data->ifaces)
|
||||
{
|
||||
g_variant_ref (data->ifaces);
|
||||
}
|
||||
|
||||
gdbo_modem_proxy_new
|
||||
(self->connection,
|
||||
G_DBUS_PROXY_FLAGS_NONE,
|
||||
g_dbus_proxy_get_name (G_DBUS_PROXY (manager)),
|
||||
path,
|
||||
NULL,
|
||||
(GAsyncReadyCallback) modem_proxy_new_cb,
|
||||
data);
|
||||
|
||||
g_debug ("Modem `%s' addition in progress", path);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
modem_removed_cb (GDBOManager *manager,
|
||||
const gchar *path,
|
||||
CallsOfonoProvider *self)
|
||||
{
|
||||
CallsOfonoOrigin *origin;
|
||||
|
||||
g_debug ("Removing modem `%s'", path);
|
||||
|
||||
origin = g_hash_table_lookup (self->origins, path);
|
||||
if (origin)
|
||||
{
|
||||
remove_origin (self, path, origin);
|
||||
}
|
||||
|
||||
g_hash_table_remove (self->modems, path);
|
||||
|
||||
g_debug ("Modem `%s' removed", path);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
get_modems_cb (GDBOManager *manager,
|
||||
GAsyncResult *res,
|
||||
CallsOfonoProvider *self)
|
||||
{
|
||||
gboolean ok;
|
||||
GVariant *modems;
|
||||
GVariantIter *modems_iter = NULL;
|
||||
GError *error = NULL;
|
||||
const gchar *path;
|
||||
GVariant *properties;
|
||||
|
||||
ok = gdbo_manager_call_get_modems_finish (manager, &modems,
|
||||
res, &error);
|
||||
if (!ok)
|
||||
{
|
||||
g_warning ("Error getting modems from oFono Manager: %s",
|
||||
error->message);
|
||||
CALLS_ERROR (self, error);
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
char *text = g_variant_print (modems, TRUE);
|
||||
g_debug ("Received modems from oFono Manager: %s", text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
g_variant_get (modems, "a(oa{sv})", &modems_iter);
|
||||
while (g_variant_iter_loop (modems_iter, "(&o@a{sv})",
|
||||
&path, &properties))
|
||||
{
|
||||
g_debug ("Got modem object path `%s'", path);
|
||||
modem_added_cb (manager, path, properties, self);
|
||||
}
|
||||
g_variant_iter_free (modems_iter);
|
||||
|
||||
g_variant_unref (modems);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
constructed (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsOfonoProvider *self = CALLS_OFONO_PROVIDER (object);
|
||||
GError *error = NULL;
|
||||
|
||||
self->connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||
if (!self->connection)
|
||||
{
|
||||
g_error ("Error creating D-Bus connection: %s",
|
||||
error->message);
|
||||
}
|
||||
|
||||
self->manager = gdbo_manager_proxy_new_sync
|
||||
(self->connection,
|
||||
G_DBUS_PROXY_FLAGS_NONE,
|
||||
"org.ofono",
|
||||
"/",
|
||||
NULL,
|
||||
&error);
|
||||
if (!self->manager)
|
||||
{
|
||||
g_error ("Error creating ModemManager object manager proxy: %s",
|
||||
error->message);
|
||||
}
|
||||
|
||||
g_signal_connect (self->manager, "modem-added",
|
||||
G_CALLBACK (modem_added_cb), self);
|
||||
g_signal_connect (self->manager, "modem-removed",
|
||||
G_CALLBACK (modem_removed_cb), self);
|
||||
|
||||
gdbo_manager_call_get_modems
|
||||
(self->manager,
|
||||
NULL,
|
||||
(GAsyncReadyCallback) get_modems_cb,
|
||||
self);
|
||||
|
||||
parent_class->constructed (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dispose (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsOfonoProvider *self = CALLS_OFONO_PROVIDER (object);
|
||||
|
||||
g_clear_object (&self->manager);
|
||||
g_clear_object (&self->connection);
|
||||
|
||||
parent_class->dispose (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsOfonoProvider *self = CALLS_OFONO_PROVIDER (object);
|
||||
|
||||
g_hash_table_unref (self->origins);
|
||||
g_hash_table_unref (self->modems);
|
||||
|
||||
parent_class->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_ofono_provider_class_init (CallsOfonoProviderClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->constructed = constructed;
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_ofono_provider_class_finalize (CallsOfonoProviderClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_ofono_provider_message_source_interface_init (CallsProviderInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_ofono_provider_provider_interface_init (CallsProviderInterface *iface)
|
||||
{
|
||||
iface->get_name = get_name;
|
||||
iface->get_origins = get_origins;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_ofono_provider_init (CallsOfonoProvider *self)
|
||||
{
|
||||
self->modems = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, g_object_unref);
|
||||
self->origins = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, NULL);
|
||||
}
|
||||
|
||||
|
||||
G_MODULE_EXPORT void
|
||||
peas_register_types (PeasObjectModule *module)
|
||||
{
|
||||
calls_ofono_provider_register_type (G_TYPE_MODULE (module));
|
||||
|
||||
peas_object_module_register_extension_type (module,
|
||||
CALLS_TYPE_PROVIDER,
|
||||
CALLS_TYPE_OFONO_PROVIDER);
|
||||
}
|
||||
39
plugins/ofono/calls-ofono-provider.h
Normal file
39
plugins/ofono/calls-ofono-provider.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CALLS_OFONO_PROVIDER_H__
|
||||
#define CALLS_OFONO_PROVIDER_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CALLS_TYPE_OFONO_PROVIDER (calls_ofono_provider_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (CallsOfonoProvider, calls_ofono_provider, CALLS, OFONO_PROVIDER, GObject);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* CALLS_OFONO_PROVIDER_H__ */
|
||||
12
plugins/ofono/libgdbofono/call.xml
Normal file
12
plugins/ofono/libgdbofono/call.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
|
||||
<interface name="org.ofono.VoiceCall"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="Deflect"><arg name="number" type="s" direction="in"/>
|
||||
</method><method name="Hangup"></method><method name="Answer"></method><signal name="PropertyChanged"><arg name="name" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
<signal name="DisconnectReason"><arg name="reason" type="s"/>
|
||||
</signal>
|
||||
</interface></node>
|
||||
11
plugins/ofono/libgdbofono/dbus-introspect.sh
Executable file
11
plugins/ofono/libgdbofono/dbus-introspect.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
DEST="$1"
|
||||
OBJ_PATH="$2"
|
||||
METHOD="$3"
|
||||
shift 3
|
||||
|
||||
dbus-send "$@" --print-reply --dest="$DEST" "$OBJ_PATH" "$METHOD" | \
|
||||
grep -v '^method return' | \
|
||||
sed -e 's/^[[:space:]]\+string "</</' \
|
||||
-e 's_</node>"_</node>_'
|
||||
13
plugins/ofono/libgdbofono/manager.xml
Normal file
13
plugins/ofono/libgdbofono/manager.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
|
||||
<interface name="org.ofono.Manager"><method name="GetModems"><arg name="modems" type="a(oa{sv})" direction="out"/>
|
||||
</method><signal name="ModemAdded"><arg name="path" type="o"/>
|
||||
<arg name="properties" type="a{sv}"/>
|
||||
</signal>
|
||||
<signal name="ModemRemoved"><arg name="path" type="o"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
</node>
|
||||
51
plugins/ofono/libgdbofono/meson.build
Normal file
51
plugins/ofono/libgdbofono/meson.build
Normal file
@@ -0,0 +1,51 @@
|
||||
#
|
||||
# Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
|
||||
|
||||
gnome = import('gnome')
|
||||
dbus_interfaces = ['manager', 'modem', 'call']
|
||||
|
||||
gdbofono_src = []
|
||||
gdbofono_headers = []
|
||||
foreach iface: dbus_interfaces
|
||||
src = gnome.gdbus_codegen(
|
||||
'gdbo-' + iface,
|
||||
iface + '.xml',
|
||||
interface_prefix: 'org.ofono.',
|
||||
namespace: 'GDBO'
|
||||
)
|
||||
gdbofono_src += src
|
||||
gdbofono_headers += src[1]
|
||||
endforeach
|
||||
|
||||
gdbofono_deps = [
|
||||
dependency('gio-2.0'),
|
||||
dependency('gio-unix-2.0'),
|
||||
]
|
||||
|
||||
gdbofono_lib = static_library(
|
||||
'gdbofono',
|
||||
gdbofono_src,
|
||||
include_directories: top_include,
|
||||
dependencies: gdbofono_deps
|
||||
)
|
||||
249
plugins/ofono/libgdbofono/modem-full.xml
Normal file
249
plugins/ofono/libgdbofono/modem-full.xml
Normal file
@@ -0,0 +1,249 @@
|
||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
|
||||
<interface name="org.ofono.Modem"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="SetProperty"><arg name="property" type="s" direction="in"/>
|
||||
<arg name="value" type="v" direction="in"/>
|
||||
</method><signal name="PropertyChanged"><arg name="name" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="org.ofono.SimManager"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="SetProperty"><arg name="property" type="s" direction="in"/>
|
||||
<arg name="value" type="v" direction="in"/>
|
||||
</method><method name="ChangePin"><arg name="type" type="s" direction="in"/>
|
||||
<arg name="oldpin" type="s" direction="in"/>
|
||||
<arg name="newpin" type="s" direction="in"/>
|
||||
</method><method name="EnterPin"><arg name="type" type="s" direction="in"/>
|
||||
<arg name="pin" type="s" direction="in"/>
|
||||
</method><method name="ResetPin"><arg name="type" type="s" direction="in"/>
|
||||
<arg name="puk" type="s" direction="in"/>
|
||||
<arg name="newpin" type="s" direction="in"/>
|
||||
</method><method name="LockPin"><arg name="type" type="s" direction="in"/>
|
||||
<arg name="pin" type="s" direction="in"/>
|
||||
</method><method name="UnlockPin"><arg name="type" type="s" direction="in"/>
|
||||
<arg name="pin" type="s" direction="in"/>
|
||||
</method><method name="GetIcon"><arg name="id" type="y" direction="in"/>
|
||||
<arg name="icon" type="ay" direction="out"/>
|
||||
</method><signal name="PropertyChanged"><arg name="name" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="org.ofono.VoiceCallManager"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="Dial"><arg name="number" type="s" direction="in"/>
|
||||
<arg name="hide_callerid" type="s" direction="in"/>
|
||||
<arg name="path" type="o" direction="out"/>
|
||||
</method><method name="DialLast"></method><method name="DialMemory"><arg name="memory_location" type="u" direction="in"/>
|
||||
</method><method name="Transfer"></method><method name="SwapCalls"></method><method name="ReleaseAndAnswer"></method><method name="ReleaseAndSwap"></method><method name="HoldAndAnswer"></method><method name="HangupAll"></method><method name="PrivateChat"><arg name="call" type="o" direction="in"/>
|
||||
<arg name="calls" type="ao" direction="out"/>
|
||||
</method><method name="CreateMultiparty"><arg name="calls" type="ao" direction="out"/>
|
||||
</method><method name="HangupMultiparty"></method><method name="SendTones"><arg name="SendTones" type="s" direction="in"/>
|
||||
</method><method name="GetCalls"><arg name="calls_with_properties" type="a(oa{sv})" direction="out"/>
|
||||
</method><signal name="Forwarded"><arg name="type" type="s"/>
|
||||
</signal>
|
||||
<signal name="BarringActive"><arg name="type" type="s"/>
|
||||
</signal>
|
||||
<signal name="PropertyChanged"><arg name="name" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
<signal name="CallAdded"><arg name="path" type="o"/>
|
||||
<arg name="properties" type="a{sv}"/>
|
||||
</signal>
|
||||
<signal name="CallRemoved"><arg name="path" type="o"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="org.ofono.AllowedAccessPoints"><method name="GetAllowedAccessPoints"><arg name="apnlist" type="as" direction="out"/>
|
||||
</method></interface>
|
||||
|
||||
<interface name="org.ofono.SimAuthentication"><method name="GetApplications"><arg name="applications" type="a{oa{sv}}" direction="out"/>
|
||||
</method><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method></interface>
|
||||
|
||||
<interface name="org.ofono.SimToolkit"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="SelectItem"><arg name="item" type="y" direction="in"/>
|
||||
<arg name="agent" type="o" direction="in"/>
|
||||
</method><method name="RegisterAgent"><arg name="path" type="o" direction="in"/>
|
||||
</method><method name="UnregisterAgent"><arg name="path" type="o" direction="in"/>
|
||||
</method><signal name="PropertyChanged"><arg name="name" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="org.ofono.CallForwarding"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="SetProperty"><arg name="property" type="s" direction="in"/>
|
||||
<arg name="value" type="v" direction="in"/>
|
||||
</method><method name="DisableAll"><arg name="type" type="s" direction="in"/>
|
||||
</method><signal name="PropertyChanged"><arg name="name" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="org.ofono.RadioSettings"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="SetProperty"><arg name="property" type="s" direction="in"/>
|
||||
<arg name="value" type="v" direction="in"/>
|
||||
</method><signal name="PropertyChanged"><arg name="name" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="org.ofono.TextTelephony"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="SetProperty"><arg name="property" type="s" direction="in"/>
|
||||
<arg name="value" type="v" direction="in"/>
|
||||
</method><signal name="PropertyChanged"><arg name="name" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="org.ofono.Phonebook"><method name="Import"><arg name="entries" type="s" direction="out"/>
|
||||
</method></interface>
|
||||
|
||||
<interface name="org.ofono.MessageManager"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="SetProperty"><arg name="property" type="s" direction="in"/>
|
||||
<arg name="value" type="v" direction="in"/>
|
||||
</method><method name="SendMessage"><arg name="to" type="s" direction="in"/>
|
||||
<arg name="text" type="s" direction="in"/>
|
||||
<arg name="path" type="o" direction="out"/>
|
||||
</method><method name="GetMessages"><arg name="messages" type="a(oa{sv})" direction="out"/>
|
||||
</method><signal name="PropertyChanged"><arg name="name" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
<signal name="IncomingMessage"><arg name="message" type="s"/>
|
||||
<arg name="info" type="a{sv}"/>
|
||||
</signal>
|
||||
<signal name="ImmediateMessage"><arg name="message" type="s"/>
|
||||
<arg name="info" type="a{sv}"/>
|
||||
</signal>
|
||||
<signal name="MessageAdded"><arg name="path" type="o"/>
|
||||
<arg name="properties" type="a{sv}"/>
|
||||
</signal>
|
||||
<signal name="MessageRemoved"><arg name="path" type="o"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="org.ofono.PushNotification"><method name="RegisterAgent"><arg name="path" type="o" direction="in"/>
|
||||
</method><method name="UnregisterAgent"><arg name="path" type="o" direction="in"/>
|
||||
</method></interface>
|
||||
|
||||
<interface name="org.ofono.SmartMessaging"><method name="RegisterAgent"><arg name="path" type="o" direction="in"/>
|
||||
</method><method name="UnregisterAgent"><arg name="path" type="o" direction="in"/>
|
||||
</method><method name="SendBusinessCard"><arg name="to" type="s" direction="in"/>
|
||||
<arg name="card" type="ay" direction="in"/>
|
||||
<arg name="path" type="o" direction="out"/>
|
||||
</method><method name="SendAppointment"><arg name="to" type="s" direction="in"/>
|
||||
<arg name="appointment" type="ay" direction="in"/>
|
||||
<arg name="path" type="o" direction="out"/>
|
||||
</method></interface>
|
||||
|
||||
<interface name="org.ofono.MessageWaiting"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="SetProperty"><arg name="property" type="s" direction="in"/>
|
||||
<arg name="value" type="v" direction="in"/>
|
||||
</method><signal name="PropertyChanged"><arg name="name" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="org.ofono.CallSettings"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="SetProperty"><arg name="property" type="s" direction="in"/>
|
||||
<arg name="value" type="v" direction="in"/>
|
||||
</method><signal name="PropertyChanged"><arg name="property" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="org.ofono.CallBarring"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="SetProperty"><arg name="property" type="s" direction="in"/>
|
||||
<arg name="value" type="v" direction="in"/>
|
||||
<arg name="pin2" type="s" direction="in"/>
|
||||
</method><method name="DisableAll"><arg name="password" type="s" direction="in"/>
|
||||
</method><method name="DisableAllIncoming"><arg name="password" type="s" direction="in"/>
|
||||
</method><method name="DisableAllOutgoing"><arg name="password" type="s" direction="in"/>
|
||||
</method><method name="ChangePassword"><arg name="old" type="s" direction="in"/>
|
||||
<arg name="new" type="s" direction="in"/>
|
||||
</method><signal name="PropertyChanged"><arg name="name" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="org.ofono.SupplementaryServices"><method name="Initiate"><arg name="command" type="s" direction="in"/>
|
||||
<arg name="result_name" type="s" direction="out"/>
|
||||
<arg name="value" type="v" direction="out"/>
|
||||
</method><method name="Respond"><arg name="reply" type="s" direction="in"/>
|
||||
<arg name="result" type="s" direction="out"/>
|
||||
</method><method name="Cancel"></method><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><signal name="NotificationReceived"><arg name="message" type="s"/>
|
||||
</signal>
|
||||
<signal name="RequestReceived"><arg name="message" type="s"/>
|
||||
</signal>
|
||||
<signal name="PropertyChanged"><arg name="name" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="org.ofono.CallMeter"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="SetProperty"><arg name="property" type="s" direction="in"/>
|
||||
<arg name="value" type="v" direction="in"/>
|
||||
<arg name="password" type="s" direction="in"/>
|
||||
</method><method name="Reset"><arg name="passoword" type="s" direction="in"/>
|
||||
</method><signal name="PropertyChanged"><arg name="property" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
<signal name="NearMaximumWarning"></signal>
|
||||
</interface>
|
||||
|
||||
<interface name="org.ofono.CallVolume"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="SetProperty"><arg name="property" type="s" direction="in"/>
|
||||
<arg name="value" type="v" direction="in"/>
|
||||
</method><signal name="PropertyChanged"><arg name="property" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="org.ofono.NetworkRegistration"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="Register"></method><method name="GetOperators"><arg name="operators_with_properties" type="a(oa{sv})" direction="out"/>
|
||||
</method><method name="Scan"><arg name="operators_with_properties" type="a(oa{sv})" direction="out"/>
|
||||
</method><signal name="PropertyChanged"><arg name="name" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="org.ofono.CellBroadcast"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="SetProperty"><arg name="property" type="s" direction="in"/>
|
||||
<arg name="value" type="v" direction="in"/>
|
||||
</method><signal name="PropertyChanged"><arg name="property" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
<signal name="IncomingBroadcast"><arg name="message" type="s"/>
|
||||
<arg name="channel" type="q"/>
|
||||
</signal>
|
||||
<signal name="EmergencyBroadcast"><arg name="message" type="s"/>
|
||||
<arg name="dict" type="a{sv}"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="org.ofono.AssistedSatelliteNavigation"><method name="SendPositioningElement"><arg name="xml_elements" type="(null)" direction="in"/>
|
||||
</method><method name="RegisterPositioningRequestAgent"><arg name="agent" type="o" direction="in"/>
|
||||
</method><method name="UnregisterPositioningRequestAgent"><arg name="agent" type="o" direction="in"/>
|
||||
</method></interface>
|
||||
|
||||
<interface name="org.ofono.ConnectionManager"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="SetProperty"><arg name="property" type="s" direction="in"/>
|
||||
<arg name="value" type="v" direction="in"/>
|
||||
</method><method name="AddContext"><arg name="type" type="s" direction="in"/>
|
||||
<arg name="path" type="o" direction="out"/>
|
||||
</method><method name="RemoveContext"><arg name="path" type="o" direction="in"/>
|
||||
</method><method name="DeactivateAll"></method><method name="GetContexts"><arg name="contexts_with_properties" type="a(oa{sv})" direction="out"/>
|
||||
</method><method name="ResetContexts"></method><signal name="PropertyChanged"><arg name="name" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
<signal name="ContextAdded"><arg name="path" type="o"/>
|
||||
<arg name="properties" type="a{sv}"/>
|
||||
</signal>
|
||||
<signal name="ContextRemoved"><arg name="path" type="o"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
</node>
|
||||
37
plugins/ofono/libgdbofono/modem.xml
Normal file
37
plugins/ofono/libgdbofono/modem.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
|
||||
<interface name="org.ofono.Modem"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="SetProperty"><arg name="property" type="s" direction="in"/>
|
||||
<arg name="value" type="v" direction="in"/>
|
||||
</method><signal name="PropertyChanged"><arg name="name" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="org.ofono.VoiceCallManager"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
|
||||
</method><method name="Dial"><arg name="number" type="s" direction="in"/>
|
||||
<arg name="hide_callerid" type="s" direction="in"/>
|
||||
<arg name="path" type="o" direction="out"/>
|
||||
</method><method name="DialLast"></method><method name="DialMemory"><arg name="memory_location" type="u" direction="in"/>
|
||||
</method><method name="Transfer"></method><method name="SwapCalls"></method><method name="ReleaseAndAnswer"></method><method name="ReleaseAndSwap"></method><method name="HoldAndAnswer"></method><method name="HangupAll"></method><method name="PrivateChat"><arg name="call" type="o" direction="in"/>
|
||||
<arg name="calls" type="ao" direction="out"/>
|
||||
</method><method name="CreateMultiparty"><arg name="calls" type="ao" direction="out"/>
|
||||
</method><method name="HangupMultiparty"></method><method name="SendTones"><arg name="SendTones" type="s" direction="in"/>
|
||||
</method><method name="GetCalls"><arg name="calls_with_properties" type="a(oa{sv})" direction="out"/>
|
||||
</method><signal name="Forwarded"><arg name="type" type="s"/>
|
||||
</signal>
|
||||
<signal name="BarringActive"><arg name="type" type="s"/>
|
||||
</signal>
|
||||
<signal name="PropertyChanged"><arg name="name" type="s"/>
|
||||
<arg name="value" type="v"/>
|
||||
</signal>
|
||||
<signal name="CallAdded"><arg name="path" type="o"/>
|
||||
<arg name="properties" type="a{sv}"/>
|
||||
</signal>
|
||||
<signal name="CallRemoved"><arg name="path" type="o"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
</node>
|
||||
60
plugins/ofono/meson.build
Normal file
60
plugins/ofono/meson.build
Normal file
@@ -0,0 +1,60 @@
|
||||
#
|
||||
# Copyright (C) 2018 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: Bob Ham <bob.ham@puri.sm>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
|
||||
subdir('libgdbofono')
|
||||
|
||||
ofono_install_dir = join_paths(full_calls_plugin_libdir, 'ofono')
|
||||
|
||||
ofono_plugin = configure_file(
|
||||
input: 'ofono.plugin.in',
|
||||
output: 'ofono.plugin',
|
||||
configuration: config_data,
|
||||
install_dir: ofono_install_dir
|
||||
)
|
||||
|
||||
ofono_deps = [
|
||||
dependency('gobject-2.0'),
|
||||
dependency('gtk+-3.0'),
|
||||
dependency('libpeas-1.0'),
|
||||
]
|
||||
|
||||
ofono_sources = files(
|
||||
[
|
||||
'calls-ofono-call.c', 'calls-ofono-call.h',
|
||||
'calls-ofono-origin.c', 'calls-ofono-origin.h',
|
||||
'calls-ofono-provider.c', 'calls-ofono-provider.h'
|
||||
]
|
||||
)
|
||||
|
||||
shared_module(
|
||||
'ofono',
|
||||
ofono_sources, gdbofono_headers,
|
||||
dependencies: ofono_deps,
|
||||
include_directories: [
|
||||
src_include,
|
||||
include_directories('.')
|
||||
],
|
||||
link_with: gdbofono_lib,
|
||||
install: true,
|
||||
install_dir: ofono_install_dir
|
||||
)
|
||||
7
plugins/ofono/ofono.plugin.in
Normal file
7
plugins/ofono/ofono.plugin.in
Normal file
@@ -0,0 +1,7 @@
|
||||
[Plugin]
|
||||
Module=ofono
|
||||
Name=oFono
|
||||
Description=oFono calls provider
|
||||
Authors=Bob Ham <rah@settrans.net>
|
||||
Copyright=Copyright (C) 2018 Purism SPC
|
||||
Website=@PACKAGE_URL_RAW@
|
||||
Reference in New Issue
Block a user