This repository has been archived on 2024-12-09. You can view files and clone it, but cannot push or open issues or pull requests.
PyBitmessage-2024-12-09/src/mpybit.py

108 lines
4.0 KiB
Python
Raw Normal View History

2018-07-03 12:06:20 +02:00
import threading
import time
2018-07-03 12:06:20 +02:00
from addresses import addBMIfNotPresent, decodeAddress
from bmconfigparser import BMConfigParser
2018-07-03 12:06:20 +02:00
from helper_ackPayload import genAckPayload
2018-07-03 12:06:20 +02:00
from helper_sql import sqlExecute
from kivy.app import App
from kivy.core.window import Window
from kivy.uix.boxlayout import BoxLayout
import queues
2018-07-03 12:06:20 +02:00
import shutdown
statusIconColor = 'red'
2018-07-03 12:06:20 +02:00
class LoginScreen(BoxLayout):
"""This will use for sending message to recipents from mobile client."""
def send(self):
2018-07-03 12:06:20 +02:00
"""Send used for sending message with title and body."""
queues.apiAddressGeneratorReturnQueue.queue.clear()
streamNumberForAddress = 1
label = "CisDevelper"
eighteenByteRipe = False
nonceTrialsPerByte = 1000
payloadLengthExtraBytes = 1000
2018-07-03 12:06:20 +02:00
print("BREAK POINT STARTING")
queues.addressGeneratorQueue.put(
(
'createRandomAddress', 4,
streamNumberForAddress, label, 1,
"", eighteenByteRipe, nonceTrialsPerByte,
payloadLengthExtraBytes
)
)
print(BMConfigParser().sections(), "BMConfigParser().sections()")
fromAddress = queues.apiAddressGeneratorReturnQueue.get()
2018-07-03 12:06:20 +02:00
print("BREAK POINT ENDING")
toAddress = "BM-2cWyUfBdY2FbgyuCb7abFZ49JYxSzUhNFe"
message = self.ids.user_input.text
subject = 'Test'
encoding = 3
print("message: ", self.ids.user_input.text)
sendMessageToPeople = True
if sendMessageToPeople:
if toAddress != '':
2018-07-03 12:06:20 +02:00
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
toAddress)
if status == 'success':
toAddress = addBMIfNotPresent(toAddress)
if addressVersionNumber > 4 or addressVersionNumber <= 1:
print("addressVersionNumber > 4 or addressVersionNumber <= 1")
if streamNumber > 1 or streamNumber == 0:
print("streamNumber > 1 or streamNumber == 0")
if statusIconColor == 'red':
print("shared.statusIconColor == 'red'")
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))
print("sqlExecute successfully ##### ##################")
2018-07-03 12:06:20 +02:00
for i in threading.enumerate():
print(i.name)
return None
2018-07-03 12:06:20 +02:00
def sayexit(self):
"""This method will exit the application screen."""
2018-07-03 12:06:20 +02:00
print("**************************EXITING FROM APPLICATION*****************************")
shutdown.doCleanShutdown()
Window.close()
2018-07-03 12:06:20 +02:00
class MainApp(App):
"""The App class is the base for creating Kivy applications
Think of it as your main entry point into the Kivy run loop."""
def build(self):
"""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()