[fpc-pascal] FPC And D-Bus

Ludo Brands ludo.brands at free.fr
Thu Nov 24 20:33:37 CET 2011


 



I'm Trying to send notification using D-Bus Notify method.
The thing is, that I do not understand how to properly use it.
My current code:
https://github.com/ik5/display-quotes/blob/master/src/units/untquotedbus.pas
#L92

I'ved marked the place where i Have AccessViolation exception.
What am I doing wrong here ?

 

 At first sight there are several things wrong:
- all values should be pointers to variables. PINTEGER(100) should be the
address of a variable that contains 100.
- null pchars are not allowed (empty strings!)
- DBUS_TYPE_ARRAY should be a group of 4 elements:  DBUS_TYPE_ARRAY , the
type of array elements (fe DBUS_TYPE_UINT32), the address of the array,
number of elements in the array
- the array of const should terminate with a DBUS_TYPE_INVALID
- I doubt DBUS_TYPE_DICT_ENTRY is allowed in dbus_message_append_args
 
Ludo 
 

A small rectification:
- DBUS_TYPE_ARRAY should be a group of 4 elements:  DBUS_TYPE_ARRAY , the
type of array elements (fe DBUS_TYPE_UINT32), the address of the pointer to
the array, number of elements in the array.
 
So to send an uint32, a string and an array of uint32 you hvae to do the
following:
 
var 
  i:dword;
  s:string;
  aa: array[0..4] of dword;
  sp,aap:pointer;
 
...
 
s:='Display Qoutes';
sp:=@s[1];
aap:=@aa[0];
dbus_message_append_args(msg,
    DBUS_TYPE_UINT32,
    [@i,
    DBUS_TYPE_STRING,
    @sp,
    DBUS_TYPE_ARRAY,
    DBUS_TYPE_UINT32,
    @aap,
    PLongInt(5),
    DBUS_TYPE_INVALID] );
 
 
Tested on ubuntu x64, message checked with dbus-monitor. 
 
Ludo
 
 
 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20111124/fec21805/attachment.html>


More information about the fpc-pascal mailing list