All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] CDMA network registration
@ 2011-10-20 15:41 Guillaume Zajac
  2011-10-20 15:41 ` [PATCH 1/2] cdma-netreg: Add various cdma-netreg watches Guillaume Zajac
  2011-10-20 15:41 ` [PATCH 2/2] cdma-connman: Add cdma-netreg status watch to activate data call Guillaume Zajac
  0 siblings, 2 replies; 8+ messages in thread
From: Guillaume Zajac @ 2011-10-20 15:41 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 672 bytes --]

Hi,

First patch is adding cdma-netreg atom watch and status watch.
Second one is using them to check if CDMA modem is registered to the network to activate datacall.

TODO: Manage romaing case whenever it is allowed.

Kind regards,
Guillaume

Guillaume Zajac (2):
  cdma-netreg: Add various cdma-netreg watches
  cdma-connman: Add cdma-netreg status watch to activate data call

 include/cdma-netreg.h |    1 +
 src/cdma-connman.c    |   74 +++++++++++++++++++++++++++++++++++++++++++++++-
 src/cdma-netreg.c     |   58 ++++++++++++++++++++++++++++++++++++++
 src/ofono.h           |   13 ++++++++
 4 files changed, 144 insertions(+), 2 deletions(-)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] cdma-netreg: Add various cdma-netreg watches
  2011-10-20 15:41 [PATCH 0/2] CDMA network registration Guillaume Zajac
