summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/project.c69
-rw-r--r--src/analysis/project.h8
2 files changed, 63 insertions, 14 deletions
diff --git a/src/analysis/project.c b/src/analysis/project.c
index e01a126..8474610 100644
--- a/src/analysis/project.c
+++ b/src/analysis/project.c
@@ -38,6 +38,7 @@
#include "../core/logs.h"
#include "../core/params.h"
#include "../core/queue.h"
+#include "../glibext/chrysamarshal.h"
#include "../glibext/delayed-int.h"
@@ -66,6 +67,7 @@ struct _GStudyProjectClass
/* Signaux */
+ void (* contents_available) (GStudyProject, GLoadedContent **, guint);
void (* content_added) (GStudyProject *, GLoadedContent *);
void (* content_removed) (GStudyProject *, GLoadedContent *);
@@ -92,9 +94,6 @@ static void g_study_project_finalize(GStudyProject *);
/* Assure l'intégration de contenus listés dans du XML. */
static void g_study_project_recover_binary_contents(GStudyProject *, xmlDoc *, xmlXPathContext *);
-/* Réceptionne la recette d'une analyse de contenu. */
-static void on_loaded_content_analyzed(GLoadedContent *, gboolean, GStudyProject *);
-
/* ------------------------ CHARGEMENTS DE CONTENUS BINAIRES ------------------------ */
@@ -124,6 +123,9 @@ typedef struct _GLoadingHandler
GCond wait_cond; /* Réveil d'attente de fin */
GMutex mutex; /* Encadrement des accès */
+ filter_loadable_cb filter; /* Filtre des contenus ? */
+ void *data; /* Données utiles au filtrage */
+
} GLoadingHandler;
/* Chargement de contenus binaires (classe) */
@@ -150,7 +152,7 @@ static void g_loading_handler_dispose(GLoadingHandler *);
static void g_loading_handler_finalize(GLoadingHandler *);
/* Crée une tâche de chargement de contenu bianire. */
-static GLoadingHandler *g_loading_handler_new_discovering(GStudyProject *, GBinContent *);
+static GLoadingHandler *g_loading_handler_new_discovering(GStudyProject *, GBinContent *, filter_loadable_cb, void *);
/* Crée une tâche de chargement de contenu bianire. */
static GLoadingHandler *g_loading_handler_new_recovering(GStudyProject *, xmlDoc *, xmlXPathContext *);
@@ -199,6 +201,14 @@ static void g_study_project_class_init(GStudyProjectClass *klass)
object->dispose = (GObjectFinalizeFunc/* ! */)g_study_project_dispose;
object->finalize = (GObjectFinalizeFunc)g_study_project_finalize;
+ g_signal_new("contents-available",
+ G_TYPE_STUDY_PROJECT,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(GStudyProjectClass, contents_available),
+ NULL, NULL,
+ g_cclosure_user_marshal_VOID__POINTER_UINT,
+ G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT);
+
g_signal_new("content-added",
G_TYPE_STUDY_PROJECT,
G_SIGNAL_RUN_LAST,
@@ -545,6 +555,8 @@ static void g_study_project_recover_binary_contents(GStudyProject *project, xmlD
* *
* Paramètres : project = projet dont le contenu est à compléter. *
* content = contenu binaire à mémoriser pour le projet. *
+* filter = procédure de filtrage de contenus chargés. *
+* data = données utiles à la procédure de filtre. *
* *
* Description : Assure l'intégration de contenus binaires dans un projet. *
* *
@@ -554,11 +566,11 @@ static void g_study_project_recover_binary_contents(GStudyProject *project, xmlD
* *
******************************************************************************/
-void g_study_project_discover_binary_content(GStudyProject *project, GBinContent *content)
+void g_study_project_discover_binary_content(GStudyProject *project, GBinContent *content, filter_loadable_cb filter, void *data)
{
GLoadingHandler *handler; /* Encadrement du chargement */
- handler = g_loading_handler_new_discovering(project, content);
+ handler = g_loading_handler_new_discovering(project, content, filter, data);
g_work_queue_schedule_work(get_work_queue(), G_DELAYED_WORK(handler), LOADING_WORK_GROUP);
@@ -579,7 +591,7 @@ void g_study_project_discover_binary_content(GStudyProject *project, GBinContent
* *
******************************************************************************/
-static void on_loaded_content_analyzed(GLoadedContent *content, gboolean success, GStudyProject *project)
+void on_loaded_content_analyzed(GLoadedContent *content, gboolean success, GStudyProject *project)
{
const char *desc; /* Description du contenu */
@@ -908,6 +920,8 @@ static void g_loading_handler_finalize(GLoadingHandler *handler)
* *
* Paramètres : project = projet dont le contenu est à compléter. *
* content = contenu binaire à mémoriser pour le projet. *
+* filter = procédure de filtrage de contenus chargés. *
+* data = données utiles à la procédure de filtre. *
* *
* Description : Crée une tâche de chargement de contenu bianire. *
* *
@@ -917,7 +931,7 @@ static void g_loading_handler_finalize(GLoadingHandler *handler)
* *
******************************************************************************/
-static GLoadingHandler *g_loading_handler_new_discovering(GStudyProject *project, GBinContent *content)
+static GLoadingHandler *g_loading_handler_new_discovering(GStudyProject *project, GBinContent *content, filter_loadable_cb filter, void *data)
{
GLoadingHandler *result; /* Tâche à retourner */
GContentExplorer *explorer; /* Explorateur de contenus */
@@ -935,6 +949,9 @@ static GLoadingHandler *g_loading_handler_new_discovering(GStudyProject *project
result->resolved = 0;
+ result->filter = filter;
+ result->data = data;
+
explorer = get_current_content_explorer();
g_mutex_lock(&result->mutex);
@@ -993,6 +1010,9 @@ static GLoadingHandler *g_loading_handler_new_recovering(GStudyProject *project,
result->resolved = 0;
+ result->filter = NULL;
+ result->data = NULL;
+
explorer = get_current_content_explorer();
explored = 0;
@@ -1211,6 +1231,7 @@ static void on_new_content_resolved(GContentResolver *resolver, wgroup_id_t wid,
{
GLoadedContent **available; /* Contenus chargés valables */
size_t count; /* Quantité de ces contenus */
+ bool keep; /* Conservation finale de liste*/
size_t i; /* Boucle de parcours */
GBinContent *content; /* Contenu brut à manipuler */
const gchar *hash; /* Empreinte d'un contenu */
@@ -1223,6 +1244,8 @@ static void on_new_content_resolved(GContentResolver *resolver, wgroup_id_t wid,
{
available = g_content_resolver_get_all(resolver, wid, &count);
+ keep = false;
+
/* Rechargement à partir d'XML ? */
if (handler->xdoc != NULL)
{
@@ -1295,19 +1318,39 @@ static void on_new_content_resolved(GContentResolver *resolver, wgroup_id_t wid,
*/
g_object_ref(G_OBJECT(available[i]));
- g_signal_connect(available[i], "analyzed",
- G_CALLBACK(on_loaded_content_analyzed), handler->project);
+ }
- g_loaded_content_analyze(available[i]);
+ if (is_batch_mode())
+ {
+ for (i = 0; i < count; i++)
+ {
+ if (handler->filter == NULL || handler->filter(available[i], handler->data))
+ {
+ g_signal_connect(available[i], "analyzed",
+ G_CALLBACK(on_loaded_content_analyzed), handler->project);
- g_object_unref(G_OBJECT(available[i]));
+ g_loaded_content_analyze(available[i]);
+
+ }
+
+ g_object_unref(G_OBJECT(available[i]));
+
+ }
+
+ }
+
+ else
+ {
+ g_signal_emit_by_name(handler->project, "contents-available", available, count);
+
+ keep = true;
}
}
/* Dans tous les cas... */
- if (available != NULL)
+ if (available != NULL && !keep)
free(available);
/* Si c'était la dernière résolution... */
diff --git a/src/analysis/project.h b/src/analysis/project.h
index c634fb2..9b42a47 100644
--- a/src/analysis/project.h
+++ b/src/analysis/project.h
@@ -74,8 +74,14 @@ const char *g_study_project_get_filename(const GStudyProject *);
/* ------------------------ INTEGRATION DE CONTENUS BINAIRES ------------------------ */
+/* Filtre sur les contenus chargeables */
+typedef bool (* filter_loadable_cb) (GLoadedContent *, void *);
+
/* Assure l'intégration de contenus binaires dans un projet. */
-void g_study_project_discover_binary_content(GStudyProject *, GBinContent *);
+void g_study_project_discover_binary_content(GStudyProject *, GBinContent *, filter_loadable_cb, void *);
+
+/* Réceptionne la recette d'une analyse de contenu. */
+void on_loaded_content_analyzed(GLoadedContent *, gboolean, GStudyProject *);
#define g_study_project_lock_contents(p) \
_g_study_project_lock_unlock_contents(p, true)