diff options
Diffstat (limited to 'plugins/pychrysalide')
-rw-r--r-- | plugins/pychrysalide/analysis/db/client.c | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/plugins/pychrysalide/analysis/db/client.c b/plugins/pychrysalide/analysis/db/client.c index 80e15b8..68699b9 100644 --- a/plugins/pychrysalide/analysis/db/client.c +++ b/plugins/pychrysalide/analysis/db/client.c @@ -62,6 +62,15 @@ static PyObject *py_hub_client_set_snapshot_name(PyObject *, PyObject *); /* Définit la désignation d'un instantané donné. */ static PyObject *py_hub_client_set_snapshot_desc(PyObject *, PyObject *); +/* Restaure un ancien instantané. */ +static PyObject *py_hub_client_restore_snapshot(PyObject *, PyObject *); + +/* Crée un nouvel instantané à partir d'un autre. */ +static PyObject *py_hub_client_create_snapshot(PyObject *, PyObject *); + +/* Supprime un ancien instantané. */ +static PyObject *py_hub_client_remove_snapshot(PyObject *, PyObject *); + /* Fournit la liste des instantanés existants. */ static PyObject *py_hub_client_get_snapshots(PyObject *, void *); @@ -465,6 +474,162 @@ static PyObject *py_hub_client_set_snapshot_desc(PyObject *self, PyObject *args) /****************************************************************************** * * +* Paramètres : self = client à manipuler. * +* args = arguments d'appel à consulter. * +* * +* Description : Restaure un ancien instantané. * +* * +* Retour : True si la commande a bien été envoyée, False sinon. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_hub_client_restore_snapshot(PyObject *self, PyObject *args) +{ + PyObject *result; /* Bilan à retourner */ + const char *raw_id; /* Identifiant brut */ + int ret; /* Bilan de lecture des args. */ + snapshot_id_t id; /* Identifiant utilisable */ + bool status; /* Bilan d'opération */ + GHubClient *client; /* Version native du serveur */ + +#define HUB_CLIENT_RESTORE_SNAPSHOT_METHOD PYTHON_METHOD_DEF \ +( \ + restore_snapshot, "$self, id, /", \ + METH_VARARGS, py_hub_client, \ + "Ask the server for restoring a given snapshot using" \ + " its identifier and returns the status of the request transmission." \ + "\n" \ + "A 'snapshot-changed' signal is emitted once the request has been" \ + " processed with success." \ +) + + ret = PyArg_ParseTuple(args, "s", &raw_id); + if (!ret) return NULL; + + status = init_snapshot_id_from_text(&id, raw_id); + if (!status) + { + PyErr_SetString(PyExc_TypeError, _("provided value is not a valid snapshot identifier.")); + return NULL; + } + + client = G_HUB_CLIENT(pygobject_get(self)); + + status = g_hub_client_restore_snapshot(client, &id); + + result = status ? Py_True : Py_False; + Py_INCREF(result); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : self = client à manipuler. * +* args = arguments d'appel à consulter. * +* * +* Description : Crée un nouvel instantané à partir d'un autre. * +* * +* Retour : True si la commande a bien été envoyée, False sinon. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_hub_client_create_snapshot(PyObject *self, PyObject *args) +{ + PyObject *result; /* Bilan à retourner */ + GHubClient *client; /* Version native du serveur */ + bool status; /* Bilan d'opération */ + +#define HUB_CLIENT_CREATE_SNAPSHOT_METHOD PYTHON_METHOD_DEF \ +( \ + create_snapshot, "$self, /", \ + METH_NOARGS, py_hub_client, \ + "Ask the server for creating a new snapshot of the current state" \ + " and returns the status of the request transmission." \ + "\n" \ + "A 'snapshots-updated' signal is emitted once the request has been" \ + " processed with success." \ +) + + client = G_HUB_CLIENT(pygobject_get(self)); + + status = g_hub_client_create_snapshot(client); + + result = status ? Py_True : Py_False; + Py_INCREF(result); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : self = client à manipuler. * +* args = arguments d'appel à consulter. * +* * +* Description : Supprime un ancien instantané. * +* * +* Retour : True si la commande a bien été envoyée, False sinon. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_hub_client_remove_snapshot(PyObject *self, PyObject *args) +{ + PyObject *result; /* Bilan à retourner */ + const char *raw_id; /* Identifiant brut */ + int rec; /* Indicateur de récursivité */ + int ret; /* Bilan de lecture des args. */ + snapshot_id_t id; /* Identifiant utilisable */ + bool status; /* Bilan d'opération */ + GHubClient *client; /* Version native du serveur */ + +#define HUB_CLIENT_REMOVE_SNAPSHOT_METHOD PYTHON_METHOD_DEF \ +( \ + remove_snapshot, "$self, id, recursive, /", \ + METH_VARARGS, py_hub_client, \ + "Ask the server for removing a given snapshot using" \ + " its identifier and returns the status of the request transmission." \ + "\n" \ + "If this removal has not to be recursive, all children snapshots get" \ + " reassigned to the parent snapshot of the target." \ + "\n" \ + "A 'snapshots-updated' signal is emitted once the request has been" \ + " processed with success." \ +) + + ret = PyArg_ParseTuple(args, "sp", &raw_id, &rec); + if (!ret) return NULL; + + status = init_snapshot_id_from_text(&id, raw_id); + if (!status) + { + PyErr_SetString(PyExc_TypeError, _("provided value is not a valid snapshot identifier.")); + return NULL; + } + + client = G_HUB_CLIENT(pygobject_get(self)); + + status = g_hub_client_remove_snapshot(client, &id, rec); + + result = status ? Py_True : Py_False; + Py_INCREF(result); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : self = objet Python concerné par l'appel. * * closure = non utilisé ici. * * * @@ -711,6 +876,9 @@ PyTypeObject *get_python_hub_client_type(void) HUB_CLIENT_SET_LAST_ACTIVE_METHOD, HUB_CLIENT_SET_SNAPSHOT_NAME_METHOD, HUB_CLIENT_SET_SNAPSHOT_DESC_METHOD, + HUB_CLIENT_RESTORE_SNAPSHOT_METHOD, + HUB_CLIENT_CREATE_SNAPSHOT_METHOD, + HUB_CLIENT_REMOVE_SNAPSHOT_METHOD, { NULL } }; |