summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/analysis/db/admin.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/analysis/db/admin.c')
-rw-r--r--plugins/pychrysalide/analysis/db/admin.c116
1 files changed, 103 insertions, 13 deletions
diff --git a/plugins/pychrysalide/analysis/db/admin.c b/plugins/pychrysalide/analysis/db/admin.c
index 52027ac..a4694e6 100644
--- a/plugins/pychrysalide/analysis/db/admin.c
+++ b/plugins/pychrysalide/analysis/db/admin.c
@@ -42,6 +42,12 @@
/* Crée un nouvel objet Python de type 'AdminClient'. */
static PyObject *py_admin_client_new(PyTypeObject *, PyObject *, PyObject *);
+/* Effectue une demande de liste de binaires existants. */
+static PyObject *py_admin_client_request_existing_binaries(PyObject *, PyObject *);
+
+/* Fournit la liste des instantanés existants. */
+static PyObject *py_admin_client_get_existing_binaries(PyObject *, void *);
+
/******************************************************************************
@@ -63,9 +69,9 @@ static PyObject *py_admin_client_new(PyTypeObject *type, PyObject *args, PyObjec
PyObject *result; /* Instance à retourner */
GAdminClient *client; /* Serveur mis en place */
-#define ADMIN_CLIENT_DOC \
- "AdminClient provides and receives binary updates to and from a connected" \
- " to a server.\n" \
+#define ADMIN_CLIENT_DOC \
+ "AdminClient provides control of the registered binary contents available from a" \
+ " server.\n" \
"\n" \
"Such clients must be authenticated and communications are encrypted using TLS.\n" \
"\n" \
@@ -74,16 +80,9 @@ static PyObject *py_admin_client_new(PyTypeObject *type, PyObject *args, PyObjec
" AdminClient()" \
"\n" \
"AdminClient instances emit the following signals:\n" \
- "* 'snapshots-updated'\n" \
- " This signal is emitted when the snapshot list has evolved.\n" \
- "\n" \
- " Handlers are expected to have only one argument: the client managing the" \
- " updated snapshots.\n" \
- "* 'snapshot-changed'\n" \
- " This signal is emitted when the identifier of the current snapshot changed.\n" \
- "\n" \
- " Handlers are expected to have only one argument: the client managing the" \
- " snapshots."
+ "* 'existing-binaries-updated'\n" \
+ " This signal is emitted when the list of existing binaries on server side" \
+ " has been updated following a user request.\n" \
client = g_admin_client_new();
@@ -101,6 +100,95 @@ static PyObject *py_admin_client_new(PyTypeObject *type, PyObject *args, PyObjec
/******************************************************************************
* *
+* Paramètres : self = client à manipuler. *
+* args = arguments d'appel non utilisés ici. *
+* *
+* Description : Effectue une demande de liste de binaires existants. *
+* *
+* Retour : True si la commande a bien été envoyée, False sinon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_admin_client_request_existing_binaries(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Bilan à retourner */
+ GAdminClient *client; /* Version native du serveur */
+ bool status; /* Bilan de l'opération */
+
+#define ADMIN_CLIENT_REQUEST_EXISTING_BINARIES_METHOD PYTHON_METHOD_DEF \
+( \
+ request_existing_binaries, "$self, /", \
+ METH_NOARGS, py_admin_client, \
+ "Ask the server for a list of all existing analyzed binaries" \
+ " and returns the status of the request transmission." \
+ "\n" \
+ "A *existing-binaries-updated* signal is emitted when the" \
+ " pychrysalide.analysis.db.AdminClient.existing_binaries attribute" \
+ " gets ready for reading." \
+)
+
+ client = G_ADMIN_CLIENT(pygobject_get(self));
+
+ status = g_admin_client_request_existing_binaries(client);
+
+ result = status ? Py_True : Py_False;
+ Py_INCREF(result);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* closure = non utilisé ici. *
+* *
+* Description : Fournit la liste des instantanés existants. *
+* *
+* Retour : Liste de binaires en place, vide si aucun. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_admin_client_get_existing_binaries(PyObject *self, void *closure)
+{
+ PyObject *result; /* Valeur à retourner */
+ GAdminClient *client; /* Version native du serveur */
+ size_t count; /* Taille de cette liste */
+ char **binaries; /* Liste des binaires présents */
+ size_t i; /* Boucle de parcours */
+
+#define ADMIN_CLIENT_EXISTING_BINARIES_ATTRIB PYTHON_GET_DEF_FULL \
+( \
+ existing_binaries, py_admin_client, \
+ "Provide the list of all exisiting binaries on the server side.\n" \
+ "\n" \
+ "The returned value is a tuple of strings or an empty tuple." \
+)
+
+ client = G_ADMIN_CLIENT(pygobject_get(self));
+
+ binaries = g_admin_client_get_existing_binaries(client, &count);
+
+ result = PyTuple_New(count);
+
+ for (i = 0; i < count; i++)
+ PyTuple_SetItem(result, i, PyUnicode_FromString(binaries[i]));
+
+ if (binaries != NULL)
+ free(binaries);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : - *
* *
* Description : Fournit un accès à une définition de type à diffuser. *
@@ -114,10 +202,12 @@ static PyObject *py_admin_client_new(PyTypeObject *type, PyObject *args, PyObjec
PyTypeObject *get_python_admin_client_type(void)
{
static PyMethodDef py_admin_client_methods[] = {
+ ADMIN_CLIENT_REQUEST_EXISTING_BINARIES_METHOD,
{ NULL }
};
static PyGetSetDef py_admin_client_getseters[] = {
+ ADMIN_CLIENT_EXISTING_BINARIES_ATTRIB,
{ NULL }
};