use strict; use Pos::Webtop::Toolbox (); use Pos::Policy::LayeredBurrito (); use Pos::Webtop::Web::ContentModule::UserPrefs::PrefModule (); # derived class package Pos::Webtop::Web::ContentModule::UserPrefs::PrefModule::DesktopWallpaper; my $className = "Pos::Webtop::Web::ContentModule::UserPrefs::PrefModule::DesktopWallpaper"; our @ISA = qw( Pos::Webtop::Web::ContentModule::UserPrefs::PrefModule ); sub new { my $this = shift; my $class = ref($this) || $this; my ($self) = @{{@_}}{qw/self/}; if ( not defined $self ) { $self = {}; bless($self,$class); } my %args = @_; $args{'self'} = $self; Pos::Webtop::Web::ContentModule::UserPrefs::PrefModule->new( %args ); $self->setPreferenceName( preferenceName=> "Desktop Wallpaper" ); $self->setPolicyTypeId( policyTypeId=> 160 ); return $self; } # these can be cut and pasted from the polyp script .. I have # made the pref form use the same hash to generate the color # map on the page for the end user my %colors = (); $colors{'BLACK'} = "0 0 0"; $colors{'BLUE'} = "0 0 255"; $colors{'DARK BLUE'} = "0 0 139"; $colors{'DARK GREEN'} = "0 139 0"; $colors{'DARK RED'} = "139 0 0"; $colors{'GREEN'} = "0 255 0"; $colors{'LIGHT BLUE'} = "173 216 230"; $colors{'PINK'} = "255 20 147"; $colors{'PURPLE'} = "160 32 240"; $colors{'TURQOISE'} = "64 224 208"; $colors{'RED'} = "255 0 0"; $colors{'WHITE'} = "255 255 255"; $colors{'YELLOW'} = "255 255 0"; $colors{'GREY'} = "100 100 100"; $colors{'LIGHT GREY'} = "238 238 238"; # implemented pure virtual sub getEmbeddedHtml { my $self = shift; my $toolBox = $self->getToolBox(); my $client = $toolBox->getClient(); my $cgi = $toolBox->getCgi(); my $pdb = $toolBox->getPolicyDb(); my $dbr = $toolBox->getWebtopDbReader(); my $policyValues = $self->getPolicyValues(); my $value = ""; foreach my $val ( @{ $policyValues } ) { $value = $val->{'policyValue'}; } my @info = (); my ($file,$align,$color) = split /\s*;\s*/, $value; $file = "" unless defined $file; $align = 'CENTER' unless defined $align; $color = 'WHITE' unless defined $color; # we also check the persisted values just in case we are moving back or between steps my $persistedFile = $client->getPersistedValue( name=> "file" ); my $persistedAlign = $client->getPersistedValue( name=> "align" ); my $persistedColor = $client->getPersistedValue( name=> "color" ); if ( defined $persistedFile ) { $file = $persistedFile; $client->repersistValues( values=> ["file"] ); } if ( defined $persistedAlign ) { $align = $persistedAlign; $client->repersistValues( values=> ["align"] ); } if ( defined $persistedColor ) { $color = $persistedColor; $client->repersistValues( values=> ["color"] ); } my $providedFileId = ""; my $existingFile = ""; if ( $file =~ /^\d+$/ ) { # it's a pk $providedFileId = $file; } else { $existingFile = $file; } my $totalSteps = 3; my $ret = ""; $ret .= $self->getEmbeddedHeader(); $ret .= "
"; # the following was in step 2 but we took it out and just check for defined on fileType my $fileType = $cgi->param('fileType'); my $bgImage; if ( defined $fileType ) { if ( $fileType eq "1" ) { # they picked a pk.. get val from the providedFile $bgImage = $cgi->param('providedFile'); } elsif ( $fileType eq "2" ) { $bgImage = $cgi->param('existingFile'); } else { # no image $bgImage = ""; } $client->setPersistedValue( name=> 'file', value=> $bgImage ); } my $wizStep = $cgi->param('wizStep'); $wizStep = -1 unless defined $wizStep; my $cancel = 0; my $finished = 0; my $wizAction = $cgi->param('wizAction'); my $skippedAlign = 0; if ( defined $cgi->param('skippedAlign') and not $cgi->param('skippedAlign') ) { $skippedAlign = 0; $client->setPersistedValue( name=> "skippedAlign", value=> 0 ); } elsif ( ( defined $cgi->param('skippedAlign') and $cgi->param('skippedAlign') ) or ( defined $client->getPersistedValue(name=>"skippedAlign") and $client->getPersistedValue(name=>"skippedAlign") ) ) { $skippedAlign = 1; $client->setPersistedValue( name=> "skippedAlign", value=> 1 ); } if ( defined $wizAction and (uc($wizAction) eq "BACK") ) { $wizStep--; if ( $wizStep eq "1" and $skippedAlign ) { $wizStep--; # skip the step again } } elsif ( defined $wizAction and (uc($wizAction) eq "CANCEL") ) { $cancel = 1; } elsif ( defined $wizAction and (uc($wizAction) eq "FINISH") ) { $finished = 1; } else { $wizStep++; if ( $wizStep eq "1" and $skippedAlign ) { $wizStep++; # skip the step again } } if ( $cancel ) { $self->setDone(); return ""; } elsif ( $finished ) { my $color = $cgi->param('color'); my $policyValue = "$file;$align;$color"; $self->setPolicyValues( values=> [ { type=> "DEFAULT", value=> $policyValue } ] ); $self->setDone(); return ""; } elsif ( $wizStep eq "2" ) { my $align = $cgi->param('align'); $client->setPersistedValue( name=> 'align', value=> $align ); $ret .= "
Step 3 of $totalSteps
Please choose the background color for your desktop. The color you pick below will be the default color used where your background image is not applicable.

