anjuta r4940 - in trunk: . libanjuta/interfaces plugins/symbol-db



Author: mcora
Date: Mon Apr 13 10:26:51 2009
New Revision: 4940
URL: http://svn.gnome.org/viewvc/anjuta?rev=4940&view=rev

Log:
	* libanjuta/interfaces/libanjuta.idl:
	* plugins/symbol-db/Makefile.am:
	* plugins/symbol-db/plugin.c (on_prefs_buffer_update_toggled):
	* plugins/symbol-db/symbol-db-engine-core.c
	(sdb_engine_get_statement_by_query_id):
	* plugins/symbol-db/symbol-db-iface.c (isymbol_manager_search),
	(isymbol_manager_get_members), (isymbol_manager_get_class_parents),
	(isymbol_manager_get_scope), (isymbol_manager_get_parent_scope),
	(isymbol_manager_get_symbol_more_info),
	(isymbol_manager_get_symbol_by_id), (do_search_prj_glb),
	(isymbol_manager_search_system), (get_unique_async_command_id),
	(on_sdb_search_command_data_arrived), (do_search_prj_glb_async),
	(isymbol_manager_search_system_async),
	(isymbol_manager_search_project),
	(isymbol_manager_search_project_async),
	(isymbol_manager_search_file), (isymbol_manager_search_file_async),
	(isymbol_manager_iface_init):
	* plugins/symbol-db/symbol-db-iface.h:
	* plugins/symbol-db/symbol-db-search-command.c
	(sdb_search_command_init), (sdb_search_command_finalize),
	(do_search_file), (do_search_prj_glb), (sdb_search_command_run),
	(sdb_search_command_class_init), (symbol_db_search_command_new),
	(symbol_db_search_command_set_file),
	(symbol_db_search_command_set_session_packages),
	(symbol_db_search_command_get_iterator_result):
	* plugins/symbol-db/symbol-db-search-command.h:
	* plugins/symbol-db/symbol-db-system.c (on_pkg_config_exit):
	Implemented async interface to search database. Needs test.

Added:
   trunk/plugins/symbol-db/symbol-db-iface.c
   trunk/plugins/symbol-db/symbol-db-iface.h
   trunk/plugins/symbol-db/symbol-db-search-command.c
   trunk/plugins/symbol-db/symbol-db-search-command.h
Modified:
   trunk/ChangeLog
   trunk/libanjuta/interfaces/libanjuta.idl
   trunk/plugins/symbol-db/Makefile.am
   trunk/plugins/symbol-db/plugin.c
   trunk/plugins/symbol-db/symbol-db-engine-core.c
   trunk/plugins/symbol-db/symbol-db-system.c

