commit 482d52e96fce9698ae0c4bd64f8daae6d7db9650 Author: Chris Cromer Date: Thu Oct 18 16:31:50 2018 -0300 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dd0496e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build +sernatur.tar.gz diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..026867a --- /dev/null +++ b/LICENSE @@ -0,0 +1,11 @@ +Copyright 2018 Chris Cromer + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..2ea24c6 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# SERNATUR +Este proyecto es para conectar a un base de datos de Postgresql para el ramo de Base de Datos. + +## Profesora +Valeria Beratto + +## Requisitos +- Vala +- Meson +- Ninja +- Gtk+-3 +- Libpq +- Valadoc (opcional para compilar valadoc del proyecto) + +## Compilar + meson --prefix=/usr build + cd build + ninja + +## Opciones de compilación +>-D valadocs=true +> +> Este opción va a compilar la documentación de codiǵo fuente usando valadoc + +>-D valadocs_dep=true +> +> Si ambos valadocs y esta opción están en uso se va a compilar la documentación del proyecto y tambien la documentación de todos los dependencies. Este opción es caro y hace mucho mas lento la compilación. \ No newline at end of file diff --git a/build_linux_package.sh b/build_linux_package.sh new file mode 100755 index 0000000..f96f6de --- /dev/null +++ b/build_linux_package.sh @@ -0,0 +1,13 @@ +#!/bin/sh -eu + +curdir=`pwd` +rm -rf buildtmp +mkdir buildtmp +LDFLAGS=-static-libstdc++ meson buildtmp --buildtype=release --prefix=/tmp/sernatur --libdir=lib --strip +ninja -C buildtmp install +rm -rf buildtmp +cp README.md /tmp/sernatur +cd /tmp/ +tar czf sernatur.tar.gz sernatur +mv sernatur.tar.gz "$curdir" +rm -rf sernatur diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 0000000..3c54d36 --- /dev/null +++ b/data/meson.build @@ -0,0 +1,3 @@ +install_data('sernatur.desktop', install_dir: join_paths(get_option('datadir'), 'applications')) +install_data('sernatur.png', install_dir: join_paths(get_option('datadir'), 'icons/hicolor/48x48/apps')) +subdir('ui') diff --git a/data/sernatur.desktop b/data/sernatur.desktop new file mode 100644 index 0000000..15a36f2 --- /dev/null +++ b/data/sernatur.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Type=Application +Name=Glade Template +Icon=glade-template +StartupNotify=true +Exec=@bindir@/glade-template +Name[en_US]=sernatur.desktop diff --git a/data/sernatur.png b/data/sernatur.png new file mode 100644 index 0000000..3276623 Binary files /dev/null and b/data/sernatur.png differ diff --git a/data/ui/meson.build b/data/ui/meson.build new file mode 100644 index 0000000..6c06a36 --- /dev/null +++ b/data/ui/meson.build @@ -0,0 +1,8 @@ +gen = generator( + find_program('glib-compile-resources'), + arguments: [ '--sourcedir=@SOURCE_DIR@/data/ui', + '--generate-source', + '--target=@OUTPUT@', + '@INPUT@'], + output: '@PLAINNAME@.c') +sernatur_gresource_c = gen.process(['sernatur.gresource.xml']) diff --git a/data/ui/sernatur.gresource.xml b/data/ui/sernatur.gresource.xml new file mode 100644 index 0000000..6dc6669 --- /dev/null +++ b/data/ui/sernatur.gresource.xml @@ -0,0 +1,6 @@ + + + + sernatur.window.ui + + diff --git a/data/ui/sernatur.window.ui b/data/ui/sernatur.window.ui new file mode 100644 index 0000000..5e5775a --- /dev/null +++ b/data/ui/sernatur.window.ui @@ -0,0 +1,17 @@ + + + + + + diff --git a/docs/MER.dia b/docs/MER.dia new file mode 100644 index 0000000..4133cb0 Binary files /dev/null and b/docs/MER.dia differ diff --git a/docs/meson.build b/docs/meson.build new file mode 100644 index 0000000..07f4d14 --- /dev/null +++ b/docs/meson.build @@ -0,0 +1,48 @@ +docs_deps = get_option('valadocs_deps') +if docs_enabled + if docs_deps + custom_target('valadoc', + input: vala_sources, + output: 'valadoc', + command: [ valadoc, + '--deps', + '--use-svg-images', + '--doclet=html', + '--force', + '--package-name=@0@'.format(meson.project_name()), + '--package-version=@0@'.format(meson.project_version()), + '--pkg=gtk+-3.0', + '--pkg=libpq', + '--vapidir=@0@'.format(join_paths(meson.source_root(), 'src/vapi')), + '--directory=@OUTDIR@/valadoc', + vala_sources, + ], + build_by_default: true, + install: true, + install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()) + ) + else + custom_target('valadoc', + input: vala_sources, + output: 'valadoc', + command: [ valadoc, + '--use-svg-images', + '--doclet=html', + '--force', + '--package-name=@0@'.format(meson.project_name()), + '--package-version=@0@'.format(meson.project_version()), + '--pkg=gtk+-3.0', + '--pkg=libpq', + '--vapidir=@0@'.format(join_paths(meson.source_root(), 'src/vapi')), + '--directory=@OUTDIR@/valadoc', + vala_sources, + ], + build_by_default: true, + install: true, + install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()) + ) + endif +endif + +install_data('trabajoSemestral(E1).pdf', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name())) +install_data('MER.dia', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name())) diff --git a/docs/trabajoSemestral(E1).pdf b/docs/trabajoSemestral(E1).pdf new file mode 100644 index 0000000..b98d7e6 Binary files /dev/null and b/docs/trabajoSemestral(E1).pdf differ diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..71cfff2 --- /dev/null +++ b/meson.build @@ -0,0 +1,23 @@ +project('sernatur', + ['c', 'vala'], + version: '1.0.0', + license: 'BSD-3', + default_options: [ + 'b_ofast=if-release', + 'b_march_native=if-release', + 'b_ndebug=if-release' + ] +) +add_global_arguments('-DGETTEXT_PACKAGE="sernatur"', language: 'c') + +docs_enabled = get_option('valadocs') +valadoc = find_program('valadoc', required: docs_enabled) + +subdir('po') +subdir('data') +subdir('src') +subdir('script') +subdir('docs') + +install_data('LICENSE', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name())) +install_data('README.md', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name())) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..89dd2f4 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,2 @@ +option('valadocs', type: 'boolean', value: true, description: 'Build valadocs for sernatur') +option('valadocs_deps', type: 'boolean', value: false, description: 'Build the valadocs of the deps of sernatur') diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 0000000..8357fca --- /dev/null +++ b/po/LINGUAS @@ -0,0 +1 @@ +es diff --git a/po/POTFILES b/po/POTFILES new file mode 100644 index 0000000..6251550 --- /dev/null +++ b/po/POTFILES @@ -0,0 +1,3 @@ +src/sernatur.vala +src/sernatur-window.vala +data/ui/sernatur.window.ui diff --git a/po/es.po b/po/es.po new file mode 100644 index 0000000..ee7b6f0 --- /dev/null +++ b/po/es.po @@ -0,0 +1,23 @@ +# Spanish translations for sernatur package. +# Copyright (C) 2018 THE sernatur'S COPYRIGHT HOLDER +# This file is distributed under the same license as the sernatur package. +# Automatically generated, 2018. +# +msgid "" +msgstr "" +"Project-Id-Version: sernatur\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-10-18 16:05-0300\n" +"PO-Revision-Date: 2018-10-18 14:58-0300\n" +"Last-Translator: Chris Cromer \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.0.6\n" + +#: src/sernatur-window.vala:51 +msgid "Server version:" +msgstr "Versión del servidor:" diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 0000000..7ee0972 --- /dev/null +++ b/po/meson.build @@ -0,0 +1,4 @@ +i18n = import('i18n') +i18n.gettext(meson.project_name(), + args: '--directory=' + meson.source_root() +) diff --git a/po/sernatur.pot b/po/sernatur.pot new file mode 100644 index 0000000..9842667 --- /dev/null +++ b/po/sernatur.pot @@ -0,0 +1,22 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the sernatur package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: sernatur\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-10-18 16:05-0300\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/sernatur-window.vala:51 +msgid "Server version:" +msgstr "" diff --git a/script/linux_bundler.sh b/script/linux_bundler.sh new file mode 100755 index 0000000..6451184 --- /dev/null +++ b/script/linux_bundler.sh @@ -0,0 +1,8 @@ +#!/bin/sh -eu + +libdir="${MESON_INSTALL_PREFIX}/lib" +mkdir -p $libdir + +libfile=`ldd ${MESON_INSTALL_PREFIX}/bin/sernatur | grep libpq | cut -d ' ' -f 3` +cp $libfile "${libdir}" +strip "${libdir}/libpq"* diff --git a/script/meson.build b/script/meson.build new file mode 100644 index 0000000..a7e977c --- /dev/null +++ b/script/meson.build @@ -0,0 +1,2 @@ +install_data('sernatur.sh', install_dir: '.') +meson.add_install_script('linux_bundler.sh') diff --git a/script/sernatur.sh b/script/sernatur.sh new file mode 100755 index 0000000..081f85c --- /dev/null +++ b/script/sernatur.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +cd "${0%/*}" + +export LD_LIBRARY_PATH="`pwd`/lib" +bin/sernatur diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..9ad4e92 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,39 @@ +gtk_dep = dependency('gtk+-3.0', version: '>=3.0.0') +# gmodule-export-2.0 is needed to connect the handlers +gmodule_dep = dependency('gmodule-2.0', version: '>=2.0') +libpq_dep = dependency('libpq') + +# this is how to link against a c lib +#libsystemd_lib = meson.get_compiler('c').find_library('libsystemd') + +cc = meson.get_compiler('c') + +# -no-pie so that the executable is double clickable in gui +if cc.get_id() == 'gcc' + c_args = ['-no-pie'] + link_args = ['-no-pie'] +else + c_args = '' + link_args = '' +endif + +vala_sources = files( + 'sernatur.vala', + 'sernatur-window.vala' +) +sources = vala_sources +c_sources = [sernatur_gresource_c] + +sources = vala_sources +sources += c_sources + +vala_args = ['--vapidir='+join_paths(meson.source_root(),'src/vapi')] +vala_args += ['--gresources='+join_paths(meson.source_root(),'data/ui/sernatur.gresource.xml')] + +exe = executable('sernatur', + sources, + c_args: c_args, + link_args: link_args, + vala_args: vala_args, + dependencies: [gtk_dep, gmodule_dep, libpq_dep], + install: true) diff --git a/src/sernatur-window.vala b/src/sernatur-window.vala new file mode 100644 index 0000000..5f88ca6 --- /dev/null +++ b/src/sernatur-window.vala @@ -0,0 +1,54 @@ +/** + * 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 ()); + } + } +} diff --git a/src/sernatur.vala b/src/sernatur.vala new file mode 100644 index 0000000..bfb9942 --- /dev/null +++ b/src/sernatur.vala @@ -0,0 +1,47 @@ +/** + * The main Sernatur namespace + */ +namespace Sernatur { + /** + * The application class + */ + public class Application : global::Gtk.Application { + /** + * The main application window + */ + private MainWindow window; + + /** + * Initialize the application + */ + public Application () { + application_id = "cl.cromer.ubb.sernatur"; + } + + /** + * Run when the application is activated + */ + public override void activate () { + window = new MainWindow (this); + window.present (); + } + + /** + * Run when the application starts + */ + public override void startup () { + Intl.textdomain ("sernatur"); + Intl.setlocale (LocaleCategory.ALL, ""); + base.startup (); + } + } + + /** + * The main function + * @param args Arguments passed from the command line + */ + public static int main (string[] args) { + var application = new Application (); + return application.run (args); + } +}