Compare commits

...

22 Commits

Author SHA1 Message Date
288b54be6c restore rescan height dialog, use safe clear+resync approach 2026-03-22 11:23:48 -05:00
221231b53b fix rescan crash: use clear+resync instead of reinitializing lightclient 2026-03-22 11:16:50 -05:00
b7a04bebc1 fix rescan crash: shutdown old lightclient before overwriting 2026-03-22 11:12:19 -05:00
f5d26dd34d fix wallet restore: pass overwrite=true to allow restoring over existing wallet 2026-03-22 11:08:05 -05:00
ff8368ca97 fix birthday parse: treat empty input as 0, update hashes 2026-03-22 10:59:30 -05:00
7ec272df90 v1.1.1: release build with tx display fix, birthday parse fix 2026-03-22 10:52:25 -05:00
e2071653b9 Rebuild with memo filter fix for change detection
The previous fix checked memo.to_utf8().is_none() but empty memos
(all-zero bytes) have first byte 0x00 < 0xF5, so to_utf8() returns
Some(Ok("")) not None. Change outputs were never filtered.
Now checks for empty string as well as None.
2026-03-22 10:36:09 -05:00
90383b0f43 v1.1.1: Bump version, fix CFLAGS in lib/Makefile, rebuild binaries
- Bump APP_VERSION from 1.1.0 to 1.1.1
- Fix CFLAGS in lib/Makefile: remove quoted empty string that broke
  blake3 cross-compilation
- Rebuild Linux and Windows binaries with IVK change detection fix
- Update SHA-256 hashes in release notes
2026-03-22 10:02:51 -05:00
5fe5447474 v1.1.1: Fix sent tx showing wrong addresses, fix CRLF line endings in build.sh
- Fix change output detection using IVK-based decryption instead of
  static address list, so sent transactions only show the actual
  recipient address
- Fix CRLF line endings in build.sh
- Add release notes for v1.1.1
- Update Linux binary
2026-03-22 09:27:56 -05:00
cc34cc3f21 Add clean shutdown, wallet safety, and UI contrast fixes
Shutdown:
- Call litelib_shutdown() to stop Rust background threads on exit
- Add 15-second timeout on wallet save dialog to prevent hang on close
- Add litelib_shutdown FFI declaration in header and controller

UI Contrast (dragonx theme):
- Fix disabled buttons: white text was invisible on white background
- Add QWizard, QMessageBox, QTextBrowser, QPlainTextEdit styling for dark theme
- Add QCheckBox, QRadioButton, QDialogButtonBox contrast rules
- Fix seed word verification buttons: dark themed with explicit text color
- Fix chat bubbles: replace light backgrounds with dark themed colors
- Fix Terms of Service link color: #0000ff -> #6699ff for visibility
- Remove duplicate conflicting QLabel#lblMessage CSS rule

Add v1.1.0 release notes with checksums
2026-03-21 05:39:19 -05:00
e601048fd8 bump version to v1.1.0 2026-03-21 04:42:20 -05:00
cd5a9f3736 DragonX compatibility: crash fixes, reorg detection, server failover, sync perf
- Fix Rust FFI panics with catch_unwind wrappers and safe CString handling
- Handle poisoned mutex/RwLock from prior panics instead of crashing
- Add stuck sync detection (10s stall threshold) and chain reorg user prompt
- Add "Skip Verification" button to seed phrase wizard
- Update payment URIs from hush: to drgx:
- Update branding strings throughout UI
- Add all 6 lite servers (lite, lite1-5.dragonx.is) with random selection
- Add server connectivity probing to skip unreachable servers
- Reuse Tokio runtime across block fetch batches to reduce sync overhead
- Update Cargo.lock dependencies
2026-03-21 03:43:23 -05:00
fekt
b0d7319182 Merge pull request 'Merge dev into master' (#2) from dev into master
Reviewed-on: https://git.hush.is/dragonx/SilentDragonXLite/pulls/2
2024-11-18 04:23:38 +01:00
fekt
336d85e6c7 Update checkpoints 2024-11-17 22:09:45 -05:00
dan_s
54813c8827 updating checkpoints and build script 2024-11-05 16:40:05 -06:00
dan_s
0865358171 updated css for dragonx theme and added as option to settings menu 2024-05-08 23:21:51 -05:00
fekt
573fba9ba0 More translation replacements 2024-04-15 21:10:44 -04:00
fekt
054dcb451b Fix halving calculation 2024-04-15 15:01:39 +00:00
duke
9947c14411 DRGX has a blocktime of 36s 2024-04-15 13:49:54 +00:00
fekt
9f47d1e293 Update blocktime for DRGX
Difficulty, longestchain, and some other data does not render in UI and needs to be fixed. Halving calculations also need to be reviewed for accuracy for DRGX.
2024-04-15 01:41:53 -04:00
fekt
f620f6c519 Update 'README.md' 2024-04-15 05:39:43 +00:00
onryo
00fe0ea59d Merge pull request 'Merge dev into main' (#149) from dev into master
Reviewed-on: https://git.hush.is/hush/SilentDragonLite/pulls/149
2024-03-25 01:49:10 +00:00
286 changed files with 124364 additions and 123603 deletions

92
.gitignore vendored
View File

@@ -1,46 +1,46 @@
bin/ bin/
debug/ debug/
release/ release/
x64/ x64/
artifacts/ artifacts/
docs/website/public docs/website/public
.vscode/ .vscode/
res/libsodium.a res/libsodium.a
res/libsodium/libsodium* res/libsodium/libsodium*
res/libsodium.a res/libsodium.a
src/ui_*.h src/ui_*.h
*.autosave *.autosave
src/precompiled.h.cpp src/precompiled.h.cpp
.qmake.stash .qmake.stash
silentdragonlite silentdragonlite
silentdragonlite.app silentdragonlite.app
silentdragon-lite-mingw* silentdragon-lite-mingw*
silentdragon-lite.vcxproj* silentdragon-lite.vcxproj*
silentdragonlite.vcxproj* silentdragonlite.vcxproj*
silentdragon-lite.sln silentdragon-lite.sln
silentdragon-lite.pro.user silentdragon-lite.pro.user
/Makefile /Makefile
/Makefile.* /Makefile.*
qrc_application.cpp qrc_application.cpp
silentdragonlite_plugin_import.cpp silentdragonlite_plugin_import.cpp
silentdragon_plugin_import.cpp silentdragon_plugin_import.cpp
silentdragonlite_resource* silentdragonlite_resource*
silentdragon_resource* silentdragon_resource*
workspace.code-workspace workspace.code-workspace
*.zip *.zip
*.tar.gz *.tar.gz
*.xcsettings *.xcsettings
.DS_Store .DS_Store
*.mak *.mak
hushd hushd
IDEWorkspaceChecks.plist IDEWorkspaceChecks.plist
*.sln *.sln
node_modules node_modules
silentdragonlite.pro.user.4.10-pre1 silentdragonlite.pro.user.4.10-pre1
silentdragonlite silentdragonlite
silentdragonlite_plugin_import.cpp silentdragonlite_plugin_import.cpp
silentdragonlite_resource.rc silentdragonlite_resource.rc
SilentDragonLite SilentDragonLite
.gdb_history .gdb_history
.*sw? .*sw?
core core

View File

@@ -1,41 +1,41 @@
language: rust language: rust
rust: rust:
- 1.41.0 - 1.41.0
matrix: matrix:
include: include:
# works on Precise and Trusty # works on Precise and Trusty
- os: linux - os: linux
- dist: xenial - dist: xenial
compiler: clang compiler: clang
addons: addons:
apt: apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7'] sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7']
packages: ['clang-3.7', 'g++-5'] packages: ['clang-3.7', 'g++-5']
before_script: before_script:
- export PATH="$PATH:$HOME/.cargo/bin" - export PATH="$PATH:$HOME/.cargo/bin"
before_install: before_install:
- rustup component add rustfmt --toolchain 1.41.0-x86_64-unknown-linux-gnu - rustup component add rustfmt --toolchain 1.41.0-x86_64-unknown-linux-gnu
- gem install bundler - gem install bundler
- curl -sSL https://sh.rustup.rs | sh -s -- -y --default-toolchain=stable --profile=minimal - curl -sSL https://sh.rustup.rs | sh -s -- -y --default-toolchain=stable --profile=minimal
- export PATH="$PATH:$HOME/.cargo/bin" - export PATH="$PATH:$HOME/.cargo/bin"
- sudo add-apt-repository ppa:beineri/opt-qt-5.14.2-xenial -y - sudo add-apt-repository ppa:beineri/opt-qt-5.14.2-xenial -y
- sudo apt-get update -qq - sudo apt-get update -qq
- sudo apt-get install libsodium-dev pkg-config - sudo apt-get install libsodium-dev pkg-config
- sudo apt-get install qt514base libgl1-mesa-dev - sudo apt-get install qt514base libgl1-mesa-dev
- source /opt/qt514/bin/qt514-env.sh - source /opt/qt514/bin/qt514-env.sh
- chmod +x res/libsodium/buildlibsodium.sh - chmod +x res/libsodium/buildlibsodium.sh
script: script:
- qmake -v - qmake -v
- clang++ -v - clang++ -v
- g++-5 -v - g++-5 -v
- qmake silentdragon-lite.pro CONFIG+=release -spec linux-clang - qmake silentdragon-lite.pro CONFIG+=release -spec linux-clang
- make CC=clang CXX=clang++ -j2 - make CC=clang CXX=clang++ -j2
- make distclean - make distclean
- qmake silentdragon-lite.pro CONFIG+=release -spec linux-g++ - qmake silentdragon-lite.pro CONFIG+=release -spec linux-g++
- res/libsodium/buildlibsodium.sh - res/libsodium/buildlibsodium.sh
- make CC=gcc-5 CXX=g++-5 -j2 - make CC=gcc-5 CXX=g++-5 -j2

12
AUTHORS
View File

@@ -1,6 +1,6 @@
# The Hush Developers # The Hush Developers
Duke Leto https://git.hush.is/duke https://github.com/leto Duke Leto https://git.hush.is/duke https://github.com/leto
Jane Mercer https://git.hush.is/radix42 https://github.com/radix42 Jane Mercer https://git.hush.is/radix42 https://github.com/radix42
fekt https://git.hush.is/fekt fekt https://git.hush.is/fekt

1356
LICENSE

File diff suppressed because it is too large Load Diff

240
README.md
View File

@@ -1,120 +1,120 @@
# SilentDragonXLite # SilentDragonXLite
SilentDragonXLite is a lightwallet for DRAGONX ($DRAGONX) runs on Linux and Windows which does not require you to download the full blockchain. This is experimental software under active development! SilentDragonXLite is a lightwallet for DRAGONX ($DRAGONX) runs on Linux, Windows, and Mac which does not require you to download the full blockchain. This is experimental software under active development!
## PRIVACY NOTICE ## PRIVACY NOTICE
SilentDragonXLite contacts a few different external websites to get various bits of data. SilentDragonXLite contacts a few different external websites to get various bits of data.
The first two are option features, to get real-time price data feeds and if you want The first two are option features, to get real-time price data feeds and if you want
to look at explorer details. Price feed can be turned off in Settings and you can set to look at explorer details. Price feed can be turned off in Settings and you can set
a custom block explorer URL as well. a custom block explorer URL as well.
* coingecko.com for price data API (optional) * coingecko.com for price data API (optional)
* explorer.dragonx.is for explorer links (optional) * explorer.dragonx.is for explorer links (optional)
* various community-run lite wallet servers to provide basic functionality (required) * various community-run lite wallet servers to provide basic functionality (required)
This means your IP address is known to these servers. Enable Tor setting in your wallet to prevent this, or better yet, use TAILS: https://tails.boum.org/ This means your IP address is known to these servers. Enable Tor setting in your wallet to prevent this, or better yet, use TAILS: https://tails.boum.org/
or https://qubes-os.org or https://qubes-os.org
## Installation ## Installation
Choose to install a binary release or compile it yourself. Choose to install a binary release or compile it yourself.
For Arch Linux users, we have a silentdragonxlite package on [AUR](https://aur.archlinux.org/). For Arch Linux users, we have a silentdragonxlite package on [AUR](https://aur.archlinux.org/).
### Option 1: Binary Release ### Option 1: Binary Release
Go to the [releases page](https://git.hush.is/dragonx/SilentDragonXLite/releases) and grab the latest binary. Go to the [releases page](https://git.hush.is/dragonx/SilentDragonXLite/releases) and grab the latest binary.
### Option 2: Compile Release Yourself ### Option 2: Compile Release Yourself
* SilentDragonXLite is written in C++ 14, and can be compiled with g++/clang++/visual c++. * SilentDragonXLite is written in C++ 14, and can be compiled with g++/clang++/visual c++.
* It also depends on Qt5, which you can get from [here](https://www.qt.io/download) or we recommend installing using your Linux version's package manager (if available). * It also depends on Qt5, which you can get from [here](https://www.qt.io/download) or we recommend installing using your Linux version's package manager (if available).
* **You'll need Rust v1.49**, so install it via [Rustup in Linux](https://rustup.rs/). **If you use a version greater then 1.63, then it will not currently build** as seen in [Issue #89](https://git.hush.is/hush/SilentDragonLite/issues/89). * **You'll need Rust v1.49**, so install it via [Rustup in Linux](https://rustup.rs/). **If you use a version greater then 1.63, then it will not currently build** as seen in [Issue #89](https://git.hush.is/hush/SilentDragonLite/issues/89).
#### Building on Linux #### Building on Linux
**Nothing below will work without rust. Check that your system has rustc 1.49. If not then you need to use [Rustup in Linux](https://rustup.rs/).** **Nothing below will work without rust. Check that your system has rustc 1.49. If not then you need to use [Rustup in Linux](https://rustup.rs/).**
An example of how to install Rust 1.49 with rustup is below: An example of how to install Rust 1.49 with rustup is below:
``` ```
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Choose: 1) Proceed with installation (default) Choose: 1) Proceed with installation (default)
source $HOME/.cargo/env source $HOME/.cargo/env
rustup install 1.49 rustup install 1.49
rustup default 1.49 rustup default 1.49
rustup -V rustup -V
``` ```
**Nothing below will work without the Linux "build-essential" package. Check that your system has it installed. If not, and you're using a Ubuntu/Debian distro, then you can install with `apt install build-essential`.** **Nothing below will work without the Linux "build-essential" package. Check that your system has it installed. If not, and you're using a Ubuntu/Debian distro, then you can install with `apt install build-essential`.**
##### Ubuntu 22.04: ##### Ubuntu 22.04:
```shell script ```shell script
sudo apt-get -y install build-essential qtbase5-dev qt5-qmake qtcreator qttools5-dev-tools sudo apt-get -y install build-essential qtbase5-dev qt5-qmake qtcreator qttools5-dev-tools
``` ```
##### Ubuntu 18.04 and 20.04: ##### Ubuntu 18.04 and 20.04:
```shell script ```shell script
sudo apt-get -y install build-essential qt5-default qt5-qmake qtcreator qttools5-dev-tools sudo apt-get -y install build-essential qt5-default qt5-qmake qtcreator qttools5-dev-tools
``` ```
Compiling can take some time, so be patient and wait for it to finish. It will take potentially a long time for slower systems. Be Patient and please report compiler problems! Compiling can take some time, so be patient and wait for it to finish. It will take potentially a long time for slower systems. Be Patient and please report compiler problems!
```shell script ```shell script
git clone https://git.hush.is/dragonx/SilentDragonXLite git clone https://git.hush.is/dragonx/SilentDragonXLite
cd SilentDragonXLite cd SilentDragonXLite
./build.sh linguist ./build.sh linguist
# This defaults to using 2 cores to compile # This defaults to using 2 cores to compile
./build.sh ./build.sh
# To use a custom number of cores to compile, such as 8 : # To use a custom number of cores to compile, such as 8 :
# ./build.sh -j8 # ./build.sh -j8
./SilentDragonXLite ./SilentDragonXLite
``` ```
### Other notes ### Other notes
#### Install Torsocks (or any other Socks service for TOR) on Ubuntu 18.04 #### Install Torsocks (or any other Socks service for TOR) on Ubuntu 18.04
```shell script ```shell script
sudo apt update sudo apt update
sudo apt install torsocks sudo apt install torsocks
``` ```
#### Connection to our TOR onion service Server #### Connection to our TOR onion service Server
NOTE: Tor server is currently under maintenance. NOTE: Tor server is currently under maintenance.
``` ```
* Open SDL Edit->Settings->LightwalletServer->nope.onion:80 * Open SDL Edit->Settings->LightwalletServer->nope.onion:80
* Open the folder of SDL in a Terminal -> Enter: TORSOCKS_LOG_LEVEL=1 torsocks -i ./SilentDragonXLite * Open the folder of SDL in a Terminal -> Enter: TORSOCKS_LOG_LEVEL=1 torsocks -i ./SilentDragonXLite
``` ```
### Note Management ### Note Management
SilentDragonXLite does automatic note and utxo management, which means it doesn't allow you to manually select which address to send outgoing transactions from. It follows these principles: SilentDragonXLite does automatic note and utxo management, which means it doesn't allow you to manually select which address to send outgoing transactions from. It follows these principles:
* Defaults to sending shielded transactions, which are now enforced via consensus rules * Defaults to sending shielded transactions, which are now enforced via consensus rules
* Sapling funds need at least 2 confirmations before they can be spent (60 seconds on average for DRAGONX mainnet) * Sapling funds need at least 2 confirmations before they can be spent (60 seconds on average for DRAGONX mainnet)
* Can select funds from multiple shielded addresses in the same transaction (via raw transactions) * Can select funds from multiple shielded addresses in the same transaction (via raw transactions)
* Will automatically shield your transparent funds at the first opportunity * Will automatically shield your transparent funds at the first opportunity
* When sending an outgoing transaction to a shielded address, SilentDragonXLite can decide to use the transaction to additionally shield your transparent funds (i.e., send your transparent funds to your own shielded address in the same transaction) * When sending an outgoing transaction to a shielded address, SilentDragonXLite can decide to use the transaction to additionally shield your transparent funds (i.e., send your transparent funds to your own shielded address in the same transaction)
## Where is my wallet stored? ## Where is my wallet stored?
Linux: `~/.silentdragonxlite` Linux: `~/.silentdragonxlite`
Windows 10: `C:\Users\%user\AppData\Roaming\silentdragonxlite` Windows 10: `C:\Users\%user\AppData\Roaming\silentdragonxlite`
Mac: `~/Library/Application Support/silentdragonxlite` Mac: `~/Library/Application Support/silentdragonxlite`
## Where are settings stored? ## Where are settings stored?
Linux: `~/.config/Hush/SilentDragonXLite.conf` Linux: `~/.config/Hush/SilentDragonXLite.conf`
Windows: `HKEY_CURRENT_USER\SOFTWARE\Hush\SilentXDragonLite` Windows: `HKEY_CURRENT_USER\SOFTWARE\Hush\SilentXDragonLite`
Mac: `~/Library/Preferences/com.hush.SilentDragonXLite.plist` Mac: `~/Library/Preferences/com.hush.SilentDragonXLite.plist`
## Support ## Support
For support join us on [Telegram](https://dragonx.is/tg) or [file an issue](https://git.hush.is/dragonx/SilentDragonXLite/issues). For support join us on [Telegram](https://dragonx.is/tg) or [file an issue](https://git.hush.is/dragonx/SilentDragonXLite/issues).
## License ## License
GPLv3 or later GPLv3 or later

55
RELEASE_NOTES_v1.1.0.md Normal file
View File

@@ -0,0 +1,55 @@
# SilentDragonXLite v1.1.0 Release Notes
## What's New
### DragonX Compatibility
- Full compatibility with the DragonX blockchain
- Updated payment URIs from `hush:` to `drgx:`
- Updated branding and UI strings throughout
### Crash Fixes
- Fixed Rust FFI panics with `catch_unwind` wrappers and safe CString construction
- Handle poisoned mutex/RwLock from prior panics instead of crashing
- Fixed empty block list panics in `clear_blocks` and `invalidate_block`
- Removed `throw;` in exception handler that caused undefined behavior
### Reorg Detection & Stuck Sync Recovery
- Detects stuck syncs (10-second stall threshold) and prompts the user to repair
- Chain reorganization detection with one-time user prompt to clear and re-sync
- Prevents duplicate reorg dialogs
### Server Failover
- All 6 lite servers available: lite, lite1-5.dragonx.is
- Random server selection with connectivity probing — dead servers are automatically skipped
- Server dropdown in settings for manual selection
### Faster Block Sync
- Reuses Tokio runtime across block fetch batches, eliminating per-batch runtime creation overhead
### Clean Shutdown
- Added 15-second timeout on wallet save during exit — the app will no longer hang on close
- Rust background threads (mempool monitor) are now cleanly stopped on exit via `litelib_shutdown()`
### Wallet Safety
- Atomic wallet saves: writes to a temp file, then renames over the original — a crash during save can no longer corrupt the wallet
- Automatic `.bak` backup created before each save
- On startup, if the wallet file is missing or corrupted, automatically recovers from the backup
### Seed Phrase
- Added "Skip Verification" button to seed phrase wizard for faster wallet setup
### UI Contrast Improvements
- Fixed disabled buttons being invisible (white text on white background)
- Fixed setup wizard, message boxes, and dialog contrast for the dark theme
- Chat bubbles now use dark themed backgrounds matching the overall UI
- Seed verification buttons styled with proper contrast
- Fixed hyperlink color in Terms of Service (blue on dark was unreadable)
---
## Downloads
| File | SHA-256 |
|---|---|
| `SilentDragonXLite` (Linux) | `f9d3e3a8cd916b2d83dda89bc181670ef2cdd8b9ae5a50ef3a1c0e76e74f04fc` |
| `SilentDragonXLite.exe` (Windows) | `5064082c1300c42bef5c0f767e39743b08c66641eb495e1d975cbfb163b76cb0` |

18
RELEASE_NOTES_v1.1.1.md Normal file
View File

@@ -0,0 +1,18 @@
# SilentDragonXLite v1.1.1 Release Notes
## What's New
### Transaction Display Fix
- **Fixed sent transactions showing wrong addresses** — Previously, sending to a single address would display multiple addresses in the transaction history (the recipient plus the wallet's own diversified change addresses). Change outputs are now correctly detected using Incoming Viewing Key (IVK) decryption instead of a static address list, so only the actual recipient address is shown.
### Wallet Birthday Fix
- **Fixed "Failed to parse wallet birthday" error** — Rescanning the wallet no longer fails due to trailing whitespace in the birthday height input.
---
## Downloads
| File | SHA-256 |
|---|---|
| `SilentDragonXLite` (Linux) | `ac44fbdfa343ffb550829827e3fbb95407e2ca3086d6bc34befdc7b5644763a7` |
| `SilentDragonXLite.exe` (Windows) | `093b6830f23b1f1d407c47f2df90a2c1465b2882a0c3b375237a5b731e36362c` |

BIN
SilentDragonXLite Executable file

Binary file not shown.

View File

@@ -0,0 +1,37 @@
#include <windows.h>
IDI_ICON1 ICON DISCARDABLE "/home/d/external/SilentDragonXLite/res/icon.ico"
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,0,0
PRODUCTVERSION 0,0,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "\0"
VALUE "FileVersion", "0.0.0.0\0"
VALUE "LegalCopyright", "\0"
VALUE "OriginalFilename", "SilentDragonXLite.exe\0"
VALUE "ProductName", "SilentDragonXLite\0"
VALUE "ProductVersion", "0.0.0.0\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 1200
END
END
/* End of Version info */

View File

@@ -1,121 +1,121 @@
<RCC> <RCC>
<qresource prefix="/fonts"> <qresource prefix="/fonts">
<file>res/Ubuntu-R.ttf</file> <file>res/Ubuntu-R.ttf</file>
</qresource> </qresource>
<qresource prefix="/icons"> <qresource prefix="/icons">
<file>res/connected.gif</file> <file>res/connected.gif</file>
<file>res/loading.gif</file> <file>res/loading.gif</file>
<file>res/paymentreq.gif</file> <file>res/paymentreq.gif</file>
<file>res/icon.ico</file> <file>res/icon.ico</file>
<file>res/mail.png</file> <file>res/mail.png</file>
<file>res/SDLogo.png</file> <file>res/SDLogo.png</file>
<file>res/sdlogo2.png</file> <file>res/sdlogo2.png</file>
<file>res/Denio.png</file> <file>res/Denio.png</file>
<file>res/Duke.png</file> <file>res/Duke.png</file>
<file>res/onryo.png</file> <file>res/onryo.png</file>
<file>res/fekt.png</file> <file>res/fekt.png</file>
<file>res/jahway603.png</file> <file>res/jahway603.png</file>
<file>res/Sharpee.png</file> <file>res/Sharpee.png</file>
<file>res/Anonymous.png</file> <file>res/Anonymous.png</file>
<file>res/send.png</file> <file>res/send.png</file>
<file>res/send.svg</file> <file>res/send.svg</file>
<file>res/addcontact.svg</file> <file>res/addcontact.svg</file>
<file>res/send-new.svg</file> <file>res/send-new.svg</file>
<file>res/add_contact.svg</file> <file>res/add_contact.svg</file>
<file>res/notification.svg</file> <file>res/notification.svg</file>
<file>res/send-new-white.png</file> <file>res/send-new-white.png</file>
<file>res/add_contact.png</file> <file>res/add_contact.png</file>
<file>res/notification.png</file> <file>res/notification.png</file>
<file>res/rahmen-message.png</file> <file>res/rahmen-message.png</file>
<file>res/message-icon.svg</file> <file>res/message-icon.svg</file>
<file>res/lock_green.png</file> <file>res/lock_green.png</file>
<file>res/lock_orange.png</file> <file>res/lock_orange.png</file>
<file>res/unlocked.png</file> <file>res/unlocked.png</file>
<file>res/getAddrWhite.png</file> <file>res/getAddrWhite.png</file>
<file>res/send-white.png</file> <file>res/send-white.png</file>
<file>res/requestWhite.png</file> <file>res/requestWhite.png</file>
<file>res/addContactWhite.png</file> <file>res/addContactWhite.png</file>
<file>res/getAddrBlack.png</file> <file>res/getAddrBlack.png</file>
<file>res/sendBlack.png</file> <file>res/sendBlack.png</file>
<file>res/requestBlack.png</file> <file>res/requestBlack.png</file>
<file>res/addContactBlack.png</file> <file>res/addContactBlack.png</file>
<file>res/unknownBlack.png</file> <file>res/unknownBlack.png</file>
<file>res/unknownWhite.png</file> <file>res/unknownWhite.png</file>
<file>res/dark-01.png</file> <file>res/dark-01.png</file>
<file>res/money-mouth.png</file> <file>res/money-mouth.png</file>
<file>res/money-outgoing.png</file> <file>res/money-outgoing.png</file>
<file>res/hush-money-white.png</file> <file>res/hush-money-white.png</file>
<file>res/tx_input.png</file> <file>res/tx_input.png</file>
<file>res/tx_output.png</file> <file>res/tx_output.png</file>
<file>res/tx_mined.png</file> <file>res/tx_mined.png</file>
</qresource> </qresource>
<qresource prefix="/img"> <qresource prefix="/img">
<file>res/drgxlogo.png</file> <file>res/drgxlogo.png</file>
<file>res/silentdragonxlite-animated.gif</file> <file>res/silentdragonxlite-animated.gif</file>
<file>res/silentdragonxlite-animated-dark.gif</file> <file>res/silentdragonxlite-animated-dark.gif</file>
<file>res/silentdragonxlite-animated-startup-dark.gif</file> <file>res/silentdragonxlite-animated-startup-dark.gif</file>
<file>res/loaderblack.gif</file> <file>res/loaderblack.gif</file>
<file>res/loaderwhite.gif</file> <file>res/loaderwhite.gif</file>
<file>res/logobig.gif</file> <file>res/logobig.gif</file>
</qresource> </qresource>
<qresource prefix="/emoji"> <qresource prefix="/emoji">
<file>res/emoji/emoji1.png</file> <file>res/emoji/emoji1.png</file>
<file>res/emoji/laughing.png</file> <file>res/emoji/laughing.png</file>
<file>res/emoji/money-mouth.png</file> <file>res/emoji/money-mouth.png</file>
<file>res/emoji/joy.png</file> <file>res/emoji/joy.png</file>
<file>res/emoji/innocent.png</file> <file>res/emoji/innocent.png</file>
<file>res/emoji/partying_face.png</file> <file>res/emoji/partying_face.png</file>
<file>res/emoji/face_with_3hearts.png</file> <file>res/emoji/face_with_3hearts.png</file>
<file>res/emoji/face-with-rolling-eyes.png</file> <file>res/emoji/face-with-rolling-eyes.png</file>
<file>res/emoji/face-with-tongue.png</file> <file>res/emoji/face-with-tongue.png</file>
<file>res/emoji/heart_shaped_eyes.png</file> <file>res/emoji/heart_shaped_eyes.png</file>
<file>res/emoji/nauseated-face.png</file> <file>res/emoji/nauseated-face.png</file>
<file>res/emoji/pile-of-poo.png</file> <file>res/emoji/pile-of-poo.png</file>
<file>res/emoji/serious-face-with-symbols-covering-mouth.png</file> <file>res/emoji/serious-face-with-symbols-covering-mouth.png</file>
<file>res/emoji/smiling-face-with-sunglasses.png</file> <file>res/emoji/smiling-face-with-sunglasses.png</file>
<file>res/emoji/stuck-out.png</file> <file>res/emoji/stuck-out.png</file>
<file>res/emoji/sweet_smile.png</file> <file>res/emoji/sweet_smile.png</file>
<file>res/emoji/hush-money-white.png</file> <file>res/emoji/hush-money-white.png</file>
<file>res/emoji/SD.png</file> <file>res/emoji/SD.png</file>
</qresource> </qresource>
<qresource prefix="/translations"> <qresource prefix="/translations">
<file>res/silentdragonxlite_ar.qm</file> <file>res/silentdragonxlite_ar.qm</file>
<file>res/silentdragonxlite_be.qm</file> <file>res/silentdragonxlite_be.qm</file>
<file>res/silentdragonxlite_pl.qm</file> <file>res/silentdragonxlite_pl.qm</file>
<file>res/silentdragonxlite_de.qm</file> <file>res/silentdragonxlite_de.qm</file>
<file>res/silentdragonxlite_es.qm</file> <file>res/silentdragonxlite_es.qm</file>
<file>res/silentdragonxlite_fa.qm</file> <file>res/silentdragonxlite_fa.qm</file>
<file>res/silentdragonxlite_fr.qm</file> <file>res/silentdragonxlite_fr.qm</file>
<file>res/silentdragonxlite_hr.qm</file> <file>res/silentdragonxlite_hr.qm</file>
<file>res/silentdragonxlite_id.qm</file> <file>res/silentdragonxlite_id.qm</file>
<file>res/silentdragonxlite_it.qm</file> <file>res/silentdragonxlite_it.qm</file>
<file>res/silentdragonxlite_pt.qm</file> <file>res/silentdragonxlite_pt.qm</file>
<file>res/silentdragonxlite_ro.qm</file> <file>res/silentdragonxlite_ro.qm</file>
<file>res/silentdragonxlite_ru.qm</file> <file>res/silentdragonxlite_ru.qm</file>
<file>res/silentdragonxlite_ud.qm</file> <file>res/silentdragonxlite_ud.qm</file>
<file>res/silentdragonxlite_sr.qm</file> <file>res/silentdragonxlite_sr.qm</file>
<file>res/silentdragonxlite_tr.qm</file> <file>res/silentdragonxlite_tr.qm</file>
<file>res/silentdragonxlite_zh.qm</file> <file>res/silentdragonxlite_zh.qm</file>
</qresource> </qresource>
<qresource prefix="/css"> <qresource prefix="/css">
<file>res/css/Blue.css</file> <file>res/css/Blue.css</file>
<file>res/css/Dark.css</file> <file>res/css/Dark.css</file>
<file>res/css/Default.css</file> <file>res/css/Default.css</file>
<file>res/css/Light.css</file> <file>res/css/Light.css</file>
<file>res/css/Midnight.css</file> <file>res/css/Midnight.css</file>
<file>res/css/test.css</file> <file>res/css/dragonx.css</file>
</qresource> </qresource>
<qresource prefix="/images/blue"> <qresource prefix="/images/blue">
<file>res/images/blue/unchecked.png</file> <file>res/images/blue/unchecked.png</file>
<file>res/images/blue/checked.png</file> <file>res/images/blue/checked.png</file>
<file>res/images/blue/blue_downArrow.png</file> <file>res/images/blue/blue_downArrow.png</file>
<file>res/images/blue/blue_downArrow_small.png</file> <file>res/images/blue/blue_downArrow_small.png</file>
<file>res/images/blue/blue_upArrow_small.png</file> <file>res/images/blue/blue_upArrow_small.png</file>
<file>res/images/blue/blue_leftArrow_small.png</file> <file>res/images/blue/blue_leftArrow_small.png</file>
<file>res/images/blue/blue_rightArrow_small.png</file> <file>res/images/blue/blue_rightArrow_small.png</file>
<file>res/images/blue/blue_qtreeview_selected.png</file> <file>res/images/blue/blue_qtreeview_selected.png</file>
</qresource> </qresource>
<qresource prefix="/images"> <qresource prefix="/images">
<file>res/images/tile.png</file> <file>res/images/tile.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -49,7 +49,7 @@ CONF=silentdragonx-lite.pro
set -e set -e
qbuild () { qbuild () {
qmake $CONF CONFIG+=debug qmake $CONF CONFIG+=release
#lupdate $CONF #lupdate $CONF
#lrelease $CONF #lrelease $CONF
# default to 2 jobs or use the -j value given as argument to this script # default to 2 jobs or use the -j value given as argument to this script

View File

@@ -1,11 +1,11 @@
Install build tools: Install build tools:
``` ```
sudo apt install dh-make sudo apt install dh-make
``` ```
To build the package from source run the following: To build the package from source run the following:
``` ```
dpkg-buildpackage -rfakeroot -b -uc -us dpkg-buildpackage -rfakeroot -b -uc -us
``` ```

View File

@@ -1,13 +1,13 @@
Source: silentdragonxlite Source: silentdragonxlite
Section: utils Section: utils
Priority: optional Priority: optional
Maintainer: onryo <onryo@hush.land> Maintainer: onryo <onryo@hush.land>
Standards-Version: 4.6.0 Standards-Version: 4.6.0
Homepage: https://dragonx.is Homepage: https://dragonx.is
Vcs-Browser: https://git.hush.is/dragonx/SilentDragonXLite Vcs-Browser: https://git.hush.is/dragonx/SilentDragonXLite
Vcs-Git: https://git.hush.is/dragonx/SilentDragonXLite.git Vcs-Git: https://git.hush.is/dragonx/SilentDragonXLite.git
Package: silentdragonxlite Package: silentdragonxlite
Architecture: amd64 arm64 Architecture: amd64 arm64
Depends: ${shlibs:Depends}, ${misc:Depends} Depends: ${shlibs:Depends}, ${misc:Depends}
Description: SilentDragonXLite is a lightwallet for DRAGONX which does not require you to download the full blockchain. Description: SilentDragonXLite is a lightwallet for DRAGONX which does not require you to download the full blockchain.

View File

@@ -1,5 +1,5 @@
Files: * Files: *
Copyright: 2019-2024, The Hush developers Copyright: 2019-2024, The Hush developers
2018-2019, The Zcash developers 2018-2019, The Zcash developers
License: GPLv3 License: GPLv3
Comment: https://hush.is/developers Comment: https://hush.is/developers

View File

@@ -1,20 +1,20 @@
#!/usr/bin/make -f #!/usr/bin/make -f
# See debhelper(7) (uncomment to enable) # See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system. # output every command that modifies files on the build system.
#export DH_VERBOSE = 1 #export DH_VERBOSE = 1
# see FEATURE AREAS in dpkg-buildflags(1) # see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all #export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# see ENVIRONMENT in dpkg-buildflags(1) # see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS # package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic #export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# package maintainers to append LDFLAGS # package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed #export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
%: %:
dh $@ dh $@
# dh_make generated override targets # dh_make generated override targets
# This is example for Cmake (See https://bugs.debian.org/641051 ) # This is example for Cmake (See https://bugs.debian.org/641051 )
#override_dh_auto_configure: #override_dh_auto_configure:
# dh_auto_configure -- # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) # dh_auto_configure -- # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)

View File

@@ -1,62 +1,62 @@
# Developer Docs for SDL # Developer Docs for SDL
Random stuff that is useful for devs. Random stuff that is useful for devs.
# Checking return values from litelib # Checking return values from litelib
There are 3 functions written in Rust that live in lib/src/lib.rs : There are 3 functions written in Rust that live in lib/src/lib.rs :
* `litelib_initialize_new` * `litelib_initialize_new`
* create a new client/connection and brand new wallet * create a new client/connection and brand new wallet
* `litelib_initialize_new_from_phrase` * `litelib_initialize_new_from_phrase`
* create a new client/connection from a seedphrase (restoring from seedphrase) * create a new client/connection from a seedphrase (restoring from seedphrase)
* `litelib_initialize_existing` * `litelib_initialize_existing`
* create a new client/connection with an already existing wallet * create a new client/connection with an already existing wallet
The Rust code calls it a "LightClient" while the C++ of SDL calls it a "Connection". The Rust code calls it a "LightClient" while the C++ of SDL calls it a "Connection".
When `litelib_initialize_existing` or `litelib_initialize_new_from_phrase` return successfully, they return the string "OK" (which is not JSON). When `litelib_initialize_existing` or `litelib_initialize_new_from_phrase` return successfully, they return the string "OK" (which is not JSON).
When `litelib_initialize_new` returns successfully it returns JSON that looks like : When `litelib_initialize_new` returns successfully it returns JSON that looks like :
``` ```
{"seed":"seed","birthday":birthday} {"seed":"seed","birthday":birthday}
``` ```
where "seed" is a 24 word seed and birthday is an integer block height. where "seed" is a 24 word seed and birthday is an integer block height.
So when calling these 3 functions, which looks almost the same in the calling code, the code which checks if they worked will be different, depending on what each returns on success. So when calling these 3 functions, which looks almost the same in the calling code, the code which checks if they worked will be different, depending on what each returns on success.
When checking the return value of `litelib_initialize_existing` or `litelib_initialize_new_from_phrase` it should look like : When checking the return value of `litelib_initialize_existing` or `litelib_initialize_new_from_phrase` it should look like :
``` ```
QString reply = ""; QString reply = "";
try { try {
char* resp = litelib_initialize_new_from_phrase(...); char* resp = litelib_initialize_new_from_phrase(...);
reply = litelib_process_response(resp); reply = litelib_process_response(resp);
} catch { } catch {
... ...
} }
if (reply.isEmpty())) { if (reply.isEmpty())) {
// litelib_initialize_new_from_phrase failed // litelib_initialize_new_from_phrase failed
... ...
} }
``` ```
Yes, `isEmpty()` is not a very strict check, we could actually check for valid-looking JSON (starts with a { and ends with a }) as well as making sure the keys "seed" and "birthday" exist. Please implement this. Yes, `isEmpty()` is not a very strict check, we could actually check for valid-looking JSON (starts with a { and ends with a }) as well as making sure the keys "seed" and "birthday" exist. Please implement this.
When checking the return value of `litelib_initialize_new` it should look like : When checking the return value of `litelib_initialize_new` it should look like :
``` ```
QString reply = ""; QString reply = "";
try { try {
char* resp = litelib_initialize_new(...); char* resp = litelib_initialize_new(...);
reply = litelib_process_response(resp); reply = litelib_process_response(resp);
} catch { } catch {
... ...
} }
if (reply.toUpper().trimmed() != "OK") { if (reply.toUpper().trimmed() != "OK") {
// litelib_initialize_new failed // litelib_initialize_new failed
... ...
} }
``` ```

View File

@@ -1,67 +1,67 @@
# SilentDragonXLite Release Process # SilentDragonXLite Release Process
## High-Level Philosophy ## High-Level Philosophy
Beware of making high-risk changes too close to a new release, because they will not get as much testing as they should. Don't merge large branches which haven't undergone lots of testing just before a release. Beware of making high-risk changes too close to a new release, because they will not get as much testing as they should. Don't merge large branches which haven't undergone lots of testing just before a release.
It is best to keep doc/relnotes/README.md up to date as changes and bug fixes are made. It's more work to summarize all changes and bugfixes just before the release. It is best to keep doc/relnotes/README.md up to date as changes and bug fixes are made. It's more work to summarize all changes and bugfixes just before the release.
## Check for changes on master that should be on dev ## Check for changes on master that should be on dev
See https://git.hush.is/hush/hush3/src/branch/master/doc/release-process.md#check-for-changes-on-master-that-should-be-on-dev , there is no sense repeating the exact same thing here. See https://git.hush.is/hush/hush3/src/branch/master/doc/release-process.md#check-for-changes-on-master-that-should-be-on-dev , there is no sense repeating the exact same thing here.
SD+SDL very often has merge conflicts in generated translation files, because QT embeds line numbers in XML. SD+SDL very often has merge conflicts in generated translation files, because QT embeds line numbers in XML.
Read how to deal with them efficiently here: https://git.hush.is/hush/SilentDragon/src/branch/dev/doc/release-process.md#dealing-with-merge-conflicts Read how to deal with them efficiently here: https://git.hush.is/hush/SilentDragon/src/branch/dev/doc/release-process.md#dealing-with-merge-conflicts
## Git Issues ## Git Issues
Look for Git issues that should be fixed in the next release: https://git.hush.is/hush/SilentDragonLite/issues Especially low-risk and simple things and like documentation changes and improvements to error messages. Take note that changing strings in the source code, such as adding a new string or changing an existing one, will affect translations. Look for Git issues that should be fixed in the next release: https://git.hush.is/hush/SilentDragonLite/issues Especially low-risk and simple things and like documentation changes and improvements to error messages. Take note that changing strings in the source code, such as adding a new string or changing an existing one, will affect translations.
## Translations ## Translations
... ...
``` ```
# update generated translation data # update generated translation data
./build.sh linguist ./build.sh linguist
git commit -am "update translations" git commit -am "update translations"
git push git push
``` ```
## Adding Checkpoints ## Adding Checkpoints
Adding checkpoints make SDL sync much faster, especially for brand new wallets. If there are no recent checkpoints, Adding checkpoints make SDL sync much faster, especially for brand new wallets. If there are no recent checkpoints,
when a user makes a new wallet, it will sync from a block far in the past, which wastes time, bandwidth and CPU resources. To add a checkpoint , they are added to the file `lib/src/lightclient/checkpoints.rs` in the silentdragonxlite-cli repo, and then the dependency on silentdragonxlite-cli is updated in this SDL repo. Here is an example commit that updates checkpoints: when a user makes a new wallet, it will sync from a block far in the past, which wastes time, bandwidth and CPU resources. To add a checkpoint , they are added to the file `lib/src/lightclient/checkpoints.rs` in the silentdragonxlite-cli repo, and then the dependency on silentdragonxlite-cli is updated in this SDL repo. Here is an example commit that updates checkpoints:
https://git.hush.is/hush/silentdragonlite-cli/commit/ef477f152e1a8bb8a5f7883a99e2a74a6f9eeb0b https://git.hush.is/hush/silentdragonlite-cli/commit/ef477f152e1a8bb8a5f7883a99e2a74a6f9eeb0b
To actually generate the checkpoint data, use the `sdl_checkpoints.pl` script in the hush3 repo: https://git.hush.is/hush/hush3/src/branch/master/contrib/sdl_checkpoints.pl . It uses the `getblockmerkletree` RPC to get the merkle tree data for a block height. It prints the data out in the format that checkpoints.rs wants it in, you simply need to copy and paste the output into the checkpoints.rs file. Once the data is updated in silentdragonlite-cli checkpoints.rs file, the file `lib/Cargo.toml` must be updated in this repo, and point to the commit id of the updated data. Once you update the manually-edited `Cargo.toml` you must run `cargo update` to update the generated `Cargo.lock` file. See https://doc.rust-lang.org/cargo/commands/cargo-update.html for more info. Once both files are updates, commit and push. To actually generate the checkpoint data, use the `sdl_checkpoints.pl` script in the hush3 repo: https://git.hush.is/hush/hush3/src/branch/master/contrib/sdl_checkpoints.pl . It uses the `getblockmerkletree` RPC to get the merkle tree data for a block height. It prints the data out in the format that checkpoints.rs wants it in, you simply need to copy and paste the output into the checkpoints.rs file. Once the data is updated in silentdragonlite-cli checkpoints.rs file, the file `lib/Cargo.toml` must be updated in this repo, and point to the commit id of the updated data. Once you update the manually-edited `Cargo.toml` you must run `cargo update` to update the generated `Cargo.lock` file. See https://doc.rust-lang.org/cargo/commands/cargo-update.html for more info. Once both files are updates, commit and push.
--- ---
To fix `error: failed to select a version for the requirement 'aes = "^0.3"'` add the following to `.cargo/config.toml`: To fix `error: failed to select a version for the requirement 'aes = "^0.3"'` add the following to `.cargo/config.toml`:
``` ```
[source.crates-io] [source.crates-io]
replace-with = "vendored-sources" replace-with = "vendored-sources"
[source.vendored-sources] [source.vendored-sources]
directory = "vendor" directory = "vendor"
``` ```
To update the file run `cargo vendor` as was mentioned in https://git.hush.is/hush/SilentDragonLite/issues/91. To update the file run `cargo vendor` as was mentioned in https://git.hush.is/hush/SilentDragonLite/issues/91.
--- ---
## Release process ## Release process
* Write release notes * Write release notes
* Choose a release name * Choose a release name
* Make Gitea release from master branch * Make Gitea release from master branch
* You can either manually make a git tag or let Gitea do it, which is easier * You can either manually make a git tag or let Gitea do it, which is easier
* Make binaries * Make binaries
* Windows exe * Windows exe
* Windows msi * Windows msi
* Linux * Linux
* Mac * Mac
* Debian package * Debian package

View File

@@ -1,80 +1,80 @@
## Crosscompile for Windows (only tested for Ubuntu 18.04) by DenioD ## Crosscompile for Windows (only tested for Ubuntu 18.04) by DenioD
``` ```
# build dependencies # build dependencies
sudo apt install -y clang g++ build-essential make mingw-w64 git pkg-config libc6-dev m4 g++-multilib autoconf libtool-bin ncurses-dev unzip python python-zmq zlib1g-dev wget curl bsdmainutils automake libgl1-mesa-dev libglu1-mesa-dev libfontconfig1-dev autopoint libssl-dev sudo apt install -y clang g++ build-essential make mingw-w64 git pkg-config libc6-dev m4 g++-multilib autoconf libtool-bin ncurses-dev unzip python python-zmq zlib1g-dev wget curl bsdmainutils automake libgl1-mesa-dev libglu1-mesa-dev libfontconfig1-dev autopoint libssl-dev
# MXE dependencies # MXE dependencies
sudo apt install -y bash bison bzip2 flex gettext git gperf intltool libc6-dev-i386 libgdk-pixbuf2.0-dev libltdl-dev libtool-bin libxml-parser-perl make openssl p7zip-full patch perl pkg-config python ruby sed unzip wget xz-utils sudo apt install -y bash bison bzip2 flex gettext git gperf intltool libc6-dev-i386 libgdk-pixbuf2.0-dev libltdl-dev libtool-bin libxml-parser-perl make openssl p7zip-full patch perl pkg-config python ruby sed unzip wget xz-utils
``` ```
## more dependencies ## more dependencies
``` ```
apt-get -y update && apt-get install -y \ apt-get -y update && apt-get install -y \
curl libdbus-1-3 libexpat1 \ curl libdbus-1-3 libexpat1 \
libgl1-mesa-dev libglu1-mesa-dev libfontconfig1-dev libssl-dev \ libgl1-mesa-dev libglu1-mesa-dev libfontconfig1-dev libssl-dev \
libfreetype6 libgl1-mesa-glx libglib2.0-0 \ libfreetype6 libgl1-mesa-glx libglib2.0-0 \
libx11-6 libx11-xcb1 \ libx11-6 libx11-xcb1 \
g++ build-essential cmake wget git clang++-6.0 \ g++ build-essential cmake wget git clang++-6.0 \
software-properties-common \ software-properties-common \
autoconf automake autopoint bison flex gperf libtool libtool-bin intltool lzip python ruby unzip p7zip-full libgdk-pixbuf2.0-dev libltdl-dev autoconf automake autopoint bison flex gperf libtool libtool-bin intltool lzip python ruby unzip p7zip-full libgdk-pixbuf2.0-dev libltdl-dev
``` ```
# Compile OpenSSL # Compile OpenSSL
``` ```
# Download openssl 1.0.2 from https://openssl.org/source/ # Download openssl 1.0.2 from https://openssl.org/source/
wget https://www.openssl.org/source/openssl-1.0.2t.tar.gz wget https://www.openssl.org/source/openssl-1.0.2t.tar.gz
tar zxvpf openssl-1.0.2t.tar.gz tar zxvpf openssl-1.0.2t.tar.gz
cd openssl-1.0.2t cd openssl-1.0.2t
./config # linux-x86_64 ./config # linux-x86_64
make -j$(nproc) make -j$(nproc)
``` ```
## Static build of Qt5 ## Static build of Qt5
# Download Qt5 sources # Download Qt5 sources
``` ```
mkdir -p ~/Qt/5.11.2 && cd ~/Qt/5.11.2 mkdir -p ~/Qt/5.11.2 && cd ~/Qt/5.11.2
wget https://download.qt.io/archive/qt/5.11/5.11.2/single/qt-everywhere-src-5.11.2.tar.xz wget https://download.qt.io/archive/qt/5.11/5.11.2/single/qt-everywhere-src-5.11.2.tar.xz
tar xvpf qt-everywhere-src-5.11.2.tar.xz && cd qt-everywhere-src-5.11.2 tar xvpf qt-everywhere-src-5.11.2.tar.xz && cd qt-everywhere-src-5.11.2
``` ```
# Configure and build Qt5 statically. # Configure and build Qt5 statically.
``` ```
OPENSSL_LIBS='-L/PATH/TO/openssl-1.0.2q -lssl -lcrypto' ./configure -static -prefix ~/Qt/5.11.2/static -skip qtlocation -skip qtmacextras -skip qtpurchasing -skip qtscript -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qtdatavis3d -skip qtdoc -skip qtcharts -skip qtdeclarative -skip qt3d -skip qtwebengine -skip qtandroidextras -skip qtwebview -skip qtgamepad -skip qtquickcontrols -skip qtquickcontrols2 -skip qtremoteobjects -skip qtwebview -skip qtwebchannel -skip qtwebglplugin -nomake examples -nomake tests -qt-zlib -qt-libpng -qt-xcb -qt-xkbcommon -feature-fontconfig -no-feature-getentropy -release -openssl-linked -opensource OPENSSL_LIBS='-L/PATH/TO/openssl-1.0.2q -lssl -lcrypto' ./configure -static -prefix ~/Qt/5.11.2/static -skip qtlocation -skip qtmacextras -skip qtpurchasing -skip qtscript -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qtdatavis3d -skip qtdoc -skip qtcharts -skip qtdeclarative -skip qt3d -skip qtwebengine -skip qtandroidextras -skip qtwebview -skip qtgamepad -skip qtquickcontrols -skip qtquickcontrols2 -skip qtremoteobjects -skip qtwebview -skip qtwebchannel -skip qtwebglplugin -nomake examples -nomake tests -qt-zlib -qt-libpng -qt-xcb -qt-xkbcommon -feature-fontconfig -no-feature-getentropy -release -openssl-linked -opensource
make -j$(nproc) make -j$(nproc)
make -j$(nproc) install make -j$(nproc) install
``` ```
# Build MXE (Cross-compiled Qt5 for Windows in Linux) # Build MXE (Cross-compiled Qt5 for Windows in Linux)
``` ```
mkdir ~/git && cd ~/git mkdir ~/git && cd ~/git
git clone https://github.com/mxe/mxe.git git clone https://github.com/mxe/mxe.git
cd mxe cd mxe
make -j$(nproc) MXE_TARGETS=x86_64-w64-mingw32.static qtbase make -j$(nproc) MXE_TARGETS=x86_64-w64-mingw32.static qtbase
``` ```
# Build SilentDragonLite .exe # Build SilentDragonLite .exe
``` ```
cd SilentDragonLite cd SilentDragonLite
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.38.0 -y curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.38.0 -y
echo 'source $HOME/.cargo/env' >> $HOME/.bashrc echo 'source $HOME/.cargo/env' >> $HOME/.bashrc
~/.cargo/bin/rustup target add x86_64-pc-windows-gnu ~/.cargo/bin/rustup target add x86_64-pc-windows-gnu
echo "[target.x86_64-pc-windows-gnu]" >> ~/.cargo/config echo "[target.x86_64-pc-windows-gnu]" >> ~/.cargo/config
echo "linker = 'x86_64-w64-mingw32.static-gcc'" >> ~/.cargo/config echo "linker = 'x86_64-w64-mingw32.static-gcc'" >> ~/.cargo/config
./win-static-build.sh ./win-static-build.sh
``` ```
# Adding a new SDL lite server backend to the code # Adding a new SDL lite server backend to the code
* Add the new server name to the array in getRandomServer() in settings.cpp * Add the new server name to the array in getRandomServer() in settings.cpp
* Add the new server to dropdown in mainwindow.cpp * Add the new server to dropdown in mainwindow.cpp
TODO: Make both of these places use a single list of servers. TODO: Make both of these places use a single list of servers.

View File

@@ -1,30 +1,30 @@
--- ---
name: Bug report name: Bug report
about: Create a report to help us improve about: Create a report to help us improve
title: '' title: ''
labels: '' labels: ''
assignees: '' assignees: ''
--- ---
Please make sure you have the latest SilentDragonXLite and let us Please make sure you have the latest SilentDragonXLite and let us
know if you have any non-default settings. know if you have any non-default settings.
**Describe the bug** **Describe the bug**
A clear and concise description of what the bug is. A clear and concise description of what the bug is.
**To Reproduce** **To Reproduce**
Steps to reproduce the behavior: Steps to reproduce the behavior:
1. Go to '...' 1. Go to '...'
2. Click on '....' 2. Click on '....'
3. Scroll down to '....' 3. Scroll down to '....'
4. See error 4. See error
**Expected behavior** **Expected behavior**
A clear and concise description of what you expected to happen. A clear and concise description of what you expected to happen.
**Desktop (please complete the following information):** **Desktop (please complete the following information):**
- OS: [e.g. Linux/Mac/Windows with version] - OS: [e.g. Linux/Mac/Windows with version]
**Additional context** **Additional context**
Add any other context about the problem here. Add any other context about the problem here.

2
lib/.cargo/config.toml Normal file
View File

@@ -0,0 +1,2 @@
[net]
git-fetch-with-cli = true

4
lib/.gitignore vendored
View File

@@ -1,2 +1,2 @@
/target/ /target/

49
lib/Cargo.lock generated
View File

@@ -127,7 +127,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f80256bc78f67e7df7e36d77366f636ed976895d91fe2ab9efa3973e8fe8c4f" checksum = "7f80256bc78f67e7df7e36d77366f636ed976895d91fe2ab9efa3973e8fe8c4f"
dependencies = [ dependencies = [
"backtrace-sys", "backtrace-sys",
"cfg-if", "cfg-if 0.1.10",
"libc", "libc",
"rustc-demangle", "rustc-demangle",
] ]
@@ -230,7 +230,7 @@ dependencies = [
"arrayref", "arrayref",
"arrayvec", "arrayvec",
"cc", "cc",
"cfg-if", "cfg-if 0.1.10",
"constant_time_eq", "constant_time_eq",
"crypto-mac", "crypto-mac",
"digest", "digest",
@@ -330,6 +330,12 @@ version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "chrono" name = "chrono"
version = "0.4.10" version = "0.4.10"
@@ -378,7 +384,7 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
] ]
[[package]] [[package]]
@@ -394,7 +400,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4" checksum = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4"
dependencies = [ dependencies = [
"autocfg 0.1.7", "autocfg 0.1.7",
"cfg-if", "cfg-if 0.1.10",
"lazy_static", "lazy_static",
] ]
@@ -438,7 +444,7 @@ version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"dirs-sys", "dirs-sys",
] ]
@@ -448,7 +454,7 @@ version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b" checksum = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"libc", "libc",
"redox_users", "redox_users",
"winapi 0.3.8", "winapi 0.3.8",
@@ -523,7 +529,7 @@ version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ff6d4dab0aa0c8e6346d46052e93b13a16cf847b54ed357087c35011048cc7d" checksum = "1ff6d4dab0aa0c8e6346d46052e93b13a16cf847b54ed357087c35011048cc7d"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"libc", "libc",
"redox_syscall", "redox_syscall",
"winapi 0.3.8", "winapi 0.3.8",
@@ -541,7 +547,7 @@ version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f" checksum = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"crc32fast", "crc32fast",
"libc", "libc",
"miniz_oxide", "miniz_oxide",
@@ -657,7 +663,7 @@ version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"libc", "libc",
"wasi", "wasi",
] ]
@@ -861,9 +867,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.66" version = "0.2.161"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1"
[[package]] [[package]]
name = "libflate" name = "libflate"
@@ -912,7 +918,7 @@ version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"serde", "serde",
] ]
@@ -974,7 +980,7 @@ version = "0.6.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" checksum = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"fuchsia-zircon", "fuchsia-zircon",
"fuchsia-zircon-sys", "fuchsia-zircon-sys",
"iovec", "iovec",
@@ -1044,7 +1050,7 @@ version = "0.2.33"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"libc", "libc",
"winapi 0.3.8", "winapi 0.3.8",
] ]
@@ -1335,6 +1341,7 @@ dependencies = [
"lazy_static", "lazy_static",
"libc", "libc",
"silentdragonxlitelib", "silentdragonxlitelib",
"socket2",
] ]
[[package]] [[package]]
@@ -1849,7 +1856,6 @@ dependencies = [
[[package]] [[package]]
name = "silentdragonxlitelib" name = "silentdragonxlitelib"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.hush.is/dragonx/silentdragonxlite-cli?rev=39ec5f36662ba7370dffa6c8346f93633dfa29ce#39ec5f36662ba7370dffa6c8346f93633dfa29ce"
dependencies = [ dependencies = [
"base58", "base58",
"bellman", "bellman",
@@ -1908,13 +1914,12 @@ dependencies = [
[[package]] [[package]]
name = "socket2" name = "socket2"
version = "0.3.11" version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"libc", "libc",
"redox_syscall",
"winapi 0.3.8", "winapi 0.3.8",
] ]
@@ -2011,7 +2016,7 @@ version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"libc", "libc",
"rand 0.7.3", "rand 0.7.3",
"redox_syscall", "redox_syscall",
@@ -2367,7 +2372,7 @@ version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e213bd24252abeb86a0b7060e02df677d367ce6cb772cef17e9214b8390a8d3" checksum = "1e213bd24252abeb86a0b7060e02df677d367ce6cb772cef17e9214b8390a8d3"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"log", "log",
"tracing-attributes", "tracing-attributes",
"tracing-core", "tracing-core",
@@ -2507,7 +2512,7 @@ version = "0.2.58"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5205e9afdf42282b192e2310a5b463a6d1c1d774e30dc3c791ac37ab42d2616c" checksum = "5205e9afdf42282b192e2310a5b463a6d1c1d774e30dc3c791ac37ab42d2616c"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"wasm-bindgen-macro", "wasm-bindgen-macro",
] ]

View File

@@ -1,15 +1,16 @@
[package] [package]
name = "qtlib" name = "qtlib"
version = "0.1.0" version = "0.1.0"
authors = ["zecwallet", "The Hush Developers"] authors = ["zecwallet", "The Hush Developers"]
edition = "2018" edition = "2018"
[lib] [lib]
name = "silentdragonxlite" name = "silentdragonxlite"
crate-type = ["staticlib"] crate-type = ["staticlib"]
[dependencies] [dependencies]
libc = "0.2.58" libc = "0.2.58"
lazy_static = "1.4.0" lazy_static = "1.4.0"
blake3 = "0.3.4" blake3 = "0.3.4"
silentdragonxlitelib = { git = "https://git.hush.is/dragonx/silentdragonxlite-cli", rev = "39ec5f36662ba7370dffa6c8346f93633dfa29ce" } silentdragonxlitelib = { path = "/home/d/external/silentdragonxlite-cli/lib" }
socket2 = "0.3.11"

View File

@@ -1,28 +1,28 @@
ifeq ($(shell uname),Darwin) ifeq ($(shell uname),Darwin)
EXT := dylib EXT := dylib
CFLAGS := "-mmacosx-version-min=10.11" CFLAGS := "-mmacosx-version-min=10.11"
else else
EXT := a EXT := a
CFLAGS := "" CFLAGS :=
endif endif
PWD := $(shell pwd) PWD := $(shell pwd)
all: release all: release
winrelease: target/x86_64-pc-windows-gnu/release/silentdragonxlite.lib winrelease: target/x86_64-pc-windows-gnu/release/silentdragonxlite.lib
target/x86_64-pc-windows-gnu/release/silentdragonxlite.lib: src/lib.rs Cargo.toml target/x86_64-pc-windows-gnu/release/silentdragonxlite.lib: src/lib.rs Cargo.toml
SODIUM_LIB_DIR="$(PWD)/libsodium-mingw/" cargo build --lib --release --target x86_64-pc-windows-gnu SODIUM_LIB_DIR="$(PWD)/libsodium-mingw/" cargo build --lib --release --target x86_64-pc-windows-gnu
release: target/release/silentdragonxlite.$(EXT) release: target/release/silentdragonxlite.$(EXT)
debug: target/debug/silentdragonxlite.$(EXT) debug: target/debug/silentdragonxlite.$(EXT)
target/release/silentdragonxlite.$(EXT): src/lib.rs Cargo.toml target/release/silentdragonxlite.$(EXT): src/lib.rs Cargo.toml
LIBS="" CFLAGS=$(CFLAGS) cargo build --lib --release LIBS="" CFLAGS=$(CFLAGS) cargo build --lib --release
target/debug/silentdragonxlite.$(EXT): src/lib.rs Cargo.toml target/debug/silentdragonxlite.$(EXT): src/lib.rs Cargo.toml
LIBS="" CFLAGS=$(CFLAGS) cargo build --lib LIBS="" CFLAGS=$(CFLAGS) cargo build --lib
clean: clean:
rm -rf target rm -rf target

View File

@@ -1,27 +1,29 @@
#ifndef _hush_PAPER_RUST_H #ifndef _hush_PAPER_RUST_H
#define _hush_PAPER_RUST_H #define _hush_PAPER_RUST_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
extern bool litelib_wallet_exists (const char* chain_name); extern bool litelib_wallet_exists (const char* chain_name);
extern char * litelib_initialize_new (bool dangerous, const char* server); extern char * litelib_initialize_new (bool dangerous, const char* server);
extern char * litelib_initialize_new_from_phrase extern char * litelib_initialize_new_from_phrase
(bool dangerous, const char* server, const char* seed, (bool dangerous, const char* server, const char* seed,
unsigned long long birthday, unsigned long long number); unsigned long long birthday, unsigned long long number,
extern char * litelib_initialize_existing (bool dangerous,const char* server); bool overwrite);
extern char * litelib_execute (const char* s, const char* args); extern char * litelib_initialize_existing (bool dangerous,const char* server);
extern void litelib_rust_free_string (char* s); extern char * litelib_execute (const char* s, const char* args);
extern char * blake3_PW (char* pw); extern void litelib_rust_free_string (char* s);
extern bool litelib_check_server_online (const char* server); extern char * blake3_PW (char* pw);
extern bool litelib_check_server_online (const char* server);
#ifdef __cplusplus extern void litelib_shutdown (void);
}
#endif #ifdef __cplusplus
}
// This is a function implemented in connection.cpp that will process a string response from #endif
// the litelib and turn into into a QString in a memory-safe way.
QString litelib_process_response(char* resp); // This is a function implemented in connection.cpp that will process a string response from
// the litelib and turn into into a QString in a memory-safe way.
#endif QString litelib_process_response(char* resp);
#endif

View File

@@ -1,276 +1,328 @@
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
use libc::{c_char}; use libc::{c_char};
use std::ffi::{CStr, CString}; use std::ffi::{CStr, CString};
use std::sync::{Mutex, Arc}; use std::sync::{Mutex, Arc};
use std::cell::RefCell; use std::cell::RefCell;
use std::ptr; use std::ptr;
use std::panic;
use silentdragonxlitelib::{commands, lightclient::{LightClient, LightClientConfig}};
use silentdragonxlitelib::{commands, lightclient::{LightClient, LightClientConfig}};
// We'll use a MUTEX to store a global lightclient instance,
// so we don't have to keep creating it. We need to store it here, in rust /// Helper to create a CString, replacing null bytes to avoid panics
// because we can't return such a complex structure back to C++ fn safe_cstring(s: &str) -> CString {
lazy_static! { let cleaned: String = s.replace('\0', "");
static ref LIGHTCLIENT: Mutex<RefCell<Option<Arc<LightClient>>>> = Mutex::new(RefCell::new(None)); CString::new(cleaned).unwrap_or_else(|_| CString::new("Error: failed to create CString").unwrap())
} }
// Check if there is an existing wallet /// Helper to create an error CString
#[no_mangle] fn error_cstring(msg: &str) -> *mut c_char {
pub extern fn litelib_wallet_exists(chain_name: *const c_char) -> bool { safe_cstring(&format!("Error: {}", msg)).into_raw()
let chain_name_str = unsafe { }
assert!(!chain_name.is_null());
// We'll use a MUTEX to store a global lightclient instance,
CStr::from_ptr(chain_name).to_string_lossy().into_owned() // so we don't have to keep creating it. We need to store it here, in rust
}; // because we can't return such a complex structure back to C++
lazy_static! {
let config = LightClientConfig::create_unconnected(chain_name_str, None); static ref LIGHTCLIENT: Mutex<RefCell<Option<Arc<LightClient>>>> = Mutex::new(RefCell::new(None));
}
println!("Wallet exists: {}", config.wallet_exists());
config.wallet_exists() // Check if there is an existing wallet
} #[no_mangle]
pub extern fn litelib_wallet_exists(chain_name: *const c_char) -> bool {
//////hash blake3 let chain_name_str = unsafe {
assert!(!chain_name.is_null());
#[no_mangle]
pub extern fn blake3_PW(pw: *const c_char) -> *mut c_char{ CStr::from_ptr(chain_name).to_string_lossy().into_owned()
};
let passwd = unsafe {
assert!(!pw.is_null()); let config = LightClientConfig::create_unconnected(chain_name_str, None);
CStr::from_ptr(pw).to_string_lossy().into_owned() println!("Wallet exists: {}", config.wallet_exists());
}; config.wallet_exists()
}
let data = passwd.as_bytes();
// Hash an input all at once. //////hash blake3
let hash1 = blake3::hash(data).to_hex();
// This is sensitive metadata, do not log it to stdout #[no_mangle]
//println!("\nBlake3 Hash: {}", hash1); pub extern fn blake3_PW(pw: *const c_char) -> *mut c_char{
println!("\nBlake3 Hash calculated");
let passwd = unsafe {
//let sttring = CString::new(hash1).unwrap(); assert!(!pw.is_null());
let e_str = CString::new(format!("{}", hash1)).unwrap();
return e_str.into_raw(); CStr::from_ptr(pw).to_string_lossy().into_owned()
} };
/// Create a new wallet and return the seed for the newly created wallet. let data = passwd.as_bytes();
#[no_mangle] // Hash an input all at once.
pub extern fn litelib_initialize_new(dangerous: bool,server: *const c_char) -> *mut c_char { let hash1 = blake3::hash(data).to_hex();
let server_str = unsafe { // This is sensitive metadata, do not log it to stdout
assert!(!server.is_null()); //println!("\nBlake3 Hash: {}", hash1);
println!("\nBlake3 Hash calculated");
CStr::from_ptr(server).to_string_lossy().into_owned()
}; //let sttring = CString::new(hash1).unwrap();
let e_str = CString::new(format!("{}", hash1)).unwrap();
let server = LightClientConfig::get_server_or_default(Some(server_str)); return e_str.into_raw();
let (config, latest_block_height) = match LightClientConfig::create(server, dangerous) { }
Ok((c, h)) => (c, h),
Err(e) => { /// Create a new wallet and return the seed for the newly created wallet.
let e_str = CString::new(format!("Error: {}", e)).unwrap(); #[no_mangle]
return e_str.into_raw(); pub extern fn litelib_initialize_new(dangerous: bool,server: *const c_char) -> *mut c_char {
} let server_str = unsafe {
}; assert!(!server.is_null());
let lightclient = match LightClient::new(&config, latest_block_height) { CStr::from_ptr(server).to_string_lossy().into_owned()
Ok(l) => l, };
Err(e) => {
let e_str = CString::new(format!("Error: {}", e)).unwrap(); let server = LightClientConfig::get_server_or_default(Some(server_str));
return e_str.into_raw(); let (config, latest_block_height) = match LightClientConfig::create(server, dangerous) {
} Ok((c, h)) => (c, h),
}; Err(e) => {
let e_str = CString::new(format!("Error: {}", e)).unwrap();
// Initialize logging return e_str.into_raw();
let _ = lightclient.init_logging(); }
};
let seed = match lightclient.do_seed_phrase() {
Ok(s) => s.dump(), let lightclient = match LightClient::new(&config, latest_block_height) {
Err(e) => { Ok(l) => l,
let e_str = CString::new(format!("Error: {}", e)).unwrap(); Err(e) => {
return e_str.into_raw(); let e_str = CString::new(format!("Error: {}", e)).unwrap();
} return e_str.into_raw();
}; }
};
let lc = Arc::new(lightclient);
match LightClient::start_mempool_monitor(lc.clone()) { // Initialize logging
Ok(_) => {println!("Starting Mempool")}, let _ = lightclient.init_logging();
Err(e) => {
println!("Couldnt start mempool {}", e) let seed = match lightclient.do_seed_phrase() {
} Ok(s) => s.dump(),
} Err(e) => {
let e_str = CString::new(format!("Error: {}", e)).unwrap();
LIGHTCLIENT.lock().unwrap().replace(Some(lc)); return e_str.into_raw();
}
// Return the wallet's seed };
let s_str = CString::new(seed).unwrap();
return s_str.into_raw(); let lc = Arc::new(lightclient);
} match LightClient::start_mempool_monitor(lc.clone()) {
Ok(_) => {println!("Starting Mempool")},
/// Restore a wallet from the seed phrase Err(e) => {
#[no_mangle] println!("Couldnt start mempool {}", e)
pub extern "C" fn litelib_initialize_new_from_phrase(dangerous: bool, server: *const c_char, }
seed: *const c_char, birthday: u64, number: u64, overwrite: bool) -> *mut c_char { }
if server.is_null() || seed.is_null() {
println!("Server or seed is null"); match LIGHTCLIENT.lock() {
return ptr::null_mut(); Ok(l) => { l.replace(Some(lc)); },
} Err(poisoned) => { poisoned.into_inner().replace(Some(lc)); },
};
let server_str = unsafe {
CStr::from_ptr(server).to_string_lossy().into_owned() // Return the wallet's seed
}; let s_str = safe_cstring(&seed);
let seed_str = unsafe { return s_str.into_raw();
CStr::from_ptr(seed).to_string_lossy().into_owned() }
};
/// Restore a wallet from the seed phrase
//println!("Initializing with server: {}, seed: {}", server_str, seed_str); #[no_mangle]
pub extern "C" fn litelib_initialize_new_from_phrase(dangerous: bool, server: *const c_char,
let server = LightClientConfig::get_server_or_default(Some(server_str)); seed: *const c_char, birthday: u64, number: u64, overwrite: bool) -> *mut c_char {
let (config, _latest_block_height) = match LightClientConfig::create(server, dangerous) { if server.is_null() || seed.is_null() {
Ok((c, h)) => { println!("Server or seed is null");
println!("Config created successfully"); return ptr::null_mut();
(c, h) }
},
Err(e) => { let server_str = unsafe {
println!("Error creating config: {}", e); CStr::from_ptr(server).to_string_lossy().into_owned()
let e_str = CString::new(format!("Error: {}", e)).unwrap_or_else(|_| CString::new("Error creating CString").unwrap()); };
return e_str.into_raw(); let seed_str = unsafe {
} CStr::from_ptr(seed).to_string_lossy().into_owned()
}; };
let lightclient = match LightClient::new_from_phrase(seed_str, &config, birthday, number, overwrite) { //println!("Initializing with server: {}, seed: {}", server_str, seed_str);
Ok(l) => {
println!("LightClient created successfully"); // Shut down the existing client if one is running, to stop background threads
l if overwrite {
}, let old_lc = match LIGHTCLIENT.lock() {
Err(e) => { Ok(l) => l.borrow().clone(),
println!("Error creating LightClient: {}", e); Err(poisoned) => poisoned.into_inner().borrow().clone(),
let e_str = CString::new(format!("Error: {}", e)).unwrap_or_else(|_| CString::new("Error creating CString").unwrap()); };
return e_str.into_raw(); if let Some(lc) = old_lc {
} lc.shutdown();
}; }
}
// Initialize logging
let _ = lightclient.init_logging(); let server = LightClientConfig::get_server_or_default(Some(server_str));
let (config, _latest_block_height) = match LightClientConfig::create(server, dangerous) {
let lc = Arc::new(lightclient); Ok((c, h)) => {
match LightClient::start_mempool_monitor(lc.clone()) { println!("Config created successfully");
Ok(_) => println!("Starting Mempool"), (c, h)
Err(e) => println!("Could not start mempool: {}", e) },
} Err(e) => {
println!("Error creating config: {}", e);
LIGHTCLIENT.lock().unwrap().replace(Some(lc)); let e_str = CString::new(format!("Error: {}", e)).unwrap_or_else(|_| CString::new("Error creating CString").unwrap());
return e_str.into_raw();
let c_str = CString::new("OK").unwrap_or_else(|_| CString::new("CString creation failed").unwrap()); }
return c_str.into_raw(); };
}
let lightclient = match LightClient::new_from_phrase(seed_str, &config, birthday, number, overwrite) {
// Initialize a new lightclient and store its value Ok(l) => {
#[no_mangle] println!("LightClient created successfully");
pub extern fn litelib_initialize_existing(dangerous: bool, server: *const c_char) -> *mut c_char { l
let server_str = unsafe { },
assert!(!server.is_null()); Err(e) => {
println!("Error creating LightClient: {}", e);
CStr::from_ptr(server).to_string_lossy().into_owned() let e_str = CString::new(format!("Error: {}", e)).unwrap_or_else(|_| CString::new("Error creating CString").unwrap());
}; return e_str.into_raw();
}
let server = LightClientConfig::get_server_or_default(Some(server_str)); };
let (config, _latest_block_height) = match LightClientConfig::create(server,dangerous) {
Ok((c, h)) => (c, h), // Initialize logging
Err(e) => { let _ = lightclient.init_logging();
let e_str = CString::new(format!("Error: {}", e)).unwrap();
return e_str.into_raw(); let lc = Arc::new(lightclient);
} match LightClient::start_mempool_monitor(lc.clone()) {
}; Ok(_) => println!("Starting Mempool"),
Err(e) => println!("Could not start mempool: {}", e)
let lightclient = match LightClient::read_from_disk(&config) { }
Ok(l) => l,
Err(e) => { match LIGHTCLIENT.lock() {
let e_str = CString::new(format!("Error: {}", e)).unwrap(); Ok(l) => { l.replace(Some(lc)); },
return e_str.into_raw(); Err(poisoned) => { poisoned.into_inner().replace(Some(lc)); },
} };
};
let c_str = safe_cstring("OK");
// Initialize logging return c_str.into_raw();
let _ = lightclient.init_logging(); }
let lc = Arc::new(lightclient); // Initialize a new lightclient and store its value
match LightClient::start_mempool_monitor(lc.clone()) { #[no_mangle]
Ok(_) => {println!("Starting Mempool")}, pub extern fn litelib_initialize_existing(dangerous: bool, server: *const c_char) -> *mut c_char {
Err(e) => { let server_str = unsafe {
println!("Couldnt start mempool {}",e) assert!(!server.is_null());
}
} CStr::from_ptr(server).to_string_lossy().into_owned()
};
LIGHTCLIENT.lock().unwrap().replace(Some(lc));
let server = LightClientConfig::get_server_or_default(Some(server_str));
let c_str = CString::new("OK").unwrap(); let (config, _latest_block_height) = match LightClientConfig::create(server,dangerous) {
return c_str.into_raw(); Ok((c, h)) => (c, h),
} Err(e) => {
let e_str = CString::new(format!("Error: {}", e)).unwrap();
#[no_mangle] return e_str.into_raw();
pub extern fn litelib_execute(cmd: *const c_char, args: *const c_char) -> *mut c_char { }
let cmd_str = unsafe { };
assert!(!cmd.is_null());
let lightclient = match LightClient::read_from_disk(&config) {
CStr::from_ptr(cmd).to_string_lossy().into_owned() Ok(l) => l,
}; Err(e) => {
let e_str = CString::new(format!("Error: {}", e)).unwrap();
let arg_str = unsafe { return e_str.into_raw();
assert!(!args.is_null()); }
};
CStr::from_ptr(args).to_string_lossy().into_owned()
}; // Initialize logging
let _ = lightclient.init_logging();
let resp: String;
{ let lc = Arc::new(lightclient);
let lightclient: Arc<LightClient>; match LightClient::start_mempool_monitor(lc.clone()) {
{ Ok(_) => {println!("Starting Mempool")},
let lc = LIGHTCLIENT.lock().unwrap(); Err(e) => {
println!("Couldnt start mempool {}",e)
if lc.borrow().is_none() { }
let e_str = CString::new("Error: Light Client is not initialized").unwrap(); }
return e_str.into_raw();
} match LIGHTCLIENT.lock() {
Ok(l) => { l.replace(Some(lc)); },
lightclient = lc.borrow().as_ref().unwrap().clone(); Err(poisoned) => { poisoned.into_inner().replace(Some(lc)); },
}; };
let args = if arg_str.is_empty() { vec![] } else { vec![arg_str.as_ref()] }; let c_str = safe_cstring("OK");
return c_str.into_raw();
resp = commands::do_user_command(&cmd_str, &args, lightclient.as_ref()).clone(); }
};
#[no_mangle]
let c_str = CString::new(resp.as_bytes()).unwrap(); pub extern fn litelib_execute(cmd: *const c_char, args: *const c_char) -> *mut c_char {
return c_str.into_raw(); let result = panic::catch_unwind(|| {
} let cmd_str = unsafe {
assert!(!cmd.is_null());
// Check is Server Connection is fine CStr::from_ptr(cmd).to_string_lossy().into_owned()
#[no_mangle] };
pub extern "C" fn litelib_check_server_online(server: *const c_char) -> bool {
let server_str = unsafe { let arg_str = unsafe {
assert!(!server.is_null()); assert!(!args.is_null());
CStr::from_ptr(args).to_string_lossy().into_owned()
CStr::from_ptr(server).to_string_lossy().into_owned() };
};
let resp: String;
let server = LightClientConfig::get_server_or_default(Some(server_str)); {
let result = LightClientConfig::create(server, false); let lightclient: Arc<LightClient>;
{
match result { let lc = match LIGHTCLIENT.lock() {
Ok(_) => true, Ok(l) => l,
Err(_) => false, Err(poisoned) => poisoned.into_inner(),
} };
}
if lc.borrow().is_none() {
/** return error_cstring("Light Client is not initialized");
* Callers that receive string return values from other functions should call this to return the string }
* back to rust, so it can be freed. Failure to call this function will result in a memory leak
*/ lightclient = lc.borrow().as_ref().unwrap().clone();
#[no_mangle] };
pub extern fn litelib_rust_free_string(s: *mut c_char) {
unsafe { let args = if arg_str.is_empty() { vec![] } else { vec![arg_str.as_ref()] };
if s.is_null() { return }
CString::from_raw(s) resp = commands::do_user_command(&cmd_str, &args, lightclient.as_ref()).clone();
}; };
}
safe_cstring(&resp).into_raw()
});
match result {
Ok(ptr) => ptr,
Err(_) => error_cstring("Rust panic in litelib_execute"),
}
}
// Check is Server Connection is fine
#[no_mangle]
pub extern "C" fn litelib_check_server_online(server: *const c_char) -> bool {
let server_str = unsafe {
assert!(!server.is_null());
CStr::from_ptr(server).to_string_lossy().into_owned()
};
let server = LightClientConfig::get_server_or_default(Some(server_str));
let result = LightClientConfig::create(server, false);
match result {
Ok(_) => true,
Err(_) => false,
}
}
/// Cleanly shut down the light client, stopping mempool monitor threads.
/// Must be called before exit to prevent hangs.
#[no_mangle]
pub extern "C" fn litelib_shutdown() {
let lc_option = match LIGHTCLIENT.lock() {
Ok(l) => l.borrow().clone(),
Err(poisoned) => poisoned.into_inner().borrow().clone(),
};
if let Some(lc) = lc_option {
lc.shutdown();
}
}
/**
* Callers that receive string return values from other functions should call this to return the string
* back to rust, so it can be freed. Failure to call this function will result in a memory leak
*/
#[no_mangle]
pub extern fn litelib_rust_free_string(s: *mut c_char) {
unsafe {
if s.is_null() { return }
CString::from_raw(s)
};
}

View File

@@ -1,51 +1,51 @@
-----BEGIN PGP PUBLIC KEY BLOCK----- -----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBF3m0ggBEACsUTcR3AWpNOP48etuLa122UfmgdN8e6Ek4AjVOkdrjcpEQnFy mQINBF3m0ggBEACsUTcR3AWpNOP48etuLa122UfmgdN8e6Ek4AjVOkdrjcpEQnFy
eLFBz+hzzw9CQezFRBu35t+Vue1rbJdfsNJ+xpVi6xl9gvFj8P1s8ifcdwTtS4gF eLFBz+hzzw9CQezFRBu35t+Vue1rbJdfsNJ+xpVi6xl9gvFj8P1s8ifcdwTtS4gF
9CzBnDc07jpDWTdUlAN1ZDGy+PjdY77TaF5yJTeMqDXMAxyT3pJodJzd3TPbEOnB 9CzBnDc07jpDWTdUlAN1ZDGy+PjdY77TaF5yJTeMqDXMAxyT3pJodJzd3TPbEOnB
6lIheAML4NktAUvKqcXAqtB0aZ85MDlPjVCRpr3sNBMtIiazqHaT629yh8JIXwoA 6lIheAML4NktAUvKqcXAqtB0aZ85MDlPjVCRpr3sNBMtIiazqHaT629yh8JIXwoA
VMYPDBE+hvgU3yu2SJCy9ojZPm/yAhFF/QklBAM0mfQKcbuPJPttkKt/SFFXJViz VMYPDBE+hvgU3yu2SJCy9ojZPm/yAhFF/QklBAM0mfQKcbuPJPttkKt/SFFXJViz
1LrBguoreXlHtgPCpVR9ioDONBGeJNAJp1xpGJOHMW/v2bRAHGTkAczd0bVtqSF/ 1LrBguoreXlHtgPCpVR9ioDONBGeJNAJp1xpGJOHMW/v2bRAHGTkAczd0bVtqSF/
6lDzrHZuY8g8IVyOok92Ib6qLXv1ycXy9U3cUr0VL63bydJKX73f7UOWrLfAdogS 6lDzrHZuY8g8IVyOok92Ib6qLXv1ycXy9U3cUr0VL63bydJKX73f7UOWrLfAdogS
YbZitkut0D9QaU9OAL2o1Q7yK5R1Eukd64wqq7kfPGclVCD3gLyOqMIhDOkC8PMz YbZitkut0D9QaU9OAL2o1Q7yK5R1Eukd64wqq7kfPGclVCD3gLyOqMIhDOkC8PMz
A+G7zt0kGk2jDpxTJWn9yYYNiuZPBabXacc+gtiHGU10EowmapoIrvnkmSvoYguq A+G7zt0kGk2jDpxTJWn9yYYNiuZPBabXacc+gtiHGU10EowmapoIrvnkmSvoYguq
VDV3mW64v3ZxYh0XJgeUf6JCm96gb7aCsgpN/YNbhjJ1mtVwdiMwKwtpwtGBJN0E VDV3mW64v3ZxYh0XJgeUf6JCm96gb7aCsgpN/YNbhjJ1mtVwdiMwKwtpwtGBJN0E
2xTxvfc7p5bN4vQubiG2RcmLAk32zoRVO4cuYV9EMww9oOWCxxC2ejUN4QARAQAB 2xTxvfc7p5bN4vQubiG2RcmLAk32zoRVO4cuYV9EMww9oOWCxxC2ejUN4QARAQAB
tCJEZW5pb0QgPGFkbWluQGh1c2gtbGlnaHR3YWxsZXQuZGU+iQJOBBMBCgA4FiEE tCJEZW5pb0QgPGFkbWluQGh1c2gtbGlnaHR3YWxsZXQuZGU+iQJOBBMBCgA4FiEE
HtZt2Nk1ekNTh+rWvH7B0J/w0l0FAl3m0ggCGwMFCwkIBwIGFQoJCAsCBBYCAwEC HtZt2Nk1ekNTh+rWvH7B0J/w0l0FAl3m0ggCGwMFCwkIBwIGFQoJCAsCBBYCAwEC
HgECF4AACgkQvH7B0J/w0l0UBhAAgZyZAUEenN6QhhpNJCZWSEKv8tOaoqzP6qBR HgECF4AACgkQvH7B0J/w0l0UBhAAgZyZAUEenN6QhhpNJCZWSEKv8tOaoqzP6qBR
iZBUqRU4lmKQBipA7r4vT0JRiR2jAeIPYaVj0fteEoRrKnQd52jGckx2+yT5w3PJ iZBUqRU4lmKQBipA7r4vT0JRiR2jAeIPYaVj0fteEoRrKnQd52jGckx2+yT5w3PJ
i2aDOdHXyUEtC0ZL7FpTbUecrn+OVDqwBLqXXPkI50ttDAZe8MlMhWJxrTIAMAe7 i2aDOdHXyUEtC0ZL7FpTbUecrn+OVDqwBLqXXPkI50ttDAZe8MlMhWJxrTIAMAe7
cFrkU8Yo0WYI9vMuESQKSHzLnORhm4bcqWUmXvWj9WOb4cr/uDAGI/KM2NvG0LhN cFrkU8Yo0WYI9vMuESQKSHzLnORhm4bcqWUmXvWj9WOb4cr/uDAGI/KM2NvG0LhN
DDwHqBZ1J+v0g36N2BQY0dvWMhEdkwN3u1iyj512cinSzBdnk+6XuoGOu5aImI+u DDwHqBZ1J+v0g36N2BQY0dvWMhEdkwN3u1iyj512cinSzBdnk+6XuoGOu5aImI+u
JetFgwFLRT5H4UtjHJ9DBp+pQERyVy+3hnYxXs/rs2yD7Tyjksrj5gytxvPk88Gg JetFgwFLRT5H4UtjHJ9DBp+pQERyVy+3hnYxXs/rs2yD7Tyjksrj5gytxvPk88Gg
cedmk4fOQSQdI7rKv1ba3DW9ltoFd+Jh456ZsLS1eVJuECw+HrJMwkSxtbLhsYXH cedmk4fOQSQdI7rKv1ba3DW9ltoFd+Jh456ZsLS1eVJuECw+HrJMwkSxtbLhsYXH
vg67KkmGE0kNEku8IdOud6IXakqKct4Rsd8C/nM/rilUvbIMxrLgGxtLIgFu8vCu vg67KkmGE0kNEku8IdOud6IXakqKct4Rsd8C/nM/rilUvbIMxrLgGxtLIgFu8vCu
Pw2VLyMiAZPRg1G6rS9/F9yrCNuQDg1nxnS8FA7IM78VvVqJGprS/qiCpNVyhtda Pw2VLyMiAZPRg1G6rS9/F9yrCNuQDg1nxnS8FA7IM78VvVqJGprS/qiCpNVyhtda
hQ98gLO2H8SnMczFsLeIzaIokx0Egyr9qq2NxZGGSnb5kBPMRF9ZB4NcfwCXXO+6 hQ98gLO2H8SnMczFsLeIzaIokx0Egyr9qq2NxZGGSnb5kBPMRF9ZB4NcfwCXXO+6
LfEKsmcugEbhXjEGKINAlG12/iZC/Pa+hjLmKgMNNuFZKNjEWEHRzJdgMMFzFraM LfEKsmcugEbhXjEGKINAlG12/iZC/Pa+hjLmKgMNNuFZKNjEWEHRzJdgMMFzFraM
+K+Nhmi5Ag0EXebSCAEQAMYPNJO8scsr83M2zNtb/k4Qnz9pIhS6A0+69oWDvZ3g +K+Nhmi5Ag0EXebSCAEQAMYPNJO8scsr83M2zNtb/k4Qnz9pIhS6A0+69oWDvZ3g
Ugq45QT/9SZ/Bl3zYXb2owwF4MXPw6fEfMHAO7I0WNvzHYzuX/zBERlF+839G0ti Ugq45QT/9SZ/Bl3zYXb2owwF4MXPw6fEfMHAO7I0WNvzHYzuX/zBERlF+839G0ti
eVSdgkaP+BuUWZYOBoWCe0ij2/sBnmjhva3Z5DaN5Wk1Sl+vp+bfoJUZ0i/DvqHz eVSdgkaP+BuUWZYOBoWCe0ij2/sBnmjhva3Z5DaN5Wk1Sl+vp+bfoJUZ0i/DvqHz
NKkGHazw5duO/3vVSe+voN9tbpHUcLInaALb1FWtUcBkh+pMQyiiN8HofAXW6Kct NKkGHazw5duO/3vVSe+voN9tbpHUcLInaALb1FWtUcBkh+pMQyiiN8HofAXW6Kct
j1ku87MPThPO2NQNyOOc9Cvhdkjrn6pCqkBB8cufZN33Cd8HoBxN9qZeL632flaM j1ku87MPThPO2NQNyOOc9Cvhdkjrn6pCqkBB8cufZN33Cd8HoBxN9qZeL632flaM
zTL21Eq6niwbecK//gSNMIf9BIEJBE81cz5U0jZkb2hZVNSY54+JUVhgDL21s1ax zTL21Eq6niwbecK//gSNMIf9BIEJBE81cz5U0jZkb2hZVNSY54+JUVhgDL21s1ax
25iRGh58mFzgM7lpo40JCDQFW0dkvPmE0KLg4RMisxSe4csgrBJiCvLAWEldooce 25iRGh58mFzgM7lpo40JCDQFW0dkvPmE0KLg4RMisxSe4csgrBJiCvLAWEldooce
6H9KobXXnseDdrZZ/x2I95ACRwXbPPyqmDO5zKs8C+kyRdmiL8i8ndXI1HsOkyyb 6H9KobXXnseDdrZZ/x2I95ACRwXbPPyqmDO5zKs8C+kyRdmiL8i8ndXI1HsOkyyb
dWGD/SNnGlVe+Y+FnHh+aXv1f+JhIi5wmUOZTM+196l93UE11xuSSXnYqOFUiCOq dWGD/SNnGlVe+Y+FnHh+aXv1f+JhIi5wmUOZTM+196l93UE11xuSSXnYqOFUiCOq
ifsQkhc/a8mDum1+LPVFif6Ho05BKBEJxL1r+S5maTBveKgmzNAju7NTrM6Q6sSz ifsQkhc/a8mDum1+LPVFif6Ho05BKBEJxL1r+S5maTBveKgmzNAju7NTrM6Q6sSz
7ZvyQusB03izr0KrnWOxIKJ7SSn+4/Jo2LHYjY8O+aSSNhE1RDpOyEHKxUwbOead 7ZvyQusB03izr0KrnWOxIKJ7SSn+4/Jo2LHYjY8O+aSSNhE1RDpOyEHKxUwbOead
ABEBAAGJAjYEGAEKACAWIQQe1m3Y2TV6Q1OH6ta8fsHQn/DSXQUCXebSCAIbDAAK ABEBAAGJAjYEGAEKACAWIQQe1m3Y2TV6Q1OH6ta8fsHQn/DSXQUCXebSCAIbDAAK
CRC8fsHQn/DSXTzQEACgKTcTDrEThiogWLbPyWslvCFGHdGP6qPWJK71cTFC8t3a CRC8fsHQn/DSXTzQEACgKTcTDrEThiogWLbPyWslvCFGHdGP6qPWJK71cTFC8t3a
1s/LLlkLYVvsVQ8nll88m7JcC1iVDiw9zKgQCDrJEeSWSEZT1BWMdx3eF9Hk1D8K 1s/LLlkLYVvsVQ8nll88m7JcC1iVDiw9zKgQCDrJEeSWSEZT1BWMdx3eF9Hk1D8K
eflQ0scuzTRTci/Ni43FU1wlRlIA+esNow7TfhkvWSTCc40J1EB5M3x1/nJwoA2V eflQ0scuzTRTci/Ni43FU1wlRlIA+esNow7TfhkvWSTCc40J1EB5M3x1/nJwoA2V
Ps6kYL/LC1WvYQ7r/Mcj9MZ3tlY75iRFhDs4JxoLPMFd2U4KdG1HeNdya2T1+ZRG Ps6kYL/LC1WvYQ7r/Mcj9MZ3tlY75iRFhDs4JxoLPMFd2U4KdG1HeNdya2T1+ZRG
fBOAzUrHzYds28VFP21gwO1r32J3zRpqIv2qXqIlafalGM274TtvRU8tAM2qnPGu fBOAzUrHzYds28VFP21gwO1r32J3zRpqIv2qXqIlafalGM274TtvRU8tAM2qnPGu
YCH+zhASnQ2ikYeOQEStdtPbAxg+z2JYxbEr3Xik7gH7/HyYZgHz4Gsj4z+PiJbM YCH+zhASnQ2ikYeOQEStdtPbAxg+z2JYxbEr3Xik7gH7/HyYZgHz4Gsj4z+PiJbM
2nybxylNQZq7+cGPw07qIN6iWhg7T+/km870IeW6a9tPy2IPWMIP6ryrfJ/Ajqq5 2nybxylNQZq7+cGPw07qIN6iWhg7T+/km870IeW6a9tPy2IPWMIP6ryrfJ/Ajqq5
SDc9QsXjhZ8WJ8fxSE00J3wTNTgJA6S3DcHIUrX2MxBlhFYGcsA7DmVHYVIhyene SDc9QsXjhZ8WJ8fxSE00J3wTNTgJA6S3DcHIUrX2MxBlhFYGcsA7DmVHYVIhyene
Uk+HRFp7oUJqXDWrwNeiQvh1Eb070WbU3ydgJN26e6imMjRjsKZxv1QawCjQpOvM Uk+HRFp7oUJqXDWrwNeiQvh1Eb070WbU3ydgJN26e6imMjRjsKZxv1QawCjQpOvM
hV5wYfwrZ7ecK6Oa3NxotE6UycBaX1TQ8n3uQllJT157mZOAKbM6x+HQZLpCoSoF hV5wYfwrZ7ecK6Oa3NxotE6UycBaX1TQ8n3uQllJT157mZOAKbM6x+HQZLpCoSoF
0qKFoqtsy5TFb+3B7q52zNQ0FLX37kdMLVCIxiHXs+xwGrEbJzLbSs99wOAGJQ== 0qKFoqtsy5TFb+3B7q52zNQ0FLX37kdMLVCIxiHXs+xwGrEbJzLbSs99wOAGJQ==
=dwdO =dwdO
-----END PGP PUBLIC KEY BLOCK----- -----END PGP PUBLIC KEY BLOCK-----

View File

@@ -1,42 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>silentdragonxlite</string> <string>silentdragonxlite</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>Created by Qt/QMake</string> <string>Created by Qt/QMake</string>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>logo.icns</string> <string>logo.icns</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>is.dragonx.SilentDragonXLite</string> <string>is.dragonx.SilentDragonXLite</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>10.11</string> <string>10.11</string>
<key>NOTE</key> <key>NOTE</key>
<string>This file was generated by Qt/QMake.</string> <string>This file was generated by Qt/QMake.</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>
<string>NSApplication</string> <string>NSApplication</string>
<key>NSSupportsAutomaticGraphicsSwitching</key> <key>NSSupportsAutomaticGraphicsSwitching</key>
<true/> <true/>
<key>NSRequiresAquaSystemAppearance</key> <key>NSRequiresAquaSystemAppearance</key>
<string>YES</string> <string>YES</string>
<key>CFBundleURLTypes</key> <key>CFBundleURLTypes</key>
<array> <array>
<dict> <dict>
<key>CFBundleURLName</key> <key>CFBundleURLName</key>
<string>hush URI</string> <string>hush URI</string>
<key>CFBundleURLSchemes</key> <key>CFBundleURLSchemes</key>
<array> <array>
<string>hush</string> <string>hush</string>
</array> </array>
</dict> </dict>
</array> </array>
<key>NSUIElement</key> <key>NSUIElement</key>
<true/> <true/>
</dict> </dict>
</plist> </plist>

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 265.7 283.5" style="enable-background:new 0 0 265.7 283.5;" xml:space="preserve"> viewBox="0 0 265.7 283.5" style="enable-background:new 0 0 265.7 283.5;" xml:space="preserve">
<g> <g>
<path d="M132.9,0C59.8,0,0,59.8,0,132.9c0,73,59.8,132.9,132.9,132.9c73,0,132.9-59.8,132.9-132.9C265.7,59.8,205.9,0,132.9,0 <path d="M132.9,0C59.8,0,0,59.8,0,132.9c0,73,59.8,132.9,132.9,132.9c73,0,132.9-59.8,132.9-132.9C265.7,59.8,205.9,0,132.9,0
L132.9,0z M199.3,146.2h-53.1v53.1h-26.6v-53.1H66.4v-26.6h53.1V66.4h26.6v53.1h53.1V146.2z M199.3,146.2"/> L132.9,0z M199.3,146.2h-53.1v53.1h-26.6v-53.1H66.4v-26.6h53.1V66.4h26.6v53.1h53.1V146.2z M199.3,146.2"/>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 604 B

After

Width:  |  Height:  |  Size: 613 B

File diff suppressed because it is too large Load Diff

View File

@@ -1,88 +1,88 @@
QWidget, QMainWindow, QMenuBar, QMenu, QDialog, QTabWidget, QTableView, QScrollArea, QGroupBox, QPlainTextEdit, QLineEdit, QLabel, MainWindow QWidget, QMainWindow, QMenuBar, QMenu, QDialog, QTabWidget, QTableView, QScrollArea, QGroupBox, QPlainTextEdit, QLineEdit, QLabel, MainWindow
{ {
background-color: #303335; background-color: #303335;
color: #ffffff; color: #ffffff;
} }
QTabWidget QTabBar::tab { QTabWidget QTabBar::tab {
padding-left:20px; padding-left:20px;
padding-right:20px; padding-right:20px;
padding-top:5px; padding-top:5px;
padding-bottom:5px; padding-bottom:5px;
border: 1px solid #525355; border: 1px solid #525355;
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #3E4244); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #3E4244);
} }
QTabWidget QTabBar::tab:selected { QTabWidget QTabBar::tab:selected {
min-height: 10px; min-height: 10px;
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #525355, stop: 1 #303335); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #525355, stop: 1 #303335);
color:#fff; color:#fff;
border: 1px ridge #000; border: 1px ridge #000;
} }
QTabWidget QTabBar::tab:hover { QTabWidget QTabBar::tab:hover {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #3E4244); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #3E4244);
color:#fff; color:#fff;
border: 1px ridge #fff; border: 1px ridge #fff;
min-height: 20px; min-height: 20px;
} }
QHeaderView { /* Table Header */ QHeaderView { /* Table Header */
background-color:#303335; background-color:#303335;
} }
QHeaderView::section { /* Table Header Sections */ QHeaderView::section { /* Table Header Sections */
qproperty-alignment:center; qproperty-alignment:center;
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #3E4244); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #3E4244);
color:#fff; color:#fff;
min-height:25px; min-height:25px;
font-weight:bold; font-weight:bold;
font-size:11px; font-size:11px;
outline:0; outline:0;
border:1px solid #525355; border:1px solid #525355;
border-right:1px solid #fff; border-right:1px solid #fff;
border-left:1px solid #fff; border-left:1px solid #fff;
padding-left:5px; padding-left:5px;
padding-right:5px; padding-right:5px;
padding-top:2px; padding-top:2px;
padding-bottom:2px; padding-bottom:2px;
} }
QHeaderView::section:last { QHeaderView::section:last {
border-right: 0px solid #d7d7d7; border-right: 0px solid #d7d7d7;
} }
QScrollArea { QScrollArea {
background:transparent; background:transparent;
border:0px; border:0px;
} }
QTableView { /* Table - has to be selected as a class otherwise it throws off QCalendarWidget */ QTableView { /* Table - has to be selected as a class otherwise it throws off QCalendarWidget */
background:#303335; background:#303335;
} }
QTableView::item { /* Table Item */ QTableView::item { /* Table Item */
background-color:#303335; background-color:#303335;
border:1px solid #fff; border:1px solid #fff;
font-size:12px; font-size:12px;
} }
QTableView::item:selected { /* Table Item Selected */ QTableView::item:selected { /* Table Item Selected */
background-color:#fff; background-color:#fff;
color:#000; color:#000;
} }
QMenuBar { QMenuBar {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #525355, stop: 1 #303335); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #525355, stop: 1 #303335);
color: #fff; color: #fff;
} }
QMenuBar::item { QMenuBar::item {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #525355, stop: 1 #303335); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #525355, stop: 1 #303335);
color: #fff; color: #fff;
} }
QMenuBar::item:selected { QMenuBar::item:selected {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #3E4244); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #3E4244);
} }

View File

@@ -1,5 +1,5 @@
QWidget, QMainWindow, QMenuBar, QMenu, QDialog, QTabWidget, QTableView, QTableView::item, QScrollArea, QGroupBox, QPlainTextEdit, QLineEdit, QLabel, MainWindow QWidget, QMainWindow, QMenuBar, QMenu, QDialog, QTabWidget, QTableView, QTableView::item, QScrollArea, QGroupBox, QPlainTextEdit, QLineEdit, QLabel, MainWindow
{ {
/**/ /**/
} }

View File

@@ -1,90 +1,90 @@
QWidget, QMainWindow, QMenuBar, QMenu, QDialog, QTabWidget, QTableView, QScrollArea, QGroupBox, QWidget, QPlainTextEdit, QLineEdit, QLabel, MainWindow QWidget, QMainWindow, QMenuBar, QMenu, QDialog, QTabWidget, QTableView, QScrollArea, QGroupBox, QWidget, QPlainTextEdit, QLineEdit, QLabel, MainWindow
{ {
background-color: #dadada; background-color: #dadada;
color: #000000; color: #000000;
} }
QTabWidget QTabBar::tab { QTabWidget QTabBar::tab {
padding-left:20px; padding-left:20px;
padding-right:20px; padding-right:20px;
padding-top:5px; padding-top:5px;
padding-bottom:5px; padding-bottom:5px;
border: 1px solid #525355; border: 1px solid #525355;
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #DADADA, stop: 1 #747577); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #DADADA, stop: 1 #747577);
color:#fff; color:#fff;
} }
QTabWidget QTabBar::tab:selected { QTabWidget QTabBar::tab:selected {
min-height: 10px; min-height: 10px;
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #DADADA); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #DADADA);
color:#000; color:#000;
border: 1px ridge #000; border: 1px ridge #000;
} }
QTabWidget QTabBar::tab:hover { QTabWidget QTabBar::tab:hover {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #DADADA); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #DADADA);
color:#000; color:#000;
border: 1px ridge #fff; border: 1px ridge #fff;
min-height: 20px min-height: 20px
} }
QHeaderView { /* Table Header */ QHeaderView { /* Table Header */
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #DADADA, stop: 1 #747577); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #DADADA, stop: 1 #747577);
} }
QHeaderView::section { /* Table Header Sections */ QHeaderView::section { /* Table Header Sections */
qproperty-alignment:center; qproperty-alignment:center;
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #DADADA, stop: 1 #747577); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #DADADA, stop: 1 #747577);
color:#fff; color:#fff;
min-height:25px; min-height:25px;
font-weight:bold; font-weight:bold;
font-size:11px; font-size:11px;
outline:0; outline:0;
border:1px solid #747577; border:1px solid #747577;
border-right:1px solid #fff; border-right:1px solid #fff;
border-left:1px solid #fff; border-left:1px solid #fff;
padding-left:5px; padding-left:5px;
padding-right:5px; padding-right:5px;
padding-top:2px; padding-top:2px;
padding-bottom:2px; padding-bottom:2px;
} }
QHeaderView::section:last { QHeaderView::section:last {
border-right: 0px solid #d7d7d7; border-right: 0px solid #d7d7d7;
} }
QScrollArea { QScrollArea {
background:transparent; background:transparent;
border:0px; border:0px;
} }
QTableView { /* Table - has to be selected as a class otherwise it throws off QCalendarWidget */ QTableView { /* Table - has to be selected as a class otherwise it throws off QCalendarWidget */
background:#DADADA; background:#DADADA;
} }
QTableView::item { /* Table Item */ QTableView::item { /* Table Item */
background-color:#DADADA; background-color:#DADADA;
border:1px solid #fff; border:1px solid #fff;
font-size:12px; font-size:12px;
} }
QTableView::item:selected { /* Table Item Selected */ QTableView::item:selected { /* Table Item Selected */
background-color:#747577; background-color:#747577;
color:#fff; color:#fff;
} }
QMenuBar { QMenuBar {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #DADADA, stop: 1 #747577); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #DADADA, stop: 1 #747577);
color: #fff; color: #fff;
} }
QMenuBar::item { QMenuBar::item {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #DADADA, stop: 1 #747577); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #DADADA, stop: 1 #747577);
color: #fff; color: #fff;
} }
QMenuBar::item:selected { QMenuBar::item:selected {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #DADADA); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #DADADA);
color:#000; color:#000;
} }

View File

@@ -1,148 +1,148 @@
/* /*
Theme: Midnight Qt Theme: Midnight Qt
Version: 1.0.2 Version: 1.0.2
Reference: https://doc.qt.io/qt-5/stylesheet-reference.html Reference: https://doc.qt.io/qt-5/stylesheet-reference.html
Author: Charles Sharpe Author: Charles Sharpe
Date: Apr. 23, 2020 Date: Apr. 23, 2020
Website: https://www.csharpe.me Website: https://www.csharpe.me
License: https://opensource.org/licenses/MIT License: https://opensource.org/licenses/MIT
*/ */
QWidget, QMainWindow, QMenuBar, QMenu, QDialog, QTabWidget, QTableView, QScrollArea, QGroupBox, QPlainTextEdit, QLineEdit, QLabel, MainWindow, QPixmap, QHBoxLayout, QVBoxLayout, QGridLayout, QAbstractItemView, QFrame QWidget, QMainWindow, QMenuBar, QMenu, QDialog, QTabWidget, QTableView, QScrollArea, QGroupBox, QPlainTextEdit, QLineEdit, QLabel, MainWindow, QPixmap, QHBoxLayout, QVBoxLayout, QGridLayout, QAbstractItemView, QFrame
{ {
background-color: #111; background-color: #111;
color: #fff; color: #fff;
} }
/* /*
QPushButton { QPushButton {
padding: 10px 15px; padding: 10px 15px;
} }
*/ */
QPushButton:hover { QPushButton:hover {
background: #222; background: #222;
} }
/* /*
QLineEdit, QRadioButton::indicator::unchecked, QCheckBox::indicator::unchecked { QLineEdit, QRadioButton::indicator::unchecked, QCheckBox::indicator::unchecked {
background: #222; background: #222;
border: 1px solid #333; border: 1px solid #333;
border-radius: 3px; border-radius: 3px;
} }
QLineEdit { QLineEdit {
font-size: 12px; font-size: 12px;
} }
QLineEdit:focus { QLineEdit:focus {
border: 1px solid #9d8400; border: 1px solid #9d8400;
}*/ }*/
/* /*
QWidget QLabel { QWidget QLabel {
font-size: 11pt; font-size: 11pt;
} }
*/ */
QWidget QCheckBox { QWidget QCheckBox {
font-weight: bold; font-weight: bold;
} }
QTabWidget QTabBar::tab { QTabWidget QTabBar::tab {
/*min-height: 15px;*/ /*min-height: 15px;*/
padding-left:20px; padding-left:20px;
padding-right:20px; padding-right:20px;
padding-top:5px; padding-top:5px;
padding-bottom:5px; padding-bottom:5px;
border: 1px ridge #222; border: 1px ridge #222;
left: 1px; /* Fix 1px alignment */ left: 1px; /* Fix 1px alignment */
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #333, stop: 1 #111); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #333, stop: 1 #111);
} }
QTabWidget QTabBar::tab:selected { QTabWidget QTabBar::tab:selected {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #555, stop: 1 #111); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #555, stop: 1 #111);
color:#fff; color:#fff;
border: 1px ridge #222; border: 1px ridge #222;
border-bottom: 0px; /* Overwrites border-bottom */ border-bottom: 0px; /* Overwrites border-bottom */
} }
QTabWidget QTabBar::tab:hover { QTabWidget QTabBar::tab:hover {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #555, stop: 1 #111); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #555, stop: 1 #111);
min-height: 20px min-height: 20px
} }
QHeaderView { /* Table Header */ QHeaderView { /* Table Header */
background-color:#111; background-color:#111;
} }
QHeaderView::section { /* Table Header Sections */ QHeaderView::section { /* Table Header Sections */
qproperty-alignment:center; qproperty-alignment:center;
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #333, stop: 1 #111); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #333, stop: 1 #111);
color:#fff; color:#fff;
min-height:25px; min-height:25px;
font-weight:bold; font-weight:bold;
font-size:11px; font-size:11px;
outline:0; outline:0;
border:1px ridge #222; border:1px ridge #222;
padding: 2px 5px; padding: 2px 5px;
} }
QHeaderView::section:last { QHeaderView::section:last {
border-right: 0px ridge #222; border-right: 0px ridge #222;
} }
QScrollArea { QScrollArea {
background:transparent; background:transparent;
border:0px; border:0px;
} }
QTableView { /* Table - has to be selected as a class otherwise it throws off QCalendarWidget */ QTableView { /* Table - has to be selected as a class otherwise it throws off QCalendarWidget */
background:#111; background:#111;
} }
QTableView::item { /* Table Item */ QTableView::item { /* Table Item */
background-color:#111; background-color:#111;
border:1px solid #222; border:1px solid #222;
font-size:12px; font-size:12px;
} }
QTableView::item:selected { /* Table Item Selected */ QTableView::item:selected { /* Table Item Selected */
background-color:#fff; background-color:#fff;
color:#000; color:#000;
} }
QMenuBar { QMenuBar {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #222, stop: 1 #111); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #222, stop: 1 #111);
color: #fff; color: #fff;
} }
QMenuBar::item { QMenuBar::item {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #222, stop: 1 #111); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #222, stop: 1 #111);
color: #fff; color: #fff;
/*padding: 5px 7px; /*padding: 5px 7px;
margin: 0px;*/ margin: 0px;*/
} }
QMenuBar::item:selected { QMenuBar::item:selected {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #333, stop: 1 #111); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #333, stop: 1 #111);
} }
QMenu { QMenu {
border:1px solid #222; border:1px solid #222;
} }
QMenu::item { QMenu::item {
padding: 7px 15px; padding: 7px 15px;
} }
QMenu::item:selected { QMenu::item:selected {
background: #222; background: #222;
} }
QMenu::separator { QMenu::separator {
height: 1px; height: 1px;
margin: 3px 7px 3px 7px; /* space at ends of separator */ margin: 3px 7px 3px 7px; /* space at ends of separator */
background: #222; background: #222;
} }

View File

@@ -1,114 +1,596 @@
QWidget, QMainWindow, QMenuBar, QMenu, QDialog, QTabWidget, QTableView, QScrollArea, QGroupBox, QPlainTextEdit, QLineEdit, QLabel, MainWindow { /*
background-color: #232834; colors
color: #91a4b8; background: rgb(24, 12, 12)
} object-background: #45505e
QTabWidget QTabBar::tab { object-background-hover: #1f242b
padding-left:20px; object-background-press: #0c0e11
padding-right:20px; text-main: white
padding-top:5px; text-secondary: rgba(255, 255, 255, 0.75)
padding-bottom:5px; text-dark: rgb(24, 12, 12)
border: 1px solid #343F4B; border: rgb(216, 38, 82)
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #343F4B, stop: 1 #232834); */
}
QTabWidget QTabBar::tab:selected {
min-height: 10px; QWidget, QMainWindow, QMenuBar, QMenu, QDialog, QTabWidget, QTableView, QScrollArea, QGroupBox, QPlainTextEdit, QLineEdit, QLabel, MainWindow {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #343F4B, stop: 1 #232834); color: white;
color:#91a4b8; border: 0px solid rgba(0, 0, 0, 0);
border: 1px ridge #91a4b8; background-color: rgb(24, 21, 21);
} }
QTabWidget QTabBar::tab:hover {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #343F4B, stop: 1 #232834);
color:#91a4b8; /* window menu options */
border: 1px ridge #91a4b8; QMenu {
min-height: 20px color: white;
} border: 1px solid rgba(216, 38, 82, .5);
QHeaderView { border-radius: 8px;
/* Table Header */ background-color: rgba(24, 21, 21, 1);
background-color:#232834; }
}
QHeaderView::section { QMenuBar {
/* Table Header Sections */ color: rgb(216, 38, 82);
qproperty-alignment:center; color: white;
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #343F4B, stop: 1 #232834); }
color:#91a4b8;
min-height:25px; QMenuBar::item {
font-weight:bold; color: rgb(216, 38, 82);
font-size:11px; color: white;
outline:0; }
border:1px solid #343F4B;
border-right:1px solid #91a4b8;
border-left:1px solid #91a4b8; #title {
padding-left:5px; margin-bottom: 8px;
padding-right:5px; }
padding-top:2px;
padding-bottom:2px; QTabWidget QTabBar {
} background-color: rgba(41, 21, 21, .25);
QHeaderView::section:last { width: 600px;
border-right: 0px solid #d7d7d7; }
}
QScrollArea { QTabWidget QTabBar::tab {
background:transparent; margin: 12px 4px;
border:0px; padding: 6px 4px;
} font-size: 20px;
QTableView { border: 0px solid white;
/* Table - has to be selected as a class otherwise it throws off QCalendarWidget */ border-radius: 9px;
background:#232834; background-color: rgba(41, 21, 21, 1);
} min-width: 130px;
QTableView::item { }
/* Table Item */ QTabWidget QTabBar::tab::last {
background-color:#232834; min-width: 280px;
border:1px solid #91a4b8; }
font-size:12px;
} QTabWidget QTabBar::tab:selected {
QTableView::item:selected { color: rgba(255, 255, 255, 0.85);
/* Table Item Selected */ border: 1px solid rgba(216, 38, 82, 0.85);
background-color:#91a4b8; background-color: rgba(216, 38, 82, 0.25);
color:#232834; }
}
QMenuBar { QTabWidget QTabBar::tab:hover {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #343F4B, stop: 1 #232834); color: white;
color: #91a4b8; border: 1px solid rgba(216, 38, 82, 1);
} background-color: rgba(216, 38, 82, 0.4);
QMenuBar::item { }
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #343F4B, stop: 1 #232834);
color: #91a4b8; QHeaderView {
} /* Table Header */
QMenuBar::item:selected { background-color: rgba(0, 0, 0, 0);
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #343F4B, stop: 1 #232834); }
}
QPushButton#startmining { QHeaderView::section {
background-color: #343F4B; /* Table Header Sections */
border-color: #91A4B8; /* qproperty-alignment:center; */
padding: 10px; min-height:25px;
} outline:0;
QPushButton#startmining:hover { padding-left:5px;
background-color: #232834; padding-right:5px;
} padding-top:2px;
QPushButton#startmining:pressed { padding-bottom:2px;
background-color: #232834; color:#91a4b8;
} font-weight:bold;
QPushButton#startmining:disabled { font-size:11px;
background-color: #232834; border:1px solid rgb(41, 21, 21);
} border-right:1px solid #91a4b8;
QPushButton#stopmining { border-left:1px solid #91a4b8;
background-color: #343F4B; }
border-color: #91A4B8;
padding: 10px;
margin-top: 7px; QTabBar {
} margin-bottom: 16px;
QPushButton#stopmining:hover { }
background-color: #232834;
} QLabel {
QPushButton#stopmining:pressed { color: rgba(255, 255, 255, 0.75);
background-color: #232834; border: 0px solid rgba(255, 255, 255, 0);
} background-color: rgba(255, 255, 255, 0);
QPushButton#stopmining:disabled { }
background-color: #232834;
}
QComboBox#genproclimit{
font-size: 24px; QLineEdit {
height: 40px; padding: 2px 4px;
} color: white;
QMenu::item:selected{ border: 1px solid rgb(216, 38, 82);
background-color: #343F4B border-top-right-radius: 4px;
} border-bottom-right-radius: 4px;
background-color: rgba(41, 21, 21, 0.75);
}
QGroupBox{
padding: 12px;
padding-top: 32px;
background-color: rgba(24, 12, 12, 0.45);
border: 1px solid rgba(216, 38, 82, 0.6);
border-radius: 8px;
font-size: 18px;
}
QGroupBox::title {
padding: 4px 12px;
color: rgba(255, 255, 255, 0.85);
border: 1px solid rgba(216, 38, 82, 0.25);
border-top-left-radius: 8px;
border-bottom-right-radius: 8px;
background-color: rgba(216, 38, 82, 0.05);
}
QGroupBox#groupBox QLabel {
font-size: 16px;
}
QPushButton {
padding: 6px 10px;
color: rgba(255, 255, 255, 0.5);
border: 1px solid rgba(216, 38, 82, 0.5);
border-radius: 4px;
background-color: rgba(216, 38, 82, 0.15);
font-size: 16px;
}
QPushButton:hover {
color: rgba(255, 255, 255, 0.75);
border: 1px solid rgba(216, 38, 82, 0.55);
background-color: rgba(216, 38, 82, 0.45);
}
QPushButton:selected {
color: rgba(255, 255, 255, 0.75);
border: 1px solid rgba(216, 38, 82, 0.75);
background-color: rgba(216, 38, 82, 0.75);
}
QPushButton:disabled {
color: rgba(255, 255, 255, 0.35);
border: 1px solid rgba(216, 38, 82, 0.15);
background-color: rgba(41, 21, 21, 0.5);
}
QComboBox{
margin: 0;
padding: 2px 4px;
border: 1px solid rgba(216, 38, 82, 0.75);
border-radius: 2px;
background-color: rgba(24, 12, 12, 0.5);
}
QScrollArea#sendToScrollArea QWidget {
border: 0px solid rgb(216, 38, 82, 0);
background-color: rgba(24, 12, 12, 0.45);
}
QScrollBar {
border: 0px solid rgba(216, 38, 82, 0);
background-color: rgba(24, 12, 12, 0);
}
QScrollBar:vertical {
width: 22px;
margin: 0 2px;
border: 2px solid rgba(216, 38, 82, 0);
background-color: rgba(0, 0, 0 , 0);
}
QScrollBar::handle:vertical,
QScrollBar::handle:horizontal {
border: 1px solid rgba(216, 38, 82, 1);
border-radius: 6px;
background-color: rgba(216, 38, 82, 0.25);
}
QScrollBar::handle:vertical {
border-radius: 6px;
}
QScrollBar::add-line {
height: 0px;
subcontrol-position: bottom;
subcontrol-origin: margin;
}
QScrollBar::sub-line {
height: 0px;
subcontrol-position: top;
subcontrol-origin: margin;
}
QScrollBar::add-page, QScrollBar::sub-page {
background: none;
}
QComboBox QAbstractItemView {
margin: 0;
padding: 2px 4px;
border: 1px solid rgba(216, 38, 82, 0.75);
border-radius: 2px;
background-color: rgba(24, 12, 12, 0.5);
selection-background-color: rgb(118, 132, 153);
}
QComboBox QAbstractItemView::item{
margin: 0;
padding: 2px 4px;
border: 1px solid rgba(216, 38, 82, 0.25);
border-radius: 2px;
background-color: rgba(24, 12, 12, 0.5);
outline: none;
}
QComboBox QAbstractItemView::item:selected{
margin: 0;
padding: 2px 4px;
border: 1px solid rgba(216, 38, 82, 0.75);
border-radius: 2px;
background-color: rgba(24, 12, 12, 0.5);
outline:none;
}
QComboBox QAbstractItemView::item:hover {
margin: 0;
padding: 2px 4px;
border: 1px solid rgba(216, 38, 82, 0.75);
border-radius: 2px;
background-color: rgba(24, 12, 12, 0.75);
outline:none;
}
QListView{
margin: 0;
padding: 2px 4px;
border: 1px solid rgba(216, 38, 82, 0.75);
border-radius: 2px;
background-color: rgba(24, 12, 12, 0.5);
}
/* TAB 1 - HUSHCHAT */
/* chat window */
QListView#listChat,
QListView#listContactWidget {
border-radius: 8px;
border: 1px solid rgba(216, 38, 82, 0.5);
background-color: rgba(216, 38, 82, 0.05);
}
QPushButton#emojiButton,
QPushButton#pushContact,
QPushButton#safeContactRequest,
QPushButton#givemeZaddr,
QPushButton#sendChatButton {
border-radius: 4px;
}
QLabel#lblMessage {
color: white;
border: 1px solid rgba(216, 38, 82, 0.5);
background-color: rgba(216, 38, 82, 0.05);
}
/* SEND TAB */
QWidget#tab_2 QLabel{
border: 0px solid white;
background-color: rgba(255, 255, 255, 0);
}
/* MEMO */
QWidget#tab_2 QLabel#MemoTxt1,
QWidget#tab_2 QLabel#MemoTxt2,
QWidget#tab_2 QLabel#MemoTxt3,
QWidget#tab_2 QLabel#MemoTxt4,
QWidget#tab_2 QLabel#MemoTxt5,
QWidget#tab_2 QLabel#MemoTxt6 {
border: 1px solid rgba(216, 38, 82, 0.25);
background-color: rgba(24, 12, 12, 0.25);
border-radius: 4px;
padding: 4px 2px;
}
QWidget#tab_2 QLineEdit {
border: 1px solid rgb(216, 38, 82);
padding: 2px 4px;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
background-color: rgba(24, 12, 12, 0.75);
}
/* From Section */
/* drop down address menu */
AddressCombo {
margin: 0;
padding: 2px 4px;
border: 1px solid rgba(216, 38, 82, 0.75);
border-radius: 2px;
background-color: rgba(24, 12, 12, 0.5);
}
/* Send To Section */
/* Recipient sub-section */
QWidget#tab_2 QGroupBox{
border: 1px solid rgba(216, 38, 82, 0.5);
border-radius: 4px;
background-color: rgba(216, 38, 82, 0.1);
}
QWidget#tab_2 QGroupBox::title {
margin-left: 24px;
font-size: 6px;
border-radius: 0;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
}
/* To Section */
QWidget#tab_2 QGroupBox#groupBox_3,
QWidget#tab_2 QGroupBox#groupBox_4 {
border: 1px solid rgba(216, 38, 82, 0.6);
border-radius: 8px;
background-color: rgba(24, 12, 12, 0.45);
}
QWidget#tab_2 QGroupBox#groupBox_3::title,
QWidget#tab_2 QGroupBox#groupBox_4::title {
border-radius: 0;
border-top-left-radius: 8px;
border-bottom-right-radius: 8px;
margin: 0;
}
/* Max Available */
QCheckBox#Max1 {
padding: 4px;
border-radius: 4px;
background-color: rgba(24, 12, 12, 0.25);
}
QCheckBox#Max1:hover {
border: 1px solid rgba(216, 38, 82, 0.25);
background-color: rgba(216, 38, 82, 0.25);
}
QCheckBox#Max1:pressed,
QCheckBox#Max1:checked {
border: 1px solid rgba(216, 38, 82, 0.75);
background-color: rgba(216, 38, 82, 0.5);
color: white;
}
QLabel#AmtUSD1,
QLabel#txtAvailableUSD {
border: 0px solid rgba(216, 38, 82, 0.25);
background-color: rgba(255, 255, 255, 0.15);
border-radius: 2px;
}
QWidget#tab_2 QGroupBox#groupBox_4 {
height: 12px;
padding: 0;
margin: 0;
border: 1px solid rgba(216, 38, 82, 0.25);
color: white;
}
QWidget#tab_2 QPushButton {
color: rgba(255, 255, 255, 0.75);
border: 1px solid rgba(216, 38, 82, 0.25);
background-color: rgba(216, 38, 82, 0.25);
}
QWidget#tab_2 QPushButton:hover {
color: rgba(255, 255, 255, 0.75);
border: 1px solid rgba(216, 38, 82, 0.55);
background-color: rgba(216, 38, 82, 0.45);
}
QWidget#tab_2 QPushButton:selected {
color: rgba(255, 255, 255, 1);
border: 1px solid rgba(216, 38, 82, 0.75);
background-color: rgba(216, 38, 82, 0.5);
}
QWidget#tab_2 QPushButton:disabled {
color: rgba(24, 12, 12, 0.75);
border: 1px solid rgba(216, 38, 82, 0.05);
background-color: rgba(255, 255, 255, 0.15);
}
QTableView {
/* Table - has to be selected as a class otherwise it throws off QCalendarWidget */
qproperty-showGrid: "false";
padding-right: 8px;
color: rgba(0, 0, 0, 0);
background-color: rgba(0, 0, 0, 0);
}
QTableView QTableCornerButton::section {
border: 0px solid rgba(0, 0, 0, 0);
background-color:rgba(0, 0, 0, 0);
}
QTableView::item {
/* Table Item */
padding: 2px;
color: white;
font-size:12px;
border: 1px solid rgba(216, 38, 82, .5);
background-color:rgba(216, 38, 82, 0.25);
}
QTableView::item:selected {
/* Table Item Selected */
margin: 4px 0;
color:rgb(41, 21, 21);
border: 1px solid rgba(216, 38, 82, .75);
background-color:rgba(216, 38, 82, 0.5);
}
QTableView { outline:none; }
QTableView#balancesTable {
/* background-color: rgba(255, 255, 255, 0); */
}
QTableView#balancesTable::item {
/* background-color: rgba(255, 255, 255, 0); */
border: 1px solid rgba(216, 38, 82, 0.25);
}
QHeaderView::section {
border: 1px solid rgba(216, 38, 82, 0.5);
background-color: rgba(0, 0, 0, 0);
}
QHeaderView::section::first {
border-top-left-radius: 10px;
background-color: rgb(41, 21, 21);
}
QHeaderView::section::middle {
background-color: rgb(41, 21, 21);
}
QHeaderView::section::last {
border: 1px solid rgba(216, 38, 82, 0.5);
border-top-right-radius: 10px;
background-color: rgb(41, 21, 21);
}
QHeaderView::section::vertical {
border: 0px solid rgba(0, 0, 0, 0);
background-color: rgba(0, 0, 0, 0);
}
QDialog#requestDialog {
min-width: 820;
min-height: 520;
}
QDialog#requestDialog QLabel#label_8
{
min-height: 25;
padding-top: 7px;
}
QDialog#requestDialog QLabel#label_7{
padding-left: 2px;
min-height: 25;
}
QDialog#requestDialog QLabel#label_5,
QDialog#requestDialog QLabel#label_6 {
min-height: 25;
padding-top: 2px;
}
QDialog#requestDialog QPushButton {
min-height: 32;
}
QDialog#requestDialog QPushButton#addContact {
min-width: 150px;
}
/* ===== SETUP WIZARD & DIALOG CONTRAST FIXES ===== */
QWizard, QWizardPage {
color: white;
background-color: rgb(24, 21, 21);
}
QWizard QLabel, QWizardPage QLabel {
color: rgba(255, 255, 255, 0.85);
}
QWizard QPushButton, QWizardPage QPushButton {
color: rgba(255, 255, 255, 0.75);
border: 1px solid rgba(216, 38, 82, 0.5);
background-color: rgba(216, 38, 82, 0.15);
}
QWizard QPushButton:hover, QWizardPage QPushButton:hover {
color: white;
border: 1px solid rgba(216, 38, 82, 0.75);
background-color: rgba(216, 38, 82, 0.45);
}
QTextBrowser, QPlainTextEdit, QTextEdit {
color: white;
border: 1px solid rgba(216, 38, 82, 0.5);
background-color: rgba(41, 21, 21, 0.75);
}
QCheckBox {
color: rgba(255, 255, 255, 0.85);
}
QCheckBox::indicator {
border: 1px solid rgba(216, 38, 82, 0.75);
background-color: rgba(41, 21, 21, 0.5);
}
QCheckBox::indicator:checked {
background-color: rgba(216, 38, 82, 0.75);
}
QRadioButton {
color: rgba(255, 255, 255, 0.85);
}
QDialogButtonBox QPushButton {
color: rgba(255, 255, 255, 0.75);
border: 1px solid rgba(216, 38, 82, 0.5);
background-color: rgba(216, 38, 82, 0.15);
min-width: 80px;
padding: 6px 16px;
}
QDialogButtonBox QPushButton:hover {
color: white;
border: 1px solid rgba(216, 38, 82, 0.75);
background-color: rgba(216, 38, 82, 0.45);
}
QMessageBox {
color: white;
background-color: rgb(24, 21, 21);
}
QMessageBox QLabel {
color: white;
}

View File

@@ -1,239 +1,239 @@
QWidget, QMainWindow, QMenuBar, QMenu, QDialog, QTabWidget, QTableView, QTableView::item, QScrollArea, QGroupBox, QPlainTextEdit, QLineEdit, QLabel, MainWindow QWidget, QMainWindow, QMenuBar, QMenu, QDialog, QTabWidget, QTableView, QTableView::item, QScrollArea, QGroupBox, QPlainTextEdit, QLineEdit, QLabel, MainWindow
{ {
/* background-color: #303335; */ /* background-color: #303335; */
background: transparent; background: transparent;
color: #ffffff; color: #ffffff;
} }
QMainWindow QMainWindow
{ {
border-image: url(':images/res/images/tile.png') 0 0 0 0 repeat repeat; border-image: url(':images/res/images/tile.png') 0 0 0 0 repeat repeat;
color: #ffffff; color: #ffffff;
} }
QTabWidget QTabBar::tab { QTabWidget QTabBar::tab {
padding-left:20px; padding-left:20px;
padding-right:20px; padding-right:20px;
padding-top:5px; padding-top:5px;
padding-bottom:5px; padding-bottom:5px;
border: 1px solid #525355; border: 1px solid #525355;
/*background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #3E4244);*/ /*background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #3E4244);*/
background-color: rgba(0, 0, 0, 128); background-color: rgba(0, 0, 0, 128);
} }
QTabWidget QTabBar::tab:selected { QTabWidget QTabBar::tab:selected {
min-height: 10px; min-height: 10px;
/*background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #525355, stop: 1 #303335);*/ /*background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #525355, stop: 1 #303335);*/
background-color: rgba(0, 64, 0, 128); background-color: rgba(0, 64, 0, 128);
color:#fff; color:#fff;
border: 1px ridge #000; border: 1px ridge #000;
} }
QTabWidget QTabBar::tab:hover { QTabWidget QTabBar::tab:hover {
/*background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #3E4244);*/ /*background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #3E4244);*/
background-color: rgba(0, 0, 0, 32); background-color: rgba(0, 0, 0, 32);
color:#fff; color:#fff;
border: 1px ridge #fff; border: 1px ridge #fff;
min-height: 20px min-height: 20px
} }
QTabWidget::pane { QTabWidget::pane {
background-color: rgba(0, 0, 0, 128); background-color: rgba(0, 0, 0, 128);
border: 2px solid rgb(0, 0, 0); border: 2px solid rgb(0, 0, 0);
border-top-left-radius: 0px; border-top-left-radius: 0px;
border-bottom-left-radius: 4px; border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px; border-bottom-right-radius: 4px;
border-top-right-radius: 4px; border-top-right-radius: 4px;
top: -2px; top: -2px;
} }
QStatusBar { QStatusBar {
background-color: rgba(0, 0, 64, 128); background-color: rgba(0, 0, 64, 128);
} }
QHeaderView { /* Table Header */ QHeaderView { /* Table Header */
/* background-color:#303335;*/ /* background-color:#303335;*/
background-color: rgba(0, 0, 0, 64); background-color: rgba(0, 0, 0, 64);
border:1px solid #fff; border:1px solid #fff;
} }
QHeaderView::section { /* Table Header Sections */ QHeaderView::section { /* Table Header Sections */
qproperty-alignment:center; qproperty-alignment:center;
/*background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #3E4244);*/ /*background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #3E4244);*/
background: transparent; background: transparent;
color:#fff; color:#fff;
min-height:25px; min-height:25px;
font-weight:bold; font-weight:bold;
font-size:11px; font-size:11px;
outline:0; outline:0;
border:1px solid #525355; border:1px solid #525355;
border-right:1px solid #fff; border-right:1px solid #fff;
border-left:1px solid #fff; border-left:1px solid #fff;
padding-left:5px; padding-left:5px;
padding-right:5px; padding-right:5px;
padding-top:2px; padding-top:2px;
padding-bottom:2px; padding-bottom:2px;
} }
QHeaderView::section:last { QHeaderView::section:last {
border-right: 0px solid #d7d7d7; border-right: 0px solid #d7d7d7;
} }
QScrollArea { QScrollArea {
background:transparent; background:transparent;
border:0px; border:0px;
} }
QTableView { /* Table - has to be selected as a class otherwise it throws off QCalendarWidget */ QTableView { /* Table - has to be selected as a class otherwise it throws off QCalendarWidget */
/*background:#303335;*/ /*background:#303335;*/
background: transparent; background: transparent;
} }
QTableView::item { /* Table Item */ QTableView::item { /* Table Item */
/*background-color:#303335;*/ /*background-color:#303335;*/
background: transparent; background: transparent;
border:1px solid #fff; border:1px solid #fff;
font-size:12px; font-size:12px;
} }
QTableView::item:selected { /* Table Item Selected */ QTableView::item:selected { /* Table Item Selected */
background-color:#fff; background-color:#fff;
color:#000; color:#000;
} }
QMenuBar { QMenuBar {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #525355, stop: 1 #303335); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #525355, stop: 1 #303335);
color: #fff; color: #fff;
} }
QMenuBar::item { QMenuBar::item {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #525355, stop: 1 #303335); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #525355, stop: 1 #303335);
color: #fff; color: #fff;
} }
QMenuBar::item:selected { QMenuBar::item:selected {
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #3E4244); background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #3E4244);
} }
QTabBar::tab { QTabBar::tab {
background-color: rgba(0, 0, 0, 128); background-color: rgba(0, 0, 0, 128);
min-width: 150px; min-width: 150px;
padding: 4px; padding: 4px;
border-bottom: 2px solid rgb(68, 49, 141); border-bottom: 2px solid rgb(68, 49, 141);
border-top-left-radius: 4px; border-top-left-radius: 4px;
border-top-right-radius: 4px; border-top-right-radius: 4px;
} }
QTabBar::tab:selected { QTabBar::tab:selected {
/* font: bold; */ /* font: bold; */
border: 2px solid rgb(68, 49, 141); border: 2px solid rgb(68, 49, 141);
border-bottom: none; border-bottom: none;
} }
QTabBar::tab:hover { QTabBar::tab:hover {
/* font: bold; */ /* font: bold; */
border: 2px solid rgb(68, 49, 141); border: 2px solid rgb(68, 49, 141);
} }
QGroupBox { QGroupBox {
background-color: rgba(0, 0, 0, 128); background-color: rgba(0, 0, 0, 128);
font-weight: bold; font-weight: bold;
font-style: italic; font-style: italic;
border: 1px solid rgba(0, 128, 0, 128); border: 1px solid rgba(0, 128, 0, 128);
border-radius: 4px; border-radius: 4px;
padding: 4px; padding: 4px;
margin-top: 16px; margin-top: 16px;
} }
QGroupBox::title { QGroupBox::title {
subcontrol-origin: margin; subcontrol-origin: margin;
subcontrol-position: top left; subcontrol-position: top left;
left: 8px; left: 8px;
padding-left: 3px; padding-left: 3px;
padding-right: 3px; padding-right: 3px;
padding-top: 6px; padding-top: 6px;
padding-bottom: 8px; padding-bottom: 8px;
} }
QLineEdit, QPushButton, QPlainTextEdit { QLineEdit, QPushButton, QPlainTextEdit {
background-color: rgba(10, 7, 20, 128); background-color: rgba(10, 7, 20, 128);
min-width: 100px; min-width: 100px;
border: 1px solid rgb(68, 49, 141); border: 1px solid rgb(68, 49, 141);
border-radius: 4px; border-radius: 4px;
padding:5px; padding:5px;
} }
QLineEdit:focus, QPushButton:pressed, QPlainTextEdit:focus { QLineEdit:focus, QPushButton:pressed, QPlainTextEdit:focus {
border: 1px solid rgb(216, 00, 255); border: 1px solid rgb(216, 00, 255);
} }
QLineEdit:hover, QPushButton:hover, QPlainTextEdit:hover { QLineEdit:hover, QPushButton:hover, QPlainTextEdit:hover {
border: 1px solid rgb(216, 00, 255); border: 1px solid rgb(216, 00, 255);
} }
QLineEdit:disabled, QPushButton:disabled, QPlainTextEdit:disabled { QLineEdit:disabled, QPushButton:disabled, QPlainTextEdit:disabled {
border: 1px solid rgb(64, 64, 64); border: 1px solid rgb(64, 64, 64);
} }
QComboBox { QComboBox {
background-color: rgba(10, 7, 20, 128); background-color: rgba(10, 7, 20, 128);
min-height: 28px; min-height: 28px;
min-width: 80px; min-width: 80px;
border: 1px solid rgb(68, 49, 141); border: 1px solid rgb(68, 49, 141);
border-radius: 4px; border-radius: 4px;
} }
QComboBox:hover { QComboBox:hover {
border: 1px solid rgb(216, 00, 255); border: 1px solid rgb(216, 00, 255);
} }
QComboBox QAbstractItemView { QComboBox QAbstractItemView {
background-color: rgb(0, 0, 0); background-color: rgb(0, 0, 0);
border: 1px solid rgb(68, 49, 141); border: 1px solid rgb(68, 49, 141);
border-radius: 4px; border-radius: 4px;
} }
QComboBox::item { QComboBox::item {
background-color: rgb(0, 0, 0); background-color: rgb(0, 0, 0);
border: 1px solid rgb(0, 0, 0); border: 1px solid rgb(0, 0, 0);
border-radius: 4px; border-radius: 4px;
height:28px; height:28px;
} }
QComboBox::item:selected { /* when user selects item using mouse or keyboard */ QComboBox::item:selected { /* when user selects item using mouse or keyboard */
background-color: rgb(20, 15, 40); background-color: rgb(20, 15, 40);
border: 1px solid rgb(68, 49, 141); border: 1px solid rgb(68, 49, 141);
border-radius: 4px; border-radius: 4px;
} }
QCheckBox::indicator, QRadioButton::indicator { QCheckBox::indicator, QRadioButton::indicator {
border: 2px solid rgb(68, 49, 141); border: 2px solid rgb(68, 49, 141);
border-radius: 6px; border-radius: 6px;
} }
QCheckBox::indicator:checked, QRadioButton::indicator:checked { QCheckBox::indicator:checked, QRadioButton::indicator:checked {
background-color: rgba(0, 255, 0, 128); background-color: rgba(0, 255, 0, 128);
} }
QCheckBox::indicator:unchecked, QRadioButton::indicator:unchecked { QCheckBox::indicator:unchecked, QRadioButton::indicator:unchecked {
background-color: rgba(0, 16, 0, 128); background-color: rgba(0, 16, 0, 128);
} }
QCheckBox::indicator:hover, QRadioButton::indicator:hover { QCheckBox::indicator:hover, QRadioButton::indicator:hover {
border: 2px solid rgb(0, 192, 0); border: 2px solid rgb(0, 192, 0);
} }
QCheckBox::indicator:disabled, QRadioButton::indicator:disabled { QCheckBox::indicator:disabled, QRadioButton::indicator:disabled {
border: 2px solid rgb(64, 64, 64); border: 2px solid rgb(64, 64, 64);
} }
QWidget.FilledIconLabel /* targets custom ui widget by class name */ QWidget.FilledIconLabel /* targets custom ui widget by class name */
{ {
background-color: rgba(255, 255, 255, 64); background-color: rgba(255, 255, 255, 64);
border: 2px solid rgb(255, 0, 0); border: 2px solid rgb(255, 0, 0);
} }

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 225.9 283.5" style="enable-background:new 0 0 225.9 283.5;" xml:space="preserve"> viewBox="0 0 225.9 283.5" style="enable-background:new 0 0 225.9 283.5;" xml:space="preserve">
<g> <g>
<path d="M113,265.7c14.6,0,26.5-11.9,26.5-26.6H86.4C86.4,253.8,98.4,265.7,113,265.7L113,265.7z M199.3,186v-73 <path d="M113,265.7c14.6,0,26.5-11.9,26.5-26.6H86.4C86.4,253.8,98.4,265.7,113,265.7L113,265.7z M199.3,186v-73
c0-41.2-27.9-74.4-66.4-83.7v-9.4C132.9,9.3,123.6,0,113,0C102.3,0,93,9.3,93,19.9v9.4C54.5,38.5,26.6,71.8,26.6,113v73L0,212.6 c0-41.2-27.9-74.4-66.4-83.7v-9.4C132.9,9.3,123.6,0,113,0C102.3,0,93,9.3,93,19.9v9.4C54.5,38.5,26.6,71.8,26.6,113v73L0,212.6
v13.3h225.9v-13.3L199.3,186z M199.3,186"/> v13.3h225.9v-13.3L199.3,186z M199.3,186"/>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 655 B

After

Width:  |  Height:  |  Size: 665 B

File diff suppressed because it is too large Load Diff

View File

@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 300.2 283.5" style="enable-background:new 0 0 300.2 283.5;" xml:space="preserve"> viewBox="0 0 300.2 283.5" style="enable-background:new 0 0 300.2 283.5;" xml:space="preserve">
<!--<style type="text/css">--> <!--<style type="text/css">-->
<!--.st0{clip-path:url(#SVGID_2_);}--> <!--.st0{clip-path:url(#SVGID_2_);}-->
<!--</style>--> <!--</style>-->
<g> <g>
<!--<g>--> <!--<g>-->
<!--<defs>--> <!--<defs>-->
<!--<rect id="SVGID_1_" x="2.6" width="297.6" height="265.7"/>--> <!--<rect id="SVGID_1_" x="2.6" width="297.6" height="265.7"/>-->
<!--</defs>--> <!--</defs>-->
<!--<clipPath id="SVGID_2_">--> <!--<clipPath id="SVGID_2_">-->
<!--<use xlink:href="#SVGID_1_" style="overflow:visible;"/>--> <!--<use xlink:href="#SVGID_1_" style="overflow:visible;"/>-->
<!--</clipPath>--> <!--</clipPath>-->
<path class="st0" d="M2.6,255.1l297.7-127.5L2.6,0v99.2l212.6,28.3L2.6,155.9V255.1z M2.6,255.1"/> <path class="st0" d="M2.6,255.1l297.7-127.5L2.6,0v99.2l212.6,28.3L2.6,155.9V255.1z M2.6,255.1"/>
<!--</g>--> <!--</g>-->
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 808 B

After

Width:  |  Height:  |  Size: 827 B

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" ?><svg id="Layer_1" style="enable-background:new 0 0 137.3 139.3;" version="1.1" viewBox="0 0 137.3 139.3" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><style type="text/css"> <?xml version="1.0" ?><svg id="Layer_1" style="enable-background:new 0 0 137.3 139.3;" version="1.1" viewBox="0 0 137.3 139.3" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><style type="text/css">
.st0{fill:#2C8AAA;} .st0{fill:#2C8AAA;}
.st1{opacity:0.19;clip-path:url(#XMLID_39_);fill:#070808;} .st1{opacity:0.19;clip-path:url(#XMLID_39_);fill:#070808;}
.st2{fill:#FFFFFF;} .st2{fill:#FFFFFF;}
.st3{opacity:0.19;fill:#070808;} .st3{opacity:0.19;fill:#070808;}
</style><g id="XMLID_2671_"><g id="XMLID_2704_"><circle class="st0" cx="68.5" cy="69.6" id="XMLID_2708_" r="66.2"/><g id="XMLID_2705_"><defs><circle cx="68.7" cy="69.6" id="XMLID_2706_" r="66.2"/></defs><clipPath id="XMLID_39_"><use style="overflow:visible;" xlink:href="#XMLID_2706_"/></clipPath><polyline class="st1" id="XMLID_2707_" points="95.7,41 155.1,91.1 134,135.8 112,146.2 33.3,62.9 "/></g></g></g><g id="XMLID_2719_"><polygon class="st2" id="XMLID_2718_" points="74.3,103.9 95.7,41 33.3,62.9 50.9,76.8 60.4,76.8 60.3,86.1 "/><polygon class="st3" id="XMLID_2713_" points="60.7,84.9 95.7,41 50.9,76.8 60.4,76.8 "/><polygon class="st3" id="XMLID_2703_" points="60.4,76.8 95.7,41 60.3,86.1 "/></g></svg> </style><g id="XMLID_2671_"><g id="XMLID_2704_"><circle class="st0" cx="68.5" cy="69.6" id="XMLID_2708_" r="66.2"/><g id="XMLID_2705_"><defs><circle cx="68.7" cy="69.6" id="XMLID_2706_" r="66.2"/></defs><clipPath id="XMLID_39_"><use style="overflow:visible;" xlink:href="#XMLID_2706_"/></clipPath><polyline class="st1" id="XMLID_2707_" points="95.7,41 155.1,91.1 134,135.8 112,146.2 33.3,62.9 "/></g></g></g><g id="XMLID_2719_"><polygon class="st2" id="XMLID_2718_" points="74.3,103.9 95.7,41 33.3,62.9 50.9,76.8 60.4,76.8 60.3,86.1 "/><polygon class="st3" id="XMLID_2713_" points="60.7,84.9 95.7,41 50.9,76.8 60.4,76.8 "/><polygon class="st3" id="XMLID_2703_" points="60.4,76.8 95.7,41 60.3,86.1 "/></g></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1,13 +1,13 @@
[Desktop Entry] [Desktop Entry]
Name=SilentDragonXLite Name=SilentDragonXLite
Comment=Lightclient UI wallet for DragonX Comment=Lightclient UI wallet for DragonX
GenericName=Wallet GenericName=Wallet
Exec=SilentDragonXLite %u Exec=SilentDragonXLite %u
Icon=SilentDragonXLite Icon=SilentDragonXLite
Type=Application Type=Application
StartupNotify=true StartupNotify=true
StartupWMClass=SilentDragonXLite StartupWMClass=SilentDragonXLite
Categories=Utility; Categories=Utility;
MimeType=x-scheme-handler/dragonx; MimeType=x-scheme-handler/dragonx;
Keywords=SilentDragonXLite; Keywords=SilentDragonXLite;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
# Copyright 2019-2024 The Hush Developers # Copyright 2019-2024 The Hush Developers
./build.sh && ./SilentDragonXLite ./build.sh && ./SilentDragonXLite

View File

@@ -1,214 +1,214 @@
#------------------------------------------------- #-------------------------------------------------
# #
# Project created by QtCreator 2018-10-05T09:54:45 # Project created by QtCreator 2018-10-05T09:54:45
# #
#------------------------------------------------- #-------------------------------------------------
# Copyright 2019-2024 The Hush Developers # Copyright 2019-2024 The Hush Developers
# Released under the GPLv3 # Released under the GPLv3
QT += core gui network QT += core gui network
CONFIG += precompile_header CONFIG += precompile_header
PRECOMPILED_HEADER = src/precompiled.h PRECOMPILED_HEADER = src/precompiled.h
QT += widgets QT += widgets
TARGET = SilentDragonXLite TARGET = SilentDragonXLite
TEMPLATE = app TEMPLATE = app
# The following define makes your compiler emit warnings if you use # The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings # any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the # depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it. # deprecated API in order to know how to port your code away from it.
DEFINES += \ DEFINES += \
QT_DEPRECATED_WARNINGS QT_DEPRECATED_WARNINGS
INCLUDEPATH += src/3rdparty/ INCLUDEPATH += src/3rdparty/
INCLUDEPATH += src/ INCLUDEPATH += src/
mac: LIBS+= -Wl,-dead_strip mac: LIBS+= -Wl,-dead_strip
mac: LIBS+= -Wl,-dead_strip_dylibs mac: LIBS+= -Wl,-dead_strip_dylibs
mac: LIBS+= -Wl,-bind_at_load mac: LIBS+= -Wl,-bind_at_load
RESOURCES = application.qrc RESOURCES = application.qrc
MOC_DIR = bin MOC_DIR = bin
OBJECTS_DIR = bin OBJECTS_DIR = bin
UI_DIR = src UI_DIR = src
CONFIG += c++14 CONFIG += c++14
SOURCES += \ SOURCES += \
src/firsttimewizard.cpp \ src/firsttimewizard.cpp \
src/main.cpp \ src/main.cpp \
src/mainwindow.cpp \ src/mainwindow.cpp \
src/balancestablemodel.cpp \ src/balancestablemodel.cpp \
src/3rdparty/qrcode/BitBuffer.cpp \ src/3rdparty/qrcode/BitBuffer.cpp \
src/3rdparty/qrcode/QrCode.cpp \ src/3rdparty/qrcode/QrCode.cpp \
src/3rdparty/qrcode/QrSegment.cpp \ src/3rdparty/qrcode/QrSegment.cpp \
src/3rdparty/json/json.hpp \ src/3rdparty/json/json.hpp \
src/settings.cpp \ src/settings.cpp \
src/sendtab.cpp \ src/sendtab.cpp \
src/txtablemodel.cpp \ src/txtablemodel.cpp \
src/qrcodelabel.cpp \ src/qrcodelabel.cpp \
src/connection.cpp \ src/connection.cpp \
src/fillediconlabel.cpp \ src/fillediconlabel.cpp \
src/addressbook.cpp \ src/addressbook.cpp \
src/logger.cpp \ src/logger.cpp \
src/addresscombo.cpp \ src/addresscombo.cpp \
src/recurring.cpp \ src/recurring.cpp \
src/requestdialog.cpp \ src/requestdialog.cpp \
src/memoedit.cpp \ src/memoedit.cpp \
src/viewalladdresses.cpp \ src/viewalladdresses.cpp \
src/datamodel.cpp \ src/datamodel.cpp \
src/controller.cpp \ src/controller.cpp \
src/liteinterface.cpp \ src/liteinterface.cpp \
src/camount.cpp \ src/camount.cpp \
src/chatbubbleme.cpp \ src/chatbubbleme.cpp \
src/chatbubblepartner.cpp \ src/chatbubblepartner.cpp \
src/chatmodel.cpp \ src/chatmodel.cpp \
src/contactmodel.cpp \ src/contactmodel.cpp \
src/DataStore/DataStore.cpp \ src/DataStore/DataStore.cpp \
src/DataStore/ChatDataStore.cpp \ src/DataStore/ChatDataStore.cpp \
src/DataStore/SietchDataStore.cpp \ src/DataStore/SietchDataStore.cpp \
src/DataStore/NoteCountDataStore.cpp \ src/DataStore/NoteCountDataStore.cpp \
src/DataStore/ContactDataStore.cpp \ src/DataStore/ContactDataStore.cpp \
src/Model/ChatItem.cpp \ src/Model/ChatItem.cpp \
src/Model/ContactRequestChatItem.cpp \ src/Model/ContactRequestChatItem.cpp \
src/Model/ContactItem.cpp \ src/Model/ContactItem.cpp \
src/Model/ContactRequest.cpp \ src/Model/ContactRequest.cpp \
src/Chat/Helper/ChatIDGenerator.cpp \ src/Chat/Helper/ChatIDGenerator.cpp \
src/Chat/Chat.cpp \ src/Chat/Chat.cpp \
src/FileSystem/FileSystem.cpp \ src/FileSystem/FileSystem.cpp \
src/Crypto/FileEncryption.cpp \ src/Crypto/FileEncryption.cpp \
src/Crypto/passwd.cpp src/Crypto/passwd.cpp
HEADERS += \ HEADERS += \
src/guiconstants.h \ src/guiconstants.h \
src/firsttimewizard.h \ src/firsttimewizard.h \
src/mainwindow.h \ src/mainwindow.h \
src/precompiled.h \ src/precompiled.h \
src/balancestablemodel.h \ src/balancestablemodel.h \
src/3rdparty/qrcode/BitBuffer.hpp \ src/3rdparty/qrcode/BitBuffer.hpp \
src/3rdparty/qrcode/QrCode.hpp \ src/3rdparty/qrcode/QrCode.hpp \
src/3rdparty/qrcode/QrSegment.hpp \ src/3rdparty/qrcode/QrSegment.hpp \
src/settings.h \ src/settings.h \
src/txtablemodel.h \ src/txtablemodel.h \
src/qrcodelabel.h \ src/qrcodelabel.h \
src/connection.h \ src/connection.h \
src/fillediconlabel.h \ src/fillediconlabel.h \
src/addressbook.h \ src/addressbook.h \
src/logger.h \ src/logger.h \
src/addresscombo.h \ src/addresscombo.h \
src/recurring.h \ src/recurring.h \
src/requestdialog.h \ src/requestdialog.h \
src/memoedit.h \ src/memoedit.h \
src/viewalladdresses.h \ src/viewalladdresses.h \
src/datamodel.h \ src/datamodel.h \
src/controller.h \ src/controller.h \
src/liteinterface.h \ src/liteinterface.h \
src/camount.h \ src/camount.h \
lib/silentdragonxlitelib.h \ lib/silentdragonxlitelib.h \
src/chatbubbleme.h \ src/chatbubbleme.h \
src/chatbubblepartner.h \ src/chatbubblepartner.h \
src/chatmodel.h \ src/chatmodel.h \
src/contactmodel.h src/contactmodel.h
FORMS += \ FORMS += \
src/contactrequest.ui \ src/contactrequest.ui \
src/deposithush.ui \ src/deposithush.ui \
src/emoji.ui \ src/emoji.ui \
src/encryption.ui \ src/encryption.ui \
src/hushrequest.ui \ src/hushrequest.ui \
src/mainwindow.ui \ src/mainwindow.ui \
src/newseed.ui \ src/newseed.ui \
src/newwallet.ui \ src/newwallet.ui \
src/recurringpayments.ui \ src/recurringpayments.ui \
src/restoreseed.ui \ src/restoreseed.ui \
src/seedrestore.ui \ src/seedrestore.ui \
src/sendHushTransactionChat.ui \ src/sendHushTransactionChat.ui \
src/settings.ui \ src/settings.ui \
src/about.ui \ src/about.ui \
src/confirm.ui \ src/confirm.ui \
src/privkey.ui \ src/privkey.ui \
src/verifyseed.ui \ src/verifyseed.ui \
src/startupencryption.ui \ src/startupencryption.ui \
src/viewalladdresses.ui \ src/viewalladdresses.ui \
src/connection.ui \ src/connection.ui \
src/addressbook.ui \ src/addressbook.ui \
src/memodialog.ui \ src/memodialog.ui \
src/createhushconfdialog.ui \ src/createhushconfdialog.ui \
src/recurringdialog.ui \ src/recurringdialog.ui \
src/requestContactDialog.ui \ src/requestContactDialog.ui \
src/newrecurring.ui \ src/newrecurring.ui \
src/requestdialog.ui \ src/requestdialog.ui \
src/removeencryption.ui \ src/removeencryption.ui \
src/recurringmultiple.ui \ src/recurringmultiple.ui \
src/chatbubbleme.ui \ src/chatbubbleme.ui \
src/chatbubblepartner.ui src/chatbubblepartner.ui
TRANSLATIONS = res/silentdragonxlite_ar.ts \ TRANSLATIONS = res/silentdragonxlite_ar.ts \
res/silentdragonxlite_be.ts \ res/silentdragonxlite_be.ts \
res/silentdragonxlite_de.ts \ res/silentdragonxlite_de.ts \
res/silentdragonxlite_es.ts \ res/silentdragonxlite_es.ts \
res/silentdragonxlite_fa.ts \ res/silentdragonxlite_fa.ts \
res/silentdragonxlite_fr.ts \ res/silentdragonxlite_fr.ts \
res/silentdragonxlite_hr.ts \ res/silentdragonxlite_hr.ts \
res/silentdragonxlite_id.ts \ res/silentdragonxlite_id.ts \
res/silentdragonxlite_it.ts \ res/silentdragonxlite_it.ts \
res/silentdragonxlite_nl.ts \ res/silentdragonxlite_nl.ts \
res/silentdragonxlite_pt.ts \ res/silentdragonxlite_pt.ts \
res/silentdragonxlite_pl.ts \ res/silentdragonxlite_pl.ts \
res/silentdragonxlite_ro.ts \ res/silentdragonxlite_ro.ts \
res/silentdragonxlite_ru.ts \ res/silentdragonxlite_ru.ts \
res/silentdragonxlite_sr.ts \ res/silentdragonxlite_sr.ts \
res/silentdragonxlite_tr.ts \ res/silentdragonxlite_tr.ts \
res/silentdragonxlite_ud.ts \ res/silentdragonxlite_ud.ts \
res/silentdragonxlite_zh.ts res/silentdragonxlite_zh.ts
include(singleapplication/singleapplication.pri) include(singleapplication/singleapplication.pri)
DEFINES += QAPPLICATION_CLASS=QApplication _FORTIFY_SOURCE=2 DEFINES += QAPPLICATION_CLASS=QApplication _FORTIFY_SOURCE=2
QMAKE_INFO_PLIST = res/Info.plist QMAKE_INFO_PLIST = res/Info.plist
win32: RC_ICONS = res/icon.ico win32: RC_ICONS = res/icon.ico
ICON = res/logo.icns ICON = res/logo.icns
# Default rules for deployment. # Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target !isEmpty(target.path): INSTALLS += target
libsodium.target = $$PWD/res/libsodium.a libsodium.target = $$PWD/res/libsodium.a
libsodium.commands = res/libsodium/buildlibsodium.sh "$@" libsodium.commands = res/libsodium/buildlibsodium.sh "$@"
unix: librust.target = $$PWD/lib/target/release/libsilentdragonxlite.a unix: librust.target = $$PWD/lib/target/release/libsilentdragonxlite.a
else:win32: librust.target = $$PWD/lib/target/x86_64-pc-windows-gnu/release/silentdragonxlite.lib else:win32: librust.target = $$PWD/lib/target/x86_64-pc-windows-gnu/release/silentdragonxlite.lib
unix: librust.commands = $(MAKE) -C $$PWD/lib unix: librust.commands = $(MAKE) -C $$PWD/lib
else:win32: librust.commands = $(MAKE) -C $$PWD/lib winrelease else:win32: librust.commands = $(MAKE) -C $$PWD/lib winrelease
librust.depends = lib/Cargo.toml lib/src/lib.rs librust.depends = lib/Cargo.toml lib/src/lib.rs
librustclean.commands = "rm -rf $$PWD/lib/target" librustclean.commands = "rm -rf $$PWD/lib/target"
distclean.depends += librustclean distclean.depends += librustclean
QMAKE_EXTRA_TARGETS += librust libsodium librustclean distclean QMAKE_EXTRA_TARGETS += librust libsodium librustclean distclean
QMAKE_CLEAN += $$PWD/lib/target/release/libsilentdragonxlite.a res/libsodium.a QMAKE_CLEAN += $$PWD/lib/target/release/libsilentdragonxlite.a res/libsodium.a
win32: LIBS += -L$$PWD/lib/target/x86_64-pc-windows-gnu/release -lsilentdragonxlite -L$$PWD/res/ -llibsodium -lsecur32 -lcrypt32 -lncrypt win32: LIBS += -L$$PWD/lib/target/x86_64-pc-windows-gnu/release -lsilentdragonxlite -L$$PWD/lib/libsodium-mingw/ -lsodium -lsecur32 -lcrypt32 -lncrypt
else:macx: LIBS += -L$$PWD/lib/target/release -lsilentdragonxlite -framework Security -framework Foundation -L$$PWD/res/ -lsodium else:macx: LIBS += -L$$PWD/lib/target/release -lsilentdragonxlite -framework Security -framework Foundation -L$$PWD/res/ -lsodium
else:unix: LIBS += -L$$PWD/lib/target/release -lsilentdragonxlite -ldl -L$$PWD/res/ -lsodium else:unix: LIBS += -L$$PWD/lib/target/release -lsilentdragonxlite -ldl -L$$PWD/res/ -lsodium
win32: PRE_TARGETDEPS += $$PWD/lib/target/x86_64-pc-windows-gnu/release/silentdragonxlite.lib $$PWD/res/libsodium.a win32: PRE_TARGETDEPS += $$PWD/lib/target/x86_64-pc-windows-gnu/release/silentdragonxlite.lib $$PWD/lib/libsodium-mingw/libsodium.a
else:unix::PRE_TARGETDEPS += $$PWD/lib/target/release/libsilentdragonxlite.a $$PWD/res/libsodium.a else:unix::PRE_TARGETDEPS += $$PWD/lib/target/release/libsilentdragonxlite.a $$PWD/res/libsodium.a
INCLUDEPATH += $$PWD/res INCLUDEPATH += $$PWD/res
DEPENDPATH += $$PWD/res DEPENDPATH += $$PWD/res
DISTFILES += DISTFILES +=

View File

@@ -0,0 +1,16 @@
// This file is autogenerated by qmake. It imports static plugin classes for
// static plugins specified using QTPLUGIN and QT_PLUGIN_CLASS.<plugin> variables.
#include <QtPlugin>
Q_IMPORT_PLUGIN(QWindowsVistaStylePlugin)
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
Q_IMPORT_PLUGIN(QGifPlugin)
Q_IMPORT_PLUGIN(QICNSPlugin)
Q_IMPORT_PLUGIN(QICOPlugin)
Q_IMPORT_PLUGIN(QJp2Plugin)
Q_IMPORT_PLUGIN(QJpegPlugin)
Q_IMPORT_PLUGIN(QMngPlugin)
Q_IMPORT_PLUGIN(QTgaPlugin)
Q_IMPORT_PLUGIN(QTiffPlugin)
Q_IMPORT_PLUGIN(QWbmpPlugin)
Q_IMPORT_PLUGIN(QWebpPlugin)
Q_IMPORT_PLUGIN(QGenericEnginePlugin)

View File

@@ -1,193 +1,193 @@
Changelog Changelog
========= =========
__3.0.14__ __3.0.14__
---------- ----------
* Fixed uninitialised variables in the `SingleApplicationPrivate` constructor. * Fixed uninitialised variables in the `SingleApplicationPrivate` constructor.
__3.0.13a__ __3.0.13a__
---------- ----------
* Process socket events asynchronously * Process socket events asynchronously
* Fix undefined variable error on Windows * Fix undefined variable error on Windows
_Francis Giraldeau_ _Francis Giraldeau_
__3.0.12a__ __3.0.12a__
---------- ----------
* Removed signal handling. * Removed signal handling.
__3.0.11a__ __3.0.11a__
---------- ----------
* Fixed bug where the message sent by the second process was not received * Fixed bug where the message sent by the second process was not received
correctly when the message is sent immediately following a connection. correctly when the message is sent immediately following a connection.
_Francis Giraldeau_ _Francis Giraldeau_
* Refactored code and implemented shared memory block consistency checks * Refactored code and implemented shared memory block consistency checks
via `qChecksum()` (CRC-16). via `qChecksum()` (CRC-16).
* Explicit `qWarning` and `qCritical` when the library is unable to initialise * Explicit `qWarning` and `qCritical` when the library is unable to initialise
correctly. correctly.
__3.0.10__ __3.0.10__
---------- ----------
* Removed C style casts and eliminated all clang warnings. Fixed `instanceId` * Removed C style casts and eliminated all clang warnings. Fixed `instanceId`
reading from only one byte in the message deserialization. Cleaned up reading from only one byte in the message deserialization. Cleaned up
serialization code using `QDataStream`. Changed connection type to use serialization code using `QDataStream`. Changed connection type to use
`quint8 enum` rather than `char`. `quint8 enum` rather than `char`.
* Renamed `SingleAppConnectionType` to `ConnectionType`. Added initialization * Renamed `SingleAppConnectionType` to `ConnectionType`. Added initialization
values to all `ConnectionType` enum cases. values to all `ConnectionType` enum cases.
_Jedidiah Buck McCready_ _Jedidiah Buck McCready_
__3.0.9__ __3.0.9__
--------- ---------
* Added SingleApplicationPrivate::primaryPid() as a solution to allow * Added SingleApplicationPrivate::primaryPid() as a solution to allow
bringing the primary window of an application to the foreground on bringing the primary window of an application to the foreground on
Windows. Windows.
_Eelco van Dam from Peacs BV_ _Eelco van Dam from Peacs BV_
__3.0.8__ __3.0.8__
--------- ---------
* Bug fix - changed QApplication::instance() to QCoreApplication::instance() * Bug fix - changed QApplication::instance() to QCoreApplication::instance()
_Evgeniy Bazhenov_ _Evgeniy Bazhenov_
__3.0.7a__ __3.0.7a__
---------- ----------
* Fixed compilation error with Mingw32 in MXE thanks to Vitaly Tonkacheyev. * Fixed compilation error with Mingw32 in MXE thanks to Vitaly Tonkacheyev.
* Removed QMutex used for thread safe behaviour. The implementation now uses * Removed QMutex used for thread safe behaviour. The implementation now uses
QCoreApplication::instance() to get an instance to SingleApplication for QCoreApplication::instance() to get an instance to SingleApplication for
memory deallocation. memory deallocation.
__3.0.6a__ __3.0.6a__
---------- ----------
* Reverted GetUserName API usage on Windows. Fixed bug with missing library. * Reverted GetUserName API usage on Windows. Fixed bug with missing library.
* Fixed bug in the Calculator example, preventing it's window to be raised * Fixed bug in the Calculator example, preventing it's window to be raised
on Windows. on Windows.
Special thanks to Charles Gunawan. Special thanks to Charles Gunawan.
__3.0.5a__ __3.0.5a__
---------- ----------
* Fixed a memory leak in the SingleApplicationPrivate destructor. * Fixed a memory leak in the SingleApplicationPrivate destructor.
_Sergei Moiseev_ _Sergei Moiseev_
__3.0.4a__ __3.0.4a__
---------- ----------
* Fixed shadow and uninitialised variable warnings. * Fixed shadow and uninitialised variable warnings.
_Paul Walmsley_ _Paul Walmsley_
__3.0.3a__ __3.0.3a__
---------- ----------
* Removed Microsoft Windows specific code for getting username due to * Removed Microsoft Windows specific code for getting username due to
multiple problems and compiler differences on Windows platforms. On multiple problems and compiler differences on Windows platforms. On
Windows the shared memory block in User mode now includes the user's Windows the shared memory block in User mode now includes the user's
home path (which contains the user's username). home path (which contains the user's username).
* Explicitly getting absolute path of the user's home directory as on Unix * Explicitly getting absolute path of the user's home directory as on Unix
a relative path (`~`) may be returned. a relative path (`~`) may be returned.
__3.0.2a__ __3.0.2a__
---------- ----------
* Fixed bug on Windows when username containing wide characters causes the * Fixed bug on Windows when username containing wide characters causes the
library to crash. library to crash.
_Le Liu_ _Le Liu_
__3.0.1a__ __3.0.1a__
---------- ----------
* Allows the application path and version to be excluded from the server name * Allows the application path and version to be excluded from the server name
hash. The following flags were added for this purpose: hash. The following flags were added for this purpose:
* `SingleApplication::Mode::ExcludeAppVersion` * `SingleApplication::Mode::ExcludeAppVersion`
* `SingleApplication::Mode::ExcludeAppPath` * `SingleApplication::Mode::ExcludeAppPath`
* Allow a non elevated process to connect to a local server created by an * Allow a non elevated process to connect to a local server created by an
elevated process run by the same user on Windows elevated process run by the same user on Windows
* Fixes a problem with upper case letters in paths on Windows * Fixes a problem with upper case letters in paths on Windows
_Le Liu_ _Le Liu_
__v3.0a__ __v3.0a__
--------- ---------
* Depricated secondary instances count. * Depricated secondary instances count.
* Added a sendMessage() method to send a message to the primary instance. * Added a sendMessage() method to send a message to the primary instance.
* Added a receivedMessage() signal, emitted when a message is received from a * Added a receivedMessage() signal, emitted when a message is received from a
secondary instance. secondary instance.
* The SingleApplication constructor's third parameter is now a bool * The SingleApplication constructor's third parameter is now a bool
specifying if the current instance should be allowed to run as a secondary specifying if the current instance should be allowed to run as a secondary
instance if there is already a primary instance. instance if there is already a primary instance.
* The SingleApplication constructor accept a fourth parameter specifying if * The SingleApplication constructor accept a fourth parameter specifying if
the SingleApplication block should be User-wide or System-wide. the SingleApplication block should be User-wide or System-wide.
* SingleApplication no longer relies on `applicationName` and * SingleApplication no longer relies on `applicationName` and
`organizationName` to be set. It instead concatenates all of the following `organizationName` to be set. It instead concatenates all of the following
data and computes a `SHA256` hash which is used as the key of the data and computes a `SHA256` hash which is used as the key of the
`QSharedMemory` block and the `QLocalServer`. Since at least `QSharedMemory` block and the `QLocalServer`. Since at least
`applicationFilePath` is always present there is no need to explicitly set `applicationFilePath` is always present there is no need to explicitly set
any of the following prior to initialising `SingleApplication`. any of the following prior to initialising `SingleApplication`.
* `QCoreApplication::applicationName` * `QCoreApplication::applicationName`
* `QCoreApplication::applicationVersion` * `QCoreApplication::applicationVersion`
* `QCoreApplication::applicationFilePath` * `QCoreApplication::applicationFilePath`
* `QCoreApplication::organizationName` * `QCoreApplication::organizationName`
* `QCoreApplication::organizationDomain` * `QCoreApplication::organizationDomain`
* User name or home directory path if in User mode * User name or home directory path if in User mode
* The primary instance is no longer notified when a secondary instance had * The primary instance is no longer notified when a secondary instance had
been started by default. A `Mode` flag for this feature exists. been started by default. A `Mode` flag for this feature exists.
* Added `instanceNumber()` which represents a unique identifier for each * Added `instanceNumber()` which represents a unique identifier for each
secondary instance started. When called from the primary instance will secondary instance started. When called from the primary instance will
return `0`. return `0`.
__v2.4__ __v2.4__
-------- --------
* Stability improvements * Stability improvements
* Support for secondary instances. * Support for secondary instances.
* The library now recovers safely after the primary process has crashed * The library now recovers safely after the primary process has crashed
and the shared memory had not been deleted. and the shared memory had not been deleted.
__v2.3__ __v2.3__
-------- --------
* Improved pimpl design and inheritance safety. * Improved pimpl design and inheritance safety.
_Vladislav Pyatnichenko_ _Vladislav Pyatnichenko_
__v2.2__ __v2.2__
-------- --------
* The `QAPPLICATION_CLASS` macro can now be defined in the file including the * The `QAPPLICATION_CLASS` macro can now be defined in the file including the
Single Application header or with a `DEFINES+=` statement in the project file. Single Application header or with a `DEFINES+=` statement in the project file.
__v2.1__ __v2.1__
-------- --------
* A race condition can no longer occur when starting two processes nearly * A race condition can no longer occur when starting two processes nearly
simultaneously. simultaneously.
Fix issue [#3](https://github.com/itay-grudev/SingleApplication/issues/3) Fix issue [#3](https://github.com/itay-grudev/SingleApplication/issues/3)
__v2.0__ __v2.0__
-------- --------
* SingleApplication is now being passed a reference to `argc` instead of a * SingleApplication is now being passed a reference to `argc` instead of a
copy. copy.
Fix issue [#1](https://github.com/itay-grudev/SingleApplication/issues/1) Fix issue [#1](https://github.com/itay-grudev/SingleApplication/issues/1)
* Improved documentation. * Improved documentation.

View File

@@ -1,24 +1,24 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) Itay Grudev 2015 - 2016 Copyright (c) Itay Grudev 2015 - 2016
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
Note: Some of the examples include code not distributed under the terms of the Note: Some of the examples include code not distributed under the terms of the
MIT License. MIT License.

View File

@@ -1,265 +1,265 @@
SingleApplication SingleApplication
================= =================
This is a replacement of the QtSingleApplication for `Qt5`. This is a replacement of the QtSingleApplication for `Qt5`.
Keeps the Primary Instance of your Application and kills each subsequent Keeps the Primary Instance of your Application and kills each subsequent
instances. It can (if enabled) spawn secondary (non-related to the primary) instances. It can (if enabled) spawn secondary (non-related to the primary)
instances and can send data to the primary instance from secondary instances. instances and can send data to the primary instance from secondary instances.
Usage Usage
----- -----
The `SingleApplication` class inherits from whatever `Q[Core|Gui]Application` The `SingleApplication` class inherits from whatever `Q[Core|Gui]Application`
class you specify via the `QAPPLICATION_CLASS` macro (`QCoreApplication` is the class you specify via the `QAPPLICATION_CLASS` macro (`QCoreApplication` is the
default). Further usage is similar to the use of the `Q[Core|Gui]Application` default). Further usage is similar to the use of the `Q[Core|Gui]Application`
classes. classes.
The library sets up a `QLocalServer` and a `QSharedMemory` block. The first The library sets up a `QLocalServer` and a `QSharedMemory` block. The first
instance of your Application is your Primary Instance. It would check if the instance of your Application is your Primary Instance. It would check if the
shared memory block exists and if not it will start a `QLocalServer` and listen shared memory block exists and if not it will start a `QLocalServer` and listen
for connections. Each subsequent instance of your application would check if the for connections. Each subsequent instance of your application would check if the
shared memory block exists and if it does, it will connect to the QLocalServer shared memory block exists and if it does, it will connect to the QLocalServer
to notify the primary instance that a new instance had been started, after which to notify the primary instance that a new instance had been started, after which
it would terminate with status code `0`. In the Primary Instance it would terminate with status code `0`. In the Primary Instance
`SingleApplication` would emit the `instanceStarted()` signal upon detecting `SingleApplication` would emit the `instanceStarted()` signal upon detecting
that a new instance had been started. that a new instance had been started.
The library uses `stdlib` to terminate the program with the `exit()` function. The library uses `stdlib` to terminate the program with the `exit()` function.
You can use the library as if you use any other `QCoreApplication` derived You can use the library as if you use any other `QCoreApplication` derived
class: class:
```cpp ```cpp
#include <QApplication> #include <QApplication>
#include <SingleApplication.h> #include <SingleApplication.h>
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {
SingleApplication app( argc, argv ); SingleApplication app( argc, argv );
return app.exec(); return app.exec();
} }
``` ```
To include the library files I would recommend that you add it as a git To include the library files I would recommend that you add it as a git
submodule to your project and include it's contents with a `.pri` file. Here is submodule to your project and include it's contents with a `.pri` file. Here is
how: how:
```bash ```bash
git submodule add git@github.com:itay-grudev/SingleApplication.git singleapplication git submodule add git@github.com:itay-grudev/SingleApplication.git singleapplication
``` ```
Then include the `singleapplication.pri` file in your `.pro` project file. Also Then include the `singleapplication.pri` file in your `.pro` project file. Also
don't forget to specify which `QCoreApplication` class your app is using if it don't forget to specify which `QCoreApplication` class your app is using if it
is not `QCoreApplication`. is not `QCoreApplication`.
```qmake ```qmake
include(singleapplication/singleapplication.pri) include(singleapplication/singleapplication.pri)
DEFINES += QAPPLICATION_CLASS=QApplication DEFINES += QAPPLICATION_CLASS=QApplication
``` ```
The `Instance Started` signal The `Instance Started` signal
------------------------ ------------------------
The SingleApplication class implements a `instanceStarted()` signal. You can The SingleApplication class implements a `instanceStarted()` signal. You can
bind to that signal to raise your application's window when a new instance had bind to that signal to raise your application's window when a new instance had
been started, for example. been started, for example.
```cpp ```cpp
// window is a QWindow instance // window is a QWindow instance
QObject::connect( QObject::connect(
&app, &app,
&SingleApplication::instanceStarted, &SingleApplication::instanceStarted,
&window, &window,
&QWindow::raise &QWindow::raise
); );
``` ```
Using `SingleApplication::instance()` is a neat way to get the Using `SingleApplication::instance()` is a neat way to get the
`SingleApplication` instance for binding to it's signals anywhere in your `SingleApplication` instance for binding to it's signals anywhere in your
program. program.
__Note:__ On Windows the ability to bring the application windows to the __Note:__ On Windows the ability to bring the application windows to the
foreground is restricted. See [Windows specific implementations](Windows.md) foreground is restricted. See [Windows specific implementations](Windows.md)
for a workaround and an example implementation. for a workaround and an example implementation.
Secondary Instances Secondary Instances
------------------- -------------------
If you want to be able to launch additional Secondary Instances (not related to If you want to be able to launch additional Secondary Instances (not related to
your Primary Instance) you have to enable that with the third parameter of the your Primary Instance) you have to enable that with the third parameter of the
`SingleApplication` constructor. The default is `false` meaning no Secondary `SingleApplication` constructor. The default is `false` meaning no Secondary
Instances. Here is an example of how you would start a Secondary Instance send Instances. Here is an example of how you would start a Secondary Instance send
a message with the command line arguments to the primary instance and then shut a message with the command line arguments to the primary instance and then shut
down. down.
```cpp ```cpp
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
SingleApplication app( argc, argv, true ); SingleApplication app( argc, argv, true );
if( app.isSecondary() ) { if( app.isSecondary() ) {
app.sendMessage( app.arguments().join(' ')).toUtf8() ); app.sendMessage( app.arguments().join(' ')).toUtf8() );
app.exit( 0 ); app.exit( 0 );
} }
return app.exec(); return app.exec();
} }
``` ```
*__Note:__ A secondary instance won't cause the emission of the *__Note:__ A secondary instance won't cause the emission of the
`instanceStarted()` signal by default. See `SingleApplication::Mode` for more `instanceStarted()` signal by default. See `SingleApplication::Mode` for more
details.* details.*
You can check whether your instance is a primary or secondary with the following You can check whether your instance is a primary or secondary with the following
methods: methods:
```cpp ```cpp
app.isPrimary(); app.isPrimary();
// or // or
app.isSecondary(); app.isSecondary();
``` ```
*__Note:__ If your Primary Instance is terminated a newly launched instance *__Note:__ If your Primary Instance is terminated a newly launched instance
will replace the Primary one even if the Secondary flag has been set.* will replace the Primary one even if the Secondary flag has been set.*
API API
--- ---
### Members ### Members
```cpp ```cpp
SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSecondary = false, Options options = Mode::User, int timeout = 100 ) SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSecondary = false, Options options = Mode::User, int timeout = 100 )
``` ```
Depending on whether `allowSecondary` is set, this constructor may terminate Depending on whether `allowSecondary` is set, this constructor may terminate
your app if there is already a primary instance running. Additional `Options` your app if there is already a primary instance running. Additional `Options`
can be specified to set whether the SingleApplication block should work can be specified to set whether the SingleApplication block should work
user-wide or system-wide. Additionally the `Mode::SecondaryNotification` may be user-wide or system-wide. Additionally the `Mode::SecondaryNotification` may be
used to notify the primary instance whenever a secondary instance had been used to notify the primary instance whenever a secondary instance had been
started (disabled by default). `timeout` specifies the maximum time in started (disabled by default). `timeout` specifies the maximum time in
milliseconds to wait for blocking operations. milliseconds to wait for blocking operations.
*__Note:__ `argc` and `argv` may be changed as Qt removes arguments that it *__Note:__ `argc` and `argv` may be changed as Qt removes arguments that it
recognizes.* recognizes.*
*__Note:__ `Mode::SecondaryNotification` only works if set on both the primary *__Note:__ `Mode::SecondaryNotification` only works if set on both the primary
and the secondary instance.* and the secondary instance.*
*__Note:__ Operating system can restrict the shared memory blocks to the same *__Note:__ Operating system can restrict the shared memory blocks to the same
user, in which case the User/System modes will have no effect and the block will user, in which case the User/System modes will have no effect and the block will
be user wide.* be user wide.*
--- ---
```cpp ```cpp
bool SingleApplication::sendMessage( QByteArray message, int timeout = 100 ) bool SingleApplication::sendMessage( QByteArray message, int timeout = 100 )
``` ```
Sends `message` to the Primary Instance. Uses `timeout` as a the maximum timeout Sends `message` to the Primary Instance. Uses `timeout` as a the maximum timeout
in milliseconds for blocking functions in milliseconds for blocking functions
--- ---
```cpp ```cpp
bool SingleApplication::isPrimary() bool SingleApplication::isPrimary()
``` ```
Returns if the instance is the primary instance. Returns if the instance is the primary instance.
--- ---
```cpp ```cpp
bool SingleApplication::isSecondary() bool SingleApplication::isSecondary()
``` ```
Returns if the instance is a secondary instance. Returns if the instance is a secondary instance.
--- ---
```cpp ```cpp
quint32 SingleApplication::instanceId() quint32 SingleApplication::instanceId()
``` ```
Returns a unique identifier for the current instance. Returns a unique identifier for the current instance.
--- ---
```cpp ```cpp
qint64 SingleApplication::primaryPid() qint64 SingleApplication::primaryPid()
``` ```
Returns the process ID (PID) of the primary instance. Returns the process ID (PID) of the primary instance.
### Signals ### Signals
```cpp ```cpp
void SingleApplication::instanceStarted() void SingleApplication::instanceStarted()
``` ```
Triggered whenever a new instance had been started, except for secondary Triggered whenever a new instance had been started, except for secondary
instances if the `Mode::SecondaryNotification` flag is not specified. instances if the `Mode::SecondaryNotification` flag is not specified.
--- ---
```cpp ```cpp
void SingleApplication::receivedMessage( quint32 instanceId, QByteArray message ) void SingleApplication::receivedMessage( quint32 instanceId, QByteArray message )
``` ```
Triggered whenever there is a message received from a secondary instance. Triggered whenever there is a message received from a secondary instance.
--- ---
### Flags ### Flags
```cpp ```cpp
enum SingleApplication::Mode enum SingleApplication::Mode
``` ```
* `Mode::User` - The SingleApplication block should apply user wide. This adds * `Mode::User` - The SingleApplication block should apply user wide. This adds
user specific data to the key used for the shared memory and server name. user specific data to the key used for the shared memory and server name.
This is the default functionality. This is the default functionality.
* `Mode::System` The SingleApplication block applies system-wide. * `Mode::System` The SingleApplication block applies system-wide.
* `Mode::SecondaryNotification` Whether to trigger `instanceStarted()` even * `Mode::SecondaryNotification` Whether to trigger `instanceStarted()` even
whenever secondary instances are started. whenever secondary instances are started.
* `Mode::ExcludeAppPath` Excludes the application path from the server name * `Mode::ExcludeAppPath` Excludes the application path from the server name
(and memory block) hash. (and memory block) hash.
* `Mode::ExcludeAppVersion` Excludes the application version from the server * `Mode::ExcludeAppVersion` Excludes the application version from the server
name (and memory block) hash. name (and memory block) hash.
*__Note:__ `Mode::SecondaryNotification` only works if set on both the primary *__Note:__ `Mode::SecondaryNotification` only works if set on both the primary
and the secondary instance.* and the secondary instance.*
*__Note:__ Operating system can restrict the shared memory blocks to the same *__Note:__ Operating system can restrict the shared memory blocks to the same
user, in which case the User/System modes will have no effect and the block will user, in which case the User/System modes will have no effect and the block will
be user wide.* be user wide.*
--- ---
Versioning Versioning
---------- ----------
Each major version introduces either very significant changes or is not Each major version introduces either very significant changes or is not
backwards compatible with the previous version. Minor versions only add backwards compatible with the previous version. Minor versions only add
additional features, bug fixes or performance improvements and are backwards additional features, bug fixes or performance improvements and are backwards
compatible with the previous release. See [`CHANGELOG.md`](CHANGELOG.md) for compatible with the previous release. See [`CHANGELOG.md`](CHANGELOG.md) for
more details. more details.
Implementation Implementation
-------------- --------------
The library is implemented with a QSharedMemory block which is thread safe and The library is implemented with a QSharedMemory block which is thread safe and
guarantees a race condition will not occur. It also uses a QLocalSocket to guarantees a race condition will not occur. It also uses a QLocalSocket to
notify the main process that a new instance had been spawned and thus invoke the notify the main process that a new instance had been spawned and thus invoke the
`instanceStarted()` signal and for messaging the primary instance. `instanceStarted()` signal and for messaging the primary instance.
Additionally the library can recover from being forcefully killed on *nix Additionally the library can recover from being forcefully killed on *nix
systems and will reset the memory block given that there are no other systems and will reset the memory block given that there are no other
instances running. instances running.
License License
------- -------
This library and it's supporting documentation are released under This library and it's supporting documentation are released under
`The MIT License (MIT)` with the exception of the Qt calculator examples which `The MIT License (MIT)` with the exception of the Qt calculator examples which
is distributed under the BSD license. is distributed under the BSD license.

View File

@@ -1,46 +1,46 @@
Windows Specific Implementations Windows Specific Implementations
================================ ================================
Setting the foreground window Setting the foreground window
----------------------------- -----------------------------
In the `instanceStarted()` example in the `README` we demonstrated how an In the `instanceStarted()` example in the `README` we demonstrated how an
application can bring it's primary instance window whenever a second copy application can bring it's primary instance window whenever a second copy
of the application is started. of the application is started.
On Windows the ability to bring the application windows to the foreground is On Windows the ability to bring the application windows to the foreground is
restricted, see [`AllowSetForegroundWindow()`][AllowSetForegroundWindow] for more restricted, see [`AllowSetForegroundWindow()`][AllowSetForegroundWindow] for more
details. details.
The background process (the primary instance) can bring its windows to the The background process (the primary instance) can bring its windows to the
foreground if it is allowed by the current foreground process (the secondary foreground if it is allowed by the current foreground process (the secondary
instance). To bypass this `SingleApplication` must be initialized with the instance). To bypass this `SingleApplication` must be initialized with the
`allowSecondary` parameter set to `true` and the `options` parameter must `allowSecondary` parameter set to `true` and the `options` parameter must
include `Mode::SecondaryNotification`, See `SingleApplication::Mode` for more include `Mode::SecondaryNotification`, See `SingleApplication::Mode` for more
details. details.
Here is an example: Here is an example:
```cpp ```cpp
if( app.isSecondary() ) { if( app.isSecondary() ) {
// This API requires LIBS += User32.lib to be added to the project // This API requires LIBS += User32.lib to be added to the project
AllowSetForegroundWindow( DWORD( app.primaryPid() ) ); AllowSetForegroundWindow( DWORD( app.primaryPid() ) );
} }
if( app.isPrimary() ) { if( app.isPrimary() ) {
QObject::connect( QObject::connect(
&app, &app,
&SingleApplication::instanceStarted, &SingleApplication::instanceStarted,
this, this,
&App::instanceStarted &App::instanceStarted
); );
} }
``` ```
```cpp ```cpp
void App::instanceStarted() { void App::instanceStarted() {
QApplication::setActiveWindow( [window/widget to set to the foreground] ); QApplication::setActiveWindow( [window/widget to set to the foreground] );
} }
``` ```
[AllowSetForegroundWindow]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms632668.aspx [AllowSetForegroundWindow]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms632668.aspx

View File

@@ -1,174 +1,174 @@
// The MIT License (MIT) // The MIT License (MIT)
// //
// Copyright (c) Itay Grudev 2015 - 2018 // Copyright (c) Itay Grudev 2015 - 2018
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal // of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights // in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is // copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions: // furnished to do so, subject to the following conditions:
// //
// The above copyright notice and this permission notice shall be included in // The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software. // all copies or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // 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 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE. // THE SOFTWARE.
#include <QtCore/QTime> #include <QtCore/QTime>
#include <QtCore/QThread> #include <QtCore/QThread>
#include <QtCore/QDateTime> #include <QtCore/QDateTime>
#include <QtCore/QByteArray> #include <QtCore/QByteArray>
#include <QtCore/QSharedMemory> #include <QtCore/QSharedMemory>
#include "singleapplication.h" #include "singleapplication.h"
#include "singleapplication_p.h" #include "singleapplication_p.h"
/** /**
* @brief Constructor. Checks and fires up LocalServer or closes the program * @brief Constructor. Checks and fires up LocalServer or closes the program
* if another instance already exists * if another instance already exists
* @param argc * @param argc
* @param argv * @param argv
* @param {bool} allowSecondaryInstances * @param {bool} allowSecondaryInstances
*/ */
SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSecondary, Options options, int timeout ) SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSecondary, Options options, int timeout )
: app_t( argc, argv ), d_ptr( new SingleApplicationPrivate( this ) ) : app_t( argc, argv ), d_ptr( new SingleApplicationPrivate( this ) )
{ {
Q_D(SingleApplication); Q_D(SingleApplication);
// Store the current mode of the program // Store the current mode of the program
d->options = options; d->options = options;
// Generating an application ID used for identifying the shared memory // Generating an application ID used for identifying the shared memory
// block and QLocalServer // block and QLocalServer
d->genBlockServerName(); d->genBlockServerName();
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
// By explicitly attaching it and then deleting it we make sure that the // By explicitly attaching it and then deleting it we make sure that the
// memory is deleted even after the process has crashed on Unix. // memory is deleted even after the process has crashed on Unix.
d->memory = new QSharedMemory( d->blockServerName ); d->memory = new QSharedMemory( d->blockServerName );
d->memory->attach(); d->memory->attach();
delete d->memory; delete d->memory;
#endif #endif
// Guarantee thread safe behaviour with a shared memory block. // Guarantee thread safe behaviour with a shared memory block.
d->memory = new QSharedMemory( d->blockServerName ); d->memory = new QSharedMemory( d->blockServerName );
// Create a shared memory block // Create a shared memory block
if( d->memory->create( sizeof( InstancesInfo ) ) ) { if( d->memory->create( sizeof( InstancesInfo ) ) ) {
// Initialize the shared memory block // Initialize the shared memory block
d->memory->lock(); d->memory->lock();
d->initializeMemoryBlock(); d->initializeMemoryBlock();
d->memory->unlock(); d->memory->unlock();
} else { } else {
// Attempt to attach to the memory segment // Attempt to attach to the memory segment
if( ! d->memory->attach() ) { if( ! d->memory->attach() ) {
qCritical() << "SingleApplication: Unable to attach to shared memory block."; qCritical() << "SingleApplication: Unable to attach to shared memory block.";
qCritical() << d->memory->errorString(); qCritical() << d->memory->errorString();
delete d; delete d;
::exit( EXIT_FAILURE ); ::exit( EXIT_FAILURE );
} }
} }
InstancesInfo* inst = static_cast<InstancesInfo*>( d->memory->data() ); InstancesInfo* inst = static_cast<InstancesInfo*>( d->memory->data() );
QTime time; QTime time;
time.start(); time.start();
// Make sure the shared memory block is initialised and in consistent state // Make sure the shared memory block is initialised and in consistent state
while( true ) { while( true ) {
d->memory->lock(); d->memory->lock();
if( d->blockChecksum() == inst->checksum ) break; if( d->blockChecksum() == inst->checksum ) break;
if( time.elapsed() > 5000 ) { if( time.elapsed() > 5000 ) {
qWarning() << "SingleApplication: Shared memory block has been in an inconsistent state from more than 5s. Assuming primary instance failure."; qWarning() << "SingleApplication: Shared memory block has been in an inconsistent state from more than 5s. Assuming primary instance failure.";
d->initializeMemoryBlock(); d->initializeMemoryBlock();
} }
d->memory->unlock(); d->memory->unlock();
// Random sleep here limits the probability of a collision between two racing apps // Random sleep here limits the probability of a collision between two racing apps
qsrand( QDateTime::currentMSecsSinceEpoch() % std::numeric_limits<uint>::max() ); qsrand( QDateTime::currentMSecsSinceEpoch() % std::numeric_limits<uint>::max() );
QThread::sleep( 8 + static_cast <unsigned long>( static_cast <float>( qrand() ) / RAND_MAX * 10 ) ); QThread::sleep( 8 + static_cast <unsigned long>( static_cast <float>( qrand() ) / RAND_MAX * 10 ) );
} }
if( inst->primary == false) { if( inst->primary == false) {
d->startPrimary(); d->startPrimary();
d->memory->unlock(); d->memory->unlock();
return; return;
} }
// Check if another instance can be started // Check if another instance can be started
if( allowSecondary ) { if( allowSecondary ) {
inst->secondary += 1; inst->secondary += 1;
inst->checksum = d->blockChecksum(); inst->checksum = d->blockChecksum();
d->instanceNumber = inst->secondary; d->instanceNumber = inst->secondary;
d->startSecondary(); d->startSecondary();
if( d->options & Mode::SecondaryNotification ) { if( d->options & Mode::SecondaryNotification ) {
d->connectToPrimary( timeout, SingleApplicationPrivate::SecondaryInstance ); d->connectToPrimary( timeout, SingleApplicationPrivate::SecondaryInstance );
} }
d->memory->unlock(); d->memory->unlock();
return; return;
} }
d->memory->unlock(); d->memory->unlock();
d->connectToPrimary( timeout, SingleApplicationPrivate::NewInstance ); d->connectToPrimary( timeout, SingleApplicationPrivate::NewInstance );
delete d; delete d;
::exit( EXIT_SUCCESS ); ::exit( EXIT_SUCCESS );
} }
/** /**
* @brief Destructor * @brief Destructor
*/ */
SingleApplication::~SingleApplication() SingleApplication::~SingleApplication()
{ {
Q_D(SingleApplication); Q_D(SingleApplication);
delete d; delete d;
} }
bool SingleApplication::isPrimary() bool SingleApplication::isPrimary()
{ {
Q_D(SingleApplication); Q_D(SingleApplication);
return d->server != nullptr; return d->server != nullptr;
} }
bool SingleApplication::isSecondary() bool SingleApplication::isSecondary()
{ {
Q_D(SingleApplication); Q_D(SingleApplication);
return d->server == nullptr; return d->server == nullptr;
} }
quint32 SingleApplication::instanceId() quint32 SingleApplication::instanceId()
{ {
Q_D(SingleApplication); Q_D(SingleApplication);
return d->instanceNumber; return d->instanceNumber;
} }
qint64 SingleApplication::primaryPid() qint64 SingleApplication::primaryPid()
{ {
Q_D(SingleApplication); Q_D(SingleApplication);
return d->primaryPid(); return d->primaryPid();
} }
bool SingleApplication::sendMessage( QByteArray message, int timeout ) bool SingleApplication::sendMessage( QByteArray message, int timeout )
{ {
Q_D(SingleApplication); Q_D(SingleApplication);
// Nobody to connect to // Nobody to connect to
if( isPrimary() ) return false; if( isPrimary() ) return false;
// Make sure the socket is connected // Make sure the socket is connected
d->connectToPrimary( timeout, SingleApplicationPrivate::Reconnect ); d->connectToPrimary( timeout, SingleApplicationPrivate::Reconnect );
d->socket->write( message ); d->socket->write( message );
bool dataWritten = d->socket->flush(); bool dataWritten = d->socket->flush();
d->socket->waitForBytesWritten( timeout ); d->socket->waitForBytesWritten( timeout );
return dataWritten; return dataWritten;
} }

View File

@@ -1,135 +1,135 @@
// The MIT License (MIT) // The MIT License (MIT)
// //
// Copyright (c) Itay Grudev 2015 - 2018 // Copyright (c) Itay Grudev 2015 - 2018
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal // of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights // in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is // copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions: // furnished to do so, subject to the following conditions:
// //
// The above copyright notice and this permission notice shall be included in // The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software. // all copies or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // 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 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE. // THE SOFTWARE.
#ifndef SINGLE_APPLICATION_H #ifndef SINGLE_APPLICATION_H
#define SINGLE_APPLICATION_H #define SINGLE_APPLICATION_H
#include <QtCore/QtGlobal> #include <QtCore/QtGlobal>
#include <QtNetwork/QLocalSocket> #include <QtNetwork/QLocalSocket>
#ifndef QAPPLICATION_CLASS #ifndef QAPPLICATION_CLASS
#define QAPPLICATION_CLASS QCoreApplication #define QAPPLICATION_CLASS QCoreApplication
#endif #endif
#include QT_STRINGIFY(QAPPLICATION_CLASS) #include QT_STRINGIFY(QAPPLICATION_CLASS)
class SingleApplicationPrivate; class SingleApplicationPrivate;
/** /**
* @brief The SingleApplication class handles multipe instances of the same * @brief The SingleApplication class handles multipe instances of the same
* Application * Application
* @see QCoreApplication * @see QCoreApplication
*/ */
class SingleApplication : public QAPPLICATION_CLASS class SingleApplication : public QAPPLICATION_CLASS
{ {
Q_OBJECT Q_OBJECT
typedef QAPPLICATION_CLASS app_t; typedef QAPPLICATION_CLASS app_t;
public: public:
/** /**
* @brief Mode of operation of SingleApplication. * @brief Mode of operation of SingleApplication.
* Whether the block should be user-wide or system-wide and whether the * Whether the block should be user-wide or system-wide and whether the
* primary instance should be notified when a secondary instance had been * primary instance should be notified when a secondary instance had been
* started. * started.
* @note Operating system can restrict the shared memory blocks to the same * @note Operating system can restrict the shared memory blocks to the same
* user, in which case the User/System modes will have no effect and the * user, in which case the User/System modes will have no effect and the
* block will be user wide. * block will be user wide.
* @enum * @enum
*/ */
enum Mode { enum Mode {
User = 1 << 0, User = 1 << 0,
System = 1 << 1, System = 1 << 1,
SecondaryNotification = 1 << 2, SecondaryNotification = 1 << 2,
ExcludeAppVersion = 1 << 3, ExcludeAppVersion = 1 << 3,
ExcludeAppPath = 1 << 4 ExcludeAppPath = 1 << 4
}; };
Q_DECLARE_FLAGS(Options, Mode) Q_DECLARE_FLAGS(Options, Mode)
/** /**
* @brief Intitializes a SingleApplication instance with argc command line * @brief Intitializes a SingleApplication instance with argc command line
* arguments in argv * arguments in argv
* @arg {int &} argc - Number of arguments in argv * @arg {int &} argc - Number of arguments in argv
* @arg {const char *[]} argv - Supplied command line arguments * @arg {const char *[]} argv - Supplied command line arguments
* @arg {bool} allowSecondary - Whether to start the instance as secondary * @arg {bool} allowSecondary - Whether to start the instance as secondary
* if there is already a primary instance. * if there is already a primary instance.
* @arg {Mode} mode - Whether for the SingleApplication block to be applied * @arg {Mode} mode - Whether for the SingleApplication block to be applied
* User wide or System wide. * User wide or System wide.
* @arg {int} timeout - Timeout to wait in miliseconds. * @arg {int} timeout - Timeout to wait in miliseconds.
* @note argc and argv may be changed as Qt removes arguments that it * @note argc and argv may be changed as Qt removes arguments that it
* recognizes * recognizes
* @note Mode::SecondaryNotification only works if set on both the primary * @note Mode::SecondaryNotification only works if set on both the primary
* instance and the secondary instance. * instance and the secondary instance.
* @note The timeout is just a hint for the maximum time of blocking * @note The timeout is just a hint for the maximum time of blocking
* operations. It does not guarantee that the SingleApplication * operations. It does not guarantee that the SingleApplication
* initialisation will be completed in given time, though is a good hint. * initialisation will be completed in given time, though is a good hint.
* Usually 4*timeout would be the worst case (fail) scenario. * Usually 4*timeout would be the worst case (fail) scenario.
* @see See the corresponding QAPPLICATION_CLASS constructor for reference * @see See the corresponding QAPPLICATION_CLASS constructor for reference
*/ */
explicit SingleApplication( int &argc, char *argv[], bool allowSecondary = false, Options options = Mode::User, int timeout = 1000 ); explicit SingleApplication( int &argc, char *argv[], bool allowSecondary = false, Options options = Mode::User, int timeout = 1000 );
~SingleApplication(); ~SingleApplication();
/** /**
* @brief Returns if the instance is the primary instance * @brief Returns if the instance is the primary instance
* @returns {bool} * @returns {bool}
*/ */
bool isPrimary(); bool isPrimary();
/** /**
* @brief Returns if the instance is a secondary instance * @brief Returns if the instance is a secondary instance
* @returns {bool} * @returns {bool}
*/ */
bool isSecondary(); bool isSecondary();
/** /**
* @brief Returns a unique identifier for the current instance * @brief Returns a unique identifier for the current instance
* @returns {qint32} * @returns {qint32}
*/ */
quint32 instanceId(); quint32 instanceId();
/** /**
* @brief Returns the process ID (PID) of the primary instance * @brief Returns the process ID (PID) of the primary instance
* @returns {qint64} * @returns {qint64}
*/ */
qint64 primaryPid(); qint64 primaryPid();
/** /**
* @brief Sends a message to the primary instance. Returns true on success. * @brief Sends a message to the primary instance. Returns true on success.
* @param {int} timeout - Timeout for connecting * @param {int} timeout - Timeout for connecting
* @returns {bool} * @returns {bool}
* @note sendMessage() will return false if invoked from the primary * @note sendMessage() will return false if invoked from the primary
* instance. * instance.
*/ */
bool sendMessage( QByteArray message, int timeout = 100 ); bool sendMessage( QByteArray message, int timeout = 100 );
Q_SIGNALS: Q_SIGNALS:
void instanceStarted(); void instanceStarted();
void receivedMessage( quint32 instanceId, QByteArray message ); void receivedMessage( quint32 instanceId, QByteArray message );
private: private:
SingleApplicationPrivate *d_ptr; SingleApplicationPrivate *d_ptr;
Q_DECLARE_PRIVATE(SingleApplication) Q_DECLARE_PRIVATE(SingleApplication)
}; };
Q_DECLARE_OPERATORS_FOR_FLAGS(SingleApplication::Options) Q_DECLARE_OPERATORS_FOR_FLAGS(SingleApplication::Options)
#endif // SINGLE_APPLICATION_H #endif // SINGLE_APPLICATION_H

View File

@@ -1,19 +1,19 @@
QT += core network QT += core network
CONFIG += c++11 CONFIG += c++11
HEADERS += $$PWD/singleapplication.h \ HEADERS += $$PWD/singleapplication.h \
$$PWD/singleapplication_p.h $$PWD/singleapplication_p.h
SOURCES += $$PWD/singleapplication.cpp \ SOURCES += $$PWD/singleapplication.cpp \
$$PWD/singleapplication_p.cpp $$PWD/singleapplication_p.cpp
INCLUDEPATH += $$PWD INCLUDEPATH += $$PWD
win32 { win32 {
msvc:LIBS += Advapi32.lib msvc:LIBS += Advapi32.lib
gcc:LIBS += -ladvapi32 gcc:LIBS += -ladvapi32
} }
DISTFILES += \ DISTFILES += \
$$PWD/README.md \ $$PWD/README.md \
$$PWD/CHANGELOG.md \ $$PWD/CHANGELOG.md \
$$PWD/Windows.md $$PWD/Windows.md

View File

@@ -1,386 +1,386 @@
// The MIT License (MIT) // The MIT License (MIT)
// //
// Copyright (c) Itay Grudev 2015 - 2018 // Copyright (c) Itay Grudev 2015 - 2018
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal // of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights // in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is // copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions: // furnished to do so, subject to the following conditions:
// //
// The above copyright notice and this permission notice shall be included in // The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software. // all copies or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // 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 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE. // THE SOFTWARE.
// //
// W A R N I N G !!! // W A R N I N G !!!
// ----------------- // -----------------
// //
// This file is not part of the SingleApplication API. It is used purely as an // This file is not part of the SingleApplication API. It is used purely as an
// implementation detail. This header file may change from version to // implementation detail. This header file may change from version to
// version without notice, or may even be removed. // version without notice, or may even be removed.
// //
#include <cstdlib> #include <cstdlib>
#include <cstddef> #include <cstddef>
#include <QtCore/QDir> #include <QtCore/QDir>
#include <QtCore/QProcess> #include <QtCore/QProcess>
#include <QtCore/QByteArray> #include <QtCore/QByteArray>
#include <QtCore/QSemaphore> #include <QtCore/QSemaphore>
#include <QtCore/QDataStream> #include <QtCore/QDataStream>
#include <QtCore/QStandardPaths> #include <QtCore/QStandardPaths>
#include <QtCore/QCryptographicHash> #include <QtCore/QCryptographicHash>
#include <QtNetwork/QLocalServer> #include <QtNetwork/QLocalServer>
#include <QtNetwork/QLocalSocket> #include <QtNetwork/QLocalSocket>
#include "singleapplication.h" #include "singleapplication.h"
#include "singleapplication_p.h" #include "singleapplication_p.h"
SingleApplicationPrivate::SingleApplicationPrivate( SingleApplication *q_ptr ) SingleApplicationPrivate::SingleApplicationPrivate( SingleApplication *q_ptr )
: q_ptr( q_ptr ) : q_ptr( q_ptr )
{ {
server = nullptr; server = nullptr;
socket = nullptr; socket = nullptr;
memory = nullptr; memory = nullptr;
instanceNumber = -1; instanceNumber = -1;
} }
SingleApplicationPrivate::~SingleApplicationPrivate() SingleApplicationPrivate::~SingleApplicationPrivate()
{ {
if( socket != nullptr ) { if( socket != nullptr ) {
socket->close(); socket->close();
delete socket; delete socket;
} }
memory->lock(); memory->lock();
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data()); InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data());
if( server != nullptr ) { if( server != nullptr ) {
server->close(); server->close();
delete server; delete server;
inst->primary = false; inst->primary = false;
inst->primaryPid = -1; inst->primaryPid = -1;
inst->checksum = blockChecksum(); inst->checksum = blockChecksum();
} }
memory->unlock(); memory->unlock();
delete memory; delete memory;
} }
void SingleApplicationPrivate::genBlockServerName() void SingleApplicationPrivate::genBlockServerName()
{ {
QCryptographicHash appData( QCryptographicHash::Sha256 ); QCryptographicHash appData( QCryptographicHash::Sha256 );
appData.addData( "SingleApplication", 17 ); appData.addData( "SingleApplication", 17 );
appData.addData( SingleApplication::app_t::applicationName().toUtf8() ); appData.addData( SingleApplication::app_t::applicationName().toUtf8() );
appData.addData( SingleApplication::app_t::organizationName().toUtf8() ); appData.addData( SingleApplication::app_t::organizationName().toUtf8() );
appData.addData( SingleApplication::app_t::organizationDomain().toUtf8() ); appData.addData( SingleApplication::app_t::organizationDomain().toUtf8() );
if( ! (options & SingleApplication::Mode::ExcludeAppVersion) ) { if( ! (options & SingleApplication::Mode::ExcludeAppVersion) ) {
appData.addData( SingleApplication::app_t::applicationVersion().toUtf8() ); appData.addData( SingleApplication::app_t::applicationVersion().toUtf8() );
} }
if( ! (options & SingleApplication::Mode::ExcludeAppPath) ) { if( ! (options & SingleApplication::Mode::ExcludeAppPath) ) {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
appData.addData( SingleApplication::app_t::applicationFilePath().toLower().toUtf8() ); appData.addData( SingleApplication::app_t::applicationFilePath().toLower().toUtf8() );
#else #else
appData.addData( SingleApplication::app_t::applicationFilePath().toUtf8() ); appData.addData( SingleApplication::app_t::applicationFilePath().toUtf8() );
#endif #endif
} }
// User level block requires a user specific data in the hash // User level block requires a user specific data in the hash
if( options & SingleApplication::Mode::User ) { if( options & SingleApplication::Mode::User ) {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
appData.addData( QStandardPaths::standardLocations( QStandardPaths::HomeLocation ).join("").toUtf8() ); appData.addData( QStandardPaths::standardLocations( QStandardPaths::HomeLocation ).join("").toUtf8() );
#endif #endif
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
appData.addData( appData.addData(
QDir( QDir(
QStandardPaths::standardLocations( QStandardPaths::HomeLocation ).first() QStandardPaths::standardLocations( QStandardPaths::HomeLocation ).first()
).absolutePath().toUtf8() ).absolutePath().toUtf8()
); );
#endif #endif
} }
// Replace the backslash in RFC 2045 Base64 [a-zA-Z0-9+/=] to comply with // Replace the backslash in RFC 2045 Base64 [a-zA-Z0-9+/=] to comply with
// server naming requirements. // server naming requirements.
blockServerName = appData.result().toBase64().replace("/", "_"); blockServerName = appData.result().toBase64().replace("/", "_");
} }
void SingleApplicationPrivate::initializeMemoryBlock() void SingleApplicationPrivate::initializeMemoryBlock()
{ {
InstancesInfo* inst = static_cast<InstancesInfo*>( memory->data() ); InstancesInfo* inst = static_cast<InstancesInfo*>( memory->data() );
inst->primary = false; inst->primary = false;
inst->secondary = 0; inst->secondary = 0;
inst->primaryPid = -1; inst->primaryPid = -1;
inst->checksum = blockChecksum(); inst->checksum = blockChecksum();
} }
void SingleApplicationPrivate::startPrimary() void SingleApplicationPrivate::startPrimary()
{ {
Q_Q(SingleApplication); Q_Q(SingleApplication);
// Successful creation means that no main process exists // Successful creation means that no main process exists
// So we start a QLocalServer to listen for connections // So we start a QLocalServer to listen for connections
QLocalServer::removeServer( blockServerName ); QLocalServer::removeServer( blockServerName );
server = new QLocalServer(); server = new QLocalServer();
// Restrict access to the socket according to the // Restrict access to the socket according to the
// SingleApplication::Mode::User flag on User level or no restrictions // SingleApplication::Mode::User flag on User level or no restrictions
if( options & SingleApplication::Mode::User ) { if( options & SingleApplication::Mode::User ) {
server->setSocketOptions( QLocalServer::UserAccessOption ); server->setSocketOptions( QLocalServer::UserAccessOption );
} else { } else {
server->setSocketOptions( QLocalServer::WorldAccessOption ); server->setSocketOptions( QLocalServer::WorldAccessOption );
} }
server->listen( blockServerName ); server->listen( blockServerName );
QObject::connect( QObject::connect(
server, server,
&QLocalServer::newConnection, &QLocalServer::newConnection,
this, this,
&SingleApplicationPrivate::slotConnectionEstablished &SingleApplicationPrivate::slotConnectionEstablished
); );
// Reset the number of connections // Reset the number of connections
InstancesInfo* inst = static_cast <InstancesInfo*>( memory->data() ); InstancesInfo* inst = static_cast <InstancesInfo*>( memory->data() );
inst->primary = true; inst->primary = true;
inst->primaryPid = q->applicationPid(); inst->primaryPid = q->applicationPid();
inst->checksum = blockChecksum(); inst->checksum = blockChecksum();
instanceNumber = 0; instanceNumber = 0;
} }
void SingleApplicationPrivate::startSecondary() void SingleApplicationPrivate::startSecondary()
{ {
} }
void SingleApplicationPrivate::connectToPrimary( int msecs, ConnectionType connectionType ) void SingleApplicationPrivate::connectToPrimary( int msecs, ConnectionType connectionType )
{ {
// Connect to the Local Server of the Primary Instance if not already // Connect to the Local Server of the Primary Instance if not already
// connected. // connected.
if( socket == nullptr ) { if( socket == nullptr ) {
socket = new QLocalSocket(); socket = new QLocalSocket();
} }
// If already connected - we are done; // If already connected - we are done;
if( socket->state() == QLocalSocket::ConnectedState ) if( socket->state() == QLocalSocket::ConnectedState )
return; return;
// If not connect // If not connect
if( socket->state() == QLocalSocket::UnconnectedState || if( socket->state() == QLocalSocket::UnconnectedState ||
socket->state() == QLocalSocket::ClosingState ) { socket->state() == QLocalSocket::ClosingState ) {
socket->connectToServer( blockServerName ); socket->connectToServer( blockServerName );
} }
// Wait for being connected // Wait for being connected
if( socket->state() == QLocalSocket::ConnectingState ) { if( socket->state() == QLocalSocket::ConnectingState ) {
socket->waitForConnected( msecs ); socket->waitForConnected( msecs );
} }
// Initialisation message according to the SingleApplication protocol // Initialisation message according to the SingleApplication protocol
if( socket->state() == QLocalSocket::ConnectedState ) { if( socket->state() == QLocalSocket::ConnectedState ) {
// Notify the parent that a new instance had been started; // Notify the parent that a new instance had been started;
QByteArray initMsg; QByteArray initMsg;
QDataStream writeStream(&initMsg, QIODevice::WriteOnly); QDataStream writeStream(&initMsg, QIODevice::WriteOnly);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
writeStream.setVersion(QDataStream::Qt_5_6); writeStream.setVersion(QDataStream::Qt_5_6);
#endif #endif
writeStream << blockServerName.toLatin1(); writeStream << blockServerName.toLatin1();
writeStream << static_cast<quint8>(connectionType); writeStream << static_cast<quint8>(connectionType);
writeStream << instanceNumber; writeStream << instanceNumber;
quint16 checksum = qChecksum(initMsg.constData(), static_cast<quint32>(initMsg.length())); quint16 checksum = qChecksum(initMsg.constData(), static_cast<quint32>(initMsg.length()));
writeStream << checksum; writeStream << checksum;
// The header indicates the message length that follows // The header indicates the message length that follows
QByteArray header; QByteArray header;
QDataStream headerStream(&header, QIODevice::WriteOnly); QDataStream headerStream(&header, QIODevice::WriteOnly);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
headerStream.setVersion(QDataStream::Qt_5_6); headerStream.setVersion(QDataStream::Qt_5_6);
#endif #endif
headerStream << static_cast <quint64>( initMsg.length() ); headerStream << static_cast <quint64>( initMsg.length() );
socket->write( header ); socket->write( header );
socket->write( initMsg ); socket->write( initMsg );
socket->flush(); socket->flush();
socket->waitForBytesWritten( msecs ); socket->waitForBytesWritten( msecs );
} }
} }
quint16 SingleApplicationPrivate::blockChecksum() quint16 SingleApplicationPrivate::blockChecksum()
{ {
return qChecksum( return qChecksum(
static_cast <const char *>( memory->data() ), static_cast <const char *>( memory->data() ),
offsetof( InstancesInfo, checksum ) offsetof( InstancesInfo, checksum )
); );
} }
qint64 SingleApplicationPrivate::primaryPid() qint64 SingleApplicationPrivate::primaryPid()
{ {
qint64 pid; qint64 pid;
memory->lock(); memory->lock();
InstancesInfo* inst = static_cast<InstancesInfo*>( memory->data() ); InstancesInfo* inst = static_cast<InstancesInfo*>( memory->data() );
pid = inst->primaryPid; pid = inst->primaryPid;
memory->unlock(); memory->unlock();
return pid; return pid;
} }
/** /**
* @brief Executed when a connection has been made to the LocalServer * @brief Executed when a connection has been made to the LocalServer
*/ */
void SingleApplicationPrivate::slotConnectionEstablished() void SingleApplicationPrivate::slotConnectionEstablished()
{ {
QLocalSocket *nextConnSocket = server->nextPendingConnection(); QLocalSocket *nextConnSocket = server->nextPendingConnection();
connectionMap.insert(nextConnSocket, ConnectionInfo()); connectionMap.insert(nextConnSocket, ConnectionInfo());
QObject::connect(nextConnSocket, &QLocalSocket::aboutToClose, QObject::connect(nextConnSocket, &QLocalSocket::aboutToClose,
[nextConnSocket, this]() { [nextConnSocket, this]() {
auto &info = connectionMap[nextConnSocket]; auto &info = connectionMap[nextConnSocket];
Q_EMIT this->slotClientConnectionClosed( nextConnSocket, info.instanceId ); Q_EMIT this->slotClientConnectionClosed( nextConnSocket, info.instanceId );
} }
); );
QObject::connect(nextConnSocket, &QLocalSocket::disconnected, QObject::connect(nextConnSocket, &QLocalSocket::disconnected,
[nextConnSocket, this](){ [nextConnSocket, this](){
connectionMap.remove(nextConnSocket); connectionMap.remove(nextConnSocket);
nextConnSocket->deleteLater(); nextConnSocket->deleteLater();
} }
); );
QObject::connect(nextConnSocket, &QLocalSocket::readyRead, QObject::connect(nextConnSocket, &QLocalSocket::readyRead,
[nextConnSocket, this]() { [nextConnSocket, this]() {
auto &info = connectionMap[nextConnSocket]; auto &info = connectionMap[nextConnSocket];
switch(info.stage) { switch(info.stage) {
case StageHeader: case StageHeader:
readInitMessageHeader(nextConnSocket); readInitMessageHeader(nextConnSocket);
break; break;
case StageBody: case StageBody:
readInitMessageBody(nextConnSocket); readInitMessageBody(nextConnSocket);
break; break;
case StageConnected: case StageConnected:
Q_EMIT this->slotDataAvailable( nextConnSocket, info.instanceId ); Q_EMIT this->slotDataAvailable( nextConnSocket, info.instanceId );
break; break;
default: default:
break; break;
}; };
} }
); );
} }
void SingleApplicationPrivate::readInitMessageHeader( QLocalSocket *sock ) void SingleApplicationPrivate::readInitMessageHeader( QLocalSocket *sock )
{ {
if (!connectionMap.contains( sock )) { if (!connectionMap.contains( sock )) {
return; return;
} }
if( sock->bytesAvailable() < ( qint64 )sizeof( quint64 ) ) { if( sock->bytesAvailable() < ( qint64 )sizeof( quint64 ) ) {
return; return;
} }
QDataStream headerStream( sock ); QDataStream headerStream( sock );
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
headerStream.setVersion( QDataStream::Qt_5_6 ); headerStream.setVersion( QDataStream::Qt_5_6 );
#endif #endif
// Read the header to know the message length // Read the header to know the message length
quint64 msgLen = 0; quint64 msgLen = 0;
headerStream >> msgLen; headerStream >> msgLen;
ConnectionInfo &info = connectionMap[sock]; ConnectionInfo &info = connectionMap[sock];
info.stage = StageBody; info.stage = StageBody;
info.msgLen = msgLen; info.msgLen = msgLen;
if ( sock->bytesAvailable() >= (qint64) msgLen ) { if ( sock->bytesAvailable() >= (qint64) msgLen ) {
readInitMessageBody( sock ); readInitMessageBody( sock );
} }
} }
void SingleApplicationPrivate::readInitMessageBody( QLocalSocket *sock ) void SingleApplicationPrivate::readInitMessageBody( QLocalSocket *sock )
{ {
Q_Q(SingleApplication); Q_Q(SingleApplication);
if (!connectionMap.contains( sock )) { if (!connectionMap.contains( sock )) {
return; return;
} }
ConnectionInfo &info = connectionMap[sock]; ConnectionInfo &info = connectionMap[sock];
if( sock->bytesAvailable() < ( qint64 )info.msgLen ) { if( sock->bytesAvailable() < ( qint64 )info.msgLen ) {
return; return;
} }
// Read the message body // Read the message body
QByteArray msgBytes = sock->read(info.msgLen); QByteArray msgBytes = sock->read(info.msgLen);
QDataStream readStream(msgBytes); QDataStream readStream(msgBytes);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
readStream.setVersion( QDataStream::Qt_5_6 ); readStream.setVersion( QDataStream::Qt_5_6 );
#endif #endif
// server name // server name
QByteArray latin1Name; QByteArray latin1Name;
readStream >> latin1Name; readStream >> latin1Name;
// connection type // connection type
ConnectionType connectionType = InvalidConnection; ConnectionType connectionType = InvalidConnection;
quint8 connTypeVal = InvalidConnection; quint8 connTypeVal = InvalidConnection;
readStream >> connTypeVal; readStream >> connTypeVal;
connectionType = static_cast <ConnectionType>( connTypeVal ); connectionType = static_cast <ConnectionType>( connTypeVal );
// instance id // instance id
quint32 instanceId = 0; quint32 instanceId = 0;
readStream >> instanceId; readStream >> instanceId;
// checksum // checksum
quint16 msgChecksum = 0; quint16 msgChecksum = 0;
readStream >> msgChecksum; readStream >> msgChecksum;
const quint16 actualChecksum = qChecksum( msgBytes.constData(), static_cast<quint32>( msgBytes.length() - sizeof( quint16 ) ) ); const quint16 actualChecksum = qChecksum( msgBytes.constData(), static_cast<quint32>( msgBytes.length() - sizeof( quint16 ) ) );
bool isValid = readStream.status() == QDataStream::Ok && bool isValid = readStream.status() == QDataStream::Ok &&
QLatin1String(latin1Name) == blockServerName && QLatin1String(latin1Name) == blockServerName &&
msgChecksum == actualChecksum; msgChecksum == actualChecksum;
if( !isValid ) { if( !isValid ) {
sock->close(); sock->close();
return; return;
} }
info.instanceId = instanceId; info.instanceId = instanceId;
info.stage = StageConnected; info.stage = StageConnected;
if( connectionType == NewInstance || if( connectionType == NewInstance ||
( connectionType == SecondaryInstance && ( connectionType == SecondaryInstance &&
options & SingleApplication::Mode::SecondaryNotification ) ) options & SingleApplication::Mode::SecondaryNotification ) )
{ {
Q_EMIT q->instanceStarted(); Q_EMIT q->instanceStarted();
} }
if (sock->bytesAvailable() > 0) { if (sock->bytesAvailable() > 0) {
Q_EMIT this->slotDataAvailable( sock, instanceId ); Q_EMIT this->slotDataAvailable( sock, instanceId );
} }
} }
void SingleApplicationPrivate::slotDataAvailable( QLocalSocket *dataSocket, quint32 instanceId ) void SingleApplicationPrivate::slotDataAvailable( QLocalSocket *dataSocket, quint32 instanceId )
{ {
Q_Q(SingleApplication); Q_Q(SingleApplication);
Q_EMIT q->receivedMessage( instanceId, dataSocket->readAll() ); Q_EMIT q->receivedMessage( instanceId, dataSocket->readAll() );
} }
void SingleApplicationPrivate::slotClientConnectionClosed( QLocalSocket *closedSocket, quint32 instanceId ) void SingleApplicationPrivate::slotClientConnectionClosed( QLocalSocket *closedSocket, quint32 instanceId )
{ {
if( closedSocket->bytesAvailable() > 0 ) if( closedSocket->bytesAvailable() > 0 )
Q_EMIT slotDataAvailable( closedSocket, instanceId ); Q_EMIT slotDataAvailable( closedSocket, instanceId );
} }

View File

@@ -1,99 +1,99 @@
// The MIT License (MIT) // The MIT License (MIT)
// //
// Copyright (c) Itay Grudev 2015 - 2016 // Copyright (c) Itay Grudev 2015 - 2016
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal // of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights // in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is // copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions: // furnished to do so, subject to the following conditions:
// //
// The above copyright notice and this permission notice shall be included in // The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software. // all copies or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // 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 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE. // THE SOFTWARE.
// //
// W A R N I N G !!! // W A R N I N G !!!
// ----------------- // -----------------
// //
// This file is not part of the SingleApplication API. It is used purely as an // This file is not part of the SingleApplication API. It is used purely as an
// implementation detail. This header file may change from version to // implementation detail. This header file may change from version to
// version without notice, or may even be removed. // version without notice, or may even be removed.
// //
#ifndef SINGLEAPPLICATION_P_H #ifndef SINGLEAPPLICATION_P_H
#define SINGLEAPPLICATION_P_H #define SINGLEAPPLICATION_P_H
#include <QtCore/QSharedMemory> #include <QtCore/QSharedMemory>
#include <QtNetwork/QLocalServer> #include <QtNetwork/QLocalServer>
#include <QtNetwork/QLocalSocket> #include <QtNetwork/QLocalSocket>
#include "singleapplication.h" #include "singleapplication.h"
struct InstancesInfo { struct InstancesInfo {
bool primary; bool primary;
quint32 secondary; quint32 secondary;
qint64 primaryPid; qint64 primaryPid;
quint16 checksum; quint16 checksum;
}; };
struct ConnectionInfo { struct ConnectionInfo {
explicit ConnectionInfo() : explicit ConnectionInfo() :
msgLen(0), instanceId(0), stage(0) {} msgLen(0), instanceId(0), stage(0) {}
qint64 msgLen; qint64 msgLen;
quint32 instanceId; quint32 instanceId;
quint8 stage; quint8 stage;
}; };
class SingleApplicationPrivate : public QObject { class SingleApplicationPrivate : public QObject {
Q_OBJECT Q_OBJECT
public: public:
enum ConnectionType : quint8 { enum ConnectionType : quint8 {
InvalidConnection = 0, InvalidConnection = 0,
NewInstance = 1, NewInstance = 1,
SecondaryInstance = 2, SecondaryInstance = 2,
Reconnect = 3 Reconnect = 3
}; };
enum ConnectionStage : quint8 { enum ConnectionStage : quint8 {
StageHeader = 0, StageHeader = 0,
StageBody = 1, StageBody = 1,
StageConnected = 2, StageConnected = 2,
}; };
Q_DECLARE_PUBLIC(SingleApplication) Q_DECLARE_PUBLIC(SingleApplication)
SingleApplicationPrivate( SingleApplication *q_ptr ); SingleApplicationPrivate( SingleApplication *q_ptr );
~SingleApplicationPrivate(); ~SingleApplicationPrivate();
void genBlockServerName(); void genBlockServerName();
void initializeMemoryBlock(); void initializeMemoryBlock();
void startPrimary(); void startPrimary();
void startSecondary(); void startSecondary();
void connectToPrimary(int msecs, ConnectionType connectionType ); void connectToPrimary(int msecs, ConnectionType connectionType );
quint16 blockChecksum(); quint16 blockChecksum();
qint64 primaryPid(); qint64 primaryPid();
void readInitMessageHeader(QLocalSocket *socket); void readInitMessageHeader(QLocalSocket *socket);
void readInitMessageBody(QLocalSocket *socket); void readInitMessageBody(QLocalSocket *socket);
SingleApplication *q_ptr; SingleApplication *q_ptr;
QSharedMemory *memory; QSharedMemory *memory;
QLocalSocket *socket; QLocalSocket *socket;
QLocalServer *server; QLocalServer *server;
quint32 instanceNumber; quint32 instanceNumber;
QString blockServerName; QString blockServerName;
SingleApplication::Options options; SingleApplication::Options options;
QMap<QLocalSocket*, ConnectionInfo> connectionMap; QMap<QLocalSocket*, ConnectionInfo> connectionMap;
public Q_SLOTS: public Q_SLOTS:
void slotConnectionEstablished(); void slotConnectionEstablished();
void slotDataAvailable( QLocalSocket*, quint32 ); void slotDataAvailable( QLocalSocket*, quint32 );
void slotClientConnectionClosed( QLocalSocket*, quint32 ); void slotClientConnectionClosed( QLocalSocket*, quint32 );
}; };
#endif // SINGLEAPPLICATION_P_H #endif // SINGLEAPPLICATION_P_H

File diff suppressed because it is too large Load Diff

View File

@@ -1,41 +1,41 @@
/* /*
* QR Code generator library (C++) * QR Code generator library (C++)
* *
* Copyright (c) Project Nayuki. (MIT License) * Copyright (c) Project Nayuki. (MIT License)
* https://www.nayuki.io/page/qr-code-generator-library * https://www.nayuki.io/page/qr-code-generator-library
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * 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 * this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to * the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * 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, * the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions: * subject to the following conditions:
* - The above copyright notice and this permission notice shall be included in * - The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* - The Software is provided "as is", without warranty of any kind, express or * - The Software is provided "as is", without warranty of any kind, express or
* implied, including but not limited to the warranties of merchantability, * implied, including but not limited to the warranties of merchantability,
* fitness for a particular purpose and noninfringement. In no event shall the * fitness for a particular purpose and noninfringement. In no event shall the
* authors or copyright holders be liable for any claim, damages or other * authors or copyright holders be liable for any claim, damages or other
* liability, whether in an action of contract, tort or otherwise, arising from, * 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 * out of or in connection with the Software or the use or other dealings in the
* Software. * Software.
*/ */
#include <stdexcept> #include <stdexcept>
#include "BitBuffer.hpp" #include "BitBuffer.hpp"
namespace qrcodegen { namespace qrcodegen {
BitBuffer::BitBuffer() BitBuffer::BitBuffer()
: std::vector<bool>() {} : std::vector<bool>() {}
void BitBuffer::appendBits(std::uint32_t val, int len) { void BitBuffer::appendBits(std::uint32_t val, int len) {
if (len < 0 || len > 31 || val >> len != 0) if (len < 0 || len > 31 || val >> len != 0)
throw std::domain_error("Value out of range"); throw std::domain_error("Value out of range");
for (int i = len - 1; i >= 0; i--) // Append bit by bit for (int i = len - 1; i >= 0; i--) // Append bit by bit
this->push_back(((val >> i) & 1) != 0); this->push_back(((val >> i) & 1) != 0);
} }
} }

View File

@@ -1,52 +1,52 @@
/* /*
* QR Code generator library (C++) * QR Code generator library (C++)
* *
* Copyright (c) Project Nayuki. (MIT License) * Copyright (c) Project Nayuki. (MIT License)
* https://www.nayuki.io/page/qr-code-generator-library * https://www.nayuki.io/page/qr-code-generator-library
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * 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 * this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to * the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * 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, * the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions: * subject to the following conditions:
* - The above copyright notice and this permission notice shall be included in * - The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* - The Software is provided "as is", without warranty of any kind, express or * - The Software is provided "as is", without warranty of any kind, express or
* implied, including but not limited to the warranties of merchantability, * implied, including but not limited to the warranties of merchantability,
* fitness for a particular purpose and noninfringement. In no event shall the * fitness for a particular purpose and noninfringement. In no event shall the
* authors or copyright holders be liable for any claim, damages or other * authors or copyright holders be liable for any claim, damages or other
* liability, whether in an action of contract, tort or otherwise, arising from, * 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 * out of or in connection with the Software or the use or other dealings in the
* Software. * Software.
*/ */
#pragma once #pragma once
#include <cstdint> #include <cstdint>
#include <vector> #include <vector>
namespace qrcodegen { namespace qrcodegen {
/* /*
* An appendable sequence of bits (0s and 1s). Mainly used by QrSegment. * An appendable sequence of bits (0s and 1s). Mainly used by QrSegment.
*/ */
class BitBuffer final : public std::vector<bool> { class BitBuffer final : public std::vector<bool> {
/*---- Constructor ----*/ /*---- Constructor ----*/
// Creates an empty bit buffer (length 0). // Creates an empty bit buffer (length 0).
public: BitBuffer(); public: BitBuffer();
/*---- Method ----*/ /*---- Method ----*/
// Appends the given number of low-order bits of the given value // Appends the given number of low-order bits of the given value
// to this buffer. Requires 0 <= len <= 31 and val < 2^len. // to this buffer. Requires 0 <= len <= 31 and val < 2^len.
public: void appendBits(std::uint32_t val, int len); public: void appendBits(std::uint32_t val, int len);
}; };
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,351 +1,351 @@
/* /*
* QR Code generator library (C++) * QR Code generator library (C++)
* *
* Copyright (c) Project Nayuki. (MIT License) * Copyright (c) Project Nayuki. (MIT License)
* https://www.nayuki.io/page/qr-code-generator-library * https://www.nayuki.io/page/qr-code-generator-library
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * 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 * this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to * the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * 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, * the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions: * subject to the following conditions:
* - The above copyright notice and this permission notice shall be included in * - The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* - The Software is provided "as is", without warranty of any kind, express or * - The Software is provided "as is", without warranty of any kind, express or
* implied, including but not limited to the warranties of merchantability, * implied, including but not limited to the warranties of merchantability,
* fitness for a particular purpose and noninfringement. In no event shall the * fitness for a particular purpose and noninfringement. In no event shall the
* authors or copyright holders be liable for any claim, damages or other * authors or copyright holders be liable for any claim, damages or other
* liability, whether in an action of contract, tort or otherwise, arising from, * 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 * out of or in connection with the Software or the use or other dealings in the
* Software. * Software.
*/ */
#pragma once #pragma once
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include <vector> #include <vector>
#include "QrSegment.hpp" #include "QrSegment.hpp"
namespace qrcodegen { namespace qrcodegen {
/* /*
* A QR Code symbol, which is a type of two-dimension barcode. * A QR Code symbol, which is a type of two-dimension barcode.
* Invented by Denso Wave and described in the ISO/IEC 18004 standard. * Invented by Denso Wave and described in the ISO/IEC 18004 standard.
* Instances of this class represent an immutable square grid of black and white cells. * Instances of this class represent an immutable square grid of black and white cells.
* The class provides static factory functions to create a QR Code from text or binary data. * The class provides static factory functions to create a QR Code from text or binary data.
* The class covers the QR Code Model 2 specification, supporting all versions (sizes) * The class covers the QR Code Model 2 specification, supporting all versions (sizes)
* from 1 to 40, all 4 error correction levels, and 4 character encoding modes. * from 1 to 40, all 4 error correction levels, and 4 character encoding modes.
* *
* Ways to create a QR Code object: * Ways to create a QR Code object:
* - High level: Take the payload data and call QrCode::encodeText() or QrCode::encodeBinary(). * - High level: Take the payload data and call QrCode::encodeText() or QrCode::encodeBinary().
* - Mid level: Custom-make the list of segments and call QrCode::encodeSegments(). * - Mid level: Custom-make the list of segments and call QrCode::encodeSegments().
* - Low level: Custom-make the array of data codeword bytes (including * - Low level: Custom-make the array of data codeword bytes (including
* segment headers and final padding, excluding error correction codewords), * segment headers and final padding, excluding error correction codewords),
* supply the appropriate version number, and call the QrCode() constructor. * supply the appropriate version number, and call the QrCode() constructor.
* (Note that all ways require supplying the desired error correction level.) * (Note that all ways require supplying the desired error correction level.)
*/ */
class QrCode final { class QrCode final {
/*---- Public helper enumeration ----*/ /*---- Public helper enumeration ----*/
/* /*
* The error correction level in a QR Code symbol. * The error correction level in a QR Code symbol.
*/ */
public: enum class Ecc { public: enum class Ecc {
LOW = 0 , // The QR Code can tolerate about 7% erroneous codewords LOW = 0 , // The QR Code can tolerate about 7% erroneous codewords
MEDIUM , // The QR Code can tolerate about 15% erroneous codewords MEDIUM , // The QR Code can tolerate about 15% erroneous codewords
QUARTILE, // The QR Code can tolerate about 25% erroneous codewords QUARTILE, // The QR Code can tolerate about 25% erroneous codewords
HIGH , // The QR Code can tolerate about 30% erroneous codewords HIGH , // The QR Code can tolerate about 30% erroneous codewords
}; };
// Returns a value in the range 0 to 3 (unsigned 2-bit integer). // Returns a value in the range 0 to 3 (unsigned 2-bit integer).
private: static int getFormatBits(Ecc ecl); private: static int getFormatBits(Ecc ecl);
/*---- Static factory functions (high level) ----*/ /*---- Static factory functions (high level) ----*/
/* /*
* Returns a QR Code representing the given Unicode text string at the given error correction level. * Returns a QR Code representing the given Unicode text string at the given error correction level.
* As a conservative upper bound, this function is guaranteed to succeed for strings that have 2953 or fewer * As a conservative upper bound, this function is guaranteed to succeed for strings that have 2953 or fewer
* UTF-8 code units (not Unicode code points) if the low error correction level is used. The smallest possible * UTF-8 code units (not Unicode code points) if the low error correction level is used. The smallest possible
* QR Code version is automatically chosen for the output. The ECC level of the result may be higher than * QR Code version is automatically chosen for the output. The ECC level of the result may be higher than
* the ecl argument if it can be done without increasing the version. * the ecl argument if it can be done without increasing the version.
*/ */
public: static QrCode encodeText(const char *text, Ecc ecl); public: static QrCode encodeText(const char *text, Ecc ecl);
/* /*
* Returns a QR Code representing the given binary data at the given error correction level. * Returns a QR Code representing the given binary data at the given error correction level.
* This function always encodes using the binary segment mode, not any text mode. The maximum number of * This function always encodes using the binary segment mode, not any text mode. The maximum number of
* bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output. * bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
* The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version. * The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
*/ */
public: static QrCode encodeBinary(const std::vector<std::uint8_t> &data, Ecc ecl); public: static QrCode encodeBinary(const std::vector<std::uint8_t> &data, Ecc ecl);
/*---- Static factory functions (mid level) ----*/ /*---- Static factory functions (mid level) ----*/
/* /*
* Returns a QR Code representing the given segments with the given encoding parameters. * Returns a QR Code representing the given segments with the given encoding parameters.
* The smallest possible QR Code version within the given range is automatically * The smallest possible QR Code version within the given range is automatically
* chosen for the output. Iff boostEcl is true, then the ECC level of the result * chosen for the output. Iff boostEcl is true, then the ECC level of the result
* may be higher than the ecl argument if it can be done without increasing the * may be higher than the ecl argument if it can be done without increasing the
* version. The mask number is either between 0 to 7 (inclusive) to force that * version. The mask number is either between 0 to 7 (inclusive) to force that
* mask, or -1 to automatically choose an appropriate mask (which may be slow). * mask, or -1 to automatically choose an appropriate mask (which may be slow).
* This function allows the user to create a custom sequence of segments that switches * This function allows the user to create a custom sequence of segments that switches
* between modes (such as alphanumeric and byte) to encode text in less space. * between modes (such as alphanumeric and byte) to encode text in less space.
* This is a mid-level API; the high-level API is encodeText() and encodeBinary(). * This is a mid-level API; the high-level API is encodeText() and encodeBinary().
*/ */
public: static QrCode encodeSegments(const std::vector<QrSegment> &segs, Ecc ecl, public: static QrCode encodeSegments(const std::vector<QrSegment> &segs, Ecc ecl,
int minVersion=1, int maxVersion=40, int mask=-1, bool boostEcl=true); // All optional parameters int minVersion=1, int maxVersion=40, int mask=-1, bool boostEcl=true); // All optional parameters
/*---- Instance fields ----*/ /*---- Instance fields ----*/
// Immutable scalar parameters: // Immutable scalar parameters:
/* The version number of this QR Code, which is between 1 and 40 (inclusive). /* The version number of this QR Code, which is between 1 and 40 (inclusive).
* This determines the size of this barcode. */ * This determines the size of this barcode. */
private: int version; private: int version;
/* The width and height of this QR Code, measured in modules, between /* The width and height of this QR Code, measured in modules, between
* 21 and 177 (inclusive). This is equal to version * 4 + 17. */ * 21 and 177 (inclusive). This is equal to version * 4 + 17. */
private: int size; private: int size;
/* The error correction level used in this QR Code. */ /* The error correction level used in this QR Code. */
private: Ecc errorCorrectionLevel; private: Ecc errorCorrectionLevel;
/* The index of the mask pattern used in this QR Code, which is between 0 and 7 (inclusive). /* The index of the mask pattern used in this QR Code, which is between 0 and 7 (inclusive).
* Even if a QR Code is created with automatic masking requested (mask = -1), * Even if a QR Code is created with automatic masking requested (mask = -1),
* the resulting object still has a mask value between 0 and 7. */ * the resulting object still has a mask value between 0 and 7. */
private: int mask; private: int mask;
// Private grids of modules/pixels, with dimensions of size*size: // Private grids of modules/pixels, with dimensions of size*size:
// The modules of this QR Code (false = white, true = black). // The modules of this QR Code (false = white, true = black).
// Immutable after constructor finishes. Accessed through getModule(). // Immutable after constructor finishes. Accessed through getModule().
private: std::vector<std::vector<bool> > modules; private: std::vector<std::vector<bool> > modules;
// Indicates function modules that are not subjected to masking. Discarded when constructor finishes. // Indicates function modules that are not subjected to masking. Discarded when constructor finishes.
private: std::vector<std::vector<bool> > isFunction; private: std::vector<std::vector<bool> > isFunction;
/*---- Constructor (low level) ----*/ /*---- Constructor (low level) ----*/
/* /*
* Creates a new QR Code with the given version number, * Creates a new QR Code with the given version number,
* error correction level, data codeword bytes, and mask number. * error correction level, data codeword bytes, and mask number.
* This is a low-level API that most users should not use directly. * This is a low-level API that most users should not use directly.
* A mid-level API is the encodeSegments() function. * A mid-level API is the encodeSegments() function.
*/ */
public: QrCode(int ver, Ecc ecl, const std::vector<std::uint8_t> &dataCodewords, int mask); public: QrCode(int ver, Ecc ecl, const std::vector<std::uint8_t> &dataCodewords, int mask);
/*---- Public instance methods ----*/ /*---- Public instance methods ----*/
/* /*
* Returns this QR Code's version, in the range [1, 40]. * Returns this QR Code's version, in the range [1, 40].
*/ */
public: int getVersion() const; public: int getVersion() const;
/* /*
* Returns this QR Code's size, in the range [21, 177]. * Returns this QR Code's size, in the range [21, 177].
*/ */
public: int getSize() const; public: int getSize() const;
/* /*
* Returns this QR Code's error correction level. * Returns this QR Code's error correction level.
*/ */
public: Ecc getErrorCorrectionLevel() const; public: Ecc getErrorCorrectionLevel() const;
/* /*
* Returns this QR Code's mask, in the range [0, 7]. * Returns this QR Code's mask, in the range [0, 7].
*/ */
public: int getMask() const; public: int getMask() const;
/* /*
* Returns the color of the module (pixel) at the given coordinates, which is false * Returns the color of the module (pixel) at the given coordinates, which is false
* for white or true for black. The top left corner has the coordinates (x=0, y=0). * for white or true for black. The top left corner has the coordinates (x=0, y=0).
* If the given coordinates are out of bounds, then false (white) is returned. * If the given coordinates are out of bounds, then false (white) is returned.
*/ */
public: bool getModule(int x, int y) const; public: bool getModule(int x, int y) const;
/* /*
* Returns a string of SVG code for an image depicting this QR Code, with the given number * Returns a string of SVG code for an image depicting this QR Code, with the given number
* of border modules. The string always uses Unix newlines (\n), regardless of the platform. * of border modules. The string always uses Unix newlines (\n), regardless of the platform.
*/ */
public: std::string toSvgString(int border) const; public: std::string toSvgString(int border) const;
/*---- Private helper methods for constructor: Drawing function modules ----*/ /*---- Private helper methods for constructor: Drawing function modules ----*/
// Reads this object's version field, and draws and marks all function modules. // Reads this object's version field, and draws and marks all function modules.
private: void drawFunctionPatterns(); private: void drawFunctionPatterns();
// Draws two copies of the format bits (with its own error correction code) // Draws two copies of the format bits (with its own error correction code)
// based on the given mask and this object's error correction level field. // based on the given mask and this object's error correction level field.
private: void drawFormatBits(int mask); private: void drawFormatBits(int mask);
// Draws two copies of the version bits (with its own error correction code), // Draws two copies of the version bits (with its own error correction code),
// based on this object's version field, iff 7 <= version <= 40. // based on this object's version field, iff 7 <= version <= 40.
private: void drawVersion(); private: void drawVersion();
// Draws a 9*9 finder pattern including the border separator, // Draws a 9*9 finder pattern including the border separator,
// with the center module at (x, y). Modules can be out of bounds. // with the center module at (x, y). Modules can be out of bounds.
private: void drawFinderPattern(int x, int y); private: void drawFinderPattern(int x, int y);
// Draws a 5*5 alignment pattern, with the center module // Draws a 5*5 alignment pattern, with the center module
// at (x, y). All modules must be in bounds. // at (x, y). All modules must be in bounds.
private: void drawAlignmentPattern(int x, int y); private: void drawAlignmentPattern(int x, int y);
// Sets the color of a module and marks it as a function module. // Sets the color of a module and marks it as a function module.
// Only used by the constructor. Coordinates must be in bounds. // Only used by the constructor. Coordinates must be in bounds.
private: void setFunctionModule(int x, int y, bool isBlack); private: void setFunctionModule(int x, int y, bool isBlack);
// Returns the color of the module at the given coordinates, which must be in range. // Returns the color of the module at the given coordinates, which must be in range.
private: bool module(int x, int y) const; private: bool module(int x, int y) const;
/*---- Private helper methods for constructor: Codewords and masking ----*/ /*---- Private helper methods for constructor: Codewords and masking ----*/
// Returns a new byte string representing the given data with the appropriate error correction // Returns a new byte string representing the given data with the appropriate error correction
// codewords appended to it, based on this object's version and error correction level. // codewords appended to it, based on this object's version and error correction level.
private: std::vector<std::uint8_t> addEccAndInterleave(const std::vector<std::uint8_t> &data) const; private: std::vector<std::uint8_t> addEccAndInterleave(const std::vector<std::uint8_t> &data) const;
// Draws the given sequence of 8-bit codewords (data and error correction) onto the entire // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
// data area of this QR Code. Function modules need to be marked off before this is called. // data area of this QR Code. Function modules need to be marked off before this is called.
private: void drawCodewords(const std::vector<std::uint8_t> &data); private: void drawCodewords(const std::vector<std::uint8_t> &data);
// XORs the codeword modules in this QR Code with the given mask pattern. // XORs the codeword modules in this QR Code with the given mask pattern.
// The function modules must be marked and the codeword bits must be drawn // The function modules must be marked and the codeword bits must be drawn
// before masking. Due to the arithmetic of XOR, calling applyMask() with // before masking. Due to the arithmetic of XOR, calling applyMask() with
// the same mask value a second time will undo the mask. A final well-formed // the same mask value a second time will undo the mask. A final well-formed
// QR Code needs exactly one (not zero, two, etc.) mask applied. // QR Code needs exactly one (not zero, two, etc.) mask applied.
private: void applyMask(int mask); private: void applyMask(int mask);
// A messy helper function for the constructors. This QR Code must be in an unmasked state when this // A messy helper function for the constructors. This QR Code must be in an unmasked state when this
// method is called. The given argument is the requested mask, which is -1 for auto or 0 to 7 for fixed. // method is called. The given argument is the requested mask, which is -1 for auto or 0 to 7 for fixed.
// This method applies and returns the actual mask chosen, from 0 to 7. // This method applies and returns the actual mask chosen, from 0 to 7.
private: int handleConstructorMasking(int mask); private: int handleConstructorMasking(int mask);
// Calculates and returns the penalty score based on state of this QR Code's current modules. // Calculates and returns the penalty score based on state of this QR Code's current modules.
// This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score. // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
private: long getPenaltyScore() const; private: long getPenaltyScore() const;
/*---- Private helper functions ----*/ /*---- Private helper functions ----*/
// Returns an ascending list of positions of alignment patterns for this version number. // Returns an ascending list of positions of alignment patterns for this version number.
// Each position is in the range [0,177), and are used on both the x and y axes. // Each position is in the range [0,177), and are used on both the x and y axes.
// This could be implemented as lookup table of 40 variable-length lists of unsigned bytes. // This could be implemented as lookup table of 40 variable-length lists of unsigned bytes.
private: std::vector<int> getAlignmentPatternPositions() const; private: std::vector<int> getAlignmentPatternPositions() const;
// Returns the number of data bits that can be stored in a QR Code of the given version number, after // Returns the number of data bits that can be stored in a QR Code of the given version number, after
// all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8. // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
// The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table. // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
private: static int getNumRawDataModules(int ver); private: static int getNumRawDataModules(int ver);
// Returns the number of 8-bit data (i.e. not error correction) codewords contained in any // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
// QR Code of the given version number and error correction level, with remainder bits discarded. // QR Code of the given version number and error correction level, with remainder bits discarded.
// This stateless pure function could be implemented as a (40*4)-cell lookup table. // This stateless pure function could be implemented as a (40*4)-cell lookup table.
private: static int getNumDataCodewords(int ver, Ecc ecl); private: static int getNumDataCodewords(int ver, Ecc ecl);
// Returns true iff the i'th bit of x is set to 1. // Returns true iff the i'th bit of x is set to 1.
private: static bool getBit(long x, int i); private: static bool getBit(long x, int i);
/*---- Constants and tables ----*/ /*---- Constants and tables ----*/
// The minimum version number supported in the QR Code Model 2 standard. // The minimum version number supported in the QR Code Model 2 standard.
public: static constexpr int MIN_VERSION = 1; public: static constexpr int MIN_VERSION = 1;
// The maximum version number supported in the QR Code Model 2 standard. // The maximum version number supported in the QR Code Model 2 standard.
public: static constexpr int MAX_VERSION = 40; public: static constexpr int MAX_VERSION = 40;
// For use in getPenaltyScore(), when evaluating which mask is best. // For use in getPenaltyScore(), when evaluating which mask is best.
private: static const int PENALTY_N1; private: static const int PENALTY_N1;
private: static const int PENALTY_N2; private: static const int PENALTY_N2;
private: static const int PENALTY_N3; private: static const int PENALTY_N3;
private: static const int PENALTY_N4; private: static const int PENALTY_N4;
private: static const std::int8_t ECC_CODEWORDS_PER_BLOCK[4][41]; private: static const std::int8_t ECC_CODEWORDS_PER_BLOCK[4][41];
private: static const std::int8_t NUM_ERROR_CORRECTION_BLOCKS[4][41]; private: static const std::int8_t NUM_ERROR_CORRECTION_BLOCKS[4][41];
/*---- Private helper class ----*/ /*---- Private helper class ----*/
/* /*
* Computes the Reed-Solomon error correction codewords for a sequence of data codewords * Computes the Reed-Solomon error correction codewords for a sequence of data codewords
* at a given degree. Objects are immutable, and the state only depends on the degree. * at a given degree. Objects are immutable, and the state only depends on the degree.
* This class exists because each data block in a QR Code shares the same the divisor polynomial. * This class exists because each data block in a QR Code shares the same the divisor polynomial.
*/ */
private: class ReedSolomonGenerator final { private: class ReedSolomonGenerator final {
/*-- Immutable field --*/ /*-- Immutable field --*/
// Coefficients of the divisor polynomial, stored from highest to lowest power, excluding the leading term which // Coefficients of the divisor polynomial, stored from highest to lowest power, excluding the leading term which
// is always 1. For example the polynomial x^3 + 255x^2 + 8x + 93 is stored as the uint8 array {255, 8, 93}. // is always 1. For example the polynomial x^3 + 255x^2 + 8x + 93 is stored as the uint8 array {255, 8, 93}.
private: std::vector<std::uint8_t> coefficients; private: std::vector<std::uint8_t> coefficients;
/*-- Constructor --*/ /*-- Constructor --*/
/* /*
* Creates a Reed-Solomon ECC generator for the given degree. This could be implemented * Creates a Reed-Solomon ECC generator for the given degree. This could be implemented
* as a lookup table over all possible parameter values, instead of as an algorithm. * as a lookup table over all possible parameter values, instead of as an algorithm.
*/ */
public: explicit ReedSolomonGenerator(int degree); public: explicit ReedSolomonGenerator(int degree);
/*-- Method --*/ /*-- Method --*/
/* /*
* Computes and returns the Reed-Solomon error correction codewords for the given * Computes and returns the Reed-Solomon error correction codewords for the given
* sequence of data codewords. The returned object is always a new byte array. * sequence of data codewords. The returned object is always a new byte array.
* This method does not alter this object's state (because it is immutable). * This method does not alter this object's state (because it is immutable).
*/ */
public: std::vector<std::uint8_t> getRemainder(const std::vector<std::uint8_t> &data) const; public: std::vector<std::uint8_t> getRemainder(const std::vector<std::uint8_t> &data) const;
/*-- Static function --*/ /*-- Static function --*/
// Returns the product of the two given field elements modulo GF(2^8/0x11D). // Returns the product of the two given field elements modulo GF(2^8/0x11D).
// All inputs are valid. This could be implemented as a 256*256 lookup table. // All inputs are valid. This could be implemented as a 256*256 lookup table.
private: static std::uint8_t multiply(std::uint8_t x, std::uint8_t y); private: static std::uint8_t multiply(std::uint8_t x, std::uint8_t y);
}; };
}; };
} }

View File

@@ -1,225 +1,225 @@
/* /*
* QR Code generator library (C++) * QR Code generator library (C++)
* *
* Copyright (c) Project Nayuki. (MIT License) * Copyright (c) Project Nayuki. (MIT License)
* https://www.nayuki.io/page/qr-code-generator-library * https://www.nayuki.io/page/qr-code-generator-library
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * 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 * this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to * the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * 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, * the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions: * subject to the following conditions:
* - The above copyright notice and this permission notice shall be included in * - The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* - The Software is provided "as is", without warranty of any kind, express or * - The Software is provided "as is", without warranty of any kind, express or
* implied, including but not limited to the warranties of merchantability, * implied, including but not limited to the warranties of merchantability,
* fitness for a particular purpose and noninfringement. In no event shall the * fitness for a particular purpose and noninfringement. In no event shall the
* authors or copyright holders be liable for any claim, damages or other * authors or copyright holders be liable for any claim, damages or other
* liability, whether in an action of contract, tort or otherwise, arising from, * 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 * out of or in connection with the Software or the use or other dealings in the
* Software. * Software.
*/ */
#include <climits> #include <climits>
#include <cstring> #include <cstring>
#include <stdexcept> #include <stdexcept>
#include <utility> #include <utility>
#include "QrSegment.hpp" #include "QrSegment.hpp"
using std::uint8_t; using std::uint8_t;
using std::vector; using std::vector;
namespace qrcodegen { namespace qrcodegen {
QrSegment::Mode::Mode(int mode, int cc0, int cc1, int cc2) : QrSegment::Mode::Mode(int mode, int cc0, int cc1, int cc2) :
modeBits(mode) { modeBits(mode) {
numBitsCharCount[0] = cc0; numBitsCharCount[0] = cc0;
numBitsCharCount[1] = cc1; numBitsCharCount[1] = cc1;
numBitsCharCount[2] = cc2; numBitsCharCount[2] = cc2;
} }
int QrSegment::Mode::getModeBits() const { int QrSegment::Mode::getModeBits() const {
return modeBits; return modeBits;
} }
int QrSegment::Mode::numCharCountBits(int ver) const { int QrSegment::Mode::numCharCountBits(int ver) const {
return numBitsCharCount[(ver + 7) / 17]; return numBitsCharCount[(ver + 7) / 17];
} }
const QrSegment::Mode QrSegment::Mode::NUMERIC (0x1, 10, 12, 14); const QrSegment::Mode QrSegment::Mode::NUMERIC (0x1, 10, 12, 14);
const QrSegment::Mode QrSegment::Mode::ALPHANUMERIC(0x2, 9, 11, 13); const QrSegment::Mode QrSegment::Mode::ALPHANUMERIC(0x2, 9, 11, 13);
const QrSegment::Mode QrSegment::Mode::BYTE (0x4, 8, 16, 16); const QrSegment::Mode QrSegment::Mode::BYTE (0x4, 8, 16, 16);
const QrSegment::Mode QrSegment::Mode::KANJI (0x8, 8, 10, 12); const QrSegment::Mode QrSegment::Mode::KANJI (0x8, 8, 10, 12);
const QrSegment::Mode QrSegment::Mode::ECI (0x7, 0, 0, 0); const QrSegment::Mode QrSegment::Mode::ECI (0x7, 0, 0, 0);
QrSegment QrSegment::makeBytes(const vector<uint8_t> &data) { QrSegment QrSegment::makeBytes(const vector<uint8_t> &data) {
if (data.size() > static_cast<unsigned int>(INT_MAX)) if (data.size() > static_cast<unsigned int>(INT_MAX))
throw std::length_error("Data too long"); throw std::length_error("Data too long");
BitBuffer bb; BitBuffer bb;
for (uint8_t b : data) for (uint8_t b : data)
bb.appendBits(b, 8); bb.appendBits(b, 8);
return QrSegment(Mode::BYTE, static_cast<int>(data.size()), std::move(bb)); return QrSegment(Mode::BYTE, static_cast<int>(data.size()), std::move(bb));
} }
QrSegment QrSegment::makeNumeric(const char *digits) { QrSegment QrSegment::makeNumeric(const char *digits) {
BitBuffer bb; BitBuffer bb;
int accumData = 0; int accumData = 0;
int accumCount = 0; int accumCount = 0;
int charCount = 0; int charCount = 0;
for (; *digits != '\0'; digits++, charCount++) { for (; *digits != '\0'; digits++, charCount++) {
char c = *digits; char c = *digits;
if (c < '0' || c > '9') if (c < '0' || c > '9')
throw std::domain_error("String contains non-numeric characters"); throw std::domain_error("String contains non-numeric characters");
accumData = accumData * 10 + (c - '0'); accumData = accumData * 10 + (c - '0');
accumCount++; accumCount++;
if (accumCount == 3) { if (accumCount == 3) {
bb.appendBits(accumData, 10); bb.appendBits(accumData, 10);
accumData = 0; accumData = 0;
accumCount = 0; accumCount = 0;
} }
} }
if (accumCount > 0) // 1 or 2 digits remaining if (accumCount > 0) // 1 or 2 digits remaining
bb.appendBits(accumData, accumCount * 3 + 1); bb.appendBits(accumData, accumCount * 3 + 1);
return QrSegment(Mode::NUMERIC, charCount, std::move(bb)); return QrSegment(Mode::NUMERIC, charCount, std::move(bb));
} }
QrSegment QrSegment::makeAlphanumeric(const char *text) { QrSegment QrSegment::makeAlphanumeric(const char *text) {
BitBuffer bb; BitBuffer bb;
int accumData = 0; int accumData = 0;
int accumCount = 0; int accumCount = 0;
int charCount = 0; int charCount = 0;
for (; *text != '\0'; text++, charCount++) { for (; *text != '\0'; text++, charCount++) {
const char *temp = std::strchr(ALPHANUMERIC_CHARSET, *text); const char *temp = std::strchr(ALPHANUMERIC_CHARSET, *text);
if (temp == nullptr) if (temp == nullptr)
throw std::domain_error("String contains unencodable characters in alphanumeric mode"); throw std::domain_error("String contains unencodable characters in alphanumeric mode");
accumData = accumData * 45 + (temp - ALPHANUMERIC_CHARSET); accumData = accumData * 45 + (temp - ALPHANUMERIC_CHARSET);
accumCount++; accumCount++;
if (accumCount == 2) { if (accumCount == 2) {
bb.appendBits(accumData, 11); bb.appendBits(accumData, 11);
accumData = 0; accumData = 0;
accumCount = 0; accumCount = 0;
} }
} }
if (accumCount > 0) // 1 character remaining if (accumCount > 0) // 1 character remaining
bb.appendBits(accumData, 6); bb.appendBits(accumData, 6);
return QrSegment(Mode::ALPHANUMERIC, charCount, std::move(bb)); return QrSegment(Mode::ALPHANUMERIC, charCount, std::move(bb));
} }
vector<QrSegment> QrSegment::makeSegments(const char *text) { vector<QrSegment> QrSegment::makeSegments(const char *text) {
// Select the most efficient segment encoding automatically // Select the most efficient segment encoding automatically
vector<QrSegment> result; vector<QrSegment> result;
if (*text == '\0'); // Leave result empty if (*text == '\0'); // Leave result empty
else if (isNumeric(text)) else if (isNumeric(text))
result.push_back(makeNumeric(text)); result.push_back(makeNumeric(text));
else if (isAlphanumeric(text)) else if (isAlphanumeric(text))
result.push_back(makeAlphanumeric(text)); result.push_back(makeAlphanumeric(text));
else { else {
vector<uint8_t> bytes; vector<uint8_t> bytes;
for (; *text != '\0'; text++) for (; *text != '\0'; text++)
bytes.push_back(static_cast<uint8_t>(*text)); bytes.push_back(static_cast<uint8_t>(*text));
result.push_back(makeBytes(bytes)); result.push_back(makeBytes(bytes));
} }
return result; return result;
} }
QrSegment QrSegment::makeEci(long assignVal) { QrSegment QrSegment::makeEci(long assignVal) {
BitBuffer bb; BitBuffer bb;
if (assignVal < 0) if (assignVal < 0)
throw std::domain_error("ECI assignment value out of range"); throw std::domain_error("ECI assignment value out of range");
else if (assignVal < (1 << 7)) else if (assignVal < (1 << 7))
bb.appendBits(assignVal, 8); bb.appendBits(assignVal, 8);
else if (assignVal < (1 << 14)) { else if (assignVal < (1 << 14)) {
bb.appendBits(2, 2); bb.appendBits(2, 2);
bb.appendBits(assignVal, 14); bb.appendBits(assignVal, 14);
} else if (assignVal < 1000000L) { } else if (assignVal < 1000000L) {
bb.appendBits(6, 3); bb.appendBits(6, 3);
bb.appendBits(assignVal, 21); bb.appendBits(assignVal, 21);
} else } else
throw std::domain_error("ECI assignment value out of range"); throw std::domain_error("ECI assignment value out of range");
return QrSegment(Mode::ECI, 0, std::move(bb)); return QrSegment(Mode::ECI, 0, std::move(bb));
} }
QrSegment::QrSegment(Mode md, int numCh, const std::vector<bool> &dt) : QrSegment::QrSegment(Mode md, int numCh, const std::vector<bool> &dt) :
mode(md), mode(md),
numChars(numCh), numChars(numCh),
data(dt) { data(dt) {
if (numCh < 0) if (numCh < 0)
throw std::domain_error("Invalid value"); throw std::domain_error("Invalid value");
} }
QrSegment::QrSegment(Mode md, int numCh, std::vector<bool> &&dt) : QrSegment::QrSegment(Mode md, int numCh, std::vector<bool> &&dt) :
mode(md), mode(md),
numChars(numCh), numChars(numCh),
data(std::move(dt)) { data(std::move(dt)) {
if (numCh < 0) if (numCh < 0)
throw std::domain_error("Invalid value"); throw std::domain_error("Invalid value");
} }
int QrSegment::getTotalBits(const vector<QrSegment> &segs, int version) { int QrSegment::getTotalBits(const vector<QrSegment> &segs, int version) {
int result = 0; int result = 0;
for (const QrSegment &seg : segs) { for (const QrSegment &seg : segs) {
int ccbits = seg.mode.numCharCountBits(version); int ccbits = seg.mode.numCharCountBits(version);
if (seg.numChars >= (1L << ccbits)) if (seg.numChars >= (1L << ccbits))
return -1; // The segment's length doesn't fit the field's bit width return -1; // The segment's length doesn't fit the field's bit width
if (4 + ccbits > INT_MAX - result) if (4 + ccbits > INT_MAX - result)
return -1; // The sum will overflow an int type return -1; // The sum will overflow an int type
result += 4 + ccbits; result += 4 + ccbits;
if (seg.data.size() > static_cast<unsigned int>(INT_MAX - result)) if (seg.data.size() > static_cast<unsigned int>(INT_MAX - result))
return -1; // The sum will overflow an int type return -1; // The sum will overflow an int type
result += static_cast<int>(seg.data.size()); result += static_cast<int>(seg.data.size());
} }
return result; return result;
} }
bool QrSegment::isAlphanumeric(const char *text) { bool QrSegment::isAlphanumeric(const char *text) {
for (; *text != '\0'; text++) { for (; *text != '\0'; text++) {
if (std::strchr(ALPHANUMERIC_CHARSET, *text) == nullptr) if (std::strchr(ALPHANUMERIC_CHARSET, *text) == nullptr)
return false; return false;
} }
return true; return true;
} }
bool QrSegment::isNumeric(const char *text) { bool QrSegment::isNumeric(const char *text) {
for (; *text != '\0'; text++) { for (; *text != '\0'; text++) {
char c = *text; char c = *text;
if (c < '0' || c > '9') if (c < '0' || c > '9')
return false; return false;
} }
return true; return true;
} }
QrSegment::Mode QrSegment::getMode() const { QrSegment::Mode QrSegment::getMode() const {
return mode; return mode;
} }
int QrSegment::getNumChars() const { int QrSegment::getNumChars() const {
return numChars; return numChars;
} }
const std::vector<bool> &QrSegment::getData() const { const std::vector<bool> &QrSegment::getData() const {
return data; return data;
} }
const char *QrSegment::ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"; const char *QrSegment::ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
} }

View File

@@ -1,216 +1,216 @@
/* /*
* QR Code generator library (C++) * QR Code generator library (C++)
* *
* Copyright (c) Project Nayuki. (MIT License) * Copyright (c) Project Nayuki. (MIT License)
* https://www.nayuki.io/page/qr-code-generator-library * https://www.nayuki.io/page/qr-code-generator-library
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * 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 * this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to * the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * 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, * the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions: * subject to the following conditions:
* - The above copyright notice and this permission notice shall be included in * - The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* - The Software is provided "as is", without warranty of any kind, express or * - The Software is provided "as is", without warranty of any kind, express or
* implied, including but not limited to the warranties of merchantability, * implied, including but not limited to the warranties of merchantability,
* fitness for a particular purpose and noninfringement. In no event shall the * fitness for a particular purpose and noninfringement. In no event shall the
* authors or copyright holders be liable for any claim, damages or other * authors or copyright holders be liable for any claim, damages or other
* liability, whether in an action of contract, tort or otherwise, arising from, * 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 * out of or in connection with the Software or the use or other dealings in the
* Software. * Software.
*/ */
#pragma once #pragma once
#include <cstdint> #include <cstdint>
#include <vector> #include <vector>
#include "BitBuffer.hpp" #include "BitBuffer.hpp"
namespace qrcodegen { namespace qrcodegen {
/* /*
* A segment of character/binary/control data in a QR Code symbol. * A segment of character/binary/control data in a QR Code symbol.
* Instances of this class are immutable. * Instances of this class are immutable.
* The mid-level way to create a segment is to take the payload data * The mid-level way to create a segment is to take the payload data
* and call a static factory function such as QrSegment::makeNumeric(). * and call a static factory function such as QrSegment::makeNumeric().
* The low-level way to create a segment is to custom-make the bit buffer * The low-level way to create a segment is to custom-make the bit buffer
* and call the QrSegment() constructor with appropriate values. * and call the QrSegment() constructor with appropriate values.
* This segment class imposes no length restrictions, but QR Codes have restrictions. * This segment class imposes no length restrictions, but QR Codes have restrictions.
* Even in the most favorable conditions, a QR Code can only hold 7089 characters of data. * Even in the most favorable conditions, a QR Code can only hold 7089 characters of data.
* Any segment longer than this is meaningless for the purpose of generating QR Codes. * Any segment longer than this is meaningless for the purpose of generating QR Codes.
*/ */
class QrSegment final { class QrSegment final {
/*---- Public helper enumeration ----*/ /*---- Public helper enumeration ----*/
/* /*
* Describes how a segment's data bits are interpreted. Immutable. * Describes how a segment's data bits are interpreted. Immutable.
*/ */
public: class Mode final { public: class Mode final {
/*-- Constants --*/ /*-- Constants --*/
public: static const Mode NUMERIC; public: static const Mode NUMERIC;
public: static const Mode ALPHANUMERIC; public: static const Mode ALPHANUMERIC;
public: static const Mode BYTE; public: static const Mode BYTE;
public: static const Mode KANJI; public: static const Mode KANJI;
public: static const Mode ECI; public: static const Mode ECI;
/*-- Fields --*/ /*-- Fields --*/
// The mode indicator bits, which is a uint4 value (range 0 to 15). // The mode indicator bits, which is a uint4 value (range 0 to 15).
private: int modeBits; private: int modeBits;
// Number of character count bits for three different version ranges. // Number of character count bits for three different version ranges.
private: int numBitsCharCount[3]; private: int numBitsCharCount[3];
/*-- Constructor --*/ /*-- Constructor --*/
private: Mode(int mode, int cc0, int cc1, int cc2); private: Mode(int mode, int cc0, int cc1, int cc2);
/*-- Methods --*/ /*-- Methods --*/
/* /*
* (Package-private) Returns the mode indicator bits, which is an unsigned 4-bit value (range 0 to 15). * (Package-private) Returns the mode indicator bits, which is an unsigned 4-bit value (range 0 to 15).
*/ */
public: int getModeBits() const; public: int getModeBits() const;
/* /*
* (Package-private) Returns the bit width of the character count field for a segment in * (Package-private) Returns the bit width of the character count field for a segment in
* this mode in a QR Code at the given version number. The result is in the range [0, 16]. * this mode in a QR Code at the given version number. The result is in the range [0, 16].
*/ */
public: int numCharCountBits(int ver) const; public: int numCharCountBits(int ver) const;
}; };
/*---- Static factory functions (mid level) ----*/ /*---- Static factory functions (mid level) ----*/
/* /*
* Returns a segment representing the given binary data encoded in * Returns a segment representing the given binary data encoded in
* byte mode. All input byte vectors are acceptable. Any text string * byte mode. All input byte vectors are acceptable. Any text string
* can be converted to UTF-8 bytes and encoded as a byte mode segment. * can be converted to UTF-8 bytes and encoded as a byte mode segment.
*/ */
public: static QrSegment makeBytes(const std::vector<std::uint8_t> &data); public: static QrSegment makeBytes(const std::vector<std::uint8_t> &data);
/* /*
* Returns a segment representing the given string of decimal digits encoded in numeric mode. * Returns a segment representing the given string of decimal digits encoded in numeric mode.
*/ */
public: static QrSegment makeNumeric(const char *digits); public: static QrSegment makeNumeric(const char *digits);
/* /*
* Returns a segment representing the given text string encoded in alphanumeric mode. * Returns a segment representing the given text string encoded in alphanumeric mode.
* The characters allowed are: 0 to 9, A to Z (uppercase only), space, * The characters allowed are: 0 to 9, A to Z (uppercase only), space,
* dollar, percent, asterisk, plus, hyphen, period, slash, colon. * dollar, percent, asterisk, plus, hyphen, period, slash, colon.
*/ */
public: static QrSegment makeAlphanumeric(const char *text); public: static QrSegment makeAlphanumeric(const char *text);
/* /*
* Returns a list of zero or more segments to represent the given text string. The result * Returns a list of zero or more segments to represent the given text string. The result
* may use various segment modes and switch modes to optimize the length of the bit stream. * may use various segment modes and switch modes to optimize the length of the bit stream.
*/ */
public: static std::vector<QrSegment> makeSegments(const char *text); public: static std::vector<QrSegment> makeSegments(const char *text);
/* /*
* Returns a segment representing an Extended Channel Interpretation * Returns a segment representing an Extended Channel Interpretation
* (ECI) designator with the given assignment value. * (ECI) designator with the given assignment value.
*/ */
public: static QrSegment makeEci(long assignVal); public: static QrSegment makeEci(long assignVal);
/*---- Public static helper functions ----*/ /*---- Public static helper functions ----*/
/* /*
* Tests whether the given string can be encoded as a segment in alphanumeric mode. * Tests whether the given string can be encoded as a segment in alphanumeric mode.
* A string is encodable iff each character is in the following set: 0 to 9, A to Z * A string is encodable iff each character is in the following set: 0 to 9, A to Z
* (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon. * (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
*/ */
public: static bool isAlphanumeric(const char *text); public: static bool isAlphanumeric(const char *text);
/* /*
* Tests whether the given string can be encoded as a segment in numeric mode. * Tests whether the given string can be encoded as a segment in numeric mode.
* A string is encodable iff each character is in the range 0 to 9. * A string is encodable iff each character is in the range 0 to 9.
*/ */
public: static bool isNumeric(const char *text); public: static bool isNumeric(const char *text);
/*---- Instance fields ----*/ /*---- Instance fields ----*/
/* The mode indicator of this segment. Accessed through getMode(). */ /* The mode indicator of this segment. Accessed through getMode(). */
private: Mode mode; private: Mode mode;
/* The length of this segment's unencoded data. Measured in characters for /* The length of this segment's unencoded data. Measured in characters for
* numeric/alphanumeric/kanji mode, bytes for byte mode, and 0 for ECI mode. * numeric/alphanumeric/kanji mode, bytes for byte mode, and 0 for ECI mode.
* Always zero or positive. Not the same as the data's bit length. * Always zero or positive. Not the same as the data's bit length.
* Accessed through getNumChars(). */ * Accessed through getNumChars(). */
private: int numChars; private: int numChars;
/* The data bits of this segment. Accessed through getData(). */ /* The data bits of this segment. Accessed through getData(). */
private: std::vector<bool> data; private: std::vector<bool> data;
/*---- Constructors (low level) ----*/ /*---- Constructors (low level) ----*/
/* /*
* Creates a new QR Code segment with the given attributes and data. * Creates a new QR Code segment with the given attributes and data.
* The character count (numCh) must agree with the mode and the bit buffer length, * The character count (numCh) must agree with the mode and the bit buffer length,
* but the constraint isn't checked. The given bit buffer is copied and stored. * but the constraint isn't checked. The given bit buffer is copied and stored.
*/ */
public: QrSegment(Mode md, int numCh, const std::vector<bool> &dt); public: QrSegment(Mode md, int numCh, const std::vector<bool> &dt);
/* /*
* Creates a new QR Code segment with the given parameters and data. * Creates a new QR Code segment with the given parameters and data.
* The character count (numCh) must agree with the mode and the bit buffer length, * The character count (numCh) must agree with the mode and the bit buffer length,
* but the constraint isn't checked. The given bit buffer is moved and stored. * but the constraint isn't checked. The given bit buffer is moved and stored.
*/ */
public: QrSegment(Mode md, int numCh, std::vector<bool> &&dt); public: QrSegment(Mode md, int numCh, std::vector<bool> &&dt);
/*---- Methods ----*/ /*---- Methods ----*/
/* /*
* Returns the mode field of this segment. * Returns the mode field of this segment.
*/ */
public: Mode getMode() const; public: Mode getMode() const;
/* /*
* Returns the character count field of this segment. * Returns the character count field of this segment.
*/ */
public: int getNumChars() const; public: int getNumChars() const;
/* /*
* Returns the data bits of this segment. * Returns the data bits of this segment.
*/ */
public: const std::vector<bool> &getData() const; public: const std::vector<bool> &getData() const;
// (Package-private) Calculates the number of bits needed to encode the given segments at // (Package-private) Calculates the number of bits needed to encode the given segments at
// the given version. Returns a non-negative number if successful. Otherwise returns -1 if a // the given version. Returns a non-negative number if successful. Otherwise returns -1 if a
// segment has too many characters to fit its length field, or the total bits exceeds INT_MAX. // segment has too many characters to fit its length field, or the total bits exceeds INT_MAX.
public: static int getTotalBits(const std::vector<QrSegment> &segs, int version); public: static int getTotalBits(const std::vector<QrSegment> &segs, int version);
/*---- Private constant ----*/ /*---- Private constant ----*/
/* The set of all legal characters in alphanumeric mode, where /* The set of all legal characters in alphanumeric mode, where
* each character value maps to the index in the string. */ * each character value maps to the index in the string. */
private: static const char *ALPHANUMERIC_CHARSET; private: static const char *ALPHANUMERIC_CHARSET;
}; };
} }

146
src/3rdparty/sodium.h vendored
View File

@@ -1,73 +1,73 @@
// Copyright 2019-2024 The Hush developers // Copyright 2019-2024 The Hush developers
// Released under the GPLv3 // Released under the GPLv3
#ifndef sodium_H #ifndef sodium_H
#define sodium_H #define sodium_H
// This is where SDL includes libsodium primitives to be used on our application // This is where SDL includes libsodium primitives to be used on our application
#include "sodium/version.h" #include "sodium/version.h"
#include "sodium/core.h" #include "sodium/core.h"
#include "sodium/crypto_aead_aes256gcm.h" #include "sodium/crypto_aead_aes256gcm.h"
#include "sodium/crypto_aead_chacha20poly1305.h" #include "sodium/crypto_aead_chacha20poly1305.h"
#include "sodium/crypto_aead_xchacha20poly1305.h" #include "sodium/crypto_aead_xchacha20poly1305.h"
#include "sodium/crypto_auth.h" #include "sodium/crypto_auth.h"
#include "sodium/crypto_auth_hmacsha256.h" #include "sodium/crypto_auth_hmacsha256.h"
#include "sodium/crypto_auth_hmacsha512.h" #include "sodium/crypto_auth_hmacsha512.h"
#include "sodium/crypto_auth_hmacsha512256.h" #include "sodium/crypto_auth_hmacsha512256.h"
#include "sodium/crypto_box.h" #include "sodium/crypto_box.h"
#include "sodium/crypto_box_curve25519xsalsa20poly1305.h" #include "sodium/crypto_box_curve25519xsalsa20poly1305.h"
#include "sodium/crypto_core_hsalsa20.h" #include "sodium/crypto_core_hsalsa20.h"
#include "sodium/crypto_core_hchacha20.h" #include "sodium/crypto_core_hchacha20.h"
#include "sodium/crypto_core_salsa20.h" #include "sodium/crypto_core_salsa20.h"
#include "sodium/crypto_core_salsa2012.h" #include "sodium/crypto_core_salsa2012.h"
#include "sodium/crypto_core_salsa208.h" #include "sodium/crypto_core_salsa208.h"
#include "sodium/crypto_generichash.h" #include "sodium/crypto_generichash.h"
#include "sodium/crypto_generichash_blake2b.h" #include "sodium/crypto_generichash_blake2b.h"
#include "sodium/crypto_hash.h" #include "sodium/crypto_hash.h"
#include "sodium/crypto_hash_sha256.h" #include "sodium/crypto_hash_sha256.h"
#include "sodium/crypto_hash_sha512.h" #include "sodium/crypto_hash_sha512.h"
#include "sodium/crypto_kdf.h" #include "sodium/crypto_kdf.h"
#include "sodium/crypto_kdf_blake2b.h" #include "sodium/crypto_kdf_blake2b.h"
#include "sodium/crypto_kx.h" #include "sodium/crypto_kx.h"
#include "sodium/crypto_onetimeauth.h" #include "sodium/crypto_onetimeauth.h"
#include "sodium/crypto_onetimeauth_poly1305.h" #include "sodium/crypto_onetimeauth_poly1305.h"
#include "sodium/crypto_pwhash.h" #include "sodium/crypto_pwhash.h"
#include "sodium/crypto_pwhash_argon2i.h" #include "sodium/crypto_pwhash_argon2i.h"
#include "sodium/crypto_scalarmult.h" #include "sodium/crypto_scalarmult.h"
#include "sodium/crypto_scalarmult_curve25519.h" #include "sodium/crypto_scalarmult_curve25519.h"
#include "sodium/crypto_secretbox.h" #include "sodium/crypto_secretbox.h"
#include "sodium/crypto_secretbox_xsalsa20poly1305.h" #include "sodium/crypto_secretbox_xsalsa20poly1305.h"
#include "sodium/crypto_secretstream_xchacha20poly1305.h" #include "sodium/crypto_secretstream_xchacha20poly1305.h"
#include "sodium/crypto_shorthash.h" #include "sodium/crypto_shorthash.h"
#include "sodium/crypto_shorthash_siphash24.h" #include "sodium/crypto_shorthash_siphash24.h"
#include "sodium/crypto_sign.h" #include "sodium/crypto_sign.h"
#include "sodium/crypto_sign_ed25519.h" #include "sodium/crypto_sign_ed25519.h"
#include "sodium/crypto_stream.h" #include "sodium/crypto_stream.h"
#include "sodium/crypto_stream_chacha20.h" #include "sodium/crypto_stream_chacha20.h"
#include "sodium/crypto_stream_salsa20.h" #include "sodium/crypto_stream_salsa20.h"
#include "sodium/crypto_stream_xsalsa20.h" #include "sodium/crypto_stream_xsalsa20.h"
#include "sodium/crypto_verify_16.h" #include "sodium/crypto_verify_16.h"
#include "sodium/crypto_verify_32.h" #include "sodium/crypto_verify_32.h"
#include "sodium/crypto_verify_64.h" #include "sodium/crypto_verify_64.h"
#include "sodium/randombytes.h" #include "sodium/randombytes.h"
#ifdef __native_client__ #ifdef __native_client__
# include "sodium/randombytes_nativeclient.h" # include "sodium/randombytes_nativeclient.h"
#endif #endif
#include "sodium/randombytes_salsa20_random.h" #include "sodium/randombytes_salsa20_random.h"
#include "sodium/randombytes_sysrandom.h" #include "sodium/randombytes_sysrandom.h"
#include "sodium/runtime.h" #include "sodium/runtime.h"
#include "sodium/utils.h" #include "sodium/utils.h"
#ifndef SODIUM_LIBRARY_MINIMAL #ifndef SODIUM_LIBRARY_MINIMAL
# include "sodium/crypto_box_curve25519xchacha20poly1305.h" # include "sodium/crypto_box_curve25519xchacha20poly1305.h"
# include "sodium/crypto_core_ed25519.h" # include "sodium/crypto_core_ed25519.h"
# include "sodium/crypto_scalarmult_ed25519.h" # include "sodium/crypto_scalarmult_ed25519.h"
# include "sodium/crypto_secretbox_xchacha20poly1305.h" # include "sodium/crypto_secretbox_xchacha20poly1305.h"
# include "sodium/crypto_pwhash_scryptsalsa208sha256.h" # include "sodium/crypto_pwhash_scryptsalsa208sha256.h"
# include "sodium/crypto_stream_salsa2012.h" # include "sodium/crypto_stream_salsa2012.h"
# include "sodium/crypto_stream_salsa208.h" # include "sodium/crypto_stream_salsa208.h"
# include "sodium/crypto_stream_xchacha20.h" # include "sodium/crypto_stream_xchacha20.h"
#endif #endif
#endif #endif

View File

@@ -1,28 +1,28 @@
#ifndef sodium_core_H #ifndef sodium_core_H
#define sodium_core_H #define sodium_core_H
#include "export.h" #include "export.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
SODIUM_EXPORT SODIUM_EXPORT
int sodium_init(void) int sodium_init(void)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
/* ---- */ /* ---- */
SODIUM_EXPORT SODIUM_EXPORT
int sodium_set_misuse_handler(void (*handler)(void)); int sodium_set_misuse_handler(void (*handler)(void));
SODIUM_EXPORT SODIUM_EXPORT
void sodium_misuse(void) void sodium_misuse(void)
__attribute__ ((noreturn)); __attribute__ ((noreturn));
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@@ -1,171 +1,171 @@
#ifndef crypto_aead_aes256gcm_H #ifndef crypto_aead_aes256gcm_H
#define crypto_aead_aes256gcm_H #define crypto_aead_aes256gcm_H
/* /*
* WARNING: Despite being the most popular AEAD construction due to its * WARNING: Despite being the most popular AEAD construction due to its
* use in TLS, safely using AES-GCM in a different context is tricky. * use in TLS, safely using AES-GCM in a different context is tricky.
* *
* No more than ~ 350 GB of input data should be encrypted with a given key. * No more than ~ 350 GB of input data should be encrypted with a given key.
* This is for ~ 16 KB messages -- Actual figures vary according to * This is for ~ 16 KB messages -- Actual figures vary according to
* message sizes. * message sizes.
* *
* In addition, nonces are short and repeated nonces would totally destroy * In addition, nonces are short and repeated nonces would totally destroy
* the security of this scheme. * the security of this scheme.
* *
* Nonces should thus come from atomic counters, which can be difficult to * Nonces should thus come from atomic counters, which can be difficult to
* set up in a distributed environment. * set up in a distributed environment.
* *
* Unless you absolutely need AES-GCM, use crypto_aead_xchacha20poly1305_ietf_*() * Unless you absolutely need AES-GCM, use crypto_aead_xchacha20poly1305_ietf_*()
* instead. It doesn't have any of these limitations. * instead. It doesn't have any of these limitations.
* Or, if you don't need to authenticate additional data, just stick to * Or, if you don't need to authenticate additional data, just stick to
* crypto_secretbox(). * crypto_secretbox().
*/ */
#include <stddef.h> #include <stddef.h>
#include "export.h" #include "export.h"
#ifdef __cplusplus #ifdef __cplusplus
# ifdef __GNUC__ # ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wlong-long" # pragma GCC diagnostic ignored "-Wlong-long"
# endif # endif
extern "C" { extern "C" {
#endif #endif
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_aes256gcm_is_available(void); int crypto_aead_aes256gcm_is_available(void);
#define crypto_aead_aes256gcm_KEYBYTES 32U #define crypto_aead_aes256gcm_KEYBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_aes256gcm_keybytes(void); size_t crypto_aead_aes256gcm_keybytes(void);
#define crypto_aead_aes256gcm_NSECBYTES 0U #define crypto_aead_aes256gcm_NSECBYTES 0U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_aes256gcm_nsecbytes(void); size_t crypto_aead_aes256gcm_nsecbytes(void);
#define crypto_aead_aes256gcm_NPUBBYTES 12U #define crypto_aead_aes256gcm_NPUBBYTES 12U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_aes256gcm_npubbytes(void); size_t crypto_aead_aes256gcm_npubbytes(void);
#define crypto_aead_aes256gcm_ABYTES 16U #define crypto_aead_aes256gcm_ABYTES 16U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_aes256gcm_abytes(void); size_t crypto_aead_aes256gcm_abytes(void);
#define crypto_aead_aes256gcm_MESSAGEBYTES_MAX \ #define crypto_aead_aes256gcm_MESSAGEBYTES_MAX \
SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_aes256gcm_ABYTES, \ SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_aes256gcm_ABYTES, \
(16ULL * ((1ULL << 32) - 2ULL)) - crypto_aead_aes256gcm_ABYTES) (16ULL * ((1ULL << 32) - 2ULL)) - crypto_aead_aes256gcm_ABYTES)
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_aes256gcm_messagebytes_max(void); size_t crypto_aead_aes256gcm_messagebytes_max(void);
typedef CRYPTO_ALIGN(16) unsigned char crypto_aead_aes256gcm_state[512]; typedef CRYPTO_ALIGN(16) unsigned char crypto_aead_aes256gcm_state[512];
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_aes256gcm_statebytes(void); size_t crypto_aead_aes256gcm_statebytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_aes256gcm_encrypt(unsigned char *c, int crypto_aead_aes256gcm_encrypt(unsigned char *c,
unsigned long long *clen_p, unsigned long long *clen_p,
const unsigned char *m, const unsigned char *m,
unsigned long long mlen, unsigned long long mlen,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *nsec, const unsigned char *nsec,
const unsigned char *npub, const unsigned char *npub,
const unsigned char *k); const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_aes256gcm_decrypt(unsigned char *m, int crypto_aead_aes256gcm_decrypt(unsigned char *m,
unsigned long long *mlen_p, unsigned long long *mlen_p,
unsigned char *nsec, unsigned char *nsec,
const unsigned char *c, const unsigned char *c,
unsigned long long clen, unsigned long long clen,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *npub, const unsigned char *npub,
const unsigned char *k) const unsigned char *k)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_aes256gcm_encrypt_detached(unsigned char *c, int crypto_aead_aes256gcm_encrypt_detached(unsigned char *c,
unsigned char *mac, unsigned char *mac,
unsigned long long *maclen_p, unsigned long long *maclen_p,
const unsigned char *m, const unsigned char *m,
unsigned long long mlen, unsigned long long mlen,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *nsec, const unsigned char *nsec,
const unsigned char *npub, const unsigned char *npub,
const unsigned char *k); const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_aes256gcm_decrypt_detached(unsigned char *m, int crypto_aead_aes256gcm_decrypt_detached(unsigned char *m,
unsigned char *nsec, unsigned char *nsec,
const unsigned char *c, const unsigned char *c,
unsigned long long clen, unsigned long long clen,
const unsigned char *mac, const unsigned char *mac,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *npub, const unsigned char *npub,
const unsigned char *k) const unsigned char *k)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
/* -- Precomputation interface -- */ /* -- Precomputation interface -- */
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_aes256gcm_beforenm(crypto_aead_aes256gcm_state *ctx_, int crypto_aead_aes256gcm_beforenm(crypto_aead_aes256gcm_state *ctx_,
const unsigned char *k); const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_aes256gcm_encrypt_afternm(unsigned char *c, int crypto_aead_aes256gcm_encrypt_afternm(unsigned char *c,
unsigned long long *clen_p, unsigned long long *clen_p,
const unsigned char *m, const unsigned char *m,
unsigned long long mlen, unsigned long long mlen,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *nsec, const unsigned char *nsec,
const unsigned char *npub, const unsigned char *npub,
const crypto_aead_aes256gcm_state *ctx_); const crypto_aead_aes256gcm_state *ctx_);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_aes256gcm_decrypt_afternm(unsigned char *m, int crypto_aead_aes256gcm_decrypt_afternm(unsigned char *m,
unsigned long long *mlen_p, unsigned long long *mlen_p,
unsigned char *nsec, unsigned char *nsec,
const unsigned char *c, const unsigned char *c,
unsigned long long clen, unsigned long long clen,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *npub, const unsigned char *npub,
const crypto_aead_aes256gcm_state *ctx_) const crypto_aead_aes256gcm_state *ctx_)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_aes256gcm_encrypt_detached_afternm(unsigned char *c, int crypto_aead_aes256gcm_encrypt_detached_afternm(unsigned char *c,
unsigned char *mac, unsigned char *mac,
unsigned long long *maclen_p, unsigned long long *maclen_p,
const unsigned char *m, const unsigned char *m,
unsigned long long mlen, unsigned long long mlen,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *nsec, const unsigned char *nsec,
const unsigned char *npub, const unsigned char *npub,
const crypto_aead_aes256gcm_state *ctx_); const crypto_aead_aes256gcm_state *ctx_);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_aes256gcm_decrypt_detached_afternm(unsigned char *m, int crypto_aead_aes256gcm_decrypt_detached_afternm(unsigned char *m,
unsigned char *nsec, unsigned char *nsec,
const unsigned char *c, const unsigned char *c,
unsigned long long clen, unsigned long long clen,
const unsigned char *mac, const unsigned char *mac,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *npub, const unsigned char *npub,
const crypto_aead_aes256gcm_state *ctx_) const crypto_aead_aes256gcm_state *ctx_)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
void crypto_aead_aes256gcm_keygen(unsigned char k[crypto_aead_aes256gcm_KEYBYTES]); void crypto_aead_aes256gcm_keygen(unsigned char k[crypto_aead_aes256gcm_KEYBYTES]);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@@ -1,174 +1,174 @@
#ifndef crypto_aead_chacha20poly1305_H #ifndef crypto_aead_chacha20poly1305_H
#define crypto_aead_chacha20poly1305_H #define crypto_aead_chacha20poly1305_H
#include <stddef.h> #include <stddef.h>
#include "export.h" #include "export.h"
#ifdef __cplusplus #ifdef __cplusplus
# ifdef __GNUC__ # ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wlong-long" # pragma GCC diagnostic ignored "-Wlong-long"
# endif # endif
extern "C" { extern "C" {
#endif #endif
/* -- IETF ChaCha20-Poly1305 construction with a 96-bit nonce and a 32-bit internal counter -- */ /* -- IETF ChaCha20-Poly1305 construction with a 96-bit nonce and a 32-bit internal counter -- */
#define crypto_aead_chacha20poly1305_ietf_KEYBYTES 32U #define crypto_aead_chacha20poly1305_ietf_KEYBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_chacha20poly1305_ietf_keybytes(void); size_t crypto_aead_chacha20poly1305_ietf_keybytes(void);
#define crypto_aead_chacha20poly1305_ietf_NSECBYTES 0U #define crypto_aead_chacha20poly1305_ietf_NSECBYTES 0U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_chacha20poly1305_ietf_nsecbytes(void); size_t crypto_aead_chacha20poly1305_ietf_nsecbytes(void);
#define crypto_aead_chacha20poly1305_ietf_NPUBBYTES 12U #define crypto_aead_chacha20poly1305_ietf_NPUBBYTES 12U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_chacha20poly1305_ietf_npubbytes(void); size_t crypto_aead_chacha20poly1305_ietf_npubbytes(void);
#define crypto_aead_chacha20poly1305_ietf_ABYTES 16U #define crypto_aead_chacha20poly1305_ietf_ABYTES 16U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_chacha20poly1305_ietf_abytes(void); size_t crypto_aead_chacha20poly1305_ietf_abytes(void);
#define crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX \ #define crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX \
SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_chacha20poly1305_ietf_ABYTES, \ SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_chacha20poly1305_ietf_ABYTES, \
(64ULL * (1ULL << 32) - 64ULL) - crypto_aead_chacha20poly1305_ietf_ABYTES) (64ULL * (1ULL << 32) - 64ULL) - crypto_aead_chacha20poly1305_ietf_ABYTES)
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_chacha20poly1305_ietf_messagebytes_max(void); size_t crypto_aead_chacha20poly1305_ietf_messagebytes_max(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_chacha20poly1305_ietf_encrypt(unsigned char *c, int crypto_aead_chacha20poly1305_ietf_encrypt(unsigned char *c,
unsigned long long *clen_p, unsigned long long *clen_p,
const unsigned char *m, const unsigned char *m,
unsigned long long mlen, unsigned long long mlen,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *nsec, const unsigned char *nsec,
const unsigned char *npub, const unsigned char *npub,
const unsigned char *k); const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_chacha20poly1305_ietf_decrypt(unsigned char *m, int crypto_aead_chacha20poly1305_ietf_decrypt(unsigned char *m,
unsigned long long *mlen_p, unsigned long long *mlen_p,
unsigned char *nsec, unsigned char *nsec,
const unsigned char *c, const unsigned char *c,
unsigned long long clen, unsigned long long clen,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *npub, const unsigned char *npub,
const unsigned char *k) const unsigned char *k)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_chacha20poly1305_ietf_encrypt_detached(unsigned char *c, int crypto_aead_chacha20poly1305_ietf_encrypt_detached(unsigned char *c,
unsigned char *mac, unsigned char *mac,
unsigned long long *maclen_p, unsigned long long *maclen_p,
const unsigned char *m, const unsigned char *m,
unsigned long long mlen, unsigned long long mlen,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *nsec, const unsigned char *nsec,
const unsigned char *npub, const unsigned char *npub,
const unsigned char *k); const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_chacha20poly1305_ietf_decrypt_detached(unsigned char *m, int crypto_aead_chacha20poly1305_ietf_decrypt_detached(unsigned char *m,
unsigned char *nsec, unsigned char *nsec,
const unsigned char *c, const unsigned char *c,
unsigned long long clen, unsigned long long clen,
const unsigned char *mac, const unsigned char *mac,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *npub, const unsigned char *npub,
const unsigned char *k) const unsigned char *k)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
void crypto_aead_chacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_chacha20poly1305_ietf_KEYBYTES]); void crypto_aead_chacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_chacha20poly1305_ietf_KEYBYTES]);
/* -- Original ChaCha20-Poly1305 construction with a 64-bit nonce and a 64-bit internal counter -- */ /* -- Original ChaCha20-Poly1305 construction with a 64-bit nonce and a 64-bit internal counter -- */
#define crypto_aead_chacha20poly1305_KEYBYTES 32U #define crypto_aead_chacha20poly1305_KEYBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_chacha20poly1305_keybytes(void); size_t crypto_aead_chacha20poly1305_keybytes(void);
#define crypto_aead_chacha20poly1305_NSECBYTES 0U #define crypto_aead_chacha20poly1305_NSECBYTES 0U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_chacha20poly1305_nsecbytes(void); size_t crypto_aead_chacha20poly1305_nsecbytes(void);
#define crypto_aead_chacha20poly1305_NPUBBYTES 8U #define crypto_aead_chacha20poly1305_NPUBBYTES 8U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_chacha20poly1305_npubbytes(void); size_t crypto_aead_chacha20poly1305_npubbytes(void);
#define crypto_aead_chacha20poly1305_ABYTES 16U #define crypto_aead_chacha20poly1305_ABYTES 16U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_chacha20poly1305_abytes(void); size_t crypto_aead_chacha20poly1305_abytes(void);
#define crypto_aead_chacha20poly1305_MESSAGEBYTES_MAX \ #define crypto_aead_chacha20poly1305_MESSAGEBYTES_MAX \
(SODIUM_SIZE_MAX - crypto_aead_chacha20poly1305_ABYTES) (SODIUM_SIZE_MAX - crypto_aead_chacha20poly1305_ABYTES)
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_chacha20poly1305_messagebytes_max(void); size_t crypto_aead_chacha20poly1305_messagebytes_max(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_chacha20poly1305_encrypt(unsigned char *c, int crypto_aead_chacha20poly1305_encrypt(unsigned char *c,
unsigned long long *clen_p, unsigned long long *clen_p,
const unsigned char *m, const unsigned char *m,
unsigned long long mlen, unsigned long long mlen,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *nsec, const unsigned char *nsec,
const unsigned char *npub, const unsigned char *npub,
const unsigned char *k); const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_chacha20poly1305_decrypt(unsigned char *m, int crypto_aead_chacha20poly1305_decrypt(unsigned char *m,
unsigned long long *mlen_p, unsigned long long *mlen_p,
unsigned char *nsec, unsigned char *nsec,
const unsigned char *c, const unsigned char *c,
unsigned long long clen, unsigned long long clen,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *npub, const unsigned char *npub,
const unsigned char *k) const unsigned char *k)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_chacha20poly1305_encrypt_detached(unsigned char *c, int crypto_aead_chacha20poly1305_encrypt_detached(unsigned char *c,
unsigned char *mac, unsigned char *mac,
unsigned long long *maclen_p, unsigned long long *maclen_p,
const unsigned char *m, const unsigned char *m,
unsigned long long mlen, unsigned long long mlen,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *nsec, const unsigned char *nsec,
const unsigned char *npub, const unsigned char *npub,
const unsigned char *k); const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_chacha20poly1305_decrypt_detached(unsigned char *m, int crypto_aead_chacha20poly1305_decrypt_detached(unsigned char *m,
unsigned char *nsec, unsigned char *nsec,
const unsigned char *c, const unsigned char *c,
unsigned long long clen, unsigned long long clen,
const unsigned char *mac, const unsigned char *mac,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *npub, const unsigned char *npub,
const unsigned char *k) const unsigned char *k)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
void crypto_aead_chacha20poly1305_keygen(unsigned char k[crypto_aead_chacha20poly1305_KEYBYTES]); void crypto_aead_chacha20poly1305_keygen(unsigned char k[crypto_aead_chacha20poly1305_KEYBYTES]);
/* Aliases */ /* Aliases */
#define crypto_aead_chacha20poly1305_IETF_KEYBYTES crypto_aead_chacha20poly1305_ietf_KEYBYTES #define crypto_aead_chacha20poly1305_IETF_KEYBYTES crypto_aead_chacha20poly1305_ietf_KEYBYTES
#define crypto_aead_chacha20poly1305_IETF_NSECBYTES crypto_aead_chacha20poly1305_ietf_NSECBYTES #define crypto_aead_chacha20poly1305_IETF_NSECBYTES crypto_aead_chacha20poly1305_ietf_NSECBYTES
#define crypto_aead_chacha20poly1305_IETF_NPUBBYTES crypto_aead_chacha20poly1305_ietf_NPUBBYTES #define crypto_aead_chacha20poly1305_IETF_NPUBBYTES crypto_aead_chacha20poly1305_ietf_NPUBBYTES
#define crypto_aead_chacha20poly1305_IETF_ABYTES crypto_aead_chacha20poly1305_ietf_ABYTES #define crypto_aead_chacha20poly1305_IETF_ABYTES crypto_aead_chacha20poly1305_ietf_ABYTES
#define crypto_aead_chacha20poly1305_IETF_MESSAGEBYTES_MAX crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX #define crypto_aead_chacha20poly1305_IETF_MESSAGEBYTES_MAX crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@@ -1,97 +1,97 @@
#ifndef crypto_aead_xchacha20poly1305_H #ifndef crypto_aead_xchacha20poly1305_H
#define crypto_aead_xchacha20poly1305_H #define crypto_aead_xchacha20poly1305_H
#include <stddef.h> #include <stddef.h>
#include "export.h" #include "export.h"
#ifdef __cplusplus #ifdef __cplusplus
# ifdef __GNUC__ # ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wlong-long" # pragma GCC diagnostic ignored "-Wlong-long"
# endif # endif
extern "C" { extern "C" {
#endif #endif
#define crypto_aead_xchacha20poly1305_ietf_KEYBYTES 32U #define crypto_aead_xchacha20poly1305_ietf_KEYBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_xchacha20poly1305_ietf_keybytes(void); size_t crypto_aead_xchacha20poly1305_ietf_keybytes(void);
#define crypto_aead_xchacha20poly1305_ietf_NSECBYTES 0U #define crypto_aead_xchacha20poly1305_ietf_NSECBYTES 0U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_xchacha20poly1305_ietf_nsecbytes(void); size_t crypto_aead_xchacha20poly1305_ietf_nsecbytes(void);
#define crypto_aead_xchacha20poly1305_ietf_NPUBBYTES 24U #define crypto_aead_xchacha20poly1305_ietf_NPUBBYTES 24U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_xchacha20poly1305_ietf_npubbytes(void); size_t crypto_aead_xchacha20poly1305_ietf_npubbytes(void);
#define crypto_aead_xchacha20poly1305_ietf_ABYTES 16U #define crypto_aead_xchacha20poly1305_ietf_ABYTES 16U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_xchacha20poly1305_ietf_abytes(void); size_t crypto_aead_xchacha20poly1305_ietf_abytes(void);
#define crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX \ #define crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX \
(SODIUM_SIZE_MAX - crypto_aead_xchacha20poly1305_ietf_ABYTES) (SODIUM_SIZE_MAX - crypto_aead_xchacha20poly1305_ietf_ABYTES)
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_xchacha20poly1305_ietf_messagebytes_max(void); size_t crypto_aead_xchacha20poly1305_ietf_messagebytes_max(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_xchacha20poly1305_ietf_encrypt(unsigned char *c, int crypto_aead_xchacha20poly1305_ietf_encrypt(unsigned char *c,
unsigned long long *clen_p, unsigned long long *clen_p,
const unsigned char *m, const unsigned char *m,
unsigned long long mlen, unsigned long long mlen,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *nsec, const unsigned char *nsec,
const unsigned char *npub, const unsigned char *npub,
const unsigned char *k); const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_xchacha20poly1305_ietf_decrypt(unsigned char *m, int crypto_aead_xchacha20poly1305_ietf_decrypt(unsigned char *m,
unsigned long long *mlen_p, unsigned long long *mlen_p,
unsigned char *nsec, unsigned char *nsec,
const unsigned char *c, const unsigned char *c,
unsigned long long clen, unsigned long long clen,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *npub, const unsigned char *npub,
const unsigned char *k) const unsigned char *k)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_xchacha20poly1305_ietf_encrypt_detached(unsigned char *c, int crypto_aead_xchacha20poly1305_ietf_encrypt_detached(unsigned char *c,
unsigned char *mac, unsigned char *mac,
unsigned long long *maclen_p, unsigned long long *maclen_p,
const unsigned char *m, const unsigned char *m,
unsigned long long mlen, unsigned long long mlen,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *nsec, const unsigned char *nsec,
const unsigned char *npub, const unsigned char *npub,
const unsigned char *k); const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_xchacha20poly1305_ietf_decrypt_detached(unsigned char *m, int crypto_aead_xchacha20poly1305_ietf_decrypt_detached(unsigned char *m,
unsigned char *nsec, unsigned char *nsec,
const unsigned char *c, const unsigned char *c,
unsigned long long clen, unsigned long long clen,
const unsigned char *mac, const unsigned char *mac,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *npub, const unsigned char *npub,
const unsigned char *k) const unsigned char *k)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
void crypto_aead_xchacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_xchacha20poly1305_ietf_KEYBYTES]); void crypto_aead_xchacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_xchacha20poly1305_ietf_KEYBYTES]);
/* Aliases */ /* Aliases */
#define crypto_aead_xchacha20poly1305_IETF_KEYBYTES crypto_aead_xchacha20poly1305_ietf_KEYBYTES #define crypto_aead_xchacha20poly1305_IETF_KEYBYTES crypto_aead_xchacha20poly1305_ietf_KEYBYTES
#define crypto_aead_xchacha20poly1305_IETF_NSECBYTES crypto_aead_xchacha20poly1305_ietf_NSECBYTES #define crypto_aead_xchacha20poly1305_IETF_NSECBYTES crypto_aead_xchacha20poly1305_ietf_NSECBYTES
#define crypto_aead_xchacha20poly1305_IETF_NPUBBYTES crypto_aead_xchacha20poly1305_ietf_NPUBBYTES #define crypto_aead_xchacha20poly1305_IETF_NPUBBYTES crypto_aead_xchacha20poly1305_ietf_NPUBBYTES
#define crypto_aead_xchacha20poly1305_IETF_ABYTES crypto_aead_xchacha20poly1305_ietf_ABYTES #define crypto_aead_xchacha20poly1305_IETF_ABYTES crypto_aead_xchacha20poly1305_ietf_ABYTES
#define crypto_aead_xchacha20poly1305_IETF_MESSAGEBYTES_MAX crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX #define crypto_aead_xchacha20poly1305_IETF_MESSAGEBYTES_MAX crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@@ -1,44 +1,44 @@
#ifndef crypto_auth_H #ifndef crypto_auth_H
#define crypto_auth_H #define crypto_auth_H
#include <stddef.h> #include <stddef.h>
#include "crypto_auth_hmacsha512256.h" #include "crypto_auth_hmacsha512256.h"
#include "export.h" #include "export.h"
#ifdef __cplusplus #ifdef __cplusplus
# ifdef __GNUC__ # ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wlong-long" # pragma GCC diagnostic ignored "-Wlong-long"
# endif # endif
extern "C" { extern "C" {
#endif #endif
#define crypto_auth_BYTES crypto_auth_hmacsha512256_BYTES #define crypto_auth_BYTES crypto_auth_hmacsha512256_BYTES
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_auth_bytes(void); size_t crypto_auth_bytes(void);
#define crypto_auth_KEYBYTES crypto_auth_hmacsha512256_KEYBYTES #define crypto_auth_KEYBYTES crypto_auth_hmacsha512256_KEYBYTES
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_auth_keybytes(void); size_t crypto_auth_keybytes(void);
#define crypto_auth_PRIMITIVE "hmacsha512256" #define crypto_auth_PRIMITIVE "hmacsha512256"
SODIUM_EXPORT SODIUM_EXPORT
const char *crypto_auth_primitive(void); const char *crypto_auth_primitive(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_auth(unsigned char *out, const unsigned char *in, int crypto_auth(unsigned char *out, const unsigned char *in,
unsigned long long inlen, const unsigned char *k); unsigned long long inlen, const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_auth_verify(const unsigned char *h, const unsigned char *in, int crypto_auth_verify(const unsigned char *h, const unsigned char *in,
unsigned long long inlen, const unsigned char *k) unsigned long long inlen, const unsigned char *k)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
void crypto_auth_keygen(unsigned char k[crypto_auth_KEYBYTES]); void crypto_auth_keygen(unsigned char k[crypto_auth_KEYBYTES]);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@@ -1,68 +1,68 @@
#ifndef crypto_auth_hmacsha256_H #ifndef crypto_auth_hmacsha256_H
#define crypto_auth_hmacsha256_H #define crypto_auth_hmacsha256_H
#include <stddef.h> #include <stddef.h>
#include "crypto_hash_sha256.h" #include "crypto_hash_sha256.h"
#include "export.h" #include "export.h"
#ifdef __cplusplus #ifdef __cplusplus
# ifdef __GNUC__ # ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wlong-long" # pragma GCC diagnostic ignored "-Wlong-long"
# endif # endif
extern "C" { extern "C" {
#endif #endif
#define crypto_auth_hmacsha256_BYTES 32U #define crypto_auth_hmacsha256_BYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_auth_hmacsha256_bytes(void); size_t crypto_auth_hmacsha256_bytes(void);
#define crypto_auth_hmacsha256_KEYBYTES 32U #define crypto_auth_hmacsha256_KEYBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_auth_hmacsha256_keybytes(void); size_t crypto_auth_hmacsha256_keybytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_auth_hmacsha256(unsigned char *out, int crypto_auth_hmacsha256(unsigned char *out,
const unsigned char *in, const unsigned char *in,
unsigned long long inlen, unsigned long long inlen,
const unsigned char *k); const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_auth_hmacsha256_verify(const unsigned char *h, int crypto_auth_hmacsha256_verify(const unsigned char *h,
const unsigned char *in, const unsigned char *in,
unsigned long long inlen, unsigned long long inlen,
const unsigned char *k) const unsigned char *k)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
typedef struct crypto_auth_hmacsha256_state { typedef struct crypto_auth_hmacsha256_state {
crypto_hash_sha256_state ictx; crypto_hash_sha256_state ictx;
crypto_hash_sha256_state octx; crypto_hash_sha256_state octx;
} crypto_auth_hmacsha256_state; } crypto_auth_hmacsha256_state;
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_auth_hmacsha256_statebytes(void); size_t crypto_auth_hmacsha256_statebytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_auth_hmacsha256_init(crypto_auth_hmacsha256_state *state, int crypto_auth_hmacsha256_init(crypto_auth_hmacsha256_state *state,
const unsigned char *key, const unsigned char *key,
size_t keylen); size_t keylen);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_auth_hmacsha256_update(crypto_auth_hmacsha256_state *state, int crypto_auth_hmacsha256_update(crypto_auth_hmacsha256_state *state,
const unsigned char *in, const unsigned char *in,
unsigned long long inlen); unsigned long long inlen);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_auth_hmacsha256_final(crypto_auth_hmacsha256_state *state, int crypto_auth_hmacsha256_final(crypto_auth_hmacsha256_state *state,
unsigned char *out); unsigned char *out);
SODIUM_EXPORT SODIUM_EXPORT
void crypto_auth_hmacsha256_keygen(unsigned char k[crypto_auth_hmacsha256_KEYBYTES]); void crypto_auth_hmacsha256_keygen(unsigned char k[crypto_auth_hmacsha256_KEYBYTES]);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@@ -1,67 +1,67 @@
#ifndef crypto_auth_hmacsha512_H #ifndef crypto_auth_hmacsha512_H
#define crypto_auth_hmacsha512_H #define crypto_auth_hmacsha512_H
#include <stddef.h> #include <stddef.h>
#include "crypto_hash_sha512.h" #include "crypto_hash_sha512.h"
#include "export.h" #include "export.h"
#ifdef __cplusplus #ifdef __cplusplus
# ifdef __GNUC__ # ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wlong-long" # pragma GCC diagnostic ignored "-Wlong-long"
# endif # endif
extern "C" { extern "C" {
#endif #endif
#define crypto_auth_hmacsha512_BYTES 64U #define crypto_auth_hmacsha512_BYTES 64U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_auth_hmacsha512_bytes(void); size_t crypto_auth_hmacsha512_bytes(void);
#define crypto_auth_hmacsha512_KEYBYTES 32U #define crypto_auth_hmacsha512_KEYBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_auth_hmacsha512_keybytes(void); size_t crypto_auth_hmacsha512_keybytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_auth_hmacsha512(unsigned char *out, int crypto_auth_hmacsha512(unsigned char *out,
const unsigned char *in, const unsigned char *in,
unsigned long long inlen, unsigned long long inlen,
const unsigned char *k); const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_auth_hmacsha512_verify(const unsigned char *h, int crypto_auth_hmacsha512_verify(const unsigned char *h,
const unsigned char *in, const unsigned char *in,
unsigned long long inlen, unsigned long long inlen,
const unsigned char *k) const unsigned char *k)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
typedef struct crypto_auth_hmacsha512_state { typedef struct crypto_auth_hmacsha512_state {
crypto_hash_sha512_state ictx; crypto_hash_sha512_state ictx;
crypto_hash_sha512_state octx; crypto_hash_sha512_state octx;
} crypto_auth_hmacsha512_state; } crypto_auth_hmacsha512_state;
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_auth_hmacsha512_statebytes(void); size_t crypto_auth_hmacsha512_statebytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_auth_hmacsha512_init(crypto_auth_hmacsha512_state *state, int crypto_auth_hmacsha512_init(crypto_auth_hmacsha512_state *state,
const unsigned char *key, const unsigned char *key,
size_t keylen); size_t keylen);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_auth_hmacsha512_update(crypto_auth_hmacsha512_state *state, int crypto_auth_hmacsha512_update(crypto_auth_hmacsha512_state *state,
const unsigned char *in, const unsigned char *in,
unsigned long long inlen); unsigned long long inlen);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_auth_hmacsha512_final(crypto_auth_hmacsha512_state *state, int crypto_auth_hmacsha512_final(crypto_auth_hmacsha512_state *state,
unsigned char *out); unsigned char *out);
SODIUM_EXPORT SODIUM_EXPORT
void crypto_auth_hmacsha512_keygen(unsigned char k[crypto_auth_hmacsha512_KEYBYTES]); void crypto_auth_hmacsha512_keygen(unsigned char k[crypto_auth_hmacsha512_KEYBYTES]);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@@ -1,62 +1,62 @@
#ifndef crypto_auth_hmacsha512256_H #ifndef crypto_auth_hmacsha512256_H
#define crypto_auth_hmacsha512256_H #define crypto_auth_hmacsha512256_H
#include <stddef.h> #include <stddef.h>
#include "crypto_auth_hmacsha512.h" #include "crypto_auth_hmacsha512.h"
#include "export.h" #include "export.h"
#ifdef __cplusplus #ifdef __cplusplus
# ifdef __GNUC__ # ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wlong-long" # pragma GCC diagnostic ignored "-Wlong-long"
# endif # endif
extern "C" { extern "C" {
#endif #endif
#define crypto_auth_hmacsha512256_BYTES 32U #define crypto_auth_hmacsha512256_BYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_auth_hmacsha512256_bytes(void); size_t crypto_auth_hmacsha512256_bytes(void);
#define crypto_auth_hmacsha512256_KEYBYTES 32U #define crypto_auth_hmacsha512256_KEYBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_auth_hmacsha512256_keybytes(void); size_t crypto_auth_hmacsha512256_keybytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_auth_hmacsha512256(unsigned char *out, const unsigned char *in, int crypto_auth_hmacsha512256(unsigned char *out, const unsigned char *in,
unsigned long long inlen,const unsigned char *k); unsigned long long inlen,const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_auth_hmacsha512256_verify(const unsigned char *h, int crypto_auth_hmacsha512256_verify(const unsigned char *h,
const unsigned char *in, const unsigned char *in,
unsigned long long inlen, unsigned long long inlen,
const unsigned char *k) const unsigned char *k)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
typedef crypto_auth_hmacsha512_state crypto_auth_hmacsha512256_state; typedef crypto_auth_hmacsha512_state crypto_auth_hmacsha512256_state;
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_auth_hmacsha512256_statebytes(void); size_t crypto_auth_hmacsha512256_statebytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_auth_hmacsha512256_init(crypto_auth_hmacsha512256_state *state, int crypto_auth_hmacsha512256_init(crypto_auth_hmacsha512256_state *state,
const unsigned char *key, const unsigned char *key,
size_t keylen); size_t keylen);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_auth_hmacsha512256_update(crypto_auth_hmacsha512256_state *state, int crypto_auth_hmacsha512256_update(crypto_auth_hmacsha512256_state *state,
const unsigned char *in, const unsigned char *in,
unsigned long long inlen); unsigned long long inlen);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_auth_hmacsha512256_final(crypto_auth_hmacsha512256_state *state, int crypto_auth_hmacsha512256_final(crypto_auth_hmacsha512256_state *state,
unsigned char *out); unsigned char *out);
SODIUM_EXPORT SODIUM_EXPORT
void crypto_auth_hmacsha512256_keygen(unsigned char k[crypto_auth_hmacsha512256_KEYBYTES]); void crypto_auth_hmacsha512256_keygen(unsigned char k[crypto_auth_hmacsha512256_KEYBYTES]);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@@ -1,173 +1,173 @@
#ifndef crypto_box_H #ifndef crypto_box_H
#define crypto_box_H #define crypto_box_H
/* /*
* THREAD SAFETY: crypto_box_keypair() is thread-safe, * THREAD SAFETY: crypto_box_keypair() is thread-safe,
* provided that sodium_init() was called before. * provided that sodium_init() was called before.
* *
* Other functions are always thread-safe. * Other functions are always thread-safe.
*/ */
#include <stddef.h> #include <stddef.h>
#include "crypto_box_curve25519xsalsa20poly1305.h" #include "crypto_box_curve25519xsalsa20poly1305.h"
#include "export.h" #include "export.h"
#ifdef __cplusplus #ifdef __cplusplus
# ifdef __GNUC__ # ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wlong-long" # pragma GCC diagnostic ignored "-Wlong-long"
# endif # endif
extern "C" { extern "C" {
#endif #endif
#define crypto_box_SEEDBYTES crypto_box_curve25519xsalsa20poly1305_SEEDBYTES #define crypto_box_SEEDBYTES crypto_box_curve25519xsalsa20poly1305_SEEDBYTES
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_seedbytes(void); size_t crypto_box_seedbytes(void);
#define crypto_box_PUBLICKEYBYTES crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES #define crypto_box_PUBLICKEYBYTES crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_publickeybytes(void); size_t crypto_box_publickeybytes(void);
#define crypto_box_SECRETKEYBYTES crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES #define crypto_box_SECRETKEYBYTES crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_secretkeybytes(void); size_t crypto_box_secretkeybytes(void);
#define crypto_box_NONCEBYTES crypto_box_curve25519xsalsa20poly1305_NONCEBYTES #define crypto_box_NONCEBYTES crypto_box_curve25519xsalsa20poly1305_NONCEBYTES
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_noncebytes(void); size_t crypto_box_noncebytes(void);
#define crypto_box_MACBYTES crypto_box_curve25519xsalsa20poly1305_MACBYTES #define crypto_box_MACBYTES crypto_box_curve25519xsalsa20poly1305_MACBYTES
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_macbytes(void); size_t crypto_box_macbytes(void);
#define crypto_box_MESSAGEBYTES_MAX crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX #define crypto_box_MESSAGEBYTES_MAX crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_messagebytes_max(void); size_t crypto_box_messagebytes_max(void);
#define crypto_box_PRIMITIVE "curve25519xsalsa20poly1305" #define crypto_box_PRIMITIVE "curve25519xsalsa20poly1305"
SODIUM_EXPORT SODIUM_EXPORT
const char *crypto_box_primitive(void); const char *crypto_box_primitive(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_seed_keypair(unsigned char *pk, unsigned char *sk, int crypto_box_seed_keypair(unsigned char *pk, unsigned char *sk,
const unsigned char *seed); const unsigned char *seed);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_keypair(unsigned char *pk, unsigned char *sk); int crypto_box_keypair(unsigned char *pk, unsigned char *sk);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_easy(unsigned char *c, const unsigned char *m, int crypto_box_easy(unsigned char *c, const unsigned char *m,
unsigned long long mlen, const unsigned char *n, unsigned long long mlen, const unsigned char *n,
const unsigned char *pk, const unsigned char *sk) const unsigned char *pk, const unsigned char *sk)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_open_easy(unsigned char *m, const unsigned char *c, int crypto_box_open_easy(unsigned char *m, const unsigned char *c,
unsigned long long clen, const unsigned char *n, unsigned long long clen, const unsigned char *n,
const unsigned char *pk, const unsigned char *sk) const unsigned char *pk, const unsigned char *sk)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_detached(unsigned char *c, unsigned char *mac, int crypto_box_detached(unsigned char *c, unsigned char *mac,
const unsigned char *m, unsigned long long mlen, const unsigned char *m, unsigned long long mlen,
const unsigned char *n, const unsigned char *pk, const unsigned char *n, const unsigned char *pk,
const unsigned char *sk) const unsigned char *sk)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_open_detached(unsigned char *m, const unsigned char *c, int crypto_box_open_detached(unsigned char *m, const unsigned char *c,
const unsigned char *mac, const unsigned char *mac,
unsigned long long clen, unsigned long long clen,
const unsigned char *n, const unsigned char *n,
const unsigned char *pk, const unsigned char *pk,
const unsigned char *sk) const unsigned char *sk)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
/* -- Precomputation interface -- */ /* -- Precomputation interface -- */
#define crypto_box_BEFORENMBYTES crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES #define crypto_box_BEFORENMBYTES crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_beforenmbytes(void); size_t crypto_box_beforenmbytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_beforenm(unsigned char *k, const unsigned char *pk, int crypto_box_beforenm(unsigned char *k, const unsigned char *pk,
const unsigned char *sk) const unsigned char *sk)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_easy_afternm(unsigned char *c, const unsigned char *m, int crypto_box_easy_afternm(unsigned char *c, const unsigned char *m,
unsigned long long mlen, const unsigned char *n, unsigned long long mlen, const unsigned char *n,
const unsigned char *k); const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_open_easy_afternm(unsigned char *m, const unsigned char *c, int crypto_box_open_easy_afternm(unsigned char *m, const unsigned char *c,
unsigned long long clen, const unsigned char *n, unsigned long long clen, const unsigned char *n,
const unsigned char *k) const unsigned char *k)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_detached_afternm(unsigned char *c, unsigned char *mac, int crypto_box_detached_afternm(unsigned char *c, unsigned char *mac,
const unsigned char *m, unsigned long long mlen, const unsigned char *m, unsigned long long mlen,
const unsigned char *n, const unsigned char *k); const unsigned char *n, const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_open_detached_afternm(unsigned char *m, const unsigned char *c, int crypto_box_open_detached_afternm(unsigned char *m, const unsigned char *c,
const unsigned char *mac, const unsigned char *mac,
unsigned long long clen, const unsigned char *n, unsigned long long clen, const unsigned char *n,
const unsigned char *k) const unsigned char *k)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
/* -- Ephemeral SK interface -- */ /* -- Ephemeral SK interface -- */
#define crypto_box_SEALBYTES (crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES) #define crypto_box_SEALBYTES (crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES)
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_sealbytes(void); size_t crypto_box_sealbytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_seal(unsigned char *c, const unsigned char *m, int crypto_box_seal(unsigned char *c, const unsigned char *m,
unsigned long long mlen, const unsigned char *pk); unsigned long long mlen, const unsigned char *pk);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_seal_open(unsigned char *m, const unsigned char *c, int crypto_box_seal_open(unsigned char *m, const unsigned char *c,
unsigned long long clen, unsigned long long clen,
const unsigned char *pk, const unsigned char *sk) const unsigned char *pk, const unsigned char *sk)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
/* -- NaCl compatibility interface ; Requires padding -- */ /* -- NaCl compatibility interface ; Requires padding -- */
#define crypto_box_ZEROBYTES crypto_box_curve25519xsalsa20poly1305_ZEROBYTES #define crypto_box_ZEROBYTES crypto_box_curve25519xsalsa20poly1305_ZEROBYTES
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_zerobytes(void); size_t crypto_box_zerobytes(void);
#define crypto_box_BOXZEROBYTES crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES #define crypto_box_BOXZEROBYTES crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_boxzerobytes(void); size_t crypto_box_boxzerobytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box(unsigned char *c, const unsigned char *m, int crypto_box(unsigned char *c, const unsigned char *m,
unsigned long long mlen, const unsigned char *n, unsigned long long mlen, const unsigned char *n,
const unsigned char *pk, const unsigned char *sk) const unsigned char *pk, const unsigned char *sk)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_open(unsigned char *m, const unsigned char *c, int crypto_box_open(unsigned char *m, const unsigned char *c,
unsigned long long clen, const unsigned char *n, unsigned long long clen, const unsigned char *n,
const unsigned char *pk, const unsigned char *sk) const unsigned char *pk, const unsigned char *sk)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_afternm(unsigned char *c, const unsigned char *m, int crypto_box_afternm(unsigned char *c, const unsigned char *m,
unsigned long long mlen, const unsigned char *n, unsigned long long mlen, const unsigned char *n,
const unsigned char *k); const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_open_afternm(unsigned char *m, const unsigned char *c, int crypto_box_open_afternm(unsigned char *m, const unsigned char *c,
unsigned long long clen, const unsigned char *n, unsigned long long clen, const unsigned char *n,
const unsigned char *k) const unsigned char *k)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@@ -1,159 +1,159 @@
#ifndef crypto_box_curve25519xchacha20poly1305_H #ifndef crypto_box_curve25519xchacha20poly1305_H
#define crypto_box_curve25519xchacha20poly1305_H #define crypto_box_curve25519xchacha20poly1305_H
#include <stddef.h> #include <stddef.h>
#include "crypto_stream_xchacha20.h" #include "crypto_stream_xchacha20.h"
#include "export.h" #include "export.h"
#ifdef __cplusplus #ifdef __cplusplus
# ifdef __GNUC__ # ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wlong-long" # pragma GCC diagnostic ignored "-Wlong-long"
# endif # endif
extern "C" { extern "C" {
#endif #endif
#define crypto_box_curve25519xchacha20poly1305_SEEDBYTES 32U #define crypto_box_curve25519xchacha20poly1305_SEEDBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_curve25519xchacha20poly1305_seedbytes(void); size_t crypto_box_curve25519xchacha20poly1305_seedbytes(void);
#define crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES 32U #define crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_curve25519xchacha20poly1305_publickeybytes(void); size_t crypto_box_curve25519xchacha20poly1305_publickeybytes(void);
#define crypto_box_curve25519xchacha20poly1305_SECRETKEYBYTES 32U #define crypto_box_curve25519xchacha20poly1305_SECRETKEYBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_curve25519xchacha20poly1305_secretkeybytes(void); size_t crypto_box_curve25519xchacha20poly1305_secretkeybytes(void);
#define crypto_box_curve25519xchacha20poly1305_BEFORENMBYTES 32U #define crypto_box_curve25519xchacha20poly1305_BEFORENMBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_curve25519xchacha20poly1305_beforenmbytes(void); size_t crypto_box_curve25519xchacha20poly1305_beforenmbytes(void);
#define crypto_box_curve25519xchacha20poly1305_NONCEBYTES 24U #define crypto_box_curve25519xchacha20poly1305_NONCEBYTES 24U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_curve25519xchacha20poly1305_noncebytes(void); size_t crypto_box_curve25519xchacha20poly1305_noncebytes(void);
#define crypto_box_curve25519xchacha20poly1305_MACBYTES 16U #define crypto_box_curve25519xchacha20poly1305_MACBYTES 16U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_curve25519xchacha20poly1305_macbytes(void); size_t crypto_box_curve25519xchacha20poly1305_macbytes(void);
#define crypto_box_curve25519xchacha20poly1305_MESSAGEBYTES_MAX \ #define crypto_box_curve25519xchacha20poly1305_MESSAGEBYTES_MAX \
(crypto_stream_xchacha20_MESSAGEBYTES_MAX - crypto_box_curve25519xchacha20poly1305_MACBYTES) (crypto_stream_xchacha20_MESSAGEBYTES_MAX - crypto_box_curve25519xchacha20poly1305_MACBYTES)
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_curve25519xchacha20poly1305_messagebytes_max(void); size_t crypto_box_curve25519xchacha20poly1305_messagebytes_max(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xchacha20poly1305_seed_keypair(unsigned char *pk, int crypto_box_curve25519xchacha20poly1305_seed_keypair(unsigned char *pk,
unsigned char *sk, unsigned char *sk,
const unsigned char *seed); const unsigned char *seed);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xchacha20poly1305_keypair(unsigned char *pk, int crypto_box_curve25519xchacha20poly1305_keypair(unsigned char *pk,
unsigned char *sk); unsigned char *sk);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xchacha20poly1305_easy(unsigned char *c, int crypto_box_curve25519xchacha20poly1305_easy(unsigned char *c,
const unsigned char *m, const unsigned char *m,
unsigned long long mlen, unsigned long long mlen,
const unsigned char *n, const unsigned char *n,
const unsigned char *pk, const unsigned char *pk,
const unsigned char *sk) const unsigned char *sk)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xchacha20poly1305_open_easy(unsigned char *m, int crypto_box_curve25519xchacha20poly1305_open_easy(unsigned char *m,
const unsigned char *c, const unsigned char *c,
unsigned long long clen, unsigned long long clen,
const unsigned char *n, const unsigned char *n,
const unsigned char *pk, const unsigned char *pk,
const unsigned char *sk) const unsigned char *sk)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xchacha20poly1305_detached(unsigned char *c, int crypto_box_curve25519xchacha20poly1305_detached(unsigned char *c,
unsigned char *mac, unsigned char *mac,
const unsigned char *m, const unsigned char *m,
unsigned long long mlen, unsigned long long mlen,
const unsigned char *n, const unsigned char *n,
const unsigned char *pk, const unsigned char *pk,
const unsigned char *sk) const unsigned char *sk)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xchacha20poly1305_open_detached(unsigned char *m, int crypto_box_curve25519xchacha20poly1305_open_detached(unsigned char *m,
const unsigned char *c, const unsigned char *c,
const unsigned char *mac, const unsigned char *mac,
unsigned long long clen, unsigned long long clen,
const unsigned char *n, const unsigned char *n,
const unsigned char *pk, const unsigned char *pk,
const unsigned char *sk) const unsigned char *sk)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
/* -- Precomputation interface -- */ /* -- Precomputation interface -- */
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xchacha20poly1305_beforenm(unsigned char *k, int crypto_box_curve25519xchacha20poly1305_beforenm(unsigned char *k,
const unsigned char *pk, const unsigned char *pk,
const unsigned char *sk) const unsigned char *sk)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xchacha20poly1305_easy_afternm(unsigned char *c, int crypto_box_curve25519xchacha20poly1305_easy_afternm(unsigned char *c,
const unsigned char *m, const unsigned char *m,
unsigned long long mlen, unsigned long long mlen,
const unsigned char *n, const unsigned char *n,
const unsigned char *k); const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xchacha20poly1305_open_easy_afternm(unsigned char *m, int crypto_box_curve25519xchacha20poly1305_open_easy_afternm(unsigned char *m,
const unsigned char *c, const unsigned char *c,
unsigned long long clen, unsigned long long clen,
const unsigned char *n, const unsigned char *n,
const unsigned char *k) const unsigned char *k)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xchacha20poly1305_detached_afternm(unsigned char *c, int crypto_box_curve25519xchacha20poly1305_detached_afternm(unsigned char *c,
unsigned char *mac, unsigned char *mac,
const unsigned char *m, const unsigned char *m,
unsigned long long mlen, unsigned long long mlen,
const unsigned char *n, const unsigned char *n,
const unsigned char *k); const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xchacha20poly1305_open_detached_afternm(unsigned char *m, int crypto_box_curve25519xchacha20poly1305_open_detached_afternm(unsigned char *m,
const unsigned char *c, const unsigned char *c,
const unsigned char *mac, const unsigned char *mac,
unsigned long long clen, unsigned long long clen,
const unsigned char *n, const unsigned char *n,
const unsigned char *k) const unsigned char *k)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
/* -- Ephemeral SK interface -- */ /* -- Ephemeral SK interface -- */
#define crypto_box_curve25519xchacha20poly1305_SEALBYTES \ #define crypto_box_curve25519xchacha20poly1305_SEALBYTES \
(crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES + \ (crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES + \
crypto_box_curve25519xchacha20poly1305_MACBYTES) crypto_box_curve25519xchacha20poly1305_MACBYTES)
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_curve25519xchacha20poly1305_sealbytes(void); size_t crypto_box_curve25519xchacha20poly1305_sealbytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xchacha20poly1305_seal(unsigned char *c, int crypto_box_curve25519xchacha20poly1305_seal(unsigned char *c,
const unsigned char *m, const unsigned char *m,
unsigned long long mlen, unsigned long long mlen,
const unsigned char *pk); const unsigned char *pk);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xchacha20poly1305_seal_open(unsigned char *m, int crypto_box_curve25519xchacha20poly1305_seal_open(unsigned char *m,
const unsigned char *c, const unsigned char *c,
unsigned long long clen, unsigned long long clen,
const unsigned char *pk, const unsigned char *pk,
const unsigned char *sk) const unsigned char *sk)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@@ -1,109 +1,109 @@
#ifndef crypto_box_curve25519xsalsa20poly1305_H #ifndef crypto_box_curve25519xsalsa20poly1305_H
#define crypto_box_curve25519xsalsa20poly1305_H #define crypto_box_curve25519xsalsa20poly1305_H
#include <stddef.h> #include <stddef.h>
#include "crypto_stream_xsalsa20.h" #include "crypto_stream_xsalsa20.h"
#include "export.h" #include "export.h"
#ifdef __cplusplus #ifdef __cplusplus
# ifdef __GNUC__ # ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wlong-long" # pragma GCC diagnostic ignored "-Wlong-long"
# endif # endif
extern "C" { extern "C" {
#endif #endif
#define crypto_box_curve25519xsalsa20poly1305_SEEDBYTES 32U #define crypto_box_curve25519xsalsa20poly1305_SEEDBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_curve25519xsalsa20poly1305_seedbytes(void); size_t crypto_box_curve25519xsalsa20poly1305_seedbytes(void);
#define crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES 32U #define crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_curve25519xsalsa20poly1305_publickeybytes(void); size_t crypto_box_curve25519xsalsa20poly1305_publickeybytes(void);
#define crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES 32U #define crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_curve25519xsalsa20poly1305_secretkeybytes(void); size_t crypto_box_curve25519xsalsa20poly1305_secretkeybytes(void);
#define crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES 32U #define crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_curve25519xsalsa20poly1305_beforenmbytes(void); size_t crypto_box_curve25519xsalsa20poly1305_beforenmbytes(void);
#define crypto_box_curve25519xsalsa20poly1305_NONCEBYTES 24U #define crypto_box_curve25519xsalsa20poly1305_NONCEBYTES 24U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_curve25519xsalsa20poly1305_noncebytes(void); size_t crypto_box_curve25519xsalsa20poly1305_noncebytes(void);
#define crypto_box_curve25519xsalsa20poly1305_MACBYTES 16U #define crypto_box_curve25519xsalsa20poly1305_MACBYTES 16U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_curve25519xsalsa20poly1305_macbytes(void); size_t crypto_box_curve25519xsalsa20poly1305_macbytes(void);
/* Only for the libsodium API - The NaCl compatibility API would require BOXZEROBYTES extra bytes */ /* Only for the libsodium API - The NaCl compatibility API would require BOXZEROBYTES extra bytes */
#define crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX \ #define crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX \
(crypto_stream_xsalsa20_MESSAGEBYTES_MAX - crypto_box_curve25519xsalsa20poly1305_MACBYTES) (crypto_stream_xsalsa20_MESSAGEBYTES_MAX - crypto_box_curve25519xsalsa20poly1305_MACBYTES)
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_curve25519xsalsa20poly1305_messagebytes_max(void); size_t crypto_box_curve25519xsalsa20poly1305_messagebytes_max(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xsalsa20poly1305_seed_keypair(unsigned char *pk, int crypto_box_curve25519xsalsa20poly1305_seed_keypair(unsigned char *pk,
unsigned char *sk, unsigned char *sk,
const unsigned char *seed); const unsigned char *seed);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xsalsa20poly1305_keypair(unsigned char *pk, int crypto_box_curve25519xsalsa20poly1305_keypair(unsigned char *pk,
unsigned char *sk); unsigned char *sk);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xsalsa20poly1305_beforenm(unsigned char *k, int crypto_box_curve25519xsalsa20poly1305_beforenm(unsigned char *k,
const unsigned char *pk, const unsigned char *pk,
const unsigned char *sk) const unsigned char *sk)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
/* -- NaCl compatibility interface ; Requires padding -- */ /* -- NaCl compatibility interface ; Requires padding -- */
#define crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES 16U #define crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES 16U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_curve25519xsalsa20poly1305_boxzerobytes(void); size_t crypto_box_curve25519xsalsa20poly1305_boxzerobytes(void);
#define crypto_box_curve25519xsalsa20poly1305_ZEROBYTES \ #define crypto_box_curve25519xsalsa20poly1305_ZEROBYTES \
(crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES + \ (crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES + \
crypto_box_curve25519xsalsa20poly1305_MACBYTES) crypto_box_curve25519xsalsa20poly1305_MACBYTES)
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_box_curve25519xsalsa20poly1305_zerobytes(void); size_t crypto_box_curve25519xsalsa20poly1305_zerobytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xsalsa20poly1305(unsigned char *c, int crypto_box_curve25519xsalsa20poly1305(unsigned char *c,
const unsigned char *m, const unsigned char *m,
unsigned long long mlen, unsigned long long mlen,
const unsigned char *n, const unsigned char *n,
const unsigned char *pk, const unsigned char *pk,
const unsigned char *sk) const unsigned char *sk)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xsalsa20poly1305_open(unsigned char *m, int crypto_box_curve25519xsalsa20poly1305_open(unsigned char *m,
const unsigned char *c, const unsigned char *c,
unsigned long long clen, unsigned long long clen,
const unsigned char *n, const unsigned char *n,
const unsigned char *pk, const unsigned char *pk,
const unsigned char *sk) const unsigned char *sk)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xsalsa20poly1305_afternm(unsigned char *c, int crypto_box_curve25519xsalsa20poly1305_afternm(unsigned char *c,
const unsigned char *m, const unsigned char *m,
unsigned long long mlen, unsigned long long mlen,
const unsigned char *n, const unsigned char *n,
const unsigned char *k); const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_box_curve25519xsalsa20poly1305_open_afternm(unsigned char *m, int crypto_box_curve25519xsalsa20poly1305_open_afternm(unsigned char *m,
const unsigned char *c, const unsigned char *c,
unsigned long long clen, unsigned long long clen,
const unsigned char *n, const unsigned char *n,
const unsigned char *k) const unsigned char *k)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@@ -1,37 +1,37 @@
#ifndef crypto_core_ed25519_H #ifndef crypto_core_ed25519_H
#define crypto_core_ed25519_H #define crypto_core_ed25519_H
#include <stddef.h> #include <stddef.h>
#include "export.h" #include "export.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define crypto_core_ed25519_BYTES 32 #define crypto_core_ed25519_BYTES 32
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_ed25519_bytes(void); size_t crypto_core_ed25519_bytes(void);
#define crypto_core_ed25519_UNIFORMBYTES 32 #define crypto_core_ed25519_UNIFORMBYTES 32
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_ed25519_uniformbytes(void); size_t crypto_core_ed25519_uniformbytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_core_ed25519_is_valid_point(const unsigned char *p); int crypto_core_ed25519_is_valid_point(const unsigned char *p);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_core_ed25519_add(unsigned char *r, int crypto_core_ed25519_add(unsigned char *r,
const unsigned char *p, const unsigned char *q); const unsigned char *p, const unsigned char *q);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_core_ed25519_sub(unsigned char *r, int crypto_core_ed25519_sub(unsigned char *r,
const unsigned char *p, const unsigned char *q); const unsigned char *p, const unsigned char *q);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_core_ed25519_from_uniform(unsigned char *p, const unsigned char *r); int crypto_core_ed25519_from_uniform(unsigned char *p, const unsigned char *r);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@@ -1,35 +1,35 @@
#ifndef crypto_core_hchacha20_H #ifndef crypto_core_hchacha20_H
#define crypto_core_hchacha20_H #define crypto_core_hchacha20_H
#include <stddef.h> #include <stddef.h>
#include "export.h" #include "export.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define crypto_core_hchacha20_OUTPUTBYTES 32U #define crypto_core_hchacha20_OUTPUTBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_hchacha20_outputbytes(void); size_t crypto_core_hchacha20_outputbytes(void);
#define crypto_core_hchacha20_INPUTBYTES 16U #define crypto_core_hchacha20_INPUTBYTES 16U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_hchacha20_inputbytes(void); size_t crypto_core_hchacha20_inputbytes(void);
#define crypto_core_hchacha20_KEYBYTES 32U #define crypto_core_hchacha20_KEYBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_hchacha20_keybytes(void); size_t crypto_core_hchacha20_keybytes(void);
#define crypto_core_hchacha20_CONSTBYTES 16U #define crypto_core_hchacha20_CONSTBYTES 16U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_hchacha20_constbytes(void); size_t crypto_core_hchacha20_constbytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_core_hchacha20(unsigned char *out, const unsigned char *in, int crypto_core_hchacha20(unsigned char *out, const unsigned char *in,
const unsigned char *k, const unsigned char *c); const unsigned char *k, const unsigned char *c);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@@ -1,35 +1,35 @@
#ifndef crypto_core_hsalsa20_H #ifndef crypto_core_hsalsa20_H
#define crypto_core_hsalsa20_H #define crypto_core_hsalsa20_H
#include <stddef.h> #include <stddef.h>
#include "export.h" #include "export.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define crypto_core_hsalsa20_OUTPUTBYTES 32U #define crypto_core_hsalsa20_OUTPUTBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_hsalsa20_outputbytes(void); size_t crypto_core_hsalsa20_outputbytes(void);
#define crypto_core_hsalsa20_INPUTBYTES 16U #define crypto_core_hsalsa20_INPUTBYTES 16U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_hsalsa20_inputbytes(void); size_t crypto_core_hsalsa20_inputbytes(void);
#define crypto_core_hsalsa20_KEYBYTES 32U #define crypto_core_hsalsa20_KEYBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_hsalsa20_keybytes(void); size_t crypto_core_hsalsa20_keybytes(void);
#define crypto_core_hsalsa20_CONSTBYTES 16U #define crypto_core_hsalsa20_CONSTBYTES 16U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_hsalsa20_constbytes(void); size_t crypto_core_hsalsa20_constbytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_core_hsalsa20(unsigned char *out, const unsigned char *in, int crypto_core_hsalsa20(unsigned char *out, const unsigned char *in,
const unsigned char *k, const unsigned char *c); const unsigned char *k, const unsigned char *c);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@@ -1,35 +1,35 @@
#ifndef crypto_core_salsa20_H #ifndef crypto_core_salsa20_H
#define crypto_core_salsa20_H #define crypto_core_salsa20_H
#include <stddef.h> #include <stddef.h>
#include "export.h" #include "export.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define crypto_core_salsa20_OUTPUTBYTES 64U #define crypto_core_salsa20_OUTPUTBYTES 64U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_salsa20_outputbytes(void); size_t crypto_core_salsa20_outputbytes(void);
#define crypto_core_salsa20_INPUTBYTES 16U #define crypto_core_salsa20_INPUTBYTES 16U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_salsa20_inputbytes(void); size_t crypto_core_salsa20_inputbytes(void);
#define crypto_core_salsa20_KEYBYTES 32U #define crypto_core_salsa20_KEYBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_salsa20_keybytes(void); size_t crypto_core_salsa20_keybytes(void);
#define crypto_core_salsa20_CONSTBYTES 16U #define crypto_core_salsa20_CONSTBYTES 16U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_salsa20_constbytes(void); size_t crypto_core_salsa20_constbytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_core_salsa20(unsigned char *out, const unsigned char *in, int crypto_core_salsa20(unsigned char *out, const unsigned char *in,
const unsigned char *k, const unsigned char *c); const unsigned char *k, const unsigned char *c);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@@ -1,35 +1,35 @@
#ifndef crypto_core_salsa2012_H #ifndef crypto_core_salsa2012_H
#define crypto_core_salsa2012_H #define crypto_core_salsa2012_H
#include <stddef.h> #include <stddef.h>
#include "export.h" #include "export.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define crypto_core_salsa2012_OUTPUTBYTES 64U #define crypto_core_salsa2012_OUTPUTBYTES 64U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_salsa2012_outputbytes(void); size_t crypto_core_salsa2012_outputbytes(void);
#define crypto_core_salsa2012_INPUTBYTES 16U #define crypto_core_salsa2012_INPUTBYTES 16U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_salsa2012_inputbytes(void); size_t crypto_core_salsa2012_inputbytes(void);
#define crypto_core_salsa2012_KEYBYTES 32U #define crypto_core_salsa2012_KEYBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_salsa2012_keybytes(void); size_t crypto_core_salsa2012_keybytes(void);
#define crypto_core_salsa2012_CONSTBYTES 16U #define crypto_core_salsa2012_CONSTBYTES 16U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_salsa2012_constbytes(void); size_t crypto_core_salsa2012_constbytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_core_salsa2012(unsigned char *out, const unsigned char *in, int crypto_core_salsa2012(unsigned char *out, const unsigned char *in,
const unsigned char *k, const unsigned char *c); const unsigned char *k, const unsigned char *c);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@@ -1,39 +1,39 @@
#ifndef crypto_core_salsa208_H #ifndef crypto_core_salsa208_H
#define crypto_core_salsa208_H #define crypto_core_salsa208_H
#include <stddef.h> #include <stddef.h>
#include "export.h" #include "export.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define crypto_core_salsa208_OUTPUTBYTES 64U #define crypto_core_salsa208_OUTPUTBYTES 64U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_salsa208_outputbytes(void) size_t crypto_core_salsa208_outputbytes(void)
__attribute__ ((deprecated)); __attribute__ ((deprecated));
#define crypto_core_salsa208_INPUTBYTES 16U #define crypto_core_salsa208_INPUTBYTES 16U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_salsa208_inputbytes(void) size_t crypto_core_salsa208_inputbytes(void)
__attribute__ ((deprecated)); __attribute__ ((deprecated));
#define crypto_core_salsa208_KEYBYTES 32U #define crypto_core_salsa208_KEYBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_salsa208_keybytes(void) size_t crypto_core_salsa208_keybytes(void)
__attribute__ ((deprecated)); __attribute__ ((deprecated));
#define crypto_core_salsa208_CONSTBYTES 16U #define crypto_core_salsa208_CONSTBYTES 16U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_salsa208_constbytes(void) size_t crypto_core_salsa208_constbytes(void)
__attribute__ ((deprecated)); __attribute__ ((deprecated));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_core_salsa208(unsigned char *out, const unsigned char *in, int crypto_core_salsa208(unsigned char *out, const unsigned char *in,
const unsigned char *k, const unsigned char *c); const unsigned char *k, const unsigned char *c);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@@ -1,75 +1,75 @@
#ifndef crypto_generichash_H #ifndef crypto_generichash_H
#define crypto_generichash_H #define crypto_generichash_H
#include <stddef.h> #include <stddef.h>
#include "crypto_generichash_blake2b.h" #include "crypto_generichash_blake2b.h"
#include "export.h" #include "export.h"
#ifdef __cplusplus #ifdef __cplusplus
# ifdef __GNUC__ # ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wlong-long" # pragma GCC diagnostic ignored "-Wlong-long"
# endif # endif
extern "C" { extern "C" {
#endif #endif
#define crypto_generichash_BYTES_MIN crypto_generichash_blake2b_BYTES_MIN #define crypto_generichash_BYTES_MIN crypto_generichash_blake2b_BYTES_MIN
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_generichash_bytes_min(void); size_t crypto_generichash_bytes_min(void);
#define crypto_generichash_BYTES_MAX crypto_generichash_blake2b_BYTES_MAX #define crypto_generichash_BYTES_MAX crypto_generichash_blake2b_BYTES_MAX
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_generichash_bytes_max(void); size_t crypto_generichash_bytes_max(void);
#define crypto_generichash_BYTES crypto_generichash_blake2b_BYTES #define crypto_generichash_BYTES crypto_generichash_blake2b_BYTES
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_generichash_bytes(void); size_t crypto_generichash_bytes(void);
#define crypto_generichash_KEYBYTES_MIN crypto_generichash_blake2b_KEYBYTES_MIN #define crypto_generichash_KEYBYTES_MIN crypto_generichash_blake2b_KEYBYTES_MIN
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_generichash_keybytes_min(void); size_t crypto_generichash_keybytes_min(void);
#define crypto_generichash_KEYBYTES_MAX crypto_generichash_blake2b_KEYBYTES_MAX #define crypto_generichash_KEYBYTES_MAX crypto_generichash_blake2b_KEYBYTES_MAX
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_generichash_keybytes_max(void); size_t crypto_generichash_keybytes_max(void);
#define crypto_generichash_KEYBYTES crypto_generichash_blake2b_KEYBYTES #define crypto_generichash_KEYBYTES crypto_generichash_blake2b_KEYBYTES
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_generichash_keybytes(void); size_t crypto_generichash_keybytes(void);
#define crypto_generichash_PRIMITIVE "blake2b" #define crypto_generichash_PRIMITIVE "blake2b"
SODIUM_EXPORT SODIUM_EXPORT
const char *crypto_generichash_primitive(void); const char *crypto_generichash_primitive(void);
typedef crypto_generichash_blake2b_state crypto_generichash_state; typedef crypto_generichash_blake2b_state crypto_generichash_state;
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_generichash_statebytes(void); size_t crypto_generichash_statebytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_generichash(unsigned char *out, size_t outlen, int crypto_generichash(unsigned char *out, size_t outlen,
const unsigned char *in, unsigned long long inlen, const unsigned char *in, unsigned long long inlen,
const unsigned char *key, size_t keylen); const unsigned char *key, size_t keylen);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_generichash_init(crypto_generichash_state *state, int crypto_generichash_init(crypto_generichash_state *state,
const unsigned char *key, const unsigned char *key,
const size_t keylen, const size_t outlen); const size_t keylen, const size_t outlen);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_generichash_update(crypto_generichash_state *state, int crypto_generichash_update(crypto_generichash_state *state,
const unsigned char *in, const unsigned char *in,
unsigned long long inlen); unsigned long long inlen);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_generichash_final(crypto_generichash_state *state, int crypto_generichash_final(crypto_generichash_state *state,
unsigned char *out, const size_t outlen); unsigned char *out, const size_t outlen);
SODIUM_EXPORT SODIUM_EXPORT
void crypto_generichash_keygen(unsigned char k[crypto_generichash_KEYBYTES]); void crypto_generichash_keygen(unsigned char k[crypto_generichash_KEYBYTES]);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

Some files were not shown because too many files have changed in this diff Show More