Modified: trunk/libanjuta/interfaces/libanjuta.idl
==============================================================================
--- trunk/libanjuta/interfaces/libanjuta.idl	(original)
+++ trunk/libanjuta/interfaces/libanjuta.idl	Mon Apr 13 10:26:51 2009
@@ -5048,6 +5048,7 @@
  */
 interface IAnjutaSymbolManager
 {
+	#include <libanjuta/anjuta-async-notify.h>	
 	#include "ianjuta-iterable.h"
 	#include "ianjuta-symbol.h"
 
@@ -5098,7 +5099,33 @@
 	* 
 	*/	
 	IAnjutaIterable* search_system (IAnjutaSymbolType match_types, gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern, gint results_limit, gint results_offset);
-		
+
+	/**
+	* ianjuta_symbol_manager_search_project_async:
+	* @obj: Self
+	* @match_types: If passed #IANJUTA_SYMBOL_TYPE_MAX the function will not perfom any filter.
+	* @include_types: Should the result contain or exclude the match_types? TRUE to include them,
+	*				  FALSE to exclude. For example use may want all symbols but classes.
+	* @info_fields: Kind of infos you would like to have available on the resulting Symbols.
+	* @pattern Pattern you want to search for. It can me something like 'foo_func' (exact match)
+	* or something like 'foo_fun%' (LIKE match, matching all the symbol prefixed with 'foo_fun'
+	* @results_limit: Limit results to an upper bound. -1 If you don't want to use this par.
+	* @results_offset: Skip results_offset results. -1 If you don't want to use this par.	 
+	* @cancel: An optional #GCancellable object to cancel the operation, or NULL.
+	* @notify: #AnjutaAsyncNotify object for finish notification and error reporting.
+	* @callback: #SearchCallback callback to call when query result data from database is available
+	* @callback_user_data: User data passed to callback	 
+	* @err: Error propagation and reporting.	 
+	*
+	* Async database query. The returned #IAnjutaIterable object must be unreffed after use.
+	* The search is case sensitive. Symbols are searched in the global packages (system) context.
+	* 
+	* Returns: guint handle to identify the query result. It would infact be possible to have
+	* more async queries at the same time. This is for identify them. Returns 0 on error.
+	* 
+    */
+	guint search_system_async (IAnjutaSymbolType match_types, gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern, gint results_limit, gint results_offset, GCancellable* cancel, AnjutaAsyncNotify *notify, SearchCallback callback, gpointer callback_user_data);
+	
 	/**
 	* ianjuta_symbol_manager_search_project:
 	* @obj: Self
@@ -5119,9 +5146,35 @@
 	* 
 	*/	
 	IAnjutaIterable* search_project (IAnjutaSymbolType match_types, gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern, gint results_limit, gint results_offset);
+
+	/**
+	* ianjuta_symbol_manager_search_project_async:
+	* @obj: Self
+	* @match_types: If passed #IANJUTA_SYMBOL_TYPE_MAX the function will not perfom any filter.
+	* @include_types: Should the result contain or exclude the match_types? TRUE to include them,
+	*				  FALSE to exclude. For example use may want all symbols but classes.
+	* @info_fields: Kind of infos you would like to have available on the resulting Symbols.
+	* @pattern Pattern you want to search for. It can me something like 'foo_func' (exact match)
+	* or something like 'foo_fun%' (LIKE match, matching all the symbol prefixed with 'foo_fun'
+	* @results_limit: Limit results to an upper bound. -1 If you don't want to use this par.
+	* @results_offset: Skip results_offset results. -1 If you don't want to use this par.	 
+	* @cancel: An optional #GCancellable object to cancel the operation, or NULL.
+	* @notify: #AnjutaAsyncNotify object for finish notification and error reporting.
+	* @callback: #SearchCallback callback to call when query result data from database is available
+	* @callback_user_data: User data passed to callback	 
+	* @err: Error propagation and reporting.	 
+	*
+	* Async database query. The returned #IAnjutaIterable object must be unreffed after use.
+	* The search is case sensitive. Symbols are searched only in the opened project's context.
+	* 
+	* Returns: guint handle to identify the query result. It would infact be possible to have
+	* more async queries at the same time. This is for identify them. Returns 0 on error.
+	* 
+    */	
+	guint search_project_async (IAnjutaSymbolType match_types, gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern, gint results_limit, gint results_offset, GCancellable* cancel, AnjutaAsyncNotify *notify, SearchCallback callback, gpointer callback_user_data);
 	
 	/**
-	* ianjuta_symbol_manager_search_project:
+	* ianjuta_symbol_manager_search_file:
 	* @obj: Self
 	* @match_types: If passed #IANJUTA_SYMBOL_TYPE_MAX the function will not perfom any filter.
 	* @include_types: Should the result contain or exclude the match_types? TRUE to include them,
@@ -5135,13 +5188,51 @@
 	* @err: Error propagation and reporting.	 
 	*
 	* Database query. The returned #IAnjutaIterable object must be unreffed after use.
-	* The search is case sensitive. Symbols are searched in the specified file.
+	* The search is case sensitive. Symbols are searched only in the specified file.
 	* 
 	* Returns: an iteratable object, or NULL if error occurs or if no symbols are found.
 	* 
 	*/		
 	IAnjutaIterable* search_file (IAnjutaSymbolType match_types, gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern, const GFile *file, gint results_limit, gint results_offset);
-		
+
+	/**
+	* ianjuta_symbol_manager_search_file_async:
+	* @obj: Self
+	* @match_types: If passed #IANJUTA_SYMBOL_TYPE_MAX the function will not perfom any filter.
+	* @include_types: Should the result contain or exclude the match_types? TRUE to include them,
+	*				  FALSE to exclude. For example use may want all symbols but classes.
+	* @info_fields: Kind of infos you would like to have available on the resulting Symbols.
+	* @pattern Pattern you want to search for. It can me something like 'foo_func' (exact match)
+	* or something like 'foo_fun%' (LIKE match, matching all the symbol prefixed with 'foo_fun'
+	* @file GFile of the file, belonging to the project, which you want to scan symbols for.
+	* @results_limit: Limit results to an upper bound. -1 If you don't want to use this par.
+	* @results_offset: Skip results_offset results. -1 If you don't want to use this par.	 
+	* @cancel: An optional #GCancellable object to cancel the operation, or NULL.
+	* @notify: #AnjutaAsyncNotify object for finish notification and error reporting.
+	* @callback: #SearchCallback callback to call when query result data from database is available
+	* @callback_user_data: User data passed to callback	 
+	* @err: Error propagation and reporting.	 
+	*
+	* Async database query. The returned #IAnjutaIterable object must be unreffed after use.
+	* The search is case sensitive. Symbols are searched only in the specified file.
+	* 
+	* Returns: guint handle to identify the query result. It would infact be possible to have
+	* more async queries at the same time. This is for identify them. Returns 0 on error.
+	* 
+    */
+	guint search_file_async (IAnjutaSymbolType match_types, gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern, const GFile *file, gint results_limit, gint results_offset, GCancellable* cancel, AnjutaAsyncNotify *notify, SearchCallback callback, gpointer callback_user_data);
+
+	/**
+    * IAnjutaSymbolManagerSearchCallback:
+    * @search_id: id that identifies uniquely the async query.
+    * @result: #IAnjutaIterable iterator object that contains the database query result.
+    * @user_data: User data
+    *
+    * Callback called for an async query to the database.
+	*/
+	typedef void (*SearchCallback) (guint search_id, IAnjutaIterable* result, gpointer user_data);
+	
+	
 	/**
 	* ianjuta_symbol_manager_get_members:
 	* @obj: Self

Modified: trunk/plugins/symbol-db/Makefile.am
==============================================================================
--- trunk/plugins/symbol-db/Makefile.am	(original)
+++ trunk/plugins/symbol-db/Makefile.am	Mon Apr 13 10:26:51 2009
@@ -64,7 +64,9 @@
 	symbol-db-engine-queries.h  symbol-db-engine-utils.c \
 	symbol-db-engine-utils.h  symbol-db-engine-priv.h \
 	symbol-db-engine-core.c  symbol-db-engine-core.h \
-	symbol-db-engine.h
+	symbol-db-engine.h  symbol-db-iface.c \
+	symbol-db-iface.h  symbol-db-search-command.h \
+	symbol-db-search-command.c
 
 libanjuta_symbol_db_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
 

Modified: trunk/plugins/symbol-db/plugin.c
==============================================================================
--- trunk/plugins/symbol-db/plugin.c	(original)
+++ trunk/plugins/symbol-db/plugin.c	Mon Apr 13 10:26:51 2009
@@ -45,6 +45,7 @@
 #include "symbol-db-view-search.h"
 #include "symbol-db-engine.h"
 #include "symbol-db-prefs.h"
+#include "symbol-db-iface.h"
 
 #define ICON_FILE "anjuta-symbol-db-plugin-48.png"
 #define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-symbol-db-plugin.ui"
@@ -325,9 +326,11 @@
 };
 
 static GtkActionEntry actions_search[] = {
-  { "ActionEditSearchFindSymbol", GTK_STOCK_FIND, N_("_Find Symbol..."),
+  { 
+	"ActionEditSearchFindSymbol", GTK_STOCK_FIND, N_("_Find Symbol..."),
 	"<control>l", N_("Find Symbol"),
-    G_CALLBACK (on_find_symbol)}
+    G_CALLBACK (on_find_symbol)
+  }
 };
 
 static void
@@ -2546,377 +2549,6 @@
 						g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);	
 }
 
-static IAnjutaIterable*
-isymbol_manager_search (IAnjutaSymbolManager *sm,
-						IAnjutaSymbolType match_types,
-						gboolean include_types,
-						IAnjutaSymbolField info_fields,
-						const gchar *match_name,
-						gboolean partial_name_match,
-						gboolean global_symbols_search,
-						gboolean global_tags_search,
-						gint results_limit,
-						gint results_offset,
-						GError **err)
-{
-	SymbolDBEngineIterator *iterator = NULL;
-	SymbolDBPlugin *sdb_plugin;
-	SymbolDBEngine *dbe_project;
-	SymbolDBEngine *dbe_globals;
-	GPtrArray *filter_array;
-	gchar *pattern;
-	gboolean exact_match = !partial_name_match;
-
-	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
-	dbe_project = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
-	dbe_globals = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_globals);
-	
-	if (match_types & IANJUTA_SYMBOL_TYPE_UNDEF)
-	{
-		filter_array = NULL;
-		/*DEBUG_PRINT ("%s", "filter_array is NULL");*/
-	}
-	else 
-	{
-		filter_array = symbol_db_util_fill_type_array (match_types);
-		/*DEBUG_PRINT ("filter_array filled with %d kinds", filter_array->len);*/
-	}
-
-	if (exact_match == FALSE)
-		pattern = g_strdup_printf ("%s%%", match_name == NULL ? "" : match_name);
-	else
-	{
-		if (match_name == NULL)
-			pattern = NULL;
-		else
-			pattern = g_strdup_printf ("%s", match_name);
-	}
-	
-	/* should we lookup for project of system tags? */
-	iterator = 
-		symbol_db_engine_find_symbol_by_name_pattern_filtered (
-					global_tags_search == FALSE ? dbe_project : dbe_globals, 
-					pattern,
-					exact_match,
-					filter_array,
-					include_types,
-					global_symbols_search,
-					global_tags_search == FALSE ? NULL : sdb_plugin->session_packages,
-					results_limit,
-					results_offset,
-					info_fields);	
-	g_free (pattern);
-	
-	if (filter_array)
-	{
-		g_ptr_array_foreach (filter_array, (GFunc)g_free, NULL);
-		g_ptr_array_free (filter_array, TRUE);
-	}
-	return IANJUTA_ITERABLE (iterator);
-}
-
-static IAnjutaIterable*
-isymbol_manager_get_members (IAnjutaSymbolManager *sm,
-							 const IAnjutaSymbol *symbol, 
-							 IAnjutaSymbolField info_fields,
-							 gboolean global_search,
-							 GError **err)
-{
-	SymbolDBEngineIteratorNode *node;
-	SymbolDBPlugin *sdb_plugin;
-	SymbolDBEngine *dbe;
-	gint sym_id;
-	SymbolDBEngineIterator *iterator;
-
-	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
-	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);	
-	node = SYMBOL_DB_ENGINE_ITERATOR_NODE (symbol);
-	
-	sym_id = symbol_db_engine_iterator_node_get_symbol_id (node);
-	
-	iterator = symbol_db_engine_get_scope_members_by_symbol_id (dbe,
-																sym_id,
-																-1, 
-																-1,
-																info_fields);
-	return IANJUTA_ITERABLE (iterator);
-}
-
-static IAnjutaIterable*
-isymbol_manager_get_class_parents (IAnjutaSymbolManager *sm,
-							 const IAnjutaSymbol *symbol,
-							 IAnjutaSymbolField info_fields,
-							 GError **err)
-{
-	SymbolDBEngineIteratorNode *node;
-	SymbolDBPlugin *sdb_plugin;
-	SymbolDBEngine *dbe;
-	gint sym_id;
-	SymbolDBEngineIterator *iterator;
-
-	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
-	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
-	
-	node = SYMBOL_DB_ENGINE_ITERATOR_NODE (symbol);
-	
-	sym_id = symbol_db_engine_iterator_node_get_symbol_id (node);
-	
-	iterator = symbol_db_engine_get_class_parents_by_symbol_id (dbe, 
-																sym_id, 
-																info_fields);
-	return IANJUTA_ITERABLE (iterator);
-}
-
-static IAnjutaIterable*
-isymbol_manager_get_scope (IAnjutaSymbolManager *sm,
-						   const gchar* filename,  
-						   gulong line,  
-						   IAnjutaSymbolField info_fields, 
-						   GError **err)
-{
-	SymbolDBPlugin *sdb_plugin;
-	SymbolDBEngine *dbe;
-	SymbolDBEngineIterator *iterator;
-
-	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
-	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
-	
-	iterator = symbol_db_engine_get_current_scope (dbe, filename, line, info_fields);
-	
-	return IANJUTA_ITERABLE (iterator);
-}
-
-static IAnjutaIterable*
-isymbol_manager_get_parent_scope (IAnjutaSymbolManager *sm,
-								  const IAnjutaSymbol *symbol, 
-								  const gchar *filename, 
-								  IAnjutaSymbolField info_fields,
-								  GError **err)
-{
-	SymbolDBEngineIteratorNode *node;
-	gint child_node_id, parent_node_id;
-	SymbolDBPlugin *sdb_plugin;
-	SymbolDBEngine *dbe;
-	SymbolDBEngineIterator *iterator;
-
-	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
-	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
-
-	node = SYMBOL_DB_ENGINE_ITERATOR_NODE (symbol);
-	
-	child_node_id = symbol_db_engine_iterator_node_get_symbol_id (node);
-	
-	if (child_node_id <= 0)
-		return NULL;
-	
-	parent_node_id = symbol_db_engine_get_parent_scope_id_by_symbol_id (dbe,
-									child_node_id,
-									filename);
-
-	iterator = symbol_db_engine_get_symbol_info_by_id (dbe, parent_node_id, 
-													   info_fields);
-	return IANJUTA_ITERABLE (iterator);
-}
-
-static IAnjutaIterable*
-isymbol_manager_get_symbol_more_info (IAnjutaSymbolManager *sm,
-								  const IAnjutaSymbol *symbol, 
-								  IAnjutaSymbolField info_fields,
-								  GError **err)
-{
-	SymbolDBEngineIteratorNode *node;
-	gint node_id;
-	SymbolDBPlugin *sdb_plugin;
-	SymbolDBEngine *dbe;
-	SymbolDBEngineIterator *iterator;
-
-	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
-	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
-
-	node = SYMBOL_DB_ENGINE_ITERATOR_NODE (symbol);
-	
-	node_id = symbol_db_engine_iterator_node_get_symbol_id (node);
-	
-	if (node_id <= 0)
-		return NULL;
-	
-	iterator = symbol_db_engine_get_symbol_info_by_id (dbe, node_id, info_fields);	
-	
-	return IANJUTA_ITERABLE (iterator);
-}
-
-static IAnjutaSymbol*
-isymbol_manager_get_symbol_by_id (IAnjutaSymbolManager *sm,
-								  gint symbol_id, 
-								  IAnjutaSymbolField info_fields,
-								  GError **err)
-{
-	SymbolDBEngineIteratorNode *node;
-	SymbolDBPlugin *sdb_plugin;
-	SymbolDBEngine *dbe;
-	SymbolDBEngineIterator *iterator;
-
-	g_return_val_if_fail (symbol_id > 0, NULL);
-	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
-	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
-
-	iterator = symbol_db_engine_get_symbol_info_by_id (dbe, symbol_id, 
-													   info_fields);	
-	
-	if (iterator == NULL)
-		return NULL;
-	
-	node = SYMBOL_DB_ENGINE_ITERATOR_NODE (iterator);
-	return IANJUTA_SYMBOL (node);
-}
-
-static IAnjutaIterable* 
-isymbol_manager_search_system (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types, 
-				gboolean include_types,  IAnjutaSymbolField info_fields, const gchar *pattern, 
-			   gint results_limit, gint results_offset, GError **err)
-{
-	SymbolDBPlugin *sdb_plugin;
-	SymbolDBEngine *dbe;
-	SymbolDBEngineIterator *iterator;
-	gboolean exact_match;
-	GPtrArray *filter_array;
-	g_return_val_if_fail (pattern != NULL, NULL);
-	
-	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
-	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_globals);
-	
-	exact_match = symbol_db_util_is_pattern_exact_match (pattern);
-
-	if (match_types & IANJUTA_SYMBOL_TYPE_UNDEF)
-	{
-		filter_array = NULL;
-	}
-	else 
-	{
-		filter_array = symbol_db_util_fill_type_array (match_types);
-	}
-	
-	iterator = 		
-		symbol_db_engine_find_symbol_by_name_pattern_filtered (dbe,
-					pattern,
-					exact_match,
-					filter_array,
-					include_types,
-					1,
-					sdb_plugin->session_packages,
-					results_limit,
-					results_offset,
-					info_fields);	
-	
-	return IANJUTA_ITERABLE (iterator);
-}	
-			
-
-static IAnjutaIterable* 
-isymbol_manager_search_project (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types, 
-				gboolean include_types,  IAnjutaSymbolField info_fields, const gchar *pattern, 
-				gint results_limit, gint results_offset, GError **err)
-{
-	SymbolDBPlugin *sdb_plugin;
-	SymbolDBEngine *dbe;
-	SymbolDBEngineIterator *iterator;
-	gboolean exact_match;
-	GPtrArray *filter_array;
-
-	g_return_val_if_fail (pattern != NULL, NULL);
-	
-	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
-	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
-	
-	exact_match = symbol_db_util_is_pattern_exact_match (pattern);
-
-	if (match_types & IANJUTA_SYMBOL_TYPE_UNDEF)
-	{
-		filter_array = NULL;
-	}
-	else 
-	{
-		filter_array = symbol_db_util_fill_type_array (match_types);
-	}
-	
-	iterator = 		
-		symbol_db_engine_find_symbol_by_name_pattern_filtered (dbe,
-				    pattern,
-					exact_match,
-					filter_array,
-					include_types,
-					1,
-					NULL,
-					results_limit,
-					results_offset,
-					info_fields);
-	
-	return IANJUTA_ITERABLE (iterator);
-}
-	
-	
-static IAnjutaIterable* 
-isymbol_manager_search_file (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types, 
-				gboolean include_types,  IAnjutaSymbolField info_fields, const gchar *pattern, 
-			 	const GFile *file, gint results_limit, gint results_offset, GError **err)
-{
-	SymbolDBPlugin *sdb_plugin;
-	SymbolDBEngine *dbe;
-	SymbolDBEngineIterator *iterator;
-	GPtrArray *filter_array;
-	gchar *abs_file_path;
-
-	g_return_val_if_fail (pattern != NULL, NULL);
-	
-	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
-	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
-	
-	abs_file_path = g_file_get_path ((GFile *)file);
-
-	if (abs_file_path == NULL)
-	{
-		g_warning ("isymbol_manager_search_file (): GFile has no absolute path");
-		return NULL;
-	}
-	
-	if (match_types & IANJUTA_SYMBOL_TYPE_UNDEF)
-	{
-		filter_array = NULL;
-	}
-	else 
-	{
-		filter_array = symbol_db_util_fill_type_array (match_types);
-	}
-	
-	iterator = 		
-		symbol_db_engine_find_symbol_by_name_pattern_on_file (dbe,
-				    pattern,
-					abs_file_path,
-					filter_array,
-					include_types,
-					results_limit,
-					results_offset,
-					info_fields);
-	
-	g_free (abs_file_path);
-	
-	return IANJUTA_ITERABLE (iterator);
-}
-
-static void
-isymbol_manager_iface_init (IAnjutaSymbolManagerIface *iface)
-{
-	iface->search = isymbol_manager_search;
-	iface->get_members = isymbol_manager_get_members;
-	iface->get_class_parents = isymbol_manager_get_class_parents;
-	iface->get_scope = isymbol_manager_get_scope;
-	iface->get_parent_scope = isymbol_manager_get_parent_scope;
-	iface->get_symbol_more_info = isymbol_manager_get_symbol_more_info;
-	iface->get_symbol_by_id = isymbol_manager_get_symbol_by_id;
-	iface->search_system = isymbol_manager_search_system;
-	iface->search_project = isymbol_manager_search_project;
-	iface->search_file = isymbol_manager_search_file;
-}
 
 
 static void
