--- Net-FCP/FCP.pm 2003/12/10 02:36:37 1.26 +++ Net-FCP/FCP.pm 2004/05/13 15:41:01 1.27 @@ -101,7 +101,8 @@ sub tolc($) { local $_ = shift; - 1 while s/(SVK|CHK|URI)/\L$1\_/; + 1 while s/(SVK|CHK|URI)([^_])/$1\_$2/i; + 1 while s/([^_])(SVK|CHK|URI)/$1\_$2/i; s/(?<=[a-z])(?=[A-Z])/_/g; lc $_; } @@ -183,7 +184,7 @@ $meta; } -=item $fcp = new Net::FCP [host => $host][, port => $port] +=item $fcp = new Net::FCP [host => $host][, port => $port][, progress => \&cb] Create a new virtual FCP connection to the given host and port (default 127.0.0.1:8481, or the environment variables C and C). @@ -191,6 +192,16 @@ Connections are virtual because no persistent physical connection is established. +You can install a progress callback that is being called with the Net::FCP +object, a txn object, the type of the transaction and the attributes. Use +it like this: + + sub progress_cb { + my ($self, $txn, $type, $attr) = @_; + + warn "progress<$txn,$type," . (join ":", %$attr) . ">\n"; + } + =begin comment However, the existance of the node is checked by executing a @@ -215,6 +226,9 @@ sub progress { my ($self, $txn, $type, $attr) = @_; + + $self->{progress}->($self, $txn, $type, $attr) + if $self->{progress}; #warn "progress<$txn,$type," . (join ":", %$attr) . ">\n"; } @@ -326,7 +340,7 @@ =item $uri = $fcp->generate_chk ($metadata, $data[, $cipher]) -Calculcates a CHK, given the metadata and data. C<$cipher> is either +Calculates a CHK, given the metadata and data. C<$cipher> is either C or C, with the latter being the default. =cut @@ -404,6 +418,9 @@ freenet. C<$meta> is the metadata (as returned by C or C). +The C<$uri> should begin with C, but the scheme is currently +added, if missing. + Due to the overhead, a better method to download big files should be used. my ($meta, $data) = @{ @@ -612,6 +629,7 @@ $self->{datalen} = hex $1; #warn "expecting new datachunk $self->{datalen}\n";#d# } elsif ($self->{buf} =~ s/^([a-zA-Z]+)\015?\012(?:(.+?)\015?\012)?EndMessage\015?\012//s) { + print "RECV<$1>\n"; $self->rcv ($1, { map { my ($a, $b) = split /=/, $_, 2; ((Net::FCP::tolc $a), $b) } split /\015?\012/, $2 @@ -683,6 +701,7 @@ sub progress { my ($self, $type, $attr) = @_; + $self->{fcp}->progress ($self, $type, $attr); } @@ -771,8 +790,8 @@ use base Net::FCP::Txn; -*rcv_uri_error = \&Net::FCP::Txn::rcv_throw_exception; -*rcv_route_not_found = \&Net::FCP::Txn::rcv_throw_exception; +*rcv_uri_error = \&Net::FCP::Txn::rcv_throw_exception; +*rcv_route_not_found = \&Net::FCP::Txn::rcv_throw_exception; sub rcv_restarted { my ($self, $attr, $type) = @_; @@ -915,9 +934,9 @@ package Net::FCP::Event::Auto; my @models = ( - [Coro => Coro::Event:: ], + [Coro => Coro::Event::], [Event => Event::], - [Glib => Glib:: ], + [Glib => Glib::], [Tk => Tk::], );