"; foreach my $colorName ( sort( keys %colors ) ) { my ($r,$b,$g) = split(/\s/,$colors{$colorName}); my $bgcolor = sprintf("#%02x%02x%02x",$r,$b,$g); $ret .= " "; } $ret .= "
\  \  $colorName

"; $ret .= $client->getFormInputs(); # make the next and back links $ret .= "
"; } elsif ( $wizStep eq "1" ) { $ret .= "
Step 2 of $totalSteps
Please choose how you want your background image displayed on your desktop.

Center
(Your image will be placed in the center of your desktop background--It may or may not cover the entire desktop area)
Tile
(Your image will be placed at the upper left corner of your screen and tiled to fill the remaining area on your desktop)
Stretch
(Your image will be stretched to fill the entire desktop area)

"; $ret .= $client->getFormInputs(); # make the next and back links $ret .= "
"; } else { $ret .= "
Step 1 of $totalSteps
Please choose the background image for your desktop wallpaper. You may either pick a image that has been provided to you from your organization or you may provide the full path to an image allready on the computer you will be using the Positive Networks VPN Client on.

Provided Image
(an image provided for use by your organization--this file will be sent to your computer at login)

Existing Image
(an image on your computer that you wish to use--provide full path to image)

No Image
(Only the background color will be used)
"; $ret .= $client->getFormInputs(); $ret .= "
"; } $ret .= "
\n"; $ret .= $self->getEmbeddedFooter(); return $ret; } # implemented pure virtual sub getPreviewText { my $self = shift; my $policyValues = $self->getPolicyValues(); my $value = ""; my $tb = $self->getToolBox(); my $client = $tb->getClient(); foreach my $val ( @{ $policyValues } ) { $value = $val->{'policyValue'}; } my @info = (); my ($file,$align,$color) = split /\s*;\s*/, $value; if ( defined $file and length($file) ) { if ( $file =~ /^\d+$/ ) { # if all digits, it's a pk to customer file table my $db = $tb->getWebtopDbReader(); my $customerId = $client->getCustomerId(); ($file) = $db->query( sql=> " select source_name from customer_queue_files where customer_id = $customerId and queue_file_id = $file "); } push @info, "Background Image '$file' with $align orientation" } if ( defined $color and length( $color ) ) { push @info, "Background Color $color"; } return join(", ", @info); } 1;