Runnable with both Python3 and Python2, with both PyQt5 and PyQt4 by using Qt.py #2250
|
@ -23,8 +23,8 @@ def getSortedAccounts():
|
||||||
configSections = BMConfigParser().addresses()
|
configSections = BMConfigParser().addresses()
|
||||||
configSections.sort(
|
configSections.sort(
|
||||||
cmp=lambda x, y: cmp(
|
cmp=lambda x, y: cmp(
|
||||||
unicode(BMConfigParser().get(x, 'label'), 'utf-8').lower(),
|
BMConfigParser().get(x, 'label').decode('utf-8').lower(),
|
||||||
unicode(BMConfigParser().get(y, 'label'), 'utf-8').lower())
|
BMConfigParser().get(y, 'label').decode('utf-8').lower())
|
||||||
)
|
)
|
||||||
return configSections
|
return configSections
|
||||||
|
|
||||||
|
@ -38,22 +38,21 @@ def getSortedSubscriptions(count=False):
|
||||||
:retuns: dict keys are addresses, values are dicts containing settings
|
:retuns: dict keys are addresses, values are dicts containing settings
|
||||||
:rtype: dict, default {}
|
:rtype: dict, default {}
|
||||||
"""
|
"""
|
||||||
queryreturn = sqlQuery('SELECT label, address, enabled FROM subscriptions ORDER BY label COLLATE NOCASE ASC')
|
queryreturn = sqlQuery(
|
||||||
|
'SELECT label, address, enabled FROM subscriptions'
|
||||||
|
' ORDER BY label COLLATE NOCASE ASC')
|
||||||
ret = {}
|
ret = {}
|
||||||
for row in queryreturn:
|
for label, address, enabled in queryreturn:
|
||||||
label, address, enabled = row
|
ret[address] = {'inbox': {}}
|
||||||
ret[address] = {}
|
ret[address]['inbox'].update(label=label, enabled=enabled, count=0)
|
||||||
ret[address]["inbox"] = {}
|
|
||||||
ret[address]["inbox"]['label'] = label
|
|
||||||
ret[address]["inbox"]['enabled'] = enabled
|
|
||||||
ret[address]["inbox"]['count'] = 0
|
|
||||||
if count:
|
if count:
|
||||||
queryreturn = sqlQuery('''SELECT fromaddress, folder, count(msgid) as cnt
|
queryreturn = sqlQuery(
|
||||||
FROM inbox, subscriptions ON subscriptions.address = inbox.fromaddress
|
'SELECT fromaddress, folder, count(msgid) AS cnt'
|
||||||
WHERE read = 0 AND toaddress = ?
|
' FROM inbox, subscriptions'
|
||||||
GROUP BY inbox.fromaddress, folder''', str_broadcast_subscribers)
|
' ON subscriptions.address = inbox.fromaddress WHERE read = 0'
|
||||||
for row in queryreturn:
|
' AND toaddress = ? GROUP BY inbox.fromaddress, folder',
|
||||||
address, folder, cnt = row
|
str_broadcast_subscribers)
|
||||||
|
for address, folder, cnt in queryreturn:
|
||||||
if folder not in ret[address]:
|
if folder not in ret[address]:
|
||||||
ret[address][folder] = {
|
ret[address][folder] = {
|
||||||
'label': ret[address]['inbox']['label'],
|
'label': ret[address]['inbox']['label'],
|
||||||
|
@ -105,7 +104,9 @@ class AccountColor(AccountMixin):
|
||||||
elif BMConfigParser().safeGetBoolean(self.address, 'chan'):
|
elif BMConfigParser().safeGetBoolean(self.address, 'chan'):
|
||||||
self.type = AccountMixin.CHAN
|
self.type = AccountMixin.CHAN
|
||||||
elif sqlQuery(
|
elif sqlQuery(
|
||||||
'''select label from subscriptions where address=?''', self.address):
|
'SELECT label FROM subscriptions WHERE address=?',
|
||||||
|
self.address
|
||||||
|
):
|
||||||
self.type = AccountMixin.SUBSCRIPTION
|
self.type = AccountMixin.SUBSCRIPTION
|
||||||
else:
|
else:
|
||||||
self.type = AccountMixin.NORMAL
|
self.type = AccountMixin.NORMAL
|
||||||
|
@ -149,28 +150,25 @@ class BMAccount(NoAccount):
|
||||||
self.type = AccountMixin.MAILINGLIST
|
self.type = AccountMixin.MAILINGLIST
|
||||||
elif self.address == str_broadcast_subscribers:
|
elif self.address == str_broadcast_subscribers:
|
||||||
self.type = AccountMixin.BROADCAST
|
self.type = AccountMixin.BROADCAST
|
||||||
else:
|
elif sqlQuery(
|
||||||
queryreturn = sqlQuery(
|
'SELECT label FROM subscriptions WHERE address=?', self.address
|
||||||
'''select label from subscriptions where address=?''', self.address)
|
):
|
||||||
if queryreturn:
|
self.type = AccountMixin.SUBSCRIPTION
|
||||||
self.type = AccountMixin.SUBSCRIPTION
|
|
||||||
|
|
||||||
def getLabel(self, address=None):
|
def getLabel(self, address=None):
|
||||||
"""Get a label for this bitmessage account"""
|
"""Get a label for this bitmessage account"""
|
||||||
address = super(BMAccount, self).getLabel(address)
|
address = super(BMAccount, self).getLabel(address)
|
||||||
label = BMConfigParser().safeGet(address, 'label', address)
|
label = BMConfigParser().safeGet(address, 'label', address)
|
||||||
queryreturn = sqlQuery(
|
queryreturn = sqlQuery(
|
||||||
'''select label from addressbook where address=?''', address)
|
'SELECT label FROM addressbook WHERE address=?', address)
|
||||||
if queryreturn != []:
|
if queryreturn:
|
||||||
for row in queryreturn:
|
label = queryreturn[-1][0]
|
||||||
label, = row
|
|
||||||
else:
|
else:
|
||||||
queryreturn = sqlQuery(
|
queryreturn = sqlQuery(
|
||||||
'''select label from subscriptions where address=?''', address)
|
'SELECT label FROM subscriptions WHERE address=?', address)
|
||||||
if queryreturn != []:
|
if queryreturn:
|
||||||
for row in queryreturn:
|
label = queryreturn[-1][0]
|
||||||
label, = row
|
return label.decode('utf-8')
|
||||||
return unicode(label, 'utf-8')
|
|
||||||
|
|
||||||
|
|
||||||
class SubscriptionAccount(BMAccount):
|
class SubscriptionAccount(BMAccount):
|
||||||
|
|
Reference in New Issue
Block a user