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