package MToken::DeviceSkel; # $Id: DeviceSkel.pm 101 2021-10-09 18:57:43Z minus $
use strict;
use utf8;

=encoding utf8

=head1 NAME

MToken::DeviceSkel - Internal helper's methods for MToken

=head1 VIRSION

Version 1.01

=head1 SYNOPSIS

none

=head1 DESCRIPTION

Internal helper's methods for MToken

no public methods

=head2 build, dirs, pool

Main methods. For internal use only

=head1 SEE ALSO

L<MToken>, L<CTK::Skel>

=head1 AUTHOR

Serż Minus (Sergey Lepenkov) L<http://www.serzik.com> E<lt>abalama@cpan.orgE<gt>

=head1 COPYRIGHT

Copyright (C) 1998-2021 D&D Corporation. All Rights Reserved

=head1 LICENSE

This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

See C<LICENSE> file and L<https://dev.perl.org/licenses/>

=cut

use constant SIGNATURE => "device";

use vars qw/ $VERSION /;
$VERSION = '1.01';

use MToken::Const qw/DIR_PRIVATE DEVICE_CONF_FILE DEVICE_MANIFEST_FILE DB_FILE/;

sub build { # Building
    my $self = shift;

    my $rplc = $self->{rplc};
    $rplc->{TODO} = "TODO";
    $rplc->{ENDSIGN} = "__END__"; # END signature
    $rplc->{DIR_PRIVATE} = DIR_PRIVATE;
    $rplc->{DEVICE_CONF_FILE} = DEVICE_CONF_FILE;
    $rplc->{DEVICE_MANIFEST_FILE} = DEVICE_MANIFEST_FILE;
    $rplc->{DB_FILE} = DB_FILE;

    $self->maybe::next::method();
    return 1;
}
sub dirs { # Directories and permissions as array of hashs
    my $self = shift;
    $self->{subdirs}{(SIGNATURE)} = [
        {
            path => DIR_PRIVATE,
            mode => 0755,
        },
    ];
    $self->maybe::next::method();
    return 1;
}
sub pool { # Multipart pool of files
    my $self = shift;
    my $pos =  tell DATA;
    my $data = scalar(do { local $/; <DATA> });
    seek DATA, $pos, 0;
    $self->{pools}{(SIGNATURE)} = $data;
    $self->maybe::next::method();
    return 1;
}

1;

__DATA__

-----BEGIN FILE-----
Name: DESCRIPTION
File: DESCRIPTION
Mode: 666

################################################################################
##
## MTOKEN      : %TOKEN_NAME%
## GENERATED   : %GMT%
## PACKAGE     : %PACKAGE% %VERSION%
##
################################################################################

This token device (folder or storage) holds keys and tokens for access to
various systems, web-sites, programs and etc.

-----END FILE-----

-----BEGIN FILE-----
Name: README
File: README
Mode: 666

This token device (folder or storage) holds keys and tokens for access to
various systems, web-sites, programs and etc.

-----END FILE-----

-----BEGIN FILE-----
Name: %DEVICE_CONF_FILE%
File: %DIR_PRIVATE%/%DEVICE_CONF_FILE%
Mode: 666

#
# This file contains data for device configuration (dconfig)
# Local configuration holda in "%DIR_PRIVATE%" directory of
# your home directory (lconfig)
# See also the global config file (gconfig) that is located in the
# system config directory (/etc/mtoken)
#

## General
TOKEN       %TOKEN_NAME%
SERVER_URL  %SERVER_URL%

-----END FILE-----

-----BEGIN FILE-----
Name: %DEVICE_CONF_FILE%
File: %DIR_PRIVATE%/%DEVICE_MANIFEST_FILE%
Mode: 666

%DIR_PRIVATE%/%DEVICE_MANIFEST_FILE%
%DIR_PRIVATE%/%DEVICE_CONF_FILE%
%DIR_PRIVATE%/%DB_FILE%
README
DESCRIPTION
-----END FILE-----

-----BEGIN FILE-----
Name: LICENSE
File: LICENSE
Mode: 644
Encode: base64

[encoded data, 47432 characters]
b3JnL3BoaWxvc29waHkvd2h5LW5vdC1sZ3BsLmh0bWw+Lgo=
-----END FILE-----
