| 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.Cancellable |
|---|
| 49 |
* - gio.Credentials |
|---|
| 50 |
* structWrap: |
|---|
| 51 |
* - GCancellable* -> Cancellable |
|---|
| 52 |
* - GCredentials* -> Credentials |
|---|
| 53 |
* module aliases: |
|---|
| 54 |
* local aliases: |
|---|
| 55 |
* overrides: |
|---|
| 56 |
*/ |
|---|
| 57 |
|
|---|
| 58 |
module gio.UnixConnection; |
|---|
| 59 |
|
|---|
| 60 |
public import gtkc.giotypes; |
|---|
| 61 |
|
|---|
| 62 |
private import gtkc.gio; |
|---|
| 63 |
private import glib.ConstructionException; |
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
private import glib.ErrorG; |
|---|
| 67 |
private import glib.GException; |
|---|
| 68 |
private import gio.Cancellable; |
|---|
| 69 |
private import gio.Credentials; |
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
private import gio.SocketConnection; |
|---|
| 74 |
|
|---|
| 75 |
/** |
|---|
| 76 |
* Description |
|---|
| 77 |
* This is the subclass of GSocketConnection that is created |
|---|
| 78 |
* for UNIX domain sockets. |
|---|
| 79 |
* It contains functions to do some of the UNIX socket specific |
|---|
| 80 |
* functionality like passing file descriptors. |
|---|
| 81 |
* Note that <gio/gunixconnection.h> belongs to |
|---|
| 82 |
* the UNIX-specific GIO interfaces, thus you have to use the |
|---|
| 83 |
* gio-unix-2.0.pc pkg-config file when using it. |
|---|
| 84 |
*/ |
|---|
| 85 |
public class UnixConnection : SocketConnection |
|---|
| 86 |
{ |
|---|
| 87 |
|
|---|
| 88 |
/** the main Gtk struct */ |
|---|
| 89 |
protected GUnixConnection* gUnixConnection; |
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
public GUnixConnection* getUnixConnectionStruct() |
|---|
| 93 |
{ |
|---|
| 94 |
return gUnixConnection; |
|---|
| 95 |
} |
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
/** the main Gtk struct as a void* */ |
|---|
| 99 |
protected override void* getStruct() |
|---|
| 100 |
{ |
|---|
| 101 |
return cast(void*)gUnixConnection; |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|
| 104 |
/** |
|---|
| 105 |
* Sets our main struct and passes it to the parent class |
|---|
| 106 |
*/ |
|---|
| 107 |
public this (GUnixConnection* gUnixConnection) |
|---|
| 108 |
{ |
|---|
| 109 |
if(gUnixConnection is null) |
|---|
| 110 |
{ |
|---|
| 111 |
this = null; |
|---|
| 112 |
return; |
|---|
| 113 |
} |
|---|
| 114 |
//Check if there already is a D object for this gtk struct |
|---|
| 115 |
void* ptr = getDObject(cast(GObject*)gUnixConnection); |
|---|
| 116 |
if( ptr !is null ) |
|---|
| 117 |
{ |
|---|
| 118 |
this = cast(UnixConnection)ptr; |
|---|
| 119 |
return; |
|---|
| 120 |
} |
|---|
| 121 |
super(cast(GSocketConnection*)gUnixConnection); |
|---|
| 122 |
this.gUnixConnection = gUnixConnection; |
|---|
| 123 |
} |
|---|
| 124 |
|
|---|
| 125 |
protected override void setStruct(GObject* obj) |
|---|
| 126 |
{ |
|---|
| 127 |
super.setStruct(obj); |
|---|
| 128 |
gUnixConnection = cast(GUnixConnection*)obj; |
|---|
| 129 |
} |
|---|
| 130 |
|
|---|
| 131 |
/** |
|---|
| 132 |
*/ |
|---|
| 133 |
|
|---|
| 134 |
/** |
|---|
| 135 |
* Receives a file descriptor from the sending end of the connection. |
|---|
| 136 |
* The sending end has to call g_unix_connection_send_fd() for this |
|---|
| 137 |
* to work. |
|---|
| 138 |
* As well as reading the fd this also reads a single byte from the |
|---|
| 139 |
* stream, as this is required for fd passing to work on some |
|---|
| 140 |
* implementations. |
|---|
| 141 |
* Since 2.22 |
|---|
| 142 |
* Params: |
|---|
| 143 |
* cancellable = optional GCancellable object, NULL to ignore. [allow-none] |
|---|
| 144 |
* Returns: a file descriptor on success, -1 on error. |
|---|
| 145 |
* Throws: GException on failure. |
|---|
| 146 |
*/ |
|---|
| 147 |
public int receiveFd(Cancellable cancellable) |
|---|
| 148 |
{ |
|---|
| 149 |
// gint g_unix_connection_receive_fd (GUnixConnection *connection, GCancellable *cancellable, GError **error); |
|---|
| 150 |
GError* err = null; |
|---|
| 151 |
|
|---|
| 152 |
auto p = g_unix_connection_receive_fd(gUnixConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 153 |
|
|---|
| 154 |
if (err !is null) |
|---|
| 155 |
{ |
|---|
| 156 |
throw new GException( new ErrorG(err) ); |
|---|
| 157 |
} |
|---|
| 158 |
|
|---|
| 159 |
return p; |
|---|
| 160 |
} |
|---|
| 161 |
|
|---|
| 162 |
/** |
|---|
| 163 |
* Passes a file descriptor to the recieving side of the |
|---|
| 164 |
* connection. The recieving end has to call g_unix_connection_receive_fd() |
|---|
| 165 |
* to accept the file descriptor. |
|---|
| 166 |
* As well as sending the fd this also writes a single byte to the |
|---|
| 167 |
* stream, as this is required for fd passing to work on some |
|---|
| 168 |
* implementations. |
|---|
| 169 |
* Since 2.22 |
|---|
| 170 |
* Params: |
|---|
| 171 |
* fd = a file descriptor |
|---|
| 172 |
* cancellable = optional GCancellable object, NULL to ignore. [allow-none] |
|---|
| 173 |
* Returns: a TRUE on success, NULL on error. |
|---|
| 174 |
* Throws: GException on failure. |
|---|
| 175 |
*/ |
|---|
| 176 |
public int sendFd(int fd, Cancellable cancellable) |
|---|
| 177 |
{ |
|---|
| 178 |
// gboolean g_unix_connection_send_fd (GUnixConnection *connection, gint fd, GCancellable *cancellable, GError **error); |
|---|
| 179 |
GError* err = null; |
|---|
| 180 |
|
|---|
| 181 |
auto p = g_unix_connection_send_fd(gUnixConnection, fd, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 182 |
|
|---|
| 183 |
if (err !is null) |
|---|
| 184 |
{ |
|---|
| 185 |
throw new GException( new ErrorG(err) ); |
|---|
| 186 |
} |
|---|
| 187 |
|
|---|
| 188 |
return p; |
|---|
| 189 |
} |
|---|
| 190 |
|
|---|
| 191 |
/** |
|---|
| 192 |
* Receives credentials from the sending end of the connection. The |
|---|
| 193 |
* sending end has to call g_unix_connection_send_credentials() (or |
|---|
| 194 |
* similar) for this to work. |
|---|
| 195 |
* As well as reading the credentials this also reads (and discards) a |
|---|
| 196 |
* single byte from the stream, as this is required for credentials |
|---|
| 197 |
* passing to work on some implementations. |
|---|
| 198 |
* Other ways to exchange credentials with a foreign peer includes the |
|---|
| 199 |
* GUnixCredentialsMessage type and g_socket_get_credentials() function. |
|---|
| 200 |
* Since 2.26 |
|---|
| 201 |
* Params: |
|---|
| 202 |
* cancellable = A GCancellable or NULL. [allow-none] |
|---|
| 203 |
* Returns: Received credentials on success (free with g_object_unref()), NULL if error is set. [transfer full] |
|---|
| 204 |
* Throws: GException on failure. |
|---|
| 205 |
*/ |
|---|
| 206 |
public Credentials receiveCredentials(Cancellable cancellable) |
|---|
| 207 |
{ |
|---|
| 208 |
// GCredentials * g_unix_connection_receive_credentials (GUnixConnection *connection, GCancellable *cancellable, GError **error); |
|---|
| 209 |
GError* err = null; |
|---|
| 210 |
|
|---|
| 211 |
auto p = g_unix_connection_receive_credentials(gUnixConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 212 |
|
|---|
| 213 |
if (err !is null) |
|---|
| 214 |
{ |
|---|
| 215 |
throw new GException( new ErrorG(err) ); |
|---|
| 216 |
} |
|---|
| 217 |
|
|---|
| 218 |
if(p is null) |
|---|
| 219 |
{ |
|---|
| 220 |
return null; |
|---|
| 221 |
} |
|---|
| 222 |
return new Credentials(cast(GCredentials*) p); |
|---|
| 223 |
} |
|---|
| 224 |
|
|---|
| 225 |
/** |
|---|
| 226 |
* Passes the credentials of the current user the receiving side |
|---|
| 227 |
* of the connection. The recieving end has to call |
|---|
| 228 |
* g_unix_connection_receive_credentials() (or similar) to accept the |
|---|
| 229 |
* credentials. |
|---|
| 230 |
* As well as sending the credentials this also writes a single NUL |
|---|
| 231 |
* byte to the stream, as this is required for credentials passing to |
|---|
| 232 |
* work on some implementations. |
|---|
| 233 |
* Other ways to exchange credentials with a foreign peer includes the |
|---|
| 234 |
* GUnixCredentialsMessage type and g_socket_get_credentials() function. |
|---|
| 235 |
* Since 2.26 |
|---|
| 236 |
* Params: |
|---|
| 237 |
* cancellable = A GCancellable or NULL. [allow-none] |
|---|
| 238 |
* Returns: TRUE on success, FALSE if error is set. |
|---|
| 239 |
* Throws: GException on failure. |
|---|
| 240 |
*/ |
|---|
| 241 |
public int sendCredentials(Cancellable cancellable) |
|---|
| 242 |
{ |
|---|
| 243 |
// gboolean g_unix_connection_send_credentials (GUnixConnection *connection, GCancellable *cancellable, GError **error); |
|---|
| 244 |
GError* err = null; |
|---|
| 245 |
|
|---|
| 246 |
auto p = g_unix_connection_send_credentials(gUnixConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 247 |
|
|---|
| 248 |
if (err !is null) |
|---|
| 249 |
{ |
|---|
| 250 |
throw new GException( new ErrorG(err) ); |
|---|
| 251 |
} |
|---|
| 252 |
|
|---|
| 253 |
return p; |
|---|
| 254 |
} |
|---|
| 255 |
} |
|---|