/* Copyright (C) 2013 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/>.
 */

#include <glibmm/object.h>
#include <giomm/dbusinterface.h>

_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/object_p.h)
_PINCLUDE(gio/gio.h) //For the GDBusMethodInvocation type in the *_p.h file.

namespace Gio
{

namespace DBus
{

_WRAP_ENUM(InterfaceSkeletonFlags, GDBusInterfaceSkeletonFlags, gtype_func g_dbus_interface_skeleton_flags_get_type, decl_prefix GIOMM_API)

class GIOMM_API InterfaceInfo;
class GIOMM_API Connection;
class GIOMM_API MethodInvocation;

_GMMPROC_EXTRA_NAMESPACE(DBus)

/** Abstract base class for D-Bus interfaces on the service side.
 * @newin{2,38}
 */
class GIOMM_API InterfaceSkeleton
: public Glib::Object,
  public Interface
{
  _CLASS_GOBJECT(InterfaceSkeleton, GDBusInterfaceSkeleton, G_DBUS_INTERFACE_SKELETON, Glib::Object, GObject, , , GIOMM_API)
  _IMPLEMENTS_INTERFACE(Interface)

public:
  _WRAP_METHOD(void flush(), g_dbus_interface_skeleton_flush)

  _WRAP_METHOD(Glib::RefPtr<InterfaceInfo> get_info(), g_dbus_interface_skeleton_get_info)
  _WRAP_METHOD(Glib::RefPtr<const InterfaceInfo> get_info() const, g_dbus_interface_skeleton_get_info, constversion)

  //TODO: _WRAP_METHOD(GDBusInterfaceVTable* get_vtable(), g_dbus_interface_skeleton_get_vtable)

  _WRAP_METHOD(Glib::VariantBase get_properties() const, g_dbus_interface_skeleton_get_properties)
  _WRAP_METHOD(void export_interface_skeleton(const Glib::RefPtr<Connection>& connection, const Glib::ustring& object_path), g_dbus_interface_skeleton_export, errthrow)
  _WRAP_METHOD(void unexport(), g_dbus_interface_skeleton_unexport)
  _WRAP_METHOD(void unexport_from_connection(const Glib::RefPtr<Connection>& connection), g_dbus_interface_skeleton_unexport_from_connection)

  _WRAP_METHOD(Glib::RefPtr<Connection> get_connection(), g_dbus_interface_skeleton_get_connection)
  _WRAP_METHOD(Glib::RefPtr<const Connection> get_connection() const, g_dbus_interface_skeleton_get_connection, constversion)

#m4 _CONVERSION(`GList*',`std::vector< Glib::RefPtr<Connection> >',`Glib::ListHandler< Glib::RefPtr<Connection> >::list_to_vector($3, Glib::OWNERSHIP_DEEP)')
  _WRAP_METHOD(std::vector< Glib::RefPtr<Connection> > get_connections(), g_dbus_interface_skeleton_get_connections)

#m4 _CONVERSION(`GList*',`std::vector< Glib::RefPtr<const Connection> >',`Glib::ListHandler< Glib::RefPtr<const Connection> >::list_to_vector($3, Glib::OWNERSHIP_DEEP)')
  _WRAP_METHOD(std::vector< Glib::RefPtr<const Connection> > get_connections() const, g_dbus_interface_skeleton_get_connections)

  _WRAP_METHOD(bool has_connection(const Glib::RefPtr<const Connection>& connection) const, g_dbus_interface_skeleton_has_connection)

  _WRAP_METHOD(Glib::ustring get_object_path() const, g_dbus_interface_skeleton_get_object_path)

  _WRAP_METHOD(InterfaceSkeletonFlags get_flags() const, g_dbus_interface_skeleton_get_flags)
  _WRAP_METHOD(void set_flags(InterfaceSkeletonFlags flags), g_dbus_interface_skeleton_set_flags)

  _WRAP_PROPERTY("g-flags", InterfaceSkeletonFlags)

#m4 _CONVERSION(`GDBusMethodInvocation*',`const Glib::RefPtr<MethodInvocation>&',`Glib::wrap($3, true)')
  _WRAP_SIGNAL(bool authorize_method(const Glib::RefPtr<MethodInvocation>& invocation), "g_authorize_method")

  //TODO: The virtual functions.
};

} // namespace DBus

} // namespace Gio
