From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis <frederic.danis@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH 3/4] netreg: add support for signal strength get and watch APIs
Date: Fri, 18 Feb 2011 17:34:07 +0100 [thread overview]
Message-ID: <1298046848-24622-4-git-send-email-frederic.danis@linux.intel.com> (raw)
In-Reply-To: <1298046848-24622-1-git-send-email-frederic.danis@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 3973 bytes --]
---
src/network.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/ofono.h | 10 +++++++++
2 files changed, 71 insertions(+), 0 deletions(-)
diff --git a/src/network.c b/src/network.c
index c059906..4a0e984 100644
--- a/src/network.c
+++ b/src/network.c
@@ -79,6 +79,7 @@ struct ofono_netreg {
GKeyFile *settings;
char *imsi;
struct ofono_watchlist *status_watches;
+ struct ofono_watchlist *strength_watches;
const struct ofono_netreg_driver *driver;
void *driver_data;
struct ofono_atom *atom;
@@ -1159,6 +1160,51 @@ static void notify_status_watches(struct ofono_netreg *netreg)
}
}
+unsigned int __ofono_netreg_add_strength_watch(struct ofono_netreg *netreg,
+ ofono_netreg_strength_notify_cb_t notify,
+ void *data, ofono_destroy_func destroy)
+{
+ struct ofono_watchlist_item *item;
+
+ DBG("%p", netreg);
+
+ if (netreg == NULL)
+ return 0;
+
+ if (notify == NULL)
+ return 0;
+
+ item = g_new0(struct ofono_watchlist_item, 1);
+
+ item->notify = notify;
+ item->destroy = destroy;
+ item->notify_data = data;
+
+ return __ofono_watchlist_add_item(netreg->strength_watches, item);
+}
+
+gboolean __ofono_netreg_remove_strength_watch(struct ofono_netreg *netreg,
+ unsigned int id)
+{
+ DBG("%p", netreg);
+
+ return __ofono_watchlist_remove_item(netreg->strength_watches, id);
+}
+
+static void notify_strength_watches(struct ofono_netreg *netreg)
+{
+ struct ofono_watchlist_item *item;
+ GSList *l;
+ ofono_netreg_strength_notify_cb_t notify;
+
+ for (l = netreg->strength_watches->items; l; l = l->next) {
+ item = l->data;
+ notify = item->notify;
+
+ notify(netreg->signal_strength, item->notify_data);
+ }
+}
+
static void reset_available(struct network_operator_data *old,
const struct ofono_network_operator *new)
{
@@ -1400,6 +1446,8 @@ void ofono_netreg_strength_notify(struct ofono_netreg *netreg, int strength)
OFONO_NETWORK_REGISTRATION_INTERFACE,
"Strength", DBUS_TYPE_BYTE,
&strength);
+
+ notify_strength_watches(netreg);
}
}
@@ -1599,6 +1647,14 @@ int ofono_netreg_get_status(struct ofono_netreg *netreg)
return netreg->status;
}
+int ofono_netreg_get_strength(struct ofono_netreg *netreg)
+{
+ if (netreg == NULL)
+ return -1;
+
+ return netreg->signal_strength;
+}
+
int ofono_netreg_get_technology(struct ofono_netreg *netreg)
{
if (netreg == NULL)
@@ -1659,6 +1715,9 @@ static void netreg_unregister(struct ofono_atom *atom)
__ofono_watchlist_free(netreg->status_watches);
netreg->status_watches = NULL;
+ __ofono_watchlist_free(netreg->strength_watches);
+ netreg->strength_watches = NULL;
+
for (l = netreg->operator_list; l; l = l->next) {
struct network_operator_data *opd = l->data;
@@ -1857,6 +1916,8 @@ void ofono_netreg_register(struct ofono_netreg *netreg)
netreg->status_watches = __ofono_watchlist_new(g_free);
+ netreg->strength_watches = __ofono_watchlist_new(g_free);
+
ofono_modem_add_interface(modem, OFONO_NETWORK_REGISTRATION_INTERFACE);
if (netreg->driver->registration_status != NULL)
diff --git a/src/ofono.h b/src/ofono.h
index 14dcd18..f82f447 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -404,6 +404,16 @@ unsigned int __ofono_netreg_add_status_watch(struct ofono_netreg *netreg,
gboolean __ofono_netreg_remove_status_watch(struct ofono_netreg *netreg,
unsigned int id);
+typedef void (*ofono_netreg_strength_notify_cb_t)(int signal_strength,
+ void *data);
+
+unsigned int __ofono_netreg_add_strength_watch(struct ofono_netreg *netreg,
+ ofono_netreg_strength_notify_cb_t cb,
+ void *data, ofono_destroy_func destroy);
+
+gboolean __ofono_netreg_remove_strength_watch(struct ofono_netreg *netreg,
+ unsigned int id);
+
void __ofono_netreg_set_base_station_name(struct ofono_netreg *netreg,
const char *name);
--
1.7.1
next prev parent reply other threads:[~2011-02-18 16:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-18 16:34 [PATCH 0/4] bluetooth: add CIND and CIEV support for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-02-18 16:34 ` [PATCH 1/4] emulator: add network info support for HFP =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-02-18 16:34 ` [PATCH 2/4] netreg: add get signal strength API =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-02-18 16:34 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis [this message]
2011-02-18 16:34 ` [PATCH 4/4] emulator: add network signal support for HFP =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1298046848-24622-4-git-send-email-frederic.danis@linux.intel.com \
--to=frederic.danis@linux.intel.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox