/** * The main Sernatur namespace */ namespace Sernatur { using Postgres; /** * The MainWindow class */ [GtkTemplate (ui = "/cl/cromer/ubb/sernatur/sernatur.window.ui")] public class MainWindow : Gtk.ApplicationWindow { /** * Initialize the main window class * @param application The application used to make the GLib object */ public MainWindow (Gtk.Application application) { GLib.Object (application: application); Database conn; conn = set_db_login ("localhost", "", "", "", "postgres", "bdd", "bdd"); if (conn.get_status () != ConnectionStatus.OK) { stderr.printf ("%s\n", conn.get_error_message ()); application.quit (); return; } /*Result res = conn.exec ("CREATE DATABASE bdd;"); if (res.get_status () != ExecStatus.COMMAND_OK) { stderr.printf ("%s\n", conn.get_error_message ()); application.quit (); return; } string password = encrypt_password ("bdd", "bdd"); res = conn.exec ("CREATE USER bdd WITH ENCRYPTED PASSWORD '" + password + "';"); if (res.get_status () != ExecStatus.COMMAND_OK) { stderr.printf ("%s\n", conn.get_error_message ()); application.quit (); return; } res = conn.exec ("GRANT ALL PRIVILEGES ON DATABASE bdd TO bdd;"); if (res.get_status () != ExecStatus.COMMAND_OK) { stderr.printf ("%s\n", conn.get_error_message ()); application.quit (); return; }*/ GLib.print (dgettext (null, "Server version:") + " %d\n", conn.get_server_version ()); } } }