@@ -2982,8 +2614,7 @@
 									   on_editor_buffer_symbols_update_timeout,
 									   sdb_plugin);			
 		
-	}
-	
+	}	
 }
 
 static void

Modified: trunk/plugins/symbol-db/symbol-db-engine-core.c
==============================================================================
--- trunk/plugins/symbol-db/symbol-db-engine-core.c	(original)
+++ trunk/plugins/symbol-db/symbol-db-engine-core.c	Mon Apr 13 10:26:51 2009
@@ -421,7 +421,6 @@
 
 	if (node->stmt == NULL)
 	{
-		/*DEBUG_PRINT ("generating new statement.. %d", query_id);*/
 		/* create a new GdaStatement */
 		node->stmt =
 			gda_sql_parser_parse_string (priv->sql_parser, node->query_str, NULL, 

Added: trunk/plugins/symbol-db/symbol-db-iface.c
==============================================================================
--- (empty file)
+++ trunk/plugins/symbol-db/symbol-db-iface.c	Mon Apr 13 10:26:51 2009
@@ -0,0 +1,619 @@
+/*
+ * anjuta
+ * Copyright (C) Massimo Cora' 2007-2009 <maxcvs email it>
+ * 
+ * anjuta is free software.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program 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 Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+#include "symbol-db-engine.h"
+
+#include "symbol-db-search-command.h"
+#include "symbol-db-iface.h"
+#include "plugin.h"
+
+#include <libanjuta/anjuta-debug.h>
+
+static guint async_command_id = 1;
+ 
+IAnjutaIterable*
+isymbol_manager_search (IAnjutaSymbolManager *sm,
+						IAnjutaSymbolType match_types,
+						gboolean include_types,
+						IAnjutaSymbolField info_fields,
+						const gchar *match_name,
+						gboolean partial_name_match,
+						gboolean global_symbols_search,
+						gboolean global_tags_search,
+						gint results_limit,
+						gint results_offset,
+						GError **err)
+{
+	SymbolDBEngineIterator *iterator = NULL;
+	SymbolDBPlugin *sdb_plugin;
+	SymbolDBEngine *dbe_project;
+	SymbolDBEngine *dbe_globals;
+	GPtrArray *filter_array;
+	gchar *pattern;
+	gboolean exact_match = !partial_name_match;
+
+	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
+	dbe_project = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
+	dbe_globals = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_globals);
+	
+	if (match_types & IANJUTA_SYMBOL_TYPE_UNDEF)
+	{
+		filter_array = NULL;
+		/*DEBUG_PRINT ("%s", "filter_array is NULL");*/
+	}
+	else 
+	{
+		filter_array = symbol_db_util_fill_type_array (match_types);
+		/*DEBUG_PRINT ("filter_array filled with %d kinds", filter_array->len);*/
+	}
+
+	if (exact_match == FALSE)
+		pattern = g_strdup_printf ("%s%%", match_name == NULL ? "" : match_name);
+	else
+	{
+		if (match_name == NULL)
+			pattern = NULL;
+		else
+			pattern = g_strdup_printf ("%s", match_name);
+	}
+	
+	/* should we lookup for project of system tags? */
+	iterator = 
+		symbol_db_engine_find_symbol_by_name_pattern_filtered (
+					global_tags_search == FALSE ? dbe_project : dbe_globals, 
+					pattern,
+					exact_match,
+					filter_array,
+					include_types,
+					global_symbols_search,
+					global_tags_search == FALSE ? NULL : sdb_plugin->session_packages,
+					results_limit,
+					results_offset,
+					info_fields);	
+	g_free (pattern);
+	
+	if (filter_array)
+	{
+		g_ptr_array_foreach (filter_array, (GFunc)g_free, NULL);
+		g_ptr_array_free (filter_array, TRUE);
+	}
+	return IANJUTA_ITERABLE (iterator);
+}
+
+IAnjutaIterable*
+isymbol_manager_get_members (IAnjutaSymbolManager *sm,
+							 const IAnjutaSymbol *symbol, 
+							 IAnjutaSymbolField info_fields,
+							 gboolean global_search,
+							 GError **err)
+{
+	SymbolDBEngineIteratorNode *node;
+	SymbolDBPlugin *sdb_plugin;
+	SymbolDBEngine *dbe;
+	gint sym_id;
+	SymbolDBEngineIterator *iterator;
+
+	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
+	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);	
+	node = SYMBOL_DB_ENGINE_ITERATOR_NODE (symbol);
+	
+	sym_id = symbol_db_engine_iterator_node_get_symbol_id (node);
+	
+	iterator = symbol_db_engine_get_scope_members_by_symbol_id (dbe,
+																sym_id,
+																-1, 
+																-1,
+																info_fields);
+	return IANJUTA_ITERABLE (iterator);
+}
+
+IAnjutaIterable*
+isymbol_manager_get_class_parents (IAnjutaSymbolManager *sm,
+							 const IAnjutaSymbol *symbol,
+							 IAnjutaSymbolField info_fields,
+							 GError **err)
+{
+	SymbolDBEngineIteratorNode *node;
+	SymbolDBPlugin *sdb_plugin;
+	SymbolDBEngine *dbe;
+	gint sym_id;
+	SymbolDBEngineIterator *iterator;
+
+	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
+	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
+	
+	node = SYMBOL_DB_ENGINE_ITERATOR_NODE (symbol);
+	
+	sym_id = symbol_db_engine_iterator_node_get_symbol_id (node);
+	
+	iterator = symbol_db_engine_get_class_parents_by_symbol_id (dbe, 
+																sym_id, 
+																info_fields);
+	return IANJUTA_ITERABLE (iterator);
+}
+
+IAnjutaIterable*
+isymbol_manager_get_scope (IAnjutaSymbolManager *sm,
+						   const gchar* filename,  
+						   gulong line,  
+						   IAnjutaSymbolField info_fields, 
+						   GError **err)
+{
+	SymbolDBPlugin *sdb_plugin;
+	SymbolDBEngine *dbe;
+	SymbolDBEngineIterator *iterator;
+
+	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
+	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
+	
+	iterator = symbol_db_engine_get_current_scope (dbe, filename, line, info_fields);
+	
+	return IANJUTA_ITERABLE (iterator);
+}
+
+IAnjutaIterable*
+isymbol_manager_get_parent_scope (IAnjutaSymbolManager *sm,
+								  const IAnjutaSymbol *symbol, 
+								  const gchar *filename, 
+								  IAnjutaSymbolField info_fields,
+								  GError **err)
+{
+	SymbolDBEngineIteratorNode *node;
+	gint child_node_id, parent_node_id;
+	SymbolDBPlugin *sdb_plugin;
+	SymbolDBEngine *dbe;
+	SymbolDBEngineIterator *iterator;
+
+	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
+	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
+
+	node = SYMBOL_DB_ENGINE_ITERATOR_NODE (symbol);
+	
+	child_node_id = symbol_db_engine_iterator_node_get_symbol_id (node);
+	
+	if (child_node_id <= 0)
+		return NULL;
+	
+	parent_node_id = symbol_db_engine_get_parent_scope_id_by_symbol_id (dbe,
+									child_node_id,
+									filename);
+
+	iterator = symbol_db_engine_get_symbol_info_by_id (dbe, parent_node_id, 
+													   info_fields);
+	return IANJUTA_ITERABLE (iterator);
+}
+
+IAnjutaIterable*
+isymbol_manager_get_symbol_more_info (IAnjutaSymbolManager *sm,
+								  const IAnjutaSymbol *symbol, 
+								  IAnjutaSymbolField info_fields,
+								  GError **err)
+{
+	SymbolDBEngineIteratorNode *node;
+	gint node_id;
+	SymbolDBPlugin *sdb_plugin;
+	SymbolDBEngine *dbe;
+	SymbolDBEngineIterator *iterator;
+
+	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
+	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
+
+	node = SYMBOL_DB_ENGINE_ITERATOR_NODE (symbol);
+	
+	node_id = symbol_db_engine_iterator_node_get_symbol_id (node);
+	
+	if (node_id <= 0)
+		return NULL;
+	
+	iterator = symbol_db_engine_get_symbol_info_by_id (dbe, node_id, info_fields);	
+	
+	return IANJUTA_ITERABLE (iterator);
+}
+
+IAnjutaSymbol*
+isymbol_manager_get_symbol_by_id (IAnjutaSymbolManager *sm,
+								  gint symbol_id, 
+								  IAnjutaSymbolField info_fields,
+								  GError **err)
+{
+	SymbolDBEngineIteratorNode *node;
+	SymbolDBPlugin *sdb_plugin;
+	SymbolDBEngine *dbe;
+	SymbolDBEngineIterator *iterator;
+
+	g_return_val_if_fail (symbol_id > 0, NULL);
+	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
+	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
+
+	iterator = symbol_db_engine_get_symbol_info_by_id (dbe, symbol_id, 
+													   info_fields);	
+	
+	if (iterator == NULL)
+		return NULL;
+	
+	node = SYMBOL_DB_ENGINE_ITERATOR_NODE (iterator);
+	return IANJUTA_SYMBOL (node);
+}
+
+static SymbolDBEngineIterator *
+do_search_prj_glb (SymbolDBEngine *dbe, IAnjutaSymbolType match_types,
+           gboolean include_types, IAnjutaSymbolField info_fields,
+           const gchar *pattern, gint results_limit, gint results_offset, 
+           GList *session_packages)
+{
+	SymbolDBEngineIterator *iterator;
+	gboolean exact_match;
+	GPtrArray *filter_array;
+	
+	exact_match = symbol_db_util_is_pattern_exact_match (pattern);
+
+	if (match_types & IANJUTA_SYMBOL_TYPE_UNDEF)
+	{
+		filter_array = NULL;
+	}
+	else 
+	{
+		filter_array = symbol_db_util_fill_type_array (match_types);
+	}
+	
+	iterator = 		
+		symbol_db_engine_find_symbol_by_name_pattern_filtered (dbe,
+					pattern,
+					exact_match,
+					filter_array,
+					include_types,
+					1,
+					session_packages,
+					results_limit,
+					results_offset,
+					info_fields);	
+	
+	return iterator;
+}
+
+IAnjutaIterable* 
+isymbol_manager_search_system (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types, 
+				gboolean include_types,  IAnjutaSymbolField info_fields, 
+				const gchar *pattern, gint results_limit, gint results_offset, 
+				GError **err)
+{
+	SymbolDBPlugin *sdb_plugin;
+	SymbolDBEngine *dbe;
+	SymbolDBEngineIterator *iterator;
+	g_return_val_if_fail (pattern != NULL, NULL);
+	
+	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
+	/* take the global's engine */
+	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_globals);
+
+	iterator = do_search_prj_glb (dbe, match_types, info_fields, 
+	                      include_types, pattern, 
+						  results_limit, results_offset,
+	           			  sdb_plugin->session_packages);
+
+	return IANJUTA_ITERABLE (iterator);
+}
+
+static guint
+get_unique_async_command_id ()
+{
+	return async_command_id++;
+}
+
+static void
+on_sdb_search_command_data_arrived (AnjutaCommand *command, 
+									 IAnjutaSymbolManagerSearchCallback callback)
+{
+	SymbolDBSearchCommand *sdbsc;
+	SymbolDBEngineIterator *iterator;
+	gpointer callback_user_data = NULL;
+	guint cmd_id;
+	
+	sdbsc = SYMBOL_DB_SEARCH_COMMAND (command);
+	iterator = symbol_db_search_command_get_iterator_result (sdbsc);
+		
+	/* get the previously saved cmd_id and callback data */
+	cmd_id = GPOINTER_TO_UINT  (g_object_get_data (G_OBJECT (command), "cmd_id"));
+	callback_user_data = g_object_get_data (G_OBJECT (command), "callback_user_data");
+	
+	callback (cmd_id, IANJUTA_ITERABLE (iterator), callback_user_data);
+}
+
+static gint
+do_search_prj_glb_async (SymbolDBSearchCommand *search_command, guint cmd_id, 
+                         GCancellable* cancel, AnjutaAsyncNotify *notify, 
+                		 IAnjutaSymbolManagerSearchCallback callback, 
+						 gpointer callback_user_data)
+{
+	/* be sure that the cmd_id and the callback_user_data stay with us when the 
+	 * data-arrived signal is raised 
+	 */
+	g_object_set_data (G_OBJECT (search_command), "cmd_id",
+	                   GUINT_TO_POINTER (cmd_id));
+
+	/* FIXME: why is data checked for NULL on iface layer? It should be able to 
+	 * arrive here == NULL....
+	 */
+	if (callback_user_data != NULL)
+		g_object_set_data (G_OBJECT (search_command), "callback_user_data", 
+	                   callback_user_data);
+
+	/* connect some signals */
+	g_signal_connect (G_OBJECT (search_command), "data-arrived",
+					  G_CALLBACK (on_sdb_search_command_data_arrived),
+					  callback);
+	
+	g_signal_connect (G_OBJECT (search_command), "command-finished",
+					  G_CALLBACK (g_object_unref),
+					  NULL);
+	
+	if (cancel)
+	{
+		g_signal_connect_swapped (G_OBJECT (cancel), "cancelled",
+								  G_CALLBACK (anjuta_command_cancel),
+								  search_command);
+	}
+	
+	if (notify)
+	{
+		g_signal_connect_swapped (G_OBJECT (search_command), "command-finished",
+								  G_CALLBACK (anjuta_async_notify_notify_finished),
+								  notify);
+	}
+	
+	anjuta_command_start (ANJUTA_COMMAND (search_command));	
+
+	return cmd_id;	
+}
+
+guint
+isymbol_manager_search_system_async (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types, 
+				gboolean include_types,  IAnjutaSymbolField info_fields, const gchar *pattern, 
+			    gint results_limit, gint results_offset, 
+                GCancellable* cancel, AnjutaAsyncNotify *notify, 
+                IAnjutaSymbolManagerSearchCallback callback, 
+				gpointer callback_user_data, GError **err)
+{
+	SymbolDBSearchCommand *search_command;
+	SymbolDBPlugin *sdb_plugin;
+	SymbolDBEngine *dbe;
+	guint cmd_id;
+
+	/* if the return is 0 then we'll have an error, i.e. no valid command id has 
+	 * been generated
+	 */
+	g_return_val_if_fail (pattern != NULL, 0);
+
+	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
+	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_globals);
+
+	/* get an unique cmd_id */
+	cmd_id = get_unique_async_command_id ();
+	
+	/* create a new command */
+	search_command = symbol_db_search_command_new (dbe, CMD_SEARCH_SYSTEM, match_types, 
+				include_types, info_fields, pattern, results_limit, results_offset);
+
+	/* don't forget to set the session packages too */
+	symbol_db_search_command_set_session_packages (search_command, 
+	                                               sdb_plugin->session_packages);	
+
+	return do_search_prj_glb_async (search_command, cmd_id, cancel, notify, 
+	                                callback, callback_user_data);
+}
+
+IAnjutaIterable* 
+isymbol_manager_search_project (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types, 
+				gboolean include_types,  IAnjutaSymbolField info_fields, const gchar *pattern, 
+				gint results_limit, gint results_offset, GError **err)
+{
+	SymbolDBPlugin *sdb_plugin;
+	SymbolDBEngine *dbe;
+	SymbolDBEngineIterator *iterator;
+	g_return_val_if_fail (pattern != NULL, NULL);
+	
+	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
+	/* take the project's engine */
+	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
+
+	iterator = do_search_prj_glb (dbe, match_types, info_fields, 
+	                      include_types, pattern, 
+						  results_limit, results_offset,
+	           			  NULL);
+
+	return IANJUTA_ITERABLE (iterator);
+}
+
+guint
+isymbol_manager_search_project_async (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types, 
+				gboolean include_types,  IAnjutaSymbolField info_fields, const gchar *pattern, 
+				gint results_limit, gint results_offset, 
+                GCancellable* cancel, AnjutaAsyncNotify *notify, 
+                IAnjutaSymbolManagerSearchCallback callback, 
+				gpointer callback_user_data, GError **err)
+{
+	SymbolDBSearchCommand *search_command;
+	SymbolDBPlugin *sdb_plugin;
+	SymbolDBEngine *dbe;
+	guint cmd_id;
+
+	/* if the return is 0 then we'll have an error, i.e. no valid command id has 
+	 * been generated
+	 */
+	g_return_val_if_fail (pattern != NULL, 0);
+
+	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
+	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
+
+	/* get an unique cmd_id */
+	cmd_id = get_unique_async_command_id ();
+	
+	/* create a new command */
+	search_command = symbol_db_search_command_new (dbe, CMD_SEARCH_PROJECT, match_types, 
+				include_types, info_fields, pattern, results_limit, results_offset);
+
+	/* don't forget to set the session packages to NULL */
+	symbol_db_search_command_set_session_packages (search_command, NULL);	
+
+	return do_search_prj_glb_async (search_command, cmd_id, cancel, notify, 
+	                                callback, callback_user_data);
+}
+
+IAnjutaIterable* 
+isymbol_manager_search_file (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types, 
+				gboolean include_types,  IAnjutaSymbolField info_fields, const gchar *pattern, 
+			 	const GFile *file, gint results_limit, gint results_offset, GError **err)
+{
+	SymbolDBPlugin *sdb_plugin;
+	SymbolDBEngine *dbe;
+	SymbolDBEngineIterator *iterator;
+	GPtrArray *filter_array;
+	gchar *abs_file_path;
+
+	g_return_val_if_fail (file != NULL, NULL);
+	g_return_val_if_fail (pattern != NULL, NULL);
+	
+	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
+	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
+	
+	abs_file_path = g_file_get_path ((GFile *)file);
+
+	if (abs_file_path == NULL)
+	{
+		g_warning ("isymbol_manager_search_file (): GFile has no absolute path");
+		return NULL;
+	}
+	
+	if (match_types & IANJUTA_SYMBOL_TYPE_UNDEF)
+	{
+		filter_array = NULL;
+	}
+	else 
+	{
+		filter_array = symbol_db_util_fill_type_array (match_types);
+	}
+	
+	iterator = 		
+		symbol_db_engine_find_symbol_by_name_pattern_on_file (dbe,
+				    pattern,
+					abs_file_path,
+					filter_array,
+					include_types,
+					results_limit,
+					results_offset,
+					info_fields);
+	
+	g_free (abs_file_path);
+	
+	return IANJUTA_ITERABLE (iterator);
+}
+
+
+guint
+isymbol_manager_search_file_async (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types, 
+				gboolean include_types,  IAnjutaSymbolField info_fields, const gchar *pattern, 
+			 	const GFile *file, gint results_limit, gint results_offset, 
+                GCancellable* cancel, AnjutaAsyncNotify *notify, 
+                IAnjutaSymbolManagerSearchCallback callback, 
+                gpointer callback_user_data, GError **err)
+{
+	SymbolDBSearchCommand *search_command;
+	SymbolDBPlugin *sdb_plugin;
+	SymbolDBEngine *dbe;
+	guint cmd_id;
+
+	/* if the return is 0 then we'll have an error, i.e. no valid command id has 
+	 * been generated
+	 */
+	g_return_val_if_fail (pattern != NULL, 0);
+	g_return_val_if_fail (file != NULL, 0);
+
+	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
+	dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
+
+	/* get an unique cmd_id */
+	cmd_id = get_unique_async_command_id ();
+	
+	/* create a new command */
+	search_command = symbol_db_search_command_new (dbe, CMD_SEARCH_FILE, match_types, 
+				include_types, info_fields, pattern, results_limit, results_offset);
+
+	/* don't forget to set the file too */
+	symbol_db_search_command_set_file (search_command, file);	
+
+	/* be sure that the cmd_id and the callback_user_data stay with us when the 
+	 * data-arrived signal is raised 
+	 */
+	g_object_set_data (G_OBJECT (search_command), "cmd_id",
+	                   GINT_TO_POINTER (cmd_id));
+
+	/* FIXME: why is data checked for NULL on iface layer? It should be able to 
+	 * arrive here == NULL....
+	 */
+	if (callback_user_data != NULL)
+		g_object_set_data (G_OBJECT (search_command), "callback_user_data", 
+	                   callback_user_data);
+
+	/* connect some signals */
+	g_signal_connect (G_OBJECT (search_command), "data-arrived",
+					  G_CALLBACK (on_sdb_search_command_data_arrived),
+					  callback);
+	
+	g_signal_connect (G_OBJECT (search_command), "command-finished",
+					  G_CALLBACK (g_object_unref),
+					  NULL);
+	
+	if (cancel)
+	{
+		g_signal_connect_swapped (G_OBJECT (cancel), "cancelled",
+								  G_CALLBACK (anjuta_command_cancel),
+								  search_command);
+	}
+	
+	if (notify)
+	{
+		g_signal_connect_swapped (G_OBJECT (search_command), "command-finished",
+								  G_CALLBACK (anjuta_async_notify_notify_finished),
+								  notify);
+	}
+	
+	anjuta_command_start (ANJUTA_COMMAND (search_command));	
+
+	return cmd_id;
+}
+
+void
+isymbol_manager_iface_init (IAnjutaSymbolManagerIface *iface)
+{
+	iface->search = isymbol_manager_search;
+	iface->get_members = isymbol_manager_get_members;
+	iface->get_class_parents = isymbol_manager_get_class_parents;
+	iface->get_scope = isymbol_manager_get_scope;
+	iface->get_parent_scope = isymbol_manager_get_parent_scope;
+	iface->get_symbol_more_info = isymbol_manager_get_symbol_more_info;
+	iface->get_symbol_by_id = isymbol_manager_get_symbol_by_id;
+	iface->search_system = isymbol_manager_search_system;
+	iface->search_system_async = isymbol_manager_search_system_async;
+	iface->search_project = isymbol_manager_search_project;
+	iface->search_project_async = isymbol_manager_search_project_async;
+	iface->search_file = isymbol_manager_search_file;
+	iface->search_file_async = isymbol_manager_search_file_async;	
+}

