/usr/include/d/gtkd-3/gio/DBusAuthObserver.d is in libgtkd-3-dev 3.7.5-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | /*
* This file is part of gtkD.
*
* gtkD is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version, with
* some exceptions, please read the COPYING file.
*
* gtkD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with gtkD; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*/
// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage
module gio.DBusAuthObserver;
private import gio.Credentials;
private import gio.IOStream;
private import gio.c.functions;
public import gio.c.types;
private import glib.ConstructionException;
private import glib.Str;
private import gobject.ObjectG;
private import gobject.Signals;
public import gtkc.giotypes;
private import std.algorithm;
/**
* The #GDBusAuthObserver type provides a mechanism for participating
* in how a #GDBusServer (or a #GDBusConnection) authenticates remote
* peers. Simply instantiate a #GDBusAuthObserver and connect to the
* signals you are interested in. Note that new signals may be added
* in the future
*
* ## Controlling Authentication # {#auth-observer}
*
* For example, if you only want to allow D-Bus connections from
* processes owned by the same uid as the server, you would use a
* signal handler like the following:
*
* |[<!-- language="C" -->
* static gboolean
* on_authorize_authenticated_peer (GDBusAuthObserver *observer,
* GIOStream *stream,
* GCredentials *credentials,
* gpointer user_data)
* {
* gboolean authorized;
*
* authorized = FALSE;
* if (credentials != NULL)
* {
* GCredentials *own_credentials;
* own_credentials = g_credentials_new ();
* if (g_credentials_is_same_user (credentials, own_credentials, NULL))
* authorized = TRUE;
* g_object_unref (own_credentials);
* }
*
* return authorized;
* }
* ]|
*
* Since: 2.26
*/
public class DBusAuthObserver : ObjectG
{
/** the main Gtk struct */
protected GDBusAuthObserver* gDBusAuthObserver;
/** Get the main Gtk struct */
public GDBusAuthObserver* getDBusAuthObserverStruct(bool transferOwnership = false)
{
if (transferOwnership)
ownedRef = false;
return gDBusAuthObserver;
}
/** the main Gtk struct as a void* */
protected override void* getStruct()
{
return cast(void*)gDBusAuthObserver;
}
protected override void setStruct(GObject* obj)
{
gDBusAuthObserver = cast(GDBusAuthObserver*)obj;
super.setStruct(obj);
}
/**
* Sets our main struct and passes it to the parent class.
*/
public this (GDBusAuthObserver* gDBusAuthObserver, bool ownedRef = false)
{
this.gDBusAuthObserver = gDBusAuthObserver;
super(cast(GObject*)gDBusAuthObserver, ownedRef);
}
/** */
public static GType getType()
{
return g_dbus_auth_observer_get_type();
}
/**
* Creates a new #GDBusAuthObserver object.
*
* Returns: A #GDBusAuthObserver. Free with g_object_unref().
*
* Since: 2.26
*
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this()
{
auto p = g_dbus_auth_observer_new();
if(p is null)
{
throw new ConstructionException("null returned by new");
}
this(cast(GDBusAuthObserver*) p, true);
}
/**
* Emits the #GDBusAuthObserver::allow-mechanism signal on @observer.
*
* Params:
* mechanism = The name of the mechanism, e.g. `DBUS_COOKIE_SHA1`.
*
* Returns: %TRUE if @mechanism can be used to authenticate the other peer, %FALSE if not.
*
* Since: 2.34
*/
public bool allowMechanism(string mechanism)
{
return g_dbus_auth_observer_allow_mechanism(gDBusAuthObserver, Str.toStringz(mechanism)) != 0;
}
/**
* Emits the #GDBusAuthObserver::authorize-authenticated-peer signal on @observer.
*
* Params:
* stream = A #GIOStream for the #GDBusConnection.
* credentials = Credentials received from the peer or %NULL.
*
* Returns: %TRUE if the peer is authorized, %FALSE if not.
*
* Since: 2.26
*/
public bool authorizeAuthenticatedPeer(IOStream stream, Credentials credentials)
{
return g_dbus_auth_observer_authorize_authenticated_peer(gDBusAuthObserver, (stream is null) ? null : stream.getIOStreamStruct(), (credentials is null) ? null : credentials.getCredentialsStruct()) != 0;
}
protected class OnAllowMechanismDelegateWrapper
{
bool delegate(string, DBusAuthObserver) dlg;
gulong handlerId;
this(bool delegate(string, DBusAuthObserver) dlg)
{
this.dlg = dlg;
onAllowMechanismListeners ~= this;
}
void remove(OnAllowMechanismDelegateWrapper source)
{
foreach(index, wrapper; onAllowMechanismListeners)
{
if (wrapper.handlerId == source.handlerId)
{
onAllowMechanismListeners[index] = null;
onAllowMechanismListeners = std.algorithm.remove(onAllowMechanismListeners, index);
break;
}
}
}
}
OnAllowMechanismDelegateWrapper[] onAllowMechanismListeners;
/**
* Emitted to check if @mechanism is allowed to be used.
*
* Params:
* mechanism = The name of the mechanism, e.g. `DBUS_COOKIE_SHA1`.
*
* Returns: %TRUE if @mechanism can be used to authenticate the other peer, %FALSE if not.
*
* Since: 2.34
*/
gulong addOnAllowMechanism(bool delegate(string, DBusAuthObserver) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
auto wrapper = new OnAllowMechanismDelegateWrapper(dlg);
wrapper.handlerId = Signals.connectData(
this,
"allow-mechanism",
cast(GCallback)&callBackAllowMechanism,
cast(void*)wrapper,
cast(GClosureNotify)&callBackAllowMechanismDestroy,
connectFlags);
return wrapper.handlerId;
}
extern(C) static int callBackAllowMechanism(GDBusAuthObserver* dbusauthobserverStruct, char* mechanism, OnAllowMechanismDelegateWrapper wrapper)
{
return wrapper.dlg(Str.toString(mechanism), wrapper.outer);
}
extern(C) static void callBackAllowMechanismDestroy(OnAllowMechanismDelegateWrapper wrapper, GClosure* closure)
{
wrapper.remove(wrapper);
}
protected class OnAuthorizeAuthenticatedPeerDelegateWrapper
{
bool delegate(IOStream, Credentials, DBusAuthObserver) dlg;
gulong handlerId;
this(bool delegate(IOStream, Credentials, DBusAuthObserver) dlg)
{
this.dlg = dlg;
onAuthorizeAuthenticatedPeerListeners ~= this;
}
void remove(OnAuthorizeAuthenticatedPeerDelegateWrapper source)
{
foreach(index, wrapper; onAuthorizeAuthenticatedPeerListeners)
{
if (wrapper.handlerId == source.handlerId)
{
onAuthorizeAuthenticatedPeerListeners[index] = null;
onAuthorizeAuthenticatedPeerListeners = std.algorithm.remove(onAuthorizeAuthenticatedPeerListeners, index);
break;
}
}
}
}
OnAuthorizeAuthenticatedPeerDelegateWrapper[] onAuthorizeAuthenticatedPeerListeners;
/**
* Emitted to check if a peer that is successfully authenticated
* is authorized.
*
* Params:
* stream = A #GIOStream for the #GDBusConnection.
* credentials = Credentials received from the peer or %NULL.
*
* Returns: %TRUE if the peer is authorized, %FALSE if not.
*
* Since: 2.26
*/
gulong addOnAuthorizeAuthenticatedPeer(bool delegate(IOStream, Credentials, DBusAuthObserver) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
auto wrapper = new OnAuthorizeAuthenticatedPeerDelegateWrapper(dlg);
wrapper.handlerId = Signals.connectData(
this,
"authorize-authenticated-peer",
cast(GCallback)&callBackAuthorizeAuthenticatedPeer,
cast(void*)wrapper,
cast(GClosureNotify)&callBackAuthorizeAuthenticatedPeerDestroy,
connectFlags);
return wrapper.handlerId;
}
extern(C) static int callBackAuthorizeAuthenticatedPeer(GDBusAuthObserver* dbusauthobserverStruct, GIOStream* stream, GCredentials* credentials, OnAuthorizeAuthenticatedPeerDelegateWrapper wrapper)
{
return wrapper.dlg(ObjectG.getDObject!(IOStream)(stream), ObjectG.getDObject!(Credentials)(credentials), wrapper.outer);
}
extern(C) static void callBackAuthorizeAuthenticatedPeerDestroy(OnAuthorizeAuthenticatedPeerDelegateWrapper wrapper, GClosure* closure)
{
wrapper.remove(wrapper);
}
}
|