All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH_v2 2/4] cdma-connman: add username and password, pass them to drivers
Date: Thu, 21 Jul 2011 06:40:42 +0200	[thread overview]
Message-ID: <1311223244-26904-3-git-send-email-guillaume.zajac@linux.intel.com> (raw)
In-Reply-To: <1311223244-26904-1-git-send-email-guillaume.zajac@linux.intel.com>

[-- 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


  parent reply	other threads:[~2011-07-21  4:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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  9:52   ` Denis Kenzior
2011-07-21  4:40 ` Guillaume Zajac [this message]
2011-07-21  9:54   ` [PATCH_v2 2/4] cdma-connman: add username and password, pass them to drivers Denis Kenzior
2011-07-21  4:40 ` [PATCH_v2 3/4] driver cdma-connman: pass credentials into activate function 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
2011-07-21  9:56   ` Denis Kenzior

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=1311223244-26904-3-git-send-email-guillaume.zajac@linux.intel.com \
    --to=guillaume.zajac@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 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.