[telepathy-gabble/master] Default resource to Telepathy.<random hex>
Will Thompson
will.thompson at collabora.co.uk
Tue May 12 11:01:26 PDT 2009
This prevents users who don't know what a resource is being confused
when Empathy and their N810 fight for control of foo at bar.com/Telepathy.
---
src/connection-manager.c | 3 +--
src/connection.c | 25 ++++++++++++++++++++++---
src/connection.h | 1 -
3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/src/connection-manager.c b/src/connection-manager.c
index 21fc865..a564760 100644
--- a/src/connection-manager.c
+++ b/src/connection-manager.c
@@ -122,8 +122,7 @@ static TpCMParamSpec jabber_params[] = {
/* FIXME: validate the server properly */
tp_cm_param_filter_string_nonempty, NULL },
- { "resource", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING,
- TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GABBLE_PARAMS_DEFAULT_RESOURCE,
+ { "resource", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, 0, NULL,
G_STRUCT_OFFSET(GabbleParams, resource),
/* FIXME: validate the resource according to the RFC */
tp_cm_param_filter_string_nonempty, NULL },
diff --git a/src/connection.c b/src/connection.c
index 866c8e3..ea783ff 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -75,6 +75,8 @@
static guint disco_reply_timeout = 5000;
+#define DEFAULT_RESOURCE_FORMAT "Telepathy.%x"
+
static void conn_service_iface_init (gpointer, gpointer);
static void capabilities_service_iface_init (gpointer, gpointer);
static void gabble_conn_contact_caps_iface_init (gpointer, gpointer);
@@ -313,6 +315,25 @@ gabble_connection_constructor (GType type,
}
static void
+gabble_connection_constructed (GObject *object)
+{
+ GabbleConnection *self = GABBLE_CONNECTION (object);
+ GabbleConnectionPrivate *priv = self->priv;
+ void (*chain_up)(GObject *) =
+ G_OBJECT_CLASS (gabble_connection_parent_class)->constructed;
+
+ if (chain_up != NULL)
+ chain_up (object);
+
+ if (priv->resource == NULL)
+ {
+ priv->resource = g_strdup_printf (DEFAULT_RESOURCE_FORMAT,
+ g_random_int ());
+ DEBUG ("defaulted resource to %s", priv->resource);
+ }
+}
+
+static void
gabble_connection_init (GabbleConnection *self)
{
GabbleConnectionPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
@@ -323,9 +344,6 @@ gabble_connection_init (GabbleConnection *self)
self->priv = priv;
self->lmconn = lm_connection_new (NULL);
- /* Set default parameters for optional parameters */
- priv->resource = g_strdup (GABBLE_PARAMS_DEFAULT_RESOURCE);
-
priv->caps_serial = 1;
}
@@ -605,6 +623,7 @@ gabble_connection_class_init (GabbleConnectionClass *gabble_connection_class)
object_class->get_property = gabble_connection_get_property;
object_class->set_property = gabble_connection_set_property;
object_class->constructor = gabble_connection_constructor;
+ object_class->constructed = gabble_connection_constructed;
parent_class->create_handle_repos = _gabble_connection_create_handle_repos;
parent_class->get_unique_connection_name = gabble_connection_get_unique_name;
diff --git a/src/connection.h b/src/connection.h
index 3e8ce41..f424559 100644
--- a/src/connection.h
+++ b/src/connection.h
@@ -39,7 +39,6 @@
G_BEGIN_DECLS
/* Default parameters for optional parameters */
-#define GABBLE_PARAMS_DEFAULT_RESOURCE "Telepathy"
#define GABBLE_PARAMS_DEFAULT_HTTPS_PROXY_PORT 443
#define GABBLE_PARAMS_DEFAULT_STUN_PORT 3478
#define GABBLE_PARAMS_DEFAULT_FALLBACK_STUN_SERVER "stun.collabora.co.uk"
--
1.5.6.5
More information about the telepathy-commits
mailing list