Remove the "status" field from here, since it's mostly used by
authorDan Winship <danw@src.gnome.org>
Wed, 10 Sep 2003 18:14:19 +0000 (18:14 +0000)
committerDan Winship <danw@src.gnome.org>
Wed, 10 Sep 2003 18:14:19 +0000 (18:14 +0000)
* libsoup/soup-message-private.h (SoupMessagePrivate): Remove the
"status" field from here, since it's mostly used by SoupSession,
which shouldn't need access to SoupMessagePrivate.

* libsoup/soup-message.h (SoupMessage): Move it here.
(SoupCallbackFn): Remove this alias for SoupMessageCallbackFn.
(soup_message_set_uri): also moved from soup-message-private.h

* libsoup/soup-message.c: s/msg->priv->status/msg->status/.

* libsoup/soup-message-handlers.c:
s/SoupCallbackFn/SoupMessageCallbackFn/ everywhere.

* libsoup/soup-message-io.c (soup_message_io_client,
soup_message_io_server, soup_message_io_unpause): Don't set up an
idle handler, just jump right in to reading/writing; if this is a
synchronous socket, then the caller wants to block, and if it's
not, then we'll quickly get an EAGAIN anyway.

* libsoup/soup-session.c: (queue_message): Likewise.
(*) Update for SoupMessageStatus move and remove
soup-message-private.h include.

* libsoup/soup-server-message.c: Remove soup-message-private.h
include.

* libsoup/soup-server.c: Likewise.

* libsoup/soup-connection.c (soup_connection_is_connected,
soup_connection_is_new): Remove these, since they weren't being
used.

* libsoup/soup-md5-utils.c: Moved from md5-utils.c and renamed, to
avoid namespace pollution.

* libsoup/soup-auth-digest.c: Update for that.
* libsoup/soup-server-auth.c: Likewise

* tests/auth-test.c: Remove soup-message-private.h include

17 files changed:
ChangeLog
libsoup/Makefile.am
libsoup/soup-auth-digest.c
libsoup/soup-connection.c
libsoup/soup-connection.h
libsoup/soup-md5-utils.c [moved from libsoup/md5-utils.c with 74% similarity]
libsoup/soup-md5-utils.h [moved from libsoup/md5-utils.h with 64% similarity]
libsoup/soup-message-handlers.c
libsoup/soup-message-io.c
libsoup/soup-message-private.h
libsoup/soup-message.c
libsoup/soup-message.h
libsoup/soup-server-auth.c
libsoup/soup-server-message.c
libsoup/soup-server.c
libsoup/soup-session.c
tests/auth-test.c

index e4b216b..ce836cc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,45 @@
+2003-09-10  Dan Winship  <danw@ximian.com>
+
+       * libsoup/soup-message-private.h (SoupMessagePrivate): Remove the
+       "status" field from here, since it's mostly used by SoupSession,
+       which shouldn't need access to SoupMessagePrivate.
+
+       * libsoup/soup-message.h (SoupMessage): Move it here.
+       (SoupCallbackFn): Remove this alias for SoupMessageCallbackFn.
+       (soup_message_set_uri): also moved from soup-message-private.h
+
+       * libsoup/soup-message.c: s/msg->priv->status/msg->status/.
+
+       * libsoup/soup-message-handlers.c:
+       s/SoupCallbackFn/SoupMessageCallbackFn/ everywhere.
+
+       * libsoup/soup-message-io.c (soup_message_io_client,
+       soup_message_io_server, soup_message_io_unpause): Don't set up an
+       idle handler, just jump right in to reading/writing; if this is a
+       synchronous socket, then the caller wants to block, and if it's
+       not, then we'll quickly get an EAGAIN anyway.
+
+       * libsoup/soup-session.c: (queue_message): Likewise.
+       (*) Update for SoupMessageStatus move and remove
+       soup-message-private.h include.
+
+       * libsoup/soup-server-message.c: Remove soup-message-private.h
+       include.
+
+       * libsoup/soup-server.c: Likewise.
+
+       * libsoup/soup-connection.c (soup_connection_is_connected,
+       soup_connection_is_new): Remove these, since they weren't being
+       used.
+
+       * libsoup/soup-md5-utils.c: Moved from md5-utils.c and renamed, to
+       avoid namespace pollution.
+
+       * libsoup/soup-auth-digest.c: Update for that.
+       * libsoup/soup-server-auth.c: Likewise
+
+       * tests/auth-test.c: Remove soup-message-private.h include
+
 2003-09-09  Dan Winship  <danw@ximian.com>
 
        Beginnings of improved synchronous API support
index bae54f8..e66857a 100644 (file)
@@ -55,8 +55,6 @@ libsoup_2_2_la_LIBADD =               \
 
 libsoup_2_2_la_SOURCES =               \
        $(MARSHAL_GENERATED)            \
-       md5-utils.h                     \
-       md5-utils.c                     \
        soup-address.c                  \
        soup-auth.h                     \
        soup-auth.c                     \
@@ -72,6 +70,8 @@ libsoup_2_2_la_SOURCES =              \
        soup-gnutls.h                   \
        soup-gnutls.c                   \
        soup-headers.c                  \
+       soup-md5-utils.h                \
+       soup-md5-utils.c                \
        soup-message.c                  \
        soup-message-client-io.c        \
        soup-message-handlers.c         \
index a38d382..e8e7da7 100644 (file)
 
 #include "soup-auth-digest.h"
 #include "soup-headers.h"
+#include "soup-md5-utils.h"
 #include "soup-message.h"
 #include "soup-misc.h"
 #include "soup-private.h"
 #include "soup-uri.h"
-#include "md5-utils.h"
 
 static void construct (SoupAuth *auth, const char *header);
 static GSList *get_protection_space (SoupAuth *auth, const SoupUri *source_uri);
