feat: omemo signal lib wip

This commit is contained in:
vae 2021-07-22 20:45:39 +03:00
parent 08fe37bfb2
commit 442ad37300
34 changed files with 745 additions and 262 deletions

View file

@ -6,17 +6,19 @@
#include "ui_contactsettings.h"
#include "omemodevices.h"
ContactSettings::ContactSettings(QWidget *parent)
: QDialog(parent), m_ui(new Ui::ContactSettings()) {
ContactSettings::ContactSettings(QString jid, QWidget *parent)
: QDialog(parent), jid(std::move(jid)), m_ui(new Ui::ContactSettings()) {
m_ui->setupUi(this);
connect(m_ui->devicesButton, &QPushButton::clicked, this, &ContactSettings::openDeviceList);
setWindowTitle(QString("Encryption settings for %1").arg(this->jid));
}
ContactSettings::~ContactSettings() {}
void ContactSettings::openDeviceList() {
auto devices = new OMEMODevices(this);
auto devices = new OMEMODevices(jid, this);
devices->setAttribute(Qt::WA_DeleteOnClose);
devices->show();

View file

@ -13,9 +13,11 @@ namespace Ui {
class ContactSettings : public QDialog {
Q_OBJECT
public:
explicit ContactSettings(QWidget *parent = nullptr);
explicit ContactSettings(QString jid, QWidget *parent = nullptr);
~ContactSettings() override;
const QString jid;
private slots:
void openDeviceList();

View file

@ -5,9 +5,11 @@
#include "omemodevices.h"
#include "ui_omemodevices.h"
OMEMODevices::OMEMODevices(QWidget *parent)
: QDialog(parent), m_ui(new Ui::OMEMODevices()) {
OMEMODevices::OMEMODevices(QString jid, QWidget *parent)
: QDialog(parent), jid(std::move(jid)), m_ui(new Ui::OMEMODevices()) {
m_ui->setupUi(this);
setWindowTitle(QString("%1's OMEMO devices").arg(this->jid));
}
OMEMODevices::~OMEMODevices() {}

View file

@ -13,9 +13,11 @@ namespace Ui {
class OMEMODevices : public QDialog {
Q_OBJECT
public:
explicit OMEMODevices(QWidget *parent = nullptr);
explicit OMEMODevices(QString jid, QWidget *parent = nullptr);
~OMEMODevices() override;
const QString jid;
private:
QScopedPointer<Ui::OMEMODevices> m_ui;
};

View file

@ -20,6 +20,7 @@
#include "ui_squawk.h"
#include <QDebug>
#include <QIcon>
#include <utility>
#include <ui/omemo/omemodevices.h>
Squawk::Squawk(QWidget *parent) :
@ -61,7 +62,6 @@ Squawk::Squawk(QWidget *parent) :
connect(m_ui->roster, &QTreeView::collapsed, this, &Squawk::onItemCollepsed);
connect(m_ui->roster->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &Squawk::onRosterSelectionChanged);
connect(&rosterModel, &Models::Roster::unnoticedMessage, this, &Squawk::onUnnoticedMessage);
connect(m_ui->actionDeviceList, &QAction::triggered, this, &Squawk::onOMEMODevices);
connect(rosterModel.accountsModel, &Models::Accounts::sizeChanged, this, &Squawk::onAccountsSizeChanged);
connect(&rosterModel, &Models::Roster::requestArchive, this, &Squawk::onRequestArchive);
@ -136,8 +136,8 @@ void Squawk::onNewContact()
nc->exec();
}
void Squawk::onOMEMODevices() {
auto od = new OMEMODevices(this);
void Squawk::openDeviceList(QString bareJid) {
auto od = new OMEMODevices(std::move(bareJid), this);
od->setAttribute(Qt::WA_DeleteOnClose);
od->show();
@ -539,6 +539,10 @@ void Squawk::onRosterContextMenu(const QPoint& point)
emit connectAccount(name);
});
}
QAction* devices = contextMenu->addAction(Shared::icon("security-high"), tr("Devices"));
devices->setEnabled(active);
connect(devices, &QAction::triggered, [this, acc]() { openDeviceList(acc->getBareJid()); });
QAction* card = contextMenu->addAction(Shared::icon("user-properties"), tr("VCard"));
card->setEnabled(active);

View file

@ -155,7 +155,7 @@ private slots:
void onPasswordPromptRejected();
void onRosterSelectionChanged(const QModelIndex& current, const QModelIndex& previous);
void onContextAboutToHide();
void onOMEMODevices();
void openDeviceList(QString bareJid);
void onUnnoticedMessage(const QString& account, const Shared::Message& msg);

View file

@ -169,17 +169,7 @@
<property name="title">
<string>Settings</string>
</property>
<widget class="QMenu" name="menuOMEMO">
<property name="title">
<string>OMEMO</string>
</property>
<property name="icon">
<iconset theme="security-high"/>
</property>
<addaction name="actionDeviceList"/>
</widget>
<addaction name="actionAccounts"/>
<addaction name="menuOMEMO"/>
</widget>
<widget class="QMenu" name="menuFile">
<property name="title">
@ -236,7 +226,8 @@
</action>
<action name="actionDeviceList">
<property name="icon">
<iconset theme="computer-laptop"/>
<iconset theme="computer-laptop">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="text">
<string>Device list</string>

View file

@ -437,7 +437,7 @@ void Conversation::onFeedContext(const QPoint& pos)
}
void Conversation::openEncryptionSettings() {
auto cs = new ContactSettings(this);
auto cs = new ContactSettings(palJid, this);
cs->setAttribute(Qt::WA_DeleteOnClose);
cs->show();