1 | =head1 NAME |
1 | =head1 NAME |
2 | |
2 | |
3 | Mozilla::Plugin - embed perl into mozilla/netscape. |
3 | Browser::Plugin - embed perl into mozilla/netscape/ie/opera. |
4 | |
4 | |
5 | =head1 SYNOPSIS |
5 | =head1 SYNOPSIS |
6 | |
6 | |
7 | use Mozilla::Plugin; |
7 | use Browser::Plugin; |
8 | |
8 | |
9 | =head1 DESCRIPTION |
9 | =head1 DESCRIPTION |
10 | |
10 | |
11 | sorry... |
11 | sorry... |
12 | |
12 | |
13 | =over 4 |
13 | =over 4 |
14 | |
14 | |
15 | =cut |
15 | =cut |
16 | |
16 | |
17 | package Mozilla::Plugin; |
17 | package Browser::Plugin; |
18 | |
18 | |
19 | use base Exporter; |
19 | use base Exporter; |
20 | use Storable; |
20 | use Storable; |
21 | #use XSLoader; |
21 | #use XSLoader; |
22 | |
22 | |
23 | $VERSION = 0.01; |
23 | $VERSION = 0.01; |
24 | @EXPORT = qw(); |
24 | @EXPORT = qw(); |
25 | |
25 | |
26 | #XSLoader::load __PACKAGE__, $VERSION; |
26 | #XSLoader::load __PACKAGE__, $VERSION; |
27 | |
27 | |
28 | my $interface; # Mozilla::Plugin::xxx (design weakness) |
28 | my $interface; # Browser::Plugin::xxx (design weakness) |
29 | |
29 | |
30 | my $debug = 1; |
30 | my $debug = 1; |
31 | |
31 | |
32 | sub NP_VERSION_MAJOR (){ 0 } |
32 | sub NP_VERSION_MAJOR (){ 0 } |
33 | sub NP_VERSION_MINOR (){ 9 } |
33 | sub NP_VERSION_MINOR (){ 9 } |
… | |
… | |
208 | lastmodified => rcv_u32, |
208 | lastmodified => rcv_u32, |
209 | notifydata => rcv_u32, |
209 | notifydata => rcv_u32, |
210 | seekable => rcv_u32, |
210 | seekable => rcv_u32, |
211 | push_stream => 1, |
211 | push_stream => 1, |
212 | ); |
212 | ); |
213 | my $str = $_OBJ{$args{id}} = new Mozilla::Stream::Receive \%args; |
213 | my $str = $_OBJ{$args{id}} = new Browser::Stream::Receive \%args; |
214 | |
214 | |
215 | my ($stype, $err) = $obj->push_stream($str); |
215 | my ($stype, $err) = $obj->push_stream($str); |
216 | |
216 | |
217 | snd_cmd 'N'; |
217 | snd_cmd 'N'; |
218 | snd_u32 $err; |
218 | snd_u32 $err; |
… | |
… | |
373 | snd_blk $target; |
373 | snd_blk $target; |
374 | if (snd_snd) { |
374 | if (snd_snd) { |
375 | rcv_cmd 'n'; |
375 | rcv_cmd 'n'; |
376 | $error = rcv_u32; |
376 | $error = rcv_u32; |
377 | unless ($error) { |
377 | unless ($error) { |
378 | $stream = new Mozilla::Stream::Send ( |
378 | $stream = new Browser::Stream::Send ( |
379 | instance => $self, |
379 | instance => $self, |
380 | mimetype => $type, |
380 | mimetype => $type, |
381 | id => rcv_ptr, |
381 | id => rcv_ptr, |
382 | url => $target, |
382 | url => $target, |
383 | ); |
383 | ); |
… | |
… | |
402 | $error = rcv_i32; |
402 | $error = rcv_i32; |
403 | } |
403 | } |
404 | $error; |
404 | $error; |
405 | } |
405 | } |
406 | |
406 | |
407 | sub Mozilla::Stream::new { |
407 | sub Browser::Stream::new { |
408 | bless $_[1], $_[0]; |
408 | bless $_[1], $_[0]; |
409 | } |
409 | } |
410 | |
410 | |
411 | sub Mozilla::Stream::destroy { |
411 | sub Browser::Stream::destroy { |
412 | my $str = shift; |
412 | my $str = shift; |
413 | my $error = shift; |
413 | my $error = shift; |
414 | unless ($str->{destroyed}) { |
414 | unless ($str->{destroyed}) { |
415 | $str->{destroyed}++; |
415 | $str->{destroyed}++; |
416 | |
416 | |
… | |
… | |
421 | snd_u32 $error || NPERR_NO_ERROR; |
421 | snd_u32 $error || NPERR_NO_ERROR; |
422 | snd_snd; |
422 | snd_snd; |
423 | } |
423 | } |
424 | } |
424 | } |
425 | |
425 | |
426 | *Mozilla::Stream::DESTROY = \&Mozilla::Stream::destroy; |
426 | *Browser::Stream::DESTROY = \&Browser::Stream::destroy; |
427 | |
427 | |
428 | BEGIN { |
428 | BEGIN { |
429 | @Mozilla::Stream::Receive::ISA = Mozilla::Stream; |
429 | @Browser::Stream::Receive::ISA = Browser::Stream; |
430 | } |
430 | } |
431 | |
431 | |
432 | sub Mozilla::Stream::Receive::write { |
432 | sub Browser::Stream::Receive::write { |
433 | # ... |
433 | # ... |
434 | } |
434 | } |
435 | |
435 | |
436 | BEGIN { |
436 | BEGIN { |
437 | @Mozilla::Stream::Send::ISA = Mozilla::Stream; |
437 | @Browser::Stream::Send::ISA = Browser::Stream; |
438 | } |
438 | } |
439 | |
439 | |
440 | =item $bytes = $stream->write($data) |
440 | =item $bytes = $stream->write($data) |
441 | |
441 | |
442 | =cut |
442 | =cut |
443 | |
443 | |
444 | sub Mozilla::Stream::Send::write { |
444 | sub Browser::Stream::Send::write { |
445 | my $str = shift; |
445 | my $str = shift; |
446 | my $obj = $self->{instance}; |
446 | my $obj = $self->{instance}; |
447 | |
447 | |
448 | snd_cmd 'w'; |
448 | snd_cmd 'w'; |
449 | snd_ptr $obj->{id}; |
449 | snd_ptr $obj->{id}; |