[glibmm] TlsCertificate: Use std::string for data instead of char*.



commit e4aaf9bc2f9cff25d93e5de2db39a4649c4321d1
Author: José Alburquerque <jaalburqu svn gnome org>
Date:   Sun Mar 31 23:22:54 2013 -0400

    TlsCertificate: Use std::string for data instead of char*.
    
        * gio/src/tlscertificate.{ccg,hg} (TlsCertificate): Use a std::string
        in the data constructor instead of a char* because it is more C++
        like.  Remove the default value for the length argument so there is no
        ambiguity with the file constructor (which also uses std::string for
        the filename).
        (create_from_pem): Renamed from create() so that there is no ambiguity
        with the other file create() methods (one with a filename argument and
        the other with a filename and key file arguments).  Handwrote the
        method in the .ccg file (_WRAP_CREATE does not allow a custom method
        name).
        (property_certificate_pem): Use a std::string instead of a char* for
        the property type in keeping with the use of std::string for pem data.
    
        These changes are for when the Tls* classes are re-added to the build.

 ChangeLog                  |   19 +++++++++++++++++++
 gio/src/tlscertificate.ccg |   11 +++++++++++
 gio/src/tlscertificate.hg  |    9 +++++----
 3 files changed, 35 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8a6b6c2..0e162f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
 2013-03-31  José Alburquerque  <jaalburquerque gmail com>
 
+       TlsCertificate: Use std::string for data instead of char*.
+
+       * gio/src/tlscertificate.{ccg,hg} (TlsCertificate): Use a std::string
+       in the data constructor instead of a char* because it is more C++
+       like.  Remove the default value for the length argument so there is no
+       ambiguity with the file constructor (which also uses std::string for
+       the filename).
+       (create_from_pem): Renamed from create() so that there is no ambiguity
+       with the other file create() methods (one with a filename argument and
+       the other with a filename and key file arguments).  Handwrote the
+       method in the .ccg file (_WRAP_CREATE does not allow a custom method
+       name).
+       (property_certificate_pem): Use a std::string instead of a char* for
+       the property type in keeping with the use of std::string for pem data.
+
+       These changes are for when the Tls* classes are re-added to the build.
+
+2013-03-31  José Alburquerque  <jaalburquerque gmail com>
+
        Credentials: Add the get_unix_pid() method.
 
        * gio/src/credentials.hg: Add the new method wrapping the
diff --git a/gio/src/tlscertificate.ccg b/gio/src/tlscertificate.ccg
index d0262cd..dd68cad 100644
--- a/gio/src/tlscertificate.ccg
+++ b/gio/src/tlscertificate.ccg
@@ -18,3 +18,14 @@
 #include <gio/gio.h>
 #include <glibmm/bytearray.h>
 #include <giomm/socketconnectable.h>
+
+namespace Gio
+{
+
+Glib::RefPtr<TlsCertificate>
+TlsCertificate::create_from_pem(const std::string& data, gssize length)
+{
+  return Glib::RefPtr<TlsCertificate>( new TlsCertificate(data, length) );
+}
+
+} // namesapce Gio
diff --git a/gio/src/tlscertificate.hg b/gio/src/tlscertificate.hg
index 9a0a61c..80484fb 100644
--- a/gio/src/tlscertificate.hg
+++ b/gio/src/tlscertificate.hg
@@ -46,13 +46,14 @@ class TlsCertificate : public Glib::Object
   _CLASS_GOBJECT(TlsCertificate, GTlsCertificate, G_TLS_CERTIFICATE, Glib::Object, GObject)
 
 protected:
-  _WRAP_CTOR(TlsCertificate(const char* data, gssize length = -1), g_tls_certificate_new_from_pem, errthrow)
+  _WRAP_CTOR(TlsCertificate(const std::string& data, gssize length), g_tls_certificate_new_from_pem, 
errthrow)
   _WRAP_CTOR(TlsCertificate(const std::string& file), g_tls_certificate_new_from_file, errthrow)
   _WRAP_CTOR(TlsCertificate(const std::string& cert_file, const std::string& key_file), 
g_tls_certificate_new_from_files, errthrow)
 
 public:
   _WRAP_METHOD_DOCS_ONLY(g_tls_certificate_new_from_pem)
-  _WRAP_CREATE(const char* data, gssize length = -1)
+  static Glib::RefPtr<TlsCertificate>
+    create_from_pem(const std::string& data, gssize length = -1);
 
   _WRAP_METHOD_DOCS_ONLY(g_tls_certificate_new_from_file)
   _WRAP_CREATE(const std::string& file)
@@ -70,14 +71,14 @@ public:
   _WRAP_METHOD(bool is_same(const Glib::RefPtr<const TlsCertificate>& cert_two) const, 
g_tls_certificate_is_same)
 
   _WRAP_PROPERTY("certificate", Glib::RefPtr<Glib::ByteArray>)
-  _WRAP_PROPERTY("certificate-pem", char*)
+  _WRAP_PROPERTY("certificate-pem", std::string)
   _WRAP_PROPERTY("issuer", Glib::RefPtr<TlsCertificate>)
 
   // Write-only and construct-only
   //_WRAP_PROPERTY("private-key", Glib::RefPtr<Glib::ByteArray>)
 
   // Write-only and construct-only
-  //_WRAP_PROPERTY("private-key-pem", char*)
+  //_WRAP_PROPERTY("private-key-pem", std::string)
 
 #m4 _CONVERSION(`GSocketConnectable*',`const Glib::RefPtr<const SocketConnectable>&',`Glib::wrap($3, true)')
 #m4 _CONVERSION(`GTlsCertificate*',`const Glib::RefPtr<const TlsCertificate>&',`Glib::wrap($3, true)')


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