view dbus-d-javatests/dsrc/DBusTesting.d @ 6:963d271f7c25

disabled event stuff, to have working example
author Frank Benoit <benoit@tionex.de>
date Sun, 28 Oct 2007 19:35:38 +0100
parents 7c2c75740370
children
line wrap: on
line source


module DBusTesting;

import tango.sys.Environment;
import tango.io.Stdout;
import tango.core.Exception;

import org.freedesktop.dbus.DBus;

import DBusTestingGen;

bool exceptionsActive = false;
char[][] called;
void checkCall( char[] name ){
	called ~= name.dup;
	if( exceptionsActive ){
		throw new TracedException( "Test Exception thrown" );
	}
}

//pragma( msg, createDImplementation( "DImplBase", ["DBusInterface.dbustest.DImpl" ] ) );
mixin( createDImplementation( "DImplBase", ["DBusInterface.dbustest.DImpl" ] ));

class Dimpl : DImplBase {
	public void testV_V(){
		checkCall( "testV_V" );
	}
	public int testI_I( in int arg1 ){
		checkCall( "testI_I" );
		return arg1 + 1234;
	}
	public void testParamAllSimpleTyes( 
	    in  bool   i_bool, 
	    out bool   o_bool, 
	    in  byte   i_byte, 
	    out byte   o_byte, 
	    in  short  i_short, 
	    out short  o_short, 
	    in  ushort i_ushort, 
	    out ushort o_ushort, 
	    in  int    i_int, 
	    out int    o_int, 
	    in  uint   i_uint, 
	    out uint   o_uint, 
	    in  long   i_long, 
	    out long   o_long, 
	    in  ulong  i_ulong, 
	    out ulong  o_ulong, 
	    in  double i_double, 
	    out double o_double, 
	    in  char[] i_string, 
	    out char[] o_string )
	{
		checkCall( "testParamAllSimpleTyes" );
		o_bool   = !i_bool;
		o_byte   = i_byte   + 1;
		o_short  = i_short  + 1;
		o_ushort = i_ushort + 1;
		o_int    = i_int    + 1;
		o_uint   = i_uint   + 1;
		o_long   = i_long   + 1;
		o_ulong  = i_ulong  + 1;
		o_double = i_double;
		o_string = i_string.reverse;
	}
/+
	public void triggerSignal( in int count ){
		checkCall( "triggerSignal" );
		for( int i = 0; i < count; i++ ){
			testSigI.opCall( i );
		}
	}
+/
}

//mixin( createJavaImplementation( "MyClass", ["DBusInterface.dbustest.DImpl" ] ));



int main(char[][] args) {
	
	char[] address = Environment.get( "DBUS_ADDRESS" );
	if( ! address ){
		Stdout.formatln( "Environment variable DBUS_ADDRESS not set" );
		return 1;
	}
    Stdout.formatln( "D-App started");
    DirectConnection dc = new DirectConnection( address );
    Stdout.formatln("D-App connected");
    auto o = new Dimpl();
    o.registerDBusObject( dc.conn );
    Stdout.formatln("Export obj : {}", o.getDBusInstanceName() );
    dc.mainLoop();
    Stdout.formatln("D-App disconnected");
    return 0;
}