Commit c7668719 authored by Luci Stanescu's avatar Luci Stanescu

Completed support for SIP aliases

parent 0b405f14
......@@ -159,6 +159,7 @@ class Contact(object):
self.name = name
self.uri = uri
self.image = image
self.sip_aliases = []
self.preferred_media = 'Audio'
self.status = 'unknown'
......@@ -169,7 +170,7 @@ class Contact(object):
return u'%s <%s>' % (self.name, self.uri) if self.name else self.uri
def __reduce__(self):
return (self.__class__, (self.group, self.name, self.uri, self.image), dict(preferred_media=self.preferred_media))
return (self.__class__, (self.group, self.name, self.uri, self.image), dict(preferred_media=self.preferred_media, sip_aliases=self.sip_aliases))
def _get_image(self):
return self.__dict__['image']
......@@ -1575,6 +1576,7 @@ class ContactEditorDialog(base_class, ui_class):
def open_for_add(self, sip_address=u'', target_group=None):
self.sip_address_editor.setText(sip_address)
self.display_name_editor.setText(u'')
self.sip_aliases_editor.setText(u'')
for index in xrange(self.group.count()):
if self.group.itemData(index).toPyObject() is target_group:
break
......@@ -1591,6 +1593,7 @@ class ContactEditorDialog(base_class, ui_class):
self.edited_contact = contact
self.sip_address_editor.setText(contact.uri)
self.display_name_editor.setText(contact.name)
self.sip_aliases_editor.setText(u'; '.join(contact.sip_aliases))
for index in xrange(self.group.count()):
if self.group.itemData(index).toPyObject() is contact.group:
break
......@@ -1616,6 +1619,7 @@ class ContactEditorDialog(base_class, ui_class):
name = unicode(self.display_name_editor.text())
image = IconCache().store(self.icon_selector.filename)
preferred_media = unicode(self.preferred_media.currentText())
sip_aliases = [alias.strip() for alias in unicode(self.sip_aliases_editor.text()).split(u';')]
group_index = self.group.currentIndex()
group_name = self.group.currentText()
if group_name != self.group.itemText(group_index):
......@@ -1629,9 +1633,10 @@ class ContactEditorDialog(base_class, ui_class):
group = self.group.itemData(group_index).toPyObject()
if self.edited_contact is None:
contact = Contact(group, name, uri, image)
contact.sip_aliases = sip_aliases
contact_model.addContact(contact)
else:
attributes = dict(group=group, name=name, uri=uri, image=image, preferred_media=preferred_media)
attributes = dict(group=group, name=name, uri=uri, image=image, preferred_media=preferred_media, sip_aliases=sip_aliases)
contact_model.updateContact(self.edited_contact, attributes)
self.edited_contact = None
......
......@@ -83,7 +83,7 @@ class SessionItem(QObject):
from blink import Blink
self.remote_party_name = None
for contact in Blink().main_window.contact_model.iter_contacts():
if uri.matches(contact.uri):
if uri.matches(contact.uri) or any(uri.matches(alias) for alias in contact.sip_aliases):
self.remote_party_name = contact.name
break
if not self.remote_party_name:
......@@ -1568,7 +1568,7 @@ class IncomingSession(QObject):
address = u'%s@%s' % (session.remote_identity.uri.user, session.remote_identity.uri.host)
self.dialog.uri_label.setText(address)
for contact in Blink().main_window.contact_model.iter_contacts():
if session.remote_identity.uri.matches(contact.uri):
if session.remote_identity.uri.matches(contact.uri) or any(session.remote_identity.uri.matches(alias) for alias in contact.sip_aliases):
self.dialog.username_label.setText(contact.name or session.remote_identity.display_name or address)
self.dialog.user_icon.setPixmap(contact.icon)
break
......
......@@ -175,7 +175,7 @@
</spacer>
</item>
<item row="5" column="0">
<widget class="QLabel" name="chat_aliases_label">
<widget class="QLabel" name="sip_aliases_label">
<property name="text">
<string>SIP Aliases:</string>
</property>
......@@ -185,7 +185,7 @@
</widget>
</item>
<item row="5" column="1" colspan="2">
<widget class="LineEdit" name="chat_aliases_editor">
<widget class="LineEdit" name="sip_aliases_editor">
<property name="inactiveText" stdset="0">
<string>List of SIP addresses separated by ;</string>
</property>
......@@ -361,7 +361,7 @@
<tabstop>group</tabstop>
<tabstop>clear_button</tabstop>
<tabstop>preferred_media</tabstop>
<tabstop>chat_aliases_editor</tabstop>
<tabstop>sip_aliases_editor</tabstop>
<tabstop>storage_place</tabstop>
<tabstop>subscribe_presence</tabstop>
<tabstop>subscribe_dialogs</tabstop>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment