/* 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, see <http://www.gnu.org/licenses/>.
 */

_CONFIGINCLUDE(giommconfig.h)

#include <glibmm/object.h>

_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/object_p.h)

namespace Gio
{


/** TlsPassword - TLS Passwords for prompting.
 * Holds a password used in TLS.
 * @newin{2,36}
 */
class GIOMM_API TlsPassword : public Glib::Object
{
  _CLASS_GOBJECT(TlsPassword, GTlsPassword, G_TLS_PASSWORD, Glib::Object, GObject, , , GIOMM_API)

public:
  _WRAP_ENUM(Flags, GTlsPasswordFlags, decl_prefix GIOMM_API)

protected:
  _WRAP_CTOR(TlsPassword(const Glib::ustring& description{.}, Flags flags{.} = Flags::NONE), g_tls_password_new)

public:
  _WRAP_METHOD_DOCS_ONLY(g_tls_password_new)
  _WRAP_CREATE(const Glib::ustring& description{.}, Flags flags{.} = Flags::NONE)

  _WRAP_METHOD(const guchar* get_value(gsize& length{?}) const, g_tls_password_get_value)

  _WRAP_METHOD(void set_value(const guchar* value, gssize length = -1), g_tls_password_set_value)
  // This function does not copy the value as g_tls_password_set_value() does.
  // It keeps a reference to the original value and expects it to be freed
  // later in a specified GDestroyNotify callback.  Ignore it for now.
  _IGNORE(g_tls_password_set_value_full)

  _WRAP_METHOD(Glib::ustring get_description() const, g_tls_password_get_description)
  _WRAP_METHOD(void set_description(const Glib::ustring& description), g_tls_password_set_description)

  _WRAP_METHOD(Flags get_flags() const, g_tls_password_get_flags)
  _WRAP_METHOD(void set_flags(Flags flags), g_tls_password_set_flags)

  _WRAP_METHOD(Glib::ustring get_warning() const, g_tls_password_get_warning)
  _WRAP_METHOD(void set_warning(const Glib::ustring& warning), g_tls_password_set_warning)

  _WRAP_PROPERTY("description", Glib::ustring)
  _WRAP_PROPERTY("flags", Flags)
  _WRAP_PROPERTY("warning", Glib::ustring)

protected:
#m4 _CONVERSION(`gsize*', `gsize&', `*($3)')
  _WRAP_VFUNC(const guchar* get_value(gsize& length) const, "get_value")

  //TODO? (See g_tls_password_set_value_full() comment above): _WRAP_VFUNC(void set_value(guchar* value, gssize length, GDestroyNotify destroy), "set_value")

#m4 _CONVERSION(`Glib::ustring', `const gchar*', `$3.c_str()')
  _WRAP_VFUNC(Glib::ustring get_default_warning() const, "get_default_warning", keep_return)
};

} // namespace Gio
