tools: renamed tools.jid.JID attribute "short" to "bare"

This commit is contained in:
souliane 2013-10-29 16:26:55 +01:00
commit 36cea6fc91
3 changed files with 94 additions and 94 deletions

View file

@ -190,7 +190,7 @@ class Chat(urwid.WidgetWrap, QuickChat):
#We ignore click on our own nick
return
#we have a click on a nick, we add the private conversation to the contact_list
full_jid = JID("%s/%s" % (self.target.short, nick))
full_jid = JID("%s/%s" % (self.target.bare, nick))
new_jid = escapePrivate(full_jid)
if new_jid not in self.host.contact_list:
self.host.contact_list.add(new_jid)
@ -340,9 +340,9 @@ class Chat(urwid.WidgetWrap, QuickChat):
def onFileSelected(self, filepath):
self.host.removePopUp()
#FIXME: check last_resource: what if self.target.resource exists ?
last_resource = self.host.bridge.getLastResource(unicode(self.target.short), self.host.profile)
last_resource = self.host.bridge.getLastResource(unicode(self.target.bare), self.host.profile)
if last_resource:
full_jid = JID("%s/%s" % (self.target.short, last_resource))
full_jid = JID("%s/%s" % (self.target.bare, last_resource))
else:
full_jid = self.target
progress_id = self.host.bridge.sendFile(full_jid, filepath, {}, self.host.profile)

View file

@ -70,7 +70,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
def __contains__(self, jid):
for group in self.groups:
if jid.short in self.groups[group][1]:
if jid.bare in self.groups[group][1]:
return True
return False
@ -108,7 +108,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
def putAlert(self, jid):
"""Put an alert on the jid to get attention from user (e.g. for new message)"""
self.alert_jid.add(jid.short)
self.alert_jid.add(jid.bare)
self.update()
def __groupClicked(self, group_wid):
@ -153,7 +153,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
and not contact in self.alert_jid and contact != self.selected):
continue
show_icon, show_attr = const_SHOW_ICON.get(show,('','default'))
contact_disp = ('alert' if contact in self.alert_jid else show_attr, nick or name or jid.node or jid.short)
contact_disp = ('alert' if contact in self.alert_jid else show_attr, nick or name or jid.node or jid.bare)
display = [ show_icon + " " , contact_disp]
if self.show_status:
status_disp = ('status',"\n " + status) if status else ""
@ -180,7 +180,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
jid=JID(special)
name = self.getCache(jid, 'name')
nick = self.getCache(jid, 'nick')
special_disp = ('alert' if special in self.alert_jid else 'default', nick or name or jid.node or jid.short)
special_disp = ('alert' if special in self.alert_jid else 'default', nick or name or jid.node or jid.bare)
display = [ " " , special_disp]
header = '(*) ' if special in self.alert_jid else ''
widget = sat_widgets.SelectableText(display,
@ -233,7 +233,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
def replace(self, jid, groups=None, attributes=None):
"""add a contact to the list if doesn't exist, else update it"""
QuickContactList.replace(self, jid, groups, attributes)
if jid.short in self.specials:
if jid.bare in self.specials:
return
if not groups:
groups = [None]
@ -244,7 +244,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
for group in groups:
if not self.groups.has_key(group):
self.groups[group] = [True,set()] #[unfold,list_of_contacts]
self.groups[group][1].add(jid.short)
self.groups[group][1].add(jid.bare)
self.update()
def remove(self, jid):
@ -253,8 +253,8 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
groups_to_remove = []
for group in self.groups:
contacts = self.groups[group][1]
if jid.short in contacts:
contacts.remove(jid.short)
if jid.bare in contacts:
contacts.remove(jid.bare)
if not len(contacts):
groups_to_remove.append(group)
for group in groups_to_remove:
@ -275,7 +275,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
if None in self.groups:
folded, group_jids = self.groups[None]
for group_jid in group_jids:
if JID(group_jid).short == special_jid.short:
if JID(group_jid).bare == special_jid.bare:
group_jids.remove(group_jid)
break
self.update()
@ -286,5 +286,5 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
def updatePresence(self, jid, show, priority, statuses):
#XXX: for the moment, we ignore presence updates for special entities
if jid.short not in self.specials:
if jid.bare not in self.specials:
QuickContactList.updatePresence(self, jid, show, priority, statuses)

View file

@ -374,13 +374,13 @@ class PrimitivusApp(QuickApp, InputHistory):
def newMessage(self, from_jid, to_jid, msg, _type, extra, profile):
QuickApp.newMessage(self, from_jid, to_jid, msg, _type, extra, profile)
if not from_jid in self.contact_list and from_jid.short != self.profiles[profile]['whoami'].short:
if not from_jid in self.contact_list and from_jid.bare != self.profiles[profile]['whoami'].bare:
#XXX: needed to show entities which haven't sent any
# presence information and which are not in roster
#TODO: put these entities in a "not in roster" list
self.contact_list.replace(from_jid)
if JID(self.contact_list.selected).short != from_jid.short:
if JID(self.contact_list.selected).bare != from_jid.bare:
self.contact_list.putAlert(from_jid)
def _dialogOkCb(self, widget, data):
@ -518,7 +518,7 @@ class PrimitivusApp(QuickApp, InputHistory):
self.removePopUp()
jid=JID(edit.get_edit_text())
if jid.is_valid():
self.bridge.addContact(jid.short, profile_key=self.profile)
self.bridge.addContact(jid.bare, profile_key=self.profile)
else:
message = _("'%s' is an invalid JID !") % jid
error (message)
@ -623,7 +623,7 @@ class PrimitivusApp(QuickApp, InputHistory):
self.chat_wins[win].updateChatState(state)
return
from_bare = JID(from_jid_s).short
from_bare = JID(from_jid_s).bare
if from_bare in self.chat_wins:
self.chat_wins[from_bare].updateChatState(state)