oFono/SimManager.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran n/a Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 75 CC 1 SCAR 6.9
CC
1
Cov
0%
ChangePin
2.0
EnterPin
2.0
ResetPin
2.0
CRAP 2.0
1 package Net::Radio::oFono::SimManager;
2  
3 use 5.010;
4 use strict;
5 use warnings;
6  
7 =head1 NAME
8  
9 Net::Radio::oFono::SimManager - access Modem object's SimManager interface
10  
11 =cut
12  
13 our $VERSION = '0.001';
14  
15 use Carp qw/croak/;
16 use Net::DBus qw(:typing);
17  
18 use base qw(Net::Radio::oFono::Modem);
19  
20 =head1 SYNOPSIS
21  
22 my $oFono = Net::Location::oFono->new();
23 my @modems = Net::Location::oFono->get_modems();
24 foreach my $modem_path (@modems) {
25 my $simmgr = Net::Location::oFono->get_modem_interface($modem_path, "SimManager");
26 $simmgr->GetProperty("SubscriberIdentity") eq $cfg{IMSI} # identify right one
27 and $simmgr->GetProperty("PinRequired") eq "pin" # do not enter when not wanted
28 and $simmgr->EnterPin("pin", "1234"); # enter pin code
29 }
30  
31 =head1 INHERITANCE
32  
33 Net::Radio::oFono::SimManager
34 ISA Net::Radio::oFono::Modem
35 ISA Net::Radio::oFono::Helpers::EventMgr
36 DOES Net::Radio::oFono::Roles::RemoteObj
37 DOES Net::Radio::oFono::Roles::Properties
38  
39 =head1 METHODS
40  
41 See C<ofono/doc/sim-api.txt> for valid pin types and detailed
42 action description and possible errors.
43  
44 =cut
45  
46 my @valid_pin_types = (
47 qw(none pin phone firstphone pin2 network netsub service corp puk),
48 qw(firstphonepuk puk2 networkpuk netsubpuk servicepuk corppuk)
49 );
50  
51 =head2 ChangePin($pintype,$oldpin,$newpin)
52  
53 Changes the appropriate pin type.
54  
55 =cut
56  
57 sub ChangePin
58 {
59 my ( $self, $pin_type, $oldpin, $newpin ) = @_;
60  
61 $pin_type ~~ @valid_pin_types
62 or croak( "Invalid PIN type: '"
63 . $pin_type
64 . "'. Valid are: '"
65 . join( "', '", @valid_pin_types )
66 . "'." );
67  
68 $self->{remote_obj}
69 ->ChangePin( dbus_string($pin_type), dbus_string($oldpin), dbus_string($newpin) );
70  
71 return;
72 }
73  
74 =head2 EnterPin($pintype,$pin)
75  
76 Enters the currently pending pin. The type value must match the pin type
77 being asked in the PinRequired property.
78  
79 =cut
80  
81 sub EnterPin
82 {
83 my ( $self, $pin_type, $pin ) = @_;
84  
85 $pin_type ~~ @valid_pin_types
86 or croak( "Invalid PIN type: '"
87 . $pin_type
88 . "'. Valid are: '"
89 . join( "', '", @valid_pin_types )
90 . "'." );
91  
92 $self->{remote_obj}->EnterPin( dbus_string($pin_type), dbus_string($pin) );
93  
94 return;
95 }
96  
97 =head2 ResetPin($pintype,$puk,$pin)
98  
99 Provides the unblock key to the modem and if correct resets the pin to
100 the new value of pin.
101  
102 =cut
103  
104 sub ResetPin
105 {
106 my ( $self, $pin_type, $puk, $pin ) = @_;
107  
108 $pin_type ~~ @valid_pin_types
109 or croak( "Invalid PIN type: '"
110 . $pin_type
111 . "'. Valid are: '"
112 . join( "', '", @valid_pin_types )
113 . "'." );
114  
115 $self->{remote_obj}->ResetPin( dbus_string($pin_type), dbus_string($puk), dbus_string($pin) );
116  
117 return;
118 }
119  
120 =head2 LockPin($pintype,$pin)
121  
122 Activates the lock for the particular pin type.
123  
124 =cut
125  
126 sub LockPin
127 {
128 my ( $self, $pin_type, $pin ) = @_;
129  
130 $pin_type ~~ @valid_pin_types
131 or croak( "Invalid PIN type: '"
132 . $pin_type
133 . "'. Valid are: '"
134 . join( "', '", @valid_pin_types )
135 . "'." );
136  
137 $self->{remote_obj}->LockPin( dbus_string($pin_type), dbus_string($pin) );
138  
139 return;
140 }
141  
142 =head2 UnlockPin($pintype,$pin)
143  
144 Deactivates the lock for the particular pin type.
145  
146 =cut
147  
148 sub UnlockPin
149 {
150 my ( $self, $pin_type, $pin ) = @_;
151  
152 $pin_type ~~ @valid_pin_types
153 or croak( "Invalid PIN type: '"
154 . $pin_type
155 . "'. Valid are: '"
156 . join( "', '", @valid_pin_types )
157 . "'." );
158  
159 $self->{remote_obj}->UnlockPin( dbus_string($pin_type), dbus_string($pin) );
160  
161 return;
162 }
163  
164 =head2 GetIcon($id)
165  
166 Obtain the icon given by id. Only ids greater than 1 are valid.
167 XPM format is currently used to return the icon data.
168  
169 =cut
170  
171 sub GetIcon
172 {
173 my ( $self, $id ) = @_;
174  
175 return $self->{remote_obj}->getIcon($id);
176 }
177  
178 =head1 BUGS
179  
180 Please report any bugs or feature requests to C<bug-net-radio-ofono at rt.cpan.org>, or through
181 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Radio-oFono>. I will be notified, and then you'll
182 automatically be notified of progress on your bug as I make changes.
183  
184 If you think you've found a bug then please read "How to Report Bugs
185 Effectively" by Simon Tatham:
186 L<http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>.
187  
188 =head1 SUPPORT
189  
190 You can find documentation for this module with the perldoc command.
191  
192 perldoc Net::Radio::oFono
193  
194 You can also look for information at:
195  
196 =over 4
197  
198 =item * RT: CPAN's request tracker (report bugs here)
199  
200 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Radio-oFono>
201  
202 If you think you've found a bug then please read "How to Report Bugs
203 Effectively" by Simon Tatham:
204 L<http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>.
205  
206 =item * AnnoCPAN: Annotated CPAN documentation
207  
208 L<http://annocpan.org/dist/Net-Radio-oFono>
209  
210 =item * CPAN Ratings
211  
212 L<http://cpanratings.perl.org/d/Net-Radio-oFono>
213  
214 =item * Search CPAN
215  
216 L<http://search.cpan.org/dist/Net-Radio-oFono/>
217  
218 =back
219  
220 =head2 Where can I go for help with a concrete version?
221  
222 Bugs and feature requests are accepted against the latest version
223 only. To get patches for earlier versions, you need to get an
224 agreement with a developer of your choice - who may or not report the
225 issue and a suggested fix upstream (depends on the license you have
226 chosen).
227  
228 =head2 Business support and maintenance
229  
230 For business support you can contact Jens via his CPAN email
231 address rehsackATcpan.org. Please keep in mind that business
232 support is neither available for free nor are you eligible to
233 receive any support based on the license distributed with this
234 package.
235  
236 =head1 ACKNOWLEDGEMENTS
237  
238 At first the guys from the oFono-Team shall be named: Marcel Holtmann and
239 Denis Kenzior, the maintainers and all the people named in ofono/AUTHORS.
240 Without their effort, there would no need for a Net::Radio::oFono module.
241  
242 Further, Peter "ribasushi" Rabbitson helped a lot by providing hints
243 and support how to make this API accessor a valuable CPAN module.
244  
245 =head1 AUTHOR
246  
247 Jens Rehsack, C<< <rehsack at cpan.org> >>
248  
249 =head1 LICENSE AND COPYRIGHT
250  
251 Copyright 2012 Jens Rehsack.
252  
253 This program is free software; you can redistribute it and/or modify it
254 under the terms of either: the GNU General Public License as published
255 by the Free Software Foundation; or the Artistic License.
256  
257 See http://dev.perl.org/licenses/ for more information.
258  
259  
260 =cut
261  
262 1;