mpybit fixes

This commit is contained in:
lakshyacis 2019-12-10 19:07:48 +05:30
parent 8d8b04aa0c
commit e092ca7aa6
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB
2 changed files with 18 additions and 15 deletions

View File

@ -4,7 +4,9 @@ Sql queries for bitmessagekivy
from helper_sql import sqlQuery from helper_sql import sqlQuery
def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, what=None, unreadOnly=False, start_indx=0, end_indx=20): def search_sql(
xAddress="toaddress", account=None, folder="inbox", where=None,
what=None, unreadOnly=False, start_indx=0, end_indx=20):
"""Method helping for searching mails""" """Method helping for searching mails"""
# pylint: disable=too-many-arguments, too-many-branches # pylint: disable=too-many-arguments, too-many-branches
if what is not None and what != "": if what is not None and what != "":
@ -14,14 +16,14 @@ def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, w
if folder == "sent" or folder == "draft": if folder == "sent" or folder == "draft":
sqlStatementBase = ( sqlStatementBase = (
'''SELECT toaddress, fromaddress, subject, message, status, ackdata,''' '''SELECT toaddress, fromaddress, subject, message, status,'''
''' lastactiontime FROM sent ''') ''' ackdata, lastactiontime FROM sent ''')
elif folder == "addressbook": elif folder == "addressbook":
sqlStatementBase = '''SELECT label, address From addressbook ''' sqlStatementBase = '''SELECT label, address From addressbook '''
else: else:
sqlStatementBase = ( sqlStatementBase = (
'''SELECT folder, msgid, toaddress, message, fromaddress, subject,''' '''SELECT folder, msgid, toaddress, message, fromaddress,'''
''' received, read FROM inbox ''') ''' subject, received, read FROM inbox ''')
sqlStatementParts = [] sqlStatementParts = []
sqlArguments = [] sqlArguments = []
@ -59,9 +61,13 @@ def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, w
if sqlStatementParts: if sqlStatementParts:
sqlStatementBase += "WHERE " + " AND ".join(sqlStatementParts) sqlStatementBase += "WHERE " + " AND ".join(sqlStatementParts)
if folder == "sent" or folder == "draft": if folder == "sent" or folder == "draft":
sqlStatementBase += " ORDER BY lastactiontime DESC limit {0}, {1}".format(start_indx, end_indx) sqlStatementBase += \
" ORDER BY lastactiontime DESC limit {0}, {1}".format(
start_indx, end_indx)
elif folder == "inbox": elif folder == "inbox":
sqlStatementBase += " ORDER BY received DESC limit {0}, {1}".format(start_indx, end_indx) sqlStatementBase += \
" ORDER BY received DESC limit {0}, {1}".format(
start_indx, end_indx)
# elif folder == "addressbook": # elif folder == "addressbook":
# sqlStatementBase += " limit {0}, {1}".format(start_indx, end_indx) # sqlStatementBase += " limit {0}, {1}".format(start_indx, end_indx)
return sqlQuery(sqlStatementBase, sqlArguments) return sqlQuery(sqlStatementBase, sqlArguments)

View File

@ -62,7 +62,7 @@ import state
from uikivysignaler import UIkivySignaler from uikivysignaler import UIkivySignaler
import identiconGeneration import identiconGeneration
from addresses import addBMIfNotPresent, decodeAddress, encodeVarint from addresses import addBMIfNotPresent, decodeAddress
def toast(text): def toast(text):
@ -590,7 +590,6 @@ class DropDownWidget(BoxLayout):
sendMessageToPeople = True sendMessageToPeople = True
if sendMessageToPeople: if sendMessageToPeople:
if toAddress != '' and subject and message: if toAddress != '' and subject and message:
from addresses import decodeAddress
status, addressVersionNumber, streamNumber, ripe = ( status, addressVersionNumber, streamNumber, ripe = (
decodeAddress(toAddress)) decodeAddress(toAddress))
if status == 'success': if status == 'success':
@ -612,7 +611,6 @@ class DropDownWidget(BoxLayout):
state.detailPageType = '' state.detailPageType = ''
state.send_draft_mail = None state.send_draft_mail = None
else: else:
from addresses import addBMIfNotPresent
toAddress = addBMIfNotPresent(toAddress) toAddress = addBMIfNotPresent(toAddress)
statusIconColor = 'red' statusIconColor = 'red'
if (addressVersionNumber > 4) or ( if (addressVersionNumber > 4) or (
@ -1708,7 +1706,7 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
self.root.ids.scr_mngr.current = 'allmails' self.root.ids.scr_mngr.current = 'allmails'
try: try:
self.root.ids.sc17.children[1].active = True self.root.ids.sc17.children[1].active = True
except Exception as e: except Exception:
self.root.ids.sc17.children[0].children[1].active = True self.root.ids.sc17.children[0].children[1].active = True
Clock.schedule_once(partial(self.load_screen_callback, instance), 1) Clock.schedule_once(partial(self.load_screen_callback, instance), 1)
@ -1723,7 +1721,7 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
self.root.ids.sc17.add_widget(Allmails()) self.root.ids.sc17.add_widget(Allmails())
try: try:
self.root.ids.sc17.children[1].active = False self.root.ids.sc17.children[1].active = False
except Exception as e: except Exception:
self.root.ids.sc17.children[0].children[1].active = False self.root.ids.sc17.children[0].children[1].active = False
@ -1843,7 +1841,8 @@ class GrashofPopup(Popup):
elif status == 'checksumfailed': elif status == 'checksumfailed':
text = "The address is not typed or copied correctly(the checksum failed)." text = "The address is not typed or copied correctly(the checksum failed)."
elif status == 'versiontoohigh': elif status == 'versiontoohigh':
text = "The version number of this address is higher than this software can support. Please upgrade Bitmessage." text = "The version number of this address is higher"\
" than this software can support. Please upgrade Bitmessage."
elif status == 'invalidcharacters': elif status == 'invalidcharacters':
text = "The address contains invalid characters." text = "The address contains invalid characters."
elif status == 'ripetooshort': elif status == 'ripetooshort':
@ -2311,9 +2310,7 @@ class Draft(Screen):
encoding = 3 encoding = 3
sendMessageToPeople = True sendMessageToPeople = True
if sendMessageToPeople: if sendMessageToPeople:
from addresses import decodeAddress
streamNumber, ripe = decodeAddress(toAddress)[2:] streamNumber, ripe = decodeAddress(toAddress)[2:]
from addresses import addBMIfNotPresent
toAddress = addBMIfNotPresent(toAddress) toAddress = addBMIfNotPresent(toAddress)
stealthLevel = BMConfigParser().safeGetInt( stealthLevel = BMConfigParser().safeGetInt(
'bitmessagesettings', 'ackstealthlevel') 'bitmessagesettings', 'ackstealthlevel')