From 903d2a98e745f4bcb4c924715416d6527ae80cf6 Mon Sep 17 00:00:00 2001 From: David Rousselie Date: Tue, 31 Jul 2007 16:27:34 +0200 Subject: [PATCH] bare jid is used as unicode string darcs-hash:20070731142734-86b55-ee4e0ec6b1395dc699c599de87133cebfef08df6.gz --- src/jcl/jabber/__init__.py | 4 ++-- src/jcl/jabber/component.py | 10 +++++----- src/jcl/jabber/disco.py | 4 ++-- src/jcl/jabber/message.py | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/jcl/jabber/__init__.py b/src/jcl/jabber/__init__.py index a2f80b0..b64e03f 100644 --- a/src/jcl/jabber/__init__.py +++ b/src/jcl/jabber/__init__.py @@ -52,7 +52,7 @@ def get_account_filter(self, stanza, lang_class, node=None): """Filter stanzas sent to account jid, only if account exists""" name = stanza.get_to().node if name is not None: - return account.get_account(stanza.get_from().bare(), + return account.get_account(unicode(stanza.get_from().bare()), name) else: return None @@ -61,7 +61,7 @@ def get_accounts_root_filter(self, stanza, lang_class, node=None): """Filter stanza sent to root node""" to_jid = stanza.get_to() if to_jid.resource is None and to_jid.node is None and node is None: - return account.get_accounts(stanza.get_from().bare()) + return account.get_accounts(unicode(stanza.get_from().bare())) else: return None diff --git a/src/jcl/jabber/component.py b/src/jcl/jabber/component.py index d4f7e09..6c13ffa 100644 --- a/src/jcl/jabber/component.py +++ b/src/jcl/jabber/component.py @@ -432,7 +432,7 @@ class JCLComponent(Component, object): remove = info_query.xpath_eval("r:query/r:remove", {"r" : "jabber:iq:register"}) if remove: - result = self.account_manager.remove_all_accounts(from_jid.bare()) + result = self.account_manager.remove_all_accounts(unicode(from_jid.bare())) self.send_stanzas(result) return 1 @@ -607,7 +607,7 @@ class AccountManager(object): info_query = info_query.make_result_response() account_class = self.get_account_class(account_type) model.db_connect() - _account = account.get_account(from_jid.bare(), name, account_class) + _account = account.get_account(unicode(from_jid.bare()), name, account_class) if _account is not None: query = info_query.new_query("jabber:iq:register") model.db_disconnect() @@ -706,7 +706,7 @@ class AccountManager(object): value = None setattr(_account, field, field_post_func(value, field_default_func, - from_jid.bare())) + unicode(from_jid.bare()))) if first_account: # component subscribe user presence when registering the first @@ -740,7 +740,7 @@ class AccountManager(object): x_data): """Update account""" self.__logger.debug("Updating account " + account_name) - bare_from_jid = from_jid.bare() + bare_from_jid = unicode(from_jid.bare()) _account = account.get_account(bare_from_jid, account_name) if _account is not None: @@ -761,7 +761,7 @@ class AccountManager(object): lang_class, x_data): """Create new account from account_class""" - bare_from_jid = from_jid.bare() + bare_from_jid = unicode(from_jid.bare()) first_account = (account.get_accounts_count(bare_from_jid) == 0) model.db_connect() _account = account_class(user_jid=unicode(bare_from_jid), diff --git a/src/jcl/jabber/disco.py b/src/jcl/jabber/disco.py index 5b2cce3..9ef54f8 100644 --- a/src/jcl/jabber/disco.py +++ b/src/jcl/jabber/disco.py @@ -113,7 +113,7 @@ class RootDiscoGetItemsHandler(DiscoHandler): else: disco_items = DiscoItems() for (_account, resource, account_type) in \ - self.component.account_manager.list_accounts(from_jid.bare()): + self.component.account_manager.list_accounts(unicode(from_jid.bare())): DiscoItem(disco_items, JID(unicode(_account.jid) + resource), account_type + _account.name, @@ -137,7 +137,7 @@ class AccountTypeDiscoGetItemsHandler(DiscoHandler): if account_class is not None: disco_items = DiscoItems() for (_account, resource, account_type) in \ - self.component.account_manager.list_accounts(from_jid.bare(), + self.component.account_manager.list_accounts(unicode(from_jid.bare()), account_class, account_type=account_type): DiscoItem(disco_items, diff --git a/src/jcl/jabber/message.py b/src/jcl/jabber/message.py index 9075a2c..068f61d 100644 --- a/src/jcl/jabber/message.py +++ b/src/jcl/jabber/message.py @@ -39,7 +39,7 @@ class PasswordMessageHandler(Handler): Return the uniq account associated with a name and user JID. DB connection might already be opened. """ - _account = account.get_account(stanza.get_from().bare(), + _account = account.get_account(unicode(stanza.get_from().bare()), stanza.get_to().node) if hasattr(_account, 'password') \ and hasattr(_account, 'waiting_password_reply') \