Skip to content

Commit 7b06145

Browse files
gui linux impl
1 parent a1a64d4 commit 7b06145

File tree

9 files changed

+52
-59
lines changed

9 files changed

+52
-59
lines changed

keychain_lib/include/keychain_lib/keychain_commands.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ struct keychain_command<command_te::create>: keychain_command_base
589589
pr_hex = to_hex(reinterpret_cast<const uint8_t *>(keys.secret().data()), 32);
590590

591591
filename = hash.hex().substr(0,16);
592-
keyname = params.keyname + "@"+ filename;
592+
keyname = params.keyname ;
593593
filename += ".json";
594594
}
595595
break;

keychain_linux/passentry_gui/include/keychain_gui_win.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class keychain_gui_win : public QDialog
4242
PopupWindow * popupWindow;
4343
void refresh(Transaction&);
4444
PasswordEnterElement * password;
45+
void send(std::string);
46+
47+
bool send_msg;
48+
4549
private:
4650
QString mExpertValue;
4751

@@ -58,10 +62,12 @@ class keychain_gui_win : public QDialog
5862
KeychainWidget * element = Q_NULLPTR;
5963

6064
KeychainServiceExchange * serviceExchange =NULL;
65+
bool passClearOnExit;
6166

6267
private:
6368
void _roundCorners();
6469
void _disableSignButton();
70+
//void closeEvent(QCloseEvent *);
6571

6672
protected:
6773
void keyPressEvent(QKeyEvent *event) override;
@@ -72,7 +78,8 @@ class keychain_gui_win : public QDialog
7278
const int START_POSITION = 96;
7379

7480
public slots:
75-
void transaction_sign();
81+
void found_pass();
7682
void cancel_sign();
7783
void set_sign_focus();
84+
7885
};

keychain_linux/passentry_gui/include/widget.hpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@ class Widget : public QWidget
1717
Widget(keychain_gui_win&, QWidget *parent = 0);
1818
~Widget();
1919
private:
20-
void closeEvent(QCloseEvent *);
2120
void parse(const std::string);
22-
bool passClearOnExit;
21+
2322
keychain_gui_win& gui;
24-
public slots:
25-
void found_pass();
26-
void send(std::string);
2723
signals:
2824
void poll();
2925
};

keychain_linux/passentry_gui/src/BitcoinWidget.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ BitcoinWidget::BitcoinWidget(Transaction &transaction, QWidget * parent)
1010
QString valueStyle("font:16px \"Segoe UI\";background:transparent;color:rgb(123,141,167)");
1111

1212
cryptoType = new SecureWindowElement(this);
13-
cryptoType->SetLabelStyle("background-image:url(:/keychain_gui_win/btc_logo.png) no-repeat;background-size:contain;");
13+
cryptoType->SetLabelStyle("background-image:url(:/keychain_gui_win/btc_logo.png) no-repeat;");
1414
cryptoType->SetValueStyle("font:16px \"Segoe UI\";background:transparent;color:rgb(123,141,167);");
1515
cryptoType->SetLabelAndValue("empty=Bitcoin");
1616

keychain_linux/passentry_gui/src/EthereumWidget.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ EthereumWidget::EthereumWidget(Transaction &transaction, QWidget * parent)
99

1010
QString valueStyle("font:16px \"Segoe UI\";background:transparent;color:rgb(123,141,167);");
1111
QString labelStyle("font:16px \"Segoe UI\";background:transparent;");
12-
cryptoType->SetLabelStyle("background-image:url(:/keychain_gui_win/bg_ephir.png) no-repeat;background-size:contain;");
12+
cryptoType->SetLabelStyle("background-image:url(:/keychain_gui_win/bg_ephir.png) no-repeat;");
1313
cryptoType->SetValueStyle(valueStyle);
1414
cryptoType->SetLabelAndValue("empty=ethereum");
1515

keychain_linux/passentry_gui/src/cmd.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ namespace slave
4646
virtual void operator()(keychain_gui_win& w, const fc_light::variant& v) const override {
4747
try
4848
{
49+
w.send_msg = false;
4950
w.close();
5051
}
5152
catch (const std::exception &e) {throw std::runtime_error(e.what());}

keychain_linux/passentry_gui/src/keychain_gui_win.cpp

+38-15
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#include "keychain_gui_win.h"
2+
#include "cmd.hpp"
23

34
keychain_gui_win::keychain_gui_win(Transaction &transaction, QWidget *parent)
45
: QDialog(parent)
56
{
67
ui.setupUi(this);
78
setWindowFlags(Qt::FramelessWindowHint);
89
setFixedSize(600, 347);
9-
10+
passClearOnExit = true;
11+
send_msg = true;
1012
}
1113

1214
void keychain_gui_win::refresh(Transaction& transaction)
@@ -161,25 +163,16 @@ void keychain_gui_win::refresh(Transaction& transaction)
161163
else
162164
lockIcon->move(width() - 55, 28);
163165
lockIcon->setMouseTracking(true);
164-
this->connect(OKButton, &QPushButton::released, this, &keychain_gui_win::transaction_sign);
165-
this->connect(CancelButton, &QPushButton::released, this, &keychain_gui_win::cancel_sign);
166+
this->connect(OKButton, &QPushButton::released, this, &keychain_gui_win::found_pass);
167+
this->connect(OKButton, &QPushButton::released, this, &keychain_gui_win::close);
168+
this->connect(CancelButton, &QPushButton::released, this, &keychain_gui_win::close);
166169
_roundCorners();
167170
password->setValueFocus();
168-
connect(password, &PasswordEnterElement::finishEnterPassword, this, &keychain_gui_win::transaction_sign);
171+
//connect(password, &PasswordEnterElement::finishEnterPassword, this, &keychain_gui_win::transaction_sign);
169172
//if (transaction.isCreatePassword())
170173
// connect(password, &PasswordEnterElement::changePassword, this, &keychain_gui_win::_disableSignButton);
171174
}
172175

