[libsoupmm] Wrap more API for Soup::Message



commit b3583ed9cacc96edc68aba9add39003b53f2c1e8
Author: Siavash Safi <siavash siavashs org>
Date:   Fri Nov 20 19:11:39 2009 +0330

    Wrap more API for Soup::Message
    
    * codegen/m4/convert_libsoup.m4: Add conversion for MessageFlags.
    * libsoup/src/message.{hg|ccg}: Hand code MessageFlags.
    Disable create_xmlrpc_request() for now since it uses Glib::ValueBase
    in public API.
    Remove MemoryUse argument from set_request() since it's useless in C++.
    Add get_address(), get_flags(), set_flags().

 codegen/m4/convert_libsoup.m4 |    1 +
 libsoup/src/message.ccg       |   12 ++++++------
 libsoup/src/message.hg        |   22 ++++++++++++++++++----
 3 files changed, 25 insertions(+), 10 deletions(-)
---
diff --git a/codegen/m4/convert_libsoup.m4 b/codegen/m4/convert_libsoup.m4
index 59a8ff3..aedad99 100644
--- a/codegen/m4/convert_libsoup.m4
+++ b/codegen/m4/convert_libsoup.m4
@@ -37,3 +37,4 @@ _CONVERSION(`GMainContext*',`Glib::RefPtr<Glib::MainContext>',`Glib::wrap($3)')
 _CONV_ENUM(Soup,DateFormat)
 _CONV_ENUM(Soup,HTTPVersion)
 _CONV_ENUM(Soup,MemoryUse)
+_CONV_ENUM(Soup,MessageFlags)
diff --git a/libsoup/src/message.ccg b/libsoup/src/message.ccg
index 738de22..bbae278 100644
--- a/libsoup/src/message.ccg
+++ b/libsoup/src/message.ccg
@@ -52,7 +52,7 @@ Message::create_form_request(const std::string& method, const std::string& uri_s
 
   if((method == "POST") || method == "PUT")
   {
-    msg->set_request(SOUP_FORM_MIME_TYPE_URLENCODED, MEMORY_COPY, form_data);
+    msg->set_request(SOUP_FORM_MIME_TYPE_URLENCODED, form_data);
     form_data.erase();
   }
 
@@ -63,7 +63,7 @@ Message::create_form_request(const std::string& method, const std::string& uri_s
 
   return msg;
 }
-
+/*
 Glib::RefPtr<Message>
 Message::create_xmlrpc_request(const std::string& uri_string, const std::string& method_name, const std::list<Glib::ValueBase>& params)
 {
@@ -72,14 +72,14 @@ Message::create_xmlrpc_request(const std::string& uri_string, const std::string&
     return Glib::RefPtr<Message>(0);
 
   Glib::RefPtr<Message> msg = create("POST", uri_string);
-  msg->set_request("text/xml", MEMORY_COPY, body);
+  msg->set_request("text/xml", body);
   return msg;
 }
-
+*/
 void
-Message::set_request(const std::string& type, MemoryUse use, const std::string& body)
+Message::set_request(const std::string& type, const std::string& body)
 {
-  soup_message_set_request(gobj(), type.c_str(), SoupMemoryUse(use), body.c_str(), body.size());
+  soup_message_set_request(gobj(), type.c_str(), SOUP_MEMORY_COPY, body.c_str(), body.size());
 }
 
 } // namespace Soup
diff --git a/libsoup/src/message.hg b/libsoup/src/message.hg
index 42abdac..92951ce 100644
--- a/libsoup/src/message.hg
+++ b/libsoup/src/message.hg
@@ -29,6 +29,14 @@ namespace Soup
 
 _WRAP_ENUM(HTTPVersion, SoupHTTPVersion, NO_GTYPE)
 
+enum MessageFlags
+{
+#ifndef LIBSOUP_DISABLE_DEPRECATED
+  OVERWRITE_CHUNKS = (1 << 3),
+#endif
+  NO_REDIRECT      = (1 << 1)
+};
+
 class Message : public Glib::Object
 {
   _CLASS_GOBJECT(Message, SoupMessage, SOUP_MESSAGE, Glib::Object, GObject)
@@ -42,17 +50,17 @@ public:
   _WRAP_CREATE(const std::string& method, const URI& uri)
   static Glib::RefPtr<Message> create(const std::string& method, const std::string& uri_string);
   static Glib::RefPtr<Message> create_form_request(const std::string& method, const std::string& uri_string, const std::map<std::string, std::string>& fields);
-  static Glib::RefPtr<Message> create_xmlrpc_request(const std::string& uri_string, const std::string& method_name, const std::list<Glib::ValueBase>& params);
 
-  // TODO: Check if all types of MemoryUse work, e.g. what happens when we use MEMORY_TAKE ?
+  // TODO: Replace the Glib::ValueBase with a custom container?
+  //static Glib::RefPtr<Message> create_xmlrpc_request(const std::string& uri_string, const std::string& method_name, const std::list<Glib::ValueBase>& params);
+
   /** Convenience function to set the request body of a Soup::Message.
    * If type is empty, the request body must be empty as well.
    *
    * @param type MIME Content-Tpe of the body
-   * @param use a Soup::MemoryUse describing how to handle the body
    * @param body a data buffer containing the message request.
    */
-  void set_request(const std::string& type, MemoryUse use, const std::string& body);
+  void set_request(const std::string& type, const std::string& body);
   _WRAP_METHOD(void set_http_version(HTTPVersion version), soup_message_set_http_version)
   _WRAP_METHOD(HTTPVersion get_http_version(), soup_message_get_http_version)
 
@@ -60,10 +68,16 @@ public:
   _WRAP_METHOD(URI get_uri(), soup_message_get_uri)
   _WRAP_METHOD(URI get_uri() const, soup_message_get_uri, constversion)
 
+  _WRAP_METHOD(Glib::RefPtr<Address> get_address(), soup_message_get_adress)
+  _WRAP_METHOD(Glib::RefPtr<const Address> get_address() const, soup_message_get_adress, constversion)
+
   _WRAP_METHOD(void set_status(guint status), soup_message_set_status)
   _WRAP_METHOD(void set_status(guint status, const std::string& reason), soup_message_set_status_full)
   _WRAP_METHOD(bool is_keepalive() const, soup_message_is_keepalive)
 
+  _WRAP_METHOD(void set_flags(MessageFlags flags), soup_message_set_flags)
+  _WRAP_METHOD(MessageFlags get_flags() const, soup_message_get_flags)
+
   _WRAP_SIGNAL(void finished(), "finished")
   _WRAP_SIGNAL(void got_body(), "got-body")
   _WRAP_SIGNAL(void got_chunk(Buffer& buffer), "got-chunk")



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