MozRepl::Plugin::Restart - Restart Firefox/Thunderbird


MozRepl-Plugin-Restart documentation Contained in the MozRepl-Plugin-Restart distribution.

Index


Code Index:

NAME

Top

MozRepl::Plugin::Restart - Restart Firefox/Thunderbird

VERSION

Top

version 0.02

SYNOPSIS

Top

    use MozRepl;

    my $repl = MozRepl->new;
    $repl->setup({ plugins => { plugins => [qw/Restart/] } });

    $repl->restart; ### and restart your Firefox or Thunderbird

DESCRIPTION

Top

Add restart() method to MozRepl.

Restart your Firefox/Thunderbird using JavaScript

In the MDC Code snippets:Miscellaneous(http://developer.mozilla.org/en/docs/Code_snippets:Miscellaneous#Restarting_Firefox.2FThunderbird)

    var nsIAppStartup = Components.interfaces.nsIAppStartup;
    Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup).quit(nsIAppStartup.eForceQuit | nsIAppStartup.eRestart);

MozRepl object (default "repl") has attribute "Ci" and "Cc". "Ci" is alias Components.interfaces, "Cc" is alias Components.classes. So restart script will be here,

    (function(repl) {
      var nsIAppStartup = repl.Ci.nsIAppStartup;
      repl.Cc["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup).quit(nsIAppStartup.eForceQuit | nsIAppStartup.eRestart); 
    })(window.repl);




METHODS

Top

execute($ctx, $args)

$ctx

Context object. See MozRepl.

$args

Hash reference.

SEE ALSO

Top

MozRepl
mozrestart

AUTHOR

Top

Toru Yamaguchi, <zigorou@cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-mozrepl-plugin-restart@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT & LICENSE

Top


MozRepl-Plugin-Restart documentation Contained in the MozRepl-Plugin-Restart distribution.
package MozRepl::Plugin::Restart;

use strict;
use warnings;

use base qw(MozRepl::Plugin::Base);

our $VERSION = '0.02';

sub execute {
    my ($self, $ctx, $args) = @_;

    my $params = {};
    $params->{repl} = $ctx->repl;

    my $command = $self->process('execute', $params);

    $ctx->log->warn("Restarting firefox/thunderbird ...");
    $ctx->execute($command);

    return 1;
}

1; # End of MozRepl::Plugin::Restart

__DATA__
__execute__
(
 function(repl) { 
   var nsIAppStartup = repl.Ci.nsIAppStartup;
   repl.Cc["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup).quit(nsIAppStartup.eForceQuit | nsIAppStartup.eRestart); 
})([% repl %]);
__END__