@@ -265,7 +265,7 @@ static void
 authenticate (SoupAuth *auth, const char *username, const char *password)
 {
        SoupAuthDigest *digest = SOUP_AUTH_DIGEST (auth);
-       MD5Context ctx;
+       SoupMD5Context ctx;
        guchar d[16];
        char *bgen;
 
@@ -281,31 +281,35 @@ authenticate (SoupAuth *auth, const char *username, const char *password)
        digest->priv->user = g_strdup (username);
 
        /* compute A1 */
-       md5_init (&ctx);
+       soup_md5_init (&ctx);
 
-       md5_update (&ctx, username, strlen (username));
+       soup_md5_update (&ctx, username, strlen (username));
 
-       md5_update (&ctx, ":", 1);
-       if (digest->priv->realm)
-               md5_update (&ctx, digest->priv->realm, strlen (digest->priv->realm));
+       soup_md5_update (&ctx, ":", 1);
+       if (digest->priv->realm) {
+               soup_md5_update (&ctx, digest->priv->realm,
+                                strlen (digest->priv->realm));
+       }
 
-       md5_update (&ctx, ":", 1);
+       soup_md5_update (&ctx, ":", 1);
        if (password)
-               md5_update (&ctx, password, strlen (password));
+               soup_md5_update (&ctx, password, strlen (password));
 
        if (digest->priv->algorithm == ALGORITHM_MD5_SESS) {
-               md5_final (&ctx, d);
-
-               md5_init (&ctx);
-               md5_update (&ctx, d, 16);
-               md5_update (&ctx, ":", 1);
-               md5_update (&ctx, digest->priv->nonce, strlen (digest->priv->nonce));
-               md5_update (&ctx, ":", 1);
-               md5_update (&ctx, digest->priv->cnonce, strlen (digest->priv->cnonce));
+               soup_md5_final (&ctx, d);
+
+               soup_md5_init (&ctx);
+               soup_md5_update (&ctx, d, 16);
+               soup_md5_update (&ctx, ":", 1);
+               soup_md5_update (&ctx, digest->priv->nonce,
+                                strlen (digest->priv->nonce));
+               soup_md5_update (&ctx, ":", 1);
+               soup_md5_update (&ctx, digest->priv->cnonce,
+                                strlen (digest->priv->cnonce));
        }
 
        /* hexify A1 */
-       md5_final (&ctx, d);
+       soup_md5_final (&ctx, d);
        digest_hex (d, digest->priv->hex_a1);
 }
 
@@ -332,7 +336,7 @@ compute_response (SoupAuthDigest *digest, SoupMessage *msg)
 {
        guchar hex_a2[33], o[33];
        guchar d[16];
-       MD5Context md5;
+       SoupMD5Context md5;
        char *url;
        const SoupUri *uri;
 
@@ -341,40 +345,42 @@ compute_response (SoupAuthDigest *digest, SoupMessage *msg)
        url = soup_uri_to_string (uri, TRUE);
 
        /* compute A2 */
-       md5_init (&md5);
-       md5_update (&md5, msg->method, strlen (msg->method));
-       md5_update (&md5, ":", 1);
-       md5_update (&md5, url, strlen (url));
+       soup_md5_init (&md5);
+       soup_md5_update (&md5, msg->method, strlen (msg->method));
+       soup_md5_update (&md5, ":", 1);
+       soup_md5_update (&md5, url, strlen (url));
 
        g_free (url);
 
        if (digest->priv->qop == QOP_AUTH_INT) {
                /* FIXME: Actually implement. Ugh. */
-               md5_update (&md5, ":", 1);
-               md5_update (&md5, "00000000000000000000000000000000", 32);
+               soup_md5_update (&md5, ":", 1);
+               soup_md5_update (&md5, "00000000000000000000000000000000", 32);
        }
 
        /* now hexify A2 */
-       md5_final (&md5, d);
+       soup_md5_final (&md5, d);
        digest_hex (d, hex_a2);
 
        /* compute KD */
-       md5_init (&md5);
-       md5_update (&md5, digest->priv->hex_a1, 32);
-       md5_update (&md5, ":", 1);
-       md5_update (&md5, digest->priv->nonce, strlen (digest->priv->nonce));
-       md5_update (&md5, ":", 1);
+       soup_md5_init (&md5);
+       soup_md5_update (&md5, digest->priv->hex_a1, 32);
+       soup_md5_update (&md5, ":", 1);
+       soup_md5_update (&md5, digest->priv->nonce,
+                        strlen (digest->priv->nonce));
+       soup_md5_update (&md5, ":", 1);
 
        if (digest->priv->qop) {
                char *tmp;
 
                tmp = g_strdup_printf ("%.8x", digest->priv->nc);
 
-               md5_update (&md5, tmp, strlen (tmp));
+               soup_md5_update (&md5, tmp, strlen (tmp));
                g_free (tmp);
-               md5_update (&md5, ":", 1);
-               md5_update (&md5, digest->priv->cnonce, strlen (digest->priv->cnonce));
-               md5_update (&md5, ":", 1);
+               soup_md5_update (&md5, ":", 1);
+               soup_md5_update (&md5, digest->priv->cnonce,
+                                strlen (digest->priv->cnonce));
+               soup_md5_update (&md5, ":", 1);
 
                if (digest->priv->qop == QOP_AUTH)
                        tmp = "auth";
@@ -383,12 +389,12 @@ compute_response (SoupAuthDigest *digest, SoupMessage *msg)
                else
                        g_assert_not_reached ();
 
-               md5_update (&md5, tmp, strlen (tmp));
-               md5_update (&md5, ":", 1);
+               soup_md5_update (&md5, tmp, strlen (tmp));
+               soup_md5_update (&md5, ":", 1);
        }
 
-       md5_update (&md5, hex_a2, 32);
-       md5_final (&md5, d);
+       soup_md5_update (&md5, hex_a2, 32);
+       soup_md5_final (&md5, d);
 
        digest_hex (d, o);
 
index 8e9a7e8..d6fbd77 100644 (file)
@@ -347,15 +347,6 @@ soup_connection_disconnect (SoupConnection *conn)
        g_signal_emit (conn, signals[DISCONNECTED], 0);
 }
 
