From 770ea5310987f89154b7cf14eed900bcecd0ca28 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Thu, 15 Dec 2011 21:28:09 +0100 Subject: [PATCH] bearer: fail connecting try if not allowed to connect --- src/mm-bearer.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/mm-bearer.c b/src/mm-bearer.c index 35621f09..6187d01c 100644 --- a/src/mm-bearer.c +++ b/src/mm-bearer.c @@ -83,6 +83,15 @@ handle_connect (MMBearer *self, GDBusMethodInvocation *invocation, const gchar *number) { + if (!self->priv->connection_allowed) { + g_dbus_method_invocation_return_error ( + invocation, + MM_CORE_ERROR, + MM_CORE_ERROR_WRONG_STATE, + "Not allowed to connect bearer"); + return TRUE; + } + if (MM_BEARER_GET_CLASS (self)->connect != NULL && MM_BEARER_GET_CLASS (self)->connect_finish != NULL) { MM_BEARER_GET_CLASS (self)->connect ( @@ -182,12 +191,20 @@ mm_bearer_get_path (MMBearer *self) void mm_bearer_set_connection_allowed (MMBearer *self) { + if (self->priv->connection_allowed) + return; + + mm_dbg ("Connection in bearer '%s' is allowed", self->priv->path); self->priv->connection_allowed = TRUE; } void mm_bearer_set_connection_forbidden (MMBearer *self) { + if (!self->priv->connection_allowed) + return; + + mm_dbg ("Connection in bearer '%s' is forbidden", self->priv->path); self->priv->connection_allowed = FALSE; /* TODO: possibly, force disconnection */ }