| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MozRepl::Plugin::Restart; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
40
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
38
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use base qw(MozRepl::Plugin::Base); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
1159
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
MozRepl::Plugin::Restart - Restart Firefox/Thunderbird |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
version 0.02 |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use MozRepl; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $repl = MozRepl->new; |
|
25
|
|
|
|
|
|
|
$repl->setup({ plugins => { plugins => [qw/Restart/] } }); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$repl->restart; ### and restart your Firefox or Thunderbird |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Add restart() method to L. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 Restart your Firefox/Thunderbird using JavaScript |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
In the MDC Code snippets:Miscellaneous(http://developer.mozilla.org/en/docs/Code_snippets:Miscellaneous#Restarting_Firefox.2FThunderbird) |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
var nsIAppStartup = Components.interfaces.nsIAppStartup; |
|
38
|
|
|
|
|
|
|
Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup).quit(nsIAppStartup.eForceQuit | nsIAppStartup.eRestart); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
MozRepl object (default "repl") has attribute "Ci" and "Cc". |
|
41
|
|
|
|
|
|
|
"Ci" is alias Components.interfaces, "Cc" is alias Components.classes. |
|
42
|
|
|
|
|
|
|
So restart script will be here, |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
(function(repl) { |
|
45
|
|
|
|
|
|
|
var nsIAppStartup = repl.Ci.nsIAppStartup; |
|
46
|
|
|
|
|
|
|
repl.Cc["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup).quit(nsIAppStartup.eForceQuit | nsIAppStartup.eRestart); |
|
47
|
|
|
|
|
|
|
})(window.repl); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 METHODS |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 execute($ctx, $args) |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=over 4 |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item $ctx |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Context object. See L. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item $args |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Hash reference. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=back |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub execute { |
|
69
|
0
|
|
|
0
|
1
|
|
my ($self, $ctx, $args) = @_; |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $params = {}; |
|
72
|
0
|
|
|
|
|
|
$params->{repl} = $ctx->repl; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
my $command = $self->process('execute', $params); |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
$ctx->log->warn("Restarting firefox/thunderbird ..."); |
|
77
|
0
|
|
|
|
|
|
$ctx->execute($command); |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return 1; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=over 4 |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item L |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item L |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 AUTHOR |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Toru Yamaguchi, C<< >> |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 BUGS |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
99
|
|
|
|
|
|
|
C, or through the web interface at |
|
100
|
|
|
|
|
|
|
L. I will be notified, and then you'll automatically be |
|
101
|
|
|
|
|
|
|
notified of progress on your bug as I make changes. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Copyright 2007 Toru Yamaguchi, All Rights Reserved. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
108
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; # End of MozRepl::Plugin::Restart |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__DATA__ |