summaryrefslogtreecommitdiff
path: root/lib/App/XScreenSaver/DBus/SaverProxy.pm
blob: d09804526451c59feb31734b0bedeae1dc93be16 (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
package App::XScreenSaver::DBus::SaverProxy; 
use strict;
use warnings;
use experimental 'signatures';
# this is the interface name 
use Net::DBus::Exporter qw(org.freedesktop.ScreenSaver);
use parent 'Net::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;