Added: trunk/plugins/symbol-db/symbol-db-iface.h
==============================================================================
--- (empty file)
+++ trunk/plugins/symbol-db/symbol-db-iface.h	Mon Apr 13 10:26:51 2009
@@ -0,0 +1,129 @@
+/*
+ * anjuta
+ * Copyright (C) Massimo Cora' 2007-2009 <maxcvs email it>
+ * 
+ * anjuta is free software.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program 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 Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+#ifndef _SYMBOL_DB_IFACE_H_
+#define _SYMBOL_DB_IFACE_H_
+
+#include <glib-object.h>
+#include <glib.h>
+
+#include <libanjuta/anjuta-async-command.h>
+#include <libanjuta/anjuta-async-notify.h>
+#include <libanjuta/interfaces/ianjuta-iterable.h>
+#include <libanjuta/interfaces/ianjuta-symbol-manager.h>
+
+void
+isymbol_manager_iface_init (IAnjutaSymbolManagerIface *iface);
+
+IAnjutaIterable* 
+isymbol_manager_search_file (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types, 
+				gboolean include_types,  IAnjutaSymbolField info_fields, const gchar *pattern, 
+			 	const GFile *file, gint results_limit, gint results_offset, GError **err);
+
+guint
+isymbol_manager_search_file_async (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types, 
+				gboolean include_types,  IAnjutaSymbolField info_fields, const gchar *pattern, 
+			 	const GFile *file, gint results_limit, gint results_offset, 
+                GCancellable* cancel, AnjutaAsyncNotify *notify, 
+                IAnjutaSymbolManagerSearchCallback callback, 
+				gpointer callback_user_data, GError **err);
+
+IAnjutaIterable* 
+isymbol_manager_search_project (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types, 
+				gboolean include_types,  IAnjutaSymbolField info_fields, const gchar *pattern, 
+				gint results_limit, gint results_offset, GError **err);
+
+guint
+isymbol_manager_search_project_async (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types, 
+				gboolean include_types,  IAnjutaSymbolField info_fields, const gchar *pattern, 
+				gint results_limit, gint results_offset, 
+                GCancellable* cancel, AnjutaAsyncNotify *notify, 
+                IAnjutaSymbolManagerSearchCallback callback, 
+				gpointer callback_user_data, GError **err);
+
+IAnjutaIterable* 
+isymbol_manager_search_system (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types, 
+				gboolean include_types,  IAnjutaSymbolField info_fields, const gchar *pattern, 
+			    gint results_limit, gint results_offset, GError **err);
+
+guint
+isymbol_manager_search_system_async (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types, 
+				gboolean include_types,  IAnjutaSymbolField info_fields, const gchar *pattern, 
+			    gint results_limit, gint results_offset, 
+                GCancellable* cancel, AnjutaAsyncNotify *notify, 
+                IAnjutaSymbolManagerSearchCallback callback, 
+				gpointer callback_user_data, GError **err);
+
+IAnjutaSymbol*
+isymbol_manager_get_symbol_by_id (IAnjutaSymbolManager *sm,
+								  gint symbol_id, 
+								  IAnjutaSymbolField info_fields,
+								  GError **err);
+
+IAnjutaIterable*
+isymbol_manager_get_symbol_more_info (IAnjutaSymbolManager *sm,
+								  const IAnjutaSymbol *symbol, 
+								  IAnjutaSymbolField info_fields,
+								  GError **err);
+
+IAnjutaIterable*
+isymbol_manager_get_parent_scope (IAnjutaSymbolManager *sm,
+								  const IAnjutaSymbol *symbol, 
+								  const gchar *filename, 
+								  IAnjutaSymbolField info_fields,
+								  GError **err);
+
+IAnjutaIterable*
+isymbol_manager_get_scope (IAnjutaSymbolManager *sm,
+						   const gchar* filename,  
+						   gulong line,  
+						   IAnjutaSymbolField info_fields, 
+						   GError **err);
+
+IAnjutaIterable*
+isymbol_manager_get_class_parents (IAnjutaSymbolManager *sm,
+							 const IAnjutaSymbol *symbol,
+							 IAnjutaSymbolField info_fields,
+							 GError **err);
+
+IAnjutaIterable*
+isymbol_manager_get_members (IAnjutaSymbolManager *sm,
+							 const IAnjutaSymbol *symbol, 
+							 IAnjutaSymbolField info_fields,
+							 gboolean global_search,
+							 GError **err);
+
+IAnjutaIterable*
+isymbol_manager_search (IAnjutaSymbolManager *sm,
+						IAnjutaSymbolType match_types,
+						gboolean include_types,
+						IAnjutaSymbolField info_fields,
+						const gchar *match_name,
+						gboolean partial_name_match,
+						gboolean global_symbols_search,
+						gboolean global_tags_search,
+						gint results_limit,
+						gint results_offset,
+						GError **err);
+
+#endif /* _SYMBOL_DB_IFACE_H_ */
+
+

Added: trunk/plugins/symbol-db/symbol-db-search-command.c
==============================================================================
--- (empty file)
+++ trunk/plugins/symbol-db/symbol-db-search-command.c	Mon Apr 13 10:26:51 2009
@@ -0,0 +1,262 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) Massimo Cora' 2009 <maxcvs email it>
+ * 
+ * anjuta is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * anjuta 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 General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "symbol-db-search-command.h"
+
+#include <libanjuta/anjuta-debug.h>
+
+struct _SymbolDBSearchCommandPriv {
+	/* may be set or not. Initial value (at init time) is NULL 
+	 * it shouldn't be freed. */
+	GFile *gfile;	
+
+	/* may be set or not. Initial value (at init time) is NULL 
+	 * it shouldn't be freed. */
+	GList *session_packages;
+
+	SymbolDBEngine *dbe;
+	CmdSearchType cmd_search_type;
+	IAnjutaSymbolType match_types;
+	gboolean include_types;
+	IAnjutaSymbolField info_fields;
+	const gchar *pattern;
+	gint results_limit;
+	gint results_offset;
+	
+
+	/* store the pointer to an iterator. The object does not have to be
+	 * freed 
+	 */
+	SymbolDBEngineIterator *iterator_result;
+};
+
+
+G_DEFINE_TYPE (SymbolDBSearchCommand, sdb_search_command, ANJUTA_TYPE_ASYNC_COMMAND);
+
+static void
+sdb_search_command_init (SymbolDBSearchCommand *object)
+{
+	object->priv = g_new0 (SymbolDBSearchCommandPriv, 1);	
+
+	object->priv->gfile = NULL;
+	object->priv->session_packages = NULL;
+}
+
+static void
+sdb_search_command_finalize (GObject *object)
+{
+	SymbolDBSearchCommand *sdbsc;	
+	sdbsc = SYMBOL_DB_SEARCH_COMMAND (object);
+	
+	g_free (sdbsc->priv);
+	
+	G_OBJECT_CLASS (sdb_search_command_parent_class)->finalize (object);
+}
+
+static SymbolDBEngineIterator *
+do_search_file (SymbolDBSearchCommand *sdbsc)
+{
+	SymbolDBSearchCommandPriv *priv;
+	SymbolDBEngineIterator *iterator;
+	GPtrArray *filter_array;
+	gchar *abs_file_path;	
+
+	priv = sdbsc->priv;
+	
+	abs_file_path = g_file_get_path (priv->gfile);
+
+	if (abs_file_path == NULL)
+	{		
+		return NULL;
+	}
+	
+	if (priv->match_types & IANJUTA_SYMBOL_TYPE_UNDEF)
+	{
+		filter_array = NULL;
+	}
+	else 
+	{
+		filter_array = symbol_db_util_fill_type_array (priv->match_types);
+	}
+	
+	iterator = 
+		symbol_db_engine_find_symbol_by_name_pattern_on_file (priv->dbe,
+				    priv->pattern,
+					abs_file_path,
+					filter_array,
+					priv->include_types,
+					priv->results_limit,
+					priv->results_offset,
+					priv->info_fields);
+	
+	g_free (abs_file_path);	
+
+	return iterator;
+}
+
+static SymbolDBEngineIterator *
+do_search_prj_glb (SymbolDBSearchCommand *sdbsc)
+{
+	SymbolDBEngineIterator *iterator;
+	gboolean exact_match;
+	GPtrArray *filter_array;
+	SymbolDBSearchCommandPriv *priv;
+	
+
+	priv = sdbsc->priv;
+	
+	exact_match = symbol_db_util_is_pattern_exact_match (priv->pattern);
+
+	if (priv->match_types & IANJUTA_SYMBOL_TYPE_UNDEF)
+	{
+		filter_array = NULL;
+	}
+	else 
+	{
+		filter_array = symbol_db_util_fill_type_array (priv->match_types);
+	}
+	
+	iterator = 		
+		symbol_db_engine_find_symbol_by_name_pattern_filtered (priv->dbe,
+					priv->pattern,
+					exact_match,
+					filter_array,
+					priv->include_types,
+					1,
+					priv->session_packages,
+					priv->results_limit,
+					priv->results_offset,
+					priv->info_fields);	
+	
+	return iterator;
+}
+
+/**
+ * Main method that'll run the task assigned with the command.
+ */
+static guint
+sdb_search_command_run (AnjutaCommand *command)
+{
+	SymbolDBSearchCommand *sdbsc;
+	SymbolDBSearchCommandPriv *priv;
+
+	sdbsc = SYMBOL_DB_SEARCH_COMMAND (command);
+
+	priv = sdbsc->priv;
+
+	switch (priv->cmd_search_type)
+	{
+		case CMD_SEARCH_FILE:
+			priv->iterator_result = do_search_file (sdbsc);
+			break;
+
+		case CMD_SEARCH_PROJECT:
+		case CMD_SEARCH_SYSTEM:
+			priv->iterator_result = do_search_prj_glb (sdbsc);
+			break;			
+	}
+
+	if (priv->iterator_result == NULL)
+	{
+		/* 1 is for error occurred */
+		return 1;
+	}
+
+	anjuta_command_notify_data_arrived (command);
+	
+	/* 0 should be for no error */
+	return 0;
+}
+
+static void
+sdb_search_command_class_init (SymbolDBSearchCommandClass *klass)
+{
+	GObjectClass* object_class = G_OBJECT_CLASS (klass);
+	AnjutaCommandClass *command_class = ANJUTA_COMMAND_CLASS (klass);
+	
+	object_class->finalize = sdb_search_command_finalize;
+	command_class->run = sdb_search_command_run;
+}
+
+/**
+ * ctor.
+ */
+SymbolDBSearchCommand* 
+symbol_db_search_command_new (SymbolDBEngine *dbe, CmdSearchType cmd_search_type, 
+                              IAnjutaSymbolType match_types, gboolean include_types,  
+                              IAnjutaSymbolField info_fields, const gchar *pattern, 
+                              gint results_limit, gint results_offset)
+{
+	SymbolDBSearchCommand *sdb_search_cmd;
+	SymbolDBSearchCommandPriv *priv;
+	
+	sdb_search_cmd = g_object_new (SYMBOL_TYPE_DB_SEARCH_COMMAND, NULL);
+
+	priv = sdb_search_cmd->priv;
+
+	/* set some priv data. Nothing should be freed later */
+	priv->cmd_search_type = cmd_search_type;
+	priv->match_types = match_types;
+	priv->include_types = include_types;
+	priv->info_fields = info_fields;
+	priv->pattern = pattern;
+	priv->results_limit = results_limit;
+	priv->results_offset = results_offset;	
+	priv->dbe = dbe;
+	priv->iterator_result = NULL;
+	
+	return sdb_search_cmd;
+}
+
+void
+symbol_db_search_command_set_file (SymbolDBSearchCommand* sdbsc, const GFile *gfile)
+{
+	SymbolDBSearchCommandPriv *priv;
+
+	g_return_if_fail (sdbsc != NULL);
+	g_return_if_fail (gfile != NULL);
+	
+	priv = sdbsc->priv;
+	
+	priv->gfile = (GFile*)gfile;
+}	
+
+void
+symbol_db_search_command_set_session_packages (SymbolDBSearchCommand* sdbsc, 
+                                               const GList *session_packages)
+{
+	SymbolDBSearchCommandPriv *priv;
+
+	g_return_if_fail (sdbsc != NULL);
+	
+	priv = sdbsc->priv;
+	
+	priv->session_packages = (GList*)session_packages;
+}	
+
+SymbolDBEngineIterator *
+symbol_db_search_command_get_iterator_result (SymbolDBSearchCommand* sdbsc)
+{
+	SymbolDBSearchCommandPriv *priv;
+	g_return_val_if_fail (sdbsc != NULL, NULL);
+	
+	priv = sdbsc->priv;
+
+	return priv->iterator_result;
+}

