* [PATCH_v2 0/2] Add CDMA features to load/save credentials @ 2011-08-11 16:02 Guillaume Zajac 2011-08-11 16:02 ` [PATCH_v2 1/2] modem: Change to online state when serial is set Guillaume Zajac 2011-08-11 16:02 ` [PATCH_v2 2/2] cdma-connman: Add feature to load/save credentials Guillaume Zajac 0 siblings, 2 replies; 6+ messages in thread From: Guillaume Zajac @ 2011-08-11 16:02 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 573 bytes --] Change log from v1 is: - pass to post_sim state when serial is received - cdma-connman atom can load settings as mode serial is received before its creation. - create new devinfo API to pass serial to cdma-connman atom Guillaume Zajac (2): modem: Change to online state when serial is set cdma-connman: Add feature to load/save credentials include/devinfo.h | 2 + src/cdma-connman.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/modem.c | 23 +++++++++++++++-- 3 files changed, 89 insertions(+), 3 deletions(-) ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH_v2 1/2] modem: Change to online state when serial is set 2011-08-11 16:02 [PATCH_v2 0/2] Add CDMA features to load/save credentials Guillaume Zajac @ 2011-08-11 16:02 ` Guillaume Zajac 2011-08-12 6:34 ` Denis Kenzior 2011-08-11 16:02 ` [PATCH_v2 2/2] cdma-connman: Add feature to load/save credentials Guillaume Zajac 1 sibling, 1 reply; 6+ messages in thread From: Guillaume Zajac @ 2011-08-11 16:02 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 3001 bytes --] For modems with no sim atom, we wait for serial reply to proceed post_sim. Add API to get serial devinfo like it is done for imsi. --- include/devinfo.h | 2 ++ src/modem.c | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/include/devinfo.h b/include/devinfo.h index 5df1316..db1db67 100644 --- a/include/devinfo.h +++ b/include/devinfo.h @@ -61,6 +61,8 @@ void ofono_devinfo_remove(struct ofono_devinfo *info); void ofono_devinfo_set_data(struct ofono_devinfo *info, void *data); void *ofono_devinfo_get_data(struct ofono_devinfo *info); +const char *ofono_devinfo_get_serial(struct ofono_devinfo *info); + #ifdef __cplusplus } #endif diff --git a/src/modem.c b/src/modem.c index 14c7a20..aa6b1c6 100644 --- a/src/modem.c +++ b/src/modem.c @@ -72,6 +72,7 @@ struct ofono_modem { ofono_bool_t powered_pending; ofono_bool_t get_online; ofono_bool_t lockdown; + ofono_bool_t pending_post_sim; char *lock_owner; guint lock_watch; guint timeout; @@ -1093,9 +1094,14 @@ static DBusMessage *modem_set_property(DBusConnection *conn, if (powered) { modem_change_state(modem, MODEM_STATE_PRE_SIM); - /* Force SIM Ready for devies with no sim atom */ + /* + * Force SIM Ready for devices with no sim atom + * Pratically, it concerns CDMA modems. We need to + * check if their serial is set before proceeding + * post_sim. + */ if (modem_has_sim(modem) == FALSE) - sim_state_watch(OFONO_SIM_STATE_READY, modem); + modem->pending_post_sim = TRUE; } else { set_online(modem, FALSE); modem_change_state(modem, MODEM_STATE_POWER_OFF); @@ -1175,7 +1181,7 @@ void ofono_modem_set_powered(struct ofono_modem *modem, ofono_bool_t powered) /* Force SIM Ready for devices with no sim atom */ if (modem_has_sim(modem) == FALSE) - sim_state_watch(OFONO_SIM_STATE_READY, modem); + modem->pending_post_sim = TRUE; } else { set_online(modem, FALSE); @@ -1315,18 +1321,29 @@ void ofono_modem_remove_interface(struct ofono_modem *modem, modem->interface_update = g_idle_add(trigger_interface_update, modem); } +const char *ofono_devinfo_get_serial(struct ofono_devinfo *info) +{ + return info->serial; +} + static void query_serial_cb(const struct ofono_error *error, const char *serial, void *user) { struct ofono_devinfo *info = user; DBusConnection *conn = ofono_dbus_get_connection(); const char *path = __ofono_atom_get_path(info->atom); + struct ofono_modem *modem = __ofono_atom_get_modem(info->atom); if (error->type != OFONO_ERROR_TYPE_NO_ERROR) return; info->serial = g_strdup(serial); + if (modem->pending_post_sim == TRUE) { + modem->pending_post_sim = FALSE; + sim_state_watch(OFONO_SIM_STATE_READY, modem); + } + ofono_dbus_signal_property_changed(conn, path, OFONO_MODEM_INTERFACE, "Serial", DBUS_TYPE_STRING, -- 1.7.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH_v2 1/2] modem: Change to online state when serial is set 2011-08-11 16:02 ` [PATCH_v2 1/2] modem: Change to online state when serial is set Guillaume Zajac @ 2011-08-12 6:34 ` Denis Kenzior 2011-08-22 8:20 ` Guillaume Zajac 2011-08-22 8:47 ` Guillaume Zajac 0 siblings, 2 replies; 6+ messages in thread From: Denis Kenzior @ 2011-08-12 6:34 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 3417 bytes --] Hi Guillaume, On 08/11/2011 11:02 AM, Guillaume Zajac wrote: > For modems with no sim atom, we wait for serial reply to proceed post_sim. > Add API to get serial devinfo like it is done for imsi. > --- > include/devinfo.h | 2 ++ > src/modem.c | 23 ++++++++++++++++++++--- > 2 files changed, 22 insertions(+), 3 deletions(-) > > diff --git a/include/devinfo.h b/include/devinfo.h > index 5df1316..db1db67 100644 > --- a/include/devinfo.h > +++ b/include/devinfo.h > @@ -61,6 +61,8 @@ void ofono_devinfo_remove(struct ofono_devinfo *info); > void ofono_devinfo_set_data(struct ofono_devinfo *info, void *data); > void *ofono_devinfo_get_data(struct ofono_devinfo *info); > > +const char *ofono_devinfo_get_serial(struct ofono_devinfo *info); > + > #ifdef __cplusplus > } > #endif > diff --git a/src/modem.c b/src/modem.c > index 14c7a20..aa6b1c6 100644 > --- a/src/modem.c > +++ b/src/modem.c > @@ -72,6 +72,7 @@ struct ofono_modem { > ofono_bool_t powered_pending; > ofono_bool_t get_online; > ofono_bool_t lockdown; > + ofono_bool_t pending_post_sim; > char *lock_owner; > guint lock_watch; > guint timeout; > @@ -1093,9 +1094,14 @@ static DBusMessage *modem_set_property(DBusConnection *conn, > if (powered) { > modem_change_state(modem, MODEM_STATE_PRE_SIM); > > - /* Force SIM Ready for devies with no sim atom */ > + /* > + * Force SIM Ready for devices with no sim atom > + * Pratically, it concerns CDMA modems. We need to > + * check if their serial is set before proceeding > + * post_sim. > + */ This comment is not true, this behavior is mostly for HFP_HF devices, not CDMA devices, and these don't even have a devinfo atom. So you are breaking these now. > if (modem_has_sim(modem) == FALSE) > - sim_state_watch(OFONO_SIM_STATE_READY, modem); > + modem->pending_post_sim = TRUE; > } else { > set_online(modem, FALSE); > modem_change_state(modem, MODEM_STATE_POWER_OFF); > @@ -1175,7 +1181,7 @@ void ofono_modem_set_powered(struct ofono_modem *modem, ofono_bool_t powered) > > /* Force SIM Ready for devices with no sim atom */ > if (modem_has_sim(modem) == FALSE) > - sim_state_watch(OFONO_SIM_STATE_READY, modem); > + modem->pending_post_sim = TRUE; > } else { > set_online(modem, FALSE); > > @@ -1315,18 +1321,29 @@ void ofono_modem_remove_interface(struct ofono_modem *modem, > modem->interface_update = g_idle_add(trigger_interface_update, modem); > } > > +const char *ofono_devinfo_get_serial(struct ofono_devinfo *info) > +{ > + return info->serial; > +} > + > static void query_serial_cb(const struct ofono_error *error, > const char *serial, void *user) > { > struct ofono_devinfo *info = user; > DBusConnection *conn = ofono_dbus_get_connection(); > const char *path = __ofono_atom_get_path(info->atom); > + struct ofono_modem *modem = __ofono_atom_get_modem(info->atom); > > if (error->type != OFONO_ERROR_TYPE_NO_ERROR) > return; > > info->serial = g_strdup(serial); > > + if (modem->pending_post_sim == TRUE) { > + modem->pending_post_sim = FALSE; > + sim_state_watch(OFONO_SIM_STATE_READY, modem); > + } > + > ofono_dbus_signal_property_changed(conn, path, > OFONO_MODEM_INTERFACE, > "Serial", DBUS_TYPE_STRING, Regards, -Denis ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH_v2 1/2] modem: Change to online state when serial is set 2011-08-12 6:34 ` Denis Kenzior @ 2011-08-22 8:20 ` Guillaume Zajac 2011-08-22 8:47 ` Guillaume Zajac 1 sibling, 0 replies; 6+ messages in thread From: Guillaume Zajac @ 2011-08-22 8:20 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 3662 bytes --] Hi Denis, On 12/08/2011 08:34, Denis Kenzior wrote: > Hi Guillaume, > > On 08/11/2011 11:02 AM, Guillaume Zajac wrote: >> For modems with no sim atom, we wait for serial reply to proceed post_sim. >> Add API to get serial devinfo like it is done for imsi. >> --- >> include/devinfo.h | 2 ++ >> src/modem.c | 23 ++++++++++++++++++++--- >> 2 files changed, 22 insertions(+), 3 deletions(-) >> >> diff --git a/include/devinfo.h b/include/devinfo.h >> index 5df1316..db1db67 100644 >> --- a/include/devinfo.h >> +++ b/include/devinfo.h >> @@ -61,6 +61,8 @@ void ofono_devinfo_remove(struct ofono_devinfo *info); >> void ofono_devinfo_set_data(struct ofono_devinfo *info, void *data); >> void *ofono_devinfo_get_data(struct ofono_devinfo *info); >> >> +const char *ofono_devinfo_get_serial(struct ofono_devinfo *info); >> + >> #ifdef __cplusplus >> } >> #endif >> diff --git a/src/modem.c b/src/modem.c >> index 14c7a20..aa6b1c6 100644 >> --- a/src/modem.c >> +++ b/src/modem.c >> @@ -72,6 +72,7 @@ struct ofono_modem { >> ofono_bool_t powered_pending; >> ofono_bool_t get_online; >> ofono_bool_t lockdown; >> + ofono_bool_t pending_post_sim; >> char *lock_owner; >> guint lock_watch; >> guint timeout; >> @@ -1093,9 +1094,14 @@ static DBusMessage *modem_set_property(DBusConnection *conn, >> if (powered) { >> modem_change_state(modem, MODEM_STATE_PRE_SIM); >> >> - /* Force SIM Ready for devies with no sim atom */ >> + /* >> + * Force SIM Ready for devices with no sim atom >> + * Pratically, it concerns CDMA modems. We need to >> + * check if their serial is set before proceeding >> + * post_sim. >> + */ > This comment is not true, this behavior is mostly for HFP_HF devices, > not CDMA devices, and these don't even have a devinfo atom. So you are > breaking these now. I didn't thought about HFP_HF devices, I will fix this :) >> if (modem_has_sim(modem) == FALSE) >> - sim_state_watch(OFONO_SIM_STATE_READY, modem); >> + modem->pending_post_sim = TRUE; >> } else { >> set_online(modem, FALSE); >> modem_change_state(modem, MODEM_STATE_POWER_OFF); >> @@ -1175,7 +1181,7 @@ void ofono_modem_set_powered(struct ofono_modem *modem, ofono_bool_t powered) >> >> /* Force SIM Ready for devices with no sim atom */ >> if (modem_has_sim(modem) == FALSE) >> - sim_state_watch(OFONO_SIM_STATE_READY, modem); >> + modem->pending_post_sim = TRUE; >> } else { >> set_online(modem, FALSE); >> >> @@ -1315,18 +1321,29 @@ void ofono_modem_remove_interface(struct ofono_modem *modem, >> modem->interface_update = g_idle_add(trigger_interface_update, modem); >> } >> >> +const char *ofono_devinfo_get_serial(struct ofono_devinfo *info) >> +{ >> + return info->serial; >> +} >> + >> static void query_serial_cb(const struct ofono_error *error, >> const char *serial, void *user) >> { >> struct ofono_devinfo *info = user; >> DBusConnection *conn = ofono_dbus_get_connection(); >> const char *path = __ofono_atom_get_path(info->atom); >> + struct ofono_modem *modem = __ofono_atom_get_modem(info->atom); >> >> if (error->type != OFONO_ERROR_TYPE_NO_ERROR) >> return; >> >> info->serial = g_strdup(serial); >> >> + if (modem->pending_post_sim == TRUE) { >> + modem->pending_post_sim = FALSE; >> + sim_state_watch(OFONO_SIM_STATE_READY, modem); >> + } >> + >> ofono_dbus_signal_property_changed(conn, path, >> OFONO_MODEM_INTERFACE, >> "Serial", DBUS_TYPE_STRING, Kind regards, Guillaume ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH_v2 1/2] modem: Change to online state when serial is set 2011-08-12 6:34 ` Denis Kenzior 2011-08-22 8:20 ` Guillaume Zajac @ 2011-08-22 8:47 ` Guillaume Zajac 1 sibling, 0 replies; 6+ messages in thread From: Guillaume Zajac @ 2011-08-22 8:47 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 3928 bytes --] Hi again Denis, On 12/08/2011 08:34, Denis Kenzior wrote: > Hi Guillaume, > > On 08/11/2011 11:02 AM, Guillaume Zajac wrote: >> For modems with no sim atom, we wait for serial reply to proceed post_sim. >> Add API to get serial devinfo like it is done for imsi. >> --- >> include/devinfo.h | 2 ++ >> src/modem.c | 23 ++++++++++++++++++++--- >> 2 files changed, 22 insertions(+), 3 deletions(-) >> >> diff --git a/include/devinfo.h b/include/devinfo.h >> index 5df1316..db1db67 100644 >> --- a/include/devinfo.h >> +++ b/include/devinfo.h >> @@ -61,6 +61,8 @@ void ofono_devinfo_remove(struct ofono_devinfo *info); >> void ofono_devinfo_set_data(struct ofono_devinfo *info, void *data); >> void *ofono_devinfo_get_data(struct ofono_devinfo *info); >> >> +const char *ofono_devinfo_get_serial(struct ofono_devinfo *info); >> + >> #ifdef __cplusplus >> } >> #endif >> diff --git a/src/modem.c b/src/modem.c >> index 14c7a20..aa6b1c6 100644 >> --- a/src/modem.c >> +++ b/src/modem.c >> @@ -72,6 +72,7 @@ struct ofono_modem { >> ofono_bool_t powered_pending; >> ofono_bool_t get_online; >> ofono_bool_t lockdown; >> + ofono_bool_t pending_post_sim; >> char *lock_owner; >> guint lock_watch; >> guint timeout; >> @@ -1093,9 +1094,14 @@ static DBusMessage *modem_set_property(DBusConnection *conn, >> if (powered) { >> modem_change_state(modem, MODEM_STATE_PRE_SIM); >> >> - /* Force SIM Ready for devies with no sim atom */ >> + /* >> + * Force SIM Ready for devices with no sim atom >> + * Pratically, it concerns CDMA modems. We need to >> + * check if their serial is set before proceeding >> + * post_sim. >> + */ > This comment is not true, this behavior is mostly for HFP_HF devices, > not CDMA devices, and these don't even have a devinfo atom. So you are > breaking these now. > I have just seen on ConnMan that Marcel would like to have a cdma SIM atom into oFono core. Previously, I have heard that SIM atom for cdma modem was not appropriate: So should I give up this implementation and wait for the cdma SIM atom implementation to manage credentials like it is done for GSM modem? >> if (modem_has_sim(modem) == FALSE) >> - sim_state_watch(OFONO_SIM_STATE_READY, modem); >> + modem->pending_post_sim = TRUE; >> } else { >> set_online(modem, FALSE); >> modem_change_state(modem, MODEM_STATE_POWER_OFF); >> @@ -1175,7 +1181,7 @@ void ofono_modem_set_powered(struct ofono_modem *modem, ofono_bool_t powered) >> >> /* Force SIM Ready for devices with no sim atom */ >> if (modem_has_sim(modem) == FALSE) >> - sim_state_watch(OFONO_SIM_STATE_READY, modem); >> + modem->pending_post_sim = TRUE; >> } else { >> set_online(modem, FALSE); >> >> @@ -1315,18 +1321,29 @@ void ofono_modem_remove_interface(struct ofono_modem *modem, >> modem->interface_update = g_idle_add(trigger_interface_update, modem); >> } >> >> +const char *ofono_devinfo_get_serial(struct ofono_devinfo *info) >> +{ >> + return info->serial; >> +} >> + >> static void query_serial_cb(const struct ofono_error *error, >> const char *serial, void *user) >> { >> struct ofono_devinfo *info = user; >> DBusConnection *conn = ofono_dbus_get_connection(); >> const char *path = __ofono_atom_get_path(info->atom); >> + struct ofono_modem *modem = __ofono_atom_get_modem(info->atom); >> >> if (error->type != OFONO_ERROR_TYPE_NO_ERROR) >> return; >> >> info->serial = g_strdup(serial); >> >> + if (modem->pending_post_sim == TRUE) { >> + modem->pending_post_sim = FALSE; >> + sim_state_watch(OFONO_SIM_STATE_READY, modem); >> + } >> + >> ofono_dbus_signal_property_changed(conn, path, >> OFONO_MODEM_INTERFACE, >> "Serial", DBUS_TYPE_STRING, Kind regards, Guillaume ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH_v2 2/2] cdma-connman: Add feature to load/save credentials 2011-08-11 16:02 [PATCH_v2 0/2] Add CDMA features to load/save credentials Guillaume Zajac 2011-08-11 16:02 ` [PATCH_v2 1/2] modem: Change to online state when serial is set Guillaume Zajac @ 2011-08-11 16:02 ` Guillaume Zajac 1 sibling, 0 replies; 6+ messages in thread From: Guillaume Zajac @ 2011-08-11 16:02 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 3675 bytes --] --- src/cdma-connman.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 67 insertions(+), 0 deletions(-) diff --git a/src/cdma-connman.c b/src/cdma-connman.c index 0c9013b..0039eb0 100644 --- a/src/cdma-connman.c +++ b/src/cdma-connman.c @@ -37,6 +37,10 @@ #include "ofono.h" #include "common.h" +#include "storage.h" + +#define CREDENTIALS_STORE "cdma" +#define CREDENTIALS_GROUP "Credentials" static GSList *g_drivers; @@ -59,6 +63,8 @@ struct ofono_cdma_connman { struct ofono_atom *atom; char username[OFONO_CDMA_CONNMAN_MAX_USERNAME_LENGTH + 1]; char password[OFONO_CDMA_CONNMAN_MAX_PASSWORD_LENGTH + 1]; + GKeyFile *credentials; + char *serial; }; static void cdma_connman_settings_free(struct cdma_connman_settings *settings) @@ -387,6 +393,12 @@ static DBusMessage *cdma_connman_set_username(struct ofono_cdma_connman *cm, strcpy(cm->username, username); + if (cm->credentials) { + g_key_file_set_string(cm->credentials, CREDENTIALS_GROUP, + "Username", username); + storage_sync(cm->serial, CREDENTIALS_STORE, cm->credentials); + } + g_dbus_send_reply(conn, msg, DBUS_TYPE_INVALID); path = __ofono_atom_get_path(cm->atom); @@ -411,6 +423,12 @@ static DBusMessage *cdma_connman_set_password(struct ofono_cdma_connman *cm, strcpy(cm->password, password); + if (cm->credentials) { + g_key_file_set_string(cm->credentials, CREDENTIALS_GROUP, + "Password", password); + storage_sync(cm->serial, CREDENTIALS_STORE, cm->credentials); + } + g_dbus_send_reply(conn, msg, DBUS_TYPE_INVALID); path = __ofono_atom_get_path(cm->atom); @@ -552,6 +570,8 @@ static void cdma_connman_remove(struct ofono_atom *atom) if (cm->driver && cm->driver->remove) cm->driver->remove(cm); + g_free(cm->serial); + g_free(cm); } @@ -593,11 +613,48 @@ struct ofono_cdma_connman *ofono_cdma_connman_create( return cm; } +static void load_credentials(struct ofono_cdma_connman *cm, const char *serial) +{ + char *username = NULL; + char *password = NULL; + + DBG("Serial %s", serial); + + cm->credentials = storage_open(serial, CREDENTIALS_STORE); + if (cm->credentials == NULL) + return; + + cm->serial = g_strdup(serial); + + username = g_key_file_get_string(cm->credentials, + CREDENTIALS_GROUP, + "Username", NULL); + if (username == NULL) + goto error; + + password = g_key_file_get_string(cm->credentials, + CREDENTIALS_GROUP, + "Password", NULL); + if (password == NULL) + goto error; + + DBG("Usr %s Pwd %s", username, password); + strcpy(cm->username, username); + strcpy(cm->password, password); + + return; + +error: + g_free(username); + g_free(password); +} + void ofono_cdma_connman_register(struct ofono_cdma_connman *cm) { DBusConnection *conn = ofono_dbus_get_connection(); struct ofono_modem *modem = __ofono_atom_get_modem(cm->atom); const char *path = __ofono_atom_get_path(cm->atom); + struct ofono_atom *devinfo = NULL; DBG(""); @@ -613,6 +670,16 @@ void ofono_cdma_connman_register(struct ofono_cdma_connman *cm) ofono_modem_add_interface(modem, OFONO_CDMA_CONNECTION_MANAGER_INTERFACE); + devinfo = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_DEVINFO); + + if (devinfo != NULL) { + const char *serial; + struct ofono_devinfo *info = __ofono_atom_get_data(devinfo); + + serial = ofono_devinfo_get_serial(info); + load_credentials(cm, serial); + } + /* TODO: add watch to support CDMA Network Registration atom */ __ofono_atom_register(cm->atom, cdma_connman_unregister); -- 1.7.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-08-22 8:47 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-08-11 16:02 [PATCH_v2 0/2] Add CDMA features to load/save credentials Guillaume Zajac 2011-08-11 16:02 ` [PATCH_v2 1/2] modem: Change to online state when serial is set Guillaume Zajac 2011-08-12 6:34 ` Denis Kenzior 2011-08-22 8:20 ` Guillaume Zajac 2011-08-22 8:47 ` Guillaume Zajac 2011-08-11 16:02 ` [PATCH_v2 2/2] cdma-connman: Add feature to load/save credentials Guillaume Zajac
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox