diff options
author | Denis Kenzior <denkenz@gmail.com> | 2009-09-11 21:35:31 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2009-09-11 21:35:31 -0500 |
commit | 6f86a8d0a6c7999a1b191b61ce5f7e5d15a80e83 (patch) | |
tree | 89a4789e7bc943b6791c033036d343cdf908f641 /src | |
parent | d54f588355b196a18802c516a30c0698c1acbf01 (diff) | |
download | ofono-6f86a8d0a6c7999a1b191b61ce5f7e5d15a80e83.tar.bz2 |
Add utility for setting the netreg base station
Diffstat (limited to 'src')
-rw-r--r-- | src/network.c | 37 | ||||
-rw-r--r-- | src/ofono.h | 3 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/network.c b/src/network.c index feadf72b..3431fba3 100644 --- a/src/network.c +++ b/src/network.c @@ -64,6 +64,7 @@ struct ofono_netreg { int location; int cellid; int technology; + char *base_station; struct network_operator_data *current_operator; GSList *operator_list; struct ofono_network_registration_ops *ops; @@ -714,6 +715,10 @@ static DBusMessage *network_get_properties(DBusConnection *conn, &strength); } + if (netreg->base_station) + ofono_dbus_dict_append(&dict, "BaseStation", DBUS_TYPE_STRING, + &netreg->base_station); + dbus_message_iter_close_container(&iter, &dict); return reply; @@ -873,6 +878,32 @@ static void set_registration_technology(struct ofono_netreg *netreg, int tech) &tech_str); } +void __ofono_netreg_set_base_station_name(struct ofono_netreg *netreg, + const char *name) +{ + DBusConnection *conn = ofono_dbus_get_connection(); + const char *path = __ofono_atom_get_path(netreg->atom); + const char *base_station = name ? name : ""; + + if (netreg->base_station) + g_free(netreg->base_station); + + if (name == NULL) { + netreg->base_station = NULL; + + /* We just got unregistered, set name to NULL + * but don't emit signal */ + if (netreg->current_operator == NULL) + return; + } else + netreg->base_station = g_strdup(name); + + ofono_dbus_signal_property_changed(conn, path, + NETWORK_REGISTRATION_INTERFACE, + "BaseStation", DBUS_TYPE_STRING, + &base_station); +} + unsigned int __ofono_netreg_add_status_watch(struct ofono_netreg *netreg, ofono_netreg_status_notify_cb_t notify, void *data, ofono_destroy_func destroy) @@ -952,6 +983,7 @@ void ofono_netreg_status_notify(struct ofono_netreg *netreg, int status, error.error = 0; current_operator_callback(&error, NULL, netreg); + __ofono_netreg_set_base_station_name(netreg, NULL); netreg->signal_strength = -1; } @@ -1470,6 +1502,11 @@ static void netreg_unregister(struct ofono_atom *atom) g_slist_free(netreg->operator_list); netreg->operator_list = NULL; + if (netreg->base_station) { + g_free(netreg->base_station); + netreg->base_station = NULL; + } + g_dbus_unregister_interface(conn, path, NETWORK_REGISTRATION_INTERFACE); ofono_modem_remove_interface(modem, NETWORK_REGISTRATION_INTERFACE); diff --git a/src/ofono.h b/src/ofono.h index e9dde2fb..06599895 100644 --- a/src/ofono.h +++ b/src/ofono.h @@ -212,6 +212,9 @@ unsigned int __ofono_netreg_add_status_watch(struct ofono_netreg *netreg, gboolean __ofono_netreg_remove_status_watch(struct ofono_netreg *netreg, unsigned int id); +void __ofono_netreg_set_base_station_name(struct ofono_netreg *netreg, + const char *name); + #include <ofono/history.h> void __ofono_history_probe_drivers(struct ofono_modem *modem); |