Added: trunk/plugins/symbol-db/symbol-db-search-command.h
==============================================================================
--- (empty file)
+++ trunk/plugins/symbol-db/symbol-db-search-command.h	Mon Apr 13 10:26:51 2009
@@ -0,0 +1,87 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) Massimo Cora' 2009 <maxcvs email it>
+ * 
+ * anjuta is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * anjuta 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 General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _SYMBOL_DB_SEARCH_COMMAND_H_
+#define _SYMBOL_DB_SEARCH_COMMAND_H_
+
+#include <glib-object.h>
+#include <libanjuta/anjuta-async-command.h>
+#include <libanjuta/interfaces/ianjuta-symbol-manager.h>
+
+#include "symbol-db-engine.h"
+
+G_BEGIN_DECLS
+
+#define SYMBOL_TYPE_DB_SEARCH_COMMAND             (sdb_search_command_get_type ())
+#define SYMBOL_DB_SEARCH_COMMAND(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), SYMBOL_TYPE_DB_SEARCH_COMMAND, SymbolDBSearchCommand))
+#define SYMBOL_DB_SEARCH_COMMAND_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), SYMBOL_TYPE_DB_SEARCH_COMMAND, SymbolDBSearchCommandClass))
+#define SYMBOL_IS_DB_SEARCH_COMMAND(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SYMBOL_TYPE_DB_SEARCH_COMMAND))
+#define SYMBOL_IS_DB_SEARCH_COMMAND_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), SYMBOL_TYPE_DB_SEARCH_COMMAND))
+#define SYMBOL_DB_SEARCH_COMMAND_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), SYMBOL_TYPE_DB_SEARCH_COMMAND, SymbolDBSearchCommandClass))
+
+typedef struct _SymbolDBSearchCommandClass SymbolDBSearchCommandClass;
+typedef struct _SymbolDBSearchCommand SymbolDBSearchCommand;
+typedef struct _SymbolDBSearchCommandPriv SymbolDBSearchCommandPriv;
+
+struct _SymbolDBSearchCommandClass
+{
+	AnjutaAsyncCommandClass parent_class;
+};
+
+struct _SymbolDBSearchCommand
+{
+	AnjutaAsyncCommand parent_instance;
+
+	SymbolDBSearchCommandPriv *priv;
+};
+
+typedef enum {
+
+	CMD_SEARCH_FILE,
+	CMD_SEARCH_PROJECT,
+	CMD_SEARCH_SYSTEM
+	
+} CmdSearchType;
+
+GType sdb_search_command_get_type (void) G_GNUC_CONST;
+
+SymbolDBSearchCommand* 
+symbol_db_search_command_new (SymbolDBEngine *dbe, CmdSearchType cmd_search_type, 
+                              IAnjutaSymbolType match_types, gboolean include_types,  
+                              IAnjutaSymbolField info_fields, const gchar *pattern, 
+			 				  gint results_limit, gint results_offset);
+
+/** set a gfile in case of a CMD_SEARCH_FILE command */
+void
+symbol_db_search_command_set_file (SymbolDBSearchCommand* sdbsc, const GFile *gfile);
+
+/** set a GList for session packages. It should be NULL if client wants just a project scan */ 
+void
+symbol_db_search_command_set_session_packages (SymbolDBSearchCommand* sdbsc, 
+                                               const GList *session_packages);
+
+
+/** get result iterator when command is finished */
+SymbolDBEngineIterator *
+symbol_db_search_command_get_iterator_result (SymbolDBSearchCommand* sdbsc);
+
+
+G_END_DECLS
+
+#endif /* _SYMBOL_DB_SEARCH_COMMAND_H_ */

Modified: trunk/plugins/symbol-db/symbol-db-system.c
==============================================================================
--- trunk/plugins/symbol-db/symbol-db-system.c	(original)
+++ trunk/plugins/symbol-db/symbol-db-system.c	Mon Apr 13 10:26:51 2009
@@ -639,8 +639,7 @@
 	ss_data = (SingleScanData *)user_data;
 	sdbs = ss_data->sdbs;
 	priv = sdbs->priv;	
-	
-	DEBUG_PRINT ("");
+		
 	/* first of all disconnect the signals */
 	g_signal_handlers_disconnect_by_func (launcher, on_pkg_config_exit,
 										  user_data);
@@ -681,7 +680,8 @@
 						 g_queue_get_length (priv->engine_queue),
 						 es_data->package_name);
 			g_queue_push_tail (priv->engine_queue, es_data);
-			
+
+/*			
 			gint i;			
 			for (i = 0; i < g_queue_get_length (priv->engine_queue); i++)
 			{
@@ -690,6 +690,7 @@
 				DEBUG_PRINT ("DEBUG queue engine [%d]: %s", i, 
 							 node->package_name);
 			}
+*/		
 		}
 		else
 		{



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