@ 2011-10-20 15:41 ` Guillaume Zajac
  2011-10-30  7:18   ` Denis Kenzior
  2011-10-20 15:41 ` [PATCH 2/2] cdma-connman: Add cdma-netreg status watch to activate data call Guillaume Zajac
  1 sibling, 1 reply; 8+ messages in thread
From: Guillaume Zajac @ 2011-10-20 15:41 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 4107 bytes --]

---
 include/cdma-netreg.h |    1 +
 src/cdma-netreg.c     |   58 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/ofono.h           |   13 +++++++++++
 3 files changed, 72 insertions(+), 0 deletions(-)

diff --git a/include/cdma-netreg.h b/include/cdma-netreg.h
index 25888d1..31ed289 100644
--- a/include/cdma-netreg.h
+++ b/include/cdma-netreg.h
@@ -50,6 +50,7 @@ void ofono_cdma_netreg_strength_notify(struct ofono_cdma_netreg *netreg,
 					int strength);
 void ofono_cdma_netreg_data_strength_notify(struct ofono_cdma_netreg *netreg,
 						int data_strength);
+int ofono_cdma_netreg_get_status(struct ofono_cdma_netreg *netreg);
 
 int ofono_cdma_netreg_driver_register(
 				const struct ofono_cdma_netreg_driver *d);
diff --git a/src/cdma-netreg.c b/src/cdma-netreg.c
index d88bfcc..d721098 100644
--- a/src/cdma-netreg.c
+++ b/src/cdma-netreg.c
@@ -35,6 +35,7 @@ struct ofono_cdma_netreg {
 	enum cdma_netreg_status status;
 	int strength;
 	int hdr_strength;
+	struct ofono_watchlist *status_watches;
 	const struct ofono_cdma_netreg_driver *driver;
 	void *driver_data;
 	struct ofono_atom *atom;
@@ -119,6 +120,53 @@ static void set_registration_status(struct ofono_cdma_netreg *cdma_netreg,
 				&str_status);
 }
 
+unsigned int __ofono_cdma_netreg_add_status_watch(
+				struct ofono_cdma_netreg *cdma_netreg,
+				ofono_cdma_netreg_status_notify_cb_t notify,
+				void *data, ofono_destroy_func destroy)
+{
+	struct ofono_watchlist_item *item;
+
+	DBG("%p", cdma_netreg);
+
+	if (cdma_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(cdma_netreg->status_watches, item);
+}
+
+gboolean __ofono_cdma_netreg_remove_status_watch(
+					struct ofono_cdma_netreg *cdma_netreg,
+					unsigned int id)
+{
+	DBG("%p", cdma_netreg);
+
+	return __ofono_watchlist_remove_item(cdma_netreg->status_watches, id);
+}
+
+static void notify_status_watches(struct ofono_cdma_netreg *cdma_netreg)
+{
+	struct ofono_watchlist_item *item;
+	GSList *l;
+	ofono_cdma_netreg_status_notify_cb_t notify;
+
+	for (l = cdma_netreg->status_watches->items; l; l = l->next) {
+		item = l->data;
+		notify = item->notify;
+
+		notify(cdma_netreg->status, item->notify_data);
+	}
+}
+
 void ofono_cdma_netreg_status_notify(struct ofono_cdma_netreg *cdma_netreg,
 					enum cdma_netreg_status status)
 {
@@ -127,6 +175,8 @@ void ofono_cdma_netreg_status_notify(struct ofono_cdma_netreg *cdma_netreg,
 
 	if (cdma_netreg->status != status)
 		set_registration_status(cdma_netreg, status);
+
+	notify_status_watches(cdma_netreg);
 }
 
 static void strength_notify_common(struct ofono_cdma_netreg *netreg,
@@ -173,6 +223,14 @@ void ofono_cdma_netreg_data_strength_notify(struct ofono_cdma_netreg *netreg,
 					"DataStrength", &netreg->hdr_strength);
 }
 
+int ofono_cdma_netreg_get_status(struct ofono_cdma_netreg *netreg)
+{
+	if (netreg == NULL)
+		return -1;
+
+	return netreg->status;
+}
+
 int ofono_cdma_netreg_driver_register(const struct ofono_cdma_netreg_driver *d)
 {
 	DBG("driver: %p, name: %s", d, d->name);
diff --git a/src/ofono.h b/src/ofono.h
index bd45560..ce2f0b6 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -485,7 +485,20 @@ void __ofono_gprs_provision_free_settings(
 #include <ofono/emulator.h>
 #include <ofono/gnss.h>
 #include <ofono/cdma-sms.h>
+
 #include <ofono/cdma-netreg.h>
+
+typedef void (*ofono_cdma_netreg_status_notify_cb_t)(int status, void *data);
+
+unsigned int __ofono_cdma_netreg_add_status_watch(
+				struct ofono_cdma_netreg *cdma_netreg,
+				ofono_cdma_netreg_status_notify_cb_t cb,
+				void *data, ofono_destroy_func destroy);
+
+gboolean __ofono_cdma_netreg_remove_status_watch(
+					struct ofono_cdma_netreg *cdma_netreg,
+					unsigned int id);
+
 #include <ofono/private-network.h>
 
 void __ofono_private_network_release(int id);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] cdma-connman: Add cdma-netreg status watch to activate data call
  2011-10-20 15:41 [PATCH 0/2] CDMA network registration Guillaume Zajac
  2011-10-20 15:41 ` [PATCH 1/2] cdma-netreg: Add various cdma-netreg watches Guillaume Zajac
@ 2011-10-20 15:41 ` Guillaume Zajac
  2011-10-30  7:16   ` Denis Kenzior
  1 sibling, 1 reply; 8+ messages in thread
From: Guillaume Zajac @ 2011-10-20 15:41 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 3723 bytes --]

---
 src/cdma-connman.c |   74 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 72 insertions(+), 2 deletions(-)

