diff options
-rw-r--r-- | modem/ofono.c | 272 | ||||
-rw-r--r-- | modem/ofono.h | 76 |
2 files changed, 180 insertions, 168 deletions
diff --git a/modem/ofono.c b/modem/ofono.c index 0d986b9..30aa30f 100644 --- a/modem/ofono.c +++ b/modem/ofono.c @@ -27,153 +27,162 @@ #include "modem/ofono.h" #include "modem/request-private.h" #include "modem/errors.h" +#include "modem/service.h" /* ---------------------------------------------------------------------- */ GType -modem_type_dbus_dict(void) +modem_type_dbus_dict (void) { static gsize type = 0; - if (g_once_init_enter(&type)) { - GType t = dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE); - g_once_init_leave(&type, t); - } + if (g_once_init_enter (&type)) + { + GType t = dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE); + g_once_init_leave (&type, t); + } return type; } GType -modem_type_dbus_ao(void) +modem_type_dbus_ao (void) { static gsize type = 0; - if (g_once_init_enter(&type)) { - GType t = dbus_g_type_get_collection("GPtrArray", DBUS_TYPE_G_OBJECT_PATH); - g_once_init_leave(&type, t); - } + if (g_once_init_enter (&type)) + { + GType t = dbus_g_type_get_collection ("GPtrArray", + DBUS_TYPE_G_OBJECT_PATH); + g_once_init_leave (&type, t); + } return type; } GType -modem_type_dbus_desc_array(void) +modem_type_dbus_desc_array (void) { static gsize type = 0; - if (g_once_init_enter(&type)) { - GType stype = dbus_g_type_get_struct("GValueArray", - DBUS_TYPE_G_OBJECT_PATH, - MODEM_TYPE_DBUS_DICT, - G_TYPE_INVALID); - GType t = dbus_g_type_get_collection("GPtrArray", stype); - g_once_init_leave(&type, t); - } + if (g_once_init_enter (&type)) + { + GType stype = dbus_g_type_get_struct ("GValueArray", + DBUS_TYPE_G_OBJECT_PATH, + MODEM_TYPE_DBUS_DICT, + G_TYPE_INVALID); + GType t = dbus_g_type_get_collection ("GPtrArray", stype); + g_once_init_leave (&type, t); + } return type; } GQuark -modem_ofono_iface_quark_sim(void) +modem_ofono_iface_quark_sim (void) { static gsize quark = 0; - if (g_once_init_enter(&quark)) { - GQuark q = g_quark_from_static_string(OFONO_IFACE_SIM); - g_once_init_leave(&quark, q); - } + if (g_once_init_enter (&quark)) + { + GQuark q = g_quark_from_static_string (OFONO_IFACE_SIM); + g_once_init_leave (&quark, q); + } return quark; } GQuark -modem_ofono_iface_quark_call_manager(void) +modem_ofono_iface_quark_call_manager (void) { static gsize quark = 0; - if (g_once_init_enter(&quark)) { - GQuark q = g_quark_from_static_string(OFONO_IFACE_CALL_MANAGER); - g_once_init_leave(&quark, q); - } + if (g_once_init_enter (&quark)) + { + GQuark q = g_quark_from_static_string (OFONO_IFACE_CALL_MANAGER); + g_once_init_leave (&quark, q); + } return quark; } GQuark -modem_ofono_iface_quark_sms(void) +modem_ofono_iface_quark_sms (void) { static gsize quark = 0; - if (g_once_init_enter(&quark)) { - GQuark q = g_quark_from_static_string(OFONO_IFACE_SMS); - g_once_init_leave(&quark, q); - } + if (g_once_init_enter (&quark)) + { + GQuark q = g_quark_from_static_string (OFONO_IFACE_SMS); + g_once_init_leave (&quark, q); + } return quark; } void -modem_ofono_init_quarks(void) +modem_ofono_init_quarks (void) { - modem_ofono_iface_quark_sim(); - modem_ofono_iface_quark_call_manager(); - modem_ofono_iface_quark_sms(); + modem_ofono_iface_quark_sim (); + modem_ofono_iface_quark_call_manager (); + modem_ofono_iface_quark_sms (); } static DBusGConnection * -modem_ofono_get_bus(void) +modem_ofono_get_bus (void) { static DBusGConnection *bus = NULL; if (G_UNLIKELY (bus == NULL)) - bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); + bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL); return bus; } static void -reply_to_set_property(DBusGProxy *proxy, - DBusGProxyCall *call, - gpointer _request) +reply_to_set_property (DBusGProxy *proxy, + DBusGProxyCall *call, + gpointer _request) { ModemRequest *request = _request; - gpointer object = modem_request_object(request); - ModemOfonoVoidReply *callback = modem_request_callback(request); - gpointer user_data = modem_request_user_data(request); + gpointer object = modem_request_object (request); + ModemOfonoVoidReply *callback = modem_request_callback (request); + gpointer user_data = modem_request_user_data (request); GError *error = NULL; - if (!dbus_g_proxy_end_call(proxy, call, &error, - G_TYPE_INVALID)) { - modem_error_fix(&error); - } + if (!dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID)) + { + modem_error_fix (&error); + } if (callback) - callback(object, request, error, user_data); + callback (object, request, error, user_data); if (error) g_error_free (error); } static void -reply_to_get_properties(DBusGProxy *proxy, - DBusGProxyCall *call, - gpointer _request) +reply_to_get_properties (DBusGProxy *proxy, + DBusGProxyCall *call, + gpointer _request) { GHashTable *properties = NULL; ModemRequest *request = _request; - gpointer object = modem_request_object(request); - ModemOfonoPropsReply *callback = modem_request_callback(request); - gpointer user_data = modem_request_user_data(request); + gpointer object = modem_request_object (request); + ModemOfonoPropsReply *callback = modem_request_callback (request); + gpointer user_data = modem_request_user_data (request); GError *error = NULL; - if (!dbus_g_proxy_end_call(proxy, call, &error, - MODEM_TYPE_DBUS_DICT, &properties, - G_TYPE_INVALID)) { - modem_error_fix(&error); - } + if (!dbus_g_proxy_end_call (proxy, call, &error, + MODEM_TYPE_DBUS_DICT, &properties, + G_TYPE_INVALID)) + { + modem_error_fix (&error); + } if (callback) - callback(object, request, properties, error, user_data); + callback (object, request, properties, error, user_data); if (error) g_error_free (error); @@ -182,24 +191,24 @@ reply_to_get_properties(DBusGProxy *proxy, } static void -reply_to_get_descs(DBusGProxy *proxy, - DBusGProxyCall *call, - gpointer _request) +reply_to_get_descs (DBusGProxy *proxy, + DBusGProxyCall *call, + gpointer _request) { GPtrArray *calls = NULL; ModemRequest *request = _request; - gpointer object = modem_request_object(request); - ModemOfonoGetDescsReply *callback = modem_request_callback(request); - gpointer user_data = modem_request_user_data(request); + gpointer object = modem_request_object (request); + ModemOfonoGetDescsReply *callback = modem_request_callback (request); + gpointer user_data = modem_request_user_data (request); GError *error = NULL; - if (!dbus_g_proxy_end_call(proxy, call, &error, + if (!dbus_g_proxy_end_call (proxy, call, &error, MODEM_TYPE_DBUS_DESC_ARRAY, &calls, G_TYPE_INVALID)) - modem_error_fix(&error); + modem_error_fix (&error); if (callback) - callback(object, request, calls, error, user_data); + callback (object, request, calls, error, user_data); if (error) g_error_free (error); @@ -207,95 +216,102 @@ reply_to_get_descs(DBusGProxy *proxy, g_ptr_array_free (calls, TRUE); } -ModemRequest *modem_ofono_request_descs(gpointer object, - DBusGProxy *proxy, char const *method, - ModemOfonoGetDescsReply *callback, gpointer userdata) +ModemRequest * +modem_ofono_request_descs (gpointer object, + DBusGProxy *proxy, + char const *method, + ModemOfonoGetDescsReply *callback, + gpointer userdata) { - return modem_request_begin(object, + return modem_request_begin (object, proxy, method, reply_to_get_descs, - G_CALLBACK(callback), userdata, + G_CALLBACK (callback), userdata, G_TYPE_INVALID); } void -modem_ofono_debug_desc(char const *name, - char const *object_path, - GHashTable *properties) +modem_ofono_debug_desc (char const *name, + char const *object_path, + GHashTable *properties) { char *key; GValue *value; GHashTableIter iter[1]; - DEBUG ("%s(\"%s\")", name, object_path); + DEBUG ("%s (\"%s\")", name, object_path); - for (g_hash_table_iter_init(iter, properties); - g_hash_table_iter_next(iter, (gpointer)&key, (gpointer)&value);) { - char *s = g_strdup_value_contents(value); - DEBUG("%s = %s", key, s); - g_free(s); - } + for (g_hash_table_iter_init (iter, properties); + g_hash_table_iter_next (iter, (gpointer)&key, (gpointer)&value);) + { + char *s = g_strdup_value_contents (value); + DEBUG ("%s = %s", key, s); + g_free (s); + } } /* ---------------------------------------------------------------------- */ DBusGProxy * -modem_ofono_proxy(char const *object_path, char const *interface) +modem_ofono_proxy (char const *object_path, char const *interface) { - return dbus_g_proxy_new_for_name(modem_ofono_get_bus(), - OFONO_BUS_NAME, - object_path, - interface); + return dbus_g_proxy_new_for_name (modem_ofono_get_bus (), + OFONO_BUS_NAME, + object_path, + interface); } ModemRequest * -modem_ofono_proxy_set_property(DBusGProxy *proxy, - char const *property, GValue *value, - ModemOfonoVoidReply *callback, - gpointer object, gpointer user_data) +modem_ofono_proxy_set_property (DBusGProxy *proxy, + char const *property, GValue *value, + ModemOfonoVoidReply *callback, + gpointer object, gpointer user_data) { - return modem_request_begin(object, proxy, - "SetProperty", - reply_to_set_property, - G_CALLBACK(callback), user_data, - G_TYPE_STRING, property, - G_TYPE_VALUE, value, - G_TYPE_INVALID); + return modem_request_begin (object, proxy, + "SetProperty", + reply_to_set_property, + G_CALLBACK (callback), user_data, + G_TYPE_STRING, property, + G_TYPE_VALUE, value, + G_TYPE_INVALID); } ModemRequest * -modem_ofono_proxy_request_properties(DBusGProxy *proxy, - ModemOfonoPropsReply *callback, - gpointer object, - gpointer user_data) +modem_ofono_proxy_request_properties (DBusGProxy *proxy, + ModemOfonoPropsReply *callback, + gpointer object, + gpointer user_data) { - return modem_request_begin(object, proxy, - "GetProperties", - reply_to_get_properties, - G_CALLBACK(callback), user_data, - G_TYPE_INVALID); + return modem_request_begin (object, proxy, + "GetProperties", + reply_to_get_properties, + G_CALLBACK (callback), user_data, + G_TYPE_INVALID); } void -modem_ofono_proxy_connect_to_property_changed(DBusGProxy *proxy, - ModemOfonoPropChangedCb callback, - gpointer user_data) +modem_ofono_proxy_connect_to_property_changed (DBusGProxy *proxy, + ModemOfonoPropChangedCb callback, + gpointer user_data) { - if (callback) { - dbus_g_proxy_add_signal(proxy, "PropertyChanged", - G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(proxy, "PropertyChanged", - G_CALLBACK(callback), user_data, NULL); - } + if (callback) + { + dbus_g_proxy_add_signal (proxy, "PropertyChanged", + G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (proxy, "PropertyChanged", + G_CALLBACK (callback), user_data, NULL); + } } void -modem_ofono_proxy_disconnect_from_property_changed( - DBusGProxy *proxy, ModemOfonoPropChangedCb callback, - gpointer user_data) +modem_ofono_proxy_disconnect_from_property_changed ( + DBusGProxy *proxy, + ModemOfonoPropChangedCb callback, + gpointer user_data) { - if (callback) { - dbus_g_proxy_disconnect_signal(proxy, "PropertyChanged", - G_CALLBACK(callback), user_data); - } + if (callback) + { + dbus_g_proxy_disconnect_signal (proxy, "PropertyChanged", + G_CALLBACK (callback), user_data); + } } diff --git a/modem/ofono.h b/modem/ofono.h index 21f7e1c..9580ed9 100644 --- a/modem/ofono.h +++ b/modem/ofono.h @@ -45,73 +45,69 @@ G_BEGIN_DECLS #define OFONO_IFACE_SMS "org.ofono.MessageManager" /* Quarks for mandatory modem interfaces */ -#define OFONO_IFACE_QUARK_SIM modem_ofono_iface_quark_sim() -#define OFONO_IFACE_QUARK_CALL_MANAGER modem_ofono_iface_quark_call_manager() -#define OFONO_IFACE_QUARK_SMS modem_ofono_iface_quark_sms() +#define OFONO_IFACE_QUARK_SIM modem_ofono_iface_quark_sim () +#define OFONO_IFACE_QUARK_CALL_MANAGER modem_ofono_iface_quark_call_manager () +#define OFONO_IFACE_QUARK_SMS modem_ofono_iface_quark_sms () /* D-Bus type a{sv} for Ofono properties */ -#define MODEM_TYPE_DBUS_DICT modem_type_dbus_dict() -#define MODEM_TYPE_ARRAY_OF_PATHS modem_type_dbus_ao() +#define MODEM_TYPE_DBUS_DICT modem_type_dbus_dict () +#define MODEM_TYPE_ARRAY_OF_PATHS modem_type_dbus_ao () /* D-Bus type a{oa{sv}} for oFono path-property list */ -#define MODEM_TYPE_DBUS_DESC_ARRAY modem_type_dbus_desc_array() +#define MODEM_TYPE_DBUS_DESC_ARRAY modem_type_dbus_desc_array () /* ---------------------------------------------------------------------- */ -typedef void ModemOfonoPropChangedCb( - DBusGProxy *proxy, char const *property, - GValue const *value, gpointer user_data); +typedef void ModemOfonoPropChangedCb (DBusGProxy *proxy, + char const *property, + GValue const *value, gpointer user_data); -typedef void ModemOfonoPropsReply( - gpointer object, - ModemRequest *request, GHashTable *properties, - GError const *error, gpointer user_data); +typedef void ModemOfonoPropsReply (gpointer object, + ModemRequest *request, GHashTable *properties, + GError const *error, gpointer user_data); -typedef void ModemOfonoVoidReply( - gpointer object, - ModemRequest *request, - GError const *error, gpointer user_data); +typedef void ModemOfonoVoidReply (gpointer object, + ModemRequest *request, + GError const *error, gpointer user_data); -typedef void ModemOfonoGetDescsReply(gpointer object, +typedef void ModemOfonoGetDescsReply (gpointer object, ModemRequest *request, GPtrArray *descs, GError const *error, gpointer user_data); /* ---------------------------------------------------------------------- */ -GType modem_type_dbus_dict(void); -GType modem_type_dbus_ao(void); -GType modem_type_dbus_desc_array(void); -GQuark modem_ofono_iface_quark_sim(void); -GQuark modem_ofono_iface_quark_call_manager(void); -GQuark modem_ofono_iface_quark_sms(void); -void modem_ofono_init_quarks(void); +GType modem_type_dbus_dict (void); +GType modem_type_dbus_ao (void); +GType modem_type_dbus_desc_array (void); +GQuark modem_ofono_iface_quark_sim (void); +GQuark modem_ofono_iface_quark_call_manager (void); +GQuark modem_ofono_iface_quark_sms (void); +void modem_ofono_init_quarks (void); -DBusGProxy *modem_ofono_proxy( - char const *object_path, char const *interface); +DBusGProxy *modem_ofono_proxy (char const *object_path, char const *interface); -ModemRequest *modem_ofono_proxy_set_property( - DBusGProxy *proxy, +ModemRequest *modem_ofono_proxy_set_property (DBusGProxy *proxy, char const *property, GValue *value, ModemOfonoVoidReply *callback, gpointer object, gpointer user_data); -ModemRequest *modem_ofono_proxy_request_properties( - DBusGProxy *proxy, ModemOfonoPropsReply *callback, - gpointer object, gpointer user_data); +ModemRequest *modem_ofono_proxy_request_properties (DBusGProxy *proxy, + ModemOfonoPropsReply *callback, + gpointer object, gpointer user_data); -void modem_ofono_proxy_connect_to_property_changed( - DBusGProxy *proxy, ModemOfonoPropChangedCb callback, - gpointer user_data); +void modem_ofono_proxy_connect_to_property_changed (DBusGProxy *proxy, + ModemOfonoPropChangedCb callback, + gpointer user_data); -void modem_ofono_proxy_disconnect_from_property_changed( - DBusGProxy *proxy, ModemOfonoPropChangedCb callback, - gpointer user_data); +void modem_ofono_proxy_disconnect_from_property_changed (DBusGProxy *proxy, + ModemOfonoPropChangedCb callback, + gpointer user_data); -ModemRequest *modem_ofono_request_descs(gpointer object, +ModemRequest *modem_ofono_request_descs (gpointer object, DBusGProxy *proxy, char const *method, ModemOfonoGetDescsReply *callback, gpointer user_dat); -void modem_ofono_debug_desc(char const *name, +void modem_ofono_debug_desc (char const *name, char const *object_path, GHashTable *properties); |