diff options
Diffstat (limited to 'plugins/pychrysalide')
-rw-r--r-- | plugins/pychrysalide/gui/Makefile.am | 3 | ||||
-rw-r--r-- | plugins/pychrysalide/gui/core/Makefile.am | 19 | ||||
-rw-r--r-- | plugins/pychrysalide/gui/core/items.c | 284 | ||||
-rw-r--r-- | plugins/pychrysalide/gui/core/items.h | 42 | ||||
-rw-r--r-- | plugins/pychrysalide/gui/core/module.c | 97 | ||||
-rw-r--r-- | plugins/pychrysalide/gui/core/module.h | 42 | ||||
-rw-r--r-- | plugins/pychrysalide/gui/module.c | 3 |
7 files changed, 489 insertions, 1 deletions
diff --git a/plugins/pychrysalide/gui/Makefile.am b/plugins/pychrysalide/gui/Makefile.am index 5a604de..2579887 100644 --- a/plugins/pychrysalide/gui/Makefile.am +++ b/plugins/pychrysalide/gui/Makefile.am @@ -6,6 +6,7 @@ libpychrysagui_la_SOURCES = \ module.h module.c libpychrysagui_la_LIBADD = \ + core/libpychrysaguicore.la \ panels/libpychrysaguipanels.la libpychrysagui_la_LDFLAGS = @@ -21,4 +22,4 @@ AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJE AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) -SUBDIRS = panels +SUBDIRS = core panels diff --git a/plugins/pychrysalide/gui/core/Makefile.am b/plugins/pychrysalide/gui/core/Makefile.am new file mode 100644 index 0000000..08e50f1 --- /dev/null +++ b/plugins/pychrysalide/gui/core/Makefile.am @@ -0,0 +1,19 @@ + +noinst_LTLIBRARIES = libpychrysaguicore.la + +libpychrysaguicore_la_SOURCES = \ + items.h items.c \ + module.h module.c + +libpychrysaguicore_la_LDFLAGS = + + +devdir = $(includedir)/chrysalide-$(subdir) + +dev_HEADERS = $(libpychrysaguicore_la_SOURCES:%c=) + + +AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \ + -I$(top_srcdir)/src + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) diff --git a/plugins/pychrysalide/gui/core/items.c b/plugins/pychrysalide/gui/core/items.c new file mode 100644 index 0000000..82c2c1c --- /dev/null +++ b/plugins/pychrysalide/gui/core/items.c @@ -0,0 +1,284 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * items.c - équivalent Python du fichier "gui/core/items.c" + * + * Copyright (C) 2018 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide 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. + * + * Chrysalide 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "items.h" + + +#include <pygobject.h> + + +#include <gui/core/items.h> + + +#include "../../access.h" +#include "../../helpers.h" +#include "../../analysis/loaded.h" +#include "../../analysis/project.h" +#include "../../glibext/loadedpanel.h" + + + +/* Lance une actualisation du fait d'un changement de contenu. */ +static PyObject *py_items_change_current_content(PyObject *, PyObject *); + +/* Lance une actualisation du fait d'un changement de vue. */ +static PyObject *py_items_change_current_view(PyObject *, PyObject *); + +/* Lance une actualisation du fait d'un changement de contenu. */ +static PyObject *py_items_update_current_view(PyObject *, PyObject *); + +/* Lance une actualisation relative à l'étendue du projet. */ +static PyObject *py_items_update_project(PyObject *, PyObject *); + + + +/****************************************************************************** +* * +* Paramètres : self = classe représentant un binaire. * +* args = arguments fournis à l'appel. * +* * +* Description : Lance une actualisation du fait d'un changement de contenu. * +* * +* Retour : None. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_items_change_current_content(PyObject *self, PyObject *args) +{ + PyObject *content_obj; /* Objet pour le contenu */ + int ret; /* Bilan de lecture des args. */ + GLoadedContent *content; /* Instance GLib correspondante*/ + + ret = PyArg_ParseTuple(args, "O!", get_python_loaded_content_type(), &content_obj); + if (!ret) return NULL; + + content = G_LOADED_CONTENT(pygobject_get(content_obj)); + + change_editor_items_current_content(content); + + Py_RETURN_NONE; + +} + + +/****************************************************************************** +* * +* Paramètres : self = classe représentant un binaire. * +* args = arguments fournis à l'appel. * +* * +* Description : Lance une actualisation du fait d'un changement de vue. * +* * +* Retour : None. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_items_change_current_view(PyObject *self, PyObject *args) +{ + PyObject *panel_obj; /* Objet de panneau chargé */ + int ret; /* Bilan de lecture des args. */ + GLoadedPanel *panel; /* Instance GLib correspondante*/ + + ret = PyArg_ParseTuple(args, "O!", get_python_loaded_panel_type(), &panel_obj); + if (!ret) return NULL; + + panel = G_LOADED_PANEL(pygobject_get(panel_obj)); + + change_editor_items_current_view(panel); + + Py_RETURN_NONE; + +} + + +/****************************************************************************** +* * +* Paramètres : self = classe représentant un binaire. * +* args = arguments fournis à l'appel. * +* * +* Description : Lance une actualisation du fait d'un changement de contenu. * +* * +* Retour : None. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_items_update_current_view(PyObject *self, PyObject *args) +{ + PyObject *panel_obj; /* Objet de panneau chargé */ + int ret; /* Bilan de lecture des args. */ + GLoadedPanel *panel; /* Instance GLib correspondante*/ + + ret = PyArg_ParseTuple(args, "O!", get_python_loaded_panel_type(), &panel_obj); + if (!ret) return NULL; + + panel = G_LOADED_PANEL(pygobject_get(panel_obj)); + + update_editor_items_current_view(panel); + + Py_RETURN_NONE; + +} + + + + +/****************************************************************************** +* * +* Paramètres : self = classe représentant un binaire. * +* args = arguments fournis à l'appel. * +* * +* Description : Lance une actualisation relative à l'étendue du projet. * +* * +* Retour : None. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_items_update_project(PyObject *self, PyObject *args) +{ + PyObject *project_obj; /* Objet de panneau chargé */ + int ret; /* Bilan de lecture des args. */ + GStudyProject *project; /* Instance GLib correspondante*/ + + ret = PyArg_ParseTuple(args, "O!", get_python_study_project_type(), &project_obj); + if (!ret) return NULL; + + project = G_STUDY_PROJECT(pygobject_get(project_obj)); + + update_project_area(project); + + Py_RETURN_NONE; + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Fournit un accès à une définition de type à diffuser. * +* * +* Retour : Définition d'objet pour Python. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyTypeObject *get_python_items_type(void) +{ + static PyMethodDef py_items_methods[] = { + { + "change_current_content", py_items_change_current_content, + METH_VARARGS | METH_STATIC, + "change_current_content($self, content/)\n--\n\nChange the current loaded content in the GUI." + }, + { + "change_current_view", py_items_change_current_view, + METH_VARARGS | METH_STATIC, + "change_current_view($self, view/)\n--\n\nChange the current view in the GUI." + }, + { + "update_current_view", py_items_update_current_view, + METH_VARARGS | METH_STATIC, + "update_current_view($self, view/)\n--\n\nUpdate the current view in the GUI." + }, + { + "update_project", py_items_update_project, + METH_VARARGS | METH_STATIC, + "update_project($self, view/)\n--\n\nUpdate the GUI for the current project." + }, + { NULL } + }; + + static PyGetSetDef py_items_getseters[] = { + { NULL } + }; + + static PyTypeObject py_items_type = { + + PyVarObject_HEAD_INIT(NULL, 0) + + .tp_name = "pychrysalide.gui.core.items", + .tp_basicsize = sizeof(PyObject), + + .tp_flags = Py_TPFLAGS_DEFAULT, + + .tp_doc = "Dealing with items of the GUI.", + + .tp_methods = py_items_methods, + .tp_getset = py_items_getseters + + }; + + return &py_items_type; + +} + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Prend en charge l'objet 'pychrysalide.gui.core.items'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool ensure_python_items_is_registered(void) +{ + PyTypeObject *type; /* Type Python de 'items' */ + PyObject *module; /* Module à recompléter */ + int ret; /* Bilan d'un appel */ + + type = get_python_items_type(); + + if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) + { + type->tp_new = PyType_GenericNew; + + if (PyType_Ready(type) != 0) + return false; + + module = get_access_to_python_module("pychrysalide.gui.core"); + + Py_INCREF(type); + ret = PyModule_AddObject(module, "items", (PyObject *)type); + + if (ret != 0) + return false; + + } + + return true; + +} diff --git a/plugins/pychrysalide/gui/core/items.h b/plugins/pychrysalide/gui/core/items.h new file mode 100644 index 0000000..1e73263 --- /dev/null +++ b/plugins/pychrysalide/gui/core/items.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * items.h - prototypes pour l'équivalent Python du fichier "gui/core/items.h" + * + * Copyright (C) 2018 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide 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. + * + * Chrysalide 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _PLUGINS_PYCHRYSALIDE_GUI_CORE_ITEMS_H +#define _PLUGINS_PYCHRYSALIDE_GUI_CORE_ITEMS_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Fournit un accès à une définition de type à diffuser. */ +PyTypeObject *get_python_items_type(void); + +/* Prend en charge l'objet 'pychrysalide.gui.core.items'. */ +bool ensure_python_items_is_registered(void); + + + +#endif /* _PLUGINS_PYCHRYSALIDE_GUI_CORE_ITEMS_H */ diff --git a/plugins/pychrysalide/gui/core/module.c b/plugins/pychrysalide/gui/core/module.c new file mode 100644 index 0000000..f90c70c --- /dev/null +++ b/plugins/pychrysalide/gui/core/module.c @@ -0,0 +1,97 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * module.c - intégration du répertoire core en tant que module + * + * Copyright (C) 2018 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide 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. + * + * Chrysalide 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "module.h" + + +#include <assert.h> + + +#include "items.h" +#include "../../helpers.h" + + + +/****************************************************************************** +* * +* Paramètres : super = module dont la définition est à compléter. * +* * +* Description : Ajoute le module 'gui.core' à un module Python. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool add_gui_core_module(PyObject *super) +{ + bool result; /* Bilan à retourner */ + PyObject *module; /* Sous-module mis en place */ + + static PyModuleDef py_chrysalide_gui_core_module = { + + .m_base = PyModuleDef_HEAD_INIT, + + .m_name = "pychrysalide.gui.core", + .m_doc = "Python module for Chrysalide.gui.core", + + .m_size = -1, + + }; + + module = build_python_module(super, &py_chrysalide_gui_core_module); + + result = (module != NULL); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Intègre les objets du module 'gui.core'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool populate_gui_core_module(void) +{ + bool result; /* Bilan à retourner */ + + result = true; + + if (result) result = ensure_python_items_is_registered(); + + assert(result); + + return result; + +} diff --git a/plugins/pychrysalide/gui/core/module.h b/plugins/pychrysalide/gui/core/module.h new file mode 100644 index 0000000..f9684d0 --- /dev/null +++ b/plugins/pychrysalide/gui/core/module.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * module.h - prototypes pour l'intégration du répertoire core en tant que module + * + * Copyright (C) 2018 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide 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. + * + * Chrysalide 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _PLUGINS_PYCHRYSALIDE_GUI_CORE_MODULE_H +#define _PLUGINS_PYCHRYSALIDE_GUI_CORE_MODULE_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Ajoute le module 'gui.core' à un module Python. */ +bool add_gui_core_module(PyObject *); + +/* Intègre les objets du module 'gui.core'. */ +bool populate_gui_core_module(void); + + + +#endif /* _PLUGINS_PYCHRYSALIDE_GUI_CORE_MODULE_H */ diff --git a/plugins/pychrysalide/gui/module.c b/plugins/pychrysalide/gui/module.c index 5dd9e72..abd9c0a 100644 --- a/plugins/pychrysalide/gui/module.c +++ b/plugins/pychrysalide/gui/module.c @@ -30,6 +30,7 @@ #include "editem.h" +#include "core/module.h" #include "panels/module.h" #include "../helpers.h" @@ -67,6 +68,7 @@ bool add_gui_module(PyObject *super) result = (module != NULL); + if (result) result = add_gui_core_module(module); if (result) result = add_gui_panels_module(module); if (!result) @@ -97,6 +99,7 @@ bool populate_gui_module(void) if (result) result = ensure_python_editor_item_is_registered(); + if (result) result = populate_gui_core_module(); if (result) result = populate_gui_panels_module(); assert(result); |