diff --git a/src/cdma-connman.c b/src/cdma-connman.c
index db8f6c5..edd71b5 100644
--- a/src/cdma-connman.c
+++ b/src/cdma-connman.c
@@ -52,6 +52,11 @@ struct cdma_connman_settings {
 struct ofono_cdma_connman {
 	ofono_bool_t powered;
 	ofono_bool_t dormant;
+	ofono_bool_t attached;
+	int cdma_netreg_status;
+	struct ofono_cdma_netreg *cdma_netreg;
+	unsigned int cdma_netreg_watch;
+	unsigned int cdma_status_watch;
 	struct cdma_connman_settings *settings;
 	DBusMessage *pending;
 	const struct ofono_cdma_connman_driver *driver;
@@ -465,7 +470,9 @@ static DBusMessage *cdma_connman_set_property(DBusConnection *conn,
 
 		cm->pending = dbus_message_ref(msg);
 
-		/* TODO: add logic to support CDMA Network Registration */
+		if (value && !cm->attached)
+			return __ofono_error_not_attached(msg);
+
 		if (value)
 			cm->driver->activate(cm, cm->username, cm->password,
 						activate_callback, cm);
@@ -531,9 +538,23 @@ static void cdma_connman_unregister(struct ofono_atom *atom)
 	DBusConnection *conn = ofono_dbus_get_connection();
 	struct ofono_modem *modem = __ofono_atom_get_modem(atom);
 	const char *path = __ofono_atom_get_path(atom);
+	struct ofono_cdma_connman *cm = __ofono_atom_get_data(atom);
 
 	DBG("");
 
+	if (cm->cdma_netreg_watch) {
+		if (cm->cdma_status_watch) {
+			__ofono_cdma_netreg_remove_status_watch(
+							cm->cdma_netreg,
+							cm->cdma_status_watch);
+			cm->cdma_status_watch = 0;
+		}
+
+		__ofono_modem_remove_atom_watch(modem, cm->cdma_netreg_watch);
+		cm->cdma_netreg_watch = 0;
+		cm->cdma_netreg = NULL;
+	}
+
 	g_dbus_unregister_interface(conn, path,
 				OFONO_CDMA_CONNECTION_MANAGER_INTERFACE);
 	ofono_modem_remove_interface(modem,
@@ -593,6 +614,53 @@ struct ofono_cdma_connman *ofono_cdma_connman_create(
 	return cm;
 }
 
+static void cdma_connman_netreg_update(struct ofono_cdma_connman *cm)
+{
+	ofono_bool_t attach;
+
+	attach = cm->cdma_netreg_status ==
+			NETWORK_REGISTRATION_STATUS_REGISTERED;
+
+	/* TODO: Manager roaming case */
+
+	cm->attached = attach;
+}
+
+static void cdma_netreg_status_changed(int status, void *data)
+{
+	struct ofono_cdma_connman *cm = data;
+
+	DBG("%d", status);
+
+	if (cm->cdma_netreg_status == status)
+		return;
+
+	cm->cdma_netreg_status = status;
+
+	cdma_connman_netreg_update(cm);
+}
+
+static void cdma_netreg_watch(struct ofono_atom *atom,
+				enum ofono_atom_watch_condition cond,
+				void *data)
+{
+	struct ofono_cdma_connman *cm = data;
+
+	if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) {
+		cm->cdma_netreg_status =
+				NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
+		return;
+	}
+
+	cm->cdma_netreg = __ofono_atom_get_data(atom);
+	cm->cdma_netreg_status = ofono_cdma_netreg_get_status(cm->cdma_netreg);
+	cm->cdma_status_watch =
+			__ofono_cdma_netreg_add_status_watch(cm->cdma_netreg,
+					cdma_netreg_status_changed, cm, NULL);
+
+	cdma_connman_netreg_update(cm);
+}
+
 void ofono_cdma_connman_register(struct ofono_cdma_connman *cm)
 {
 	DBusConnection *conn = ofono_dbus_get_connection();
@@ -613,7 +681,9 @@ void ofono_cdma_connman_register(struct ofono_cdma_connman *cm)
 	ofono_modem_add_interface(modem,
 				OFONO_CDMA_CONNECTION_MANAGER_INTERFACE);
 
-	/* TODO: add watch to support CDMA Network Registration atom */
+	cm->cdma_netreg_watch = __ofono_modem_add_atom_watch(modem,
+					OFONO_ATOM_TYPE_CDMA_NETREG,
+					cdma_netreg_watch, cm, NULL);
 
 	__ofono_atom_register(cm->atom, cdma_connman_unregister);
 }
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] cdma-connman: Add cdma-netreg status watch to activate data call
  2011-10-20 15:41 ` [PATCH 2/2] cdma-connman: Add cdma-netreg status watch to activate data call Guillaume Zajac
@ 2011-10-30  7:16   ` Denis Kenzior
  2011-10-31 15:27     ` Guillaume Zajac
  0 siblings, 1 reply; 8+ messages in thread
From: Denis Kenzior @ 2011-10-30  7:16 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 4426 bytes --]

Hi Guillaume,

On 10/20/2011 10:41 AM, Guillaume Zajac wrote:
> ---
>  src/cdma-connman.c |   74 ++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 72 insertions(+), 2 deletions(-)
> 
> diff --git a/src/cdma-connman.c b/src/cdma-connman.c
> index db8f6c5..edd71b5 100644
> --- a/src/cdma-connman.c
> +++ b/src/cdma-connman.c
> @@ -52,6 +52,11 @@ struct cdma_connman_settings {
>  struct ofono_cdma_connman {
>  	ofono_bool_t powered;
>  	ofono_bool_t dormant;
> +	ofono_bool_t attached;
> +	int cdma_netreg_status;
> +	struct ofono_cdma_netreg *cdma_netreg;
> +	unsigned int cdma_netreg_watch;
> +	unsigned int cdma_status_watch;
>  	struct cdma_connman_settings *settings;
>  	DBusMessage *pending;
>  	const struct ofono_cdma_connman_driver *driver;
> @@ -465,7 +470,9 @@ static DBusMessage *cdma_connman_set_property(DBusConnection *conn,
>  
>  		cm->pending = dbus_message_ref(msg);
>  
> -		/* TODO: add logic to support CDMA Network Registration */
> +		if (value && !cm->attached)
> +			return __ofono_error_not_attached(msg);
> +

There is no concept of attachment in CDMA, so I'd prefer we not do it
this way.  Can't we simply check the current netreg atom status here?

>  		if (value)
>  			cm->driver->activate(cm, cm->username, cm->password,
>  						activate_callback, cm);
> @@ -531,9 +538,23 @@ static void cdma_connman_unregister(struct ofono_atom *atom)
>  	DBusConnection *conn = ofono_dbus_get_connection();
>  	struct ofono_modem *modem = __ofono_atom_get_modem(atom);
>  	const char *path = __ofono_atom_get_path(atom);
> +	struct ofono_cdma_connman *cm = __ofono_atom_get_data(atom);
>  
>  	DBG("");
>  
> +	if (cm->cdma_netreg_watch) {
> +		if (cm->cdma_status_watch) {
> +			__ofono_cdma_netreg_remove_status_watch(
> +							cm->cdma_netreg,
> +							cm->cdma_status_watch);
> +			cm->cdma_status_watch = 0;
> +		}
> +
> +		__ofono_modem_remove_atom_watch(modem, cm->cdma_netreg_watch);
> +		cm->cdma_netreg_watch = 0;
> +		cm->cdma_netreg = NULL;
> +	}
> +
>  	g_dbus_unregister_interface(conn, path,
>  				OFONO_CDMA_CONNECTION_MANAGER_INTERFACE);
>  	ofono_modem_remove_interface(modem,
> @@ -593,6 +614,53 @@ struct ofono_cdma_connman *ofono_cdma_connman_create(
>  	return cm;
>  }
>  
> +static void cdma_connman_netreg_update(struct ofono_cdma_connman *cm)
> +{
> +	ofono_bool_t attach;
> +
> +	attach = cm->cdma_netreg_status ==
> +			NETWORK_REGISTRATION_STATUS_REGISTERED;
> +
> +	/* TODO: Manager roaming case */
> +
> +	cm->attached = attach;
> +}
> +
> +static void cdma_netreg_status_changed(int status, void *data)
> +{
> +	struct ofono_cdma_connman *cm = data;
> +
> +	DBG("%d", status);
> +
> +	if (cm->cdma_netreg_status == status)
> +		return;
> +
> +	cm->cdma_netreg_status = status;
> +
> +	cdma_connman_netreg_update(cm);
> +}
> +
> +static void cdma_netreg_watch(struct ofono_atom *atom,
> +				enum ofono_atom_watch_condition cond,
> +				void *data)
> +{
> +	struct ofono_cdma_connman *cm = data;
> +
> +	if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) {
> +		cm->cdma_netreg_status =
> +				NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
> +		return;
> +	}
> +
> +	cm->cdma_netreg = __ofono_atom_get_data(atom);
> +	cm->cdma_netreg_status = ofono_cdma_netreg_get_status(cm->cdma_netreg);
> +	cm->cdma_status_watch =
> +			__ofono_cdma_netreg_add_status_watch(cm->cdma_netreg,
> +					cdma_netreg_status_changed, cm, NULL);
> +
> +	cdma_connman_netreg_update(cm);
> +}
> +
>  void ofono_cdma_connman_register(struct ofono_cdma_connman *cm)
>  {
>  	DBusConnection *conn = ofono_dbus_get_connection();
> @@ -613,7 +681,9 @@ void ofono_cdma_connman_register(struct ofono_cdma_connman *cm)
>  	ofono_modem_add_interface(modem,
>  				OFONO_CDMA_CONNECTION_MANAGER_INTERFACE);
>  
> -	/* TODO: add watch to support CDMA Network Registration atom */
> +	cm->cdma_netreg_watch = __ofono_modem_add_atom_watch(modem,
> +					OFONO_ATOM_TYPE_CDMA_NETREG,
> +					cdma_netreg_watch, cm, NULL);
>  
>  	__ofono_atom_register(cm->atom, cdma_connman_unregister);
>  }

It seems to me that this is way too complicated.  All you want is to
check the netreg status before trying to set powered.  If we lose netreg
when the connection is active, then the regular cdma-connman
notification procedures would apply.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] cdma-netreg: Add various cdma-netreg watches
  2011-10-20 15:41 ` [PATCH 1/2] cdma-netreg: Add various cdma-netreg watches Guillaume Zajac
@ 2011-10-30  7:18   ` Denis Kenzior
  2011-10-31 14:55     ` Guillaume Zajac
  0 siblings, 1 reply; 8+ messages in thread
From: Denis Kenzior @ 2011-10-30  7:18 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 538 bytes --]

Hi Guillaume,

On 10/20/2011 10:41 AM, Guillaume Zajac wrote:
> ---
>  include/cdma-netreg.h |    1 +
>  src/cdma-netreg.c     |   58 +++++++++++++++++++++++++++++++++++++++++++++++++
>  src/ofono.h           |   13 +++++++++++
>  3 files changed, 72 insertions(+), 0 deletions(-)
> 

Please follow patch submission guidelines outlined in HACKING.  Namely
the include/ changes should be in a separate patch.

I cherry picked the chunks dealing with ofono_cdma_netreg_get_status and
pushed them upstream.

Thanks,
-Denis

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] cdma-connman: Add cdma-netreg status watch to activate data call
  2011-10-31 15:27     ` Guillaume Zajac
@ 2011-10-30  8:27       ` Denis Kenzior
  0 siblings, 0 replies; 8+ messages in thread
From: Denis Kenzior @ 2011-10-30  8:27 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1278 bytes --]

Hi Guillaume,

>> There is no concept of attachment in CDMA, so I'd prefer we not do it
>> this way.  Can't we simply check the current netreg atom status here?
> 
> Fine for me. Then we should also create a new D-Bus error message like:
> __ofono_error_not_registered().
> 

That sounds fine to me.

<snip>

>> It seems to me that this is way too complicated.  All you want is to
>> check the netreg status before trying to set powered.  If we lose netreg
>> when the connection is active, then the regular cdma-connman
>> notification procedures would apply.
> 
> Once we lost netreg, what are we supposed to do?
> cdma-netreg atom will signal "Status" property has changed.
> Is that up to ConnMan to deactivate the data call in checking the
> cdma-netreg "Status" property equal to "unregistered"?

Ah, so that's what you want to accomplish.  This wasn't clear from your
patch.  You have two options here:

- Rely on the modem to drop the data connection and have the
cdma-connman driver notify us appropriately.  The mechanism would be
similar to ofono_gprs_context_deactivated.

- In addition to above, force the Powered property to False when the
registration is lost.  In which case you would need the status watches.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] cdma-netreg: Add various cdma-netreg watches
  2011-10-30  7:18   ` Denis Kenzior
@ 2011-10-31 14:55     ` Guillaume Zajac
  0 siblings, 0 replies; 8+ messages in thread
From: Guillaume Zajac @ 2011-10-31 14:55 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 645 bytes --]

Hi Denis,

On 30/10/2011 08:18, Denis Kenzior wrote:
> Hi Guillaume,
>
> On 10/20/2011 10:41 AM, Guillaume Zajac wrote:
>> ---
>>   include/cdma-netreg.h |    1 +
>>   src/cdma-netreg.c     |   58 +++++++++++++++++++++++++++++++++++++++++++++++++
>>   src/ofono.h           |   13 +++++++++++
>>   3 files changed, 72 insertions(+), 0 deletions(-)
>>
> Please follow patch submission guidelines outlined in HACKING.  Namely
> the include/ changes should be in a separate patch.

Ok sorry for that.

> I cherry picked the chunks dealing with ofono_cdma_netreg_get_status and
> pushed them upstream.

Kind regards,
Guillaume

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] cdma-connman: Add cdma-netreg status watch to activate data call
  2011-10-30  7:16   ` Denis Kenzior
@ 2011-10-31 15:27     ` Guillaume Zajac
  2011-10-30  8:27       ` Denis Kenzior
  0 siblings, 1 reply; 8+ messages in thread
From: Guillaume Zajac @ 2011-10-31 15:27 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 4981 bytes --]

Hi Denis,

On 30/10/2011 08:16, Denis Kenzior wrote:
> Hi Guillaume,
>
> On 10/20/2011 10:41 AM, Guillaume Zajac wrote:
>> ---
>>   src/cdma-connman.c |   74 ++++++++++++++++++++++++++++++++++++++++++++++++++-
>>   1 files changed, 72 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/cdma-connman.c b/src/cdma-connman.c
>> index db8f6c5..edd71b5 100644
>> --- a/src/cdma-connman.c
>> +++ b/src/cdma-connman.c
>> @@ -52,6 +52,11 @@ struct cdma_connman_settings {
>>   struct ofono_cdma_connman {
>>   	ofono_bool_t powered;
>>   	ofono_bool_t dormant;
>> +	ofono_bool_t attached;
>> +	int cdma_netreg_status;
>> +	struct ofono_cdma_netreg *cdma_netreg;
>> +	unsigned int cdma_netreg_watch;
>> +	unsigned int cdma_status_watch;
>>   	struct cdma_connman_settings *settings;
>>   	DBusMessage *pending;
>>   	const struct ofono_cdma_connman_driver *driver;
>> @@ -465,7 +470,9 @@ static DBusMessage *cdma_connman_set_property(DBusConnection *conn,
>>
>>   		cm->pending = dbus_message_ref(msg);
>>
>> -		/* TODO: add logic to support CDMA Network Registration */
>> +		if (value&&  !cm->attached)
>> +			return __ofono_error_not_attached(msg);
>> +
> There is no concept of attachment in CDMA, so I'd prefer we not do it
> this way.  Can't we simply check the current netreg atom status here?

Fine for me. Then we should also create a new D-Bus error message like:
__ofono_error_not_registered().

>>   		if (value)
>>   			cm->driver->activate(cm, cm->username, cm->password,
>>   						activate_callback, cm);
>> @@ -531,9 +538,23 @@ static void cdma_connman_unregister(struct ofono_atom *atom)
>>   	DBusConnection *conn = ofono_dbus_get_connection();
>>   	struct ofono_modem *modem = __ofono_atom_get_modem(atom);
>>   	const char *path = __ofono_atom_get_path(atom);
>> +	struct ofono_cdma_connman *cm = __ofono_atom_get_data(atom);
>>
>>   	DBG("");
>>
>> +	if (cm->cdma_netreg_watch) {
>> +		if (cm->cdma_status_watch) {
>> +			__ofono_cdma_netreg_remove_status_watch(
>> +							cm->cdma_netreg,
>> +							cm->cdma_status_watch);
>> +			cm->cdma_status_watch = 0;
>> +		}
>> +
>> +		__ofono_modem_remove_atom_watch(modem, cm->cdma_netreg_watch);
>> +		cm->cdma_netreg_watch = 0;
>> +		cm->cdma_netreg = NULL;
>> +	}
>> +
>>   	g_dbus_unregister_interface(conn, path,
>>   				OFONO_CDMA_CONNECTION_MANAGER_INTERFACE);
>>   	ofono_modem_remove_interface(modem,
>> @@ -593,6 +614,53 @@ struct ofono_cdma_connman *ofono_cdma_connman_create(
>>   	return cm;
>>   }
>>
>> +static void cdma_connman_netreg_update(struct ofono_cdma_connman *cm)
>> +{
>> +	ofono_bool_t attach;
>> +
>> +	attach = cm->cdma_netreg_status ==
>> +			NETWORK_REGISTRATION_STATUS_REGISTERED;
>> +
>> +	/* TODO: Manager roaming case */
>> +
>> +	cm->attached = attach;
>> +}
>> +
>> +static void cdma_netreg_status_changed(int status, void *data)
>> +{
>> +	struct ofono_cdma_connman *cm = data;
>> +
>> +	DBG("%d", status);
>> +
>> +	if (cm->cdma_netreg_status == status)
>> +		return;
>> +
>> +	cm->cdma_netreg_status = status;
>> +
>> +	cdma_connman_netreg_update(cm);
>> +}
>> +
>> +static void cdma_netreg_watch(struct ofono_atom *atom,
>> +				enum ofono_atom_watch_condition cond,
>> +				void *data)
>> +{
>> +	struct ofono_cdma_connman *cm = data;
>> +
>> +	if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) {
>> +		cm->cdma_netreg_status =
>> +				NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
>> +		return;
>> +	}
>> +
>> +	cm->cdma_netreg = __ofono_atom_get_data(atom);
>> +	cm->cdma_netreg_status = ofono_cdma_netreg_get_status(cm->cdma_netreg);
>> +	cm->cdma_status_watch =
>> +			__ofono_cdma_netreg_add_status_watch(cm->cdma_netreg,
>> +					cdma_netreg_status_changed, cm, NULL);
>> +
>> +	cdma_connman_netreg_update(cm);
>> +}
>> +
>>   void ofono_cdma_connman_register(struct ofono_cdma_connman *cm)
>>   {
>>   	DBusConnection *conn = ofono_dbus_get_connection();
>> @@ -613,7 +681,9 @@ void ofono_cdma_connman_register(struct ofono_cdma_connman *cm)
>>   	ofono_modem_add_interface(modem,
>>   				OFONO_CDMA_CONNECTION_MANAGER_INTERFACE);
>>
>> -	/* TODO: add watch to support CDMA Network Registration atom */
>> +	cm->cdma_netreg_watch = __ofono_modem_add_atom_watch(modem,
>> +					OFONO_ATOM_TYPE_CDMA_NETREG,
>> +					cdma_netreg_watch, cm, NULL);
>>
>>   	__ofono_atom_register(cm->atom, cdma_connman_unregister);
>>   }
> It seems to me that this is way too complicated.  All you want is to
> check the netreg status before trying to set powered.  If we lose netreg
> when the connection is active, then the regular cdma-connman
> notification procedures would apply.

Once we lost netreg, what are we supposed to do?
cdma-netreg atom will signal "Status" property has changed.
Is that up to ConnMan to deactivate the data call in checking the 
cdma-netreg "Status" property equal to "unregistered"?

Kind regards,
Guillaume

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-10-31 15:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-20 15:41 [PATCH 0/2] CDMA network registration Guillaume Zajac
2011-10-20 15:41 ` [PATCH 1/2] cdma-netreg: Add various cdma-netreg watches Guillaume Zajac
2011-10-30  7:18   ` Denis Kenzior
2011-10-31 14:55     ` Guillaume Zajac
2011-10-20 15:41 ` [PATCH 2/2] cdma-connman: Add cdma-netreg status watch to activate data call Guillaume Zajac
2011-10-30  7:16   ` Denis Kenzior
2011-10-31 15:27     ` Guillaume Zajac
2011-10-30  8:27       ` Denis Kenzior

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.