| 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 = GDBusAuthObserver.html |
|---|
| 27 |
* outPack = gio |
|---|
| 28 |
* outFile = DBusAuthObserver |
|---|
| 29 |
* strct = GDBusAuthObserver |
|---|
| 30 |
* realStrct= |
|---|
| 31 |
* ctorStrct= |
|---|
| 32 |
* clss = DBusAuthObserver |
|---|
| 33 |
* interf = |
|---|
| 34 |
* class Code: No |
|---|
| 35 |
* interface Code: No |
|---|
| 36 |
* template for: |
|---|
| 37 |
* extend = |
|---|
| 38 |
* implements: |
|---|
| 39 |
* prefixes: |
|---|
| 40 |
* - g_dbus_auth_observer_ |
|---|
| 41 |
* omit structs: |
|---|
| 42 |
* omit prefixes: |
|---|
| 43 |
* omit code: |
|---|
| 44 |
* omit signals: |
|---|
| 45 |
* imports: |
|---|
| 46 |
* - gio.Credentials |
|---|
| 47 |
* - gio.IOStream |
|---|
| 48 |
* structWrap: |
|---|
| 49 |
* - GCredentials* -> Credentials |
|---|
| 50 |
* - GIOStream* -> IOStream |
|---|
| 51 |
* module aliases: |
|---|
| 52 |
* local aliases: |
|---|
| 53 |
* overrides: |
|---|
| 54 |
*/ |
|---|
| 55 |
|
|---|
| 56 |
module gio.DBusAuthObserver; |
|---|
| 57 |
|
|---|
| 58 |
public import gtkc.giotypes; |
|---|
| 59 |
|
|---|
| 60 |
private import gtkc.gio; |
|---|
| 61 |
private import glib.ConstructionException; |
|---|
| 62 |
|
|---|
| 63 |
private import gobject.Signals; |
|---|
| 64 |
public import gtkc.gdktypes; |
|---|
| 65 |
|
|---|
| 66 |
private import gio.Credentials; |
|---|
| 67 |
private import gio.IOStream; |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
private import gobject.ObjectG; |
|---|
| 72 |
|
|---|
| 73 |
/** |
|---|
| 74 |
* Description |
|---|
| 75 |
* The GDBusAuthObserver type provides a mechanism for participating |
|---|
| 76 |
* in how a GDBusServer (or a GDBusConnection) authenticates remote |
|---|
| 77 |
* peers. Simply instantiate a GDBusAuthObserver and connect to the |
|---|
| 78 |
* signals you are interested in. Note that new signals may be added |
|---|
| 79 |
* in the future |
|---|
| 80 |
* For example, if you only want to allow D-Bus connections from |
|---|
| 81 |
* processes owned by the same uid as the server, you would use a |
|---|
| 82 |
* signal handler like the following: |
|---|
| 83 |
* $(DDOC_COMMENT example) |
|---|
| 84 |
*/ |
|---|
| 85 |
public class DBusAuthObserver : ObjectG |
|---|
| 86 |
{ |
|---|
| 87 |
|
|---|
| 88 |
/** the main Gtk struct */ |
|---|
| 89 |
protected GDBusAuthObserver* gDBusAuthObserver; |
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
public GDBusAuthObserver* getDBusAuthObserverStruct() |
|---|
| 93 |
{ |
|---|
| 94 |
return gDBusAuthObserver; |
|---|
| 95 |
} |
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
/** the main Gtk struct as a void* */ |
|---|
| 99 |
protected override void* getStruct() |
|---|
| 100 |
{ |
|---|
| 101 |
return cast(void*)gDBusAuthObserver; |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|
| 104 |
/** |
|---|
| 105 |
* Sets our main struct and passes it to the parent class |
|---|
| 106 |
*/ |
|---|
| 107 |
public this (GDBusAuthObserver* gDBusAuthObserver) |
|---|
| 108 |
{ |
|---|
| 109 |
if(gDBusAuthObserver 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*)gDBusAuthObserver); |
|---|
| 116 |
if( ptr !is null ) |
|---|
| 117 |
{ |
|---|
| 118 |
this = cast(DBusAuthObserver)ptr; |
|---|
| 119 |
return; |
|---|
| 120 |
} |
|---|
| 121 |
super(cast(GObject*)gDBusAuthObserver); |
|---|
| 122 |
this.gDBusAuthObserver = gDBusAuthObserver; |
|---|
| 123 |
} |
|---|
| 124 |
|
|---|
| 125 |
protected override void setStruct(GObject* obj) |
|---|
| 126 |
{ |
|---|
| 127 |
super.setStruct(obj); |
|---|
| 128 |
gDBusAuthObserver = cast(GDBusAuthObserver*)obj; |
|---|
| 129 |
} |
|---|
| 130 |
|
|---|
| 131 |
/** |
|---|
| 132 |
*/ |
|---|
| 133 |
int[string] connectedSignals; |
|---|
| 134 |
|
|---|
| 135 |
bool delegate(IOStream, Credentials, DBusAuthObserver)[] onAuthorizeAuthenticatedPeerListeners; |
|---|
| 136 |
/** |
|---|
| 137 |
* Emitted to check if a peer that is successfully authenticated |
|---|
| 138 |
* is authorized. |
|---|
| 139 |
* TRUE if the peer is authorized, FALSE if not. |
|---|
| 140 |
* Since 2.26 |
|---|
| 141 |
*/ |
|---|
| 142 |
void addOnAuthorizeAuthenticatedPeer(bool delegate(IOStream, Credentials, DBusAuthObserver) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) |
|---|
| 143 |
{ |
|---|
| 144 |
if ( !("authorize-authenticated-peer" in connectedSignals) ) |
|---|
| 145 |
{ |
|---|
| 146 |
Signals.connectData( |
|---|
| 147 |
getStruct(), |
|---|
| 148 |
"authorize-authenticated-peer", |
|---|
| 149 |
cast(GCallback)&callBackAuthorizeAuthenticatedPeer, |
|---|
| 150 |
cast(void*)this, |
|---|
| 151 |
null, |
|---|
| 152 |
connectFlags); |
|---|
| 153 |
connectedSignals["authorize-authenticated-peer"] = 1; |
|---|
| 154 |
} |
|---|
| 155 |
onAuthorizeAuthenticatedPeerListeners ~= dlg; |
|---|
| 156 |
} |
|---|
| 157 |
extern(C) static gboolean callBackAuthorizeAuthenticatedPeer(GDBusAuthObserver* observerStruct, GIOStream* stream, GCredentials* credentials, DBusAuthObserver dBusAuthObserver) |
|---|
| 158 |
{ |
|---|
| 159 |
foreach ( bool delegate(IOStream, Credentials, DBusAuthObserver) dlg ; dBusAuthObserver.onAuthorizeAuthenticatedPeerListeners ) |
|---|
| 160 |
{ |
|---|
| 161 |
if ( dlg(new IOStream(stream), new Credentials(credentials), dBusAuthObserver) ) |
|---|
| 162 |
{ |
|---|
| 163 |
return 1; |
|---|
| 164 |
} |
|---|
| 165 |
} |
|---|
| 166 |
|
|---|
| 167 |
return 0; |
|---|
| 168 |
} |
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
/** |
|---|
| 172 |
* Creates a new GDBusAuthObserver object. |
|---|
| 173 |
* Since 2.26 |
|---|
| 174 |
* Throws: ConstructionException GTK+ fails to create the object. |
|---|
| 175 |
*/ |
|---|
| 176 |
public this () |
|---|
| 177 |
{ |
|---|
| 178 |
// GDBusAuthObserver * g_dbus_auth_observer_new (void); |
|---|
| 179 |
auto p = g_dbus_auth_observer_new(); |
|---|
| 180 |
if(p is null) |
|---|
| 181 |
{ |
|---|
| 182 |
throw new ConstructionException("null returned by g_dbus_auth_observer_new()"); |
|---|
| 183 |
} |
|---|
| 184 |
this(cast(GDBusAuthObserver*) p); |
|---|
| 185 |
} |
|---|
| 186 |
|
|---|
| 187 |
/** |
|---|
| 188 |
* Emits the "authorize-authenticated-peer" signal on observer. |
|---|
| 189 |
* Since 2.26 |
|---|
| 190 |
* Signal Details |
|---|
| 191 |
* The "authorize-authenticated-peer" signal |
|---|
| 192 |
* gboolean user_function (GDBusAuthObserver *observer, |
|---|
| 193 |
* GIOStream *stream, |
|---|
| 194 |
* GCredentials *credentials, |
|---|
| 195 |
* gpointer user_data) : Run Last |
|---|
| 196 |
* Emitted to check if a peer that is successfully authenticated |
|---|
| 197 |
* is authorized. |
|---|
| 198 |
* Since 2.26 |
|---|
| 199 |
* Params: |
|---|
| 200 |
* stream = A GIOStream for the GDBusConnection. |
|---|
| 201 |
* credentials = Credentials received from the peer or NULL. |
|---|
| 202 |
* stream = A GIOStream for the GDBusConnection. |
|---|
| 203 |
* credentials = Credentials received from the peer or NULL. |
|---|
| 204 |
* Returns: TRUE if the peer is authorized, FALSE if not.Returns: TRUE if the peer is authorized, FALSE if not. |
|---|
| 205 |
*/ |
|---|
| 206 |
public int authorizeAuthenticatedPeer(IOStream stream, Credentials credentials) |
|---|
| 207 |
{ |
|---|
| 208 |
// gboolean g_dbus_auth_observer_authorize_authenticated_peer (GDBusAuthObserver *observer, GIOStream *stream, GCredentials *credentials); |
|---|
| 209 |
return g_dbus_auth_observer_authorize_authenticated_peer(gDBusAuthObserver, (stream is null) ? null : stream.getIOStreamStruct(), (credentials is null) ? null : credentials.getCredentialsStruct()); |
|---|
| 210 |
} |
|---|
| 211 |
} |
|---|