mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-08 12:55:32 +00:00
record-store: codestyle
This commit is contained in:
parent
9877f4469b
commit
38abbc5b18
1 changed files with 163 additions and 219 deletions
|
@ -50,8 +50,7 @@ typedef enum
|
||||||
static CallsCallRecordState
|
static CallsCallRecordState
|
||||||
state_to_record_state (CallsCallState call_state)
|
state_to_record_state (CallsCallState call_state)
|
||||||
{
|
{
|
||||||
switch (call_state)
|
switch (call_state) {
|
||||||
{
|
|
||||||
case CALLS_CALL_STATE_DIALING:
|
case CALLS_CALL_STATE_DIALING:
|
||||||
case CALLS_CALL_STATE_ALERTING:
|
case CALLS_CALL_STATE_ALERTING:
|
||||||
case CALLS_CALL_STATE_INCOMING:
|
case CALLS_CALL_STATE_INCOMING:
|
||||||
|
@ -100,25 +99,21 @@ delete_record_cb (GomResource *resource,
|
||||||
&id,
|
&id,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (!ok)
|
if (!ok) {
|
||||||
{
|
if (error) {
|
||||||
if (error)
|
|
||||||
{
|
|
||||||
g_warning ("Error deleting call record with id %u from database %s",
|
g_warning ("Error deleting call record with id %u from database %s",
|
||||||
id, error->message);
|
id, error->message);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
g_warning ("Unknown error deleting call record with id %u from database",
|
g_warning ("Unknown error deleting call record with id %u from database",
|
||||||
id);
|
id);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
} else {
|
||||||
g_debug ("Successfully deleted call record with id %u from database",
|
g_debug ("Successfully deleted call record with id %u from database",
|
||||||
id);
|
id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,8 +140,7 @@ load_calls_fetch_cb (GomResourceGroup *group,
|
||||||
ok = gom_resource_group_fetch_finish (group,
|
ok = gom_resource_group_fetch_finish (group,
|
||||||
res,
|
res,
|
||||||
&error);
|
&error);
|
||||||
if (error)
|
if (error) {
|
||||||
{
|
|
||||||
g_debug ("Error fetching call records: %s",
|
g_debug ("Error fetching call records: %s",
|
||||||
error->message);
|
error->message);
|
||||||
return;
|
return;
|
||||||
|
@ -158,8 +152,7 @@ load_calls_fetch_cb (GomResourceGroup *group,
|
||||||
count, self->filename);
|
count, self->filename);
|
||||||
records = g_new (gpointer, count);
|
records = g_new (gpointer, count);
|
||||||
|
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i) {
|
||||||
{
|
|
||||||
GomResource *resource;
|
GomResource *resource;
|
||||||
CallsCallRecord *record;
|
CallsCallRecord *record;
|
||||||
GDateTime *end = NULL;
|
GDateTime *end = NULL;
|
||||||
|
@ -175,9 +168,7 @@ load_calls_fetch_cb (GomResourceGroup *group,
|
||||||
"end", &end,
|
"end", &end,
|
||||||
NULL);
|
NULL);
|
||||||
if (end)
|
if (end)
|
||||||
{
|
|
||||||
g_date_time_unref (end);
|
g_date_time_unref (end);
|
||||||
}
|
|
||||||
|
|
||||||
g_signal_connect (record,
|
g_signal_connect (record,
|
||||||
"call-delete",
|
"call-delete",
|
||||||
|
@ -208,8 +199,7 @@ load_calls_find_cb (GomRepository *repository,
|
||||||
group = gom_repository_find_finish (repository,
|
group = gom_repository_find_finish (repository,
|
||||||
res,
|
res,
|
||||||
&error);
|
&error);
|
||||||
if (error)
|
if (error) {
|
||||||
{
|
|
||||||
g_debug ("Error finding call records in database `%s': %s",
|
g_debug ("Error finding call records in database `%s': %s",
|
||||||
self->filename, error->message);
|
self->filename, error->message);
|
||||||
return;
|
return;
|
||||||
|
@ -217,8 +207,7 @@ load_calls_find_cb (GomRepository *repository,
|
||||||
g_assert (group != NULL);
|
g_assert (group != NULL);
|
||||||
|
|
||||||
count = gom_resource_group_get_count (group);
|
count = gom_resource_group_get_count (group);
|
||||||
if (count == 0)
|
if (count == 0) {
|
||||||
{
|
|
||||||
g_debug ("No call records found in database `%s'",
|
g_debug ("No call records found in database `%s'",
|
||||||
self->filename);
|
self->filename);
|
||||||
return;
|
return;
|
||||||
|
@ -271,24 +260,18 @@ set_up_repo_migrate_cb (GomRepository *repo,
|
||||||
gboolean ok;
|
gboolean ok;
|
||||||
|
|
||||||
ok = gom_repository_automatic_migrate_finish (repo, res, &error);
|
ok = gom_repository_automatic_migrate_finish (repo, res, &error);
|
||||||
if (!ok)
|
if (!ok) {
|
||||||
{
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
|
||||||
g_warning ("Error migrating call record database `%s': %s",
|
g_warning ("Error migrating call record database `%s': %s",
|
||||||
self->filename, error->message);
|
self->filename, error->message);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
g_warning ("Unknown error migrating call record database `%s'",
|
g_warning ("Unknown error migrating call record database `%s'",
|
||||||
self->filename);
|
self->filename);
|
||||||
}
|
|
||||||
|
|
||||||
g_clear_object (&self->repository);
|
g_clear_object (&self->repository);
|
||||||
g_clear_object (&self->adapter);
|
g_clear_object (&self->adapter);
|
||||||
}
|
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
g_debug ("Successfully migrated call record database `%s'",
|
g_debug ("Successfully migrated call record database `%s'",
|
||||||
self->filename);
|
self->filename);
|
||||||
load_calls (self);
|
load_calls (self);
|
||||||
|
@ -302,8 +285,7 @@ set_up_repo (CallsRecordStore *self)
|
||||||
GomRepository *repo;
|
GomRepository *repo;
|
||||||
GList *types = NULL;
|
GList *types = NULL;
|
||||||
|
|
||||||
if (self->repository)
|
if (self->repository) {
|
||||||
{
|
|
||||||
g_warning ("Opened call record database `%s'"
|
g_warning ("Opened call record database `%s'"
|
||||||
" while repository exists",
|
" while repository exists",
|
||||||
self->filename);
|
self->filename);
|
||||||
|
@ -339,19 +321,14 @@ close_adapter (CallsRecordStore *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = gom_adapter_close_sync(self->adapter, &error);
|
ok = gom_adapter_close_sync(self->adapter, &error);
|
||||||
if (!ok)
|
if (!ok) {
|
||||||
{
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
|
||||||
g_warning ("Error closing call record database `%s': %s",
|
g_warning ("Error closing call record database `%s': %s",
|
||||||
self->filename, error->message);
|
self->filename, error->message);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
g_warning ("Unknown error closing call record database `%s'",
|
g_warning ("Unknown error closing call record database `%s'",
|
||||||
self->filename);
|
self->filename);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
g_clear_object (&self->adapter);
|
g_clear_object (&self->adapter);
|
||||||
}
|
}
|
||||||
|
@ -366,23 +343,17 @@ open_repo_adapter_open_cb (GomAdapter *adapter,
|
||||||
gboolean ok;
|
gboolean ok;
|
||||||
|
|
||||||
ok = gom_adapter_open_finish (adapter, res, &error);
|
ok = gom_adapter_open_finish (adapter, res, &error);
|
||||||
if (!ok)
|
if (!ok) {
|
||||||
{
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
|
||||||
g_warning ("Error opening call record database `%s': %s",
|
g_warning ("Error opening call record database `%s': %s",
|
||||||
self->filename, error->message);
|
self->filename, error->message);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
g_warning ("Unknown error opening call record database `%s'",
|
g_warning ("Unknown error opening call record database `%s'",
|
||||||
self->filename);
|
self->filename);
|
||||||
}
|
|
||||||
|
|
||||||
close_adapter (self);
|
close_adapter (self);
|
||||||
}
|
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
g_debug ("Successfully opened call record database `%s'",
|
g_debug ("Successfully opened call record database `%s'",
|
||||||
self->filename);
|
self->filename);
|
||||||
set_up_repo (self);
|
set_up_repo (self);
|
||||||
|
@ -398,18 +369,14 @@ open_repo (CallsRecordStore *self)
|
||||||
gchar *uri;
|
gchar *uri;
|
||||||
|
|
||||||
if (self->adapter)
|
if (self->adapter)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
dir = g_path_get_dirname (self->filename);
|
dir = g_path_get_dirname (self->filename);
|
||||||
err = g_mkdir_with_parents (dir, 0755);
|
err = g_mkdir_with_parents (dir, 0755);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
|
||||||
g_warning ("Could not create Calls data directory `%s': %s",
|
g_warning ("Could not create Calls data directory `%s': %s",
|
||||||
dir, g_strerror (errno));
|
dir, g_strerror (errno));
|
||||||
}
|
|
||||||
g_free (dir);
|
g_free (dir);
|
||||||
|
|
||||||
|
|
||||||
|
@ -443,26 +410,21 @@ record_call_save_cb (GomResource *resource,
|
||||||
gboolean ok;
|
gboolean ok;
|
||||||
|
|
||||||
ok = gom_resource_save_finish (resource, res, &error);
|
ok = gom_resource_save_finish (resource, res, &error);
|
||||||
if (!ok)
|
if (!ok) {
|
||||||
{
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
|
||||||
g_warning ("Error saving call record to database: %s",
|
g_warning ("Error saving call record to database: %s",
|
||||||
error->message);
|
error->message);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
g_warning ("Unknown error saving call record to database");
|
g_warning ("Unknown error saving call record to database");
|
||||||
}
|
|
||||||
|
|
||||||
g_object_set_data (call_obj, "calls-call-record", NULL);
|
g_object_set_data (call_obj, "calls-call-record", NULL);
|
||||||
}
|
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
g_debug ("Successfully saved new call record to database");
|
g_debug ("Successfully saved new call record to database");
|
||||||
g_list_store_insert (G_LIST_STORE (data->self),
|
g_list_store_insert (G_LIST_STORE (data->self),
|
||||||
0,
|
0,
|
||||||
CALLS_CALL_RECORD (resource));
|
CALLS_CALL_RECORD (resource));
|
||||||
|
|
||||||
g_object_set_data (call_obj, "calls-call-start", NULL);
|
g_object_set_data (call_obj, "calls-call-start", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,20 +480,14 @@ update_cb (GomResource *resource,
|
||||||
gboolean ok;
|
gboolean ok;
|
||||||
|
|
||||||
ok = gom_resource_save_finish (resource, res, &error);
|
ok = gom_resource_save_finish (resource, res, &error);
|
||||||
if (!ok)
|
if (!ok) {
|
||||||
{
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
|
||||||
g_warning ("Error updating call record in database: %s",
|
g_warning ("Error updating call record in database: %s",
|
||||||
error->message);
|
error->message);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
g_warning ("Unknown error updating call record in database");
|
g_warning ("Unknown error updating call record in database");
|
||||||
}
|
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
g_debug ("Successfully updated call record in database");
|
g_debug ("Successfully updated call record in database");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -549,9 +505,7 @@ stamp_call (CallsCallRecord *record,
|
||||||
stamp_name, &stamp,
|
stamp_name, &stamp,
|
||||||
NULL);
|
NULL);
|
||||||
if (stamp)
|
if (stamp)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
g_debug ("Stamping call `%s'", stamp_name);
|
g_debug ("Stamping call `%s'", stamp_name);
|
||||||
|
@ -580,18 +534,13 @@ state_changed_cb (CallsRecordStore *self,
|
||||||
|
|
||||||
|
|
||||||
/* Check whether the call is recorded */
|
/* Check whether the call is recorded */
|
||||||
if (!record)
|
if (!record) {
|
||||||
{
|
|
||||||
/* Try to record the call again */
|
/* Try to record the call again */
|
||||||
if (g_object_get_data (call_obj, "calls-call-start") != NULL)
|
if (g_object_get_data (call_obj, "calls-call-start") != NULL)
|
||||||
{
|
|
||||||
record_call (self, call);
|
record_call (self, call);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
g_warning ("Record store received state change"
|
g_warning ("Record store received state change"
|
||||||
" for non-started call");
|
" for non-started call");
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,21 +548,19 @@ state_changed_cb (CallsRecordStore *self,
|
||||||
old_rec_state = state_to_record_state (old_state);
|
old_rec_state = state_to_record_state (old_state);
|
||||||
|
|
||||||
if (new_rec_state == old_rec_state)
|
if (new_rec_state == old_rec_state)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
switch (old_rec_state)
|
switch (old_rec_state) {
|
||||||
{
|
|
||||||
case STARTED:
|
case STARTED:
|
||||||
switch (new_rec_state)
|
switch (new_rec_state) {
|
||||||
{
|
|
||||||
case ANSWERED:
|
case ANSWERED:
|
||||||
stamp_call (record, "answered");
|
stamp_call (record, "answered");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ENDED:
|
case ENDED:
|
||||||
stamp_call (record, "end");
|
stamp_call (record, "end");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
break;
|
break;
|
||||||
|
@ -621,11 +568,11 @@ state_changed_cb (CallsRecordStore *self,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ANSWERED:
|
case ANSWERED:
|
||||||
switch (new_rec_state)
|
switch (new_rec_state) {
|
||||||
{
|
|
||||||
case ENDED:
|
case ENDED:
|
||||||
stamp_call (record, "end");
|
stamp_call (record, "end");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
break;
|
break;
|
||||||
|
@ -651,8 +598,7 @@ call_added_cb (CallsRecordStore *self,
|
||||||
g_object_set_data_full (call_obj, "calls-call-start",
|
g_object_set_data_full (call_obj, "calls-call-start",
|
||||||
start, (GDestroyNotify)g_date_time_unref);
|
start, (GDestroyNotify)g_date_time_unref);
|
||||||
|
|
||||||
if (!self->repository)
|
if (!self->repository) {
|
||||||
{
|
|
||||||
open_repo (self);
|
open_repo (self);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -676,9 +622,7 @@ call_removed_cb (CallsRecordStore *self,
|
||||||
g_object_get_data (G_OBJECT (call), "calls-call-record");
|
g_object_get_data (G_OBJECT (call), "calls-call-record");
|
||||||
|
|
||||||
if (record)
|
if (record)
|
||||||
{
|
|
||||||
stamp_call (record, "end");
|
stamp_call (record, "end");
|
||||||
}
|
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_data (call, self);
|
g_signal_handlers_disconnect_by_data (call, self);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue