1 // Generated by gmmproc 2.64.2 -- DO NOT MODIFY! 2 #ifndef _GIOMM_DBUSAUTHOBSERVER_H 3 #define _GIOMM_DBUSAUTHOBSERVER_H 4 5 6 #include <glibmm/ustring.h> 7 #include <sigc++/sigc++.h> 8 9 /* Copyright (C) 2010 The giomm Development Team 10 * 11 * This library is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 15 * 16 * This library is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 23 */ 24 25 #include <glibmm/object.h> 26 #include <giomm/credentials.h> 27 #include <giomm/iostream.h> 28 29 30 #ifndef DOXYGEN_SHOULD_SKIP_THIS 31 using GDBusAuthObserver = struct _GDBusAuthObserver; 32 using GDBusAuthObserverClass = struct _GDBusAuthObserverClass; 33 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 34 35 36 #ifndef DOXYGEN_SHOULD_SKIP_THIS 37 namespace Gio 38 { 39 40 namespace DBus 41 { class GIOMM_API AuthObserver_Class; } // namespace DBus 42 43 } // namespace Gio 44 #endif //DOXYGEN_SHOULD_SKIP_THIS 45 46 namespace Gio 47 { 48 49 namespace DBus 50 { 51 52 53 /** AuthObserver - An object used for authenticating connections. 54 * The AuthObserver type provides a mechanism for participating in how a 55 * Server (or a Connection) authenticates remote peers. Simply 56 * instantiate an AuthObserver and connect to the signals you are 57 * interested in. Note that new signals may be added in the future. 58 * 59 * For example, if you only want to allow D-Bus connections from 60 * processes owned by the same uid as the server, you would use a 61 * signal handler like the following: 62 * @code 63 * bool on_authorize_authenticated_peer( 64 * const Glib::RefPtr<const Gio::IOStream>&, 65 * const Glib::RefPtr<const Gio::Credentials>& credentials) 66 * { 67 * bool authorized = false; 68 * 69 * if (credentials) 70 * { 71 * Glib::RefPtr<Gio::Credentials> own_credentials = Gio::Credentials::create(); 72 * try 73 * { 74 * if (credentials->is_same_user(own_credentials)) 75 * authorized = true; 76 * } 77 * catch (const Gio::Error& ex) 78 * { 79 * std::cerr << "Gio::Error: " << ex.what() << std::endl; 80 * } 81 * } 82 * 83 * return authorized; 84 * } 85 * @endcode 86 * 87 * @newin{2,28} 88 * @ingroup DBus 89 */ 90 91 class GIOMM_API AuthObserver : public Glib::Object 92 { 93 94 #ifndef DOXYGEN_SHOULD_SKIP_THIS 95 96 public: 97 using CppObjectType = AuthObserver; 98 using CppClassType = AuthObserver_Class; 99 using BaseObjectType = GDBusAuthObserver; 100 using BaseClassType = GDBusAuthObserverClass; 101 102 // noncopyable 103 AuthObserver(const AuthObserver&) = delete; 104 AuthObserver& operator=(const AuthObserver&) = delete; 105 106 private: friend class AuthObserver_Class; 107 static CppClassType authobserver_class_; 108 109 protected: 110 explicit AuthObserver(const Glib::ConstructParams& construct_params); 111 explicit AuthObserver(GDBusAuthObserver* castitem); 112 113 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 114 115 public: 116 117 AuthObserver(AuthObserver&& src) noexcept; 118 AuthObserver& operator=(AuthObserver&& src) noexcept; 119 120 ~AuthObserver() noexcept override; 121 122 /** Get the GType for this class, for use with the underlying GObject type system. 123 */ 124 static GType get_type() G_GNUC_CONST; 125 126 #ifndef DOXYGEN_SHOULD_SKIP_THIS 127 128 129 static GType get_base_type() G_GNUC_CONST; 130 #endif 131 132 ///Provides access to the underlying C GObject. gobj()133 GDBusAuthObserver* gobj() { return reinterpret_cast<GDBusAuthObserver*>(gobject_); } 134 135 ///Provides access to the underlying C GObject. gobj()136 const GDBusAuthObserver* gobj() const { return reinterpret_cast<GDBusAuthObserver*>(gobject_); } 137 138 ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. 139 GDBusAuthObserver* gobj_copy(); 140 141 private: 142 143 144 protected: 145 AuthObserver(); 146 147 148 public: 149 150 static Glib::RefPtr<AuthObserver> create(); 151 152 153 /** Emits the DBusAuthObserver::signal_authorize_authenticated_peer() signal on @a observer. 154 * 155 * @newin{2,26} 156 * 157 * @param stream A IOStream for the DBusConnection. 158 * @param credentials Credentials received from the peer or <tt>nullptr</tt>. 159 * @return <tt>true</tt> if the peer is authorized, <tt>false</tt> if not. 160 */ 161 bool authorize_authenticated_peer(const Glib::RefPtr<const IOStream>& stream, const Glib::RefPtr<const Credentials>& credentials); 162 163 /** Emits the DBusAuthObserver::signal_allow_mechanism() signal on @a observer. 164 * 165 * @newin{2,34} 166 * 167 * @param mechanism The name of the mechanism, e.g. `DBUS_COOKIE_SHA1`. 168 * @return <tt>true</tt> if @a mechanism can be used to authenticate the other peer, <tt>false</tt> if not. 169 */ 170 bool allow_mechanism(const std::string& mechanism); 171 172 173 /** 174 * @par Slot Prototype: 175 * <tt>bool on_my_%authorize_authenticated_peer(const Glib::RefPtr<const IOStream>& stream, const Glib::RefPtr<const Credentials>& credentials)</tt> 176 * 177 * Flags: Run Last 178 * 179 * Emitted to check if a peer that is successfully authenticated 180 * is authorized. 181 * 182 * @newin{2,26} 183 * 184 * @param stream A IOStream for the DBusConnection. 185 * @param credentials Credentials received from the peer or <tt>nullptr</tt>. 186 * @return <tt>true</tt> if the peer is authorized, <tt>false</tt> if not. 187 */ 188 189 Glib::SignalProxy< bool,const Glib::RefPtr<const IOStream>&,const Glib::RefPtr<const Credentials>& > signal_authorize_authenticated_peer(); 190 191 192 /** 193 * @par Slot Prototype: 194 * <tt>bool on_my_%allow_mechanism(const std::string& mechanism)</tt> 195 * 196 * Flags: Run Last 197 * 198 * Emitted to check if @a mechanism is allowed to be used. 199 * 200 * @newin{2,34} 201 * 202 * @param mechanism The name of the mechanism, e.g. `DBUS_COOKIE_SHA1`. 203 * @return <tt>true</tt> if @a mechanism can be used to authenticate the other peer, <tt>false</tt> if not. 204 */ 205 206 Glib::SignalProxy< bool,const std::string& > signal_allow_mechanism(); 207 208 209 public: 210 211 public: 212 //C++ methods used to invoke GTK+ virtual functions: 213 214 protected: 215 //GTK+ Virtual Functions (override these to change behaviour): 216 217 //Default Signal Handlers:: 218 219 220 }; 221 222 } //namespace DBus 223 224 } // namespace Gio 225 226 227 namespace Glib 228 { 229 /** A Glib::wrap() method for this object. 230 * 231 * @param object The C instance. 232 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref. 233 * @result A C++ instance that wraps this C instance. 234 * 235 * @relates Gio::DBus::AuthObserver 236 */ 237 GIOMM_API 238 Glib::RefPtr<Gio::DBus::AuthObserver> wrap(GDBusAuthObserver* object, bool take_copy = false); 239 } 240 241 242 #endif /* _GIOMM_DBUSAUTHOBSERVER_H */ 243 244