[anjuta/sdb-core-trans] symbol-db: fixed iface and implemented add_package.
- From: Massimo Cora' <mcora src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/sdb-core-trans] symbol-db: fixed iface and implemented add_package.
- Date: Fri, 30 Jul 2010 14:25:06 +0000 (UTC)
commit c5a3e0bcabd12e30ae52f771d06ea75936a6e9e1
Author: Massimo Corà <mcora src gnome org>
Date: Fri Jul 30 15:02:34 2010 +0200
symbol-db: fixed iface and implemented add_package.
libanjuta/interfaces/libanjuta.idl | 4 +-
plugins/symbol-db/benchmark/symbol-db/benchmark.c | 6 +-
plugins/symbol-db/plugin.c | 28 ++++++++++--
plugins/symbol-db/symbol-db-engine-core.c | 48 ++++++++++++++++-----
plugins/symbol-db/symbol-db-engine-core.h | 6 ++-
plugins/symbol-db/symbol-db-engine-priv.h | 11 ++++-
plugins/symbol-db/symbol-db-system.c | 3 +-
plugins/symbol-db/tables.sql | 4 +-
8 files changed, 84 insertions(+), 26 deletions(-)
---
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index 950045e..26732c1 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -6068,7 +6068,7 @@ interface IAnjutaSymbolManager
* FALSE if the version given was newer than the version in the database or the
* package was not found. In this case, add_package() should be called.
*/
- gboolean activate_package (const gchar *pkg_name, const gchar *pkg_version);
+ gboolean activate_package (const gchar *pkg_name, const gchar* pkg_version);
/**
* ianjuta_symbol_manager_deactivate_package:
@@ -6078,7 +6078,7 @@ interface IAnjutaSymbolManager
* Deactivates the package if it was found. If package is NULL, deactivate all
* packages
*/
- gboolean deactivate_package (const gchar* pkg_name, const gchar *pkg_version);
+ gboolean deactivate_package (const gchar* pkg_name, const gchar* pkg_version);
}
diff --git a/plugins/symbol-db/benchmark/symbol-db/benchmark.c b/plugins/symbol-db/benchmark/symbol-db/benchmark.c
index 901b333..a5b3059 100644
--- a/plugins/symbol-db/benchmark/symbol-db/benchmark.c
+++ b/plugins/symbol-db/benchmark/symbol-db/benchmark.c
@@ -115,13 +115,13 @@ int main (int argc, char** argv)
return -1;
}
- symbol_db_engine_add_new_project (engine, NULL, root_dir, 1.0);
+ symbol_db_engine_add_new_project (engine, NULL, root_dir, "1.0");
mimes = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (mimes, "text/x-csrc", "text/x-csrc");
g_hash_table_insert (mimes, "text/x-chdr", "text/x-chdr");
g_hash_table_insert (mimes, "text/x-c++src", "text/x-c++src");
- g_hash_table_insert (mimes, "text/x-c+++hdr", "text/x-c++hdr");
+ g_hash_table_insert (mimes, "text/x-c++hdr", "text/x-c++hdr");
files = get_source_files_by_mime (root_dir, mimes);
g_hash_table_destroy (mimes);
@@ -133,7 +133,7 @@ int main (int argc, char** argv)
g_signal_connect (G_OBJECT (engine), "single-file-scan-end",
G_CALLBACK (on_single_file_scan_end), files);
- symbol_db_engine_add_new_files_full_async (engine, root_dir, files, languages, TRUE);
+ symbol_db_engine_add_new_files_full_async (engine, root_dir, "1.0", files, languages, TRUE);
g_free (root_dir);
g_object_unref (g_dir);
diff --git a/plugins/symbol-db/plugin.c b/plugins/symbol-db/plugin.c
index c287bc1..cee6b32 100644
--- a/plugins/symbol-db/plugin.c
+++ b/plugins/symbol-db/plugin.c
@@ -475,8 +475,6 @@ on_editor_buffer_symbol_update_scan_end (SymbolDBEngine *dbe, gint process_id,
str = (gchar*)g_ptr_array_remove_index (sdb_plugin->buffer_update_files,
i);
- /* we can now free it */
- g_free (str);
}
}
@@ -876,7 +874,7 @@ do_add_new_files (SymbolDBPlugin *sdb_plugin, const GPtrArray *sources_array,
if (to_scan_array->len > 0)
{
gint proc_id = symbol_db_engine_add_new_files_full_async (sdb_plugin->sdbe_project,
- sdb_plugin->project_opened, to_scan_array, languages_array,
+ sdb_plugin->project_opened, "1.0", to_scan_array, languages_array,
TRUE);
/* insert the proc id associated within the task */
@@ -1662,7 +1660,7 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
symbol_db_engine_add_new_project (sdb_plugin->sdbe_project,
NULL, /* still no workspace logic */
sdb_plugin->project_opened,
- 1.0);
+ "1.0");
}
/*
@@ -2489,7 +2487,25 @@ isymbol_manager_add_package (IAnjutaSymbolManager *isymbol_manager,
const GList* files,
GError *err)
{
+ SymbolDBPlugin *sdb_plugin;
+ SymbolDBQuery *query;
+ IAnjutaLanguage *lang_manager;
+
+ sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (isymbol_manager);
+ lang_manager =anjuta_shell_get_interface (ANJUTA_PLUGIN (sdb_plugin)->shell, IAnjutaLanguage,
+ NULL);
+
+ if (symbol_db_engine_add_new_project (sdb_plugin->sdbe_globals, NULL, pkg_name,
+ pkg_version) == FALSE)
+ {
+ return FALSE;
+ }
+
+ symbol_db_engine_add_new_files_async (sdb_plugin->sdbe_globals, lang_manager,
+ pkg_name, pkg_version, files);
+
+ return TRUE;
}
static gboolean
@@ -2499,6 +2515,7 @@ isymbol_manager_activate_package (IAnjutaSymbolManager *isymbol_manager,
GError *err)
{
+ return TRUE;
}
static gboolean
@@ -2507,7 +2524,8 @@ isymbol_manager_deactivate_package (IAnjutaSymbolManager *isymbol_manager,
const gchar *pkg_version,
GError *err)
{
-
+
+ return TRUE;
}
static void
diff --git a/plugins/symbol-db/symbol-db-engine-core.c b/plugins/symbol-db/symbol-db-engine-core.c
index 2d55188..703d467 100644
--- a/plugins/symbol-db/symbol-db-engine-core.c
+++ b/plugins/symbol-db/symbol-db-engine-core.c
@@ -1655,8 +1655,9 @@ sdb_engine_init (SymbolDBEngine * object)
/* -- project -- */
STATIC_QUERY_POPULATE_INIT_NODE(sdbe->priv->static_query_list,
PREP_QUERY_PROJECT_NEW,
- "INSERT INTO project (project_name, wrkspace_id, analyse_time) VALUES (\
+ "INSERT INTO project (project_name, project_version, wrkspace_id, analyse_time) VALUES (\
## /* name:'prjname' type:gchararray */, \
+ ## /* name:'prjversion' type:gchararray */, \
(SELECT workspace_id FROM workspace \
WHERE \
workspace_name = ## /* name:'wsname' type:gchararray */ LIMIT 1), \
@@ -1682,7 +1683,9 @@ sdb_engine_init (SymbolDBEngine * object)
## /* name:'filepath' type:gchararray */, \
(SELECT project_id FROM project \
WHERE \
- project_name = ## /* name:'prjname' type:gchararray */ LIMIT 1), \
+ project_name = ## /* name:'prjname' type:gchararray */ AND \
+ project_version = ## /* name:'prjversion' type:gchararray */ \
+ LIMIT 1), \
## /* name:'langid' type:gint */, \
datetime ('now', 'localtime'))");
@@ -2712,7 +2715,7 @@ symbol_db_engine_project_exists (SymbolDBEngine * dbe, /*gchar* workspace, */
/* ~~~ Thread note: this function locks the mutex ~~~ */
gboolean
symbol_db_engine_add_new_project (SymbolDBEngine * dbe, const gchar * workspace,
- const gchar * project, gdouble version)
+ const gchar * project, const gchar* version)
{
const GdaSet *plist;
const GdaStatement *stmt;
@@ -2777,9 +2780,18 @@ symbol_db_engine_add_new_project (SymbolDBEngine * dbe, const gchar * workspace,
g_warning ("param prjname is NULL from pquery!");
SDB_UNLOCK(priv);
return FALSE;
- }
+ }
SDB_PARAM_SET_STRING(param, project);
+
+ if ((param = gda_set_get_holder ((GdaSet*)plist, "prjversion")) == NULL)
+ {
+ g_warning ("param prjversion is NULL from pquery!");
+ SDB_UNLOCK(priv);
+ return FALSE;
+ }
+
+ SDB_PARAM_SET_STRING(param, version);
if ((param = gda_set_get_holder ((GdaSet*)plist, "wsname")) == NULL)
{
@@ -2894,7 +2906,8 @@ sdb_engine_add_new_language (SymbolDBEngine * dbe, const gchar *language)
*/
static gboolean
sdb_engine_add_new_db_file (SymbolDBEngine * dbe, const gchar * project_name,
- const gchar * local_filepath, const gchar * language)
+ const gchar *project_version, const gchar * local_filepath,
+ const gchar * language)
{
const GdaSet *plist;
const GdaStatement *stmt;
@@ -2956,6 +2969,16 @@ sdb_engine_add_new_db_file (SymbolDBEngine * dbe, const gchar * project_name,
}
SDB_PARAM_SET_STRING(param, project_name);
+
+ /* prjversion parameter */
+ if ((param = gda_set_get_holder ((GdaSet*)plist, "prjversion")) == NULL)
+ {
+ g_warning ("param prjversion is NULL from pquery!");
+ SDB_UNLOCK(priv);
+ return FALSE;
+ }
+
+ SDB_PARAM_SET_STRING(param, project_version);
/* language id parameter */
if ((param = gda_set_get_holder ((GdaSet*)plist, "langid")) == NULL)
@@ -3017,6 +3040,7 @@ gint
symbol_db_engine_add_new_files_async (SymbolDBEngine *dbe,
IAnjutaLanguage* lang_manager,
const gchar * project_name,
+ const gchar * project_version,
const GPtrArray *sources_array)
{
SymbolDBEnginePriv *priv;
@@ -3074,8 +3098,8 @@ symbol_db_engine_add_new_files_async (SymbolDBEngine *dbe,
g_object_unref (gfile_info);
}
- gint res = symbol_db_engine_add_new_files_full_async (dbe, project_name, sources_array,
- lang_array, TRUE);
+ gint res = symbol_db_engine_add_new_files_full_async (dbe, project_name, project_version,
+ sources_array, lang_array, TRUE);
/* free resources */
g_ptr_array_unref (lang_array);
@@ -3086,6 +3110,7 @@ symbol_db_engine_add_new_files_async (SymbolDBEngine *dbe,
gint
symbol_db_engine_add_new_files_full_async (SymbolDBEngine * dbe,
const gchar * project_name,
+ const gchar * project_version,
const GPtrArray * files_path,
const GPtrArray * languages,
gboolean force_scan)
@@ -3125,12 +3150,13 @@ symbol_db_engine_add_new_files_full_async (SymbolDBEngine * dbe,
}
if (project_name != NULL &&
- sdb_engine_add_new_db_file (dbe, project_name, node_file,
+ sdb_engine_add_new_db_file (dbe, project_name, project_version, node_file,
node_lang) == FALSE)
{
DEBUG_PRINT ("Error processing file %s, db_directory %s, project_name %s, "
- "project_directory %s", node_file,
- priv->db_directory, project_name, priv->project_directory);
+ "project_version %s, project_directory %s", node_file,
+ priv->db_directory, project_name, project_version,
+ priv->project_directory);
return -1;
}
@@ -5287,7 +5313,7 @@ symbol_db_engine_update_buffer_symbols (SymbolDBEngine * dbe, const gchar *proje
continue;
}
- relative_path = symbol_db_util_get_file_db_path (dbe, curr_abs_file);
+ relative_path = g_strdup (symbol_db_util_get_file_db_path (dbe, curr_abs_file));
if (relative_path == NULL)
{
g_warning ("relative_path is NULL");
diff --git a/plugins/symbol-db/symbol-db-engine-core.h b/plugins/symbol-db/symbol-db-engine-core.h
index ca4ccfc..1d34b97 100644
--- a/plugins/symbol-db/symbol-db-engine-core.h
+++ b/plugins/symbol-db/symbol-db-engine-core.h
@@ -160,10 +160,12 @@ symbol_db_engine_add_new_workspace (SymbolDBEngine *dbe, const gchar* workspace)
* @param workspace Can be NULL. In that case a default workspace will be created,
* and project will depend on that.
* @param project Project name. Must NOT be NULL.
+ * @param version Version of the project, or of the package that project represents.
+ * If not sure pass "1.0".
*/
gboolean
symbol_db_engine_add_new_project (SymbolDBEngine *dbe, const gchar* workspace,
- const gchar* project, gdouble version);
+ const gchar* project, const gchar* version);
/**
* Test project existence.
@@ -215,6 +217,7 @@ symbol_db_engine_project_exists (SymbolDBEngine *dbe, /*gchar* workspace, */
gint
symbol_db_engine_add_new_files_full_async (SymbolDBEngine *dbe,
const gchar * project_name,
+ const gchar * project_version,
const GPtrArray *files_path,
const GPtrArray *languages,
gboolean force_scan);
@@ -239,6 +242,7 @@ gint
symbol_db_engine_add_new_files_async (SymbolDBEngine *dbe,
IAnjutaLanguage* lang_manager,
const gchar * project_name,
+ const gchar * project_version,
const GPtrArray *files_path);
/**
diff --git a/plugins/symbol-db/symbol-db-engine-priv.h b/plugins/symbol-db/symbol-db-engine-priv.h
index 6eb6af4..b07992a 100644
--- a/plugins/symbol-db/symbol-db-engine-priv.h
+++ b/plugins/symbol-db/symbol-db-engine-priv.h
@@ -38,7 +38,7 @@
#define ANJUTA_DB_FILE ".anjuta_sym_db"
/* if tables.sql changes or general db structure changes modify also the value here */
-#define SYMBOL_DB_VERSION "300.7"
+#define SYMBOL_DB_VERSION "300.8"
#define TABLES_SQL PACKAGE_DATA_DIR"/tables.sql"
@@ -61,6 +61,10 @@
g_value_init (&value, G_TYPE_INT); \
g_value_set_int (&value, (int_value));
+#define SDB_GVALUE_SET_DOUBLE(value, double_value) \
+ g_value_init (&value, G_TYPE_DOUBLE); \
+ g_value_set_double (&value, (double_value));
+
#define SDB_GVALUE_SET_STRING(value, str_value) \
g_value_init (&value, G_TYPE_STRING); \
g_value_set_string (&value, (str_value));
@@ -75,6 +79,11 @@
gda_holder_set_value ((gda_param), &v, NULL); \
g_value_unset (&v);
+#define SDB_PARAM_SET_DOUBLE(gda_param, double_value) \
+ SDB_GVALUE_SET_DOUBLE(v, double_value); \
+ gda_holder_set_value ((gda_param), &v, NULL); \
+ g_value_unset (&v);
+
#define SDB_PARAM_SET_STRING(gda_param, str_value) \
SDB_GVALUE_SET_STRING(v, str_value); \
gda_holder_set_value ((gda_param), &v, NULL); \
diff --git a/plugins/symbol-db/symbol-db-system.c b/plugins/symbol-db/symbol-db-system.c
index ce416e6..913e9c0 100644
--- a/plugins/symbol-db/symbol-db-system.c
+++ b/plugins/symbol-db/symbol-db-system.c
@@ -499,7 +499,7 @@ sdb_system_do_engine_scan (SymbolDBSystem *sdbs, EngineScanData *es_data)
languages_array);
symbol_db_engine_add_new_project (priv->sdbe_globals, NULL,
- es_data->package_name, 1.0);
+ es_data->package_name, "1.0");
}
else
{
@@ -516,6 +516,7 @@ sdb_system_do_engine_scan (SymbolDBSystem *sdbs, EngineScanData *es_data)
proc_id = symbol_db_engine_add_new_files_full_async (priv->sdbe_globals,
es_data->special_abort_scan == FALSE ?
es_data->package_name : NULL,
+ "1.0",
files_to_scan_array,
languages_array,
es_data->special_abort_scan == FALSE ?
diff --git a/plugins/symbol-db/tables.sql b/plugins/symbol-db/tables.sql
index 0dd883f..a831f22 100644
--- a/plugins/symbol-db/tables.sql
+++ b/plugins/symbol-db/tables.sql
@@ -11,10 +11,10 @@ CREATE TABLE workspace (workspace_id integer PRIMARY KEY AUTOINCREMENT,
DROP TABLE IF EXISTS project;
CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT,
project_name text not null,
- version numeric not null default 1.0,
+ project_version text not null default '1.0',
wrkspace_id integer REFERENCES workspace (workspace_id),
analyse_time date,
- unique (project_name, version)
+ unique (project_name, project_version)
);
DROP TABLE IF EXISTS file;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]