File: pong.pl

package info (click to toggle)
qt4-perl 4.5~~svn1145508-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 5,144 kB
  • ctags: 5,947
  • sloc: perl: 29,224; cpp: 18,849; xml: 98; makefile: 91; sh: 4
file content (55 lines) | stat: -rwxr-xr-x 1,097 bytes parent folder | download
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
#!/usr/bin/perl

package Pong;

use strict;
use warnings;

use QtCore4;
use QtGui4;
use QtCore4::isa qw( Qt::Object );
use QtCore4::slots
    'QString ping' => ['QString'];

sub NEW {
    shift->SUPER::NEW(@_);
}

sub ping {
    my ( $arg ) = @_;
    Qt::MetaObject::invokeMethod(Qt::CoreApplication::instance(), 'quit');
    return "ping(\"$arg\") got called";
}

package main;

use strict;
use warnings;
use blib;

use QtCore4;
use QtGui4;
use Pong;
use PingCommon qw( SERVICE_NAME );

sub main {
    my $app = Qt::Application(\@ARGV);

    if (!Qt::DBusConnection::sessionBus()->isConnected()) {
        die "Cannot connect to the D-BUS session bus.\n" .
                "To start it, run:\n" .
                "\teval `dbus-launch --auto-syntax`\n";
    }

    if (!Qt::DBusConnection::sessionBus()->registerService(SERVICE_NAME)) {
        die Qt::DBusConnection::sessionBus()->lastError()->message();
        exit(1);
    }

    my $pong = Pong();
    Qt::DBusConnection::sessionBus()->registerObject('/', $pong, Qt::DBusConnection::ExportAllSlots());
    
    exit $app->exec();
}

main();