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


#include <glibmm.h>

#include <giomm/socketlistener.h>
#include <giomm/private/socketlistener_p.h>


// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-

/* Copyright (C) 2010 Jonathon Jongsma
 *
 * 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 "slot_async.h"

namespace Gio
{

bool SocketListener::add_socket(const Glib::RefPtr<Socket>& socket)
{
  GError* gerror = nullptr;
  const bool retval = g_socket_listener_add_socket(gobj(),
    Glib::unwrap(socket),
    0,
  &gerror);

  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return retval;
}


bool SocketListener::add_address(const Glib::RefPtr<SocketAddress>& address, SocketType type, SocketProtocol protocol, const Glib::RefPtr<Glib::Object>& source_object, Glib::RefPtr<SocketAddress>& effective_address)
{
  GError* gerror = nullptr;
  GSocketAddress *retaddr = nullptr;
  const bool retval = g_socket_listener_add_address (gobj(),
                                          Glib::unwrap(address),
                                          static_cast<GSocketType>(type),
                                          static_cast<GSocketProtocol>(protocol),
                                          Glib::unwrap(source_object),
                                          &retaddr,
                                          &gerror);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  if(retaddr)
    effective_address = Glib::wrap(retaddr);

  return retval;
}

bool SocketListener::add_address(const Glib::RefPtr<SocketAddress>& address, SocketType type, SocketProtocol protocol, Glib::RefPtr<SocketAddress>& effective_address)
{
  GError* gerror = nullptr;
  GSocketAddress *retaddr = nullptr;
  const bool retval = g_socket_listener_add_address (gobj(),
                                          Glib::unwrap(address),
                                          static_cast<GSocketType>(type),
                                          static_cast<GSocketProtocol>(protocol),
                                          0,
                                          &retaddr,
                                          &gerror);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  if(retaddr)
    effective_address = Glib::wrap(retaddr);

  return retval;
}


bool SocketListener::add_inet_port(guint16 port)
{
  GError* gerror = nullptr;
  const bool retvalue = g_socket_listener_add_inet_port(gobj(), port, 0, &gerror);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return retvalue;
}


guint16 SocketListener::add_any_inet_port()
{
  GError* gerror = nullptr;
  const auto retvalue = g_socket_listener_add_any_inet_port(gobj(), 0, &gerror);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return retvalue;
}


Glib::RefPtr<Socket> SocketListener::accept_socket(Glib::RefPtr<Glib::Object>& source_object, const Glib::RefPtr<Cancellable>& cancellable)
{
  GError* gerror = nullptr;
  GObject *retobj = nullptr;
  auto retvalue = g_socket_listener_accept_socket(gobj(),
                                                      &retobj,
                                                      Glib::unwrap(cancellable),
                                                      &gerror);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  if(retobj)
    source_object = Glib::wrap(retobj);

  return Glib::wrap(retvalue);
}

Glib::RefPtr<Socket> SocketListener::accept_socket(Glib::RefPtr<Glib::Object>& source_object)
{
  GError* gerror = nullptr;
  GObject *retobj = nullptr;
  auto retvalue = g_socket_listener_accept_socket(gobj(),
                                                      &retobj,
                                                      0,
                                                      &gerror);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  if(retobj)
    source_object = Glib::wrap(retobj);

  return Glib::wrap(retvalue);
}

Glib::RefPtr<Socket> SocketListener::accept_socket(const Glib::RefPtr<Cancellable>& cancellable)
{
  GError* gerror = nullptr;
  auto retvalue = g_socket_listener_accept_socket(gobj(),
                                                      0,
                                                      Glib::unwrap(cancellable),
                                                      &gerror);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return Glib::wrap(retvalue);
}

Glib::RefPtr<Socket> SocketListener::accept_socket()
{
  GError* gerror = nullptr;
  auto retvalue = g_socket_listener_accept_socket(gobj(),
                                                      0,
                                                      0,
                                                      &gerror);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return Glib::wrap(retvalue);
}


void SocketListener::accept_socket_async(const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
{
  // Create a copy of the slot.
  // A pointer to it will be passed through the callback's data parameter
  // and deleted in the callback.
  auto slot_copy = new SlotAsyncReady(slot);

  g_socket_listener_accept_socket_async(gobj(),
                                        Glib::unwrap(cancellable),
                                        &SignalProxy_async_callback,
                                        slot_copy);
}

void SocketListener::accept_socket_async(const SlotAsyncReady& slot)
{
  // Create a copy of the slot.
  // A pointer to it will be passed through the callback's data parameter
  // and deleted in the callback.
  auto slot_copy = new SlotAsyncReady(slot);

  g_socket_listener_accept_socket_async(gobj(),
                                        0,
                                        &SignalProxy_async_callback,
                                        slot_copy);
}

Glib::RefPtr<Socket> SocketListener::accept_socket_finish(const Glib::RefPtr<AsyncResult>& result, Glib::RefPtr<Glib::Object>& source_object)
{
  GError* gerror = nullptr;
  GObject *retobj = nullptr;
  auto retvalue = g_socket_listener_accept_socket_finish(gobj(),
                                                             Glib::unwrap(result),
                                                             &retobj,
                                                             &gerror);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  if(retobj)
    source_object = Glib::wrap(retobj);

  return Glib::wrap(retvalue);
}

Glib::RefPtr<Socket> SocketListener::accept_socket_finish(const Glib::RefPtr<AsyncResult>& result)
{
  GError* gerror = nullptr;
  auto retvalue = g_socket_listener_accept_socket_finish(gobj(),
                                                             Glib::unwrap(result),
                                                             0,
                                                             &gerror);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return Glib::wrap(retvalue);
}


Glib::RefPtr<SocketConnection> SocketListener::accept(Glib::RefPtr<Object>& source_object, const Glib::RefPtr<Cancellable>& cancellable)
{
  GError* gerror = nullptr;
  GObject *retobj = nullptr;
  auto retvalue = g_socket_listener_accept(gobj(),
                                                         &retobj,
                                                         Glib::unwrap(cancellable),
                                                         &gerror);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  if(retobj)
    source_object = Glib::wrap(retobj);

  return Glib::wrap(retvalue);
}

Glib::RefPtr<SocketConnection> SocketListener::accept(Glib::RefPtr<Object>& source_object)
{
  GError* gerror = nullptr;
  GObject *retobj = nullptr;
  auto retvalue = g_socket_listener_accept(gobj(),
                                                         &retobj,
                                                         0,
                                                         &gerror);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  if(retobj)
    source_object = Glib::wrap(retobj);

  return Glib::wrap(retvalue);
}

Glib::RefPtr<SocketConnection> SocketListener::accept(const Glib::RefPtr<Cancellable>& cancellable)
{
  GError* gerror = nullptr;
  auto retvalue = g_socket_listener_accept(gobj(),
                                                         0,
                                                         Glib::unwrap(cancellable),
                                                         &gerror);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return Glib::wrap(retvalue);
}

Glib::RefPtr<SocketConnection> SocketListener::accept()
{
  GError* gerror = nullptr;
  auto retvalue = g_socket_listener_accept(gobj(),
                                                         0,
                                                         0,
                                                         &gerror);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return Glib::wrap(retvalue);
}


void SocketListener::accept_async(const SlotAsyncReady& slot)
{
  // Create a copy of the slot.
  // A pointer to it will be passed through the callback's data parameter
  // and deleted in the callback.
  auto slot_copy = new SlotAsyncReady(slot);

  g_socket_listener_accept_async(gobj(),
                                 0,
                                 &SignalProxy_async_callback,
                                 slot_copy);
}

void SocketListener::accept_async(const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
{
  // Create a copy of the slot.
  // A pointer to it will be passed through the callback's data parameter
  // and deleted in the callback.
  auto slot_copy = new SlotAsyncReady(slot);

  g_socket_listener_accept_async(gobj(),
                                 Glib::unwrap(cancellable),
                                 &SignalProxy_async_callback,
                                 slot_copy);
}

Glib::RefPtr<SocketConnection> SocketListener::accept_finish(const Glib::RefPtr<AsyncResult>& result, Glib::RefPtr<Glib::Object>& source_object)
{
  GError* gerror = nullptr;
  GObject *retobj = nullptr;
  auto retvalue = g_socket_listener_accept_finish(gobj(),
                                                                Glib::unwrap(result),
                                                                &retobj,
                                                                &gerror);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  if(retobj)
    source_object = Glib::wrap(retobj);

  return Glib::wrap(retvalue);
}

Glib::RefPtr<SocketConnection> SocketListener::accept_finish(const Glib::RefPtr<AsyncResult>& result)
{
  GError* gerror = nullptr;
  auto retvalue = g_socket_listener_accept_finish(gobj(),
                                                                Glib::unwrap(result),
                                                                0,
                                                                &gerror);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return Glib::wrap(retvalue);
}

} // namespace Gio

namespace
{
} // anonymous namespace


namespace Glib
{

Glib::RefPtr<Gio::SocketListener> wrap(GSocketListener* object, bool take_copy)
{
  return Glib::RefPtr<Gio::SocketListener>( dynamic_cast<Gio::SocketListener*> (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& SocketListener_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_ = &SocketListener_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_socket_listener_get_type());

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

  }

  return *this;
}


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


}


Glib::ObjectBase* SocketListener_Class::wrap_new(GObject* object)
{
  return new SocketListener((GSocketListener*)object);
}


/* The implementation: */

