I found another way to register own callback events (this is example which connect to Pidgin instant messenger):

var
VTable: DBusObjectPathVTable;


function MessageHandler(connection: PDBusConnection; message_: PDBusMessage;
user_data: Pointer): DBusHandlerResult; cdecl;
begin
MemoLog.Lines.Add('New signal');

Result := DBUS_HANDLER_RESULT_HANDLED;
end;

function BusConnect: Boolean;
begin
Result := False;
dbus_error_init(@err);
MemoLog.Lines.Add('Listening for signals');
{ Connection }
conn := dbus_bus_get(DBUS_BUS_SESSION, @err);

if dbus_error_is_set(@err) <> 0 then
begin
WriteLn('Connection Error: ' + err.message);
dbus_error_free(@err);
end;

{ Request the name of the bus }
ret := dbus_bus_request_name(conn, 'im.pidgin.purple.PurpleInterface', DBUS_NAME_FLAG_REPLACE_EXISTING, @err);

if dbus_error_is_set(@err) <> 0 then
begin
MemoLog.Lines.Add('Name Error: ' + err.message);
dbus_error_free(@err);
Exit;
end;

// add a rule for which messages we want to see
dbus_bus_add_match(conn, 'type=''signal'',interface=''im.pidgin.purple.PurpleInterface''', @err); // see signals from the given interface
dbus_connection_flush(conn);
if (dbus_error_is_set(@err) <> 0) then
begin
MemoLog.Lines.Add('Match Error (' + err.message + ')');
Exit;
end;
MemoLog.Lines.Add('Match rule sent');

VTable.message_function := @MessageHandler;
if dbus_connection_try_register_object_path(conn, '/im/pidgin/purple/PurpleObject', @VTable, nil, @err)=0 then
MemoLog.Lines.Add('Cant register');
if (dbus_error_is_set(@err) <> 0) then
begin
MemoLog.Lines.Add('Error in register (' + err.message + ')');
Exit;
end;

Result := True;
end;

But this same problem like with dbus_connection_set_wakeup_main_function - It works only on my computer (64 bit ubuntu). When I send this executable to my friends or compile and run on 32 bit ubuntu, then MessageHandler is never called. dbus_connection_try_register_object_path return TRUE and error is not set, so I don't know what is a reason. But this is another proof that something is wrong with receiving callback events by free pascal dbus. I have no idea what blocking this on other computers. Firewall? Missing some librarys? On each computer is same libdbus library.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to