Commit 4a4c1cf7 authored by Dan Pascu's avatar Dan Pascu

Use API level 2 for QString for better python integration

parent 9376ce46
...@@ -10,14 +10,17 @@ __date__ = 'October 26th, 2012' ...@@ -10,14 +10,17 @@ __date__ = 'October 26th, 2012'
import os import os
import sys import sys
from collections import defaultdict import sip
import cjson import cjson
sip.setapi('QString', 2)
from PyQt4.QtGui import QApplication from PyQt4.QtGui import QApplication
from application import log from application import log
from application.notification import IObserver, NotificationCenter, NotificationData from application.notification import IObserver, NotificationCenter, NotificationData
from application.python import Null from application.python import Null
from application.system import host, makedirs, unlink from application.system import host, makedirs, unlink
from collections import defaultdict
from eventlib import api from eventlib import api
from gnutls.crypto import X509Certificate, X509PrivateKey from gnutls.crypto import X509Certificate, X509PrivateKey
from gnutls.errors import GNUTLSError from gnutls.errors import GNUTLSError
......
...@@ -295,44 +295,44 @@ class AddAccountDialog(base_class, ui_class): ...@@ -295,44 +295,44 @@ class AddAccountDialog(base_class, ui_class):
def _get_display_name(self): def _get_display_name(self):
if self.panel_view.currentWidget() is self.add_account_panel: if self.panel_view.currentWidget() is self.add_account_panel:
return unicode(self.display_name_editor.text()) return self.display_name_editor.text()
else: else:
return unicode(self.name_editor.text()) return self.name_editor.text()
def _set_display_name(self, value): def _set_display_name(self, value):
self.display_name_editor.setText(value) self.display_name_editor.setText(value)
self.name_editor.setText(value) self.name_editor.setText(value)
def _get_username(self): def _get_username(self):
return unicode(self.username_editor.text()) return self.username_editor.text()
def _set_username(self, value): def _set_username(self, value):
self.username_editor.setText(value) self.username_editor.setText(value)
def _get_sip_address(self): def _get_sip_address(self):
return unicode(self.sip_address_editor.text()) return self.sip_address_editor.text()
def _set_sip_address(self, value): def _set_sip_address(self, value):
self.sip_address_editor.setText(value) self.sip_address_editor.setText(value)
def _get_password(self): def _get_password(self):
if self.panel_view.currentWidget() is self.add_account_panel: if self.panel_view.currentWidget() is self.add_account_panel:
return unicode(self.password_editor.text()) return self.password_editor.text()
else: else:
return unicode(self.new_password_editor.text()) return self.new_password_editor.text()
def _set_password(self, value): def _set_password(self, value):
self.password_editor.setText(value) self.password_editor.setText(value)
self.new_password_editor.setText(value) self.new_password_editor.setText(value)
def _get_verify_password(self): def _get_verify_password(self):
return unicode(self.verify_password_editor.text()) return self.verify_password_editor.text()
def _set_verify_password(self, value): def _set_verify_password(self, value):
self.verify_password_editor.setText(value) self.verify_password_editor.setText(value)
def _get_email_address(self): def _get_email_address(self):
return unicode(self.email_address_editor.text()) return self.email_address_editor.text()
def _set_email_address(self, value): def _set_email_address(self, value):
self.email_address_editor.setText(value) self.email_address_editor.setText(value)
...@@ -372,7 +372,7 @@ class AddAccountDialog(base_class, ui_class): ...@@ -372,7 +372,7 @@ class AddAccountDialog(base_class, ui_class):
self.accept_button.setEnabled(all(input.text_valid for input in inputs)) self.accept_button.setEnabled(all(input.text_valid for input in inputs))
def _SH_PasswordTextChanged(self, text): def _SH_PasswordTextChanged(self, text):
self.verify_password_editor.regexp = re.compile(u'^%s$' % re.escape(unicode(text))) self.verify_password_editor.regexp = re.compile(u'^%s$' % re.escape(text))
def _SH_ValidityStatusChanged(self): def _SH_ValidityStatusChanged(self):
red = '#cc0000' red = '#cc0000'
...@@ -590,7 +590,7 @@ class ServerToolsWebView(QWebView): ...@@ -590,7 +590,7 @@ class ServerToolsWebView(QWebView):
self.last_error = None self.last_error = None
def _SH_URLChanged(self, url): def _SH_URLChanged(self, url):
query_items = dict((unicode(name), unicode(value)) for name, value in url.queryItems()) query_items = dict(url.queryItems())
self.tab = query_items.get('tab') or self.tab self.tab = query_items.get('tab') or self.tab
self.task = query_items.get('task') or self.task self.task = query_items.get('task') or self.task
......
...@@ -13,7 +13,7 @@ import socket ...@@ -13,7 +13,7 @@ import socket
import sys import sys
from PyQt4 import uic from PyQt4 import uic
from PyQt4.QtCore import Qt, QAbstractListModel, QByteArray, QEvent, QMimeData, QModelIndex, QPointF, QRectF, QRegExp, QSize, QStringList, pyqtSignal from PyQt4.QtCore import Qt, QAbstractListModel, QByteArray, QEvent, QMimeData, QModelIndex, QPointF, QRectF, QRegExp, QSize, pyqtSignal
from PyQt4.QtGui import QBrush, QColor, QLinearGradient, QPainter, QPainterPath, QPalette, QPen, QPixmap, QPolygonF, QStyle from PyQt4.QtGui import QBrush, QColor, QLinearGradient, QPainter, QPainterPath, QPalette, QPen, QPixmap, QPolygonF, QStyle
from PyQt4.QtGui import QAction, QKeyEvent, QListView, QMenu, QMouseEvent, QRegExpValidator, QSortFilterProxyModel, QStyledItemDelegate from PyQt4.QtGui import QAction, QKeyEvent, QListView, QMenu, QMouseEvent, QRegExpValidator, QSortFilterProxyModel, QStyledItemDelegate
...@@ -108,7 +108,7 @@ class ContactGroup(object): ...@@ -108,7 +108,7 @@ class ContactGroup(object):
@updates_contacts_db @updates_contacts_db
def _name_changed(self): def _name_changed(self):
self.name = unicode(self.widget.name_editor.text()) self.name = self.widget.name_editor.text()
def _get_widget(self): def _get_widget(self):
return self.__dict__['widget'] return self.__dict__['widget']
...@@ -533,9 +533,9 @@ class GoogleContactsDialog(base_class, ui_class): ...@@ -533,9 +533,9 @@ class GoogleContactsDialog(base_class, ui_class):
@run_in_green_thread @run_in_green_thread
def _authorize_google_account(self): def _authorize_google_account(self):
red = '#cc0000' red = '#cc0000'
captcha_response = unicode(self.captcha_editor.text()) if self.captcha_token else None captcha_response = self.captcha_editor.text() if self.captcha_token else None
username = unicode(self.username_editor.text()) username = self.username_editor.text()
password = unicode(self.password_editor.text()) password = self.password_editor.text()
client = ContactsClient() client = ContactsClient()
try: try:
client.client_login(email=username, password=password, source='Blink', captcha_token=self.captcha_token, captcha_response=captcha_response) client.client_login(email=username, password=password, source='Blink', captcha_token=self.captcha_token, captcha_response=captcha_response)
...@@ -640,7 +640,7 @@ class ContactGroupWidget(base_class, ui_class): ...@@ -640,7 +640,7 @@ class ContactGroupWidget(base_class, ui_class):
return self.name_view.currentWidget() is self.editor_widget return self.name_view.currentWidget() is self.editor_widget
def _get_name(self): def _get_name(self):
return unicode(self.name_label.text()) return self.name_label.text()
def _set_name(self, value): def _set_name(self, value):
self.name_label.setText(value) self.name_label.setText(value)
...@@ -935,7 +935,7 @@ class ContactModel(QAbstractListModel): ...@@ -935,7 +935,7 @@ class ContactModel(QAbstractListModel):
return Qt.CopyAction | Qt.MoveAction return Qt.CopyAction | Qt.MoveAction
def mimeTypes(self): def mimeTypes(self):
return QStringList(['application/x-blink-contact-list']) return ['application/x-blink-contact-list']
def mimeData(self, indexes): def mimeData(self, indexes):
mime_data = QMimeData() mime_data = QMimeData()
...@@ -1369,7 +1369,7 @@ class ContactSearchModel(QSortFilterProxyModel): ...@@ -1369,7 +1369,7 @@ class ContactSearchModel(QSortFilterProxyModel):
item = source_model.data(source_index, Qt.DisplayRole) item = source_model.data(source_index, Qt.DisplayRole)
if isinstance(item, ContactGroup): if isinstance(item, ContactGroup):
return False return False
search_tokens = unicode(self.filterRegExp().pattern()).lower().split() search_tokens = self.filterRegExp().pattern().lower().split()
searched_item = unicode(item).lower() searched_item = unicode(item).lower()
return all(token in searched_item for token in search_tokens) return all(token in searched_item for token in search_tokens)
...@@ -1382,7 +1382,7 @@ class ContactSearchModel(QSortFilterProxyModel): ...@@ -1382,7 +1382,7 @@ class ContactSearchModel(QSortFilterProxyModel):
return Qt.CopyAction return Qt.CopyAction
def mimeTypes(self): def mimeTypes(self):
return QStringList(['application/x-blink-contact-list']) return ['application/x-blink-contact-list']
def mimeData(self, indexes): def mimeData(self, indexes):
mime_data = QMimeData() mime_data = QMimeData()
...@@ -2067,11 +2067,11 @@ class ContactEditorDialog(base_class, ui_class): ...@@ -2067,11 +2067,11 @@ class ContactEditorDialog(base_class, ui_class):
@updates_contacts_db @updates_contacts_db
def process_contact(self): def process_contact(self):
contact_model = self.parent().contact_model contact_model = self.parent().contact_model
uri = unicode(self.sip_address_editor.text()) uri = self.sip_address_editor.text()
name = unicode(self.display_name_editor.text()) name = self.display_name_editor.text()
image = IconCache().store(self.icon_selector.filename) image = IconCache().store(self.icon_selector.filename)
preferred_media = unicode(self.preferred_media.currentText()) preferred_media = self.preferred_media.currentText()
sip_aliases = [alias.strip() for alias in unicode(self.sip_aliases_editor.text()).split(u';')] sip_aliases = [alias.strip() for alias in self.sip_aliases_editor.text().split(u';')]
group_index = self.group.currentIndex() group_index = self.group.currentIndex()
group_name = self.group.currentText() group_name = self.group.currentText()
if group_name != self.group.itemText(group_index): if group_name != self.group.itemText(group_index):
...@@ -2080,7 +2080,7 @@ class ContactEditorDialog(base_class, ui_class): ...@@ -2080,7 +2080,7 @@ class ContactEditorDialog(base_class, ui_class):
if index >= 0: if index >= 0:
group = self.group.itemData(index).toPyObject() group = self.group.itemData(index).toPyObject()
else: else:
group = ContactGroup(unicode(group_name)) group = ContactGroup(group_name)
else: else:
group = self.group.itemData(group_index).toPyObject() group = self.group.itemData(group_index).toPyObject()
if self.edited_contact is None: if self.edited_contact is None:
......
...@@ -381,7 +381,7 @@ class MainWindow(base_class, ui_class): ...@@ -381,7 +381,7 @@ class MainWindow(base_class, ui_class):
list_view = self.contact_list if self.contacts_view.currentWidget() is self.contact_list_panel else self.search_list list_view = self.contact_list if self.contacts_view.currentWidget() is self.contact_list_panel else self.search_list
selected_indexes = list_view.selectionModel().selectedIndexes() selected_indexes = list_view.selectionModel().selectedIndexes()
contact = list_view.model().data(selected_indexes[0]) if selected_indexes else Null contact = list_view.model().data(selected_indexes[0]) if selected_indexes else Null
address = contact.uri or unicode(self.search_box.text()) address = contact.uri or self.search_box.text()
name = contact.name or None name = contact.name or None
session_manager = SessionManager() session_manager = SessionManager()
session_manager.start_call(name, address, contact=contact, account=BonjourAccount() if isinstance(contact, BonjourNeighbour) else None) session_manager.start_call(name, address, contact=contact, account=BonjourAccount() if isinstance(contact, BonjourNeighbour) else None)
...@@ -403,13 +403,13 @@ class MainWindow(base_class, ui_class): ...@@ -403,13 +403,13 @@ class MainWindow(base_class, ui_class):
self.enable_call_buttons(account_manager.default_account is not None and len(selected_items)==1 and isinstance(self.contact_model.data(selected_items[0]), Contact)) self.enable_call_buttons(account_manager.default_account is not None and len(selected_items)==1 and isinstance(self.contact_model.data(selected_items[0]), Contact))
def _SH_ContactModelAddedItems(self, items): def _SH_ContactModelAddedItems(self, items):
if self.search_box.text().isEmpty(): if not self.search_box.text():
return return
active_widget = self.search_list_panel if self.contact_search_model.rowCount() else self.not_found_panel active_widget = self.search_list_panel if self.contact_search_model.rowCount() else self.not_found_panel
self.search_view.setCurrentWidget(active_widget) self.search_view.setCurrentWidget(active_widget)
def _SH_ContactModelRemovedItems(self, items): def _SH_ContactModelRemovedItems(self, items):
if self.search_box.text().isEmpty(): if not self.search_box.text():
return return
if any(type(item) is Contact for item in items) and self.contact_search_model.rowCount() == 0: if any(type(item) is Contact for item in items) and self.contact_search_model.rowCount() == 0:
self.search_box.clear() self.search_box.clear()
...@@ -421,7 +421,7 @@ class MainWindow(base_class, ui_class): ...@@ -421,7 +421,7 @@ class MainWindow(base_class, ui_class):
self.display_name.clearFocus() self.display_name.clearFocus()
index = self.identity.currentIndex() index = self.identity.currentIndex()
if index != -1: if index != -1:
name = unicode(self.display_name.text()) name = self.display_name.text()
account = self.identity.itemData(index).toPyObject().account account = self.identity.itemData(index).toPyObject().account
account.display_name = name if name else None account.display_name = name if name else None
account.save() account.save()
...@@ -459,7 +459,7 @@ class MainWindow(base_class, ui_class): ...@@ -459,7 +459,7 @@ class MainWindow(base_class, ui_class):
SIPApplication.voice_audio_bridge.mixer.muted = muted SIPApplication.voice_audio_bridge.mixer.muted = muted
def _SH_SearchBoxReturnPressed(self): def _SH_SearchBoxReturnPressed(self):
address = unicode(self.search_box.text()) address = self.search_box.text()
if address: if address:
session_manager = SessionManager() session_manager = SessionManager()
session_manager.start_call(None, address) session_manager.start_call(None, address)
...@@ -469,17 +469,16 @@ class MainWindow(base_class, ui_class): ...@@ -469,17 +469,16 @@ class MainWindow(base_class, ui_class):
account_manager = AccountManager() account_manager = AccountManager()
if text: if text:
self.switch_view_button.view = SwitchViewButton.ContactView self.switch_view_button.view = SwitchViewButton.ContactView
if self.contacts_view.currentWidget() is not self.search_panel:
self.search_list.selectionModel().clearSelection()
self.contacts_view.setCurrentWidget(self.search_panel)
self.search_view.setCurrentWidget(self.search_list_panel if self.contact_search_model.rowCount() else self.not_found_panel)
selected_items = self.search_list.selectionModel().selectedIndexes() selected_items = self.search_list.selectionModel().selectedIndexes()
self.enable_call_buttons(account_manager.default_account is not None and len(selected_items)<=1) self.enable_call_buttons(account_manager.default_account is not None and len(selected_items)<=1)
else: else:
self.contacts_view.setCurrentWidget(self.contact_list_panel)
selected_items = self.contact_list.selectionModel().selectedIndexes() selected_items = self.contact_list.selectionModel().selectedIndexes()
self.enable_call_buttons(account_manager.default_account is not None and len(selected_items)==1 and type(self.contact_model.data(selected_items[0])) is Contact) self.enable_call_buttons(account_manager.default_account is not None and len(selected_items)==1 and type(self.contact_model.data(selected_items[0])) is Contact)
active_widget = self.contact_list_panel if text.isEmpty() else self.search_panel
if active_widget is self.search_panel and self.contacts_view.currentWidget() is not self.search_panel:
self.search_list.selectionModel().clearSelection()
self.contacts_view.setCurrentWidget(active_widget)
active_widget = self.search_list_panel if self.contact_search_model.rowCount() else self.not_found_panel
self.search_view.setCurrentWidget(active_widget)
def _SH_SearchListSelectionChanged(self, selected, deselected): def _SH_SearchListSelectionChanged(self, selected, deselected):
account_manager = AccountManager() account_manager = AccountManager()
......
...@@ -40,9 +40,7 @@ class IDDPrefixValidator(QRegExpValidator): ...@@ -40,9 +40,7 @@ class IDDPrefixValidator(QRegExpValidator):
super(IDDPrefixValidator, self).__init__(QRegExp(u'[0-9+*#]+'), parent) super(IDDPrefixValidator, self).__init__(QRegExp(u'[0-9+*#]+'), parent)
def fixup(self, input): def fixup(self, input):
if input.isEmpty(): return super(IDDPrefixValidator, self).fixup(input or u'+')
input.append(u'+')
return super(IDDPrefixValidator, self).fixup(input)
class PrefixValidator(QRegExpValidator): class PrefixValidator(QRegExpValidator):
...@@ -50,9 +48,7 @@ class PrefixValidator(QRegExpValidator): ...@@ -50,9 +48,7 @@ class PrefixValidator(QRegExpValidator):
super(PrefixValidator, self).__init__(QRegExp(u'(None|[0-9+*#]+)'), parent) super(PrefixValidator, self).__init__(QRegExp(u'(None|[0-9+*#]+)'), parent)
def fixup(self, input): def fixup(self, input):
if input.isEmpty(): return super(PrefixValidator, self).fixup(input or u'None')
input.append(u'None')
return super(PrefixValidator, self).fixup(input)
class HostnameValidator(QRegExpValidator): class HostnameValidator(QRegExpValidator):
...@@ -67,7 +63,7 @@ class SIPAddressValidator(QRegExpValidator): ...@@ -67,7 +63,7 @@ class SIPAddressValidator(QRegExpValidator):
def fixup(self, input): def fixup(self, input):
if input and '@' not in input: if input and '@' not in input:
preferences_window = self.parent() preferences_window = self.parent()
input.append(u'@%s' % preferences_window.selected_account.id.domain) input += u'@%s' % preferences_window.selected_account.id.domain
return super(SIPAddressValidator, self).fixup(input) return super(SIPAddressValidator, self).fixup(input)
...@@ -78,25 +74,25 @@ class WebURLValidator(QRegExpValidator): ...@@ -78,25 +74,25 @@ class WebURLValidator(QRegExpValidator):
class XCAPRootValidator(WebURLValidator): class XCAPRootValidator(WebURLValidator):
def fixup(self, input): def fixup(self, input):
url = urlparse.urlparse(unicode(input)) url = urlparse.urlparse(input)
if not (url.scheme and url.netloc): if not (url.scheme and url.netloc):
input.clear() input = u''
return super(XCAPRootValidator, self).fixup(input) return super(XCAPRootValidator, self).fixup(input)
def validate(self, input, pos): def validate(self, input, pos):
state, pos = super(XCAPRootValidator, self).validate(input, pos) state, input, pos = super(XCAPRootValidator, self).validate(input, pos)
if state == QValidator.Acceptable: if state == QValidator.Acceptable:
if input and input[-1] in ('?', ';', '&'): if input.endswith(('?', ';', '&')):
state = QValidator.Invalid state = QValidator.Invalid
else: else:
url = urlparse.urlparse(unicode(input)) url = urlparse.urlparse(input)
if url.params or url.query or url.fragment: if url.params or url.query or url.fragment:
state = QValidator.Invalid state = QValidator.Invalid
elif url.port is not None: elif url.port is not None:
port = int(url.port) port = int(url.port)
if not (0 < port <= 65535): if not (0 < port <= 65535):
state = QValidator.Invalid state = QValidator.Invalid
return state, pos return state, input, pos
# Custom widgets used in preferences.ui # Custom widgets used in preferences.ui
...@@ -122,14 +118,14 @@ class SIPPortEditor(QSpinBox): ...@@ -122,14 +118,14 @@ class SIPPortEditor(QSpinBox):
return super(SIPPortEditor, self).stepBy(steps) return super(SIPPortEditor, self).stepBy(steps)
def validate(self, input, pos): def validate(self, input, pos):
state, pos = super(SIPPortEditor, self).validate(input, pos) state, input, pos = super(SIPPortEditor, self).validate(input, pos)
if state == QValidator.Acceptable: if state == QValidator.Acceptable:
value = int(input) value = int(input)
if 0 < value < 1024: if 0 < value < 1024:
state = QValidator.Intermediate state = QValidator.Intermediate
elif value == self.sibling.value() != 0: elif value == self.sibling.value() != 0:
state = QValidator.Intermediate state = QValidator.Intermediate
return state, pos return state, input, pos
class AccountListView(QListView): class AccountListView(QListView):
...@@ -308,10 +304,10 @@ class PreferencesWindow(base_class, ui_class): ...@@ -308,10 +304,10 @@ class PreferencesWindow(base_class, ui_class):
self.section_group.addAction(action) self.section_group.addAction(action)
for index in xrange(self.idd_prefix_button.count()): for index in xrange(self.idd_prefix_button.count()):
text = unicode(self.idd_prefix_button.itemText(index)) text = self.idd_prefix_button.itemText(index)
self.idd_prefix_button.setItemData(index, QVariant(None if text == "+" else text)) self.idd_prefix_button.setItemData(index, QVariant(None if text == "+" else text))
for index in xrange(self.prefix_button.count()): for index in xrange(self.prefix_button.count()):
text = unicode(self.prefix_button.itemText(index)) text = self.prefix_button.itemText(index)
self.prefix_button.setItemData(index, QVariant(None if text == "None" else text)) self.prefix_button.setItemData(index, QVariant(None if text == "None" else text))
self.voicemail_uri_editor.setValidator(SIPAddressValidator(self)) self.voicemail_uri_editor.setValidator(SIPAddressValidator(self))
...@@ -392,14 +388,14 @@ class PreferencesWindow(base_class, ui_class): ...@@ -392,14 +388,14 @@ class PreferencesWindow(base_class, ui_class):
def account_msrp_relay(self): def account_msrp_relay(self):
host = self.msrp_relay_host_editor.text() host = self.msrp_relay_host_editor.text()
port = self.msrp_relay_port.value() port = self.msrp_relay_port.value()
transport = str(self.msrp_relay_transport_button.currentText()).lower() transport = self.msrp_relay_transport_button.currentText().lower()
return MSRPRelayAddress(host, port, transport) if host else None return MSRPRelayAddress(host, port, transport) if host else None
@property @property
def account_outbound_proxy(self): def account_outbound_proxy(self):
host = self.outbound_proxy_host_editor.text() host = self.outbound_proxy_host_editor.text()
port = self.outbound_proxy_port.value() port = self.outbound_proxy_port.value()
transport = str(self.outbound_proxy_transport_button.currentText()).lower() transport = self.outbound_proxy_transport_button.currentText().lower()
return SIPProxyAddress(host, port, transport) if host else None return SIPProxyAddress(host, port, transport) if host else None
@property @property
...@@ -768,14 +764,14 @@ class PreferencesWindow(base_class, ui_class): ...@@ -768,14 +764,14 @@ class PreferencesWindow(base_class, ui_class):
def _SH_DisplayNameEditorEditingFinished(self): def _SH_DisplayNameEditorEditingFinished(self):
account = self.selected_account account = self.selected_account
display_name = unicode(self.display_name_editor.text()) or None display_name = self.display_name_editor.text() or None
if account.display_name != display_name: if account.display_name != display_name:
account.display_name = display_name account.display_name = display_name
account.save() account.save()
def _SH_PasswordEditorEditingFinished(self): def _SH_PasswordEditorEditingFinished(self):
account = self.selected_account account = self.selected_account
password = unicode(self.password_editor.text()) password = self.password_editor.text()
if account.auth.password != password: if account.auth.password != password:
account.auth.password = password account.auth.password = password
account.save() account.save()
...@@ -785,23 +781,23 @@ class PreferencesWindow(base_class, ui_class): ...@@ -785,23 +781,23 @@ class PreferencesWindow(base_class, ui_class):
if not self.load_in_progress: if not self.load_in_progress:
account = self.selected_account account = self.selected_account
items = [self.account_audio_codecs_list.item(row) for row in xrange(self.account_audio_codecs_list.count())] items = [self.account_audio_codecs_list.item(row) for row in xrange(self.account_audio_codecs_list.count())]
account.rtp.audio_codec_list = [str(item.text()) for item in items if item.checkState()==Qt.Checked] account.rtp.audio_codec_list = [item.text() for item in items if item.checkState()==Qt.Checked]
account.rtp.audio_codec_order = [str(item.text()) for item in items] account.rtp.audio_codec_order = [item.text() for item in items]
account.save() account.save()
def _SH_AccountAudioCodecsListModelRowsInserted(self, parent, start, end): def _SH_AccountAudioCodecsListModelRowsInserted(self, parent, start, end):
if not self.load_in_progress: if not self.load_in_progress:
account = self.selected_account account = self.selected_account
items = [self.account_audio_codecs_list.item(row) for row in xrange(self.account_audio_codecs_list.count())] items = [self.account_audio_codecs_list.item(row) for row in xrange(self.account_audio_codecs_list.count())]
account.rtp.audio_codec_order = [str(item.text()) for item in items] account.rtp.audio_codec_order = [item.text() for item in items]
account.rtp.audio_codec_list = [str(item.text()) for item in items if item.checkState()==Qt.Checked] account.rtp.audio_codec_list = [item.text() for item in items if item.checkState()==Qt.Checked]
account.save() account.save()
def _SH_AccountAudioCodecsListModelRowsMoved(self, source_parent, source_start, source_end, dest_parent, dest_row): def _SH_AccountAudioCodecsListModelRowsMoved(self, source_parent, source_start, source_end, dest_parent, dest_row):
account = self.selected_account account = self.selected_account
items = [self.account_audio_codecs_list.item(row) for row in xrange(self.account_audio_codecs_list.count())] items = [self.account_audio_codecs_list.item(row) for row in xrange(self.account_audio_codecs_list.count())]
account.rtp.audio_codec_order = [str(item.text()) for item in items] account.rtp.audio_codec_order = [item.text() for item in items]
account.rtp.audio_codec_list = [str(item.text()) for item in items if item.checkState()==Qt.Checked] account.rtp.audio_codec_list = [item.text() for item in items if item.checkState()==Qt.Checked]
account.save() account.save()
def _SH_ResetAudioCodecsButtonClicked(self, checked): def _SH_ResetAudioCodecsButtonClicked(self, checked):
...@@ -830,7 +826,7 @@ class PreferencesWindow(base_class, ui_class): ...@@ -830,7 +826,7 @@ class PreferencesWindow(base_class, ui_class):
def _SH_SRTPEncryptionButtonActivated(self, text): def _SH_SRTPEncryptionButtonActivated(self, text):
account = self.selected_account account = self.selected_account
account.rtp.srtp_encryption = str(text) account.rtp.srtp_encryption = text
account.save() account.save()
# Account server settings # Account server settings
...@@ -863,7 +859,7 @@ class PreferencesWindow(base_class, ui_class): ...@@ -863,7 +859,7 @@ class PreferencesWindow(base_class, ui_class):
def _SH_AuthUsernameEditorEditingFinished(self): def _SH_AuthUsernameEditorEditingFinished(self):
account = self.selected_account account = self.selected_account
auth_username = unicode(self.auth_username_editor.text()) or None auth_username = self.auth_username_editor.text() or None
if account.auth.username != auth_username: if account.auth.username != auth_username:
account.auth.username = auth_username account.auth.username = auth_username
account.save() account.save()
...@@ -897,28 +893,28 @@ class PreferencesWindow(base_class, ui_class): ...@@ -897,28 +893,28 @@ class PreferencesWindow(base_class, ui_class):
def _SH_VoicemailURIEditorEditingFinished(self): def _SH_VoicemailURIEditorEditingFinished(self):
account = self.selected_account account = self.selected_account
voicemail_uri = unicode(self.voicemail_uri_editor.text()) or None voicemail_uri = self.voicemail_uri_editor.text() or None
if account.message_summary.voicemail_uri != voicemail_uri: if account.message_summary.voicemail_uri != voicemail_uri:
account.message_summary.voicemail_uri = voicemail_uri account.message_summary.voicemail_uri = voicemail_uri
account.save() account.save()
def _SH_XCAPRootEditorEditingFinished(self): def _SH_XCAPRootEditorEditingFinished(self):
account = self.selected_account account = self.selected_account
xcap_root = unicode(self.xcap_root_editor.text()) or None xcap_root = self.xcap_root_editor.text() or None
if account.xcap.xcap_root != xcap_root: if account.xcap.xcap_root != xcap_root:
account.xcap.xcap_root = xcap_root account.xcap.xcap_root = xcap_root
account.save() account.save()
def _SH_ServerToolsURLEditorEditingFinished(self): def _SH_ServerToolsURLEditorEditingFinished(self):
account = self.selected_account account = self.selected_account
url = unicode(self.server_tools_url_editor.text()) or None url = self.server_tools_url_editor.text() or None
if account.server.settings_url != url: if account.server.settings_url != url:
account.server.settings_url = url account.server.settings_url = url
account.save() account.save()
def _SH_ConferenceServerEditorEditingFinished(self): def _SH_ConferenceServerEditorEditingFinished(self):
account = self.selected_account account = self.selected_account
server = unicode(self.conference_server_editor.text()) or None server = self.conference_server_editor.text() or None
if account.server.conference_server != server: if account.server.conference_server != server:
account.server.conference_server = server account.server.conference_server = server
account.save() account.save()
...@@ -931,7 +927,7 @@ class PreferencesWindow(base_class, ui_class): ...@@ -931,7 +927,7 @@ class PreferencesWindow(base_class, ui_class):
def _SH_MSRPTransportButtonActivated(self, text): def _SH_MSRPTransportButtonActivated(self, text):
account = self.selected_account account = self.selected_account
account.msrp.transport = str(text).lower() account.msrp.transport = text.lower()
account.save() account.save()
# Account advanced settings # Account advanced settings
...@@ -960,7 +956,7 @@ class PreferencesWindow(base_class, ui_class): ...@@ -960,7 +956,7 @@ class PreferencesWindow(base_class, ui_class):
def _SH_IDDPrefixButtonActivated(self, text): def _SH_IDDPrefixButtonActivated(self, text):
self._update_pstn_example_label() self._update_pstn_example_label()
account = self.selected_account account = self.selected_account
idd_prefix = None if text=='+' else str(text) idd_prefix = None if text=='+' else text
if account.pstn.idd_prefix != idd_prefix: if account.pstn.idd_prefix != idd_prefix:
account.pstn.idd_prefix = idd_prefix account.pstn.idd_prefix = idd_prefix
account.save() account.save()
...@@ -968,7 +964,7 @@ class PreferencesWindow(base_class, ui_class): ...@@ -968,7 +964,7 @@ class PreferencesWindow(base_class, ui_class):
def _SH_PrefixButtonActivated(self, text): def _SH_PrefixButtonActivated(self, text):
self._update_pstn_example_label() self._update_pstn_example_label()
account = self.selected_account account = self.selected_account
prefix = None if text=='None' else str(text) prefix = None if text=='None' else text
if account.pstn.prefix != prefix: if account.pstn.prefix != prefix:
account.pstn.prefix = prefix account.pstn.prefix = prefix
account.save() account.save()
...@@ -982,7 +978,7 @@ class PreferencesWindow(base_class, ui_class): ...@@ -982,7 +978,7 @@ class PreferencesWindow(base_class, ui_class):
# TODO: open the file selection dialog in non-modal mode (and the error messages boxes as well). -Dan # TODO: open the file selection dialog in non-modal mode (and the error messages boxes as well). -Dan
account = self.selected_account account = self.selected_account
directory = os.path.dirname(account.tls.certificate.normalized) if account.tls.certificate else os.path.expanduser('~') directory = os.path.dirname(account.tls.certificate.normalized) if account.tls.certificate else os.path.expanduser('~')
cert_path = unicode(QFileDialog.getOpenFileName(self, u'Select Certificate File', directory, u"TLS certificates (*.crt *.pem)")) or None cert_path = QFileDialog.getOpenFileName(self, u'Select Certificate File', directory, u"TLS certificates (*.crt *.pem)") or None
if cert_path is not None: if cert_path is not None:
cert_path = os.path.normpath(cert_path) cert_path = os.path.normpath(cert_path)
if cert_path != account.tls.certificate: if cert_path != account.tls.certificate:
...@@ -1025,7 +1021,7 @@ class PreferencesWindow(base_class, ui_class): ...@@ -1025,7 +1021,7 @@ class PreferencesWindow(base_class, ui_class):
def _SH_AudioSampleRateButtonActivated(self, text): def _SH_AudioSampleRateButtonActivated(self, text):
settings = SIPSimpleSettings() settings = SIPSimpleSettings()
settings.audio.sample_rate = str(text) settings.audio.sample_rate = text
settings.save() settings.save()
def _SH_EnableEchoCancellingButtonClicked(self, checked): def _SH_EnableEchoCancellingButtonClicked(self, checked):
...@@ -1038,22 +1034,22 @@ class PreferencesWindow(base_class, ui_class): ...@@ -1038,22 +1034,22 @@ class PreferencesWindow(base_class, ui_class):
if not self.load_in_progress: if not self.load_in_progress:
settings = SIPSimpleSettings() settings = SIPSimpleSettings()
item_iterator = (self.audio_codecs_list.item(row) for row in xrange(self.audio_codecs_list.count())) item_iterator = (self.audio_codecs_list.item(row) for row in xrange(self.audio_codecs_list.count()))
settings.rtp.audio_codec_list = [str(item.text()) for item in item_iterator if item.checkState()==Qt.Checked] settings.rtp.audio_codec_list = [item.text() for item in item_iterator if item.checkState()==Qt.Checked]
settings.save() settings.save()
def _SH_AudioCodecsListModelRowsInserted(self, parent, start, end): def _SH_AudioCodecsListModelRowsInserted(self, parent, start, end):
if not self.load_in_progress: if not self.load_in_progress:
settings = SIPSimpleSettings() settings = SIPSimpleSettings()
items = [self.audio_codecs_list.item(row) for row in xrange(self.audio_codecs_list.count())] items = [self.audio_codecs_list.item(row) for row in xrange(self.audio_codecs_list.count())]
settings.rtp.audio_codec_order = [str(item.text()) for item in items] settings.rtp.audio_codec_order = [item.text() for item in items]
settings.rtp.audio_codec_list = [str(item.text()) for item in items if item.checkState()==Qt.Checked] settings.rtp.audio_codec_list = [item.text() for item in items if item.checkState()==Qt.Checked]
settings.save() settings.save()
def _SH_AudioCodecsListModelRowsMoved(self, source_parent, source_start, source_end, dest_parent, dest_row): def _SH_AudioCodecsListModelRowsMoved(self, source_parent, source_start, source_end, dest_parent, dest_row):
settings = SIPSimpleSettings() settings = SIPSimpleSettings()
items = [self.audio_codecs_list.item(row) for row in xrange(self.audio_codecs_list.count())] items = [self.audio_codecs_list.item(row) for row in xrange(self.audio_codecs_list.count())]
settings.rtp.audio_codec_order = [str(item.text()) for item in items] settings.rtp.audio_codec_order = [item.text() for item in items]
settings.rtp.audio_codec_list = [str(item.text()) for item in items if item.checkState()==Qt.Checked] settings.rtp.audio_codec_list = [item.text() for item in items if item.checkState()==Qt.Checked]
settings.save() settings.save()
# Answering machine signal handlers # Answering machine signal handlers
...@@ -1107,7 +1103,7 @@ class PreferencesWindow(base_class, ui_class): ...@@ -1107,7 +1103,7 @@ class PreferencesWindow(base_class, ui_class):
# TODO: open the file selection dialog in non-modal mode. Same for the one for TLS CA list and the IconSelector from contacts. -Dan # TODO: open the file selection dialog in non-modal mode. Same for the one for TLS CA list and the IconSelector from contacts. -Dan
settings = SIPSimpleSettings() settings = SIPSimpleSettings()
directory = settings.file_transfer.directory or os.path.expanduser('~') directory = settings.file_transfer.directory or os.path.expanduser('~')
directory = unicode(QFileDialog.getExistingDirectory(self, u'Select Download Directory', directory)) or None directory = QFileDialog.getExistingDirectory(self, u'Select Download Directory', directory) or None
if directory is not None: if directory is not None:
directory = os.path.normpath(directory) directory = os.path.normpath(directory)
if directory != settings.file_transfer.directory: if directory != settings.file_transfer.directory:
...@@ -1249,7 +1245,7 @@ class PreferencesWindow(base_class, ui_class): ...@@ -1249,7 +1245,7 @@ class PreferencesWindow(base_class, ui_class):
# TODO: open the file selection dialog in non-modal mode (and the error messages boxes as well). -Dan # TODO: open the file selection dialog in non-modal mode (and the error messages boxes as well). -Dan
settings = SIPSimpleSettings() settings = SIPSimpleSettings()
directory = os.path.dirname(settings.tls.ca_list.normalized) if settings.tls.ca_list else os.path.expanduser('~') directory = os.path.dirname(settings.tls.ca_list.normalized) if settings.tls.ca_list else os.path.expanduser('~')
ca_path = unicode(QFileDialog.getOpenFileName(self, u'Select Certificate Authority File', directory, u"TLS certificates (*.crt *.pem)")) or None ca_path = QFileDialog.getOpenFileName(self, u'Select Certificate Authority File', directory, u"TLS certificates (*.crt *.pem)") or None
if ca_path is not None: if ca_path is not None:
ca_path = os.path.normpath(ca_path) ca_path = os.path.normpath(ca_path)
if ca_path != settings.tls.ca_list: if ca_path != settings.tls.ca_list:
......
...@@ -15,7 +15,7 @@ from functools import partial ...@@ -15,7 +15,7 @@ from functools import partial
from itertools import chain, izip, repeat from itertools import chain, izip, repeat
from PyQt4 import uic from PyQt4 import uic
from PyQt4.QtCore import Qt, QAbstractListModel, QByteArray, QEvent, QMimeData, QModelIndex, QObject, QSize, QStringList, QTimer, pyqtSignal from PyQt4.QtCore import Qt, QAbstractListModel, QByteArray, QEvent, QMimeData, QModelIndex, QObject, QSize, QTimer, pyqtSignal
from PyQt4.QtGui import QApplication, QBrush, QColor, QDrag, QLinearGradient, QListView, QPainter, QPen, QPixmap, QShortcut, QStyledItemDelegate from PyQt4.QtGui import QApplication, QBrush, QColor, QDrag, QLinearGradient, QListView, QPainter, QPen, QPixmap, QShortcut, QStyledItemDelegate
from application.notification import IObserver, NotificationCenter from application.notification import IObserver, NotificationCenter
...@@ -999,7 +999,7 @@ class SessionModel(QAbstractListModel): ...@@ -999,7 +999,7 @@ class SessionModel(QAbstractListModel):
return Qt.CopyAction | Qt.MoveAction return Qt.CopyAction | Qt.MoveAction
def mimeTypes(self): def mimeTypes(self):
return QStringList(['application/x-blink-session-list']) return ['application/x-blink-session-list']
def mimeData(self, indexes): def mimeData(self, indexes):
mime_data = QMimeData() mime_data = QMimeData()
......
...@@ -40,7 +40,7 @@ class IconSelector(QLabel): ...@@ -40,7 +40,7 @@ class IconSelector(QLabel):
def mouseReleaseEvent(self, event): def mouseReleaseEvent(self, event):
if event.button() == Qt.LeftButton and self.rect().contains(event.pos()): if event.button() == Qt.LeftButton and self.rect().contains(event.pos()):
filename = unicode(QFileDialog.getOpenFileName(self, u'Select Icon', self.last_icon_directory, u"Images (*.png *.tiff *.jpg *.xmp *.svg)")) filename = QFileDialog.getOpenFileName(self, u'Select Icon', self.last_icon_directory, u"Images (*.png *.tiff *.jpg *.xmp *.svg)")
if filename: if filename:
self.last_icon_directory = os.path.dirname(filename) self.last_icon_directory = os.path.dirname(filename)
self.filename = filename if os.path.realpath(filename) != os.path.realpath(Resources.get(self.default_icon)) else None self.filename = filename if os.path.realpath(filename) != os.path.realpath(Resources.get(self.default_icon)) else None
......
...@@ -100,7 +100,7 @@ class LineEdit(QLineEdit): ...@@ -100,7 +100,7 @@ class LineEdit(QLineEdit):
def paintEvent(self, event): def paintEvent(self, event):
QLineEdit.paintEvent(self, event) QLineEdit.paintEvent(self, event)
if not self.hasFocus() and self.text().isEmpty() and self.inactiveText: if not self.hasFocus() and not self.text() and self.inactiveText:
options = QStyleOptionFrameV2() options = QStyleOptionFrameV2()
self.initStyleOption(options) self.initStyleOption(options)
text_rect = self.style().subElementRect(QStyle.SE_LineEditContents, options, self) text_rect = self.style().subElementRect(QStyle.SE_LineEditContents, options, self)
...@@ -168,7 +168,7 @@ class ValidatingLineEdit(LineEdit): ...@@ -168,7 +168,7 @@ class ValidatingLineEdit(LineEdit):
self._validate() self._validate()
def _validate(self): def _validate(self):
text = unicode(self.text()) text = self.text()
text_correct = self.regexp.search(text) is not None text_correct = self.regexp.search(text) is not None
text_allowed = text not in self.exceptions text_allowed = text not in self.exceptions
if self.text_correct != text_correct or self.text_allowed != text_allowed: if self.text_correct != text_correct or self.text_allowed != text_allowed:
...@@ -277,7 +277,7 @@ class SearchBox(LineEdit): ...@@ -277,7 +277,7 @@ class SearchBox(LineEdit):
self.inactiveText = u"Search" self.inactiveText = u"Search"
def _SH_TextChanged(self, text): def _SH_TextChanged(self, text):
self.clear_button.setVisible(not text.isEmpty()) self.clear_button.setVisible(bool(text))
class LocationBar(LineEdit): class LocationBar(LineEdit):
...@@ -301,6 +301,6 @@ class LocationBar(LineEdit): ...@@ -301,6 +301,6 @@ class LocationBar(LineEdit):
self.locationCleared.emit() self.locationCleared.emit()
def _SH_TextChanged(self, text): def _SH_TextChanged(self, text):
self.clear_button.setVisible(not text.isEmpty()) self.clear_button.setVisible(bool(text))
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