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


#include <glibmm.h>

#include <giomm/dbusobject.h>
#include <giomm/private/dbusobject_p.h>


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

/* 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, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <gio/gio.h>
#include <giomm/dbusinterface.h>
#include <glibmm/vectorutils.h>

namespace Gio
{

} // namespace Gio

namespace
{


static void Object_signal_interface_added_callback(GDBusObject* self, GDBusInterface* p0,void* data)
{
  using namespace Gio::DBus;
  typedef sigc::slot< void,const Glib::RefPtr<Gio::DBus::Interface>& > SlotType;

  auto obj = dynamic_cast<Object*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
  // Do not try to call a signal on a disassociated wrapper.
  if(obj)
  {
    try
    {
      if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
        (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true)
);
    }
    catch(...)
    {
       Glib::exception_handlers_invoke();
    }
  }
}

static const Glib::SignalProxyInfo Object_signal_interface_added_info =
{
  "interface_added",
  (GCallback) &Object_signal_interface_added_callback,
  (GCallback) &Object_signal_interface_added_callback
};


static void Object_signal_interface_removed_callback(GDBusObject* self, GDBusInterface* p0,void* data)
{
  using namespace Gio::DBus;
  typedef sigc::slot< void,const Glib::RefPtr<Gio::DBus::Interface>& > SlotType;

  auto obj = dynamic_cast<Object*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
  // Do not try to call a signal on a disassociated wrapper.
  if(obj)
  {
    try
    {
      if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
        (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true)
);
    }
    catch(...)
    {
       Glib::exception_handlers_invoke();
    }
  }
}

static const Glib::SignalProxyInfo Object_signal_interface_removed_info =
{
  "interface_removed",
  (GCallback) &Object_signal_interface_removed_callback,
  (GCallback) &Object_signal_interface_removed_callback
};


} // anonymous namespace


namespace Glib
{

Glib::RefPtr<Gio::DBus::Object> wrap(GDBusObject* object, bool take_copy)
{
  return Glib::RefPtr<Gio::DBus::Object>( dynamic_cast<Gio::DBus::Object*> (Glib::wrap_auto_interface<Gio::DBus::Object> ((GObject*)(object), take_copy)) );
  //We use dynamic_cast<> in case of multiple inheritance.
}

} // namespace Glib


namespace Gio
{

namespace DBus
{


/* The *_Class implementation: */

const Glib::Interface_Class& Object_Class::init()
{
  if(!gtype_) // create the GType if necessary
  {
    // Glib::Interface_Class has to know the interface init function
    // in order to add interfaces to implementing types.
    class_init_func_ = &Object_Class::iface_init_function;

    // We can not derive from another interface, and it is not necessary anyway.
    gtype_ = g_dbus_object_get_type();
  }

  return *this;
}

void Object_Class::iface_init_function(void* g_iface, void*)
{
  const auto klass = static_cast<BaseClassType*>(g_iface);

  //This is just to avoid an "unused variable" warning when there are no vfuncs or signal handlers to connect.
  //This is a temporary fix until I find out why I can not seem to derive a GtkFileChooser interface. murrayc
  g_assert(klass != nullptr); 

  klass->get_object_path = &get_object_path_vfunc_callback;
  klass->get_interfaces = &get_interfaces_vfunc_callback;
  klass->get_interface = &get_interface_vfunc_callback;

  klass->interface_added = &interface_added_callback;
  klass->interface_removed = &interface_removed_callback;
}

const gchar* Object_Class::get_object_path_vfunc_callback(GDBusObject* self)
{
  const auto obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
        // Call the virtual member method, which derived classes might override.
        static auto quark_return_value = g_quark_from_static_string("Gio::DBus::Object::get_object_path_vfunc");

        auto return_value = static_cast<Glib::ustring*>(g_object_get_qdata(obj_base->gobj(), quark_return_value));
        if (!return_value)
        {
          return_value = new Glib::ustring();
          g_object_set_qdata_full(obj_base->gobj(), quark_return_value, return_value,
          &Glib::destroy_notify_delete<Glib::ustring>);
        }
        // Keep a copy of the return value. The caller is not expected
        // to free the object that the returned pointer points to.
        *return_value = obj->get_object_path_vfunc();
        return (*return_value).c_str();
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
)  );

  // Call the original underlying C function:
  if(base && base->get_object_path)
  {
    const gchar* retval = (*base->get_object_path)(self);
    return retval;
  }

  typedef const gchar* RType;
  return RType();
}
GList* Object_Class::get_interfaces_vfunc_callback(GDBusObject* self)
{
  const auto obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
        // Call the virtual member method, which derived classes might override.
        return g_list_copy(Glib::ListHandler< Glib::RefPtr<Gio::DBus::Interface> >::vector_to_list(obj->get_interfaces_vfunc()).data());
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
)  );

  // Call the original underlying C function:
  if(base && base->get_interfaces)
  {
    GList* retval = (*base->get_interfaces)(self);
    return retval;
  }

  typedef GList* RType;
  return RType();
}
GDBusInterface* Object_Class::get_interface_vfunc_callback(GDBusObject* self, const gchar* interface_name)
{
  const auto obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
        // Call the virtual member method, which derived classes might override.
        return Glib::unwrap(obj->get_interface_vfunc(Glib::convert_const_gchar_ptr_to_ustring(interface_name)
));
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
)  );

  // Call the original underlying C function:
  if(base && base->get_interface)
  {
    GDBusInterface* retval = (*base->get_interface)(self, interface_name);
    return retval;
  }

  typedef GDBusInterface* RType;
  return RType();
}

