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 = GUnixConnection.html 27 * outPack = gio 28 * outFile = UnixConnection 29 * strct = GUnixConnection 30 * realStrct= 31 * ctorStrct= 32 * clss = UnixConnection 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - g_unix_connection_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.ErrorG 47 * - glib.GException 48 * - gio.AsyncResultIF 49 * - gio.Cancellable 50 * - gio.Credentials 51 * structWrap: 52 * - GAsyncResult* -> AsyncResultIF 53 * - GCancellable* -> Cancellable 54 * - GCredentials* -> Credentials 55 * module aliases: 56 * local aliases: 57 * overrides: 58 */ 59 60 module gio.UnixConnection; 61 62 public import gtkc.giotypes; 63 64 private import gtkc.gio; 65 private import glib.ConstructionException; 66 private import gobject.ObjectG; 67 68 69 private import glib.ErrorG; 70 private import glib.GException; 71 private import gio.AsyncResultIF; 72 private import gio.Cancellable; 73 private import gio.Credentials; 74 75 76 77 private import gio.SocketConnection; 78 79 /** 80 * This is the subclass of GSocketConnection that is created 81 * for UNIX domain sockets. 82 * 83 * It contains functions to do some of the UNIX socket specific 84 * functionality like passing file descriptors. 85 * 86 * Note that <gio/gunixconnection.h> belongs to 87 * the UNIX-specific GIO interfaces, thus you have to use the 88 * gio-unix-2.0.pc pkg-config file when using it. 89 */ 90 public class UnixConnection : SocketConnection 91 { 92 93 /** the main Gtk struct */ 94 protected GUnixConnection* gUnixConnection; 95 96 97 public GUnixConnection* getUnixConnectionStruct() 98 { 99 return gUnixConnection; 100 } 101 102 103 /** the main Gtk struct as a void* */ 104 protected override void* getStruct() 105 { 106 return cast(void*)gUnixConnection; 107 } 108 109 /** 110 * Sets our main struct and passes it to the parent class 111 */ 112 public this (GUnixConnection* gUnixConnection) 113 { 114 super(cast(GSocketConnection*)gUnixConnection); 115 this.gUnixConnection = gUnixConnection; 116 } 117 118 protected override void setStruct(GObject* obj) 119 { 120 super.setStruct(obj); 121 gUnixConnection = cast(GUnixConnection*)obj; 122 } 123 124 /** 125 */ 126 127 /** 128 * Receives a file descriptor from the sending end of the connection. 129 * The sending end has to call g_unix_connection_send_fd() for this 130 * to work. 131 * As well as reading the fd this also reads a single byte from the 132 * stream, as this is required for fd passing to work on some 133 * implementations. 134 * Since 2.22 135 * Params: 136 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 137 * Returns: a file descriptor on success, -1 on error. 138 * Throws: GException on failure. 139 */ 140 public int receiveFd(Cancellable cancellable) 141 { 142 // gint g_unix_connection_receive_fd (GUnixConnection *connection, GCancellable *cancellable, GError **error); 143 GError* err = null; 144 145 auto p = g_unix_connection_receive_fd(gUnixConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 146 147 if (err !is null) 148 { 149 throw new GException( new ErrorG(err) ); 150 } 151 152 return p; 153 } 154 155 /** 156 * Passes a file descriptor to the receiving side of the 157 * connection. The receiving end has to call g_unix_connection_receive_fd() 158 * to accept the file descriptor. 159 * As well as sending the fd this also writes a single byte to the 160 * stream, as this is required for fd passing to work on some 161 * implementations. 162 * Since 2.22 163 * Params: 164 * fd = a file descriptor 165 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 166 * Returns: a TRUE on success, NULL on error. 167 * Throws: GException on failure. 168 */ 169 public int sendFd(int fd, Cancellable cancellable) 170 { 171 // gboolean g_unix_connection_send_fd (GUnixConnection *connection, gint fd, GCancellable *cancellable, GError **error); 172 GError* err = null; 173 174 auto p = g_unix_connection_send_fd(gUnixConnection, fd, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 175 176 if (err !is null) 177 { 178 throw new GException( new ErrorG(err) ); 179 } 180 181 return p; 182 } 183 184 /** 185 * Receives credentials from the sending end of the connection. The 186 * sending end has to call g_unix_connection_send_credentials() (or 187 * similar) for this to work. 188 * As well as reading the credentials this also reads (and discards) a 189 * single byte from the stream, as this is required for credentials 190 * passing to work on some implementations. 191 * Other ways to exchange credentials with a foreign peer includes the 192 * GUnixCredentialsMessage type and g_socket_get_credentials() function. 193 * Since 2.26 194 * Params: 195 * cancellable = A GCancellable or NULL. [allow-none] 196 * Returns: Received credentials on success (free with g_object_unref()), NULL if error is set. [transfer full] 197 * Throws: GException on failure. 198 */ 199 public Credentials receiveCredentials(Cancellable cancellable) 200 { 201 // GCredentials * g_unix_connection_receive_credentials (GUnixConnection *connection, GCancellable *cancellable, GError **error); 202 GError* err = null; 203 204 auto p = g_unix_connection_receive_credentials(gUnixConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 205 206 if (err !is null) 207 { 208 throw new GException( new ErrorG(err) ); 209 } 210 211 212 if(p is null) 213 { 214 return null; 215 } 216 217 return ObjectG.getDObject!(Credentials)(cast(GCredentials*) p); 218 } 219 220 /** 221 * Asynchronously receive credentials. 222 * For more details, see g_unix_connection_receive_credentials() which is 223 * the synchronous version of this call. 224 * When the operation is finished, callback will be called. You can then call 225 * g_unix_connection_receive_credentials_finish() to get the result of the operation. 226 * Since 2.32 227 * Params: 228 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 229 * callback = a GAsyncReadyCallback to call when the request is satisfied. [scope async] 230 * userData = the data to pass to callback function. [closure] 231 */ 232 public void receiveCredentialsAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 233 { 234 // void g_unix_connection_receive_credentials_async (GUnixConnection *connection, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 235 g_unix_connection_receive_credentials_async(gUnixConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 236 } 237 238 /** 239 * Finishes an asynchronous receive credentials operation started with 240 * g_unix_connection_receive_credentials_async(). 241 * Since 2.32 242 * Params: 243 * result = a GAsyncResult. 244 * Returns: a GCredentials, or NULL on error. Free the returned object with g_object_unref(). [transfer full] 245 * Throws: GException on failure. 246 */ 247 public Credentials receiveCredentialsFinish(AsyncResultIF result) 248 { 249 // GCredentials * g_unix_connection_receive_credentials_finish (GUnixConnection *connection, GAsyncResult *result, GError **error); 250 GError* err = null; 251 252 auto p = g_unix_connection_receive_credentials_finish(gUnixConnection, (result is null) ? null : result.getAsyncResultTStruct(), &err); 253 254 if (err !is null) 255 { 256 throw new GException( new ErrorG(err) ); 257 } 258 259 260 if(p is null) 261 { 262 return null; 263 } 264 265 return ObjectG.getDObject!(Credentials)(cast(GCredentials*) p); 266 } 267 268 /** 269 * Passes the credentials of the current user the receiving side 270 * of the connection. The receiving end has to call 271 * g_unix_connection_receive_credentials() (or similar) to accept the 272 * credentials. 273 * As well as sending the credentials this also writes a single NUL 274 * byte to the stream, as this is required for credentials passing to 275 * work on some implementations. 276 * Other ways to exchange credentials with a foreign peer includes the 277 * GUnixCredentialsMessage type and g_socket_get_credentials() function. 278 * Since 2.26 279 * Params: 280 * cancellable = A GCancellable or NULL. [allow-none] 281 * Returns: TRUE on success, FALSE if error is set. 282 * Throws: GException on failure. 283 */ 284 public int sendCredentials(Cancellable cancellable) 285 { 286 // gboolean g_unix_connection_send_credentials (GUnixConnection *connection, GCancellable *cancellable, GError **error); 287 GError* err = null; 288 289 auto p = g_unix_connection_send_credentials(gUnixConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 290 291 if (err !is null) 292 { 293 throw new GException( new ErrorG(err) ); 294 } 295 296 return p; 297 } 298 299 /** 300 * Asynchronously send credentials. 301 * For more details, see g_unix_connection_send_credentials() which is 302 * the synchronous version of this call. 303 * When the operation is finished, callback will be called. You can then call 304 * g_unix_connection_send_credentials_finish() to get the result of the operation. 305 * Since 2.32 306 * Params: 307 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 308 * callback = a GAsyncReadyCallback to call when the request is satisfied. [scope async] 309 * userData = the data to pass to callback function. [closure] 310 */ 311 public void sendCredentialsAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 312 { 313 // void g_unix_connection_send_credentials_async (GUnixConnection *connection, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 314 g_unix_connection_send_credentials_async(gUnixConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 315 } 316 317 /** 318 * Finishes an asynchronous send credentials operation started with 319 * g_unix_connection_send_credentials_async(). 320 * Since 2.32 321 * Params: 322 * result = a GAsyncResult. 323 * Returns: TRUE if the operation was successful, otherwise FALSE. 324 * Throws: GException on failure. 325 */ 326 public int sendCredentialsFinish(AsyncResultIF result) 327 { 328 // gboolean g_unix_connection_send_credentials_finish (GUnixConnection *connection, GAsyncResult *result, GError **error); 329 GError* err = null; 330 331 auto p = g_unix_connection_send_credentials_finish(gUnixConnection, (result is null) ? null : result.getAsyncResultTStruct(), &err); 332 333 if (err !is null) 334 { 335 throw new GException( new ErrorG(err) ); 336 } 337 338 return p; 339 } 340 }