line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Jabber::PubSub::JEAI;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
23643
|
use 5.008003;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
43
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings;
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
49
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter;
|
8
|
1
|
|
|
1
|
|
926
|
use AutoLoader qw(AUTOLOAD);
|
|
1
|
|
|
|
|
1625
|
|
|
1
|
|
|
|
|
6
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter);
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export
|
13
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead.
|
14
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants.
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# This allows declaration use Jabber::PubSub::JEAI ':all';
|
17
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
|
18
|
|
|
|
|
|
|
# will save memory.
|
19
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw(
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
) ] );
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @EXPORT = qw(
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
);
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our $VERSION = '0.03';
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Preloaded methods go here.
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program.
|
35
|
1
|
|
|
1
|
|
567
|
use Net::Jabber qw(Client);
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub create_channel{
|
37
|
|
|
|
|
|
|
my $p = shift;
|
38
|
|
|
|
|
|
|
my ($uid,$pwd,$host,$port,$resource) = &conn_info($p);
|
39
|
|
|
|
|
|
|
my $timestamp = time;
|
40
|
|
|
|
|
|
|
my ($channel,$to,$iq_id,$payload);
|
41
|
|
|
|
|
|
|
unless (defined $p->{'to'}){
|
42
|
|
|
|
|
|
|
warn "Missing service name: using pubsub.localhost instead.";
|
43
|
|
|
|
|
|
|
$to = 'pubsub.localhost';
|
44
|
|
|
|
|
|
|
}else{
|
45
|
|
|
|
|
|
|
$to = $p->{'to'}||'pubsub.localhost';
|
46
|
|
|
|
|
|
|
}
|
47
|
|
|
|
|
|
|
unless (defined $p->{'iq_id'}){
|
48
|
|
|
|
|
|
|
warn "Missing IQ ID: using default.";
|
49
|
|
|
|
|
|
|
$iq_id = 'creating_on_'.$timestamp;
|
50
|
|
|
|
|
|
|
}else{
|
51
|
|
|
|
|
|
|
$iq_id = $p->{'iq_id'}||'creating_on_'.$timestamp;
|
52
|
|
|
|
|
|
|
}
|
53
|
|
|
|
|
|
|
unless (defined $p->{'channel'}){
|
54
|
|
|
|
|
|
|
die "Missing channel name.";
|
55
|
|
|
|
|
|
|
}else{
|
56
|
|
|
|
|
|
|
$channel = $p->{'channel'};
|
57
|
|
|
|
|
|
|
}
|
58
|
|
|
|
|
|
|
my ($Jabber,$vCard,@connect);
|
59
|
|
|
|
|
|
|
eval{
|
60
|
|
|
|
|
|
|
$Jabber = Net::XMPP::Client->new();
|
61
|
|
|
|
|
|
|
$Jabber->Connect(
|
62
|
|
|
|
|
|
|
hostname => $host,
|
63
|
|
|
|
|
|
|
port => $port,
|
64
|
|
|
|
|
|
|
);
|
65
|
|
|
|
|
|
|
@connect = $Jabber->AuthSend(
|
66
|
|
|
|
|
|
|
username => $uid,
|
67
|
|
|
|
|
|
|
password => $pwd,
|
68
|
|
|
|
|
|
|
resource => $resource,
|
69
|
|
|
|
|
|
|
);
|
70
|
|
|
|
|
|
|
};
|
71
|
|
|
|
|
|
|
die $! if($@);
|
72
|
|
|
|
|
|
|
if ($connect[0] ne "ok") {
|
73
|
|
|
|
|
|
|
die "Ident/Auth with server failed: $connect[0] - $connect[1]\n";
|
74
|
|
|
|
|
|
|
}else{
|
75
|
|
|
|
|
|
|
print "User $uid is connected to Jabber server $host on port $port...\n";
|
76
|
|
|
|
|
|
|
}
|
77
|
|
|
|
|
|
|
my $xml = qq|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|;
|
80
|
|
|
|
|
|
|
eval{
|
81
|
|
|
|
|
|
|
$vCard = new Net::Jabber::IQ();
|
82
|
|
|
|
|
|
|
$vCard->SetIQ(type=>'set', to=>$to, id=> $iq_id);
|
83
|
|
|
|
|
|
|
$vCard->InsertRawXML($xml);
|
84
|
|
|
|
|
|
|
$Jabber->Send($vCard);
|
85
|
|
|
|
|
|
|
};
|
86
|
|
|
|
|
|
|
die $! if($@);
|
87
|
|
|
|
|
|
|
print "User $uid has ordered to create pub/sub channel $channel.\n";
|
88
|
|
|
|
|
|
|
1;
|
89
|
|
|
|
|
|
|
}
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub delete_channel{
|
92
|
|
|
|
|
|
|
my $p = shift;
|
93
|
|
|
|
|
|
|
my ($uid,$pwd,$host,$port,$resource) = &conn_info($p);
|
94
|
|
|
|
|
|
|
my $timestamp = time;
|
95
|
|
|
|
|
|
|
my ($channel,$to,$iq_id,$payload);
|
96
|
|
|
|
|
|
|
unless (defined $p->{'to'}){
|
97
|
|
|
|
|
|
|
warn "Missing service name: using pubsub.localhost instead.";
|
98
|
|
|
|
|
|
|
$to = 'pubsub.localhost';
|
99
|
|
|
|
|
|
|
}else{
|
100
|
|
|
|
|
|
|
$to = $p->{'to'}||'pubsub.localhost';
|
101
|
|
|
|
|
|
|
}
|
102
|
|
|
|
|
|
|
unless (defined $p->{'iq_id'}){
|
103
|
|
|
|
|
|
|
warn "Missing IQ ID: using default.";
|
104
|
|
|
|
|
|
|
$iq_id = 'deleting_on_'.$timestamp;
|
105
|
|
|
|
|
|
|
}else{
|
106
|
|
|
|
|
|
|
$iq_id = $p->{'iq_id'}||'deleting_on_'.$timestamp;
|
107
|
|
|
|
|
|
|
}
|
108
|
|
|
|
|
|
|
unless (defined $p->{'channel'}){
|
109
|
|
|
|
|
|
|
die "Missing channel name.";
|
110
|
|
|
|
|
|
|
}else{
|
111
|
|
|
|
|
|
|
$channel = $p->{'channel'};
|
112
|
|
|
|
|
|
|
}
|
113
|
|
|
|
|
|
|
my ($Jabber,$vCard,@connect);
|
114
|
|
|
|
|
|
|
eval{
|
115
|
|
|
|
|
|
|
$Jabber = Net::XMPP::Client->new();
|
116
|
|
|
|
|
|
|
$Jabber->Connect(
|
117
|
|
|
|
|
|
|
hostname => $host,
|
118
|
|
|
|
|
|
|
port => $port,
|
119
|
|
|
|
|
|
|
);
|
120
|
|
|
|
|
|
|
@connect = $Jabber->AuthSend(
|
121
|
|
|
|
|
|
|
username => $uid,
|
122
|
|
|
|
|
|
|
password => $pwd,
|
123
|
|
|
|
|
|
|
resource => $resource,
|
124
|
|
|
|
|
|
|
);
|
125
|
|
|
|
|
|
|
};
|
126
|
|
|
|
|
|
|
die $! if($@);
|
127
|
|
|
|
|
|
|
if ($connect[0] ne "ok") {
|
128
|
|
|
|
|
|
|
die "Ident/Auth with server failed: $connect[0] - $connect[1]\n";
|
129
|
|
|
|
|
|
|
}else{
|
130
|
|
|
|
|
|
|
print "User $uid is connected to Jabber server $host on port $port...\n";
|
131
|
|
|
|
|
|
|
}
|
132
|
|
|
|
|
|
|
my $xml = qq|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|;
|
135
|
|
|
|
|
|
|
eval{
|
136
|
|
|
|
|
|
|
$vCard = new Net::Jabber::IQ();
|
137
|
|
|
|
|
|
|
$vCard->SetIQ(type=>'set', to=>$to, id=> $iq_id);
|
138
|
|
|
|
|
|
|
$vCard->InsertRawXML($xml);
|
139
|
|
|
|
|
|
|
$Jabber->Send($vCard);
|
140
|
|
|
|
|
|
|
};
|
141
|
|
|
|
|
|
|
die $! if($@);
|
142
|
|
|
|
|
|
|
print "User $uid has ordered to delete pub/sub channel $channel.\n";
|
143
|
|
|
|
|
|
|
1;
|
144
|
|
|
|
|
|
|
}
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub subscribe {
|
147
|
|
|
|
|
|
|
my $p = shift;
|
148
|
|
|
|
|
|
|
my ($uid,$pwd,$host,$port,$resource) = &conn_info($p);
|
149
|
|
|
|
|
|
|
my $timestamp = time;
|
150
|
|
|
|
|
|
|
my ($channel,$to,$iq_id,$payload);
|
151
|
|
|
|
|
|
|
unless (defined $p->{'to'}){
|
152
|
|
|
|
|
|
|
warn "Missing service name: using pubsub.localhost instead.";
|
153
|
|
|
|
|
|
|
$to = 'pubsub.localhost';
|
154
|
|
|
|
|
|
|
}else{
|
155
|
|
|
|
|
|
|
$to = $p->{'to'}||'pubsub.localhost';
|
156
|
|
|
|
|
|
|
}
|
157
|
|
|
|
|
|
|
unless (defined $p->{'iq_id'}){
|
158
|
|
|
|
|
|
|
warn "Missing IQ ID: using default.";
|
159
|
|
|
|
|
|
|
$iq_id = 'subscribing_on_'.$timestamp;
|
160
|
|
|
|
|
|
|
}else{
|
161
|
|
|
|
|
|
|
$iq_id = $p->{'iq_id'}||'subscribing_on_'.$timestamp;
|
162
|
|
|
|
|
|
|
}
|
163
|
|
|
|
|
|
|
unless (defined $p->{'channel'}){
|
164
|
|
|
|
|
|
|
die "Missing channel name.";
|
165
|
|
|
|
|
|
|
}else{
|
166
|
|
|
|
|
|
|
$channel = $p->{'channel'};
|
167
|
|
|
|
|
|
|
}
|
168
|
|
|
|
|
|
|
my ($Jabber,$vCard,@connect);
|
169
|
|
|
|
|
|
|
eval{
|
170
|
|
|
|
|
|
|
$Jabber = Net::XMPP::Client->new();
|
171
|
|
|
|
|
|
|
$Jabber->Connect(
|
172
|
|
|
|
|
|
|
hostname => $host,
|
173
|
|
|
|
|
|
|
port => $port,
|
174
|
|
|
|
|
|
|
);
|
175
|
|
|
|
|
|
|
@connect = $Jabber->AuthSend(
|
176
|
|
|
|
|
|
|
username => $uid,
|
177
|
|
|
|
|
|
|
password => $pwd,
|
178
|
|
|
|
|
|
|
resource => $resource,
|
179
|
|
|
|
|
|
|
);
|
180
|
|
|
|
|
|
|
};
|
181
|
|
|
|
|
|
|
die $! if($@);
|
182
|
|
|
|
|
|
|
if ($connect[0] ne "ok") {
|
183
|
|
|
|
|
|
|
die "Ident/Auth with server failed: $connect[0] - $connect[1]\n";
|
184
|
|
|
|
|
|
|
}else{
|
185
|
|
|
|
|
|
|
print "User $uid is connected to Jabber server $host on port $port...\n";
|
186
|
|
|
|
|
|
|
}
|
187
|
|
|
|
|
|
|
eval{
|
188
|
|
|
|
|
|
|
my $xml = qq|
|
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
|;
|
191
|
|
|
|
|
|
|
$vCard = new Net::Jabber::IQ();
|
192
|
|
|
|
|
|
|
$vCard->SetIQ(type=>'set', to=>$to, id=> $iq_id);
|
193
|
|
|
|
|
|
|
$vCard->InsertRawXML($xml);
|
194
|
|
|
|
|
|
|
$Jabber->Send($vCard);
|
195
|
|
|
|
|
|
|
};
|
196
|
|
|
|
|
|
|
die $! if($@);
|
197
|
|
|
|
|
|
|
print "User $uid has ordered to subscribe to channel $channel.\n";
|
198
|
|
|
|
|
|
|
1;
|
199
|
|
|
|
|
|
|
}
|
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub publish {
|
202
|
|
|
|
|
|
|
my $p = shift;
|
203
|
|
|
|
|
|
|
my ($uid,$pwd,$host,$port,$resource) = &conn_info($p);
|
204
|
|
|
|
|
|
|
my $timestamp = time;
|
205
|
|
|
|
|
|
|
my ($channel,$to,$iq_id,$payload);
|
206
|
|
|
|
|
|
|
unless (defined $p->{'to'}){
|
207
|
|
|
|
|
|
|
warn "Missing service name: using pubsub.localhost instead.";
|
208
|
|
|
|
|
|
|
$to = 'pubsub.localhost';
|
209
|
|
|
|
|
|
|
}else{
|
210
|
|
|
|
|
|
|
$to = $p->{'to'}||'pubsub.localhost';
|
211
|
|
|
|
|
|
|
}
|
212
|
|
|
|
|
|
|
unless (defined $p->{'iq_id'}){
|
213
|
|
|
|
|
|
|
warn "Missing IQ ID: using default.";
|
214
|
|
|
|
|
|
|
$iq_id = 'publishing_on_'.$timestamp;
|
215
|
|
|
|
|
|
|
}else{
|
216
|
|
|
|
|
|
|
$iq_id = $p->{'iq_id'}||'publishing_on_'.$timestamp;
|
217
|
|
|
|
|
|
|
}
|
218
|
|
|
|
|
|
|
unless (defined $p->{'channel'}){
|
219
|
|
|
|
|
|
|
die "Missing channel name.";
|
220
|
|
|
|
|
|
|
}else{
|
221
|
|
|
|
|
|
|
$channel = $p->{'channel'};
|
222
|
|
|
|
|
|
|
}
|
223
|
|
|
|
|
|
|
unless (defined $p->{'payload'}){
|
224
|
|
|
|
|
|
|
die "Missing payload."
|
225
|
|
|
|
|
|
|
}else{
|
226
|
|
|
|
|
|
|
$payload = $p->{'payload'};
|
227
|
|
|
|
|
|
|
}
|
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
my ($Jabber,$vCard,@connect);
|
230
|
|
|
|
|
|
|
eval{
|
231
|
|
|
|
|
|
|
$Jabber = Net::XMPP::Client->new();
|
232
|
|
|
|
|
|
|
$Jabber->Connect(
|
233
|
|
|
|
|
|
|
hostname => $host,
|
234
|
|
|
|
|
|
|
port => $port,
|
235
|
|
|
|
|
|
|
);
|
236
|
|
|
|
|
|
|
@connect = $Jabber->AuthSend(
|
237
|
|
|
|
|
|
|
username => $uid,
|
238
|
|
|
|
|
|
|
password => $pwd,
|
239
|
|
|
|
|
|
|
resource => $resource,
|
240
|
|
|
|
|
|
|
);
|
241
|
|
|
|
|
|
|
};
|
242
|
|
|
|
|
|
|
die $! if($@);
|
243
|
|
|
|
|
|
|
if ($connect[0] ne "ok") {
|
244
|
|
|
|
|
|
|
die "Ident/Auth with server failed: $connect[0] - $connect[1]\n";
|
245
|
|
|
|
|
|
|
}else{
|
246
|
|
|
|
|
|
|
print "User $uid is connected to Jabber server $host on port $port...\n";
|
247
|
|
|
|
|
|
|
}
|
248
|
|
|
|
|
|
|
eval{
|
249
|
|
|
|
|
|
|
my $xml = qq|
|
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
- $payload
|
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
|;
|
254
|
|
|
|
|
|
|
$vCard = new Net::Jabber::IQ();
|
255
|
|
|
|
|
|
|
$vCard->SetIQ(type=>'set', to=>$to, id=> $iq_id);
|
256
|
|
|
|
|
|
|
$vCard->InsertRawXML($xml);
|
257
|
|
|
|
|
|
|
my $res = $Jabber->Send($vCard);
|
258
|
|
|
|
|
|
|
};
|
259
|
|
|
|
|
|
|
die $! if($@);
|
260
|
|
|
|
|
|
|
print "User $uid has sent a message to channel $channel.\n";
|
261
|
|
|
|
|
|
|
1;
|
262
|
|
|
|
|
|
|
}
|
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
sub listen {
|
266
|
|
|
|
|
|
|
my $p = shift;
|
267
|
|
|
|
|
|
|
my ($uid,$pwd,$host,$port,$resource) = &conn_info($p);
|
268
|
|
|
|
|
|
|
my $timestamp = time;
|
269
|
|
|
|
|
|
|
my ($channel,$to,$iq_id,$payload);
|
270
|
|
|
|
|
|
|
my ($Jabber,$Presence, @connect);
|
271
|
|
|
|
|
|
|
eval{
|
272
|
|
|
|
|
|
|
$Jabber = Net::XMPP::Client->new();
|
273
|
|
|
|
|
|
|
$Presence = Net::XMPP::Presence->new();
|
274
|
|
|
|
|
|
|
$Jabber->Connect(
|
275
|
|
|
|
|
|
|
hostname => $host,
|
276
|
|
|
|
|
|
|
port => $port,
|
277
|
|
|
|
|
|
|
);
|
278
|
|
|
|
|
|
|
@connect = $Jabber->AuthSend(
|
279
|
|
|
|
|
|
|
username => $uid,
|
280
|
|
|
|
|
|
|
password => $pwd,
|
281
|
|
|
|
|
|
|
resource => $resource,
|
282
|
|
|
|
|
|
|
);
|
283
|
|
|
|
|
|
|
};
|
284
|
|
|
|
|
|
|
die $! if($@);
|
285
|
|
|
|
|
|
|
if ($connect[0] ne "ok") {
|
286
|
|
|
|
|
|
|
die "Ident/Auth with server failed: $connect[0] - $connect[1]\n";
|
287
|
|
|
|
|
|
|
}else{
|
288
|
|
|
|
|
|
|
print "User $uid is connected to Jabber server $host on port $port...\n";
|
289
|
|
|
|
|
|
|
}
|
290
|
|
|
|
|
|
|
$Presence->SetType("available");
|
291
|
|
|
|
|
|
|
$Presence->SetStatus("Ask me! Ask me, now!");
|
292
|
|
|
|
|
|
|
$Jabber->Send($Presence);
|
293
|
|
|
|
|
|
|
$Jabber->SetCallBacks(message=>\&handle_message, presence=>\&handle_presence, iq=>\&handle_iq,);
|
294
|
|
|
|
|
|
|
my $lookups = 0;
|
295
|
|
|
|
|
|
|
my $max_lookups = 10;
|
296
|
|
|
|
|
|
|
while (defined($Jabber->Process())) {
|
297
|
|
|
|
|
|
|
my $current_type = $Presence->GetType();
|
298
|
|
|
|
|
|
|
if (($lookups >= $max_lookups) && ($current_type ne "unavailable")) {
|
299
|
|
|
|
|
|
|
$Presence->SetType("unavailable");
|
300
|
|
|
|
|
|
|
$Presence->SetStatus("I am helping someone else right now.");
|
301
|
|
|
|
|
|
|
$Jabber->Send($Presence);
|
302
|
|
|
|
|
|
|
}
|
303
|
|
|
|
|
|
|
if ( ($lookups < $max_lookups) && ($current_type ne "available")) {
|
304
|
|
|
|
|
|
|
$Presence->SetType("available");
|
305
|
|
|
|
|
|
|
$Presence->SetStatus("Ask me! Ask me, now!");
|
306
|
|
|
|
|
|
|
$Jabber->Send($Presence);
|
307
|
|
|
|
|
|
|
}
|
308
|
|
|
|
|
|
|
}
|
309
|
|
|
|
|
|
|
1;
|
310
|
|
|
|
|
|
|
}
|
311
|
|
|
|
|
|
|
sub handle_message {
|
312
|
|
|
|
|
|
|
shift;
|
313
|
|
|
|
|
|
|
my $msg = shift->GetX();
|
314
|
|
|
|
|
|
|
my $item = $msg->{TREE}->{CHILDREN}->[0]->{CHILDREN}->[0]->{CHILDREN}->[0]->{CHILDREN}->[0];
|
315
|
|
|
|
|
|
|
print $item,"\n";
|
316
|
|
|
|
|
|
|
return $item;
|
317
|
|
|
|
|
|
|
}
|
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
sub handle_presence {
|
320
|
|
|
|
|
|
|
print Dumper(\@_);
|
321
|
|
|
|
|
|
|
return \@_;
|
322
|
|
|
|
|
|
|
}
|
323
|
|
|
|
|
|
|
sub handle_iq {
|
324
|
|
|
|
|
|
|
print Dumper(\@_);
|
325
|
|
|
|
|
|
|
return \@_;
|
326
|
|
|
|
|
|
|
}
|
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
sub conn_info {
|
329
|
|
|
|
|
|
|
my $p = shift;
|
330
|
|
|
|
|
|
|
die "Missing input param." unless(defined $p);
|
331
|
|
|
|
|
|
|
my ($uid,$pwd,$host,$port,$resource,$channel,$to,$iq_id,$payload);
|
332
|
|
|
|
|
|
|
my $timestamp = time;
|
333
|
|
|
|
|
|
|
unless (defined $p->{'uid'}){
|
334
|
|
|
|
|
|
|
die "Missing ID of the channel owner.";
|
335
|
|
|
|
|
|
|
}else{
|
336
|
|
|
|
|
|
|
$uid = $p->{'uid'};
|
337
|
|
|
|
|
|
|
}
|
338
|
|
|
|
|
|
|
unless (defined $p->{'pwd'}){
|
339
|
|
|
|
|
|
|
die "Missing password of the channel owner.";
|
340
|
|
|
|
|
|
|
}else{
|
341
|
|
|
|
|
|
|
$pwd = $p->{'pwd'};
|
342
|
|
|
|
|
|
|
}
|
343
|
|
|
|
|
|
|
unless (defined $p->{'host'}){
|
344
|
|
|
|
|
|
|
warn "Missing host name: using localhost instead.";
|
345
|
|
|
|
|
|
|
$host = 'localhost';
|
346
|
|
|
|
|
|
|
}else{
|
347
|
|
|
|
|
|
|
$host = $p->{'host'}||'localhost';
|
348
|
|
|
|
|
|
|
}
|
349
|
|
|
|
|
|
|
unless (defined $p->{'port'}){
|
350
|
|
|
|
|
|
|
warn "Missing port number: using 5222 instead.";
|
351
|
|
|
|
|
|
|
$port = 5222;
|
352
|
|
|
|
|
|
|
}else{
|
353
|
|
|
|
|
|
|
$port = $p->{'port'}||5222;
|
354
|
|
|
|
|
|
|
}
|
355
|
|
|
|
|
|
|
unless (defined $p->{'resource'}){
|
356
|
|
|
|
|
|
|
warn "Missing resource name: using PerlScript instead.";
|
357
|
|
|
|
|
|
|
$resource = 'PerlScript';
|
358
|
|
|
|
|
|
|
}else{
|
359
|
|
|
|
|
|
|
$resource = $p->{'resource'}||'PerlScript';
|
360
|
|
|
|
|
|
|
}
|
361
|
|
|
|
|
|
|
return ($uid,$pwd,$host,$port,$resource);
|
362
|
|
|
|
|
|
|
}
|
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
1;
|
365
|
|
|
|
|
|
|
__END__
|