oFono/CellBroadcast.pm untested

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