Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-11

FPC And D-Bus

6 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ludo Brands
to ik

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

Reply by email

ik
to Ludo Brands
Ludo Brands wrote 24 lines
** 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

Thanks, It still does not work., but now it does not crash anymore :)

Show quoted text 7 lines
Ludo _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Ludo Brands
to Ludo Brands: I'm Trying to send notification using D-Bus Notify method. The thing is, that I do not…

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';
;
;
dbus_message_append_args(msg,
DBUS_TYPE_UINT32,
,
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

Reply by email

ik
to Ludo Brands
Ludo Brands wrote 61 lines
** 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'; ; ; dbus_message_append_args(msg, DBUS_TYPE_UINT32, , 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.

Thank you Ludo. It still does not work, now it complains about the interface is wrong for some reason.
I gave up, and I binded libnotify <https://github.com/ik5/libnotify-fpc>instead.

Ludo

Ido

Show quoted text 10 lines
_______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Ludo Brands
to ik

Thank you Ludo. It still does not work, now it complains about the interface is wrong for some reason.
I gave up, and I binded libnotify <https://github.com/ik5/libnotify-fpc> instead.

Probably the better solution.
I also noticed in dbus-monitor messages complaining about messages signature not correct which is probably linked to the dict entry. Appending dictionaries is complex. IRC it requires an iterator for the container and another for the entries.

Ludo

Reply by email