* [PATCH_v2 1/4] cdma-connman: pass username and password to drivers while activating cdma-connman
2011-07-21 4:40 [PATCH_v2 0/4] CDMA-connman add username and password properties Guillaume Zajac
@ 2011-07-21 4:40 ` Guillaume Zajac
2011-07-21 9:52 ` Denis Kenzior
2011-07-21 4:40 ` [PATCH_v2 2/4] cdma-connman: add username and password, pass them to drivers Guillaume Zajac
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Guillaume Zajac @ 2011-07-21 4:40 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 961 bytes --]
---
include/cdma-connman.h | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/include/cdma-connman.h b/include/cdma-connman.h
index 22252e0..6a1c9ff 100644
--- a/include/cdma-connman.h
+++ b/include/cdma-connman.h
@@ -30,6 +30,9 @@ extern "C" {
struct ofono_cdma_connman;
+#define OFONO_CDMA_CONNMAN_MAX_USERNAME_LENGTH 63
+#define OFONO_CDMA_CONNMAN_MAX_PASSWORD_LENGTH 255
+
typedef void (*ofono_cdma_connman_cb_t)(const struct ofono_error *error,
void *data);
typedef void (*ofono_cdma_connman_up_cb_t)(const struct ofono_error *error,
@@ -47,6 +50,8 @@ struct ofono_cdma_connman_driver {
void *data);
void (*remove)(struct ofono_cdma_connman *cm);
void (*activate)(struct ofono_cdma_connman *cm,
+ const char *username,
+ const char *password,
ofono_cdma_connman_up_cb_t cb,
void *data);
void (*deactivate)(struct ofono_cdma_connman *cm,
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH_v2 2/4] cdma-connman: add username and password, pass them to drivers
2011-07-21 4:40 [PATCH_v2 0/4] CDMA-connman add username and password properties Guillaume Zajac
2011-07-21 4:40 ` [PATCH_v2 1/4] cdma-connman: pass username and password to drivers while activating cdma-connman Guillaume Zajac
@ 2011-07-21 4:40 ` Guillaume Zajac
2011-07-21 9:54 ` Denis Kenzior
2011-07-21 4:40 ` [PATCH_v2 3/4] driver cdma-connman: pass credentials into activate function Guillaume Zajac
2011-07-21 4:40 ` [PATCH_v2 4/4] test: add script to set credentials for cdma connection Guillaume Zajac
3 siblings, 1 reply; 9+ messages in thread
From: Guillaume Zajac @ 2011-07-21 4:40 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3017 bytes --]
---
src/cdma-connman.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 47 insertions(+), 1 deletions(-)
diff --git a/src/cdma-connman.c b/src/cdma-connman.c
index 3321b87..4466dee 100644
--- a/src/cdma-connman.c
+++ b/src/cdma-connman.c
@@ -57,6 +57,8 @@ struct ofono_cdma_connman {
const struct ofono_cdma_connman_driver *driver;
void *driver_data;
struct ofono_atom *atom;
+ char username[OFONO_CDMA_CONNMAN_MAX_USERNAME_LENGTH + 1];
+ char password[OFONO_CDMA_CONNMAN_MAX_PASSWORD_LENGTH + 1];
};
static void cdma_connman_settings_free(struct cdma_connman_settings *settings)
@@ -371,6 +373,36 @@ static DBusMessage *cdma_connman_get_properties(DBusConnection *conn,
return reply;
}
+static DBusMessage *cdma_connman_set_username(struct ofono_cdma_connman *cm,
+ DBusConnection *conn, DBusMessage *msg,
+ const char *username)
+{
+ if (strlen(username) > OFONO_CDMA_CONNMAN_MAX_USERNAME_LENGTH)
+ return __ofono_error_invalid_format(msg);
+
+ if (g_str_equal(username, cm->username))
+ return dbus_message_new_method_return(msg);
+
+ strcpy(cm->username, username);
+
+ return dbus_message_new_method_return(msg);
+}
+
+static DBusMessage *cdma_connman_set_password(struct ofono_cdma_connman *cm,
+ DBusConnection *conn, DBusMessage *msg,
+ const char *password)
+{
+ if (strlen(password) > OFONO_CDMA_CONNMAN_MAX_PASSWORD_LENGTH)
+ return __ofono_error_invalid_format(msg);
+
+ if (g_str_equal(password, cm->password))
+ return dbus_message_new_method_return(msg);
+
+ strcpy(cm->password, password);
+
+ return dbus_message_new_method_return(msg);
+}
+
static DBusMessage *cdma_connman_set_property(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -379,6 +411,7 @@ static DBusMessage *cdma_connman_set_property(DBusConnection *conn,
DBusMessageIter var;
const char *property;
dbus_bool_t value;
+ const char *str;
DBG("");
@@ -416,11 +449,24 @@ static DBusMessage *cdma_connman_set_property(DBusConnection *conn,
/* TODO: add logic to support CDMA Network Registration */
if (value)
- cm->driver->activate(cm, activate_callback, cm);
+ cm->driver->activate(cm, cm->username, cm->password,
+ activate_callback, cm);
else
cm->driver->deactivate(cm, deactivate_callback, cm);
return dbus_message_new_method_return(msg);
+ } else if (!strcmp(property, "Username")) {
+ if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING)
+ return __ofono_error_invalid_args(msg);
+
+ dbus_message_iter_get_basic(&var, &str);
+ return cdma_connman_set_username(cm, conn, msg, str);
+ } else if (!strcmp(property, "Password")) {
+ if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING)
+ return __ofono_error_invalid_args(msg);
+
+ dbus_message_iter_get_basic(&var, &str);
+ return cdma_connman_set_password(cm, conn, msg, str);
}
/* TODO: Dormant property. Not yet supported. */
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH_v2 2/4] cdma-connman: add username and password, pass them to drivers
2011-07-21 4:40 ` [PATCH_v2 2/4] cdma-connman: add username and password, pass them to drivers Guillaume Zajac
@ 2011-07-21 9:54 ` Denis Kenzior
0 siblings, 0 replies; 9+ messages in thread
From: Denis Kenzior @ 2011-07-21 9:54 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1630 bytes --]
Hi Guillaume,
On 07/20/2011 11:40 PM, Guillaume Zajac wrote:
> ---
> src/cdma-connman.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
> 1 files changed, 47 insertions(+), 1 deletions(-)
>
I applied this patch, with a follow on commit afterwards:
> @@ -371,6 +373,36 @@ static DBusMessage *cdma_connman_get_properties(DBusConnection *conn,
> return reply;
> }
>
> +static DBusMessage *cdma_connman_set_username(struct ofono_cdma_connman *cm,
> + DBusConnection *conn, DBusMessage *msg,
> + const char *username)
> +{
> + if (strlen(username) > OFONO_CDMA_CONNMAN_MAX_USERNAME_LENGTH)
> + return __ofono_error_invalid_format(msg);
> +
> + if (g_str_equal(username, cm->username))
> + return dbus_message_new_method_return(msg);
> +
> + strcpy(cm->username, username);
> +
> + return dbus_message_new_method_return(msg);
When you're changing a property, you really must signal PropertyChanged
as well.
> +}
> +
> +static DBusMessage *cdma_connman_set_password(struct ofono_cdma_connman *cm,
> + DBusConnection *conn, DBusMessage *msg,
> + const char *password)
> +{
> + if (strlen(password) > OFONO_CDMA_CONNMAN_MAX_PASSWORD_LENGTH)
> + return __ofono_error_invalid_format(msg);
> +
> + if (g_str_equal(password, cm->password))
> + return dbus_message_new_method_return(msg);
> +
> + strcpy(cm->password, password);
> +
> + return dbus_message_new_method_return(msg);
same comment as above.
> +}
> +
> static DBusMessage *cdma_connman_set_property(DBusConnection *conn,
> DBusMessage *msg, void *data)
> {
Regards,
-Denis
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH_v2 3/4] driver cdma-connman: pass credentials into activate function
2011-07-21 4:40 [PATCH_v2 0/4] CDMA-connman add username and password properties Guillaume Zajac
2011-07-21 4:40 ` [PATCH_v2 1/4] cdma-connman: pass username and password to drivers while activating cdma-connman Guillaume Zajac
2011-07-21 4:40 ` [PATCH_v2 2/4] cdma-connman: add username and password, pass them to drivers Guillaume Zajac
@ 2011-07-21 4:40 ` Guillaume Zajac
2011-07-21 9:54 ` Denis Kenzior
2011-07-21 4:40 ` [PATCH_v2 4/4] test: add script to set credentials for cdma connection Guillaume Zajac
3 siblings, 1 reply; 9+ messages in thread
From: Guillaume Zajac @ 2011-07-21 4:40 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1530 bytes --]
---
drivers/cdmamodem/connman.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/drivers/cdmamodem/connman.c b/drivers/cdmamodem/connman.c
index 14c78b1..ce9a748 100644
--- a/drivers/cdmamodem/connman.c
+++ b/drivers/cdmamodem/connman.c
@@ -56,6 +56,8 @@ struct connman_data {
GAtChat *chat;
GAtPPP *ppp;
enum state state;
+ char username[OFONO_CDMA_CONNMAN_MAX_USERNAME_LENGTH + 1];
+ char password[OFONO_CDMA_CONNMAN_MAX_PASSWORD_LENGTH + 1];
union {
ofono_cdma_connman_cb_t down_cb; /* Down callback */
ofono_cdma_connman_up_cb_t up_cb; /* Up callback */
@@ -145,6 +147,8 @@ static gboolean setup_ppp(struct ofono_cdma_connman *cm)
g_at_ppp_set_connect_function(cd->ppp, ppp_connect, cm);
g_at_ppp_set_disconnect_function(cd->ppp, ppp_disconnect, cm);
+ g_at_ppp_set_credentials(cd->ppp, cd->username, cd->password);
+
/* open the ppp connection */
g_at_ppp_open(cd->ppp, io);
@@ -175,6 +179,8 @@ static void atd_cb(gboolean ok, GAtResult *result, gpointer user_data)
}
static void cdma_connman_activate(struct ofono_cdma_connman *cm,
+ const char *username,
+ const char *password,
ofono_cdma_connman_up_cb_t cb,
void *data)
{
@@ -185,6 +191,9 @@ static void cdma_connman_activate(struct ofono_cdma_connman *cm,
cd->up_cb = cb;
cd->cb_data = data;
+ strcpy(cd->username, username);
+ strcpy(cd->password, password);
+
cd->state = STATE_ENABLING;
sprintf(buf, "ATD#777");
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH_v2 4/4] test: add script to set credentials for cdma connection
2011-07-21 4:40 [PATCH_v2 0/4] CDMA-connman add username and password properties Guillaume Zajac
` (2 preceding siblings ...)
2011-07-21 4:40 ` [PATCH_v2 3/4] driver cdma-connman: pass credentials into activate function Guillaume Zajac
@ 2011-07-21 4:40 ` Guillaume Zajac
2011-07-21 9:56 ` Denis Kenzior
3 siblings, 1 reply; 9+ messages in thread
From: Guillaume Zajac @ 2011-07-21 4:40 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1138 bytes --]
---
test/create-cdma-credentials | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
create mode 100755 test/create-cdma-credentials
diff --git a/test/create-cdma-credentials b/test/create-cdma-credentials
new file mode 100755
index 0000000..0f52a98
--- /dev/null
+++ b/test/create-cdma-credentials
@@ -0,0 +1,29 @@
+#!/usr/bin/python
+
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+manager = dbus.Interface(bus.get_object('org.ofono', '/'),
+ 'org.ofono.Manager')
+
+modems = manager.GetModems()
+
+for path, properties in modems:
+ if "org.ofono.cdma.ConnectionManager" not in properties["Interfaces"]:
+ continue
+
+ cm = dbus.Interface(bus.get_object('org.ofono', path),
+ 'org.ofono.cdma.ConnectionManager')
+
+ print "Connecting CDMA Packet Data Service on modem %s..." % path
+
+ if len(sys.argv) > 1:
+ cm.SetProperty("Username", (sys.argv[1]))
+ print "Setting Username to %s" % (sys.argv[1])
+
+ if len(sys.argv) > 2:
+ cm.SetProperty("Password", (sys.argv[2]))
+ print "Setting Password to %s" % (sys.argv[2])
+
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread