[telepathy-mission-control/master] McdAccount: don't allow setting RequestedPresence to unset, unknown or error
Simon McVittie
simon.mcvittie at collabora.co.uk
Thu Jun 25 10:27:28 PDT 2009
These make no sense to set on yourself.
---
src/mcd-account.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/src/mcd-account.c b/src/mcd-account.c
index 631ed3b..af2df9e 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -1092,6 +1092,21 @@ get_parameters (TpSvcDBusProperties *self, const gchar *name, GValue *value)
}
static gboolean
+_presence_type_is_settable (TpConnectionPresenceType type)
+{
+ switch (type)
+ {
+ case TP_CONNECTION_PRESENCE_TYPE_UNSET:
+ case TP_CONNECTION_PRESENCE_TYPE_UNKNOWN:
+ case TP_CONNECTION_PRESENCE_TYPE_ERROR:
+ return FALSE;
+
+ default:
+ return TRUE;
+ }
+}
+
+static gboolean
_presence_type_is_online (TpConnectionPresenceType type)
{
switch (type)
@@ -1347,6 +1362,13 @@ set_requested_presence (TpSvcDBusProperties *self,
status = g_value_get_string (va->values + 1);
message = g_value_get_string (va->values + 2);
+ if (!_presence_type_is_settable (type))
+ {
+ g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
+ "RequestedPresence %d cannot be set on yourself", type);
+ return FALSE;
+ }
+
DEBUG ("setting requested presence: %d, %s, %s", type, status, message);
if (mcd_account_request_presence_int (account, type, status, message))
--
1.5.6.5
More information about the telepathy-commits
mailing list