From: Andrea Zagli Date: Sun, 3 Dec 2017 09:56:14 +0000 (+0100) Subject: Utilizzo di Territorio::init e Organigramma::init. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=refs%2Fheads%2Fdevelop;p=albonline%2Fbe Utilizzo di Territorio::init e Organigramma::init. --- diff --git a/data/albonline/gui/albonline.gui b/data/albonline/gui/albonline.gui index 58f6814..8bb7dd6 100644 --- a/data/albonline/gui/albonline.gui +++ b/data/albonline/gui/albonline.gui @@ -1676,7 +1676,7 @@ w_main Gestione Albonline 0.0.2 - Copyright © 2013-2016 Andrea Zagli <azagli@libero.it> + Copyright © 2013-2017 Andrea Zagli <azagli@libero.it> Andrea Zagli <azagli@libero.it> image-missing diff --git a/docs/albonline/examples/albonline.conf b/docs/albonline/examples/albonline.conf index fb36f07..05197f5 100644 --- a/docs/albonline/examples/albonline.conf +++ b/docs/albonline/examples/albonline.conf @@ -1,13 +1,14 @@ -[DB_TERRITORIO] +[TERRITORIO_DB] cnc_string=PostgreSQL://postgres:postgres@HOST=localhost;PORT=5432;DB_NAME=territorio -[ZAKAUTHO_TERRITORIO] +[TERRITORIO_ZAKAUTHO] cnc_string=PostgreSQL://postgres:postgres@HOST=localhost;PORT=5432;DB_NAME=autoz -[DB_ORGANIGRAMMA] +[ORGANIGRAMMA_DB] +pg_cnc_string=host=localhost dbname=organigramma user=postgres password=postgres cnc_string=PostgreSQL://postgres:postgres@HOST=localhost;PORT=5432;DB_NAME=organigramma -[ZAKAUTHO_ORGANIGRAMMA] +[ORGANIGRAMMA_ZAKAUTHO] cnc_string=PostgreSQL://postgres:postgres@HOST=localhost;PORT=5432;DB_NAME=autoz [libzakauthe] diff --git a/src/main.c b/src/main.c index 26359df..6d21ed9 100644 --- a/src/main.c +++ b/src/main.c @@ -174,16 +174,12 @@ main (int argc, char *argv[]) GdaConnection *gdacon; ZakAuthe *aute; - gchar **aute_params; - gsize n_aute_params; GSList *sl_aute_params; gchar *utente; gchar *cnc_string; - gint i; - ZakAuthoIResource *ires1; #ifdef G_OS_WIN32 @@ -247,15 +243,13 @@ main (int argc, char *argv[]) /* inizializzazione commons */ commons = g_new0 (Commons, 1); - commons->territorio_commons = g_new0 (TerritorioCommons, 1); - commons->organigramma_commons = g_new0 (OrganigrammaCommons, 1); + commons->territorio_commons = territorio_init (confi, "TERRITORIO_"); + commons->organigramma_commons = organigramma_init (confi, "ORGANIGRAMMA_"); commons->utente = utente; commons->territorio_commons->utente = utente; commons->organigramma_commons->utente = utente; - commons->organigramma_commons->territorio_commons = commons->territorio_commons; - if (argc == 3) { commons->pr_cod_prat = strtol (argv[2], NULL, 10); @@ -274,10 +268,6 @@ main (int argc, char *argv[]) { commons->guidir = g_strdup (GUIDIR); commons->formdir = g_strdup (FORMDIR); - commons->territorio_commons->guidir = g_build_filename ("/mingw", "share", "territorio", "gui", NULL); - commons->territorio_commons->formdir = g_build_filename ("/mingw", "share", "territorio", "form", NULL); - commons->organigramma_commons->guidir = g_build_filename ("/mingw", "share", "organigramma", "gui", NULL); - commons->organigramma_commons->formdir = g_build_filename ("/mingw", "share", "organigramma", "form", NULL); } else { @@ -286,26 +276,16 @@ main (int argc, char *argv[]) commons->guidir = g_build_filename (moddir, "share", PACKAGE, "gui", NULL); commons->formdir = g_build_filename (moddir, "share", PACKAGE, "form", NULL); - commons->territorio_commons->guidir = g_build_filename (moddir, "share", "territorio", "gui", NULL); - commons->territorio_commons->formdir = g_build_filename (moddir, "share", "territorio", "form", NULL); - commons->organigramma_commons->guidir = g_build_filename (moddir, "share", "organigramma", "gui", NULL); - commons->organigramma_commons->formdir = g_build_filename (moddir, "share", "organigramma", "form", NULL); } #else commons->guidir = g_strdup (GUIDIR); commons->formdir = g_strdup (FORMDIR); - commons->territorio_commons->guidir = g_build_filename ("/usr", "local", "share", "territorio", "gui", NULL); - commons->territorio_commons->formdir = g_build_filename ("/usr", "local", "share", "territorio", "form", NULL); - commons->organigramma_commons->guidir = g_build_filename ("/usr", "local", "share", "organigramma", "gui", NULL); - commons->organigramma_commons->formdir = g_build_filename ("/usr", "local", "share", "organigramma", "form", NULL); #endif commons->guifile = g_build_filename (commons->guidir, "albonline.gui", NULL); - commons->territorio_commons->guifile = g_build_filename (commons->territorio_commons->guidir, "territorio.gui", NULL); - commons->organigramma_commons->guifile = g_build_filename (commons->organigramma_commons->guidir, "organigramma.gui", NULL); /* leggo la stringa di connessione al db */ cnc_string = zak_confi_path_get_value (confi, "DB/cnc_string"); @@ -398,47 +378,6 @@ main (int argc, char *argv[]) /* inizializzo solipa */ commons->solipa = solipa_new (); - /* leggo la stringa di connessione al db territorio */ - cnc_string = zak_confi_path_get_value (confi, "DB_TERRITORIO/cnc_string"); - if (cnc_string == NULL) - { - g_error ("Impossibile leggere la stringa di connessione dal file di configurazione."); - } - - commons->territorio_commons->gdaex = gdaex_new_from_string (cnc_string); - if (commons->territorio_commons->gdaex == NULL) - { - g_error ("Errore nella connessione al database: %s", cnc_string); - } - - /* leggo i parametri per libzakautho di territorio */ - cnc_string = zak_confi_path_get_value (confi, "ZAKAUTHO_TERRITORIO/cnc_string"); - if (cnc_string == NULL) - { - g_warning ("Impossibile leggere la stringa di connessione per libzakautho dal file di configurazione."); - return 0; - } - - error = NULL; - gdacon = gda_connection_open_from_string (NULL, cnc_string, NULL, 0, &error); - if (gdacon == NULL) - { - g_warning ("Impossibile creare la connessione al db per libzakautho di territorio: %s.\n", error != NULL && error->message != NULL ? error->message : "nessun dettaglio"); - return 0; - } - - commons->territorio_commons->autoz = zak_autho_new (); - if (commons->territorio_commons->autoz == NULL) - { - g_warning ("Impossibile creare l'oggetto per libzakautho."); - return 0; - } - if (!zak_autho_load_from_db (commons->territorio_commons->autoz, gdacon, NULL, TRUE)) - { - g_warning ("Impossibile caricare la configurazione per libzakauto dal db."); - return 0; - } - commons->territorio_commons->role_utente = zak_autho_get_role_from_id (commons->territorio_commons->autoz, commons->territorio_commons->utente); if (commons->territorio_commons->role_utente == NULL) { @@ -446,47 +385,6 @@ main (int argc, char *argv[]) return 0; } - /* leggo la stringa di connessione al db organigramma */ - cnc_string = zak_confi_path_get_value (confi, "DB_ORGANIGRAMMA/cnc_string"); - if (cnc_string == NULL) - { - g_error ("Impossibile leggere la stringa di connessione dal file di configurazione."); - } - - commons->organigramma_commons->gdaex = gdaex_new_from_string (cnc_string); - if (commons->organigramma_commons->gdaex == NULL) - { - g_error ("Errore nella connessione al database: %s", cnc_string); - } - - /* leggo i parametri per libzakautho di organigramma */ - cnc_string = zak_confi_path_get_value (confi, "ZAKAUTHO_ORGANIGRAMMA/cnc_string"); - if (cnc_string == NULL) - { - g_warning ("Impossibile leggere la stringa di connessione per libzakautho dal file di configurazione."); - return 0; - } - - error = NULL; - gdacon = gda_connection_open_from_string (NULL, cnc_string, NULL, 0, &error); - if (gdacon == NULL) - { - g_warning ("Impossibile creare la connessione al db per libzakautho di organigramma: %s.\n", error != NULL && error->message != NULL ? error->message : "nessun dettaglio"); - return 0; - } - - commons->organigramma_commons->autoz = zak_autho_new (); - if (commons->organigramma_commons->autoz == NULL) - { - g_warning ("Impossibile creare l'oggetto per libzakautho."); - return 0; - } - if (!zak_autho_load_from_db (commons->organigramma_commons->autoz, gdacon, NULL, TRUE)) - { - g_warning ("Impossibile caricare la configurazione per libzakautho dal db."); - return 0; - } - commons->organigramma_commons->role_utente = zak_autho_get_role_from_id (commons->organigramma_commons->autoz, commons->organigramma_commons->utente); if (commons->organigramma_commons->role_utente == NULL) { @@ -496,8 +394,6 @@ main (int argc, char *argv[]) /* gtkbuilder */ commons->gtkbuilder = gtk_builder_new (); - commons->territorio_commons->gtkbuilder = gtk_builder_new (); - commons->organigramma_commons->gtkbuilder = gtk_builder_new (); error = NULL; gtk_builder_add_objects_from_file (commons->gtkbuilder, commons->guifile,