forked from blue/squawk
cant believe it, first ever encrypted messages!
This commit is contained in:
parent
a7d1a28f29
commit
637eb702a8
10 changed files with 190 additions and 69 deletions
|
@ -31,10 +31,12 @@ Chat::Chat(Models::Account* acc, Models::Contact* p_contact, QWidget* parent):
|
|||
setAvatar(p_contact->getAvatarPath());
|
||||
|
||||
connect(contact, &Models::Contact::childChanged, this, &Chat::onContactChanged);
|
||||
#ifdef WITH_OMEMO
|
||||
if (p_contact->hasKeys(Shared::EncryptionProtocol::omemo2)) {
|
||||
m_ui->encryptionButton->setVisible(true);
|
||||
//if ()
|
||||
updateEncryptionState();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Chat::~Chat()
|
||||
|
@ -56,9 +58,14 @@ void Chat::onContactChanged(Models::Item* item, int row, int col) {
|
|||
case 7:
|
||||
setAvatar(contact->getAvatarPath());
|
||||
break;
|
||||
#ifdef WITH_OMEMO
|
||||
case 8:
|
||||
m_ui->encryptionButton->setVisible(contact->hasKeys(Shared::EncryptionProtocol::omemo2));
|
||||
break;
|
||||
case 9:
|
||||
updateEncryptionState();
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,12 +76,25 @@ void Chat::updateState() {
|
|||
statusIcon->setToolTip(Shared::Global::getName(av));
|
||||
}
|
||||
|
||||
void Chat::updateEncryptionState() {
|
||||
m_ui->encryptionButton->setEnabled(true);
|
||||
if (contact->getEncryption() == Shared::EncryptionProtocol::omemo2)
|
||||
m_ui->encryptionButton->setIcon(Shared::icon("lock"));
|
||||
else
|
||||
m_ui->encryptionButton->setIcon(Shared::icon("unlock"));
|
||||
}
|
||||
|
||||
|
||||
Shared::Message Chat::createMessage() const {
|
||||
Shared::Message msg = Conversation::createMessage();
|
||||
msg.setType(Shared::Message::chat);
|
||||
msg.setFrom(account->getFullJid());
|
||||
msg.setToJid(palJid);
|
||||
msg.setToResource(activePalResource);
|
||||
#ifdef WITH_OMEMO
|
||||
if (contact->getEncryption() == Shared::EncryptionProtocol::omemo2)
|
||||
msg.setEncryption(Shared::EncryptionProtocol::omemo2);
|
||||
#endif
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
@ -87,3 +107,11 @@ void Chat::onMessage(const Shared::Message& data){
|
|||
setPalResource(res);
|
||||
}
|
||||
}
|
||||
|
||||
void Chat::onEncryptionButtonClicked() {
|
||||
m_ui->encryptionButton->setEnabled(false);
|
||||
if (contact->getEncryption() == Shared::EncryptionProtocol::omemo2)
|
||||
emit setEncryption(Shared::EncryptionProtocol::none);
|
||||
else
|
||||
emit setEncryption(Shared::EncryptionProtocol::omemo2);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue