Merge remote-tracking branch 'origin/hushchat' into dev
61
.gdb_history
Normal file
@@ -0,0 +1,61 @@
|
||||
b ContactDataStore::dump()
|
||||
r
|
||||
n
|
||||
q
|
||||
b ContactDataStore::dump()
|
||||
r
|
||||
n
|
||||
c
|
||||
./build.sh
|
||||
$(./build.sh)
|
||||
$(./build.sh)
|
||||
q
|
||||
r
|
||||
q
|
||||
r
|
||||
b ContactDataStore::dump()
|
||||
r
|
||||
n
|
||||
b ContactItem::toJson()
|
||||
r
|
||||
c
|
||||
n
|
||||
q
|
||||
b ContactItem::toJson()
|
||||
r
|
||||
n
|
||||
c
|
||||
c
|
||||
c
|
||||
c
|
||||
c
|
||||
c
|
||||
c
|
||||
c
|
||||
q
|
||||
b FileSystem::writeContacts(QString file, json j)
|
||||
b FileSystem::writeContacts
|
||||
r
|
||||
q
|
||||
b FileSystem::writeContacts
|
||||
r
|
||||
b ContactDataStore::dump()
|
||||
r
|
||||
c
|
||||
n
|
||||
q
|
||||
b FileSystem::writeContacts
|
||||
r
|
||||
n
|
||||
q
|
||||
r
|
||||
b FileEncryption::encrypt
|
||||
r
|
||||
s
|
||||
n
|
||||
q
|
||||
b FileSystem::readContactsOldFormat
|
||||
r
|
||||
n
|
||||
c
|
||||
q
|
||||
@@ -26,7 +26,7 @@ SilentDragonLite does automatic note and utxo management, which means it doesn't
|
||||
## Compiling from source
|
||||
* SilentDragonLite 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).
|
||||
* You'll need Rust v1.37 +
|
||||
* You'll need Rust v1.41 +
|
||||
|
||||
## Building on Linux
|
||||
|
||||
|
||||
@@ -8,30 +8,72 @@
|
||||
<file>res/paymentreq.gif</file>
|
||||
<file>res/icon.ico</file>
|
||||
<file>res/mail.png</file>
|
||||
<file>res/darkwing.png</file>
|
||||
<file>res/SDLogo.png</file>
|
||||
<file>res/sdlogo2.png</file>
|
||||
<file>res/Berg.png</file>
|
||||
<file>res/Denio.png</file>
|
||||
<file>res/Duke.png</file>
|
||||
<file>res/Sharpee.png</file>
|
||||
<file>res/Yoda.png</file>
|
||||
<file>res/Mickey.png</file>
|
||||
<file>res/Snoopy.png</file>
|
||||
<file>res/Popey.png</file>
|
||||
<file>res/Garfield.png</file>
|
||||
<file>res/Pinguin.png</file>
|
||||
<file>res/Stag.png</file>
|
||||
<file>res/Elsa.png</file>
|
||||
<file>res/send.png</file>
|
||||
<file>res/send.svg</file>
|
||||
<file>res/addcontact.svg</file>
|
||||
<file>res/send-new.svg</file>
|
||||
<file>res/add_contact.svg</file>
|
||||
<file>res/notification.svg</file>
|
||||
<file>res/send-new-white.png</file>
|
||||
<file>res/add_contact.png</file>
|
||||
<file>res/notification.png</file>
|
||||
<file>res/rahmen-message.png</file>
|
||||
<file>res/message-icon.svg</file>
|
||||
<file>res/lock_green.png</file>
|
||||
<file>res/lock_orange.png</file>
|
||||
<file>res/unlocked.png</file>
|
||||
<file>res/getAddrWhite.png</file>
|
||||
<file>res/send-white.png</file>
|
||||
<file>res/requestWhite.png</file>
|
||||
<file>res/addContactWhite.png</file>
|
||||
<file>res/getAddrBlack.png</file>
|
||||
<file>res/sendBlack.png</file>
|
||||
<file>res/requestBlack.png</file>
|
||||
<file>res/addContactBlack.png</file>
|
||||
<file>res/unknownBlack.png</file>
|
||||
<file>res/unknownWhite.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/img">
|
||||
<file>res/hushdlogo.gif</file>
|
||||
<file>res/logobig.gif</file>
|
||||
<file>res/silentdragonlite-animated.gif</file>
|
||||
<file>res/silentdragonlite-animated-dark.gif</file>
|
||||
<file>res/silentdragonlite-animated-startup.gif</file>
|
||||
<file>res/silentdragonlite-animated-startup-dark.gif</file>
|
||||
<file>res/loaderblack.gif</file>
|
||||
<file>res/loaderwhite.gif</file>
|
||||
</qresource>
|
||||
<qresource prefix="/translations">
|
||||
<file>res/silentdragonlite_de.qm</file>
|
||||
<file>res/silentdragonlite_es.qm</file>
|
||||
<file>res/silentdragonlite_fr.qm</file>
|
||||
<file>res/silentdragonlite_pt.qm</file>
|
||||
<file>res/silentdragonlite_it.qm</file>
|
||||
<file>res/silentdragonlite_hr.qm</file>
|
||||
<file>res/silentdragonlite_fa.qm</file>
|
||||
<file>res/silentdragonlite_de.qm</file>
|
||||
<file>res/silentdragonlite_es.qm</file>
|
||||
<file>res/silentdragonlite_fr.qm</file>
|
||||
<file>res/silentdragonlite_pt.qm</file>
|
||||
<file>res/silentdragonlite_it.qm</file>
|
||||
<file>res/silentdragonlite_hr.qm</file>
|
||||
<file>res/silentdragonlite_fa.qm</file>
|
||||
<file>res/silentdragonlite_id.qm</file>
|
||||
<file>res/silentdragonlite_ar.qm</file>
|
||||
</qresource>
|
||||
<qresource prefix="/css">
|
||||
<file>res/css/blue.css</file>
|
||||
<file>res/css/dark.css</file>
|
||||
<file>res/css/default.css</file>
|
||||
<file>res/css/light.css</file>
|
||||
<file>res/css/midnight.css</file>
|
||||
<file>res/css/Blue.css</file>
|
||||
<file>res/css/Dark.css</file>
|
||||
<file>res/css/Default.css</file>
|
||||
<file>res/css/Light.css</file>
|
||||
<file>res/css/Midnight.css</file>
|
||||
</qresource>
|
||||
<qresource prefix="/images/blue">
|
||||
<file>res/images/blue/unchecked.png</file>
|
||||
|
||||
5
compile.log
Normal file
@@ -0,0 +1,5 @@
|
||||
Compiling SilentDragonLite 1.2.2 with 4 threads...
|
||||
g++ -c -include bin/SilentDragonLite -pipe -g -std=gnu++1y -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQAPPLICATION_CLASS=QApplication -D_FORTIFY_SOURCE=2 -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_WEBSOCKETS_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -Isrc/3rdparty -Isrc -Isingleapplication -Ires -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtWebSockets -isystem /usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -Ibin -Isrc -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o bin/mainwindow.o src/mainwindow.cpp
|
||||
g++ -c -include bin/SilentDragonLite -pipe -g -std=gnu++1y -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQAPPLICATION_CLASS=QApplication -D_FORTIFY_SOURCE=2 -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_WEBSOCKETS_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -Isrc/3rdparty -Isrc -Isingleapplication -Ires -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtWebSockets -isystem /usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -Ibin -Isrc -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o bin/sendtab.o src/sendtab.cpp
|
||||
g++ -c -include bin/SilentDragonLite -pipe -g -std=gnu++1y -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQAPPLICATION_CLASS=QApplication -D_FORTIFY_SOURCE=2 -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_WEBSOCKETS_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -Isrc/3rdparty -Isrc -Isingleapplication -Ires -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtWebSockets -isystem /usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -Ibin -Isrc -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o bin/addressbook.o src/addressbook.cpp
|
||||
g++ -c -include bin/SilentDragonLite -pipe -g -std=gnu++1y -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQAPPLICATION_CLASS=QApplication -D_FORTIFY_SOURCE=2 -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_WEBSOCKETS_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -Isrc/3rdparty -Isrc -Isingleapplication -Ires -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtWebSockets -isystem /usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -Ibin -Isrc -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o bin/addresscombo.o src/addresscombo.cpp
|
||||
7
lib/Cargo.lock
generated
@@ -1177,7 +1177,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=7efa024660cbe08e7eadf2524134e153c89c51ad)",
|
||||
"silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=d2887d07879a93bdd9b2c8bd12504bb977e82fe0)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1640,7 +1640,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "silentdragonlitelib"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/MyHush/silentdragonlite-cli?rev=7efa024660cbe08e7eadf2524134e153c89c51ad#7efa024660cbe08e7eadf2524134e153c89c51ad"
|
||||
source = "git+https://github.com/MyHush/silentdragonlite-cli?rev=d2887d07879a93bdd9b2c8bd12504bb977e82fe0#d2887d07879a93bdd9b2c8bd12504bb977e82fe0"
|
||||
dependencies = [
|
||||
"base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bellman 0.1.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)",
|
||||
@@ -1652,6 +1652,7 @@ dependencies = [
|
||||
"http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"json 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libflate 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log4rs 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pairing 0.14.2 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)",
|
||||
@@ -2630,7 +2631,7 @@ dependencies = [
|
||||
"checksum serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35"
|
||||
"checksum sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0"
|
||||
"checksum signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41"
|
||||
"checksum silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=7efa024660cbe08e7eadf2524134e153c89c51ad)" = "<none>"
|
||||
"checksum silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=d2887d07879a93bdd9b2c8bd12504bb977e82fe0)" = "<none>"
|
||||
"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
|
||||
"checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6"
|
||||
"checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85"
|
||||
|
||||
@@ -11,4 +11,4 @@ crate-type = ["staticlib"]
|
||||
[dependencies]
|
||||
libc = "0.2.58"
|
||||
lazy_static = "1.4.0"
|
||||
silentdragonlitelib = { git = "https://github.com/MyHush/silentdragonlite-cli", rev = "7efa024660cbe08e7eadf2524134e153c89c51ad" }
|
||||
silentdragonlitelib = { git = "https://github.com/MyHush/silentdragonlite-cli", rev = "d2887d07879a93bdd9b2c8bd12504bb977e82fe0" }
|
||||
|
||||
2
peda-session-SilentDragonLite.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
break FileSystem::readContactsOldFormat
|
||||
|
||||
BIN
res/Berg.png
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
res/Denio.png
Normal file
|
After Width: | Height: | Size: 65 KiB |
BIN
res/Duke.png
Normal file
|
After Width: | Height: | Size: 75 KiB |
BIN
res/Elsa.png
Normal file
|
After Width: | Height: | Size: 92 KiB |
BIN
res/Garfield.png
Normal file
|
After Width: | Height: | Size: 106 KiB |
BIN
res/Mickey.png
Normal file
|
After Width: | Height: | Size: 57 KiB |
BIN
res/Pinguin.png
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
res/Popey.png
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
res/SDLogo.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
res/Sharpee.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
res/Snoopy.png
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
res/Stag.png
Normal file
|
After Width: | Height: | Size: 140 KiB |
BIN
res/Yoda.png
Normal file
|
After Width: | Height: | Size: 82 KiB |
BIN
res/addContactBlack.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
res/addContactWhite.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
res/add_contact.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
9
res/add_contact.svg
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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"
|
||||
viewBox="0 0 265.7 283.5" style="enable-background:new 0 0 265.7 283.5;" xml:space="preserve">
|
||||
<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
|
||||
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>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 604 B |
7
res/addcontact.svg
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Svg Vector Icons : http://www.onlinewebfonts.com/icon -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
|
||||
<metadata> Svg Vector Icons : http://www.onlinewebfonts.com/icon </metadata>
|
||||
<g><path d="M870.2,797.3l-99.5-2.4l2.4-99.7c0.4-15.7-12.1-28.8-27.8-29.2c-15.7-0.4-28.8,12-29.2,27.8l-2.4,99.7l-99.6-2.4c-15.7-0.4-28.8,12.1-29.2,27.8c-0.4,15.7,12,28.8,27.8,29.2l99.6,2.4l-2.4,99.7c-0.4,15.7,12,28.8,27.8,29.2c15.7,0.4,28.8-12,29.2-27.8l2.4-99.6l99.5,2.4c15.6,0.4,28.8-12,29.2-27.8C898.3,810.8,885.9,797.7,870.2,797.3L870.2,797.3z"/><path d="M515.1,568.6c2.2,15.9,16.9,27.1,32.7,25.1c117.1-14.5,232.6,25.5,316.9,109.9c11.4,11.4,29.8,11.5,41.1,0.3c11.3-11.2,11.2-29.7-0.3-41.1C808.3,565.4,675,519.2,539.9,536C524.4,538,512.9,553.1,515.1,568.6z M113.8,990c15.9,0.5,29.2-12.2,29.7-28.4c6.3-209.1,178.4-374.1,383.6-367.9c158.1,4.8,290.6-122.2,295.5-283.1c4.8-160.9-119.8-295.7-277.9-300.5C386.6,5.4,254.1,132.4,249.2,293.3c-3.2,106.5,52.2,207,142.4,260.6C216.3,608.1,91.5,772.7,85.8,959.9C85.3,976,97.9,989.5,113.8,990z M542.9,68.8c126.3,3.8,225.8,111.5,221.9,240.1C761,437.5,655.2,539,528.9,535.1c-126.2-3.8-225.6-111.5-221.8-240.1C311,166.6,416.8,65.1,542.9,68.8z"/></g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
@@ -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, ChatModel, requestDialog
|
||||
{
|
||||
background-color: #303335;
|
||||
color: #ffffff;
|
||||
@@ -25,7 +25,7 @@ QTabWidget QTabBar::tab:hover {
|
||||
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #747577, stop: 1 #3E4244);
|
||||
color:#fff;
|
||||
border: 1px ridge #fff;
|
||||
min-height: 20px
|
||||
min-height: 20px;
|
||||
}
|
||||
|
||||
QHeaderView { /* Table Header */
|
||||
BIN
res/darkwing.png
Normal file
|
After Width: | Height: | Size: 174 KiB |
BIN
res/getAddrBlack.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
res/getAddrWhite.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
res/hushdark.png
Normal file
|
After Width: | Height: | Size: 49 KiB |
BIN
res/loaderblack.gif
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
res/loaderwhite.gif
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
res/lock.png
Normal file
|
After Width: | Height: | Size: 812 B |
7
res/lock.svg
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Svg Vector Icons : http://www.onlinewebfonts.com/icon -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
|
||||
<metadata> Svg Vector Icons : http://www.onlinewebfonts.com/icon </metadata>
|
||||
<g><path d="M500,10C229.4,10,10,229.4,10,500c0,270.6,219.4,490,490,490c270.6,0,490-219.4,490-490C990,229.4,770.6,10,500,10z M500,947.4C252.9,947.4,52.6,747.1,52.6,500C52.6,252.9,252.9,52.6,500,52.6c247.1,0,447.4,200.3,447.4,447.4C947.4,747.1,747.1,947.4,500,947.4z"/><path d="M452.1,392.4c0-24.5,6.4-83.1,69.2-83.1c59.7,0,69.2,52.2,69.2,83.1v18.1h52.2v-18.1c0-81-46.9-133.2-120.4-133.2c-73.5,0-120.4,52.2-120.4,133.2v18.1h52.2v-18.1H452.1z M641.7,427.6H400.9c-28.8,0-52.2,22.4-52.2,51.1V647c0,27.7,23.4,51.1,52.2,51.1h240.7c28.8,0,52.2-22.4,52.2-51.1V478.7C693.9,451,670.4,427.6,641.7,427.6L641.7,427.6z M538.3,575.6V614c0,9.6-7.5,17-17,17c-9.6,0-17-7.5-17-17v-38.3c-10.7-5.3-17-17-17-28.8c0-18.1,14.9-34.1,34.1-34.1s34.1,14.9,34.1,34.1C555.4,558.6,549,569.2,538.3,575.6L538.3,575.6z"/></g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
7
res/lock_blue.svg
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Svg Vector Icons : http://www.onlinewebfonts.com/icon -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg fill="#46a2da" width="16px" height="16px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
|
||||
<metadata> Svg Vector Icons : http://www.onlinewebfonts.com/icon </metadata>
|
||||
<g><path d="M500,10C229.4,10,10,229.4,10,500c0,270.6,219.4,490,490,490c270.6,0,490-219.4,490-490C990,229.4,770.6,10,500,10z M500,947.4C252.9,947.4,52.6,747.1,52.6,500C52.6,252.9,252.9,52.6,500,52.6c247.1,0,447.4,200.3,447.4,447.4C947.4,747.1,747.1,947.4,500,947.4z"/><path d="M452.1,392.4c0-24.5,6.4-83.1,69.2-83.1c59.7,0,69.2,52.2,69.2,83.1v18.1h52.2v-18.1c0-81-46.9-133.2-120.4-133.2c-73.5,0-120.4,52.2-120.4,133.2v18.1h52.2v-18.1H452.1z M641.7,427.6H400.9c-28.8,0-52.2,22.4-52.2,51.1V647c0,27.7,23.4,51.1,52.2,51.1h240.7c28.8,0,52.2-22.4,52.2-51.1V478.7C693.9,451,670.4,427.6,641.7,427.6L641.7,427.6z M538.3,575.6V614c0,9.6-7.5,17-17,17c-9.6,0-17-7.5-17-17v-38.3c-10.7-5.3-17-17-17-28.8c0-18.1,14.9-34.1,34.1-34.1s34.1,14.9,34.1,34.1C555.4,558.6,549,569.2,538.3,575.6L538.3,575.6z"/></g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
BIN
res/lock_green.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
7
res/lock_green.svg
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Svg Vector Icons : http://www.onlinewebfonts.com/icon -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg fill="#32dc15" width="16px" height="16px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
|
||||
<metadata> Svg Vector Icons : http://www.onlinewebfonts.com/icon </metadata>
|
||||
<g><path d="M500,10C229.4,10,10,229.4,10,500c0,270.6,219.4,490,490,490c270.6,0,490-219.4,490-490C990,229.4,770.6,10,500,10z M500,947.4C252.9,947.4,52.6,747.1,52.6,500C52.6,252.9,252.9,52.6,500,52.6c247.1,0,447.4,200.3,447.4,447.4C947.4,747.1,747.1,947.4,500,947.4z"/><path d="M452.1,392.4c0-24.5,6.4-83.1,69.2-83.1c59.7,0,69.2,52.2,69.2,83.1v18.1h52.2v-18.1c0-81-46.9-133.2-120.4-133.2c-73.5,0-120.4,52.2-120.4,133.2v18.1h52.2v-18.1H452.1z M641.7,427.6H400.9c-28.8,0-52.2,22.4-52.2,51.1V647c0,27.7,23.4,51.1,52.2,51.1h240.7c28.8,0,52.2-22.4,52.2-51.1V478.7C693.9,451,670.4,427.6,641.7,427.6L641.7,427.6z M538.3,575.6V614c0,9.6-7.5,17-17,17c-9.6,0-17-7.5-17-17v-38.3c-10.7-5.3-17-17-17-28.8c0-18.1,14.9-34.1,34.1-34.1s34.1,14.9,34.1,34.1C555.4,558.6,549,569.2,538.3,575.6L538.3,575.6z"/></g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
BIN
res/lock_orange.png
Normal file
|
After Width: | Height: | Size: 929 B |
9
res/message-icon.svg
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 19.0.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"
|
||||
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
|
||||
<g id="XMLID_1_">
|
||||
<polygon id="XMLID_3_" points="256,371.5 256,379 512,379 512,27.4 0,27.4 0,379 136.3,379 136.3,484.6 261,377.4 256,371.5
|
||||
256,379 256,371.5 251,364.9 152.1,449.7 152.1,363.2 15.8,363.2 15.8,43.2 496.2,43.2 496.2,363.2 252.7,363.2 251,364.9 "/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 636 B |
BIN
res/notification.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
10
res/notification.svg
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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"
|
||||
viewBox="0 0 225.9 283.5" style="enable-background:new 0 0 225.9 283.5;" xml:space="preserve">
|
||||
<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
|
||||
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"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 655 B |
BIN
res/rahmen-message.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
res/requestBlack.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
res/requestWhite.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
res/sdlogo2.png
Normal file
|
After Width: | Height: | Size: 58 KiB |
BIN
res/send-new-white.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
19
res/send-new.svg
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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"
|
||||
viewBox="0 0 300.2 283.5" style="enable-background:new 0 0 300.2 283.5;" xml:space="preserve">
|
||||
<!--<style type="text/css">-->
|
||||
<!--.st0{clip-path:url(#SVGID_2_);}-->
|
||||
<!--</style>-->
|
||||
<g>
|
||||
<!--<g>-->
|
||||
<!--<defs>-->
|
||||
<!--<rect id="SVGID_1_" x="2.6" width="297.6" height="265.7"/>-->
|
||||
<!--</defs>-->
|
||||
<!--<clipPath id="SVGID_2_">-->
|
||||
<!--<use xlink:href="#SVGID_1_" style="overflow:visible;"/>-->
|
||||
<!--</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"/>
|
||||
<!--</g>-->
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 808 B |
BIN
res/send-white.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
res/send.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
6
res/send.svg
Normal file
@@ -0,0 +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">
|
||||
.st0{fill:#2C8AAA;}
|
||||
.st1{opacity:0.19;clip-path:url(#XMLID_39_);fill:#070808;}
|
||||
.st2{fill:#FFFFFF;}
|
||||
.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>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
BIN
res/sendBlack.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
res/silentdragonlite_ar.qm
Normal file
2651
res/silentdragonlite_ar.ts
Normal file
BIN
res/silentdragonlite_id.qm
Normal file
2002
res/silentdragonlite_id.ts
Normal file
BIN
res/unknownBlack.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
res/unknownWhite.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
res/unkownBlack.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
res/unlocked.png
Normal file
|
After Width: | Height: | Size: 1006 B |
@@ -13,6 +13,7 @@ PRECOMPILED_HEADER = src/precompiled.h
|
||||
QT += widgets
|
||||
QT += websockets
|
||||
|
||||
|
||||
TARGET = SilentDragonLite
|
||||
|
||||
TEMPLATE = app
|
||||
@@ -33,6 +34,7 @@ mac: LIBS+= -Wl,-bind_at_load
|
||||
|
||||
RESOURCES = application.qrc
|
||||
|
||||
|
||||
MOC_DIR = bin
|
||||
OBJECTS_DIR = bin
|
||||
UI_DIR = src
|
||||
@@ -65,7 +67,24 @@ SOURCES += \
|
||||
src/datamodel.cpp \
|
||||
src/controller.cpp \
|
||||
src/liteinterface.cpp \
|
||||
src/camount.cpp
|
||||
src/camount.cpp \
|
||||
src/chatbubbleme.cpp \
|
||||
src/chatbubblepartner.cpp \
|
||||
src/chatmodel.cpp \
|
||||
src/contactmodel.cpp \
|
||||
src/DataStore/DataStore.cpp \
|
||||
src/DataStore/ChatDataStore.cpp \
|
||||
src/DataStore/SietchDataStore.cpp \
|
||||
src/DataStore/ContactDataStore.cpp \
|
||||
src/Model/ChatItem.cpp \
|
||||
src/Model/ContactRequestChatItem.cpp \
|
||||
src/Model/ContactItem.cpp \
|
||||
src/Model/ContactRequest.cpp \
|
||||
src/Chat/Helper/ChatIDGenerator.cpp \
|
||||
src/Chat/Chat.cpp \
|
||||
src/FileSystem/FileSystem.cpp \
|
||||
src/Crypto/FileEncryption.cpp \
|
||||
src/Crypto/passwd.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/firsttimewizard.h \
|
||||
@@ -94,10 +113,17 @@ HEADERS += \
|
||||
src/controller.h \
|
||||
src/liteinterface.h \
|
||||
src/camount.h \
|
||||
lib/silentdragonlitelib.h
|
||||
lib/silentdragonlitelib.h \
|
||||
src/chatbubbleme.h \
|
||||
src/chatbubblepartner.h \
|
||||
src/chatmodel.h \
|
||||
src/contactmodel.h
|
||||
|
||||
FORMS += \
|
||||
src/contactrequest.ui \
|
||||
src/deposithush.ui \
|
||||
src/encryption.ui \
|
||||
src/hushrequest.ui \
|
||||
src/mainwindow.ui \
|
||||
src/migration.ui \
|
||||
src/newseed.ui \
|
||||
@@ -109,15 +135,20 @@ FORMS += \
|
||||
src/confirm.ui \
|
||||
src/privkey.ui \
|
||||
src/memodialog.ui \
|
||||
src/startupencryption.ui \
|
||||
src/viewalladdresses.ui \
|
||||
src/connection.ui \
|
||||
src/addressbook.ui \
|
||||
src/mobileappconnector.ui \
|
||||
src/createhushconfdialog.ui \
|
||||
src/recurringdialog.ui \
|
||||
src/requestContactDialog.ui \
|
||||
src/newrecurring.ui \
|
||||
src/requestdialog.ui \
|
||||
src/recurringmultiple.ui
|
||||
src/removeencryption.ui \
|
||||
src/recurringmultiple.ui \
|
||||
src/chatbubbleme.ui \
|
||||
src/chatbubblepartner.ui
|
||||
|
||||
|
||||
TRANSLATIONS = res/silentdragonlite_es.ts \
|
||||
@@ -129,6 +160,8 @@ TRANSLATIONS = res/silentdragonlite_es.ts \
|
||||
res/silentdragonlite_hr.ts \
|
||||
res/silentdragonlite_sr.ts \
|
||||
res/silentdragonlite_fa.ts \
|
||||
res/silentdragonlite_id.ts \
|
||||
res/silentdragonlite_ar.ts \
|
||||
res/silentdragonlite_tr.ts
|
||||
|
||||
include(singleapplication/singleapplication.pri)
|
||||
|
||||
101
src/Chat/Chat.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
// Copyright 2019-2020 The Hush developers
|
||||
// GPLv3
|
||||
|
||||
#include "Chat.h"
|
||||
#include "../addressbook.h"
|
||||
#include "../DataStore/DataStore.h"
|
||||
Chat::Chat() {}
|
||||
|
||||
ChatMemoEdit::ChatMemoEdit(QWidget* parent) : QTextEdit(parent) {
|
||||
QObject::connect(this, &QTextEdit::textChanged, this, &ChatMemoEdit::updateDisplayChat);
|
||||
}
|
||||
|
||||
void ChatMemoEdit::updateDisplayChat() {
|
||||
QString txt = this->toPlainText();
|
||||
if (lenDisplayLabelchat)
|
||||
lenDisplayLabelchat->setText(QString::number(txt.toUtf8().size()) + "/" + QString::number(maxlenchat));
|
||||
|
||||
if (txt.toUtf8().size() <= maxlenchat) {
|
||||
// Everything is fine
|
||||
if (sendChatButton)
|
||||
sendChatButton->setEnabled(true);
|
||||
|
||||
if (lenDisplayLabelchat)
|
||||
lenDisplayLabelchat->setStyleSheet("");
|
||||
}
|
||||
else {
|
||||
// Overweight
|
||||
if (sendChatButton)
|
||||
sendChatButton->setEnabled(false);
|
||||
|
||||
if (lenDisplayLabelchat)
|
||||
lenDisplayLabelchat->setStyleSheet("color: red;");
|
||||
}
|
||||
}
|
||||
|
||||
void ChatMemoEdit::setMaxLenChat(int len) {
|
||||
this->maxlenchat = len;
|
||||
updateDisplayChat();
|
||||
}
|
||||
|
||||
void ChatMemoEdit::SetSendChatButton(QPushButton* button) {
|
||||
this->sendChatButton = button;
|
||||
}
|
||||
|
||||
void ChatMemoEdit::setLenDisplayLabelChat(QLabel* label) {
|
||||
this->lenDisplayLabelchat = label;
|
||||
}
|
||||
|
||||
void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
|
||||
{
|
||||
|
||||
QStandardItemModel *chat = new QStandardItemModel();
|
||||
DataStore::getChatDataStore()->dump(); // test to see if the chat items in datastore are correctly dumped to json
|
||||
for (auto &p : AddressBook::getInstance()->getAllAddressLabels())
|
||||
{
|
||||
for (auto &c : DataStore::getChatDataStore()->getAllMemos())
|
||||
{
|
||||
|
||||
if (
|
||||
(p.getName() == ui->contactNameMemo->text().trimmed()) &&
|
||||
(p.getPartnerAddress() == c.second.getAddress()) &&
|
||||
(c.second.isOutgoing() == true))
|
||||
{
|
||||
|
||||
QStandardItem *Items = new QStandardItem(c.second.toChatLine());
|
||||
|
||||
Items->setData(OUTGOING, Qt::UserRole + 1);
|
||||
chat->appendRow(Items);
|
||||
ui->listChat->setModel(chat);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->listChat->setModel(chat);
|
||||
}
|
||||
|
||||
if (
|
||||
(p.getName() == ui->contactNameMemo->text().trimmed()) &&
|
||||
(p.getMyAddress() == c.second.getAddress()) &&
|
||||
(c.second.isOutgoing() == false) &&
|
||||
(c.second.getCid() == p.getCid())
|
||||
)
|
||||
{
|
||||
QStandardItem *Items1 = new QStandardItem(c.second.toChatLine());
|
||||
Items1->setData(INCOMING, Qt::UserRole + 1);
|
||||
chat->appendRow(Items1);
|
||||
ui->listChat->setModel(chat);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ui->listChat->setModel(chat);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
34
src/Chat/Chat.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef CHAT_H
|
||||
#define CHAT_H
|
||||
|
||||
#include <QString>
|
||||
#include <QStandardItemModel>
|
||||
#include <QAbstractItemDelegate>
|
||||
#include <QPainter>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <QListView>
|
||||
#include "precompiled.h"
|
||||
#include "mainwindow.h"
|
||||
#include "controller.h"
|
||||
#include "settings.h"
|
||||
#include "camount.h"
|
||||
|
||||
#include "../Model/ChatItem.h"
|
||||
|
||||
|
||||
class Chat // Chat Controller
|
||||
{
|
||||
private:
|
||||
QTableView* parent;
|
||||
Ui::MainWindow* ui;
|
||||
MainWindow* main;
|
||||
std::map<QString, QString> cidMap;
|
||||
std::map<QString, QString> requestZaddrMap;
|
||||
public:
|
||||
Chat();
|
||||
void renderChatBox(Ui::MainWindow* ui, QListView *view, QLabel *label); // action
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
193
src/Chat/Helper/ChatDelegator.h
Normal file
@@ -0,0 +1,193 @@
|
||||
// Copyright 2019-2020 The Hush developers
|
||||
// GPLv3
|
||||
|
||||
#ifndef CHATDELEGATOR_H
|
||||
#define CHATDELEGATOR_H
|
||||
|
||||
#include <QString>
|
||||
#include <QStandardItemModel>
|
||||
#include <QAbstractItemDelegate>
|
||||
#include <QPainter>
|
||||
|
||||
enum RenderType
|
||||
{
|
||||
OUTGOING=0,
|
||||
INCOMING=1,
|
||||
INDATE=2,
|
||||
OUTDATE=3
|
||||
};
|
||||
|
||||
class ListViewDelegate : public QAbstractItemDelegate
|
||||
{
|
||||
int d_radius;
|
||||
int d_toppadding;
|
||||
int d_bottompadding;
|
||||
int d_leftpadding;
|
||||
int d_rightpadding;
|
||||
int d_verticalmargin;
|
||||
int d_horizontalmargin;
|
||||
int d_pointerwidth;
|
||||
int d_pointerheight;
|
||||
float d_widthfraction;
|
||||
public:
|
||||
inline ListViewDelegate(QObject *parent = nullptr);
|
||||
|
||||
protected:
|
||||
inline void paint(QPainter *painter, QStyleOptionViewItem const &option, QModelIndex const &index) const;
|
||||
inline QSize sizeHint(QStyleOptionViewItem const &option, QModelIndex const &index) const;
|
||||
};
|
||||
|
||||
inline ListViewDelegate::ListViewDelegate(QObject *parent): QAbstractItemDelegate(parent), d_radius(5), d_toppadding(5), d_bottompadding(3), d_leftpadding(5), d_rightpadding(5), d_verticalmargin(5), d_horizontalmargin(10), d_pointerwidth(4), d_pointerheight(17), d_widthfraction(.6)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline void ListViewDelegate::paint(QPainter *painter, QStyleOptionViewItem const &option, QModelIndex const &index) const
|
||||
{
|
||||
QTextDocument bodydoc;
|
||||
QTextOption textOption(bodydoc.defaultTextOption());
|
||||
textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
|
||||
bodydoc.setDefaultTextOption(textOption);
|
||||
bodydoc.setDefaultFont(QFont("Roboto", 12));
|
||||
QString bodytext(index.data(Qt::DisplayRole).toString());
|
||||
bodydoc.setHtml(bodytext);
|
||||
qreal contentswidth = option.rect.width() * d_widthfraction - d_horizontalmargin - d_pointerwidth - d_leftpadding - d_rightpadding;
|
||||
bodydoc.setTextWidth(contentswidth);
|
||||
qreal bodyheight = bodydoc.size().height();
|
||||
int outgoing = index.data(Qt::UserRole + 1).toInt();
|
||||
int outdate = index.data(Qt::UserRole + 1).toInt();
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
// uncomment to see the area provided to paint this item
|
||||
|
||||
//painter->drawRect(option.rect);
|
||||
|
||||
painter->translate(option.rect.left() + d_horizontalmargin, option.rect.top() + ((index.row() == 0) ? d_verticalmargin : 0));
|
||||
|
||||
QColor bgcolor("#ffffff");
|
||||
switch(outgoing)
|
||||
{
|
||||
case INDATE:
|
||||
bgcolor = "transparent";
|
||||
break;
|
||||
|
||||
case OUTDATE:
|
||||
bgcolor = "transparent";
|
||||
break;
|
||||
|
||||
case OUTGOING:
|
||||
bgcolor = "#f8f9fa";
|
||||
break;
|
||||
|
||||
default:
|
||||
case INCOMING:
|
||||
bgcolor = "#535353";
|
||||
break;
|
||||
}
|
||||
|
||||
// create chat bubble
|
||||
QPainterPath pointie;
|
||||
|
||||
// left bottom
|
||||
pointie.moveTo(0, bodyheight + d_toppadding + d_bottompadding);
|
||||
|
||||
// right bottom
|
||||
pointie.lineTo(0 + contentswidth + d_pointerwidth + d_leftpadding + d_rightpadding - d_radius,
|
||||
bodyheight + d_toppadding + d_bottompadding);
|
||||
pointie.arcTo(0 + contentswidth + d_pointerwidth + d_leftpadding + d_rightpadding - 2 * d_radius,
|
||||
bodyheight + d_toppadding + d_bottompadding - 2 * d_radius,
|
||||
2 * d_radius, 2 * d_radius, 270, 90);
|
||||
|
||||
// right top
|
||||
pointie.lineTo(0 + contentswidth + d_pointerwidth + d_leftpadding + d_rightpadding, 0 + d_radius);
|
||||
pointie.arcTo(0 + contentswidth + d_pointerwidth + d_leftpadding + d_rightpadding - 2 * d_radius, 0,
|
||||
2 * d_radius, 2 * d_radius, 0, 90);
|
||||
|
||||
// left top
|
||||
pointie.lineTo(0 + d_pointerwidth + d_radius, 0);
|
||||
pointie.arcTo(0 + d_pointerwidth, 0, 2 * d_radius, 2 * d_radius, 90, 90);
|
||||
|
||||
// left bottom almost (here is the pointie)
|
||||
pointie.lineTo(0 + d_pointerwidth, bodyheight + d_toppadding + d_bottompadding - d_pointerheight);
|
||||
pointie.closeSubpath();
|
||||
|
||||
// rotate bubble for outgoing messages
|
||||
if ((outgoing == OUTGOING) || (outdate == OUTDATE))
|
||||
{
|
||||
painter->translate(option.rect.width() - pointie.boundingRect().width() - d_horizontalmargin - d_pointerwidth, 0);
|
||||
painter->translate(pointie.boundingRect().center());
|
||||
painter->rotate(180);
|
||||
painter->translate(-pointie.boundingRect().center());
|
||||
}
|
||||
|
||||
// now paint it!
|
||||
painter->setPen(QPen(bgcolor));
|
||||
painter->drawPath(pointie);
|
||||
painter->fillPath(pointie, QBrush(bgcolor));
|
||||
|
||||
// rotate back or painter is going to paint the text rotated...
|
||||
if ((outgoing == OUTGOING) || (outdate == OUTDATE))
|
||||
{
|
||||
painter->translate(pointie.boundingRect().center());
|
||||
painter->rotate(-180);
|
||||
painter->translate(-pointie.boundingRect().center());
|
||||
}
|
||||
|
||||
// set text color used to draw message body
|
||||
QAbstractTextDocumentLayout::PaintContext ctx;
|
||||
switch(outgoing)
|
||||
{
|
||||
case INDATE:
|
||||
ctx.palette.setColor(QPalette::Text, QColor("Black"));
|
||||
break;
|
||||
|
||||
case OUTDATE:
|
||||
ctx.palette.setColor(QPalette::Text, QColor("Black"));
|
||||
break;
|
||||
|
||||
case OUTGOING:
|
||||
ctx.palette.setColor(QPalette::Text, QColor("Black"));
|
||||
break;
|
||||
|
||||
default:
|
||||
case INCOMING:
|
||||
ctx.palette.setColor(QPalette::Text, QColor("whitesmoke"));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// draw body text
|
||||
painter->translate((outgoing == OUTGOING ? 0 : d_pointerwidth) + d_leftpadding, 0);
|
||||
painter->translate((outdate == OUTDATE ? 0 : d_pointerwidth) + d_leftpadding, 0);
|
||||
bodydoc.documentLayout()->draw(painter, ctx);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
inline QSize ListViewDelegate::sizeHint(QStyleOptionViewItem const &option, QModelIndex const &index) const
|
||||
{
|
||||
QTextDocument bodydoc;
|
||||
QTextOption textOption(bodydoc.defaultTextOption());
|
||||
textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
|
||||
bodydoc.setDefaultTextOption(textOption);
|
||||
bodydoc.setDefaultFont(QFont("Roboto", 12));
|
||||
QString bodytext(index.data(Qt::DisplayRole).toString());
|
||||
bodydoc.setHtml(bodytext);
|
||||
|
||||
// the width of the contents are the (a fraction of the window width) minus (margins + padding + width of the bubble's tail)
|
||||
qreal contentswidth = option.rect.width() * d_widthfraction - d_horizontalmargin - d_pointerwidth - d_leftpadding - d_rightpadding;
|
||||
|
||||
// set this available width on the text document
|
||||
bodydoc.setTextWidth(contentswidth);
|
||||
|
||||
QSize size(bodydoc.idealWidth() + d_horizontalmargin + d_pointerwidth + d_leftpadding + d_rightpadding,
|
||||
bodydoc.size().height() + d_bottompadding + d_toppadding + d_verticalmargin + 1); // I dont remember why +1, haha, might not be necessary
|
||||
|
||||
if (index.row() == 0) // have extra margin at top of first item
|
||||
size += QSize(0, d_verticalmargin);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
#endif
|
||||
28
src/Chat/Helper/ChatIDGenerator.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "ChatIDGenerator.h"
|
||||
|
||||
ChatIDGenerator* ChatIDGenerator::getInstance()
|
||||
{
|
||||
if(ChatIDGenerator::instance == nullptr)
|
||||
ChatIDGenerator::instance = new ChatIDGenerator();
|
||||
|
||||
return ChatIDGenerator::instance;
|
||||
}
|
||||
|
||||
QString ChatIDGenerator::generateID(ChatItem item)
|
||||
{
|
||||
QString key = QString::number(item.getTimestamp()) + QString("-");
|
||||
key += QString(
|
||||
QCryptographicHash::hash(
|
||||
QString(
|
||||
QString::number(item.getTimestamp()) +
|
||||
item.getAddress() +
|
||||
item.getContact() +
|
||||
item.getMemo()
|
||||
).toUtf8(),
|
||||
QCryptographicHash::Md5
|
||||
).toHex()
|
||||
);
|
||||
return key;
|
||||
}
|
||||
|
||||
ChatIDGenerator* ChatIDGenerator::instance = nullptr;
|
||||
18
src/Chat/Helper/ChatIDGenerator.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef CHATIDGENERATOR_H
|
||||
#define CHATIDGENERATOR_H
|
||||
|
||||
#include <QString>
|
||||
#include <QUuid>
|
||||
#include "../../Model/ChatItem.h"
|
||||
|
||||
class ChatIDGenerator
|
||||
{
|
||||
private:
|
||||
static ChatIDGenerator* instance;
|
||||
|
||||
public:
|
||||
static ChatIDGenerator* getInstance();
|
||||
QString generateID(ChatItem item);
|
||||
};
|
||||
|
||||
#endif
|
||||
114
src/Crypto/FileEncryption.cpp
Normal file
@@ -0,0 +1,114 @@
|
||||
#include "FileEncryption.h"
|
||||
|
||||
void FileEncryption::showConfig()
|
||||
{
|
||||
qInfo() << FILEENCRYPTION_CHUNK_SIZE;
|
||||
}
|
||||
|
||||
int FileEncryption::encrypt(QString target_file, QString source_file, const unsigned char key[crypto_secretstream_xchacha20poly1305_KEYBYTES])
|
||||
{
|
||||
unsigned char plain_data[FILEENCRYPTION_CHUNK_SIZE];
|
||||
unsigned char cipher_data[FILEENCRYPTION_CHUNK_SIZE + crypto_secretstream_xchacha20poly1305_ABYTES];
|
||||
unsigned char header[crypto_secretstream_xchacha20poly1305_HEADERBYTES];
|
||||
crypto_secretstream_xchacha20poly1305_state state;
|
||||
FILE *target, *source;
|
||||
unsigned long long cipher_len;
|
||||
size_t rlen;
|
||||
int eof;
|
||||
unsigned char tag;
|
||||
|
||||
if(!FileEncryption::exists(source_file.toStdString()))
|
||||
{
|
||||
qDebug() << "File not exits" << source_file;
|
||||
return -1;
|
||||
}
|
||||
|
||||
source = fopen(source_file.toStdString().c_str(), "rb");
|
||||
target = fopen(target_file.toStdString().c_str(), "wb");
|
||||
crypto_secretstream_xchacha20poly1305_init_push(&state, header, key);
|
||||
fwrite(header, 1, sizeof header, target);
|
||||
do
|
||||
{
|
||||
rlen = fread(plain_data, 1, sizeof plain_data, source);
|
||||
eof = feof(source);
|
||||
tag = eof ? crypto_secretstream_xchacha20poly1305_TAG_FINAL : 0;
|
||||
crypto_secretstream_xchacha20poly1305_push(
|
||||
&state,
|
||||
cipher_data,
|
||||
&cipher_len,
|
||||
plain_data,
|
||||
rlen,
|
||||
NULL,
|
||||
0,
|
||||
tag
|
||||
);
|
||||
|
||||
fwrite(cipher_data, 1, (size_t) cipher_len, target);
|
||||
}
|
||||
while (! eof);
|
||||
|
||||
fclose(target);
|
||||
fclose(source);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FileEncryption::decrypt(QString target_file, QString source_file, const unsigned char key[crypto_secretstream_xchacha20poly1305_KEYBYTES])
|
||||
{
|
||||
unsigned char buf_in[FILEENCRYPTION_CHUNK_SIZE + crypto_secretstream_xchacha20poly1305_ABYTES];
|
||||
unsigned char buf_out[FILEENCRYPTION_CHUNK_SIZE];
|
||||
unsigned char header[crypto_secretstream_xchacha20poly1305_HEADERBYTES];
|
||||
crypto_secretstream_xchacha20poly1305_state st;
|
||||
FILE *fp_t, *fp_s;
|
||||
unsigned long long out_len;
|
||||
size_t rlen;
|
||||
int eof;
|
||||
int ret = -1;
|
||||
unsigned char tag;
|
||||
|
||||
if(!FileEncryption::exists(source_file.toStdString()))
|
||||
{
|
||||
qDebug() << "File not exits" << source_file;
|
||||
return -1;
|
||||
}
|
||||
|
||||
fp_s = fopen(source_file.toStdString().c_str(), "rb");
|
||||
fp_t = fopen(target_file.toStdString().c_str(), "wb");
|
||||
fread(header, 1, sizeof header, fp_s);
|
||||
if (crypto_secretstream_xchacha20poly1305_init_pull(&st, header, key) != 0)
|
||||
{
|
||||
goto ret; /* incomplete header */
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
rlen = fread(buf_in, 1, sizeof buf_in, fp_s);
|
||||
eof = feof(fp_s);
|
||||
if (crypto_secretstream_xchacha20poly1305_pull(
|
||||
&st,
|
||||
buf_out,
|
||||
&out_len,
|
||||
&tag,
|
||||
buf_in,
|
||||
rlen,
|
||||
NULL,
|
||||
0
|
||||
) != 0)
|
||||
{
|
||||
goto ret; /* corrupted chunk */
|
||||
}
|
||||
|
||||
if (tag == crypto_secretstream_xchacha20poly1305_TAG_FINAL && ! eof)
|
||||
{
|
||||
goto ret; /* premature end (end of file reached before the end of the stream) */
|
||||
}
|
||||
|
||||
fwrite(buf_out, 1, (size_t) out_len, fp_t);
|
||||
}
|
||||
while (! eof);
|
||||
ret = 0;
|
||||
|
||||
ret:
|
||||
fclose(fp_t);
|
||||
fclose(fp_s);
|
||||
return ret;
|
||||
}
|
||||
24
src/Crypto/FileEncryption.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef FILEENCRYPTION_H
|
||||
#define FILEENCRYPTION_H
|
||||
#include <stdio.h>
|
||||
#include <sodium.h>
|
||||
#include <QString>
|
||||
#include <fstream>
|
||||
|
||||
#define FILEENCRYPTION_CHUNK_SIZE 4096
|
||||
|
||||
class FileEncryption
|
||||
{
|
||||
private:
|
||||
inline static bool exists (const std::string& name) {
|
||||
std::ifstream f(name.c_str());
|
||||
return f.good();
|
||||
}
|
||||
public:
|
||||
static void showConfig();
|
||||
static int encrypt(QString target_file, QString source_file, const unsigned char key[crypto_secretstream_xchacha20poly1305_KEYBYTES]);
|
||||
static int decrypt(QString target_file, QString source_file, const unsigned char key[crypto_secretstream_xchacha20poly1305_KEYBYTES]);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
60
src/Crypto/passwd.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "passwd.h"
|
||||
|
||||
void PASSWD::show_hex_buff(unsigned char buf[])
|
||||
{
|
||||
int i;
|
||||
for (uint8_t i=0; i < crypto_secretstream_xchacha20poly1305_KEYBYTES; i++)
|
||||
printf("%02X ", buf[i]);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
const unsigned char* PASSWD::key(QString password)
|
||||
{
|
||||
|
||||
int length = password.length();
|
||||
|
||||
char *sequence = NULL;
|
||||
sequence = new char[length+1];
|
||||
strncpy(sequence, password.toLocal8Bit(), length +1);
|
||||
|
||||
#define MESSAGE ((const unsigned char *) sequence)
|
||||
#define MESSAGE_LEN length
|
||||
|
||||
unsigned char hash[crypto_secretstream_xchacha20poly1305_KEYBYTES];
|
||||
|
||||
crypto_hash_sha256(hash, MESSAGE, MESSAGE_LEN);
|
||||
|
||||
qDebug()<<"Generating SaltHash from password: " <<sequence;
|
||||
|
||||
|
||||
/////////we use the Hash of the Password as Salt, not perfect but still a good solution.
|
||||
|
||||
#define PASSWORD sequence
|
||||
#define KEY_LEN crypto_box_SEEDBYTES
|
||||
|
||||
unsigned char key[KEY_LEN];
|
||||
|
||||
if (crypto_pwhash
|
||||
(key, sizeof key, PASSWORD, strlen(PASSWORD), hash,
|
||||
crypto_pwhash_OPSLIMIT_SENSITIVE, crypto_pwhash_MEMLIMIT_SENSITIVE,
|
||||
crypto_pwhash_ALG_DEFAULT) != 0) {
|
||||
/* out of memory */
|
||||
}
|
||||
|
||||
qDebug()<<"Generating cryptographic key from password: " <<sequence;
|
||||
|
||||
|
||||
// crypto_generichash(blacke2hash, sizeof hash, MESSAGE, MESSAGE_LEN, NULL, 0);
|
||||
|
||||
//for(uint8_t i = 0; i < crypto_secretstream_xchacha20poly1305_KEYBYTES/2; i++)
|
||||
// hash[i] = blacke2hash[i];
|
||||
|
||||
// for(uint8_t i = crypto_secretstream_xchacha20poly1305_KEYBYTES/2; i < crypto_secretstream_xchacha20poly1305_KEYBYTES; i++)
|
||||
// hash[i] = sha256hash[i];
|
||||
|
||||
// delete[] sha256hash;
|
||||
//delete[] blacke2hash;
|
||||
qDebug()<<"secret key generated:\n";
|
||||
PASSWD::show_hex_buff(key);
|
||||
return key;
|
||||
}
|
||||
14
src/Crypto/passwd.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef PASSWD_H
|
||||
#define PASSWD_H
|
||||
#include <stdio.h>
|
||||
#include <sodium.h>
|
||||
#include <QString>
|
||||
|
||||
class PASSWD
|
||||
{
|
||||
public:
|
||||
static void show_hex_buff(unsigned char buf[]);
|
||||
static const unsigned char* key(QString);
|
||||
};
|
||||
|
||||
#endif
|
||||
127
src/DataStore/ChatDataStore.cpp
Normal file
@@ -0,0 +1,127 @@
|
||||
// Copyright 2019-2020 The Hush developers
|
||||
// GPLv3
|
||||
|
||||
#include "ChatDataStore.h"
|
||||
#include "addressbook.h"
|
||||
#include "chatmodel.h"
|
||||
|
||||
|
||||
ChatDataStore* ChatDataStore::getInstance()
|
||||
{
|
||||
if(!ChatDataStore::instanced)
|
||||
{
|
||||
ChatDataStore::instanced = true;
|
||||
ChatDataStore::instance = new ChatDataStore();
|
||||
}
|
||||
|
||||
return ChatDataStore::instance;
|
||||
}
|
||||
|
||||
void ChatDataStore::clear()
|
||||
{
|
||||
this->data.clear();
|
||||
}
|
||||
|
||||
|
||||
void ChatDataStore::setData(QString key, ChatItem value)
|
||||
{
|
||||
this->data[key] = value;
|
||||
}
|
||||
|
||||
ChatItem ChatDataStore::getData(QString key)
|
||||
{
|
||||
return this->data[key];
|
||||
}
|
||||
|
||||
QString ChatDataStore::getPassword()
|
||||
{
|
||||
|
||||
return _password;
|
||||
}
|
||||
|
||||
void ChatDataStore::setPassword(QString password)
|
||||
{
|
||||
|
||||
_password = password;
|
||||
}
|
||||
|
||||
QString ChatDataStore::dump()
|
||||
{
|
||||
json chats;
|
||||
chats["count"] = this->data.size();
|
||||
json j = {};
|
||||
for (auto &c: this->data)
|
||||
{
|
||||
j.push_back(c.second.toJson());
|
||||
}
|
||||
chats["chatitems"] = j;
|
||||
return QString::fromStdString(chats.dump());
|
||||
}
|
||||
|
||||
std::map<QString, ChatItem> ChatDataStore::getAllRawChatItems()
|
||||
{
|
||||
return this->data;
|
||||
}
|
||||
|
||||
std::map<QString, ChatItem> ChatDataStore::getAllNewContactRequests()
|
||||
{
|
||||
std::map<QString, ChatItem> filteredItems;
|
||||
|
||||
for(auto &c: this->data)
|
||||
{
|
||||
if (
|
||||
(c.second.isOutgoing() == false) &&
|
||||
(c.second.getType() == "Cont") &&
|
||||
(c.second.isContact() == false) &&
|
||||
(c.second.getMemo().startsWith("{"))
|
||||
|
||||
)
|
||||
|
||||
{
|
||||
filteredItems[c.first] = c.second;
|
||||
}
|
||||
}
|
||||
return filteredItems;
|
||||
}
|
||||
|
||||
std::map<QString, ChatItem> ChatDataStore::getAllOldContactRequests()
|
||||
{
|
||||
std::map<QString, ChatItem> filteredItems;
|
||||
|
||||
for(auto &c: this->data)
|
||||
{
|
||||
if (
|
||||
(c.second.isOutgoing() == false) &&
|
||||
(c.second.getType() == "Cont") &&
|
||||
(c.second.isContact() == true) &&
|
||||
(c.second.getMemo().startsWith("{"))
|
||||
)
|
||||
{
|
||||
filteredItems[c.first] = c.second;
|
||||
}
|
||||
}
|
||||
return filteredItems;
|
||||
}
|
||||
|
||||
std::map<QString, ChatItem> ChatDataStore::getAllMemos()
|
||||
{
|
||||
std::map<QString, ChatItem> filteredItems;
|
||||
for(auto &c: this->data)
|
||||
{
|
||||
if (
|
||||
|
||||
(c.second.getMemo().startsWith("{") == false) &&
|
||||
(c.second.getMemo().isEmpty() == false)
|
||||
|
||||
|
||||
)
|
||||
{
|
||||
filteredItems[c.first] = c.second;
|
||||
}
|
||||
}
|
||||
return filteredItems;
|
||||
}
|
||||
|
||||
|
||||
ChatDataStore* ChatDataStore::instance = nullptr;
|
||||
bool ChatDataStore::instanced = false;
|
||||
44
src/DataStore/ChatDataStore.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef CHATDATASTORE_H
|
||||
#define CHATDATASTORE_H
|
||||
#include "../chatmodel.h"
|
||||
using json = nlohmann::json;
|
||||
|
||||
class ChatDataStore
|
||||
{
|
||||
private:
|
||||
static bool instanced;
|
||||
static ChatDataStore* instance;
|
||||
Ui::MainWindow* ui;
|
||||
MainWindow* main;
|
||||
std::map<QString, ChatItem> data;
|
||||
ChatDataStore()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
static ChatDataStore* getInstance();
|
||||
void clear();
|
||||
void setData(QString key, ChatItem value);
|
||||
ChatItem getData(QString key);
|
||||
std::map<QString, ChatItem> getAllRawChatItems();
|
||||
std::map<QString, ChatItem> getAllNewContactRequests();
|
||||
std::map<QString, ChatItem> getAllOldContactRequests();
|
||||
std::map<QString, ChatItem> getAllMemos();
|
||||
QString getPassword();
|
||||
|
||||
void setPassword(QString Password);
|
||||
QString _password;
|
||||
|
||||
QString dump();
|
||||
|
||||
~ChatDataStore()
|
||||
{
|
||||
ChatDataStore::instanced = false;
|
||||
ChatDataStore::instance = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
50
src/DataStore/ContactDataStore.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
// Copyright 2019-2020 The Hush developers
|
||||
// GPLv3
|
||||
|
||||
#include "ContactDataStore.h"
|
||||
#include <string>
|
||||
|
||||
ContactDataStore* ContactDataStore::getInstance()
|
||||
{
|
||||
if(!ContactDataStore::instanced)
|
||||
{
|
||||
ContactDataStore::instanced = true;
|
||||
ContactDataStore::instance = new ContactDataStore();
|
||||
}
|
||||
|
||||
return ContactDataStore::instance;
|
||||
}
|
||||
|
||||
void ContactDataStore::clear()
|
||||
{
|
||||
this->data.clear();
|
||||
}
|
||||
|
||||
|
||||
void ContactDataStore::setData(QString key, ContactItem value)
|
||||
{
|
||||
this->data[key] = value;
|
||||
}
|
||||
|
||||
ContactItem ContactDataStore::getData(QString key)
|
||||
{
|
||||
return this->data[key];
|
||||
}
|
||||
|
||||
QString ContactDataStore::dump()
|
||||
{
|
||||
json contacts;
|
||||
contacts["count"] = this->data.size();
|
||||
json j = {};
|
||||
for (auto &c: this->data)
|
||||
{
|
||||
qDebug() << c.second.toQTString();
|
||||
c.second.toJson();
|
||||
j.push_back(c.second.toJson());
|
||||
}
|
||||
contacts["contacts"] = j;
|
||||
return QString::fromStdString(contacts.dump(4));
|
||||
}
|
||||
|
||||
ContactDataStore* ContactDataStore::instance = nullptr;
|
||||
bool ContactDataStore::instanced = false;
|
||||
34
src/DataStore/ContactDataStore.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef CONTACTDATASTORE_H
|
||||
#define CONTACTDATASTORE_H
|
||||
#include "../Model/ContactItem.h"
|
||||
#include <string>
|
||||
using json = nlohmann::json;
|
||||
|
||||
class ContactDataStore
|
||||
{
|
||||
private:
|
||||
static bool instanced;
|
||||
static ContactDataStore* instance;
|
||||
std::map<QString, ContactItem> data;
|
||||
ContactDataStore()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
static ContactDataStore* getInstance();
|
||||
void clear();
|
||||
void setData(QString key, ContactItem value);
|
||||
ContactItem getData(QString key);
|
||||
QString dump();
|
||||
|
||||
~ContactDataStore()
|
||||
{
|
||||
ContactDataStore::instanced = false;
|
||||
ContactDataStore::instance = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
16
src/DataStore/DataStore.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "DataStore.h"
|
||||
|
||||
SietchDataStore* DataStore::getSietchDataStore()
|
||||
{
|
||||
return SietchDataStore::getInstance();
|
||||
}
|
||||
|
||||
ChatDataStore* DataStore::getChatDataStore()
|
||||
{
|
||||
return ChatDataStore::getInstance();
|
||||
}
|
||||
|
||||
ContactDataStore* DataStore::getContactDataStore()
|
||||
{
|
||||
return ContactDataStore::getInstance();
|
||||
}
|
||||
16
src/DataStore/DataStore.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef DATASTORE_H
|
||||
#define DATASTORE_H
|
||||
|
||||
#include "SietchDataStore.h"
|
||||
#include "ChatDataStore.h"
|
||||
#include "ContactDataStore.h"
|
||||
|
||||
class DataStore
|
||||
{
|
||||
public:
|
||||
static SietchDataStore* getSietchDataStore();
|
||||
static ChatDataStore* getChatDataStore();
|
||||
static ContactDataStore* getContactDataStore();
|
||||
};
|
||||
|
||||
#endif
|
||||
35
src/DataStore/SietchDataStore.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "SietchDataStore.h"
|
||||
|
||||
SietchDataStore* SietchDataStore::getInstance()
|
||||
{
|
||||
if(!SietchDataStore::instanced)
|
||||
{
|
||||
SietchDataStore::instanced = true;
|
||||
SietchDataStore::instance = new SietchDataStore();
|
||||
}
|
||||
|
||||
return SietchDataStore::instance;
|
||||
}
|
||||
|
||||
void SietchDataStore::clear()
|
||||
{
|
||||
this->data.clear();
|
||||
}
|
||||
|
||||
void SietchDataStore::setData(QString key, QString value)
|
||||
{
|
||||
this->data[key] = value;
|
||||
}
|
||||
|
||||
QString SietchDataStore::getData(QString key)
|
||||
{
|
||||
return this->data[key];
|
||||
}
|
||||
|
||||
QString SietchDataStore::dump()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
SietchDataStore* SietchDataStore::instance = nullptr;
|
||||
bool SietchDataStore::instanced = false;
|
||||
31
src/DataStore/SietchDataStore.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef SIETCHDATASTORE_H
|
||||
#define SIETCHDATASTORE_H
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
class SietchDataStore
|
||||
{
|
||||
private:
|
||||
static bool instanced;
|
||||
static SietchDataStore* instance;
|
||||
std::map<QString, QString> data;
|
||||
SietchDataStore()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
static SietchDataStore* getInstance();
|
||||
void clear();
|
||||
void setData(QString key, QString value);
|
||||
QString getData(QString key);
|
||||
QString dump();
|
||||
|
||||
~SietchDataStore()
|
||||
{
|
||||
SietchDataStore::instanced = false;
|
||||
SietchDataStore::instance = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
127
src/FileSystem/FileSystem.cpp
Normal file
@@ -0,0 +1,127 @@
|
||||
#include "FileSystem.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
|
||||
FileSystem::FileSystem()
|
||||
{
|
||||
}
|
||||
|
||||
FileSystem* FileSystem::getInstance()
|
||||
{
|
||||
if(!FileSystem::instanced)
|
||||
{
|
||||
FileSystem::instanced = true;
|
||||
FileSystem::instance = new FileSystem();
|
||||
FileEncryption::showConfig();
|
||||
}
|
||||
|
||||
return FileSystem::instance;
|
||||
}
|
||||
|
||||
/*QList<ContactItem> FileSystem::readContacts(QString file)
|
||||
{
|
||||
//return this->readContactsOldFormat(file); //will be called if addresses are in the old dat-format
|
||||
|
||||
QFile _file(file);
|
||||
if (_file.exists())
|
||||
{
|
||||
std::ifstream f(file.toStdString().c_str(), std::ios::binary);
|
||||
if(f.is_open())
|
||||
{
|
||||
std::vector<unsigned char> buffer(std::istreambuf_iterator<char>(f), {});
|
||||
//todo covert to string to use is as json to feed the data store in addressbook
|
||||
}
|
||||
|
||||
f.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
qInfo() << file << "not exist";
|
||||
}
|
||||
}
|
||||
|
||||
void FileSystem::writeContacts(QString file, QString data)
|
||||
{
|
||||
qDebug() << data;
|
||||
QFile _file(file);
|
||||
if (_file.exists())
|
||||
{
|
||||
std::ofstream f(file.toStdString().c_str());
|
||||
if(f.is_open())
|
||||
{
|
||||
//ENCRYPT HERE
|
||||
|
||||
f << data.toStdString();
|
||||
}
|
||||
|
||||
f.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
qInfo() << file << "not exist";
|
||||
}
|
||||
}
|
||||
|
||||
void FileSystem::writeContactsOldFormat(QString file, QList<ContactItem> contacts)
|
||||
{
|
||||
QFile _file(file);
|
||||
_file.open(QIODevice::ReadWrite | QIODevice::Truncate);
|
||||
QDataStream out(&_file); // we will serialize the data into the file
|
||||
QList<QList<QString>> _contacts;
|
||||
for(auto &item: contacts)
|
||||
{
|
||||
QList<QString> c;
|
||||
c.push_back(item.getName());
|
||||
c.push_back(item.getPartnerAddress());
|
||||
c.push_back(item.getMyAddress());
|
||||
c.push_back(item.getCid());
|
||||
c.push_back(item.getAvatar());
|
||||
_contacts.push_back(c);
|
||||
}
|
||||
out << QString("v0") << _contacts;
|
||||
_file.close();
|
||||
}
|
||||
|
||||
QList<ContactItem> FileSystem::readContactsOldFormat(QString file)
|
||||
{
|
||||
QList<ContactItem> contacts;
|
||||
QFile _file(file);
|
||||
if (_file.exists())
|
||||
{
|
||||
contacts.clear();
|
||||
_file.open(QIODevice::ReadOnly);
|
||||
QDataStream in(&_file); // read the data serialized from the file
|
||||
QString version;
|
||||
in >> version;
|
||||
qDebug() << "Read " << version << " Hush contacts from disk...";
|
||||
qDebug() << "Detected old addressbook format";
|
||||
QList<QList<QString>> stuff;
|
||||
in >> stuff;
|
||||
//qDebug() << "Stuff: " << stuff;
|
||||
for (int i=0; i < stuff.size(); i++)
|
||||
{
|
||||
ContactItem contact = ContactItem(stuff[i][0],stuff[i][1], stuff[i][2], stuff[i][3],stuff[i][4]);
|
||||
contacts.push_back(contact);
|
||||
|
||||
}
|
||||
|
||||
_file.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "No Hush contacts found on disk!";
|
||||
}
|
||||
|
||||
return contacts;
|
||||
}
|
||||
|
||||
FileSystem::~FileSystem()
|
||||
{
|
||||
this->instance = nullptr;
|
||||
this->instanced = false;
|
||||
delete this->instance;
|
||||
}*/
|
||||
|
||||
FileSystem *FileSystem::instance = nullptr;
|
||||
bool FileSystem::instanced = false;
|
||||
31
src/FileSystem/FileSystem.h
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright 2019-2020 The Hush developers
|
||||
// GPLv3
|
||||
#ifndef FILESYSTEM_H
|
||||
#define FILESYSTEM_H
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include "../Model/ContactItem.h"
|
||||
#include "../Crypto/FileEncryption.h"
|
||||
#include <fstream>
|
||||
using json = nlohmann::json;
|
||||
class FileSystem
|
||||
{
|
||||
private:
|
||||
static bool instanced;
|
||||
static FileSystem* instance;
|
||||
FileSystem();
|
||||
|
||||
public:
|
||||
static FileSystem* getInstance();
|
||||
QList<ContactItem> readContacts(QString file);
|
||||
void writeContacts(QString file, QString data);
|
||||
|
||||
//converter
|
||||
QList<ContactItem> readContactsOldFormat(QString file);
|
||||
void writeContactsOldFormat(QString file, QList<ContactItem> contacts);
|
||||
~FileSystem();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
11
src/Logger/LogContext.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef LOGCONTEXT_H
|
||||
#define LOGCONTEXT_H
|
||||
|
||||
#include <string>
|
||||
class LogContext
|
||||
{
|
||||
public:
|
||||
virtual void log(std::string message) {};
|
||||
};
|
||||
|
||||
#endif
|
||||
18
src/Logger/LogCrtitical.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef LOGCRITICAL_H
|
||||
#define LOGCRITICAL_H
|
||||
|
||||
#include "LogType.h"
|
||||
#include "LogStrategy.h"
|
||||
#include "LogWriter.h"
|
||||
|
||||
class LogCritical : public LogStrategy
|
||||
{
|
||||
public:
|
||||
void log(std::string message)
|
||||
{
|
||||
LogWriter* lw = LogWriter::getInstance();
|
||||
lw->write(LogType::CRITICAL, message);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
18
src/Logger/LogDebug.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef LOGDEBUG_H
|
||||
#define LOGDEBUG_H
|
||||
|
||||
#include "LogType.h"
|
||||
#include "LogStrategy.h"
|
||||
#include "LogWriter.h"
|
||||
|
||||
class LogDebug : public LogStrategy
|
||||
{
|
||||
public:
|
||||
void log(std::string message)
|
||||
{
|
||||
LogWriter* lw = LogWriter::getInstance();
|
||||
lw->write(LogType::DEBUG, message);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
18
src/Logger/LogError.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef LOGERROR_H
|
||||
#define LOGERROR_H
|
||||
|
||||
#include "LogType.h"
|
||||
#include "LogStrategy.h"
|
||||
#include "LogWriter.h"
|
||||
|
||||
class LogError : public LogStrategy
|
||||
{
|
||||
public:
|
||||
void log(std::string message)
|
||||
{
|
||||
LogWriter* lw = LogWriter::getInstance();
|
||||
lw->write(LogType::ERROR, message);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
18
src/Logger/LogFatal.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef LOGFATAL_H
|
||||
#define LOGFATAL_H
|
||||
|
||||
#include "LogType.h"
|
||||
#include "LogStrategy.h"
|
||||
#include "LogWriter.h"
|
||||
|
||||
class LogFatal : public LogStrategy
|
||||
{
|
||||
public:
|
||||
void log(std::string message)
|
||||
{
|
||||
LogWriter* lw = LogWriter::getInstance();
|
||||
lw->write(LogType::FATAL, message);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||