2018-05-26 14:43:21 +02:00
|
|
|
# pylint: disable=too-many-locals
|
|
|
|
"""
|
|
|
|
This program can be used to print out everything in your Inbox or Sent folders and also take things out of the trash.
|
|
|
|
Scroll down to the bottom to see the functions that you can uncomment. Save then run this file.
|
|
|
|
The functions which only read the database file seem to function just
|
|
|
|
fine even if you have Bitmessage running but you should definitly close
|
|
|
|
it before running the functions that make changes (like taking items out
|
|
|
|
of the trash).
|
|
|
|
"""
|
|
|
|
|
|
|
|
from __future__ import absolute_import
|
2013-02-11 22:28:38 +01:00
|
|
|
|
|
|
|
import sqlite3
|
2018-05-26 14:43:21 +02:00
|
|
|
from binascii import hexlify
|
2013-02-11 22:28:38 +01:00
|
|
|
from time import strftime, localtime
|
2018-05-26 14:43:21 +02:00
|
|
|
|
2017-01-11 17:26:25 +01:00
|
|
|
import paths
|
2017-02-08 13:41:56 +01:00
|
|
|
import queues
|
2018-05-26 14:43:21 +02:00
|
|
|
|
2013-02-11 22:28:38 +01:00
|
|
|
|
2017-01-11 17:00:00 +01:00
|
|
|
appdata = paths.lookupAppdataFolder()
|
2013-02-11 22:28:38 +01:00
|
|
|
|
2018-05-26 14:43:21 +02:00
|
|
|
conn = sqlite3.connect(appdata + 'messages.dat')
|
2013-02-11 22:28:38 +01:00
|
|
|
conn.text_factory = str
|
|
|
|
cur = conn.cursor()
|
|
|
|
|
2018-05-26 14:43:21 +02:00
|
|
|
|
2013-02-11 22:28:38 +01:00
|
|
|
def readInbox():
|
2018-05-26 14:43:21 +02:00
|
|
|
"""Print each row from inbox table"""
|
2013-02-11 22:28:38 +01:00
|
|
|
print 'Printing everything in inbox table:'
|
|
|
|
item = '''select * from inbox'''
|
|
|
|
parameters = ''
|
|
|
|
cur.execute(item, parameters)
|
|
|
|
output = cur.fetchall()
|
|
|
|
for row in output:
|
|
|
|
print row
|
|
|
|
|
2018-05-26 14:43:21 +02:00
|
|
|
|
2013-02-11 22:28:38 +01:00
|
|
|
def readSent():
|
2018-05-26 14:43:21 +02:00
|
|
|
"""Print each row from sent table"""
|
2013-02-11 22:28:38 +01:00
|
|
|
print 'Printing everything in Sent table:'
|
2013-06-11 20:15:17 +02:00
|
|
|
item = '''select * from sent where folder !='trash' '''
|
2013-02-11 22:28:38 +01:00
|
|
|
parameters = ''
|
|
|
|
cur.execute(item, parameters)
|
|
|
|
output = cur.fetchall()
|
|
|
|
for row in output:
|
2018-05-26 14:43:21 +02:00
|
|
|
(msgid, toaddress, toripe, fromaddress, subject, message, ackdata, lastactiontime,
|
|
|
|
sleeptill, status, retrynumber, folder, encodingtype, ttl) = row # pylint: disable=unused-variable
|
|
|
|
print(hexlify(msgid), toaddress, 'toripe:', hexlify(toripe), 'fromaddress:', fromaddress, 'ENCODING TYPE:',
|
|
|
|
encodingtype, 'SUBJECT:', repr(subject), 'MESSAGE:', repr(message), 'ACKDATA:', hexlify(ackdata),
|
|
|
|
lastactiontime, status, retrynumber, folder)
|
|
|
|
|
2013-02-11 22:28:38 +01:00
|
|
|
|
2013-02-11 23:17:49 +01:00
|
|
|
def readSubscriptions():
|
2018-05-26 14:43:21 +02:00
|
|
|
"""Print each row from subscriptions table"""
|
2013-02-11 23:17:49 +01:00
|
|
|
print 'Printing everything in subscriptions table:'
|
|
|
|
item = '''select * from subscriptions'''
|
|
|
|
parameters = ''
|
|
|
|
cur.execute(item, parameters)
|
|
|
|
output = cur.fetchall()
|
|
|
|
for row in output:
|
|
|
|
print row
|
|
|
|
|
2018-05-26 14:43:21 +02:00
|
|
|
|
2013-02-11 22:28:38 +01:00
|
|
|
def readPubkeys():
|
2018-05-26 14:43:21 +02:00
|
|
|
"""Print each row from pubkeys table"""
|
2013-02-11 22:28:38 +01:00
|
|
|
print 'Printing everything in pubkeys table:'
|
2015-03-09 07:35:32 +01:00
|
|
|
item = '''select address, transmitdata, time, usedpersonally from pubkeys'''
|
2013-02-11 22:28:38 +01:00
|
|
|
parameters = ''
|
|
|
|
cur.execute(item, parameters)
|
|
|
|
output = cur.fetchall()
|
|
|
|
for row in output:
|
2015-03-09 07:35:32 +01:00
|
|
|
address, transmitdata, time, usedpersonally = row
|
2018-05-26 14:43:21 +02:00
|
|
|
print(
|
|
|
|
'Address:', address, '\tTime first broadcast:', unicode(
|
|
|
|
strftime('%a, %d %b %Y %I:%M %p', localtime(time)), 'utf-8'),
|
|
|
|
'\tUsed by me personally:', usedpersonally, '\tFull pubkey message:', hexlify(transmitdata),
|
|
|
|
)
|
|
|
|
|
2013-02-11 22:28:38 +01:00
|
|
|
|
2013-02-18 21:01:47 +01:00
|
|
|
def readInventory():
|
2018-05-26 14:43:21 +02:00
|
|
|
"""Print each row from inventory table"""
|
2013-02-18 21:01:47 +01:00
|
|
|
print 'Printing everything in inventory table:'
|
2014-08-27 09:14:32 +02:00
|
|
|
item = '''select hash, objecttype, streamnumber, payload, expirestime from inventory'''
|
2013-02-18 21:01:47 +01:00
|
|
|
parameters = ''
|
|
|
|
cur.execute(item, parameters)
|
|
|
|
output = cur.fetchall()
|
2013-08-08 23:55:15 +02:00
|
|
|
for row in output:
|
2018-05-26 14:43:21 +02:00
|
|
|
obj_hash, objecttype, streamnumber, payload, expirestime = row
|
|
|
|
print 'Hash:', hexlify(obj_hash), objecttype, streamnumber, '\t', hexlify(payload), '\t', unicode(
|
|
|
|
strftime('%a, %d %b %Y %I:%M %p', localtime(expirestime)), 'utf-8')
|
2013-08-03 00:35:31 +02:00
|
|
|
|
2013-02-18 21:01:47 +01:00
|
|
|
|
2013-02-11 22:28:38 +01:00
|
|
|
def takeInboxMessagesOutOfTrash():
|
2018-05-26 14:43:21 +02:00
|
|
|
"""Update all inbox messages with folder=trash to have folder=inbox"""
|
2013-02-11 22:28:38 +01:00
|
|
|
item = '''update inbox set folder='inbox' where folder='trash' '''
|
|
|
|
parameters = ''
|
|
|
|
cur.execute(item, parameters)
|
2018-05-26 14:43:21 +02:00
|
|
|
_ = cur.fetchall()
|
2013-02-11 22:28:38 +01:00
|
|
|
conn.commit()
|
|
|
|
print 'done'
|
|
|
|
|
2018-05-26 14:43:21 +02:00
|
|
|
|
2013-02-11 22:28:38 +01:00
|
|
|
def takeSentMessagesOutOfTrash():
|
2018-05-26 14:43:21 +02:00
|
|
|
"""Update all sent messages with folder=trash to have folder=sent"""
|
2013-02-11 22:28:38 +01:00
|
|
|
item = '''update sent set folder='sent' where folder='trash' '''
|
|
|
|
parameters = ''
|
|
|
|
cur.execute(item, parameters)
|
2018-05-26 14:43:21 +02:00
|
|
|
_ = cur.fetchall()
|
2013-02-11 22:28:38 +01:00
|
|
|
conn.commit()
|
|
|
|
print 'done'
|
|
|
|
|
2018-05-26 14:43:21 +02:00
|
|
|
|
2013-04-08 23:15:50 +02:00
|
|
|
def markAllInboxMessagesAsUnread():
|
2018-05-26 14:43:21 +02:00
|
|
|
"""Update all messages in inbox to have read=0"""
|
2013-04-08 23:15:50 +02:00
|
|
|
item = '''update inbox set read='0' '''
|
|
|
|
parameters = ''
|
|
|
|
cur.execute(item, parameters)
|
2018-05-26 14:43:21 +02:00
|
|
|
_ = cur.fetchall()
|
2013-04-08 23:15:50 +02:00
|
|
|
conn.commit()
|
2017-02-08 13:41:56 +01:00
|
|
|
queues.UISignalQueue.put(('changedInboxUnread', None))
|
2013-04-08 23:15:50 +02:00
|
|
|
print 'done'
|
|
|
|
|
2018-05-26 14:43:21 +02:00
|
|
|
|
2013-04-22 22:01:41 +02:00
|
|
|
def vacuum():
|
2018-05-26 14:43:21 +02:00
|
|
|
"""Perform a vacuum on the database"""
|
2013-04-22 22:01:41 +02:00
|
|
|
item = '''VACUUM'''
|
|
|
|
parameters = ''
|
|
|
|
cur.execute(item, parameters)
|
2018-05-26 14:43:21 +02:00
|
|
|
_ = cur.fetchall()
|
2013-04-22 22:01:41 +02:00
|
|
|
conn.commit()
|
|
|
|
print 'done'
|
|
|
|
|
2013-02-11 22:28:38 +01:00
|
|
|
|
2018-05-26 14:43:21 +02:00
|
|
|
if __name__ == '__main__':
|
|
|
|
readInbox()
|