Compare commits
7 Commits
v0.6
...
belovachap
Author | SHA1 | Date | |
---|---|---|---|
|
7074a5d3df | ||
|
83ccc9e39a | ||
|
309fa40120 | ||
|
f4fdb94a56 | ||
|
6751ff9adc | ||
|
b9cd75a7de | ||
|
c45d781c96 |
3
.gitattributes
vendored
3
.gitattributes
vendored
|
@ -1,3 +0,0 @@
|
|||
# Pickle files (for testing) should always have UNIX line endings.
|
||||
# Windows issue like here https://stackoverflow.com/questions/556269
|
||||
knownnodes.dat text eol=lf
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -17,5 +17,4 @@ dist
|
|||
*.egg-info
|
||||
docs/_*/*
|
||||
docs/autodoc/
|
||||
build
|
||||
pyan/
|
||||
|
|
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +0,0 @@
|
|||
[submodule "packages/flatpak/shared-modules"]
|
||||
path = packages/flatpak/shared-modules
|
||||
url = https://github.com/flathub/shared-modules.git
|
|
@ -1,9 +0,0 @@
|
|||
version: 2
|
||||
|
||||
python:
|
||||
version: 2.7
|
||||
install:
|
||||
- requirements: docs/requirements.txt
|
||||
- method: setuptools
|
||||
path: .
|
||||
system_packages: true
|
14
.travis.yml
14
.travis.yml
|
@ -1,22 +1,16 @@
|
|||
language: python
|
||||
cache: pip
|
||||
dist: bionic
|
||||
python:
|
||||
- "2.7_with_system_site_packages"
|
||||
- "3.7"
|
||||
- "2.7"
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- build-essential
|
||||
- libcap-dev
|
||||
- python-qt4
|
||||
- tor
|
||||
- xvfb
|
||||
install:
|
||||
- pip install -r requirements.txt
|
||||
- ln -s src pybitmessage # tests environment
|
||||
- python setup.py install
|
||||
- export PYTHONWARNINGS=all
|
||||
script:
|
||||
- python checkdeps.py
|
||||
- xvfb-run src/bitmessagemain.py -t
|
||||
- python -bm tests
|
||||
- src/bitmessagemain.py -t
|
||||
- python setup.py test
|
||||
|
|
2
COPYING
2
COPYING
|
@ -1,5 +1,5 @@
|
|||
Copyright (c) 2012-2016 Jonathan Warren
|
||||
Copyright (c) 2012-2020 The Bitmessage Developers
|
||||
Copyright (c) 2012-2019 The Bitmessage Developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
26
Dockerfile
26
Dockerfile
|
@ -6,37 +6,43 @@ RUN apt-get update
|
|||
|
||||
# Install dependencies
|
||||
RUN apt-get install -yq --no-install-suggests --no-install-recommends \
|
||||
build-essential libcap-dev libssl-dev \
|
||||
python-all-dev python-msgpack python-pip python-setuptools
|
||||
python-msgpack dh-python python-all-dev build-essential libssl-dev \
|
||||
python-stdeb fakeroot python-pip libcap-dev
|
||||
|
||||
RUN pip2 install --upgrade pip
|
||||
RUN pip install --upgrade pip
|
||||
|
||||
EXPOSE 8444 8442
|
||||
|
||||
ENV HOME /home/bitmessage
|
||||
ENV BITMESSAGE_HOME ${HOME}
|
||||
|
||||
ENV VER 0.6.3.2
|
||||
|
||||
WORKDIR ${HOME}
|
||||
ADD . ${HOME}
|
||||
|
||||
# Install tests dependencies
|
||||
RUN pip2 install -r requirements.txt
|
||||
# Install
|
||||
RUN python2 setup.py install
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
# Build and install deb
|
||||
RUN python2 setup.py sdist \
|
||||
&& py2dsc-deb dist/pybitmessage-${VER}.tar.gz \
|
||||
&& dpkg -i deb_dist/python-pybitmessage_${VER}-1_amd64.deb
|
||||
|
||||
# Create a user
|
||||
RUN useradd bitmessage && chown -R bitmessage ${HOME}
|
||||
|
||||
USER bitmessage
|
||||
|
||||
# Generate default config
|
||||
RUN src/bitmessagemain.py -t && mv keys.dat /tmp
|
||||
|
||||
# Clean HOME
|
||||
RUN rm -rf ${HOME}/*
|
||||
|
||||
# Generate default config
|
||||
RUN pybitmessage -t
|
||||
|
||||
# Setup environment
|
||||
RUN APIPASS=$(tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo) \
|
||||
RUN mv /tmp/keys.dat . \
|
||||
&& APIPASS=$(tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo) \
|
||||
&& echo "\napiusername: api\napipassword: $APIPASS" \
|
||||
&& echo "apienabled = true\napiinterface = 0.0.0.0\napiusername = api\napipassword = $APIPASS" >> keys.dat
|
||||
|
||||
|
|
27
Dockerfile.test_py2
Normal file
27
Dockerfile.test_py2
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Dockerfile for testing PyBitmessage with Python 2
|
||||
# docker build -f Dockerfile.test_py2 .
|
||||
|
||||
FROM ubuntu:xenial
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install -yq --no-install-suggests --no-install-recommends \
|
||||
build-essential libcap-dev python-all-dev python-setuptools virtualenv
|
||||
|
||||
WORKDIR /home/bitmessage
|
||||
RUN ln -s src pybitmessage # tests environment
|
||||
|
||||
ENV VIRTUAL_ENV=/home/bitmessage/venv
|
||||
RUN virtualenv $VIRTUAL_ENV
|
||||
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||
|
||||
RUN python --version
|
||||
RUN pip --version
|
||||
|
||||
ADD requirements.txt .
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
ADD . .
|
||||
|
||||
RUN python setup.py install
|
||||
RUN coverage run --source=src setup.py test
|
||||
RUN coverage report
|
28
Dockerfile.test_py3
Normal file
28
Dockerfile.test_py3
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Dockerfile for testing PyBitmessage with Python 3
|
||||
# docker build -f Dockerfile.test_py3 .
|
||||
|
||||
FROM ubuntu:xenial
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install -yq --no-install-suggests --no-install-recommends \
|
||||
build-essential libcap-dev libssl-dev python3-all-dev python3-setuptools \
|
||||
virtualenv
|
||||
|
||||
WORKDIR /home/bitmessage
|
||||
RUN ln -s src pybitmessage # tests environment
|
||||
|
||||
ENV VIRTUAL_ENV=/home/bitmessage/venv
|
||||
RUN virtualenv -p python3 $VIRTUAL_ENV
|
||||
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||
|
||||
RUN python --version
|
||||
RUN pip --version
|
||||
|
||||
ADD requirements.txt .
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
ADD . .
|
||||
|
||||
RUN python setup.py install
|
||||
RUN coverage run --source=src setup.py test
|
||||
RUN coverage report
|
|
@ -1,64 +0,0 @@
|
|||
FROM ubuntu:bionic AS pybm-travis-bionic
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
ENV TRAVIS_SKIP_APT_UPDATE 1
|
||||
|
||||
RUN apt-get update
|
||||
|
||||
RUN apt-get install -yq --no-install-suggests --no-install-recommends \
|
||||
software-properties-common
|
||||
|
||||
RUN dpkg --add-architecture i386
|
||||
|
||||
RUN add-apt-repository ppa:deadsnakes/ppa
|
||||
|
||||
RUN apt-get -y install sudo
|
||||
|
||||
RUN apt-get install -yq --no-install-suggests --no-install-recommends \
|
||||
# travis xenial bionic
|
||||
python-setuptools libssl-dev libpq-dev python-prctl python-dev \
|
||||
python-dev python-virtualenv python-pip virtualenv \
|
||||
# dpkg
|
||||
python-minimal python-setuptools python-all python openssl libssl-dev \
|
||||
dh-apparmor debhelper dh-python python-msgpack python-qt4 python-stdeb \
|
||||
python-all-dev python-crypto python-psutil \
|
||||
fakeroot python-pytest \
|
||||
# Code quality
|
||||
pylint python-pycodestyle python3-pycodestyle pycodestyle python-flake8 \
|
||||
python3-flake8 flake8 python-pyflakes python3-pyflakes pyflakes pyflakes3 \
|
||||
curl \
|
||||
# Wine
|
||||
python python-pip wget wine-stable winetricks mingw-w64 wine32 wine64 xvfb \
|
||||
# Buildbot
|
||||
python3-dev libffi-dev python3-setuptools \
|
||||
python3-pip \
|
||||
# python 3.7
|
||||
python3.7 python3.7-dev \
|
||||
# .travis.yml
|
||||
build-essential libcap-dev tor \
|
||||
language-pack-en
|
||||
|
||||
# cleanup
|
||||
RUN rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN useradd -m -U builder
|
||||
|
||||
RUN echo 'builder ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
||||
|
||||
# travis2bash
|
||||
RUN wget -O /usr/local/bin/travis2bash.sh https://git.bitmessage.org/Bitmessage/buildbot-scripts/raw/branch/master/travis2bash.sh
|
||||
RUN chmod +x /usr/local/bin/travis2bash.sh
|
||||
|
||||
# copy sources
|
||||
COPY . /home/builder/src
|
||||
RUN chown -R builder.builder /home/builder/src
|
||||
|
||||
USER builder
|
||||
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV LANGUAGE en_US:en
|
||||
ENV LC_ALL en_US.UTF-8
|
||||
|
||||
WORKDIR /home/builder/src
|
||||
|
||||
ENTRYPOINT /usr/local/bin/travis2bash.sh
|
51
LICENSE
51
LICENSE
|
@ -1,6 +1,6 @@
|
|||
The MIT License (MIT)
|
||||
Copyright (c) 2012-2016 Jonathan Warren
|
||||
Copyright (c) 2012-2020 The Bitmessage Developers
|
||||
Copyright (c) 2012-2019 The Bitmessage Developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -22,7 +22,7 @@ SOFTWARE.
|
|||
|
||||
===== qidenticon.py identicon python implementation with QPixmap output by sendiulo <sendiulo@gmx.net>
|
||||
|
||||
qidenticon.py is Licensed under FreeBSD License.
|
||||
qidenticon.py is Licesensed under FreeBSD License.
|
||||
(http://www.freebsd.org/copyright/freebsd-license.html)
|
||||
|
||||
Copyright 2013 "Sendiulo". All rights reserved.
|
||||
|
@ -36,7 +36,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR I
|
|||
|
||||
===== based on identicon.py identicon python implementation. by Shin Adachi <shn@glucose.jp>
|
||||
|
||||
identicon.py is Licensed under FreeBSD License.
|
||||
identicon.py is Licesensed under FreeBSD License.
|
||||
(http://www.freebsd.org/copyright/freebsd-license.html)
|
||||
|
||||
Copyright 1994-2009 Shin Adachi. All rights reserved.
|
||||
|
@ -47,48 +47,3 @@ Redistribution and use in source and binary forms, with or without modification,
|
|||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
===== based on asyncore_pollchoose.py asyncore_pollchoose python implementation. by Sam Rushing <rushing@nightmare.com>
|
||||
|
||||
Copyright 1996 by Sam Rushing. All Rights Reserved
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and
|
||||
its documentation for any purpose and without fee is hereby
|
||||
granted, provided that the above copyright notice appear in all
|
||||
copies and that both that copyright notice and this permission
|
||||
notice appear in supporting documentation, and that the name of Sam
|
||||
Rushing not be used in advertising or publicity pertaining to
|
||||
distribution of the software without specific, written prior
|
||||
permission.
|
||||
|
||||
SAM RUSHING DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
NO EVENT SHALL SAM RUSHING BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
===== based on namecoin.py namecoin.py python implementation by Daniel Kraft <d@domob.eu>
|
||||
|
||||
Copyright (C) 2013 by Daniel Kraft <d@domob.eu>
|
||||
|
||||
This file is part of the Bitmessage project.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -14,10 +14,12 @@ Development
|
|||
----------
|
||||
Bitmessage is a collaborative project. You are welcome to submit pull requests
|
||||
although if you plan to put a non-trivial amount of work into coding new
|
||||
features, it is recommended that you first describe your ideas in the
|
||||
separate issue.
|
||||
features, it is recommended that you first solicit feedback on the DevTalk
|
||||
pseudo-mailing list:
|
||||
BM-2D9QKN4teYRvoq2fyzpiftPh9WP9qggtzh
|
||||
|
||||
Feel welcome to join chan "bitmessage", BM-2cWy7cvHoq3f1rYMerRJp8PT653jjSuEdY
|
||||
which is on preview here: https://beamstat.com/chan/bitmessage
|
||||
|
||||
References
|
||||
----------
|
||||
|
|
43
android_instruction.rst
Normal file
43
android_instruction.rst
Normal file
|
@ -0,0 +1,43 @@
|
|||
PyBitmessage(Android)
|
||||
|
||||
This sample aims to be as close to a real world example of a mobile. It has a more refined design and also provides a practical example of how a mobile app would interact and communicate with its adresses.
|
||||
|
||||
Steps for trying out this sample:
|
||||
|
||||
Compile and install the mobile app onto your mobile device or emulator.
|
||||
|
||||
|
||||
Getting Started
|
||||
|
||||
This sample uses the kivy as Kivy is an open source, cross-platform Python framework for the development of applications that make use of innovative, multi-touch user interfaces. The aim is to allow for quick and easy interaction design and rapid prototyping whilst making your code reusable and deployable.
|
||||
|
||||
Kivy is written in Python and Cython, supports various input devices and has an extensive widget library. With the same codebase, you can target Windows, OS X, Linux, Android and iOS. All Kivy widgets are built with multitouch support.
|
||||
|
||||
Kivy in support take Buildozer which is a tool that automates the entire build process. It downloads and sets up all the prequisites for python-for-android, including the android SDK and NDK, then builds an apk that can be automatically pushed to the device.
|
||||
|
||||
Buildozer currently works only in Linux, and is an alpha release, but it already works well and can significantly simplify the apk build.
|
||||
|
||||
To build this project, use the "Buildozer android release deploy run" command or use.
|
||||
Buildozer ue=sed for creating application packages easily.The goal is to have one "buildozer.spec" file in your app directory, describing your application requirements and settings such as title, icon, included modules etc. Buildozer will use that spec to create a package for Android, iOS, Windows, OSX and/or Linux.
|
||||
|
||||
Installing Requirements
|
||||
|
||||
You can create a package for android using the python-for-android project as with using the Buildozer tool to automate the entire process. You can also see Packaging your application for the Kivy Launcher to run kivy programs without compiling them.
|
||||
|
||||
You can get buildozer at https://github.com/kivy/buildozer or you can directly install using pip install buildozer
|
||||
|
||||
This will install buildozer in your system. Afterwards, navigate to your project directory and run:
|
||||
|
||||
buildozer init
|
||||
|
||||
This creates a buildozer.spec file controlling your build configuration. You should edit it appropriately with your app name etc. You can set variables to control most or all of the parameters passed to python-for-android.
|
||||
|
||||
Install buildozer’s dependencies.
|
||||
|
||||
Finally, plug in your android device and run:
|
||||
|
||||
buildozer android debug deploy run >> To build, push and automatically run the apk on your device. Here we used debug as tested in debug mode for now.
|
||||
|
||||
Packaging your application for the Kivy Launcher
|
||||
|
||||
|
16
build/changelang.sh
Executable file
16
build/changelang.sh
Executable file
|
@ -0,0 +1,16 @@
|
|||
export LANG=de_DE.UTF-8
|
||||
export LANGUAGE=de_DE
|
||||
export LC_CTYPE="de_DE.UTF-8"
|
||||
export LC_NUMERIC=de_DE.UTF-8
|
||||
export LC_TIME=de_DE.UTF-8
|
||||
export LC_COLLATE="de_DE.UTF-8"
|
||||
export LC_MONETARY=de_DE.UTF-8
|
||||
export LC_MESSAGES="de_DE.UTF-8"
|
||||
export LC_PAPER=de_DE.UTF-8
|
||||
export LC_NAME=de_DE.UTF-8
|
||||
export LC_ADDRESS=de_DE.UTF-8
|
||||
export LC_TELEPHONE=de_DE.UTF-8
|
||||
export LC_MEASUREMENT=de_DE.UTF-8
|
||||
export LC_IDENTIFICATION=de_DE.UTF-8
|
||||
export LC_ALL=
|
||||
python2.7 src/bitmessagemain.py
|
23
build/compiletest.py
Executable file
23
build/compiletest.py
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/python2.7
|
||||
|
||||
import ctypes
|
||||
import fnmatch
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
matches = []
|
||||
for root, dirnames, filenames in os.walk('src'):
|
||||
for filename in fnmatch.filter(filenames, '*.py'):
|
||||
matches.append(os.path.join(root, filename))
|
||||
|
||||
for filename in matches:
|
||||
source = open(filename, 'r').read() + '\n'
|
||||
try:
|
||||
compile(source, filename, 'exec')
|
||||
except Exception as e:
|
||||
if 'win' in sys.platform:
|
||||
ctypes.windll.user32.MessageBoxA(0, traceback.format_exc(), "Exception in " + filename, 1)
|
||||
else:
|
||||
print "Exception in %s: %s" % (filename, traceback.format_exc())
|
||||
sys.exit(1)
|
11
build/mergepullrequest.sh
Executable file
11
build/mergepullrequest.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "You must specify pull request number"
|
||||
exit
|
||||
fi
|
||||
|
||||
git pull
|
||||
git checkout v0.6
|
||||
git fetch origin pull/"$1"/head:"$1"
|
||||
git merge --ff-only "$1"
|
|
@ -1,189 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# INIT
|
||||
MACHINE_TYPE=$(uname -m)
|
||||
BASE_DIR=$(pwd)
|
||||
PYTHON_VERSION=2.7.17
|
||||
PYQT_VERSION=4-4.11.4-gpl-Py2.7-Qt4.8.7
|
||||
OPENSSL_VERSION=1_0_2t
|
||||
SRCPATH=~/Downloads
|
||||
|
||||
#Functions
|
||||
function download_sources_32 {
|
||||
if [ ! -d ${SRCPATH} ]; then
|
||||
mkdir -p ${SRCPATH}
|
||||
fi
|
||||
wget -P ${SRCPATH} -c -nc --content-disposition \
|
||||
https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}.msi \
|
||||
https://download.microsoft.com/download/1/1/1/1116b75a-9ec3-481a-a3c8-1777b5381140/vcredist_x86.exe \
|
||||
https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/PyQt${PYQT_VERSION}-x32.exe?raw=true \
|
||||
https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/Win32OpenSSL-${OPENSSL_VERSION}.exe?raw=true \
|
||||
https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/pyopencl-2015.1-cp27-none-win32.whl?raw=true
|
||||
}
|
||||
|
||||
function download_sources_64 {
|
||||
if [ ! -d ${SRCPATH} ]; then
|
||||
mkdir -p ${SRCPATH}
|
||||
fi
|
||||
wget -P ${SRCPATH} -c -nc --content-disposition \
|
||||
http://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}.amd64.msi \
|
||||
https://download.microsoft.com/download/d/2/4/d242c3fb-da5a-4542-ad66-f9661d0a8d19/vcredist_x64.exe \
|
||||
https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/PyQt${PYQT_VERSION}-x64.exe?raw=true \
|
||||
https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/Win64OpenSSL-${OPENSSL_VERSION}.exe?raw=true \
|
||||
https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/pyopencl-2015.1-cp27-none-win_amd64.whl?raw=true
|
||||
}
|
||||
|
||||
function download_sources {
|
||||
if [ "${MACHINE_TYPE}" == 'x86_64' ]; then
|
||||
download_sources_64
|
||||
else
|
||||
download_sources_32
|
||||
fi
|
||||
}
|
||||
|
||||
function install_wine {
|
||||
echo "Setting up wine"
|
||||
if [ "${MACHINE_TYPE}" == 'x86_64' ]; then
|
||||
export WINEPREFIX=${HOME}/.wine64 WINEARCH=win64
|
||||
else
|
||||
export WINEPREFIX=${HOME}/.wine32 WINEARCH=win32
|
||||
fi
|
||||
rm -rf "${WINEPREFIX}"
|
||||
rm -rf packages/pyinstaller/{build,dist}
|
||||
}
|
||||
|
||||
function install_python(){
|
||||
cd ${SRCPATH} || exit 1
|
||||
if [ "${MACHINE_TYPE}" == 'x86_64' ]; then
|
||||
echo "Installing Python ${PYTHON_VERSION} 64b"
|
||||
wine msiexec -i python-${PYTHON_VERSION}.amd64.msi /q /norestart
|
||||
echo "Installing vcredist for 64 bit"
|
||||
wine vcredist_x64.exe /q /norestart
|
||||
else
|
||||
echo "Installing Python ${PYTHON_VERSION} 32b"
|
||||
wine msiexec -i python-${PYTHON_VERSION}.msi /q /norestart
|
||||
# MSVCR 2008 required for Windows XP
|
||||
cd ${SRCPATH} || exit 1
|
||||
echo "Installing vc_redist (2008) for 32 bit "
|
||||
wine vcredist_x86.exe /Q
|
||||
fi
|
||||
echo "Installing pytools 2020.2"
|
||||
# last version compatible with python 2
|
||||
wine python -m pip install pytools==2020.2
|
||||
echo "Upgrading pip"
|
||||
wine python -m pip install --upgrade pip
|
||||
}
|
||||
|
||||
function install_pyqt(){
|
||||
if [ "${MACHINE_TYPE}" == 'x86_64' ]; then
|
||||
echo "Installing PyQt-${PYQT_VERSION} 64b"
|
||||
wine PyQt${PYQT_VERSION}-x64.exe /S /WX
|
||||
else
|
||||
echo "Installing PyQt-${PYQT_VERSION} 32b"
|
||||
wine PyQt${PYQT_VERSION}-x32.exe /S /WX
|
||||
fi
|
||||
}
|
||||
|
||||
function install_openssl(){
|
||||
if [ "${MACHINE_TYPE}" == 'x86_64' ]; then
|
||||
echo "Installing OpenSSL ${OPENSSL_VERSION} 64b"
|
||||
wine Win64OpenSSL-${OPENSSL_VERSION}.exe /q /norestart /silent /verysilent /sp- /suppressmsgboxes
|
||||
else
|
||||
echo "Installing OpenSSL ${OPENSSL_VERSION} 32b"
|
||||
wine Win32OpenSSL-${OPENSSL_VERSION}.exe /q /norestart /silent /verysilent /sp- /suppressmsgboxes
|
||||
fi
|
||||
}
|
||||
|
||||
function install_pyinstaller()
|
||||
{
|
||||
cd "${BASE_DIR}" || exit 1
|
||||
echo "Installing PyInstaller"
|
||||
if [ "${MACHINE_TYPE}" == 'x86_64' ]; then
|
||||
# 3.6 is the last version to support python 2.7
|
||||
wine python -m pip install -I pyinstaller==3.6
|
||||
else
|
||||
# 3.2.1 is the last version to work on XP
|
||||
# see https://github.com/pyinstaller/pyinstaller/issues/2931
|
||||
wine python -m pip install -I pyinstaller==3.2.1
|
||||
fi
|
||||
}
|
||||
|
||||
function install_msgpack()
|
||||
{
|
||||
cd "${BASE_DIR}" || exit 1
|
||||
echo "Installing msgpack"
|
||||
wine python -m pip install msgpack-python
|
||||
}
|
||||
|
||||
function install_pyopencl()
|
||||
{
|
||||
cd "${SRCPATH}" || exit 1
|
||||
echo "Installing PyOpenCL"
|
||||
if [ "${MACHINE_TYPE}" == 'x86_64' ]; then
|
||||
wine python -m pip install pyopencl-2015.1-cp27-none-win_amd64.whl
|
||||
else
|
||||
wine python -m pip install pyopencl-2015.1-cp27-none-win32.whl
|
||||
fi
|
||||
sed -Ei 's/_DEFAULT_INCLUDE_OPTIONS = .*/_DEFAULT_INCLUDE_OPTIONS = [] /' \
|
||||
"$WINEPREFIX/drive_c/Python27/Lib/site-packages/pyopencl/__init__.py"
|
||||
}
|
||||
|
||||
function build_dll(){
|
||||
cd "${BASE_DIR}" || exit 1
|
||||
cd src/bitmsghash || exit 1
|
||||
if [ "${MACHINE_TYPE}" == 'x86_64' ]; then
|
||||
echo "Create dll"
|
||||
x86_64-w64-mingw32-g++ -D_WIN32 -Wall -O3 -march=native \
|
||||
"-I$HOME/.wine64/drive_c/OpenSSL-Win64/include" \
|
||||
-I/usr/x86_64-w64-mingw32/include \
|
||||
"-L$HOME/.wine64/drive_c/OpenSSL-Win64/lib" \
|
||||
-c bitmsghash.cpp
|
||||
x86_64-w64-mingw32-g++ -static-libgcc -shared bitmsghash.o \
|
||||
-D_WIN32 -O3 -march=native \
|
||||
"-I$HOME/.wine64/drive_c/OpenSSL-Win64/include" \
|
||||
"-L$HOME/.wine64/drive_c/OpenSSL-Win64" \
|
||||
-L/usr/lib/x86_64-linux-gnu/wine \
|
||||
-fPIC -shared -lcrypt32 -leay32 -lwsock32 \
|
||||
-o bitmsghash64.dll -Wl,--out-implib,bitmsghash.a
|
||||
else
|
||||
echo "Create dll"
|
||||
i686-w64-mingw32-g++ -D_WIN32 -Wall -m32 -O3 -march=native \
|
||||
"-I$HOME/.wine32/drive_c/OpenSSL-Win32/include" \
|
||||
-I/usr/i686-w64-mingw32/include \
|
||||
"-L$HOME/.wine32/drive_c/OpenSSL-Win32/lib" \
|
||||
-c bitmsghash.cpp
|
||||
i686-w64-mingw32-g++ -static-libgcc -shared bitmsghash.o \
|
||||
-D_WIN32 -O3 -march=native \
|
||||
"-I$HOME/.wine32/drive_c/OpenSSL-Win32/include" \
|
||||
"-L$HOME/.wine32/drive_c/OpenSSL-Win32/lib/MinGW" \
|
||||
-fPIC -shared -lcrypt32 -leay32 -lwsock32 \
|
||||
-o bitmsghash32.dll -Wl,--out-implib,bitmsghash.a
|
||||
fi
|
||||
}
|
||||
|
||||
function build_exe(){
|
||||
cd "${BASE_DIR}" || exit 1
|
||||
cd packages/pyinstaller || exit 1
|
||||
wine pyinstaller bitmessagemain.spec
|
||||
}
|
||||
|
||||
# prepare on ubuntu
|
||||
# dpkg --add-architecture i386
|
||||
# apt update
|
||||
# apt -y install wget wine-stable wine-development winetricks mingw-w64 wine32 wine64 xvfb
|
||||
|
||||
|
||||
download_sources
|
||||
if [ "$1" == "--download-only" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
install_wine
|
||||
install_python
|
||||
install_pyqt
|
||||
install_openssl
|
||||
install_pyopencl
|
||||
install_msgpack
|
||||
install_pyinstaller
|
||||
build_dll
|
||||
build_exe
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python2
|
||||
"""
|
||||
Check dependencies and give recommendations about how to satisfy them
|
||||
Check dependendies and give recommendations about how to satisfy them
|
||||
|
||||
Limitations:
|
||||
|
||||
|
@ -144,9 +144,6 @@ for lhs, rhs in EXTRAS_REQUIRE.items():
|
|||
for x in rhs
|
||||
if x in EXTRAS_REQUIRE_DEPS
|
||||
]):
|
||||
try:
|
||||
import_module(lhs)
|
||||
except Exception as e:
|
||||
rhs_cmd = ''.join([
|
||||
CMD,
|
||||
' ',
|
||||
|
@ -167,7 +164,7 @@ if (not compiler or prereqs) and OPSYS in PACKAGE_MANAGER:
|
|||
if not compiler:
|
||||
compilerToPackages()
|
||||
prereqToPackages()
|
||||
if prereqs and mandatory:
|
||||
if mandatory:
|
||||
sys.exit(1)
|
||||
else:
|
||||
print("All the dependencies satisfied, you can install PyBitmessage")
|
||||
|
|
|
@ -6,4 +6,4 @@ Comment=Send encrypted messages
|
|||
Exec=pybitmessage %F
|
||||
Icon=pybitmessage
|
||||
Terminal=false
|
||||
Categories=Office;Email;Network;
|
||||
Categories=Office;Email;
|
||||
|
|
18
docs/_static/custom.css
vendored
18
docs/_static/custom.css
vendored
|
@ -1,18 +0,0 @@
|
|||
/* Hide "On GitHub" section from versions menu */
|
||||
li.wy-breadcrumbs-aside > a.fa {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Override table width restrictions */
|
||||
/* @media screen and (min-width: 700px) { */
|
||||
|
||||
.wy-table-responsive table td {
|
||||
/* !important prevents the common CSS stylesheets from overriding
|
||||
this as on RTD they are loaded after this stylesheet */
|
||||
white-space: normal !important;
|
||||
}
|
||||
|
||||
.wy-table-responsive {
|
||||
overflow: visible !important;
|
||||
}
|
||||
/* } */
|
119
docs/conf.py
119
docs/conf.py
|
@ -2,24 +2,35 @@
|
|||
"""
|
||||
Configuration file for the Sphinx documentation builder.
|
||||
|
||||
For a full list of options see the documentation:
|
||||
This file does only contain a selection of the most common options. For a
|
||||
full list see the documentation:
|
||||
http://www.sphinx-doc.org/en/master/config
|
||||
|
||||
-- Path setup --------------------------------------------------------------
|
||||
|
||||
If extensions (or modules to document with autodoc) are in another directory,
|
||||
add these directories to sys.path here. If the directory is relative to the
|
||||
documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from sphinx.apidoc import main
|
||||
from mock import Mock as MagicMock
|
||||
|
||||
sys.path.insert(0, os.path.abspath('.'))
|
||||
sys.path.insert(0, os.path.abspath('..'))
|
||||
sys.path.insert(0, os.path.abspath('../src'))
|
||||
sys.path.insert(0, os.path.abspath('../src/pyelliptic'))
|
||||
|
||||
from importlib import import_module
|
||||
|
||||
import version # noqa:E402
|
||||
import version
|
||||
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = u'PyBitmessage'
|
||||
copyright = u'2019, The Bitmessage Team' # pylint: disable=redefined-builtin
|
||||
copyright = u'2018, The Bitmessage Team' # pylint: disable=redefined-builtin
|
||||
author = u'The Bitmessage Team'
|
||||
|
||||
# The short X.Y version
|
||||
|
@ -39,18 +50,15 @@ release = version
|
|||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.coverage', # FIXME: unused
|
||||
'sphinx.ext.imgmath', # legacy unused
|
||||
# 'sphinx.ext.doctest', # Currently disabled due to bad doctests
|
||||
'sphinx.ext.intersphinx',
|
||||
'sphinx.ext.linkcode',
|
||||
'sphinx.ext.napoleon',
|
||||
'sphinx.ext.todo',
|
||||
'sphinxcontrib.apidoc',
|
||||
'sphinx.ext.coverage',
|
||||
'sphinx.ext.imgmath',
|
||||
'sphinx.ext.viewcode',
|
||||
'm2r',
|
||||
]
|
||||
|
||||
default_role = 'obj'
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
|
@ -67,29 +75,23 @@ master_doc = 'index'
|
|||
#
|
||||
# This is also used if you do content translation via gettext catalogs.
|
||||
# Usually you set "language" from the command line for these cases.
|
||||
# language = None
|
||||
language = None
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This pattern also affects html_static_path and html_extra_path .
|
||||
exclude_patterns = ['_build']
|
||||
exclude_patterns = [u'_build', 'Thumbs.db', '.DS_Store']
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# Don't prepend every class or function name with full module path
|
||||
add_module_names = False
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
modindex_common_prefix = ['pybitmessage.']
|
||||
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
html_theme = 'alabaster'
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
|
@ -102,10 +104,6 @@ html_theme = 'sphinx_rtd_theme'
|
|||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
html_css_files = [
|
||||
'custom.css',
|
||||
]
|
||||
|
||||
# Custom sidebar templates, must be a dictionary that maps document names
|
||||
# to template names.
|
||||
#
|
||||
|
@ -116,7 +114,10 @@ html_css_files = [
|
|||
#
|
||||
# html_sidebars = {}
|
||||
|
||||
html_show_sourcelink = False
|
||||
# Deal with long lines in source view
|
||||
html_theme_options = {
|
||||
'page_width': '1366px',
|
||||
}
|
||||
|
||||
# -- Options for HTMLHelp output ---------------------------------------------
|
||||
|
||||
|
@ -198,74 +199,10 @@ epub_exclude_files = ['search.html']
|
|||
|
||||
# -- Extension configuration -------------------------------------------------
|
||||
|
||||
autodoc_mock_imports = [
|
||||
'debug',
|
||||
'pybitmessage.bitmessagekivy',
|
||||
'pybitmessage.bitmessageqt.addressvalidator',
|
||||
'pybitmessage.helper_startup',
|
||||
'pybitmessage.network.httpd',
|
||||
'pybitmessage.network.https',
|
||||
'ctypes',
|
||||
'dialog',
|
||||
'gi',
|
||||
'kivy',
|
||||
'logging',
|
||||
'msgpack',
|
||||
'numpy',
|
||||
'pkg_resources',
|
||||
'pycanberra',
|
||||
'pyopencl',
|
||||
'PyQt4',
|
||||
'pyxdg',
|
||||
'qrcode',
|
||||
'stem',
|
||||
]
|
||||
autodoc_member_order = 'bysource'
|
||||
|
||||
# Apidoc settings
|
||||
apidoc_module_dir = '../pybitmessage'
|
||||
apidoc_output_dir = 'autodoc'
|
||||
apidoc_excluded_paths = [
|
||||
'bitmessagekivy', 'build_osx.py',
|
||||
'bitmessageqt/addressvalidator.py', 'bitmessageqt/migrationwizard.py',
|
||||
'bitmessageqt/newaddresswizard.py', 'helper_startup.py',
|
||||
'kivymd', 'main.py', 'navigationdrawer', 'network/http*',
|
||||
'pybitmessage', 'tests', 'version.py'
|
||||
]
|
||||
apidoc_module_first = True
|
||||
apidoc_separate_modules = True
|
||||
apidoc_toc_file = False
|
||||
apidoc_extra_args = ['-a']
|
||||
|
||||
# Napoleon settings
|
||||
napoleon_google_docstring = True
|
||||
|
||||
|
||||
# linkcode function
|
||||
def linkcode_resolve(domain, info):
|
||||
"""This generates source URL's for sphinx.ext.linkcode"""
|
||||
if domain != 'py' or not info['module']:
|
||||
return
|
||||
try:
|
||||
home = os.path.abspath(import_module('pybitmessage').__path__[0])
|
||||
mod = import_module(info['module']).__file__
|
||||
except ImportError:
|
||||
return
|
||||
repo = 'https://github.com/Bitmessage/PyBitmessage/blob/v0.6/src%s'
|
||||
path = mod.replace(home, '')
|
||||
if path != mod:
|
||||
# put the link only for top level definitions
|
||||
if len(info['fullname'].split('.')) > 1:
|
||||
return
|
||||
if path.endswith('.pyc'):
|
||||
path = path[:-1]
|
||||
return repo % path
|
||||
|
||||
|
||||
# -- Options for intersphinx extension ---------------------------------------
|
||||
|
||||
# Example configuration for intersphinx: refer to the Python standard library.
|
||||
intersphinx_mapping = {'https://docs.python.org/2.7/': None}
|
||||
intersphinx_mapping = {'https://docs.python.org/': None}
|
||||
|
||||
# -- Options for todo extension ----------------------------------------------
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.. mdinclude:: ../../../fabfile/README.md
|
||||
.. mdinclude:: fabfile/README.md
|
||||
|
||||
|
|
|
@ -21,12 +21,12 @@ If we are to make bold claims about protecting your privacy we should demonstrat
|
|||
- looking to audit
|
||||
- warrant canary
|
||||
|
||||
Digital footprint
|
||||
Digital foootprint
|
||||
------------------
|
||||
|
||||
Your internet use can reveal metadata you wouldn't expect. This can be connected with other information about you if you're not careful.
|
||||
|
||||
* Use separate addresses for different purposes
|
||||
* Use separate addresses for different puprose
|
||||
* Don't make the same mistakes all the time
|
||||
* Your language use is unique. The more you type, the more you fingerprint yourself. The words you know and use often vs the words you don't know or use often.
|
||||
|
||||
|
|
|
@ -11,17 +11,17 @@ Bitmessage makes use of fabric_ to define tasks such as building documentation o
|
|||
Code style and linters
|
||||
----------------------
|
||||
|
||||
We aim to be PEP8 compliant but we recognize that we have a long way still to go. Currently we have style and lint exceptions specified at the most specific place we can. We are ignoring certain issues project-wide in order to avoid alert-blindness, avoid style and lint regressions and to allow continuous integration to hook into the output from the tools. While it is hoped that all new changes pass the checks, fixing some existing violations are mini-projects in themselves. Current thinking on ignorable violations is reflected in the options and comments in setup.cfg. Module and line-level lint warnings represent refactoring opportunities.
|
||||
We aim to be PEP8 compliant but we recognise that we have a long way still to go. Currently we have style and lint exceptions specified at the most specific place we can. We are ignoring certain issues project-wide in order to avoid alert-blindess, avoid style and lint regressions and to allow continuous integration to hook into the output from the tools. While it is hoped that all new changes pass the checks, fixing some existing violations are mini-projects in themselves. Current thinking on ignorable violations is reflected in the options and comments in setup.cfg. Module and line-level lint warnings represent refactoring opportunities.
|
||||
|
||||
Pull requests
|
||||
-------------
|
||||
|
||||
There is a template at PULL_REQUEST_TEMPLATE.md that appears in the pull-request description. Please replace this text with something appropriate to your changes based on the ideas in the template.
|
||||
There is a template at PULL_REQUEST_TEMPLATE.md that appears in the pull-request description. Please replace this text with something appropriate to your changes based off the ideas in the template.
|
||||
|
||||
Bike-shedding
|
||||
-------------
|
||||
|
||||
Beyond having well-documented, Pythonic code with static analysis tool checks, extensive test coverage and powerful devops tools, what else can we have? Without violating any linters there is room for making arbitrary decisions solely for the sake of project consistency. These are the stuff of the pedant's PR comments. Rather than have such conversations in PR comments, we can lay out the result of discussion here.
|
||||
Beyond having well-documented, Pythonic code with static analysis tool checks, extensive test coverage and powerful devops tools, what else can we have? Without violating any linters there is room for making arbirary decisions solely for the sake of project consistency. These are the stuff of the pedant's PR comments. Rather than have such conversations in PR comments, we can lay out the result of discussion here.
|
||||
|
||||
I'm putting up a strawman for each topic here, mostly based on my memory of reading related Stack Overflow articles etc. If contributors feel strongly (and we don't have anything better to do) then maybe we can convince each other to update this section.
|
||||
|
||||
|
@ -49,7 +49,7 @@ British vs American spelling
|
|||
Dependency graph
|
||||
----------------
|
||||
|
||||
These images are not very useful right now but the aim is to tweak the settings of one or more of them to be informative, and/or divide them up into smaller graphs.
|
||||
These images are not very useful right now but the aim is to tweak the settings of one or more of them to be informative, and/or divide them up into smaller grapghs.
|
||||
|
||||
To re-build them, run `fab build_docs:dep_graphs=true`. Note that the dot graph takes a lot of time.
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
Processes
|
||||
=========
|
||||
|
||||
In order to keep the Bitmessage project running, the team runs a number of systems and accounts that form the
|
||||
development pipeline and continuous delivery process. We are always striving to improve this process. Towards
|
||||
In other to keep the Bitmessage project running the team run a number of systems and accounts that form the
|
||||
development pipeline and continuous delivery process. We are always striving to improve the process. Towards
|
||||
that end it is documented here.
|
||||
|
||||
|
||||
|
@ -20,7 +20,7 @@ Our official Github_ account is Bitmessage. Our issue tracker is here as well.
|
|||
BitMessage
|
||||
----------
|
||||
|
||||
We eat our own dog food! You can send us bug reports via the [chan] bitmessage BM-2cWy7cvHoq3f1rYMerRJp8PT653jjSuEdY
|
||||
We eat our own dog food! You can send us bug reports via the Bitmessage chan at xxx
|
||||
|
||||
|
||||
.. _website: https://bitmessage.org
|
||||
|
|
|
@ -1,17 +1,9 @@
|
|||
.. mdinclude:: ../README.md
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
.. toctree::
|
||||
:maxdepth: 3
|
||||
|
||||
autodoc/pybitmessage
|
||||
|
||||
Legacy pages
|
||||
------------
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
overview
|
||||
usage
|
||||
contribute
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
m2r
|
||||
sphinxcontrib-apidoc
|
|
@ -1,6 +1,6 @@
|
|||
# Fabric
|
||||
|
||||
[Fabric](https://www.fabfile.org) is a Python library for performing devops tasks. You can think of it a bit like a
|
||||
[Fabric](https://www.fabfile.org) is a Python library for performing devops tasks. You can thing of it a bit like a
|
||||
makefile on steroids for Python. Its api abstracts away the clunky way you would run shell commands in Python, check
|
||||
return values and manage stdio. Tasks may be targetted at particular hosts or group of hosts.
|
||||
|
||||
|
@ -46,7 +46,7 @@ Furthermore, you can use -- to run arbitrary shell commands rather than tasks:
|
|||
|
||||
There are a number of advantages that should benefit us:
|
||||
|
||||
* Common tasks can be written in Python and executed consistently
|
||||
* Common tasks can be writen in Python and executed consistently
|
||||
* Common tasks are now under source control
|
||||
* All developers can run the same commands, if the underlying command sequence for a task changes (after review, obv)
|
||||
the user does not have to care
|
||||
|
|
|
@ -15,7 +15,7 @@ OSX:
|
|||
|
||||
https://github.com/Bitmessage/PyBitmessage/releases
|
||||
|
||||
Works on OSX 10.7.5 or higher
|
||||
Wors on OSX 10.7.5 or higher
|
||||
|
||||
|
||||
Arch linux:
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
# Last Modified: Wed Apr 29 21:04:08 2020
|
||||
#include <tunables/global>
|
||||
|
||||
/usr/bin/pybitmessage {
|
||||
#include <abstractions/base>
|
||||
#include <abstractions/fonts>
|
||||
#include <abstractions/lightdm>
|
||||
#include <abstractions/python>
|
||||
#include <abstractions/user-tmp>
|
||||
|
||||
owner /home/*/.ICEauthority r,
|
||||
owner /home/*/.Xauthority r,
|
||||
owner /home/*/.config/PyBitmessage/ rw,
|
||||
owner /home/*/.config/PyBitmessage/* rwk,
|
||||
owner /home/*/.config/Trolltech.conf rwk,
|
||||
owner /home/*/.config/Trolltech.conf.* rw,
|
||||
owner /proc/*/mounts r,
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
{
|
||||
"id": "org.bitmessage.BaseApp",
|
||||
"branch": "19.08",
|
||||
"runtime": "org.freedesktop.Platform",
|
||||
"sdk": "org.freedesktop.Sdk",
|
||||
"runtime-version": "19.08",
|
||||
"separate-locales": false,
|
||||
"modules": [
|
||||
"shared-modules/python2.7/python-2.7.json",
|
||||
"shared-modules/qt4/qt4-4.8.7-minimal.json",
|
||||
{
|
||||
"name": "python-sip",
|
||||
"sources": [
|
||||
{
|
||||
"type": "archive",
|
||||
"url": "https://www.riverbankcomputing.com/static/Downloads/sip/4.19.25/sip-4.19.25.tar.gz",
|
||||
"sha256": "b39d93e937647807bac23579edbff25fe46d16213f708370072574ab1f1b4211"
|
||||
}
|
||||
],
|
||||
"buildsystem": "simple",
|
||||
"build-commands": [
|
||||
"python configure.py --sip-module PyQt4.sip --no-dist-info",
|
||||
"make",
|
||||
"make install"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "python-qt4",
|
||||
"sources": [
|
||||
{
|
||||
"type": "archive",
|
||||
"url": "http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.12.3/PyQt4_gpl_x11-4.12.3.tar.gz",
|
||||
"sha256": "a00f5abef240a7b5852b7924fa5fdf5174569525dc076cd368a566619e56d472"
|
||||
}
|
||||
],
|
||||
"buildsystem": "simple",
|
||||
"build-commands": [
|
||||
"python configure.py -w --confirm-license",
|
||||
"make",
|
||||
"make install"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "PyBitmessage-dependencies",
|
||||
"buildsystem" : "simple",
|
||||
"build-options": {
|
||||
"build-args": [
|
||||
"--share=network"
|
||||
]
|
||||
},
|
||||
"build-commands": [
|
||||
"pip --version",
|
||||
"pip install setuptools msgpack"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
{
|
||||
"app-id": "org.bitmessage.PyBitmessage",
|
||||
"runtime": "org.freedesktop.Platform",
|
||||
"runtime-version": "19.08",
|
||||
"branch": "stable",
|
||||
"sdk": "org.freedesktop.Sdk",
|
||||
"base": "org.bitmessage.BaseApp",
|
||||
"command": "pybitmessage",
|
||||
"base-version":"stable",
|
||||
"finish-args" : [
|
||||
"--share=network",
|
||||
"--socket=x11",
|
||||
"--share=ipc",
|
||||
"--filesystem=xdg-config/PyBitmessage:create"
|
||||
],
|
||||
"modules": [
|
||||
{
|
||||
"name" : "PyBitmessage",
|
||||
"buildsystem" : "simple",
|
||||
"build-options": {
|
||||
"build-args": [
|
||||
"--share=network"
|
||||
]
|
||||
},
|
||||
"build-commands": [
|
||||
"python --version",
|
||||
"pwd",
|
||||
"ls",
|
||||
"python checkdeps.py",
|
||||
"python setup.py install --prefix=/app --exec-prefix=/app",
|
||||
"sed -i 's~/usr/bin/~/app/bin/~' /app/bin/pybitmessage",
|
||||
"cat /app/bin/pybitmessage",
|
||||
"mv /app/share/applications/pybitmessage.desktop /app/share/applications/org.bitmessage.PyBitmessage.desktop",
|
||||
"sed -i 's~Icon=pybitmessage~Icon=org.bitmessage.PyBitmessage~' /app/share/applications/org.bitmessage.PyBitmessage.desktop",
|
||||
"mv /app/share/icons/hicolor/scalable/apps/pybitmessage.svg /app/share/icons/hicolor/scalable/apps/org.bitmessage.PyBitmessage.svg",
|
||||
"mv /app/share/icons/hicolor/24x24/apps/pybitmessage.png /app/share/icons/hicolor/24x24/apps/org.bitmessage.PyBitmessage.png",
|
||||
"which pybitmessage"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "dir",
|
||||
"path" : "../../"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit fd4d38328ccb078b88ad4a891807e593ae8de806
|
|
@ -1,132 +1,79 @@
|
|||
# -*- mode: python -*-
|
||||
import ctypes
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
site_root = os.path.abspath(HOMEPATH)
|
||||
spec_root = os.path.abspath(SPECPATH)
|
||||
arch = 32 if ctypes.sizeof(ctypes.c_voidp) == 4 else 64
|
||||
cdrivePath = site_root[0:3]
|
||||
srcPath = os.path.join(spec_root[:-20], "src")
|
||||
sslName = 'OpenSSL-Win%i' % arch
|
||||
openSSLPath = os.path.join(cdrivePath, sslName)
|
||||
msvcrDllPath = os.path.join(cdrivePath, "windows", "system32")
|
||||
outPath = os.path.join(spec_root, "bitmessagemain")
|
||||
qtBase = "PyQt4"
|
||||
|
||||
sys.path.insert(0, srcPath)
|
||||
os.chdir(srcPath)
|
||||
|
||||
srcPath = "C:\\src\\PyBitmessage\\src\\"
|
||||
qtPath = "C:\\Qt-4.8.7\\"
|
||||
openSSLPath = "C:\\OpenSSL-1.0.2j\\bin\\"
|
||||
outPath = "C:\\src\\PyInstaller-3.2.1\\bitmessagemain"
|
||||
today = time.strftime("%Y%m%d")
|
||||
snapshot = False
|
||||
|
||||
os.rename(
|
||||
os.path.join(srcPath, '__init__.py'),
|
||||
os.path.join(srcPath, '__init__.py.backup'))
|
||||
os.rename(os.path.join(srcPath, '__init__.py'), os.path.join(srcPath, '__init__.py.backup'))
|
||||
|
||||
a = Analysis(
|
||||
[os.path.join(srcPath, 'bitmessagemain.py')],
|
||||
# -*- mode: python -*-
|
||||
a = Analysis([srcPath + 'bitmessagemain.py'],
|
||||
pathex=[outPath],
|
||||
hiddenimports=[
|
||||
'bitmessageqt.languagebox', 'pyopencl', 'numpy', 'win32com',
|
||||
'setuptools.msvc', '_cffi_backend'
|
||||
],
|
||||
hiddenimports=[],
|
||||
hookspath=None,
|
||||
runtime_hooks=None,
|
||||
excludes=['bsddb', 'bz2', 'tcl', 'tk', 'Tkinter']
|
||||
)
|
||||
|
||||
os.rename(
|
||||
os.path.join(srcPath, '__init__.py.backup'),
|
||||
os.path.join(srcPath, '__init__.py'))
|
||||
runtime_hooks=None)
|
||||
|
||||
os.rename(os.path.join(srcPath, '__init__.py.backup'), os.path.join(srcPath, '__init__.py'))
|
||||
|
||||
def addTranslations():
|
||||
import os
|
||||
extraDatas = []
|
||||
for file_ in os.listdir(os.path.join(srcPath, 'translations')):
|
||||
if file_[-3:] != ".qm":
|
||||
for file in os.listdir(srcPath + 'translations'):
|
||||
if file[-3:] != ".qm":
|
||||
continue
|
||||
extraDatas.append((
|
||||
os.path.join('translations', file_),
|
||||
os.path.join(srcPath, 'translations', file_), 'DATA'))
|
||||
for libdir in sys.path:
|
||||
qtdir = os.path.join(libdir, qtBase, 'translations')
|
||||
if os.path.isdir(qtdir):
|
||||
break
|
||||
if not os.path.isdir(qtdir):
|
||||
return extraDatas
|
||||
for file_ in os.listdir(qtdir):
|
||||
if file_[0:3] != "qt_" or file_[5:8] != ".qm":
|
||||
extraDatas.append((os.path.join('translations', file), os.path.join(srcPath, 'translations', file), 'DATA'))
|
||||
for file in os.listdir(qtPath + 'translations'):
|
||||
if file[0:3] != "qt_" or file[5:8] != ".qm":
|
||||
continue
|
||||
extraDatas.append((
|
||||
os.path.join('translations', file_),
|
||||
os.path.join(qtdir, file_), 'DATA'))
|
||||
extraDatas.append((os.path.join('translations', file), os.path.join(qtPath, 'translations', file), 'DATA'))
|
||||
return extraDatas
|
||||
|
||||
|
||||
dir_append = os.path.join(srcPath, 'bitmessageqt')
|
||||
|
||||
a.datas += [
|
||||
(os.path.join('ui', file_), os.path.join(dir_append, file_), 'DATA')
|
||||
for file_ in os.listdir(dir_append) if file_.endswith('.ui')
|
||||
]
|
||||
def addUIs():
|
||||
import os
|
||||
extraDatas = []
|
||||
for file in os.listdir(srcPath + 'bitmessageqt'):
|
||||
if file[-3:] != ".ui":
|
||||
continue
|
||||
extraDatas.append((os.path.join('ui', file), os.path.join(srcPath, 'bitmessageqt', file), 'DATA'))
|
||||
return extraDatas
|
||||
|
||||
# append the translations directory
|
||||
a.datas += addTranslations()
|
||||
a.datas += addUIs()
|
||||
|
||||
if ctypes.sizeof(ctypes.c_voidp) == 4:
|
||||
arch=32
|
||||
else:
|
||||
arch=64
|
||||
|
||||
excluded_binaries = [
|
||||
'QtOpenGL4.dll',
|
||||
'QtSvg4.dll',
|
||||
'QtXml4.dll',
|
||||
]
|
||||
a.binaries = TOC([x for x in a.binaries if x[0] not in excluded_binaries])
|
||||
a.binaries += [('libeay32.dll', openSSLPath + 'libeay32.dll', 'BINARY'),
|
||||
(os.path.join('bitmsghash', 'bitmsghash%i.dll' % (arch)), os.path.join(srcPath, 'bitmsghash', 'bitmsghash%i.dll' % (arch)), 'BINARY'),
|
||||
(os.path.join('bitmsghash', 'bitmsghash.cl'), os.path.join(srcPath, 'bitmsghash', 'bitmsghash.cl'), 'BINARY'),
|
||||
(os.path.join('sslkeys', 'cert.pem'), os.path.join(srcPath, 'sslkeys', 'cert.pem'), 'BINARY'),
|
||||
(os.path.join('sslkeys', 'key.pem'), os.path.join(srcPath, 'sslkeys', 'key.pem'), 'BINARY')
|
||||
]
|
||||
|
||||
a.binaries += [
|
||||
# No effect: libeay32.dll will be taken from PyQt if installed
|
||||
('libeay32.dll', os.path.join(openSSLPath, 'libeay32.dll'), 'BINARY'),
|
||||
(os.path.join('bitmsghash', 'bitmsghash%i.dll' % arch),
|
||||
os.path.join(srcPath, 'bitmsghash', 'bitmsghash%i.dll' % arch),
|
||||
'BINARY'),
|
||||
(os.path.join('bitmsghash', 'bitmsghash.cl'),
|
||||
os.path.join(srcPath, 'bitmsghash', 'bitmsghash.cl'), 'BINARY'),
|
||||
(os.path.join('sslkeys', 'cert.pem'),
|
||||
os.path.join(srcPath, 'sslkeys', 'cert.pem'), 'BINARY'),
|
||||
(os.path.join('sslkeys', 'key.pem'),
|
||||
os.path.join(srcPath, 'sslkeys', 'key.pem'), 'BINARY')
|
||||
]
|
||||
|
||||
|
||||
from version import softwareVersion
|
||||
|
||||
today = time.strftime("%Y%m%d")
|
||||
|
||||
fname = '%s_%%s_%s.exe' % (
|
||||
('Bitmessagedev', today) if snapshot else ('Bitmessage', softwareVersion)
|
||||
) % ("x86" if arch == 32 else "x64")
|
||||
with open(os.path.join(srcPath, 'version.py'), 'rt') as f:
|
||||
softwareVersion = f.readline().split('\'')[1]
|
||||
|
||||
fname = 'Bitmessage_%s_%s.exe' % ("x86" if arch == 32 else "x64", softwareVersion)
|
||||
if snapshot:
|
||||
fname = 'Bitmessagedev_%s_%s.exe' % ("x86" if arch == 32 else "x64", today)
|
||||
|
||||
pyz = PYZ(a.pure)
|
||||
exe = EXE(
|
||||
pyz,
|
||||
exe = EXE(pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
a.binaries,
|
||||
name=fname,
|
||||
debug=False,
|
||||
strip=None,
|
||||
upx=False,
|
||||
console=False, icon=os.path.join(srcPath, 'images', 'can-icon.ico')
|
||||
)
|
||||
|
||||
coll = COLLECT(
|
||||
exe,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
strip=False,
|
||||
upx=False,
|
||||
name='main'
|
||||
)
|
||||
console=False, icon= os.path.join(srcPath, 'images', 'can-icon.ico'))
|
||||
|
|
48
packages/unmaintained/debian.sh
Executable file
48
packages/unmaintained/debian.sh
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash
|
||||
|
||||
APP=pybitmessage
|
||||
PREV_VERSION=0.4.4
|
||||
VERSION=0.6.0
|
||||
RELEASE=1
|
||||
ARCH_TYPE=all
|
||||
DIR=${APP}-${VERSION}
|
||||
CURDIR=`pwd`
|
||||
SHORTDIR=`basename ${CURDIR}`
|
||||
|
||||
if [ $ARCH_TYPE == "x86_64" ]; then
|
||||
ARCH_TYPE="amd64"
|
||||
fi
|
||||
if [ $ARCH_TYPE == "i686" ]; then
|
||||
ARCH_TYPE="i386"
|
||||
fi
|
||||
|
||||
|
||||
# Update version numbers automatically - so you don't have to
|
||||
sed -i 's/VERSION='${PREV_VERSION}'/VERSION='${VERSION}'/g' Makefile rpm.sh arch.sh puppy.sh ebuild.sh slack.sh
|
||||
sed -i 's/Version: '${PREV_VERSION}'/Version: '${VERSION}'/g' rpmpackage/${APP}.spec
|
||||
sed -i 's/Release: '${RELEASE}'/Release: '${RELEASE}'/g' rpmpackage/${APP}.spec
|
||||
sed -i 's/pkgrel='${RELEASE}'/pkgrel='${RELEASE}'/g' archpackage/PKGBUILD
|
||||
sed -i 's/pkgver='${PREV_VERSION}'/pkgver='${VERSION}'/g' archpackage/PKGBUILD
|
||||
sed -i "s/-${PREV_VERSION}-/-${VERSION}-/g" puppypackage/*.specs
|
||||
sed -i "s/|${PREV_VERSION}|/|${VERSION}|/g" puppypackage/*.specs
|
||||
sed -i 's/VERSION='${PREV_VERSION}'/VERSION='${VERSION}'/g' puppypackage/pinstall.sh puppypackage/puninstall.sh
|
||||
sed -i 's/-'${PREV_VERSION}'.so/-'${VERSION}'.so/g' debian/*.links
|
||||
|
||||
make clean
|
||||
make
|
||||
|
||||
# Change the parent directory name to Debian format
|
||||
mv ../${SHORTDIR} ../${DIR}
|
||||
|
||||
# Create a source archive
|
||||
make sourcedeb
|
||||
|
||||
# Build the package
|
||||
dpkg-buildpackage -F -us -uc
|
||||
|
||||
# Sign files
|
||||
gpg -ba ../${APP}_${VERSION}-1_${ARCH_TYPE}.deb
|
||||
gpg -ba ../${APP}_${VERSION}.orig.tar.gz
|
||||
|
||||
# Restore the parent directory name
|
||||
mv ../${DIR} ../${SHORTDIR}
|
483
packages/unmaintained/debian/changelog
Normal file
483
packages/unmaintained/debian/changelog
Normal file
|
@ -0,0 +1,483 @@
|
|||
pybitmessage (0.6.0-1) trusty; urgency=low
|
||||
|
||||
* Bugfixes
|
||||
* UI improvements
|
||||
* performance and security improvements
|
||||
* integration with email gateway (mailchuck.com)
|
||||
|
||||
-- Peter Surda <dev@mailchuck.com> Mon, 2 May 2016 16:25:00 +0200
|
||||
|
||||
pybitmessage (0.4.4-1) utopic; urgency=low
|
||||
|
||||
* Added ability to limit network transfer rate
|
||||
* Updated to Protocol Version 3
|
||||
* Removed use of memoryview so that we can support python 2.7.3
|
||||
* Make use of l10n for localizations
|
||||
|
||||
-- Bob Mottram (4096 bits) <bob@robotics.uk.to> Sun, 2 November 2014 12:55:00 +0100
|
||||
|
||||
pybitmessage (0.4.3-1) saucy; urgency=low
|
||||
|
||||
* Support pyelliptic's updated HMAC algorithm. We'll remove support for the old method after an upgrade period.
|
||||
* Improved version check
|
||||
* Refactored decodeBase58 function
|
||||
* Ignore duplicate messages
|
||||
* Added bytes received/sent counts and rate on the network information tab
|
||||
* Fix unicode handling in 'View HTML code as formatted text'
|
||||
* Refactor handling of packet headers
|
||||
* Use pointMult function instead of arithmetic.privtopub since it is faster
|
||||
* Fixed issue where client wasn't waiting for a verack before continuing on with the conversation
|
||||
* Fixed CPU hogging by implementing tab-based refresh improvements
|
||||
* Added curses interface
|
||||
* Added support for IPv6
|
||||
* Added a 'trustedpeer' option to keys.dat
|
||||
* Limit maximum object size to 20 MB
|
||||
* Support email-like > quote characters and reply-below-quote
|
||||
* Added Japanese and Dutch language files; updated Norwegian and Russian languages files
|
||||
|
||||
-- Bob Mottram (4096 bits) <bob@robotics.uk.to> Thu, 6 March 2014 20:23:00 +0100
|
||||
|
||||
pybitmessage (0.4.2-1) saucy; urgency=low
|
||||
|
||||
* Exclude debian directory from orig.tar.gz
|
||||
|
||||
* Added Norwegian, Chinese, and Arabic translations
|
||||
|
||||
* sock.sendall function isn't atomic.
|
||||
Let sendDataThread be the only thread which sends data.
|
||||
|
||||
* Moved API code to api.py
|
||||
|
||||
* Populate comboBoxSendFrom when replying
|
||||
|
||||
* Added option to show recent broadcasts when subscribing
|
||||
|
||||
* Fixed issue: If Windows username contained an international character,
|
||||
Bitmessage wouldn't start
|
||||
|
||||
* Added some code for FreeBSD compatibility
|
||||
|
||||
* Moved responsibility for processing network objects
|
||||
to the new ObjectProcessorThread
|
||||
|
||||
* Refactored main QT module
|
||||
Moved popup menus initialization to separate methods
|
||||
Simplified inbox loading
|
||||
Moved magic strings to the model scope constants so they won't
|
||||
be created every time.
|
||||
|
||||
* Updated list of defaultKnownNodes
|
||||
|
||||
* Fixed issue: [Linux] When too many messages arrive too quickly,
|
||||
exception occurs: "Exceeded maximum number of notifications"
|
||||
|
||||
* Fixed issue: creating then deleting an Address in short time crashes
|
||||
class_singleWorker.py
|
||||
|
||||
* Refactored code which displays messages to improve code readability
|
||||
|
||||
* load "Sent To" label from subscriptions if available
|
||||
|
||||
* Removed code to add chans to our address book as it is no longer necessary
|
||||
|
||||
* Added identicons
|
||||
|
||||
* Modified addresses.decodeAddress so that API command decodeAddress
|
||||
works properly
|
||||
|
||||
* Added API commands createChan, joinChan, leaveChan, deleteAddress
|
||||
|
||||
* In pyelliptic, check the return value of RAND_bytes to make sure enough
|
||||
random data was generated
|
||||
|
||||
* Don't store messages in UI table (and thus in memory), pull from SQL
|
||||
inventory as needed
|
||||
|
||||
* Fix typos in API commands addSubscription and getInboxMessagesByAddress
|
||||
|
||||
* Add feature in settings menu to give up resending a message after a
|
||||
specified period of time
|
||||
|
||||
-- Bob Mottram (4096 bits) <bob@robotics.uk.to> Thu, 6 March 2014 20:23:00 +0100
|
||||
|
||||
pybitmessage (0.4.1-1) raring; urgency=low
|
||||
|
||||
* Fixed whitelist bug
|
||||
|
||||
* Fixed chan bug
|
||||
Added addressversion field to pubkeys table
|
||||
Sending messages to a chan no longer uses anything in the pubkeys table
|
||||
Sending messages to yourself is now fully supported
|
||||
|
||||
* Change _verifyAddress function to support v4 addresses
|
||||
|
||||
-- Bob Mottram (4096 bits) <bob@robotics.uk.to> Sun, 29 September 2013 09:54:00 +0100
|
||||
|
||||
pybitmessage (0.4.0-1) raring; urgency=low
|
||||
|
||||
* Raised default demanded difficulty from 1 to 2 for new addresses
|
||||
|
||||
* Added v4 addresses:
|
||||
pubkeys are now encrypted and tagged in the inventory
|
||||
|
||||
* Use locks when accessing dictionary inventory
|
||||
|
||||
* Refactored the way inv and addr messages are shared
|
||||
|
||||
* Give user feedback when disk is full
|
||||
|
||||
* Added chan true/false to listAddresses results
|
||||
|
||||
* When replying using chan address, send to whole chan not just sender
|
||||
|
||||
* Refactored of the way PyBitmessage looks for interesting new objects
|
||||
in large inv messages from peers
|
||||
|
||||
* Show inventory lookup rate on Network Status tab
|
||||
|
||||
* Added SqlBulkExecute class
|
||||
so we can update inventory with only one commit
|
||||
|
||||
* Updated Russian translations
|
||||
|
||||
* Move duplicated SQL code into helper
|
||||
|
||||
* Allow specification of alternate settings dir
|
||||
via BITMESSAGE_HOME environment variable
|
||||
|
||||
* Removed use of gevent. Removed class_bgWorker.py
|
||||
|
||||
* Added Sip and PyQt to includes in build_osx.py
|
||||
|
||||
* Show number of each message type processed
|
||||
in the API command clientStatus
|
||||
|
||||
* Use fast PoW
|
||||
unless we're explicitly a frozen (binary) version of the code
|
||||
|
||||
* Enable user-set localization in settings
|
||||
|
||||
* Fix Archlinux package creation
|
||||
|
||||
* Fallback to language only localization when region doesn't match
|
||||
|
||||
* Fixed brew install instructions
|
||||
|
||||
* Added German translation
|
||||
|
||||
* Made inbox and sent messages table panels read-only
|
||||
|
||||
* Allow inbox and sent preview panels to resize
|
||||
|
||||
* Count RE: as a reply header, just like Re: so we don't chain Re: RE:
|
||||
|
||||
* Fix for traceback on OSX
|
||||
|
||||
* Added backend ability to understand shorter addresses
|
||||
|
||||
* Convert 'API Error' to raise APIError()
|
||||
|
||||
* Added option in settings to allow sending to a mobile device
|
||||
(app not yet done)
|
||||
|
||||
* Added ability to start daemon mode when using Bitmessage as a module
|
||||
|
||||
* Improved the way client detects locale
|
||||
|
||||
* Added API commands:
|
||||
getInboxMessageIds, getSentMessageIds, listAddressBookEntries,
|
||||
trashSentMessageByAckData, addAddressBookEntry,
|
||||
deleteAddressBookEntry, listAddresses2, listSubscriptions
|
||||
|
||||
* Set a maximum frequency for playing sounds
|
||||
|
||||
* Show Invalid Method error in same format as other API errors
|
||||
|
||||
* Update status of separate broadcasts separately
|
||||
even if the sent data is identical
|
||||
|
||||
* Added Namecoin integration
|
||||
|
||||
* Internally distinguish peers by IP and port
|
||||
|
||||
* Inbox message retrieval API
|
||||
functions now also returns read status
|
||||
|
||||
-- Bob Mottram (4096 bits) <bob@robotics.uk.to> Sat, 28 September 2013 09:54:00 +0100
|
||||
|
||||
pybitmessage (0.3.5-1) raring; urgency=low
|
||||
|
||||
* Inbox message retrieval API functions now also returns read status
|
||||
|
||||
* Added right-click option to mark a message as unread
|
||||
|
||||
* Prompt user to connect at first startup
|
||||
|
||||
* Install into /usr/local by default
|
||||
|
||||
* Add a missing rm -f to the uninstall task.
|
||||
|
||||
* Use system text color for enabled addresses instead of black
|
||||
|
||||
* Added support for Chans
|
||||
|
||||
* Start storing msgid in sent table
|
||||
|
||||
* Optionally play sounds on connection/disconnection or when messages arrive
|
||||
|
||||
* Adding configuration option to listen for connections when using SOCKS
|
||||
|
||||
* Added packaging for multiple distros (Arch, Puppy, Slack, etc.)
|
||||
|
||||
* Added Russian translation
|
||||
|
||||
* Added search support in the UI
|
||||
|
||||
* Added 'make uninstall'
|
||||
|
||||
* To improve OSX support, use PKCS5_PBKDF2_HMAC_SHA1
|
||||
if PKCS5_PBKDF2_HMAC is unavailable
|
||||
|
||||
* Added better warnings for OSX users who are using old versions of Python
|
||||
|
||||
* Repaired debian packaging
|
||||
|
||||
* Altered Makefile to avoid needing to chase changes
|
||||
|
||||
* Added logger module
|
||||
|
||||
* Added bgWorker class for background tasks
|
||||
|
||||
* Added use of gevent module
|
||||
|
||||
* On not-Windows: Fix insecure keyfile permissions
|
||||
|
||||
* Fix 100% CPU usage issue
|
||||
|
||||
-- Bob Mottram (4096 bits) <bob@robotics.uk.to> Mon, 29 July 2013 22:11:00 +0100
|
||||
|
||||
pybitmessage (0.3.4-1) raring; urgency=low
|
||||
|
||||
* Switched addr, msg, broadcast, and getpubkey message types
|
||||
to 8 byte time. Last remaining type is pubkey.
|
||||
|
||||
* Added tooltips to show the full subject of messages
|
||||
|
||||
* Added Maximum Acceptable Difficulty fields in the settings
|
||||
|
||||
* Send out pubkey immediately after generating deterministic
|
||||
addresses rather than waiting for a request
|
||||
|
||||
-- Bob Mottram (4096 bits) <bob@robotics.uk.to> Sun, 30 June 2013 11:23:00 +0100
|
||||
|
||||
pybitmessage (0.3.3-1) raring; urgency=low
|
||||
|
||||
* Remove inbox item from GUI when using API command trashMessage
|
||||
|
||||
* Add missing trailing semicolons to pybitmessage.desktop
|
||||
|
||||
* Ensure $(DESTDIR)/usr/bin exists
|
||||
|
||||
* Update Makefile to correct sandbox violations when built
|
||||
via Portage (Gentoo)
|
||||
|
||||
* Fix message authentication bug
|
||||
|
||||
-- Bob Mottram (4096 bits) <bob@robotics.uk.to> Sat, 29 June 2013 11:23:00 +0100
|
||||
|
||||
pybitmessage (0.3.211-1) raring; urgency=low
|
||||
|
||||
* Removed multi-core proof of work
|
||||
as the multiprocessing module does not work well with
|
||||
pyinstaller's --onefile option.
|
||||
|
||||
-- Bob Mottram (4096 bits) <bob@robotics.uk.to> Fri, 28 June 2013 11:23:00 +0100
|
||||
|
||||
pybitmessage (0.3.2-1) raring; urgency=low
|
||||
|
||||
* Bugfix: Remove remaining references to the old myapp.trayIcon
|
||||
|
||||
* Refactored message status-related code. API function getStatus
|
||||
now returns one of these strings: notfound, msgqueued,
|
||||
broadcastqueued, broadcastsent, doingpubkeypow, awaitingpubkey,
|
||||
doingmsgpow, msgsent, or ackreceived
|
||||
|
||||
* Moved proof of work to low-priority multi-threaded child
|
||||
processes
|
||||
|
||||
* Added menu option to delete all trashed messages
|
||||
|
||||
* Added inv flooding attack mitigation
|
||||
|
||||
* On Linux, when selecting Show Bitmessage, do not maximize
|
||||
automatically
|
||||
|
||||
* Store tray icons in bitmessage_icons_rc.py
|
||||
|
||||
-- Bob Mottram (4096 bits) <bob@robotics.uk.to> Mon, 03 June 2013 20:17:00 +0100
|
||||
|
||||
pybitmessage (0.3.1-1) raring; urgency=low
|
||||
|
||||
* Added new API commands: getDeterministicAddress,
|
||||
addSubscription, deleteSubscription
|
||||
|
||||
* TCP Connection timeout for non-fully-established connections
|
||||
now 20 seconds
|
||||
|
||||
* Don't update the time we last communicated with a node unless
|
||||
the connection is fully established. This will allow us to
|
||||
forget about active but non-Bitmessage nodes which have made
|
||||
it into our knownNodes file.
|
||||
|
||||
* Prevent incoming connection flooding from crashing
|
||||
singleListener thread. Client will now only accept one
|
||||
connection per remote node IP
|
||||
|
||||
* Bugfix: Worker thread crashed when doing a POW to send out
|
||||
a v2 pubkey (bug introduced in 0.3.0)
|
||||
|
||||
* Wrap all sock.shutdown functions in error handlers
|
||||
|
||||
* Put all 'commit' commands within SQLLocks
|
||||
|
||||
* Bugfix: If address book label is blank, Bitmessage wouldn't
|
||||
show message (bug introduced in 0.3.0)
|
||||
|
||||
* Messaging menu item selects the oldest unread message
|
||||
|
||||
* Standardize on 'Quit' rather than 'Exit'
|
||||
|
||||
* [OSX] Try to seek homebrew installation of OpenSSL
|
||||
|
||||
* Prevent multiple instances of the application from running
|
||||
|
||||
* Show 'Connected' or 'Connection Lost' indicators
|
||||
|
||||
* Use only 9 half-open connections on Windows but 32 for
|
||||
everyone else
|
||||
|
||||
* Added appIndicator (a more functional tray icon) and Ubuntu
|
||||
Messaging Menu integration
|
||||
|
||||
* Changed Debian install directory and run script name based
|
||||
on Github issue #135
|
||||
|
||||
-- Jonathan Warren (4096 bits) <jonathan@bitmessage.org> Sat, 25 May 2013 12:06:00 +0100
|
||||
|
||||
pybitmessage (0.3.0-1) raring; urgency=low
|
||||
|
||||
* Added new API function: getStatus
|
||||
|
||||
* Added error-handling around all sock.sendall() functions
|
||||
in the receiveData thread so that if there is a problem
|
||||
sending data, the threads will close gracefully
|
||||
|
||||
* Abandoned and removed the connectionsCount data structure;
|
||||
use the connectedHostsList instead because it has proved to be
|
||||
more accurate than trying to maintain the connectionsCount
|
||||
|
||||
* Added daemon mode. All UI code moved into a module and many
|
||||
shared objects moved into shared.py
|
||||
|
||||
* Truncate display of very long messages to avoid freezing the UI
|
||||
|
||||
* Added encrypted broadcasts for v3 addresses or v2 addresses
|
||||
after 2013-05-28 10:00 UTC
|
||||
|
||||
* No longer self.sock.close() from within receiveDataThreads,
|
||||
let the sendDataThreads do it
|
||||
|
||||
* Swapped out the v2 announcements subscription address for a v3
|
||||
announcements subscription address
|
||||
|
||||
* Vacuum the messages.dat file once a month:
|
||||
will greatly reduce the file size
|
||||
|
||||
* Added a settings table in message.dat
|
||||
|
||||
* Implemented v3 addresses:
|
||||
pubkey messages must now include two var_ints: nonce_trials_per_byte
|
||||
and extra_bytes, and also be signed. When sending a message to a v3
|
||||
address, the sender must use these values in calculating its POW or
|
||||
else the message will not be accepted by the receiver.
|
||||
|
||||
* Display a privacy warning when selecting 'Send Broadcast from this address'
|
||||
|
||||
* Added gitignore file
|
||||
|
||||
* Added code in preparation for a switch from 32-bit time to 64-bit time.
|
||||
Nodes will now advertise themselves as using protocol version 2.
|
||||
|
||||
* Don't necessarily delete entries from the inventory after 2.5 days;
|
||||
leave pubkeys there for 28 days so that we don't process the same ones
|
||||
many times throughout a month. This was causing the 'pubkeys processed'
|
||||
indicator on the 'Network Status' tab to not accurately reflect the
|
||||
number of truly new addresses on the network.
|
||||
|
||||
* Use 32 threads for outgoing connections in order to connect quickly
|
||||
|
||||
* Fix typo when calling os.environ in the sys.platform=='darwin' case
|
||||
|
||||
* Allow the cancelling of a message which is in the process of being
|
||||
sent by trashing it then restarting Bitmessage
|
||||
|
||||
* Bug fix: can't delete address from address book
|
||||
|
||||
-- Bob Mottram (4096 bits) <bob@sluggish.dyndns.org> Mon, 6 May 2013 12:06:00 +0100
|
||||
|
||||
pybitmessage (0.2.8-1) unstable; urgency=low
|
||||
|
||||
* Fixed Ubuntu & OS X issue:
|
||||
Bitmessage wouldn't receive any objects from peers after restart.
|
||||
|
||||
* Inventory flush to disk when exiting program now vastly faster.
|
||||
|
||||
* Fixed address generation bug (kept Bitmessage from restarting).
|
||||
|
||||
* Improve deserialization of messages
|
||||
before processing (a 'best practice').
|
||||
|
||||
* Change to help Macs find OpenSSL the way Unix systems find it.
|
||||
|
||||
* Do not share or accept IPs which are in the private IP ranges.
|
||||
|
||||
* Added time-fuzzing
|
||||
to the embedded time in pubkey and getpubkey messages.
|
||||
|
||||
* Added a knownNodes lock
|
||||
to prevent an exception from sometimes occurring when saving
|
||||
the data-structure to disk.
|
||||
|
||||
* Show unread messages in bold
|
||||
and do not display new messages automatically.
|
||||
|
||||
* Support selecting multiple items
|
||||
in the inbox, sent box, and address book.
|
||||
|
||||
* Use delete key to trash Inbox or Sent messages.
|
||||
|
||||
* Display richtext(HTML) messages
|
||||
from senders in address book or subscriptions (although not
|
||||
pseudo-mailing-lists; use new right-click option).
|
||||
|
||||
* Trim spaces
|
||||
from the beginning and end of addresses when adding to
|
||||
address book, subscriptions, and blacklist.
|
||||
|
||||
* Improved the display of the time for foreign language users.
|
||||
|
||||
-- Bob Mottram (4096 bits) <bob@sluggish.dyndns.org> Tue, 9 Apr 2013 17:44:00 +0100
|
||||
|
||||
pybitmessage (0.2.7-1) unstable; urgency=low
|
||||
|
||||
* Added debian packaging
|
||||
|
||||
* Script to generate debian packages
|
||||
|
||||
* SVG icon for Gnome shell, etc
|
||||
|
||||
* Source moved int src directory for debian standards compatibility
|
||||
|
||||
* Trailing carriage return on COPYING LICENSE and README.md
|
||||
|
||||
-- Bob Mottram (4096 bits) <bob@sluggish.dyndns.org> Mon, 1 Apr 2013 17:12:14 +0100
|
1
packages/unmaintained/debian/compat
Normal file
1
packages/unmaintained/debian/compat
Normal file
|
@ -0,0 +1 @@
|
|||
9
|
21
packages/unmaintained/debian/control
Normal file
21
packages/unmaintained/debian/control
Normal file
|
@ -0,0 +1,21 @@
|
|||
Source: pybitmessage
|
||||
Section: mail
|
||||
Priority: extra
|
||||
Maintainer: Bob Mottram (4096 bits) <bob@robotics.uk.to>
|
||||
Build-Depends: debhelper (>= 9.0.0), libqt4-dev (>= 4.8.0), python-qt4-dev, libsqlite3-dev
|
||||
Standards-Version: 3.9.4
|
||||
Homepage: https://github.com/Bitmessage/PyBitmessage
|
||||
Vcs-Git: https://github.com/Bitmessage/PyBitmessage.git
|
||||
|
||||
Package: pybitmessage
|
||||
Architecture: all
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, python (>= 2.7), openssl, python-qt4, sqlite3, gst123
|
||||
Suggests: libmessaging-menu-dev
|
||||
Description: Send encrypted messages
|
||||
Bitmessage is a P2P communications protocol used to send encrypted
|
||||
messages to another person or to many subscribers. It is decentralized and
|
||||
trustless, meaning that you need-not inherently trust any entities like
|
||||
root certificate authorities. It uses strong authentication which means
|
||||
that the sender of a message cannot be spoofed, and it aims to hide
|
||||
"non-content" data, like the sender and receiver of messages, from passive
|
||||
eavesdroppers like those running warrantless wiretapping programs.
|
30
packages/unmaintained/debian/copyright
Normal file
30
packages/unmaintained/debian/copyright
Normal file
|
@ -0,0 +1,30 @@
|
|||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name:
|
||||
Source:
|
||||
|
||||
Files: *
|
||||
Copyright: Copyright 2016 Bob Mottram (4096 bits) <bob@robotics.uk.to>
|
||||
License: MIT
|
||||
|
||||
Files: debian/*
|
||||
Copyright: Copyright 2016 Bob Mottram (4096 bits) <bob@robotics.uk.to>
|
||||
License: MIT
|
||||
|
||||
License: MIT
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
.
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
packages/unmaintained/debian/docs
Normal file
1
packages/unmaintained/debian/docs
Normal file
|
@ -0,0 +1 @@
|
|||
|
1
packages/unmaintained/debian/manpages
Normal file
1
packages/unmaintained/debian/manpages
Normal file
|
@ -0,0 +1 @@
|
|||
man/pybitmessage.1.gz
|
4
packages/unmaintained/debian/pybm
Normal file
4
packages/unmaintained/debian/pybm
Normal file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
cd /usr/share/pybitmessage
|
||||
exec python bitmessagemain.py
|
||||
|
43
packages/unmaintained/debian/rules
Executable file
43
packages/unmaintained/debian/rules
Executable file
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/make -f
|
||||
|
||||
APP=pybitmessage
|
||||
PREFIX=/usr
|
||||
build: build-stamp
|
||||
make
|
||||
build-arch: build-stamp
|
||||
build-indep: build-stamp
|
||||
build-stamp:
|
||||
dh_testdir
|
||||
touch build-stamp
|
||||
|
||||
clean:
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
rm -f build-stamp
|
||||
dh_clean
|
||||
|
||||
install: build clean
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_prep
|
||||
dh_installdirs
|
||||
${MAKE} install -B DESTDIR=${CURDIR}/debian/${APP} PREFIX=/usr
|
||||
binary-indep: build install
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_installchangelogs
|
||||
dh_installdocs
|
||||
dh_installexamples
|
||||
dh_installman
|
||||
dh_link
|
||||
dh_compress
|
||||
dh_fixperms
|
||||
dh_installdeb
|
||||
dh_gencontrol
|
||||
dh_md5sums
|
||||
dh_builddeb
|
||||
|
||||
binary-arch: build install
|
||||
|
||||
binary: binary-indep binary-arch
|
||||
.PHONY: build clean binary-indep binary-arch binary install
|
1
packages/unmaintained/debian/source/format
Normal file
1
packages/unmaintained/debian/source/format
Normal file
|
@ -0,0 +1 @@
|
|||
3.0 (quilt)
|
18
packages/unmaintained/debian/source/include-binaries
Normal file
18
packages/unmaintained/debian/source/include-binaries
Normal file
|
@ -0,0 +1,18 @@
|
|||
src/images/sent.png
|
||||
src/images/can-icon-16px.png
|
||||
src/images/addressbook.png
|
||||
src/images/networkstatus.png
|
||||
src/images/redicon.png
|
||||
src/images/subscriptions.png
|
||||
src/images/blacklist.png
|
||||
src/images/can-icon-24px.png
|
||||
src/images/can-icon-24px-red.png
|
||||
src/images/can-icon-24px-yellow.png
|
||||
src/images/can-icon-24px-green.png
|
||||
src/images/identities.png
|
||||
src/images/yellowicon.png
|
||||
src/images/inbox.png
|
||||
src/images/greenicon.png
|
||||
src/images/can-icon.ico
|
||||
src/images/send.png
|
||||
desktop/can-icon.svg
|
|
@ -1 +0,0 @@
|
|||
src
|
|
@ -1,4 +1,6 @@
|
|||
configparser
|
||||
coverage
|
||||
python_prctl
|
||||
future
|
||||
psutil
|
||||
pycrypto
|
||||
python_prctl
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
docker build -t pybm-travis-bionic -f Dockerfile.travis .
|
||||
docker run pybm-travis-bionic
|
|
@ -1,17 +1,14 @@
|
|||
# Since there is overlap in the violations that the different tools check for, it makes sense to quiesce some warnings
|
||||
# in some tools if those warnings in other tools are preferred. This avoids the need to add duplicate lint warnings.
|
||||
|
||||
# max-line-length should be removed ASAP!
|
||||
|
||||
[pycodestyle]
|
||||
max-line-length = 119
|
||||
|
||||
[flake8]
|
||||
max-line-length = 119
|
||||
ignore = E722,F841,W503
|
||||
ignore = E722,F841
|
||||
# E722: pylint is preferred for bare-except
|
||||
# F841: pylint is preferred for unused-variable
|
||||
# W503: deprecated: https://bugs.python.org/issue26763 - https://www.python.org/dev/peps/pep-0008/#should-a-line-break-before-or-after-a-binary-operator
|
||||
|
||||
# pylint honours the [MESSAGES CONTROL] section
|
||||
# as well as [MASTER] section
|
||||
|
|
61
setup.py
61
setup.py
|
@ -1,9 +1,7 @@
|
|||
#!/usr/bin/env python2.7
|
||||
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
from setuptools import setup, Extension
|
||||
from setuptools.command.install import install
|
||||
|
@ -12,17 +10,19 @@ from src.version import softwareVersion
|
|||
|
||||
|
||||
EXTRAS_REQUIRE = {
|
||||
'docs': ['sphinx', 'sphinxcontrib-apidoc', 'm2r'],
|
||||
'gir': ['pygobject'],
|
||||
'json': ['jsonrpclib'],
|
||||
'notify2': ['notify2'],
|
||||
'opencl': ['pyopencl', 'numpy'],
|
||||
'prctl': ['python_prctl'], # Named threads
|
||||
'qrcode': ['qrcode'],
|
||||
'sound;platform_system=="Windows"': ['winsound'],
|
||||
'tor': ['stem'],
|
||||
'xdg': ['pyxdg'],
|
||||
'xml': ['defusedxml']
|
||||
'docs': [
|
||||
'sphinx', # fab build_docs
|
||||
'graphviz', # fab build_docs
|
||||
'curses', # src/depends.py
|
||||
'python2-pythondialog', # src/depends.py
|
||||
'm2r', # fab build_docs
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
@ -69,6 +69,7 @@ if __name__ == "__main__":
|
|||
'pybitmessage.network',
|
||||
'pybitmessage.plugins',
|
||||
'pybitmessage.pyelliptic',
|
||||
'pybitmessage.socks',
|
||||
'pybitmessage.storage'
|
||||
]
|
||||
|
||||
|
@ -86,24 +87,6 @@ if __name__ == "__main__":
|
|||
except ImportError:
|
||||
packages += ['pybitmessage.fallback.umsgpack']
|
||||
|
||||
data_files = [
|
||||
('share/applications/',
|
||||
['desktop/pybitmessage.desktop']),
|
||||
('share/icons/hicolor/scalable/apps/',
|
||||
['desktop/icons/scalable/pybitmessage.svg']),
|
||||
('share/icons/hicolor/24x24/apps/',
|
||||
['desktop/icons/24x24/pybitmessage.png'])
|
||||
]
|
||||
|
||||
try:
|
||||
if platform.dist()[0] in ('Debian', 'Ubuntu'):
|
||||
data_files += [
|
||||
("etc/apparmor.d/",
|
||||
['packages/apparmor/pybitmessage'])
|
||||
]
|
||||
except AttributeError:
|
||||
pass # FIXME: use distro for more recent python
|
||||
|
||||
dist = setup(
|
||||
name='pybitmessage',
|
||||
version=softwareVersion,
|
||||
|
@ -119,7 +102,6 @@ if __name__ == "__main__":
|
|||
#keywords='',
|
||||
install_requires=installRequires,
|
||||
tests_require=requirements,
|
||||
test_suite='tests.unittest_discover',
|
||||
extras_require=EXTRAS_REQUIRE,
|
||||
classifiers=[
|
||||
"License :: OSI Approved :: MIT License"
|
||||
|
@ -136,7 +118,14 @@ if __name__ == "__main__":
|
|||
'translations/*.ts', 'translations/*.qm',
|
||||
'images/*.png', 'images/*.ico', 'images/*.icns'
|
||||
]},
|
||||
data_files=data_files,
|
||||
data_files=[
|
||||
('share/applications/',
|
||||
['desktop/pybitmessage.desktop']),
|
||||
('share/icons/hicolor/scalable/apps/',
|
||||
['desktop/icons/scalable/pybitmessage.svg']),
|
||||
('share/icons/hicolor/24x24/apps/',
|
||||
['desktop/icons/24x24/pybitmessage.png'])
|
||||
],
|
||||
ext_modules=[bitmsghash],
|
||||
zip_safe=False,
|
||||
entry_points={
|
||||
|
@ -158,20 +147,10 @@ if __name__ == "__main__":
|
|||
'libmessaging ='
|
||||
'pybitmessage.plugins.indicator_libmessaging [gir]'
|
||||
],
|
||||
'bitmessage.desktop': [
|
||||
'freedesktop = pybitmessage.plugins.desktop_xdg [xdg]'
|
||||
],
|
||||
'bitmessage.proxyconfig': [
|
||||
'stem = pybitmessage.plugins.proxyconfig_stem [tor]'
|
||||
],
|
||||
'console_scripts': [
|
||||
'pybitmessage = pybitmessage.bitmessagemain:main'
|
||||
] if sys.platform[:3] == 'win' else []
|
||||
# 'console_scripts': [
|
||||
# 'pybitmessage = pybitmessage.bitmessagemain:main'
|
||||
# ]
|
||||
},
|
||||
scripts=['src/pybitmessage'],
|
||||
cmdclass={'install': InstallCmd},
|
||||
command_options={
|
||||
'build_sphinx': {
|
||||
'source_dir': ('setup.py', 'docs')}
|
||||
}
|
||||
cmdclass={'install': InstallCmd}
|
||||
)
|
||||
|
|
131
src/addresses.py
131
src/addresses.py
|
@ -1,14 +1,16 @@
|
|||
"""
|
||||
Operations with addresses
|
||||
src/addresses.py
|
||||
================
|
||||
|
||||
"""
|
||||
# pylint: disable=redefined-outer-name,inconsistent-return-statements
|
||||
|
||||
import hashlib
|
||||
import logging
|
||||
from binascii import hexlify, unhexlify
|
||||
from struct import pack, unpack
|
||||
|
||||
from debug import logger
|
||||
|
||||
logger = logging.getLogger('default')
|
||||
|
||||
ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
|
||||
|
||||
|
@ -16,16 +18,17 @@ ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
|
|||
def encodeBase58(num, alphabet=ALPHABET):
|
||||
"""Encode a number in Base X
|
||||
|
||||
Args:
|
||||
num: The number to encode
|
||||
alphabet: The alphabet to use for encoding
|
||||
`num`: The number to encode
|
||||
`alphabet`: The alphabet to use for encoding
|
||||
"""
|
||||
if num == 0:
|
||||
return alphabet[0]
|
||||
arr = []
|
||||
base = len(alphabet)
|
||||
while num:
|
||||
num, rem = divmod(num, base)
|
||||
rem = num % base
|
||||
# print 'num is:', num
|
||||
num = num // base
|
||||
arr.append(alphabet[rem])
|
||||
arr.reverse()
|
||||
return ''.join(arr)
|
||||
|
@ -34,9 +37,9 @@ def encodeBase58(num, alphabet=ALPHABET):
|
|||
def decodeBase58(string, alphabet=ALPHABET):
|
||||
"""Decode a Base X encoded string into the number
|
||||
|
||||
Args:
|
||||
string: The encoded string
|
||||
alphabet: The alphabet to use for encoding
|
||||
Arguments:
|
||||
- `string`: The encoded string
|
||||
- `alphabet`: The alphabet to use for encoding
|
||||
"""
|
||||
base = len(alphabet)
|
||||
num = 0
|
||||
|
@ -51,20 +54,11 @@ def decodeBase58(string, alphabet=ALPHABET):
|
|||
return num
|
||||
|
||||
|
||||
class varintEncodeError(Exception):
|
||||
"""Exception class for encoding varint"""
|
||||
pass
|
||||
|
||||
|
||||
class varintDecodeError(Exception):
|
||||
"""Exception class for decoding varint data"""
|
||||
pass
|
||||
|
||||
|
||||
def encodeVarint(integer):
|
||||
"""Convert integer into varint bytes"""
|
||||
if integer < 0:
|
||||
raise varintEncodeError('varint cannot be < 0')
|
||||
logger.error('varint cannot be < 0')
|
||||
raise SystemExit
|
||||
if integer < 253:
|
||||
return pack('>B', integer)
|
||||
if integer >= 253 and integer < 65536:
|
||||
|
@ -74,7 +68,13 @@ def encodeVarint(integer):
|
|||
if integer >= 4294967296 and integer < 18446744073709551616:
|
||||
return pack('>B', 255) + pack('>Q', integer)
|
||||
if integer >= 18446744073709551616:
|
||||
raise varintEncodeError('varint cannot be >= 18446744073709551616')
|
||||
logger.error('varint cannot be >= 18446744073709551616')
|
||||
raise SystemExit
|
||||
|
||||
|
||||
class varintDecodeError(Exception):
|
||||
"""Exception class for decoding varint data"""
|
||||
pass
|
||||
|
||||
|
||||
def decodeVarint(data):
|
||||
|
@ -149,16 +149,16 @@ def encodeAddress(version, stream, ripe):
|
|||
'Programming error in encodeAddress: The length of'
|
||||
' a given ripe hash was not 20.'
|
||||
)
|
||||
if ripe[:2] == b'\x00\x00':
|
||||
if ripe[:2] == '\x00\x00':
|
||||
ripe = ripe[2:]
|
||||
elif ripe[:1] == b'\x00':
|
||||
elif ripe[:1] == '\x00':
|
||||
ripe = ripe[1:]
|
||||
elif version == 4:
|
||||
if len(ripe) != 20:
|
||||
raise Exception(
|
||||
'Programming error in encodeAddress: The length of'
|
||||
' a given ripe hash was not 20.')
|
||||
ripe = ripe.lstrip(b'\x00')
|
||||
ripe = ripe.lstrip('\x00')
|
||||
|
||||
storedBinaryData = encodeVarint(version) + encodeVarint(stream) + ripe
|
||||
|
||||
|
@ -179,8 +179,7 @@ def decodeAddress(address):
|
|||
returns (status, address version number, stream number,
|
||||
data (almost certainly a ripe hash))
|
||||
"""
|
||||
# pylint: disable=too-many-return-statements,too-many-statements
|
||||
# pylint: disable=too-many-branches
|
||||
# pylint: disable=too-many-return-statements,too-many-statements,too-many-return-statements,too-many-branches
|
||||
|
||||
address = str(address).strip()
|
||||
|
||||
|
@ -192,8 +191,8 @@ def decodeAddress(address):
|
|||
status = 'invalidcharacters'
|
||||
return status, 0, 0, ''
|
||||
# after converting to hex, the string will be prepended
|
||||
# with a 0x and appended with a L in python2
|
||||
hexdata = hex(integer)[2:].rstrip('L')
|
||||
# with a 0x and appended with a L
|
||||
hexdata = hex(integer)[2:-1]
|
||||
|
||||
if len(hexdata) % 2 != 0:
|
||||
hexdata = '0' + hexdata
|
||||
|
@ -243,13 +242,13 @@ def decodeAddress(address):
|
|||
data[bytesUsedByVersionNumber + bytesUsedByStreamNumber:-4]
|
||||
if len(embeddedRipeData) == 19:
|
||||
return status, addressVersionNumber, streamNumber, \
|
||||
b'\x00' + embeddedRipeData
|
||||
'\x00' + embeddedRipeData
|
||||
elif len(embeddedRipeData) == 20:
|
||||
return status, addressVersionNumber, streamNumber, \
|
||||
embeddedRipeData
|
||||
elif len(embeddedRipeData) == 18:
|
||||
return status, addressVersionNumber, streamNumber, \
|
||||
b'\x00\x00' + embeddedRipeData
|
||||
'\x00\x00' + embeddedRipeData
|
||||
elif len(embeddedRipeData) < 18:
|
||||
return 'ripetooshort', 0, 0, ''
|
||||
elif len(embeddedRipeData) > 20:
|
||||
|
@ -258,7 +257,7 @@ def decodeAddress(address):
|
|||
elif addressVersionNumber == 4:
|
||||
embeddedRipeData = \
|
||||
data[bytesUsedByVersionNumber + bytesUsedByStreamNumber:-4]
|
||||
if embeddedRipeData[0:1] == b'\x00':
|
||||
if embeddedRipeData[0:1] == '\x00':
|
||||
# In order to enforce address non-malleability, encoded
|
||||
# RIPE data must have NULL bytes removed from the front
|
||||
return 'encodingproblem', 0, 0, ''
|
||||
|
@ -266,7 +265,7 @@ def decodeAddress(address):
|
|||
return 'ripetoolong', 0, 0, ''
|
||||
elif len(embeddedRipeData) < 4:
|
||||
return 'ripetooshort', 0, 0, ''
|
||||
x00string = b'\x00' * (20 - len(embeddedRipeData))
|
||||
x00string = '\x00' * (20 - len(embeddedRipeData))
|
||||
return status, addressVersionNumber, streamNumber, \
|
||||
x00string + embeddedRipeData
|
||||
|
||||
|
@ -275,3 +274,69 @@ def addBMIfNotPresent(address):
|
|||
"""Prepend BM- to an address if it doesn't already have it"""
|
||||
address = str(address).strip()
|
||||
return address if address[:3] == 'BM-' else 'BM-' + address
|
||||
|
||||
|
||||
# TODO: make test case
|
||||
if __name__ == "__main__":
|
||||
from pyelliptic import arithmetic
|
||||
|
||||
print(
|
||||
'\nLet us make an address from scratch. Suppose we generate two'
|
||||
' random 32 byte values and call the first one the signing key'
|
||||
' and the second one the encryption key:'
|
||||
)
|
||||
privateSigningKey = \
|
||||
'93d0b61371a54b53df143b954035d612f8efa8a3ed1cf842c2186bfd8f876665'
|
||||
privateEncryptionKey = \
|
||||
'4b0b73a54e19b059dc274ab69df095fe699f43b17397bca26fdf40f4d7400a3a'
|
||||
print(
|
||||
'\nprivateSigningKey = %s\nprivateEncryptionKey = %s' %
|
||||
(privateSigningKey, privateEncryptionKey)
|
||||
)
|
||||
print(
|
||||
'\nNow let us convert them to public keys by doing'
|
||||
' an elliptic curve point multiplication.'
|
||||
)
|
||||
publicSigningKey = arithmetic.privtopub(privateSigningKey)
|
||||
publicEncryptionKey = arithmetic.privtopub(privateEncryptionKey)
|
||||
print(
|
||||
'\npublicSigningKey = %s\npublicEncryptionKey = %s' %
|
||||
(publicSigningKey, publicEncryptionKey)
|
||||
)
|
||||
|
||||
print(
|
||||
'\nNotice that they both begin with the \\x04 which specifies'
|
||||
' the encoding type. This prefix is not send over the wire.'
|
||||
' You must strip if off before you send your public key across'
|
||||
' the wire, and you must add it back when you receive a public key.'
|
||||
)
|
||||
|
||||
publicSigningKeyBinary = \
|
||||
arithmetic.changebase(publicSigningKey, 16, 256, minlen=64)
|
||||
publicEncryptionKeyBinary = \
|
||||
arithmetic.changebase(publicEncryptionKey, 16, 256, minlen=64)
|
||||
|
||||
ripe = hashlib.new('ripemd160')
|
||||
sha = hashlib.new('sha512')
|
||||
sha.update(publicSigningKeyBinary + publicEncryptionKeyBinary)
|
||||
|
||||
ripe.update(sha.digest())
|
||||
addressVersionNumber = 2
|
||||
streamNumber = 1
|
||||
print(
|
||||
'\nRipe digest that we will encode in the address: %s' %
|
||||
hexlify(ripe.digest())
|
||||
)
|
||||
returnedAddress = \
|
||||
encodeAddress(addressVersionNumber, streamNumber, ripe.digest())
|
||||
print('Encoded address: %s' % returnedAddress)
|
||||
status, addressVersionNumber, streamNumber, data = \
|
||||
decodeAddress(returnedAddress)
|
||||
print(
|
||||
'\nAfter decoding address:\n\tStatus: %s'
|
||||
'\n\taddressVersionNumber %s'
|
||||
'\n\tstreamNumber %s'
|
||||
'\n\tlength of data (the ripe hash): %s'
|
||||
'\n\tripe data: %s' %
|
||||
(status, addressVersionNumber, streamNumber, len(data), hexlify(data))
|
||||
)
|
||||
|
|
1636
src/api.py
1636
src/api.py
|
@ -1,189 +1,83 @@
|
|||
# pylint: disable=too-many-locals,too-many-lines,no-self-use,too-many-public-methods,too-many-branches
|
||||
# pylint: disable=too-many-statements
|
||||
"""
|
||||
src/api.py
|
||||
==========
|
||||
|
||||
# Copyright (c) 2012-2016 Jonathan Warren
|
||||
# Copyright (c) 2012-2020 The Bitmessage developers
|
||||
# pylint: disable=too-many-lines,no-self-use,unused-variable,unused-argument
|
||||
# Copyright (c) 2012-2019 The Bitmessage developers
|
||||
|
||||
This is not what you run to run the Bitmessage API. Instead, enable the API
|
||||
( https://bitmessage.org/wiki/API ) and optionally enable daemon mode
|
||||
( https://bitmessage.org/wiki/Daemon ) then run bitmessagemain.py.
|
||||
"""
|
||||
This is not what you run to start the Bitmessage API.
|
||||
Instead, `enable the API <https://bitmessage.org/wiki/API>`_
|
||||
and optionally `enable daemon mode <https://bitmessage.org/wiki/Daemon>`_
|
||||
then run the PyBitmessage.
|
||||
|
||||
The PyBitmessage API is provided either as
|
||||
`XML-RPC <http://xmlrpc.scripting.com/spec.html>`_ or
|
||||
`JSON-RPC <https://www.jsonrpc.org/specification>`_ like in bitcoin.
|
||||
It's selected according to 'apivariant' setting in config file.
|
||||
|
||||
Special value ``apivariant=legacy`` is to mimic the old pre 0.6.3
|
||||
behaviour when any results are returned as strings of json.
|
||||
|
||||
.. list-table:: All config settings related to API:
|
||||
:header-rows: 0
|
||||
|
||||
* - apienabled = true
|
||||
- if 'false' the `singleAPI` wont start
|
||||
* - apiinterface = 127.0.0.1
|
||||
- this is the recommended default
|
||||
* - apiport = 8442
|
||||
- the API listens apiinterface:apiport if apiport is not used,
|
||||
random in range (32767, 65535) otherwice
|
||||
* - apivariant = xml
|
||||
- current default for backward compatibility, 'json' is recommended
|
||||
* - apiusername = username
|
||||
- set the username
|
||||
* - apipassword = password
|
||||
- and the password
|
||||
* - apinotifypath =
|
||||
- not really the API setting, this sets a path for the executable to be ran
|
||||
when certain internal event happens
|
||||
|
||||
To use the API concider such simple example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import jsonrpclib
|
||||
|
||||
from pybitmessage import bmconfigparser, helper_startup
|
||||
|
||||
helper_startup.loadConfig() # find and load local config file
|
||||
conf = bmconfigparser.BMConfigParser()
|
||||
api_uri = "http://%s:%s@127.0.0.1:8442/" % (
|
||||
conf.safeGet('bitmessagesettings', 'apiusername'),
|
||||
conf.safeGet('bitmessagesettings', 'apipassword')
|
||||
)
|
||||
api = jsonrpclib.ServerProxy(api_uri)
|
||||
print(api.clientStatus())
|
||||
|
||||
|
||||
For further examples please reference `.tests.test_api`.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import base64
|
||||
import ConfigParser
|
||||
import errno
|
||||
import hashlib
|
||||
import httplib
|
||||
import json
|
||||
import random # nosec
|
||||
import socket
|
||||
import subprocess
|
||||
import threading
|
||||
import time
|
||||
import xmlrpclib
|
||||
from binascii import hexlify, unhexlify
|
||||
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler, SimpleXMLRPCServer
|
||||
from struct import pack
|
||||
|
||||
from version import softwareVersion
|
||||
|
||||
import defaults
|
||||
import helper_inbox
|
||||
import helper_sent
|
||||
import helper_threading
|
||||
import network.stats
|
||||
import proofofwork
|
||||
import queues
|
||||
import shared
|
||||
import shutdown
|
||||
import state
|
||||
from addresses import (
|
||||
addBMIfNotPresent,
|
||||
calculateInventoryHash,
|
||||
decodeAddress,
|
||||
decodeVarint,
|
||||
varintDecodeError
|
||||
)
|
||||
from addresses import addBMIfNotPresent, calculateInventoryHash, decodeAddress, decodeVarint, varintDecodeError
|
||||
from bmconfigparser import BMConfigParser
|
||||
from debug import logger
|
||||
from helper_ackPayload import genAckPayload
|
||||
from helper_sql import SqlBulkExecute, sqlExecute, sqlQuery, sqlStoredProcedure
|
||||
from inventory import Inventory
|
||||
from network.threads import StoppableThread
|
||||
from version import softwareVersion
|
||||
|
||||
try: # TODO: write tests for XML vulnerabilities
|
||||
from defusedxml.xmlrpc import monkey_patch
|
||||
except ImportError:
|
||||
logger.warning(
|
||||
'defusedxml not available, only use API on a secure, closed network.')
|
||||
else:
|
||||
monkey_patch()
|
||||
|
||||
|
||||
str_chan = '[chan]'
|
||||
str_broadcast_subscribers = '[Broadcast subscribers]'
|
||||
|
||||
|
||||
class ErrorCodes(type):
|
||||
"""Metaclass for :class:`APIError` documenting error codes."""
|
||||
_CODES = {
|
||||
0: 'Invalid command parameters number',
|
||||
1: 'The specified passphrase is blank.',
|
||||
2: 'The address version number currently must be 3, 4, or 0'
|
||||
' (which means auto-select).',
|
||||
3: 'The stream number must be 1 (or 0 which means'
|
||||
' auto-select). Others aren\'t supported.',
|
||||
4: 'Why would you ask me to generate 0 addresses for you?',
|
||||
5: 'You have (accidentally?) specified too many addresses to'
|
||||
' make. Maximum 999. This check only exists to prevent'
|
||||
' mischief; if you really want to create more addresses than'
|
||||
' this, contact the Bitmessage developers and we can modify'
|
||||
' the check or you can do it yourself by searching the source'
|
||||
' code for this message.',
|
||||
6: 'The encoding type must be 2 or 3.',
|
||||
7: 'Could not decode address',
|
||||
8: 'Checksum failed for address',
|
||||
9: 'Invalid characters in address',
|
||||
10: 'Address version number too high (or zero)',
|
||||
11: 'The address version number currently must be 2, 3 or 4.'
|
||||
' Others aren\'t supported. Check the address.',
|
||||
12: 'The stream number must be 1. Others aren\'t supported.'
|
||||
' Check the address.',
|
||||
13: 'Could not find this address in your keys.dat file.',
|
||||
14: 'Your fromAddress is disabled. Cannot send.',
|
||||
15: 'Invalid ackData object size.',
|
||||
16: 'You are already subscribed to that address.',
|
||||
17: 'Label is not valid UTF-8 data.',
|
||||
18: 'Chan name does not match address.',
|
||||
19: 'The length of hash should be 32 bytes (encoded in hex'
|
||||
' thus 64 characters).',
|
||||
20: 'Invalid method:',
|
||||
21: 'Unexpected API Failure',
|
||||
22: 'Decode error',
|
||||
23: 'Bool expected in eighteenByteRipe',
|
||||
24: 'Chan address is already present.',
|
||||
25: 'Specified address is not a chan address.'
|
||||
' Use deleteAddress API call instead.',
|
||||
26: 'Malformed varint in address: ',
|
||||
27: 'Message is too long.'
|
||||
}
|
||||
class APIError(Exception):
|
||||
"""APIError exception class"""
|
||||
|
||||
def __new__(mcs, name, bases, namespace):
|
||||
result = super(ErrorCodes, mcs).__new__(mcs, name, bases, namespace)
|
||||
for code in mcs._CODES.iteritems():
|
||||
# beware: the formatting is adjusted for list-table
|
||||
result.__doc__ += """ * - %04i
|
||||
- %s
|
||||
""" % code
|
||||
return result
|
||||
|
||||
|
||||
class APIError(xmlrpclib.Fault):
|
||||
"""
|
||||
APIError exception class
|
||||
|
||||
.. list-table:: Possible error values
|
||||
:header-rows: 1
|
||||
:widths: auto
|
||||
|
||||
* - Error Number
|
||||
- Message
|
||||
"""
|
||||
__metaclass__ = ErrorCodes
|
||||
def __init__(self, error_number, error_message):
|
||||
super(APIError, self).__init__()
|
||||
self.error_number = error_number
|
||||
self.error_message = error_message
|
||||
|
||||
def __str__(self):
|
||||
return "API Error %04i: %s" % (self.faultCode, self.faultString)
|
||||
return "API Error %04i: %s" % (self.error_number, self.error_message)
|
||||
|
||||
|
||||
class StoppableXMLRPCServer(SimpleXMLRPCServer):
|
||||
"""A SimpleXMLRPCServer that honours state.shutdown"""
|
||||
allow_reuse_address = True
|
||||
|
||||
def serve_forever(self):
|
||||
"""Start the SimpleXMLRPCServer"""
|
||||
# pylint: disable=arguments-differ
|
||||
while state.shutdown == 0:
|
||||
self.handle_request()
|
||||
|
||||
|
||||
# This thread, of which there is only one, runs the API.
|
||||
class singleAPI(StoppableThread):
|
||||
class singleAPI(threading.Thread, helper_threading.StoppableThread):
|
||||
"""API thread"""
|
||||
|
||||
name = "singleAPI"
|
||||
def __init__(self):
|
||||
threading.Thread.__init__(self, name="singleAPI")
|
||||
self.initStop()
|
||||
|
||||
def stopThread(self):
|
||||
super(singleAPI, self).stopThread()
|
||||
|
@ -199,64 +93,29 @@ class singleAPI(StoppableThread):
|
|||
pass
|
||||
|
||||
def run(self):
|
||||
"""
|
||||
The instance of `SimpleXMLRPCServer.SimpleXMLRPCServer` or
|
||||
:class:`jsonrpclib.SimpleJSONRPCServer` is created and started here
|
||||
with `BMRPCDispatcher` dispatcher.
|
||||
"""
|
||||
port = BMConfigParser().getint('bitmessagesettings', 'apiport')
|
||||
try:
|
||||
getattr(errno, 'WSAEADDRINUSE')
|
||||
except AttributeError:
|
||||
errno.WSAEADDRINUSE = errno.EADDRINUSE
|
||||
|
||||
RPCServerBase = SimpleXMLRPCServer
|
||||
ct = 'text/xml'
|
||||
if BMConfigParser().safeGet(
|
||||
'bitmessagesettings', 'apivariant') == 'json':
|
||||
try:
|
||||
from jsonrpclib.SimpleJSONRPCServer import (
|
||||
SimpleJSONRPCServer as RPCServerBase)
|
||||
except ImportError:
|
||||
logger.warning(
|
||||
'jsonrpclib not available, failing back to XML-RPC')
|
||||
else:
|
||||
ct = 'application/json-rpc'
|
||||
|
||||
# Nested class. FIXME not found a better solution.
|
||||
class StoppableRPCServer(RPCServerBase):
|
||||
"""A SimpleXMLRPCServer that honours state.shutdown"""
|
||||
allow_reuse_address = True
|
||||
content_type = ct
|
||||
|
||||
def serve_forever(self, poll_interval=None):
|
||||
"""Start the RPCServer"""
|
||||
while state.shutdown == 0:
|
||||
self.handle_request()
|
||||
|
||||
for attempt in range(50):
|
||||
try:
|
||||
if attempt > 0:
|
||||
logger.warning(
|
||||
'Failed to start API listener on port %s', port)
|
||||
port = random.randint(32767, 65535)
|
||||
se = StoppableRPCServer(
|
||||
se = StoppableXMLRPCServer(
|
||||
(BMConfigParser().get(
|
||||
'bitmessagesettings', 'apiinterface'),
|
||||
port),
|
||||
BMXMLRPCRequestHandler, True, encoding='UTF-8')
|
||||
MySimpleXMLRPCRequestHandler, True, True)
|
||||
except socket.error as e:
|
||||
if e.errno in (errno.EADDRINUSE, errno.WSAEADDRINUSE):
|
||||
continue
|
||||
else:
|
||||
if attempt > 0:
|
||||
logger.warning('Setting apiport to %s', port)
|
||||
BMConfigParser().set(
|
||||
'bitmessagesettings', 'apiport', str(port))
|
||||
"bitmessagesettings", "apiport", str(port))
|
||||
BMConfigParser().save()
|
||||
break
|
||||
|
||||
se.register_instance(BMRPCDispatcher())
|
||||
se.register_introspection_functions()
|
||||
|
||||
apiNotifyPath = BMConfigParser().safeGet(
|
||||
|
@ -276,69 +135,14 @@ class singleAPI(StoppableThread):
|
|||
se.serve_forever()
|
||||
|
||||
|
||||
class CommandHandler(type):
|
||||
class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||
"""
|
||||
The metaclass for `BMRPCDispatcher` which fills _handlers dict by
|
||||
methods decorated with @command
|
||||
This is one of several classes that constitute the API
|
||||
|
||||
This class was written by Vaibhav Bhatia. Modified by Jonathan Warren (Atheros).
|
||||
http://code.activestate.com/recipes/501148-xmlrpc-serverclient-which-does-cookie-handling-and/
|
||||
"""
|
||||
def __new__(mcs, name, bases, namespace):
|
||||
# pylint: disable=protected-access
|
||||
result = super(CommandHandler, mcs).__new__(
|
||||
mcs, name, bases, namespace)
|
||||
result.config = BMConfigParser()
|
||||
result._handlers = {}
|
||||
apivariant = result.config.safeGet('bitmessagesettings', 'apivariant')
|
||||
for func in namespace.values():
|
||||
try:
|
||||
for alias in getattr(func, '_cmd'):
|
||||
try:
|
||||
prefix, alias = alias.split(':')
|
||||
if apivariant != prefix:
|
||||
continue
|
||||
except ValueError:
|
||||
pass
|
||||
result._handlers[alias] = func
|
||||
except AttributeError:
|
||||
pass
|
||||
return result
|
||||
|
||||
|
||||
class command(object): # pylint: disable=too-few-public-methods
|
||||
"""Decorator for API command method"""
|
||||
def __init__(self, *aliases):
|
||||
self.aliases = aliases
|
||||
|
||||
def __call__(self, func):
|
||||
if BMConfigParser().safeGet(
|
||||
'bitmessagesettings', 'apivariant') == 'legacy':
|
||||
def wrapper(*args):
|
||||
"""
|
||||
A wrapper for legacy apivariant which dumps the result
|
||||
into string of json
|
||||
"""
|
||||
result = func(*args)
|
||||
return result if isinstance(result, (int, str)) \
|
||||
else json.dumps(result, indent=4)
|
||||
wrapper.__doc__ = func.__doc__
|
||||
else:
|
||||
wrapper = func
|
||||
# pylint: disable=protected-access
|
||||
wrapper._cmd = self.aliases
|
||||
wrapper.__doc__ = """Commands: *%s*
|
||||
|
||||
""" % ', '.join(self.aliases) + wrapper.__doc__.lstrip()
|
||||
return wrapper
|
||||
|
||||
|
||||
# This is one of several classes that constitute the API
|
||||
# This class was written by Vaibhav Bhatia.
|
||||
# Modified by Jonathan Warren (Atheros).
|
||||
# Further modified by the Bitmessage developers
|
||||
# http://code.activestate.com/recipes/501148
|
||||
class BMXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||
"""The main API handler"""
|
||||
|
||||
# pylint: disable=protected-access
|
||||
def do_POST(self):
|
||||
"""
|
||||
Handles the HTTP POST request.
|
||||
|
@ -346,8 +150,7 @@ class BMXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
Attempts to interpret all HTTP POST requests as XML-RPC calls,
|
||||
which are forwarded to the server's _dispatch method for handling.
|
||||
|
||||
.. note:: this method is the same as in
|
||||
`SimpleXMLRPCServer.SimpleXMLRPCRequestHandler`,
|
||||
Note: this method is the same as in SimpleXMLRPCRequestHandler,
|
||||
just hacked to handle cookies
|
||||
"""
|
||||
|
||||
|
@ -370,35 +173,22 @@ class BMXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
size_remaining -= len(L[-1])
|
||||
data = ''.join(L)
|
||||
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
self.cookies = []
|
||||
|
||||
validuser = self.APIAuthenticateClient()
|
||||
if not validuser:
|
||||
time.sleep(2)
|
||||
self.send_response(httplib.UNAUTHORIZED)
|
||||
self.end_headers()
|
||||
return
|
||||
# "RPC Username or password incorrect or HTTP header"
|
||||
# " lacks authentication at all."
|
||||
else:
|
||||
# In previous versions of SimpleXMLRPCServer, _dispatch
|
||||
# could be overridden in this class, instead of in
|
||||
# SimpleXMLRPCDispatcher. To maintain backwards compatibility,
|
||||
# check to see if a subclass implements _dispatch and dispatch
|
||||
# using that method if present.
|
||||
|
||||
response = self.server._marshaled_dispatch(
|
||||
response = self.server._marshaled_dispatch( # pylint: disable=protected-access
|
||||
data, getattr(self, '_dispatch', None)
|
||||
)
|
||||
except Exception: # This should only happen if the module is buggy
|
||||
except BaseException: # This should only happen if the module is buggy
|
||||
# internal error, report as HTTP server error
|
||||
self.send_response(httplib.INTERNAL_SERVER_ERROR)
|
||||
self.send_response(500)
|
||||
self.end_headers()
|
||||
else:
|
||||
# got a valid XML RPC response
|
||||
self.send_response(httplib.OK)
|
||||
self.send_header("Content-type", self.server.content_type)
|
||||
self.send_response(200)
|
||||
self.send_header("Content-type", "text/xml")
|
||||
self.send_header("Content-length", str(len(response)))
|
||||
|
||||
# HACK :start -> sends cookies here
|
||||
|
@ -419,19 +209,16 @@ class BMXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
shutdown.doCleanShutdown()
|
||||
|
||||
def APIAuthenticateClient(self):
|
||||
"""
|
||||
Predicate to check for valid API credentials in the request header
|
||||
"""
|
||||
"""Predicate to check for valid API credentials in the request header"""
|
||||
|
||||
if 'Authorization' in self.headers:
|
||||
# handle Basic authentication
|
||||
encstr = self.headers.get('Authorization').split()[1]
|
||||
_, encstr = self.headers.get('Authorization').split()
|
||||
emailid, password = encstr.decode('base64').split(':')
|
||||
return (
|
||||
emailid == BMConfigParser().get(
|
||||
'bitmessagesettings', 'apiusername'
|
||||
) and password == BMConfigParser().get(
|
||||
'bitmessagesettings', 'apipassword'))
|
||||
emailid == BMConfigParser().get('bitmessagesettings', 'apiusername') and
|
||||
password == BMConfigParser().get('bitmessagesettings', 'apipassword')
|
||||
)
|
||||
else:
|
||||
logger.warning(
|
||||
'Authentication failed because header lacks'
|
||||
|
@ -440,14 +227,7 @@ class BMXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
|
||||
return False
|
||||
|
||||
|
||||
# pylint: disable=no-self-use,no-member,too-many-public-methods
|
||||
class BMRPCDispatcher(object):
|
||||
"""This class is used to dispatch API commands"""
|
||||
__metaclass__ = CommandHandler
|
||||
|
||||
@staticmethod
|
||||
def _decode(text, decode_type):
|
||||
def _decode(self, text, decode_type):
|
||||
try:
|
||||
if decode_type == 'hex':
|
||||
return unhexlify(text)
|
||||
|
@ -455,26 +235,29 @@ class BMRPCDispatcher(object):
|
|||
return base64.b64decode(text)
|
||||
except Exception as e:
|
||||
raise APIError(
|
||||
22, 'Decode error - %s. Had trouble while decoding string: %r'
|
||||
22, "Decode error - %s. Had trouble while decoding string: %r"
|
||||
% (e, text)
|
||||
)
|
||||
return None
|
||||
|
||||
def _verifyAddress(self, address):
|
||||
status, addressVersionNumber, streamNumber, ripe = \
|
||||
decodeAddress(address)
|
||||
if status != 'success':
|
||||
logger.warning(
|
||||
'API Error 0007: Could not decode address %s. Status: %s.',
|
||||
address, status
|
||||
)
|
||||
|
||||
if status == 'checksumfailed':
|
||||
raise APIError(8, 'Checksum failed for address: ' + address)
|
||||
if status == 'invalidcharacters':
|
||||
raise APIError(9, 'Invalid characters in address: ' + address)
|
||||
if status == 'versiontoohigh':
|
||||
raise APIError(
|
||||
10, 'Address version number too high (or zero) in address: '
|
||||
+ address)
|
||||
raise APIError(10, 'Address version number too high (or zero) in address: ' + address)
|
||||
if status == 'varintmalformed':
|
||||
raise APIError(26, 'Malformed varint in address: ' + address)
|
||||
raise APIError(
|
||||
7, 'Could not decode address: %s : %s' % (address, status))
|
||||
raise APIError(7, 'Could not decode address: %s : %s' % (address, status))
|
||||
if addressVersionNumber < 2 or addressVersionNumber > 4:
|
||||
raise APIError(
|
||||
11, 'The address version number currently must be 2, 3 or 4.'
|
||||
|
@ -486,108 +269,71 @@ class BMRPCDispatcher(object):
|
|||
' Check the address.'
|
||||
)
|
||||
|
||||
return {
|
||||
'status': status,
|
||||
'addressVersion': addressVersionNumber,
|
||||
'streamNumber': streamNumber,
|
||||
'ripe': base64.b64encode(ripe)
|
||||
} if self._method == 'decodeAddress' else (
|
||||
status, addressVersionNumber, streamNumber, ripe)
|
||||
|
||||
@staticmethod
|
||||
def _dump_inbox_message( # pylint: disable=too-many-arguments
|
||||
msgid, toAddress, fromAddress, subject, received,
|
||||
message, encodingtype, read):
|
||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||
return {
|
||||
'msgid': hexlify(msgid),
|
||||
'toAddress': toAddress,
|
||||
'fromAddress': fromAddress,
|
||||
'subject': base64.b64encode(subject),
|
||||
'message': base64.b64encode(message),
|
||||
'encodingType': encodingtype,
|
||||
'receivedTime': received,
|
||||
'read': read
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def _dump_sent_message( # pylint: disable=too-many-arguments
|
||||
msgid, toAddress, fromAddress, subject, lastactiontime,
|
||||
message, encodingtype, status, ackdata):
|
||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||
return {
|
||||
'msgid': hexlify(msgid),
|
||||
'toAddress': toAddress,
|
||||
'fromAddress': fromAddress,
|
||||
'subject': base64.b64encode(subject),
|
||||
'message': base64.b64encode(message),
|
||||
'encodingType': encodingtype,
|
||||
'lastActionTime': lastactiontime,
|
||||
'status': status,
|
||||
'ackData': hexlify(ackdata)
|
||||
}
|
||||
return (status, addressVersionNumber, streamNumber, ripe)
|
||||
|
||||
# Request Handlers
|
||||
|
||||
@command('decodeAddress')
|
||||
def HandleDecodeAddress(self, address):
|
||||
"""
|
||||
Decode given address and return dict with
|
||||
status, addressVersion, streamNumber and ripe keys
|
||||
"""
|
||||
return self._verifyAddress(address)
|
||||
def HandleListAddresses(self, method):
|
||||
"""Handle a request to list addresses"""
|
||||
|
||||
@command('listAddresses', 'listAddresses2')
|
||||
def HandleListAddresses(self):
|
||||
"""
|
||||
Returns dict with a list of all used addresses with their properties
|
||||
in the *addresses* key.
|
||||
"""
|
||||
data = []
|
||||
for address in self.config.addresses():
|
||||
streamNumber = decodeAddress(address)[2]
|
||||
label = self.config.get(address, 'label')
|
||||
if self._method == 'listAddresses2':
|
||||
data = '{"addresses":['
|
||||
for addressInKeysFile in BMConfigParser().addresses():
|
||||
status, addressVersionNumber, streamNumber, hash01 = decodeAddress( # pylint: disable=unused-variable
|
||||
addressInKeysFile)
|
||||
if len(data) > 20:
|
||||
data += ','
|
||||
if BMConfigParser().has_option(addressInKeysFile, 'chan'):
|
||||
chan = BMConfigParser().getboolean(addressInKeysFile, 'chan')
|
||||
else:
|
||||
chan = False
|
||||
label = BMConfigParser().get(addressInKeysFile, 'label')
|
||||
if method == 'listAddresses2':
|
||||
label = base64.b64encode(label)
|
||||
data.append({
|
||||
data += json.dumps({
|
||||
'label': label,
|
||||
'address': address,
|
||||
'address': addressInKeysFile,
|
||||
'stream': streamNumber,
|
||||
'enabled': self.config.safeGetBoolean(address, 'enabled'),
|
||||
'chan': self.config.safeGetBoolean(address, 'chan')
|
||||
})
|
||||
return {'addresses': data}
|
||||
'enabled':
|
||||
BMConfigParser().getboolean(addressInKeysFile, 'enabled'),
|
||||
'chan': chan
|
||||
}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
|
||||
# the listAddressbook alias should be removed eventually.
|
||||
@command('listAddressBookEntries', 'legacy:listAddressbook')
|
||||
def HandleListAddressBookEntries(self, label=None):
|
||||
"""
|
||||
Returns dict with a list of all address book entries (address and label)
|
||||
in the *addresses* key.
|
||||
"""
|
||||
def HandleListAddressBookEntries(self, params):
|
||||
"""Handle a request to list address book entries"""
|
||||
|
||||
if len(params) == 1:
|
||||
label, = params
|
||||
label = self._decode(label, "base64")
|
||||
queryreturn = sqlQuery(
|
||||
"SELECT label, address from addressbook WHERE label = ?",
|
||||
label
|
||||
) if label else sqlQuery("SELECT label, address from addressbook")
|
||||
data = []
|
||||
for label, address in queryreturn:
|
||||
label)
|
||||
elif len(params) > 1:
|
||||
raise APIError(0, "Too many paremeters, max 1")
|
||||
else:
|
||||
queryreturn = sqlQuery("SELECT label, address from addressbook")
|
||||
data = '{"addresses":['
|
||||
for row in queryreturn:
|
||||
label, address = row
|
||||
label = shared.fixPotentiallyInvalidUTF8Data(label)
|
||||
data.append({
|
||||
if len(data) > 20:
|
||||
data += ','
|
||||
data += json.dumps({
|
||||
'label': base64.b64encode(label),
|
||||
'address': address
|
||||
})
|
||||
return {'addresses': data}
|
||||
'address': address}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
|
||||
# the addAddressbook alias should be deleted eventually.
|
||||
@command('addAddressBookEntry', 'legacy:addAddressbook')
|
||||
def HandleAddAddressBookEntry(self, address, label):
|
||||
"""Add an entry to address book. label must be base64 encoded."""
|
||||
def HandleAddAddressBookEntry(self, params):
|
||||
"""Handle a request to add an address book entry"""
|
||||
|
||||
if len(params) != 2:
|
||||
raise APIError(0, "I need label and address")
|
||||
address, label = params
|
||||
label = self._decode(label, "base64")
|
||||
address = addBMIfNotPresent(address)
|
||||
self._verifyAddress(address)
|
||||
# TODO: add unique together constraint in the table
|
||||
queryreturn = sqlQuery(
|
||||
"SELECT address FROM addressbook WHERE address=?", address)
|
||||
if queryreturn != []:
|
||||
|
@ -600,10 +346,12 @@ class BMRPCDispatcher(object):
|
|||
queues.UISignalQueue.put(('rerenderAddressBook', ''))
|
||||
return "Added address %s to address book" % address
|
||||
|
||||
# the deleteAddressbook alias should be deleted eventually.
|
||||
@command('deleteAddressBookEntry', 'legacy:deleteAddressbook')
|
||||
def HandleDeleteAddressBookEntry(self, address):
|
||||
"""Delete an entry from address book."""
|
||||
def HandleDeleteAddressBookEntry(self, params):
|
||||
"""Handle a request to delete an address book entry"""
|
||||
|
||||
if len(params) != 1:
|
||||
raise APIError(0, "I need an address")
|
||||
address, = params
|
||||
address = addBMIfNotPresent(address)
|
||||
self._verifyAddress(address)
|
||||
sqlExecute('DELETE FROM addressbook WHERE address=?', address)
|
||||
|
@ -612,42 +360,46 @@ class BMRPCDispatcher(object):
|
|||
queues.UISignalQueue.put(('rerenderAddressBook', ''))
|
||||
return "Deleted address book entry for %s if it existed" % address
|
||||
|
||||
@command('createRandomAddress')
|
||||
def HandleCreateRandomAddress(
|
||||
self, label, eighteenByteRipe=False, totalDifficulty=0,
|
||||
smallMessageDifficulty=0
|
||||
):
|
||||
"""
|
||||
Create one address using the random number generator.
|
||||
def HandleCreateRandomAddress(self, params):
|
||||
"""Handle a request to create a random address"""
|
||||
|
||||
:param str label: base64 encoded label for the address
|
||||
:param bool eighteenByteRipe: is telling Bitmessage whether to
|
||||
generate an address with an 18 byte RIPE hash
|
||||
(as opposed to a 19 byte hash).
|
||||
"""
|
||||
if not params:
|
||||
raise APIError(0, 'I need parameters!')
|
||||
|
||||
nonceTrialsPerByte = self.config.get(
|
||||
'bitmessagesettings', 'defaultnoncetrialsperbyte'
|
||||
) if not totalDifficulty else int(
|
||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte
|
||||
* totalDifficulty)
|
||||
payloadLengthExtraBytes = self.config.get(
|
||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes'
|
||||
) if not smallMessageDifficulty else int(
|
||||
defaults.networkDefaultPayloadLengthExtraBytes
|
||||
* smallMessageDifficulty)
|
||||
|
||||
if not isinstance(eighteenByteRipe, bool):
|
||||
raise APIError(
|
||||
23, 'Bool expected in eighteenByteRipe, saw %s instead'
|
||||
% type(eighteenByteRipe))
|
||||
elif len(params) == 1:
|
||||
label, = params
|
||||
eighteenByteRipe = False
|
||||
nonceTrialsPerByte = BMConfigParser().get(
|
||||
'bitmessagesettings', 'defaultnoncetrialsperbyte')
|
||||
payloadLengthExtraBytes = BMConfigParser().get(
|
||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
||||
elif len(params) == 2:
|
||||
label, eighteenByteRipe = params
|
||||
nonceTrialsPerByte = BMConfigParser().get(
|
||||
'bitmessagesettings', 'defaultnoncetrialsperbyte')
|
||||
payloadLengthExtraBytes = BMConfigParser().get(
|
||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
||||
elif len(params) == 3:
|
||||
label, eighteenByteRipe, totalDifficulty = params
|
||||
nonceTrialsPerByte = int(
|
||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty)
|
||||
payloadLengthExtraBytes = BMConfigParser().get(
|
||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
||||
elif len(params) == 4:
|
||||
label, eighteenByteRipe, totalDifficulty, \
|
||||
smallMessageDifficulty = params
|
||||
nonceTrialsPerByte = int(
|
||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty)
|
||||
payloadLengthExtraBytes = int(
|
||||
defaults.networkDefaultPayloadLengthExtraBytes * smallMessageDifficulty)
|
||||
else:
|
||||
raise APIError(0, 'Too many parameters!')
|
||||
label = self._decode(label, "base64")
|
||||
try:
|
||||
unicode(label, 'utf-8')
|
||||
except UnicodeDecodeError:
|
||||
except BaseException:
|
||||
raise APIError(17, 'Label is not valid UTF-8 data.')
|
||||
queues.apiAddressGeneratorReturnQueue.queue.clear()
|
||||
# FIXME hard coded stream no
|
||||
streamNumberForAddress = 1
|
||||
queues.addressGeneratorQueue.put((
|
||||
'createRandomAddress', 4, streamNumberForAddress, label, 1, "",
|
||||
|
@ -655,53 +407,94 @@ class BMRPCDispatcher(object):
|
|||
))
|
||||
return queues.apiAddressGeneratorReturnQueue.get()
|
||||
|
||||
# pylint: disable=too-many-arguments
|
||||
@command('createDeterministicAddresses')
|
||||
def HandleCreateDeterministicAddresses(
|
||||
self, passphrase, numberOfAddresses=1, addressVersionNumber=0,
|
||||
streamNumber=0, eighteenByteRipe=False, totalDifficulty=0,
|
||||
smallMessageDifficulty=0
|
||||
):
|
||||
"""
|
||||
Create many addresses deterministically using the passphrase.
|
||||
def HandleCreateDeterministicAddresses(self, params):
|
||||
"""Handle a request to create a deterministic address"""
|
||||
|
||||
:param str passphrase: base64 encoded passphrase
|
||||
:param int numberOfAddresses: number of addresses to create,
|
||||
up to 999
|
||||
if not params:
|
||||
raise APIError(0, 'I need parameters!')
|
||||
|
||||
*addressVersionNumber* and *streamNumber* may be set to 0
|
||||
which will tell Bitmessage to use the most up-to-date
|
||||
address version and the most available stream.
|
||||
"""
|
||||
elif len(params) == 1:
|
||||
passphrase, = params
|
||||
numberOfAddresses = 1
|
||||
addressVersionNumber = 0
|
||||
streamNumber = 0
|
||||
eighteenByteRipe = False
|
||||
nonceTrialsPerByte = BMConfigParser().get(
|
||||
'bitmessagesettings', 'defaultnoncetrialsperbyte')
|
||||
payloadLengthExtraBytes = BMConfigParser().get(
|
||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
||||
|
||||
nonceTrialsPerByte = self.config.get(
|
||||
'bitmessagesettings', 'defaultnoncetrialsperbyte'
|
||||
) if not totalDifficulty else int(
|
||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte
|
||||
* totalDifficulty)
|
||||
payloadLengthExtraBytes = self.config.get(
|
||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes'
|
||||
) if not smallMessageDifficulty else int(
|
||||
defaults.networkDefaultPayloadLengthExtraBytes
|
||||
* smallMessageDifficulty)
|
||||
elif len(params) == 2:
|
||||
passphrase, numberOfAddresses = params
|
||||
addressVersionNumber = 0
|
||||
streamNumber = 0
|
||||
eighteenByteRipe = False
|
||||
nonceTrialsPerByte = BMConfigParser().get(
|
||||
'bitmessagesettings', 'defaultnoncetrialsperbyte')
|
||||
payloadLengthExtraBytes = BMConfigParser().get(
|
||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
||||
|
||||
elif len(params) == 3:
|
||||
passphrase, numberOfAddresses, addressVersionNumber = params
|
||||
streamNumber = 0
|
||||
eighteenByteRipe = False
|
||||
nonceTrialsPerByte = BMConfigParser().get(
|
||||
'bitmessagesettings', 'defaultnoncetrialsperbyte')
|
||||
payloadLengthExtraBytes = BMConfigParser().get(
|
||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
||||
|
||||
elif len(params) == 4:
|
||||
passphrase, numberOfAddresses, addressVersionNumber, \
|
||||
streamNumber = params
|
||||
eighteenByteRipe = False
|
||||
nonceTrialsPerByte = BMConfigParser().get(
|
||||
'bitmessagesettings', 'defaultnoncetrialsperbyte')
|
||||
payloadLengthExtraBytes = BMConfigParser().get(
|
||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
||||
|
||||
elif len(params) == 5:
|
||||
passphrase, numberOfAddresses, addressVersionNumber, \
|
||||
streamNumber, eighteenByteRipe = params
|
||||
nonceTrialsPerByte = BMConfigParser().get(
|
||||
'bitmessagesettings', 'defaultnoncetrialsperbyte')
|
||||
payloadLengthExtraBytes = BMConfigParser().get(
|
||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
||||
|
||||
elif len(params) == 6:
|
||||
passphrase, numberOfAddresses, addressVersionNumber, \
|
||||
streamNumber, eighteenByteRipe, totalDifficulty = params
|
||||
nonceTrialsPerByte = int(
|
||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty)
|
||||
payloadLengthExtraBytes = BMConfigParser().get(
|
||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
||||
|
||||
elif len(params) == 7:
|
||||
passphrase, numberOfAddresses, addressVersionNumber, \
|
||||
streamNumber, eighteenByteRipe, totalDifficulty, \
|
||||
smallMessageDifficulty = params
|
||||
nonceTrialsPerByte = int(
|
||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty)
|
||||
payloadLengthExtraBytes = int(
|
||||
defaults.networkDefaultPayloadLengthExtraBytes * smallMessageDifficulty)
|
||||
else:
|
||||
raise APIError(0, 'Too many parameters!')
|
||||
if not passphrase:
|
||||
raise APIError(1, 'The specified passphrase is blank.')
|
||||
if not isinstance(eighteenByteRipe, bool):
|
||||
raise APIError(
|
||||
23, 'Bool expected in eighteenByteRipe, saw %s instead'
|
||||
% type(eighteenByteRipe))
|
||||
23, 'Bool expected in eighteenByteRipe, saw %s instead' %
|
||||
type(eighteenByteRipe))
|
||||
passphrase = self._decode(passphrase, "base64")
|
||||
# 0 means "just use the proper addressVersionNumber"
|
||||
if addressVersionNumber == 0:
|
||||
addressVersionNumber = 4
|
||||
if addressVersionNumber not in (3, 4):
|
||||
if addressVersionNumber != 3 and addressVersionNumber != 4:
|
||||
raise APIError(
|
||||
2, 'The address version number currently must be 3, 4, or 0'
|
||||
' (which means auto-select). %i isn\'t supported.'
|
||||
% addressVersionNumber)
|
||||
' (which means auto-select). %i isn\'t supported.' %
|
||||
addressVersionNumber)
|
||||
if streamNumber == 0: # 0 means "just use the most available stream"
|
||||
streamNumber = 1 # FIXME hard coded stream no
|
||||
streamNumber = 1
|
||||
if streamNumber != 1:
|
||||
raise APIError(
|
||||
3, 'The stream number must be 1 (or 0 which means'
|
||||
|
@ -726,24 +519,27 @@ class BMRPCDispatcher(object):
|
|||
'unused API address', numberOfAddresses, passphrase,
|
||||
eighteenByteRipe, nonceTrialsPerByte, payloadLengthExtraBytes
|
||||
))
|
||||
data = '{"addresses":['
|
||||
queueReturn = queues.apiAddressGeneratorReturnQueue.get()
|
||||
for item in queueReturn:
|
||||
if len(data) > 20:
|
||||
data += ','
|
||||
data += "\"" + item + "\""
|
||||
data += ']}'
|
||||
return data
|
||||
|
||||
return {'addresses': queues.apiAddressGeneratorReturnQueue.get()}
|
||||
|
||||
@command('getDeterministicAddress')
|
||||
def HandleGetDeterministicAddress(
|
||||
self, passphrase, addressVersionNumber, streamNumber):
|
||||
"""
|
||||
Similar to *createDeterministicAddresses* except that the one
|
||||
address that is returned will not be added to the Bitmessage
|
||||
user interface or the keys.dat file.
|
||||
"""
|
||||
def HandleGetDeterministicAddress(self, params):
|
||||
"""Handle a request to get a deterministic address"""
|
||||
|
||||
if len(params) != 3:
|
||||
raise APIError(0, 'I need exactly 3 parameters.')
|
||||
passphrase, addressVersionNumber, streamNumber = params
|
||||
numberOfAddresses = 1
|
||||
eighteenByteRipe = False
|
||||
if not passphrase:
|
||||
raise APIError(1, 'The specified passphrase is blank.')
|
||||
passphrase = self._decode(passphrase, "base64")
|
||||
if addressVersionNumber not in (3, 4):
|
||||
if addressVersionNumber != 3 and addressVersionNumber != 4:
|
||||
raise APIError(
|
||||
2, 'The address version number currently must be 3 or 4. %i'
|
||||
' isn\'t supported.' % addressVersionNumber)
|
||||
|
@ -761,14 +557,16 @@ class BMRPCDispatcher(object):
|
|||
))
|
||||
return queues.apiAddressGeneratorReturnQueue.get()
|
||||
|
||||
@command('createChan')
|
||||
def HandleCreateChan(self, passphrase):
|
||||
"""
|
||||
Creates a new chan. passphrase must be base64 encoded.
|
||||
Returns the corresponding Bitmessage address.
|
||||
"""
|
||||
def HandleCreateChan(self, params):
|
||||
"""Handle a request to create a chan"""
|
||||
|
||||
if not params:
|
||||
raise APIError(0, 'I need parameters.')
|
||||
|
||||
elif len(params) == 1:
|
||||
passphrase, = params
|
||||
passphrase = self._decode(passphrase, "base64")
|
||||
|
||||
if not passphrase:
|
||||
raise APIError(1, 'The specified passphrase is blank.')
|
||||
# It would be nice to make the label the passphrase but it is
|
||||
|
@ -776,7 +574,7 @@ class BMRPCDispatcher(object):
|
|||
try:
|
||||
unicode(passphrase, 'utf-8')
|
||||
label = str_chan + ' ' + passphrase
|
||||
except UnicodeDecodeError:
|
||||
except BaseException:
|
||||
label = str_chan + ' ' + repr(passphrase)
|
||||
|
||||
addressVersionNumber = 4
|
||||
|
@ -789,17 +587,18 @@ class BMRPCDispatcher(object):
|
|||
passphrase, True
|
||||
))
|
||||
queueReturn = queues.apiAddressGeneratorReturnQueue.get()
|
||||
try:
|
||||
return queueReturn[0]
|
||||
except IndexError:
|
||||
if not queueReturn:
|
||||
raise APIError(24, 'Chan address is already present.')
|
||||
address = queueReturn[0]
|
||||
return address
|
||||
|
||||
@command('joinChan')
|
||||
def HandleJoinChan(self, passphrase, suppliedAddress):
|
||||
"""
|
||||
Join a chan. passphrase must be base64 encoded. Returns 'success'.
|
||||
"""
|
||||
def HandleJoinChan(self, params):
|
||||
"""Handle a request to join a chan"""
|
||||
|
||||
if len(params) < 2:
|
||||
raise APIError(0, 'I need two parameters.')
|
||||
elif len(params) == 2:
|
||||
passphrase, suppliedAddress = params
|
||||
passphrase = self._decode(passphrase, "base64")
|
||||
if not passphrase:
|
||||
raise APIError(1, 'The specified passphrase is blank.')
|
||||
|
@ -808,287 +607,374 @@ class BMRPCDispatcher(object):
|
|||
try:
|
||||
unicode(passphrase, 'utf-8')
|
||||
label = str_chan + ' ' + passphrase
|
||||
except UnicodeDecodeError:
|
||||
except BaseException:
|
||||
label = str_chan + ' ' + repr(passphrase)
|
||||
|
||||
self._verifyAddress(suppliedAddress)
|
||||
status, addressVersionNumber, streamNumber, toRipe = self._verifyAddress( # pylint: disable=unused-variable
|
||||
suppliedAddress)
|
||||
suppliedAddress = addBMIfNotPresent(suppliedAddress)
|
||||
queues.apiAddressGeneratorReturnQueue.queue.clear()
|
||||
queues.addressGeneratorQueue.put((
|
||||
'joinChan', suppliedAddress, label, passphrase, True
|
||||
))
|
||||
queueReturn = queues.apiAddressGeneratorReturnQueue.get()
|
||||
try:
|
||||
if queueReturn[0] == 'chan name does not match address':
|
||||
raise APIError(18, 'Chan name does not match address.')
|
||||
except IndexError:
|
||||
raise APIError(24, 'Chan address is already present.')
|
||||
addressGeneratorReturnValue = \
|
||||
queues.apiAddressGeneratorReturnQueue.get()
|
||||
|
||||
if addressGeneratorReturnValue[0] == \
|
||||
'chan name does not match address':
|
||||
raise APIError(18, 'Chan name does not match address.')
|
||||
if not addressGeneratorReturnValue:
|
||||
raise APIError(24, 'Chan address is already present.')
|
||||
return "success"
|
||||
|
||||
@command('leaveChan')
|
||||
def HandleLeaveChan(self, address):
|
||||
"""
|
||||
Leave a chan. Returns 'success'.
|
||||
def HandleLeaveChan(self, params):
|
||||
"""Handle a request to leave a chan"""
|
||||
|
||||
.. note:: at this time, the address is still shown in the UI
|
||||
until a restart.
|
||||
"""
|
||||
self._verifyAddress(address)
|
||||
if not params:
|
||||
raise APIError(0, 'I need parameters.')
|
||||
elif len(params) == 1:
|
||||
address, = params
|
||||
# pylint: disable=unused-variable
|
||||
status, addressVersionNumber, streamNumber, toRipe = self._verifyAddress(address)
|
||||
address = addBMIfNotPresent(address)
|
||||
if not self.config.safeGetBoolean(address, 'chan'):
|
||||
if not BMConfigParser().has_section(address):
|
||||
raise APIError(
|
||||
13, 'Could not find this address in your keys.dat file.')
|
||||
if not BMConfigParser().safeGetBoolean(address, 'chan'):
|
||||
raise APIError(
|
||||
25, 'Specified address is not a chan address.'
|
||||
' Use deleteAddress API call instead.')
|
||||
try:
|
||||
self.config.remove_section(address)
|
||||
except ConfigParser.NoSectionError:
|
||||
raise APIError(
|
||||
13, 'Could not find this address in your keys.dat file.')
|
||||
self.config.save()
|
||||
queues.UISignalQueue.put(('rerenderMessagelistFromLabels', ''))
|
||||
queues.UISignalQueue.put(('rerenderMessagelistToLabels', ''))
|
||||
return "success"
|
||||
BMConfigParser().remove_section(address)
|
||||
with open(state.appdata + 'keys.dat', 'wb') as configfile:
|
||||
BMConfigParser().write(configfile)
|
||||
return 'success'
|
||||
|
||||
@command('deleteAddress')
|
||||
def HandleDeleteAddress(self, address):
|
||||
"""
|
||||
Permanently delete the address from keys.dat file. Returns 'success'.
|
||||
"""
|
||||
self._verifyAddress(address)
|
||||
def HandleDeleteAddress(self, params):
|
||||
"""Handle a request to delete an address"""
|
||||
|
||||
if not params:
|
||||
raise APIError(0, 'I need parameters.')
|
||||
elif len(params) == 1:
|
||||
address, = params
|
||||
# pylint: disable=unused-variable
|
||||
status, addressVersionNumber, streamNumber, toRipe = self._verifyAddress(address)
|
||||
address = addBMIfNotPresent(address)
|
||||
try:
|
||||
self.config.remove_section(address)
|
||||
except ConfigParser.NoSectionError:
|
||||
if not BMConfigParser().has_section(address):
|
||||
raise APIError(
|
||||
13, 'Could not find this address in your keys.dat file.')
|
||||
self.config.save()
|
||||
BMConfigParser().remove_section(address)
|
||||
with open(state.appdata + 'keys.dat', 'wb') as configfile:
|
||||
BMConfigParser().write(configfile)
|
||||
queues.UISignalQueue.put(('writeNewAddressToTable', ('', '', '')))
|
||||
shared.reloadMyAddressHashes()
|
||||
return "success"
|
||||
return 'success'
|
||||
|
||||
@command('getAllInboxMessages')
|
||||
def HandleGetAllInboxMessages(self):
|
||||
"""
|
||||
Returns a dict with all inbox messages in the *inboxMessages* key.
|
||||
The message is a dict with such keys:
|
||||
*msgid*, *toAddress*, *fromAddress*, *subject*, *message*,
|
||||
*encodingType*, *receivedTime*, *read*.
|
||||
*msgid* is hex encoded string.
|
||||
*subject* and *message* are base64 encoded.
|
||||
"""
|
||||
def HandleGetAllInboxMessages(self, params): # pylint: disable=unused-argument
|
||||
"""Handle a request to get all inbox messages"""
|
||||
|
||||
queryreturn = sqlQuery(
|
||||
"SELECT msgid, toaddress, fromaddress, subject, received, message,"
|
||||
" encodingtype, read FROM inbox WHERE folder='inbox'"
|
||||
" encodingtype, read FROM inbox where folder='inbox'"
|
||||
" ORDER BY received"
|
||||
)
|
||||
return {"inboxMessages": [
|
||||
self._dump_inbox_message(*data) for data in queryreturn
|
||||
]}
|
||||
data = '{"inboxMessages":['
|
||||
for row in queryreturn:
|
||||
msgid, toAddress, fromAddress, subject, received, message, \
|
||||
encodingtype, read = row
|
||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||
if len(data) > 25:
|
||||
data += ','
|
||||
data += json.dumps({
|
||||
'msgid': hexlify(msgid),
|
||||
'toAddress': toAddress,
|
||||
'fromAddress': fromAddress,
|
||||
'subject': base64.b64encode(subject),
|
||||
'message': base64.b64encode(message),
|
||||
'encodingType': encodingtype,
|
||||
'receivedTime': received,
|
||||
'read': read}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
|
||||
@command('getAllInboxMessageIds', 'getAllInboxMessageIDs')
|
||||
def HandleGetAllInboxMessageIds(self):
|
||||
"""
|
||||
The same as *getAllInboxMessages* but returns only *msgid*s,
|
||||
result key - *inboxMessageIds*.
|
||||
"""
|
||||
def HandleGetAllInboxMessageIds(self, params): # pylint: disable=unused-argument
|
||||
"""Handle a request to get all inbox message IDs"""
|
||||
|
||||
queryreturn = sqlQuery(
|
||||
"SELECT msgid FROM inbox where folder='inbox' ORDER BY received")
|
||||
data = '{"inboxMessageIds":['
|
||||
for row in queryreturn:
|
||||
msgid = row[0]
|
||||
if len(data) > 25:
|
||||
data += ','
|
||||
data += json.dumps(
|
||||
{'msgid': hexlify(msgid)}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
|
||||
return {"inboxMessageIds": [
|
||||
{'msgid': hexlify(msgid)} for msgid, in queryreturn
|
||||
]}
|
||||
def HandleGetInboxMessageById(self, params):
|
||||
"""Handle a request to get an inbox messsage by ID"""
|
||||
|
||||
@command('getInboxMessageById', 'getInboxMessageByID')
|
||||
def HandleGetInboxMessageById(self, hid, readStatus=None):
|
||||
"""
|
||||
Returns a dict with list containing single message in the result
|
||||
key *inboxMessage*. May also return None if message was not found.
|
||||
|
||||
:param str hid: hex encoded msgid
|
||||
:param bool readStatus: sets the message's read status if present
|
||||
"""
|
||||
|
||||
msgid = self._decode(hid, "hex")
|
||||
if readStatus is not None:
|
||||
if not params:
|
||||
raise APIError(0, 'I need parameters!')
|
||||
elif len(params) == 1:
|
||||
msgid = self._decode(params[0], "hex")
|
||||
elif len(params) >= 2:
|
||||
msgid = self._decode(params[0], "hex")
|
||||
readStatus = params[1]
|
||||
if not isinstance(readStatus, bool):
|
||||
raise APIError(
|
||||
23, 'Bool expected in readStatus, saw %s instead.'
|
||||
% type(readStatus))
|
||||
23, 'Bool expected in readStatus, saw %s instead.' %
|
||||
type(readStatus))
|
||||
queryreturn = sqlQuery(
|
||||
"SELECT read FROM inbox WHERE msgid=?", msgid)
|
||||
# UPDATE is slow, only update if status is different
|
||||
try:
|
||||
if (queryreturn[0][0] == 1) != readStatus:
|
||||
if queryreturn != [] and (queryreturn[0][0] == 1) != readStatus:
|
||||
sqlExecute(
|
||||
"UPDATE inbox set read = ? WHERE msgid=?",
|
||||
readStatus, msgid)
|
||||
queues.UISignalQueue.put(('changedInboxUnread', None))
|
||||
except IndexError:
|
||||
pass
|
||||
queryreturn = sqlQuery(
|
||||
"SELECT msgid, toaddress, fromaddress, subject, received, message,"
|
||||
" encodingtype, read FROM inbox WHERE msgid=?", msgid
|
||||
)
|
||||
try:
|
||||
return {"inboxMessage": [
|
||||
self._dump_inbox_message(*queryreturn[0])]}
|
||||
except IndexError:
|
||||
pass # FIXME inconsistent
|
||||
data = '{"inboxMessage":['
|
||||
for row in queryreturn:
|
||||
msgid, toAddress, fromAddress, subject, received, message, \
|
||||
encodingtype, read = row
|
||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||
data += json.dumps({
|
||||
'msgid': hexlify(msgid),
|
||||
'toAddress': toAddress,
|
||||
'fromAddress': fromAddress,
|
||||
'subject': base64.b64encode(subject),
|
||||
'message': base64.b64encode(message),
|
||||
'encodingType': encodingtype,
|
||||
'receivedTime': received,
|
||||
'read': read}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
|
||||
@command('getAllSentMessages')
|
||||
def HandleGetAllSentMessages(self):
|
||||
"""
|
||||
The same as *getAllInboxMessages* but for sent,
|
||||
result key - *sentMessages*. Message dict keys are:
|
||||
*msgid*, *toAddress*, *fromAddress*, *subject*, *message*,
|
||||
*encodingType*, *lastActionTime*, *status*, *ackData*.
|
||||
*ackData* is also a hex encoded string.
|
||||
"""
|
||||
def HandleGetAllSentMessages(self, params): # pylint: disable=unused-argument
|
||||
"""Handle a request to get all sent messages"""
|
||||
|
||||
queryreturn = sqlQuery(
|
||||
"SELECT msgid, toaddress, fromaddress, subject, lastactiontime,"
|
||||
" message, encodingtype, status, ackdata FROM sent"
|
||||
" WHERE folder='sent' ORDER BY lastactiontime"
|
||||
)
|
||||
return {"sentMessages": [
|
||||
self._dump_sent_message(*data) for data in queryreturn
|
||||
]}
|
||||
data = '{"sentMessages":['
|
||||
for row in queryreturn:
|
||||
msgid, toAddress, fromAddress, subject, lastactiontime, message, \
|
||||
encodingtype, status, ackdata = row
|
||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||
if len(data) > 25:
|
||||
data += ','
|
||||
data += json.dumps({
|
||||
'msgid': hexlify(msgid),
|
||||
'toAddress': toAddress,
|
||||
'fromAddress': fromAddress,
|
||||
'subject': base64.b64encode(subject),
|
||||
'message': base64.b64encode(message),
|
||||
'encodingType': encodingtype,
|
||||
'lastActionTime': lastactiontime,
|
||||
'status': status,
|
||||
'ackData': hexlify(ackdata)}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
|
||||
@command('getAllSentMessageIds', 'getAllSentMessageIDs')
|
||||
def HandleGetAllSentMessageIds(self):
|
||||
"""
|
||||
The same as *getAllInboxMessageIds* but for sent,
|
||||
result key - *sentMessageIds*.
|
||||
"""
|
||||
def HandleGetAllSentMessageIds(self, params): # pylint: disable=unused-argument
|
||||
"""Handle a request to get all sent message IDs"""
|
||||
|
||||
queryreturn = sqlQuery(
|
||||
"SELECT msgid FROM sent WHERE folder='sent'"
|
||||
"SELECT msgid FROM sent where folder='sent'"
|
||||
" ORDER BY lastactiontime"
|
||||
)
|
||||
return {"sentMessageIds": [
|
||||
{'msgid': hexlify(msgid)} for msgid, in queryreturn
|
||||
]}
|
||||
data = '{"sentMessageIds":['
|
||||
for row in queryreturn:
|
||||
msgid = row[0]
|
||||
if len(data) > 25:
|
||||
data += ','
|
||||
data += json.dumps(
|
||||
{'msgid': hexlify(msgid)}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
|
||||
# after some time getInboxMessagesByAddress should be removed
|
||||
@command('getInboxMessagesByReceiver', 'legacy:getInboxMessagesByAddress')
|
||||
def HandleInboxMessagesByReceiver(self, toAddress):
|
||||
"""
|
||||
The same as *getAllInboxMessages* but returns only messages
|
||||
for toAddress.
|
||||
"""
|
||||
def HandleInboxMessagesByReceiver(self, params):
|
||||
"""Handle a request to get inbox messages by receiver"""
|
||||
|
||||
if not params:
|
||||
raise APIError(0, 'I need parameters!')
|
||||
toAddress = params[0]
|
||||
queryreturn = sqlQuery(
|
||||
"SELECT msgid, toaddress, fromaddress, subject, received,"
|
||||
" message, encodingtype, read FROM inbox WHERE folder='inbox'"
|
||||
" AND toAddress=?", toAddress)
|
||||
return {"inboxMessages": [
|
||||
self._dump_inbox_message(*data) for data in queryreturn
|
||||
]}
|
||||
"SELECT msgid, toaddress, fromaddress, subject, received, message,"
|
||||
" encodingtype FROM inbox WHERE folder='inbox' AND toAddress=?",
|
||||
toAddress)
|
||||
data = '{"inboxMessages":['
|
||||
for row in queryreturn:
|
||||
msgid, toAddress, fromAddress, subject, received, message, \
|
||||
encodingtype = row
|
||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||
if len(data) > 25:
|
||||
data += ','
|
||||
data += json.dumps({
|
||||
'msgid': hexlify(msgid),
|
||||
'toAddress': toAddress,
|
||||
'fromAddress': fromAddress,
|
||||
'subject': base64.b64encode(subject),
|
||||
'message': base64.b64encode(message),
|
||||
'encodingType': encodingtype,
|
||||
'receivedTime': received}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
|
||||
@command('getSentMessageById', 'getSentMessageByID')
|
||||
def HandleGetSentMessageById(self, hid):
|
||||
"""
|
||||
Similiar to *getInboxMessageById* but doesn't change message's
|
||||
read status (sent messages have no such field).
|
||||
Result key is *sentMessage*
|
||||
"""
|
||||
def HandleGetSentMessageById(self, params):
|
||||
"""Handle a request to get a sent message by ID"""
|
||||
|
||||
msgid = self._decode(hid, "hex")
|
||||
if not params:
|
||||
raise APIError(0, 'I need parameters!')
|
||||
msgid = self._decode(params[0], "hex")
|
||||
queryreturn = sqlQuery(
|
||||
"SELECT msgid, toaddress, fromaddress, subject, lastactiontime,"
|
||||
" message, encodingtype, status, ackdata FROM sent WHERE msgid=?",
|
||||
msgid
|
||||
)
|
||||
try:
|
||||
return {"sentMessage": [
|
||||
self._dump_sent_message(*queryreturn[0])
|
||||
]}
|
||||
except IndexError:
|
||||
pass # FIXME inconsistent
|
||||
data = '{"sentMessage":['
|
||||
for row in queryreturn:
|
||||
msgid, toAddress, fromAddress, subject, lastactiontime, message, \
|
||||
encodingtype, status, ackdata = row
|
||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||
data += json.dumps({
|
||||
'msgid': hexlify(msgid),
|
||||
'toAddress': toAddress,
|
||||
'fromAddress': fromAddress,
|
||||
'subject': base64.b64encode(subject),
|
||||
'message': base64.b64encode(message),
|
||||
'encodingType': encodingtype,
|
||||
'lastActionTime': lastactiontime,
|
||||
'status': status,
|
||||
'ackData': hexlify(ackdata)}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
|
||||
@command('getSentMessagesByAddress', 'getSentMessagesBySender')
|
||||
def HandleGetSentMessagesByAddress(self, fromAddress):
|
||||
"""
|
||||
The same as *getAllSentMessages* but returns only messages
|
||||
from fromAddress.
|
||||
"""
|
||||
def HandleGetSentMessagesByAddress(self, params):
|
||||
"""Handle a request to get sent messages by address"""
|
||||
|
||||
if not params:
|
||||
raise APIError(0, 'I need parameters!')
|
||||
fromAddress = params[0]
|
||||
queryreturn = sqlQuery(
|
||||
"SELECT msgid, toaddress, fromaddress, subject, lastactiontime,"
|
||||
" message, encodingtype, status, ackdata FROM sent"
|
||||
" WHERE folder='sent' AND fromAddress=? ORDER BY lastactiontime",
|
||||
fromAddress
|
||||
)
|
||||
return {"sentMessages": [
|
||||
self._dump_sent_message(*data) for data in queryreturn
|
||||
]}
|
||||
data = '{"sentMessages":['
|
||||
for row in queryreturn:
|
||||
msgid, toAddress, fromAddress, subject, lastactiontime, message, \
|
||||
encodingtype, status, ackdata = row # pylint: disable=unused-variable
|
||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||
if len(data) > 25:
|
||||
data += ','
|
||||
data += json.dumps({
|
||||
'msgid': hexlify(msgid),
|
||||
'toAddress': toAddress,
|
||||
'fromAddress': fromAddress,
|
||||
'subject': base64.b64encode(subject),
|
||||
'message': base64.b64encode(message),
|
||||
'encodingType': encodingtype,
|
||||
'lastActionTime': lastactiontime,
|
||||
'status': status,
|
||||
'ackData': hexlify(ackdata)}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
|
||||
@command('getSentMessageByAckData')
|
||||
def HandleGetSentMessagesByAckData(self, ackData):
|
||||
"""
|
||||
Similiar to *getSentMessageById* but searches by ackdata
|
||||
(also hex encoded).
|
||||
"""
|
||||
def HandleGetSentMessagesByAckData(self, params):
|
||||
"""Handle a request to get sent messages by ack data"""
|
||||
|
||||
ackData = self._decode(ackData, "hex")
|
||||
if not params:
|
||||
raise APIError(0, 'I need parameters!')
|
||||
ackData = self._decode(params[0], "hex")
|
||||
queryreturn = sqlQuery(
|
||||
"SELECT msgid, toaddress, fromaddress, subject, lastactiontime,"
|
||||
" message, encodingtype, status, ackdata FROM sent"
|
||||
" WHERE ackdata=?", ackData
|
||||
)
|
||||
data = '{"sentMessage":['
|
||||
for row in queryreturn:
|
||||
msgid, toAddress, fromAddress, subject, lastactiontime, message, \
|
||||
encodingtype, status, ackdata = row
|
||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||
data += json.dumps({
|
||||
'msgid': hexlify(msgid),
|
||||
'toAddress': toAddress,
|
||||
'fromAddress': fromAddress,
|
||||
'subject': base64.b64encode(subject),
|
||||
'message': base64.b64encode(message),
|
||||
'encodingType': encodingtype,
|
||||
'lastActionTime': lastactiontime,
|
||||
'status': status,
|
||||
'ackData': hexlify(ackdata)}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
|
||||
try:
|
||||
return {"sentMessage": [
|
||||
self._dump_sent_message(*queryreturn[0])
|
||||
]}
|
||||
except IndexError:
|
||||
pass # FIXME inconsistent
|
||||
def HandleTrashMessage(self, params):
|
||||
"""Handle a request to trash a message by ID"""
|
||||
|
||||
if not params:
|
||||
raise APIError(0, 'I need parameters!')
|
||||
msgid = self._decode(params[0], "hex")
|
||||
|
||||
@command('trashMessage')
|
||||
def HandleTrashMessage(self, msgid):
|
||||
"""
|
||||
Trash message by msgid (encoded in hex). Returns a simple message
|
||||
saying that the message was trashed assuming it ever even existed.
|
||||
Prior existence is not checked.
|
||||
"""
|
||||
msgid = self._decode(msgid, "hex")
|
||||
# Trash if in inbox table
|
||||
helper_inbox.trash(msgid)
|
||||
# Trash if in sent table
|
||||
sqlExecute("UPDATE sent SET folder='trash' WHERE msgid=?", msgid)
|
||||
sqlExecute('''UPDATE sent SET folder='trash' WHERE msgid=?''', msgid)
|
||||
return 'Trashed message (assuming message existed).'
|
||||
|
||||
@command('trashInboxMessage')
|
||||
def HandleTrashInboxMessage(self, msgid):
|
||||
"""Trash inbox message by msgid (encoded in hex)."""
|
||||
msgid = self._decode(msgid, "hex")
|
||||
def HandleTrashInboxMessage(self, params):
|
||||
"""Handle a request to trash an inbox message by ID"""
|
||||
|
||||
if not params:
|
||||
raise APIError(0, 'I need parameters!')
|
||||
msgid = self._decode(params[0], "hex")
|
||||
helper_inbox.trash(msgid)
|
||||
return 'Trashed inbox message (assuming message existed).'
|
||||
|
||||
@command('trashSentMessage')
|
||||
def HandleTrashSentMessage(self, msgid):
|
||||
"""Trash sent message by msgid (encoded in hex)."""
|
||||
msgid = self._decode(msgid, "hex")
|
||||
def HandleTrashSentMessage(self, params):
|
||||
"""Handle a request to trash a sent message by ID"""
|
||||
|
||||
if not params:
|
||||
raise APIError(0, 'I need parameters!')
|
||||
msgid = self._decode(params[0], "hex")
|
||||
sqlExecute('''UPDATE sent SET folder='trash' WHERE msgid=?''', msgid)
|
||||
return 'Trashed sent message (assuming message existed).'
|
||||
|
||||
@command('sendMessage')
|
||||
def HandleSendMessage(
|
||||
self, toAddress, fromAddress, subject, message,
|
||||
encodingType=2, TTL=4 * 24 * 60 * 60
|
||||
):
|
||||
"""
|
||||
Send the message and return ackdata (hex encoded string).
|
||||
subject and message must be encoded in base64 which may optionally
|
||||
include line breaks. TTL is specified in seconds; values outside
|
||||
the bounds of 3600 to 2419200 will be moved to be within those
|
||||
bounds. TTL defaults to 4 days.
|
||||
"""
|
||||
# pylint: disable=too-many-locals
|
||||
if encodingType not in (2, 3):
|
||||
def HandleSendMessage(self, params):
|
||||
"""Handle a request to send a message"""
|
||||
|
||||
if not params:
|
||||
raise APIError(0, 'I need parameters!')
|
||||
|
||||
elif len(params) == 4:
|
||||
toAddress, fromAddress, subject, message = params
|
||||
encodingType = 2
|
||||
TTL = 4 * 24 * 60 * 60
|
||||
|
||||
elif len(params) == 5:
|
||||
toAddress, fromAddress, subject, message, encodingType = params
|
||||
TTL = 4 * 24 * 60 * 60
|
||||
|
||||
elif len(params) == 6:
|
||||
toAddress, fromAddress, subject, message, encodingType, TTL = \
|
||||
params
|
||||
|
||||
if encodingType not in [2, 3]:
|
||||
raise APIError(6, 'The encoding type must be 2 or 3.')
|
||||
subject = self._decode(subject, "base64")
|
||||
message = self._decode(message, "base64")
|
||||
|
@ -1100,9 +986,12 @@ class BMRPCDispatcher(object):
|
|||
TTL = 28 * 24 * 60 * 60
|
||||
toAddress = addBMIfNotPresent(toAddress)
|
||||
fromAddress = addBMIfNotPresent(fromAddress)
|
||||
# pylint: disable=unused-variable
|
||||
status, addressVersionNumber, streamNumber, toRipe = \
|
||||
self._verifyAddress(toAddress)
|
||||
self._verifyAddress(fromAddress)
|
||||
try:
|
||||
fromAddressEnabled = self.config.getboolean(
|
||||
fromAddressEnabled = BMConfigParser().getboolean(
|
||||
fromAddress, 'enabled')
|
||||
except BaseException:
|
||||
raise APIError(
|
||||
|
@ -1110,31 +999,58 @@ class BMRPCDispatcher(object):
|
|||
if not fromAddressEnabled:
|
||||
raise APIError(14, 'Your fromAddress is disabled. Cannot send.')
|
||||
|
||||
ackdata = helper_sent.insert(
|
||||
toAddress=toAddress, fromAddress=fromAddress,
|
||||
subject=subject, message=message, encoding=encodingType, ttl=TTL)
|
||||
stealthLevel = BMConfigParser().safeGetInt(
|
||||
'bitmessagesettings', 'ackstealthlevel')
|
||||
ackdata = genAckPayload(streamNumber, stealthLevel)
|
||||
|
||||
t = ('',
|
||||
toAddress,
|
||||
toRipe,
|
||||
fromAddress,
|
||||
subject,
|
||||
message,
|
||||
ackdata,
|
||||
int(time.time()), # sentTime (this won't change)
|
||||
int(time.time()), # lastActionTime
|
||||
0,
|
||||
'msgqueued',
|
||||
0,
|
||||
'sent',
|
||||
2,
|
||||
TTL)
|
||||
helper_sent.insert(t)
|
||||
|
||||
toLabel = ''
|
||||
queryreturn = sqlQuery(
|
||||
"SELECT label FROM addressbook WHERE address=?", toAddress)
|
||||
try:
|
||||
toLabel, = queryreturn[0][0]
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
if queryreturn != []:
|
||||
for row in queryreturn:
|
||||
toLabel, = row
|
||||
queues.UISignalQueue.put(('displayNewSentMessage', (
|
||||
toAddress, toLabel, fromAddress, subject, message, ackdata)))
|
||||
|
||||
queues.workerQueue.put(('sendmessage', toAddress))
|
||||
|
||||
return hexlify(ackdata)
|
||||
|
||||
@command('sendBroadcast')
|
||||
def HandleSendBroadcast(
|
||||
self, fromAddress, subject, message, encodingType=2,
|
||||
TTL=4 * 24 * 60 * 60):
|
||||
"""Send the broadcast message. Similiar to *sendMessage*."""
|
||||
def HandleSendBroadcast(self, params):
|
||||
"""Handle a request to send a broadcast message"""
|
||||
|
||||
if encodingType not in (2, 3):
|
||||
if not params:
|
||||
raise APIError(0, 'I need parameters!')
|
||||
|
||||
if len(params) == 3:
|
||||
fromAddress, subject, message = params
|
||||
encodingType = 2
|
||||
TTL = 4 * 24 * 60 * 60
|
||||
|
||||
elif len(params) == 4:
|
||||
fromAddress, subject, message, encodingType = params
|
||||
TTL = 4 * 24 * 60 * 60
|
||||
elif len(params) == 5:
|
||||
fromAddress, subject, message, encodingType, TTL = params
|
||||
|
||||
if encodingType not in [2, 3]:
|
||||
raise APIError(6, 'The encoding type must be 2 or 3.')
|
||||
|
||||
subject = self._decode(subject, "base64")
|
||||
|
@ -1148,61 +1064,81 @@ class BMRPCDispatcher(object):
|
|||
fromAddress = addBMIfNotPresent(fromAddress)
|
||||
self._verifyAddress(fromAddress)
|
||||
try:
|
||||
self.config.getboolean(fromAddress, 'enabled')
|
||||
BMConfigParser().getboolean(fromAddress, 'enabled')
|
||||
except BaseException:
|
||||
raise APIError(
|
||||
13, 'Could not find your fromAddress in the keys.dat file.')
|
||||
toAddress = str_broadcast_subscribers
|
||||
13, 'could not find your fromAddress in the keys.dat file.')
|
||||
streamNumber = decodeAddress(fromAddress)[2]
|
||||
ackdata = genAckPayload(streamNumber, 0)
|
||||
toAddress = '[Broadcast subscribers]'
|
||||
ripe = ''
|
||||
|
||||
ackdata = helper_sent.insert(
|
||||
fromAddress=fromAddress, subject=subject,
|
||||
message=message, status='broadcastqueued',
|
||||
encoding=encodingType)
|
||||
t = ('',
|
||||
toAddress,
|
||||
ripe,
|
||||
fromAddress,
|
||||
subject,
|
||||
message,
|
||||
ackdata,
|
||||
int(time.time()), # sentTime (this doesn't change)
|
||||
int(time.time()), # lastActionTime
|
||||
0,
|
||||
'broadcastqueued',
|
||||
0,
|
||||
'sent',
|
||||
2,
|
||||
TTL)
|
||||
helper_sent.insert(t)
|
||||
|
||||
toLabel = str_broadcast_subscribers
|
||||
toLabel = '[Broadcast subscribers]'
|
||||
queues.UISignalQueue.put(('displayNewSentMessage', (
|
||||
toAddress, toLabel, fromAddress, subject, message, ackdata)))
|
||||
queues.workerQueue.put(('sendbroadcast', ''))
|
||||
|
||||
return hexlify(ackdata)
|
||||
|
||||
@command('getStatus')
|
||||
def HandleGetStatus(self, ackdata):
|
||||
"""
|
||||
Get the status of sent message by its ackdata (hex encoded).
|
||||
Returns one of these strings: notfound, msgqueued,
|
||||
broadcastqueued, broadcastsent, doingpubkeypow, awaitingpubkey,
|
||||
doingmsgpow, forcepow, msgsent, msgsentnoackexpected or ackreceived.
|
||||
"""
|
||||
def HandleGetStatus(self, params):
|
||||
"""Handle a request to get the status of a sent message"""
|
||||
|
||||
if len(params) != 1:
|
||||
raise APIError(0, 'I need one parameter!')
|
||||
ackdata, = params
|
||||
if len(ackdata) < 76:
|
||||
# The length of ackData should be at least 38 bytes (76 hex digits)
|
||||
raise APIError(15, 'Invalid ackData object size.')
|
||||
ackdata = self._decode(ackdata, "hex")
|
||||
queryreturn = sqlQuery(
|
||||
"SELECT status FROM sent where ackdata=?", ackdata)
|
||||
try:
|
||||
return queryreturn[0][0]
|
||||
except IndexError:
|
||||
if queryreturn == []:
|
||||
return 'notfound'
|
||||
for row in queryreturn:
|
||||
status, = row
|
||||
return status
|
||||
|
||||
@command('addSubscription')
|
||||
def HandleAddSubscription(self, address, label=''):
|
||||
"""Subscribe to the address. label must be base64 encoded."""
|
||||
def HandleAddSubscription(self, params):
|
||||
"""Handle a request to add a subscription"""
|
||||
|
||||
if label:
|
||||
if not params:
|
||||
raise APIError(0, 'I need parameters!')
|
||||
if len(params) == 1:
|
||||
address, = params
|
||||
label = ''
|
||||
if len(params) == 2:
|
||||
address, label = params
|
||||
label = self._decode(label, "base64")
|
||||
try:
|
||||
unicode(label, 'utf-8')
|
||||
except UnicodeDecodeError:
|
||||
except BaseException:
|
||||
raise APIError(17, 'Label is not valid UTF-8 data.')
|
||||
self._verifyAddress(address)
|
||||
if len(params) > 2:
|
||||
raise APIError(0, 'I need either 1 or 2 parameters!')
|
||||
address = addBMIfNotPresent(address)
|
||||
self._verifyAddress(address)
|
||||
# First we must check to see if the address is already in the
|
||||
# subscriptions list.
|
||||
queryreturn = sqlQuery(
|
||||
"SELECT * FROM subscriptions WHERE address=?", address)
|
||||
if queryreturn:
|
||||
if queryreturn != []:
|
||||
raise APIError(16, 'You are already subscribed to that address.')
|
||||
sqlExecute(
|
||||
"INSERT INTO subscriptions VALUES (?,?,?)", label, address, True)
|
||||
|
@ -1211,43 +1147,37 @@ class BMRPCDispatcher(object):
|
|||
queues.UISignalQueue.put(('rerenderSubscriptions', ''))
|
||||
return 'Added subscription.'
|
||||
|
||||
@command('deleteSubscription')
|
||||
def HandleDeleteSubscription(self, address):
|
||||
"""
|
||||
Unsubscribe from the address. The program does not check whether
|
||||
you were subscribed in the first place.
|
||||
"""
|
||||
def HandleDeleteSubscription(self, params):
|
||||
"""Handle a request to delete a subscription"""
|
||||
|
||||
if len(params) != 1:
|
||||
raise APIError(0, 'I need 1 parameter!')
|
||||
address, = params
|
||||
address = addBMIfNotPresent(address)
|
||||
sqlExecute("DELETE FROM subscriptions WHERE address=?", address)
|
||||
sqlExecute('''DELETE FROM subscriptions WHERE address=?''', address)
|
||||
shared.reloadBroadcastSendersForWhichImWatching()
|
||||
queues.UISignalQueue.put(('rerenderMessagelistFromLabels', ''))
|
||||
queues.UISignalQueue.put(('rerenderSubscriptions', ''))
|
||||
return 'Deleted subscription if it existed.'
|
||||
|
||||
@command('listSubscriptions')
|
||||
def ListSubscriptions(self):
|
||||
"""
|
||||
Returns dict with a list of all subscriptions
|
||||
in the *subscriptions* key.
|
||||
"""
|
||||
def ListSubscriptions(self, params): # pylint: disable=unused-argument
|
||||
"""Handle a request to list susbcriptions"""
|
||||
|
||||
# pylint: disable=unused-variable
|
||||
queryreturn = sqlQuery(
|
||||
"SELECT label, address, enabled FROM subscriptions")
|
||||
data = []
|
||||
for label, address, enabled in queryreturn:
|
||||
data = {'subscriptions': []}
|
||||
for row in queryreturn:
|
||||
label, address, enabled = row
|
||||
label = shared.fixPotentiallyInvalidUTF8Data(label)
|
||||
data.append({
|
||||
data['subscriptions'].append({
|
||||
'label': base64.b64encode(label),
|
||||
'address': address,
|
||||
'enabled': enabled == 1
|
||||
})
|
||||
return {'subscriptions': data}
|
||||
return json.dumps(data, indent=4, separators=(',', ': '))
|
||||
|
||||
@command('disseminatePreEncryptedMsg')
|
||||
def HandleDisseminatePreEncryptedMsg(
|
||||
self, encryptedPayload, requiredAverageProofOfWorkNonceTrialsPerByte,
|
||||
requiredPayloadLengthExtraBytes):
|
||||
def HandleDisseminatePreEncryptedMsg(self, params):
|
||||
"""Handle a request to disseminate an encrypted message"""
|
||||
|
||||
# The device issuing this command to PyBitmessage supplies a msg
|
||||
|
@ -1255,28 +1185,38 @@ class BMRPCDispatcher(object):
|
|||
# to be done. PyBitmessage accepts this msg object and sends it out
|
||||
# to the rest of the Bitmessage network as if it had generated
|
||||
# the message itself. Please do not yet add this to the api doc.
|
||||
if len(params) != 3:
|
||||
raise APIError(0, 'I need 3 parameter!')
|
||||
encryptedPayload, requiredAverageProofOfWorkNonceTrialsPerByte, \
|
||||
requiredPayloadLengthExtraBytes = params
|
||||
encryptedPayload = self._decode(encryptedPayload, "hex")
|
||||
# Let us do the POW and attach it to the front
|
||||
target = 2**64 / ((
|
||||
len(encryptedPayload) + requiredPayloadLengthExtraBytes + 8) *
|
||||
requiredAverageProofOfWorkNonceTrialsPerByte)
|
||||
logger.info(
|
||||
'(For msg message via API) Doing proof of work. Total required'
|
||||
' difficulty: %s\nRequired small message difficulty: %s',
|
||||
float(requiredAverageProofOfWorkNonceTrialsPerByte) /
|
||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte,
|
||||
float(requiredPayloadLengthExtraBytes) /
|
||||
defaults.networkDefaultPayloadLengthExtraBytes,
|
||||
target = 2**64 / (
|
||||
(
|
||||
len(encryptedPayload) + requiredPayloadLengthExtraBytes + 8
|
||||
) * requiredAverageProofOfWorkNonceTrialsPerByte
|
||||
)
|
||||
with shared.printLock:
|
||||
print(
|
||||
'(For msg message via API) Doing proof of work. Total required difficulty:',
|
||||
float(
|
||||
requiredAverageProofOfWorkNonceTrialsPerByte
|
||||
) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte,
|
||||
'Required small message difficulty:',
|
||||
float(requiredPayloadLengthExtraBytes) / defaults.networkDefaultPayloadLengthExtraBytes,
|
||||
)
|
||||
powStartTime = time.time()
|
||||
initialHash = hashlib.sha512(encryptedPayload).digest()
|
||||
trialValue, nonce = proofofwork.run(target, initialHash)
|
||||
logger.info(
|
||||
'(For msg message via API) Found proof of work %s\nNonce: %s\n'
|
||||
'POW took %s seconds. %s nonce trials per second.',
|
||||
trialValue, nonce, int(time.time() - powStartTime),
|
||||
nonce / (time.time() - powStartTime)
|
||||
with shared.printLock:
|
||||
print '(For msg message via API) Found proof of work', trialValue, 'Nonce:', nonce
|
||||
try:
|
||||
print(
|
||||
'POW took', int(time.time() - powStartTime), 'seconds.',
|
||||
nonce / (time.time() - powStartTime), 'nonce trials per second.',
|
||||
)
|
||||
except BaseException:
|
||||
pass
|
||||
encryptedPayload = pack('>Q', nonce) + encryptedPayload
|
||||
toStreamNumber = decodeVarint(encryptedPayload[16:26])[0]
|
||||
inventoryHash = calculateInventoryHash(encryptedPayload)
|
||||
|
@ -1286,21 +1226,21 @@ class BMRPCDispatcher(object):
|
|||
objectType, toStreamNumber, encryptedPayload,
|
||||
int(time.time()) + TTL, ''
|
||||
)
|
||||
logger.info(
|
||||
'Broadcasting inv for msg(API disseminatePreEncryptedMsg'
|
||||
' command): %s', hexlify(inventoryHash))
|
||||
with shared.printLock:
|
||||
print 'Broadcasting inv for msg(API disseminatePreEncryptedMsg command):', hexlify(inventoryHash)
|
||||
queues.invQueue.put((toStreamNumber, inventoryHash))
|
||||
|
||||
@command('trashSentMessageByAckData')
|
||||
def HandleTrashSentMessageByAckDAta(self, ackdata):
|
||||
"""Trash a sent message by ackdata (hex encoded)"""
|
||||
def HandleTrashSentMessageByAckDAta(self, params):
|
||||
"""Handle a request to trash a sent message by ackdata"""
|
||||
|
||||
# This API method should only be used when msgid is not available
|
||||
ackdata = self._decode(ackdata, "hex")
|
||||
if not params:
|
||||
raise APIError(0, 'I need parameters!')
|
||||
ackdata = self._decode(params[0], "hex")
|
||||
sqlExecute("UPDATE sent SET folder='trash' WHERE ackdata=?", ackdata)
|
||||
return 'Trashed sent message (assuming message existed).'
|
||||
|
||||
@command('disseminatePubkey')
|
||||
def HandleDissimatePubKey(self, payload):
|
||||
def HandleDissimatePubKey(self, params): # pylint: disable=unused-argument
|
||||
"""Handle a request to disseminate a public key"""
|
||||
|
||||
# The device issuing this command to PyBitmessage supplies a pubkey
|
||||
|
@ -1308,19 +1248,19 @@ class BMRPCDispatcher(object):
|
|||
# PyBitmessage accepts this pubkey object and sends it out to the rest
|
||||
# of the Bitmessage network as if it had generated the pubkey object
|
||||
# itself. Please do not yet add this to the api doc.
|
||||
if len(params) != 1:
|
||||
raise APIError(0, 'I need 1 parameter!')
|
||||
payload, = params
|
||||
payload = self._decode(payload, "hex")
|
||||
|
||||
# Let us do the POW
|
||||
target = 2 ** 64 / ((
|
||||
len(payload) + defaults.networkDefaultPayloadLengthExtraBytes + 8
|
||||
) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)
|
||||
logger.info('(For pubkey message via API) Doing proof of work...')
|
||||
print '(For pubkey message via API) Doing proof of work...'
|
||||
initialHash = hashlib.sha512(payload).digest()
|
||||
trialValue, nonce = proofofwork.run(target, initialHash)
|
||||
logger.info(
|
||||
'(For pubkey message via API) Found proof of work %s Nonce: %s',
|
||||
trialValue, nonce
|
||||
)
|
||||
print '(For pubkey message via API) Found proof of work', trialValue, 'Nonce:', nonce
|
||||
payload = pack('>Q', nonce) + payload
|
||||
|
||||
pubkeyReadPosition = 8 # bypass the nonce
|
||||
|
@ -1329,8 +1269,9 @@ class BMRPCDispatcher(object):
|
|||
pubkeyReadPosition += 8
|
||||
else:
|
||||
pubkeyReadPosition += 4
|
||||
addressVersionLength = decodeVarint(
|
||||
payload[pubkeyReadPosition:pubkeyReadPosition + 10])[1]
|
||||
# pylint: disable=unused-variable
|
||||
addressVersion, addressVersionLength = decodeVarint(
|
||||
payload[pubkeyReadPosition:pubkeyReadPosition + 10])
|
||||
pubkeyReadPosition += addressVersionLength
|
||||
pubkeyStreamNumber = decodeVarint(
|
||||
payload[pubkeyReadPosition:pubkeyReadPosition + 10])[0]
|
||||
|
@ -1340,19 +1281,19 @@ class BMRPCDispatcher(object):
|
|||
Inventory()[inventoryHash] = (
|
||||
objectType, pubkeyStreamNumber, payload, int(time.time()) + TTL, ''
|
||||
)
|
||||
logger.info(
|
||||
'broadcasting inv within API command disseminatePubkey with'
|
||||
' hash: %s', hexlify(inventoryHash))
|
||||
with shared.printLock:
|
||||
print 'broadcasting inv within API command disseminatePubkey with hash:', hexlify(inventoryHash)
|
||||
queues.invQueue.put((pubkeyStreamNumber, inventoryHash))
|
||||
|
||||
@command(
|
||||
'getMessageDataByDestinationHash', 'getMessageDataByDestinationTag')
|
||||
def HandleGetMessageDataByDestinationHash(self, requestedHash):
|
||||
def HandleGetMessageDataByDestinationHash(self, params):
|
||||
"""Handle a request to get message data by destination hash"""
|
||||
|
||||
# Method will eventually be used by a particular Android app to
|
||||
# select relevant messages. Do not yet add this to the api
|
||||
# doc.
|
||||
if len(params) != 1:
|
||||
raise APIError(0, 'I need 1 parameter!')
|
||||
requestedHash, = params
|
||||
if len(requestedHash) != 32:
|
||||
raise APIError(
|
||||
19, 'The length of hash should be 32 bytes (encoded in hex'
|
||||
|
@ -1366,7 +1307,8 @@ class BMRPCDispatcher(object):
|
|||
"SELECT hash, payload FROM inventory WHERE tag = ''"
|
||||
" and objecttype = 2")
|
||||
with SqlBulkExecute() as sql:
|
||||
for hash01, payload in queryreturn:
|
||||
for row in queryreturn:
|
||||
hash01, payload = row
|
||||
readPosition = 16 # Nonce length + time length
|
||||
# Stream Number length
|
||||
readPosition += decodeVarint(
|
||||
|
@ -1376,121 +1318,169 @@ class BMRPCDispatcher(object):
|
|||
|
||||
queryreturn = sqlQuery(
|
||||
"SELECT payload FROM inventory WHERE tag = ?", requestedHash)
|
||||
return {"receivedMessageDatas": [
|
||||
{'data': hexlify(payload)} for payload, in queryreturn
|
||||
]}
|
||||
data = '{"receivedMessageDatas":['
|
||||
for row in queryreturn:
|
||||
payload, = row
|
||||
if len(data) > 25:
|
||||
data += ','
|
||||
data += json.dumps(
|
||||
{'data': hexlify(payload)}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
|
||||
@command('clientStatus')
|
||||
def HandleClientStatus(self):
|
||||
"""
|
||||
Returns the bitmessage status as dict with keys *networkConnections*,
|
||||
*numberOfMessagesProcessed*, *numberOfBroadcastsProcessed*,
|
||||
*numberOfPubkeysProcessed*, *pendingDownload*, *networkStatus*,
|
||||
*softwareName*, *softwareVersion*. *networkStatus* will be one of
|
||||
these strings: "notConnected",
|
||||
"connectedButHaveNotReceivedIncomingConnections",
|
||||
or "connectedAndReceivingIncomingConnections".
|
||||
"""
|
||||
def HandleClientStatus(self, params): # pylint: disable=unused-argument
|
||||
"""Handle a request to get the status of the client"""
|
||||
|
||||
connections_num = len(network.stats.connectedHostsList())
|
||||
if connections_num == 0:
|
||||
networkStatus = 'notConnected'
|
||||
elif state.clientHasReceivedIncomingConnections:
|
||||
elif shared.clientHasReceivedIncomingConnections:
|
||||
networkStatus = 'connectedAndReceivingIncomingConnections'
|
||||
else:
|
||||
networkStatus = 'connectedButHaveNotReceivedIncomingConnections'
|
||||
return {
|
||||
return json.dumps({
|
||||
'networkConnections': connections_num,
|
||||
'numberOfMessagesProcessed': state.numberOfMessagesProcessed,
|
||||
'numberOfBroadcastsProcessed': state.numberOfBroadcastsProcessed,
|
||||
'numberOfPubkeysProcessed': state.numberOfPubkeysProcessed,
|
||||
'pendingDownload': network.stats.pendingDownload(),
|
||||
'numberOfMessagesProcessed': shared.numberOfMessagesProcessed,
|
||||
'numberOfBroadcastsProcessed': shared.numberOfBroadcastsProcessed,
|
||||
'numberOfPubkeysProcessed': shared.numberOfPubkeysProcessed,
|
||||
'networkStatus': networkStatus,
|
||||
'softwareName': 'PyBitmessage',
|
||||
'softwareVersion': softwareVersion
|
||||
}
|
||||
}, indent=4, separators=(',', ': '))
|
||||
|
||||
@command('helloWorld')
|
||||
def HandleHelloWorld(self, a, b):
|
||||
def HandleDecodeAddress(self, params):
|
||||
"""Handle a request to decode an address"""
|
||||
|
||||
# Return a meaningful decoding of an address.
|
||||
if len(params) != 1:
|
||||
raise APIError(0, 'I need 1 parameter!')
|
||||
address, = params
|
||||
status, addressVersion, streamNumber, ripe = decodeAddress(address)
|
||||
return json.dumps({
|
||||
'status': status,
|
||||
'addressVersion': addressVersion,
|
||||
'streamNumber': streamNumber,
|
||||
'ripe': base64.b64encode(ripe)
|
||||
}, indent=4, separators=(',', ': '))
|
||||
|
||||
def HandleHelloWorld(self, params):
|
||||
"""Test two string params"""
|
||||
|
||||
a, b = params
|
||||
return a + '-' + b
|
||||
|
||||
@command('add')
|
||||
def HandleAdd(self, a, b):
|
||||
def HandleAdd(self, params):
|
||||
"""Test two numeric params"""
|
||||
|
||||
a, b = params
|
||||
return a + b
|
||||
|
||||
@command('statusBar')
|
||||
def HandleStatusBar(self, message):
|
||||
"""Update GUI statusbar message"""
|
||||
def HandleStatusBar(self, params):
|
||||
"""Handle a request to update the status bar"""
|
||||
|
||||
message, = params
|
||||
queues.UISignalQueue.put(('updateStatusBar', message))
|
||||
|
||||
@command('deleteAndVacuum')
|
||||
def HandleDeleteAndVacuum(self):
|
||||
"""Cleanup trashes and vacuum messages database"""
|
||||
def HandleDeleteAndVacuum(self, params):
|
||||
"""Handle a request to run the deleteandvacuum stored procedure"""
|
||||
|
||||
if not params:
|
||||
sqlStoredProcedure('deleteandvacuume')
|
||||
return 'done'
|
||||
return None
|
||||
|
||||
@command('shutdown')
|
||||
def HandleShutdown(self):
|
||||
"""Shutdown the bitmessage. Returns 'done'."""
|
||||
def HandleShutdown(self, params):
|
||||
"""Handle a request to shutdown the node"""
|
||||
|
||||
if not params:
|
||||
# backward compatible trick because False == 0 is True
|
||||
state.shutdown = False
|
||||
return 'done'
|
||||
return None
|
||||
|
||||
handlers = {}
|
||||
handlers['helloWorld'] = HandleHelloWorld
|
||||
handlers['add'] = HandleAdd
|
||||
handlers['statusBar'] = HandleStatusBar
|
||||
handlers['listAddresses'] = HandleListAddresses
|
||||
handlers['listAddressBookEntries'] = HandleListAddressBookEntries
|
||||
# the listAddressbook alias should be removed eventually.
|
||||
handlers['listAddressbook'] = HandleListAddressBookEntries
|
||||
handlers['addAddressBookEntry'] = HandleAddAddressBookEntry
|
||||
# the addAddressbook alias should be deleted eventually.
|
||||
handlers['addAddressbook'] = HandleAddAddressBookEntry
|
||||
handlers['deleteAddressBookEntry'] = HandleDeleteAddressBookEntry
|
||||
# The deleteAddressbook alias should be deleted eventually.
|
||||
handlers['deleteAddressbook'] = HandleDeleteAddressBookEntry
|
||||
handlers['createRandomAddress'] = HandleCreateRandomAddress
|
||||
handlers['createDeterministicAddresses'] = \
|
||||
HandleCreateDeterministicAddresses
|
||||
handlers['getDeterministicAddress'] = HandleGetDeterministicAddress
|
||||
handlers['createChan'] = HandleCreateChan
|
||||
handlers['joinChan'] = HandleJoinChan
|
||||
handlers['leaveChan'] = HandleLeaveChan
|
||||
handlers['deleteAddress'] = HandleDeleteAddress
|
||||
handlers['getAllInboxMessages'] = HandleGetAllInboxMessages
|
||||
handlers['getAllInboxMessageIds'] = HandleGetAllInboxMessageIds
|
||||
handlers['getAllInboxMessageIDs'] = HandleGetAllInboxMessageIds
|
||||
handlers['getInboxMessageById'] = HandleGetInboxMessageById
|
||||
handlers['getInboxMessageByID'] = HandleGetInboxMessageById
|
||||
handlers['getAllSentMessages'] = HandleGetAllSentMessages
|
||||
handlers['getAllSentMessageIds'] = HandleGetAllSentMessageIds
|
||||
handlers['getAllSentMessageIDs'] = HandleGetAllSentMessageIds
|
||||
handlers['getInboxMessagesByReceiver'] = HandleInboxMessagesByReceiver
|
||||
# after some time getInboxMessagesByAddress should be removed
|
||||
handlers['getInboxMessagesByAddress'] = HandleInboxMessagesByReceiver
|
||||
handlers['getSentMessageById'] = HandleGetSentMessageById
|
||||
handlers['getSentMessageByID'] = HandleGetSentMessageById
|
||||
handlers['getSentMessagesByAddress'] = HandleGetSentMessagesByAddress
|
||||
handlers['getSentMessagesBySender'] = HandleGetSentMessagesByAddress
|
||||
handlers['getSentMessageByAckData'] = HandleGetSentMessagesByAckData
|
||||
handlers['trashMessage'] = HandleTrashMessage
|
||||
handlers['trashInboxMessage'] = HandleTrashInboxMessage
|
||||
handlers['trashSentMessage'] = HandleTrashSentMessage
|
||||
handlers['trashSentMessageByAckData'] = HandleTrashSentMessageByAckDAta
|
||||
handlers['sendMessage'] = HandleSendMessage
|
||||
handlers['sendBroadcast'] = HandleSendBroadcast
|
||||
handlers['getStatus'] = HandleGetStatus
|
||||
handlers['addSubscription'] = HandleAddSubscription
|
||||
handlers['deleteSubscription'] = HandleDeleteSubscription
|
||||
handlers['listSubscriptions'] = ListSubscriptions
|
||||
handlers['disseminatePreEncryptedMsg'] = HandleDisseminatePreEncryptedMsg
|
||||
handlers['disseminatePubkey'] = HandleDissimatePubKey
|
||||
handlers['getMessageDataByDestinationHash'] = \
|
||||
HandleGetMessageDataByDestinationHash
|
||||
handlers['getMessageDataByDestinationTag'] = \
|
||||
HandleGetMessageDataByDestinationHash
|
||||
handlers['clientStatus'] = HandleClientStatus
|
||||
handlers['decodeAddress'] = HandleDecodeAddress
|
||||
handlers['deleteAndVacuum'] = HandleDeleteAndVacuum
|
||||
handlers['shutdown'] = HandleShutdown
|
||||
|
||||
def _handle_request(self, method, params):
|
||||
try:
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
self._method = method
|
||||
func = self._handlers[method]
|
||||
return func(self, *params)
|
||||
except KeyError:
|
||||
if method not in self.handlers:
|
||||
raise APIError(20, 'Invalid method: %s' % method)
|
||||
except TypeError as e:
|
||||
msg = 'Unexpected API Failure - %s' % e
|
||||
if 'argument' not in str(e):
|
||||
raise APIError(21, msg)
|
||||
argcount = len(params)
|
||||
maxcount = func.func_code.co_argcount
|
||||
if argcount > maxcount:
|
||||
msg = (
|
||||
'Command %s takes at most %s parameters (%s given)'
|
||||
% (method, maxcount, argcount))
|
||||
else:
|
||||
mincount = maxcount - len(func.func_defaults or [])
|
||||
if argcount < mincount:
|
||||
msg = (
|
||||
'Command %s takes at least %s parameters (%s given)'
|
||||
% (method, mincount, argcount))
|
||||
raise APIError(0, msg)
|
||||
finally:
|
||||
result = self.handlers[method](self, params)
|
||||
state.last_api_response = time.time()
|
||||
return result
|
||||
|
||||
def _dispatch(self, method, params):
|
||||
_fault = None
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
self.cookies = []
|
||||
|
||||
validuser = self.APIAuthenticateClient()
|
||||
if not validuser:
|
||||
time.sleep(2)
|
||||
return "RPC Username or password incorrect or HTTP header lacks authentication at all."
|
||||
|
||||
try:
|
||||
return self._handle_request(method, params)
|
||||
except APIError as e:
|
||||
_fault = e
|
||||
return str(e)
|
||||
except varintDecodeError as e:
|
||||
logger.error(e)
|
||||
_fault = APIError(
|
||||
26, 'Data contains a malformed varint. Some details: %s' % e)
|
||||
return "API Error 0026: Data contains a malformed varint. Some details: %s" % e
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
_fault = APIError(21, 'Unexpected API Failure - %s' % e)
|
||||
|
||||
if _fault:
|
||||
if self.config.safeGet(
|
||||
'bitmessagesettings', 'apivariant') == 'legacy':
|
||||
return str(_fault)
|
||||
else:
|
||||
raise _fault # pylint: disable=raising-bad-type
|
||||
|
||||
def _listMethods(self):
|
||||
"""List all API commands"""
|
||||
return self._handlers.keys()
|
||||
|
||||
def _methodHelp(self, method):
|
||||
return self._handlers[method].__doc__
|
||||
return "API Error 0021: Unexpected API Failure - %s" % e
|
||||
|
|
|
@ -13,15 +13,15 @@ TODO: fix the following (currently ignored) violations:
|
|||
|
||||
"""
|
||||
|
||||
import xmlrpclib
|
||||
import datetime
|
||||
import imghdr
|
||||
import json
|
||||
import ntpath
|
||||
import os
|
||||
import json
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
import xmlrpclib
|
||||
import sys
|
||||
import os
|
||||
|
||||
from bmconfigparser import BMConfigParser
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
Bitmessage commandline interface
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
# Copyright (c) 2014 Luke Montalvo <lukemontalvo@gmail.com>
|
||||
# This file adds a alternative commandline interface, feel free to critique and fork
|
||||
#
|
||||
|
@ -10,32 +11,42 @@ Bitmessage commandline interface
|
|||
# * python2-pythondialog
|
||||
# * dialog
|
||||
|
||||
import ConfigParser
|
||||
import curses
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import chr
|
||||
from builtins import ascii
|
||||
from builtins import str
|
||||
from builtins import range
|
||||
from builtins import *
|
||||
from builtins import object
|
||||
import os
|
||||
import sys
|
||||
import io
|
||||
from textwrap import *
|
||||
|
||||
import time
|
||||
from textwrap import fill
|
||||
from time import strftime, localtime
|
||||
from threading import Timer
|
||||
|
||||
import curses
|
||||
import dialog
|
||||
from dialog import Dialog
|
||||
import helper_sent
|
||||
from helper_sql import *
|
||||
from helper_ackPayload import genAckPayload
|
||||
|
||||
from addresses import *
|
||||
import configparser
|
||||
from bmconfigparser import BMConfigParser
|
||||
from inventory import Inventory
|
||||
import l10n
|
||||
import network.stats
|
||||
from pyelliptic.openssl import OpenSSL
|
||||
import queues
|
||||
import shared
|
||||
import shutdown
|
||||
import state
|
||||
|
||||
from addresses import addBMIfNotPresent, decodeAddress
|
||||
from bmconfigparser import BMConfigParser
|
||||
from helper_sql import sqlExecute, sqlQuery
|
||||
from inventory import Inventory
|
||||
|
||||
# pylint: disable=global-statement
|
||||
import network.stats
|
||||
|
||||
|
||||
quit_ = False
|
||||
quit = False
|
||||
menutab = 1
|
||||
menu = ["Inbox", "Send", "Sent", "Your Identities", "Subscriptions", "Address Book", "Blacklist", "Network Status"]
|
||||
naptime = 100
|
||||
|
@ -61,194 +72,155 @@ bwtype = "black"
|
|||
|
||||
BROADCAST_STR = "[Broadcast subscribers]"
|
||||
|
||||
|
||||
class printLog(object):
|
||||
"""Printing logs"""
|
||||
# pylint: disable=no-self-use
|
||||
|
||||
def write(self, output):
|
||||
"""Write logs"""
|
||||
global log
|
||||
log += output
|
||||
|
||||
def flush(self):
|
||||
"""Flush logs"""
|
||||
pass
|
||||
|
||||
|
||||
class errLog(object):
|
||||
"""Error logs"""
|
||||
# pylint: disable=no-self-use
|
||||
|
||||
def write(self, output):
|
||||
"""Write error logs"""
|
||||
global log
|
||||
log += "!" + output
|
||||
|
||||
log += "!"+output
|
||||
def flush(self):
|
||||
"""Flush error logs"""
|
||||
pass
|
||||
|
||||
|
||||
printlog = printLog()
|
||||
errlog = errLog()
|
||||
|
||||
|
||||
def cpair(a):
|
||||
"""Color pairs"""
|
||||
r = curses.color_pair(a)
|
||||
if r not in range(1, curses.COLOR_PAIRS - 1):
|
||||
if r not in list(range(1, curses.COLOR_PAIRS-1)):
|
||||
r = curses.color_pair(0)
|
||||
return r
|
||||
|
||||
|
||||
def ascii(s):
|
||||
"""ASCII values"""
|
||||
r = ""
|
||||
for c in s:
|
||||
if ord(c) in range(128):
|
||||
r += c
|
||||
return r
|
||||
|
||||
|
||||
def drawmenu(stdscr):
|
||||
"""Creating menu's"""
|
||||
menustr = " "
|
||||
for i, _ in enumerate(menu):
|
||||
if menutab == i + 1:
|
||||
for i in range(0, len(menu)):
|
||||
if menutab == i+1:
|
||||
menustr = menustr[:-1]
|
||||
menustr += "["
|
||||
menustr += str(i + 1) + menu[i]
|
||||
if menutab == i + 1:
|
||||
menustr += str(i+1)+menu[i]
|
||||
if menutab == i+1:
|
||||
menustr += "] "
|
||||
elif i != len(menu) - 1:
|
||||
elif i != len(menu)-1:
|
||||
menustr += " "
|
||||
stdscr.addstr(2, 5, menustr, curses.A_UNDERLINE)
|
||||
|
||||
|
||||
def set_background_title(d, title):
|
||||
"""Setting background title"""
|
||||
try:
|
||||
d.set_background_title(title)
|
||||
except:
|
||||
d.add_persistent_args(("--backtitle", title))
|
||||
|
||||
|
||||
def scrollbox(d, text, height=None, width=None):
|
||||
"""Setting scroll box"""
|
||||
try:
|
||||
d.scrollbox(text, height, width, exit_label="Continue")
|
||||
d.scrollbox(text, height, width, exit_label = "Continue")
|
||||
except:
|
||||
d.msgbox(text, height or 0, width or 0, ok_label="Continue")
|
||||
|
||||
d.msgbox(text, height or 0, width or 0, ok_label = "Continue")
|
||||
|
||||
def resetlookups():
|
||||
"""Reset the Inventory Lookups"""
|
||||
global inventorydata
|
||||
inventorydata = Inventory().numberOfInventoryLookupsPerformed
|
||||
Inventory().numberOfInventoryLookupsPerformed = 0
|
||||
Timer(1, resetlookups, ()).start()
|
||||
|
||||
|
||||
def drawtab(stdscr):
|
||||
"""Method for drawing different tabs"""
|
||||
# pylint: disable=too-many-branches, too-many-statements
|
||||
if menutab in range(1, len(menu) + 1):
|
||||
if menutab in range(1, len(menu)+1):
|
||||
if menutab == 1: # Inbox
|
||||
stdscr.addstr(3, 5, "To", curses.A_BOLD)
|
||||
stdscr.addstr(3, 40, "From", curses.A_BOLD)
|
||||
stdscr.addstr(3, 80, "Subject", curses.A_BOLD)
|
||||
stdscr.addstr(3, 120, "Time Received", curses.A_BOLD)
|
||||
stdscr.hline(4, 5, '-', 121)
|
||||
for i, item in enumerate(inbox[max(min(len(inbox) - curses.LINES + 6, inboxcur - 5), 0):]):
|
||||
if 6 + i < curses.LINES:
|
||||
for i, item in enumerate(inbox[max(min(len(inbox)-curses.LINES+6, inboxcur-5), 0):]):
|
||||
if 6+i < curses.LINES:
|
||||
a = 0
|
||||
if i == inboxcur - max(min(len(inbox) - curses.LINES + 6, inboxcur - 5), 0):
|
||||
# Highlight current address
|
||||
if i == inboxcur - max(min(len(inbox)-curses.LINES+6, inboxcur-5), 0): # Highlight current address
|
||||
a = a | curses.A_REVERSE
|
||||
if item[7] is False: # If not read, highlight
|
||||
if item[7] == False: # If not read, highlight
|
||||
a = a | curses.A_BOLD
|
||||
stdscr.addstr(5 + i, 5, item[1][:34], a)
|
||||
stdscr.addstr(5 + i, 40, item[3][:39], a)
|
||||
stdscr.addstr(5 + i, 80, item[5][:39], a)
|
||||
stdscr.addstr(5 + i, 120, item[6][:39], a)
|
||||
stdscr.addstr(5+i, 5, item[1][:34], a)
|
||||
stdscr.addstr(5+i, 40, item[3][:39], a)
|
||||
stdscr.addstr(5+i, 80, item[5][:39], a)
|
||||
stdscr.addstr(5+i, 120, item[6][:39], a)
|
||||
elif menutab == 3: # Sent
|
||||
stdscr.addstr(3, 5, "To", curses.A_BOLD)
|
||||
stdscr.addstr(3, 40, "From", curses.A_BOLD)
|
||||
stdscr.addstr(3, 80, "Subject", curses.A_BOLD)
|
||||
stdscr.addstr(3, 120, "Status", curses.A_BOLD)
|
||||
stdscr.hline(4, 5, '-', 121)
|
||||
for i, item in enumerate(sentbox[max(min(len(sentbox) - curses.LINES + 6, sentcur - 5), 0):]):
|
||||
if 6 + i < curses.LINES:
|
||||
for i, item in enumerate(sentbox[max(min(len(sentbox)-curses.LINES+6, sentcur-5), 0):]):
|
||||
if 6+i < curses.LINES:
|
||||
a = 0
|
||||
if i == sentcur - max(min(len(sentbox) - curses.LINES + 6, sentcur - 5), 0):
|
||||
# Highlight current address
|
||||
if i == sentcur - max(min(len(sentbox)-curses.LINES+6, sentcur-5), 0): # Highlight current address
|
||||
a = a | curses.A_REVERSE
|
||||
stdscr.addstr(5 + i, 5, item[0][:34], a)
|
||||
stdscr.addstr(5 + i, 40, item[2][:39], a)
|
||||
stdscr.addstr(5 + i, 80, item[4][:39], a)
|
||||
stdscr.addstr(5 + i, 120, item[5][:39], a)
|
||||
stdscr.addstr(5+i, 5, item[0][:34], a)
|
||||
stdscr.addstr(5+i, 40, item[2][:39], a)
|
||||
stdscr.addstr(5+i, 80, item[4][:39], a)
|
||||
stdscr.addstr(5+i, 120, item[5][:39], a)
|
||||
elif menutab == 2 or menutab == 4: # Send or Identities
|
||||
stdscr.addstr(3, 5, "Label", curses.A_BOLD)
|
||||
stdscr.addstr(3, 40, "Address", curses.A_BOLD)
|
||||
stdscr.addstr(3, 80, "Stream", curses.A_BOLD)
|
||||
stdscr.hline(4, 5, '-', 81)
|
||||
for i, item in enumerate(addresses[max(min(len(addresses) - curses.LINES + 6, addrcur - 5), 0):]):
|
||||
if 6 + i < curses.LINES:
|
||||
for i, item in enumerate(addresses[max(min(len(addresses)-curses.LINES+6, addrcur-5), 0):]):
|
||||
if 6+i < curses.LINES:
|
||||
a = 0
|
||||
if i == addrcur - max(min(len(addresses) - curses.LINES + 6, addrcur - 5), 0):
|
||||
# Highlight current address
|
||||
if i == addrcur - max(min(len(addresses)-curses.LINES+6, addrcur-5), 0): # Highlight current address
|
||||
a = a | curses.A_REVERSE
|
||||
if item[1] and item[3] not in [8, 9]: # Embolden enabled, non-special addresses
|
||||
if item[1] == True and item[3] not in [8,9]: # Embolden enabled, non-special addresses
|
||||
a = a | curses.A_BOLD
|
||||
stdscr.addstr(5 + i, 5, item[0][:34], a)
|
||||
stdscr.addstr(5 + i, 40, item[2][:39], cpair(item[3]) | a)
|
||||
stdscr.addstr(5 + i, 80, str(1)[:39], a)
|
||||
stdscr.addstr(5+i, 5, item[0][:34], a)
|
||||
stdscr.addstr(5+i, 40, item[2][:39], cpair(item[3]) | a)
|
||||
stdscr.addstr(5+i, 80, str(1)[:39], a)
|
||||
elif menutab == 5: # Subscriptions
|
||||
stdscr.addstr(3, 5, "Label", curses.A_BOLD)
|
||||
stdscr.addstr(3, 80, "Address", curses.A_BOLD)
|
||||
stdscr.addstr(3, 120, "Enabled", curses.A_BOLD)
|
||||
stdscr.hline(4, 5, '-', 121)
|
||||
for i, item in enumerate(subscriptions[max(min(len(subscriptions) - curses.LINES + 6, subcur - 5), 0):]):
|
||||
if 6 + i < curses.LINES:
|
||||
for i, item in enumerate(subscriptions[max(min(len(subscriptions)-curses.LINES+6, subcur-5), 0):]):
|
||||
if 6+i < curses.LINES:
|
||||
a = 0
|
||||
if i == subcur - max(min(len(subscriptions) - curses.LINES + 6, subcur - 5), 0):
|
||||
# Highlight current address
|
||||
if i == subcur - max(min(len(subscriptions)-curses.LINES+6, subcur-5), 0): # Highlight current address
|
||||
a = a | curses.A_REVERSE
|
||||
if item[2]: # Embolden enabled subscriptions
|
||||
if item[2] == True: # Embolden enabled subscriptions
|
||||
a = a | curses.A_BOLD
|
||||
stdscr.addstr(5 + i, 5, item[0][:74], a)
|
||||
stdscr.addstr(5 + i, 80, item[1][:39], a)
|
||||
stdscr.addstr(5 + i, 120, str(item[2]), a)
|
||||
stdscr.addstr(5+i, 5, item[0][:74], a)
|
||||
stdscr.addstr(5+i, 80, item[1][:39], a)
|
||||
stdscr.addstr(5+i, 120, str(item[2]), a)
|
||||
elif menutab == 6: # Address book
|
||||
stdscr.addstr(3, 5, "Label", curses.A_BOLD)
|
||||
stdscr.addstr(3, 40, "Address", curses.A_BOLD)
|
||||
stdscr.hline(4, 5, '-', 41)
|
||||
for i, item in enumerate(addrbook[max(min(len(addrbook) - curses.LINES + 6, abookcur - 5), 0):]):
|
||||
if 6 + i < curses.LINES:
|
||||
for i, item in enumerate(addrbook[max(min(len(addrbook)-curses.LINES+6, abookcur-5), 0):]):
|
||||
if 6+i < curses.LINES:
|
||||
a = 0
|
||||
if i == abookcur - max(min(len(addrbook) - curses.LINES + 6, abookcur - 5), 0):
|
||||
# Highlight current address
|
||||
if i == abookcur - max(min(len(addrbook)-curses.LINES+6, abookcur-5), 0): # Highlight current address
|
||||
a = a | curses.A_REVERSE
|
||||
stdscr.addstr(5 + i, 5, item[0][:34], a)
|
||||
stdscr.addstr(5 + i, 40, item[1][:39], a)
|
||||
stdscr.addstr(5+i, 5, item[0][:34], a)
|
||||
stdscr.addstr(5+i, 40, item[1][:39], a)
|
||||
elif menutab == 7: # Blacklist
|
||||
stdscr.addstr(3, 5, "Type: " + bwtype)
|
||||
stdscr.addstr(3, 5, "Type: "+bwtype)
|
||||
stdscr.addstr(4, 5, "Label", curses.A_BOLD)
|
||||
stdscr.addstr(4, 80, "Address", curses.A_BOLD)
|
||||
stdscr.addstr(4, 120, "Enabled", curses.A_BOLD)
|
||||
stdscr.hline(5, 5, '-', 121)
|
||||
for i, item in enumerate(blacklist[max(min(len(blacklist) - curses.LINES + 6, blackcur - 5), 0):]):
|
||||
if 7 + i < curses.LINES:
|
||||
for i, item in enumerate(blacklist[max(min(len(blacklist)-curses.LINES+6, blackcur-5), 0):]):
|
||||
if 7+i < curses.LINES:
|
||||
a = 0
|
||||
if i == blackcur - max(min(len(blacklist) - curses.LINES + 6, blackcur - 5), 0):
|
||||
# Highlight current address
|
||||
if i == blackcur - max(min(len(blacklist)-curses.LINES+6, blackcur-5), 0): # Highlight current address
|
||||
a = a | curses.A_REVERSE
|
||||
if item[2]: # Embolden enabled subscriptions
|
||||
if item[2] == True: # Embolden enabled subscriptions
|
||||
a = a | curses.A_BOLD
|
||||
stdscr.addstr(6 + i, 5, item[0][:74], a)
|
||||
stdscr.addstr(6 + i, 80, item[1][:39], a)
|
||||
stdscr.addstr(6 + i, 120, str(item[2]), a)
|
||||
stdscr.addstr(6+i, 5, item[0][:74], a)
|
||||
stdscr.addstr(6+i, 80, item[1][:39], a)
|
||||
stdscr.addstr(6+i, 120, str(item[2]), a)
|
||||
elif menutab == 8: # Network status
|
||||
# Connection data
|
||||
connected_hosts = network.stats.connectedHostsList()
|
||||
|
@ -268,61 +240,48 @@ def drawtab(stdscr):
|
|||
for i, item in enumerate(streamcount):
|
||||
if i < 4:
|
||||
if i == 0:
|
||||
stdscr.addstr(8 + i, 6, "?")
|
||||
stdscr.addstr(8+i, 6, "?")
|
||||
else:
|
||||
stdscr.addstr(8 + i, 6, str(i))
|
||||
stdscr.addstr(8 + i, 18, str(item).ljust(2))
|
||||
stdscr.addstr(8+i, 6, str(i))
|
||||
stdscr.addstr(8+i, 18, str(item).ljust(2))
|
||||
|
||||
# Uptime and processing data
|
||||
stdscr.addstr(6, 35, "Since startup on " + l10n.formatTimestamp(startuptime, False))
|
||||
stdscr.addstr(7, 40, "Processed " + str(
|
||||
state.numberOfMessagesProcessed).ljust(4) + " person-to-person messages.")
|
||||
stdscr.addstr(8, 40, "Processed " + str(
|
||||
state.numberOfBroadcastsProcessed).ljust(4) + " broadcast messages.")
|
||||
stdscr.addstr(9, 40, "Processed " + str(
|
||||
state.numberOfPubkeysProcessed).ljust(4) + " public keys.")
|
||||
stdscr.addstr(6, 35, "Since startup on "+l10n.formatTimestamp(startuptime, False))
|
||||
stdscr.addstr(7, 40, "Processed "+str(shared.numberOfMessagesProcessed).ljust(4)+" person-to-person messages.")
|
||||
stdscr.addstr(8, 40, "Processed "+str(shared.numberOfBroadcastsProcessed).ljust(4)+" broadcast messages.")
|
||||
stdscr.addstr(9, 40, "Processed "+str(shared.numberOfPubkeysProcessed).ljust(4)+" public keys.")
|
||||
|
||||
# Inventory data
|
||||
stdscr.addstr(11, 35, "Inventory lookups per second: " + str(inventorydata).ljust(3))
|
||||
stdscr.addstr(11, 35, "Inventory lookups per second: "+str(inventorydata).ljust(3))
|
||||
|
||||
# Log
|
||||
stdscr.addstr(13, 6, "Log", curses.A_BOLD)
|
||||
n = log.count('\n')
|
||||
if n > 0:
|
||||
lg = log.split('\n')
|
||||
l = log.split('\n')
|
||||
if n > 512:
|
||||
del lg[:(n - 256)]
|
||||
del l[:(n-256)]
|
||||
logpad.erase()
|
||||
n = len(lg)
|
||||
for i, item in enumerate(lg):
|
||||
n = len(l)
|
||||
for i, item in enumerate(l):
|
||||
a = 0
|
||||
if item and item[0] == '!':
|
||||
if len(item) > 0 and item[0] == '!':
|
||||
a = curses.color_pair(1)
|
||||
item = item[1:]
|
||||
logpad.addstr(i, 0, item, a)
|
||||
logpad.refresh(n - curses.LINES + 2, 0, 14, 6, curses.LINES - 2, curses.COLS - 7)
|
||||
logpad.refresh(n-curses.LINES+2, 0, 14, 6, curses.LINES-2, curses.COLS-7)
|
||||
stdscr.refresh()
|
||||
|
||||
|
||||
def redraw(stdscr):
|
||||
"""Redraw menu"""
|
||||
stdscr.erase()
|
||||
stdscr.border()
|
||||
drawmenu(stdscr)
|
||||
stdscr.refresh()
|
||||
|
||||
|
||||
def dialogreset(stdscr):
|
||||
"""Resetting dialogue"""
|
||||
stdscr.clear()
|
||||
stdscr.keypad(1)
|
||||
curses.curs_set(0)
|
||||
|
||||
|
||||
# pylint: disable=too-many-branches, too-many-statements
|
||||
def handlech(c, stdscr):
|
||||
"""Handle character given on the command-line interface"""
|
||||
# pylint: disable=redefined-outer-name, too-many-nested-blocks, too-many-locals
|
||||
if c != curses.ERR:
|
||||
global inboxcur, addrcur, sentcur, subcur, abookcur, blackcur
|
||||
if c in range(256):
|
||||
|
@ -330,17 +289,15 @@ def handlech(c, stdscr):
|
|||
global menutab
|
||||
menutab = int(chr(c))
|
||||
elif chr(c) == 'q':
|
||||
global quit_
|
||||
quit_ = True
|
||||
global quit
|
||||
quit = True
|
||||
elif chr(c) == '\n':
|
||||
curses.curs_set(1)
|
||||
d = Dialog(dialog="dialog")
|
||||
if menutab == 1:
|
||||
set_background_title(d, "Inbox Message Dialog Box")
|
||||
r, t = d.menu(
|
||||
"Do what with \"" + inbox[inboxcur][5] + "\" from \"" + inbox[inboxcur][3] + "\"?",
|
||||
choices=[
|
||||
("1", "View message"),
|
||||
r, t = d.menu("Do what with \""+inbox[inboxcur][5]+"\" from \""+inbox[inboxcur][3]+"\"?",
|
||||
choices=[("1", "View message"),
|
||||
("2", "Mark message as unread"),
|
||||
("3", "Reply"),
|
||||
("4", "Add sender to Address Book"),
|
||||
|
@ -348,16 +305,8 @@ def handlech(c, stdscr):
|
|||
("6", "Move to trash")])
|
||||
if r == d.DIALOG_OK:
|
||||
if t == "1": # View
|
||||
set_background_title(
|
||||
d,
|
||||
"\"" +
|
||||
inbox[inboxcur][5] +
|
||||
"\" from \"" +
|
||||
inbox[inboxcur][3] +
|
||||
"\" to \"" +
|
||||
inbox[inboxcur][1] +
|
||||
"\"")
|
||||
data = "" # pyint: disable=redefined-outer-name
|
||||
set_background_title(d, "\""+inbox[inboxcur][5]+"\" from \""+inbox[inboxcur][3]+"\" to \""+inbox[inboxcur][1]+"\"")
|
||||
data = ""
|
||||
ret = sqlQuery("SELECT message FROM inbox WHERE msgid=?", inbox[inboxcur][0])
|
||||
if ret != []:
|
||||
for row in ret:
|
||||
|
@ -365,12 +314,12 @@ def handlech(c, stdscr):
|
|||
data = shared.fixPotentiallyInvalidUTF8Data(data)
|
||||
msg = ""
|
||||
for i, item in enumerate(data.split("\n")):
|
||||
msg += fill(item, replace_whitespace=False) + "\n"
|
||||
scrollbox(d, unicode(ascii(msg)), 30, 80)
|
||||
msg += fill(item, replace_whitespace=False)+"\n"
|
||||
scrollbox(d, str(ascii(msg)), 30, 80)
|
||||
sqlExecute("UPDATE inbox SET read=1 WHERE msgid=?", inbox[inboxcur][0])
|
||||
inbox[inboxcur][7] = 1
|
||||
else:
|
||||
scrollbox(d, unicode("Could not fetch message."))
|
||||
scrollbox(d, str("Could not fetch message."))
|
||||
elif t == "2": # Mark unread
|
||||
sqlExecute("UPDATE inbox SET read=0 WHERE msgid=?", inbox[inboxcur][0])
|
||||
inbox[inboxcur][7] = 0
|
||||
|
@ -383,10 +332,8 @@ def handlech(c, stdscr):
|
|||
if fromaddr == item[2] and item[3] != 0:
|
||||
ischan = True
|
||||
break
|
||||
if not addresses[i][1]: # pylint: disable=undefined-loop-variable
|
||||
scrollbox(d, unicode(
|
||||
"Sending address disabled, please either enable it"
|
||||
"or choose a different address."))
|
||||
if not addresses[i][1]:
|
||||
scrollbox(d, str("Sending address disabled, please either enable it or choose a different address."))
|
||||
return
|
||||
toaddr = m[2]
|
||||
if ischan:
|
||||
|
@ -394,7 +341,7 @@ def handlech(c, stdscr):
|
|||
|
||||
subject = m[5]
|
||||
if not m[5][:4] == "Re: ":
|
||||
subject = "Re: " + m[5]
|
||||
subject = "Re: "+m[5]
|
||||
body = ""
|
||||
ret = sqlQuery("SELECT message FROM inbox WHERE msgid=?", m[0])
|
||||
if ret != []:
|
||||
|
@ -406,8 +353,8 @@ def handlech(c, stdscr):
|
|||
dialogreset(stdscr)
|
||||
elif t == "4": # Add to Address Book
|
||||
addr = inbox[inboxcur][4]
|
||||
if addr not in [item[1] for i, item in enumerate(addrbook)]:
|
||||
r, t = d.inputbox("Label for address \"" + addr + "\"")
|
||||
if addr not in [item[1] for i,item in enumerate(addrbook)]:
|
||||
r, t = d.inputbox("Label for address \""+addr+"\"")
|
||||
if r == d.DIALOG_OK:
|
||||
label = t
|
||||
sqlExecute("INSERT INTO addressbook VALUES (?,?)", label, addr)
|
||||
|
@ -416,10 +363,10 @@ def handlech(c, stdscr):
|
|||
addrbook.append([label, addr])
|
||||
addrbook.reverse()
|
||||
else:
|
||||
scrollbox(d, unicode("The selected address is already in the Address Book."))
|
||||
scrollbox(d, str("The selected address is already in the Address Book."))
|
||||
elif t == "5": # Save message
|
||||
set_background_title(d, "Save \"" + inbox[inboxcur][5] + "\" as text file")
|
||||
r, t = d.inputbox("Filename", init=inbox[inboxcur][5] + ".txt")
|
||||
set_background_title(d, "Save \""+inbox[inboxcur][5]+"\" as text file")
|
||||
r, t = d.inputbox("Filename", init=inbox[inboxcur][5]+".txt")
|
||||
if r == d.DIALOG_OK:
|
||||
msg = ""
|
||||
ret = sqlQuery("SELECT message FROM inbox WHERE msgid=?", inbox[inboxcur][0])
|
||||
|
@ -430,13 +377,11 @@ def handlech(c, stdscr):
|
|||
fh.write(msg)
|
||||
fh.close()
|
||||
else:
|
||||
scrollbox(d, unicode("Could not fetch message."))
|
||||
scrollbox(d, str("Could not fetch message."))
|
||||
elif t == "6": # Move to trash
|
||||
sqlExecute("UPDATE inbox SET folder='trash' WHERE msgid=?", inbox[inboxcur][0])
|
||||
del inbox[inboxcur]
|
||||
scrollbox(d, unicode(
|
||||
"Message moved to trash. There is no interface to view your trash,"
|
||||
" \nbut the message is still on disk if you are desperate to recover it."))
|
||||
scrollbox(d, str("Message moved to trash. There is no interface to view your trash, \nbut the message is still on disk if you are desperate to recover it."))
|
||||
elif menutab == 2:
|
||||
a = ""
|
||||
if addresses[addrcur][3] != 0: # if current address is a chan
|
||||
|
@ -444,58 +389,36 @@ def handlech(c, stdscr):
|
|||
sendMessage(addresses[addrcur][2], a)
|
||||
elif menutab == 3:
|
||||
set_background_title(d, "Sent Messages Dialog Box")
|
||||
r, t = d.menu(
|
||||
"Do what with \"" + sentbox[sentcur][4] + "\" to \"" + sentbox[sentcur][0] + "\"?",
|
||||
choices=[
|
||||
("1", "View message"),
|
||||
r, t = d.menu("Do what with \""+sentbox[sentcur][4]+"\" to \""+sentbox[sentcur][0]+"\"?",
|
||||
choices=[("1", "View message"),
|
||||
("2", "Move to trash")])
|
||||
if r == d.DIALOG_OK:
|
||||
if t == "1": # View
|
||||
set_background_title(
|
||||
d,
|
||||
"\"" +
|
||||
sentbox[sentcur][4] +
|
||||
"\" from \"" +
|
||||
sentbox[sentcur][3] +
|
||||
"\" to \"" +
|
||||
sentbox[sentcur][1] +
|
||||
"\"")
|
||||
set_background_title(d, "\""+sentbox[sentcur][4]+"\" from \""+sentbox[sentcur][3]+"\" to \""+sentbox[sentcur][1]+"\"")
|
||||
data = ""
|
||||
ret = sqlQuery(
|
||||
"SELECT message FROM sent WHERE subject=? AND ackdata=?",
|
||||
sentbox[sentcur][4],
|
||||
sentbox[sentcur][6])
|
||||
ret = sqlQuery("SELECT message FROM sent WHERE subject=? AND ackdata=?", sentbox[sentcur][4], sentbox[sentcur][6])
|
||||
if ret != []:
|
||||
for row in ret:
|
||||
data, = row
|
||||
data = shared.fixPotentiallyInvalidUTF8Data(data)
|
||||
msg = ""
|
||||
for i, item in enumerate(data.split("\n")):
|
||||
msg += fill(item, replace_whitespace=False) + "\n"
|
||||
scrollbox(d, unicode(ascii(msg)), 30, 80)
|
||||
msg += fill(item, replace_whitespace=False)+"\n"
|
||||
scrollbox(d, str(ascii(msg)), 30, 80)
|
||||
else:
|
||||
scrollbox(d, unicode("Could not fetch message."))
|
||||
scrollbox(d, str("Could not fetch message."))
|
||||
elif t == "2": # Move to trash
|
||||
sqlExecute(
|
||||
"UPDATE sent SET folder='trash' WHERE subject=? AND ackdata=?",
|
||||
sentbox[sentcur][4],
|
||||
sentbox[sentcur][6])
|
||||
sqlExecute("UPDATE sent SET folder='trash' WHERE subject=? AND ackdata=?", sentbox[sentcur][4], sentbox[sentcur][6])
|
||||
del sentbox[sentcur]
|
||||
scrollbox(d, unicode(
|
||||
"Message moved to trash. There is no interface to view your trash"
|
||||
" \nbut the message is still on disk if you are desperate to recover it."))
|
||||
scrollbox(d, str("Message moved to trash. There is no interface to view your trash, \nbut the message is still on disk if you are desperate to recover it."))
|
||||
elif menutab == 4:
|
||||
set_background_title(d, "Your Identities Dialog Box")
|
||||
if len(addresses) <= addrcur:
|
||||
r, t = d.menu(
|
||||
"Do what with addresses?",
|
||||
choices=[
|
||||
("1", "Create new address")])
|
||||
r, t = d.menu("Do what with addresses?",
|
||||
choices=[("1", "Create new address")])
|
||||
else:
|
||||
r, t = d.menu(
|
||||
"Do what with \"" + addresses[addrcur][0] + "\" : \"" + addresses[addrcur][2] + "\"?",
|
||||
choices=[
|
||||
("1", "Create new address"),
|
||||
r, t = d.menu("Do what with \""+addresses[addrcur][0]+"\" : \""+addresses[addrcur][2]+"\"?",
|
||||
choices=[("1", "Create new address"),
|
||||
("2", "Send a message from this address"),
|
||||
("3", "Rename"),
|
||||
("4", "Enable"),
|
||||
|
@ -505,39 +428,29 @@ def handlech(c, stdscr):
|
|||
if r == d.DIALOG_OK:
|
||||
if t == "1": # Create new address
|
||||
set_background_title(d, "Create new address")
|
||||
scrollbox(
|
||||
d, unicode(
|
||||
"Here you may generate as many addresses as you like.\n"
|
||||
scrollbox(d, str("Here you may generate as many addresses as you like.\n"
|
||||
"Indeed, creating and abandoning addresses is encouraged.\n"
|
||||
"Deterministic addresses have several pros and cons:\n"
|
||||
"\nPros:\n"
|
||||
" * You can recreate your addresses on any computer from memory\n"
|
||||
" * You need not worry about backing up your keys.dat file as long as you"
|
||||
" \n can remember your passphrase\n"
|
||||
" * You need not worry about backing up your keys.dat file as long as you \n can remember your passphrase\n"
|
||||
"Cons:\n"
|
||||
" * You must remember (or write down) your passphrase in order to recreate"
|
||||
" \n your keys if they are lost\n"
|
||||
" * You must remember (or write down) your passphrase in order to recreate \n your keys if they are lost\n"
|
||||
" * You must also remember the address version and stream numbers\n"
|
||||
" * If you choose a weak passphrase someone may be able to brute-force it"
|
||||
" \n and then send and receive messages as you"))
|
||||
r, t = d.menu(
|
||||
"Choose an address generation technique",
|
||||
choices=[
|
||||
("1", "Use a random number generator"),
|
||||
" * If you choose a weak passphrase someone may be able to brute-force it \n and then send and receive messages as you"))
|
||||
r, t = d.menu("Choose an address generation technique",
|
||||
choices=[("1", "Use a random number generator"),
|
||||
("2", "Use a passphrase")])
|
||||
if r == d.DIALOG_OK:
|
||||
if t == "1":
|
||||
set_background_title(d, "Randomly generate address")
|
||||
r, t = d.inputbox("Label (not shown to anyone except you)")
|
||||
label = ""
|
||||
if r == d.DIALOG_OK and t:
|
||||
if r == d.DIALOG_OK and len(t) > 0:
|
||||
label = t
|
||||
r, t = d.menu(
|
||||
"Choose a stream",
|
||||
choices=[("1", "Use the most available stream"),
|
||||
("", "(Best if this is the first of many addresses you will create)"),
|
||||
("2", "Use the same stream as an existing address"),
|
||||
("", "(Saves you some bandwidth and processing power)")])
|
||||
r, t = d.menu("Choose a stream",
|
||||
choices=[("1", "Use the most available stream"),("", "(Best if this is the first of many addresses you will create)"),
|
||||
("2", "Use the same stream as an existing address"),("", "(Saves you some bandwidth and processing power)")])
|
||||
if r == d.DIALOG_OK:
|
||||
if t == "1":
|
||||
stream = 1
|
||||
|
@ -549,63 +462,36 @@ def handlech(c, stdscr):
|
|||
if r == d.DIALOG_OK:
|
||||
stream = decodeAddress(addrs[int(t)][1])[2]
|
||||
shorten = False
|
||||
r, t = d.checklist(
|
||||
"Miscellaneous options",
|
||||
choices=[(
|
||||
"1",
|
||||
"Spend time shortening the address",
|
||||
1 if shorten else 0)])
|
||||
r, t = d.checklist("Miscellaneous options",
|
||||
choices=[("1", "Spend time shortening the address", 1 if shorten else 0)])
|
||||
if r == d.DIALOG_OK and "1" in t:
|
||||
shorten = True
|
||||
queues.addressGeneratorQueue.put((
|
||||
"createRandomAddress",
|
||||
4,
|
||||
stream,
|
||||
label,
|
||||
1,
|
||||
"",
|
||||
shorten))
|
||||
queues.addressGeneratorQueue.put(("createRandomAddress", 4, stream, label, 1, "", shorten))
|
||||
elif t == "2":
|
||||
set_background_title(d, "Make deterministic addresses")
|
||||
r, t = d.passwordform(
|
||||
"Enter passphrase",
|
||||
[
|
||||
("Passphrase", 1, 1, "", 2, 1, 64, 128),
|
||||
r, t = d.passwordform("Enter passphrase",
|
||||
[("Passphrase", 1, 1, "", 2, 1, 64, 128),
|
||||
("Confirm passphrase", 3, 1, "", 4, 1, 64, 128)],
|
||||
form_height=4, insecure=True)
|
||||
if r == d.DIALOG_OK:
|
||||
if t[0] == t[1]:
|
||||
passphrase = t[0]
|
||||
r, t = d.rangebox(
|
||||
"Number of addresses to generate",
|
||||
width=48,
|
||||
min=1,
|
||||
max=99,
|
||||
init=8)
|
||||
r, t = d.rangebox("Number of addresses to generate",
|
||||
width=48, min=1, max=99, init=8)
|
||||
if r == d.DIALOG_OK:
|
||||
number = t
|
||||
stream = 1
|
||||
shorten = False
|
||||
r, t = d.checklist(
|
||||
"Miscellaneous options",
|
||||
choices=[(
|
||||
"1",
|
||||
"Spend time shortening the address",
|
||||
1 if shorten else 0)])
|
||||
r, t = d.checklist("Miscellaneous options",
|
||||
choices=[("1", "Spend time shortening the address", 1 if shorten else 0)])
|
||||
if r == d.DIALOG_OK and "1" in t:
|
||||
shorten = True
|
||||
scrollbox(
|
||||
d, unicode(
|
||||
"In addition to your passphrase, be sure to remember the"
|
||||
" following numbers:\n"
|
||||
"\n * Address version number: " + str(4) + "\n"
|
||||
" * Stream number: " + str(stream)))
|
||||
queues.addressGeneratorQueue.put(
|
||||
('createDeterministicAddresses', 4, stream,
|
||||
"unused deterministic address", number,
|
||||
str(passphrase), shorten))
|
||||
scrollbox(d, str("In addition to your passphrase, be sure to remember the following numbers:\n"
|
||||
"\n * Address version number: "+str(4)+"\n"
|
||||
" * Stream number: "+str(stream)))
|
||||
queues.addressGeneratorQueue.put(('createDeterministicAddresses', 4, stream, "unused deterministic address", number, str(passphrase), shorten))
|
||||
else:
|
||||
scrollbox(d, unicode("Passphrases do not match"))
|
||||
scrollbox(d, str("Passphrases do not match"))
|
||||
elif t == "2": # Send a message
|
||||
a = ""
|
||||
if addresses[addrcur][3] != 0: # if current address is a chan
|
||||
|
@ -653,26 +539,23 @@ def handlech(c, stdscr):
|
|||
a = addresses[addrcur][2]
|
||||
set_background_title(d, "Special address behavior")
|
||||
if BMConfigParser().safeGetBoolean(a, "chan"):
|
||||
scrollbox(d, unicode(
|
||||
"This is a chan address. You cannot use it as a pseudo-mailing list."))
|
||||
scrollbox(d, str("This is a chan address. You cannot use it as a pseudo-mailing list."))
|
||||
else:
|
||||
m = BMConfigParser().safeGetBoolean(a, "mailinglist")
|
||||
r, t = d.radiolist(
|
||||
"Select address behavior",
|
||||
choices=[
|
||||
("1", "Behave as a normal address", not m),
|
||||
r, t = d.radiolist("Select address behavior",
|
||||
choices=[("1", "Behave as a normal address", not m),
|
||||
("2", "Behave as a pseudo-mailing-list address", m)])
|
||||
if r == d.DIALOG_OK:
|
||||
if t == "1" and m:
|
||||
if t == "1" and m == True:
|
||||
BMConfigParser().set(a, "mailinglist", "false")
|
||||
if addresses[addrcur][1]:
|
||||
addresses[addrcur][3] = 0 # Set color to black
|
||||
else:
|
||||
addresses[addrcur][3] = 8 # Set color to gray
|
||||
elif t == "2" and m is False:
|
||||
elif t == "2" and m == False:
|
||||
try:
|
||||
mn = BMConfigParser().get(a, "mailinglistname")
|
||||
except ConfigParser.NoOptionError:
|
||||
except configparser.NoOptionError:
|
||||
mn = ""
|
||||
r, t = d.inputbox("Mailing list name", init=mn)
|
||||
if r == d.DIALOG_OK:
|
||||
|
@ -685,15 +568,11 @@ def handlech(c, stdscr):
|
|||
elif menutab == 5:
|
||||
set_background_title(d, "Subscriptions Dialog Box")
|
||||
if len(subscriptions) <= subcur:
|
||||
r, t = d.menu(
|
||||
"Do what with subscription to \"" + subscriptions[subcur][0] + "\"?",
|
||||
choices=[
|
||||
("1", "Add new subscription")])
|
||||
r, t = d.menu("Do what with subscription to \""+subscriptions[subcur][0]+"\"?",
|
||||
choices=[("1", "Add new subscription")])
|
||||
else:
|
||||
r, t = d.menu(
|
||||
"Do what with subscription to \"" + subscriptions[subcur][0] + "\"?",
|
||||
choices=[
|
||||
("1", "Add new subscription"),
|
||||
r, t = d.menu("Do what with subscription to \""+subscriptions[subcur][0]+"\"?",
|
||||
choices=[("1", "Add new subscription"),
|
||||
("2", "Delete this subscription"),
|
||||
("3", "Enable"),
|
||||
("4", "Disable")])
|
||||
|
@ -714,39 +593,27 @@ def handlech(c, stdscr):
|
|||
sqlExecute("INSERT INTO subscriptions VALUES (?,?,?)", label, addr, True)
|
||||
shared.reloadBroadcastSendersForWhichImWatching()
|
||||
elif t == "2":
|
||||
r, t = d.inputbox("Type in \"I want to delete this subscription\"")
|
||||
r, t = d.inpuxbox("Type in \"I want to delete this subscription\"")
|
||||
if r == d.DIALOG_OK and t == "I want to delete this subscription":
|
||||
sqlExecute(
|
||||
"DELETE FROM subscriptions WHERE label=? AND address=?",
|
||||
subscriptions[subcur][0],
|
||||
subscriptions[subcur][1])
|
||||
sqlExecute("DELETE FROM subscriptions WHERE label=? AND address=?", subscriptions[subcur][0], subscriptions[subcur][1])
|
||||
shared.reloadBroadcastSendersForWhichImWatching()
|
||||
del subscriptions[subcur]
|
||||
elif t == "3":
|
||||
sqlExecute(
|
||||
"UPDATE subscriptions SET enabled=1 WHERE label=? AND address=?",
|
||||
subscriptions[subcur][0],
|
||||
subscriptions[subcur][1])
|
||||
sqlExecute("UPDATE subscriptions SET enabled=1 WHERE label=? AND address=?", subscriptions[subcur][0], subscriptions[subcur][1])
|
||||
shared.reloadBroadcastSendersForWhichImWatching()
|
||||
subscriptions[subcur][2] = True
|
||||
elif t == "4":
|
||||
sqlExecute(
|
||||
"UPDATE subscriptions SET enabled=0 WHERE label=? AND address=?",
|
||||
subscriptions[subcur][0],
|
||||
subscriptions[subcur][1])
|
||||
sqlExecute("UPDATE subscriptions SET enabled=0 WHERE label=? AND address=?", subscriptions[subcur][0], subscriptions[subcur][1])
|
||||
shared.reloadBroadcastSendersForWhichImWatching()
|
||||
subscriptions[subcur][2] = False
|
||||
elif menutab == 6:
|
||||
set_background_title(d, "Address Book Dialog Box")
|
||||
if len(addrbook) <= abookcur:
|
||||
r, t = d.menu(
|
||||
"Do what with addressbook?",
|
||||
r, t = d.menu("Do what with addressbook?",
|
||||
choices=[("3", "Add new address to Address Book")])
|
||||
else:
|
||||
r, t = d.menu(
|
||||
"Do what with \"" + addrbook[abookcur][0] + "\" : \"" + addrbook[abookcur][1] + "\"",
|
||||
choices=[
|
||||
("1", "Send a message to this address"),
|
||||
r, t = d.menu("Do what with \""+addrbook[abookcur][0]+"\" : \""+addrbook[abookcur][1]+"\"",
|
||||
choices=[("1", "Send a message to this address"),
|
||||
("2", "Subscribe to this address"),
|
||||
("3", "Add new address to Address Book"),
|
||||
("4", "Delete this address")])
|
||||
|
@ -768,8 +635,8 @@ def handlech(c, stdscr):
|
|||
r, t = d.inputbox("Input new address")
|
||||
if r == d.DIALOG_OK:
|
||||
addr = t
|
||||
if addr not in [item[1] for i, item in enumerate(addrbook)]:
|
||||
r, t = d.inputbox("Label for address \"" + addr + "\"")
|
||||
if addr not in [item[1] for i,item in enumerate(addrbook)]:
|
||||
r, t = d.inputbox("Label for address \""+addr+"\"")
|
||||
if r == d.DIALOG_OK:
|
||||
sqlExecute("INSERT INTO addressbook VALUES (?,?)", t, addr)
|
||||
# Prepend entry
|
||||
|
@ -777,43 +644,29 @@ def handlech(c, stdscr):
|
|||
addrbook.append([t, addr])
|
||||
addrbook.reverse()
|
||||
else:
|
||||
scrollbox(d, unicode("The selected address is already in the Address Book."))
|
||||
scrollbox(d, str("The selected address is already in the Address Book."))
|
||||
elif t == "4":
|
||||
r, t = d.inputbox("Type in \"I want to delete this Address Book entry\"")
|
||||
if r == d.DIALOG_OK and t == "I want to delete this Address Book entry":
|
||||
sqlExecute(
|
||||
"DELETE FROM addressbook WHERE label=? AND address=?",
|
||||
addrbook[abookcur][0],
|
||||
addrbook[abookcur][1])
|
||||
sqlExecute("DELETE FROM addressbook WHERE label=? AND address=?", addrbook[abookcur][0], addrbook[abookcur][1])
|
||||
del addrbook[abookcur]
|
||||
elif menutab == 7:
|
||||
set_background_title(d, "Blacklist Dialog Box")
|
||||
r, t = d.menu(
|
||||
"Do what with \"" + blacklist[blackcur][0] + "\" : \"" + blacklist[blackcur][1] + "\"?",
|
||||
choices=[
|
||||
("1", "Delete"),
|
||||
r, t = d.menu("Do what with \""+blacklist[blackcur][0]+"\" : \""+blacklist[blackcur][1]+"\"?",
|
||||
choices=[("1", "Delete"),
|
||||
("2", "Enable"),
|
||||
("3", "Disable")])
|
||||
if r == d.DIALOG_OK:
|
||||
if t == "1":
|
||||
r, t = d.inputbox("Type in \"I want to delete this Blacklist entry\"")
|
||||
if r == d.DIALOG_OK and t == "I want to delete this Blacklist entry":
|
||||
sqlExecute(
|
||||
"DELETE FROM blacklist WHERE label=? AND address=?",
|
||||
blacklist[blackcur][0],
|
||||
blacklist[blackcur][1])
|
||||
sqlExecute("DELETE FROM blacklist WHERE label=? AND address=?", blacklist[blackcur][0], blacklist[blackcur][1])
|
||||
del blacklist[blackcur]
|
||||
elif t == "2":
|
||||
sqlExecute(
|
||||
"UPDATE blacklist SET enabled=1 WHERE label=? AND address=?",
|
||||
blacklist[blackcur][0],
|
||||
blacklist[blackcur][1])
|
||||
sqlExecute("UPDATE blacklist SET enabled=1 WHERE label=? AND address=?", blacklist[blackcur][0], blacklist[blackcur][1])
|
||||
blacklist[blackcur][2] = True
|
||||
elif t == "3":
|
||||
sqlExecute(
|
||||
"UPDATE blacklist SET enabled=0 WHERE label=? AND address=?",
|
||||
blacklist[blackcur][0],
|
||||
blacklist[blackcur][1])
|
||||
elif t== "3":
|
||||
sqlExecute("UPDATE blacklist SET enabled=0 WHERE label=? AND address=?", blacklist[blackcur][0], blacklist[blackcur][1])
|
||||
blacklist[blackcur][2] = False
|
||||
dialogreset(stdscr)
|
||||
else:
|
||||
|
@ -831,17 +684,17 @@ def handlech(c, stdscr):
|
|||
if menutab == 7 and blackcur > 0:
|
||||
blackcur -= 1
|
||||
elif c == curses.KEY_DOWN:
|
||||
if menutab == 1 and inboxcur < len(inbox) - 1:
|
||||
if menutab == 1 and inboxcur < len(inbox)-1:
|
||||
inboxcur += 1
|
||||
if (menutab == 2 or menutab == 4) and addrcur < len(addresses) - 1:
|
||||
if (menutab == 2 or menutab == 4) and addrcur < len(addresses)-1:
|
||||
addrcur += 1
|
||||
if menutab == 3 and sentcur < len(sentbox) - 1:
|
||||
if menutab == 3 and sentcur < len(sentbox)-1:
|
||||
sentcur += 1
|
||||
if menutab == 5 and subcur < len(subscriptions) - 1:
|
||||
if menutab == 5 and subcur < len(subscriptions)-1:
|
||||
subcur += 1
|
||||
if menutab == 6 and abookcur < len(addrbook) - 1:
|
||||
if menutab == 6 and abookcur < len(addrbook)-1:
|
||||
abookcur += 1
|
||||
if menutab == 7 and blackcur < len(blacklist) - 1:
|
||||
if menutab == 7 and blackcur < len(blacklist)-1:
|
||||
blackcur += 1
|
||||
elif c == curses.KEY_HOME:
|
||||
if menutab == 1:
|
||||
|
@ -858,42 +711,33 @@ def handlech(c, stdscr):
|
|||
blackcur = 0
|
||||
elif c == curses.KEY_END:
|
||||
if menutab == 1:
|
||||
inboxcur = len(inbox) - 1
|
||||
inboxcur = len(inbox)-1
|
||||
if menutab == 2 or menutab == 4:
|
||||
addrcur = len(addresses) - 1
|
||||
addrcur = len(addresses)-1
|
||||
if menutab == 3:
|
||||
sentcur = len(sentbox) - 1
|
||||
sentcur = len(sentbox)-1
|
||||
if menutab == 5:
|
||||
subcur = len(subscriptions) - 1
|
||||
subcur = len(subscriptions)-1
|
||||
if menutab == 6:
|
||||
abookcur = len(addrbook) - 1
|
||||
abookcur = len(addrbook)-1
|
||||
if menutab == 7:
|
||||
blackcur = len(blackcur) - 1
|
||||
blackcur = len(blackcur)-1
|
||||
redraw(stdscr)
|
||||
|
||||
|
||||
# pylint: disable=too-many-locals, too-many-arguments
|
||||
def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=False):
|
||||
"""Method for message sending"""
|
||||
if sender == "":
|
||||
return
|
||||
d = Dialog(dialog="dialog")
|
||||
set_background_title(d, "Send a message")
|
||||
if recv == "":
|
||||
r, t = d.inputbox(
|
||||
"Recipient address (Cancel to load from the Address Book or leave blank to broadcast)",
|
||||
10,
|
||||
60)
|
||||
r, t = d.inputbox("Recipient address (Cancel to load from the Address Book or leave blank to broadcast)", 10, 60)
|
||||
if r != d.DIALOG_OK:
|
||||
global menutab
|
||||
menutab = 6
|
||||
return
|
||||
recv = t
|
||||
if broadcast is None and sender != recv:
|
||||
r, t = d.radiolist(
|
||||
"How to send the message?",
|
||||
choices=[
|
||||
("1", "Send to one or more specific people", 1),
|
||||
if broadcast == None and sender != recv:
|
||||
r, t = d.radiolist("How to send the message?",
|
||||
choices=[("1", "Send to one or more specific people", 1),
|
||||
("2", "Broadcast to everyone who is subscribed to your address", 0)])
|
||||
if r != d.DIALOG_OK:
|
||||
return
|
||||
|
@ -914,12 +758,12 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
|
|||
|
||||
if not broadcast:
|
||||
recvlist = []
|
||||
for _, item in enumerate(recv.replace(",", ";").split(";")):
|
||||
for i, item in enumerate(recv.replace(",", ";").split(";")):
|
||||
recvlist.append(item.strip())
|
||||
list(set(recvlist)) # Remove exact duplicates
|
||||
for addr in recvlist:
|
||||
if addr != "":
|
||||
status, version, stream = decodeAddress(addr)[:3]
|
||||
status, version, stream, ripe = decodeAddress(addr)
|
||||
if status != "success":
|
||||
set_background_title(d, "Recipient address error")
|
||||
err = "Could not decode" + addr + " : " + status + "\n\n"
|
||||
|
@ -930,58 +774,78 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
|
|||
elif status == "invalidcharacters":
|
||||
err += "The address contains invalid characters."
|
||||
elif status == "versiontoohigh":
|
||||
err += ("The address version is too high. Either you need to upgrade your Bitmessage software"
|
||||
" or your acquaintance is doing something clever.")
|
||||
err += "The address version is too high. Either you need to upgrade your Bitmessage software or your acquaintance is doing something clever."
|
||||
elif status == "ripetooshort":
|
||||
err += ("Some data encoded in the address is too short. There might be something wrong with"
|
||||
" the software of your acquaintance.")
|
||||
err += "Some data encoded in the address is too short. There might be something wrong with the software of your acquaintance."
|
||||
elif status == "ripetoolong":
|
||||
err += ("Some data encoded in the address is too long. There might be something wrong with"
|
||||
" the software of your acquaintance.")
|
||||
err += "Some data encoded in the address is too long. There might be something wrong with the software of your acquaintance."
|
||||
elif status == "varintmalformed":
|
||||
err += ("Some data encoded in the address is malformed. There might be something wrong with"
|
||||
" the software of your acquaintance.")
|
||||
err += "Some data encoded in the address is malformed. There might be something wrong with the software of your acquaintance."
|
||||
else:
|
||||
err += "It is unknown what is wrong with the address."
|
||||
scrollbox(d, unicode(err))
|
||||
scrollbox(d, str(err))
|
||||
else:
|
||||
addr = addBMIfNotPresent(addr)
|
||||
if version > 4 or version <= 1:
|
||||
set_background_title(d, "Recipient address error")
|
||||
scrollbox(d, unicode(
|
||||
"Could not understand version number " +
|
||||
version +
|
||||
"of address" +
|
||||
addr +
|
||||
"."))
|
||||
scrollbox(d, str("Could not understand version number " + version + "of address" + addr + "."))
|
||||
continue
|
||||
if stream > 1 or stream == 0:
|
||||
set_background_title(d, "Recipient address error")
|
||||
scrollbox(d, unicode(
|
||||
"Bitmessage currently only supports stream numbers of 1,"
|
||||
"unlike as requested for address " + addr + "."))
|
||||
scrollbox(d, str("Bitmessage currently only supports stream numbers of 1, unlike as requested for address " + addr + "."))
|
||||
continue
|
||||
if not network.stats.connectedHostsList():
|
||||
set_background_title(d, "Not connected warning")
|
||||
scrollbox(d, unicode("Because you are not currently connected to the network, "))
|
||||
helper_sent.insert(
|
||||
toAddress=addr, fromAddress=sender, subject=subject, message=body)
|
||||
scrollbox(d, str("Because you are not currently connected to the network, "))
|
||||
stealthLevel = BMConfigParser().safeGetInt('bitmessagesettings', 'ackstealthlevel')
|
||||
ackdata = genAckPayload(streamNumber, stealthLevel)
|
||||
sqlExecute(
|
||||
"INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
||||
"",
|
||||
addr,
|
||||
ripe,
|
||||
sender,
|
||||
subject,
|
||||
body,
|
||||
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.
|
||||
"msgqueued",
|
||||
0, # retryNumber
|
||||
"sent",
|
||||
2, # encodingType
|
||||
BMConfigParser().getint('bitmessagesettings', 'ttl'))
|
||||
queues.workerQueue.put(("sendmessage", addr))
|
||||
else: # Broadcast
|
||||
if recv == "":
|
||||
set_background_title(d, "Empty sender error")
|
||||
scrollbox(d, unicode("You must specify an address to send the message from."))
|
||||
scrollbox(d, str("You must specify an address to send the message from."))
|
||||
else:
|
||||
# dummy ackdata, no need for stealth
|
||||
helper_sent.insert(
|
||||
fromAddress=sender, subject=subject,
|
||||
message=body, status='broadcastqueued')
|
||||
ackdata = genAckPayload(streamNumber, 0)
|
||||
recv = BROADCAST_STR
|
||||
ripe = ""
|
||||
sqlExecute(
|
||||
"INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
||||
"",
|
||||
recv,
|
||||
ripe,
|
||||
sender,
|
||||
subject,
|
||||
body,
|
||||
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
|
||||
2, # encodingType
|
||||
BMConfigParser().getint('bitmessagesettings', 'ttl'))
|
||||
queues.workerQueue.put(('sendbroadcast', ''))
|
||||
|
||||
|
||||
# pylint: disable=redefined-outer-name, too-many-locals
|
||||
def loadInbox():
|
||||
"""Load the list of messages"""
|
||||
sys.stdout = sys.__stdout__
|
||||
print("Loading inbox messages...")
|
||||
sys.stdout = printlog
|
||||
|
@ -1027,13 +891,10 @@ def loadInbox():
|
|||
fromlabel = shared.fixPotentiallyInvalidUTF8Data(fromlabel)
|
||||
|
||||
# Load into array
|
||||
inbox.append([msgid, tolabel, toaddr, fromlabel, fromaddr, subject, l10n.formatTimestamp(
|
||||
received, False), read])
|
||||
inbox.append([msgid, tolabel, toaddr, fromlabel, fromaddr, subject,
|
||||
l10n.formatTimestamp(received, False), read])
|
||||
inbox.reverse()
|
||||
|
||||
|
||||
def loadSent():
|
||||
"""Load the messages that sent"""
|
||||
sys.stdout = sys.__stdout__
|
||||
print("Loading sent messages...")
|
||||
sys.stdout = printlog
|
||||
|
@ -1081,20 +942,20 @@ def loadSent():
|
|||
statstr = "Message queued"
|
||||
elif status == "msgsent":
|
||||
t = l10n.formatTimestamp(lastactiontime, False)
|
||||
statstr = "Message sent at " + t + ".Waiting for acknowledgement."
|
||||
statstr = "Message sent at "+t+".Waiting for acknowledgement."
|
||||
elif status == "msgsentnoackexpected":
|
||||
t = l10n.formatTimestamp(lastactiontime, False)
|
||||
statstr = "Message sent at " + t + "."
|
||||
statstr = "Message sent at "+t+"."
|
||||
elif status == "doingmsgpow":
|
||||
statstr = "The proof of work required to send the message has been queued."
|
||||
elif status == "ackreceived":
|
||||
t = l10n.formatTimestamp(lastactiontime, False)
|
||||
statstr = "Acknowledgment of the message received at " + t + "."
|
||||
statstr = "Acknowledgment of the message received at "+t+"."
|
||||
elif status == "broadcastqueued":
|
||||
statstr = "Broadcast queued."
|
||||
elif status == "broadcastsent":
|
||||
t = l10n.formatTimestamp(lastactiontime, False)
|
||||
statstr = "Broadcast sent at " + t + "."
|
||||
statstr = "Broadcast sent at "+t+"."
|
||||
elif status == "forcepow":
|
||||
statstr = "Forced difficulty override. Message will start sending soon."
|
||||
elif status == "badkey":
|
||||
|
@ -1103,23 +964,13 @@ def loadSent():
|
|||
statstr = "Error: The work demanded by the recipient is more difficult than you are willing to do."
|
||||
else:
|
||||
t = l10n.formatTimestamp(lastactiontime, False)
|
||||
statstr = "Unknown status " + status + " at " + t + "."
|
||||
statstr = "Unknown status "+status+" at "+t+"."
|
||||
|
||||
# Load into array
|
||||
sentbox.append([
|
||||
tolabel,
|
||||
toaddr,
|
||||
fromlabel,
|
||||
fromaddr,
|
||||
subject,
|
||||
statstr,
|
||||
ackdata,
|
||||
sentbox.append([tolabel, toaddr, fromlabel, fromaddr, subject, statstr, ackdata,
|
||||
l10n.formatTimestamp(lastactiontime, False)])
|
||||
sentbox.reverse()
|
||||
|
||||
|
||||
def loadAddrBook():
|
||||
"""Load address book"""
|
||||
sys.stdout = sys.__stdout__
|
||||
print("Loading address book...")
|
||||
sys.stdout = printlog
|
||||
|
@ -1130,19 +981,13 @@ def loadAddrBook():
|
|||
label = shared.fixPotentiallyInvalidUTF8Data(label)
|
||||
addrbook.append([label, addr])
|
||||
addrbook.reverse()
|
||||
|
||||
|
||||
def loadSubscriptions():
|
||||
"""Load subscription functionality"""
|
||||
ret = sqlQuery("SELECT label, address, enabled FROM subscriptions")
|
||||
for row in ret:
|
||||
label, address, enabled = row
|
||||
subscriptions.append([label, address, enabled])
|
||||
subscriptions.reverse()
|
||||
|
||||
|
||||
def loadBlackWhiteList():
|
||||
"""load black/white list"""
|
||||
global bwtype
|
||||
bwtype = BMConfigParser().get("bitmessagesettings", "blackwhitelist")
|
||||
if bwtype == "black":
|
||||
|
@ -1154,12 +999,11 @@ def loadBlackWhiteList():
|
|||
blacklist.append([label, address, enabled])
|
||||
blacklist.reverse()
|
||||
|
||||
|
||||
def runwrapper():
|
||||
"""Main method"""
|
||||
sys.stdout = printlog
|
||||
# sys.stderr = errlog
|
||||
#sys.stderr = errlog
|
||||
|
||||
# Load messages from database
|
||||
loadInbox()
|
||||
loadSent()
|
||||
loadAddrBook()
|
||||
|
@ -1178,9 +1022,7 @@ def runwrapper():
|
|||
curses.wrapper(run)
|
||||
doShutdown()
|
||||
|
||||
|
||||
def run(stdscr):
|
||||
"""Main loop"""
|
||||
# Schedule inventory lookup data
|
||||
resetlookups()
|
||||
|
||||
|
@ -1209,28 +1051,27 @@ def run(stdscr):
|
|||
addresses.append([BMConfigParser().get(addressInKeysFile, "label"), isEnabled, addressInKeysFile])
|
||||
# Set address color
|
||||
if not isEnabled:
|
||||
addresses[len(addresses) - 1].append(8) # gray
|
||||
addresses[len(addresses)-1].append(8) # gray
|
||||
elif BMConfigParser().safeGetBoolean(addressInKeysFile, 'chan'):
|
||||
addresses[len(addresses) - 1].append(9) # orange
|
||||
addresses[len(addresses)-1].append(9) # orange
|
||||
elif BMConfigParser().safeGetBoolean(addressInKeysFile, 'mailinglist'):
|
||||
addresses[len(addresses) - 1].append(5) # magenta
|
||||
addresses[len(addresses)-1].append(5) # magenta
|
||||
else:
|
||||
addresses[len(addresses) - 1].append(0) # black
|
||||
addresses[len(addresses)-1].append(0) # black
|
||||
addresses.reverse()
|
||||
|
||||
stdscr.clear()
|
||||
redraw(stdscr)
|
||||
while quit_ is False:
|
||||
while quit == False:
|
||||
drawtab(stdscr)
|
||||
handlech(stdscr.getch(), stdscr)
|
||||
|
||||
|
||||
def doShutdown():
|
||||
"""Shutting the app down"""
|
||||
sys.stdout = sys.__stdout__
|
||||
print("Shutting down...")
|
||||
sys.stdout = printlog
|
||||
shutdown.doCleanShutdown()
|
||||
sys.stdout = sys.__stdout__
|
||||
sys.stderr = sys.__stderr__
|
||||
os._exit(0) # pylint: disable=protected-access
|
||||
|
||||
os._exit(0)
|
||||
|
|
0
src/bitmessagekivy/__init__.py
Normal file
0
src/bitmessagekivy/__init__.py
Normal file
52
src/bitmessagekivy/kivy_helper_search.py
Normal file
52
src/bitmessagekivy/kivy_helper_search.py
Normal file
|
@ -0,0 +1,52 @@
|
|||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import *
|
||||
from helper_sql import *
|
||||
|
||||
|
||||
def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, what=None, unreadOnly=False):
|
||||
if what is not None and what != "":
|
||||
what = "%" + what + "%"
|
||||
else:
|
||||
what = None
|
||||
|
||||
if folder == "sent":
|
||||
sqlStatementBase = '''
|
||||
SELECT toaddress, fromaddress, subject, status, ackdata, lastactiontime
|
||||
FROM sent '''
|
||||
else:
|
||||
sqlStatementBase = '''SELECT folder, msgid, toaddress, fromaddress, subject, received, read
|
||||
FROM inbox '''
|
||||
sqlStatementParts = []
|
||||
sqlArguments = []
|
||||
if account is not None:
|
||||
if xAddress == 'both':
|
||||
sqlStatementParts.append("(fromaddress = ? OR toaddress = ?)")
|
||||
sqlArguments.append(account)
|
||||
sqlArguments.append(account)
|
||||
else:
|
||||
sqlStatementParts.append(xAddress + " = ? ")
|
||||
sqlArguments.append(account)
|
||||
if folder is not None:
|
||||
if folder == "new":
|
||||
folder = "inbox"
|
||||
unreadOnly = True
|
||||
sqlStatementParts.append("folder = ? ")
|
||||
sqlArguments.append(folder)
|
||||
else:
|
||||
sqlStatementParts.append("folder != ?")
|
||||
sqlArguments.append("trash")
|
||||
if what is not None:
|
||||
sqlStatementParts.append("%s LIKE ?" % (where))
|
||||
sqlArguments.append(what)
|
||||
if unreadOnly:
|
||||
sqlStatementParts.append("read = 0")
|
||||
if len(sqlStatementParts) > 0:
|
||||
sqlStatementBase += "WHERE " + " AND ".join(sqlStatementParts)
|
||||
if folder == "sent":
|
||||
sqlStatementBase += " ORDER BY lastactiontime"
|
||||
return sqlQuery(sqlStatementBase, sqlArguments)
|
354
src/bitmessagekivy/main.kv
Normal file
354
src/bitmessagekivy/main.kv
Normal file
|
@ -0,0 +1,354 @@
|
|||
#:import la kivy.adapters.listadapter
|
||||
#:import factory kivy.factory
|
||||
#:import mpybit bitmessagekivy.mpybit
|
||||
#:import C kivy.utils.get_color_from_hex
|
||||
|
||||
<Navigator>:
|
||||
id: nav_drawer
|
||||
NavigationDrawerIconButton:
|
||||
Spinner:
|
||||
pos_hint:{"x":0,"y":.3}
|
||||
id: btn
|
||||
background_color: app.theme_cls.primary_dark
|
||||
text: app.showmeaddresses(name='text')
|
||||
values: app.showmeaddresses(name='values')
|
||||
on_text:app.getCurrentAccountData(self.text)
|
||||
|
||||
NavigationDrawerIconButton:
|
||||
icon: 'email-open'
|
||||
text: "inbox"
|
||||
on_release: app.root.ids.scr_mngr.current = 'inbox'
|
||||
NavigationDrawerIconButton:
|
||||
icon: 'mail-send'
|
||||
text: "sent"
|
||||
on_release: app.root.ids.scr_mngr.current = 'sent'
|
||||
NavigationDrawerIconButton:
|
||||
icon: 'dropbox'
|
||||
text: "trash"
|
||||
on_release: app.root.ids.scr_mngr.current = 'trash'
|
||||
NavigationDrawerIconButton:
|
||||
icon: 'email'
|
||||
text: "drafts"
|
||||
on_release: app.root.ids.scr_mngr.current = 'dialog'
|
||||
NavigationDrawerIconButton:
|
||||
icon: 'markunread-mailbox'
|
||||
text: "test"
|
||||
on_release: app.root.ids.scr_mngr.current = 'test'
|
||||
NavigationDrawerIconButton:
|
||||
text: "new identity"
|
||||
icon:'accounts-add'
|
||||
on_release: app.root.ids.scr_mngr.current = 'newidentity'
|
||||
|
||||
BoxLayout:
|
||||
orientation: 'vertical'
|
||||
Toolbar:
|
||||
id: toolbar
|
||||
title: app.getCurrentAccount()
|
||||
background_color: app.theme_cls.primary_dark
|
||||
left_action_items: [['menu', lambda x: app.nav_drawer.toggle()]]
|
||||
Button:
|
||||
text:"EXIT"
|
||||
color: 0,0,0,1
|
||||
background_color: (0,0,0,0)
|
||||
size_hint_y: 0.4
|
||||
size_hint_x: 0.1
|
||||
pos_hint: {'x': 0.8, 'y':0.4}
|
||||
on_press: app.say_exit()
|
||||
|
||||
|
||||
ScreenManager:
|
||||
id: scr_mngr
|
||||
Inbox:
|
||||
id:sc1
|
||||
Sent:
|
||||
id:sc2
|
||||
Trash:
|
||||
id:sc3
|
||||
Dialog:
|
||||
id:sc4
|
||||
Test:
|
||||
id:sc5
|
||||
Create:
|
||||
id:sc6
|
||||
NewIdentity:
|
||||
id:sc7
|
||||
Page:
|
||||
id:sc8
|
||||
AddressSuccessful:
|
||||
id:sc9
|
||||
|
||||
Button:
|
||||
id:create
|
||||
height:100
|
||||
size_hint_y: 0.13
|
||||
size_hint_x: 0.1
|
||||
pos_hint: {'x': 0.85, 'y': 0.5}
|
||||
background_color: (0,0,0,0)
|
||||
on_press: scr_mngr.current = 'create'
|
||||
Image:
|
||||
source: 'images/plus.png'
|
||||
y: self.parent.y - 7.5
|
||||
x: self.parent.x + self.parent.width - 50
|
||||
size: 70, 70
|
||||
|
||||
<SwipeButton@Carousel>:
|
||||
text: ''
|
||||
size_hint_y: None
|
||||
height: 48
|
||||
ignore_perpendicular_swipes: True
|
||||
data_index: 0
|
||||
min_move: 20 / self.width
|
||||
|
||||
on__offset: app.update_index(root.data_index, self.index)
|
||||
|
||||
canvas.before:
|
||||
Color:
|
||||
rgba: C('FFFFFF33')
|
||||
|
||||
Rectangle:
|
||||
pos: self.pos
|
||||
size: self.size
|
||||
|
||||
Line:
|
||||
rectangle: self.pos + self.size
|
||||
|
||||
Button:
|
||||
text: 'delete ({}:{})'.format(root.text, root.data_index)
|
||||
on_press: app.delete(root.data_index)
|
||||
|
||||
Button:
|
||||
text: root.text
|
||||
on_press: app.getInboxMessageDetail(self.text)
|
||||
|
||||
Button:
|
||||
text: 'archive'
|
||||
on_press: app.archive(root.data_index)
|
||||
|
||||
<Inbox>:
|
||||
name: 'inbox'
|
||||
RecycleView:
|
||||
data: root.data
|
||||
viewclass: 'SwipeButton'
|
||||
do_scroll_x: False
|
||||
scroll_timeout: 100
|
||||
|
||||
RecycleBoxLayout:
|
||||
id:rc
|
||||
orientation: 'vertical'
|
||||
size_hint_y: None
|
||||
height: self.minimum_height
|
||||
default_size_hint: 1, None
|
||||
canvas.before:
|
||||
Color:
|
||||
rgba: 0,0,0, 1
|
||||
Rectangle:
|
||||
pos: self.pos
|
||||
size: self.size
|
||||
|
||||
<Sent>:
|
||||
name: 'sent'
|
||||
RecycleView:
|
||||
data: root.data
|
||||
viewclass: 'SwipeButton'
|
||||
do_scroll_x: False
|
||||
scroll_timeout: 100
|
||||
|
||||
RecycleBoxLayout:
|
||||
id:rc
|
||||
orientation: 'vertical'
|
||||
size_hint_y: None
|
||||
height: self.minimum_height
|
||||
default_size_hint: 1, None
|
||||
canvas.before:
|
||||
Color:
|
||||
rgba: 0,0,0, 1
|
||||
Rectangle:
|
||||
pos: self.pos
|
||||
size: self.size
|
||||
|
||||
<Trash>:
|
||||
name: 'trash'
|
||||
RecycleView:
|
||||
data: root.data
|
||||
viewclass: 'SwipeButton'
|
||||
do_scroll_x: False
|
||||
scroll_timeout: 100
|
||||
|
||||
RecycleBoxLayout:
|
||||
id:rc
|
||||
orientation: 'vertical'
|
||||
size_hint_y: None
|
||||
height: self.minimum_height
|
||||
default_size_hint: 1, None
|
||||
canvas.before:
|
||||
Color:
|
||||
rgba: 0,0,0, 1
|
||||
Rectangle:
|
||||
pos: self.pos
|
||||
size: self.size
|
||||
|
||||
<Dialog>:
|
||||
name: 'dialog'
|
||||
Label:
|
||||
text:"I have a good dialox box"
|
||||
color: 0,0,0,1
|
||||
<Test>:
|
||||
name: 'test'
|
||||
Label:
|
||||
text:"I am in test"
|
||||
color: 0,0,0,1
|
||||
|
||||
<Create>:
|
||||
name: 'create'
|
||||
GridLayout:
|
||||
rows: 5
|
||||
cols: 1
|
||||
padding: 60,60,60,60
|
||||
spacing: 50
|
||||
BoxLayout:
|
||||
size_hint_y: None
|
||||
height: '32dp'
|
||||
Label:
|
||||
text: 'FROM'
|
||||
color: 0,0,0,1
|
||||
Spinner:
|
||||
size_hint: 1,1
|
||||
pos_hint: {"x":0,"top":1.}
|
||||
pos: 10,10
|
||||
id: spinner_id
|
||||
text: app.showmeaddresses(name='text')
|
||||
values: app.showmeaddresses(name='values')
|
||||
|
||||
BoxLayout:
|
||||
size_hint_y: None
|
||||
height: '32dp'
|
||||
Label:
|
||||
text: 'TO'
|
||||
color: 0,0,0,1
|
||||
TextInput:
|
||||
id: recipent
|
||||
hint_text: 'To'
|
||||
|
||||
BoxLayout:
|
||||
size_hint_y: None
|
||||
height: '32dp'
|
||||
Label:
|
||||
text: 'SUBJECT'
|
||||
color: 0,0,0,1
|
||||
TextInput:
|
||||
id: subject
|
||||
hint_text: 'SUBJECT'
|
||||
|
||||
BoxLayout:
|
||||
size_hint_y: None
|
||||
height: '32dp'
|
||||
Label:
|
||||
text: 'BODY'
|
||||
color: 0,0,0,1
|
||||
TextInput:
|
||||
id: message
|
||||
multiline:True
|
||||
size_hint: 1,2
|
||||
|
||||
Button:
|
||||
text: 'send'
|
||||
size_hint_y: 0.1
|
||||
size_hint_x: 0.2
|
||||
height: '32dp'
|
||||
pos_hint: {'x': .5, 'y': 0.1}
|
||||
on_press: root.send()
|
||||
Button:
|
||||
text: 'cancel'
|
||||
size_hint_y: 0.1
|
||||
size_hint_x: 0.2
|
||||
height: '32dp'
|
||||
pos_hint: {'x': .72, 'y': 0.1}
|
||||
on_press: root.cancel()
|
||||
|
||||
<NewIdentity>:
|
||||
name: 'newidentity'
|
||||
GridLayout:
|
||||
padding: '120dp'
|
||||
cols: 1
|
||||
Label:
|
||||
text:"""Here you may generate as many addresses as you like. Indeed, creating and abandoning addresses is encouraged."""
|
||||
line_height:1.5
|
||||
text_size:(700,None)
|
||||
color: 0,0,0,1
|
||||
BoxLayout:
|
||||
CheckBox:
|
||||
canvas.before:
|
||||
Color:
|
||||
rgb: 1,0,0
|
||||
Ellipse:
|
||||
pos:self.center_x-8, self.center_y-8
|
||||
size:[16,16]
|
||||
group: "money"
|
||||
id:chk
|
||||
text:"use a random number generator to make an address"
|
||||
on_active:
|
||||
root.checked = self.text
|
||||
active:root.is_active
|
||||
|
||||
Label:
|
||||
text: "use a random number generator to make an address"
|
||||
color: 0,0,0,1
|
||||
BoxLayout:
|
||||
CheckBox:
|
||||
canvas.before:
|
||||
Color:
|
||||
rgb: 1,0,0
|
||||
Ellipse:
|
||||
pos:self.center_x-8, self.center_y-8
|
||||
size:[16,16]
|
||||
group: "money"
|
||||
id:chk
|
||||
text:"use a pseudo number generator to make an address"
|
||||
on_active:
|
||||
root.checked = self.text
|
||||
active:not root.is_active
|
||||
Label:
|
||||
text: "use a pseudo number generator to make an address"
|
||||
color: 0,0,0,1
|
||||
Label:
|
||||
color: 0,0,0,1
|
||||
size_hint_x: .35
|
||||
markup: True
|
||||
text: "[b]{}[/b]".format("Randomly generated addresses")
|
||||
BoxLayout:
|
||||
size_hint_y: None
|
||||
height: '32dp'
|
||||
Label:
|
||||
text: "Label (not shown to anyone except you)"
|
||||
color: 0,0,0,1
|
||||
BoxLayout:
|
||||
size_hint_y: None
|
||||
height: '32dp'
|
||||
TextInput:
|
||||
id: label
|
||||
|
||||
Button:
|
||||
text: 'Cancel'
|
||||
size_hint_y: 0.1
|
||||
size_hint_x: 0.3
|
||||
height: '32dp'
|
||||
pos_hint: {'x': .1, 'y': 0.1}
|
||||
Button:
|
||||
text: 'Ok'
|
||||
size_hint_y: 0.1
|
||||
size_hint_x: 0.3
|
||||
height: '32dp'
|
||||
pos_hint: {'x': .5, 'y': 0.1}
|
||||
on_press: root.generateaddress()
|
||||
|
||||
<Page>:
|
||||
name: 'page'
|
||||
Label:
|
||||
text: 'I am on description of my email yooooo'
|
||||
color: 0,0,0,1
|
||||
|
||||
<AddressSuccessful>:
|
||||
name: 'add_sucess'
|
||||
Label:
|
||||
text: 'Successfully created a new bit address'
|
||||
color: 0,0,0,1
|
400
src/bitmessagekivy/mpybit.py
Normal file
400
src/bitmessagekivy/mpybit.py
Normal file
|
@ -0,0 +1,400 @@
|
|||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import *
|
||||
from . import kivy_helper_search
|
||||
import os
|
||||
import queues
|
||||
import shutdown
|
||||
import state
|
||||
import time
|
||||
|
||||
from kivy.app import App
|
||||
from kivy.lang import Builder
|
||||
from kivy.properties import BooleanProperty
|
||||
from kivy.clock import Clock
|
||||
from navigationdrawer import NavigationDrawer
|
||||
from kivy.properties import ObjectProperty, StringProperty, ListProperty
|
||||
from kivy.uix.screenmanager import Screen
|
||||
from kivy.uix.textinput import TextInput
|
||||
from kivymd.theming import ThemeManager
|
||||
from kivymd.toolbar import Toolbar
|
||||
from bmconfigparser import BMConfigParser
|
||||
from helper_ackPayload import genAckPayload
|
||||
from addresses import decodeAddress, addBMIfNotPresent
|
||||
from helper_sql import sqlExecute
|
||||
|
||||
statusIconColor = 'red'
|
||||
|
||||
|
||||
class NavigateApp(App, TextInput):
|
||||
"""Application uses kivy in which base Class of Navigate App inherits from the App class."""
|
||||
|
||||
theme_cls = ThemeManager()
|
||||
nav_drawer = ObjectProperty()
|
||||
|
||||
def build(self):
|
||||
"""Return a main_widget as a root widget.
|
||||
|
||||
An application can be built if you return a widget on build(), or if you set
|
||||
self.root.
|
||||
"""
|
||||
main_widget = Builder.load_file(
|
||||
os.path.join(os.path.dirname(__file__), 'main.kv'))
|
||||
self.nav_drawer = Navigator()
|
||||
return main_widget
|
||||
|
||||
def getCurrentAccountData(self, text):
|
||||
"""Get Current Address Account Data."""
|
||||
state.association = text
|
||||
self.root.ids.sc1.clear_widgets()
|
||||
self.root.ids.sc2.clear_widgets()
|
||||
self.root.ids.sc3.clear_widgets()
|
||||
self.root.ids.sc1.add_widget(Inbox())
|
||||
self.root.ids.sc2.add_widget(Sent())
|
||||
self.root.ids.sc3.add_widget(Trash())
|
||||
self.root.ids.toolbar.title = BMConfigParser().get(
|
||||
state.association, 'label') + '({})'.format(state.association)
|
||||
Inbox()
|
||||
Sent()
|
||||
Trash()
|
||||
|
||||
def say_exit(self):
|
||||
"""Exit the application as uses shutdown PyBitmessage."""
|
||||
print("**************************EXITING FROM APPLICATION*****************************")
|
||||
App.get_running_app().stop()
|
||||
shutdown.doCleanShutdown()
|
||||
|
||||
@staticmethod
|
||||
def showmeaddresses(name="text"):
|
||||
"""Show the addresses in spinner to make as dropdown."""
|
||||
if name == "text":
|
||||
return BMConfigParser().addresses()[0]
|
||||
elif name == "values":
|
||||
return BMConfigParser().addresses()
|
||||
|
||||
def update_index(self, data_index, index):
|
||||
"""Update index after archieve message to trash."""
|
||||
if self.root.ids.scr_mngr.current == 'inbox':
|
||||
self.root.ids.sc1.data[data_index]['index'] = index
|
||||
elif self.root.ids.scr_mngr.current == 'sent':
|
||||
self.root.ids.sc2.data[data_index]['index'] = index
|
||||
elif self.root.ids.scr_mngr.current == 'trash':
|
||||
self.root.ids.sc3.data[data_index]['index'] = index
|
||||
|
||||
def delete(self, data_index):
|
||||
"""It will make delete using remove function."""
|
||||
print("delete {}".format(data_index))
|
||||
self._remove(data_index)
|
||||
|
||||
def archive(self, data_index):
|
||||
"""It will make archieve using remove function."""
|
||||
print("archive {}".format(data_index))
|
||||
self._remove(data_index)
|
||||
|
||||
def _remove(self, data_index):
|
||||
"""It will remove message by resetting the values in recycleview data."""
|
||||
if self.root.ids.scr_mngr.current == 'inbox':
|
||||
self.root.ids.sc1.data.pop(data_index)
|
||||
self.root.ids.sc1.data = [{
|
||||
'data_index': i,
|
||||
'index': d['index'],
|
||||
'height': d['height'],
|
||||
'text': d['text']}
|
||||
for i, d in enumerate(self.root.ids.sc1.data)
|
||||
]
|
||||
elif self.root.ids.scr_mngr.current == 'sent':
|
||||
self.root.ids.sc2.data.pop(data_index)
|
||||
self.root.ids.sc2.data = [{
|
||||
'data_index': i,
|
||||
'index': d['index'],
|
||||
'height': d['height'],
|
||||
'text': d['text']}
|
||||
for i, d in enumerate(self.root.ids.sc2.data)
|
||||
]
|
||||
elif self.root.ids.scr_mngr.current == 'trash':
|
||||
self.root.ids.sc3.data.pop(data_index)
|
||||
self.root.ids.sc3.data = [{
|
||||
'data_index': i,
|
||||
'index': d['index'],
|
||||
'height': d['height'],
|
||||
'text': d['text']}
|
||||
for i, d in enumerate(self.root.ids.sc3.data)
|
||||
]
|
||||
|
||||
def getInboxMessageDetail(self, instance):
|
||||
"""It will get message detail after make selected message description."""
|
||||
try:
|
||||
self.root.ids.scr_mngr.current = 'page'
|
||||
except AttributeError:
|
||||
self.parent.manager.current = 'page'
|
||||
print('Message Clicked {}'.format(instance))
|
||||
|
||||
@staticmethod
|
||||
def getCurrentAccount():
|
||||
"""It uses to get current account label."""
|
||||
return BMConfigParser().get(state.association, 'label') + '({})'.format(state.association)
|
||||
|
||||
|
||||
class Navigator(NavigationDrawer):
|
||||
"""Navigator class uses NavigationDrawer.
|
||||
|
||||
It is an UI panel that shows our app's main navigation menu
|
||||
It is hidden when not in use, but appears when the user swipes
|
||||
a finger from the left edge of the screen or, when at the top
|
||||
level of the app, the user touches the drawer icon in the app bar
|
||||
"""
|
||||
|
||||
image_source = StringProperty('images/qidenticon_two.png')
|
||||
title = StringProperty('Navigation')
|
||||
|
||||
|
||||
class Inbox(Screen):
|
||||
"""Inbox Screen uses screen to show widgets of screens."""
|
||||
|
||||
data = ListProperty()
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Inbox, self).__init__(*args, **kwargs)
|
||||
if state.association == '':
|
||||
state.association = Navigator().ids.btn.text
|
||||
Clock.schedule_once(self.init_ui, 0)
|
||||
|
||||
def init_ui(self, dt=0):
|
||||
"""Clock Schdule for method inbox accounts."""
|
||||
self.inboxaccounts()
|
||||
print(dt)
|
||||
|
||||
def inboxaccounts(self):
|
||||
"""Load inbox accounts."""
|
||||
account = state.association
|
||||
self.loadMessagelist(account, 'All', '')
|
||||
|
||||
def loadMessagelist(self, account, where="", what=""):
|
||||
"""Load Inbox list for inbox messages."""
|
||||
xAddress = "toaddress"
|
||||
queryreturn = kivy_helper_search.search_sql(
|
||||
xAddress, account, 'inbox', where, what, False)
|
||||
if queryreturn:
|
||||
self.data = [{
|
||||
'data_index': i,
|
||||
'index': 1,
|
||||
'height': 48,
|
||||
'text': row[4]}
|
||||
for i, row in enumerate(queryreturn)
|
||||
]
|
||||
else:
|
||||
self.data = [{
|
||||
'data_index': 1,
|
||||
'index': 1,
|
||||
'height': 48,
|
||||
'text': "yet no message for this account!!!!!!!!!!!!!"}
|
||||
]
|
||||
|
||||
|
||||
class Page(Screen):
|
||||
pass
|
||||
|
||||
|
||||
class AddressSuccessful(Screen):
|
||||
pass
|
||||
|
||||
|
||||
class Sent(Screen):
|
||||
"""Sent Screen uses screen to show widgets of screens."""
|
||||
|
||||
data = ListProperty()
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Sent, self).__init__(*args, **kwargs)
|
||||
if state.association == '':
|
||||
state.association = Navigator().ids.btn.text
|
||||
Clock.schedule_once(self.init_ui, 0)
|
||||
|
||||
def init_ui(self, dt=0):
|
||||
"""Clock Schdule for method sent accounts."""
|
||||
self.sentaccounts()
|
||||
print(dt)
|
||||
|
||||
def sentaccounts(self):
|
||||
"""Load sent accounts."""
|
||||
account = state.association
|
||||
self.loadSent(account, 'All', '')
|
||||
|
||||
def loadSent(self, account, where="", what=""):
|
||||
"""Load Sent list for Sent messages."""
|
||||
xAddress = 'fromaddress'
|
||||
queryreturn = kivy_helper_search.search_sql(
|
||||
xAddress, account, "sent", where, what, False)
|
||||
if queryreturn:
|
||||
self.data = [{
|
||||
'data_index': i,
|
||||
'index': 1,
|
||||
'height': 48,
|
||||
'text': row[2]}
|
||||
for i, row in enumerate(queryreturn)
|
||||
]
|
||||
else:
|
||||
self.data = [{
|
||||
'data_index': 1,
|
||||
'index': 1,
|
||||
'height': 48,
|
||||
'text': "yet no message for this account!!!!!!!!!!!!!"}
|
||||
]
|
||||
|
||||
|
||||
class Trash(Screen):
|
||||
"""Trash Screen uses screen to show widgets of screens."""
|
||||
|
||||
data = ListProperty()
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Trash, self).__init__(*args, **kwargs)
|
||||
if state.association == '':
|
||||
state.association = Navigator().ids.btn.text
|
||||
Clock.schedule_once(self.init_ui, 0)
|
||||
|
||||
def init_ui(self, dt=0):
|
||||
"""Clock Schdule for method inbox accounts."""
|
||||
self.inboxaccounts()
|
||||
print(dt)
|
||||
|
||||
def inboxaccounts(self):
|
||||
"""Load inbox accounts."""
|
||||
account = state.association
|
||||
self.loadTrashlist(account, 'All', '')
|
||||
|
||||
def loadTrashlist(self, account, where="", what=""):
|
||||
"""Load Trash list for trashed messages."""
|
||||
xAddress = "toaddress"
|
||||
queryreturn = kivy_helper_search.search_sql(
|
||||
xAddress, account, 'trash', where, what, False)
|
||||
if queryreturn:
|
||||
self.data = [{
|
||||
'data_index': i,
|
||||
'index': 1,
|
||||
'height': 48,
|
||||
'text': row[4]}
|
||||
for i, row in enumerate(queryreturn)
|
||||
]
|
||||
else:
|
||||
self.data = [{
|
||||
'data_index': 1,
|
||||
'index': 1,
|
||||
'height': 48,
|
||||
'text': "yet no message for this account!!!!!!!!!!!!!"}
|
||||
]
|
||||
|
||||
|
||||
class Dialog(Screen):
|
||||
"""Dialog Screen uses screen to show widgets of screens."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class Test(Screen):
|
||||
"""Test Screen uses screen to show widgets of screens."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class Create(Screen):
|
||||
"""Create Screen uses screen to show widgets of screens."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Create, self).__init__(*args, **kwargs)
|
||||
|
||||
def send(self):
|
||||
"""Send message from one address to another."""
|
||||
fromAddress = self.ids.spinner_id.text
|
||||
# For now we are using static address i.e we are not using recipent field value.
|
||||
toAddress = "BM-2cWyUfBdY2FbgyuCb7abFZ49JYxSzUhNFe"
|
||||
message = self.ids.message.text
|
||||
subject = self.ids.subject.text
|
||||
encoding = 3
|
||||
print(("message: ", self.ids.message.text))
|
||||
sendMessageToPeople = True
|
||||
if sendMessageToPeople:
|
||||
if toAddress != '':
|
||||
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
|
||||
toAddress)
|
||||
if status == 'success':
|
||||
toAddress = addBMIfNotPresent(toAddress)
|
||||
|
||||
if addressVersionNumber > 4 or addressVersionNumber <= 1:
|
||||
print("addressVersionNumber > 4 or addressVersionNumber <= 1")
|
||||
if streamNumber > 1 or streamNumber == 0:
|
||||
print("streamNumber > 1 or streamNumber == 0")
|
||||
if statusIconColor == 'red':
|
||||
print("shared.statusIconColor == 'red'")
|
||||
stealthLevel = BMConfigParser().safeGetInt(
|
||||
'bitmessagesettings', 'ackstealthlevel')
|
||||
ackdata = genAckPayload(streamNumber, stealthLevel)
|
||||
t = ()
|
||||
sqlExecute(
|
||||
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
|
||||
'',
|
||||
toAddress,
|
||||
ripe,
|
||||
fromAddress,
|
||||
subject,
|
||||
message,
|
||||
ackdata,
|
||||
int(time.time()),
|
||||
int(time.time()),
|
||||
0,
|
||||
'msgqueued',
|
||||
0,
|
||||
'sent',
|
||||
encoding,
|
||||
BMConfigParser().getint('bitmessagesettings', 'ttl'))
|
||||
toLabel = ''
|
||||
queues.workerQueue.put(('sendmessage', toAddress))
|
||||
print("sqlExecute successfully ##### ##################")
|
||||
self.ids.message.text = ''
|
||||
self.ids.spinner_id.text = '<select>'
|
||||
self.ids.subject.text = ''
|
||||
self.ids.recipent.text = ''
|
||||
return None
|
||||
|
||||
def cancel(self):
|
||||
"""Reset values for send message."""
|
||||
self.ids.message.text = ''
|
||||
self.ids.spinner_id.text = '<select>'
|
||||
self.ids.subject.text = ''
|
||||
self.ids.recipent.text = ''
|
||||
return None
|
||||
|
||||
|
||||
class NewIdentity(Screen):
|
||||
"""Create new address for PyBitmessage."""
|
||||
|
||||
is_active = BooleanProperty(False)
|
||||
checked = StringProperty("")
|
||||
# self.manager.parent.ids.create.children[0].source = 'images/plus-4-xxl.png'
|
||||
|
||||
def generateaddress(self):
|
||||
"""Generate new address."""
|
||||
if self.checked == 'use a random number generator to make an address':
|
||||
queues.apiAddressGeneratorReturnQueue.queue.clear()
|
||||
streamNumberForAddress = 1
|
||||
label = self.ids.label.text
|
||||
eighteenByteRipe = False
|
||||
nonceTrialsPerByte = 1000
|
||||
payloadLengthExtraBytes = 1000
|
||||
|
||||
queues.addressGeneratorQueue.put((
|
||||
'createRandomAddress',
|
||||
4, streamNumberForAddress,
|
||||
label, 1, "", eighteenByteRipe,
|
||||
nonceTrialsPerByte,
|
||||
payloadLengthExtraBytes)
|
||||
)
|
||||
self.manager.current = 'add_sucess'
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
NavigateApp().run()
|
|
@ -1,22 +1,21 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
The PyBitmessage startup script
|
||||
"""
|
||||
#!/usr/bin/python2.7
|
||||
# Copyright (c) 2012-2016 Jonathan Warren
|
||||
# Copyright (c) 2012-2020 The Bitmessage developers
|
||||
# Copyright (c) 2012-2019 The Bitmessage developers
|
||||
# Distributed under the MIT/X11 software license. See the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
# Right now, PyBitmessage only support connecting to stream 1. It doesn't
|
||||
# yet contain logic to expand into further streams.
|
||||
|
||||
# The software version variable is now held in shared.py
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
try:
|
||||
import pathmagic
|
||||
except ImportError:
|
||||
from pybitmessage import pathmagic
|
||||
app_dir = pathmagic.setup()
|
||||
app_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
os.chdir(app_dir)
|
||||
sys.path.insert(0, app_dir)
|
||||
|
||||
|
||||
import depends
|
||||
depends.check_dependencies()
|
||||
|
@ -32,26 +31,67 @@ import time
|
|||
import traceback
|
||||
from struct import pack
|
||||
|
||||
from helper_startup import (
|
||||
isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections
|
||||
)
|
||||
from singleinstance import singleinstance
|
||||
|
||||
import defaults
|
||||
import shared
|
||||
import shutdown
|
||||
import knownnodes
|
||||
import state
|
||||
import shutdown
|
||||
from debug import logger
|
||||
|
||||
# Classes
|
||||
from class_sqlThread import sqlThread
|
||||
from class_singleCleaner import singleCleaner
|
||||
from class_objectProcessor import objectProcessor
|
||||
from class_singleWorker import singleWorker
|
||||
from class_addressGenerator import addressGenerator
|
||||
from bmconfigparser import BMConfigParser
|
||||
from debug import logger # this should go before any threads
|
||||
from helper_startup import (
|
||||
adjustHalfOpenConnectionsLimit, start_proxyconfig)
|
||||
|
||||
from inventory import Inventory
|
||||
# Network objects and threads
|
||||
from network import (
|
||||
BMConnectionPool, Dandelion, AddrThread, AnnounceThread, BMNetworkThread,
|
||||
InvThread, ReceiveQueueThread, DownloadThread, UploadThread
|
||||
)
|
||||
from network.knownnodes import readKnownNodes
|
||||
from singleinstance import singleinstance
|
||||
# Synchronous threads
|
||||
from threads import (
|
||||
set_thread_name, printLock,
|
||||
addressGenerator, objectProcessor, singleCleaner, singleWorker, sqlThread)
|
||||
|
||||
from network.fix_circular_imports import BMConnectionPool, Dandelion
|
||||
from network.networkthread import BMNetworkThread
|
||||
from network.receivequeuethread import ReceiveQueueThread
|
||||
from network.announcethread import AnnounceThread
|
||||
from network.invthread import InvThread
|
||||
from network.addrthread import AddrThread
|
||||
from network.downloadthread import DownloadThread
|
||||
from network.uploadthread import UploadThread
|
||||
|
||||
# Helper Functions
|
||||
import helper_threading
|
||||
|
||||
|
||||
def connectToStream(streamNumber):
|
||||
state.streamsInWhichIAmParticipating.append(streamNumber)
|
||||
|
||||
if isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections():
|
||||
# Some XP and Vista systems can only have 10 outgoing connections
|
||||
# at a time.
|
||||
state.maximumNumberOfHalfOpenConnections = 9
|
||||
else:
|
||||
state.maximumNumberOfHalfOpenConnections = 64
|
||||
try:
|
||||
# don't overload Tor
|
||||
if BMConfigParser().get(
|
||||
'bitmessagesettings', 'socksproxytype') != 'none':
|
||||
state.maximumNumberOfHalfOpenConnections = 4
|
||||
except:
|
||||
pass
|
||||
|
||||
with knownnodes.knownNodesLock:
|
||||
if streamNumber not in knownnodes.knownNodes:
|
||||
knownnodes.knownNodes[streamNumber] = {}
|
||||
if streamNumber*2 not in knownnodes.knownNodes:
|
||||
knownnodes.knownNodes[streamNumber*2] = {}
|
||||
if streamNumber*2+1 not in knownnodes.knownNodes:
|
||||
knownnodes.knownNodes[streamNumber*2+1] = {}
|
||||
|
||||
BMConnectionPool().connectToStream(streamNumber)
|
||||
|
||||
|
||||
def _fixSocket():
|
||||
|
@ -67,8 +107,6 @@ def _fixSocket():
|
|||
addressToString = ctypes.windll.ws2_32.WSAAddressToStringA
|
||||
|
||||
def inet_ntop(family, host):
|
||||
"""Converting an IP address in packed
|
||||
binary format to string format"""
|
||||
if family == socket.AF_INET:
|
||||
if len(host) != 4:
|
||||
raise ValueError("invalid IPv4 host")
|
||||
|
@ -90,8 +128,6 @@ def _fixSocket():
|
|||
stringToAddress = ctypes.windll.ws2_32.WSAStringToAddressA
|
||||
|
||||
def inet_pton(family, host):
|
||||
"""Converting an IP address in string format
|
||||
to a packed binary format"""
|
||||
buf = "\0" * 28
|
||||
lengthBuf = pack("I", len(buf))
|
||||
if stringToAddress(str(host),
|
||||
|
@ -132,9 +168,9 @@ def signal_handler(signum, frame):
|
|||
if thread.name not in ("PyBitmessage", "MainThread"):
|
||||
return
|
||||
logger.error("Got signal %i", signum)
|
||||
# there are possible non-UI variants to run bitmessage
|
||||
# which should shutdown especially test-mode
|
||||
if state.thisapp.daemon or not state.enableGUI:
|
||||
# there are possible non-UI variants to run bitmessage which should shutdown
|
||||
# especially test-mode
|
||||
if shared.thisapp.daemon or not state.enableGUI:
|
||||
shutdown.doCleanShutdown()
|
||||
else:
|
||||
print('# Thread: %s(%d)' % (thread.name, thread.ident))
|
||||
|
@ -146,19 +182,15 @@ def signal_handler(signum, frame):
|
|||
' because the UI captures the signal.')
|
||||
|
||||
|
||||
class Main(object):
|
||||
"""Main PyBitmessage class"""
|
||||
class Main:
|
||||
def start(self):
|
||||
"""Start main application"""
|
||||
# pylint: disable=too-many-statements,too-many-branches,too-many-locals
|
||||
_fixSocket()
|
||||
adjustHalfOpenConnectionsLimit()
|
||||
|
||||
config = BMConfigParser()
|
||||
daemon = config.safeGetBoolean('bitmessagesettings', 'daemon')
|
||||
daemon = BMConfigParser().safeGetBoolean(
|
||||
'bitmessagesettings', 'daemon')
|
||||
|
||||
try:
|
||||
opts, _ = getopt.getopt(
|
||||
opts, args = getopt.getopt(
|
||||
sys.argv[1:], "hcdt",
|
||||
["help", "curses", "daemon", "test"])
|
||||
|
||||
|
@ -166,7 +198,7 @@ class Main(object):
|
|||
self.usage()
|
||||
sys.exit(2)
|
||||
|
||||
for opt, _ in opts:
|
||||
for opt, arg in opts:
|
||||
if opt in ("-h", "--help"):
|
||||
self.usage()
|
||||
sys.exit()
|
||||
|
@ -183,14 +215,13 @@ class Main(object):
|
|||
# Fallback: in case when no api command was issued
|
||||
state.last_api_response = time.time()
|
||||
# Apply special settings
|
||||
config = BMConfigParser()
|
||||
config.set(
|
||||
'bitmessagesettings', 'apienabled', 'true')
|
||||
config.set(
|
||||
'bitmessagesettings', 'apiusername', 'username')
|
||||
config.set(
|
||||
'bitmessagesettings', 'apipassword', 'password')
|
||||
config.set(
|
||||
'bitmessagesettings', 'apivariant', 'legacy')
|
||||
config.set(
|
||||
'bitmessagesettings', 'apinotifypath',
|
||||
os.path.join(app_dir, 'tests', 'apinotify_handler.py')
|
||||
|
@ -213,32 +244,32 @@ class Main(object):
|
|||
' \'-c\' as a commandline argument.'
|
||||
)
|
||||
# is the application already running? If yes then exit.
|
||||
state.thisapp = singleinstance("", daemon)
|
||||
shared.thisapp = singleinstance("", daemon)
|
||||
|
||||
if daemon:
|
||||
with printLock:
|
||||
with shared.printLock:
|
||||
print('Running as a daemon. Send TERM signal to end.')
|
||||
self.daemonize()
|
||||
|
||||
self.setSignalHandler()
|
||||
|
||||
set_thread_name("PyBitmessage")
|
||||
helper_threading.set_thread_name("PyBitmessage")
|
||||
|
||||
state.dandelion = config.safeGetInt('network', 'dandelion')
|
||||
state.dandelion = BMConfigParser().safeGetInt('network', 'dandelion')
|
||||
# dandelion requires outbound connections, without them,
|
||||
# stem objects will get stuck forever
|
||||
if state.dandelion and not config.safeGetBoolean(
|
||||
if state.dandelion and not BMConfigParser().safeGetBoolean(
|
||||
'bitmessagesettings', 'sendoutgoingconnections'):
|
||||
state.dandelion = 0
|
||||
|
||||
if state.testmode or config.safeGetBoolean(
|
||||
if state.testmode or BMConfigParser().safeGetBoolean(
|
||||
'bitmessagesettings', 'extralowdifficulty'):
|
||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte = int(
|
||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte / 100)
|
||||
defaults.networkDefaultPayloadLengthExtraBytes = int(
|
||||
defaults.networkDefaultPayloadLengthExtraBytes / 100)
|
||||
|
||||
readKnownNodes()
|
||||
knownnodes.readKnownNodes()
|
||||
|
||||
# Not needed if objproc is disabled
|
||||
if state.enableObjProc:
|
||||
|
@ -270,15 +301,15 @@ class Main(object):
|
|||
if state.enableObjProc:
|
||||
|
||||
# SMTP delivery thread
|
||||
if daemon and config.safeGet(
|
||||
'bitmessagesettings', 'smtpdeliver', '') != '':
|
||||
if daemon and BMConfigParser().safeGet(
|
||||
"bitmessagesettings", "smtpdeliver", '') != '':
|
||||
from class_smtpDeliver import smtpDeliver
|
||||
smtpDeliveryThread = smtpDeliver()
|
||||
smtpDeliveryThread.start()
|
||||
|
||||
# SMTP daemon thread
|
||||
if daemon and config.safeGetBoolean(
|
||||
'bitmessagesettings', 'smtpd'):
|
||||
if daemon and BMConfigParser().safeGetBoolean(
|
||||
"bitmessagesettings", "smtpd"):
|
||||
from class_smtpServer import smtpServer
|
||||
smtpServerThread = smtpServer()
|
||||
smtpServerThread.start()
|
||||
|
@ -303,7 +334,7 @@ class Main(object):
|
|||
shared.reloadBroadcastSendersForWhichImWatching()
|
||||
|
||||
# API is also objproc dependent
|
||||
if config.safeGetBoolean('bitmessagesettings', 'apienabled'):
|
||||
if BMConfigParser().safeGetBoolean('bitmessagesettings', 'apienabled'):
|
||||
import api # pylint: disable=relative-import
|
||||
singleAPIThread = api.singleAPI()
|
||||
# close the main program even if there are threads left
|
||||
|
@ -312,19 +343,17 @@ class Main(object):
|
|||
|
||||
# start network components if networking is enabled
|
||||
if state.enableNetwork:
|
||||
start_proxyconfig()
|
||||
BMConnectionPool().connectToStream(1)
|
||||
BMConnectionPool()
|
||||
asyncoreThread = BMNetworkThread()
|
||||
asyncoreThread.daemon = True
|
||||
asyncoreThread.start()
|
||||
for i in range(config.getint('threads', 'receive')):
|
||||
for i in range(BMConfigParser().getint("threads", "receive")):
|
||||
receiveQueueThread = ReceiveQueueThread(i)
|
||||
receiveQueueThread.daemon = True
|
||||
receiveQueueThread.start()
|
||||
if config.safeGetBoolean('bitmessagesettings', 'udp'):
|
||||
state.announceThread = AnnounceThread()
|
||||
state.announceThread.daemon = True
|
||||
state.announceThread.start()
|
||||
announceThread = AnnounceThread()
|
||||
announceThread.daemon = True
|
||||
announceThread.start()
|
||||
state.invThread = InvThread()
|
||||
state.invThread.daemon = True
|
||||
state.invThread.start()
|
||||
|
@ -338,7 +367,10 @@ class Main(object):
|
|||
state.uploadThread.daemon = True
|
||||
state.uploadThread.start()
|
||||
|
||||
if config.safeGetBoolean('bitmessagesettings', 'upnp'):
|
||||
connectToStream(1)
|
||||
|
||||
if BMConfigParser().safeGetBoolean(
|
||||
'bitmessagesettings', 'upnp'):
|
||||
import upnp
|
||||
upnpThread = upnp.uPnPThread()
|
||||
upnpThread.start()
|
||||
|
@ -353,53 +385,51 @@ class Main(object):
|
|||
print('Running with curses')
|
||||
import bitmessagecurses
|
||||
bitmessagecurses.runwrapper()
|
||||
elif state.kivy:
|
||||
BMConfigParser().remove_option('bitmessagesettings', 'dontconnect')
|
||||
from bitmessagekivy.mpybit import NavigateApp
|
||||
NavigateApp().run()
|
||||
else:
|
||||
import bitmessageqt
|
||||
bitmessageqt.run()
|
||||
else:
|
||||
config.remove_option('bitmessagesettings', 'dontconnect')
|
||||
BMConfigParser().remove_option('bitmessagesettings', 'dontconnect')
|
||||
|
||||
if daemon:
|
||||
while state.shutdown == 0:
|
||||
time.sleep(1)
|
||||
if (
|
||||
state.testmode
|
||||
and time.time() - state.last_api_response >= 30
|
||||
):
|
||||
if (state.testmode and
|
||||
time.time() - state.last_api_response >= 30):
|
||||
self.stop()
|
||||
elif not state.enableGUI:
|
||||
state.enableGUI = True
|
||||
try:
|
||||
# pylint: disable=relative-import
|
||||
from tests import core as test_core
|
||||
except ImportError:
|
||||
self.stop()
|
||||
return
|
||||
|
||||
from tests import core as test_core # pylint: disable=relative-import
|
||||
test_core_result = test_core.run()
|
||||
state.enableGUI = True
|
||||
self.stop()
|
||||
test_core.cleanup()
|
||||
sys.exit(not test_core_result.wasSuccessful())
|
||||
sys.exit(
|
||||
'Core tests failed!'
|
||||
if test_core_result.errors or test_core_result.failures
|
||||
else 0
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def daemonize():
|
||||
"""Running as a daemon. Send signal in end."""
|
||||
def daemonize(self):
|
||||
grandfatherPid = os.getpid()
|
||||
parentPid = None
|
||||
try:
|
||||
if os.fork():
|
||||
# unlock
|
||||
state.thisapp.cleanup()
|
||||
shared.thisapp.cleanup()
|
||||
# wait until grandchild ready
|
||||
while True:
|
||||
time.sleep(1)
|
||||
os._exit(0) # pylint: disable=protected-access
|
||||
os._exit(0)
|
||||
except AttributeError:
|
||||
# fork not implemented
|
||||
pass
|
||||
else:
|
||||
parentPid = os.getpid()
|
||||
state.thisapp.lock() # relock
|
||||
shared.thisapp.lock() # relock
|
||||
|
||||
os.umask(0)
|
||||
try:
|
||||
|
@ -410,17 +440,17 @@ class Main(object):
|
|||
try:
|
||||
if os.fork():
|
||||
# unlock
|
||||
state.thisapp.cleanup()
|
||||
shared.thisapp.cleanup()
|
||||
# wait until child ready
|
||||
while True:
|
||||
time.sleep(1)
|
||||
os._exit(0) # pylint: disable=protected-access
|
||||
os._exit(0)
|
||||
except AttributeError:
|
||||
# fork not implemented
|
||||
pass
|
||||
else:
|
||||
state.thisapp.lock() # relock
|
||||
state.thisapp.lockPid = None # indicate we're the final child
|
||||
shared.thisapp.lock() # relock
|
||||
shared.thisapp.lockPid = None # indicate we're the final child
|
||||
sys.stdout.flush()
|
||||
sys.stderr.flush()
|
||||
if not sys.platform.startswith('win'):
|
||||
|
@ -435,16 +465,12 @@ class Main(object):
|
|||
os.kill(parentPid, signal.SIGTERM)
|
||||
os.kill(grandfatherPid, signal.SIGTERM)
|
||||
|
||||
@staticmethod
|
||||
def setSignalHandler():
|
||||
"""Setting the Signal Handler"""
|
||||
def setSignalHandler(self):
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
signal.signal(signal.SIGTERM, signal_handler)
|
||||
# signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||
|
||||
@staticmethod
|
||||
def usage():
|
||||
"""Displaying the usages"""
|
||||
def usage(self):
|
||||
print('Usage: ' + sys.argv[0] + ' [OPTIONS]')
|
||||
print('''
|
||||
Options:
|
||||
|
@ -454,19 +480,16 @@ Options:
|
|||
-t, --test dryrun, make testing
|
||||
|
||||
All parameters are optional.
|
||||
''')
|
||||
'''
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def stop():
|
||||
"""Stop main application"""
|
||||
with printLock:
|
||||
def stop(self):
|
||||
with shared.printLock:
|
||||
print('Stopping Bitmessage Deamon.')
|
||||
shutdown.doCleanShutdown()
|
||||
|
||||
# .. todo:: nice function but no one is using this
|
||||
@staticmethod
|
||||
def getApiAddress():
|
||||
"""This function returns API address and port"""
|
||||
# TODO: nice function but no one is using this
|
||||
def getApiAddress(self):
|
||||
if not BMConfigParser().safeGetBoolean(
|
||||
'bitmessagesettings', 'apienabled'):
|
||||
return None
|
||||
|
@ -476,7 +499,6 @@ All parameters are optional.
|
|||
|
||||
|
||||
def main():
|
||||
"""Triggers main module"""
|
||||
mainprogram = Main()
|
||||
mainprogram.start()
|
||||
|
||||
|
|
|
@ -1,13 +1,22 @@
|
|||
"""
|
||||
PyQt based UI for bitmessage, the main module
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
from builtins import range
|
||||
from builtins import *
|
||||
from past.utils import old_div
|
||||
import hashlib
|
||||
import locale
|
||||
import os
|
||||
import random
|
||||
import string
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
import threading
|
||||
|
@ -18,43 +27,46 @@ from sqlite3 import register_adapter
|
|||
from PyQt4 import QtCore, QtGui
|
||||
from PyQt4.QtNetwork import QLocalSocket, QLocalServer
|
||||
|
||||
import shared
|
||||
import state
|
||||
from debug import logger
|
||||
from tr import _translate
|
||||
from addresses import decodeAddress, addBMIfNotPresent
|
||||
from bitmessageui import Ui_MainWindow
|
||||
import shared
|
||||
from .bitmessageui import Ui_MainWindow
|
||||
from bmconfigparser import BMConfigParser
|
||||
import defaults
|
||||
import namecoin
|
||||
from messageview import MessageView
|
||||
from migrationwizard import Ui_MigrationWizard
|
||||
from foldertree import (
|
||||
from .messageview import MessageView
|
||||
from .migrationwizard import Ui_MigrationWizard
|
||||
from .foldertree import (
|
||||
AccountMixin, Ui_FolderWidget, Ui_AddressWidget, Ui_SubscriptionWidget,
|
||||
MessageList_AddressWidget, MessageList_SubjectWidget,
|
||||
Ui_AddressBookWidgetItemLabel, Ui_AddressBookWidgetItemAddress,
|
||||
MessageList_TimeWidget)
|
||||
import settingsmixin
|
||||
import support
|
||||
Ui_AddressBookWidgetItemLabel, Ui_AddressBookWidgetItemAddress)
|
||||
from .settings import Ui_settingsDialog
|
||||
from . import settingsmixin
|
||||
from . import support
|
||||
import debug
|
||||
from helper_ackPayload import genAckPayload
|
||||
from helper_sql import sqlQuery, sqlExecute, sqlExecuteChunked, sqlStoredProcedure
|
||||
import helper_addressbook
|
||||
import helper_search
|
||||
import l10n
|
||||
from utils import str_broadcast_subscribers, avatarize
|
||||
from account import (
|
||||
import openclpow
|
||||
from .utils import str_broadcast_subscribers, avatarize
|
||||
from .account import (
|
||||
getSortedAccounts, getSortedSubscriptions, accountClass, BMAccount,
|
||||
GatewayAccount, MailchuckAccount, AccountColor)
|
||||
import dialogs
|
||||
from . import dialogs
|
||||
from network.stats import pendingDownload, pendingUpload
|
||||
from uisignaler import UISignaler
|
||||
from .uisignaler import UISignaler
|
||||
import knownnodes
|
||||
import paths
|
||||
from proofofwork import getPowType
|
||||
import queues
|
||||
import shutdown
|
||||
from statusbar import BMStatusBar
|
||||
import sound
|
||||
# This is needed for tray icon
|
||||
import bitmessage_icons_rc # noqa:F401 pylint: disable=unused-import
|
||||
import helper_sent
|
||||
import state
|
||||
from .statusbar import BMStatusBar
|
||||
from network.asyncore_pollchoose import set_rates
|
||||
from . import sound
|
||||
|
||||
|
||||
try:
|
||||
from plugins.plugin import get_plugin, get_plugins
|
||||
|
@ -62,6 +74,49 @@ except ImportError:
|
|||
get_plugins = False
|
||||
|
||||
|
||||
def change_translation(newlocale):
|
||||
global qmytranslator, qsystranslator
|
||||
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()
|
||||
translationpath = os.path.join (paths.codePath(), 'translations', 'bitmessage_' + newlocale)
|
||||
qmytranslator.load(translationpath)
|
||||
QtGui.QApplication.installTranslator(qmytranslator)
|
||||
|
||||
qsystranslator = QtCore.QTranslator()
|
||||
if paths.frozen:
|
||||
translationpath = os.path.join (paths.codePath(), 'translations', 'qt_' + newlocale)
|
||||
else:
|
||||
translationpath = os.path.join (str(QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)), 'qt_' + newlocale)
|
||||
qsystranslator.load(translationpath)
|
||||
QtGui.QApplication.installTranslator(qsystranslator)
|
||||
|
||||
lang = locale.normalize(l10n.getTranslationLanguage())
|
||||
langs = [lang.split(".")[0] + "." + l10n.encoding, lang.split(".")[0] + "." + 'UTF-8', lang]
|
||||
if 'win32' in sys.platform or 'win64' in sys.platform:
|
||||
langs = [l10n.getWindowsLocale(lang)]
|
||||
for lang in langs:
|
||||
try:
|
||||
l10n.setlocale(locale.LC_ALL, lang)
|
||||
if 'win32' not in sys.platform and 'win64' not in sys.platform:
|
||||
l10n.encoding = locale.nl_langinfo(locale.CODESET)
|
||||
else:
|
||||
l10n.encoding = locale.getlocale()[1]
|
||||
logger.info("Successfully set locale to %s", lang)
|
||||
break
|
||||
except:
|
||||
logger.error("Failed to set locale to %s", lang, exc_info=True)
|
||||
|
||||
|
||||
# TODO: rewrite
|
||||
def powQueueSize():
|
||||
"""Returns the size of queues.workerQueue including current unfinished work"""
|
||||
|
@ -75,17 +130,11 @@ def powQueueSize():
|
|||
return queue_len
|
||||
|
||||
|
||||
def openKeysFile():
|
||||
"""Open keys file with an external editor"""
|
||||
keysfile = os.path.join(state.appdata, 'keys.dat')
|
||||
if 'linux' in sys.platform:
|
||||
subprocess.call(["xdg-open", keysfile])
|
||||
elif sys.platform.startswith('win'):
|
||||
os.startfile(keysfile) # pylint: disable=no-member
|
||||
|
||||
|
||||
class MyForm(settingsmixin.SMainWindow):
|
||||
|
||||
# the last time that a message arrival sound was played
|
||||
lastSoundTime = datetime.now() - timedelta(days=1)
|
||||
|
||||
# the maximum frequency of message sounds in seconds
|
||||
maxSoundFrequencySec = 60
|
||||
|
||||
|
@ -93,58 +142,6 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
REPLY_TYPE_CHAN = 1
|
||||
REPLY_TYPE_UPD = 2
|
||||
|
||||
def change_translation(self, newlocale=None):
|
||||
"""Change translation language for the application"""
|
||||
if newlocale is None:
|
||||
newlocale = l10n.getTranslationLanguage()
|
||||
try:
|
||||
if not self.qmytranslator.isEmpty():
|
||||
QtGui.QApplication.removeTranslator(self.qmytranslator)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
if not self.qsystranslator.isEmpty():
|
||||
QtGui.QApplication.removeTranslator(self.qsystranslator)
|
||||
except:
|
||||
pass
|
||||
|
||||
self.qmytranslator = QtCore.QTranslator()
|
||||
translationpath = os.path.join(
|
||||
paths.codePath(), 'translations', 'bitmessage_' + newlocale)
|
||||
self.qmytranslator.load(translationpath)
|
||||
QtGui.QApplication.installTranslator(self.qmytranslator)
|
||||
|
||||
self.qsystranslator = QtCore.QTranslator()
|
||||
if paths.frozen:
|
||||
translationpath = os.path.join(
|
||||
paths.codePath(), 'translations', 'qt_' + newlocale)
|
||||
else:
|
||||
translationpath = os.path.join(
|
||||
str(QtCore.QLibraryInfo.location(
|
||||
QtCore.QLibraryInfo.TranslationsPath)), 'qt_' + newlocale)
|
||||
self.qsystranslator.load(translationpath)
|
||||
QtGui.QApplication.installTranslator(self.qsystranslator)
|
||||
|
||||
lang = locale.normalize(l10n.getTranslationLanguage())
|
||||
langs = [
|
||||
lang.split(".")[0] + "." + l10n.encoding,
|
||||
lang.split(".")[0] + "." + 'UTF-8',
|
||||
lang
|
||||
]
|
||||
if 'win32' in sys.platform or 'win64' in sys.platform:
|
||||
langs = [l10n.getWindowsLocale(lang)]
|
||||
for lang in langs:
|
||||
try:
|
||||
l10n.setlocale(locale.LC_ALL, lang)
|
||||
if 'win32' not in sys.platform and 'win64' not in sys.platform:
|
||||
l10n.encoding = locale.nl_langinfo(locale.CODESET)
|
||||
else:
|
||||
l10n.encoding = locale.getlocale()[1]
|
||||
logger.info("Successfully set locale to %s", lang)
|
||||
break
|
||||
except:
|
||||
logger.error("Failed to set locale to %s", lang, exc_info=True)
|
||||
|
||||
def init_file_menu(self):
|
||||
QtCore.QObject.connect(self.ui.actionExit, QtCore.SIGNAL(
|
||||
"triggered()"), self.quit)
|
||||
|
@ -417,7 +414,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
|
||||
def rerenderTabTreeSubscriptions(self):
|
||||
treeWidget = self.ui.treeWidgetSubscriptions
|
||||
folders = Ui_FolderWidget.folderWeight.keys()
|
||||
folders = list(Ui_FolderWidget.folderWeight.keys())
|
||||
folders.remove("new")
|
||||
|
||||
# sort ascending when creating
|
||||
|
@ -429,7 +426,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
db = getSortedSubscriptions(True)
|
||||
for address in db:
|
||||
for folder in folders:
|
||||
if folder not in db[address]:
|
||||
if not folder in db[address]:
|
||||
db[address][folder] = {}
|
||||
|
||||
if treeWidget.isSortingEnabled():
|
||||
|
@ -444,7 +441,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
else:
|
||||
toAddress = None
|
||||
|
||||
if toAddress not in db:
|
||||
if not toAddress in db:
|
||||
treeWidget.takeTopLevelItem(i)
|
||||
# no increment
|
||||
continue
|
||||
|
@ -465,7 +462,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
# add missing folders
|
||||
if len(db[toAddress]) > 0:
|
||||
j = 0
|
||||
for f, c in db[toAddress].iteritems():
|
||||
for f, c in db[toAddress].items():
|
||||
try:
|
||||
subwidget = Ui_FolderWidget(widget, j, toAddress, f, c['count'])
|
||||
except KeyError:
|
||||
|
@ -492,6 +489,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
|
||||
treeWidget.setSortingEnabled(True)
|
||||
|
||||
|
||||
def rerenderTabTreeMessages(self):
|
||||
self.rerenderTabTree('messages')
|
||||
|
||||
|
@ -503,7 +501,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
treeWidget = self.ui.treeWidgetYourIdentities
|
||||
elif tab == 'chan':
|
||||
treeWidget = self.ui.treeWidgetChans
|
||||
folders = Ui_FolderWidget.folderWeight.keys()
|
||||
folders = list(Ui_FolderWidget.folderWeight.keys())
|
||||
|
||||
# sort ascending when creating
|
||||
if treeWidget.topLevelItemCount() == 0:
|
||||
|
@ -562,7 +560,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
else:
|
||||
toAddress = None
|
||||
|
||||
if toAddress not in db:
|
||||
if not toAddress in db:
|
||||
treeWidget.takeTopLevelItem(i)
|
||||
# no increment
|
||||
continue
|
||||
|
@ -571,9 +569,8 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
while j < widget.childCount():
|
||||
subwidget = widget.child(j)
|
||||
try:
|
||||
subwidget.setUnreadCount(
|
||||
db[toAddress][subwidget.folderName])
|
||||
if subwidget.folderName not in ("new", "trash", "sent"):
|
||||
subwidget.setUnreadCount(db[toAddress][subwidget.folderName])
|
||||
if subwidget.folderName not in ["new", "trash", "sent"]:
|
||||
unread += db[toAddress][subwidget.folderName]
|
||||
db[toAddress].pop(subwidget.folderName, None)
|
||||
except:
|
||||
|
@ -585,11 +582,11 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
# add missing folders
|
||||
if len(db[toAddress]) > 0:
|
||||
j = 0
|
||||
for f, c in db[toAddress].iteritems():
|
||||
for f, c in db[toAddress].items():
|
||||
if toAddress is not None and tab == 'messages' and folder == "new":
|
||||
continue
|
||||
subwidget = Ui_FolderWidget(widget, j, toAddress, f, c)
|
||||
if subwidget.folderName not in ("new", "trash", "sent"):
|
||||
if subwidget.folderName not in ["new", "trash", "sent"]:
|
||||
unread += c
|
||||
j += 1
|
||||
widget.setUnreadCount(unread)
|
||||
|
@ -605,7 +602,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
if toAddress is not None and tab == 'messages' and folder == "new":
|
||||
continue
|
||||
subwidget = Ui_FolderWidget(widget, j, toAddress, folder, db[toAddress][folder])
|
||||
if subwidget.folderName not in ("new", "trash", "sent"):
|
||||
if subwidget.folderName not in ["new", "trash", "sent"]:
|
||||
unread += db[toAddress][folder]
|
||||
j += 1
|
||||
widget.setUnreadCount(unread)
|
||||
|
@ -618,13 +615,6 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
self.ui = Ui_MainWindow()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
self.qmytranslator = self.qsystranslator = None
|
||||
self.indicatorUpdate = None
|
||||
self.actionStatus = None
|
||||
|
||||
# the last time that a message arrival sound was played
|
||||
self.lastSoundTime = datetime.now() - timedelta(days=1)
|
||||
|
||||
# Ask the user if we may delete their old version 1 addresses if they
|
||||
# have any.
|
||||
for addressInKeysFile in getSortedAccounts():
|
||||
|
@ -640,7 +630,22 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
BMConfigParser().remove_section(addressInKeysFile)
|
||||
BMConfigParser().save()
|
||||
|
||||
self.change_translation()
|
||||
# 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:
|
||||
# Auto-startup for Windows
|
||||
RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"
|
||||
self.settings = QtCore.QSettings(RUN_PATH, QtCore.QSettings.NativeFormat)
|
||||
self.settings.remove(
|
||||
"PyBitmessage") # In case the user moves the program and the registry entry is no longer valid, this will delete the old registry entry.
|
||||
if BMConfigParser().getboolean('bitmessagesettings', 'startonlogon'):
|
||||
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
|
||||
|
||||
# e.g. for editing labels
|
||||
self.recurDepth = 0
|
||||
|
@ -740,6 +745,9 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
QtCore.QObject.connect(self.pushButtonStatusIcon, QtCore.SIGNAL(
|
||||
"clicked()"), self.click_pushButtonStatusIcon)
|
||||
|
||||
self.numberOfMessagesProcessed = 0
|
||||
self.numberOfBroadcastsProcessed = 0
|
||||
self.numberOfPubkeysProcessed = 0
|
||||
self.unreadCount = 0
|
||||
|
||||
# Set the icon sizes for the identicons
|
||||
|
@ -788,9 +796,6 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
self.ui.treeWidgetSubscriptions.keyPressEvent = self.treeWidgetKeyPressEvent
|
||||
self.ui.treeWidgetChans.keyPressEvent = self.treeWidgetKeyPressEvent
|
||||
|
||||
# Key press in addressbook
|
||||
self.ui.tableWidgetAddressBook.keyPressEvent = self.addressbookKeyPressEvent
|
||||
|
||||
# Key press in messagelist
|
||||
self.ui.tableWidgetInbox.keyPressEvent = self.tableWidgetKeyPressEvent
|
||||
self.ui.tableWidgetInboxSubscriptions.keyPressEvent = self.tableWidgetKeyPressEvent
|
||||
|
@ -821,15 +826,6 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
|
||||
self.initSettings()
|
||||
self.resetNamecoinConnection()
|
||||
self.sqlInit()
|
||||
self.indicatorInit()
|
||||
self.notifierInit()
|
||||
self.updateStartOnLogon()
|
||||
|
||||
self.ui.updateNetworkSwitchMenuLabel()
|
||||
|
||||
self._firstrun = BMConfigParser().safeGetBoolean(
|
||||
'bitmessagesettings', 'dontconnect')
|
||||
|
||||
self._contact_selected = None
|
||||
|
||||
|
@ -842,30 +838,6 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
finally:
|
||||
self._contact_selected = None
|
||||
|
||||
def updateStartOnLogon(self):
|
||||
"""
|
||||
Configure Bitmessage to start on startup (or remove the
|
||||
configuration) based on the setting in the keys.dat file
|
||||
"""
|
||||
startonlogon = BMConfigParser().safeGetBoolean(
|
||||
'bitmessagesettings', 'startonlogon')
|
||||
if sys.platform.startswith('win'): # Auto-startup for Windows
|
||||
RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"
|
||||
settings = QtCore.QSettings(
|
||||
RUN_PATH, QtCore.QSettings.NativeFormat)
|
||||
# In case the user moves the program and the registry entry is
|
||||
# no longer valid, this will delete the old registry entry.
|
||||
if startonlogon:
|
||||
settings.setValue("PyBitmessage", sys.argv[0])
|
||||
else:
|
||||
settings.remove("PyBitmessage")
|
||||
else:
|
||||
try: # get desktop plugin if any
|
||||
self.desktop = get_plugin('desktop')()
|
||||
self.desktop.adjust_startonlogon(startonlogon)
|
||||
except (NameError, TypeError):
|
||||
self.desktop = False
|
||||
|
||||
def updateTTL(self, sliderPosition):
|
||||
TTL = int(sliderPosition ** 3.199 + 3600)
|
||||
self.updateHumanFriendlyTTLDescription(TTL)
|
||||
|
@ -873,7 +845,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
BMConfigParser().save()
|
||||
|
||||
def updateHumanFriendlyTTLDescription(self, TTL):
|
||||
numberOfHours = int(round(TTL / (60*60)))
|
||||
numberOfHours = int(round(old_div(TTL, (60*60))))
|
||||
font = QtGui.QFont()
|
||||
stylesheet = ""
|
||||
|
||||
|
@ -886,7 +858,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
stylesheet = "QLabel { color : red; }"
|
||||
font.setBold(True)
|
||||
else:
|
||||
numberOfDays = int(round(TTL / (24*60*60)))
|
||||
numberOfDays = int(round(old_div(TTL, (24*60*60))))
|
||||
self.ui.labelHumanFriendlyTTLDescription.setText(_translate("MainWindow", "%n day(s)", None, QtCore.QCoreApplication.CodecForTr, numberOfDays))
|
||||
font.setBold(False)
|
||||
self.ui.labelHumanFriendlyTTLDescription.setStyleSheet(stylesheet)
|
||||
|
@ -981,29 +953,39 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
Switch unread for item of msgid and related items in
|
||||
other STableWidgets "All Accounts" and "Chans"
|
||||
"""
|
||||
status = widget.item(row, 0).unread
|
||||
if status != unread:
|
||||
return
|
||||
|
||||
widgets = [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxChans]
|
||||
rrow = None
|
||||
related = [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxChans]
|
||||
try:
|
||||
widgets.remove(widget)
|
||||
related = widgets.pop()
|
||||
related.remove(widget)
|
||||
related = related.pop()
|
||||
except ValueError:
|
||||
pass
|
||||
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 range(related.rowCount()):
|
||||
if related.item(rrow, 3).data() == msgid:
|
||||
if msgid == str(related.item(rrow, 3).data(
|
||||
QtCore.Qt.UserRole).toPyObject()):
|
||||
break
|
||||
else:
|
||||
rrow = None
|
||||
|
||||
for col in range(widget.columnCount()):
|
||||
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)
|
||||
if rrow:
|
||||
|
||||
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)
|
||||
|
||||
# Here we need to update unread count for:
|
||||
|
@ -1050,7 +1032,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
for i in range(root.childCount()):
|
||||
addressItem = root.child(i)
|
||||
if addressItem.type == AccountMixin.ALL:
|
||||
newCount = sum(totalUnread.itervalues())
|
||||
newCount = sum(totalUnread.values())
|
||||
self.drawTrayIcon(self.currentTrayIconFileName, newCount)
|
||||
else:
|
||||
try:
|
||||
|
@ -1058,7 +1040,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
broadcastsUnread
|
||||
if addressItem.type == AccountMixin.SUBSCRIPTION
|
||||
else normalUnread
|
||||
)[addressItem.address].itervalues())
|
||||
)[addressItem.address].values())
|
||||
except KeyError:
|
||||
newCount = 0
|
||||
if newCount != addressItem.unreadCount:
|
||||
|
@ -1089,46 +1071,43 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
if sortingEnabled:
|
||||
tableWidget.setSortingEnabled(False)
|
||||
tableWidget.insertRow(0)
|
||||
for i, item in enumerate(items):
|
||||
tableWidget.setItem(0, i, item)
|
||||
for i in range(len(items)):
|
||||
tableWidget.setItem(0, i, items[i])
|
||||
if sortingEnabled:
|
||||
tableWidget.setSortingEnabled(True)
|
||||
|
||||
def addMessageListItemSent(
|
||||
self, tableWidget, toAddress, fromAddress, subject,
|
||||
status, ackdata, lastactiontime
|
||||
):
|
||||
acct = accountClass(fromAddress) or BMAccount(fromAddress)
|
||||
def addMessageListItemSent(self, tableWidget, toAddress, fromAddress, subject, status, ackdata, lastactiontime):
|
||||
acct = accountClass(fromAddress)
|
||||
if acct is None:
|
||||
acct = BMAccount(fromAddress)
|
||||
acct.parseMessage(toAddress, fromAddress, subject, "")
|
||||
|
||||
items = []
|
||||
MessageList_AddressWidget(items, str(toAddress), str(acct.toLabel, 'utf-8'))
|
||||
MessageList_AddressWidget(items, str(fromAddress), str(acct.fromLabel, 'utf-8'))
|
||||
MessageList_SubjectWidget(items, str(subject), str(acct.subject, 'utf-8', 'replace'))
|
||||
|
||||
if status == 'awaitingpubkey':
|
||||
statusText = _translate(
|
||||
"MainWindow",
|
||||
"Waiting for their encryption key. Will request it again soon."
|
||||
)
|
||||
"MainWindow", "Waiting for their encryption key. Will request it again soon.")
|
||||
elif status == 'doingpowforpubkey':
|
||||
statusText = _translate(
|
||||
"MainWindow", "Doing work necessary to request encryption key."
|
||||
)
|
||||
"MainWindow", "Doing work necessary to request encryption key.")
|
||||
elif status == 'msgqueued':
|
||||
statusText = _translate("MainWindow", "Queued.")
|
||||
statusText = _translate(
|
||||
"MainWindow", "Queued.")
|
||||
elif status == 'msgsent':
|
||||
statusText = _translate(
|
||||
"MainWindow",
|
||||
"Message sent. Waiting for acknowledgement. Sent at %1"
|
||||
).arg(l10n.formatTimestamp(lastactiontime))
|
||||
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))
|
||||
statusText = _translate("MainWindow", "Message sent. Sent at %1").arg(
|
||||
l10n.formatTimestamp(lastactiontime))
|
||||
elif status == 'doingmsgpow':
|
||||
statusText = _translate(
|
||||
"MainWindow", "Doing work necessary to send message.")
|
||||
elif status == 'ackreceived':
|
||||
statusText = _translate(
|
||||
"MainWindow",
|
||||
"Acknowledgement of the message received %1"
|
||||
).arg(l10n.formatTimestamp(lastactiontime))
|
||||
statusText = _translate("MainWindow", "Acknowledgement of the message received %1").arg(
|
||||
l10n.formatTimestamp(lastactiontime))
|
||||
elif status == 'broadcastqueued':
|
||||
statusText = _translate(
|
||||
"MainWindow", "Broadcast queued.")
|
||||
|
@ -1139,64 +1118,58 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
statusText = _translate("MainWindow", "Broadcast on %1").arg(
|
||||
l10n.formatTimestamp(lastactiontime))
|
||||
elif status == 'toodifficult':
|
||||
statusText = _translate(
|
||||
"MainWindow",
|
||||
"Problem: The work demanded by the recipient is more"
|
||||
" difficult than you are willing to do. %1"
|
||||
).arg(l10n.formatTimestamp(lastactiontime))
|
||||
statusText = _translate("MainWindow", "Problem: The work demanded by the recipient is more difficult than you are willing to do. %1").arg(
|
||||
l10n.formatTimestamp(lastactiontime))
|
||||
elif status == 'badkey':
|
||||
statusText = _translate(
|
||||
"MainWindow",
|
||||
"Problem: The recipient\'s encryption key is no good."
|
||||
" Could not encrypt message. %1"
|
||||
).arg(l10n.formatTimestamp(lastactiontime))
|
||||
statusText = _translate("MainWindow", "Problem: The recipient\'s encryption key is no good. Could not encrypt message. %1").arg(
|
||||
l10n.formatTimestamp(lastactiontime))
|
||||
elif status == 'forcepow':
|
||||
statusText = _translate(
|
||||
"MainWindow",
|
||||
"Forced difficulty override. Send should start soon.")
|
||||
"MainWindow", "Forced difficulty override. Send should start soon.")
|
||||
else:
|
||||
statusText = _translate(
|
||||
"MainWindow", "Unknown status: %1 %2").arg(status).arg(
|
||||
statusText = _translate("MainWindow", "Unknown status: %1 %2").arg(status).arg(
|
||||
l10n.formatTimestamp(lastactiontime))
|
||||
|
||||
items = [
|
||||
MessageList_AddressWidget(
|
||||
toAddress, unicode(acct.toLabel, 'utf-8')),
|
||||
MessageList_AddressWidget(
|
||||
fromAddress, unicode(acct.fromLabel, 'utf-8')),
|
||||
MessageList_SubjectWidget(
|
||||
str(subject), unicode(acct.subject, 'utf-8', 'replace')),
|
||||
MessageList_TimeWidget(
|
||||
statusText, False, lastactiontime, ackdata)]
|
||||
newItem = myTableWidgetItem(statusText)
|
||||
newItem.setToolTip(statusText)
|
||||
newItem.setData(QtCore.Qt.UserRole, QtCore.QByteArray(ackdata))
|
||||
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, toAddress, fromAddress, subject,
|
||||
msgid, received, read
|
||||
):
|
||||
def addMessageListItemInbox(self, tableWidget, msgfolder, msgid, toAddress, fromAddress, subject, received, read):
|
||||
font = QtGui.QFont()
|
||||
font.setBold(True)
|
||||
if toAddress == str_broadcast_subscribers:
|
||||
acct = accountClass(fromAddress)
|
||||
else:
|
||||
acct = accountClass(toAddress) or accountClass(fromAddress)
|
||||
acct = accountClass(toAddress)
|
||||
if acct is None:
|
||||
acct = accountClass(fromAddress)
|
||||
if acct is None:
|
||||
acct = BMAccount(fromAddress)
|
||||
acct.parseMessage(toAddress, fromAddress, subject, "")
|
||||
|
||||
items = [
|
||||
MessageList_AddressWidget(
|
||||
toAddress, unicode(acct.toLabel, 'utf-8'), not read),
|
||||
MessageList_AddressWidget(
|
||||
fromAddress, unicode(acct.fromLabel, 'utf-8'), not read),
|
||||
MessageList_SubjectWidget(
|
||||
str(subject), unicode(acct.subject, 'utf-8', 'replace'),
|
||||
not read),
|
||||
MessageList_TimeWidget(
|
||||
l10n.formatTimestamp(received), not read, received, msgid)
|
||||
]
|
||||
items = []
|
||||
#to
|
||||
MessageList_AddressWidget(items, toAddress, str(acct.toLabel, 'utf-8'), not read)
|
||||
# from
|
||||
MessageList_AddressWidget(items, fromAddress, str(acct.fromLabel, 'utf-8'), not read)
|
||||
# subject
|
||||
MessageList_SubjectWidget(items, str(subject), str(acct.subject, 'utf-8', 'replace'), not read)
|
||||
# time received
|
||||
time_item = myTableWidgetItem(l10n.formatTimestamp(received))
|
||||
time_item.setToolTip(l10n.formatTimestamp(received))
|
||||
time_item.setData(QtCore.Qt.UserRole, QtCore.QByteArray(msgid))
|
||||
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
|
||||
|
||||
# Load Sent items from database
|
||||
|
@ -1211,40 +1184,35 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
xAddress = 'both'
|
||||
else:
|
||||
tableWidget.setColumnHidden(0, False)
|
||||
tableWidget.setColumnHidden(1, bool(account))
|
||||
if account is None:
|
||||
tableWidget.setColumnHidden(1, False)
|
||||
else:
|
||||
tableWidget.setColumnHidden(1, True)
|
||||
xAddress = 'fromaddress'
|
||||
|
||||
queryreturn = helper_search.search_sql(
|
||||
xAddress, account, "sent", where, what, False)
|
||||
tableWidget.setUpdatesEnabled(False)
|
||||
tableWidget.setSortingEnabled(False)
|
||||
tableWidget.setRowCount(0)
|
||||
queryreturn = helper_search.search_sql(xAddress, account, "sent", where, what, False)
|
||||
|
||||
for row in queryreturn:
|
||||
self.addMessageListItemSent(tableWidget, *row)
|
||||
toAddress, fromAddress, subject, status, ackdata, lastactiontime = row
|
||||
self.addMessageListItemSent(tableWidget, toAddress, fromAddress, subject, status, ackdata, lastactiontime)
|
||||
|
||||
tableWidget.horizontalHeader().setSortIndicator(
|
||||
3, QtCore.Qt.DescendingOrder)
|
||||
tableWidget.setSortingEnabled(True)
|
||||
tableWidget.horizontalHeaderItem(3).setText(
|
||||
_translate("MainWindow", "Sent"))
|
||||
tableWidget.horizontalHeaderItem(3).setText(_translate("MainWindow", "Sent", None))
|
||||
tableWidget.setUpdatesEnabled(True)
|
||||
|
||||
# Load messages from database file
|
||||
def loadMessagelist(
|
||||
self, tableWidget, account, folder="inbox", where="", what="",
|
||||
unreadOnly=False
|
||||
):
|
||||
tableWidget.setUpdatesEnabled(False)
|
||||
tableWidget.setSortingEnabled(False)
|
||||
tableWidget.setRowCount(0)
|
||||
|
||||
def loadMessagelist(self, tableWidget, account, folder="inbox", where="", what="", unreadOnly = False):
|
||||
if folder == 'sent':
|
||||
self.loadSent(tableWidget, account, where, what)
|
||||
return
|
||||
|
||||
if tableWidget == self.ui.tableWidgetInboxSubscriptions:
|
||||
xAddress = "fromaddress"
|
||||
if not what:
|
||||
where = _translate("MainWindow", "To")
|
||||
what = str_broadcast_subscribers
|
||||
else:
|
||||
xAddress = "toaddress"
|
||||
if account is not None:
|
||||
|
@ -1254,21 +1222,21 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
tableWidget.setColumnHidden(0, False)
|
||||
tableWidget.setColumnHidden(1, False)
|
||||
|
||||
queryreturn = helper_search.search_sql(
|
||||
xAddress, account, folder, where, what, unreadOnly)
|
||||
tableWidget.setUpdatesEnabled(False)
|
||||
tableWidget.setSortingEnabled(False)
|
||||
tableWidget.setRowCount(0)
|
||||
|
||||
queryreturn = helper_search.search_sql(xAddress, account, folder, where, what, unreadOnly)
|
||||
|
||||
for row in queryreturn:
|
||||
toAddress, fromAddress, subject, _, msgid, received, read = row
|
||||
self.addMessageListItemInbox(
|
||||
tableWidget, toAddress, fromAddress, subject,
|
||||
msgid, received, read)
|
||||
msgfolder, msgid, toAddress, fromAddress, subject, received, read = row
|
||||
self.addMessageListItemInbox(tableWidget, msgfolder, msgid, toAddress, fromAddress, subject, received, read)
|
||||
|
||||
tableWidget.horizontalHeader().setSortIndicator(
|
||||
3, QtCore.Qt.DescendingOrder)
|
||||
tableWidget.setSortingEnabled(True)
|
||||
tableWidget.selectRow(0)
|
||||
tableWidget.horizontalHeaderItem(3).setText(
|
||||
_translate("MainWindow", "Received"))
|
||||
tableWidget.horizontalHeaderItem(3).setText(_translate("MainWindow", "Received", None))
|
||||
tableWidget.setUpdatesEnabled(True)
|
||||
|
||||
# create application indicator
|
||||
|
@ -1424,11 +1392,9 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
def sqlInit(self):
|
||||
register_adapter(QtCore.QByteArray, str)
|
||||
|
||||
# Try init the distro specific appindicator,
|
||||
# for example the Ubuntu MessagingMenu
|
||||
def indicatorInit(self):
|
||||
"""
|
||||
Try init the distro specific appindicator,
|
||||
for example the Ubuntu MessagingMenu
|
||||
"""
|
||||
def _noop_update(*args, **kwargs):
|
||||
pass
|
||||
|
||||
|
@ -1471,21 +1437,12 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
self, title, subtitle, category, label=None, icon=None):
|
||||
self.playSound(category, label)
|
||||
self._notifier(
|
||||
unicode(title), unicode(subtitle), category, label, icon)
|
||||
str(title), str(subtitle), category, label, icon)
|
||||
|
||||
# tree
|
||||
def treeWidgetKeyPressEvent(self, event):
|
||||
return self.handleKeyPress(event, self.getCurrentTreeWidget())
|
||||
|
||||
# addressbook
|
||||
def addressbookKeyPressEvent(self, event):
|
||||
"""Handle keypress event in addressbook widget"""
|
||||
if event.key() == QtCore.Qt.Key_Delete:
|
||||
self.on_action_AddressBookDelete()
|
||||
else:
|
||||
return QtGui.QTableWidget.keyPressEvent(
|
||||
self.ui.tableWidgetAddressBook, event)
|
||||
|
||||
# inbox / sent
|
||||
def tableWidgetKeyPressEvent(self, event):
|
||||
return self.handleKeyPress(event, self.getCurrentMessagelist())
|
||||
|
@ -1494,12 +1451,11 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
def textEditKeyPressEvent(self, event):
|
||||
return self.handleKeyPress(event, self.getCurrentMessageTextedit())
|
||||
|
||||
def handleKeyPress(self, event, focus=None):
|
||||
"""This method handles keypress events for all widgets on MyForm"""
|
||||
def handleKeyPress(self, event, focus = None):
|
||||
messagelist = self.getCurrentMessagelist()
|
||||
if event.key() == QtCore.Qt.Key_Delete:
|
||||
if isinstance(focus, (MessageView, QtGui.QTableWidget)):
|
||||
folder = self.getCurrentFolder()
|
||||
if event.key() == QtCore.Qt.Key_Delete:
|
||||
if isinstance (focus, MessageView) or isinstance(focus, QtGui.QTableWidget):
|
||||
if folder == "sent":
|
||||
self.on_action_SentTrash()
|
||||
else:
|
||||
|
@ -1535,18 +1491,17 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
self.ui.lineEditTo.setFocus()
|
||||
event.ignore()
|
||||
elif event.key() == QtCore.Qt.Key_F:
|
||||
try:
|
||||
self.getCurrentSearchLine(retObj=True).setFocus()
|
||||
except AttributeError:
|
||||
pass
|
||||
searchline = self.getCurrentSearchLine(retObj = True)
|
||||
if searchline:
|
||||
searchline.setFocus()
|
||||
event.ignore()
|
||||
if not event.isAccepted():
|
||||
return
|
||||
if isinstance(focus, MessageView):
|
||||
if isinstance (focus, MessageView):
|
||||
return MessageView.keyPressEvent(focus, event)
|
||||
if isinstance(focus, QtGui.QTableWidget):
|
||||
elif isinstance (focus, QtGui.QTableWidget):
|
||||
return QtGui.QTableWidget.keyPressEvent(focus, event)
|
||||
if isinstance(focus, QtGui.QTreeWidget):
|
||||
elif isinstance (focus, QtGui.QTreeWidget):
|
||||
return QtGui.QTreeWidget.keyPressEvent(focus, event)
|
||||
|
||||
# menu button 'manage keys'
|
||||
|
@ -1571,7 +1526,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
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)
|
||||
if reply == QtGui.QMessageBox.Yes:
|
||||
openKeysFile()
|
||||
shared.openKeysFile()
|
||||
|
||||
# menu button 'delete all treshed messages'
|
||||
def click_actionDeleteAllTrashedMessages(self):
|
||||
|
@ -1644,7 +1599,6 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
dialog = dialogs.ConnectDialog(self)
|
||||
if dialog.exec_():
|
||||
if dialog.radioButtonConnectNow.isChecked():
|
||||
self.ui.updateNetworkSwitchMenuLabel(False)
|
||||
BMConfigParser().remove_option(
|
||||
'bitmessagesettings', 'dontconnect')
|
||||
BMConfigParser().save()
|
||||
|
@ -1678,6 +1632,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
# The window state has just been changed to
|
||||
# Normal/Maximised/FullScreen
|
||||
pass
|
||||
# QtGui.QWidget.changeEvent(self, event)
|
||||
|
||||
def __icon_activated(self, reason):
|
||||
if reason == QtGui.QSystemTrayIcon.Trigger:
|
||||
|
@ -1694,7 +1649,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
if color == 'red':
|
||||
self.pushButtonStatusIcon.setIcon(
|
||||
QtGui.QIcon(":/newPrefix/images/redicon.png"))
|
||||
state.statusIconColor = 'red'
|
||||
shared.statusIconColor = 'red'
|
||||
# if the connection is lost then show a notification
|
||||
if self.connected and _notifications_enabled:
|
||||
self.notifierShow(
|
||||
|
@ -1720,7 +1675,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
self.statusbar.clearMessage()
|
||||
self.pushButtonStatusIcon.setIcon(
|
||||
QtGui.QIcon(":/newPrefix/images/yellowicon.png"))
|
||||
state.statusIconColor = 'yellow'
|
||||
shared.statusIconColor = 'yellow'
|
||||
# if a new connection has been established then show a notification
|
||||
if not self.connected and _notifications_enabled:
|
||||
self.notifierShow(
|
||||
|
@ -1738,7 +1693,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
self.statusbar.clearMessage()
|
||||
self.pushButtonStatusIcon.setIcon(
|
||||
QtGui.QIcon(":/newPrefix/images/greenicon.png"))
|
||||
state.statusIconColor = 'green'
|
||||
shared.statusIconColor = 'green'
|
||||
if not self.connected and _notifications_enabled:
|
||||
self.notifierShow(
|
||||
'Bitmessage',
|
||||
|
@ -1761,7 +1716,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
self.drawTrayIcon(iconFileName, self.findInboxUnreadCount())
|
||||
|
||||
def calcTrayIcon(self, iconFileName, inboxUnreadCount):
|
||||
pixmap = QtGui.QPixmap(":/newPrefix/images/" + iconFileName)
|
||||
pixmap = QtGui.QPixmap(":/newPrefix/images/"+iconFileName)
|
||||
if inboxUnreadCount > 0:
|
||||
# choose font and calculate font parameters
|
||||
fontName = "Lucida"
|
||||
|
@ -1773,8 +1728,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
rect = fontMetrics.boundingRect(txt)
|
||||
# margins that we add in the top-right corner
|
||||
marginX = 2
|
||||
# it looks like -2 is also ok due to the error of metric
|
||||
marginY = 0
|
||||
marginY = 0 # it looks like -2 is also ok due to the error of metric
|
||||
# if it renders too wide we need to change it to a plus symbol
|
||||
if rect.width() > 20:
|
||||
txt = "+"
|
||||
|
@ -1814,18 +1768,11 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
return self.unreadCount
|
||||
|
||||
def updateSentItemStatusByToAddress(self, toAddress, textToDisplay):
|
||||
for sent in (
|
||||
self.ui.tableWidgetInbox,
|
||||
self.ui.tableWidgetInboxSubscriptions,
|
||||
self.ui.tableWidgetInboxChans
|
||||
):
|
||||
for sent in [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxChans]:
|
||||
treeWidget = self.widgetConvert(sent)
|
||||
if self.getCurrentFolder(treeWidget) != "sent":
|
||||
continue
|
||||
if treeWidget in (
|
||||
self.ui.treeWidgetSubscriptions,
|
||||
self.ui.treeWidgetChans
|
||||
) and self.getCurrentAccount(treeWidget) != toAddress:
|
||||
if treeWidget in [self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans] and self.getCurrentAccount(treeWidget) != toAddress:
|
||||
continue
|
||||
|
||||
for i in range(sent.rowCount()):
|
||||
|
@ -1845,17 +1792,15 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
def updateSentItemStatusByAckdata(self, ackdata, textToDisplay):
|
||||
if type(ackdata) is str:
|
||||
ackdata = QtCore.QByteArray(ackdata)
|
||||
for sent in (
|
||||
self.ui.tableWidgetInbox,
|
||||
self.ui.tableWidgetInboxSubscriptions,
|
||||
self.ui.tableWidgetInboxChans
|
||||
):
|
||||
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()):
|
||||
toAddress = sent.item(i, 0).data(QtCore.Qt.UserRole)
|
||||
tableAckdata = sent.item(i, 3).data()
|
||||
toAddress = sent.item(
|
||||
i, 0).data(QtCore.Qt.UserRole)
|
||||
tableAckdata = sent.item(
|
||||
i, 3).data(QtCore.Qt.UserRole).toPyObject()
|
||||
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
|
||||
toAddress)
|
||||
if ackdata == tableAckdata:
|
||||
|
@ -1879,7 +1824,8 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
):
|
||||
i = None
|
||||
for i in range(inbox.rowCount()):
|
||||
if msgid == inbox.item(i, 3).data():
|
||||
if msgid == \
|
||||
inbox.item(i, 3).data(QtCore.Qt.UserRole).toPyObject():
|
||||
break
|
||||
else:
|
||||
continue
|
||||
|
@ -1920,9 +1866,9 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
def rerenderAddressBook(self):
|
||||
def addRow (address, label, type):
|
||||
self.ui.tableWidgetAddressBook.insertRow(0)
|
||||
newItem = Ui_AddressBookWidgetItemLabel(address, unicode(label, 'utf-8'), type)
|
||||
newItem = Ui_AddressBookWidgetItemLabel(address, str(label, 'utf-8'), type)
|
||||
self.ui.tableWidgetAddressBook.setItem(0, 0, newItem)
|
||||
newItem = Ui_AddressBookWidgetItemAddress(address, unicode(label, 'utf-8'), type)
|
||||
newItem = Ui_AddressBookWidgetItemAddress(address, str(label, 'utf-8'), type)
|
||||
self.ui.tableWidgetAddressBook.setItem(0, 1, newItem)
|
||||
|
||||
oldRows = {}
|
||||
|
@ -1954,17 +1900,15 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
newRows[address] = [label, AccountMixin.NORMAL]
|
||||
|
||||
completerList = []
|
||||
for address in sorted(
|
||||
oldRows, key=lambda x: oldRows[x][2], reverse=True
|
||||
):
|
||||
try:
|
||||
completerList.append(
|
||||
newRows.pop(address)[0] + " <" + address + ">")
|
||||
except KeyError:
|
||||
for address in sorted(oldRows, key = lambda x: oldRows[x][2], reverse = True):
|
||||
if address in newRows:
|
||||
completerList.append(str(newRows[address][0], encoding="UTF-8") + " <" + address + ">")
|
||||
newRows.pop(address)
|
||||
else:
|
||||
self.ui.tableWidgetAddressBook.removeRow(oldRows[address][2])
|
||||
for address in newRows:
|
||||
addRow(address, newRows[address][0], newRows[address][1])
|
||||
completerList.append(unicode(newRows[address][0], encoding="UTF-8") + " <" + address + ">")
|
||||
completerList.append(str(newRows[address][0], encoding="UTF-8") + " <" + address + ">")
|
||||
|
||||
# sort
|
||||
self.ui.tableWidgetAddressBook.sortByColumn(
|
||||
|
@ -2033,14 +1977,11 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
|
||||
acct = accountClass(fromAddress)
|
||||
|
||||
# To send a message to specific people (rather than broadcast)
|
||||
if sendMessageToPeople:
|
||||
toAddressesList = set([
|
||||
s.strip() for s in toAddresses.replace(',', ';').split(';')
|
||||
])
|
||||
# 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.
|
||||
if sendMessageToPeople: # To send a message to specific people (rather than broadcast)
|
||||
toAddressesList = [s.strip()
|
||||
for s in toAddresses.replace(',', ';').split(';')]
|
||||
toAddressesList = list(set(
|
||||
toAddressesList)) # 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.
|
||||
for toAddress in toAddressesList:
|
||||
if toAddress != '':
|
||||
# label plus address
|
||||
|
@ -2075,10 +2016,11 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
).arg(email)
|
||||
)
|
||||
return
|
||||
status, addressVersionNumber, streamNumber = decodeAddress(toAddress)[:3]
|
||||
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
|
||||
toAddress)
|
||||
if status != 'success':
|
||||
try:
|
||||
toAddress = unicode(toAddress, 'utf-8', 'ignore')
|
||||
toAddress = str(toAddress, 'utf-8', 'ignore')
|
||||
except:
|
||||
pass
|
||||
logger.error('Error: Could not decode recipient address ' + toAddress + ':' + status)
|
||||
|
@ -2158,7 +2100,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
"MainWindow", "Concerning the address %1, Bitmessage cannot handle stream numbers of %2. Perhaps upgrade Bitmessage to the latest version.").arg(toAddress).arg(str(streamNumber)))
|
||||
continue
|
||||
self.statusbar.clearMessage()
|
||||
if state.statusIconColor == 'red':
|
||||
if shared.statusIconColor == 'red':
|
||||
self.updateStatusBar(_translate(
|
||||
"MainWindow",
|
||||
"Warning: You are currently not connected."
|
||||
|
@ -2166,9 +2108,29 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
" send the message but it won\'t send until"
|
||||
" you connect.")
|
||||
)
|
||||
ackdata = helper_sent.insert(
|
||||
toAddress=toAddress, fromAddress=fromAddress,
|
||||
subject=subject, message=message, encoding=encoding)
|
||||
stealthLevel = BMConfigParser().safeGetInt(
|
||||
'bitmessagesettings', 'ackstealthlevel')
|
||||
ackdata = genAckPayload(streamNumber, stealthLevel)
|
||||
t = ()
|
||||
sqlExecute(
|
||||
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
|
||||
'',
|
||||
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.
|
||||
'msgqueued',
|
||||
0, # retryNumber
|
||||
'sent', # folder
|
||||
encoding, # encodingtype
|
||||
BMConfigParser().getint('bitmessagesettings', 'ttl')
|
||||
)
|
||||
|
||||
toLabel = ''
|
||||
queryreturn = sqlQuery('''select label from addressbook where address=?''',
|
||||
toAddress)
|
||||
|
@ -2202,13 +2164,28 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
# 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.
|
||||
streamNumber = decodeAddress(fromAddress)[2]
|
||||
ackdata = genAckPayload(streamNumber, 0)
|
||||
toAddress = str_broadcast_subscribers
|
||||
|
||||
# msgid. We don't know what this will be until the POW is done.
|
||||
ackdata = helper_sent.insert(
|
||||
fromAddress=fromAddress,
|
||||
subject=subject, message=message,
|
||||
status='broadcastqueued', encoding=encoding)
|
||||
ripe = ''
|
||||
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')
|
||||
)
|
||||
sqlExecute(
|
||||
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)
|
||||
|
||||
toLabel = str_broadcast_subscribers
|
||||
|
||||
|
@ -2268,7 +2245,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read.
|
||||
isMaillinglist = BMConfigParser().safeGetBoolean(addressInKeysFile, 'mailinglist')
|
||||
if isEnabled and not isMaillinglist:
|
||||
label = unicode(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip()
|
||||
label = str(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip()
|
||||
if label == "":
|
||||
label = addressInKeysFile
|
||||
self.ui.comboBoxSendFrom.addItem(avatarize(addressInKeysFile), label, addressInKeysFile)
|
||||
|
@ -2292,7 +2269,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read.
|
||||
isChan = BMConfigParser().safeGetBoolean(addressInKeysFile, 'chan')
|
||||
if isEnabled and not isChan:
|
||||
label = unicode(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip()
|
||||
label = str(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip()
|
||||
if label == "":
|
||||
label = addressInKeysFile
|
||||
self.ui.comboBoxSendFromBroadcast.addItem(avatarize(addressInKeysFile), label, addressInKeysFile)
|
||||
|
@ -2312,111 +2289,71 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
# 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.
|
||||
def displayNewSentMessage(
|
||||
self, toAddress, toLabel, fromAddress, subject,
|
||||
message, ackdata):
|
||||
def displayNewSentMessage(self, toAddress, toLabel, fromAddress, subject, message, ackdata):
|
||||
acct = accountClass(fromAddress)
|
||||
acct.parseMessage(toAddress, fromAddress, subject, message)
|
||||
tab = -1
|
||||
for sent in (
|
||||
self.ui.tableWidgetInbox,
|
||||
self.ui.tableWidgetInboxSubscriptions,
|
||||
self.ui.tableWidgetInboxChans
|
||||
):
|
||||
for sent in [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxChans]:
|
||||
tab += 1
|
||||
if tab == 1:
|
||||
tab = 2
|
||||
treeWidget = self.widgetConvert(sent)
|
||||
if self.getCurrentFolder(treeWidget) != "sent":
|
||||
continue
|
||||
if treeWidget == self.ui.treeWidgetYourIdentities \
|
||||
and self.getCurrentAccount(treeWidget) not in (
|
||||
fromAddress, None, False):
|
||||
if treeWidget == self.ui.treeWidgetYourIdentities and self.getCurrentAccount(treeWidget) not in (fromAddress, None, False):
|
||||
continue
|
||||
elif treeWidget in (
|
||||
self.ui.treeWidgetSubscriptions,
|
||||
self.ui.treeWidgetChans
|
||||
) and self.getCurrentAccount(treeWidget) != toAddress:
|
||||
elif treeWidget in [self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans] and self.getCurrentAccount(treeWidget) != toAddress:
|
||||
continue
|
||||
elif not helper_search.check_match(
|
||||
toAddress, fromAddress, subject, message,
|
||||
self.getCurrentSearchOption(tab),
|
||||
self.getCurrentSearchLine(tab)
|
||||
):
|
||||
elif not helper_search.check_match(toAddress, fromAddress, subject, message, self.getCurrentSearchOption(tab), self.getCurrentSearchLine(tab)):
|
||||
continue
|
||||
|
||||
self.addMessageListItemSent(
|
||||
sent, toAddress, fromAddress, subject,
|
||||
"msgqueued", ackdata, time.time())
|
||||
self.getAccountTextedit(acct).setPlainText(message)
|
||||
self.addMessageListItemSent(sent, toAddress, fromAddress, subject, "msgqueued", ackdata, time.time())
|
||||
self.getAccountTextedit(acct).setPlainText(str(message, 'utf-8', 'replace'))
|
||||
sent.setCurrentCell(0, 0)
|
||||
|
||||
def displayNewInboxMessage(
|
||||
self, inventoryHash, toAddress, fromAddress, subject, message):
|
||||
acct = accountClass(
|
||||
fromAddress if toAddress == str_broadcast_subscribers
|
||||
else toAddress
|
||||
)
|
||||
def displayNewInboxMessage(self, inventoryHash, toAddress, fromAddress, subject, message):
|
||||
if toAddress == str_broadcast_subscribers:
|
||||
acct = accountClass(fromAddress)
|
||||
else:
|
||||
acct = accountClass(toAddress)
|
||||
inbox = self.getAccountMessagelist(acct)
|
||||
ret = treeWidget = None
|
||||
ret = None
|
||||
tab = -1
|
||||
for treeWidget in (
|
||||
self.ui.treeWidgetYourIdentities,
|
||||
self.ui.treeWidgetSubscriptions,
|
||||
self.ui.treeWidgetChans
|
||||
):
|
||||
for treeWidget in [self.ui.treeWidgetYourIdentities, self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans]:
|
||||
tab += 1
|
||||
if tab == 1:
|
||||
tab = 2
|
||||
if not helper_search.check_match(
|
||||
toAddress, fromAddress, subject, message,
|
||||
self.getCurrentSearchOption(tab),
|
||||
self.getCurrentSearchLine(tab)
|
||||
):
|
||||
continue
|
||||
tableWidget = self.widgetConvert(treeWidget)
|
||||
current_account = self.getCurrentAccount(treeWidget)
|
||||
current_folder = self.getCurrentFolder(treeWidget)
|
||||
# pylint: disable=too-many-boolean-expressions
|
||||
if ((tableWidget == inbox
|
||||
and current_account == acct.address
|
||||
and current_folder in ("inbox", None))
|
||||
or (treeWidget == self.ui.treeWidgetYourIdentities
|
||||
and current_account is None
|
||||
and current_folder in ("inbox", "new", None))):
|
||||
ret = self.addMessageListItemInbox(
|
||||
tableWidget, toAddress, fromAddress, subject,
|
||||
inventoryHash, time.time(), False)
|
||||
|
||||
if not helper_search.check_match(toAddress, fromAddress, subject, message, self.getCurrentSearchOption(tab), self.getCurrentSearchLine(tab)):
|
||||
continue
|
||||
if tableWidget == inbox and self.getCurrentAccount(treeWidget) == acct.address and self.getCurrentFolder(treeWidget) in ["inbox", None]:
|
||||
ret = self.addMessageListItemInbox(inbox, "inbox", inventoryHash, toAddress, fromAddress, subject, time.time(), 0)
|
||||
elif treeWidget == self.ui.treeWidgetYourIdentities and self.getCurrentAccount(treeWidget) is None and self.getCurrentFolder(treeWidget) in ["inbox", "new", None]:
|
||||
ret = self.addMessageListItemInbox(tableWidget, "inbox", inventoryHash, toAddress, fromAddress, subject, time.time(), 0)
|
||||
if ret is None:
|
||||
acct.parseMessage(toAddress, fromAddress, subject, "")
|
||||
else:
|
||||
acct = ret
|
||||
# pylint:disable=undefined-loop-variable
|
||||
self.propagateUnreadCount(widget=treeWidget if ret else None)
|
||||
if BMConfigParser().safeGetBoolean(
|
||||
if BMConfigParser().getboolean(
|
||||
'bitmessagesettings', 'showtraynotifications'):
|
||||
self.notifierShow(
|
||||
_translate("MainWindow", "New Message"),
|
||||
_translate("MainWindow", "From %1").arg(
|
||||
unicode(acct.fromLabel, 'utf-8')),
|
||||
str(acct.fromLabel, 'utf-8')),
|
||||
sound.SOUND_UNKNOWN
|
||||
)
|
||||
if self.getCurrentAccount() is not None and (
|
||||
(self.getCurrentFolder(treeWidget) != "inbox"
|
||||
and self.getCurrentFolder(treeWidget) is not None)
|
||||
or self.getCurrentAccount(treeWidget) != acct.address):
|
||||
# Ubuntu should notify of new message irrespective of
|
||||
if self.getCurrentAccount() is not None and ((self.getCurrentFolder(treeWidget) != "inbox" and self.getCurrentFolder(treeWidget) is not None) or self.getCurrentAccount(treeWidget) != acct.address):
|
||||
# Ubuntu should notify of new message irespective of
|
||||
# whether it's in current message list or not
|
||||
self.indicatorUpdate(True, to_label=acct.toLabel)
|
||||
|
||||
try:
|
||||
if acct.feedback != GatewayAccount.ALL_OK:
|
||||
# cannot find item to pass here ):
|
||||
if hasattr(acct, "feedback") \
|
||||
and acct.feedback != GatewayAccount.ALL_OK:
|
||||
if acct.feedback == GatewayAccount.REGISTRATION_DENIED:
|
||||
dialogs.EmailGatewayDialog(
|
||||
self, BMConfigParser(), acct).exec_()
|
||||
# possible other branches?
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def click_pushButtonAddAddressBook(self, dialog=None):
|
||||
if not dialog:
|
||||
|
@ -2439,15 +2376,15 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
))
|
||||
return
|
||||
|
||||
if helper_addressbook.insert(label=label, address=address):
|
||||
self.addEntryToAddressBook(address, label)
|
||||
|
||||
def addEntryToAddressBook(self, address, label):
|
||||
if shared.isAddressInMyAddressBook(address):
|
||||
return
|
||||
sqlExecute('''INSERT INTO addressbook VALUES (?,?)''', label, address)
|
||||
self.rerenderMessagelistFromLabels()
|
||||
self.rerenderMessagelistToLabels()
|
||||
self.rerenderAddressBook()
|
||||
else:
|
||||
self.updateStatusBar(_translate(
|
||||
"MainWindow",
|
||||
"Error: You cannot add your own address in the address book."
|
||||
))
|
||||
|
||||
def addSubscription(self, address, label):
|
||||
# This should be handled outside of this function, for error displaying
|
||||
|
@ -2507,7 +2444,225 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
dialogs.AboutDialog(self).exec_()
|
||||
|
||||
def click_actionSettings(self):
|
||||
dialogs.SettingsDialog(self, firstrun=self._firstrun).exec_()
|
||||
self.settingsDialogInstance = settingsDialog(self)
|
||||
if self._firstrun:
|
||||
self.settingsDialogInstance.ui.tabWidgetSettings.setCurrentIndex(1)
|
||||
if self.settingsDialogInstance.exec_():
|
||||
if self._firstrun:
|
||||
BMConfigParser().remove_option(
|
||||
'bitmessagesettings', 'dontconnect')
|
||||
BMConfigParser().set('bitmessagesettings', 'startonlogon', str(
|
||||
self.settingsDialogInstance.ui.checkBoxStartOnLogon.isChecked()))
|
||||
BMConfigParser().set('bitmessagesettings', 'minimizetotray', str(
|
||||
self.settingsDialogInstance.ui.checkBoxMinimizeToTray.isChecked()))
|
||||
BMConfigParser().set('bitmessagesettings', 'trayonclose', str(
|
||||
self.settingsDialogInstance.ui.checkBoxTrayOnClose.isChecked()))
|
||||
BMConfigParser().set('bitmessagesettings', 'hidetrayconnectionnotifications', str(
|
||||
self.settingsDialogInstance.ui.checkBoxHideTrayConnectionNotifications.isChecked()))
|
||||
BMConfigParser().set('bitmessagesettings', 'showtraynotifications', str(
|
||||
self.settingsDialogInstance.ui.checkBoxShowTrayNotifications.isChecked()))
|
||||
BMConfigParser().set('bitmessagesettings', 'startintray', str(
|
||||
self.settingsDialogInstance.ui.checkBoxStartInTray.isChecked()))
|
||||
BMConfigParser().set('bitmessagesettings', 'willinglysendtomobile', str(
|
||||
self.settingsDialogInstance.ui.checkBoxWillinglySendToMobile.isChecked()))
|
||||
BMConfigParser().set('bitmessagesettings', 'useidenticons', str(
|
||||
self.settingsDialogInstance.ui.checkBoxUseIdenticons.isChecked()))
|
||||
BMConfigParser().set('bitmessagesettings', 'replybelow', str(
|
||||
self.settingsDialogInstance.ui.checkBoxReplyBelow.isChecked()))
|
||||
|
||||
lang = str(self.settingsDialogInstance.ui.languageComboBox.itemData(self.settingsDialogInstance.ui.languageComboBox.currentIndex()).toString())
|
||||
BMConfigParser().set('bitmessagesettings', 'userlocale', lang)
|
||||
change_translation(l10n.getTranslationLanguage())
|
||||
|
||||
if int(BMConfigParser().get('bitmessagesettings', 'port')) != int(self.settingsDialogInstance.ui.lineEditTCPPort.text()):
|
||||
if not BMConfigParser().safeGetBoolean('bitmessagesettings', 'dontconnect'):
|
||||
QtGui.QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate(
|
||||
"MainWindow", "You must restart Bitmessage for the port number change to take effect."))
|
||||
BMConfigParser().set('bitmessagesettings', 'port', str(
|
||||
self.settingsDialogInstance.ui.lineEditTCPPort.text()))
|
||||
if self.settingsDialogInstance.ui.checkBoxUPnP.isChecked() != BMConfigParser().safeGetBoolean('bitmessagesettings', 'upnp'):
|
||||
BMConfigParser().set('bitmessagesettings', 'upnp', str(self.settingsDialogInstance.ui.checkBoxUPnP.isChecked()))
|
||||
if self.settingsDialogInstance.ui.checkBoxUPnP.isChecked():
|
||||
import upnp
|
||||
upnpThread = upnp.uPnPThread()
|
||||
upnpThread.start()
|
||||
#print 'self.settingsDialogInstance.ui.comboBoxProxyType.currentText()', self.settingsDialogInstance.ui.comboBoxProxyType.currentText()
|
||||
#print 'self.settingsDialogInstance.ui.comboBoxProxyType.currentText())[0:5]', self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5]
|
||||
if BMConfigParser().get('bitmessagesettings', 'socksproxytype') == 'none' and self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] == 'SOCKS':
|
||||
if shared.statusIconColor != 'red':
|
||||
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 BMConfigParser().get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] != 'SOCKS':
|
||||
self.statusbar.clearMessage()
|
||||
state.resetNetworkProtocolAvailability() # just in case we changed something in the network connectivity
|
||||
if self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] == 'SOCKS':
|
||||
BMConfigParser().set('bitmessagesettings', 'socksproxytype', str(
|
||||
self.settingsDialogInstance.ui.comboBoxProxyType.currentText()))
|
||||
else:
|
||||
BMConfigParser().set('bitmessagesettings', 'socksproxytype', 'none')
|
||||
BMConfigParser().set('bitmessagesettings', 'socksauthentication', str(
|
||||
self.settingsDialogInstance.ui.checkBoxAuthentication.isChecked()))
|
||||
BMConfigParser().set('bitmessagesettings', 'sockshostname', str(
|
||||
self.settingsDialogInstance.ui.lineEditSocksHostname.text()))
|
||||
BMConfigParser().set('bitmessagesettings', 'socksport', str(
|
||||
self.settingsDialogInstance.ui.lineEditSocksPort.text()))
|
||||
BMConfigParser().set('bitmessagesettings', 'socksusername', str(
|
||||
self.settingsDialogInstance.ui.lineEditSocksUsername.text()))
|
||||
BMConfigParser().set('bitmessagesettings', 'sockspassword', str(
|
||||
self.settingsDialogInstance.ui.lineEditSocksPassword.text()))
|
||||
BMConfigParser().set('bitmessagesettings', 'sockslisten', str(
|
||||
self.settingsDialogInstance.ui.checkBoxSocksListen.isChecked()))
|
||||
try:
|
||||
# Rounding to integers just for aesthetics
|
||||
BMConfigParser().set('bitmessagesettings', 'maxdownloadrate', str(
|
||||
int(float(self.settingsDialogInstance.ui.lineEditMaxDownloadRate.text()))))
|
||||
BMConfigParser().set('bitmessagesettings', 'maxuploadrate', str(
|
||||
int(float(self.settingsDialogInstance.ui.lineEditMaxUploadRate.text()))))
|
||||
except ValueError:
|
||||
QtGui.QMessageBox.about(self, _translate("MainWindow", "Number needed"), _translate(
|
||||
"MainWindow", "Your maximum download and upload rate must be numbers. Ignoring what you typed."))
|
||||
else:
|
||||
set_rates(BMConfigParser().safeGetInt("bitmessagesettings", "maxdownloadrate"),
|
||||
BMConfigParser().safeGetInt("bitmessagesettings", "maxuploadrate"))
|
||||
|
||||
BMConfigParser().set('bitmessagesettings', 'maxoutboundconnections', str(
|
||||
int(float(self.settingsDialogInstance.ui.lineEditMaxOutboundConnections.text()))))
|
||||
|
||||
BMConfigParser().set('bitmessagesettings', 'namecoinrpctype',
|
||||
self.settingsDialogInstance.getNamecoinType())
|
||||
BMConfigParser().set('bitmessagesettings', 'namecoinrpchost', str(
|
||||
self.settingsDialogInstance.ui.lineEditNamecoinHost.text()))
|
||||
BMConfigParser().set('bitmessagesettings', 'namecoinrpcport', str(
|
||||
self.settingsDialogInstance.ui.lineEditNamecoinPort.text()))
|
||||
BMConfigParser().set('bitmessagesettings', 'namecoinrpcuser', str(
|
||||
self.settingsDialogInstance.ui.lineEditNamecoinUser.text()))
|
||||
BMConfigParser().set('bitmessagesettings', 'namecoinrpcpassword', str(
|
||||
self.settingsDialogInstance.ui.lineEditNamecoinPassword.text()))
|
||||
self.resetNamecoinConnection()
|
||||
|
||||
# Demanded difficulty tab
|
||||
if float(self.settingsDialogInstance.ui.lineEditTotalDifficulty.text()) >= 1:
|
||||
BMConfigParser().set('bitmessagesettings', 'defaultnoncetrialsperbyte', str(int(float(
|
||||
self.settingsDialogInstance.ui.lineEditTotalDifficulty.text()) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
||||
if float(self.settingsDialogInstance.ui.lineEditSmallMessageDifficulty.text()) >= 1:
|
||||
BMConfigParser().set('bitmessagesettings', 'defaultpayloadlengthextrabytes', str(int(float(
|
||||
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()))
|
||||
queues.workerQueue.put(('resetPoW', ''))
|
||||
|
||||
acceptableDifficultyChanged = False
|
||||
|
||||
if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) >= 1 or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) == 0:
|
||||
if BMConfigParser().get('bitmessagesettings','maxacceptablenoncetrialsperbyte') != str(int(float(
|
||||
self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)):
|
||||
# the user changed the max acceptable total difficulty
|
||||
acceptableDifficultyChanged = True
|
||||
BMConfigParser().set('bitmessagesettings', 'maxacceptablenoncetrialsperbyte', str(int(float(
|
||||
self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
||||
if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1 or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0:
|
||||
if BMConfigParser().get('bitmessagesettings','maxacceptablepayloadlengthextrabytes') != str(int(float(
|
||||
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) * defaults.networkDefaultPayloadLengthExtraBytes)):
|
||||
# the user changed the max acceptable small message difficulty
|
||||
acceptableDifficultyChanged = True
|
||||
BMConfigParser().set('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', str(int(float(
|
||||
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) * defaults.networkDefaultPayloadLengthExtraBytes)))
|
||||
if acceptableDifficultyChanged:
|
||||
# It might now be possible to send msgs which were previously marked as toodifficult.
|
||||
# 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' ''')
|
||||
queues.workerQueue.put(('sendmessage', ''))
|
||||
|
||||
#start:UI setting to stop trying to send messages after X days/months
|
||||
# I'm open to changing this UI to something else if someone has a better idea.
|
||||
if ((self.settingsDialogInstance.ui.lineEditDays.text()=='') and (self.settingsDialogInstance.ui.lineEditMonths.text()=='')):#We need to handle this special case. Bitmessage has its default behavior. The input is blank/blank
|
||||
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxdays', '')
|
||||
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxmonths', '')
|
||||
shared.maximumLengthOfTimeToBotherResendingMessages = float('inf')
|
||||
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:
|
||||
if (float(self.settingsDialogInstance.ui.lineEditDays.text()) >=0 and float(self.settingsDialogInstance.ui.lineEditMonths.text()) >=0):
|
||||
shared.maximumLengthOfTimeToBotherResendingMessages = (float(str(self.settingsDialogInstance.ui.lineEditDays.text())) * 24 * 60 * 60) + (float(str(self.settingsDialogInstance.ui.lineEditMonths.text())) * (60 * 60 * 24 *365)/12)
|
||||
if shared.maximumLengthOfTimeToBotherResendingMessages < 432000: # If the time period is less than 5 hours, we give zero values to all fields. No message will be sent again.
|
||||
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."))
|
||||
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxdays', '0')
|
||||
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxmonths', '0')
|
||||
shared.maximumLengthOfTimeToBotherResendingMessages = 0
|
||||
else:
|
||||
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxdays', str(float(
|
||||
self.settingsDialogInstance.ui.lineEditDays.text())))
|
||||
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxmonths', str(float(
|
||||
self.settingsDialogInstance.ui.lineEditMonths.text())))
|
||||
|
||||
BMConfigParser().save()
|
||||
|
||||
if 'win32' in sys.platform or 'win64' in sys.platform:
|
||||
# Auto-startup for Windows
|
||||
RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"
|
||||
self.settings = QtCore.QSettings(RUN_PATH, QtCore.QSettings.NativeFormat)
|
||||
if BMConfigParser().getboolean('bitmessagesettings', 'startonlogon'):
|
||||
self.settings.setValue("PyBitmessage", sys.argv[0])
|
||||
else:
|
||||
self.settings.remove("PyBitmessage")
|
||||
elif 'darwin' in sys.platform:
|
||||
# startup for mac
|
||||
pass
|
||||
elif 'linux' in sys.platform:
|
||||
# startup for linux
|
||||
pass
|
||||
|
||||
if state.appdata != paths.lookupExeFolder() and self.settingsDialogInstance.ui.checkBoxPortableMode.isChecked(): # If we are NOT using portable mode now but the user selected that we should...
|
||||
# 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.resetLogging()
|
||||
try:
|
||||
os.remove(previousAppdataLocation + 'debug.log')
|
||||
os.remove(previousAppdataLocation + 'debug.log.1')
|
||||
except:
|
||||
pass
|
||||
|
||||
if state.appdata == paths.lookupExeFolder() and not self.settingsDialogInstance.ui.checkBoxPortableMode.isChecked(): # If we ARE using portable mode now but the user selected that we shouldn't...
|
||||
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.resetLogging()
|
||||
try:
|
||||
os.remove(paths.lookupExeFolder() + 'debug.log')
|
||||
os.remove(paths.lookupExeFolder() + 'debug.log.1')
|
||||
except:
|
||||
pass
|
||||
|
||||
def on_action_Send(self):
|
||||
"""Send message to current selected address"""
|
||||
|
@ -2569,11 +2724,17 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
if idCount == 0:
|
||||
return
|
||||
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
|
||||
msgids = []
|
||||
for i in range(0, idCount):
|
||||
msgids.append(tableWidget.item(i, 3).data())
|
||||
for col in xrange(tableWidget.columnCount()):
|
||||
tableWidget.item(i, col).setUnread(False)
|
||||
msgids.append(str(tableWidget.item(
|
||||
i, 3).data(QtCore.Qt.UserRole).toPyObject()))
|
||||
tableWidget.item(i, 0).setUnread(False)
|
||||
tableWidget.item(i, 1).setUnread(False)
|
||||
tableWidget.item(i, 2).setUnread(False)
|
||||
tableWidget.item(i, 3).setFont(font)
|
||||
|
||||
markread = sqlExecuteChunked(
|
||||
"UPDATE inbox SET read = 1 WHERE msgid IN({0}) AND read=0",
|
||||
|
@ -2641,8 +2802,10 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
) + "\n\n" +
|
||||
_translate(
|
||||
"MainWindow", "Wait until these tasks finish?"),
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
|
||||
| QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel)
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No |
|
||||
QtGui.QMessageBox.Cancel,
|
||||
QtGui.QMessageBox.Cancel
|
||||
)
|
||||
if reply == QtGui.QMessageBox.No:
|
||||
waitForPow = False
|
||||
elif reply == QtGui.QMessageBox.Cancel:
|
||||
|
@ -2659,14 +2822,16 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
" synchronisation finishes?", None,
|
||||
QtCore.QCoreApplication.CodecForTr, pendingDownload()
|
||||
),
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
|
||||
| QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel)
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No |
|
||||
QtGui.QMessageBox.Cancel,
|
||||
QtGui.QMessageBox.Cancel
|
||||
)
|
||||
if reply == QtGui.QMessageBox.Yes:
|
||||
self.wait = waitForSync = True
|
||||
elif reply == QtGui.QMessageBox.Cancel:
|
||||
return
|
||||
|
||||
if state.statusIconColor == 'red' and not BMConfigParser().safeGetBoolean(
|
||||
if shared.statusIconColor == 'red' and not BMConfigParser().safeGetBoolean(
|
||||
'bitmessagesettings', 'dontconnect'):
|
||||
reply = QtGui.QMessageBox.question(
|
||||
self, _translate("MainWindow", "Not connected"),
|
||||
|
@ -2676,8 +2841,10 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
" 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)
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No |
|
||||
QtGui.QMessageBox.Cancel,
|
||||
QtGui.QMessageBox.Cancel
|
||||
)
|
||||
if reply == QtGui.QMessageBox.Yes:
|
||||
waitForConnection = True
|
||||
self.wait = waitForSync = True
|
||||
|
@ -2692,7 +2859,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
if waitForConnection:
|
||||
self.updateStatusBar(_translate(
|
||||
"MainWindow", "Waiting for network connection..."))
|
||||
while state.statusIconColor == 'red':
|
||||
while shared.statusIconColor == 'red':
|
||||
time.sleep(0.5)
|
||||
QtCore.QCoreApplication.processEvents(
|
||||
QtCore.QEventLoop.AllEvents, 1000
|
||||
|
@ -2722,8 +2889,8 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
if curWorkerQueue > 0:
|
||||
self.updateStatusBar(_translate(
|
||||
"MainWindow", "Waiting for PoW to finish... %1%"
|
||||
).arg(50 * (maxWorkerQueue - curWorkerQueue) /
|
||||
maxWorkerQueue))
|
||||
).arg(old_div(50 * (maxWorkerQueue - curWorkerQueue),
|
||||
maxWorkerQueue)))
|
||||
time.sleep(0.5)
|
||||
QtCore.QCoreApplication.processEvents(
|
||||
QtCore.QEventLoop.AllEvents, 1000
|
||||
|
@ -2751,7 +2918,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
self.updateStatusBar(_translate(
|
||||
"MainWindow",
|
||||
"Waiting for objects to be sent... %1%"
|
||||
).arg(int(50 + 20 * (pendingUpload() / maxPendingUpload))))
|
||||
).arg(int(50 + 20 * (old_div(pendingUpload(), maxPendingUpload)))))
|
||||
time.sleep(0.5)
|
||||
QtCore.QCoreApplication.processEvents(
|
||||
QtCore.QEventLoop.AllEvents, 1000
|
||||
|
@ -2771,7 +2938,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
QtCore.QEventLoop.AllEvents, 1000
|
||||
)
|
||||
self.saveSettings()
|
||||
for attr, obj in self.ui.__dict__.iteritems():
|
||||
for attr, obj in self.ui.__dict__.items():
|
||||
if hasattr(obj, "__class__") \
|
||||
and isinstance(obj, settingsmixin.SettingsMixin):
|
||||
saveMethod = getattr(obj, "saveSettings", None)
|
||||
|
@ -2784,7 +2951,6 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
QtCore.QEventLoop.AllEvents, 1000
|
||||
)
|
||||
shutdown.doCleanShutdown()
|
||||
|
||||
self.updateStatusBar(_translate(
|
||||
"MainWindow", "Stopping notifications... %1%").arg(90))
|
||||
self.tray.hide()
|
||||
|
@ -2793,21 +2959,20 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
"MainWindow", "Shutdown imminent... %1%").arg(100))
|
||||
|
||||
logger.info("Shutdown complete")
|
||||
self.close()
|
||||
# FIXME: rewrite loops with timer instead
|
||||
if self.wait:
|
||||
self.destroy()
|
||||
app.quit()
|
||||
super(MyForm, myapp).close()
|
||||
# return
|
||||
sys.exit()
|
||||
|
||||
# window close event
|
||||
def closeEvent(self, event):
|
||||
"""window close event"""
|
||||
event.ignore()
|
||||
self.appIndicatorHide()
|
||||
|
||||
trayonclose = BMConfigParser().safeGetBoolean(
|
||||
'bitmessagesettings', 'trayonclose')
|
||||
if trayonclose:
|
||||
self.appIndicatorHide()
|
||||
else:
|
||||
# custom quit method
|
||||
|
||||
event.ignore()
|
||||
if not trayonclose:
|
||||
# quit the application
|
||||
self.quit()
|
||||
|
||||
def on_action_InboxMessageForceHtml(self):
|
||||
|
@ -2823,7 +2988,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
|
||||
lines = messageText.split('\n')
|
||||
totalLines = len(lines)
|
||||
for i in xrange(totalLines):
|
||||
for i in range(totalLines):
|
||||
if 'Message ostensibly from ' in lines[i]:
|
||||
lines[i] = '<p style="font-size: 12px; color: grey;">%s</span></p>' % (
|
||||
lines[i])
|
||||
|
@ -2834,7 +2999,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
lines[i] = '<br><br>'
|
||||
content = ' '.join(lines) # To keep the whitespace between lines
|
||||
content = shared.fixPotentiallyInvalidUTF8Data(content)
|
||||
content = unicode(content, 'utf-8)')
|
||||
content = str(content, 'utf-8)')
|
||||
textEdit.setHtml(QtCore.QString(content))
|
||||
|
||||
def on_action_InboxMarkUnread(self):
|
||||
|
@ -2846,7 +3011,8 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
# modified = 0
|
||||
for row in tableWidget.selectedIndexes():
|
||||
currentRow = row.row()
|
||||
msgid = tableWidget.item(currentRow, 3).data()
|
||||
msgid = str(tableWidget.item(
|
||||
currentRow, 3).data(QtCore.Qt.UserRole).toPyObject())
|
||||
msgids.add(msgid)
|
||||
# if not tableWidget.item(currentRow, 0).unread:
|
||||
# modified += 1
|
||||
|
@ -2874,11 +3040,11 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
if not BMConfigParser().safeGetBoolean('bitmessagesettings', 'replybelow'):
|
||||
return '\n\n------------------------------------------------------\n' + message
|
||||
|
||||
quoteWrapper = textwrap.TextWrapper(
|
||||
replace_whitespace=False, initial_indent='> ',
|
||||
subsequent_indent='> ', break_long_words=False,
|
||||
break_on_hyphens=False)
|
||||
|
||||
quoteWrapper = textwrap.TextWrapper(replace_whitespace = False,
|
||||
initial_indent = '> ',
|
||||
subsequent_indent = '> ',
|
||||
break_long_words = False,
|
||||
break_on_hyphens = False)
|
||||
def quote_line(line):
|
||||
# Do quote empty lines.
|
||||
if line == '' or line.isspace():
|
||||
|
@ -2891,20 +3057,18 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
return quoteWrapper.fill(line)
|
||||
return '\n'.join([quote_line(l) for l in message.splitlines()]) + '\n\n'
|
||||
|
||||
def setSendFromComboBox(self, address=None):
|
||||
def setSendFromComboBox(self, address = None):
|
||||
if address is None:
|
||||
messagelist = self.getCurrentMessagelist()
|
||||
if not messagelist:
|
||||
return
|
||||
if messagelist:
|
||||
currentInboxRow = messagelist.currentRow()
|
||||
address = messagelist.item(currentInboxRow, 0).address
|
||||
for box in (
|
||||
self.ui.comboBoxSendFrom, self.ui.comboBoxSendFromBroadcast
|
||||
):
|
||||
for i in range(box.count()):
|
||||
if str(box.itemData(i).toPyObject()) == address:
|
||||
box.setCurrentIndex(i)
|
||||
break
|
||||
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)
|
||||
|
||||
|
@ -2936,7 +3100,8 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
acct = accountClass(toAddressAtCurrentInboxRow)
|
||||
fromAddressAtCurrentInboxRow = tableWidget.item(
|
||||
currentInboxRow, column_from).address
|
||||
msgid = tableWidget.item(currentInboxRow, 3).data()
|
||||
msgid = str(tableWidget.item(
|
||||
currentInboxRow, 3).data(QtCore.Qt.UserRole).toPyObject())
|
||||
queryreturn = sqlQuery(
|
||||
"SELECT message FROM inbox WHERE msgid=?", msgid
|
||||
) or sqlQuery("SELECT message FROM sent WHERE ackdata=?", msgid)
|
||||
|
@ -3017,9 +3182,9 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
self.setSendFromComboBox(toAddressAtCurrentInboxRow)
|
||||
|
||||
quotedText = self.quoted_text(
|
||||
unicode(messageAtCurrentInboxRow, 'utf-8', 'replace'))
|
||||
str(messageAtCurrentInboxRow, 'utf-8', 'replace'))
|
||||
widget['message'].setPlainText(quotedText)
|
||||
if acct.subject[0:3] in ('Re:', 'RE:'):
|
||||
if acct.subject[0:3] in ['Re:', 'RE:']:
|
||||
widget['subject'].setText(
|
||||
tableWidget.item(currentInboxRow, 2).label)
|
||||
else:
|
||||
|
@ -3035,6 +3200,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
if not tableWidget:
|
||||
return
|
||||
currentInboxRow = tableWidget.currentRow()
|
||||
# tableWidget.item(currentRow,1).data(Qt.UserRole).toPyObject()
|
||||
addressAtCurrentInboxRow = tableWidget.item(
|
||||
currentInboxRow, 1).data(QtCore.Qt.UserRole)
|
||||
self.ui.tabWidget.setCurrentIndex(
|
||||
|
@ -3048,6 +3214,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
if not tableWidget:
|
||||
return
|
||||
currentInboxRow = tableWidget.currentRow()
|
||||
# tableWidget.item(currentRow,1).data(Qt.UserRole).toPyObject()
|
||||
addressAtCurrentInboxRow = tableWidget.item(
|
||||
currentInboxRow, 1).data(QtCore.Qt.UserRole)
|
||||
recipientAddress = tableWidget.item(
|
||||
|
@ -3071,28 +3238,23 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
"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
|
||||
):
|
||||
def deleteRowFromMessagelist(self, row = None, inventoryHash = None, ackData = None, messageLists = None):
|
||||
if messageLists is None:
|
||||
messageLists = (
|
||||
self.ui.tableWidgetInbox,
|
||||
self.ui.tableWidgetInboxChans,
|
||||
self.ui.tableWidgetInboxSubscriptions
|
||||
)
|
||||
messageLists = (self.ui.tableWidgetInbox, self.ui.tableWidgetInboxChans, self.ui.tableWidgetInboxSubscriptions)
|
||||
elif type(messageLists) not in (list, tuple):
|
||||
messageLists = (messageLists,)
|
||||
messageLists = (messageLists)
|
||||
for messageList in messageLists:
|
||||
if row is not None:
|
||||
inventoryHash = messageList.item(row, 3).data()
|
||||
inventoryHash = str(messageList.item(row, 3).data(
|
||||
QtCore.Qt.UserRole).toPyObject())
|
||||
messageList.removeRow(row)
|
||||
elif inventoryHash is not None:
|
||||
for i in range(messageList.rowCount() - 1, -1, -1):
|
||||
if messageList.item(i, 3).data() == inventoryHash:
|
||||
if messageList.item(i, 3).data(QtCore.Qt.UserRole).toPyObject() == inventoryHash:
|
||||
messageList.removeRow(i)
|
||||
elif ackData is not None:
|
||||
for i in range(messageList.rowCount() - 1, -1, -1):
|
||||
if messageList.item(i, 3).data() == ackData:
|
||||
if messageList.item(i, 3).data(QtCore.Qt.UserRole).toPyObject() == ackData:
|
||||
messageList.removeRow(i)
|
||||
|
||||
# Send item on the Inbox tab to trash
|
||||
|
@ -3102,25 +3264,24 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
return
|
||||
currentRow = 0
|
||||
folder = self.getCurrentFolder()
|
||||
shifted = QtGui.QApplication.queryKeyboardModifiers() \
|
||||
& QtCore.Qt.ShiftModifier
|
||||
tableWidget.setUpdatesEnabled(False)
|
||||
inventoryHashesToTrash = set()
|
||||
shifted = QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier
|
||||
tableWidget.setUpdatesEnabled(False);
|
||||
inventoryHashesToTrash = []
|
||||
# ranges in reversed order
|
||||
for r in sorted(
|
||||
tableWidget.selectedRanges(), key=lambda r: r.topRow()
|
||||
)[::-1]:
|
||||
for i in range(r.bottomRow() - r.topRow() + 1):
|
||||
inventoryHashesToTrash.add(
|
||||
tableWidget.item(r.topRow() + i, 3).data())
|
||||
for r in sorted(tableWidget.selectedRanges(), key=lambda r: r.topRow())[::-1]:
|
||||
for i in range(r.bottomRow()-r.topRow()+1):
|
||||
inventoryHashToTrash = str(tableWidget.item(
|
||||
r.topRow()+i, 3).data(QtCore.Qt.UserRole).toPyObject())
|
||||
if inventoryHashToTrash in inventoryHashesToTrash:
|
||||
continue
|
||||
inventoryHashesToTrash.append(inventoryHashToTrash)
|
||||
currentRow = r.topRow()
|
||||
self.getCurrentMessageTextedit().setText("")
|
||||
tableWidget.model().removeRows(
|
||||
r.topRow(), r.bottomRow() - r.topRow() + 1)
|
||||
tableWidget.model().removeRows(r.topRow(), r.bottomRow()-r.topRow()+1)
|
||||
idCount = len(inventoryHashesToTrash)
|
||||
sqlExecuteChunked(
|
||||
("DELETE FROM inbox" if folder == "trash" or shifted else
|
||||
"UPDATE inbox SET folder='trash', read=1") +
|
||||
"DELETE FROM inbox" if folder == "trash" or shifted else
|
||||
"UPDATE inbox SET folder='trash'"
|
||||
" WHERE msgid IN ({0})", idCount, *inventoryHashesToTrash)
|
||||
tableWidget.selectRow(0 if currentRow == 0 else currentRow - 1)
|
||||
tableWidget.setUpdatesEnabled(True)
|
||||
|
@ -3133,22 +3294,21 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
return
|
||||
currentRow = 0
|
||||
tableWidget.setUpdatesEnabled(False)
|
||||
inventoryHashesToTrash = set()
|
||||
inventoryHashesToTrash = []
|
||||
# ranges in reversed order
|
||||
for r in sorted(
|
||||
tableWidget.selectedRanges(), key=lambda r: r.topRow()
|
||||
)[::-1]:
|
||||
for i in range(r.bottomRow() - r.topRow() + 1):
|
||||
inventoryHashesToTrash.add(
|
||||
tableWidget.item(r.topRow() + i, 3).data())
|
||||
for r in sorted(tableWidget.selectedRanges(), key=lambda r: r.topRow())[::-1]:
|
||||
for i in range(r.bottomRow()-r.topRow()+1):
|
||||
inventoryHashToTrash = str(tableWidget.item(
|
||||
r.topRow()+i, 3).data(QtCore.Qt.UserRole).toPyObject())
|
||||
if inventoryHashToTrash in inventoryHashesToTrash:
|
||||
continue
|
||||
inventoryHashesToTrash.append(inventoryHashToTrash)
|
||||
currentRow = r.topRow()
|
||||
self.getCurrentMessageTextedit().setText("")
|
||||
tableWidget.model().removeRows(
|
||||
r.topRow(), r.bottomRow() - r.topRow() + 1)
|
||||
tableWidget.model().removeRows(r.topRow(), r.bottomRow()-r.topRow()+1)
|
||||
tableWidget.selectRow(0 if currentRow == 0 else currentRow - 1)
|
||||
idCount = len(inventoryHashesToTrash)
|
||||
sqlExecuteChunked(
|
||||
"UPDATE inbox SET folder='inbox' WHERE msgid IN({0})",
|
||||
sqlExecuteChunked('''UPDATE inbox SET folder='inbox' WHERE msgid IN({0})''',
|
||||
idCount, *inventoryHashesToTrash)
|
||||
tableWidget.selectRow(0 if currentRow == 0 else currentRow - 1)
|
||||
tableWidget.setUpdatesEnabled(True)
|
||||
|
@ -3167,7 +3327,8 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
subjectAtCurrentInboxRow = ''
|
||||
|
||||
# Retrieve the message data out of the SQL database
|
||||
msgid = tableWidget.item(currentInboxRow, 3).data()
|
||||
msgid = str(tableWidget.item(
|
||||
currentInboxRow, 3).data(QtCore.Qt.UserRole).toPyObject())
|
||||
queryreturn = sqlQuery(
|
||||
'''select message from inbox where msgid=?''', msgid)
|
||||
if queryreturn != []:
|
||||
|
@ -3195,7 +3356,8 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
shifted = QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier
|
||||
while tableWidget.selectedIndexes() != []:
|
||||
currentRow = tableWidget.selectedIndexes()[0].row()
|
||||
ackdataToTrash = tableWidget.item(currentRow, 3).data()
|
||||
ackdataToTrash = str(tableWidget.item(
|
||||
currentRow, 3).data(QtCore.Qt.UserRole).toPyObject())
|
||||
sqlExecute(
|
||||
"DELETE FROM sent" if folder == "trash" or shifted else
|
||||
"UPDATE sent SET folder='trash'"
|
||||
|
@ -3241,7 +3403,8 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
0].row()
|
||||
item = self.ui.tableWidgetAddressBook.item(currentRow, 0)
|
||||
sqlExecute(
|
||||
'DELETE FROM addressbook WHERE address=?', item.address)
|
||||
'DELETE FROM addressbook WHERE label=? AND address=?',
|
||||
item.label, item.address)
|
||||
self.ui.tableWidgetAddressBook.removeRow(currentRow)
|
||||
self.rerenderMessagelistFromLabels()
|
||||
self.rerenderMessagelistToLabels()
|
||||
|
@ -3263,7 +3426,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
return self.updateStatusBar(_translate(
|
||||
"MainWindow", "No addresses selected."))
|
||||
|
||||
addresses_string = unicode(
|
||||
addresses_string = str(
|
||||
self.ui.lineEditTo.text().toUtf8(), 'utf-8')
|
||||
for item in selected_items:
|
||||
address_string = item.accountString()
|
||||
|
@ -3418,13 +3581,13 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
return None
|
||||
|
||||
def getCurrentTreeWidget(self):
|
||||
currentIndex = self.ui.tabWidget.currentIndex()
|
||||
treeWidgetList = (
|
||||
currentIndex = self.ui.tabWidget.currentIndex();
|
||||
treeWidgetList = [
|
||||
self.ui.treeWidgetYourIdentities,
|
||||
False,
|
||||
self.ui.treeWidgetSubscriptions,
|
||||
self.ui.treeWidgetChans
|
||||
)
|
||||
]
|
||||
if currentIndex >= 0 and currentIndex < len(treeWidgetList):
|
||||
return treeWidgetList[currentIndex]
|
||||
else:
|
||||
|
@ -3442,15 +3605,17 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
return self.ui.treeWidgetYourIdentities
|
||||
|
||||
def getCurrentMessagelist(self):
|
||||
currentIndex = self.ui.tabWidget.currentIndex()
|
||||
messagelistList = (
|
||||
currentIndex = self.ui.tabWidget.currentIndex();
|
||||
messagelistList = [
|
||||
self.ui.tableWidgetInbox,
|
||||
False,
|
||||
self.ui.tableWidgetInboxSubscriptions,
|
||||
self.ui.tableWidgetInboxChans,
|
||||
)
|
||||
]
|
||||
if currentIndex >= 0 and currentIndex < len(messagelistList):
|
||||
return messagelistList[currentIndex]
|
||||
else:
|
||||
return False
|
||||
|
||||
def getAccountMessagelist(self, account):
|
||||
try:
|
||||
|
@ -3468,18 +3633,24 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
if messagelist:
|
||||
currentRow = messagelist.currentRow()
|
||||
if currentRow >= 0:
|
||||
return messagelist.item(currentRow, 3).data()
|
||||
msgid = str(messagelist.item(
|
||||
currentRow, 3).data(QtCore.Qt.UserRole).toPyObject())
|
||||
# data is saved at the 4. column of the table...
|
||||
return msgid
|
||||
return False
|
||||
|
||||
def getCurrentMessageTextedit(self):
|
||||
currentIndex = self.ui.tabWidget.currentIndex()
|
||||
messagelistList = (
|
||||
messagelistList = [
|
||||
self.ui.textEditInboxMessage,
|
||||
False,
|
||||
self.ui.textEditInboxMessageSubscriptions,
|
||||
self.ui.textEditInboxMessageChans,
|
||||
)
|
||||
]
|
||||
if currentIndex >= 0 and currentIndex < len(messagelistList):
|
||||
return messagelistList[currentIndex]
|
||||
else:
|
||||
return False
|
||||
|
||||
def getAccountTextedit(self, account):
|
||||
try:
|
||||
|
@ -3495,28 +3666,33 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
def getCurrentSearchLine(self, currentIndex=None, retObj=False):
|
||||
if currentIndex is None:
|
||||
currentIndex = self.ui.tabWidget.currentIndex()
|
||||
messagelistList = (
|
||||
messagelistList = [
|
||||
self.ui.inboxSearchLineEdit,
|
||||
False,
|
||||
self.ui.inboxSearchLineEditSubscriptions,
|
||||
self.ui.inboxSearchLineEditChans,
|
||||
)
|
||||
]
|
||||
if currentIndex >= 0 and currentIndex < len(messagelistList):
|
||||
return (
|
||||
messagelistList[currentIndex] if retObj
|
||||
else messagelistList[currentIndex].text().toUtf8().data())
|
||||
if retObj:
|
||||
return messagelistList[currentIndex]
|
||||
else:
|
||||
return messagelistList[currentIndex].text().toUtf8().data()
|
||||
else:
|
||||
return None
|
||||
|
||||
def getCurrentSearchOption(self, currentIndex=None):
|
||||
if currentIndex is None:
|
||||
currentIndex = self.ui.tabWidget.currentIndex()
|
||||
messagelistList = (
|
||||
messagelistList = [
|
||||
self.ui.inboxSearchOption,
|
||||
False,
|
||||
self.ui.inboxSearchOptionSubscriptions,
|
||||
self.ui.inboxSearchOptionChans,
|
||||
)
|
||||
]
|
||||
if currentIndex >= 0 and currentIndex < len(messagelistList):
|
||||
return messagelistList[currentIndex].currentText()
|
||||
return messagelistList[currentIndex].currentText().toUtf8().data()
|
||||
else:
|
||||
return None
|
||||
|
||||
# Group of functions for the Your Identities dialog box
|
||||
def getCurrentItem(self, treeWidget=None):
|
||||
|
@ -3620,11 +3796,12 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
tableWidget = self.getCurrentMessagelist()
|
||||
currentColumn = tableWidget.currentColumn()
|
||||
currentRow = tableWidget.currentRow()
|
||||
currentFolder = self.getCurrentFolder()
|
||||
if currentColumn not in (0, 1, 2): # to, from, subject
|
||||
currentColumn = 0 if currentFolder == "sent" else 1
|
||||
|
||||
if currentFolder == "sent":
|
||||
if currentColumn not in [0, 1, 2]: # to, from, subject
|
||||
if self.getCurrentFolder() == "sent":
|
||||
currentColumn = 0
|
||||
else:
|
||||
currentColumn = 1
|
||||
if self.getCurrentFolder() == "sent":
|
||||
myAddress = tableWidget.item(currentRow, 1).data(QtCore.Qt.UserRole)
|
||||
otherAddress = tableWidget.item(currentRow, 0).data(QtCore.Qt.UserRole)
|
||||
else:
|
||||
|
@ -3637,11 +3814,11 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
text = str(tableWidget.item(currentRow, currentColumn).label)
|
||||
else:
|
||||
text = tableWidget.item(currentRow, currentColumn).data(QtCore.Qt.UserRole)
|
||||
|
||||
text = str(str(text), 'utf-8', 'ignore')
|
||||
clipboard = QtGui.QApplication.clipboard()
|
||||
clipboard.setText(text)
|
||||
|
||||
# set avatar functions
|
||||
#set avatar functions
|
||||
def on_action_TreeWidgetSetAvatar(self):
|
||||
address = self.getCurrentAccount()
|
||||
self.setAvatar(address)
|
||||
|
@ -3658,36 +3835,19 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
thisTableWidget.item(
|
||||
currentRow, 0).setIcon(avatarize(addressAtCurrentRow))
|
||||
|
||||
# TODO: reuse utils
|
||||
def setAvatar(self, addressAtCurrentRow):
|
||||
if not os.path.exists(state.appdata + 'avatars/'):
|
||||
os.makedirs(state.appdata + 'avatars/')
|
||||
hash = hashlib.md5(addBMIfNotPresent(addressAtCurrentRow)).hexdigest()
|
||||
extensions = [
|
||||
'PNG', 'GIF', 'JPG', 'JPEG', 'SVG', 'BMP', 'MNG', 'PBM',
|
||||
'PGM', 'PPM', 'TIFF', 'XBM', 'XPM', 'TGA']
|
||||
|
||||
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'}
|
||||
extensions = ['PNG', 'GIF', 'JPG', 'JPEG', 'SVG', 'BMP', 'MNG', 'PBM', 'PGM', 'PPM', 'TIFF', 'XBM', 'XPM', 'TGA']
|
||||
# http://pyqt.sourceforge.net/Docs/PyQt4/qimagereader.html#supportedImageFormats
|
||||
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'}
|
||||
filters = []
|
||||
all_images_filter = []
|
||||
current_files = []
|
||||
for ext in extensions:
|
||||
filters += [names[ext] + ' (*.' + ext.lower() + ')']
|
||||
all_images_filter += ['*.' + ext.lower()]
|
||||
filters += [ names[ext] + ' (*.' + ext.lower() + ')' ]
|
||||
all_images_filter += [ '*.' + ext.lower() ]
|
||||
upper = state.appdata + 'avatars/' + hash + '.' + ext.upper()
|
||||
lower = state.appdata + 'avatars/' + hash + '.' + ext.lower()
|
||||
if os.path.isfile(lower):
|
||||
|
@ -3698,31 +3858,25 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
filters[1:1] = ['All files (*.*)']
|
||||
sourcefile = QtGui.QFileDialog.getOpenFileName(
|
||||
self, _translate("MainWindow", "Set avatar..."),
|
||||
filter=';;'.join(filters)
|
||||
filter = ';;'.join(filters)
|
||||
)
|
||||
# determine the correct filename (note that avatars don't use the suffix)
|
||||
destination = state.appdata + 'avatars/' + hash + '.' + sourcefile.split('.')[-1]
|
||||
exists = QtCore.QFile.exists(destination)
|
||||
if sourcefile == '':
|
||||
# ask for removal of avatar
|
||||
if exists | (len(current_files) > 0):
|
||||
displayMsg = _translate(
|
||||
"MainWindow", "Do you really want to remove this avatar?")
|
||||
if exists | (len(current_files)>0):
|
||||
displayMsg = _translate("MainWindow", "Do you really want to remove this avatar?")
|
||||
overwrite = QtGui.QMessageBox.question(
|
||||
self, 'Message', displayMsg,
|
||||
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
|
||||
self, 'Message', displayMsg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
|
||||
else:
|
||||
overwrite = QtGui.QMessageBox.No
|
||||
else:
|
||||
# ask whether to overwrite old avatar
|
||||
if exists | (len(current_files) > 0):
|
||||
displayMsg = _translate(
|
||||
"MainWindow",
|
||||
"You have already set an avatar for this address."
|
||||
" Do you really want to overwrite it?")
|
||||
if exists | (len(current_files)>0):
|
||||
displayMsg = _translate("MainWindow", "You have already set an avatar for this address. Do you really want to overwrite it?")
|
||||
overwrite = QtGui.QMessageBox.question(
|
||||
self, 'Message', displayMsg,
|
||||
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
|
||||
self, 'Message', displayMsg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
|
||||
else:
|
||||
overwrite = QtGui.QMessageBox.No
|
||||
|
||||
|
@ -3756,11 +3910,11 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
self.setAddressSound(widget.item(widget.currentRow(), 0).text())
|
||||
|
||||
def setAddressSound(self, addr):
|
||||
filters = [unicode(_translate(
|
||||
filters = [str(_translate(
|
||||
"MainWindow", "Sound files (%s)" %
|
||||
' '.join(['*%s%s' % (os.extsep, ext) for ext in sound.extensions])
|
||||
))]
|
||||
sourcefile = unicode(QtGui.QFileDialog.getOpenFileName(
|
||||
sourcefile = str(QtGui.QFileDialog.getOpenFileName(
|
||||
self, _translate("MainWindow", "Set notification sound..."),
|
||||
filter=';;'.join(filters)
|
||||
))
|
||||
|
@ -3769,7 +3923,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
return
|
||||
|
||||
destdir = os.path.join(state.appdata, 'sounds')
|
||||
destfile = unicode(addr) + os.path.splitext(sourcefile)[-1]
|
||||
destfile = str(addr) + os.path.splitext(sourcefile)[-1]
|
||||
destination = os.path.join(destdir, destfile)
|
||||
|
||||
if sourcefile == destination:
|
||||
|
@ -3911,7 +4065,8 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
# Check to see if this item is toodifficult and display an additional
|
||||
# menu option (Force Send) if it is.
|
||||
if currentRow >= 0:
|
||||
ackData = self.ui.tableWidgetInbox.item(currentRow, 3).data()
|
||||
ackData = str(self.ui.tableWidgetInbox.item(
|
||||
currentRow, 3).data(QtCore.Qt.UserRole).toPyObject())
|
||||
queryreturn = sqlQuery('''SELECT status FROM sent where ackdata=?''', ackData)
|
||||
for row in queryreturn:
|
||||
status, = row
|
||||
|
@ -3922,27 +4077,25 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
|
||||
def inboxSearchLineEditUpdated(self, text):
|
||||
# dynamic search for too short text is slow
|
||||
text = text.toUtf8()
|
||||
if 0 < len(text) < 3:
|
||||
if len(str(text)) < 3:
|
||||
return
|
||||
messagelist = self.getCurrentMessagelist()
|
||||
if messagelist:
|
||||
searchOption = self.getCurrentSearchOption()
|
||||
if messagelist:
|
||||
account = self.getCurrentAccount()
|
||||
folder = self.getCurrentFolder()
|
||||
self.loadMessagelist(
|
||||
messagelist, account, folder, searchOption, text)
|
||||
self.loadMessagelist(messagelist, account, folder, searchOption, str(text))
|
||||
|
||||
def inboxSearchLineEditReturnPressed(self):
|
||||
logger.debug("Search return pressed")
|
||||
searchLine = self.getCurrentSearchLine()
|
||||
messagelist = self.getCurrentMessagelist()
|
||||
if messagelist and len(str(searchLine)) < 3:
|
||||
if len(str(searchLine)) < 3:
|
||||
searchOption = self.getCurrentSearchOption()
|
||||
account = self.getCurrentAccount()
|
||||
folder = self.getCurrentFolder()
|
||||
self.loadMessagelist(
|
||||
messagelist, account, folder, searchOption, searchLine)
|
||||
self.loadMessagelist(messagelist, account, folder, searchOption, searchLine)
|
||||
if messagelist:
|
||||
messagelist.setFocus()
|
||||
|
||||
def treeWidgetItemClicked(self):
|
||||
|
@ -3968,7 +4121,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
if (not isinstance(item, Ui_AddressWidget)) or (not self.getCurrentTreeWidget()) or self.getCurrentTreeWidget().currentItem() is None:
|
||||
return
|
||||
# not visible
|
||||
if (not self.getCurrentItem()) or (not isinstance(self.getCurrentItem(), Ui_AddressWidget)):
|
||||
if (not self.getCurrentItem()) or (not isinstance (self.getCurrentItem(), Ui_AddressWidget)):
|
||||
return
|
||||
# only currently selected item
|
||||
if item.address != self.getCurrentAccount():
|
||||
|
@ -3977,7 +4130,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
if item.type == AccountMixin.ALL:
|
||||
return
|
||||
|
||||
newLabel = unicode(item.text(0), 'utf-8', 'ignore')
|
||||
newLabel = str(item.text(0), 'utf-8', 'ignore')
|
||||
oldLabel = item.defaultLabel()
|
||||
|
||||
# unchanged, do not do anything either
|
||||
|
@ -4001,12 +4154,12 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
self.recurDepth -= 1
|
||||
|
||||
def tableWidgetInboxItemClicked(self):
|
||||
folder = self.getCurrentFolder()
|
||||
messageTextedit = self.getCurrentMessageTextedit()
|
||||
if not messageTextedit:
|
||||
return
|
||||
|
||||
msgid = self.getCurrentMessageId()
|
||||
folder = self.getCurrentFolder()
|
||||
if msgid:
|
||||
queryreturn = sqlQuery(
|
||||
'''SELECT message FROM %s WHERE %s=?''' % (
|
||||
|
@ -4048,7 +4201,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
self.rerenderMessagelistToLabels()
|
||||
completerList = self.ui.lineEditTo.completer().model().stringList()
|
||||
for i in range(len(completerList)):
|
||||
if unicode(completerList[i]).endswith(" <" + item.address + ">"):
|
||||
if str(completerList[i]).endswith(" <" + item.address + ">"):
|
||||
completerList[i] = item.label + " <" + item.address + ">"
|
||||
self.ui.lineEditTo.completer().model().setStringList(completerList)
|
||||
|
||||
|
@ -4067,15 +4220,12 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
self.rerenderAddressBook()
|
||||
|
||||
def updateStatusBar(self, data):
|
||||
try:
|
||||
message, option = data
|
||||
except ValueError:
|
||||
if type(data) is tuple or type(data) is list:
|
||||
option = data[1]
|
||||
message = data[0]
|
||||
else:
|
||||
option = 0
|
||||
message = data
|
||||
except TypeError:
|
||||
logger.debug(
|
||||
'Invalid argument for updateStatusBar!', exc_info=True)
|
||||
|
||||
if message != "":
|
||||
logger.info('Status bar: ' + message)
|
||||
|
||||
|
@ -4094,15 +4244,18 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
'bitmessagesettings', 'dontconnect'
|
||||
) or self.namecoin.test()[0] == 'failed':
|
||||
logger.warning(
|
||||
'There was a problem testing for a Namecoin daemon.'
|
||||
' Hiding the Fetch Namecoin ID button')
|
||||
'There was a problem testing for a Namecoin daemon. Hiding the'
|
||||
' Fetch Namecoin ID button')
|
||||
self.ui.pushButtonFetchNamecoinID.hide()
|
||||
else:
|
||||
self.ui.pushButtonFetchNamecoinID.show()
|
||||
|
||||
def initSettings(self):
|
||||
QtCore.QCoreApplication.setOrganizationName("PyBitmessage")
|
||||
QtCore.QCoreApplication.setOrganizationDomain("bitmessage.org")
|
||||
QtCore.QCoreApplication.setApplicationName("pybitmessageqt")
|
||||
self.loadSettings()
|
||||
for attr, obj in self.ui.__dict__.iteritems():
|
||||
for attr, obj in self.ui.__dict__.items():
|
||||
if hasattr(obj, "__class__") and \
|
||||
isinstance(obj, settingsmixin.SettingsMixin):
|
||||
loadMethod = getattr(obj, "loadSettings", None)
|
||||
|
@ -4110,11 +4263,251 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
obj.loadSettings()
|
||||
|
||||
|
||||
class settingsDialog(QtGui.QDialog):
|
||||
|
||||
def __init__(self, parent):
|
||||
QtGui.QWidget.__init__(self, parent)
|
||||
self.ui = Ui_settingsDialog()
|
||||
self.ui.setupUi(self)
|
||||
self.parent = parent
|
||||
self.ui.checkBoxStartOnLogon.setChecked(
|
||||
BMConfigParser().getboolean('bitmessagesettings', 'startonlogon'))
|
||||
self.ui.checkBoxMinimizeToTray.setChecked(
|
||||
BMConfigParser().getboolean('bitmessagesettings', 'minimizetotray'))
|
||||
self.ui.checkBoxTrayOnClose.setChecked(
|
||||
BMConfigParser().safeGetBoolean('bitmessagesettings', 'trayonclose'))
|
||||
self.ui.checkBoxHideTrayConnectionNotifications.setChecked(
|
||||
BMConfigParser().getboolean("bitmessagesettings", "hidetrayconnectionnotifications"))
|
||||
self.ui.checkBoxShowTrayNotifications.setChecked(
|
||||
BMConfigParser().getboolean('bitmessagesettings', 'showtraynotifications'))
|
||||
self.ui.checkBoxStartInTray.setChecked(
|
||||
BMConfigParser().getboolean('bitmessagesettings', 'startintray'))
|
||||
self.ui.checkBoxWillinglySendToMobile.setChecked(
|
||||
BMConfigParser().safeGetBoolean('bitmessagesettings', 'willinglysendtomobile'))
|
||||
self.ui.checkBoxUseIdenticons.setChecked(
|
||||
BMConfigParser().safeGetBoolean('bitmessagesettings', 'useidenticons'))
|
||||
self.ui.checkBoxReplyBelow.setChecked(
|
||||
BMConfigParser().safeGetBoolean('bitmessagesettings', 'replybelow'))
|
||||
|
||||
if state.appdata == paths.lookupExeFolder():
|
||||
self.ui.checkBoxPortableMode.setChecked(True)
|
||||
else:
|
||||
try:
|
||||
import tempfile
|
||||
tempfile.NamedTemporaryFile(
|
||||
dir=paths.lookupExeFolder(), delete=True
|
||||
).close() # should autodelete
|
||||
except:
|
||||
self.ui.checkBoxPortableMode.setDisabled(True)
|
||||
|
||||
if 'darwin' in sys.platform:
|
||||
self.ui.checkBoxStartOnLogon.setDisabled(True)
|
||||
self.ui.checkBoxStartOnLogon.setText(_translate(
|
||||
"MainWindow", "Start-on-login not yet supported on your OS."))
|
||||
self.ui.checkBoxMinimizeToTray.setDisabled(True)
|
||||
self.ui.checkBoxMinimizeToTray.setText(_translate(
|
||||
"MainWindow", "Minimize-to-tray not yet supported on your OS."))
|
||||
self.ui.checkBoxShowTrayNotifications.setDisabled(True)
|
||||
self.ui.checkBoxShowTrayNotifications.setText(_translate(
|
||||
"MainWindow", "Tray notifications not yet supported on your OS."))
|
||||
elif 'linux' in sys.platform:
|
||||
self.ui.checkBoxStartOnLogon.setDisabled(True)
|
||||
self.ui.checkBoxStartOnLogon.setText(_translate(
|
||||
"MainWindow", "Start-on-login not yet supported on your OS."))
|
||||
# On the Network settings tab:
|
||||
self.ui.lineEditTCPPort.setText(str(
|
||||
BMConfigParser().get('bitmessagesettings', 'port')))
|
||||
self.ui.checkBoxUPnP.setChecked(
|
||||
BMConfigParser().safeGetBoolean('bitmessagesettings', 'upnp'))
|
||||
self.ui.checkBoxAuthentication.setChecked(BMConfigParser().getboolean(
|
||||
'bitmessagesettings', 'socksauthentication'))
|
||||
self.ui.checkBoxSocksListen.setChecked(BMConfigParser().getboolean(
|
||||
'bitmessagesettings', 'sockslisten'))
|
||||
if str(BMConfigParser().get('bitmessagesettings', 'socksproxytype')) == 'none':
|
||||
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)
|
||||
self.ui.checkBoxSocksListen.setEnabled(False)
|
||||
elif str(BMConfigParser().get('bitmessagesettings', 'socksproxytype')) == 'SOCKS4a':
|
||||
self.ui.comboBoxProxyType.setCurrentIndex(1)
|
||||
elif str(BMConfigParser().get('bitmessagesettings', 'socksproxytype')) == 'SOCKS5':
|
||||
self.ui.comboBoxProxyType.setCurrentIndex(2)
|
||||
|
||||
self.ui.lineEditSocksHostname.setText(str(
|
||||
BMConfigParser().get('bitmessagesettings', 'sockshostname')))
|
||||
self.ui.lineEditSocksPort.setText(str(
|
||||
BMConfigParser().get('bitmessagesettings', 'socksport')))
|
||||
self.ui.lineEditSocksUsername.setText(str(
|
||||
BMConfigParser().get('bitmessagesettings', 'socksusername')))
|
||||
self.ui.lineEditSocksPassword.setText(str(
|
||||
BMConfigParser().get('bitmessagesettings', 'sockspassword')))
|
||||
QtCore.QObject.connect(self.ui.comboBoxProxyType, QtCore.SIGNAL(
|
||||
"currentIndexChanged(int)"), self.comboBoxProxyTypeChanged)
|
||||
self.ui.lineEditMaxDownloadRate.setText(str(
|
||||
BMConfigParser().get('bitmessagesettings', 'maxdownloadrate')))
|
||||
self.ui.lineEditMaxUploadRate.setText(str(
|
||||
BMConfigParser().get('bitmessagesettings', 'maxuploadrate')))
|
||||
self.ui.lineEditMaxOutboundConnections.setText(str(
|
||||
BMConfigParser().get('bitmessagesettings', 'maxoutboundconnections')))
|
||||
|
||||
# Demanded difficulty tab
|
||||
self.ui.lineEditTotalDifficulty.setText(str((float(BMConfigParser().getint(
|
||||
'bitmessagesettings', 'defaultnoncetrialsperbyte')) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
||||
self.ui.lineEditSmallMessageDifficulty.setText(str((float(BMConfigParser().getint(
|
||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes')) / defaults.networkDefaultPayloadLengthExtraBytes)))
|
||||
|
||||
# Max acceptable difficulty tab
|
||||
self.ui.lineEditMaxAcceptableTotalDifficulty.setText(str((float(BMConfigParser().getint(
|
||||
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte')) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
||||
self.ui.lineEditMaxAcceptableSmallMessageDifficulty.setText(str((float(BMConfigParser().getint(
|
||||
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes')) / defaults.networkDefaultPayloadLengthExtraBytes)))
|
||||
|
||||
# OpenCL
|
||||
if openclpow.openclAvailable():
|
||||
self.ui.comboBoxOpenCL.setEnabled(True)
|
||||
else:
|
||||
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()):
|
||||
if self.ui.comboBoxOpenCL.itemText(i) == BMConfigParser().safeGet('bitmessagesettings', 'opencl'):
|
||||
self.ui.comboBoxOpenCL.setCurrentIndex(i)
|
||||
break
|
||||
|
||||
# Namecoin integration tab
|
||||
nmctype = BMConfigParser().get('bitmessagesettings', 'namecoinrpctype')
|
||||
self.ui.lineEditNamecoinHost.setText(str(
|
||||
BMConfigParser().get('bitmessagesettings', 'namecoinrpchost')))
|
||||
self.ui.lineEditNamecoinPort.setText(str(
|
||||
BMConfigParser().get('bitmessagesettings', 'namecoinrpcport')))
|
||||
self.ui.lineEditNamecoinUser.setText(str(
|
||||
BMConfigParser().get('bitmessagesettings', 'namecoinrpcuser')))
|
||||
self.ui.lineEditNamecoinPassword.setText(str(
|
||||
BMConfigParser().get('bitmessagesettings', 'namecoinrpcpassword')))
|
||||
|
||||
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)
|
||||
QtCore.QObject.connect(self.ui.pushButtonNamecoinTest, QtCore.SIGNAL(
|
||||
"clicked()"), self.click_pushButtonNamecoinTest)
|
||||
|
||||
#Message Resend tab
|
||||
self.ui.lineEditDays.setText(str(
|
||||
BMConfigParser().get('bitmessagesettings', 'stopresendingafterxdays')))
|
||||
self.ui.lineEditMonths.setText(str(
|
||||
BMConfigParser().get('bitmessagesettings', 'stopresendingafterxmonths')))
|
||||
|
||||
|
||||
#'System' tab removed for now.
|
||||
"""try:
|
||||
maxCores = BMConfigParser().getint('bitmessagesettings', 'maxcores')
|
||||
except:
|
||||
maxCores = 99999
|
||||
if maxCores <= 1:
|
||||
self.ui.comboBoxMaxCores.setCurrentIndex(0)
|
||||
elif maxCores == 2:
|
||||
self.ui.comboBoxMaxCores.setCurrentIndex(1)
|
||||
elif maxCores <= 4:
|
||||
self.ui.comboBoxMaxCores.setCurrentIndex(2)
|
||||
elif maxCores <= 8:
|
||||
self.ui.comboBoxMaxCores.setCurrentIndex(3)
|
||||
elif maxCores <= 16:
|
||||
self.ui.comboBoxMaxCores.setCurrentIndex(4)
|
||||
else:
|
||||
self.ui.comboBoxMaxCores.setCurrentIndex(5)"""
|
||||
|
||||
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
|
||||
|
||||
def comboBoxProxyTypeChanged(self, comboBoxIndex):
|
||||
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)
|
||||
self.ui.checkBoxSocksListen.setEnabled(False)
|
||||
elif comboBoxIndex == 1 or comboBoxIndex == 2:
|
||||
self.ui.lineEditSocksHostname.setEnabled(True)
|
||||
self.ui.lineEditSocksPort.setEnabled(True)
|
||||
self.ui.checkBoxAuthentication.setEnabled(True)
|
||||
self.ui.checkBoxSocksListen.setEnabled(True)
|
||||
if self.ui.checkBoxAuthentication.isChecked():
|
||||
self.ui.lineEditSocksUsername.setEnabled(True)
|
||||
self.ui.lineEditSocksPassword.setEnabled(True)
|
||||
|
||||
# Check status of namecoin integration radio buttons and translate
|
||||
# it to a string as in the options.
|
||||
def getNamecoinType(self):
|
||||
if self.ui.radioButtonNamecoinNamecoind.isChecked():
|
||||
return "namecoind"
|
||||
if self.ui.radioButtonNamecoinNmcontrol.isChecked():
|
||||
return "nmcontrol"
|
||||
assert False
|
||||
|
||||
# Namecoin connection type was changed.
|
||||
def namecoinTypeChanged(self, checked):
|
||||
nmctype = self.getNamecoinType()
|
||||
assert nmctype == "namecoind" or nmctype == "nmcontrol"
|
||||
|
||||
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:
|
||||
self.ui.lineEditNamecoinPort.setText(defaults.namecoinDefaultRpcPort)
|
||||
else:
|
||||
self.ui.lineEditNamecoinPort.setText("9000")
|
||||
|
||||
def click_pushButtonNamecoinTest(self):
|
||||
"""Test the namecoin settings specified in the settings dialog."""
|
||||
self.ui.labelNamecoinTestResult.setText(_translate(
|
||||
"MainWindow", "Testing..."))
|
||||
options = {}
|
||||
options["type"] = self.getNamecoinType()
|
||||
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())
|
||||
nc = namecoin.namecoinConnection(options)
|
||||
status, text = nc.test()
|
||||
self.ui.labelNamecoinTestResult.setText(text)
|
||||
if status == 'success':
|
||||
self.parent.namecoin = nc
|
||||
|
||||
|
||||
# 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.
|
||||
class myTableWidgetItem(QtGui.QTableWidgetItem):
|
||||
|
||||
def __lt__(self, other):
|
||||
return int(self.data(33).toPyObject()) < int(other.data(33).toPyObject())
|
||||
|
||||
|
||||
app = None
|
||||
myapp = None
|
||||
|
||||
|
||||
class BitmessageQtApplication(QtGui.QApplication):
|
||||
class MySingleApplication(QtGui.QApplication):
|
||||
"""
|
||||
Listener to allow our Qt form to get focus when another instance of the
|
||||
application is open.
|
||||
|
@ -4127,12 +4520,8 @@ class BitmessageQtApplication(QtGui.QApplication):
|
|||
uuid = '6ec0149b-96e1-4be1-93ab-1465fb3ebf7c'
|
||||
|
||||
def __init__(self, *argv):
|
||||
super(BitmessageQtApplication, self).__init__(*argv)
|
||||
id = BitmessageQtApplication.uuid
|
||||
|
||||
QtCore.QCoreApplication.setOrganizationName("PyBitmessage")
|
||||
QtCore.QCoreApplication.setOrganizationDomain("bitmessage.org")
|
||||
QtCore.QCoreApplication.setApplicationName("pybitmessageqt")
|
||||
super(MySingleApplication, self).__init__(*argv)
|
||||
id = MySingleApplication.uuid
|
||||
|
||||
self.server = None
|
||||
self.is_running = False
|
||||
|
@ -4160,8 +4549,6 @@ class BitmessageQtApplication(QtGui.QApplication):
|
|||
self.server.listen(id)
|
||||
self.server.newConnection.connect(self.on_new_connection)
|
||||
|
||||
self.setStyleSheet("QStatusBar::item { border: 0px solid black }")
|
||||
|
||||
def __del__(self):
|
||||
if self.server:
|
||||
self.server.close()
|
||||
|
@ -4174,19 +4561,26 @@ class BitmessageQtApplication(QtGui.QApplication):
|
|||
def init():
|
||||
global app
|
||||
if not app:
|
||||
app = BitmessageQtApplication(sys.argv)
|
||||
app = MySingleApplication(sys.argv)
|
||||
return app
|
||||
|
||||
|
||||
def run():
|
||||
global myapp
|
||||
app = init()
|
||||
change_translation(l10n.getTranslationLanguage())
|
||||
app.setStyleSheet("QStatusBar::item { border: 0px solid black }")
|
||||
myapp = MyForm()
|
||||
|
||||
myapp.sqlInit()
|
||||
myapp.appIndicatorInit(app)
|
||||
|
||||
myapp.indicatorInit()
|
||||
myapp.notifierInit()
|
||||
myapp._firstrun = BMConfigParser().safeGetBoolean(
|
||||
'bitmessagesettings', 'dontconnect')
|
||||
if myapp._firstrun:
|
||||
myapp.showConnectDialog() # ask the user if we may connect
|
||||
myapp.ui.updateNetworkSwitchMenuLabel()
|
||||
|
||||
# try:
|
||||
# if BMConfigParser().get('bitmessagesettings', 'mailchuck') < 1:
|
||||
|
@ -4198,4 +4592,4 @@ def run():
|
|||
if not BMConfigParser().getboolean('bitmessagesettings', 'startintray'):
|
||||
myapp.show()
|
||||
|
||||
app.exec_()
|
||||
sys.exit(app.exec_())
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Copyright © 2012-2016 Jonathan Warren<br/>Copyright © 2012-2020 The Bitmessage Developers</p></body></html></string>
|
||||
<string><html><head/><body><p>Copyright © 2012-2016 Jonathan Warren<br/>Copyright © 2012-2019 The Bitmessage Developers</p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeft</set>
|
||||
|
|
|
@ -8,7 +8,16 @@ Account related functions.
|
|||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
|
||||
from past.builtins import cmp
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
from builtins import *
|
||||
from builtins import object
|
||||
import inspect
|
||||
import re
|
||||
import sys
|
||||
|
@ -31,12 +40,12 @@ def getSortedAccounts():
|
|||
configSections = BMConfigParser().addresses()
|
||||
configSections.sort(
|
||||
cmp=lambda x, y: cmp(
|
||||
unicode(
|
||||
str(
|
||||
BMConfigParser().get(
|
||||
x,
|
||||
'label'),
|
||||
'utf-8').lower(),
|
||||
unicode(
|
||||
str(
|
||||
BMConfigParser().get(
|
||||
y,
|
||||
'label'),
|
||||
|
@ -169,7 +178,7 @@ class BMAccount(object):
|
|||
|
||||
self.toAddress = toAddress
|
||||
self.fromAddress = fromAddress
|
||||
if isinstance(subject, unicode):
|
||||
if isinstance(subject, str):
|
||||
self.subject = str(subject)
|
||||
else:
|
||||
self.subject = subject
|
||||
|
|
|
@ -1,22 +1,35 @@
|
|||
"""
|
||||
Dialogs that work with BM address.
|
||||
"""
|
||||
# pylint: disable=attribute-defined-outside-init,too-few-public-methods,relative-import
|
||||
src/bitmessageqt/address_dialogs.py
|
||||
===================================
|
||||
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
from builtins import *
|
||||
from builtins import object
|
||||
import hashlib
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
import queues
|
||||
import widgets
|
||||
from account import AccountMixin, GatewayAccount, MailchuckAccount, accountClass, getSortedAccounts
|
||||
from . import widgets
|
||||
from .account import AccountMixin, GatewayAccount, MailchuckAccount, accountClass, getSortedAccounts
|
||||
from addresses import addBMIfNotPresent, decodeAddress, encodeVarint
|
||||
from inventory import Inventory
|
||||
from .retranslateui import RetranslateMixin
|
||||
from tr import _translate
|
||||
|
||||
|
||||
class AddressCheckMixin(object):
|
||||
"""Base address validation class for QT UI"""
|
||||
# pylint: disable=too-few-public-methods
|
||||
|
||||
def __init__(self):
|
||||
self.valid = False
|
||||
|
@ -29,9 +42,7 @@ class AddressCheckMixin(object):
|
|||
pass
|
||||
|
||||
def addressChanged(self, QString):
|
||||
"""
|
||||
Address validation callback, performs validation and gives feedback
|
||||
"""
|
||||
"""Address validation callback, performs validation and gives feedback"""
|
||||
status, addressVersion, streamNumber, ripe = decodeAddress(
|
||||
str(QString))
|
||||
self.valid = status == 'success'
|
||||
|
@ -100,8 +111,8 @@ class AddressDataDialog(QtGui.QDialog, AddressCheckMixin):
|
|||
super(AddressDataDialog, self).accept()
|
||||
|
||||
|
||||
class AddAddressDialog(AddressDataDialog):
|
||||
"""QDialog for adding a new address"""
|
||||
class AddAddressDialog(AddressDataDialog, RetranslateMixin):
|
||||
"""QDialog for adding a new address, with validation and translation"""
|
||||
|
||||
def __init__(self, parent=None, address=None):
|
||||
super(AddAddressDialog, self).__init__(parent)
|
||||
|
@ -111,8 +122,8 @@ class AddAddressDialog(AddressDataDialog):
|
|||
self.lineEditAddress.setText(address)
|
||||
|
||||
|
||||
class NewAddressDialog(QtGui.QDialog):
|
||||
"""QDialog for generating a new address"""
|
||||
class NewAddressDialog(QtGui.QDialog, RetranslateMixin):
|
||||
"""QDialog for generating a new address, with translation"""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(NewAddressDialog, self).__init__(parent)
|
||||
|
@ -173,8 +184,8 @@ class NewAddressDialog(QtGui.QDialog):
|
|||
))
|
||||
|
||||
|
||||
class NewSubscriptionDialog(AddressDataDialog):
|
||||
"""QDialog for subscribing to an address"""
|
||||
class NewSubscriptionDialog(AddressDataDialog, RetranslateMixin):
|
||||
"""QDialog for subscribing to an address, with validation and translation"""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(NewSubscriptionDialog, self).__init__(parent)
|
||||
|
@ -191,8 +202,8 @@ class NewSubscriptionDialog(AddressDataDialog):
|
|||
else:
|
||||
Inventory().flush()
|
||||
doubleHashOfAddressData = hashlib.sha512(hashlib.sha512(
|
||||
encodeVarint(addressVersion)
|
||||
+ encodeVarint(streamNumber) + ripe
|
||||
encodeVarint(addressVersion) +
|
||||
encodeVarint(streamNumber) + ripe
|
||||
).digest()).digest()
|
||||
tag = doubleHashOfAddressData[32:]
|
||||
self.recent = Inventory().by_type_and_tag(3, tag)
|
||||
|
@ -216,8 +227,8 @@ class NewSubscriptionDialog(AddressDataDialog):
|
|||
))
|
||||
|
||||
|
||||
class RegenerateAddressesDialog(QtGui.QDialog):
|
||||
"""QDialog for regenerating deterministic addresses"""
|
||||
class RegenerateAddressesDialog(QtGui.QDialog, RetranslateMixin):
|
||||
"""QDialog for regenerating deterministic addresses, with translation"""
|
||||
def __init__(self, parent=None):
|
||||
super(RegenerateAddressesDialog, self).__init__(parent)
|
||||
widgets.load('regenerateaddresses.ui', self)
|
||||
|
@ -225,10 +236,8 @@ class RegenerateAddressesDialog(QtGui.QDialog):
|
|||
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
|
||||
|
||||
|
||||
class SpecialAddressBehaviorDialog(QtGui.QDialog):
|
||||
"""
|
||||
QDialog for special address behaviour (e.g. mailing list functionality)
|
||||
"""
|
||||
class SpecialAddressBehaviorDialog(QtGui.QDialog, RetranslateMixin):
|
||||
"""QDialog for special address behaviour (e.g. mailing list functionality), with translation"""
|
||||
|
||||
def __init__(self, parent=None, config=None):
|
||||
super(SpecialAddressBehaviorDialog, self).__init__(parent)
|
||||
|
@ -256,9 +265,13 @@ class SpecialAddressBehaviorDialog(QtGui.QDialog):
|
|||
self.radioButtonBehaviorMailingList.click()
|
||||
else:
|
||||
self.radioButtonBehaveNormalAddress.click()
|
||||
mailingListName = config.safeGet(self.address, 'mailinglistname', '')
|
||||
try:
|
||||
mailingListName = config.get(
|
||||
self.address, 'mailinglistname')
|
||||
except:
|
||||
mailingListName = ''
|
||||
self.lineEditMailingListName.setText(
|
||||
unicode(mailingListName, 'utf-8')
|
||||
str(mailingListName, 'utf-8')
|
||||
)
|
||||
|
||||
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
|
||||
|
@ -290,8 +303,8 @@ class SpecialAddressBehaviorDialog(QtGui.QDialog):
|
|||
self.parent.rerenderMessagelistToLabels()
|
||||
|
||||
|
||||
class EmailGatewayDialog(QtGui.QDialog):
|
||||
"""QDialog for email gateway control"""
|
||||
class EmailGatewayDialog(QtGui.QDialog, RetranslateMixin):
|
||||
"""QDialog for email gateway control, with translation"""
|
||||
def __init__(self, parent, config=None, account=None):
|
||||
super(EmailGatewayDialog, self).__init__(parent)
|
||||
widgets.load('emailgateway.ui', self)
|
||||
|
|
|
@ -1,29 +1,23 @@
|
|||
"""
|
||||
Address validator module.
|
||||
"""
|
||||
# pylint: disable=too-many-branches,too-many-arguments
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
from builtins import *
|
||||
from builtins import object
|
||||
from PyQt4 import QtGui
|
||||
from Queue import Empty
|
||||
from queue import Empty
|
||||
|
||||
from account import getSortedAccounts
|
||||
from addresses import decodeAddress, addBMIfNotPresent
|
||||
from .account import getSortedAccounts
|
||||
from queues import apiAddressGeneratorReturnQueue, addressGeneratorQueue
|
||||
from tr import _translate
|
||||
from utils import str_chan
|
||||
|
||||
from .utils import str_chan
|
||||
|
||||
class AddressPassPhraseValidatorMixin(object):
|
||||
"""Bitmessage address or passphrase validator class for Qt UI"""
|
||||
def setParams(
|
||||
self,
|
||||
passPhraseObject=None,
|
||||
addressObject=None,
|
||||
feedBackObject=None,
|
||||
buttonBox=None,
|
||||
addressMandatory=True,
|
||||
):
|
||||
"""Initialisation"""
|
||||
def setParams(self, passPhraseObject=None, addressObject=None, feedBackObject=None, buttonBox=None, addressMandatory=True):
|
||||
self.addressObject = addressObject
|
||||
self.passPhraseObject = passPhraseObject
|
||||
self.feedBackObject = feedBackObject
|
||||
|
@ -34,7 +28,6 @@ class AddressPassPhraseValidatorMixin(object):
|
|||
self.okButtonLabel = self.buttonBox.button(QtGui.QDialogButtonBox.Ok).text()
|
||||
|
||||
def setError(self, string):
|
||||
"""Indicate that the validation is pending or failed"""
|
||||
if string is not None and self.feedBackObject is not None:
|
||||
font = QtGui.QFont()
|
||||
font.setBold(True)
|
||||
|
@ -45,14 +38,11 @@ class AddressPassPhraseValidatorMixin(object):
|
|||
if self.buttonBox:
|
||||
self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(False)
|
||||
if string is not None and self.feedBackObject is not None:
|
||||
self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setText(
|
||||
_translate("AddressValidator", "Invalid"))
|
||||
self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setText(_translate("AddressValidator", "Invalid"))
|
||||
else:
|
||||
self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setText(
|
||||
_translate("AddressValidator", "Validating..."))
|
||||
self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setText(_translate("AddressValidator", "Validating..."))
|
||||
|
||||
def setOK(self, string):
|
||||
"""Indicate that the validation succeeded"""
|
||||
if string is not None and self.feedBackObject is not None:
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
|
@ -65,13 +55,12 @@ class AddressPassPhraseValidatorMixin(object):
|
|||
self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setText(self.okButtonLabel)
|
||||
|
||||
def checkQueue(self):
|
||||
"""Validator queue loop"""
|
||||
gotOne = False
|
||||
|
||||
# wait until processing is done
|
||||
if not addressGeneratorQueue.empty():
|
||||
self.setError(None)
|
||||
return None
|
||||
return
|
||||
|
||||
while True:
|
||||
try:
|
||||
|
@ -80,30 +69,25 @@ class AddressPassPhraseValidatorMixin(object):
|
|||
if gotOne:
|
||||
break
|
||||
else:
|
||||
return None
|
||||
return
|
||||
else:
|
||||
gotOne = True
|
||||
|
||||
if not addressGeneratorReturnValue:
|
||||
if len(addressGeneratorReturnValue) == 0:
|
||||
self.setError(_translate("AddressValidator", "Address already present as one of your identities."))
|
||||
return (QtGui.QValidator.Intermediate, 0)
|
||||
if addressGeneratorReturnValue[0] == 'chan name does not match address':
|
||||
self.setError(
|
||||
_translate(
|
||||
"AddressValidator",
|
||||
"Although the Bitmessage address you "
|
||||
"entered was valid, it doesn't match the chan name."))
|
||||
self.setError(_translate("AddressValidator", "Although the Bitmessage address you entered was valid, it doesn\'t match the chan name."))
|
||||
return (QtGui.QValidator.Intermediate, 0)
|
||||
self.setOK(_translate("MainWindow", "Passphrase and address appear to be valid."))
|
||||
|
||||
def returnValid(self):
|
||||
"""Return the value of whether the validation was successful"""
|
||||
if self.isValid:
|
||||
return QtGui.QValidator.Acceptable
|
||||
else:
|
||||
return QtGui.QValidator.Intermediate
|
||||
|
||||
def validate(self, s, pos):
|
||||
"""Top level validator method"""
|
||||
if self.addressObject is None:
|
||||
address = None
|
||||
else:
|
||||
|
@ -130,13 +114,7 @@ class AddressPassPhraseValidatorMixin(object):
|
|||
|
||||
# version too high
|
||||
if decodeAddress(address)[0] == 'versiontoohigh':
|
||||
self.setError(
|
||||
_translate(
|
||||
"AddressValidator",
|
||||
"Address too new. Although that Bitmessage"
|
||||
" address might be valid, its version number"
|
||||
" is too new for us to handle. Perhaps you need"
|
||||
" to upgrade Bitmessage."))
|
||||
self.setError(_translate("AddressValidator", "Address too new. Although that Bitmessage address might be valid, its version number is too new for us to handle. Perhaps you need to upgrade Bitmessage."))
|
||||
return (QtGui.QValidator.Intermediate, pos)
|
||||
|
||||
# invalid
|
||||
|
@ -153,28 +131,23 @@ class AddressPassPhraseValidatorMixin(object):
|
|||
if address is None:
|
||||
addressGeneratorQueue.put(('createChan', 4, 1, str_chan + ' ' + str(passPhrase), passPhrase, False))
|
||||
else:
|
||||
addressGeneratorQueue.put(
|
||||
('joinChan', addBMIfNotPresent(address),
|
||||
"{} {}".format(str_chan, passPhrase), passPhrase, False))
|
||||
addressGeneratorQueue.put(('joinChan', addBMIfNotPresent(address), str_chan + ' ' + str(passPhrase), passPhrase, False))
|
||||
|
||||
if self.buttonBox.button(QtGui.QDialogButtonBox.Ok).hasFocus():
|
||||
return (self.returnValid(), pos)
|
||||
else:
|
||||
return (QtGui.QValidator.Intermediate, pos)
|
||||
|
||||
def checkData(self):
|
||||
"""Validator Qt signal interface"""
|
||||
return self.validate("", 0)
|
||||
|
||||
|
||||
class AddressValidator(QtGui.QValidator, AddressPassPhraseValidatorMixin):
|
||||
"""AddressValidator class for Qt UI"""
|
||||
def __init__(self, parent=None, passPhraseObject=None, feedBackObject=None, buttonBox=None, addressMandatory=True):
|
||||
super(AddressValidator, self).__init__(parent)
|
||||
self.setParams(passPhraseObject, parent, feedBackObject, buttonBox, addressMandatory)
|
||||
|
||||
|
||||
class PassPhraseValidator(QtGui.QValidator, AddressPassPhraseValidatorMixin):
|
||||
"""PassPhraseValidator class for Qt UI"""
|
||||
def __init__(self, parent=None, addressObject=None, feedBackObject=None, buttonBox=None, addressMandatory=False):
|
||||
super(PassPhraseValidator, self).__init__(parent)
|
||||
self.setParams(parent, addressObject, feedBackObject, buttonBox, addressMandatory)
|
||||
|
|
|
@ -7,9 +7,16 @@
|
|||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import *
|
||||
from PyQt4 import QtCore
|
||||
|
||||
qt_resource_data = "\
|
||||
qt_resource_data = b"\
|
||||
\x00\x00\x03\x66\
|
||||
\x89\
|
||||
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
|
||||
|
@ -1534,7 +1541,7 @@ qt_resource_data = "\
|
|||
\x82\
|
||||
"
|
||||
|
||||
qt_resource_name = "\
|
||||
qt_resource_name = b"\
|
||||
\x00\x09\
|
||||
\x0c\x78\x54\x88\
|
||||
\x00\x6e\
|
||||
|
@ -1639,7 +1646,7 @@ qt_resource_name = "\
|
|||
\x00\x70\x00\x6e\x00\x67\
|
||||
"
|
||||
|
||||
qt_resource_struct = "\
|
||||
qt_resource_struct = b"\
|
||||
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
|
||||
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
|
||||
\x00\x00\x00\x18\x00\x02\x00\x00\x00\x15\x00\x00\x00\x03\
|
||||
|
|
|
@ -7,14 +7,23 @@
|
|||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import *
|
||||
from builtins import object
|
||||
from past.utils import old_div
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from bmconfigparser import BMConfigParser
|
||||
from foldertree import AddressBookCompleter
|
||||
from messageview import MessageView
|
||||
from messagecompose import MessageCompose
|
||||
import settingsmixin
|
||||
from networkstatus import NetworkStatus
|
||||
from blacklist import Blacklist
|
||||
from .foldertree import AddressBookCompleter
|
||||
from .messageview import MessageView
|
||||
from .messagecompose import MessageCompose
|
||||
from . import settingsmixin
|
||||
from .networkstatus import NetworkStatus
|
||||
from .blacklist import Blacklist
|
||||
|
||||
try:
|
||||
_fromUtf8 = QtCore.QString.fromUtf8
|
||||
|
@ -104,7 +113,6 @@ class Ui_MainWindow(object):
|
|||
self.inboxSearchOption.addItem(_fromUtf8(""))
|
||||
self.inboxSearchOption.addItem(_fromUtf8(""))
|
||||
self.inboxSearchOption.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
|
||||
self.inboxSearchOption.setCurrentIndex(3)
|
||||
self.horizontalSplitterSearch.addWidget(self.inboxSearchOption)
|
||||
self.horizontalSplitterSearch.handle(1).setEnabled(False)
|
||||
self.horizontalSplitterSearch.setStretchFactor(0, 1)
|
||||
|
@ -404,8 +412,8 @@ class Ui_MainWindow(object):
|
|||
self.inboxSearchOptionSubscriptions.addItem(_fromUtf8(""))
|
||||
self.inboxSearchOptionSubscriptions.addItem(_fromUtf8(""))
|
||||
self.inboxSearchOptionSubscriptions.addItem(_fromUtf8(""))
|
||||
self.inboxSearchOptionSubscriptions.addItem(_fromUtf8(""))
|
||||
self.inboxSearchOptionSubscriptions.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
|
||||
self.inboxSearchOptionSubscriptions.setCurrentIndex(2)
|
||||
self.horizontalSplitter_2.addWidget(self.inboxSearchOptionSubscriptions)
|
||||
self.horizontalSplitter_2.handle(1).setEnabled(False)
|
||||
self.horizontalSplitter_2.setStretchFactor(0, 1)
|
||||
|
@ -505,7 +513,6 @@ class Ui_MainWindow(object):
|
|||
self.inboxSearchOptionChans.addItem(_fromUtf8(""))
|
||||
self.inboxSearchOptionChans.addItem(_fromUtf8(""))
|
||||
self.inboxSearchOptionChans.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
|
||||
self.inboxSearchOptionChans.setCurrentIndex(3)
|
||||
self.horizontalSplitter_6.addWidget(self.inboxSearchOptionChans)
|
||||
self.horizontalSplitter_6.handle(1).setEnabled(False)
|
||||
self.horizontalSplitter_6.setStretchFactor(0, 1)
|
||||
|
@ -710,7 +717,7 @@ class Ui_MainWindow(object):
|
|||
self.pushButtonTTL.setText(_translate("MainWindow", "TTL:", None))
|
||||
hours = 48
|
||||
try:
|
||||
hours = int(BMConfigParser().getint('bitmessagesettings', 'ttl')/60/60)
|
||||
hours = int(old_div(BMConfigParser().getint('bitmessagesettings', 'ttl'),60/60))
|
||||
except:
|
||||
pass
|
||||
self.labelHumanFriendlyTTLDescription.setText(_translate("MainWindow", "%n hour(s)", None, QtCore.QCoreApplication.CodecForTr, hours))
|
||||
|
@ -721,9 +728,10 @@ class Ui_MainWindow(object):
|
|||
self.pushButtonAddSubscription.setText(_translate("MainWindow", "Add new Subscription", None))
|
||||
self.inboxSearchLineEditSubscriptions.setPlaceholderText(_translate("MainWindow", "Search", None))
|
||||
self.inboxSearchOptionSubscriptions.setItemText(0, _translate("MainWindow", "All", None))
|
||||
self.inboxSearchOptionSubscriptions.setItemText(1, _translate("MainWindow", "From", None))
|
||||
self.inboxSearchOptionSubscriptions.setItemText(2, _translate("MainWindow", "Subject", None))
|
||||
self.inboxSearchOptionSubscriptions.setItemText(3, _translate("MainWindow", "Message", None))
|
||||
self.inboxSearchOptionSubscriptions.setItemText(1, _translate("MainWindow", "To", None))
|
||||
self.inboxSearchOptionSubscriptions.setItemText(2, _translate("MainWindow", "From", None))
|
||||
self.inboxSearchOptionSubscriptions.setItemText(3, _translate("MainWindow", "Subject", None))
|
||||
self.inboxSearchOptionSubscriptions.setItemText(4, _translate("MainWindow", "Message", None))
|
||||
self.tableWidgetInboxSubscriptions.setSortingEnabled(True)
|
||||
item = self.tableWidgetInboxSubscriptions.horizontalHeaderItem(0)
|
||||
item.setText(_translate("MainWindow", "To", None))
|
||||
|
@ -771,10 +779,8 @@ class Ui_MainWindow(object):
|
|||
self.actionRegenerateDeterministicAddresses.setText(_translate("MainWindow", "Regenerate deterministic addresses", None))
|
||||
self.actionDeleteAllTrashedMessages.setText(_translate("MainWindow", "Delete all trashed messages", None))
|
||||
self.actionJoinChan.setText(_translate("MainWindow", "Join / Create chan", None))
|
||||
self.updateNetworkSwitchMenuLabel()
|
||||
|
||||
|
||||
import bitmessage_icons_rc
|
||||
from . import bitmessage_icons_rc
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
|
|
|
@ -1,15 +1,23 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
from builtins import *
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
import widgets
|
||||
from . import widgets
|
||||
from addresses import addBMIfNotPresent
|
||||
from bmconfigparser import BMConfigParser
|
||||
from dialogs import AddAddressDialog
|
||||
from .dialogs import AddAddressDialog
|
||||
from helper_sql import sqlExecute, sqlQuery
|
||||
from queues import UISignalQueue
|
||||
from retranslateui import RetranslateMixin
|
||||
from .retranslateui import RetranslateMixin
|
||||
from tr import _translate
|
||||
from uisignaler import UISignaler
|
||||
from utils import avatarize
|
||||
from .uisignaler import UISignaler
|
||||
from .utils import avatarize
|
||||
|
||||
|
||||
class Blacklist(QtGui.QWidget, RetranslateMixin):
|
||||
|
@ -73,7 +81,7 @@ class Blacklist(QtGui.QWidget, RetranslateMixin):
|
|||
if queryreturn == []:
|
||||
self.tableWidgetBlacklist.setSortingEnabled(False)
|
||||
self.tableWidgetBlacklist.insertRow(0)
|
||||
newItem = QtGui.QTableWidgetItem(unicode(
|
||||
newItem = QtGui.QTableWidgetItem(str(
|
||||
self.NewBlacklistDialogInstance.lineEditLabel.text().toUtf8(), 'utf-8'))
|
||||
newItem.setIcon(avatarize(address))
|
||||
self.tableWidgetBlacklist.setItem(0, 0, newItem)
|
||||
|
@ -172,7 +180,7 @@ class Blacklist(QtGui.QWidget, RetranslateMixin):
|
|||
for row in queryreturn:
|
||||
label, address, enabled = row
|
||||
self.tableWidgetBlacklist.insertRow(0)
|
||||
newItem = QtGui.QTableWidgetItem(unicode(label, 'utf-8'))
|
||||
newItem = QtGui.QTableWidgetItem(str(label, 'utf-8'))
|
||||
if not enabled:
|
||||
newItem.setTextColor(QtGui.QColor(128, 128, 128))
|
||||
newItem.setIcon(avatarize(address))
|
||||
|
|
|
@ -1,31 +1,38 @@
|
|||
"""
|
||||
Custom dialog classes
|
||||
src/bitmessageqt/dialogs.py
|
||||
===========================
|
||||
"""
|
||||
# pylint: disable=too-few-public-methods
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
from builtins import *
|
||||
from PyQt4 import QtGui
|
||||
|
||||
import paths
|
||||
import widgets
|
||||
from address_dialogs import (
|
||||
AddAddressDialog, EmailGatewayDialog, NewAddressDialog,
|
||||
NewSubscriptionDialog, RegenerateAddressesDialog,
|
||||
SpecialAddressBehaviorDialog
|
||||
)
|
||||
from newchandialog import NewChanDialog
|
||||
from settings import SettingsDialog
|
||||
from tr import _translate
|
||||
from version import softwareVersion
|
||||
|
||||
import paths
|
||||
from . import widgets
|
||||
from .address_dialogs import (
|
||||
AddAddressDialog, EmailGatewayDialog, NewAddressDialog, NewSubscriptionDialog, RegenerateAddressesDialog,
|
||||
SpecialAddressBehaviorDialog
|
||||
)
|
||||
from .newchandialog import NewChanDialog
|
||||
from .retranslateui import RetranslateMixin
|
||||
from tr import _translate
|
||||
|
||||
__all__ = [
|
||||
"NewChanDialog", "AddAddressDialog", "NewAddressDialog",
|
||||
"NewSubscriptionDialog", "RegenerateAddressesDialog",
|
||||
"SpecialAddressBehaviorDialog", "EmailGatewayDialog",
|
||||
"SettingsDialog"
|
||||
"SpecialAddressBehaviorDialog", "EmailGatewayDialog"
|
||||
]
|
||||
|
||||
|
||||
class AboutDialog(QtGui.QDialog):
|
||||
class AboutDialog(QtGui.QDialog, RetranslateMixin):
|
||||
"""The `About` dialog"""
|
||||
def __init__(self, parent=None):
|
||||
super(AboutDialog, self).__init__(parent)
|
||||
|
@ -45,7 +52,7 @@ class AboutDialog(QtGui.QDialog):
|
|||
try:
|
||||
self.label_2.setText(
|
||||
self.label_2.text().replace(
|
||||
'2020', str(last_commit.get('time').year)
|
||||
'2019', str(last_commit.get('time').year)
|
||||
))
|
||||
except AttributeError:
|
||||
pass
|
||||
|
@ -53,7 +60,7 @@ class AboutDialog(QtGui.QDialog):
|
|||
self.setFixedSize(QtGui.QWidget.sizeHint(self))
|
||||
|
||||
|
||||
class IconGlossaryDialog(QtGui.QDialog):
|
||||
class IconGlossaryDialog(QtGui.QDialog, RetranslateMixin):
|
||||
"""The `Icon Glossary` dialog, explaining the status icon colors"""
|
||||
def __init__(self, parent=None, config=None):
|
||||
super(IconGlossaryDialog, self).__init__(parent)
|
||||
|
@ -69,7 +76,7 @@ class IconGlossaryDialog(QtGui.QDialog):
|
|||
self.setFixedSize(QtGui.QWidget.sizeHint(self))
|
||||
|
||||
|
||||
class HelpDialog(QtGui.QDialog):
|
||||
class HelpDialog(QtGui.QDialog, RetranslateMixin):
|
||||
"""The `Help` dialog"""
|
||||
def __init__(self, parent=None):
|
||||
super(HelpDialog, self).__init__(parent)
|
||||
|
@ -77,7 +84,7 @@ class HelpDialog(QtGui.QDialog):
|
|||
self.setFixedSize(QtGui.QWidget.sizeHint(self))
|
||||
|
||||
|
||||
class ConnectDialog(QtGui.QDialog):
|
||||
class ConnectDialog(QtGui.QDialog, RetranslateMixin):
|
||||
"""The `Connect` dialog"""
|
||||
def __init__(self, parent=None):
|
||||
super(ConnectDialog, self).__init__(parent)
|
||||
|
|
|
@ -1,18 +1,28 @@
|
|||
"""
|
||||
Folder tree and messagelist widgets definitions.
|
||||
src/bitmessageqt/foldertree.py
|
||||
==============================
|
||||
"""
|
||||
# pylint: disable=too-many-arguments,bad-super-call
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
# pylint: disable=too-many-arguments,bad-super-call,attribute-defined-outside-init
|
||||
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
from builtins import range
|
||||
from builtins import *
|
||||
from builtins import object
|
||||
from cgi import escape
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from bmconfigparser import BMConfigParser
|
||||
from helper_sql import sqlExecute, sqlQuery
|
||||
from settingsmixin import SettingsMixin
|
||||
from .settingsmixin import SettingsMixin
|
||||
from tr import _translate
|
||||
from utils import avatarize
|
||||
from .utils import avatarize
|
||||
|
||||
# for pylupdate
|
||||
_translate("MainWindow", "inbox")
|
||||
|
@ -20,8 +30,6 @@ _translate("MainWindow", "new")
|
|||
_translate("MainWindow", "sent")
|
||||
_translate("MainWindow", "trash")
|
||||
|
||||
TimestampRole = QtCore.Qt.UserRole + 1
|
||||
|
||||
|
||||
class AccountMixin(object):
|
||||
"""UI-related functionality for accounts"""
|
||||
|
@ -124,7 +132,7 @@ class AccountMixin(object):
|
|||
AccountMixin.NORMAL,
|
||||
AccountMixin.CHAN, AccountMixin.MAILINGLIST):
|
||||
try:
|
||||
retval = unicode(
|
||||
retval = str(
|
||||
BMConfigParser().get(self.address, 'label'), 'utf-8')
|
||||
except Exception:
|
||||
queryreturn = sqlQuery(
|
||||
|
@ -136,12 +144,12 @@ class AccountMixin(object):
|
|||
if queryreturn != []:
|
||||
for row in queryreturn:
|
||||
retval, = row
|
||||
retval = unicode(retval, 'utf-8')
|
||||
retval = str(retval, 'utf-8')
|
||||
elif self.address is None or self.type == AccountMixin.ALL:
|
||||
return unicode(
|
||||
return str(
|
||||
str(_translate("MainWindow", "All accounts")), 'utf-8')
|
||||
|
||||
return retval or unicode(self.address, 'utf-8')
|
||||
return retval or str(self.address, 'utf-8')
|
||||
|
||||
|
||||
class BMTreeWidgetItem(QtGui.QTreeWidgetItem, AccountMixin):
|
||||
|
@ -232,15 +240,15 @@ class Ui_AddressWidget(BMTreeWidgetItem, SettingsMixin):
|
|||
|
||||
def _getLabel(self):
|
||||
if self.address is None:
|
||||
return unicode(_translate(
|
||||
return str(_translate(
|
||||
"MainWindow", "All accounts").toUtf8(), 'utf-8', 'ignore')
|
||||
else:
|
||||
try:
|
||||
return unicode(
|
||||
return str(
|
||||
BMConfigParser().get(self.address, 'label'),
|
||||
'utf-8', 'ignore')
|
||||
except:
|
||||
return unicode(self.address, 'utf-8')
|
||||
return str(self.address, 'utf-8')
|
||||
|
||||
def _getAddressBracket(self, unreadCount=False):
|
||||
ret = "" if self.isExpanded() \
|
||||
|
@ -311,8 +319,8 @@ class Ui_SubscriptionWidget(Ui_AddressWidget):
|
|||
if queryreturn != []:
|
||||
for row in queryreturn:
|
||||
retval, = row
|
||||
return unicode(retval, 'utf-8', 'ignore')
|
||||
return unicode(self.address, 'utf-8')
|
||||
return str(retval, 'utf-8', 'ignore')
|
||||
return str(self.address, 'utf-8')
|
||||
|
||||
def setType(self):
|
||||
"""Set account type"""
|
||||
|
@ -326,7 +334,7 @@ class Ui_SubscriptionWidget(Ui_AddressWidget):
|
|||
label = str(
|
||||
value.toString().toUtf8()).decode('utf-8', 'ignore')
|
||||
else:
|
||||
label = unicode(value, 'utf-8', 'ignore')
|
||||
label = str(value, 'utf-8', 'ignore')
|
||||
sqlExecute(
|
||||
'''UPDATE subscriptions SET label=? WHERE address=?''',
|
||||
label, self.address)
|
||||
|
@ -336,14 +344,13 @@ class Ui_SubscriptionWidget(Ui_AddressWidget):
|
|||
class BMTableWidgetItem(QtGui.QTableWidgetItem, SettingsMixin):
|
||||
"""A common abstract class for Table widget item"""
|
||||
|
||||
def __init__(self, label=None, unread=False):
|
||||
def __init__(self, parent=None, label=None, unread=False):
|
||||
super(QtGui.QTableWidgetItem, self).__init__()
|
||||
self.setLabel(label)
|
||||
self.setUnread(unread)
|
||||
self._setup()
|
||||
|
||||
def _setup(self):
|
||||
self.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||
if parent is not None:
|
||||
parent.append(self)
|
||||
|
||||
def setLabel(self, label):
|
||||
"""Set object label"""
|
||||
|
@ -370,9 +377,7 @@ class BMAddressWidget(BMTableWidgetItem, AccountMixin):
|
|||
"""A common class for Table widget item with account"""
|
||||
|
||||
def _setup(self):
|
||||
super(BMAddressWidget, self)._setup()
|
||||
self.setEnabled(True)
|
||||
self.setType()
|
||||
|
||||
def _getLabel(self):
|
||||
return self.label
|
||||
|
@ -392,9 +397,14 @@ class BMAddressWidget(BMTableWidgetItem, AccountMixin):
|
|||
|
||||
class MessageList_AddressWidget(BMAddressWidget):
|
||||
"""Address item in a messagelist"""
|
||||
def __init__(self, address=None, label=None, unread=False):
|
||||
def __init__(self, parent, address=None, label=None, unread=False):
|
||||
self.setAddress(address)
|
||||
super(MessageList_AddressWidget, self).__init__(label, unread)
|
||||
super(MessageList_AddressWidget, self).__init__(parent, label, unread)
|
||||
|
||||
def _setup(self):
|
||||
self.isEnabled = True
|
||||
self.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||
self.setType()
|
||||
|
||||
def setLabel(self, label=None):
|
||||
"""Set label"""
|
||||
|
@ -407,7 +417,7 @@ class MessageList_AddressWidget(BMAddressWidget):
|
|||
AccountMixin.NORMAL,
|
||||
AccountMixin.CHAN, AccountMixin.MAILINGLIST):
|
||||
try:
|
||||
newLabel = unicode(
|
||||
newLabel = str(
|
||||
BMConfigParser().get(self.address, 'label'),
|
||||
'utf-8', 'ignore')
|
||||
except:
|
||||
|
@ -418,7 +428,7 @@ class MessageList_AddressWidget(BMAddressWidget):
|
|||
'''select label from subscriptions where address=?''', self.address)
|
||||
if queryreturn:
|
||||
for row in queryreturn:
|
||||
newLabel = unicode(row[0], 'utf-8', 'ignore')
|
||||
newLabel = str(row[0], 'utf-8', 'ignore')
|
||||
|
||||
self.label = newLabel
|
||||
|
||||
|
@ -443,9 +453,12 @@ class MessageList_AddressWidget(BMAddressWidget):
|
|||
|
||||
class MessageList_SubjectWidget(BMTableWidgetItem):
|
||||
"""Message list subject item"""
|
||||
def __init__(self, subject=None, label=None, unread=False):
|
||||
def __init__(self, parent, subject=None, label=None, unread=False):
|
||||
self.setSubject(subject)
|
||||
super(MessageList_SubjectWidget, self).__init__(label, unread)
|
||||
super(MessageList_SubjectWidget, self).__init__(parent, label, unread)
|
||||
|
||||
def _setup(self):
|
||||
self.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||
|
||||
def setSubject(self, subject):
|
||||
"""Set subject"""
|
||||
|
@ -456,7 +469,7 @@ class MessageList_SubjectWidget(BMTableWidgetItem):
|
|||
if role == QtCore.Qt.UserRole:
|
||||
return self.subject
|
||||
if role == QtCore.Qt.ToolTipRole:
|
||||
return escape(unicode(self.subject, 'utf-8'))
|
||||
return escape(str(self.subject, 'utf-8'))
|
||||
return super(MessageList_SubjectWidget, self).data(role)
|
||||
|
||||
# label (or address) alphabetically, disabled at the end
|
||||
|
@ -466,37 +479,6 @@ class MessageList_SubjectWidget(BMTableWidgetItem):
|
|||
return super(QtGui.QTableWidgetItem, self).__lt__(other)
|
||||
|
||||
|
||||
# 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.
|
||||
class MessageList_TimeWidget(BMTableWidgetItem):
|
||||
"""
|
||||
A subclass of QTableWidgetItem for received (lastactiontime) field.
|
||||
'<' operator is overloaded to sort by TimestampRole == 33
|
||||
msgid is available by QtCore.Qt.UserRole
|
||||
"""
|
||||
|
||||
def __init__(self, label=None, unread=False, timestamp=None, msgid=''):
|
||||
super(MessageList_TimeWidget, self).__init__(label, unread)
|
||||
self.setData(QtCore.Qt.UserRole, QtCore.QByteArray(msgid))
|
||||
self.setData(TimestampRole, int(timestamp))
|
||||
|
||||
def __lt__(self, other):
|
||||
return self.data(TimestampRole) < other.data(TimestampRole)
|
||||
|
||||
def data(self, role=QtCore.Qt.UserRole):
|
||||
"""
|
||||
Returns expected python types for QtCore.Qt.UserRole and TimestampRole
|
||||
custom roles and super for any Qt role
|
||||
"""
|
||||
data = super(MessageList_TimeWidget, self).data(role)
|
||||
if role == TimestampRole:
|
||||
return int(data.toPyObject())
|
||||
if role == QtCore.Qt.UserRole:
|
||||
return str(data.toPyObject())
|
||||
return data
|
||||
|
||||
|
||||
class Ui_AddressBookWidgetItem(BMAddressWidget):
|
||||
"""Addressbook item"""
|
||||
# pylint: disable=unused-argument
|
||||
|
@ -546,8 +528,8 @@ class Ui_AddressBookWidgetItem(BMAddressWidget):
|
|||
class Ui_AddressBookWidgetItemLabel(Ui_AddressBookWidgetItem):
|
||||
"""Addressbook label item"""
|
||||
def __init__(self, address, label, acc_type):
|
||||
self.address = address
|
||||
super(Ui_AddressBookWidgetItemLabel, self).__init__(label, acc_type)
|
||||
self.address = address
|
||||
|
||||
def data(self, role):
|
||||
"""Return object data"""
|
||||
|
@ -558,8 +540,9 @@ class Ui_AddressBookWidgetItemLabel(Ui_AddressBookWidgetItem):
|
|||
class Ui_AddressBookWidgetItemAddress(Ui_AddressBookWidgetItem):
|
||||
"""Addressbook address item"""
|
||||
def __init__(self, address, label, acc_type):
|
||||
self.address = address
|
||||
super(Ui_AddressBookWidgetItemAddress, self).__init__(address, acc_type)
|
||||
self.address = address
|
||||
self.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||
|
||||
def data(self, role):
|
||||
"""Return object data"""
|
||||
|
@ -584,14 +567,14 @@ class AddressBookCompleter(QtGui.QCompleter):
|
|||
|
||||
def splitPath(self, path):
|
||||
"""Split on semicolon"""
|
||||
text = unicode(path.toUtf8(), 'utf-8')
|
||||
text = str(path.toUtf8(), 'utf-8')
|
||||
return [text[:self.widget().cursorPosition()].split(';')[-1].strip()]
|
||||
|
||||
def pathFromIndex(self, index):
|
||||
"""Perform autocompletion (reimplemented QCompleter method)"""
|
||||
autoString = unicode(
|
||||
autoString = str(
|
||||
index.data(QtCore.Qt.EditRole).toString().toUtf8(), 'utf-8')
|
||||
text = unicode(self.widget().text().toUtf8(), 'utf-8')
|
||||
text = str(self.widget().text().toUtf8(), 'utf-8')
|
||||
|
||||
# If cursor position was saved, restore it, else save it
|
||||
if self.cursorPos != -1:
|
||||
|
|
|
@ -1,45 +1,40 @@
|
|||
"""Language Box Module for Locale Settings"""
|
||||
# pylint: disable=too-few-public-methods,bad-continuation
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from builtins import *
|
||||
import glob
|
||||
import os
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
import paths
|
||||
from bmconfigparser import BMConfigParser
|
||||
|
||||
import paths
|
||||
|
||||
class LanguageBox(QtGui.QComboBox):
|
||||
"""LanguageBox class for Qt UI"""
|
||||
languageName = {
|
||||
"system": "System Settings", "eo": "Esperanto",
|
||||
"en_pirate": "Pirate English"
|
||||
}
|
||||
|
||||
def __init__(self, parent=None):
|
||||
languageName = {"system": "System Settings", "eo": "Esperanto", "en_pirate": "Pirate English"}
|
||||
def __init__(self, parent = None):
|
||||
super(QtGui.QComboBox, self).__init__(parent)
|
||||
self.populate()
|
||||
|
||||
def populate(self):
|
||||
"""Populates drop down list with all available languages."""
|
||||
self.clear()
|
||||
localesPath = os.path.join(paths.codePath(), 'translations')
|
||||
self.addItem(QtGui.QApplication.translate(
|
||||
"settingsDialog", "System Settings", "system"), "system")
|
||||
localesPath = os.path.join (paths.codePath(), 'translations')
|
||||
self.addItem(QtGui.QApplication.translate("settingsDialog", "System Settings", "system"), "system")
|
||||
self.setCurrentIndex(0)
|
||||
self.setInsertPolicy(QtGui.QComboBox.InsertAlphabetically)
|
||||
for translationFile in sorted(
|
||||
glob.glob(os.path.join(localesPath, "bitmessage_*.qm"))
|
||||
):
|
||||
localeShort = \
|
||||
os.path.split(translationFile)[1].split("_", 1)[1][:-3]
|
||||
for translationFile in sorted(glob.glob(os.path.join(localesPath, "bitmessage_*.qm"))):
|
||||
localeShort = os.path.split(translationFile)[1].split("_", 1)[1][:-3]
|
||||
locale = QtCore.QLocale(QtCore.QString(localeShort))
|
||||
|
||||
if localeShort in LanguageBox.languageName:
|
||||
self.addItem(
|
||||
LanguageBox.languageName[localeShort], localeShort)
|
||||
self.addItem(LanguageBox.languageName[localeShort], localeShort)
|
||||
elif locale.nativeLanguageName() == "":
|
||||
self.addItem(localeShort, localeShort)
|
||||
else:
|
||||
locale = QtCore.QLocale(localeShort)
|
||||
self.addItem(
|
||||
locale.nativeLanguageName() or localeShort, localeShort)
|
||||
self.addItem(locale.nativeLanguageName(), localeShort)
|
||||
|
||||
configuredLocale = BMConfigParser().safeGet(
|
||||
'bitmessagesettings', 'userlocale', "system")
|
||||
|
|
|
@ -1,37 +1,32 @@
|
|||
"""
|
||||
Message editor with a wheel zoom functionality
|
||||
"""
|
||||
# pylint: disable=bad-continuation
|
||||
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
from builtins import *
|
||||
from past.utils import old_div
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
|
||||
class MessageCompose(QtGui.QTextEdit):
|
||||
"""Editor class with wheel zoom functionality"""
|
||||
def __init__(self, parent=0):
|
||||
|
||||
def __init__(self, parent = 0):
|
||||
super(MessageCompose, self).__init__(parent)
|
||||
self.setAcceptRichText(False)
|
||||
self.setAcceptRichText(False) # we'll deal with this later when we have a new message format
|
||||
self.defaultFontPointSize = self.currentFont().pointSize()
|
||||
|
||||
def wheelEvent(self, event):
|
||||
"""Mouse wheel scroll event handler"""
|
||||
if (
|
||||
QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ControlModifier
|
||||
) == QtCore.Qt.ControlModifier and event.orientation() == QtCore.Qt.Vertical:
|
||||
if (QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ControlModifier) == QtCore.Qt.ControlModifier and event.orientation() == QtCore.Qt.Vertical:
|
||||
if event.delta() > 0:
|
||||
self.zoomIn(1)
|
||||
else:
|
||||
self.zoomOut(1)
|
||||
zoom = self.currentFont().pointSize() * 100 / self.defaultFontPointSize
|
||||
QtGui.QApplication.activeWindow().statusBar().showMessage(
|
||||
QtGui.QApplication.translate("MainWindow", "Zoom level %1%").arg(
|
||||
str(zoom)
|
||||
)
|
||||
)
|
||||
zoom = old_div(self.currentFont().pointSize() * 100, self.defaultFontPointSize)
|
||||
QtGui.QApplication.activeWindow().statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Zoom level %1%").arg(str(zoom)))
|
||||
else:
|
||||
# in QTextEdit, super does not zoom, only scroll
|
||||
super(MessageCompose, self).wheelEvent(event)
|
||||
|
||||
def reset(self):
|
||||
"""Clear the edit content"""
|
||||
self.setText('')
|
||||
|
|
|
@ -1,14 +1,21 @@
|
|||
"""
|
||||
Custom message viewer with support for switching between HTML and plain
|
||||
text rendering, HTML sanitization, lazy rendering (as you scroll down),
|
||||
zoom and URL click warning popup
|
||||
src/bitmessageqt/messageview.py
|
||||
===============================
|
||||
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
from builtins import *
|
||||
from past.utils import old_div
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from safehtmlparser import SafeHTMLParser
|
||||
from tr import _translate
|
||||
from .safehtmlparser import SafeHTMLParser
|
||||
|
||||
|
||||
class MessageView(QtGui.QTextBrowser):
|
||||
|
@ -51,12 +58,11 @@ class MessageView(QtGui.QTextBrowser):
|
|||
"""Mouse wheel scroll event handler"""
|
||||
# super will actually automatically take care of zooming
|
||||
super(MessageView, self).wheelEvent(event)
|
||||
if (
|
||||
QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ControlModifier
|
||||
) == QtCore.Qt.ControlModifier and event.orientation() == QtCore.Qt.Vertical:
|
||||
zoom = self.currentFont().pointSize() * 100 / self.defaultFontPointSize
|
||||
QtGui.QApplication.activeWindow().statusBar().showMessage(_translate(
|
||||
"MainWindow", "Zoom level %1%").arg(str(zoom)))
|
||||
if (QtGui.QApplication.queryKeyboardModifiers() &
|
||||
QtCore.Qt.ControlModifier) == QtCore.Qt.ControlModifier and event.orientation() == QtCore.Qt.Vertical:
|
||||
zoom = old_div(self.currentFont().pointSize() * 100, self.defaultFontPointSize)
|
||||
QtGui.QApplication.activeWindow().statusBar().showMessage(
|
||||
QtGui.QApplication.translate("MainWindow", "Zoom level %1%").arg(str(zoom)))
|
||||
|
||||
def setWrappingWidth(self, width=None):
|
||||
"""Set word-wrapping width"""
|
||||
|
@ -91,7 +97,7 @@ class MessageView(QtGui.QTextBrowser):
|
|||
QtGui.QApplication.translate(
|
||||
"MessageView",
|
||||
"The link \"%1\" will open in a browser. It may be a security risk, it could de-anonymise you"
|
||||
" or download malicious data. Are you sure?").arg(unicode(link.toString())),
|
||||
" or download malicious data. Are you sure?").arg(str(link.toString())),
|
||||
QtGui.QMessageBox.Yes,
|
||||
QtGui.QMessageBox.No)
|
||||
if reply == QtGui.QMessageBox.Yes:
|
||||
|
@ -133,7 +139,7 @@ class MessageView(QtGui.QTextBrowser):
|
|||
self.mode = MessageView.MODE_PLAIN
|
||||
out = self.html.raw
|
||||
if self.html.has_html:
|
||||
out = "<div align=\"center\" style=\"text-decoration: underline;\"><b>" + unicode(
|
||||
out = "<div align=\"center\" style=\"text-decoration: underline;\"><b>" + str(
|
||||
QtGui.QApplication.translate(
|
||||
"MessageView", "HTML detected, click here to display")) + "</b></div><br/>" + out
|
||||
self.out = out
|
||||
|
@ -145,7 +151,7 @@ class MessageView(QtGui.QTextBrowser):
|
|||
"""Render message as HTML"""
|
||||
self.mode = MessageView.MODE_HTML
|
||||
out = self.html.sanitised
|
||||
out = "<div align=\"center\" style=\"text-decoration: underline;\"><b>" + unicode(
|
||||
out = "<div align=\"center\" style=\"text-decoration: underline;\"><b>" + str(
|
||||
QtGui.QApplication.translate("MessageView", "Click here to disable HTML")) + "</b></div><br/>" + out
|
||||
self.out = out
|
||||
self.outpos = 0
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
#!/usr/bin/env python2.7
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import *
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
class MigrationWizardIntroPage(QtGui.QWizardPage):
|
||||
|
|
|
@ -1,20 +1,34 @@
|
|||
"""
|
||||
Network status tab widget definition.
|
||||
"""
|
||||
src/bitmessageqt/networkstatus.py
|
||||
=================================
|
||||
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
from builtins import map
|
||||
from builtins import range
|
||||
from builtins import *
|
||||
from past.utils import old_div
|
||||
import time
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
import knownnodes
|
||||
import l10n
|
||||
import network.stats
|
||||
import state
|
||||
import widgets
|
||||
import shared
|
||||
from . import widgets
|
||||
from inventory import Inventory
|
||||
from network import BMConnectionPool, knownnodes
|
||||
from retranslateui import RetranslateMixin
|
||||
from network.fix_circular_imports import BMConnectionPool
|
||||
from .retranslateui import RetranslateMixin
|
||||
from tr import _translate
|
||||
from uisignaler import UISignaler
|
||||
from .uisignaler import UISignaler
|
||||
|
||||
|
||||
class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
||||
|
@ -31,6 +45,8 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
|||
header.setSortIndicator(0, QtCore.Qt.AscendingOrder)
|
||||
|
||||
self.startup = time.localtime()
|
||||
self.labelStartupTime.setText(_translate("networkstatus", "Since startup on %1").arg(
|
||||
l10n.formatTimestamp(self.startup)))
|
||||
|
||||
self.UISignalThread = UISignaler.get()
|
||||
# pylint: disable=no-member
|
||||
|
@ -91,8 +107,8 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
|||
"Object(s) to be synced: %n",
|
||||
None,
|
||||
QtCore.QCoreApplication.CodecForTr,
|
||||
network.stats.pendingDownload()
|
||||
+ network.stats.pendingUpload()))
|
||||
network.stats.pendingDownload() +
|
||||
network.stats.pendingUpload()))
|
||||
|
||||
def updateNumberOfMessagesProcessed(self):
|
||||
"""Update the counter for number of processed messages"""
|
||||
|
@ -103,7 +119,7 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
|||
"Processed %n person-to-person message(s).",
|
||||
None,
|
||||
QtCore.QCoreApplication.CodecForTr,
|
||||
state.numberOfMessagesProcessed))
|
||||
shared.numberOfMessagesProcessed))
|
||||
|
||||
def updateNumberOfBroadcastsProcessed(self):
|
||||
"""Update the counter for the number of processed broadcasts"""
|
||||
|
@ -114,7 +130,7 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
|||
"Processed %n broadcast message(s).",
|
||||
None,
|
||||
QtCore.QCoreApplication.CodecForTr,
|
||||
state.numberOfBroadcastsProcessed))
|
||||
shared.numberOfBroadcastsProcessed))
|
||||
|
||||
def updateNumberOfPubkeysProcessed(self):
|
||||
"""Update the counter for the number of processed pubkeys"""
|
||||
|
@ -125,7 +141,7 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
|||
"Processed %n public key(s).",
|
||||
None,
|
||||
QtCore.QCoreApplication.CodecForTr,
|
||||
state.numberOfPubkeysProcessed))
|
||||
shared.numberOfPubkeysProcessed))
|
||||
|
||||
def updateNumberOfBytes(self):
|
||||
"""
|
||||
|
@ -202,7 +218,7 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
|||
self.tableWidgetConnectionCount.item(0, 0).setData(QtCore.Qt.UserRole, destination)
|
||||
self.tableWidgetConnectionCount.item(0, 1).setData(QtCore.Qt.UserRole, outbound)
|
||||
else:
|
||||
if not BMConnectionPool().inboundConnections:
|
||||
if len(BMConnectionPool().inboundConnections) == 0:
|
||||
self.window().setStatusIcon('yellow')
|
||||
for i in range(self.tableWidgetConnectionCount.rowCount()):
|
||||
if self.tableWidgetConnectionCount.item(i, 0).data(QtCore.Qt.UserRole).toPyObject() != destination:
|
||||
|
@ -220,30 +236,21 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
|||
# FYI: The 'singlelistener' thread sets the icon color to green when it
|
||||
# receives an incoming connection, meaning that the user's firewall is
|
||||
# configured correctly.
|
||||
if self.tableWidgetConnectionCount.rowCount() and state.statusIconColor == 'red':
|
||||
if self.tableWidgetConnectionCount.rowCount() and shared.statusIconColor == 'red':
|
||||
self.window().setStatusIcon('yellow')
|
||||
elif self.tableWidgetConnectionCount.rowCount() == 0 and state.statusIconColor != "red":
|
||||
elif self.tableWidgetConnectionCount.rowCount() == 0 and shared.statusIconColor != "red":
|
||||
self.window().setStatusIcon('red')
|
||||
|
||||
# timer driven
|
||||
def runEveryTwoSeconds(self):
|
||||
"""Updates counters, runs every 2 seconds if the timer is running"""
|
||||
self.labelLookupsPerSecond.setText(_translate("networkstatus", "Inventory lookups per second: %1").arg(
|
||||
str(Inventory().numberOfInventoryLookupsPerformed / 2)))
|
||||
str(old_div(Inventory().numberOfInventoryLookupsPerformed, 2))))
|
||||
Inventory().numberOfInventoryLookupsPerformed = 0
|
||||
self.updateNumberOfBytes()
|
||||
self.updateNumberOfObjectsToBeSynced()
|
||||
|
||||
def retranslateUi(self):
|
||||
"""Conventional Qt Designer method for dynamic l10n"""
|
||||
super(NetworkStatus, self).retranslateUi()
|
||||
self.labelTotalConnections.setText(
|
||||
_translate(
|
||||
"networkstatus", "Total Connections: %1").arg(
|
||||
str(self.tableWidgetConnectionCount.rowCount())))
|
||||
self.labelStartupTime.setText(_translate(
|
||||
"networkstatus", "Since startup on %1"
|
||||
).arg(l10n.formatTimestamp(self.startup)))
|
||||
self.updateNumberOfMessagesProcessed()
|
||||
self.updateNumberOfBroadcastsProcessed()
|
||||
self.updateNumberOfPubkeysProcessed()
|
||||
self.labelStartupTime.setText(_translate("networkstatus", "Since startup on %1").arg(
|
||||
l10n.formatTimestamp(self.startup)))
|
||||
|
|
362
src/bitmessageqt/newaddresswizard.py
Normal file
362
src/bitmessageqt/newaddresswizard.py
Normal file
|
@ -0,0 +1,362 @@
|
|||
#!/usr/bin/env python2.7
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from builtins import *
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
class NewAddressWizardIntroPage(QtGui.QWizardPage):
|
||||
def __init__(self):
|
||||
super(QtGui.QWizardPage, self).__init__()
|
||||
self.setTitle("Creating a new address")
|
||||
|
||||
label = QtGui.QLabel("This wizard will help you create as many addresses as you like. Indeed, creating and abandoning addresses is encouraged.\n\n"
|
||||
"What type of address would you like? Would you like to send emails or not?\n"
|
||||
"You can still change your mind later, and register/unregister with an email service provider.\n\n")
|
||||
label.setWordWrap(True)
|
||||
|
||||
self.emailAsWell = QtGui.QRadioButton("Combined email and bitmessage address")
|
||||
self.onlyBM = QtGui.QRadioButton("Bitmessage-only address (no email)")
|
||||
self.emailAsWell.setChecked(True)
|
||||
self.registerField("emailAsWell", self.emailAsWell)
|
||||
self.registerField("onlyBM", self.onlyBM)
|
||||
|
||||
layout = QtGui.QVBoxLayout()
|
||||
layout.addWidget(label)
|
||||
layout.addWidget(self.emailAsWell)
|
||||
layout.addWidget(self.onlyBM)
|
||||
self.setLayout(layout)
|
||||
|
||||
def nextId(self):
|
||||
if self.emailAsWell.isChecked():
|
||||
return 4
|
||||
else:
|
||||
return 1
|
||||
|
||||
|
||||
class NewAddressWizardRngPassphrasePage(QtGui.QWizardPage):
|
||||
def __init__(self):
|
||||
super(QtGui.QWizardPage, self).__init__()
|
||||
self.setTitle("Random or Passphrase")
|
||||
|
||||
label = QtGui.QLabel("<html><head/><body><p>You may generate addresses by using either random numbers or by using a passphrase. "
|
||||
"If you use a passphrase, the address is called a "deterministic" address. "
|
||||
"The \'Random Number\' option is selected by default but deterministic addresses have several pros and cons:</p>"
|
||||
"<table border=0><tr><td><span style=\" font-weight:600;\">Pros:</span></td><td><span style=\" font-weight:600;\">Cons:</span></td></tr>"
|
||||
"<tr><td>You can recreate your addresses on any computer from memory. "
|
||||
"You need-not worry about backing up your keys.dat file as long as you can remember your passphrase.</td>"
|
||||
"<td>You must remember (or write down) your passphrase if you expect to be able "
|
||||
"to recreate your keys if they are lost. "
|
||||
# "You must remember the address version number and the stream number along with your passphrase. "
|
||||
"If you choose a weak passphrase and someone on the Internet can brute-force it, they can read your messages and send messages as you."
|
||||
"</p></body></html>")
|
||||
label.setWordWrap(True)
|
||||
|
||||
self.randomAddress = QtGui.QRadioButton("Use a random number generator to make an address")
|
||||
self.deterministicAddress = QtGui.QRadioButton("Use a passphrase to make an address")
|
||||
self.randomAddress.setChecked(True)
|
||||
|
||||
layout = QtGui.QVBoxLayout()
|
||||
layout.addWidget(label)
|
||||
layout.addWidget(self.randomAddress)
|
||||
layout.addWidget(self.deterministicAddress)
|
||||
self.setLayout(layout)
|
||||
|
||||
def nextId(self):
|
||||
if self.randomAddress.isChecked():
|
||||
return 2
|
||||
else:
|
||||
return 3
|
||||
|
||||
class NewAddressWizardRandomPage(QtGui.QWizardPage):
|
||||
def __init__(self, addresses):
|
||||
super(QtGui.QWizardPage, self).__init__()
|
||||
self.setTitle("Random")
|
||||
|
||||
label = QtGui.QLabel("Random address.")
|
||||
label.setWordWrap(True)
|
||||
|
||||
labelLabel = QtGui.QLabel("Label (not shown to anyone except you):")
|
||||
self.labelLineEdit = QtGui.QLineEdit()
|
||||
|
||||
self.radioButtonMostAvailable = QtGui.QRadioButton("Use the most available stream\n"
|
||||
"(best if this is the first of many addresses you will create)")
|
||||
self.radioButtonExisting = QtGui.QRadioButton("Use the same stream as an existing address\n"
|
||||
"(saves you some bandwidth and processing power)")
|
||||
self.radioButtonMostAvailable.setChecked(True)
|
||||
self.comboBoxExisting = QtGui.QComboBox()
|
||||
self.comboBoxExisting.setEnabled(False)
|
||||
self.comboBoxExisting.setEditable(True)
|
||||
|
||||
for address in addresses:
|
||||
self.comboBoxExisting.addItem(address)
|
||||
|
||||
# self.comboBoxExisting.setObjectName(_fromUtf8("comboBoxExisting"))
|
||||
self.checkBoxEighteenByteRipe = QtGui.QCheckBox("Spend several minutes of extra computing time to make the address(es) 1 or 2 characters shorter")
|
||||
|
||||
layout = QtGui.QGridLayout()
|
||||
layout.addWidget(label, 0, 0)
|
||||
layout.addWidget(labelLabel, 1, 0)
|
||||
layout.addWidget(self.labelLineEdit, 2, 0)
|
||||
layout.addWidget(self.radioButtonMostAvailable, 3, 0)
|
||||
layout.addWidget(self.radioButtonExisting, 4, 0)
|
||||
layout.addWidget(self.comboBoxExisting, 5, 0)
|
||||
layout.addWidget(self.checkBoxEighteenByteRipe, 6, 0)
|
||||
self.setLayout(layout)
|
||||
|
||||
QtCore.QObject.connect(self.radioButtonExisting, QtCore.SIGNAL("toggled(bool)"), self.comboBoxExisting.setEnabled)
|
||||
|
||||
self.registerField("label", self.labelLineEdit)
|
||||
self.registerField("radioButtonMostAvailable", self.radioButtonMostAvailable)
|
||||
self.registerField("radioButtonExisting", self.radioButtonExisting)
|
||||
self.registerField("comboBoxExisting", self.comboBoxExisting)
|
||||
|
||||
# self.emailAsWell = QtGui.QRadioButton("Combined email and bitmessage account")
|
||||
# self.onlyBM = QtGui.QRadioButton("Bitmessage-only account (no email)")
|
||||
# self.emailAsWell.setChecked(True)
|
||||
|
||||
def nextId(self):
|
||||
return 6
|
||||
|
||||
|
||||
class NewAddressWizardPassphrasePage(QtGui.QWizardPage):
|
||||
def __init__(self):
|
||||
super(QtGui.QWizardPage, self).__init__()
|
||||
self.setTitle("Passphrase")
|
||||
|
||||
label = QtGui.QLabel("Deterministric address.")
|
||||
label.setWordWrap(True)
|
||||
|
||||
passphraseLabel = QtGui.QLabel("Passphrase")
|
||||
self.lineEditPassphrase = QtGui.QLineEdit()
|
||||
self.lineEditPassphrase.setEchoMode(QtGui.QLineEdit.Password)
|
||||
self.lineEditPassphrase.setInputMethodHints(QtCore.Qt.ImhHiddenText|QtCore.Qt.ImhNoAutoUppercase|QtCore.Qt.ImhNoPredictiveText)
|
||||
retypePassphraseLabel = QtGui.QLabel("Retype passphrase")
|
||||
self.lineEditPassphraseAgain = QtGui.QLineEdit()
|
||||
self.lineEditPassphraseAgain.setEchoMode(QtGui.QLineEdit.Password)
|
||||
|
||||
numberLabel = QtGui.QLabel("Number of addresses to make based on your passphrase:")
|
||||
self.spinBoxNumberOfAddressesToMake = QtGui.QSpinBox()
|
||||
self.spinBoxNumberOfAddressesToMake.setMinimum(1)
|
||||
self.spinBoxNumberOfAddressesToMake.setProperty("value", 8)
|
||||
# self.spinBoxNumberOfAddressesToMake.setObjectName(_fromUtf8("spinBoxNumberOfAddressesToMake"))
|
||||
label2 = QtGui.QLabel("In addition to your passphrase, you must remember these numbers:")
|
||||
label3 = QtGui.QLabel("Address version number: 4")
|
||||
label4 = QtGui.QLabel("Stream number: 1")
|
||||
|
||||
layout = QtGui.QGridLayout()
|
||||
layout.addWidget(label, 0, 0, 1, 4)
|
||||
layout.addWidget(passphraseLabel, 1, 0, 1, 4)
|
||||
layout.addWidget(self.lineEditPassphrase, 2, 0, 1, 4)
|
||||
layout.addWidget(retypePassphraseLabel, 3, 0, 1, 4)
|
||||
layout.addWidget(self.lineEditPassphraseAgain, 4, 0, 1, 4)
|
||||
layout.addWidget(numberLabel, 5, 0, 1, 3)
|
||||
layout.addWidget(self.spinBoxNumberOfAddressesToMake, 5, 3)
|
||||
layout.setColumnMinimumWidth(3, 1)
|
||||
layout.addWidget(label2, 6, 0, 1, 4)
|
||||
layout.addWidget(label3, 7, 0, 1, 2)
|
||||
layout.addWidget(label4, 7, 2, 1, 2)
|
||||
self.setLayout(layout)
|
||||
|
||||
def nextId(self):
|
||||
return 6
|
||||
|
||||
|
||||
class NewAddressWizardEmailProviderPage(QtGui.QWizardPage):
|
||||
def __init__(self):
|
||||
super(QtGui.QWizardPage, self).__init__()
|
||||
self.setTitle("Choose email provider")
|
||||
|
||||
label = QtGui.QLabel("Currently only Mailchuck email gateway is available "
|
||||
"(@mailchuck.com email address). In the future, maybe other gateways will be available. "
|
||||
"Press Next.")
|
||||
label.setWordWrap(True)
|
||||
|
||||
# self.mailchuck = QtGui.QRadioButton("Mailchuck email gateway (@mailchuck.com)")
|
||||
# self.mailchuck.setChecked(True)
|
||||
|
||||
layout = QtGui.QVBoxLayout()
|
||||
layout.addWidget(label)
|
||||
# layout.addWidget(self.mailchuck)
|
||||
self.setLayout(layout)
|
||||
|
||||
def nextId(self):
|
||||
return 5
|
||||
|
||||
|
||||
class NewAddressWizardEmailAddressPage(QtGui.QWizardPage):
|
||||
def __init__(self):
|
||||
super(QtGui.QWizardPage, self).__init__()
|
||||
self.setTitle("Email address")
|
||||
|
||||
label = QtGui.QLabel("Choosing an email address. Address must end with @mailchuck.com")
|
||||
label.setWordWrap(True)
|
||||
|
||||
self.specificEmail = QtGui.QRadioButton("Pick your own email address:")
|
||||
self.specificEmail.setChecked(True)
|
||||
self.emailLineEdit = QtGui.QLineEdit()
|
||||
self.randomEmail = QtGui.QRadioButton("Generate a random email address")
|
||||
|
||||
QtCore.QObject.connect(self.specificEmail, QtCore.SIGNAL("toggled(bool)"), self.emailLineEdit.setEnabled)
|
||||
|
||||
layout = QtGui.QVBoxLayout()
|
||||
layout.addWidget(label)
|
||||
layout.addWidget(self.specificEmail)
|
||||
layout.addWidget(self.emailLineEdit)
|
||||
layout.addWidget(self.randomEmail)
|
||||
self.setLayout(layout)
|
||||
|
||||
def nextId(self):
|
||||
return 6
|
||||
|
||||
|
||||
class NewAddressWizardWaitPage(QtGui.QWizardPage):
|
||||
def __init__(self):
|
||||
super(QtGui.QWizardPage, self).__init__()
|
||||
self.setTitle("Wait")
|
||||
|
||||
self.label = QtGui.QLabel("Wait!")
|
||||
self.label.setWordWrap(True)
|
||||
self.progressBar = QtGui.QProgressBar()
|
||||
self.progressBar.setMinimum(0)
|
||||
self.progressBar.setMaximum(100)
|
||||
self.progressBar.setValue(0)
|
||||
|
||||
# self.emailAsWell = QtGui.QRadioButton("Combined email and bitmessage account")
|
||||
# self.onlyBM = QtGui.QRadioButton("Bitmessage-only account (no email)")
|
||||
# self.emailAsWell.setChecked(True)
|
||||
|
||||
layout = QtGui.QVBoxLayout()
|
||||
layout.addWidget(self.label)
|
||||
layout.addWidget(self.progressBar)
|
||||
# layout.addWidget(self.emailAsWell)
|
||||
# layout.addWidget(self.onlyBM)
|
||||
self.setLayout(layout)
|
||||
|
||||
def update(self, i):
|
||||
if i == 101 and self.wizard().currentId() == 6:
|
||||
self.wizard().button(QtGui.QWizard.NextButton).click()
|
||||
return
|
||||
elif i == 101:
|
||||
print("haha")
|
||||
return
|
||||
self.progressBar.setValue(i)
|
||||
if i == 50:
|
||||
self.emit(QtCore.SIGNAL('completeChanged()'))
|
||||
|
||||
def isComplete(self):
|
||||
# print "val = " + str(self.progressBar.value())
|
||||
if self.progressBar.value() >= 50:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def initializePage(self):
|
||||
if self.field("emailAsWell").toBool():
|
||||
val = "yes/"
|
||||
else:
|
||||
val = "no/"
|
||||
if self.field("onlyBM").toBool():
|
||||
val += "yes"
|
||||
else:
|
||||
val += "no"
|
||||
|
||||
self.label.setText("Wait! " + val)
|
||||
# self.wizard().button(QtGui.QWizard.NextButton).setEnabled(False)
|
||||
self.progressBar.setValue(0)
|
||||
self.thread = NewAddressThread()
|
||||
self.connect(self.thread, self.thread.signal, self.update)
|
||||
self.thread.start()
|
||||
|
||||
def nextId(self):
|
||||
return 10
|
||||
|
||||
|
||||
class NewAddressWizardConclusionPage(QtGui.QWizardPage):
|
||||
def __init__(self):
|
||||
super(QtGui.QWizardPage, self).__init__()
|
||||
self.setTitle("All done!")
|
||||
|
||||
label = QtGui.QLabel("You successfully created a new address.")
|
||||
label.setWordWrap(True)
|
||||
|
||||
layout = QtGui.QVBoxLayout()
|
||||
layout.addWidget(label)
|
||||
self.setLayout(layout)
|
||||
|
||||
class Ui_NewAddressWizard(QtGui.QWizard):
|
||||
def __init__(self, addresses):
|
||||
super(QtGui.QWizard, self).__init__()
|
||||
|
||||
self.pages = {}
|
||||
|
||||
page = NewAddressWizardIntroPage()
|
||||
self.setPage(0, page)
|
||||
self.setStartId(0)
|
||||
page = NewAddressWizardRngPassphrasePage()
|
||||
self.setPage(1, page)
|
||||
page = NewAddressWizardRandomPage(addresses)
|
||||
self.setPage(2, page)
|
||||
page = NewAddressWizardPassphrasePage()
|
||||
self.setPage(3, page)
|
||||
page = NewAddressWizardEmailProviderPage()
|
||||
self.setPage(4, page)
|
||||
page = NewAddressWizardEmailAddressPage()
|
||||
self.setPage(5, page)
|
||||
page = NewAddressWizardWaitPage()
|
||||
self.setPage(6, page)
|
||||
page = NewAddressWizardConclusionPage()
|
||||
self.setPage(10, page)
|
||||
|
||||
self.setWindowTitle("New address wizard")
|
||||
self.adjustSize()
|
||||
self.show()
|
||||
|
||||
class NewAddressThread(QtCore.QThread):
|
||||
def __init__(self):
|
||||
QtCore.QThread.__init__(self)
|
||||
self.signal = QtCore.SIGNAL("signal")
|
||||
|
||||
def __del__(self):
|
||||
self.wait()
|
||||
|
||||
def createDeterministic(self):
|
||||
pass
|
||||
|
||||
def createPassphrase(self):
|
||||
pass
|
||||
|
||||
def broadcastAddress(self):
|
||||
pass
|
||||
|
||||
def registerMailchuck(self):
|
||||
pass
|
||||
|
||||
def waitRegistration(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
import time
|
||||
for i in range(1, 101):
|
||||
time.sleep(0.1) # artificial time delay
|
||||
self.emit(self.signal, i)
|
||||
self.emit(self.signal, 101)
|
||||
# self.terminate()
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
import sys
|
||||
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
|
||||
wizard = Ui_NewAddressWizard(["a", "b", "c", "d"])
|
||||
if (wizard.exec_()):
|
||||
print("Email: " + ("yes" if wizard.field("emailAsWell").toBool() else "no"))
|
||||
print("BM: " + ("yes" if wizard.field("onlyBM").toBool() else "no"))
|
||||
else:
|
||||
print("Wizard cancelled")
|
||||
sys.exit()
|
|
@ -3,19 +3,27 @@ src/bitmessageqt/newchandialog.py
|
|||
=================================
|
||||
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
from builtins import *
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
import widgets
|
||||
from . import widgets
|
||||
from addresses import addBMIfNotPresent
|
||||
from addressvalidator import AddressValidator, PassPhraseValidator
|
||||
from queues import (
|
||||
addressGeneratorQueue, apiAddressGeneratorReturnQueue, UISignalQueue)
|
||||
from .addressvalidator import AddressValidator, PassPhraseValidator
|
||||
from queues import UISignalQueue, addressGeneratorQueue, apiAddressGeneratorReturnQueue
|
||||
from .retranslateui import RetranslateMixin
|
||||
from tr import _translate
|
||||
from utils import str_chan
|
||||
from .utils import str_chan
|
||||
|
||||
|
||||
class NewChanDialog(QtGui.QDialog):
|
||||
class NewChanDialog(QtGui.QDialog, RetranslateMixin):
|
||||
"""The `New Chan` dialog"""
|
||||
def __init__(self, parent=None):
|
||||
super(NewChanDialog, self).__init__(parent)
|
||||
|
@ -66,7 +74,7 @@ class NewChanDialog(QtGui.QDialog):
|
|||
addressGeneratorReturnValue = apiAddressGeneratorReturnQueue.get(True)
|
||||
if addressGeneratorReturnValue and addressGeneratorReturnValue[0] != 'chan name does not match address':
|
||||
UISignalQueue.put(('updateStatusBar', _translate(
|
||||
"newchandialog", "Successfully created / joined chan %1").arg(unicode(self.chanPassPhrase.text()))))
|
||||
"newchandialog", "Successfully created / joined chan %1").arg(str(self.chanPassPhrase.text()))))
|
||||
self.parent.ui.tabWidget.setCurrentIndex(
|
||||
self.parent.ui.tabWidget.indexOf(self.parent.ui.chans)
|
||||
)
|
||||
|
|
|
@ -1,13 +1,22 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from builtins import *
|
||||
from builtins import object
|
||||
from os import path
|
||||
from PyQt4 import QtGui
|
||||
from debug import logger
|
||||
import widgets
|
||||
from . import widgets
|
||||
|
||||
class RetranslateMixin(object):
|
||||
def retranslateUi(self):
|
||||
defaults = QtGui.QWidget()
|
||||
widgets.load(self.__class__.__name__.lower() + '.ui', defaults)
|
||||
for attr, value in defaults.__dict__.iteritems():
|
||||
for attr, value in defaults.__dict__.items():
|
||||
setTextMethod = getattr(value, "setText", None)
|
||||
if callable(setTextMethod):
|
||||
getattr(self, attr).setText(getattr(defaults, attr).text())
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
"""Subclass of HTMLParser.HTMLParser for MessageView widget"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
from builtins import *
|
||||
from html.parser import HTMLParser
|
||||
import inspect
|
||||
import re
|
||||
from HTMLParser import HTMLParser
|
||||
|
||||
from urllib import quote_plus
|
||||
from urlparse import urlparse
|
||||
|
||||
from urllib.parse import quote, quote_plus
|
||||
from urllib.parse import urlparse
|
||||
|
||||
class SafeHTMLParser(HTMLParser):
|
||||
"""HTML parser with sanitisation"""
|
||||
# from html5lib.sanitiser
|
||||
acceptable_elements = (
|
||||
'a', 'abbr', 'acronym', 'address', 'area',
|
||||
acceptable_elements = ['a', 'abbr', 'acronym', 'address', 'area',
|
||||
'article', 'aside', 'audio', 'b', 'big', 'blockquote', 'br', 'button',
|
||||
'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup',
|
||||
'command', 'datagrid', 'datalist', 'dd', 'del', 'details', 'dfn',
|
||||
|
@ -24,52 +26,34 @@ class SafeHTMLParser(HTMLParser):
|
|||
'p', 'pre', 'progress', 'q', 's', 'samp', 'section', 'select',
|
||||
'small', 'sound', 'source', 'spacer', 'span', 'strike', 'strong',
|
||||
'sub', 'sup', 'table', 'tbody', 'td', 'textarea', 'time', 'tfoot',
|
||||
'th', 'thead', 'tr', 'tt', 'u', 'ul', 'var', 'video'
|
||||
)
|
||||
replaces_pre = (
|
||||
("&", "&"), ("\"", """), ("<", "<"), (">", ">"))
|
||||
replaces_post = (
|
||||
("\n", "<br/>"), ("\t", " "),
|
||||
(" ", " "), (" ", " "), ("<br/> ", "<br/> "))
|
||||
src_schemes = ["data"]
|
||||
# uriregex1 = re.compile(
|
||||
# r'(?i)\b((?:(https?|ftp|bitcoin):(?:/{1,3}|[a-z0-9%])'
|
||||
# r'|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)'
|
||||
# r'(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))'
|
||||
# r'+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?]))')
|
||||
uriregex1 = re.compile(
|
||||
r'((https?|ftp|bitcoin):(?:/{1,3}|[a-z0-9%])'
|
||||
r'(?:[a-zA-Z]|[0-9]|[$-_@.&+#]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+)'
|
||||
)
|
||||
'th', 'thead', 'tr', 'tt', 'u', 'ul', 'var', 'video']
|
||||
replaces_pre = [["&", "&"], ["\"", """], ["<", "<"], [">", ">"]]
|
||||
replaces_post = [["\n", "<br/>"], ["\t", " "], [" ", " "], [" ", " "], ["<br/> ", "<br/> "]]
|
||||
src_schemes = [ "data" ]
|
||||
#uriregex1 = re.compile(r'(?i)\b((?:(https?|ftp|bitcoin):(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?]))')
|
||||
uriregex1 = re.compile(r'((https?|ftp|bitcoin):(?:/{1,3}|[a-z0-9%])(?:[a-zA-Z]|[0-9]|[$-_@.&+#]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+)')
|
||||
uriregex2 = re.compile(r'<a href="([^"]+)&')
|
||||
emailregex = re.compile(
|
||||
r'\b([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,})\b')
|
||||
emailregex = re.compile(r'\b([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,})\b')
|
||||
|
||||
@staticmethod
|
||||
def replace_pre(text):
|
||||
"""Perform substring replacement before regex replacements"""
|
||||
for a in SafeHTMLParser.replaces_pre:
|
||||
text = text.replace(*a)
|
||||
text = text.replace(a[0], a[1])
|
||||
return text
|
||||
|
||||
@staticmethod
|
||||
def replace_post(text):
|
||||
"""Perform substring replacement after regex replacements"""
|
||||
for a in SafeHTMLParser.replaces_post:
|
||||
text = text.replace(*a)
|
||||
text = text.replace(a[0], a[1])
|
||||
if len(text) > 1 and text[0] == " ":
|
||||
text = " " + text[1:]
|
||||
return text
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
HTMLParser.__init__(self, *args, **kwargs)
|
||||
self.reset()
|
||||
self.reset_safe()
|
||||
self.has_html = None
|
||||
self.allow_picture = None
|
||||
|
||||
def reset_safe(self):
|
||||
"""Reset runtime variables specific to this class"""
|
||||
self.elements = set()
|
||||
self.raw = u""
|
||||
self.sanitised = u""
|
||||
|
@ -77,9 +61,8 @@ class SafeHTMLParser(HTMLParser):
|
|||
self.allow_picture = False
|
||||
self.allow_external_src = False
|
||||
|
||||
def add_if_acceptable(self, tag, attrs=None):
|
||||
"""Add tag if it passes sanitisation"""
|
||||
if tag not in self.acceptable_elements:
|
||||
def add_if_acceptable(self, tag, attrs = None):
|
||||
if tag not in SafeHTMLParser.acceptable_elements:
|
||||
return
|
||||
self.sanitised += "<"
|
||||
if inspect.stack()[1][3] == "handle_endtag":
|
||||
|
@ -91,17 +74,17 @@ class SafeHTMLParser(HTMLParser):
|
|||
val = ""
|
||||
elif attr == "src" and not self.allow_external_src:
|
||||
url = urlparse(val)
|
||||
if url.scheme not in self.src_schemes:
|
||||
if url.scheme not in SafeHTMLParser.src_schemes:
|
||||
val = ""
|
||||
self.sanitised += " " + quote_plus(attr)
|
||||
if val is not None:
|
||||
if not (val is None):
|
||||
self.sanitised += "=\"" + val + "\""
|
||||
if inspect.stack()[1][3] == "handle_startendtag":
|
||||
self.sanitised += "/"
|
||||
self.sanitised += ">"
|
||||
|
||||
def handle_starttag(self, tag, attrs):
|
||||
if tag in self.acceptable_elements:
|
||||
if tag in SafeHTMLParser.acceptable_elements:
|
||||
self.has_html = True
|
||||
self.add_if_acceptable(tag, attrs)
|
||||
|
||||
|
@ -109,7 +92,7 @@ class SafeHTMLParser(HTMLParser):
|
|||
self.add_if_acceptable(tag)
|
||||
|
||||
def handle_startendtag(self, tag, attrs):
|
||||
if tag in self.acceptable_elements:
|
||||
if tag in SafeHTMLParser.acceptable_elements:
|
||||
self.has_html = True
|
||||
self.add_if_acceptable(tag, attrs)
|
||||
|
||||
|
@ -124,19 +107,20 @@ class SafeHTMLParser(HTMLParser):
|
|||
|
||||
def feed(self, data):
|
||||
try:
|
||||
data = unicode(data, 'utf-8')
|
||||
data = str(data, 'utf-8')
|
||||
except UnicodeDecodeError:
|
||||
data = unicode(data, 'utf-8', errors='replace')
|
||||
data = str(data, 'utf-8', errors='replace')
|
||||
HTMLParser.feed(self, data)
|
||||
tmp = SafeHTMLParser.replace_pre(data)
|
||||
tmp = self.uriregex1.sub(r'<a href="\1">\1</a>', tmp)
|
||||
tmp = self.uriregex2.sub(r'<a href="\1&', tmp)
|
||||
tmp = self.emailregex.sub(r'<a href="mailto:\1">\1</a>', tmp)
|
||||
tmp = SafeHTMLParser.uriregex1.sub(
|
||||
r'<a href="\1">\1</a>',
|
||||
tmp)
|
||||
tmp = SafeHTMLParser.uriregex2.sub(r'<a href="\1&', tmp)
|
||||
tmp = SafeHTMLParser.emailregex.sub(r'<a href="mailto:\1">\1</a>', tmp)
|
||||
tmp = SafeHTMLParser.replace_post(tmp)
|
||||
self.raw += tmp
|
||||
|
||||
def is_html(self, text=None, allow_picture=False):
|
||||
"""Detect if string contains HTML tags"""
|
||||
def is_html(self, text = None, allow_picture = False):
|
||||
if text:
|
||||
self.reset()
|
||||
self.reset_safe()
|
||||
|
|
|
@ -1,608 +1,638 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# pylint: disable=too-many-instance-attributes,too-many-locals,too-many-statements,attribute-defined-outside-init
|
||||
"""
|
||||
This module setting file is for settings
|
||||
src/bitmessageqt/settings.py
|
||||
============================
|
||||
|
||||
Form implementation generated from reading ui file 'settings.ui'
|
||||
|
||||
Created: Thu Dec 25 23:21:20 2014
|
||||
by: PyQt4 UI code generator 4.10.3
|
||||
|
||||
WARNING! All changes made in this file will be lost!
|
||||
"""
|
||||
import ConfigParser
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import *
|
||||
from builtins import object
|
||||
from sys import platform
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
import debug
|
||||
import defaults
|
||||
import namecoin
|
||||
import openclpow
|
||||
import paths
|
||||
import queues
|
||||
import state
|
||||
import widgets
|
||||
from bmconfigparser import BMConfigParser
|
||||
from helper_sql import sqlExecute, sqlStoredProcedure
|
||||
from helper_startup import start_proxyconfig
|
||||
from network import knownnodes, AnnounceThread
|
||||
from network.asyncore_pollchoose import set_rates
|
||||
from tr import _translate
|
||||
from . import bitmessage_icons_rc # pylint: disable=unused-import
|
||||
from .languagebox import LanguageBox
|
||||
|
||||
try:
|
||||
_fromUtf8 = QtCore.QString.fromUtf8
|
||||
except AttributeError:
|
||||
def _fromUtf8(s):
|
||||
return s
|
||||
|
||||
try:
|
||||
_encoding = QtGui.QApplication.UnicodeUTF8
|
||||
|
||||
def _translate(context, text, disambig):
|
||||
return QtGui.QApplication.translate(context, text, disambig, _encoding)
|
||||
except AttributeError:
|
||||
def _translate(context, text, disambig):
|
||||
return QtGui.QApplication.translate(context, text, disambig)
|
||||
|
||||
|
||||
def getSOCKSProxyType(config):
|
||||
"""Get user socksproxytype setting from *config*"""
|
||||
try:
|
||||
result = ConfigParser.SafeConfigParser.get(
|
||||
config, 'bitmessagesettings', 'socksproxytype')
|
||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
|
||||
return None
|
||||
else:
|
||||
if result.lower() in ('', 'none', 'false'):
|
||||
result = None
|
||||
return result
|
||||
class Ui_settingsDialog(object):
|
||||
"""Encapsulate a UI settings dialog object"""
|
||||
|
||||
def setupUi(self, settingsDialog):
|
||||
"""Set up the UI"""
|
||||
|
||||
class SettingsDialog(QtGui.QDialog):
|
||||
"""The "Settings" dialog"""
|
||||
def __init__(self, parent=None, firstrun=False):
|
||||
super(SettingsDialog, self).__init__(parent)
|
||||
widgets.load('settings.ui', self)
|
||||
|
||||
self.parent = parent
|
||||
self.firstrun = firstrun
|
||||
self.config = BMConfigParser()
|
||||
self.net_restart_needed = False
|
||||
self.timer = QtCore.QTimer()
|
||||
|
||||
if self.config.safeGetBoolean('bitmessagesettings', 'dontconnect'):
|
||||
self.firstrun = False
|
||||
try:
|
||||
import pkg_resources
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
# Append proxy types defined in plugins
|
||||
for ep in pkg_resources.iter_entry_points(
|
||||
'bitmessage.proxyconfig'):
|
||||
self.comboBoxProxyType.addItem(ep.name)
|
||||
|
||||
settingsDialog.setObjectName(_fromUtf8("settingsDialog"))
|
||||
settingsDialog.resize(521, 413)
|
||||
self.gridLayout = QtGui.QGridLayout(settingsDialog)
|
||||
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
|
||||
self.buttonBox = QtGui.QDialogButtonBox(settingsDialog)
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok)
|
||||
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
|
||||
self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1)
|
||||
self.tabWidgetSettings = QtGui.QTabWidget(settingsDialog)
|
||||
self.tabWidgetSettings.setObjectName(_fromUtf8("tabWidgetSettings"))
|
||||
self.tabUserInterface = QtGui.QWidget()
|
||||
self.tabUserInterface.setEnabled(True)
|
||||
self.tabUserInterface.setObjectName(_fromUtf8("tabUserInterface"))
|
||||
self.formLayout = QtGui.QFormLayout(self.tabUserInterface)
|
||||
self.formLayout.setObjectName(_fromUtf8("formLayout"))
|
||||
self.checkBoxStartOnLogon = QtGui.QCheckBox(self.tabUserInterface)
|
||||
self.checkBoxStartOnLogon.setObjectName(_fromUtf8("checkBoxStartOnLogon"))
|
||||
self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.checkBoxStartOnLogon)
|
||||
self.groupBoxTray = QtGui.QGroupBox(self.tabUserInterface)
|
||||
self.groupBoxTray.setObjectName(_fromUtf8("groupBoxTray"))
|
||||
self.formLayoutTray = QtGui.QFormLayout(self.groupBoxTray)
|
||||
self.formLayoutTray.setObjectName(_fromUtf8("formLayoutTray"))
|
||||
self.checkBoxStartInTray = QtGui.QCheckBox(self.groupBoxTray)
|
||||
self.checkBoxStartInTray.setObjectName(_fromUtf8("checkBoxStartInTray"))
|
||||
self.formLayoutTray.setWidget(0, QtGui.QFormLayout.SpanningRole, self.checkBoxStartInTray)
|
||||
self.checkBoxMinimizeToTray = QtGui.QCheckBox(self.groupBoxTray)
|
||||
self.checkBoxMinimizeToTray.setChecked(True)
|
||||
self.checkBoxMinimizeToTray.setObjectName(_fromUtf8("checkBoxMinimizeToTray"))
|
||||
self.formLayoutTray.setWidget(1, QtGui.QFormLayout.LabelRole, self.checkBoxMinimizeToTray)
|
||||
self.checkBoxTrayOnClose = QtGui.QCheckBox(self.groupBoxTray)
|
||||
self.checkBoxTrayOnClose.setChecked(True)
|
||||
self.checkBoxTrayOnClose.setObjectName(_fromUtf8("checkBoxTrayOnClose"))
|
||||
self.formLayoutTray.setWidget(2, QtGui.QFormLayout.LabelRole, self.checkBoxTrayOnClose)
|
||||
self.formLayout.setWidget(1, QtGui.QFormLayout.SpanningRole, self.groupBoxTray)
|
||||
self.checkBoxHideTrayConnectionNotifications = QtGui.QCheckBox(self.tabUserInterface)
|
||||
self.checkBoxHideTrayConnectionNotifications.setChecked(False)
|
||||
self.checkBoxHideTrayConnectionNotifications.setObjectName(
|
||||
_fromUtf8("checkBoxHideTrayConnectionNotifications"))
|
||||
self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.checkBoxHideTrayConnectionNotifications)
|
||||
self.checkBoxShowTrayNotifications = QtGui.QCheckBox(self.tabUserInterface)
|
||||
self.checkBoxShowTrayNotifications.setObjectName(_fromUtf8("checkBoxShowTrayNotifications"))
|
||||
self.formLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.checkBoxShowTrayNotifications)
|
||||
self.checkBoxPortableMode = QtGui.QCheckBox(self.tabUserInterface)
|
||||
self.checkBoxPortableMode.setObjectName(_fromUtf8("checkBoxPortableMode"))
|
||||
self.formLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.checkBoxPortableMode)
|
||||
self.PortableModeDescription = QtGui.QLabel(self.tabUserInterface)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.PortableModeDescription.sizePolicy().hasHeightForWidth())
|
||||
self.PortableModeDescription.setSizePolicy(sizePolicy)
|
||||
self.PortableModeDescription.setWordWrap(True)
|
||||
self.PortableModeDescription.setObjectName(_fromUtf8("PortableModeDescription"))
|
||||
self.formLayout.setWidget(5, QtGui.QFormLayout.SpanningRole, self.PortableModeDescription)
|
||||
self.checkBoxWillinglySendToMobile = QtGui.QCheckBox(self.tabUserInterface)
|
||||
self.checkBoxWillinglySendToMobile.setObjectName(_fromUtf8("checkBoxWillinglySendToMobile"))
|
||||
self.formLayout.setWidget(6, QtGui.QFormLayout.SpanningRole, self.checkBoxWillinglySendToMobile)
|
||||
self.checkBoxUseIdenticons = QtGui.QCheckBox(self.tabUserInterface)
|
||||
self.checkBoxUseIdenticons.setObjectName(_fromUtf8("checkBoxUseIdenticons"))
|
||||
self.formLayout.setWidget(7, QtGui.QFormLayout.LabelRole, self.checkBoxUseIdenticons)
|
||||
self.checkBoxReplyBelow = QtGui.QCheckBox(self.tabUserInterface)
|
||||
self.checkBoxReplyBelow.setObjectName(_fromUtf8("checkBoxReplyBelow"))
|
||||
self.formLayout.setWidget(8, QtGui.QFormLayout.LabelRole, self.checkBoxReplyBelow)
|
||||
self.groupBox = QtGui.QGroupBox(self.tabUserInterface)
|
||||
self.groupBox.setObjectName(_fromUtf8("groupBox"))
|
||||
self.formLayout_2 = QtGui.QFormLayout(self.groupBox)
|
||||
self.formLayout_2.setObjectName(_fromUtf8("formLayout_2"))
|
||||
self.languageComboBox = LanguageBox(self.groupBox)
|
||||
self.languageComboBox.setMinimumSize(QtCore.QSize(100, 0))
|
||||
self.languageComboBox.setObjectName(_fromUtf8("languageComboBox")) # pylint: disable=not-callable
|
||||
self.formLayout_2.setWidget(0, QtGui.QFormLayout.LabelRole, self.languageComboBox)
|
||||
self.formLayout.setWidget(9, QtGui.QFormLayout.FieldRole, self.groupBox)
|
||||
self.tabWidgetSettings.addTab(self.tabUserInterface, _fromUtf8(""))
|
||||
self.tabNetworkSettings = QtGui.QWidget()
|
||||
self.tabNetworkSettings.setObjectName(_fromUtf8("tabNetworkSettings"))
|
||||
self.gridLayout_4 = QtGui.QGridLayout(self.tabNetworkSettings)
|
||||
self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4"))
|
||||
self.groupBox1 = QtGui.QGroupBox(self.tabNetworkSettings)
|
||||
self.groupBox1.setObjectName(_fromUtf8("groupBox1"))
|
||||
self.gridLayout_3 = QtGui.QGridLayout(self.groupBox1)
|
||||
self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3"))
|
||||
self.label = QtGui.QLabel(self.groupBox1)
|
||||
self.label.setObjectName(_fromUtf8("label"))
|
||||
self.gridLayout_3.addWidget(self.label, 0, 0, 1, 1, QtCore.Qt.AlignRight)
|
||||
self.lineEditTCPPort = QtGui.QLineEdit(self.groupBox1)
|
||||
self.lineEditTCPPort.setMaximumSize(QtCore.QSize(70, 16777215))
|
||||
self.lineEditTCPPort.setObjectName(_fromUtf8("lineEditTCPPort"))
|
||||
self.gridLayout_3.addWidget(self.lineEditTCPPort, 0, 1, 1, 1, QtCore.Qt.AlignLeft)
|
||||
self.labelUPnP = QtGui.QLabel(self.groupBox1)
|
||||
self.labelUPnP.setObjectName(_fromUtf8("labelUPnP"))
|
||||
self.gridLayout_3.addWidget(self.labelUPnP, 0, 2, 1, 1, QtCore.Qt.AlignRight)
|
||||
self.checkBoxUPnP = QtGui.QCheckBox(self.groupBox1)
|
||||
self.checkBoxUPnP.setObjectName(_fromUtf8("checkBoxUPnP"))
|
||||
self.gridLayout_3.addWidget(self.checkBoxUPnP, 0, 3, 1, 1, QtCore.Qt.AlignLeft)
|
||||
self.gridLayout_4.addWidget(self.groupBox1, 0, 0, 1, 1)
|
||||
self.groupBox_3 = QtGui.QGroupBox(self.tabNetworkSettings)
|
||||
self.groupBox_3.setObjectName(_fromUtf8("groupBox_3"))
|
||||
self.gridLayout_9 = QtGui.QGridLayout(self.groupBox_3)
|
||||
self.gridLayout_9.setObjectName(_fromUtf8("gridLayout_9"))
|
||||
spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_9.addItem(spacerItem1, 0, 0, 2, 1)
|
||||
self.label_24 = QtGui.QLabel(self.groupBox_3)
|
||||
self.label_24.setObjectName(_fromUtf8("label_24"))
|
||||
self.gridLayout_9.addWidget(self.label_24, 0, 1, 1, 1)
|
||||
self.lineEditMaxDownloadRate = QtGui.QLineEdit(self.groupBox_3)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.lineEditMaxDownloadRate.sizePolicy().hasHeightForWidth())
|
||||
self.lineEditMaxDownloadRate.setSizePolicy(sizePolicy)
|
||||
self.lineEditMaxDownloadRate.setMaximumSize(QtCore.QSize(60, 16777215))
|
||||
self.lineEditMaxDownloadRate.setObjectName(_fromUtf8("lineEditMaxDownloadRate"))
|
||||
self.gridLayout_9.addWidget(self.lineEditMaxDownloadRate, 0, 2, 1, 1)
|
||||
self.label_25 = QtGui.QLabel(self.groupBox_3)
|
||||
self.label_25.setObjectName(_fromUtf8("label_25"))
|
||||
self.gridLayout_9.addWidget(self.label_25, 1, 1, 1, 1)
|
||||
self.lineEditMaxUploadRate = QtGui.QLineEdit(self.groupBox_3)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.lineEditMaxUploadRate.sizePolicy().hasHeightForWidth())
|
||||
self.lineEditMaxUploadRate.setSizePolicy(sizePolicy)
|
||||
self.lineEditMaxUploadRate.setMaximumSize(QtCore.QSize(60, 16777215))
|
||||
self.lineEditMaxUploadRate.setObjectName(_fromUtf8("lineEditMaxUploadRate"))
|
||||
self.gridLayout_9.addWidget(self.lineEditMaxUploadRate, 1, 2, 1, 1)
|
||||
self.label_26 = QtGui.QLabel(self.groupBox_3)
|
||||
self.label_26.setObjectName(_fromUtf8("label_26"))
|
||||
self.gridLayout_9.addWidget(self.label_26, 2, 1, 1, 1)
|
||||
self.lineEditMaxOutboundConnections = QtGui.QLineEdit(self.groupBox_3)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.lineEditMaxOutboundConnections.sizePolicy().hasHeightForWidth())
|
||||
self.lineEditMaxOutboundConnections.setSizePolicy(sizePolicy)
|
||||
self.lineEditMaxOutboundConnections.setMaximumSize(QtCore.QSize(60, 16777215))
|
||||
self.lineEditMaxOutboundConnections.setObjectName(_fromUtf8("lineEditMaxOutboundConnections"))
|
||||
self.lineEditMaxOutboundConnections.setValidator(
|
||||
QtGui.QIntValidator(0, 8, self.lineEditMaxOutboundConnections))
|
||||
|
||||
self.adjust_from_config(self.config)
|
||||
if firstrun:
|
||||
# switch to "Network Settings" tab if user selected
|
||||
# "Let me configure special network settings first" on first run
|
||||
self.tabWidgetSettings.setCurrentIndex(
|
||||
self.tabWidgetSettings.indexOf(self.tabNetworkSettings)
|
||||
)
|
||||
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
|
||||
|
||||
def adjust_from_config(self, config):
|
||||
"""Adjust all widgets state according to config settings"""
|
||||
# pylint: disable=too-many-branches,too-many-statements
|
||||
if not self.parent.tray.isSystemTrayAvailable():
|
||||
self.groupBoxTray.setEnabled(False)
|
||||
self.groupBoxTray.setTitle(_translate(
|
||||
"MainWindow", "Tray (not available in your system)"))
|
||||
for setting in (
|
||||
'minimizetotray', 'trayonclose', 'startintray'):
|
||||
config.set('bitmessagesettings', setting, 'false')
|
||||
self.gridLayout_9.addWidget(self.lineEditMaxOutboundConnections, 2, 2, 1, 1)
|
||||
self.gridLayout_4.addWidget(self.groupBox_3, 2, 0, 1, 1)
|
||||
self.groupBox_2 = QtGui.QGroupBox(self.tabNetworkSettings)
|
||||
self.groupBox_2.setObjectName(_fromUtf8("groupBox_2"))
|
||||
self.gridLayout_2 = QtGui.QGridLayout(self.groupBox_2)
|
||||
self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
|
||||
self.label_2 = QtGui.QLabel(self.groupBox_2)
|
||||
self.label_2.setObjectName(_fromUtf8("label_2"))
|
||||
self.gridLayout_2.addWidget(self.label_2, 0, 0, 1, 1)
|
||||
self.label_3 = QtGui.QLabel(self.groupBox_2)
|
||||
self.label_3.setObjectName(_fromUtf8("label_3"))
|
||||
self.gridLayout_2.addWidget(self.label_3, 1, 1, 1, 1)
|
||||
self.lineEditSocksHostname = QtGui.QLineEdit(self.groupBox_2)
|
||||
self.lineEditSocksHostname.setObjectName(_fromUtf8("lineEditSocksHostname"))
|
||||
self.lineEditSocksHostname.setPlaceholderText(_fromUtf8("127.0.0.1"))
|
||||
self.gridLayout_2.addWidget(self.lineEditSocksHostname, 1, 2, 1, 2)
|
||||
self.label_4 = QtGui.QLabel(self.groupBox_2)
|
||||
self.label_4.setObjectName(_fromUtf8("label_4"))
|
||||
self.gridLayout_2.addWidget(self.label_4, 1, 4, 1, 1)
|
||||
self.lineEditSocksPort = QtGui.QLineEdit(self.groupBox_2)
|
||||
self.lineEditSocksPort.setObjectName(_fromUtf8("lineEditSocksPort"))
|
||||
if platform in ['darwin', 'win32', 'win64']:
|
||||
self.lineEditSocksPort.setPlaceholderText(_fromUtf8("9150"))
|
||||
else:
|
||||
self.checkBoxMinimizeToTray.setChecked(
|
||||
config.getboolean('bitmessagesettings', 'minimizetotray'))
|
||||
self.checkBoxTrayOnClose.setChecked(
|
||||
config.safeGetBoolean('bitmessagesettings', 'trayonclose'))
|
||||
self.checkBoxStartInTray.setChecked(
|
||||
config.getboolean('bitmessagesettings', 'startintray'))
|
||||
|
||||
self.checkBoxHideTrayConnectionNotifications.setChecked(
|
||||
config.getboolean(
|
||||
'bitmessagesettings', 'hidetrayconnectionnotifications'))
|
||||
self.checkBoxShowTrayNotifications.setChecked(
|
||||
config.getboolean('bitmessagesettings', 'showtraynotifications'))
|
||||
|
||||
self.checkBoxStartOnLogon.setChecked(
|
||||
config.getboolean('bitmessagesettings', 'startonlogon'))
|
||||
|
||||
self.checkBoxWillinglySendToMobile.setChecked(
|
||||
config.safeGetBoolean(
|
||||
'bitmessagesettings', 'willinglysendtomobile'))
|
||||
self.checkBoxUseIdenticons.setChecked(
|
||||
config.safeGetBoolean('bitmessagesettings', 'useidenticons'))
|
||||
self.checkBoxReplyBelow.setChecked(
|
||||
config.safeGetBoolean('bitmessagesettings', 'replybelow'))
|
||||
|
||||
if state.appdata == paths.lookupExeFolder():
|
||||
self.checkBoxPortableMode.setChecked(True)
|
||||
else:
|
||||
try:
|
||||
tempfile.NamedTemporaryFile(
|
||||
dir=paths.lookupExeFolder(), delete=True
|
||||
).close() # should autodelete
|
||||
except Exception:
|
||||
self.checkBoxPortableMode.setDisabled(True)
|
||||
|
||||
if 'darwin' in sys.platform:
|
||||
self.checkBoxMinimizeToTray.setDisabled(True)
|
||||
self.checkBoxMinimizeToTray.setText(_translate(
|
||||
"MainWindow",
|
||||
"Minimize-to-tray not yet supported on your OS."))
|
||||
self.checkBoxShowTrayNotifications.setDisabled(True)
|
||||
self.checkBoxShowTrayNotifications.setText(_translate(
|
||||
"MainWindow",
|
||||
"Tray notifications not yet supported on your OS."))
|
||||
|
||||
if 'win' not in sys.platform and not self.parent.desktop:
|
||||
self.checkBoxStartOnLogon.setDisabled(True)
|
||||
self.checkBoxStartOnLogon.setText(_translate(
|
||||
"MainWindow", "Start-on-login not yet supported on your OS."))
|
||||
|
||||
# On the Network settings tab:
|
||||
self.lineEditTCPPort.setText(str(
|
||||
config.get('bitmessagesettings', 'port')))
|
||||
self.checkBoxUPnP.setChecked(
|
||||
config.safeGetBoolean('bitmessagesettings', 'upnp'))
|
||||
self.checkBoxUDP.setChecked(
|
||||
config.safeGetBoolean('bitmessagesettings', 'udp'))
|
||||
self.checkBoxAuthentication.setChecked(
|
||||
config.getboolean('bitmessagesettings', 'socksauthentication'))
|
||||
self.checkBoxSocksListen.setChecked(
|
||||
config.getboolean('bitmessagesettings', 'sockslisten'))
|
||||
self.checkBoxOnionOnly.setChecked(
|
||||
config.safeGetBoolean('bitmessagesettings', 'onionservicesonly'))
|
||||
|
||||
self._proxy_type = getSOCKSProxyType(config)
|
||||
self.comboBoxProxyType.setCurrentIndex(
|
||||
0 if not self._proxy_type
|
||||
else self.comboBoxProxyType.findText(self._proxy_type))
|
||||
self.comboBoxProxyTypeChanged(self.comboBoxProxyType.currentIndex())
|
||||
|
||||
self.lineEditSocksHostname.setText(
|
||||
config.get('bitmessagesettings', 'sockshostname'))
|
||||
self.lineEditSocksPort.setText(str(
|
||||
config.get('bitmessagesettings', 'socksport')))
|
||||
self.lineEditSocksUsername.setText(
|
||||
config.get('bitmessagesettings', 'socksusername'))
|
||||
self.lineEditSocksPassword.setText(
|
||||
config.get('bitmessagesettings', 'sockspassword'))
|
||||
|
||||
self.lineEditMaxDownloadRate.setText(str(
|
||||
config.get('bitmessagesettings', 'maxdownloadrate')))
|
||||
self.lineEditMaxUploadRate.setText(str(
|
||||
config.get('bitmessagesettings', 'maxuploadrate')))
|
||||
self.lineEditMaxOutboundConnections.setText(str(
|
||||
config.get('bitmessagesettings', 'maxoutboundconnections')))
|
||||
|
||||
# Demanded difficulty tab
|
||||
self.lineEditTotalDifficulty.setText(str((float(
|
||||
config.getint(
|
||||
'bitmessagesettings', 'defaultnoncetrialsperbyte')
|
||||
) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
||||
self.lineEditSmallMessageDifficulty.setText(str((float(
|
||||
config.getint(
|
||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
||||
) / defaults.networkDefaultPayloadLengthExtraBytes)))
|
||||
|
||||
# Max acceptable difficulty tab
|
||||
self.lineEditMaxAcceptableTotalDifficulty.setText(str((float(
|
||||
config.getint(
|
||||
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte')
|
||||
) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
||||
self.lineEditMaxAcceptableSmallMessageDifficulty.setText(str((float(
|
||||
config.getint(
|
||||
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes')
|
||||
) / defaults.networkDefaultPayloadLengthExtraBytes)))
|
||||
|
||||
# OpenCL
|
||||
self.comboBoxOpenCL.setEnabled(openclpow.openclAvailable())
|
||||
self.comboBoxOpenCL.clear()
|
||||
self.comboBoxOpenCL.addItem("None")
|
||||
self.comboBoxOpenCL.addItems(openclpow.vendors)
|
||||
self.comboBoxOpenCL.setCurrentIndex(0)
|
||||
for i in range(self.comboBoxOpenCL.count()):
|
||||
if self.comboBoxOpenCL.itemText(i) == config.safeGet(
|
||||
'bitmessagesettings', 'opencl'):
|
||||
self.comboBoxOpenCL.setCurrentIndex(i)
|
||||
break
|
||||
|
||||
# Namecoin integration tab
|
||||
nmctype = config.get('bitmessagesettings', 'namecoinrpctype')
|
||||
self.lineEditNamecoinHost.setText(
|
||||
config.get('bitmessagesettings', 'namecoinrpchost'))
|
||||
self.lineEditNamecoinPort.setText(str(
|
||||
config.get('bitmessagesettings', 'namecoinrpcport')))
|
||||
self.lineEditNamecoinUser.setText(
|
||||
config.get('bitmessagesettings', 'namecoinrpcuser'))
|
||||
self.lineEditNamecoinPassword.setText(
|
||||
config.get('bitmessagesettings', 'namecoinrpcpassword'))
|
||||
|
||||
if nmctype == "namecoind":
|
||||
self.radioButtonNamecoinNamecoind.setChecked(True)
|
||||
elif nmctype == "nmcontrol":
|
||||
self.radioButtonNamecoinNmcontrol.setChecked(True)
|
||||
self.lineEditNamecoinUser.setEnabled(False)
|
||||
self.labelNamecoinUser.setEnabled(False)
|
||||
self.lineEditNamecoinPassword.setEnabled(False)
|
||||
self.labelNamecoinPassword.setEnabled(False)
|
||||
else:
|
||||
assert False
|
||||
|
||||
# Message Resend tab
|
||||
self.lineEditDays.setText(str(
|
||||
config.get('bitmessagesettings', 'stopresendingafterxdays')))
|
||||
self.lineEditMonths.setText(str(
|
||||
config.get('bitmessagesettings', 'stopresendingafterxmonths')))
|
||||
|
||||
def comboBoxProxyTypeChanged(self, comboBoxIndex):
|
||||
"""A callback for currentIndexChanged event of comboBoxProxyType"""
|
||||
if comboBoxIndex == 0:
|
||||
self.lineEditSocksHostname.setEnabled(False)
|
||||
self.lineEditSocksPort.setEnabled(False)
|
||||
self.lineEditSocksPort.setPlaceholderText(_fromUtf8("9050"))
|
||||
self.gridLayout_2.addWidget(self.lineEditSocksPort, 1, 5, 1, 1)
|
||||
self.checkBoxAuthentication = QtGui.QCheckBox(self.groupBox_2)
|
||||
self.checkBoxAuthentication.setObjectName(_fromUtf8("checkBoxAuthentication"))
|
||||
self.gridLayout_2.addWidget(self.checkBoxAuthentication, 2, 1, 1, 1)
|
||||
self.label_5 = QtGui.QLabel(self.groupBox_2)
|
||||
self.label_5.setObjectName(_fromUtf8("label_5"))
|
||||
self.gridLayout_2.addWidget(self.label_5, 2, 2, 1, 1)
|
||||
self.lineEditSocksUsername = QtGui.QLineEdit(self.groupBox_2)
|
||||
self.lineEditSocksUsername.setEnabled(False)
|
||||
self.lineEditSocksUsername.setObjectName(_fromUtf8("lineEditSocksUsername"))
|
||||
self.gridLayout_2.addWidget(self.lineEditSocksUsername, 2, 3, 1, 1)
|
||||
self.label_6 = QtGui.QLabel(self.groupBox_2)
|
||||
self.label_6.setObjectName(_fromUtf8("label_6"))
|
||||
self.gridLayout_2.addWidget(self.label_6, 2, 4, 1, 1)
|
||||
self.lineEditSocksPassword = QtGui.QLineEdit(self.groupBox_2)
|
||||
self.lineEditSocksPassword.setEnabled(False)
|
||||
self.checkBoxAuthentication.setEnabled(False)
|
||||
self.checkBoxSocksListen.setEnabled(False)
|
||||
self.checkBoxOnionOnly.setEnabled(False)
|
||||
else:
|
||||
self.lineEditSocksHostname.setEnabled(True)
|
||||
self.lineEditSocksPort.setEnabled(True)
|
||||
self.checkBoxAuthentication.setEnabled(True)
|
||||
self.checkBoxSocksListen.setEnabled(True)
|
||||
self.checkBoxOnionOnly.setEnabled(True)
|
||||
if self.checkBoxAuthentication.isChecked():
|
||||
self.lineEditSocksUsername.setEnabled(True)
|
||||
self.lineEditSocksPassword.setEnabled(True)
|
||||
self.lineEditSocksPassword.setInputMethodHints(
|
||||
QtCore.Qt.ImhHiddenText | QtCore.Qt.ImhNoAutoUppercase | QtCore.Qt.ImhNoPredictiveText)
|
||||
self.lineEditSocksPassword.setEchoMode(QtGui.QLineEdit.Password)
|
||||
self.lineEditSocksPassword.setObjectName(_fromUtf8("lineEditSocksPassword"))
|
||||
self.gridLayout_2.addWidget(self.lineEditSocksPassword, 2, 5, 1, 1)
|
||||
self.checkBoxSocksListen = QtGui.QCheckBox(self.groupBox_2)
|
||||
self.checkBoxSocksListen.setObjectName(_fromUtf8("checkBoxSocksListen"))
|
||||
self.gridLayout_2.addWidget(self.checkBoxSocksListen, 3, 1, 1, 4)
|
||||
self.comboBoxProxyType = QtGui.QComboBox(self.groupBox_2)
|
||||
self.comboBoxProxyType.setObjectName(_fromUtf8("comboBoxProxyType")) # pylint: disable=not-callable
|
||||
self.comboBoxProxyType.addItem(_fromUtf8(""))
|
||||
self.comboBoxProxyType.addItem(_fromUtf8(""))
|
||||
self.comboBoxProxyType.addItem(_fromUtf8(""))
|
||||
self.gridLayout_2.addWidget(self.comboBoxProxyType, 0, 1, 1, 1)
|
||||
self.gridLayout_4.addWidget(self.groupBox_2, 1, 0, 1, 1)
|
||||
spacerItem2 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
self.gridLayout_4.addItem(spacerItem2, 3, 0, 1, 1)
|
||||
self.tabWidgetSettings.addTab(self.tabNetworkSettings, _fromUtf8(""))
|
||||
self.tabDemandedDifficulty = QtGui.QWidget()
|
||||
self.tabDemandedDifficulty.setObjectName(_fromUtf8("tabDemandedDifficulty"))
|
||||
self.gridLayout_6 = QtGui.QGridLayout(self.tabDemandedDifficulty)
|
||||
self.gridLayout_6.setObjectName(_fromUtf8("gridLayout_6"))
|
||||
self.label_9 = QtGui.QLabel(self.tabDemandedDifficulty)
|
||||
self.label_9.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
|
||||
self.label_9.setObjectName(_fromUtf8("label_9"))
|
||||
self.gridLayout_6.addWidget(self.label_9, 1, 1, 1, 1)
|
||||
self.label_10 = QtGui.QLabel(self.tabDemandedDifficulty)
|
||||
self.label_10.setWordWrap(True)
|
||||
self.label_10.setObjectName(_fromUtf8("label_10"))
|
||||
self.gridLayout_6.addWidget(self.label_10, 2, 0, 1, 3)
|
||||
self.label_11 = QtGui.QLabel(self.tabDemandedDifficulty)
|
||||
self.label_11.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
|
||||
self.label_11.setObjectName(_fromUtf8("label_11"))
|
||||
self.gridLayout_6.addWidget(self.label_11, 3, 1, 1, 1)
|
||||
self.label_8 = QtGui.QLabel(self.tabDemandedDifficulty)
|
||||
self.label_8.setWordWrap(True)
|
||||
self.label_8.setObjectName(_fromUtf8("label_8"))
|
||||
self.gridLayout_6.addWidget(self.label_8, 0, 0, 1, 3)
|
||||
spacerItem3 = QtGui.QSpacerItem(203, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_6.addItem(spacerItem3, 1, 0, 1, 1)
|
||||
self.label_12 = QtGui.QLabel(self.tabDemandedDifficulty)
|
||||
self.label_12.setWordWrap(True)
|
||||
self.label_12.setObjectName(_fromUtf8("label_12"))
|
||||
self.gridLayout_6.addWidget(self.label_12, 4, 0, 1, 3)
|
||||
self.lineEditSmallMessageDifficulty = QtGui.QLineEdit(self.tabDemandedDifficulty)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.lineEditSmallMessageDifficulty.sizePolicy().hasHeightForWidth())
|
||||
self.lineEditSmallMessageDifficulty.setSizePolicy(sizePolicy)
|
||||
self.lineEditSmallMessageDifficulty.setMaximumSize(QtCore.QSize(70, 16777215))
|
||||
self.lineEditSmallMessageDifficulty.setObjectName(_fromUtf8("lineEditSmallMessageDifficulty"))
|
||||
self.gridLayout_6.addWidget(self.lineEditSmallMessageDifficulty, 3, 2, 1, 1)
|
||||
self.lineEditTotalDifficulty = QtGui.QLineEdit(self.tabDemandedDifficulty)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.lineEditTotalDifficulty.sizePolicy().hasHeightForWidth())
|
||||
self.lineEditTotalDifficulty.setSizePolicy(sizePolicy)
|
||||
self.lineEditTotalDifficulty.setMaximumSize(QtCore.QSize(70, 16777215))
|
||||
self.lineEditTotalDifficulty.setObjectName(_fromUtf8("lineEditTotalDifficulty"))
|
||||
self.gridLayout_6.addWidget(self.lineEditTotalDifficulty, 1, 2, 1, 1)
|
||||
spacerItem4 = QtGui.QSpacerItem(203, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_6.addItem(spacerItem4, 3, 0, 1, 1)
|
||||
spacerItem5 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
self.gridLayout_6.addItem(spacerItem5, 5, 0, 1, 1)
|
||||
self.tabWidgetSettings.addTab(self.tabDemandedDifficulty, _fromUtf8(""))
|
||||
self.tabMaxAcceptableDifficulty = QtGui.QWidget()
|
||||
self.tabMaxAcceptableDifficulty.setObjectName(_fromUtf8("tabMaxAcceptableDifficulty"))
|
||||
self.gridLayout_7 = QtGui.QGridLayout(self.tabMaxAcceptableDifficulty)
|
||||
self.gridLayout_7.setObjectName(_fromUtf8("gridLayout_7"))
|
||||
self.label_15 = QtGui.QLabel(self.tabMaxAcceptableDifficulty)
|
||||
self.label_15.setWordWrap(True)
|
||||
self.label_15.setObjectName(_fromUtf8("label_15"))
|
||||
self.gridLayout_7.addWidget(self.label_15, 0, 0, 1, 3)
|
||||
spacerItem6 = QtGui.QSpacerItem(102, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_7.addItem(spacerItem6, 1, 0, 1, 1)
|
||||
self.label_13 = QtGui.QLabel(self.tabMaxAcceptableDifficulty)
|
||||
self.label_13.setLayoutDirection(QtCore.Qt.LeftToRight)
|
||||
self.label_13.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
|
||||
self.label_13.setObjectName(_fromUtf8("label_13"))
|
||||
self.gridLayout_7.addWidget(self.label_13, 1, 1, 1, 1)
|
||||
self.lineEditMaxAcceptableTotalDifficulty = QtGui.QLineEdit(self.tabMaxAcceptableDifficulty)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.lineEditMaxAcceptableTotalDifficulty.sizePolicy().hasHeightForWidth())
|
||||
self.lineEditMaxAcceptableTotalDifficulty.setSizePolicy(sizePolicy)
|
||||
self.lineEditMaxAcceptableTotalDifficulty.setMaximumSize(QtCore.QSize(70, 16777215))
|
||||
self.lineEditMaxAcceptableTotalDifficulty.setObjectName(_fromUtf8("lineEditMaxAcceptableTotalDifficulty"))
|
||||
self.gridLayout_7.addWidget(self.lineEditMaxAcceptableTotalDifficulty, 1, 2, 1, 1)
|
||||
spacerItem7 = QtGui.QSpacerItem(102, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_7.addItem(spacerItem7, 2, 0, 1, 1)
|
||||
self.label_14 = QtGui.QLabel(self.tabMaxAcceptableDifficulty)
|
||||
self.label_14.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
|
||||
self.label_14.setObjectName(_fromUtf8("label_14"))
|
||||
self.gridLayout_7.addWidget(self.label_14, 2, 1, 1, 1)
|
||||
self.lineEditMaxAcceptableSmallMessageDifficulty = QtGui.QLineEdit(self.tabMaxAcceptableDifficulty)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.lineEditMaxAcceptableSmallMessageDifficulty.sizePolicy().hasHeightForWidth())
|
||||
self.lineEditMaxAcceptableSmallMessageDifficulty.setSizePolicy(sizePolicy)
|
||||
self.lineEditMaxAcceptableSmallMessageDifficulty.setMaximumSize(QtCore.QSize(70, 16777215))
|
||||
self.lineEditMaxAcceptableSmallMessageDifficulty.setObjectName(
|
||||
_fromUtf8("lineEditMaxAcceptableSmallMessageDifficulty"))
|
||||
self.gridLayout_7.addWidget(self.lineEditMaxAcceptableSmallMessageDifficulty, 2, 2, 1, 1)
|
||||
spacerItem8 = QtGui.QSpacerItem(20, 147, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
self.gridLayout_7.addItem(spacerItem8, 3, 1, 1, 1)
|
||||
self.labelOpenCL = QtGui.QLabel(self.tabMaxAcceptableDifficulty)
|
||||
self.labelOpenCL.setObjectName(_fromUtf8("labelOpenCL"))
|
||||
self.gridLayout_7.addWidget(self.labelOpenCL, 4, 0, 1, 1)
|
||||
self.comboBoxOpenCL = QtGui.QComboBox(self.tabMaxAcceptableDifficulty)
|
||||
self.comboBoxOpenCL.setObjectName = (_fromUtf8("comboBoxOpenCL"))
|
||||
self.gridLayout_7.addWidget(self.comboBoxOpenCL, 4, 1, 1, 1)
|
||||
self.tabWidgetSettings.addTab(self.tabMaxAcceptableDifficulty, _fromUtf8(""))
|
||||
self.tabNamecoin = QtGui.QWidget()
|
||||
self.tabNamecoin.setObjectName(_fromUtf8("tabNamecoin"))
|
||||
self.gridLayout_8 = QtGui.QGridLayout(self.tabNamecoin)
|
||||
self.gridLayout_8.setObjectName(_fromUtf8("gridLayout_8"))
|
||||
spacerItem9 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_8.addItem(spacerItem9, 2, 0, 1, 1)
|
||||
self.label_16 = QtGui.QLabel(self.tabNamecoin)
|
||||
self.label_16.setWordWrap(True)
|
||||
self.label_16.setObjectName(_fromUtf8("label_16"))
|
||||
self.gridLayout_8.addWidget(self.label_16, 0, 0, 1, 3)
|
||||
self.label_17 = QtGui.QLabel(self.tabNamecoin)
|
||||
self.label_17.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
|
||||
self.label_17.setObjectName(_fromUtf8("label_17"))
|
||||
self.gridLayout_8.addWidget(self.label_17, 2, 1, 1, 1)
|
||||
self.lineEditNamecoinHost = QtGui.QLineEdit(self.tabNamecoin)
|
||||
self.lineEditNamecoinHost.setObjectName(_fromUtf8("lineEditNamecoinHost"))
|
||||
self.gridLayout_8.addWidget(self.lineEditNamecoinHost, 2, 2, 1, 1)
|
||||
spacerItem10 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_8.addItem(spacerItem10, 3, 0, 1, 1)
|
||||
spacerItem11 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_8.addItem(spacerItem11, 4, 0, 1, 1)
|
||||
self.label_18 = QtGui.QLabel(self.tabNamecoin)
|
||||
self.label_18.setEnabled(True)
|
||||
self.label_18.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
|
||||
self.label_18.setObjectName(_fromUtf8("label_18"))
|
||||
self.gridLayout_8.addWidget(self.label_18, 3, 1, 1, 1)
|
||||
self.lineEditNamecoinPort = QtGui.QLineEdit(self.tabNamecoin)
|
||||
self.lineEditNamecoinPort.setObjectName(_fromUtf8("lineEditNamecoinPort"))
|
||||
self.gridLayout_8.addWidget(self.lineEditNamecoinPort, 3, 2, 1, 1)
|
||||
spacerItem12 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
self.gridLayout_8.addItem(spacerItem12, 8, 1, 1, 1)
|
||||
self.labelNamecoinUser = QtGui.QLabel(self.tabNamecoin)
|
||||
self.labelNamecoinUser.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
|
||||
self.labelNamecoinUser.setObjectName(_fromUtf8("labelNamecoinUser"))
|
||||
self.gridLayout_8.addWidget(self.labelNamecoinUser, 4, 1, 1, 1)
|
||||
self.lineEditNamecoinUser = QtGui.QLineEdit(self.tabNamecoin)
|
||||
self.lineEditNamecoinUser.setObjectName(_fromUtf8("lineEditNamecoinUser"))
|
||||
self.gridLayout_8.addWidget(self.lineEditNamecoinUser, 4, 2, 1, 1)
|
||||
spacerItem13 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_8.addItem(spacerItem13, 5, 0, 1, 1)
|
||||
self.labelNamecoinPassword = QtGui.QLabel(self.tabNamecoin)
|
||||
self.labelNamecoinPassword.setAlignment(
|
||||
QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
|
||||
self.labelNamecoinPassword.setObjectName(_fromUtf8("labelNamecoinPassword"))
|
||||
self.gridLayout_8.addWidget(self.labelNamecoinPassword, 5, 1, 1, 1)
|
||||
self.lineEditNamecoinPassword = QtGui.QLineEdit(self.tabNamecoin)
|
||||
self.lineEditNamecoinPassword.setInputMethodHints(
|
||||
QtCore.Qt.ImhHiddenText | QtCore.Qt.ImhNoAutoUppercase | QtCore.Qt.ImhNoPredictiveText)
|
||||
self.lineEditNamecoinPassword.setEchoMode(QtGui.QLineEdit.Password)
|
||||
self.lineEditNamecoinPassword.setObjectName(_fromUtf8("lineEditNamecoinPassword"))
|
||||
self.gridLayout_8.addWidget(self.lineEditNamecoinPassword, 5, 2, 1, 1)
|
||||
self.labelNamecoinTestResult = QtGui.QLabel(self.tabNamecoin)
|
||||
self.labelNamecoinTestResult.setText(_fromUtf8(""))
|
||||
self.labelNamecoinTestResult.setObjectName(_fromUtf8("labelNamecoinTestResult"))
|
||||
self.gridLayout_8.addWidget(self.labelNamecoinTestResult, 7, 0, 1, 2)
|
||||
self.pushButtonNamecoinTest = QtGui.QPushButton(self.tabNamecoin)
|
||||
self.pushButtonNamecoinTest.setObjectName(_fromUtf8("pushButtonNamecoinTest"))
|
||||
self.gridLayout_8.addWidget(self.pushButtonNamecoinTest, 7, 2, 1, 1)
|
||||
self.horizontalLayout = QtGui.QHBoxLayout()
|
||||
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
|
||||
self.label_21 = QtGui.QLabel(self.tabNamecoin)
|
||||
self.label_21.setObjectName(_fromUtf8("label_21"))
|
||||
self.horizontalLayout.addWidget(self.label_21)
|
||||
self.radioButtonNamecoinNamecoind = QtGui.QRadioButton(self.tabNamecoin)
|
||||
self.radioButtonNamecoinNamecoind.setObjectName(_fromUtf8("radioButtonNamecoinNamecoind"))
|
||||
self.horizontalLayout.addWidget(self.radioButtonNamecoinNamecoind)
|
||||
self.radioButtonNamecoinNmcontrol = QtGui.QRadioButton(self.tabNamecoin)
|
||||
self.radioButtonNamecoinNmcontrol.setObjectName(_fromUtf8("radioButtonNamecoinNmcontrol"))
|
||||
self.horizontalLayout.addWidget(self.radioButtonNamecoinNmcontrol)
|
||||
self.gridLayout_8.addLayout(self.horizontalLayout, 1, 0, 1, 3)
|
||||
self.tabWidgetSettings.addTab(self.tabNamecoin, _fromUtf8(""))
|
||||
self.tabResendsExpire = QtGui.QWidget()
|
||||
self.tabResendsExpire.setObjectName(_fromUtf8("tabResendsExpire"))
|
||||
self.gridLayout_5 = QtGui.QGridLayout(self.tabResendsExpire)
|
||||
self.gridLayout_5.setObjectName(_fromUtf8("gridLayout_5"))
|
||||
self.label_7 = QtGui.QLabel(self.tabResendsExpire)
|
||||
self.label_7.setWordWrap(True)
|
||||
self.label_7.setObjectName(_fromUtf8("label_7"))
|
||||
self.gridLayout_5.addWidget(self.label_7, 0, 0, 1, 3)
|
||||
spacerItem14 = QtGui.QSpacerItem(212, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_5.addItem(spacerItem14, 1, 0, 1, 1)
|
||||
self.widget = QtGui.QWidget(self.tabResendsExpire)
|
||||
self.widget.setMinimumSize(QtCore.QSize(231, 75))
|
||||
self.widget.setObjectName(_fromUtf8("widget"))
|
||||
self.label_19 = QtGui.QLabel(self.widget)
|
||||
self.label_19.setGeometry(QtCore.QRect(10, 20, 101, 20))
|
||||
self.label_19.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
|
||||
self.label_19.setObjectName(_fromUtf8("label_19"))
|
||||
self.label_20 = QtGui.QLabel(self.widget)
|
||||
self.label_20.setGeometry(QtCore.QRect(30, 40, 80, 16))
|
||||
self.label_20.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
|
||||
self.label_20.setObjectName(_fromUtf8("label_20"))
|
||||
self.lineEditDays = QtGui.QLineEdit(self.widget)
|
||||
self.lineEditDays.setGeometry(QtCore.QRect(113, 20, 51, 20))
|
||||
self.lineEditDays.setObjectName(_fromUtf8("lineEditDays"))
|
||||
self.lineEditMonths = QtGui.QLineEdit(self.widget)
|
||||
self.lineEditMonths.setGeometry(QtCore.QRect(113, 40, 51, 20))
|
||||
self.lineEditMonths.setObjectName(_fromUtf8("lineEditMonths"))
|
||||
self.label_22 = QtGui.QLabel(self.widget)
|
||||
self.label_22.setGeometry(QtCore.QRect(169, 23, 61, 16))
|
||||
self.label_22.setObjectName(_fromUtf8("label_22"))
|
||||
self.label_23 = QtGui.QLabel(self.widget)
|
||||
self.label_23.setGeometry(QtCore.QRect(170, 41, 71, 16))
|
||||
self.label_23.setObjectName(_fromUtf8("label_23"))
|
||||
self.gridLayout_5.addWidget(self.widget, 1, 2, 1, 1)
|
||||
spacerItem15 = QtGui.QSpacerItem(20, 129, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
self.gridLayout_5.addItem(spacerItem15, 2, 1, 1, 1)
|
||||
self.tabWidgetSettings.addTab(self.tabResendsExpire, _fromUtf8(""))
|
||||
self.gridLayout.addWidget(self.tabWidgetSettings, 0, 0, 1, 1)
|
||||
|
||||
def getNamecoinType(self):
|
||||
"""
|
||||
Check status of namecoin integration radio buttons
|
||||
and translate it to a string as in the options.
|
||||
"""
|
||||
if self.radioButtonNamecoinNamecoind.isChecked():
|
||||
return "namecoind"
|
||||
if self.radioButtonNamecoinNmcontrol.isChecked():
|
||||
return "nmcontrol"
|
||||
assert False
|
||||
self.retranslateUi(settingsDialog)
|
||||
self.tabWidgetSettings.setCurrentIndex(0)
|
||||
QtCore.QObject.connect( # pylint: disable=no-member
|
||||
self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), settingsDialog.accept)
|
||||
QtCore.QObject.connect( # pylint: disable=no-member
|
||||
self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), settingsDialog.reject)
|
||||
QtCore.QObject.connect( # pylint: disable=no-member
|
||||
self.checkBoxAuthentication,
|
||||
QtCore.SIGNAL(
|
||||
_fromUtf8("toggled(bool)")),
|
||||
self.lineEditSocksUsername.setEnabled)
|
||||
QtCore.QObject.connect( # pylint: disable=no-member
|
||||
self.checkBoxAuthentication,
|
||||
QtCore.SIGNAL(
|
||||
_fromUtf8("toggled(bool)")),
|
||||
self.lineEditSocksPassword.setEnabled)
|
||||
QtCore.QMetaObject.connectSlotsByName(settingsDialog)
|
||||
settingsDialog.setTabOrder(self.tabWidgetSettings, self.checkBoxStartOnLogon)
|
||||
settingsDialog.setTabOrder(self.checkBoxStartOnLogon, self.checkBoxStartInTray)
|
||||
settingsDialog.setTabOrder(self.checkBoxStartInTray, self.checkBoxMinimizeToTray)
|
||||
settingsDialog.setTabOrder(self.checkBoxMinimizeToTray, self.lineEditTCPPort)
|
||||
settingsDialog.setTabOrder(self.lineEditTCPPort, self.comboBoxProxyType)
|
||||
settingsDialog.setTabOrder(self.comboBoxProxyType, self.lineEditSocksHostname)
|
||||
settingsDialog.setTabOrder(self.lineEditSocksHostname, self.lineEditSocksPort)
|
||||
settingsDialog.setTabOrder(self.lineEditSocksPort, self.checkBoxAuthentication)
|
||||
settingsDialog.setTabOrder(self.checkBoxAuthentication, self.lineEditSocksUsername)
|
||||
settingsDialog.setTabOrder(self.lineEditSocksUsername, self.lineEditSocksPassword)
|
||||
settingsDialog.setTabOrder(self.lineEditSocksPassword, self.checkBoxSocksListen)
|
||||
settingsDialog.setTabOrder(self.checkBoxSocksListen, self.buttonBox)
|
||||
|
||||
# Namecoin connection type was changed.
|
||||
def namecoinTypeChanged(self, checked): # pylint: disable=unused-argument
|
||||
"""A callback for toggled event of radioButtonNamecoinNamecoind"""
|
||||
nmctype = self.getNamecoinType()
|
||||
assert nmctype == "namecoind" or nmctype == "nmcontrol"
|
||||
def retranslateUi(self, settingsDialog):
|
||||
"""Re-translate the UI into the supported languages"""
|
||||
|
||||
isNamecoind = (nmctype == "namecoind")
|
||||
self.lineEditNamecoinUser.setEnabled(isNamecoind)
|
||||
self.labelNamecoinUser.setEnabled(isNamecoind)
|
||||
self.lineEditNamecoinPassword.setEnabled(isNamecoind)
|
||||
self.labelNamecoinPassword.setEnabled(isNamecoind)
|
||||
|
||||
if isNamecoind:
|
||||
self.lineEditNamecoinPort.setText(defaults.namecoinDefaultRpcPort)
|
||||
else:
|
||||
self.lineEditNamecoinPort.setText("9000")
|
||||
|
||||
def click_pushButtonNamecoinTest(self):
|
||||
"""Test the namecoin settings specified in the settings dialog."""
|
||||
self.labelNamecoinTestResult.setText(
|
||||
_translate("MainWindow", "Testing..."))
|
||||
nc = namecoin.namecoinConnection({
|
||||
'type': self.getNamecoinType(),
|
||||
'host': str(self.lineEditNamecoinHost.text().toUtf8()),
|
||||
'port': str(self.lineEditNamecoinPort.text().toUtf8()),
|
||||
'user': str(self.lineEditNamecoinUser.text().toUtf8()),
|
||||
'password': str(self.lineEditNamecoinPassword.text().toUtf8())
|
||||
})
|
||||
status, text = nc.test()
|
||||
self.labelNamecoinTestResult.setText(text)
|
||||
if status == 'success':
|
||||
self.parent.namecoin = nc
|
||||
|
||||
def accept(self):
|
||||
"""A callback for accepted event of buttonBox (OK button pressed)"""
|
||||
# pylint: disable=too-many-branches,too-many-statements
|
||||
super(SettingsDialog, self).accept()
|
||||
if self.firstrun:
|
||||
self.config.remove_option('bitmessagesettings', 'dontconnect')
|
||||
self.config.set('bitmessagesettings', 'startonlogon', str(
|
||||
self.checkBoxStartOnLogon.isChecked()))
|
||||
self.config.set('bitmessagesettings', 'minimizetotray', str(
|
||||
self.checkBoxMinimizeToTray.isChecked()))
|
||||
self.config.set('bitmessagesettings', 'trayonclose', str(
|
||||
self.checkBoxTrayOnClose.isChecked()))
|
||||
self.config.set(
|
||||
'bitmessagesettings', 'hidetrayconnectionnotifications',
|
||||
str(self.checkBoxHideTrayConnectionNotifications.isChecked()))
|
||||
self.config.set('bitmessagesettings', 'showtraynotifications', str(
|
||||
self.checkBoxShowTrayNotifications.isChecked()))
|
||||
self.config.set('bitmessagesettings', 'startintray', str(
|
||||
self.checkBoxStartInTray.isChecked()))
|
||||
self.config.set('bitmessagesettings', 'willinglysendtomobile', str(
|
||||
self.checkBoxWillinglySendToMobile.isChecked()))
|
||||
self.config.set('bitmessagesettings', 'useidenticons', str(
|
||||
self.checkBoxUseIdenticons.isChecked()))
|
||||
self.config.set('bitmessagesettings', 'replybelow', str(
|
||||
self.checkBoxReplyBelow.isChecked()))
|
||||
|
||||
lang = str(self.languageComboBox.itemData(
|
||||
self.languageComboBox.currentIndex()).toString())
|
||||
self.config.set('bitmessagesettings', 'userlocale', lang)
|
||||
self.parent.change_translation()
|
||||
|
||||
if int(self.config.get('bitmessagesettings', 'port')) != int(
|
||||
self.lineEditTCPPort.text()):
|
||||
self.config.set(
|
||||
'bitmessagesettings', 'port', str(self.lineEditTCPPort.text()))
|
||||
if not self.config.safeGetBoolean(
|
||||
'bitmessagesettings', 'dontconnect'):
|
||||
self.net_restart_needed = True
|
||||
|
||||
if self.checkBoxUPnP.isChecked() != self.config.safeGetBoolean(
|
||||
'bitmessagesettings', 'upnp'):
|
||||
self.config.set(
|
||||
'bitmessagesettings', 'upnp',
|
||||
str(self.checkBoxUPnP.isChecked()))
|
||||
if self.checkBoxUPnP.isChecked():
|
||||
import upnp
|
||||
upnpThread = upnp.uPnPThread()
|
||||
upnpThread.start()
|
||||
|
||||
udp_enabled = self.checkBoxUDP.isChecked()
|
||||
if udp_enabled != self.config.safeGetBoolean(
|
||||
'bitmessagesettings', 'udp'):
|
||||
self.config.set('bitmessagesettings', 'udp', str(udp_enabled))
|
||||
if udp_enabled:
|
||||
announceThread = AnnounceThread()
|
||||
announceThread.daemon = True
|
||||
announceThread.start()
|
||||
else:
|
||||
try:
|
||||
state.announceThread.stopThread()
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
proxytype_index = self.comboBoxProxyType.currentIndex()
|
||||
if proxytype_index == 0:
|
||||
if self._proxy_type and state.statusIconColor != 'red':
|
||||
self.net_restart_needed = True
|
||||
elif state.statusIconColor == 'red' and self.config.safeGetBoolean(
|
||||
'bitmessagesettings', 'dontconnect'):
|
||||
self.net_restart_needed = False
|
||||
elif self.comboBoxProxyType.currentText() != self._proxy_type:
|
||||
self.net_restart_needed = True
|
||||
self.parent.statusbar.clearMessage()
|
||||
|
||||
self.config.set(
|
||||
'bitmessagesettings', 'socksproxytype',
|
||||
'none' if self.comboBoxProxyType.currentIndex() == 0
|
||||
else str(self.comboBoxProxyType.currentText())
|
||||
)
|
||||
if proxytype_index > 2: # last literal proxytype in ui
|
||||
start_proxyconfig()
|
||||
|
||||
self.config.set('bitmessagesettings', 'socksauthentication', str(
|
||||
self.checkBoxAuthentication.isChecked()))
|
||||
self.config.set('bitmessagesettings', 'sockshostname', str(
|
||||
self.lineEditSocksHostname.text()))
|
||||
self.config.set('bitmessagesettings', 'socksport', str(
|
||||
self.lineEditSocksPort.text()))
|
||||
self.config.set('bitmessagesettings', 'socksusername', str(
|
||||
self.lineEditSocksUsername.text()))
|
||||
self.config.set('bitmessagesettings', 'sockspassword', str(
|
||||
self.lineEditSocksPassword.text()))
|
||||
self.config.set('bitmessagesettings', 'sockslisten', str(
|
||||
self.checkBoxSocksListen.isChecked()))
|
||||
if (
|
||||
self.checkBoxOnionOnly.isChecked()
|
||||
and not self.config.safeGetBoolean(
|
||||
'bitmessagesettings', 'onionservicesonly')
|
||||
):
|
||||
self.net_restart_needed = True
|
||||
self.config.set('bitmessagesettings', 'onionservicesonly', str(
|
||||
self.checkBoxOnionOnly.isChecked()))
|
||||
try:
|
||||
# Rounding to integers just for aesthetics
|
||||
self.config.set('bitmessagesettings', 'maxdownloadrate', str(
|
||||
int(float(self.lineEditMaxDownloadRate.text()))))
|
||||
self.config.set('bitmessagesettings', 'maxuploadrate', str(
|
||||
int(float(self.lineEditMaxUploadRate.text()))))
|
||||
except ValueError:
|
||||
QtGui.QMessageBox.about(
|
||||
self, _translate("MainWindow", "Number needed"),
|
||||
settingsDialog.setWindowTitle(_translate("settingsDialog", "Settings", None))
|
||||
self.checkBoxStartOnLogon.setText(_translate("settingsDialog", "Start Bitmessage on user login", None))
|
||||
self.groupBoxTray.setTitle(_translate("settingsDialog", "Tray", None))
|
||||
self.checkBoxStartInTray.setText(
|
||||
_translate(
|
||||
"MainWindow",
|
||||
"Your maximum download and upload rate must be numbers."
|
||||
" Ignoring what you typed.")
|
||||
)
|
||||
else:
|
||||
set_rates(
|
||||
self.config.safeGetInt('bitmessagesettings', 'maxdownloadrate'),
|
||||
self.config.safeGetInt('bitmessagesettings', 'maxuploadrate'))
|
||||
|
||||
self.config.set('bitmessagesettings', 'maxoutboundconnections', str(
|
||||
int(float(self.lineEditMaxOutboundConnections.text()))))
|
||||
|
||||
self.config.set(
|
||||
'bitmessagesettings', 'namecoinrpctype', self.getNamecoinType())
|
||||
self.config.set('bitmessagesettings', 'namecoinrpchost', str(
|
||||
self.lineEditNamecoinHost.text()))
|
||||
self.config.set('bitmessagesettings', 'namecoinrpcport', str(
|
||||
self.lineEditNamecoinPort.text()))
|
||||
self.config.set('bitmessagesettings', 'namecoinrpcuser', str(
|
||||
self.lineEditNamecoinUser.text()))
|
||||
self.config.set('bitmessagesettings', 'namecoinrpcpassword', str(
|
||||
self.lineEditNamecoinPassword.text()))
|
||||
self.parent.resetNamecoinConnection()
|
||||
|
||||
# Demanded difficulty tab
|
||||
if float(self.lineEditTotalDifficulty.text()) >= 1:
|
||||
self.config.set(
|
||||
'bitmessagesettings', 'defaultnoncetrialsperbyte',
|
||||
str(int(
|
||||
float(self.lineEditTotalDifficulty.text())
|
||||
* defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
||||
if float(self.lineEditSmallMessageDifficulty.text()) >= 1:
|
||||
self.config.set(
|
||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes',
|
||||
str(int(
|
||||
float(self.lineEditSmallMessageDifficulty.text())
|
||||
* defaults.networkDefaultPayloadLengthExtraBytes)))
|
||||
|
||||
if self.comboBoxOpenCL.currentText().toUtf8() != self.config.safeGet(
|
||||
'bitmessagesettings', 'opencl'):
|
||||
self.config.set(
|
||||
'bitmessagesettings', 'opencl',
|
||||
str(self.comboBoxOpenCL.currentText()))
|
||||
queues.workerQueue.put(('resetPoW', ''))
|
||||
|
||||
acceptableDifficultyChanged = False
|
||||
|
||||
if (
|
||||
float(self.lineEditMaxAcceptableTotalDifficulty.text()) >= 1
|
||||
or float(self.lineEditMaxAcceptableTotalDifficulty.text()) == 0
|
||||
):
|
||||
if self.config.get(
|
||||
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte'
|
||||
) != str(int(
|
||||
float(self.lineEditMaxAcceptableTotalDifficulty.text())
|
||||
* defaults.networkDefaultProofOfWorkNonceTrialsPerByte)):
|
||||
# the user changed the max acceptable total difficulty
|
||||
acceptableDifficultyChanged = True
|
||||
self.config.set(
|
||||
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte',
|
||||
str(int(
|
||||
float(self.lineEditMaxAcceptableTotalDifficulty.text())
|
||||
* defaults.networkDefaultProofOfWorkNonceTrialsPerByte))
|
||||
)
|
||||
if (
|
||||
float(self.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1
|
||||
or float(self.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0
|
||||
):
|
||||
if self.config.get(
|
||||
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes'
|
||||
) != str(int(
|
||||
float(self.lineEditMaxAcceptableSmallMessageDifficulty.text())
|
||||
* defaults.networkDefaultPayloadLengthExtraBytes)):
|
||||
# the user changed the max acceptable small message difficulty
|
||||
acceptableDifficultyChanged = True
|
||||
self.config.set(
|
||||
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes',
|
||||
str(int(
|
||||
float(self.lineEditMaxAcceptableSmallMessageDifficulty.text())
|
||||
* defaults.networkDefaultPayloadLengthExtraBytes))
|
||||
)
|
||||
if acceptableDifficultyChanged:
|
||||
# It might now be possible to send msgs which were previously
|
||||
# marked as toodifficult. 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'")
|
||||
queues.workerQueue.put(('sendmessage', ''))
|
||||
|
||||
stopResendingDefaults = False
|
||||
|
||||
# UI setting to stop trying to send messages after X days/months
|
||||
# I'm open to changing this UI to something else if someone has a better idea.
|
||||
if self.lineEditDays.text() == '' and self.lineEditMonths.text() == '':
|
||||
# We need to handle this special case. Bitmessage has its
|
||||
# default behavior. The input is blank/blank
|
||||
self.config.set('bitmessagesettings', 'stopresendingafterxdays', '')
|
||||
self.config.set('bitmessagesettings', 'stopresendingafterxmonths', '')
|
||||
state.maximumLengthOfTimeToBotherResendingMessages = float('inf')
|
||||
stopResendingDefaults = True
|
||||
|
||||
try:
|
||||
days = float(self.lineEditDays.text())
|
||||
except ValueError:
|
||||
self.lineEditDays.setText("0")
|
||||
days = 0.0
|
||||
try:
|
||||
months = float(self.lineEditMonths.text())
|
||||
except ValueError:
|
||||
self.lineEditMonths.setText("0")
|
||||
months = 0.0
|
||||
|
||||
if days >= 0 and months >= 0 and not stopResendingDefaults:
|
||||
state.maximumLengthOfTimeToBotherResendingMessages = \
|
||||
days * 24 * 60 * 60 + months * 60 * 60 * 24 * 365 / 12
|
||||
if state.maximumLengthOfTimeToBotherResendingMessages < 432000:
|
||||
# If the time period is less than 5 hours, we give
|
||||
# zero values to all fields. No message will be sent again.
|
||||
QtGui.QMessageBox.about(
|
||||
self,
|
||||
_translate("MainWindow", "Will not resend ever"),
|
||||
"settingsDialog",
|
||||
"Start Bitmessage in the tray (don\'t show main window)",
|
||||
None))
|
||||
self.checkBoxMinimizeToTray.setText(_translate("settingsDialog", "Minimize to tray", None))
|
||||
self.checkBoxTrayOnClose.setText(_translate("settingsDialog", "Close to tray", None))
|
||||
self.checkBoxHideTrayConnectionNotifications.setText(
|
||||
_translate("settingsDialog", "Hide connection notifications", None))
|
||||
self.checkBoxShowTrayNotifications.setText(
|
||||
_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.")
|
||||
)
|
||||
self.config.set(
|
||||
'bitmessagesettings', 'stopresendingafterxdays', '0')
|
||||
self.config.set(
|
||||
'bitmessagesettings', 'stopresendingafterxmonths', '0')
|
||||
state.maximumLengthOfTimeToBotherResendingMessages = 0.0
|
||||
else:
|
||||
self.config.set(
|
||||
'bitmessagesettings', 'stopresendingafterxdays', str(days))
|
||||
self.config.set(
|
||||
'bitmessagesettings', 'stopresendingafterxmonths',
|
||||
str(months))
|
||||
|
||||
self.config.save()
|
||||
|
||||
if self.net_restart_needed:
|
||||
self.net_restart_needed = False
|
||||
self.config.setTemp('bitmessagesettings', 'dontconnect', 'true')
|
||||
self.timer.singleShot(
|
||||
5000, lambda:
|
||||
self.config.setTemp(
|
||||
'bitmessagesettings', 'dontconnect', 'false')
|
||||
)
|
||||
|
||||
self.parent.updateStartOnLogon()
|
||||
|
||||
if (
|
||||
state.appdata != paths.lookupExeFolder()
|
||||
and self.checkBoxPortableMode.isChecked()
|
||||
):
|
||||
# If we are NOT using portable mode now but the user selected
|
||||
# that we should...
|
||||
# Write the keys.dat file to disk in the new location
|
||||
sqlStoredProcedure('movemessagstoprog')
|
||||
with open(paths.lookupExeFolder() + 'keys.dat', 'wb') as configfile:
|
||||
self.config.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.resetLogging()
|
||||
try:
|
||||
os.remove(previousAppdataLocation + 'debug.log')
|
||||
os.remove(previousAppdataLocation + 'debug.log.1')
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if (
|
||||
state.appdata == paths.lookupExeFolder()
|
||||
and not self.checkBoxPortableMode.isChecked()
|
||||
):
|
||||
# If we ARE using portable mode now but the user selected
|
||||
# that we shouldn't...
|
||||
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
|
||||
self.config.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.resetLogging()
|
||||
try:
|
||||
os.remove(paths.lookupExeFolder() + 'debug.log')
|
||||
os.remove(paths.lookupExeFolder() + 'debug.log.1')
|
||||
except Exception:
|
||||
pass
|
||||
"settingsDialog",
|
||||
"Show notification when message received",
|
||||
None))
|
||||
self.checkBoxPortableMode.setText(_translate("settingsDialog", "Run in Portable Mode", None))
|
||||
self.PortableModeDescription.setText(
|
||||
_translate(
|
||||
"settingsDialog",
|
||||
"In Portable Mode, messages and config files are stored in the same directory as the"
|
||||
" program rather than the normal application-data folder. This makes it convenient to"
|
||||
" run Bitmessage from a USB thumb drive.",
|
||||
None))
|
||||
self.checkBoxWillinglySendToMobile.setText(
|
||||
_translate(
|
||||
"settingsDialog",
|
||||
"Willingly include unencrypted destination address when sending to a mobile device",
|
||||
None))
|
||||
self.checkBoxUseIdenticons.setText(_translate("settingsDialog", "Use Identicons", None))
|
||||
self.checkBoxReplyBelow.setText(_translate("settingsDialog", "Reply below Quote", None))
|
||||
self.groupBox.setTitle(_translate("settingsDialog", "Interface Language", None))
|
||||
self.languageComboBox.setItemText(0, _translate("settingsDialog", "System Settings", "system"))
|
||||
self.tabWidgetSettings.setTabText(
|
||||
self.tabWidgetSettings.indexOf(
|
||||
self.tabUserInterface),
|
||||
_translate(
|
||||
"settingsDialog", "User Interface", None))
|
||||
self.groupBox1.setTitle(_translate("settingsDialog", "Listening port", None))
|
||||
self.label.setText(_translate("settingsDialog", "Listen for connections on port:", None))
|
||||
self.labelUPnP.setText(_translate("settingsDialog", "UPnP:", None))
|
||||
self.groupBox_3.setTitle(_translate("settingsDialog", "Bandwidth limit", None))
|
||||
self.label_24.setText(_translate("settingsDialog", "Maximum download rate (kB/s): [0: unlimited]", None))
|
||||
self.label_25.setText(_translate("settingsDialog", "Maximum upload rate (kB/s): [0: unlimited]", None))
|
||||
self.label_26.setText(_translate("settingsDialog", "Maximum outbound connections: [0: none]", None))
|
||||
self.groupBox_2.setTitle(_translate("settingsDialog", "Proxy server / Tor", None))
|
||||
self.label_2.setText(_translate("settingsDialog", "Type:", None))
|
||||
self.label_3.setText(_translate("settingsDialog", "Server hostname:", None))
|
||||
self.label_4.setText(_translate("settingsDialog", "Port:", None))
|
||||
self.checkBoxAuthentication.setText(_translate("settingsDialog", "Authentication", None))
|
||||
self.label_5.setText(_translate("settingsDialog", "Username:", None))
|
||||
self.label_6.setText(_translate("settingsDialog", "Pass:", None))
|
||||
self.checkBoxSocksListen.setText(
|
||||
_translate(
|
||||
"settingsDialog",
|
||||
"Listen for incoming connections when using proxy",
|
||||
None))
|
||||
self.comboBoxProxyType.setItemText(0, _translate("settingsDialog", "none", None))
|
||||
self.comboBoxProxyType.setItemText(1, _translate("settingsDialog", "SOCKS4a", None))
|
||||
self.comboBoxProxyType.setItemText(2, _translate("settingsDialog", "SOCKS5", None))
|
||||
self.tabWidgetSettings.setTabText(
|
||||
self.tabWidgetSettings.indexOf(
|
||||
self.tabNetworkSettings),
|
||||
_translate(
|
||||
"settingsDialog", "Network Settings", None))
|
||||
self.label_9.setText(_translate("settingsDialog", "Total difficulty:", None))
|
||||
self.label_10.setText(
|
||||
_translate(
|
||||
"settingsDialog",
|
||||
"The \'Total difficulty\' affects the absolute amount of work the sender must complete."
|
||||
" Doubling this value doubles the amount of work.",
|
||||
None))
|
||||
self.label_11.setText(_translate("settingsDialog", "Small message difficulty:", None))
|
||||
self.label_8.setText(_translate(
|
||||
"settingsDialog",
|
||||
"When someone sends you a message, their computer must first complete some work. The difficulty of this"
|
||||
" work, by default, is 1. You may raise this default for new addresses you create by changing the values"
|
||||
" here. Any new addresses you create will require senders to meet the higher difficulty. There is one"
|
||||
" exception: if you add a friend or acquaintance to your address book, Bitmessage will automatically"
|
||||
" notify them when you next send a message that they need only complete the minimum amount of"
|
||||
" work: difficulty 1. ",
|
||||
None))
|
||||
self.label_12.setText(
|
||||
_translate(
|
||||
"settingsDialog",
|
||||
"The \'Small message difficulty\' mostly only affects the difficulty of sending small messages."
|
||||
" Doubling this value makes it almost twice as difficult to send a small message but doesn\'t really"
|
||||
" affect large messages.",
|
||||
None))
|
||||
self.tabWidgetSettings.setTabText(
|
||||
self.tabWidgetSettings.indexOf(
|
||||
self.tabDemandedDifficulty),
|
||||
_translate(
|
||||
"settingsDialog", "Demanded difficulty", None))
|
||||
self.label_15.setText(
|
||||
_translate(
|
||||
"settingsDialog",
|
||||
"Here you may set the maximum amount of work you are willing to do to send a message to another"
|
||||
" person. Setting these values to 0 means that any value is acceptable.",
|
||||
None))
|
||||
self.label_13.setText(_translate("settingsDialog", "Maximum acceptable total difficulty:", None))
|
||||
self.label_14.setText(_translate("settingsDialog", "Maximum acceptable small message difficulty:", None))
|
||||
self.tabWidgetSettings.setTabText(
|
||||
self.tabWidgetSettings.indexOf(
|
||||
self.tabMaxAcceptableDifficulty),
|
||||
_translate(
|
||||
"settingsDialog", "Max acceptable difficulty", None))
|
||||
self.labelOpenCL.setText(_translate("settingsDialog", "Hardware GPU acceleration (OpenCL):", None))
|
||||
self.label_16.setText(_translate(
|
||||
"settingsDialog",
|
||||
"<html><head/><body><p>Bitmessage can utilize a different Bitcoin-based program called Namecoin to make"
|
||||
" addresses human-friendly. For example, instead of having to tell your friend your long Bitmessage"
|
||||
" address, you can simply tell him to send a message to <span style=\" font-style:italic;\">test."
|
||||
" </span></p><p>(Getting your own Bitmessage address into Namecoin is still rather difficult).</p>"
|
||||
"<p>Bitmessage can use either namecoind directly or a running nmcontrol instance.</p></body></html>",
|
||||
None))
|
||||
self.label_17.setText(_translate("settingsDialog", "Host:", None))
|
||||
self.label_18.setText(_translate("settingsDialog", "Port:", None))
|
||||
self.labelNamecoinUser.setText(_translate("settingsDialog", "Username:", None))
|
||||
self.labelNamecoinPassword.setText(_translate("settingsDialog", "Password:", None))
|
||||
self.pushButtonNamecoinTest.setText(_translate("settingsDialog", "Test", None))
|
||||
self.label_21.setText(_translate("settingsDialog", "Connect to:", None))
|
||||
self.radioButtonNamecoinNamecoind.setText(_translate("settingsDialog", "Namecoind", None))
|
||||
self.radioButtonNamecoinNmcontrol.setText(_translate("settingsDialog", "NMControl", None))
|
||||
self.tabWidgetSettings.setTabText(
|
||||
self.tabWidgetSettings.indexOf(
|
||||
self.tabNamecoin),
|
||||
_translate(
|
||||
"settingsDialog", "Namecoin integration", None))
|
||||
self.label_7.setText(_translate(
|
||||
"settingsDialog",
|
||||
"<html><head/><body><p>By default, if you send a message to someone and he is offline for more than two"
|
||||
" days, Bitmessage will send the message again after an additional two days. This will be continued with"
|
||||
" exponential backoff forever; messages will be resent after 5, 10, 20 days ect. until the receiver"
|
||||
" acknowledges them. Here you may change that behavior by having Bitmessage give up after a certain"
|
||||
" number of days or months.</p><p>Leave these input fields blank for the default behavior."
|
||||
" </p></body></html>",
|
||||
None))
|
||||
self.label_19.setText(_translate("settingsDialog", "Give up after", None))
|
||||
self.label_20.setText(_translate("settingsDialog", "and", None))
|
||||
self.label_22.setText(_translate("settingsDialog", "days", None))
|
||||
self.label_23.setText(_translate("settingsDialog", "months.", None))
|
||||
self.tabWidgetSettings.setTabText(
|
||||
self.tabWidgetSettings.indexOf(
|
||||
self.tabResendsExpire),
|
||||
_translate(
|
||||
"settingsDialog", "Resends Expire", None))
|
||||
|
|
|
@ -37,18 +37,6 @@
|
|||
<string>User Interface</string>
|
||||
</attribute>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="leftMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxStartOnLogon">
|
||||
<property name="text">
|
||||
|
@ -56,43 +44,20 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBoxTray">
|
||||
<property name="title">
|
||||
<string>Tray</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="formLayoutTray">
|
||||
<item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkBoxStartInTray">
|
||||
<property name="text">
|
||||
<string>Start Bitmessage in the tray (don't show main window)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxMinimizeToTray">
|
||||
<property name="text">
|
||||
<string>Minimize to tray</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxTrayOnClose">
|
||||
<property name="text">
|
||||
<string>Close to tray</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxHideTrayConnectionNotifications">
|
||||
<property name="text">
|
||||
<string>Hide connection notifications</string>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -152,15 +117,90 @@
|
|||
<property name="title">
|
||||
<string>Interface Language</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="LanguageBox" name="languageComboBox">
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="languageComboBox">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string comment="system">System Settings</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true" comment="en">English</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true" comment="eo">Esperanto</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true" comment="fr">Français</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true" comment="de">Deutsch</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true" comment="es">Español</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true" comment="ru">русский</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true" comment="no">Norsk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true" comment="ar">العربية</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true" comment="zh_cn">简体中文</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true" comment="ja">日本語</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true" comment="nl">Nederlands</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true" comment="cs">Česky</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string comment="en_pirate">Pirate English</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string comment="other">Other (set in keys.dat)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -173,18 +213,6 @@
|
|||
<string>Network Settings</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
|
@ -192,13 +220,26 @@
|
|||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>125</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Listen for connections on port:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="0" column="2">
|
||||
<widget class="QLineEdit" name="lineEditTCPPort">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
|
@ -208,30 +249,10 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QCheckBox" name="checkBoxUPnP">
|
||||
<property name="text">
|
||||
<string>UPnP</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Bandwidth limit</string>
|
||||
|
@ -322,7 +343,7 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Proxy server / Tor</string>
|
||||
|
@ -403,13 +424,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="4">
|
||||
<widget class="QCheckBox" name="checkBoxOnionOnly">
|
||||
<property name="text">
|
||||
<string>Only connect to onion services (*.onion)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comboBoxProxyType">
|
||||
<item>
|
||||
|
@ -419,12 +433,12 @@
|
|||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">SOCKS4a</string>
|
||||
<string>SOCKS4a</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">SOCKS5</string>
|
||||
<string>SOCKS5</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
|
@ -432,14 +446,7 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxUDP">
|
||||
<property name="text">
|
||||
<string>Announce self by UDP</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="3" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
@ -459,18 +466,6 @@
|
|||
<string>Demanded difficulty</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<property name="leftMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
|
@ -599,18 +594,6 @@
|
|||
<string>Max acceptable difficulty</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<property name="leftMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
|
@ -715,33 +698,6 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelOpenCL">
|
||||
<property name="text">
|
||||
<string>Hardware GPU acceleration (OpenCL):</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBoxOpenCL"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_12">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tabNamecoin">
|
||||
|
@ -749,18 +705,6 @@
|
|||
<string>Namecoin integration</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_8">
|
||||
<property name="leftMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<item row="2" column="0">
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
|
@ -944,18 +888,6 @@
|
|||
<string>Resends Expire</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<property name="leftMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
|
@ -980,16 +912,22 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QGroupBox">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>231</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_19">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>101</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Give up after</string>
|
||||
</property>
|
||||
|
@ -997,9 +935,15 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_20">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>40</y>
|
||||
<width>80</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>and</string>
|
||||
</property>
|
||||
|
@ -1007,42 +951,52 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEditDays">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>55</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>113</x>
|
||||
<y>20</y>
|
||||
<width>51</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEditMonths">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>55</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>113</x>
|
||||
<y>40</y>
|
||||
<width>51</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel">
|
||||
<widget class="QLabel" name="label_22">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>169</x>
|
||||
<y>23</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>days</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel">
|
||||
<widget class="QLabel" name="label_23">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>170</x>
|
||||
<y>41</y>
|
||||
<width>71</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>months.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
|
@ -1063,14 +1017,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LanguageBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>bitmessageqt.languagebox</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>tabWidgetSettings</tabstop>
|
||||
<tabstop>checkBoxStartOnLogon</tabstop>
|
||||
|
@ -1154,53 +1101,5 @@
|
|||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>comboBoxProxyType</sender>
|
||||
<signal>currentIndexChanged(int)</signal>
|
||||
<receiver>settingsDialog</receiver>
|
||||
<slot>comboBoxProxyTypeChanged</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>radioButtonNamecoinNamecoind</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>settingsDialog</receiver>
|
||||
<slot>namecoinTypeChanged</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pushButtonNamecoinTest</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>settingsDialog</receiver>
|
||||
<slot>click_pushButtonNamecoinTest</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
|
|
@ -4,7 +4,16 @@ src/settingsmixin.py
|
|||
====================
|
||||
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
from builtins import *
|
||||
from builtins import object
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Sound Module"""
|
||||
|
||||
# sound type constants
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import *
|
||||
SOUND_NONE = 0
|
||||
SOUND_KNOWN = 1
|
||||
SOUND_UNKNOWN = 2
|
||||
|
@ -13,12 +19,10 @@ SOUND_CONNECTION_GREEN = 5
|
|||
# returns true if the given sound category is a connection sound
|
||||
# rather than a received message sound
|
||||
def is_connection_sound(category):
|
||||
"""Check if sound type is related to connectivity"""
|
||||
return category in (
|
||||
SOUND_CONNECTED,
|
||||
SOUND_DISCONNECTED,
|
||||
SOUND_CONNECTION_GREEN
|
||||
)
|
||||
|
||||
|
||||
extensions = ('wav', 'mp3', 'oga')
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
# pylint: disable=unused-argument
|
||||
"""Status bar Module"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import *
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from queue import Queue
|
||||
from time import time
|
||||
from PyQt4 import QtGui
|
||||
|
||||
|
||||
class BMStatusBar(QtGui.QStatusBar):
|
||||
"""Status bar with queue and priorities"""
|
||||
duration = 10000
|
||||
deleteAfter = 60
|
||||
|
||||
|
@ -17,9 +20,6 @@ class BMStatusBar(QtGui.QStatusBar):
|
|||
self.iterator = 0
|
||||
|
||||
def timerEvent(self, event):
|
||||
"""an event handler which allows to queue and prioritise messages to
|
||||
show in the status bar, for example if many messages come very quickly
|
||||
after one another, it adds delays and so on"""
|
||||
while len(self.important) > 0:
|
||||
self.iterator += 1
|
||||
try:
|
||||
|
@ -37,3 +37,9 @@ class BMStatusBar(QtGui.QStatusBar):
|
|||
self.important.append([message, time()])
|
||||
self.iterator = len(self.important) - 2
|
||||
self.timerEvent(None)
|
||||
|
||||
def showMessage(self, message, timeout=0):
|
||||
super(BMStatusBar, self).showMessage(message, timeout)
|
||||
|
||||
def clearMessage(self):
|
||||
super(BMStatusBar, self).clearMessage()
|
||||
|
|
|
@ -1,43 +1,40 @@
|
|||
"""Composing support request message functions."""
|
||||
# pylint: disable=no-member
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
from builtins import *
|
||||
import ctypes
|
||||
from PyQt4 import QtCore, QtGui
|
||||
import ssl
|
||||
import sys
|
||||
import time
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
import account
|
||||
from . import account
|
||||
from bmconfigparser import BMConfigParser
|
||||
from debug import logger
|
||||
import defaults
|
||||
import network.stats
|
||||
from .foldertree import AccountMixin
|
||||
from helper_sql import *
|
||||
from l10n import getTranslationLanguage
|
||||
from openclpow import openclAvailable, openclEnabled
|
||||
import paths
|
||||
import proofofwork
|
||||
import queues
|
||||
import state
|
||||
from bmconfigparser import BMConfigParser
|
||||
from foldertree import AccountMixin
|
||||
from helper_sql import sqlExecute, sqlQuery
|
||||
from l10n import getTranslationLanguage
|
||||
from openclpow import openclEnabled
|
||||
from pyelliptic.openssl import OpenSSL
|
||||
from settings import getSOCKSProxyType
|
||||
import queues
|
||||
import network.stats
|
||||
import state
|
||||
from version import softwareVersion
|
||||
from tr import _translate
|
||||
|
||||
|
||||
# this is BM support address going to Peter Surda
|
||||
OLD_SUPPORT_ADDRESS = 'BM-2cTkCtMYkrSPwFTpgcBrMrf5d8oZwvMZWK'
|
||||
SUPPORT_ADDRESS = 'BM-2cUdgkDDAahwPAU6oD2A7DnjqZz3hgY832'
|
||||
SUPPORT_LABEL = _translate("Support", "PyBitmessage support")
|
||||
SUPPORT_MY_LABEL = _translate("Support", "My new address")
|
||||
SUPPORT_LABEL = 'PyBitmessage support'
|
||||
SUPPORT_MY_LABEL = 'My new address'
|
||||
SUPPORT_SUBJECT = 'Support request'
|
||||
SUPPORT_MESSAGE = _translate("Support", '''
|
||||
You can use this message to send a report to one of the PyBitmessage core \
|
||||
developers regarding PyBitmessage or the mailchuck.com email service. \
|
||||
If you are using PyBitmessage involuntarily, for example because \
|
||||
your computer was infected with ransomware, this is not an appropriate venue \
|
||||
for resolving such issues.
|
||||
SUPPORT_MESSAGE = '''You can use this message to send a report to one of the PyBitmessage core developers regarding PyBitmessage or the mailchuck.com email service. If you are using PyBitmessage involuntarily, for example because your computer was infected with ransomware, this is not an appropriate venue for resolving such issues.
|
||||
|
||||
Please describe what you are trying to do:
|
||||
|
||||
|
@ -47,8 +44,7 @@ Please describe what happens instead:
|
|||
|
||||
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Please write above this line and if possible, keep the information about your \
|
||||
environment below intact.
|
||||
Please write above this line and if possible, keep the information about your environment below intact.
|
||||
|
||||
PyBitmessage version: {}
|
||||
Operating system: {}
|
||||
|
@ -63,19 +59,15 @@ Locale: {}
|
|||
SOCKS: {}
|
||||
UPnP: {}
|
||||
Connected hosts: {}
|
||||
''')
|
||||
|
||||
'''
|
||||
|
||||
def checkAddressBook(myapp):
|
||||
sqlExecute('DELETE from addressbook WHERE address=?', OLD_SUPPORT_ADDRESS)
|
||||
queryreturn = sqlQuery('SELECT * FROM addressbook WHERE address=?', SUPPORT_ADDRESS)
|
||||
sqlExecute('''DELETE from addressbook WHERE address=?''', OLD_SUPPORT_ADDRESS)
|
||||
queryreturn = sqlQuery('''SELECT * FROM addressbook WHERE address=?''', SUPPORT_ADDRESS)
|
||||
if queryreturn == []:
|
||||
sqlExecute(
|
||||
'INSERT INTO addressbook VALUES (?,?)',
|
||||
SUPPORT_LABEL.toUtf8(), SUPPORT_ADDRESS)
|
||||
sqlExecute('''INSERT INTO addressbook VALUES (?,?)''', str(QtGui.QApplication.translate("Support", SUPPORT_LABEL)), SUPPORT_ADDRESS)
|
||||
myapp.rerenderAddressBook()
|
||||
|
||||
|
||||
def checkHasNormalAddress():
|
||||
for address in account.getSortedAccounts():
|
||||
acct = account.accountClass(address)
|
||||
|
@ -83,32 +75,22 @@ def checkHasNormalAddress():
|
|||
return address
|
||||
return False
|
||||
|
||||
|
||||
def createAddressIfNeeded(myapp):
|
||||
if not checkHasNormalAddress():
|
||||
queues.addressGeneratorQueue.put((
|
||||
'createRandomAddress', 4, 1,
|
||||
str(SUPPORT_MY_LABEL.toUtf8()),
|
||||
1, "", False,
|
||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte,
|
||||
defaults.networkDefaultPayloadLengthExtraBytes
|
||||
))
|
||||
queues.addressGeneratorQueue.put(('createRandomAddress', 4, 1, str(QtGui.QApplication.translate("Support", SUPPORT_MY_LABEL)), 1, "", False, defaults.networkDefaultProofOfWorkNonceTrialsPerByte, defaults.networkDefaultPayloadLengthExtraBytes))
|
||||
while state.shutdown == 0 and not checkHasNormalAddress():
|
||||
time.sleep(.2)
|
||||
myapp.rerenderComboBoxSendFrom()
|
||||
return checkHasNormalAddress()
|
||||
|
||||
|
||||
def createSupportMessage(myapp):
|
||||
checkAddressBook(myapp)
|
||||
address = createAddressIfNeeded(myapp)
|
||||
if state.shutdown:
|
||||
return
|
||||
|
||||
myapp.ui.lineEditSubject.setText(SUPPORT_SUBJECT)
|
||||
addrIndex = myapp.ui.comboBoxSendFrom.findData(
|
||||
address, QtCore.Qt.UserRole,
|
||||
QtCore.Qt.MatchFixedString | QtCore.Qt.MatchCaseSensitive)
|
||||
myapp.ui.lineEditSubject.setText(str(QtGui.QApplication.translate("Support", SUPPORT_SUBJECT)))
|
||||
addrIndex = myapp.ui.comboBoxSendFrom.findData(address, QtCore.Qt.UserRole, QtCore.Qt.MatchFixedString | QtCore.Qt.MatchCaseSensitive)
|
||||
if addrIndex == -1: # something is very wrong
|
||||
return
|
||||
myapp.ui.comboBoxSendFrom.setCurrentIndex(addrIndex)
|
||||
|
@ -133,8 +115,7 @@ def createSupportMessage(myapp):
|
|||
architecture = "32" if ctypes.sizeof(ctypes.c_voidp) == 4 else "64"
|
||||
pythonversion = sys.version
|
||||
|
||||
opensslversion = "%s (Python internal), %s (external for PyElliptic)" % (
|
||||
ssl.OPENSSL_VERSION, OpenSSL._version)
|
||||
opensslversion = "%s (Python internal), %s (external for PyElliptic)" % (ssl.OPENSSL_VERSION, OpenSSL._version)
|
||||
|
||||
frozen = "N/A"
|
||||
if paths.frozen:
|
||||
|
@ -145,13 +126,12 @@ def createSupportMessage(myapp):
|
|||
BMConfigParser().safeGet('bitmessagesettings', 'opencl')
|
||||
) if openclEnabled() else "None"
|
||||
locale = getTranslationLanguage()
|
||||
socks = getSOCKSProxyType(BMConfigParser()) or "N/A"
|
||||
socks = BMConfigParser().safeGet(
|
||||
'bitmessagesettings', 'socksproxytype', "N/A")
|
||||
upnp = BMConfigParser().safeGet('bitmessagesettings', 'upnp', "N/A")
|
||||
connectedhosts = len(network.stats.connectedHostsList())
|
||||
|
||||
myapp.ui.textEditMessage.setText(unicode(SUPPORT_MESSAGE, 'utf-8').format(
|
||||
version, os, architecture, pythonversion, opensslversion, frozen,
|
||||
portablemode, cpow, openclpow, locale, socks, upnp, connectedhosts))
|
||||
myapp.ui.textEditMessage.setText(str(QtGui.QApplication.translate("Support", SUPPORT_MESSAGE)).format(version, os, architecture, pythonversion, opensslversion, frozen, portablemode, cpow, openclpow, locale, socks, upnp, connectedhosts))
|
||||
|
||||
# single msg tab
|
||||
myapp.ui.tabWidgetSend.setCurrentIndex(
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
"""bitmessageqt tests"""
|
||||
|
||||
from addressbook import TestAddressbook
|
||||
from main import TestMain, TestUISignaler
|
||||
from settings import TestSettings
|
||||
from support import TestSupport
|
||||
|
||||
__all__ = [
|
||||
"TestAddressbook", "TestMain", "TestSettings", "TestSupport",
|
||||
"TestUISignaler"
|
||||
]
|
|
@ -1,17 +0,0 @@
|
|||
import helper_addressbook
|
||||
from bitmessageqt.support import createAddressIfNeeded
|
||||
|
||||
from main import TestBase
|
||||
|
||||
|
||||
class TestAddressbook(TestBase):
|
||||
"""Test case for addressbook"""
|
||||
|
||||
def test_add_own_address_to_addressbook(self):
|
||||
"""Checking own address adding in addressbook"""
|
||||
try:
|
||||
address = createAddressIfNeeded(self.window)
|
||||
self.assertFalse(
|
||||
helper_addressbook.insert(label='test', address=address))
|
||||
except IndexError:
|
||||
self.fail("Can't generate addresses")
|
|
@ -1,60 +0,0 @@
|
|||
"""Common definitions for bitmessageqt tests"""
|
||||
|
||||
import Queue
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
import bitmessageqt
|
||||
import queues
|
||||
from tr import _translate
|
||||
|
||||
|
||||
class TestBase(unittest.TestCase):
|
||||
"""Base class for bitmessageqt test case"""
|
||||
|
||||
def setUp(self):
|
||||
self.app = (
|
||||
QtGui.QApplication.instance()
|
||||
or bitmessageqt.BitmessageQtApplication(sys.argv))
|
||||
self.window = self.app.activeWindow()
|
||||
if not self.window:
|
||||
self.window = bitmessageqt.MyForm()
|
||||
self.window.appIndicatorInit(self.app)
|
||||
|
||||
def tearDown(self):
|
||||
# self.app.deleteLater()
|
||||
while True:
|
||||
try:
|
||||
thread, exc = queues.excQueue.get(block=False)
|
||||
except Queue.Empty:
|
||||
return
|
||||
if thread == 'tests':
|
||||
self.fail('Exception in the main thread: %s' % exc)
|
||||
|
||||
|
||||
class TestMain(unittest.TestCase):
|
||||
"""Test case for main window - basic features"""
|
||||
|
||||
def test_translate(self):
|
||||
"""Check the results of _translate() with various args"""
|
||||
self.assertIsInstance(
|
||||
_translate("MainWindow", "Test"),
|
||||
QtCore.QString
|
||||
)
|
||||
|
||||
|
||||
class TestUISignaler(TestBase):
|
||||
"""Test case for UISignalQueue"""
|
||||
|
||||
def test_updateStatusBar(self):
|
||||
"""Check arguments order of updateStatusBar command"""
|
||||
queues.UISignalQueue.put((
|
||||
'updateStatusBar', (
|
||||
_translate("test", "Testing updateStatusBar..."), 1)
|
||||
))
|
||||
|
||||
QtCore.QTimer.singleShot(60, self.app.quit)
|
||||
self.app.exec_()
|
||||
# self.app.processEvents(QtCore.QEventLoop.AllEvents, 60)
|
|
@ -1,34 +0,0 @@
|
|||
import threading
|
||||
import time
|
||||
|
||||
from main import TestBase
|
||||
from bmconfigparser import BMConfigParser
|
||||
from bitmessageqt import settings
|
||||
|
||||
|
||||
class TestSettings(TestBase):
|
||||
"""A test case for the "Settings" dialog"""
|
||||
def setUp(self):
|
||||
super(TestSettings, self).setUp()
|
||||
self.dialog = settings.SettingsDialog(self.window)
|
||||
|
||||
def test_udp(self):
|
||||
"""Test the effect of checkBoxUDP"""
|
||||
udp_setting = BMConfigParser().safeGetBoolean(
|
||||
'bitmessagesettings', 'udp')
|
||||
self.assertEqual(udp_setting, self.dialog.checkBoxUDP.isChecked())
|
||||
self.dialog.checkBoxUDP.setChecked(not udp_setting)
|
||||
self.dialog.accept()
|
||||
self.assertEqual(
|
||||
not udp_setting,
|
||||
BMConfigParser().safeGetBoolean('bitmessagesettings', 'udp'))
|
||||
time.sleep(5)
|
||||
for thread in threading.enumerate():
|
||||
if thread.name == 'Announcer': # find Announcer thread
|
||||
if udp_setting:
|
||||
self.fail(
|
||||
'Announcer thread is running while udp set to False')
|
||||
break
|
||||
else:
|
||||
if not udp_setting:
|
||||
self.fail('No Announcer thread found while udp set to True')
|
|
@ -1,33 +0,0 @@
|
|||
# from PyQt4 import QtTest
|
||||
|
||||
import sys
|
||||
|
||||
from shared import isAddressInMyAddressBook
|
||||
|
||||
from main import TestBase
|
||||
|
||||
|
||||
class TestSupport(TestBase):
|
||||
"""A test case for support module"""
|
||||
SUPPORT_ADDRESS = 'BM-2cUdgkDDAahwPAU6oD2A7DnjqZz3hgY832'
|
||||
SUPPORT_SUBJECT = 'Support request'
|
||||
|
||||
def test(self):
|
||||
"""trigger menu action "Contact Support" and check the result"""
|
||||
ui = self.window.ui
|
||||
self.assertEqual(ui.lineEditTo.text(), '')
|
||||
self.assertEqual(ui.lineEditSubject.text(), '')
|
||||
|
||||
ui.actionSupport.trigger()
|
||||
|
||||
self.assertTrue(
|
||||
isAddressInMyAddressBook(self.SUPPORT_ADDRESS))
|
||||
|
||||
self.assertEqual(
|
||||
ui.tabWidget.currentIndex(), ui.tabWidget.indexOf(ui.send))
|
||||
self.assertEqual(
|
||||
ui.lineEditTo.text(), self.SUPPORT_ADDRESS)
|
||||
self.assertEqual(
|
||||
ui.lineEditSubject.text(), self.SUPPORT_SUBJECT)
|
||||
self.assertIn(
|
||||
sys.version, ui.textEditMessage.toPlainText())
|
|
@ -1,4 +1,12 @@
|
|||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
from builtins import *
|
||||
from PyQt4.QtCore import QThread, SIGNAL
|
||||
import sys
|
||||
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import *
|
||||
from PyQt4 import QtGui
|
||||
import hashlib
|
||||
import os
|
||||
|
||||
from PyQt4 import QtGui
|
||||
|
||||
import state
|
||||
from addresses import addBMIfNotPresent
|
||||
from bmconfigparser import BMConfigParser
|
||||
import state
|
||||
|
||||
str_broadcast_subscribers = '[Broadcast subscribers]'
|
||||
str_chan = '[chan]'
|
||||
|
||||
|
||||
def identiconize(address):
|
||||
size = 48
|
||||
|
||||
|
@ -31,40 +35,32 @@ def identiconize(address):
|
|||
# the identicons to decrease the risk of attacks where someone creates
|
||||
# an address to mimic someone else's identicon.
|
||||
identiconsuffix = BMConfigParser().get('bitmessagesettings', 'identiconsuffix')
|
||||
if identicon_lib[:len('qidenticon')] == 'qidenticon':
|
||||
if (identicon_lib[:len('qidenticon')] == 'qidenticon'):
|
||||
# print identicon_lib
|
||||
# originally by:
|
||||
# :Author:Shin Adachi <shn@glucose.jp>
|
||||
# Licesensed under FreeBSD License.
|
||||
# stripped from PIL and uses QT instead (by sendiulo, same license)
|
||||
import qidenticon
|
||||
icon_hash = hashlib.md5(
|
||||
addBMIfNotPresent(address) + identiconsuffix).hexdigest()
|
||||
use_two_colors = identicon_lib[:len('qidenticon_two')] == 'qidenticon_two'
|
||||
opacity = int(
|
||||
identicon_lib not in (
|
||||
'qidenticon_x', 'qidenticon_two_x',
|
||||
'qidenticon_b', 'qidenticon_two_b'
|
||||
)) * 255
|
||||
hash = hashlib.md5(addBMIfNotPresent(address)+identiconsuffix).hexdigest()
|
||||
use_two_colors = (identicon_lib[:len('qidenticon_two')] == 'qidenticon_two')
|
||||
opacity = int(not((identicon_lib == 'qidenticon_x') | (identicon_lib == 'qidenticon_two_x') | (identicon_lib == 'qidenticon_b') | (identicon_lib == 'qidenticon_two_b')))*255
|
||||
penwidth = 0
|
||||
image = qidenticon.render_identicon(
|
||||
int(icon_hash, 16), size, use_two_colors, opacity, penwidth)
|
||||
image = qidenticon.render_identicon(int(hash, 16), size, use_two_colors, opacity, penwidth)
|
||||
# filename = './images/identicons/'+hash+'.png'
|
||||
# image.save(filename)
|
||||
idcon = QtGui.QIcon()
|
||||
idcon.addPixmap(image, QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
return idcon
|
||||
elif identicon_lib == 'pydenticon':
|
||||
# Here you could load pydenticon.py
|
||||
# (just put it in the "src" folder of your Bitmessage source)
|
||||
# print identicon_lib
|
||||
# Here you could load pydenticon.py (just put it in the "src" folder of your Bitmessage source)
|
||||
from pydenticon import Pydenticon
|
||||
# It is not included in the source, because it is licensed under GPLv3
|
||||
# GPLv3 is a copyleft license that would influence our licensing
|
||||
# Find the source here:
|
||||
# https://github.com/azaghal/pydenticon
|
||||
# note that it requires pillow (or PIL) to be installed:
|
||||
# https://python-pillow.org/
|
||||
idcon_render = Pydenticon(
|
||||
addBMIfNotPresent(address) + identiconsuffix, size * 3)
|
||||
# Find the source here: http://boottunes.googlecode.com/svn-history/r302/trunk/src/pydenticon.py
|
||||
# note that it requires PIL to be installed: http://www.pythonware.com/products/pil/
|
||||
idcon_render = Pydenticon(addBMIfNotPresent(address)+identiconsuffix, size*3)
|
||||
rendering = idcon_render._render()
|
||||
data = rendering.convert("RGBA").tostring("raw", "RGBA")
|
||||
qim = QtGui.QImage(data, size, size, QtGui.QImage.Format_ARGB32)
|
||||
|
@ -73,31 +69,32 @@ def identiconize(address):
|
|||
idcon.addPixmap(pix, QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
return idcon
|
||||
|
||||
|
||||
def avatarize(address):
|
||||
"""
|
||||
Loads a supported image for the given address' hash form 'avatars' folder
|
||||
loads a supported image for the given address' hash form 'avatars' folder
|
||||
falls back to default avatar if 'default.*' file exists
|
||||
falls back to identiconize(address)
|
||||
"""
|
||||
idcon = QtGui.QIcon()
|
||||
icon_hash = hashlib.md5(addBMIfNotPresent(address)).hexdigest()
|
||||
hash = hashlib.md5(addBMIfNotPresent(address)).hexdigest()
|
||||
str_broadcast_subscribers = '[Broadcast subscribers]'
|
||||
if address == str_broadcast_subscribers:
|
||||
# don't hash [Broadcast subscribers]
|
||||
icon_hash = address
|
||||
# https://www.riverbankcomputing.com/static/Docs/PyQt4/qimagereader.html#supportedImageFormats
|
||||
hash = address
|
||||
# http://pyqt.sourceforge.net/Docs/PyQt4/qimagereader.html#supportedImageFormats
|
||||
# print QImageReader.supportedImageFormats ()
|
||||
# QImageReader.supportedImageFormats ()
|
||||
extensions = [
|
||||
'PNG', 'GIF', 'JPG', 'JPEG', 'SVG', 'BMP', 'MNG', 'PBM', 'PGM', 'PPM',
|
||||
'TIFF', 'XBM', 'XPM', 'TGA']
|
||||
extensions = ['PNG', 'GIF', 'JPG', 'JPEG', 'SVG', 'BMP', 'MNG', 'PBM', 'PGM', 'PPM', 'TIFF', 'XBM', 'XPM', 'TGA']
|
||||
# try to find a specific avatar
|
||||
for ext in extensions:
|
||||
lower_hash = state.appdata + 'avatars/' + icon_hash + '.' + ext.lower()
|
||||
upper_hash = state.appdata + 'avatars/' + icon_hash + '.' + ext.upper()
|
||||
lower_hash = state.appdata + 'avatars/' + hash + '.' + ext.lower()
|
||||
upper_hash = state.appdata + 'avatars/' + hash + '.' + ext.upper()
|
||||
if os.path.isfile(lower_hash):
|
||||
# print 'found avatar of ', address
|
||||
idcon.addFile(lower_hash)
|
||||
return idcon
|
||||
elif os.path.isfile(upper_hash):
|
||||
# print 'found avatar of ', address
|
||||
idcon.addFile(upper_hash)
|
||||
return idcon
|
||||
# if we haven't found any, try to find a default avatar
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import *
|
||||
from PyQt4 import uic
|
||||
import os.path
|
||||
import paths
|
||||
|
|
|
@ -2,21 +2,19 @@
|
|||
BMConfigParser class definition and default configuration settings
|
||||
"""
|
||||
|
||||
import sys
|
||||
if sys.version_info[0] == 3:
|
||||
# python 3
|
||||
import configparser as ConfigParser
|
||||
SafeConfigParser = ConfigParser.ConfigParser
|
||||
else:
|
||||
# python 2
|
||||
import ConfigParser
|
||||
SafeConfigParser = ConfigParser.SafeConfigParser
|
||||
from configparser import (
|
||||
ConfigParser,
|
||||
InterpolationError,
|
||||
NoOptionError,
|
||||
NoSectionError,
|
||||
)
|
||||
from datetime import datetime
|
||||
import os
|
||||
from past.builtins import basestring
|
||||
import shutil
|
||||
from singleton import Singleton
|
||||
|
||||
import state
|
||||
from singleton import Singleton
|
||||
import os
|
||||
import shutil
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
BMConfigDefaults = {
|
||||
|
@ -28,39 +26,32 @@ BMConfigDefaults = {
|
|||
"maxtotalconnections": 200,
|
||||
"maxuploadrate": 0,
|
||||
"apiinterface": "127.0.0.1",
|
||||
"apiport": 8442,
|
||||
"udp": "True"
|
||||
"apiport": 8442
|
||||
},
|
||||
"threads": {
|
||||
"receive": 3,
|
||||
},
|
||||
"network": {
|
||||
"bind": "",
|
||||
"bind": '',
|
||||
"dandelion": 90,
|
||||
},
|
||||
"inventory": {
|
||||
"storage": "sqlite",
|
||||
"acceptmismatch": "False",
|
||||
"acceptmismatch": False,
|
||||
},
|
||||
"knownnodes": {
|
||||
"maxnodes": 20000,
|
||||
},
|
||||
"zlib": {
|
||||
"maxsize": 1048576
|
||||
'maxsize': 1048576
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Singleton
|
||||
class BMConfigParser(SafeConfigParser):
|
||||
|
||||
"""
|
||||
Singleton class inherited from :class:`ConfigParser.SafeConfigParser`
|
||||
with additional methods specific to bitmessage config.
|
||||
"""
|
||||
# pylint: disable=too-many-ancestors
|
||||
|
||||
_temp = {}
|
||||
class BMConfigParser(ConfigParser):
|
||||
"""Singleton class inherited from ConfigParser with additional methods
|
||||
specific to bitmessage config."""
|
||||
|
||||
def set(self, section, option, value=None):
|
||||
if self._optcre is self.OPTCRE or value:
|
||||
|
@ -68,123 +59,66 @@ class BMConfigParser(SafeConfigParser):
|
|||
raise TypeError("option values must be strings")
|
||||
if not self.validate(section, option, value):
|
||||
raise ValueError("Invalid value %s" % value)
|
||||
return ConfigParser.ConfigParser.set(self, section, option, value)
|
||||
return ConfigParser.set(self, section, option, value)
|
||||
|
||||
def get(self, section, option, raw=False, vars=None):
|
||||
if sys.version_info[0] == 3:
|
||||
# pylint: disable=arguments-differ
|
||||
def get(self, section, option, *args, raw=False, vars=None, **kwargs):
|
||||
try:
|
||||
if section == "bitmessagesettings" and option == "timeformat":
|
||||
return ConfigParser.ConfigParser.get(
|
||||
self, section, option)
|
||||
try:
|
||||
return self._temp[section][option]
|
||||
except KeyError:
|
||||
pass
|
||||
return ConfigParser.ConfigParser.get(
|
||||
self, section, option)
|
||||
except ConfigParser.InterpolationError:
|
||||
return ConfigParser.ConfigParser.get(
|
||||
self, section, option)
|
||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError) as e:
|
||||
return ConfigParser.get(self, section, option, raw=raw, vars=vars)
|
||||
return ConfigParser.get(self, section, option, raw=True, vars=vars)
|
||||
except InterpolationError:
|
||||
return ConfigParser.get(self, section, option, raw=True, vars=vars)
|
||||
except (NoSectionError, NoOptionError) as e:
|
||||
try:
|
||||
return BMConfigDefaults[section][option]
|
||||
except (KeyError, ValueError, AttributeError):
|
||||
raise e
|
||||
else:
|
||||
# pylint: disable=arguments-differ
|
||||
try:
|
||||
if section == "bitmessagesettings" and option == "timeformat":
|
||||
return ConfigParser.ConfigParser.get(
|
||||
self, section, option, raw, vars)
|
||||
try:
|
||||
return self._temp[section][option]
|
||||
except KeyError:
|
||||
pass
|
||||
return ConfigParser.ConfigParser.get(
|
||||
self, section, option, True, vars)
|
||||
except ConfigParser.InterpolationError:
|
||||
return ConfigParser.ConfigParser.get(
|
||||
self, section, option, True, vars)
|
||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError) as e:
|
||||
try:
|
||||
return BMConfigDefaults[section][option]
|
||||
except (KeyError, ValueError, AttributeError):
|
||||
raise e
|
||||
|
||||
def setTemp(self, section, option, value=None):
|
||||
"""Temporary set option to value, not saving."""
|
||||
try:
|
||||
self._temp[section][option] = value
|
||||
except KeyError:
|
||||
self._temp[section] = {option: value}
|
||||
|
||||
def safeGetBoolean(self, section, field):
|
||||
"""Return value as boolean, False on exceptions"""
|
||||
try:
|
||||
return self.getboolean(section, field)
|
||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError,
|
||||
ValueError, AttributeError):
|
||||
except (NoSectionError, NoOptionError, ValueError, AttributeError):
|
||||
return False
|
||||
|
||||
def safeGetInt(self, section, field, default=0):
|
||||
"""Return value as integer, default on exceptions,
|
||||
0 if default missing"""
|
||||
try:
|
||||
return self.getint(section, field)
|
||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError,
|
||||
except (NoSectionError, NoOptionError,
|
||||
ValueError, AttributeError):
|
||||
return default
|
||||
|
||||
def safeGet(self, section, option, default=None):
|
||||
"""Return value as is, default on exceptions, None if default missing"""
|
||||
try:
|
||||
return self.get(section, option)
|
||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError,
|
||||
except (NoSectionError, NoOptionError,
|
||||
ValueError, AttributeError):
|
||||
return default
|
||||
|
||||
def items(self, section, raw=False, variables=None):
|
||||
"""Return section variables as parent,
|
||||
but override the "raw" argument to always True"""
|
||||
# pylint: disable=arguments-differ
|
||||
return ConfigParser.ConfigParser.items(self, section, True, variables)
|
||||
def items(self, section, vars=None, **kwargs):
|
||||
return ConfigParser.items(self, section, raw=True, vars=vars)
|
||||
|
||||
@staticmethod
|
||||
def addresses():
|
||||
"""Return a list of local bitmessage addresses (from section labels)"""
|
||||
return [
|
||||
x for x in BMConfigParser().sections() if x.startswith('BM-')]
|
||||
|
||||
def _reset(self):
|
||||
"""Reset current config. There doesn't appear to be a built in
|
||||
method for this"""
|
||||
sections = self.sections()
|
||||
for x in sections:
|
||||
self.remove_section(x)
|
||||
def addresses(self):
|
||||
return filter(
|
||||
lambda x: x.startswith('BM-'), BMConfigParser().sections())
|
||||
|
||||
def read(self, filenames):
|
||||
"""Read config and populate defaults"""
|
||||
self._reset()
|
||||
ConfigParser.ConfigParser.read(self, filenames)
|
||||
ConfigParser.read(self, filenames)
|
||||
for section in self.sections():
|
||||
for option in self.options(section):
|
||||
try:
|
||||
if not self.validate(
|
||||
section, option,
|
||||
ConfigParser.ConfigParser.get(self, section, option)
|
||||
self.get(section, option)
|
||||
):
|
||||
try:
|
||||
newVal = BMConfigDefaults[section][option]
|
||||
except KeyError:
|
||||
continue
|
||||
ConfigParser.ConfigParser.set(
|
||||
self, section, option, newVal)
|
||||
except ConfigParser.InterpolationError:
|
||||
self.set(section, option, newVal)
|
||||
except InterpolationError:
|
||||
continue
|
||||
|
||||
def save(self):
|
||||
"""Save the runtime config onto the filesystem"""
|
||||
fileName = os.path.join(state.appdata, 'keys.dat')
|
||||
fileNameBak = '.'.join([
|
||||
fileName, datetime.now().strftime("%Y%j%H%M%S%f"), 'bak'])
|
||||
|
@ -199,22 +133,19 @@ class BMConfigParser(SafeConfigParser):
|
|||
# didn't exist before.
|
||||
fileNameExisted = False
|
||||
# write the file
|
||||
with open(fileName, 'wb') as configfile:
|
||||
with open(fileName, 'w') as configfile:
|
||||
self.write(configfile)
|
||||
# delete the backup
|
||||
if fileNameExisted:
|
||||
os.remove(fileNameBak)
|
||||
|
||||
def validate(self, section, option, value):
|
||||
"""Input validator interface (using factory pattern)"""
|
||||
try:
|
||||
return getattr(self, 'validate_%s_%s' % (section, option))(value)
|
||||
except AttributeError:
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def validate_bitmessagesettings_maxoutboundconnections(value):
|
||||
"""Reject maxoutboundconnections that are too high or too low"""
|
||||
def validate_bitmessagesettings_maxoutboundconnections(self, value):
|
||||
try:
|
||||
value = int(value)
|
||||
except ValueError:
|
||||
|
@ -222,4 +153,3 @@ class BMConfigParser(SafeConfigParser):
|
|||
if value < 0 or value > 8:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
"""Building osx."""
|
||||
import os
|
||||
from glob import glob
|
||||
import os
|
||||
from PyQt4 import QtCore
|
||||
from setuptools import setup
|
||||
|
||||
|
@ -13,26 +12,20 @@ DATA_FILES = [
|
|||
('bitmsghash', ['bitmsghash/bitmsghash.cl', 'bitmsghash/bitmsghash.so']),
|
||||
('translations', glob('translations/*.qm')),
|
||||
('ui', glob('bitmessageqt/*.ui')),
|
||||
(
|
||||
'translations',
|
||||
glob(os.path.join(str(QtCore.QLibraryInfo.location(
|
||||
QtCore.QLibraryInfo.TranslationsPath)), 'qt_??.qm'))),
|
||||
(
|
||||
'translations',
|
||||
glob(os.path.join(str(QtCore.QLibraryInfo.location(
|
||||
QtCore.QLibraryInfo.TranslationsPath)), 'qt_??_??.qm'))),
|
||||
('translations', glob(str(QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)) + '/qt_??.qm')),
|
||||
('translations', glob(str(QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)) + '/qt_??_??.qm')),
|
||||
]
|
||||
|
||||
setup(
|
||||
name=name,
|
||||
version=version,
|
||||
app=mainscript,
|
||||
data_files=DATA_FILES,
|
||||
setup_requires=["py2app"],
|
||||
options=dict(
|
||||
py2app=dict(
|
||||
includes=['sip', 'PyQt4._qt'],
|
||||
iconfile="images/bitmessage.icns"
|
||||
name = name,
|
||||
version = version,
|
||||
app = mainscript,
|
||||
data_files = DATA_FILES,
|
||||
setup_requires = ["py2app"],
|
||||
options = dict(
|
||||
py2app = dict(
|
||||
includes = ['sip', 'PyQt4._qt'],
|
||||
iconfile = "images/bitmessage.icns"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
275
src/buildozer.spec
Normal file
275
src/buildozer.spec
Normal file
|
@ -0,0 +1,275 @@
|
|||
[app]
|
||||
|
||||
# (str) Title of your application
|
||||
title = PyBitmessage
|
||||
|
||||
# (str) Package name
|
||||
package.name = PyBitmessage
|
||||
|
||||
# (str) Package domain (needed for android/ios packaging)
|
||||
package.domain = org.test
|
||||
|
||||
# (str) Source code where the main.py live
|
||||
source.dir = .
|
||||
|
||||
# (list) Source files to include (let empty to include all the files)
|
||||
source.include_exts = py,png,jpg,kv,atlas
|
||||
|
||||
# (list) List of inclusions using pattern matching
|
||||
#source.include_patterns = assets/*,images/*.png
|
||||
|
||||
# (list) Source files to exclude (let empty to not exclude anything)
|
||||
#source.exclude_exts = spec
|
||||
|
||||
# (list) List of directory to exclude (let empty to not exclude anything)
|
||||
#source.exclude_dirs = tests, bin
|
||||
|
||||
# (list) List of exclusions using pattern matching
|
||||
#source.exclude_patterns = license,images/*/*.jpg
|
||||
|
||||
# (str) Application versioning (method 1)
|
||||
version = 0.1
|
||||
|
||||
# (str) Application versioning (method 2)
|
||||
# version.regex = __version__ = ['"](.*)['"]
|
||||
# version.filename = %(source.dir)s/main.py
|
||||
|
||||
# (list) Application requirements
|
||||
# comma seperated e.g. requirements = sqlite3,kivy
|
||||
requirements = python2, sqlite3, kivy, openssl
|
||||
|
||||
# (str) Custom source folders for requirements
|
||||
# Sets custom source for any requirements with recipes
|
||||
# requirements.source.kivy = ../../kivy
|
||||
#requirements.source.sqlite3 =
|
||||
|
||||
# (list) Garden requirements
|
||||
#garden_requirements =
|
||||
|
||||
# (str) Presplash of the application
|
||||
#presplash.filename = %(source.dir)s/data/presplash.png
|
||||
|
||||
# (str) Icon of the application
|
||||
#icon.filename = %(source.dir)s/data/icon.png
|
||||
|
||||
# (str) Supported orientation (one of landscape, portrait or all)
|
||||
orientation = portrait
|
||||
|
||||
# (list) List of service to declare
|
||||
#services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY
|
||||
|
||||
#
|
||||
# OSX Specific
|
||||
#
|
||||
|
||||
#
|
||||
# author = © Copyright Info
|
||||
|
||||
# change the major version of python used by the app
|
||||
#osx.python_version = 2
|
||||
|
||||
|
||||
# Kivy version to use
|
||||
osx.kivy_version = 1.9.1
|
||||
|
||||
#
|
||||
# Android specific
|
||||
#
|
||||
|
||||
# (bool) Indicate if the application should be fullscreen or not
|
||||
fullscreen = 0
|
||||
|
||||
# (string) Presplash background color (for new android toolchain)
|
||||
# Supported formats are: #RRGGBB #AARRGGBB or one of the following names:
|
||||
# red, blue, green, black, white, gray, cyan, magenta, yellow, lightgray,
|
||||
# darkgray, grey, lightgrey, darkgrey, aqua, fuchsia, lime, maroon, navy,
|
||||
# olive, purple, silver, teal.
|
||||
#android.presplash_color = #FFFFFF
|
||||
|
||||
# (list) Permissions
|
||||
android.permissions = INTERNET
|
||||
|
||||
# (int) Android API to use
|
||||
#android.api = 19
|
||||
|
||||
# (int) Minimum API required
|
||||
#android.minapi = 9
|
||||
|
||||
# (int) Android SDK version to use
|
||||
#android.sdk = 20
|
||||
|
||||
# (str) Android NDK version to use
|
||||
#android.ndk = 9c
|
||||
|
||||
# (bool) Use --private data storage (True) or --dir public storage (False)
|
||||
#android.private_storage = True
|
||||
|
||||
# (str) Android NDK directory (if empty, it will be automatically downloaded.)
|
||||
#android.ndk_path =
|
||||
|
||||
# (str) Android SDK directory (if empty, it will be automatically downloaded.)
|
||||
#android.sdk_path =
|
||||
|
||||
# (str) ANT directory (if empty, it will be automatically downloaded.)
|
||||
#android.ant_path =
|
||||
|
||||
# (bool) If True, then skip trying to update the Android sdk
|
||||
# This can be useful to avoid excess Internet downloads or save time
|
||||
# when an update is due and you just want to test/build your package
|
||||
# android.skip_update = False
|
||||
|
||||
# (str) Android entry point, default is ok for Kivy-based app
|
||||
#android.entrypoint = org.renpy.android.PythonActivity
|
||||
|
||||
# (list) Pattern to whitelist for the whole project
|
||||
#android.whitelist =
|
||||
|
||||
android.whitelist = /usr/lib/komodo-edit/python/lib/python2.7/lib-dynload/_sqlite3.so
|
||||
|
||||
|
||||
# (str) Path to a custom whitelist file
|
||||
#android.whitelist_src =
|
||||
|
||||
# (str) Path to a custom blacklist file
|
||||
#android.blacklist_src =
|
||||
|
||||
# (list) List of Java .jar files to add to the libs so that pyjnius can access
|
||||
# their classes. Don't add jars that you do not need, since extra jars can slow
|
||||
# down the build process. Allows wildcards matching, for example:
|
||||
# OUYA-ODK/libs/*.jar
|
||||
#android.add_jars = foo.jar,bar.jar,path/to/more/*.jar
|
||||
|
||||
# (list) List of Java files to add to the android project (can be java or a
|
||||
# directory containing the files)
|
||||
#android.add_src =
|
||||
|
||||
# (list) Android AAR archives to add (currently works only with sdl2_gradle
|
||||
# bootstrap)
|
||||
#android.add_aars =
|
||||
|
||||
# (list) Gradle dependencies to add (currently works only with sdl2_gradle
|
||||
# bootstrap)
|
||||
#android.gradle_dependencies =
|
||||
, /home/cis/Downloads/libssl1.0.2_1.0.2l-2+deb9u2_amd64
|
||||
# (str) python-for-android branch to use, defaults to stable
|
||||
#p4a.branch = stable
|
||||
|
||||
# (str) OUYA Console category. Should be one of GAME or APP
|
||||
# If you leave this blank, OUYA support will not be enabled
|
||||
#android.ouya.category = GAME
|
||||
|
||||
# (str) Filename of OUYA Console icon. It must be a 732x412 png image.
|
||||
#android.ouya.icon.filename = %(source.dir)s/data/ouya_icon.png
|
||||
|
||||
# (str) XML file to include as an intent filters in <activity> tag
|
||||
#android.manifest.intent_filters =
|
||||
|
||||
# (list) Android additionnal libraries to copy into libs/armeabi
|
||||
#android.add_libs_armeabi = libs/android/*.so
|
||||
#android.add_libs_armeabi_v7a = libs/android-v7/*.so
|
||||
#android.add_libs_x86 = libs/android-x86/*.so
|
||||
#android.add_libs_mips = libs/android-mips/*.so
|
||||
|
||||
# (bool) Indicate whether the screen should stay on
|
||||
# Don't forget to add the WAKE_LOCK permission if you set this to True
|
||||
#android.wakelock = False
|
||||
|
||||
# (list) Android application meta-data to set (key=value format)
|
||||
#android.meta_data =
|
||||
|
||||
# (list) Android library project to add (will be added in the
|
||||
# project.properties automatically.)
|
||||
#android.library_references =
|
||||
|
||||
# (str) Android logcat filters to use
|
||||
#android.logcat_filters = *:S python:D
|
||||
|
||||
# (bool) Copy library instead of making a libpymodules.so
|
||||
#android.copy_libs = 1
|
||||
|
||||
# (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86
|
||||
android.arch = armeabi-v7a
|
||||
|
||||
#
|
||||
# Python for android (p4a) specific
|
||||
#
|
||||
|
||||
# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
|
||||
#p4a.source_dir =
|
||||
|
||||
# (str) The directory in which python-for-android should look for your own build recipes (if any)
|
||||
#p4a.local_recipes =
|
||||
|
||||
# (str) Filename to the hook for p4a
|
||||
#p4a.hook =
|
||||
|
||||
# (str) Bootstrap to use for android builds
|
||||
# p4a.bootstrap = sdl2
|
||||
|
||||
|
||||
#
|
||||
# iOS specific
|
||||
#
|
||||
|
||||
# (str) Path to a custom kivy-ios folder
|
||||
#ios.kivy_ios_dir = ../kivy-ios
|
||||
|
||||
# (str) Name of the certificate to use for signing the debug version
|
||||
# Get a list of available identities: buildozer ios list_identities
|
||||
#ios.codesign.debug = "iPhone Developer: <lastname> <firstname> (<hexstring>)"
|
||||
|
||||
# (str) Name of the certificate to use for signing the release version
|
||||
#ios.codesign.release = %(ios.codesign.debug)s
|
||||
|
||||
|
||||
[buildozer]
|
||||
|
||||
# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
|
||||
log_level = 2
|
||||
|
||||
# (int) Display warning if buildozer is run as root (0 = False, 1 = True)
|
||||
warn_on_root = 1
|
||||
|
||||
# (str) Path to build artifact storage, absolute or relative to spec file
|
||||
# build_dir = ./.buildozer
|
||||
|
||||
# (str) Path to build output (i.e. .apk, .ipa) storage
|
||||
# bin_dir = ./bin
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# List as sections
|
||||
#
|
||||
# You can define all the "list" as [section:key].
|
||||
# Each line will be considered as a option to the list.
|
||||
# Let's take [app] / source.exclude_patterns.
|
||||
# Instead of doing:
|
||||
#
|
||||
#[app]
|
||||
#source.exclude_patterns = license,data/audio/*.wav,data/images/original/*
|
||||
#
|
||||
# This can be translated into:
|
||||
#
|
||||
#[app:source.exclude_patterns]
|
||||
#license
|
||||
#data/audio/*.wav
|
||||
#data/images/original/*
|
||||
#
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Profiles
|
||||
#
|
||||
# You can extend section / key with a profile
|
||||
# For example, you want to deploy a demo version of your application without
|
||||
# HD content. You could first change the title to add "(demo)" in the name
|
||||
# and extend the excluded directories to remove the HD content.
|
||||
#
|
||||
#[app@demo]
|
||||
#title = My Application (demo)
|
||||
#
|
||||
#[app:source.exclude_patterns@demo]
|
||||
#images/hd/*
|
||||
#
|
||||
# Then, invoke the command line with the "demo" profile:
|
||||
#
|
||||
#buildozer --profile demo android debug
|
|
@ -1,28 +1,30 @@
|
|||
"""
|
||||
A thread for creating addresses
|
||||
"""
|
||||
import hashlib
|
||||
import time
|
||||
from binascii import hexlify
|
||||
|
||||
import defaults
|
||||
import highlevelcrypto
|
||||
import queues
|
||||
import shared
|
||||
import state
|
||||
import tr
|
||||
from addresses import decodeAddress, encodeAddress, encodeVarint
|
||||
from bmconfigparser import BMConfigParser
|
||||
from fallback import RIPEMD160Hash
|
||||
from network import StoppableThread
|
||||
import time
|
||||
import threading
|
||||
import hashlib
|
||||
from binascii import hexlify
|
||||
from pyelliptic import arithmetic
|
||||
from pyelliptic.openssl import OpenSSL
|
||||
|
||||
import tr
|
||||
import queues
|
||||
import state
|
||||
import shared
|
||||
import defaults
|
||||
import highlevelcrypto
|
||||
from bmconfigparser import BMConfigParser
|
||||
from debug import logger
|
||||
from addresses import decodeAddress, encodeAddress, encodeVarint
|
||||
from fallback import RIPEMD160Hash
|
||||
from helper_threading import StoppableThread
|
||||
|
||||
class addressGenerator(StoppableThread):
|
||||
"""A thread for creating addresses"""
|
||||
|
||||
name = "addressGenerator"
|
||||
class addressGenerator(threading.Thread, StoppableThread):
|
||||
|
||||
def __init__(self):
|
||||
# QThread.__init__(self, parent)
|
||||
threading.Thread.__init__(self, name="addressGenerator")
|
||||
self.initStop()
|
||||
|
||||
def stopThread(self):
|
||||
try:
|
||||
|
@ -32,12 +34,6 @@ class addressGenerator(StoppableThread):
|
|||
super(addressGenerator, self).stopThread()
|
||||
|
||||
def run(self):
|
||||
"""
|
||||
Process the requests for addresses generation
|
||||
from `.queues.addressGeneratorQueue`
|
||||
"""
|
||||
# pylint: disable=too-many-locals, too-many-branches
|
||||
# pylint: disable=protected-access, too-many-statements
|
||||
while state.shutdown == 0:
|
||||
queueValue = queues.addressGeneratorQueue.get()
|
||||
nonceTrialsPerByte = 0
|
||||
|
@ -93,12 +89,12 @@ class addressGenerator(StoppableThread):
|
|||
elif queueValue[0] == 'stopThread':
|
||||
break
|
||||
else:
|
||||
self.logger.error(
|
||||
logger.error(
|
||||
'Programming error: A structure with the wrong number'
|
||||
' of values was passed into the addressGeneratorQueue.'
|
||||
' Here is the queueValue: %r\n', queueValue)
|
||||
if addressVersionNumber < 3 or addressVersionNumber > 4:
|
||||
self.logger.error(
|
||||
logger.error(
|
||||
'Program error: For some reason the address generator'
|
||||
' queue has been given a request to create at least'
|
||||
' one version %s address which it cannot do.\n',
|
||||
|
@ -147,10 +143,10 @@ class addressGenerator(StoppableThread):
|
|||
'\x00' * numberOfNullBytesDemandedOnFrontOfRipeHash
|
||||
):
|
||||
break
|
||||
self.logger.info(
|
||||
logger.info(
|
||||
'Generated address with ripe digest: %s', hexlify(ripe))
|
||||
try:
|
||||
self.logger.info(
|
||||
logger.info(
|
||||
'Address generator calculated %s addresses at %s'
|
||||
' addresses per second before finding one with'
|
||||
' the correct ripe-prefix.',
|
||||
|
@ -217,8 +213,8 @@ class addressGenerator(StoppableThread):
|
|||
elif command == 'createDeterministicAddresses' \
|
||||
or command == 'getDeterministicAddress' \
|
||||
or command == 'createChan' or command == 'joinChan':
|
||||
if not deterministicPassphrase:
|
||||
self.logger.warning(
|
||||
if len(deterministicPassphrase) == 0:
|
||||
logger.warning(
|
||||
'You are creating deterministic'
|
||||
' address(es) using a blank passphrase.'
|
||||
' Bitmessage will do it but it is rather stupid.')
|
||||
|
@ -271,10 +267,10 @@ class addressGenerator(StoppableThread):
|
|||
):
|
||||
break
|
||||
|
||||
self.logger.info(
|
||||
logger.info(
|
||||
'Generated address with ripe digest: %s', hexlify(ripe))
|
||||
try:
|
||||
self.logger.info(
|
||||
logger.info(
|
||||
'Address generator calculated %s addresses'
|
||||
' at %s addresses per second before finding'
|
||||
' one with the correct ripe-prefix.',
|
||||
|
@ -324,7 +320,7 @@ class addressGenerator(StoppableThread):
|
|||
addressAlreadyExists = True
|
||||
|
||||
if addressAlreadyExists:
|
||||
self.logger.info(
|
||||
logger.info(
|
||||
'%s already exists. Not adding it again.',
|
||||
address
|
||||
)
|
||||
|
@ -337,7 +333,7 @@ class addressGenerator(StoppableThread):
|
|||
).arg(address)
|
||||
))
|
||||
else:
|
||||
self.logger.debug('label: %s', label)
|
||||
logger.debug('label: %s', label)
|
||||
BMConfigParser().set(address, 'label', label)
|
||||
BMConfigParser().set(address, 'enabled', 'true')
|
||||
BMConfigParser().set(address, 'decoy', 'false')
|
||||
|
|
|
@ -1,40 +1,32 @@
|
|||
"""
|
||||
The objectProcessor thread, of which there is only one,
|
||||
processes the network objects
|
||||
"""
|
||||
# pylint: disable=too-many-locals,too-many-return-statements
|
||||
# pylint: disable=too-many-branches,too-many-statements
|
||||
import hashlib
|
||||
import logging
|
||||
import random
|
||||
import shared
|
||||
import threading
|
||||
import time
|
||||
from binascii import hexlify
|
||||
from subprocess import call # nosec
|
||||
|
||||
import highlevelcrypto
|
||||
import knownnodes
|
||||
from addresses import (
|
||||
calculateInventoryHash, decodeAddress, decodeVarint, encodeAddress,
|
||||
encodeVarint, varintDecodeError
|
||||
)
|
||||
from bmconfigparser import BMConfigParser
|
||||
import helper_bitcoin
|
||||
import helper_inbox
|
||||
import helper_msgcoding
|
||||
import helper_sent
|
||||
import highlevelcrypto
|
||||
import l10n
|
||||
from helper_sql import SqlBulkExecute, sqlExecute, sqlQuery
|
||||
from helper_ackPayload import genAckPayload
|
||||
from network.fix_circular_imports import BMStringParser
|
||||
import protocol
|
||||
import queues
|
||||
import shared
|
||||
import state
|
||||
import tr
|
||||
from addresses import (
|
||||
calculateInventoryHash, decodeAddress, decodeVarint,
|
||||
encodeAddress, encodeVarint, varintDecodeError
|
||||
)
|
||||
from bmconfigparser import BMConfigParser
|
||||
from debug import logger
|
||||
from fallback import RIPEMD160Hash
|
||||
from helper_sql import sql_ready, SqlBulkExecute, sqlExecute, sqlQuery
|
||||
from network import bmproto, knownnodes
|
||||
from network.node import Peer
|
||||
# pylint: disable=too-many-locals, too-many-return-statements, too-many-branches, too-many-statements
|
||||
|
||||
logger = logging.getLogger('default')
|
||||
import l10n
|
||||
|
||||
|
||||
class objectProcessor(threading.Thread):
|
||||
|
@ -43,14 +35,12 @@ class objectProcessor(threading.Thread):
|
|||
objects (msg, broadcast, pubkey, getpubkey) from the receiveDataThreads.
|
||||
"""
|
||||
def __init__(self):
|
||||
threading.Thread.__init__(self, name="objectProcessor")
|
||||
random.seed()
|
||||
# It may be the case that the last time Bitmessage was running,
|
||||
# the user closed it before it finished processing everything in the
|
||||
# objectProcessorQueue. Assuming that Bitmessage wasn't closed
|
||||
# forcefully, it should have saved the data in the queue into the
|
||||
# objectprocessorqueue table. Let's pull it out.
|
||||
sql_ready.wait()
|
||||
threading.Thread.__init__(self, name="objectProcessor")
|
||||
queryreturn = sqlQuery(
|
||||
'''SELECT objecttype, data FROM objectprocessorqueue''')
|
||||
for row in queryreturn:
|
||||
|
@ -60,11 +50,10 @@ class objectProcessor(threading.Thread):
|
|||
logger.debug(
|
||||
'Loaded %s objects from disk into the objectProcessorQueue.',
|
||||
len(queryreturn))
|
||||
self._ack_obj = bmproto.BMStringParser()
|
||||
self._ack_obj = BMStringParser()
|
||||
self.successfullyDecryptMessageTimings = []
|
||||
|
||||
def run(self):
|
||||
"""Process the objects from `.queues.objectProcessorQueue`"""
|
||||
while True:
|
||||
objectType, data = queues.objectProcessorQueue.get()
|
||||
|
||||
|
@ -128,10 +117,7 @@ class objectProcessor(threading.Thread):
|
|||
state.shutdown = 2
|
||||
break
|
||||
|
||||
@staticmethod
|
||||
def checkackdata(data):
|
||||
"""Checking Acknowledgement of message received or not?"""
|
||||
# pylint: disable=protected-access
|
||||
def checkackdata(self, data):
|
||||
# Let's check whether this is a message acknowledgement bound for us.
|
||||
if len(data) < 32:
|
||||
return
|
||||
|
@ -139,22 +125,20 @@ class objectProcessor(threading.Thread):
|
|||
# bypass nonce and time, retain object type/version/stream + body
|
||||
readPosition = 16
|
||||
|
||||
if data[readPosition:] in state.ackdataForWhichImWatching:
|
||||
if data[readPosition:] in shared.ackdataForWhichImWatching:
|
||||
logger.info('This object is an acknowledgement bound for me.')
|
||||
del state.ackdataForWhichImWatching[data[readPosition:]]
|
||||
del shared.ackdataForWhichImWatching[data[readPosition:]]
|
||||
sqlExecute(
|
||||
'UPDATE sent SET status=?, lastactiontime=?'
|
||||
' WHERE ackdata=?',
|
||||
'ackreceived', int(time.time()), data[readPosition:])
|
||||
queues.UISignalQueue.put((
|
||||
'updateSentItemStatusByAckdata',
|
||||
(
|
||||
data[readPosition:],
|
||||
(data[readPosition:],
|
||||
tr._translate(
|
||||
"MainWindow",
|
||||
"Acknowledgement of the message received %1"
|
||||
).arg(l10n.formatTimestamp())
|
||||
)
|
||||
).arg(l10n.formatTimestamp()))
|
||||
))
|
||||
else:
|
||||
logger.debug('This object is not an acknowledgement bound for me.')
|
||||
|
@ -167,15 +151,14 @@ class objectProcessor(threading.Thread):
|
|||
readPosition += length
|
||||
stream, length = decodeVarint(data[readPosition:readPosition + 10])
|
||||
readPosition += length
|
||||
# it seems that stream is checked in network.bmproto
|
||||
# it seems that stream is checked in network.fix_circular_imports
|
||||
port, length = decodeVarint(data[readPosition:readPosition + 10])
|
||||
host = protocol.checkIPAddress(data[readPosition + length:])
|
||||
|
||||
if not host:
|
||||
return
|
||||
peer = Peer(host, port)
|
||||
peer = state.Peer(host, port)
|
||||
with knownnodes.knownNodesLock:
|
||||
# FIXME: adjust expirestime
|
||||
knownnodes.addKnownNode(
|
||||
stream, peer, is_self=state.ownAddresses.get(peer))
|
||||
|
||||
|
@ -284,9 +267,8 @@ class objectProcessor(threading.Thread):
|
|||
queues.workerQueue.put(('sendOutOrStoreMyV4Pubkey', myAddress))
|
||||
|
||||
def processpubkey(self, data):
|
||||
"""Process a pubkey object"""
|
||||
pubkeyProcessingStartTime = time.time()
|
||||
state.numberOfPubkeysProcessed += 1
|
||||
shared.numberOfPubkeysProcessed += 1
|
||||
queues.UISignalQueue.put((
|
||||
'updateNumberOfPubkeysProcessed', 'no data'))
|
||||
readPosition = 20 # bypass the nonce, time, and object type
|
||||
|
@ -333,7 +315,6 @@ class objectProcessor(threading.Thread):
|
|||
'\x04' + publicSigningKey + '\x04' + publicEncryptionKey)
|
||||
ripe = RIPEMD160Hash(sha.digest()).digest()
|
||||
|
||||
if logger.isEnabledFor(logging.DEBUG):
|
||||
logger.debug(
|
||||
'within recpubkey, addressVersion: %s, streamNumber: %s'
|
||||
'\nripe %s\npublicSigningKey in hex: %s'
|
||||
|
@ -398,7 +379,6 @@ class objectProcessor(threading.Thread):
|
|||
sha.update(publicSigningKey + publicEncryptionKey)
|
||||
ripe = RIPEMD160Hash(sha.digest()).digest()
|
||||
|
||||
if logger.isEnabledFor(logging.DEBUG):
|
||||
logger.debug(
|
||||
'within recpubkey, addressVersion: %s, streamNumber: %s'
|
||||
'\nripe %s\npublicSigningKey in hex: %s'
|
||||
|
@ -457,9 +437,8 @@ class objectProcessor(threading.Thread):
|
|||
timeRequiredToProcessPubkey)
|
||||
|
||||
def processmsg(self, data):
|
||||
"""Process a message object"""
|
||||
messageProcessingStartTime = time.time()
|
||||
state.numberOfMessagesProcessed += 1
|
||||
shared.numberOfMessagesProcessed += 1
|
||||
queues.UISignalQueue.put((
|
||||
'updateNumberOfMessagesProcessed', 'no data'))
|
||||
readPosition = 20 # bypass the nonce, time, and object type
|
||||
|
@ -576,6 +555,7 @@ class objectProcessor(threading.Thread):
|
|||
decryptedData[readPosition:readPosition + 10])
|
||||
readPosition += messageLengthLength
|
||||
message = decryptedData[readPosition:readPosition + messageLength]
|
||||
# print 'First 150 characters of message:', repr(message[:150])
|
||||
readPosition += messageLength
|
||||
ackLength, ackLengthLength = decodeVarint(
|
||||
decryptedData[readPosition:readPosition + 10])
|
||||
|
@ -598,7 +578,6 @@ class objectProcessor(threading.Thread):
|
|||
logger.debug('ECDSA verify failed')
|
||||
return
|
||||
logger.debug('ECDSA verify passed')
|
||||
if logger.isEnabledFor(logging.DEBUG):
|
||||
logger.debug(
|
||||
'As a matter of intellectual curiosity, here is the Bitcoin'
|
||||
' address associated with the keys owned by the other person:'
|
||||
|
@ -646,8 +625,7 @@ class objectProcessor(threading.Thread):
|
|||
if decodeAddress(toAddress)[1] >= 3 \
|
||||
and not BMConfigParser().safeGetBoolean(toAddress, 'chan'):
|
||||
# If I'm not friendly with this person:
|
||||
if not shared.isAddressInMyAddressBookSubscriptionsListOrWhitelist(
|
||||
fromAddress):
|
||||
if not shared.isAddressInMyAddressBookSubscriptionsListOrWhitelist(fromAddress):
|
||||
requiredNonceTrialsPerByte = BMConfigParser().getint(
|
||||
toAddress, 'noncetrialsperbyte')
|
||||
requiredPayloadLengthExtraBytes = BMConfigParser().getint(
|
||||
|
@ -744,14 +722,32 @@ class objectProcessor(threading.Thread):
|
|||
# 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.
|
||||
toAddress = '[Broadcast subscribers]'
|
||||
streamNumber = decodeAddress(fromAddress)[2]
|
||||
|
||||
ackdata = helper_sent.insert(
|
||||
fromAddress=fromAddress,
|
||||
status='broadcastqueued',
|
||||
subject=subject,
|
||||
message=message,
|
||||
encoding=messageEncodingType)
|
||||
ackdata = genAckPayload(streamNumber, 0)
|
||||
toAddress = '[Broadcast subscribers]'
|
||||
ripe = ''
|
||||
|
||||
# We really should have a discussion about how to
|
||||
# set the TTL for mailing list broadcasts. This is obviously
|
||||
# hard-coded.
|
||||
TTL = 2*7*24*60*60 # 2 weeks
|
||||
t = ('',
|
||||
toAddress,
|
||||
ripe,
|
||||
fromAddress,
|
||||
subject,
|
||||
message,
|
||||
ackdata,
|
||||
int(time.time()), # sentTime (this doesn't change)
|
||||
int(time.time()), # lastActionTime
|
||||
0,
|
||||
'broadcastqueued',
|
||||
0,
|
||||
'sent',
|
||||
messageEncodingType,
|
||||
TTL)
|
||||
helper_sent.insert(t)
|
||||
|
||||
queues.UISignalQueue.put((
|
||||
'displayNewSentMessage', (
|
||||
|
@ -787,9 +783,8 @@ class objectProcessor(threading.Thread):
|
|||
)
|
||||
|
||||
def processbroadcast(self, data):
|
||||
"""Process a broadcast object"""
|
||||
messageProcessingStartTime = time.time()
|
||||
state.numberOfBroadcastsProcessed += 1
|
||||
shared.numberOfBroadcastsProcessed += 1
|
||||
queues.UISignalQueue.put((
|
||||
'updateNumberOfBroadcastsProcessed', 'no data'))
|
||||
inventoryHash = calculateInventoryHash(data)
|
||||
|
@ -972,7 +967,7 @@ class objectProcessor(threading.Thread):
|
|||
|
||||
fromAddress = encodeAddress(
|
||||
sendersAddressVersion, sendersStream, calculatedRipe)
|
||||
logger.info('fromAddress: %s', fromAddress)
|
||||
logger.info('fromAddress: %s' % fromAddress)
|
||||
|
||||
# Let's store the public key in case we want to reply to this person.
|
||||
sqlExecute('''INSERT INTO pubkeys VALUES (?,?,?,?,?)''',
|
||||
|
@ -989,7 +984,7 @@ class objectProcessor(threading.Thread):
|
|||
|
||||
fromAddress = encodeAddress(
|
||||
sendersAddressVersion, sendersStream, calculatedRipe)
|
||||
logger.debug('fromAddress: %s', fromAddress)
|
||||
logger.debug('fromAddress: ' + fromAddress)
|
||||
|
||||
try:
|
||||
decodedMessage = helper_msgcoding.MsgDecode(
|
||||
|
@ -1050,18 +1045,17 @@ class objectProcessor(threading.Thread):
|
|||
# for it.
|
||||
elif addressVersion >= 4:
|
||||
tag = hashlib.sha512(hashlib.sha512(
|
||||
encodeVarint(addressVersion) + encodeVarint(streamNumber)
|
||||
+ ripe
|
||||
encodeVarint(addressVersion) + encodeVarint(streamNumber) + ripe
|
||||
).digest()).digest()[32:]
|
||||
if tag in state.neededPubkeys:
|
||||
del state.neededPubkeys[tag]
|
||||
self.sendMessages(address)
|
||||
|
||||
@staticmethod
|
||||
def sendMessages(address):
|
||||
def sendMessages(self, address):
|
||||
"""
|
||||
This method is called by the `possibleNewPubkey` when it sees
|
||||
that we now have the necessary pubkey to send one or more messages.
|
||||
This function is called by the possibleNewPubkey function when
|
||||
that function sees that we now have the necessary pubkey
|
||||
to send one or more messages.
|
||||
"""
|
||||
logger.info('We have been awaiting the arrival of this pubkey.')
|
||||
sqlExecute(
|
||||
|
@ -1071,9 +1065,7 @@ class objectProcessor(threading.Thread):
|
|||
" AND folder='sent'", address)
|
||||
queues.workerQueue.put(('sendmessage', ''))
|
||||
|
||||
@staticmethod
|
||||
def ackDataHasAValidHeader(ackData):
|
||||
"""Checking ackData with valid Header, not sending ackData when false"""
|
||||
def ackDataHasAValidHeader(self, ackData):
|
||||
if len(ackData) < protocol.Header.size:
|
||||
logger.info(
|
||||
'The length of ackData is unreasonably short. Not sending'
|
||||
|
@ -1108,12 +1100,11 @@ class objectProcessor(threading.Thread):
|
|||
return False
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def addMailingListNameToSubject(subject, mailingListName):
|
||||
"""Adding mailingListName to subject"""
|
||||
def addMailingListNameToSubject(self, subject, mailingListName):
|
||||
subject = subject.strip()
|
||||
if subject[:3] == 'Re:' or subject[:3] == 'RE:':
|
||||
subject = subject[3:].strip()
|
||||
if '[' + mailingListName + ']' in subject:
|
||||
return subject
|
||||
else:
|
||||
return '[' + mailingListName + '] ' + subject
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user