UTC time in pseudo-mailing-list broadcasts #106

Merged
Atheros1 merged 3 commits from master into master 2013-04-04 20:45:54 +02:00
2 changed files with 17 additions and 33 deletions

View File

@ -122,14 +122,8 @@ def encodeAddress(version,stream,ripe):
def decodeAddress(address):
#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
if address[:3] != 'BM-':
status = 'missingbm'
return status,0,0,0
#take off the BM-
integer = decodeBase58(address[3:])"""
address = str(address).strip()
#changed Bitmessage to accept addresses that lack the "BM-" prefix.
if address[:3] == 'BM-':
integer = decodeBase58(address[3:])
else:
@ -189,6 +183,7 @@ def decodeAddress(address):
return status,addressVersionNumber,streamNumber,'\x00\x00'+data[bytesUsedByVersionNumber+bytesUsedByStreamNumber:-4]
def addBMIfNotPresent(address):
address = str(address).strip()
if address[:3] != 'BM-':
return 'BM-'+address
else:

View File

@ -46,7 +46,7 @@ import pickle
import random
import sqlite3
import threading #used for the locks, not for the threads
from time import strftime, localtime
from time import strftime, localtime, gmtime
import os
import shutil #used for moving the messages.dat file
import string
@ -944,8 +944,8 @@ class receiveDataThread(QThread):
#Let us send out this message as a broadcast
subject = self.addMailingListNameToSubject(subject,mailingListName)
#Let us now send this message out as a broadcast
message = '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.
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 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.
toAddress = '[Broadcast subscribers]'
ripe = ''
@ -1287,37 +1287,30 @@ class receiveDataThread(QThread):
print 'sending pubkey'
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
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]
self.sock.send(headerData + payload)
elif objectType == 'getpubkey':
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'
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]
self.sock.send(headerData + payload)
elif objectType == 'msg':
print 'sending msg'
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 += 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]
self.sock.send(headerData + payload)
elif objectType == 'broadcast':
print 'sending broadcast'
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
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]
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:
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
def on_action_InboxMessageForceHtml(self):
# Updated to work with all characters. Previously, non-english characters caused errors.
try:
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 '
lines = self.ui.tableWidgetInbox.item(currentInboxRow,2).data(Qt.UserRole).toPyObject().split('\n')
for i in xrange(len(lines)):
if lines[i].find(from_prefix) != -1:
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])
if lines[i].contains('Message ostensibly from '):
lines[i] = '<p style="font-size: 12px; color: grey;">%s</span></p>' % (lines[i])
elif lines[i] == '------------------------------------------------------':
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>')
self.ui.textEditInboxMessage.setHtml(QtCore.QString(content))