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