line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OMA::Download::OTA; |
2
|
1
|
|
|
1
|
|
44135
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
3
|
|
|
|
|
|
|
BEGIN { |
4
|
1
|
|
|
1
|
|
1016
|
$OMA::Download::OTA::VERSION = '1.00.06'; |
5
|
|
|
|
|
|
|
} |
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
OMA::Download::OTA - Perl extension for creating download descriptor objects according to the OMA Download OTA 1.0 specification. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 DESCRIPTION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Complete implementation of the Open Mobile Alliance Download Over The Air 1.0 specification. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use OMA::Download::OTA; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 new |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $ota = OMA::Download::OTA->new(%properties); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
25
|
|
|
|
|
|
|
sub new { |
26
|
1
|
|
|
1
|
1
|
175
|
my ($class, %arg)=@_; |
27
|
1
|
|
|
|
|
41
|
my $self={ |
28
|
|
|
|
|
|
|
properties => { |
29
|
|
|
|
|
|
|
name => $arg{name}, |
30
|
|
|
|
|
|
|
vendor => $arg{vendor}, |
31
|
|
|
|
|
|
|
type => $arg{type}, |
32
|
|
|
|
|
|
|
size => $arg{size}, |
33
|
|
|
|
|
|
|
description => $arg{description}, |
34
|
|
|
|
|
|
|
objectURI => $arg{objectURI}, |
35
|
|
|
|
|
|
|
installNotifyURI => $arg{installNotifyURI}, |
36
|
|
|
|
|
|
|
nextURL => $arg{nextURL}, |
37
|
|
|
|
|
|
|
DDVersion => '1.0', |
38
|
|
|
|
|
|
|
infoURL => $arg{infoURL}, |
39
|
|
|
|
|
|
|
iconURI => $arg{iconURI}, |
40
|
|
|
|
|
|
|
installParam => $arg{installParam}, |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
status => { |
43
|
|
|
|
|
|
|
900 => 'Success', |
44
|
|
|
|
|
|
|
901 => 'Insufficient memory', |
45
|
|
|
|
|
|
|
902 => 'User Cancelled', |
46
|
|
|
|
|
|
|
903 => 'Loss of Service', |
47
|
|
|
|
|
|
|
905 => 'Attribute mismatch', |
48
|
|
|
|
|
|
|
906 => 'Invalid descriptor', |
49
|
|
|
|
|
|
|
951 => 'Invalid DDVersion', |
50
|
|
|
|
|
|
|
952 => 'Device Aborted', |
51
|
|
|
|
|
|
|
953 => 'Non-Acceptable Content', |
52
|
|
|
|
|
|
|
954 => 'Loader Error' |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
}; |
55
|
1
|
|
|
|
|
7
|
$self=bless $self, $class; |
56
|
1
|
|
|
|
|
5
|
$self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
=head1 PROPERTIES |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 name |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Get or set the download name |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
print $ota->name; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$ota->name('Nice download'); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
sub name { |
70
|
0
|
|
|
0
|
1
|
0
|
my ($self, $val)=@_; |
71
|
0
|
0
|
|
|
|
0
|
$self->{name} = $val if $val; |
72
|
0
|
|
|
|
|
0
|
$self->{name} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 vendor |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Get or set the download vendor name |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
print $ota->vendor; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
$ota->vendor('My Cool Company'); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
sub vendor { |
85
|
0
|
|
|
0
|
1
|
0
|
my ($self, $val)=@_; |
86
|
0
|
0
|
|
|
|
0
|
$self->{vendor} = $val if $val; |
87
|
0
|
|
|
|
|
0
|
$self->{vendor} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 type |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Get or set the download MIME type |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
print $ota->type; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
$ota->type('image/gif'); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
sub type { |
100
|
0
|
|
|
0
|
1
|
0
|
my ($self, $val)=@_; |
101
|
0
|
0
|
|
|
|
0
|
$self->{type} = $val if $val; |
102
|
0
|
|
|
|
|
0
|
$self->{type} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 size |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Get or set the download file size |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
print $ota->size; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
$ota->size(65536); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
sub size { |
115
|
0
|
|
|
0
|
1
|
0
|
my ($self, $val)=@_; |
116
|
0
|
0
|
|
|
|
0
|
$self->{size} = $val if defined $val; |
117
|
0
|
|
|
|
|
0
|
$self->{size} |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 description |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Get or set the download description |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
print $ota->description |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
$ota->description('A nice picture of the Moon'); |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
sub description { |
130
|
0
|
|
|
0
|
1
|
0
|
my ($self, $val)=@_; |
131
|
0
|
0
|
|
|
|
0
|
$self->{description} = $val if defined $val; |
132
|
0
|
|
|
|
|
0
|
$self->{description} |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 objectURI |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Get or set the download object URI |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
print $ota->objectURI; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
$ota->objectURI('http://example.com/image123.gif'); |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
144
|
|
|
|
|
|
|
sub objectURI { |
145
|
0
|
|
|
0
|
1
|
0
|
my ($self, $val)=@_; |
146
|
0
|
0
|
|
|
|
0
|
$self->{objectURI} = $val if $val; |
147
|
0
|
|
|
|
|
0
|
$self->{objectURI} |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 installNotifyURI |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Get or set the intall notificatition URI. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
print $ota->installNotifyURI; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
$ota->installNotifyURI('http://example.com/notify.cgi'); |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=cut |
159
|
|
|
|
|
|
|
sub installNotifyURI { |
160
|
0
|
|
|
0
|
1
|
0
|
my ($self, $val)=@_; |
161
|
0
|
0
|
|
|
|
0
|
$self->{installNotifyURI} = $val if defined $val; |
162
|
0
|
|
|
|
|
0
|
$self->{installNotifyURI} |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 nextURL |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Get or set the next URL |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
print $ota->nextURL; |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
$ota->nextURL('http://example.com/complete.html'); |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |
174
|
|
|
|
|
|
|
sub nextURL { |
175
|
0
|
|
|
0
|
1
|
0
|
my ($self, $val)=@_; |
176
|
0
|
0
|
|
|
|
0
|
$self->{nextURL} = $val if defined $val; |
177
|
0
|
|
|
|
|
0
|
$self->{nextURL} |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head2 DDVersion |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Get or set the download descriptor version. Defaults to 1.0. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
print $ota->DDVersion; |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
$ota->DDVersion('1.0'); |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |
189
|
|
|
|
|
|
|
sub DDVersion { |
190
|
0
|
|
|
0
|
1
|
0
|
my ($self, $val)=@_; |
191
|
0
|
0
|
|
|
|
0
|
$self->{DDVersion} = $val if $val; |
192
|
0
|
|
|
|
|
0
|
$self->{DDVersion} |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head2 infoURL |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Get or set the donwload info URL |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
print $ota->infoURL; |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
$ota->infoURL('http://example.com/moon.html'); |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=cut |
204
|
|
|
|
|
|
|
sub infoURL { |
205
|
0
|
|
|
0
|
1
|
0
|
my ($self, $val)=@_; |
206
|
0
|
0
|
|
|
|
0
|
$self->{infoURL} = $val if defined $val; |
207
|
0
|
|
|
|
|
0
|
$self->{infoURL} |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head2 iconURI |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
Get or set the download icon URI |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
print $ota->iconURI; |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
$ota->iconURI('http://example.com/moon.gif'); |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=cut |
219
|
|
|
|
|
|
|
sub iconURI { |
220
|
0
|
|
|
0
|
1
|
0
|
my ($self, $val)=@_; |
221
|
0
|
0
|
|
|
|
0
|
$self->{iconURI} = $val if defined $val; |
222
|
0
|
|
|
|
|
0
|
$self->{iconURI} |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head2 installParam |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
Get or set intall parameter |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=cut |
230
|
|
|
|
|
|
|
sub installParam { |
231
|
0
|
|
|
0
|
1
|
0
|
my ($self, $val)=@_; |
232
|
0
|
0
|
|
|
|
0
|
$self->{installParam} = $val if defined $val; |
233
|
0
|
|
|
|
|
0
|
$self->{installParam} |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head2 mime |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
Returns the Download Descriptor MIME type |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
print $ota->mime; |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=cut |
243
|
|
|
|
|
|
|
sub mime { |
244
|
0
|
|
|
0
|
1
|
0
|
'application/vnd.oma.dd+xml' |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head1 METHODS |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head2 packit |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
Returns the Download Descriptor |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
print $ota->packit; |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=cut |
256
|
|
|
|
|
|
|
sub packit { |
257
|
1
|
|
|
1
|
1
|
6
|
my ($self)=@_; |
258
|
1
|
|
|
|
|
2
|
my $res=''; |
259
|
1
|
|
|
|
|
2
|
for my $p (keys %{$self->{properties}}) { |
|
1
|
|
|
|
|
10
|
|
260
|
12
|
|
|
|
|
17
|
my $c = $self->{properties}{$p}; |
261
|
12
|
100
|
|
|
|
25
|
if ($c) { |
262
|
9
|
50
|
|
|
|
15
|
if (ref $c eq 'ARRAY') { |
263
|
0
|
|
|
|
|
0
|
for my $c (@$c) { |
264
|
0
|
|
|
|
|
0
|
$res.=_in_element($p, $c); |
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
} else { |
267
|
9
|
|
|
|
|
16
|
$res.=_in_element($p, $c); |
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
} |
271
|
1
|
|
|
|
|
164
|
return ''."\n".$res.'' |
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
## Private |
275
|
|
|
|
|
|
|
sub _in_element { |
276
|
9
|
|
|
9
|
|
12
|
my ($element, $content)=@_; |
277
|
9
|
|
|
|
|
10
|
my $res='<'.$element; |
278
|
9
|
50
|
|
|
|
15
|
if ($content) { |
279
|
9
|
|
|
|
|
18
|
$res.='>'.$content.''.$element.'>'."\n" |
280
|
|
|
|
|
|
|
} else { |
281
|
0
|
|
|
|
|
0
|
$res.='/>' |
282
|
|
|
|
|
|
|
} |
283
|
9
|
|
|
|
|
26
|
$res; |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
1; |
286
|
|
|
|
|
|
|
__END__ |