From 27eeef5382c1b3693c6ab64391cac17de9dc0016 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 6 Jun 2007 15:52:32 +0200 Subject: [PATCH] Parts of local history. --- submit/MO/Submit.pm | 12 +++++++++++- submit/contest | 19 ++++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/submit/MO/Submit.pm b/submit/MO/Submit.pm index 15e6d7c..a375058 100644 --- a/submit/MO/Submit.pm +++ b/submit/MO/Submit.pm @@ -9,6 +9,7 @@ use warnings; use IO::Socket::INET; use IO::Socket::SSL; # qw(debug3); use Sherlock::Object; +use POSIX; sub new($) { my $user = $ENV{"USER"} or die "Environment variable USER not set\n"; @@ -18,10 +19,12 @@ sub new($) { my $self = { "Contest" => "CPSPC 2007", "Server" => "localhost:8888", - "Key" => "$mo/key.pem", + "Key" => "$mo/key.pem", # Keys and certificates "Cert" => "$mo/cert.pem", "CACert" => "$mo/ca-cert.pem", "Trace" => defined $ENV{"MO_SUBMIT_TRACE"}, + "History" => "$home/.history"; # Keep submission history in this directory + "RefreshTimer" => 5000, # How often GUI sends STATUS commands [ms] "user" => $user, "sk" => undef, "error" => undef, @@ -159,4 +162,11 @@ sub send_file($$$) { return $self->reply; } +sub local_submit($$$$$) { + my ($self, $task, $part, $ext, $filename) = @_; + my $hist = $self->{"History"}; + -d $hist or mkdir $hist or return "Unable to create $hist: $!"; + ### FIXME: Unfinished +} + 1; diff --git a/submit/contest b/submit/contest index 0246cad..0c2e022 100755 --- a/submit/contest +++ b/submit/contest @@ -159,7 +159,7 @@ sub start_refresh_timer($) { my ($go) = @_; stop_refresh_timer(); refresh() if $go; - $refresh_timer_id = Glib::Timeout->add(5000, \&timed_refresh); + $refresh_timer_id = Glib::Timeout->add($conn->{"RefreshTimer}, \&timed_refresh); } sub stop_refresh_timer() { @@ -308,8 +308,19 @@ sub submit_failed($) { } sub run_submit() { + my ($task, $part) = split /\//, $selected_task; + defined $part or $part = $task; + + if (defined $conn->{"History"}) { + busy("Submitting locally"); + my $err = $conn->local_submit($task, $part, $submit_extension, $submit_filename); + if (defined $err) { + submit_failed("Recording to local history failed\n($err)"); + return; + } + } + if ($conn->is_connected) { - ### FIXME: Busy cursor should be started earlier busy("Checking server status..."); my $r = new Sherlock::Object("!" => "STATUS"); ### FIXME: use a NOP command $r = $conn->request($r); @@ -319,13 +330,11 @@ sub run_submit() { if (!$conn->connect) { ready($conn->{"error"}); submit_failed("Unable to connect to the server"); ### FIXME: Mention local submit + return; } } busy("Submitting..."); - my ($task, $part) = split /\//, $selected_task; - defined $part or $part = $task; - my $fh = new IO::File($submit_filename); if (!$fh) { submit_failed("Unable to open $submit_filename\n($!)"); -- 2.39.2