-gboolean
-soup_connection_is_connected (SoupConnection *conn)
-{
-       g_return_val_if_fail (SOUP_IS_CONNECTION (conn), FALSE);
-
-       return conn->priv->socket != NULL;
-}
-
-
 /**
  * soup_connection_is_in_use:
  * @conn: a connection
@@ -385,22 +376,6 @@ soup_connection_last_used (SoupConnection *conn)
        return conn->priv->last_used;
 }
 
-/**
- * soup_connection_is_new:
- * @conn: a connection
- *
- * Return value: whether or not @conn is "new". (That is, it has not
- * yet completed a whole HTTP transaction.)
- **/
-gboolean
-soup_connection_is_new (SoupConnection *conn)
-{
-       g_return_val_if_fail (SOUP_IS_CONNECTION (conn), FALSE);
-
-       return conn->priv->last_used == 0;
-}
-
-
 static void
 request_done (SoupMessage *req, gpointer user_data)
 {
index 449743e..74628e1 100644 (file)
@@ -51,9 +51,7 @@ void            soup_connection_connect_async  (SoupConnection   *conn,
 guint           soup_connection_connect_sync   (SoupConnection   *conn);
 
 void            soup_connection_disconnect     (SoupConnection   *conn);
-gboolean        soup_connection_is_connected   (SoupConnection   *conn);
 
-gboolean        soup_connection_is_new         (SoupConnection   *conn);
 gboolean        soup_connection_is_in_use      (SoupConnection   *conn);
 time_t          soup_connection_last_used      (SoupConnection   *conn);
 
similarity index 74%
rename from libsoup/md5-utils.c
rename to libsoup/soup-md5-utils.c
index a4dd42a..b4fc115 100644 (file)
@@ -11,8 +11,8 @@
  * with every copy.
  *
  * To compute the message digest of a chunk of bytes, declare an
- * MD5Context structure, pass it to md5_init, call md5_update as
- * needed on buffers full of bytes, and then call md5_Final, which
+ * SoupMD5Context structure, pass it to soup_md5_init, call soup_md5_update as
+ * needed on buffers full of bytes, and then call soup_md5_Final, which
  * will fill a supplied 16-byte array with the digest.
  */
 
  */
 
 
-#include "md5-utils.h"
-#include <stdio.h>
+#include "soup-md5-utils.h"
 #include <string.h>
 
-static void md5_transform (guint32 buf[4], const guint32 in[16]);
-
-static gint _ie = 0x44332211;
-static union _endian { gint i; gchar b[4]; } *_endian = (union _endian *)&_ie;
-#define        IS_BIG_ENDIAN()         (_endian->b[0] == '\x44')
-#define        IS_LITTLE_ENDIAN()      (_endian->b[0] == '\x11')
-
+static void soup_md5_transform (guint32 buf[4], const guint32 in[16]);
 
 /*
  * Note: this code is harmless on little-endian machines.
  */
 static void 
-_byte_reverse (guchar *buf, guint32 longs)
+byte_reverse (guchar *buf, guint32 longs)
 {
        guint32 t;
        do {
@@ -51,14 +44,14 @@ _byte_reverse (guchar *buf, guint32 longs)
 }
 
 /**
- * md5_init: Initialise an md5 context object
+ * soup_md5_init: Initialise an md5 context object
  * @ctx: md5 context 
  * 
  * Initialise an md5 buffer. 
  *
  **/
 void 
-md5_init (MD5Context *ctx)
+soup_md5_init (SoupMD5Context *ctx)
 {
        ctx->buf[0] = 0x67452301;
        ctx->buf[1] = 0xefcdab89;
@@ -68,16 +61,13 @@ md5_init (MD5Context *ctx)
        ctx->bits[0] = 0;
        ctx->bits[1] = 0;
        
-       if (IS_BIG_ENDIAN())    
-               ctx->doByteReverse = 1;         
-       else 
-               ctx->doByteReverse = 0; 
+       ctx->doByteReverse = (G_BYTE_ORDER == G_BIG_ENDIAN);
 }
 
 
 
 /**
- * md5_update: add a buffer to md5 hash computation
+ * soup_md5_update: add a buffer to md5 hash computation
  * @ctx: conetxt object used for md5 computaion
  * @buf: buffer to add
  * @len: buffer length
@@ -86,7 +76,7 @@ md5_init (MD5Context *ctx)
  * of bytes. Use this to progressively construct an md5 hash.
  **/
 void 
-md5_update (MD5Context *ctx, const guchar *buf, guint32 len)
+soup_md5_update (SoupMD5Context *ctx, const guchar *buf, guint32 len)
 {
        guint32 t;
        
@@ -111,8 +101,8 @@ md5_update (MD5Context *ctx, const guchar *buf, guint32 len)
                }
                memcpy (p, buf, t);
                if (ctx->doByteReverse)
-                       _byte_reverse (ctx->in, 16);
-               md5_transform (ctx->buf, (guint32 *) ctx->in);
+                       byte_reverse (ctx->in, 16);
+               soup_md5_transform (ctx->buf, (guint32 *) ctx->in);
                buf += t;
                len -= t;
        }
@@ -121,8 +111,8 @@ md5_update (MD5Context *ctx, const guchar *buf, guint32 len)
        while (len >= 64) {
                memcpy (ctx->in, buf, 64);
                if (ctx->doByteReverse)
-                       _byte_reverse (ctx->in, 16);
-               md5_transform (ctx->buf, (guint32 *) ctx->in);
+                       byte_reverse (ctx->in, 16);
+               soup_md5_transform (ctx->buf, (guint32 *) ctx->in);
                buf += 64;
                len -= 64;
        }
@@ -132,23 +122,19 @@ md5_update (MD5Context *ctx, const guchar *buf, guint32 len)
        memcpy (ctx->in, buf, len);
 }
 
-
-
-
-
 /*
  * Final wrapup - pad to 64-byte boundary with the bit pattern 
  * 1 0* (64-bit count of bits processed, MSB-first)
  */
 /**
- * md5_final: copy the final md5 hash to a bufer
+ * soup_md5_final: copy the final md5 hash to a bufer
  * @digest: 16 bytes buffer
  * @ctx: context containing the calculated md5
  * 
  * copy the final md5 hash to a bufer
  **/
 void 
-md5_final (MD5Context *ctx, guchar digest[16])
+soup_md5_final (SoupMD5Context *ctx, guchar digest[16])
 {
        guint32 count;
        guchar *p;
@@ -169,8 +155,8 @@ md5_final (MD5Context *ctx, guchar digest[16])
                /* Two lots of padding:  Pad the first block to 64 bytes */
                memset (p, 0, count);
                if (ctx->doByteReverse)
-                       _byte_reverse (ctx->in, 16);
-               md5_transform (ctx->buf, (guint32 *) ctx->in);
+                       byte_reverse (ctx->in, 16);
+               soup_md5_transform (ctx->buf, (guint32 *) ctx->in);
                
                /* Now fill the next block with 56 bytes */
                memset (ctx->in, 0, 56);
@@ -179,15 +165,15 @@ md5_final (MD5Context *ctx, guchar digest[16])
                memset (p, 0, count - 8);
        }
        if (ctx->doByteReverse)
-               _byte_reverse (ctx->in, 14);
+               byte_reverse (ctx->in, 14);
        
        /* Append length in bits and transform */
        ((guint32 *) ctx->in)[14] = ctx->bits[0];
        ((guint32 *) ctx->in)[15] = ctx->bits[1];
        
-       md5_transform (ctx->buf, (guint32 *) ctx->in);
+       soup_md5_transform (ctx->buf, (guint32 *) ctx->in);
        if (ctx->doByteReverse)
-               _byte_reverse ((guchar *) ctx->buf, 4);
+               byte_reverse ((guchar *) ctx->buf, 4);
        memcpy (digest, ctx->buf, 16);
 }
 
