line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=pod |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Net::OSCAR::Buddylist -- tied hash class whose keys are Net::OSCAR::Screennames and which also maintains the ordering of its keys. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
version 1.928 |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
OSCAR screennames don't compare like normal scalars; they're case and whitespace-insensitive. |
14
|
|
|
|
|
|
|
This is a tied hash class that has that behavior for its keys. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package Net::OSCAR::Buddylist; |
19
|
|
|
|
|
|
|
BEGIN { |
20
|
4
|
|
|
4
|
|
133
|
$Net::OSCAR::Buddylist::VERSION = '1.928'; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$REVISION = '$Revision$'; |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
4
|
|
121
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
115
|
|
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
4
|
|
20
|
use Carp; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
228
|
|
28
|
4
|
|
|
4
|
|
1870
|
use Net::OSCAR::Screenname; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
110
|
|
29
|
4
|
|
|
4
|
|
19
|
use Net::OSCAR::Utility qw(normalize); |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
4119
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new { |
32
|
0
|
|
|
0
|
0
|
0
|
my $pkg = shift; |
33
|
0
|
|
|
|
|
0
|
$pkg->{nonorm} = 0; |
34
|
0
|
0
|
|
|
|
0
|
$pkg->{nonorm} = shift if @_; |
35
|
0
|
|
|
|
|
0
|
$pkg->TIEHASH(@_); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub setorder { |
39
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Anything not specified gets shoved at the end |
42
|
0
|
|
|
|
|
0
|
my @end = grep { my $inbud = $_; not grep { $_ eq $inbud } @_ } @{$self->{ORDERFORM}}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
0
|
@{$self->{ORDERFORM}} = @_; |
|
0
|
|
|
|
|
0
|
|
45
|
0
|
|
|
|
|
0
|
push @{$self->{ORDERFORM}}, @end; |
|
0
|
|
|
|
|
0
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub TIEHASH { |
49
|
2
|
|
|
2
|
|
2
|
my $class = shift; |
50
|
2
|
|
|
|
|
8
|
my $self = { DATA => {}, ORDERFORM => [], CURRKEY => -1}; |
51
|
2
|
|
|
|
|
9
|
return bless $self, $class; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub FETCH { |
55
|
0
|
|
|
0
|
|
0
|
my($self, $key) = @_; |
56
|
0
|
0
|
|
|
|
0
|
confess "\$self was undefined!" unless defined($self); |
57
|
0
|
0
|
|
|
|
0
|
return undef unless $key; |
58
|
0
|
0
|
|
|
|
0
|
$self->{DATA}->{$self->{nonorm} ? $key : normalize($key)}; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub STORE { |
62
|
2
|
|
|
2
|
|
4
|
my($self, $key, $value) = @_; |
63
|
2
|
50
|
|
|
|
15
|
if(exists $self->{DATA}->{$self->{nonorm} ? $key : normalize($key)}) { |
|
|
50
|
|
|
|
|
|
64
|
0
|
|
|
|
|
0
|
my $foo = 0; |
65
|
0
|
|
|
|
|
0
|
for(my $i = 0; $i < scalar @{$self->{ORDERFORM}}; $i++) { |
|
0
|
|
|
|
|
0
|
|
66
|
0
|
0
|
|
|
|
0
|
next unless $key eq $self->{ORDERFORM}->[$i]; |
67
|
0
|
|
|
|
|
0
|
$foo = 1; |
68
|
0
|
0
|
|
|
|
0
|
$self->{ORDERFORM}->[$i] = $self->{nonorm} ? $key : Net::OSCAR::Screenname->new($key); |
69
|
0
|
|
|
|
|
0
|
last; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} else { |
72
|
2
|
50
|
|
|
|
2
|
push @{$self->{ORDERFORM}}, $self->{nonorm} ? $key : Net::OSCAR::Screenname->new($key); |
|
2
|
|
|
|
|
15
|
|
73
|
|
|
|
|
|
|
} |
74
|
2
|
50
|
|
|
|
8
|
$self->{DATA}->{$self->{nonorm} ? $key : normalize($key)} = $value; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub DELETE { |
78
|
0
|
|
|
0
|
|
|
my($self, $key) = @_; |
79
|
0
|
0
|
|
|
|
|
my $retval = delete $self->{DATA}->{$self->{nonorm} ? $key : normalize($key)}; |
80
|
0
|
|
|
|
|
|
my $foo = 0; |
81
|
0
|
|
|
|
|
|
for(my $i = 0; $i < scalar @{$self->{ORDERFORM}}; $i++) { |
|
0
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
next unless $key eq $self->{ORDERFORM}->[$i]; |
83
|
0
|
|
|
|
|
|
$foo = 1; |
84
|
0
|
|
|
|
|
|
splice(@{$self->{ORDERFORM}}, $i, 1); |
|
0
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# What if the user deletes a key while iterating? We need to correct for the new index. |
87
|
0
|
0
|
0
|
|
|
|
if($self->{CURRKEY} != -1 and $i <= $self->{CURRKEY}) { |
88
|
0
|
|
|
|
|
|
$self->{CURRKEY}--; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
last; |
92
|
|
|
|
|
|
|
} |
93
|
0
|
|
|
|
|
|
return $retval; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub CLEAR { |
97
|
0
|
|
|
0
|
|
|
my $self = shift; |
98
|
0
|
|
|
|
|
|
$self->{DATA} = {}; |
99
|
0
|
|
|
|
|
|
$self->{ORDERFORM} = []; |
100
|
0
|
|
|
|
|
|
$self->{CURRKEY} = -1; |
101
|
0
|
|
|
|
|
|
return $self; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub EXISTS { |
105
|
0
|
|
|
0
|
|
|
my($self, $key) = @_; |
106
|
0
|
0
|
|
|
|
|
return exists $self->{DATA}->{$self->{nonorm} ? $key : normalize($key)}; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub FIRSTKEY { |
110
|
0
|
|
|
0
|
|
|
$_[0]->{CURRKEY} = -1; |
111
|
0
|
|
|
|
|
|
goto &NEXTKEY; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub NEXTKEY { |
115
|
0
|
|
|
0
|
|
|
my ($self, $currkey) = @_; |
116
|
0
|
|
|
|
|
|
$currkey = ++$self->{CURRKEY}; |
117
|
|
|
|
|
|
|
|
118
|
0
|
0
|
|
|
|
|
if($currkey >= scalar @{$self->{ORDERFORM}}) { |
|
0
|
|
|
|
|
|
|
119
|
0
|
0
|
|
|
|
|
return wantarray ? () : undef; |
120
|
|
|
|
|
|
|
} else { |
121
|
0
|
|
|
|
|
|
my $key = $self->{ORDERFORM}->[$currkey]; |
122
|
0
|
0
|
|
|
|
|
my $normalkey = $self->{nonorm} ? $key : normalize($key); |
123
|
0
|
0
|
|
|
|
|
return wantarray ? ($key, $self->{DATA}->{$normalkey}) : $key; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
1; |