/* 
 * © 2007-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
 *
 * 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 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., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */
#include "stdafx.h"

#include "sqlide.h"


using namespace bec;
using namespace grt;


#define MODULE_VERSION "1.0.0"


GRT_MODULE_ENTRY_POINT(SqlImpl);


#ifdef _WIN32
# define FRONTEND_LIBNAME(obj, windows_dll, linux_so, osx_dylib)\
  obj->moduleName(windows_dll)
#elif defined(__APPLE__)
# define FRONTEND_LIBNAME(obj, windows_dll, linux_so, osx_dylib)\
  obj->moduleName(osx_dylib)
#else
# define FRONTEND_LIBNAME(obj, windows_dll, linux_so, osx_dylib)\
  obj->moduleName(linux_so)
#endif


grt::ListRef<app_Plugin> SqlImpl::getPluginInfo()
{
  grt::ListRef<app_Plugin> list(get_grt());
  GRT *grt= get_grt();
  {
    app_PluginRef plugin(grt);

    FRONTEND_LIBNAME(
      plugin,
      ".\\sqlide.fe.dll",
      "",
      "");
    plugin->pluginType("gui");
    plugin->moduleFunctionName("DbSqlEditor");
    plugin->name("db.sql.editor");
    plugin->caption("SQL Editor");
    plugin->groups().insert("database/Database");

    grt::StringListRef document_types(grt);
    document_types.insert("workbench.Document");
    //plugin->documentStructNames(document_types);

    app_PluginObjectInputRef pdef(grt);
    pdef->objectStructName("db.Catalog");
    plugin->inputValues().insert(pdef);

    list.insert(plugin);
  }
  return list;
}


std::auto_ptr<Sql_editor> SqlImpl::getSqlEditor(db_mgmt_RdbmsRef rdbms)
{
  return std::auto_ptr<Sql_editor>(new Sql_editor(rdbms));
}
