DBus.pm untested

filter: Statementstmt 0.0% 0 / 7 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 2 Podpod n/a totaltotal 0.0% 0 / 9 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Protocol::DBus;
2  
3 use strict;
4 use warnings;
5  
6 our $VERSION = '0.05-TRIAL2';
7  
8 =encoding utf8
9  
10 =head1 NAME
11  
12 Protocol::DBus - D-Bus in pure Perl
13  
14 =head1 SYNOPSIS
15  
16 my $dbus = Protcol::DBus::Client::system();
17  
18 For blocking I/O:
19  
20 $dbus->do_authn();
21  
22 $dbus->send_call(
23 path => '/org/freedesktop/DBus',
24 interface => 'org.freedesktop.DBus.Properties',
25 member => 'GetAll',
26 destination => 'org.freedesktop.DBus',
27 signature => 's',
28 body => [ 'org.freedesktop.DBus' ],
29 on_return => sub { my ($msg) = @_ },
30 );
31  
32 my $msg = $dbus->get_message();
33  
34 For non-blocking I/O:
35  
36 $dbus->blocking(0);
37  
38 my $fileno = $dbus->fileno();
39  
40 # You can use whatever polling method you prefer;
41 # the following is just for demonstration:
42 vec( my $mask, $fileno, 1 ) = 1;
43  
44 while (!$dbus->do_authn()) {
45 if ($dbus->authn_pending_send()) {
46 select( undef, my $wout = $mask, undef, undef );
47 }
48 else {
49 select( my $rout = $mask, undef, undef, undef );
50 }
51 }
52  
53 $dbus->send_call( .. ); # same parameters as above
54  
55 while (1) {
56 my $wout = $dbus->pending_send() || q<>;
57 $wout &&= $mask;
58  
59 select( my $rout = $mask, $wout, undef, undef );
60  
61 if ($wout =~ tr<\0><>c) {
62 $dbus->flush_write_queue();
63 }
64  
65 if ($rout =~ tr<\0><>c) {
66  
67 # It’s critical to get_message() until undef is returned.
68 1 while $dbus->get_message();
69 }
70 }
71  
72 =head1 DESCRIPTION
73  
74 This is an original, pure-Perl implementation of client logic for
75 L<the D-Bus protocol|https://dbus.freedesktop.org/doc/dbus-specification.html>.
76  
77 Right now this distribution is an experimental effort. If you use it in your
78 project, be sure to check the changelog before deploying a new version. Please
79 file bug reports as appropriate.
80  
81 See L<Protocol::DBus::Client> and the above sample for a starting point.
82  
83 =head1 EXAMPLES
84  
85 See the distribution’s F<examples/> directory.
86  
87 =cut