oFono/NetworkOperator.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 49 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
_init
2.0
DESTROY
2.0
CRAP 2.0
1 package Net::Radio::oFono::NetworkOperator;
2  
3 use 5.010;
4 use strict;
5 use warnings;
6  
7 =head1 NAME
8  
9 Net::Radio::oFono::NetworkOperator - provide NetworkOperator API for objects managed by NetworkRegistration
10  
11 =cut
12  
13 our $VERSION = '0.001';
14  
15 use Net::DBus qw(:typing);
16  
17 # R/O
18 use base
19 qw(Net::Radio::oFono::Helpers::EventMgr Net::Radio::oFono::Roles::RemoteObj Net::Radio::oFono::Roles::Properties);
20  
21 =head1 SYNOPSIS
22  
23 my $oFono = Net::Location::oFono->new();
24 my @modems = Net::Location::oFono->get_modems();
25 foreach my $modem_path (@modems) {
26 my $simmgr = Net::Location::oFono->get_modem_interface($modem_path, "SimManager");
27 $simmgr->GetProperty("SubscriberIdentity") eq $cfg{IMSI} # identify right one
28 or next;
29 my $netreg = Net::Location::oFono->get_modem_interface($modem_path, "NetworkRegistration");
30 my %operators = $netreg->GetOperators();
31 foreach my $oper_path (keys %operators) {
32 my $oper = $netreg->GetOperator($oper_path);
33 if( $oper->GetProperty("Name") =~ $pref ) {
34 $oper->Register();
35 last;
36 }
37 }
38 }
39  
40 =head1 DESCRIPTION
41  
42 This class provide NetworkOperator API for objects managed by
43 L<Net::Radio::oFono::NetworkRegistration|NetworkRegistration>.
44  
45 =head1 INHERITANCE
46  
47 Net::Radio::oFono::NetworkOperator
48 ISA Net::Radio::oFono::Helpers::EventMgr
49 DOES Net::Radio::oFono::Roles::RemoteObj
50 DOES Net::Radio::oFono::Roles::Properties
51  
52 =head1 METHODS
53  
54 See C<ofono/doc/network-api.txt> for valid properties and detailed
55 action description and possible errors.
56  
57 =head2 new
58  
59 =cut
60  
61 sub new
62 {
63 my ( $class, $obj_path, %events ) = @_;
64  
65 my $self = $class->SUPER::new(%events);
66  
67 bless( $self, $class );
68  
69 $self->_init($obj_path);
70 $self->GetProperties(1);
71  
72 return $self;
73 }
74  
75 sub _init
76 {
77 my ( $self, $obj_path ) = @_;
78  
79 ( my $interface = ref($self) ) =~ s/Net::Radio::oFono:://;
80  
81 # initialize roles
82 $self->Net::Radio::oFono::Roles::RemoteObj::_init( $obj_path, "org.ofono.$interface" );
83 $self->Net::Radio::oFono::Roles::Properties::_init();
84  
85 return;
86 }
87  
88 sub DESTROY
89 {
90 my $self = $_[0];
91  
92 # destroy roles
93 $self->Net::Radio::oFono::Roles::Properties::DESTROY();
94 $self->Net::Radio::oFono::Roles::RemoteObj::DESTROY();
95  
96 # destroy base class
97 $self->Net::Radio::oFono::Helpers::EventMgr::DESTROY();
98  
99 return;
100 }
101  
102 =head2 Register()
103  
104 Attempts to register to this network operator.
105  
106 The method will return immediately, the result should be observed by
107 tracking the NetworkRegistration Status property.
108  
109 =cut
110  
111 sub Register
112 {
113 my ($self) = @_;
114  
115 $self->{remote_obj}->Register();
116  
117 return;
118 }
119  
120 =head1 BUGS
121  
122 Please report any bugs or feature requests to C<bug-net-radio-ofono at rt.cpan.org>, or through
123 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Radio-oFono>. I will be notified, and then you'll
124 automatically be notified of progress on your bug as I make changes.
125  
126 If you think you've found a bug then please read "How to Report Bugs
127 Effectively" by Simon Tatham:
128 L<http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>.
129  
130 =head1 SUPPORT
131  
132 You can find documentation for this module with the perldoc command.
133  
134 perldoc Net::Radio::oFono
135  
136 You can also look for information at:
137  
138 =over 4
139  
140 =item * RT: CPAN's request tracker (report bugs here)
141  
142 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Radio-oFono>
143  
144 If you think you've found a bug then please read "How to Report Bugs
145 Effectively" by Simon Tatham:
146 L<http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>.
147  
148 =item * AnnoCPAN: Annotated CPAN documentation
149  
150 L<http://annocpan.org/dist/Net-Radio-oFono>
151  
152 =item * CPAN Ratings
153  
154 L<http://cpanratings.perl.org/d/Net-Radio-oFono>
155  
156 =item * Search CPAN
157  
158 L<http://search.cpan.org/dist/Net-Radio-oFono/>
159  
160 =back
161  
162 =head2 Where can I go for help with a concrete version?
163  
164 Bugs and feature requests are accepted against the latest version
165 only. To get patches for earlier versions, you need to get an
166 agreement with a developer of your choice - who may or not report the
167 issue and a suggested fix upstream (depends on the license you have
168 chosen).
169  
170 =head2 Business support and maintenance
171  
172 For business support you can contact Jens via his CPAN email
173 address rehsackATcpan.org. Please keep in mind that business
174 support is neither available for free nor are you eligible to
175 receive any support based on the license distributed with this
176 package.
177  
178 =head1 ACKNOWLEDGEMENTS
179  
180 At first the guys from the oFono-Team shall be named: Marcel Holtmann and
181 Denis Kenzior, the maintainers and all the people named in ofono/AUTHORS.
182 Without their effort, there would no need for a Net::Radio::oFono module.
183  
184 Further, Peter "ribasushi" Rabbitson helped a lot by providing hints
185 and support how to make this API accessor a valuable CPAN module.
186  
187 =head1 AUTHOR
188  
189 Jens Rehsack, C<< <rehsack at cpan.org> >>
190  
191 =head1 LICENSE AND COPYRIGHT
192  
193 Copyright 2012 Jens Rehsack.
194  
195 This program is free software; you can redistribute it and/or modify it
196 under the terms of either: the GNU General Public License as published
197 by the Free Software Foundation; or the Artistic License.
198  
199 See http://dev.perl.org/licenses/ for more information.
200  
201  
202 =cut
203  
204 1;