X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgdbusauthobserver.c;h=23e7f3179d6fb0a9a7cfd678d41b09672fb961fe;hb=634b69219979c084837c59874e5b2aec01a1d3e4;hp=ff9482113d93e7abb12671fd2f9c41e97e4c8a73;hpb=94b907134426e26393a86630dae5ce53baee6ae6;p=platform%2Fupstream%2Fglib.git
diff --git a/gio/gdbusauthobserver.c b/gio/gdbusauthobserver.c
index ff94821..23e7f31 100644
--- a/gio/gdbusauthobserver.c
+++ b/gio/gdbusauthobserver.c
@@ -13,9 +13,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see .
*
* Author: David Zeuthen
*/
@@ -23,7 +21,6 @@
#include "config.h"
#include "gdbusauthobserver.h"
-#include "gio-marshal.h"
#include "gcredentials.h"
#include "gioenumtypes.h"
#include "giostream.h"
@@ -42,10 +39,13 @@
* 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:
- * Controlling Authentication
+ *
+ * |[
* static gboolean
* on_authorize_authenticated_peer (GDBusAuthObserver *observer,
* GIOStream *stream,
@@ -66,7 +66,7 @@
*
* return authorized;
* }
- *
+ * ]|
*/
typedef struct _GDBusAuthObserverClass GDBusAuthObserverClass;
@@ -90,6 +90,9 @@ struct _GDBusAuthObserverClass
gboolean (*authorize_authenticated_peer) (GDBusAuthObserver *observer,
GIOStream *stream,
GCredentials *credentials);
+
+ gboolean (*allow_mechanism) (GDBusAuthObserver *observer,
+ const gchar *mechanism);
};
/**
@@ -108,6 +111,7 @@ struct _GDBusAuthObserver
enum
{
AUTHORIZE_AUTHENTICATED_PEER_SIGNAL,
+ ALLOW_MECHANISM_SIGNAL,
LAST_SIGNAL,
};
@@ -131,6 +135,13 @@ g_dbus_auth_observer_authorize_authenticated_peer_real (GDBusAuthObserver *obse
return TRUE;
}
+static gboolean
+g_dbus_auth_observer_allow_mechanism_real (GDBusAuthObserver *observer,
+ const gchar *mechanism)
+{
+ return TRUE;
+}
+
static void
g_dbus_auth_observer_class_init (GDBusAuthObserverClass *klass)
{
@@ -139,12 +150,13 @@ g_dbus_auth_observer_class_init (GDBusAuthObserverClass *klass)
gobject_class->finalize = g_dbus_auth_observer_finalize;
klass->authorize_authenticated_peer = g_dbus_auth_observer_authorize_authenticated_peer_real;
+ klass->allow_mechanism = g_dbus_auth_observer_allow_mechanism_real;
/**
* GDBusAuthObserver::authorize-authenticated-peer:
* @observer: The #GDBusAuthObserver emitting the signal.
* @stream: A #GIOStream for the #GDBusConnection.
- * @credentials: Credentials received from the peer or %NULL.
+ * @credentials: (allow-none): Credentials received from the peer or %NULL.
*
* Emitted to check if a peer that is successfully authenticated
* is authorized.
@@ -160,11 +172,34 @@ g_dbus_auth_observer_class_init (GDBusAuthObserverClass *klass)
G_STRUCT_OFFSET (GDBusAuthObserverClass, authorize_authenticated_peer),
_g_signal_accumulator_false_handled,
NULL, /* accu_data */
- _gio_marshal_BOOLEAN__OBJECT_OBJECT,
+ NULL,
G_TYPE_BOOLEAN,
2,
G_TYPE_IO_STREAM,
G_TYPE_CREDENTIALS);
+
+ /**
+ * GDBusAuthObserver::allow-mechanism:
+ * @observer: The #GDBusAuthObserver emitting the signal.
+ * @mechanism: The name of the mechanism, e.g. `DBUS_COOKIE_SHA1`.
+ *
+ * Emitted to check if @mechanism is allowed to be used.
+ *
+ * Returns: %TRUE if @mechanism can be used to authenticate the other peer, %FALSE if not.
+ *
+ * Since: 2.34
+ */
+ signals[ALLOW_MECHANISM_SIGNAL] =
+ g_signal_new ("allow-mechanism",
+ G_TYPE_DBUS_AUTH_OBSERVER,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GDBusAuthObserverClass, allow_mechanism),
+ _g_signal_accumulator_false_handled,
+ NULL, /* accu_data */
+ NULL,
+ G_TYPE_BOOLEAN,
+ 1,
+ G_TYPE_STRING);
}
static void
@@ -193,7 +228,7 @@ g_dbus_auth_observer_new (void)
* g_dbus_auth_observer_authorize_authenticated_peer:
* @observer: A #GDBusAuthObserver.
* @stream: A #GIOStream for the #GDBusConnection.
- * @credentials: Credentials received from the peer or %NULL.
+ * @credentials: (allow-none): Credentials received from the peer or %NULL.
*
* Emits the #GDBusAuthObserver::authorize-authenticated-peer signal on @observer.
*
@@ -217,3 +252,30 @@ g_dbus_auth_observer_authorize_authenticated_peer (GDBusAuthObserver *observer,
&denied);
return denied;
}
+
+/**
+ * g_dbus_auth_observer_allow_mechanism:
+ * @observer: A #GDBusAuthObserver.
+ * @mechanism: The name of the mechanism, e.g. `DBUS_COOKIE_SHA1`.
+ *
+ * Emits the #GDBusAuthObserver::allow-mechanism signal on @observer.
+ *
+ * Returns: %TRUE if @mechanism can be used to authenticate the other peer, %FALSE if not.
+ *
+ * Since: 2.34
+ */
+gboolean
+g_dbus_auth_observer_allow_mechanism (GDBusAuthObserver *observer,
+ const gchar *mechanism)
+{
+ gboolean ret;
+
+ ret = FALSE;
+ g_signal_emit (observer,
+ signals[ALLOW_MECHANISM_SIGNAL],
+ 0,
+ mechanism,
+ &ret);
+ return ret;
+}
+