/usr/share/perl5/ClamTk/Assistant.pm is in clamtk 5.20-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | # ClamTk, copyright (C) 2004-2015 Dave M
#
# This file is part of ClamTk (http://code.google.com/p/clamtk/).
#
# ClamTk is free software; you can redistribute it and/or modify it
# under the terms of either:
#
# a) the GNU General Public License as published by the Free Software
# Foundation; either version 1, or (at your option) any later version, or
#
# b) the "Artistic License".
package ClamTk::Assistant;
use Glib 'TRUE', 'FALSE';
# use strict;
# use warnings;
$| = 1;
use File::Copy 'copy';
use Locale::gettext;
my $pref;
sub show_window {
my $box = Gtk2::VBox->new( FALSE, 0 );
$box->set_border_width( 12 );
# Get current update preference
$pref = ClamTk::Prefs->get_preference( 'Update' );
# Just in case, set it to 'shared' if nothing else:
$pref ||= 'shared';
#<<<
my $label = Gtk2::Label->new(
_(
'Please choose how you will update your antivirus signatures'
)
);
#>>>
my $flabel = Gtk2::Label->new;
$flabel->set_markup( "<b>" . $label->get_label . "</b>" );
$flabel->set_alignment( 0.0, 0.5 );
$box->pack_start( $flabel, FALSE, FALSE, 10 );
my $bbox = Gtk2::VButtonBox->new;
$bbox->can_focus( FALSE );
$bbox->set_spacing_default( 5 );
$bbox->set_layout_default( 'start' );
$box->add( $bbox );
#<<<
my $auto_button = Gtk2::RadioButton->new_with_label_from_widget(
undef,
_('My computer automatically receives updates')
);
$auto_button->can_focus( FALSE );
$auto_button->signal_connect(
toggled => sub {
if( $auto_button->get_active ) {
$pref = 'shared';
} else {
$pref = 'single';
}
}
);
my $man_button = Gtk2::RadioButton->new_from_widget( $auto_button );
$man_button->set_label(
_('I would like to update signatures myself')
);
$man_button->can_focus( FALSE );
$man_button->signal_connect(
toggled => sub {
if( $man_button->get_active ) {
$pref = 'single';
} else {
$pref = 'shared';
}
}
);
#>>>
$bbox->pack_start( $auto_button, FALSE, FALSE, 0 );
$bbox->pack_start( $man_button, FALSE, FALSE, 0 );
if ( $pref eq 'shared' ) {
$auto_button->set_active( TRUE );
} elsif ( $pref eq 'single' ) {
$man_button->set_active( TRUE );
}
my $infobar = Gtk2::InfoBar->new;
$infobar->set_message_type( 'other' );
$box->pack_start( $infobar, FALSE, FALSE, 10 );
$label = Gtk2::Label->new( _( 'Press Apply to save changes' ) );
$infobar->get_content_area->add( $label );
$infobar->add_button( 'gtk-apply', -10 );
$infobar->signal_connect(
response => sub {
my ( $bar, $sig ) = @_;
Gtk2->main_iteration while Gtk2->events_pending;
$label->set_text( _( 'Please wait...' ) );
Gtk2->main_iteration while Gtk2->events_pending;
if ( save() ) {
set_infobar_text( TRUE, $bar );
} else {
set_infobar_text( FALSE, $bar );
}
}
);
$box->show_all();
return $box;
}
sub set_infobar_text {
my ( $success, $bar ) = @_;
# The text we display
my $label;
# The message type of infobar we display
my $type;
if ( $success ) {
$label = _( 'Your changes were saved.' );
$type = 'info';
} else {
$label = _( 'Error updating: try again later' );
$type = 'error';
}
for my $child ( $bar->get_content_area->get_children ) {
if ( $child->isa( 'Gtk2::Label' ) ) {
$child->set_text( $label );
}
}
$bar->set_message_type( $type );
my $loop = Glib::MainLoop->new;
Glib::Timeout->add(
2000,
sub {
$loop->quit;
FALSE;
}
);
$loop->run;
$bar->set_message_type( 'other' );
#for my $child ( $bar->get_content_area->get_children ) {
for my $child ( $bar->get_children ) {
if ( $child->isa( 'Gtk2::Label' ) ) {
$child->set_text( _( 'Press Apply to save changes' ) );
}
}
Gtk2->main_iteration while Gtk2->events_pending;
}
sub save {
my ( $ret ) = ClamTk::Prefs->set_preference( 'Update', $pref );
if ( $ret == 1 ) {
# It worked, so see if there are system signatures around
# we can copy to save bandwidth and time
my $paths = ClamTk::App->get_path( 'db' );
if ( $pref eq 'single' ) {
my ( $d, $m ) = ( 0 ) x 2;
Gtk2->main_iteration while ( Gtk2->events_pending );
for my $dir_list (
'/var/clamav', '/var/lib/clamav',
'/opt/local/share/clamav', '/usr/share/clamav',
'/usr/local/share/clamav', '/var/db/clamav',
)
{
if ( -e "$dir_list/daily.cld" ) {
copy( "$dir_list/daily.cld", "$paths/daily.cld" );
$d = 1;
} elsif ( -e "$dir_list/daily.cvd" ) {
copy( "$dir_list/daily.cvd", "$paths/daily.cvd" );
$d = 1;
}
if ( -e "$dir_list/main.cld" ) {
copy( "$dir_list/main.cld", "$paths/main.cld" );
$m = 1;
} elsif ( -e "$dir_list/main.cvd" ) {
copy( "$dir_list/main.cvd", "$paths/main.cvd" );
$m = 1;
}
if ( -e "$dir_list/bytecode.cld" ) {
copy( "$dir_list/bytecode.cld", "$paths/bytecode.cld" );
}
last if ( $d && $m );
}
}
}
# Update statusbar
Gtk2->main_iteration while Gtk2->events_pending;
ClamTk::GUI->startup();
Gtk2->main_iteration while Gtk2->events_pending;
return 1;
}
1;
|