ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/MapWidget.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/MapWidget.pm (file contents):
Revision 1.83 by root, Sun Oct 1 14:48:51 2006 UTC vs.
Revision 1.84 by root, Sun Oct 1 18:17:38 2006 UTC

78 local $ENV{CFPLUS_LOGIN} = $::PROFILE->{user}; 78 local $ENV{CFPLUS_LOGIN} = $::PROFILE->{user};
79 local $ENV{CFPLUS_PASSWORD} = $::PROFILE->{password}; 79 local $ENV{CFPLUS_PASSWORD} = $::PROFILE->{password};
80 local $ENV{CFPLUS_UPLOAD} = $::CONN->{upload}; 80 local $ENV{CFPLUS_UPLOAD} = $::CONN->{upload};
81 local $ENV{CROSSFIRE_MAPDIR} = $::CONN->{cvs_root}; 81 local $ENV{CROSSFIRE_MAPDIR} = $::CONN->{cvs_root};
82 82
83# CFPlus::set_proxy; 83 CFPlus::set_proxy;
84 84
85 my $map = "map:$::CONN->{map_info}[0]";
86
87 if (fork == 0) {
88 $SIG{__DIE__} = sub {
89 warn "@_";
90 CFPlus::_exit 99;
91 };
92
85 # TODO: move into editor 93 # TODO: move into editor
86 require LWP::Simple; 94 require LWP::UserAgent;
95
96 my $ua = LWP::UserAgent->new (
97 agent => "cfplus $CFPlus::VERSION",
98 keep_alive => 1,
99 env_proxy => 1,
100 );
101
102 if ($map =~ /^map:(.*)/) {
103 my $mapname = $1;
104 # try to get the most recent head revision, what a hack
105 my $log = $ua->get ("$ENV{CROSSFIRE_MAPDIR}/$mapname?view=log&logsort=rev")->decoded_content;
106
107 if ($log =~ /\?rev=(\d+\.\d+)"/) {
108 my $rev = $1;
109 my $map = $ua->get ("$ENV{CROSSFIRE_MAPDIR}/$mapname?rev=$rev")->decoded_content;
110 warn "revision is $rev " .(length $map)."\n";#d#
111
112 # now upload it
113 my $comment = "some comment";
114
115 require HTTP::Request::Common;
116
117 my $res = $ua->post (
118 $ENV{CFPLUS_UPLOAD},
119 Content_Type => 'multipart/form-data',
120 Content => [
121 path => $mapname,
122 mapdir => $ENV{CROSSFIRE_MAPDIR},
123 map => $map,
124 revision => $rev,
125 cf_login => $ENV{CFPLUS_LOGIN},
126 cf_password => $ENV{CFPLUS_PASSWORD},
127 comment => "",
128 ]
129 );
130
131 if ($res->is_error) {
132 # fatal condition
133 warn $res->status_line;
134 } else {
135 # script replies are marked as {{..}}
136 my @msgs = $res->decoded_content =~ m/\{\{(.*?)\}\}/g;
137 warn map "$_\n", @msgs;
138 }
139 } else {
140 # error, could not detect revision
141 }
142 }
143
144 CFPlus::_exit;
145 }
87} 146}
88 147
89sub invoke_button_down { 148sub invoke_button_down {
90 my ($self, $ev, $x, $y) = @_; 149 my ($self, $ev, $x, $y) = @_;
91 150
134 ? "Disable automatic pickup" 193 ? "Disable automatic pickup"
135 : "Enable automatic pickup", 194 : "Enable automatic pickup",
136 sub { $::PICKUP_ENABLE->toggle } 195 sub { $::PICKUP_ENABLE->toggle }
137 ], 196 ],
138 $::CONN && length $::CONN->{cvs_root} 197 $::CONN && length $::CONN->{cvs_root}
139 ? ["Edit this map <span size='xx-small'>(" . (CFPlus::asxml $::CONN->{map_info}[0]) . ")</span>", \&editor_invoke] 198 ? ["Edit this map <span size='xx-small'>(" . (CFPlus::asxml $::CONN->{map_info}[0]) . ")</span>",
199 \&editor_invoke]
140 : (), 200 : (),
141 $::CONN && length $::CONN->{test_server} 201 $::CONN && length $::CONN->{test_server}
142 ? ["Login on Test Server", \&test_server_login] 202 ? ["Login on Test Server <span size='xx-small'>(" . (CFPlus::asxml $::CONN->{test_server}) . ")</span>",
203 \&test_server_login]
143 : (), 204 : (),
144 ["Quit", 205 ["Quit",
145 sub { 206 sub {
146 if ($::CONN) { 207 if ($::CONN) {
147 &::open_quit_dialog; 208 &::open_quit_dialog;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines