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
|
package CarAdaptor;
use strict;
use warnings;
use Qt4;
use Qt4::isa qw( Qt4::DBusAbstractAdaptor );
use Qt4::classinfo
'D-Bus Interface' => 'com.trolltech.Examples.CarInterface',
'D-Bus Introspection' => '' .
" <interface name=\'com.trolltech.Examples.CarInterface\' >\n" .
" <method name=\'accelerate\' />\n" .
" <method name=\'decelerate\' />\n" .
" <method name=\'turnLeft\' />\n" .
" <method name=\'turnRight\' />\n" .
" <signal name=\'crashed\' />\n" .
" </interface>\n" .
'';
use Qt4::slots
accelerate => [],
decelerate => [],
turnLeft => [],
turnRight => [];
use Qt4::signals
crashed => [];
sub NEW
{
my ($class, $parent, $car) = @_;
# constructor
$class->SUPER::NEW($parent);
this->{car} = $car;
this->startTimer(1000 / 33);
}
sub accelerate
{
# handle method call com.trolltech.Examples.CarInterface.accelerate
#Qt4::MetaObject::invokeMethod(this->{car}, 'accelerate');
this->{car}->accelerate();
}
sub decelerate
{
# handle method call com.trolltech.Examples.CarInterface.decelerate
#Qt4::MetaObject::invokeMethod(this->{car}, 'decelerate');
this->{car}->decelerate();
}
sub turnLeft
{
# handle method call com.trolltech.Examples.CarInterface.turnLeft
#Qt4::MetaObject::invokeMethod(this->{car}, 'turnLeft');
this->{car}->turnLeft();
}
sub turnRight
{
# handle method call com.trolltech.Examples.CarInterface.turnRight
#Qt4::MetaObject::invokeMethod(this->{car}, 'turnRight');
this->{car}->turnRight();
}
sub timerEvent
{
this->{car}->timerEvent(@_);
}
1;
|