@ -18,11 +18,13 @@ from namecoin import namecoinConnection, ensureNamecoinOptions
from newaddressdialog import *
from newsubscriptiondialog import *
from regenerateaddresses import *
from newchandialog import *
from specialaddressbehavior import *
from settings import *
from about import *
from help import *
from iconglossary import *
from connect import *
import sys
from time import strftime , localtime , gmtime
import time
@ -32,11 +34,14 @@ import pickle
import platform
import debug
from debug import logger
import subprocess
try :
from PyQt4 import QtCore , QtGui
from PyQt4 . QtCore import *
from PyQt4 . QtGui import *
except Exception as err :
print ' PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API. You can download it from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \' PyQt Download \' (without quotes). '
print ' Error message: ' , err
@ -53,7 +58,16 @@ def _translate(context, text):
class MyForm ( QtGui . QMainWindow ) :
# sound type constants
SOUND_NONE = 0
SOUND_KNOWN = 1
SOUND_UNKNOWN = 2
SOUND_CONNECTED = 3
SOUND_DISCONNECTED = 4
SOUND_CONNECTION_GREEN = 5
str_broadcast_subscribers = ' [Broadcast subscribers] '
str_chan = ' [chan] '
def __init__ ( self , parent = None ) :
QtGui . QWidget . __init__ ( self , parent )
@ -106,6 +120,8 @@ class MyForm(QtGui.QMainWindow):
" triggered() " ) , self . click_actionDeleteAllTrashedMessages )
QtCore . QObject . connect ( self . ui . actionRegenerateDeterministicAddresses , QtCore . SIGNAL (
" triggered() " ) , self . click_actionRegenerateDeterministicAddresses )
QtCore . QObject . connect ( self . ui . actionJoinChan , QtCore . SIGNAL (
" triggered() " ) , self . click_actionJoinChan ) # also used for creating chans.
QtCore . QObject . connect ( self . ui . pushButtonNewAddress , QtCore . SIGNAL (
" clicked() " ) , self . click_NewAddressDialog )
QtCore . QObject . connect ( self . ui . comboBoxSendFrom , QtCore . SIGNAL (
@ -296,6 +312,8 @@ class MyForm(QtGui.QMainWindow):
newItem = QtGui . QTableWidgetItem ( addressInKeysFile )
newItem . setFlags (
QtCore . Qt . ItemIsSelectable | QtCore . Qt . ItemIsEnabled )
if shared . safeConfigGetBoolean ( addressInKeysFile , ' chan ' ) :
newItem . setTextColor ( QtGui . QColor ( 216 , 119 , 0 ) ) # orange
if not isEnabled :
newItem . setTextColor ( QtGui . QColor ( 128 , 128 , 128 ) )
if shared . safeConfigGetBoolean ( addressInKeysFile , ' mailinglist ' ) :
@ -410,6 +428,8 @@ class MyForm(QtGui.QMainWindow):
self . rerenderComboBoxSendFrom ( )
# Show or hide the application window after clicking an item within the
# tray icon or, on Windows, the try icon itself.
def appIndicatorShowOrHideWindow ( self ) :
@ -597,6 +617,9 @@ class MyForm(QtGui.QMainWindow):
elif status == ' msgsent ' :
statusText = _translate ( " MainWindow " , " Message sent. Waiting on acknowledgement. Sent at % 1 " ) . arg (
unicode ( strftime ( shared . config . get ( ' bitmessagesettings ' , ' timeformat ' ) , localtime ( lastactiontime ) ) , ' utf-8 ' ) )
elif status == ' msgsentnoackexpected ' :
statusText = _translate ( " MainWindow " , " Message sent. Sent at % 1 " ) . arg (
unicode ( strftime ( shared . config . get ( ' bitmessagesettings ' , ' timeformat ' ) , localtime ( lastactiontime ) ) , ' utf-8 ' ) )
elif status == ' doingmsgpow ' :
statusText = _translate (
" MainWindow " , " Need to do work to send message. Work is queued. " )
@ -712,6 +735,8 @@ class MyForm(QtGui.QMainWindow):
newItem . setData ( Qt . UserRole , str ( toAddress ) )
if shared . safeConfigGetBoolean ( toAddress , ' mailinglist ' ) :
newItem . setTextColor ( QtGui . QColor ( 137 , 04 , 177 ) )
if shared . safeConfigGetBoolean ( str ( toAddress ) , ' chan ' ) :
newItem . setTextColor ( QtGui . QColor ( 216 , 119 , 0 ) ) # orange
self . ui . tableWidgetInbox . setItem ( 0 , 0 , newItem )
if fromLabel == ' ' :
newItem = QtGui . QTableWidgetItem (
@ -957,6 +982,57 @@ class MyForm(QtGui.QMainWindow):
# update the menu entries
self . ubuntuMessagingMenuUnread ( drawAttention )
# play a sound
def playSound ( self , category , label ) :
soundFilename = None
if label is not None :
# does a sound file exist for this particular contact?
if ( os . path . isfile ( shared . appdata + ' sounds/ ' + label + ' .wav ' ) or
os . path . isfile ( shared . appdata + ' sounds/ ' + label + ' .mp3 ' ) ) :
soundFilename = shared . appdata + ' sounds/ ' + label
if soundFilename is None :
if category is self . SOUND_KNOWN :
soundFilename = shared . appdata + ' sounds/known '
elif category is self . SOUND_UNKNOWN :
soundFilename = shared . appdata + ' sounds/unknown '
elif category is self . SOUND_CONNECTED :
soundFilename = shared . appdata + ' sounds/connected '
elif category is self . SOUND_DISCONNECTED :
soundFilename = shared . appdata + ' sounds/disconnected '
elif category is self . SOUND_CONNECTION_GREEN :
soundFilename = shared . appdata + ' sounds/green '
if soundFilename is not None :
# if not wav then try mp3 format
if not os . path . isfile ( soundFilename + ' .wav ' ) :
soundFilename = soundFilename + ' .mp3 '
else :
soundFilename = soundFilename + ' .wav '
if os . path . isfile ( soundFilename ) :
if ' linux ' in sys . platform :
# Note: QSound was a nice idea but it didn't work
if ' .mp3 ' in soundFilename :
try :
subprocess . call ( [ " gst123 " , soundFilename ] ,
stdin = subprocess . PIPE ,
stdout = subprocess . PIPE )
except :
print " WARNING: gst123 must be installed in order to play mp3 sounds "
else :
try :
subprocess . call ( [ " aplay " , soundFilename ] ,
stdin = subprocess . PIPE ,
stdout = subprocess . PIPE )
except :
print " WARNING: aplay must be installed in order to play WAV sounds "
elif sys . platform [ 0 : 3 ] == ' win ' :
# use winsound on Windows
import winsound
winsound . PlaySound ( soundFilename , winsound . SND_FILENAME )
# initialise the message notifier
def notifierInit ( self ) :
global withMessagingMenu
@ -964,8 +1040,11 @@ class MyForm(QtGui.QMainWindow):
Notify . init ( ' pybitmessage ' )
# shows a notification
def notifierShow ( self , title , subtitle ):
def notifierShow ( self , title , subtitle , fromCategory , label ):
global withMessagingMenu
self . playSound ( fromCategory , label ) ;
if withMessagingMenu :
n = Notify . Notification . new (
title , subtitle , ' notification-message-email ' )
@ -1035,6 +1114,68 @@ class MyForm(QtGui.QMainWindow):
) , self . regenerateAddressesDialogInstance . ui . lineEditPassphrase . text ( ) . toUtf8 ( ) , self . regenerateAddressesDialogInstance . ui . checkBoxEighteenByteRipe . isChecked ( ) ) )
self . ui . tabWidget . setCurrentIndex ( 3 )
def click_actionJoinChan ( self ) :
self . newChanDialogInstance = newChanDialog ( self )
if self . newChanDialogInstance . exec_ ( ) :
if self . newChanDialogInstance . ui . radioButtonCreateChan . isChecked ( ) :
if self . newChanDialogInstance . ui . lineEditChanNameCreate . text ( ) == " " :
QMessageBox . about ( self , _translate ( " MainWindow " , " Chan name needed " ) , _translate (
" MainWindow " , " You didn ' t enter a chan name. " ) )
return
shared . apiAddressGeneratorReturnQueue . queue . clear ( )
shared . addressGeneratorQueue . put ( ( ' createChan ' , 3 , 1 , self . str_chan + ' ' + str ( self . newChanDialogInstance . ui . lineEditChanNameCreate . text ( ) . toUtf8 ( ) ) , self . newChanDialogInstance . ui . lineEditChanNameCreate . text ( ) . toUtf8 ( ) ) )
addressGeneratorReturnValue = shared . apiAddressGeneratorReturnQueue . get ( )
print ' addressGeneratorReturnValue ' , addressGeneratorReturnValue
if len ( addressGeneratorReturnValue ) == 0 :
QMessageBox . about ( self , _translate ( " MainWindow " , " Address already present " ) , _translate (
" MainWindow " , " Could not add chan because it appears to already be one of your identities. " ) )
return
createdAddress = addressGeneratorReturnValue [ 0 ]
self . addEntryToAddressBook ( createdAddress , self . str_chan + ' ' + str ( self . newChanDialogInstance . ui . lineEditChanNameCreate . text ( ) . toUtf8 ( ) ) )
QMessageBox . about ( self , _translate ( " MainWindow " , " Success " ) , _translate (
" MainWindow " , " Successfully created chan. To let others join your chan, give them the chan name and this Bitmessage address: % 1. This address also appears in ' Your Identities ' . " ) . arg ( createdAddress ) )
self . ui . tabWidget . setCurrentIndex ( 3 )
elif self . newChanDialogInstance . ui . radioButtonJoinChan . isChecked ( ) :
if self . newChanDialogInstance . ui . lineEditChanNameJoin . text ( ) == " " :
QMessageBox . about ( self , _translate ( " MainWindow " , " Chan name needed " ) , _translate (
" MainWindow " , " You didn ' t enter a chan name. " ) )
return
if decodeAddress ( self . newChanDialogInstance . ui . lineEditChanBitmessageAddress . text ( ) ) [ 0 ] == ' versiontoohigh ' :
QMessageBox . about ( self , _translate ( " MainWindow " , " Address too new " ) , _translate (
" MainWindow " , " Although that Bitmessage address might be valid, its version number is too new for us to handle. Perhaps you need to upgrade Bitmessage. " ) )
return
if decodeAddress ( self . newChanDialogInstance . ui . lineEditChanBitmessageAddress . text ( ) ) [ 0 ] != ' success ' :
QMessageBox . about ( self , _translate ( " MainWindow " , " Address invalid " ) , _translate (
" MainWindow " , " That Bitmessage address is not valid. " ) )
return
shared . apiAddressGeneratorReturnQueue . queue . clear ( )
shared . addressGeneratorQueue . put ( ( ' joinChan ' , addBMIfNotPresent ( self . newChanDialogInstance . ui . lineEditChanBitmessageAddress . text ( ) ) , self . str_chan + ' ' + str ( self . newChanDialogInstance . ui . lineEditChanNameJoin . text ( ) . toUtf8 ( ) ) , self . newChanDialogInstance . ui . lineEditChanNameJoin . text ( ) . toUtf8 ( ) ) )
addressGeneratorReturnValue = shared . apiAddressGeneratorReturnQueue . get ( )
print ' addressGeneratorReturnValue ' , addressGeneratorReturnValue
if addressGeneratorReturnValue == ' chan name does not match address ' :
QMessageBox . about ( self , _translate ( " MainWindow " , " Address does not match chan name " ) , _translate (
" MainWindow " , " Although the Bitmessage address you entered was valid, it doesn \' t match the chan name. " ) )
return
if len ( addressGeneratorReturnValue ) == 0 :
QMessageBox . about ( self , _translate ( " MainWindow " , " Address already present " ) , _translate (
" MainWindow " , " Could not add chan because it appears to already be one of your identities. " ) )
return
createdAddress = addressGeneratorReturnValue [ 0 ]
self . addEntryToAddressBook ( createdAddress , self . str_chan + ' ' + str ( self . newChanDialogInstance . ui . lineEditChanNameJoin . text ( ) ) )
QMessageBox . about ( self , _translate ( " MainWindow " , " Success " ) , _translate (
" MainWindow " , " Successfully joined chan. " ) )
self . ui . tabWidget . setCurrentIndex ( 3 )
def showConnectDialog ( self ) :
self . connectDialogInstance = connectDialog ( self )
if self . connectDialogInstance . exec_ ( ) :
if self . connectDialogInstance . ui . radioButtonConnectNow . isChecked ( ) :
shared . config . remove_option ( ' bitmessagesettings ' , ' dontconnect ' )
with open ( shared . appdata + ' keys.dat ' , ' wb ' ) as configfile :
shared . config . write ( configfile )
else :
self . click_actionSettings ( )
def openKeysFile ( self ) :
if ' linux ' in sys . platform :
subprocess . call ( [ " xdg-open " , shared . appdata + ' keys.dat ' ] )
@ -1138,7 +1279,8 @@ class MyForm(QtGui.QMainWindow):
# if the connection is lost then show a notification
if self . connected :
self . notifierShow ( ' Bitmessage ' , unicode ( _translate (
" MainWindow " , " Connection lost " ) . toUtf8 ( ) , ' utf-8 ' ) )
" MainWindow " , " Connection lost " ) . toUtf8 ( ) , ' utf-8 ' ) ,
self . SOUND_DISCONNECTED , None )
self . connected = False
if self . actionStatus is not None :
@ -1155,7 +1297,8 @@ class MyForm(QtGui.QMainWindow):
# if a new connection has been established then show a notification
if not self . connected :
self . notifierShow ( ' Bitmessage ' , unicode ( _translate (
" MainWindow " , " Connected " ) . toUtf8 ( ) , ' utf-8 ' ) )
" MainWindow " , " Connected " ) . toUtf8 ( ) , ' utf-8 ' ) ,
self . SOUND_CONNECTED , None )
self . connected = True
if self . actionStatus is not None :
@ -1171,7 +1314,8 @@ class MyForm(QtGui.QMainWindow):
shared . statusIconColor = ' green '
if not self . connected :
self . notifierShow ( ' Bitmessage ' , unicode ( _translate (
" MainWindow " , " Connected " ) . toUtf8 ( ) , ' utf-8 ' ) )
" MainWindow " , " Connected " ) . toUtf8 ( ) , ' utf-8 ' ) ,
self . SOUND_CONNECTION_GREEN , None )
self . connected = True
if self . actionStatus is not None :
@ -1278,7 +1422,7 @@ class MyForm(QtGui.QMainWindow):
self . ui . tableWidgetInbox . item ( i , 0 ) . setTextColor ( QtGui . QColor ( 137 , 04 , 177 ) )
else :
self . ui . tableWidgetInbox . item (
i , 0 ) . setTextColor ( Q tGui. QColor ( 0 , 0 , 0 ) )
i , 0 ) . setTextColor ( Q Application. palette ( ) . text ( ) . color ( ) )
def rerenderSentFromLabels ( self ) :
for i in range ( self . ui . tableWidgetSent . rowCount ( ) ) :
@ -1382,12 +1526,11 @@ class MyForm(QtGui.QMainWindow):
toAddress = addBMIfNotPresent ( toAddress )
try :
shared . config . get ( toAddress , ' enabled ' )
# The toAddress is one owned by me. We cannot send
# messages to ourselves without significant changes
# to the codebase.
QMessageBox . about ( self , _translate ( " MainWindow " , " Sending to your address " ) , _translate (
" MainWindow " , " Error: One of the addresses to which you are sending a message, % 1, is yours. Unfortunately the Bitmessage client cannot process its own messages. Please try running a second client on a different computer or within a VM. " ) . arg ( toAddress ) )
continue
# The toAddress is one owned by me.
if not shared . safeConfigGetBoolean ( toAddress , ' chan ' ) :
QMessageBox . about ( self , _translate ( " MainWindow " , " Sending to your address " ) , _translate (
" MainWindow " , " Error: One of the addresses to which you are sending a message, % 1, is yours. Unfortunately the Bitmessage client cannot process its own messages. Please try running a second client on a different computer or within a VM. " ) . arg ( toAddress ) )
continue
except :
pass
if addressVersionNumber > 3 or addressVersionNumber < = 1 :
@ -1531,6 +1674,16 @@ class MyForm(QtGui.QMainWindow):
def redrawLabelFrom ( self , index ) :
self . ui . labelFrom . setText (
self . ui . comboBoxSendFrom . itemData ( index ) . toPyObject ( ) )
self . setBroadcastEnablementDependingOnWhetherThisIsAChanAddress ( self . ui . comboBoxSendFrom . itemData ( index ) . toPyObject ( ) )
def setBroadcastEnablementDependingOnWhetherThisIsAChanAddress ( self , address ) :
# If this is a chan then don't let people broadcast because no one
# should subscribe to chan addresses.
if shared . safeConfigGetBoolean ( str ( address ) , ' chan ' ) :
self . ui . radioButtonSpecific . click ( )
self . ui . radioButtonBroadcast . setEnabled ( False )
else :
self . ui . radioButtonBroadcast . setEnabled ( True )
def rerenderComboBoxSendFrom ( self ) :
self . ui . comboBoxSendFrom . clear ( )
@ -1647,6 +1800,8 @@ class MyForm(QtGui.QMainWindow):
newItem . setData ( Qt . UserRole , str ( toAddress ) )
if shared . safeConfigGetBoolean ( str ( toAddress ) , ' mailinglist ' ) :
newItem . setTextColor ( QtGui . QColor ( 137 , 04 , 177 ) )
if shared . safeConfigGetBoolean ( str ( toAddress ) , ' chan ' ) :
newItem . setTextColor ( QtGui . QColor ( 216 , 119 , 0 ) ) # orange
self . ui . tableWidgetInbox . insertRow ( 0 )
self . ui . tableWidgetInbox . setItem ( 0 , 0 , newItem )
@ -1654,12 +1809,12 @@ class MyForm(QtGui.QMainWindow):
newItem = QtGui . QTableWidgetItem ( unicode ( fromAddress , ' utf-8 ' ) )
newItem . setToolTip ( unicode ( fromAddress , ' utf-8 ' ) )
if shared . config . getboolean ( ' bitmessagesettings ' , ' showtraynotifications ' ) :
self . notifierShow ( unicode ( _translate ( " MainWindow " , ' New Message ' ) . toUtf8 ( ) , ' utf-8 ' ) , unicode ( _translate ( " MainWindow " , ' From ' ) . toUtf8 ( ) , ' utf-8 ' ) + unicode ( fromAddress , ' utf-8 ' ) )
self . notifierShow ( unicode ( _translate ( " MainWindow " , ' New Message ' ) . toUtf8 ( ) , ' utf-8 ' ) , unicode ( _translate ( " MainWindow " , ' From ' ) . toUtf8 ( ) , ' utf-8 ' ) + unicode ( fromAddress , ' utf-8 ' ) , self . SOUND_UNKNOWN , None )
else :
newItem = QtGui . QTableWidgetItem ( unicode ( fromLabel , ' utf-8 ' ) )
newItem . setToolTip ( unicode ( unicode ( fromLabel , ' utf-8 ' ) ) )
if shared . config . getboolean ( ' bitmessagesettings ' , ' showtraynotifications ' ) :
self . notifierShow ( unicode ( _translate ( " MainWindow " , ' New Message ' ) . toUtf8 ( ) , ' utf-8 ' ) , unicode ( _translate ( " MainWindow " , ' From ' ) . toUtf8 ( ) , ' utf-8 ' ) + unicode ( fromLabel , ' utf-8 ' ) )
self . notifierShow ( unicode ( _translate ( " MainWindow " , ' New Message ' ) . toUtf8 ( ) , ' utf-8 ' ) , unicode ( _translate ( " MainWindow " , ' From ' ) . toUtf8 ( ) , ' utf-8 ' ) + unicode ( fromLabel , ' utf-8 ' ) , self . SOUND_KNOWN , unicode ( fromLabel , ' utf-8 ' ) )
newItem . setData ( Qt . UserRole , str ( fromAddress ) )
newItem . setFont ( font )
self . ui . tableWidgetInbox . setItem ( 0 , 1 , newItem )
@ -1686,45 +1841,47 @@ class MyForm(QtGui.QMainWindow):
# First we must check to see if the address is already in the
# address book. The user cannot add it again or else it will
# cause problems when updating and deleting the entry.
shared . sqlLock . acquire ( )
t = ( addBMIfNotPresent ( str (
self . NewSubscriptionDialogInstance . ui . lineEditSubscriptionAddress . text ( ) ) ) , )
shared . sqlSubmitQueue . put (
''' select * from addressbook where address=? ''' )
shared . sqlSubmitQueue . put ( t )
queryreturn = shared . sqlReturnQueue . get ( )
shared . sqlLock . release ( )
if queryreturn == [ ] :
self . ui . tableWidgetAddressBook . setSortingEnabled ( False )
self . ui . tableWidgetAddressBook . insertRow ( 0 )
newItem = QtGui . QTableWidgetItem ( unicode (
self . NewSubscriptionDialogInstance . ui . newsubscriptionlabel . text ( ) . toUtf8 ( ) , ' utf-8 ' ) )
self . ui . tableWidgetAddressBook . setItem ( 0 , 0 , newItem )
newItem = QtGui . QTableWidgetItem ( addBMIfNotPresent (
self . NewSubscriptionDialogInstance . ui . lineEditSubscriptionAddress . text ( ) ) )
newItem . setFlags (
QtCore . Qt . ItemIsSelectable | QtCore . Qt . ItemIsEnabled )
self . ui . tableWidgetAddressBook . setItem ( 0 , 1 , newItem )
self . ui . tableWidgetAddressBook . setSortingEnabled ( True )
t = ( str ( self . NewSubscriptionDialogInstance . ui . newsubscriptionlabel . text ( ) . toUtf8 ( ) ) , addBMIfNotPresent (
str ( self . NewSubscriptionDialogInstance . ui . lineEditSubscriptionAddress . text ( ) ) ) )
shared . sqlLock . acquire ( )
shared . sqlSubmitQueue . put (
''' INSERT INTO addressbook VALUES (?,?) ''' )
shared . sqlSubmitQueue . put ( t )
queryreturn = shared . sqlReturnQueue . get ( )
shared . sqlSubmitQueue . put ( ' commit ' )
shared . sqlLock . release ( )
self . rerenderInboxFromLabels ( )
self . rerenderSentToLabels ( )
else :
self . statusBar ( ) . showMessage ( _translate (
" MainWindow " , " Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want. " ) )
address = addBMIfNotPresent ( str (
self . NewSubscriptionDialogInstance . ui . lineEditSubscriptionAddress . text ( ) ) )
label = self . NewSubscriptionDialogInstance . ui . newsubscriptionlabel . text ( ) . toUtf8 ( )
self . addEntryToAddressBook ( address , label )
else :
self . statusBar ( ) . showMessage ( _translate (
" MainWindow " , " The address you entered was invalid. Ignoring it. " ) )
def addSubscription ( self , label , address ) :
def addEntryToAddressBook ( self , address , label ) :
shared . sqlLock . acquire ( )
t = ( address , )
shared . sqlSubmitQueue . put (
''' select * from addressbook where address=? ''' )
shared . sqlSubmitQueue . put ( t )
queryreturn = shared . sqlReturnQueue . get ( )
shared . sqlLock . release ( )
if queryreturn == [ ] :
self . ui . tableWidgetAddressBook . setSortingEnabled ( False )
self . ui . tableWidgetAddressBook . insertRow ( 0 )
newItem = QtGui . QTableWidgetItem ( unicode ( label , ' utf-8 ' ) )
self . ui . tableWidgetAddressBook . setItem ( 0 , 0 , newItem )
newItem = QtGui . QTableWidgetItem ( address )
newItem . setFlags (
QtCore . Qt . ItemIsSelectable | QtCore . Qt . ItemIsEnabled )
self . ui . tableWidgetAddressBook . setItem ( 0 , 1 , newItem )
self . ui . tableWidgetAddressBook . setSortingEnabled ( True )
t = ( str ( label ) , address )
shared . sqlLock . acquire ( )
shared . sqlSubmitQueue . put (
''' INSERT INTO addressbook VALUES (?,?) ''' )
shared . sqlSubmitQueue . put ( t )
queryreturn = shared . sqlReturnQueue . get ( )
shared . sqlSubmitQueue . put ( ' commit ' )
shared . sqlLock . release ( )
self . rerenderInboxFromLabels ( )
self . rerenderSentToLabels ( )
else :
self . statusBar ( ) . showMessage ( _translate (
" MainWindow " , " Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want. " ) )
def addSubscription ( self , address , label ) :
address = addBMIfNotPresent ( address )
#This should be handled outside of this function, for error displaying and such, but it must also be checked here.
if shared . isAddressInMySubscriptionsList ( address ) :
@ -1761,7 +1918,7 @@ class MyForm(QtGui.QMainWindow):
self . statusBar ( ) . showMessage ( _translate ( " MainWindow " , " Error: You cannot add the same address to your subsciptions twice. Perhaps rename the existing one if you want. " ) )
return
label = self . NewSubscriptionDialogInstance . ui . newsubscriptionlabel . text ( ) . toUtf8 ( )
self . addSubscription ( label, address )
self . addSubscription ( address, label )
def loadBlackWhiteList ( self ) :
# Initialize the Blacklist or Whitelist table
@ -1816,14 +1973,15 @@ class MyForm(QtGui.QMainWindow):
shared . config . set ( ' bitmessagesettings ' , ' startintray ' , str (
self . settingsDialogInstance . ui . checkBoxStartInTray . isChecked ( ) ) )
if int ( shared . config . get ( ' bitmessagesettings ' , ' port ' ) ) != int ( self . settingsDialogInstance . ui . lineEditTCPPort . text ( ) ) :
QMessageBox . about ( self , _translate ( " MainWindow " , " Restart " ) , _translate (
" MainWindow " , " You must restart Bitmessage for the port number change to take effect. " ) )
if not shared . safeConfigGetBoolean ( ' bitmessagesettings ' , ' dontconnect ' ) :
QMessageBox . about ( self , _translate ( " MainWindow " , " Restart " ) , _translate (
" MainWindow " , " You must restart Bitmessage for the port number change to take effect. " ) )
shared . config . set ( ' bitmessagesettings ' , ' port ' , str (
self . settingsDialogInstance . ui . lineEditTCPPort . text ( ) ) )
if shared . config . get ( ' bitmessagesettings ' , ' socksproxytype ' ) == ' none ' and str ( self . settingsDialogInstance . ui . comboBoxProxyType . currentText ( ) ) [ 0 : 5 ] == ' SOCKS ' :
if shared . statusIconColor != ' red ' :
QMessageBox . about ( self , _translate ( " MainWindow " , " Restart " ) , _translate (
" MainWindow " , " Bitmessage will use your proxy from now on but you may want to manually restart Bitmessage now to close existing connections ." ) )
" MainWindow " , " Bitmessage will use your proxy from now on but you may want to manually restart Bitmessage now to close existing connections (if any) ." ) )
if shared . config . get ( ' bitmessagesettings ' , ' socksproxytype ' ) [ 0 : 5 ] == ' SOCKS ' and str ( self . settingsDialogInstance . ui . comboBoxProxyType . currentText ( ) ) == ' none ' :
self . statusBar ( ) . showMessage ( ' ' )
shared . config . set ( ' bitmessagesettings ' , ' socksproxytype ' , str (
@ -2016,13 +2174,16 @@ class MyForm(QtGui.QMainWindow):
currentRow = self . ui . tableWidgetYourIdentities . currentRow ( )
addressAtCurrentRow = str (
self . ui . tableWidgetYourIdentities . item ( currentRow , 1 ) . text ( ) )
if shared . safeConfigGetBoolean ( addressAtCurrentRow , ' chan ' ) :
return
if self . dialog . ui . radioButtonBehaveNormalAddress . isChecked ( ) :
shared . config . set ( str (
addressAtCurrentRow ) , ' mailinglist ' , ' false ' )
# Set the color to either black or grey
if shared . config . getboolean ( addressAtCurrentRow , ' enabled ' ) :
self . ui . tableWidgetYourIdentities . item (
currentRow , 1 ) . setTextColor ( QtGui . QColor ( 0 , 0 , 0 ) )
currentRow , 1 ) . setTextColor ( QApplication . palette ( )
. text ( ) . color ( ) )
else :
self . ui . tableWidgetYourIdentities . item (
currentRow , 1 ) . setTextColor ( QtGui . QColor ( 128 , 128 , 128 ) )
@ -2049,12 +2210,6 @@ class MyForm(QtGui.QMainWindow):
# address.'
streamNumberForAddress = addressStream (
self . dialog . ui . comboBoxExisting . currentText ( ) )
# self.addressGenerator = addressGenerator()
# self.addressGenerator.setup(3,streamNumberForAddress,str(self.dialog.ui.newaddresslabel.text().toUtf8()),1,"",self.dialog.ui.checkBoxEighteenByteRipe.isChecked())
# QtCore.QObject.connect(self.addressGenerator, SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.writeNewAddressToTable)
# QtCore.QObject.connect(self.addressGenerator, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar)
# self.addressGenerator.start()
shared . addressGeneratorQueue . put ( ( ' createRandomAddress ' , 3 , streamNumberForAddress , str (
self . dialog . ui . newaddresslabel . text ( ) . toUtf8 ( ) ) , 1 , " " , self . dialog . ui . checkBoxEighteenByteRipe . isChecked ( ) ) )
else :
@ -2066,11 +2221,6 @@ class MyForm(QtGui.QMainWindow):
" MainWindow " , " Choose a passphrase " ) , _translate ( " MainWindow " , " You really do need a passphrase. " ) )
else :
streamNumberForAddress = 1 # this will eventually have to be replaced by logic to determine the most available stream number.
# self.addressGenerator = addressGenerator()
# self.addressGenerator.setup(3,streamNumberForAddress,"unused address",self.dialog.ui.spinBoxNumberOfAddressesToMake.value(),self.dialog.ui.lineEditPassphrase.text().toUtf8(),self.dialog.ui.checkBoxEighteenByteRipe.isChecked())
# QtCore.QObject.connect(self.addressGenerator, SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.writeNewAddressToTable)
# QtCore.QObject.connect(self.addressGenerator, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar)
# self.addressGenerator.start()
shared . addressGeneratorQueue . put ( ( ' createDeterministicAddresses ' , 3 , streamNumberForAddress , " unused deterministic address " , self . dialog . ui . spinBoxNumberOfAddressesToMake . value (
) , self . dialog . ui . lineEditPassphrase . text ( ) . toUtf8 ( ) , self . dialog . ui . checkBoxEighteenByteRipe . isChecked ( ) ) )
else :
@ -2147,6 +2297,7 @@ class MyForm(QtGui.QMainWindow):
self . ui . labelFrom . setText ( ' ' )
else :
self . ui . labelFrom . setText ( toAddressAtCurrentInboxRow )
self . setBroadcastEnablementDependingOnWhetherThisIsAChanAddress ( toAddressAtCurrentInboxRow )
self . ui . lineEditTo . setText ( str ( fromAddressAtCurrentInboxRow ) )
self . ui . comboBoxSendFrom . setCurrentIndex ( 0 )
# self.ui.comboBoxSendFrom.setEditText(str(self.ui.tableWidgetInbox.item(currentInboxRow,0).text))
@ -2370,7 +2521,7 @@ class MyForm(QtGui.QMainWindow):
self . statusBar ( ) . showMessage ( QtGui . QApplication . translate ( " MainWindow " , " Error: You cannot add the same address to your subsciptions twice. Perhaps rename the existing one if you want. " ) )
continue
labelAtCurrentRow = self . ui . tableWidgetAddressBook . item ( currentRow , 0 ) . text ( ) . toUtf8 ( )
self . addSubscription ( labelAtCurrentRow, address AtCurrentRow)
self . addSubscription ( addressAtCurrentRow, label AtCurrentRow)
self . ui . tabWidget . setCurrentIndex ( 4 )
def on_context_menuAddressBook ( self , point ) :
@ -2422,9 +2573,9 @@ class MyForm(QtGui.QMainWindow):
shared . sqlSubmitQueue . put ( ' commit ' )
shared . sqlLock . release ( )
self . ui . tableWidgetSubscriptions . item (
currentRow , 0 ) . setTextColor ( Q tGui. QColor ( 0 , 0 , 0 ) )
currentRow , 0 ) . setTextColor ( Q Application. palette ( ) . text ( ) . color ( ) )
self . ui . tableWidgetSubscriptions . item (
currentRow , 1 ) . setTextColor ( Q tGui. QColor ( 0 , 0 , 0 ) )
currentRow , 1 ) . setTextColor ( Q Application. palette ( ) . text ( ) . color ( ) )
shared . reloadBroadcastSendersForWhichImWatching ( )
def on_action_SubscriptionsDisable ( self ) :
@ -2493,9 +2644,9 @@ class MyForm(QtGui.QMainWindow):
addressAtCurrentRow = self . ui . tableWidgetBlacklist . item (
currentRow , 1 ) . text ( )
self . ui . tableWidgetBlacklist . item (
currentRow , 0 ) . setTextColor ( Q tGui. QColor ( 0 , 0 , 0 ) )
currentRow , 0 ) . setTextColor ( Q Application. palette ( ) . text ( ) . color ( ) )
self . ui . tableWidgetBlacklist . item (
currentRow , 1 ) . setTextColor ( Q tGui. QColor ( 0 , 0 , 0 ) )
currentRow , 1 ) . setTextColor ( Q Application. palette ( ) . text ( ) . color ( ) )
t = ( str ( addressAtCurrentRow ) , )
shared . sqlLock . acquire ( )
if shared . config . get ( ' bitmessagesettings ' , ' blackwhitelist ' ) == ' black ' :
@ -2546,13 +2697,15 @@ class MyForm(QtGui.QMainWindow):
with open ( shared . appdata + ' keys.dat ' , ' wb ' ) as configfile :
shared . config . write ( configfile )
self . ui . tableWidgetYourIdentities . item (
currentRow , 0 ) . setTextColor ( Q tGui. QColor ( 0 , 0 , 0 ) )
currentRow , 0 ) . setTextColor ( Q Application. palette ( ) . text ( ) . color ( ) )
self . ui . tableWidgetYourIdentities . item (
currentRow , 1 ) . setTextColor ( Q tGui. QColor ( 0 , 0 , 0 ) )
currentRow , 1 ) . setTextColor ( Q Application. palette ( ) . text ( ) . color ( ) )
self . ui . tableWidgetYourIdentities . item (
currentRow , 2 ) . setTextColor ( Q tGui. QColor ( 0 , 0 , 0 ) )
currentRow , 2 ) . setTextColor ( Q Application. palette ( ) . text ( ) . color ( ) )
if shared . safeConfigGetBoolean ( addressAtCurrentRow , ' mailinglist ' ) :
self . ui . tableWidgetYourIdentities . item ( currentRow , 1 ) . setTextColor ( QtGui . QColor ( 137 , 04 , 177 ) )
if shared . safeConfigGetBoolean ( addressAtCurrentRow , ' chan ' ) :
self . ui . tableWidgetYourIdentities . item ( currentRow , 1 ) . setTextColor ( QtGui . QColor ( 216 , 119 , 0 ) ) # orange
shared . reloadMyAddressHashes ( )
def on_action_YourIdentitiesDisable ( self ) :
@ -2721,11 +2874,14 @@ class MyForm(QtGui.QMainWindow):
def writeNewAddressToTable ( self , label , address , streamNumber ) :
self . ui . tableWidgetYourIdentities . setSortingEnabled ( False )
self . ui . tableWidgetYourIdentities . insertRow ( 0 )
newItem = QtGui . QTableWidgetItem ( unicode ( label , ' utf-8 ' ) )
self . ui . tableWidgetYourIdentities . setItem (
0 , 0 , QtGui. QTableWidgetItem ( unicode ( label , ' utf-8 ' ) ) )
0 , 0 , newItem )
newItem = QtGui . QTableWidgetItem ( address )
newItem . setFlags (
QtCore . Qt . ItemIsSelectable | QtCore . Qt . ItemIsEnabled )
if shared . safeConfigGetBoolean ( address , ' chan ' ) :
newItem . setTextColor ( QtGui . QColor ( 216 , 119 , 0 ) ) # orange
self . ui . tableWidgetYourIdentities . setItem ( 0 , 1 , newItem )
newItem = QtGui . QTableWidgetItem ( streamNumber )
newItem . setFlags (
@ -2751,7 +2907,15 @@ class helpDialog(QtGui.QDialog):
self . parent = parent
self . ui . labelHelpURI . setOpenExternalLinks ( True )
QtGui . QWidget . resize ( self , QtGui . QWidget . sizeHint ( self ) )
class connectDialog ( QtGui . QDialog ) :
def __init__ ( self , parent ) :
QtGui . QWidget . __init__ ( self , parent )
self . ui = Ui_connectDialog ( )
self . ui . setupUi ( self )
self . parent = parent
QtGui . QWidget . resize ( self , QtGui . QWidget . sizeHint ( self ) )
class aboutDialog ( QtGui . QDialog ) :
@ -2772,7 +2936,6 @@ class regenerateAddressesDialog(QtGui.QDialog):
self . parent = parent
QtGui . QWidget . resize ( self , QtGui . QWidget . sizeHint ( self ) )
class settingsDialog ( QtGui . QDialog ) :
def __init__ ( self , parent ) :
@ -2963,17 +3126,23 @@ class SpecialAddressBehaviorDialog(QtGui.QDialog):
currentRow = parent . ui . tableWidgetYourIdentities . currentRow ( )
addressAtCurrentRow = str (
parent . ui . tableWidgetYourIdentities . item ( currentRow , 1 ) . text ( ) )
if shared . safeConfigGetBoolean ( addressAtCurrentRow , ' mailinglist ' ) :
self . ui . radioButtonBehaviorMailingList . click ( )
else :
self . ui . radioButtonBehaveNormalAddress . click ( )
try :
mailingListName = shared . config . get (
addressAtCurrentRow , ' mailinglistname ' )
except :
mailingListName = ' '
self . ui . lineEditMailingListName . setText (
unicode ( mailingListName , ' utf-8 ' ) )
if not shared . safeConfigGetBoolean ( addressAtCurrentRow , ' chan ' ) :
if shared . safeConfigGetBoolean ( addressAtCurrentRow , ' mailinglist ' ) :
self . ui . radioButtonBehaviorMailingList . click ( )
else :
self . ui . radioButtonBehaveNormalAddress . click ( )
try :
mailingListName = shared . config . get (
addressAtCurrentRow , ' mailinglistname ' )
except :
mailingListName = ' '
self . ui . lineEditMailingListName . setText (
unicode ( mailingListName , ' utf-8 ' ) )
else : # if addressAtCurrentRow is a chan address
self . ui . radioButtonBehaviorMailingList . setDisabled ( True )
self . ui . lineEditMailingListName . setText ( _translate (
" MainWindow " , " This is a chan address. You cannot use it as a pseudo-mailing list. " ) )
QtGui . QWidget . resize ( self , QtGui . QWidget . sizeHint ( self ) )
@ -3032,11 +3201,11 @@ class NewAddressDialog(QtGui.QDialog):
self . ui . groupBoxDeterministic . setHidden ( True )
QtGui . QWidget . resize ( self , QtGui . QWidget . sizeHint ( self ) )
class N ewChanDialog( QtGui . QDialog ) :
class n ewChanDialog( QtGui . QDialog ) :
def __init__ ( self , parent ) :
QtGui . QWidget . __init__ ( self , parent )
self . ui = Ui_ N ewChanDialog( )
self . ui = Ui_ n ewChanDialog( )
self . ui . setupUi ( self )
self . parent = parent
self . ui . groupBoxCreateChan . setHidden ( True )
@ -3158,6 +3327,8 @@ def run():
myapp . appIndicatorInit ( app )
myapp . ubuntuMessagingMenuInit ( )
myapp . notifierInit ( )
if shared . safeConfigGetBoolean ( ' bitmessagesettings ' , ' dontconnect ' ) :
myapp . showConnectDialog ( ) # ask the user if we may connect
if gevent is None :
sys . exit ( app . exec_ ( ) )
else :