MaTirelire/SavedPreferences.pm

filter: Statementstmt 27.8% 17 / 61 Branchbran 0.0% 0 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 100% 2 / 2 totaltotal 27.2% 24 / 88 CC 10 SCAR 32.4
CC
10
Cov
22%
ParseResource
42.0
PackResource
30.0
BEGIN
1.0
CRAP 25.4
« MaTirelire/DBItemId.pm ↑ Summary MaTirelire/Currencies.pm »
1 =encoding iso-8859-1
2  
3 =cut
4  
5 #
6 # Copyright (C) 2005, Maxime Soulé
7 # You may distribute this file under the terms of the Artistic
8 # License, as specified in the README file.
9 #
10  
11 package Palm::MaTirelire::SavedPreferences;
12  
13 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use Palm::BlockPack;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 ▶use Palm::MaTirelire;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 ▶use base qw(Palm::MaTirelire);
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 our $VERSION = '1.0';
22  
23  
24 1 my $ACCOUNTV1_BLOCK = Palm::BlockPack->new
25 (n => 'version',
26 C => 'cur_category',
27 UInt8 => [
28 'country_conv:4',
29 'reserved1:*',
30 ],
31 UInt16 => [
32 'warning:1',
33 'check_locked:1',
34 'repeat_startup:1',
35 'sum_type:3',
36 'replace_desc:1',
37 'repeat_days:6',
38 'show_all_cat:1',
39 'updown_action:2'
40 ],
41 UInt32 => [
42 'sum_date:5',
43 'sum_todayplus:5',
44 'time_select3:1',
45 'remove_type:1',
46 'db_must_be_corrected:1',
47 'left_handed:1',
48 'timeout:3',
49 'reserved2:*'
50 ],
51 N => 'access_code',
52 skip => 12,
53 );
54  
55 1 my $ACCOUNTV2_BLOCK = Palm::BlockPack->new
56 (
57 n => 'version',
58 UInt32 => [
59 'no_beta_alert:1',
60 'db_must_be_corrected:1',
61 'replace_desc:1',
62 'updown_action:2',
63 'time_select3:1',
64 'left_handed:1',
65 'timeout:3',
66 'remove_type:1',
67 'XXX:2',
68 'firstnext_action:2',
69 'first_form:3',
70 'select_focused_num_flds:1',
71 'reserved:*'
72 ],
73 N => 'access_code',
74 'Z32' => 'last_db',
75 'N' => 'list_font',
76 'N' => 'list_bold_font',
77 '[C8]' => 'colors',
78 'n' => 'list_flags',
79 );
80  
81  
82 sub import
83 1 ▶{
Subroutine import: called CC=1 SCAR=0.0
84 1 &Palm::PDB::RegisterPRCHandlers(__PACKAGE__, [ "psys", 'sprf' ]);
85 }
86  
87  
88 sub ParseResource
89 0 ▶{
Subroutine ParseResource: not called CC=6 SCAR=37.4
Pod documented
90 0 my $self = shift;
91 0 my %record = @_;
92  
93 0 my $data = delete $record{data};
94  
95 0 ▶ if ($record{type} eq 'MaTi')
Branch: 2 branches
BranchTrueFalseTotal
if ($record{'type'} eq 'MaTi') { } 0 0 0
elsif ($record{'type'} eq 'MaT2') { } 0 0 0
96 {
97 0 $record{data} = {};
98  
99 0 $ACCOUNTV1_BLOCK->unpack_block(\$data, $record{data}, 1);
100  
101 0 my @lists = qw(modes types descriptions);
102 0 @{$record{data}}{@lists} = ([], [], []);
103  
104 0 ▶ while ($data ne '')
Branch: 1 branch
BranchTrueFalseTotal
if ($data ne "") 0 0 0
105 {
106 0 my $elt = unpack('Z*', $data);
107  
108 0 substr($data, 0, length($elt) + 1) = '';
109  
110 0 ▶ if ($elt eq '')
Branch: 1 branch
BranchTrueFalseTotal
if ($elt eq '') { } 0 0 0
111 {
112 0 shift @lists;
113  
114 0 ▶ if (@lists == 0)
Branch: 1 branch
BranchTrueFalseTotal
if (@lists == 0) 0 0 0
115 {
116 # Too many bytes
117 0 last;
118 }
119 }
120 else
121 {
122 0 push(@{$record{data}{$lists[0]}}, $elt);
123 }
124 }
125 }
126 elsif ($record{type} eq 'MaT2')
127 {
128 0 $record{data} = {};
129  
130 0 $ACCOUNTV2_BLOCK->unpack_block(\$data, $record{data});
131 }
132 else
133 {
134 0 $record{data} = $data;
135 }
136  
137 0 return \%record;
138 }
139  
140  
141 sub PackResource
142 0 ▶{
Subroutine PackResource: not called CC=5 SCAR=34.0
Pod documented
143 0 my $self = shift;
144 0 my $record = shift;
145 0 my $pack;
146  
147 0 ▶ if ($record->{type} eq 'MaTi')
Branch: 2 branches
BranchTrueFalseTotal
if ($record->{'type'} eq 'MaTi') { } 0 0 0
elsif ($record->{'type'} eq 'MaT2') { } 0 0 0
148 {
149 0 my $ref_data = $record->{data};
150  
151 0 ▶ if (ref $ref_data)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ref_data) { } 0 0 0
152 {
153 0 $pack = $ACCOUNTV1_BLOCK->pack_block($ref_data);
154  
155 $pack .= join("\0",
156 0 join('', map { "$_\0" } @{$ref_data->{modes}}),
157 0 join('', map { "$_\0" } @{$ref_data->{types}}),
158 0 join('', map { "$_\0" } @{$ref_data->{descriptions}})
159 );
160  
161 0 $pack .= "\0"; # Compatibility
162 }
163 else
164 {
165 0 $pack = $ref_data;
166 }
167 }
168 elsif ($record->{type} eq 'MaT2')
169 {
170 0 my $ref_data = $record->{data};
171  
172 0 ▶ if (ref $ref_data)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ref_data) { } 0 0 0
173 {
174 0 $pack = $ACCOUNTV2_BLOCK->pack_block($ref_data);
175 }
176 else
177 {
178 0 $pack = $ref_data;
179 }
180 }
181 else
182 {
183 0 $pack = $record->{data};
184 }
185  
186 0 return $pack;
187 }
188  
189 1 1;
190 __END__
« MaTirelire/DBItemId.pm ↑ Summary MaTirelire/Currencies.pm »