From e3f109cbce68418e0d022513c5c1680d44d860ab Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Wed, 20 Aug 2008 00:36:52 +0200 Subject: [PATCH] Added parameters to control jabber priority namely, priority_available and priority_away. The old, default "priority" parameter now works for all other states. That means "invisible". Signed-off-by: Michael Krelin --- src/conn-presence.c | 8 ++++++++ src/gabble-connection-manager.c | 16 ++++++++++++++++ src/gabble-connection.c | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 1 deletions(-) diff --git a/src/conn-presence.c b/src/conn-presence.c index 5021189..fd01360 100644 --- a/src/conn-presence.c +++ b/src/conn-presence.c @@ -222,6 +222,14 @@ set_own_status_cb (GObject *obj, } prio = CLAMP (g_value_get_int (priority), G_MININT8, G_MAXINT8); } + else + { + g_object_get(conn, + (i==GABBLE_PRESENCE_AVAILABLE)? "priority-available" + : (i==GABBLE_PRESENCE_AWAY)? "priority-away" : "priority", + &prio, + NULL); + } if (gabble_presence_update (conn->self_presence, resource, i, status, prio)) diff --git a/src/gabble-connection-manager.c b/src/gabble-connection-manager.c index ab2585c..8af4611 100644 --- a/src/gabble-connection-manager.c +++ b/src/gabble-connection-manager.c @@ -79,6 +79,8 @@ struct _GabbleParams { gchar *alias; gchar *auth_mac; gchar *auth_btid; + gint priority_available; + gint priority_away; }; enum { @@ -100,6 +102,8 @@ enum { JABBER_PARAM_ALIAS, JABBER_PARAM_AUTH_MAC, JABBER_PARAM_AUTH_BTID, + JABBER_PARAM_PRIORITY_AVAILABLE, + JABBER_PARAM_PRIORITY_AWAY, LAST_JABBER_PARAM }; @@ -184,6 +188,14 @@ static const TpCMParamSpec jabber_params[] = { { "btid", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, 0, NULL, G_STRUCT_OFFSET(GabbleParams, auth_btid), NULL, NULL }, + { "priority-available", DBUS_TYPE_INT16_AS_STRING, G_TYPE_INT, + TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GINT_TO_POINTER(30), + G_STRUCT_OFFSET(GabbleParams, priority_available), NULL, NULL }, + + { "priority-away", DBUS_TYPE_INT16_AS_STRING, G_TYPE_INT, + TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GINT_TO_POINTER(15), + G_STRUCT_OFFSET(GabbleParams, priority_away), NULL, NULL }, + { NULL, NULL, 0, 0, NULL, 0 } }; @@ -272,6 +284,10 @@ _gabble_connection_manager_new_connection (TpBaseConnectionManager *self, params->auth_mac); SET_PROPERTY_IF_PARAM_SET ("auth-btid", JABBER_PARAM_AUTH_BTID, params->auth_btid); + SET_PROPERTY_IF_PARAM_SET ("priority-available", JABBER_PARAM_PRIORITY_AVAILABLE, + (gint8) CLAMP (params->priority_available, G_MININT8, G_MAXINT8)); + SET_PROPERTY_IF_PARAM_SET ("priority-away", JABBER_PARAM_PRIORITY_AWAY, + (gint8) CLAMP (params->priority_away, G_MININT8, G_MAXINT8)); /* split up account into username, stream-server and resource */ if (!_gabble_connection_set_properties_from_account (conn, params->account, diff --git a/src/gabble-connection.c b/src/gabble-connection.c index acf1678..fa17ae9 100644 --- a/src/gabble-connection.c +++ b/src/gabble-connection.c @@ -123,6 +123,8 @@ enum PROP_ALIAS, PROP_AUTH_MAC, PROP_AUTH_BTID, + PROP_PRIORITY_AVAILABLE, + PROP_PRIORITY_AWAY, LAST_PROPERTY }; @@ -167,6 +169,8 @@ struct _GabbleConnectionPrivate gchar *alias; gchar *auth_mac; gchar *auth_btid; + gint8 priority_available; + gint8 priority_away; /* reference to conference server name */ const gchar *conference_server; @@ -332,6 +336,12 @@ gabble_connection_get_property (GObject *object, case PROP_STUN_PORT: g_value_set_uint (value, priv->stun_port); break; + case PROP_PRIORITY_AVAILABLE: + g_value_set_char (value, priv->priority_available); + break; + case PROP_PRIORITY_AWAY: + g_value_set_char (value, priv->priority_away); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -416,6 +426,12 @@ gabble_connection_set_property (GObject *object, case PROP_STUN_PORT: priv->stun_port = g_value_get_uint (value); break; + case PROP_PRIORITY_AVAILABLE: + priv->priority_available = g_value_get_char (value); + break; + case PROP_PRIORITY_AWAY: + priv->priority_away = g_value_get_char (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -685,6 +701,22 @@ gabble_connection_class_init (GabbleConnectionClass *gabble_connection_class) G_PARAM_STATIC_BLURB); g_object_class_install_property (object_class, PROP_AUTH_BTID, param_spec); + param_spec = g_param_spec_char ("priority-available", "Jabber presence priority when available", + "The default priority used when reporting our presence in available state.", + G_MININT8, G_MAXINT8, 30, + G_PARAM_READWRITE | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_BLURB); + g_object_class_install_property (object_class, PROP_PRIORITY_AVAILABLE, param_spec); + + param_spec = g_param_spec_char ("priority-away", "Jabber presence priority when away", + "The default priority used when reporting our presence in away state.", + G_MININT8, G_MAXINT8, 15, + G_PARAM_READWRITE | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_BLURB); + g_object_class_install_property (object_class, PROP_PRIORITY_AWAY, param_spec); + conn_presence_class_init (gabble_connection_class); } @@ -1886,7 +1918,7 @@ connection_auth_cb (LmConnection *lmconn, /* set initial presence */ conn->self_presence = gabble_presence_new (); gabble_presence_update (conn->self_presence, priv->resource, - GABBLE_PRESENCE_AVAILABLE, NULL, priv->priority); + GABBLE_PRESENCE_AVAILABLE, NULL, priv->priority_available); /* set initial capabilities */ gabble_presence_set_capabilities (conn->self_presence, priv->resource, -- 1.5.2.4