2019-12-07 11:10:31 +01:00
|
|
|
"""Composing support request message functions."""
|
|
|
|
|
2015-12-16 00:58:52 +01:00
|
|
|
import ctypes
|
2018-02-21 18:10:32 +01:00
|
|
|
import os
|
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
|
|
|
|
2024-05-26 03:18:08 +02:00
|
|
|
from unqstr import ustr, unic
|
2024-05-27 15:43:01 +02:00
|
|
|
from dbcompat import dbstr
|
2019-12-07 11:10:31 +01:00
|
|
|
|
2024-05-24 05:42:29 +02:00
|
|
|
from bitmessageqt import account
|
2017-02-08 20:37:42 +01:00
|
|
|
import defaults
|
2019-12-07 11:10:31 +01:00
|
|
|
import network.stats
|
2017-01-11 17:00:00 +01:00
|
|
|
import paths
|
2017-08-15 18:14:36 +02:00
|
|
|
import proofofwork
|
2017-02-08 13:41:56 +01:00
|
|
|
import queues
|
2017-01-11 17:00:00 +01:00
|
|
|
import state
|
2022-01-28 13:55:23 +01:00
|
|
|
from bmconfigparser import config
|
2024-05-24 05:42:29 +02:00
|
|
|
from .foldertree import AccountMixin
|
2019-12-07 11:10:31 +01:00
|
|
|
from helper_sql import sqlExecute, sqlQuery
|
|
|
|
from l10n import getTranslationLanguage
|
|
|
|
from openclpow import openclEnabled
|
|
|
|
from pyelliptic.openssl import OpenSSL
|
2024-05-24 05:42:29 +02:00
|
|
|
from .settings import getSOCKSProxyType
|
2017-01-11 14:27:19 +01:00
|
|
|
from version import softwareVersion
|
2019-12-07 11:10:31 +01:00
|
|
|
from tr import _translate
|
|
|
|
|
2015-12-16 00:58:52 +01:00
|
|
|
|
|
|
|
# this is BM support address going to Peter Surda
|
2018-02-13 23:33:12 +01:00
|
|
|
OLD_SUPPORT_ADDRESS = 'BM-2cTkCtMYkrSPwFTpgcBrMrf5d8oZwvMZWK'
|
|
|
|
SUPPORT_ADDRESS = 'BM-2cUdgkDDAahwPAU6oD2A7DnjqZz3hgY832'
|
2019-12-07 11:10:31 +01:00
|
|
|
SUPPORT_LABEL = _translate("Support", "PyBitmessage support")
|
|
|
|
SUPPORT_MY_LABEL = _translate("Support", "My new address")
|
2018-02-21 18:10:32 +01:00
|
|
|
SUPPORT_SUBJECT = _translate("Support", "Support request")
|
2019-12-07 11:10:31 +01:00
|
|
|
SUPPORT_MESSAGE = _translate("Support", '''
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2019-12-07 11:10:31 +01:00
|
|
|
Please write above this line and if possible, keep the information about your \
|
|
|
|
environment below intact.
|
2015-12-16 00:58:52 +01:00
|
|
|
|
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: {}
|
2018-02-21 18:10:32 +01:00
|
|
|
Qt API: {}
|
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: {}
|
2019-12-07 11:10:31 +01:00
|
|
|
''')
|
|
|
|
|
2015-12-16 00:58:52 +01:00
|
|
|
|
|
|
|
def checkAddressBook(myapp):
|
2018-02-21 18:10:32 +01:00
|
|
|
"""
|
|
|
|
Add "PyBitmessage support" address to address book, remove old one if found.
|
|
|
|
"""
|
2024-05-27 15:43:01 +02:00
|
|
|
sqlExecute('DELETE from addressbook WHERE address=?', dbstr(OLD_SUPPORT_ADDRESS))
|
2018-02-21 18:10:32 +01:00
|
|
|
queryreturn = sqlQuery(
|
2024-05-29 14:39:16 +02:00
|
|
|
'SELECT * FROM addressbook WHERE address=?', dbstr(SUPPORT_ADDRESS))
|
2015-12-16 00:58:52 +01:00
|
|
|
if queryreturn == []:
|
2019-12-07 11:10:31 +01:00
|
|
|
sqlExecute(
|
2020-05-30 13:18:49 +02:00
|
|
|
'INSERT INTO addressbook VALUES (?,?)',
|
2024-05-28 01:40:40 +02:00
|
|
|
dbstr(SUPPORT_LABEL), dbstr(SUPPORT_ADDRESS))
|
2015-12-16 00:58:52 +01:00
|
|
|
myapp.rerenderAddressBook()
|
|
|
|
|
2019-12-07 11:10:31 +01:00
|
|
|
|
2015-12-16 00:58:52 +01:00
|
|
|
def checkHasNormalAddress():
|
2018-02-21 18:10:32 +01:00
|
|
|
"""Returns first enabled normal address or False if not found."""
|
2024-05-21 16:49:12 +02:00
|
|
|
for address in config.addresses(True):
|
2015-12-16 00:58:52 +01:00
|
|
|
acct = account.accountClass(address)
|
2024-05-21 16:49:12 +02:00
|
|
|
if acct.type == AccountMixin.NORMAL and config.safeGetBoolean(
|
2018-02-21 18:10:32 +01:00
|
|
|
address, 'enabled'):
|
2015-12-16 00:58:52 +01:00
|
|
|
return address
|
|
|
|
return False
|
|
|
|
|
2019-12-07 11:10:31 +01:00
|
|
|
|
2015-12-16 00:58:52 +01:00
|
|
|
def createAddressIfNeeded(myapp):
|
2018-02-21 18:10:32 +01:00
|
|
|
"""Checks if user has any anabled normal address, creates new one if no."""
|
2015-12-16 00:58:52 +01:00
|
|
|
if not checkHasNormalAddress():
|
2019-12-07 11:10:31 +01:00
|
|
|
queues.addressGeneratorQueue.put((
|
2020-05-30 13:18:49 +02:00
|
|
|
'createRandomAddress', 4, 1,
|
2024-05-23 06:28:40 +02:00
|
|
|
ustr(SUPPORT_MY_LABEL),
|
2020-05-30 13:18:49 +02:00
|
|
|
1, "", False,
|
2019-12-07 11:10:31 +01:00
|
|
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte,
|
|
|
|
defaults.networkDefaultPayloadLengthExtraBytes
|
|
|
|
))
|
2017-01-14 23:20:15 +01:00
|
|
|
while state.shutdown == 0 and not checkHasNormalAddress():
|
2015-12-16 00:58:52 +01:00
|
|
|
time.sleep(.2)
|
|
|
|
myapp.rerenderComboBoxSendFrom()
|
|
|
|
return checkHasNormalAddress()
|
|
|
|
|
2019-12-07 11:10:31 +01:00
|
|
|
|
2015-12-16 00:58:52 +01:00
|
|
|
def createSupportMessage(myapp):
|
2018-02-21 18:10:32 +01:00
|
|
|
"""
|
|
|
|
Prepare the support request message and switch to tab "Send"
|
|
|
|
"""
|
2015-12-16 00:58:52 +01:00
|
|
|
checkAddressBook(myapp)
|
|
|
|
address = createAddressIfNeeded(myapp)
|
2017-01-14 23:20:15 +01:00
|
|
|
if state.shutdown:
|
2015-12-16 00:58:52 +01:00
|
|
|
return
|
|
|
|
|
2019-12-07 11:10:31 +01:00
|
|
|
myapp.ui.lineEditSubject.setText(SUPPORT_SUBJECT)
|
2018-02-23 14:42:50 +01:00
|
|
|
# addrIndex = myapp.ui.comboBoxSendFrom.findData(
|
|
|
|
# address, QtCore.Qt.UserRole,
|
|
|
|
# QtCore.Qt.MatchFixedString | QtCore.Qt.MatchCaseSensitive
|
|
|
|
# )
|
|
|
|
addrIndex = myapp.ui.comboBoxSendFrom.findData(address)
|
2019-12-07 11:10:31 +01:00
|
|
|
if addrIndex == -1: # something is very wrong
|
2015-12-16 00:58:52 +01:00
|
|
|
return
|
|
|
|
myapp.ui.comboBoxSendFrom.setCurrentIndex(addrIndex)
|
|
|
|
myapp.ui.lineEditTo.setText(SUPPORT_ADDRESS)
|
2017-11-07 12:46:23 +01:00
|
|
|
|
2017-01-11 14:27:19 +01:00
|
|
|
version = softwareVersion
|
2017-11-07 12:46:23 +01:00
|
|
|
commit = paths.lastCommit().get('commit')
|
2017-02-07 20:46:30 +01:00
|
|
|
if commit:
|
|
|
|
version += " GIT " + commit
|
2017-01-13 12:29:14 +01:00
|
|
|
|
2018-02-21 18:10:32 +01:00
|
|
|
if sys.platform.startswith("win"):
|
|
|
|
# pylint: disable=no-member
|
|
|
|
osname = "Windows %s.%s" % sys.getwindowsversion()[:2]
|
2015-12-16 00:58:52 +01:00
|
|
|
else:
|
2015-12-16 14:19:19 +01:00
|
|
|
try:
|
2018-02-21 18:10:32 +01:00
|
|
|
unixversion = os.uname()
|
|
|
|
osname = unixversion[0] + " " + unixversion[2]
|
2015-12-16 14:19:19 +01:00
|
|
|
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
|
2019-12-07 11:10:31 +01:00
|
|
|
|
|
|
|
opensslversion = "%s (Python internal), %s (external for PyElliptic)" % (
|
|
|
|
ssl.OPENSSL_VERSION, OpenSSL._version)
|
2016-01-21 17:57:00 +01:00
|
|
|
|
2019-02-11 17:48:57 +01:00
|
|
|
qtapi = os.environ.get('QT_API', 'fallback')
|
2018-02-21 18:10:32 +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
|
2018-02-21 18:10:32 +01:00
|
|
|
portablemode = str(state.appdata == paths.lookupExeFolder())
|
2017-08-15 18:14:36 +02:00
|
|
|
cpow = "True" if proofofwork.bmpow else "False"
|
2024-05-23 06:28:40 +02:00
|
|
|
openclpow = ustr(
|
2022-01-28 13:55:23 +01:00
|
|
|
config.safeGet('bitmessagesettings', 'opencl')
|
2018-03-03 16:31:49 +01:00
|
|
|
) if openclEnabled() else "None"
|
2015-12-16 00:58:52 +01:00
|
|
|
locale = getTranslationLanguage()
|
2024-05-21 16:49:12 +02:00
|
|
|
socks = getSOCKSProxyType(config) or 'N/A'
|
|
|
|
upnp = config.safeGet('bitmessagesettings', 'upnp', 'N/A')
|
2017-09-21 12:59:43 +02:00
|
|
|
connectedhosts = len(network.stats.connectedHostsList())
|
2015-12-16 00:58:52 +01:00
|
|
|
|
2024-05-23 06:28:40 +02:00
|
|
|
myapp.ui.textEditMessage.setText(unic(ustr(SUPPORT_MESSAGE).format(
|
2018-02-21 18:10:32 +01:00
|
|
|
version, osname, architecture, pythonversion, opensslversion, qtapi,
|
|
|
|
frozen, portablemode, cpow, openclpow, locale, socks, upnp,
|
|
|
|
connectedhosts
|
2024-05-29 14:39:16 +02:00
|
|
|
)))
|
2015-12-16 00:58:52 +01:00
|
|
|
|
|
|
|
# single msg tab
|
2018-01-18 15:14:29 +01:00
|
|
|
myapp.ui.tabWidgetSend.setCurrentIndex(
|
|
|
|
myapp.ui.tabWidgetSend.indexOf(myapp.ui.sendDirect)
|
|
|
|
)
|
2015-12-16 00:58:52 +01:00
|
|
|
# send tab
|
2018-01-18 15:14:29 +01:00
|
|
|
myapp.ui.tabWidget.setCurrentIndex(
|
|
|
|
myapp.ui.tabWidget.indexOf(myapp.ui.send)
|
|
|
|
)
|