2018-05-15 17:20:53 +02:00
|
|
|
# pylint: disable=too-many-lines,broad-except,too-many-instance-attributes,global-statement,too-few-public-methods
|
|
|
|
# pylint: disable=too-many-statements,too-many-branches,attribute-defined-outside-init,too-many-arguments,no-member
|
|
|
|
# pylint: disable=unused-argument,no-self-use,too-many-locals,unused-variable,too-many-nested-blocks
|
|
|
|
# pylint: disable=too-many-return-statements,protected-access,super-init-not-called,non-parent-init-called
|
|
|
|
"""
|
|
|
|
Initialise the QT interface
|
|
|
|
"""
|
|
|
|
|
|
|
|
from debug import logger # pylint: disable=wrong-import-order
|
|
|
|
|
|
|
|
import hashlib
|
|
|
|
import locale
|
|
|
|
import os
|
|
|
|
import random
|
|
|
|
import string
|
2018-01-22 17:52:28 +01:00
|
|
|
import sys
|
2018-05-15 17:20:53 +02:00
|
|
|
import textwrap
|
|
|
|
import time
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
|
2013-05-10 21:47:01 +02:00
|
|
|
|
2015-10-02 22:24:46 +02:00
|
|
|
try:
|
|
|
|
from PyQt4 import QtCore, QtGui
|
2016-05-02 17:10:45 +02:00
|
|
|
from PyQt4.QtNetwork import QLocalSocket, QLocalServer
|
2018-05-15 17:20:53 +02:00
|
|
|
except ImportError:
|
|
|
|
logmsg = (
|
|
|
|
'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).'
|
|
|
|
)
|
2015-11-20 08:49:44 +01:00
|
|
|
logger.critical(logmsg, exc_info=True)
|
2015-10-02 22:24:46 +02:00
|
|
|
sys.exit()
|
|
|
|
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2018-02-06 23:55:41 +01:00
|
|
|
from sqlite3 import register_adapter
|
2018-05-15 17:20:53 +02:00
|
|
|
|
|
|
|
import debug # pylint: disable=ungrouped-imports
|
|
|
|
import defaults
|
2016-02-14 19:56:05 +01:00
|
|
|
import helper_search
|
2018-05-15 17:20:53 +02:00
|
|
|
import knownnodes
|
2014-08-06 04:01:01 +02:00
|
|
|
import l10n
|
2015-11-26 02:37:07 +01:00
|
|
|
import openclpow
|
2017-01-11 17:00:00 +01:00
|
|
|
import paths
|
2017-02-08 13:41:56 +01:00
|
|
|
import queues
|
2018-05-15 17:20:53 +02:00
|
|
|
import shared
|
2017-02-08 13:41:56 +01:00
|
|
|
import shutdown
|
2017-01-11 17:00:00 +01:00
|
|
|
import state
|
2018-05-15 17:20:53 +02:00
|
|
|
import upnp
|
|
|
|
|
|
|
|
from bitmessageqt import sound, support, dialogs
|
|
|
|
from bitmessageqt.foldertree import (
|
|
|
|
AccountMixin, Ui_FolderWidget, Ui_AddressWidget, Ui_SubscriptionWidget, MessageList_AddressWidget,
|
|
|
|
MessageList_SubjectWidget, Ui_AddressBookWidgetItemLabel, Ui_AddressBookWidgetItemAddress,
|
|
|
|
)
|
|
|
|
from bitmessageqt.account import (
|
|
|
|
getSortedAccounts, getSortedSubscriptions, accountClass, BMAccount, GatewayAccount, MailchuckAccount, AccountColor,
|
|
|
|
)
|
|
|
|
from bitmessageqt.bitmessageui import Ui_MainWindow, settingsmixin
|
|
|
|
from bitmessageqt.messageview import MessageView
|
|
|
|
from bitmessageqt.migrationwizard import Ui_MigrationWizard
|
|
|
|
from bitmessageqt.settings import Ui_settingsDialog
|
|
|
|
from bitmessageqt.utils import str_broadcast_subscribers, avatarize
|
|
|
|
from bitmessageqt.uisignaler import UISignaler
|
|
|
|
from bitmessageqt.statusbar import BMStatusBar
|
|
|
|
|
|
|
|
from addresses import decodeAddress, addBMIfNotPresent
|
|
|
|
from bmconfigparser import BMConfigParser
|
|
|
|
from namecoin import namecoinConnection
|
|
|
|
from helper_ackPayload import genAckPayload
|
|
|
|
from helper_generic import powQueueSize
|
|
|
|
from helper_sql import sqlQuery, sqlExecute, sqlExecuteChunked, sqlStoredProcedure
|
|
|
|
from network.stats import pendingDownload, pendingUpload
|
2018-01-01 12:49:08 +01:00
|
|
|
from network.asyncore_pollchoose import set_rates
|
2018-05-15 17:20:53 +02:00
|
|
|
from proofofwork import getPowType
|
|
|
|
from tr import _translate
|
2013-06-25 22:26:12 +02:00
|
|
|
|
2017-10-13 00:36:54 +02:00
|
|
|
|
2017-03-01 15:46:13 +01:00
|
|
|
try:
|
2017-03-10 15:45:46 +01:00
|
|
|
from plugins.plugin import get_plugin, get_plugins
|
2017-03-01 15:46:13 +01:00
|
|
|
except ImportError:
|
|
|
|
get_plugins = False
|
|
|
|
|
|
|
|
|
2018-05-15 17:20:53 +02:00
|
|
|
qmytranslator = None
|
|
|
|
qsystranslator = None
|
|
|
|
|
|
|
|
|
2016-12-13 11:54:01 +01:00
|
|
|
def change_translation(newlocale):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Change a translation to a new locale"""
|
|
|
|
|
2015-12-15 04:24:35 +01:00
|
|
|
global qmytranslator, qsystranslator
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-12-15 04:24:35 +01:00
|
|
|
try:
|
|
|
|
if not qmytranslator.isEmpty():
|
|
|
|
QtGui.QApplication.removeTranslator(qmytranslator)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
if not qsystranslator.isEmpty():
|
|
|
|
QtGui.QApplication.removeTranslator(qsystranslator)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
qmytranslator = QtCore.QTranslator()
|
2018-05-15 17:20:53 +02:00
|
|
|
translationpath = os.path.join(paths.codePath(), 'translations', 'bitmessage_' + newlocale)
|
2015-12-15 04:24:35 +01:00
|
|
|
qmytranslator.load(translationpath)
|
|
|
|
QtGui.QApplication.installTranslator(qmytranslator)
|
|
|
|
|
|
|
|
qsystranslator = QtCore.QTranslator()
|
2017-01-11 17:00:00 +01:00
|
|
|
if paths.frozen:
|
2018-05-15 17:20:53 +02:00
|
|
|
translationpath = os.path.join(paths.codePath(), 'translations', 'qt_' + newlocale)
|
2015-12-22 23:28:40 +01:00
|
|
|
else:
|
2018-05-15 17:20:53 +02:00
|
|
|
translationpath = os.path.join(str(QtCore.QLibraryInfo.location(
|
|
|
|
QtCore.QLibraryInfo.TranslationsPath)), 'qt_' + newlocale)
|
2015-12-15 04:24:35 +01:00
|
|
|
qsystranslator.load(translationpath)
|
|
|
|
QtGui.QApplication.installTranslator(qsystranslator)
|
2013-11-02 00:25:24 +01:00
|
|
|
|
2016-12-13 11:54:01 +01:00
|
|
|
lang = locale.normalize(l10n.getTranslationLanguage())
|
2016-06-14 21:57:40 +02:00
|
|
|
langs = [lang.split(".")[0] + "." + l10n.encoding, lang.split(".")[0] + "." + 'UTF-8', lang]
|
2016-04-27 12:15:30 +02:00
|
|
|
if 'win32' in sys.platform or 'win64' in sys.platform:
|
2016-05-24 08:44:07 +02:00
|
|
|
langs = [l10n.getWindowsLocale(lang)]
|
|
|
|
for lang in langs:
|
|
|
|
try:
|
2016-12-13 11:54:01 +01:00
|
|
|
l10n.setlocale(locale.LC_ALL, lang)
|
2016-05-24 08:44:07 +02:00
|
|
|
if 'win32' not in sys.platform and 'win64' not in sys.platform:
|
2016-12-13 11:54:01 +01:00
|
|
|
l10n.encoding = locale.nl_langinfo(locale.CODESET)
|
2016-05-24 08:44:07 +02:00
|
|
|
else:
|
2016-12-13 11:54:01 +01:00
|
|
|
l10n.encoding = locale.getlocale()[1]
|
2016-05-24 08:44:07 +02:00
|
|
|
logger.info("Successfully set locale to %s", lang)
|
|
|
|
break
|
|
|
|
except:
|
|
|
|
logger.error("Failed to set locale to %s", lang, exc_info=True)
|
2016-04-25 18:14:42 +02:00
|
|
|
|
2017-03-23 18:04:56 +01:00
|
|
|
|
2018-05-15 17:20:53 +02:00
|
|
|
class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-methods
|
|
|
|
"""TBC"""
|
2013-05-10 21:47:01 +02:00
|
|
|
|
2013-07-31 23:25:34 +02:00
|
|
|
# the last time that a message arrival sound was played
|
2017-03-10 00:00:54 +01:00
|
|
|
lastSoundTime = datetime.now() - timedelta(days=1)
|
2013-07-31 23:25:34 +02:00
|
|
|
|
|
|
|
# the maximum frequency of message sounds in seconds
|
|
|
|
maxSoundFrequencySec = 60
|
|
|
|
|
2015-12-14 13:07:17 +01:00
|
|
|
REPLY_TYPE_SENDER = 0
|
|
|
|
REPLY_TYPE_CHAN = 1
|
2013-05-14 17:06:01 +02:00
|
|
|
|
2013-11-07 20:35:11 +01:00
|
|
|
def init_file_menu(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Initialise the file menu"""
|
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
QtCore.QObject.connect(self.ui.actionExit, QtCore.SIGNAL(
|
|
|
|
"triggered()"), self.quit)
|
2018-01-24 17:37:05 +01:00
|
|
|
QtCore.QObject.connect(self.ui.actionNetworkSwitch, QtCore.SIGNAL(
|
|
|
|
"triggered()"), self.network_switch)
|
2013-06-12 23:12:32 +02:00
|
|
|
QtCore.QObject.connect(self.ui.actionManageKeys, QtCore.SIGNAL(
|
|
|
|
"triggered()"), self.click_actionManageKeys)
|
2013-11-07 20:35:11 +01:00
|
|
|
QtCore.QObject.connect(self.ui.actionDeleteAllTrashedMessages,
|
|
|
|
QtCore.SIGNAL(
|
|
|
|
"triggered()"),
|
|
|
|
self.click_actionDeleteAllTrashedMessages)
|
|
|
|
QtCore.QObject.connect(self.ui.actionRegenerateDeterministicAddresses,
|
|
|
|
QtCore.SIGNAL(
|
|
|
|
"triggered()"),
|
|
|
|
self.click_actionRegenerateDeterministicAddresses)
|
2018-05-15 17:20:53 +02:00
|
|
|
QtCore.QObject.connect(
|
|
|
|
self.ui.pushButtonAddChan,
|
|
|
|
QtCore.SIGNAL("clicked()"),
|
|
|
|
self.click_actionJoinChan) # also used for creating chans.
|
2013-06-12 23:12:32 +02:00
|
|
|
QtCore.QObject.connect(self.ui.pushButtonNewAddress, QtCore.SIGNAL(
|
|
|
|
"clicked()"), self.click_NewAddressDialog)
|
|
|
|
QtCore.QObject.connect(self.ui.pushButtonAddAddressBook, QtCore.SIGNAL(
|
|
|
|
"clicked()"), self.click_pushButtonAddAddressBook)
|
|
|
|
QtCore.QObject.connect(self.ui.pushButtonAddSubscription, QtCore.SIGNAL(
|
|
|
|
"clicked()"), self.click_pushButtonAddSubscription)
|
2015-03-03 20:04:12 +01:00
|
|
|
QtCore.QObject.connect(self.ui.pushButtonTTL, QtCore.SIGNAL(
|
|
|
|
"clicked()"), self.click_pushButtonTTL)
|
2018-02-05 15:40:43 +01:00
|
|
|
QtCore.QObject.connect(self.ui.pushButtonClear, QtCore.SIGNAL(
|
|
|
|
"clicked()"), self.click_pushButtonClear)
|
2013-06-12 23:12:32 +02:00
|
|
|
QtCore.QObject.connect(self.ui.pushButtonSend, QtCore.SIGNAL(
|
|
|
|
"clicked()"), self.click_pushButtonSend)
|
2015-03-21 11:37:08 +01:00
|
|
|
QtCore.QObject.connect(self.ui.pushButtonFetchNamecoinID, QtCore.SIGNAL(
|
|
|
|
"clicked()"), self.click_pushButtonFetchNamecoinID)
|
2013-06-12 23:12:32 +02:00
|
|
|
QtCore.QObject.connect(self.ui.actionSettings, QtCore.SIGNAL(
|
|
|
|
"triggered()"), self.click_actionSettings)
|
|
|
|
QtCore.QObject.connect(self.ui.actionAbout, QtCore.SIGNAL(
|
|
|
|
"triggered()"), self.click_actionAbout)
|
2015-12-16 00:58:52 +01:00
|
|
|
QtCore.QObject.connect(self.ui.actionSupport, QtCore.SIGNAL(
|
|
|
|
"triggered()"), self.click_actionSupport)
|
2013-06-12 23:12:32 +02:00
|
|
|
QtCore.QObject.connect(self.ui.actionHelp, QtCore.SIGNAL(
|
|
|
|
"triggered()"), self.click_actionHelp)
|
|
|
|
|
2014-12-28 11:42:38 +01:00
|
|
|
def init_inbox_popup_menu(self, connectSignal=True):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Popup menu for the Inbox tab"""
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
self.ui.inboxContextMenuToolbar = QtGui.QToolBar()
|
2013-11-07 20:35:11 +01:00
|
|
|
# Actions
|
2013-06-13 09:59:40 +02:00
|
|
|
self.actionReply = self.ui.inboxContextMenuToolbar.addAction(_translate(
|
2015-12-14 13:07:17 +01:00
|
|
|
"MainWindow", "Reply to sender"), self.on_action_InboxReply)
|
|
|
|
self.actionReplyChan = self.ui.inboxContextMenuToolbar.addAction(_translate(
|
|
|
|
"MainWindow", "Reply to channel"), self.on_action_InboxReplyChan)
|
2013-11-07 20:35:11 +01:00
|
|
|
self.actionAddSenderToAddressBook = self.ui.inboxContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Add sender to your Address Book"),
|
|
|
|
self.on_action_InboxAddSenderToAddressBook)
|
2015-11-14 01:14:10 +01:00
|
|
|
self.actionAddSenderToBlackList = self.ui.inboxContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Add sender to your Blacklist"),
|
|
|
|
self.on_action_InboxAddSenderToBlackList)
|
2013-06-12 23:12:32 +02:00
|
|
|
self.actionTrashInboxMessage = self.ui.inboxContextMenuToolbar.addAction(
|
2013-11-07 20:35:11 +01:00
|
|
|
_translate("MainWindow", "Move to Trash"),
|
|
|
|
self.on_action_InboxTrash)
|
2015-11-01 10:56:37 +01:00
|
|
|
self.actionUndeleteTrashedMessage = self.ui.inboxContextMenuToolbar.addAction(
|
|
|
|
_translate("MainWindow", "Undelete"),
|
|
|
|
self.on_action_TrashUndelete)
|
2013-11-07 20:35:11 +01:00
|
|
|
self.actionForceHtml = self.ui.inboxContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "View HTML code as formatted text"),
|
|
|
|
self.on_action_InboxMessageForceHtml)
|
|
|
|
self.actionSaveMessageAs = self.ui.inboxContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Save message as..."),
|
|
|
|
self.on_action_InboxSaveMessageAs)
|
|
|
|
self.actionMarkUnread = self.ui.inboxContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Mark Unread"), self.on_action_InboxMarkUnread)
|
2015-03-23 22:35:56 +01:00
|
|
|
|
|
|
|
# contextmenu messagelists
|
2013-06-12 23:12:32 +02:00
|
|
|
self.ui.tableWidgetInbox.setContextMenuPolicy(
|
|
|
|
QtCore.Qt.CustomContextMenu)
|
2014-12-28 11:42:38 +01:00
|
|
|
if connectSignal:
|
2018-05-15 17:20:53 +02:00
|
|
|
self.connect(
|
|
|
|
self.ui.tableWidgetInbox,
|
|
|
|
QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'),
|
|
|
|
self.on_context_menuInbox)
|
2015-03-23 22:35:56 +01:00
|
|
|
self.ui.tableWidgetInboxSubscriptions.setContextMenuPolicy(
|
|
|
|
QtCore.Qt.CustomContextMenu)
|
|
|
|
if connectSignal:
|
2018-05-15 17:20:53 +02:00
|
|
|
self.connect(
|
|
|
|
self.ui.tableWidgetInboxSubscriptions,
|
|
|
|
QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'),
|
|
|
|
self.on_context_menuInbox)
|
2015-03-23 22:35:56 +01:00
|
|
|
self.ui.tableWidgetInboxChans.setContextMenuPolicy(
|
|
|
|
QtCore.Qt.CustomContextMenu)
|
|
|
|
if connectSignal:
|
2018-05-15 17:20:53 +02:00
|
|
|
self.connect(
|
|
|
|
self.ui.tableWidgetInboxChans,
|
|
|
|
QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'),
|
|
|
|
self.on_context_menuInbox)
|
2015-03-23 22:35:56 +01:00
|
|
|
|
2014-12-28 11:42:38 +01:00
|
|
|
def init_identities_popup_menu(self, connectSignal=True):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Popup menu for the Your Identities tab"""
|
|
|
|
|
2015-03-21 11:37:08 +01:00
|
|
|
self.ui.addressContextMenuToolbarYourIdentities = QtGui.QToolBar()
|
|
|
|
# Actions
|
|
|
|
self.actionNewYourIdentities = self.ui.addressContextMenuToolbarYourIdentities.addAction(_translate(
|
|
|
|
"MainWindow", "New"), self.on_action_YourIdentitiesNew)
|
|
|
|
self.actionEnableYourIdentities = self.ui.addressContextMenuToolbarYourIdentities.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Enable"), self.on_action_Enable)
|
|
|
|
self.actionDisableYourIdentities = self.ui.addressContextMenuToolbarYourIdentities.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Disable"), self.on_action_Disable)
|
|
|
|
self.actionSetAvatarYourIdentities = self.ui.addressContextMenuToolbarYourIdentities.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Set avatar..."),
|
|
|
|
self.on_action_TreeWidgetSetAvatar)
|
|
|
|
self.actionClipboardYourIdentities = self.ui.addressContextMenuToolbarYourIdentities.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Copy address to clipboard"),
|
|
|
|
self.on_action_Clipboard)
|
|
|
|
self.actionSpecialAddressBehaviorYourIdentities = self.ui.addressContextMenuToolbarYourIdentities.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Special address behavior..."),
|
|
|
|
self.on_action_SpecialAddressBehaviorDialog)
|
2015-10-03 17:24:21 +02:00
|
|
|
self.actionEmailGateway = self.ui.addressContextMenuToolbarYourIdentities.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Email gateway"),
|
|
|
|
self.on_action_EmailGatewayDialog)
|
2016-08-20 22:38:36 +02:00
|
|
|
self.actionMarkAllRead = self.ui.addressContextMenuToolbarYourIdentities.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Mark all messages as read"),
|
|
|
|
self.on_action_MarkAllRead)
|
2015-03-21 11:37:08 +01:00
|
|
|
|
|
|
|
self.ui.treeWidgetYourIdentities.setContextMenuPolicy(
|
|
|
|
QtCore.Qt.CustomContextMenu)
|
|
|
|
if connectSignal:
|
2018-05-15 17:20:53 +02:00
|
|
|
self.connect(
|
|
|
|
self.ui.treeWidgetYourIdentities,
|
|
|
|
QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'),
|
|
|
|
self.on_context_menuYourIdentities)
|
2015-03-21 11:37:08 +01:00
|
|
|
|
2017-03-07 14:44:48 +01:00
|
|
|
# load all gui.menu plugins with prefix 'address'
|
|
|
|
self.menu_plugins = {'address': []}
|
|
|
|
for plugin in get_plugins('gui.menu', 'address'):
|
|
|
|
try:
|
|
|
|
handler, title = plugin(self)
|
|
|
|
except TypeError:
|
|
|
|
continue
|
|
|
|
self.menu_plugins['address'].append(
|
|
|
|
self.ui.addressContextMenuToolbarYourIdentities.addAction(
|
|
|
|
title, handler
|
|
|
|
))
|
|
|
|
|
2015-03-21 11:37:08 +01:00
|
|
|
def init_chan_popup_menu(self, connectSignal=True):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Popup menu for the Channels tab"""
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
self.ui.addressContextMenuToolbar = QtGui.QToolBar()
|
2013-11-07 20:35:11 +01:00
|
|
|
# Actions
|
2013-06-13 09:59:40 +02:00
|
|
|
self.actionNew = self.ui.addressContextMenuToolbar.addAction(_translate(
|
2013-06-12 23:12:32 +02:00
|
|
|
"MainWindow", "New"), self.on_action_YourIdentitiesNew)
|
2015-11-09 18:22:38 +01:00
|
|
|
self.actionDelete = self.ui.addressContextMenuToolbar.addAction(
|
|
|
|
_translate("MainWindow", "Delete"),
|
|
|
|
self.on_action_YourIdentitiesDelete)
|
2013-11-07 20:35:11 +01:00
|
|
|
self.actionEnable = self.ui.addressContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
2015-03-21 11:37:08 +01:00
|
|
|
"MainWindow", "Enable"), self.on_action_Enable)
|
2013-11-07 20:35:11 +01:00
|
|
|
self.actionDisable = self.ui.addressContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
2015-03-21 11:37:08 +01:00
|
|
|
"MainWindow", "Disable"), self.on_action_Disable)
|
2013-11-07 20:35:11 +01:00
|
|
|
self.actionSetAvatar = self.ui.addressContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Set avatar..."),
|
2015-03-21 11:37:08 +01:00
|
|
|
self.on_action_TreeWidgetSetAvatar)
|
2013-11-07 20:35:11 +01:00
|
|
|
self.actionClipboard = self.ui.addressContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Copy address to clipboard"),
|
2015-03-21 11:37:08 +01:00
|
|
|
self.on_action_Clipboard)
|
2013-11-07 20:35:11 +01:00
|
|
|
self.actionSpecialAddressBehavior = self.ui.addressContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Special address behavior..."),
|
|
|
|
self.on_action_SpecialAddressBehaviorDialog)
|
2015-03-03 18:17:56 +01:00
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
self.ui.treeWidgetChans.setContextMenuPolicy(
|
2013-06-12 23:12:32 +02:00
|
|
|
QtCore.Qt.CustomContextMenu)
|
2014-12-28 11:42:38 +01:00
|
|
|
if connectSignal:
|
2018-05-15 17:20:53 +02:00
|
|
|
self.connect(
|
|
|
|
self.ui.treeWidgetChans,
|
|
|
|
QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'),
|
|
|
|
self.on_context_menuChan)
|
2015-03-03 18:17:56 +01:00
|
|
|
|
2014-12-28 11:42:38 +01:00
|
|
|
def init_addressbook_popup_menu(self, connectSignal=True):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Popup menu for the Address Book page"""
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
self.ui.addressBookContextMenuToolbar = QtGui.QToolBar()
|
2013-11-07 20:35:11 +01:00
|
|
|
# Actions
|
|
|
|
self.actionAddressBookSend = self.ui.addressBookContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Send message to this address"),
|
|
|
|
self.on_action_AddressBookSend)
|
|
|
|
self.actionAddressBookClipboard = self.ui.addressBookContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Copy address to clipboard"),
|
|
|
|
self.on_action_AddressBookClipboard)
|
|
|
|
self.actionAddressBookSubscribe = self.ui.addressBookContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Subscribe to this address"),
|
|
|
|
self.on_action_AddressBookSubscribe)
|
|
|
|
self.actionAddressBookSetAvatar = self.ui.addressBookContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Set avatar..."),
|
|
|
|
self.on_action_AddressBookSetAvatar)
|
2017-09-04 15:06:48 +02:00
|
|
|
self.actionAddressBookSetSound = \
|
|
|
|
self.ui.addressBookContextMenuToolbar.addAction(
|
|
|
|
_translate("MainWindow", "Set notification sound..."),
|
|
|
|
self.on_action_AddressBookSetSound)
|
2013-11-07 20:35:11 +01:00
|
|
|
self.actionAddressBookNew = self.ui.addressBookContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Add New Address"), self.on_action_AddressBookNew)
|
|
|
|
self.actionAddressBookDelete = self.ui.addressBookContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Delete"), self.on_action_AddressBookDelete)
|
2013-06-12 23:12:32 +02:00
|
|
|
self.ui.tableWidgetAddressBook.setContextMenuPolicy(
|
|
|
|
QtCore.Qt.CustomContextMenu)
|
2014-12-28 11:42:38 +01:00
|
|
|
if connectSignal:
|
2018-05-15 17:20:53 +02:00
|
|
|
self.connect(
|
|
|
|
self.ui.tableWidgetAddressBook,
|
|
|
|
QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'),
|
|
|
|
self.on_context_menuAddressBook)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2014-12-28 11:42:38 +01:00
|
|
|
def init_subscriptions_popup_menu(self, connectSignal=True):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Popup menu for the Subscriptions page"""
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
self.ui.subscriptionsContextMenuToolbar = QtGui.QToolBar()
|
2013-11-07 20:35:11 +01:00
|
|
|
# Actions
|
2013-06-12 23:12:32 +02:00
|
|
|
self.actionsubscriptionsNew = self.ui.subscriptionsContextMenuToolbar.addAction(
|
2013-06-13 09:59:40 +02:00
|
|
|
_translate("MainWindow", "New"), self.on_action_SubscriptionsNew)
|
2013-06-12 23:12:32 +02:00
|
|
|
self.actionsubscriptionsDelete = self.ui.subscriptionsContextMenuToolbar.addAction(
|
2013-11-07 20:35:11 +01:00
|
|
|
_translate("MainWindow", "Delete"),
|
|
|
|
self.on_action_SubscriptionsDelete)
|
2013-06-12 23:12:32 +02:00
|
|
|
self.actionsubscriptionsClipboard = self.ui.subscriptionsContextMenuToolbar.addAction(
|
2013-11-07 20:35:11 +01:00
|
|
|
_translate("MainWindow", "Copy address to clipboard"),
|
|
|
|
self.on_action_SubscriptionsClipboard)
|
2013-06-12 23:12:32 +02:00
|
|
|
self.actionsubscriptionsEnable = self.ui.subscriptionsContextMenuToolbar.addAction(
|
2013-11-07 20:35:11 +01:00
|
|
|
_translate("MainWindow", "Enable"),
|
|
|
|
self.on_action_SubscriptionsEnable)
|
2013-06-12 23:12:32 +02:00
|
|
|
self.actionsubscriptionsDisable = self.ui.subscriptionsContextMenuToolbar.addAction(
|
2013-11-07 20:35:11 +01:00
|
|
|
_translate("MainWindow", "Disable"),
|
|
|
|
self.on_action_SubscriptionsDisable)
|
2013-09-21 09:41:23 +02:00
|
|
|
self.actionsubscriptionsSetAvatar = self.ui.subscriptionsContextMenuToolbar.addAction(
|
2013-11-07 20:35:11 +01:00
|
|
|
_translate("MainWindow", "Set avatar..."),
|
2015-03-21 11:37:08 +01:00
|
|
|
self.on_action_TreeWidgetSetAvatar)
|
|
|
|
self.ui.treeWidgetSubscriptions.setContextMenuPolicy(
|
2013-06-12 23:12:32 +02:00
|
|
|
QtCore.Qt.CustomContextMenu)
|
2014-12-28 11:42:38 +01:00
|
|
|
if connectSignal:
|
2018-05-15 17:20:53 +02:00
|
|
|
self.connect(
|
|
|
|
self.ui.treeWidgetSubscriptions,
|
|
|
|
QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'),
|
|
|
|
self.on_context_menuSubscriptions)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2014-12-28 11:42:38 +01:00
|
|
|
def init_sent_popup_menu(self, connectSignal=True):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Popup menu for the Sent page"""
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
self.ui.sentContextMenuToolbar = QtGui.QToolBar()
|
2013-11-07 20:35:11 +01:00
|
|
|
# Actions
|
|
|
|
self.actionTrashSentMessage = self.ui.sentContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Move to Trash"), self.on_action_SentTrash)
|
|
|
|
self.actionSentClipboard = self.ui.sentContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Copy destination address to clipboard"),
|
|
|
|
self.on_action_SentClipboard)
|
|
|
|
self.actionForceSend = self.ui.sentContextMenuToolbar.addAction(
|
|
|
|
_translate(
|
|
|
|
"MainWindow", "Force send"), self.on_action_ForceSend)
|
2013-06-12 23:12:32 +02:00
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
def rerenderTabTreeSubscriptions(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
treeWidget = self.ui.treeWidgetSubscriptions
|
2015-11-27 00:56:25 +01:00
|
|
|
folders = Ui_FolderWidget.folderWeight.keys()
|
|
|
|
folders.remove("new")
|
2015-03-23 22:35:56 +01:00
|
|
|
|
2015-11-19 04:05:58 +01:00
|
|
|
# sort ascending when creating
|
|
|
|
if treeWidget.topLevelItemCount() == 0:
|
2018-01-22 17:52:28 +01:00
|
|
|
treeWidget.header().setSortIndicator(
|
|
|
|
0, QtCore.Qt.AscendingOrder)
|
2015-11-19 04:05:58 +01:00
|
|
|
# init dictionary
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-11-19 04:05:58 +01:00
|
|
|
db = getSortedSubscriptions(True)
|
2015-11-19 04:14:13 +01:00
|
|
|
for address in db:
|
|
|
|
for folder in folders:
|
2018-05-15 17:20:53 +02:00
|
|
|
if folder not in db[address]:
|
2015-11-19 04:14:13 +01:00
|
|
|
db[address][folder] = {}
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-11-19 04:05:58 +01:00
|
|
|
if treeWidget.isSortingEnabled():
|
|
|
|
treeWidget.setSortingEnabled(False)
|
|
|
|
|
|
|
|
i = 0
|
|
|
|
while i < treeWidget.topLevelItemCount():
|
|
|
|
widget = treeWidget.topLevelItem(i)
|
|
|
|
if widget is not None:
|
|
|
|
toAddress = widget.address
|
|
|
|
else:
|
|
|
|
toAddress = None
|
2018-05-15 17:20:53 +02:00
|
|
|
|
|
|
|
if toAddress not in db:
|
2015-11-19 04:05:58 +01:00
|
|
|
treeWidget.takeTopLevelItem(i)
|
|
|
|
# no increment
|
|
|
|
continue
|
|
|
|
unread = 0
|
|
|
|
j = 0
|
|
|
|
while j < widget.childCount():
|
|
|
|
subwidget = widget.child(j)
|
|
|
|
try:
|
|
|
|
subwidget.setUnreadCount(db[toAddress][subwidget.folderName]['count'])
|
|
|
|
unread += db[toAddress][subwidget.folderName]['count']
|
|
|
|
db[toAddress].pop(subwidget.folderName, None)
|
|
|
|
except:
|
|
|
|
widget.takeChild(j)
|
|
|
|
# no increment
|
|
|
|
continue
|
|
|
|
j += 1
|
|
|
|
|
|
|
|
# add missing folders
|
2018-05-15 17:20:53 +02:00
|
|
|
if db[toAddress]:
|
2015-11-19 04:05:58 +01:00
|
|
|
j = 0
|
|
|
|
for f, c in db[toAddress].iteritems():
|
2015-11-19 04:14:13 +01:00
|
|
|
try:
|
|
|
|
subwidget = Ui_FolderWidget(widget, j, toAddress, f, c['count'])
|
|
|
|
except KeyError:
|
|
|
|
subwidget = Ui_FolderWidget(widget, j, toAddress, f, 0)
|
2015-11-19 04:05:58 +01:00
|
|
|
j += 1
|
|
|
|
widget.setUnreadCount(unread)
|
|
|
|
db.pop(toAddress, None)
|
|
|
|
i += 1
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-11-19 04:05:58 +01:00
|
|
|
i = 0
|
|
|
|
for toAddress in db:
|
2018-05-15 17:20:53 +02:00
|
|
|
widget = Ui_SubscriptionWidget(
|
|
|
|
treeWidget, i, toAddress,
|
|
|
|
db[toAddress]["inbox"]['count'],
|
|
|
|
db[toAddress]["inbox"]['label'],
|
|
|
|
db[toAddress]["inbox"]['enabled'])
|
2015-11-19 04:05:58 +01:00
|
|
|
j = 0
|
2015-10-18 21:11:10 +02:00
|
|
|
unread = 0
|
2015-03-23 22:35:56 +01:00
|
|
|
for folder in folders:
|
2015-10-18 21:11:10 +02:00
|
|
|
try:
|
2015-11-19 04:05:58 +01:00
|
|
|
subwidget = Ui_FolderWidget(widget, j, toAddress, folder, db[toAddress][folder]['count'])
|
|
|
|
unread += db[toAddress][folder]['count']
|
2015-10-18 21:11:10 +02:00
|
|
|
except KeyError:
|
2015-11-19 04:05:58 +01:00
|
|
|
subwidget = Ui_FolderWidget(widget, j, toAddress, folder, 0)
|
|
|
|
j += 1
|
|
|
|
widget.setUnreadCount(unread)
|
|
|
|
i += 1
|
2015-03-23 22:35:56 +01:00
|
|
|
|
2018-05-15 17:20:53 +02:00
|
|
|
treeWidget.setSortingEnabled(True)
|
2015-11-19 04:05:58 +01:00
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
def rerenderTabTreeMessages(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
self.rerenderTabTree('messages')
|
|
|
|
|
|
|
|
def rerenderTabTreeChans(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
self.rerenderTabTree('chan')
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-03-21 11:37:08 +01:00
|
|
|
def rerenderTabTree(self, tab):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-21 11:37:08 +01:00
|
|
|
if tab == 'messages':
|
|
|
|
treeWidget = self.ui.treeWidgetYourIdentities
|
|
|
|
elif tab == 'chan':
|
2015-03-23 22:35:56 +01:00
|
|
|
treeWidget = self.ui.treeWidgetChans
|
2015-11-27 00:56:25 +01:00
|
|
|
folders = Ui_FolderWidget.folderWeight.keys()
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-10-03 12:12:18 +02:00
|
|
|
# sort ascending when creating
|
|
|
|
if treeWidget.topLevelItemCount() == 0:
|
2018-01-22 17:52:28 +01:00
|
|
|
treeWidget.header().setSortIndicator(
|
|
|
|
0, QtCore.Qt.AscendingOrder)
|
2015-10-02 22:24:46 +02:00
|
|
|
# init dictionary
|
|
|
|
db = {}
|
|
|
|
enabled = {}
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-10-19 20:03:06 +02:00
|
|
|
for toAddress in getSortedAccounts():
|
2017-01-11 14:27:19 +01:00
|
|
|
isEnabled = BMConfigParser().getboolean(
|
2015-10-02 22:24:46 +02:00
|
|
|
toAddress, 'enabled')
|
2017-01-11 14:27:19 +01:00
|
|
|
isChan = BMConfigParser().safeGetBoolean(
|
2015-10-02 22:24:46 +02:00
|
|
|
toAddress, 'chan')
|
2015-10-01 10:15:23 +02:00
|
|
|
|
2016-01-24 18:25:33 +01:00
|
|
|
if treeWidget == self.ui.treeWidgetYourIdentities:
|
2015-10-01 10:15:23 +02:00
|
|
|
if isChan:
|
|
|
|
continue
|
2016-01-24 18:25:33 +01:00
|
|
|
elif treeWidget == self.ui.treeWidgetChans:
|
2015-10-01 10:15:23 +02:00
|
|
|
if not isChan:
|
|
|
|
continue
|
|
|
|
|
2015-10-02 22:24:46 +02:00
|
|
|
db[toAddress] = {}
|
2015-10-01 10:15:23 +02:00
|
|
|
for folder in folders:
|
2015-10-02 22:24:46 +02:00
|
|
|
db[toAddress][folder] = 0
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-10-02 22:24:46 +02:00
|
|
|
enabled[toAddress] = isEnabled
|
2015-10-01 10:15:23 +02:00
|
|
|
|
2015-10-02 22:24:46 +02:00
|
|
|
# get number of (unread) messages
|
2015-11-27 00:56:25 +01:00
|
|
|
total = 0
|
2018-05-15 17:20:53 +02:00
|
|
|
queryreturn = sqlQuery(
|
|
|
|
'SELECT toaddress, folder, count(msgid) as cnt FROM inbox WHERE read = 0 GROUP BY toaddress, folder')
|
2015-10-02 22:24:46 +02:00
|
|
|
for row in queryreturn:
|
|
|
|
toaddress, folder, cnt = row
|
2015-11-27 00:56:25 +01:00
|
|
|
total += cnt
|
2015-10-02 22:24:46 +02:00
|
|
|
if toaddress in db and folder in db[toaddress]:
|
|
|
|
db[toaddress][folder] = cnt
|
2016-01-24 18:25:33 +01:00
|
|
|
if treeWidget == self.ui.treeWidgetYourIdentities:
|
2015-11-27 00:56:25 +01:00
|
|
|
db[None] = {}
|
|
|
|
db[None]["inbox"] = total
|
|
|
|
db[None]["new"] = total
|
2016-03-16 18:30:47 +01:00
|
|
|
db[None]["sent"] = 0
|
|
|
|
db[None]["trash"] = 0
|
2015-11-27 00:56:25 +01:00
|
|
|
enabled[None] = True
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-10-02 22:24:46 +02:00
|
|
|
if treeWidget.isSortingEnabled():
|
|
|
|
treeWidget.setSortingEnabled(False)
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-11-09 18:44:27 +01:00
|
|
|
i = 0
|
|
|
|
while i < treeWidget.topLevelItemCount():
|
2015-10-02 22:24:46 +02:00
|
|
|
widget = treeWidget.topLevelItem(i)
|
2015-11-09 18:22:38 +01:00
|
|
|
if widget is not None:
|
|
|
|
toAddress = widget.address
|
|
|
|
else:
|
|
|
|
toAddress = None
|
2018-05-15 17:20:53 +02:00
|
|
|
|
|
|
|
if toAddress not in db:
|
2015-10-02 22:24:46 +02:00
|
|
|
treeWidget.takeTopLevelItem(i)
|
2015-11-09 18:44:27 +01:00
|
|
|
# no increment
|
2015-10-02 22:24:46 +02:00
|
|
|
continue
|
|
|
|
unread = 0
|
2015-11-09 18:44:27 +01:00
|
|
|
j = 0
|
|
|
|
while j < widget.childCount():
|
2015-10-02 22:24:46 +02:00
|
|
|
subwidget = widget.child(j)
|
|
|
|
try:
|
|
|
|
subwidget.setUnreadCount(db[toAddress][subwidget.folderName])
|
2016-04-28 10:12:06 +02:00
|
|
|
if subwidget.folderName not in ["new", "trash", "sent"]:
|
|
|
|
unread += db[toAddress][subwidget.folderName]
|
2015-10-02 22:24:46 +02:00
|
|
|
db[toAddress].pop(subwidget.folderName, None)
|
|
|
|
except:
|
2015-11-09 18:44:27 +01:00
|
|
|
widget.takeChild(j)
|
|
|
|
# no increment
|
|
|
|
continue
|
|
|
|
j += 1
|
2015-10-02 22:24:46 +02:00
|
|
|
|
|
|
|
# add missing folders
|
2018-05-15 17:20:53 +02:00
|
|
|
if db[toAddress]:
|
2015-11-09 18:44:27 +01:00
|
|
|
j = 0
|
2015-10-02 22:24:46 +02:00
|
|
|
for f, c in db[toAddress].iteritems():
|
2017-02-14 01:35:32 +01:00
|
|
|
if toAddress is not None and tab == 'messages' and folder == "new":
|
|
|
|
continue
|
2015-11-09 18:44:27 +01:00
|
|
|
subwidget = Ui_FolderWidget(widget, j, toAddress, f, c)
|
2016-04-28 10:12:06 +02:00
|
|
|
if subwidget.folderName not in ["new", "trash", "sent"]:
|
|
|
|
unread += c
|
2015-11-09 18:44:27 +01:00
|
|
|
j += 1
|
2015-10-02 22:24:46 +02:00
|
|
|
widget.setUnreadCount(unread)
|
|
|
|
db.pop(toAddress, None)
|
2015-11-09 18:44:27 +01:00
|
|
|
i += 1
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-10-02 22:24:46 +02:00
|
|
|
i = 0
|
|
|
|
for toAddress in db:
|
2015-10-27 19:24:29 +01:00
|
|
|
widget = Ui_AddressWidget(treeWidget, i, toAddress, db[toAddress]["inbox"], enabled[toAddress])
|
2015-10-02 22:24:46 +02:00
|
|
|
j = 0
|
|
|
|
unread = 0
|
|
|
|
for folder in folders:
|
2017-02-14 01:35:32 +01:00
|
|
|
if toAddress is not None and tab == 'messages' and folder == "new":
|
2015-11-27 00:56:25 +01:00
|
|
|
continue
|
2015-10-02 22:24:46 +02:00
|
|
|
subwidget = Ui_FolderWidget(widget, j, toAddress, folder, db[toAddress][folder])
|
2016-04-28 10:12:06 +02:00
|
|
|
if subwidget.folderName not in ["new", "trash", "sent"]:
|
|
|
|
unread += db[toAddress][folder]
|
2015-10-02 22:24:46 +02:00
|
|
|
j += 1
|
|
|
|
widget.setUnreadCount(unread)
|
|
|
|
i += 1
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-10-02 22:24:46 +02:00
|
|
|
treeWidget.setSortingEnabled(True)
|
2015-03-21 11:37:08 +01:00
|
|
|
|
2013-11-07 20:35:11 +01:00
|
|
|
def __init__(self, parent=None):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2013-11-07 20:35:11 +01:00
|
|
|
QtGui.QWidget.__init__(self, parent)
|
|
|
|
self.ui = Ui_MainWindow()
|
|
|
|
self.ui.setupUi(self)
|
|
|
|
|
|
|
|
# Ask the user if we may delete their old version 1 addresses if they
|
|
|
|
# have any.
|
2015-10-19 20:03:06 +02:00
|
|
|
for addressInKeysFile in getSortedAccounts():
|
2018-05-15 17:20:53 +02:00
|
|
|
status, addressVersionNumber, streamNumber, addressHash = decodeAddress(
|
2015-10-19 20:03:06 +02:00
|
|
|
addressInKeysFile)
|
|
|
|
if addressVersionNumber == 1:
|
|
|
|
displayMsg = _translate(
|
2018-05-15 17:20:53 +02:00
|
|
|
"MainWindow",
|
|
|
|
'One of your addresses, %1, is an old version 1 address. Version 1 addresses are no longer '
|
|
|
|
'supported. May we delete it now?').arg(addressInKeysFile)
|
2015-10-19 20:03:06 +02:00
|
|
|
reply = QtGui.QMessageBox.question(
|
|
|
|
self, 'Message', displayMsg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
|
|
|
|
if reply == QtGui.QMessageBox.Yes:
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().remove_section(addressInKeysFile)
|
2017-01-15 10:50:02 +01:00
|
|
|
BMConfigParser().save()
|
2013-11-07 20:35:11 +01:00
|
|
|
|
|
|
|
# Configure Bitmessage to start on startup (or remove the
|
|
|
|
# configuration) based on the setting in the keys.dat file
|
|
|
|
if 'win32' in sys.platform or 'win64' in sys.platform:
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2013-11-07 20:35:11 +01:00
|
|
|
# Auto-startup for Windows
|
|
|
|
RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"
|
2018-02-09 11:11:48 +01:00
|
|
|
self.settings = QtCore.QSettings(RUN_PATH, QtCore.QSettings.NativeFormat)
|
2018-05-15 17:20:53 +02:00
|
|
|
# In case the user moves the program and the registry entry is no longer
|
|
|
|
# valid, this will delete the old registry entry.
|
|
|
|
self.settings.remove("PyBitmessage")
|
2017-01-11 14:27:19 +01:00
|
|
|
if BMConfigParser().getboolean('bitmessagesettings', 'startonlogon'):
|
2013-11-07 20:35:11 +01:00
|
|
|
self.settings.setValue("PyBitmessage", sys.argv[0])
|
|
|
|
elif 'darwin' in sys.platform:
|
|
|
|
# startup for mac
|
|
|
|
pass
|
|
|
|
elif 'linux' in sys.platform:
|
|
|
|
# startup for linux
|
|
|
|
pass
|
|
|
|
|
2015-10-19 17:37:43 +02:00
|
|
|
# e.g. for editing labels
|
2015-10-04 20:32:17 +02:00
|
|
|
self.recurDepth = 0
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-10-19 17:37:43 +02:00
|
|
|
# switch back to this when replying
|
|
|
|
self.replyFromTab = None
|
2017-01-16 23:38:18 +01:00
|
|
|
|
|
|
|
# so that quit won't loop
|
|
|
|
self.quitAccepted = False
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2013-11-07 20:35:11 +01:00
|
|
|
self.init_file_menu()
|
|
|
|
self.init_inbox_popup_menu()
|
|
|
|
self.init_identities_popup_menu()
|
|
|
|
self.init_addressbook_popup_menu()
|
|
|
|
self.init_subscriptions_popup_menu()
|
2015-03-21 11:37:08 +01:00
|
|
|
self.init_chan_popup_menu()
|
2013-11-07 20:35:11 +01:00
|
|
|
self.init_sent_popup_menu()
|
2016-03-17 22:09:46 +01:00
|
|
|
|
2015-03-21 11:37:08 +01:00
|
|
|
# Initialize the user's list of addresses on the 'Chan' tab.
|
2015-03-23 22:35:56 +01:00
|
|
|
self.rerenderTabTreeChans()
|
2015-03-03 18:17:56 +01:00
|
|
|
|
2015-03-21 11:37:08 +01:00
|
|
|
# Initialize the user's list of addresses on the 'Messages' tab.
|
2015-03-23 22:35:56 +01:00
|
|
|
self.rerenderTabTreeMessages()
|
2015-03-03 18:17:56 +01:00
|
|
|
|
2015-03-21 11:37:08 +01:00
|
|
|
# Set welcome message
|
2017-03-05 22:07:18 +01:00
|
|
|
self.ui.textEditInboxMessage.setText(_translate("MainWindow", """
|
2015-03-21 11:37:08 +01:00
|
|
|
Welcome to easy and secure Bitmessage
|
2015-03-23 22:35:56 +01:00
|
|
|
* send messages to other people
|
2015-03-21 11:37:08 +01:00
|
|
|
* send broadcast messages like twitter or
|
2015-03-23 22:35:56 +01:00
|
|
|
* discuss in chan(nel)s with other people
|
2017-03-05 22:07:18 +01:00
|
|
|
"""))
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
# Initialize the address book
|
2013-09-05 12:31:52 +02:00
|
|
|
self.rerenderAddressBook()
|
2013-06-12 23:12:32 +02:00
|
|
|
|
|
|
|
# Initialize the Subscriptions
|
2013-05-24 22:12:16 +02:00
|
|
|
self.rerenderSubscriptions()
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-07-12 10:24:24 +02:00
|
|
|
# Initialize the inbox search
|
|
|
|
QtCore.QObject.connect(self.ui.inboxSearchLineEdit, QtCore.SIGNAL(
|
2016-03-01 08:23:51 +01:00
|
|
|
"returnPressed()"), self.inboxSearchLineEditReturnPressed)
|
2015-03-23 22:35:56 +01:00
|
|
|
QtCore.QObject.connect(self.ui.inboxSearchLineEditSubscriptions, QtCore.SIGNAL(
|
2016-03-01 08:23:51 +01:00
|
|
|
"returnPressed()"), self.inboxSearchLineEditReturnPressed)
|
2015-03-23 22:35:56 +01:00
|
|
|
QtCore.QObject.connect(self.ui.inboxSearchLineEditChans, QtCore.SIGNAL(
|
2016-03-01 08:23:51 +01:00
|
|
|
"returnPressed()"), self.inboxSearchLineEditReturnPressed)
|
|
|
|
QtCore.QObject.connect(self.ui.inboxSearchLineEdit, QtCore.SIGNAL(
|
|
|
|
"textChanged(QString)"), self.inboxSearchLineEditUpdated)
|
|
|
|
QtCore.QObject.connect(self.ui.inboxSearchLineEditSubscriptions, QtCore.SIGNAL(
|
|
|
|
"textChanged(QString)"), self.inboxSearchLineEditUpdated)
|
|
|
|
QtCore.QObject.connect(self.ui.inboxSearchLineEditChans, QtCore.SIGNAL(
|
|
|
|
"textChanged(QString)"), self.inboxSearchLineEditUpdated)
|
2013-07-12 10:24:24 +02:00
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
# Initialize addressbook
|
2013-06-12 23:12:32 +02:00
|
|
|
QtCore.QObject.connect(self.ui.tableWidgetAddressBook, QtCore.SIGNAL(
|
|
|
|
"itemChanged(QTableWidgetItem *)"), self.tableWidgetAddressBookItemChanged)
|
2016-04-29 02:03:48 +02:00
|
|
|
# This is necessary for the completer to work if multiple recipients
|
|
|
|
QtCore.QObject.connect(self.ui.lineEditTo, QtCore.SIGNAL(
|
|
|
|
"cursorPositionChanged(int, int)"), self.ui.lineEditTo.completer().onCursorPositionChanged)
|
2015-03-23 22:35:56 +01:00
|
|
|
|
|
|
|
# show messages from message list
|
2013-06-12 23:12:32 +02:00
|
|
|
QtCore.QObject.connect(self.ui.tableWidgetInbox, QtCore.SIGNAL(
|
|
|
|
"itemSelectionChanged ()"), self.tableWidgetInboxItemClicked)
|
2015-03-23 22:35:56 +01:00
|
|
|
QtCore.QObject.connect(self.ui.tableWidgetInboxSubscriptions, QtCore.SIGNAL(
|
|
|
|
"itemSelectionChanged ()"), self.tableWidgetInboxItemClicked)
|
|
|
|
QtCore.QObject.connect(self.ui.tableWidgetInboxChans, QtCore.SIGNAL(
|
|
|
|
"itemSelectionChanged ()"), self.tableWidgetInboxItemClicked)
|
|
|
|
|
|
|
|
# tree address lists
|
2015-03-21 11:37:08 +01:00
|
|
|
QtCore.QObject.connect(self.ui.treeWidgetYourIdentities, QtCore.SIGNAL(
|
2015-03-23 22:35:56 +01:00
|
|
|
"itemSelectionChanged ()"), self.treeWidgetItemClicked)
|
2015-10-04 10:47:51 +02:00
|
|
|
QtCore.QObject.connect(self.ui.treeWidgetYourIdentities, QtCore.SIGNAL(
|
|
|
|
"itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged)
|
2015-03-21 11:37:08 +01:00
|
|
|
QtCore.QObject.connect(self.ui.treeWidgetSubscriptions, QtCore.SIGNAL(
|
2015-03-23 22:35:56 +01:00
|
|
|
"itemSelectionChanged ()"), self.treeWidgetItemClicked)
|
2015-10-27 19:50:52 +01:00
|
|
|
QtCore.QObject.connect(self.ui.treeWidgetSubscriptions, QtCore.SIGNAL(
|
|
|
|
"itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged)
|
2015-03-23 22:35:56 +01:00
|
|
|
QtCore.QObject.connect(self.ui.treeWidgetChans, QtCore.SIGNAL(
|
|
|
|
"itemSelectionChanged ()"), self.treeWidgetItemClicked)
|
2015-10-27 19:50:52 +01:00
|
|
|
QtCore.QObject.connect(self.ui.treeWidgetChans, QtCore.SIGNAL(
|
|
|
|
"itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged)
|
2018-02-05 13:39:32 +01:00
|
|
|
QtCore.QObject.connect(
|
|
|
|
self.ui.tabWidget, QtCore.SIGNAL("currentChanged(int)"),
|
|
|
|
self.tabWidgetCurrentChanged
|
|
|
|
)
|
2013-06-12 23:12:32 +02:00
|
|
|
|
|
|
|
# Put the colored icon on the status bar
|
2016-03-16 18:04:18 +01:00
|
|
|
# self.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png"))
|
2016-12-15 16:11:29 +01:00
|
|
|
self.setStatusBar(BMStatusBar())
|
2013-05-02 17:53:54 +02:00
|
|
|
self.statusbar = self.statusBar()
|
2016-03-16 18:04:18 +01:00
|
|
|
|
|
|
|
self.pushButtonStatusIcon = QtGui.QPushButton(self)
|
|
|
|
self.pushButtonStatusIcon.setText('')
|
2018-01-22 17:52:28 +01:00
|
|
|
self.pushButtonStatusIcon.setIcon(
|
|
|
|
QtGui.QIcon(':/newPrefix/images/redicon.png'))
|
2016-03-16 18:04:18 +01:00
|
|
|
self.pushButtonStatusIcon.setFlat(True)
|
|
|
|
self.statusbar.insertPermanentWidget(0, self.pushButtonStatusIcon)
|
|
|
|
QtCore.QObject.connect(self.pushButtonStatusIcon, QtCore.SIGNAL(
|
|
|
|
"clicked()"), self.click_pushButtonStatusIcon)
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
self.numberOfMessagesProcessed = 0
|
|
|
|
self.numberOfBroadcastsProcessed = 0
|
|
|
|
self.numberOfPubkeysProcessed = 0
|
2015-10-31 15:27:07 +01:00
|
|
|
self.unreadCount = 0
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-08-27 11:47:14 +02:00
|
|
|
# Set the icon sizes for the identicons
|
2018-05-15 17:20:53 +02:00
|
|
|
identicon_size = 3 * 7
|
2013-08-27 11:47:14 +02:00
|
|
|
self.ui.tableWidgetInbox.setIconSize(QtCore.QSize(identicon_size, identicon_size))
|
2015-03-23 22:35:56 +01:00
|
|
|
self.ui.treeWidgetChans.setIconSize(QtCore.QSize(identicon_size, identicon_size))
|
2015-03-03 18:17:56 +01:00
|
|
|
self.ui.treeWidgetYourIdentities.setIconSize(QtCore.QSize(identicon_size, identicon_size))
|
2015-03-21 11:37:08 +01:00
|
|
|
self.ui.treeWidgetSubscriptions.setIconSize(QtCore.QSize(identicon_size, identicon_size))
|
2013-08-27 11:47:14 +02:00
|
|
|
self.ui.tableWidgetAddressBook.setIconSize(QtCore.QSize(identicon_size, identicon_size))
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2016-03-16 19:27:12 +01:00
|
|
|
self.UISignalThread = UISignaler.get()
|
2013-06-12 23:12:32 +02:00
|
|
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
|
|
|
"writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.writeNewAddressToTable)
|
|
|
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
|
|
|
"updateStatusBar(PyQt_PyObject)"), self.updateStatusBar)
|
|
|
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
2015-03-09 07:35:32 +01:00
|
|
|
"updateSentItemStatusByToAddress(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByToAddress)
|
2013-06-12 23:12:32 +02:00
|
|
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
|
|
|
"updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByAckdata)
|
2018-05-15 17:20:53 +02:00
|
|
|
QtCore.QObject.connect(
|
|
|
|
self.UISignalThread, QtCore.SIGNAL(
|
|
|
|
"displayNewInboxMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),
|
|
|
|
self.displayNewInboxMessage)
|
|
|
|
QtCore.QObject.connect(
|
|
|
|
self.UISignalThread, QtCore.SIGNAL(
|
|
|
|
("displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,"
|
|
|
|
"PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)")),
|
|
|
|
self.displayNewSentMessage)
|
2013-06-12 23:12:32 +02:00
|
|
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
|
|
|
"setStatusIcon(PyQt_PyObject)"), self.setStatusIcon)
|
2013-11-29 02:05:53 +01:00
|
|
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
|
|
|
"changedInboxUnread(PyQt_PyObject)"), self.changedInboxUnread)
|
2013-06-12 23:12:32 +02:00
|
|
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
2016-01-23 20:24:50 +01:00
|
|
|
"rerenderMessagelistFromLabels()"), self.rerenderMessagelistFromLabels)
|
2013-09-05 12:31:52 +02:00
|
|
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
2016-01-23 20:24:50 +01:00
|
|
|
"rerenderMessgelistToLabels()"), self.rerenderMessagelistToLabels)
|
2013-09-05 12:31:52 +02:00
|
|
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
|
|
|
"rerenderAddressBook()"), self.rerenderAddressBook)
|
2013-06-12 23:12:32 +02:00
|
|
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
|
|
|
"rerenderSubscriptions()"), self.rerenderSubscriptions)
|
|
|
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
|
|
|
"removeInboxRowByMsgid(PyQt_PyObject)"), self.removeInboxRowByMsgid)
|
2015-10-19 22:33:18 +02:00
|
|
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
|
|
|
"newVersionAvailable(PyQt_PyObject)"), self.newVersionAvailable)
|
2013-09-05 02:14:25 +02:00
|
|
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
|
|
|
"displayAlert(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.displayAlert)
|
2013-05-02 17:53:54 +02:00
|
|
|
self.UISignalThread.start()
|
|
|
|
|
2016-03-01 08:23:51 +01:00
|
|
|
# Key press in tree view
|
|
|
|
self.ui.treeWidgetYourIdentities.keyPressEvent = self.treeWidgetKeyPressEvent
|
|
|
|
self.ui.treeWidgetSubscriptions.keyPressEvent = self.treeWidgetKeyPressEvent
|
|
|
|
self.ui.treeWidgetChans.keyPressEvent = self.treeWidgetKeyPressEvent
|
|
|
|
|
|
|
|
# Key press in messagelist
|
|
|
|
self.ui.tableWidgetInbox.keyPressEvent = self.tableWidgetKeyPressEvent
|
|
|
|
self.ui.tableWidgetInboxSubscriptions.keyPressEvent = self.tableWidgetKeyPressEvent
|
|
|
|
self.ui.tableWidgetInboxChans.keyPressEvent = self.tableWidgetKeyPressEvent
|
|
|
|
|
|
|
|
# Key press in messageview
|
|
|
|
self.ui.textEditInboxMessage.keyPressEvent = self.textEditKeyPressEvent
|
|
|
|
self.ui.textEditInboxMessageSubscriptions.keyPressEvent = self.textEditKeyPressEvent
|
|
|
|
self.ui.textEditInboxMessageChans.keyPressEvent = self.textEditKeyPressEvent
|
|
|
|
|
2013-08-15 00:59:50 +02:00
|
|
|
# Below this point, it would be good if all of the necessary global data
|
|
|
|
# structures were initialized.
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-05-08 22:42:28 +02:00
|
|
|
self.rerenderComboBoxSendFrom()
|
2015-03-21 11:37:08 +01:00
|
|
|
self.rerenderComboBoxSendFromBroadcast()
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-03-03 20:04:12 +01:00
|
|
|
# Put the TTL slider in the correct spot
|
2017-01-11 14:27:19 +01:00
|
|
|
TTL = BMConfigParser().getint('bitmessagesettings', 'ttl')
|
2018-05-15 17:20:53 +02:00
|
|
|
if TTL < 3600: # an hour
|
2015-03-03 20:04:12 +01:00
|
|
|
TTL = 3600
|
2018-05-15 17:20:53 +02:00
|
|
|
elif TTL > 28 * 24 * 60 * 60: # 28 days
|
|
|
|
TTL = 28 * 24 * 60 * 60
|
|
|
|
self.ui.horizontalSliderTTL.setSliderPosition((TTL - 3600) ** (1 / 3.199))
|
2015-03-03 20:04:12 +01:00
|
|
|
self.updateHumanFriendlyTTLDescription(TTL)
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-03-03 20:04:12 +01:00
|
|
|
QtCore.QObject.connect(self.ui.horizontalSliderTTL, QtCore.SIGNAL(
|
|
|
|
"valueChanged(int)"), self.updateTTL)
|
2015-11-08 21:44:02 +01:00
|
|
|
|
|
|
|
self.initSettings()
|
2018-03-08 11:57:39 +01:00
|
|
|
|
|
|
|
self.namecoin = namecoinConnection()
|
|
|
|
|
|
|
|
# Check to see whether we can connect to namecoin.
|
|
|
|
# Hide the 'Fetch Namecoin ID' button if we can't.
|
|
|
|
if BMConfigParser().safeGetBoolean(
|
|
|
|
'bitmessagesettings', 'dontconnect'
|
2018-05-15 17:20:53 +02:00
|
|
|
) or self.namecoin.test()[0] == 'failed':
|
2018-03-08 11:57:39 +01:00
|
|
|
logger.warning(
|
|
|
|
'There was a problem testing for a Namecoin daemon. Hiding the'
|
|
|
|
' Fetch Namecoin ID button')
|
2015-03-21 11:37:08 +01:00
|
|
|
self.ui.pushButtonFetchNamecoinID.hide()
|
2018-03-08 11:57:39 +01:00
|
|
|
|
2015-03-19 18:44:10 +01:00
|
|
|
def updateTTL(self, sliderPosition):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-19 18:44:10 +01:00
|
|
|
TTL = int(sliderPosition ** 3.199 + 3600)
|
|
|
|
self.updateHumanFriendlyTTLDescription(TTL)
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'ttl', str(TTL))
|
2017-01-15 10:50:02 +01:00
|
|
|
BMConfigParser().save()
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-03-19 18:44:10 +01:00
|
|
|
def updateHumanFriendlyTTLDescription(self, TTL):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
|
|
|
numberOfHours = int(round(TTL / (60 * 60)))
|
2017-02-22 16:07:39 +01:00
|
|
|
font = QtGui.QFont()
|
|
|
|
stylesheet = ""
|
|
|
|
|
2015-03-19 18:44:10 +01:00
|
|
|
if numberOfHours < 48:
|
2017-02-22 16:07:39 +01:00
|
|
|
self.ui.labelHumanFriendlyTTLDescription.setText(
|
|
|
|
_translate("MainWindow", "%n hour(s)", None, QtCore.QCoreApplication.CodecForTr, numberOfHours) +
|
|
|
|
", " +
|
|
|
|
_translate("MainWindow", "not recommended for chans", None, QtCore.QCoreApplication.CodecForTr)
|
2018-05-15 17:20:53 +02:00
|
|
|
)
|
2017-02-22 16:07:39 +01:00
|
|
|
stylesheet = "QLabel { color : red; }"
|
|
|
|
font.setBold(True)
|
2015-03-19 18:44:10 +01:00
|
|
|
else:
|
2018-05-15 17:20:53 +02:00
|
|
|
numberOfDays = int(round(TTL / (24 * 60 * 60)))
|
|
|
|
self.ui.labelHumanFriendlyTTLDescription.setText(
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"%n day(s)",
|
|
|
|
None,
|
|
|
|
QtCore.QCoreApplication.CodecForTr,
|
|
|
|
numberOfDays))
|
2017-02-22 16:07:39 +01:00
|
|
|
font.setBold(False)
|
|
|
|
self.ui.labelHumanFriendlyTTLDescription.setStyleSheet(stylesheet)
|
|
|
|
self.ui.labelHumanFriendlyTTLDescription.setFont(font)
|
2013-07-24 17:46:28 +02:00
|
|
|
|
2013-05-08 22:42:28 +02:00
|
|
|
def appIndicatorShowOrHideWindow(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""
|
|
|
|
Show or hide the application window after clicking an item within the tray icon or, on Windows,
|
|
|
|
the try icon itself.
|
|
|
|
"""
|
|
|
|
|
2013-05-08 22:42:28 +02:00
|
|
|
if not self.actionShow.isChecked():
|
|
|
|
self.hide()
|
|
|
|
else:
|
2013-05-25 19:59:00 +02:00
|
|
|
self.show()
|
2013-06-12 23:12:32 +02:00
|
|
|
self.setWindowState(
|
|
|
|
self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive)
|
2015-12-16 21:41:44 +01:00
|
|
|
self.raise_()
|
2013-05-15 18:36:30 +02:00
|
|
|
self.activateWindow()
|
2013-05-07 23:22:34 +02:00
|
|
|
|
|
|
|
def appIndicatorShow(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""show the application window"""
|
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
if self.actionShow is None:
|
2013-05-07 23:22:34 +02:00
|
|
|
return
|
2013-05-14 17:44:51 +02:00
|
|
|
if not self.actionShow.isChecked():
|
|
|
|
self.actionShow.setChecked(True)
|
2015-12-16 21:41:44 +01:00
|
|
|
self.appIndicatorShowOrHideWindow()
|
2013-05-07 23:22:34 +02:00
|
|
|
|
2013-05-13 13:20:29 +02:00
|
|
|
def appIndicatorHide(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""unchecks the show item on the application indicator"""
|
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
if self.actionShow is None:
|
2013-05-13 13:20:29 +02:00
|
|
|
return
|
2013-05-14 17:44:51 +02:00
|
|
|
if self.actionShow.isChecked():
|
|
|
|
self.actionShow.setChecked(False)
|
|
|
|
self.appIndicatorShowOrHideWindow()
|
2013-05-13 13:20:29 +02:00
|
|
|
|
2017-10-11 23:26:14 +02:00
|
|
|
def appIndicatorSwitchQuietMode(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2017-10-11 23:26:14 +02:00
|
|
|
BMConfigParser().set(
|
|
|
|
'bitmessagesettings', 'showtraynotifications',
|
|
|
|
str(not self.actionQuiet.isChecked())
|
|
|
|
)
|
|
|
|
|
2017-03-23 18:04:56 +01:00
|
|
|
def appIndicatorInbox(self, item=None):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Show the program window and select inbox tab"""
|
|
|
|
|
2013-05-10 21:47:01 +02:00
|
|
|
self.appIndicatorShow()
|
2013-05-13 23:34:08 +02:00
|
|
|
# select inbox
|
2018-01-18 15:14:29 +01:00
|
|
|
self.ui.tabWidget.setCurrentIndex(
|
|
|
|
self.ui.tabWidget.indexOf(self.ui.inbox)
|
|
|
|
)
|
2017-03-23 18:04:56 +01:00
|
|
|
self.ui.treeWidgetYourIdentities.setCurrentItem(
|
|
|
|
self.ui.treeWidgetYourIdentities.topLevelItem(0).child(0)
|
|
|
|
)
|
|
|
|
|
|
|
|
if item:
|
|
|
|
self.ui.tableWidgetInbox.setCurrentItem(item)
|
2013-05-14 17:06:01 +02:00
|
|
|
self.tableWidgetInboxItemClicked()
|
|
|
|
else:
|
2013-06-12 23:12:32 +02:00
|
|
|
self.ui.tableWidgetInbox.setCurrentCell(0, 0)
|
2013-05-10 21:47:01 +02:00
|
|
|
|
2013-05-07 23:22:34 +02:00
|
|
|
def appIndicatorSend(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Show the program window and select send tab"""
|
2013-05-07 23:22:34 +02:00
|
|
|
self.appIndicatorShow()
|
2018-01-18 15:14:29 +01:00
|
|
|
self.ui.tabWidget.setCurrentIndex(
|
|
|
|
self.ui.tabWidget.indexOf(self.ui.send)
|
|
|
|
)
|
2013-05-07 23:22:34 +02:00
|
|
|
|
|
|
|
def appIndicatorSubscribe(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Show the program window and select subscriptions tab"""
|
|
|
|
|
2013-05-07 23:22:34 +02:00
|
|
|
self.appIndicatorShow()
|
2018-01-18 15:14:29 +01:00
|
|
|
self.ui.tabWidget.setCurrentIndex(
|
|
|
|
self.ui.tabWidget.indexOf(self.ui.subscriptions)
|
|
|
|
)
|
2013-05-07 23:22:34 +02:00
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
def appIndicatorChannel(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Show the program window and select channels tab"""
|
|
|
|
|
2013-05-07 23:22:34 +02:00
|
|
|
self.appIndicatorShow()
|
2018-01-18 15:14:29 +01:00
|
|
|
self.ui.tabWidget.setCurrentIndex(
|
|
|
|
self.ui.tabWidget.indexOf(self.ui.chans)
|
|
|
|
)
|
|
|
|
|
2018-02-06 14:48:56 +01:00
|
|
|
def updateUnreadStatus(self, widget, row, msgid, unread=True):
|
|
|
|
"""
|
|
|
|
Switch unread for item of msgid and related items in
|
|
|
|
other STableWidgets "All Accounts" and "Chans"
|
|
|
|
"""
|
|
|
|
related = [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxChans]
|
|
|
|
try:
|
|
|
|
related.remove(widget)
|
|
|
|
related = related.pop()
|
|
|
|
except ValueError:
|
|
|
|
rrow = None
|
|
|
|
related = []
|
|
|
|
else:
|
|
|
|
# maybe use instead:
|
|
|
|
# rrow = related.row(msgid), msgid should be QTableWidgetItem
|
|
|
|
# related = related.findItems(msgid, QtCore.Qt.MatchExactly),
|
|
|
|
# returns an empty list
|
|
|
|
for rrow in xrange(related.rowCount()):
|
|
|
|
if msgid == str(related.item(rrow, 3).data(
|
|
|
|
QtCore.Qt.UserRole).toPyObject()):
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
rrow = None
|
|
|
|
|
|
|
|
status = widget.item(row, 0).unread
|
|
|
|
if status == unread:
|
|
|
|
font = QtGui.QFont()
|
|
|
|
font.setBold(not status)
|
|
|
|
widget.item(row, 3).setFont(font)
|
|
|
|
for col in (0, 1, 2):
|
|
|
|
widget.item(row, col).setUnread(not status)
|
|
|
|
|
|
|
|
try:
|
|
|
|
related.item(rrow, 3).setFont(font)
|
|
|
|
except (TypeError, AttributeError):
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
for col in (0, 1, 2):
|
|
|
|
related.item(rrow, col).setUnread(not status)
|
|
|
|
|
2018-05-15 17:20:53 +02:00
|
|
|
def propagateUnreadCount(self, address=None, folder="inbox", widget=None, type_arg=1):
|
|
|
|
"""TBC"""
|
|
|
|
|
2015-11-27 02:11:24 +01:00
|
|
|
widgets = [self.ui.treeWidgetYourIdentities, self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans]
|
2018-05-15 17:20:53 +02:00
|
|
|
queryReturn = sqlQuery(
|
|
|
|
"SELECT toaddress, folder, COUNT(msgid) AS cnt FROM inbox WHERE read = 0 GROUP BY toaddress, folder")
|
2016-05-23 11:10:55 +02:00
|
|
|
totalUnread = {}
|
|
|
|
normalUnread = {}
|
|
|
|
for row in queryReturn:
|
|
|
|
normalUnread[row[0]] = {}
|
|
|
|
if row[1] in ["trash"]:
|
|
|
|
continue
|
|
|
|
normalUnread[row[0]][row[1]] = row[2]
|
|
|
|
if row[1] in totalUnread:
|
|
|
|
totalUnread[row[1]] += row[2]
|
|
|
|
else:
|
|
|
|
totalUnread[row[1]] = row[2]
|
2018-05-15 17:20:53 +02:00
|
|
|
queryReturn = sqlQuery(
|
|
|
|
"SELECT fromaddress, folder, COUNT(msgid) AS cnt FROM inbox "
|
|
|
|
"WHERE read = 0 AND toaddress = ? GROUP BY fromaddress, folder",
|
|
|
|
str_broadcast_subscribers)
|
2016-05-23 11:10:55 +02:00
|
|
|
broadcastsUnread = {}
|
|
|
|
for row in queryReturn:
|
|
|
|
broadcastsUnread[row[0]] = {}
|
|
|
|
broadcastsUnread[row[0]][row[1]] = row[2]
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-10-31 15:27:07 +01:00
|
|
|
for treeWidget in widgets:
|
|
|
|
root = treeWidget.invisibleRootItem()
|
|
|
|
for i in range(root.childCount()):
|
|
|
|
addressItem = root.child(i)
|
2016-05-23 11:10:55 +02:00
|
|
|
newCount = 0
|
|
|
|
if addressItem.type == AccountMixin.ALL:
|
|
|
|
newCount = sum(totalUnread.itervalues())
|
|
|
|
self.drawTrayIcon(self.currentTrayIconFileName, newCount)
|
|
|
|
elif addressItem.type == AccountMixin.SUBSCRIPTION:
|
|
|
|
if addressItem.address in broadcastsUnread:
|
|
|
|
newCount = sum(broadcastsUnread[addressItem.address].itervalues())
|
|
|
|
elif addressItem.address in normalUnread:
|
|
|
|
newCount = sum(normalUnread[addressItem.address].itervalues())
|
|
|
|
if newCount != addressItem.unreadCount:
|
|
|
|
addressItem.setUnreadCount(newCount)
|
2015-10-31 15:27:07 +01:00
|
|
|
if addressItem.childCount == 0:
|
|
|
|
continue
|
|
|
|
for j in range(addressItem.childCount()):
|
|
|
|
folderItem = addressItem.child(j)
|
2016-05-23 11:10:55 +02:00
|
|
|
newCount = 0
|
|
|
|
folderName = folderItem.folderName
|
|
|
|
if folderName == "new":
|
|
|
|
folderName = "inbox"
|
|
|
|
if addressItem.type == AccountMixin.ALL and folderName in totalUnread:
|
|
|
|
newCount = totalUnread[folderName]
|
|
|
|
elif addressItem.type == AccountMixin.SUBSCRIPTION:
|
2018-05-15 17:20:53 +02:00
|
|
|
if addressItem.address in broadcastsUnread and folderName in broadcastsUnread[
|
|
|
|
addressItem.address]:
|
2016-05-23 11:10:55 +02:00
|
|
|
newCount = broadcastsUnread[addressItem.address][folderName]
|
|
|
|
elif addressItem.address in normalUnread and folderName in normalUnread[addressItem.address]:
|
|
|
|
newCount = normalUnread[addressItem.address][folderName]
|
|
|
|
if newCount != folderItem.unreadCount:
|
|
|
|
folderItem.setUnreadCount(newCount)
|
2013-05-07 23:22:34 +02:00
|
|
|
|
2015-11-27 02:11:24 +01:00
|
|
|
def addMessageListItem(self, tableWidget, items):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2016-01-25 23:52:11 +01:00
|
|
|
sortingEnabled = tableWidget.isSortingEnabled()
|
|
|
|
if sortingEnabled:
|
|
|
|
tableWidget.setSortingEnabled(False)
|
2015-11-27 02:11:24 +01:00
|
|
|
tableWidget.insertRow(0)
|
2018-05-15 17:20:53 +02:00
|
|
|
for i, _ in enumerate(items):
|
2015-11-27 02:11:24 +01:00
|
|
|
tableWidget.setItem(0, i, items[i])
|
2016-01-25 23:52:11 +01:00
|
|
|
if sortingEnabled:
|
|
|
|
tableWidget.setSortingEnabled(True)
|
2015-11-27 02:11:24 +01:00
|
|
|
|
|
|
|
def addMessageListItemSent(self, tableWidget, toAddress, fromAddress, subject, status, ackdata, lastactiontime):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-11-27 02:11:24 +01:00
|
|
|
acct = accountClass(fromAddress)
|
2016-03-22 16:30:12 +01:00
|
|
|
if acct is None:
|
|
|
|
acct = BMAccount(fromAddress)
|
2015-11-27 02:11:24 +01:00
|
|
|
acct.parseMessage(toAddress, fromAddress, subject, "")
|
|
|
|
|
|
|
|
items = []
|
2015-12-21 21:08:28 +01:00
|
|
|
MessageList_AddressWidget(items, str(toAddress), unicode(acct.toLabel, 'utf-8'))
|
|
|
|
MessageList_AddressWidget(items, str(fromAddress), unicode(acct.fromLabel, 'utf-8'))
|
2016-01-04 15:43:24 +01:00
|
|
|
MessageList_SubjectWidget(items, str(subject), unicode(acct.subject, 'utf-8', 'replace'))
|
2015-11-27 02:11:24 +01:00
|
|
|
|
|
|
|
if status == 'awaitingpubkey':
|
|
|
|
statusText = _translate(
|
|
|
|
"MainWindow", "Waiting for their encryption key. Will request it again soon.")
|
|
|
|
elif status == 'doingpowforpubkey':
|
|
|
|
statusText = _translate(
|
2016-10-05 20:06:47 +02:00
|
|
|
"MainWindow", "Doing work necessary to request encryption key.")
|
2015-11-27 02:11:24 +01:00
|
|
|
elif status == 'msgqueued':
|
|
|
|
statusText = _translate(
|
|
|
|
"MainWindow", "Queued.")
|
|
|
|
elif status == 'msgsent':
|
|
|
|
statusText = _translate("MainWindow", "Message sent. Waiting for acknowledgement. Sent at %1").arg(
|
|
|
|
l10n.formatTimestamp(lastactiontime))
|
|
|
|
elif status == 'msgsentnoackexpected':
|
|
|
|
statusText = _translate("MainWindow", "Message sent. Sent at %1").arg(
|
|
|
|
l10n.formatTimestamp(lastactiontime))
|
|
|
|
elif status == 'doingmsgpow':
|
|
|
|
statusText = _translate(
|
2016-10-05 20:06:47 +02:00
|
|
|
"MainWindow", "Doing work necessary to send message.")
|
2015-11-27 02:11:24 +01:00
|
|
|
elif status == 'ackreceived':
|
|
|
|
statusText = _translate("MainWindow", "Acknowledgement of the message received %1").arg(
|
|
|
|
l10n.formatTimestamp(lastactiontime))
|
|
|
|
elif status == 'broadcastqueued':
|
|
|
|
statusText = _translate(
|
|
|
|
"MainWindow", "Broadcast queued.")
|
2016-10-05 20:06:47 +02:00
|
|
|
elif status == 'doingbroadcastpow':
|
|
|
|
statusText = _translate(
|
|
|
|
"MainWindow", "Doing work necessary to send broadcast.")
|
2015-11-27 02:11:24 +01:00
|
|
|
elif status == 'broadcastsent':
|
2018-05-15 17:20:53 +02:00
|
|
|
statusText = _translate(
|
|
|
|
"MainWindow", "Broadcast on %1").arg(
|
|
|
|
l10n.formatTimestamp(lastactiontime))
|
2015-11-27 02:11:24 +01:00
|
|
|
elif status == 'toodifficult':
|
2018-05-15 17:20:53 +02:00
|
|
|
statusText = _translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Problem: The work demanded by the recipient is more difficult than you are willing to do. %1").arg(
|
|
|
|
l10n.formatTimestamp(lastactiontime))
|
2015-11-27 02:11:24 +01:00
|
|
|
elif status == 'badkey':
|
2018-05-15 17:20:53 +02:00
|
|
|
statusText = _translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Problem: The recipient\'s encryption key is no good. Could not encrypt message. %1").arg(
|
|
|
|
l10n.formatTimestamp(lastactiontime))
|
2015-11-27 02:11:24 +01:00
|
|
|
elif status == 'forcepow':
|
|
|
|
statusText = _translate(
|
|
|
|
"MainWindow", "Forced difficulty override. Send should start soon.")
|
|
|
|
else:
|
|
|
|
statusText = _translate("MainWindow", "Unknown status: %1 %2").arg(status).arg(
|
|
|
|
l10n.formatTimestamp(lastactiontime))
|
|
|
|
newItem = myTableWidgetItem(statusText)
|
|
|
|
newItem.setToolTip(statusText)
|
2018-01-22 17:52:28 +01:00
|
|
|
newItem.setData(QtCore.Qt.UserRole, QtCore.QByteArray(ackdata))
|
2015-11-27 02:11:24 +01:00
|
|
|
newItem.setData(33, int(lastactiontime))
|
|
|
|
newItem.setFlags(
|
|
|
|
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
|
|
|
items.append(newItem)
|
|
|
|
self.addMessageListItem(tableWidget, items)
|
|
|
|
return acct
|
|
|
|
|
|
|
|
def addMessageListItemInbox(self, tableWidget, msgfolder, msgid, toAddress, fromAddress, subject, received, read):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2018-01-22 17:52:28 +01:00
|
|
|
font = QtGui.QFont()
|
2015-11-27 02:11:24 +01:00
|
|
|
font.setBold(True)
|
2016-01-23 10:14:12 +01:00
|
|
|
if toAddress == str_broadcast_subscribers:
|
2015-11-27 02:11:24 +01:00
|
|
|
acct = accountClass(fromAddress)
|
|
|
|
else:
|
|
|
|
acct = accountClass(toAddress)
|
2015-12-20 00:59:25 +01:00
|
|
|
if acct is None:
|
|
|
|
acct = accountClass(fromAddress)
|
|
|
|
if acct is None:
|
|
|
|
acct = BMAccount(fromAddress)
|
2015-11-27 02:11:24 +01:00
|
|
|
acct.parseMessage(toAddress, fromAddress, subject, "")
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-11-27 02:11:24 +01:00
|
|
|
items = []
|
2018-05-15 17:20:53 +02:00
|
|
|
# to
|
2015-12-21 21:08:28 +01:00
|
|
|
MessageList_AddressWidget(items, toAddress, unicode(acct.toLabel, 'utf-8'), not read)
|
2015-11-27 02:11:24 +01:00
|
|
|
# from
|
2015-12-21 21:08:28 +01:00
|
|
|
MessageList_AddressWidget(items, fromAddress, unicode(acct.fromLabel, 'utf-8'), not read)
|
2015-11-27 02:11:24 +01:00
|
|
|
# subject
|
2016-01-04 15:43:24 +01:00
|
|
|
MessageList_SubjectWidget(items, str(subject), unicode(acct.subject, 'utf-8', 'replace'), not read)
|
2015-11-27 02:11:24 +01:00
|
|
|
# time received
|
|
|
|
time_item = myTableWidgetItem(l10n.formatTimestamp(received))
|
|
|
|
time_item.setToolTip(l10n.formatTimestamp(received))
|
2018-01-22 17:52:28 +01:00
|
|
|
time_item.setData(QtCore.Qt.UserRole, QtCore.QByteArray(msgid))
|
2015-11-27 02:11:24 +01:00
|
|
|
time_item.setData(33, int(received))
|
|
|
|
time_item.setFlags(
|
|
|
|
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
|
|
|
if not read:
|
|
|
|
time_item.setFont(font)
|
|
|
|
items.append(time_item)
|
|
|
|
self.addMessageListItem(tableWidget, items)
|
|
|
|
return acct
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
def loadSent(self, tableWidget, account, where="", what=""):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Load Sent items from database"""
|
|
|
|
|
2016-03-12 09:58:16 +01:00
|
|
|
if tableWidget == self.ui.tableWidgetInboxSubscriptions:
|
2015-10-23 19:23:16 +02:00
|
|
|
tableWidget.setColumnHidden(0, True)
|
|
|
|
tableWidget.setColumnHidden(1, False)
|
2015-10-23 12:38:59 +02:00
|
|
|
xAddress = 'toaddress'
|
2016-03-12 09:58:16 +01:00
|
|
|
elif tableWidget == self.ui.tableWidgetInboxChans:
|
|
|
|
tableWidget.setColumnHidden(0, False)
|
|
|
|
tableWidget.setColumnHidden(1, True)
|
|
|
|
xAddress = 'both'
|
2015-10-23 12:38:59 +02:00
|
|
|
else:
|
2015-10-23 19:23:16 +02:00
|
|
|
tableWidget.setColumnHidden(0, False)
|
2016-03-16 18:30:47 +01:00
|
|
|
if account is None:
|
|
|
|
tableWidget.setColumnHidden(1, False)
|
|
|
|
else:
|
|
|
|
tableWidget.setColumnHidden(1, True)
|
2015-10-23 12:38:59 +02:00
|
|
|
xAddress = 'fromaddress'
|
2013-07-12 10:42:52 +02:00
|
|
|
|
2016-10-22 01:47:29 +02:00
|
|
|
tableWidget.setUpdatesEnabled(False)
|
2016-02-14 19:56:05 +01:00
|
|
|
tableWidget.setSortingEnabled(False)
|
2015-11-01 10:09:04 +01:00
|
|
|
tableWidget.setRowCount(0)
|
2016-02-14 19:56:05 +01:00
|
|
|
queryreturn = helper_search.search_sql(xAddress, account, "sent", where, what, False)
|
|
|
|
|
2013-07-12 10:24:24 +02:00
|
|
|
for row in queryreturn:
|
2013-10-13 19:45:30 +02:00
|
|
|
toAddress, fromAddress, subject, status, ackdata, lastactiontime = row
|
2015-11-27 02:11:24 +01:00
|
|
|
self.addMessageListItemSent(tableWidget, toAddress, fromAddress, subject, status, ackdata, lastactiontime)
|
2015-10-03 12:12:18 +02:00
|
|
|
|
2018-01-22 17:52:28 +01:00
|
|
|
tableWidget.horizontalHeader().setSortIndicator(
|
|
|
|
3, QtCore.Qt.DescendingOrder)
|
2017-02-14 01:35:32 +01:00
|
|
|
tableWidget.setSortingEnabled(True)
|
2016-04-29 21:07:08 +02:00
|
|
|
tableWidget.horizontalHeaderItem(3).setText(_translate("MainWindow", "Sent", None))
|
2016-10-22 01:47:29 +02:00
|
|
|
tableWidget.setUpdatesEnabled(True)
|
2013-07-12 10:24:24 +02:00
|
|
|
|
2018-05-15 17:20:53 +02:00
|
|
|
def loadMessagelist(self, tableWidget, account, folder="inbox", where="", what="", unreadOnly=False):
|
|
|
|
"""Load messages from database file"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
if folder == 'sent':
|
|
|
|
self.loadSent(tableWidget, account, where, what)
|
|
|
|
return
|
|
|
|
|
2015-10-10 19:58:01 +02:00
|
|
|
if tableWidget == self.ui.tableWidgetInboxSubscriptions:
|
|
|
|
xAddress = "fromaddress"
|
|
|
|
else:
|
|
|
|
xAddress = "toaddress"
|
2015-11-27 00:56:25 +01:00
|
|
|
if account is not None:
|
|
|
|
tableWidget.setColumnHidden(0, True)
|
|
|
|
tableWidget.setColumnHidden(1, False)
|
|
|
|
else:
|
|
|
|
tableWidget.setColumnHidden(0, False)
|
|
|
|
tableWidget.setColumnHidden(1, False)
|
2016-02-14 19:56:05 +01:00
|
|
|
|
2016-10-22 01:47:29 +02:00
|
|
|
tableWidget.setUpdatesEnabled(False)
|
2015-10-03 12:12:18 +02:00
|
|
|
tableWidget.setSortingEnabled(False)
|
2016-02-14 19:56:05 +01:00
|
|
|
tableWidget.setRowCount(0)
|
|
|
|
|
|
|
|
queryreturn = helper_search.search_sql(xAddress, account, folder, where, what, unreadOnly)
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-03-19 18:25:50 +01:00
|
|
|
for row in queryreturn:
|
2015-10-03 12:12:18 +02:00
|
|
|
msgfolder, msgid, toAddress, fromAddress, subject, received, read = row
|
2018-05-15 17:20:53 +02:00
|
|
|
self.addMessageListItemInbox(tableWidget, msgfolder, msgid, toAddress,
|
|
|
|
fromAddress, subject, received, read)
|
2015-03-19 18:25:50 +01:00
|
|
|
|
2018-01-22 17:52:28 +01:00
|
|
|
tableWidget.horizontalHeader().setSortIndicator(
|
|
|
|
3, QtCore.Qt.DescendingOrder)
|
2015-10-03 12:12:18 +02:00
|
|
|
tableWidget.setSortingEnabled(True)
|
2016-03-01 08:23:51 +01:00
|
|
|
tableWidget.selectRow(0)
|
2016-04-29 21:07:08 +02:00
|
|
|
tableWidget.horizontalHeaderItem(3).setText(_translate("MainWindow", "Received", None))
|
2016-10-22 01:47:29 +02:00
|
|
|
tableWidget.setUpdatesEnabled(True)
|
2015-03-19 18:25:50 +01:00
|
|
|
|
2018-05-15 17:20:53 +02:00
|
|
|
def appIndicatorInit(self, this_app):
|
|
|
|
"""create application indicator"""
|
|
|
|
|
|
|
|
self.initTrayIcon("can-icon-24px-red.png", this_app)
|
2015-02-21 14:24:17 +01:00
|
|
|
traySignal = "activated(QSystemTrayIcon::ActivationReason)"
|
|
|
|
QtCore.QObject.connect(self.tray, QtCore.SIGNAL(
|
|
|
|
traySignal), self.__icon_activated)
|
2013-05-14 17:44:51 +02:00
|
|
|
|
2018-01-22 17:52:28 +01:00
|
|
|
m = QtGui.QMenu()
|
2013-05-07 23:22:34 +02:00
|
|
|
|
2013-06-13 09:59:40 +02:00
|
|
|
self.actionStatus = QtGui.QAction(_translate(
|
2013-06-12 23:12:32 +02:00
|
|
|
"MainWindow", "Not Connected"), m, checkable=False)
|
2013-05-07 23:22:34 +02:00
|
|
|
m.addAction(self.actionStatus)
|
|
|
|
|
2013-05-07 23:58:47 +02:00
|
|
|
# separator
|
2013-06-12 23:12:32 +02:00
|
|
|
actionSeparator = QtGui.QAction('', m, checkable=False)
|
2013-05-07 23:58:47 +02:00
|
|
|
actionSeparator.setSeparator(True)
|
|
|
|
m.addAction(actionSeparator)
|
|
|
|
|
2013-05-07 23:22:34 +02:00
|
|
|
# show bitmessage
|
2013-06-13 09:59:40 +02:00
|
|
|
self.actionShow = QtGui.QAction(_translate(
|
2013-06-12 23:12:32 +02:00
|
|
|
"MainWindow", "Show Bitmessage"), m, checkable=True)
|
2017-01-11 14:27:19 +01:00
|
|
|
self.actionShow.setChecked(not BMConfigParser().getboolean(
|
2013-06-12 23:12:32 +02:00
|
|
|
'bitmessagesettings', 'startintray'))
|
2013-05-08 22:42:28 +02:00
|
|
|
self.actionShow.triggered.connect(self.appIndicatorShowOrHideWindow)
|
2018-05-15 17:20:53 +02:00
|
|
|
if sys.platform[0:3] != 'win':
|
2013-06-12 23:12:32 +02:00
|
|
|
m.addAction(self.actionShow)
|
2013-05-07 23:22:34 +02:00
|
|
|
|
2017-10-11 23:26:14 +02:00
|
|
|
# quiet mode
|
|
|
|
self.actionQuiet = QtGui.QAction(_translate(
|
|
|
|
"MainWindow", "Quiet Mode"), m, checkable=True)
|
|
|
|
self.actionQuiet.setChecked(not BMConfigParser().getboolean(
|
|
|
|
'bitmessagesettings', 'showtraynotifications'))
|
|
|
|
self.actionQuiet.triggered.connect(self.appIndicatorSwitchQuietMode)
|
|
|
|
m.addAction(self.actionQuiet)
|
|
|
|
|
2013-05-07 23:22:34 +02:00
|
|
|
# Send
|
2013-06-13 09:59:40 +02:00
|
|
|
actionSend = QtGui.QAction(_translate(
|
2013-06-12 23:12:32 +02:00
|
|
|
"MainWindow", "Send"), m, checkable=False)
|
2013-05-07 23:22:34 +02:00
|
|
|
actionSend.triggered.connect(self.appIndicatorSend)
|
|
|
|
m.addAction(actionSend)
|
|
|
|
|
|
|
|
# Subscribe
|
2013-06-13 09:59:40 +02:00
|
|
|
actionSubscribe = QtGui.QAction(_translate(
|
2013-06-12 23:12:32 +02:00
|
|
|
"MainWindow", "Subscribe"), m, checkable=False)
|
2013-05-07 23:22:34 +02:00
|
|
|
actionSubscribe.triggered.connect(self.appIndicatorSubscribe)
|
|
|
|
m.addAction(actionSubscribe)
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
# Channels
|
2015-03-03 18:17:56 +01:00
|
|
|
actionSubscribe = QtGui.QAction(_translate(
|
2015-03-23 22:35:56 +01:00
|
|
|
"MainWindow", "Channel"), m, checkable=False)
|
|
|
|
actionSubscribe.triggered.connect(self.appIndicatorChannel)
|
2015-03-03 18:17:56 +01:00
|
|
|
m.addAction(actionSubscribe)
|
2013-05-07 23:22:34 +02:00
|
|
|
|
2013-05-07 23:58:47 +02:00
|
|
|
# separator
|
2013-06-12 23:12:32 +02:00
|
|
|
actionSeparator = QtGui.QAction('', m, checkable=False)
|
2013-05-07 23:58:47 +02:00
|
|
|
actionSeparator.setSeparator(True)
|
|
|
|
m.addAction(actionSeparator)
|
|
|
|
|
|
|
|
# Quit
|
2013-06-13 09:59:40 +02:00
|
|
|
m.addAction(_translate(
|
2013-06-12 23:12:32 +02:00
|
|
|
"MainWindow", "Quit"), self.quit)
|
2013-05-14 17:44:51 +02:00
|
|
|
|
2013-05-08 22:42:28 +02:00
|
|
|
self.tray.setContextMenu(m)
|
|
|
|
self.tray.show()
|
2013-05-07 23:22:34 +02:00
|
|
|
|
2013-05-10 21:47:01 +02:00
|
|
|
def getUnread(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""returns the number of unread messages and subscriptions"""
|
|
|
|
|
2017-03-23 18:04:56 +01:00
|
|
|
counters = [0, 0]
|
2013-05-10 21:47:01 +02:00
|
|
|
|
2017-03-23 18:04:56 +01:00
|
|
|
queryreturn = sqlQuery('''
|
|
|
|
SELECT msgid, toaddress, read FROM inbox where folder='inbox'
|
|
|
|
''')
|
|
|
|
for msgid, toAddress, read in queryreturn:
|
2013-05-10 21:47:01 +02:00
|
|
|
|
|
|
|
if not read:
|
2017-03-23 18:04:56 +01:00
|
|
|
# increment the unread subscriptions if True (1)
|
|
|
|
# else messages (0)
|
|
|
|
counters[toAddress == str_broadcast_subscribers] += 1
|
2013-05-10 21:47:01 +02:00
|
|
|
|
2017-03-23 18:04:56 +01:00
|
|
|
return counters
|
2013-05-10 21:47:01 +02:00
|
|
|
|
2018-05-15 17:20:53 +02:00
|
|
|
def playSound(self, category, label): # pylint: disable=inconsistent-return-statements
|
|
|
|
"""play a sound"""
|
|
|
|
|
2013-08-01 15:48:01 +02:00
|
|
|
# filename of the sound to be played
|
2013-07-15 18:01:12 +02:00
|
|
|
soundFilename = None
|
2013-08-01 15:48:01 +02:00
|
|
|
|
2018-05-15 17:20:53 +02:00
|
|
|
def _choose_ext(basename): # pylint: disable=inconsistent-return-statements
|
|
|
|
"""TBC"""
|
|
|
|
|
2017-09-04 15:06:48 +02:00
|
|
|
for ext in sound.extensions:
|
|
|
|
if os.path.isfile(os.extsep.join([basename, ext])):
|
|
|
|
return os.extsep + ext
|
2013-07-15 18:01:12 +02:00
|
|
|
|
2013-08-01 15:48:01 +02:00
|
|
|
# if the address had a known label in the address book
|
2017-03-10 00:00:54 +01:00
|
|
|
if label:
|
2013-07-31 23:25:34 +02:00
|
|
|
# Does a sound file exist for this particular contact?
|
2017-03-10 00:00:54 +01:00
|
|
|
soundFilename = state.appdata + 'sounds/' + label
|
|
|
|
ext = _choose_ext(soundFilename)
|
|
|
|
if not ext:
|
2017-03-15 14:56:47 +01:00
|
|
|
category = sound.SOUND_KNOWN
|
2017-03-10 00:00:54 +01:00
|
|
|
soundFilename = None
|
2013-07-31 23:25:34 +02:00
|
|
|
|
2013-07-15 18:01:12 +02:00
|
|
|
if soundFilename is None:
|
2017-03-10 00:00:54 +01:00
|
|
|
# Avoid making sounds more frequently than the threshold.
|
|
|
|
# This suppresses playing sounds repeatedly when there
|
|
|
|
# are many new messages
|
2017-03-15 14:56:47 +01:00
|
|
|
if not sound.is_connection_sound(category):
|
2017-03-10 00:00:54 +01:00
|
|
|
# elapsed time since the last sound was played
|
|
|
|
dt = datetime.now() - self.lastSoundTime
|
|
|
|
# suppress sounds which are more frequent than the threshold
|
2018-05-15 17:20:53 +02:00
|
|
|
if not dt.total_seconds() < self.maxSoundFrequencySec:
|
|
|
|
|
|
|
|
# the sound is for an address which exists in the address book
|
|
|
|
if category is sound.SOUND_KNOWN:
|
|
|
|
soundFilename = state.appdata + 'sounds/known'
|
|
|
|
# the sound is for an unknown address
|
|
|
|
elif category is sound.SOUND_UNKNOWN:
|
|
|
|
soundFilename = state.appdata + 'sounds/unknown'
|
|
|
|
# initial connection sound
|
|
|
|
elif category is sound.SOUND_CONNECTED:
|
|
|
|
soundFilename = state.appdata + 'sounds/connected'
|
|
|
|
# disconnected sound
|
|
|
|
elif category is sound.SOUND_DISCONNECTED:
|
|
|
|
soundFilename = state.appdata + 'sounds/disconnected'
|
|
|
|
# sound when the connection status becomes green
|
|
|
|
elif category is sound.SOUND_CONNECTION_GREEN:
|
|
|
|
soundFilename = state.appdata + 'sounds/green'
|
2013-07-15 18:01:12 +02:00
|
|
|
|
2017-03-10 00:00:54 +01:00
|
|
|
if soundFilename is None:
|
2017-03-11 12:40:33 +01:00
|
|
|
logger.warning("Probably wrong category number in playSound()")
|
2017-03-10 00:00:54 +01:00
|
|
|
return
|
2013-08-01 10:58:30 +02:00
|
|
|
|
2017-03-15 14:56:47 +01:00
|
|
|
if not sound.is_connection_sound(category):
|
2017-03-10 00:00:54 +01:00
|
|
|
# record the last time that a received message sound was played
|
|
|
|
self.lastSoundTime = datetime.now()
|
2013-07-15 18:01:12 +02:00
|
|
|
|
2017-03-10 00:00:54 +01:00
|
|
|
try: # try already known format
|
|
|
|
soundFilename += ext
|
|
|
|
except (TypeError, NameError):
|
|
|
|
ext = _choose_ext(soundFilename)
|
|
|
|
if not ext:
|
2017-03-11 12:40:33 +01:00
|
|
|
try: # if no user sound file found try to play from theme
|
|
|
|
return self._theme_player(category, label)
|
|
|
|
except TypeError:
|
|
|
|
return
|
2017-03-10 00:00:54 +01:00
|
|
|
|
|
|
|
soundFilename += ext
|
|
|
|
|
|
|
|
self._player(soundFilename)
|
2013-07-15 18:01:12 +02:00
|
|
|
|
2018-02-06 23:55:41 +01:00
|
|
|
def sqlInit(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Adapters and converters for QT <-> sqlite"""
|
|
|
|
|
2018-02-06 23:55:41 +01:00
|
|
|
register_adapter(QtCore.QByteArray, str)
|
|
|
|
|
2017-03-23 18:04:56 +01:00
|
|
|
def indicatorInit(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
""" Try init the distro specific appindicator, for example the Ubuntu MessagingMenu"""
|
|
|
|
|
2017-03-23 18:04:56 +01:00
|
|
|
def _noop_update(*args, **kwargs):
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
|
|
|
self.indicatorUpdate = get_plugin('indicator')(self)
|
|
|
|
except (NameError, TypeError):
|
2017-12-02 00:45:01 +01:00
|
|
|
logger.warning("No indicator plugin found")
|
2017-03-23 18:04:56 +01:00
|
|
|
self.indicatorUpdate = _noop_update
|
|
|
|
|
2013-05-11 18:33:16 +02:00
|
|
|
def notifierInit(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""initialise the message notifier"""
|
|
|
|
|
2017-03-10 00:00:54 +01:00
|
|
|
def _simple_notify(
|
|
|
|
title, subtitle, category, label=None, icon=None):
|
|
|
|
self.tray.showMessage(title, subtitle, 1, 2000)
|
2013-05-11 18:33:16 +02:00
|
|
|
|
2017-03-10 00:00:54 +01:00
|
|
|
self._notifier = _simple_notify
|
2017-03-10 15:45:46 +01:00
|
|
|
# does nothing if isAvailable returns false
|
2017-03-10 00:00:54 +01:00
|
|
|
self._player = QtGui.QSound.play
|
2013-07-15 18:01:12 +02:00
|
|
|
|
2017-03-10 00:00:54 +01:00
|
|
|
if not get_plugins:
|
2013-05-11 18:33:16 +02:00
|
|
|
return
|
2017-03-10 00:00:54 +01:00
|
|
|
|
2017-03-10 15:45:46 +01:00
|
|
|
_plugin = get_plugin('notification.message')
|
|
|
|
if _plugin:
|
|
|
|
self._notifier = _plugin
|
2017-03-11 12:40:33 +01:00
|
|
|
else:
|
|
|
|
logger.warning("No notification.message plugin found")
|
|
|
|
|
|
|
|
self._theme_player = get_plugin('notification.sound', 'theme')
|
2017-03-10 00:00:54 +01:00
|
|
|
|
|
|
|
if not QtGui.QSound.isAvailable():
|
2017-03-10 15:45:46 +01:00
|
|
|
_plugin = get_plugin(
|
|
|
|
'notification.sound', 'file', fallback='file.fallback')
|
|
|
|
if _plugin:
|
|
|
|
self._player = _plugin
|
2017-03-10 00:00:54 +01:00
|
|
|
else:
|
2017-03-11 12:40:33 +01:00
|
|
|
logger.warning("No notification.sound plugin found")
|
2017-03-10 00:00:54 +01:00
|
|
|
|
|
|
|
def notifierShow(
|
|
|
|
self, title, subtitle, category, label=None, icon=None):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2017-03-10 00:00:54 +01:00
|
|
|
self.playSound(category, label)
|
|
|
|
self._notifier(
|
|
|
|
unicode(title), unicode(subtitle), category, label, icon)
|
2013-05-11 18:33:16 +02:00
|
|
|
|
2016-03-01 08:23:51 +01:00
|
|
|
def treeWidgetKeyPressEvent(self, event):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""tree"""
|
|
|
|
|
2016-03-01 08:23:51 +01:00
|
|
|
return self.handleKeyPress(event, self.getCurrentTreeWidget())
|
|
|
|
|
|
|
|
def tableWidgetKeyPressEvent(self, event):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""inbox / sent"""
|
|
|
|
|
2016-03-01 08:23:51 +01:00
|
|
|
return self.handleKeyPress(event, self.getCurrentMessagelist())
|
|
|
|
|
|
|
|
def textEditKeyPressEvent(self, event):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""messageview"""
|
|
|
|
|
2016-03-01 08:23:51 +01:00
|
|
|
return self.handleKeyPress(event, self.getCurrentMessageTextedit())
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2018-05-15 17:20:53 +02:00
|
|
|
def handleKeyPress(self, event, focus=None): # pylint: disable=inconsistent-return-statements
|
|
|
|
"""TBC"""
|
|
|
|
|
2016-03-01 08:23:51 +01:00
|
|
|
messagelist = self.getCurrentMessagelist()
|
|
|
|
folder = self.getCurrentFolder()
|
2015-11-19 17:37:34 +01:00
|
|
|
if event.key() == QtCore.Qt.Key_Delete:
|
2018-05-15 17:20:53 +02:00
|
|
|
if isinstance(focus, (MessageView, QtGui.QTableWidget)):
|
2016-03-01 08:23:51 +01:00
|
|
|
if folder == "sent":
|
|
|
|
self.on_action_SentTrash()
|
|
|
|
else:
|
|
|
|
self.on_action_InboxTrash()
|
|
|
|
event.ignore()
|
2016-03-16 18:42:08 +01:00
|
|
|
elif QtGui.QApplication.queryKeyboardModifiers() == QtCore.Qt.NoModifier:
|
|
|
|
if event.key() == QtCore.Qt.Key_N:
|
|
|
|
currentRow = messagelist.currentRow()
|
|
|
|
if currentRow < messagelist.rowCount() - 1:
|
|
|
|
messagelist.selectRow(currentRow + 1)
|
|
|
|
event.ignore()
|
|
|
|
elif event.key() == QtCore.Qt.Key_P:
|
|
|
|
currentRow = messagelist.currentRow()
|
|
|
|
if currentRow > 0:
|
|
|
|
messagelist.selectRow(currentRow - 1)
|
|
|
|
event.ignore()
|
|
|
|
elif event.key() == QtCore.Qt.Key_R:
|
|
|
|
if messagelist == self.ui.tableWidgetInboxChans:
|
|
|
|
self.on_action_InboxReplyChan()
|
|
|
|
else:
|
|
|
|
self.on_action_InboxReply()
|
|
|
|
event.ignore()
|
|
|
|
elif event.key() == QtCore.Qt.Key_C:
|
|
|
|
currentAddress = self.getCurrentAccount()
|
|
|
|
if currentAddress:
|
|
|
|
self.setSendFromComboBox(currentAddress)
|
2018-01-18 15:14:29 +01:00
|
|
|
self.ui.tabWidgetSend.setCurrentIndex(
|
|
|
|
self.ui.tabWidgetSend.indexOf(self.ui.sendDirect)
|
|
|
|
)
|
|
|
|
self.ui.tabWidget.setCurrentIndex(
|
|
|
|
self.ui.tabWidget.indexOf(self.ui.send)
|
|
|
|
)
|
2016-03-16 18:42:08 +01:00
|
|
|
self.ui.lineEditTo.setFocus()
|
|
|
|
event.ignore()
|
|
|
|
elif event.key() == QtCore.Qt.Key_F:
|
2018-05-15 17:20:53 +02:00
|
|
|
searchline = self.getCurrentSearchLine(retObj=True)
|
2016-03-16 18:42:08 +01:00
|
|
|
if searchline:
|
|
|
|
searchline.setFocus()
|
|
|
|
event.ignore()
|
2016-03-01 08:23:51 +01:00
|
|
|
if not event.isAccepted():
|
|
|
|
return
|
2018-05-15 17:20:53 +02:00
|
|
|
if isinstance(focus, MessageView):
|
2016-03-01 08:23:51 +01:00
|
|
|
return MessageView.keyPressEvent(focus, event)
|
2018-05-15 17:20:53 +02:00
|
|
|
elif isinstance(focus, QtGui.QTableWidget):
|
2016-03-01 08:23:51 +01:00
|
|
|
return QtGui.QTableWidget.keyPressEvent(focus, event)
|
2018-05-15 17:20:53 +02:00
|
|
|
elif isinstance(focus, QtGui.QTreeWidget):
|
2016-03-01 08:23:51 +01:00
|
|
|
return QtGui.QTreeWidget.keyPressEvent(focus, event)
|
2015-11-19 17:37:34 +01:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def click_actionManageKeys(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""menu button 'manage keys'"""
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
if 'darwin' in sys.platform or 'linux' in sys.platform:
|
2017-01-11 17:00:00 +01:00
|
|
|
if state.appdata == '':
|
2013-06-12 23:12:32 +02:00
|
|
|
# reply = QtGui.QMessageBox.information(self, 'keys.dat?','You
|
|
|
|
# may manage your keys by editing the keys.dat file stored in
|
|
|
|
# the same directory as this program. It is important that you
|
|
|
|
# back up this file.', QMessageBox.Ok)
|
2018-05-15 17:20:53 +02:00
|
|
|
reply = QtGui.QMessageBox.information(
|
|
|
|
self,
|
|
|
|
'keys.dat?',
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
("You may manage your keys by editing the keys.dat file stored in the same directory as this "
|
|
|
|
"program. It is important that you back up this file.")),
|
|
|
|
QtGui.QMessageBox.Ok)
|
2013-06-12 14:22:04 +02:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
else:
|
2018-05-15 17:20:53 +02:00
|
|
|
QtGui.QMessageBox.information(
|
|
|
|
self,
|
|
|
|
'keys.dat?',
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
("You may manage your keys by editing the keys.dat file stored in\n %1 \nIt is important "
|
|
|
|
"that you back up this file.")).arg(
|
|
|
|
state.appdata),
|
|
|
|
QtGui.QMessageBox.Ok)
|
2013-05-02 17:53:54 +02:00
|
|
|
elif sys.platform == 'win32' or sys.platform == 'win64':
|
2017-01-11 17:00:00 +01:00
|
|
|
if state.appdata == '':
|
2018-05-15 17:20:53 +02:00
|
|
|
reply = QtGui.QMessageBox.question(
|
|
|
|
self,
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Open keys.dat?"),
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
("You may manage your keys by editing the keys.dat file stored in the same directory as this "
|
|
|
|
"program. It is important that you back up this file. Would you like to open the file now? "
|
|
|
|
"(Be sure to close Bitmessage before making any changes.)")),
|
|
|
|
QtGui.QMessageBox.Yes,
|
|
|
|
QtGui.QMessageBox.No)
|
2013-05-02 17:53:54 +02:00
|
|
|
else:
|
2018-05-15 17:20:53 +02:00
|
|
|
reply = QtGui.QMessageBox.question(
|
|
|
|
self,
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Open keys.dat?"),
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
("You may manage your keys by editing the keys.dat file stored in\n %1 \nIt is important "
|
|
|
|
"that you back up this file. Would you like to open the file now? (Be sure to close "
|
|
|
|
"Bitmessage before making any changes.)")).arg(
|
|
|
|
state.appdata),
|
|
|
|
QtGui.QMessageBox.Yes,
|
|
|
|
QtGui.QMessageBox.No)
|
2013-05-02 17:53:54 +02:00
|
|
|
if reply == QtGui.QMessageBox.Yes:
|
2014-09-15 08:34:33 +02:00
|
|
|
shared.openKeysFile()
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-05-28 22:50:09 +02:00
|
|
|
def click_actionDeleteAllTrashedMessages(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""menu button 'delete all treshed messages'"""
|
|
|
|
|
|
|
|
if QtGui.QMessageBox.question(
|
|
|
|
self,
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Delete trash?"),
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Are you sure you want to delete all trashed messages?"),
|
|
|
|
QtGui.QMessageBox.Yes,
|
|
|
|
QtGui.QMessageBox.No) == QtGui.QMessageBox.No:
|
2013-05-28 22:50:09 +02:00
|
|
|
return
|
2013-08-27 02:01:19 +02:00
|
|
|
sqlStoredProcedure('deleteandvacuume')
|
2015-11-01 09:02:20 +01:00
|
|
|
self.rerenderTabTreeMessages()
|
|
|
|
self.rerenderTabTreeSubscriptions()
|
|
|
|
self.rerenderTabTreeChans()
|
|
|
|
if self.getCurrentFolder(self.ui.treeWidgetYourIdentities) == "trash":
|
2018-05-15 17:20:53 +02:00
|
|
|
self.loadMessagelist(
|
|
|
|
self.ui.tableWidgetInbox, self.getCurrentAccount(
|
|
|
|
self.ui.treeWidgetYourIdentities), "trash")
|
2015-11-01 09:02:20 +01:00
|
|
|
elif self.getCurrentFolder(self.ui.treeWidgetSubscriptions) == "trash":
|
2018-05-15 17:20:53 +02:00
|
|
|
self.loadMessagelist(
|
|
|
|
self.ui.tableWidgetInboxSubscriptions,
|
|
|
|
self.getCurrentAccount(
|
|
|
|
self.ui.treeWidgetSubscriptions),
|
|
|
|
"trash")
|
2015-11-01 09:02:20 +01:00
|
|
|
elif self.getCurrentFolder(self.ui.treeWidgetChans) == "trash":
|
2018-05-15 17:20:53 +02:00
|
|
|
self.loadMessagelist(
|
|
|
|
self.ui.tableWidgetInboxChans,
|
|
|
|
self.getCurrentAccount(
|
|
|
|
self.ui.treeWidgetChans),
|
|
|
|
"trash")
|
2015-11-01 09:02:20 +01:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def click_actionRegenerateDeterministicAddresses(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""menu button 'regenerate deterministic addresses'"""
|
|
|
|
|
2018-01-18 17:47:09 +01:00
|
|
|
dialog = dialogs.RegenerateAddressesDialog(self)
|
|
|
|
if dialog.exec_():
|
|
|
|
if dialog.lineEditPassphrase.text() == "":
|
2018-01-22 17:52:28 +01:00
|
|
|
QtGui.QMessageBox.about(
|
2018-01-18 17:47:09 +01:00
|
|
|
self, _translate("MainWindow", "bad passphrase"),
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"You must type your passphrase. If you don\'t"
|
|
|
|
" have one then this is not the form for you."
|
|
|
|
))
|
2014-09-10 22:47:51 +02:00
|
|
|
return
|
2018-01-18 17:47:09 +01:00
|
|
|
streamNumberForAddress = int(dialog.lineEditStreamNumber.text())
|
2014-09-10 22:47:51 +02:00
|
|
|
try:
|
|
|
|
addressVersionNumber = int(
|
2018-01-18 17:47:09 +01:00
|
|
|
dialog.lineEditAddressVersionNumber.text())
|
2014-09-10 22:47:51 +02:00
|
|
|
except:
|
2018-01-22 17:52:28 +01:00
|
|
|
QtGui.QMessageBox.about(
|
2018-01-18 17:47:09 +01:00
|
|
|
self,
|
|
|
|
_translate("MainWindow", "Bad address version number"),
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Your address version number must be a number:"
|
|
|
|
" either 3 or 4."
|
|
|
|
))
|
2014-09-10 22:47:51 +02:00
|
|
|
return
|
|
|
|
if addressVersionNumber < 3 or addressVersionNumber > 4:
|
2018-01-22 17:52:28 +01:00
|
|
|
QtGui.QMessageBox.about(
|
2018-01-18 17:47:09 +01:00
|
|
|
self,
|
|
|
|
_translate("MainWindow", "Bad address version number"),
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Your address version number must be either 3 or 4."
|
|
|
|
))
|
2014-09-10 22:47:51 +02:00
|
|
|
return
|
2018-01-18 17:47:09 +01:00
|
|
|
queues.addressGeneratorQueue.put((
|
|
|
|
'createDeterministicAddresses',
|
|
|
|
addressVersionNumber, streamNumberForAddress,
|
|
|
|
"regenerated deterministic address",
|
|
|
|
dialog.spinBoxNumberOfAddressesToMake.value(),
|
|
|
|
dialog.lineEditPassphrase.text().toUtf8(),
|
|
|
|
dialog.checkBoxEighteenByteRipe.isChecked()
|
|
|
|
))
|
2018-01-18 15:14:29 +01:00
|
|
|
self.ui.tabWidget.setCurrentIndex(
|
|
|
|
self.ui.tabWidget.indexOf(self.ui.chans)
|
|
|
|
)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-07-22 07:10:22 +02:00
|
|
|
def click_actionJoinChan(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""opens 'join chan' dialog"""
|
|
|
|
|
2018-01-19 17:38:15 +01:00
|
|
|
dialogs.NewChanDialog(self)
|
2013-07-22 07:10:22 +02:00
|
|
|
|
2013-07-24 17:46:28 +02:00
|
|
|
def showConnectDialog(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2017-10-16 15:09:52 +02:00
|
|
|
dialog = dialogs.ConnectDialog(self)
|
|
|
|
if dialog.exec_():
|
|
|
|
if dialog.radioButtonConnectNow.isChecked():
|
2017-03-28 16:38:05 +02:00
|
|
|
BMConfigParser().remove_option(
|
|
|
|
'bitmessagesettings', 'dontconnect')
|
2017-01-15 10:50:02 +01:00
|
|
|
BMConfigParser().save()
|
2017-10-16 15:09:52 +02:00
|
|
|
elif dialog.radioButtonConfigureNetwork.isChecked():
|
2013-07-24 17:46:28 +02:00
|
|
|
self.click_actionSettings()
|
2018-03-20 16:54:27 +01:00
|
|
|
else:
|
|
|
|
self._firstrun = False
|
2013-07-24 17:46:28 +02:00
|
|
|
|
2015-10-02 15:05:47 +02:00
|
|
|
def showMigrationWizard(self, level):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-10-02 15:05:47 +02:00
|
|
|
self.migrationWizardInstance = Ui_MigrationWizard(["a"])
|
|
|
|
if self.migrationWizardInstance.exec_():
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
pass
|
2017-10-16 15:09:52 +02:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def changeEvent(self, event):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2014-11-14 12:21:18 +01:00
|
|
|
if event.type() == QtCore.QEvent.LanguageChange:
|
|
|
|
self.ui.retranslateUi(self)
|
2014-12-28 11:42:38 +01:00
|
|
|
self.init_inbox_popup_menu(False)
|
2016-04-29 20:55:58 +02:00
|
|
|
self.init_identities_popup_menu(False)
|
2015-03-21 11:37:08 +01:00
|
|
|
self.init_chan_popup_menu(False)
|
2014-12-28 11:42:38 +01:00
|
|
|
self.init_addressbook_popup_menu(False)
|
|
|
|
self.init_subscriptions_popup_menu(False)
|
|
|
|
self.init_sent_popup_menu(False)
|
2016-03-17 22:09:46 +01:00
|
|
|
self.ui.blackwhitelist.init_blacklist_popup_menu(False)
|
2013-05-08 22:42:28 +02:00
|
|
|
if event.type() == QtCore.QEvent.WindowStateChange:
|
|
|
|
if self.windowState() & QtCore.Qt.WindowMinimized:
|
2018-05-15 17:20:53 +02:00
|
|
|
if BMConfigParser().getboolean('bitmessagesettings', 'minimizetotray'):
|
|
|
|
if 'darwin' not in sys.platform:
|
|
|
|
QtCore.QTimer.singleShot(0, self.appIndicatorHide)
|
2015-01-06 23:55:01 +01:00
|
|
|
elif event.oldState() & QtCore.Qt.WindowMinimized:
|
|
|
|
# The window state has just been changed to
|
|
|
|
# Normal/Maximised/FullScreen
|
|
|
|
pass
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def __icon_activated(self, reason):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
if reason == QtGui.QSystemTrayIcon.Trigger:
|
2013-05-08 22:42:28 +02:00
|
|
|
self.actionShow.setChecked(not self.actionShow.isChecked())
|
|
|
|
self.appIndicatorShowOrHideWindow()
|
|
|
|
|
2013-05-11 18:46:21 +02:00
|
|
|
# Indicates whether or not there is a connection to the Bitmessage network
|
|
|
|
connected = False
|
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
def setStatusIcon(self, color):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Set the status icon"""
|
|
|
|
|
2017-03-10 00:00:54 +01:00
|
|
|
_notifications_enabled = not BMConfigParser().getboolean(
|
|
|
|
'bitmessagesettings', 'hidetrayconnectionnotifications')
|
2013-05-02 17:53:54 +02:00
|
|
|
if color == 'red':
|
2016-03-16 18:04:18 +01:00
|
|
|
self.pushButtonStatusIcon.setIcon(
|
2018-01-22 17:52:28 +01:00
|
|
|
QtGui.QIcon(":/newPrefix/images/redicon.png"))
|
2013-05-02 17:53:54 +02:00
|
|
|
shared.statusIconColor = 'red'
|
2013-05-11 18:46:21 +02:00
|
|
|
# if the connection is lost then show a notification
|
2017-03-10 00:00:54 +01:00
|
|
|
if self.connected and _notifications_enabled:
|
|
|
|
self.notifierShow(
|
|
|
|
'Bitmessage',
|
|
|
|
_translate("MainWindow", "Connection lost"),
|
2017-03-15 14:56:47 +01:00
|
|
|
sound.SOUND_DISCONNECTED)
|
2017-02-27 16:18:22 +01:00
|
|
|
if not BMConfigParser().safeGetBoolean('bitmessagesettings', 'upnp') and \
|
2018-05-15 17:20:53 +02:00
|
|
|
BMConfigParser().get('bitmessagesettings', 'socksproxytype') == "none":
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Problems connecting? Try enabling UPnP in the Network"
|
|
|
|
" Settings"
|
|
|
|
))
|
2013-05-11 18:46:21 +02:00
|
|
|
self.connected = False
|
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
if self.actionStatus is not None:
|
2013-06-13 09:59:40 +02:00
|
|
|
self.actionStatus.setText(_translate(
|
2013-06-12 23:12:32 +02:00
|
|
|
"MainWindow", "Not Connected"))
|
2013-11-29 02:05:53 +01:00
|
|
|
self.setTrayIconFile("can-icon-24px-red.png")
|
2013-05-02 17:53:54 +02:00
|
|
|
if color == 'yellow':
|
2018-05-15 17:20:53 +02:00
|
|
|
if self.statusbar.currentMessage() == ('Warning: You are currently not connected. Bitmessage will do '
|
|
|
|
'the work necessary to send the message but it won\'t send until '
|
|
|
|
'you connect.'):
|
2018-01-23 17:15:11 +01:00
|
|
|
self.statusbar.clearMessage()
|
2018-01-22 17:52:28 +01:00
|
|
|
self.pushButtonStatusIcon.setIcon(
|
|
|
|
QtGui.QIcon(":/newPrefix/images/yellowicon.png"))
|
2013-05-02 17:53:54 +02:00
|
|
|
shared.statusIconColor = 'yellow'
|
2013-05-11 18:46:21 +02:00
|
|
|
# if a new connection has been established then show a notification
|
2017-03-10 00:00:54 +01:00
|
|
|
if not self.connected and _notifications_enabled:
|
|
|
|
self.notifierShow(
|
|
|
|
'Bitmessage',
|
|
|
|
_translate("MainWindow", "Connected"),
|
2017-03-15 14:56:47 +01:00
|
|
|
sound.SOUND_CONNECTED)
|
2013-05-11 18:46:21 +02:00
|
|
|
self.connected = True
|
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
if self.actionStatus is not None:
|
2013-06-13 09:59:40 +02:00
|
|
|
self.actionStatus.setText(_translate(
|
2013-06-12 23:12:32 +02:00
|
|
|
"MainWindow", "Connected"))
|
2013-11-29 02:05:53 +01:00
|
|
|
self.setTrayIconFile("can-icon-24px-yellow.png")
|
2013-05-02 17:53:54 +02:00
|
|
|
if color == 'green':
|
2018-05-15 17:20:53 +02:00
|
|
|
if self.statusbar.currentMessage() == ('Warning: You are currently not connected. Bitmessage will do the '
|
|
|
|
'work necessary to send the message but it won\'t send until you '
|
|
|
|
'connect.'):
|
2018-01-23 17:15:11 +01:00
|
|
|
self.statusbar.clearMessage()
|
2016-03-16 18:04:18 +01:00
|
|
|
self.pushButtonStatusIcon.setIcon(
|
2018-01-22 17:52:28 +01:00
|
|
|
QtGui.QIcon(":/newPrefix/images/greenicon.png"))
|
2013-05-02 17:53:54 +02:00
|
|
|
shared.statusIconColor = 'green'
|
2017-03-10 00:00:54 +01:00
|
|
|
if not self.connected and _notifications_enabled:
|
|
|
|
self.notifierShow(
|
|
|
|
'Bitmessage',
|
|
|
|
_translate("MainWindow", "Connected"),
|
2017-03-15 14:56:47 +01:00
|
|
|
sound.SOUND_CONNECTION_GREEN)
|
2013-05-11 18:46:21 +02:00
|
|
|
self.connected = True
|
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
if self.actionStatus is not None:
|
2013-06-13 09:59:40 +02:00
|
|
|
self.actionStatus.setText(_translate(
|
2013-06-12 23:12:32 +02:00
|
|
|
"MainWindow", "Connected"))
|
2013-11-29 02:05:53 +01:00
|
|
|
self.setTrayIconFile("can-icon-24px-green.png")
|
|
|
|
|
2018-05-15 17:20:53 +02:00
|
|
|
def initTrayIcon(self, iconFileName, this_app):
|
|
|
|
"""TBC"""
|
|
|
|
|
2013-11-29 02:05:53 +01:00
|
|
|
self.currentTrayIconFileName = iconFileName
|
2018-01-22 17:52:28 +01:00
|
|
|
self.tray = QtGui.QSystemTrayIcon(
|
2018-05-15 17:20:53 +02:00
|
|
|
self.calcTrayIcon(iconFileName, self.findInboxUnreadCount()), this_app)
|
2013-11-29 02:05:53 +01:00
|
|
|
|
|
|
|
def setTrayIconFile(self, iconFileName):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2013-11-29 02:05:53 +01:00
|
|
|
self.currentTrayIconFileName = iconFileName
|
|
|
|
self.drawTrayIcon(iconFileName, self.findInboxUnreadCount())
|
|
|
|
|
|
|
|
def calcTrayIcon(self, iconFileName, inboxUnreadCount):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
|
|
|
pixmap = QtGui.QPixmap(":/newPrefix/images/" + iconFileName)
|
2013-11-29 02:05:53 +01:00
|
|
|
if inboxUnreadCount > 0:
|
|
|
|
# choose font and calculate font parameters
|
|
|
|
fontName = "Lucida"
|
|
|
|
fontSize = 10
|
|
|
|
font = QtGui.QFont(fontName, fontSize, QtGui.QFont.Bold)
|
|
|
|
fontMetrics = QtGui.QFontMetrics(font)
|
|
|
|
# text
|
|
|
|
txt = str(inboxUnreadCount)
|
|
|
|
rect = fontMetrics.boundingRect(txt)
|
|
|
|
# margins that we add in the top-right corner
|
|
|
|
marginX = 2
|
2018-05-15 17:20:53 +02:00
|
|
|
marginY = 0 # it looks like -2 is also ok due to the error of metric
|
2013-11-29 02:05:53 +01:00
|
|
|
# if it renders too wide we need to change it to a plus symbol
|
|
|
|
if rect.width() > 20:
|
|
|
|
txt = "+"
|
|
|
|
fontSize = 15
|
|
|
|
font = QtGui.QFont(fontName, fontSize, QtGui.QFont.Bold)
|
|
|
|
fontMetrics = QtGui.QFontMetrics(font)
|
|
|
|
rect = fontMetrics.boundingRect(txt)
|
|
|
|
# draw text
|
2018-01-22 17:52:28 +01:00
|
|
|
painter = QtGui.QPainter()
|
2013-11-29 02:05:53 +01:00
|
|
|
painter.begin(pixmap)
|
2018-01-22 17:52:28 +01:00
|
|
|
painter.setPen(
|
|
|
|
QtGui.QPen(QtGui.QColor(255, 0, 0), QtCore.Qt.SolidPattern))
|
2013-11-29 02:05:53 +01:00
|
|
|
painter.setFont(font)
|
2018-05-15 17:20:53 +02:00
|
|
|
painter.drawText(24 - rect.right() - marginX, -rect.top() + marginY, txt)
|
2013-11-29 02:05:53 +01:00
|
|
|
painter.end()
|
|
|
|
return QtGui.QIcon(pixmap)
|
|
|
|
|
|
|
|
def drawTrayIcon(self, iconFileName, inboxUnreadCount):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2013-11-29 02:05:53 +01:00
|
|
|
self.tray.setIcon(self.calcTrayIcon(iconFileName, inboxUnreadCount))
|
|
|
|
|
2018-01-22 17:52:28 +01:00
|
|
|
def changedInboxUnread(self, row=None):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2018-01-22 17:52:28 +01:00
|
|
|
self.drawTrayIcon(
|
|
|
|
self.currentTrayIconFileName, self.findInboxUnreadCount())
|
2015-10-03 01:17:47 +02:00
|
|
|
self.rerenderTabTreeMessages()
|
2015-10-31 15:27:07 +01:00
|
|
|
self.rerenderTabTreeSubscriptions()
|
|
|
|
self.rerenderTabTreeChans()
|
2013-11-29 02:05:53 +01:00
|
|
|
|
2018-01-22 17:52:28 +01:00
|
|
|
def findInboxUnreadCount(self, count=None):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-10-31 15:27:07 +01:00
|
|
|
if count is None:
|
|
|
|
queryreturn = sqlQuery('''SELECT count(*) from inbox WHERE folder='inbox' and read=0''')
|
|
|
|
cnt = 0
|
|
|
|
for row in queryreturn:
|
|
|
|
cnt, = row
|
|
|
|
self.unreadCount = int(cnt)
|
|
|
|
else:
|
|
|
|
self.unreadCount = count
|
|
|
|
return self.unreadCount
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2015-11-05 17:27:35 +01:00
|
|
|
def updateSentItemStatusByToAddress(self, toAddress, textToDisplay):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-11-09 19:39:30 +01:00
|
|
|
for sent in [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxChans]:
|
|
|
|
treeWidget = self.widgetConvert(sent)
|
|
|
|
if self.getCurrentFolder(treeWidget) != "sent":
|
|
|
|
continue
|
2018-05-15 17:20:53 +02:00
|
|
|
if treeWidget in [self.ui.treeWidgetSubscriptions,
|
|
|
|
self.ui.treeWidgetChans] and self.getCurrentAccount(treeWidget) != toAddress:
|
2015-11-09 19:39:30 +01:00
|
|
|
continue
|
|
|
|
|
|
|
|
for i in range(sent.rowCount()):
|
2018-01-22 17:52:28 +01:00
|
|
|
rowAddress = sent.item(i, 0).data(QtCore.Qt.UserRole)
|
2015-11-09 19:39:30 +01:00
|
|
|
if toAddress == rowAddress:
|
|
|
|
sent.item(i, 3).setToolTip(textToDisplay)
|
|
|
|
try:
|
|
|
|
newlinePosition = textToDisplay.indexOf('\n')
|
2018-05-15 17:20:53 +02:00
|
|
|
except: # If no "_translate" appended to string before passing in, there's no qstring
|
2015-11-09 19:39:30 +01:00
|
|
|
newlinePosition = 0
|
|
|
|
if newlinePosition > 1:
|
|
|
|
sent.item(i, 3).setText(
|
|
|
|
textToDisplay[:newlinePosition])
|
|
|
|
else:
|
|
|
|
sent.item(i, 3).setText(textToDisplay)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
def updateSentItemStatusByAckdata(self, ackdata, textToDisplay):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
|
|
|
if isinstance(ackdata, str):
|
2018-02-18 19:39:26 +01:00
|
|
|
ackdata = QtCore.QByteArray(ackdata)
|
2015-11-09 19:39:30 +01:00
|
|
|
for sent in [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxChans]:
|
|
|
|
treeWidget = self.widgetConvert(sent)
|
|
|
|
if self.getCurrentFolder(treeWidget) != "sent":
|
|
|
|
continue
|
|
|
|
for i in range(sent.rowCount()):
|
2015-12-20 01:21:54 +01:00
|
|
|
toAddress = sent.item(
|
2018-01-22 17:52:28 +01:00
|
|
|
i, 0).data(QtCore.Qt.UserRole)
|
2015-11-09 19:39:30 +01:00
|
|
|
tableAckdata = sent.item(
|
2018-01-22 17:52:28 +01:00
|
|
|
i, 3).data(QtCore.Qt.UserRole).toPyObject()
|
2015-11-09 19:39:30 +01:00
|
|
|
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
|
|
|
|
toAddress)
|
|
|
|
if ackdata == tableAckdata:
|
|
|
|
sent.item(i, 3).setToolTip(textToDisplay)
|
|
|
|
try:
|
|
|
|
newlinePosition = textToDisplay.indexOf('\n')
|
2018-05-15 17:20:53 +02:00
|
|
|
except: # If no "_translate" appended to string before passing in, there's no qstring
|
2015-11-09 19:39:30 +01:00
|
|
|
newlinePosition = 0
|
|
|
|
if newlinePosition > 1:
|
|
|
|
sent.item(i, 3).setText(
|
|
|
|
textToDisplay[:newlinePosition])
|
|
|
|
else:
|
|
|
|
sent.item(i, 3).setText(textToDisplay)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
def removeInboxRowByMsgid(self, msgid): # msgid and inventoryHash are the same thing
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-10-31 18:42:44 +01:00
|
|
|
for inbox in ([
|
2018-05-15 17:20:53 +02:00
|
|
|
self.ui.tableWidgetInbox,
|
|
|
|
self.ui.tableWidgetInboxSubscriptions,
|
|
|
|
self.ui.tableWidgetInboxChans]):
|
2015-10-31 18:42:44 +01:00
|
|
|
for i in range(inbox.rowCount()):
|
2018-01-22 17:52:28 +01:00
|
|
|
if msgid == str(inbox.item(i, 3).data(QtCore.Qt.UserRole).toPyObject()):
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(
|
|
|
|
_translate("MainWindow", "Message trashed"))
|
2015-11-09 19:39:30 +01:00
|
|
|
treeWidget = self.widgetConvert(inbox)
|
2018-05-15 17:20:53 +02:00
|
|
|
self.propagateUnreadCount(
|
|
|
|
inbox.item(
|
|
|
|
i,
|
|
|
|
1 if inbox.item(
|
|
|
|
i,
|
|
|
|
1).type == AccountMixin.SUBSCRIPTION else 0).data(
|
|
|
|
QtCore.Qt.UserRole),
|
|
|
|
self.getCurrentFolder(treeWidget),
|
|
|
|
treeWidget,
|
|
|
|
0)
|
2015-10-31 18:42:44 +01:00
|
|
|
inbox.removeRow(i)
|
|
|
|
break
|
2018-01-23 17:15:11 +01:00
|
|
|
|
2015-10-19 22:33:18 +02:00
|
|
|
def newVersionAvailable(self, version):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-10-19 22:33:18 +02:00
|
|
|
self.notifiedNewVersion = ".".join(str(n) for n in version)
|
2018-05-15 17:20:53 +02:00
|
|
|
self.updateStatusBar(
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"New version of PyBitmessage is available: %1. Download it"
|
|
|
|
" from https://github.com/Bitmessage/PyBitmessage/releases/latest"
|
2018-01-23 17:15:11 +01:00
|
|
|
).arg(self.notifiedNewVersion)
|
|
|
|
)
|
2013-06-05 23:15:26 +02:00
|
|
|
|
2013-09-05 02:14:25 +02:00
|
|
|
def displayAlert(self, title, text, exitAfterUserClicksOk):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(text)
|
2018-01-22 17:52:28 +01:00
|
|
|
QtGui.QMessageBox.critical(self, title, text, QtGui.QMessageBox.Ok)
|
2013-09-05 02:14:25 +02:00
|
|
|
if exitAfterUserClicksOk:
|
2018-05-15 17:20:53 +02:00
|
|
|
sys.exit(0)
|
2013-09-05 02:14:25 +02:00
|
|
|
|
2016-01-23 20:24:50 +01:00
|
|
|
def rerenderMessagelistFromLabels(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
|
|
|
for messagelist in (
|
|
|
|
self.ui.tableWidgetInbox,
|
|
|
|
self.ui.tableWidgetInboxChans,
|
|
|
|
self.ui.tableWidgetInboxSubscriptions):
|
2016-01-23 20:24:50 +01:00
|
|
|
for i in range(messagelist.rowCount()):
|
|
|
|
messagelist.item(i, 1).setLabel()
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2016-01-23 20:24:50 +01:00
|
|
|
def rerenderMessagelistToLabels(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
|
|
|
for messagelist in (
|
|
|
|
self.ui.tableWidgetInbox,
|
|
|
|
self.ui.tableWidgetInboxChans,
|
|
|
|
self.ui.tableWidgetInboxSubscriptions):
|
2016-01-23 20:24:50 +01:00
|
|
|
for i in range(messagelist.rowCount()):
|
|
|
|
messagelist.item(i, 0).setLabel()
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-09-05 12:31:52 +02:00
|
|
|
def rerenderAddressBook(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
|
|
|
def addRow(address, label, arg_type):
|
|
|
|
"""TBC"""
|
|
|
|
|
2015-10-23 19:14:01 +02:00
|
|
|
self.ui.tableWidgetAddressBook.insertRow(0)
|
2018-05-15 17:20:53 +02:00
|
|
|
newItem = Ui_AddressBookWidgetItemLabel(address, unicode(label, 'utf-8'), arg_type)
|
2015-10-23 19:14:01 +02:00
|
|
|
self.ui.tableWidgetAddressBook.setItem(0, 0, newItem)
|
2018-05-15 17:20:53 +02:00
|
|
|
newItem = Ui_AddressBookWidgetItemAddress(address, unicode(label, 'utf-8'), arg_type)
|
2015-10-23 19:14:01 +02:00
|
|
|
self.ui.tableWidgetAddressBook.setItem(0, 1, newItem)
|
|
|
|
|
2016-01-23 20:24:50 +01:00
|
|
|
oldRows = {}
|
|
|
|
for i in range(self.ui.tableWidgetAddressBook.rowCount()):
|
|
|
|
item = self.ui.tableWidgetAddressBook.item(i, 0)
|
|
|
|
oldRows[item.address] = [item.label, item.type, i]
|
|
|
|
|
|
|
|
if self.ui.tableWidgetAddressBook.rowCount() == 0:
|
2018-01-22 17:52:28 +01:00
|
|
|
self.ui.tableWidgetAddressBook.horizontalHeader().setSortIndicator(0, QtCore.Qt.AscendingOrder)
|
2016-01-23 20:24:50 +01:00
|
|
|
if self.ui.tableWidgetAddressBook.isSortingEnabled():
|
|
|
|
self.ui.tableWidgetAddressBook.setSortingEnabled(False)
|
|
|
|
|
|
|
|
newRows = {}
|
2015-10-23 19:14:01 +02:00
|
|
|
# subscriptions
|
|
|
|
queryreturn = sqlQuery('SELECT label, address FROM subscriptions WHERE enabled = 1')
|
|
|
|
for row in queryreturn:
|
|
|
|
label, address = row
|
2016-01-23 20:24:50 +01:00
|
|
|
newRows[address] = [label, AccountMixin.SUBSCRIPTION]
|
2015-10-23 19:14:01 +02:00
|
|
|
# chans
|
|
|
|
addresses = getSortedAccounts()
|
|
|
|
for address in addresses:
|
|
|
|
account = accountClass(address)
|
2017-01-11 14:27:19 +01:00
|
|
|
if (account.type == AccountMixin.CHAN and BMConfigParser().safeGetBoolean(address, 'enabled')):
|
2016-01-23 20:24:50 +01:00
|
|
|
newRows[address] = [account.getLabel(), AccountMixin.CHAN]
|
2015-10-23 19:14:01 +02:00
|
|
|
# normal accounts
|
2013-09-05 12:31:52 +02:00
|
|
|
queryreturn = sqlQuery('SELECT * FROM addressbook')
|
|
|
|
for row in queryreturn:
|
|
|
|
label, address = row
|
2016-01-23 20:24:50 +01:00
|
|
|
newRows[address] = [label, AccountMixin.NORMAL]
|
|
|
|
|
2016-04-29 02:03:48 +02:00
|
|
|
completerList = []
|
2018-05-15 17:20:53 +02:00
|
|
|
for address in sorted(oldRows, key=lambda x: oldRows[x][2], reverse=True):
|
2016-01-23 20:24:50 +01:00
|
|
|
if address in newRows:
|
2016-04-29 11:43:40 +02:00
|
|
|
completerList.append(unicode(newRows[address][0], encoding="UTF-8") + " <" + address + ">")
|
2016-01-23 20:24:50 +01:00
|
|
|
newRows.pop(address)
|
|
|
|
else:
|
|
|
|
self.ui.tableWidgetAddressBook.removeRow(oldRows[address][2])
|
|
|
|
for address in newRows:
|
|
|
|
addRow(address, newRows[address][0], newRows[address][1])
|
2016-04-29 11:43:40 +02:00
|
|
|
completerList.append(unicode(newRows[address][0], encoding="UTF-8") + " <" + address + ">")
|
2015-10-23 19:14:01 +02:00
|
|
|
|
|
|
|
# sort
|
2018-01-22 17:52:28 +01:00
|
|
|
self.ui.tableWidgetAddressBook.sortByColumn(
|
|
|
|
0, QtCore.Qt.AscendingOrder)
|
2015-10-23 19:14:01 +02:00
|
|
|
self.ui.tableWidgetAddressBook.setSortingEnabled(True)
|
2016-04-29 02:03:48 +02:00
|
|
|
self.ui.lineEditTo.completer().model().setStringList(completerList)
|
2016-01-23 20:24:50 +01:00
|
|
|
|
2013-05-24 22:12:16 +02:00
|
|
|
def rerenderSubscriptions(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
self.rerenderTabTreeSubscriptions()
|
2013-05-24 22:12:16 +02:00
|
|
|
|
2015-03-03 20:04:12 +01:00
|
|
|
def click_pushButtonTTL(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-03 20:04:12 +01:00
|
|
|
QtGui.QMessageBox.information(self, 'Time To Live', _translate(
|
2018-05-15 17:20:53 +02:00
|
|
|
"MainWindow",
|
|
|
|
("The TTL, or Time-To-Live is the length of time that the network will hold the message."
|
|
|
|
"The recipient must get it during this time. If your Bitmessage client does not hear an "
|
|
|
|
"acknowledgement, it will resend the message automatically. The longer the Time-To-Live, "
|
|
|
|
"the more work your computer must do to send the message. A Time-To-Live of four or five "
|
|
|
|
"days is often appropriate.")), QtGui.QMessageBox.Ok)
|
2015-03-03 20:04:12 +01:00
|
|
|
|
2018-02-05 15:40:43 +01:00
|
|
|
def click_pushButtonClear(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2018-02-05 15:40:43 +01:00
|
|
|
self.ui.lineEditSubject.setText("")
|
|
|
|
self.ui.lineEditTo.setText("")
|
|
|
|
self.ui.textEditMessage.setText("")
|
|
|
|
self.ui.comboBoxSendFrom.setCurrentIndex(0)
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def click_pushButtonSend(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""
|
|
|
|
TBC
|
|
|
|
|
|
|
|
Regarding the line below `if len(message) > (2 ** 18 - 500):`:
|
|
|
|
|
|
|
|
The whole network message must fit in 2^18 bytes.
|
|
|
|
Let's assume 500 bytes of overhead. If someone wants to get that
|
|
|
|
too an exact number you are welcome to but I think that it would
|
|
|
|
be a better use of time to support message continuation so that
|
|
|
|
users can send messages of any length.
|
|
|
|
"""
|
|
|
|
|
2016-11-14 20:23:58 +01:00
|
|
|
encoding = 3 if QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier else 2
|
|
|
|
|
2018-01-23 17:15:11 +01:00
|
|
|
self.statusbar.clearMessage()
|
2015-03-21 11:37:08 +01:00
|
|
|
|
2018-01-18 15:14:29 +01:00
|
|
|
if self.ui.tabWidgetSend.currentIndex() == \
|
|
|
|
self.ui.tabWidgetSend.indexOf(self.ui.sendDirect):
|
2015-03-23 22:35:56 +01:00
|
|
|
# message to specific people
|
2015-03-21 11:37:08 +01:00
|
|
|
sendMessageToPeople = True
|
2015-09-30 10:22:41 +02:00
|
|
|
fromAddress = str(self.ui.comboBoxSendFrom.itemData(
|
2018-01-22 17:52:28 +01:00
|
|
|
self.ui.comboBoxSendFrom.currentIndex(),
|
|
|
|
QtCore.Qt.UserRole).toString())
|
2016-08-14 12:56:28 +02:00
|
|
|
toAddresses = str(self.ui.lineEditTo.text().toUtf8())
|
2015-03-21 11:37:08 +01:00
|
|
|
subject = str(self.ui.lineEditSubject.text().toUtf8())
|
|
|
|
message = str(
|
|
|
|
self.ui.textEditMessage.document().toPlainText().toUtf8())
|
|
|
|
else:
|
2015-03-23 22:35:56 +01:00
|
|
|
# broadcast message
|
2015-03-21 11:37:08 +01:00
|
|
|
sendMessageToPeople = False
|
2015-09-30 10:22:41 +02:00
|
|
|
fromAddress = str(self.ui.comboBoxSendFromBroadcast.itemData(
|
2018-01-22 17:52:28 +01:00
|
|
|
self.ui.comboBoxSendFromBroadcast.currentIndex(),
|
|
|
|
QtCore.Qt.UserRole).toString())
|
2015-03-21 11:37:08 +01:00
|
|
|
subject = str(self.ui.lineEditSubjectBroadcast.text().toUtf8())
|
|
|
|
message = str(
|
|
|
|
self.ui.textEditMessageBroadcast.document().toPlainText().toUtf8())
|
2018-01-22 17:52:28 +01:00
|
|
|
if len(message) > (2 ** 18 - 500):
|
|
|
|
QtGui.QMessageBox.about(
|
|
|
|
self, _translate("MainWindow", "Message too long"),
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"The message that you are trying to send is too long"
|
|
|
|
" by %1 bytes. (The maximum is 261644 bytes). Please"
|
|
|
|
" cut it down before sending."
|
|
|
|
).arg(len(message) - (2 ** 18 - 500)))
|
2014-08-27 09:14:32 +02:00
|
|
|
return
|
2018-01-22 17:52:28 +01:00
|
|
|
|
2015-10-03 17:24:21 +02:00
|
|
|
acct = accountClass(fromAddress)
|
2015-03-21 11:37:08 +01:00
|
|
|
|
2018-05-15 17:20:53 +02:00
|
|
|
if sendMessageToPeople: # To send a message to specific people (rather than broadcast)
|
2013-06-12 23:12:32 +02:00
|
|
|
toAddressesList = [s.strip()
|
|
|
|
for s in toAddresses.replace(',', ';').split(';')]
|
2018-05-15 17:20:53 +02:00
|
|
|
# remove duplicate addresses. If the user has one address with a BM- and
|
|
|
|
# the same address without the BM-, this will not catch it. They'll send
|
|
|
|
# the message to the person twice.
|
|
|
|
toAddressesList = list(set(toAddressesList))
|
2013-05-02 17:53:54 +02:00
|
|
|
for toAddress in toAddressesList:
|
2013-06-12 23:12:32 +02:00
|
|
|
if toAddress != '':
|
2016-04-29 02:03:48 +02:00
|
|
|
# label plus address
|
|
|
|
if "<" in toAddress and ">" in toAddress:
|
|
|
|
toAddress = toAddress.split('<')[1].split('>')[0]
|
|
|
|
# email address
|
2017-08-24 14:16:37 +02:00
|
|
|
if toAddress.find("@") >= 0:
|
2015-12-02 23:12:38 +01:00
|
|
|
if isinstance(acct, GatewayAccount):
|
|
|
|
acct.createMessage(toAddress, fromAddress, subject, message)
|
|
|
|
subject = acct.subject
|
|
|
|
toAddress = acct.toAddress
|
|
|
|
else:
|
2018-05-15 17:20:53 +02:00
|
|
|
if QtGui.QMessageBox.question(
|
|
|
|
self, "Sending an email?",
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
("You are trying to send an email instead of a bitmessage. This requires "
|
|
|
|
"registering with a gateway. Attempt to register?")),
|
|
|
|
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) != QtGui.QMessageBox.Yes:
|
2017-08-24 14:16:37 +02:00
|
|
|
continue
|
2015-12-02 23:12:38 +01:00
|
|
|
email = acct.getLabel()
|
2018-05-15 17:20:53 +02:00
|
|
|
if email[-14:] != "@mailchuck.com": # attempt register
|
2015-12-02 23:12:38 +01:00
|
|
|
# 12 character random email address
|
2018-05-15 17:20:53 +02:00
|
|
|
email = ''.join(random.SystemRandom().choice(string.ascii_lowercase)
|
|
|
|
for _ in range(12)) + "@mailchuck.com"
|
2015-12-02 23:12:38 +01:00
|
|
|
acct = MailchuckAccount(fromAddress)
|
|
|
|
acct.register(email)
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set(fromAddress, 'label', email)
|
|
|
|
BMConfigParser().set(fromAddress, 'gateway', 'mailchuck')
|
2017-01-15 10:50:02 +01:00
|
|
|
BMConfigParser().save()
|
2018-05-15 17:20:53 +02:00
|
|
|
self.updateStatusBar(
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
("Error: Your account wasn't registered at an email gateway. Sending registration"
|
|
|
|
" now as %1, please wait for the registration to be processed before retrying "
|
|
|
|
"sending.")
|
2018-01-23 17:15:11 +01:00
|
|
|
).arg(email)
|
|
|
|
)
|
2015-12-02 23:12:38 +01:00
|
|
|
return
|
2013-06-12 23:12:32 +02:00
|
|
|
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
|
|
|
|
toAddress)
|
|
|
|
if status != 'success':
|
2016-10-24 22:31:54 +02:00
|
|
|
try:
|
2016-10-26 02:19:26 +02:00
|
|
|
toAddress = unicode(toAddress, 'utf-8', 'ignore')
|
2016-10-24 22:31:54 +02:00
|
|
|
except:
|
|
|
|
pass
|
2016-10-24 22:33:13 +02:00
|
|
|
logger.error('Error: Could not decode recipient address ' + toAddress + ':' + status)
|
2013-06-29 19:29:35 +02:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
if status == 'missingbm':
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Error: Bitmessage addresses start with"
|
|
|
|
" BM- Please check the recipient address %1"
|
2018-05-15 17:20:53 +02:00
|
|
|
).arg(toAddress))
|
2013-05-02 17:53:54 +02:00
|
|
|
elif status == 'checksumfailed':
|
2018-01-31 19:12:04 +01:00
|
|
|
self.updateStatusBar(_translate(
|
2018-01-23 17:15:11 +01:00
|
|
|
"MainWindow",
|
|
|
|
"Error: The recipient address %1 is not"
|
|
|
|
" typed or copied correctly. Please check it."
|
2018-05-15 17:20:53 +02:00
|
|
|
).arg(toAddress))
|
2013-05-02 17:53:54 +02:00
|
|
|
elif status == 'invalidcharacters':
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Error: The recipient address %1 contains"
|
|
|
|
" invalid characters. Please check it."
|
2018-05-15 17:20:53 +02:00
|
|
|
).arg(toAddress))
|
2013-05-02 17:53:54 +02:00
|
|
|
elif status == 'versiontoohigh':
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Error: The version of the recipient address"
|
|
|
|
" %1 is too high. Either you need to upgrade"
|
|
|
|
" your Bitmessage software or your"
|
|
|
|
" acquaintance is being clever."
|
2018-05-15 17:20:53 +02:00
|
|
|
).arg(toAddress))
|
2013-05-02 17:53:54 +02:00
|
|
|
elif status == 'ripetooshort':
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Error: Some data encoded in the recipient"
|
|
|
|
" address %1 is too short. There might be"
|
|
|
|
" something wrong with the software of"
|
|
|
|
" your acquaintance."
|
2018-05-15 17:20:53 +02:00
|
|
|
).arg(toAddress))
|
2013-05-02 17:53:54 +02:00
|
|
|
elif status == 'ripetoolong':
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Error: Some data encoded in the recipient"
|
|
|
|
" address %1 is too long. There might be"
|
|
|
|
" something wrong with the software of"
|
|
|
|
" your acquaintance."
|
2018-05-15 17:20:53 +02:00
|
|
|
).arg(toAddress))
|
2014-08-27 09:14:32 +02:00
|
|
|
elif status == 'varintmalformed':
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Error: Some data encoded in the recipient"
|
|
|
|
" address %1 is malformed. There might be"
|
|
|
|
" something wrong with the software of"
|
|
|
|
" your acquaintance."
|
2018-05-15 17:20:53 +02:00
|
|
|
).arg(toAddress))
|
2013-05-02 17:53:54 +02:00
|
|
|
else:
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Error: Something is wrong with the"
|
|
|
|
" recipient address %1."
|
2018-05-15 17:20:53 +02:00
|
|
|
).arg(toAddress))
|
2013-05-02 17:53:54 +02:00
|
|
|
elif fromAddress == '':
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow",
|
2018-05-15 17:20:53 +02:00
|
|
|
("Error: You must specify a From address. If you don\'t have one, go to the"
|
|
|
|
" \'Your Identities\' tab.")))
|
2013-05-02 17:53:54 +02:00
|
|
|
else:
|
|
|
|
toAddress = addBMIfNotPresent(toAddress)
|
2015-09-30 10:22:41 +02:00
|
|
|
|
2013-09-13 06:27:34 +02:00
|
|
|
if addressVersionNumber > 4 or addressVersionNumber <= 1:
|
2018-05-15 17:20:53 +02:00
|
|
|
QtGui.QMessageBox.about(
|
|
|
|
self,
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Address version number"),
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
("Concerning the address %1, Bitmessage cannot understand address version "
|
|
|
|
"numbers of %2. Perhaps upgrade Bitmessage to the latest version.")
|
|
|
|
).arg(toAddress).arg(
|
|
|
|
str(addressVersionNumber)))
|
2013-05-02 17:53:54 +02:00
|
|
|
continue
|
|
|
|
if streamNumber > 1 or streamNumber == 0:
|
2018-05-15 17:20:53 +02:00
|
|
|
QtGui.QMessageBox.about(
|
|
|
|
self,
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Stream number"),
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
("Concerning the address %1, Bitmessage cannot handle stream numbers of %2. "
|
|
|
|
"Perhaps upgrade Bitmessage to the latest version.")
|
|
|
|
).arg(toAddress).arg(
|
|
|
|
str(streamNumber)))
|
2013-05-02 17:53:54 +02:00
|
|
|
continue
|
2018-01-23 17:15:11 +01:00
|
|
|
self.statusbar.clearMessage()
|
2013-05-02 17:53:54 +02:00
|
|
|
if shared.statusIconColor == 'red':
|
2018-05-15 17:20:53 +02:00
|
|
|
self.updateStatusBar(
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
("Warning: You are currently not connected. Bitmessage will do the work necessary"
|
|
|
|
" to send the message but it won\'t send until you connect.")
|
|
|
|
)
|
2018-01-23 17:15:11 +01:00
|
|
|
)
|
|
|
|
stealthLevel = BMConfigParser().safeGetInt(
|
|
|
|
'bitmessagesettings', 'ackstealthlevel')
|
2017-09-30 11:19:44 +02:00
|
|
|
ackdata = genAckPayload(streamNumber, stealthLevel)
|
2013-08-27 02:01:19 +02:00
|
|
|
t = ()
|
|
|
|
sqlExecute(
|
2015-03-09 07:35:32 +01:00
|
|
|
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
|
2013-08-27 02:01:19 +02:00
|
|
|
'',
|
|
|
|
toAddress,
|
|
|
|
ripe,
|
|
|
|
fromAddress,
|
|
|
|
subject,
|
|
|
|
message,
|
|
|
|
ackdata,
|
2018-05-15 17:20:53 +02:00
|
|
|
int(time.time()), # sentTime (this will never change)
|
|
|
|
int(time.time()), # lastActionTime
|
|
|
|
0, # sleepTill time. This will get set when the POW gets done.
|
2013-08-27 02:01:19 +02:00
|
|
|
'msgqueued',
|
2018-05-15 17:20:53 +02:00
|
|
|
0, # retryNumber
|
|
|
|
'sent', # folder
|
|
|
|
encoding, # encodingtype
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().getint('bitmessagesettings', 'ttl')
|
2018-05-15 17:20:53 +02:00
|
|
|
)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
|
|
|
toLabel = ''
|
2013-08-27 02:01:19 +02:00
|
|
|
queryreturn = sqlQuery('''select label from addressbook where address=?''',
|
|
|
|
toAddress)
|
2013-06-12 23:12:32 +02:00
|
|
|
if queryreturn != []:
|
2013-05-02 17:53:54 +02:00
|
|
|
for row in queryreturn:
|
|
|
|
toLabel, = row
|
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
self.displayNewSentMessage(
|
|
|
|
toAddress, toLabel, fromAddress, subject, message, ackdata)
|
2017-02-08 13:41:56 +01:00
|
|
|
queues.workerQueue.put(('sendmessage', toAddress))
|
2013-05-02 17:53:54 +02:00
|
|
|
|
|
|
|
self.ui.comboBoxSendFrom.setCurrentIndex(0)
|
|
|
|
self.ui.lineEditTo.setText('')
|
|
|
|
self.ui.lineEditSubject.setText('')
|
2016-01-22 19:16:47 +01:00
|
|
|
self.ui.textEditMessage.reset()
|
2015-10-19 17:37:43 +02:00
|
|
|
if self.replyFromTab is not None:
|
|
|
|
self.ui.tabWidget.setCurrentIndex(self.replyFromTab)
|
|
|
|
self.replyFromTab = None
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow", "Message queued."))
|
|
|
|
# self.ui.tableWidgetInbox.setCurrentCell(0, 0)
|
2013-05-02 17:53:54 +02:00
|
|
|
else:
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow", "Your \'To\' field is empty."))
|
2013-06-12 23:12:32 +02:00
|
|
|
else: # User selected 'Broadcast'
|
2013-05-02 17:53:54 +02:00
|
|
|
if fromAddress == '':
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Error: You must specify a From address. If you don\'t"
|
|
|
|
" have one, go to the \'Your Identities\' tab."
|
|
|
|
))
|
2013-05-02 17:53:54 +02:00
|
|
|
else:
|
2018-01-23 17:15:11 +01:00
|
|
|
self.statusbar.clearMessage()
|
2013-06-12 23:12:32 +02:00
|
|
|
# We don't actually need the ackdata for acknowledgement since
|
|
|
|
# this is a broadcast message, but we can use it to update the
|
|
|
|
# user interface when the POW is done generating.
|
2018-02-09 00:49:08 +01:00
|
|
|
streamNumber = decodeAddress(fromAddress)[2]
|
2017-09-30 11:19:44 +02:00
|
|
|
ackdata = genAckPayload(streamNumber, 0)
|
2015-10-13 23:36:09 +02:00
|
|
|
toAddress = str_broadcast_subscribers
|
2013-05-02 17:53:54 +02:00
|
|
|
ripe = ''
|
2018-05-15 17:20:53 +02:00
|
|
|
t = (
|
|
|
|
'', # msgid. We don't know what this will be until the POW is done.
|
|
|
|
toAddress,
|
|
|
|
ripe,
|
|
|
|
fromAddress,
|
|
|
|
subject,
|
|
|
|
message,
|
|
|
|
ackdata,
|
|
|
|
int(time.time()), # sentTime (this will never change)
|
|
|
|
int(time.time()), # lastActionTime
|
|
|
|
0, # sleepTill time. This will get set when the POW gets done.
|
|
|
|
'broadcastqueued',
|
|
|
|
0, # retryNumber
|
|
|
|
'sent', # folder
|
|
|
|
encoding, # encoding type
|
|
|
|
BMConfigParser().getint('bitmessagesettings', 'ttl')
|
|
|
|
)
|
2013-08-27 02:01:19 +02:00
|
|
|
sqlExecute(
|
2015-03-09 07:35:32 +01:00
|
|
|
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2015-10-13 23:36:09 +02:00
|
|
|
toLabel = str_broadcast_subscribers
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2013-10-16 07:08:22 +02:00
|
|
|
self.displayNewSentMessage(
|
|
|
|
toAddress, toLabel, fromAddress, subject, message, ackdata)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2017-02-08 13:41:56 +01:00
|
|
|
queues.workerQueue.put(('sendbroadcast', ''))
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2015-03-21 11:37:08 +01:00
|
|
|
self.ui.comboBoxSendFromBroadcast.setCurrentIndex(0)
|
|
|
|
self.ui.lineEditSubjectBroadcast.setText('')
|
2016-01-22 19:16:47 +01:00
|
|
|
self.ui.textEditMessageBroadcast.reset()
|
2018-01-18 15:14:29 +01:00
|
|
|
self.ui.tabWidget.setCurrentIndex(
|
|
|
|
self.ui.tabWidget.indexOf(self.ui.send)
|
|
|
|
)
|
2015-10-10 19:58:01 +02:00
|
|
|
self.ui.tableWidgetInboxSubscriptions.setCurrentCell(0, 0)
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow", "Broadcast queued."))
|
2013-05-02 17:53:54 +02:00
|
|
|
|
|
|
|
def click_pushButtonLoadFromAddressBook(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
self.ui.tabWidget.setCurrentIndex(5)
|
|
|
|
for i in range(4):
|
|
|
|
time.sleep(0.1)
|
2018-01-23 17:15:11 +01:00
|
|
|
self.statusbar.clearMessage()
|
2013-05-02 17:53:54 +02:00
|
|
|
time.sleep(0.1)
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Right click one or more entries in your address book and"
|
|
|
|
" select \'Send message to this address\'."
|
|
|
|
))
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-07-04 22:06:30 +02:00
|
|
|
def click_pushButtonFetchNamecoinID(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2013-07-05 17:29:49 +02:00
|
|
|
nc = namecoinConnection()
|
2016-08-17 22:02:41 +02:00
|
|
|
identities = str(self.ui.lineEditTo.text().toUtf8()).split(";")
|
|
|
|
err, addr = nc.query(identities[-1].strip())
|
2013-07-05 17:29:49 +02:00
|
|
|
if err is not None:
|
2018-01-31 19:12:04 +01:00
|
|
|
self.updateStatusBar(
|
|
|
|
_translate("MainWindow", "Error: %1").arg(err))
|
2013-07-05 17:29:49 +02:00
|
|
|
else:
|
2016-08-17 22:02:41 +02:00
|
|
|
identities[-1] = addr
|
|
|
|
self.ui.lineEditTo.setText("; ".join(identities))
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow", "Fetched address from namecoin identity."))
|
2013-07-04 22:06:30 +02:00
|
|
|
|
2015-10-14 23:38:34 +02:00
|
|
|
def setBroadcastEnablementDependingOnWhetherThisIsAMailingListAddress(self, address):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""If this is a chan then don't let people broadcast because no one should subscribe to chan addresses."""
|
|
|
|
|
2018-01-18 15:14:29 +01:00
|
|
|
self.ui.tabWidgetSend.setCurrentIndex(
|
|
|
|
self.ui.tabWidgetSend.indexOf(
|
|
|
|
self.ui.sendBroadcast
|
|
|
|
if BMConfigParser().safeGetBoolean(str(address), 'mailinglist')
|
|
|
|
else self.ui.sendDirect
|
|
|
|
))
|
2013-05-02 17:53:54 +02:00
|
|
|
|
|
|
|
def rerenderComboBoxSendFrom(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
self.ui.comboBoxSendFrom.clear()
|
2015-10-19 20:03:06 +02:00
|
|
|
for addressInKeysFile in getSortedAccounts():
|
2018-05-15 17:20:53 +02:00
|
|
|
|
|
|
|
# I realize that this is poor programming practice but I don't care. It's easier for others to read.
|
|
|
|
isEnabled = BMConfigParser().getboolean(addressInKeysFile, 'enabled')
|
2017-01-11 14:27:19 +01:00
|
|
|
isMaillinglist = BMConfigParser().safeGetBoolean(addressInKeysFile, 'mailinglist')
|
2015-10-19 20:03:06 +02:00
|
|
|
if isEnabled and not isMaillinglist:
|
2017-01-11 14:27:19 +01:00
|
|
|
label = unicode(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip()
|
2016-10-25 02:47:28 +02:00
|
|
|
if label == "":
|
|
|
|
label = addressInKeysFile
|
|
|
|
self.ui.comboBoxSendFrom.addItem(avatarize(addressInKeysFile), label, addressInKeysFile)
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-10-31 20:27:28 +01:00
|
|
|
for i in range(self.ui.comboBoxSendFrom.count()):
|
2018-01-22 17:52:28 +01:00
|
|
|
address = str(self.ui.comboBoxSendFrom.itemData(
|
|
|
|
i, QtCore.Qt.UserRole).toString())
|
|
|
|
self.ui.comboBoxSendFrom.setItemData(
|
|
|
|
i, AccountColor(address).accountColor(),
|
|
|
|
QtCore.Qt.ForegroundRole)
|
2013-06-12 23:12:32 +02:00
|
|
|
self.ui.comboBoxSendFrom.insertItem(0, '', '')
|
2018-05-15 17:20:53 +02:00
|
|
|
if self.ui.comboBoxSendFrom.count() == 2:
|
2013-05-02 17:53:54 +02:00
|
|
|
self.ui.comboBoxSendFrom.setCurrentIndex(1)
|
|
|
|
else:
|
|
|
|
self.ui.comboBoxSendFrom.setCurrentIndex(0)
|
|
|
|
|
2015-03-21 11:37:08 +01:00
|
|
|
def rerenderComboBoxSendFromBroadcast(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-21 11:37:08 +01:00
|
|
|
self.ui.comboBoxSendFromBroadcast.clear()
|
2015-10-19 20:03:06 +02:00
|
|
|
for addressInKeysFile in getSortedAccounts():
|
2018-05-15 17:20:53 +02:00
|
|
|
|
|
|
|
# I realize that this is poor programming practice but I don't care. It's easier for others to read.
|
|
|
|
isEnabled = BMConfigParser().getboolean(addressInKeysFile, 'enabled')
|
2017-01-11 14:27:19 +01:00
|
|
|
isChan = BMConfigParser().safeGetBoolean(addressInKeysFile, 'chan')
|
2015-11-12 01:42:20 +01:00
|
|
|
if isEnabled and not isChan:
|
2017-01-11 14:27:19 +01:00
|
|
|
label = unicode(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip()
|
2016-10-25 02:47:28 +02:00
|
|
|
if label == "":
|
|
|
|
label = addressInKeysFile
|
|
|
|
self.ui.comboBoxSendFromBroadcast.addItem(avatarize(addressInKeysFile), label, addressInKeysFile)
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-10-31 20:27:28 +01:00
|
|
|
for i in range(self.ui.comboBoxSendFromBroadcast.count()):
|
2018-01-22 17:52:28 +01:00
|
|
|
address = str(self.ui.comboBoxSendFromBroadcast.itemData(
|
|
|
|
i, QtCore.Qt.UserRole).toString())
|
|
|
|
self.ui.comboBoxSendFromBroadcast.setItemData(
|
|
|
|
i, AccountColor(address).accountColor(),
|
|
|
|
QtCore.Qt.ForegroundRole)
|
2015-03-21 11:37:08 +01:00
|
|
|
self.ui.comboBoxSendFromBroadcast.insertItem(0, '', '')
|
2018-05-15 17:20:53 +02:00
|
|
|
if self.ui.comboBoxSendFromBroadcast.count() == 2:
|
2015-03-21 11:37:08 +01:00
|
|
|
self.ui.comboBoxSendFromBroadcast.setCurrentIndex(1)
|
|
|
|
else:
|
|
|
|
self.ui.comboBoxSendFromBroadcast.setCurrentIndex(0)
|
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
def displayNewSentMessage(self, toAddress, toLabel, fromAddress, subject, message, ackdata):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""
|
|
|
|
This function is called by the processmsg function when that function
|
|
|
|
receives a message to an address that is acting as a
|
|
|
|
pseudo-mailing-list. The message will be broadcast out. This function
|
|
|
|
puts the message on the 'Sent' tab.
|
|
|
|
"""
|
|
|
|
|
2015-10-03 12:12:18 +02:00
|
|
|
acct = accountClass(fromAddress)
|
|
|
|
acct.parseMessage(toAddress, fromAddress, subject, message)
|
2016-02-14 19:56:05 +01:00
|
|
|
tab = -1
|
2015-11-09 19:39:30 +01:00
|
|
|
for sent in [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxChans]:
|
2016-02-14 19:56:05 +01:00
|
|
|
tab += 1
|
|
|
|
if tab == 1:
|
|
|
|
tab = 2
|
2015-11-09 19:39:30 +01:00
|
|
|
treeWidget = self.widgetConvert(sent)
|
|
|
|
if self.getCurrentFolder(treeWidget) != "sent":
|
|
|
|
continue
|
2018-05-15 17:20:53 +02:00
|
|
|
if all(
|
|
|
|
[
|
|
|
|
treeWidget == self.ui.treeWidgetYourIdentities,
|
|
|
|
self.getCurrentAccount(treeWidget) not in (fromAddress, None, False),
|
|
|
|
]
|
|
|
|
):
|
2015-11-09 19:39:30 +01:00
|
|
|
continue
|
2018-05-15 17:20:53 +02:00
|
|
|
elif all(
|
|
|
|
[
|
|
|
|
treeWidget in [self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans],
|
|
|
|
self.getCurrentAccount(treeWidget) != toAddress,
|
|
|
|
]
|
|
|
|
):
|
2015-11-09 19:39:30 +01:00
|
|
|
continue
|
2018-05-15 17:20:53 +02:00
|
|
|
elif not helper_search.check_match(
|
|
|
|
toAddress,
|
|
|
|
fromAddress,
|
|
|
|
subject,
|
|
|
|
message,
|
|
|
|
self.getCurrentSearchOption(tab),
|
|
|
|
self.getCurrentSearchLine(tab),
|
|
|
|
):
|
2016-02-14 19:56:05 +01:00
|
|
|
continue
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-11-27 02:11:24 +01:00
|
|
|
self.addMessageListItemSent(sent, toAddress, fromAddress, subject, "msgqueued", ackdata, time.time())
|
2018-02-18 19:39:26 +01:00
|
|
|
self.getAccountTextedit(acct).setPlainText(unicode(message, 'utf-8', 'replace'))
|
2016-01-22 20:21:01 +01:00
|
|
|
sent.setCurrentCell(0, 0)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
def displayNewInboxMessage(self, inventoryHash, toAddress, fromAddress, subject, message):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-10-31 20:05:58 +01:00
|
|
|
if toAddress == str_broadcast_subscribers:
|
|
|
|
acct = accountClass(fromAddress)
|
|
|
|
else:
|
|
|
|
acct = accountClass(toAddress)
|
2015-10-22 23:56:20 +02:00
|
|
|
inbox = self.getAccountMessagelist(acct)
|
2015-11-27 02:11:24 +01:00
|
|
|
ret = None
|
2016-02-14 19:56:05 +01:00
|
|
|
tab = -1
|
2018-05-15 17:20:53 +02:00
|
|
|
for treeWidget in [
|
|
|
|
self.ui.treeWidgetYourIdentities,
|
|
|
|
self.ui.treeWidgetSubscriptions,
|
|
|
|
self.ui.treeWidgetChans,
|
|
|
|
]:
|
2016-02-14 19:56:05 +01:00
|
|
|
tab += 1
|
|
|
|
if tab == 1:
|
|
|
|
tab = 2
|
2015-11-27 02:11:24 +01:00
|
|
|
tableWidget = self.widgetConvert(treeWidget)
|
2018-05-15 17:20:53 +02:00
|
|
|
if not helper_search.check_match(
|
|
|
|
toAddress,
|
|
|
|
fromAddress,
|
|
|
|
subject,
|
|
|
|
message,
|
|
|
|
self.getCurrentSearchOption(tab),
|
|
|
|
self.getCurrentSearchLine(tab),
|
|
|
|
):
|
2016-02-14 19:56:05 +01:00
|
|
|
continue
|
2018-05-15 17:20:53 +02:00
|
|
|
if all(
|
|
|
|
[
|
|
|
|
tableWidget == inbox,
|
|
|
|
self.getCurrentAccount(treeWidget) == acct.address,
|
|
|
|
self.getCurrentFolder(treeWidget) in ["inbox", None],
|
|
|
|
]
|
|
|
|
):
|
|
|
|
ret = self.addMessageListItemInbox(
|
|
|
|
inbox,
|
|
|
|
"inbox",
|
|
|
|
inventoryHash,
|
|
|
|
toAddress,
|
|
|
|
fromAddress,
|
|
|
|
subject,
|
|
|
|
time.time(),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
elif treeWidget == all(
|
|
|
|
[
|
|
|
|
self.ui.treeWidgetYourIdentities,
|
|
|
|
self.getCurrentAccount(treeWidget) is None,
|
|
|
|
self.getCurrentFolder(treeWidget) in ["inbox", "new", None]
|
|
|
|
]
|
|
|
|
):
|
|
|
|
ret = self.addMessageListItemInbox(
|
|
|
|
tableWidget,
|
|
|
|
"inbox",
|
|
|
|
inventoryHash,
|
|
|
|
toAddress,
|
|
|
|
fromAddress,
|
|
|
|
subject,
|
|
|
|
time.time(),
|
|
|
|
0,
|
|
|
|
)
|
2015-11-27 02:11:24 +01:00
|
|
|
if ret is None:
|
|
|
|
acct.parseMessage(toAddress, fromAddress, subject, "")
|
|
|
|
else:
|
|
|
|
acct = ret
|
2015-10-31 20:05:58 +01:00
|
|
|
self.propagateUnreadCount(acct.address)
|
2017-03-10 00:00:54 +01:00
|
|
|
if BMConfigParser().getboolean(
|
|
|
|
'bitmessagesettings', 'showtraynotifications'):
|
|
|
|
self.notifierShow(
|
|
|
|
_translate("MainWindow", "New Message"),
|
|
|
|
_translate("MainWindow", "From %1").arg(
|
|
|
|
unicode(acct.fromLabel, 'utf-8')),
|
2017-03-15 14:56:47 +01:00
|
|
|
sound.SOUND_UNKNOWN
|
2017-03-10 00:00:54 +01:00
|
|
|
)
|
2018-05-15 17:20:53 +02:00
|
|
|
if any(
|
|
|
|
[
|
|
|
|
all(
|
|
|
|
[
|
|
|
|
self.getCurrentAccount() is not None,
|
|
|
|
self.getCurrentFolder(treeWidget) != "inbox", # pylint: disable=undefined-loop-variable
|
|
|
|
self.getCurrentFolder(treeWidget) is not None, # pylint: disable=undefined-loop-variable
|
|
|
|
]
|
|
|
|
),
|
|
|
|
self.getCurrentAccount(treeWidget) != acct.address # pylint: disable=undefined-loop-variable
|
|
|
|
]
|
|
|
|
):
|
2017-03-23 18:04:56 +01:00
|
|
|
# Ubuntu should notify of new message irespective of
|
|
|
|
# whether it's in current message list or not
|
|
|
|
self.indicatorUpdate(True, to_label=acct.toLabel)
|
|
|
|
# cannot find item to pass here ):
|
2018-05-15 17:20:53 +02:00
|
|
|
if hasattr(acct, "feedback") and acct.feedback != GatewayAccount.ALL_OK:
|
2016-02-15 08:19:45 +01:00
|
|
|
if acct.feedback == GatewayAccount.REGISTRATION_DENIED:
|
2018-01-24 16:27:51 +01:00
|
|
|
dialogs.EmailGatewayDialog(
|
|
|
|
self, BMConfigParser(), acct).exec_()
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2017-10-06 13:45:27 +02:00
|
|
|
def click_pushButtonAddAddressBook(self, dialog=None):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2017-10-06 13:45:27 +02:00
|
|
|
if not dialog:
|
2017-10-12 22:36:47 +02:00
|
|
|
dialog = dialogs.AddAddressDialog(self)
|
2018-01-24 16:27:51 +01:00
|
|
|
dialog.exec_()
|
|
|
|
try:
|
|
|
|
address, label = dialog.data
|
|
|
|
except AttributeError:
|
|
|
|
return
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
if shared.isAddressInMyAddressBook(address):
|
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Error: You cannot add the same address to your"
|
|
|
|
" address book twice. Try renaming the existing one"
|
|
|
|
" if you want."
|
|
|
|
))
|
|
|
|
return
|
|
|
|
|
|
|
|
self.addEntryToAddressBook(address, label)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2017-10-06 13:45:27 +02:00
|
|
|
def addEntryToAddressBook(self, address, label):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2017-10-12 22:36:47 +02:00
|
|
|
if shared.isAddressInMyAddressBook(address):
|
|
|
|
return
|
|
|
|
sqlExecute('''INSERT INTO addressbook VALUES (?,?)''', label, address)
|
|
|
|
self.rerenderMessagelistFromLabels()
|
|
|
|
self.rerenderMessagelistToLabels()
|
|
|
|
self.rerenderAddressBook()
|
2013-07-22 07:10:22 +02:00
|
|
|
|
|
|
|
def addSubscription(self, address, label):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2017-10-12 22:36:47 +02:00
|
|
|
# This should be handled outside of this function, for error displaying
|
|
|
|
# and such, but it must also be checked here.
|
2013-06-14 03:55:38 +02:00
|
|
|
if shared.isAddressInMySubscriptionsList(address):
|
|
|
|
return
|
2017-10-12 22:36:47 +02:00
|
|
|
# Add to database (perhaps this should be separated from the MyForm class)
|
|
|
|
sqlExecute(
|
|
|
|
'''INSERT INTO subscriptions VALUES (?,?,?)''',
|
|
|
|
label, address, True
|
|
|
|
)
|
2016-01-23 20:24:50 +01:00
|
|
|
self.rerenderMessagelistFromLabels()
|
2013-06-14 03:55:38 +02:00
|
|
|
shared.reloadBroadcastSendersForWhichImWatching()
|
2015-11-19 19:17:26 +01:00
|
|
|
self.rerenderAddressBook()
|
2015-03-23 22:35:56 +01:00
|
|
|
self.rerenderTabTreeSubscriptions()
|
2013-05-02 17:53:54 +02:00
|
|
|
|
|
|
|
def click_pushButtonAddSubscription(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2017-10-12 22:36:47 +02:00
|
|
|
dialog = dialogs.NewSubscriptionDialog(self)
|
2018-01-24 16:27:51 +01:00
|
|
|
dialog.exec_()
|
|
|
|
try:
|
|
|
|
address, label = dialog.data
|
|
|
|
except AttributeError:
|
|
|
|
return
|
|
|
|
|
|
|
|
# We must check to see if the address is already in the
|
|
|
|
# subscriptions list. The user cannot add it again or else it
|
|
|
|
# will cause problems when updating and deleting the entry.
|
|
|
|
if shared.isAddressInMySubscriptionsList(address):
|
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Error: You cannot add the same address to your"
|
|
|
|
" subscriptions twice. Perhaps rename the existing one"
|
|
|
|
" if you want."
|
|
|
|
))
|
|
|
|
return
|
|
|
|
|
|
|
|
self.addSubscription(address, label)
|
|
|
|
# Now, if the user wants to display old broadcasts, let's get
|
|
|
|
# them out of the inventory and put them
|
|
|
|
# to the objectProcessorQueue to be processed
|
|
|
|
if dialog.checkBoxDisplayMessagesAlreadyInInventory.isChecked():
|
|
|
|
for value in dialog.recent:
|
|
|
|
queues.objectProcessorQueue.put((
|
|
|
|
value.type, value.payload
|
2018-01-23 17:15:11 +01:00
|
|
|
))
|
2013-05-02 17:53:54 +02:00
|
|
|
|
|
|
|
def click_pushButtonStatusIcon(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2017-10-13 00:36:54 +02:00
|
|
|
dialogs.IconGlossaryDialog(self, config=BMConfigParser()).exec_()
|
2013-05-02 17:53:54 +02:00
|
|
|
|
|
|
|
def click_actionHelp(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2017-10-16 15:09:52 +02:00
|
|
|
dialogs.HelpDialog(self).exec_()
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2015-12-16 00:58:52 +01:00
|
|
|
def click_actionSupport(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-12-16 00:58:52 +01:00
|
|
|
support.createSupportMessage(self)
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def click_actionAbout(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2017-10-13 00:36:54 +02:00
|
|
|
dialogs.AboutDialog(self).exec_()
|
2013-05-02 17:53:54 +02:00
|
|
|
|
|
|
|
def click_actionSettings(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
self.settingsDialogInstance = settingsDialog(self)
|
2017-03-28 16:38:05 +02:00
|
|
|
if self._firstrun:
|
|
|
|
self.settingsDialogInstance.ui.tabWidgetSettings.setCurrentIndex(1)
|
2013-05-02 17:53:54 +02:00
|
|
|
if self.settingsDialogInstance.exec_():
|
2017-03-28 16:38:05 +02:00
|
|
|
if self._firstrun:
|
|
|
|
BMConfigParser().remove_option(
|
|
|
|
'bitmessagesettings', 'dontconnect')
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'startonlogon', str(
|
2013-06-12 23:12:32 +02:00
|
|
|
self.settingsDialogInstance.ui.checkBoxStartOnLogon.isChecked()))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'minimizetotray', str(
|
2013-06-12 23:12:32 +02:00
|
|
|
self.settingsDialogInstance.ui.checkBoxMinimizeToTray.isChecked()))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'trayonclose', str(
|
2016-03-01 02:50:31 +01:00
|
|
|
self.settingsDialogInstance.ui.checkBoxTrayOnClose.isChecked()))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'hidetrayconnectionnotifications', str(
|
2016-10-07 01:58:40 +02:00
|
|
|
self.settingsDialogInstance.ui.checkBoxHideTrayConnectionNotifications.isChecked()))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'showtraynotifications', str(
|
2013-06-12 23:12:32 +02:00
|
|
|
self.settingsDialogInstance.ui.checkBoxShowTrayNotifications.isChecked()))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'startintray', str(
|
2013-06-12 23:12:32 +02:00
|
|
|
self.settingsDialogInstance.ui.checkBoxStartInTray.isChecked()))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'willinglysendtomobile', str(
|
2013-08-08 21:37:48 +02:00
|
|
|
self.settingsDialogInstance.ui.checkBoxWillinglySendToMobile.isChecked()))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'useidenticons', str(
|
2013-11-02 00:25:24 +01:00
|
|
|
self.settingsDialogInstance.ui.checkBoxUseIdenticons.isChecked()))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'replybelow', str(
|
2014-01-28 20:57:01 +01:00
|
|
|
self.settingsDialogInstance.ui.checkBoxReplyBelow.isChecked()))
|
2018-05-15 17:20:53 +02:00
|
|
|
|
|
|
|
lang = str(self.settingsDialogInstance.ui.languageComboBox.itemData(
|
|
|
|
self.settingsDialogInstance.ui.languageComboBox.currentIndex()).toString())
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'userlocale', lang)
|
2016-08-14 12:01:00 +02:00
|
|
|
change_translation(l10n.getTranslationLanguage())
|
2018-05-15 17:20:53 +02:00
|
|
|
|
|
|
|
if int(BMConfigParser().get('bitmessagesettings', 'port')) != int(
|
|
|
|
self.settingsDialogInstance.ui.lineEditTCPPort.text()):
|
2017-01-11 14:27:19 +01:00
|
|
|
if not BMConfigParser().safeGetBoolean('bitmessagesettings', 'dontconnect'):
|
2018-01-22 17:52:28 +01:00
|
|
|
QtGui.QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate(
|
2013-07-24 17:46:28 +02:00
|
|
|
"MainWindow", "You must restart Bitmessage for the port number change to take effect."))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'port', str(
|
2013-06-12 23:12:32 +02:00
|
|
|
self.settingsDialogInstance.ui.lineEditTCPPort.text()))
|
2018-05-15 17:20:53 +02:00
|
|
|
if self.settingsDialogInstance.ui.checkBoxUPnP.isChecked() != BMConfigParser().safeGetBoolean(
|
|
|
|
'bitmessagesettings', 'upnp'
|
|
|
|
):
|
|
|
|
|
|
|
|
BMConfigParser().set(
|
|
|
|
'bitmessagesettings', 'upnp',
|
|
|
|
str(self.settingsDialogInstance.ui.checkBoxUPnP.isChecked()))
|
2015-11-22 13:02:06 +01:00
|
|
|
if self.settingsDialogInstance.ui.checkBoxUPnP.isChecked():
|
|
|
|
upnpThread = upnp.uPnPThread()
|
|
|
|
upnpThread.start()
|
2018-05-15 17:20:53 +02:00
|
|
|
|
|
|
|
if all(
|
|
|
|
[
|
|
|
|
BMConfigParser().get(
|
|
|
|
'bitmessagesettings',
|
|
|
|
'socksproxytype') == 'none',
|
|
|
|
self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] == 'SOCKS',
|
|
|
|
]
|
|
|
|
):
|
2013-05-02 17:53:54 +02:00
|
|
|
if shared.statusIconColor != 'red':
|
2018-05-15 17:20:53 +02:00
|
|
|
QtGui.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 (if any).")))
|
|
|
|
|
|
|
|
if all(
|
|
|
|
[
|
|
|
|
BMConfigParser().get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS',
|
|
|
|
self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] != 'SOCKS',
|
|
|
|
]
|
|
|
|
):
|
2018-01-23 17:15:11 +01:00
|
|
|
self.statusbar.clearMessage()
|
2018-05-15 17:20:53 +02:00
|
|
|
state.resetNetworkProtocolAvailability() # just in case we changed something in the network connectivity
|
2013-08-28 04:29:39 +02:00
|
|
|
if self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] == 'SOCKS':
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'socksproxytype', str(
|
2013-08-28 04:29:39 +02:00
|
|
|
self.settingsDialogInstance.ui.comboBoxProxyType.currentText()))
|
|
|
|
else:
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'socksproxytype', 'none')
|
|
|
|
BMConfigParser().set('bitmessagesettings', 'socksauthentication', str(
|
2013-06-12 23:12:32 +02:00
|
|
|
self.settingsDialogInstance.ui.checkBoxAuthentication.isChecked()))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'sockshostname', str(
|
2013-06-12 23:12:32 +02:00
|
|
|
self.settingsDialogInstance.ui.lineEditSocksHostname.text()))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'socksport', str(
|
2013-06-12 23:12:32 +02:00
|
|
|
self.settingsDialogInstance.ui.lineEditSocksPort.text()))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'socksusername', str(
|
2013-06-12 23:12:32 +02:00
|
|
|
self.settingsDialogInstance.ui.lineEditSocksUsername.text()))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'sockspassword', str(
|
2013-06-12 23:12:32 +02:00
|
|
|
self.settingsDialogInstance.ui.lineEditSocksPassword.text()))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'sockslisten', str(
|
2013-07-12 20:03:09 +02:00
|
|
|
self.settingsDialogInstance.ui.checkBoxSocksListen.isChecked()))
|
2014-09-10 22:47:51 +02:00
|
|
|
try:
|
|
|
|
# Rounding to integers just for aesthetics
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'maxdownloadrate', str(
|
2014-09-10 22:47:51 +02:00
|
|
|
int(float(self.settingsDialogInstance.ui.lineEditMaxDownloadRate.text()))))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'maxuploadrate', str(
|
2014-09-10 22:47:51 +02:00
|
|
|
int(float(self.settingsDialogInstance.ui.lineEditMaxUploadRate.text()))))
|
2018-01-01 12:49:08 +01:00
|
|
|
except ValueError:
|
2018-01-22 17:52:28 +01:00
|
|
|
QtGui.QMessageBox.about(self, _translate("MainWindow", "Number needed"), _translate(
|
2014-09-10 22:47:51 +02:00
|
|
|
"MainWindow", "Your maximum download and upload rate must be numbers. Ignoring what you typed."))
|
2018-01-01 12:49:08 +01:00
|
|
|
else:
|
|
|
|
set_rates(BMConfigParser().safeGetInt("bitmessagesettings", "maxdownloadrate"),
|
2018-05-15 17:20:53 +02:00
|
|
|
BMConfigParser().safeGetInt("bitmessagesettings", "maxuploadrate"))
|
2017-01-13 02:12:11 +01:00
|
|
|
|
|
|
|
BMConfigParser().set('bitmessagesettings', 'maxoutboundconnections', str(
|
|
|
|
int(float(self.settingsDialogInstance.ui.lineEditMaxOutboundConnections.text()))))
|
|
|
|
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'namecoinrpctype',
|
2018-05-15 17:20:53 +02:00
|
|
|
self.settingsDialogInstance.getNamecoinType())
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'namecoinrpchost', str(
|
2013-07-07 17:34:43 +02:00
|
|
|
self.settingsDialogInstance.ui.lineEditNamecoinHost.text()))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'namecoinrpcport', str(
|
2013-07-07 17:34:43 +02:00
|
|
|
self.settingsDialogInstance.ui.lineEditNamecoinPort.text()))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'namecoinrpcuser', str(
|
2013-07-07 17:34:43 +02:00
|
|
|
self.settingsDialogInstance.ui.lineEditNamecoinUser.text()))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'namecoinrpcpassword', str(
|
2013-07-07 17:34:43 +02:00
|
|
|
self.settingsDialogInstance.ui.lineEditNamecoinPassword.text()))
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2014-09-10 22:47:51 +02:00
|
|
|
# Demanded difficulty tab
|
2013-05-02 17:53:54 +02:00
|
|
|
if float(self.settingsDialogInstance.ui.lineEditTotalDifficulty.text()) >= 1:
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'defaultnoncetrialsperbyte', str(int(float(
|
2018-05-15 17:20:53 +02:00
|
|
|
self.settingsDialogInstance.ui.lineEditTotalDifficulty.text()
|
|
|
|
) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
2013-05-02 17:53:54 +02:00
|
|
|
if float(self.settingsDialogInstance.ui.lineEditSmallMessageDifficulty.text()) >= 1:
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'defaultpayloadlengthextrabytes', str(int(float(
|
2018-05-15 17:20:53 +02:00
|
|
|
self.settingsDialogInstance.ui.lineEditSmallMessageDifficulty.text()
|
|
|
|
) * defaults.networkDefaultPayloadLengthExtraBytes)))
|
|
|
|
|
|
|
|
if self.settingsDialogInstance.ui.comboBoxOpenCL.currentText().toUtf8(
|
|
|
|
) != BMConfigParser().safeGet("bitmessagesettings", "opencl"):
|
|
|
|
BMConfigParser().set(
|
|
|
|
'bitmessagesettings', 'opencl',
|
|
|
|
str(self.settingsDialogInstance.ui.comboBoxOpenCL.currentText()))
|
2017-02-28 22:59:44 +01:00
|
|
|
queues.workerQueue.put(('resetPoW', ''))
|
2015-11-26 02:37:07 +01:00
|
|
|
|
2014-10-15 23:16:27 +02:00
|
|
|
acceptableDifficultyChanged = False
|
2018-05-15 17:20:53 +02:00
|
|
|
|
|
|
|
if any(
|
|
|
|
[
|
|
|
|
float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) >= 1,
|
|
|
|
float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) == 0,
|
|
|
|
]
|
|
|
|
):
|
|
|
|
if BMConfigParser().get(
|
|
|
|
'bitmessagesettings',
|
|
|
|
'maxacceptablenoncetrialsperbyte',
|
|
|
|
) != str(
|
|
|
|
int(
|
|
|
|
float(
|
|
|
|
self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()
|
|
|
|
) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte
|
|
|
|
)
|
|
|
|
):
|
2014-10-15 23:16:27 +02:00
|
|
|
# the user changed the max acceptable total difficulty
|
|
|
|
acceptableDifficultyChanged = True
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'maxacceptablenoncetrialsperbyte', str(int(float(
|
2018-05-15 17:20:53 +02:00
|
|
|
self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()
|
|
|
|
) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
|
|
|
|
|
|
|
if any(
|
|
|
|
[
|
|
|
|
float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1,
|
|
|
|
float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0,
|
|
|
|
]
|
|
|
|
):
|
|
|
|
if BMConfigParser().get(
|
|
|
|
'bitmessagesettings',
|
|
|
|
'maxacceptablepayloadlengthextrabytes',
|
|
|
|
) != str(
|
|
|
|
int(
|
|
|
|
float(
|
|
|
|
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()
|
|
|
|
) * defaults.networkDefaultPayloadLengthExtraBytes
|
|
|
|
)
|
|
|
|
):
|
2014-10-15 23:16:27 +02:00
|
|
|
# the user changed the max acceptable small message difficulty
|
|
|
|
acceptableDifficultyChanged = True
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', str(int(float(
|
2018-05-15 17:20:53 +02:00
|
|
|
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()
|
|
|
|
) * defaults.networkDefaultPayloadLengthExtraBytes)))
|
2014-10-15 23:16:27 +02:00
|
|
|
if acceptableDifficultyChanged:
|
2018-05-15 17:20:53 +02:00
|
|
|
# It might now be possible to send msgs which were previously marked as toodifficult.
|
2014-10-15 23:16:27 +02:00
|
|
|
# Let us change them to 'msgqueued'. The singleWorker will try to send them and will again
|
|
|
|
# mark them as toodifficult if the receiver's required difficulty is still higher than
|
|
|
|
# we are willing to do.
|
|
|
|
sqlExecute('''UPDATE sent SET status='msgqueued' WHERE status='toodifficult' ''')
|
2017-02-08 13:41:56 +01:00
|
|
|
queues.workerQueue.put(('sendmessage', ''))
|
2018-05-15 17:20:53 +02:00
|
|
|
|
|
|
|
# start:UI setting to stop trying to send messages after X days/months
|
2013-11-04 08:05:07 +01:00
|
|
|
# I'm open to changing this UI to something else if someone has a better idea.
|
2018-05-15 17:20:53 +02:00
|
|
|
if all(
|
|
|
|
[
|
|
|
|
self.settingsDialogInstance.ui.lineEditDays.text() == '',
|
|
|
|
self.settingsDialogInstance.ui.lineEditMonths.text() == '',
|
|
|
|
]
|
|
|
|
): # We need to handle this special case. Bitmessage has its default behavior. The input is blank/blank
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxdays', '')
|
|
|
|
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxmonths', '')
|
2013-11-04 08:05:07 +01:00
|
|
|
shared.maximumLengthOfTimeToBotherResendingMessages = float('inf')
|
2013-11-06 05:22:51 +01:00
|
|
|
try:
|
|
|
|
float(self.settingsDialogInstance.ui.lineEditDays.text())
|
|
|
|
lineEditDaysIsValidFloat = True
|
|
|
|
except:
|
|
|
|
lineEditDaysIsValidFloat = False
|
|
|
|
try:
|
|
|
|
float(self.settingsDialogInstance.ui.lineEditMonths.text())
|
|
|
|
lineEditMonthsIsValidFloat = True
|
|
|
|
except:
|
|
|
|
lineEditMonthsIsValidFloat = False
|
|
|
|
if lineEditDaysIsValidFloat and not lineEditMonthsIsValidFloat:
|
|
|
|
self.settingsDialogInstance.ui.lineEditMonths.setText("0")
|
|
|
|
if lineEditMonthsIsValidFloat and not lineEditDaysIsValidFloat:
|
|
|
|
self.settingsDialogInstance.ui.lineEditDays.setText("0")
|
|
|
|
if lineEditDaysIsValidFloat or lineEditMonthsIsValidFloat:
|
2018-05-15 17:20:53 +02:00
|
|
|
if all(
|
|
|
|
[
|
|
|
|
float(self.settingsDialogInstance.ui.lineEditDays.text()) >= 0,
|
|
|
|
float(self.settingsDialogInstance.ui.lineEditMonths.text()) >= 0,
|
|
|
|
]
|
|
|
|
):
|
|
|
|
shared.maximumLengthOfTimeToBotherResendingMessages = sum(
|
|
|
|
float(str(self.settingsDialogInstance.ui.lineEditDays.text())) * 24 * 60 * 60,
|
|
|
|
float(str(self.settingsDialogInstance.ui.lineEditMonths.text())) * (60 * 60 * 24 * 365) / 12,
|
|
|
|
)
|
|
|
|
# If the time period is less than 5 hours, we give zero values to all
|
|
|
|
# fields. No message will be sent again.
|
|
|
|
if shared.maximumLengthOfTimeToBotherResendingMessages < 432000:
|
|
|
|
QtGui.QMessageBox.about(
|
|
|
|
self,
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Will not resend ever"),
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
("Note that the time limit you entered is less than the amount of time Bitmessage "
|
|
|
|
"waits for the first resend attempt therefore your messages will never be resent.")))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxdays', '0')
|
|
|
|
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxmonths', '0')
|
2013-11-06 05:22:51 +01:00
|
|
|
shared.maximumLengthOfTimeToBotherResendingMessages = 0
|
|
|
|
else:
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxdays', str(float(
|
2018-05-15 17:20:53 +02:00
|
|
|
self.settingsDialogInstance.ui.lineEditDays.text())))
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxmonths', str(float(
|
2018-05-15 17:20:53 +02:00
|
|
|
self.settingsDialogInstance.ui.lineEditMonths.text())))
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2017-01-15 10:50:02 +01:00
|
|
|
BMConfigParser().save()
|
2013-05-02 17:53:54 +02:00
|
|
|
|
|
|
|
if 'win32' in sys.platform or 'win64' in sys.platform:
|
2018-05-15 17:20:53 +02:00
|
|
|
# Auto-startup for Windows
|
2013-05-02 17:53:54 +02:00
|
|
|
RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"
|
2018-02-09 11:11:48 +01:00
|
|
|
self.settings = QtCore.QSettings(RUN_PATH, QtCore.QSettings.NativeFormat)
|
2017-01-11 14:27:19 +01:00
|
|
|
if BMConfigParser().getboolean('bitmessagesettings', 'startonlogon'):
|
2013-06-12 23:12:32 +02:00
|
|
|
self.settings.setValue("PyBitmessage", sys.argv[0])
|
2013-05-02 17:53:54 +02:00
|
|
|
else:
|
|
|
|
self.settings.remove("PyBitmessage")
|
|
|
|
elif 'darwin' in sys.platform:
|
2013-06-12 23:12:32 +02:00
|
|
|
# startup for mac
|
2013-05-02 17:53:54 +02:00
|
|
|
pass
|
|
|
|
elif 'linux' in sys.platform:
|
2013-06-12 23:12:32 +02:00
|
|
|
# startup for linux
|
2013-05-02 17:53:54 +02:00
|
|
|
pass
|
|
|
|
|
2018-05-15 17:20:53 +02:00
|
|
|
# If we are NOT using portable mode now but the user selected that we should...
|
|
|
|
if state.appdata != paths.lookupExeFolder():
|
|
|
|
if self.settingsDialogInstance.ui.checkBoxPortableMode.isChecked():
|
|
|
|
|
|
|
|
# Write the keys.dat file to disk in the new location
|
|
|
|
sqlStoredProcedure('movemessagstoprog')
|
|
|
|
with open(paths.lookupExeFolder() + 'keys.dat', 'wb') as configfile:
|
|
|
|
BMConfigParser().write(configfile)
|
|
|
|
# Write the knownnodes.dat file to disk in the new location
|
|
|
|
knownnodes.saveKnownNodes(paths.lookupExeFolder())
|
|
|
|
os.remove(state.appdata + 'keys.dat')
|
|
|
|
os.remove(state.appdata + 'knownnodes.dat')
|
|
|
|
previousAppdataLocation = state.appdata
|
|
|
|
state.appdata = paths.lookupExeFolder()
|
|
|
|
debug.restartLoggingInUpdatedAppdataLocation()
|
|
|
|
try:
|
|
|
|
os.remove(previousAppdataLocation + 'debug.log')
|
|
|
|
os.remove(previousAppdataLocation + 'debug.log.1')
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
# If we ARE using portable mode now but the user selected that we shouldn't...
|
|
|
|
if state.appdata == paths.lookupExeFolder():
|
|
|
|
if not self.settingsDialogInstance.ui.checkBoxPortableMode.isChecked():
|
|
|
|
|
|
|
|
state.appdata = paths.lookupAppdataFolder()
|
|
|
|
if not os.path.exists(state.appdata):
|
|
|
|
os.makedirs(state.appdata)
|
|
|
|
sqlStoredProcedure('movemessagstoappdata')
|
|
|
|
# Write the keys.dat file to disk in the new location
|
|
|
|
BMConfigParser().save()
|
|
|
|
# Write the knownnodes.dat file to disk in the new location
|
|
|
|
knownnodes.saveKnownNodes(state.appdata)
|
|
|
|
os.remove(paths.lookupExeFolder() + 'keys.dat')
|
|
|
|
os.remove(paths.lookupExeFolder() + 'knownnodes.dat')
|
|
|
|
debug.restartLoggingInUpdatedAppdataLocation()
|
|
|
|
try:
|
|
|
|
os.remove(paths.lookupExeFolder() + 'debug.log')
|
|
|
|
os.remove(paths.lookupExeFolder() + 'debug.log.1')
|
|
|
|
except:
|
|
|
|
pass
|
2013-05-02 17:53:54 +02:00
|
|
|
|
|
|
|
def on_action_SpecialAddressBehaviorDialog(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2017-10-17 17:00:27 +02:00
|
|
|
dialogs.SpecialAddressBehaviorDialog(self, BMConfigParser())
|
2015-03-21 11:37:08 +01:00
|
|
|
|
2015-10-03 17:24:21 +02:00
|
|
|
def on_action_EmailGatewayDialog(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2018-01-19 15:26:07 +01:00
|
|
|
dialog = dialogs.EmailGatewayDialog(self, config=BMConfigParser())
|
2015-10-03 17:24:21 +02:00
|
|
|
# For Modal dialogs
|
2018-01-24 16:27:51 +01:00
|
|
|
dialog.exec_()
|
|
|
|
try:
|
|
|
|
acct = dialog.data
|
|
|
|
except AttributeError:
|
|
|
|
return
|
2018-01-19 15:26:07 +01:00
|
|
|
|
2018-01-24 16:27:51 +01:00
|
|
|
# Only settings remain here
|
|
|
|
acct.settings()
|
|
|
|
for i in range(self.ui.comboBoxSendFrom.count()):
|
|
|
|
if str(self.ui.comboBoxSendFrom.itemData(i).toPyObject()) \
|
|
|
|
== acct.fromAddress:
|
|
|
|
self.ui.comboBoxSendFrom.setCurrentIndex(i)
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.ui.comboBoxSendFrom.setCurrentIndex(0)
|
|
|
|
|
|
|
|
self.ui.lineEditTo.setText(acct.toAddress)
|
|
|
|
self.ui.lineEditSubject.setText(acct.subject)
|
|
|
|
self.ui.textEditMessage.setText(acct.message)
|
|
|
|
self.ui.tabWidgetSend.setCurrentIndex(
|
|
|
|
self.ui.tabWidgetSend.indexOf(self.ui.sendDirect)
|
|
|
|
)
|
|
|
|
self.ui.tabWidget.setCurrentIndex(
|
|
|
|
self.ui.tabWidget.indexOf(self.ui.send)
|
|
|
|
)
|
|
|
|
self.ui.textEditMessage.setFocus()
|
2016-08-20 22:38:36 +02:00
|
|
|
|
|
|
|
def on_action_MarkAllRead(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2018-01-25 22:04:38 +01:00
|
|
|
if QtGui.QMessageBox.question(
|
|
|
|
self, "Marking all messages as read?",
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Are you sure you would like to mark all messages read?"
|
2018-01-22 17:52:28 +01:00
|
|
|
), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
|
|
|
|
) != QtGui.QMessageBox.Yes:
|
2016-08-20 22:38:36 +02:00
|
|
|
return
|
2018-02-06 14:48:56 +01:00
|
|
|
# addressAtCurrentRow = self.getCurrentAccount()
|
2016-08-20 22:38:36 +02:00
|
|
|
tableWidget = self.getCurrentMessagelist()
|
|
|
|
|
2018-01-25 22:04:38 +01:00
|
|
|
idCount = tableWidget.rowCount()
|
|
|
|
if idCount == 0:
|
2016-08-20 22:38:36 +02:00
|
|
|
return
|
|
|
|
|
2018-01-22 17:52:28 +01:00
|
|
|
font = QtGui.QFont()
|
2016-08-20 22:38:36 +02:00
|
|
|
font.setBold(False)
|
|
|
|
|
2018-01-25 22:04:38 +01:00
|
|
|
msgids = []
|
|
|
|
for i in range(0, idCount):
|
2016-08-20 22:38:36 +02:00
|
|
|
msgids.append(str(tableWidget.item(
|
2018-01-22 17:52:28 +01:00
|
|
|
i, 3).data(QtCore.Qt.UserRole).toPyObject()))
|
2016-08-20 22:38:36 +02:00
|
|
|
tableWidget.item(i, 0).setUnread(False)
|
|
|
|
tableWidget.item(i, 1).setUnread(False)
|
|
|
|
tableWidget.item(i, 2).setUnread(False)
|
|
|
|
tableWidget.item(i, 3).setFont(font)
|
|
|
|
|
2018-01-25 22:04:38 +01:00
|
|
|
markread = sqlExecuteChunked(
|
|
|
|
"UPDATE %s SET read = 1 WHERE %s IN({0}) AND read=0" % (
|
|
|
|
('sent', 'ackdata') if self.getCurrentFolder() == 'sent'
|
|
|
|
else ('inbox', 'msgid')
|
|
|
|
), idCount, *msgids
|
|
|
|
)
|
2016-08-20 22:38:36 +02:00
|
|
|
|
|
|
|
if markread > 0:
|
2018-02-06 14:48:56 +01:00
|
|
|
self.propagateUnreadCount()
|
2018-05-15 17:20:53 +02:00
|
|
|
# addressAtCurrentRow, self.getCurrentFolder(), None, 0)
|
2016-08-20 22:38:36 +02:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def click_NewAddressDialog(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2018-01-24 16:27:51 +01:00
|
|
|
dialogs.NewAddressDialog(self)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2018-01-24 17:37:05 +01:00
|
|
|
def network_switch(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2018-01-24 17:37:05 +01:00
|
|
|
dontconnect_option = not BMConfigParser().safeGetBoolean(
|
|
|
|
'bitmessagesettings', 'dontconnect')
|
|
|
|
BMConfigParser().set(
|
|
|
|
'bitmessagesettings', 'dontconnect', str(dontconnect_option))
|
|
|
|
BMConfigParser().save()
|
|
|
|
self.ui.updateNetworkSwitchMenuLabel(dontconnect_option)
|
|
|
|
|
2018-03-08 11:57:39 +01:00
|
|
|
self.ui.pushButtonFetchNamecoinID.setHidden(
|
|
|
|
dontconnect_option or self.namecoin.test()[0] == 'failed'
|
|
|
|
)
|
|
|
|
|
2013-05-13 15:02:10 +02:00
|
|
|
def quit(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Quit selected from menu or application indicator"""
|
2016-04-20 15:33:01 +02:00
|
|
|
|
2017-01-16 23:38:18 +01:00
|
|
|
if self.quitAccepted:
|
|
|
|
return
|
|
|
|
|
2016-10-05 20:06:47 +02:00
|
|
|
self.show()
|
|
|
|
self.raise_()
|
|
|
|
self.activateWindow()
|
|
|
|
|
|
|
|
waitForPow = True
|
2016-10-20 16:06:46 +02:00
|
|
|
waitForConnection = False
|
|
|
|
waitForSync = False
|
2016-10-05 20:06:47 +02:00
|
|
|
|
|
|
|
# C PoW currently doesn't support interrupting and OpenCL is untested
|
2018-03-13 07:32:23 +01:00
|
|
|
if getPowType() == "python" and (powQueueSize() > 0 or pendingUpload() > 0):
|
2018-05-15 17:20:53 +02:00
|
|
|
reply = QtGui.QMessageBox.question(
|
|
|
|
self,
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Proof of work pending"),
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"%n object(s) pending proof of work",
|
|
|
|
None,
|
|
|
|
QtCore.QCoreApplication.CodecForTr,
|
|
|
|
powQueueSize()) +
|
|
|
|
", " +
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"%n object(s) waiting to be distributed",
|
|
|
|
None,
|
|
|
|
QtCore.QCoreApplication.CodecForTr,
|
|
|
|
pendingUpload()) +
|
|
|
|
"\n\n" +
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Wait until these tasks finish?"),
|
|
|
|
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No | QtGui.QMessageBox.Cancel,
|
|
|
|
QtGui.QMessageBox.Cancel)
|
2016-10-05 20:06:47 +02:00
|
|
|
if reply == QtGui.QMessageBox.No:
|
|
|
|
waitForPow = False
|
2017-11-30 19:44:03 +01:00
|
|
|
elif reply == QtGui.QMessageBox.Cancel:
|
2016-10-20 16:06:46 +02:00
|
|
|
return
|
|
|
|
|
2018-03-13 07:32:23 +01:00
|
|
|
if pendingDownload() > 0:
|
2018-05-15 17:20:53 +02:00
|
|
|
reply = QtGui.QMessageBox.question(
|
|
|
|
self,
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Synchronisation pending"),
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
("Bitmessage hasn't synchronised with the network, %n object(s) to be downloaded. If you quit "
|
|
|
|
"now, it may cause delivery delays. Wait until the synchronisation finishes?"),
|
|
|
|
None,
|
|
|
|
QtCore.QCoreApplication.CodecForTr,
|
|
|
|
pendingDownload()),
|
|
|
|
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No | QtGui.QMessageBox.Cancel,
|
|
|
|
QtGui.QMessageBox.Cancel)
|
2016-10-20 16:06:46 +02:00
|
|
|
if reply == QtGui.QMessageBox.Yes:
|
|
|
|
waitForSync = True
|
|
|
|
elif reply == QtGui.QMessageBox.Cancel:
|
|
|
|
return
|
|
|
|
|
2018-01-30 17:42:10 +01:00
|
|
|
if shared.statusIconColor == 'red' and not BMConfigParser().safeGetBoolean(
|
|
|
|
'bitmessagesettings', 'dontconnect'):
|
2018-05-15 17:20:53 +02:00
|
|
|
reply = QtGui.QMessageBox.question(
|
|
|
|
self,
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Not connected"),
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
("Bitmessage isn't connected to the network. If you quit now, it may cause delivery delays. "
|
|
|
|
"Wait until connected and the synchronisation finishes?")),
|
|
|
|
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No | QtGui.QMessageBox.Cancel,
|
|
|
|
QtGui.QMessageBox.Cancel)
|
2016-10-20 16:06:46 +02:00
|
|
|
if reply == QtGui.QMessageBox.Yes:
|
|
|
|
waitForConnection = True
|
|
|
|
waitForSync = True
|
|
|
|
elif reply == QtGui.QMessageBox.Cancel:
|
|
|
|
return
|
|
|
|
|
2017-01-16 23:38:18 +01:00
|
|
|
self.quitAccepted = True
|
|
|
|
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow", "Shutting down PyBitmessage... %1%").arg(0))
|
2016-10-20 16:06:46 +02:00
|
|
|
|
|
|
|
if waitForConnection:
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
2016-10-20 16:06:46 +02:00
|
|
|
"MainWindow", "Waiting for network connection..."))
|
|
|
|
while shared.statusIconColor == 'red':
|
|
|
|
time.sleep(0.5)
|
2018-01-23 17:15:11 +01:00
|
|
|
QtCore.QCoreApplication.processEvents(
|
|
|
|
QtCore.QEventLoop.AllEvents, 1000
|
|
|
|
)
|
2016-10-20 16:06:46 +02:00
|
|
|
|
2018-05-15 17:20:53 +02:00
|
|
|
# this probably will not work correctly, because there is a delay between
|
|
|
|
# the status icon turning red and inventory exchange, but it's better than
|
|
|
|
# nothing.
|
2016-10-20 16:06:46 +02:00
|
|
|
if waitForSync:
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
2016-10-20 16:06:46 +02:00
|
|
|
"MainWindow", "Waiting for finishing synchronisation..."))
|
2018-03-13 07:32:23 +01:00
|
|
|
while pendingDownload() > 0:
|
2016-10-20 16:06:46 +02:00
|
|
|
time.sleep(0.5)
|
2018-01-23 17:15:11 +01:00
|
|
|
QtCore.QCoreApplication.processEvents(
|
|
|
|
QtCore.QEventLoop.AllEvents, 1000
|
|
|
|
)
|
2016-10-05 20:06:47 +02:00
|
|
|
|
|
|
|
if waitForPow:
|
|
|
|
# check if PoW queue empty
|
|
|
|
maxWorkerQueue = 0
|
|
|
|
curWorkerQueue = powQueueSize()
|
|
|
|
while curWorkerQueue > 0:
|
|
|
|
# worker queue size
|
|
|
|
curWorkerQueue = powQueueSize()
|
|
|
|
if curWorkerQueue > maxWorkerQueue:
|
|
|
|
maxWorkerQueue = curWorkerQueue
|
|
|
|
if curWorkerQueue > 0:
|
2018-05-15 17:20:53 +02:00
|
|
|
self.updateStatusBar(
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Waiting for PoW to finish... %1%",
|
|
|
|
).arg(50 * (maxWorkerQueue - curWorkerQueue) / maxWorkerQueue)
|
2018-01-23 17:15:11 +01:00
|
|
|
)
|
2016-10-05 20:06:47 +02:00
|
|
|
time.sleep(0.5)
|
2018-01-23 17:15:11 +01:00
|
|
|
QtCore.QCoreApplication.processEvents(
|
|
|
|
QtCore.QEventLoop.AllEvents, 1000
|
|
|
|
)
|
|
|
|
|
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow", "Shutting down Pybitmessage... %1%").arg(50))
|
|
|
|
|
|
|
|
QtCore.QCoreApplication.processEvents(
|
|
|
|
QtCore.QEventLoop.AllEvents, 1000
|
|
|
|
)
|
2016-10-05 20:06:47 +02:00
|
|
|
if maxWorkerQueue > 0:
|
2018-01-23 17:15:11 +01:00
|
|
|
# a bit of time so that the hashHolder is populated
|
|
|
|
time.sleep(0.5)
|
|
|
|
QtCore.QCoreApplication.processEvents(
|
|
|
|
QtCore.QEventLoop.AllEvents, 1000
|
|
|
|
)
|
|
|
|
|
2017-01-19 19:48:12 +01:00
|
|
|
# check if upload (of objects created locally) pending
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow", "Waiting for objects to be sent... %1%").arg(50))
|
2018-03-13 07:32:23 +01:00
|
|
|
maxPendingUpload = max(1, pendingUpload())
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2018-03-13 07:32:23 +01:00
|
|
|
while pendingUpload() > 1:
|
2018-05-15 17:20:53 +02:00
|
|
|
self.updateStatusBar(
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Waiting for objects to be sent... %1%"
|
|
|
|
).arg(int(50 + 20 * (pendingUpload() / maxPendingUpload)))
|
2018-03-13 07:32:23 +01:00
|
|
|
)
|
|
|
|
time.sleep(0.5)
|
|
|
|
QtCore.QCoreApplication.processEvents(
|
|
|
|
QtCore.QEventLoop.AllEvents, 1000
|
|
|
|
)
|
2016-10-05 20:06:47 +02:00
|
|
|
|
2018-01-23 17:15:11 +01:00
|
|
|
QtCore.QCoreApplication.processEvents(
|
|
|
|
QtCore.QEventLoop.AllEvents, 1000
|
|
|
|
)
|
|
|
|
QtCore.QCoreApplication.processEvents(
|
|
|
|
QtCore.QEventLoop.AllEvents, 1000
|
|
|
|
)
|
2016-04-20 15:33:01 +02:00
|
|
|
|
2015-11-14 21:07:46 +01:00
|
|
|
# save state and geometry self and all widgets
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow", "Saving settings... %1%").arg(70))
|
|
|
|
QtCore.QCoreApplication.processEvents(
|
|
|
|
QtCore.QEventLoop.AllEvents, 1000
|
|
|
|
)
|
2015-11-14 21:07:46 +01:00
|
|
|
self.saveSettings()
|
|
|
|
for attr, obj in self.ui.__dict__.iteritems():
|
2018-01-23 17:15:11 +01:00
|
|
|
if hasattr(obj, "__class__") \
|
|
|
|
and isinstance(obj, settingsmixin.SettingsMixin):
|
2015-11-14 21:07:46 +01:00
|
|
|
saveMethod = getattr(obj, "saveSettings", None)
|
2018-01-23 17:15:11 +01:00
|
|
|
if callable(saveMethod):
|
2015-11-14 21:07:46 +01:00
|
|
|
obj.saveSettings()
|
|
|
|
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow", "Shutting down core... %1%").arg(80))
|
|
|
|
QtCore.QCoreApplication.processEvents(
|
|
|
|
QtCore.QEventLoop.AllEvents, 1000
|
|
|
|
)
|
2017-02-08 13:41:56 +01:00
|
|
|
shutdown.doCleanShutdown()
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow", "Stopping notifications... %1%").arg(90))
|
2013-05-08 22:42:28 +02:00
|
|
|
self.tray.hide()
|
2015-10-11 11:57:58 +02:00
|
|
|
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow", "Shutdown imminent... %1%").arg(100))
|
2016-01-26 13:01:28 +01:00
|
|
|
shared.thisapp.cleanup()
|
2016-04-20 15:33:01 +02:00
|
|
|
logger.info("Shutdown complete")
|
2017-01-16 23:38:18 +01:00
|
|
|
super(MyForm, myapp).close()
|
2018-05-15 17:20:53 +02:00
|
|
|
sys.exit(0)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-05-13 15:02:10 +02:00
|
|
|
def closeEvent(self, event):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""window close event"""
|
|
|
|
|
2013-05-13 15:02:10 +02:00
|
|
|
self.appIndicatorHide()
|
2016-03-01 02:50:31 +01:00
|
|
|
trayonclose = False
|
2013-05-13 15:02:10 +02:00
|
|
|
|
|
|
|
try:
|
2017-01-11 14:27:19 +01:00
|
|
|
trayonclose = BMConfigParser().getboolean(
|
2016-03-01 02:50:31 +01:00
|
|
|
'bitmessagesettings', 'trayonclose')
|
2013-05-13 15:02:10 +02:00
|
|
|
except Exception:
|
2013-05-14 17:44:51 +02:00
|
|
|
pass
|
2013-05-13 15:02:10 +02:00
|
|
|
|
2016-10-20 16:06:46 +02:00
|
|
|
# always ignore, it shuts down by itself
|
2017-01-16 23:38:18 +01:00
|
|
|
if self.quitAccepted:
|
|
|
|
event.accept()
|
|
|
|
return
|
|
|
|
|
2016-10-20 16:06:46 +02:00
|
|
|
event.ignore()
|
|
|
|
if not trayonclose:
|
2013-05-13 15:02:10 +02:00
|
|
|
# quit the application
|
|
|
|
self.quit()
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def on_action_InboxMessageForceHtml(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
msgid = self.getCurrentMessageId()
|
|
|
|
textEdit = self.getCurrentMessageTextedit()
|
|
|
|
if not msgid:
|
|
|
|
return
|
2013-10-16 07:08:22 +02:00
|
|
|
queryreturn = sqlQuery(
|
|
|
|
'''select message from inbox where msgid=?''', msgid)
|
|
|
|
if queryreturn != []:
|
|
|
|
for row in queryreturn:
|
2014-06-02 19:05:26 +02:00
|
|
|
messageText, = row
|
2013-10-16 07:08:22 +02:00
|
|
|
|
2014-06-02 19:05:26 +02:00
|
|
|
lines = messageText.split('\n')
|
2014-06-03 07:45:59 +02:00
|
|
|
totalLines = len(lines)
|
|
|
|
for i in xrange(totalLines):
|
2013-10-16 07:08:22 +02:00
|
|
|
if 'Message ostensibly from ' in lines[i]:
|
2014-06-03 07:45:59 +02:00
|
|
|
lines[i] = '<p style="font-size: 12px; color: grey;">%s</span></p>' % (
|
2013-06-12 23:12:32 +02:00
|
|
|
lines[i])
|
2013-05-02 17:53:54 +02:00
|
|
|
elif lines[i] == '------------------------------------------------------':
|
|
|
|
lines[i] = '<hr>'
|
2018-05-15 17:20:53 +02:00
|
|
|
elif lines[i] == '' and (i + 1) < totalLines and \
|
|
|
|
lines[i + 1] != '------------------------------------------------------':
|
2014-06-03 07:45:59 +02:00
|
|
|
lines[i] = '<br><br>'
|
2018-05-15 17:20:53 +02:00
|
|
|
content = ' '.join(lines) # To keep the whitespace between lines
|
2014-06-03 07:45:59 +02:00
|
|
|
content = shared.fixPotentiallyInvalidUTF8Data(content)
|
|
|
|
content = unicode(content, 'utf-8)')
|
2015-03-23 22:35:56 +01:00
|
|
|
textEdit.setHtml(QtCore.QString(content))
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-07-26 04:00:54 +02:00
|
|
|
def on_action_InboxMarkUnread(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
tableWidget = self.getCurrentMessagelist()
|
|
|
|
if not tableWidget:
|
|
|
|
return
|
2018-02-06 14:48:56 +01:00
|
|
|
|
|
|
|
msgids = set()
|
2015-03-23 22:35:56 +01:00
|
|
|
for row in tableWidget.selectedIndexes():
|
2013-07-26 04:00:54 +02:00
|
|
|
currentRow = row.row()
|
2018-02-06 14:48:56 +01:00
|
|
|
msgid = str(tableWidget.item(
|
2018-01-22 17:52:28 +01:00
|
|
|
currentRow, 3).data(QtCore.Qt.UserRole).toPyObject())
|
2018-02-06 14:48:56 +01:00
|
|
|
msgids.add(msgid)
|
|
|
|
self.updateUnreadStatus(tableWidget, currentRow, msgid, False)
|
|
|
|
|
|
|
|
idCount = len(msgids)
|
|
|
|
sqlExecuteChunked(
|
2018-01-25 22:22:15 +01:00
|
|
|
'''UPDATE inbox SET read=0 WHERE msgid IN ({0}) AND read=1''',
|
2018-02-06 14:48:56 +01:00
|
|
|
idCount, *msgids
|
2018-01-25 22:22:15 +01:00
|
|
|
)
|
|
|
|
|
2018-02-06 14:48:56 +01:00
|
|
|
self.propagateUnreadCount()
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2014-01-28 20:32:16 +01:00
|
|
|
def quoted_text(self, message):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Format predefined text on message reply."""
|
|
|
|
|
2017-01-11 14:27:19 +01:00
|
|
|
if not BMConfigParser().safeGetBoolean('bitmessagesettings', 'replybelow'):
|
2018-05-15 17:20:53 +02:00
|
|
|
return '\n\n------------------------------------------------------\n' + message
|
|
|
|
|
|
|
|
quoteWrapper = textwrap.TextWrapper(
|
|
|
|
replace_whitespace=False,
|
|
|
|
initial_indent='> ',
|
|
|
|
subsequent_indent='> ',
|
|
|
|
break_long_words=False,
|
|
|
|
break_on_hyphens=False,
|
|
|
|
)
|
2014-01-28 20:57:01 +01:00
|
|
|
|
2014-01-28 20:32:16 +01:00
|
|
|
def quote_line(line):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2014-01-28 20:32:16 +01:00
|
|
|
# Do quote empty lines.
|
|
|
|
if line == '' or line.isspace():
|
|
|
|
return '> '
|
|
|
|
# Quote already quoted lines, but do not wrap them.
|
|
|
|
elif line[0:2] == '> ':
|
|
|
|
return '> ' + line
|
|
|
|
# Wrap and quote lines/paragraphs new to this message.
|
2018-05-15 17:20:53 +02:00
|
|
|
return quoteWrapper.fill(line)
|
|
|
|
|
2014-01-28 20:32:16 +01:00
|
|
|
return '\n'.join([quote_line(l) for l in message.splitlines()]) + '\n\n'
|
|
|
|
|
2018-05-15 17:20:53 +02:00
|
|
|
def setSendFromComboBox(self, address=None):
|
|
|
|
"""TBC"""
|
|
|
|
|
2016-03-01 08:23:51 +01:00
|
|
|
if address is None:
|
|
|
|
messagelist = self.getCurrentMessagelist()
|
|
|
|
if messagelist:
|
|
|
|
currentInboxRow = messagelist.currentRow()
|
|
|
|
address = messagelist.item(
|
|
|
|
currentInboxRow, 0).address
|
|
|
|
for box in [self.ui.comboBoxSendFrom, self.ui.comboBoxSendFromBroadcast]:
|
|
|
|
listOfAddressesInComboBoxSendFrom = [str(box.itemData(i).toPyObject()) for i in range(box.count())]
|
|
|
|
if address in listOfAddressesInComboBoxSendFrom:
|
|
|
|
currentIndex = listOfAddressesInComboBoxSendFrom.index(address)
|
|
|
|
box.setCurrentIndex(currentIndex)
|
|
|
|
else:
|
|
|
|
box.setCurrentIndex(0)
|
|
|
|
|
2015-12-14 13:07:17 +01:00
|
|
|
def on_action_InboxReplyChan(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-12-14 13:07:17 +01:00
|
|
|
self.on_action_InboxReply(self.REPLY_TYPE_CHAN)
|
2018-05-15 17:20:53 +02:00
|
|
|
|
|
|
|
def on_action_InboxReply(self, replyType=None):
|
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
tableWidget = self.getCurrentMessagelist()
|
|
|
|
if not tableWidget:
|
|
|
|
return
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-12-14 13:07:17 +01:00
|
|
|
if replyType is None:
|
|
|
|
replyType = self.REPLY_TYPE_SENDER
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-10-19 17:37:43 +02:00
|
|
|
# save this to return back after reply is done
|
|
|
|
self.replyFromTab = self.ui.tabWidget.currentIndex()
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
currentInboxRow = tableWidget.currentRow()
|
2015-12-20 01:21:54 +01:00
|
|
|
toAddressAtCurrentInboxRow = tableWidget.item(
|
2016-01-04 15:43:24 +01:00
|
|
|
currentInboxRow, 0).address
|
2015-10-03 17:24:21 +02:00
|
|
|
acct = accountClass(toAddressAtCurrentInboxRow)
|
2015-12-20 01:21:54 +01:00
|
|
|
fromAddressAtCurrentInboxRow = tableWidget.item(
|
2016-01-04 15:43:24 +01:00
|
|
|
currentInboxRow, 1).address
|
2015-03-23 22:35:56 +01:00
|
|
|
msgid = str(tableWidget.item(
|
2018-01-22 17:52:28 +01:00
|
|
|
currentInboxRow, 3).data(QtCore.Qt.UserRole).toPyObject())
|
2013-10-13 19:45:30 +02:00
|
|
|
queryreturn = sqlQuery(
|
|
|
|
'''select message from inbox where msgid=?''', msgid)
|
|
|
|
if queryreturn != []:
|
|
|
|
for row in queryreturn:
|
|
|
|
messageAtCurrentInboxRow, = row
|
2018-05-15 17:20:53 +02:00
|
|
|
acct.parseMessage(
|
|
|
|
toAddressAtCurrentInboxRow,
|
|
|
|
fromAddressAtCurrentInboxRow,
|
|
|
|
tableWidget.item(
|
|
|
|
currentInboxRow,
|
|
|
|
2).subject,
|
|
|
|
messageAtCurrentInboxRow)
|
2015-10-13 23:36:09 +02:00
|
|
|
widget = {
|
|
|
|
'subject': self.ui.lineEditSubject,
|
|
|
|
'from': self.ui.comboBoxSendFrom,
|
|
|
|
'message': self.ui.textEditMessage
|
|
|
|
}
|
|
|
|
if toAddressAtCurrentInboxRow == str_broadcast_subscribers:
|
2018-01-18 15:14:29 +01:00
|
|
|
self.ui.tabWidgetSend.setCurrentIndex(
|
|
|
|
self.ui.tabWidgetSend.indexOf(self.ui.sendDirect)
|
|
|
|
)
|
2017-01-11 14:27:19 +01:00
|
|
|
elif not BMConfigParser().has_section(toAddressAtCurrentInboxRow):
|
2018-05-15 17:20:53 +02:00
|
|
|
QtGui.QMessageBox.information(
|
|
|
|
self, _translate("MainWindow", "Address is gone"),
|
|
|
|
_translate("MainWindow", "Bitmessage cannot find your address %1. Perhaps you removed it?").arg(
|
|
|
|
toAddressAtCurrentInboxRow),
|
|
|
|
QtGui.QMessageBox.Ok)
|
2017-01-11 14:27:19 +01:00
|
|
|
elif not BMConfigParser().getboolean(toAddressAtCurrentInboxRow, 'enabled'):
|
2018-05-15 17:20:53 +02:00
|
|
|
QtGui.QMessageBox.information(
|
|
|
|
self,
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Address disabled"),
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
("Error: The address from which you are trying to send is disabled. You\'ll have to enable it on "
|
|
|
|
"the \'Your Identities\' tab before using it.")),
|
|
|
|
QtGui.QMessageBox.Ok)
|
2013-05-02 17:53:54 +02:00
|
|
|
else:
|
2015-10-14 23:38:34 +02:00
|
|
|
self.setBroadcastEnablementDependingOnWhetherThisIsAMailingListAddress(toAddressAtCurrentInboxRow)
|
2018-01-18 15:14:29 +01:00
|
|
|
broadcast_tab_index = self.ui.tabWidgetSend.indexOf(
|
|
|
|
self.ui.sendBroadcast
|
|
|
|
)
|
|
|
|
if self.ui.tabWidgetSend.currentIndex() == broadcast_tab_index:
|
2015-10-14 23:38:34 +02:00
|
|
|
widget = {
|
|
|
|
'subject': self.ui.lineEditSubjectBroadcast,
|
|
|
|
'from': self.ui.comboBoxSendFromBroadcast,
|
|
|
|
'message': self.ui.textEditMessageBroadcast
|
|
|
|
}
|
2018-01-18 15:14:29 +01:00
|
|
|
self.ui.tabWidgetSend.setCurrentIndex(broadcast_tab_index)
|
2015-10-14 23:38:34 +02:00
|
|
|
toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow
|
2016-04-30 10:37:34 +02:00
|
|
|
if fromAddressAtCurrentInboxRow == tableWidget.item(currentInboxRow, 1).label or (
|
2018-05-15 17:20:53 +02:00
|
|
|
isinstance(acct, GatewayAccount) and fromAddressAtCurrentInboxRow == acct.relayAddress):
|
2016-04-30 10:37:34 +02:00
|
|
|
self.ui.lineEditTo.setText(str(acct.fromAddress))
|
|
|
|
else:
|
2018-05-15 17:20:53 +02:00
|
|
|
self.ui.lineEditTo.setText(
|
|
|
|
''.join(
|
|
|
|
[
|
|
|
|
tableWidget.item(currentInboxRow, 1).label,
|
|
|
|
" <",
|
|
|
|
str(acct.fromAddress) + ">",
|
|
|
|
]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
# If the previous message was to a chan then we should send our reply to
|
|
|
|
# the chan rather than to the particular person who sent the message.
|
2015-12-14 13:07:17 +01:00
|
|
|
if acct.type == AccountMixin.CHAN and replyType == self.REPLY_TYPE_CHAN:
|
|
|
|
logger.debug('original sent to a chan. Setting the to address in the reply to the chan address.')
|
2016-04-30 10:37:34 +02:00
|
|
|
if toAddressAtCurrentInboxRow == tableWidget.item(currentInboxRow, 0).label:
|
|
|
|
self.ui.lineEditTo.setText(str(toAddressAtCurrentInboxRow))
|
|
|
|
else:
|
2018-05-15 17:20:53 +02:00
|
|
|
self.ui.lineEditTo.setText(tableWidget.item(
|
|
|
|
currentInboxRow, 0).label + " <" + str(acct.toAddress) + ">")
|
|
|
|
|
2016-03-01 08:23:51 +01:00
|
|
|
self.setSendFromComboBox(toAddressAtCurrentInboxRow)
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2016-01-04 15:43:24 +01:00
|
|
|
quotedText = self.quoted_text(unicode(messageAtCurrentInboxRow, 'utf-8', 'replace'))
|
2016-01-23 09:56:15 +01:00
|
|
|
widget['message'].setPlainText(quotedText)
|
2015-10-03 17:24:21 +02:00
|
|
|
if acct.subject[0:3] in ['Re:', 'RE:']:
|
2016-01-04 15:43:24 +01:00
|
|
|
widget['subject'].setText(tableWidget.item(currentInboxRow, 2).label)
|
2013-05-02 17:53:54 +02:00
|
|
|
else:
|
2016-01-04 15:43:24 +01:00
|
|
|
widget['subject'].setText('Re: ' + tableWidget.item(currentInboxRow, 2).label)
|
2018-01-18 15:14:29 +01:00
|
|
|
self.ui.tabWidget.setCurrentIndex(
|
|
|
|
self.ui.tabWidget.indexOf(self.ui.send)
|
|
|
|
)
|
2016-01-12 16:49:04 +01:00
|
|
|
widget['message'].setFocus()
|
2013-05-02 17:53:54 +02:00
|
|
|
|
|
|
|
def on_action_InboxAddSenderToAddressBook(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
tableWidget = self.getCurrentMessagelist()
|
|
|
|
if not tableWidget:
|
|
|
|
return
|
|
|
|
currentInboxRow = tableWidget.currentRow()
|
|
|
|
# tableWidget.item(currentRow,1).data(Qt.UserRole).toPyObject()
|
2015-12-20 01:21:54 +01:00
|
|
|
addressAtCurrentInboxRow = tableWidget.item(
|
2018-01-22 17:52:28 +01:00
|
|
|
currentInboxRow, 1).data(QtCore.Qt.UserRole)
|
2018-01-18 15:14:29 +01:00
|
|
|
self.ui.tabWidget.setCurrentIndex(
|
|
|
|
self.ui.tabWidget.indexOf(self.ui.send)
|
|
|
|
)
|
2018-01-24 16:27:51 +01:00
|
|
|
self.click_pushButtonAddAddressBook(
|
|
|
|
dialogs.AddAddressDialog(self, addressAtCurrentInboxRow))
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2015-11-14 01:14:10 +01:00
|
|
|
def on_action_InboxAddSenderToBlackList(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-11-14 01:14:10 +01:00
|
|
|
tableWidget = self.getCurrentMessagelist()
|
|
|
|
if not tableWidget:
|
|
|
|
return
|
|
|
|
currentInboxRow = tableWidget.currentRow()
|
|
|
|
# tableWidget.item(currentRow,1).data(Qt.UserRole).toPyObject()
|
2015-12-20 01:21:54 +01:00
|
|
|
addressAtCurrentInboxRow = tableWidget.item(
|
2018-01-22 17:52:28 +01:00
|
|
|
currentInboxRow, 1).data(QtCore.Qt.UserRole)
|
2015-12-20 01:21:54 +01:00
|
|
|
recipientAddress = tableWidget.item(
|
2018-01-22 17:52:28 +01:00
|
|
|
currentInboxRow, 0).data(QtCore.Qt.UserRole)
|
2015-11-14 01:14:10 +01:00
|
|
|
# Let's make sure that it isn't already in the address book
|
|
|
|
queryreturn = sqlQuery('''select * from blacklist where address=?''',
|
|
|
|
addressAtCurrentInboxRow)
|
|
|
|
if queryreturn == []:
|
2018-05-15 17:20:53 +02:00
|
|
|
label = "\"" + tableWidget.item(currentInboxRow,
|
|
|
|
2).subject + "\" in " + BMConfigParser().get(recipientAddress,
|
|
|
|
"label")
|
2015-11-14 01:14:10 +01:00
|
|
|
sqlExecute('''INSERT INTO blacklist VALUES (?,?, ?)''',
|
2015-11-14 18:53:11 +01:00
|
|
|
label,
|
2015-11-14 01:14:10 +01:00
|
|
|
addressAtCurrentInboxRow, True)
|
2016-03-17 22:09:46 +01:00
|
|
|
self.ui.blackwhitelist.rerenderBlackWhiteList()
|
2018-05-15 17:20:53 +02:00
|
|
|
self.updateStatusBar(
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Entry added to the blacklist. Edit the label to your liking."
|
|
|
|
)
|
2018-01-23 17:15:11 +01:00
|
|
|
)
|
2015-11-14 01:14:10 +01:00
|
|
|
else:
|
2018-05-15 17:20:53 +02:00
|
|
|
self.updateStatusBar(
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
("Error: You cannot add the same address to your blacklist"
|
|
|
|
" twice. Try renaming the existing one if you want.")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
def deleteRowFromMessagelist(self, row=None, inventoryHash=None, ackData=None, messageLists=None):
|
|
|
|
"""TBC"""
|
2015-11-14 01:14:10 +01:00
|
|
|
|
2016-03-01 02:25:39 +01:00
|
|
|
if messageLists is None:
|
2018-05-15 17:20:53 +02:00
|
|
|
messageLists = (
|
|
|
|
self.ui.tableWidgetInbox,
|
|
|
|
self.ui.tableWidgetInboxChans,
|
|
|
|
self.ui.tableWidgetInboxSubscriptions)
|
|
|
|
elif not isinstance(messageLists, (list, tuple)):
|
2016-03-01 02:25:39 +01:00
|
|
|
messageLists = (messageLists)
|
|
|
|
for messageList in messageLists:
|
|
|
|
if row is not None:
|
2018-01-22 17:52:28 +01:00
|
|
|
inventoryHash = str(messageList.item(row, 3).data(
|
|
|
|
QtCore.Qt.UserRole).toPyObject())
|
2016-03-01 02:25:39 +01:00
|
|
|
messageList.removeRow(row)
|
|
|
|
elif inventoryHash is not None:
|
|
|
|
for i in range(messageList.rowCount() - 1, -1, -1):
|
2018-01-22 17:52:28 +01:00
|
|
|
if messageList.item(i, 3).data(QtCore.Qt.UserRole).toPyObject() == inventoryHash:
|
2016-03-01 02:25:39 +01:00
|
|
|
messageList.removeRow(i)
|
|
|
|
elif ackData is not None:
|
|
|
|
for i in range(messageList.rowCount() - 1, -1, -1):
|
2018-01-22 17:52:28 +01:00
|
|
|
if messageList.item(i, 3).data(QtCore.Qt.UserRole).toPyObject() == ackData:
|
2016-03-01 02:25:39 +01:00
|
|
|
messageList.removeRow(i)
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def on_action_InboxTrash(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Send item on the Inbox tab to trash"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
tableWidget = self.getCurrentMessagelist()
|
|
|
|
if not tableWidget:
|
|
|
|
return
|
2015-10-10 19:58:01 +02:00
|
|
|
currentRow = 0
|
2015-11-19 17:37:34 +01:00
|
|
|
folder = self.getCurrentFolder()
|
|
|
|
shifted = QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier
|
2018-05-15 17:20:53 +02:00
|
|
|
tableWidget.setUpdatesEnabled(False)
|
2018-01-28 08:12:46 +01:00
|
|
|
inventoryHashesToTrash = []
|
2018-01-28 09:16:37 +01:00
|
|
|
# ranges in reversed order
|
|
|
|
for r in sorted(tableWidget.selectedRanges(), key=lambda r: r.topRow())[::-1]:
|
2018-05-15 17:20:53 +02:00
|
|
|
for i in range(r.bottomRow() - r.topRow() + 1):
|
2018-01-28 09:16:37 +01:00
|
|
|
inventoryHashToTrash = str(tableWidget.item(
|
2018-05-15 17:20:53 +02:00
|
|
|
r.topRow() + i, 3).data(QtCore.Qt.UserRole).toPyObject())
|
2018-01-28 09:16:37 +01:00
|
|
|
if inventoryHashToTrash in inventoryHashesToTrash:
|
|
|
|
continue
|
|
|
|
inventoryHashesToTrash.append(inventoryHashToTrash)
|
2018-01-28 12:48:25 +01:00
|
|
|
currentRow = r.topRow()
|
2018-01-28 16:13:07 +01:00
|
|
|
self.getCurrentMessageTextedit().setText("")
|
2018-05-15 17:20:53 +02:00
|
|
|
tableWidget.model().removeRows(r.topRow(), r.bottomRow() - r.topRow() + 1)
|
2018-01-28 08:12:46 +01:00
|
|
|
idCount = len(inventoryHashesToTrash)
|
|
|
|
if folder == "trash" or shifted:
|
|
|
|
sqlExecuteChunked('''DELETE FROM inbox WHERE msgid IN ({0})''',
|
2018-05-15 17:20:53 +02:00
|
|
|
idCount, *inventoryHashesToTrash)
|
2013-05-02 17:53:54 +02:00
|
|
|
else:
|
2018-01-28 08:12:46 +01:00
|
|
|
sqlExecuteChunked('''UPDATE inbox SET folder='trash' WHERE msgid IN ({0})''',
|
2018-05-15 17:20:53 +02:00
|
|
|
idCount, *inventoryHashesToTrash)
|
2018-01-28 08:12:46 +01:00
|
|
|
tableWidget.selectRow(0 if currentRow == 0 else currentRow - 1)
|
|
|
|
tableWidget.setUpdatesEnabled(True)
|
|
|
|
self.propagateUnreadCount(self.getCurrentAccount, folder)
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow", "Moved items to trash."))
|
|
|
|
|
2015-11-01 10:56:37 +01:00
|
|
|
def on_action_TrashUndelete(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-11-01 10:56:37 +01:00
|
|
|
tableWidget = self.getCurrentMessagelist()
|
|
|
|
if not tableWidget:
|
|
|
|
return
|
|
|
|
currentRow = 0
|
2018-01-28 08:12:46 +01:00
|
|
|
tableWidget.setUpdatesEnabled(False)
|
|
|
|
inventoryHashesToTrash = []
|
2018-01-28 09:16:37 +01:00
|
|
|
# ranges in reversed order
|
|
|
|
for r in sorted(tableWidget.selectedRanges(), key=lambda r: r.topRow())[::-1]:
|
2018-05-15 17:20:53 +02:00
|
|
|
for i in range(r.bottomRow() - r.topRow() + 1):
|
2018-01-28 09:16:37 +01:00
|
|
|
inventoryHashToTrash = str(tableWidget.item(
|
2018-05-15 17:20:53 +02:00
|
|
|
r.topRow() + i, 3).data(QtCore.Qt.UserRole).toPyObject())
|
2018-01-28 09:16:37 +01:00
|
|
|
if inventoryHashToTrash in inventoryHashesToTrash:
|
|
|
|
continue
|
|
|
|
inventoryHashesToTrash.append(inventoryHashToTrash)
|
2018-01-28 12:48:25 +01:00
|
|
|
currentRow = r.topRow()
|
2018-01-28 16:13:07 +01:00
|
|
|
self.getCurrentMessageTextedit().setText("")
|
2018-05-15 17:20:53 +02:00
|
|
|
tableWidget.model().removeRows(r.topRow(), r.bottomRow() - r.topRow() + 1)
|
2015-11-01 10:56:37 +01:00
|
|
|
if currentRow == 0:
|
|
|
|
tableWidget.selectRow(currentRow)
|
|
|
|
else:
|
|
|
|
tableWidget.selectRow(currentRow - 1)
|
2018-01-28 08:12:46 +01:00
|
|
|
idCount = len(inventoryHashesToTrash)
|
|
|
|
sqlExecuteChunked('''UPDATE inbox SET folder='inbox' WHERE msgid IN({0})''',
|
2018-05-15 17:20:53 +02:00
|
|
|
idCount, *inventoryHashesToTrash)
|
2018-01-28 08:12:46 +01:00
|
|
|
tableWidget.selectRow(0 if currentRow == 0 else currentRow - 1)
|
|
|
|
tableWidget.setUpdatesEnabled(True)
|
|
|
|
self.propagateUnreadCount(self.getCurrentAccount)
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate("MainWindow", "Undeleted item."))
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-06-17 00:28:18 +02:00
|
|
|
def on_action_InboxSaveMessageAs(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
tableWidget = self.getCurrentMessagelist()
|
|
|
|
if not tableWidget:
|
|
|
|
return
|
|
|
|
currentInboxRow = tableWidget.currentRow()
|
2013-06-19 22:49:31 +02:00
|
|
|
try:
|
2018-01-22 17:52:28 +01:00
|
|
|
subjectAtCurrentInboxRow = str(tableWidget.item(
|
|
|
|
currentInboxRow, 2).data(QtCore.Qt.UserRole))
|
2013-06-19 22:49:31 +02:00
|
|
|
except:
|
|
|
|
subjectAtCurrentInboxRow = ''
|
2013-10-16 07:08:22 +02:00
|
|
|
|
|
|
|
# Retrieve the message data out of the SQL database
|
2015-03-23 22:35:56 +01:00
|
|
|
msgid = str(tableWidget.item(
|
2018-01-22 17:52:28 +01:00
|
|
|
currentInboxRow, 3).data(QtCore.Qt.UserRole).toPyObject())
|
2013-10-16 07:08:22 +02:00
|
|
|
queryreturn = sqlQuery(
|
|
|
|
'''select message from inbox where msgid=?''', msgid)
|
|
|
|
if queryreturn != []:
|
|
|
|
for row in queryreturn:
|
|
|
|
message, = row
|
|
|
|
|
2013-06-17 00:28:18 +02:00
|
|
|
defaultFilename = "".join(x for x in subjectAtCurrentInboxRow if x.isalnum()) + '.txt'
|
2018-05-15 17:20:53 +02:00
|
|
|
filename = QtGui.QFileDialog.getSaveFileName(
|
|
|
|
self, _translate("MainWindow", "Save As..."),
|
|
|
|
defaultFilename, "Text files (*.txt);;All files (*.*)")
|
2013-06-17 00:28:18 +02:00
|
|
|
if filename == '':
|
|
|
|
return
|
|
|
|
try:
|
|
|
|
f = open(filename, 'w')
|
2013-10-16 07:08:22 +02:00
|
|
|
f.write(message)
|
2013-06-17 00:28:18 +02:00
|
|
|
f.close()
|
2018-01-23 17:15:11 +01:00
|
|
|
except Exception:
|
2015-11-20 08:49:44 +01:00
|
|
|
logger.exception('Message not saved', exc_info=True)
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate("MainWindow", "Write error."))
|
2013-06-17 00:28:18 +02:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def on_action_SentTrash(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Send item on the Sent tab to trash"""
|
|
|
|
|
2015-11-01 10:59:11 +01:00
|
|
|
currentRow = 0
|
|
|
|
tableWidget = self.getCurrentMessagelist()
|
|
|
|
if not tableWidget:
|
|
|
|
return
|
2015-11-19 17:37:34 +01:00
|
|
|
folder = self.getCurrentFolder()
|
|
|
|
shifted = (QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier) > 0
|
2015-11-01 10:59:11 +01:00
|
|
|
while tableWidget.selectedIndexes() != []:
|
|
|
|
currentRow = tableWidget.selectedIndexes()[0].row()
|
|
|
|
ackdataToTrash = str(tableWidget.item(
|
2018-01-22 17:52:28 +01:00
|
|
|
currentRow, 3).data(QtCore.Qt.UserRole).toPyObject())
|
2015-11-19 17:37:34 +01:00
|
|
|
if folder == "trash" or shifted:
|
|
|
|
sqlExecute('''DELETE FROM sent WHERE ackdata=?''', ackdataToTrash)
|
|
|
|
else:
|
|
|
|
sqlExecute('''UPDATE sent SET folder='trash' WHERE ackdata=?''', ackdataToTrash)
|
2016-01-24 12:16:41 +01:00
|
|
|
if tableWidget.item(currentRow, 0).unread:
|
2018-05-15 17:20:53 +02:00
|
|
|
self.propagateUnreadCount(
|
|
|
|
tableWidget.item(
|
|
|
|
currentRow,
|
|
|
|
1 if tableWidget.item(currentRow, 1).type == AccountMixin.SUBSCRIPTION else 0
|
|
|
|
).data(QtCore.Qt.UserRole),
|
|
|
|
folder,
|
|
|
|
self.getCurrentTreeWidget(),
|
|
|
|
-1,
|
|
|
|
)
|
2015-11-01 10:59:11 +01:00
|
|
|
self.getCurrentMessageTextedit().setPlainText("")
|
|
|
|
tableWidget.removeRow(currentRow)
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow", "Moved items to trash."))
|
|
|
|
|
|
|
|
self.ui.tableWidgetInbox.selectRow(
|
|
|
|
currentRow if currentRow == 0 else currentRow - 1)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-06-11 00:53:15 +02:00
|
|
|
def on_action_ForceSend(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-03 18:17:56 +01:00
|
|
|
currentRow = self.ui.tableWidgetInbox.currentRow()
|
2015-12-20 01:21:54 +01:00
|
|
|
addressAtCurrentRow = self.ui.tableWidgetInbox.item(
|
2018-01-22 17:52:28 +01:00
|
|
|
currentRow, 0).data(QtCore.Qt.UserRole)
|
2013-06-11 00:53:15 +02:00
|
|
|
toRipe = decodeAddress(addressAtCurrentRow)[3]
|
2013-08-27 02:01:19 +02:00
|
|
|
sqlExecute(
|
|
|
|
'''UPDATE sent SET status='forcepow' WHERE toripe=? AND status='toodifficult' and folder='sent' ''',
|
|
|
|
toRipe)
|
|
|
|
queryreturn = sqlQuery('''select ackdata FROM sent WHERE status='forcepow' ''')
|
2013-06-11 00:53:15 +02:00
|
|
|
for row in queryreturn:
|
|
|
|
ackdata, = row
|
2017-02-08 13:41:56 +01:00
|
|
|
queues.UISignalQueue.put(('updateSentItemStatusByAckdata', (
|
2013-06-12 23:12:32 +02:00
|
|
|
ackdata, 'Overriding maximum-difficulty setting. Work queued.')))
|
2017-02-08 13:41:56 +01:00
|
|
|
queues.workerQueue.put(('sendmessage', ''))
|
2013-06-11 00:53:15 +02:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def on_action_SentClipboard(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-03 18:17:56 +01:00
|
|
|
currentRow = self.ui.tableWidgetInbox.currentRow()
|
2015-12-20 01:21:54 +01:00
|
|
|
addressAtCurrentRow = self.ui.tableWidgetInbox.item(
|
2018-01-22 17:52:28 +01:00
|
|
|
currentRow, 0).data(QtCore.Qt.UserRole)
|
2013-05-02 17:53:54 +02:00
|
|
|
clipboard = QtGui.QApplication.clipboard()
|
|
|
|
clipboard.setText(str(addressAtCurrentRow))
|
|
|
|
|
|
|
|
def on_action_AddressBookNew(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Group of functions for the Address Book dialog box"""
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
self.click_pushButtonAddAddressBook()
|
2013-06-12 23:12:32 +02:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def on_action_AddressBookDelete(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
while self.ui.tableWidgetAddressBook.selectedIndexes() != []:
|
2013-06-12 23:12:32 +02:00
|
|
|
currentRow = self.ui.tableWidgetAddressBook.selectedIndexes()[
|
|
|
|
0].row()
|
|
|
|
labelAtCurrentRow = self.ui.tableWidgetAddressBook.item(
|
|
|
|
currentRow, 0).text().toUtf8()
|
|
|
|
addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(
|
|
|
|
currentRow, 1).text()
|
2013-08-27 02:01:19 +02:00
|
|
|
sqlExecute('''DELETE FROM addressbook WHERE label=? AND address=?''',
|
|
|
|
str(labelAtCurrentRow), str(addressAtCurrentRow))
|
2013-05-02 17:53:54 +02:00
|
|
|
self.ui.tableWidgetAddressBook.removeRow(currentRow)
|
2016-01-23 20:24:50 +01:00
|
|
|
self.rerenderMessagelistFromLabels()
|
|
|
|
self.rerenderMessagelistToLabels()
|
2013-06-12 23:12:32 +02:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def on_action_AddressBookClipboard(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
fullStringOfAddresses = ''
|
|
|
|
listOfSelectedRows = {}
|
|
|
|
for i in range(len(self.ui.tableWidgetAddressBook.selectedIndexes())):
|
2013-06-12 23:12:32 +02:00
|
|
|
listOfSelectedRows[
|
|
|
|
self.ui.tableWidgetAddressBook.selectedIndexes()[i].row()] = 0
|
2013-05-02 17:53:54 +02:00
|
|
|
for currentRow in listOfSelectedRows:
|
2013-06-12 23:12:32 +02:00
|
|
|
addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(
|
|
|
|
currentRow, 1).text()
|
2013-05-02 17:53:54 +02:00
|
|
|
if fullStringOfAddresses == '':
|
|
|
|
fullStringOfAddresses = addressAtCurrentRow
|
|
|
|
else:
|
2013-06-12 23:12:32 +02:00
|
|
|
fullStringOfAddresses += ', ' + str(addressAtCurrentRow)
|
2013-05-02 17:53:54 +02:00
|
|
|
clipboard = QtGui.QApplication.clipboard()
|
|
|
|
clipboard.setText(fullStringOfAddresses)
|
2013-06-12 23:12:32 +02:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def on_action_AddressBookSend(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
listOfSelectedRows = {}
|
|
|
|
for i in range(len(self.ui.tableWidgetAddressBook.selectedIndexes())):
|
2013-06-12 23:12:32 +02:00
|
|
|
listOfSelectedRows[
|
|
|
|
self.ui.tableWidgetAddressBook.selectedIndexes()[i].row()] = 0
|
2013-05-02 17:53:54 +02:00
|
|
|
for currentRow in listOfSelectedRows:
|
2013-06-12 23:12:32 +02:00
|
|
|
addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(
|
2016-04-29 09:31:56 +02:00
|
|
|
currentRow, 0).address
|
|
|
|
labelAtCurrentRow = self.ui.tableWidgetAddressBook.item(
|
|
|
|
currentRow, 0).label
|
|
|
|
stringToAdd = labelAtCurrentRow + " <" + addressAtCurrentRow + ">"
|
2013-05-02 17:53:54 +02:00
|
|
|
if self.ui.lineEditTo.text() == '':
|
2016-04-29 09:31:56 +02:00
|
|
|
self.ui.lineEditTo.setText(stringToAdd)
|
2013-05-02 17:53:54 +02:00
|
|
|
else:
|
2016-04-29 11:43:40 +02:00
|
|
|
self.ui.lineEditTo.setText(unicode(
|
|
|
|
self.ui.lineEditTo.text().toUtf8(), encoding="UTF-8") + '; ' + stringToAdd)
|
2013-05-02 17:53:54 +02:00
|
|
|
if listOfSelectedRows == {}:
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
|
|
|
"MainWindow", "No addresses selected."))
|
2013-05-02 17:53:54 +02:00
|
|
|
else:
|
2018-01-23 17:15:11 +01:00
|
|
|
self.statusbar.clearMessage()
|
2018-01-18 15:14:29 +01:00
|
|
|
self.ui.tabWidget.setCurrentIndex(
|
|
|
|
self.ui.tabWidget.indexOf(self.ui.send)
|
|
|
|
)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-06-14 03:55:38 +02:00
|
|
|
def on_action_AddressBookSubscribe(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2013-06-14 03:55:38 +02:00
|
|
|
listOfSelectedRows = {}
|
|
|
|
for i in range(len(self.ui.tableWidgetAddressBook.selectedIndexes())):
|
|
|
|
listOfSelectedRows[self.ui.tableWidgetAddressBook.selectedIndexes()[i].row()] = 0
|
|
|
|
for currentRow in listOfSelectedRows:
|
2018-05-15 17:20:53 +02:00
|
|
|
addressAtCurrentRow = str(self.ui.tableWidgetAddressBook.item(currentRow, 1).text())
|
2013-06-14 03:55:38 +02:00
|
|
|
# Then subscribe to it... provided it's not already in the address book
|
|
|
|
if shared.isAddressInMySubscriptionsList(addressAtCurrentRow):
|
2018-01-23 17:15:11 +01:00
|
|
|
self.updateStatusBar(_translate(
|
2018-01-22 17:52:28 +01:00
|
|
|
"MainWindow",
|
|
|
|
"Error: You cannot add the same address to your"
|
|
|
|
" subscriptions twice. Perhaps rename the existing"
|
2018-01-23 17:15:11 +01:00
|
|
|
" one if you want."))
|
2013-06-14 04:27:52 +02:00
|
|
|
continue
|
2018-05-15 17:20:53 +02:00
|
|
|
labelAtCurrentRow = self.ui.tableWidgetAddressBook.item(currentRow, 0).text().toUtf8()
|
2013-07-22 07:10:22 +02:00
|
|
|
self.addSubscription(addressAtCurrentRow, labelAtCurrentRow)
|
2018-01-18 15:14:29 +01:00
|
|
|
self.ui.tabWidget.setCurrentIndex(
|
|
|
|
self.ui.tabWidget.indexOf(self.ui.subscriptions)
|
|
|
|
)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
def on_context_menuAddressBook(self, point):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-11-01 08:46:27 +01:00
|
|
|
self.popMenuAddressBook = QtGui.QMenu(self)
|
2015-10-31 21:38:54 +01:00
|
|
|
self.popMenuAddressBook.addAction(self.actionAddressBookSend)
|
|
|
|
self.popMenuAddressBook.addAction(self.actionAddressBookClipboard)
|
|
|
|
self.popMenuAddressBook.addAction(self.actionAddressBookSubscribe)
|
|
|
|
self.popMenuAddressBook.addAction(self.actionAddressBookSetAvatar)
|
2017-09-04 15:06:48 +02:00
|
|
|
self.popMenuAddressBook.addAction(self.actionAddressBookSetSound)
|
2015-10-31 21:38:54 +01:00
|
|
|
self.popMenuAddressBook.addSeparator()
|
|
|
|
self.popMenuAddressBook.addAction(self.actionAddressBookNew)
|
|
|
|
normal = True
|
|
|
|
for row in self.ui.tableWidgetAddressBook.selectedIndexes():
|
|
|
|
currentRow = row.row()
|
2018-05-15 17:20:53 +02:00
|
|
|
row_type = self.ui.tableWidgetAddressBook.item(
|
2015-12-01 01:09:28 +01:00
|
|
|
currentRow, 0).type
|
2018-05-15 17:20:53 +02:00
|
|
|
if row_type != AccountMixin.NORMAL:
|
2015-10-31 21:38:54 +01:00
|
|
|
normal = False
|
|
|
|
if normal:
|
|
|
|
# only if all selected addressbook items are normal, allow delete
|
|
|
|
self.popMenuAddressBook.addAction(self.actionAddressBookDelete)
|
2013-06-12 23:12:32 +02:00
|
|
|
self.popMenuAddressBook.exec_(
|
|
|
|
self.ui.tableWidgetAddressBook.mapToGlobal(point))
|
2013-05-02 17:53:54 +02:00
|
|
|
|
|
|
|
def on_action_SubscriptionsNew(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Group of functions for the Subscriptions dialog box"""
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
self.click_pushButtonAddSubscription()
|
2018-01-22 17:52:28 +01:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def on_action_SubscriptionsDelete(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2018-01-22 17:52:28 +01:00
|
|
|
if QtGui.QMessageBox.question(
|
|
|
|
self, "Delete subscription?",
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"If you delete the subscription, messages that you"
|
|
|
|
" already received will become inaccessible. Maybe"
|
|
|
|
" you can consider disabling the subscription instead."
|
|
|
|
" Disabled subscriptions will not receive new"
|
|
|
|
" messages, but you can still view messages you"
|
|
|
|
" already received.\n\nAre you sure you want to"
|
|
|
|
" delete the subscription?"
|
|
|
|
), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
|
|
|
|
) != QtGui.QMessageBox.Yes:
|
2015-11-19 19:28:32 +01:00
|
|
|
return
|
2015-03-23 22:35:56 +01:00
|
|
|
address = self.getCurrentAccount()
|
|
|
|
sqlExecute('''DELETE FROM subscriptions WHERE address=?''',
|
|
|
|
address)
|
|
|
|
self.rerenderTabTreeSubscriptions()
|
2016-01-23 20:24:50 +01:00
|
|
|
self.rerenderMessagelistFromLabels()
|
2015-11-19 19:17:26 +01:00
|
|
|
self.rerenderAddressBook()
|
2013-05-02 17:53:54 +02:00
|
|
|
shared.reloadBroadcastSendersForWhichImWatching()
|
2013-06-12 23:12:32 +02:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def on_action_SubscriptionsClipboard(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
address = self.getCurrentAccount()
|
2013-05-02 17:53:54 +02:00
|
|
|
clipboard = QtGui.QApplication.clipboard()
|
2015-03-23 22:35:56 +01:00
|
|
|
clipboard.setText(str(address))
|
2013-06-12 23:12:32 +02:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def on_action_SubscriptionsEnable(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
address = self.getCurrentAccount()
|
2013-08-27 02:01:19 +02:00
|
|
|
sqlExecute(
|
2015-03-23 22:35:56 +01:00
|
|
|
'''update subscriptions set enabled=1 WHERE address=?''',
|
|
|
|
address)
|
2015-10-27 19:24:29 +01:00
|
|
|
account = self.getCurrentItem()
|
|
|
|
account.setEnabled(True)
|
2015-11-19 19:17:26 +01:00
|
|
|
self.rerenderAddressBook()
|
2013-05-02 17:53:54 +02:00
|
|
|
shared.reloadBroadcastSendersForWhichImWatching()
|
2013-06-12 23:12:32 +02:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def on_action_SubscriptionsDisable(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
address = self.getCurrentAccount()
|
2013-08-27 02:01:19 +02:00
|
|
|
sqlExecute(
|
2015-03-23 22:35:56 +01:00
|
|
|
'''update subscriptions set enabled=0 WHERE address=?''',
|
|
|
|
address)
|
2015-10-27 19:24:29 +01:00
|
|
|
account = self.getCurrentItem()
|
|
|
|
account.setEnabled(False)
|
2016-01-24 01:16:00 +01:00
|
|
|
self.rerenderAddressBook()
|
2013-05-02 17:53:54 +02:00
|
|
|
shared.reloadBroadcastSendersForWhichImWatching()
|
2013-06-12 23:12:32 +02:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def on_context_menuSubscriptions(self, point):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2016-01-24 18:25:09 +01:00
|
|
|
currentItem = self.getCurrentItem()
|
2015-11-01 08:46:27 +01:00
|
|
|
self.popMenuSubscriptions = QtGui.QMenu(self)
|
2016-08-20 22:38:36 +02:00
|
|
|
if isinstance(currentItem, Ui_AddressWidget):
|
|
|
|
self.popMenuSubscriptions.addAction(self.actionsubscriptionsNew)
|
|
|
|
self.popMenuSubscriptions.addAction(self.actionsubscriptionsDelete)
|
|
|
|
self.popMenuSubscriptions.addSeparator()
|
|
|
|
if currentItem.isEnabled:
|
|
|
|
self.popMenuSubscriptions.addAction(self.actionsubscriptionsDisable)
|
|
|
|
else:
|
|
|
|
self.popMenuSubscriptions.addAction(self.actionsubscriptionsEnable)
|
|
|
|
self.popMenuSubscriptions.addAction(self.actionsubscriptionsSetAvatar)
|
|
|
|
self.popMenuSubscriptions.addSeparator()
|
|
|
|
self.popMenuSubscriptions.addAction(self.actionsubscriptionsClipboard)
|
|
|
|
self.popMenuSubscriptions.addSeparator()
|
2017-03-07 14:44:48 +01:00
|
|
|
# preloaded gui.menu plugins with prefix 'address'
|
|
|
|
for plugin in self.menu_plugins['address']:
|
|
|
|
self.popMenuSubscriptions.addAction(plugin)
|
|
|
|
self.popMenuSubscriptions.addSeparator()
|
2016-08-20 22:38:36 +02:00
|
|
|
self.popMenuSubscriptions.addAction(self.actionMarkAllRead)
|
2013-06-12 23:12:32 +02:00
|
|
|
self.popMenuSubscriptions.exec_(
|
2015-03-23 22:35:56 +01:00
|
|
|
self.ui.treeWidgetSubscriptions.mapToGlobal(point))
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2018-05-15 17:20:53 +02:00
|
|
|
def widgetConvert(self, widget): # pylint: disable=inconsistent-return-statements
|
|
|
|
"""TBC"""
|
|
|
|
|
2015-11-09 19:39:30 +01:00
|
|
|
if widget == self.ui.tableWidgetInbox:
|
|
|
|
return self.ui.treeWidgetYourIdentities
|
|
|
|
elif widget == self.ui.tableWidgetInboxSubscriptions:
|
|
|
|
return self.ui.treeWidgetSubscriptions
|
|
|
|
elif widget == self.ui.tableWidgetInboxChans:
|
|
|
|
return self.ui.treeWidgetChans
|
|
|
|
elif widget == self.ui.treeWidgetYourIdentities:
|
|
|
|
return self.ui.tableWidgetInbox
|
|
|
|
elif widget == self.ui.treeWidgetSubscriptions:
|
|
|
|
return self.ui.tableWidgetInboxSubscriptions
|
2015-11-27 02:11:24 +01:00
|
|
|
elif widget == self.ui.treeWidgetChans:
|
2015-11-09 19:39:30 +01:00
|
|
|
return self.ui.tableWidgetInboxChans
|
|
|
|
|
2015-03-21 11:37:08 +01:00
|
|
|
def getCurrentTreeWidget(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
|
|
|
currentIndex = self.ui.tabWidget.currentIndex()
|
2015-03-21 11:37:08 +01:00
|
|
|
treeWidgetList = [
|
|
|
|
self.ui.treeWidgetYourIdentities,
|
|
|
|
False,
|
|
|
|
self.ui.treeWidgetSubscriptions,
|
|
|
|
self.ui.treeWidgetChans
|
|
|
|
]
|
2018-05-15 17:20:53 +02:00
|
|
|
return treeWidgetList[currentIndex] if currentIndex >= 0 and currentIndex < len(treeWidgetList) else False
|
2015-03-21 11:37:08 +01:00
|
|
|
|
2015-10-22 23:56:20 +02:00
|
|
|
def getAccountTreeWidget(self, account):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-10-22 23:56:20 +02:00
|
|
|
try:
|
2015-11-26 19:41:20 +01:00
|
|
|
if account.type == AccountMixin.CHAN:
|
2015-10-22 23:56:20 +02:00
|
|
|
return self.ui.treeWidgetChans
|
2015-11-26 19:41:20 +01:00
|
|
|
elif account.type == AccountMixin.SUBSCRIPTION:
|
2015-10-22 23:56:20 +02:00
|
|
|
return self.ui.treeWidgetSubscriptions
|
2018-05-15 17:20:53 +02:00
|
|
|
return self.ui.treeWidgetYourIdentities
|
2015-10-22 23:56:20 +02:00
|
|
|
except:
|
|
|
|
return self.ui.treeWidgetYourIdentities
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
def getCurrentMessagelist(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
|
|
|
currentIndex = self.ui.tabWidget.currentIndex()
|
2015-03-23 22:35:56 +01:00
|
|
|
messagelistList = [
|
|
|
|
self.ui.tableWidgetInbox,
|
|
|
|
False,
|
|
|
|
self.ui.tableWidgetInboxSubscriptions,
|
|
|
|
self.ui.tableWidgetInboxChans,
|
|
|
|
]
|
|
|
|
if currentIndex >= 0 and currentIndex < len(messagelistList):
|
|
|
|
return messagelistList[currentIndex]
|
2018-05-15 17:20:53 +02:00
|
|
|
return False
|
|
|
|
|
2015-10-22 23:56:20 +02:00
|
|
|
def getAccountMessagelist(self, account):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-10-22 23:56:20 +02:00
|
|
|
try:
|
2015-11-26 19:41:20 +01:00
|
|
|
if account.type == AccountMixin.CHAN:
|
2015-10-22 23:56:20 +02:00
|
|
|
return self.ui.tableWidgetInboxChans
|
2015-11-26 19:41:20 +01:00
|
|
|
elif account.type == AccountMixin.SUBSCRIPTION:
|
2015-10-22 23:56:20 +02:00
|
|
|
return self.ui.tableWidgetInboxSubscriptions
|
2018-05-15 17:20:53 +02:00
|
|
|
return self.ui.tableWidgetInbox
|
2015-10-22 23:56:20 +02:00
|
|
|
except:
|
|
|
|
return self.ui.tableWidgetInbox
|
2015-03-23 22:35:56 +01:00
|
|
|
|
|
|
|
def getCurrentMessageId(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
messagelist = self.getCurrentMessagelist()
|
|
|
|
if messagelist:
|
|
|
|
currentRow = messagelist.currentRow()
|
|
|
|
if currentRow >= 0:
|
|
|
|
msgid = str(messagelist.item(
|
2018-01-22 17:52:28 +01:00
|
|
|
currentRow, 3).data(QtCore.Qt.UserRole).toPyObject())
|
|
|
|
# data is saved at the 4. column of the table...
|
2015-03-23 22:35:56 +01:00
|
|
|
return msgid
|
|
|
|
return False
|
|
|
|
|
|
|
|
def getCurrentMessageTextedit(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2018-01-22 17:52:28 +01:00
|
|
|
currentIndex = self.ui.tabWidget.currentIndex()
|
2015-03-23 22:35:56 +01:00
|
|
|
messagelistList = [
|
|
|
|
self.ui.textEditInboxMessage,
|
|
|
|
False,
|
|
|
|
self.ui.textEditInboxMessageSubscriptions,
|
|
|
|
self.ui.textEditInboxMessageChans,
|
|
|
|
]
|
|
|
|
if currentIndex >= 0 and currentIndex < len(messagelistList):
|
|
|
|
return messagelistList[currentIndex]
|
2018-05-15 17:20:53 +02:00
|
|
|
return False
|
2015-03-23 22:35:56 +01:00
|
|
|
|
2015-10-22 23:56:20 +02:00
|
|
|
def getAccountTextedit(self, account):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-10-22 23:56:20 +02:00
|
|
|
try:
|
2015-11-26 19:41:20 +01:00
|
|
|
if account.type == AccountMixin.CHAN:
|
2015-10-22 23:56:20 +02:00
|
|
|
return self.ui.textEditInboxMessageChans
|
2015-11-26 19:41:20 +01:00
|
|
|
elif account.type == AccountMixin.SUBSCRIPTION:
|
2015-10-22 23:56:20 +02:00
|
|
|
return self.ui.textEditInboxSubscriptions
|
2018-05-15 17:20:53 +02:00
|
|
|
return self.ui.textEditInboxMessage
|
2015-10-22 23:56:20 +02:00
|
|
|
except:
|
|
|
|
return self.ui.textEditInboxMessage
|
|
|
|
|
2018-05-15 17:20:53 +02:00
|
|
|
def getCurrentSearchLine(self, currentIndex=None, retObj=False): # pylint: disable=inconsistent-return-statements
|
|
|
|
"""TBC"""
|
|
|
|
|
2016-02-14 19:56:05 +01:00
|
|
|
if currentIndex is None:
|
2018-01-22 17:52:28 +01:00
|
|
|
currentIndex = self.ui.tabWidget.currentIndex()
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
messagelistList = [
|
|
|
|
self.ui.inboxSearchLineEdit,
|
|
|
|
False,
|
|
|
|
self.ui.inboxSearchLineEditSubscriptions,
|
|
|
|
self.ui.inboxSearchLineEditChans,
|
|
|
|
]
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
if currentIndex >= 0 and currentIndex < len(messagelistList):
|
2016-03-01 08:23:51 +01:00
|
|
|
if retObj:
|
|
|
|
return messagelistList[currentIndex]
|
2018-05-15 17:20:53 +02:00
|
|
|
return messagelistList[currentIndex].text().toUtf8().data()
|
|
|
|
|
|
|
|
def getCurrentSearchOption(self, currentIndex=None): # pylint: disable=inconsistent-return-statements
|
|
|
|
"""TBC"""
|
2015-03-23 22:35:56 +01:00
|
|
|
|
2016-02-14 19:56:05 +01:00
|
|
|
if currentIndex is None:
|
2018-01-22 17:52:28 +01:00
|
|
|
currentIndex = self.ui.tabWidget.currentIndex()
|
2015-03-23 22:35:56 +01:00
|
|
|
messagelistList = [
|
|
|
|
self.ui.inboxSearchOption,
|
|
|
|
False,
|
|
|
|
self.ui.inboxSearchOptionSubscriptions,
|
|
|
|
self.ui.inboxSearchOptionChans,
|
|
|
|
]
|
|
|
|
if currentIndex >= 0 and currentIndex < len(messagelistList):
|
|
|
|
return messagelistList[currentIndex].currentText().toUtf8().data()
|
|
|
|
|
2018-01-22 17:52:28 +01:00
|
|
|
def getCurrentItem(self, treeWidget=None):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Group of functions for the Your Identities dialog box"""
|
|
|
|
|
2015-10-22 23:56:20 +02:00
|
|
|
if treeWidget is None:
|
|
|
|
treeWidget = self.getCurrentTreeWidget()
|
2015-03-21 11:37:08 +01:00
|
|
|
if treeWidget:
|
|
|
|
currentItem = treeWidget.currentItem()
|
|
|
|
if currentItem:
|
2015-10-19 17:22:37 +02:00
|
|
|
return currentItem
|
|
|
|
return False
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2018-01-22 17:52:28 +01:00
|
|
|
def getCurrentAccount(self, treeWidget=None):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TODO: debug msg in else?"""
|
|
|
|
|
2015-10-22 23:56:20 +02:00
|
|
|
currentItem = self.getCurrentItem(treeWidget)
|
2015-10-19 17:22:37 +02:00
|
|
|
if currentItem:
|
|
|
|
account = currentItem.address
|
|
|
|
return account
|
2018-05-15 17:20:53 +02:00
|
|
|
return False
|
|
|
|
|
|
|
|
def getCurrentFolder(self, treeWidget=None): # pylint: disable=inconsistent-return-statements
|
|
|
|
"""TBC"""
|
2015-03-21 11:37:08 +01:00
|
|
|
|
2015-10-22 23:56:20 +02:00
|
|
|
if treeWidget is None:
|
|
|
|
treeWidget = self.getCurrentTreeWidget()
|
2015-03-21 11:37:08 +01:00
|
|
|
if treeWidget:
|
|
|
|
currentItem = treeWidget.currentItem()
|
2015-10-03 12:12:18 +02:00
|
|
|
if currentItem and hasattr(currentItem, 'folderName'):
|
|
|
|
return currentItem.folderName
|
2015-03-21 11:37:08 +01:00
|
|
|
|
|
|
|
def setCurrentItemColor(self, color):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-21 11:37:08 +01:00
|
|
|
treeWidget = self.getCurrentTreeWidget()
|
|
|
|
if treeWidget:
|
|
|
|
brush = QtGui.QBrush()
|
|
|
|
brush.setStyle(QtCore.Qt.NoBrush)
|
2015-03-23 22:35:56 +01:00
|
|
|
brush.setColor(color)
|
2015-03-21 11:37:08 +01:00
|
|
|
currentItem = treeWidget.currentItem()
|
|
|
|
currentItem.setForeground(0, brush)
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def on_action_YourIdentitiesNew(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
self.click_NewAddressDialog()
|
2013-06-12 23:12:32 +02:00
|
|
|
|
2015-11-09 18:22:38 +01:00
|
|
|
def on_action_YourIdentitiesDelete(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-11-09 18:22:38 +01:00
|
|
|
account = self.getCurrentItem()
|
2015-11-26 19:41:20 +01:00
|
|
|
if account.type == AccountMixin.NORMAL:
|
2018-01-22 17:52:28 +01:00
|
|
|
return # maybe in the future
|
2015-11-26 19:41:20 +01:00
|
|
|
elif account.type == AccountMixin.CHAN:
|
2018-01-22 17:52:28 +01:00
|
|
|
if QtGui.QMessageBox.question(
|
|
|
|
self, "Delete channel?",
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"If you delete the channel, messages that you"
|
|
|
|
" already received will become inaccessible."
|
|
|
|
" Maybe you can consider disabling the channel"
|
|
|
|
" instead. Disabled channels will not receive new"
|
|
|
|
" messages, but you can still view messages you"
|
|
|
|
" already received.\n\nAre you sure you want to"
|
|
|
|
" delete the channel?"
|
|
|
|
), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
|
|
|
|
) == QtGui.QMessageBox.Yes:
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().remove_section(str(account.address))
|
2015-11-09 18:22:38 +01:00
|
|
|
else:
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
return
|
2017-01-15 10:50:02 +01:00
|
|
|
BMConfigParser().save()
|
2015-11-09 18:22:38 +01:00
|
|
|
shared.reloadMyAddressHashes()
|
2015-11-19 19:17:26 +01:00
|
|
|
self.rerenderAddressBook()
|
2017-02-14 01:35:32 +01:00
|
|
|
self.rerenderComboBoxSendFrom()
|
2015-11-26 19:41:20 +01:00
|
|
|
if account.type == AccountMixin.NORMAL:
|
2015-11-09 18:22:38 +01:00
|
|
|
self.rerenderTabTreeMessages()
|
2015-11-26 19:41:20 +01:00
|
|
|
elif account.type == AccountMixin.CHAN:
|
2015-11-09 18:22:38 +01:00
|
|
|
self.rerenderTabTreeChans()
|
|
|
|
|
2015-03-21 11:37:08 +01:00
|
|
|
def on_action_Enable(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-21 11:37:08 +01:00
|
|
|
addressAtCurrentRow = self.getCurrentAccount()
|
|
|
|
self.enableIdentity(addressAtCurrentRow)
|
2015-10-27 19:24:29 +01:00
|
|
|
account = self.getCurrentItem()
|
|
|
|
account.setEnabled(True)
|
2015-03-21 11:37:08 +01:00
|
|
|
|
|
|
|
def enableIdentity(self, address):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set(address, 'enabled', 'true')
|
2017-01-15 10:50:02 +01:00
|
|
|
BMConfigParser().save()
|
2013-05-02 17:53:54 +02:00
|
|
|
shared.reloadMyAddressHashes()
|
2015-11-19 19:17:26 +01:00
|
|
|
self.rerenderAddressBook()
|
2013-06-12 23:12:32 +02:00
|
|
|
|
2015-03-21 11:37:08 +01:00
|
|
|
def on_action_Disable(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-21 11:37:08 +01:00
|
|
|
address = self.getCurrentAccount()
|
|
|
|
self.disableIdentity(address)
|
2015-10-27 19:24:29 +01:00
|
|
|
account = self.getCurrentItem()
|
|
|
|
account.setEnabled(False)
|
2015-03-21 11:37:08 +01:00
|
|
|
|
|
|
|
def disableIdentity(self, address):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().set(str(address), 'enabled', 'false')
|
2017-01-15 10:50:02 +01:00
|
|
|
BMConfigParser().save()
|
2013-05-02 17:53:54 +02:00
|
|
|
shared.reloadMyAddressHashes()
|
2015-11-19 19:17:26 +01:00
|
|
|
self.rerenderAddressBook()
|
2013-06-12 23:12:32 +02:00
|
|
|
|
2015-03-21 11:37:08 +01:00
|
|
|
def on_action_Clipboard(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
address = self.getCurrentAccount()
|
2013-05-02 17:53:54 +02:00
|
|
|
clipboard = QtGui.QApplication.clipboard()
|
2015-03-23 22:35:56 +01:00
|
|
|
clipboard.setText(str(address))
|
2017-03-01 15:46:13 +01:00
|
|
|
|
2015-12-14 12:21:00 +01:00
|
|
|
def on_action_ClipboardMessagelist(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-12-14 12:21:00 +01:00
|
|
|
tableWidget = self.getCurrentMessagelist()
|
|
|
|
currentColumn = tableWidget.currentColumn()
|
|
|
|
currentRow = tableWidget.currentRow()
|
2018-05-15 17:20:53 +02:00
|
|
|
if currentColumn not in [0, 1, 2]: # to, from, subject
|
2015-12-14 12:21:00 +01:00
|
|
|
if self.getCurrentFolder() == "sent":
|
|
|
|
currentColumn = 0
|
|
|
|
else:
|
|
|
|
currentColumn = 1
|
|
|
|
if self.getCurrentFolder() == "sent":
|
2018-01-22 17:52:28 +01:00
|
|
|
myAddress = tableWidget.item(currentRow, 1).data(QtCore.Qt.UserRole)
|
|
|
|
otherAddress = tableWidget.item(currentRow, 0).data(QtCore.Qt.UserRole)
|
2015-12-14 12:21:00 +01:00
|
|
|
else:
|
2018-01-22 17:52:28 +01:00
|
|
|
myAddress = tableWidget.item(currentRow, 0).data(QtCore.Qt.UserRole)
|
|
|
|
otherAddress = tableWidget.item(currentRow, 1).data(QtCore.Qt.UserRole)
|
2015-12-14 12:21:00 +01:00
|
|
|
account = accountClass(myAddress)
|
2018-05-15 17:20:53 +02:00
|
|
|
if all(
|
|
|
|
[
|
|
|
|
isinstance(account, GatewayAccount),
|
|
|
|
otherAddress == account.relayAddress,
|
|
|
|
any(
|
|
|
|
[
|
|
|
|
currentColumn in [0, 2] and self.getCurrentFolder() == "sent",
|
|
|
|
currentColumn in [1, 2] and self.getCurrentFolder() != "sent",
|
|
|
|
]
|
|
|
|
),
|
|
|
|
]
|
|
|
|
):
|
|
|
|
|
2015-12-20 01:21:54 +01:00
|
|
|
text = str(tableWidget.item(currentRow, currentColumn).label)
|
2015-12-14 12:21:00 +01:00
|
|
|
else:
|
2018-01-22 17:52:28 +01:00
|
|
|
text = tableWidget.item(currentRow, currentColumn).data(QtCore.Qt.UserRole)
|
2016-03-12 08:49:20 +01:00
|
|
|
text = unicode(str(text), 'utf-8', 'ignore')
|
2015-12-14 12:21:00 +01:00
|
|
|
clipboard = QtGui.QApplication.clipboard()
|
2016-03-12 08:49:20 +01:00
|
|
|
clipboard.setText(text)
|
2015-03-21 11:37:08 +01:00
|
|
|
|
|
|
|
def on_action_TreeWidgetSetAvatar(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""set avatar functions"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
address = self.getCurrentAccount()
|
|
|
|
self.setAvatar(address)
|
2013-06-12 23:12:32 +02:00
|
|
|
|
2013-09-21 09:41:23 +02:00
|
|
|
def on_action_AddressBookSetAvatar(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2013-09-21 09:41:23 +02:00
|
|
|
self.on_action_SetAvatar(self.ui.tableWidgetAddressBook)
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2013-09-21 09:41:23 +02:00
|
|
|
def on_action_SetAvatar(self, thisTableWidget):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2013-09-21 09:41:23 +02:00
|
|
|
currentRow = thisTableWidget.currentRow()
|
|
|
|
addressAtCurrentRow = thisTableWidget.item(
|
2013-09-20 14:30:53 +02:00
|
|
|
currentRow, 1).text()
|
2015-03-21 11:37:08 +01:00
|
|
|
setToIdenticon = not self.setAvatar(addressAtCurrentRow)
|
|
|
|
if setToIdenticon:
|
|
|
|
thisTableWidget.item(
|
|
|
|
currentRow, 0).setIcon(avatarize(addressAtCurrentRow))
|
|
|
|
|
|
|
|
def setAvatar(self, addressAtCurrentRow):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2017-01-11 17:00:00 +01:00
|
|
|
if not os.path.exists(state.appdata + 'avatars/'):
|
|
|
|
os.makedirs(state.appdata + 'avatars/')
|
2018-05-15 17:20:53 +02:00
|
|
|
addressHash = hashlib.md5(addBMIfNotPresent(addressAtCurrentRow)).hexdigest()
|
|
|
|
extensions = [
|
|
|
|
'PNG',
|
|
|
|
'GIF',
|
|
|
|
'JPG',
|
|
|
|
'JPEG',
|
|
|
|
'SVG',
|
|
|
|
'BMP',
|
|
|
|
'MNG',
|
|
|
|
'PBM',
|
|
|
|
'PGM',
|
|
|
|
'PPM',
|
|
|
|
'TIFF',
|
|
|
|
'XBM',
|
|
|
|
'XPM',
|
|
|
|
'TGA']
|
2013-09-20 14:30:53 +02:00
|
|
|
# http://pyqt.sourceforge.net/Docs/PyQt4/qimagereader.html#supportedImageFormats
|
2018-05-15 17:20:53 +02:00
|
|
|
names = {
|
|
|
|
'BMP': 'Windows Bitmap',
|
|
|
|
'GIF': 'Graphic Interchange Format',
|
|
|
|
'JPG': 'Joint Photographic Experts Group',
|
|
|
|
'JPEG': 'Joint Photographic Experts Group',
|
|
|
|
'MNG': 'Multiple-image Network Graphics',
|
|
|
|
'PNG': 'Portable Network Graphics',
|
|
|
|
'PBM': 'Portable Bitmap',
|
|
|
|
'PGM': 'Portable Graymap',
|
|
|
|
'PPM': 'Portable Pixmap',
|
|
|
|
'TIFF': 'Tagged Image File Format',
|
|
|
|
'XBM': 'X11 Bitmap',
|
|
|
|
'XPM': 'X11 Pixmap',
|
|
|
|
'SVG': 'Scalable Vector Graphics',
|
|
|
|
'TGA': 'Targa Image Format'}
|
2013-09-20 14:30:53 +02:00
|
|
|
filters = []
|
|
|
|
all_images_filter = []
|
2013-09-21 09:41:23 +02:00
|
|
|
current_files = []
|
2013-09-20 14:30:53 +02:00
|
|
|
for ext in extensions:
|
2018-05-15 17:20:53 +02:00
|
|
|
filters += [names[ext] + ' (*.' + ext.lower() + ')']
|
|
|
|
all_images_filter += ['*.' + ext.lower()]
|
|
|
|
upper = state.appdata + 'avatars/' + addressHash + '.' + ext.upper()
|
|
|
|
lower = state.appdata + 'avatars/' + addressHash + '.' + ext.lower()
|
2013-09-21 09:41:23 +02:00
|
|
|
if os.path.isfile(lower):
|
|
|
|
current_files += [lower]
|
|
|
|
elif os.path.isfile(upper):
|
|
|
|
current_files += [upper]
|
2013-09-20 14:30:53 +02:00
|
|
|
filters[0:0] = ['Image files (' + ' '.join(all_images_filter) + ')']
|
|
|
|
filters[1:1] = ['All files (*.*)']
|
2018-01-22 17:52:28 +01:00
|
|
|
sourcefile = QtGui.QFileDialog.getOpenFileName(
|
|
|
|
self, _translate("MainWindow", "Set avatar..."),
|
2018-05-15 17:20:53 +02:00
|
|
|
filter=';;'.join(filters)
|
2018-01-22 17:52:28 +01:00
|
|
|
)
|
2013-09-20 14:30:53 +02:00
|
|
|
# determine the correct filename (note that avatars don't use the suffix)
|
2018-05-15 17:20:53 +02:00
|
|
|
destination = state.appdata + 'avatars/' + addressHash + '.' + sourcefile.split('.')[-1]
|
2013-09-20 14:30:53 +02:00
|
|
|
exists = QtCore.QFile.exists(destination)
|
2013-09-21 09:41:23 +02:00
|
|
|
if sourcefile == '':
|
|
|
|
# ask for removal of avatar
|
2018-05-15 17:20:53 +02:00
|
|
|
if exists | current_files:
|
2013-09-21 09:41:23 +02:00
|
|
|
displayMsg = _translate("MainWindow", "Do you really want to remove this avatar?")
|
|
|
|
overwrite = QtGui.QMessageBox.question(
|
2018-05-15 17:20:53 +02:00
|
|
|
self, 'Message', displayMsg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
|
2013-09-21 09:41:23 +02:00
|
|
|
else:
|
|
|
|
overwrite = QtGui.QMessageBox.No
|
|
|
|
else:
|
|
|
|
# ask whether to overwrite old avatar
|
2018-05-15 17:20:53 +02:00
|
|
|
if exists | current_files:
|
|
|
|
displayMsg = _translate(
|
|
|
|
"MainWindow",
|
|
|
|
"You have already set an avatar for this address. Do you really want to overwrite it?")
|
2013-09-21 09:41:23 +02:00
|
|
|
overwrite = QtGui.QMessageBox.question(
|
2018-05-15 17:20:53 +02:00
|
|
|
self, 'Message', displayMsg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
|
2013-09-21 09:41:23 +02:00
|
|
|
else:
|
|
|
|
overwrite = QtGui.QMessageBox.No
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2013-09-21 09:41:23 +02:00
|
|
|
# copy the image file to the appdata folder
|
2018-05-15 17:20:53 +02:00
|
|
|
if not exists | overwrite == QtGui.QMessageBox.Yes:
|
2013-09-20 14:30:53 +02:00
|
|
|
if overwrite == QtGui.QMessageBox.Yes:
|
2018-05-15 17:20:53 +02:00
|
|
|
for file_name in current_files:
|
|
|
|
QtCore.QFile.remove(file_name)
|
2013-09-20 14:30:53 +02:00
|
|
|
QtCore.QFile.remove(destination)
|
2013-09-21 09:41:23 +02:00
|
|
|
# copy it
|
|
|
|
if sourcefile != '':
|
|
|
|
copied = QtCore.QFile.copy(sourcefile, destination)
|
|
|
|
if not copied:
|
2015-11-18 16:22:17 +01:00
|
|
|
logger.error('couldn\'t copy :(')
|
2013-09-20 14:30:53 +02:00
|
|
|
# set the icon
|
2015-03-23 22:35:56 +01:00
|
|
|
self.rerenderTabTreeMessages()
|
|
|
|
self.rerenderTabTreeSubscriptions()
|
|
|
|
self.rerenderTabTreeChans()
|
2013-09-21 09:41:23 +02:00
|
|
|
self.rerenderComboBoxSendFrom()
|
2015-03-21 11:37:08 +01:00
|
|
|
self.rerenderComboBoxSendFromBroadcast()
|
2016-01-23 20:24:50 +01:00
|
|
|
self.rerenderMessagelistFromLabels()
|
|
|
|
self.rerenderMessagelistToLabels()
|
2016-03-17 22:09:46 +01:00
|
|
|
self.ui.blackwhitelist.rerenderBlackWhiteList()
|
2015-03-21 11:37:08 +01:00
|
|
|
# generate identicon
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
2017-09-04 15:06:48 +02:00
|
|
|
|
|
|
|
def on_action_AddressBookSetSound(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2017-09-04 15:06:48 +02:00
|
|
|
widget = self.ui.tableWidgetAddressBook
|
|
|
|
self.setAddressSound(widget.item(widget.currentRow(), 0).text())
|
|
|
|
|
|
|
|
def setAddressSound(self, addr):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2017-09-04 15:06:48 +02:00
|
|
|
filters = [unicode(_translate(
|
|
|
|
"MainWindow", "Sound files (%s)" %
|
|
|
|
' '.join(['*%s%s' % (os.extsep, ext) for ext in sound.extensions])
|
|
|
|
))]
|
|
|
|
sourcefile = unicode(QtGui.QFileDialog.getOpenFileName(
|
|
|
|
self, _translate("MainWindow", "Set notification sound..."),
|
|
|
|
filter=';;'.join(filters)
|
|
|
|
))
|
|
|
|
|
|
|
|
if not sourcefile:
|
|
|
|
return
|
|
|
|
|
|
|
|
destdir = os.path.join(state.appdata, 'sounds')
|
|
|
|
destfile = unicode(addr) + os.path.splitext(sourcefile)[-1]
|
|
|
|
destination = os.path.join(destdir, destfile)
|
|
|
|
|
|
|
|
if sourcefile == destination:
|
|
|
|
return
|
|
|
|
|
|
|
|
pattern = destfile.lower()
|
|
|
|
for item in os.listdir(destdir):
|
|
|
|
if item.lower() == pattern:
|
|
|
|
overwrite = QtGui.QMessageBox.question(
|
|
|
|
self, _translate("MainWindow", "Message"),
|
|
|
|
_translate(
|
|
|
|
"MainWindow",
|
|
|
|
"You have already set a notification sound"
|
|
|
|
" for this address book entry."
|
|
|
|
" Do you really want to overwrite it?"),
|
|
|
|
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No
|
|
|
|
) == QtGui.QMessageBox.Yes
|
|
|
|
if overwrite:
|
|
|
|
QtCore.QFile.remove(os.path.join(destdir, item))
|
|
|
|
break
|
|
|
|
|
|
|
|
if not QtCore.QFile.copy(sourcefile, destination):
|
|
|
|
logger.error(
|
|
|
|
'couldn\'t copy %s to %s', sourcefile, destination)
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def on_context_menuYourIdentities(self, point):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2016-01-24 18:25:09 +01:00
|
|
|
currentItem = self.getCurrentItem()
|
2015-11-01 08:46:27 +01:00
|
|
|
self.popMenuYourIdentities = QtGui.QMenu(self)
|
2016-08-20 22:38:36 +02:00
|
|
|
if isinstance(currentItem, Ui_AddressWidget):
|
|
|
|
self.popMenuYourIdentities.addAction(self.actionNewYourIdentities)
|
|
|
|
self.popMenuYourIdentities.addSeparator()
|
|
|
|
self.popMenuYourIdentities.addAction(self.actionClipboardYourIdentities)
|
|
|
|
self.popMenuYourIdentities.addSeparator()
|
|
|
|
if currentItem.isEnabled:
|
|
|
|
self.popMenuYourIdentities.addAction(self.actionDisableYourIdentities)
|
|
|
|
else:
|
|
|
|
self.popMenuYourIdentities.addAction(self.actionEnableYourIdentities)
|
|
|
|
self.popMenuYourIdentities.addAction(self.actionSetAvatarYourIdentities)
|
|
|
|
self.popMenuYourIdentities.addAction(self.actionSpecialAddressBehaviorYourIdentities)
|
|
|
|
self.popMenuYourIdentities.addAction(self.actionEmailGateway)
|
|
|
|
self.popMenuYourIdentities.addSeparator()
|
2018-02-20 15:22:46 +01:00
|
|
|
if currentItem.type != AccountMixin.ALL:
|
|
|
|
# preloaded gui.menu plugins with prefix 'address'
|
|
|
|
for plugin in self.menu_plugins['address']:
|
|
|
|
self.popMenuYourIdentities.addAction(plugin)
|
2017-03-07 14:44:48 +01:00
|
|
|
self.popMenuYourIdentities.addSeparator()
|
2016-08-20 22:38:36 +02:00
|
|
|
self.popMenuYourIdentities.addAction(self.actionMarkAllRead)
|
2017-03-01 15:46:13 +01:00
|
|
|
|
2015-03-21 11:37:08 +01:00
|
|
|
self.popMenuYourIdentities.exec_(
|
|
|
|
self.ui.treeWidgetYourIdentities.mapToGlobal(point))
|
|
|
|
|
|
|
|
def on_context_menuChan(self, point):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TODO: make one popMenu"""
|
|
|
|
|
2016-01-24 18:25:09 +01:00
|
|
|
currentItem = self.getCurrentItem()
|
2015-11-01 08:46:27 +01:00
|
|
|
self.popMenu = QtGui.QMenu(self)
|
2016-08-20 22:38:36 +02:00
|
|
|
if isinstance(currentItem, Ui_AddressWidget):
|
|
|
|
self.popMenu.addAction(self.actionNew)
|
|
|
|
self.popMenu.addAction(self.actionDelete)
|
|
|
|
self.popMenu.addSeparator()
|
|
|
|
self.popMenu.addAction(self.actionClipboard)
|
|
|
|
self.popMenu.addSeparator()
|
|
|
|
if currentItem.isEnabled:
|
|
|
|
self.popMenu.addAction(self.actionDisable)
|
|
|
|
else:
|
|
|
|
self.popMenu.addAction(self.actionEnable)
|
|
|
|
self.popMenu.addAction(self.actionSetAvatar)
|
|
|
|
self.popMenu.addSeparator()
|
2017-03-07 14:44:48 +01:00
|
|
|
# preloaded gui.menu plugins with prefix 'address'
|
|
|
|
for plugin in self.menu_plugins['address']:
|
|
|
|
self.popMenu.addAction(plugin)
|
|
|
|
self.popMenu.addSeparator()
|
2016-08-20 22:38:36 +02:00
|
|
|
self.popMenu.addAction(self.actionMarkAllRead)
|
2013-06-12 23:12:32 +02:00
|
|
|
self.popMenu.exec_(
|
2015-03-23 22:35:56 +01:00
|
|
|
self.ui.treeWidgetChans.mapToGlobal(point))
|
2013-06-12 23:12:32 +02:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def on_context_menuInbox(self, point):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
tableWidget = self.getCurrentMessagelist()
|
|
|
|
if tableWidget:
|
|
|
|
currentFolder = self.getCurrentFolder()
|
2015-11-01 11:08:41 +01:00
|
|
|
if currentFolder is None:
|
2015-03-23 22:35:56 +01:00
|
|
|
pass
|
|
|
|
if currentFolder == 'sent':
|
|
|
|
self.on_context_menuSent(point)
|
|
|
|
else:
|
2015-11-01 10:56:37 +01:00
|
|
|
self.popMenuInbox = QtGui.QMenu(self)
|
|
|
|
self.popMenuInbox.addAction(self.actionForceHtml)
|
|
|
|
self.popMenuInbox.addAction(self.actionMarkUnread)
|
|
|
|
self.popMenuInbox.addSeparator()
|
2015-12-20 01:21:54 +01:00
|
|
|
address = tableWidget.item(
|
2018-01-22 17:52:28 +01:00
|
|
|
tableWidget.currentRow(), 0).data(QtCore.Qt.UserRole)
|
2015-12-14 13:07:17 +01:00
|
|
|
account = accountClass(address)
|
|
|
|
if account.type == AccountMixin.CHAN:
|
|
|
|
self.popMenuInbox.addAction(self.actionReplyChan)
|
2015-11-01 10:56:37 +01:00
|
|
|
self.popMenuInbox.addAction(self.actionReply)
|
|
|
|
self.popMenuInbox.addAction(self.actionAddSenderToAddressBook)
|
2015-12-14 12:21:00 +01:00
|
|
|
self.actionClipboardMessagelist = self.ui.inboxContextMenuToolbar.addAction(
|
2018-05-15 17:20:53 +02:00
|
|
|
_translate(
|
|
|
|
"MainWindow", "Copy subject to clipboard"
|
|
|
|
if tableWidget.currentColumn() == 2 else "Copy address to clipboard"),
|
2015-12-14 12:21:00 +01:00
|
|
|
self.on_action_ClipboardMessagelist)
|
|
|
|
self.popMenuInbox.addAction(self.actionClipboardMessagelist)
|
2015-11-01 10:56:37 +01:00
|
|
|
self.popMenuInbox.addSeparator()
|
2015-11-14 01:14:10 +01:00
|
|
|
self.popMenuInbox.addAction(self.actionAddSenderToBlackList)
|
|
|
|
self.popMenuInbox.addSeparator()
|
2015-11-01 10:56:37 +01:00
|
|
|
self.popMenuInbox.addAction(self.actionSaveMessageAs)
|
|
|
|
if currentFolder == "trash":
|
|
|
|
self.popMenuInbox.addAction(self.actionUndeleteTrashedMessage)
|
|
|
|
else:
|
|
|
|
self.popMenuInbox.addAction(self.actionTrashInboxMessage)
|
2015-03-23 22:35:56 +01:00
|
|
|
self.popMenuInbox.exec_(tableWidget.mapToGlobal(point))
|
2013-06-12 23:12:32 +02:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def on_context_menuSent(self, point):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
self.popMenuSent = QtGui.QMenu(self)
|
|
|
|
self.popMenuSent.addAction(self.actionSentClipboard)
|
|
|
|
self.popMenuSent.addAction(self.actionTrashSentMessage)
|
|
|
|
|
|
|
|
# Check to see if this item is toodifficult and display an additional
|
|
|
|
# menu option (Force Send) if it is.
|
2015-03-03 18:17:56 +01:00
|
|
|
currentRow = self.ui.tableWidgetInbox.currentRow()
|
2015-03-23 22:35:56 +01:00
|
|
|
if currentRow >= 0:
|
|
|
|
ackData = str(self.ui.tableWidgetInbox.item(
|
2018-01-22 17:52:28 +01:00
|
|
|
currentRow, 3).data(QtCore.Qt.UserRole).toPyObject())
|
2015-03-23 22:35:56 +01:00
|
|
|
queryreturn = sqlQuery('''SELECT status FROM sent where ackdata=?''', ackData)
|
|
|
|
for row in queryreturn:
|
|
|
|
status, = row
|
|
|
|
if status == 'toodifficult':
|
|
|
|
self.popMenuSent.addAction(self.actionForceSend)
|
|
|
|
|
2015-03-03 18:17:56 +01:00
|
|
|
self.popMenuSent.exec_(self.ui.tableWidgetInbox.mapToGlobal(point))
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2016-03-01 08:23:51 +01:00
|
|
|
def inboxSearchLineEditUpdated(self, text):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2016-03-01 08:23:51 +01:00
|
|
|
# dynamic search for too short text is slow
|
|
|
|
if len(str(text)) < 3:
|
|
|
|
return
|
2016-02-14 19:56:05 +01:00
|
|
|
messagelist = self.getCurrentMessagelist()
|
2016-03-01 08:23:51 +01:00
|
|
|
searchOption = self.getCurrentSearchOption()
|
2016-02-14 19:56:05 +01:00
|
|
|
if messagelist:
|
2016-03-01 08:23:51 +01:00
|
|
|
account = self.getCurrentAccount()
|
|
|
|
folder = self.getCurrentFolder()
|
|
|
|
self.loadMessagelist(messagelist, account, folder, searchOption, str(text))
|
|
|
|
|
|
|
|
def inboxSearchLineEditReturnPressed(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2016-03-01 08:23:51 +01:00
|
|
|
logger.debug("Search return pressed")
|
|
|
|
searchLine = self.getCurrentSearchLine()
|
|
|
|
messagelist = self.getCurrentMessagelist()
|
|
|
|
if len(str(searchLine)) < 3:
|
|
|
|
searchOption = self.getCurrentSearchOption()
|
2016-02-14 19:56:05 +01:00
|
|
|
account = self.getCurrentAccount()
|
|
|
|
folder = self.getCurrentFolder()
|
|
|
|
self.loadMessagelist(messagelist, account, folder, searchOption, searchLine)
|
2016-03-01 08:23:51 +01:00
|
|
|
if messagelist:
|
|
|
|
messagelist.setFocus()
|
2015-03-23 22:35:56 +01:00
|
|
|
|
|
|
|
def treeWidgetItemClicked(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2016-02-14 19:56:05 +01:00
|
|
|
searchLine = self.getCurrentSearchLine()
|
|
|
|
searchOption = self.getCurrentSearchOption()
|
|
|
|
messageTextedit = self.getCurrentMessageTextedit()
|
|
|
|
if messageTextedit:
|
2018-01-22 17:52:28 +01:00
|
|
|
messageTextedit.setPlainText(QtCore.QString(""))
|
2015-03-23 22:35:56 +01:00
|
|
|
messagelist = self.getCurrentMessagelist()
|
|
|
|
if messagelist:
|
|
|
|
account = self.getCurrentAccount()
|
|
|
|
folder = self.getCurrentFolder()
|
2016-05-23 11:10:55 +02:00
|
|
|
treeWidget = self.getCurrentTreeWidget()
|
|
|
|
# refresh count indicator
|
|
|
|
self.propagateUnreadCount(account.address if hasattr(account, 'address') else None, folder, treeWidget, 0)
|
2016-02-14 19:56:05 +01:00
|
|
|
self.loadMessagelist(messagelist, account, folder, searchOption, searchLine)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2015-10-04 10:47:51 +02:00
|
|
|
def treeWidgetItemChanged(self, item, column):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-10-04 10:57:14 +02:00
|
|
|
# only for manual edits. automatic edits (setText) are ignored
|
|
|
|
if column != 0:
|
|
|
|
return
|
2015-10-05 10:32:56 +02:00
|
|
|
# only account names of normal addresses (no chans/mailinglists)
|
2018-05-15 17:20:53 +02:00
|
|
|
if any(
|
|
|
|
[
|
|
|
|
not isinstance(item, Ui_AddressWidget),
|
|
|
|
not self.getCurrentTreeWidget(),
|
|
|
|
self.getCurrentTreeWidget().currentItem() is None,
|
|
|
|
]
|
|
|
|
):
|
2015-10-05 17:07:23 +02:00
|
|
|
return
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-10-05 17:07:23 +02:00
|
|
|
# not visible
|
2018-05-15 17:20:53 +02:00
|
|
|
if (not self.getCurrentItem()) or (not isinstance(self.getCurrentItem(), Ui_AddressWidget)):
|
2015-10-04 10:57:14 +02:00
|
|
|
return
|
|
|
|
# only currently selected item
|
2015-10-19 17:22:37 +02:00
|
|
|
if item.address != self.getCurrentAccount():
|
2015-10-04 10:57:14 +02:00
|
|
|
return
|
2016-01-10 17:45:49 +01:00
|
|
|
# "All accounts" can't be renamed
|
|
|
|
if item.type == AccountMixin.ALL:
|
|
|
|
return
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2016-03-12 10:58:48 +01:00
|
|
|
newLabel = unicode(item.text(0), 'utf-8', 'ignore')
|
2016-01-23 22:18:07 +01:00
|
|
|
oldLabel = item.defaultLabel()
|
|
|
|
|
2015-10-04 10:57:14 +02:00
|
|
|
# unchanged, do not do anything either
|
|
|
|
if newLabel == oldLabel:
|
|
|
|
return
|
2015-10-04 20:32:17 +02:00
|
|
|
|
|
|
|
# recursion prevention
|
|
|
|
if self.recurDepth > 0:
|
|
|
|
return
|
|
|
|
|
|
|
|
self.recurDepth += 1
|
2016-01-23 20:24:50 +01:00
|
|
|
if item.type == AccountMixin.NORMAL or item.type == AccountMixin.MAILINGLIST:
|
2015-10-19 20:17:28 +02:00
|
|
|
self.rerenderComboBoxSendFromBroadcast()
|
2016-01-23 20:24:50 +01:00
|
|
|
if item.type == AccountMixin.NORMAL or item.type == AccountMixin.CHAN:
|
2015-10-19 20:17:28 +02:00
|
|
|
self.rerenderComboBoxSendFrom()
|
2016-01-23 20:24:50 +01:00
|
|
|
self.rerenderMessagelistFromLabels()
|
|
|
|
if item.type != AccountMixin.SUBSCRIPTION:
|
|
|
|
self.rerenderMessagelistToLabels()
|
2016-01-23 22:18:07 +01:00
|
|
|
if item.type in (AccountMixin.NORMAL, AccountMixin.CHAN, AccountMixin.SUBSCRIPTION):
|
|
|
|
self.rerenderAddressBook()
|
2015-10-04 20:32:17 +02:00
|
|
|
self.recurDepth -= 1
|
2015-10-04 10:47:51 +02:00
|
|
|
|
2015-03-03 18:17:56 +01:00
|
|
|
def tableWidgetInboxItemClicked(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
folder = self.getCurrentFolder()
|
|
|
|
messageTextedit = self.getCurrentMessageTextedit()
|
2015-11-12 01:43:06 +01:00
|
|
|
if not messageTextedit:
|
|
|
|
return
|
2015-03-23 22:35:56 +01:00
|
|
|
|
2018-02-06 14:48:56 +01:00
|
|
|
msgid = self.getCurrentMessageId()
|
|
|
|
if msgid:
|
|
|
|
queryreturn = sqlQuery(
|
|
|
|
'''SELECT message FROM %s WHERE %s=?''' % (
|
|
|
|
('sent', 'ackdata') if folder == 'sent'
|
|
|
|
else ('inbox', 'msgid')
|
|
|
|
), msgid
|
|
|
|
)
|
2015-03-23 22:35:56 +01:00
|
|
|
|
2018-02-06 14:48:56 +01:00
|
|
|
try:
|
|
|
|
message = queryreturn[-1][0]
|
|
|
|
except NameError:
|
|
|
|
message = ""
|
|
|
|
except IndexError:
|
|
|
|
message = _translate(
|
|
|
|
"MainWindow",
|
|
|
|
"Error occurred: could not load message from disk."
|
|
|
|
)
|
|
|
|
else:
|
2016-01-24 12:16:41 +01:00
|
|
|
tableWidget = self.getCurrentMessagelist()
|
|
|
|
currentRow = tableWidget.currentRow()
|
2018-02-06 14:48:56 +01:00
|
|
|
# refresh
|
|
|
|
if tableWidget.item(currentRow, 0).unread is True:
|
|
|
|
self.updateUnreadStatus(tableWidget, currentRow, msgid)
|
|
|
|
# propagate
|
2018-05-15 17:20:53 +02:00
|
|
|
if all(
|
|
|
|
[
|
|
|
|
folder != 'sent',
|
|
|
|
sqlExecute('''UPDATE inbox SET read=1 WHERE msgid=? AND read=0''', msgid) > 0,
|
|
|
|
]
|
|
|
|
):
|
2018-02-06 14:48:56 +01:00
|
|
|
self.propagateUnreadCount()
|
2015-10-02 22:24:46 +02:00
|
|
|
|
2015-11-11 00:51:55 +01:00
|
|
|
messageTextedit.setCurrentFont(QtGui.QFont())
|
|
|
|
messageTextedit.setTextColor(QtGui.QColor())
|
2015-12-14 19:43:39 +01:00
|
|
|
messageTextedit.setContent(message)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2016-01-23 22:18:07 +01:00
|
|
|
def tableWidgetAddressBookItemChanged(self, item):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2016-01-23 22:18:07 +01:00
|
|
|
if item.type == AccountMixin.CHAN:
|
|
|
|
self.rerenderComboBoxSendFrom()
|
2016-01-23 20:24:50 +01:00
|
|
|
self.rerenderMessagelistFromLabels()
|
|
|
|
self.rerenderMessagelistToLabels()
|
2017-02-14 01:35:32 +01:00
|
|
|
completerList = self.ui.lineEditTo.completer().model().stringList()
|
2018-05-15 17:20:53 +02:00
|
|
|
for i, this_item in enumerate(completerList):
|
|
|
|
if unicode(this_item).endswith(" <" + item.address + ">"):
|
|
|
|
this_item = item.label + " <" + item.address + ">"
|
2017-02-14 13:57:20 +01:00
|
|
|
self.ui.lineEditTo.completer().model().setStringList(completerList)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2018-02-05 13:39:32 +01:00
|
|
|
def tabWidgetCurrentChanged(self, n):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2018-02-05 13:39:32 +01:00
|
|
|
if n == self.ui.tabWidget.indexOf(self.ui.networkstatus):
|
|
|
|
self.ui.networkstatus.startUpdate()
|
|
|
|
else:
|
|
|
|
self.ui.networkstatus.stopUpdate()
|
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
def writeNewAddressToTable(self, label, address, streamNumber):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-03-23 22:35:56 +01:00
|
|
|
self.rerenderTabTreeMessages()
|
|
|
|
self.rerenderTabTreeSubscriptions()
|
|
|
|
self.rerenderTabTreeChans()
|
2013-05-02 17:53:54 +02:00
|
|
|
self.rerenderComboBoxSendFrom()
|
2015-03-21 11:37:08 +01:00
|
|
|
self.rerenderComboBoxSendFromBroadcast()
|
2017-02-14 01:35:32 +01:00
|
|
|
self.rerenderAddressBook()
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
def updateStatusBar(self, data):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
|
|
|
if isinstance(data, (tuple, list)):
|
2016-12-15 16:11:29 +01:00
|
|
|
option = data[1]
|
|
|
|
message = data[0]
|
|
|
|
else:
|
|
|
|
option = 0
|
|
|
|
message = data
|
|
|
|
if message != "":
|
2018-05-15 17:20:53 +02:00
|
|
|
logger.info('Status bar: %s', message)
|
2013-06-29 19:29:35 +02:00
|
|
|
|
2016-12-15 16:11:29 +01:00
|
|
|
if option == 1:
|
2018-01-23 17:15:11 +01:00
|
|
|
self.statusbar.addImportant(message)
|
2016-12-15 16:11:29 +01:00
|
|
|
else:
|
2018-01-23 17:15:11 +01:00
|
|
|
self.statusbar.showMessage(message, 10000)
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2015-11-08 21:44:02 +01:00
|
|
|
def initSettings(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-11-08 21:44:02 +01:00
|
|
|
QtCore.QCoreApplication.setOrganizationName("PyBitmessage")
|
|
|
|
QtCore.QCoreApplication.setOrganizationDomain("bitmessage.org")
|
|
|
|
QtCore.QCoreApplication.setApplicationName("pybitmessageqt")
|
|
|
|
self.loadSettings()
|
|
|
|
for attr, obj in self.ui.__dict__.iteritems():
|
2018-01-23 17:15:11 +01:00
|
|
|
if hasattr(obj, "__class__") and \
|
|
|
|
isinstance(obj, settingsmixin.SettingsMixin):
|
2015-11-08 21:44:02 +01:00
|
|
|
loadMethod = getattr(obj, "loadSettings", None)
|
2018-01-23 17:15:11 +01:00
|
|
|
if callable(loadMethod):
|
2015-11-08 21:44:02 +01:00
|
|
|
obj.loadSettings()
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
class settingsDialog(QtGui.QDialog):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
2013-06-12 23:12:32 +02:00
|
|
|
|
|
|
|
def __init__(self, parent):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
QtGui.QWidget.__init__(self, parent)
|
|
|
|
self.ui = Ui_settingsDialog()
|
|
|
|
self.ui.setupUi(self)
|
|
|
|
self.parent = parent
|
2013-06-12 23:12:32 +02:00
|
|
|
self.ui.checkBoxStartOnLogon.setChecked(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().getboolean('bitmessagesettings', 'startonlogon'))
|
2013-06-12 23:12:32 +02:00
|
|
|
self.ui.checkBoxMinimizeToTray.setChecked(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().getboolean('bitmessagesettings', 'minimizetotray'))
|
2016-03-01 02:50:31 +01:00
|
|
|
self.ui.checkBoxTrayOnClose.setChecked(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().safeGetBoolean('bitmessagesettings', 'trayonclose'))
|
2016-10-07 01:58:40 +02:00
|
|
|
self.ui.checkBoxHideTrayConnectionNotifications.setChecked(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().getboolean("bitmessagesettings", "hidetrayconnectionnotifications"))
|
2013-06-12 23:12:32 +02:00
|
|
|
self.ui.checkBoxShowTrayNotifications.setChecked(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().getboolean('bitmessagesettings', 'showtraynotifications'))
|
2013-06-12 23:12:32 +02:00
|
|
|
self.ui.checkBoxStartInTray.setChecked(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().getboolean('bitmessagesettings', 'startintray'))
|
2013-08-08 21:37:48 +02:00
|
|
|
self.ui.checkBoxWillinglySendToMobile.setChecked(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().safeGetBoolean('bitmessagesettings', 'willinglysendtomobile'))
|
2013-11-02 00:25:24 +01:00
|
|
|
self.ui.checkBoxUseIdenticons.setChecked(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().safeGetBoolean('bitmessagesettings', 'useidenticons'))
|
2014-01-28 20:57:01 +01:00
|
|
|
self.ui.checkBoxReplyBelow.setChecked(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().safeGetBoolean('bitmessagesettings', 'replybelow'))
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2017-01-11 17:00:00 +01:00
|
|
|
if state.appdata == paths.lookupExeFolder():
|
2013-05-02 17:53:54 +02:00
|
|
|
self.ui.checkBoxPortableMode.setChecked(True)
|
2015-12-16 16:18:38 +01:00
|
|
|
else:
|
|
|
|
try:
|
|
|
|
import tempfile
|
2017-10-09 11:09:09 +02:00
|
|
|
tempfile.NamedTemporaryFile(
|
|
|
|
dir=paths.lookupExeFolder(), delete=True
|
|
|
|
).close() # should autodelete
|
2015-12-16 16:18:38 +01:00
|
|
|
except:
|
|
|
|
self.ui.checkBoxPortableMode.setDisabled(True)
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
if 'darwin' in sys.platform:
|
|
|
|
self.ui.checkBoxStartOnLogon.setDisabled(True)
|
2013-11-02 05:19:54 +01:00
|
|
|
self.ui.checkBoxStartOnLogon.setText(_translate(
|
|
|
|
"MainWindow", "Start-on-login not yet supported on your OS."))
|
2013-05-02 17:53:54 +02:00
|
|
|
self.ui.checkBoxMinimizeToTray.setDisabled(True)
|
2013-11-02 05:19:54 +01:00
|
|
|
self.ui.checkBoxMinimizeToTray.setText(_translate(
|
|
|
|
"MainWindow", "Minimize-to-tray not yet supported on your OS."))
|
2013-05-02 17:53:54 +02:00
|
|
|
self.ui.checkBoxShowTrayNotifications.setDisabled(True)
|
2013-11-02 05:19:54 +01:00
|
|
|
self.ui.checkBoxShowTrayNotifications.setText(_translate(
|
|
|
|
"MainWindow", "Tray notifications not yet supported on your OS."))
|
2013-05-02 17:53:54 +02:00
|
|
|
elif 'linux' in sys.platform:
|
|
|
|
self.ui.checkBoxStartOnLogon.setDisabled(True)
|
2013-11-02 05:19:54 +01:00
|
|
|
self.ui.checkBoxStartOnLogon.setText(_translate(
|
|
|
|
"MainWindow", "Start-on-login not yet supported on your OS."))
|
2013-06-12 23:12:32 +02:00
|
|
|
# On the Network settings tab:
|
|
|
|
self.ui.lineEditTCPPort.setText(str(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().get('bitmessagesettings', 'port')))
|
2015-11-22 13:02:06 +01:00
|
|
|
self.ui.checkBoxUPnP.setChecked(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().safeGetBoolean('bitmessagesettings', 'upnp'))
|
|
|
|
self.ui.checkBoxAuthentication.setChecked(BMConfigParser().getboolean(
|
2013-06-12 23:12:32 +02:00
|
|
|
'bitmessagesettings', 'socksauthentication'))
|
2017-01-11 14:27:19 +01:00
|
|
|
self.ui.checkBoxSocksListen.setChecked(BMConfigParser().getboolean(
|
2013-07-12 20:03:09 +02:00
|
|
|
'bitmessagesettings', 'sockslisten'))
|
2017-01-11 14:27:19 +01:00
|
|
|
if str(BMConfigParser().get('bitmessagesettings', 'socksproxytype')) == 'none':
|
2013-05-02 17:53:54 +02:00
|
|
|
self.ui.comboBoxProxyType.setCurrentIndex(0)
|
|
|
|
self.ui.lineEditSocksHostname.setEnabled(False)
|
|
|
|
self.ui.lineEditSocksPort.setEnabled(False)
|
|
|
|
self.ui.lineEditSocksUsername.setEnabled(False)
|
|
|
|
self.ui.lineEditSocksPassword.setEnabled(False)
|
|
|
|
self.ui.checkBoxAuthentication.setEnabled(False)
|
2013-07-12 20:03:09 +02:00
|
|
|
self.ui.checkBoxSocksListen.setEnabled(False)
|
2017-01-11 14:27:19 +01:00
|
|
|
elif str(BMConfigParser().get('bitmessagesettings', 'socksproxytype')) == 'SOCKS4a':
|
2013-05-02 17:53:54 +02:00
|
|
|
self.ui.comboBoxProxyType.setCurrentIndex(1)
|
2017-01-11 14:27:19 +01:00
|
|
|
elif str(BMConfigParser().get('bitmessagesettings', 'socksproxytype')) == 'SOCKS5':
|
2013-05-02 17:53:54 +02:00
|
|
|
self.ui.comboBoxProxyType.setCurrentIndex(2)
|
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
self.ui.lineEditSocksHostname.setText(str(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().get('bitmessagesettings', 'sockshostname')))
|
2013-06-12 23:12:32 +02:00
|
|
|
self.ui.lineEditSocksPort.setText(str(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().get('bitmessagesettings', 'socksport')))
|
2013-06-12 23:12:32 +02:00
|
|
|
self.ui.lineEditSocksUsername.setText(str(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().get('bitmessagesettings', 'socksusername')))
|
2013-06-12 23:12:32 +02:00
|
|
|
self.ui.lineEditSocksPassword.setText(str(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().get('bitmessagesettings', 'sockspassword')))
|
2013-06-12 23:12:32 +02:00
|
|
|
QtCore.QObject.connect(self.ui.comboBoxProxyType, QtCore.SIGNAL(
|
|
|
|
"currentIndexChanged(int)"), self.comboBoxProxyTypeChanged)
|
2014-09-10 22:47:51 +02:00
|
|
|
self.ui.lineEditMaxDownloadRate.setText(str(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().get('bitmessagesettings', 'maxdownloadrate')))
|
2014-09-10 22:47:51 +02:00
|
|
|
self.ui.lineEditMaxUploadRate.setText(str(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().get('bitmessagesettings', 'maxuploadrate')))
|
2017-01-13 02:12:11 +01:00
|
|
|
self.ui.lineEditMaxOutboundConnections.setText(str(
|
|
|
|
BMConfigParser().get('bitmessagesettings', 'maxoutboundconnections')))
|
2013-06-12 23:12:32 +02:00
|
|
|
|
2014-09-10 22:47:51 +02:00
|
|
|
# Demanded difficulty tab
|
2018-05-15 17:20:53 +02:00
|
|
|
self.ui.lineEditTotalDifficulty.setText(
|
|
|
|
str(
|
|
|
|
float(
|
|
|
|
BMConfigParser().getint('bitmessagesettings', 'defaultnoncetrialsperbyte')
|
|
|
|
) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte
|
|
|
|
)
|
|
|
|
)
|
|
|
|
self.ui.lineEditSmallMessageDifficulty.setText(
|
|
|
|
str(
|
|
|
|
float(
|
|
|
|
BMConfigParser().getint('bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
|
|
|
) / defaults.networkDefaultPayloadLengthExtraBytes
|
|
|
|
)
|
|
|
|
)
|
2013-06-12 23:12:32 +02:00
|
|
|
|
|
|
|
# Max acceptable difficulty tab
|
2018-05-15 17:20:53 +02:00
|
|
|
self.ui.lineEditMaxAcceptableTotalDifficulty.setText(
|
|
|
|
str(
|
|
|
|
float(
|
|
|
|
BMConfigParser().getint('bitmessagesettings', 'maxacceptablenoncetrialsperbyte')
|
|
|
|
) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte
|
|
|
|
)
|
|
|
|
)
|
|
|
|
self.ui.lineEditMaxAcceptableSmallMessageDifficulty.setText(
|
|
|
|
str(
|
|
|
|
float(
|
|
|
|
BMConfigParser().getint('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes')
|
|
|
|
) / defaults.networkDefaultPayloadLengthExtraBytes
|
|
|
|
)
|
|
|
|
)
|
2013-06-11 00:53:15 +02:00
|
|
|
|
2015-11-26 02:37:07 +01:00
|
|
|
# OpenCL
|
2016-11-10 21:43:10 +01:00
|
|
|
if openclpow.openclAvailable():
|
|
|
|
self.ui.comboBoxOpenCL.setEnabled(True)
|
2015-11-26 02:37:07 +01:00
|
|
|
else:
|
2016-11-10 21:43:10 +01:00
|
|
|
self.ui.comboBoxOpenCL.setEnabled(False)
|
|
|
|
self.ui.comboBoxOpenCL.clear()
|
|
|
|
self.ui.comboBoxOpenCL.addItem("None")
|
|
|
|
self.ui.comboBoxOpenCL.addItems(openclpow.vendors)
|
|
|
|
self.ui.comboBoxOpenCL.setCurrentIndex(0)
|
|
|
|
for i in range(self.ui.comboBoxOpenCL.count()):
|
2017-01-11 14:27:19 +01:00
|
|
|
if self.ui.comboBoxOpenCL.itemText(i) == BMConfigParser().safeGet('bitmessagesettings', 'opencl'):
|
2016-11-10 21:43:10 +01:00
|
|
|
self.ui.comboBoxOpenCL.setCurrentIndex(i)
|
|
|
|
break
|
2015-11-26 02:37:07 +01:00
|
|
|
|
2013-07-07 17:34:43 +02:00
|
|
|
# Namecoin integration tab
|
2017-01-11 14:27:19 +01:00
|
|
|
nmctype = BMConfigParser().get('bitmessagesettings', 'namecoinrpctype')
|
2013-07-07 17:34:43 +02:00
|
|
|
self.ui.lineEditNamecoinHost.setText(str(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().get('bitmessagesettings', 'namecoinrpchost')))
|
2013-07-07 17:34:43 +02:00
|
|
|
self.ui.lineEditNamecoinPort.setText(str(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().get('bitmessagesettings', 'namecoinrpcport')))
|
2013-07-07 17:34:43 +02:00
|
|
|
self.ui.lineEditNamecoinUser.setText(str(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().get('bitmessagesettings', 'namecoinrpcuser')))
|
2013-07-07 17:34:43 +02:00
|
|
|
self.ui.lineEditNamecoinPassword.setText(str(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().get('bitmessagesettings', 'namecoinrpcpassword')))
|
2013-07-07 20:04:57 +02:00
|
|
|
|
|
|
|
if nmctype == "namecoind":
|
|
|
|
self.ui.radioButtonNamecoinNamecoind.setChecked(True)
|
|
|
|
elif nmctype == "nmcontrol":
|
|
|
|
self.ui.radioButtonNamecoinNmcontrol.setChecked(True)
|
|
|
|
self.ui.lineEditNamecoinUser.setEnabled(False)
|
|
|
|
self.ui.labelNamecoinUser.setEnabled(False)
|
|
|
|
self.ui.lineEditNamecoinPassword.setEnabled(False)
|
|
|
|
self.ui.labelNamecoinPassword.setEnabled(False)
|
|
|
|
else:
|
|
|
|
assert False
|
|
|
|
|
|
|
|
QtCore.QObject.connect(self.ui.radioButtonNamecoinNamecoind, QtCore.SIGNAL(
|
|
|
|
"toggled(bool)"), self.namecoinTypeChanged)
|
|
|
|
QtCore.QObject.connect(self.ui.radioButtonNamecoinNmcontrol, QtCore.SIGNAL(
|
|
|
|
"toggled(bool)"), self.namecoinTypeChanged)
|
2013-07-07 18:41:13 +02:00
|
|
|
QtCore.QObject.connect(self.ui.pushButtonNamecoinTest, QtCore.SIGNAL(
|
|
|
|
"clicked()"), self.click_pushButtonNamecoinTest)
|
2013-07-07 17:34:43 +02:00
|
|
|
|
2018-05-15 17:20:53 +02:00
|
|
|
# Message Resend tab
|
2013-09-28 02:47:16 +02:00
|
|
|
self.ui.lineEditDays.setText(str(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().get('bitmessagesettings', 'stopresendingafterxdays')))
|
2013-09-28 02:47:16 +02:00
|
|
|
self.ui.lineEditMonths.setText(str(
|
2017-01-11 14:27:19 +01:00
|
|
|
BMConfigParser().get('bitmessagesettings', 'stopresendingafterxmonths')))
|
2013-05-30 22:25:42 +02:00
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
|
2013-05-02 17:53:54 +02:00
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
def comboBoxProxyTypeChanged(self, comboBoxIndex):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
if comboBoxIndex == 0:
|
|
|
|
self.ui.lineEditSocksHostname.setEnabled(False)
|
|
|
|
self.ui.lineEditSocksPort.setEnabled(False)
|
|
|
|
self.ui.lineEditSocksUsername.setEnabled(False)
|
|
|
|
self.ui.lineEditSocksPassword.setEnabled(False)
|
|
|
|
self.ui.checkBoxAuthentication.setEnabled(False)
|
2013-07-12 20:03:09 +02:00
|
|
|
self.ui.checkBoxSocksListen.setEnabled(False)
|
2013-05-02 17:53:54 +02:00
|
|
|
elif comboBoxIndex == 1 or comboBoxIndex == 2:
|
|
|
|
self.ui.lineEditSocksHostname.setEnabled(True)
|
|
|
|
self.ui.lineEditSocksPort.setEnabled(True)
|
|
|
|
self.ui.checkBoxAuthentication.setEnabled(True)
|
2013-07-12 20:03:09 +02:00
|
|
|
self.ui.checkBoxSocksListen.setEnabled(True)
|
2013-05-02 17:53:54 +02:00
|
|
|
if self.ui.checkBoxAuthentication.isChecked():
|
|
|
|
self.ui.lineEditSocksUsername.setEnabled(True)
|
|
|
|
self.ui.lineEditSocksPassword.setEnabled(True)
|
|
|
|
|
2013-07-07 20:04:57 +02:00
|
|
|
def getNamecoinType(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Check status of namecoin integration radio buttons and translate it to a string as in the options."""
|
|
|
|
|
2013-07-07 20:04:57 +02:00
|
|
|
if self.ui.radioButtonNamecoinNamecoind.isChecked():
|
|
|
|
return "namecoind"
|
2018-05-15 17:20:53 +02:00
|
|
|
elif self.ui.radioButtonNamecoinNmcontrol.isChecked():
|
2013-07-07 20:04:57 +02:00
|
|
|
return "nmcontrol"
|
2018-05-15 17:20:53 +02:00
|
|
|
logger.info("Neither namecoind nor nmcontrol were checked. This is a fatal error")
|
|
|
|
sys.exit(1)
|
2013-07-07 20:04:57 +02:00
|
|
|
|
|
|
|
def namecoinTypeChanged(self, checked):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Namecoin connection type was changed."""
|
|
|
|
|
2013-07-07 20:04:57 +02:00
|
|
|
nmctype = self.getNamecoinType()
|
|
|
|
assert nmctype == "namecoind" or nmctype == "nmcontrol"
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2013-07-07 20:04:57 +02:00
|
|
|
isNamecoind = (nmctype == "namecoind")
|
|
|
|
self.ui.lineEditNamecoinUser.setEnabled(isNamecoind)
|
|
|
|
self.ui.labelNamecoinUser.setEnabled(isNamecoind)
|
|
|
|
self.ui.lineEditNamecoinPassword.setEnabled(isNamecoind)
|
|
|
|
self.ui.labelNamecoinPassword.setEnabled(isNamecoind)
|
|
|
|
|
|
|
|
if isNamecoind:
|
2017-02-08 13:41:56 +01:00
|
|
|
self.ui.lineEditNamecoinPort.setText(defaults.namecoinDefaultRpcPort)
|
2013-07-07 20:04:57 +02:00
|
|
|
else:
|
|
|
|
self.ui.lineEditNamecoinPort.setText("9000")
|
|
|
|
|
2013-07-07 18:41:13 +02:00
|
|
|
def click_pushButtonNamecoinTest(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Test the namecoin settings specified in the settings dialog."""
|
|
|
|
|
2013-08-15 00:59:50 +02:00
|
|
|
self.ui.labelNamecoinTestResult.setText(_translate(
|
2018-05-15 17:20:53 +02:00
|
|
|
"MainWindow", "Testing..."))
|
2013-07-07 18:41:13 +02:00
|
|
|
options = {}
|
2013-07-07 20:04:57 +02:00
|
|
|
options["type"] = self.getNamecoinType()
|
2016-08-17 22:02:41 +02:00
|
|
|
options["host"] = str(self.ui.lineEditNamecoinHost.text().toUtf8())
|
|
|
|
options["port"] = str(self.ui.lineEditNamecoinPort.text().toUtf8())
|
|
|
|
options["user"] = str(self.ui.lineEditNamecoinUser.text().toUtf8())
|
|
|
|
options["password"] = str(self.ui.lineEditNamecoinPassword.text().toUtf8())
|
2013-07-07 18:41:13 +02:00
|
|
|
nc = namecoinConnection(options)
|
2013-08-15 01:46:59 +02:00
|
|
|
response = nc.test()
|
|
|
|
responseStatus = response[0]
|
|
|
|
responseText = response[1]
|
|
|
|
self.ui.labelNamecoinTestResult.setText(responseText)
|
2018-05-15 17:20:53 +02:00
|
|
|
if responseStatus == 'success':
|
2015-03-21 11:37:08 +01:00
|
|
|
self.parent.ui.pushButtonFetchNamecoinID.show()
|
2013-07-07 18:41:13 +02:00
|
|
|
|
2013-06-12 23:12:32 +02:00
|
|
|
|
2018-01-22 17:52:28 +01:00
|
|
|
class myTableWidgetItem(QtGui.QTableWidgetItem):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""
|
|
|
|
In order for the time columns on the Inbox and Sent tabs to be sorted correctly (rather than alphabetically),
|
|
|
|
we need to overload the < operator and use this class instead of QTableWidgetItem.
|
|
|
|
"""
|
2013-06-12 23:12:32 +02:00
|
|
|
|
|
|
|
def __lt__(self, other):
|
2013-05-02 17:53:54 +02:00
|
|
|
return int(self.data(33).toPyObject()) < int(other.data(33).toPyObject())
|
|
|
|
|
2015-11-15 00:12:19 +01:00
|
|
|
|
|
|
|
app = None
|
|
|
|
myapp = None
|
|
|
|
|
2018-01-22 17:52:28 +01:00
|
|
|
|
|
|
|
class MySingleApplication(QtGui.QApplication):
|
2015-11-15 00:12:19 +01:00
|
|
|
"""
|
|
|
|
Listener to allow our Qt form to get focus when another instance of the
|
|
|
|
application is open.
|
|
|
|
|
|
|
|
Based off this nice reimplmentation of MySingleApplication:
|
|
|
|
http://stackoverflow.com/a/12712362/2679626
|
|
|
|
"""
|
|
|
|
|
|
|
|
# Unique identifier for this application
|
|
|
|
uuid = '6ec0149b-96e1-4be1-93ab-1465fb3ebf7c'
|
|
|
|
|
|
|
|
def __init__(self, *argv):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-11-15 00:12:19 +01:00
|
|
|
super(MySingleApplication, self).__init__(*argv)
|
2018-05-15 17:20:53 +02:00
|
|
|
_id = MySingleApplication.uuid
|
2015-11-15 00:12:19 +01:00
|
|
|
|
|
|
|
self.server = None
|
|
|
|
self.is_running = False
|
|
|
|
|
|
|
|
socket = QLocalSocket()
|
2018-05-15 17:20:53 +02:00
|
|
|
socket.connectToServer(_id)
|
2015-11-15 00:12:19 +01:00
|
|
|
self.is_running = socket.waitForConnected()
|
|
|
|
|
|
|
|
# Cleanup past crashed servers
|
|
|
|
if not self.is_running:
|
|
|
|
if socket.error() == QLocalSocket.ConnectionRefusedError:
|
|
|
|
socket.disconnectFromServer()
|
2018-05-15 17:20:53 +02:00
|
|
|
QLocalServer.removeServer(_id)
|
2015-11-15 00:12:19 +01:00
|
|
|
|
|
|
|
socket.abort()
|
|
|
|
|
|
|
|
# Checks if there's an instance of the local server id running
|
|
|
|
if self.is_running:
|
2017-01-10 21:15:35 +01:00
|
|
|
# This should be ignored, singleinstance.py will take care of exiting me.
|
2015-11-15 00:12:19 +01:00
|
|
|
pass
|
|
|
|
else:
|
|
|
|
# Nope, create a local server with this id and assign on_new_connection
|
|
|
|
# for whenever a second instance tries to run focus the application.
|
|
|
|
self.server = QLocalServer()
|
2018-05-15 17:20:53 +02:00
|
|
|
self.server.listen(_id)
|
2015-11-15 00:12:19 +01:00
|
|
|
self.server.newConnection.connect(self.on_new_connection)
|
|
|
|
|
|
|
|
def __del__(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-11-15 00:12:19 +01:00
|
|
|
if self.server:
|
|
|
|
self.server.close()
|
|
|
|
|
|
|
|
def on_new_connection(self):
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-11-15 00:12:19 +01:00
|
|
|
if myapp:
|
|
|
|
myapp.appIndicatorShow()
|
|
|
|
|
2018-01-22 17:52:28 +01:00
|
|
|
|
2015-11-15 00:12:19 +01:00
|
|
|
def init():
|
2018-05-15 17:20:53 +02:00
|
|
|
"""TBC"""
|
|
|
|
|
2015-11-15 00:12:19 +01:00
|
|
|
global app
|
2018-05-15 17:20:53 +02:00
|
|
|
|
2015-11-15 00:12:19 +01:00
|
|
|
if not app:
|
|
|
|
app = MySingleApplication(sys.argv)
|
|
|
|
return app
|
|
|
|
|
2018-01-22 17:52:28 +01:00
|
|
|
|
2013-05-02 17:53:54 +02:00
|
|
|
def run():
|
2018-05-15 17:20:53 +02:00
|
|
|
"""Run the gui"""
|
|
|
|
|
2015-11-15 00:12:19 +01:00
|
|
|
global myapp
|
2018-05-15 17:20:53 +02:00
|
|
|
|
|
|
|
running_app = init()
|
2014-11-14 12:21:18 +01:00
|
|
|
change_translation(l10n.getTranslationLanguage())
|
2013-05-02 17:53:54 +02:00
|
|
|
app.setStyleSheet("QStatusBar::item { border: 0px solid black }")
|
|
|
|
myapp = MyForm()
|
2013-05-13 12:51:48 +02:00
|
|
|
|
2018-02-06 23:55:41 +01:00
|
|
|
myapp.sqlInit()
|
2018-05-15 17:20:53 +02:00
|
|
|
myapp.appIndicatorInit(running_app)
|
2017-03-23 18:04:56 +01:00
|
|
|
myapp.indicatorInit()
|
2013-05-11 18:33:16 +02:00
|
|
|
myapp.notifierInit()
|
2017-03-28 16:38:05 +02:00
|
|
|
myapp._firstrun = BMConfigParser().safeGetBoolean(
|
|
|
|
'bitmessagesettings', 'dontconnect')
|
|
|
|
if myapp._firstrun:
|
|
|
|
myapp.showConnectDialog() # ask the user if we may connect
|
2018-01-24 17:37:05 +01:00
|
|
|
myapp.ui.updateNetworkSwitchMenuLabel()
|
2017-03-28 16:38:05 +02:00
|
|
|
|
2015-10-02 15:05:47 +02:00
|
|
|
# only show after wizards and connect dialogs have completed
|
2017-01-11 14:27:19 +01:00
|
|
|
if not BMConfigParser().getboolean('bitmessagesettings', 'startintray'):
|
2015-10-02 15:05:47 +02:00
|
|
|
myapp.show()
|
|
|
|
|
2013-08-26 01:31:54 +02:00
|
|
|
sys.exit(app.exec_())
|