2015-12-16 00:58:52 +01:00
import ctypes
from PyQt4 import QtCore , QtGui
2016-01-21 17:57:00 +01:00
import ssl
2015-12-16 00:58:52 +01:00
import sys
2015-12-21 15:38:45 +01:00
import time
2015-12-16 00:58:52 +01:00
import account
2017-01-11 14:27:19 +01:00
from configparser import BMConfigParser
2015-12-16 00:58:52 +01:00
from debug import logger
from foldertree import AccountMixin
from helper_sql import *
from l10n import getTranslationLanguage
2016-11-10 21:43:10 +01:00
from openclpow import openclAvailable , openclEnabled
2017-01-11 17:00:00 +01:00
import paths
2015-12-16 00:58:52 +01:00
from proofofwork import bmpow
2017-01-11 17:26:25 +01:00
import protocol
2016-01-21 17:57:00 +01:00
from pyelliptic . openssl import OpenSSL
2015-12-16 00:58:52 +01:00
import shared
2017-01-11 17:00:00 +01:00
import state
2017-01-11 14:27:19 +01:00
from version import softwareVersion
2015-12-16 00:58:52 +01:00
# this is BM support address going to Peter Surda
SUPPORT_ADDRESS = ' BM-2cTkCtMYkrSPwFTpgcBrMrf5d8oZwvMZWK '
SUPPORT_LABEL = ' PyBitmessage support '
SUPPORT_MY_LABEL = ' My new address '
SUPPORT_SUBJECT = ' Support request '
2015-12-16 14:19:19 +01:00
SUPPORT_MESSAGE = ''' You can use this message to send a report to one of the PyBitmessage core developers regarding PyBitmessage or the mailchuck.com email service. If you are using PyBitmessage involuntarily, for example because your computer was infected with ransomware, this is not an appropriate venue for resolving such issues.
2015-12-16 00:58:52 +01:00
2016-03-18 18:59:20 +01:00
Please describe what you are trying to do :
2015-12-16 00:58:52 +01:00
Please describe what you expect to happen :
2015-12-16 14:19:19 +01:00
Please describe what happens instead :
2015-12-16 00:58:52 +01:00
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
Please write above this line and if possible , keep the information about your environment below intact .
2016-11-05 00:46:07 +01:00
PyBitmessage version : { }
2015-12-16 00:58:52 +01:00
Operating system : { }
Architecture : { } bit
2016-01-21 17:57:00 +01:00
Python Version : { }
OpenSSL Version : { }
2015-12-16 00:58:52 +01:00
Frozen : { }
2015-12-16 01:15:19 +01:00
Portable mode : { }
2015-12-16 00:58:52 +01:00
C PoW : { }
OpenCL PoW : { }
Locale : { }
SOCKS : { }
UPnP : { }
Connected hosts : { }
'''
def checkAddressBook ( myapp ) :
queryreturn = sqlQuery ( ''' SELECT * FROM addressbook WHERE address=? ''' , SUPPORT_ADDRESS )
if queryreturn == [ ] :
sqlExecute ( ''' INSERT INTO addressbook VALUES (?,?) ''' , str ( QtGui . QApplication . translate ( " Support " , SUPPORT_LABEL ) ) , SUPPORT_ADDRESS )
myapp . rerenderAddressBook ( )
def checkHasNormalAddress ( ) :
for address in account . getSortedAccounts ( ) :
acct = account . accountClass ( address )
2017-01-11 14:27:19 +01:00
if acct . type == AccountMixin . NORMAL and BMConfigParser ( ) . safeGetBoolean ( address , ' enabled ' ) :
2015-12-16 00:58:52 +01:00
return address
return False
def createAddressIfNeeded ( myapp ) :
if not checkHasNormalAddress ( ) :
2017-01-11 17:00:00 +01:00
shared . addressGeneratorQueue . put ( ( ' createRandomAddress ' , 4 , 1 , str ( QtGui . QApplication . translate ( " Support " , SUPPORT_MY_LABEL ) ) , 1 , " " , False , protocol . networkDefaultProofOfWorkNonceTrialsPerByte , protocol . networkDefaultPayloadLengthExtraBytes ) )
2015-12-16 00:58:52 +01:00
while shared . shutdown == 0 and not checkHasNormalAddress ( ) :
time . sleep ( .2 )
myapp . rerenderComboBoxSendFrom ( )
return checkHasNormalAddress ( )
def createSupportMessage ( myapp ) :
checkAddressBook ( myapp )
address = createAddressIfNeeded ( myapp )
if shared . shutdown :
return
myapp . ui . lineEditSubject . setText ( str ( QtGui . QApplication . translate ( " Support " , SUPPORT_SUBJECT ) ) )
addrIndex = myapp . ui . comboBoxSendFrom . findData ( address , QtCore . Qt . UserRole , QtCore . Qt . MatchFixedString | QtCore . Qt . MatchCaseSensitive )
if addrIndex == - 1 : # something is very wrong
return
myapp . ui . comboBoxSendFrom . setCurrentIndex ( addrIndex )
myapp . ui . lineEditTo . setText ( SUPPORT_ADDRESS )
2017-01-11 14:27:19 +01:00
version = softwareVersion
2015-12-16 00:58:52 +01:00
os = sys . platform
if os == " win32 " :
windowsversion = sys . getwindowsversion ( )
os = " Windows " + str ( windowsversion [ 0 ] ) + " . " + str ( windowsversion [ 1 ] )
else :
2015-12-16 14:19:19 +01:00
try :
from os import uname
unixversion = uname ( )
os = unixversion [ 0 ] + " " + unixversion [ 2 ]
except :
pass
2015-12-16 00:58:52 +01:00
architecture = " 32 " if ctypes . sizeof ( ctypes . c_voidp ) == 4 else " 64 "
2016-01-21 17:57:00 +01:00
pythonversion = sys . version
2017-01-13 12:02:34 +01:00
opensslversion = " %s (Python internal), %s (external for PyElliptic) " % ( ssl . OPENSSL_VERSION , OpenSSL ( ) . _version )
2016-01-21 17:57:00 +01:00
2015-12-16 00:58:52 +01:00
frozen = " N/A "
2017-01-11 17:00:00 +01:00
if paths . frozen :
frozen = paths . frozen
portablemode = " True " if state . appdata == paths . lookupExeFolder ( ) else " False "
2015-12-16 01:15:19 +01:00
cpow = " True " if bmpow else " False "
2015-12-16 00:58:52 +01:00
#cpow = QtGui.QApplication.translate("Support", cpow)
2017-01-11 14:27:19 +01:00
openclpow = str ( BMConfigParser ( ) . safeGet ( ' bitmessagesettings ' , ' opencl ' ) ) if openclEnabled ( ) else " None "
2015-12-16 00:58:52 +01:00
#openclpow = QtGui.QApplication.translate("Support", openclpow)
locale = getTranslationLanguage ( )
try :
2017-01-11 14:27:19 +01:00
socks = BMConfigParser ( ) . get ( ' bitmessagesettings ' , ' socksproxytype ' )
2015-12-16 00:58:52 +01:00
except :
socks = " N/A "
try :
2017-01-11 14:27:19 +01:00
upnp = BMConfigParser ( ) . get ( ' bitmessagesettings ' , ' upnp ' )
2015-12-16 00:58:52 +01:00
except :
upnp = " N/A "
connectedhosts = len ( shared . connectedHostsList )
2016-01-21 17:57:00 +01:00
myapp . ui . textEditMessage . setText ( str ( QtGui . QApplication . translate ( " Support " , SUPPORT_MESSAGE ) ) . format ( version , os , architecture , pythonversion , opensslversion , frozen , portablemode , cpow , openclpow , locale , socks , upnp , connectedhosts ) )
2015-12-16 00:58:52 +01:00
# single msg tab
myapp . ui . tabWidgetSend . setCurrentIndex ( 0 )
# send tab
myapp . ui . tabWidget . setCurrentIndex ( 1 )