2018-07-03 12:06:20 +02:00
|
|
|
import time
|
2018-07-03 11:08:02 +02:00
|
|
|
|
2018-07-09 13:17:59 +02:00
|
|
|
from kivy.app import App
|
|
|
|
from kivy.core.window import Window
|
|
|
|
from kivy.uix.boxlayout import BoxLayout
|
|
|
|
from kivy.uix.gridlayout import GridLayout
|
|
|
|
|
2018-07-07 14:11:58 +02:00
|
|
|
from debug import logger
|
|
|
|
|
2018-07-03 12:06:20 +02:00
|
|
|
from addresses import addBMIfNotPresent, decodeAddress
|
2018-07-03 11:08:02 +02:00
|
|
|
|
|
|
|
from bmconfigparser import BMConfigParser
|
2018-07-03 12:06:20 +02:00
|
|
|
|
2018-07-03 11:08:02 +02:00
|
|
|
from helper_ackPayload import genAckPayload
|
2018-07-03 12:06:20 +02:00
|
|
|
|
|
|
|
from helper_sql import sqlExecute
|
|
|
|
|
2018-07-03 11:08:02 +02:00
|
|
|
import queues
|
2018-07-03 12:06:20 +02:00
|
|
|
|
2018-07-03 11:08:02 +02:00
|
|
|
import shutdown
|
|
|
|
statusIconColor = 'red'
|
|
|
|
|
|
|
|
|
2018-07-09 13:17:59 +02:00
|
|
|
class LoginScreen(BoxLayout):
|
2018-07-03 12:06:20 +02:00
|
|
|
"""This will use for sending message to recipents from mobile client."""
|
2018-07-03 11:08:02 +02:00
|
|
|
|
|
|
|
def send(self):
|
2018-07-07 14:11:58 +02:00
|
|
|
"""It is used for sending message with subject and body."""
|
2018-07-03 11:08:02 +02:00
|
|
|
queues.apiAddressGeneratorReturnQueue.queue.clear()
|
|
|
|
streamNumberForAddress = 1
|
|
|
|
label = "CisDevelper"
|
|
|
|
eighteenByteRipe = False
|
|
|
|
nonceTrialsPerByte = 1000
|
|
|
|
payloadLengthExtraBytes = 1000
|
2018-07-03 16:00:19 +02:00
|
|
|
queues.addressGeneratorQueue.put((
|
|
|
|
'createRandomAddress', 4,
|
|
|
|
streamNumberForAddress, label, 1,
|
|
|
|
"", eighteenByteRipe, nonceTrialsPerByte,
|
|
|
|
payloadLengthExtraBytes
|
|
|
|
))
|
2018-07-03 11:08:02 +02:00
|
|
|
fromAddress = queues.apiAddressGeneratorReturnQueue.get()
|
|
|
|
toAddress = "BM-2cWyUfBdY2FbgyuCb7abFZ49JYxSzUhNFe"
|
|
|
|
message = self.ids.user_input.text
|
|
|
|
subject = 'Test'
|
|
|
|
encoding = 3
|
|
|
|
sendMessageToPeople = True
|
|
|
|
if sendMessageToPeople:
|
|
|
|
if toAddress != '':
|
2018-07-03 12:06:20 +02:00
|
|
|
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
|
|
|
|
toAddress)
|
2018-07-03 11:08:02 +02:00
|
|
|
if status == 'success':
|
|
|
|
toAddress = addBMIfNotPresent(toAddress)
|
|
|
|
|
|
|
|
if addressVersionNumber > 4 or addressVersionNumber <= 1:
|
2018-07-07 14:11:58 +02:00
|
|
|
logger.info("addressVersionNumber > 4 or addressVersionNumber <= 1")
|
2018-07-03 11:08:02 +02:00
|
|
|
if streamNumber > 1 or streamNumber == 0:
|
2018-07-07 14:11:58 +02:00
|
|
|
logger.info("streamNumber > 1 or streamNumber == 0")
|
2018-07-03 11:08:02 +02:00
|
|
|
if statusIconColor == 'red':
|
2018-07-07 14:11:58 +02:00
|
|
|
logger.info("shared.statusIconColor == 'red'")
|
2018-07-03 11:08:02 +02:00
|
|
|
stealthLevel = BMConfigParser().safeGetInt(
|
|
|
|
'bitmessagesettings', 'ackstealthlevel')
|
|
|
|
ackdata = genAckPayload(streamNumber, stealthLevel)
|
|
|
|
sqlExecute(
|
|
|
|
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
|
|
|
|
'',
|
|
|
|
toAddress,
|
|
|
|
ripe,
|
|
|
|
fromAddress,
|
|
|
|
subject,
|
|
|
|
message,
|
|
|
|
ackdata,
|
|
|
|
int(time.time()),
|
|
|
|
int(time.time()),
|
|
|
|
0,
|
|
|
|
'msgqueued',
|
|
|
|
0,
|
|
|
|
'sent',
|
|
|
|
encoding,
|
|
|
|
BMConfigParser().getint('bitmessagesettings', 'ttl'))
|
|
|
|
queues.workerQueue.put(('sendmessage', toAddress))
|
|
|
|
return None
|
|
|
|
|
2018-07-03 12:06:20 +02:00
|
|
|
def sayexit(self):
|
2018-07-07 14:11:58 +02:00
|
|
|
"""Method will exit the application screen."""
|
2018-07-03 11:08:02 +02:00
|
|
|
shutdown.doCleanShutdown()
|
|
|
|
Window.close()
|
|
|
|
|
|
|
|
|
2018-07-03 12:06:20 +02:00
|
|
|
class MainApp(App):
|
2018-07-03 12:15:42 +02:00
|
|
|
"""The App class is the base for creating Kivy applications
|
|
|
|
Think of it as your main entry point into the Kivy run loop."""
|
2018-07-07 14:11:58 +02:00
|
|
|
|
2018-07-03 11:08:02 +02:00
|
|
|
def build(self):
|
2018-07-07 14:11:58 +02:00
|
|
|
"""To initialize an app with a widget tree, we need to override the build().
|
|
|
|
method in our app class and return the widget tree which we have constructed..
|
|
|
|
"""
|
2018-07-03 12:06:20 +02:00
|
|
|
return LoginScreen()
|