minor changes to previous commit
This commit is contained in:
parent
95c1dbda5a
commit
ea3cf9e00e
|
@ -727,16 +727,15 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
# This is not a particularly commonly used API function. Before we
|
# This is not a particularly commonly used API function. Before we
|
||||||
# use it we'll need to fill out a field in our inventory database
|
# use it we'll need to fill out a field in our inventory database
|
||||||
# which is blank by default (first20bytesofencryptedmessage).
|
# which is blank by default (first20bytesofencryptedmessage).
|
||||||
parameters = ''
|
|
||||||
queryreturn = sqlQuery(
|
queryreturn = sqlQuery(
|
||||||
'''SELECT hash, payload FROM inventory WHERE first20bytesofencryptedmessage = '' and objecttype = 'msg' ; ''')
|
'''SELECT hash, payload FROM inventory WHERE first20bytesofencryptedmessage = '' and objecttype = 'msg' ; ''')
|
||||||
|
with SqlBulkExecute() as sql:
|
||||||
for row in queryreturn:
|
for row in queryreturn:
|
||||||
hash, payload = row
|
hash, payload = row
|
||||||
readPosition = 16 # Nonce length + time length
|
readPosition = 16 # Nonce length + time length
|
||||||
readPosition += decodeVarint(payload[readPosition:readPosition+10])[1] # Stream Number length
|
readPosition += decodeVarint(payload[readPosition:readPosition+10])[1] # Stream Number length
|
||||||
t = (payload[readPosition:readPosition+20],hash)
|
t = (payload[readPosition:readPosition+20],hash)
|
||||||
sqlExecute('''UPDATE inventory SET first20bytesofencryptedmessage=? WHERE hash=?; ''', t)
|
sql.execute('''UPDATE inventory SET first20bytesofencryptedmessage=? WHERE hash=?; ''', t)
|
||||||
|
|
||||||
queryreturn = sqlQuery('''SELECT payload FROM inventory WHERE first20bytesofencryptedmessage = ?''',
|
queryreturn = sqlQuery('''SELECT payload FROM inventory WHERE first20bytesofencryptedmessage = ?''',
|
||||||
requestedHash)
|
requestedHash)
|
||||||
|
|
|
@ -558,7 +558,7 @@ class MyForm(QtGui.QMainWindow):
|
||||||
else:
|
else:
|
||||||
where = "toaddress || fromaddress || subject || message"
|
where = "toaddress || fromaddress || subject || message"
|
||||||
|
|
||||||
sql = '''
|
sqlStatement = '''
|
||||||
SELECT toaddress, fromaddress, subject, message, status, ackdata, lastactiontime
|
SELECT toaddress, fromaddress, subject, message, status, ackdata, lastactiontime
|
||||||
FROM sent WHERE folder="sent" AND %s LIKE ?
|
FROM sent WHERE folder="sent" AND %s LIKE ?
|
||||||
ORDER BY lastactiontime
|
ORDER BY lastactiontime
|
||||||
|
@ -567,7 +567,7 @@ class MyForm(QtGui.QMainWindow):
|
||||||
while self.ui.tableWidgetSent.rowCount() > 0:
|
while self.ui.tableWidgetSent.rowCount() > 0:
|
||||||
self.ui.tableWidgetSent.removeRow(0)
|
self.ui.tableWidgetSent.removeRow(0)
|
||||||
|
|
||||||
queryreturn = sqlQuery(sql, what)
|
queryreturn = sqlQuery(sqlStatement, what)
|
||||||
for row in queryreturn:
|
for row in queryreturn:
|
||||||
toAddress, fromAddress, subject, message, status, ackdata, lastactiontime = row
|
toAddress, fromAddress, subject, message, status, ackdata, lastactiontime = row
|
||||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||||
|
@ -678,7 +678,7 @@ class MyForm(QtGui.QMainWindow):
|
||||||
else:
|
else:
|
||||||
where = "toaddress || fromaddress || subject || message"
|
where = "toaddress || fromaddress || subject || message"
|
||||||
|
|
||||||
sql = '''
|
sqlStatement = '''
|
||||||
SELECT msgid, toaddress, fromaddress, subject, received, message, read
|
SELECT msgid, toaddress, fromaddress, subject, received, message, read
|
||||||
FROM inbox WHERE folder="inbox" AND %s LIKE ?
|
FROM inbox WHERE folder="inbox" AND %s LIKE ?
|
||||||
ORDER BY received
|
ORDER BY received
|
||||||
|
@ -689,7 +689,7 @@ class MyForm(QtGui.QMainWindow):
|
||||||
|
|
||||||
font = QFont()
|
font = QFont()
|
||||||
font.setBold(True)
|
font.setBold(True)
|
||||||
queryreturn = sqlQuery(sql, what)
|
queryreturn = sqlQuery(sqlStatement, what)
|
||||||
for row in queryreturn:
|
for row in queryreturn:
|
||||||
msgid, toAddress, fromAddress, subject, received, message, read = row
|
msgid, toAddress, fromAddress, subject, received, message, read = row
|
||||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||||
|
|
|
@ -7,6 +7,7 @@ sqlLock = threading.Lock()
|
||||||
|
|
||||||
def sqlQuery(sqlStatement, *args):
|
def sqlQuery(sqlStatement, *args):
|
||||||
sqlLock.acquire()
|
sqlLock.acquire()
|
||||||
|
print 'sqlQuery args are:', args
|
||||||
sqlSubmitQueue.put(sqlStatement)
|
sqlSubmitQueue.put(sqlStatement)
|
||||||
|
|
||||||
if args == ():
|
if args == ():
|
||||||
|
@ -21,6 +22,7 @@ def sqlQuery(sqlStatement, *args):
|
||||||
|
|
||||||
def sqlExecute(sqlStatement, *args):
|
def sqlExecute(sqlStatement, *args):
|
||||||
sqlLock.acquire()
|
sqlLock.acquire()
|
||||||
|
print 'sqlExecute args are:', args
|
||||||
sqlSubmitQueue.put(sqlStatement)
|
sqlSubmitQueue.put(sqlStatement)
|
||||||
|
|
||||||
if args == ():
|
if args == ():
|
||||||
|
|
Reference in New Issue
Block a user