[PATCH 06/11] wispr: added WISPr XML content parser.
--- src/wispr.c | 220 +++ 1 files changed, 220 insertions(+), 0 deletions(-) diff --git a/src/wispr.c b/src/wispr.c index 9e3b0e3..4cda5ed 100644 --- a/src/wispr.c +++ b/src/wispr.c @@ -32,6 +32,19 @@ #define STATUS_URL "http://www.connman.net/online/status.html"; +struct connman_wispr_message { + gboolean has_error; + const char *current_element; + int message_type; + int response_code; + char *login_url; + char *abort_login_url; + char *logoff_url; + char *access_procedure; + char *access_location; + char *location_name; +}; + struct connman_wispr_portal_context { struct connman_service *service; enum connman_ipconfig_type type; @@ -40,6 +53,10 @@ struct connman_wispr_portal_context { GWeb *web; unsigned int token; guint request_id; + + /* WISPr specific */ + GWebParser *wispr_parser; + struct connman_wispr_message wispr_msg; }; struct connman_wispr_portal { @@ -49,6 +66,35 @@ struct connman_wispr_portal { static GHashTable *wispr_portal_list = NULL; +static void connman_wispr_message_init(struct connman_wispr_message *msg) +{ + DBG(""); + + msg->has_error = FALSE; + msg->current_element = NULL; + + msg->message_type = -1; + msg->response_code = -1; + + g_free(msg->login_url); + msg->login_url = NULL; + + g_free(msg->abort_login_url); + msg->abort_login_url = NULL; + + g_free(msg->logoff_url); + msg->logoff_url = NULL; + + g_free(msg->access_procedure); + msg->access_procedure = NULL; + + g_free(msg->access_location); + msg->access_location = NULL; + + g_free(msg->location_name); + msg->location_name = NULL; +} + static void free_connman_wispr_portal_context(struct connman_wispr_portal_context *wp_context) { DBG(""); @@ -64,6 +110,9 @@ static void free_connman_wispr_portal_context(struct connman_wispr_portal_contex g_web_unref(wp_context->web); + g_web_parser_unref(wp_context->wispr_parser); + connman_wispr_message_init(&wp_context->wispr_msg); + g_free(wp_context); } @@ -82,6 +131,151 @@ static void free_connman_wispr_portal(gpointer data) g_free(wispr_portal); } +static struct { + const char *str; + enum { + WISPR_ELEMENT_NONE = 0, + WISPR_ELEMENT_ACCESS_PROCEDURE = 1, + WISPR_ELEMENT_ACCESS_LOCATION = 2, + WISPR_ELEMENT_LOCATION_NAME = 3, + WISPR_ELEMENT_LOGIN_URL = 4, + WISPR_ELEMENT_ABORT_LOGIN_URL = 5, + WISPR_ELEMENT_MESSAGE_TYPE = 6, + WISPR_ELEMENT_RESPONSE_CODE = 7, + WISPR_ELEMENT_NEXT_URL = 8, + WISPR_ELEMENT_DELAY = 9, + WISPR_ELEMENT_REPLY_MESSAGE = 10, + WISPR_ELEMENT_LOGIN_RESULTS_URL = 11, + WISPR_ELEMENT_LOGOFF_URL= 12, + } element; +} wispr_element_map[] = { + { "AccessProcedure",WISPR_ELEMENT_ACCESS_PROCEDURE }, + { "AccessLocation", WISPR_ELEMENT_ACCESS_LOCATION }, + { "LocationName", WISPR_ELEMENT_LOCATION_NAME }, + { "LoginURL", WISPR_ELEMENT_LOGIN_URL }, + { "AbortLoginURL", WISPR_ELEMENT_ABORT_LOGIN_URL }, + { "MessageType",WISPR_ELEMENT_MESSAGE_TYPE }, + { "ResponseCode", WISPR_ELEMENT_RESPONSE_CODE }, + { "NextURL",WISPR_ELEMENT_NEXT_URL }, + { "Delay", WISPR_ELEMENT_DELAY }, + { "ReplyMessage", WISPR_ELEMENT_REPLY_MESSAGE }, + { "LoginResultsURL",WISPR_ELEMENT_LOGIN_RESULTS_URL }, + { "LogoffURL", WISPR_ELEMENT_LOGOFF_URL}, + { NULL, WISPR_ELEMENT_NONE }, +}; + +static void xml_wispr_start_element_handler(GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + gpointer user_data, GError **error) +{ + struct connman_wispr_message *msg = user_data; + + msg->current_element = element_name; +} + +static void xml_wispr_end_element_handler(GMarkupParseContext *context, + const gchar *element_name, + gpointer user_data, GError **error) +{ + struct connman_wispr_message *msg = user_data; + + msg->current_element = NULL; +} + +static void xml_wispr_text_handler(GMarkupParseContext *context, + const gchar *text, gsize text_len, + gp
[PATCH 06/11] wispr: added WISPr XML content parser.
--- src/wispr.c | 220 +++ 1 files changed, 220 insertions(+), 0 deletions(-) diff --git a/src/wispr.c b/src/wispr.c index 9e3b0e3..4cda5ed 100644 --- a/src/wispr.c +++ b/src/wispr.c @@ -32,6 +32,19 @@ #define STATUS_URL "http://www.connman.net/online/status.html"; +struct connman_wispr_message { + gboolean has_error; + const char *current_element; + int message_type; + int response_code; + char *login_url; + char *abort_login_url; + char *logoff_url; + char *access_procedure; + char *access_location; + char *location_name; +}; + struct connman_wispr_portal_context { struct connman_service *service; enum connman_ipconfig_type type; @@ -40,6 +53,10 @@ struct connman_wispr_portal_context { GWeb *web; unsigned int token; guint request_id; + + /* WISPr specific */ + GWebParser *wispr_parser; + struct connman_wispr_message wispr_msg; }; struct connman_wispr_portal { @@ -49,6 +66,35 @@ struct connman_wispr_portal { static GHashTable *wispr_portal_list = NULL; +static void connman_wispr_message_init(struct connman_wispr_message *msg) +{ + DBG(""); + + msg->has_error = FALSE; + msg->current_element = NULL; + + msg->message_type = -1; + msg->response_code = -1; + + g_free(msg->login_url); + msg->login_url = NULL; + + g_free(msg->abort_login_url); + msg->abort_login_url = NULL; + + g_free(msg->logoff_url); + msg->logoff_url = NULL; + + g_free(msg->access_procedure); + msg->access_procedure = NULL; + + g_free(msg->access_location); + msg->access_location = NULL; + + g_free(msg->location_name); + msg->location_name = NULL; +} + static void free_connman_wispr_portal_context(struct connman_wispr_portal_context *wp_context) { DBG(""); @@ -64,6 +110,9 @@ static void free_connman_wispr_portal_context(struct connman_wispr_portal_contex g_web_unref(wp_context->web); + g_web_parser_unref(wp_context->wispr_parser); + connman_wispr_message_init(&wp_context->wispr_msg); + g_free(wp_context); } @@ -82,6 +131,151 @@ static void free_connman_wispr_portal(gpointer data) g_free(wispr_portal); } +static struct { + const char *str; + enum { + WISPR_ELEMENT_NONE = 0, + WISPR_ELEMENT_ACCESS_PROCEDURE = 1, + WISPR_ELEMENT_ACCESS_LOCATION = 2, + WISPR_ELEMENT_LOCATION_NAME = 3, + WISPR_ELEMENT_LOGIN_URL = 4, + WISPR_ELEMENT_ABORT_LOGIN_URL = 5, + WISPR_ELEMENT_MESSAGE_TYPE = 6, + WISPR_ELEMENT_RESPONSE_CODE = 7, + WISPR_ELEMENT_NEXT_URL = 8, + WISPR_ELEMENT_DELAY = 9, + WISPR_ELEMENT_REPLY_MESSAGE = 10, + WISPR_ELEMENT_LOGIN_RESULTS_URL = 11, + WISPR_ELEMENT_LOGOFF_URL= 12, + } element; +} wispr_element_map[] = { + { "AccessProcedure",WISPR_ELEMENT_ACCESS_PROCEDURE }, + { "AccessLocation", WISPR_ELEMENT_ACCESS_LOCATION }, + { "LocationName", WISPR_ELEMENT_LOCATION_NAME }, + { "LoginURL", WISPR_ELEMENT_LOGIN_URL }, + { "AbortLoginURL", WISPR_ELEMENT_ABORT_LOGIN_URL }, + { "MessageType",WISPR_ELEMENT_MESSAGE_TYPE }, + { "ResponseCode", WISPR_ELEMENT_RESPONSE_CODE }, + { "NextURL",WISPR_ELEMENT_NEXT_URL }, + { "Delay", WISPR_ELEMENT_DELAY }, + { "ReplyMessage", WISPR_ELEMENT_REPLY_MESSAGE }, + { "LoginResultsURL",WISPR_ELEMENT_LOGIN_RESULTS_URL }, + { "LogoffURL", WISPR_ELEMENT_LOGOFF_URL}, + { NULL, WISPR_ELEMENT_NONE }, +}; + +static void xml_wispr_start_element_handler(GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + gpointer user_data, GError **error) +{ + struct connman_wispr_message *msg = user_data; + + msg->current_element = element_name; +} + +static void xml_wispr_end_element_handler(GMarkupParseContext *context, + const gchar *element_name, + gpointer user_data, GError **error) +{ + struct connman_wispr_message *msg = user_data; + + msg->current_element = NULL; +} + +static void xml_wispr_text_handler(GMarkupParseContext *context, + const gchar *text, gsize text_len, + gp
[PATCH 06/11] wispr: added WISPr XML content parser.
--- src/wispr.c | 220 +++ 1 files changed, 220 insertions(+), 0 deletions(-) diff --git a/src/wispr.c b/src/wispr.c index 9e3b0e3..4cda5ed 100644 --- a/src/wispr.c +++ b/src/wispr.c @@ -32,6 +32,19 @@ #define STATUS_URL "http://www.connman.net/online/status.html"; +struct connman_wispr_message { + gboolean has_error; + const char *current_element; + int message_type; + int response_code; + char *login_url; + char *abort_login_url; + char *logoff_url; + char *access_procedure; + char *access_location; + char *location_name; +}; + struct connman_wispr_portal_context { struct connman_service *service; enum connman_ipconfig_type type; @@ -40,6 +53,10 @@ struct connman_wispr_portal_context { GWeb *web; unsigned int token; guint request_id; + + /* WISPr specific */ + GWebParser *wispr_parser; + struct connman_wispr_message wispr_msg; }; struct connman_wispr_portal { @@ -49,6 +66,35 @@ struct connman_wispr_portal { static GHashTable *wispr_portal_list = NULL; +static void connman_wispr_message_init(struct connman_wispr_message *msg) +{ + DBG(""); + + msg->has_error = FALSE; + msg->current_element = NULL; + + msg->message_type = -1; + msg->response_code = -1; + + g_free(msg->login_url); + msg->login_url = NULL; + + g_free(msg->abort_login_url); + msg->abort_login_url = NULL; + + g_free(msg->logoff_url); + msg->logoff_url = NULL; + + g_free(msg->access_procedure); + msg->access_procedure = NULL; + + g_free(msg->access_location); + msg->access_location = NULL; + + g_free(msg->location_name); + msg->location_name = NULL; +} + static void free_connman_wispr_portal_context(struct connman_wispr_portal_context *wp_context) { DBG(""); @@ -64,6 +110,9 @@ static void free_connman_wispr_portal_context(struct connman_wispr_portal_contex g_web_unref(wp_context->web); + g_web_parser_unref(wp_context->wispr_parser); + connman_wispr_message_init(&wp_context->wispr_msg); + g_free(wp_context); } @@ -82,6 +131,151 @@ static void free_connman_wispr_portal(gpointer data) g_free(wispr_portal); } +static struct { + const char *str; + enum { + WISPR_ELEMENT_NONE = 0, + WISPR_ELEMENT_ACCESS_PROCEDURE = 1, + WISPR_ELEMENT_ACCESS_LOCATION = 2, + WISPR_ELEMENT_LOCATION_NAME = 3, + WISPR_ELEMENT_LOGIN_URL = 4, + WISPR_ELEMENT_ABORT_LOGIN_URL = 5, + WISPR_ELEMENT_MESSAGE_TYPE = 6, + WISPR_ELEMENT_RESPONSE_CODE = 7, + WISPR_ELEMENT_NEXT_URL = 8, + WISPR_ELEMENT_DELAY = 9, + WISPR_ELEMENT_REPLY_MESSAGE = 10, + WISPR_ELEMENT_LOGIN_RESULTS_URL = 11, + WISPR_ELEMENT_LOGOFF_URL= 12, + } element; +} wispr_element_map[] = { + { "AccessProcedure",WISPR_ELEMENT_ACCESS_PROCEDURE }, + { "AccessLocation", WISPR_ELEMENT_ACCESS_LOCATION }, + { "LocationName", WISPR_ELEMENT_LOCATION_NAME }, + { "LoginURL", WISPR_ELEMENT_LOGIN_URL }, + { "AbortLoginURL", WISPR_ELEMENT_ABORT_LOGIN_URL }, + { "MessageType",WISPR_ELEMENT_MESSAGE_TYPE }, + { "ResponseCode", WISPR_ELEMENT_RESPONSE_CODE }, + { "NextURL",WISPR_ELEMENT_NEXT_URL }, + { "Delay", WISPR_ELEMENT_DELAY }, + { "ReplyMessage", WISPR_ELEMENT_REPLY_MESSAGE }, + { "LoginResultsURL",WISPR_ELEMENT_LOGIN_RESULTS_URL }, + { "LogoffURL", WISPR_ELEMENT_LOGOFF_URL}, + { NULL, WISPR_ELEMENT_NONE }, +}; + +static void xml_wispr_start_element_handler(GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + gpointer user_data, GError **error) +{ + struct connman_wispr_message *msg = user_data; + + msg->current_element = element_name; +} + +static void xml_wispr_end_element_handler(GMarkupParseContext *context, + const gchar *element_name, + gpointer user_data, GError **error) +{ + struct connman_wispr_message *msg = user_data; + + msg->current_element = NULL; +} + +static void xml_wispr_text_handler(GMarkupParseContext *context, + const gchar *text, gsize text_len, + gp
[PATCH 06/11] wispr: added WISPr XML content parser.
--- src/wispr.c | 220 +++ 1 files changed, 220 insertions(+), 0 deletions(-) diff --git a/src/wispr.c b/src/wispr.c index e079316..6a7e603 100644 --- a/src/wispr.c +++ b/src/wispr.c @@ -32,6 +32,19 @@ #define STATUS_URL "http://www.connman.net/online/status.html"; +struct connman_wispr_message { + gboolean has_error; + const char *current_element; + int message_type; + int response_code; + char *login_url; + char *abort_login_url; + char *logoff_url; + char *access_procedure; + char *access_location; + char *location_name; +}; + struct connman_wispr_portal_context { struct connman_service *service; enum connman_ipconfig_type type; @@ -40,6 +53,10 @@ struct connman_wispr_portal_context { GWeb *web; unsigned int token; guint request_id; + + /* WISPr specific */ + GWebParser *wispr_parser; + struct connman_wispr_message wispr_msg; }; struct connman_wispr_portal { @@ -49,6 +66,35 @@ struct connman_wispr_portal { static GHashTable *wispr_portal_list = NULL; +static void connman_wispr_message_init(struct connman_wispr_message *msg) +{ + DBG(""); + + msg->has_error = FALSE; + msg->current_element = NULL; + + msg->message_type = -1; + msg->response_code = -1; + + g_free(msg->login_url); + msg->login_url = NULL; + + g_free(msg->abort_login_url); + msg->abort_login_url = NULL; + + g_free(msg->logoff_url); + msg->logoff_url = NULL; + + g_free(msg->access_procedure); + msg->access_procedure = NULL; + + g_free(msg->access_location); + msg->access_location = NULL; + + g_free(msg->location_name); + msg->location_name = NULL; +} + static void free_connman_wispr_portal_context(struct connman_wispr_portal_context *wp_context) { DBG(""); @@ -64,6 +110,9 @@ static void free_connman_wispr_portal_context(struct connman_wispr_portal_contex g_web_unref(wp_context->web); + g_web_parser_unref(wp_context->wispr_parser); + connman_wispr_message_init(&wp_context->wispr_msg); + g_free(wp_context); } @@ -82,6 +131,151 @@ static void free_connman_wispr_portal(gpointer data) g_free(wispr_portal); } +static struct { + const char *str; + enum { + WISPR_ELEMENT_NONE = 0, + WISPR_ELEMENT_ACCESS_PROCEDURE = 1, + WISPR_ELEMENT_ACCESS_LOCATION = 2, + WISPR_ELEMENT_LOCATION_NAME = 3, + WISPR_ELEMENT_LOGIN_URL = 4, + WISPR_ELEMENT_ABORT_LOGIN_URL = 5, + WISPR_ELEMENT_MESSAGE_TYPE = 6, + WISPR_ELEMENT_RESPONSE_CODE = 7, + WISPR_ELEMENT_NEXT_URL = 8, + WISPR_ELEMENT_DELAY = 9, + WISPR_ELEMENT_REPLY_MESSAGE = 10, + WISPR_ELEMENT_LOGIN_RESULTS_URL = 11, + WISPR_ELEMENT_LOGOFF_URL= 12, + } element; +} wispr_element_map[] = { + { "AccessProcedure",WISPR_ELEMENT_ACCESS_PROCEDURE }, + { "AccessLocation", WISPR_ELEMENT_ACCESS_LOCATION }, + { "LocationName", WISPR_ELEMENT_LOCATION_NAME }, + { "LoginURL", WISPR_ELEMENT_LOGIN_URL }, + { "AbortLoginURL", WISPR_ELEMENT_ABORT_LOGIN_URL }, + { "MessageType",WISPR_ELEMENT_MESSAGE_TYPE }, + { "ResponseCode", WISPR_ELEMENT_RESPONSE_CODE }, + { "NextURL",WISPR_ELEMENT_NEXT_URL }, + { "Delay", WISPR_ELEMENT_DELAY }, + { "ReplyMessage", WISPR_ELEMENT_REPLY_MESSAGE }, + { "LoginResultsURL",WISPR_ELEMENT_LOGIN_RESULTS_URL }, + { "LogoffURL", WISPR_ELEMENT_LOGOFF_URL}, + { NULL, WISPR_ELEMENT_NONE }, +}; + +static void xml_wispr_start_element_handler(GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + gpointer user_data, GError **error) +{ + struct connman_wispr_message *msg = user_data; + + msg->current_element = element_name; +} + +static void xml_wispr_end_element_handler(GMarkupParseContext *context, + const gchar *element_name, + gpointer user_data, GError **error) +{ + struct connman_wispr_message *msg = user_data; + + msg->current_element = NULL; +} + +static void xml_wispr_text_handler(GMarkupParseContext *context, + const gchar *text, gsize text_len, + gp
[PATCH 06/11] wispr: added WISPr XML content parser.
--- src/wispr.c | 220 +++ 1 files changed, 220 insertions(+), 0 deletions(-) diff --git a/src/wispr.c b/src/wispr.c index 7c1e5a4..ef78770 100644 --- a/src/wispr.c +++ b/src/wispr.c @@ -32,6 +32,19 @@ #define STATUS_URL "http://www.connman.net/online/status.html"; +struct connman_wispr_message { + gboolean has_error; + const char *current_element; + int message_type; + int response_code; + char *login_url; + char *abort_login_url; + char *logoff_url; + char *access_procedure; + char *access_location; + char *location_name; +}; + struct connman_wispr_portal_context { struct connman_service *service; enum connman_ipconfig_type type; @@ -40,6 +53,10 @@ struct connman_wispr_portal_context { GWeb *web; unsigned int token; guint request_id; + + /* WISPr specific */ + GWebParser *wispr_parser; + struct connman_wispr_message wispr_msg; }; struct connman_wispr_portal { @@ -49,6 +66,35 @@ struct connman_wispr_portal { static GHashTable *wispr_portal_list = NULL; +static void connman_wispr_message_init(struct connman_wispr_message *msg) +{ + DBG(""); + + msg->has_error = FALSE; + msg->current_element = NULL; + + msg->message_type = -1; + msg->response_code = -1; + + g_free(msg->login_url); + msg->login_url = NULL; + + g_free(msg->abort_login_url); + msg->abort_login_url = NULL; + + g_free(msg->logoff_url); + msg->logoff_url = NULL; + + g_free(msg->access_procedure); + msg->access_procedure = NULL; + + g_free(msg->access_location); + msg->access_location = NULL; + + g_free(msg->location_name); + msg->location_name = NULL; +} + static void free_connman_wispr_portal_context(struct connman_wispr_portal_context *wp_context) { DBG(""); @@ -64,6 +110,9 @@ static void free_connman_wispr_portal_context(struct connman_wispr_portal_contex g_web_unref(wp_context->web); + g_web_parser_unref(wp_context->wispr_parser); + connman_wispr_message_init(&wp_context->wispr_msg); + g_free(wp_context); } @@ -82,6 +131,151 @@ static void free_connman_wispr_portal(gpointer data) g_free(wispr_portal); } +static struct { + const char *str; + enum { + WISPR_ELEMENT_NONE = 0, + WISPR_ELEMENT_ACCESS_PROCEDURE = 1, + WISPR_ELEMENT_ACCESS_LOCATION = 2, + WISPR_ELEMENT_LOCATION_NAME = 3, + WISPR_ELEMENT_LOGIN_URL = 4, + WISPR_ELEMENT_ABORT_LOGIN_URL = 5, + WISPR_ELEMENT_MESSAGE_TYPE = 6, + WISPR_ELEMENT_RESPONSE_CODE = 7, + WISPR_ELEMENT_NEXT_URL = 8, + WISPR_ELEMENT_DELAY = 9, + WISPR_ELEMENT_REPLY_MESSAGE = 10, + WISPR_ELEMENT_LOGIN_RESULTS_URL = 11, + WISPR_ELEMENT_LOGOFF_URL= 12, + } element; +} wispr_element_map[] = { + { "AccessProcedure",WISPR_ELEMENT_ACCESS_PROCEDURE }, + { "AccessLocation", WISPR_ELEMENT_ACCESS_LOCATION }, + { "LocationName", WISPR_ELEMENT_LOCATION_NAME }, + { "LoginURL", WISPR_ELEMENT_LOGIN_URL }, + { "AbortLoginURL", WISPR_ELEMENT_ABORT_LOGIN_URL }, + { "MessageType",WISPR_ELEMENT_MESSAGE_TYPE }, + { "ResponseCode", WISPR_ELEMENT_RESPONSE_CODE }, + { "NextURL",WISPR_ELEMENT_NEXT_URL }, + { "Delay", WISPR_ELEMENT_DELAY }, + { "ReplyMessage", WISPR_ELEMENT_REPLY_MESSAGE }, + { "LoginResultsURL",WISPR_ELEMENT_LOGIN_RESULTS_URL }, + { "LogoffURL", WISPR_ELEMENT_LOGOFF_URL}, + { NULL, WISPR_ELEMENT_NONE }, +}; + +static void xml_wispr_start_element_handler(GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + gpointer user_data, GError **error) +{ + struct connman_wispr_message *msg = user_data; + + msg->current_element = element_name; +} + +static void xml_wispr_end_element_handler(GMarkupParseContext *context, + const gchar *element_name, + gpointer user_data, GError **error) +{ + struct connman_wispr_message *msg = user_data; + + msg->current_element = NULL; +} + +static void xml_wispr_text_handler(GMarkupParseContext *context, + const gchar *text, gsize text_len, + gp