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 = GDBusMethodInvocation.html 27 * outPack = gio 28 * outFile = DBusMethodInvocation 29 * strct = GDBusMethodInvocation 30 * realStrct= 31 * ctorStrct= 32 * clss = DBusMethodInvocation 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - g_dbus_method_invocation_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - glib.ErrorG 48 * - glib.GException 49 * - glib.Variant 50 * - gio.DBusConnection 51 * - gio.DBusMessage 52 * - gio.DBusPropertyInfo 53 * - gio.UnixFDList 54 * structWrap: 55 * - GDBusConnection* -> DBusConnection 56 * - GDBusMessage* -> DBusMessage 57 * - GDBusPropertyInfo* -> DBusPropertyInfo 58 * - GError* -> ErrorG 59 * - GUnixFDList* -> UnixFDList 60 * - GVariant* -> Variant 61 * module aliases: 62 * local aliases: 63 * overrides: 64 */ 65 66 module gio.DBusMethodInvocation; 67 68 public import gtkc.giotypes; 69 70 private import gtkc.gio; 71 private import glib.ConstructionException; 72 private import gobject.ObjectG; 73 74 75 private import glib.Str; 76 private import glib.ErrorG; 77 private import glib.GException; 78 private import glib.Variant; 79 private import gio.DBusConnection; 80 private import gio.DBusMessage; 81 private import gio.DBusPropertyInfo; 82 private import gio.UnixFDList; 83 84 85 86 private import gobject.ObjectG; 87 88 /** 89 * Instances of the GDBusMethodInvocation class are used when 90 * handling D-Bus method calls. It provides a way to asynchronously 91 * return results and errors. 92 * 93 * The normal way to obtain a GDBusMethodInvocation object is to receive 94 * it as an argument to the handle_method_call() function in a 95 * GDBusInterfaceVTable that was passed to g_dbus_connection_register_object(). 96 */ 97 public class DBusMethodInvocation : ObjectG 98 { 99 100 /** the main Gtk struct */ 101 protected GDBusMethodInvocation* gDBusMethodInvocation; 102 103 104 public GDBusMethodInvocation* getDBusMethodInvocationStruct() 105 { 106 return gDBusMethodInvocation; 107 } 108 109 110 /** the main Gtk struct as a void* */ 111 protected override void* getStruct() 112 { 113 return cast(void*)gDBusMethodInvocation; 114 } 115 116 /** 117 * Sets our main struct and passes it to the parent class 118 */ 119 public this (GDBusMethodInvocation* gDBusMethodInvocation) 120 { 121 super(cast(GObject*)gDBusMethodInvocation); 122 this.gDBusMethodInvocation = gDBusMethodInvocation; 123 } 124 125 protected override void setStruct(GObject* obj) 126 { 127 super.setStruct(obj); 128 gDBusMethodInvocation = cast(GDBusMethodInvocation*)obj; 129 } 130 131 /** 132 */ 133 134 /** 135 * Gets the bus name that invoked the method. 136 * Since 2.26 137 * Returns: A string. Do not free, it is owned by invocation. 138 */ 139 public string getSender() 140 { 141 // const gchar * g_dbus_method_invocation_get_sender (GDBusMethodInvocation *invocation); 142 return Str.toString(g_dbus_method_invocation_get_sender(gDBusMethodInvocation)); 143 } 144 145 /** 146 * Gets the object path the method was invoked on. 147 * Since 2.26 148 * Returns: A string. Do not free, it is owned by invocation. 149 */ 150 public string getObjectPath() 151 { 152 // const gchar * g_dbus_method_invocation_get_object_path (GDBusMethodInvocation *invocation); 153 return Str.toString(g_dbus_method_invocation_get_object_path(gDBusMethodInvocation)); 154 } 155 156 /** 157 * Gets the name of the D-Bus interface the method was invoked on. 158 * If this method call is a property Get, Set or GetAll call that has 159 * been redirected to the method call handler then 160 * "org.freedesktop.DBus.Properties" will be returned. See 161 * GDBusInterfaceVTable for more information. 162 * Since 2.26 163 * Returns: A string. Do not free, it is owned by invocation. 164 */ 165 public string getInterfaceName() 166 { 167 // const gchar * g_dbus_method_invocation_get_interface_name (GDBusMethodInvocation *invocation); 168 return Str.toString(g_dbus_method_invocation_get_interface_name(gDBusMethodInvocation)); 169 } 170 171 /** 172 * Gets the name of the method that was invoked. 173 * Since 2.26 174 * Returns: A string. Do not free, it is owned by invocation. 175 */ 176 public string getMethodName() 177 { 178 // const gchar * g_dbus_method_invocation_get_method_name (GDBusMethodInvocation *invocation); 179 return Str.toString(g_dbus_method_invocation_get_method_name(gDBusMethodInvocation)); 180 } 181 182 /** 183 * Gets information about the method call, if any. 184 * If this method invocation is a property Get, Set or GetAll call that 185 * has been redirected to the method call handler then NULL will be 186 * returned. See g_dbus_method_invocation_get_property_info() and 187 * GDBusInterfaceVTable for more information. 188 * Since 2.26 189 * Returns: A GDBusMethodInfo or NULL. Do not free, it is owned by invocation. 190 */ 191 public GDBusMethodInfo* getMethodInfo() 192 { 193 // const GDBusMethodInfo * g_dbus_method_invocation_get_method_info (GDBusMethodInvocation *invocation); 194 return g_dbus_method_invocation_get_method_info(gDBusMethodInvocation); 195 } 196 197 /** 198 * Gets information about the property that this method call is for, if 199 * any. 200 * This will only be set in the case of an invocation in response to a 201 * property Get or Set call that has been directed to the method call 202 * handler for an object on account of its property_get() or 203 * property_set() vtable pointers being unset. 204 * See GDBusInterfaceVTable for more information. 205 * If the call was GetAll, NULL will be returned. 206 * Since 2.38 207 * Returns: a GDBusPropertyInfo or NULL. [transfer none] 208 */ 209 public DBusPropertyInfo getPropertyInfo() 210 { 211 // const GDBusPropertyInfo * g_dbus_method_invocation_get_property_info (GDBusMethodInvocation *invocation); 212 auto p = g_dbus_method_invocation_get_property_info(gDBusMethodInvocation); 213 214 if(p is null) 215 { 216 return null; 217 } 218 219 return ObjectG.getDObject!(DBusPropertyInfo)(cast(GDBusPropertyInfo*) p); 220 } 221 222 /** 223 * Gets the GDBusConnection the method was invoked on. 224 * Since 2.26 225 * Returns: A GDBusConnection. Do not free, it is owned by invocation. [transfer none] 226 */ 227 public DBusConnection getConnection() 228 { 229 // GDBusConnection * g_dbus_method_invocation_get_connection (GDBusMethodInvocation *invocation); 230 auto p = g_dbus_method_invocation_get_connection(gDBusMethodInvocation); 231 232 if(p is null) 233 { 234 return null; 235 } 236 237 return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) p); 238 } 239 240 /** 241 * Gets the GDBusMessage for the method invocation. This is useful if 242 * you need to use low-level protocol features, such as UNIX file 243 * descriptor passing, that cannot be properly expressed in the 244 * GVariant API. 245 * See Example 6, “D-Bus server example” and Example 8, “D-Bus UNIX File Descriptor example” for an example of how to use this 246 * low-level API to send and receive UNIX file descriptors. 247 * Since 2.26 248 * Returns: GDBusMessage. Do not free, it is owned by invocation. [transfer none] 249 */ 250 public DBusMessage getMessage() 251 { 252 // GDBusMessage * g_dbus_method_invocation_get_message (GDBusMethodInvocation *invocation); 253 auto p = g_dbus_method_invocation_get_message(gDBusMethodInvocation); 254 255 if(p is null) 256 { 257 return null; 258 } 259 260 return ObjectG.getDObject!(DBusMessage)(cast(GDBusMessage*) p); 261 } 262 263 /** 264 * Gets the parameters of the method invocation. If there are no input 265 * parameters then this will return a GVariant with 0 children rather than NULL. 266 * Since 2.26 267 * Returns: A GVariant tuple. Do not unref this because it is owned by invocation. [transfer none] 268 */ 269 public Variant getParameters() 270 { 271 // GVariant * g_dbus_method_invocation_get_parameters (GDBusMethodInvocation *invocation); 272 auto p = g_dbus_method_invocation_get_parameters(gDBusMethodInvocation); 273 274 if(p is null) 275 { 276 return null; 277 } 278 279 return ObjectG.getDObject!(Variant)(cast(GVariant*) p); 280 } 281 282 /** 283 * Gets the user_data gpointer passed to g_dbus_connection_register_object(). 284 * Since 2.26 285 * Returns: A gpointer. 286 */ 287 public void* getUserData() 288 { 289 // gpointer g_dbus_method_invocation_get_user_data (GDBusMethodInvocation *invocation); 290 return g_dbus_method_invocation_get_user_data(gDBusMethodInvocation); 291 } 292 293 /** 294 * Finishes handling a D-Bus method call by returning parameters. 295 * If the parameters GVariant is floating, it is consumed. 296 * It is an error if parameters is not of the right format. 297 * This method will free invocation, you cannot use it afterwards. 298 * Since 2.26 299 * Params: 300 * parameters = A GVariant tuple with out parameters for the method or NULL if not passing any parameters. [allow-none] 301 */ 302 public void returnValue(Variant parameters) 303 { 304 // void g_dbus_method_invocation_return_value (GDBusMethodInvocation *invocation, GVariant *parameters); 305 g_dbus_method_invocation_return_value(gDBusMethodInvocation, (parameters is null) ? null : parameters.getVariantStruct()); 306 } 307 308 /** 309 * Like g_dbus_method_invocation_return_error() but intended for 310 * language bindings. 311 * This method will free invocation, you cannot use it afterwards. 312 * Since 2.26 313 * Params: 314 * domain = A GQuark for the GError error domain. 315 * code = The error code. 316 * format = printf()-style format. 317 * varArgs = va_list of parameters for format. 318 */ 319 public void returnErrorValist(GQuark domain, int code, string format, void* varArgs) 320 { 321 // void g_dbus_method_invocation_return_error_valist (GDBusMethodInvocation *invocation, GQuark domain, gint code, const gchar *format, va_list var_args); 322 g_dbus_method_invocation_return_error_valist(gDBusMethodInvocation, domain, code, Str.toStringz(format), varArgs); 323 } 324 325 /** 326 * Like g_dbus_method_invocation_return_error() but without printf()-style formatting. 327 * This method will free invocation, you cannot use it afterwards. 328 * Since 2.26 329 * Params: 330 * domain = A GQuark for the GError error domain. 331 * code = The error code. 332 * message = The error message. 333 */ 334 public void returnErrorLiteral(GQuark domain, int code, string message) 335 { 336 // void g_dbus_method_invocation_return_error_literal (GDBusMethodInvocation *invocation, GQuark domain, gint code, const gchar *message); 337 g_dbus_method_invocation_return_error_literal(gDBusMethodInvocation, domain, code, Str.toStringz(message)); 338 } 339 340 /** 341 * Like g_dbus_method_invocation_return_error() but takes a GError 342 * instead of the error domain, error code and message. 343 * This method will free invocation, you cannot use it afterwards. 344 * Since 2.26 345 * Params: 346 * error = A GError. 347 */ 348 public void returnGerror(ErrorG error) 349 { 350 // void g_dbus_method_invocation_return_gerror (GDBusMethodInvocation *invocation, const GError *error); 351 g_dbus_method_invocation_return_gerror(gDBusMethodInvocation, (error is null) ? null : error.getErrorGStruct()); 352 } 353 354 /** 355 * Finishes handling a D-Bus method call by returning an error. 356 * This method will free invocation, you cannot use it afterwards. 357 * Since 2.26 358 * Params: 359 * errorName = A valid D-Bus error name. 360 * errorMessage = A valid D-Bus error message. 361 */ 362 public void returnDbusError(string errorName, string errorMessage) 363 { 364 // void g_dbus_method_invocation_return_dbus_error (GDBusMethodInvocation *invocation, const gchar *error_name, const gchar *error_message); 365 g_dbus_method_invocation_return_dbus_error(gDBusMethodInvocation, Str.toStringz(errorName), Str.toStringz(errorMessage)); 366 } 367 368 /** 369 * Like g_dbus_method_invocation_return_gerror() but takes ownership 370 * of error so the caller does not need to free it. 371 * This method will free invocation, you cannot use it afterwards. 372 * Since 2.30 373 * Params: 374 * error = A GError. [transfer full] 375 */ 376 public void takeError(ErrorG error) 377 { 378 // void g_dbus_method_invocation_take_error (GDBusMethodInvocation *invocation, GError *error); 379 g_dbus_method_invocation_take_error(gDBusMethodInvocation, (error is null) ? null : error.getErrorGStruct()); 380 } 381 382 /** 383 * Like g_dbus_method_invocation_return_value() but also takes a GUnixFDList. 384 * This method is only available on UNIX. 385 * This method will free invocation, you cannot use it afterwards. 386 * Since 2.30 387 * Params: 388 * parameters = A GVariant tuple with out parameters for the method or NULL if not passing any parameters. [allow-none] 389 * fdList = A GUnixFDList or NULL. [allow-none] 390 */ 391 public void returnValueWithUnixFdList(Variant parameters, UnixFDList fdList) 392 { 393 // void g_dbus_method_invocation_return_value_with_unix_fd_list (GDBusMethodInvocation *invocation, GVariant *parameters, GUnixFDList *fd_list); 394 g_dbus_method_invocation_return_value_with_unix_fd_list(gDBusMethodInvocation, (parameters is null) ? null : parameters.getVariantStruct(), (fdList is null) ? null : fdList.getUnixFDListStruct()); 395 } 396 }