[libgdamm] GdaDsnInfo: Structure was wrapped as a class



commit 93caec77330fd22aa6e05ae9ca0972e5cdaed142
Author: Pavlo Solntsev <pavlo solntsev gmail com>
Date:   Thu Mar 1 13:57:43 2018 -0600

    GdaDsnInfo: Structure was wrapped as a class
    
    Provides a wrapper for GdaDsnInfo structure. New class was
    introduced and conig.hg file was modified to use the new wrapper.
    
    Bug #793469

 libgda/src/config.hg         |   20 ++++++++-----
 libgda/src/dsninfo.ccg       |   32 ++++++++++++++++++++++
 libgda/src/dsninfo.hg        |   59 ++++++++++++++++++++++++++++++++++++++++++
 libgda/src/filelist.am       |    1 +
 tools/m4/convert_libgdamm.m4 |    2 +
 5 files changed, 106 insertions(+), 8 deletions(-)
---
diff --git a/libgda/src/config.hg b/libgda/src/config.hg
index 72496df..8c75f0d 100644
--- a/libgda/src/config.hg
+++ b/libgda/src/config.hg
@@ -22,7 +22,7 @@
 #include <glibmm/object.h>
 #include <libgdamm/serverprovider.h>
 #include <libgdamm/datamodel.h>
-#include <libgda/gda-config.h>
+#include <libgdamm/dsninfo.h>
 
 _DEFS(libgdamm,libgda)
 _PINCLUDE(glibmm/private/object_p.h)
@@ -46,9 +46,10 @@ class Config : public Glib::Object
 protected:
   _CTOR_DEFAULT;
 public:
-  _WRAP_METHOD(static Glib::RefPtr<Config> get(), gda_config_get, refreturn)
+#m4 _CONVERSION(`GdaDsnInfo*',`DsnInfo',`Glib::wrap($3,true)')
+  _WRAP_METHOD(static Glib::RefPtr<Config> get(), gda_config_get,refreturn)
 
-  _WRAP_METHOD(static GdaDsnInfo* get_dsn_info(const Glib::ustring& dsn_name), gda_config_get_dsn_info)
+  _WRAP_METHOD(static DsnInfo get_dsn_info(const Glib::ustring& dsn_name), gda_config_get_dsn_info)
   _WRAP_METHOD(static bool dsn_needs_authentication(const Glib::ustring& dsn_name), 
gda_config_dsn_needs_authentication)
 
   _WRAP_METHOD(static Glib::RefPtr<DataModel> list_dsn(), gda_config_list_dsn)
@@ -61,11 +62,14 @@ public:
 
   _WRAP_METHOD(static bool can_modify_system_config(), gda_config_can_modify_system_config)
 
-  #m4 _CONVERSION(`gpointer',`GdaDsnInfo*',`(GdaDsnInfo*)($3)')
-  _WRAP_SIGNAL(void dsn_added(GdaDsnInfo* info), "dsn-added", no_default_handler)
-  _WRAP_SIGNAL(void dsn_changed(GdaDsnInfo* info), "dsn-changed", no_default_handler)
-  _WRAP_SIGNAL(void dsn_removed(GdaDsnInfo* info), "dsn-removed", no_default_handler)
-  _WRAP_SIGNAL(void dsn_to_be_removed(GdaDsnInfo* info), "dsn-to-be-removed", no_default_handler)
+#m4 _CONVERSION(`const DsnInfo&',`const GdaDsnInfo*',__FCR2P)
+  _WRAP_METHOD(static void define_dsn(const DsnInfo &dsn),gda_config_define_dsn, errthrow)
+
+  #m4 _CONVERSION(`gpointer',`const DsnInfo&',`Glib::wrap((GdaDsnInfo*)($3))')
+  _WRAP_SIGNAL(void dsn_added(const DsnInfo& info), "dsn-added", no_default_handler)
+  _WRAP_SIGNAL(void dsn_changed(const DsnInfo& info), "dsn-changed", no_default_handler)
+  _WRAP_SIGNAL(void dsn_removed(const DsnInfo& info), "dsn-removed", no_default_handler)
+  _WRAP_SIGNAL(void dsn_to_be_removed(const DsnInfo& info), "dsn-to-be-removed", no_default_handler)
 
   _WRAP_PROPERTY("system-filename", Glib::ustring)
   _WRAP_PROPERTY("user-filename", Glib::ustring)
