2014-04-27 03:46:32 +04:00
|
|
|
package Password;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use utf8;
|
|
|
|
|
2014-04-27 23:11:52 +04:00
|
|
|
use Database;
|
2014-04-27 03:46:32 +04:00
|
|
|
|
2014-04-28 12:04:17 +04:00
|
|
|
use PasswordSave;
|
|
|
|
use PasswordShow;
|
|
|
|
|
2014-04-27 03:46:32 +04:00
|
|
|
sub new {
|
|
|
|
my $class = shift;
|
|
|
|
|
2014-04-28 12:04:17 +04:00
|
|
|
my $db = Database->new();
|
|
|
|
|
|
|
|
my $p_save = PasswordSave->new();
|
|
|
|
my $p_show = PasswordShow->new();
|
|
|
|
|
2014-04-27 03:46:32 +04:00
|
|
|
my $self = {
|
2014-04-28 12:04:17 +04:00
|
|
|
_db => $db,
|
|
|
|
_p_save => $p_save,
|
|
|
|
_p_show => $p_show,
|
2014-04-27 03:46:32 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
bless $self, $class;
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
2014-04-28 12:04:17 +04:00
|
|
|
# Check configuration. If it doesn't exist create it.
|
|
|
|
sub check_config {
|
|
|
|
my ($self) = @_;
|
|
|
|
if (-e $ENV->{HOME}."/.PM/db.sqlite") {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
my $db = $self->{_db};
|
|
|
|
$db->create_base();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|