oFono/ConnectionManager.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 57 CC 1 SCAR 6.9
CC
1
Cov
0%
_init
2.0
DESTROY
2.0
DeactivateAll
2.0
CRAP 2.0
1 package Net::Radio::oFono::ConnectionManager;
2  
3 use 5.010;
4 use strict;
5 use warnings;
6  
7 =head1 NAME
8  
9 Net::Radio::oFono::ConnectionManager - provide ConnectionManager interface for Modem objects
10  
11 =cut
12  
13 our $VERSION = '0.001';
14  
15 use Net::DBus qw(:typing);
16  
17 require Net::Radio::oFono::ConnectionContext;
18  
19 use Net::Radio::oFono::Roles::Manager qw(Context ConnectionContext);
20 use base qw(Net::Radio::oFono::Modem Net::Radio::oFono::Roles::Manager);
21  
22 =head1 SYNOPSIS
23  
24 my $oFono = Net::Location::oFono->new();
25 my @modems = Net::Location::oFono->get_modems();
26 # show default network information
27 foreach my $modem_path (@modems) {
28 my $conman = Net::Location::oFono->get_modem_interface($modem_path, "ConnectionManager");
29 say "Attached: ", 0+$conman->GetProperty("Attached"), # boolean
30 "Bearer: ", $conman->GetProperty("Bearer"),
31 "RoamingAllowed: ", 0+$conman->GetProperty("RoamingAllowed"); # boolean
32 $conman->DeactivateAll(); # end of data
33 }
34  
35 =head1 INHERITANCE
36  
37 Net::Radio::oFono::ConnectionManager
38 ISA Net::Radio::oFono::Modem
39 ISA Net::Radio::oFono::Helpers::EventMgr
40 DOES Net::Radio::oFono::Roles::RemoteObj
41 DOES Net::Radio::oFono::Roles::Manager
42  
43 =head1 METHODS
44  
45 See C<ofono/doc/conman-api.txt> for valid properties and detailed
46 action description and possible errors.
47  
48 =head2 _init($obj_path)
49  
50 Initializes the modem and the manager role to handle the
51 I<ContextAdded> and I<ContextRemoved> signals.
52  
53 =cut
54  
55 sub _init
56 {
57 my ( $self, $obj_path ) = @_;
58  
59 ( my $interface = ref($self) ) =~ s/Net::Radio::oFono:://;
60  
61 # initialize base class
62 $self->Net::Radio::oFono::Modem::_init($obj_path);
63 # initialize role
64 $self->Net::Radio::oFono::Roles::Manager::_init();
65  
66 return;
67 }
68  
69 sub DESTROY
70 {
71 my $self = $_[0];
72  
73 # destroy role
74 $self->Net::Radio::oFono::Roles::Manager::DESTROY();
75 # initialize base class
76 $self->Net::Radio::oFono::Modem::DESTROY();
77  
78 return;
79 }
80  
81 =head2 GetContexts(;$force)
82  
83 Get hash of context objects and properties.
84  
85 Set the I<$force> parameter to a true value when no D-Bus main loop
86 is running and signal handling might be incomplete.
87  
88 This method is injected by L<Net::Radio::oFono::Roles::Manager> as an alias
89 for L<Net::Radio::oFono::Roles::Manager/GetObjects(;$force)|GetObjects()>.
90  
91 =head2 GetContext($obj_path;$force)
92  
93 Returns an instance of the specified L<Net::Radio::oFono::ConnectionContext|Context>.
94  
95 Set the I<$force> parameter to a true value when no D-Bus main loop
96 is running and signal handling might be incomplete.
97  
98 This method is injected by L<Net::Radio::oFono::Roles::Manager> as an alias
99 for L<Net::Radio::oFono::Roles::Manager/GetObject($object_path;$force)|GetObject()>.
100  
101 =head2 DeactivateAll()
102  
103 Deactivates all active contexts.
104  
105 =cut
106  
107 sub DeactivateAll
108 {
109 my $self = $_[0];
110  
111 $self->{remote_obj}->DeactivateAll();
112  
113 return;
114 }
115  
116 =head2 AddContext($type)
117  
118 Creates a new Primary context. The type contains the intended purpose of
119 the context.
120  
121 =cut
122  
123 sub AddContext
124 {
125 my ( $self, $type ) = @_;
126  
127 return $self->{remote_obj}->AddContext( dbus_string($type) );
128 }
129  
130 =head2 RemoveContext($obj_path)
131  
132 Removes a primary context. All secondary contexts, if any, associated with
133 the primary context are also removed.
134  
135 =cut
136  
137 sub RemoveContext
138 {
139 my ( $self, $obj_path ) = @_;
140  
141 $self->{remote_obj}->RemoveContext( dbus_object_path($obj_path) );
142  
143 return;
144 }
145  
146 #sub RemoveAllContexts
147 #{
148 # my ( $self ) = @_;
149 #
150 # my @context_obj_paths = keys %{$self->{contexts}};
151 # foreach my $cop (@context_obj_paths)
152 # {
153 # $self->{remote_obj}->RemoveContext( dbus_object_path($cop) );
154 # }
155 #
156 # return;
157 #}
158  
159 =head1 BUGS
160  
161 Please report any bugs or feature requests to C<bug-net-radio-ofono at rt.cpan.org>, or through
162 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Radio-oFono>. I will be notified, and then you'll
163 automatically be notified of progress on your bug as I make changes.
164  
165 If you think you've found a bug then please read "How to Report Bugs
166 Effectively" by Simon Tatham:
167 L<http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>.
168  
169 =head1 SUPPORT
170  
171 You can find documentation for this module with the perldoc command.
172  
173 perldoc Net::Radio::oFono
174  
175 You can also look for information at:
176  
177 =over 4
178  
179 =item * RT: CPAN's request tracker (report bugs here)
180  
181 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Radio-oFono>
182  
183 If you think you've found a bug then please read "How to Report Bugs
184 Effectively" by Simon Tatham:
185 L<http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>.
186  
187 =item * AnnoCPAN: Annotated CPAN documentation
188  
189 L<http://annocpan.org/dist/Net-Radio-oFono>
190  
191 =item * CPAN Ratings
192  
193 L<http://cpanratings.perl.org/d/Net-Radio-oFono>
194  
195 =item * Search CPAN
196  
197 L<http://search.cpan.org/dist/Net-Radio-oFono/>
198  
199 =back
200  
201 =head2 Where can I go for help with a concrete version?
202  
203 Bugs and feature requests are accepted against the latest version
204 only. To get patches for earlier versions, you need to get an
205 agreement with a developer of your choice - who may or not report the
206 issue and a suggested fix upstream (depends on the license you have
207 chosen).
208  
209 =head2 Business support and maintenance
210  
211 For business support you can contact Jens via his CPAN email
212 address rehsackATcpan.org. Please keep in mind that business
213 support is neither available for free nor are you eligible to
214 receive any support based on the license distributed with this
215 package.
216  
217 =head1 ACKNOWLEDGEMENTS
218  
219 At first the guys from the oFono-Team shall be named: Marcel Holtmann and
220 Denis Kenzior, the maintainers and all the people named in ofono/AUTHORS.
221 Without their effort, there would no need for a Net::Radio::oFono module.
222  
223 Further, Peter "ribasushi" Rabbitson helped a lot by providing hints
224 and support how to make this API accessor a valuable CPAN module.
225  
226 =head1 AUTHOR
227  
228 Jens Rehsack, C<< <rehsack at cpan.org> >>
229  
230 =head1 LICENSE AND COPYRIGHT
231  
232 Copyright 2012 Jens Rehsack.
233  
234 This program is free software; you can redistribute it and/or modify it
235 under the terms of either: the GNU General Public License as published
236 by the Free Software Foundation; or the Artistic License.
237  
238 See http://dev.perl.org/licenses/ for more information.
239  
240  
241 =cut
242  
243 1;