oFono/Modem.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 50 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
_init
2.0
modem_path
2.0
CRAP 2.0
1 package Net::Radio::oFono::Modem;
2  
3 use 5.010;
4 use strict;
5 use warnings;
6  
7 =head1 NAME
8  
9 Net::Radio::oFono::Modem - access to oFono's Modem objects
10  
11 =cut
12  
13 our $VERSION = '0.001';
14  
15 use base
16 qw(Net::Radio::oFono::Helpers::EventMgr Net::Radio::oFono::Roles::RemoteObj Net::Radio::oFono::Roles::Properties);
17  
18 use Net::DBus qw(:typing);
19  
20 use Log::Any qw($log);
21  
22 =head1 SYNOPSIS
23  
24 Provides access to oFono's Modem objects with org.ofono.Modem interface.
25  
26 use Net::Radio::oFono::Modem;
27 ...
28 my $modem = Net::Radio::oFono::Modem->new("/option_0");
29 if( !$modem->GetProperty("Online") )
30 {
31 $modem->SetProperty("Online", dbus_boolean(1) );
32 }
33  
34 Usually modem objects are accessed via L<Net::Radio::oFono/get_modem_interface>:
35  
36 $oFono->get_modem_interface("Modem")->SetProperty("Online", dbus_boolean(1) );
37  
38 =head1 INHERITANCE
39  
40 Net::Radio::oFono::Modem
41 ISA Net::Radio::oFono::Helpers::EventMgr
42 DOES Net::Radio::oFono::Roles::RemoteObj
43 DOES Net::Radio::oFono::Roles::Properties
44  
45 =head1 EVENTS
46  
47 No additional events are triggered.
48  
49 =head1 METHODS
50  
51 =head2 new($obj_path;%events)
52  
53 Instantiates new object for org.ofono.Modem interfaced objects.
54  
55 =cut
56  
57 sub new
58 {
59 my ( $class, $obj_path, %events ) = @_;
60  
61 my $self = $class->SUPER::new(%events);
62  
63 bless( $self, $class );
64  
65 $self->_init($obj_path);
66  
67 return $self;
68 }
69  
70 =head2 _init($obj_path)
71  
72 Initializes the Modem interface. Using the "basename" of the instantiated package
73 as interface name for the RemoteObj role.
74  
75 =cut
76  
77 sub _init
78 {
79 my ( $self, $obj_path ) = @_;
80  
81 ( my $interface = ref($self) ) =~ s/Net::Radio::oFono:://;
82  
83 # initialize roles
84 $self->Net::Radio::oFono::Roles::RemoteObj::_init( $obj_path, "org.ofono.$interface" );
85 $self->Net::Radio::oFono::Roles::Properties::_init();
86  
87 return;
88 }
89  
90 =head2 modem_path
91  
92 Alias for C<obj_path> getter of RemoteObj role.
93  
94 =cut
95  
96 # let us inject this, too?
97 sub modem_path
98 {
99 return $_[0]->{obj_path};
100 }
101  
102 sub DESTROY
103 {
104 my $self = $_[0];
105  
106 # destroy roles
107 $self->Net::Radio::oFono::Roles::Properties::DESTROY();
108 $self->Net::Radio::oFono::Roles::RemoteObj::DESTROY();
109  
110 # destroy base class
111 $self->Net::Radio::oFono::Helpers::EventMgr::DESTROY();
112  
113 return;
114 }
115  
116 1;