diff --git a/libgda/src/dsninfo.ccg b/libgda/src/dsninfo.ccg
new file mode 100644
index 0000000..35ce798
--- /dev/null
+++ b/libgda/src/dsninfo.ccg
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2018 libgdamm 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.
+ */
+
+_DEFS(libgdamm,libgda)
+
+#include <libgdamm/dsninfo.h>
+
+namespace Gnome
+{
+
+namespace Gda
+{
+
+
+} // namespace Gda
+
+} // namespace Gnome
diff --git a/libgda/src/dsninfo.hg b/libgda/src/dsninfo.hg
new file mode 100644
index 0000000..d38bf15
--- /dev/null
+++ b/libgda/src/dsninfo.hg
@@ -0,0 +1,59 @@
+/* Copyright 2018 libgdamm 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.
+ */
+
+_DEFS(libgdamm,libgda)
+
+#include <libgda/gda-value.h>
+#include <libgda/gda-config.h>
+
+namespace Gnome
+{
+
+namespace Gda
+{
+
+/**
+ */
+class DsnInfo
+{
+  _CLASS_BOXEDTYPE(DsnInfo, GdaDsnInfo, gda_dsn_info_new, gda_dsn_info_copy, gda_dsn_info_free)
+//  _IGNORE(gda_dsn_info_get_type)
+
+  public:
+#m4 _CONVERSION(gchar*, Glib::ustring, Glib::ustring($3))
+  _MEMBER_SET_STR(name, name, Glib::ustring, const gchar*)
+  _MEMBER_GET(name, name, Glib::ustring, gchar*)
+
+  _MEMBER_SET_STR(provider, provider, Glib::ustring, const gchar*)
+  _MEMBER_GET(provider, provider, Glib::ustring, gchar*)
+
+  _MEMBER_SET_STR(description, description, Glib::ustring, const gchar*)
+  _MEMBER_GET(description, description, Glib::ustring, gchar*)
+
+  _MEMBER_SET_STR(cnc_string, cnc_string, Glib::ustring, const gchar*)
+  _MEMBER_GET(cnc_string, cnc_string, Glib::ustring, gchar*)
+
+  _MEMBER_SET_STR(auth_string, auth_string, Glib::ustring, const gchar*)
+  _MEMBER_GET(auth_string, auth_string, Glib::ustring, gchar*)
+
+  _MEMBER_SET_PTR(is_system, is_system, bool, gboolean) // parameter will be passed by value
+  _MEMBER_GET(is_system, is_system, bool, gboolean)
+};
+
+} // namespace Gda
+
+} // namespace Gnome
diff --git a/libgda/src/filelist.am b/libgda/src/filelist.am
index d074220..ccc3d53 100644
--- a/libgda/src/filelist.am
+++ b/libgda/src/filelist.am
@@ -26,6 +26,7 @@ files_hg =                    \
        datamodeliter.hg        \
        dataproxy.hg            \
        dataselect.hg           \
+       dsninfo.hg          \
         geometricpoint.hg \
        handlerbin.hg           \
        handlerboolean.hg       \
diff --git a/tools/m4/convert_libgdamm.m4 b/tools/m4/convert_libgdamm.m4
index 255f651..05abcf7 100644
--- a/tools/m4/convert_libgdamm.m4
+++ b/tools/m4/convert_libgdamm.m4
@@ -55,6 +55,8 @@ _CONVERSION(`GdaMetaStruct*',`Glib::RefPtr<const MetaStruct>',`Glib::wrap($3)')
 _CONVERSION(`GdaMetaStore*',`Glib::RefPtr<MetaStore>',`Glib::wrap($3)')
 _CONVERSION(`GdaMetaStore*',`Glib::RefPtr<const MetaStore>',`Glib::wrap($3)')
 _CONVERSION(`GdaConfig*',`Glib::RefPtr<Config>',`Glib::wrap($3)')
+_CONVERSION(`GdaDsnInfo*',`Glib::RefPtr<DsnInfo>',`Glib::wrap($3)')
+_CONVERSION(`GdaDsnInfo*',`Glib::RefPtr<const DsnInfo>',`Glib::wrap($3)')
 
 _CONVERSION(`const Glib::RefPtr<BlobOp>&', `GdaBlobOp*', __CONVERT_REFPTR_TO_P)
 _CONVERSION(`const Glib::RefPtr<DataModel>&', `GdaDataModel*', __CONVERT_REFPTR_TO_P)


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