summaryrefslogtreecommitdiff
path: root/src/analysis/binary.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-12-03 15:25:23 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-12-03 15:25:23 (GMT)
commit9e58f9ae7208eeaf09a4b0af2f60996341d6af50 (patch)
treee170112cca3c11ec347c8cf21357b88a090b5b23 /src/analysis/binary.c
parent7b9727379e1c3f2aefc4ac0db0e91d0cfb0a481f (diff)
Selected the right storage for each loaded binary.
Diffstat (limited to 'src/analysis/binary.c')
-rw-r--r--src/analysis/binary.c88
1 files changed, 31 insertions, 57 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index 6cc3c74..4d6c8ba 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -48,7 +48,6 @@
#include "../core/logs.h"
#include "../core/params.h"
#include "../core/processors.h"
-//#include "../glibext/chrysamarshal.h"
#include "../glibext/gbinarycursor.h"
#include "../glibext/gloadedpanel.h"
#include "../gtkext/easygtk.h"
@@ -429,7 +428,6 @@ static bool g_loaded_binary_load_storage(GLoadedBinary *binary, xmlXPathContext
char *value; /* Valeur lue à partie du XML */
char *access; /* Chemin d'accès à un élément */
unsigned short port; /* Port de communication */
- bool use; /* Usage d'un serveur distant */
DBFeatures i; /* Boucle de parcours */
result = true;
@@ -522,6 +520,9 @@ static bool g_loaded_binary_load_storage(GLoadedBinary *binary, xmlXPathContext
}
+ if (binary->use_remote)
+ g_loaded_binary_set_remote_storage_usage(binary, true);
+
glbls_no_storage_config:
free(storage_path);
@@ -705,10 +706,10 @@ void g_loaded_binary_set_remote_storage_usage(GLoadedBinary *binary, bool use)
{
binary->use_remote = use;
+ g_clear_object(&binary->remote);
+
if (use)
- /* TODO : reload conn ! */;
- else
- /* TODO : stop conn ! */;
+ g_loaded_binary_connect_remote(binary);
}
@@ -821,13 +822,6 @@ static bool g_loaded_binary_connect_internal(GLoadedBinary *binary)
GBinContent *content; /* Contenu bianire manipulé */
const gchar *checksum; /* Identifiant de binaire */
-
-
- char *host; /* Nom du serveur à contacter */
- int port; /* Numéro du port associé */
-
-
-
result = false;
/* Utilisateur représenté */
@@ -854,19 +848,8 @@ static bool g_loaded_binary_connect_internal(GLoadedBinary *binary)
checksum,
binary->collections);
-
-
-
- if (!g_generic_config_get_value(get_main_configuration(), MPK_LOCAL_HOST, &host))
- /* ... */;
-
- if (!g_generic_config_get_value(get_main_configuration(), MPK_LOCAL_PORT, &port))
- /* ... */;
-
-
result = g_db_client_start_internal(binary->local);
-
glbcl_exit:
return result;
@@ -895,15 +878,10 @@ static bool g_loaded_binary_connect_remote(GLoadedBinary *binary)
GBinContent *content; /* Contenu bianire manipulé */
const gchar *checksum; /* Identifiant de binaire */
-
-
- char *host; /* Nom du serveur à contacter */
- int port; /* Numéro du port associé */
-
-
-
result = false;
+ assert(binary->remote == NULL);
+
/* Utilisateur représenté */
if (!g_generic_config_get_value(get_main_configuration(), MPK_AUTHOR_NAME, &tmp))
@@ -923,23 +901,21 @@ static bool g_loaded_binary_connect_remote(GLoadedBinary *binary)
/* Tentative de connexion */
- binary->local = g_db_client_new(author, priv,
- g_loaded_binary_get_name(binary, false),
- checksum,
- binary->collections);
-
-
+ binary->remote = g_db_client_new(author, priv,
+ g_loaded_binary_get_name(binary, false),
+ checksum,
+ binary->collections);
+ result = g_db_client_start_remote(binary->local, binary->remote_host, binary->remote_port);
- if (!g_generic_config_get_value(get_main_configuration(), MPK_LOCAL_HOST, &host))
- /* ... */;
-
- if (!g_generic_config_get_value(get_main_configuration(), MPK_LOCAL_PORT, &port))
- /* ... */;
-
+ if (!result)
+ {
+ log_variadic_message(LMT_ERROR, _("Failed to connect to remote host '%s:%hu'"),
+ binary->remote_host, binary->remote_port);
- result = g_db_client_start_remote(binary->local, host, port);
+ g_clear_object(&binary->remote);
+ }
glbcl_exit:
@@ -1129,10 +1105,13 @@ bool _g_loaded_binary_add_to_collection(GLoadedBinary *binary, GDbItem *item, bo
{
storage = g_loaded_binary_get_storage(binary, feature);
+ if (storage == DBS_ALL_REMOTE)
+ client = binary->remote;
+ else
+ client = NULL;
- /* TODO : sélection du bon client... */
- client = binary->local;
-
+ if (client == NULL)
+ client = binary->local;
init_packed_buffer(&out_pbuf);
@@ -1147,8 +1126,6 @@ bool _g_loaded_binary_add_to_collection(GLoadedBinary *binary, GDbItem *item, bo
exit_packed_buffer(&out_pbuf);
-
-
}
g_object_unref(G_OBJECT(collec));
@@ -1159,10 +1136,6 @@ bool _g_loaded_binary_add_to_collection(GLoadedBinary *binary, GDbItem *item, bo
}
-
-
-
-
/******************************************************************************
* *
* Paramètres : binary = élément binaire à consulter. *
@@ -1199,10 +1172,13 @@ bool _g_loaded_binary_remove_from_collection(GLoadedBinary *binary, DBFeatures f
{
storage = g_loaded_binary_get_storage(binary, feature);
+ if (storage == DBS_ALL_REMOTE)
+ client = binary->remote;
+ else
+ client = NULL;
- /* TODO : sélection du bon client... */
- client = binary->local;
-
+ if (client == NULL)
+ client = binary->local;
init_packed_buffer(&out_pbuf);
@@ -1217,8 +1193,6 @@ bool _g_loaded_binary_remove_from_collection(GLoadedBinary *binary, DBFeatures f
exit_packed_buffer(&out_pbuf);
-
-
}
g_object_unref(G_OBJECT(collec));