| 1 |
/* |
|---|
| 2 |
* This file is part of gtkD. |
|---|
| 3 |
* |
|---|
| 4 |
* gtkD is free software; you can redistribute it and/or modify |
|---|
| 5 |
* it under the terms of the GNU Lesser General Public License |
|---|
| 6 |
* as published by the Free Software Foundation; either version 3 |
|---|
| 7 |
* of the License, or (at your option) any later version, with |
|---|
| 8 |
* some exceptions, please read the COPYING file. |
|---|
| 9 |
* |
|---|
| 10 |
* gtkD is distributed in the hope that it will be useful, |
|---|
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 |
* GNU Lesser General Public License for more details. |
|---|
| 14 |
* |
|---|
| 15 |
* You should have received a copy of the GNU Lesser General Public License |
|---|
| 16 |
* along with gtkD; if not, write to the Free Software |
|---|
| 17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA |
|---|
| 18 |
*/ |
|---|
| 19 |
|
|---|
| 20 |
// generated automatically - do not change |
|---|
| 21 |
// find conversion definition on APILookup.txt |
|---|
| 22 |
// implement new conversion functionalities on the wrap.utils pakage |
|---|
| 23 |
|
|---|
| 24 |
/* |
|---|
| 25 |
* Conversion parameters: |
|---|
| 26 |
* inFile = GDBusConnection.html |
|---|
| 27 |
* outPack = gio |
|---|
| 28 |
* outFile = DBusConnection |
|---|
| 29 |
* strct = GDBusConnection |
|---|
| 30 |
* realStrct= |
|---|
| 31 |
* ctorStrct= |
|---|
| 32 |
* clss = DBusConnection |
|---|
| 33 |
* interf = |
|---|
| 34 |
* class Code: Yes |
|---|
| 35 |
* interface Code: No |
|---|
| 36 |
* template for: |
|---|
| 37 |
* extend = GObject |
|---|
| 38 |
* implements: |
|---|
| 39 |
* - InitableIF |
|---|
| 40 |
* - AsyncInitableIF |
|---|
| 41 |
* prefixes: |
|---|
| 42 |
* - g_dbus_connection_ |
|---|
| 43 |
* - g_dbus_ |
|---|
| 44 |
* omit structs: |
|---|
| 45 |
* omit prefixes: |
|---|
| 46 |
* omit code: |
|---|
| 47 |
* - g_dbus_connection_new_finish |
|---|
| 48 |
* - g_dbus_connection_new_for_address_finish |
|---|
| 49 |
* omit signals: |
|---|
| 50 |
* imports: |
|---|
| 51 |
* - glib.Str |
|---|
| 52 |
* - glib.ErrorG |
|---|
| 53 |
* - glib.GException |
|---|
| 54 |
* - glib.Variant |
|---|
| 55 |
* - glib.VariantType |
|---|
| 56 |
* - gio.AsyncResultIF |
|---|
| 57 |
* - gio.Cancellable |
|---|
| 58 |
* - gio.Credentials |
|---|
| 59 |
* - gio.DBusAuthObserver |
|---|
| 60 |
* - gio.DBusMessage |
|---|
| 61 |
* - gio.DBusMethodInvocation |
|---|
| 62 |
* - gio.IOStream |
|---|
| 63 |
* - gio.InitableT |
|---|
| 64 |
* - gio.InitableIF |
|---|
| 65 |
* - gio.AsyncInitableT |
|---|
| 66 |
* - gio.AsyncInitableIF |
|---|
| 67 |
* structWrap: |
|---|
| 68 |
* - GAsyncResult* -> AsyncResultIF |
|---|
| 69 |
* - GCancellable* -> Cancellable |
|---|
| 70 |
* - GCredentials* -> Credentials |
|---|
| 71 |
* - GDBusAuthObserver* -> DBusAuthObserver |
|---|
| 72 |
* - GDBusConnection* -> DBusConnection |
|---|
| 73 |
* - GDBusMessage* -> DBusMessage |
|---|
| 74 |
* - GDBusMethodInvocation* -> DBusMethodInvocation |
|---|
| 75 |
* - GIOStream* -> IOStream |
|---|
| 76 |
* - GVariant* -> Variant |
|---|
| 77 |
* - GVariantType* -> VariantType |
|---|
| 78 |
* module aliases: |
|---|
| 79 |
* local aliases: |
|---|
| 80 |
* overrides: |
|---|
| 81 |
*/ |
|---|
| 82 |
|
|---|
| 83 |
module gio.DBusConnection; |
|---|
| 84 |
|
|---|
| 85 |
public import gtkc.giotypes; |
|---|
| 86 |
|
|---|
| 87 |
private import gtkc.gio; |
|---|
| 88 |
private import glib.ConstructionException; |
|---|
| 89 |
|
|---|
| 90 |
private import gobject.Signals; |
|---|
| 91 |
public import gtkc.gdktypes; |
|---|
| 92 |
|
|---|
| 93 |
private import glib.Str; |
|---|
| 94 |
private import glib.ErrorG; |
|---|
| 95 |
private import glib.GException; |
|---|
| 96 |
private import glib.Variant; |
|---|
| 97 |
private import glib.VariantType; |
|---|
| 98 |
private import gio.AsyncResultIF; |
|---|
| 99 |
private import gio.Cancellable; |
|---|
| 100 |
private import gio.Credentials; |
|---|
| 101 |
private import gio.DBusAuthObserver; |
|---|
| 102 |
private import gio.DBusMessage; |
|---|
| 103 |
private import gio.DBusMethodInvocation; |
|---|
| 104 |
private import gio.IOStream; |
|---|
| 105 |
private import gio.InitableT; |
|---|
| 106 |
private import gio.InitableIF; |
|---|
| 107 |
private import gio.AsyncInitableT; |
|---|
| 108 |
private import gio.AsyncInitableIF; |
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
private import gobject.ObjectG; |
|---|
| 113 |
|
|---|
| 114 |
/** |
|---|
| 115 |
* Description |
|---|
| 116 |
* The GDBusConnection type is used for D-Bus connections to remote |
|---|
| 117 |
* peers such as a message buses. It is a low-level API that offers a |
|---|
| 118 |
* lot of flexibility. For instance, it lets you establish a connection |
|---|
| 119 |
* over any transport that can by represented as an GIOStream. |
|---|
| 120 |
* This class is rarely used directly in D-Bus clients. If you are writing |
|---|
| 121 |
* an D-Bus client, it is often easier to use the g_bus_own_name(), |
|---|
| 122 |
* g_bus_watch_name() or g_dbus_proxy_new_for_bus() APIs. |
|---|
| 123 |
* $(DDOC_COMMENT example) |
|---|
| 124 |
* $(DDOC_COMMENT example) |
|---|
| 125 |
* $(DDOC_COMMENT example) |
|---|
| 126 |
* $(DDOC_COMMENT example) |
|---|
| 127 |
*/ |
|---|
| 128 |
public class DBusConnection : ObjectG, InitableIF, AsyncInitableIF |
|---|
| 129 |
{ |
|---|
| 130 |
|
|---|
| 131 |
/** the main Gtk struct */ |
|---|
| 132 |
protected GDBusConnection* gDBusConnection; |
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
public GDBusConnection* getDBusConnectionStruct() |
|---|
| 136 |
{ |
|---|
| 137 |
return gDBusConnection; |
|---|
| 138 |
} |
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
/** the main Gtk struct as a void* */ |
|---|
| 142 |
protected override void* getStruct() |
|---|
| 143 |
{ |
|---|
| 144 |
return cast(void*)gDBusConnection; |
|---|
| 145 |
} |
|---|
| 146 |
|
|---|
| 147 |
/** |
|---|
| 148 |
* Sets our main struct and passes it to the parent class |
|---|
| 149 |
*/ |
|---|
| 150 |
public this (GDBusConnection* gDBusConnection) |
|---|
| 151 |
{ |
|---|
| 152 |
if(gDBusConnection is null) |
|---|
| 153 |
{ |
|---|
| 154 |
this = null; |
|---|
| 155 |
return; |
|---|
| 156 |
} |
|---|
| 157 |
//Check if there already is a D object for this gtk struct |
|---|
| 158 |
void* ptr = getDObject(cast(GObject*)gDBusConnection); |
|---|
| 159 |
if( ptr !is null ) |
|---|
| 160 |
{ |
|---|
| 161 |
this = cast(DBusConnection)ptr; |
|---|
| 162 |
return; |
|---|
| 163 |
} |
|---|
| 164 |
super(cast(GObject*)gDBusConnection); |
|---|
| 165 |
this.gDBusConnection = gDBusConnection; |
|---|
| 166 |
} |
|---|
| 167 |
|
|---|
| 168 |
protected override void setStruct(GObject* obj) |
|---|
| 169 |
{ |
|---|
| 170 |
super.setStruct(obj); |
|---|
| 171 |
gDBusConnection = cast(GDBusConnection*)obj; |
|---|
| 172 |
} |
|---|
| 173 |
|
|---|
| 174 |
// add the Initable capabilities |
|---|
| 175 |
mixin InitableT!(DBusConnection); |
|---|
| 176 |
|
|---|
| 177 |
// add the AsyncInitable capabilities |
|---|
| 178 |
mixin AsyncInitableT!(DBusConnection); |
|---|
| 179 |
|
|---|
| 180 |
/** |
|---|
| 181 |
* Finishes an operation started with g_dbus_connection_new(). |
|---|
| 182 |
* Since 2.26 |
|---|
| 183 |
* Params: |
|---|
| 184 |
* res = A GAsyncResult obtained from the GAsyncReadyCallback |
|---|
| 185 |
* passed to g_dbus_connection_new(). |
|---|
| 186 |
* address = If true finish an address. |
|---|
| 187 |
* Throws: GException on failure. |
|---|
| 188 |
* Throws: ConstructionException GTK+ fails to create the object. |
|---|
| 189 |
*/ |
|---|
| 190 |
public this (AsyncResultIF res, bool address = false) |
|---|
| 191 |
{ |
|---|
| 192 |
// GDBusConnection * g_dbus_connection_new_finish (GAsyncResult *res, GError **error); |
|---|
| 193 |
GError* err = null; |
|---|
| 194 |
GDBusConnection* p; |
|---|
| 195 |
|
|---|
| 196 |
if ( address ) |
|---|
| 197 |
{ |
|---|
| 198 |
p = g_dbus_connection_new_for_address_finish((res is null) ? null : res.getAsyncResultTStruct(), &err); |
|---|
| 199 |
} |
|---|
| 200 |
else |
|---|
| 201 |
{ |
|---|
| 202 |
p = g_dbus_connection_new_finish((res is null) ? null : res.getAsyncResultTStruct(), &err); |
|---|
| 203 |
} |
|---|
| 204 |
|
|---|
| 205 |
if (err !is null) |
|---|
| 206 |
{ |
|---|
| 207 |
throw new GException( new ErrorG(err) ); |
|---|
| 208 |
} |
|---|
| 209 |
|
|---|
| 210 |
if(p is null) |
|---|
| 211 |
{ |
|---|
| 212 |
throw new ConstructionException("null returned by g_dbus_connection_new_finish((res is null) ? null : res.getAsyncResultTStruct(), &err)"); |
|---|
| 213 |
} |
|---|
| 214 |
this(cast(GDBusConnection*) p); |
|---|
| 215 |
} |
|---|
| 216 |
|
|---|
| 217 |
/** |
|---|
| 218 |
*/ |
|---|
| 219 |
int[string] connectedSignals; |
|---|
| 220 |
|
|---|
| 221 |
void delegate(gboolean, GError*, DBusConnection)[] onClosedListeners; |
|---|
| 222 |
/** |
|---|
| 223 |
* Emitted when the connection is closed. |
|---|
| 224 |
* The cause of this event can be |
|---|
| 225 |
* If g_dbus_connection_close() is called. In this case |
|---|
| 226 |
* remote_peer_vanished is set to FALSE and error is NULL. |
|---|
| 227 |
* If the remote peer closes the connection. In this case |
|---|
| 228 |
* remote_peer_vanished is set to TRUE and error is set. |
|---|
| 229 |
* If the remote peer sends invalid or malformed data. In this |
|---|
| 230 |
* case remote_peer_vanished is set to FALSE and error |
|---|
| 231 |
* is set. |
|---|
| 232 |
* Upon receiving this signal, you should give up your reference to |
|---|
| 233 |
* connection. You are guaranteed that this signal is emitted only |
|---|
| 234 |
* once. |
|---|
| 235 |
* TRUE if connection is closed because the |
|---|
| 236 |
* remote peer closed its end of the connection. |
|---|
| 237 |
* Since 2.26 |
|---|
| 238 |
*/ |
|---|
| 239 |
void addOnClosed(void delegate(gboolean, GError*, DBusConnection) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) |
|---|
| 240 |
{ |
|---|
| 241 |
if ( !("closed" in connectedSignals) ) |
|---|
| 242 |
{ |
|---|
| 243 |
Signals.connectData( |
|---|
| 244 |
getStruct(), |
|---|
| 245 |
"closed", |
|---|
| 246 |
cast(GCallback)&callBackClosed, |
|---|
| 247 |
cast(void*)this, |
|---|
| 248 |
null, |
|---|
| 249 |
connectFlags); |
|---|
| 250 |
connectedSignals["closed"] = 1; |
|---|
| 251 |
} |
|---|
| 252 |
onClosedListeners ~= dlg; |
|---|
| 253 |
} |
|---|
| 254 |
extern(C) static void callBackClosed(GDBusConnection* connectionStruct, gboolean remotePeerVanished, GError* error, DBusConnection dBusConnection) |
|---|
| 255 |
{ |
|---|
| 256 |
foreach ( void delegate(gboolean, GError*, DBusConnection) dlg ; dBusConnection.onClosedListeners ) |
|---|
| 257 |
{ |
|---|
| 258 |
dlg(remotePeerVanished, error, dBusConnection); |
|---|
| 259 |
} |
|---|
| 260 |
} |
|---|
| 261 |
|
|---|
| 262 |
|
|---|
| 263 |
/** |
|---|
| 264 |
* Asynchronously connects to the message bus specified by bus_type. |
|---|
| 265 |
* When the operation is finished, callback will be invoked. You can |
|---|
| 266 |
* then call g_bus_get_finish() to get the result of the operation. |
|---|
| 267 |
* This is a asynchronous failable function. See g_bus_get_sync() for |
|---|
| 268 |
* the synchronous version. |
|---|
| 269 |
* Since 2.26 |
|---|
| 270 |
* Params: |
|---|
| 271 |
* busType = A GBusType. |
|---|
| 272 |
* cancellable = A GCancellable or NULL. |
|---|
| 273 |
* callback = A GAsyncReadyCallback to call when the request is satisfied. |
|---|
| 274 |
* userData = The data to pass to callback. |
|---|
| 275 |
*/ |
|---|
| 276 |
public static void gBusGet(GBusType busType, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) |
|---|
| 277 |
{ |
|---|
| 278 |
// void g_bus_get (GBusType bus_type, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); |
|---|
| 279 |
g_bus_get(busType, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); |
|---|
| 280 |
} |
|---|
| 281 |
|
|---|
| 282 |
/** |
|---|
| 283 |
* Finishes an operation started with g_bus_get(). |
|---|
| 284 |
* The returned object is a singleton, that is, shared with other |
|---|
| 285 |
* callers of g_bus_get() and g_bus_get_sync() for bus_type. In the |
|---|
| 286 |
* event that you need a private message bus connection, use |
|---|
| 287 |
* g_dbus_address_get_for_bus() and |
|---|
| 288 |
* g_dbus_connection_new_for_address(). |
|---|
| 289 |
* Note that the returned GDBusConnection object will (usually) have |
|---|
| 290 |
* the "exit-on-close" property set to TRUE. |
|---|
| 291 |
* Since 2.26 |
|---|
| 292 |
* Params: |
|---|
| 293 |
* res = A GAsyncResult obtained from the GAsyncReadyCallback passed to g_bus_get(). |
|---|
| 294 |
* Returns: A GDBusConnection or NULL if error is set. Free with g_object_unref(). [transfer full] |
|---|
| 295 |
* Throws: GException on failure. |
|---|
| 296 |
*/ |
|---|
| 297 |
public static DBusConnection gBusGetFinish(AsyncResultIF res) |
|---|
| 298 |
{ |
|---|
| 299 |
// GDBusConnection * g_bus_get_finish (GAsyncResult *res, GError **error); |
|---|
| 300 |
GError* err = null; |
|---|
| 301 |
|
|---|
| 302 |
auto p = g_bus_get_finish((res is null) ? null : res.getAsyncResultTStruct(), &err); |
|---|
| 303 |
|
|---|
| 304 |
if (err !is null) |
|---|
| 305 |
{ |
|---|
| 306 |
throw new GException( new ErrorG(err) ); |
|---|
| 307 |
} |
|---|
| 308 |
|
|---|
| 309 |
if(p is null) |
|---|
| 310 |
{ |
|---|
| 311 |
return null; |
|---|
| 312 |
} |
|---|
| 313 |
return new DBusConnection(cast(GDBusConnection*) p); |
|---|
| 314 |
} |
|---|
| 315 |
|
|---|
| 316 |
/** |
|---|
| 317 |
* Synchronously connects to the message bus specified by bus_type. |
|---|
| 318 |
* Note that the returned object may shared with other callers, |
|---|
| 319 |
* e.g. if two separate parts of a process calls this function with |
|---|
| 320 |
* the same bus_type, they will share the same object. |
|---|
| 321 |
* This is a synchronous failable function. See g_bus_get() and |
|---|
| 322 |
* g_bus_get_finish() for the asynchronous version. |
|---|
| 323 |
* The returned object is a singleton, that is, shared with other |
|---|
| 324 |
* callers of g_bus_get() and g_bus_get_sync() for bus_type. In the |
|---|
| 325 |
* event that you need a private message bus connection, use |
|---|
| 326 |
* g_dbus_address_get_for_bus_sync() and |
|---|
| 327 |
* g_dbus_connection_new_for_address(). |
|---|
| 328 |
* Note that the returned GDBusConnection object will (usually) have |
|---|
| 329 |
* the "exit-on-close" property set to TRUE. |
|---|
| 330 |
* Since 2.26 |
|---|
| 331 |
* Params: |
|---|
| 332 |
* busType = A GBusType. |
|---|
| 333 |
* cancellable = A GCancellable or NULL. |
|---|
| 334 |
* Returns: A GDBusConnection or NULL if error is set. Free with g_object_unref(). [transfer full] |
|---|
| 335 |
* Throws: GException on failure. |
|---|
| 336 |
*/ |
|---|
| 337 |
public static DBusConnection gBusGetSync(GBusType busType, Cancellable cancellable) |
|---|
| 338 |
{ |
|---|
| 339 |
// GDBusConnection * g_bus_get_sync (GBusType bus_type, GCancellable *cancellable, GError **error); |
|---|
| 340 |
GError* err = null; |
|---|
| 341 |
|
|---|
| 342 |
auto p = g_bus_get_sync(busType, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 343 |
|
|---|
| 344 |
if (err !is null) |
|---|
| 345 |
{ |
|---|
| 346 |
throw new GException( new ErrorG(err) ); |
|---|
| 347 |
} |
|---|
| 348 |
|
|---|
| 349 |
if(p is null) |
|---|
| 350 |
{ |
|---|
| 351 |
return null; |
|---|
| 352 |
} |
|---|
| 353 |
return new DBusConnection(cast(GDBusConnection*) p); |
|---|
| 354 |
} |
|---|
| 355 |
|
|---|
| 356 |
/** |
|---|
| 357 |
* Asynchronously sets up a D-Bus connection for exchanging D-Bus messages |
|---|
| 358 |
* with the end represented by stream. |
|---|
| 359 |
* If observer is not NULL it may be used to control the |
|---|
| 360 |
* authentication process. |
|---|
| 361 |
* When the operation is finished, callback will be invoked. You can |
|---|
| 362 |
* then call g_dbus_connection_new_finish() to get the result of the |
|---|
| 363 |
* operation. |
|---|
| 364 |
* This is a asynchronous failable constructor. See |
|---|
| 365 |
* g_dbus_connection_new_sync() for the synchronous |
|---|
| 366 |
* version. |
|---|
| 367 |
* Since 2.26 |
|---|
| 368 |
* Params: |
|---|
| 369 |
* stream = A GIOStream. |
|---|
| 370 |
* guid = The GUID to use if a authenticating as a server or NULL. [allow-none] |
|---|
| 371 |
* flags = Flags describing how to make the connection. |
|---|
| 372 |
* observer = A GDBusAuthObserver or NULL. [allow-none] |
|---|
| 373 |
* cancellable = A GCancellable or NULL. |
|---|
| 374 |
* callback = A GAsyncReadyCallback to call when the request is satisfied. |
|---|
| 375 |
* userData = The data to pass to callback. |
|---|
| 376 |
*/ |
|---|
| 377 |
public static void newDBusConnection(IOStream stream, string guid, GDBusConnectionFlags flags, DBusAuthObserver observer, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) |
|---|
| 378 |
{ |
|---|
| 379 |
// void g_dbus_connection_new (GIOStream *stream, const gchar *guid, GDBusConnectionFlags flags, GDBusAuthObserver *observer, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); |
|---|
| 380 |
g_dbus_connection_new((stream is null) ? null : stream.getIOStreamStruct(), Str.toStringz(guid), flags, (observer is null) ? null : observer.getDBusAuthObserverStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); |
|---|
| 381 |
} |
|---|
| 382 |
|
|---|
| 383 |
/** |
|---|
| 384 |
* Synchronously sets up a D-Bus connection for exchanging D-Bus messages |
|---|
| 385 |
* with the end represented by stream. |
|---|
| 386 |
* If observer is not NULL it may be used to control the |
|---|
| 387 |
* authentication process. |
|---|
| 388 |
* This is a synchronous failable constructor. See |
|---|
| 389 |
* g_dbus_connection_new() for the asynchronous version. |
|---|
| 390 |
* Since 2.26 |
|---|
| 391 |
* Params: |
|---|
| 392 |
* stream = A GIOStream. |
|---|
| 393 |
* guid = The GUID to use if a authenticating as a server or NULL. [allow-none] |
|---|
| 394 |
* flags = Flags describing how to make the connection. |
|---|
| 395 |
* observer = A GDBusAuthObserver or NULL. [allow-none] |
|---|
| 396 |
* cancellable = A GCancellable or NULL. |
|---|
| 397 |
* Throws: GException on failure. |
|---|
| 398 |
* Throws: ConstructionException GTK+ fails to create the object. |
|---|
| 399 |
*/ |
|---|
| 400 |
public this (IOStream stream, string guid, GDBusConnectionFlags flags, DBusAuthObserver observer, Cancellable cancellable) |
|---|
| 401 |
{ |
|---|
| 402 |
// GDBusConnection * g_dbus_connection_new_sync (GIOStream *stream, const gchar *guid, GDBusConnectionFlags flags, GDBusAuthObserver *observer, GCancellable *cancellable, GError **error); |
|---|
| 403 |
GError* err = null; |
|---|
| 404 |
|
|---|
| 405 |
auto p = g_dbus_connection_new_sync((stream is null) ? null : stream.getIOStreamStruct(), Str.toStringz(guid), flags, (observer is null) ? null : observer.getDBusAuthObserverStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 406 |
|
|---|
| 407 |
if (err !is null) |
|---|
| 408 |
{ |
|---|
| 409 |
throw new GException( new ErrorG(err) ); |
|---|
| 410 |
} |
|---|
| 411 |
|
|---|
| 412 |
if(p is null) |
|---|
| 413 |
{ |
|---|
| 414 |
throw new ConstructionException("null returned by g_dbus_connection_new_sync((stream is null) ? null : stream.getIOStreamStruct(), Str.toStringz(guid), flags, (observer is null) ? null : observer.getDBusAuthObserverStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err)"); |
|---|
| 415 |
} |
|---|
| 416 |
this(cast(GDBusConnection*) p); |
|---|
| 417 |
} |
|---|
| 418 |
|
|---|
| 419 |
/** |
|---|
| 420 |
* Asynchronously connects and sets up a D-Bus client connection for |
|---|
| 421 |
* exchanging D-Bus messages with an endpoint specified by address |
|---|
| 422 |
* which must be in the D-Bus address format. |
|---|
| 423 |
* This constructor can only be used to initiate client-side |
|---|
| 424 |
* connections - use g_dbus_connection_new() if you need to act as the |
|---|
| 425 |
* server. In particular, flags cannot contain the |
|---|
| 426 |
* G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER or |
|---|
| 427 |
* G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS flags. |
|---|
| 428 |
* When the operation is finished, callback will be invoked. You can |
|---|
| 429 |
* then call g_dbus_connection_new_finish() to get the result of the |
|---|
| 430 |
* operation. |
|---|
| 431 |
* If observer is not NULL it may be used to control the |
|---|
| 432 |
* authentication process. |
|---|
| 433 |
* This is a asynchronous failable constructor. See |
|---|
| 434 |
* g_dbus_connection_new_for_address_sync() for the synchronous |
|---|
| 435 |
* version. |
|---|
| 436 |
* Since 2.26 |
|---|
| 437 |
* Params: |
|---|
| 438 |
* address = A D-Bus address. |
|---|
| 439 |
* flags = Flags describing how to make the connection. |
|---|
| 440 |
* observer = A GDBusAuthObserver or NULL. [allow-none] |
|---|
| 441 |
* cancellable = A GCancellable or NULL. |
|---|
| 442 |
* callback = A GAsyncReadyCallback to call when the request is satisfied. |
|---|
| 443 |
* userData = The data to pass to callback. |
|---|
| 444 |
*/ |
|---|
| 445 |
public static void newForAddress(string address, GDBusConnectionFlags flags, DBusAuthObserver observer, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) |
|---|
| 446 |
{ |
|---|
| 447 |
// void g_dbus_connection_new_for_address (const gchar *address, GDBusConnectionFlags flags, GDBusAuthObserver *observer, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); |
|---|
| 448 |
g_dbus_connection_new_for_address(Str.toStringz(address), flags, (observer is null) ? null : observer.getDBusAuthObserverStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); |
|---|
| 449 |
} |
|---|
| 450 |
|
|---|
| 451 |
/** |
|---|
| 452 |
* Synchronously connects and sets up a D-Bus client connection for |
|---|
| 453 |
* exchanging D-Bus messages with an endpoint specified by address |
|---|
| 454 |
* which must be in the D-Bus address format. |
|---|
| 455 |
* This constructor can only be used to initiate client-side |
|---|
| 456 |
* connections - use g_dbus_connection_new_sync() if you need to act |
|---|
| 457 |
* as the server. In particular, flags cannot contain the |
|---|
| 458 |
* G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER or |
|---|
| 459 |
* G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS flags. |
|---|
| 460 |
* This is a synchronous failable constructor. See |
|---|
| 461 |
* g_dbus_connection_new_for_address() for the asynchronous version. |
|---|
| 462 |
* If observer is not NULL it may be used to control the |
|---|
| 463 |
* authentication process. |
|---|
| 464 |
* Since 2.26 |
|---|
| 465 |
* Params: |
|---|
| 466 |
* address = A D-Bus address. |
|---|
| 467 |
* flags = Flags describing how to make the connection. |
|---|
| 468 |
* observer = A GDBusAuthObserver or NULL. [allow-none] |
|---|
| 469 |
* cancellable = A GCancellable or NULL. |
|---|
| 470 |
* Throws: GException on failure. |
|---|
| 471 |
* Throws: ConstructionException GTK+ fails to create the object. |
|---|
| 472 |
*/ |
|---|
| 473 |
public this (string address, GDBusConnectionFlags flags, DBusAuthObserver observer, Cancellable cancellable) |
|---|
| 474 |
{ |
|---|
| 475 |
// GDBusConnection * g_dbus_connection_new_for_address_sync (const gchar *address, GDBusConnectionFlags flags, GDBusAuthObserver *observer, GCancellable *cancellable, GError **error); |
|---|
| 476 |
GError* err = null; |
|---|
| 477 |
|
|---|
| 478 |
auto p = g_dbus_connection_new_for_address_sync(Str.toStringz(address), flags, (observer is null) ? null : observer.getDBusAuthObserverStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 479 |
|
|---|
| 480 |
if (err !is null) |
|---|
| 481 |
{ |
|---|
| 482 |
throw new GException( new ErrorG(err) ); |
|---|
| 483 |
} |
|---|
| 484 |
|
|---|
| 485 |
if(p is null) |
|---|
| 486 |
{ |
|---|
| 487 |
throw new ConstructionException("null returned by g_dbus_connection_new_for_address_sync(Str.toStringz(address), flags, (observer is null) ? null : observer.getDBusAuthObserverStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err)"); |
|---|
| 488 |
} |
|---|
| 489 |
this(cast(GDBusConnection*) p); |
|---|
| 490 |
} |
|---|
| 491 |
|
|---|
| 492 |
/** |
|---|
| 493 |
* If connection was created with |
|---|
| 494 |
* G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING, this method |
|---|
| 495 |
* starts processing messages. Does nothing on if connection wasn't |
|---|
| 496 |
* created with this flag or if the method has already been called. |
|---|
| 497 |
* Since 2.26 |
|---|
| 498 |
*/ |
|---|
| 499 |
public void startMessageProcessing() |
|---|
| 500 |
{ |
|---|
| 501 |
// void g_dbus_connection_start_message_processing (GDBusConnection *connection); |
|---|
| 502 |
g_dbus_connection_start_message_processing(gDBusConnection); |
|---|
| 503 |
} |
|---|
| 504 |
|
|---|
| 505 |
/** |
|---|
| 506 |
* Closes connection. Note that this never causes the process to |
|---|
| 507 |
* exit (this might only happen if the other end of a shared message |
|---|
| 508 |
* bus connection disconnects, see "exit-on-close"). |
|---|
| 509 |
* Once the connection is closed, operations such as sending a message |
|---|
| 510 |
* will return with the error G_IO_ERROR_CLOSED. Closing a connection |
|---|
| 511 |
* will not automatically flush the connection so queued messages may |
|---|
| 512 |
* be lost. Use g_dbus_connection_flush() if you need such guarantees. |
|---|
| 513 |
* If connection is already closed, this method fails with |
|---|
| 514 |
* G_IO_ERROR_CLOSED. |
|---|
| 515 |
* When connection has been closed, the "closed" |
|---|
| 516 |
* signal is emitted in the thread-default main |
|---|
| 517 |
* loop of the thread that connection was constructed in. |
|---|
| 518 |
* This is an asynchronous method. When the operation is finished, |
|---|
| 519 |
* callback will be invoked in the thread-default main |
|---|
| 520 |
* loop of the thread you are calling this method from. You can |
|---|
| 521 |
* then call g_dbus_connection_close_finish() to get the result of the |
|---|
| 522 |
* operation. See g_dbus_connection_close_sync() for the synchronous |
|---|
| 523 |
* version. |
|---|
| 524 |
* Since 2.26 |
|---|
| 525 |
* Params: |
|---|
| 526 |
* cancellable = A GCancellable or NULL. |
|---|
| 527 |
* callback = A GAsyncReadyCallback to call when the request is |
|---|
| 528 |
* satisfied or NULL if you don't care about the result. [allow-none] |
|---|
| 529 |
* userData = The data to pass to callback. |
|---|
| 530 |
*/ |
|---|
| 531 |
public void close(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) |
|---|
| 532 |
{ |
|---|
| 533 |
// void g_dbus_connection_close (GDBusConnection *connection, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); |
|---|
| 534 |
g_dbus_connection_close(gDBusConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); |
|---|
| 535 |
} |
|---|
| 536 |
|
|---|
| 537 |
/** |
|---|
| 538 |
* Finishes an operation started with g_dbus_connection_close(). |
|---|
| 539 |
* Since 2.26 |
|---|
| 540 |
* Params: |
|---|
| 541 |
* res = A GAsyncResult obtained from the GAsyncReadyCallback passed to g_dbus_connection_close(). |
|---|
| 542 |
* Returns: TRUE if the operation succeeded, FALSE if error is set. |
|---|
| 543 |
* Throws: GException on failure. |
|---|
| 544 |
*/ |
|---|
| 545 |
public int closeFinish(AsyncResultIF res) |
|---|
| 546 |
{ |
|---|
| 547 |
// gboolean g_dbus_connection_close_finish (GDBusConnection *connection, GAsyncResult *res, GError **error); |
|---|
| 548 |
GError* err = null; |
|---|
| 549 |
|
|---|
| 550 |
auto p = g_dbus_connection_close_finish(gDBusConnection, (res is null) ? null : res.getAsyncResultTStruct(), &err); |
|---|
| 551 |
|
|---|
| 552 |
if (err !is null) |
|---|
| 553 |
{ |
|---|
| 554 |
throw new GException( new ErrorG(err) ); |
|---|
| 555 |
} |
|---|
| 556 |
|
|---|
| 557 |
return p; |
|---|
| 558 |
} |
|---|
| 559 |
|
|---|
| 560 |
/** |
|---|
| 561 |
* Synchronously closees connection. The calling thread is blocked |
|---|
| 562 |
* until this is done. See g_dbus_connection_close() for the |
|---|
| 563 |
* asynchronous version of this method and more details about what it |
|---|
| 564 |
* does. |
|---|
| 565 |
* Since 2.26 |
|---|
| 566 |
* Params: |
|---|
| 567 |
* cancellable = A GCancellable or NULL. |
|---|
| 568 |
* Returns: TRUE if the operation succeeded, FALSE if error is set. |
|---|
| 569 |
* Throws: GException on failure. |
|---|
| 570 |
*/ |
|---|
| 571 |
public int closeSync(Cancellable cancellable) |
|---|
| 572 |
{ |
|---|
| 573 |
// gboolean g_dbus_connection_close_sync (GDBusConnection *connection, GCancellable *cancellable, GError **error); |
|---|
| 574 |
GError* err = null; |
|---|
| 575 |
|
|---|
| 576 |
auto p = g_dbus_connection_close_sync(gDBusConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 577 |
|
|---|
| 578 |
if (err !is null) |
|---|
| 579 |
{ |
|---|
| 580 |
throw new GException( new ErrorG(err) ); |
|---|
| 581 |
} |
|---|
| 582 |
|
|---|
| 583 |
return p; |
|---|
| 584 |
} |
|---|
| 585 |
|
|---|
| 586 |
/** |
|---|
| 587 |
* Gets whether connection is closed. |
|---|
| 588 |
* Since 2.26 |
|---|
| 589 |
* Returns: TRUE if the connection is closed, FALSE otherwise. |
|---|
| 590 |
*/ |
|---|
| 591 |
public int isClosed() |
|---|
| 592 |
{ |
|---|
| 593 |
// gboolean g_dbus_connection_is_closed (GDBusConnection *connection); |
|---|
| 594 |
return g_dbus_connection_is_closed(gDBusConnection); |
|---|
| 595 |
} |
|---|
| 596 |
|
|---|
| 597 |
/** |
|---|
| 598 |
* Asynchronously flushes connection, that is, writes all queued |
|---|
| 599 |
* outgoing message to the transport and then flushes the transport |
|---|
| 600 |
* (using g_output_stream_flush_async()). This is useful in programs |
|---|
| 601 |
* that wants to emit a D-Bus signal and then exit |
|---|
| 602 |
* immediately. Without flushing the connection, there is no guarantee |
|---|
| 603 |
* that the message has been sent to the networking buffers in the OS |
|---|
| 604 |
* kernel. |
|---|
| 605 |
* This is an asynchronous method. When the operation is finished, |
|---|
| 606 |
* callback will be invoked in the thread-default main |
|---|
| 607 |
* loop of the thread you are calling this method from. You can |
|---|
| 608 |
* then call g_dbus_connection_flush_finish() to get the result of the |
|---|
| 609 |
* operation. See g_dbus_connection_flush_sync() for the synchronous |
|---|
| 610 |
* version. |
|---|
| 611 |
* Since 2.26 |
|---|
| 612 |
* Params: |
|---|
| 613 |
* cancellable = A GCancellable or NULL. |
|---|
| 614 |
* callback = A GAsyncReadyCallback to call when the request is |
|---|
| 615 |
* satisfied or NULL if you don't care about the result. [allow-none] |
|---|
| 616 |
* userData = The data to pass to callback. |
|---|
| 617 |
*/ |
|---|
| 618 |
public void flush(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) |
|---|
| 619 |
{ |
|---|
| 620 |
// void g_dbus_connection_flush (GDBusConnection *connection, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); |
|---|
| 621 |
g_dbus_connection_flush(gDBusConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); |
|---|
| 622 |
} |
|---|
| 623 |
|
|---|
| 624 |
/** |
|---|
| 625 |
* Finishes an operation started with g_dbus_connection_flush(). |
|---|
| 626 |
* Since 2.26 |
|---|
| 627 |
* Params: |
|---|
| 628 |
* res = A GAsyncResult obtained from the GAsyncReadyCallback passed to g_dbus_connection_flush(). |
|---|
| 629 |
* Returns: TRUE if the operation succeeded, FALSE if error is set. |
|---|
| 630 |
* Throws: GException on failure. |
|---|
| 631 |
*/ |
|---|
| 632 |
public int flushFinish(AsyncResultIF res) |
|---|
| 633 |
{ |
|---|
| 634 |
// gboolean g_dbus_connection_flush_finish (GDBusConnection *connection, GAsyncResult *res, GError **error); |
|---|
| 635 |
GError* err = null; |
|---|
| 636 |
|
|---|
| 637 |
auto p = g_dbus_connection_flush_finish(gDBusConnection, (res is null) ? null : res.getAsyncResultTStruct(), &err); |
|---|
| 638 |
|
|---|
| 639 |
if (err !is null) |
|---|
| 640 |
{ |
|---|
| 641 |
throw new GException( new ErrorG(err) ); |
|---|
| 642 |
} |
|---|
| 643 |
|
|---|
| 644 |
return p; |
|---|
| 645 |
} |
|---|
| 646 |
|
|---|
| 647 |
/** |
|---|
| 648 |
* Synchronously flushes connection. The calling thread is blocked |
|---|
| 649 |
* until this is done. See g_dbus_connection_flush() for the |
|---|
| 650 |
* asynchronous version of this method and more details about what it |
|---|
| 651 |
* does. |
|---|
| 652 |
* Since 2.26 |
|---|
| 653 |
* Params: |
|---|
| 654 |
* cancellable = A GCancellable or NULL. |
|---|
| 655 |
* Returns: TRUE if the operation succeeded, FALSE if error is set. |
|---|
| 656 |
* Throws: GException on failure. |
|---|
| 657 |
*/ |
|---|
| 658 |
public int flushSync(Cancellable cancellable) |
|---|
| 659 |
{ |
|---|
| 660 |
// gboolean g_dbus_connection_flush_sync (GDBusConnection *connection, GCancellable *cancellable, GError **error); |
|---|
| 661 |
GError* err = null; |
|---|
| 662 |
|
|---|
| 663 |
auto p = g_dbus_connection_flush_sync(gDBusConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 664 |
|
|---|
| 665 |
if (err !is null) |
|---|
| 666 |
{ |
|---|
| 667 |
throw new GException( new ErrorG(err) ); |
|---|
| 668 |
} |
|---|
| 669 |
|
|---|
| 670 |
return p; |
|---|
| 671 |
} |
|---|
| 672 |
|
|---|
| 673 |
/** |
|---|
| 674 |
* Gets whether the process is terminated when connection is |
|---|
| 675 |
* closed by the remote peer. See |
|---|
| 676 |
* "exit-on-close" for more details. |
|---|
| 677 |
* Since 2.26 |
|---|
| 678 |
* Returns: Whether the process is terminated when connection is closed by the remote peer. |
|---|
| 679 |
*/ |
|---|
| 680 |
public int getExitOnClose() |
|---|
| 681 |
{ |
|---|
| 682 |
// gboolean g_dbus_connection_get_exit_on_close (GDBusConnection *connection); |
|---|
| 683 |
return g_dbus_connection_get_exit_on_close(gDBusConnection); |
|---|
| 684 |
} |
|---|
| 685 |
|
|---|
| 686 |
/** |
|---|
| 687 |
* Sets whether the process should be terminated when connection is |
|---|
| 688 |
* closed by the remote peer. See "exit-on-close" for |
|---|
| 689 |
* more details. |
|---|
| 690 |
* Note that this function should be used with care. Most modern UNIX |
|---|
| 691 |
* desktops tie the notion of a user session the session bus, and expect |
|---|
| 692 |
* all of a users applications to quit when their bus connection goes away. |
|---|
| 693 |
* If you are setting exit_on_close to FALSE for the shared session |
|---|
| 694 |
* bus connection, you should make sure that your application exits |
|---|
| 695 |
* when the user session ends. |
|---|
| 696 |
* Since 2.26 |
|---|
| 697 |
* Params: |
|---|
| 698 |
* exitOnClose = Whether the process should be terminated |
|---|
| 699 |
* when connection is closed by the remote peer. |
|---|
| 700 |
*/ |
|---|
| 701 |
public void setExitOnClose(int exitOnClose) |
|---|
| 702 |
{ |
|---|
| 703 |
// void g_dbus_connection_set_exit_on_close (GDBusConnection *connection, gboolean exit_on_close); |
|---|
| 704 |
g_dbus_connection_set_exit_on_close(gDBusConnection, exitOnClose); |
|---|
| 705 |
} |
|---|
| 706 |
|
|---|
| 707 |
/** |
|---|
| 708 |
* Gets the underlying stream used for IO. |
|---|
| 709 |
* Since 2.26 |
|---|
| 710 |
* Returns: the stream used for IO. [transfer none] |
|---|
| 711 |
*/ |
|---|
| 712 |
public IOStream getStream() |
|---|
| 713 |
{ |
|---|
| 714 |
// GIOStream * g_dbus_connection_get_stream (GDBusConnection *connection); |
|---|
| 715 |
auto p = g_dbus_connection_get_stream(gDBusConnection); |
|---|
| 716 |
if(p is null) |
|---|
| 717 |
{ |
|---|
| 718 |
return null; |
|---|
| 719 |
} |
|---|
| 720 |
return new IOStream(cast(GIOStream*) p); |
|---|
| 721 |
} |
|---|
| 722 |
|
|---|
| 723 |
/** |
|---|
| 724 |
* The GUID of the peer performing the role of server when |
|---|
| 725 |
* authenticating. See "guid" for more details. |
|---|
| 726 |
* Since 2.26 |
|---|
| 727 |
* Returns: The GUID. Do not free this string, it is owned by connection. |
|---|
| 728 |
*/ |
|---|
| 729 |
public string getGuid() |
|---|
| 730 |
{ |
|---|
| 731 |
// const gchar * g_dbus_connection_get_guid (GDBusConnection *connection); |
|---|
| 732 |
return Str.toString(g_dbus_connection_get_guid(gDBusConnection)); |
|---|
| 733 |
} |
|---|
| 734 |
|
|---|
| 735 |
/** |
|---|
| 736 |
* Gets the unique name of connection as assigned by the message |
|---|
| 737 |
* bus. This can also be used to figure out if connection is a |
|---|
| 738 |
* message bus connection. |
|---|
| 739 |
* Since 2.26 |
|---|
| 740 |
* Returns: The unique name or NULL if connection is not a message bus connection. Do not free this string, it is owned by connection. |
|---|
| 741 |
*/ |
|---|
| 742 |
public string getUniqueName() |
|---|
| 743 |
{ |
|---|
| 744 |
// const gchar * g_dbus_connection_get_unique_name (GDBusConnection *connection); |
|---|
| 745 |
return Str.toString(g_dbus_connection_get_unique_name(gDBusConnection)); |
|---|
| 746 |
} |
|---|
| 747 |
|
|---|
| 748 |
/** |
|---|
| 749 |
* Gets the capabilities negotiated with the remote peer |
|---|
| 750 |
* Since 2.26 |
|---|
| 751 |
* Returns: Zero or more flags from the GDBusCapabilityFlags enumeration. |
|---|
| 752 |
*/ |
|---|
| 753 |
public GDBusCapabilityFlags getCapabilities() |
|---|
| 754 |
{ |
|---|
| 755 |
// GDBusCapabilityFlags g_dbus_connection_get_capabilities (GDBusConnection *connection); |
|---|
| 756 |
return g_dbus_connection_get_capabilities(gDBusConnection); |
|---|
| 757 |
} |
|---|
| 758 |
|
|---|
| 759 |
/** |
|---|
| 760 |
* Gets the credentials of the authenticated peer. This will always |
|---|
| 761 |
* return NULL unless connection acted as a server |
|---|
| 762 |
* (e.g. G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER was passed) |
|---|
| 763 |
* when set up and the client passed credentials as part of the |
|---|
| 764 |
* authentication process. |
|---|
| 765 |
* In a message bus setup, the message bus is always the server and |
|---|
| 766 |
* each application is a client. So this method will always return |
|---|
| 767 |
* NULL for message bus clients. |
|---|
| 768 |
* Since 2.26 |
|---|
| 769 |
* Returns: A GCredentials or NULL if not available. Do not free this object, it is owned by connection. [transfer none] |
|---|
| 770 |
*/ |
|---|
| 771 |
public Credentials getPeerCredentials() |
|---|
| 772 |
{ |
|---|
| 773 |
// GCredentials * g_dbus_connection_get_peer_credentials (GDBusConnection *connection); |
|---|
| 774 |
auto p = g_dbus_connection_get_peer_credentials(gDBusConnection); |
|---|
| 775 |
if(p is null) |
|---|
| 776 |
{ |
|---|
| 777 |
return null; |
|---|
| 778 |
} |
|---|
| 779 |
return new Credentials(cast(GCredentials*) p); |
|---|
| 780 |
} |
|---|
| 781 |
|
|---|
| 782 |
/** |
|---|
| 783 |
* Asynchronously invokes the method_name method on the |
|---|
| 784 |
* interface_name D-Bus interface on the remote object at |
|---|
| 785 |
* object_path owned by bus_name. |
|---|
| 786 |
* If connection is closed then the operation will fail with |
|---|
| 787 |
* G_IO_ERROR_CLOSED. If cancellable is canceled, the operation will |
|---|
| 788 |
* fail with G_IO_ERROR_CANCELLED. If parameters contains a value |
|---|
| 789 |
* not compatible with the D-Bus protocol, the operation fails with |
|---|
| 790 |
* G_IO_ERROR_INVALID_ARGUMENT. |
|---|
| 791 |
* If reply_type is non-NULL then the reply will be checked for having this type and an |
|---|
| 792 |
* error will be raised if it does not match. Said another way, if you give a reply_type |
|---|
| 793 |
* then any non-NULL return value will be of this type. |
|---|
| 794 |
* If the parameters GVariant is floating, it is consumed. This allows |
|---|
| 795 |
* Since 2.26 |
|---|
| 796 |
* Params: |
|---|
| 797 |
* busName = A unique or well-known bus name or NULL if |
|---|
| 798 |
* connection is not a message bus connection. [allow-none] |
|---|
| 799 |
* objectPath = Path of remote object. |
|---|
| 800 |
* interfaceName = D-Bus interface to invoke method on. |
|---|
| 801 |
* methodName = The name of the method to invoke. |
|---|
| 802 |
* parameters = A GVariant tuple with parameters for the method |
|---|
| 803 |
* or NULL if not passing parameters. [allow-none] |
|---|
| 804 |
* replyType = The expected type of the reply, or NULL. [allow-none] |
|---|
| 805 |
* flags = Flags from the GDBusCallFlags enumeration. |
|---|
| 806 |
* timeoutMsec = The timeout in milliseconds, -1 to use the default |
|---|
| 807 |
* timeout or G_MAXINT for no timeout. |
|---|
| 808 |
* cancellable = A GCancellable or NULL. |
|---|
| 809 |
* callback = A GAsyncReadyCallback to call when the request is |
|---|
| 810 |
* satisfied or NULL if you don't * care about the result of the |
|---|
| 811 |
* method invocation. [allow-none] |
|---|
| 812 |
* userData = The data to pass to callback. |
|---|
| 813 |
*/ |
|---|
| 814 |
public void call(string busName, string objectPath, string interfaceName, string methodName, Variant parameters, VariantType replyType, GDBusCallFlags flags, int timeoutMsec, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) |
|---|
| 815 |
{ |
|---|
| 816 |
// void g_dbus_connection_call (GDBusConnection *connection, const gchar *bus_name, const gchar *object_path, const gchar *interface_name, const gchar *method_name, GVariant *parameters, const GVariantType *reply_type, GDBusCallFlags flags, gint timeout_msec, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); |
|---|
| 817 |
g_dbus_connection_call(gDBusConnection, Str.toStringz(busName), Str.toStringz(objectPath), Str.toStringz(interfaceName), Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), (replyType is null) ? null : replyType.getVariantTypeStruct(), flags, timeoutMsec, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); |
|---|
| 818 |
} |
|---|
| 819 |
|
|---|
| 820 |
/** |
|---|
| 821 |
* Finishes an operation started with g_dbus_connection_call(). |
|---|
| 822 |
* Since 2.26 |
|---|
| 823 |
* Params: |
|---|
| 824 |
* res = A GAsyncResult obtained from the GAsyncReadyCallback passed to g_dbus_connection_call(). |
|---|
| 825 |
* Returns: NULL if error is set. Otherwise a GVariant tuple with return values. Free with g_variant_unref(). |
|---|
| 826 |
* Throws: GException on failure. |
|---|
| 827 |
*/ |
|---|
| 828 |
public Variant callFinish(AsyncResultIF res) |
|---|
| 829 |
{ |
|---|
| 830 |
// GVariant * g_dbus_connection_call_finish (GDBusConnection *connection, GAsyncResult *res, GError **error); |
|---|
| 831 |
GError* err = null; |
|---|
| 832 |
|
|---|
| 833 |
auto p = g_dbus_connection_call_finish(gDBusConnection, (res is null) ? null : res.getAsyncResultTStruct(), &err); |
|---|
| 834 |
|
|---|
| 835 |
if (err !is null) |
|---|
| 836 |
{ |
|---|
| 837 |
throw new GException( new ErrorG(err) ); |
|---|
| 838 |
} |
|---|
| 839 |
|
|---|
| 840 |
if(p is null) |
|---|
| 841 |
{ |
|---|
| 842 |
return null; |
|---|
| 843 |
} |
|---|
| 844 |
return new Variant(cast(GVariant*) p); |
|---|
| 845 |
} |
|---|
| 846 |
|
|---|
| 847 |
/** |
|---|
| 848 |
* Synchronously invokes the method_name method on the |
|---|
| 849 |
* interface_name D-Bus interface on the remote object at |
|---|
| 850 |
* object_path owned by bus_name. |
|---|
| 851 |
* If connection is closed then the operation will fail with |
|---|
| 852 |
* G_IO_ERROR_CLOSED. If cancellable is canceled, the |
|---|
| 853 |
* operation will fail with G_IO_ERROR_CANCELLED. If parameters |
|---|
| 854 |
* contains a value not compatible with the D-Bus protocol, the operation |
|---|
| 855 |
* fails with G_IO_ERROR_INVALID_ARGUMENT. |
|---|
| 856 |
* If reply_type is non-NULL then the reply will be checked for having |
|---|
| 857 |
* this type and an error will be raised if it does not match. Said |
|---|
| 858 |
* another way, if you give a reply_type then any non-NULL return |
|---|
| 859 |
* value will be of this type. |
|---|
| 860 |
* If the parameters GVariant is floating, it is consumed. |
|---|
| 861 |
* Since 2.26 |
|---|
| 862 |
* Params: |
|---|
| 863 |
* busName = A unique or well-known bus name. |
|---|
| 864 |
* objectPath = Path of remote object. |
|---|
| 865 |
* interfaceName = D-Bus interface to invoke method on. |
|---|
| 866 |
* methodName = The name of the method to invoke. |
|---|
| 867 |
* parameters = A GVariant tuple with parameters for the method |
|---|
| 868 |
* or NULL if not passing parameters. [allow-none] |
|---|
| 869 |
* replyType = The expected type of the reply, or NULL. [allow-none] |
|---|
| 870 |
* flags = Flags from the GDBusCallFlags enumeration. |
|---|
| 871 |
* timeoutMsec = The timeout in milliseconds, -1 to use the default |
|---|
| 872 |
* timeout or G_MAXINT for no timeout. |
|---|
| 873 |
* cancellable = A GCancellable or NULL. |
|---|
| 874 |
* Returns: NULL if error is set. Otherwise a GVariant tuple with return values. Free with g_variant_unref(). |
|---|
| 875 |
* Throws: GException on failure. |
|---|
| 876 |
*/ |
|---|
| 877 |
public Variant callSync(string busName, string objectPath, string interfaceName, string methodName, Variant parameters, VariantType replyType, GDBusCallFlags flags, int timeoutMsec, Cancellable cancellable) |
|---|
| 878 |
{ |
|---|
| 879 |
// GVariant * g_dbus_connection_call_sync (GDBusConnection *connection, const gchar *bus_name, const gchar *object_path, const gchar *interface_name, const gchar *method_name, GVariant *parameters, const GVariantType *reply_type, GDBusCallFlags flags, gint timeout_msec, GCancellable *cancellable, GError **error); |
|---|
| 880 |
GError* err = null; |
|---|
| 881 |
|
|---|
| 882 |
auto p = g_dbus_connection_call_sync(gDBusConnection, Str.toStringz(busName), Str.toStringz(objectPath), Str.toStringz(interfaceName), Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), (replyType is null) ? null : replyType.getVariantTypeStruct(), flags, timeoutMsec, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 883 |
|
|---|
| 884 |
if (err !is null) |
|---|
| 885 |
{ |
|---|
| 886 |
throw new GException( new ErrorG(err) ); |
|---|
| 887 |
} |
|---|
| 888 |
|
|---|
| 889 |
if(p is null) |
|---|
| 890 |
{ |
|---|
| 891 |
return null; |
|---|
| 892 |
} |
|---|
| 893 |
return new Variant(cast(GVariant*) p); |
|---|
| 894 |
} |
|---|
| 895 |
|
|---|
| 896 |
/** |
|---|
| 897 |
* Emits a signal. |
|---|
| 898 |
* If the parameters GVariant is floating, it is consumed. |
|---|
| 899 |
* This can only fail if parameters is not compatible with the D-Bus protocol. |
|---|
| 900 |
* Since 2.26 |
|---|
| 901 |
* Params: |
|---|
| 902 |
* destinationBusName = The unique bus name for the destination |
|---|
| 903 |
* for the signal or NULL to emit to all listeners. [allow-none] |
|---|
| 904 |
* objectPath = Path of remote object. |
|---|
| 905 |
* interfaceName = D-Bus interface to emit a signal on. |
|---|
| 906 |
* signalName = The name of the signal to emit. |
|---|
| 907 |
* parameters = A GVariant tuple with parameters for the signal |
|---|
| 908 |
* or NULL if not passing parameters. [allow-none] |
|---|
| 909 |
* Returns: TRUE unless error is set. |
|---|
| 910 |
* Throws: GException on failure. |
|---|
| 911 |
*/ |
|---|
| 912 |
public int emitSignal(string destinationBusName, string objectPath, string interfaceName, string signalName, Variant parameters) |
|---|
| 913 |
{ |
|---|
| 914 |
// gboolean g_dbus_connection_emit_signal (GDBusConnection *connection, const gchar *destination_bus_name, const gchar *object_path, const gchar *interface_name, const gchar *signal_name, GVariant *parameters, GError **error); |
|---|
| 915 |
GError* err = null; |
|---|
| 916 |
|
|---|
| 917 |
auto p = g_dbus_connection_emit_signal(gDBusConnection, Str.toStringz(destinationBusName), Str.toStringz(objectPath), Str.toStringz(interfaceName), Str.toStringz(signalName), (parameters is null) ? null : parameters.getVariantStruct(), &err); |
|---|
| 918 |
|
|---|
| 919 |
if (err !is null) |
|---|
| 920 |
{ |
|---|
| 921 |
throw new GException( new ErrorG(err) ); |
|---|
| 922 |
} |
|---|
| 923 |
|
|---|
| 924 |
return p; |
|---|
| 925 |
} |
|---|
| 926 |
|
|---|
| 927 |
/** |
|---|
| 928 |
* Subscribes to signals on connection and invokes callback with a |
|---|
| 929 |
* whenever the signal is received. Note that callback |
|---|
| 930 |
* will be invoked in the thread-default main |
|---|
| 931 |
* loop of the thread you are calling this method from. |
|---|
| 932 |
* If connection is not a message bus connection, sender must be |
|---|
| 933 |
* NULL. |
|---|
| 934 |
* If sender is a well-known name note that callback is invoked with |
|---|
| 935 |
* the unique name for the owner of sender, not the well-known name |
|---|
| 936 |
* as one would expect. This is because the message bus rewrites the |
|---|
| 937 |
* name. As such, to avoid certain race conditions, users should be |
|---|
| 938 |
* tracking the name owner of the well-known name and use that when |
|---|
| 939 |
* processing the received signal. |
|---|
| 940 |
* Since 2.26 |
|---|
| 941 |
* Params: |
|---|
| 942 |
* sender = Sender name to match on (unique or well-known name) |
|---|
| 943 |
* or NULL to listen from all senders. [allow-none] |
|---|
| 944 |
* interfaceName = D-Bus interface name to match on or NULL to |
|---|
| 945 |
* match on all interfaces. [allow-none] |
|---|
| 946 |
* member = D-Bus signal name to match on or NULL to match on all signals. [allow-none] |
|---|
| 947 |
* objectPath = Object path to match on or NULL to match on all object paths. [allow-none] |
|---|
| 948 |
* arg0 = Contents of first string argument to match on or NULL |
|---|
| 949 |
* to match on all kinds of arguments. [allow-none] |
|---|
| 950 |
* flags = Flags describing how to subscribe to the signal (currently unused). |
|---|
| 951 |
* callback = Callback to invoke when there is a signal matching the requested data. |
|---|
| 952 |
* userData = User data to pass to callback. |
|---|
| 953 |
* userDataFreeFunc = Function to free user_data with when subscription is removed or NULL. |
|---|
| 954 |
* Returns: A subscription identifier that can be used with g_dbus_connection_signal_unsubscribe(). |
|---|
| 955 |
*/ |
|---|
| 956 |
public uint signalSubscribe(string sender, string interfaceName, string member, string objectPath, string arg0, GDBusSignalFlags flags, GDBusSignalCallback callback, void* userData, GDestroyNotify userDataFreeFunc) |
|---|
| 957 |
{ |
|---|
| 958 |
// guint g_dbus_connection_signal_subscribe (GDBusConnection *connection, const gchar *sender, const gchar *interface_name, const gchar *member, const gchar *object_path, const gchar *arg0, GDBusSignalFlags flags, GDBusSignalCallback callback, gpointer user_data, GDestroyNotify user_data_free_func); |
|---|
| 959 |
return g_dbus_connection_signal_subscribe(gDBusConnection, Str.toStringz(sender), Str.toStringz(interfaceName), Str.toStringz(member), Str.toStringz(objectPath), Str.toStringz(arg0), flags, callback, userData, userDataFreeFunc); |
|---|
| 960 |
} |
|---|
| 961 |
|
|---|
| 962 |
/** |
|---|
| 963 |
* Unsubscribes from signals. |
|---|
| 964 |
* Since 2.26 |
|---|
| 965 |
* Params: |
|---|
| 966 |
* subscriptionId = A subscription id obtained from g_dbus_connection_signal_subscribe(). |
|---|
| 967 |
*/ |
|---|
| 968 |
public void signalUnsubscribe(uint subscriptionId) |
|---|
| 969 |
{ |
|---|
| 970 |
// void g_dbus_connection_signal_unsubscribe (GDBusConnection *connection, guint subscription_id); |
|---|
| 971 |
g_dbus_connection_signal_unsubscribe(gDBusConnection, subscriptionId); |
|---|
| 972 |
} |
|---|
| 973 |
|
|---|
| 974 |
/** |
|---|
| 975 |
* Asynchronously sends message to the peer represented by connection. |
|---|
| 976 |
* Unless flags contain the |
|---|
| 977 |
* G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag, the serial number |
|---|
| 978 |
* will be assigned by connection and set on message via |
|---|
| 979 |
* g_dbus_message_set_serial(). If out_serial is not NULL, then the |
|---|
| 980 |
* serial number used will be written to this location prior to |
|---|
| 981 |
* submitting the message to the underlying transport. |
|---|
| 982 |
* If connection is closed then the operation will fail with |
|---|
| 983 |
* G_IO_ERROR_CLOSED. If message is not well-formed, |
|---|
| 984 |
* the operation fails with G_IO_ERROR_INVALID_ARGUMENT. |
|---|
| 985 |
* See Example 2, âD-Bus server exampleâ and Example 4, âD-Bus UNIX File Descriptor exampleâ for an example of how to use this |
|---|
| 986 |
* low-level API to send and receive UNIX file descriptors. |
|---|
| 987 |
* Note that message must be unlocked, unless flags contain the |
|---|
| 988 |
* G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag. |
|---|
| 989 |
* Since 2.26 |
|---|
| 990 |
* Params: |
|---|
| 991 |
* message = A GDBusMessage |
|---|
| 992 |
* flags = Flags affecting how the message is sent. |
|---|
| 993 |
* outSerial = Return location for serial number assigned |
|---|
| 994 |
* to message when sending it or NULL. [out][allow-none] |
|---|
| 995 |
* Returns: TRUE if the message was well-formed and queued for transmission, FALSE if error is set. |
|---|
| 996 |
* Throws: GException on failure. |
|---|
| 997 |
*/ |
|---|
| 998 |
public int sendMessage(DBusMessage message, GDBusSendMessageFlags flags, out uint outSerial) |
|---|
| 999 |
{ |
|---|
| 1000 |
// gboolean g_dbus_connection_send_message (GDBusConnection *connection, GDBusMessage *message, GDBusSendMessageFlags flags, volatile guint32 *out_serial, GError **error); |
|---|
| 1001 |
GError* err = null; |
|---|
| 1002 |
|
|---|
| 1003 |
auto p = g_dbus_connection_send_message(gDBusConnection, (message is null) ? null : message.getDBusMessageStruct(), flags, &outSerial, &err); |
|---|
| 1004 |
|
|---|
| 1005 |
if (err !is null) |
|---|
| 1006 |
{ |
|---|
| 1007 |
throw new GException( new ErrorG(err) ); |
|---|
| 1008 |
} |
|---|
| 1009 |
|
|---|
| 1010 |
return p; |
|---|
| 1011 |
} |
|---|
| 1012 |
|
|---|
| 1013 |
/** |
|---|
| 1014 |
* Asynchronously sends message to the peer represented by connection. |
|---|
| 1015 |
* Unless flags contain the |
|---|
| 1016 |
* G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag, the serial number |
|---|
| 1017 |
* will be assigned by connection and set on message via |
|---|
| 1018 |
* g_dbus_message_set_serial(). If out_serial is not NULL, then the |
|---|
| 1019 |
* serial number used will be written to this location prior to |
|---|
| 1020 |
* submitting the message to the underlying transport. |
|---|
| 1021 |
* If connection is closed then the operation will fail with |
|---|
| 1022 |
* G_IO_ERROR_CLOSED. If cancellable is canceled, the operation will |
|---|
| 1023 |
* fail with G_IO_ERROR_CANCELLED. If message is not well-formed, |
|---|
| 1024 |
* the operation fails with G_IO_ERROR_INVALID_ARGUMENT. |
|---|
| 1025 |
* This is an asynchronous method. When the operation is finished, callback will be invoked |
|---|
| 1026 |
* in the thread-default main loop |
|---|
| 1027 |
* of the thread you are calling this method from. You can then call |
|---|
| 1028 |
* g_dbus_connection_send_message_with_reply_finish() to get the result of the operation. |
|---|
| 1029 |
* See g_dbus_connection_send_message_with_reply_sync() for the synchronous version. |
|---|
| 1030 |
* Note that message must be unlocked, unless flags contain the |
|---|
| 1031 |
* G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag. |
|---|
| 1032 |
* See Example 2, âD-Bus server exampleâ and Example 4, âD-Bus UNIX File Descriptor exampleâ for an example of how to use this |
|---|
| 1033 |
* low-level API to send and receive UNIX file descriptors. |
|---|
| 1034 |
* Since 2.26 |
|---|
| 1035 |
* Params: |
|---|
| 1036 |
* message = A GDBusMessage. |
|---|
| 1037 |
* flags = Flags affecting how the message is sent. |
|---|
| 1038 |
* timeoutMsec = The timeout in milliseconds, -1 to use the default |
|---|
| 1039 |
* timeout or G_MAXINT for no timeout. |
|---|
| 1040 |
* outSerial = Return location for serial number assigned |
|---|
| 1041 |
* to message when sending it or NULL. [out][allow-none] |
|---|
| 1042 |
* cancellable = A GCancellable or NULL. |
|---|
| 1043 |
* callback = A GAsyncReadyCallback to call when the request is |
|---|
| 1044 |
* satisfied or NULL if you don't care about the result. [allow-none] |
|---|
| 1045 |
* userData = The data to pass to callback. |
|---|
| 1046 |
*/ |
|---|
| 1047 |
public void sendMessageWithReply(DBusMessage message, GDBusSendMessageFlags flags, int timeoutMsec, out uint outSerial, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) |
|---|
| 1048 |
{ |
|---|
| 1049 |
// void g_dbus_connection_send_message_with_reply (GDBusConnection *connection, GDBusMessage *message, GDBusSendMessageFlags flags, gint timeout_msec, volatile guint32 *out_serial, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); |
|---|
| 1050 |
g_dbus_connection_send_message_with_reply(gDBusConnection, (message is null) ? null : message.getDBusMessageStruct(), flags, timeoutMsec, &outSerial, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); |
|---|
| 1051 |
} |
|---|
| 1052 |
|
|---|
| 1053 |
/** |
|---|
| 1054 |
* Finishes an operation started with g_dbus_connection_send_message_with_reply(). |
|---|
| 1055 |
* Note that error is only set if a local in-process error |
|---|
| 1056 |
* occured. That is to say that the returned GDBusMessage object may |
|---|
| 1057 |
* be of type G_DBUS_MESSAGE_TYPE_ERROR. Use |
|---|
| 1058 |
* g_dbus_message_to_gerror() to transcode this to a GError. |
|---|
| 1059 |
* See Example 2, âD-Bus server exampleâ and Example 4, âD-Bus UNIX File Descriptor exampleâ for an example of how to use this |
|---|
| 1060 |
* low-level API to send and receive UNIX file descriptors. |
|---|
| 1061 |
* Since 2.26 |
|---|
| 1062 |
* Params: |
|---|
| 1063 |
* res = A GAsyncResult obtained from the GAsyncReadyCallback passed to g_dbus_connection_send_message_with_reply(). |
|---|
| 1064 |
* Returns: A locked GDBusMessage or NULL if error is set. [transfer full] |
|---|
| 1065 |
* Throws: GException on failure. |
|---|
| 1066 |
*/ |
|---|
| 1067 |
public DBusMessage sendMessageWithReplyFinish(AsyncResultIF res) |
|---|
| 1068 |
{ |
|---|
| 1069 |
// GDBusMessage * g_dbus_connection_send_message_with_reply_finish (GDBusConnection *connection, GAsyncResult *res, GError **error); |
|---|
| 1070 |
GError* err = null; |
|---|
| 1071 |
|
|---|
| 1072 |
auto p = g_dbus_connection_send_message_with_reply_finish(gDBusConnection, (res is null) ? null : res.getAsyncResultTStruct(), &err); |
|---|
| 1073 |
|
|---|
| 1074 |
if (err !is null) |
|---|
| 1075 |
{ |
|---|
| 1076 |
throw new GException( new ErrorG(err) ); |
|---|
| 1077 |
} |
|---|
| 1078 |
|
|---|
| 1079 |
if(p is null) |
|---|
| 1080 |
{ |
|---|
| 1081 |
return null; |
|---|
| 1082 |
} |
|---|
| 1083 |
return new DBusMessage(cast(GDBusMessage*) p); |
|---|
| 1084 |
} |
|---|
| 1085 |
|
|---|
| 1086 |
/** |
|---|
| 1087 |
* Synchronously sends message to the peer represented by connection |
|---|
| 1088 |
* and blocks the calling thread until a reply is received or the |
|---|
| 1089 |
* timeout is reached. See g_dbus_connection_send_message_with_reply() |
|---|
| 1090 |
* for the asynchronous version of this method. |
|---|
| 1091 |
* Unless flags contain the |
|---|
| 1092 |
* G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag, the serial number |
|---|
| 1093 |
* will be assigned by connection and set on message via |
|---|
| 1094 |
* g_dbus_message_set_serial(). If out_serial is not NULL, then the |
|---|
| 1095 |
* serial number used will be written to this location prior to |
|---|
| 1096 |
* submitting the message to the underlying transport. |
|---|
| 1097 |
* If connection is closed then the operation will fail with |
|---|
| 1098 |
* G_IO_ERROR_CLOSED. If cancellable is canceled, the operation will |
|---|
| 1099 |
* fail with G_IO_ERROR_CANCELLED. If message is not well-formed, |
|---|
| 1100 |
* the operation fails with G_IO_ERROR_INVALID_ARGUMENT. |
|---|
| 1101 |
* Note that error is only set if a local in-process error |
|---|
| 1102 |
* occured. That is to say that the returned GDBusMessage object may |
|---|
| 1103 |
* be of type G_DBUS_MESSAGE_TYPE_ERROR. Use |
|---|
| 1104 |
* g_dbus_message_to_gerror() to transcode this to a GError. |
|---|
| 1105 |
* See Example 2, âD-Bus server exampleâ and Example 4, âD-Bus UNIX File Descriptor exampleâ for an example of how to use this |
|---|
| 1106 |
* low-level API to send and receive UNIX file descriptors. |
|---|
| 1107 |
* Note that message must be unlocked, unless flags contain the |
|---|
| 1108 |
* G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag. |
|---|
| 1109 |
* Since 2.26 |
|---|
| 1110 |
* Params: |
|---|
| 1111 |
* message = A GDBusMessage. |
|---|
| 1112 |
* flags = Flags affecting how the message is sent. |
|---|
| 1113 |
* timeoutMsec = The timeout in milliseconds, -1 to use the default |
|---|
| 1114 |
* timeout or G_MAXINT for no timeout. |
|---|
| 1115 |
* outSerial = Return location for serial number assigned |
|---|
| 1116 |
* to message when sending it or NULL. [out][allow-none] |
|---|
| 1117 |
* cancellable = A GCancellable or NULL. |
|---|
| 1118 |
* Returns: A locked GDBusMessage that is the reply to message or NULL if error is set. [transfer full] |
|---|
| 1119 |
* Throws: GException on failure. |
|---|
| 1120 |
*/ |
|---|
| 1121 |
public DBusMessage sendMessageWithReplySync(DBusMessage message, GDBusSendMessageFlags flags, int timeoutMsec, out uint outSerial, Cancellable cancellable) |
|---|
| 1122 |
{ |
|---|
| 1123 |
// GDBusMessage * g_dbus_connection_send_message_with_reply_sync (GDBusConnection *connection, GDBusMessage *message, GDBusSendMessageFlags flags, gint timeout_msec, volatile guint32 *out_serial, GCancellable *cancellable, GError **error); |
|---|
| 1124 |
GError* err = null; |
|---|
| 1125 |
|
|---|
| 1126 |
auto p = g_dbus_connection_send_message_with_reply_sync(gDBusConnection, (message is null) ? null : message.getDBusMessageStruct(), flags, timeoutMsec, &outSerial, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 1127 |
|
|---|
| 1128 |
if (err !is null) |
|---|
| 1129 |
{ |
|---|
| 1130 |
throw new GException( new ErrorG(err) ); |
|---|
| 1131 |
} |
|---|
| 1132 |
|
|---|
| 1133 |
if(p is null) |
|---|
| 1134 |
{ |
|---|
| 1135 |
return null; |
|---|
| 1136 |
} |
|---|
| 1137 |
return new DBusMessage(cast(GDBusMessage*) p); |
|---|
| 1138 |
} |
|---|
| 1139 |
|
|---|
| 1140 |
/** |
|---|
| 1141 |
* Adds a message filter. Filters are handlers that are run on all |
|---|
| 1142 |
* incoming and outgoing messages, prior to standard dispatch. Filters |
|---|
| 1143 |
* are run in the order that they were added. The same handler can be |
|---|
| 1144 |
* added as a filter more than once, in which case it will be run more |
|---|
| 1145 |
* than once. Filters added during a filter callback won't be run on |
|---|
| 1146 |
* the message being processed. Filter functions are allowed to modify |
|---|
| 1147 |
* and even drop messages - see the GDBusMessageFilterResult |
|---|
| 1148 |
* enumeration for details. |
|---|
| 1149 |
* Note that filters are run in a dedicated message handling thread so |
|---|
| 1150 |
* they can't block and, generally, can't do anything but signal a |
|---|
| 1151 |
* worker thread. Also note that filters are rarely needed - use API |
|---|
| 1152 |
* such as g_dbus_connection_send_message_with_reply(), |
|---|
| 1153 |
* g_dbus_connection_signal_subscribe() or |
|---|
| 1154 |
* g_dbus_connection_call() instead. |
|---|
| 1155 |
* If a filter consumes an incoming message the message is not |
|---|
| 1156 |
* dispatched anywhere else - not even the standard dispatch machinery |
|---|
| 1157 |
* (that API such as g_dbus_connection_signal_subscribe() and |
|---|
| 1158 |
* g_dbus_connection_send_message_with_reply() relies on) will see the |
|---|
| 1159 |
* message. Similary, if a filter consumes an outgoing message, the |
|---|
| 1160 |
* message will not be sent to the other peer. |
|---|
| 1161 |
* Since 2.26 |
|---|
| 1162 |
* Params: |
|---|
| 1163 |
* filterFunction = A filter function. |
|---|
| 1164 |
* userData = User data to pass to filter_function. |
|---|
| 1165 |
* userDataFreeFunc = Function to free user_data with when filter |
|---|
| 1166 |
* is removed or NULL. |
|---|
| 1167 |
* Returns: A filter identifier that can be used with g_dbus_connection_remove_filter(). |
|---|
| 1168 |
*/ |
|---|
| 1169 |
public uint addFilter(GDBusMessageFilterFunction filterFunction, void* userData, GDestroyNotify userDataFreeFunc) |
|---|
| 1170 |
{ |
|---|
| 1171 |
// guint g_dbus_connection_add_filter (GDBusConnection *connection, GDBusMessageFilterFunction filter_function, gpointer user_data, GDestroyNotify user_data_free_func); |
|---|
| 1172 |
return g_dbus_connection_add_filter(gDBusConnection, filterFunction, userData, userDataFreeFunc); |
|---|
| 1173 |
} |
|---|
| 1174 |
|
|---|
| 1175 |
/** |
|---|
| 1176 |
* Removes a filter. |
|---|
| 1177 |
* Since 2.26 |
|---|
| 1178 |
* Params: |
|---|
| 1179 |
* filterId = an identifier obtained from g_dbus_connection_add_filter() |
|---|
| 1180 |
*/ |
|---|
| 1181 |
public void removeFilter(uint filterId) |
|---|
| 1182 |
{ |
|---|
| 1183 |
// void g_dbus_connection_remove_filter (GDBusConnection *connection, guint filter_id); |
|---|
| 1184 |
g_dbus_connection_remove_filter(gDBusConnection, filterId); |
|---|
| 1185 |
} |
|---|
| 1186 |
|
|---|
| 1187 |
/** |
|---|
| 1188 |
* Registers callbacks for exported objects at object_path with the |
|---|
| 1189 |
* D-Bus interface that is described in interface_info. |
|---|
| 1190 |
* Calls to functions in vtable (and user_data_free_func) will |
|---|
| 1191 |
* happen in the thread-default main |
|---|
| 1192 |
* loop of the thread you are calling this method from. |
|---|
| 1193 |
* Note that all GVariant values passed to functions in vtable will match |
|---|
| 1194 |
* the signature given in interface_info - if a remote caller passes |
|---|
| 1195 |
* incorrect values, the org.freedesktop.DBus.Error.InvalidArgs |
|---|
| 1196 |
* is returned to the remote caller. |
|---|
| 1197 |
* Additionally, if the remote caller attempts to invoke methods or |
|---|
| 1198 |
* access properties not mentioned in interface_info the |
|---|
| 1199 |
* org.freedesktop.DBus.Error.UnknownMethod resp. |
|---|
| 1200 |
* org.freedesktop.DBus.Error.InvalidArgs errors |
|---|
| 1201 |
* are returned to the caller. |
|---|
| 1202 |
* It is considered a programming error if the |
|---|
| 1203 |
* GDBusInterfaceGetPropertyFunc function in vtable returns a |
|---|
| 1204 |
* GVariant of incorrect type. |
|---|
| 1205 |
* If an existing callback is already registered at object_path and |
|---|
| 1206 |
* interface_name, then error is set to G_IO_ERROR_EXISTS. |
|---|
| 1207 |
* GDBus automatically implements the standard D-Bus interfaces |
|---|
| 1208 |
* org.freedesktop.DBus.Properties, org.freedesktop.DBus.Introspectable |
|---|
| 1209 |
* and org.freedesktop.Peer, so you don't have to implement those for |
|---|
| 1210 |
* the objects you export. You can implement |
|---|
| 1211 |
* org.freedesktop.DBus.Properties yourself, e.g. to handle getting |
|---|
| 1212 |
* and setting of properties asynchronously. |
|---|
| 1213 |
* Note that the reference count on interface_info will be |
|---|
| 1214 |
* incremented by 1 (unless allocated statically, e.g. if the |
|---|
| 1215 |
* reference count is -1, see g_dbus_interface_info_ref()) for as long |
|---|
| 1216 |
* as the object is exported. Also note that vtable will be copied. |
|---|
| 1217 |
* A NULL vtable can be used for |
|---|
| 1218 |
* marker |
|---|
| 1219 |
* interfaces. |
|---|
| 1220 |
* See Example 2, âD-Bus server exampleâ for an example of how to use this |
|---|
| 1221 |
* method. |
|---|
| 1222 |
* Since 2.26 |
|---|
| 1223 |
* Params: |
|---|
| 1224 |
* objectPath = The object path to register at |
|---|
| 1225 |
* interfaceInfo = Introspection data for the interface |
|---|
| 1226 |
* vtable = A GDBusInterfaceVTable to call into, or NULL. [allow-none] |
|---|
| 1227 |
* userData = Data to pass to functions in vtable |
|---|
| 1228 |
* userDataFreeFunc = Function to call when the object path is unregistered |
|---|
| 1229 |
* Returns: 0 if error is set, otherwise a registration id (never 0) that can be used with g_dbus_connection_unregister_object() . |
|---|
| 1230 |
* Throws: GException on failure. |
|---|
| 1231 |
*/ |
|---|
| 1232 |
public uint registerObject(string objectPath, GDBusInterfaceInfo* interfaceInfo, GDBusInterfaceVTable* vtable, void* userData, GDestroyNotify userDataFreeFunc) |
|---|
| 1233 |
{ |
|---|
| 1234 |
// guint g_dbus_connection_register_object (GDBusConnection *connection, const gchar *object_path, GDBusInterfaceInfo *interface_info, const GDBusInterfaceVTable *vtable, gpointer user_data, GDestroyNotify user_data_free_func, GError **error); |
|---|
| 1235 |
GError* err = null; |
|---|
| 1236 |
|
|---|
| 1237 |
auto p = g_dbus_connection_register_object(gDBusConnection, Str.toStringz(objectPath), interfaceInfo, vtable, userData, userDataFreeFunc, &err); |
|---|
| 1238 |
|
|---|
| 1239 |
if (err !is null) |
|---|
| 1240 |
{ |
|---|
| 1241 |
throw new GException( new ErrorG(err) ); |
|---|
| 1242 |
} |
|---|
| 1243 |
|
|---|
| 1244 |
return p; |
|---|
| 1245 |
} |
|---|
| 1246 |
|
|---|
| 1247 |
/** |
|---|
| 1248 |
* Unregisters an object. |
|---|
| 1249 |
* Since 2.26 |
|---|
| 1250 |
* Params: |
|---|
| 1251 |
* registrationId = A registration id obtained from g_dbus_connection_register_object(). |
|---|
| 1252 |
* Returns: TRUE if the object was unregistered, FALSE otherwise. |
|---|
| 1253 |
*/ |
|---|
| 1254 |
public int unregisterObject(uint registrationId) |
|---|
| 1255 |
{ |
|---|
| 1256 |
// gboolean g_dbus_connection_unregister_object (GDBusConnection *connection, guint registration_id); |
|---|
| 1257 |
return g_dbus_connection_unregister_object(gDBusConnection, registrationId); |
|---|
| 1258 |
} |
|---|
| 1259 |
|
|---|
| 1260 |
/** |
|---|
| 1261 |
* Registers a whole subtree of âdynamicâ objects. |
|---|
| 1262 |
* The enumerate and introspection functions in vtable are used to |
|---|
| 1263 |
* convey, to remote callers, what nodes exist in the subtree rooted |
|---|
| 1264 |
* by object_path. |
|---|
| 1265 |
* When handling remote calls into any node in the subtree, first the |
|---|
| 1266 |
* enumerate function is used to check if the node exists. If the node exists |
|---|
| 1267 |
* or the G_DBUS_SUBTREE_FLAGS_DISPATCH_TO_UNENUMERATED_NODES flag is set |
|---|
| 1268 |
* the introspection function is used to check if the node supports the |
|---|
| 1269 |
* requested method. If so, the dispatch function is used to determine |
|---|
| 1270 |
* where to dispatch the call. The collected GDBusInterfaceVTable and |
|---|
| 1271 |
* gpointer will be used to call into the interface vtable for processing |
|---|
| 1272 |
* the request. |
|---|
| 1273 |
* All calls into user-provided code will be invoked in the thread-default main |
|---|
| 1274 |
* loop of the thread you are calling this method from. |
|---|
| 1275 |
* If an existing subtree is already registered at object_path or |
|---|
| 1276 |
* then error is set to G_IO_ERROR_EXISTS. |
|---|
| 1277 |
* Note that it is valid to register regular objects (using |
|---|
| 1278 |
* g_dbus_connection_register_object()) in a subtree registered with |
|---|
| 1279 |
* g_dbus_connection_register_subtree() - if so, the subtree handler |
|---|
| 1280 |
* is tried as the last resort. One way to think about a subtree |
|---|
| 1281 |
* handler is to consider it a âfallback handlerâ |
|---|
| 1282 |
* for object paths not registered via g_dbus_connection_register_object() |
|---|
| 1283 |
* or other bindings. |
|---|
| 1284 |
* Note that vtable will be copied so you cannot change it after |
|---|
| 1285 |
* registration. |
|---|
| 1286 |
* See Example 3, âD-Bus subtree exampleâ for an example of how to use this method. |
|---|
| 1287 |
* Since 2.26 |
|---|
| 1288 |
* Params: |
|---|
| 1289 |
* objectPath = The object path to register the subtree at. |
|---|
| 1290 |
* vtable = A GDBusSubtreeVTable to enumerate, introspect and dispatch nodes in the subtree. |
|---|
| 1291 |
* flags = Flags used to fine tune the behavior of the subtree. |
|---|
| 1292 |
* userData = Data to pass to functions in vtable. |
|---|
| 1293 |
* userDataFreeFunc = Function to call when the subtree is unregistered. |
|---|
| 1294 |
* Returns: 0 if error is set, otherwise a subtree registration id (never 0) that can be used with g_dbus_connection_unregister_subtree() . |
|---|
| 1295 |
* Throws: GException on failure. |
|---|
| 1296 |
*/ |
|---|
| 1297 |
public uint registerSubtree(string objectPath, GDBusSubtreeVTable* vtable, GDBusSubtreeFlags flags, void* userData, GDestroyNotify userDataFreeFunc) |
|---|
| 1298 |
{ |
|---|
| 1299 |
// guint g_dbus_connection_register_subtree (GDBusConnection *connection, const gchar *object_path, const GDBusSubtreeVTable *vtable, GDBusSubtreeFlags flags, gpointer user_data, GDestroyNotify user_data_free_func, GError **error); |
|---|
| 1300 |
GError* err = null; |
|---|
| 1301 |
|
|---|
| 1302 |
auto p = g_dbus_connection_register_subtree(gDBusConnection, Str.toStringz(objectPath), vtable, flags, userData, userDataFreeFunc, &err); |
|---|
| 1303 |
|
|---|
| 1304 |
if (err !is null) |
|---|
| 1305 |
{ |
|---|
| 1306 |
throw new GException( new ErrorG(err) ); |
|---|
| 1307 |
} |
|---|
| 1308 |
|
|---|
| 1309 |
return p; |
|---|
| 1310 |
} |
|---|
| 1311 |
|
|---|
| 1312 |
/** |
|---|
| 1313 |
* Unregisters a subtree. |
|---|
| 1314 |
* Since 2.26 |
|---|
| 1315 |
* Params: |
|---|
| 1316 |
* registrationId = A subtree registration id obtained from g_dbus_connection_register_subtree(). |
|---|
| 1317 |
* Returns: TRUE if the subtree was unregistered, FALSE otherwise. |
|---|
| 1318 |
*/ |
|---|
| 1319 |
public int unregisterSubtree(uint registrationId) |
|---|
| 1320 |
{ |
|---|
| 1321 |
// gboolean g_dbus_connection_unregister_subtree (GDBusConnection *connection, guint registration_id); |
|---|
| 1322 |
return g_dbus_connection_unregister_subtree(gDBusConnection, registrationId); |
|---|
| 1323 |
} |
|---|
| 1324 |
} |
|---|