2013-02-11 22:28:38 +01:00
#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.
2013-04-12 18:42:20 +02:00
#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).
2013-02-11 22:28:38 +01:00
import sqlite3
from time import strftime , localtime
import sys
2013-08-03 00:35:31 +02:00
import shared
import string
2013-02-11 22:28:38 +01:00
2013-08-03 00:35:31 +02:00
appdata = shared . lookupAppdataFolder ( )
2013-02-11 22:28:38 +01:00
conn = sqlite3 . connect ( appdata + ' messages.dat ' )
conn . text_factory = str
cur = conn . cursor ( )
def readInbox ( ) :
print ' Printing everything in inbox table: '
item = ''' select * from inbox '''
parameters = ' '
cur . execute ( item , parameters )
output = cur . fetchall ( )
for row in output :
print row
def readSent ( ) :
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 :
2015-03-09 07:35:32 +01:00
msgid , toaddress , toripe , fromaddress , subject , message , ackdata , lastactiontime , sleeptill , status , retrynumber , folder , encodingtype , ttl = row
print msgid . encode ( ' hex ' ) , toaddress , ' toripe: ' , toripe . encode ( ' hex ' ) , ' fromaddress: ' , fromaddress , ' ENCODING TYPE: ' , encodingtype , ' SUBJECT: ' , repr ( subject ) , ' MESSAGE: ' , repr ( message ) , ' ACKDATA: ' , ackdata . encode ( ' hex ' ) , lastactiontime , status , retrynumber , folder
2013-02-11 22:28:38 +01:00
2013-02-11 23:17:49 +01:00
def readSubscriptions ( ) :
print ' Printing everything in subscriptions table: '
item = ''' select * from subscriptions '''
parameters = ' '
cur . execute ( item , parameters )
output = cur . fetchall ( )
for row in output :
print row
2013-02-11 22:28:38 +01:00
def readPubkeys ( ) :
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
print ' Address: ' , address , ' \t Time first broadcast: ' , unicode ( strftime ( ' %a , %d % b % Y % I: % M % p ' , localtime ( time ) ) , ' utf-8 ' ) , ' \t Used by me personally: ' , usedpersonally , ' \t Full pubkey message: ' , transmitdata . encode ( ' hex ' )
2013-02-11 22:28:38 +01:00
2013-02-18 21:01:47 +01:00
def readInventory ( ) :
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 :
2014-08-27 09:14:32 +02:00
hash , objecttype , streamnumber , payload , expirestime = row
print ' Hash: ' , hash . encode ( ' hex ' ) , objecttype , streamnumber , ' \t ' , payload . encode ( ' hex ' ) , ' \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 ( ) :
item = ''' update inbox set folder= ' inbox ' where folder= ' trash ' '''
parameters = ' '
cur . execute ( item , parameters )
output = cur . fetchall ( )
conn . commit ( )
print ' done '
def takeSentMessagesOutOfTrash ( ) :
item = ''' update sent set folder= ' sent ' where folder= ' trash ' '''
parameters = ' '
cur . execute ( item , parameters )
output = cur . fetchall ( )
conn . commit ( )
print ' done '
2013-04-08 23:15:50 +02:00
def markAllInboxMessagesAsUnread ( ) :
item = ''' update inbox set read= ' 0 ' '''
parameters = ' '
cur . execute ( item , parameters )
output = cur . fetchall ( )
conn . commit ( )
2013-11-29 02:05:53 +01:00
shared . UISignalQueue . put ( ( ' changedInboxUnread ' , None ) )
2013-04-08 23:15:50 +02:00
print ' done '
2013-04-22 22:01:41 +02:00
def vacuum ( ) :
item = ''' VACUUM '''
parameters = ' '
cur . execute ( item , parameters )
output = cur . fetchall ( )
conn . commit ( )
print ' done '
2013-04-08 23:15:50 +02:00
#takeInboxMessagesOutOfTrash()
2013-02-11 22:28:38 +01:00
#takeSentMessagesOutOfTrash()
2013-04-08 23:15:50 +02:00
#markAllInboxMessagesAsUnread()
2013-08-08 23:55:15 +02:00
readInbox ( )
2013-07-22 07:10:22 +02:00
#readSent()
2013-02-18 21:01:47 +01:00
#readPubkeys()
2013-03-14 16:58:52 +01:00
#readSubscriptions()
2013-08-08 23:55:15 +02:00
#readInventory()
2013-05-28 22:50:09 +02:00
#vacuum() #will defragment and clean empty space from the messages.dat file.
2013-04-26 19:20:30 +02:00
2013-02-11 22:28:38 +01:00