2019-07-22 10:52:46 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018, 2019 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-record.h"
|
|
|
|
|
|
|
|
#include <glib/gi18n.h>
|
|
|
|
|
|
|
|
|
|
|
|
struct _CallsCallRecord
|
|
|
|
{
|
|
|
|
GomResource parent_instance;
|
|
|
|
guint id;
|
2021-04-12 09:44:30 +00:00
|
|
|
char *target;
|
2019-07-22 10:52:46 +00:00
|
|
|
gboolean inbound;
|
|
|
|
GDateTime *start;
|
|
|
|
GDateTime *answered;
|
|
|
|
GDateTime *end;
|
2021-04-12 09:44:30 +00:00
|
|
|
char *protocol;
|
2019-07-22 10:52:46 +00:00
|
|
|
gboolean complete;
|
|
|
|
};
|
|
|
|
|
|
|
|
G_DEFINE_TYPE(CallsCallRecord, calls_call_record, GOM_TYPE_RESOURCE)
|
|
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PROP_0,
|
|
|
|
PROP_ID,
|
|
|
|
PROP_TARGET,
|
|
|
|
PROP_INBOUND,
|
|
|
|
PROP_START,
|
|
|
|
PROP_ANSWERED,
|
|
|
|
PROP_END,
|
2021-04-12 09:44:30 +00:00
|
|
|
PROP_PROTOCOL,
|
2019-07-22 10:52:46 +00:00
|
|
|
PROP_LAST_PROP,
|
|
|
|
};
|
|
|
|
static GParamSpec *props[PROP_LAST_PROP];
|
|
|
|
|
2020-06-08 13:09:57 +00:00
|
|
|
enum {
|
|
|
|
SIGNAL_CALL_DELETE,
|
|
|
|
SIGNAL_LAST_SIGNAL,
|
|
|
|
};
|
|
|
|
static guint signals [SIGNAL_LAST_SIGNAL];
|
|
|
|
|
2019-07-22 10:52:46 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
CallsCallRecord *self = CALLS_CALL_RECORD (object);
|
|
|
|
|
|
|
|
switch (property_id) {
|
|
|
|
|
2021-04-12 09:20:30 +00:00
|
|
|
case PROP_ID:
|
|
|
|
g_value_set_uint (value, self->id);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_TARGET:
|
|
|
|
g_value_set_string (value, self->target);
|
|
|
|
break;
|
2019-07-22 10:52:46 +00:00
|
|
|
|
2021-04-12 09:20:30 +00:00
|
|
|
case PROP_INBOUND:
|
|
|
|
g_value_set_boolean (value, self->inbound);
|
|
|
|
break;
|
2019-07-22 10:52:46 +00:00
|
|
|
|
2021-04-12 09:20:30 +00:00
|
|
|
case PROP_START:
|
|
|
|
g_value_set_boxed (value, self->start);
|
|
|
|
break;
|
2019-07-22 10:52:46 +00:00
|
|
|
|
2021-04-12 09:20:30 +00:00
|
|
|
case PROP_ANSWERED:
|
|
|
|
g_value_set_boxed (value, self->answered);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_END:
|
|
|
|
g_value_set_boxed (value, self->end);
|
|
|
|
break;
|
2019-07-22 10:52:46 +00:00
|
|
|
|
2021-04-12 09:44:30 +00:00
|
|
|
case PROP_PROTOCOL:
|
|
|
|
g_value_set_string (value, self->protocol);
|
|
|
|
break;
|
|
|
|
|
2019-07-22 10:52:46 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_date_time (GDateTime **stamp_ptr,
|
|
|
|
const GValue *value)
|
|
|
|
{
|
|
|
|
gpointer new_stamp = g_value_get_boxed (value);
|
|
|
|
|
|
|
|
g_clear_pointer (stamp_ptr, g_date_time_unref);
|
|
|
|
|
|
|
|
if (new_stamp)
|
|
|
|
{
|
|
|
|
*stamp_ptr = g_date_time_ref (new_stamp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
CallsCallRecord *self = CALLS_CALL_RECORD (object);
|
|
|
|
|
|
|
|
switch (property_id) {
|
|
|
|
case PROP_ID:
|
|
|
|
self->id = g_value_get_uint (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_TARGET:
|
2021-04-12 09:33:57 +00:00
|
|
|
g_free (self->target);
|
|
|
|
self->target = g_value_dup_string (value);
|
2019-07-22 10:52:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_INBOUND:
|
|
|
|
self->inbound = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_START:
|
|
|
|
set_date_time (&self->start, value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_ANSWERED:
|
|
|
|
set_date_time (&self->answered, value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_END:
|
|
|
|
set_date_time (&self->end, value);
|
|
|
|
break;
|
|
|
|
|
2021-04-12 09:44:30 +00:00
|
|
|
case PROP_PROTOCOL:
|
|
|
|
g_free (self->protocol);
|
|
|
|
self->protocol = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
|
2019-07-22 10:52:46 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
finalize (GObject *object)
|
|
|
|
{
|
|
|
|
CallsCallRecord *self = CALLS_CALL_RECORD (object);
|
|
|
|
|
|
|
|
g_clear_pointer (&self->end, g_date_time_unref);
|
|
|
|
g_clear_pointer (&self->answered, g_date_time_unref);
|
|
|
|
g_clear_pointer (&self->start, g_date_time_unref);
|
|
|
|
g_free (self->target);
|
2021-04-12 09:44:30 +00:00
|
|
|
g_free (self->protocol);
|
2019-07-22 10:52:46 +00:00
|
|
|
|
2020-02-18 15:01:22 +00:00
|
|
|
G_OBJECT_CLASS (calls_call_record_parent_class)->finalize (object);
|
2019-07-22 10:52:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
calls_call_record_class_init (CallsCallRecordClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GomResourceClass *resource_class = GOM_RESOURCE_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->finalize = finalize;
|
|
|
|
object_class->get_property = get_property;
|
|
|
|
object_class->set_property = set_property;
|
|
|
|
|
2020-06-08 13:09:57 +00:00
|
|
|
signals[SIGNAL_CALL_DELETE] =
|
|
|
|
g_signal_new ("call-delete",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
0,
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE,
|
|
|
|
0, NULL);
|
|
|
|
|
2019-07-22 10:52:46 +00:00
|
|
|
gom_resource_class_set_table (resource_class, "calls");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NB: ANY ADDITIONS TO THIS LIST REQUIRE AN INCREASE IN
|
|
|
|
* RECORD_STORE_VERSION IN calls-record-store.c AND THE USE OF
|
|
|
|
*
|
|
|
|
* gom_resource_class_set_property_new_in_version
|
|
|
|
* (resource_class, "property", 2);
|
|
|
|
*
|
|
|
|
* HERE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
props[PROP_ID] =
|
|
|
|
g_param_spec_uint ("id",
|
2020-05-29 05:38:11 +00:00
|
|
|
"ID",
|
|
|
|
"The row ID",
|
2019-07-22 10:52:46 +00:00
|
|
|
0, G_MAXUINT, 0,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
2021-04-12 09:20:30 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_ID, props[PROP_ID]);
|
2019-07-22 10:52:46 +00:00
|
|
|
gom_resource_class_set_primary_key (resource_class, "id");
|
|
|
|
|
|
|
|
props[PROP_TARGET] =
|
|
|
|
g_param_spec_string ("target",
|
2020-05-29 05:38:11 +00:00
|
|
|
"Target",
|
|
|
|
"The PTSN phone number or other address of the call",
|
2019-07-22 10:52:46 +00:00
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
2021-04-12 09:20:30 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_TARGET, props[PROP_TARGET]);
|
2019-07-22 10:52:46 +00:00
|
|
|
|
|
|
|
props[PROP_INBOUND] =
|
|
|
|
g_param_spec_boolean ("inbound",
|
2020-05-29 05:38:11 +00:00
|
|
|
"Inbound",
|
|
|
|
"Whether the call was an inbound call",
|
2019-07-22 10:52:46 +00:00
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
2021-04-12 09:20:30 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_INBOUND, props[PROP_INBOUND]);
|
2019-07-22 10:52:46 +00:00
|
|
|
|
|
|
|
props[PROP_START] =
|
|
|
|
g_param_spec_boxed ("start",
|
2020-05-29 05:38:11 +00:00
|
|
|
"Start",
|
|
|
|
"Time stamp of the start of the call",
|
2019-07-22 10:52:46 +00:00
|
|
|
G_TYPE_DATE_TIME,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
2021-04-12 09:20:30 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_START, props[PROP_START]);
|
2019-07-22 10:52:46 +00:00
|
|
|
|
|
|
|
props[PROP_ANSWERED] =
|
|
|
|
g_param_spec_boxed ("answered",
|
2020-05-29 05:38:11 +00:00
|
|
|
"Answered",
|
|
|
|
"Time stamp of when the call was answered",
|
2019-07-22 10:52:46 +00:00
|
|
|
G_TYPE_DATE_TIME,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
2021-04-12 09:20:30 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_ANSWERED, props[PROP_ANSWERED]);
|
2019-07-22 10:52:46 +00:00
|
|
|
|
|
|
|
props[PROP_END] =
|
|
|
|
g_param_spec_boxed ("end",
|
2020-05-29 05:38:11 +00:00
|
|
|
"End",
|
|
|
|
"Time stamp of the end of the call",
|
2019-07-22 10:52:46 +00:00
|
|
|
G_TYPE_DATE_TIME,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
2021-04-12 09:20:30 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_END, props[PROP_END]);
|
|
|
|
|
2021-04-12 09:44:30 +00:00
|
|
|
props[PROP_PROTOCOL] =
|
|
|
|
g_param_spec_string ("protocol",
|
|
|
|
"Protocol",
|
|
|
|
"The URI protocol for this call",
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
|
|
|
g_object_class_install_property (object_class, PROP_PROTOCOL, props[PROP_PROTOCOL]);
|
|
|
|
|
|
|
|
gom_resource_class_set_property_new_in_version (resource_class, "protocol", 2);
|
|
|
|
|
2019-07-22 10:52:46 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* NB: ANY ADDITIONS TO THIS LIST REQUIRE AN INCREASE IN
|
|
|
|
* RECORD_STORE_VERSION IN calls-record-store.c AND THE USE OF
|
|
|
|
*
|
|
|
|
* gom_resource_class_set_property_new_in_version
|
|
|
|
* (resource_class, "property", 2);
|
|
|
|
*
|
|
|
|
* HERE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
calls_call_record_init (CallsCallRecord *self)
|
|
|
|
{
|
|
|
|
}
|