diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2007-10-25 14:08:38 +0000 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2007-10-25 14:08:38 +0000 |
commit | 9a62be1d5659d6fd6518799ef2cfc9150f20eaf9 (patch) | |
tree | 64bd4ade6315543a15a03fc1ff76d165e82a79cf | |
parent | 3ae0d26551317feefbb48643f55c5d60fb370486 (diff) |
add a "host-name-fqdn" property to the bytestream-mananager so we use the host name from avahi_client_get_host_name_fqdn in OOB bytestreams
-rw-r--r-- | src/salut-bytestream-manager.c | 37 | ||||
-rw-r--r-- | src/salut-bytestream-manager.h | 3 | ||||
-rw-r--r-- | src/salut-connection.c | 7 |
3 files changed, 33 insertions, 14 deletions
diff --git a/src/salut-bytestream-manager.c b/src/salut-bytestream-manager.c index 37d7597a..4c1bb2dc 100644 --- a/src/salut-bytestream-manager.c +++ b/src/salut-bytestream-manager.c @@ -42,6 +42,7 @@ G_DEFINE_TYPE (SalutBytestreamManager, salut_bytestream_manager, G_TYPE_OBJECT) enum { PROP_CONNECTION = 1, + PROP_HOST_NAME_FQDN, LAST_PROPERTY }; @@ -54,6 +55,7 @@ struct _SalutBytestreamManagerPrivate SalutImManager *im_manager; SalutMucManager *muc_manager; SalutXmppConnectionManager *xmpp_connection_manager; + gchar *host_name_fqdn; gboolean dispose_has_run; }; @@ -439,6 +441,7 @@ salut_bytestream_manager_dispose (GObject *object) g_object_unref (priv->im_manager); g_object_unref (priv->muc_manager); g_object_unref (priv->xmpp_connection_manager); + g_free (priv->host_name_fqdn); if (G_OBJECT_CLASS (salut_bytestream_manager_parent_class)->dispose) G_OBJECT_CLASS (salut_bytestream_manager_parent_class)->dispose (object); @@ -459,6 +462,9 @@ salut_bytestream_manager_get_property (GObject *object, case PROP_CONNECTION: g_value_set_object (value, priv->connection); break; + case PROP_HOST_NAME_FQDN: + g_value_set_string (value, priv->host_name_fqdn); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -480,6 +486,10 @@ salut_bytestream_manager_set_property (GObject *object, case PROP_CONNECTION: priv->connection = g_value_get_object (value); break; + case PROP_HOST_NAME_FQDN: + g_free (priv->host_name_fqdn); + priv->host_name_fqdn = g_value_dup_string (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -545,16 +555,31 @@ salut_bytestream_manager_class_init ( G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB); g_object_class_install_property (object_class, PROP_CONNECTION, param_spec); + + param_spec = g_param_spec_string ( + "host-name-fqdn", + "host name FQDN", + "The FQDN host name that will be used by OOB bytestreams", + NULL, + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_READWRITE | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB); + g_object_class_install_property (object_class, PROP_HOST_NAME_FQDN, + param_spec); } SalutBytestreamManager * -salut_bytestream_manager_new (SalutConnection *conn) +salut_bytestream_manager_new (SalutConnection *conn, + const gchar *host_name_fqdn) { g_return_val_if_fail (SALUT_IS_CONNECTION (conn), NULL); return g_object_new ( SALUT_TYPE_BYTESTREAM_MANAGER, "connection", conn, + "host-name-fqdn", host_name_fqdn, NULL); } @@ -751,12 +776,6 @@ si_request_reply_cb (SalutXmppConnectionManager *manager, if (!tp_strdiff (stream_method, GIBBER_XMPP_NS_OOB)) { - gchar *host; - - /* FIXME: there is probably a better way to define this hostname. - * Using avahi and/or Salut API ? */ - host = g_strdup_printf ("%s.local", g_get_host_name ()); - /* Remote user have accepted the stream */ DEBUG ("remote user chose a OOB bytestream"); bytestream = g_object_new (GIBBER_TYPE_BYTESTREAM_OOB, @@ -766,10 +785,8 @@ si_request_reply_cb (SalutXmppConnectionManager *manager, "self-id", priv->connection->name, "peer-id", from, "stream-init-id", NULL, - "host", host, + "host", priv->host_name_fqdn, NULL); - - g_free (host); } else if (!tp_strdiff (stream_method, GIBBER_XMPP_NS_IBB)) { diff --git a/src/salut-bytestream-manager.h b/src/salut-bytestream-manager.h index a99f44c1..8dceae2e 100644 --- a/src/salut-bytestream-manager.h +++ b/src/salut-bytestream-manager.h @@ -67,7 +67,8 @@ typedef void (* SalutBytestreamManagerNegotiateReplyFunc) ( GibberXmppStanza *stanza, gpointer user_data); SalutBytestreamManager * -salut_bytestream_manager_new (SalutConnection *connection); +salut_bytestream_manager_new (SalutConnection *connection, + const gchar *host_name_fqdn); GibberXmppStanza * salut_bytestream_manager_make_stream_init_iq (const gchar *from, diff --git a/src/salut-connection.c b/src/salut-connection.c index b094e0c0..6dfe021f 100644 --- a/src/salut-connection.c +++ b/src/salut-connection.c @@ -847,6 +847,10 @@ _salut_avahi_client_running_cb(SalutAvahiClient *c, TP_CONNECTION_STATUS_DISCONNECTED, TP_CONNECTION_STATUS_REASON_NETWORK_ERROR); } + + /* Create the bytestream manager */ + priv->bytestream_manager = salut_bytestream_manager_new (self, + avahi_client_get_host_name_fqdn (priv->avahi_client->avahi_client)); } /* public functions */ @@ -2436,9 +2440,6 @@ salut_connection_create_channel_factories(TpBaseConnection *base) { priv->tubes_manager = salut_tubes_manager_new (self, priv->contact_manager); */ - /* Create the bytestream manager */ - priv->bytestream_manager = salut_bytestream_manager_new (self); - g_ptr_array_add(factories, priv->contact_manager); g_ptr_array_add(factories, priv->im_manager); g_ptr_array_add(factories, priv->muc_manager); |