/* Copyright (C) 2010 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 <giomm/socketaddress.h>

_DEFS(giomm,gio)
_PINCLUDE(giomm/private/socketaddress_p.h)

namespace Gio
{

_WRAP_ENUM(UnixSocketAddressType, GUnixSocketAddressType, decl_prefix GIOMM_API)

class GLIBMM_API ByteArray;

/** UnixSocketAddress - UNIX SocketAddress.
 * Support for UNIX-domain (also known as local) sockets.
 *
 * UNIX domain sockets are generally visible in the filesystem. However, some
 * systems support abstract socket names which are not visible in the
 * filesystem and not affected by the filesystem permissions, visibility, etc.
 * Currently this is only supported under Linux. If you attempt to use
 * abstract sockets on other systems, function calls may return
 * Gio::IO_ERROR_NOT_SUPPORTED errors. You can use
 * Gio::UnixSocketAddress::abstract_names_supported() to see if abstract names
 * are supported.
 *
 * Note that @c <giomm/unixsocketaddress.h> belongs to the UNIX-specific GIO
 * interfaces.
 * @newin{2,28}
 * @ingroup NetworkIO
 */
class GIOMM_API UnixSocketAddress
: public SocketAddress
{
  _CLASS_GOBJECT(UnixSocketAddress, GUnixSocketAddress, G_UNIX_SOCKET_ADDRESS, SocketAddress, GSocketAddress, , , GIOMM_API)
  _GTKMMPROC_WIN32_NO_WRAP

protected:
 _WRAP_CTOR(UnixSocketAddress(const std::string& path), g_unix_socket_address_new)

 //TODO: Possibly add when g_unix_socket_address_new_with_type() does not do
 //more than call g_object_new() (maybe file a bug).
 //_WRAP_CTOR(UnixSocketAddress(const std::string& path, int path_len = -1, UnixSocketAddressType type = Gio::UNIX_SOCKET_ADDRESS_PATH), g_unix_socket_address_new_with_type)

public:
 _WRAP_METHOD_DOCS_ONLY(g_unix_socket_address_new)
 _WRAP_CREATE(const std::string& path)

 //TODO: Add when the above constructor is included, removing the handwritten
 //create() method for it below.
 //_WRAP_METHOD_DOCS_ONLY(g_unix_socket_address_new_with_type)
 //_WRAP_CREATE(const std::string& path, int path_len = -1, UnixSocketAddressType type = Gio::UNIX_SOCKET_ADDRESS_PATH)

 _WRAP_METHOD_DOCS_ONLY(g_unix_socket_address_new_with_type)
 static Glib::RefPtr<UnixSocketAddress> create(const std::string& path,
   UnixSocketAddressType type, int path_len = -1);

 // Deprecated.
 _IGNORE(g_unix_socket_address_get_is_abstract)

 _WRAP_METHOD(UnixSocketAddressType get_address_type() const, g_unix_socket_address_get_address_type)
 _WRAP_METHOD(std::string get_path() const, g_unix_socket_address_get_path)
 _IGNORE(g_unix_socket_address_get_path_len)

 _WRAP_METHOD(static bool abstract_names_supported(), g_unix_socket_address_abstract_names_supported)

  _WRAP_PROPERTY("abstract", bool, deprecated "Use property_address_type() instead, which distinguishes between zero-padded and non-zero-padded abstract addresses.")
  _WRAP_PROPERTY("address-type", UnixSocketAddressType)
  _WRAP_PROPERTY("path", std::string)
  _WRAP_PROPERTY("path-as-array", Glib::RefPtr<ByteArray>)
};

} // namespace Gio
