summaryrefslogtreecommitdiff
path: root/lib/App/XScreenSaver/DBus/SaverProxy.pm
blob: 10fbb99fe35979d227d9f2650cbf700cf909c97d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package App::XScreenSaver::DBus::SaverProxy; 
use v5.20;
use strict;
use warnings;
use experimental qw(signatures postderef);
# this is the interface name 
use Net::DBus::Exporter qw(org.freedesktop.ScreenSaver);
use parent 'Net::DBus::Object';
our $VERSION = '1.0.2'# VERSION 
# ABSTRACT: proxy dbus object 
 
 
dbus_method('Inhibit',['string','string'],['uint32']);
dbus_method('UnInhibit',['uint32'],[]);
 
sub new($class,$service,$path,$inhibit_cb,$uninhibit_cb) {
    my $self = $class->SUPER::new($service$path);
    bless $self$class;
    $self->{__inhibit_cb} = $inhibit_cb;
    $self->{__uninhibit_cb} = $uninhibit_cb;
    return $self;
}
 
our $_message;
sub _dispatch_object($self,$connection,$message,@etc) {
    local $_message = $message;
    return $self->SUPER::_dispatch_object($connection,$message,@etc);
}
 
sub Inhibit($self,$name,$reason) {
    return $self->{__inhibit_cb}->($name,$reason,$_message);
}
 
sub UnInhibit($self,$cookie) {
    return $self->{__uninhibit_cb}->($cookie,$_message);
}
 
1;
 
__END__
 
=pod
 
=encoding UTF-8
 
=head1 NAME
 
App::XScreenSaver::DBus::SaverProxy - proxy dbus object
 
=head1 VERSION
 
version 1.0.2
 
=head1 DESCRIPTION
 
This is functionally the same as L<< C<Net::DBus::ObjectProxy> >>, but
specialised for this application, and with a hack to allow L<<
C<App::XScreenSaver::DBus::Saver> >> to access the sender of the
message.
 
=head1 AUTHOR
 
Gianni Ceccarelli <dakkar@thenautilus.net>
 
=head1 COPYRIGHT AND LICENSE
 
This software is Copyright (c) 2021 by Gianni Ceccarelli <dakkar@thenautilus.net>.
 
This is free software, licensed under:
 
  The GNU Affero General Public License, Version 3, November 2007
 
=cut