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 private import gobject.ObjectG; 63 64 private import gobject.Signals; 65 public import gtkc.gdktypes; 66 67 private import gio.Credentials; 68 private import gio.IOStream; 69 70 71 72 private import gobject.ObjectG; 73 74 /** 75 * Description 76 * The GDBusAuthObserver type provides a mechanism for participating 77 * in how a GDBusServer (or a GDBusConnection) authenticates remote 78 * peers. Simply instantiate a GDBusAuthObserver and connect to the 79 * signals you are interested in. Note that new signals may be added 80 * in the future 81 * For example, if you only want to allow D-Bus connections from 82 * processes owned by the same uid as the server, you would use a 83 * signal handler like the following: 84 * $(DDOC_COMMENT example) 85 */ 86 public class DBusAuthObserver : ObjectG 87 { 88 89 /** the main Gtk struct */ 90 protected GDBusAuthObserver* gDBusAuthObserver; 91 92 93 public GDBusAuthObserver* getDBusAuthObserverStruct() 94 { 95 return gDBusAuthObserver; 96 } 97 98 99 /** the main Gtk struct as a void* */ 100 protected override void* getStruct() 101 { 102 return cast(void*)gDBusAuthObserver; 103 } 104 105 /** 106 * Sets our main struct and passes it to the parent class 107 */ 108 public this (GDBusAuthObserver* gDBusAuthObserver) 109 { 110 super(cast(GObject*)gDBusAuthObserver); 111 this.gDBusAuthObserver = gDBusAuthObserver; 112 } 113 114 protected override void setStruct(GObject* obj) 115 { 116 super.setStruct(obj); 117 gDBusAuthObserver = cast(GDBusAuthObserver*)obj; 118 } 119 120 /** 121 */ 122 int[string] connectedSignals; 123 124 bool delegate(IOStream, Credentials, DBusAuthObserver)[] onAuthorizeAuthenticatedPeerListeners; 125 /** 126 * Emitted to check if a peer that is successfully authenticated 127 * is authorized. 128 * TRUE if the peer is authorized, FALSE if not. 129 * Since 2.26 130 */ 131 void addOnAuthorizeAuthenticatedPeer(bool delegate(IOStream, Credentials, DBusAuthObserver) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 132 { 133 if ( !("authorize-authenticated-peer" in connectedSignals) ) 134 { 135 Signals.connectData( 136 getStruct(), 137 "authorize-authenticated-peer", 138 cast(GCallback)&callBackAuthorizeAuthenticatedPeer, 139 cast(void*)this, 140 null, 141 connectFlags); 142 connectedSignals["authorize-authenticated-peer"] = 1; 143 } 144 onAuthorizeAuthenticatedPeerListeners ~= dlg; 145 } 146 extern(C) static gboolean callBackAuthorizeAuthenticatedPeer(GDBusAuthObserver* observerStruct, GIOStream* stream, GCredentials* credentials, DBusAuthObserver _dBusAuthObserver) 147 { 148 foreach ( bool delegate(IOStream, Credentials, DBusAuthObserver) dlg ; _dBusAuthObserver.onAuthorizeAuthenticatedPeerListeners ) 149 { 150 if ( dlg(ObjectG.getDObject!(IOStream)(stream), ObjectG.getDObject!(Credentials)(credentials), _dBusAuthObserver) ) 151 { 152 return 1; 153 } 154 } 155 156 return 0; 157 } 158 159 160 /** 161 * Creates a new GDBusAuthObserver object. 162 * Since 2.26 163 * Throws: ConstructionException GTK+ fails to create the object. 164 */ 165 public this () 166 { 167 // GDBusAuthObserver * g_dbus_auth_observer_new (void); 168 auto p = g_dbus_auth_observer_new(); 169 if(p is null) 170 { 171 throw new ConstructionException("null returned by g_dbus_auth_observer_new()"); 172 } 173 this(cast(GDBusAuthObserver*) p); 174 } 175 176 /** 177 * Emits the "authorize-authenticated-peer" signal on observer. 178 * Since 2.26 179 * Signal Details 180 * The "authorize-authenticated-peer" signal 181 * gboolean user_function (GDBusAuthObserver *observer, 182 * GIOStream *stream, 183 * GCredentials *credentials, 184 * gpointer user_data) : Run Last 185 * Emitted to check if a peer that is successfully authenticated 186 * is authorized. 187 * Since 2.26 188 * Params: 189 * stream = A GIOStream for the GDBusConnection. 190 * credentials = Credentials received from the peer or NULL. 191 * stream = A GIOStream for the GDBusConnection. 192 * credentials = Credentials received from the peer or NULL. 193 * Returns: TRUE if the peer is authorized, FALSE if not.Returns: TRUE if the peer is authorized, FALSE if not. 194 */ 195 public int authorizeAuthenticatedPeer(IOStream stream, Credentials credentials) 196 { 197 // gboolean g_dbus_auth_observer_authorize_authenticated_peer (GDBusAuthObserver *observer, GIOStream *stream, GCredentials *credentials); 198 return g_dbus_auth_observer_authorize_authenticated_peer(gDBusAuthObserver, (stream is null) ? null : stream.getIOStreamStruct(), (credentials is null) ? null : credentials.getCredentialsStruct()); 199 } 200 }