From a7d1a28f2932f78d75fb44e88f169617b705b9f5 Mon Sep 17 00:00:00 2001 From: blue Date: Sat, 4 Nov 2023 22:12:15 -0300 Subject: [PATCH] some work towards encryption --- CMakeLists.txt | 7 --- core/CMakeLists.txt | 1 - core/account.cpp | 11 +++++ core/account.h | 1 + core/components/CMakeLists.txt | 2 + core/{storage => components}/archive.cpp | 19 ++++---- core/{storage => components}/archive.h | 6 ++- core/handlers/rosterhandler.cpp | 14 +++--- core/handlers/rosterhandler.h | 2 +- core/rosteritem.cpp | 10 ++-- core/rosteritem.h | 8 ++-- core/squawk.cpp | 9 ++++ core/squawk.h | 1 + core/storage/CMakeLists.txt | 4 -- main/application.cpp | 10 ++++ main/application.h | 2 + ui/models/contact.cpp | 25 +++++++++- ui/models/contact.h | 3 ++ ui/squawk.cpp | 61 ++++++++++++------------ ui/squawk.h | 4 +- ui/widgets/conversation.h | 10 ++-- 21 files changed, 129 insertions(+), 81 deletions(-) rename core/{storage => components}/archive.cpp (96%) rename core/{storage => components}/archive.h (94%) delete mode 100644 core/storage/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 5950c36..378aa51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,13 +46,6 @@ endif() find_package(Boost COMPONENTS) target_include_directories(squawk PRIVATE ${Boost_INCLUDE_DIRS}) -target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}_INCLUDE_DIRS}) -target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS}) -target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}DBus_INCLUDE_DIRS}) -target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}Gui_INCLUDE_DIRS}) -target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}Xml_INCLUDE_DIRS}) -target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}Network_INCLUDE_DIRS}) -target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}Core_INCLUDE_DIRS}) #OMEMO if (WITH_OMEMO) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 01c6d8f..a02bfe6 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -31,7 +31,6 @@ target_sources(squawk PRIVATE target_include_directories(squawk PRIVATE ${LMDB_INCLUDE_DIRS}) add_subdirectory(handlers) -add_subdirectory(storage) add_subdirectory(passwordStorageEngines) add_subdirectory(components) add_subdirectory(delayManager) diff --git a/core/account.cpp b/core/account.cpp index b06f51b..96ca4e1 100644 --- a/core/account.cpp +++ b/core/account.cpp @@ -669,6 +669,17 @@ void Core::Account::setRoomJoined(const QString& jid, bool joined) { conf->setJoined(joined); } +void Core::Account::setContactEncryption(const QString& jid, Shared::EncryptionProtocol value) { + Contact* cnt = rh->getContact(jid); + if (cnt == nullptr) { + qDebug() << "An attempt to set encryption to the non-existing contact" << jid << "of the account" << getName() << ", skipping"; + return; + } + + cnt->setEncryption(value); +} + + void Core::Account::discoverInfo(const QString& address, const QString& node) { if (state == Shared::ConnectionState::connected) { dm->requestInfo(address, node); diff --git a/core/account.h b/core/account.h index a9425e7..6442abf 100644 --- a/core/account.h +++ b/core/account.h @@ -132,6 +132,7 @@ public: void removeContactFromGroupRequest(const QString& jid, const QString& groupName); void renameContactRequest(const QString& jid, const QString& newName); void requestChangeMessage(const QString& jid, const QString& messageId, const QMap& data); + void setContactEncryption(const QString& jid, Shared::EncryptionProtocol value); void setRoomJoined(const QString& jid, bool joined); void setRoomAutoJoin(const QString& jid, bool joined); diff --git a/core/components/CMakeLists.txt b/core/components/CMakeLists.txt index 86d9fb8..77d290b 100644 --- a/core/components/CMakeLists.txt +++ b/core/components/CMakeLists.txt @@ -2,12 +2,14 @@ set(SOURCE_FILES networkaccess.cpp clientcache.cpp urlstorage.cpp + archive.cpp ) set(HEADER_FILES networkaccess.h clientcache.h urlstorage.h + archive.h ) target_sources(squawk PRIVATE diff --git a/core/storage/archive.cpp b/core/components/archive.cpp similarity index 96% rename from core/storage/archive.cpp rename to core/components/archive.cpp index 0a93850..003cce6 100644 --- a/core/storage/archive.cpp +++ b/core/components/archive.cpp @@ -17,12 +17,11 @@ */ #include "archive.h" + #include #include -#include + #include -#include -#include Core::Archive::Archive(const QString& account, const QString& p_jid, QObject* parent): QObject(parent), @@ -262,23 +261,23 @@ void Core::Archive::setFromTheBeginning(bool is) { stats->forceRecord("fromTheBeginning", is); } -bool Core::Archive::isEncryptionEnabled() const { +Shared::EncryptionProtocol Core::Archive::encryption() const { try { - return stats->getRecord("isEncryptionEnabled").toBool(); + return stats->getRecord("encryption").value(); } catch (const LMDBAL::NotFound& e) { - return false; + return Shared::EncryptionProtocol::none; } } -bool Core::Archive::setEncryptionEnabled(bool is) { +bool Core::Archive::setEncryption(Shared::EncryptionProtocol is) { LMDBAL::WriteTransaction txn = db.beginTransaction(); - bool current = false; + Shared::EncryptionProtocol current = Shared::EncryptionProtocol::none; try { - current = stats->getRecord("isEncryptionEnabled", txn).toBool(); + current = stats->getRecord("encryption", txn).value(); } catch (const LMDBAL::NotFound& e) {} if (is != current) { - stats->forceRecord("isEncryptionEnabled", is, txn); + stats->forceRecord("encryption", static_cast(is), txn); txn.commit(); return true; } diff --git a/core/storage/archive.h b/core/components/archive.h similarity index 94% rename from core/storage/archive.h rename to core/components/archive.h index 6f3c9eb..08f508a 100644 --- a/core/storage/archive.h +++ b/core/components/archive.h @@ -23,7 +23,9 @@ #include #include #include +#include +#include "shared/enums.h" #include "shared/message.h" #include "shared/exception.h" #include @@ -60,8 +62,8 @@ public: std::list getBefore(unsigned int count, const QString& id); bool isFromTheBeginning() const; void setFromTheBeginning(bool is); - bool isEncryptionEnabled() const; - bool setEncryptionEnabled(bool is); //returns true if changed, false otherwise + Shared::EncryptionProtocol encryption() const; + bool setEncryption(Shared::EncryptionProtocol value); //returns true if changed, false otherwise bool setAvatar(const QByteArray& data, AvatarInfo& info, bool generated = false, const QString& resource = ""); AvatarInfo getAvatarInfo(const QString& resource = "") const; bool readAvatarInfo(AvatarInfo& target, const QString& resource = "") const; diff --git a/core/handlers/rosterhandler.cpp b/core/handlers/rosterhandler.cpp index 4ce8939..38425ba 100644 --- a/core/handlers/rosterhandler.cpp +++ b/core/handlers/rosterhandler.cpp @@ -225,7 +225,7 @@ void Core::RosterHandler::onContactGroupAdded(const QString& group) { #if (QXMPP_VERSION) >= QT_VERSION_CHECK(1, 5, 0) {"trust", QVariant::fromValue(acc->th->getSummary(contact->jid))}, #endif - {"encryption", contact->isEncryptionEnabled()} + {"encryption", QVariant::fromValue(contact->encryption())} }); addToGroup(contact->jid, group); emit acc->addContact(contact->jid, group, cData); @@ -246,9 +246,9 @@ void Core::RosterHandler::onContactNameChanged(const QString& cname) { emit acc->changeContact(contact->jid, {{"name", cname}}); } -void Core::RosterHandler::onContactEncryptionChanged(bool value) { +void Core::RosterHandler::onContactEncryptionChanged(Shared::EncryptionProtocol value) { RosterItem* contact = static_cast(sender()); - emit acc->changeContact(contact->jid, {{"encryption", value}}); + emit acc->changeContact(contact->jid, {{"encryption", QVariant::fromValue(value)}}); } void Core::RosterHandler::onContactSubscriptionStateChanged(Shared::SubscriptionState cstate) { @@ -328,7 +328,7 @@ Core::Contact * Core::RosterHandler::addOutOfRosterContact(const QString& jid) { cnt->setSubscriptionState(Shared::SubscriptionState::unknown); emit acc->addContact(lcJid, "", QMap({ {"state", QVariant::fromValue(Shared::SubscriptionState::unknown)}, - {"encryption", false} + {"encryption", QVariant::fromValue(Shared::EncryptionProtocol::none)} })); handleNewContact(cnt); return cnt; @@ -361,9 +361,9 @@ void Core::RosterHandler::onRosterItemRemoved(const QString& bareJid) { Contact* contact = itr->second; contacts.erase(itr); QSet cGroups = contact->getGroups(); - for (QSet::const_iterator itr = cGroups.begin(), end = cGroups.end(); itr != end; ++itr) { - removeFromGroup(lcJid, *itr); - } + for (const QString& group : cGroups) + removeFromGroup(lcJid, group); + emit acc->removeContact(lcJid); contact->deleteLater(); diff --git a/core/handlers/rosterhandler.h b/core/handlers/rosterhandler.h index 61f3d7a..1f8e480 100644 --- a/core/handlers/rosterhandler.h +++ b/core/handlers/rosterhandler.h @@ -95,7 +95,7 @@ private slots: void onContactNameChanged(const QString& name); void onContactSubscriptionStateChanged(Shared::SubscriptionState state); void onContactAvatarChanged(Shared::Avatar, const QString& path); - void onContactEncryptionChanged(bool value); + void onContactEncryptionChanged(Shared::EncryptionProtocol value); void onPepSupportedChanged(Shared::Support support); private: diff --git a/core/rosteritem.cpp b/core/rosteritem.cpp index afbf836..a5763e2 100644 --- a/core/rosteritem.cpp +++ b/core/rosteritem.cpp @@ -561,12 +561,12 @@ Shared::Message Core::RosterItem::getMessage(const QString& id) { return archive->getElement(id); } -bool Core::RosterItem::isEncryptionEnabled() const { - return archive->isEncryptionEnabled(); +Shared::EncryptionProtocol Core::RosterItem::encryption() const { + return archive->encryption(); } -void Core::RosterItem::enableEncryption(bool value) { - bool changed = archive->setEncryptionEnabled(value); +void Core::RosterItem::setEncryption(Shared::EncryptionProtocol value) { + bool changed = archive->setEncryption(value); if (changed) emit encryptionChanged(value); } @@ -574,7 +574,7 @@ void Core::RosterItem::enableEncryption(bool value) { QMap Core::RosterItem::getInfo() const { QMap result({ {"name", name}, - {"encryption", isEncryptionEnabled()}, + {"encryption", QVariant::fromValue(encryption())}, }); Archive::AvatarInfo info; bool hasAvatar = readAvatarInfo(info); diff --git a/core/rosteritem.h b/core/rosteritem.h index fa154c0..203ed88 100644 --- a/core/rosteritem.h +++ b/core/rosteritem.h @@ -34,7 +34,7 @@ #include "shared/enums.h" #include "shared/message.h" #include "shared/vcard.h" -#include "storage/archive.h" +#include "components/archive.h" #include "adapterfunctions.h" namespace Core { @@ -62,8 +62,8 @@ public: void setName(const QString& n); QString getServer() const; bool isMuc() const; - bool isEncryptionEnabled() const; - void enableEncryption(bool value = true); + Shared::EncryptionProtocol encryption() const; + void setEncryption(Shared::EncryptionProtocol value); void addMessageToArchive(const Shared::Message& msg); void correctMessageInArchive(const QString& originalId, const Shared::Message& msg); @@ -91,7 +91,7 @@ signals: void needHistory(const QString& before, const QString& after, const QDateTime& afterTime = QDateTime()) const; void avatarChanged(Shared::Avatar, const QString& path) const; void requestVCard(const QString& jid) const; - void encryptionChanged(bool value) const; + void encryptionChanged(Shared::EncryptionProtocol value) const; public: const QString jid; diff --git a/core/squawk.cpp b/core/squawk.cpp index b7a0aad..1888487 100644 --- a/core/squawk.cpp +++ b/core/squawk.cpp @@ -590,6 +590,15 @@ void Core::Squawk::setRoomAutoJoin(const QString& account, const QString& jid, b itr->second->setRoomAutoJoin(jid, joined); } +void Core::Squawk::setContactEncryption(const QString& account, const QString& jid, Shared::EncryptionProtocol value) { + AccountsMap::const_iterator itr = amap.find(account); + if (itr == amap.end()) { + qDebug() << "An attempt to set encryption to the contact" << jid << "of non existing account" << account << ", skipping"; + return; + } + itr->second->setContactEncryption(jid, value); +} + void Core::Squawk::onAccountAddRoomPresence(const QString& jid, const QString& nick, const QMap& data) { Account* acc = static_cast(sender()); emit addRoomParticipant(acc->getName(), jid, nick, data); diff --git a/core/squawk.h b/core/squawk.h index eebe917..2ee122e 100644 --- a/core/squawk.h +++ b/core/squawk.h @@ -116,6 +116,7 @@ public slots: void removeContactRequest(const QString& account, const QString& jid); void renameContactRequest(const QString& account, const QString& jid, const QString& newName); void addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet& groups); + void setContactEncryption(const QString& account, const QString& jid, Shared::EncryptionProtocol value); void setRoomJoined(const QString& account, const QString& jid, bool joined); void setRoomAutoJoin(const QString& account, const QString& jid, bool joined); diff --git a/core/storage/CMakeLists.txt b/core/storage/CMakeLists.txt deleted file mode 100644 index e2de42c..0000000 --- a/core/storage/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -target_sources(squawk PRIVATE - archive.cpp - archive.h -) diff --git a/main/application.cpp b/main/application.cpp index 0701a0c..d184e6b 100644 --- a/main/application.cpp +++ b/main/application.cpp @@ -50,6 +50,7 @@ Application::Application(Core::Squawk* p_core): connect(this, &Application::replaceMessage, core, &Core::Squawk::replaceMessage); connect(this, &Application::sendMessage, core, &Core::Squawk::sendMessage); connect(this, &Application::resendMessage, core, &Core::Squawk::resendMessage); + connect(this, &Application::setEncryption, core, &Core::Squawk::setContactEncryption); connect(&roster, &Models::Roster::requestArchive, std::bind(&Core::Squawk::requestArchive, core, std::placeholders::_1, std::placeholders::_2, 20, std::placeholders::_3)); @@ -526,6 +527,7 @@ void Application::subscribeConversation(Conversation* conv) { connect(conv, &Conversation::sendMessage, this, &Application::onConversationMessage); connect(conv, &Conversation::replaceMessage, this, &Application::onConversationReplaceMessage); connect(conv, &Conversation::resendMessage, this, &Application::onConversationResend); + connect(conv, &Conversation::setEncryption, this, &Application::onConversationSetEncryption); connect(conv, &Conversation::notifyableMessage, this, &Application::notify); } @@ -586,6 +588,14 @@ void Application::onConversationReplaceMessage(const QString& originalId, const emit replaceMessage(acc, originalId, msg); } +void Application::onConversationSetEncryption(Shared::EncryptionProtocol value) { + Conversation* conv = static_cast(sender()); + QString acc = conv->getAccount(); + QString jid = conv->getJid(); + + emit setEncryption(acc, jid, value); +} + void Application::onConversationResend(const QString& id) { Conversation* conv = static_cast(sender()); QString acc = conv->getAccount(); diff --git a/main/application.h b/main/application.h index 54c2dbc..408572b 100644 --- a/main/application.h +++ b/main/application.h @@ -60,6 +60,7 @@ signals: void setRoomAutoJoin(const QString& account, const QString& jid, bool joined); void subscribeContact(const QString& account, const QString& jid, const QString& reason); void unsubscribeContact(const QString& account, const QString& jid, const QString& reason); + void setEncryption(const QString& account, const QString& jid, Shared::EncryptionProtocol value); void quitting(); void readyToQuit(); @@ -101,6 +102,7 @@ private slots: void onItemExpanded(const QModelIndex& index); void onItemCollapsed(const QModelIndex& index); void onAddedElement(const std::list& path); + void onConversationSetEncryption(Shared::EncryptionProtocol value); private: void createMainWindow(); diff --git a/ui/models/contact.cpp b/ui/models/contact.cpp index c27965b..c89724e 100644 --- a/ui/models/contact.cpp +++ b/ui/models/contact.cpp @@ -36,6 +36,10 @@ Models::Contact::Contact(const Account* acc, const QString& p_jid ,const QMap()); + + itr = data.find("encryption"); + if (itr != data.end()) + setEncryption(itr.value().value()); } 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()); + } else if (field == "encryption") { + setEncryption(value.value()); } 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(p_enc)); +} + +Shared::EncryptionProtocol Models::Contact::getEncryption() const { + return encryption; +} + diff --git a/ui/models/contact.h b/ui/models/contact.h index dbf33d4..d03e936 100644 --- a/ui/models/contact.h +++ b/ui/models/contact.h @@ -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; diff --git a/ui/squawk.cpp b/ui/squawk.cpp index ce759ac..64ea636 100644 --- a/ui/squawk.cpp +++ b/ui/squawk.cpp @@ -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(item.internalPointer()); - if (node->type == Models::Item::reference) { + if (node->type == Models::Item::reference) node = static_cast(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(index.internalPointer()); - if (item->type == Models::Item::reference) { + if (item->type == Models::Item::reference) item = static_cast(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); diff --git a/ui/squawk.h b/ui/squawk.h index 4e1ca4b..70eae8e 100644 --- a/ui/squawk.h +++ b/ui/squawk.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -50,8 +51,7 @@ class Squawk; class Application; -class Squawk : public QMainWindow -{ +class Squawk : public QMainWindow { Q_OBJECT friend class Application; public: diff --git a/ui/widgets/conversation.h b/ui/widgets/conversation.h index 80c8c2f..8af1745 100644 --- a/ui/widgets/conversation.h +++ b/ui/widgets/conversation.h @@ -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);