2 -- D_Bus/Ada - An Ada binding to D-Bus
4 -- Copyright (C) 2011-2015 Reto Buerki <reet@codelabs.ch>
6 -- This program is free software; you can redistribute it and/or
7 -- modify it under the terms of the GNU General Public License
8 -- as published by the Free Software Foundation; either version 2
9 -- of the License, or (at your option) any later version.
11 -- This program is distributed in the hope that it will be useful,
12 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 -- GNU General Public License for more details.
16 -- You should have received a copy of the GNU General Public License
17 -- along with this program; if not, write to the Free Software
18 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 -- As a special exception, if other files instantiate generics from this
22 -- unit, or you link this unit with other files to produce an
23 -- executable this unit does not by itself cause the resulting
24 -- executable to be covered by the GNU General Public License. This
25 -- exception does not however invalidate any other reasons why the
26 -- executable file might be covered by the GNU Public License.
29 with dbus_connection_h;
30 private with dbus_pending_call_h;
36 package D_Bus.Connection is
38 type Connection_Type (<>) is limited private;
41 function Connect (Bus : Bus_Type := Bus_Session) return Connection_Type;
42 -- Connect to the given message bus type.
44 function Connect (Address : String) return Connection_Type;
45 -- Connect to the given remote address.
47 subtype Timeout_Type is Integer range -1 .. Integer'Last;
49 Default_Timeout : constant Timeout_Type;
51 function Call_Blocking
52 (Connection : Connection_Type;
54 Path : Types.Obj_Path;
57 Timeout_Msec : Timeout_Type := Default_Timeout;
58 Args : Arguments.Argument_List_Type :=
59 Arguments.Empty_Argument_List)
60 return Arguments.Argument_List_Type;
61 -- Synchronously call the given method.
64 (Connection : Connection_Type;
65 Object_Name : Types.Obj_Path;
68 Args : Arguments.Argument_List_Type :=
69 Arguments.Empty_Argument_List);
70 -- Send a signal over the given connection.
73 (Connection : Connection_Type;
74 Message : Messages.Message_Type);
75 -- Add given message to the outgoing message queue.
77 procedure Request_Name
78 (Connection : Connection_Type;
80 -- Request name on the bus for given connection.
83 (Connection : Connection_Type;
85 -- Add given match rule to match messages going through the message bus.
88 (Connection : Connection_Type;
89 Timeout_Msec : Timeout_Type)
91 -- The return value indicates whether reading or writing is still possible
92 -- for the specified connection, i.e. whether the connection is connected.
95 (Connection : Connection_Type;
96 Message : out Messages.Message_Type);
97 -- Returns the first-received message from the incoming message queue,
98 -- removing it from the queue. The caller owns a reference to the returned
99 -- message. If the queue is empty, Null_Message is returned.
101 procedure Flush (Connection : Connection_Type);
102 -- Send any pending messages.
106 Default_Timeout : constant Timeout_Type
107 := dbus_pending_call_h.DBUS_TIMEOUT_USE_DEFAULT;
109 type Connection_Type is limited record
110 Thin_Connection : access dbus_connection_h.DBusConnection := null;
113 end D_Bus.Connection;