[libsoupmm] Add Soup::Server



commit 8397395b687af16eb109537c25580a4fb1e6a763
Author: Siavash Safi <siavash siavashs org>
Date:   Wed Sep 2 15:49:08 2009 +0430

    Add Soup::Server
    
    * codegen/extradefs/generate_extra_defs_libsoup.cc: Added new types
    * codegen/m4/convert_libsoup.m4:
    * libsoup/.gitignore:
    * libsoup/libsoupmm.h:
    * libsoup/src/filelist.am: Add libsoup_others.defs
    * libsoup/src/libsoup.defs: Add libsoup_others.defs
    * libsoup/src/libsoup_others.defs: Add define-object for
    SoupClientContext to get rid of warnings from DocsParser.pm
    * libsoup/src/libsoup_signals.defs: Regenerated
    * libsoup/src/server.ccg:
    * libsoup/src/server.hg:

 codegen/extradefs/generate_extra_defs_libsoup.cc |    2 +
 codegen/m4/convert_libsoup.m4                    |    6 +
 libsoup/.gitignore                               |    2 +
 libsoup/libsoupmm.h                              |    1 +
 libsoup/src/filelist.am                          |    3 +-
 libsoup/src/libsoup.defs                         |    1 +
 libsoup/src/libsoup_others.defs                  |    6 +
 libsoup/src/libsoup_signals.defs                 |  107 ++++++++++++++++++++++
 libsoup/src/server.ccg                           |   44 +++++++++
 libsoup/src/server.hg                            |   74 +++++++++++++++
 10 files changed, 245 insertions(+), 1 deletions(-)
---
diff --git a/codegen/extradefs/generate_extra_defs_libsoup.cc b/codegen/extradefs/generate_extra_defs_libsoup.cc
index 27f7705..e896940 100644
--- a/codegen/extradefs/generate_extra_defs_libsoup.cc
+++ b/codegen/extradefs/generate_extra_defs_libsoup.cc
@@ -29,9 +29,11 @@ int main(int, char**)
   std::cout << get_defs(SOUP_TYPE_ADDRESS);
   std::cout << get_defs(SOUP_TYPE_AUTH);
   std::cout << get_defs(SOUP_TYPE_BUFFER);
+  std::cout << get_defs(SOUP_TYPE_CLIENT_CONTEXT);
   std::cout << get_defs(SOUP_TYPE_MESSAGE);
   std::cout << get_defs(SOUP_TYPE_MESSAGE_BODY);
   std::cout << get_defs(SOUP_TYPE_SESSION);
+  std::cout << get_defs(SOUP_TYPE_SERVER);
   std::cout << get_defs(SOUP_TYPE_URI);
 
   return 0;
diff --git a/codegen/m4/convert_libsoup.m4 b/codegen/m4/convert_libsoup.m4
index f6c9405..f9250d2 100644
--- a/codegen/m4/convert_libsoup.m4
+++ b/codegen/m4/convert_libsoup.m4
@@ -4,11 +4,16 @@ dnl This file is part of libsoupmm.
 _CONVERSION(`SoupAuth*',`const Glib::RefPtr<Auth>&',`Glib::wrap($3)')
 _CONVERSION(`const Glib::RefPtr<Auth>&',`SoupAuth*',__CONVERT_REFPTR_TO_P)
 
+_CONVERSION(`SoupAddress*',`Glib::RefPtr<Address>',`Glib::wrap($3)')
+
 _CONVERSION(`Buffer',`SoupBuffer*',($3).gobj())
 _CONVERSION(`Buffer&',`SoupBuffer*',($3).gobj())
 _CONVERSION(`SoupBuffer*',`Buffer',($2)($3))
 _CONVERSION(`SoupBuffer*',`Buffer&',($2)($3))
 
+_CONVERSION(`SoupClientContext*',`ClientContext',`Glib::wrap($3)')
+_CONVERSION(`ClientContext',`SoupClientContext*',($3).gobj())
+
 _CONVERSION(`SoupMessage*',`Glib::RefPtr<Message>',`Glib::wrap($3)')
 _CONVERSION(`SoupMessage*',`const Glib::RefPtr<Message>&',`Glib::wrap($3)')
 _CONVERSION(`const Glib::RefPtr<Message>&',`SoupMessage*',__CONVERT_REFPTR_TO_P)
@@ -22,6 +27,7 @@ _CONVERSION(`const URI&',`SoupURI*',($3).gobj())
 _CONVERSION(`SoupURI*',`URI',($2)($3))
 
 _CONVERSION(`return-char*',`std::string',`Glib::convert_return_gchar_ptr_to_stdstring($3)')
+_CONVERSION(`GMainContext*',`Glib::RefPtr<Glib::MainContext>',`Glib::wrap($3)')
 
 _CONV_ENUM(Soup,HTTPVersion)
 _CONV_ENUM(Soup,MemoryUse)
diff --git a/libsoup/.gitignore b/libsoup/.gitignore
index 7c609c2..f65f7c8 100644
--- a/libsoup/.gitignore
+++ b/libsoup/.gitignore
@@ -10,6 +10,8 @@
 /libsoupmm/message.h
 /libsoupmm/message-body.cc
 /libsoupmm/message-body.h
+/libsoupmm/server.cc
+/libsoupmm/server.h
 /libsoupmm/session.cc
 /libsoupmm/session.h
 /libsoupmm/uri.cc
diff --git a/libsoup/libsoupmm.h b/libsoup/libsoupmm.h
index 24d4357..c6a1415 100644
--- a/libsoup/libsoupmm.h
+++ b/libsoup/libsoupmm.h
@@ -29,6 +29,7 @@
 #include <libsoupmm/form.h>
 #include <libsoupmm/message.h>
 #include <libsoupmm/message-body.h>
+#include <libsoupmm/server.h>
 #include <libsoupmm/session.h>
 #include <libsoupmm/status.h>
 #include <libsoupmm/uri.h>
diff --git a/libsoup/src/filelist.am b/libsoup/src/filelist.am
index c23db5b..ace6e5c 100644
--- a/libsoup/src/filelist.am
+++ b/libsoup/src/filelist.am
@@ -4,9 +4,10 @@ files_defs =			\
 	libsoup.defs		\
 	libsoup_enums.defs	\
 	libsoup_methods.defs	\
+	libsoup_others.defs	\
 	libsoup_signals.defs	\
 	libsoup_docs.xml	\
 	libsoup_docs_override.xml
 
-files_hg  = address.hg auth.hg enums.hg message.hg message-body.hg session.hg uri.hg
+files_hg  = address.hg auth.hg enums.hg message.hg message-body.hg server.hg session.hg uri.hg
 files_ccg = $(files_hg:.hg=.ccg)
diff --git a/libsoup/src/libsoup.defs b/libsoup/src/libsoup.defs
index 803e22c..85a0e0c 100644
--- a/libsoup/src/libsoup.defs
+++ b/libsoup/src/libsoup.defs
@@ -1,4 +1,5 @@
 ;; Include generated API definition files
 (include libsoup_enums.defs)
 (include libsoup_methods.defs)
+(include libsoup_others.defs)
 (include libsoup_signals.defs)
diff --git a/libsoup/src/libsoup_others.defs b/libsoup/src/libsoup_others.defs
new file mode 100644
index 0000000..5f68d13
--- /dev/null
+++ b/libsoup/src/libsoup_others.defs
@@ -0,0 +1,6 @@
+(define-object ClientContext
+  (in-module "Soup")
+  (c-name "SoupClientContext")
+  (gtype-id "SOUP_TYPE_CLIENT_CONTEXT")
+)
+
diff --git a/libsoup/src/libsoup_signals.defs b/libsoup/src/libsoup_signals.defs
index 73a3621..a4714c9 100644
--- a/libsoup/src/libsoup_signals.defs
+++ b/libsoup/src/libsoup_signals.defs
@@ -94,6 +94,8 @@
 
 ;; From SoupBuffer
 
+;; From SoupClientContext
+
 ;; From SoupMessage
 
 (define-signal wrote-informational
@@ -382,5 +384,110 @@
   (construct-only #f)
 )
 
+;; From SoupServer
+
+(define-signal request-started
+  (of-object "SoupServer")
+  (return-type "void")
+  (when "first")
+  (parameters
+    '("SoupMessage*" "p0")
+    '("SoupClientContext*" "p1")
+  )
+)
+
+(define-signal request-read
+  (of-object "SoupServer")
+  (return-type "void")
+  (when "first")
+  (parameters
+    '("SoupMessage*" "p0")
+    '("SoupClientContext*" "p1")
+  )
+)
+
+(define-signal request-finished
+  (of-object "SoupServer")
+  (return-type "void")
+  (when "first")
+  (parameters
+    '("SoupMessage*" "p0")
+    '("SoupClientContext*" "p1")
+  )
+)
+
+(define-signal request-aborted
+  (of-object "SoupServer")
+  (return-type "void")
+  (when "first")
+  (parameters
+    '("SoupMessage*" "p0")
+    '("SoupClientContext*" "p1")
+  )
+)
+
+(define-property port
+  (of-object "SoupServer")
+  (prop-type "GParamUInt")
+  (docs "Port to listen on")
+  (readable #t)
+  (writable #t)
+  (construct-only #t)
+)
+
+(define-property interface
+  (of-object "SoupServer")
+  (prop-type "GParamObject")
+  (docs "Address of interface to listen on")
+  (readable #t)
+  (writable #t)
+  (construct-only #t)
+)
+
+(define-property ssl-cert-file
+  (of-object "SoupServer")
+  (prop-type "GParamString")
+  (docs "File containing server SSL certificate")
+  (readable #t)
+  (writable #t)
+  (construct-only #t)
+)
+
+(define-property ssl-key-file
+  (of-object "SoupServer")
+  (prop-type "GParamString")
+  (docs "File containing server SSL key")
+  (readable #t)
+  (writable #t)
+  (construct-only #t)
+)
+
+(define-property async-context
+  (of-object "SoupServer")
+  (prop-type "GParamPointer")
+  (docs "The GMainContext to dispatch async I/O in")
+  (readable #t)
+  (writable #t)
+  (construct-only #t)
+)
+
+(define-property raw-paths
+  (of-object "SoupServer")
+  (prop-type "GParamBoolean")
+  (docs "If %TRUE, percent-encoding in the Request-URI path will not be automatically decoded.")
+  (readable #t)
+  (writable #t)
+  (construct-only #t)
+)
+
+(define-property server-header
+  (of-object "SoupServer")
+  (prop-type "GParamString")
+  (docs "Server header")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
 ;; From SoupURI
 
diff --git a/libsoup/src/server.ccg b/libsoup/src/server.ccg
new file mode 100644
index 0000000..ea0f36c
--- /dev/null
+++ b/libsoup/src/server.ccg
@@ -0,0 +1,44 @@
+/* Copyright (c) 2009  Siavash Safi <siavashs siavashs org>
+ *
+ * This file is part of libsoupmm.
+ *
+ * libsoupmm is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 2.1 of the License,
+ * or (at your option) any later version.
+ *
+ * libsoupmm is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Soup
+{
+
+Server::Server(const Glib::RefPtr<Glib::MainContext>& async_context, Glib::RefPtr<Address>& interface, guint port, bool raw_path, const std::string& server_header, const std::string& ssl_cert_file, const std::string& ssl_key_file)
+{
+  GMainContext* c_context = NULL;
+  if(async_context)
+    c_context = async_context->gobj();
+
+  gobject_ = G_OBJECT(soup_server_new(SOUP_SERVER_ASYNC_CONTEXT, c_context,
+                             SOUP_SERVER_INTERFACE, interface->gobj(),
+                             SOUP_SERVER_PORT, port,
+                             SOUP_SERVER_RAW_PATHS, static_cast<int>(raw_path),
+                             SOUP_SERVER_SERVER_HEADER, server_header.c_str(),
+                             SOUP_SERVER_SSL_CERT_FILE, ssl_cert_file.c_str(),
+                             SOUP_SERVER_SSL_KEY_FILE, ssl_key_file.c_str(),
+                             NULL));
+}
+
+Glib::RefPtr<Server>
+Server::create(const Glib::RefPtr<Glib::MainContext>& async_context, Glib::RefPtr<Address>& interface, guint port, bool raw_path, const std::string& server_header, const std::string& ssl_cert_file, const std::string& ssl_key_file)
+{
+  return Glib::RefPtr<Server>(new Server(async_context, interface, port, raw_path, server_header, ssl_cert_file, ssl_key_file));
+}
+
+} // namespace Soup
diff --git a/libsoup/src/server.hg b/libsoup/src/server.hg
new file mode 100644
index 0000000..5b36910
--- /dev/null
+++ b/libsoup/src/server.hg
@@ -0,0 +1,74 @@
+/* Copyright (c) 2009  Siavash Safi <siavashs siavashs org>
+ *
+ * This file is part of libsoupmm.
+ *
+ * libsoupmm is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 2.1 of the License,
+ * or (at your option) any later version.
+ *
+ * libsoupmm is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glibmm/object.h>
+#include <libsoupmm/address.h>
+#include <libsoupmm/message.h>
+#include <libsoup/soup-server.h>
+
+_DEFS(libsoupmm,libsoup)
+_PINCLUDE(glibmm/private/object_p.h)
+
+// We define these micros since the copy and free functions do not exist
+#define SOUP_CLIENT_CONTEXT(obj)      (G_TYPE_CHECK_INSTANCE_CAST((obj), SOUP_TYPE_CLIENT_CONTEXT, SoupClientContext))
+#define soup_client_context_copy(obj) (SOUP_CLIENT_CONTEXT(g_boxed_copy(SOUP_TYPE_CLIENT_CONTEXT, obj)))
+#define soup_client_context_free(obj) (g_boxed_free(SOUP_TYPE_CLIENT_CONTEXT, obj))
+
+namespace Soup
+{
+
+class ClientContext
+{
+  _CLASS_BOXEDTYPE(ClientContext, SoupClientContext, NONE, soup_client_context_copy, soup_client_context_free)
+  _CUSTOM_STRUCT_PROTOTYPE
+
+public:
+  _WRAP_METHOD(Glib::RefPtr<Address> get_address(), soup_client_context_get_address)
+  _WRAP_METHOD(Glib::RefPtr<const Address> get_address() const, soup_client_context_get_address, constversion)
+  _WRAP_METHOD(std::string get_host() const, soup_client_context_get_host)
+  _WRAP_METHOD(std::string get_auth_user() const, soup_client_context_get_auth_user)
+};
+
+class Server : public Glib::Object
+{
+  _CLASS_GOBJECT(Server, SoupServer, SOUP_SERVER, Glib::Object, GObject)
+  _STRUCT_NOT_HIDDEN
+
+protected:
+ explicit Server(const Glib::RefPtr<Glib::MainContext>& async_context, Glib::RefPtr<Address>& interface, guint port, bool raw_path, const std::string& server_header, const std::string& ssl_cert_file, const std::string& ssl_key_file); 
+
+public:
+  static Glib::RefPtr<Server> create(const Glib::RefPtr<Glib::MainContext>& async_context, Glib::RefPtr<Address>& interface, guint port=0, bool raw_path=false, const std::string& server_header="", const std::string& ssl_cert_file="", const std::string& ssl_key_file="");
+
+  _WRAP_METHOD(bool is_https() const, soup_server_is_https)
+  _WRAP_METHOD(guint get_port() const, soup_server_get_port)
+  _WRAP_METHOD(void run(), soup_server_run)
+  _WRAP_METHOD(void run_async(), soup_server_run_async)
+  _WRAP_METHOD(void quit(), soup_server_quit)
+  _WRAP_METHOD(Glib::RefPtr<Glib::MainContext> get_async_context(), soup_server_get_async_context)
+  _WRAP_METHOD(Glib::RefPtr<const Glib::MainContext> get_async_context() const, soup_server_get_async_context, constversion)
+  _WRAP_METHOD(void pause_message(const Glib::RefPtr<Message>& msg), soup_server_pause_message)
+  _WRAP_METHOD(void unpause_message(const Glib::RefPtr<Message>& msg), soup_server_unpause_message)
+
+  _WRAP_SIGNAL(void request_aborted(const Glib::RefPtr<Message>& msg, ClientContext client), "request-aborted")
+  _WRAP_SIGNAL(void request_finished(const Glib::RefPtr<Message>& msg, ClientContext client), "request-finished")
+  _WRAP_SIGNAL(void request_read(const Glib::RefPtr<Message>& msg, ClientContext client), "request-read")
+  _WRAP_SIGNAL(void request_started(const Glib::RefPtr<Message>& msg, ClientContext client), "request-started")
+};
+
+} // namespace Soup



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