173-
void keychain_gui_win::transaction_sign() {
174-
QString passPhrase("");
175-
passPhrase = password->GetValue();
176-
if (passPhrase.isEmpty()) {
177-
serviceExchange->EncodeError(L"empty_password", 14);
178-
return;
179-
}
180-
serviceExchange->EncodeSuccess(passPhrase.toStdWString(), passPhrase.length());
181-
this->close();
182-
}
183176

184177
void keychain_gui_win::cancel_sign() {
185178
serviceExchange->EncodeCancel();
@@ -251,11 +244,41 @@ void keychain_gui_win::keyPressEvent(QKeyEvent *event)
251244
}
252245
}
253246

254-
247+
/*
255248
void keychain_gui_win::closeEvent(QCloseEvent * event)
256249
{
257250
serviceExchange->EncodeCancel();
258251
this->close();
259252
}
253+
*/
260254

255+
void keychain_gui_win::closeEvent(QCloseEvent *event)
256+
{
257+
if (send_msg)
258+
{
259+
passClearOnExit ?
260+
send(fc_light::json::to_string(fc_light::variant( master::cmd<( master::cmds::cancel)>().base))) :
261+
send(fc_light::json::to_string(fc_light::variant( master::cmd<( master::cmds::ok)>().base)));
262+
}
261263

264+
event->accept();
265+
}
266+
267+
268+
void keychain_gui_win::found_pass() {
269+
//QString passPhrase("");
270+
//passPhrase = password->GetValue();
271+
//if (passPhrase.isEmpty()) {
272+
// serviceExchange->EncodeError(L"empty_password", 14);
273+
// return;
274+
//}
275+
//serviceExchange->EncodeSuccess(passPhrase.toStdWString(), passPhrase.length());
276+
passClearOnExit = false;
277+
//this->close();
278+
}
279+
280+
void keychain_gui_win::send(std::string a)
281+
{
282+
if ( write(STDIN_FILENO, a.c_str(), a.length() ) != a.length() )
283+
close();
284+
}

keychain_linux/passentry_gui/src/main.cpp

-13
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,10 @@
99
#include <keychain_lib/keychain_logger.hpp>
1010

1111

12-
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
13-
{
14-
auto log = logger_singletone::instance();
15-
16-
QByteArray localMsg = msg.toLocal8Bit();
17-
18-
BOOST_LOG_SEV(log.lg, info) << "Debug:" <<localMsg.constData()<< " " << context.file << " "
19-
<< context.line << " " << context.function;
20-
}
21-
22-
2312
int main(int argc, char *argv[])
2413
{
2514
QApplication a(argc, argv);
2615

27-
qInstallMessageHandler(myMessageOutput);
28-
// w.show();
2916
QString value("");
3017
Transaction trans(value);
3118
keychain_gui_win g(trans);

keychain_linux/passentry_gui/src/widget.cpp

+1-22
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ Widget::Widget(keychain_gui_win& gui_, QWidget *parent)
2828
connect(polling, &Polling::err, this, &Widget::close);
2929

3030
pollingThread.start();
31-
passClearOnExit = true;
32-
emit Widget::poll();
31+
emit Widget::poll();
3332
}
3433

3534
Widget::~Widget()
@@ -39,26 +38,6 @@ Widget::~Widget()
3938
}
4039

4140

42-
void Widget::send(std::string a)
43-
{
44-
if ( write(STDIN_FILENO, a.c_str(), a.length() ) != a.length() )
45-
close();
46-
}
47-
48-
49-
50-
void Widget::found_pass()
51-
{
52-
passClearOnExit = false;
53-
}
54-
55-
void Widget::closeEvent(QCloseEvent *event)
56-
{
57-
passClearOnExit ?
58-
send(fc_light::json::to_string(fc_light::variant( master::cmd<( master::cmds::cancel)>().base))) :
59-
send(fc_light::json::to_string(fc_light::variant( master::cmd<( master::cmds::ok)>().base)));
60-
event->accept();
61-
}
6241

6342
void Widget::parse(const std::string s)
6443
{

0 commit comments

Comments
 (0)