@@ -208,11 +194,11 @@ md5_final (MD5Context *ctx, guchar digest[16])
 
 /*
  * The core of the MD5 algorithm, this alters an existing MD5 hash to
- * reflect the addition of 16 longwords of new data.  md5_Update blocks
+ * reflect the addition of 16 longwords of new data.  soup_md5_Update blocks
  * the data and converts bytes into longwords for this routine.
  */
 static void 
-md5_transform (guint32 buf[4], const guint32 in[16])
+soup_md5_transform (guint32 buf[4], const guint32 in[16])
 {
        register guint32 a, b, c, d;
        
@@ -294,69 +280,3 @@ md5_transform (guint32 buf[4], const guint32 in[16])
        buf[2] += c;
        buf[3] += d;
 }
-
-
-
-
-/**
- * md5_get_digest: get the md5 hash of a buffer
- * @buffer: byte buffer
- * @buffer_size: buffer size (in bytes)
- * @digest: 16 bytes buffer receiving the hash code.
- * 
- * Get the md5 hash of a buffer. The result is put in 
- * the 16 bytes buffer @digest .
- **/
-void
-md5_get_digest (const gchar *buffer, gint buffer_size, guchar digest[16])
-{      
-       MD5Context ctx;
-
-       md5_init (&ctx);
-       md5_update (&ctx, buffer, buffer_size);
-       md5_final (&ctx, digest);
-       
-}
-
-
-/**
- * md5_get_digest_from_file: get the md5 hash of a file
- * @filename: file name
- * @digest: 16 bytes buffer receiving the hash code.
- * 
- * Get the md5 hash of a file. The result is put in 
- * the 16 bytes buffer @digest .
- **/
-void
-md5_get_digest_from_file (const gchar *filename, guchar digest[16])
-{      
-       MD5Context ctx;
-       guchar tmp_buf[1024];
-       gint nb_bytes_read;
-       FILE *fp;
-
-       printf("generating checksum\n");
-
-       md5_init (&ctx);
-       fp = fopen(filename, "r");
-       if (!fp) {
-       return;
-       }
-       
-       while ((nb_bytes_read = fread (tmp_buf, sizeof (guchar), 1024, fp)) > 0)
-               md5_update (&ctx, tmp_buf, nb_bytes_read);
-       
-       if (ferror(fp)) {
-               fclose(fp);
-               return;
-       }
-
-       
-       md5_final (&ctx, digest);
-       
-       printf("checksum done\n");
-}
-
-
-
-
similarity index 64%
rename from libsoup/md5-utils.h
rename to libsoup/soup-md5-utils.h
index 08e014e..5295a61 100644 (file)
  */
 
 
-#ifndef MD5_UTILS_H
-#define MD5_UTILS_H
+#ifndef SOUP_MD5_UTILS_H
+#define SOUP_MD5_UTILS_H
 
 #include <glib.h>
 
 typedef struct {
-       guint32 buf[4];
-       guint32 bits[2];
-       guchar in[64];
-       gint doByteReverse;
+       guint32  buf[4];
+       guint32  bits[2];
+       guchar   in[64];
+       gboolean doByteReverse;
+} SoupMD5Context;
 
-} MD5Context ;
+void soup_md5_init   (SoupMD5Context *ctx);
+void soup_md5_update (SoupMD5Context *ctx,
+                     const guchar   *buf,
+                     guint32         len);
+void soup_md5_final  (SoupMD5Context *ctx,
+                     guchar          digest[16]);
 
 
-void md5_get_digest (const gchar *buffer, gint buffer_size, guchar digest[16]);
-
-/* use this one when speed is needed */
-/* for use in provider code only */
-void md5_get_digest_from_file (const gchar *filename, guchar digest[16]);
-
-/* raw routines */
-void md5_init (MD5Context *ctx);
-void md5_update (MD5Context *ctx, const guchar *buf, guint32 len);
-void md5_final (MD5Context *ctx, guchar digest[16]);
-
-
-#endif /* MD5_UTILS_H */
+#endif /* SOUP_MD5_UTILS_H */
index 9d08412..23b3558 100644 (file)
@@ -21,11 +21,11 @@ typedef enum {
 } SoupHandlerKind;
 
 typedef struct {
-       SoupHandlerPhase  phase;
-       SoupCallbackFn    handler_cb;
-       gpointer          user_data;
+       SoupHandlerPhase         phase;
+       SoupMessageCallbackFn    handler_cb;
+       gpointer                 user_data;
 
-       SoupHandlerKind   kind;
+       SoupHandlerKind          kind;
        union {
                guint            status_code;
                SoupStatusClass  status_class;
@@ -86,14 +86,14 @@ soup_message_run_handlers (SoupMessage *msg, SoupHandlerPhase invoke_phase)
 }
 
 static void
-add_handler (SoupMessage      *msg,
-            SoupHandlerPhase  phase,
-            SoupCallbackFn    handler_cb,
-            gpointer          user_data,
-            SoupHandlerKind   kind,
-            const char       *header,
-            guint             status_code,
-            SoupStatusClass   status_class)
+add_handler (SoupMessage           *msg,
+            SoupHandlerPhase       phase,
+            SoupMessageCallbackFn  handler_cb,
+            gpointer               user_data,
+            SoupHandlerKind        kind,
+            const char            *header,
+            guint                  status_code,
+            SoupStatusClass        status_class)
 {
        SoupHandlerData *data;
 
@@ -122,11 +122,11 @@ add_handler (SoupMessage      *msg,
 }
 
 void
-soup_message_add_header_handler (SoupMessage      *msg,
-                                const char       *header,
-                                SoupHandlerPhase  phase,
-                                SoupCallbackFn    handler_cb,
-                                gpointer          user_data)
+soup_message_add_header_handler (SoupMessage           *msg,
+                                const char            *header,
+                                SoupHandlerPhase       phase,
+                                SoupMessageCallbackFn  handler_cb,
+                                gpointer               user_data)
 {
        g_return_if_fail (SOUP_IS_MESSAGE (msg));
        g_return_if_fail (header != NULL);
@@ -138,11 +138,11 @@ soup_message_add_header_handler (SoupMessage      *msg,
 }
 
 void
-soup_message_add_status_code_handler (SoupMessage      *msg,
-                                     guint             status_code,
-                                     SoupHandlerPhase  phase,
-                                     SoupCallbackFn    handler_cb,
-                                     gpointer          user_data)
+soup_message_add_status_code_handler (SoupMessage           *msg,
+                                     guint                  status_code,
+                                     SoupHandlerPhase       phase,
+                                     SoupMessageCallbackFn  handler_cb,
+                                     gpointer               user_data)
 {
        g_return_if_fail (SOUP_IS_MESSAGE (msg));
        g_return_if_fail (status_code != 0);
@@ -154,11 +154,11 @@ soup_message_add_status_code_handler (SoupMessage      *msg,
 }
 
 void
-soup_message_add_status_class_handler (SoupMessage      *msg,
-                                      SoupStatusClass   status_class,
-                                      SoupHandlerPhase  phase,
-                                      SoupCallbackFn    handler_cb,
-                                      gpointer          user_data)
+soup_message_add_status_class_handler (SoupMessage           *msg,
+                                      SoupStatusClass        status_class,
+                                      SoupHandlerPhase       phase,
+                                      SoupMessageCallbackFn  handler_cb,
+                                      gpointer               user_data)
 {
        g_return_if_fail (SOUP_IS_MESSAGE (msg));
        g_return_if_fail (status_class != 0);
@@ -172,7 +172,7 @@ soup_message_add_status_class_handler (SoupMessage      *msg,
 void
 soup_message_add_handler (SoupMessage      *msg,
                          SoupHandlerPhase  phase,
-                         SoupCallbackFn    handler_cb,
+                         SoupMessageCallbackFn    handler_cb,
                          gpointer          user_data)
 {
        g_return_if_fail (SOUP_IS_MESSAGE (msg));
@@ -182,10 +182,10 @@ soup_message_add_handler (SoupMessage      *msg,
 }
 
 void
-soup_message_remove_handler (SoupMessage     *msg,
-                            SoupHandlerPhase phase,
-                            SoupCallbackFn   handler_cb,
-                            gpointer         user_data)
+soup_message_remove_handler (SoupMessage           *msg,
+                            SoupHandlerPhase       phase,
+                            SoupMessageCallbackFn  handler_cb,
+                            gpointer               user_data)
 {
        GSList *iter = msg->priv->content_handlers;
 
index 847bdaa..1345296 100644 (file)
@@ -52,7 +52,7 @@ typedef struct {
        SoupDataBuffer       *write_body;
        guint                 written;
 
-       guint read_tag, write_tag, err_tag, idle_tag;
+       guint read_tag, write_tag, err_tag;
 
        SoupMessageGetHeadersFn   get_headers_cb;
        SoupMessageParseHeadersFn parse_headers_cb;
@@ -76,8 +76,6 @@ soup_message_io_cancel (SoupMessage *msg)
        if (!io)
                return;
 
-       if (io->idle_tag)
-               g_source_remove (io->idle_tag);
        if (io->read_tag)
                g_signal_handler_disconnect (io->sock, io->read_tag);
        if (io->write_tag)
@@ -644,21 +642,6 @@ new_iostate (SoupMessage *msg, SoupSocket *sock, SoupMessageIOMode mode,
        return io;
 }
 
-static gboolean
-idle_io (gpointer user_data)
-{
-       SoupMessage *msg = user_data;
-       SoupMessageIOData *io = msg->priv->io_data;
-
-       io->idle_tag = 0;
-       if (io->write_state != SOUP_MESSAGE_IO_STATE_NOT_STARTED &&
-           io->write_state != SOUP_MESSAGE_IO_STATE_BLOCKING)
-               io_write (io->sock, msg);
-       else
-               io_read (io->sock, msg);
-       return FALSE;
-}
-
 void
 soup_message_io_client (SoupMessage *msg, SoupSocket *sock,
                        SoupMessageGetHeadersFn get_headers_cb,
@@ -674,7 +657,7 @@ soup_message_io_client (SoupMessage *msg, SoupSocket *sock,
        io->write_body      = &msg->request;
 
        io->write_state     = SOUP_MESSAGE_IO_STATE_HEADERS;
-       io->idle_tag        = g_idle_add (idle_io, msg);
+       io_write (sock, msg);
 }
 
 void
@@ -692,7 +675,7 @@ soup_message_io_server (SoupMessage *msg, SoupSocket *sock,
        io->write_body      = &msg->response;
 
        io->read_state      = SOUP_MESSAGE_IO_STATE_HEADERS;
-       io->idle_tag        = g_idle_add (idle_io, msg);
+       io_read (sock, msg);
 }
 
 void  
@@ -710,10 +693,6 @@ soup_message_io_pause (SoupMessage *msg)
                g_signal_handler_disconnect (io->sock, io->read_tag);
                io->read_tag = 0;
        }
-       if (io->idle_tag) {
-               g_source_remove (io->idle_tag);
-               io->idle_tag = 0;
-       }
 }
 
 void  
@@ -723,7 +702,7 @@ soup_message_io_unpause (SoupMessage *msg)
 
        g_return_if_fail (io != NULL);
 
-       if (io->write_tag || io->read_tag || io->idle_tag)
+       if (io->write_tag || io->read_tag)
                return;
 
        io->write_tag = g_signal_connect (io->sock, "writable",
@@ -731,5 +710,9 @@ soup_message_io_unpause (SoupMessage *msg)
        io->read_tag = g_signal_connect (io->sock, "readable",
                                         G_CALLBACK (io_read), msg);
 
-       io->idle_tag = g_idle_add (idle_io, msg);
+       if (io->write_state != SOUP_MESSAGE_IO_STATE_NOT_STARTED &&
+           io->write_state != SOUP_MESSAGE_IO_STATE_BLOCKING)
+               io_write (io->sock, msg);
+       else
+               io_read (io->sock, msg);
 }
index cff4702..6782acb 100644 (file)
@@ -8,19 +8,7 @@
 
 #include <libsoup/soup-message.h>
 
-typedef enum {
-       SOUP_MESSAGE_STATUS_IDLE,
-       SOUP_MESSAGE_STATUS_QUEUED,
-        SOUP_MESSAGE_STATUS_CONNECTING,
-        SOUP_MESSAGE_STATUS_RUNNING,
-       SOUP_MESSAGE_STATUS_FINISHED,
-} SoupMessageStatus;
-
-#define SOUP_MESSAGE_IS_STARTING(msg) (msg->priv->status == SOUP_MESSAGE_STATUS_QUEUED || msg->priv->status == SOUP_MESSAGE_STATUS_CONNECTING)
-
 struct SoupMessagePrivate {
-       SoupMessageStatus  status;
-
        gpointer           io_data;
 
        guint              msg_flags;
@@ -41,9 +29,6 @@ void             soup_message_cleanup        (SoupMessage      *req);
 
 gboolean         soup_message_is_keepalive   (SoupMessage      *msg);
 
-void             soup_message_set_uri        (SoupMessage      *msg,
-                                             const SoupUri    *uri);
-
 
 typedef void     (*SoupMessageGetHeadersFn)  (SoupMessage      *msg,
                                              GString          *headers,
index 2eb46e1..b0faf5c 100644 (file)
@@ -46,7 +46,7 @@ init (GObject *object)
 
        msg->priv = g_new0 (SoupMessagePrivate, 1);
 
-       msg->priv->status  = SOUP_MESSAGE_STATUS_IDLE;
+       msg->status  = SOUP_MESSAGE_STATUS_IDLE;
 
        msg->request_headers = g_hash_table_new (soup_str_case_hash,
                                                 soup_str_case_equal);
@@ -504,8 +504,8 @@ soup_message_prepare (SoupMessage *req)
 {
        soup_message_io_cancel (req);
 
-       if (req->priv->status != SOUP_MESSAGE_STATUS_IDLE)
-               req->priv->status = SOUP_MESSAGE_STATUS_IDLE;
+       if (req->status != SOUP_MESSAGE_STATUS_IDLE)
+               req->status = SOUP_MESSAGE_STATUS_IDLE;
 
        if (req->response.owner == SOUP_BUFFER_SYSTEM_OWNED)
                g_free (req->response.body);
index 33c2910..08f60be 100644 (file)
 typedef struct SoupMessagePrivate SoupMessagePrivate;
 
 typedef enum {
+       SOUP_MESSAGE_STATUS_IDLE,
+       SOUP_MESSAGE_STATUS_QUEUED,
+        SOUP_MESSAGE_STATUS_CONNECTING,
+        SOUP_MESSAGE_STATUS_RUNNING,
+       SOUP_MESSAGE_STATUS_FINISHED,
+} SoupMessageStatus;
+
+#define SOUP_MESSAGE_IS_STARTING(msg) (msg->status == SOUP_MESSAGE_STATUS_QUEUED || msg->status == SOUP_MESSAGE_STATUS_CONNECTING)
+
+typedef enum {
        SOUP_TRANSFER_UNKNOWN = 0,
        SOUP_TRANSFER_CHUNKED,
        SOUP_TRANSFER_CONTENT_LENGTH,
@@ -51,6 +61,8 @@ struct SoupMessage {
 
        SoupDataBuffer      response;
        GHashTable         *response_headers;
+
+       SoupMessageStatus   status;
 };
 
 typedef struct {
@@ -69,8 +81,6 @@ typedef struct {
 GType soup_message_get_type (void);
 
 typedef void (*SoupMessageCallbackFn) (SoupMessage *req, gpointer user_data);
-/* Backward compat; FIXME */
-typedef SoupMessageCallbackFn SoupCallbackFn;
 
 SoupMessage   *soup_message_new                 (const char        *method,
                                                 const char        *uri);
@@ -124,6 +134,8 @@ SoupHttpVersion  soup_message_get_http_version    (SoupMessage       *msg);
 gboolean         soup_message_is_keepalive        (SoupMessage       *msg);
 
 const SoupUri   *soup_message_get_uri             (SoupMessage       *msg);
+void             soup_message_set_uri             (SoupMessage       *msg,
+                                                  const SoupUri     *uri);
 
 typedef enum {
        /*
@@ -183,32 +195,32 @@ typedef enum {
 
 void           soup_message_add_handler         (SoupMessage       *msg,
                                                 SoupHandlerPhase   type,
-                                                SoupCallbackFn     handler_cb,
+                                                SoupMessageCallbackFn     handler_cb,
                                                 gpointer           user_data);
 
 void           soup_message_add_header_handler  (SoupMessage       *msg,
                                                 const char        *header,
                                                 SoupHandlerPhase   type,
-                                                SoupCallbackFn     handler_cb,
+                                                SoupMessageCallbackFn,
                                                 gpointer           user_data);
 
 void           soup_message_add_status_code_handler (
                                                 SoupMessage       *msg,
                                                 guint              status_code,
                                                 SoupHandlerPhase   type,
-                                                SoupCallbackFn     handler_cb,
+                                                SoupMessageCallbackFn,
                                                 gpointer           user_data);
 
 void           soup_message_add_status_class_handler (
                                                 SoupMessage       *msg,
                                                 SoupStatusClass    status_class,
                                                 SoupHandlerPhase   type,
-                                                SoupCallbackFn     handler_cb,
+                                                SoupMessageCallbackFn,
                                                 gpointer           user_data);
 
 void           soup_message_remove_handler      (SoupMessage       *msg, 
                                                 SoupHandlerPhase   type,
-                                                SoupCallbackFn     handler_cb,
+                                                SoupMessageCallbackFn,
                                                 gpointer           user_data);
 
 /*
index b171d57..3225f60 100644 (file)
@@ -13,8 +13,8 @@
 
 #include "soup-server-auth.h"
 
-#include "md5-utils.h"
 #include "soup-headers.h"
+#include "soup-md5-utils.h"
 #include "soup-misc.h"
 #include "soup-uri.h"
 
@@ -84,79 +84,79 @@ static gboolean
 check_digest_passwd (SoupServerAuthDigest *digest,
                     gchar                *passwd)
 {
-       MD5Context ctx;
+       SoupMD5Context ctx;
        guchar d[16];
        guchar hex_a1 [33], hex_a2[33], o[33];
        gchar *tmp;
 
        /* compute A1 */
-       md5_init (&ctx);
-       md5_update (&ctx, digest->user, strlen (digest->user));
-       md5_update (&ctx, ":", 1);
-       md5_update (&ctx, digest->realm, strlen (digest->realm));
-       md5_update (&ctx, ":", 1);
+       soup_md5_init (&ctx);
+       soup_md5_update (&ctx, digest->user, strlen (digest->user));
+       soup_md5_update (&ctx, ":", 1);
+       soup_md5_update (&ctx, digest->realm, strlen (digest->realm));
+       soup_md5_update (&ctx, ":", 1);
 
        if (passwd)
-               md5_update (&ctx, passwd, strlen (passwd));
+               soup_md5_update (&ctx, passwd, strlen (passwd));
 
        if (digest->algorithm == SOUP_ALGORITHM_MD5_SESS) {
-               md5_final (&ctx, d);
-
-               md5_init (&ctx);
-               md5_update (&ctx, d, 16);
-               md5_update (&ctx, ":", 1);
-               md5_update (&ctx, digest->nonce, strlen (digest->nonce));
-               md5_update (&ctx, ":", 1);
-               md5_update (&ctx, digest->cnonce, strlen (digest->cnonce));
+               soup_md5_final (&ctx, d);
+
+               soup_md5_init (&ctx);
+               soup_md5_update (&ctx, d, 16);
+               soup_md5_update (&ctx, ":", 1);
+               soup_md5_update (&ctx, digest->nonce, strlen (digest->nonce));
+               soup_md5_update (&ctx, ":", 1);
+               soup_md5_update (&ctx, digest->cnonce, strlen (digest->cnonce));
        }
 
        /* hexify A1 */
-       md5_final (&ctx, d);
+       soup_md5_final (&ctx, d);
        digest_hex (d, hex_a1);
 
        /* compute A2 */
-       md5_init (&ctx);
-       md5_update (&ctx, 
+       soup_md5_init (&ctx);
+       soup_md5_update (&ctx, 
                    digest->request_method, 
                    strlen (digest->request_method));
-       md5_update (&ctx, ":", 1);
-       md5_update (&ctx, digest->digest_uri, strlen (digest->digest_uri));
+       soup_md5_update (&ctx, ":", 1);
+       soup_md5_update (&ctx, digest->digest_uri, strlen (digest->digest_uri));
 
        if (digest->integrity) {
                /* FIXME: Actually implement. Ugh. */
-               md5_update (&ctx, ":", 1);
-               md5_update (&ctx, "00000000000000000000000000000000", 32);
+               soup_md5_update (&ctx, ":", 1);
+               soup_md5_update (&ctx, "00000000000000000000000000000000", 32);
        }
 
        /* hexify A2 */
-       md5_final (&ctx, d);
+       soup_md5_final (&ctx, d);
        digest_hex (d, hex_a2);
 
        /* compute KD */
-       md5_init (&ctx);
-       md5_update (&ctx, hex_a1, 32);
-       md5_update (&ctx, ":", 1);
-       md5_update (&ctx, digest->nonce, strlen (digest->nonce));
-       md5_update (&ctx, ":", 1);
+       soup_md5_init (&ctx);
+       soup_md5_update (&ctx, hex_a1, 32);
+       soup_md5_update (&ctx, ":", 1);
+       soup_md5_update (&ctx, digest->nonce, strlen (digest->nonce));
+       soup_md5_update (&ctx, ":", 1);
 
        tmp = g_strdup_printf ("%.8x", digest->nonce_count);
-       md5_update (&ctx, tmp, strlen (tmp));
+       soup_md5_update (&ctx, tmp, strlen (tmp));
        g_free (tmp);
 
-       md5_update (&ctx, ":", 1);
-       md5_update (&ctx, digest->cnonce, strlen (digest->cnonce));
-       md5_update (&ctx, ":", 1);
+       soup_md5_update (&ctx, ":", 1);
+       soup_md5_update (&ctx, digest->cnonce, strlen (digest->cnonce));
+       soup_md5_update (&ctx, ":", 1);
 
        if (digest->integrity)
                tmp = "auth-int";
        else 
                tmp = "auth";
 
-       md5_update (&ctx, tmp, strlen (tmp));
-       md5_update (&ctx, ":", 1);
+       soup_md5_update (&ctx, tmp, strlen (tmp));
+       soup_md5_update (&ctx, ":", 1);
 
-       md5_update (&ctx, hex_a2, 32);
-       md5_final (&ctx, d);
+       soup_md5_update (&ctx, hex_a2, 32);
+       soup_md5_final (&ctx, d);
 
        digest_hex (d, o);
 
index c29dacd..f55e680 100644 (file)
@@ -15,7 +15,6 @@
 #include <unistd.h>
 
 #include "soup-server-message.h"
-#include "soup-message-private.h"
 #include "soup-private.h"
 #include "soup-server.h"
 
index e2e4531..d87b838 100644 (file)
@@ -22,7 +22,6 @@
 #include "soup-address.h"
 #include "soup-headers.h"
 #include "soup-private.h"
-#include "soup-message-private.h"
 #include "soup-server-auth.h"
 #include "soup-server-message.h"
 #include "soup-socket.h"
index 7576f61..a4b2b7c 100644 (file)
@@ -15,7 +15,6 @@
 
 #include "soup-session.h"
 #include "soup-connection.h"
-#include "soup-message-private.h"
 #include "soup-message-queue.h"
 #include "soup-private.h"
 
@@ -37,7 +36,6 @@ struct SoupSessionPrivate {
        guint max_conns, max_conns_per_host;
 
        SoupMessageQueue *queue;
-       guint queue_idle_tag;
 
        GHashTable *hosts; /* SoupUri -> SoupSessionHost */
        GHashTable *conns; /* SoupConnection -> SoupSessionHost */
@@ -79,9 +77,6 @@ finalize (GObject *object)
        SoupMessageQueueIter iter;
        SoupMessage *msg;
 
-       if (session->priv->queue_idle_tag)
-               g_source_remove (session->priv->queue_idle_tag);
-
        for (msg = soup_message_queue_first (session->priv->queue, &iter); msg;
             msg = soup_message_queue_next (session->priv->queue, &iter)) {
                soup_message_queue_remove (session->priv->queue, &iter);
@@ -413,7 +408,7 @@ request_finished (SoupMessage *req, gpointer user_data)
        SoupSession *session = user_data;
 
        soup_message_queue_remove_message (session->priv->queue, req);
-       req->priv->status = SOUP_MESSAGE_STATUS_FINISHED;
+       req->status = SOUP_MESSAGE_STATUS_FINISHED;
 }
 
 static void
@@ -454,7 +449,7 @@ add_auth (SoupSession *session, SoupMessage *msg, gboolean proxy)
 static void
 send_request (SoupSession *session, SoupMessage *req, SoupConnection *conn)
 {
-       req->priv->status = SOUP_MESSAGE_STATUS_RUNNING;
+       req->status = SOUP_MESSAGE_STATUS_RUNNING;
 
        add_auth (session, req, FALSE);
        if (session->priv->proxy_uri)
@@ -595,7 +590,7 @@ run_queue (SoupSession *session, gboolean try_pruning)
                        continue;
                }
 
-               if (msg->priv->status == SOUP_MESSAGE_STATUS_CONNECTING) {
+               if (msg->status == SOUP_MESSAGE_STATUS_CONNECTING) {
                        /* We already started a connection for this
                         * message, so don't start another one.
                         */
@@ -641,7 +636,7 @@ run_queue (SoupSession *session, gboolean try_pruning)
                /* Mark the request as connecting, so we don't try to
                 * open another new connection for it next time around.
                 */
-               msg->priv->status = SOUP_MESSAGE_STATUS_CONNECTING;
+               msg->status = SOUP_MESSAGE_STATUS_CONNECTING;
 
                started_any = TRUE;
        }
@@ -661,37 +656,24 @@ run_queue (SoupSession *session, gboolean try_pruning)
        return started_any;
 }
 
-static gboolean
-idle_run_queue (gpointer user_data)
-{
-       SoupSession *session = user_data;
-
-       session->priv->queue_idle_tag = 0;
-       run_queue (session, TRUE);
-       return FALSE;
-}
-
 static void
 queue_message (SoupSession *session, SoupMessage *req, gboolean requeue)
 {
        soup_message_prepare (req);
 
-       req->priv->status = SOUP_MESSAGE_STATUS_QUEUED;
+       req->status = SOUP_MESSAGE_STATUS_QUEUED;
        if (!requeue)
                soup_message_queue_append (session->priv->queue, req);
 
-       if (!session->priv->queue_idle_tag) {
-               session->priv->queue_idle_tag =
-                       g_idle_add (idle_run_queue, session);
-       }
+       run_queue (session, TRUE);
 }
 
 /**
  * soup_session_queue_message:
  * @session: a #SoupSession
  * @req: the message to queue
- * @callback: a #SoupCallbackFn which will be called after the message
- * completes or when an unrecoverable error occurs.
+ * @callback: a #SoupMessageCallbackFn which will be called after the
+ * message completes or when an unrecoverable error occurs.
  * @user_data: a pointer passed to @callback.
  * 
  * Queues the message @req for sending. All messages are processed
@@ -704,7 +686,7 @@ queue_message (SoupSession *session, SoupMessage *req, gboolean requeue)
  */
 void
 soup_session_queue_message (SoupSession *session, SoupMessage *req,
-                           SoupCallbackFn callback, gpointer user_data)
+                           SoupMessageCallbackFn callback, gpointer user_data)
 {
        g_return_if_fail (SOUP_IS_SESSION (session));
        g_return_if_fail (SOUP_IS_MESSAGE (req));
@@ -726,7 +708,7 @@ soup_session_queue_message (SoupSession *session, SoupMessage *req,
                                               SOUP_HANDLER_POST_BODY,
                                               authorize_handler, session);
 
-       if (!(req->priv->msg_flags & SOUP_MESSAGE_NO_REDIRECT)) {
+       if (!(soup_message_get_flags (req) & SOUP_MESSAGE_NO_REDIRECT)) {
                soup_message_add_status_class_handler (
                        req, SOUP_STATUS_CLASS_REDIRECT,
                        SOUP_HANDLER_POST_BODY,
@@ -781,7 +763,7 @@ soup_session_send_message (SoupSession *session, SoupMessage *req)
        while (1) {
                g_main_iteration (TRUE);
 
-               if (req->priv->status == SOUP_MESSAGE_STATUS_FINISHED ||
+               if (req->status == SOUP_MESSAGE_STATUS_FINISHED ||
                    SOUP_STATUS_IS_TRANSPORT (req->status_code))
                        break;
        }
index 9ece051..d0d91ff 100644 (file)
@@ -5,7 +5,6 @@
 #include "libsoup/soup.h"
 #include "libsoup/soup-auth.h"
 #include "libsoup/soup-private.h"
-#include "libsoup/soup-message-private.h"
 #include "libsoup/soup-session.h"
 
 int errors = 0;