/* 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, see .
*/
#include
#include
namespace Gio
{
bool
SocketListener::add_socket(const Glib::RefPtr& socket)
{
GError* gerror = nullptr;
const bool retval = g_socket_listener_add_socket(gobj(), Glib::unwrap(socket), nullptr, &gerror);
if (gerror)
::Glib::Error::throw_exception(gerror);
return retval;
}
bool
SocketListener::add_address(const Glib::RefPtr& address, Socket::Type type,
Socket::Protocol protocol, const Glib::RefPtr& source_object,
Glib::RefPtr& effective_address)
{
GError* gerror = nullptr;
GSocketAddress* retaddr = nullptr;
const bool retval =
g_socket_listener_add_address(gobj(), Glib::unwrap(address), static_cast(type),
static_cast(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& address, Socket::Type type,
Socket::Protocol protocol, Glib::RefPtr& effective_address)
{
GError* gerror = nullptr;
GSocketAddress* retaddr = nullptr;
const bool retval =
g_socket_listener_add_address(gobj(), Glib::unwrap(address), static_cast(type),
static_cast(protocol), nullptr, &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, nullptr, &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(), nullptr, &gerror);
if (gerror)
::Glib::Error::throw_exception(gerror);
return retvalue;
}
Glib::RefPtr
SocketListener::accept_socket(
Glib::RefPtr& source_object, const Glib::RefPtr& 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
SocketListener::accept_socket(Glib::RefPtr& source_object)
{
GError* gerror = nullptr;
GObject* retobj = nullptr;
auto retvalue = g_socket_listener_accept_socket(gobj(), &retobj, nullptr, &gerror);
if (gerror)
::Glib::Error::throw_exception(gerror);
if (retobj)
source_object = Glib::wrap(retobj);
return Glib::wrap(retvalue);
}
Glib::RefPtr
SocketListener::accept_socket(const Glib::RefPtr& cancellable)
{
GError* gerror = nullptr;
auto retvalue =
g_socket_listener_accept_socket(gobj(), nullptr, Glib::unwrap(cancellable), &gerror);
if (gerror)
::Glib::Error::throw_exception(gerror);
return Glib::wrap(retvalue);
}
Glib::RefPtr
SocketListener::accept_socket()
{
GError* gerror = nullptr;
auto retvalue = g_socket_listener_accept_socket(gobj(), nullptr, nullptr, &gerror);
if (gerror)
::Glib::Error::throw_exception(gerror);
return Glib::wrap(retvalue);
}
void
SocketListener::accept_socket_async(
const Glib::RefPtr& 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(), nullptr, &SignalProxy_async_callback, slot_copy);
}
Glib::RefPtr
SocketListener::accept_socket_finish(
const Glib::RefPtr& result, Glib::RefPtr& 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
SocketListener::accept_socket_finish(const Glib::RefPtr& result)
{
GError* gerror = nullptr;
auto retvalue =
g_socket_listener_accept_socket_finish(gobj(), Glib::unwrap(result), nullptr, &gerror);
if (gerror)
::Glib::Error::throw_exception(gerror);
return Glib::wrap(retvalue);
}
Glib::RefPtr
SocketListener::accept(
Glib::RefPtr