summaryrefslogtreecommitdiff
path: root/src/analysis/loaded.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/loaded.c')
-rw-r--r--src/analysis/loaded.c173
1 files changed, 122 insertions, 51 deletions
diff --git a/src/analysis/loaded.c b/src/analysis/loaded.c
index 10ab05e..3a497f9 100644
--- a/src/analysis/loaded.c
+++ b/src/analysis/loaded.c
@@ -39,11 +39,6 @@
-/* Analyse de contenu chargé (instance) */
-typedef struct _GLoadedAnalysis GLoadedAnalysis;
-
-
-
/* ---------------------- GESTION SOUS FORME DE CONTENU CHARGE ---------------------- */
@@ -59,8 +54,20 @@ typedef struct _analysis_data_t
} analysis_data_t;
-/* Procède à l'initialisation de l'interface de contenu chargé. */
-static void g_loaded_content_default_init(GLoadedContentInterface *);
+/* Initialise la classe des contenus chargés. */
+static void g_loaded_content_class_init(GLoadedContentClass *);
+
+/* Initialise un contenu chargé. */
+static void g_loaded_content_init(GLoadedContent *);
+
+/* Procède à l'initialisation de l'interface de composant nommé. */
+static void g_loaded_content_named_init(GNamedWidgetIface *);
+
+/* Supprime toutes les références externes. */
+static void g_loaded_content_dispose(GLoadedContent *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_loaded_content_finalize(GLoadedContent *);
/* Crée une structure pour accompagner une tâche d'analyse. */
static analysis_data_t *create_analysis_data(GLoadedContent *, bool, bool);
@@ -82,14 +89,15 @@ static void on_loaded_content_analysis_completed(GSeqWork *, analysis_data_t *);
/* Détermine le type d'une interface pour l'intégration de contenu chargé. */
-G_DEFINE_INTERFACE(GLoadedContent, g_loaded_content, G_TYPE_OBJECT);
+G_DEFINE_TYPE_WITH_CODE(GLoadedContent, g_loaded_content, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE(G_TYPE_NAMED_WIDGET, g_loaded_content_named_init));
/******************************************************************************
* *
-* Paramètres : iface = interface GLib à initialiser. *
+* Paramètres : klass = classe à initialiser. *
* *
-* Description : Procède à l'initialisation de l'interface de contenu chargé. *
+* Description : Initialise la classe des contenus chargés. *
* *
* Retour : - *
* *
@@ -97,12 +105,19 @@ G_DEFINE_INTERFACE(GLoadedContent, g_loaded_content, G_TYPE_OBJECT);
* *
******************************************************************************/
-static void g_loaded_content_default_init(GLoadedContentInterface *iface)
+static void g_loaded_content_class_init(GLoadedContentClass *klass)
{
+ GObjectClass *object; /* Autre version de la classe */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_loaded_content_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_loaded_content_finalize;
+
g_signal_new("analyzed",
G_TYPE_LOADED_CONTENT,
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GLoadedContentIface, analyzed),
+ G_STRUCT_OFFSET(GLoadedContentClass, analyzed),
NULL, NULL,
g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
@@ -112,6 +127,24 @@ static void g_loaded_content_default_init(GLoadedContentInterface *iface)
/******************************************************************************
* *
+* Paramètres : content = instance à initialiser. *
+* *
+* Description : Initialise un contenu chargé. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_loaded_content_init(GLoadedContent *content)
+{
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : iface = interface GLib à initialiser. *
* *
* Description : Procède à l'initialisation de l'interface de composant nommé.*
@@ -122,7 +155,7 @@ static void g_loaded_content_default_init(GLoadedContentInterface *iface)
* *
******************************************************************************/
-void g_loaded_content_named_interface_init(GNamedWidgetIface *iface)
+static void g_loaded_content_named_init(GNamedWidgetIface *iface)
{
iface->get_name = (get_named_widget_name_fc)g_loaded_content_describe;
iface->get_widget = (get_named_widget_widget_fc)g_loaded_content_build_default_view;
@@ -132,6 +165,44 @@ void g_loaded_content_named_interface_init(GNamedWidgetIface *iface)
/******************************************************************************
* *
+* Paramètres : content = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_loaded_content_dispose(GLoadedContent *content)
+{
+ G_OBJECT_CLASS(g_loaded_content_parent_class)->dispose(G_OBJECT(content));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : content = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_loaded_content_finalize(GLoadedContent *content)
+{
+ G_OBJECT_CLASS(g_loaded_content_parent_class)->finalize(G_OBJECT(content));
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : content = élément chargé à traiter. *
* xdoc = structure XML en cours d'édition. *
* context = contexte à utiliser pour les recherches. *
@@ -148,12 +219,12 @@ void g_loaded_content_named_interface_init(GNamedWidgetIface *iface)
bool g_loaded_content_restore(GLoadedContent *content, xmlDocPtr xdoc, xmlXPathContextPtr context, const char *path)
{
bool result; /* Bilan à faire remonter */
- GLoadedContentIface *iface; /* Interface utilisée */
+ GLoadedContentClass *class; /* Classe de l'instance */
- iface = G_LOADED_CONTENT_GET_IFACE(content);
+ class = G_LOADED_CONTENT_GET_CLASS(content);
- if (iface->restore != NULL)
- result = iface->restore(content, xdoc, context, path);
+ if (class->restore != NULL)
+ result = class->restore(content, xdoc, context, path);
else
result = true;
@@ -181,12 +252,12 @@ bool g_loaded_content_restore(GLoadedContent *content, xmlDocPtr xdoc, xmlXPathC
bool g_loaded_content_save(GLoadedContent *content, xmlDocPtr xdoc, xmlXPathContextPtr context, const char *path)
{
bool result; /* Bilan à faire remonter */
- GLoadedContentIface *iface; /* Interface utilisée */
+ GLoadedContentClass *class; /* Classe de l'instance */
- iface = G_LOADED_CONTENT_GET_IFACE(content);
+ class = G_LOADED_CONTENT_GET_CLASS(content);
- if (iface->save != NULL)
- result = iface->save(content, xdoc, context, path);
+ if (class->save != NULL)
+ result = class->save(content, xdoc, context, path);
else
result = true;
@@ -211,11 +282,11 @@ bool g_loaded_content_save(GLoadedContent *content, xmlDocPtr xdoc, xmlXPathCont
GBinContent *g_loaded_content_get_content(const GLoadedContent *content)
{
GBinContent *result; /* Contenu interne à renvoyer */
- GLoadedContentIface *iface; /* Interface utilisée */
+ GLoadedContentClass *class; /* Classe de l'instance */
- iface = G_LOADED_CONTENT_GET_IFACE(content);
+ class = G_LOADED_CONTENT_GET_CLASS(content);
- result = iface->get_content(content);
+ result = class->get_content(content);
return result;
@@ -237,11 +308,11 @@ GBinContent *g_loaded_content_get_content(const GLoadedContent *content)
char *g_loaded_content_get_format_name(const GLoadedContent *content)
{
char *result; /* Contenu interne à renvoyer */
- GLoadedContentIface *iface; /* Interface utilisée */
+ GLoadedContentClass *class; /* Classe de l'instance */
- iface = G_LOADED_CONTENT_GET_IFACE(content);
+ class = G_LOADED_CONTENT_GET_CLASS(content);
- result = iface->get_format_name(content);
+ result = class->get_format_name(content);
return result;
@@ -298,17 +369,17 @@ static analysis_data_t *create_analysis_data(GLoadedContent *content, bool conne
static bool process_analysis_with_data(analysis_data_t *data, size_t i, GtkStatusStack *status, activity_id_t id)
{
- GLoadedContentIface *iface; /* Interface utilisée */
+ GLoadedContentClass *class; /* Classe de l'instance */
GWorkQueue *queue; /* Gestionnaire de différés */
wgroup_id_t gid; /* Identifiant pour les tâches */
- iface = G_LOADED_CONTENT_GET_IFACE(data->content);
+ class = G_LOADED_CONTENT_GET_CLASS(data->content);
queue = get_work_queue();
gid = g_work_queue_define_work_group(queue);
- data->success = iface->analyze(data->content, data->connect, data->cache, gid, status);
+ data->success = class->analyze(data->content, data->connect, data->cache, gid, status);
if (data->success)
handle_loaded_content(PGA_CONTENT_ANALYZED, data->content, gid, status);
@@ -460,11 +531,11 @@ bool g_loaded_content_analyze_and_wait(GLoadedContent *content, bool connect, bo
char *g_loaded_content_describe(const GLoadedContent *content, bool full)
{
char *result; /* Description à retourner */
- GLoadedContentIface *iface; /* Interface utilisée */
+ GLoadedContentClass *class; /* Classe de l'instance */
- iface = G_LOADED_CONTENT_GET_IFACE(content);
+ class = G_LOADED_CONTENT_GET_CLASS(content);
- result = iface->describe(content, full);
+ result = class->describe(content, full);
return result;
@@ -520,11 +591,11 @@ char **g_loaded_content_detect_obfuscators(const GLoadedContent *content, bool v
unsigned int g_loaded_content_count_views(const GLoadedContent *content)
{
unsigned int result; /* Quantité de vues à renvoyer */
- GLoadedContentIface *iface; /* Interface utilisée */
+ GLoadedContentClass *class; /* Classe de l'instance */
- iface = G_LOADED_CONTENT_GET_IFACE(content);
+ class = G_LOADED_CONTENT_GET_CLASS(content);
- result = iface->count_views(content);
+ result = class->count_views(content);
return result;
@@ -547,13 +618,13 @@ unsigned int g_loaded_content_count_views(const GLoadedContent *content)
char *g_loaded_content_get_view_name(const GLoadedContent *content, unsigned int index)
{
char *result; /* Désignation à retourner */
- GLoadedContentIface *iface; /* Interface utilisée */
+ GLoadedContentClass *class; /* Classe de l'instance */
- iface = G_LOADED_CONTENT_GET_IFACE(content);
+ class = G_LOADED_CONTENT_GET_CLASS(content);
assert(index <= g_loaded_content_count_views(content));
- result = iface->get_view_name(content, index);
+ result = class->get_view_name(content, index);
return result;
@@ -575,11 +646,11 @@ char *g_loaded_content_get_view_name(const GLoadedContent *content, unsigned int
GtkWidget *g_loaded_content_build_default_view(GLoadedContent *content)
{
GtkWidget *result; /* Support à retourner */
- GLoadedContentIface *iface; /* Interface utilisée */
+ GLoadedContentClass *class; /* Classe de l'instance */
- iface = G_LOADED_CONTENT_GET_IFACE(content);
+ class = G_LOADED_CONTENT_GET_CLASS(content);
- result = iface->build_def_view(content);
+ result = class->build_def_view(content);
return result;
@@ -602,13 +673,13 @@ GtkWidget *g_loaded_content_build_default_view(GLoadedContent *content)
GtkWidget *g_loaded_content_build_view(GLoadedContent *content, unsigned int index)
{
GtkWidget *result; /* Support à retourner */
- GLoadedContentIface *iface; /* Interface utilisée */
+ GLoadedContentClass *class; /* Classe de l'instance */
- iface = G_LOADED_CONTENT_GET_IFACE(content);
+ class = G_LOADED_CONTENT_GET_CLASS(content);
assert(index <= g_loaded_content_count_views(content));
- result = iface->build_view(content, index);
+ result = class->build_view(content, index);
return result;
@@ -631,11 +702,11 @@ GtkWidget *g_loaded_content_build_view(GLoadedContent *content, unsigned int ind
unsigned int g_loaded_content_get_view_index(GLoadedContent *content, GtkWidget *view)
{
unsigned int result; /* Indice à retourner */
- GLoadedContentIface *iface; /* Interface utilisée */
+ GLoadedContentClass *class; /* Classe de l'instance */
- iface = G_LOADED_CONTENT_GET_IFACE(content);
+ class = G_LOADED_CONTENT_GET_CLASS(content);
- result = iface->get_view_index(content, view);
+ result = class->get_view_index(content, view);
assert(result == -1 || result <= g_loaded_content_count_views(content));
@@ -660,13 +731,13 @@ unsigned int g_loaded_content_get_view_index(GLoadedContent *content, GtkWidget
GDisplayOptions *g_loaded_content_get_display_options(const GLoadedContent *content, unsigned int index)
{
GDisplayOptions *result; /* Accès aux options à renvoyer*/
- GLoadedContentIface *iface; /* Interface utilisée */
+ GLoadedContentClass *class; /* Classe de l'instance */
assert(index <= g_loaded_content_count_views(content));
- iface = G_LOADED_CONTENT_GET_IFACE(content);
+ class = G_LOADED_CONTENT_GET_CLASS(content);
- result = iface->get_options(content, index);
+ result = class->get_options(content, index);
return result;