| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Slackware::Slackget::Network::Message ; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
72
|
|
|
4
|
1
|
|
|
1
|
|
8
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
687
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Slackware::Slackget::Network::Message - The response object for Slackware::Slackget::Network class |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 1.0.0 |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.9.1'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This class is the message object used by the Slackware::Slackget::Network class to return informations from the network connection. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This module is the evolution of the old Slackware::Slackget::Network::Response. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 new |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
the constructor require no argument. But store every given argument in the object (which is a hashref). |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $msg = new Slackware::Slackget::Network::Message ; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new |
|
35
|
|
|
|
|
|
|
{ |
|
36
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
37
|
0
|
|
|
|
|
|
my $self = {@_}; |
|
38
|
0
|
|
|
|
|
|
bless($self,$class); |
|
39
|
0
|
|
|
|
|
|
return $self; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 new_from_data |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
This is an alternative constructor to create a Slackware::Slackget::Network::Message with the whole slack-get protocol compatible data structure. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
You must provide the following arguments : |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
* an action id (integer) |
|
49
|
|
|
|
|
|
|
* a action (string) |
|
50
|
|
|
|
|
|
|
* some data |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Here is a little example : |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $msg = Slackware::Slackget::Network::Message->new( |
|
55
|
|
|
|
|
|
|
123456789, |
|
56
|
|
|
|
|
|
|
'search', |
|
57
|
|
|
|
|
|
|
@keywords, |
|
58
|
|
|
|
|
|
|
); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub new_from_data { |
|
63
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
64
|
0
|
|
|
|
|
|
my $action_id = shift; |
|
65
|
0
|
|
|
|
|
|
my $action = shift; |
|
66
|
0
|
|
|
|
|
|
my @data = @_; |
|
67
|
0
|
|
|
|
|
|
my $self = {}; |
|
68
|
|
|
|
|
|
|
# my $self = { |
|
69
|
|
|
|
|
|
|
# raw_data => { |
|
70
|
|
|
|
|
|
|
# Enveloppe => { |
|
71
|
|
|
|
|
|
|
# Action => { |
|
72
|
|
|
|
|
|
|
# id => $action_id , |
|
73
|
|
|
|
|
|
|
# content => $action, |
|
74
|
|
|
|
|
|
|
# }, |
|
75
|
|
|
|
|
|
|
# Data => { |
|
76
|
|
|
|
|
|
|
# content => join('',@_), |
|
77
|
|
|
|
|
|
|
# }, |
|
78
|
|
|
|
|
|
|
# } |
|
79
|
|
|
|
|
|
|
# } |
|
80
|
|
|
|
|
|
|
# }; |
|
81
|
0
|
|
|
|
|
|
bless($self,$class); |
|
82
|
0
|
|
|
|
|
|
$self->create_enveloppe(); |
|
83
|
0
|
|
|
|
|
|
$self->{raw_data}->{Enveloppe}->{Action}->{id} = $action_id; |
|
84
|
0
|
|
|
|
|
|
$self->{raw_data}->{Enveloppe}->{Action}->{content} = $action; |
|
85
|
0
|
|
|
|
|
|
$self->{raw_data}->{Enveloppe}->{Data}->{content} = join('',@data); |
|
86
|
0
|
|
|
|
|
|
return $self; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 create_enveloppe |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Create a base enveloppe for the SlackGetProtocol in the raw_data section. This method access directly to the object's data structure. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Be carefull not to use it on an already initialized object. Else all "raw_data" will be lost. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$self = { |
|
96
|
|
|
|
|
|
|
action => 0, |
|
97
|
|
|
|
|
|
|
action_id => 0, |
|
98
|
|
|
|
|
|
|
raw_data => { |
|
99
|
|
|
|
|
|
|
Enveloppe => { |
|
100
|
|
|
|
|
|
|
Action => { |
|
101
|
|
|
|
|
|
|
id => 0 , |
|
102
|
|
|
|
|
|
|
content => 0, |
|
103
|
|
|
|
|
|
|
}, |
|
104
|
|
|
|
|
|
|
Data => {}, |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
}; |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub create_enveloppe { |
|
112
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
113
|
0
|
|
|
|
|
|
$self->action(0); |
|
114
|
0
|
|
|
|
|
|
$self->action_id(0); |
|
115
|
0
|
|
|
|
|
|
$self->{raw_data} = { |
|
116
|
|
|
|
|
|
|
Enveloppe => { |
|
117
|
|
|
|
|
|
|
Action => { |
|
118
|
|
|
|
|
|
|
id => 0 , |
|
119
|
|
|
|
|
|
|
content => 0, |
|
120
|
|
|
|
|
|
|
}, |
|
121
|
|
|
|
|
|
|
Data => {}, |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
}; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 is_success |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
true if the operation is a success |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub is_success { |
|
133
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
134
|
0
|
|
|
|
|
|
my $data = shift; |
|
135
|
0
|
0
|
|
|
|
|
return $data ? $self->{is_success}=$data : $self->{is_success}; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 is_error |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
true if the operation is an error |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub is_error { |
|
145
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
146
|
0
|
|
|
|
|
|
return !$self->{is_success} ; |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 error_msg |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
return a string containing an error message. Works only if $response->is_error() is true. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub error_msg { |
|
156
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
157
|
0
|
|
|
|
|
|
my $data = shift; |
|
158
|
0
|
0
|
|
|
|
|
return $data ? $self->{error_msg}=$data : $self->{error_msg}; |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 have_choice |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
true if the daemon return a choice |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub have_choice { |
|
168
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
169
|
0
|
|
|
|
|
|
my $data = shift; |
|
170
|
0
|
0
|
|
|
|
|
return $data ? $self->{have_choice}=$data : $self->{have_choice}; |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head2 data |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
return all raw data returned by the remote daemon |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub data { |
|
180
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
181
|
0
|
|
|
|
|
|
my $data = shift; |
|
182
|
0
|
0
|
|
|
|
|
return $data ? $self->{raw_data}=$data : $self->{raw_data}; |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head2 action |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
return (or set) the action of the message (all network messages must have an action). |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub action{ |
|
192
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
193
|
0
|
|
|
|
|
|
my $data = shift; |
|
194
|
0
|
0
|
|
|
|
|
if($data){ |
|
195
|
0
|
0
|
0
|
|
|
|
$self->{raw_data}->{Enveloppe}->{Action}->{content} = $data if(exists($self->{raw_data}->{Enveloppe}->{Action}) && ref($self->{raw_data}->{Enveloppe}->{Action}) eq 'HASH' ); |
|
196
|
0
|
|
|
|
|
|
$self->{action}=$data |
|
197
|
|
|
|
|
|
|
}else{ |
|
198
|
0
|
|
|
|
|
|
return $self->{action}; |
|
199
|
|
|
|
|
|
|
} |
|
200
|
|
|
|
|
|
|
} |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head2 action_id |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
return (or set) the action ID of the message (all network messages must have an action id). |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=cut |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub action_id{ |
|
209
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
210
|
0
|
|
|
|
|
|
my $data = shift; |
|
211
|
0
|
0
|
|
|
|
|
if($data){ |
|
212
|
0
|
0
|
0
|
|
|
|
$self->{raw_data}->{Enveloppe}->{Action}->{id} = $data if(exists($self->{raw_data}->{Enveloppe}->{Action}) && ref($self->{raw_data}->{Enveloppe}->{Action}) eq 'HASH' ); |
|
213
|
0
|
|
|
|
|
|
$self->{action_id}=$data |
|
214
|
|
|
|
|
|
|
}else{ |
|
215
|
0
|
|
|
|
|
|
return $self->{action_id}; |
|
216
|
|
|
|
|
|
|
} |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 AUTHOR |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
DUPUIS Arnaud, C<< >> |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 BUGS |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
227
|
|
|
|
|
|
|
C, or through the web interface at |
|
228
|
|
|
|
|
|
|
L. |
|
229
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
230
|
|
|
|
|
|
|
your bug as I make changes. |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 SUPPORT |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
perldoc Slackware::Slackget |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
You can also look for information at: |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=over 4 |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=item * Infinity Perl website |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
L |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=item * slack-get specific website |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
L |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
L |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
L |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
L |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=item * Search CPAN |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
L |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=back |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
Thanks to Bertrand Dupuis (yes my brother) for his contribution to the documentation. |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
Copyright 2005 DUPUIS Arnaud, All Rights Reserved. |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
278
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=cut |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
1; # End of Slackware::Slackget::Network::Message |