Code cleanup
This commit is contained in:
parent
fc50d71625
commit
a69f2a6bbe
|
@ -51,9 +51,6 @@ import state
|
||||||
from kivymd.uix.bottomsheet import MDCustomBottomSheet
|
from kivymd.uix.bottomsheet import MDCustomBottomSheet
|
||||||
|
|
||||||
from kivy.lang import Observable
|
from kivy.lang import Observable
|
||||||
# import gettext
|
|
||||||
# import l10n
|
|
||||||
# import locale
|
|
||||||
import ast
|
import ast
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import toast
|
from bitmessagekivy.baseclass.common import toast
|
||||||
|
@ -209,7 +206,6 @@ class NavigateApp(MDApp):
|
||||||
"""Navigation Layout of class"""
|
"""Navigation Layout of class"""
|
||||||
# pylint: disable=too-many-public-methods,inconsistent-return-statements
|
# pylint: disable=too-many-public-methods,inconsistent-return-statements
|
||||||
|
|
||||||
# theme_cls = ThemeManager()
|
|
||||||
previous_date = ObjectProperty()
|
previous_date = ObjectProperty()
|
||||||
obj_1 = ObjectProperty()
|
obj_1 = ObjectProperty()
|
||||||
variable_1 = ListProperty(addr for addr in BMConfigParser().addresses()
|
variable_1 = ListProperty(addr for addr in BMConfigParser().addresses()
|
||||||
|
@ -238,8 +234,6 @@ class NavigateApp(MDApp):
|
||||||
'{0}.kv'.format(all_data[kv]["kv_string"]),
|
'{0}.kv'.format(all_data[kv]["kv_string"]),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
print('{0}.kv'.format(all_data[kv]["kv_string"]))
|
|
||||||
# import pdb; pdb.set_trace()
|
|
||||||
# self.obj_1 = AddressBook()
|
# self.obj_1 = AddressBook()
|
||||||
kivysignalthread = UIkivySignaler()
|
kivysignalthread = UIkivySignaler()
|
||||||
kivysignalthread.daemon = True
|
kivysignalthread.daemon = True
|
||||||
|
@ -247,26 +241,20 @@ class NavigateApp(MDApp):
|
||||||
Window.bind(on_keyboard=self.on_key, on_request_close=self.on_request_close)
|
Window.bind(on_keyboard=self.on_key, on_request_close=self.on_request_close)
|
||||||
return Builder.load_file(
|
return Builder.load_file(
|
||||||
os.path.join(os.path.dirname(__file__), 'main.kv'))
|
os.path.join(os.path.dirname(__file__), 'main.kv'))
|
||||||
# return Builder.load_file('/home/cis/Bitmessagepeter/KivyPoject/PyBitmessage/src/tests/mock/pybitmessage/main.kv')
|
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Running the widgets"""
|
"""Running the widgets"""
|
||||||
print('run 251 ---------------------------------')
|
|
||||||
kivyuisignaler.release()
|
kivyuisignaler.release()
|
||||||
super(NavigateApp, self).run()
|
super(NavigateApp, self).run()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def showmeaddresses(name="text"):
|
def showmeaddresses(name="text"):
|
||||||
print('showmeaddresses 257 ---------------------------------')
|
|
||||||
"""Show the addresses in spinner to make as dropdown"""
|
"""Show the addresses in spinner to make as dropdown"""
|
||||||
if name == "text":
|
if name == "text":
|
||||||
print('if')
|
|
||||||
if BMConfigParser().addresses():
|
if BMConfigParser().addresses():
|
||||||
return BMConfigParser().addresses()[0][:16] + '..'
|
return BMConfigParser().addresses()[0][:16] + '..'
|
||||||
return "textdemo"
|
return "textdemo"
|
||||||
elif name == "values":
|
elif name == "values":
|
||||||
print('else')
|
|
||||||
if BMConfigParser().addresses():
|
if BMConfigParser().addresses():
|
||||||
return [address[:16] + '..'
|
return [address[:16] + '..'
|
||||||
for address in BMConfigParser().addresses()]
|
for address in BMConfigParser().addresses()]
|
||||||
|
@ -274,28 +262,26 @@ class NavigateApp(MDApp):
|
||||||
|
|
||||||
def getCurrentAccountData(self, text):
|
def getCurrentAccountData(self, text):
|
||||||
"""Get Current Address Account Data"""
|
"""Get Current Address Account Data"""
|
||||||
# print('getCurrentAccountData 273 ---------------------------------')
|
if text != '':
|
||||||
# if text != '':
|
if os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(text)):
|
||||||
# if os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(text)):
|
self.load_selected_Image(text)
|
||||||
# self.load_selected_Image(text)
|
else:
|
||||||
# else:
|
self.set_identicon(text)
|
||||||
# self.set_identicon(text)
|
self.root.ids.content_drawer.ids.reset_image.opacity = 0
|
||||||
# self.root.ids.content_drawer.ids.reset_image.opacity = 0
|
self.root.ids.content_drawer.ids.reset_image.disabled = True
|
||||||
# self.root.ids.content_drawer.ids.reset_image.disabled = True
|
address_label = self.current_address_label(
|
||||||
# address_label = self.current_address_label(
|
BMConfigParser().get(text, 'label'), text)
|
||||||
# BMConfigParser().get(text, 'label'), text)
|
|
||||||
|
|
||||||
# self.root_window.children[1].ids.toolbar.title = address_label
|
self.root_window.children[1].ids.toolbar.title = address_label
|
||||||
# state.association = text
|
state.association = text
|
||||||
# state.searcing_text = ''
|
state.searcing_text = ''
|
||||||
# LoadingPopup().open()
|
LoadingPopup().open()
|
||||||
# self.set_message_count()
|
self.set_message_count()
|
||||||
# for nav_obj in self.root.ids.content_drawer.children[
|
for nav_obj in self.root.ids.content_drawer.children[
|
||||||
# 0].children[0].children[0].children:
|
0].children[0].children[0].children:
|
||||||
# nav_obj.active = True if nav_obj.text == 'Inbox' else False
|
nav_obj.active = True if nav_obj.text == 'Inbox' else False
|
||||||
# self.fileManagerSetting()
|
self.fileManagerSetting()
|
||||||
# Clock.schedule_once(self.setCurrentAccountData, 0.5)
|
Clock.schedule_once(self.setCurrentAccountData, 0.5)
|
||||||
pass
|
|
||||||
|
|
||||||
def fileManagerSetting(self):
|
def fileManagerSetting(self):
|
||||||
"""This method is for file manager setting"""
|
"""This method is for file manager setting"""
|
||||||
|
@ -306,33 +292,29 @@ class NavigateApp(MDApp):
|
||||||
|
|
||||||
def setCurrentAccountData(self, dt=0):
|
def setCurrentAccountData(self, dt=0):
|
||||||
"""This method set the current accout data on all the screens"""
|
"""This method set the current accout data on all the screens"""
|
||||||
print('setCurrentAccountData 304 ---------------------------------')
|
self.root.ids.sc1.ids.ml.clear_widgets()
|
||||||
|
self.root.ids.sc1.loadMessagelist(state.association)
|
||||||
|
|
||||||
# self.root.ids.sc1.ids.ml.clear_widgets()
|
self.root.ids.sc4.ids.ml.clear_widgets()
|
||||||
# self.root.ids.sc1.loadMessagelist(state.association)
|
self.root.ids.sc4.children[2].children[2].ids.search_field.text = ''
|
||||||
|
self.root.ids.sc4.loadSent(state.association)
|
||||||
|
|
||||||
# self.root.ids.sc4.ids.ml.clear_widgets()
|
self.root.ids.sc16.clear_widgets()
|
||||||
# self.root.ids.sc4.children[2].children[2].ids.search_field.text = ''
|
self.root.ids.sc16.add_widget(Draft())
|
||||||
# self.root.ids.sc4.loadSent(state.association)
|
|
||||||
|
|
||||||
# self.root.ids.sc16.clear_widgets()
|
self.root.ids.sc5.clear_widgets()
|
||||||
# self.root.ids.sc16.add_widget(Draft())
|
self.root.ids.sc5.add_widget(Trash())
|
||||||
|
|
||||||
# self.root.ids.sc5.clear_widgets()
|
self.root.ids.sc17.clear_widgets()
|
||||||
# self.root.ids.sc5.add_widget(Trash())
|
self.root.ids.sc17.add_widget(Allmails())
|
||||||
|
|
||||||
# self.root.ids.sc17.clear_widgets()
|
self.root.ids.sc10.ids.ml.clear_widgets()
|
||||||
# self.root.ids.sc17.add_widget(Allmails())
|
self.root.ids.sc10.init_ui()
|
||||||
|
|
||||||
# self.root.ids.sc10.ids.ml.clear_widgets()
|
|
||||||
# self.root.ids.sc10.init_ui()
|
|
||||||
|
|
||||||
self.root.ids.scr_mngr.current = 'inbox'
|
self.root.ids.scr_mngr.current = 'inbox'
|
||||||
pass
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getCurrentAccount():
|
def getCurrentAccount():
|
||||||
print('getCurrentAccount 329 ----------------------------')
|
|
||||||
"""It uses to get current account label"""
|
"""It uses to get current account label"""
|
||||||
if state.association:
|
if state.association:
|
||||||
return state.association
|
return state.association
|
||||||
|
@ -381,47 +363,45 @@ class NavigateApp(MDApp):
|
||||||
toast(altet_txt)
|
toast(altet_txt)
|
||||||
|
|
||||||
def is_camara_attached(self):
|
def is_camara_attached(self):
|
||||||
print('is_camara_attached -----------------------378')
|
|
||||||
"""This method is for checking is camera available or not"""
|
"""This method is for checking is camera available or not"""
|
||||||
self.root.ids.sc23.check_camera()
|
self.root.ids.sc23.check_camera()
|
||||||
is_available = self.root.ids.sc23.camera_avaialbe
|
is_available = self.root.ids.sc23.camera_avaialbe
|
||||||
return is_available
|
return is_available
|
||||||
|
|
||||||
def savecontact(self, instance):
|
def savecontact(self, instance):
|
||||||
# """Method is used for saving contacts"""
|
"""Method is used for saving contacts"""
|
||||||
# pupup_obj = self.add_popup.content_cls
|
pupup_obj = self.add_popup.content_cls
|
||||||
# label = pupup_obj.ids.label.text.strip()
|
label = pupup_obj.ids.label.text.strip()
|
||||||
# address = pupup_obj.ids.address.text.strip()
|
address = pupup_obj.ids.address.text.strip()
|
||||||
# if label == '' and address == '':
|
if label == '' and address == '':
|
||||||
|
pupup_obj.ids.label.focus = True
|
||||||
|
pupup_obj.ids.address.focus = True
|
||||||
|
elif address == '':
|
||||||
|
pupup_obj.ids.address.focus = True
|
||||||
|
elif label == '':
|
||||||
|
pupup_obj.ids.label.focus = True
|
||||||
|
else:
|
||||||
|
pupup_obj.ids.address.focus = True
|
||||||
# pupup_obj.ids.label.focus = True
|
# pupup_obj.ids.label.focus = True
|
||||||
# pupup_obj.ids.address.focus = True
|
|
||||||
# elif address == '':
|
|
||||||
# pupup_obj.ids.address.focus = True
|
|
||||||
# elif label == '':
|
|
||||||
# pupup_obj.ids.label.focus = True
|
|
||||||
# else:
|
|
||||||
# pupup_obj.ids.address.focus = True
|
|
||||||
# # pupup_obj.ids.label.focus = True
|
|
||||||
|
|
||||||
# stored_address = [addr[1] for addr in kivy_helper_search.search_sql(
|
stored_address = [addr[1] for addr in kivy_helper_search.search_sql(
|
||||||
# folder="addressbook")]
|
folder="addressbook")]
|
||||||
# stored_labels = [labels[0] for labels in kivy_helper_search.search_sql(
|
stored_labels = [labels[0] for labels in kivy_helper_search.search_sql(
|
||||||
# folder="addressbook")]
|
folder="addressbook")]
|
||||||
# if label and address and address not in stored_address \
|
if label and address and address not in stored_address \
|
||||||
# and label not in stored_labels and pupup_obj.valid:
|
and label not in stored_labels and pupup_obj.valid:
|
||||||
# # state.navinstance = self.parent.children[1]
|
# state.navinstance = self.parent.children[1]
|
||||||
# queues.UISignalQueue.put(('rerenderAddressBook', ''))
|
queues.UISignalQueue.put(('rerenderAddressBook', ''))
|
||||||
# self.add_popup.dismiss()
|
self.add_popup.dismiss()
|
||||||
# sqlExecute("INSERT INTO addressbook VALUES(?,?)", label, address)
|
sqlExecute("INSERT INTO addressbook VALUES(?,?)", label, address)
|
||||||
# try:
|
try:
|
||||||
# rootIds = self.root.ids
|
rootIds = self.root.ids
|
||||||
# except Exception as e:
|
except Exception as e:
|
||||||
# rootIds = state.kivyapp.root.ids
|
rootIds = state.kivyapp.root.ids
|
||||||
# rootIds.sc11.ids.ml.clear_widgets()
|
rootIds.sc11.ids.ml.clear_widgets()
|
||||||
# rootIds.sc11.loadAddresslist(None, 'All', '')
|
rootIds.sc11.loadAddresslist(None, 'All', '')
|
||||||
# rootIds.scr_mngr.current = 'addressbook'
|
rootIds.scr_mngr.current = 'addressbook'
|
||||||
# toast('Saved')
|
toast('Saved')
|
||||||
pass
|
|
||||||
|
|
||||||
def close_pop(self, instance):
|
def close_pop(self, instance):
|
||||||
"""Pop is Canceled"""
|
"""Pop is Canceled"""
|
||||||
|
@ -430,290 +410,263 @@ class NavigateApp(MDApp):
|
||||||
|
|
||||||
def getDefaultAccData(self, instance):
|
def getDefaultAccData(self, instance):
|
||||||
"""Getting Default Account Data"""
|
"""Getting Default Account Data"""
|
||||||
print('getDefaultAccData---------------------------------')
|
|
||||||
if self.variable_1:
|
if self.variable_1:
|
||||||
state.association = first_addr = self.variable_1[0]
|
state.association = first_addr = self.variable_1[0]
|
||||||
# if BMConfigParser().get(str(first_addr), 'enabled') == 'true':
|
|
||||||
# img = identiconGeneration.generate(first_addr)
|
|
||||||
# print('line...........................................426')
|
|
||||||
# self.createFolder(state.imageDir + '/default_identicon/')
|
|
||||||
# if platform == 'android':
|
|
||||||
# # android_path = os.path.expanduser
|
|
||||||
# # ("~/user/0/org.test.bitapp/files/app/")
|
|
||||||
# if not os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(
|
|
||||||
# BMConfigParser().addresses()[0])):
|
|
||||||
# android_path = os.path.join(
|
|
||||||
# os.environ['ANDROID_PRIVATE'] + '/app/')
|
|
||||||
# img.texture.save('{1}/images/kivy/default_identicon/{0}.png'.format(
|
|
||||||
# BMConfigParser().addresses()[0], android_path))
|
|
||||||
# else:
|
|
||||||
# if not os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(
|
|
||||||
# BMConfigParser().addresses()[0])):
|
|
||||||
# img.texture.save(state.imageDir + '/default_identicon/{}.png'.format(
|
|
||||||
# BMConfigParser().addresses()[0]))
|
|
||||||
# instance.parent.parent.parent.parent.parent.ids.top_box.children[0].texture = (
|
|
||||||
# img.texture)
|
|
||||||
return first_addr
|
return first_addr
|
||||||
return 'Select Address'
|
return 'Select Address'
|
||||||
|
|
||||||
def get_default_logo(self, instance):
|
def get_default_logo(self, instance):
|
||||||
"""Getting default logo image"""
|
"""Getting default logo image"""
|
||||||
# if self.variable_1:
|
if self.variable_1:
|
||||||
# first_addr = self.variable_1[0]
|
first_addr = self.variable_1[0]
|
||||||
# if BMConfigParser().get(str(first_addr), 'enabled') == 'true':
|
if BMConfigParser().get(str(first_addr), 'enabled') == 'true':
|
||||||
# if os.path.exists(
|
if os.path.exists(
|
||||||
# state.imageDir + '/default_identicon/{}.png'.format(first_addr)):
|
state.imageDir + '/default_identicon/{}.png'.format(first_addr)):
|
||||||
# return state.imageDir + '/default_identicon/{}.png'.format(
|
return state.imageDir + '/default_identicon/{}.png'.format(
|
||||||
# first_addr)
|
first_addr)
|
||||||
# else:
|
else:
|
||||||
# img = identiconGeneration.generate(first_addr)
|
img = identiconGeneration.generate(first_addr)
|
||||||
# instance.texture = img.texture
|
instance.texture = img.texture
|
||||||
# return
|
return
|
||||||
# return state.imageDir + '/drawer_logo1.png'
|
return state.imageDir + '/drawer_logo1.png'
|
||||||
pass
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def addressexist():
|
def addressexist():
|
||||||
print('addressexist 469 --------------------------')
|
|
||||||
"""Checking address existence"""
|
"""Checking address existence"""
|
||||||
if BMConfigParser().addresses():
|
if BMConfigParser().addresses():
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def on_key(self, window, key, *args):
|
def on_key(self, window, key, *args):
|
||||||
pass
|
# pylint: disable=inconsistent-return-statements, too-many-branches
|
||||||
# # pylint: disable=inconsistent-return-statements, too-many-branches
|
"""Method is used for going on previous screen"""
|
||||||
# """Method is used for going on previous screen"""
|
if key == 27:
|
||||||
# if key == 27:
|
if state.in_search_mode and self.root.ids.scr_mngr.current not in [
|
||||||
# if state.in_search_mode and self.root.ids.scr_mngr.current not in [
|
"mailDetail", "create"]:
|
||||||
# "mailDetail", "create"]:
|
self.closeSearchScreen()
|
||||||
# self.closeSearchScreen()
|
elif self.root.ids.scr_mngr.current == "mailDetail":
|
||||||
# elif self.root.ids.scr_mngr.current == "mailDetail":
|
self.root.ids.scr_mngr.current = 'sent'\
|
||||||
# self.root.ids.scr_mngr.current = 'sent'\
|
if state.detailPageType == 'sent' else 'inbox' \
|
||||||
# if state.detailPageType == 'sent' else 'inbox' \
|
if state.detailPageType == 'inbox' else 'draft'
|
||||||
# if state.detailPageType == 'inbox' else 'draft'
|
self.back_press()
|
||||||
# self.back_press()
|
if state.in_search_mode and state.searcing_text:
|
||||||
# if state.in_search_mode and state.searcing_text:
|
toolbar_obj = self.root.ids.toolbar
|
||||||
# toolbar_obj = self.root.ids.toolbar
|
toolbar_obj.left_action_items = [
|
||||||
# toolbar_obj.left_action_items = [
|
['arrow-left', lambda x: self.closeSearchScreen()]]
|
||||||
# ['arrow-left', lambda x: self.closeSearchScreen()]]
|
toolbar_obj.right_action_items = []
|
||||||
# toolbar_obj.right_action_items = []
|
self.root.ids.toolbar.title = ''
|
||||||
# self.root.ids.toolbar.title = ''
|
elif self.root.ids.scr_mngr.current == "create":
|
||||||
# elif self.root.ids.scr_mngr.current == "create":
|
self.save_draft()
|
||||||
# self.save_draft()
|
self.set_common_header()
|
||||||
# self.set_common_header()
|
state.in_composer = False
|
||||||
# state.in_composer = False
|
self.root.ids.scr_mngr.current = 'inbox'
|
||||||
# self.root.ids.scr_mngr.current = 'inbox'
|
elif self.root.ids.scr_mngr.current == "showqrcode":
|
||||||
# elif self.root.ids.scr_mngr.current == "showqrcode":
|
self.set_common_header()
|
||||||
# self.set_common_header()
|
self.root.ids.scr_mngr.current = 'myaddress'
|
||||||
# self.root.ids.scr_mngr.current = 'myaddress'
|
elif self.root.ids.scr_mngr.current == "random":
|
||||||
# elif self.root.ids.scr_mngr.current == "random":
|
self.root.ids.scr_mngr.current = 'login'
|
||||||
# self.root.ids.scr_mngr.current = 'login'
|
elif self.root.ids.scr_mngr.current == 'pay-options':
|
||||||
# elif self.root.ids.scr_mngr.current == 'pay-options':
|
self.set_common_header()
|
||||||
# self.set_common_header()
|
self.root.ids.scr_mngr.current = 'payment'
|
||||||
# self.root.ids.scr_mngr.current = 'payment'
|
elif self.root.ids.scr_mngr.current == 'chroom':
|
||||||
# elif self.root.ids.scr_mngr.current == 'chroom':
|
if state.association:
|
||||||
# if state.association:
|
address_label = self.current_address_label(
|
||||||
# address_label = self.current_address_label(
|
BMConfigParser().get(
|
||||||
# BMConfigParser().get(
|
state.association, 'label'), state.association)
|
||||||
# state.association, 'label'), state.association)
|
self.root.ids.toolbar.title = address_label
|
||||||
# self.root.ids.toolbar.title = address_label
|
self.set_common_header()
|
||||||
# self.set_common_header()
|
self.root.ids.scr_mngr.transition = FallOutTransition()
|
||||||
# self.root.ids.scr_mngr.transition = FallOutTransition()
|
self.root.ids.scr_mngr.current = 'chlist'
|
||||||
# self.root.ids.scr_mngr.current = 'chlist'
|
self.root.ids.scr_mngr.transition = SlideTransition()
|
||||||
# self.root.ids.scr_mngr.transition = SlideTransition()
|
else:
|
||||||
# else:
|
if state.kivyapp.variable_1:
|
||||||
# if state.kivyapp.variable_1:
|
self.root.ids.scr_mngr.current = 'inbox'
|
||||||
# self.root.ids.scr_mngr.current = 'inbox'
|
self.root.ids.scr_mngr.transition.direction = 'right'
|
||||||
# self.root.ids.scr_mngr.transition.direction = 'right'
|
self.root.ids.scr_mngr.transition.bind(on_complete=self.reset)
|
||||||
# self.root.ids.scr_mngr.transition.bind(on_complete=self.reset)
|
return True
|
||||||
# return True
|
elif key == 13 and state.searcing_text and not state.in_composer:
|
||||||
# elif key == 13 and state.searcing_text and not state.in_composer:
|
if state.search_screen == 'inbox':
|
||||||
# if state.search_screen == 'inbox':
|
self.root.ids.sc1.children[1].active = True
|
||||||
# self.root.ids.sc1.children[1].active = True
|
Clock.schedule_once(self.search_callback, 0.5)
|
||||||
# Clock.schedule_once(self.search_callback, 0.5)
|
elif state.search_screen == 'addressbook':
|
||||||
# elif state.search_screen == 'addressbook':
|
self.root.ids.sc11.children[1].active = True
|
||||||
# self.root.ids.sc11.children[1].active = True
|
Clock.schedule_once(self.search_callback, 0.5)
|
||||||
# Clock.schedule_once(self.search_callback, 0.5)
|
elif state.search_screen == 'myaddress':
|
||||||
# elif state.search_screen == 'myaddress':
|
self.loadMyAddressScreen(True)
|
||||||
# self.loadMyAddressScreen(True)
|
Clock.schedule_once(self.search_callback, 0.5)
|
||||||
# Clock.schedule_once(self.search_callback, 0.5)
|
elif state.search_screen == 'sent':
|
||||||
# elif state.search_screen == 'sent':
|
self.root.ids.sc4.children[1].active = True
|
||||||
# self.root.ids.sc4.children[1].active = True
|
Clock.schedule_once(self.search_callback, 0.5)
|
||||||
# Clock.schedule_once(self.search_callback, 0.5)
|
|
||||||
|
|
||||||
def search_callback(self, dt=0):
|
def search_callback(self, dt=0):
|
||||||
"""Show data after loader is loaded"""
|
"""Show data after loader is loaded"""
|
||||||
# if state.search_screen == 'inbox':
|
if state.search_screen == 'inbox':
|
||||||
# self.root.ids.sc1.ids.ml.clear_widgets()
|
self.root.ids.sc1.ids.ml.clear_widgets()
|
||||||
# self.root.ids.sc1.loadMessagelist(state.association)
|
self.root.ids.sc1.loadMessagelist(state.association)
|
||||||
# self.root.ids.sc1.children[1].active = False
|
self.root.ids.sc1.children[1].active = False
|
||||||
# elif state.search_screen == 'addressbook':
|
elif state.search_screen == 'addressbook':
|
||||||
# self.root.ids.sc11.ids.ml.clear_widgets()
|
self.root.ids.sc11.ids.ml.clear_widgets()
|
||||||
# self.root.ids.sc11.loadAddresslist(None, 'All', '')
|
self.root.ids.sc11.loadAddresslist(None, 'All', '')
|
||||||
# self.root.ids.sc11.children[1].active = False
|
self.root.ids.sc11.children[1].active = False
|
||||||
# elif state.search_screen == 'myaddress':
|
elif state.search_screen == 'myaddress':
|
||||||
# self.root.ids.sc10.ids.ml.clear_widgets()
|
self.root.ids.sc10.ids.ml.clear_widgets()
|
||||||
# self.root.ids.sc10.init_ui()
|
self.root.ids.sc10.init_ui()
|
||||||
# self.loadMyAddressScreen(False)
|
self.loadMyAddressScreen(False)
|
||||||
# else:
|
else:
|
||||||
# self.root.ids.sc4.ids.ml.clear_widgets()
|
self.root.ids.sc4.ids.ml.clear_widgets()
|
||||||
# self.root.ids.sc4.loadSent(state.association)
|
self.root.ids.sc4.loadSent(state.association)
|
||||||
# self.root.ids.sc4.children[1].active = False
|
self.root.ids.sc4.children[1].active = False
|
||||||
# self.root.ids.scr_mngr.current = state.search_screen
|
self.root.ids.scr_mngr.current = state.search_screen
|
||||||
pass
|
|
||||||
|
|
||||||
def loadMyAddressScreen(self, action):
|
def loadMyAddressScreen(self, action):
|
||||||
# """loadMyAddressScreen method spin the loader"""
|
"""loadMyAddressScreen method spin the loader"""
|
||||||
# if len(self.root.ids.sc10.children) <= 2:
|
if len(self.root.ids.sc10.children) <= 2:
|
||||||
# self.root.ids.sc10.children[0].active = action
|
self.root.ids.sc10.children[0].active = action
|
||||||
# else:
|
else:
|
||||||
# self.root.ids.sc10.children[1].active = action
|
self.root.ids.sc10.children[1].active = action
|
||||||
pass
|
|
||||||
def save_draft(self):
|
def save_draft(self):
|
||||||
# """Saving drafts messages"""
|
"""Saving drafts messages"""
|
||||||
# composer_objs = self.root
|
composer_objs = self.root
|
||||||
# from_addr = str(self.root.ids.sc3.children[1].ids.ti.text)
|
from_addr = str(self.root.ids.sc3.children[1].ids.ti.text)
|
||||||
# # to_addr = str(self.root.ids.sc3.children[1].ids.txt_input.text)
|
# to_addr = str(self.root.ids.sc3.children[1].ids.txt_input.text)
|
||||||
# if from_addr and state.detailPageType != 'draft' \
|
if from_addr and state.detailPageType != 'draft' \
|
||||||
# and not state.in_sent_method:
|
and not state.in_sent_method:
|
||||||
# Draft().draft_msg(composer_objs)
|
Draft().draft_msg(composer_objs)
|
||||||
# return
|
return
|
||||||
pass
|
|
||||||
|
|
||||||
def reset(self, *args):
|
def reset(self, *args):
|
||||||
# """Set transition direction"""
|
"""Set transition direction"""
|
||||||
# self.root.ids.scr_mngr.transition.direction = 'left'
|
self.root.ids.scr_mngr.transition.direction = 'left'
|
||||||
# self.root.ids.scr_mngr.transition.unbind(on_complete=self.reset)
|
self.root.ids.scr_mngr.transition.unbind(on_complete=self.reset)
|
||||||
pass
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def status_dispatching(data):
|
def status_dispatching(data):
|
||||||
# """Dispatching Status acknowledgment"""
|
"""Dispatching Status acknowledgment"""
|
||||||
# ackData, message = data
|
ackData, message = data
|
||||||
# if state.ackdata == ackData:
|
if state.ackdata == ackData:
|
||||||
# state.status.status = message
|
state.status.status = message
|
||||||
pass
|
|
||||||
|
|
||||||
def clear_composer(self):
|
def clear_composer(self):
|
||||||
# """If slow down, the new composer edit screen"""
|
"""If slow down, the new composer edit screen"""
|
||||||
# self.set_navbar_for_composer()
|
self.set_navbar_for_composer()
|
||||||
# composer_obj = self.root.ids.sc3.children[1].ids
|
composer_obj = self.root.ids.sc3.children[1].ids
|
||||||
# composer_obj.ti.text = ''
|
composer_obj.ti.text = ''
|
||||||
# composer_obj.btn.text = 'Select'
|
composer_obj.btn.text = 'Select'
|
||||||
# composer_obj.txt_input.text = ''
|
composer_obj.txt_input.text = ''
|
||||||
# composer_obj.subject.text = ''
|
composer_obj.subject.text = ''
|
||||||
# composer_obj.body.text = ''
|
composer_obj.body.text = ''
|
||||||
# state.in_composer = True
|
state.in_composer = True
|
||||||
# state.in_sent_method = False
|
state.in_sent_method = False
|
||||||
pass
|
|
||||||
|
|
||||||
def set_navbar_for_composer(self):
|
def set_navbar_for_composer(self):
|
||||||
# """Clearing toolbar data when composer open"""
|
"""Clearing toolbar data when composer open"""
|
||||||
# self.root.ids.toolbar.left_action_items = [
|
self.root.ids.toolbar.left_action_items = [
|
||||||
# ['arrow-left', lambda x: self.back_press()]]
|
['arrow-left', lambda x: self.back_press()]]
|
||||||
# self.root.ids.toolbar.right_action_items = [
|
self.root.ids.toolbar.right_action_items = [
|
||||||
# ['refresh',
|
['refresh',
|
||||||
# lambda x: self.root.ids.sc3.children[1].reset_composer()],
|
lambda x: self.root.ids.sc3.children[1].reset_composer()],
|
||||||
# ['send',
|
['send',
|
||||||
# lambda x: self.root.ids.sc3.children[1].send(self)]]
|
lambda x: self.root.ids.sc3.children[1].send(self)]]
|
||||||
pass
|
|
||||||
def set_toolbar_for_QrCode(self):
|
def set_toolbar_for_QrCode(self):
|
||||||
# """This method is use for setting Qr code toolbar."""
|
"""This method is use for setting Qr code toolbar."""
|
||||||
# self.root.ids.toolbar.left_action_items = [
|
self.root.ids.toolbar.left_action_items = [
|
||||||
# ['arrow-left', lambda x: self.back_press()]]
|
['arrow-left', lambda x: self.back_press()]]
|
||||||
# self.root.ids.toolbar.right_action_items = []
|
self.root.ids.toolbar.right_action_items = []
|
||||||
pass
|
|
||||||
|
|
||||||
def set_common_header(self):
|
def set_common_header(self):
|
||||||
# """Common header for all window"""
|
"""Common header for all window"""
|
||||||
# self.root.ids.toolbar.right_action_items = [
|
self.root.ids.toolbar.right_action_items = [
|
||||||
# ['account-plus', lambda x: self.addingtoaddressbook()]]
|
['account-plus', lambda x: self.addingtoaddressbook()]]
|
||||||
# # self.root.ids.toolbar.left_action_items = [
|
|
||||||
# # ['menu', lambda x: self.root.toggle_nav_drawer()]]
|
|
||||||
# self.root.ids.toolbar.left_action_items = [
|
# self.root.ids.toolbar.left_action_items = [
|
||||||
# ['menu', lambda x: self.root.ids.nav_drawer.set_state("toggle")]]
|
# ['menu', lambda x: self.root.toggle_nav_drawer()]]
|
||||||
# return
|
self.root.ids.toolbar.left_action_items = [
|
||||||
pass
|
['menu', lambda x: self.root.ids.nav_drawer.set_state("toggle")]]
|
||||||
|
return
|
||||||
|
|
||||||
def back_press(self):
|
def back_press(self):
|
||||||
# """Method for, reverting composer to previous page"""
|
"""Method for, reverting composer to previous page"""
|
||||||
# if self.root.ids.scr_mngr.current == 'create':
|
if self.root.ids.scr_mngr.current == 'create':
|
||||||
# self.save_draft()
|
self.save_draft()
|
||||||
# if self.root.ids.scr_mngr.current == \
|
if self.root.ids.scr_mngr.current == \
|
||||||
# 'mailDetail' and state.in_search_mode:
|
'mailDetail' and state.in_search_mode:
|
||||||
# toolbar_obj = self.root.ids.toolbar
|
toolbar_obj = self.root.ids.toolbar
|
||||||
# toolbar_obj.left_action_items = [
|
toolbar_obj.left_action_items = [
|
||||||
# ['arrow-left', lambda x: self.closeSearchScreen()]]
|
['arrow-left', lambda x: self.closeSearchScreen()]]
|
||||||
# toolbar_obj.right_action_items = []
|
toolbar_obj.right_action_items = []
|
||||||
# self.root.ids.toolbar.title = ''
|
self.root.ids.toolbar.title = ''
|
||||||
# else:
|
else:
|
||||||
# self.set_common_header()
|
self.set_common_header()
|
||||||
# if self.root.ids.scr_mngr.current == 'chroom' and state.association:
|
if self.root.ids.scr_mngr.current == 'chroom' and state.association:
|
||||||
# self.root.ids.scr_mngr.transition = FallOutTransition()
|
self.root.ids.scr_mngr.transition = FallOutTransition()
|
||||||
# address_label = self.current_address_label(
|
address_label = self.current_address_label(
|
||||||
# BMConfigParser().get(
|
BMConfigParser().get(
|
||||||
# state.association, 'label'), state.association)
|
state.association, 'label'), state.association)
|
||||||
# self.root.ids.toolbar.title = address_label
|
self.root.ids.toolbar.title = address_label
|
||||||
# self.root.ids.scr_mngr.current = 'inbox' \
|
self.root.ids.scr_mngr.current = 'inbox' \
|
||||||
# if state.in_composer else 'allmails'\
|
if state.in_composer else 'allmails'\
|
||||||
# if state.is_allmail else state.detailPageType\
|
if state.is_allmail else state.detailPageType\
|
||||||
# if state.detailPageType else 'myaddress'\
|
if state.detailPageType else 'myaddress'\
|
||||||
# if self.root.ids.scr_mngr.current == 'showqrcode' else 'payment'\
|
if self.root.ids.scr_mngr.current == 'showqrcode' else 'payment'\
|
||||||
# if self.root.ids.scr_mngr.current == 'pay-options' else 'chlist'\
|
if self.root.ids.scr_mngr.current == 'pay-options' else 'chlist'\
|
||||||
# if self.root.ids.scr_mngr.current == 'chroom' else 'inbox'
|
if self.root.ids.scr_mngr.current == 'chroom' else 'inbox'
|
||||||
# if self.root.ids.scr_mngr.current == 'chlist':
|
if self.root.ids.scr_mngr.current == 'chlist':
|
||||||
# self.root.ids.scr_mngr.transition = SlideTransition()
|
self.root.ids.scr_mngr.transition = SlideTransition()
|
||||||
# self.root.ids.scr_mngr.transition.direction = 'right'
|
self.root.ids.scr_mngr.transition.direction = 'right'
|
||||||
# self.root.ids.scr_mngr.transition.bind(on_complete=self.reset)
|
self.root.ids.scr_mngr.transition.bind(on_complete=self.reset)
|
||||||
# if state.is_allmail or state.detailPageType == 'draft':
|
if state.is_allmail or state.detailPageType == 'draft':
|
||||||
# state.is_allmail = False
|
state.is_allmail = False
|
||||||
# state.detailPageType = ''
|
state.detailPageType = ''
|
||||||
# state.in_composer = False
|
state.in_composer = False
|
||||||
pass
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_inbox_count():
|
def get_inbox_count():
|
||||||
# """Getting inbox count"""
|
"""Getting inbox count"""
|
||||||
# state.inbox_count = str(sqlQuery(
|
state.inbox_count = str(sqlQuery(
|
||||||
# "SELECT COUNT(*) FROM inbox WHERE toaddress = '{}' and"
|
"SELECT COUNT(*) FROM inbox WHERE toaddress = '{}' and"
|
||||||
# " folder = 'inbox' ;".format(state.association))[0][0])
|
" folder = 'inbox' ;".format(state.association))[0][0])
|
||||||
pass
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_sent_count():
|
def get_sent_count():
|
||||||
# """Getting sent count"""
|
"""Getting sent count"""
|
||||||
# state.sent_count = str(sqlQuery(
|
state.sent_count = str(sqlQuery(
|
||||||
# "SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and"
|
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and"
|
||||||
# " folder = 'sent' ;".format(state.association))[0][0])
|
" folder = 'sent' ;".format(state.association))[0][0])
|
||||||
pass
|
|
||||||
def set_message_count(self):
|
def set_message_count(self):
|
||||||
"""Setting message count"""
|
"""Setting message count"""
|
||||||
# msg_counter_objs = state.kivyapp.root.children[0].children[0].ids
|
msg_counter_objs = state.kivyapp.root.children[0].children[0].ids
|
||||||
# try:
|
# try:
|
||||||
# msg_counter_objs = (
|
# msg_counter_objs = (
|
||||||
# self.root_window.children[0].children[2].children[0].ids)
|
# self.root_window.children[0].children[2].children[0].ids)
|
||||||
# except Exception:
|
# except Exception:
|
||||||
# msg_counter_objs = (
|
# msg_counter_objs = (
|
||||||
# self.root_window.children[2].children[2].children[0].ids)
|
# self.root_window.children[2].children[2].children[0].ids)
|
||||||
# self.get_inbox_count()
|
self.get_inbox_count()
|
||||||
# self.get_sent_count()
|
self.get_sent_count()
|
||||||
# state.trash_count = str(sqlQuery(
|
state.trash_count = 0
|
||||||
|
# str(sqlQuery(
|
||||||
# "SELECT (SELECT count(*) FROM sent"
|
# "SELECT (SELECT count(*) FROM sent"
|
||||||
# " where fromaddress = '{0}' and folder = 'trash' )"
|
# " where fromaddress = '{0}' and folder = 'trash' )"
|
||||||
# "+(SELECT count(*) FROM inbox where toaddress = '{0}' and"
|
# "+(SELECT count(*) FROM inbox where toaddress = '{0}' and"
|
||||||
# " folder = 'trash') AS SumCount".format(state.association))[0][0])
|
# " folder = 'trash') AS SumCount".format(state.association))[0][0])
|
||||||
# state.draft_count = str(sqlQuery(
|
state.draft_count = 0
|
||||||
|
# str(sqlQuery(
|
||||||
# "SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and"
|
# "SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and"
|
||||||
# " folder = 'draft' ;".format(state.association))[0][0])
|
# " folder = 'draft' ;".format(state.association))[0][0])
|
||||||
# state.all_count = str(int(state.sent_count) + int(state.inbox_count))
|
state.all_count = str(int(state.sent_count) + int(state.inbox_count))
|
||||||
# if msg_counter_objs:
|
if msg_counter_objs:
|
||||||
# msg_counter_objs.send_cnt.badge_text = state.sent_count
|
msg_counter_objs.send_cnt.badge_text = state.sent_count
|
||||||
# msg_counter_objs.inbox_cnt.badge_text = state.inbox_count
|
msg_counter_objs.inbox_cnt.badge_text = state.inbox_count
|
||||||
# msg_counter_objs.trash_cnt.badge_text = state.trash_count
|
msg_counter_objs.trash_cnt.badge_text = state.trash_count
|
||||||
# msg_counter_objs.draft_cnt.badge_text = state.draft_count
|
msg_counter_objs.draft_cnt.badge_text = state.draft_count
|
||||||
# msg_counter_objs.allmail_cnt.badge_text = state.all_count
|
msg_counter_objs.allmail_cnt.badge_text = state.all_count
|
||||||
pass
|
|
||||||
def on_start(self):
|
def on_start(self):
|
||||||
# """Setting message count"""
|
"""Setting message count"""
|
||||||
# self.set_message_count()
|
self.set_message_count()
|
||||||
pass
|
|
||||||
|
|
||||||
# @staticmethod
|
# @staticmethod
|
||||||
# def on_stop():
|
# def on_stop():
|
||||||
|
@ -744,199 +697,192 @@ class NavigateApp(MDApp):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def searchQuery(self, instance):
|
def searchQuery(self, instance):
|
||||||
# """Showing searched mails"""
|
"""Showing searched mails"""
|
||||||
# state.search_screen = self.root.ids.scr_mngr.current
|
state.search_screen = self.root.ids.scr_mngr.current
|
||||||
# state.searcing_text = str(instance.text).strip()
|
state.searcing_text = str(instance.text).strip()
|
||||||
# if instance.focus and state.searcing_text:
|
if instance.focus and state.searcing_text:
|
||||||
# toolbar_obj = self.root.ids.toolbar
|
toolbar_obj = self.root.ids.toolbar
|
||||||
# toolbar_obj.left_action_items = [
|
toolbar_obj.left_action_items = [
|
||||||
# ['arrow-left', lambda x: self.closeSearchScreen()]]
|
['arrow-left', lambda x: self.closeSearchScreen()]]
|
||||||
# toolbar_obj.right_action_items = []
|
toolbar_obj.right_action_items = []
|
||||||
# self.root.ids.toolbar.title = ''
|
self.root.ids.toolbar.title = ''
|
||||||
# state.in_search_mode = True
|
state.in_search_mode = True
|
||||||
pass
|
|
||||||
|
|
||||||
def closeSearchScreen(self):
|
def closeSearchScreen(self):
|
||||||
"""Function for close search screen"""
|
"""Function for close search screen"""
|
||||||
# self.set_common_header()
|
self.set_common_header()
|
||||||
# if state.association:
|
if state.association:
|
||||||
# address_label = self.current_address_label(
|
address_label = self.current_address_label(
|
||||||
# BMConfigParser().get(
|
BMConfigParser().get(
|
||||||
# state.association, 'label'), state.association)
|
state.association, 'label'), state.association)
|
||||||
# self.root.ids.toolbar.title = address_label
|
self.root.ids.toolbar.title = address_label
|
||||||
# state.searcing_text = ''
|
state.searcing_text = ''
|
||||||
# self.refreshScreen()
|
self.refreshScreen()
|
||||||
# state.in_search_mode = False
|
state.in_search_mode = False
|
||||||
pass
|
|
||||||
|
|
||||||
def refreshScreen(self):
|
def refreshScreen(self):
|
||||||
# """Method show search button only on inbox or sent screen"""
|
"""Method show search button only on inbox or sent screen"""
|
||||||
# # pylint: disable=unused-variable
|
# pylint: disable=unused-variable
|
||||||
# state.searcing_text = ''
|
state.searcing_text = ''
|
||||||
# if state.search_screen == 'inbox':
|
if state.search_screen == 'inbox':
|
||||||
# self.root.ids.sc1.ids.inbox_search.ids.search_field.text = ''
|
self.root.ids.sc1.ids.inbox_search.ids.search_field.text = ''
|
||||||
# # try:
|
# try:
|
||||||
# # self.root.ids.sc1.children[
|
# self.root.ids.sc1.children[
|
||||||
# # 3].children[2].ids.search_field.text = ''
|
# 3].children[2].ids.search_field.text = ''
|
||||||
# # except Exception:
|
# except Exception:
|
||||||
# # self.root.ids.sc1.children[
|
# self.root.ids.sc1.children[
|
||||||
# # 2].children[2].ids.search_field.text = ''
|
# 2].children[2].ids.search_field.text = ''
|
||||||
# self.root.ids.sc1.children[1].active = True
|
self.root.ids.sc1.children[1].active = True
|
||||||
# Clock.schedule_once(self.search_callback, 0.5)
|
Clock.schedule_once(self.search_callback, 0.5)
|
||||||
# elif state.search_screen == 'addressbook':
|
elif state.search_screen == 'addressbook':
|
||||||
# self.root.ids.sc11.ids.address_search.ids.search_field.text = ''
|
self.root.ids.sc11.ids.address_search.ids.search_field.text = ''
|
||||||
# # self.root.ids.sc11.children[
|
|
||||||
# # 2].children[2].ids.search_field.text = ''
|
|
||||||
# self.root.ids.sc11.children[
|
# self.root.ids.sc11.children[
|
||||||
# 1].active = True
|
# 2].children[2].ids.search_field.text = ''
|
||||||
# Clock.schedule_once(self.search_callback, 0.5)
|
self.root.ids.sc11.children[
|
||||||
# elif state.search_screen == 'myaddress':
|
1].active = True
|
||||||
# self.root.ids.sc10.ids.search_bar.ids.search_field.text = ''
|
Clock.schedule_once(self.search_callback, 0.5)
|
||||||
# # try:
|
elif state.search_screen == 'myaddress':
|
||||||
# # self.root.ids.sc10.children[
|
self.root.ids.sc10.ids.search_bar.ids.search_field.text = ''
|
||||||
# # 1].children[2].ids.search_field.text = ''
|
# try:
|
||||||
# # except Exception:
|
# self.root.ids.sc10.children[
|
||||||
# # self.root.ids.sc10.children[
|
# 1].children[2].ids.search_field.text = ''
|
||||||
# # 2].children[2].ids.search_field.text = ''
|
# except Exception:
|
||||||
# self.loadMyAddressScreen(True)
|
# self.root.ids.sc10.children[
|
||||||
# Clock.schedule_once(self.search_callback, 0.5)
|
# 2].children[2].ids.search_field.text = ''
|
||||||
# else:
|
self.loadMyAddressScreen(True)
|
||||||
# self.root.ids.sc4.ids.sent_search.ids.search_field.text = ''
|
Clock.schedule_once(self.search_callback, 0.5)
|
||||||
# # self.root.ids.sc4.children[
|
else:
|
||||||
# # 2].children[2].ids.search_field.text = ''
|
self.root.ids.sc4.ids.sent_search.ids.search_field.text = ''
|
||||||
# self.root.ids.sc4.children[1].active = True
|
# self.root.ids.sc4.children[
|
||||||
# Clock.schedule_once(self.search_callback, 0.5)
|
# 2].children[2].ids.search_field.text = ''
|
||||||
# return
|
self.root.ids.sc4.children[1].active = True
|
||||||
pass
|
Clock.schedule_once(self.search_callback, 0.5)
|
||||||
|
return
|
||||||
|
|
||||||
def set_identicon(self, text):
|
def set_identicon(self, text):
|
||||||
# """Show identicon in address spinner"""
|
"""Show identicon in address spinner"""
|
||||||
# img = identiconGeneration.generate(text)
|
img = identiconGeneration.generate(text)
|
||||||
# # self.root.children[0].children[0].ids.btn.children[1].texture = (img.texture)
|
# self.root.children[0].children[0].ids.btn.children[1].texture = (img.texture)
|
||||||
# # below line is for displaing logo
|
# below line is for displaing logo
|
||||||
# self.root.ids.content_drawer.ids.top_box.children[0].texture = (img.texture)
|
self.root.ids.content_drawer.ids.top_box.children[0].texture = (img.texture)
|
||||||
pass
|
|
||||||
def set_mail_detail_header(self):
|
def set_mail_detail_header(self):
|
||||||
# """Setting the details of the page"""
|
"""Setting the details of the page"""
|
||||||
# if state.association and state.in_search_mode:
|
if state.association and state.in_search_mode:
|
||||||
# address_label = self.current_address_label(
|
address_label = self.current_address_label(
|
||||||
# BMConfigParser().get(
|
BMConfigParser().get(
|
||||||
# state.association, 'label'), state.association)
|
state.association, 'label'), state.association)
|
||||||
# self.root.ids.toolbar.title = address_label
|
self.root.ids.toolbar.title = address_label
|
||||||
# toolbar_obj = self.root.ids.toolbar
|
toolbar_obj = self.root.ids.toolbar
|
||||||
# toolbar_obj.left_action_items = [
|
toolbar_obj.left_action_items = [
|
||||||
# ['arrow-left', lambda x: self.back_press()]]
|
['arrow-left', lambda x: self.back_press()]]
|
||||||
# delete_btn = ['delete-forever',
|
delete_btn = ['delete-forever',
|
||||||
# lambda x: self.root.ids.sc14.delete_mail()]
|
lambda x: self.root.ids.sc14.delete_mail()]
|
||||||
# dynamic_list = []
|
dynamic_list = []
|
||||||
# if state.detailPageType == 'inbox':
|
if state.detailPageType == 'inbox':
|
||||||
# dynamic_list = [
|
dynamic_list = [
|
||||||
# ['reply', lambda x: self.root.ids.sc14.inbox_reply()],
|
['reply', lambda x: self.root.ids.sc14.inbox_reply()],
|
||||||
# delete_btn]
|
delete_btn]
|
||||||
# elif state.detailPageType == 'sent':
|
elif state.detailPageType == 'sent':
|
||||||
# dynamic_list = [delete_btn]
|
dynamic_list = [delete_btn]
|
||||||
# elif state.detailPageType == 'draft':
|
elif state.detailPageType == 'draft':
|
||||||
# dynamic_list = [
|
dynamic_list = [
|
||||||
# ['pencil', lambda x: self.root.ids.sc14.write_msg(self)],
|
['pencil', lambda x: self.root.ids.sc14.write_msg(self)],
|
||||||
# delete_btn]
|
delete_btn]
|
||||||
# toolbar_obj.right_action_items = dynamic_list
|
toolbar_obj.right_action_items = dynamic_list
|
||||||
pass
|
|
||||||
def load_screen(self, instance):
|
def load_screen(self, instance):
|
||||||
# """This method is used for loading screen on every click"""
|
"""This method is used for loading screen on every click"""
|
||||||
# if instance.text == 'Inbox':
|
if instance.text == 'Inbox':
|
||||||
# self.root.ids.scr_mngr.current = 'inbox'
|
self.root.ids.scr_mngr.current = 'inbox'
|
||||||
# self.root.ids.sc1.children[1].active = True
|
self.root.ids.sc1.children[1].active = True
|
||||||
# elif instance.text == 'All Mails':
|
elif instance.text == 'All Mails':
|
||||||
# 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:
|
except Exception:
|
||||||
# self.root.ids.sc17.children[0].children[1].active = True
|
self.root.ids.sc17.children[0].children[1].active = True
|
||||||
# elif instance.text == 'Trash':
|
elif instance.text == 'Trash':
|
||||||
# self.root.ids.scr_mngr.current = 'trash'
|
self.root.ids.scr_mngr.current = 'trash'
|
||||||
# try:
|
try:
|
||||||
# self.root.ids.sc5.children[1].active = True
|
self.root.ids.sc5.children[1].active = True
|
||||||
# except Exception as e:
|
except Exception as e:
|
||||||
# self.root.ids.sc5.children[0].children[1].active = True
|
self.root.ids.sc5.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)
|
||||||
pass
|
|
||||||
|
|
||||||
def load_screen_callback(self, instance, dt=0):
|
def load_screen_callback(self, instance, dt=0):
|
||||||
# """This method is rotating loader for few seconds"""
|
"""This method is rotating loader for few seconds"""
|
||||||
# if instance.text == 'Inbox':
|
if instance.text == 'Inbox':
|
||||||
# self.root.ids.sc1.ids.ml.clear_widgets()
|
self.root.ids.sc1.ids.ml.clear_widgets()
|
||||||
# self.root.ids.sc1.loadMessagelist(state.association)
|
self.root.ids.sc1.loadMessagelist(state.association)
|
||||||
# self.root.ids.sc1.children[1].active = False
|
self.root.ids.sc1.children[1].active = False
|
||||||
# elif instance.text == 'All Mails':
|
elif instance.text == 'All Mails':
|
||||||
# self.root.ids.sc17.clear_widgets()
|
self.root.ids.sc17.clear_widgets()
|
||||||
# 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:
|
except Exception:
|
||||||
# self.root.ids.sc17.children[0].children[1].active = False
|
self.root.ids.sc17.children[0].children[1].active = False
|
||||||
# elif instance.text == 'Trash':
|
elif instance.text == 'Trash':
|
||||||
# # self.root.ids.sc5.ids.ml.clear_widgets()
|
# self.root.ids.sc5.ids.ml.clear_widgets()
|
||||||
# # self.root.ids.sc5.init_ui(0)
|
# self.root.ids.sc5.init_ui(0)
|
||||||
# self.root.ids.sc5.clear_widgets()
|
self.root.ids.sc5.clear_widgets()
|
||||||
# self.root.ids.sc5.add_widget(Trash())
|
self.root.ids.sc5.add_widget(Trash())
|
||||||
# try:
|
try:
|
||||||
# self.root.ids.sc5.children[1].active = False
|
self.root.ids.sc5.children[1].active = False
|
||||||
# except Exception as e:
|
except Exception as e:
|
||||||
# self.root.ids.sc5.children[0].children[1].active = False
|
self.root.ids.sc5.children[0].children[1].active = False
|
||||||
pass
|
|
||||||
def on_request_close(self, *args): # pylint: disable=no-self-use
|
def on_request_close(self, *args): # pylint: disable=no-self-use
|
||||||
"""This method is for app closing request"""
|
"""This method is for app closing request"""
|
||||||
AppClosingPopup().open()
|
AppClosingPopup().open()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def file_manager_open(self):
|
def file_manager_open(self):
|
||||||
# """This method open the file manager of local system"""
|
"""This method open the file manager of local system"""
|
||||||
# from kivymd.uix.filemanager import MDFileManager
|
from kivymd.uix.filemanager import MDFileManager
|
||||||
|
|
||||||
# if not self.file_manager:
|
if not self.file_manager:
|
||||||
# self.file_manager = MDFileManager(
|
self.file_manager = MDFileManager(
|
||||||
# exit_manager=self.exit_manager,
|
exit_manager=self.exit_manager,
|
||||||
# select_path=self.select_path,
|
select_path=self.select_path,
|
||||||
# ext=['.png', '.jpg']
|
ext=['.png', '.jpg']
|
||||||
# )
|
)
|
||||||
# self.file_manager.previous = False
|
self.file_manager.previous = False
|
||||||
# self.file_manager.current_path = '/'
|
self.file_manager.current_path = '/'
|
||||||
# if platform == 'android':
|
if platform == 'android':
|
||||||
# from android.permissions import request_permissions, Permission, check_permission
|
from android.permissions import request_permissions, Permission, check_permission
|
||||||
# if check_permission(Permission.WRITE_EXTERNAL_STORAGE) and \
|
if check_permission(Permission.WRITE_EXTERNAL_STORAGE) and \
|
||||||
# check_permission(Permission.READ_EXTERNAL_STORAGE):
|
check_permission(Permission.READ_EXTERNAL_STORAGE):
|
||||||
# self.file_manager.show(os.getenv('EXTERNAL_STORAGE'))
|
self.file_manager.show(os.getenv('EXTERNAL_STORAGE'))
|
||||||
# self.manager_open = True
|
self.manager_open = True
|
||||||
# else:
|
else:
|
||||||
# request_permissions([Permission.WRITE_EXTERNAL_STORAGE, Permission.READ_EXTERNAL_STORAGE])
|
request_permissions([Permission.WRITE_EXTERNAL_STORAGE, Permission.READ_EXTERNAL_STORAGE])
|
||||||
# else:
|
else:
|
||||||
# self.file_manager.show(os.environ["HOME"])
|
self.file_manager.show(os.environ["HOME"])
|
||||||
# self.manager_open = True
|
self.manager_open = True
|
||||||
pass
|
|
||||||
|
|
||||||
def select_path(self, path):
|
def select_path(self, path):
|
||||||
"""This method is used to save the select image"""
|
"""This method is used to save the select image"""
|
||||||
# try:
|
try:
|
||||||
# from PIL import Image as PilImage
|
from PIL import Image as PilImage
|
||||||
# newImg = PilImage.open(path).resize((300, 300))
|
newImg = PilImage.open(path).resize((300, 300))
|
||||||
# if platform == 'android':
|
if platform == 'android':
|
||||||
# android_path = os.path.join(
|
android_path = os.path.join(
|
||||||
# os.environ['ANDROID_PRIVATE'] + '/app' + '/images' + '/kivy/')
|
os.environ['ANDROID_PRIVATE'] + '/app' + '/images' + '/kivy/')
|
||||||
# if not os.path.exists(android_path + '/default_identicon/'):
|
if not os.path.exists(android_path + '/default_identicon/'):
|
||||||
# os.makedirs(android_path + '/default_identicon/')
|
os.makedirs(android_path + '/default_identicon/')
|
||||||
# newImg.save('{1}/default_identicon/{0}.png'.format(
|
newImg.save('{1}/default_identicon/{0}.png'.format(
|
||||||
# state.association, android_path))
|
state.association, android_path))
|
||||||
# else:
|
else:
|
||||||
# if not os.path.exists(state.imageDir + '/default_identicon/'):
|
if not os.path.exists(state.imageDir + '/default_identicon/'):
|
||||||
# os.makedirs(state.imageDir + '/default_identicon/')
|
os.makedirs(state.imageDir + '/default_identicon/')
|
||||||
# newImg.save(state.imageDir + '/default_identicon/{0}.png'.format(state.association))
|
newImg.save(state.imageDir + '/default_identicon/{0}.png'.format(state.association))
|
||||||
# self.load_selected_Image(state.association)
|
self.load_selected_Image(state.association)
|
||||||
# toast('Image changed')
|
toast('Image changed')
|
||||||
# except Exception:
|
except Exception:
|
||||||
# toast('Exit')
|
toast('Exit')
|
||||||
# self.exit_manager()
|
self.exit_manager()
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def exit_manager(self, *args):
|
def exit_manager(self, *args):
|
||||||
"""Called when the user reaches the root of the directory tree."""
|
"""Called when the user reaches the root of the directory tree."""
|
||||||
|
@ -944,68 +890,64 @@ class NavigateApp(MDApp):
|
||||||
self.file_manager.close()
|
self.file_manager.close()
|
||||||
|
|
||||||
def load_selected_Image(self, curerentAddr):
|
def load_selected_Image(self, curerentAddr):
|
||||||
# """This method load the selected image on screen"""
|
"""This method load the selected image on screen"""
|
||||||
# top_box_obj = self.root.ids.content_drawer.ids.top_box.children[0]
|
top_box_obj = self.root.ids.content_drawer.ids.top_box.children[0]
|
||||||
# # spinner_img_obj = self.root.ids.content_drawer.ids.btn.children[1]
|
# spinner_img_obj = self.root.ids.content_drawer.ids.btn.children[1]
|
||||||
# # spinner_img_obj.source = top_box_obj.source ='./images/default_identicon/{0}.png'.format(curerentAddr)
|
# spinner_img_obj.source = top_box_obj.source ='./images/default_identicon/{0}.png'.format(curerentAddr)
|
||||||
# top_box_obj.source = state.imageDir + '/default_identicon/{0}.png'.format(curerentAddr)
|
top_box_obj.source = state.imageDir + '/default_identicon/{0}.png'.format(curerentAddr)
|
||||||
# self.root.ids.content_drawer.ids.reset_image.opacity = 1
|
self.root.ids.content_drawer.ids.reset_image.opacity = 1
|
||||||
# self.root.ids.content_drawer.ids.reset_image.disabled = False
|
self.root.ids.content_drawer.ids.reset_image.disabled = False
|
||||||
# top_box_obj.reload()
|
top_box_obj.reload()
|
||||||
pass
|
|
||||||
# spinner_img_obj.reload()
|
# spinner_img_obj.reload()
|
||||||
|
|
||||||
def rest_default_avatar_img(self):
|
def rest_default_avatar_img(self):
|
||||||
# """set default avatar generated image"""
|
"""set default avatar generated image"""
|
||||||
# self.set_identicon(state.association)
|
self.set_identicon(state.association)
|
||||||
# img_path = state.imageDir + '/default_identicon/{}.png'.format(state.association)
|
img_path = state.imageDir + '/default_identicon/{}.png'.format(state.association)
|
||||||
# try:
|
try:
|
||||||
# if os.path.exists(img_path):
|
if os.path.exists(img_path):
|
||||||
# os.remove(img_path)
|
os.remove(img_path)
|
||||||
# self.root.ids.content_drawer.ids.reset_image.opacity = 0
|
self.root.ids.content_drawer.ids.reset_image.opacity = 0
|
||||||
# self.root.ids.content_drawer.ids.reset_image.disabled = True
|
self.root.ids.content_drawer.ids.reset_image.disabled = True
|
||||||
# except Exception as e:
|
except Exception as e:
|
||||||
# pass
|
|
||||||
# toast('Avatar reset')
|
|
||||||
pass
|
pass
|
||||||
|
toast('Avatar reset')
|
||||||
|
|
||||||
def copy_composer_text(self, text): # pylint: disable=no-self-use
|
def copy_composer_text(self, text): # pylint: disable=no-self-use
|
||||||
# """Copy the data from mail detail page"""
|
"""Copy the data from mail detail page"""
|
||||||
# Clipboard.copy(text)
|
Clipboard.copy(text)
|
||||||
# toast('Copied')
|
toast('Copied')
|
||||||
pass
|
|
||||||
|
|
||||||
def reset_login_screen(self):
|
def reset_login_screen(self):
|
||||||
"""This method is used for clearing random screen"""
|
"""This method is used for clearing random screen"""
|
||||||
# if self.root.ids.sc7.ids.add_random_bx.children:
|
if self.root.ids.sc7.ids.add_random_bx.children:
|
||||||
# self.root.ids.sc7.ids.add_random_bx.clear_widgets()
|
self.root.ids.sc7.ids.add_random_bx.clear_widgets()
|
||||||
pass
|
|
||||||
|
|
||||||
def open_payment_layout(self, sku):
|
def open_payment_layout(self, sku):
|
||||||
"""It basically open up a payment layout for kivy Ui"""
|
"""It basically open up a payment layout for kivy Ui"""
|
||||||
# pml = PaymentMethodLayout()
|
pml = PaymentMethodLayout()
|
||||||
# self.product_id = sku
|
self.product_id = sku
|
||||||
# self.custom_sheet = MDCustomBottomSheet(screen=pml)
|
self.custom_sheet = MDCustomBottomSheet(screen=pml)
|
||||||
# self.custom_sheet.open()
|
self.custom_sheet.open()
|
||||||
pass
|
|
||||||
def initiate_purchase(self, method_name):
|
def initiate_purchase(self, method_name):
|
||||||
"""initiate_purchase module"""
|
"""initiate_purchase module"""
|
||||||
# print("Purchasing {} through {}".format(self.product_id, method_name))
|
print("Purchasing {} through {}".format(self.product_id, method_name))
|
||||||
pass
|
|
||||||
def _after_scan(self, text):
|
def _after_scan(self, text):
|
||||||
# if platform == 'android':
|
# if platform == 'android':
|
||||||
# toast_txt = cast(CharSequence, String(text))
|
# toast_txt = cast(CharSequence, String(text))
|
||||||
# show_toast(toast_txt, Toast.LENGTH_SHORT)
|
# show_toast(toast_txt, Toast.LENGTH_SHORT)
|
||||||
# if self.root.ids.sc23.previous_open_screen == 'composer':
|
if self.root.ids.sc23.previous_open_screen == 'composer':
|
||||||
# self.root.ids.sc3.children[1].ids.txt_input.text = text
|
self.root.ids.sc3.children[1].ids.txt_input.text = text
|
||||||
# self.root.ids.scr_mngr.current = 'create'
|
self.root.ids.scr_mngr.current = 'create'
|
||||||
# elif self.root.ids.sc23.previous_open_screen:
|
elif self.root.ids.sc23.previous_open_screen:
|
||||||
# back_screen = self.root.ids.sc23.previous_open_screen
|
back_screen = self.root.ids.sc23.previous_open_screen
|
||||||
# self.root.ids.scr_mngr.current = 'inbox' if back_screen == 'scanscreen' else back_screen
|
self.root.ids.scr_mngr.current = 'inbox' if back_screen == 'scanscreen' else back_screen
|
||||||
# add_obj = self.root.ids.sc23.pop_up_instance
|
add_obj = self.root.ids.sc23.pop_up_instance
|
||||||
# add_obj.content_cls.ids.address.text = text
|
add_obj.content_cls.ids.address.text = text
|
||||||
# Clock.schedule_once(partial(self.open_popup, add_obj), .5)
|
Clock.schedule_once(partial(self.open_popup, add_obj), .5)
|
||||||
pass
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def open_popup(instance, dt):
|
def open_popup(instance, dt):
|
||||||
"""This method is used for opening popup"""
|
"""This method is used for opening popup"""
|
||||||
|
|
|
@ -15,7 +15,6 @@ from queues import (
|
||||||
|
|
||||||
|
|
||||||
def doCleanShutdown():
|
def doCleanShutdown():
|
||||||
import pdb; pdb.set_trace()
|
|
||||||
"""
|
"""
|
||||||
Used to tell all the treads to finish work and exit.
|
Used to tell all the treads to finish work and exit.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -10,15 +10,9 @@ from pybitmessage.class_singleCleaner import singleCleaner
|
||||||
from pybitmessage import state
|
from pybitmessage import state
|
||||||
from pybitmessage.network.threads import StoppableThread
|
from pybitmessage.network.threads import StoppableThread
|
||||||
|
|
||||||
# from pybitmessage.network.connectionpool import BMConnectionPool
|
|
||||||
# from pybitmessage.network.networkthread import BMNetworkThread
|
|
||||||
# from pybitmessage.network.receivequeuethread import ReceiveQueueThread
|
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods,no-init,old-style-class
|
|
||||||
class MockMain:
|
class MockMain:
|
||||||
"""Mock main function"""
|
"""Mock main function"""
|
||||||
|
|
||||||
# pylint: disable=no-self-use
|
|
||||||
def start(self):
|
def start(self):
|
||||||
"""Start main application"""
|
"""Start main application"""
|
||||||
# pylint: disable=too-many-statements,too-many-branches,too-many-locals, unused-variable
|
# pylint: disable=too-many-statements,too-many-branches,too-many-locals, unused-variable
|
||||||
|
@ -47,253 +41,18 @@ class MockMain:
|
||||||
|
|
||||||
Inventory() # init
|
Inventory() # init
|
||||||
|
|
||||||
# # Start the cleanerThread
|
# Start the cleanerThread
|
||||||
singleCleanerThread = singleCleaner()
|
singleCleanerThread = singleCleaner()
|
||||||
# # close the main program even if there are threads left
|
# close the main program even if there are threads left
|
||||||
singleCleanerThread.daemon = True
|
singleCleanerThread.daemon = True
|
||||||
singleCleanerThread.start()
|
singleCleanerThread.start()
|
||||||
# Not needed if objproc disabled
|
|
||||||
# if state.enableObjProc:
|
|
||||||
# shared.reloadMyAddressHashes()
|
|
||||||
# shared.reloadBroadcastSendersForWhichImWatching()
|
|
||||||
# API is also objproc dependent
|
|
||||||
# if config.safeGetBoolean('bitmessagesettings', 'apienabled'):
|
|
||||||
# # pylint: disable=relative-import
|
|
||||||
# from pybitmessage import api
|
|
||||||
# singleAPIThread = api.singleAPI()
|
|
||||||
# # close the main program even if there are threads left
|
|
||||||
# singleAPIThread.daemon = True
|
|
||||||
# singleAPIThread.start()
|
|
||||||
|
|
||||||
# # start network components if networking is enabled
|
|
||||||
# if state.enableNetwork:
|
|
||||||
# # start_proxyconfig()
|
|
||||||
# # BMConnectionPool().connectToStream(1)
|
|
||||||
# asyncoreThread = BMNetworkThread()
|
|
||||||
# asyncoreThread.daemon = True
|
|
||||||
# asyncoreThread.start()
|
|
||||||
|
|
||||||
# for i in range(config.safeGet('threads', 'receive')):
|
|
||||||
# receiveQueueThread = ReceiveQueueThread(i)
|
|
||||||
# receiveQueueThread.daemon = True
|
|
||||||
# receiveQueueThread.start()
|
|
||||||
# announceThread = AnnounceThread()
|
|
||||||
# announceThread.daemon = True
|
|
||||||
# announceThread.start()
|
|
||||||
# state.invThread = InvThread()
|
|
||||||
# state.invThread.daemon = True
|
|
||||||
# state.invThread.start()
|
|
||||||
# state.addrThread = AddrThread()
|
|
||||||
# state.addrThread.daemon = True
|
|
||||||
# state.addrThread.start()
|
|
||||||
# state.downloadThread = DownloadThread()
|
|
||||||
# state.downloadThread.daemon = True
|
|
||||||
# state.downloadThread.start()
|
|
||||||
# state.uploadThread = UploadThread()
|
|
||||||
# state.uploadThread.daemon = True
|
|
||||||
# state.uploadThread.start()
|
|
||||||
|
|
||||||
# if config.safeGetBoolean('bitmessagesettings', 'upnp'):
|
|
||||||
# import upnp
|
|
||||||
# upnpThread = upnp.uPnPThread()
|
|
||||||
# upnpThread.start()
|
|
||||||
# else:
|
|
||||||
# # Populate with hardcoded value (same as connectToStream above)
|
|
||||||
# state.streamsInWhichIAmParticipating.append(1)
|
|
||||||
# if not daemon and state.enableGUI:
|
|
||||||
# if state.curses:
|
|
||||||
# if not depends.check_curses():
|
|
||||||
# sys.exit()
|
|
||||||
# print('Running with curses')
|
|
||||||
# import bitmessagecurses
|
|
||||||
# bitmessagecurses.runwrapper()
|
|
||||||
|
|
||||||
# config.remove_option('bitmessagesettings', 'dontconnect')
|
|
||||||
# pylint: disable=no-member,import-error,no-name-in-module,relative-import
|
|
||||||
from pybitmessage.mpybit import NavigateApp
|
from pybitmessage.mpybit import NavigateApp
|
||||||
state.kivyapp = NavigateApp()
|
state.kivyapp = NavigateApp()
|
||||||
print('NavigateApp() ----------------------')
|
print('NavigateApp() ----------------------')
|
||||||
state.kivyapp.run()
|
state.kivyapp.run()
|
||||||
print('state.kivyapp.run() ----------------------')
|
print('state.kivyapp.run() ----------------------')
|
||||||
|
|
||||||
|
|
||||||
# else:
|
|
||||||
# config.remove_option('bitmessagesettings', 'dontconnect')
|
|
||||||
|
|
||||||
# if daemon:
|
|
||||||
# while state.shutdown == 0:
|
|
||||||
# time.sleep(1)
|
|
||||||
# if (
|
|
||||||
# state.testmode
|
|
||||||
# and time.time() - state.last_api_response >= 30
|
|
||||||
# ):
|
|
||||||
# self.stop()
|
|
||||||
# elif not state.enableGUI:
|
|
||||||
# state.enableGUI = True
|
|
||||||
# # pylint: disable=relative-import
|
|
||||||
# from tests import core as test_core
|
|
||||||
# test_core_result = test_core.run()
|
|
||||||
# state.enableGUI = True
|
|
||||||
# self.stop()
|
|
||||||
# test_core.cleanup()
|
|
||||||
# sys.exit(
|
|
||||||
# 'Core tests failed!'
|
|
||||||
# if test_core_result.errors or test_core_result.failures
|
|
||||||
# else 0
|
|
||||||
# )
|
|
||||||
|
|
||||||
# @staticmethod
|
|
||||||
# def daemonize():
|
|
||||||
# """Running as a daemon. Send signal in end."""
|
|
||||||
# grandfatherPid = os.getpid()
|
|
||||||
# parentPid = None
|
|
||||||
# try:
|
|
||||||
# if os.fork():
|
|
||||||
# # unlock
|
|
||||||
# state.thisapp.cleanup()
|
|
||||||
# # wait until grandchild ready
|
|
||||||
# while True:
|
|
||||||
# time.sleep(1)
|
|
||||||
|
|
||||||
# os._exit(0) # pylint: disable=protected-access
|
|
||||||
# except AttributeError:
|
|
||||||
# # fork not implemented
|
|
||||||
# pass
|
|
||||||
# else:
|
|
||||||
# parentPid = os.getpid()
|
|
||||||
# state.thisapp.lock() # relock
|
|
||||||
|
|
||||||
# os.umask(0)
|
|
||||||
# try:
|
|
||||||
# os.setsid()
|
|
||||||
# except AttributeError:
|
|
||||||
# # setsid not implemented
|
|
||||||
# pass
|
|
||||||
# try:
|
|
||||||
# if os.fork():
|
|
||||||
# # unlock
|
|
||||||
# state.thisapp.cleanup()
|
|
||||||
# # wait until child ready
|
|
||||||
# while True:
|
|
||||||
# time.sleep(1)
|
|
||||||
# os._exit(0) # pylint: disable=protected-access
|
|
||||||
# except AttributeError:
|
|
||||||
# # fork not implemented
|
|
||||||
# pass
|
|
||||||
# else:
|
|
||||||
# state.thisapp.lock() # relock
|
|
||||||
# state.thisapp.lockPid = None # indicate we're the final child
|
|
||||||
# sys.stdout.flush()
|
|
||||||
# sys.stderr.flush()
|
|
||||||
# if not sys.platform.startswith('win'):
|
|
||||||
# si = file(os.devnull, 'r')
|
|
||||||
# so = file(os.devnull, 'a+')
|
|
||||||
# se = file(os.devnull, 'a+', 0)
|
|
||||||
# os.dup2(si.fileno(), sys.stdin.fileno())
|
|
||||||
# os.dup2(so.fileno(), sys.stdout.fileno())
|
|
||||||
# os.dup2(se.fileno(), sys.stderr.fileno())
|
|
||||||
# if parentPid:
|
|
||||||
# # signal ready
|
|
||||||
# os.kill(parentPid, signal.SIGTERM)
|
|
||||||
# os.kill(grandfatherPid, signal.SIGTERM)
|
|
||||||
|
|
||||||
# @staticmethod
|
|
||||||
# def setSignalHandler():
|
|
||||||
# """Setting the Signal Handler"""
|
|
||||||
# signal.signal(signal.SIGINT, signal_handler)
|
|
||||||
# signal.signal(signal.SIGTERM, signal_handler)
|
|
||||||
# # signal.signal(signal.SIGINT, signal.SIG_DFL)
|
|
||||||
|
|
||||||
# @staticmethod
|
|
||||||
# def usage():
|
|
||||||
# """Displaying the usages"""
|
|
||||||
# print('Usage: ' + sys.argv[0] + ' [OPTIONS]')
|
|
||||||
# print('''
|
|
||||||
# Options:
|
|
||||||
# -h, --help show this help message and exit
|
|
||||||
# -c, --curses use curses (text mode) interface
|
|
||||||
# -d, --daemon run in daemon (background) mode
|
|
||||||
# -t, --test dryrun, make testing
|
|
||||||
|
|
||||||
# All parameters are optional.
|
|
||||||
# ''')
|
|
||||||
|
|
||||||
# @staticmethod
|
|
||||||
# def stop():
|
|
||||||
# """Stop main application"""
|
|
||||||
# with printLock:
|
|
||||||
# print('Stopping Bitmessage Deamon.')
|
|
||||||
# shutdown.doCleanShutdown()
|
|
||||||
|
|
||||||
# # .. todo:: nice function but no one is using this
|
|
||||||
# @staticmethod
|
|
||||||
# def getApiAddress():
|
|
||||||
# """This function returns API address and port"""
|
|
||||||
# if not BMConfigParser().safeGetBoolean(
|
|
||||||
# 'bitmessagesettings', 'apienabled'):
|
|
||||||
# return None
|
|
||||||
# address = BMConfigParser().get('bitmessagesettings', 'apiinterface')
|
|
||||||
# port = BMConfigParser().getint('bitmessagesettings', 'apiport')
|
|
||||||
# return {'address': address, 'port': port}
|
|
||||||
|
|
||||||
# def start_proxyconfig():
|
|
||||||
# """Check socksproxytype and start any proxy configuration plugin"""
|
|
||||||
# if not get_plugin:
|
|
||||||
# return
|
|
||||||
# config = BMConfigParser()
|
|
||||||
# proxy_type = config.safeGet('bitmessagesettings', 'socksproxytype')
|
|
||||||
# if proxy_type and proxy_type not in ('none', 'SOCKS4a', 'SOCKS5'):
|
|
||||||
# try:
|
|
||||||
# proxyconfig_start = time.time()
|
|
||||||
# if not get_plugin('proxyconfig', name=proxy_type)(config):
|
|
||||||
# raise TypeError()
|
|
||||||
# except TypeError:
|
|
||||||
# # cannot import shutdown here ):
|
|
||||||
# logger.error(
|
|
||||||
# 'Failed to run proxy config plugin %s',
|
|
||||||
# proxy_type, exc_info=True)
|
|
||||||
# os._exit(0) # pylint: disable=protected-access
|
|
||||||
# else:
|
|
||||||
# logger.info(
|
|
||||||
# 'Started proxy config plugin %s in %s sec',
|
|
||||||
# proxy_type, time.time() - proxyconfig_start)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# class AnnounceThread(StoppableThread):
|
|
||||||
# """A thread to manage regular announcing of this node"""
|
|
||||||
# name = "Announcer"
|
|
||||||
|
|
||||||
# def run(self):
|
|
||||||
# lastSelfAnnounced = 0
|
|
||||||
# while not self._stopped and state.shutdown == 0:
|
|
||||||
# processed = 0
|
|
||||||
# if lastSelfAnnounced < time.time() - UDPSocket.announceInterval:
|
|
||||||
# self.announceSelf()
|
|
||||||
# lastSelfAnnounced = time.time()
|
|
||||||
# if processed == 0:
|
|
||||||
# self.stop.wait(10)
|
|
||||||
|
|
||||||
# @staticmethod
|
|
||||||
# def announceSelf():
|
|
||||||
# """Announce our presence"""
|
|
||||||
# for connection in [udpSockets for udpSockets in BMConnectionPool().udpSockets.values()]:
|
|
||||||
# if not connection.announcing:
|
|
||||||
# continue
|
|
||||||
# for stream in state.streamsInWhichIAmParticipating:
|
|
||||||
# addr = (
|
|
||||||
# stream,
|
|
||||||
# # state.Peer('127.0.0.1',int( BMConfigParser().safeGet("bitmessagesettings", "port"))),
|
|
||||||
# # int(time.time()))
|
|
||||||
# # connection.append_write_buf(BMProto.assembleAddr([addr]))
|
|
||||||
# Peer(
|
|
||||||
# '127.0.0.1',
|
|
||||||
# BMConfigParser().safeGetInt(
|
|
||||||
# 'bitmessagesettings', 'port')),
|
|
||||||
# time.time())
|
|
||||||
# connection.append_write_buf(assemble_addr([addr]))
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Triggers main module"""
|
"""Triggers main module"""
|
||||||
mainprogram = MockMain()
|
mainprogram = MockMain()
|
||||||
|
|
|
@ -166,30 +166,30 @@ class Draft(Screen):
|
||||||
sendMessageToPeople = True
|
sendMessageToPeople = True
|
||||||
if sendMessageToPeople:
|
if sendMessageToPeople:
|
||||||
streamNumber, ripe = decodeAddress(toAddress)[2:]
|
streamNumber, ripe = decodeAddress(toAddress)[2:]
|
||||||
from addresses import addBMIfNotPresent
|
from pybitmessage.addresses import addBMIfNotPresent
|
||||||
toAddress = addBMIfNotPresent(toAddress)
|
toAddress = addBMIfNotPresent(toAddress)
|
||||||
stealthLevel = BMConfigParser().safeGetInt(
|
stealthLevel = BMConfigParser().safeGetInt(
|
||||||
'bitmessagesettings', 'ackstealthlevel')
|
'bitmessagesettings', 'ackstealthlevel')
|
||||||
from helper_ackPayload import genAckPayload
|
# from helper_ackPayload import genAckPayload
|
||||||
ackdata = genAckPayload(streamNumber, stealthLevel)
|
# ackdata = genAckPayload(streamNumber, stealthLevel)
|
||||||
sqlExecute(
|
# sqlExecute(
|
||||||
'''INSERT INTO sent VALUES
|
# '''INSERT INTO sent VALUES
|
||||||
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
|
# (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
|
||||||
'',
|
# '',
|
||||||
toAddress,
|
# toAddress,
|
||||||
ripe,
|
# ripe,
|
||||||
fromAddress,
|
# fromAddress,
|
||||||
subject,
|
# subject,
|
||||||
message,
|
# message,
|
||||||
ackdata,
|
# ackdata,
|
||||||
int(time.time()),
|
# int(time.time()),
|
||||||
int(time.time()),
|
# int(time.time()),
|
||||||
0,
|
# 0,
|
||||||
'msgqueued',
|
# 'msgqueued',
|
||||||
0,
|
# 0,
|
||||||
'draft',
|
# 'draft',
|
||||||
encoding,
|
# encoding,
|
||||||
BMConfigParser().safeGetInt('bitmessagesettings', 'ttl'))
|
# BMConfigParser().safeGetInt('bitmessagesettings', 'ttl'))
|
||||||
state.msg_counter_objs = src_object.children[2].children[0].ids
|
state.msg_counter_objs = src_object.children[2].children[0].ids
|
||||||
state.draft_count = str(int(state.draft_count) + 1) \
|
state.draft_count = str(int(state.draft_count) + 1) \
|
||||||
if state.association == fromAddress else state.draft_count
|
if state.association == fromAddress else state.draft_count
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# from pybitmessage.get_platform import platform
|
|
||||||
# from pybitmessage import identiconGeneration
|
|
||||||
|
|
||||||
# from pybitmessage import kivy_helper_search
|
|
||||||
# from pybitmessage.bmconfigparser import BMConfigParser
|
|
||||||
from pybitmessage.helper_sql import sqlExecute
|
from pybitmessage.helper_sql import sqlExecute
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
|
@ -21,8 +16,6 @@ from pybitmessage.baseclass.common import (
|
||||||
ThemeClsColor, toast, SwipeToDeleteItem,
|
ThemeClsColor, toast, SwipeToDeleteItem,
|
||||||
ShowTimeHistoy
|
ShowTimeHistoy
|
||||||
)
|
)
|
||||||
# from maildetail import MailDetail
|
|
||||||
# from trash import Trash
|
|
||||||
|
|
||||||
|
|
||||||
class Inbox(Screen):
|
class Inbox(Screen):
|
||||||
|
@ -34,22 +27,18 @@ class Inbox(Screen):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""Method Parsing the address"""
|
"""Method Parsing the address"""
|
||||||
# import pdb; pdb.set_trace()
|
|
||||||
super(Inbox, self).__init__(*args, **kwargs)
|
super(Inbox, self).__init__(*args, **kwargs)
|
||||||
Clock.schedule_once(self.init_ui, 0)
|
Clock.schedule_once(self.init_ui, 0)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def set_defaultAddress():
|
def set_defaultAddress():
|
||||||
"""This method set's default address"""
|
"""This method set's default address"""
|
||||||
# import pdb; pdb.set_trace()
|
|
||||||
|
|
||||||
if state.association == "":
|
if state.association == "":
|
||||||
if state.kivyapp.variable_1:
|
if state.kivyapp.variable_1:
|
||||||
state.association = state.kivyapp.variable_1[0]
|
state.association = state.kivyapp.variable_1[0]
|
||||||
|
|
||||||
def init_ui(self, dt=0):
|
def init_ui(self, dt=0):
|
||||||
"""Clock schdule for method inbox accounts"""
|
"""Clock schdule for method inbox accounts"""
|
||||||
# import pdb; pdb.set_trace()
|
|
||||||
self.loadMessagelist()
|
self.loadMessagelist()
|
||||||
|
|
||||||
def loadMessagelist(self, where="", what=""):
|
def loadMessagelist(self, where="", what=""):
|
||||||
|
@ -57,7 +46,6 @@ class Inbox(Screen):
|
||||||
self.set_defaultAddress()
|
self.set_defaultAddress()
|
||||||
self.account = state.association
|
self.account = state.association
|
||||||
if state.searcing_text:
|
if state.searcing_text:
|
||||||
# self.children[2].children[0].children[0].scroll_y = 1.0
|
|
||||||
self.ids.scroll_y.scroll_y = 1.0
|
self.ids.scroll_y.scroll_y = 1.0
|
||||||
where = ["subject", "message"]
|
where = ["subject", "message"]
|
||||||
what = state.searcing_text
|
what = state.searcing_text
|
||||||
|
@ -71,7 +59,6 @@ class Inbox(Screen):
|
||||||
state.kivyapp.get_inbox_count()
|
state.kivyapp.get_inbox_count()
|
||||||
self.set_inboxCount(state.inbox_count)
|
self.set_inboxCount(state.inbox_count)
|
||||||
for mail in self.queryreturn:
|
for mail in self.queryreturn:
|
||||||
# third_text = mail[3].replace('\n', ' ')
|
|
||||||
body = mail[3].decode() if isinstance(mail[3], bytes) else mail[3]
|
body = mail[3].decode() if isinstance(mail[3], bytes) else mail[3]
|
||||||
subject = mail[5].decode() if isinstance(mail[5], bytes) else mail[5]
|
subject = mail[5].decode() if isinstance(mail[5], bytes) else mail[5]
|
||||||
data.append(
|
data.append(
|
||||||
|
@ -117,9 +104,6 @@ class Inbox(Screen):
|
||||||
|
|
||||||
def inboxDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20):
|
def inboxDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20):
|
||||||
"""This method is used for retrieving inbox data"""
|
"""This method is used for retrieving inbox data"""
|
||||||
# self.queryreturn = kivy_helper_search.search_sql(
|
|
||||||
# xAddress, self.account, "inbox", where, what, False, start_indx, end_indx
|
|
||||||
# )
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def set_mdList(self, data):
|
def set_mdList(self, data):
|
||||||
|
@ -159,7 +143,6 @@ class Inbox(Screen):
|
||||||
what = state.searcing_text
|
what = state.searcing_text
|
||||||
self.inboxDataQuery("toaddress", where, what, total_message, 5)
|
self.inboxDataQuery("toaddress", where, what, total_message, 5)
|
||||||
for mail in self.queryreturn:
|
for mail in self.queryreturn:
|
||||||
# third_text = mail[3].replace('\n', ' ')
|
|
||||||
subject = mail[3].decode() if isinstance(mail[3], bytes) else mail[3]
|
subject = mail[3].decode() if isinstance(mail[3], bytes) else mail[3]
|
||||||
body = mail[5].decode() if isinstance(mail[5], bytes) else mail[5]
|
body = mail[5].decode() if isinstance(mail[5], bytes) else mail[5]
|
||||||
data.append(
|
data.append(
|
||||||
|
@ -211,29 +194,20 @@ class Inbox(Screen):
|
||||||
state.all_count = str(int(state.all_count) - 1)
|
state.all_count = str(int(state.all_count) - 1)
|
||||||
|
|
||||||
if int(state.inbox_count) <= 0:
|
if int(state.inbox_count) <= 0:
|
||||||
# self.ids.identi_tag.children[0].text = ''
|
|
||||||
self.ids.tag_label.text = ''
|
self.ids.tag_label.text = ''
|
||||||
self.ids.ml.remove_widget(
|
self.ids.ml.remove_widget(
|
||||||
instance.parent.parent)
|
instance.parent.parent)
|
||||||
toast('Deleted')
|
toast('Deleted')
|
||||||
# self.update_trash()
|
|
||||||
|
|
||||||
def archive(self, data_index, instance, *args):
|
def archive(self, data_index, instance, *args):
|
||||||
"""Archive inbox mail from inbox listing"""
|
"""Archive inbox mail from inbox listing"""
|
||||||
sqlExecute("UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", data_index)
|
# sqlExecute("UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", data_index)
|
||||||
self.ids.ml.remove_widget(instance.parent.parent)
|
self.ids.ml.remove_widget(instance.parent.parent)
|
||||||
self.update_trash()
|
self.update_trash()
|
||||||
|
|
||||||
def update_trash(self):
|
def update_trash(self):
|
||||||
"""Update trash screen mails which is deleted from inbox"""
|
"""Update trash screen mails which is deleted from inbox"""
|
||||||
self.manager.parent.ids.sc5.clear_widgets()
|
self.manager.parent.ids.sc5.clear_widgets()
|
||||||
# self.manager.parent.ids.sc5.add_widget(Trash())
|
|
||||||
# try:
|
|
||||||
# self.parent.screens[4].clear_widgets()
|
|
||||||
# self.parent.screens[4].add_widget(Trash())
|
|
||||||
# except Exception:
|
|
||||||
# self.parent.parent.screens[4].clear_widgets()
|
|
||||||
# self.parent.parent.screens[4].add_widget(Trash())
|
|
||||||
|
|
||||||
def refresh_callback(self, *args):
|
def refresh_callback(self, *args):
|
||||||
"""Method updates the state of application,
|
"""Method updates the state of application,
|
||||||
|
|
|
@ -179,8 +179,7 @@ class AppClosingPopup(Popup):
|
||||||
"""Action on closing window"""
|
"""Action on closing window"""
|
||||||
if text == 'Yes':
|
if text == 'Yes':
|
||||||
print("*******************EXITING FROM APPLICATION*******************")
|
print("*******************EXITING FROM APPLICATION*******************")
|
||||||
import pdb; pdb.set_trace()
|
from pybitmessage import shutdown
|
||||||
import shutdown
|
|
||||||
shutdown.doCleanShutdown()
|
shutdown.doCleanShutdown()
|
||||||
else:
|
else:
|
||||||
self.dismiss()
|
self.dismiss()
|
||||||
|
|
|
@ -6,12 +6,8 @@ import logging
|
||||||
import random
|
import random
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
# import queues
|
|
||||||
from pybitmessage import state
|
from pybitmessage import state
|
||||||
|
|
||||||
# from helper_sql import sql_ready, sqlExecute, sqlQuery
|
|
||||||
# from network import bmproto
|
|
||||||
|
|
||||||
logger = logging.getLogger('default')
|
logger = logging.getLogger('default')
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,30 +19,12 @@ class objectProcessor(threading.Thread):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
threading.Thread.__init__(self, name="objectProcessor")
|
threading.Thread.__init__(self, name="objectProcessor")
|
||||||
random.seed()
|
random.seed()
|
||||||
# It may be the case that the last time Bitmessage was running,
|
|
||||||
# the user closed it before it finished processing everything in the
|
|
||||||
# objectProcessorQueue. Assuming that Bitmessage wasn't closed
|
|
||||||
# forcefully, it should have saved the data in the queue into the
|
|
||||||
# objectprocessorqueue table. Let's pull it out.
|
|
||||||
|
|
||||||
# sql_ready.wait()
|
|
||||||
# queryreturn = sqlQuery(
|
|
||||||
# 'SELECT objecttype, data FROM objectprocessorqueue')
|
|
||||||
# for objectType, data in queryreturn:
|
|
||||||
# queues.objectProcessorQueue.put((objectType, data))
|
|
||||||
# sqlExecute('DELETE FROM objectprocessorqueue')
|
|
||||||
# logger.debug(
|
|
||||||
# 'Loaded %s objects from disk into the objectProcessorQueue.',
|
|
||||||
# len(queryreturn))
|
|
||||||
# self._ack_obj = bmproto.BMStringParser()
|
|
||||||
self.successfullyDecryptMessageTimings = []
|
self.successfullyDecryptMessageTimings = []
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Process the objects from `.queues.objectProcessorQueue`"""
|
"""Process the objects from `.queues.objectProcessorQueue`"""
|
||||||
while True:
|
while True:
|
||||||
# pylint: disable=unused-variable
|
# pylint: disable=unused-variable
|
||||||
# objectType, data = queues.objectProcessorQueue.get()
|
|
||||||
|
|
||||||
if state.shutdown:
|
if state.shutdown:
|
||||||
state.shutdown = 2
|
state.shutdown = 2
|
||||||
break
|
break
|
||||||
|
|
|
@ -87,25 +87,8 @@ class singleCleaner(StoppableThread):
|
||||||
if timeWeLastClearedInventoryAndPubkeysTables < \
|
if timeWeLastClearedInventoryAndPubkeysTables < \
|
||||||
int(time.time()) - 7380:
|
int(time.time()) - 7380:
|
||||||
timeWeLastClearedInventoryAndPubkeysTables = int(time.time())
|
timeWeLastClearedInventoryAndPubkeysTables = int(time.time())
|
||||||
import pdb;pdb.set_trace()
|
|
||||||
# Inventory().clean()
|
|
||||||
queues.workerQueue.put(('sendOnionPeerObj', ''))
|
queues.workerQueue.put(('sendOnionPeerObj', ''))
|
||||||
# pubkeys
|
|
||||||
# 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 = []
|
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:
|
for row in queryreturn:
|
||||||
if len(row) < 2:
|
if len(row) < 2:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
|
@ -121,35 +104,6 @@ class singleCleaner(StoppableThread):
|
||||||
elif status == 'msgsent':
|
elif status == 'msgsent':
|
||||||
self.resendMsg(ackData)
|
self.resendMsg(ackData)
|
||||||
deleteTrashMsgPermonantly()
|
deleteTrashMsgPermonantly()
|
||||||
# try:
|
|
||||||
# # Cleanup knownnodes and handle possible severe exception
|
|
||||||
# # while writing it to disk
|
|
||||||
# knownnodes.cleanupKnownNodes()
|
|
||||||
# except Exception as err:
|
|
||||||
# # pylint: disable=protected-access
|
|
||||||
# if "Errno 28" in str(err):
|
|
||||||
# self.logger.fatal(
|
|
||||||
# '(while writing knownnodes to disk)'
|
|
||||||
# ' Alert: Your disk or data storage volume is full.'
|
|
||||||
# )
|
|
||||||
# queues.UISignalQueue.put((
|
|
||||||
# 'alert',
|
|
||||||
# (tr._translate("MainWindow", "Disk full"),
|
|
||||||
# tr._translate(
|
|
||||||
# "MainWindow",
|
|
||||||
# 'Alert: Your disk or data storage volume'
|
|
||||||
# ' is full. Bitmessage will now exit.'),
|
|
||||||
# True)
|
|
||||||
# ))
|
|
||||||
# # FIXME redundant?
|
|
||||||
# if state.thisapp.daemon or not state.enableGUI:
|
|
||||||
# os._exit(1)
|
|
||||||
|
|
||||||
# inv/object tracking
|
|
||||||
|
|
||||||
# for connection in BMConnectionPool().connections():
|
|
||||||
# connection.clean()
|
|
||||||
|
|
||||||
# discovery tracking
|
# discovery tracking
|
||||||
exp = time.time() - singleCleaner.expireDiscoveredPeers
|
exp = time.time() - singleCleaner.expireDiscoveredPeers
|
||||||
reaper = (k for k, v in state.discoveredPeers.items() if v < exp)
|
reaper = (k for k, v in state.discoveredPeers.items() if v < exp)
|
||||||
|
@ -185,9 +139,6 @@ class singleCleaner(StoppableThread):
|
||||||
'updateStatusBar',
|
'updateStatusBar',
|
||||||
'Doing work necessary to again attempt to request a public key...'
|
'Doing work necessary to again attempt to request a public key...'
|
||||||
))
|
))
|
||||||
# sqlExecute(
|
|
||||||
# '''UPDATE sent SET status='msgqueued' WHERE toaddress=?''',
|
|
||||||
# address)
|
|
||||||
queues.workerQueue.put(('sendmessage', ''))
|
queues.workerQueue.put(('sendmessage', ''))
|
||||||
|
|
||||||
def resendMsg(self, ackdata):
|
def resendMsg(self, ackdata):
|
||||||
|
@ -196,9 +147,6 @@ class singleCleaner(StoppableThread):
|
||||||
'It has been a long time and we haven\'t heard an acknowledgement'
|
'It has been a long time and we haven\'t heard an acknowledgement'
|
||||||
' to our msg. Sending again.'
|
' to our msg. Sending again.'
|
||||||
)
|
)
|
||||||
# sqlExecute(
|
|
||||||
# '''UPDATE sent SET status='msgqueued' WHERE ackdata=?''',
|
|
||||||
# ackdata)
|
|
||||||
queues.workerQueue.put(('sendmessage', ''))
|
queues.workerQueue.put(('sendmessage', ''))
|
||||||
queues.UISignalQueue.put((
|
queues.UISignalQueue.put((
|
||||||
'updateStatusBar',
|
'updateStatusBar',
|
||||||
|
@ -210,10 +158,4 @@ def deleteTrashMsgPermonantly():
|
||||||
"""This method is used to delete old messages"""
|
"""This method is used to delete old messages"""
|
||||||
ndays_before_time = datetime.now() - timedelta(days=30)
|
ndays_before_time = datetime.now() - timedelta(days=30)
|
||||||
old_messages = time.mktime(ndays_before_time.timetuple())
|
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))
|
|
||||||
return
|
return
|
||||||
|
|
|
@ -20,21 +20,22 @@ MODE = "RGB"
|
||||||
|
|
||||||
def generate(Generate_string=None):
|
def generate(Generate_string=None):
|
||||||
"""Generating string"""
|
"""Generating string"""
|
||||||
hash_string = generate_hash(Generate_string)
|
# hash_string = generate_hash(Generate_string)
|
||||||
color = random_color(hash_string)
|
# color = random_color(hash_string)
|
||||||
# image = Image.new(MODE, V_RESOLUTION, BACKGROUND_COLOR)
|
# # image = Image.new(MODE, V_RESOLUTION, BACKGROUND_COLOR)
|
||||||
# image = generate_image(image, color, hash_string)
|
# # image = generate_image(image, color, hash_string)
|
||||||
image = open("/home/cis/Downloads/1.png")
|
# image = open("/home/cis/Downloads/1.png")
|
||||||
# image = image.resize(RESOLUTION, 0)
|
# # image = image.resize(RESOLUTION, 0)
|
||||||
data = BytesIO()
|
# data = BytesIO()
|
||||||
image.save(data, format='png')
|
# image.save(data, format='png')
|
||||||
data.seek(0)
|
# data.seek(0)
|
||||||
# yes you actually need this
|
# # yes you actually need this
|
||||||
im = CoreImage(BytesIO(data.read()), ext='png')
|
# im = CoreImage(BytesIO(data.read()), ext='png')
|
||||||
beeld = kiImage()
|
# beeld = kiImage()
|
||||||
# only use this line in first code instance
|
# # only use this line in first code instance
|
||||||
beeld.texture = im.texture
|
# beeld.texture = im.texture
|
||||||
return beeld
|
# return beeld
|
||||||
|
pass
|
||||||
# image.show()
|
# image.show()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -270,7 +270,7 @@ class NavigateApp(MDApp):
|
||||||
if os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(text)):
|
if os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(text)):
|
||||||
self.load_selected_Image(text)
|
self.load_selected_Image(text)
|
||||||
else:
|
else:
|
||||||
self.set_identicon(text)
|
# self.set_identicon(text)
|
||||||
self.root.ids.content_drawer.ids.reset_image.opacity = 0
|
self.root.ids.content_drawer.ids.reset_image.opacity = 0
|
||||||
self.root.ids.content_drawer.ids.reset_image.disabled = True
|
self.root.ids.content_drawer.ids.reset_image.disabled = True
|
||||||
address_label = self.current_address_label(
|
address_label = self.current_address_label(
|
||||||
|
@ -449,8 +449,8 @@ class NavigateApp(MDApp):
|
||||||
return state.imageDir + '/default_identicon/{}.png'.format(
|
return state.imageDir + '/default_identicon/{}.png'.format(
|
||||||
first_addr)
|
first_addr)
|
||||||
else:
|
else:
|
||||||
img = identiconGeneration.generate(first_addr)
|
# img = identiconGeneration.generate(first_addr)
|
||||||
instance.texture = img.texture
|
# instance.texture = img.texture
|
||||||
return
|
return
|
||||||
return state.imageDir + '/drawer_logo1.png'
|
return state.imageDir + '/drawer_logo1.png'
|
||||||
|
|
||||||
|
@ -785,10 +785,11 @@ class NavigateApp(MDApp):
|
||||||
|
|
||||||
def set_identicon(self, text):
|
def set_identicon(self, text):
|
||||||
"""Show identicon in address spinner"""
|
"""Show identicon in address spinner"""
|
||||||
img = identiconGeneration.generate(text)
|
# img = identiconGeneration.generate(text)
|
||||||
# self.root.children[0].children[0].ids.btn.children[1].texture = (img.texture)
|
# self.root.children[0].children[0].ids.btn.children[1].texture = (img.texture)
|
||||||
# below line is for displaing logo
|
# below line is for displaing logo
|
||||||
self.root.ids.content_drawer.ids.top_box.children[0].texture = (img.texture)
|
# self.root.ids.content_drawer.ids.top_box.children[0].texture = (img.texture)
|
||||||
|
pass
|
||||||
|
|
||||||
def set_mail_detail_header(self):
|
def set_mail_detail_header(self):
|
||||||
"""Setting the details of the page"""
|
"""Setting the details of the page"""
|
||||||
|
@ -926,7 +927,7 @@ class NavigateApp(MDApp):
|
||||||
|
|
||||||
def rest_default_avatar_img(self):
|
def rest_default_avatar_img(self):
|
||||||
"""set default avatar generated image"""
|
"""set default avatar generated image"""
|
||||||
self.set_identicon(state.association)
|
# self.set_identicon(state.association)
|
||||||
img_path = state.imageDir + '/default_identicon/{}.png'.format(state.association)
|
img_path = state.imageDir + '/default_identicon/{}.png'.format(state.association)
|
||||||
try:
|
try:
|
||||||
if os.path.exists(img_path):
|
if os.path.exists(img_path):
|
||||||
|
|
89
src/tests/mock/pybitmessage/shutdown.py
Normal file
89
src/tests/mock/pybitmessage/shutdown.py
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
"""shutdown function"""
|
||||||
|
import os
|
||||||
|
import queue as Queue
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
|
||||||
|
from pybitmessage import state
|
||||||
|
# from debug import logger
|
||||||
|
# from helper_sql import sqlQuery, sqlStoredProcedure
|
||||||
|
# from inventory import Inventory
|
||||||
|
# from knownnodes import saveKnownNodes
|
||||||
|
from pybitmessage.network.threads import StoppableThread
|
||||||
|
from pybitmessage.queues import (
|
||||||
|
addressGeneratorQueue, objectProcessorQueue, UISignalQueue, workerQueue)
|
||||||
|
|
||||||
|
|
||||||
|
def doCleanShutdown():
|
||||||
|
"""
|
||||||
|
Used to tell all the treads to finish work and exit.
|
||||||
|
"""
|
||||||
|
state.shutdown = 1
|
||||||
|
|
||||||
|
objectProcessorQueue.put(('checkShutdownVariable', 'no data'))
|
||||||
|
for thread in threading.enumerate():
|
||||||
|
if thread.is_alive() and isinstance(thread, StoppableThread):
|
||||||
|
thread.stopThread()
|
||||||
|
|
||||||
|
UISignalQueue.put((
|
||||||
|
'updateStatusBar',
|
||||||
|
'Saving the knownNodes list of peers to disk...'))
|
||||||
|
# logger.info('Saving knownNodes list of peers to disk')
|
||||||
|
# saveKnownNodes()
|
||||||
|
# logger.info('Done saving knownNodes list of peers to disk')
|
||||||
|
UISignalQueue.put((
|
||||||
|
'updateStatusBar',
|
||||||
|
'Done saving the knownNodes list of peers to disk.'))
|
||||||
|
# logger.info('Flushing inventory in memory out to disk...')
|
||||||
|
UISignalQueue.put((
|
||||||
|
'updateStatusBar',
|
||||||
|
'Flushing inventory in memory out to disk.'
|
||||||
|
' This should normally only take a second...'))
|
||||||
|
# Inventory().flush()
|
||||||
|
|
||||||
|
# Verify that the objectProcessor has finished exiting. It should have
|
||||||
|
# incremented the shutdown variable from 1 to 2. This must finish before
|
||||||
|
# we command the sqlThread to exit.
|
||||||
|
while state.shutdown == 1:
|
||||||
|
time.sleep(.1)
|
||||||
|
|
||||||
|
# Wait long enough to guarantee that any running proof of work worker
|
||||||
|
# threads will check the shutdown variable and exit. If the main thread
|
||||||
|
# closes before they do then they won't stop.
|
||||||
|
time.sleep(.25)
|
||||||
|
|
||||||
|
for thread in threading.enumerate():
|
||||||
|
if (
|
||||||
|
thread is not threading.currentThread()
|
||||||
|
and isinstance(thread, StoppableThread)
|
||||||
|
and thread.name != 'SQL'
|
||||||
|
):
|
||||||
|
# logger.debug("Waiting for thread %s", thread.name)
|
||||||
|
thread.join()
|
||||||
|
|
||||||
|
# This one last useless query will guarantee that the previous flush
|
||||||
|
# committed and that the
|
||||||
|
# objectProcessorThread committed before we close the program.
|
||||||
|
# sqlQuery('SELECT address FROM subscriptions')
|
||||||
|
# logger.info('Finished flushing inventory.')
|
||||||
|
# sqlStoredProcedure('exit')
|
||||||
|
|
||||||
|
# flush queues
|
||||||
|
for queue in (
|
||||||
|
workerQueue, UISignalQueue, addressGeneratorQueue,
|
||||||
|
objectProcessorQueue):
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
queue.get(False)
|
||||||
|
queue.task_done()
|
||||||
|
except Queue.Empty:
|
||||||
|
break
|
||||||
|
|
||||||
|
# if state.thisapp.daemon or not state.enableGUI:
|
||||||
|
# logger.info('Clean shutdown complete.')
|
||||||
|
# state.thisapp.cleanup()
|
||||||
|
# os._exit(0) # pylint: disable=protected-access
|
||||||
|
# else:
|
||||||
|
# logger.info('Core shutdown complete.')
|
||||||
|
# for thread in threading.enumerate():
|
||||||
|
# logger.debug('Thread %s still running', thread.name)
|
Reference in New Issue
Block a user