| 1 | package Plagger::Plugin::Notify::OpenBrowser::FirefoxRemote; | ||
| 2 | use base qw( Plagger::Plugin::Notify::OpenBrowser ); | ||
| 3 | |||
| 4 | use strict; | ||
| 5 | use Net::Telnet; | ||
| 6 | |||
| 7 | sub init { | ||
| 8 | my $self = shift; | ||
| 9 | $self->Plagger::Plugin::init(@_); # Don't call SUPER::init which does auto-dispatch | ||
| 10 | } | ||
| 11 | |||
| 12 | sub open { | ||
| 13 | my($self, $link) = @_; | ||
| 14 | |||
| 15 | $self->{conn} ||= do { | ||
| 16 | my $host = $self->conf->{host} || "localhost"; | ||
| 17 | my $port = $self->conf->{port} || 4242; | ||
| 18 | my $telnet = Net::Telnet->new(Port => $port); | ||
| 19 | $telnet->open($host) | ||
| 20 | or return $self->log(error => "Can't connect to $host:$port"); | ||
| 21 | $self->log(info => "Connect MozRepl at $host:$port"); | ||
| 22 | $telnet; | ||
| 23 | }; | ||
| 24 | |||
| 25 | $self->log(info => "Open $link in a remote Firefox"); | ||
| 26 | $self->{conn}->cmd("window.openNewTabWith('$link')"); | ||
| 27 | } | ||
| 28 | |||
| 29 | 1; | ||
| 30 | |||
| 31 | __END__ |