void Object_Class::interface_added_callback(GDBusObject* self, GDBusInterface* p0)
{
  const auto obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
        // Call the virtual member method, which derived classes might override.
        obj->on_interface_added(Glib::wrap(p0, true)
);
        return;
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  const auto base = static_cast<BaseClassType*>(
        g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
)    );

  // Call the original underlying C function:
  if(base && base->interface_added)
    (*base->interface_added)(self, p0);
}
void Object_Class::interface_removed_callback(GDBusObject* self, GDBusInterface* p0)
{
  const auto obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
        // Call the virtual member method, which derived classes might override.
        obj->on_interface_removed(Glib::wrap(p0, true)
);
        return;
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  const auto base = static_cast<BaseClassType*>(
        g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
)    );

  // Call the original underlying C function:
  if(base && base->interface_removed)
    (*base->interface_removed)(self, p0);
}


Glib::ObjectBase* Object_Class::wrap_new(GObject* object)
{
  return new Object((GDBusObject*)(object));
}


/* The implementation: */

Object::Object()
:
  Glib::Interface(object_class_.init())
{}

Object::Object(GDBusObject* castitem)
:
  Glib::Interface((GObject*)(castitem))
{}

Object::Object(const Glib::Interface_Class& interface_class)
: Glib::Interface(interface_class)
{
}

Object::Object(Object&& src) noexcept
: Glib::Interface(std::move(src))
{}

Object& Object::operator=(Object&& src) noexcept
{
  Glib::Interface::operator=(std::move(src));
  return *this;
}

Object::~Object() noexcept
{}

// static
void Object::add_interface(GType gtype_implementer)
{
  object_class_.init().add_interface(gtype_implementer);
}

Object::CppClassType Object::object_class_; // initialize static member

GType Object::get_type()
{
  return object_class_.init().get_type();
}


GType Object::get_base_type()
{
  return g_dbus_object_get_type();
}


Glib::ustring Object::get_object_path() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(g_dbus_object_get_object_path(const_cast<GDBusObject*>(gobj())));
}

std::vector< Glib::RefPtr<Gio::DBus::Interface> > Object::get_interfaces()
{
  return Glib::ListHandler< Glib::RefPtr<Gio::DBus::Interface> >::list_to_vector(g_dbus_object_get_interfaces(gobj()), Glib::OWNERSHIP_DEEP);
}

std::vector< Glib::RefPtr<const Gio::DBus::Interface> > Object::get_interfaces() const
{
  return Glib::ListHandler< Glib::RefPtr<const Gio::DBus::Interface> >::list_to_vector(g_dbus_object_get_interfaces(const_cast<GDBusObject*>(gobj())), Glib::OWNERSHIP_DEEP);
}

Glib::RefPtr<Gio::DBus::Interface> Object::get_interface(const Glib::ustring& interface_name)
{
  return Glib::wrap(g_dbus_object_get_interface(gobj(), interface_name.c_str()));
}

Glib::RefPtr<const Gio::DBus::Interface> Object::get_interface(const Glib::ustring& interface_name) const
{
  return const_cast<Object*>(this)->get_interface(interface_name);
}


Glib::SignalProxy1< void,const Glib::RefPtr<Gio::DBus::Interface>& > Object::signal_interface_added()
{
  return Glib::SignalProxy1< void,const Glib::RefPtr<Gio::DBus::Interface>& >(this, &Object_signal_interface_added_info);
}


Glib::SignalProxy1< void,const Glib::RefPtr<Gio::DBus::Interface>& > Object::signal_interface_removed()
{
  return Glib::SignalProxy1< void,const Glib::RefPtr<Gio::DBus::Interface>& >(this, &Object_signal_interface_removed_info);
}


void Gio::DBus::Object::on_interface_added(const Glib::RefPtr<Gio::DBus::Interface>& iface)
{
  const auto base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
)  );

  if(base && base->interface_added)
    (*base->interface_added)(gobj(),Glib::unwrap(iface));
}
void Gio::DBus::Object::on_interface_removed(const Glib::RefPtr<Gio::DBus::Interface>& iface)
{
  const auto base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
)  );

  if(base && base->interface_removed)
    (*base->interface_removed)(gobj(),Glib::unwrap(iface));
}

Glib::ustring Gio::DBus::Object::get_object_path_vfunc() const
{
  const auto base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
)  );

  if(base && base->get_object_path)
  {
    Glib::ustring retval(Glib::convert_const_gchar_ptr_to_ustring((*base->get_object_path)(const_cast<GDBusObject*>(gobj()))));
    return retval;
  }

  typedef Glib::ustring RType;
  return RType();
}
std::vector< Glib::RefPtr<Gio::DBus::Interface> > Gio::DBus::Object::get_interfaces_vfunc() const
{
  const auto base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
)  );

  if(base && base->get_interfaces)
  {
    std::vector< Glib::RefPtr<Gio::DBus::Interface> > retval(Glib::ListHandler< Glib::RefPtr<Gio::DBus::Interface> >::list_to_vector((*base->get_interfaces)(const_cast<GDBusObject*>(gobj())), Glib::OWNERSHIP_DEEP));
    return retval;
  }

  typedef std::vector< Glib::RefPtr<Gio::DBus::Interface> > RType;
  return RType();
}
Glib::RefPtr<Gio::DBus::Interface> Gio::DBus::Object::get_interface_vfunc(const Glib::ustring& interface_name) const
{
  const auto base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
)  );

  if(base && base->get_interface)
  {
    Glib::RefPtr<Gio::DBus::Interface> retval(Glib::wrap((*base->get_interface)(const_cast<GDBusObject*>(gobj()),interface_name.c_str())));
    return retval;
  }

  typedef Glib::RefPtr<Gio::DBus::Interface> RType;
  return RType();
}


} // namespace DBus

} // namespace Gio


