// Generated by gmmproc 2.43.90 -- DO NOT MODIFY!


#include <glibmm.h>

#include <giomm/tlscertificate.h>
#include <giomm/private/tlscertificate_p.h>


/* Copyright (C) 2012 The giomm Development Team
 *
 * This library 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.
 *
 * This library 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 library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#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

namespace
{
} // anonymous namespace


namespace Glib
{

Glib::RefPtr<Gio::TlsCertificate> wrap(GTlsCertificate* object, bool take_copy)
{
  return Glib::RefPtr<Gio::TlsCertificate>( dynamic_cast<Gio::TlsCertificate*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
  //We use dynamic_cast<> in case of multiple inheritance.
}

} /* namespace Glib */


namespace Gio
{


/* The *_Class implementation: */

const Glib::Class& TlsCertificate_Class::init()
{
  if(!gtype_) // create the GType if necessary
  {
    // Glib::Class has to know the class init function to clone custom types.
    class_init_func_ = &TlsCertificate_Class::class_init_function;

    // This is actually just optimized away, apparently with no harm.
    // Make sure that the parent type has been created.
    //CppClassParent::CppObjectType::get_type();

    // Create the wrapper type, with the same class/instance size as the base type.
    register_derived_type(g_tls_certificate_get_type());

    // Add derived versions of interfaces, if the C type implements any interfaces:

  }

  return *this;
}


void TlsCertificate_Class::class_init_function(void* g_class, void* class_data)
{
  BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
  CppClassParent::class_init_function(klass, class_data);

  klass->verify = &verify_vfunc_callback;

}

GTlsCertificateFlags TlsCertificate_Class::verify_vfunc_callback(GTlsCertificate* self, GSocketConnectable* identity, GTlsCertificate* trusted_ca)
{
  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
      #endif //GLIBMM_EXCEPTIONS_ENABLED
        // Call the virtual member method, which derived classes might override.
        return ((GTlsCertificateFlags)(obj->verify_vfunc(Glib::wrap(identity, true)
, Glib::wrap(trusted_ca, true)
)));
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
      #endif //GLIBMM_EXCEPTIONS_ENABLED
    }
  }

  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
  );

  // Call the original underlying C function:
  if(base && base->verify)
  {
    GTlsCertificateFlags retval = (*base->verify)(self, identity, trusted_ca);
    return retval;
  }

  typedef GTlsCertificateFlags RType;
  return RType();
}


Glib::ObjectBase* TlsCertificate_Class::wrap_new(GObject* object)
{
  return new TlsCertificate((GTlsCertificate*)object);
}


/* The implementation: */

GTlsCertificate* TlsCertificate::gobj_copy()
{
  reference();
  return gobj();
}

TlsCertificate::TlsCertificate(const Glib::ConstructParams& construct_params)
:
  Glib::Object(construct_params)
{

}

TlsCertificate::TlsCertificate(GTlsCertificate* castitem)
:
  Glib::Object((GObject*)(castitem))
{}


TlsCertificate::~TlsCertificate()
{}


TlsCertificate::CppClassType TlsCertificate::tlscertificate_class_; // initialize static member

GType TlsCertificate::get_type()
{
  return tlscertificate_class_.init().get_type();
}


GType TlsCertificate::get_base_type()
{
  return g_tls_certificate_get_type();
}


TlsCertificate::TlsCertificate(const std::string& data, gssize length)
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(0),
  Glib::Object(Glib::ConstructParams(tlscertificate_class_.init(), "data", data.c_str(), "length", length, static_cast<char*>(0)))
{
  

}

TlsCertificate::TlsCertificate(const std::string& file)
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(0),
  Glib::Object(Glib::ConstructParams(tlscertificate_class_.init(), "file", file.c_str(), static_cast<char*>(0)))
{
  

}

TlsCertificate::TlsCertificate(const std::string& cert_file, const std::string& key_file)
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(0),
  Glib::Object(Glib::ConstructParams(tlscertificate_class_.init(), "cert_file", cert_file.c_str(), "key_file", key_file.c_str(), static_cast<char*>(0)))
{
  

}