GSocketListener* SocketListener::gobj_copy()
{
  reference();
  return gobj();
}

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

}

SocketListener::SocketListener(GSocketListener* castitem)
:
  Glib::Object((GObject*)(castitem))
{}


SocketListener::~SocketListener()
{}


SocketListener::CppClassType SocketListener::socketlistener_class_; // initialize static member

GType SocketListener::get_type()
{
  return socketlistener_class_.init().get_type();
}


GType SocketListener::get_base_type()
{
  return g_socket_listener_get_type();
}


SocketListener::SocketListener()
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(0),
  Glib::Object(Glib::ConstructParams(socketlistener_class_.init()))
{
  

}

Glib::RefPtr<SocketListener> SocketListener::create()
{
  return Glib::RefPtr<SocketListener>( new SocketListener() );
}

void SocketListener::set_backlog(int listen_backlog)
{
  g_socket_listener_set_backlog(gobj(), listen_backlog);
}

bool SocketListener::add_socket(const Glib::RefPtr<Socket>& socket, const Glib::RefPtr<Glib::Object>& source_object)
{
  GError* gerror = nullptr;
  bool retvalue = g_socket_listener_add_socket(gobj(), const_cast<GSocket*>(Glib::unwrap(socket)), Glib::unwrap(source_object), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

bool SocketListener::add_inet_port(guint16 port, const Glib::RefPtr<Glib::Object>& source_object)
{
  GError* gerror = nullptr;
  bool retvalue = g_socket_listener_add_inet_port(gobj(), port, Glib::unwrap(source_object), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

guint16 SocketListener::add_any_inet_port(const Glib::RefPtr<Glib::Object>& source_object)
{
  GError* gerror = nullptr;
  guint16 retvalue = g_socket_listener_add_any_inet_port(gobj(), Glib::unwrap(source_object), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

void SocketListener::close()
{
  g_socket_listener_close(gobj());
}


Glib::PropertyProxy< int > SocketListener::property_listen_backlog() 
{
  return Glib::PropertyProxy< int >(this, "listen-backlog");
}

Glib::PropertyProxy_ReadOnly< int > SocketListener::property_listen_backlog() const
{
  return Glib::PropertyProxy_ReadOnly< int >(this, "listen-backlog");
}


} // namespace Gio


