Uncrustify sources

Ran `find src plugins -iname '*.[c|h]' -print0 | xargs -0 uncrustify --no-backup`
with some minimal manual intervention.
This commit is contained in:
Evangelos Ribeiro Tzaras
2022-04-24 12:24:55 +02:00
parent 8daa502de5
commit 7ac862155b
83 changed files with 1744 additions and 1869 deletions

View File

@@ -29,8 +29,7 @@
#include <glib/gi18n.h>
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);
}

View File

@@ -31,11 +31,10 @@
#include <glib-object.h>
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);

View File

@@ -22,8 +22,7 @@
*
*/
#ifndef CALLS_DUMMY_ORIGIN_H__
#define CALLS_DUMMY_ORIGIN_H__
#pragma once
#include <glib-object.h>
@@ -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__ */

View File

@@ -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,

View File

@@ -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

View File

@@ -33,11 +33,10 @@
#include <glib/gi18n.h>
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);
}

View File

@@ -34,26 +34,25 @@
#include <glib/gi18n.h>
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;
}

View File

@@ -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);

View File

@@ -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

View File

@@ -16,10 +16,9 @@
#include <glib.h>
struct mcc_list
{
struct mcc_list {
guint mcc;
char code[3];
char code[3];
};
/*

View File

@@ -31,11 +31,10 @@
#include <glib/gi18n.h>
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);
}

View File

@@ -32,16 +32,15 @@
#include <glib/gi18n.h>
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);

View File

@@ -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");

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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);

View File

@@ -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

View File

@@ -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);

View File

@@ -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

View File

@@ -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...");

View File

@@ -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",

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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;
}

View File

@@ -28,17 +28,15 @@
#include <sofia-sip/nua.h>
#include <glib-object.h>
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);

View File

@@ -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;

View File

@@ -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);