#!/usr/bin/perl # vim: set et ts=4 sw=4: # Copyright 2012 Steven Tucker # Copyright 2013-2016 Matteo Pasotti # Copyright 2014-2016 Angelo Naselli # # This file is part of manatools # # ManaTools is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # ManaTools is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with ManaTools. If not, see . package mpanCommandLine; use Moose; extends 'ManaTools::Shared::GUI::CommandLine'; use ManaTools::Shared::Locales; my $loc = ManaTools::Shared::Locales->new(); has 'devel' => ( is => 'ro', isa => 'Bool', documentation => $loc->N('Developers mode'), ); has 'name' => ( is => 'ro', isa => 'Str', documentation => $loc->N('Application name, used for logging identifier and x application configuration directory. Default mpan'), ); has 'title' => ( is => 'ro', isa => 'Str', documentation => $loc->N('Window title. Default name value'), ); no Moose; __PACKAGE__->meta->make_immutable; 1; use strict; use warnings; use diagnostics; use ManaTools::Privileges; use ManaTools::SettingsReader; use ManaTools::MainDisplay; use yui; my $cmdline = mpanCommandLine->new_with_options(); my $settings = getSettings(); if ($cmdline->devel()) { print $loc->N("== Development mode ON ==") . "\n"; } else { ask_for_authentication($settings->{priv_method}) if is_root_capability_required(); } my $param = {}; $param->{title} = $cmdline->title() if $cmdline->title(); $param->{name} = $cmdline->name() if $cmdline->name(); $param->{configDir} = $cmdline->conf_dir() if $cmdline->conf_dir(); my $mainWin = new ManaTools::MainDisplay($param); while (1) { my $launch = $mainWin->start(); $mainWin->cleanup(); if ($launch) { $launch->start(); } else { last; } } # mpan settings sub getSettings { my ($self) = @_; # yui commandline parser my $confDir = $cmdline->conf_dir() || "/etc"; chop $confDir if substr($confDir, -1) eq '/'; $confDir .= '/mpan'; # configuration file name my $fileName = "$confDir/settings.conf"; my $settingsReader = ManaTools::SettingsReader->new({fileName => $fileName}); return $settingsReader->settings(); } =pod =head1 main main launcher =cut 1;