forked from blue/squawk
some work towards encryption
This commit is contained in:
parent
297e08ba41
commit
a7d1a28f29
21 changed files with 129 additions and 81 deletions
|
@ -36,6 +36,10 @@ Models::Contact::Contact(const Account* acc, const QString& p_jid ,const QMap<QS
|
|||
itr = data.find("trust");
|
||||
if (itr != data.end())
|
||||
setTrust(itr.value().value<Shared::TrustSummary>());
|
||||
|
||||
itr = data.find("encryption");
|
||||
if (itr != data.end())
|
||||
setEncryption(itr.value().value<Shared::EncryptionProtocol>());
|
||||
}
|
||||
|
||||
Models::Contact::~Contact() {}
|
||||
|
@ -71,7 +75,7 @@ void Models::Contact::setStatus(const QString& p_state) {
|
|||
}
|
||||
|
||||
int Models::Contact::columnCount() const {
|
||||
return 9;
|
||||
return 10;
|
||||
}
|
||||
|
||||
QVariant Models::Contact::data(int column) const {
|
||||
|
@ -94,6 +98,8 @@ QVariant Models::Contact::data(int column) const {
|
|||
return getAvatarPath();
|
||||
case 8:
|
||||
return QVariant::fromValue(getTrust());
|
||||
case 9:
|
||||
return QVariant::fromValue(getEncryption());
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -115,6 +121,8 @@ void Models::Contact::update(const QString& field, const QVariant& value) {
|
|||
setState(value.toUInt());
|
||||
} else if (field == "trust") {
|
||||
setTrust(value.value<Shared::TrustSummary>());
|
||||
} else if (field == "encryption") {
|
||||
setEncryption(value.value<Shared::EncryptionProtocol>());
|
||||
} else {
|
||||
Element::update(field, value);
|
||||
}
|
||||
|
@ -254,3 +262,18 @@ bool Models::Contact::hasKeys(Shared::EncryptionProtocol protocol) const {
|
|||
return trust.hasKeys(protocol);
|
||||
}
|
||||
|
||||
void Models::Contact::setEncryption(Shared::EncryptionProtocol p_enc) {
|
||||
if (encryption != p_enc) {
|
||||
encryption = p_enc;
|
||||
changed(9);
|
||||
}
|
||||
}
|
||||
|
||||
void Models::Contact::setEncryption(unsigned int p_enc) {
|
||||
setEncryption(Shared::Global::fromInt<Shared::EncryptionProtocol>(p_enc));
|
||||
}
|
||||
|
||||
Shared::EncryptionProtocol Models::Contact::getEncryption() const {
|
||||
return encryption;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
|
||||
Shared::Availability getAvailability() const;
|
||||
Shared::SubscriptionState getState() const;
|
||||
Shared::EncryptionProtocol getEncryption() const;
|
||||
|
||||
QIcon getStatusIcon(bool big = false) const;
|
||||
|
||||
|
@ -78,6 +79,8 @@ protected:
|
|||
void setState(unsigned int p_state);
|
||||
void setStatus(const QString& p_state);
|
||||
void setTrust(const Shared::TrustSummary& p_trust);
|
||||
void setEncryption(Shared::EncryptionProtocol p_enc);
|
||||
void setEncryption(unsigned int p_enc);
|
||||
|
||||
private:
|
||||
Shared::Availability availability;
|
||||
|
|
|
@ -37,11 +37,11 @@ Squawk::Squawk(Models::Roster& p_rosterModel, QWidget *parent) :
|
|||
m_ui->setupUi(this);
|
||||
m_ui->roster->setModel(&rosterModel);
|
||||
m_ui->roster->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
if (QApplication::style()->styleHint(QStyle::SH_ScrollBar_Transient) == 1) {
|
||||
if (QApplication::style()->styleHint(QStyle::SH_ScrollBar_Transient) == 1)
|
||||
m_ui->roster->setColumnWidth(1, 52);
|
||||
} else {
|
||||
else
|
||||
m_ui->roster->setColumnWidth(1, 26);
|
||||
}
|
||||
|
||||
m_ui->roster->setIconSize(QSize(20, 20));
|
||||
m_ui->roster->header()->setStretchLastSection(false);
|
||||
m_ui->roster->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
|
@ -69,24 +69,24 @@ Squawk::Squawk(Models::Roster& p_rosterModel, QWidget *parent) :
|
|||
connect(m_ui->actionAboutSquawk, &QAction::triggered, this, &Squawk::onAboutSquawkCalled);
|
||||
//m_ui->mainToolBar->addWidget(m_ui->comboBox);
|
||||
|
||||
if (testAttribute(Qt::WA_TranslucentBackground)) {
|
||||
if (testAttribute(Qt::WA_TranslucentBackground))
|
||||
m_ui->roster->viewport()->setAutoFillBackground(false);
|
||||
}
|
||||
|
||||
|
||||
QSettings settings;
|
||||
settings.beginGroup("ui");
|
||||
settings.beginGroup("window");
|
||||
if (settings.contains("geometry")) {
|
||||
if (settings.contains("geometry"))
|
||||
restoreGeometry(settings.value("geometry").toByteArray());
|
||||
}
|
||||
if (settings.contains("state")) {
|
||||
|
||||
if (settings.contains("state"))
|
||||
restoreState(settings.value("state").toByteArray());
|
||||
}
|
||||
|
||||
settings.endGroup();
|
||||
|
||||
if (settings.contains("splitter")) {
|
||||
if (settings.contains("splitter"))
|
||||
m_ui->splitter->restoreState(settings.value("splitter").toByteArray());
|
||||
}
|
||||
|
||||
settings.endGroup();
|
||||
|
||||
onAccountsChanged();
|
||||
|
@ -181,8 +181,10 @@ void Squawk::onJoinConferenceAccepted() {
|
|||
void Squawk::closeEvent(QCloseEvent* event) {
|
||||
if (accounts != nullptr)
|
||||
accounts->close();
|
||||
|
||||
if (preferences != nullptr)
|
||||
preferences->close();
|
||||
|
||||
if (about != nullptr)
|
||||
about->close();
|
||||
|
||||
|
@ -221,9 +223,9 @@ void Squawk::stateChanged(Shared::Availability state) {
|
|||
void Squawk::onRosterItemDoubleClicked(const QModelIndex& item) {
|
||||
if (item.isValid()) {
|
||||
Models::Item* node = static_cast<Models::Item*>(item.internalPointer());
|
||||
if (node->type == Models::Item::reference) {
|
||||
if (node->type == Models::Item::reference)
|
||||
node = static_cast<Models::Reference*>(node)->dereference();
|
||||
}
|
||||
|
||||
Models::Contact* contact = nullptr;
|
||||
Models::Room* room = nullptr;
|
||||
switch (node->type) {
|
||||
|
@ -258,9 +260,9 @@ void Squawk::onRosterContextMenu(const QPoint& point) {
|
|||
QModelIndex index = m_ui->roster->indexAt(point);
|
||||
if (index.isValid()) {
|
||||
Models::Item* item = static_cast<Models::Item*>(index.internalPointer());
|
||||
if (item->type == Models::Item::reference) {
|
||||
if (item->type == Models::Item::reference)
|
||||
item = static_cast<Models::Reference*>(item)->dereference();
|
||||
}
|
||||
|
||||
contextMenu->clear();
|
||||
bool hasMenu = false;
|
||||
bool active = item->getAccountConnectionState() == Shared::ConnectionState::connected;
|
||||
|
@ -320,9 +322,9 @@ void Squawk::onRosterContextMenu(const QPoint& point) {
|
|||
QInputDialog* dialog = new QInputDialog(this);
|
||||
connect(dialog, &QDialog::accepted, [this, dialog, cntName, id]() {
|
||||
QString newName = dialog->textValue();
|
||||
if (newName != cntName) {
|
||||
if (newName != cntName)
|
||||
emit renameContactRequest(id.account, id.name, newName);
|
||||
}
|
||||
|
||||
dialog->deleteLater();
|
||||
});
|
||||
connect(dialog, &QDialog::rejected, dialog, &QObject::deleteLater);
|
||||
|
@ -342,11 +344,10 @@ void Squawk::onRosterContextMenu(const QPoint& point) {
|
|||
gr->setChecked(rosterModel.groupHasContact(id.account, groupName, id.name));
|
||||
gr->setEnabled(active);
|
||||
connect(gr, &QAction::toggled, [this, groupName, id](bool checked) {
|
||||
if (checked) {
|
||||
if (checked)
|
||||
emit addContactToGroupRequest(id.account, id.name, groupName);
|
||||
} else {
|
||||
else
|
||||
emit removeContactFromGroupRequest(id.account, id.name, groupName);
|
||||
}
|
||||
});
|
||||
}
|
||||
QAction* newGroup = groupsMenu->addAction(Shared::icon("group-new"), tr("New group"));
|
||||
|
@ -405,9 +406,8 @@ void Squawk::onRosterContextMenu(const QPoint& point) {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
if (hasMenu) {
|
||||
if (hasMenu)
|
||||
contextMenu->popup(m_ui->roster->viewport()->mapToGlobal(point));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -515,9 +515,9 @@ void Squawk::onRosterSelectionChanged(const QModelIndex& current, const QModelIn
|
|||
}
|
||||
|
||||
if (hasContext && QGuiApplication::mouseButtons() & Qt::RightButton) {
|
||||
if (id != nullptr) {
|
||||
if (id != nullptr)
|
||||
delete id;
|
||||
}
|
||||
|
||||
needToRestore = true;
|
||||
restoreSelection = previous;
|
||||
return;
|
||||
|
@ -538,20 +538,19 @@ void Squawk::onRosterSelectionChanged(const QModelIndex& current, const QModelIn
|
|||
}
|
||||
|
||||
Models::Account* acc = rosterModel.getAccount(id->account);
|
||||
if (contact != nullptr) {
|
||||
if (contact != nullptr)
|
||||
currentConversation = new Chat(acc, contact);
|
||||
} else if (room != nullptr) {
|
||||
else if (room != nullptr)
|
||||
currentConversation = new Room(acc, room);
|
||||
}
|
||||
if (!testAttribute(Qt::WA_TranslucentBackground)) {
|
||||
|
||||
if (!testAttribute(Qt::WA_TranslucentBackground))
|
||||
currentConversation->setFeedFrames(true, false, true, true);
|
||||
}
|
||||
|
||||
|
||||
emit openedConversation();
|
||||
|
||||
if (res.size() > 0) {
|
||||
if (res.size() > 0)
|
||||
currentConversation->setPalResource(res);
|
||||
}
|
||||
|
||||
m_ui->splitter->insertWidget(1, currentConversation);
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <QScopedPointer>
|
||||
#include <QCloseEvent>
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
#include <QInputDialog>
|
||||
|
||||
#include <deque>
|
||||
|
@ -50,8 +51,7 @@ class Squawk;
|
|||
|
||||
class Application;
|
||||
|
||||
class Squawk : public QMainWindow
|
||||
{
|
||||
class Squawk : public QMainWindow {
|
||||
Q_OBJECT
|
||||
friend class Application;
|
||||
public:
|
||||
|
|
|
@ -46,13 +46,11 @@
|
|||
#include "ui/widgets/messageline/feedview.h"
|
||||
#include "ui/widgets/messageline/messagedelegate.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
namespace Ui {
|
||||
class Conversation;
|
||||
}
|
||||
|
||||
class KeyEnterReceiver : public QObject
|
||||
{
|
||||
class KeyEnterReceiver : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
KeyEnterReceiver(QObject* parent = 0);
|
||||
|
@ -65,8 +63,7 @@ signals:
|
|||
void imagePasted();
|
||||
};
|
||||
|
||||
class Conversation : public QWidget
|
||||
{
|
||||
class Conversation : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Conversation(bool muc, Models::Account* acc, Models::Element* el, const QString pJid, const QString pRes, QWidget* parent = 0);
|
||||
|
@ -91,6 +88,7 @@ signals:
|
|||
void requestLocalFile(const QString& messageId, const QString& url);
|
||||
void downloadFile(const QString& messageId, const QString& url);
|
||||
void notifyableMessage(const QString& account, const Shared::Message& msg);
|
||||
void setEncryption(Shared::EncryptionProtocol value);
|
||||
|
||||
protected:
|
||||
virtual void setName(const QString& name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue