summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/analysis/db
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-10-13 23:24:57 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-10-13 23:24:57 (GMT)
commitf439711a77e0719e7f1dcf4b5c5511157986c918 (patch)
treecac0cf37be2676fcf2dc958f9d9fd2fadea20653 /plugins/pychrysalide/analysis/db
parent986125d4c2d8b049017b6d0770f16b9058076165 (diff)
Retrieved the current snapshot identifier from servers.
Diffstat (limited to 'plugins/pychrysalide/analysis/db')
-rw-r--r--plugins/pychrysalide/analysis/db/client.c100
1 files changed, 100 insertions, 0 deletions
diff --git a/plugins/pychrysalide/analysis/db/client.c b/plugins/pychrysalide/analysis/db/client.c
index e5b67da..afece26 100644
--- a/plugins/pychrysalide/analysis/db/client.c
+++ b/plugins/pychrysalide/analysis/db/client.c
@@ -54,6 +54,9 @@ static PyObject *py_hub_client_save(PyObject *, PyObject *);
/* Active les éléments en amont d'un horodatage donné. */
static PyObject *py_hub_client_set_last_active(PyObject *, PyObject *);
+/* Fournit l'identifiant de l'instantané courant. */
+static PyObject *py_hub_client_get_current_snapshot(PyObject *, void *);
+
/******************************************************************************
@@ -332,6 +335,102 @@ static PyObject *py_hub_client_set_last_active(PyObject *self, PyObject *args)
/******************************************************************************
* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* closure = non utilisé ici. *
+* *
+* Description : Fournit l'identifiant de l'instantané courant. *
+* *
+* Retour : Identifiant d'instantané ou None. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_hub_client_get_current_snapshot(PyObject *self, void *closure)
+{
+ PyObject *result; /* Valeur à retourner */
+ GHubClient *client; /* Version native du serveur */
+ snapshot_id_t id; /* Identifiant à transmettre */
+ bool status; /* Validité de cet identifiant */
+
+#define HUB_CLIENT_CURRENT_SNAPSHOT_ATTRIB PYTHON_GETSET_DEF_FULL \
+( \
+ current_snapshot, py_hub_client, \
+ "Identifier of the current snapshot, provided as a string." \
+ "\n" \
+ "The returned value is a cached version of the value stored at" \
+ " server side. Thus, defining a new current snapshot is" \
+ " successful as soon as the request to this server is sent." \
+)
+
+ client = G_HUB_CLIENT(pygobject_get(self));
+
+ status = g_hub_client_get_current_snapshot(client, &id);
+
+ if (status)
+ result = PyUnicode_FromString(snapshot_id_as_string(&id));
+
+ else
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* value = valeur fournie à intégrer ou prendre en compte. *
+* closure = adresse non utilisée ici. *
+* *
+* Description : Définit l'identifiant de l'instantané courant. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static int py_hub_client_set_current_snapshot(PyObject *self, PyObject *value, void *closure)
+{
+ int ret; /* Bilan d'analyse */
+ void *raw; /* Valeur brute d'identifiant */
+ snapshot_id_t id; /* Identifiant reconnu */
+ bool status; /* Bilan d'une conversion */
+ GHubClient *client; /* Version native du serveur */
+
+ ret = PyUnicode_Check(value);
+ if (!ret) return -1;
+
+ raw = PyUnicode_DATA(value);
+
+ status = init_snapshot_id_from_text(&id, raw);
+ if (!status)
+ {
+ PyErr_SetString(PyExc_TypeError, _("provided value is not a valid snapshot identifier."));
+ return -1;
+ }
+
+ client = G_HUB_CLIENT(pygobject_get(self));
+
+ status = g_hub_client_set_current_snapshot(client, &id);
+ if (!status)
+ {
+ PyErr_SetString(PyExc_TypeError, "unable to send the provided snapshot identifier");
+ return -1;
+ }
+
+ return 0;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : - *
* *
* Description : Fournit un accès à une définition de type à diffuser. *
@@ -353,6 +452,7 @@ PyTypeObject *get_python_hub_client_type(void)
};
static PyGetSetDef py_hub_client_getseters[] = {
+ HUB_CLIENT_CURRENT_SNAPSHOT_ATTRIB,
{ NULL }
};