summaryrefslogtreecommitdiffstats
path: root/perl-install/dbus_object.pm
blob: 1b4a4264e0e628ddbb3cf98d6ebdd05a2323fc73 (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
package dbus_object;

sub system_bus() {
    require Net::DBus;
    Net::DBus->system;
}

sub new {
    my ($type, $bus, $service, $path, $interface) = @_;
    my $o = {
	bus => $bus,
	service => $service,
	path => $path,
	interface => $interface,
    };
    attach_object($o);
    bless $o, $type;
}

sub attach_object {
    my ($o) = @_;
    my $service = $o->{bus}->get_service($o->{service});
    $o->{object} = $service->get_object($o->{path}, $o->{interface});
}

sub call_method {
    my ($o, $method, @args) = @_;
    $o->{object}->$method(@args);
}

sub safe_call_method {
    my ($o, $method, @args) = @_;
    my @ret;
    eval {
        @ret = $o->call_method($method, @args);
    };
    if ($@) {
        print STDERR "($method) exception: $@\n";
        $o->{bus}{connection}->dispatch;
        return;
    }
    @ret;
}

sub set_gtk2_watch {
    my ($o) = @_;
    set_gtk2_watch_helper($o->{bus});
}

sub set_gtk2_watch_helper {
    my ($bus) = @_;
    $bus->{connection}->set_watch_callbacks(sub {
        my ($con, $watch) = @_;
        my $flags = $watch->get_flags;
        require Net::DBus::Binding::Watch;
	require Gtk2::Helper;
        if ($flags & &Net::DBus::Binding::Watch::READABLE) {
            Gtk2::Helper->add_watch($watch->get_fileno, 'in', sub {
                $watch->handle(&Net::DBus::Binding::Watch::READABLE);
                $con->dispatch;
                1;
            });
        }
        #- do nothing for WRITABLE watch, we dispatch when needed
    }, undef, undef); #- do nothing when watch is disabled or toggled yet

    $bus->{connection}->dispatch;
}

1;
s='deletions'>-58/+63 | * UpdatedWilly Sudiarto Raharjo2006-01-181-18/+27 | * *** empty log message ***José Melo2006-01-181-2/+2 | * *** empty log message ***José Melo2006-01-181-2/+2 | * *** empty log message ***José Melo2006-01-181-29/+29 | * *** empty log message ***José Melo2006-01-181-3193/+4344 | * Updated POT fileFunda Wang2006-01-1771-91890/+96859 | * Updated translation.Karl Ove Hufthammer2006-01-131-59/+59 | * updateThierry Vignaud2006-01-121-184/+34 | * Updated Norwegian Nynorsk translation.Karl Ove Hufthammer2006-01-101-78/+99 | * Updated nn translation.Karl Ove Hufthammer2006-01-091-88/+105 | * updated po fileShiva Huang2006-01-091-83/+106 | * *** empty log message ***José Melo2006-01-081-2/+2 | * *** empty log message ***José Melo2006-01-081-273/+185 | * More pt_BR fixes.Wanderlei Antonio Cavassin2006-01-061-6/+8 | * Updated nn translation.Karl Ove Hufthammer2006-01-041-165/+104 | * updated po fileShiva Huang2006-01-031-22/+23 | * osatu gabeIñigo Salvador Azurmendi2005-12-311-381/+175 | * Fix missing, spelling, better translationsPjetur Hjaltason2005-12-291-2349/+189 | * Updated Simplified Chinese translation.Funda Wang2005-12-171-12/+11 | * update (Yukiko Bando)Thierry Vignaud2005-12-151-10/+11 | * update (Yukiko Bando)Thierry Vignaud2005-12-151-73/+80 | * updated pot filePablo Saratxaga2005-12-1525-836/+1085 | * updated pot filePablo Saratxaga2005-12-1546-1727/+2110 | * fixed encoding to UTF-8Pablo Saratxaga2005-12-151-320/+332 | * updated Galician filePablo Saratxaga2005-12-141-1435/+493 | * UpdatedWilly Sudiarto Raharjo2005-12-091-4/+4 | * Updatd POT file.Funda Wang2005-12-0871-15127/+16276 | * *** empty log message ***José Melo2005-12-051-191/+93 | * UpdatedWilly Sudiarto Raharjo2005-12-051-2/+2 | * Updated POT file.Funda Wang2005-12-04