line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Slackware::Slackget::Network; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1216
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
56
|
|
5
|
|
|
|
|
|
|
use constant { |
6
|
1
|
|
|
|
|
4773
|
SLACK_GET_PROTOCOL_VERSION => 0.5, |
7
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_MESSAGE_START => 0x4200, |
8
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_ACK => 0x4201, |
9
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_NACK => 0x4202, |
10
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_SERVER_END_CONNECTION => 0x4203, |
11
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_MESSAGE_STOP => 0x4242, |
12
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_NEGOCIATION_QUERY_SEND_BACKENDS_LIST => 0x4211, |
13
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_NEGOCIATION_QUERY_SEND_AGREEMENT => 0x4212, |
14
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_NEGOCIATION_QUERY_SEND_ACK => 0x4213, |
15
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_INFO_LEVEL_STANDARD => 0x4250, |
16
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_INFO_LEVEL_IMPORTANT => 0x4251, |
17
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_INFO_LEVEL_PKG => 0x4252, |
18
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_INFO_LEVEL_EMERGENCY => 0x4253, |
19
|
1
|
|
|
1
|
|
5
|
}; |
|
1
|
|
|
|
|
1
|
|
20
|
|
|
|
|
|
|
require Slackware::Slackget::Network::Message ; |
21
|
|
|
|
|
|
|
# require XML::Simple; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 NAME |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Slackware::Slackget::Network - A class for network communication |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 VERSION |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Version 1.0.0 (this version number is absolutly irrelevant and should be considered as an error, real version number is 0.8.2 and is accessible through the $VERSION_REAL variable) |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our $VERSION = '1.0.0'; |
34
|
|
|
|
|
|
|
our $VERSION_REAL='0.8.3'; |
35
|
|
|
|
|
|
|
our @ISA; |
36
|
|
|
|
|
|
|
my @BACKENDS = ('XML'); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 SYNOPSIS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
WARNING WARNING : this module's API and behaviour changed a lot since the 0.12 release ! Please take good care of this : WARNING WARNING |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
This class' purpose is to make all network dialog transparent. You give to this class the raw (XML) network message sent to (or from) a slack-get daemon (sg_daemon) and Slackware::Slackget::Network decode and wrap it for you. |
43
|
|
|
|
|
|
|
The "plus" of this system is that sg_daemon (or any slack-get client) developpers are safe if something change in the network protocol : it will never change the API. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
use Slackware::Slackget::Network; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $net = Slackware::Slackget::Network->new(); |
48
|
|
|
|
|
|
|
my $message_object = new Slackware::Slackget::Network::Message ; |
49
|
|
|
|
|
|
|
$message_object->action('get_connection_id'); |
50
|
|
|
|
|
|
|
my $xml_msg = $net->encode($message_object); |
51
|
|
|
|
|
|
|
my $response_object = $net->decode($xml_msg); |
52
|
|
|
|
|
|
|
# $message_object and $response_object are equals in term of values |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
All methods from this module return a Slackware::Slackget::Network::Message (L) object. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Since the 0.12 release of this module this module is nothing more than a encoder/decoder for slack-get's network messages. So no more network handling nor automatic response sent directly through the socket passed as argument. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub new |
61
|
|
|
|
|
|
|
{ |
62
|
0
|
|
|
0
|
1
|
|
my ($class,%args) = @_ ; |
63
|
|
|
|
|
|
|
sub _create_random_id |
64
|
|
|
|
|
|
|
{ |
65
|
0
|
|
|
0
|
|
|
my $newpass=''; |
66
|
0
|
|
|
|
|
|
for (my $k=1;$k<=56;$k++) |
67
|
|
|
|
|
|
|
{ |
68
|
0
|
|
|
|
|
|
my $lettre = ('a'...'z',1...9)[35*rand]; |
69
|
0
|
|
|
|
|
|
$newpass.=$lettre; |
70
|
|
|
|
|
|
|
} |
71
|
0
|
|
|
|
|
|
return $newpass; |
72
|
|
|
|
|
|
|
} |
73
|
0
|
|
|
|
|
|
my $self = { _backends => [], _supported_backends => [], _mode => 'server' }; |
74
|
0
|
0
|
0
|
|
|
|
$self->{_mode} = $args{mode} if( defined($args{mode}) && ($args{mode} eq 'server' || $args{mode} eq 'client') ); |
|
|
|
0
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] debug mode activated\n" if($ENV{SG_DAEMON_DEBUG}); |
76
|
|
|
|
|
|
|
# my $backend = 'Slackware::Slackget::Network::Backend::XML'; |
77
|
|
|
|
|
|
|
# $backend = $args{backend} if(defined($args{backend})); |
78
|
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
$args{backends} = [@BACKENDS] unless( defined($args{backends}) ); |
80
|
0
|
|
|
|
|
|
foreach my $b (@{$args{backends}}){ |
|
0
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my $backend = "Slackware::Slackget::Network::Backend::$b"; |
82
|
0
|
|
|
|
|
|
eval "require $backend;"; |
83
|
0
|
0
|
|
|
|
|
if($@){ |
84
|
0
|
|
|
|
|
|
warn "[Slackware::Slackget::Network] backend \"$backend\" cannot be load ($@).\n";# Fall back to Slackware::Slackget::Network::Backend::XML.\n" ; |
85
|
|
|
|
|
|
|
# eval "require Slackware::Slackget::Network::Backend::XML;"; |
86
|
|
|
|
|
|
|
# if($@){ |
87
|
|
|
|
|
|
|
# warn "[Slackware::Slackget::Network] backend Slackware::Slackget::Network::Backend::XML is not available either. This is critical we can't continue.\n" ; |
88
|
|
|
|
|
|
|
# return undef; |
89
|
|
|
|
|
|
|
# } |
90
|
|
|
|
|
|
|
}else{ |
91
|
0
|
|
|
|
|
|
my $bo; |
92
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] creating new $backend object.\n" if($ENV{SG_DAEMON_DEBUG}); |
93
|
0
|
|
|
|
|
|
$bo = $backend->new ; |
94
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] object is $bo.\n" if($ENV{SG_DAEMON_DEBUG}); |
95
|
0
|
|
|
|
|
|
push @{$self->{_backends}}, $bo; |
|
0
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
push @{$self->{_supported_backends}}, $b; |
|
0
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
0
|
|
|
|
|
|
$self->{_PRIV}->{CONNID} = _create_random_id() ; |
100
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] [constructor] CONNID is $self->{_PRIV}->{CONNID}.\n" if($ENV{SG_DAEMON_DEBUG}); |
101
|
0
|
|
|
|
|
|
$self->{_PRIV}->{ACTIONID} = int((rand(10000)+1) * (rand(10000)+1)); |
102
|
0
|
|
|
|
|
|
$self->{_PRIV}->{CACHE} = ''; |
103
|
0
|
|
|
|
|
|
bless($self,$class); |
104
|
0
|
|
|
|
|
|
return $self; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 new |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
You can pass the following arguments to the constructor : |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
* backends => |
114
|
|
|
|
|
|
|
my $net = Slackware::Slackget::Network->new(backends => [ 'ZIP' , 'XML' ]); |
115
|
|
|
|
|
|
|
# **ATTENTION ** : the order you give to the backends determine the way it will encode/decode messages ! |
116
|
|
|
|
|
|
|
# in this exemple, decode() will call : |
117
|
|
|
|
|
|
|
# |_ ZIP->backend_decode() |
118
|
|
|
|
|
|
|
# |_ XML->backend_decode() |
119
|
|
|
|
|
|
|
# And encode() will call : |
120
|
|
|
|
|
|
|
# |_ XML->backend_encode() |
121
|
|
|
|
|
|
|
# |_ ZIP->backend_encode() |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
The only included backend is the XML one for the moment. If the backend could not be loaded the constructor fall back to the XML backend. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 FUNCTIONS |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
All methods return a Slackware::Slackget::Network::Message (L) object, and if the remote slack-getd return some data they are accessibles via the data() accessor of the Slackware::Slackget::Network::Message object. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 decode |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Decode a Slackware::Slackget::Network::Message by going through the backend decoding stack. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub decode { |
138
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
139
|
0
|
|
|
|
|
|
my $input = shift; |
140
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] decode($input)\n" if($ENV{SG_DAEMON_DEBUG}); |
141
|
0
|
|
|
|
|
|
my $output = $input ; |
142
|
0
|
|
|
|
|
|
foreach my $backend (@{$self->{_backends}}){ |
|
0
|
|
|
|
|
|
|
143
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] using backend $backend to decode data\n" if($ENV{SG_DAEMON_DEBUG}); |
144
|
0
|
|
|
|
|
|
$output = $backend->backend_decode($output); |
145
|
|
|
|
|
|
|
} |
146
|
0
|
|
|
|
|
|
return $output; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 encode |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Encode a Slackware::Slackget::Network::Message by going through the backend encoding stack. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub encode { |
156
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
157
|
0
|
|
|
|
|
|
my $message = shift ; |
158
|
0
|
0
|
|
|
|
|
if($ENV{SG_DAEMON_DEBUG}){ |
159
|
0
|
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] encode() incoming message : $message, dump is :\n"; |
160
|
0
|
|
|
|
|
|
require Data::Dumper; print Data::Dumper::Dumper($message),"\n"; |
|
0
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
} |
162
|
0
|
|
|
|
|
|
my $output = $message ; |
163
|
0
|
|
|
|
|
|
foreach my $backend (reverse( @{$self->{_backends}} )){ |
|
0
|
|
|
|
|
|
|
164
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] encode() going through $backend\n" if($ENV{SG_DAEMON_DEBUG}); |
165
|
0
|
|
|
|
|
|
$output = $backend->backend_encode($output); |
166
|
|
|
|
|
|
|
} |
167
|
0
|
|
|
|
|
|
return $output ; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head2 interpret |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Interpret a Slackware::Slackget::Network::Message. "Interpret" means "execute actions". |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
So the interpretable Slackware::Slackget::Network::Message are those supported by this module. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Currently supported actions are : get_connection_id |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub interpret { |
181
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
182
|
0
|
|
|
|
|
|
my $message = shift ; |
183
|
0
|
0
|
|
|
|
|
return undef unless(defined($message)); |
184
|
0
|
0
|
|
|
|
|
if(defined($message->action)){ |
185
|
0
|
|
|
|
|
|
my $func = '__'.$message->action; |
186
|
0
|
0
|
|
|
|
|
if($self->can($func.'_mode_'.$self->{_mode})) { |
|
|
0
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
$func = $func.'_mode_'.$self->{_mode}; |
188
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] interpret($message) through $func\n" if($ENV{SG_DAEMON_DEBUG}); |
189
|
0
|
|
|
|
|
|
return $self->$func($message) ; |
190
|
|
|
|
|
|
|
}elsif($self->can($func)){ |
191
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] interpret($message) through $func\n" if($ENV{SG_DAEMON_DEBUG}); |
192
|
0
|
|
|
|
|
|
return $self->$func($message) ; |
193
|
|
|
|
|
|
|
}else{ |
194
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] cannot interpret $message\n" if($ENV{SG_DAEMON_DEBUG}); |
195
|
0
|
|
|
|
|
|
return undef; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head2 generate |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Generate a new Slackware::Slackget::Network::Message formatted for a specific action. Like interpret() it works only with a subset of available actions. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Only the major actions are hardcoded to be automatically generated. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
You can generate messages for the following actions : search, build_medias_list, build_update_list, build_installed_list, notification, upgradepkg, installpkg, removepkg, get_patches_list. |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=cut |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
sub generate { |
211
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
212
|
0
|
|
|
|
|
|
my $str_msg = shift; |
213
|
0
|
|
|
|
|
|
my @extra_args = @_; |
214
|
0
|
0
|
|
|
|
|
return undef unless(defined($str_msg)); |
215
|
0
|
|
|
|
|
|
my $func = '__'.$str_msg; |
216
|
0
|
0
|
|
|
|
|
if( $self->can($func.'_generate') ){ |
|
|
0
|
|
|
|
|
|
217
|
0
|
|
|
|
|
|
$func = $func.'_generate'; |
218
|
0
|
|
|
|
|
|
return $self->$func(@extra_args) ; # only *_generate specific function can receive arguments |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
elsif($self->can($func)){ |
221
|
0
|
|
|
|
|
|
return $self->$func() ; |
222
|
|
|
|
|
|
|
}else{ |
223
|
0
|
|
|
|
|
|
return undef; |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head2 backends_list |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
Return the list of supported backends. |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
backends_list() returned list contains only backends that can be loaded an instanciated. |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=cut |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub backends_list { |
236
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
237
|
0
|
|
|
|
|
|
return @{$self->{_supported_backends}} |
|
0
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head2 scan_backends |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
Return a list of available backends on the system. Some of those backends can be completly broken. |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
At this point you have absolutly no garanties that all the backends will works. |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=cut |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
sub scan_backends { |
249
|
0
|
|
|
0
|
1
|
|
my @backends; |
250
|
0
|
|
|
|
|
|
foreach my $lib (@INC){ |
251
|
0
|
|
|
|
|
|
while(<$lib/Slackware/Slackget/Network/Backend/*.pm>){ |
252
|
0
|
|
|
|
|
|
print "scan_backends: $_\n"; |
253
|
|
|
|
|
|
|
# TODO: check the actual need of this scan_backends() method. And if it's usefull, then make it actually return something |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=head2 cache_data |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
This method allow you to cache data (incredible isn't it ?). It's use by slack-get to fill network buffer until the complete network message is received. |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
$net->cache_data('some kind of stupid data'); |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=cut |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
sub cache_data { |
267
|
0
|
|
|
0
|
1
|
|
my ($self,@data)=@_; |
268
|
0
|
|
|
|
|
|
$self->{_PRIV}->{CACHE} .= join('',@data); |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=head2 cached_data |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
Return previously cached data. |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
my $data = $net->cached_data() ; |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=cut |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
sub cached_data { |
280
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
281
|
0
|
|
|
|
|
|
return $self->{_PRIV}->{CACHE}; |
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=head2 clear_cache |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
Unconditionnally delete cached data from memory. |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
$net->clear_cache(); |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=cut |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
sub clear_cache { |
293
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
294
|
0
|
|
|
|
|
|
$self->{_PRIV}->{CACHE} = ''; |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
sub _get_action_id { |
298
|
0
|
|
|
0
|
|
|
my $self = shift; |
299
|
0
|
|
|
|
|
|
$self->{_PRIV}->{ACTIONID} += int(rand(1000)+1) ; |
300
|
0
|
|
|
|
|
|
return $self->{_PRIV}->{ACTIONID}; |
301
|
|
|
|
|
|
|
} |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=head2 __get_connection_id |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
Set the id of the connection. The id is generate by the constructor and must not be modified. This method is automatically called by the constructor and is mostly private. |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
$net->__get_connection_id ; |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
=cut |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
sub __get_connection_id |
312
|
|
|
|
|
|
|
{ |
313
|
0
|
|
|
0
|
|
|
my $self = shift; |
314
|
0
|
|
|
|
|
|
my $message = shift ; |
315
|
0
|
0
|
|
|
|
|
if($message){ |
316
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] __get_connection_id as a response (seems so...)\n" if($ENV{SG_DAEMON_DEBUG}); |
317
|
0
|
|
|
|
|
|
return Slackware::Slackget::Network::Message->new( |
318
|
|
|
|
|
|
|
action => 'get_connection_id', |
319
|
|
|
|
|
|
|
raw_data => { |
320
|
|
|
|
|
|
|
Enveloppe => { |
321
|
|
|
|
|
|
|
Action => { |
322
|
|
|
|
|
|
|
id => $message->{raw_data}->{Enveloppe}->{Action}->{id} , |
323
|
|
|
|
|
|
|
content => 'get_connection_id', |
324
|
|
|
|
|
|
|
}, |
325
|
|
|
|
|
|
|
Data => { |
326
|
|
|
|
|
|
|
content => $self->{_PRIV}->{CONNID}, |
327
|
|
|
|
|
|
|
}, |
328
|
|
|
|
|
|
|
} |
329
|
|
|
|
|
|
|
}, |
330
|
|
|
|
|
|
|
); |
331
|
|
|
|
|
|
|
}else{ |
332
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] __get_connection_id as a request (seems so...)\n" if($ENV{SG_DAEMON_DEBUG}); |
333
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
334
|
0
|
|
|
|
|
|
return Slackware::Slackget::Network::Message->new( |
335
|
|
|
|
|
|
|
action => 'get_connection_id', |
336
|
|
|
|
|
|
|
action_id => $aid, |
337
|
|
|
|
|
|
|
raw_data => { |
338
|
|
|
|
|
|
|
Enveloppe => { |
339
|
|
|
|
|
|
|
Action => { |
340
|
|
|
|
|
|
|
id => $aid , |
341
|
|
|
|
|
|
|
content => 'get_connection_id', |
342
|
|
|
|
|
|
|
}, |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
}, |
345
|
|
|
|
|
|
|
); |
346
|
|
|
|
|
|
|
} |
347
|
|
|
|
|
|
|
} |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
sub __get_connection_id_mode_client { |
350
|
0
|
|
|
0
|
|
|
my $self = shift; |
351
|
0
|
|
|
|
|
|
my $message = shift ; |
352
|
0
|
0
|
|
|
|
|
if($message){ |
353
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] __get_connection_id_mode_client interpreting $message\n" if($ENV{SG_DAEMON_DEBUG}); |
354
|
0
|
|
|
|
|
|
$self->{_PRIV}->{CONNID} = $message->data()->{Enveloppe}->{Data}; |
355
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] __get_connection_id_mode_client new CONNID is $self->{_PRIV}->{CONNID}.\n" if($ENV{SG_DAEMON_DEBUG}); |
356
|
0
|
|
|
|
|
|
return $message; |
357
|
|
|
|
|
|
|
} |
358
|
|
|
|
|
|
|
} |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
sub __search_generate { |
361
|
0
|
|
|
0
|
|
|
my ($self, @query) = @_ ; |
362
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
363
|
0
|
|
|
|
|
|
return Slackware::Slackget::Network::Message->new( |
364
|
|
|
|
|
|
|
action => 'search', |
365
|
|
|
|
|
|
|
action_id => $aid, |
366
|
|
|
|
|
|
|
raw_data => { |
367
|
|
|
|
|
|
|
Enveloppe => { |
368
|
|
|
|
|
|
|
Action => { |
369
|
|
|
|
|
|
|
id => $aid , |
370
|
|
|
|
|
|
|
content => 'search', |
371
|
|
|
|
|
|
|
}, |
372
|
|
|
|
|
|
|
Data => { |
373
|
|
|
|
|
|
|
li => [@query], |
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
}, |
376
|
|
|
|
|
|
|
}, |
377
|
|
|
|
|
|
|
); |
378
|
|
|
|
|
|
|
} |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
sub __build_medias_list_generate { |
381
|
0
|
|
|
0
|
|
|
my ($self) = @_ ; |
382
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
383
|
0
|
|
|
|
|
|
return Slackware::Slackget::Network::Message->new( |
384
|
|
|
|
|
|
|
action => 'build_medias_list', |
385
|
|
|
|
|
|
|
action_id => $aid, |
386
|
|
|
|
|
|
|
raw_data => { |
387
|
|
|
|
|
|
|
Enveloppe => { |
388
|
|
|
|
|
|
|
Action => { |
389
|
|
|
|
|
|
|
id => $aid , |
390
|
|
|
|
|
|
|
content => 'build_medias_list', |
391
|
|
|
|
|
|
|
}, |
392
|
|
|
|
|
|
|
}, |
393
|
|
|
|
|
|
|
}, |
394
|
|
|
|
|
|
|
); |
395
|
|
|
|
|
|
|
} |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
sub __build_update_list_generate { |
398
|
0
|
|
|
0
|
|
|
my ($self) = @_ ; |
399
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
400
|
0
|
|
|
|
|
|
return Slackware::Slackget::Network::Message->new( |
401
|
|
|
|
|
|
|
action => 'build_update_list', |
402
|
|
|
|
|
|
|
action_id => $aid, |
403
|
|
|
|
|
|
|
raw_data => { |
404
|
|
|
|
|
|
|
Enveloppe => { |
405
|
|
|
|
|
|
|
Action => { |
406
|
|
|
|
|
|
|
id => $aid , |
407
|
|
|
|
|
|
|
content => 'build_update_list', |
408
|
|
|
|
|
|
|
}, |
409
|
|
|
|
|
|
|
}, |
410
|
|
|
|
|
|
|
}, |
411
|
|
|
|
|
|
|
); |
412
|
|
|
|
|
|
|
} |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
sub __build_installed_list_generate { |
415
|
0
|
|
|
0
|
|
|
my ($self) = @_ ; |
416
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
417
|
0
|
|
|
|
|
|
return Slackware::Slackget::Network::Message->new( |
418
|
|
|
|
|
|
|
action => 'build_installed_list', |
419
|
|
|
|
|
|
|
action_id => $aid, |
420
|
|
|
|
|
|
|
raw_data => { |
421
|
|
|
|
|
|
|
Enveloppe => { |
422
|
|
|
|
|
|
|
Action => { |
423
|
|
|
|
|
|
|
id => $aid , |
424
|
|
|
|
|
|
|
content => 'build_installed_list', |
425
|
|
|
|
|
|
|
}, |
426
|
|
|
|
|
|
|
}, |
427
|
|
|
|
|
|
|
}, |
428
|
|
|
|
|
|
|
); |
429
|
|
|
|
|
|
|
} |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
sub __notification_generate { |
432
|
0
|
|
|
0
|
|
|
my $self = shift; |
433
|
0
|
|
|
|
|
|
my @notifications = @_; |
434
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
435
|
0
|
|
|
|
|
|
my $msg = new Slackware::Slackget::Network::Message; |
436
|
0
|
|
|
|
|
|
$msg->create_enveloppe ; |
437
|
0
|
|
|
|
|
|
$msg->action('notification'); |
438
|
0
|
|
|
|
|
|
$msg->action_id($aid); |
439
|
0
|
0
|
|
|
|
|
if(scalar(@notifications) >= 1 ){ |
440
|
0
|
|
|
|
|
|
$msg->data()->{Enveloppe}->{Data}->{li} = []; |
441
|
0
|
|
|
|
|
|
foreach my $nm (@notifications){ |
442
|
0
|
|
|
|
|
|
push @{ $msg->data()->{Enveloppe}->{Data}->{li} },$nm; |
|
0
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
} |
444
|
|
|
|
|
|
|
} |
445
|
0
|
|
|
|
|
|
return $msg; |
446
|
|
|
|
|
|
|
} |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
sub __removepkg_generate { |
449
|
0
|
|
|
0
|
|
|
my $self = shift; |
450
|
0
|
|
|
|
|
|
my @pkgs = @_ ; |
451
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
452
|
0
|
|
|
|
|
|
my $msg = new Slackware::Slackget::Network::Message; |
453
|
0
|
|
|
|
|
|
$msg->create_enveloppe ; |
454
|
0
|
|
|
|
|
|
$msg->action('removepkg'); |
455
|
0
|
|
|
|
|
|
$msg->action_id($aid); |
456
|
0
|
0
|
|
|
|
|
if(scalar(@pkgs) >= 1 ){ |
457
|
0
|
|
|
|
|
|
$msg->data()->{Enveloppe}->{Data}->{li} = []; |
458
|
0
|
|
|
|
|
|
foreach my $p (@pkgs){ |
459
|
0
|
|
|
|
|
|
push @{ $msg->data()->{Enveloppe}->{Data}->{li} },$p; |
|
0
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
} |
461
|
|
|
|
|
|
|
} |
462
|
0
|
|
|
|
|
|
return $msg; |
463
|
|
|
|
|
|
|
} |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
sub __get_patches_list_generate { |
466
|
0
|
|
|
0
|
|
|
my ($self) = @_ ; |
467
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
468
|
0
|
|
|
|
|
|
return Slackware::Slackget::Network::Message->new( |
469
|
|
|
|
|
|
|
action => 'get_patches_list', |
470
|
|
|
|
|
|
|
action_id => $aid, |
471
|
|
|
|
|
|
|
raw_data => { |
472
|
|
|
|
|
|
|
Enveloppe => { |
473
|
|
|
|
|
|
|
Action => { |
474
|
|
|
|
|
|
|
id => $aid , |
475
|
|
|
|
|
|
|
content => 'get_patches_list', |
476
|
|
|
|
|
|
|
}, |
477
|
|
|
|
|
|
|
}, |
478
|
|
|
|
|
|
|
}, |
479
|
|
|
|
|
|
|
); |
480
|
|
|
|
|
|
|
} |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
sub __upgradepkg_generate { |
483
|
0
|
|
|
0
|
|
|
my ($self,@pkgs) = @_ ; |
484
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
485
|
0
|
|
|
|
|
|
my $msg = new Slackware::Slackget::Network::Message; |
486
|
0
|
|
|
|
|
|
$msg->create_enveloppe ; |
487
|
0
|
|
|
|
|
|
$msg->action('upgradepkg'); |
488
|
0
|
|
|
|
|
|
$msg->action_id($aid); |
489
|
0
|
0
|
|
|
|
|
if(scalar(@pkgs) >= 1 ){ |
490
|
0
|
|
|
|
|
|
$msg->data()->{Enveloppe}->{Data}->{li} = []; |
491
|
0
|
|
|
|
|
|
push @{ $msg->data()->{Enveloppe}->{Data}->{li} },@pkgs; |
|
0
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
} |
493
|
0
|
|
|
|
|
|
return $msg; |
494
|
|
|
|
|
|
|
} |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
sub __installpkg_generate { |
497
|
0
|
|
|
0
|
|
|
my ($self,@pkgs) = @_ ; |
498
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
499
|
0
|
|
|
|
|
|
my $msg = new Slackware::Slackget::Network::Message; |
500
|
0
|
|
|
|
|
|
$msg->create_enveloppe ; |
501
|
0
|
|
|
|
|
|
$msg->action('installpkg'); |
502
|
0
|
|
|
|
|
|
$msg->action_id($aid); |
503
|
0
|
0
|
|
|
|
|
if(scalar(@pkgs) >= 1 ){ |
504
|
0
|
|
|
|
|
|
$msg->data()->{Enveloppe}->{Data}->{li} = []; |
505
|
0
|
|
|
|
|
|
push @{ $msg->data()->{Enveloppe}->{Data}->{li} },@pkgs; |
|
0
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
} |
507
|
0
|
|
|
|
|
|
return $msg; |
508
|
|
|
|
|
|
|
} |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
# |
511
|
|
|
|
|
|
|
# =head2 __get_installed_list |
512
|
|
|
|
|
|
|
# |
513
|
|
|
|
|
|
|
# get the list of installed packages on the remote daemon. |
514
|
|
|
|
|
|
|
# |
515
|
|
|
|
|
|
|
# my $installed_list = $net->get_installed_list ; |
516
|
|
|
|
|
|
|
# |
517
|
|
|
|
|
|
|
# If an error occured call the appropriate handler. |
518
|
|
|
|
|
|
|
# |
519
|
|
|
|
|
|
|
# In all case return a Slackware::Slackget::Network::Message (L) object. |
520
|
|
|
|
|
|
|
# |
521
|
|
|
|
|
|
|
# =cut |
522
|
|
|
|
|
|
|
# |
523
|
|
|
|
|
|
|
# sub __get_installed_list { |
524
|
|
|
|
|
|
|
# my $self = shift; |
525
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
526
|
|
|
|
|
|
|
# $self->send_data("get_installed_list:$self->{CONNID}\n") ; |
527
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
528
|
|
|
|
|
|
|
# { |
529
|
|
|
|
|
|
|
# return $self->_handle_responses("get_installed_list") ; |
530
|
|
|
|
|
|
|
# } |
531
|
|
|
|
|
|
|
# } |
532
|
|
|
|
|
|
|
# |
533
|
|
|
|
|
|
|
# =head2 __get_packages_list |
534
|
|
|
|
|
|
|
# |
535
|
|
|
|
|
|
|
# get the list of new avalaible packages on the remote daemon. |
536
|
|
|
|
|
|
|
# |
537
|
|
|
|
|
|
|
# my $status = $net->get_packages_list ; |
538
|
|
|
|
|
|
|
# |
539
|
|
|
|
|
|
|
# If an error occured call the appropriate handler. |
540
|
|
|
|
|
|
|
# |
541
|
|
|
|
|
|
|
# In all case return a Slackware::Slackget::Network::Message (L) object. |
542
|
|
|
|
|
|
|
# |
543
|
|
|
|
|
|
|
# =cut |
544
|
|
|
|
|
|
|
# |
545
|
|
|
|
|
|
|
# sub __get_packages_list { |
546
|
|
|
|
|
|
|
# my $self = shift; |
547
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
548
|
|
|
|
|
|
|
# $self->send_data("get_packages_list:$self->{CONNID}\n") ; |
549
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
550
|
|
|
|
|
|
|
# { |
551
|
|
|
|
|
|
|
# return $self->_handle_responses("get_packages_list") ; |
552
|
|
|
|
|
|
|
# } |
553
|
|
|
|
|
|
|
# } |
554
|
|
|
|
|
|
|
# |
555
|
|
|
|
|
|
|
# =head2 __get_html_info |
556
|
|
|
|
|
|
|
# |
557
|
|
|
|
|
|
|
# Get an HTML encoded string which give some general information on the remote slack-getd |
558
|
|
|
|
|
|
|
# |
559
|
|
|
|
|
|
|
# print $net->get_html_info ; |
560
|
|
|
|
|
|
|
# |
561
|
|
|
|
|
|
|
# =cut |
562
|
|
|
|
|
|
|
# |
563
|
|
|
|
|
|
|
# sub __get_html_info |
564
|
|
|
|
|
|
|
# { |
565
|
|
|
|
|
|
|
# my $self = shift; |
566
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
567
|
|
|
|
|
|
|
# $self->send_data("get_html_info:$self->{CONNID}\n") ; |
568
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
569
|
|
|
|
|
|
|
# { |
570
|
|
|
|
|
|
|
# return $self->_handle_responses("get_html_info") ; |
571
|
|
|
|
|
|
|
# } |
572
|
|
|
|
|
|
|
# } |
573
|
|
|
|
|
|
|
# |
574
|
|
|
|
|
|
|
# =head2 __build_packages_list |
575
|
|
|
|
|
|
|
# |
576
|
|
|
|
|
|
|
# Said to the remote slack-getd to build the new packages cache. |
577
|
|
|
|
|
|
|
# |
578
|
|
|
|
|
|
|
# my $status = $net->build_packages_list ; |
579
|
|
|
|
|
|
|
# |
580
|
|
|
|
|
|
|
# The returned status contains no significant data in case of success. |
581
|
|
|
|
|
|
|
# |
582
|
|
|
|
|
|
|
# =cut |
583
|
|
|
|
|
|
|
# |
584
|
|
|
|
|
|
|
# sub __build_packages_list |
585
|
|
|
|
|
|
|
# { |
586
|
|
|
|
|
|
|
# my ($self) = @_ ; |
587
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
588
|
|
|
|
|
|
|
# $self->send_data("build_packages_list:$self->{CONNID}\n") ; |
589
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
590
|
|
|
|
|
|
|
# { |
591
|
|
|
|
|
|
|
# return $self->_handle_responses("build_packages_list") ; |
592
|
|
|
|
|
|
|
# } |
593
|
|
|
|
|
|
|
# } |
594
|
|
|
|
|
|
|
# |
595
|
|
|
|
|
|
|
# =head2 __build_installed_list |
596
|
|
|
|
|
|
|
# |
597
|
|
|
|
|
|
|
# Said to the remote slack-getd to build the installed packages cache. |
598
|
|
|
|
|
|
|
# |
599
|
|
|
|
|
|
|
# my $status = $net->build_installed_list ; |
600
|
|
|
|
|
|
|
# |
601
|
|
|
|
|
|
|
# The returned status contains no significant data in case of success. |
602
|
|
|
|
|
|
|
# |
603
|
|
|
|
|
|
|
# =cut |
604
|
|
|
|
|
|
|
# |
605
|
|
|
|
|
|
|
# sub __build_installed_list |
606
|
|
|
|
|
|
|
# { |
607
|
|
|
|
|
|
|
# my ($self) = @_ ; |
608
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
609
|
|
|
|
|
|
|
# $self->send_data("build_installed_list:$self->{CONNID}\n") ; |
610
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
611
|
|
|
|
|
|
|
# { |
612
|
|
|
|
|
|
|
# return $self->_handle_responses("build_installed_list") ; |
613
|
|
|
|
|
|
|
# } |
614
|
|
|
|
|
|
|
# } |
615
|
|
|
|
|
|
|
# |
616
|
|
|
|
|
|
|
# =head2 __build_media_list |
617
|
|
|
|
|
|
|
# |
618
|
|
|
|
|
|
|
# Said to the remote slack-getd to build the media list (medias.xml file). |
619
|
|
|
|
|
|
|
# |
620
|
|
|
|
|
|
|
# my $status = $net->build_media_list ; |
621
|
|
|
|
|
|
|
# |
622
|
|
|
|
|
|
|
# The returned status contains no significant data in case of success. |
623
|
|
|
|
|
|
|
# |
624
|
|
|
|
|
|
|
# =cut |
625
|
|
|
|
|
|
|
# |
626
|
|
|
|
|
|
|
# sub __build_media_list |
627
|
|
|
|
|
|
|
# { |
628
|
|
|
|
|
|
|
# my ($self) = @_ ; |
629
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
630
|
|
|
|
|
|
|
# $self->send_data("build_media_list:$self->{CONNID}\n") ; |
631
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
632
|
|
|
|
|
|
|
# { |
633
|
|
|
|
|
|
|
# return $self->_handle_responses("build_media_list") ; |
634
|
|
|
|
|
|
|
# } |
635
|
|
|
|
|
|
|
# } |
636
|
|
|
|
|
|
|
# |
637
|
|
|
|
|
|
|
# =head2 __diskspace |
638
|
|
|
|
|
|
|
# |
639
|
|
|
|
|
|
|
# Ask to the remote daemon for the state of the disk space on a specify partition. |
640
|
|
|
|
|
|
|
# |
641
|
|
|
|
|
|
|
# $net->handle_responses(1); # We want Slackware::Slackget::Network handle the response and return the hashref. |
642
|
|
|
|
|
|
|
# my $response = $net->diskspace( "/" ) ; |
643
|
|
|
|
|
|
|
# $net->handle_responses(0); |
644
|
|
|
|
|
|
|
# print "Free space on remote computer / directory is ",$response->data()->{avalaible_space}," KB\n"; |
645
|
|
|
|
|
|
|
# |
646
|
|
|
|
|
|
|
# Return a Slackware::Slackget::Network::Message object which contains (in case of success) a HASHREF build like that : |
647
|
|
|
|
|
|
|
# |
648
|
|
|
|
|
|
|
# $space = { |
649
|
|
|
|
|
|
|
# device => , |
650
|
|
|
|
|
|
|
# total_size => , |
651
|
|
|
|
|
|
|
# used_space => , |
652
|
|
|
|
|
|
|
# available_space => , |
653
|
|
|
|
|
|
|
# use_percentage => , |
654
|
|
|
|
|
|
|
# mount_point => |
655
|
|
|
|
|
|
|
# }; |
656
|
|
|
|
|
|
|
# |
657
|
|
|
|
|
|
|
# =cut |
658
|
|
|
|
|
|
|
# |
659
|
|
|
|
|
|
|
# sub __diskspace |
660
|
|
|
|
|
|
|
# { |
661
|
|
|
|
|
|
|
# my ($self,$dir) = @_ ; |
662
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
663
|
|
|
|
|
|
|
# # print STDOUT "[DEBUG::Network.pm] sending command \"diskspace:$dir\" to remote daemon\n"; |
664
|
|
|
|
|
|
|
# $self->send_data("diskspace:$self->{CONNID}:$dir\n") ; |
665
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
666
|
|
|
|
|
|
|
# { |
667
|
|
|
|
|
|
|
# my $str = ''; |
668
|
|
|
|
|
|
|
# my $ds = {}; |
669
|
|
|
|
|
|
|
# while(<$socket>) |
670
|
|
|
|
|
|
|
# { |
671
|
|
|
|
|
|
|
# chomp; |
672
|
|
|
|
|
|
|
# if($_=~ /^wait:$self->{CONNID}:/) |
673
|
|
|
|
|
|
|
# { |
674
|
|
|
|
|
|
|
# sleep 1; |
675
|
|
|
|
|
|
|
# next ; |
676
|
|
|
|
|
|
|
# } |
677
|
|
|
|
|
|
|
# if ($_=~ /auth_violation:$self->{CONNID}:\s*(.*)/) |
678
|
|
|
|
|
|
|
# { |
679
|
|
|
|
|
|
|
# return Slackware::Slackget::Network::Message->new( |
680
|
|
|
|
|
|
|
# is_success => undef, |
681
|
|
|
|
|
|
|
# ERROR_MSG => $1, |
682
|
|
|
|
|
|
|
# DATA => $_ |
683
|
|
|
|
|
|
|
# ); |
684
|
|
|
|
|
|
|
# last ; |
685
|
|
|
|
|
|
|
# } |
686
|
|
|
|
|
|
|
# if($_=~ /^diskspace:$self->{CONNID}:(device=[^;]+;total_size=[^;]+;used_space=[^;]+;available_space=[^;]+;use_percentage=[^;]+;mount_point=[^;]+)/) |
687
|
|
|
|
|
|
|
# { |
688
|
|
|
|
|
|
|
# my $tmp = $1; |
689
|
|
|
|
|
|
|
# print STDOUT "[DEBUG::Network.pm] $tmp contient des info sur diskspace\n"; |
690
|
|
|
|
|
|
|
# foreach my $pair (split(/;/,$tmp)) |
691
|
|
|
|
|
|
|
# { |
692
|
|
|
|
|
|
|
# my ($key,$value) = split(/=/,$pair); |
693
|
|
|
|
|
|
|
# print STDOUT "[DEBUG::Network.pm] $key => $value\n"; |
694
|
|
|
|
|
|
|
# $ds->{$key} = $value; |
695
|
|
|
|
|
|
|
# } |
696
|
|
|
|
|
|
|
# } |
697
|
|
|
|
|
|
|
# else |
698
|
|
|
|
|
|
|
# { |
699
|
|
|
|
|
|
|
# my $code = $self->_handle_protocol($_) ; |
700
|
|
|
|
|
|
|
# last if($code==2); |
701
|
|
|
|
|
|
|
# print STDOUT "[DEBUG::Network.pm] $_ ne contient pas d'info sur diskspace\n"; |
702
|
|
|
|
|
|
|
# } |
703
|
|
|
|
|
|
|
# last if($_=~ /^end:$self->{CONNID}:\s*diskspace/); |
704
|
|
|
|
|
|
|
# } |
705
|
|
|
|
|
|
|
# return Slackware::Slackget::Network::Message->new( |
706
|
|
|
|
|
|
|
# is_success => 1, |
707
|
|
|
|
|
|
|
# DATA => $ds |
708
|
|
|
|
|
|
|
# ); |
709
|
|
|
|
|
|
|
# } |
710
|
|
|
|
|
|
|
# |
711
|
|
|
|
|
|
|
# } |
712
|
|
|
|
|
|
|
# |
713
|
|
|
|
|
|
|
# =head2 __search |
714
|
|
|
|
|
|
|
# |
715
|
|
|
|
|
|
|
# take at least two parameters : the word you search for, and a field. Valid fields are those who describe a package entity in the packages.xml file. |
716
|
|
|
|
|
|
|
# |
717
|
|
|
|
|
|
|
# my $response = $net->search('gcc','name','description') ; # search for package containing 'gcc' in fields 'name' and 'description' |
718
|
|
|
|
|
|
|
# |
719
|
|
|
|
|
|
|
# Return the remote slack-getd's response in the DATA section of the response (L). |
720
|
|
|
|
|
|
|
# |
721
|
|
|
|
|
|
|
# =cut |
722
|
|
|
|
|
|
|
# |
723
|
|
|
|
|
|
|
# sub __search |
724
|
|
|
|
|
|
|
# { |
725
|
|
|
|
|
|
|
# my ($self,$word,@args) = @_ ; |
726
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
727
|
|
|
|
|
|
|
# my $fields = join(';',@args); |
728
|
|
|
|
|
|
|
# # chop $fields ; |
729
|
|
|
|
|
|
|
# $self->send_data("search:$self->{CONNID}:$word:$fields\n") ; |
730
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
731
|
|
|
|
|
|
|
# { |
732
|
|
|
|
|
|
|
# return $self->_handle_responses("search") ; |
733
|
|
|
|
|
|
|
# } |
734
|
|
|
|
|
|
|
# } |
735
|
|
|
|
|
|
|
# |
736
|
|
|
|
|
|
|
# =head2 __websearch |
737
|
|
|
|
|
|
|
# |
738
|
|
|
|
|
|
|
# Take 2 parameters : a reference on an array which contains the words to search for, and another array reference which contains a list of fields (valid fields are thoses describe in the packages.xml file). |
739
|
|
|
|
|
|
|
# |
740
|
|
|
|
|
|
|
# |
741
|
|
|
|
|
|
|
# The DATA section of the response (L) will contain an ARRAYREF. Each cell of this array will contains a package in HTML |
742
|
|
|
|
|
|
|
# The returned data is HTML, each package are separed by a line wich only contain the string "__MARK__" |
743
|
|
|
|
|
|
|
# |
744
|
|
|
|
|
|
|
# my $response = $network->websearch([ 'burn', 'cd' ], [ 'name', 'description' ]) ; |
745
|
|
|
|
|
|
|
# |
746
|
|
|
|
|
|
|
# =cut |
747
|
|
|
|
|
|
|
# |
748
|
|
|
|
|
|
|
# sub __websearch |
749
|
|
|
|
|
|
|
# { |
750
|
|
|
|
|
|
|
# my ($self,$requests,$args) = @_ ; |
751
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
752
|
|
|
|
|
|
|
# my $fields = join(';',@{$args}); |
753
|
|
|
|
|
|
|
# my $words = join(';',@{$requests}) ; |
754
|
|
|
|
|
|
|
# # chop $fields ; |
755
|
|
|
|
|
|
|
# warn "[Slackware::Slackget::Network] (debug::websearch) self=$self, words=$words, fields=$fields\n"; |
756
|
|
|
|
|
|
|
# $self->send_data("websearch:$self->{CONNID}:$words:$fields\n") ; |
757
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
758
|
|
|
|
|
|
|
# { |
759
|
|
|
|
|
|
|
# my $str = []; |
760
|
|
|
|
|
|
|
# my $idx = 0; |
761
|
|
|
|
|
|
|
# while(<$socket>) |
762
|
|
|
|
|
|
|
# { |
763
|
|
|
|
|
|
|
# if($_=~ /^wait:$self->{CONNID}:/) |
764
|
|
|
|
|
|
|
# { |
765
|
|
|
|
|
|
|
# sleep 1; |
766
|
|
|
|
|
|
|
# next ; |
767
|
|
|
|
|
|
|
# } |
768
|
|
|
|
|
|
|
# last if($_=~ /^end:$self->{CONNID}: websearch/); |
769
|
|
|
|
|
|
|
# if ($_=~ /auth_violation:$self->{CONNID}:\s*(.*)/) |
770
|
|
|
|
|
|
|
# { |
771
|
|
|
|
|
|
|
# return Slackware::Slackget::Network::Message->new( |
772
|
|
|
|
|
|
|
# is_success => undef, |
773
|
|
|
|
|
|
|
# ERROR_MSG => $1, |
774
|
|
|
|
|
|
|
# DATA => $_ |
775
|
|
|
|
|
|
|
# ); |
776
|
|
|
|
|
|
|
# last ; |
777
|
|
|
|
|
|
|
# } |
778
|
|
|
|
|
|
|
# my $code = $self->_handle_protocol($_) ; |
779
|
|
|
|
|
|
|
# if($_=~/__MARK__/) |
780
|
|
|
|
|
|
|
# { |
781
|
|
|
|
|
|
|
# $idx++; |
782
|
|
|
|
|
|
|
# } |
783
|
|
|
|
|
|
|
# else |
784
|
|
|
|
|
|
|
# { |
785
|
|
|
|
|
|
|
# $str->[$idx] .= $_; |
786
|
|
|
|
|
|
|
# } |
787
|
|
|
|
|
|
|
# last if($code==2); |
788
|
|
|
|
|
|
|
# } |
789
|
|
|
|
|
|
|
# return Slackware::Slackget::Network::Message->new( |
790
|
|
|
|
|
|
|
# is_success => 1, |
791
|
|
|
|
|
|
|
# DATA => $str |
792
|
|
|
|
|
|
|
# ); |
793
|
|
|
|
|
|
|
# } |
794
|
|
|
|
|
|
|
# |
795
|
|
|
|
|
|
|
# } |
796
|
|
|
|
|
|
|
# |
797
|
|
|
|
|
|
|
# =head2 __multisearch |
798
|
|
|
|
|
|
|
# |
799
|
|
|
|
|
|
|
# Take 2 parameters : a reference on an array which contains the words to search for, and another array reference which contains a list of fields (valid fields are thoses describe in the packages.xml file). |
800
|
|
|
|
|
|
|
# |
801
|
|
|
|
|
|
|
# |
802
|
|
|
|
|
|
|
# The DATA section of the response (L) will contain the XML encoded response. |
803
|
|
|
|
|
|
|
# |
804
|
|
|
|
|
|
|
# my $response = $network->websearch([ 'burn', 'cd' ], [ 'name', 'description' ]) ; |
805
|
|
|
|
|
|
|
# |
806
|
|
|
|
|
|
|
# =cut |
807
|
|
|
|
|
|
|
# |
808
|
|
|
|
|
|
|
# sub __multisearch |
809
|
|
|
|
|
|
|
# { |
810
|
|
|
|
|
|
|
# my ($self,$requests,$args) = @_ ; |
811
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
812
|
|
|
|
|
|
|
# my $fields = join(';',@{$args}); |
813
|
|
|
|
|
|
|
# my $words = join(';',@{$requests}) ; |
814
|
|
|
|
|
|
|
# # chop $fields ; |
815
|
|
|
|
|
|
|
# $self->send_data("multisearch:$self->{CONNID}:$words:$fields\n") ; |
816
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
817
|
|
|
|
|
|
|
# { |
818
|
|
|
|
|
|
|
# return $self->_handle_responses("search") ; |
819
|
|
|
|
|
|
|
# } |
820
|
|
|
|
|
|
|
# |
821
|
|
|
|
|
|
|
# } |
822
|
|
|
|
|
|
|
# |
823
|
|
|
|
|
|
|
# |
824
|
|
|
|
|
|
|
# =head2 __getfile |
825
|
|
|
|
|
|
|
# |
826
|
|
|
|
|
|
|
# This method allow you to download one or more files from a slack-get daemon. This method of download is specific to slack-get and is based on the EBCS protocol. |
827
|
|
|
|
|
|
|
# |
828
|
|
|
|
|
|
|
# Arguments are : |
829
|
|
|
|
|
|
|
# |
830
|
|
|
|
|
|
|
# files : pass a Slackware::Slackget::PackageList to this option. |
831
|
|
|
|
|
|
|
# |
832
|
|
|
|
|
|
|
# destdir : a string wich is the directory where will be stored the downloaded files. |
833
|
|
|
|
|
|
|
# |
834
|
|
|
|
|
|
|
# Here is a little code example : |
835
|
|
|
|
|
|
|
# |
836
|
|
|
|
|
|
|
# # $pkgl is a Slackware::Slackget::PackageList object. |
837
|
|
|
|
|
|
|
# $net->getfile( |
838
|
|
|
|
|
|
|
# file => $pkgl, |
839
|
|
|
|
|
|
|
# destdir => $sgo->config()->{common}->{'update-directory'}."/package-cache/" |
840
|
|
|
|
|
|
|
# ); |
841
|
|
|
|
|
|
|
# |
842
|
|
|
|
|
|
|
# =cut |
843
|
|
|
|
|
|
|
# |
844
|
|
|
|
|
|
|
# sub __getfile |
845
|
|
|
|
|
|
|
# { |
846
|
|
|
|
|
|
|
# my $self = shift; |
847
|
|
|
|
|
|
|
# my %args = @_ ; |
848
|
|
|
|
|
|
|
# # my $pkgl = $args{'file'}; |
849
|
|
|
|
|
|
|
# return Slackware::Slackget::Network::Message->new( |
850
|
|
|
|
|
|
|
# is_success => undef, |
851
|
|
|
|
|
|
|
# ERROR_MSG => "An object of Slackware::Slackget::PackageList type was waited, but another type of object has come.", |
852
|
|
|
|
|
|
|
# DATA => undef |
853
|
|
|
|
|
|
|
# ) if(ref($args{'file'}) ne 'Slackware::Slackget::PackageList') ; |
854
|
|
|
|
|
|
|
# # my $destdir = shift; |
855
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
856
|
|
|
|
|
|
|
# my $str = 'The following files have been successfully saved : '; |
857
|
|
|
|
|
|
|
# my $file; |
858
|
|
|
|
|
|
|
# my $write_in = 0; |
859
|
|
|
|
|
|
|
# # TODO: termin�ici : envoy�le message de requete de fichiers, et finir le code de r�up�ation des fichiers (voir par ex si il n'y as pas d'erreur). |
860
|
|
|
|
|
|
|
# my $requested_pkgs = ''; |
861
|
|
|
|
|
|
|
# $args{'file'}->index_list() ; |
862
|
|
|
|
|
|
|
# foreach (@{$args{'file'}->get_all}) |
863
|
|
|
|
|
|
|
# { |
864
|
|
|
|
|
|
|
# $requested_pkgs .= $_->get_id().';' |
865
|
|
|
|
|
|
|
# } |
866
|
|
|
|
|
|
|
# chop $requested_pkgs; |
867
|
|
|
|
|
|
|
# $self->send_data("getfile:$self->{CONNID}:$requested_pkgs\n"); |
868
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
869
|
|
|
|
|
|
|
# { |
870
|
|
|
|
|
|
|
# my $current_file; |
871
|
|
|
|
|
|
|
# while(<$socket>) |
872
|
|
|
|
|
|
|
# { |
873
|
|
|
|
|
|
|
# if($_=~ /^wait:$self->{CONNID}:/) |
874
|
|
|
|
|
|
|
# { |
875
|
|
|
|
|
|
|
# print "wait\n"; |
876
|
|
|
|
|
|
|
# sleep 2; |
877
|
|
|
|
|
|
|
# next ; |
878
|
|
|
|
|
|
|
# } |
879
|
|
|
|
|
|
|
# last if($_=~ /^end:$self->{CONNID}:\s*getfile/); |
880
|
|
|
|
|
|
|
# if ($_=~ /auth_violation:$self->{CONNID}:\s*(.*)/) |
881
|
|
|
|
|
|
|
# { |
882
|
|
|
|
|
|
|
# return Slackware::Slackget::Network::Message->new( |
883
|
|
|
|
|
|
|
# is_success => undef, |
884
|
|
|
|
|
|
|
# ERROR_MSG => $1, |
885
|
|
|
|
|
|
|
# DATA => $_ |
886
|
|
|
|
|
|
|
# ); |
887
|
|
|
|
|
|
|
# last ; |
888
|
|
|
|
|
|
|
# } |
889
|
|
|
|
|
|
|
# elsif($_ =~ /binaryfile:$self->{CONNID}:\s*(.+)/) |
890
|
|
|
|
|
|
|
# { |
891
|
|
|
|
|
|
|
# undef($file); |
892
|
|
|
|
|
|
|
# $file = Slackware::Slackget::File->new("$args{'destdir'}/$1",'no-auto-load' => 1, 'mode' => 'write','binary' => 1); |
893
|
|
|
|
|
|
|
# $current_file=$1; |
894
|
|
|
|
|
|
|
# $current_file=~ s/\.tgz//; |
895
|
|
|
|
|
|
|
# $write_in = 1; |
896
|
|
|
|
|
|
|
# } |
897
|
|
|
|
|
|
|
# elsif($_ =~ /end:$self->{CONNID}:binaryfile/) |
898
|
|
|
|
|
|
|
# { |
899
|
|
|
|
|
|
|
# $file->Write_and_close ; |
900
|
|
|
|
|
|
|
# $args{'file'}->get_indexed($current_file)->setValue('is-installable',1) ; |
901
|
|
|
|
|
|
|
# $current_file = ''; |
902
|
|
|
|
|
|
|
# $str .= $file->filename().' '; |
903
|
|
|
|
|
|
|
# $write_in = 0; |
904
|
|
|
|
|
|
|
# } |
905
|
|
|
|
|
|
|
# my $code = $self->_handle_protocol($_) ; |
906
|
|
|
|
|
|
|
# last if($code==2); |
907
|
|
|
|
|
|
|
# $file->Add($_) if($write_in && $code == 1); |
908
|
|
|
|
|
|
|
# } |
909
|
|
|
|
|
|
|
# return Slackware::Slackget::Network::Message->new( |
910
|
|
|
|
|
|
|
# is_success => 1, |
911
|
|
|
|
|
|
|
# DATA => $str |
912
|
|
|
|
|
|
|
# ); |
913
|
|
|
|
|
|
|
# } |
914
|
|
|
|
|
|
|
# |
915
|
|
|
|
|
|
|
# } |
916
|
|
|
|
|
|
|
# |
917
|
|
|
|
|
|
|
# =head2 __reboot |
918
|
|
|
|
|
|
|
# |
919
|
|
|
|
|
|
|
# This method ask the remote daemon to reboot the remote computer. |
920
|
|
|
|
|
|
|
# |
921
|
|
|
|
|
|
|
# =cut |
922
|
|
|
|
|
|
|
# |
923
|
|
|
|
|
|
|
# sub __reboot |
924
|
|
|
|
|
|
|
# { |
925
|
|
|
|
|
|
|
# my $self = shift; |
926
|
|
|
|
|
|
|
# $self->send_data("reboot:$self->{CONNID}\n"); |
927
|
|
|
|
|
|
|
# } |
928
|
|
|
|
|
|
|
# |
929
|
|
|
|
|
|
|
# =head2 __quit |
930
|
|
|
|
|
|
|
# |
931
|
|
|
|
|
|
|
# Close the current connection. |
932
|
|
|
|
|
|
|
# |
933
|
|
|
|
|
|
|
# $net->__quit ; |
934
|
|
|
|
|
|
|
# |
935
|
|
|
|
|
|
|
# =cut |
936
|
|
|
|
|
|
|
# |
937
|
|
|
|
|
|
|
# sub __quit { |
938
|
|
|
|
|
|
|
# my ($self,$mess) = @_ ; |
939
|
|
|
|
|
|
|
# $mess = "end session" unless(defined($mess)); |
940
|
|
|
|
|
|
|
# chomp $mess; |
941
|
|
|
|
|
|
|
# # print "[debug Slackware::Slackget::Network] sending \"quit:$self->{CONNID}:$mess\"\n"; |
942
|
|
|
|
|
|
|
# $self->send_data("quit:$self->{CONNID}:$mess\n") ; |
943
|
|
|
|
|
|
|
# # $self->{SOCKET}->close() ; |
944
|
|
|
|
|
|
|
# } |
945
|
|
|
|
|
|
|
# |
946
|
|
|
|
|
|
|
# =head1 ACCESSORS |
947
|
|
|
|
|
|
|
# |
948
|
|
|
|
|
|
|
# =head2 slackget (read only) |
949
|
|
|
|
|
|
|
# |
950
|
|
|
|
|
|
|
# return the current slackget10 object. |
951
|
|
|
|
|
|
|
# |
952
|
|
|
|
|
|
|
# =cut |
953
|
|
|
|
|
|
|
# |
954
|
|
|
|
|
|
|
# sub slackget |
955
|
|
|
|
|
|
|
# { |
956
|
|
|
|
|
|
|
# my $self = shift ; |
957
|
|
|
|
|
|
|
# return $self->{SGO} ; |
958
|
|
|
|
|
|
|
# } |
959
|
|
|
|
|
|
|
|
960
|
|
|
|
|
|
|
=head2 connection_id |
961
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
Get or set the connection ID. |
963
|
|
|
|
|
|
|
|
964
|
|
|
|
|
|
|
$net->connection_id(1234); |
965
|
|
|
|
|
|
|
print "Connection ID : ", $net->connection_id , "\n"; |
966
|
|
|
|
|
|
|
|
967
|
|
|
|
|
|
|
=cut |
968
|
|
|
|
|
|
|
|
969
|
|
|
|
|
|
|
sub connection_id |
970
|
|
|
|
|
|
|
{ |
971
|
0
|
0
|
|
0
|
1
|
|
return $_[1] ? $_[0]->{CONNID}=$_[1] : $_[0]->{CONNID}; |
972
|
|
|
|
|
|
|
} |
973
|
|
|
|
|
|
|
|
974
|
|
|
|
|
|
|
# =head2 handle_responses (read/write) |
975
|
|
|
|
|
|
|
# |
976
|
|
|
|
|
|
|
# Boolean accessor, get/set the value of the handle_responses option. |
977
|
|
|
|
|
|
|
# |
978
|
|
|
|
|
|
|
# =cut |
979
|
|
|
|
|
|
|
# |
980
|
|
|
|
|
|
|
# sub handle_responses |
981
|
|
|
|
|
|
|
# { |
982
|
|
|
|
|
|
|
# return $_[1] ? $_[0]->{DATA}->{data}=$_[1] : $_[0]->{DATA}->{data}; |
983
|
|
|
|
|
|
|
# } |
984
|
|
|
|
|
|
|
|
985
|
|
|
|
|
|
|
=head1 PKGTOOLS BINDINGS |
986
|
|
|
|
|
|
|
|
987
|
|
|
|
|
|
|
Methods in this section are the remote call procedure for pkgtools interactions. The slack-getd daemon use another class for direct call to the pkgtools (L). |
988
|
|
|
|
|
|
|
|
989
|
|
|
|
|
|
|
The 3 methods have the same operating mode : |
990
|
|
|
|
|
|
|
|
991
|
|
|
|
|
|
|
1) Take a single Slackware::Slackget::PackageList as argument |
992
|
|
|
|
|
|
|
|
993
|
|
|
|
|
|
|
2) Do the job |
994
|
|
|
|
|
|
|
|
995
|
|
|
|
|
|
|
3) If their is more than one choice for the package you try to install, the daemon ask for a choice of you. |
996
|
|
|
|
|
|
|
|
997
|
|
|
|
|
|
|
3bis) Re-do the job |
998
|
|
|
|
|
|
|
|
999
|
|
|
|
|
|
|
4) For each package in the Slackware::Slackget::PackageList set a 'status' field which contain the status of the (install|upgrade|remove) process. |
1000
|
|
|
|
|
|
|
|
1001
|
|
|
|
|
|
|
=head2 __installpkg |
1002
|
|
|
|
|
|
|
|
1003
|
|
|
|
|
|
|
$net->installpkg($packagelist) ; |
1004
|
|
|
|
|
|
|
|
1005
|
|
|
|
|
|
|
=cut |
1006
|
|
|
|
|
|
|
|
1007
|
|
|
|
|
|
|
sub __installpkg |
1008
|
|
|
|
|
|
|
{ |
1009
|
0
|
|
|
0
|
|
|
my ($self,$packagelist) = @_ ; |
1010
|
0
|
0
|
|
|
|
|
return undef if(ref($packagelist) ne 'Slackware::Slackget::PackageList') ; |
1011
|
0
|
|
|
|
|
|
my $request; |
1012
|
0
|
|
|
|
|
|
foreach (@{$packagelist->get_all}) |
|
0
|
|
|
|
|
|
|
1013
|
|
|
|
|
|
|
{ |
1014
|
0
|
|
|
|
|
|
$request .= $_->get_id().';'; |
1015
|
|
|
|
|
|
|
} |
1016
|
0
|
|
|
|
|
|
chop $request; |
1017
|
0
|
|
|
|
|
|
print "[DEBUG::Network::installpkg] request => $request\n"; |
1018
|
0
|
|
|
|
|
|
my $socket = $self->{SOCKET} ; |
1019
|
0
|
|
|
|
|
|
$self->send_data("installpkg:$self->{CONNID}:$request\n") ; |
1020
|
0
|
0
|
|
|
|
|
if($self->{handle_responses}) |
1021
|
|
|
|
|
|
|
{ |
1022
|
0
|
|
|
|
|
|
return $self->_handle_responses("installpkg","All packages marked for installation have been treated.") ; |
1023
|
|
|
|
|
|
|
} |
1024
|
0
|
|
|
|
|
|
return 1; |
1025
|
|
|
|
|
|
|
} |
1026
|
|
|
|
|
|
|
|
1027
|
|
|
|
|
|
|
=head2 __upgradepkg |
1028
|
|
|
|
|
|
|
|
1029
|
|
|
|
|
|
|
$net->upgradepkg($packagelist) ; |
1030
|
|
|
|
|
|
|
|
1031
|
|
|
|
|
|
|
=cut |
1032
|
|
|
|
|
|
|
|
1033
|
|
|
|
|
|
|
sub __upgradepkg |
1034
|
|
|
|
|
|
|
{ |
1035
|
0
|
|
|
0
|
|
|
my ($self,$packagelist) = @_ ; |
1036
|
0
|
0
|
|
|
|
|
return undef if(ref($packagelist) ne 'Slackware::Slackget::PackageList') ; |
1037
|
0
|
|
|
|
|
|
my $request; |
1038
|
0
|
|
|
|
|
|
foreach (@{$packagelist->get_all}) |
|
0
|
|
|
|
|
|
|
1039
|
|
|
|
|
|
|
{ |
1040
|
0
|
|
|
|
|
|
$request .= $_->get_id().';'; |
1041
|
|
|
|
|
|
|
} |
1042
|
0
|
|
|
|
|
|
chop $request; |
1043
|
0
|
|
|
|
|
|
print "[DEBUG::Network::installpkg] request => $request\n"; |
1044
|
0
|
|
|
|
|
|
my $socket = $self->{SOCKET} ; |
1045
|
0
|
|
|
|
|
|
$self->send_data("upgradepkg:$self->{CONNID}:$request\n") ; |
1046
|
0
|
0
|
|
|
|
|
if($self->{handle_responses}) |
1047
|
|
|
|
|
|
|
{ |
1048
|
0
|
|
|
|
|
|
return $self->_handle_responses("upgradepkg","All packages marked for upgrade have been treated.") ; |
1049
|
|
|
|
|
|
|
} |
1050
|
0
|
|
|
|
|
|
return 1; |
1051
|
|
|
|
|
|
|
} |
1052
|
|
|
|
|
|
|
|
1053
|
|
|
|
|
|
|
=head2 __removepkg |
1054
|
|
|
|
|
|
|
|
1055
|
|
|
|
|
|
|
Send network commands to a slack-get daemon. This method (like other pkgtools network call), do nothing by herself, but sending a "removepkg:pkg1;pkg2;..;pkgN" to the slack-getd. |
1056
|
|
|
|
|
|
|
|
1057
|
|
|
|
|
|
|
$net->removepkg($packagelist) ; |
1058
|
|
|
|
|
|
|
|
1059
|
|
|
|
|
|
|
=cut |
1060
|
|
|
|
|
|
|
|
1061
|
|
|
|
|
|
|
sub __removepkg |
1062
|
|
|
|
|
|
|
{ |
1063
|
0
|
|
|
0
|
|
|
my ($self,$packagelist) = @_ ; |
1064
|
0
|
|
|
|
|
|
print "[DEBUG::Network::removepkg] packagelist => $packagelist\n"; |
1065
|
0
|
0
|
|
|
|
|
return undef if(ref($packagelist) ne 'Slackware::Slackget::PackageList') ; |
1066
|
0
|
|
|
|
|
|
my $request; |
1067
|
0
|
|
|
|
|
|
foreach (@{$packagelist->get_all}) |
|
0
|
|
|
|
|
|
|
1068
|
|
|
|
|
|
|
{ |
1069
|
0
|
|
|
|
|
|
$request .= $_->get_id().';'; |
1070
|
|
|
|
|
|
|
} |
1071
|
0
|
|
|
|
|
|
chop $request; |
1072
|
0
|
|
|
|
|
|
print "[DEBUG::Network::removepkg] request => $request\n"; |
1073
|
0
|
|
|
|
|
|
my $socket = $self->{SOCKET} ; |
1074
|
0
|
|
|
|
|
|
$self->send_data("removepkg:$self->{CONNID}:$request\n") ; |
1075
|
0
|
0
|
|
|
|
|
if($self->{handle_responses}) |
1076
|
|
|
|
|
|
|
{ |
1077
|
0
|
|
|
|
|
|
return $self->_handle_responses("removepkg","All packages marked for remove have been treated.") ; |
1078
|
|
|
|
|
|
|
} |
1079
|
0
|
|
|
|
|
|
return 1; |
1080
|
|
|
|
|
|
|
} |
1081
|
|
|
|
|
|
|
|
1082
|
|
|
|
|
|
|
=head1 DEFAULT HANDLERS |
1083
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
Since the 0.12 release there is no more default handlers. |
1085
|
|
|
|
|
|
|
|
1086
|
|
|
|
|
|
|
=cut |
1087
|
|
|
|
|
|
|
|
1088
|
|
|
|
|
|
|
|
1089
|
|
|
|
|
|
|
=head1 AUTHOR |
1090
|
|
|
|
|
|
|
|
1091
|
|
|
|
|
|
|
DUPUIS Arnaud, C<< >> |
1092
|
|
|
|
|
|
|
|
1093
|
|
|
|
|
|
|
=head1 BUGS |
1094
|
|
|
|
|
|
|
|
1095
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
1096
|
|
|
|
|
|
|
C, or through the web interface at |
1097
|
|
|
|
|
|
|
L. |
1098
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
1099
|
|
|
|
|
|
|
your bug as I make changes. |
1100
|
|
|
|
|
|
|
|
1101
|
|
|
|
|
|
|
=head1 SUPPORT |
1102
|
|
|
|
|
|
|
|
1103
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
1104
|
|
|
|
|
|
|
|
1105
|
|
|
|
|
|
|
perldoc Slackware::Slackget |
1106
|
|
|
|
|
|
|
|
1107
|
|
|
|
|
|
|
|
1108
|
|
|
|
|
|
|
You can also look for information at: |
1109
|
|
|
|
|
|
|
|
1110
|
|
|
|
|
|
|
=over 4 |
1111
|
|
|
|
|
|
|
|
1112
|
|
|
|
|
|
|
=item * Infinity Perl website |
1113
|
|
|
|
|
|
|
|
1114
|
|
|
|
|
|
|
L |
1115
|
|
|
|
|
|
|
|
1116
|
|
|
|
|
|
|
=item * slack-get specific website |
1117
|
|
|
|
|
|
|
|
1118
|
|
|
|
|
|
|
L |
1119
|
|
|
|
|
|
|
|
1120
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
L |
1123
|
|
|
|
|
|
|
|
1124
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
1125
|
|
|
|
|
|
|
|
1126
|
|
|
|
|
|
|
L |
1127
|
|
|
|
|
|
|
|
1128
|
|
|
|
|
|
|
=item * CPAN Ratings |
1129
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
L |
1131
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
=item * Search CPAN |
1133
|
|
|
|
|
|
|
|
1134
|
|
|
|
|
|
|
L |
1135
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
=back |
1137
|
|
|
|
|
|
|
|
1138
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
1139
|
|
|
|
|
|
|
|
1140
|
|
|
|
|
|
|
Thanks to Bertrand Dupuis (yes my brother) for his contribution to the documentation. |
1141
|
|
|
|
|
|
|
|
1142
|
|
|
|
|
|
|
=head1 SEE ALSO |
1143
|
|
|
|
|
|
|
|
1144
|
|
|
|
|
|
|
L, L, L |
1145
|
|
|
|
|
|
|
|
1146
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
1147
|
|
|
|
|
|
|
|
1148
|
|
|
|
|
|
|
Copyright 2005 DUPUIS Arnaud, All Rights Reserved. |
1149
|
|
|
|
|
|
|
|
1150
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
1151
|
|
|
|
|
|
|
under the same terms as Perl itself. |
1152
|
|
|
|
|
|
|
|
1153
|
|
|
|
|
|
|
=cut |
1154
|
|
|
|
|
|
|
|
1155
|
|
|
|
|
|
|
1; # End of Slackware::Slackget::Network |