[PATCH 3/5] connectivity: Add the private member login_url



From: Jonh Wendell <jonh wendell oiwifi com br>

It will contain, in the case we are behind a captive portal,
the url to login at the captive portal.

Signed-off-by: Jonh Wendell <jonh wendell oiwifi com br>
---
 src/nm-connectivity.c | 22 ++++++++++++++++++++++
 src/nm-connectivity.h | 15 +++++++++------
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/src/nm-connectivity.c b/src/nm-connectivity.c
index 51c1a5e..6f63670 100644
--- a/src/nm-connectivity.c
+++ b/src/nm-connectivity.c
@@ -51,6 +51,8 @@ typedef struct {
 	NMConnectivityState state;
 	/* the source id for the periodic check */
 	guint check_id;
+	/* if we are behind a captive portal, this is the url it redirects us */
+	char *login_url;
 } NMConnectivityPrivate;
 
 enum {
@@ -60,6 +62,7 @@ enum {
 	PROP_INTERVAL,
 	PROP_RESPONSE,
 	PROP_STATE,
+	PROP_LOGIN_URL,
 	LAST_PROP
 };
 
@@ -72,6 +75,14 @@ nm_connectivity_get_state (NMConnectivity *connectivity)
 	return NM_CONNECTIVITY_GET_PRIVATE (connectivity)->state;
 }
 
+const char *
+nm_connectivity_get_login_url (NMConnectivity *connectivity)
+{
+	g_return_val_if_fail (NM_IS_CONNECTIVITY (connectivity), NULL);
+
+	return NM_CONNECTIVITY_GET_PRIVATE (connectivity)->login_url;
+}
+
 static void
 update_state (NMConnectivity *self, NMConnectivityState state)
 {
@@ -273,6 +284,9 @@ get_property (GObject *object, guint property_id,
 	case PROP_STATE:
 		g_value_set_enum (value, priv->state);
 		break;
+	case PROP_LOGIN_URL:
+		g_value_set_string (value, priv->login_url);
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 		break;
@@ -363,5 +377,13 @@ nm_connectivity_class_init (NMConnectivityClass *klass)
 		                    NM_TYPE_CONNECTIVITY_STATE,
 		                    NM_CONNECTIVITY_STATE_NOT_CONNECTED,
 		                    G_PARAM_READABLE));
+
+	g_object_class_install_property
+		(object_class, PROP_LOGIN_URL,
+		 g_param_spec_string (NM_CONNECTIVITY_LOGIN_URL,
+		                      "Login URL",
+		                      "URL for login as supplied by the captive portal",
+		                      NULL,
+		                      G_PARAM_READABLE));
 }
 
diff --git a/src/nm-connectivity.h b/src/nm-connectivity.h
index c5ca692..1d62a67 100644
--- a/src/nm-connectivity.h
+++ b/src/nm-connectivity.h
@@ -40,6 +40,7 @@
 #define NM_CONNECTIVITY_INTERVAL  "interval"
 #define NM_CONNECTIVITY_RESPONSE  "response"
 #define NM_CONNECTIVITY_STATE     "state"
+#define NM_CONNECTIVITY_LOGIN_URL "login-url"
 
 typedef enum {
 	NM_CONNECTIVITY_STATE_NOT_CONNECTED,
@@ -58,14 +59,16 @@ typedef struct {
 GType nm_connectivity_get_type (void);
 
 
-NMConnectivity *nm_connectivity_new           (const gchar *check_uri,
-                                               guint check_interval,
-                                               const gchar *check_response);
+NMConnectivity *    nm_connectivity_new           (const gchar *check_uri,
+                                                   guint check_interval,
+                                                   const gchar *check_response);
 
-void                nm_connectivity_start_check (NMConnectivity *connectivity);
+void                nm_connectivity_start_check   (NMConnectivity *connectivity);
 
-void                nm_connectivity_stop_check  (NMConnectivity *connectivity);
+void                nm_connectivity_stop_check    (NMConnectivity *connectivity);
 
-NMConnectivityState nm_connectivity_get_state   (NMConnectivity *connectivity);
+NMConnectivityState nm_connectivity_get_state     (NMConnectivity *connectivity);
+
+const char *        nm_connectivity_get_login_url (NMConnectivity *connectivity);
 
 #endif /* NM_CONNECTIVITY_H */
-- 
1.8.1.2



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]