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