merge PR, send request from Contacttab
This commit is contained in:
@@ -5,12 +5,14 @@
|
||||
|
||||
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;
|
||||
_receiverAddress = receiver;
|
||||
_memo = memo;
|
||||
_cid = cid;
|
||||
_label = label;
|
||||
_avatar = avatar;
|
||||
}
|
||||
|
||||
QString ContactRequest::getSenderAddress()
|
||||
@@ -33,6 +35,16 @@ QString ContactRequest::getCid()
|
||||
return _cid;
|
||||
}
|
||||
|
||||
QString ContactRequest::getLabel()
|
||||
{
|
||||
return _label;
|
||||
}
|
||||
|
||||
QString ContactRequest::getAvatar()
|
||||
{
|
||||
return _avatar;
|
||||
}
|
||||
|
||||
void ContactRequest::setSenderAddress(QString address)
|
||||
{
|
||||
_senderAddress = address;
|
||||
@@ -53,9 +65,19 @@ void ContactRequest::setCid(QString cid)
|
||||
_cid = cid;
|
||||
}
|
||||
|
||||
void ContactRequest::setLabel(QString label)
|
||||
{
|
||||
_label = label;
|
||||
}
|
||||
|
||||
void ContactRequest::setAvatar(QString avatar)
|
||||
{
|
||||
_avatar = avatar;
|
||||
}
|
||||
|
||||
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()
|
||||
@@ -64,4 +86,6 @@ ContactRequest::~ContactRequest()
|
||||
_receiverAddress = "";
|
||||
_memo = "";
|
||||
_cid = "";
|
||||
_label = "";
|
||||
_avatar = "";
|
||||
}
|
||||
@@ -14,18 +14,24 @@ class ContactRequest
|
||||
QString _receiverAddress;
|
||||
QString _memo;
|
||||
QString _cid;
|
||||
QString _label;
|
||||
QString _avatar;
|
||||
|
||||
public:
|
||||
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 getReceiverAddress();
|
||||
QString getMemo();
|
||||
QString getCid();
|
||||
QString getLabel();
|
||||
QString getAvatar();
|
||||
void setSenderAddress(QString address);
|
||||
void setReceiverAddress(QString contact);
|
||||
void setMemo(QString memo);
|
||||
void setCid(QString cid);
|
||||
void setLabel(QString label);
|
||||
void setAvatar(QString avatar);
|
||||
QString toString();
|
||||
~ContactRequest();
|
||||
};
|
||||
|
||||
@@ -463,6 +463,8 @@ void::MainWindow::addContact()
|
||||
QDialog dialog(this);
|
||||
request.setupUi(&dialog);
|
||||
Settings::saveRestore(&dialog);
|
||||
|
||||
|
||||
bool sapling = true;
|
||||
rpc->createNewZaddr(sapling, [=] (json reply) {
|
||||
QString myAddr = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||
@@ -471,21 +473,48 @@ void::MainWindow::addContact()
|
||||
ui->listReceiveAddresses->setCurrentIndex(0);
|
||||
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, [&] () {
|
||||
QString cid = request.cid->text();
|
||||
QString addr = request.zaddr->text().trimmed();
|
||||
QString getrequest = addr;
|
||||
QString newLabel = request.labelRequest->text().trimmed();
|
||||
|
||||
QString addr = request.zaddr->text();
|
||||
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.setReceiverAddress(addr);
|
||||
contactRequest.setMemo(newLabel);
|
||||
contactRequest.setMemo(memo);
|
||||
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())
|
||||
{
|
||||
QMessageBox::critical(
|
||||
@@ -520,42 +549,83 @@ void::MainWindow::addContact()
|
||||
QMessageBox::Ok
|
||||
);
|
||||
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
|
||||
Tx MainWindow::createTxForSafeContactRequest()
|
||||
{
|
||||
Tx tx;
|
||||
{
|
||||
CAmount totalAmt;
|
||||
QString amtStr = "0";
|
||||
CAmount amt;
|
||||
amt = CAmount::fromDecimalString("0");
|
||||
totalAmt = totalAmt + amt;
|
||||
for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
|
||||
{
|
||||
if (ui->contactNameMemo->text().trimmed() == c.getName())
|
||||
{
|
||||
QString cid = c.getCid();
|
||||
QString myAddr = c.getMyAddress();
|
||||
|
||||
QString cid = contactRequest.getCid();
|
||||
QString myAddr = contactRequest.getSenderAddress();
|
||||
QString type = "Cont";
|
||||
QString addr = c.getPartnerAddress();
|
||||
qDebug() << contactRequest.toString();
|
||||
QString addr = contactRequest.getReceiverAddress();
|
||||
|
||||
QString hmemo= createHeaderMemo(type,cid,myAddr);
|
||||
QString memo = ui->memoTxtChat->toPlainText().trimmed();
|
||||
QString memo = contactRequest.getMemo();
|
||||
// ui->memoSizeChat->setLenDisplayLabel();// Todo -> activate lendisplay for chat
|
||||
|
||||
tx.toAddrs.push_back(ToFields{addr, amt, hmemo});
|
||||
tx.toAddrs.push_back(ToFields{addr, amt, memo});
|
||||
qDebug() << "pushback chattx";
|
||||
tx.fee = Settings::getMinerFee();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return tx;
|
||||
qDebug() << "RequestTx created";
|
||||
@@ -563,7 +633,7 @@ Tx MainWindow::createTxForSafeContactRequest()
|
||||
|
||||
void MainWindow::ContactRequest() {
|
||||
|
||||
/* if (request.labelRequest->text().trimmed().isEmpty() || request.memorequest->toPlainText().trimmed().isEmpty()) {
|
||||
if (contactRequest.getReceiverAddress().isEmpty() || contactRequest.getMemo().isEmpty()) {
|
||||
|
||||
// auto addr = "";
|
||||
// if (! Settings::isZAddress(AddressBook::addressFromAddressLabel(addr->text()))) {
|
||||
@@ -573,7 +643,7 @@ void MainWindow::ContactRequest() {
|
||||
|
||||
msg.exec();
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
Tx tx = createTxForSafeContactRequest();
|
||||
|
||||
|
||||
@@ -14,21 +14,21 @@
|
||||
<string>Send a contact request</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="2">
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="right">Choose a avatar for your contact :</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Please insert a Nickname for your contact :</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<item row="1" column="3">
|
||||
<widget class="QComboBox" name="comboBoxAvatar">
|
||||
<item>
|
||||
<property name="text">
|
||||
@@ -162,44 +162,54 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLineEdit" name="labelRequest"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Please insert the Address of your contact :</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QLineEdit" name="zaddr"/>
|
||||
</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">
|
||||
<property name="text">
|
||||
<string>Your HushChat Address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</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"/>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>The Conversation ID </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="8" column="0" colspan="2">
|
||||
<widget class="QLabel" name="cid">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<item row="9" column="0">
|
||||
<widget class="QPushButton" name="cancel">
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
@@ -215,7 +225,36 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<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">
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
@@ -224,7 +263,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add Contact</string>
|
||||
<string>Add Contact & send request</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
|
||||
@@ -56,6 +56,8 @@ public:
|
||||
bool isWebsocketListening();
|
||||
void createWebsocket(QString wormholecode);
|
||||
void stopWebsocket();
|
||||
void saveContact();
|
||||
void saveandsendContact();
|
||||
|
||||
|
||||
void balancesReady();
|
||||
|
||||
Reference in New Issue
Block a user