diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-12-18 22:44:24 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-12-18 22:44:24 (GMT) |
commit | f4dbbab3190d13e61f125eea51a0ecec2ab9e897 (patch) | |
tree | 2362579b428c363e2cca94e0fa89b1e39b7a50e7 /plugins/pychrysa/plugin.c | |
parent | 64e09a6c3e39785975b5322973ed83734cedb82e (diff) |
Created a proper panel for the Android permissions in the editor.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@305 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/pychrysa/plugin.c')
-rw-r--r-- | plugins/pychrysa/plugin.c | 129 |
1 files changed, 96 insertions, 33 deletions
diff --git a/plugins/pychrysa/plugin.c b/plugins/pychrysa/plugin.c index 9601432..1bda007 100644 --- a/plugins/pychrysa/plugin.c +++ b/plugins/pychrysa/plugin.c @@ -25,10 +25,14 @@ #include "plugin.h" +#include <pygobject.h> + + #include "../../src/analysis/binary.h" #include "../../src/plugins/plugin-int.h" +#include "helpers.h" #include "analysis/binary.h" #include "debug/debugger.h" @@ -65,6 +69,9 @@ static void g_python_plugin_class_init(GPythonPluginClass *); /* Initialise l'instance d'un greffon Python. */ static void g_python_plugin_init(GPythonPlugin *); +/* Procède à l'initialisation du greffon. */ +static bool g_python_plugin_do_init(GPythonPlugin *, GObject *); + /* Indique l'utilité pratique du greffon. */ static PluginAction g_python_plugin_get_action(const GPythonPlugin *); @@ -106,6 +113,9 @@ static PyObject *pychrysa_plugin_run(PyObject *, PyObject *); /* Définit les constantes pour les greffons en Python. */ static bool pychrysa_plugin_define_constants(PyObject *); +/* Procède à l'initialisation du greffon. */ +static PyObject *pychrysa_plugin_init(PyObject *, PyObject *); + /* Définit le comportement par défaut d'un greffon Python. */ static PyObject *pychrysa_plugin_get_action(PyObject *, PyObject *); @@ -255,29 +265,6 @@ static void g_python_plugin_init(GPythonPlugin *plugin) -PyObject *run_python_method(PyObject *module, const char *method, PyObject *args) -{ - PyObject *result; /* Bilan à retourner */ - PyObject *func; /* Fonction visée */ - - result = NULL; - - func = PyObject_GetAttrString(module, method); - if (func == NULL) return NULL; - - if (PyCallable_Check(func)) - { - result = PyObject_CallObject(func, args); - if (result == NULL) PyErr_Print(); - } - else if (PyErr_Occurred()) PyErr_Print(); - - Py_DECREF(func); - - return result; - -} - /****************************************************************************** * * @@ -333,7 +320,9 @@ GPluginModule *g_python_plugin_new(const char *modname, const char *filename) G_PLUGIN_MODULE(result)->name = strdup(modname); G_PLUGIN_MODULE(result)->name = stradd(G_PLUGIN_MODULE(result)->name, ".py"); + G_PLUGIN_MODULE(result)->filename = strdup(G_PLUGIN_MODULE(result)->name); + G_PLUGIN_MODULE(result)->init = g_python_plugin_do_init; G_PLUGIN_MODULE(result)->get_action = g_python_plugin_get_action; G_PLUGIN_MODULE(result)->is_matching = g_python_plugin_is_matching; @@ -360,6 +349,44 @@ GPluginModule *g_python_plugin_new(const char *modname, const char *filename) /****************************************************************************** * * +* Paramètres : plugin = greffon à initialiser. * +* ref = espace de référencement global. * +* * +* Description : Procède à l'initialisation du greffon. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_python_plugin_do_init(GPythonPlugin *plugin, GObject *ref) +{ + bool result; /* Bilan à retourner */ + PyObject *args; /* Arguments pour l'appel */ + PyObject *value; /* Valeur obtenue */ + int cmp; /* Bilan de la comparaison */ + + args = PyTuple_New(1); + PyTuple_SetItem(args, 0, pygobject_new(ref)); + + value = run_python_method(plugin->instance, "init", args); + + if (PyObject_Cmp(value, Py_True, &cmp) == -1) + result = false; + else + result = (cmp == 0); + + Py_XDECREF(value); + Py_DECREF(args); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : plugin = greffon de prise en charge à utiliser. * * * * Description : Indique l'utilité pratique du greffon. * @@ -669,6 +696,27 @@ static bool pychrysa_plugin_define_constants(PyObject *dict) * Paramètres : self = classe assurant le lien avec l'éditeur de messages. * * args = arguments fournis à l'appel. * * * +* Description : Procède à l'initialisation du greffon. * +* * +* Retour : Rien en équivalent Python. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *pychrysa_plugin_init(PyObject *self, PyObject *args) +{ + Py_INCREF(Py_True); + return Py_True; + +} + + +/****************************************************************************** +* * +* Paramètres : self = classe assurant le lien avec l'éditeur de messages. * +* args = arguments fournis à l'appel. * +* * * Description : Définit le comportement par défaut d'un greffon Python. * * * * Retour : Rien en équivalent Python. * @@ -820,20 +868,35 @@ bool add_plugin_to_python_module(PyObject *module) static PyMethodDef pychrysa_plugin_methods[] = { - { "get_action", (PyCFunction)pychrysa_plugin_get_action, METH_NOARGS, - "Register the plugin for given actions." + { + "init", (PyCFunction)pychrysa_plugin_init, + METH_VARARGS, + "Initialize the plugin." + }, + { + "get_action", (PyCFunction)pychrysa_plugin_get_action, + METH_NOARGS, + "Register the plugin for given actions." }, - { "is_matching", (PyCFunction)pychrysa_plugin_is_matching, METH_VARARGS, - "Define if the given file can be handled." + { + "is_matching", (PyCFunction)pychrysa_plugin_is_matching, + METH_VARARGS, + "Define if the given file can be handled." }, - { "handle_debugger", (PyCFunction)pychrysa_plugin_handle_debugger, METH_VARARGS, - "Be notify about debugger attaching or detaching." + { + "handle_debugger", (PyCFunction)pychrysa_plugin_handle_debugger, + METH_VARARGS, + "Be notify about debugger attaching or detaching." }, - { "run", (PyCFunction)pychrysa_plugin_run, METH_VARARGS, - "Run the plugin for a specific action." + { + "run", (PyCFunction)pychrysa_plugin_run, + METH_VARARGS, + "Run the plugin for a specific action." }, - { "add_wgt", (PyCFunction)add_wgt, METH_VARARGS, - "Run the plugin for a specific action." + { + "add_wgt", (PyCFunction)add_wgt, + METH_VARARGS, + "Run the plugin for a specific action." }, NULL }; |