Glib::RefPtr<TlsCertificate> TlsCertificate::create(const std::string& file)
{
  return Glib::RefPtr<TlsCertificate>( new TlsCertificate(file) );
}

Glib::RefPtr<TlsCertificate> TlsCertificate::create(const std::string& cert_file, const std::string& key_file)
{
  return Glib::RefPtr<TlsCertificate>( new TlsCertificate(cert_file, key_file) );
}

std::vector< Glib::RefPtr<TlsCertificate> > TlsCertificate::create_list_from_file(const std::string& file)
{
  GError* gerror = 0;
  std::vector< Glib::RefPtr<TlsCertificate> > retvalue = Glib::ListHandler< Glib::RefPtr<TlsCertificate> >::list_to_vector(g_tls_certificate_list_new_from_file(file.c_str(), &(gerror)), Glib::OWNERSHIP_DEEP);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}


Glib::RefPtr<TlsCertificate> TlsCertificate::get_issuer()
{
  Glib::RefPtr<TlsCertificate> retvalue = Glib::wrap(g_tls_certificate_get_issuer(gobj()));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;
}

Glib::RefPtr<const TlsCertificate> TlsCertificate::get_issuer() const
{
  return const_cast<TlsCertificate*>(this)->get_issuer();
}

TlsCertificateFlags TlsCertificate::verify(const Glib::RefPtr<const SocketConnectable>& identity, const Glib::RefPtr<const TlsCertificate>& trusted_ca) const
{
  return ((TlsCertificateFlags)(g_tls_certificate_verify(const_cast<GTlsCertificate*>(gobj()), const_cast<GSocketConnectable*>(Glib::unwrap(identity)), const_cast<GTlsCertificate*>(Glib::unwrap(trusted_ca)))));
}

TlsCertificateFlags TlsCertificate::verify(const Glib::RefPtr<const SocketConnectable>& identity) const
{
  return ((TlsCertificateFlags)(g_tls_certificate_verify(const_cast<GTlsCertificate*>(gobj()), const_cast<GSocketConnectable*>(Glib::unwrap(identity)), 0)));
}

TlsCertificateFlags TlsCertificate::verify(const Glib::RefPtr<const TlsCertificate>& trusted_ca) const
{
  return ((TlsCertificateFlags)(g_tls_certificate_verify(const_cast<GTlsCertificate*>(gobj()), 0, const_cast<GTlsCertificate*>(Glib::unwrap(trusted_ca)))));
}

TlsCertificateFlags TlsCertificate::verify() const
{
  return ((TlsCertificateFlags)(g_tls_certificate_verify(const_cast<GTlsCertificate*>(gobj()), 0, 0)));
}

bool TlsCertificate::is_same(const Glib::RefPtr<const TlsCertificate>& cert_two) const
{
  return g_tls_certificate_is_same(const_cast<GTlsCertificate*>(gobj()), const_cast<GTlsCertificate*>(Glib::unwrap(cert_two)));
}


#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Glib::ByteArray> > TlsCertificate::property_certificate() const
{
  return Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Glib::ByteArray> >(this, "certificate");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_ReadOnly< std::string > TlsCertificate::property_certificate_pem() const
{
  return Glib::PropertyProxy_ReadOnly< std::string >(this, "certificate-pem");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<TlsCertificate> > TlsCertificate::property_issuer() const
{
  return Glib::PropertyProxy_ReadOnly< Glib::RefPtr<TlsCertificate> >(this, "issuer");
}
#endif //GLIBMM_PROPERTIES_ENABLED


TlsCertificateFlags Gio::TlsCertificate::verify_vfunc(const Glib::RefPtr<const SocketConnectable>& identity, const Glib::RefPtr<const TlsCertificate>& trusted_ca) const
{
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
  );

  if(base && base->verify)
  {
    TlsCertificateFlags retval(((TlsCertificateFlags)((*base->verify)(const_cast<GTlsCertificate*>(gobj()),const_cast<GSocketConnectable*>(Glib::unwrap(identity)),const_cast<GTlsCertificate*>(Glib::unwrap(trusted_ca))))));
    return retval;
  }

  typedef TlsCertificateFlags RType;
  return RType();
}


} // namespace Gio


