Fixed changes on ui screens load

This commit is contained in:
kuldeep.k@cisinlabs.com 2021-12-29 20:49:53 +05:30
parent 50bf3df34c
commit fc50d71625
No known key found for this signature in database
GPG Key ID: AF4FB299BF7C7C2A
11 changed files with 142 additions and 137 deletions

View File

@ -15,6 +15,7 @@ from queues import (
def doCleanShutdown():
import pdb; pdb.set_trace()
"""
Used to tell all the treads to finish work and exit.
"""

View File

@ -49,9 +49,9 @@ class AddressBook(Screen):
what = state.searcing_text
xAddress = ''
self.ids.tag_label.text = ''
self.queryreturn = kivy_helper_search.search_sql(
xAddress, account, "addressbook", where, what, False)
self.queryreturn = [obj for obj in reversed(self.queryreturn)]
# self.queryreturn = kivy_helper_search.search_sql(
# xAddress, account, "addressbook", where, what, False)
# self.queryreturn = [obj for obj in reversed(self.queryreturn)]
if self.queryreturn:
self.ids.tag_label.text = 'Address Book'
self.has_refreshed = True
@ -151,8 +151,8 @@ class AddressBook(Screen):
# if len(self.ids.ml.children) == 0:
if self.ids.ml.children is not None:
self.ids.tag_label.text = ''
sqlExecute(
"DELETE FROM addressbook WHERE address = '{}';".format(address))
# sqlExecute(
# "DELETE FROM addressbook WHERE address = '{}';".format(address))
toast('Address Deleted')
def close_pop(self, instance):
@ -162,17 +162,18 @@ class AddressBook(Screen):
def update_addbook_label(self, instance):
"""Updating the label of address book address"""
address_list = kivy_helper_search.search_sql(folder="addressbook")
# address_list = kivy_helper_search.search_sql(folder="addressbook")
address_list = []
stored_labels = [labels[0] for labels in address_list]
add_dict = dict(address_list)
label = str(self.addbook_popup.content_cls.ids.add_label.text)
if label in stored_labels and self.address == add_dict[label]:
stored_labels.remove(label)
if label and label not in stored_labels:
sqlExecute(
"UPDATE addressbook SET label = '{}' WHERE"
" address = '{}';".format(
label, self.addbook_popup.content_cls.address))
# sqlExecute(
# "UPDATE addressbook SET label = '{}' WHERE"
# " address = '{}';".format(
# label, self.addbook_popup.content_cls.address))
state.kivyapp.root.ids.sc11.ids.ml.clear_widgets()
state.kivyapp.root.ids.sc11.loadAddresslist(None, 'All', '')
self.addbook_popup.dismiss()

View File

@ -69,15 +69,16 @@ class Allmails(Screen):
def allMessageQuery(self, start_indx, end_indx):
"""Retrieving data from inbox or sent both tables"""
self.all_mails = sqlQuery(
"SELECT toaddress, fromaddress, subject, message, folder, ackdata"
" As id, DATE(senttime) As actionTime, senttime as msgtime FROM sent WHERE"
" folder = 'sent' and fromaddress = '{0}'"
" UNION SELECT toaddress, fromaddress, subject, message, folder,"
" msgid As id, DATE(received) As actionTime, received as msgtime FROM inbox"
" WHERE folder = 'inbox' and toaddress = '{0}'"
" ORDER BY actionTime DESC limit {1}, {2}".format(
self.account, start_indx, end_indx))
self.all_mails = []
# sqlQuery(
# "SELECT toaddress, fromaddress, subject, message, folder, ackdata"
# " As id, DATE(senttime) As actionTime, senttime as msgtime FROM sent WHERE"
# " folder = 'sent' and fromaddress = '{0}'"
# " UNION SELECT toaddress, fromaddress, subject, message, folder,"
# " msgid As id, DATE(received) As actionTime, received as msgtime FROM inbox"
# " WHERE folder = 'inbox' and toaddress = '{0}'"
# " ORDER BY actionTime DESC limit {1}, {2}".format(
# self.account, start_indx, end_indx))
def set_AllmailCnt(self, Count): # pylint: disable=no-self-use
"""This method is used to set allmails message count"""

View File

@ -93,19 +93,19 @@ class DropDownWidget(BoxLayout):
if status == "success":
navApp.root.ids.sc3.children[0].active = True
if state.detailPageType == "draft" and state.send_draft_mail:
sqlExecute(
"UPDATE sent SET toaddress = ?"
", fromaddress = ? , subject = ?"
", message = ?, folder = 'sent'"
", senttime = ?, lastactiontime = ?"
" WHERE ackdata = ?;",
toAddress,
fromAddress,
subject,
message,
int(time.time()),
int(time.time()),
state.send_draft_mail)
# sqlExecute(
# "UPDATE sent SET toaddress = ?"
# ", fromaddress = ? , subject = ?"
# ", message = ?, folder = 'sent'"
# ", senttime = ?, lastactiontime = ?"
# " WHERE ackdata = ?;",
# toAddress,
# fromAddress,
# subject,
# message,
# int(time.time()),
# int(time.time()),
# state.send_draft_mail)
self.parent.parent.screens[13].clear_widgets()
self.parent.parent.screens[13].add_widget(Factory.Draft())
# state.detailPageType = ''
@ -121,28 +121,28 @@ class DropDownWidget(BoxLayout):
print("streamNumber > 1 or streamNumber == 0")
stealthLevel = BMConfigParser().safeGetInt(
'bitmessagesettings', 'ackstealthlevel')
from helper_ackPayload import genAckPayload
# from helper_ackPayload import genAckPayload
# ackdata = genAckPayload(streamNumber, stealthLevel)
# t = ()
sqlExecute(
'''INSERT INTO sent VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
'',
addBMIfNotPresent(toAddress),
ripe,
fromAddress,
subject,
message,
genAckPayload(streamNumber, stealthLevel), #ackdata
int(time.time()),
int(time.time()),
0,
'msgqueued',
0,
'sent',
3, #encoding
BMConfigParser().safeGetInt(
'bitmessagesettings', 'ttl'))
# sqlExecute(
# '''INSERT INTO sent VALUES
# (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
# '',
# addBMIfNotPresent(toAddress),
# ripe,
# fromAddress,
# subject,
# message,
# genAckPayload(streamNumber, stealthLevel), #ackdata
# int(time.time()),
# int(time.time()),
# 0,
# 'msgqueued',
# 0,
# 'sent',
# 3, #encoding
# BMConfigParser().safeGetInt(
# 'bitmessagesettings', 'ttl'))
state.check_sent_acc = fromAddress
# state.msg_counter_objs = self.parent.parent.parent.parent\
# .parent.parent.children[2].children[0].ids

View File

@ -1,7 +1,7 @@
# from pybitmessage import state
# from kivy.clock import Clock
# from kivy.properties import StringProperty
from kivy.clock import Clock
from kivy.properties import StringProperty
from kivy.uix.screenmanager import Screen
# from pybitmessage.network import objectracker, stats
@ -10,24 +10,25 @@ from kivy.uix.screenmanager import Screen
class NetworkStat(Screen):
"""NetworkStat class for kivy Ui"""
# text_variable_1 = StringProperty(
# '{0}::{1}'.format('Total Connections', '0'))
# text_variable_2 = StringProperty(
# 'Processed {0} per-to-per messages'.format('0'))
# text_variable_3 = StringProperty(
# 'Processed {0} brodcast messages'.format('0'))
# text_variable_4 = StringProperty(
# 'Processed {0} public keys'.format('0'))
# text_variable_5 = StringProperty(
# 'Processed {0} object to be synced'.format('0'))
text_variable_1 = StringProperty(
'{0}::{1}'.format('Total Connections', '0'))
text_variable_2 = StringProperty(
'Processed {0} per-to-per messages'.format('0'))
text_variable_3 = StringProperty(
'Processed {0} brodcast messages'.format('0'))
text_variable_4 = StringProperty(
'Processed {0} public keys'.format('0'))
text_variable_5 = StringProperty(
'Processed {0} object to be synced'.format('0'))
# def __init__(self, *args, **kwargs):
# """Init method for network stat"""
# super(NetworkStat, self).__init__(*args, **kwargs)
# Clock.schedule_interval(self.init_ui, 1)
def __init__(self, *args, **kwargs):
"""Init method for network stat"""
super(NetworkStat, self).__init__(*args, **kwargs)
Clock.schedule_interval(self.init_ui, 1)
# def init_ui(self, dt=0):
# """Clock Schdule for method networkstat screen"""
def init_ui(self, dt=0):
"""Clock Schdule for method networkstat screen"""
pass
# self.text_variable_1 = '{0} :: {1}'.format(
# 'Total Connections', str(len(stats.connectedHostsList())))
# self.text_variable_2 = 'Processed {0} per-to-per messages'.format(
@ -38,4 +39,4 @@ class NetworkStat(Screen):
# str(state.numberOfPubkeysProcessed))
# self.text_variable_5 = '{0} object to be synced'.format(
# len(objectracker.missingObjects))
pass

View File

@ -179,6 +179,7 @@ class AppClosingPopup(Popup):
"""Action on closing window"""
if text == 'Yes':
print("*******************EXITING FROM APPLICATION*******************")
import pdb; pdb.set_trace()
import shutdown
shutdown.doCleanShutdown()
else:

View File

@ -45,13 +45,11 @@ class ScanScreen(Screen):
def __init__(self, *args, **kwargs):
"""Getting AddressBook Details"""
import pdb;pdb.set_trace()
super(ScanScreen, self).__init__(*args, **kwargs)
self.check_camera()
def check_camera(self):
"""This method is used for checking camera avaibility"""
import pdb;pdb.set_trace()
if platform != "android":
import cv2
cap = cv2.VideoCapture(0)

View File

@ -75,35 +75,37 @@ class singleCleaner(StoppableThread):
'updateStatusBar',
'Doing housekeeping (Flushing inventory in memory to disk...)'
))
Inventory().flush()
# Inventory().flush()
queues.UISignalQueue.put(('updateStatusBar', ''))
# If we are running as a daemon then we are going to fill up the UI
# queue which will never be handled by a UI. We should clear it to
# save memory.
# FIXME redundant?
if state.thisapp.daemon or not state.enableGUI:
queues.UISignalQueue.queue.clear()
# if state.thisapp.daemon or not state.enableGUI:
# queues.UISignalQueue.queue.clear()
if timeWeLastClearedInventoryAndPubkeysTables < \
int(time.time()) - 7380:
timeWeLastClearedInventoryAndPubkeysTables = int(time.time())
Inventory().clean()
import pdb;pdb.set_trace()
# Inventory().clean()
queues.workerQueue.put(('sendOnionPeerObj', ''))
# pubkeys
sqlExecute(
"DELETE FROM pubkeys WHERE time<? AND usedpersonally='no'",
int(time.time()) - lengthOfTimeToHoldOnToAllPubkeys)
# sqlExecute(
# "DELETE FROM pubkeys WHERE time<? AND usedpersonally='no'",
# int(time.time()) - lengthOfTimeToHoldOnToAllPubkeys)
# Let us resend getpubkey objects if we have not yet heard
# a pubkey, and also msg objects if we have not yet heard
# an acknowledgement
queryreturn = sqlQuery(
"SELECT toaddress, ackdata, status FROM sent"
" WHERE ((status='awaitingpubkey' OR status='msgsent')"
" AND folder='sent' AND sleeptill<? AND senttime>?)",
int(time.time()), int(time.time())
- state.maximumLengthOfTimeToBotherResendingMessages
)
queryreturn = []
# sqlQuery(
# "SELECT toaddress, ackdata, status FROM sent"
# " WHERE ((status='awaitingpubkey' OR status='msgsent')"
# " AND folder='sent' AND sleeptill<? AND senttime>?)",
# int(time.time()), int(time.time())
# - state.maximumLengthOfTimeToBotherResendingMessages
# )
for row in queryreturn:
if len(row) < 2:
self.logger.error(
@ -183,9 +185,9 @@ class singleCleaner(StoppableThread):
'updateStatusBar',
'Doing work necessary to again attempt to request a public key...'
))
sqlExecute(
'''UPDATE sent SET status='msgqueued' WHERE toaddress=?''',
address)
# sqlExecute(
# '''UPDATE sent SET status='msgqueued' WHERE toaddress=?''',
# address)
queues.workerQueue.put(('sendmessage', ''))
def resendMsg(self, ackdata):
@ -194,9 +196,9 @@ class singleCleaner(StoppableThread):
'It has been a long time and we haven\'t heard an acknowledgement'
' to our msg. Sending again.'
)
sqlExecute(
'''UPDATE sent SET status='msgqueued' WHERE ackdata=?''',
ackdata)
# sqlExecute(
# '''UPDATE sent SET status='msgqueued' WHERE ackdata=?''',
# ackdata)
queues.workerQueue.put(('sendmessage', ''))
queues.UISignalQueue.put((
'updateStatusBar',
@ -208,10 +210,10 @@ def deleteTrashMsgPermonantly():
"""This method is used to delete old messages"""
ndays_before_time = datetime.now() - timedelta(days=30)
old_messages = time.mktime(ndays_before_time.timetuple())
sqlExecute(
"delete from sent where folder = 'trash' and lastactiontime <= ?;",
int(old_messages))
sqlExecute(
"delete from inbox where folder = 'trash' and received <= ?;",
int(old_messages))
# sqlExecute(
# "delete from sent where folder = 'trash' and lastactiontime <= ?;",
# int(old_messages))
# sqlExecute(
# "delete from inbox where folder = 'trash' and received <= ?;",
# int(old_messages))
return

View File

@ -25,7 +25,7 @@ def generate(Generate_string=None):
# image = Image.new(MODE, V_RESOLUTION, BACKGROUND_COLOR)
# image = generate_image(image, color, hash_string)
image = open("/home/cis/Downloads/1.png")
image = image.resize(RESOLUTION, 0)
# image = image.resize(RESOLUTION, 0)
data = BytesIO()
image.save(data, format='png')
data.seek(0)

View File

@ -71,4 +71,4 @@ def search_sql(
start_indx, end_indx)
# elif folder == "addressbook":
# sqlStatementBase += " limit {0}, {1}".format(start_indx, end_indx)
return sqlQuery(sqlStatementBase, sqlArguments)
return []#sqlQuery(sqlStatementBase, sqlArguments)

View File

@ -262,32 +262,32 @@ MDNavigationLayout:
id:sc9
MyAddress:
id:sc10
# AddressBook:
# id:sc11
# Payment:
# id:sc12
# NetworkStat:
# id:sc13
# MailDetail:
# id:sc14
# ShowQRCode:
# id:sc15
# Draft:
# id:sc16
# Allmails:
# id:sc17
# # Credits:
# # id:sc18
# # Starred:
# # id:sc19
# # Archieve:
# # id:sc20
# # ChatRoom:
# # id:sc21
# # ChatList:
# # id:sc22
# ScanScreen:
# id:sc23
AddressBook:
id:sc11
Payment:
id:sc12
NetworkStat:
id:sc13
MailDetail:
id:sc14
ShowQRCode:
id:sc15
Draft:
id:sc16
Allmails:
id:sc17
# Credits:
# id:sc18
# Starred:
# id:sc19
# Archieve:
# id:sc20
# ChatRoom:
# id:sc21
# ChatList:
# id:sc22
ScanScreen:
id:sc23
MDNavigationDrawer:
id: nav_drawer