2018-05-17 13:16:51 +00:00
|
|
|
/*
|
|
|
|
* 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-call.h"
|
|
|
|
#include "calls-message-source.h"
|
|
|
|
#include "enum-types.h"
|
2023-01-21 15:42:39 +00:00
|
|
|
#include "calls-util.h"
|
2018-05-17 13:16:51 +00:00
|
|
|
|
2019-06-28 08:59:02 +00:00
|
|
|
#include <glib/gi18n.h>
|
|
|
|
|
2018-05-17 13:16:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:calls-call
|
|
|
|
* @short_description: A call.
|
|
|
|
* @Title: CallsCall
|
2018-05-23 08:52:58 +00:00
|
|
|
*
|
2021-10-22 05:21:11 +00:00
|
|
|
* This is the interface to a call. It has a id, name and a
|
2018-05-23 08:52:58 +00:00
|
|
|
* state. Only the state changes after creation. If the state is
|
2022-01-18 03:47:19 +00:00
|
|
|
* #CALLS_CALL_STATE_INCOMING, the call can be answered with #calls_call_answer.
|
|
|
|
* The call can also be hung up at any time with #calls_call_hang_up.
|
2018-05-23 08:52:58 +00:00
|
|
|
*
|
2022-01-18 03:47:19 +00:00
|
|
|
* DTMF tones can be played to the call using #calls_call_send_dtmf_tone
|
2021-11-16 12:59:06 +00:00
|
|
|
* Valid characters for the key are 0-9, '*', '#', 'A',
|
2018-05-23 08:52:58 +00:00
|
|
|
* 'B', 'C' and 'D'.
|
2018-05-17 13:16:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
enum {
|
2021-04-05 04:00:10 +00:00
|
|
|
PROP_0,
|
|
|
|
PROP_INBOUND,
|
2021-10-22 05:21:11 +00:00
|
|
|
PROP_ID,
|
2021-04-05 04:00:10 +00:00
|
|
|
PROP_NAME,
|
|
|
|
PROP_STATE,
|
2021-04-26 10:00:02 +00:00
|
|
|
PROP_PROTOCOL,
|
2022-02-09 17:29:24 +00:00
|
|
|
PROP_CALL_TYPE,
|
2022-05-09 09:00:42 +00:00
|
|
|
PROP_ENCRYPTED,
|
2021-04-05 04:00:10 +00:00
|
|
|
N_PROPS,
|
2018-05-17 13:16:51 +00:00
|
|
|
};
|
|
|
|
|
2021-04-05 04:00:10 +00:00
|
|
|
enum {
|
|
|
|
STATE_CHANGED,
|
|
|
|
N_SIGNALS,
|
|
|
|
};
|
|
|
|
|
|
|
|
static GParamSpec *properties[N_PROPS];
|
|
|
|
static guint signals[N_SIGNALS];
|
|
|
|
|
2021-10-18 23:43:25 +00:00
|
|
|
typedef struct {
|
2022-04-24 10:24:55 +00:00
|
|
|
char *id;
|
|
|
|
char *name;
|
2021-12-10 08:02:39 +00:00
|
|
|
CallsCallState state;
|
2022-04-24 10:24:55 +00:00
|
|
|
gboolean inbound;
|
2022-05-09 09:00:42 +00:00
|
|
|
gboolean encrypted;
|
2022-04-24 10:24:55 +00:00
|
|
|
CallsCallType call_type;
|
2021-10-18 23:43:25 +00:00
|
|
|
} CallsCallPrivate;
|
|
|
|
|
|
|
|
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (CallsCall, calls_call, G_TYPE_OBJECT)
|
|
|
|
|
|
|
|
|
2021-04-26 10:00:02 +00:00
|
|
|
static const char *
|
|
|
|
calls_call_real_get_protocol (CallsCall *self)
|
|
|
|
{
|
2021-12-11 08:29:49 +00:00
|
|
|
return get_protocol_from_address_with_fallback (calls_call_get_id (self));
|
2021-04-26 10:00:02 +00:00
|
|
|
}
|
|
|
|
|
2021-04-05 04:00:10 +00:00
|
|
|
static void
|
|
|
|
calls_call_real_answer (CallsCall *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
calls_call_real_hang_up (CallsCall *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-11-16 12:59:06 +00:00
|
|
|
calls_call_real_send_dtmf_tone (CallsCall *self,
|
|
|
|
char key)
|
2021-04-05 04:00:10 +00:00
|
|
|
{
|
2021-11-16 13:06:02 +00:00
|
|
|
g_info ("Beep! (%c)", key);
|
2021-04-05 04:00:10 +00:00
|
|
|
}
|
2018-05-23 08:52:58 +00:00
|
|
|
|
2021-12-10 07:00:11 +00:00
|
|
|
static void
|
|
|
|
calls_call_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
CallsCall *self = CALLS_CALL (object);
|
|
|
|
CallsCallPrivate *priv = calls_call_get_instance_private (self);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_INBOUND:
|
|
|
|
priv->inbound = g_value_get_boolean (value);
|
2021-12-10 08:02:39 +00:00
|
|
|
if (priv->inbound)
|
|
|
|
calls_call_set_state (self, CALLS_CALL_STATE_INCOMING);
|
|
|
|
else
|
|
|
|
calls_call_set_state (self, CALLS_CALL_STATE_DIALING);
|
|
|
|
break;
|
|
|
|
|
2021-12-10 08:46:32 +00:00
|
|
|
case PROP_ID:
|
|
|
|
calls_call_set_id (self, g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
|
2021-12-11 08:24:57 +00:00
|
|
|
case PROP_NAME:
|
|
|
|
calls_call_set_name (self, g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
|
2021-12-10 08:02:39 +00:00
|
|
|
case PROP_STATE:
|
|
|
|
calls_call_set_state (self, g_value_get_enum (value));
|
2021-12-10 07:00:11 +00:00
|
|
|
break;
|
|
|
|
|
2022-02-09 17:29:24 +00:00
|
|
|
case PROP_CALL_TYPE:
|
|
|
|
priv->call_type = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
|
2022-05-09 09:00:42 +00:00
|
|
|
case PROP_ENCRYPTED:
|
|
|
|
calls_call_set_encrypted (self, g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
|
2021-12-10 07:00:11 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-05 04:00:10 +00:00
|
|
|
static void
|
|
|
|
calls_call_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
CallsCall *self = CALLS_CALL (object);
|
|
|
|
|
2021-12-10 06:02:15 +00:00
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_INBOUND:
|
|
|
|
g_value_set_boolean (value, calls_call_get_inbound (self));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_ID:
|
|
|
|
g_value_set_string (value, calls_call_get_id (self));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_NAME:
|
|
|
|
g_value_set_string (value, calls_call_get_name (self));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_STATE:
|
|
|
|
g_value_set_enum (value, calls_call_get_state (self));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_PROTOCOL:
|
|
|
|
g_value_set_string (value, calls_call_get_protocol (self));
|
|
|
|
break;
|
|
|
|
|
2022-02-09 17:29:24 +00:00
|
|
|
case PROP_CALL_TYPE:
|
|
|
|
g_value_set_enum (value, calls_call_get_call_type (self));
|
|
|
|
break;
|
|
|
|
|
2022-05-09 09:00:42 +00:00
|
|
|
case PROP_ENCRYPTED:
|
|
|
|
g_value_set_boolean (value, calls_call_get_encrypted (self));
|
|
|
|
break;
|
|
|
|
|
2021-12-10 06:02:15 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
}
|
2021-04-05 04:00:10 +00:00
|
|
|
}
|
|
|
|
|
2022-01-27 15:34:55 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
calls_call_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
CallsCallPrivate *priv = calls_call_get_instance_private (CALLS_CALL (object));
|
|
|
|
|
|
|
|
g_clear_pointer (&priv->id, g_free);
|
|
|
|
g_clear_pointer (&priv->name, g_free);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (calls_call_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2021-04-05 04:00:10 +00:00
|
|
|
static void
|
|
|
|
calls_call_class_init (CallsCallClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->get_property = calls_call_get_property;
|
2021-12-10 07:00:11 +00:00
|
|
|
object_class->set_property = calls_call_set_property;
|
2022-01-27 15:34:55 +00:00
|
|
|
object_class->dispose = calls_call_dispose;
|
2021-04-05 04:00:10 +00:00
|
|
|
|
2021-04-26 10:00:02 +00:00
|
|
|
klass->get_protocol = calls_call_real_get_protocol;
|
2021-04-05 04:00:10 +00:00
|
|
|
klass->answer = calls_call_real_answer;
|
|
|
|
klass->hang_up = calls_call_real_hang_up;
|
2021-11-16 12:59:06 +00:00
|
|
|
klass->send_dtmf_tone = calls_call_real_send_dtmf_tone;
|
2018-05-17 13:16:51 +00:00
|
|
|
|
2022-02-17 18:13:07 +00:00
|
|
|
/**
|
|
|
|
* CallsCall:inbound: (attributes org.gtk.Property.get=calls_call_get_inbound)
|
|
|
|
*
|
|
|
|
* %TRUE if the call is inbound, %FALSE otherwise.
|
|
|
|
*/
|
2021-04-05 04:00:10 +00:00
|
|
|
properties[PROP_INBOUND] =
|
2019-06-28 08:59:02 +00:00
|
|
|
g_param_spec_boolean ("inbound",
|
2020-05-29 05:38:11 +00:00
|
|
|
"Inbound",
|
|
|
|
"Whether the call is inbound",
|
2019-06-28 08:59:02 +00:00
|
|
|
FALSE,
|
2021-12-10 07:00:11 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
|
2020-02-22 23:55:45 +00:00
|
|
|
|
2022-02-17 18:13:07 +00:00
|
|
|
/**
|
|
|
|
* CallsCall:id: (attributes org.gtk.Property.get=calls_call_get_id org.gtk.Property.set=calls_call_set_id)
|
|
|
|
|
|
|
|
* Get the id (number, SIP address) the call is connected to. It is possible that this
|
|
|
|
* could return %NULL if the id is not known, for example if an
|
|
|
|
* incoming PTSN call has no caller ID information.
|
|
|
|
*/
|
2021-10-22 05:21:11 +00:00
|
|
|
properties[PROP_ID] =
|
|
|
|
g_param_spec_string ("id",
|
|
|
|
"Id",
|
|
|
|
"The id the call is connected to if known",
|
2020-05-29 05:38:11 +00:00
|
|
|
NULL,
|
2021-12-10 08:46:32 +00:00
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
G_PARAM_EXPLICIT_NOTIFY |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2020-02-22 23:55:45 +00:00
|
|
|
|
2022-02-17 18:13:07 +00:00
|
|
|
/**
|
|
|
|
* CallsCall:name: (attributes org.gtk.Property.get=calls_call_get_name org.gtk.Property.set=calls_call_set_name)
|
|
|
|
*
|
|
|
|
* The (network provided) name of the call. For the name of a contact, see #calls_best_match_get_name
|
|
|
|
*/
|
2021-04-05 04:00:10 +00:00
|
|
|
properties[PROP_NAME] =
|
2020-02-22 23:55:45 +00:00
|
|
|
g_param_spec_string ("name",
|
2020-05-29 05:38:11 +00:00
|
|
|
"Name",
|
|
|
|
"The name of the party the call is connected to, if the network provides it",
|
|
|
|
NULL,
|
2021-12-11 08:24:57 +00:00
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_EXPLICIT_NOTIFY |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2020-02-22 23:55:45 +00:00
|
|
|
|
2022-02-17 18:13:07 +00:00
|
|
|
/**
|
|
|
|
* CallsCall:state: (attributes org.gtk.Property.get=calls_call_get_state org.gtk.Property.set=calls_call_set_state)
|
|
|
|
*
|
|
|
|
* The state of the call or %CALLS_CALL_STATE_UNKNOWN if unknown.
|
|
|
|
*/
|
2021-04-05 04:00:10 +00:00
|
|
|
properties[PROP_STATE] =
|
2020-02-22 23:55:45 +00:00
|
|
|
g_param_spec_enum ("state",
|
2020-05-29 05:38:11 +00:00
|
|
|
"State",
|
|
|
|
"The current state of the call",
|
|
|
|
CALLS_TYPE_CALL_STATE,
|
2021-12-10 07:02:08 +00:00
|
|
|
CALLS_CALL_STATE_UNKNOWN,
|
2021-12-10 08:02:39 +00:00
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_EXPLICIT_NOTIFY |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2021-04-05 04:00:10 +00:00
|
|
|
|
2022-02-17 18:13:07 +00:00
|
|
|
/**
|
|
|
|
* CallsCall:protocol: (attributes org.gtk.Property.get=calls_call_get_protocol)
|
|
|
|
*
|
|
|
|
* The protocol for this call, f.e. tel or sip
|
|
|
|
*/
|
2021-04-26 10:00:02 +00:00
|
|
|
properties[PROP_PROTOCOL] =
|
|
|
|
g_param_spec_string ("protocol",
|
|
|
|
"Protocol",
|
|
|
|
"The protocol used for this call",
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2022-02-17 18:13:07 +00:00
|
|
|
/**
|
|
|
|
* CallsCall:call-type: (attributes org.gtk.Property.get=calls_call_get_call_type)
|
|
|
|
*
|
|
|
|
* The type of this call or #CALLS_CALL_TYPE_UNKNOWN if unknown
|
|
|
|
*/
|
2022-02-09 17:29:24 +00:00
|
|
|
properties[PROP_CALL_TYPE] =
|
|
|
|
g_param_spec_enum ("call-type",
|
|
|
|
"Call type",
|
|
|
|
"The type of call (f.e. cellular, sip voice)",
|
|
|
|
CALLS_TYPE_CALL_TYPE,
|
|
|
|
CALLS_CALL_TYPE_UNKNOWN,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2022-05-09 09:00:42 +00:00
|
|
|
/**
|
|
|
|
* CallsCall:encrypted:
|
|
|
|
*
|
|
|
|
* If the call is encrypted
|
|
|
|
*/
|
|
|
|
|
|
|
|
properties[PROP_ENCRYPTED] =
|
|
|
|
g_param_spec_boolean ("encrypted",
|
|
|
|
"encrypted",
|
|
|
|
"If the call is encrypted",
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2021-04-05 04:00:10 +00:00
|
|
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
2019-06-28 08:59:02 +00:00
|
|
|
|
2018-05-23 08:52:58 +00:00
|
|
|
/**
|
|
|
|
* CallsCall::state-changed:
|
|
|
|
* @self: The #CallsCall instance.
|
2018-11-09 12:38:04 +00:00
|
|
|
* @new_state: The new state of the call.
|
|
|
|
* @old_state: The old state of the call.
|
2018-05-23 08:52:58 +00:00
|
|
|
*
|
|
|
|
* This signal is emitted when the state of the call changes, for
|
|
|
|
* example when it's answered or when the call is disconnected.
|
|
|
|
*/
|
2021-04-05 04:00:10 +00:00
|
|
|
signals[STATE_CHANGED] =
|
|
|
|
g_signal_new ("state-changed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0, NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE,
|
|
|
|
2, CALLS_TYPE_CALL_STATE, CALLS_TYPE_CALL_STATE);
|
2018-05-17 13:16:51 +00:00
|
|
|
}
|
|
|
|
|
2021-04-05 04:00:10 +00:00
|
|
|
static void
|
|
|
|
calls_call_init (CallsCall *self)
|
|
|
|
{
|
|
|
|
}
|
2018-05-17 13:16:51 +00:00
|
|
|
|
2018-05-23 08:52:58 +00:00
|
|
|
/**
|
2022-02-17 18:13:07 +00:00
|
|
|
* calls_call_get_id: (attributes org.gtk.Method.get_property=id)
|
2018-05-23 08:52:58 +00:00
|
|
|
* @self: a #CallsCall
|
|
|
|
*
|
2022-02-17 18:13:07 +00:00
|
|
|
* Returns: (transfer none) (nullable): the id, or %NULL if the id is unknown
|
2018-05-23 08:52:58 +00:00
|
|
|
*/
|
2021-04-05 04:00:10 +00:00
|
|
|
const char *
|
2021-10-22 05:21:11 +00:00
|
|
|
calls_call_get_id (CallsCall *self)
|
2021-04-05 04:00:10 +00:00
|
|
|
{
|
2021-12-10 08:46:32 +00:00
|
|
|
CallsCallPrivate *priv = calls_call_get_instance_private (self);
|
|
|
|
|
2021-04-05 04:00:10 +00:00
|
|
|
g_return_val_if_fail (CALLS_IS_CALL (self), NULL);
|
|
|
|
|
2021-12-10 08:46:32 +00:00
|
|
|
return priv->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-02-17 18:13:07 +00:00
|
|
|
* calls_call_set_id: (attributes org.gtk.Method.set_property=id)
|
2021-12-10 08:46:32 +00:00
|
|
|
* @self: a #CallsCall
|
|
|
|
* @id: the id of the remote party
|
|
|
|
*
|
|
|
|
* Set the id of the call. Some implementations might only be able to set
|
|
|
|
* the id after construction.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
calls_call_set_id (CallsCall *self,
|
|
|
|
const char *id)
|
|
|
|
{
|
|
|
|
CallsCallPrivate *priv = calls_call_get_instance_private (self);
|
|
|
|
|
|
|
|
g_return_if_fail (CALLS_IS_CALL (self));
|
|
|
|
|
|
|
|
if (g_strcmp0 (id, priv->id) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_free (priv->id);
|
|
|
|
priv->id = g_strdup (id);
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ID]);
|
2021-04-05 04:00:10 +00:00
|
|
|
}
|
2018-05-23 08:52:58 +00:00
|
|
|
|
|
|
|
/**
|
2022-02-17 18:13:07 +00:00
|
|
|
* calls_call_get_name: (attributes org.gtk.Method.get_property=name)
|
2018-05-23 08:52:58 +00:00
|
|
|
* @self: a #CallsCall
|
|
|
|
*
|
|
|
|
* Get the name of the party the call is connected to, if the network
|
|
|
|
* provides it.
|
|
|
|
*
|
2021-10-22 05:21:11 +00:00
|
|
|
* Returns the id, or NULL
|
2018-05-23 08:52:58 +00:00
|
|
|
*/
|
2021-04-05 04:00:10 +00:00
|
|
|
const char *
|
|
|
|
calls_call_get_name (CallsCall *self)
|
|
|
|
{
|
2021-12-11 08:24:57 +00:00
|
|
|
CallsCallPrivate *priv = calls_call_get_instance_private (self);
|
|
|
|
|
2021-04-05 04:00:10 +00:00
|
|
|
g_return_val_if_fail (CALLS_IS_CALL (self), NULL);
|
|
|
|
|
2021-12-11 08:24:57 +00:00
|
|
|
return priv->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-02-17 18:13:07 +00:00
|
|
|
* calls_call_set_name: (attributes org.gtk.Method.set_property=name)
|
2021-12-11 08:24:57 +00:00
|
|
|
* @self: a #CallsCall
|
|
|
|
* @name: the name to set
|
|
|
|
*
|
|
|
|
* Sets the name of the call as provided by the network.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
calls_call_set_name (CallsCall *self,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
CallsCallPrivate *priv = calls_call_get_instance_private (self);
|
|
|
|
|
|
|
|
g_return_if_fail (CALLS_IS_CALL (self));
|
|
|
|
|
|
|
|
g_clear_pointer (&priv->name, g_free);
|
|
|
|
if (name)
|
|
|
|
priv->name = g_strdup (name);
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_NAME]);
|
2021-04-05 04:00:10 +00:00
|
|
|
}
|
2018-05-17 13:16:51 +00:00
|
|
|
|
|
|
|
/**
|
2022-02-17 18:13:07 +00:00
|
|
|
* calls_call_get_state: (attributes org.gtk.Method.get_property=state)
|
2018-05-17 13:16:51 +00:00
|
|
|
* @self: a #CallsCall
|
|
|
|
*
|
2018-05-23 08:52:58 +00:00
|
|
|
* Get the current state of the call.
|
2018-05-17 13:16:51 +00:00
|
|
|
*
|
|
|
|
* Returns: the state
|
|
|
|
*/
|
2021-04-05 04:00:10 +00:00
|
|
|
CallsCallState
|
|
|
|
calls_call_get_state (CallsCall *self)
|
|
|
|
{
|
2021-12-10 08:02:39 +00:00
|
|
|
CallsCallPrivate *priv = calls_call_get_instance_private (self);
|
|
|
|
|
2022-06-22 22:59:02 +00:00
|
|
|
g_return_val_if_fail (CALLS_IS_CALL (self), CALLS_CALL_STATE_UNKNOWN);
|
2021-04-05 04:00:10 +00:00
|
|
|
|
2021-12-10 08:02:39 +00:00
|
|
|
return priv->state;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-02-17 18:13:07 +00:00
|
|
|
* calls_call_set_state: (attributes org.gtk.Method.set_property=state org.gtk.Method.signal=state-changed)
|
2021-12-10 08:02:39 +00:00
|
|
|
* @self: a #CallsCall
|
|
|
|
* @state: a #CallsCallState
|
|
|
|
*
|
|
|
|
* Set the current state of the call.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
calls_call_set_state (CallsCall *self,
|
|
|
|
CallsCallState state)
|
|
|
|
{
|
|
|
|
CallsCallPrivate *priv = calls_call_get_instance_private (self);
|
|
|
|
CallsCallState old_state;
|
|
|
|
|
|
|
|
g_return_if_fail (CALLS_IS_CALL (self));
|
|
|
|
|
|
|
|
old_state = priv->state;
|
|
|
|
|
|
|
|
if (old_state == state) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->state = state;
|
|
|
|
|
2022-01-14 08:08:23 +00:00
|
|
|
g_object_ref (G_OBJECT (self));
|
|
|
|
|
2021-12-10 08:02:39 +00:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_STATE]);
|
|
|
|
g_signal_emit_by_name (CALLS_CALL (self),
|
|
|
|
"state-changed",
|
|
|
|
state,
|
|
|
|
old_state);
|
2022-01-14 08:08:23 +00:00
|
|
|
|
|
|
|
g_object_unref (G_OBJECT (self));
|
2021-04-05 04:00:10 +00:00
|
|
|
}
|
2018-05-17 13:16:51 +00:00
|
|
|
|
2022-02-09 17:29:24 +00:00
|
|
|
/**
|
2022-02-17 18:13:07 +00:00
|
|
|
* calls_call_get_call_type: (attributes org.gtk.Method.get_property=call-type)
|
2022-02-09 17:29:24 +00:00
|
|
|
* @self: a #CallsCall
|
|
|
|
*
|
|
|
|
* Returns: The type of call, or #CALLS_CALL_TYPE_UNKNOWN if not known.
|
|
|
|
*/
|
|
|
|
CallsCallType
|
|
|
|
calls_call_get_call_type (CallsCall *self)
|
|
|
|
{
|
|
|
|
CallsCallPrivate *priv = calls_call_get_instance_private (self);
|
|
|
|
|
|
|
|
g_return_val_if_fail (CALLS_IS_CALL (self), CALLS_CALL_TYPE_UNKNOWN);
|
|
|
|
|
|
|
|
return priv->call_type;
|
|
|
|
}
|
|
|
|
|
2018-05-23 08:52:58 +00:00
|
|
|
/**
|
|
|
|
* calls_call_answer:
|
|
|
|
* @self: a #CallsCall
|
|
|
|
*
|
|
|
|
* If the call is incoming, answer it.
|
|
|
|
*
|
|
|
|
*/
|
2021-04-05 04:00:10 +00:00
|
|
|
void
|
|
|
|
calls_call_answer (CallsCall *self)
|
|
|
|
{
|
|
|
|
g_return_if_fail (CALLS_IS_CALL (self));
|
|
|
|
|
|
|
|
CALLS_CALL_GET_CLASS (self)->answer (self);
|
|
|
|
}
|
2018-05-23 08:52:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* calls_call_hang_up:
|
|
|
|
* @self: a #CallsCall
|
|
|
|
*
|
|
|
|
* Hang up the call.
|
|
|
|
*
|
|
|
|
*/
|
2021-04-05 04:00:10 +00:00
|
|
|
void
|
|
|
|
calls_call_hang_up (CallsCall *self)
|
|
|
|
{
|
|
|
|
g_return_if_fail (CALLS_IS_CALL (self));
|
|
|
|
|
|
|
|
CALLS_CALL_GET_CLASS (self)->hang_up (self);
|
|
|
|
}
|
2018-05-17 13:16:51 +00:00
|
|
|
|
|
|
|
|
2019-07-22 10:52:42 +00:00
|
|
|
/**
|
2022-02-17 18:13:07 +00:00
|
|
|
* calls_call_get_inbound: (attributes org.gtk.Method.get_property=inbound)
|
2019-07-22 10:52:42 +00:00
|
|
|
* @self: a #CallsCall
|
|
|
|
*
|
|
|
|
* Get the direction of the call.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if inbound, FALSE if outbound.
|
|
|
|
*/
|
2021-04-05 04:00:10 +00:00
|
|
|
gboolean
|
|
|
|
calls_call_get_inbound (CallsCall *self)
|
|
|
|
{
|
2021-12-10 07:00:11 +00:00
|
|
|
CallsCallPrivate *priv = calls_call_get_instance_private (self);
|
|
|
|
|
2021-04-05 04:00:10 +00:00
|
|
|
g_return_val_if_fail (CALLS_IS_CALL (self), FALSE);
|
|
|
|
|
2021-12-10 07:00:11 +00:00
|
|
|
return priv->inbound;
|
2021-04-05 04:00:10 +00:00
|
|
|
}
|
2019-07-22 10:52:42 +00:00
|
|
|
|
2021-04-26 10:00:02 +00:00
|
|
|
/**
|
2022-02-17 18:13:07 +00:00
|
|
|
* calls_call_get_protocol: (attributes org.gtk.Method.get_property=protocol)
|
2021-04-26 10:00:02 +00:00
|
|
|
* @self: a #CallsCall
|
|
|
|
*
|
|
|
|
* Get the protocol of the call (i.e. "tel", "sip")
|
|
|
|
*
|
2022-01-21 09:06:44 +00:00
|
|
|
* Returns: (transfer none): The protocol used or %NULL when unknown
|
2021-04-26 10:00:02 +00:00
|
|
|
*/
|
|
|
|
const char *
|
|
|
|
calls_call_get_protocol (CallsCall *self)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CALLS_IS_CALL (self), NULL);
|
|
|
|
|
|
|
|
return CALLS_CALL_GET_CLASS (self)->get_protocol (self);
|
|
|
|
}
|
|
|
|
|
2021-11-12 08:51:04 +00:00
|
|
|
/**
|
|
|
|
* calls_call_can_dtmf:
|
|
|
|
* @self: a #CallsCall
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if this call supports DTMF, %FALSE otherwise
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
calls_call_can_dtmf (CallsCall *self)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CALLS_IS_CALL (self), FALSE);
|
|
|
|
|
2021-11-16 12:59:06 +00:00
|
|
|
return CALLS_CALL_GET_CLASS (self)->send_dtmf_tone != calls_call_real_send_dtmf_tone;
|
2021-11-12 08:51:04 +00:00
|
|
|
}
|
2018-05-17 13:16:51 +00:00
|
|
|
|
2018-05-23 08:52:58 +00:00
|
|
|
/**
|
2021-11-16 12:59:06 +00:00
|
|
|
* calls_call_send_dtmf_tone:
|
2018-05-23 08:52:58 +00:00
|
|
|
* @self: a #CallsCall
|
|
|
|
* @key: which tone to start
|
|
|
|
*
|
2021-11-16 12:59:06 +00:00
|
|
|
* Start playing a DTMF tone for the specified key. Implementations
|
2018-05-23 08:52:58 +00:00
|
|
|
* will stop playing the tone either after an implementation-specific
|
2021-11-16 12:59:06 +00:00
|
|
|
* timeout.
|
2018-05-23 08:52:58 +00:00
|
|
|
*
|
|
|
|
*/
|
2018-05-31 10:20:17 +00:00
|
|
|
void
|
2021-11-16 12:59:06 +00:00
|
|
|
calls_call_send_dtmf_tone (CallsCall *self,
|
|
|
|
gchar key)
|
2018-05-31 10:20:17 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (CALLS_IS_CALL (self));
|
2021-11-16 14:18:54 +00:00
|
|
|
g_return_if_fail (dtmf_tone_key_is_valid (key));
|
2018-05-31 10:20:17 +00:00
|
|
|
|
2021-11-16 12:59:06 +00:00
|
|
|
CALLS_CALL_GET_CLASS (self)->send_dtmf_tone (self, key);
|
2018-05-31 10:20:17 +00:00
|
|
|
}
|
2021-01-28 16:05:00 +00:00
|
|
|
|
2021-04-05 04:00:10 +00:00
|
|
|
gboolean
|
|
|
|
calls_call_state_parse_nick (CallsCallState *state,
|
|
|
|
const char *nick)
|
|
|
|
{
|
|
|
|
GEnumClass *klass;
|
|
|
|
GEnumValue *value;
|
|
|
|
gboolean ret;
|
|
|
|
|
|
|
|
g_return_val_if_fail (state != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (nick != NULL, FALSE);
|
|
|
|
|
|
|
|
klass = g_type_class_ref (CALLS_TYPE_CALL_STATE);
|
|
|
|
value = g_enum_get_value_by_nick (klass, nick);
|
|
|
|
|
2021-12-10 06:02:15 +00:00
|
|
|
if (value) {
|
|
|
|
*state = (CallsCallState) value->value;
|
|
|
|
ret = TRUE;
|
|
|
|
} else {
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
2021-04-05 04:00:10 +00:00
|
|
|
|
|
|
|
g_type_class_unref (klass);
|
|
|
|
return ret;
|
|
|
|
}
|
2022-05-09 09:00:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* calls_call_get_encrypted:
|
|
|
|
* @self: A #CallsCall
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the call is encrypted, %FALSE otherwise.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
calls_call_get_encrypted (CallsCall *self)
|
|
|
|
{
|
|
|
|
CallsCallPrivate *priv = calls_call_get_instance_private (self);
|
|
|
|
|
|
|
|
g_return_val_if_fail (CALLS_IS_CALL (self), FALSE);
|
|
|
|
|
|
|
|
return priv->encrypted;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* calls_call_set_encrypted:
|
|
|
|
* @self: A #CallsCall
|
|
|
|
* @encrypted: A boolean indicating if the call is encrypted
|
|
|
|
*
|
|
|
|
* Set whether the call is encrypted or not.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
calls_call_set_encrypted (CallsCall *self,
|
|
|
|
gboolean encrypted)
|
|
|
|
{
|
|
|
|
CallsCallPrivate *priv = calls_call_get_instance_private (self);
|
|
|
|
|
|
|
|
g_return_if_fail (CALLS_IS_CALL (self));
|
|
|
|
|
|
|
|
if (priv->encrypted == encrypted)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_debug ("Encryption %sabled", encrypted ? "en" : "dis");
|
|
|
|
|
|
|
|
priv->encrypted = encrypted;
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ENCRYPTED]);
|
|
|
|
}
|