/* gstreamermm - a C++ wrapper for gstreamer
 *
 * Copyright 2008 The gstreamermm 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 <gst/gst.h>
#include <gstreamermm/structure.h>
_PINCLUDE(gstreamermm/private/object_p.h)

namespace
{

extern "C"
{

gboolean Plugin_Init_gstreamermm_callback(GstPlugin* plugin, void* data)
{
  Gst::Plugin::SlotInit* the_slot = static_cast<Gst::Plugin::SlotInit*>(data);
  bool result = false;

  try
  {
    result = (*the_slot)(Glib::wrap(plugin, true));
    delete the_slot;
    return result;
  }
  catch(...)
  {
    Glib::exception_handlers_invoke();
  }

  return false;
}

} // extern "C"

} // anonymous namespace

namespace Gst
{

bool Plugin::register_static(int major_version, int minor_version,
    const Glib::ustring& name, const Glib::ustring& description,
    const SlotInit& init_slot, const Glib::ustring& version,
    const Glib::ustring& license, const Glib::ustring& source,
    const Glib::ustring& package, const Glib::ustring& origin)
{
  SlotInit* slot_copy = new SlotInit(init_slot);

  return gst_plugin_register_static_full(major_version, minor_version,
    name.c_str(), const_cast<char*>(description.c_str()),
    &Plugin_Init_gstreamermm_callback, version.c_str(), license.c_str(),
    source.c_str(), package.c_str(), origin.c_str(), slot_copy);
}

} //namespace Gst
