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.Variant 49 * - gio.DBusConnection 50 * - gio.DBusMessage 51 * structWrap: 52 * - GDBusConnection* -> DBusConnection 53 * - GDBusMessage* -> DBusMessage 54 * - GError* -> ErrorG 55 * - GVariant* -> Variant 56 * module aliases: 57 * local aliases: 58 * overrides: 59 */ 60 61 module gio.DBusMethodInvocation; 62 63 public import gtkc.giotypes; 64 65 private import gtkc.gio; 66 private import glib.ConstructionException; 67 private import gobject.ObjectG; 68 69 70 private import glib.Str; 71 private import glib.ErrorG; 72 private import glib.Variant; 73 private import gio.DBusConnection; 74 private import gio.DBusMessage; 75 76 77 78 private import gobject.ObjectG; 79 80 /** 81 * Description 82 * Instances of the GDBusMethodInvocation class are used when 83 * handling D-Bus method calls. It provides a way to asynchronously 84 * return results and errors. 85 * The normal way to obtain a GDBusMethodInvocation object is to receive 86 * it as an argument to the handle_method_call() function in a 87 * GDBusInterfaceVTable that was passed to g_dbus_connection_register_object(). 88 */ 89 public class DBusMethodInvocation : ObjectG 90 { 91 92 /** the main Gtk struct */ 93 protected GDBusMethodInvocation* gDBusMethodInvocation; 94 95 96 public GDBusMethodInvocation* getDBusMethodInvocationStruct() 97 { 98 return gDBusMethodInvocation; 99 } 100 101 102 /** the main Gtk struct as a void* */ 103 protected override void* getStruct() 104 { 105 return cast(void*)gDBusMethodInvocation; 106 } 107 108 /** 109 * Sets our main struct and passes it to the parent class 110 */ 111 public this (GDBusMethodInvocation* gDBusMethodInvocation) 112 { 113 super(cast(GObject*)gDBusMethodInvocation); 114 this.gDBusMethodInvocation = gDBusMethodInvocation; 115 } 116 117 protected override void setStruct(GObject* obj) 118 { 119 super.setStruct(obj); 120 gDBusMethodInvocation = cast(GDBusMethodInvocation*)obj; 121 } 122 123 /** 124 */ 125 126 /** 127 * Gets the bus name that invoked the method. 128 * Since 2.26 129 * Returns: A string. Do not free, it is owned by invocation. 130 */ 131 public string getSender() 132 { 133 // const gchar * g_dbus_method_invocation_get_sender (GDBusMethodInvocation *invocation); 134 return Str.toString(g_dbus_method_invocation_get_sender(gDBusMethodInvocation)); 135 } 136 137 /** 138 * Gets the object path the method was invoked on. 139 * Since 2.26 140 * Returns: A string. Do not free, it is owned by invocation. 141 */ 142 public string getObjectPath() 143 { 144 // const gchar * g_dbus_method_invocation_get_object_path (GDBusMethodInvocation *invocation); 145 return Str.toString(g_dbus_method_invocation_get_object_path(gDBusMethodInvocation)); 146 } 147 148 /** 149 * Gets the name of the D-Bus interface the method was invoked on. 150 * Since 2.26 151 * Returns: A string. Do not free, it is owned by invocation. 152 */ 153 public string getInterfaceName() 154 { 155 // const gchar * g_dbus_method_invocation_get_interface_name (GDBusMethodInvocation *invocation); 156 return Str.toString(g_dbus_method_invocation_get_interface_name(gDBusMethodInvocation)); 157 } 158 159 /** 160 * Gets the name of the method that was invoked. 161 * Since 2.26 162 * Returns: A string. Do not free, it is owned by invocation. 163 */ 164 public string getMethodName() 165 { 166 // const gchar * g_dbus_method_invocation_get_method_name (GDBusMethodInvocation *invocation); 167 return Str.toString(g_dbus_method_invocation_get_method_name(gDBusMethodInvocation)); 168 } 169 170 /** 171 * Gets information about the method call, if any. 172 * Since 2.26 173 * Returns: A GDBusMethodInfo or NULL. Do not free, it is owned by invocation. 174 */ 175 public GDBusMethodInfo* getMethodInfo() 176 { 177 // const GDBusMethodInfo * g_dbus_method_invocation_get_method_info (GDBusMethodInvocation *invocation); 178 return g_dbus_method_invocation_get_method_info(gDBusMethodInvocation); 179 } 180 181 /** 182 * Gets the GDBusConnection the method was invoked on. 183 * Since 2.26 184 * Returns: A GDBusConnection. Do not free, it is owned by invocation. [transfer none] 185 */ 186 public DBusConnection getConnection() 187 { 188 // GDBusConnection * g_dbus_method_invocation_get_connection (GDBusMethodInvocation *invocation); 189 auto p = g_dbus_method_invocation_get_connection(gDBusMethodInvocation); 190 191 if(p is null) 192 { 193 return null; 194 } 195 196 return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) p); 197 } 198 199 /** 200 * Gets the GDBusMessage for the method invocation. This is useful if 201 * you need to use low-level protocol features, such as UNIX file 202 * descriptor passing, that cannot be properly expressed in the 203 * GVariant API. 204 * See Example 2, “D-Bus server example” and Example 4, “D-Bus UNIX File Descriptor example” for an example of how to use this 205 * low-level API to send and receive UNIX file descriptors. 206 * Since 2.26 207 * Returns: GDBusMessage. Do not free, it is owned by invocation. [transfer none] 208 */ 209 public DBusMessage getMessage() 210 { 211 // GDBusMessage * g_dbus_method_invocation_get_message (GDBusMethodInvocation *invocation); 212 auto p = g_dbus_method_invocation_get_message(gDBusMethodInvocation); 213 214 if(p is null) 215 { 216 return null; 217 } 218 219 return ObjectG.getDObject!(DBusMessage)(cast(GDBusMessage*) p); 220 } 221 222 /** 223 * Gets the parameters of the method invocation. If there are no input 224 * parameters then this will return a GVariant with 0 children rather than NULL. 225 * Since 2.26 226 * Returns: A GVariant tuple. Do not unref this because it is owned by invocation. [transfer none] 227 */ 228 public Variant getParameters() 229 { 230 // GVariant * g_dbus_method_invocation_get_parameters (GDBusMethodInvocation *invocation); 231 auto p = g_dbus_method_invocation_get_parameters(gDBusMethodInvocation); 232 233 if(p is null) 234 { 235 return null; 236 } 237 238 return ObjectG.getDObject!(Variant)(cast(GVariant*) p); 239 } 240 241 /** 242 * Gets the user_data gpointer passed to g_dbus_connection_register_object(). 243 * Since 2.26 244 * Returns: A gpointer. 245 */ 246 public void* getUserData() 247 { 248 // gpointer g_dbus_method_invocation_get_user_data (GDBusMethodInvocation *invocation); 249 return g_dbus_method_invocation_get_user_data(gDBusMethodInvocation); 250 } 251 252 /** 253 * Finishes handling a D-Bus method call by returning parameters. 254 * If the parameters GVariant is floating, it is consumed. 255 * It is an error if parameters is not of the right format. 256 * This method will free invocation, you cannot use it afterwards. 257 * Since 2.26 258 * Params: 259 * parameters = A GVariant tuple with out parameters for the method or NULL if not passing any parameters. 260 */ 261 public void returnValue(Variant parameters) 262 { 263 // void g_dbus_method_invocation_return_value (GDBusMethodInvocation *invocation, GVariant *parameters); 264 g_dbus_method_invocation_return_value(gDBusMethodInvocation, (parameters is null) ? null : parameters.getVariantStruct()); 265 } 266 267 /** 268 * Like g_dbus_method_invocation_return_error() but intended for 269 * language bindings. 270 * This method will free invocation, you cannot use it afterwards. 271 * Since 2.26 272 * Params: 273 * domain = A GQuark for the GError error domain. 274 * code = The error code. 275 * format = printf()-style format. 276 * varArgs = va_list of parameters for format. 277 */ 278 public void returnErrorValist(GQuark domain, int code, string format, void* varArgs) 279 { 280 // void g_dbus_method_invocation_return_error_valist (GDBusMethodInvocation *invocation, GQuark domain, gint code, const gchar *format, va_list var_args); 281 g_dbus_method_invocation_return_error_valist(gDBusMethodInvocation, domain, code, Str.toStringz(format), varArgs); 282 } 283 284 /** 285 * Like g_dbus_method_invocation_return_error() but without printf()-style formatting. 286 * This method will free invocation, you cannot use it afterwards. 287 * Since 2.26 288 * Params: 289 * domain = A GQuark for the GError error domain. 290 * code = The error code. 291 * message = The error message. 292 */ 293 public void returnErrorLiteral(GQuark domain, int code, string message) 294 { 295 // void g_dbus_method_invocation_return_error_literal (GDBusMethodInvocation *invocation, GQuark domain, gint code, const gchar *message); 296 g_dbus_method_invocation_return_error_literal(gDBusMethodInvocation, domain, code, Str.toStringz(message)); 297 } 298 299 /** 300 * Like g_dbus_method_invocation_return_error() but takes a GError 301 * instead of the error domain, error code and message. 302 * This method will free invocation, you cannot use it afterwards. 303 * Since 2.26 304 * Params: 305 * error = A GError. 306 */ 307 public void returnGerror(ErrorG error) 308 { 309 // void g_dbus_method_invocation_return_gerror (GDBusMethodInvocation *invocation, const GError *error); 310 g_dbus_method_invocation_return_gerror(gDBusMethodInvocation, (error is null) ? null : error.getErrorGStruct()); 311 } 312 313 /** 314 * Finishes handling a D-Bus method call by returning an error. 315 * This method will free invocation, you cannot use it afterwards. 316 * Since 2.26 317 * Params: 318 * errorName = A valid D-Bus error name. 319 * errorMessage = A valid D-Bus error message. 320 */ 321 public void returnDbusError(string errorName, string errorMessage) 322 { 323 // void g_dbus_method_invocation_return_dbus_error (GDBusMethodInvocation *invocation, const gchar *error_name, const gchar *error_message); 324 g_dbus_method_invocation_return_dbus_error(gDBusMethodInvocation, Str.toStringz(errorName), Str.toStringz(errorMessage)); 325 } 326 }