UTC time in pseudo-mailing-list broadcasts #106
|
@ -122,14 +122,8 @@ def encodeAddress(version,stream,ripe):
|
||||||
def decodeAddress(address):
|
def decodeAddress(address):
|
||||||
#returns (status, address version number, stream number, data (almost certainly a ripe hash))
|
#returns (status, address version number, stream number, data (almost certainly a ripe hash))
|
||||||
|
|
||||||
"""#check for the BM- at the front of the address. If it isn't there, this address might be for a different version of Bitmessage
|
address = str(address).strip()
|
||||||
if address[:3] != 'BM-':
|
|
||||||
status = 'missingbm'
|
|
||||||
return status,0,0,0
|
|
||||||
#take off the BM-
|
|
||||||
integer = decodeBase58(address[3:])"""
|
|
||||||
|
|
||||||
#changed Bitmessage to accept addresses that lack the "BM-" prefix.
|
|
||||||
if address[:3] == 'BM-':
|
if address[:3] == 'BM-':
|
||||||
integer = decodeBase58(address[3:])
|
integer = decodeBase58(address[3:])
|
||||||
else:
|
else:
|
||||||
|
@ -189,6 +183,7 @@ def decodeAddress(address):
|
||||||
return status,addressVersionNumber,streamNumber,'\x00\x00'+data[bytesUsedByVersionNumber+bytesUsedByStreamNumber:-4]
|
return status,addressVersionNumber,streamNumber,'\x00\x00'+data[bytesUsedByVersionNumber+bytesUsedByStreamNumber:-4]
|
||||||
|
|
||||||
def addBMIfNotPresent(address):
|
def addBMIfNotPresent(address):
|
||||||
|
address = str(address).strip()
|
||||||
if address[:3] != 'BM-':
|
if address[:3] != 'BM-':
|
||||||
return 'BM-'+address
|
return 'BM-'+address
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -46,7 +46,7 @@ import pickle
|
||||||
import random
|
import random
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import threading #used for the locks, not for the threads
|
import threading #used for the locks, not for the threads
|
||||||
from time import strftime, localtime
|
from time import strftime, localtime, gmtime
|
||||||
import os
|
import os
|
||||||
import shutil #used for moving the messages.dat file
|
import shutil #used for moving the messages.dat file
|
||||||
import string
|
import string
|
||||||
|
@ -944,8 +944,8 @@ class receiveDataThread(QThread):
|
||||||
#Let us send out this message as a broadcast
|
#Let us send out this message as a broadcast
|
||||||
subject = self.addMailingListNameToSubject(subject,mailingListName)
|
subject = self.addMailingListNameToSubject(subject,mailingListName)
|
||||||
#Let us now send this message out as a broadcast
|
#Let us now send this message out as a broadcast
|
||||||
message = 'Message ostensibly from ' + fromAddress + ':\n\n' + body
|
message = strftime("%a, %Y-%m-%d %H:%M:%S UTC",gmtime()) + ' Message ostensibly from ' + fromAddress + ':\n\n' + body
|
||||||
fromAddress = toAddress #The fromAddress for the broadcast is the toAddress (my address) for the msg message we are currently processing.
|
fromAddress = toAddress #The fromAddress for the broadcast that we are about to send is the toAddress (my address) for the msg message we are currently processing.
|
||||||
ackdata = OpenSSL.rand(32) #We don't actually need the ackdata for acknowledgement since this is a broadcast message but we can use it to update the user interface when the POW is done generating.
|
ackdata = OpenSSL.rand(32) #We don't actually need the ackdata for acknowledgement since this is a broadcast message but we can use it to update the user interface when the POW is done generating.
|
||||||
toAddress = '[Broadcast subscribers]'
|
toAddress = '[Broadcast subscribers]'
|
||||||
ripe = ''
|
ripe = ''
|
||||||
|
@ -1287,37 +1287,30 @@ class receiveDataThread(QThread):
|
||||||
print 'sending pubkey'
|
print 'sending pubkey'
|
||||||
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
||||||
headerData += 'pubkey\x00\x00\x00\x00\x00\x00'
|
headerData += 'pubkey\x00\x00\x00\x00\x00\x00'
|
||||||
headerData += pack('>L',len(payload)) #payload length. Note that we add an extra 8 for the nonce.
|
headerData += pack('>L',len(payload)) #payload length.
|
||||||
headerData += hashlib.sha512(payload).digest()[:4]
|
headerData += hashlib.sha512(payload).digest()[:4]
|
||||||
self.sock.send(headerData + payload)
|
self.sock.send(headerData + payload)
|
||||||
elif objectType == 'getpubkey':
|
elif objectType == 'getpubkey' or objectType == 'pubkeyrequest':
|
||||||
print 'sending getpubkey'
|
print 'sending getpubkey'
|
||||||
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
||||||
headerData += 'getpubkey\x00\x00\x00'
|
headerData += 'getpubkey\x00\x00\x00'
|
||||||
headerData += pack('>L',len(payload)) #payload length. Note that we add an extra 8 for the nonce.
|
headerData += pack('>L',len(payload)) #payload length.
|
||||||
headerData += hashlib.sha512(payload).digest()[:4]
|
headerData += hashlib.sha512(payload).digest()[:4]
|
||||||
self.sock.send(headerData + payload)
|
self.sock.send(headerData + payload)
|
||||||
elif objectType == 'msg':
|
elif objectType == 'msg':
|
||||||
print 'sending msg'
|
print 'sending msg'
|
||||||
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
||||||
headerData += 'msg\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
headerData += 'msg\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||||
headerData += pack('>L',len(payload)) #payload length. Note that we add an extra 8 for the nonce.
|
headerData += pack('>L',len(payload)) #payload length.
|
||||||
headerData += hashlib.sha512(payload).digest()[:4]
|
headerData += hashlib.sha512(payload).digest()[:4]
|
||||||
self.sock.send(headerData + payload)
|
self.sock.send(headerData + payload)
|
||||||
elif objectType == 'broadcast':
|
elif objectType == 'broadcast':
|
||||||
print 'sending broadcast'
|
print 'sending broadcast'
|
||||||
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
||||||
headerData += 'broadcast\x00\x00\x00'
|
headerData += 'broadcast\x00\x00\x00'
|
||||||
headerData += pack('>L',len(payload)) #payload length. Note that we add an extra 8 for the nonce.
|
headerData += pack('>L',len(payload)) #payload length.
|
||||||
headerData += hashlib.sha512(payload).digest()[:4]
|
headerData += hashlib.sha512(payload).digest()[:4]
|
||||||
self.sock.send(headerData + payload)
|
self.sock.send(headerData + payload)
|
||||||
elif objectType == 'getpubkey' or objectType == 'pubkeyrequest':
|
|
||||||
print 'sending getpubkey'
|
|
||||||
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
|
||||||
headerData += 'getpubkey\x00\x00\x00' #version command
|
|
||||||
headerData += pack('>L',len(payload)) #payload length
|
|
||||||
headerData += hashlib.sha512(payload).digest()[0:4]
|
|
||||||
self.sock.send(headerData + payload)
|
|
||||||
else:
|
else:
|
||||||
sys.stderr.write('Error: sendData has been asked to send a strange objectType: %s\n' % str(objectType))
|
sys.stderr.write('Error: sendData has been asked to send a strange objectType: %s\n' % str(objectType))
|
||||||
|
|
||||||
|
@ -4650,20 +4643,16 @@ class MyForm(QtGui.QMainWindow):
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
def on_action_InboxMessageForceHtml(self):
|
def on_action_InboxMessageForceHtml(self):
|
||||||
# Updated to work with all characters. Previously, non-english characters caused errors.
|
currentInboxRow = self.ui.tableWidgetInbox.currentRow()
|
||||||
try:
|
lines = self.ui.tableWidgetInbox.item(currentInboxRow,2).data(Qt.UserRole).toPyObject().split('\n')
|
||||||
lines = str(self.ui.textEditInboxMessage.toPlainText()).split('\n')
|
|
||||||
except UnicodeEncodeError:
|
|
||||||
currentInboxRow = self.ui.tableWidgetInbox.currentRow()
|
|
||||||
self.ui.textEditInboxMessage.setHtml(self.ui.tableWidgetInbox.item(currentInboxRow,2).data(Qt.UserRole).toPyObject())
|
|
||||||
return
|
|
||||||
from_prefix = 'Message ostensibly from '
|
|
||||||
for i in xrange(len(lines)):
|
for i in xrange(len(lines)):
|
||||||
if lines[i].find(from_prefix) != -1:
|
if lines[i].contains('Message ostensibly from '):
|
||||||
lines[i] = '<p style="font-size: 12px; color: grey;">%s<span style="font-size: 12px; color: black;">%s</span></p>' % (from_prefix,lines[i][24:-1])
|
lines[i] = '<p style="font-size: 12px; color: grey;">%s</span></p>' % (lines[i])
|
||||||
elif lines[i] == '------------------------------------------------------':
|
elif lines[i] == '------------------------------------------------------':
|
||||||
lines[i] = '<hr>'
|
lines[i] = '<hr>'
|
||||||
content = '\n'.join(lines)
|
content = ''
|
||||||
|
for i in xrange(len(lines)):
|
||||||
|
content += lines[i] + '<br>'
|
||||||
content = content.replace('\n\n', '<br><br>')
|
content = content.replace('\n\n', '<br><br>')
|
||||||
self.ui.textEditInboxMessage.setHtml(QtCore.QString(content))
|
self.ui.textEditInboxMessage.setHtml(QtCore.QString(content))
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user