--- deliantra/Deliantra-Client/DC/MapWidget.pm 2006/10/08 21:22:30 1.85 +++ deliantra/Deliantra-Client/DC/MapWidget.pm 2006/10/09 01:06:36 1.88 @@ -82,24 +82,7 @@ my $editsup = $::CONN && $::CONN->{editor_support} or return; - # putting the password into the env is somewhat tasteless -# local $ENV{CFPLUS_LOGIN} = $::PROFILE->{user}; -# local $ENV{CFPLUS_PASSWORD} = $::PROFILE->{password}; -# local $ENV{CFPLUS_UPLOAD} = $::CONN->{upload}; - - my ($pid, $fh); - unless ($pid = open $fh, "-|:utf8", "-") { - $SIG{__DIE__} = sub { - warn "@_\n"; - CFPlus::_exit 99; - }; - - open STDERR, ">&STDOUT"; - binmode STDOUT, ":utf8"; - binmode STDERR, ":utf8"; - close $fh; - - $| = 1; + CFPlus::background { print "preparing editor startup...\n"; CFPlus::set_proxy; @@ -131,6 +114,10 @@ if (1) { # upload a map my $mapname = $::CONN->{map_info}[0]; + my $mappath = "$mapdir/$mapname"; + + -e $mappath and die "$mappath already exists\n"; + print "getting map revision for $mapname...\n"; # try to get the most recent head revision, what a hack, @@ -144,6 +131,31 @@ my $map = (check_lwp $ua->get ("$editsup->{cvs_root}/$mapname?rev=$rev"))->decoded_content; + my $meta = { + %$editsup, + path => $mapname, + revision => $rev, + cf_login => $::PROFILE->{user}, + }; + + require File::Basename; + require File::Path; + + File::Path::mkpath (File::Basename::dirname ($mappath)); + open my $fh, ">:raw:perlio", "$mappath.meta" + or die "$mappath.meta: $!\n"; + print $fh CFPlus::to_json $meta; + close $fh; + open my $fh, ">:raw:perlio:utf8", $mappath + or die "$mappath: $!\n"; + print $fh $map; + close $fh; + + print "saved as $mappath\n"; + + print "invoking editor...\n"; + exec "/root/s2/gce $mappath";#d# + # now upload it # require HTTP::Request::Common; # @@ -173,27 +185,7 @@ die "viewvc parse error, unable to detect revision\n"; } } - - print "invoking editor...\n"; - exec "/root/s2/gce";#d# - - CFPlus::_exit; } - - my $buffer; - - Event->io (fd => $fh, poll => 'r', cb => sub { - unless (sysread $fh, $buffer, 4096, length $buffer) { - $_[0]->w->cancel; - $buffer .= "done\n"; - } - - while ($buffer =~ s/^(.*)\n//) { - ::message ({ - markup => "editor($pid): " . CFPlus::asxml $1, - }); - } - }); } sub invoke_button_down {