App-USBKeyCopyCon

 view release on metacpan or  search on metacpan

lib/App/USBKeyCopyCon.pm  view on Meta::CPAN

    }

    if($done) {
        foreach my $key_info (values %$current_keys) {
            if($key_info->{status} >= 0 and $key_info->{status}  < 10) {
                $done = 0;
                last;
            }
        }
        $self->play_sound_file if $done;
    }
    return TRUE;
}


sub set_temp_root {
    my($self, $new_temp) = @_;

    $self->clean_temp_dir;

    $self->temp_root($new_temp);
    my $temp_dir = "$new_temp/usb-copy.$$";

    my $path = "$temp_dir/master";
    $self->master_root($path);
    mkpath($path, { mode => 0700 }) if not -d $path;

    $path = "$temp_dir/mount";
    $self->mount_dir($path);
    mkpath($path, { mode => 0700 }) if not -d $path;

    return;
}


sub clean_temp_dir {
    my $self = shift;

    my $path = $self->master_root or return;
    $path =~ s{/master$}{};
    if(-d $path and $self->sudo_path and $self->current_state ne 'MASTER-WAIT') {
        my $command = $self->sudo_wrap("chown -R $< $path");
        system($command);
    }
    rmtree($path) if -d $path;
}


sub run {
    my $self = shift;

    # Arrange to catch exit status of child processes
    my $exit_status = $self->exit_status;
    $SIG{CHLD} = sub {
        my $pid;
        do {
            $pid = waitpid(-1, WNOHANG);
            $exit_status->{$pid} = $? if $pid > 0;
        } while $pid > 0;
    };
    Glib::Timeout->add(500, sub { $self->tick });

    Gtk2->main;

    $self->restore_automount;
    $self->clean_temp_dir;
}


1;

__END__

=head1 ATTRIBUTES

The application object has the following attributes (with correspondingly named
accessor methods):

=over 4

=item app_win

The main Gtk2::Window object.

=item automount_state

Stores the enabled state ('true' or 'false') of the GNOME/Nautilus media
automount option.  The function will be disabled on startup and this value will
be restored on exit.

=item capacity_combo

The Gtk2::ComboBox object for the device filter 'Capacity' drop-down menu.

=item capacity_entry

The Gtk2::Entry object for the device filter 'Capacity' text entry box.

=item console

The Gtk2::TextView object used for writing output messages.

=item current_keys

A hash for tracking which (non-master) keys are currently inserted and what
stage each copy process is at.  The hash key is the device 'UDI' and the value
is a hash of device dtails .

=item current_state

Used to control which mode the application is in:

  MASTER-WAIT    waiting for the user to insert the master key
  MASTER-COPYING waiting for the master key 'reader' script to complete
  MASTER-COPIED  waiting for the user to remove the master key
  COPYING        waiting for the user to insert blank keys

=item exit_status

Used by a SIGCHLD handler to track the exit status of the copy scripts.  The
key is a process ID and the value is the exist status returned by C<wait>.

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.514 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )