diff --git a/plugins/dummy/calls-dummy-call.c b/plugins/dummy/calls-dummy-call.c index 1cfb064..07fdf4e 100644 --- a/plugins/dummy/calls-dummy-call.c +++ b/plugins/dummy/calls-dummy-call.c @@ -29,8 +29,7 @@ #include -struct _CallsDummyCall -{ +struct _CallsDummyCall { GObject parent_instance; }; @@ -83,7 +82,7 @@ outbound_timeout_cb (CallsDummyCall *self) case CALLS_CALL_STATE_DIALING: calls_call_set_state (call, CALLS_CALL_STATE_ALERTING); g_timeout_add_seconds - (3, (GSourceFunc)outbound_timeout_cb, self); + (3, (GSourceFunc) outbound_timeout_cb, self); break; case CALLS_CALL_STATE_ALERTING: @@ -116,7 +115,7 @@ constructed (GObject *object) CallsDummyCall *self = CALLS_DUMMY_CALL (object); if (!calls_call_get_inbound (CALLS_CALL (object))) - g_timeout_add_seconds (1, (GSourceFunc)outbound_timeout_cb, self); + g_timeout_add_seconds (1, (GSourceFunc) outbound_timeout_cb, self); G_OBJECT_CLASS (calls_dummy_call_parent_class)->constructed (object); } diff --git a/plugins/dummy/calls-dummy-origin.c b/plugins/dummy/calls-dummy-origin.c index 94a8ad9..87a7a41 100644 --- a/plugins/dummy/calls-dummy-origin.c +++ b/plugins/dummy/calls-dummy-origin.c @@ -31,11 +31,10 @@ #include -struct _CallsDummyOrigin -{ - GObject parent_instance; +struct _CallsDummyOrigin { + GObject parent_instance; GString *name; - GList *calls; + GList *calls; }; static void calls_dummy_origin_message_source_interface_init (CallsOriginInterface *iface); @@ -54,8 +53,8 @@ enum { /* Property for setting the origins name upon construction */ PROP_DUMMY_NAME_CONSTRUCTOR, - /* The origins name. The implements the name property from CallsOrigin. - * Readonly property, can't be set directly. */ + /* The origins name. The implements the name property from CallsOrigin. + * Readonly property, can't be set directly. */ PROP_NAME, PROP_CALLS, @@ -99,8 +98,7 @@ remove_calls (CallsDummyOrigin *self, const gchar *reason) } -struct DisconnectedData -{ +struct DisconnectedData { CallsDummyOrigin *self; CallsCall *call; }; @@ -194,10 +192,10 @@ set_property (GObject *object, static void -get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { CallsDummyOrigin *self = CALLS_DUMMY_ORIGIN (object); diff --git a/plugins/dummy/calls-dummy-origin.h b/plugins/dummy/calls-dummy-origin.h index e99ba2f..a050610 100644 --- a/plugins/dummy/calls-dummy-origin.h +++ b/plugins/dummy/calls-dummy-origin.h @@ -22,8 +22,7 @@ * */ -#ifndef CALLS_DUMMY_ORIGIN_H__ -#define CALLS_DUMMY_ORIGIN_H__ +#pragma once #include @@ -33,10 +32,8 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (CallsDummyOrigin, calls_dummy_origin, CALLS, DUMMY_ORIGIN, GObject); -CallsDummyOrigin *calls_dummy_origin_new (const gchar *name); +CallsDummyOrigin *calls_dummy_origin_new (const gchar *name); void calls_dummy_origin_create_inbound (CallsDummyOrigin *self, const gchar *number); G_END_DECLS - -#endif /* CALLS_DUMMY_ORIGIN_H__ */ diff --git a/plugins/dummy/calls-dummy-provider.c b/plugins/dummy/calls-dummy-provider.c index fe9d05d..6105677 100644 --- a/plugins/dummy/calls-dummy-provider.c +++ b/plugins/dummy/calls-dummy-provider.c @@ -37,11 +37,10 @@ static const char * const supported_protocols[] = { NULL }; -struct _CallsDummyProvider -{ +struct _CallsDummyProvider { CallsProvider parent_instance; - GListStore *origins; + GListStore *origins; }; static void calls_dummy_provider_message_source_interface_init (CallsMessageSourceInterface *iface); @@ -50,16 +49,16 @@ static void calls_dummy_provider_message_source_interface_init (CallsMessageSour #ifdef FOR_TESTING G_DEFINE_TYPE_WITH_CODE -(CallsDummyProvider, calls_dummy_provider, CALLS_TYPE_PROVIDER, - G_IMPLEMENT_INTERFACE (CALLS_TYPE_MESSAGE_SOURCE, - calls_dummy_provider_message_source_interface_init)) + (CallsDummyProvider, calls_dummy_provider, CALLS_TYPE_PROVIDER, + G_IMPLEMENT_INTERFACE (CALLS_TYPE_MESSAGE_SOURCE, + calls_dummy_provider_message_source_interface_init)) #else G_DEFINE_DYNAMIC_TYPE_EXTENDED -(CallsDummyProvider, calls_dummy_provider, CALLS_TYPE_PROVIDER, 0, - G_IMPLEMENT_INTERFACE_DYNAMIC (CALLS_TYPE_MESSAGE_SOURCE, - calls_dummy_provider_message_source_interface_init)) + (CallsDummyProvider, calls_dummy_provider, CALLS_TYPE_PROVIDER, 0, + G_IMPLEMENT_INTERFACE_DYNAMIC (CALLS_TYPE_MESSAGE_SOURCE, + calls_dummy_provider_message_source_interface_init)) #endif /* FOR_TESTING */ @@ -68,7 +67,8 @@ static gboolean usr1_handler (CallsDummyProvider *self) { GListModel *model; - g_autoptr(CallsDummyOrigin) origin = NULL; + + g_autoptr (CallsDummyOrigin) origin = NULL; model = G_LIST_MODEL (self->origins); g_return_val_if_fail (g_list_model_get_n_items (model) > 0, FALSE); @@ -85,8 +85,9 @@ usr1_handler (CallsDummyProvider *self) static gboolean usr2_handler (CallsDummyProvider *self) { + g_autoptr (CallsDummyOrigin) origin = NULL; + GListModel *model; - g_autoptr(CallsDummyOrigin) origin = NULL; model = G_LIST_MODEL (self->origins); g_return_val_if_fail (g_list_model_get_n_items (model) > 0, FALSE); @@ -120,7 +121,7 @@ calls_dummy_provider_get_origins (CallsProvider *provider) return G_LIST_MODEL (self->origins); } -static const char * const * +static const char *const * calls_dummy_provider_get_protocols (CallsProvider *provider) { return supported_protocols; @@ -140,7 +141,7 @@ constructed (GObject *object) calls_dummy_provider_add_origin (self, "Dummy origin"); g_unix_signal_add (SIGUSR1, - (GSourceFunc)usr1_handler, + (GSourceFunc) usr1_handler, self); g_unix_signal_add (SIGUSR2, (GSourceFunc) usr2_handler, diff --git a/plugins/dummy/calls-dummy-provider.h b/plugins/dummy/calls-dummy-provider.h index 3df9df6..f94996e 100644 --- a/plugins/dummy/calls-dummy-provider.h +++ b/plugins/dummy/calls-dummy-provider.h @@ -37,9 +37,9 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (CallsDummyProvider, calls_dummy_provider, CALLS, DUMMY_PROVIDER, CallsProvider) CallsDummyProvider *calls_dummy_provider_new (void); -void calls_dummy_provider_add_origin (CallsDummyProvider *self, - const gchar *name); -void peas_register_types (PeasObjectModule *module); +void calls_dummy_provider_add_origin (CallsDummyProvider *self, + const gchar *name); +void peas_register_types (PeasObjectModule *module); G_END_DECLS diff --git a/plugins/mm/calls-mm-call.c b/plugins/mm/calls-mm-call.c index b055cf6..bfe15e6 100644 --- a/plugins/mm/calls-mm-call.c +++ b/plugins/mm/calls-mm-call.c @@ -33,11 +33,10 @@ #include -struct _CallsMMCall -{ +struct _CallsMMCall { GObject parent_instance; MMCall *mm_call; - gchar *disconnect_reason; + gchar *disconnect_reason; }; static void calls_mm_call_message_source_interface_init (CallsMessageSourceInterface *iface); @@ -61,10 +60,9 @@ notify_id_cb (CallsMMCall *self, } -struct CallsMMCallStateReasonMap -{ - MMCallStateReason value; - const gchar *desc; +struct CallsMMCallStateReasonMap { + MMCallStateReason value; + const gchar *desc; }; static const struct CallsMMCallStateReasonMap STATE_REASON_MAP[] = { @@ -89,39 +87,34 @@ static const struct CallsMMCallStateReasonMap STATE_REASON_MAP[] = { }; static void -set_disconnect_reason (CallsMMCall *self, - MMCallStateReason reason) +set_disconnect_reason (CallsMMCall *self, + MMCallStateReason reason) { const struct CallsMMCallStateReasonMap *map_row; if (self->disconnect_reason) - { - g_free (self->disconnect_reason); - } + g_free (self->disconnect_reason); - for (map_row = STATE_REASON_MAP; map_row->desc; ++map_row) - { - if (map_row->value == reason) - { - self->disconnect_reason = - g_strdup (gettext (map_row->desc)); - return; - } + for (map_row = STATE_REASON_MAP; map_row->desc; ++map_row) { + if (map_row->value == reason) { + self->disconnect_reason = + g_strdup (gettext (map_row->desc)); + return; } + } self->disconnect_reason = g_strdup_printf (_("Call disconnected (unknown reason code %i)"), - (int)reason); + (int) reason); g_warning ("%s", self->disconnect_reason); } -struct CallsMMCallStateMap -{ - MMCallState mm; - CallsCallState calls; - const gchar *name; +struct CallsMMCallStateMap { + MMCallState mm; + CallsCallState calls; + const gchar *name; }; static const struct CallsMMCallStateMap STATE_MAP[] = { @@ -144,28 +137,24 @@ static const struct CallsMMCallStateMap STATE_MAP[] = { }; static void -state_changed_cb (CallsMMCall *self, - MMCallState old, - MMCallState mm_new, - MMCallStateReason reason) +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); - } + 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); - calls_call_set_state (CALLS_CALL (self), map_row->calls); - return; - } + 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); + calls_call_set_state (CALLS_CALL (self), map_row->calls); + return; } + } } @@ -175,11 +164,10 @@ calls_mm_call_get_protocol (CallsCall *self) return "tel"; } -struct CallsMMOperationData -{ +struct CallsMMOperationData { const gchar *desc; CallsMMCall *self; - gboolean (*finish_func) (MMCall *, GAsyncResult *, GError **); + gboolean (*finish_func) (MMCall *, GAsyncResult *, GError **); }; static void @@ -188,17 +176,17 @@ operation_cb (MMCall *mm_call, struct CallsMMOperationData *data) { gboolean ok; + g_autoptr (GError) error = NULL; ok = data->finish_func (mm_call, res, &error); - if (!ok) - { - g_warning ("Error %s ModemManager call to `%s': %s", - data->desc, - calls_call_get_id (CALLS_CALL (data->self)), - error->message); - CALLS_ERROR (data->self, error); - } + if (!ok) { + g_warning ("Error %s ModemManager call to `%s': %s", + data->desc, + calls_call_get_id (CALLS_CALL (data->self)), + error->message); + CALLS_ERROR (data->self, error); + } g_free (data); } @@ -222,9 +210,9 @@ operation_cb (MMCall *mm_call, data); \ } -DEFINE_OPERATION(accept, calls_mm_call_answer, "accepting"); -DEFINE_OPERATION(hangup, calls_mm_call_hang_up, "hanging up"); -DEFINE_OPERATION(start, calls_mm_call_start_call, "starting outgoing call"); +DEFINE_OPERATION (accept, calls_mm_call_answer, "accepting"); +DEFINE_OPERATION (hangup, calls_mm_call_hang_up, "hanging up"); +DEFINE_OPERATION (start, calls_mm_call_start_call, "starting outgoing call"); static void @@ -241,10 +229,10 @@ calls_mm_call_send_dtmf_tone (CallsCall *call, gchar key) mm_call_send_dtmf (self->mm_call, - key_str, - NULL, - (GAsyncReadyCallback) operation_cb, - data); + key_str, + NULL, + (GAsyncReadyCallback) operation_cb, + data); } diff --git a/plugins/mm/calls-mm-origin.c b/plugins/mm/calls-mm-origin.c index 9ab09b8..0f3918e 100644 --- a/plugins/mm/calls-mm-origin.c +++ b/plugins/mm/calls-mm-origin.c @@ -34,26 +34,25 @@ #include -struct _CallsMMOrigin -{ - GObject parent_instance; - MMObject *mm_obj; - MMModemVoice *voice; +struct _CallsMMOrigin { + GObject parent_instance; + MMObject *mm_obj; + MMModemVoice *voice; MMModem3gppUssd *ussd; - MMSim *sim; + MMSim *sim; /* XXX: These should be used only for pointer comparison, * The content should never be used as it might be * pointing to a freed location */ - char *last_ussd_request; - char *last_ussd_response; + char *last_ussd_request; + char *last_ussd_response; gulong ussd_handle_id; - char *id; - char *name; - GHashTable *calls; - char *country_code; + char *id; + char *name; + GHashTable *calls; + char *country_code; }; static void calls_mm_origin_message_source_interface_init (CallsOriginInterface *iface); @@ -85,8 +84,9 @@ ussd_initiate_cb (GObject *object, GAsyncResult *result, gpointer user_data) { - MMModem3gppUssd *ussd = (MMModem3gppUssd *)object; - g_autoptr(GTask) task = user_data; + MMModem3gppUssd *ussd = (MMModem3gppUssd *) object; + + g_autoptr (GTask) task = user_data; CallsMMOrigin *self = user_data; char *response = NULL; GError *error = NULL; @@ -110,8 +110,9 @@ ussd_reinitiate_cb (GObject *object, GAsyncResult *result, gpointer user_data) { - CallsUssd *ussd = (CallsUssd *)object; - g_autoptr(GTask) task = user_data; + CallsUssd *ussd = (CallsUssd *) object; + + g_autoptr (GTask) task = user_data; CallsMMOrigin *self = user_data; GCancellable *cancellable; GError *error = NULL; @@ -139,9 +140,10 @@ ussd_respond_cb (GObject *object, GAsyncResult *result, gpointer user_data) { - MMModem3gppUssd *ussd = (MMModem3gppUssd *)object; + MMModem3gppUssd *ussd = (MMModem3gppUssd *) object; CallsMMOrigin *self; - g_autoptr(GTask) task = user_data; + + g_autoptr (GTask) task = user_data; char *response = NULL; GError *error = NULL; @@ -164,9 +166,10 @@ ussd_cancel_cb (GObject *object, GAsyncResult *result, gpointer user_data) { - MMModem3gppUssd *ussd = (MMModem3gppUssd *)object; + MMModem3gppUssd *ussd = (MMModem3gppUssd *) object; CallsMMOrigin *self; - g_autoptr(GTask) task = user_data; + + g_autoptr (GTask) task = user_data; GError *error = NULL; gboolean response; @@ -196,33 +199,32 @@ calls_mm_ussd_get_state (CallsUssd *ussd) } static void -calls_mm_ussd_initiate_async (CallsUssd *ussd, - const char *command, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +calls_mm_ussd_initiate_async (CallsUssd *ussd, + const char *command, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { CallsMMOrigin *self = CALLS_MM_ORIGIN (ussd); - g_autoptr(GTask) task = NULL; + + g_autoptr (GTask) task = NULL; CallsUssdState state; g_return_if_fail (CALLS_IS_USSD (ussd)); task = g_task_new (self, cancellable, callback, user_data); - if (!self->ussd) - { - g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, - "No USSD interface found"); - return; - } + if (!self->ussd) { + g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, + "No USSD interface found"); + return; + } - if (!command || !*command) - { - g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, - "USSD command empty"); - return; - } + if (!command || !*command) { + g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, + "USSD command empty"); + return; + } state = calls_ussd_get_state (CALLS_USSD (self)); g_task_set_task_data (task, g_strdup (command), g_free); @@ -237,9 +239,9 @@ calls_mm_ussd_initiate_async (CallsUssd *ussd, } static char * -calls_mm_ussd_initiate_finish (CallsUssd *ussd, - GAsyncResult *result, - GError **error) +calls_mm_ussd_initiate_finish (CallsUssd *ussd, + GAsyncResult *result, + GError **error) { g_return_val_if_fail (CALLS_IS_USSD (ussd), NULL); g_return_val_if_fail (G_IS_TASK (result), NULL); @@ -249,11 +251,11 @@ calls_mm_ussd_initiate_finish (CallsUssd *ussd, } static void -calls_mm_ussd_respond_async (CallsUssd *ussd, - const char *response, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +calls_mm_ussd_respond_async (CallsUssd *ussd, + const char *response, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { CallsMMOrigin *self = CALLS_MM_ORIGIN (ussd); GTask *task; @@ -266,9 +268,9 @@ calls_mm_ussd_respond_async (CallsUssd *ussd, } static char * -calls_mm_ussd_respond_finish (CallsUssd *ussd, - GAsyncResult *result, - GError **error) +calls_mm_ussd_respond_finish (CallsUssd *ussd, + GAsyncResult *result, + GError **error) { g_return_val_if_fail (CALLS_IS_USSD (ussd), NULL); g_return_val_if_fail (G_IS_TASK (result), NULL); @@ -278,10 +280,10 @@ calls_mm_ussd_respond_finish (CallsUssd *ussd, } static void -calls_mm_ussd_cancel_async (CallsUssd *ussd, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +calls_mm_ussd_cancel_async (CallsUssd *ussd, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { CallsMMOrigin *self = CALLS_MM_ORIGIN (ussd); GTask *task; @@ -294,9 +296,9 @@ calls_mm_ussd_cancel_async (CallsUssd *ussd, } static gboolean -calls_mm_ussd_cancel_finish (CallsUssd *ussd, - GAsyncResult *result, - GError **error) +calls_mm_ussd_cancel_finish (CallsUssd *ussd, + GAsyncResult *result, + GError **error) { g_return_val_if_fail (CALLS_IS_USSD (ussd), FALSE); g_return_val_if_fail (G_IS_TASK (result), FALSE); @@ -312,15 +314,15 @@ dial_cb (MMModemVoice *voice, CallsMMOrigin *self) { MMCall *call; + g_autoptr (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); - } + if (!call) { + g_warning ("Error dialing number on ModemManager modem `%s': %s", + self->name, error->message); + CALLS_ERROR (self, error); + } } @@ -337,10 +339,10 @@ dial (CallsOrigin *origin, const gchar *number) mm_modem_voice_create_call (self->voice, - call_props, - NULL, - (GAsyncReadyCallback) dial_cb, - self); + call_props, + NULL, + (GAsyncReadyCallback) dial_cb, + self); g_object_unref (call_props); } @@ -365,22 +367,20 @@ remove_calls (CallsMMOrigin *self, const gchar *reason) paths = g_hash_table_get_keys (self->calls); - for (node = paths; node != NULL; node = node->next) - { - g_hash_table_steal_extended (self->calls, node->data, NULL, &call); - g_signal_emit_by_name (self, "call-removed", - CALLS_CALL(call), reason); - g_object_unref (call); - } + for (node = paths; node != NULL; node = node->next) { + g_hash_table_steal_extended (self->calls, node->data, NULL, &call); + g_signal_emit_by_name (self, "call-removed", + CALLS_CALL (call), reason); + g_object_unref (call); + } g_list_free_full (paths, g_free); } -struct CallsMMOriginDeleteCallData -{ +struct CallsMMOriginDeleteCallData { CallsMMOrigin *self; - gchar *path; + gchar *path; }; @@ -390,15 +390,15 @@ delete_call_cb (MMModemVoice *voice, struct CallsMMOriginDeleteCallData *data) { gboolean ok; + g_autoptr (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); - } + 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); @@ -406,8 +406,8 @@ delete_call_cb (MMModemVoice *voice, static void -delete_call (CallsMMOrigin *self, - CallsMMCall *call) +delete_call (CallsMMOrigin *self, + CallsMMCall *call) { const gchar *path; struct CallsMMOriginDeleteCallData *data; @@ -420,10 +420,10 @@ delete_call (CallsMMOrigin *self, mm_modem_voice_delete_call (self->voice, - path, - NULL, - (GAsyncReadyCallback)delete_call_cb, - data); + path, + NULL, + (GAsyncReadyCallback) delete_call_cb, + data); } static void @@ -457,14 +457,13 @@ add_call (CallsMMOrigin *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)); + 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); - } + 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); @@ -476,10 +475,9 @@ add_call (CallsMMOrigin *self, } -struct CallsMMOriginCallAddedData -{ +struct CallsMMOriginCallAddedData { CallsMMOrigin *self; - gchar *path; + gchar *path; }; @@ -488,53 +486,45 @@ call_added_list_calls_cb (MMModemVoice *voice, GAsyncResult *res, struct CallsMMOriginCallAddedData *data) { - GList *calls; g_autoptr (GError) error = NULL; + GList *calls; + 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); - } + 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; + } else { + GList *node; + MMCall *call; + gboolean found = FALSE; - for (node = calls; node; node = node->next) - { - call = MM_CALL (node->data); + 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); + 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); } @@ -547,12 +537,11 @@ call_added_cb (MMModemVoice *voice, { 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; - } + 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; @@ -560,9 +549,9 @@ call_added_cb (MMModemVoice *voice, mm_modem_voice_list_calls (voice, - NULL, - (GAsyncReadyCallback) call_added_list_calls_cb, - data); + NULL, + (GAsyncReadyCallback) call_added_list_calls_cb, + data); } @@ -582,19 +571,17 @@ call_deleted_cb (MMModemVoice *voice, g_free (key); - if (!call) - { - g_warning ("Could not find removed call `%s'", path); - return; - } + 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 (CALLS_MM_CALL (call)); - if (mm_reason) - { - g_string_assign (reason, mm_reason); - } + if (mm_reason) { + g_string_assign (reason, mm_reason); + } g_signal_emit_by_name (self, "call-removed", call, reason); @@ -611,24 +598,22 @@ list_calls_cb (MMModemVoice *voice, CallsMMOrigin *self) { GList *calls, *node; + g_autoptr (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; + 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)); - } + for (node = calls; node; node = node->next) { + add_call (self, MM_CALL (node->data)); + } g_list_free_full (calls, g_object_unref); } @@ -648,7 +633,7 @@ set_property (GObject *object, break; case PROP_MODEM: - g_set_object (&self->mm_obj, g_value_get_object(value)); + g_set_object (&self->mm_obj, g_value_get_object (value)); break; default: @@ -659,10 +644,10 @@ set_property (GObject *object, static void -get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { CallsMMOrigin *self = CALLS_MM_ORIGIN (object); @@ -676,7 +661,7 @@ get_property (GObject *object, break; case PROP_CALLS: - g_value_set_pointer(value, g_hash_table_get_values (self->calls)); + g_value_set_pointer (value, g_hash_table_get_values (self->calls)); break; case PROP_COUNTRY_CODE: @@ -741,30 +726,28 @@ ussd_properties_changed_cb (CallsMMOrigin *self, /* XXX: We check for user state only because the NetworkRequest * dbus property change isn't regularly emitted */ if (state == CALLS_USSD_STATE_USER_RESPONSE || - (value = g_variant_lookup_value (properties, "NetworkRequest", NULL))) - { - response = mm_modem_3gpp_ussd_get_network_request (self->ussd); + (value = g_variant_lookup_value (properties, "NetworkRequest", NULL))) { + response = mm_modem_3gpp_ussd_get_network_request (self->ussd); - if (response && *response && response != self->last_ussd_request) - g_signal_emit_by_name (self, "ussd-added", response); + if (response && *response && response != self->last_ussd_request) + g_signal_emit_by_name (self, "ussd-added", response); - if (response && *response) - self->last_ussd_request = (char *)response; - g_clear_pointer (&value, g_variant_unref); - } + if (response && *response) + self->last_ussd_request = (char *) response; + g_clear_pointer (&value, g_variant_unref); + } if (state != CALLS_USSD_STATE_USER_RESPONSE && - (value = g_variant_lookup_value (properties, "NetworkNotification", NULL))) - { - response = mm_modem_3gpp_ussd_get_network_notification (self->ussd); + (value = g_variant_lookup_value (properties, "NetworkNotification", NULL))) { + response = mm_modem_3gpp_ussd_get_network_notification (self->ussd); - if (response && *response && response != self->last_ussd_response) - g_signal_emit_by_name (self, "ussd-added", response); + if (response && *response && response != self->last_ussd_response) + g_signal_emit_by_name (self, "ussd-added", response); - if (response && *response) - self->last_ussd_response = (char *)response; - g_clear_pointer (&value, g_variant_unref); - } + if (response && *response) + self->last_ussd_response = (char *) response; + g_clear_pointer (&value, g_variant_unref); + } } static void @@ -838,9 +821,9 @@ constructed (GObject *object) mm_modem_voice_list_calls (self->voice, - NULL, - (GAsyncReadyCallback) list_calls_cb, - self); + NULL, + (GAsyncReadyCallback) list_calls_cb, + self); G_OBJECT_CLASS (calls_mm_origin_parent_class)->constructed (object); } @@ -915,12 +898,12 @@ static void calls_mm_origin_ussd_interface_init (CallsUssdInterface *iface) { iface->get_state = calls_mm_ussd_get_state; - iface->initiate_async = calls_mm_ussd_initiate_async; + iface->initiate_async = calls_mm_ussd_initiate_async; iface->initiate_finish = calls_mm_ussd_initiate_finish; - iface->respond_async = calls_mm_ussd_respond_async; - iface->respond_finish = calls_mm_ussd_respond_finish; - iface->cancel_async = calls_mm_ussd_cancel_async; - iface->cancel_finish = calls_mm_ussd_cancel_finish; + iface->respond_async = calls_mm_ussd_respond_async; + iface->respond_finish = calls_mm_ussd_respond_finish; + iface->cancel_async = calls_mm_ussd_cancel_async; + iface->cancel_finish = calls_mm_ussd_cancel_finish; } @@ -962,4 +945,3 @@ calls_mm_origin_matches (CallsMMOrigin *self, return FALSE; } - diff --git a/plugins/mm/calls-mm-provider.c b/plugins/mm/calls-mm-provider.c index 53fb3d2..4424958 100644 --- a/plugins/mm/calls-mm-provider.c +++ b/plugins/mm/calls-mm-provider.c @@ -39,26 +39,25 @@ static const char * const supported_protocols[] = { NULL }; -struct _CallsMMProvider -{ +struct _CallsMMProvider { CallsProvider parent_instance; /* The status property */ - gchar *status; + gchar *status; /** ID for the D-Bus watch */ - guint watch_id; + guint watch_id; /** ModemManager object proxy */ - MMManager *mm; + MMManager *mm; /* A list of CallsOrigins */ - GListStore *origins; + GListStore *origins; }; static void calls_mm_provider_message_source_interface_init (CallsMessageSourceInterface *iface); G_DEFINE_DYNAMIC_TYPE_EXTENDED -(CallsMMProvider, calls_mm_provider, CALLS_TYPE_PROVIDER, 0, - G_IMPLEMENT_INTERFACE_DYNAMIC (CALLS_TYPE_MESSAGE_SOURCE, - calls_mm_provider_message_source_interface_init)) + (CallsMMProvider, calls_mm_provider, CALLS_TYPE_PROVIDER, 0, + G_IMPLEMENT_INTERFACE_DYNAMIC (CALLS_TYPE_MESSAGE_SOURCE, + calls_mm_provider_message_source_interface_init)) static void @@ -66,9 +65,7 @@ set_status (CallsMMProvider *self, const gchar *new_status) { if (strcmp (self->status, new_status) == 0) - { - return; - } + return; g_free (self->status); self->status = g_strdup (new_status); @@ -81,18 +78,13 @@ update_status (CallsMMProvider *self) { const gchar *s; - if (!self->mm) - { - s = _("ModemManager unavailable"); - } - else if (g_list_model_get_n_items (G_LIST_MODEL (self->origins)) == 0) - { - s = _("No voice-capable modem available"); - } - else - { - s = _("Normal"); - } + if (!self->mm) { + s = _("ModemManager unavailable"); + } else if (g_list_model_get_n_items (G_LIST_MODEL (self->origins)) == 0) { + s = _("No voice-capable modem available"); + } else { + s = _("Normal"); + } set_status (self, s); } @@ -111,15 +103,14 @@ mm_provider_contains (CallsMMProvider *self, model = G_LIST_MODEL (self->origins); n_items = g_list_model_get_n_items (model); - for (guint i = 0; i < n_items; i++) - { - g_autoptr(CallsMMOrigin) origin = NULL; + for (guint i = 0; i < n_items; i++) { + g_autoptr (CallsMMOrigin) origin = NULL; - origin = g_list_model_get_item (model, i); + origin = g_list_model_get_item (model, i); - if (calls_mm_origin_matches (origin, mm_obj)) - return TRUE; - } + if (calls_mm_origin_matches (origin, mm_obj)) + return TRUE; + } return FALSE; } @@ -129,6 +120,7 @@ add_origin (CallsMMProvider *self, GDBusObject *object) { MMObject *mm_obj; + g_autoptr (CallsMMOrigin) origin = NULL; g_autoptr (MMModem3gpp) modem_3gpp = NULL; const gchar *path; @@ -136,12 +128,11 @@ add_origin (CallsMMProvider *self, mm_obj = MM_OBJECT (object); path = g_dbus_object_get_object_path (object); - if (mm_provider_contains (self, mm_obj)) - { - g_warning ("New voice interface on existing" - " origin with path `%s'", path); - return; - } + if (mm_provider_contains (self, mm_obj)) { + g_warning ("New voice interface on existing" + " origin with path `%s'", path); + return; + } g_debug ("Adding new voice-capable modem `%s'", path); @@ -172,10 +163,9 @@ interface_added_cb (CallsMMProvider *self, g_dbus_object_get_object_path (object)); if (g_strcmp0 (info->name, - "org.freedesktop.ModemManager1.Modem.Voice") == 0) - { - add_origin (self, object); - } + "org.freedesktop.ModemManager1.Modem.Voice") == 0) { + add_origin (self, object); + } } @@ -195,13 +185,12 @@ remove_modem_object (CallsMMProvider *self, origin = g_list_model_get_item (model, i); - if (calls_mm_origin_matches (origin, MM_OBJECT (object))) - { - g_list_store_remove (self->origins, i); - update_status (self); + if (calls_mm_origin_matches (origin, MM_OBJECT (object))) { + g_list_store_remove (self->origins, i); + update_status (self); - break; - } + break; + } } } @@ -221,10 +210,9 @@ interface_removed_cb (CallsMMProvider *self, info->name, path); if (g_strcmp0 (info->name, - "org.freedesktop.ModemManager1.Modem.Voice") == 0) - { - remove_modem_object (self, path, object); - } + "org.freedesktop.ModemManager1.Modem.Voice") == 0) { + remove_modem_object (self, path, object); + } } @@ -234,11 +222,10 @@ 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)); - } + 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); } @@ -250,10 +237,9 @@ 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)); - } + for (node = objects; node; node = node->next) { + add_mm_object (self, G_DBUS_OBJECT (node->data)); + } g_list_free_full (objects, g_object_unref); } @@ -285,18 +271,17 @@ object_removed_cb (CallsMMProvider *self, static void mm_manager_new_cb (GDBusConnection *connection, - GAsyncResult *res, + 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(); - } + 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), @@ -319,8 +304,8 @@ mm_manager_new_cb (GDBusConnection *connection, static void mm_appeared_cb (GDBusConnection *connection, - const gchar *name, - const gchar *name_owner, + const gchar *name, + const gchar *name_owner, CallsMMProvider *self) { g_debug ("ModemManager appeared on D-Bus"); @@ -335,7 +320,7 @@ mm_appeared_cb (GDBusConnection *connection, static void mm_vanished_cb (GDBusConnection *connection, - const gchar *name, + const gchar *name, CallsMMProvider *self) { g_debug ("ModemManager vanished from D-Bus"); @@ -366,7 +351,7 @@ calls_mm_provider_get_origins (CallsProvider *provider) return G_LIST_MODEL (self->origins); } -static const char * const * +static const char *const * calls_mm_provider_get_protocols (CallsProvider *provider) { return supported_protocols; @@ -387,8 +372,8 @@ constructed (GObject *object) 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, + (GBusNameAppearedCallback) mm_appeared_cb, + (GBusNameVanishedCallback) mm_vanished_cb, self, NULL); g_debug ("Watching for ModemManager"); @@ -402,11 +387,10 @@ dispose (GObject *object) { CallsMMProvider *self = CALLS_MM_PROVIDER (object); - if (self->watch_id) - { - g_bus_unwatch_name (self->watch_id); - self->watch_id = 0; - } + if (self->watch_id) { + g_bus_unwatch_name (self->watch_id); + self->watch_id = 0; + } g_list_store_remove_all (self->origins); diff --git a/plugins/mm/calls-mm-provider.h b/plugins/mm/calls-mm-provider.h index 88c455e..a6351c1 100644 --- a/plugins/mm/calls-mm-provider.h +++ b/plugins/mm/calls-mm-provider.h @@ -37,7 +37,7 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (CallsMMProvider, calls_mm_provider, CALLS, MM_PROVIDER, CallsProvider) -void peas_register_types (PeasObjectModule *module); +void peas_register_types (PeasObjectModule *module); G_END_DECLS diff --git a/plugins/mm/itu-e212-iso.h b/plugins/mm/itu-e212-iso.h index 545916e..b2df64b 100644 --- a/plugins/mm/itu-e212-iso.h +++ b/plugins/mm/itu-e212-iso.h @@ -16,10 +16,9 @@ #include -struct mcc_list -{ +struct mcc_list { guint mcc; - char code[3]; + char code[3]; }; /* diff --git a/plugins/ofono/calls-ofono-call.c b/plugins/ofono/calls-ofono-call.c index 8318ec2..8b6b2da 100644 --- a/plugins/ofono/calls-ofono-call.c +++ b/plugins/ofono/calls-ofono-call.c @@ -31,11 +31,10 @@ #include -struct _CallsOfonoCall -{ - GObject parent_instance; +struct _CallsOfonoCall { + GObject parent_instance; GDBOVoiceCall *voice_call; - gchar *disconnect_reason; + gchar *disconnect_reason; }; static void calls_ofono_call_message_source_interface_init (CallsMessageSourceInterface *iface); @@ -55,7 +54,7 @@ enum { SIGNAL_TONE, SIGNAL_LAST_SIGNAL, }; -static guint signals [SIGNAL_LAST_SIGNAL]; +static guint signals[SIGNAL_LAST_SIGNAL]; static const char * calls_ofono_call_get_protocol (CallsCall *call) @@ -63,11 +62,10 @@ calls_ofono_call_get_protocol (CallsCall *call) return "tel"; } -struct CallsCallOperationData -{ - const gchar *desc; +struct CallsCallOperationData { + const gchar *desc; CallsOfonoCall *self; - gboolean (*finish_func) (GDBOVoiceCall *, GAsyncResult *, GError **); + gboolean (*finish_func) (GDBOVoiceCall *, GAsyncResult *, GError **); }; @@ -76,9 +74,10 @@ operation_cb (GDBOVoiceCall *voice_call, GAsyncResult *res, struct CallsCallOperationData *data) { - gboolean ok; g_autoptr (GError) error = NULL; + gboolean ok; + ok = data->finish_func (voice_call, res, &error); if (!ok) { g_warning ("Error %s oFono voice call to `%s': %s", @@ -106,8 +105,8 @@ calls_ofono_call_answer (CallsCall *call) gdbo_voice_call_call_answer (self->voice_call, NULL, - (GAsyncReadyCallback) operation_cb, - data); + (GAsyncReadyCallback) operation_cb, + data); } @@ -124,8 +123,8 @@ calls_ofono_call_hang_up (CallsCall *call) gdbo_voice_call_call_hangup (self->voice_call, NULL, - (GAsyncReadyCallback) operation_cb, - data); + (GAsyncReadyCallback) operation_cb, + data); } @@ -133,6 +132,7 @@ static void calls_ofono_call_send_dtmf_tone (CallsCall *call, gchar key) { CallsOfonoCall *self = CALLS_OFONO_CALL (call); + if (calls_call_get_state (call) != CALLS_CALL_STATE_ACTIVE) { g_warning ("Tone start requested for non-active call to `%s'", calls_call_get_id (call)); @@ -200,7 +200,7 @@ property_changed_cb (CallsOfonoCall *self, static void disconnect_reason_cb (CallsOfonoCall *self, - const gchar *reason) + const gchar *reason) { if (reason) { g_free (self->disconnect_reason); @@ -276,11 +276,11 @@ calls_ofono_call_class_init (CallsOfonoCallClass *klass) 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); + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + NULL, NULL, NULL, NULL, + G_TYPE_NONE, + 1, &tone_arg_types); } diff --git a/plugins/ofono/calls-ofono-origin.c b/plugins/ofono/calls-ofono-origin.c index 49d8948..b492e72 100644 --- a/plugins/ofono/calls-ofono-origin.c +++ b/plugins/ofono/calls-ofono-origin.c @@ -32,16 +32,15 @@ #include -struct _CallsOfonoOrigin -{ - GObject parent_instance; - GDBusConnection *connection; - GDBOModem *modem; - gchar *name; +struct _CallsOfonoOrigin { + GObject parent_instance; + GDBusConnection *connection; + GDBOModem *modem; + gchar *name; GDBOVoiceCallManager *voice; - gboolean sending_tones; - GString *tone_queue; - GHashTable *calls; + gboolean sending_tones; + GString *tone_queue; + GHashTable *calls; }; static void calls_ofono_origin_message_source_interface_init (CallsOriginInterface *iface); @@ -66,22 +65,22 @@ static GParamSpec *props[PROP_LAST_PROP]; static void -dial_cb (GDBOVoiceCallManager *voice, - GAsyncResult *res, - CallsOfonoOrigin *self) +dial_cb (GDBOVoiceCallManager *voice, + GAsyncResult *res, + CallsOfonoOrigin *self) { gboolean ok; + g_autoptr (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; - } + (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 */ } @@ -96,11 +95,11 @@ dial (CallsOrigin *origin, const gchar *number) gdbo_voice_call_manager_call_dial (self->voice, - number, - "default" /* default caller id settings */, - NULL, - (GAsyncReadyCallback) dial_cb, - self); + number, + "default" /* default caller id settings */, + NULL, + (GAsyncReadyCallback) dial_cb, + self); } @@ -161,10 +160,10 @@ set_property (GObject *object, static void -get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { CallsOfonoOrigin *self = CALLS_OFONO_ORIGIN (object); @@ -178,7 +177,7 @@ get_property (GObject *object, break; case PROP_CALLS: - g_value_set_pointer(value, g_hash_table_get_values (self->calls)); + g_value_set_pointer (value, g_hash_table_get_values (self->calls)); break; case PROP_COUNTRY_CODE: @@ -199,14 +198,13 @@ remove_call (CallsOfonoOrigin *self, { 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_signal_emit_by_name (CALLS_ORIGIN (self), "call-removed", + CALLS_CALL (call), reason); g_hash_table_remove (self->calls, path); } -struct CallsRemoveCallsData -{ +struct CallsRemoveCallsData { CallsOrigin *origin; const gchar *reason; }; @@ -217,7 +215,7 @@ remove_calls_cb (const gchar *path, struct CallsRemoveCallsData *data) { g_signal_emit_by_name (data->origin, "call-removed", - CALLS_CALL(call), data->reason); + CALLS_CALL (call), data->reason); return TRUE; } @@ -232,8 +230,7 @@ remove_calls (CallsOfonoOrigin *self, const gchar *reason) } -struct CallsVoiceCallProxyNewData -{ +struct CallsVoiceCallProxyNewData { CallsOfonoOrigin *self; GVariant *properties; }; @@ -249,33 +246,28 @@ send_tones_cb (GDBOVoiceCallManager *voice, /* 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); - } + (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); + 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); + 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; - } + g_string_free (self->tone_queue, TRUE); + self->tone_queue = NULL; + } else { + self->sending_tones = FALSE; + } } @@ -285,63 +277,56 @@ tone_cb (CallsOfonoOrigin *self, { 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); - } + 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); + } 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); + gdbo_voice_call_manager_call_send_tones (self->voice, + key_str, + NULL, + (GAsyncReadyCallback) send_tones_cb, + self); - self->sending_tones = TRUE; - } + self->sending_tones = TRUE; + } } static void -voice_call_proxy_new_cb (GDBusConnection *connection, - GAsyncResult *res, +voice_call_proxy_new_cb (GDBusConnection *connection, + GAsyncResult *res, struct CallsVoiceCallProxyNewData *data) { CallsOfonoOrigin *self = data->self; GDBOVoiceCall *voice_call; + g_autoptr (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; - } + 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_hash_table_insert (self->calls, g_strdup (path), call); - g_signal_emit_by_name (CALLS_ORIGIN(self), "call-added", - CALLS_CALL(call)); + g_signal_emit_by_name (CALLS_ORIGIN (self), "call-added", + CALLS_CALL (call)); g_debug ("Call `%s' added", path); } @@ -357,11 +342,10 @@ call_added_cb (GDBOVoiceCallManager *voice, g_debug ("Adding call `%s'", path); - if (g_hash_table_lookup (self->calls, path)) - { - g_warning ("Call `%s' already exists", path); - return; - } + 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; @@ -370,12 +354,12 @@ call_added_cb (GDBOVoiceCallManager *voice, 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_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); } @@ -393,24 +377,22 @@ call_removed_cb (GDBOVoiceCallManager *voice, 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; - } + 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"); - } + 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); @@ -426,21 +408,21 @@ get_calls_cb (GDBOVoiceCallManager *voice, { gboolean ok; GVariant *calls_with_properties = NULL; + g_autoptr (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; - } + (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); @@ -453,10 +435,10 @@ get_calls_cb (GDBOVoiceCallManager *voice, 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_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); @@ -470,15 +452,14 @@ voice_new_cb (GDBusConnection *connection, g_autoptr (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; - } + (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); @@ -487,9 +468,9 @@ voice_new_cb (GDBusConnection *connection, gdbo_voice_call_manager_call_get_calls (self->voice, - NULL, - (GAsyncReadyCallback) get_calls_cb, - self); + NULL, + (GAsyncReadyCallback) get_calls_cb, + self); } @@ -510,18 +491,16 @@ constructed (GObject *object) name = g_object_get_data (G_OBJECT (self->modem), "calls-modem-name"); if (name) - { - self->name = g_strdup (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_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_OBJECT_CLASS (calls_ofono_origin_parent_class)->constructed (object); } @@ -545,10 +524,9 @@ finalize (GObject *object) { CallsOfonoOrigin *self = CALLS_OFONO_ORIGIN (object); - if (self->tone_queue) - { - g_string_free (self->tone_queue, TRUE); - } + if (self->tone_queue) { + g_string_free (self->tone_queue, TRUE); + } g_free (self->name); G_OBJECT_CLASS (calls_ofono_origin_parent_class)->finalize (object); diff --git a/plugins/ofono/calls-ofono-provider.c b/plugins/ofono/calls-ofono-provider.c index 1c2d9fa..8fd7b2b 100644 --- a/plugins/ofono/calls-ofono-provider.c +++ b/plugins/ofono/calls-ofono-provider.c @@ -41,22 +41,21 @@ static const char * const supported_protocols[] = { NULL }; -struct _CallsOfonoProvider -{ - CallsProvider parent_instance; +struct _CallsOfonoProvider { + CallsProvider parent_instance; /* The status property */ - gchar *status; + gchar *status; /** ID for the D-Bus watch */ - guint watch_id; + guint watch_id; /** D-Bus connection */ GDBusConnection *connection; /** D-Bus proxy for the oFono Manager object */ - GDBOManager *manager; + GDBOManager *manager; /** Map of D-Bus object paths to a struct CallsModemData */ - GHashTable *modems; + GHashTable *modems; /* A list of CallsOrigins */ - GListStore *origins; + GListStore *origins; }; @@ -64,19 +63,18 @@ static void calls_ofono_provider_message_source_interface_init (CallsMessageSour G_DEFINE_DYNAMIC_TYPE_EXTENDED -(CallsOfonoProvider, calls_ofono_provider, CALLS_TYPE_PROVIDER, 0, - G_IMPLEMENT_INTERFACE_DYNAMIC (CALLS_TYPE_MESSAGE_SOURCE, - calls_ofono_provider_message_source_interface_init)) + (CallsOfonoProvider, calls_ofono_provider, CALLS_TYPE_PROVIDER, 0, + G_IMPLEMENT_INTERFACE_DYNAMIC (CALLS_TYPE_MESSAGE_SOURCE, + calls_ofono_provider_message_source_interface_init)) static void set_status (CallsOfonoProvider *self, const gchar *new_status) { - if (strcmp (self->status, new_status) == 0) - { - return; - } + if (strcmp (self->status, new_status) == 0) { + return; + } g_free (self->status); self->status = g_strdup (new_status); @@ -92,18 +90,13 @@ update_status (CallsOfonoProvider *self) model = G_LIST_MODEL (self->origins); - if (!self->connection) - { - s = _("DBus unavailable"); - } - else if (g_list_model_get_n_items (model) == 0) - { - s = _("No voice-capable modem available"); - } - else - { - s = _("Normal"); - } + if (!self->connection) { + s = _("DBus unavailable"); + } else if (g_list_model_get_n_items (model) == 0) { + s = _("No voice-capable modem available"); + } else { + s = _("Normal"); + } set_status (self, s); } @@ -122,22 +115,20 @@ ofono_find_origin_index (CallsOfonoProvider *self, model = G_LIST_MODEL (self->origins); n_items = g_list_model_get_n_items (model); - for (guint i = 0; i < n_items; i++) - { - g_autoptr(CallsOfonoOrigin) origin = NULL; + for (guint i = 0; i < n_items; i++) { + g_autoptr (CallsOfonoOrigin) origin = NULL; - origin = g_list_model_get_item (model, i); + origin = g_list_model_get_item (model, i); - if (calls_ofono_origin_matches (origin, path)) - { - if (index) - *index = i; + if (calls_ofono_origin_matches (origin, path)) { + if (index) + *index = i; - update_status (self); + update_status (self); - return TRUE; - } + return TRUE; } + } return FALSE; } @@ -148,14 +139,14 @@ object_array_includes (GVariantIter *iter, { const gchar *str; gboolean found = FALSE; + while (g_variant_iter_loop (iter, "&s", &str)) - { - if (g_strcmp0 (str, needle) == 0) - { - found = TRUE; - break; - } + { + if (g_strcmp0 (str, needle) == 0) { + found = TRUE; + break; } + } g_variant_iter_free (iter); return found; @@ -164,9 +155,9 @@ object_array_includes (GVariantIter *iter, static void modem_check_ifaces (CallsOfonoProvider *self, - GDBOModem *modem, - const gchar *modem_name, - GVariant *ifaces) + GDBOModem *modem, + const gchar *modem_name, + GVariant *ifaces) { gboolean voice; GVariantIter *iter = NULL; @@ -176,32 +167,28 @@ modem_check_ifaces (CallsOfonoProvider *self, g_variant_get (ifaces, "as", &iter); - voice = object_array_includes - (iter, "org.ofono.VoiceCallManager"); + voice = object_array_includes (iter, "org.ofono.VoiceCallManager"); path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (modem)); has_origin = ofono_find_origin_index (self, path, &index); - if (voice && !has_origin) - { - g_autoptr(CallsOfonoOrigin) origin = NULL; + if (voice && !has_origin) { + g_autoptr (CallsOfonoOrigin) origin = NULL; - g_debug ("Adding oFono Origin with path `%s'", path); + g_debug ("Adding oFono Origin with path `%s'", path); - origin = calls_ofono_origin_new (modem); - g_list_store_append (self->origins, origin); - } - else if (!voice && has_origin) - { - g_list_store_remove (self->origins, index); - } + origin = calls_ofono_origin_new (modem); + g_list_store_append (self->origins, origin); + } else if (!voice && has_origin) { + g_list_store_remove (self->origins, index); + } } static void -modem_property_changed_cb (GDBOModem *modem, - const gchar *name, - GVariant *value, +modem_property_changed_cb (GDBOModem *modem, + const gchar *name, + GVariant *value, CallsOfonoProvider *self) { gchar *modem_name; @@ -209,22 +196,19 @@ modem_property_changed_cb (GDBOModem *modem, g_debug ("Modem property `%s' changed", name); if (g_strcmp0 (name, "Interfaces") != 0) - { - return; - } + return; modem_name = g_object_get_data (G_OBJECT (modem), "calls-modem-name"); /* PropertyChanged gives us a variant gvariant containing a string array, - but modem_check_ifaces expects the inner string array gvariant */ - value = g_variant_get_variant(value); + but modem_check_ifaces expects the inner string array gvariant */ + value = g_variant_get_variant (value); modem_check_ifaces (self, modem, modem_name, value); } -struct CallsModemProxyNewData -{ +struct CallsModemProxyNewData { CallsOfonoProvider *self; gchar *name; GVariant *ifaces; @@ -232,8 +216,8 @@ struct CallsModemProxyNewData static void -modem_proxy_new_cb (GDBusConnection *connection, - GAsyncResult *res, +modem_proxy_new_cb (GDBusConnection *connection, + GAsyncResult *res, struct CallsModemProxyNewData *data) { GDBOModem *modem; @@ -241,15 +225,14 @@ modem_proxy_new_cb (GDBusConnection *connection, 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; - } + 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), @@ -263,15 +246,14 @@ modem_proxy_new_cb (GDBusConnection *connection, path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (modem)); - g_hash_table_insert (data->self->modems, g_strdup(path), 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); - } + if (data->ifaces) { + modem_check_ifaces (data->self, modem, + data->name, data->ifaces); + g_variant_unref (data->ifaces); + } g_free (data); @@ -302,7 +284,7 @@ modem_properties_get_name (GVariant *properties) return NULL; } -static const char * const * +static const char *const * calls_ofono_provider_get_protocols (CallsProvider *provider) { return supported_protocols; @@ -324,31 +306,29 @@ modem_added_cb (GDBOManager *manager, g_debug ("Adding modem `%s'", path); - if (g_hash_table_lookup (self->modems, path)) - { - g_warning ("Modem `%s' already exists", path); - return; - } + 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); - } + (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_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); } @@ -373,26 +353,26 @@ modem_removed_cb (GDBOManager *manager, static void -get_modems_cb (GDBOManager *manager, - GAsyncResult *res, +get_modems_cb (GDBOManager *manager, + GAsyncResult *res, CallsOfonoProvider *self) { + g_autoptr (GError) error = NULL; + gboolean ok; GVariant *modems; GVariantIter *modems_iter = NULL; - g_autoptr (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; - } + 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); @@ -403,10 +383,10 @@ get_modems_cb (GDBOManager *manager, 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_debug ("Got modem object path `%s'", path); + modem_added_cb (manager, path, properties, self); + } g_variant_iter_free (modems_iter); g_variant_unref (modems); @@ -435,31 +415,29 @@ calls_ofono_provider_get_origins (CallsProvider *provider) } static void -ofono_appeared_cb (GDBusConnection *connection, - const gchar *name, - const gchar *name_owner, +ofono_appeared_cb (GDBusConnection *connection, + const gchar *name, + const gchar *name_owner, CallsOfonoProvider *self) { g_autoptr (GError) error = NULL; self->connection = connection; - if (!self->connection) - { - g_error ("Error creating D-Bus connection: %s", - error->message); - } + 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); - } + (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); @@ -468,15 +446,15 @@ ofono_appeared_cb (GDBusConnection *connection, gdbo_manager_call_get_modems (self->manager, - NULL, - (GAsyncReadyCallback) get_modems_cb, - self); + NULL, + (GAsyncReadyCallback) get_modems_cb, + self); } static void -ofono_vanished_cb (GDBusConnection *connection, - const gchar *name, +ofono_vanished_cb (GDBusConnection *connection, + const gchar *name, CallsOfonoProvider *self) { g_debug ("Ofono vanished from D-Bus"); diff --git a/plugins/ofono/calls-ofono-provider.h b/plugins/ofono/calls-ofono-provider.h index c65549d..d703771 100644 --- a/plugins/ofono/calls-ofono-provider.h +++ b/plugins/ofono/calls-ofono-provider.h @@ -37,7 +37,7 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (CallsOfonoProvider, calls_ofono_provider, CALLS, OFONO_PROVIDER, CallsProvider) -void peas_register_types (PeasObjectModule *module); +void peas_register_types (PeasObjectModule *module); G_END_DECLS diff --git a/plugins/sip/calls-sip-account-widget.c b/plugins/sip/calls-sip-account-widget.c index e93df37..2d7eb46 100644 --- a/plugins/sip/calls-sip-account-widget.c +++ b/plugins/sip/calls-sip-account-widget.c @@ -97,10 +97,10 @@ is_form_filled (CallsSipAccountWidget *self) g_assert (CALLS_IS_SIP_ACCOUNT_WIDGET (self)); return - g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (self->host)), "") != 0 && - g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (self->user)), "") != 0 && - g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (self->password)), "") != 0 && - g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (self->port)), "") != 0; + g_strcmp0 (gtk_entry_get_text (self->host), "") != 0 && + g_strcmp0 (gtk_entry_get_text (self->user), "") != 0 && + g_strcmp0 (gtk_entry_get_text (self->password), "") != 0 && + g_strcmp0 (gtk_entry_get_text (self->port), "") != 0; } @@ -122,35 +122,35 @@ on_user_changed (CallsSipAccountWidget *self) static void set_password_visibility (CallsSipAccountWidget *self, gboolean visible) { - const char* icon_name; + const char *icon_name; - g_assert (CALLS_IS_SIP_ACCOUNT_WIDGET (self)); - g_assert (GTK_IS_ENTRY (self->password)); + g_assert (CALLS_IS_SIP_ACCOUNT_WIDGET (self)); + g_assert (GTK_IS_ENTRY (self->password)); - icon_name = visible ? - "view-conceal-symbolic" : - "view-reveal-symbolic"; + icon_name = visible ? + "view-conceal-symbolic" : + "view-reveal-symbolic"; - gtk_entry_set_visibility (self->password, visible); - gtk_entry_set_icon_from_icon_name (self->password, GTK_ENTRY_ICON_SECONDARY, - icon_name); + gtk_entry_set_visibility (self->password, visible); + gtk_entry_set_icon_from_icon_name (self->password, GTK_ENTRY_ICON_SECONDARY, + icon_name); } static void -on_password_visibility_changed(CallsSipAccountWidget *self, - GtkEntryIconPosition icon_pos, - GdkEvent *event, - GtkEntry *entry) +on_password_visibility_changed (CallsSipAccountWidget *self, + GtkEntryIconPosition icon_pos, + GdkEvent *event, + GtkEntry *entry) { - gboolean visible; + gboolean visible; - g_assert (CALLS_IS_SIP_ACCOUNT_WIDGET (self)); - g_assert (GTK_IS_ENTRY (entry)); - g_assert (icon_pos == GTK_ENTRY_ICON_SECONDARY); + g_assert (CALLS_IS_SIP_ACCOUNT_WIDGET (self)); + g_assert (GTK_IS_ENTRY (entry)); + g_assert (icon_pos == GTK_ENTRY_ICON_SECONDARY); - visible = !gtk_entry_get_visibility (entry); - set_password_visibility (self, visible); + visible = !gtk_entry_get_visibility (entry); + set_password_visibility (self, visible); } /* @@ -173,7 +173,7 @@ on_port_entry_insert_text (CallsSipAccountWidget *self, if (!new_text || !*new_text || self->port_self_change) return; - pos = (int *)position; + pos = (int *) position; g_object_set_data (G_OBJECT (entry), "old-pos", GINT_TO_POINTER (*pos)); if (new_text_length == -1) @@ -215,7 +215,7 @@ get_port (CallsSipAccountWidget *self) int port = 0; text = gtk_entry_get_text (self->port); - port = (int)g_ascii_strtod (text, NULL); + port = (int) g_ascii_strtod (text, NULL); return port; } @@ -270,6 +270,7 @@ find_protocol (CallsSipAccountWidget *self, guint *index) { guint len; + g_assert (CALLS_IS_SIP_ACCOUNT_WIDGET (self)); len = g_list_model_get_n_items (G_LIST_MODEL (self->protocols_store)); @@ -352,7 +353,7 @@ edit_form (CallsSipAccountWidget *self, /* The following should always succeed, TODO inform user in the error case related issue #275 https://source.puri.sm/Librem5/calls/-/issues/275 - */ + */ if (!find_protocol (self, protocol, &protocol_index)) protocol_index = 0; diff --git a/plugins/sip/calls-sip-account-widget.h b/plugins/sip/calls-sip-account-widget.h index 1f310e5..7a54763 100644 --- a/plugins/sip/calls-sip-account-widget.h +++ b/plugins/sip/calls-sip-account-widget.h @@ -35,8 +35,8 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (CallsSipAccountWidget, calls_sip_account_widget, CALLS, SIP_ACCOUNT_WIDGET, GtkBox) CallsSipAccountWidget *calls_sip_account_widget_new (CallsSipProvider *provider); -void calls_sip_account_widget_set_origin (CallsSipAccountWidget *self, - CallsSipOrigin *origin); -CallsSipOrigin *calls_sip_account_widget_get_origin (CallsSipAccountWidget *self); +void calls_sip_account_widget_set_origin (CallsSipAccountWidget *self, + CallsSipOrigin *origin); +CallsSipOrigin *calls_sip_account_widget_get_origin (CallsSipAccountWidget *self); G_END_DECLS diff --git a/plugins/sip/calls-sip-call.c b/plugins/sip/calls-sip-call.c index 8270d56..1b616f7 100644 --- a/plugins/sip/calls-sip-call.c +++ b/plugins/sip/calls-sip-call.c @@ -56,21 +56,20 @@ enum { }; static GParamSpec *props[PROP_LAST_PROP]; -struct _CallsSipCall -{ - GObject parent_instance; +struct _CallsSipCall { + GObject parent_instance; - CallsSipMediaManager *manager; + CallsSipMediaManager *manager; CallsSipMediaPipeline *pipeline; - char *ip; + char *ip; - guint rport_rtp; - guint rport_rtcp; - gchar *remote; + guint rport_rtp; + guint rport_rtcp; + gchar *remote; - nua_handle_t *nh; - GList *codecs; + nua_handle_t *nh; + GList *codecs; }; static void calls_sip_call_message_source_interface_init (CallsMessageSourceInterface *iface); @@ -219,10 +218,10 @@ calls_sip_call_set_property (GObject *object, static void -calls_sip_call_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +calls_sip_call_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { CallsSipCall *self = CALLS_SIP_CALL (object); diff --git a/plugins/sip/calls-sip-call.h b/plugins/sip/calls-sip-call.h index 5a57dc3..5badcad 100644 --- a/plugins/sip/calls-sip-call.h +++ b/plugins/sip/calls-sip-call.h @@ -37,20 +37,20 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (CallsSipCall, calls_sip_call, CALLS, SIP_CALL, CallsCall) CallsSipCall *calls_sip_call_new (const char *number, - gboolean inbound, + gboolean inbound, const char *own_ip, CallsSipMediaPipeline *pipeline, nua_handle_t *handle); -void calls_sip_call_setup_remote_media_connection (CallsSipCall *self, - const char *remote, - guint port_rtp, - guint port_rtcp); -void calls_sip_call_setup_local_media_connection (CallsSipCall *self); -void calls_sip_call_activate_media (CallsSipCall *self, - gboolean enabled); -void calls_sip_call_set_state (CallsSipCall *self, - CallsCallState state); -void calls_sip_call_set_codecs (CallsSipCall *self, - GList *codecs); +void calls_sip_call_setup_remote_media_connection (CallsSipCall *self, + const char *remote, + guint port_rtp, + guint port_rtcp); +void calls_sip_call_setup_local_media_connection (CallsSipCall *self); +void calls_sip_call_activate_media (CallsSipCall *self, + gboolean enabled); +void calls_sip_call_set_state (CallsSipCall *self, + CallsCallState state); +void calls_sip_call_set_codecs (CallsSipCall *self, + GList *codecs); G_END_DECLS diff --git a/plugins/sip/calls-sip-media-manager.c b/plugins/sip/calls-sip-media-manager.c index 9d3746d..cc6aa56 100644 --- a/plugins/sip/calls-sip-media-manager.c +++ b/plugins/sip/calls-sip-media-manager.c @@ -48,16 +48,15 @@ * #CallsSipMediaPipeline objects that are ready to be used. */ -typedef struct _CallsSipMediaManager -{ - GObject parent; +typedef struct _CallsSipMediaManager { + GObject parent; - int address_family; + int address_family; struct addrinfo hints; - CallsSettings *settings; - GList *preferred_codecs; - GListStore *pipelines; + CallsSettings *settings; + GList *preferred_codecs; + GListStore *pipelines; } CallsSipMediaManager; G_DEFINE_TYPE (CallsSipMediaManager, calls_sip_media_manager, G_TYPE_OBJECT); @@ -95,6 +94,7 @@ static void on_notify_preferred_audio_codecs (CallsSipMediaManager *self) { GList *supported_codecs; + g_auto (GStrv) settings_codec_preference = NULL; g_assert (CALLS_IS_SIP_MEDIA_MANAGER (self)); @@ -173,7 +173,7 @@ calls_sip_media_manager_class_init (CallsSipMediaManagerClass *klass) static void calls_sip_media_manager_init (CallsSipMediaManager *self) { - if (!gst_is_initialized()) + if (!gst_is_initialized ()) gst_init (NULL, NULL); self->settings = calls_settings_new (); @@ -228,6 +228,7 @@ calls_sip_media_manager_get_capabilities (CallsSipMediaManager *self, GList *supported_codecs) { char *payload_type = use_srtp ? "SAVP" : "AVP"; + g_autoptr (GString) media_line = NULL; g_autoptr (GString) attribute_lines = NULL; GList *node; @@ -262,7 +263,7 @@ calls_sip_media_manager_get_capabilities (CallsSipMediaManager *self, g_string_append_printf (attribute_lines, "a=rtcp:%d\r\n", rtcp_port); - done: +done: if (own_ip && *own_ip) address_family_string = get_address_family_string (self, own_ip); diff --git a/plugins/sip/calls-sip-media-manager.h b/plugins/sip/calls-sip-media-manager.h index 4158d78..c399bb9 100644 --- a/plugins/sip/calls-sip-media-manager.h +++ b/plugins/sip/calls-sip-media-manager.h @@ -38,22 +38,22 @@ G_DECLARE_FINAL_TYPE (CallsSipMediaManager, calls_sip_media_manager, CALLS, SIP_ CallsSipMediaManager* calls_sip_media_manager_default (void); -gchar* calls_sip_media_manager_get_capabilities (CallsSipMediaManager *self, - const char *own_ip, - gint rtp_port, - gint rtcp_port, - gboolean use_srtp, - GList *supported_codecs); -gchar* calls_sip_media_manager_static_capabilities (CallsSipMediaManager *self, - const char *own_ip, - gint rtp_port, - gint rtcp_port, - gboolean use_srtp); -gboolean calls_sip_media_manager_supports_media (CallsSipMediaManager *self, - const char *media_type); -GList * calls_sip_media_manager_codec_candidates (CallsSipMediaManager *self); -GList * calls_sip_media_manager_get_codecs_from_sdp (CallsSipMediaManager *self, - sdp_media_t *sdp_media); -CallsSipMediaPipeline *calls_sip_media_manager_get_pipeline (CallsSipMediaManager *self); +gchar *calls_sip_media_manager_get_capabilities (CallsSipMediaManager *self, + const char *own_ip, + gint rtp_port, + gint rtcp_port, + gboolean use_srtp, + GList *supported_codecs); +gchar *calls_sip_media_manager_static_capabilities (CallsSipMediaManager *self, + const char *own_ip, + gint rtp_port, + gint rtcp_port, + gboolean use_srtp); +gboolean calls_sip_media_manager_supports_media (CallsSipMediaManager *self, + const char *media_type); +GList *calls_sip_media_manager_codec_candidates (CallsSipMediaManager *self); +GList *calls_sip_media_manager_get_codecs_from_sdp (CallsSipMediaManager *self, + sdp_media_t *sdp_media); +CallsSipMediaPipeline *calls_sip_media_manager_get_pipeline (CallsSipMediaManager *self); G_END_DECLS diff --git a/plugins/sip/calls-sip-media-pipeline.c b/plugins/sip/calls-sip-media-pipeline.c index 5532dfd..0eefa57 100644 --- a/plugins/sip/calls-sip-media-pipeline.c +++ b/plugins/sip/calls-sip-media-pipeline.c @@ -113,44 +113,44 @@ static uint signals[N_SIGNALS]; struct _CallsSipMediaPipeline { - GObject parent; + GObject parent; - MediaCodecInfo *codec; - gboolean debug; + MediaCodecInfo *codec; + gboolean debug; CallsMediaPipelineState state; - uint element_map_playing; - uint element_map_paused; - uint element_map_stopped; - gboolean emitted_sending_signal; + uint element_map_playing; + uint element_map_paused; + uint element_map_stopped; + gboolean emitted_sending_signal; /* Connection details */ - char *remote; - gint rport_rtp; - gint rport_rtcp; + char *remote; + gint rport_rtp; + gint rport_rtcp; - GstElement *pipeline; - GstElement *rtpbin; + GstElement *pipeline; + GstElement *rtpbin; - GstElement *rtp_src; - GstElement *rtp_sink; - GstElement *rtcp_sink; - GstElement *rtcp_src; + GstElement *rtp_src; + GstElement *rtp_sink; + GstElement *rtcp_sink; + GstElement *rtcp_src; - GstElement *audio_src; - GstElement *payloader; - GstElement *encoder; + GstElement *audio_src; + GstElement *payloader; + GstElement *encoder; - GstElement *audio_sink; - GstElement *depayloader; - GstElement *decoder; + GstElement *audio_sink; + GstElement *depayloader; + GstElement *decoder; /* Gstreamer busses */ - GstBus *bus; - guint bus_watch_id; + GstBus *bus; + guint bus_watch_id; }; -#if GLIB_CHECK_VERSION(2, 70, 0) +#if GLIB_CHECK_VERSION (2, 70, 0) G_DEFINE_FINAL_TYPE (CallsSipMediaPipeline, calls_sip_media_pipeline, G_TYPE_OBJECT) #else G_DEFINE_TYPE (CallsSipMediaPipeline, calls_sip_media_pipeline, G_TYPE_OBJECT) @@ -254,24 +254,24 @@ on_bus_message (GstBus *bus, switch (GST_MESSAGE_TYPE (message)) { case GST_MESSAGE_ERROR: - { - g_autoptr (GError) error = NULL; - g_autofree char *msg = NULL; + { + g_autoptr (GError) error = NULL; + g_autofree char *msg = NULL; - gst_message_parse_error (message, &error, &msg); - g_warning ("Error on the message bus: %s (%s)", error->message, msg); - break; - } + gst_message_parse_error (message, &error, &msg); + g_warning ("Error on the message bus: %s (%s)", error->message, msg); + break; + } case GST_MESSAGE_WARNING: - { - g_autoptr (GError) error = NULL; - g_autofree char *msg = NULL; + { + g_autoptr (GError) error = NULL; + g_autofree char *msg = NULL; - gst_message_parse_warning (message, &error, &msg); - g_warning ("Warning on the message bus: %s (%s)", error->message, msg); - break; - } + gst_message_parse_warning (message, &error, &msg); + g_warning ("Warning on the message bus: %s (%s)", error->message, msg); + break; + } case GST_MESSAGE_EOS: g_debug ("Received end of stream"); @@ -279,77 +279,77 @@ on_bus_message (GstBus *bus, break; case GST_MESSAGE_STATE_CHANGED: - { - GstState oldstate; - GstState newstate; - uint element_id = 0; - uint unset_element_id; + { + GstState oldstate; + GstState newstate; + uint element_id = 0; + uint unset_element_id; - gst_message_parse_state_changed (message, &oldstate, &newstate, NULL); + gst_message_parse_state_changed (message, &oldstate, &newstate, NULL); - g_debug ("Element %s has changed state from %s to %s", - GST_OBJECT_NAME (message->src), - gst_element_state_get_name (oldstate), - gst_element_state_get_name (newstate)); + g_debug ("Element %s has changed state from %s to %s", + GST_OBJECT_NAME (message->src), + gst_element_state_get_name (oldstate), + gst_element_state_get_name (newstate)); - if (message->src == GST_OBJECT (self->pipeline)) - element_id = EL_PIPELINE; - else if (message->src == GST_OBJECT (self->rtpbin)) - element_id = EL_RTPBIN; + if (message->src == GST_OBJECT (self->pipeline)) + element_id = EL_PIPELINE; + else if (message->src == GST_OBJECT (self->rtpbin)) + element_id = EL_RTPBIN; - else if (message->src == GST_OBJECT (self->rtp_src)) - element_id = EL_RTP_SRC; - else if (message->src == GST_OBJECT (self->rtp_sink)) - element_id = EL_RTP_SINK; + else if (message->src == GST_OBJECT (self->rtp_src)) + element_id = EL_RTP_SRC; + else if (message->src == GST_OBJECT (self->rtp_sink)) + element_id = EL_RTP_SINK; - else if (message->src == GST_OBJECT (self->rtcp_src)) - element_id = EL_RTCP_SRC; - else if (message->src == GST_OBJECT (self->rtcp_sink)) - element_id = EL_RTCP_SINK; + else if (message->src == GST_OBJECT (self->rtcp_src)) + element_id = EL_RTCP_SRC; + else if (message->src == GST_OBJECT (self->rtcp_sink)) + element_id = EL_RTCP_SINK; - /* TODO srtp encryption - else if (message->src == GST_OBJECT (self->srtpenc)) - element_id = EL_SRTP_ENCODER; - else if (message->src == GST_OBJECT (self->srtpdec)) - element_id = EL_SRTP_DECODER; - */ + /* TODO srtp encryption + else if (message->src == GST_OBJECT (self->srtpenc)) + element_id = EL_SRTP_ENCODER; + else if (message->src == GST_OBJECT (self->srtpdec)) + element_id = EL_SRTP_DECODER; + */ - else if (message->src == GST_OBJECT (self->audio_src)) - element_id = EL_AUDIO_SRC; - else if (message->src == GST_OBJECT (self->audio_sink)) - element_id = EL_AUDIO_SINK; + else if (message->src == GST_OBJECT (self->audio_src)) + element_id = EL_AUDIO_SRC; + else if (message->src == GST_OBJECT (self->audio_sink)) + element_id = EL_AUDIO_SINK; - else if (message->src == GST_OBJECT (self->payloader)) - element_id = EL_PAYLOADER; - else if (message->src == GST_OBJECT (self->depayloader)) - element_id = EL_DEPAYLOADER; + else if (message->src == GST_OBJECT (self->payloader)) + element_id = EL_PAYLOADER; + else if (message->src == GST_OBJECT (self->depayloader)) + element_id = EL_DEPAYLOADER; - else if (message->src == GST_OBJECT (self->encoder)) - element_id = EL_ENCODER; - else if (message->src == GST_OBJECT (self->decoder)) - element_id = EL_DECODER; + else if (message->src == GST_OBJECT (self->encoder)) + element_id = EL_ENCODER; + else if (message->src == GST_OBJECT (self->decoder)) + element_id = EL_DECODER; - unset_element_id = G_MAXUINT ^ element_id; + unset_element_id = G_MAXUINT ^ element_id; - if (newstate == GST_STATE_PLAYING) { - self->element_map_playing |= element_id; - self->element_map_paused &= unset_element_id; - self->element_map_stopped &= unset_element_id; - } else if (newstate == GST_STATE_PAUSED) { - self->element_map_paused |= element_id; - self->element_map_playing &= unset_element_id; - self->element_map_stopped &= unset_element_id; - } else if (newstate == GST_STATE_NULL) { - self->element_map_stopped |= element_id; - self->element_map_playing &= unset_element_id; - self->element_map_paused &= unset_element_id; - } - - check_element_maps (self); - break; + if (newstate == GST_STATE_PLAYING) { + self->element_map_playing |= element_id; + self->element_map_paused &= unset_element_id; + self->element_map_stopped &= unset_element_id; + } else if (newstate == GST_STATE_PAUSED) { + self->element_map_paused |= element_id; + self->element_map_playing &= unset_element_id; + self->element_map_stopped &= unset_element_id; + } else if (newstate == GST_STATE_NULL) { + self->element_map_stopped |= element_id; + self->element_map_playing &= unset_element_id; + self->element_map_paused &= unset_element_id; } + check_element_maps (self); + break; + } + default: if (self->debug) g_debug ("Got unhandled %s message", GST_MESSAGE_TYPE_NAME (message)); @@ -584,7 +584,7 @@ pipeline_link_elements (CallsSipMediaPipeline *self, gst_object_unref (sinkpad); srcpad = gst_element_get_static_pad (self->rtcp_src, "src"); -#if GST_CHECK_VERSION (1, 20 , 0) +#if GST_CHECK_VERSION (1, 20, 0) sinkpad = gst_element_request_pad_simple (self->rtpbin, "recv_rtcp_sink_0"); #else sinkpad = gst_element_get_request_pad (self->rtpbin, "recv_rtcp_sink_0"); @@ -596,21 +596,21 @@ pipeline_link_elements (CallsSipMediaPipeline *self, return FALSE; } - gst_object_unref (srcpad); - gst_object_unref (sinkpad); + gst_object_unref (srcpad); + gst_object_unref (sinkpad); #if GST_CHECK_VERSION (1, 20, 0) - srcpad = gst_element_request_pad_simple (self->rtpbin, "send_rtcp_src_0"); + srcpad = gst_element_request_pad_simple (self->rtpbin, "send_rtcp_src_0"); #else - srcpad = gst_element_get_request_pad (self->rtpbin, "send_rtcp_src_0"); + srcpad = gst_element_get_request_pad (self->rtpbin, "send_rtcp_src_0"); #endif - sinkpad = gst_element_get_static_pad (self->rtcp_sink, "sink"); - if (gst_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK) { - if (error) - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - "Failed to link rtpbin to rtcpsink"); - return FALSE; - } + sinkpad = gst_element_get_static_pad (self->rtcp_sink, "sink"); + if (gst_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK) { + if (error) + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "Failed to link rtpbin to rtcpsink"); + return FALSE; + } /* can only link to depayloader after RTP payload has been verified */ g_signal_connect (self->rtpbin, "pad-added", G_CALLBACK (on_pad_added), self->depayloader); @@ -966,8 +966,7 @@ diagnose_ports_in_use (CallsSipMediaPipeline *self) if (same_socket) { g_debug ("Diagnosing bidirectional socket..."); diagnose_used_ports_in_socket (socket_in); - } - else { + } else { g_debug ("Diagnosing server socket..."); diagnose_used_ports_in_socket (socket_in); g_debug ("Diagnosing client socket..."); diff --git a/plugins/sip/calls-sip-origin.c b/plugins/sip/calls-sip-origin.c index de65cea..b99232a 100644 --- a/plugins/sip/calls-sip-origin.c +++ b/plugins/sip/calls-sip-origin.c @@ -82,47 +82,46 @@ static GParamSpec *props[PROP_LAST_PROP]; static gboolean set_contact_header = FALSE; -struct _CallsSipOrigin -{ - GObject parent_instance; +struct _CallsSipOrigin { + GObject parent_instance; - CallsSipContext *ctx; - nua_t *nua; - CallsSipHandles *oper; - char *contact_header; /* Needed for sofia SIP >= 1.13 */ + CallsSipContext *ctx; + nua_t *nua; + CallsSipHandles *oper; + char *contact_header; /* Needed for sofia SIP >= 1.13 */ /* Direct connection mode is useful for debugging purposes */ - gboolean use_direct_connection; + gboolean use_direct_connection; /* Needed to handle shutdown correctly. See sip_callback and dispose method */ - gboolean is_nua_shutdown; - gboolean is_shutdown_success; + gboolean is_nua_shutdown; + gboolean is_shutdown_success; - CallsAccountState state; + CallsAccountState state; CallsSipMediaManager *media_manager; /* Account information */ - char *host; - char *user; - char *password; - char *display_name; - gint port; - char *transport_protocol; - gboolean auto_connect; - gboolean direct_mode; - gboolean can_tel; + char *host; + char *user; + char *password; + char *display_name; + gint port; + char *transport_protocol; + gboolean auto_connect; + gboolean direct_mode; + gboolean can_tel; - char *own_ip; - gint local_port; + char *own_ip; + gint local_port; - const char *protocol_prefix; - char *address; - char *name; - char *id; + const char *protocol_prefix; + char *address; + char *name; + char *id; - GList *calls; - GHashTable *call_handles; + GList *calls; + GHashTable *call_handles; }; static void calls_sip_origin_message_source_interface_init (CallsOriginInterface *iface); @@ -138,9 +137,9 @@ G_DEFINE_TYPE_WITH_CODE (CallsSipOrigin, calls_sip_origin, G_TYPE_OBJECT, calls_sip_origin_accounts_interface_init)) static void -change_state (CallsSipOrigin *self, - CallsAccountState new_state, - CallsAccountStateReason reason) +change_state (CallsSipOrigin *self, + CallsAccountState new_state, + CallsAccountStateReason reason) { CallsAccountState old_state; @@ -160,7 +159,7 @@ change_state (CallsSipOrigin *self, static void remove_call (CallsSipOrigin *self, CallsCall *call, - const gchar *reason) + const char *reason) { CallsOrigin *origin; CallsSipCall *sip_call; @@ -188,7 +187,7 @@ remove_call (CallsSipOrigin *self, static void remove_calls (CallsSipOrigin *self, - const gchar *reason) + const char *reason) { CallsCall *call; GList *next; @@ -229,18 +228,19 @@ on_call_state_changed (CallsSipCall *call, static void add_call (CallsSipOrigin *self, - const gchar *address, + const char *address, gboolean inbound, nua_handle_t *handle) { CallsSipCall *sip_call; CallsCall *call; CallsSipMediaPipeline *pipeline; - g_autofree gchar *local_sdp = NULL; - g_auto (GStrv) address_split = NULL; const char *call_address = address; gint rtp_port, rtcp_port; + g_auto (GStrv) address_split = NULL; + g_autofree char *local_sdp = NULL; + pipeline = calls_sip_media_manager_get_pipeline (self->media_manager); rtp_port = calls_sip_media_pipeline_get_rtp_port (pipeline); rtcp_port = calls_sip_media_pipeline_get_rtcp_port (pipeline); @@ -299,7 +299,7 @@ add_call (CallsSipOrigin *self, static void dial (CallsOrigin *origin, - const gchar *address) + const char *address) { CallsSipOrigin *self; nua_handle_t *nh; @@ -354,7 +354,7 @@ dial (CallsOrigin *origin, static void create_inbound (CallsSipOrigin *self, - const gchar *address, + const char *address, nua_handle_t *handle) { g_assert (CALLS_IS_SIP_ORIGIN (self)); @@ -375,9 +375,9 @@ sip_authenticate (CallsSipOrigin *self, nua_handle_t *nh, sip_t const *sip) { - const gchar *scheme = NULL; - const gchar *realm = NULL; - g_autofree gchar *auth = NULL; + const char *scheme = NULL; + const char *realm = NULL; + g_autofree char *auth = NULL; sip_www_authenticate_t *www_auth = sip->sip_www_authenticate; sip_proxy_authenticate_t *proxy_auth = sip->sip_proxy_authenticate; @@ -412,20 +412,20 @@ sip_r_invite (int status, sip_t const *sip, tagi_t tags[]) { - g_debug ("response to outgoing INVITE: %03d %s", status, phrase); + g_debug ("response to outgoing INVITE: %03d %s", status, phrase); - /* TODO call states (see i_state) */ - if (status == 401 || status == 407) { - sip_authenticate (origin, nh, sip); - } else if (status == 403) { - g_warning ("Response to outgoing INVITE: 403 wrong credentials?"); - } else if (status == 904) { - g_warning ("Response to outgoing INVITE: 904 unmatched challenge." - "Possibly the challenge was already answered?"); - } else if (status == 180) { - } else if (status == 100) { - } else if (status == 200) { - } + /* TODO call states (see i_state) */ + if (status == 401 || status == 407) { + sip_authenticate (origin, nh, sip); + } else if (status == 403) { + g_warning ("Response to outgoing INVITE: 403 wrong credentials?"); + } else if (status == 904) { + g_warning ("Response to outgoing INVITE: 904 unmatched challenge." + "Possibly the challenge was already answered?"); + } else if (status == 180) { + } else if (status == 100) { + } else if (status == 200) { + } } @@ -446,7 +446,7 @@ sip_r_register (int status, change_state (origin, CALLS_ACCOUNT_STATE_ONLINE, CALLS_ACCOUNT_STATE_REASON_CONNECTED); - nua_get_params (nua, TAG_ANY (), TAG_END()); + nua_get_params (nua, TAG_ANY (), TAG_END ()); if (sip->sip_contact && sip->sip_contact->m_url && sip->sip_contact->m_url->url_host) { g_free (origin->own_ip); @@ -591,7 +591,7 @@ sip_i_state (int status, rtcp_port = rtp_port + 1; calls_sip_call_setup_remote_media_connection (call, - media_ip ? : session_ip, + media_ip ?: session_ip, rtp_port, rtcp_port); } @@ -675,7 +675,7 @@ sip_callback (nua_event_t event, { CallsSipOrigin *origin = CALLS_SIP_ORIGIN (magic); CallsSipHandles *op = origin->oper; - g_autofree gchar * from = NULL; + g_autofree char *from = NULL; switch (event) { case nua_i_invite: @@ -807,14 +807,13 @@ sip_callback (nua_event_t event, if (status == 200) { origin->is_nua_shutdown = TRUE; origin->is_shutdown_success = TRUE; - } - else if (status == 500) { + } else if (status == 500) { origin->is_nua_shutdown = TRUE; origin->is_shutdown_success = FALSE; } break; - /* Deprecated events */ + /* Deprecated events */ case nua_i_active: break; case nua_i_terminated: @@ -827,7 +826,7 @@ sip_callback (nua_event_t event, status, phrase); g_warning ("printing tags"); - tl_print(stdout, "", tags); + tl_print (stdout, "", tags); break; } } @@ -1168,6 +1167,7 @@ supports_protocol (CallsOrigin *origin, const char *protocol) { CallsSipOrigin *self; + g_assert (protocol); g_assert (CALLS_IS_SIP_ORIGIN (origin)); @@ -1276,10 +1276,10 @@ calls_sip_origin_set_property (GObject *object, static void -calls_sip_origin_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +calls_sip_origin_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { CallsSipOrigin *self = CALLS_SIP_ORIGIN (object); g_autofree char *name = NULL; @@ -1360,6 +1360,7 @@ static void calls_sip_origin_constructed (GObject *object) { CallsSipOrigin *self = CALLS_SIP_ORIGIN (object); + g_autoptr (GError) error = NULL; int major = 0; int minor = 0; @@ -1501,7 +1502,7 @@ calls_sip_origin_class_init (CallsSipOriginClass *klass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); g_object_class_install_property (object_class, PROP_ACC_LOCAL_PORT, props[PROP_ACC_LOCAL_PORT]); - props[PROP_SIP_CONTEXT] = + props[PROP_SIP_CONTEXT] = g_param_spec_pointer ("sip-context", "SIP context", "The SIP context (sofia) used for our sip handles", diff --git a/plugins/sip/calls-sip-origin.h b/plugins/sip/calls-sip-origin.h index b1c50c2..95b35fe 100644 --- a/plugins/sip/calls-sip-origin.h +++ b/plugins/sip/calls-sip-origin.h @@ -32,14 +32,14 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (CallsSipOrigin, calls_sip_origin, CALLS, SIP_ORIGIN, GObject) -void calls_sip_origin_set_credentials (CallsSipOrigin *self, - const char *host, - const char *user, - const char *password, - const char *display_name, - const char *transport_protocol, - gint port, - gboolean use_for_tel, - gboolean auto_connect); +void calls_sip_origin_set_credentials (CallsSipOrigin *self, + const char *host, + const char *user, + const char *password, + const char *display_name, + const char *transport_protocol, + gint port, + gboolean use_for_tel, + gboolean auto_connect); G_END_DECLS diff --git a/plugins/sip/calls-sip-provider.c b/plugins/sip/calls-sip-provider.c index 8a03b64..6bad5ec 100644 --- a/plugins/sip/calls-sip-provider.c +++ b/plugins/sip/calls-sip-provider.c @@ -65,17 +65,16 @@ enum { }; static GParamSpec *props[PROP_LAST_PROP]; -struct _CallsSipProvider -{ - CallsProvider parent_instance; +struct _CallsSipProvider { + CallsProvider parent_instance; - GListStore *origins; + GListStore *origins; /* SIP */ - CallsSipContext *ctx; - SipEngineState sip_state; + CallsSipContext *ctx; + SipEngineState sip_state; - gboolean use_memory_backend; - gchar *filename; + gboolean use_memory_backend; + gchar *filename; CallsSipAccountWidget *account_widget; }; @@ -86,20 +85,20 @@ static void calls_sip_provider_account_provider_interface_init (CallsAccountProv #ifdef FOR_TESTING G_DEFINE_TYPE_WITH_CODE -(CallsSipProvider, calls_sip_provider, CALLS_TYPE_PROVIDER, - G_IMPLEMENT_INTERFACE (CALLS_TYPE_MESSAGE_SOURCE, - calls_sip_provider_message_source_interface_init) - G_IMPLEMENT_INTERFACE (CALLS_TYPE_ACCOUNT_PROVIDER, - calls_sip_provider_account_provider_interface_init)) + (CallsSipProvider, calls_sip_provider, CALLS_TYPE_PROVIDER, + G_IMPLEMENT_INTERFACE (CALLS_TYPE_MESSAGE_SOURCE, + calls_sip_provider_message_source_interface_init) + G_IMPLEMENT_INTERFACE (CALLS_TYPE_ACCOUNT_PROVIDER, + calls_sip_provider_account_provider_interface_init)) #else G_DEFINE_DYNAMIC_TYPE_EXTENDED -(CallsSipProvider, calls_sip_provider, CALLS_TYPE_PROVIDER, 0, - G_IMPLEMENT_INTERFACE_DYNAMIC (CALLS_TYPE_MESSAGE_SOURCE, - calls_sip_provider_message_source_interface_init) - G_IMPLEMENT_INTERFACE_DYNAMIC (CALLS_TYPE_ACCOUNT_PROVIDER, - calls_sip_provider_account_provider_interface_init)) + (CallsSipProvider, calls_sip_provider, CALLS_TYPE_PROVIDER, 0, + G_IMPLEMENT_INTERFACE_DYNAMIC (CALLS_TYPE_MESSAGE_SOURCE, + calls_sip_provider_message_source_interface_init) + G_IMPLEMENT_INTERFACE_DYNAMIC (CALLS_TYPE_ACCOUNT_PROVIDER, + calls_sip_provider_account_provider_interface_init)) #endif /* FOR_TESTING */ @@ -115,6 +114,7 @@ on_origin_pw_looked_up (GObject *source, gpointer user_data) { SipOriginLoadData *data; + g_autoptr (GError) error = NULL; g_autofree char *id = NULL; g_autofree char *name = NULL; @@ -367,7 +367,7 @@ calls_sip_provider_get_origins (CallsProvider *provider) return G_LIST_MODEL (self->origins); } -static const char * const * +static const char *const * calls_sip_provider_get_protocols (CallsProvider *provider) { return supported_protocols; @@ -397,7 +397,7 @@ calls_sip_provider_deinit_sip (CallsSipProvider *self) } g_clear_pointer (&self->ctx, g_free); - bail: +bail: self->sip_state = SIP_ENGINE_NULL; g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SIP_STATE]); } @@ -448,7 +448,7 @@ calls_sip_provider_init_sofia (CallsSipProvider *self, g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SIP_STATE]); return TRUE; - err: +err: self->sip_state = SIP_ENGINE_ERROR; g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SIP_STATE]); return FALSE; @@ -456,10 +456,10 @@ calls_sip_provider_init_sofia (CallsSipProvider *self, static void -calls_sip_provider_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +calls_sip_provider_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { CallsSipProvider *self = CALLS_SIP_PROVIDER (object); @@ -479,6 +479,7 @@ static void calls_sip_provider_constructed (GObject *object) { CallsSipProvider *self = CALLS_SIP_PROVIDER (object); + g_autoptr (GError) error = NULL; const gchar *env_sip_test; @@ -500,7 +501,7 @@ calls_sip_provider_constructed (GObject *object) g_warning ("Could not initialize sofia stack: %s", error->message); } - out: +out: G_OBJECT_CLASS (calls_sip_provider_parent_class)->constructed (object); } diff --git a/plugins/sip/calls-sip-provider.h b/plugins/sip/calls-sip-provider.h index 0d16d61..edd2df0 100644 --- a/plugins/sip/calls-sip-provider.h +++ b/plugins/sip/calls-sip-provider.h @@ -37,35 +37,35 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (CallsSipProvider, calls_sip_provider, CALLS, SIP_PROVIDER, CallsProvider) CallsSipProvider *calls_sip_provider_new (void); -CallsSipOrigin *calls_sip_provider_add_origin (CallsSipProvider *self, - const char *id, - const char *host, - const char *user, - const char *password, - const char *display_name, - const char *transport_protocol, - gint port, - gboolean store_credentials); -CallsSipOrigin *calls_sip_provider_add_origin_full (CallsSipProvider *self, - const char *id, - const char *host, - const char *user, - const char *password, - const char *display_name, - const char *transport_protocol, - gint port, - gboolean auto_connect, - gboolean direct_mode, - gint local_port, - gboolean use_for_tel, - gboolean store_credentials); -gboolean calls_sip_provider_remove_origin (CallsSipProvider *self, - CallsSipOrigin *origin); -void calls_sip_provider_load_accounts (CallsSipProvider *self, - GKeyFile *key_file); -void calls_sip_provider_save_accounts (CallsSipProvider *self, - GKeyFile *key_file); -gboolean calls_sip_provider_save_accounts_to_disk (CallsSipProvider *self); -void peas_register_types (PeasObjectModule *module); +CallsSipOrigin *calls_sip_provider_add_origin (CallsSipProvider *self, + const char *id, + const char *host, + const char *user, + const char *password, + const char *display_name, + const char *transport_protocol, + gint port, + gboolean store_credentials); +CallsSipOrigin *calls_sip_provider_add_origin_full (CallsSipProvider *self, + const char *id, + const char *host, + const char *user, + const char *password, + const char *display_name, + const char *transport_protocol, + gint port, + gboolean auto_connect, + gboolean direct_mode, + gint local_port, + gboolean use_for_tel, + gboolean store_credentials); +gboolean calls_sip_provider_remove_origin (CallsSipProvider *self, + CallsSipOrigin *origin); +void calls_sip_provider_load_accounts (CallsSipProvider *self, + GKeyFile *key_file); +void calls_sip_provider_save_accounts (CallsSipProvider *self, + GKeyFile *key_file); +gboolean calls_sip_provider_save_accounts_to_disk (CallsSipProvider *self); +void peas_register_types (PeasObjectModule *module); G_END_DECLS diff --git a/plugins/sip/calls-sip-util.c b/plugins/sip/calls-sip-util.c index a4349e2..45d1eed 100644 --- a/plugins/sip/calls-sip-util.c +++ b/plugins/sip/calls-sip-util.c @@ -58,6 +58,6 @@ gboolean protocol_is_valid (const char *protocol) { return g_strcmp0 (protocol, "UDP") == 0 || - g_strcmp0 (protocol, "TCP") == 0 || - g_strcmp0 (protocol, "TLS") == 0; + g_strcmp0 (protocol, "TCP") == 0 || + g_strcmp0 (protocol, "TLS") == 0; } diff --git a/plugins/sip/calls-sip-util.h b/plugins/sip/calls-sip-util.h index 86b4709..a87af6e 100644 --- a/plugins/sip/calls-sip-util.h +++ b/plugins/sip/calls-sip-util.h @@ -28,17 +28,15 @@ #include #include -typedef struct -{ - su_home_t home[1]; - su_root_t *root; +typedef struct { + su_home_t home[1]; + su_root_t *root; } CallsSipContext; -typedef struct -{ - nua_handle_t *register_handle; - nua_handle_t *call_handle; - CallsSipContext *context; +typedef struct { + nua_handle_t *register_handle; + nua_handle_t *call_handle; + CallsSipContext *context; } CallsSipHandles; @@ -49,16 +47,15 @@ typedef struct * @SIP_ENGINE_ERROR: Unrecoverable/Unhandled sofia-sip error * @SIP_ENGINE_READY: Ready for operation */ -typedef enum - { - SIP_ENGINE_NULL = 0, - SIP_ENGINE_INITIALIZING, - SIP_ENGINE_ERROR, - SIP_ENGINE_READY, - } SipEngineState; +typedef enum { + SIP_ENGINE_NULL = 0, + SIP_ENGINE_INITIALIZING, + SIP_ENGINE_ERROR, + SIP_ENGINE_READY, +} SipEngineState; -gboolean check_sips (const char *addr); -gboolean check_ipv6 (const char *host); -const char *get_protocol_prefix (const char *protocol); -gboolean protocol_is_valid (const char *protocol); +gboolean check_sips (const char *addr); +gboolean check_ipv6 (const char *host); +const char *get_protocol_prefix (const char *protocol); +gboolean protocol_is_valid (const char *protocol); diff --git a/plugins/sip/gst-rfc3551.c b/plugins/sip/gst-rfc3551.c index 9693557..a72b297 100644 --- a/plugins/sip/gst-rfc3551.c +++ b/plugins/sip/gst-rfc3551.c @@ -46,7 +46,8 @@ static MediaCodecInfo gst_codecs[] = { * Returns: %TRUE if codec is available on your system, %FALSE otherwise */ gboolean -media_codec_available_in_gst (MediaCodecInfo *codec) { +media_codec_available_in_gst (MediaCodecInfo *codec) +{ gboolean available = FALSE; GstRegistry *registry = gst_registry_get (); GstPlugin *plugin = NULL; diff --git a/plugins/sip/gst-rfc3551.h b/plugins/sip/gst-rfc3551.h index 8c53f15..36d571a 100644 --- a/plugins/sip/gst-rfc3551.h +++ b/plugins/sip/gst-rfc3551.h @@ -34,8 +34,8 @@ typedef struct { guint payload_id; char *name; - gint clock_rate; - gint channels; + gint clock_rate; + gint channels; char *gst_payloader_name; char *gst_depayloader_name; char *gst_encoder_name; @@ -44,8 +44,8 @@ typedef struct { } MediaCodecInfo; -gboolean media_codec_available_in_gst (MediaCodecInfo *codec); -MediaCodecInfo* media_codec_by_name (const char *name); -MediaCodecInfo* media_codec_by_payload_id (uint payload_id); -gchar* media_codec_get_gst_capabilities (MediaCodecInfo *codec); -GList* media_codecs_get_candidates (void); +gboolean media_codec_available_in_gst (MediaCodecInfo *codec); +MediaCodecInfo *media_codec_by_name (const char *name); +MediaCodecInfo *media_codec_by_payload_id (uint payload_id); +gchar *media_codec_get_gst_capabilities (MediaCodecInfo *codec); +GList *media_codecs_get_candidates (void); diff --git a/src/calls-account-overview.c b/src/calls-account-overview.c index b7ee75c..ef55934 100644 --- a/src/calls-account-overview.c +++ b/src/calls-account-overview.c @@ -49,23 +49,23 @@ typedef enum { struct _CallsAccountOverview { - HdyWindow parent; + HdyWindow parent; /* UI widgets */ - GtkStack *stack; - GtkWidget *intro; - GtkWidget *overview; - GtkWidget *add_btn; - GtkWidget *add_row; + GtkStack *stack; + GtkWidget *intro; + GtkWidget *overview; + GtkWidget *add_btn; + GtkWidget *add_row; /* The window where we add the account providers widget */ - GtkWindow *account_window; - GtkWidget *current_account_widget; + GtkWindow *account_window; + GtkWidget *current_account_widget; /* misc */ - CallsAccountOverviewState state; - GList *providers; - CallsInAppNotification *in_app_notification; + CallsAccountOverviewState state; + GList *providers; + CallsInAppNotification *in_app_notification; }; G_DEFINE_TYPE (CallsAccountOverview, calls_account_overview, HDY_TYPE_WINDOW) diff --git a/src/calls-account-provider.h b/src/calls-account-provider.h index cfd8a96..d1fbe97 100644 --- a/src/calls-account-provider.h +++ b/src/calls-account-provider.h @@ -35,14 +35,13 @@ G_BEGIN_DECLS G_DECLARE_INTERFACE (CallsAccountProvider, calls_account_provider, CALLS, ACCOUNT_PROVIDER, CallsProvider) -struct _CallsAccountProviderInterface -{ +struct _CallsAccountProviderInterface { GTypeInterface parent_iface; - GtkWidget *(*get_account_widget) (CallsAccountProvider *self); - void (*add_new_account) (CallsAccountProvider *self); - void (*edit_account) (CallsAccountProvider *self, - CallsAccount *account); + GtkWidget *(*get_account_widget) (CallsAccountProvider *self); + void (*add_new_account) (CallsAccountProvider *self); + void (*edit_account) (CallsAccountProvider *self, + CallsAccount *account); }; GtkWidget *calls_account_provider_get_account_widget (CallsAccountProvider *self); diff --git a/src/calls-account-row.c b/src/calls-account-row.c index ca7294c..cc64eec 100644 --- a/src/calls-account-row.c +++ b/src/calls-account-row.c @@ -140,10 +140,10 @@ calls_account_row_set_property (GObject *object, static void -calls_account_row_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +calls_account_row_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { CallsAccountRow *self = CALLS_ACCOUNT_ROW (object); @@ -213,8 +213,8 @@ calls_account_row_class_init (CallsAccountRowClass *klass) gtk_widget_class_bind_template_child (widget_class, CallsAccountRow, online_switch); gtk_widget_class_bind_template_child (widget_class, CallsAccountRow, edit_btn); - gtk_widget_class_bind_template_callback (widget_class, on_edit_clicked); - gtk_widget_class_bind_template_callback (widget_class, on_online_switched); + gtk_widget_class_bind_template_callback (widget_class, on_edit_clicked); + gtk_widget_class_bind_template_callback (widget_class, on_online_switched); } diff --git a/src/calls-account-row.h b/src/calls-account-row.h index 1ab6971..5670c28 100644 --- a/src/calls-account-row.h +++ b/src/calls-account-row.h @@ -38,9 +38,9 @@ G_DECLARE_FINAL_TYPE (CallsAccountRow, calls_account_row, CALLS, ACCOUNT_ROW, Hd CallsAccountRow *calls_account_row_new (CallsAccountProvider *provider, CallsAccount *account); -gboolean calls_account_row_get_online (CallsAccountRow *self); -void calls_account_row_set_online (CallsAccountRow *self, - gboolean online); -CallsAccount *calls_account_row_get_account (CallsAccountRow *self); +gboolean calls_account_row_get_online (CallsAccountRow *self); +void calls_account_row_set_online (CallsAccountRow *self, + gboolean online); +CallsAccount *calls_account_row_get_account (CallsAccountRow *self); G_END_DECLS diff --git a/src/calls-account.c b/src/calls-account.c index 5a61522..2dd6407 100644 --- a/src/calls-account.c +++ b/src/calls-account.c @@ -44,7 +44,7 @@ enum { SIGNAL_STATE_CHANGED, SIGNAL_LAST_SIGNAL, }; -static guint signals [SIGNAL_LAST_SIGNAL]; +static guint signals[SIGNAL_LAST_SIGNAL]; static gboolean @@ -92,7 +92,8 @@ calls_account_state_reason_is_error (CallsAccountStateReason reason) static void calls_account_default_init (CallsAccountInterface *iface) { - g_object_interface_install_property (iface, + g_object_interface_install_property ( + iface, g_param_spec_enum ("account-state", "Account state", "The state of the account", @@ -102,7 +103,8 @@ calls_account_default_init (CallsAccountInterface *iface) G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY)); - g_object_interface_install_property (iface, + g_object_interface_install_property ( + iface, g_param_spec_string ("address", "Address", "The address of this account", @@ -312,8 +314,8 @@ calls_account_emit_message_for_state_change (CallsAccount *account, if (reason_is_error || calls_log_get_verbosity () >= 3) message = g_strdup_printf ("%s: %s", - calls_account_state_to_string (new_state), - calls_account_state_reason_to_string (reason)); + calls_account_state_to_string (new_state), + calls_account_state_reason_to_string (reason)); else message = g_strdup (calls_account_state_to_string (new_state)); diff --git a/src/calls-account.h b/src/calls-account.h index f405604..90e5803 100644 --- a/src/calls-account.h +++ b/src/calls-account.h @@ -91,24 +91,23 @@ typedef enum { } CallsAccountStateReason; -struct _CallsAccountInterface -{ +struct _CallsAccountInterface { GTypeInterface parent_iface; - void (*go_online) (CallsAccount *self, - gboolean online); - const char *(*get_address) (CallsAccount *self); + void (*go_online) (CallsAccount *self, + gboolean online); + const char *(*get_address) (CallsAccount *self); }; -void calls_account_go_online (CallsAccount *self, - gboolean online); -const char *calls_account_get_address (CallsAccount *self); -CallsAccountState calls_account_get_state (CallsAccount *self); -const char *calls_account_state_to_string (CallsAccountState state); -const char *calls_account_state_reason_to_string (CallsAccountStateReason reason); -void calls_account_emit_message_for_state_change (CallsAccount *account, - CallsAccountState new_state, - CallsAccountStateReason reason); +void calls_account_go_online (CallsAccount *self, + gboolean online); +const char *calls_account_get_address (CallsAccount *self); +CallsAccountState calls_account_get_state (CallsAccount *self); +const char *calls_account_state_to_string (CallsAccountState state); +const char *calls_account_state_reason_to_string (CallsAccountStateReason reason); +void calls_account_emit_message_for_state_change (CallsAccount *account, + CallsAccountState new_state, + CallsAccountStateReason reason); G_END_DECLS diff --git a/src/calls-application.c b/src/calls-application.c index f8fc3e4..24c491c 100644 --- a/src/calls-application.c +++ b/src/calls-application.c @@ -57,9 +57,8 @@ #define DEFAULT_PROVIDER_PLUGIN "mm" -struct _CallsApplication -{ - GtkApplication parent_instance; +struct _CallsApplication { + GtkApplication parent_instance; gboolean daemon; CallsRinger *ringer; @@ -79,10 +78,10 @@ static gboolean start_proper (CallsApplication *self); static gboolean -cmd_verbose_cb (const char *option_name, - const char *value, - gpointer data, - GError **error) +cmd_verbose_cb (const char *option_name, + const char *value, + gpointer data, + GError **error) { calls_log_increase_verbosity (); @@ -165,6 +164,7 @@ set_default_providers_action (GSimpleAction *action, { CallsManager *manager = calls_manager_get_default (); CallsSettings *settings = calls_manager_get_settings (manager); + g_auto (GStrv) plugins = NULL; /** * Only add default providers when there are none added yet, @@ -240,7 +240,7 @@ extract_dial_string (const char *number) } dial_string = g_regex_replace_literal - (replace_visual, number, -1, 0, "", 0, &error); + (replace_visual, number, -1, 0, "", 0, &error); if (!dial_string) { g_warning ("Error replacing visual separators" @@ -260,25 +260,25 @@ call_number (CallsApplication *self, g_autofree char *dial_string = NULL; gboolean number_ok; - number_ok = check_dial_number (number); - if (!number_ok) { - g_warning ("Dial number `%s' is not a valid dial string", - number); - return; - } + number_ok = check_dial_number (number); + if (!number_ok) { + g_warning ("Dial number `%s' is not a valid dial string", + number); + return; + } - dial_string = extract_dial_string (number); - if (!dial_string) { - return; - } + dial_string = extract_dial_string (number); + if (!dial_string) { + return; + } - g_debug ("Dialing dial string `%s' extracted from number `%s'", - dial_string, number); + g_debug ("Dialing dial string `%s' extracted from number `%s'", + dial_string, number); - start_proper (self); + start_proper (self); - calls_main_window_dial (self->main_window, - dial_string); + calls_main_window_dial (self->main_window, + dial_string); } @@ -368,6 +368,7 @@ show_accounts (GSimpleAction *action, gpointer user_data) { CallsApplication *app = CALLS_APPLICATION (g_application_get_default ()); + calls_main_window_show_accounts_overview (app->main_window); } @@ -377,7 +378,7 @@ manager_state_changed_cb (GApplication *application) GAction* dial_action = g_action_map_lookup_action (G_ACTION_MAP (application), "dial"); CallsManagerFlags state_flags = calls_manager_get_state_flags (calls_manager_get_default ()); gboolean enabled = (state_flags & CALLS_MANAGER_FLAGS_HAS_CELLULAR_MODEM) || - (state_flags & CALLS_MANAGER_FLAGS_HAS_VOIP_ACCOUNT); + (state_flags & CALLS_MANAGER_FLAGS_HAS_VOIP_ACCOUNT); g_simple_action_set_enabled (G_SIMPLE_ACTION (dial_action), enabled); } @@ -413,7 +414,7 @@ startup (GApplication *application) { g_autoptr (GtkCssProvider) provider = NULL; g_autoptr (GError) error = NULL; -#if HDY_CHECK_VERSION(1, 5, 0) +#if HDY_CHECK_VERSION (1, 5, 0) HdyStyleManager *style_manager; #endif @@ -421,7 +422,7 @@ startup (GApplication *application) hdy_init (); -#if HDY_CHECK_VERSION(1, 5, 0) +#if HDY_CHECK_VERSION (1, 5, 0) style_manager = hdy_style_manager_get_default (); hdy_style_manager_set_color_scheme (style_manager, HDY_COLOR_SCHEME_PREFER_LIGHT); @@ -462,8 +463,9 @@ calls_application_command_line (GApplication *application, CallsApplication *self = CALLS_APPLICATION (application); GVariantDict *options; const char *arg; + g_autoptr (GVariant) providers = NULL; - g_auto(GStrv) arguments = NULL; + g_auto (GStrv) arguments = NULL; gint argc; options = g_application_command_line_get_options_dict (command_line); @@ -514,8 +516,8 @@ app_shutdown (GApplication *application) static void -notify_window_visible_cb (GtkWidget *window, - GParamSpec *pspec, +notify_window_visible_cb (GtkWidget *window, + GParamSpec *pspec, CallsApplication *application) { CallsManager *manager = calls_manager_get_default (); @@ -530,7 +532,7 @@ notify_window_visible_cb (GtkWidget *window, static gboolean -start_proper (CallsApplication *self) +start_proper (CallsApplication *self) { GtkApplication *gtk_app; @@ -550,8 +552,8 @@ start_proper (CallsApplication *self) g_assert (CALLS_IS_NOTIFIER (self->notifier)); self->main_window = calls_main_window_new - (gtk_app, - G_LIST_MODEL (self->record_store)); + (gtk_app, + G_LIST_MODEL (self->record_store)); g_assert (self->main_window != NULL); self->call_window = calls_call_window_new (gtk_app); @@ -600,10 +602,10 @@ activate (GApplication *application) } static void -app_open (GApplication *application, - GFile **files, - gint n_files, - const char *hint) +app_open (GApplication *application, + GFile **files, + gint n_files, + const char *hint) { CallsApplication *self = CALLS_APPLICATION (application); @@ -642,7 +644,7 @@ app_open (GApplication *application, static void finalize (GObject *object) { - CallsApplication *self = (CallsApplication *)object; + CallsApplication *self = (CallsApplication *) object; g_clear_object (&self->call_window); g_clear_object (&self->main_window); @@ -669,8 +671,8 @@ calls_application_class_init (CallsApplicationClass *klass) application_class->shutdown = app_shutdown; application_class->activate = activate; application_class->open = app_open; - application_class->dbus_register = calls_application_dbus_register; - application_class->dbus_unregister = calls_application_dbus_unregister; + application_class->dbus_register = calls_application_dbus_register; + application_class->dbus_unregister = calls_application_dbus_unregister; g_type_ensure (CALLS_TYPE_HISTORY_BOX); g_type_ensure (CALLS_TYPE_NEW_CALL_BOX); diff --git a/src/calls-best-match.c b/src/calls-best-match.c index f359868..09d2953 100644 --- a/src/calls-best-match.c +++ b/src/calls-best-match.c @@ -31,16 +31,15 @@ #include -struct _CallsBestMatch -{ - GObject parent_instance; +struct _CallsBestMatch { + GObject parent_instance; - FolksSearchView *view; - FolksIndividual *matched_individual; - char *phone_number; - char *country_code; - char *name_sip; - gboolean had_country_code_last_time; + FolksSearchView *view; + FolksIndividual *matched_individual; + char *phone_number; + char *country_code; + char *name_sip; + gboolean had_country_code_last_time; }; G_DEFINE_TYPE (CallsBestMatch, calls_best_match, G_TYPE_OBJECT); @@ -112,7 +111,7 @@ update_best_match (CallsBestMatch *self) g_return_if_fail (GEE_IS_COLLECTION (individuals)); if (!gee_collection_get_is_empty (GEE_COLLECTION (individuals))) - matched_individual = gee_sorted_set_first (individuals); + matched_individual = gee_sorted_set_first (individuals); if (matched_individual == self->matched_individual) return; @@ -174,10 +173,10 @@ set_property (GObject *object, static void -get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { CallsBestMatch *self = CALLS_BEST_MATCH (object); @@ -432,8 +431,8 @@ calls_best_match_get_primary_info (CallsBestMatch *self) if (self->phone_number) return self->phone_number; - anon: - return _("Anonymous caller"); +anon: + return _("Anonymous caller"); } /** @@ -461,6 +460,6 @@ calls_best_match_get_secondary_info (CallsBestMatch *self) * https://gitlab.gnome.org/GNOME/calls/-/issues/358 */ - anon: +anon: return ""; } diff --git a/src/calls-best-match.h b/src/calls-best-match.h index 5b4df30..0b5f034 100644 --- a/src/calls-best-match.h +++ b/src/calls-best-match.h @@ -33,15 +33,15 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (CallsBestMatch, calls_best_match, CALLS, BEST_MATCH, GObject); -CallsBestMatch *calls_best_match_new (const char *phone_number); -gboolean calls_best_match_has_individual (CallsBestMatch *self); -const char *calls_best_match_get_phone_number (CallsBestMatch *self); -void calls_best_match_set_phone_number (CallsBestMatch *self, - const char *phone_number); -const char *calls_best_match_get_name (CallsBestMatch *self); -GLoadableIcon *calls_best_match_get_avatar (CallsBestMatch *self); -const char *calls_best_match_get_primary_info (CallsBestMatch *self); -const char *calls_best_match_get_secondary_info (CallsBestMatch *self); +CallsBestMatch *calls_best_match_new (const char *phone_number); +gboolean calls_best_match_has_individual (CallsBestMatch *self); +const char *calls_best_match_get_phone_number (CallsBestMatch *self); +void calls_best_match_set_phone_number (CallsBestMatch *self, + const char *phone_number); +const char *calls_best_match_get_name (CallsBestMatch *self); +GLoadableIcon *calls_best_match_get_avatar (CallsBestMatch *self); +const char *calls_best_match_get_primary_info (CallsBestMatch *self); +const char *calls_best_match_get_secondary_info (CallsBestMatch *self); G_END_DECLS diff --git a/src/calls-call-record-row.c b/src/calls-call-record-row.c index 013d285..ca99415 100644 --- a/src/calls-call-record-row.c +++ b/src/calls-call-record-row.c @@ -37,29 +37,28 @@ #include -struct _CallsCallRecordRow -{ - GtkListBoxRow parent_instance; +struct _CallsCallRecordRow { + GtkListBoxRow parent_instance; - GtkWidget *avatar; - GtkImage *type; - GtkLabel *target; - GtkLabel *time; - GtkButton *button; - GtkPopover *popover; - GtkGesture *gesture; - GtkEventBox *event_box; + GtkWidget *avatar; + GtkImage *type; + GtkLabel *target; + GtkLabel *time; + GtkButton *button; + GtkPopover *popover; + GtkGesture *gesture; + GtkEventBox *event_box; - GMenu *context_menu; + GMenu *context_menu; - GActionMap *action_map; + GActionMap *action_map; CallsCallRecord *record; - gulong answered_notify_handler_id; - gulong end_notify_handler_id; - guint date_change_timeout; + gulong answered_notify_handler_id; + gulong end_notify_handler_id; + guint date_change_timeout; - CallsBestMatch *contact; + CallsBestMatch *contact; }; G_DEFINE_TYPE (CallsCallRecordRow, calls_call_record_row, GTK_TYPE_LIST_BOX_ROW) @@ -75,10 +74,11 @@ static GParamSpec *props[PROP_LAST_PROP]; static void nice_time (GDateTime *t, - gchar **nice, - gboolean *final) + gchar **nice, + gboolean *final) { GDateTime *now = g_date_time_new_now_local (); + g_autoptr (GTimeZone) local_tz = g_time_zone_new_local (); g_autoptr (GDateTime) t_local_tz = g_date_time_to_timezone (t, local_tz); const gboolean today = @@ -119,6 +119,7 @@ update_time_text (CallsCallRecordRow *self, gboolean *final) { gchar *nice; + nice_time (end, &nice, final); gtk_label_set_text (self->time, nice); g_free (nice); @@ -155,18 +156,17 @@ setup_date_change_timeout (CallsCallRecordRow *self) g_date_time_unref (gnextday); // Convert to a timeval - tomorrow.tv_sec = g_date_time_to_unix (gtomorrow); + tomorrow.tv_sec = g_date_time_to_unix (gtomorrow); tomorrow.tv_usec = 0; g_date_time_unref (gtomorrow); // Get the precise time now err = gettimeofday (&now, NULL); - if (err == -1) - { - g_warning ("Error getting time to set date change timeout: %s", - g_strerror (errno)); - return; - } + if (err == -1) { + g_warning ("Error getting time to set date change timeout: %s", + g_strerror (errno)); + return; + } // Find how long from now until the start of the next day timersub (&tomorrow, &now, &delta); @@ -180,7 +180,7 @@ setup_date_change_timeout (CallsCallRecordRow *self) // Add the timeout self->date_change_timeout = g_timeout_add (interval, - (GSourceFunc)date_change_cb, + (GSourceFunc) date_change_cb, self); } @@ -294,7 +294,7 @@ on_notify_can_add_contacts (CallsCallRecordRow *self) if (!calls_contacts_provider_get_can_add_contacts (contacts_provider)) return; - g_signal_handlers_disconnect_by_data(contacts_provider, self); + g_signal_handlers_disconnect_by_data (contacts_provider, self); /* The record has a NULL id */ if (!self->contact) @@ -379,7 +379,7 @@ context_menu (GtkWidget *widget, gtk_popover_bind_model (self->popover, G_MENU_MODEL (self->context_menu), "row-history"); - } + } gtk_popover_popup (self->popover); } @@ -483,10 +483,10 @@ constructed (GObject *object) static void -get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { CallsCallRecordRow *self = CALLS_CALL_RECORD_ROW (object); @@ -562,6 +562,7 @@ delete_call_activated (GSimpleAction *action, gpointer data) { GtkWidget *self = GTK_WIDGET (data); + g_signal_emit_by_name (CALLS_CALL_RECORD_ROW (self)->record, "call-delete"); } @@ -603,9 +604,9 @@ new_contact_activated (GSimpleAction *action, static GActionEntry entries[] = { - { "delete-call", delete_call_activated, NULL, NULL, NULL}, - { "copy-number", copy_number_activated, NULL, NULL, NULL}, - { "new-contact", new_contact_activated, NULL, NULL, NULL}, + { "delete-call", delete_call_activated, NULL, NULL, NULL}, + { "copy-number", copy_number_activated, NULL, NULL, NULL}, + { "new-contact", new_contact_activated, NULL, NULL, NULL}, }; @@ -613,6 +614,7 @@ static void calls_call_record_row_init (CallsCallRecordRow *self) { GAction *act; + gtk_widget_init_template (GTK_WIDGET (self)); self->action_map = G_ACTION_MAP (g_simple_action_group_new ()); diff --git a/src/calls-call-record-row.h b/src/calls-call-record-row.h index 99f171b..8498808 100644 --- a/src/calls-call-record-row.h +++ b/src/calls-call-record-row.h @@ -37,8 +37,8 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (CallsCallRecordRow, calls_call_record_row, CALLS, CALL_RECORD_ROW, GtkListBoxRow) -CallsCallRecordRow *calls_call_record_row_new (CallsCallRecord *record); -CallsCallRecord * calls_call_record_row_get_record (CallsCallRecordRow *self); +CallsCallRecordRow *calls_call_record_row_new (CallsCallRecord *record); +CallsCallRecord *calls_call_record_row_get_record (CallsCallRecordRow *self); G_END_DECLS diff --git a/src/calls-call-record.c b/src/calls-call-record.c index bd39343..eba9f75 100644 --- a/src/calls-call-record.c +++ b/src/calls-call-record.c @@ -27,20 +27,19 @@ #include -struct _CallsCallRecord -{ +struct _CallsCallRecord { GomResource parent_instance; - guint id; - char *target; - gboolean inbound; - GDateTime *start; - GDateTime *answered; - GDateTime *end; - char *protocol; - gboolean complete; + guint id; + char *target; + gboolean inbound; + GDateTime *start; + GDateTime *answered; + GDateTime *end; + char *protocol; + gboolean complete; }; -G_DEFINE_TYPE(CallsCallRecord, calls_call_record, GOM_TYPE_RESOURCE) +G_DEFINE_TYPE (CallsCallRecord, calls_call_record, GOM_TYPE_RESOURCE) enum { @@ -57,17 +56,17 @@ enum { static GParamSpec *props[PROP_LAST_PROP]; enum { - SIGNAL_CALL_DELETE, - SIGNAL_LAST_SIGNAL, + SIGNAL_CALL_DELETE, + SIGNAL_LAST_SIGNAL, }; -static guint signals [SIGNAL_LAST_SIGNAL]; +static guint signals[SIGNAL_LAST_SIGNAL]; static void -get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { CallsCallRecord *self = CALLS_CALL_RECORD (object); @@ -109,17 +108,15 @@ get_property (GObject *object, static void -set_date_time (GDateTime **stamp_ptr, - const GValue *value) +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); - } + *stamp_ptr = g_date_time_ref (new_stamp); } diff --git a/src/calls-call-selector-item.c b/src/calls-call-selector-item.c index d343bd9..6240141 100644 --- a/src/calls-call-selector-item.c +++ b/src/calls-call-selector-item.c @@ -32,15 +32,14 @@ #include -struct _CallsCallSelectorItem -{ - GtkEventBox parent_instance; +struct _CallsCallSelectorItem { + GtkEventBox parent_instance; CuiCallDisplay *display; - GtkBox *main_box; - GtkLabel *name; - GtkLabel *status; + GtkBox *main_box; + GtkLabel *name; + GtkLabel *status; }; G_DEFINE_TYPE (CallsCallSelectorItem, calls_call_selector_item, GTK_TYPE_EVENT_BOX); @@ -184,5 +183,3 @@ calls_call_selector_item_get_display (CallsCallSelectorItem *item) g_return_val_if_fail (CALLS_IS_CALL_SELECTOR_ITEM (item), NULL); return item->display; } - - diff --git a/src/calls-call-selector-item.h b/src/calls-call-selector-item.h index b70ac50..5ea5c09 100644 --- a/src/calls-call-selector-item.h +++ b/src/calls-call-selector-item.h @@ -35,7 +35,7 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (CallsCallSelectorItem, calls_call_selector_item, CALLS, CALL_SELECTOR_ITEM, GtkEventBox); -CallsCallSelectorItem *calls_call_selector_item_new (CuiCallDisplay *display); +CallsCallSelectorItem *calls_call_selector_item_new (CuiCallDisplay *display); CuiCallDisplay *calls_call_selector_item_get_display (CallsCallSelectorItem *item); G_END_DECLS diff --git a/src/calls-call-window.c b/src/calls-call-window.c index 6d21055..0411e3f 100644 --- a/src/calls-call-window.c +++ b/src/calls-call-window.c @@ -40,21 +40,20 @@ #include -struct _CallsCallWindow -{ - GtkApplicationWindow parent_instance; +struct _CallsCallWindow { + GtkApplicationWindow parent_instance; - GListStore *calls; + GListStore *calls; CallsInAppNotification *in_app_notification; - GtkStack *main_stack; - GtkStack *header_bar_stack; - GtkButton *show_calls; - GtkStack *call_stack; - GtkFlowBox *call_selector; + GtkStack *main_stack; + GtkStack *header_bar_stack; + GtkButton *show_calls; + GtkStack *call_stack; + GtkFlowBox *call_selector; - guint inhibit_cookie; + guint inhibit_cookie; }; G_DEFINE_TYPE (CallsCallWindow, calls_call_window, GTK_TYPE_APPLICATION_WINDOW); @@ -280,6 +279,7 @@ calls_call_window_init (CallsCallWindow *self) { g_autoptr (GList) calls = NULL; GList *c; + gtk_widget_init_template (GTK_WIDGET (self)); self->calls = g_list_store_new (CALLS_TYPE_CALL_SELECTOR_ITEM); @@ -350,4 +350,3 @@ calls_call_window_new (GtkApplication *application) "application", application, NULL); } - diff --git a/src/calls-call.c b/src/calls-call.c index 5c03cdf..e2a0a8a 100644 --- a/src/calls-call.c +++ b/src/calls-call.c @@ -66,11 +66,11 @@ static GParamSpec *properties[N_PROPS]; static guint signals[N_SIGNALS]; typedef struct { - char *id; - char *name; + char *id; + char *name; CallsCallState state; - gboolean inbound; - CallsCallType call_type; + gboolean inbound; + CallsCallType call_type; } CallsCallPrivate; G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (CallsCall, calls_call, G_TYPE_OBJECT) diff --git a/src/calls-call.h b/src/calls-call.h index 1becc3f..dcb2c44 100644 --- a/src/calls-call.h +++ b/src/calls-call.h @@ -49,38 +49,36 @@ typedef enum { CALLS_CALL_TYPE_SIP_VOICE, } CallsCallType; -struct _CallsCallClass -{ +struct _CallsCallClass { GObjectClass parent_iface; - const char *(*get_protocol) (CallsCall *self); - void (*answer) (CallsCall *self); - void (*hang_up) (CallsCall *self); - void (*send_dtmf_tone) (CallsCall *self, - char key); + const char *(*get_protocol) (CallsCall *self); + void (*answer) (CallsCall *self); + void (*hang_up) (CallsCall *self); + void (*send_dtmf_tone) (CallsCall *self, + char key); }; -const char *calls_call_get_id (CallsCall *self); -void calls_call_set_id (CallsCall *self, - const char *id); -const char *calls_call_get_name (CallsCall *self); -void calls_call_set_name (CallsCall *self, - const char *name); -CallsCallState calls_call_get_state (CallsCall *self); -void calls_call_set_state (CallsCall *self, - CallsCallState state); -CallsCallType calls_call_get_call_type (CallsCall *self); -gboolean calls_call_get_inbound (CallsCall *self); -const char *calls_call_get_protocol (CallsCall *self); -void calls_call_answer (CallsCall *self); -void calls_call_hang_up (CallsCall *self); -gboolean calls_call_can_dtmf (CallsCall *self); -void calls_call_send_dtmf_tone (CallsCall *self, - char key); +const char *calls_call_get_id (CallsCall *self); +void calls_call_set_id (CallsCall *self, + const char *id); +const char *calls_call_get_name (CallsCall *self); +void calls_call_set_name (CallsCall *self, + const char *name); +CallsCallState calls_call_get_state (CallsCall *self); +void calls_call_set_state (CallsCall *self, + CallsCallState state); +CallsCallType calls_call_get_call_type (CallsCall *self); +gboolean calls_call_get_inbound (CallsCall *self); +const char *calls_call_get_protocol (CallsCall *self); +void calls_call_answer (CallsCall *self); +void calls_call_hang_up (CallsCall *self); +gboolean calls_call_can_dtmf (CallsCall *self); +void calls_call_send_dtmf_tone (CallsCall *self, + char key); -gboolean calls_call_state_parse_nick (CallsCallState *state, - const char *nick); +gboolean calls_call_state_parse_nick (CallsCallState *state, + const char *nick); G_END_DECLS - diff --git a/src/calls-contacts-box.c b/src/calls-contacts-box.c index f4b6865..50c1af6 100644 --- a/src/calls-contacts-box.c +++ b/src/calls-contacts-box.c @@ -32,14 +32,13 @@ #define HANDY_USE_UNSTABLE_API #include -struct _CallsContactsBox -{ - GtkBin parent_instance; +struct _CallsContactsBox { + GtkBin parent_instance; - GtkWidget *search_entry; - GtkWidget *contacts_frame; - GtkWidget *contacts_listbox; - GtkWidget *placeholder_empty; + GtkWidget *search_entry; + GtkWidget *contacts_frame; + GtkWidget *contacts_listbox; + GtkWidget *placeholder_empty; FolksSimpleQuery *search_query; }; @@ -51,6 +50,7 @@ search_changed_cb (CallsContactsBox *self, GtkEntry *entry) { const gchar *search_text; + search_text = gtk_entry_get_text (entry); folks_simple_query_set_query_string (self->search_query, search_text); @@ -73,31 +73,27 @@ adjust_style (CallsContactsBox *self, GtkWidget *widget) { g_return_if_fail (CALLS_IS_CONTACTS_BOX (self)); - if (gtk_widget_get_mapped (widget)) - { - gtk_frame_set_shadow_type (GTK_FRAME (self->contacts_frame), GTK_SHADOW_NONE); - gtk_widget_set_vexpand (self->contacts_frame, TRUE); - gtk_style_context_add_class (gtk_widget_get_style_context (self->contacts_listbox), - "no-background"); - } - else - { - gtk_frame_set_shadow_type (GTK_FRAME (self->contacts_frame), GTK_SHADOW_ETCHED_IN); - gtk_widget_set_vexpand (self->contacts_frame, FALSE); - gtk_style_context_remove_class (gtk_widget_get_style_context (self->contacts_listbox), - "no-background"); - } + if (gtk_widget_get_mapped (widget)) { + gtk_frame_set_shadow_type (GTK_FRAME (self->contacts_frame), GTK_SHADOW_NONE); + gtk_widget_set_vexpand (self->contacts_frame, TRUE); + gtk_style_context_add_class (gtk_widget_get_style_context (self->contacts_listbox), + "no-background"); + } else { + gtk_frame_set_shadow_type (GTK_FRAME (self->contacts_frame), GTK_SHADOW_ETCHED_IN); + gtk_widget_set_vexpand (self->contacts_frame, FALSE); + gtk_style_context_remove_class (gtk_widget_get_style_context (self->contacts_listbox), + "no-background"); + } } static void -header_cb (GtkListBoxRow *row, - GtkListBoxRow *before) +header_cb (GtkListBoxRow *row, + GtkListBoxRow *before) { - if (!before) - { - gtk_list_box_row_set_header (row, NULL); - return; - } + if (!before) { + gtk_list_box_row_set_header (row, NULL); + return; + } if (!gtk_list_box_row_get_header (row)) @@ -109,6 +105,7 @@ contacts_provider_added (CallsContactsBox *self, FolksIndividual *individual) { GtkWidget *row; + row = calls_contacts_row_new (individual); gtk_container_add (GTK_CONTAINER (self->contacts_listbox), row); @@ -131,7 +128,7 @@ contacts_provider_removed (CallsContactsBox *self, static gint contacts_sort_func (CallsContactsRow *a, CallsContactsRow *b, - gpointer user_data) + gpointer user_data) { const gchar *name_a = folks_individual_get_display_name (calls_contacts_row_get_item (a)); const gchar *name_b = folks_individual_get_display_name (calls_contacts_row_get_item (b)); @@ -157,6 +154,7 @@ static void calls_contacts_box_init (CallsContactsBox *self) { CallsContactsProvider *contacts_provider; + g_autoptr (GeeCollection) individuals = NULL; gchar* query_fields[] = { "alias", "full-name", diff --git a/src/calls-contacts-box.h b/src/calls-contacts-box.h index 9f1616d..14eb91d 100644 --- a/src/calls-contacts-box.h +++ b/src/calls-contacts-box.h @@ -33,7 +33,7 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (CallsContactsBox, calls_contacts_box, CALLS, CONTACTS_BOX, GtkBin); -GtkWidget * calls_contacts_box_new (void); +GtkWidget *calls_contacts_box_new (void); G_END_DECLS diff --git a/src/calls-contacts-provider.c b/src/calls-contacts-provider.c index 5bd1818..8279a48 100644 --- a/src/calls-contacts-provider.c +++ b/src/calls-contacts-provider.c @@ -48,16 +48,14 @@ */ -typedef struct -{ - GeeIterator *iter; - IdleCallback callback; - gpointer user_data; +typedef struct { + GeeIterator *iter; + IdleCallback callback; + gpointer user_data; } IdleData; -struct _CallsContactsProvider -{ +struct _CallsContactsProvider { GObject parent_instance; FolksIndividualAggregator *folks_aggregator; @@ -215,12 +213,13 @@ on_contacts_actions_updated (CallsContactsProvider *self) static void -on_contacts_appeared (GDBusConnection *connection, - const char *name, - const char *owner_name, - gpointer user_data) +on_contacts_appeared (GDBusConnection *connection, + const char *name, + const char *owner_name, + gpointer user_data) { CallsContactsProvider *self; + g_autoptr (GError) error = NULL; g_assert (CALLS_IS_CONTACTS_PROVIDER (user_data)); @@ -298,7 +297,7 @@ calls_contacts_provider_finalize (GObject *object) static void calls_contacts_provider_class_init (CallsContactsProviderClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->get_property = calls_contacts_provider_get_property; object_class->set_property = calls_contacts_provider_set_property; @@ -313,14 +312,14 @@ calls_contacts_provider_class_init (CallsContactsProviderClass *klass) * having been added. */ signals[SIGNAL_ADDED] = - g_signal_new ("added", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, NULL, - G_TYPE_NONE, - 1, - FOLKS_TYPE_INDIVIDUAL); + g_signal_new ("added", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, + 1, + FOLKS_TYPE_INDIVIDUAL); /** * CallsContactsProvider::removed: * @self: The #CallsContactsProvider instance @@ -330,14 +329,14 @@ calls_contacts_provider_class_init (CallsContactsProviderClass *klass) * having been removed. */ signals[SIGNAL_REMOVED] = - g_signal_new ("removed", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, NULL, - G_TYPE_NONE, - 1, - FOLKS_TYPE_INDIVIDUAL); + g_signal_new ("removed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, + 1, + FOLKS_TYPE_INDIVIDUAL); /** * CallsContactsProvider::settings: @@ -481,6 +480,7 @@ calls_contacts_provider_consume_iter_on_idle (GeeIterator *iter, gpointer user_data) { IdleData *data = g_new (IdleData, 1); + data->iter = iter; data->user_data = user_data; data->callback = callback; diff --git a/src/calls-contacts-provider.h b/src/calls-contacts-provider.h index be6cfd8..9f7d1aa 100644 --- a/src/calls-contacts-provider.h +++ b/src/calls-contacts-provider.h @@ -42,7 +42,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (GeeSortedSet, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (GeeCollection, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (EPhoneNumber, e_phone_number_free) -typedef void (*IdleCallback) (gpointer user_data, +typedef void (*IdleCallback) (gpointer user_data, FolksIndividual *individual); #define CALLS_TYPE_CONTACTS_PROVIDER (calls_contacts_provider_get_type ()) @@ -50,14 +50,14 @@ typedef void (*IdleCallback) (gpointer user_data, G_DECLARE_FINAL_TYPE (CallsContactsProvider, calls_contacts_provider, CALLS, CONTACTS_PROVIDER, GObject) CallsContactsProvider *calls_contacts_provider_new (CallsSettings *settings); -GeeCollection *calls_contacts_provider_get_individuals (CallsContactsProvider *self); -CallsBestMatch *calls_contacts_provider_lookup_id (CallsContactsProvider *self, - const char *id); -void calls_contacts_provider_consume_iter_on_idle (GeeIterator *iter, - IdleCallback callback, - gpointer user_data); -gboolean calls_contacts_provider_get_can_add_contacts (CallsContactsProvider *self); -void calls_contacts_provider_add_new_contact (CallsContactsProvider *self, - const char *phone_number); +GeeCollection *calls_contacts_provider_get_individuals (CallsContactsProvider *self); +CallsBestMatch *calls_contacts_provider_lookup_id (CallsContactsProvider *self, + const char *id); +void calls_contacts_provider_consume_iter_on_idle (GeeIterator *iter, + IdleCallback callback, + gpointer user_data); +gboolean calls_contacts_provider_get_can_add_contacts (CallsContactsProvider *self); +void calls_contacts_provider_add_new_contact (CallsContactsProvider *self, + const char *phone_number); G_END_DECLS diff --git a/src/calls-contacts-row.c b/src/calls-contacts-row.c index 6a5b54a..0dc614d 100644 --- a/src/calls-contacts-row.c +++ b/src/calls-contacts-row.c @@ -16,17 +16,16 @@ #include "calls-contacts-row.h" #include "calls-contacts-provider.h" -struct _CallsContactsRow -{ - GtkListBoxRow parent_instance; +struct _CallsContactsRow { + GtkListBoxRow parent_instance; - GtkWidget *avatar; - GtkWidget *title; - GtkWidget *grid; + GtkWidget *avatar; + GtkWidget *title; + GtkWidget *grid; - gint n_phonenumbers; + gint n_phonenumbers; - FolksIndividual *item; + FolksIndividual *item; }; G_DEFINE_TYPE (CallsContactsRow, calls_contacts_row, GTK_TYPE_LIST_BOX_ROW) @@ -63,6 +62,7 @@ static void phone_numbers_changed_cb (CallsContactsRow *self) { GeeIterator *phone_iter; + g_autoptr (GeeSet) phone_numbers; while (gtk_grid_get_child_at (GTK_GRID (self->grid), 1, 1) != NULL) { @@ -121,7 +121,7 @@ calls_contacts_row_dispose (GObject *object) static void calls_contacts_row_class_init (CallsContactsRowClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); object_class->dispose = calls_contacts_row_dispose; diff --git a/src/calls-dbus-manager.c b/src/calls-dbus-manager.c index 4e2cf19..4be96a7 100644 --- a/src/calls-dbus-manager.c +++ b/src/calls-dbus-manager.c @@ -102,12 +102,12 @@ on_handle_call_hangup (CallsDBusCallsCall *skeleton, } static gboolean -(avatar_loadable_icon_transform_to_image_path) (GBinding *binding, - const GValue *from_value, - GValue *to_value, - gpointer user_data) + (avatar_loadable_icon_transform_to_image_path) (GBinding *binding, + const GValue *from_value, + GValue *to_value, + gpointer user_data) { - GLoadableIcon *icon = G_LOADABLE_ICON (g_value_get_object(from_value)); + GLoadableIcon *icon = G_LOADABLE_ICON (g_value_get_object (from_value)); if (icon == NULL) { g_value_set_string (to_value, NULL); @@ -237,11 +237,11 @@ on_notify_update_hints (CallsUiCallData *call, static void call_added_cb (CallsDBusManager *self, CuiCall *call) { - g_autofree char *path = NULL; g_autoptr (GError) error = NULL; g_autoptr (CallsDBusObjectSkeleton) object = NULL; g_autoptr (CallsDBusCallsCall) iface = NULL; g_autoptr (CallsBestMatch) match = NULL; + g_autofree char *path = NULL; path = get_obj_path (self, self->iface_num++); object = calls_dbus_object_skeleton_new (path); diff --git a/src/calls-dbus-manager.h b/src/calls-dbus-manager.h index 4ecb0d3..7534d42 100644 --- a/src/calls-dbus-manager.h +++ b/src/calls-dbus-manager.h @@ -19,8 +19,8 @@ G_DECLARE_FINAL_TYPE (CallsDBusManager, calls_dbus_manager, CALLS, DBUS_MANAGER, GObject) CallsDBusManager *calls_dbus_manager_new (void); -gboolean calls_dbus_manager_register (CallsDBusManager *self, - GDBusConnection *connection, - const char *object_path, - GError **error); +gboolean calls_dbus_manager_register (CallsDBusManager *self, + GDBusConnection *connection, + const char *object_path, + GError **error); G_END_DECLS diff --git a/src/calls-history-box.c b/src/calls-history-box.c index b174848..d419d38 100644 --- a/src/calls-history-box.c +++ b/src/calls-history-box.c @@ -31,14 +31,13 @@ #include -struct _CallsHistoryBox -{ - GtkStack parent_instance; +struct _CallsHistoryBox { + GtkStack parent_instance; GtkListBox *history; GListModel *model; - gulong model_changed_handler_id; + gulong model_changed_handler_id; }; @@ -74,8 +73,8 @@ update (CallsHistoryBox *self) static void -delete_call_cb (CallsCallRecord *record, - CallsHistoryBox *self) +delete_call_cb (CallsCallRecord *record, + CallsHistoryBox *self) { guint position; guint id; @@ -84,8 +83,8 @@ delete_call_cb (CallsCallRecord *record, g_return_if_fail (CALLS_IS_CALL_RECORD (record)); ok = calls_find_in_store (self->model, - record, - &position); + record, + &position); g_object_get (G_OBJECT (record), "id", @@ -100,7 +99,7 @@ delete_call_cb (CallsCallRecord *record, g_list_store_remove ((GListStore *) self->model, position); - update(self); + update (self); } @@ -109,6 +108,7 @@ create_row_cb (CallsCallRecord *record, CallsHistoryBox *self) { GtkWidget *row_widget; + row_widget = GTK_WIDGET (calls_call_record_row_new (record)); g_signal_connect (record, @@ -149,12 +149,12 @@ constructed (GObject *object) self->model_changed_handler_id = g_signal_connect_swapped - (self->model, "items-changed", G_CALLBACK (update), self); + (self->model, "items-changed", G_CALLBACK (update), self); g_assert (self->model_changed_handler_id != 0); gtk_list_box_bind_model (self->history, self->model, - (GtkListBoxCreateWidgetFunc)create_row_cb, + (GtkListBoxCreateWidgetFunc) create_row_cb, self, NULL); @@ -208,7 +208,7 @@ calls_history_box_init (CallsHistoryBox *self) CallsHistoryBox * -calls_history_box_new (GListModel *model) +calls_history_box_new (GListModel *model) { return g_object_new (CALLS_TYPE_HISTORY_BOX, "model", model, diff --git a/src/calls-history-box.h b/src/calls-history-box.h index a2c3fce..4c94ec3 100644 --- a/src/calls-history-box.h +++ b/src/calls-history-box.h @@ -35,7 +35,7 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (CallsHistoryBox, calls_history_box, CALLS, HISTORY_BOX, GtkStack); -CallsHistoryBox * calls_history_box_new (GListModel *model); +CallsHistoryBox *calls_history_box_new (GListModel *model); G_END_DECLS diff --git a/src/calls-in-app-notification.c b/src/calls-in-app-notification.c index b0ef204..9c36d09 100644 --- a/src/calls-in-app-notification.c +++ b/src/calls-in-app-notification.c @@ -26,14 +26,13 @@ #define DEFAULT_TIMEOUT_SECONDS 3 -struct _CallsInAppNotification -{ +struct _CallsInAppNotification { GtkRevealer parent_instance; - GtkLabel *label; + GtkLabel *label; - guint timeout; - guint timeout_id; + guint timeout; + guint timeout_id; }; G_DEFINE_TYPE (CallsInAppNotification, calls_in_app_notification, GTK_TYPE_REVEALER) @@ -56,10 +55,10 @@ timeout_cb (CallsInAppNotification *self) static void -calls_in_app_notification_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +calls_in_app_notification_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { CallsInAppNotification *self = CALLS_IN_APP_NOTIFICATION (object); @@ -159,7 +158,7 @@ calls_in_app_notification_show (CallsInAppNotification *self, const gchar *messa g_source_remove (self->timeout_id); gtk_revealer_set_reveal_child (GTK_REVEALER (self), TRUE); - self->timeout_id = g_timeout_add_seconds (self->timeout, (GSourceFunc)timeout_cb, self); + self->timeout_id = g_timeout_add_seconds (self->timeout, (GSourceFunc) timeout_cb, self); } @@ -170,5 +169,5 @@ calls_in_app_notification_hide (CallsInAppNotification *self) g_clear_handle_id (&self->timeout_id, g_source_remove); - gtk_revealer_set_reveal_child (GTK_REVEALER(self), FALSE); + gtk_revealer_set_reveal_child (GTK_REVEALER (self), FALSE); } diff --git a/src/calls-log.c b/src/calls-log.c index a2f6b4f..46f49b8 100644 --- a/src/calls-log.c +++ b/src/calls-log.c @@ -63,7 +63,7 @@ get_log_level_prefix (GLogLevelFlags log_level, log_level = log_level & ~CALLS_LOG_DETAILED; if (use_color) { - switch ((int)log_level) { /* Same colors as used in GLib */ + switch ((int) log_level) { /* Same colors as used in GLib */ case G_LOG_LEVEL_ERROR: return " \033[1;31mERROR\033[0m"; case G_LOG_LEVEL_CRITICAL: return "\033[1;35mCRITICAL\033[0m"; case G_LOG_LEVEL_WARNING: return " \033[1;33mWARNING\033[0m"; @@ -74,7 +74,7 @@ get_log_level_prefix (GLogLevelFlags log_level, default: return " UNKNOWN"; } } else { - switch ((int)log_level) { + switch ((int) log_level) { case G_LOG_LEVEL_ERROR: return " ERROR"; case G_LOG_LEVEL_CRITICAL: return "CRITICAL"; case G_LOG_LEVEL_WARNING: return " WARNING"; @@ -95,7 +95,7 @@ calls_log_write (GLogLevelFlags log_level, gsize n_fields, gpointer user_data) { - g_autoptr(GString) log_str = NULL; + g_autoptr (GString) log_str = NULL; FILE *stream; gboolean can_color; @@ -123,7 +123,7 @@ calls_log_write (GLogLevelFlags log_level, strftime (buffer, sizeof (buffer), "%H:%M:%S", &tm_now); g_string_append_printf (log_str, "%s.%04d ", buffer, - (int)((now % G_USEC_PER_SEC) / 100)); + (int) ((now % G_USEC_PER_SEC) / 100)); } can_color = g_log_writer_supports_color (fileno (stream)); @@ -173,7 +173,7 @@ calls_log_handler (GLogLevelFlags log_level, const char *log_message = NULL; /* If domain is “all” show logs upto debug regardless of the verbosity */ - switch ((int)log_level) { + switch ((int) log_level) { case G_LOG_LEVEL_MESSAGE: if (any_domain && domains) break; @@ -235,7 +235,7 @@ calls_log_handler (GLogLevelFlags log_level, if (any_domain || strcasestr (domains, log_domain)) return calls_log_write (log_level, log_domain, log_message, - fields, n_fields, user_data); + fields, n_fields, user_data); return G_LOG_WRITER_HANDLED; } diff --git a/src/calls-main-window.c b/src/calls-main-window.c index 09ed527..33b6566 100644 --- a/src/calls-main-window.c +++ b/src/calls-main-window.c @@ -40,32 +40,31 @@ #include -struct _CallsMainWindow -{ - HdyApplicationWindow parent_instance; +struct _CallsMainWindow { + HdyApplicationWindow parent_instance; - GListModel *record_store; + GListModel *record_store; CallsInAppNotification *in_app_notification; - HdyViewSwitcherTitle *title_switcher; - GtkStack *main_stack; + HdyViewSwitcherTitle *title_switcher; + GtkStack *main_stack; - GtkRevealer *permanent_error_revealer; - GtkLabel *permanent_error_label; + GtkRevealer *permanent_error_revealer; + GtkLabel *permanent_error_label; - CallsAccountOverview *account_overview; - CallsNewCallBox *new_call; + CallsAccountOverview *account_overview; + CallsNewCallBox *new_call; - GtkDialog *ussd_dialog; - GtkStack *ussd_stack; - GtkSpinner *ussd_spinner; - GtkBox *ussd_content; - GtkLabel *ussd_label; - GtkEntry *ussd_entry; - GtkButton *ussd_close_button; - GtkButton *ussd_cancel_button; - GtkButton *ussd_reply_button; + GtkDialog *ussd_dialog; + GtkStack *ussd_stack; + GtkSpinner *ussd_spinner; + GtkBox *ussd_content; + GtkLabel *ussd_label; + GtkEntry *ussd_entry; + GtkButton *ussd_close_button; + GtkButton *ussd_cancel_button; + GtkButton *ussd_reply_button; }; G_DEFINE_TYPE (CallsMainWindow, calls_main_window, HDY_TYPE_APPLICATION_WINDOW); @@ -106,8 +105,8 @@ about_action (GSimpleAction *action, NULL }; - version = g_str_equal (VCS_TAG, "") ? PACKAGE_VERSION: - PACKAGE_VERSION "-" VCS_TAG; + version = g_str_equal (VCS_TAG, "") ? + PACKAGE_VERSION : PACKAGE_VERSION "-" VCS_TAG; /* * “program-name” defaults to g_get_application_name(). @@ -128,7 +127,7 @@ about_action (GSimpleAction *action, } -static const GActionEntry window_entries [] = +static const GActionEntry window_entries[] = { { "about", about_action }, }; @@ -216,26 +215,24 @@ window_ussd_respond_cb (GObject *object, GAsyncResult *result, gpointer user_data) { - CallsMainWindow *self = user_data; - g_autofree char *response = NULL; g_autoptr (GError) error = NULL; + g_autofree char *response = NULL; + CallsMainWindow *self = user_data; CallsUssd *ussd; ussd = g_object_get_data (G_OBJECT (self->ussd_dialog), "ussd"); response = calls_ussd_respond_finish (ussd, result, &error); - if (error) - { - gtk_dialog_response (self->ussd_dialog, GTK_RESPONSE_CLOSE); - g_warning ("USSD Error: %s", error->message); - return; - } + if (error) { + gtk_dialog_response (self->ussd_dialog, GTK_RESPONSE_CLOSE); + g_warning ("USSD Error: %s", error->message); + return; + } - if (response && *response) - { - window_update_ussd_state (self, ussd); - gtk_label_set_text (self->ussd_label, response); - } + if (response && *response) { + window_update_ussd_state (self, ussd); + gtk_label_set_text (self->ussd_label, response); + } gtk_spinner_stop (self->ussd_spinner); gtk_stack_set_visible_child (self->ussd_stack, GTK_WIDGET (self->ussd_content)); @@ -263,20 +260,19 @@ main_window_ussd_send_cb (GObject *object, GAsyncResult *result, gpointer user_data) { - CallsMainWindow *self = user_data; - g_autofree char *response = NULL; g_autoptr (GError) error = NULL; + g_autofree char *response = NULL; + CallsMainWindow *self = user_data; CallsUssd *ussd; response = calls_new_call_box_send_ussd_finish (self->new_call, result, &error); ussd = g_task_get_task_data (G_TASK (result)); - if (error) - { - gtk_dialog_response (self->ussd_dialog, GTK_RESPONSE_CLOSE); - g_warning ("USSD Error: %s", error->message); - return; - } + if (error) { + gtk_dialog_response (self->ussd_dialog, GTK_RESPONSE_CLOSE); + g_warning ("USSD Error: %s", error->message); + return; + } g_object_set_data_full (G_OBJECT (self->ussd_dialog), "ussd", g_object_ref (ussd), g_object_unref); @@ -376,9 +372,9 @@ constructed (GObject *object) "recent", _("Recent")); gtk_container_child_set (main_stack, widget, - "icon-name", "document-open-recent-symbolic", - "position", 0, - NULL); + "icon-name", "document-open-recent-symbolic", + "position", 0, + NULL); gtk_widget_set_visible (widget, TRUE); gtk_stack_set_visible_child_name (self->main_stack, "recent"); @@ -501,22 +497,19 @@ void calls_main_window_dial (CallsMainWindow *self, const gchar *target) { - if (calls_number_is_ussd (target)) - { - gtk_widget_hide (GTK_WIDGET (self->ussd_cancel_button)); - gtk_widget_hide (GTK_WIDGET (self->ussd_reply_button)); - gtk_stack_set_visible_child (self->ussd_stack, GTK_WIDGET (self->ussd_spinner)); - gtk_spinner_start (self->ussd_spinner); + if (calls_number_is_ussd (target)) { + gtk_widget_hide (GTK_WIDGET (self->ussd_cancel_button)); + gtk_widget_hide (GTK_WIDGET (self->ussd_reply_button)); + gtk_stack_set_visible_child (self->ussd_stack, GTK_WIDGET (self->ussd_spinner)); + gtk_spinner_start (self->ussd_spinner); - calls_new_call_box_send_ussd_async (self->new_call, target, NULL, - main_window_ussd_send_cb, self); + calls_new_call_box_send_ussd_async (self->new_call, target, NULL, + main_window_ussd_send_cb, self); - gtk_window_present (GTK_WINDOW (self->ussd_dialog)); - } - else - { - calls_new_call_box_dial (self->new_call, target); - } + gtk_window_present (GTK_WINDOW (self->ussd_dialog)); + } else { + calls_new_call_box_dial (self->new_call, target); + } } void diff --git a/src/calls-main-window.h b/src/calls-main-window.h index b5f3085..58d2bb8 100644 --- a/src/calls-main-window.h +++ b/src/calls-main-window.h @@ -33,11 +33,11 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (CallsMainWindow, calls_main_window, CALLS, MAIN_WINDOW, HdyApplicationWindow); -CallsMainWindow *calls_main_window_new (GtkApplication *application, - GListModel *record_store); -void calls_main_window_dial (CallsMainWindow *self, - const gchar *target); -void calls_main_window_show_accounts_overview (CallsMainWindow *self); +CallsMainWindow *calls_main_window_new (GtkApplication *application, + GListModel *record_store); +void calls_main_window_dial (CallsMainWindow *self, + const gchar *target); +void calls_main_window_show_accounts_overview (CallsMainWindow *self); G_END_DECLS diff --git a/src/calls-manager.c b/src/calls-manager.c index dcdafb4..82e5b0c 100644 --- a/src/calls-manager.c +++ b/src/calls-manager.c @@ -59,25 +59,24 @@ static const char * const protocols[] = { "sips" }; -struct _CallsManager -{ - GObject parent_instance; +struct _CallsManager { + GObject parent_instance; - GHashTable *providers; + GHashTable *providers; - GListStore *origins; + GListStore *origins; /* origins_by_protocol maps protocol names to GListStore's of suitable origins */ - GHashTable *origins_by_protocol; + GHashTable *origins_by_protocol; /* dial_actions_by_protocol maps protocol names to GSimpleActions */ - GHashTable *dial_actions_by_protocol; + GHashTable *dial_actions_by_protocol; /* map CallsCall to CallsUiCallData */ - GHashTable *calls; + GHashTable *calls; CallsContactsProvider *contacts_provider; - CallsManagerFlags state_flags; - CallsSettings *settings; + CallsManagerFlags state_flags; + CallsSettings *settings; }; static void @@ -106,7 +105,7 @@ enum { PROVIDERS_CHANGED, SIGNAL_LAST_SIGNAL, }; -static guint signals [SIGNAL_LAST_SIGNAL]; +static guint signals[SIGNAL_LAST_SIGNAL]; static void @@ -224,7 +223,7 @@ on_message (CallsMessageSource *source, } calls_message_source_emit_message (CALLS_MESSAGE_SOURCE (self), - notification ? : message, + notification ?: message, message_type); } @@ -247,8 +246,7 @@ add_call (CallsManager *self, CallsCall *call, CallsOrigin *origin) } -struct CallsRemoveData -{ +struct CallsRemoveData { CallsManager *manager; CallsCall *call; }; @@ -358,6 +356,7 @@ static void add_origin (CallsManager *self, CallsOrigin *origin) { g_autofree const char *name = NULL; + g_assert (CALLS_IS_MANAGER (self)); g_assert (CALLS_IS_ORIGIN (origin)); @@ -379,12 +378,11 @@ add_origin (CallsManager *self, CallsOrigin *origin) g_signal_connect_swapped (origin, "call-added", G_CALLBACK (add_call), self); g_signal_connect_swapped (origin, "call-removed", G_CALLBACK (remove_call), self); - if (CALLS_IS_USSD (origin)) - { - g_signal_connect_swapped (origin, "ussd-added", G_CALLBACK (ussd_added_cb), self); - g_signal_connect_swapped (origin, "ussd-cancelled", G_CALLBACK (ussd_cancelled_cb), self); - g_signal_connect_swapped (origin, "ussd-state-changed", G_CALLBACK (ussd_state_changed_cb), self); - } + if (CALLS_IS_USSD (origin)) { + g_signal_connect_swapped (origin, "ussd-added", G_CALLBACK (ussd_added_cb), self); + g_signal_connect_swapped (origin, "ussd-cancelled", G_CALLBACK (ussd_cancelled_cb), self); + g_signal_connect_swapped (origin, "ussd-state-changed", G_CALLBACK (ussd_state_changed_cb), self); + } calls_origin_foreach_call (origin, (CallsOriginForeachCallFunc) add_call, self); } @@ -464,9 +462,10 @@ static void remove_provider (CallsManager *self, const char *name) { + g_autoptr (CallsProvider) provider = NULL; + GListModel *origins; guint n_items; - g_autoptr (CallsProvider) provider = NULL; g_assert (CALLS_IS_MANAGER (self)); g_assert (name); @@ -488,7 +487,7 @@ remove_provider (CallsManager *self, n_items = g_list_model_get_n_items (origins); for (guint i = 0; i < n_items; i++) { - g_autoptr(CallsOrigin) origin = NULL; + g_autoptr (CallsOrigin) origin = NULL; origin = g_list_model_get_item (origins, i); remove_origin (self, origin); @@ -568,7 +567,7 @@ origin_items_changed_cb (GListModel *model, g_warning ("Managed origins are not in sync anymore!"); } - skip_remove: +skip_remove: for (i = 0; i < added; i++) { g_debug ("before adding: %d", g_list_model_get_n_items (G_LIST_MODEL (self->origins))); @@ -830,7 +829,7 @@ calls_manager_get_default (void) if (instance == NULL) { instance = calls_manager_new (); - g_object_add_weak_pointer (G_OBJECT (instance), (gpointer *)&instance); + g_object_add_weak_pointer (G_OBJECT (instance), (gpointer *) &instance); } return instance; } @@ -980,12 +979,11 @@ calls_manager_has_active_call (CallsManager *self) calls = calls_manager_get_calls (self); - for (node = calls; node; node = node->next) - { - call = node->data; - if (calls_call_get_state (call) != CALLS_CALL_STATE_DISCONNECTED) - return TRUE; - } + for (node = calls; node; node = node->next) { + call = node->data; + if (calls_call_get_state (call) != CALLS_CALL_STATE_DISCONNECTED) + return TRUE; + } return FALSE; } diff --git a/src/calls-manager.h b/src/calls-manager.h index 9d1c986..1784112 100644 --- a/src/calls-manager.h +++ b/src/calls-manager.h @@ -39,11 +39,11 @@ G_DECLARE_FINAL_TYPE (CallsManager, calls_manager, CALLS, MANAGER, GObject) typedef enum /*< flags >*/ { - CALLS_MANAGER_FLAGS_UNKNOWN = 0, + CALLS_MANAGER_FLAGS_UNKNOWN = 0, CALLS_MANAGER_FLAGS_HAS_CELLULAR_PROVIDER = (1<<0), - CALLS_MANAGER_FLAGS_HAS_CELLULAR_MODEM = (1<<1), - CALLS_MANAGER_FLAGS_HAS_VOIP_PROVIDER = (1<<2), - CALLS_MANAGER_FLAGS_HAS_VOIP_ACCOUNT = (1<<3), + CALLS_MANAGER_FLAGS_HAS_CELLULAR_MODEM = (1<<1), + CALLS_MANAGER_FLAGS_HAS_VOIP_PROVIDER = (1<<2), + CALLS_MANAGER_FLAGS_HAS_VOIP_ACCOUNT = (1<<3), } CallsManagerFlags; @@ -66,7 +66,7 @@ GListModel *calls_manager_get_suitable_origins (CallsManager *sel const char *target); CallsOrigin *calls_manager_get_origin_by_id (CallsManager *self, const char *origin_id); -const gchar *calls_manager_get_contact_name (CallsCall *call); +const gchar *calls_manager_get_contact_name (CallsCall *call); gboolean calls_manager_has_active_call (CallsManager *self); void calls_manager_hang_up_all_calls (CallsManager *self); gboolean calls_manager_has_any_provider (CallsManager *self); diff --git a/src/calls-message-source.c b/src/calls-message-source.c index 875dfd0..260feac 100644 --- a/src/calls-message-source.c +++ b/src/calls-message-source.c @@ -40,7 +40,7 @@ enum { SIGNAL_MESSAGE, SIGNAL_LAST_SIGNAL, }; -static guint signals [SIGNAL_LAST_SIGNAL]; +static guint signals[SIGNAL_LAST_SIGNAL]; static void @@ -61,11 +61,11 @@ calls_message_source_default_init (CallsMessageSourceInterface *iface) */ signals[SIGNAL_MESSAGE] = g_signal_newv ("message", - G_TYPE_FROM_INTERFACE (iface), - G_SIGNAL_RUN_LAST, - NULL, NULL, NULL, NULL, - G_TYPE_NONE, - 2, arg_types); + G_TYPE_FROM_INTERFACE (iface), + G_SIGNAL_RUN_LAST, + NULL, NULL, NULL, NULL, + G_TYPE_NONE, + 2, arg_types); } /** diff --git a/src/calls-message-source.h b/src/calls-message-source.h index 93d0beb..5a0a51c 100644 --- a/src/calls-message-source.h +++ b/src/calls-message-source.h @@ -32,8 +32,7 @@ G_BEGIN_DECLS G_DECLARE_INTERFACE (CallsMessageSource, calls_message_source, CALLS, MESSAGE_SOURCE, GObject) -struct _CallsMessageSourceInterface -{ +struct _CallsMessageSourceInterface { GTypeInterface parent_iface; }; @@ -69,8 +68,8 @@ struct _CallsMessageSourceInterface #define CALLS_ERROR(obj,error) \ CALLS_EMIT_MESSAGE (obj, error->message, GTK_MESSAGE_ERROR) -void calls_message_source_emit_message (CallsMessageSource *self, - const char *message, - GtkMessageType message_type); +void calls_message_source_emit_message (CallsMessageSource *self, + const char *message, + GtkMessageType message_type); G_END_DECLS diff --git a/src/calls-network-watch.c b/src/calls-network-watch.c index 46216d4..576d32c 100644 --- a/src/calls-network-watch.c +++ b/src/calls-network-watch.c @@ -47,8 +47,8 @@ typedef struct { struct nlmsghdr n; - struct rtmsg r; - char buf[1024]; + struct rtmsg r; + char buf[1024]; } RequestData; enum { @@ -67,20 +67,20 @@ static guint signals[N_SIGNALS]; typedef struct _CallsNetworkWatch { - GObject parent; + GObject parent; RequestData *req; - int fd; + int fd; unsigned int seq; - char buf[1024]; /* buffer for responses to rtnetlink requests */ + char buf[1024]; /* buffer for responses to rtnetlink requests */ - guint timeout_id; + guint timeout_id; - gboolean repeated_warning; + gboolean repeated_warning; - char *ipv4; - char *ipv6; - char tmp_addr[INET6_ADDRSTRLEN]; + char *ipv4; + char *ipv6; + char tmp_addr[INET6_ADDRSTRLEN]; } CallsNetworkWatch; @@ -308,9 +308,9 @@ on_watch_network (CallsNetworkWatch *self) } static void -calls_network_watch_get_property (GObject *object, - guint property_id, - GValue *value, +calls_network_watch_get_property (GObject *object, + guint property_id, + GValue *value, GParamSpec *pspec) { CallsNetworkWatch *self = CALLS_NETWORK_WATCH (object); diff --git a/src/calls-network-watch.h b/src/calls-network-watch.h index 5ee4069..e45e6c0 100644 --- a/src/calls-network-watch.h +++ b/src/calls-network-watch.h @@ -32,8 +32,8 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (CallsNetworkWatch, calls_network_watch, CALLS, NETWORK_WATCH, GObject) -CallsNetworkWatch *calls_network_watch_get_default (void); -const char *calls_network_watch_get_ipv4 (CallsNetworkWatch *self); -const char *calls_network_watch_get_ipv6 (CallsNetworkWatch *self); +CallsNetworkWatch *calls_network_watch_get_default (void); +const char *calls_network_watch_get_ipv4 (CallsNetworkWatch *self); +const char *calls_network_watch_get_ipv6 (CallsNetworkWatch *self); G_END_DECLS diff --git a/src/calls-new-call-box.c b/src/calls-new-call-box.c index aac15a4..10a3270 100644 --- a/src/calls-new-call-box.c +++ b/src/calls-new-call-box.c @@ -40,23 +40,22 @@ enum { }; static GParamSpec *props[PROP_LAST_PROP]; -struct _CallsNewCallBox -{ - GtkBox parent_instance; +struct _CallsNewCallBox { + GtkBox parent_instance; - GtkListBox *origin_list_box; - HdyComboRow *origin_list; - GtkButton *backspace; - HdyKeypad *keypad; - GtkButton *dial; - GtkEntry *address_entry; - HdyActionRow *result; - GtkButton *dial_result; + GtkListBox *origin_list_box; + HdyComboRow *origin_list; + GtkButton *backspace; + HdyKeypad *keypad; + GtkButton *dial; + GtkEntry *address_entry; + HdyActionRow *result; + GtkButton *dial_result; GtkGestureLongPress *long_press_back_gesture; - GList *dial_queue; + GList *dial_queue; - gboolean numeric_input_only; + gboolean numeric_input_only; }; G_DEFINE_TYPE (CallsNewCallBox, calls_new_call_box, GTK_TYPE_BOX); @@ -85,6 +84,7 @@ get_origin (CallsNewCallBox *self, { CallsManager *manager = calls_manager_get_default (); CallsSettings *settings = calls_manager_get_settings (manager); + g_autoptr (CallsOrigin) origin = NULL; GListModel *model; gboolean auto_use_def_origin = @@ -158,6 +158,7 @@ static void long_press_back_cb (CallsNewCallBox *self) { GtkEntry *entry = hdy_keypad_get_entry (self->keypad); + gtk_editable_delete_text (GTK_EDITABLE (entry), 0, -1); } @@ -165,6 +166,7 @@ static void backspace_clicked_cb (CallsNewCallBox *self) { GtkEntry *entry = hdy_keypad_get_entry (self->keypad); + g_signal_emit_by_name (entry, "backspace", NULL); } @@ -174,7 +176,8 @@ ussd_send_cb (GObject *object, gpointer user_data) { CallsNewCallBox *self; - CallsUssd *ussd = (CallsUssd *)object; + CallsUssd *ussd = (CallsUssd *) object; + g_autoptr (GTask) task = user_data; GError *error = NULL; char *response; @@ -232,6 +235,7 @@ dial_queued_cb (gchar *target, CallsNewCallBox *self) { CallsOrigin *origin = NULL; + g_debug ("Try dialing queued target `%s'", target); origin = get_origin (self, @@ -239,9 +243,9 @@ dial_queued_cb (gchar *target, if (origin) { calls_origin_dial (origin, target); self->dial_queue = g_list_remove (self->dial_queue, target); - } - else + } else { g_debug ("No suitable origin found"); + } } @@ -414,11 +418,11 @@ calls_new_call_box_dial (CallsNewCallBox *self, } void -calls_new_call_box_send_ussd_async (CallsNewCallBox *self, - const char *target, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +calls_new_call_box_send_ussd_async (CallsNewCallBox *self, + const char *target, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { g_autoptr (CallsOrigin) origin = NULL; g_autoptr (GTask) task = NULL; @@ -454,7 +458,7 @@ calls_new_call_box_send_ussd_async (CallsNewCallBox *self, char * calls_new_call_box_send_ussd_finish (CallsNewCallBox *self, GAsyncResult *result, - GError **error) + GError **error) { g_return_val_if_fail (CALLS_IS_NEW_CALL_BOX (self), NULL); g_return_val_if_fail (G_IS_TASK (result), NULL); diff --git a/src/calls-new-call-box.h b/src/calls-new-call-box.h index ac1b530..adc8891 100644 --- a/src/calls-new-call-box.h +++ b/src/calls-new-call-box.h @@ -22,8 +22,7 @@ * */ -#ifndef CALLS_NEW_CALL_BOX_H__ -#define CALLS_NEW_CALL_BOX_H__ +#pragma once #include @@ -31,20 +30,18 @@ G_BEGIN_DECLS #define CALLS_TYPE_NEW_CALL_BOX (calls_new_call_box_get_type ()) -G_DECLARE_FINAL_TYPE (CallsNewCallBox, calls_new_call_box, CALLS, NEW_CALL_BOX, GtkBox); +G_DECLARE_FINAL_TYPE (CallsNewCallBox, calls_new_call_box, CALLS, NEW_CALL_BOX, GtkBox) -CallsNewCallBox * calls_new_call_box_new (void); -void calls_new_call_box_dial (CallsNewCallBox *self, - const gchar *target); -void calls_new_call_box_send_ussd_async (CallsNewCallBox *self, - const char *target, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -char *calls_new_call_box_send_ussd_finish (CallsNewCallBox *self, - GAsyncResult *result, - GError **error); +CallsNewCallBox *calls_new_call_box_new (void); +void calls_new_call_box_dial (CallsNewCallBox *self, + const gchar *target); +void calls_new_call_box_send_ussd_async (CallsNewCallBox *self, + const char *target, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +char *calls_new_call_box_send_ussd_finish (CallsNewCallBox *self, + GAsyncResult *result, + GError **error); G_END_DECLS - -#endif /* CALLS_NEW_CALL_BOX_H__ */ diff --git a/src/calls-notifier.c b/src/calls-notifier.c index 386f538..63276ba 100644 --- a/src/calls-notifier.c +++ b/src/calls-notifier.c @@ -35,11 +35,10 @@ #include #include -struct _CallsNotifier -{ - GObject parent_instance; +struct _CallsNotifier { + GObject parent_instance; - GListStore *unanswered; + GListStore *unanswered; }; G_DEFINE_TYPE (CallsNotifier, calls_notifier, G_TYPE_OBJECT); @@ -49,6 +48,7 @@ static void notify (CallsNotifier *self, CuiCall *call) { GApplication *app = g_application_get_default (); + g_autoptr (GNotification) notification = g_notification_new (_("Missed call")); g_autofree gchar *msg = NULL; g_autofree gchar *ref = NULL; @@ -58,13 +58,13 @@ notify (CallsNotifier *self, CuiCall *call) gboolean got_id; gboolean got_contact; -#if GLIB_CHECK_VERSION(2,70,0) +#if GLIB_CHECK_VERSION (2,70,0) g_notification_set_category (notification, "x-gnome.call.unanswered"); #endif /* TODO: We need to update the notification when the contact name changes We would need to resend the notification in this case, as changing the properties after having called g_application_send_notification() will have no effect. - */ + */ name = cui_call_get_display_name (call); id = cui_call_get_id (call); @@ -123,7 +123,7 @@ state_changed_cb (CallsNotifier *self, static void call_added_cb (CallsNotifier *self, CuiCall *call) { - g_list_store_append(self->unanswered, call); + g_list_store_append (self->unanswered, call); g_signal_connect_swapped (call, "state-changed", diff --git a/src/calls-origin.c b/src/calls-origin.c index ec850fc..aa00aca 100644 --- a/src/calls-origin.c +++ b/src/calls-origin.c @@ -40,7 +40,7 @@ enum { SIGNAL_CALL_REMOVED, SIGNAL_LAST_SIGNAL, }; -static guint signals [SIGNAL_LAST_SIGNAL]; +static guint signals[SIGNAL_LAST_SIGNAL]; static void calls_origin_default_init (CallsOriginInterface *iface) @@ -80,19 +80,19 @@ calls_origin_default_init (CallsOriginInterface *iface) signals[SIGNAL_CALL_ADDED] = g_signal_newv ("call-added", - G_TYPE_FROM_INTERFACE (iface), - G_SIGNAL_RUN_LAST, - NULL, NULL, NULL, NULL, - G_TYPE_NONE, - 1, arg_types); + G_TYPE_FROM_INTERFACE (iface), + G_SIGNAL_RUN_LAST, + NULL, NULL, NULL, NULL, + G_TYPE_NONE, + 1, arg_types); signals[SIGNAL_CALL_REMOVED] = g_signal_newv ("call-removed", - G_TYPE_FROM_INTERFACE (iface), - G_SIGNAL_RUN_LAST, - NULL, NULL, NULL, NULL, - G_TYPE_NONE, - 2, arg_types); + G_TYPE_FROM_INTERFACE (iface), + G_SIGNAL_RUN_LAST, + NULL, NULL, NULL, NULL, + G_TYPE_NONE, + 2, arg_types); } #define DEFINE_ORIGIN_GETTER(prop,rettype,errval) \ @@ -107,7 +107,7 @@ calls_origin_default_init (CallsOriginInterface *iface) * Returns (transfer full): A string containing the name. The string must be freed by * the caller. */ -DEFINE_ORIGIN_GETTER(name, char *, NULL); +DEFINE_ORIGIN_GETTER (name, char *, NULL); /** * calls_origin_get_id: @@ -118,7 +118,7 @@ DEFINE_ORIGIN_GETTER(name, char *, NULL); * Returns (transfer full): A string containing the id. The string must be freed by * the caller. */ -DEFINE_ORIGIN_GETTER(id, char *, NULL); +DEFINE_ORIGIN_GETTER (id, char *, NULL); /** * calls_origin_get_calls: @@ -129,7 +129,7 @@ DEFINE_ORIGIN_GETTER(id, char *, NULL); * Returns: (transfer container): A newly-allocated GList of objects implementing * #CallsCall or NULL if there was an error. */ -DEFINE_ORIGIN_GETTER(calls, GList *, NULL); +DEFINE_ORIGIN_GETTER (calls, GList *, NULL); /** * calls_origin_foreach_call: @@ -140,9 +140,9 @@ DEFINE_ORIGIN_GETTER(calls, GList *, NULL); * Iterate over all current calls from this origin **/ void -calls_origin_foreach_call(CallsOrigin *self, - CallsOriginForeachCallFunc callback, - gpointer param) +calls_origin_foreach_call (CallsOrigin *self, + CallsOriginForeachCallFunc callback, + gpointer param) { g_autoptr (GList) calls = NULL; GList *node; @@ -164,8 +164,8 @@ calls_origin_foreach_call(CallsOrigin *self, * there is an error, an appropriate #message signal will be emitted. */ void -calls_origin_dial(CallsOrigin *self, - const char *number) +calls_origin_dial (CallsOrigin *self, + const char *number) { CallsOriginInterface *iface; @@ -175,7 +175,7 @@ calls_origin_dial(CallsOrigin *self, iface = CALLS_ORIGIN_GET_IFACE (self); g_return_if_fail (iface->dial != NULL); - return iface->dial(self, number); + return iface->dial (self, number); } /** diff --git a/src/calls-origin.h b/src/calls-origin.h index e90246f..42549f0 100644 --- a/src/calls-origin.h +++ b/src/calls-origin.h @@ -22,8 +22,7 @@ * */ -#ifndef CALLS_ORIGIN_H__ -#define CALLS_ORIGIN_H__ +#pragma once #include "calls-call.h" #include "util.h" @@ -35,31 +34,29 @@ G_BEGIN_DECLS #define CALLS_TYPE_ORIGIN (calls_origin_get_type ()) -G_DECLARE_INTERFACE (CallsOrigin, calls_origin, CALLS, ORIGIN, GObject); +G_DECLARE_INTERFACE (CallsOrigin, calls_origin, CALLS, ORIGIN, GObject) -struct _CallsOriginInterface -{ +struct _CallsOriginInterface { GTypeInterface parent_iface; - void (*dial) (CallsOrigin *self, - const char *number); - gboolean (*supports_protocol) (CallsOrigin *self, - const char *protocol); + void (*dial) (CallsOrigin *self, + const char *number); + gboolean (*supports_protocol) (CallsOrigin *self, + const char *protocol); }; typedef void (*CallsOriginForeachCallFunc) (gpointer param, CallsCall* call, CallsOrigin* origin); -char * calls_origin_get_name (CallsOrigin *self); -char * calls_origin_get_id (CallsOrigin *self); -GList * calls_origin_get_calls (CallsOrigin *self); -void calls_origin_foreach_call (CallsOrigin *self, - CallsOriginForeachCallFunc callback, - gpointer param); -void calls_origin_dial (CallsOrigin *self, - const char *number); -gboolean calls_origin_supports_protocol (CallsOrigin *self, - const char *protocol); +char *calls_origin_get_name (CallsOrigin *self); +char *calls_origin_get_id (CallsOrigin *self); +GList *calls_origin_get_calls (CallsOrigin *self); +void calls_origin_foreach_call (CallsOrigin *self, + CallsOriginForeachCallFunc callback, + gpointer param); +void calls_origin_dial (CallsOrigin *self, + const char *number); +gboolean calls_origin_supports_protocol (CallsOrigin *self, + const char *protocol); G_END_DECLS -#endif /* CALLS_ORIGIN_H__ */ diff --git a/src/calls-provider.h b/src/calls-provider.h index 7c326d9..da1b5b5 100644 --- a/src/calls-provider.h +++ b/src/calls-provider.h @@ -40,26 +40,25 @@ G_BEGIN_DECLS G_DECLARE_DERIVABLE_TYPE (CallsProvider, calls_provider, CALLS, PROVIDER, GObject) -struct _CallsProviderClass -{ - GObjectClass parent_class; +struct _CallsProviderClass { + GObjectClass parent_class; - const char *(*get_name) (CallsProvider *self); - const char *(*get_status) (CallsProvider *self); - GListModel *(*get_origins) (CallsProvider *self); - const char * const *(*get_protocols) (CallsProvider *self); - gboolean (*is_modem) (CallsProvider *self); - gboolean (*is_operational) (CallsProvider *self); + const char *(*get_name) (CallsProvider *self); + const char *(*get_status) (CallsProvider *self); + GListModel *(*get_origins) (CallsProvider *self); + const char *const *(*get_protocols) (CallsProvider *self); + gboolean (*is_modem) (CallsProvider *self); + gboolean (*is_operational) (CallsProvider *self); }; -const char *calls_provider_get_name (CallsProvider *self); -const char *calls_provider_get_status (CallsProvider *self); -GListModel *calls_provider_get_origins (CallsProvider *self); -CallsProvider *calls_provider_load_plugin (const char *name); -void calls_provider_unload_plugin (const char *name); -const char * const *calls_provider_get_protocols (CallsProvider *self); -gboolean calls_provider_is_modem (CallsProvider *self); -gboolean calls_provider_is_operational (CallsProvider *self); +const char *calls_provider_get_name (CallsProvider *self); +const char *calls_provider_get_status (CallsProvider *self); +GListModel *calls_provider_get_origins (CallsProvider *self); +CallsProvider *calls_provider_load_plugin (const char *name); +void calls_provider_unload_plugin (const char *name); +const char *const *calls_provider_get_protocols (CallsProvider *self); +gboolean calls_provider_is_modem (CallsProvider *self); +gboolean calls_provider_is_operational (CallsProvider *self); G_END_DECLS diff --git a/src/calls-record-store.c b/src/calls-record-store.c index 7ee6382..a13c717 100644 --- a/src/calls-record-store.c +++ b/src/calls-record-store.c @@ -75,13 +75,12 @@ state_to_record_state (CuiCallState call_state) } -struct _CallsRecordStore -{ +struct _CallsRecordStore { GtkApplicationWindow parent_instance; - gchar *filename; - GomAdapter *adapter; - GomRepository *repository; + gchar *filename; + GomAdapter *adapter; + GomRepository *repository; }; G_DEFINE_TYPE (CallsRecordStore, calls_record_store, G_TYPE_LIST_STORE); @@ -124,8 +123,8 @@ delete_record_cb (GomResource *resource, static void -delete_call_cb (CallsCallRecord *record, - CallsRecordStore *self) +delete_call_cb (CallsCallRecord *record, + CallsRecordStore *self) { gom_resource_delete_async (GOM_RESOURCE (record), (GAsyncReadyCallback) delete_record_cb, @@ -138,8 +137,8 @@ load_calls_fetch_cb (GomResourceGroup *group, GAsyncResult *res, CallsRecordStore *self) { - gboolean ok; g_autoptr (GError) error = NULL; + gboolean ok; guint count, i; gpointer *records; @@ -191,8 +190,8 @@ load_calls_find_cb (GomRepository *repository, GAsyncResult *res, CallsRecordStore *self) { - GomResourceGroup *group; g_autoptr (GError) error = NULL; + GomResourceGroup *group; guint count; group = gom_repository_find_finish (repository, @@ -214,12 +213,11 @@ load_calls_find_cb (GomRepository *repository, g_debug ("Found %u call records in database `%s', fetching", count, self->filename); - gom_resource_group_fetch_async - (group, - 0, - count, - (GAsyncReadyCallback)load_calls_fetch_cb, - self); + gom_resource_group_fetch_async (group, + 0, + count, + (GAsyncReadyCallback) load_calls_fetch_cb, + self); } @@ -230,7 +228,7 @@ load_calls (CallsRecordStore *self) GomSorting *sorting; filter = gom_filter_new_is_not_null - (CALLS_TYPE_CALL_RECORD, "start"); + (CALLS_TYPE_CALL_RECORD, "start"); sorting = gom_sorting_new (CALLS_TYPE_CALL_RECORD, "start", @@ -243,7 +241,7 @@ load_calls (CallsRecordStore *self) CALLS_TYPE_CALL_RECORD, filter, sorting, - (GAsyncReadyCallback)load_calls_find_cb, + (GAsyncReadyCallback) load_calls_find_cb, self); g_object_unref (G_OBJECT (filter)); @@ -251,8 +249,8 @@ load_calls (CallsRecordStore *self) static void -set_up_repo_migrate_cb (GomRepository *repo, - GAsyncResult *res, +set_up_repo_migrate_cb (GomRepository *repo, + GAsyncResult *res, CallsRecordStore *self) { g_autoptr (GError) error = NULL; @@ -260,17 +258,17 @@ set_up_repo_migrate_cb (GomRepository *repo, ok = gom_repository_automatic_migrate_finish (repo, res, &error); 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); + 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); + 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); @@ -296,13 +294,13 @@ set_up_repo (CallsRecordStore *self) g_debug ("Attempting migration of call" " record database `%s'", self->filename); - types = g_list_append (types, (gpointer)CALLS_TYPE_CALL_RECORD); + types = g_list_append (types, (gpointer) CALLS_TYPE_CALL_RECORD); gom_repository_automatic_migrate_async (repo, - RECORD_STORE_VERSION, - types, - (GAsyncReadyCallback)set_up_repo_migrate_cb, - self); + RECORD_STORE_VERSION, + types, + (GAsyncReadyCallback) set_up_repo_migrate_cb, + self); self->repository = repo; } @@ -314,28 +312,27 @@ close_adapter (CallsRecordStore *self) g_autoptr (GError) error = NULL; gboolean ok; - if (!self->adapter) - { - return; - } + if (!self->adapter) { + return; + } - ok = gom_adapter_close_sync(self->adapter, &error); + ok = gom_adapter_close_sync (self->adapter, &error); 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); - } + 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); } static void -open_repo_adapter_open_cb (GomAdapter *adapter, - GAsyncResult *res, +open_repo_adapter_open_cb (GomAdapter *adapter, + GAsyncResult *res, CallsRecordStore *self) { g_autoptr (GError) error = NULL; @@ -384,18 +381,17 @@ open_repo (CallsRecordStore *self) self->adapter = gom_adapter_new (); gom_adapter_open_async (self->adapter, - uri, - (GAsyncReadyCallback)open_repo_adapter_open_cb, - self); + uri, + (GAsyncReadyCallback) open_repo_adapter_open_cb, + self); g_free (uri); } -struct CallsRecordCallData -{ +struct CallsRecordCallData { CallsRecordStore *self; - CallsUiCallData *call; + CallsUiCallData *call; }; @@ -405,6 +401,7 @@ record_call_save_cb (GomResource *resource, struct CallsRecordCallData *data) { GObject * const call_obj = G_OBJECT (data->call); + g_autoptr (GError) error = NULL; gboolean ok; @@ -469,7 +466,7 @@ record_call (CallsRecordStore *self, data->call = call; gom_resource_save_async (GOM_RESOURCE (record), - (GAsyncReadyCallback)record_call_save_cb, + (GAsyncReadyCallback) record_call_save_cb, data); } @@ -497,8 +494,8 @@ update_cb (GomResource *resource, static void -stamp_call (CallsCallRecord *record, - const gchar *stamp_name) +stamp_call (CallsCallRecord *record, + const gchar *stamp_name) { GObject *record_obj = G_OBJECT (record); GDateTime *stamp = NULL; @@ -519,7 +516,7 @@ stamp_call (CallsCallRecord *record, g_date_time_unref (stamp); gom_resource_save_async (GOM_RESOURCE (record), - (GAsyncReadyCallback)update_cb, + (GAsyncReadyCallback) update_cb, NULL); } @@ -603,7 +600,7 @@ call_added_cb (CallsRecordStore *self, g_assert (g_object_get_data (call_obj, "calls-call-start") == NULL); start = g_date_time_new_now_utc (); 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) { open_repo (self); diff --git a/src/calls-ringer.c b/src/calls-ringer.c index 7978601..40052c2 100644 --- a/src/calls-ringer.c +++ b/src/calls-ringer.c @@ -35,6 +35,7 @@ #define LIBFEEDBACK_USE_UNSTABLE_API #include + enum { PROP_0, PROP_IS_RINGING, @@ -53,18 +54,20 @@ typedef enum { struct _CallsRinger { - GObject parent_instance; + GObject parent_instance; - GList *calls; - LfbEvent *event; - GCancellable *cancel_ring; + GList *calls; + LfbEvent *event; + GCancellable *cancel_ring; CallsRingState state; - guint restart_id; - gboolean is_quiet; + guint restart_id; + gboolean is_quiet; }; -G_DEFINE_TYPE (CallsRinger, calls_ringer, G_TYPE_OBJECT); + +G_DEFINE_TYPE (CallsRinger, calls_ringer, G_TYPE_OBJECT) + static const char * ring_state_to_string (CallsRingState state) @@ -83,6 +86,7 @@ ring_state_to_string (CallsRingState state) } } + static void change_ring_state (CallsRinger *self, CallsRingState state) @@ -114,21 +118,22 @@ on_event_triggered (LfbEvent *event, GAsyncResult *res, CallsRinger *self) { - g_autoptr (GError) err = NULL; - g_return_if_fail (LFB_IS_EVENT (event)); - g_return_if_fail (CALLS_IS_RINGER (self)); + g_autoptr (GError) err = NULL; - g_debug ("%s", __func__); - if (lfb_event_trigger_feedback_finish (event, res, &err)) { - change_ring_state (self, CALLS_RING_STATE_PLAYING); - } else { - if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - g_warning ("Failed to trigger feedback for '%s': %s", - lfb_event_get_event (event), err->message); - change_ring_state (self, CALLS_RING_STATE_INACTIVE); - } + g_return_if_fail (LFB_IS_EVENT (event)); + g_return_if_fail (CALLS_IS_RINGER (self)); - g_object_unref (self); + g_debug ("%s", __func__); + if (lfb_event_trigger_feedback_finish (event, res, &err)) { + change_ring_state (self, CALLS_RING_STATE_PLAYING); + } else { + if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("Failed to trigger feedback for '%s': %s", + lfb_event_get_event (event), err->message); + change_ring_state (self, CALLS_RING_STATE_INACTIVE); + } + + g_object_unref (self); } @@ -170,22 +175,22 @@ on_event_feedback_ended (LfbEvent *event, GAsyncResult *res, CallsRinger *self) { - g_autoptr (GError) err = NULL; + g_autoptr (GError) err = NULL; - g_return_if_fail (LFB_IS_EVENT (event)); - g_return_if_fail (CALLS_IS_RINGER (self)); + g_return_if_fail (LFB_IS_EVENT (event)); + g_return_if_fail (CALLS_IS_RINGER (self)); - g_debug ("%s: state: %s", __func__, ring_state_to_string (self->state)); + g_debug ("%s: state: %s", __func__, ring_state_to_string (self->state)); - if (self->state == CALLS_RING_STATE_REQUEST_PLAY || - self->state == CALLS_RING_STATE_PLAYING) - g_warning ("Feedback ended although it should be playing"); + if (self->state == CALLS_RING_STATE_REQUEST_PLAY || + self->state == CALLS_RING_STATE_PLAYING) + g_warning ("Feedback ended although it should be playing"); - if (!lfb_event_end_feedback_finish (event, res, &err)) - g_warning ("Failed to end feedback for '%s': %s", - lfb_event_get_event (event), err->message); + if (!lfb_event_end_feedback_finish (event, res, &err)) + g_warning ("Failed to end feedback for '%s': %s", + lfb_event_get_event (event), err->message); - change_ring_state (self, CALLS_RING_STATE_INACTIVE); + change_ring_state (self, CALLS_RING_STATE_INACTIVE); } @@ -527,7 +532,7 @@ calls_ringer_get_is_ringing (CallsRinger *self) g_return_val_if_fail (CALLS_IS_RINGER (self), FALSE); return self->state == CALLS_RING_STATE_PLAYING || - self->state == CALLS_RING_STATE_REQUEST_STOP; + self->state == CALLS_RING_STATE_REQUEST_STOP; } /** diff --git a/src/calls-ringer.h b/src/calls-ringer.h index acd5fed..e15b476 100644 --- a/src/calls-ringer.h +++ b/src/calls-ringer.h @@ -22,8 +22,7 @@ * */ -#ifndef CALLS_RINGER_H__ -#define CALLS_RINGER_H__ +#pragma once #include @@ -31,13 +30,11 @@ G_BEGIN_DECLS #define CALLS_TYPE_RINGER (calls_ringer_get_type ()) -G_DECLARE_FINAL_TYPE (CallsRinger, calls_ringer, CALLS, RINGER, GObject); +G_DECLARE_FINAL_TYPE (CallsRinger, calls_ringer, CALLS, RINGER, GObject) -CallsRinger *calls_ringer_new (void); -gboolean calls_ringer_get_is_ringing (CallsRinger *self); -gboolean calls_ringer_get_ring_is_quiet (CallsRinger *self); +CallsRinger *calls_ringer_new (void); +gboolean calls_ringer_get_is_ringing (CallsRinger *self); +gboolean calls_ringer_get_ring_is_quiet (CallsRinger *self); G_END_DECLS - -#endif /* CALLS_RINGER_H__ */ diff --git a/src/calls-secret-store.h b/src/calls-secret-store.h index e709c0e..3608972 100644 --- a/src/calls-secret-store.h +++ b/src/calls-secret-store.h @@ -33,4 +33,3 @@ const SecretSchema *calls_secret_get_schema (void) G_GNUC_CONST; #define CALLS_SECRET_SCHEMA calls_secret_get_schema () - diff --git a/src/calls-settings.c b/src/calls-settings.c index 965f6f9..3cc7175 100644 --- a/src/calls-settings.c +++ b/src/calls-settings.c @@ -47,7 +47,7 @@ enum { static GParamSpec *props[PROP_LAST_PROP]; struct _CallsSettings { - GObject parent_instance; + GObject parent_instance; GSettings *settings; }; diff --git a/src/calls-settings.h b/src/calls-settings.h index de19376..2e90d68 100644 --- a/src/calls-settings.h +++ b/src/calls-settings.h @@ -33,18 +33,17 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (CallsSettings, calls_settings, CALLS, SETTINGS, GObject) CallsSettings *calls_settings_new (void); -gboolean calls_settings_get_use_default_origins (CallsSettings *self); -void calls_settings_set_use_default_origins (CallsSettings *self, - gboolean enable); -char *calls_settings_get_country_code (CallsSettings *self); -void calls_settings_set_country_code (CallsSettings *self, - const char *country_code); -char **calls_settings_get_autoload_plugins (CallsSettings *self); -void calls_settings_set_autoload_plugins (CallsSettings *self, - const char * const *plugins); -char **calls_settings_get_preferred_audio_codecs (CallsSettings *self); -void calls_settings_set_preferred_audio_codecs (CallsSettings *self, - const char * const *codecs); +gboolean calls_settings_get_use_default_origins (CallsSettings *self); +void calls_settings_set_use_default_origins (CallsSettings *self, + gboolean enable); +char *calls_settings_get_country_code (CallsSettings *self); +void calls_settings_set_country_code (CallsSettings *self, + const char *country_code); +char **calls_settings_get_autoload_plugins (CallsSettings *self); +void calls_settings_set_autoload_plugins (CallsSettings *self, + const char * const *plugins); +char **calls_settings_get_preferred_audio_codecs (CallsSettings *self); +void calls_settings_set_preferred_audio_codecs (CallsSettings *self, + const char * const *codecs); G_END_DECLS - diff --git a/src/calls-ui-call-data.c b/src/calls-ui-call-data.c index b6ae061..e3d21e7 100644 --- a/src/calls-ui-call-data.c +++ b/src/calls-ui-call-data.c @@ -55,23 +55,22 @@ enum { static GParamSpec *props[PROP_LAST_PROP]; static guint signals[N_SIGNALS]; -struct _CallsUiCallData -{ - GObject parent_instance; +struct _CallsUiCallData { + GObject parent_instance; - CallsCall *call; + CallsCall *call; CallsBestMatch *best_match; - GTimer *timer; - gdouble active_time; - guint timer_id; + GTimer *timer; + gdouble active_time; + guint timer_id; - CuiCallState state; - char *origin_id; - gboolean silenced; + CuiCallState state; + char *origin_id; + gboolean silenced; - gboolean ui_active; /* whether a UI should be shown (or the ringer should ring) */ - guint set_active_id; + gboolean ui_active; /* whether a UI should be shown (or the ringer should ring) */ + guint set_active_id; }; static void calls_ui_call_data_cui_call_interface_init (CuiCallInterface *iface); @@ -282,6 +281,7 @@ static void on_notify_state (CallsUiCallData *self) { CallsCallState state; + g_assert (CALLS_IS_UI_CALL_DATA (self)); state = calls_call_get_state (self->call); @@ -725,6 +725,7 @@ char * calls_ui_call_data_dup_origin_name (CallsUiCallData *self) { CallsOrigin *origin; + g_return_val_if_fail (CALLS_IS_UI_CALL_DATA (self), NULL); origin = calls_manager_get_origin_by_id (calls_manager_get_default (), diff --git a/src/calls-ui-call-data.h b/src/calls-ui-call-data.h index 4e1d5ad..2e269fc 100644 --- a/src/calls-ui-call-data.h +++ b/src/calls-ui-call-data.h @@ -37,13 +37,13 @@ G_DECLARE_FINAL_TYPE (CallsUiCallData, calls_ui_call_data, CALLS, UI_CALL_DATA, CallsUiCallData *calls_ui_call_data_new (CallsCall *call, const char *origin_id); -void calls_ui_call_data_silence_ring (CallsUiCallData *self); -gboolean calls_ui_call_data_get_silenced (CallsUiCallData *self); -gboolean calls_ui_call_data_get_ui_active (CallsUiCallData *self); -CallsCallType calls_ui_call_data_get_call_type (CallsUiCallData *self); -const char *calls_ui_call_data_get_origin_id (CallsUiCallData *self); -char *calls_ui_call_data_dup_origin_name (CallsUiCallData *self); +void calls_ui_call_data_silence_ring (CallsUiCallData *self); +gboolean calls_ui_call_data_get_silenced (CallsUiCallData *self); +gboolean calls_ui_call_data_get_ui_active (CallsUiCallData *self); +CallsCallType calls_ui_call_data_get_call_type (CallsUiCallData *self); +const char *calls_ui_call_data_get_origin_id (CallsUiCallData *self); +char *calls_ui_call_data_dup_origin_name (CallsUiCallData *self); -CuiCallState calls_call_state_to_cui_call_state (CallsCallState state); +CuiCallState calls_call_state_to_cui_call_state (CallsCallState state); G_END_DECLS diff --git a/src/calls-ussd.c b/src/calls-ussd.c index d043cf1..fb678c7 100644 --- a/src/calls-ussd.c +++ b/src/calls-ussd.c @@ -42,7 +42,7 @@ enum { N_SIGNALS }; -static guint signals [N_SIGNALS]; +static guint signals[N_SIGNALS]; static void calls_ussd_default_init (CallsUssdInterface *iface) @@ -107,11 +107,11 @@ calls_ussd_get_state (CallsUssd *self) } void -calls_ussd_initiate_async (CallsUssd *self, - const char *command, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +calls_ussd_initiate_async (CallsUssd *self, + const char *command, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { CallsUssdInterface *iface; @@ -126,9 +126,9 @@ calls_ussd_initiate_async (CallsUssd *self, } char * -calls_ussd_initiate_finish (CallsUssd *self, - GAsyncResult *result, - GError **error) +calls_ussd_initiate_finish (CallsUssd *self, + GAsyncResult *result, + GError **error) { CallsUssdInterface *iface; @@ -143,11 +143,11 @@ calls_ussd_initiate_finish (CallsUssd *self, } void -calls_ussd_respond_async (CallsUssd *self, - const char *response, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +calls_ussd_respond_async (CallsUssd *self, + const char *response, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { CallsUssdInterface *iface; @@ -162,9 +162,9 @@ calls_ussd_respond_async (CallsUssd *self, } char * -calls_ussd_respond_finish (CallsUssd *self, - GAsyncResult *result, - GError **error) +calls_ussd_respond_finish (CallsUssd *self, + GAsyncResult *result, + GError **error) { CallsUssdInterface *iface; @@ -179,10 +179,10 @@ calls_ussd_respond_finish (CallsUssd *self, } void -calls_ussd_cancel_async (CallsUssd *self, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +calls_ussd_cancel_async (CallsUssd *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { CallsUssdInterface *iface; @@ -196,9 +196,9 @@ calls_ussd_cancel_async (CallsUssd *self, } gboolean -calls_ussd_cancel_finish (CallsUssd *self, - GAsyncResult *result, - GError **error) +calls_ussd_cancel_finish (CallsUssd *self, + GAsyncResult *result, + GError **error) { CallsUssdInterface *iface; diff --git a/src/calls-ussd.h b/src/calls-ussd.h index 9fe3d47..498ee34 100644 --- a/src/calls-ussd.h +++ b/src/calls-ussd.h @@ -40,61 +40,60 @@ typedef enum CALLS_USSD_STATE_USER_RESPONSE } CallsUssdState; -struct _CallsUssdInterface -{ +struct _CallsUssdInterface { GTypeInterface parent_iface; - CallsUssdState (*get_state) (CallsUssd *self); - void (*initiate_async) (CallsUssd *self, - const char *command, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - char *(*initiate_finish) (CallsUssd *self, - GAsyncResult *result, - GError **error); - void (*respond_async) (CallsUssd *self, - const char *response, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - char *(*respond_finish) (CallsUssd *self, - GAsyncResult *result, - GError **error); - void (*cancel_async) (CallsUssd *self, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - gboolean (*cancel_finish) (CallsUssd *self, - GAsyncResult *result, - GError **error); + CallsUssdState (*get_state) (CallsUssd *self); + void (*initiate_async) (CallsUssd *self, + const char *command, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + char *(*initiate_finish) (CallsUssd *self, + GAsyncResult *result, + GError **error); + void (*respond_async) (CallsUssd *self, + const char *response, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + char *(*respond_finish) (CallsUssd *self, + GAsyncResult *result, + GError **error); + void (*cancel_async) (CallsUssd *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (*cancel_finish) (CallsUssd *self, + GAsyncResult *result, + GError **error); }; -CallsUssdState calls_ussd_get_state (CallsUssd *self); -void calls_ussd_initiate_async (CallsUssd *self, - const char *command, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -char *calls_ussd_initiate_finish (CallsUssd *self, - GAsyncResult *result, - GError **error); -void calls_ussd_respond_async (CallsUssd *self, - const char *response, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -char *calls_ussd_respond_finish (CallsUssd *self, - GAsyncResult *result, - GError **error); -void calls_ussd_cancel_async (CallsUssd *self, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -gboolean calls_ussd_cancel_finish (CallsUssd *self, - GAsyncResult *result, - GError **error); +CallsUssdState calls_ussd_get_state (CallsUssd *self); +void calls_ussd_initiate_async (CallsUssd *self, + const char *command, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +char *calls_ussd_initiate_finish (CallsUssd *self, + GAsyncResult *result, + GError **error); +void calls_ussd_respond_async (CallsUssd *self, + const char *response, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +char *calls_ussd_respond_finish (CallsUssd *self, + GAsyncResult *result, + GError **error); +void calls_ussd_cancel_async (CallsUssd *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean calls_ussd_cancel_finish (CallsUssd *self, + GAsyncResult *result, + GError **error); G_END_DECLS diff --git a/src/util.c b/src/util.c index c356e15..db81c91 100644 --- a/src/util.c +++ b/src/util.c @@ -28,19 +28,17 @@ void calls_object_unref (gpointer object) { - if (object) - { - g_object_unref (object); - } + if (object) { + g_object_unref (object); + } } -typedef struct -{ - gpointer needle; - guint needle_column; +typedef struct { + gpointer needle; + guint needle_column; GtkTreeIter *iter; - gboolean found; + gboolean found; } ListStoreFindData; static gboolean @@ -55,20 +53,19 @@ list_store_find_foreach_cb (GtkTreeModel *model, gtk_tree_model_get (model, iter, find_data->needle_column, &value, -1); - if (value == find_data->needle) - { - *find_data->iter = *iter; - return (find_data->found = TRUE); - } + if (value == find_data->needle) { + *find_data->iter = *iter; + return (find_data->found = TRUE); + } return FALSE; } gboolean calls_list_store_find (GtkListStore *store, - gpointer needle, - gint needle_column, - GtkTreeIter *iter) + gpointer needle, + gint needle_column, + GtkTreeIter *iter) { ListStoreFindData find_data = { needle, needle_column, iter, FALSE }; diff --git a/src/util.h b/src/util.h index 4aa2d0a..abad8be 100644 --- a/src/util.h +++ b/src/util.h @@ -111,40 +111,39 @@ G_BEGIN_DECLS /** If the GObject object is non-NULL, unref it */ -void calls_object_unref (gpointer object); +void calls_object_unref (gpointer object); /** Find a particular pointer value in a GtkListStore */ gboolean -calls_list_store_find (GtkListStore *store, - gpointer needle, - gint needle_column, - GtkTreeIter *iter); + calls_list_store_find (GtkListStore *store, + gpointer needle, + gint needle_column, + GtkTreeIter *iter); /** Append a single character to a GtkEntry's contents */ void -calls_entry_append (GtkEntry *entry, - gchar character); + calls_entry_append (GtkEntry *entry, + gchar character); -gboolean calls_date_time_is_same_day (GDateTime *a, - GDateTime *b); -gboolean calls_date_time_is_yesterday (GDateTime *now, - GDateTime *t); -gboolean calls_date_time_is_same_year (GDateTime *a, - GDateTime *b); -gboolean calls_number_is_ussd (const char *number); +gboolean calls_date_time_is_same_day (GDateTime *a, + GDateTime *b); +gboolean calls_date_time_is_yesterday (GDateTime *now, + GDateTime *t); +gboolean calls_date_time_is_same_year (GDateTime *a, + GDateTime *b); +gboolean calls_number_is_ussd (const char *number); -gboolean calls_find_in_store (GListModel *list, - gpointer item, - guint *position); +gboolean calls_find_in_store (GListModel *list, + gpointer item, + guint *position); -const char* get_protocol_from_address (const char *target); -const char* get_protocol_from_address_with_fallback (const char *target); +const char *get_protocol_from_address (const char *target); +const char *get_protocol_from_address_with_fallback (const char *target); -gboolean dtmf_tone_key_is_valid (char key); -const char *get_call_icon_symbolic_name (gboolean inbound, - gboolean missed); +gboolean dtmf_tone_key_is_valid (char key); +const char *get_call_icon_symbolic_name (gboolean inbound, + gboolean missed); G_END_DECLS -