Difference between revisions of "FPC and DBus"

From Lazarus wiki
Jump to navigationJump to search
(cleanup layout, categories)
Line 1: Line 1:
 
{{FPC and DBus}}
 
{{FPC and DBus}}
  
=== Documentation ===
+
== Overview ==
  
DBUS is a GNU library that implements inter-process communication. It's the default library of this kind for GNU applications.
+
DBUS is a GNU library that implements inter-process communication. It's the default library of this kind for GNU applications. It can often be found on Linux machines.
  
 
This library provides a simple way for applications to talk to one another, using a bus sytem. These headers are the translation of the low-level C API for DBUS. In the future it is desirable that these headers be wrapped around a class to make their use easier.
 
This library provides a simple way for applications to talk to one another, using a bus sytem. These headers are the translation of the low-level C API for DBUS. In the future it is desirable that these headers be wrapped around a class to make their use easier.
  
==== Common Code ====
+
== Documentation ==
  
Independently from what you want to achieve, a lot of the code for a software that uses DBUS will be very similar. This is the startup and finalization code. On the startup you need to connect to the bus. Usually there is a system and a session bus. Depending on the configuration of the system you may not have access to the system bus. Next you need to request a name on the bus. Below is a simple startup code.
+
Independently from what you want to achieve, a lot of the code for a program that uses DBUS will be very similar. This is the startup and finalization code.  
 +
 
 +
=== Startup ===
 +
On startup you need to connect to the bus. Usually there is a system and a session bus. Depending on the configuration of the system, you may not have access to the system bus. Next you need to request a name on the bus. Below is some simple startup code.
  
 
<syntaxhighlight>
 
<syntaxhighlight>
Line 17: Line 20:
 
   ret: cint;
 
   ret: cint;
 
begin
 
begin
   { Initializes the errors }
+
   { Initializes the error handling }
 
   dbus_error_init(@err);
 
   dbus_error_init(@err);
 
    
 
    
Line 45: Line 48:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
When you no longer need the bus you should close the connection. A good place to do this in most cases is right before the application terminates.
+
=== Shutdown ===
 +
When you no longer need the bus, you should close the connection. A good place to do this in most cases is right before the application terminates.
  
 
<syntaxhighlight>
 
<syntaxhighlight>
Line 52: Line 56:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Sending a Signal ====
+
=== Sending a Signal ===
  
==== Receiving a Signal ====
+
=== Receiving a Signal ===
  
==== Calling a Method ====
+
=== Calling a Method ===
  
==== Responding to Method calls ====
+
=== Responding to Method calls ===
  
=== Authors ===
+
== Authors ==
  
 
[[User:Sekelsenmat|Felipe Monteiro de Carvalho]]
 
[[User:Sekelsenmat|Felipe Monteiro de Carvalho]]
  
  
=== License ===
+
== License ==
  
  
=== Download ===
+
== Status ==
  
 
Status: Beta
 
Status: Beta
  
=== Download ===
+
== Download ==
  
==== Installed by default ====
+
=== Installed by default ===
The FPC package for DBUS resides in packages/[[dbus]] in the FPC (2.2.2/2.3.x+) packages tree.
+
The FPC package for DBUS resides in packages/[[dbus]] in the FPC (2.2.2+) packages tree.
  
You can download a full FPC 2.2.2+ repository and it will be included.
+
You can download a full FPC repository and it will be included.
  
==== Older versions ====
+
=== Older versions ===
 
For older versions: you can download the subversion version of this project using this command:
 
For older versions: you can download the subversion version of this project using this command:
 
<syntaxhighlight lang=bash>
 
<syntaxhighlight lang=bash>
Line 85: Line 89:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== Bug Reporting ===
+
== Bug Reporting ==
  
 
Tests are necessary to verify if all functions and structures are declared properly. Tests were done on Windows, FreeBSD and Linux operating systems. It is necessary to test if the modules work correctly in other operating system.
 
Tests are necessary to verify if all functions and structures are declared properly. Tests were done on Windows, FreeBSD and Linux operating systems. It is necessary to test if the modules work correctly in other operating system.
  
You can post Bug Reports here:
+
You can post Bug Reports to the [http://bugs.freepascal.org regular bug tracker] (make sure to choose the FPC project and select the Packages category)
*** to do: add location if it is not standard mantis***
 
  
=== Change Log ===
+
== Change Log ==
  
 
*??.??.06 DBus headers version 0.1
 
*??.??.06 DBus headers version 0.1
Line 99: Line 102:
 
* 03.11.2010 Updated DBus headers to version 1.2.16
 
* 03.11.2010 Updated DBus headers to version 1.2.16
  
=== Help ===
+
== Help ==
  
 
Please send help requests to the Free Pascal mailling list or on apache-modules mailing list.
 
Please send help requests to the Free Pascal mailling list or on apache-modules mailing list.
  
=== External Links ===
+
== See also ==
  
 
* [http://www.matthew.ath.cx/misc/dbus] - A Tutorial about using the DBUS C API
 
* [http://www.matthew.ath.cx/misc/dbus] - A Tutorial about using the DBUS C API
  
 
[[Category:Headers and Bindings]]
 
[[Category:Headers and Bindings]]
 +
[[Category:FPC]]
 +
[[Category:Linux]]

Revision as of 06:59, 5 August 2013

English (en) español (es)

Overview

DBUS is a GNU library that implements inter-process communication. It's the default library of this kind for GNU applications. It can often be found on Linux machines.

This library provides a simple way for applications to talk to one another, using a bus sytem. These headers are the translation of the low-level C API for DBUS. In the future it is desirable that these headers be wrapped around a class to make their use easier.

Documentation

Independently from what you want to achieve, a lot of the code for a program that uses DBUS will be very similar. This is the startup and finalization code.

Startup

On startup you need to connect to the bus. Usually there is a system and a session bus. Depending on the configuration of the system, you may not have access to the system bus. Next you need to request a name on the bus. Below is some simple startup code.

var
  err: DBusError;
  conn: PDBusConnection;
  ret: cint;
begin
  { Initializes the error handling }
  dbus_error_init(@err);
  
  { 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;
  
  if conn = nil then Exit;
  
  { Request the name of the bus }
  ret := dbus_bus_request_name(conn, 'test.method.server', DBUS_NAME_FLAG_REPLACE_EXISTING, @err);

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

  ....

Shutdown

When you no longer need the bus, you should close the connection. A good place to do this in most cases is right before the application terminates.

  { Finalization }
  dbus_connection_close(conn);

Sending a Signal

Receiving a Signal

Calling a Method

Responding to Method calls

Authors

Felipe Monteiro de Carvalho


License

Status

Status: Beta

Download

Installed by default

The FPC package for DBUS resides in packages/dbus in the FPC (2.2.2+) packages tree.

You can download a full FPC repository and it will be included.

Older versions

For older versions: you can download the subversion version of this project using this command:

svn checkout http://svn.freepascal.org/svn/fpc/trunk/packages/dbus dbus

Bug Reporting

Tests are necessary to verify if all functions and structures are declared properly. Tests were done on Windows, FreeBSD and Linux operating systems. It is necessary to test if the modules work correctly in other operating system.

You can post Bug Reports to the regular bug tracker (make sure to choose the FPC project and select the Packages category)

Change Log

  • ??.??.06 DBus headers version 0.1
  1. Under construction
  • 03.11.2010 Updated DBus headers to version 1.2.16

Help

Please send help requests to the Free Pascal mailling list or on apache-modules mailing list.

See also

  • [1] - A Tutorial about using the DBUS C API