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