From 944c6c271c1964296cdcdc960c6959c32e4a0a47 Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Mon, 1 Apr 2013 16:26:37 +0300 Subject: [PATCH] http: small cleanup in sipe-http-request.c Add to comments which module has what responsibilities. --- src/core/sipe-http-request.c | 26 +++++++++++++++++++------- src/core/sipe-http-transport.c | 7 +++++++ src/core/sipe-http.c | 7 +++++++ src/core/sipe-http.h | 5 +++-- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/core/sipe-http-request.c b/src/core/sipe-http-request.c index ccde59db..75b03e83 100644 --- a/src/core/sipe-http-request.c +++ b/src/core/sipe-http-request.c @@ -19,6 +19,15 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + * SIPE HTTP request layer implementation + * + * - request handling: creation, parameters, deletion, cancelling + * - session handling: creation, closing + * - connection request queue handling + * - compile HTTP header contents and hand-off to transport layer + * - process HTTP response and hand-off to user callback */ #ifdef HAVE_CONFIG_H @@ -40,6 +49,9 @@ #define _SIPE_HTTP_PRIVATE_IF_TRANSPORT #include "sipe-http-transport.h" +#define SIPE_HTTP_CONNECTION ((struct sipe_http_connection *) conn_public) +#define SIPE_HTTP_CONNECTION_PUBLIC ((struct sipe_http_connection_public *) conn) + struct sipe_http_connection { struct sipe_http_connection_public public; GSList *pending_requests; @@ -82,7 +94,7 @@ struct sipe_http_connection_public *sipe_http_connection_new(struct sipe_core_pr conn->public.host = g_strdup(host); conn->public.port = port; - return((struct sipe_http_connection_public *) conn); + return(SIPE_HTTP_CONNECTION_PUBLIC); } static void sipe_http_request_free(struct sipe_core_private *sipe_private, @@ -127,7 +139,7 @@ static void sipe_http_request_send(struct sipe_http_connection *conn) g_free(cookie); g_free(content); - sipe_http_transport_send((struct sipe_http_connection_public *) conn, + sipe_http_transport_send(SIPE_HTTP_CONNECTION_PUBLIC, header, req->body); g_free(header); @@ -135,19 +147,19 @@ static void sipe_http_request_send(struct sipe_http_connection *conn) gboolean sipe_http_request_pending(struct sipe_http_connection_public *conn_public) { - return(((struct sipe_http_connection *) conn_public)->pending_requests != NULL); + return(SIPE_HTTP_CONNECTION->pending_requests != NULL); } void sipe_http_request_next(struct sipe_http_connection_public *conn_public) { - sipe_http_request_send((struct sipe_http_connection *) conn_public); + sipe_http_request_send(SIPE_HTTP_CONNECTION); } void sipe_http_request_response(struct sipe_http_connection_public *conn_public, struct sipmsg *msg) { struct sipe_core_private *sipe_private = conn_public->sipe_private; - struct sipe_http_connection *conn = (struct sipe_http_connection *) conn_public; + struct sipe_http_connection *conn = SIPE_HTTP_CONNECTION; struct sipe_http_request *req = conn->pending_requests->data; const gchar *hdr; @@ -196,7 +208,7 @@ void sipe_http_request_response(struct sipe_http_connection_public *conn_public, void sipe_http_request_shutdown(struct sipe_http_connection_public *conn_public) { - struct sipe_http_connection *conn = (struct sipe_http_connection *) conn_public; + struct sipe_http_connection *conn = SIPE_HTTP_CONNECTION; if (conn->pending_requests) { GSList *entry = conn->pending_requests; @@ -244,7 +256,7 @@ struct sipe_http_request *sipe_http_request_new(struct sipe_core_private *sipe_p req->connection = conn = (struct sipe_http_connection *) sipe_http_transport_new(sipe_private, host, port); - if (conn->pending_requests == NULL) + if (!sipe_http_request_pending(SIPE_HTTP_CONNECTION_PUBLIC)) req->flags = SIPE_HTTP_REQUEST_FLAG_FIRST; conn->pending_requests = g_slist_append(conn->pending_requests, req); diff --git a/src/core/sipe-http-transport.c b/src/core/sipe-http-transport.c index b2ff0fe8..a791eb7a 100644 --- a/src/core/sipe-http-transport.c +++ b/src/core/sipe-http-transport.c @@ -19,6 +19,13 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + * SIPE HTTP transport layer implementation + * + * - connection handling: opening, closing, timeout + * - interface to backend: sending & receiving of raw messages + * - request queue pulling */ #include diff --git a/src/core/sipe-http.c b/src/core/sipe-http.c index 1eba0004..b01fb3c1 100644 --- a/src/core/sipe-http.c +++ b/src/core/sipe-http.c @@ -19,6 +19,13 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + * SIPE HTTP API implementation + * + * - convenience functions for public API: GET & POST requests + * - URL parsing + * - all other public API functions are implemented by lower layers */ #include diff --git a/src/core/sipe-http.h b/src/core/sipe-http.h index 02b6e32e..06b23911 100644 --- a/src/core/sipe-http.h +++ b/src/core/sipe-http.h @@ -19,10 +19,11 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + * Public interface to HTTP request service */ -/* Public interface to HTTP request service */ - /* * Interface dependencies: * -- 2.11.4.GIT