line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CTK::Plugin; # $id$ |
2
|
3
|
|
|
3
|
|
24
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
86
|
|
3
|
3
|
|
|
3
|
|
14
|
use utf8; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
12
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=encoding utf-8 |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
CTK::Plugin - Base class for CTK plugins writing |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 1.00 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
package CTK::Plugin::Foo; |
18
|
|
|
|
|
|
|
use strict; |
19
|
|
|
|
|
|
|
use base qw/CTK::Plugin/; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub init { |
22
|
|
|
|
|
|
|
my $self = shift; # It is CTK object! |
23
|
|
|
|
|
|
|
... |
24
|
|
|
|
|
|
|
return 1; # or 0 if errors |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
__PACKAGE__->register_method( |
28
|
|
|
|
|
|
|
namespace => "CTK", # Optional. Default: CTK |
29
|
|
|
|
|
|
|
method => "foo", |
30
|
|
|
|
|
|
|
callback => sub { |
31
|
|
|
|
|
|
|
my $self = shift; # It is CTK object! |
32
|
|
|
|
|
|
|
... |
33
|
|
|
|
|
|
|
return 1; |
34
|
|
|
|
|
|
|
}); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 DESCRIPTION |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
A "plugin" for the CTK is simply a Perl module which exists in a known package |
41
|
|
|
|
|
|
|
location (CTK::Plugin::*) and conforms to a our standard, allowing it to be |
42
|
|
|
|
|
|
|
loaded and used automatically. See L for example |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 init |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Allows you to initialize your plugin |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
The method is automatically call in CTK constructor. The first param is CTK object. |
49
|
|
|
|
|
|
|
The method MUST return 0 in case of failure or 1 in case of successful initialization |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 register_method |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__PACKAGE__->register_method( |
54
|
|
|
|
|
|
|
namespace => "CTK", # Optional. Default: CTK |
55
|
|
|
|
|
|
|
method => "mothod_name", |
56
|
|
|
|
|
|
|
callback => sub { |
57
|
|
|
|
|
|
|
my $self = shift; # It is CTK object! |
58
|
|
|
|
|
|
|
... |
59
|
|
|
|
|
|
|
return 1; |
60
|
|
|
|
|
|
|
}); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Allows register the method that will be linked with Your plugin callback function |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 HISTORY |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=over 8 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item B<1.00 Wed 1 May 00:20:20 MSK 2019> |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Init version |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=back |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
See C file |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 TO DO |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
See C file |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 BUGS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
* none noted |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SEE ALSO |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
L |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 AUTHOR |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Serż Minus (Sergey Lepenkov) L Eabalama@cpan.orgE |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 COPYRIGHT |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 LICENSE |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
99
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
See C file and L |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
3
|
|
|
3
|
|
121
|
use vars qw/ $VERSION /; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
148
|
|
106
|
|
|
|
|
|
|
$VERSION = '1.00'; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
use constant { |
109
|
3
|
|
|
|
|
629
|
NAMESPACE => "CTK", |
110
|
3
|
|
|
3
|
|
19
|
}; |
|
3
|
|
|
|
|
5
|
|
111
|
|
|
|
|
|
|
|
112
|
2
|
|
|
2
|
1
|
7
|
sub init { 1 } |
113
|
|
|
|
|
|
|
sub register_method { |
114
|
40
|
|
|
40
|
1
|
68
|
my $package = shift; |
115
|
40
|
|
|
|
|
123
|
my %meta = @_; |
116
|
40
|
|
100
|
|
|
143
|
my $namespace = $meta{namespace} || NAMESPACE; |
117
|
40
|
|
50
|
0
|
|
106
|
my $callback = $meta{callback} || sub { 1 }; |
|
0
|
|
|
|
|
|
|
118
|
40
|
50
|
|
|
|
93
|
return unless ref($callback) eq "CODE"; |
119
|
40
|
|
|
|
|
58
|
my $method = $meta{method}; |
120
|
40
|
50
|
|
|
|
66
|
return unless $method; |
121
|
40
|
|
|
|
|
110
|
my $ff = sprintf("%s::%s", $namespace, $method); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# Check |
124
|
3
|
50
|
|
3
|
|
21
|
return if do { no strict 'refs'; defined &{$ff} }; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
177
|
|
|
40
|
|
|
|
|
66
|
|
|
40
|
|
|
|
|
45
|
|
|
40
|
|
|
|
|
210
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# Create method! |
127
|
40
|
|
|
|
|
63
|
do { |
128
|
3
|
|
|
3
|
|
18
|
no strict 'refs'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
248
|
|
129
|
40
|
|
|
|
|
55
|
*{$ff} = \&$callback; |
|
40
|
|
|
|
|
172
|
|
130
|
|
|
|
|
|
|
}; |
131
|
40
|
|
|
|
|
113
|
return 1; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
1; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
__END__ |