summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2010-07-11 12:49:10 +0100
committerWill Thompson <will.thompson@collabora.co.uk>2010-07-11 12:49:13 +0100
commit57f31dac78ea87b5464133e88a4185cc3c2db44a (patch)
treea0064ebeeb73fe4a4aecb869671029a45cbcdae4
parentbdfeaa99b30b1e0ed89fe222edf4f0fbacb21494 (diff)
parent780b9193dfa8f601acde1ee4f6ffb753921d554a (diff)
Merge branch 'port-type'
Reviewed-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--src/connection-manager.c18
-rw-r--r--src/connection.c45
-rw-r--r--tests/twisted/connect/fail.py2
-rw-r--r--tests/twisted/connect/twice-to-same-account.py16
-rw-r--r--tests/twisted/hazetest.py4
5 files changed, 48 insertions, 37 deletions
diff --git a/src/connection-manager.c b/src/connection-manager.c
index c126d3d..b711fd3 100644
--- a/src/connection-manager.c
+++ b/src/connection-manager.c
@@ -266,8 +266,22 @@ _translate_protocol_option (PurpleAccountOption *option,
purple_account_option_get_default_bool (option));
break;
case PURPLE_PREF_INT:
- paramspec->dtype = DBUS_TYPE_INT32_AS_STRING;
- paramspec->gtype = G_TYPE_INT;
+ /* The spec decrees that ports should be uint16, and people get
+ * very upset if they're not. I suppose technically there could be
+ * int parameters whose names end in "port" which aren't meant to
+ * be unsigned?
+ */
+ if (g_str_has_suffix (name, "port"))
+ {
+ paramspec->dtype = DBUS_TYPE_UINT16_AS_STRING;
+ paramspec->gtype = G_TYPE_UINT;
+ }
+ else
+ {
+ paramspec->dtype = DBUS_TYPE_INT32_AS_STRING;
+ paramspec->gtype = G_TYPE_INT;
+ }
+
paramspec->flags |= TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT;
paramspec->def = GINT_TO_POINTER (
purple_account_option_get_default_int (option));
diff --git a/src/connection.c b/src/connection.c
index 93bbaec..7bcb2a2 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -312,35 +312,30 @@ set_option (
const PurpleAccountOption *option,
GHashTable *params)
{
- GValue *value = g_hash_table_lookup (params, option->pref_name);
+ if (g_hash_table_lookup (params, option->pref_name) == NULL)
+ return;
- if (!value)
- return;
-
- switch (option->type)
+ switch (option->type)
{
- case PURPLE_PREF_BOOLEAN:
- g_assert (G_VALUE_TYPE (value) == G_TYPE_BOOLEAN);
- purple_account_set_bool (account, option->pref_name,
- g_value_get_boolean (value));
- break;
- case PURPLE_PREF_INT:
- g_assert (G_VALUE_TYPE (value) == G_TYPE_INT);
- purple_account_set_int (account, option->pref_name,
- g_value_get_int (value));
- break;
- case PURPLE_PREF_STRING:
- case PURPLE_PREF_STRING_LIST:
- g_assert (G_VALUE_TYPE (value) == G_TYPE_STRING);
- purple_account_set_string (account, option->pref_name,
- g_value_get_string (value));
- break;
- default:
- g_warning ("option '%s' has unhandled type %u",
- option->pref_name, option->type);
+ case PURPLE_PREF_BOOLEAN:
+ purple_account_set_bool (account, option->pref_name,
+ tp_asv_get_boolean (params, option->pref_name, NULL));
+ break;
+ case PURPLE_PREF_INT:
+ purple_account_set_int (account, option->pref_name,
+ tp_asv_get_int32 (params, option->pref_name, NULL));
+ break;
+ case PURPLE_PREF_STRING:
+ case PURPLE_PREF_STRING_LIST:
+ purple_account_set_string (account, option->pref_name,
+ tp_asv_get_string (params, option->pref_name));
+ break;
+ default:
+ g_warning ("option '%s' has unhandled type %u",
+ option->pref_name, option->type);
}
- g_hash_table_remove (params, option->pref_name);
+ g_hash_table_remove (params, option->pref_name);
}
/**
diff --git a/tests/twisted/connect/fail.py b/tests/twisted/connect/fail.py
index 7edad57..5b676f0 100644
--- a/tests/twisted/connect/fail.py
+++ b/tests/twisted/connect/fail.py
@@ -13,5 +13,5 @@ def test(q, bus, conn, stream):
q.expect('dbus-signal', signal='StatusChanged', args=[2, 2])
if __name__ == '__main__':
- exec_test(test, {'port': dbus.Int32(4243)})
+ exec_test(test, {'port': dbus.UInt32(4243)})
diff --git a/tests/twisted/connect/twice-to-same-account.py b/tests/twisted/connect/twice-to-same-account.py
index ef008d2..fb2c25e 100644
--- a/tests/twisted/connect/twice-to-same-account.py
+++ b/tests/twisted/connect/twice-to-same-account.py
@@ -7,13 +7,17 @@ shortly afterwards.
import dbus
from hazetest import exec_test
-from servicetest import tp_name_prefix, tp_path_prefix
+from servicetest import (
+ tp_name_prefix, tp_path_prefix, assertEquals, EventPattern,
+ )
import constants as cs
def test(q, bus, conn, stream):
conn.Connect()
- q.expect('dbus-signal', signal='StatusChanged', args=[1, 1])
- q.expect('stream-authenticated')
+ q.expect_many(
+ EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]),
+ EventPattern('stream-authenticated'),
+ )
# FIXME: unlike Gabble, Haze does not signal a presence update to
# available during connect
@@ -31,16 +35,14 @@ def test(q, bus, conn, stream):
'account': 'test@localhost/Resource',
'password': 'pass',
'server': 'localhost',
- # FIXME: the spec says this is a UInt32 and Gabble agrees
- 'port': dbus.Int32(4242),
+ 'port': dbus.UInt32(4242),
}
# You might think that this is the test...
try:
cm_iface.RequestConnection('jabber', params)
except dbus.DBusException, e:
- # tp-glib <0.7.28 got the error domain wrong! :D
- assert e.get_dbus_name().endswith("NotAvailable")
+ assertEquals(cs.NOT_AVAILABLE, e.get_dbus_name())
# but you'd be wrong: we now test that Haze is still alive.
conn.Disconnect()
diff --git a/tests/twisted/hazetest.py b/tests/twisted/hazetest.py
index 080e450..90cbb32 100644
--- a/tests/twisted/hazetest.py
+++ b/tests/twisted/hazetest.py
@@ -279,10 +279,10 @@ def make_connection(bus, event_func, params=None):
default_params = {
'account': 'test@localhost/Resource',
'password': 'pass',
+ # FIXME: fd.o#14212
#'resource': 'Resource',
'server': 'localhost',
- # FIXME: the spec says this is a UInt32 and Gabble agrees
- 'port': dbus.Int32(4242),
+ 'port': dbus.UInt32(4242),
'require-encryption': False,
}