forked from blue/squawk
showing the button for encryption if there is at least one omemo key, trust summary update calculations
This commit is contained in:
parent
4f295fee3c
commit
69d797fe51
9 changed files with 134 additions and 39 deletions
|
@ -206,10 +206,10 @@ Shared::TrustSummary Models::Contact::getTrust() const {
|
|||
}
|
||||
|
||||
void Models::Contact::setTrust(const Shared::TrustSummary& p_trust) {
|
||||
//if (trust != p_trust) {
|
||||
if (trust != p_trust) {
|
||||
trust = p_trust;
|
||||
changed(8);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -245,7 +245,11 @@ QString Models::Contact::getDisplayedName() const {
|
|||
}
|
||||
|
||||
void Models::Contact::handleRecconnect() {
|
||||
if (getMessagesCount() > 0) {
|
||||
if (getMessagesCount() > 0)
|
||||
feed->requestLatestMessages();
|
||||
}
|
||||
}
|
||||
|
||||
bool Models::Contact::hasKeys(Shared::EncryptionProtocol protocol) const {
|
||||
return trust.hasKeys(protocol);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
QString getStatus() const;
|
||||
QString getDisplayedName() const override;
|
||||
Shared::TrustSummary getTrust() const;
|
||||
bool hasKeys(Shared::EncryptionProtocol protocol) const;
|
||||
|
||||
void handleRecconnect(); //this is a special method Models::Roster calls when reconnect happens
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
#include "chat.h"
|
||||
#include "ui_conversation.h"
|
||||
|
||||
Chat::Chat(Models::Account* acc, Models::Contact* p_contact, QWidget* parent):
|
||||
Conversation(false, acc, p_contact, p_contact->getJid(), "", parent),
|
||||
|
@ -28,14 +29,14 @@ Chat::Chat(Models::Account* acc, Models::Contact* p_contact, QWidget* parent):
|
|||
setAvatar(p_contact->getAvatarPath());
|
||||
|
||||
connect(contact, &Models::Contact::childChanged, this, &Chat::onContactChanged);
|
||||
if (p_contact->hasKeys(Shared::EncryptionProtocol::omemo2))
|
||||
m_ui->encryptionButton->setVisible(true);
|
||||
}
|
||||
|
||||
Chat::~Chat()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void Chat::onContactChanged(Models::Item* item, int row, int col)
|
||||
{
|
||||
void Chat::onContactChanged(Models::Item* item, int row, int col) {
|
||||
if (item == contact) {
|
||||
switch (col) {
|
||||
case 0:
|
||||
|
@ -50,19 +51,20 @@ void Chat::onContactChanged(Models::Item* item, int row, int col)
|
|||
case 7:
|
||||
setAvatar(contact->getAvatarPath());
|
||||
break;
|
||||
case 8:
|
||||
m_ui->encryptionButton->setVisible(contact->hasKeys(Shared::EncryptionProtocol::omemo2));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Chat::updateState()
|
||||
{
|
||||
void Chat::updateState() {
|
||||
Shared::Availability av = contact->getAvailability();
|
||||
statusIcon->setPixmap(Shared::availabilityIcon(av, true).pixmap(40));
|
||||
statusIcon->setToolTip(Shared::Global::getName(av));
|
||||
}
|
||||
|
||||
Shared::Message Chat::createMessage() const
|
||||
{
|
||||
Shared::Message Chat::createMessage() const {
|
||||
Shared::Message msg = Conversation::createMessage();
|
||||
msg.setType(Shared::Message::chat);
|
||||
msg.setFrom(account->getFullJid());
|
||||
|
@ -71,14 +73,12 @@ Shared::Message Chat::createMessage() const
|
|||
return msg;
|
||||
}
|
||||
|
||||
void Chat::onMessage(const Shared::Message& data)
|
||||
{
|
||||
void Chat::onMessage(const Shared::Message& data){
|
||||
Conversation::onMessage(data);
|
||||
|
||||
if (!data.getOutgoing()) {
|
||||
const QString& res = data.getPenPalResource();
|
||||
if (res.size() > 0) {
|
||||
if (res.size() > 0)
|
||||
setPalResource(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue