summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2012-08-02 11:44:11 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2012-08-02 11:44:11 +0100
commit83be5b433f7927f49e2d87d262ded4bbfdbb2e8f (patch)
tree38a5874fc04a60eae547f4126a94b052305292f9
parent952349de572a794428011753630c5827a2c454d1 (diff)
tubes: use guint64s for all tube IDs
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--src/muc-channel.c34
-rw-r--r--src/tube-dbus.c10
-rw-r--r--src/tube-dbus.h2
-rw-r--r--src/tube-iface.c2
-rw-r--r--src/tube-stream.c14
-rw-r--r--src/tube-stream.h2
-rw-r--r--src/tubes-manager.c29
7 files changed, 45 insertions, 48 deletions
diff --git a/src/muc-channel.c b/src/muc-channel.c
index 270732d5..a408a056 100644
--- a/src/muc-channel.c
+++ b/src/muc-channel.c
@@ -135,7 +135,7 @@ static SalutTubeIface * create_new_tube (SalutMucChannel *self,
TpHandle initiator,
const gchar *service,
GHashTable *parameters,
- guint tube_id,
+ guint64 tube_id,
guint portnum,
WockyStanza *iq_req,
gboolean requested);
@@ -1488,7 +1488,7 @@ publish_tube_in_node (SalutMucChannel *self,
GHashTable *parameters;
TpTubeType type;
gchar *service, *id_str;
- guint tube_id;
+ guint64 tube_id;
TpHandle initiator_handle;
g_object_get (tube,
@@ -1499,7 +1499,7 @@ publish_tube_in_node (SalutMucChannel *self,
"id", &tube_id,
NULL);
- id_str = g_strdup_printf ("%u", tube_id);
+ id_str = g_strdup_printf ("%" G_GUINT64_FORMAT, tube_id);
wocky_node_set_attribute (node, "service", service);
wocky_node_set_attribute (node, "id", id_str);
@@ -1650,7 +1650,7 @@ tube_closed_cb (SalutTubeIface *tube,
SalutMucChannel *self)
{
SalutMucChannelPrivate *priv = self->priv;
- guint id;
+ guint64 id;
g_object_get (tube,
"id", &id,
@@ -1671,7 +1671,7 @@ generate_tube_id (SalutMucChannel *self)
/* probably totally overkill */
do
{
- out = g_random_int_range (0, G_MAXINT);
+ out = g_random_int_range (1, G_MAXINT32);
}
while (g_hash_table_lookup (priv->tubes,
GUINT_TO_POINTER (out)) != NULL);
@@ -1685,7 +1685,7 @@ create_new_tube (SalutMucChannel *self,
TpHandle initiator,
const gchar *service,
GHashTable *parameters,
- guint tube_id,
+ guint64 tube_id,
guint portnum,
WockyStanza *iq_req,
gboolean requested)
@@ -1717,7 +1717,7 @@ create_new_tube (SalutMucChannel *self,
tp_base_channel_register ((TpBaseChannel *) tube);
- DEBUG ("create tube %u", tube_id);
+ DEBUG ("create tube %" G_GUINT64_FORMAT, tube_id);
g_hash_table_insert (priv->tubes, GUINT_TO_POINTER (tube_id), tube);
g_signal_connect (tube, "tube-opened", G_CALLBACK (tube_opened_cb), self);
@@ -1735,7 +1735,7 @@ salut_muc_channel_tube_request (SalutMucChannel *self,
const gchar *channel_type;
const gchar *service;
GHashTable *parameters = NULL;
- guint tube_id;
+ guint64 tube_id;
TpTubeType type;
tube_id = generate_tube_id (self);
@@ -1805,10 +1805,8 @@ salut_muc_channel_bytestream_offered (SalutMucChannel *self,
SalutMucChannelPrivate *priv = self->priv;
WockyNode *node = wocky_stanza_get_top_node (msg);
const gchar *stream_id, *tmp;
- gchar *endptr;
WockyNode *si_node, *stream_node;
- guint tube_id;
- unsigned long tube_id_tmp;
+ guint64 tube_id;
SalutTubeIface *tube;
WockyStanzaType type;
WockyStanzaSubType sub_type;
@@ -1841,17 +1839,16 @@ salut_muc_channel_bytestream_offered (SalutMucChannel *self,
gibber_bytestream_iface_close (bytestream, &e);
return;
}
- tube_id_tmp = strtoul (tmp, &endptr, 10);
- if (!endptr || *endptr || tube_id_tmp > G_MAXUINT32)
+ tube_id = g_ascii_strtoull (tmp, NULL, 10);
+ if (tube_id == 0 || tube_id > G_MAXUINT32)
{
GError e = { WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST,
- "<muc-stream> tube attribute not numeric or > 2**32" };
+ "<muc-stream> tube attribute is non-numeric or out of range" };
- DEBUG ("tube id is not numeric or > 2**32: %s", tmp);
+ DEBUG ("tube id is non-numeric or out of range: %s", tmp);
gibber_bytestream_iface_close (bytestream, &e);
return;
}
- tube_id = (guint) tube_id_tmp;
tube = g_hash_table_lookup (priv->tubes, GUINT_TO_POINTER (tube_id));
if (tube == NULL)
@@ -1860,12 +1857,13 @@ salut_muc_channel_bytestream_offered (SalutMucChannel *self,
"<muc-stream> tube attribute points to a nonexistent "
"tube" };
- DEBUG ("tube %u doesn't exist", tube_id);
+ DEBUG ("tube %" G_GUINT64_FORMAT " doesn't exist", tube_id);
gibber_bytestream_iface_close (bytestream, &e);
return;
}
- DEBUG ("received new bytestream request for existing tube: %u", tube_id);
+ DEBUG ("received new bytestream request for existing tube: %" G_GUINT64_FORMAT,
+ tube_id);
salut_tube_iface_add_bytestream (tube, bytestream);
}
diff --git a/src/tube-dbus.c b/src/tube-dbus.c
index 0d12086b..39686d2f 100644
--- a/src/tube-dbus.c
+++ b/src/tube-dbus.c
@@ -114,7 +114,7 @@ struct _SalutTubeDBusPrivate
{
TpHandle self_handle;
GibberMucConnection *muc_connection;
- guint id;
+ guint64 id;
GibberBytestreamIface *bytestream;
gchar *stream_id;
TpHandle initiator;
@@ -636,7 +636,7 @@ salut_tube_dbus_get_property (GObject *object,
g_value_set_object (value, priv->muc_connection);
break;
case PROP_ID:
- g_value_set_uint (value, priv->id);
+ g_value_set_uint64 (value, priv->id);
break;
case PROP_BYTESTREAM:
g_value_set_object (value, priv->bytestream);
@@ -693,7 +693,7 @@ salut_tube_dbus_set_property (GObject *object,
g_object_ref (priv->muc_connection);
break;
case PROP_ID:
- priv->id = g_value_get_uint (value);
+ priv->id = g_value_get_uint64 (value);
break;
case PROP_BYTESTREAM:
if (priv->bytestream == NULL)
@@ -868,7 +868,7 @@ salut_tube_dbus_get_object_path_suffix (TpBaseChannel *base)
SalutTubeDBus *self = SALUT_TUBE_DBUS (base);
SalutTubeDBusPrivate *priv = SALUT_TUBE_DBUS_GET_PRIVATE (self);
- return g_strdup_printf ("DBusTubeChannel/%u/%u",
+ return g_strdup_printf ("DBusTubeChannel/%u/%" G_GUINT64_FORMAT,
tp_base_channel_get_target_handle (base),
priv->id);
}
@@ -1307,7 +1307,7 @@ salut_tube_dbus_new (SalutConnection *conn,
TpHandle initiator,
const gchar *service,
GHashTable *parameters,
- guint id,
+ guint64 id,
gboolean requested)
{
SalutTubeDBus *tube;
diff --git a/src/tube-dbus.h b/src/tube-dbus.h
index 5e617cfc..71b43bb6 100644
--- a/src/tube-dbus.h
+++ b/src/tube-dbus.h
@@ -69,7 +69,7 @@ SalutTubeDBus *
salut_tube_dbus_new (SalutConnection *conn,
TpHandle handle, TpHandleType handle_type, TpHandle self_handle,
GibberMucConnection *muc_connection, TpHandle initiator,
- const gchar *service, GHashTable *parameters, guint id,
+ const gchar *service, GHashTable *parameters, guint64 id,
gboolean requested);
gboolean salut_tube_dbus_add_name (SalutTubeDBus *self, TpHandle handle,
diff --git a/src/tube-iface.c b/src/tube-iface.c
index 6978b074..56ad5e0c 100644
--- a/src/tube-iface.c
+++ b/src/tube-iface.c
@@ -130,7 +130,7 @@ salut_tube_iface_base_init (gpointer klass)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_interface_install_property (klass, param_spec);
- param_spec = g_param_spec_uint (
+ param_spec = g_param_spec_uint64 (
"id",
"id",
"The unique identifier of this tube",
diff --git a/src/tube-stream.c b/src/tube-stream.c
index 80fee7ea..ee501fe6 100644
--- a/src/tube-stream.c
+++ b/src/tube-stream.c
@@ -143,7 +143,7 @@ typedef struct _SalutTubeStreamPrivate SalutTubeStreamPrivate;
struct _SalutTubeStreamPrivate
{
TpHandle self_handle;
- guint id;
+ guint64 id;
guint port;
WockyStanza *iq_req;
@@ -526,7 +526,7 @@ start_stream_initiation (SalutTubeStream *self,
si_node = wocky_node_get_child_ns (msg_node, "si", WOCKY_XMPP_NS_SI);
g_assert (si_node != NULL);
- id_str = g_strdup_printf ("%u", priv->id);
+ id_str = g_strdup_printf ("%" G_GUINT64_FORMAT, priv->id);
g_assert (cls->target_handle_type == TP_HANDLE_TYPE_ROOM);
@@ -1096,7 +1096,7 @@ salut_tube_stream_get_property (GObject *object,
g_value_set_uint (value, priv->self_handle);
break;
case PROP_ID:
- g_value_set_uint (value, priv->id);
+ g_value_set_uint64 (value, priv->id);
break;
case PROP_TYPE:
g_value_set_uint (value, TP_TUBE_TYPE_STREAM);
@@ -1156,7 +1156,7 @@ salut_tube_stream_set_property (GObject *object,
priv->self_handle = g_value_get_uint (value);
break;
case PROP_ID:
- priv->id = g_value_get_uint (value);
+ priv->id = g_value_get_uint64 (value);
break;
case PROP_SERVICE:
g_free (priv->service);
@@ -1272,7 +1272,7 @@ salut_tube_stream_get_object_path_suffix (TpBaseChannel *base)
SalutTubeStream *self = SALUT_TUBE_STREAM (base);
SalutTubeStreamPrivate *priv = SALUT_TUBE_STREAM_GET_PRIVATE (self);
- return g_strdup_printf ("StreamTubeChannel/%u/%u",
+ return g_strdup_printf ("StreamTubeChannel/%u/%" G_GUINT64_FORMAT,
tp_base_channel_get_target_handle (base),
priv->id);
}
@@ -1518,7 +1518,7 @@ salut_tube_stream_new (SalutConnection *conn,
gboolean offered,
const gchar *service,
GHashTable *parameters,
- guint id,
+ guint64 id,
guint portnum,
WockyStanza *iq_req,
gboolean requested)
@@ -1758,7 +1758,7 @@ salut_tube_stream_close (SalutTubeIface *tube, gboolean closed_remotely)
SalutContact *contact;
jid_from = tp_handle_inspect (contact_repo, priv->self_handle);
- tube_id_str = g_strdup_printf ("%u", priv->id);
+ tube_id_str = g_strdup_printf ("%" G_GUINT64_FORMAT, priv->id);
g_object_get (conn, "contact-manager", &contact_mgr, NULL);
g_assert (contact_mgr != NULL);
diff --git a/src/tube-stream.h b/src/tube-stream.h
index 7c5f0f72..0594d20f 100644
--- a/src/tube-stream.h
+++ b/src/tube-stream.h
@@ -68,7 +68,7 @@ SalutTubeStream *salut_tube_stream_new (SalutConnection *conn,
TpHandle handle,
TpHandleType handle_type, TpHandle self_handle, TpHandle initiator,
gboolean offered, const gchar *service,
- GHashTable *parameters, guint id, guint portnum,
+ GHashTable *parameters, guint64 id, guint portnum,
WockyStanza *iq_req, gboolean requested);
gboolean salut_tube_stream_check_params (TpSocketAddressType address_type,
diff --git a/src/tubes-manager.c b/src/tubes-manager.c
index 778e11c5..597e12f4 100644
--- a/src/tubes-manager.c
+++ b/src/tubes-manager.c
@@ -62,7 +62,7 @@ static SalutTubeIface * create_new_tube (SalutTubesManager *self,
TpHandle handle,
const gchar *service,
GHashTable *parameters,
- guint tube_id,
+ guint64 tube_id,
guint portnum,
WockyStanza *iq_req);
@@ -125,7 +125,7 @@ extract_tube_information (TpHandleRepoIface *contact_repo,
TpHandle *initiator_handle,
const gchar **service,
GHashTable **parameters,
- guint *tube_id,
+ guint64 *tube_id,
guint *portnum,
GError **error)
{
@@ -191,8 +191,7 @@ extract_tube_information (TpHandleRepoIface *contact_repo,
if (tube_id != NULL)
{
const gchar *str;
- gchar *endptr;
- long int tmp;
+ guint64 tmp;
str = wocky_node_get_attribute (node, "id");
if (str == NULL)
@@ -202,14 +201,14 @@ extract_tube_information (TpHandleRepoIface *contact_repo,
return FALSE;
}
- tmp = strtol (str, &endptr, 10);
- if (!endptr || *endptr)
+ tmp = g_ascii_strtoull (str, NULL, 10);
+ if (tmp == 0 || tmp > G_MAXUINT32)
{
g_set_error (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT,
- "tube id is not numeric: %s", str);
+ "tube id is non-numeric or out of range: %s", str);
return FALSE;
}
- *tube_id = (int) tmp;
+ *tube_id = tmp;
}
/* next fields are not in the close stanza */
@@ -298,7 +297,7 @@ iq_tube_request_cb (WockyPorter *porter,
TpTubeType tube_type;
TpHandle initiator_handle;
GHashTable *parameters;
- guint tube_id;
+ guint64 tube_id;
guint portnum = 0;
gboolean close_;
GError *error = NULL;
@@ -326,7 +325,7 @@ iq_tube_request_cb (WockyPorter *porter,
return TRUE;
}
- DEBUG ("received a tube request, tube id %d", tube_id);
+ DEBUG ("received a tube request, tube id %" G_GUINT64_FORMAT, tube_id);
chan = g_hash_table_lookup (priv->tubes,
GUINT_TO_POINTER (tube_id));
@@ -688,17 +687,17 @@ channel_closed_cb (SalutTubeIface *tube,
g_hash_table_remove (priv->tubes, GUINT_TO_POINTER (id));
}
-static guint
+static guint64
generate_tube_id (SalutTubesManager *self)
{
SalutTubesManagerPrivate *priv =
SALUT_TUBES_MANAGER_GET_PRIVATE (self);
- guint out;
+ guint64 out;
/* probably totally overkill */
do
{
- out = g_random_int_range (0, G_MAXINT);
+ out = g_random_int_range (1, G_MAXINT32);
}
while (g_hash_table_lookup (priv->tubes,
GUINT_TO_POINTER (out)) != NULL);
@@ -712,7 +711,7 @@ create_new_tube (SalutTubesManager *self,
TpHandle handle,
const gchar *service,
GHashTable *parameters,
- guint tube_id,
+ guint64 tube_id,
guint portnum,
WockyStanza *iq_req)
{
@@ -759,7 +758,7 @@ new_channel_from_request (SalutTubesManager *self,
TpTubeType type;
const gchar *ctype, *service;
TpHandle handle;
- guint tube_id;
+ guint64 tube_id;
GHashTable *parameters;
ctype = tp_asv_get_string (request, TP_PROP_CHANNEL_CHANNEL_TYPE);