* [PATCH 0/6] Clear the ground for AG implementation
@ 2013-04-10 19:24 Paulo Borges
2013-04-10 19:24 ` [PATCH 1/6] include: Add ofono_emulator_set_removed_cb() Paulo Borges
` (6 more replies)
0 siblings, 7 replies; 19+ messages in thread
From: Paulo Borges @ 2013-04-10 19:24 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1073 bytes --]
This patch series clear the ground for AG card implementation.
[PATCH 1/6] and [PATCH 2/6]
Implements a mechanism to notify when a emulator is removed and freed.
This mechanism will be required in [PATCH 6/6].
[PATCH 3/6]
HFP 1.6 adds a new feature Codec Negotiation. This commit changes HF
feature check interval.
[PATCH 4/6], [PATCH 5/6] and [PATCH 6/6]
Stores and removes emulators from a hash. This hash is important to
recover the correct emulator and remove it in RequestDisconnection().
Paulo Borges (6):
include: Add ofono_emulator_set_removed_cb()
emulator: Add removed notification mechanism
emulator: Change feature check to attend HFP 1.6
hfp_ag_bluez5: Create a hash to store emulators
hfp_ag_bluez5: Store emulator when connect
hfp_ag_bluez5: Remove emulator when disconnect
include/emulator.h | 5 ++++
plugins/hfp_ag_bluez5.c | 61 ++++++++++++++++++++++++++++++++++++++++++++---
src/emulator.c | 28 +++++++++++++++++++++-
3 files changed, 90 insertions(+), 4 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 1/6] include: Add ofono_emulator_set_removed_cb()
2013-04-10 19:24 [PATCH 0/6] Clear the ground for AG implementation Paulo Borges
@ 2013-04-10 19:24 ` Paulo Borges
2013-04-10 19:24 ` [PATCH 2/6] emulator: Add removed notification mechanism Paulo Borges
` (5 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Paulo Borges @ 2013-04-10 19:24 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 994 bytes --]
---
include/emulator.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/emulator.h b/include/emulator.h
index 5cd894b..3e8b6d9 100644
--- a/include/emulator.h
+++ b/include/emulator.h
@@ -67,6 +67,8 @@ typedef void (*ofono_emulator_request_cb_t)(struct ofono_emulator *em,
struct ofono_emulator_request *req,
void *data);
+typedef void (*ofono_emulator_removed_cb_t)(void *data);
+
struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
enum ofono_emulator_type type);
@@ -74,6 +76,9 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd);
void ofono_emulator_remove(struct ofono_emulator *em);
+void ofono_emulator_set_removed_cb(struct ofono_emulator* em,
+ ofono_emulator_removed_cb_t cb, void *data);
+
void ofono_emulator_send_final(struct ofono_emulator *em,
const struct ofono_error *final);
void ofono_emulator_send_unsolicited(struct ofono_emulator *em,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 2/6] emulator: Add removed notification mechanism
2013-04-10 19:24 [PATCH 0/6] Clear the ground for AG implementation Paulo Borges
2013-04-10 19:24 ` [PATCH 1/6] include: Add ofono_emulator_set_removed_cb() Paulo Borges
@ 2013-04-10 19:24 ` Paulo Borges
2013-04-11 21:50 ` Paulo Borges
2013-04-10 19:24 ` [PATCH 3/6] emulator: Change feature check to attend HFP 1.6 Paulo Borges
` (4 subsequent siblings)
6 siblings, 1 reply; 19+ messages in thread
From: Paulo Borges @ 2013-04-10 19:24 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1394 bytes --]
---
src/emulator.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/emulator.c b/src/emulator.c
index 0817b5d..4a748f0 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -37,6 +37,11 @@
#define RING_TIMEOUT 3
+struct removed_cb {
+ ofono_emulator_removed_cb_t cb;
+ void *data;
+};
+
struct ofono_emulator {
struct ofono_atom *atom;
enum ofono_emulator_type type;
@@ -53,6 +58,7 @@ struct ofono_emulator {
gboolean clip;
gboolean ccwa;
int pns_id;
+ struct removed_cb *removed_cb;
};
struct indicator {
@@ -952,6 +958,11 @@ static void emulator_remove(struct ofono_atom *atom)
DBG("atom: %p", atom);
+ if (em->removed_cb) {
+ em->removed_cb->cb(em->removed_cb->data);
+ g_free(em->removed_cb);
+ }
+
g_free(em);
}
@@ -995,6 +1006,21 @@ void ofono_emulator_remove(struct ofono_emulator *em)
__ofono_atom_free(em->atom);
}
+void ofono_emulator_set_removed_cb(struct ofono_emulator* em,
+ ofono_emulator_removed_cb_t cb, void *data)
+{
+ struct removed_cb *removed_cb;
+
+ if (em == NULL)
+ return;
+
+ removed_cb = g_try_new0(struct removed_cb, 1);
+ removed_cb->cb = cb;
+ removed_cb->data = data;
+
+ em->removed_cb = removed_cb;
+}
+
void ofono_emulator_send_final(struct ofono_emulator *em,
const struct ofono_error *final)
{
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 3/6] emulator: Change feature check to attend HFP 1.6
2013-04-10 19:24 [PATCH 0/6] Clear the ground for AG implementation Paulo Borges
2013-04-10 19:24 ` [PATCH 1/6] include: Add ofono_emulator_set_removed_cb() Paulo Borges
2013-04-10 19:24 ` [PATCH 2/6] emulator: Add removed notification mechanism Paulo Borges
@ 2013-04-10 19:24 ` Paulo Borges
2013-04-10 19:24 ` [PATCH 4/6] hfp_ag_bluez5: Create a hash to store emulators Paulo Borges
` (3 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Paulo Borges @ 2013-04-10 19:24 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 545 bytes --]
In HFP 1.6 there is a new feature: Codec Negociation.
---
src/emulator.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/emulator.c b/src/emulator.c
index 4a748f0..f34d4d3 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -459,7 +459,7 @@ static void brsf_cb(GAtServer *server, GAtServerRequestType type,
if (g_at_result_iter_next_number(&iter, &val) == FALSE)
goto fail;
- if (val < 0 || val > 127)
+ if (val < 0 || val > 255)
goto fail;
em->r_features = val;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 4/6] hfp_ag_bluez5: Create a hash to store emulators
2013-04-10 19:24 [PATCH 0/6] Clear the ground for AG implementation Paulo Borges
` (2 preceding siblings ...)
2013-04-10 19:24 ` [PATCH 3/6] emulator: Change feature check to attend HFP 1.6 Paulo Borges
@ 2013-04-10 19:24 ` Paulo Borges
2013-04-10 19:24 ` [PATCH 5/6] hfp_ag_bluez5: Store emulator when connect Paulo Borges
` (2 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Paulo Borges @ 2013-04-10 19:24 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1419 bytes --]
---
plugins/hfp_ag_bluez5.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/plugins/hfp_ag_bluez5.c b/plugins/hfp_ag_bluez5.c
index 64ea8ca..b15b64f 100644
--- a/plugins/hfp_ag_bluez5.c
+++ b/plugins/hfp_ag_bluez5.c
@@ -51,6 +51,19 @@
static guint modemwatch_id;
static GList *modems;
static GHashTable *sim_hash = NULL;
+static GHashTable *emulator_hash = NULL;
+
+static gboolean emulator_remove(gpointer key, gpointer value,
+ gpointer user_data)
+{
+ struct ofono_emulator *em = value;
+
+ DBG("%p", em);
+
+ ofono_emulator_remove(em);
+
+ return TRUE;
+}
static DBusMessage *profile_new_connection(DBusConnection *conn,
DBusMessage *msg, void *data)
@@ -254,6 +267,9 @@ static int hfp_ag_init(void)
modemwatch_id = __ofono_modemwatch_add(modem_watch, NULL, NULL);
__ofono_modem_foreach(call_modemwatch, NULL);
+ emulator_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
+ NULL);
+
return 0;
}
@@ -265,6 +281,9 @@ static void hfp_ag_exit(void)
g_dbus_unregister_interface(conn, HFP_AG_EXT_PROFILE_PATH,
BLUEZ_PROFILE_INTERFACE);
+ g_hash_table_foreach_remove(emulator_hash, emulator_remove, NULL);
+ g_hash_table_destroy(emulator_hash);
+
g_list_free(modems);
g_hash_table_foreach_remove(sim_hash, sim_watch_remove, NULL);
g_hash_table_destroy(sim_hash);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 5/6] hfp_ag_bluez5: Store emulator when connect
2013-04-10 19:24 [PATCH 0/6] Clear the ground for AG implementation Paulo Borges
` (3 preceding siblings ...)
2013-04-10 19:24 ` [PATCH 4/6] hfp_ag_bluez5: Create a hash to store emulators Paulo Borges
@ 2013-04-10 19:24 ` Paulo Borges
2013-04-10 19:24 ` [PATCH 6/6] hfp_ag_bluez5: Remove emulator when disconnect Paulo Borges
2013-04-12 20:40 ` [PATCH 0/7] Clear the ground for AG card implementation Paulo Borges
6 siblings, 0 replies; 19+ messages in thread
From: Paulo Borges @ 2013-04-10 19:24 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 492 bytes --]
---
plugins/hfp_ag_bluez5.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/plugins/hfp_ag_bluez5.c b/plugins/hfp_ag_bluez5.c
index b15b64f..2046e7d 100644
--- a/plugins/hfp_ag_bluez5.c
+++ b/plugins/hfp_ag_bluez5.c
@@ -116,6 +116,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
}
ofono_emulator_register(em, fd);
+ g_hash_table_insert(emulator_hash, g_strdup(device), em);
return dbus_message_new_method_return(msg);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 6/6] hfp_ag_bluez5: Remove emulator when disconnect
2013-04-10 19:24 [PATCH 0/6] Clear the ground for AG implementation Paulo Borges
` (4 preceding siblings ...)
2013-04-10 19:24 ` [PATCH 5/6] hfp_ag_bluez5: Store emulator when connect Paulo Borges
@ 2013-04-10 19:24 ` Paulo Borges
2013-04-12 20:40 ` [PATCH 0/7] Clear the ground for AG card implementation Paulo Borges
6 siblings, 0 replies; 19+ messages in thread
From: Paulo Borges @ 2013-04-10 19:24 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2283 bytes --]
---
plugins/hfp_ag_bluez5.c | 43 +++++++++++++++++++++++++++++++++++++++----
1 file changed, 39 insertions(+), 4 deletions(-)
diff --git a/plugins/hfp_ag_bluez5.c b/plugins/hfp_ag_bluez5.c
index 2046e7d..0301fdb 100644
--- a/plugins/hfp_ag_bluez5.c
+++ b/plugins/hfp_ag_bluez5.c
@@ -65,11 +65,21 @@ static gboolean emulator_remove(gpointer key, gpointer value,
return TRUE;
}
+static void emulator_removed_cb(void *user_data)
+{
+ char *device = user_data;
+
+ DBG("%s", device);
+
+ g_hash_table_remove(emulator_hash, device);
+}
+
static DBusMessage *profile_new_connection(DBusConnection *conn,
DBusMessage *msg, void *data)
{
DBusMessageIter entry;
const char *device;
+ char *key;
int fd;
struct ofono_emulator *em;
struct ofono_modem *modem;
@@ -115,8 +125,11 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
"Not enough resources");
}
+ key = g_strdup(device);
+
ofono_emulator_register(em, fd);
- g_hash_table_insert(emulator_hash, g_strdup(device), em);
+ ofono_emulator_set_removed_cb(em, emulator_removed_cb, key);
+ g_hash_table_insert(emulator_hash, key, em);
return dbus_message_new_method_return(msg);
@@ -148,11 +161,33 @@ static DBusMessage *profile_cancel(DBusConnection *conn,
static DBusMessage *profile_disconnection(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
+ DBusMessageIter iter;
+ const char *device;
+ struct ofono_emulator *em;
+
DBG("Profile handler RequestDisconnection");
- return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
- ".NotImplemented",
- "Implementation not provided");
+ if (!dbus_message_iter_init(msg, &iter))
+ goto invalid;
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_OBJECT_PATH)
+ goto invalid;
+
+ dbus_message_iter_get_basic(&iter, &device);
+
+ DBG("%s", device);
+
+ em = g_hash_table_lookup(emulator_hash, device);
+ if (em == NULL)
+ goto invalid;
+
+ ofono_emulator_remove(em);
+
+ return dbus_message_new_method_return(msg);
+
+invalid:
+ return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE ".Rejected",
+ "Invalid arguments in method call");
}
static const GDBusMethodTable profile_methods[] = {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH 2/6] emulator: Add removed notification mechanism
2013-04-10 19:24 ` [PATCH 2/6] emulator: Add removed notification mechanism Paulo Borges
@ 2013-04-11 21:50 ` Paulo Borges
0 siblings, 0 replies; 19+ messages in thread
From: Paulo Borges @ 2013-04-11 21:50 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2005 bytes --]
On Wed, Apr 10, 2013 at 4:24 PM, Paulo Borges <paulo.borges@openbossa.org>wrote:
> ---
> src/emulator.c | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/src/emulator.c b/src/emulator.c
> index 0817b5d..4a748f0 100644
> --- a/src/emulator.c
> +++ b/src/emulator.c
> @@ -37,6 +37,11 @@
>
> #define RING_TIMEOUT 3
>
> +struct removed_cb {
> + ofono_emulator_removed_cb_t cb;
> + void *data;
> +};
> +
> struct ofono_emulator {
> struct ofono_atom *atom;
> enum ofono_emulator_type type;
> @@ -53,6 +58,7 @@ struct ofono_emulator {
> gboolean clip;
> gboolean ccwa;
> int pns_id;
> + struct removed_cb *removed_cb;
> };
>
> struct indicator {
> @@ -952,6 +958,11 @@ static void emulator_remove(struct ofono_atom *atom)
>
> DBG("atom: %p", atom);
>
> + if (em->removed_cb) {
> + em->removed_cb->cb(em->removed_cb->data);
> + g_free(em->removed_cb);
> + }
> +
> g_free(em);
> }
>
> @@ -995,6 +1006,21 @@ void ofono_emulator_remove(struct ofono_emulator *em)
> __ofono_atom_free(em->atom);
> }
>
> +void ofono_emulator_set_removed_cb(struct ofono_emulator* em,
> + ofono_emulator_removed_cb_t cb, void *data)
> +{
> + struct removed_cb *removed_cb;
> +
> + if (em == NULL)
> + return;
> +
> + removed_cb = g_try_new0(struct removed_cb, 1);
> + removed_cb->cb = cb;
> + removed_cb->data = data;
> +
> + em->removed_cb = removed_cb;
> +}
> +
> void ofono_emulator_send_final(struct ofono_emulator *em,
> const struct ofono_error *final)
> {
> --
> 1.7.9.5
>
>
Hi,
please ignore this patch. I'm now using cb_data from atutil.h to handle the
callback in a new series. I will send it again soon, but all other patchs
from this series remains the same.
Paulo
[-- Attachment #2: attachment.html --]
[-- Type: text/html, Size: 2483 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 0/7] Clear the ground for AG card implementation
2013-04-10 19:24 [PATCH 0/6] Clear the ground for AG implementation Paulo Borges
` (5 preceding siblings ...)
2013-04-10 19:24 ` [PATCH 6/6] hfp_ag_bluez5: Remove emulator when disconnect Paulo Borges
@ 2013-04-12 20:40 ` Paulo Borges
2013-04-12 20:40 ` [PATCH 1/7] emulator: Copy callback mechanism from atutil.h Paulo Borges
` (6 more replies)
6 siblings, 7 replies; 19+ messages in thread
From: Paulo Borges @ 2013-04-12 20:40 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1147 bytes --]
Changelog v2:
* Now uses cb_data mechanism from atutil.h
--
[PATCH 2/7] and [PATCH 3/7]
Implements a mechanism to notify when a emulator is removed and freed.
This mechanism will be required in [PATCH 6/6].
[PATCH 4/7]
HFP 1.6 adds a new feature Codec Negotiation. This commit changes HF
feature check interval.
[PATCH 5/7], [PATCH 6/7] and [PATCH 7/7]
Stores and removes emulators from the hash. This hash is important to
recover the correct emulator and remove it in RequestDisconnection()
Paulo Borges (7):
emulator: Copy callback mechanism from atutil.h
include: Add ofono_emulator_set_removed_cb()
emulator: Add removed notification mechanism
emulator: Change feature check to attend HFP 1.6
hfp_ag_bluez5: Create a hash to store emulators
hfp_ag_bluez5: Store emulator when connect
hfp_ag_bluez5: Remove emulator when disconnect
include/emulator.h | 5 ++++
plugins/hfp_ag_bluez5.c | 61 ++++++++++++++++++++++++++++++++++++++++++++---
src/emulator.c | 52 +++++++++++++++++++++++++++++++++++++++-
3 files changed, 114 insertions(+), 4 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 1/7] emulator: Copy callback mechanism from atutil.h
2013-04-12 20:40 ` [PATCH 0/7] Clear the ground for AG card implementation Paulo Borges
@ 2013-04-12 20:40 ` Paulo Borges
2013-04-12 20:41 ` [PATCH 2/7] include: Add ofono_emulator_set_removed_cb() Paulo Borges
` (5 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Paulo Borges @ 2013-04-12 20:40 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1338 bytes --]
atutil.h needs GAtChat and GAtResult definitions and we do not have
these definitions inside emulator.c.
---
src/emulator.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/src/emulator.c b/src/emulator.c
index 0817b5d..6071615 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -37,6 +37,28 @@
#define RING_TIMEOUT 3
+#define CALLBACK_WITH_FAILURE(cb, args...) \
+ do { \
+ struct ofono_error cb_e; \
+ cb_e.type = OFONO_ERROR_TYPE_FAILURE; \
+ cb_e.error = 0; \
+ \
+ cb(&cb_e, ##args); \
+ } while (0) \
+
+#define CALLBACK_WITH_SUCCESS(cb, args...) \
+ do { \
+ struct ofono_error e; \
+ e.type = OFONO_ERROR_TYPE_NO_ERROR; \
+ e.error = 0; \
+ cb(&e, ##args); \
+ } while (0)
+
+struct cb_data {
+ void *cb;
+ void *data;
+};
+
struct ofono_emulator {
struct ofono_atom *atom;
enum ofono_emulator_type type;
@@ -65,6 +87,17 @@ struct indicator {
gboolean mandatory;
};
+static inline struct cb_data *cb_data_new(void *cb, void *data)
+{
+ struct cb_data *ret;
+
+ ret = g_new0(struct cb_data, 1);
+ ret->cb = cb;
+ ret->data = data;
+
+ return ret;
+}
+
static void emulator_debug(const char *str, void *data)
{
ofono_info("%s: %s\n", (char *)data, str);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 2/7] include: Add ofono_emulator_set_removed_cb()
2013-04-12 20:40 ` [PATCH 0/7] Clear the ground for AG card implementation Paulo Borges
2013-04-12 20:40 ` [PATCH 1/7] emulator: Copy callback mechanism from atutil.h Paulo Borges
@ 2013-04-12 20:41 ` Paulo Borges
2013-04-12 20:41 ` [PATCH 3/7] emulator: Add removed notification mechanism Paulo Borges
` (4 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Paulo Borges @ 2013-04-12 20:41 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 994 bytes --]
---
include/emulator.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/emulator.h b/include/emulator.h
index 5cd894b..3e8b6d9 100644
--- a/include/emulator.h
+++ b/include/emulator.h
@@ -67,6 +67,8 @@ typedef void (*ofono_emulator_request_cb_t)(struct ofono_emulator *em,
struct ofono_emulator_request *req,
void *data);
+typedef void (*ofono_emulator_removed_cb_t)(void *data);
+
struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
enum ofono_emulator_type type);
@@ -74,6 +76,9 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd);
void ofono_emulator_remove(struct ofono_emulator *em);
+void ofono_emulator_set_removed_cb(struct ofono_emulator* em,
+ ofono_emulator_removed_cb_t cb, void *data);
+
void ofono_emulator_send_final(struct ofono_emulator *em,
const struct ofono_error *final);
void ofono_emulator_send_unsolicited(struct ofono_emulator *em,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 3/7] emulator: Add removed notification mechanism
2013-04-12 20:40 ` [PATCH 0/7] Clear the ground for AG card implementation Paulo Borges
2013-04-12 20:40 ` [PATCH 1/7] emulator: Copy callback mechanism from atutil.h Paulo Borges
2013-04-12 20:41 ` [PATCH 2/7] include: Add ofono_emulator_set_removed_cb() Paulo Borges
@ 2013-04-12 20:41 ` Paulo Borges
2013-04-12 20:41 ` [PATCH 4/7] emulator: Change feature check to attend HFP 1.6 Paulo Borges
` (3 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Paulo Borges @ 2013-04-12 20:41 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1150 bytes --]
This mechanism is used to notify when an emulator is about to be freed.
---
src/emulator.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/emulator.c b/src/emulator.c
index 6071615..890ea20 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -75,6 +75,7 @@ struct ofono_emulator {
gboolean clip;
gboolean ccwa;
int pns_id;
+ struct cb_data *removed_cb;
};
struct indicator {
@@ -985,6 +986,13 @@ static void emulator_remove(struct ofono_atom *atom)
DBG("atom: %p", atom);
+ if (em->removed_cb) {
+ ofono_emulator_removed_cb_t cb = em->removed_cb->cb;
+
+ cb(em->removed_cb->data);
+ g_free(em->removed_cb);
+ }
+
g_free(em);
}
@@ -1028,6 +1036,15 @@ void ofono_emulator_remove(struct ofono_emulator *em)
__ofono_atom_free(em->atom);
}
+void ofono_emulator_set_removed_cb(struct ofono_emulator* em,
+ ofono_emulator_removed_cb_t cb, void *data)
+{
+ if (em == NULL)
+ return;
+
+ em->removed_cb = cb_data_new(cb, data);
+}
+
void ofono_emulator_send_final(struct ofono_emulator *em,
const struct ofono_error *final)
{
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 4/7] emulator: Change feature check to attend HFP 1.6
2013-04-12 20:40 ` [PATCH 0/7] Clear the ground for AG card implementation Paulo Borges
` (2 preceding siblings ...)
2013-04-12 20:41 ` [PATCH 3/7] emulator: Add removed notification mechanism Paulo Borges
@ 2013-04-12 20:41 ` Paulo Borges
2013-04-15 12:24 ` Denis Kenzior
2013-04-12 20:41 ` [PATCH 5/7] hfp_ag_bluez5: Create a hash to store emulators Paulo Borges
` (2 subsequent siblings)
6 siblings, 1 reply; 19+ messages in thread
From: Paulo Borges @ 2013-04-12 20:41 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 719 bytes --]
HFP 1.6 adds a new feature called Codec Negotitation. For the HF Role,
this feature is stored in the eighty bit of the supported features
bitmap.
This way, we need to change the range of valid HF feature bitmaps to
2^8-1.
---
src/emulator.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/emulator.c b/src/emulator.c
index 890ea20..80341a4 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -487,7 +487,7 @@ static void brsf_cb(GAtServer *server, GAtServerRequestType type,
if (g_at_result_iter_next_number(&iter, &val) == FALSE)
goto fail;
- if (val < 0 || val > 127)
+ if (val < 0 || val > 255)
goto fail;
em->r_features = val;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 5/7] hfp_ag_bluez5: Create a hash to store emulators
2013-04-12 20:40 ` [PATCH 0/7] Clear the ground for AG card implementation Paulo Borges
` (3 preceding siblings ...)
2013-04-12 20:41 ` [PATCH 4/7] emulator: Change feature check to attend HFP 1.6 Paulo Borges
@ 2013-04-12 20:41 ` Paulo Borges
2013-04-12 20:41 ` [PATCH 6/7] hfp_ag_bluez5: Store emulator when connect Paulo Borges
2013-04-12 20:41 ` [PATCH 7/7] hfp_ag_bluez5: Remove emulator when disconnect Paulo Borges
6 siblings, 0 replies; 19+ messages in thread
From: Paulo Borges @ 2013-04-12 20:41 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1500 bytes --]
We need to store emulators so we can disconnect and free them at
RequestDisconnect().
---
plugins/hfp_ag_bluez5.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/plugins/hfp_ag_bluez5.c b/plugins/hfp_ag_bluez5.c
index 64ea8ca..b485e17 100644
--- a/plugins/hfp_ag_bluez5.c
+++ b/plugins/hfp_ag_bluez5.c
@@ -51,6 +51,19 @@
static guint modemwatch_id;
static GList *modems;
static GHashTable *sim_hash = NULL;
+static GHashTable *emulator_hash;
+
+static gboolean emulator_remove(gpointer key, gpointer value,
+ gpointer user_data)
+{
+ struct ofono_emulator *em = value;
+
+ DBG("%p", em);
+
+ ofono_emulator_remove(em);
+
+ return TRUE;
+}
static DBusMessage *profile_new_connection(DBusConnection *conn,
DBusMessage *msg, void *data)
@@ -254,6 +267,9 @@ static int hfp_ag_init(void)
modemwatch_id = __ofono_modemwatch_add(modem_watch, NULL, NULL);
__ofono_modem_foreach(call_modemwatch, NULL);
+ emulator_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
+ NULL);
+
return 0;
}
@@ -265,6 +281,9 @@ static void hfp_ag_exit(void)
g_dbus_unregister_interface(conn, HFP_AG_EXT_PROFILE_PATH,
BLUEZ_PROFILE_INTERFACE);
+ g_hash_table_foreach_remove(emulator_hash, emulator_remove, NULL);
+ g_hash_table_destroy(emulator_hash);
+
g_list_free(modems);
g_hash_table_foreach_remove(sim_hash, sim_watch_remove, NULL);
g_hash_table_destroy(sim_hash);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 6/7] hfp_ag_bluez5: Store emulator when connect
2013-04-12 20:40 ` [PATCH 0/7] Clear the ground for AG card implementation Paulo Borges
` (4 preceding siblings ...)
2013-04-12 20:41 ` [PATCH 5/7] hfp_ag_bluez5: Create a hash to store emulators Paulo Borges
@ 2013-04-12 20:41 ` Paulo Borges
2013-04-12 20:41 ` [PATCH 7/7] hfp_ag_bluez5: Remove emulator when disconnect Paulo Borges
6 siblings, 0 replies; 19+ messages in thread
From: Paulo Borges @ 2013-04-12 20:41 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 540 bytes --]
The emulator is stored after being registered.
---
plugins/hfp_ag_bluez5.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/plugins/hfp_ag_bluez5.c b/plugins/hfp_ag_bluez5.c
index b485e17..dbf053b 100644
--- a/plugins/hfp_ag_bluez5.c
+++ b/plugins/hfp_ag_bluez5.c
@@ -116,6 +116,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
}
ofono_emulator_register(em, fd);
+ g_hash_table_insert(emulator_hash, g_strdup(device), em);
return dbus_message_new_method_return(msg);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 7/7] hfp_ag_bluez5: Remove emulator when disconnect
2013-04-12 20:40 ` [PATCH 0/7] Clear the ground for AG card implementation Paulo Borges
` (5 preceding siblings ...)
2013-04-12 20:41 ` [PATCH 6/7] hfp_ag_bluez5: Store emulator when connect Paulo Borges
@ 2013-04-12 20:41 ` Paulo Borges
2013-04-15 12:30 ` Denis Kenzior
6 siblings, 1 reply; 19+ messages in thread
From: Paulo Borges @ 2013-04-12 20:41 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2704 bytes --]
When a RequestDisconnect() is received, the emulator must be both
disconnected and removed from the hash.
But an emulator can also be disconnected and freed automatically if its
GAtServer closes. In this case, the hash can hold an invalid pointer.
So, after the emulator is registered, a function is set to be called
when the emulator is about to be freed and this function removes the
emulator from the hash.
---
plugins/hfp_ag_bluez5.c | 43 +++++++++++++++++++++++++++++++++++++++----
1 file changed, 39 insertions(+), 4 deletions(-)
diff --git a/plugins/hfp_ag_bluez5.c b/plugins/hfp_ag_bluez5.c
index dbf053b..36c22f3 100644
--- a/plugins/hfp_ag_bluez5.c
+++ b/plugins/hfp_ag_bluez5.c
@@ -65,11 +65,21 @@ static gboolean emulator_remove(gpointer key, gpointer value,
return TRUE;
}
+static void emulator_removed_cb(void *user_data)
+{
+ char *device = user_data;
+
+ DBG("%s", device);
+
+ g_hash_table_remove(emulator_hash, device);
+}
+
static DBusMessage *profile_new_connection(DBusConnection *conn,
DBusMessage *msg, void *data)
{
DBusMessageIter entry;
const char *device;
+ char *key;
int fd;
struct ofono_emulator *em;
struct ofono_modem *modem;
@@ -115,8 +125,11 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
"Not enough resources");
}
+ key = g_strdup(device);
+
ofono_emulator_register(em, fd);
- g_hash_table_insert(emulator_hash, g_strdup(device), em);
+ ofono_emulator_set_removed_cb(em, emulator_removed_cb, key);
+ g_hash_table_insert(emulator_hash, key, em);
return dbus_message_new_method_return(msg);
@@ -148,11 +161,33 @@ static DBusMessage *profile_cancel(DBusConnection *conn,
static DBusMessage *profile_disconnection(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
+ DBusMessageIter iter;
+ const char *device;
+ struct ofono_emulator *em;
+
DBG("Profile handler RequestDisconnection");
- return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
- ".NotImplemented",
- "Implementation not provided");
+ if (!dbus_message_iter_init(msg, &iter))
+ goto invalid;
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_OBJECT_PATH)
+ goto invalid;
+
+ dbus_message_iter_get_basic(&iter, &device);
+
+ DBG("%s", device);
+
+ em = g_hash_table_lookup(emulator_hash, device);
+ if (em == NULL)
+ goto invalid;
+
+ ofono_emulator_remove(em);
+
+ return dbus_message_new_method_return(msg);
+
+invalid:
+ return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE ".Rejected",
+ "Invalid arguments in method call");
}
static const GDBusMethodTable profile_methods[] = {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH 4/7] emulator: Change feature check to attend HFP 1.6
2013-04-12 20:41 ` [PATCH 4/7] emulator: Change feature check to attend HFP 1.6 Paulo Borges
@ 2013-04-15 12:24 ` Denis Kenzior
0 siblings, 0 replies; 19+ messages in thread
From: Denis Kenzior @ 2013-04-15 12:24 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 484 bytes --]
Hi Paulo,
On 04/12/2013 03:41 PM, Paulo Borges wrote:
> HFP 1.6 adds a new feature called Codec Negotitation. For the HF Role,
> this feature is stored in the eighty bit of the supported features
> bitmap.
>
> This way, we need to change the range of valid HF feature bitmaps to
> 2^8-1.
> ---
> src/emulator.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Patch has been applied, but I reworded the commit description slightly.
Regards,
-Denis
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 7/7] hfp_ag_bluez5: Remove emulator when disconnect
2013-04-12 20:41 ` [PATCH 7/7] hfp_ag_bluez5: Remove emulator when disconnect Paulo Borges
@ 2013-04-15 12:30 ` Denis Kenzior
2013-04-15 18:58 ` Paulo Borges
0 siblings, 1 reply; 19+ messages in thread
From: Denis Kenzior @ 2013-04-15 12:30 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 849 bytes --]
Hi Paulo,
On 04/12/2013 03:41 PM, Paulo Borges wrote:
> When a RequestDisconnect() is received, the emulator must be both
> disconnected and removed from the hash.
>
> But an emulator can also be disconnected and freed automatically if its
> GAtServer closes. In this case, the hash can hold an invalid pointer.
>
> So, after the emulator is registered, a function is set to be called
> when the emulator is about to be freed and this function removes the
> emulator from the hash.
> ---
> plugins/hfp_ag_bluez5.c | 43 +++++++++++++++++++++++++++++++++++++++----
> 1 file changed, 39 insertions(+), 4 deletions(-)
Have you considered keeping track of the file descriptors instead? e.g.
simply adding a hash table of fds obtained from NewConnection() and
g_io_add_watch()-ing on the 'HUP' condition?
Regards,
-Denis
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 7/7] hfp_ag_bluez5: Remove emulator when disconnect
2013-04-15 12:30 ` Denis Kenzior
@ 2013-04-15 18:58 ` Paulo Borges
0 siblings, 0 replies; 19+ messages in thread
From: Paulo Borges @ 2013-04-15 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1024 bytes --]
Hi Denis,
On Mon, Apr 15, 2013 at 9:30 AM, Denis Kenzior <denkenz@gmail.com> wrote:
> Hi Paulo,
>
>
> On 04/12/2013 03:41 PM, Paulo Borges wrote:
>
>> When a RequestDisconnect() is received, the emulator must be both
>> disconnected and removed from the hash.
>>
>> But an emulator can also be disconnected and freed automatically if its
>> GAtServer closes. In this case, the hash can hold an invalid pointer.
>>
>> So, after the emulator is registered, a function is set to be called
>> when the emulator is about to be freed and this function removes the
>> emulator from the hash.
>> ---
>> plugins/hfp_ag_bluez5.c | 43 ++++++++++++++++++++++++++++++**
>> +++++++++----
>> 1 file changed, 39 insertions(+), 4 deletions(-)
>>
>
> Have you considered keeping track of the file descriptors instead? e.g.
> simply adding a hash table of fds obtained from NewConnection() and
> g_io_add_watch()-ing on the 'HUP' condition?
>
> Regards,
> -Denis
>
I'll test this approach.
Paulo.
[-- Attachment #2: attachment.html --]
[-- Type: text/html, Size: 1438 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2013-04-15 18:58 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-10 19:24 [PATCH 0/6] Clear the ground for AG implementation Paulo Borges
2013-04-10 19:24 ` [PATCH 1/6] include: Add ofono_emulator_set_removed_cb() Paulo Borges
2013-04-10 19:24 ` [PATCH 2/6] emulator: Add removed notification mechanism Paulo Borges
2013-04-11 21:50 ` Paulo Borges
2013-04-10 19:24 ` [PATCH 3/6] emulator: Change feature check to attend HFP 1.6 Paulo Borges
2013-04-10 19:24 ` [PATCH 4/6] hfp_ag_bluez5: Create a hash to store emulators Paulo Borges
2013-04-10 19:24 ` [PATCH 5/6] hfp_ag_bluez5: Store emulator when connect Paulo Borges
2013-04-10 19:24 ` [PATCH 6/6] hfp_ag_bluez5: Remove emulator when disconnect Paulo Borges
2013-04-12 20:40 ` [PATCH 0/7] Clear the ground for AG card implementation Paulo Borges
2013-04-12 20:40 ` [PATCH 1/7] emulator: Copy callback mechanism from atutil.h Paulo Borges
2013-04-12 20:41 ` [PATCH 2/7] include: Add ofono_emulator_set_removed_cb() Paulo Borges
2013-04-12 20:41 ` [PATCH 3/7] emulator: Add removed notification mechanism Paulo Borges
2013-04-12 20:41 ` [PATCH 4/7] emulator: Change feature check to attend HFP 1.6 Paulo Borges
2013-04-15 12:24 ` Denis Kenzior
2013-04-12 20:41 ` [PATCH 5/7] hfp_ag_bluez5: Create a hash to store emulators Paulo Borges
2013-04-12 20:41 ` [PATCH 6/7] hfp_ag_bluez5: Store emulator when connect Paulo Borges
2013-04-12 20:41 ` [PATCH 7/7] hfp_ag_bluez5: Remove emulator when disconnect Paulo Borges
2013-04-15 12:30 ` Denis Kenzior
2013-04-15 18:58 ` Paulo Borges
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.