[libgda] sqlcipher: implementing as GdaSqliteProvider derived



commit 22902746dd878a9396862c581394dd59dfc24e25
Author: Daniel Espinosa Ortiz <esodan gmail com>
Date:   Wed Mar 6 17:33:21 2019 -0600

    sqlcipher: implementing as GdaSqliteProvider derived

 po/POTFILES.in                               |  1 +
 providers/sqlcipher/Makefile.am              |  2 +-
 providers/sqlcipher/gda-sqlcipher-provider.c | 53 ++++++++++++++++++++++++++++
 providers/sqlcipher/gda-sqlcipher-provider.h | 38 ++++++++++++++++++++
 providers/sqlcipher/libmain.c                |  4 +--
 providers/sqlcipher/meson.build              | 12 +++++--
 6 files changed, 104 insertions(+), 6 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index e840c7b1c..243ceaf1e 100755
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -235,6 +235,7 @@ providers/reuseable/mysql/gda-mysql-meta.c
 providers/reuseable/mysql/gda-mysql-reuseable.c
 providers/reuseable/postgres/gda-postgres-meta.c
 providers/reuseable/postgres/gda-postgres-reuseable.c
+providers/sqlcipher/gda-sqlcipher-provider.c
 providers/sqlcipher/libmain.c
 providers/sqlcipher/sqlcipher_specs_add_column.xml.in
 providers/sqlcipher/sqlcipher_specs_auth.xml.in
diff --git a/providers/sqlcipher/Makefile.am b/providers/sqlcipher/Makefile.am
index a5fbb4d80..6daf73f4b 100644
--- a/providers/sqlcipher/Makefile.am
+++ b/providers/sqlcipher/Makefile.am
@@ -21,7 +21,7 @@ sqlite_sources = sqlite3.c sqlite3.h
 libmain.lo: sqlite3.h
 
 libgda_sqlcipher_la_SOURCES = \
-       $(sqlite_sources) \
+       gda-sqlcipher-provider.c \
        sqlcipher.gresources.c \
        libmain.c
 
diff --git a/providers/sqlcipher/gda-sqlcipher-provider.c b/providers/sqlcipher/gda-sqlcipher-provider.c
new file mode 100644
index 000000000..246b8ca42
--- /dev/null
+++ b/providers/sqlcipher/gda-sqlcipher-provider.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2019 Daniel Espinosa <esodan gmail com>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+
+#include <glib/gi18n-lib.h>
+#include <providers/sqlcipher/gda-sqlcipher-provider.h>
+#include "libgda/sqlite/gda-symbols-util.h"
+
+// API routines from library
+Sqlite3ApiRoutines *libapi;
+
+/**
+ * call it if you are implementing a new derived provider using
+ * a different SQLite library, like SQLCipher
+ */
+static gpointer
+gda_sqlcipher_provider_get_api_internal (GdaSqliteProvider *prov) {
+  return libapi;
+}
+
+G_DEFINE_TYPE (GdaSqlcipherProvider, gda_sqlcipher_provider, GDA_TYPE_SQLITE_PROVIDER)
+
+static void
+gda_sqlcipher_provider_class_init (GdaSqlcipherProviderClass *klass)
+{
+  GModule *module2;
+
+  module2 = find_sqlite_library ("sqlcipher");
+  if (module2)
+    load_symbols (module2, &libapi);
+  if (s3r == NULL) {
+    g_warning (_("Can't find libsqlite3." G_MODULE_SUFFIX " file."));
+  }
+  GDA_SQLITE_PROVIDER_CLASS (gda_sqlcipher_provider_parent_class)->get_api = 
gda_sqlcipher_provider_get_api_internal;
+}
+
+static void
+gda_sqlcipher_provider_init (GdaSqlcipherProvider *object) {}
diff --git a/providers/sqlcipher/gda-sqlcipher-provider.h b/providers/sqlcipher/gda-sqlcipher-provider.h
new file mode 100644
index 000000000..6bd36f9a2
--- /dev/null
+++ b/providers/sqlcipher/gda-sqlcipher-provider.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2019 Daniel Espinosa <esodan gmail com>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+
+#ifndef __GDA_SQLCIPHER_PROVIDER_H__
+#define __GDA_SQLCIPHER_PROVIDER_H__
+
+#include <libgda/sqlite/gda-sqlite-provider.h>
+
+
+G_BEGIN_DECLS
+
+#define GDA_TYPE_SQLCIPHER_PROVIDER            (gda_sqlcipher_provider_get_type())
+
+G_DECLARE_DERIVABLE_TYPE (GdaSqlcipherProvider, gda_sqlcipher_provider, GDA, SQLCIPHER_PROVIDER, 
GdaSqliteProvider)
+
+struct _GdaSqlcipherProviderClass {
+       GdaSqliteProviderClass parent_class;
+};
+
+G_END_DECLS
+
+#endif
diff --git a/providers/sqlcipher/libmain.c b/providers/sqlcipher/libmain.c
index 85ca14848..e1423f208 100644
--- a/providers/sqlcipher/libmain.c
+++ b/providers/sqlcipher/libmain.c
@@ -26,7 +26,7 @@
 #include <glib/gi18n-lib.h>
 #include <gmodule.h>
 #include <libgda/gda-config.h>
-#include "gda-sqlite-provider.h"
+#include "gda-sqlcipher-provider.h"
 #include <libgda/gda-server-provider-extra.h>
 #include <libgda/binreloc/gda-binreloc.h>
 #include <libgda/sqlite/gda-symbols-util.h>
@@ -109,7 +109,7 @@ plugin_create_provider (void)
 {
        GdaServerProvider *prov;
 
-       prov = (GdaServerProvider*) g_object_new (GDA_TYPE_SQLITE_PROVIDER, NULL);
+       prov = (GdaServerProvider*) g_object_new (GDA_TYPE_SQLCIPHER_PROVIDER, NULL);
         g_object_set_data ((GObject *) prov, "GDA_PROVIDER_DIR", module_path);
         return prov;
 }
diff --git a/providers/sqlcipher/meson.build b/providers/sqlcipher/meson.build
index 9406389cd..7c8991869 100644
--- a/providers/sqlcipher/meson.build
+++ b/providers/sqlcipher/meson.build
@@ -69,10 +69,15 @@ sqlcipher_resources += sqlcipher_resourcesc
 sqlcipher_resources += sqlcipher_resourcesh
 
 libgda_sqlcipher_sources = files([
-       'libmain.c'
+       'libmain.c',
+       'gda-sqlcipher-provider.c'
        ])
 libgda_sqlcipher_sources += sqlcipher_resources
-libgda_sqlcipher_sources += sqlcipher_sources
+
+sqlcipherheaders = files(['gda-sqlcipher-provider.h'])
+libgda_sqlcipher_sources += sqlcipherheaders
+
+install_headers (sqlcipherheaders, subdir: join_paths(project_package, 'providers', 'sqlcipher'))
 
 if sqlcipher_internal
 libgda_sqlcipher_sources += files([
@@ -104,7 +109,8 @@ libgda_sqlcipher_provider = library ('gda-sqlcipher-'+project_api_version,
                libcrypto_dep,
                inc_libgda_sqlcipherh_dep,
                inc_sqliteh_dep,
-               inc_libgdah_dep
+               inc_libgdah_dep,
+               inc_rooth_dep
                ],
        c_args: sqlcipher_cargs,
        link_with: libgda,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]