[kupfer: 13/22] plugin.{gajim, pidgin}: Add user id as alias for contacts



commit a5fd30a4b227d69be5551ddb00d2ca38658aad37
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Thu Oct 29 15:36:59 2009 +0100

    plugin.{gajim,pidgin}: Add user id as alias for contacts
    
    This allows contacts to be matched both by name and by their user id.
    
    Launchpad bug https://bugs.launchpad.net/kupfer/+bug/462866

 kupfer/plugin/gajim.py  |    5 +++++
 kupfer/plugin/pidgin.py |    5 +++++
 2 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/plugin/gajim.py b/kupfer/plugin/gajim.py
index a1af001..ac55142 100644
--- a/kupfer/plugin/gajim.py
+++ b/kupfer/plugin/gajim.py
@@ -51,9 +51,14 @@ class GajimContact(Leaf):
 	""" Leaf represent single contact from Gajim """
 
 	def __init__(self, name, jid, account, status, resource):
+		# @obj should be unique for each contact
+		# we use @jid as an alias for this contact
 		obj = (account, jid)
 		Leaf.__init__(self, obj, name or jid)
 
+		if unicode(self) != jid:
+			self.name_aliases.add(jid)
+
 		self._description = _("[%(status)s] %(userid)s/%(service)s") % \
 				{
 					"status": _STATUSES.get(status, status),
diff --git a/kupfer/plugin/pidgin.py b/kupfer/plugin/pidgin.py
index 0a50f23..09710ab 100644
--- a/kupfer/plugin/pidgin.py
+++ b/kupfer/plugin/pidgin.py
@@ -86,9 +86,14 @@ class PidginContact(Leaf):
 
 	def __init__(self, jid, name, account, icon, protocol, available,
 		status_message):
+		# @obj should be unique for each contact
+		# we use @jid as an alias for this contact
 		obj = (account, jid)
 		Leaf.__init__(self, obj, name or jid)
 
+		if unicode(self) != jid:
+			self.name_aliases.add(jid)
+
 		self._description = _("[%(status)s] %(userid)s/%(service)s") % \
 				{
 					"status": _("Available") if available else _("Away"),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]