diff options
Diffstat (limited to 'src/analysis/project.c')
-rw-r--r-- | src/analysis/project.c | 361 |
1 files changed, 4 insertions, 357 deletions
diff --git a/src/analysis/project.c b/src/analysis/project.c index 99ec908..88e90ea 100644 --- a/src/analysis/project.c +++ b/src/analysis/project.c @@ -33,8 +33,8 @@ #include <i18n.h> +#include "loading.h" #include "../common/xml.h" -#include "../core/formats.h" #include "../core/params.h" #include "../glibext/signal.h" #include "../gtkext/easygtk.h" @@ -44,6 +44,7 @@ #include "../gui/core/panels.h" #include "../gui/panels/log.h" #include "../gui/panels/panel.h" +#include "../format/format.h" @@ -103,12 +104,6 @@ static void g_study_project_class_init(GStudyProjectClass *); /*Initialise une instance de projet d'étude. */ static void g_study_project_init(GStudyProject *); -/* Acquitte la fin d'un chargement différé et complet. */ -static void ack_loaded_binary_with_content(GBinaryLoader *, GStudyProject *); - -/* Acquitte la fin d'un chargement différé et complet. */ -static void ack_loaded_binary(GBinaryLoader *, GStudyProject *); - /* Supprime de l'écran un projet en place. */ static void g_study_project_hide(const GStudyProject *); @@ -122,47 +117,6 @@ GPanelItem *_setup_new_panel_item_for_binary(GStudyProject *, GLoadedBinary *, B -/* ----------------------- AMORCE POUR CHARGEMENT DE CONTENUS ----------------------- */ - - -/* Ensembles binaires à désassembler (instance) */ -struct _GDelayedStudy -{ - GDelayedWork parent; /* A laisser en premier */ - - GStudyProject *project; /* Projet de rattachement */ - GBinContent *content; /* Contenu binaire à traiter */ - ProjectContentState state; /* Renseigne le type de contenu*/ - - bool only_preload; /* Enregistrement seulement ? */ - -}; - -/* Ensembles binaires à désassembler (classe) */ -struct _GDelayedStudyClass -{ - GDelayedWorkClass parent; /* A laisser en premier */ - -}; - - -/* Initialise la classe des intégrations de binaires à étudier. */ -static void g_delayed_study_class_init(GDelayedStudyClass *); - -/* Initialise une intégration de binaire à étudier. */ -static void g_delayed_study_init(GDelayedStudy *); - -/* Supprime toutes les références externes. */ -static void g_delayed_study_dispose(GDelayedStudy *); - -/* Procède à la libération totale de la mémoire. */ -static void g_delayed_study_finalize(GDelayedStudy *); - -/* Prépare une intégration de binaire au projet courant. */ -static void g_delayed_study_process(GDelayedStudy *, GtkStatusStack *); - - - /* ---------------------------------------------------------------------------------- */ /* DEFINITION D'UN PROJET INTERNE */ /* ---------------------------------------------------------------------------------- */ @@ -355,8 +309,6 @@ GStudyProject *g_study_project_open(GObject *ref, const char *filename) free(access); - g_signal_connect(loader, "work-completed", G_CALLBACK(ack_loaded_binary), result); - queue = get_work_queue(); g_work_queue_schedule_work(queue, G_DELAYED_WORK(loader), DEFAULT_WORK_GROUP); @@ -568,47 +520,7 @@ GBinContent *g_study_project_find_binary_content_by_hash(GStudyProject *project, * * ******************************************************************************/ -static void ack_loaded_binary_with_content(GBinaryLoader *loader, GStudyProject *project) -{ - GLoadedBinary *binary; /* Binaire désormais en place */ - GExeFormat *format; /* Format de données reconnu */ - GBinContent *content; /* Contenu binaire d'origine */ - - binary = g_binary_loader_get_result(loader); - - if (binary != NULL) - { - format = g_loaded_binary_get_format(binary); - content = g_binary_format_get_content(G_BIN_FORMAT(format)); - - g_study_project_add_binary_content(project, content, PCS_ROOT/* FIXME : dstudy->state*/); - - g_object_unref(G_OBJECT(content)); - g_object_unref(G_OBJECT(format)); - - ack_loaded_binary(loader, project); - - g_object_unref(G_OBJECT(binary)); - - } - -} - - -/****************************************************************************** -* * -* Paramètres : loader = travail de chargement mené à bien. * -* project = lieu d'intégration des résultats obtenus. * -* * -* Description : Acquitte la fin d'un chargement différé et complet. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void ack_loaded_binary(GBinaryLoader *loader, GStudyProject *project) +void ack_loaded_binary(GBinaryLoader *loader, GStudyProject *project) { GLoadedBinary *binary; /* Binaire désormais en place */ @@ -642,6 +554,7 @@ static void ack_loaded_binary(GBinaryLoader *loader, GStudyProject *project) void g_study_project_add_loaded_binary(GLoadedBinary *binary, GStudyProject *project) { + /* FIXME : remplacer cette fonction par un "swap" */ g_study_project_attach_binary(project, binary); } @@ -1223,269 +1136,3 @@ void push_project_into_recent_list(const GStudyProject *project) g_generic_config_set_value(get_main_configuration(), MPK_LAST_PROJECT, project->filename); } - - - -/* ---------------------------------------------------------------------------------- */ -/* AMORCE POUR CHARGEMENT DE CONTENUS */ -/* ---------------------------------------------------------------------------------- */ - - -/* Indique le type défini pour les tâches de préparations d'étude. */ -G_DEFINE_TYPE(GDelayedStudy, g_delayed_study, G_TYPE_DELAYED_WORK); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des intégrations de binaires à étudier. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_delayed_study_class_init(GDelayedStudyClass *klass) -{ - GObjectClass *object; /* Autre version de la classe */ - GDelayedWorkClass *work; /* Version en classe parente */ - - object = G_OBJECT_CLASS(klass); - work = G_DELAYED_WORK_CLASS(klass); - - object->dispose = (GObjectFinalizeFunc/* ! */)g_delayed_study_dispose; - object->finalize = (GObjectFinalizeFunc)g_delayed_study_finalize; - - work->run = (run_task_fc)g_delayed_study_process; - -} - - -/****************************************************************************** -* * -* Paramètres : dstudy = instance à initialiser. * -* * -* Description : Initialise une intégration de binaire à étudier. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_delayed_study_init(GDelayedStudy *dstudy) -{ - dstudy->only_preload = false; - -} - - -/****************************************************************************** -* * -* Paramètres : binary = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_delayed_study_dispose(GDelayedStudy *dstudy) -{ - g_object_unref(G_OBJECT(dstudy->project)); - g_object_unref(G_OBJECT(dstudy->content)); - - G_OBJECT_CLASS(g_delayed_study_parent_class)->dispose(G_OBJECT(dstudy)); - -} - - -/****************************************************************************** -* * -* Paramètres : binary = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_delayed_study_finalize(GDelayedStudy *dstudy) -{ - G_OBJECT_CLASS(g_delayed_study_parent_class)->finalize(G_OBJECT(dstudy)); - -} - - -/****************************************************************************** -* * -* Paramètres : project = projet dont le contenu est à compléter. * -* content = contenu binaire chargé à analyser. * -* state = état du contenu à conserver. * -* * -* Description : Crée une tâche d'intégration de contenu binaire. * -* * -* Retour : Tâche créée. * -* * -* Remarques : L'appelant perd la propriété du contenu. * -* * -******************************************************************************/ - -GDelayedStudy *g_delayed_study_new(GStudyProject *project, GBinContent *content, ProjectContentState state) -{ - GDelayedStudy *result; /* Tâche à retourner */ - - result = g_object_new(G_TYPE_DELAYED_STUDY, NULL); - - g_object_ref(G_OBJECT(project)); - result->project = project; - - g_object_ref(G_OBJECT(content)); - result->content = content; - - result->state = state; - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : dstudy = intégration à mener. * -* status = barre de statut à tenir informée. * -* * -* Description : Prépare une intégration de binaire au projet courant. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_delayed_study_process(GDelayedStudy *dstudy, GtkStatusStack *status) -{ - FormatMatchStatus mstatus; /* Statut d'une reconnaissance */ - char *target; /* Sous-traitance requise */ - GBinaryLoader *loader; /* Dispositif de chargement */ - GWorkQueue *queue; /* Gestionnaire de différés */ - - mstatus = find_matching_format(dstudy->content, NULL, &target); - - switch (mstatus) - { - case FMS_MATCHED: - - if (dstudy->only_preload) - g_study_project_add_binary_content(dstudy->project, dstudy->content, dstudy->state); - - else - { - loader = g_binary_loader_new(dstudy->content); - - g_signal_connect(loader, "work-completed", G_CALLBACK(ack_loaded_binary_with_content), - dstudy->project); - - queue = get_work_queue(); - g_work_queue_schedule_work(queue, G_DELAYED_WORK(loader), DEFAULT_WORK_GROUP); - - } - - break; - - case FMS_FORWARDED: - /** - * L'émetteur de ce type de réponse a pour charge de - * reprogrammer lui même l'analyse de nouveaux contenus. - */ - log_variadic_message(LMT_PROCESS, _("binary '%s' contains other binaries..."), - g_binary_content_describe(dstudy->content, true)); - - if (dstudy->state == PCS_ROOT) - g_study_project_add_binary_content(dstudy->project, dstudy->content, PCS_ROOT); - - break; - - default: - /** - * Les jeux sont faits pour le contenu binaire courant. - */ - log_variadic_message(LMT_PROCESS, _("Unknown binary format for '%s'..."), - g_binary_content_describe(dstudy->content, true)); - break; - - } - -} - - -/****************************************************************************** -* * -* Paramètres : dstudy = tâche d'analyse de contenu pour projet à mener. * -* * -* Description : Limite l'étude et l'intégration d'un contenu binaire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_delayed_study_preload_only(GDelayedStudy *dstudy) -{ - dstudy->only_preload = true; - -} - - -/****************************************************************************** -* * -* Paramètres : content = contenu binaire chargé à analyser. * -* state = état du contenu à conserver. * -* * -* Description : Programme l'étude et l'intégration d'un contenu binaire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void qck_study_new_content(GBinContent *content, ProjectContentState state) -{ - GDelayedStudy *dstudy; /* Etude à conduire */ - - dstudy = g_delayed_study_new(get_current_project(), content, state); - - study_new_content(dstudy); - -} - - -/****************************************************************************** -* * -* Paramètres : content = contenu binaire chargé à analyser. * -* state = état du contenu à conserver. * -* * -* Description : Programme l'étude et l'intégration d'un contenu binaire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void study_new_content(GDelayedStudy *dstudy) -{ - GWorkQueue *queue; /* Gestionnaire de différés */ - - queue = get_work_queue(); - g_work_queue_schedule_work(queue, G_DELAYED_WORK(dstudy), DEFAULT_WORK_GROUP); - -} |