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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user