merge PR, send request from Contacttab
This commit is contained in:
@@ -5,12 +5,14 @@
|
|||||||
|
|
||||||
ContactRequest::ContactRequest() {}
|
ContactRequest::ContactRequest() {}
|
||||||
|
|
||||||
ContactRequest::ContactRequest(QString sender, QString receiver, QString memo, QString cid)
|
ContactRequest::ContactRequest(QString sender, QString receiver, QString memo, QString cid, QString label, QString avatar)
|
||||||
{
|
{
|
||||||
_senderAddress = sender;
|
_senderAddress = sender;
|
||||||
_receiverAddress = receiver;
|
_receiverAddress = receiver;
|
||||||
_memo = memo;
|
_memo = memo;
|
||||||
_cid = cid;
|
_cid = cid;
|
||||||
|
_label = label;
|
||||||
|
_avatar = avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ContactRequest::getSenderAddress()
|
QString ContactRequest::getSenderAddress()
|
||||||
@@ -33,6 +35,16 @@ QString ContactRequest::getCid()
|
|||||||
return _cid;
|
return _cid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ContactRequest::getLabel()
|
||||||
|
{
|
||||||
|
return _label;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ContactRequest::getAvatar()
|
||||||
|
{
|
||||||
|
return _avatar;
|
||||||
|
}
|
||||||
|
|
||||||
void ContactRequest::setSenderAddress(QString address)
|
void ContactRequest::setSenderAddress(QString address)
|
||||||
{
|
{
|
||||||
_senderAddress = address;
|
_senderAddress = address;
|
||||||
@@ -53,9 +65,19 @@ void ContactRequest::setCid(QString cid)
|
|||||||
_cid = cid;
|
_cid = cid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContactRequest::setLabel(QString label)
|
||||||
|
{
|
||||||
|
_label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContactRequest::setAvatar(QString avatar)
|
||||||
|
{
|
||||||
|
_avatar = avatar;
|
||||||
|
}
|
||||||
|
|
||||||
QString ContactRequest::toString()
|
QString ContactRequest::toString()
|
||||||
{
|
{
|
||||||
return "sender: " + _senderAddress + " receiver: " + _receiverAddress + " memo: " + _memo + " cid: " + _cid;
|
return "sender: " + _senderAddress + " receiver: " + _receiverAddress + " memo: " + _memo + " cid: " + _cid + " label: " + _label + " avatar: " + _avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContactRequest::~ContactRequest()
|
ContactRequest::~ContactRequest()
|
||||||
@@ -64,4 +86,6 @@ ContactRequest::~ContactRequest()
|
|||||||
_receiverAddress = "";
|
_receiverAddress = "";
|
||||||
_memo = "";
|
_memo = "";
|
||||||
_cid = "";
|
_cid = "";
|
||||||
|
_label = "";
|
||||||
|
_avatar = "";
|
||||||
}
|
}
|
||||||
@@ -14,18 +14,24 @@ class ContactRequest
|
|||||||
QString _receiverAddress;
|
QString _receiverAddress;
|
||||||
QString _memo;
|
QString _memo;
|
||||||
QString _cid;
|
QString _cid;
|
||||||
|
QString _label;
|
||||||
|
QString _avatar;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ContactRequest();
|
ContactRequest();
|
||||||
ContactRequest(QString sender, QString receiver, QString memo, QString cid);
|
ContactRequest(QString sender, QString receiver, QString memo, QString cid, QString label, QString avatar);
|
||||||
QString getSenderAddress();
|
QString getSenderAddress();
|
||||||
QString getReceiverAddress();
|
QString getReceiverAddress();
|
||||||
QString getMemo();
|
QString getMemo();
|
||||||
QString getCid();
|
QString getCid();
|
||||||
|
QString getLabel();
|
||||||
|
QString getAvatar();
|
||||||
void setSenderAddress(QString address);
|
void setSenderAddress(QString address);
|
||||||
void setReceiverAddress(QString contact);
|
void setReceiverAddress(QString contact);
|
||||||
void setMemo(QString memo);
|
void setMemo(QString memo);
|
||||||
void setCid(QString cid);
|
void setCid(QString cid);
|
||||||
|
void setLabel(QString label);
|
||||||
|
void setAvatar(QString avatar);
|
||||||
QString toString();
|
QString toString();
|
||||||
~ContactRequest();
|
~ContactRequest();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -463,6 +463,8 @@ void::MainWindow::addContact()
|
|||||||
QDialog dialog(this);
|
QDialog dialog(this);
|
||||||
request.setupUi(&dialog);
|
request.setupUi(&dialog);
|
||||||
Settings::saveRestore(&dialog);
|
Settings::saveRestore(&dialog);
|
||||||
|
|
||||||
|
|
||||||
bool sapling = true;
|
bool sapling = true;
|
||||||
rpc->createNewZaddr(sapling, [=] (json reply) {
|
rpc->createNewZaddr(sapling, [=] (json reply) {
|
||||||
QString myAddr = QString::fromStdString(reply.get<json::array_t>()[0]);
|
QString myAddr = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
@@ -471,21 +473,48 @@ void::MainWindow::addContact()
|
|||||||
ui->listReceiveAddresses->setCurrentIndex(0);
|
ui->listReceiveAddresses->setCurrentIndex(0);
|
||||||
qDebug() << "new generated myAddr" << myAddr;
|
qDebug() << "new generated myAddr" << myAddr;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QString cid = QUuid::createUuid().toString(QUuid::WithoutBraces);
|
||||||
|
request.cid->setText(cid);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString cid = QUuid::createUuid().toString(QUuid::WithoutBraces);
|
|
||||||
request.cid->setText(cid);
|
|
||||||
|
|
||||||
QObject::connect(request.sendRequestButton, &QPushButton::clicked, [&] () {
|
QObject::connect(request.sendRequestButton, &QPushButton::clicked, [&] () {
|
||||||
QString cid = request.cid->text();
|
|
||||||
QString addr = request.zaddr->text().trimmed();
|
QString addr = request.zaddr->text();
|
||||||
QString getrequest = addr;
|
|
||||||
QString newLabel = request.labelRequest->text().trimmed();
|
|
||||||
QString myAddr = request.myzaddr->text().trimmed();
|
QString myAddr = request.myzaddr->text().trimmed();
|
||||||
|
QString memo = request.memorequest->toPlainText().trimmed();
|
||||||
|
QString avatar = QString(":/icons/res/") + request.comboBoxAvatar->currentText() + QString(".png");
|
||||||
|
QString label = request.labelRequest->text().trimmed();
|
||||||
|
|
||||||
|
|
||||||
contactRequest.setSenderAddress(myAddr);
|
contactRequest.setSenderAddress(myAddr);
|
||||||
contactRequest.setReceiverAddress(addr);
|
contactRequest.setReceiverAddress(addr);
|
||||||
contactRequest.setMemo(newLabel);
|
contactRequest.setMemo(memo);
|
||||||
contactRequest.setCid(cid);
|
contactRequest.setCid(cid);
|
||||||
QString avatar = QString(":/icons/res/") + request.comboBoxAvatar->currentText() + QString(".png");
|
contactRequest.setAvatar(avatar);
|
||||||
|
contactRequest.setLabel(label);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
QObject::connect(request.sendRequestButton, &QPushButton::clicked, this, &MainWindow::saveandsendContact);
|
||||||
|
QObject::connect(request.onlyAdd, &QPushButton::clicked, this, &MainWindow::saveContact);
|
||||||
|
|
||||||
|
dialog.exec();
|
||||||
|
|
||||||
|
rpc->refreshContacts(ui->listContactWidget);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::saveandsendContact()
|
||||||
|
{
|
||||||
|
this->ContactRequest();
|
||||||
|
QString addr = contactRequest.getReceiverAddress();
|
||||||
|
QString newLabel = contactRequest.getLabel();
|
||||||
|
QString myAddr = contactRequest.getSenderAddress();
|
||||||
|
QString cid = contactRequest.getCid();
|
||||||
|
QString avatar = contactRequest.getAvatar();
|
||||||
|
|
||||||
if (addr.isEmpty() || newLabel.isEmpty())
|
if (addr.isEmpty() || newLabel.isEmpty())
|
||||||
{
|
{
|
||||||
QMessageBox::critical(
|
QMessageBox::critical(
|
||||||
@@ -520,42 +549,83 @@ void::MainWindow::addContact()
|
|||||||
QMessageBox::Ok
|
QMessageBox::Ok
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
});
|
|
||||||
|
|
||||||
dialog.exec();
|
|
||||||
rpc->refreshContacts(ui->listContactWidget);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::saveContact()
|
||||||
|
{
|
||||||
|
|
||||||
|
QString addr = contactRequest.getReceiverAddress();
|
||||||
|
QString newLabel = contactRequest.getLabel();
|
||||||
|
QString myAddr = contactRequest.getSenderAddress();
|
||||||
|
QString cid = contactRequest.getCid();
|
||||||
|
QString avatar = contactRequest.getAvatar();
|
||||||
|
|
||||||
|
if (addr.isEmpty() || newLabel.isEmpty())
|
||||||
|
{
|
||||||
|
QMessageBox::critical(
|
||||||
|
this,
|
||||||
|
QObject::tr("Address or Label Error"),
|
||||||
|
QObject::tr("Address or Label cannot be empty"),
|
||||||
|
QMessageBox::Ok
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test if address is valid.
|
||||||
|
if (!Settings::isValidAddress(addr))
|
||||||
|
{
|
||||||
|
QMessageBox::critical(
|
||||||
|
this,
|
||||||
|
QObject::tr("Address Format Error"),
|
||||||
|
QObject::tr("%1 doesn't seem to be a valid hush address.").arg(addr),
|
||||||
|
QMessageBox::Ok
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////Todo: Test if label allready exist!
|
||||||
|
|
||||||
|
////// Success, so show it
|
||||||
|
AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid, avatar);
|
||||||
|
QMessageBox::information(
|
||||||
|
this,
|
||||||
|
QObject::tr("Added Contact"),
|
||||||
|
QObject::tr("successfully added your new contact").arg(newLabel),
|
||||||
|
QMessageBox::Ok
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Create a Tx for a contact Request
|
// Create a Tx for a contact Request
|
||||||
Tx MainWindow::createTxForSafeContactRequest()
|
Tx MainWindow::createTxForSafeContactRequest()
|
||||||
{
|
{
|
||||||
Tx tx;
|
Tx tx;
|
||||||
|
{
|
||||||
CAmount totalAmt;
|
CAmount totalAmt;
|
||||||
QString amtStr = "0";
|
QString amtStr = "0";
|
||||||
CAmount amt;
|
CAmount amt;
|
||||||
amt = CAmount::fromDecimalString("0");
|
amt = CAmount::fromDecimalString("0");
|
||||||
totalAmt = totalAmt + amt;
|
totalAmt = totalAmt + amt;
|
||||||
for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
|
|
||||||
{
|
QString cid = contactRequest.getCid();
|
||||||
if (ui->contactNameMemo->text().trimmed() == c.getName())
|
QString myAddr = contactRequest.getSenderAddress();
|
||||||
{
|
|
||||||
QString cid = c.getCid();
|
|
||||||
QString myAddr = c.getMyAddress();
|
|
||||||
QString type = "Cont";
|
QString type = "Cont";
|
||||||
QString addr = c.getPartnerAddress();
|
QString addr = contactRequest.getReceiverAddress();
|
||||||
qDebug() << contactRequest.toString();
|
|
||||||
QString hmemo= createHeaderMemo(type,cid,myAddr);
|
QString hmemo= createHeaderMemo(type,cid,myAddr);
|
||||||
QString memo = ui->memoTxtChat->toPlainText().trimmed();
|
QString memo = contactRequest.getMemo();
|
||||||
// ui->memoSizeChat->setLenDisplayLabel();// Todo -> activate lendisplay for chat
|
// ui->memoSizeChat->setLenDisplayLabel();// Todo -> activate lendisplay for chat
|
||||||
|
|
||||||
tx.toAddrs.push_back(ToFields{addr, amt, hmemo});
|
tx.toAddrs.push_back(ToFields{addr, amt, hmemo});
|
||||||
tx.toAddrs.push_back(ToFields{addr, amt, memo});
|
tx.toAddrs.push_back(ToFields{addr, amt, memo});
|
||||||
qDebug() << "pushback chattx";
|
qDebug() << "pushback chattx";
|
||||||
tx.fee = Settings::getMinerFee();
|
tx.fee = Settings::getMinerFee();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tx;
|
return tx;
|
||||||
qDebug() << "RequestTx created";
|
qDebug() << "RequestTx created";
|
||||||
@@ -563,7 +633,7 @@ Tx MainWindow::createTxForSafeContactRequest()
|
|||||||
|
|
||||||
void MainWindow::ContactRequest() {
|
void MainWindow::ContactRequest() {
|
||||||
|
|
||||||
/* if (request.labelRequest->text().trimmed().isEmpty() || request.memorequest->toPlainText().trimmed().isEmpty()) {
|
if (contactRequest.getReceiverAddress().isEmpty() || contactRequest.getMemo().isEmpty()) {
|
||||||
|
|
||||||
// auto addr = "";
|
// auto addr = "";
|
||||||
// if (! Settings::isZAddress(AddressBook::addressFromAddressLabel(addr->text()))) {
|
// if (! Settings::isZAddress(AddressBook::addressFromAddressLabel(addr->text()))) {
|
||||||
@@ -573,7 +643,7 @@ void MainWindow::ContactRequest() {
|
|||||||
|
|
||||||
msg.exec();
|
msg.exec();
|
||||||
return;
|
return;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
Tx tx = createTxForSafeContactRequest();
|
Tx tx = createTxForSafeContactRequest();
|
||||||
|
|
||||||
|
|||||||
@@ -14,21 +14,21 @@
|
|||||||
<string>Send a contact request</string>
|
<string>Send a contact request</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="2">
|
<item row="0" column="3">
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><html><head/><body><p align="right">Choose a avatar for your contact :</p></body></html></string>
|
<string><html><head/><body><p align="right">Choose a avatar for your contact :</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><html><head/><body><p>Please insert a Nickname for your contact :</p></body></html></string>
|
<string><html><head/><body><p>Please insert a Nickname for your contact :</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="1" column="3">
|
||||||
<widget class="QComboBox" name="comboBoxAvatar">
|
<widget class="QComboBox" name="comboBoxAvatar">
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -162,44 +162,54 @@
|
|||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0" colspan="2">
|
||||||
<widget class="QLineEdit" name="labelRequest"/>
|
<widget class="QLineEdit" name="labelRequest"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><html><head/><body><p>Please insert the Address of your contact :</p></body></html></string>
|
<string><html><head/><body><p>Please insert the Address of your contact :</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="4" column="0" colspan="2">
|
||||||
<widget class="QLineEdit" name="zaddr"/>
|
<widget class="QLineEdit" name="zaddr"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="4" column="2" colspan="2">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Insert a memo for the request</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Your HushChat Address</string>
|
<string>Your HushChat Address</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="5" column="2" rowspan="4" colspan="2">
|
||||||
|
<widget class="QTextEdit" name="memorequest"/>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0" colspan="2">
|
||||||
<widget class="QLineEdit" name="myzaddr"/>
|
<widget class="QLineEdit" name="myzaddr"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0">
|
<item row="7" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QLabel" name="label_5">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>The Conversation ID </string>
|
<string>The Conversation ID </string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0">
|
<item row="8" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="cid">
|
<widget class="QLabel" name="cid">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="1">
|
<item row="9" column="0">
|
||||||
<widget class="QPushButton" name="cancel">
|
<widget class="QPushButton" name="cancel">
|
||||||
<property name="baseSize">
|
<property name="baseSize">
|
||||||
<size>
|
<size>
|
||||||
@@ -215,7 +225,36 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="9" column="1">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>278</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item row="9" column="2">
|
<item row="9" column="2">
|
||||||
|
<widget class="QPushButton" name="onlyAdd">
|
||||||
|
<property name="baseSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Only add this contact</string>
|
||||||
|
</property>
|
||||||
|
<property name="flat">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="3">
|
||||||
<widget class="QPushButton" name="sendRequestButton">
|
<widget class="QPushButton" name="sendRequestButton">
|
||||||
<property name="baseSize">
|
<property name="baseSize">
|
||||||
<size>
|
<size>
|
||||||
@@ -224,7 +263,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add Contact</string>
|
<string>Add Contact & send request</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="flat">
|
<property name="flat">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ public:
|
|||||||
bool isWebsocketListening();
|
bool isWebsocketListening();
|
||||||
void createWebsocket(QString wormholecode);
|
void createWebsocket(QString wormholecode);
|
||||||
void stopWebsocket();
|
void stopWebsocket();
|
||||||
|
void saveContact();
|
||||||
|
void saveandsendContact();
|
||||||
|
|
||||||
|
|
||||||
void balancesReady();
|
void balancesReady();
|
||||||
|
|||||||
Reference in New Issue
Block a user