libmain.c 2.8 KB
Newer Older
1 2 3 4 5 6
/*
 * Copyright (C) 2002 Holger Thon <holger.thon@gnome-db.org>
 * Copyright (C) 2002 - 2004 Rodrigo Moya <rodrigo@gnome-db.org>
 * Copyright (C) 2003 Gonzalo Paniagua Javier <gonzalo@gnome-db.org>
 * Copyright (C) 2005 Bas Driessen <bas.driessen@xobas.com>
 * Copyright (C) 2005 Stanislav Brabec <sbrabec@suse.de>
7
 * Copyright (C) 2005 - 2015 Vivien Malerba <malerba@gnome-db.org>
8
 * Copyright (C) 2011 Murray Cumming <murrayc@murrayc.com>
9 10
 *
 * This library is free software; you can redistribute it and/or
11
 * modify it under the terms of the GNU Lesser General Public
12 13 14 15 16 17
 * 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
18
 * Lesser General Public License for more details.
19
 *
20 21 22 23
 * 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., 51 Franklin St, Fifth Floor,
 * Boston, MA  02110-1301, USA.
24 25
 */

26
#include <glib/gi18n-lib.h>
27
#include <gmodule.h>
28
#include <libgda/gda-server-provider-extra.h>
29
#include <libgda/binreloc/gda-binreloc.h>
30 31
#include "gda-mysql.h"
#include "gda-mysql-provider.h"
32

33
static gchar      *module_path = NULL;
34 35 36
const gchar       *plugin_get_name (void);
const gchar       *plugin_get_description (void);
gchar             *plugin_get_dsn_spec (void);
Holger Thon's avatar
Holger Thon committed
37 38
GdaServerProvider *plugin_create_provider (void);

39 40 41 42
/*
 * Functions executed when calling g_module_open() and g_module_close()
 */
const gchar *
43
g_module_check_init (G_GNUC_UNUSED GModule *module)
44 45 46 47 48 49
{
        /*g_module_make_resident (module);*/
        return NULL;
}

void
50
g_module_unload (G_GNUC_UNUSED GModule *module)
51 52 53 54 55 56 57 58
{
        g_free (module_path);
        module_path = NULL;
}

/*
 * Normal plugin functions 
 */
59 60 61
void
plugin_init (const gchar *real_path)
{
62 63
        if (real_path)
                module_path = g_strdup (real_path);
64 65
}

66 67 68
const gchar *
plugin_get_name (void)
{
69
	return MYSQL_PROVIDER_NAME;
70 71 72 73 74
}

const gchar *
plugin_get_description (void)
{
75
	return _("Provider for MySQL databases");
76 77
}

78 79 80
gchar *
plugin_get_dsn_spec (void)
{
81 82 83 84 85
	gchar *ret, *dir;

	dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
	ret = gda_server_provider_load_file_contents (module_path, dir, "mysql_specs_dsn.xml");
	g_free (dir);
86 87 88 89
	if (ret)
		return ret;
	else
		return gda_server_provider_load_resource_contents ("mysql", "mysql_specs_dsn.raw.xml");
90 91
}

92 93 94
GdaServerProvider *
plugin_create_provider (void)
{
95 96
	GdaServerProvider *prov;

97 98 99
	prov = (GdaServerProvider*) g_object_new (GDA_TYPE_MYSQL_PROVIDER, NULL);
        g_object_set_data ((GObject *) prov, "GDA_PROVIDER_DIR", module_path);
        return prov;
100
}