summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/dbus/src/dbus-connection.inc
blob: fc1296d6371949f497ab58341aa0d9525a5f62b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
{ -*- mode: C; c-file-style: "gnu" -*- }
{ dbus-connection.h DBusConnection object
 *
 * Copyright (C) 2002, 2003  Red Hat Inc.
 *
 * Licensed under the Academic Free License version 2.1
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 }

{#include <dbus/dbus-errors.h>}
{.$include dbus-memory.inc}
{#include <dbus/dbus-message.h>}
{.$include dbus-shared.inc}

type
  DBusWatch = record end;
  PDBusWatch = ^DBusWatch;

  DBusTimeout = record end;
  PDBusTimeout = ^DBusTimeout;

  DBusPreallocatedSend = record end;
  PDBusPreallocatedSend = ^DBusPreallocatedSend;

  DBusPendingCall = record end;
  PDBusPendingCall = ^DBusPendingCall;
  PPDBusPendingCall = ^PDBusPendingCall;

  DBusConnection = record end;
  PDBusConnection = ^DBusConnection;

  DBusWatchFlags =
  (
    DBUS_WATCH_READABLE = 1 shl 0, {< As in POLLIN }
    DBUS_WATCH_WRITABLE = 1 shl 1, {< As in POLLOUT }
    DBUS_WATCH_ERROR    = 1 shl 2, {< As in POLLERR (can't watch for this, but
                                 *   the flag can be passed to dbus_watch_handle()).}
    DBUS_WATCH_HANGUP   = 1 shl 3  {< As in POLLHUP (can't watch for it, but
                                 *   can be present in current state). }
  );

  DBusDispatchStatus =
  (
    DBUS_DISPATCH_DATA_REMAINS,  {< There is more data to potentially convert to messages. }
    DBUS_DISPATCH_COMPLETE,      {< All currently available data has been processed. }
    DBUS_DISPATCH_NEED_MEMORY    {< More memory is needed to continue. }
  );

  DBusAddWatchFunction = function (watch: PDBusWatch; data: Pointer): dbus_bool_t; cdecl;
  DBusWatchToggledFunction = procedure(watch: PDBusWatch; data: Pointer); cdecl;
  DBusRemoveWatchFunction = procedure(watch: PDBusWatch; data: Pointer); cdecl;
  DBusAddTimeoutFunction = function(timeout: PDBusTimeout; data: Pointer): dbus_bool_t; cdecl;
  DBusTimeoutToggledFunction = procedure(timeout: PDBusTimeout; data: Pointer); cdecl;
  DBusRemoveTimeoutFunction = procedure(timeout: PDBusTimeout; data: Pointer); cdecl;
  DBusDispatchStatusFunction = procedure(connection: PDBusConnection;
   new_status: DBusDispatchStatus; data: Pointer); cdecl;
  DBusWakeupMainFunction = procedure(data: Pointer); cdecl;
  DBusAllowUnixUserFunction = function(connection: PDBusConnection;
   uid: cuint; data: Pointer): dbus_bool_t; cdecl;

  DBusAllowWindowsUserFunction = function(connection: PDBusConnection;
   user_sid: PChar; data: Pointer): dbus_bool_t; cdecl;

  DBusPendingCallNotifyFunction = procedure(pending: PDBusPendingCall;
   user_data: Pointer); cdecl;

  DBusHandleMessageFunction = function(connection: PDBusConnection;
   message_: PDBusMessage; user_data: Pointer): DBusHandlerResult; cdecl;

function dbus_connection_open(const address: PChar; error: PDBusError): PDBusConnection; cdecl; external LibDBus;
function dbus_connection_open_private(const address: PChar; error: PDBusError): PDBusConnection; cdecl; external LibDBus;
function dbus_connection_ref(connection: PDBusConnection): PDBusConnection; cdecl; external LibDBus;
procedure dbus_connection_unref(connection: PDBusConnection); cdecl; external LibDBus;
procedure dbus_connection_close(connection: PDBusConnection); cdecl; external LibDBus;
function dbus_connection_get_is_connected(connection: PDBusConnection): dbus_bool_t; cdecl; external LibDBus;
function dbus_connection_get_is_authenticated(connection: PDBusConnection): dbus_bool_t; cdecl; external LibDBus;
procedure dbus_connection_set_exit_on_disconnect(connection: PDBusConnection;
 exit_on_disconnect: dbus_bool_t); cdecl; external LibDBus;
procedure dbus_connection_flush(connection: PDBusConnection); cdecl; external LibDBus;
function dbus_connection_read_write_dispatch(connection: PDBusConnection;
 timeout_milliseconds: Integer): dbus_bool_t; cdecl; external LibDBus;
function dbus_connection_read_write(connection: PDBusConnection;
 timeout_milliseconds: Integer): dbus_bool_t; cdecl; external LibDBus;
function dbus_connection_borrow_message(connection: PDBusConnection): PDBusMessage; cdecl; external LibDBus;
procedure dbus_connection_return_message(connection: PDBusConnection; message_: PDBusMessage); cdecl; external LibDBus;
procedure dbus_connection_steal_borrowed_message(connection: PDBusConnection; message_: PDBusMessage); cdecl; external LibDBus;
function dbus_connection_pop_message(connection: PDBusConnection): PDBusMessage; cdecl; external LibDBus;
function dbus_connection_get_dispatch_status(connection: PDBusConnection): DBusDispatchStatus; cdecl; external LibDBus;
function dbus_connection_dispatch(connection: PDBusConnection): DBusDispatchStatus; cdecl; external LibDBus;
function dbus_connection_has_messages_to_send(connection: PDBusConnection): dbus_bool_t; cdecl; external LibDBus;
function dbus_connection_send(connection: PDBusConnection; message_: PDBusMessage;
 client_serial: Pdbus_uint32_t): dbus_bool_t; cdecl; external LibDBus;
function dbus_connection_send_with_reply(connection: PDBusConnection;
 message_: PDBusMessage;
 pending_return: PPDBusPendingCall;
 timeout_milliseconds: cint): dbus_bool_t; cdecl; external LibDBus;
function dbus_connection_send_with_reply_and_block(connection: PDBusConnection;
 message_: PDBusMessage;
 timeout_milliseconds: cint;
 error: PDBusError): PDBusMessage; cdecl; external LibDBus;
function dbus_connection_set_watch_functions(connection: PDBusConnection;
 add_function: DBusAddWatchFunction;
 remove_function: DBusRemoveWatchFunction;
 toggled_function: DBusWatchToggledFunction;
 data: Pointer;
 free_data_function: DBusFreeFunction): dbus_bool_t; cdecl; external LibDBus;
function dbus_connection_set_timeout_functions(connection: PDBusConnection;
 add_function: DBusAddTimeoutFunction;
 remove_function: DBusRemoveTimeoutFunction;
 toggled_function: DBusTimeoutToggledFunction;
 data: Pointer;
 free_data_function: DBusFreeFunction): dbus_bool_t; cdecl; external LibDBus;
procedure dbus_connection_set_wakeup_main_function(connection: PDBusConnection;
 wakeup_main_function: DBusWakeupMainFunction;
 data: Pointer;
 free_data_function: DBusFreeFunction); cdecl; external LibDBus;
procedure dbus_connection_set_dispatch_status_function (connection: PDBusConnection;
 function_: DBusDispatchStatusFunction;
 data: Pointer;
 free_data_function: DBusFreeFunction); cdecl; external LibDBus;
function dbus_connection_get_unix_user(connection: PDBusConnection;
 uid: Pculong): dbus_bool_t; cdecl; external LibDBus;
function dbus_connection_get_unix_process_id(connection: PDBusConnection;
 pid: Pculong): dbus_bool_t; cdecl; external LibDBus;
function dbus_connection_get_adt_audit_session_data(connection: PDBusConnection;
  data: PPointer; data_size: Pdbus_int32_t): dbus_bool_t; cdecl; external LibDBus;
procedure dbus_connection_set_unix_user_function(connection: PDBusConnection;
 function_: DBusAllowUnixUserFunction;
 data: Pointer;
 free_data_function: DBusFreeFunction); cdecl; external LibDBus;

function dbus_connection_get_windows_user(connection: PDBusConnection;
 windows_sid_p: PPChar): dbus_bool_t; cdecl; external LibDBus;
procedure dbus_connection_set_windows_user_function(connection: PDBusConnection;
 function_: DBusAllowWindowsUserFunction;
 data: Pointer;
 free_data_function: DBusFreeFunction); cdecl; external LibDBus;

procedure dbus_connection_set_allow_anonymous(connection: PDBusConnection;
 value: dbus_bool_t); cdecl; external LibDBus;
procedure dbus_connection_set_route_peer_messages(connection: PDBusConnection;
 value: dbus_bool_t); cdecl; external LibDBus;

//deprecated:
function dbus_watch_get_fd(watch: PDBusWatch): cint; cdecl; external LibDBus;

function dbus_watch_get_unix_fd(watch: PDBusWatch): cint; cdecl; external LibDBus;
function dbus_watch_get_socket(watch: PDBusWatch): cint; cdecl; external LibDBus;
function dbus_watch_get_flags(watch: PDBusWatch): cuint; cdecl; external LibDBus;
function dbus_watch_get_data(watch: PDBusWatch): Pointer; cdecl; external LibDBus;
procedure dbus_watch_set_data(watch: PDBusWatch;
 data: Pointer; free_data_function: DBusFreeFunction); cdecl; external LibDBus;
function dbus_watch_handle(watch: PDBusWatch; flags: cuint): dbus_bool_t; cdecl; external LibDBus;
function  dbus_watch_get_enabled(watch: PDBusWatch): dbus_bool_t; cdecl; external LibDBus;

function dbus_timeout_get_interval(timeout: PDBusTimeout): cint; cdecl; external LibDBus;
function dbus_timeout_get_data(timeout: PDBusTimeout): Pointer; cdecl; external LibDBus;
procedure dbus_timeout_set_data(timeout: PDBusTimeout;
 data: Pointer; free_data_function: DBusFreeFunction); cdecl; external LibDBus;
function dbus_timeout_handle(timeout: PDBusTimeout): dbus_bool_t; cdecl; external LibDBus;
function dbus_timeout_get_enabled(timeout: PDBusTimeout): dbus_bool_t; cdecl; external LibDBus;

{ Filters }

function dbus_connection_add_filter(connection: PDBusConnection;
 function_: DBusHandleMessageFunction;
 user_data: Pointer; free_data_function: DBusFreeFunction): dbus_bool_t; cdecl; external LibDBus;
procedure dbus_connection_remove_filter (connection: PDBusConnection;
 function_: DBusHandleMessageFunction; user_data: Pointer); cdecl; external LibDBus;


{ Other }
function dbus_connection_allocate_data_slot (slot_p: Pdbus_int32_t): dbus_bool_t; cdecl; external LibDBus;
procedure dbus_connection_free_data_slot     (slot_p: Pdbus_int32_t); cdecl; external LibDBus;
function dbus_connection_set_data(connection: PDBusConnection;
 slot: dbus_int32_t; data: Pointer; free_data_func: DBusFreeFunction): dbus_bool_t; cdecl; external LibDBus;
function dbus_connection_get_data(connection: PDBusConnection; slot: dbus_int32_t): Pointer; cdecl; external LibDBus;

procedure dbus_connection_set_change_sigpipe (will_modify_sigpipe: dbus_bool_t); cdecl; external LibDBus;

procedure dbus_connection_set_max_message_size  (connection: PDBusConnection; size: clong); cdecl; external LibDBus;
function dbus_connection_get_max_message_size  (connection: PDBusConnection): clong; cdecl; external LibDBus;
procedure dbus_connection_set_max_received_size (connection: PDBusConnection; size: clong); cdecl; external LibDBus;
function dbus_connection_get_max_received_size (connection: PDBusConnection): clong; cdecl; external LibDBus;
function dbus_connection_get_outgoing_size     (connection: PDBusConnection): clong; cdecl; external LibDBus;

function dbus_connection_preallocate_send       (connection: PDBusConnection): PDBusPreallocatedSend; cdecl; external LibDBus;
procedure dbus_connection_free_preallocated_send (connection: PDBusConnection; preallocated: PDBusPreallocatedSend); cdecl; external LibDBus;
procedure dbus_connection_send_preallocated      (connection: PDBusConnection;
 preallocated: PDBusPreallocatedSend;
 message_: PDBusMessage; client_serial: Pdbus_uint32_t); cdecl; external LibDBus;


{ Object tree functionality }

type
  DBusObjectPathUnregisterFunction = procedure(connection: PDBusConnection;
   user_data: Pointer); cdecl;
  DBusObjectPathMessageFunction = function(connection: PDBusConnection;
   message_: PDBusMessage; user_data: Pointer): DBusHandlerResult; cdecl;

{
 * Virtual table that must be implemented to handle a portion of the
 * object path hierarchy.
 }
  dbus_internal_func = procedure(param1: Pointer); cdecl;

  PDBusObjectPathVTable = ^DBusObjectPathVTable;

  DBusObjectPathVTable = record

    unregister_function: DBusObjectPathUnregisterFunction; {< Function to unregister this handler }
    message_function: DBusObjectPathMessageFunction; {< Function to handle messages }
  
    dbus_internal_pad1: dbus_internal_func; {< Reserved for future expansion }
    dbus_internal_pad2: dbus_internal_func; {< Reserved for future expansion }
    dbus_internal_pad3: dbus_internal_func; {< Reserved for future expansion }
    dbus_internal_pad4: dbus_internal_func; {< Reserved for future expansion }
  end;

function dbus_connection_try_register_object_path(connection: PDBusConnection;
  path: PChar; vtable: PDBusObjectPathVTable; user_data: Pointer;
  error: PDBusError): dbus_bool_t; cdecl; external LibDBus;

function dbus_connection_register_object_path(connection: PDBusConnection;
 path: PChar; vtable: PDBusObjectPathVTable;
 user_data: Pointer): dbus_bool_t; cdecl; external LibDBus;

function dbus_connection_try_register_fallback(connection: PDBusConnection;
 path: PChar; vtable: PDBusObjectPathVTable; user_data: Pointer;
 error: PDBusError): dbus_bool_t; cdecl; external LibDBus;

function dbus_connection_register_fallback(connection: PDBusConnection;
 const path: PChar;
 const vtable: PDBusObjectPathVTable;
 user_data: Pointer): dbus_bool_t; cdecl; external LibDBus;
function dbus_connection_unregister_object_path(connection: PDBusConnection;
 const path: PChar): dbus_bool_t; cdecl; external LibDBus;

function dbus_connection_get_object_path_data(connection: PDBusConnection;
 const path: PChar;
 data_p: PPointer): dbus_bool_t; cdecl; external LibDBus;

function dbus_connection_list_registered(connection: PDBusConnection;
 const parent_path: PChar;
 child_entries: PPPChar): dbus_bool_t; cdecl; external LibDBus;

function dbus_connection_get_unix_fd(connection: PDBusConnection;
 fd: Pcint): dbus_bool_t; cdecl; external LibDBus;

function dbus_connection_get_socket(connection: PDBusConnection;
 fd: Pcint): dbus_bool_t; cdecl; external LibDBus;