[libgda] Added the GdaProviderInfo::icon_id field
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Added the GdaProviderInfo::icon_id field
- Date: Sun, 4 Jan 2015 16:10:23 +0000 (UTC)
commit 0e778091399fb82abd28e22a1f225b8885ad3a5e
Author: Vivien Malerba <malerba gnome-db org>
Date: Sun Jan 4 17:00:11 2015 +0100
Added the GdaProviderInfo::icon_id field
libgda/gda-config.c | 18 +++++++++++++++---
libgda/gda-config.h | 3 ++-
providers/bdb/libmain.c | 7 +++++++
providers/bdbsql/libmain.c | 16 +++++++++++++---
providers/firebird/libmain-embed.c | 8 ++++++++
providers/jdbc/jni-wrapper.c | 2 +-
providers/jdbc/libmain.c | 30 ++++++++++++++++++++++++++----
providers/mdb/libmain.c | 7 +++++++
8 files changed, 79 insertions(+), 12 deletions(-)
---
diff --git a/libgda/gda-config.c b/libgda/gda-config.c
index 34b9a04..049fefc 100644
--- a/libgda/gda-config.c
+++ b/libgda/gda-config.c
@@ -1770,7 +1770,7 @@ load_all_providers (void)
static InternalProvider *
create_internal_provider (const gchar *path,
const gchar *prov_name, const gchar *prov_descr,
- gchar *dsn_spec, gchar *auth_spec)
+ gchar *dsn_spec, gchar *auth_spec, const gchar *icon_id)
{
g_return_val_if_fail (prov_name, NULL);
@@ -1846,6 +1846,9 @@ create_internal_provider (const gchar *path,
gda_holder_set_attribute_static (h, GDAUI_ATTRIBUTE_PLUGIN, value);
gda_value_free (value);
}
+
+ info->icon_id = icon_id ? g_strdup (icon_id) : g_strdup (prov_name);
+
return ip;
}
@@ -1879,12 +1882,14 @@ load_providers_from_dir (const gchar *dirname, gboolean recurs)
const gchar * (* plugin_get_description) (void);
gchar * (* plugin_get_dsn_spec) (void);
gchar * (* plugin_get_auth_spec) (void);
+ const gchar * (*plugin_get_icon_id) (void);
/* methods for shared libraries which provide several types of providers (ODBC, JDBC, ...) */
const gchar ** (* plugin_get_sub_names) (void);
const gchar * (* plugin_get_sub_description) (const gchar *name);
gchar * (* plugin_get_sub_dsn_spec) (const gchar *name);
gchar * (* plugin_get_sub_auth_spec) (const gchar *name);
+ const gchar * (*plugin_get_sub_icon_id) (const gchar *name);
if (recurs) {
gchar *cname;
@@ -1928,6 +1933,8 @@ load_providers_from_dir (const gchar *dirname, gboolean recurs)
(gpointer *) &plugin_get_dsn_spec);
g_module_symbol (handle, "plugin_get_auth_spec",
(gpointer *) &plugin_get_auth_spec);
+ g_module_symbol (handle, "plugin_get_icon_id",
+ (gpointer *) &plugin_get_icon_id);
g_module_symbol (handle, "plugin_get_sub_names",
(gpointer *) &plugin_get_sub_names);
g_module_symbol (handle, "plugin_get_sub_description",
@@ -1936,6 +1943,8 @@ load_providers_from_dir (const gchar *dirname, gboolean recurs)
(gpointer *) &plugin_get_sub_dsn_spec);
g_module_symbol (handle, "plugin_get_sub_auth_spec",
(gpointer *) &plugin_get_sub_auth_spec);
+ g_module_symbol (handle, "plugin_get_sub_icon_id",
+ (gpointer *) &plugin_get_sub_icon_id);
if (plugin_get_sub_names) {
const gchar **subnames = plugin_get_sub_names ();
@@ -1949,7 +1958,9 @@ load_providers_from_dir (const gchar *dirname, gboolean recurs)
plugin_get_sub_dsn_spec ?
plugin_get_sub_dsn_spec (*ptr) : NULL,
plugin_get_sub_auth_spec ?
- plugin_get_sub_auth_spec (*ptr) : NULL);
+ plugin_get_sub_auth_spec (*ptr) : NULL,
+ plugin_get_sub_icon_id ?
+ plugin_get_sub_icon_id (*ptr) : NULL);
if (ip) {
unique_instance->priv->prov_list =
g_slist_prepend (unique_instance->priv->prov_list, ip);
@@ -1965,7 +1976,8 @@ load_providers_from_dir (const gchar *dirname, gboolean recurs)
plugin_get_name ? plugin_get_name () : name,
plugin_get_description ? plugin_get_description () :
NULL,
plugin_get_dsn_spec ? plugin_get_dsn_spec () : NULL,
- plugin_get_auth_spec ? plugin_get_auth_spec () : NULL);
+ plugin_get_auth_spec ? plugin_get_auth_spec () : NULL,
+ plugin_get_icon_id ? plugin_get_icon_id () : NULL);
if (ip) {
unique_instance->priv->prov_list =
g_slist_prepend (unique_instance->priv->prov_list, ip);
diff --git a/libgda/gda-config.h b/libgda/gda-config.h
index e8203bb..11879ff 100644
--- a/libgda/gda-config.h
+++ b/libgda/gda-config.h
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2000 Reinhard Müller <reinhard src gnome org>
* Copyright (C) 2000 - 2005 Rodrigo Moya <rodrigo gnome-db org>
- * Copyright (C) 2001 - 2011 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2001 - 2014 Vivien Malerba <malerba gnome-db org>
* Copyright (C) 2002 Gonzalo Paniagua Javier <gonzalo gnome-db org>
* Copyright (C) 2003 Laurent Sansonetti <laurent datarescue be>
* Copyright (C) 2003 - 2007 Murray Cumming <murrayc murrayc com>
@@ -103,6 +103,7 @@ struct _GdaProviderInfo {
gchar *description;
GdaSet *dsn_params; /* Specs to create a DSN */
GdaSet *auth_params; /* Specs to authenticate a client */
+ gchar *icon_id; /* use gdaui_get_icon_for_db_engine(icon_id) to get the actual GdkPixbuf
*/
/*< private >*/
/* Padding for future expansion */
diff --git a/providers/bdb/libmain.c b/providers/bdb/libmain.c
index a6e89d3..b0f3d0a 100644
--- a/providers/bdb/libmain.c
+++ b/providers/bdb/libmain.c
@@ -34,6 +34,7 @@ static gchar *module_path = NULL;
const gchar *plugin_get_name (void);
const gchar *plugin_get_description (void);
gchar *plugin_get_dsn_spec (void);
+const gchar *plugin_get_icon_id (void);
GdaServerProvider *plugin_create_provider (void);
/*
@@ -97,6 +98,12 @@ plugin_get_auth_spec (void)
return g_strdup (AUTH);
}
+const gchar *
+plugin_get_icon_id (void)
+{
+ return "bdb";
+}
+
GdaServerProvider *
plugin_create_provider (void)
{
diff --git a/providers/bdbsql/libmain.c b/providers/bdbsql/libmain.c
index 6907ed0..2ddd8ee 100644
--- a/providers/bdbsql/libmain.c
+++ b/providers/bdbsql/libmain.c
@@ -34,6 +34,7 @@ static gchar *module_path = NULL;
const gchar *plugin_get_name (void);
const gchar *plugin_get_description (void);
gchar *plugin_get_dsn_spec (void);
+const gchar *plugin_get_icon_id (void);
GdaServerProvider *plugin_create_provider (void);
GModule *bdbsql_module = NULL;
@@ -43,12 +44,15 @@ GModule *bdbsql_module = NULL;
const gchar *
g_module_check_init (GModule *module)
{
- if (! bdbsql_module)
+ if (! bdbsql_module) {
bdbsql_module = find_sqlite_library ("libdb_sql-5");
+ if (! bdbsql_module)
+ bdbsql_module = find_sqlite_library ("libdb_sql-6");
+ }
if (bdbsql_module)
load_symbols (bdbsql_module);
if (! s3r)
- return _("Can't find libdb_sql-5." G_MODULE_SUFFIX " file.");
+ return _("Can't find libdb_sql-5." G_MODULE_SUFFIX " or libdb_sql-6." G_MODULE_SUFFIX "file,
or any dependent library");
/*g_module_make_resident (module);*/
return NULL;
@@ -86,7 +90,7 @@ plugin_get_name (void)
const gchar *
plugin_get_description (void)
{
- return _("Provider for BDB SQL databases");
+ return _("Provider for Berkeley DB SQL databases");
}
gchar *
@@ -111,6 +115,12 @@ plugin_get_auth_spec (void)
return g_strdup (AUTH);
}
+const gchar *
+plugin_get_icon_id (void)
+{
+ return "bdb";
+}
+
GdaServerProvider *
plugin_create_provider (void)
{
diff --git a/providers/firebird/libmain-embed.c b/providers/firebird/libmain-embed.c
index 3d3f423..cfacac7 100644
--- a/providers/firebird/libmain-embed.c
+++ b/providers/firebird/libmain-embed.c
@@ -31,6 +31,7 @@ static gchar *module_path = NULL;
const gchar *plugin_get_name (void);
const gchar *plugin_get_description (void);
gchar *plugin_get_dsn_spec (void);
+const gchar *plugin_get_icon_id (void);
GdaServerProvider *plugin_create_provider (void);
/*
@@ -80,6 +81,13 @@ plugin_get_dsn_spec (void)
return ret;
}
+const gchar *
+plugin_get_icon_id (void)
+{
+ return FIREBIRD_PROVIDER_NAME;
+}
+
+
gchar *
plugin_get_auth_spec (void)
{
diff --git a/providers/jdbc/jni-wrapper.c b/providers/jdbc/jni-wrapper.c
index 26da6c8..059f6fa 100644
--- a/providers/jdbc/jni-wrapper.c
+++ b/providers/jdbc/jni-wrapper.c
@@ -377,7 +377,7 @@ jni_wrapper_handle_exception (JNIEnv *jenv, gint *out_error_code, gchar **out_sq
GValue *res;
res = jni_wrapper_method_call (jenv, get_message_method, exc_value, NULL, NULL, NULL);
-
+
if (res) {
if (G_VALUE_TYPE (res) == G_TYPE_STRING) {
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
diff --git a/providers/jdbc/libmain.c b/providers/jdbc/libmain.c
index 64fdeaf..ef4efd8 100644
--- a/providers/jdbc/libmain.c
+++ b/providers/jdbc/libmain.c
@@ -53,6 +53,7 @@ static gchar *module_path = NULL;
EXPORT const gchar **plugin_get_sub_names (void);
EXPORT const gchar *plugin_get_sub_description (const gchar *name);
EXPORT gchar *plugin_get_sub_dsn_spec (const gchar *name);
+EXPORT const gchar *plugin_get_sub_icon_id (const gchar *name);
EXPORT GdaServerProvider *plugin_create_sub_provider (const gchar *name);
/* locate and load JAVA virtual machine */
@@ -309,6 +310,17 @@ plugin_get_sub_dsn_spec (const gchar *name)
return ret;
}
+EXPORT const gchar *
+plugin_get_sub_icon_id (const gchar *name)
+{
+ JdbcDriver *dr;
+ dr = g_hash_table_lookup (jdbc_drivers_hash, name);
+ if (dr)
+ return dr->native_db;
+ else
+ return NULL;
+}
+
EXPORT GdaServerProvider *
plugin_create_sub_provider (const gchar *name)
{
@@ -473,13 +485,23 @@ load_jvm ()
gchar *path;
GError *error = NULL;
path = g_build_filename (module_path, "gdaprovider-6.0.jar", NULL);
- jni_wrapper_create_vm (&_jdbc_provider_java_vm, __CreateJavaVM, module_path, path, &error);
- if (!_jdbc_provider_java_vm) {
+ if (! g_file_test (path, G_FILE_TEST_IS_REGULAR)) {
if (g_getenv ("GDA_SHOW_PROVIDER_LOADING_ERROR"))
- g_warning (_("Can't create JAVA virtual machine: %s"),
- error && error->message ? error->message : _("No detail"));
+ g_warning (_("Could not find Libgda's JAR (gdaprovider-6.0.jar), "
+ "JDBC provider is unavailable."));
jvm_found = FALSE;
}
+ else {
+ jni_wrapper_create_vm (&_jdbc_provider_java_vm, __CreateJavaVM, module_path, path,
&error);
+ g_free (path);
+ if (!_jdbc_provider_java_vm) {
+ if (g_getenv ("GDA_SHOW_PROVIDER_LOADING_ERROR"))
+ g_warning (_("Can't create JAVA virtual machine: %s"),
+ error && error->message ? error->message : _("No detail"));
+ g_clear_error (&error);
+ jvm_found = FALSE;
+ }
+ }
}
else {
__CreateJavaVM = NULL;
diff --git a/providers/mdb/libmain.c b/providers/mdb/libmain.c
index cd2c0ac..3b5a19a 100644
--- a/providers/mdb/libmain.c
+++ b/providers/mdb/libmain.c
@@ -32,6 +32,7 @@ const gchar *plugin_get_name (void);
const gchar *plugin_get_description (void);
gchar *plugin_get_dsn_spec (void);
GdaServerProvider *plugin_create_provider (void);
+const gchar *plugin_get_icon_id (void);
/*
* Functions executed when calling g_module_open() and g_module_close()
@@ -94,6 +95,12 @@ plugin_get_auth_spec (void)
return g_strdup (AUTH);
}
+const gchar *
+plugin_get_icon_id (void)
+{
+ return "mdb";
+}
+
GdaServerProvider *
plugin_create_provider (void)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]