mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-07-25 18:05:34 +02:00
swarmdetailspanel: link to setConversationPreferences
Save current color, and notification's preferences Change-Id: I3197be53bf622528aa3bc2e3f0d9aea29068e144
This commit is contained in:
parent
3f33fb19e5
commit
ef2d588abc
11 changed files with 198 additions and 14 deletions
|
@ -572,6 +572,11 @@ CallAdapter::showNotification(const QString& accountId, const QString& convUid)
|
||||||
auto& accInfo = lrcInstance_->getAccountInfo(accountId);
|
auto& accInfo = lrcInstance_->getAccountInfo(accountId);
|
||||||
auto title = accInfo.conversationModel->title(convUid);
|
auto title = accInfo.conversationModel->title(convUid);
|
||||||
|
|
||||||
|
auto preferences = accInfo.conversationModel->getConversationPreferences(convUid);
|
||||||
|
// Ignore notifications for this conversation
|
||||||
|
if (preferences["ignoreNotifications"] == "true")
|
||||||
|
return;
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
auto convAvatar = Utils::conversationAvatar(lrcInstance_, convUid, QSize(50, 50), accountId);
|
auto convAvatar = Utils::conversationAvatar(lrcInstance_, convUid, QSize(50, 50), accountId);
|
||||||
auto notifId = QString("%1;%2").arg(accountId).arg(convUid);
|
auto notifId = QString("%1;%2").arg(accountId).arg(convUid);
|
||||||
|
|
|
@ -168,6 +168,11 @@ ConversationsAdapter::onNewUnreadInteraction(const QString& accountId,
|
||||||
|| convUid != lrcInstance_->get_selectedConvUid())) {
|
|| convUid != lrcInstance_->get_selectedConvUid())) {
|
||||||
auto& accountInfo = lrcInstance_->getAccountInfo(accountId);
|
auto& accountInfo = lrcInstance_->getAccountInfo(accountId);
|
||||||
auto from = accountInfo.contactModel->bestNameForContact(interaction.authorUri);
|
auto from = accountInfo.contactModel->bestNameForContact(interaction.authorUri);
|
||||||
|
|
||||||
|
auto preferences = accountInfo.conversationModel->getConversationPreferences(convUid);
|
||||||
|
// Ignore notifications for this conversation
|
||||||
|
if (preferences["ignoreNotifications"] == "true")
|
||||||
|
return;
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
auto contactPhoto = Utils::contactPhoto(lrcInstance_,
|
auto contactPhoto = Utils::contactPhoto(lrcInstance_,
|
||||||
interaction.authorUri,
|
interaction.authorUri,
|
||||||
|
@ -226,6 +231,11 @@ ConversationsAdapter::onNewTrustRequest(const QString& accountId,
|
||||||
}
|
}
|
||||||
auto& accInfo = lrcInstance_->getAccountInfo(accountId);
|
auto& accInfo = lrcInstance_->getAccountInfo(accountId);
|
||||||
auto from = accInfo.contactModel->bestNameForContact(peerUri);
|
auto from = accInfo.contactModel->bestNameForContact(peerUri);
|
||||||
|
|
||||||
|
auto preferences = accInfo.conversationModel->getConversationPreferences(convId);
|
||||||
|
// Ignore notifications for this conversation
|
||||||
|
if (preferences["ignoreNotifications"] == "true")
|
||||||
|
return;
|
||||||
auto contactPhoto = Utils::contactPhoto(lrcInstance_, peerUri, QSize(50, 50), accountId);
|
auto contactPhoto = Utils::contactPhoto(lrcInstance_, peerUri, QSize(50, 50), accountId);
|
||||||
auto notifId = QString("%1;%2").arg(accountId).arg(conv);
|
auto notifId = QString("%1;%2").arg(accountId).arg(conv);
|
||||||
systemTray_->showNotification(notifId,
|
systemTray_->showNotification(notifId,
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "currentconversation.h"
|
#include "currentconversation.h"
|
||||||
|
#include "qmlregister.h"
|
||||||
|
|
||||||
|
#include <api/conversationmodel.h>
|
||||||
|
|
||||||
CurrentConversation::CurrentConversation(LRCInstance* lrcInstance, QObject* parent)
|
CurrentConversation::CurrentConversation(LRCInstance* lrcInstance, QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
|
@ -58,7 +61,7 @@ CurrentConversation::updateData()
|
||||||
set_isCoreDialog(convInfo.isCoreDialog());
|
set_isCoreDialog(convInfo.isCoreDialog());
|
||||||
set_isRequest(convInfo.isRequest);
|
set_isRequest(convInfo.isRequest);
|
||||||
set_needsSyncing(convInfo.needsSyncing);
|
set_needsSyncing(convInfo.needsSyncing);
|
||||||
set_color(Utils::getAvatarColor(convId).name());
|
updateConversationPreferences(convId);
|
||||||
set_isSip(accInfo.profileInfo.type == profile::Type::SIP);
|
set_isSip(accInfo.profileInfo.type == profile::Type::SIP);
|
||||||
set_callId(convInfo.getCallId());
|
set_callId(convInfo.getCallId());
|
||||||
set_allMessagesLoaded(convInfo.allMessagesLoaded);
|
set_allMessagesLoaded(convInfo.allMessagesLoaded);
|
||||||
|
@ -107,6 +110,33 @@ CurrentConversation::updateData()
|
||||||
updateErrors(convId);
|
updateErrors(convId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CurrentConversation::setPreference(const QString& key, const QString& value)
|
||||||
|
{
|
||||||
|
auto accountId = lrcInstance_->get_currentAccountId();
|
||||||
|
const auto& accInfo = lrcInstance_->accountModel().getAccountInfo(accountId);
|
||||||
|
auto convId = lrcInstance_->get_selectedConvUid();
|
||||||
|
if (auto optConv = accInfo.conversationModel->getConversationForUid(convId)) {
|
||||||
|
auto& convInfo = optConv->get();
|
||||||
|
auto preferences = convInfo.preferences;
|
||||||
|
preferences[key] = value;
|
||||||
|
accInfo.conversationModel->setConversationPreferences(convId, preferences);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
CurrentConversation::getPreference(const QString& key) const
|
||||||
|
{
|
||||||
|
auto accountId = lrcInstance_->get_currentAccountId();
|
||||||
|
const auto& accInfo = lrcInstance_->accountModel().getAccountInfo(accountId);
|
||||||
|
auto convId = lrcInstance_->get_selectedConvUid();
|
||||||
|
if (auto optConv = accInfo.conversationModel->getConversationForUid(convId)) {
|
||||||
|
auto& convInfo = optConv->get();
|
||||||
|
return convInfo.preferences[key];
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CurrentConversation::onConversationUpdated(const QString& convId)
|
CurrentConversation::onConversationUpdated(const QString& convId)
|
||||||
{
|
{
|
||||||
|
@ -126,6 +156,27 @@ CurrentConversation::onProfileUpdated(const QString& convId)
|
||||||
set_description(lrcInstance_->getCurrentConversationModel()->description(convId));
|
set_description(lrcInstance_->getCurrentConversationModel()->description(convId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CurrentConversation::updateConversationPreferences(const QString& convId)
|
||||||
|
{
|
||||||
|
if (convId != lrcInstance_->get_selectedConvUid())
|
||||||
|
return;
|
||||||
|
auto accountId = lrcInstance_->get_currentAccountId();
|
||||||
|
const auto& accInfo = lrcInstance_->accountModel().getAccountInfo(accountId);
|
||||||
|
if (auto optConv = accInfo.conversationModel->getConversationForUid(convId)) {
|
||||||
|
auto& convInfo = optConv->get();
|
||||||
|
auto preferences = convInfo.preferences;
|
||||||
|
auto color = Utils::getAvatarColor(convId).name();
|
||||||
|
if (convInfo.preferences.contains("color")) {
|
||||||
|
color = convInfo.preferences["color"];
|
||||||
|
}
|
||||||
|
set_color(color);
|
||||||
|
if (convInfo.preferences.contains("ignoreNotifications")) {
|
||||||
|
set_ignoreNotifications(convInfo.preferences["ignoreNotifications"] == "true");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CurrentConversation::connectModel()
|
CurrentConversation::connectModel()
|
||||||
{
|
{
|
||||||
|
@ -148,6 +199,11 @@ CurrentConversation::connectModel()
|
||||||
this,
|
this,
|
||||||
&CurrentConversation::updateErrors,
|
&CurrentConversation::updateErrors,
|
||||||
Qt::UniqueConnection);
|
Qt::UniqueConnection);
|
||||||
|
connect(lrcInstance_->getCurrentConversationModel(),
|
||||||
|
&ConversationModel::conversationPreferencesUpdated,
|
||||||
|
this,
|
||||||
|
&CurrentConversation::updateConversationPreferences,
|
||||||
|
Qt::UniqueConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -40,6 +40,7 @@ class CurrentConversation final : public QObject
|
||||||
QML_PROPERTY(bool, needsSyncing)
|
QML_PROPERTY(bool, needsSyncing)
|
||||||
QML_PROPERTY(bool, isSip)
|
QML_PROPERTY(bool, isSip)
|
||||||
QML_PROPERTY(bool, isBanned)
|
QML_PROPERTY(bool, isBanned)
|
||||||
|
QML_PROPERTY(bool, ignoreNotifications)
|
||||||
QML_PROPERTY(QString, callId)
|
QML_PROPERTY(QString, callId)
|
||||||
QML_PROPERTY(QString, color)
|
QML_PROPERTY(QString, color)
|
||||||
QML_PROPERTY(call::Status, callState)
|
QML_PROPERTY(call::Status, callState)
|
||||||
|
@ -60,6 +61,8 @@ public:
|
||||||
~CurrentConversation() = default;
|
~CurrentConversation() = default;
|
||||||
Q_INVOKABLE void scrollToMsg(const QString& msgId);
|
Q_INVOKABLE void scrollToMsg(const QString& msgId);
|
||||||
Q_INVOKABLE void showSwarmDetails() const;
|
Q_INVOKABLE void showSwarmDetails() const;
|
||||||
|
Q_INVOKABLE void setPreference(const QString& key, const QString& value);
|
||||||
|
Q_INVOKABLE QString getPreference(const QString& key) const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void scrollTo(const QString& msgId);
|
void scrollTo(const QString& msgId);
|
||||||
|
@ -70,6 +73,7 @@ private Q_SLOTS:
|
||||||
void onConversationUpdated(const QString& convId);
|
void onConversationUpdated(const QString& convId);
|
||||||
void onProfileUpdated(const QString& convId);
|
void onProfileUpdated(const QString& convId);
|
||||||
void updateErrors(const QString& convId);
|
void updateErrors(const QString& convId);
|
||||||
|
void updateConversationPreferences(const QString& convId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LRCInstance* lrcInstance_;
|
LRCInstance* lrcInstance_;
|
||||||
|
|
|
@ -229,8 +229,7 @@ Rectangle {
|
||||||
id: colorDialog
|
id: colorDialog
|
||||||
title: JamiStrings.chooseAColor
|
title: JamiStrings.chooseAColor
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
console.warn("TODO SAVE preference")
|
CurrentConversation.setPreference("color", colorDialog.color)
|
||||||
CurrentConversation.color = colorDialog.color
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +257,7 @@ Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.leftMargin: JamiTheme.preferredMarginSize
|
anchors.leftMargin: JamiTheme.preferredMarginSize
|
||||||
|
|
||||||
checked: false // TODO
|
checked: CurrentConversation.ignoreNotifications
|
||||||
|
|
||||||
labelText: JamiStrings.ignoreTheSwarm
|
labelText: JamiStrings.ignoreTheSwarm
|
||||||
fontPointSize: JamiTheme.settingsFontSize
|
fontPointSize: JamiTheme.settingsFontSize
|
||||||
|
@ -266,7 +265,7 @@ Rectangle {
|
||||||
tooltipText: JamiStrings.ignoreTheSwarmTooltip
|
tooltipText: JamiStrings.ignoreTheSwarmTooltip
|
||||||
|
|
||||||
onSwitchToggled: {
|
onSwitchToggled: {
|
||||||
// TODO
|
CurrentConversation.setPreference("ignoreNotifications", checked ? "true" : "false")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,7 @@ struct Info
|
||||||
QSet<QString> typers;
|
QSet<QString> typers;
|
||||||
|
|
||||||
MapStringString infos {};
|
MapStringString infos {};
|
||||||
|
MapStringString preferences {};
|
||||||
|
|
||||||
QString getCallId() const
|
QString getCallId() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -332,11 +332,17 @@ public:
|
||||||
*/
|
*/
|
||||||
void removeConversationMember(const QString& conversationId, const QString& memberId);
|
void removeConversationMember(const QString& conversationId, const QString& memberId);
|
||||||
/**
|
/**
|
||||||
* get conversation info
|
* get conversation's info
|
||||||
* @param conversationId conversation's id
|
* @param conversationId conversation's id
|
||||||
* @return conversation info
|
* @return conversation info
|
||||||
*/
|
*/
|
||||||
MapStringString getConversationInfos(const QString& conversationId);
|
MapStringString getConversationInfos(const QString& conversationId);
|
||||||
|
/**
|
||||||
|
* get conversation's preferences
|
||||||
|
* @param conversationId conversation's id
|
||||||
|
* @return conversation preferences
|
||||||
|
*/
|
||||||
|
MapStringString getConversationPreferences(const QString& conversationId);
|
||||||
/**
|
/**
|
||||||
* create a new swarm conversation
|
* create a new swarm conversation
|
||||||
* @param participants conversation's participants
|
* @param participants conversation's participants
|
||||||
|
@ -346,9 +352,15 @@ public:
|
||||||
/**
|
/**
|
||||||
* update conversation info
|
* update conversation info
|
||||||
* @param conversationId conversation's id
|
* @param conversationId conversation's id
|
||||||
* @param info
|
* @param infos
|
||||||
*/
|
*/
|
||||||
void updateConversationInfos(const QString& conversationId, MapStringString info);
|
void updateConversationInfos(const QString& conversationId, MapStringString info);
|
||||||
|
/**
|
||||||
|
* update conversation's preferences
|
||||||
|
* @param conversationId conversation's id
|
||||||
|
* @param preferences
|
||||||
|
*/
|
||||||
|
void setConversationPreferences(const QString& conversationId, MapStringString preferences);
|
||||||
/**
|
/**
|
||||||
* Remove first error
|
* Remove first error
|
||||||
* @param conversationId
|
* @param conversationId
|
||||||
|
@ -438,6 +450,11 @@ Q_SIGNALS:
|
||||||
* @param uid
|
* @param uid
|
||||||
*/
|
*/
|
||||||
void onConversationErrorsUpdated(const QString& uid) const;
|
void onConversationErrorsUpdated(const QString& uid) const;
|
||||||
|
/**
|
||||||
|
* Emitted when conversation's preferences has been updated
|
||||||
|
* @param uid
|
||||||
|
*/
|
||||||
|
void conversationPreferencesUpdated(const QString& uid) const;
|
||||||
/**
|
/**
|
||||||
* Emitted when conversation's profile has been updated
|
* Emitted when conversation's profile has been updated
|
||||||
* @param uid
|
* @param uid
|
||||||
|
|
|
@ -345,6 +345,11 @@ CallbacksHandler::CallbacksHandler(const Lrc& parent)
|
||||||
this,
|
this,
|
||||||
&CallbacksHandler::slotOnConversationError,
|
&CallbacksHandler::slotOnConversationError,
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
|
connect(&ConfigurationManager::instance(),
|
||||||
|
&ConfigurationManagerInterface::conversationPreferencesUpdated,
|
||||||
|
this,
|
||||||
|
&CallbacksHandler::slotConversationPreferencesUpdated,
|
||||||
|
Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallbacksHandler::~CallbacksHandler() {}
|
CallbacksHandler::~CallbacksHandler() {}
|
||||||
|
@ -806,4 +811,12 @@ CallbacksHandler::slotOnConversationError(const QString& accountId,
|
||||||
Q_EMIT conversationError(accountId, conversationId, code, what);
|
Q_EMIT conversationError(accountId, conversationId, code, what);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CallbacksHandler::slotConversationPreferencesUpdated(const QString& accountId,
|
||||||
|
const QString& conversationId,
|
||||||
|
const MapStringString& preferences)
|
||||||
|
{
|
||||||
|
Q_EMIT conversationPreferencesUpdated(accountId, conversationId, preferences);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace lrc
|
} // namespace lrc
|
||||||
|
|
|
@ -367,9 +367,12 @@ Q_SIGNALS:
|
||||||
const QString& memberId,
|
const QString& memberId,
|
||||||
int event);
|
int event);
|
||||||
void conversationError(const QString& accountId,
|
void conversationError(const QString& accountId,
|
||||||
const QString& conversationId,
|
const QString& conversationId,
|
||||||
int code,
|
int code,
|
||||||
const QString& what);
|
const QString& what);
|
||||||
|
void conversationPreferencesUpdated(const QString& accountId,
|
||||||
|
const QString& conversationId,
|
||||||
|
const MapStringString& preferences);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
|
@ -674,6 +677,9 @@ private Q_SLOTS:
|
||||||
void slotConversationRequestReceived(const QString& accountId,
|
void slotConversationRequestReceived(const QString& accountId,
|
||||||
const QString& conversationId,
|
const QString& conversationId,
|
||||||
const MapStringString& metadatas);
|
const MapStringString& metadatas);
|
||||||
|
void slotConversationPreferencesUpdated(const QString& accountId,
|
||||||
|
const QString& conversationId,
|
||||||
|
const MapStringString& preferences);
|
||||||
void slotConversationRequestDeclined(const QString& accountId, const QString& conversationId);
|
void slotConversationRequestDeclined(const QString& accountId, const QString& conversationId);
|
||||||
void slotConversationReady(const QString& accountId, const QString& conversationId);
|
void slotConversationReady(const QString& accountId, const QString& conversationId);
|
||||||
void slotConversationRemoved(const QString& accountId, const QString& conversationId);
|
void slotConversationRemoved(const QString& accountId, const QString& conversationId);
|
||||||
|
|
|
@ -374,6 +374,9 @@ public Q_SLOTS:
|
||||||
const QString& what);
|
const QString& what);
|
||||||
void slotConversationReady(const QString& accountId, const QString& conversationId);
|
void slotConversationReady(const QString& accountId, const QString& conversationId);
|
||||||
void slotConversationRemoved(const QString& accountId, const QString& conversationId);
|
void slotConversationRemoved(const QString& accountId, const QString& conversationId);
|
||||||
|
void slotConversationPreferencesUpdated(const QString& accountId,
|
||||||
|
const QString& conversationId,
|
||||||
|
const MapStringString& preferences);
|
||||||
};
|
};
|
||||||
|
|
||||||
ConversationModel::ConversationModel(const account::Info& owner,
|
ConversationModel::ConversationModel(const account::Info& owner,
|
||||||
|
@ -966,6 +969,14 @@ ConversationModel::getConversationInfos(const QString& conversationId)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MapStringString
|
||||||
|
ConversationModel::getConversationPreferences(const QString& conversationId)
|
||||||
|
{
|
||||||
|
MapStringString ret = ConfigurationManager::instance()
|
||||||
|
.getConversationPreferences(owner.id, conversationId);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ConversationModel::createConversation(const VectorString& participants, const MapStringString& infos)
|
ConversationModel::createConversation(const VectorString& participants, const MapStringString& infos)
|
||||||
{
|
{
|
||||||
|
@ -982,12 +993,13 @@ ConversationModel::createConversation(const VectorString& participants, const Ma
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ConversationModel::updateConversationInfos(const QString& conversationId, const MapStringString info)
|
ConversationModel::updateConversationInfos(const QString& conversationId,
|
||||||
|
const MapStringString infos)
|
||||||
{
|
{
|
||||||
MapStringString newInfos = info;
|
MapStringString newInfos = infos;
|
||||||
// Compress avatar as it will be sent in the conversation's request over the DHT
|
// Compress avatar as it will be sent in the conversation's request over the DHT
|
||||||
if (info.contains("avatar"))
|
if (infos.contains("avatar"))
|
||||||
newInfos["avatar"] = storage::vcard::compressedAvatar(info["avatar"]);
|
newInfos["avatar"] = storage::vcard::compressedAvatar(infos["avatar"]);
|
||||||
ConfigurationManager::instance().updateConversationInfos(owner.id, conversationId, newInfos);
|
ConfigurationManager::instance().updateConversationInfos(owner.id, conversationId, newInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1003,6 +1015,13 @@ ConversationModel::popFrontError(const QString& conversationId)
|
||||||
Q_EMIT onConversationErrorsUpdated(conversationId);
|
Q_EMIT onConversationErrorsUpdated(conversationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ConversationModel::setConversationPreferences(const QString& conversationId,
|
||||||
|
const MapStringString prefs)
|
||||||
|
{
|
||||||
|
ConfigurationManager::instance().setConversationPreferences(owner.id, conversationId, prefs);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ConversationModel::hasPendingRequests() const
|
ConversationModel::hasPendingRequests() const
|
||||||
{
|
{
|
||||||
|
@ -1865,6 +1884,10 @@ ConversationModelPimpl::ConversationModelPimpl(const ConversationModel& linked,
|
||||||
&CallbacksHandler::conversationError,
|
&CallbacksHandler::conversationError,
|
||||||
this,
|
this,
|
||||||
&ConversationModelPimpl::slotOnConversationError);
|
&ConversationModelPimpl::slotOnConversationError);
|
||||||
|
connect(&callbacksHandler,
|
||||||
|
&CallbacksHandler::conversationPreferencesUpdated,
|
||||||
|
this,
|
||||||
|
&ConversationModelPimpl::slotConversationPreferencesUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConversationModelPimpl::~ConversationModelPimpl()
|
ConversationModelPimpl::~ConversationModelPimpl()
|
||||||
|
@ -2009,6 +2032,10 @@ ConversationModelPimpl::~ConversationModelPimpl()
|
||||||
&CallbacksHandler::conversationError,
|
&CallbacksHandler::conversationError,
|
||||||
this,
|
this,
|
||||||
&ConversationModelPimpl::slotOnConversationError);
|
&ConversationModelPimpl::slotOnConversationError);
|
||||||
|
disconnect(&callbacksHandler,
|
||||||
|
&CallbacksHandler::conversationPreferencesUpdated,
|
||||||
|
this,
|
||||||
|
&ConversationModelPimpl::slotConversationPreferencesUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2577,6 +2604,9 @@ ConversationModelPimpl::slotConversationReady(const QString& accountId,
|
||||||
const MapStringString& details = ConfigurationManager::instance()
|
const MapStringString& details = ConfigurationManager::instance()
|
||||||
.conversationInfos(accountId, conversationId);
|
.conversationInfos(accountId, conversationId);
|
||||||
conversation.infos = details;
|
conversation.infos = details;
|
||||||
|
const MapStringString& preferences
|
||||||
|
= ConfigurationManager::instance().getConversationPreferences(accountId, conversationId);
|
||||||
|
conversation.preferences = preferences;
|
||||||
conversation.mode = conversation::to_mode(details["mode"].toInt());
|
conversation.mode = conversation::to_mode(details["mode"].toInt());
|
||||||
conversation.isRequest = false;
|
conversation.isRequest = false;
|
||||||
conversation.needsSyncing = false;
|
conversation.needsSyncing = false;
|
||||||
|
@ -2983,6 +3013,9 @@ ConversationModelPimpl::addSwarmConversation(const QString& convId)
|
||||||
}
|
}
|
||||||
conversation.participants = participants;
|
conversation.participants = participants;
|
||||||
conversation.mode = mode;
|
conversation.mode = mode;
|
||||||
|
const MapStringString& preferences = ConfigurationManager::instance()
|
||||||
|
.getConversationPreferences(linked.owner.id, convId);
|
||||||
|
conversation.preferences = preferences;
|
||||||
conversation.unreadMessages = ConfigurationManager::instance().countInteractions(linked.owner.id,
|
conversation.unreadMessages = ConfigurationManager::instance().countInteractions(linked.owner.id,
|
||||||
convId,
|
convId,
|
||||||
lastRead,
|
lastRead,
|
||||||
|
@ -4198,6 +4231,19 @@ ConversationModelPimpl::updateTransferProgress(QTimer* timer,
|
||||||
timer->deleteLater();
|
timer->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ConversationModelPimpl::slotConversationPreferencesUpdated(const QString&,
|
||||||
|
const QString& conversationId,
|
||||||
|
const MapStringString& preferences)
|
||||||
|
{
|
||||||
|
auto conversationIdx = indexOf(conversationId);
|
||||||
|
if (conversationIdx < 0)
|
||||||
|
return;
|
||||||
|
auto& conversation = conversations[conversationIdx];
|
||||||
|
conversation.preferences = preferences;
|
||||||
|
Q_EMIT linked.conversationPreferencesUpdated(conversationId);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace lrc
|
} // namespace lrc
|
||||||
|
|
||||||
#include "api/moc_conversationmodel.cpp"
|
#include "api/moc_conversationmodel.cpp"
|
||||||
|
|
|
@ -319,6 +319,14 @@ public:
|
||||||
Q_EMIT conversationRemoved(QString(accountId.c_str()),
|
Q_EMIT conversationRemoved(QString(accountId.c_str()),
|
||||||
QString(conversationId.c_str()));
|
QString(conversationId.c_str()));
|
||||||
}),
|
}),
|
||||||
|
exportable_callback<ConversationSignal::ConversationPreferencesUpdated>(
|
||||||
|
[this](const std::string& accountId,
|
||||||
|
const std::string& conversationId,
|
||||||
|
const std::map<std::string, std::string>& preferences) {
|
||||||
|
Q_EMIT conversationPreferencesUpdated(QString(accountId.c_str()),
|
||||||
|
QString(conversationId.c_str()),
|
||||||
|
convertMap(preferences));
|
||||||
|
}),
|
||||||
exportable_callback<ConversationSignal::ConversationMemberEvent>(
|
exportable_callback<ConversationSignal::ConversationMemberEvent>(
|
||||||
[this](const std::string& accountId,
|
[this](const std::string& accountId,
|
||||||
const std::string& conversationId,
|
const std::string& conversationId,
|
||||||
|
@ -1103,6 +1111,13 @@ public Q_SLOTS: // METHODS
|
||||||
DRing::conversationInfos(accountId.toStdString(), conversationId.toStdString()));
|
DRing::conversationInfos(accountId.toStdString(), conversationId.toStdString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MapStringString getConversationPreferences(const QString& accountId,
|
||||||
|
const QString& conversationId)
|
||||||
|
{
|
||||||
|
return convertMap(DRing::getConversationPreferences(accountId.toStdString(),
|
||||||
|
conversationId.toStdString()));
|
||||||
|
}
|
||||||
|
|
||||||
void updateConversationInfos(const QString& accountId,
|
void updateConversationInfos(const QString& accountId,
|
||||||
const QString& conversationId,
|
const QString& conversationId,
|
||||||
const MapStringString& info)
|
const MapStringString& info)
|
||||||
|
@ -1112,6 +1127,15 @@ public Q_SLOTS: // METHODS
|
||||||
convertMap(info));
|
convertMap(info));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setConversationPreferences(const QString& accountId,
|
||||||
|
const QString& conversationId,
|
||||||
|
const MapStringString& prefs)
|
||||||
|
{
|
||||||
|
DRing::setConversationPreferences(accountId.toStdString(),
|
||||||
|
conversationId.toStdString(),
|
||||||
|
convertMap(prefs));
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t countInteractions(const QString& accountId,
|
uint32_t countInteractions(const QString& accountId,
|
||||||
const QString& conversationId,
|
const QString& conversationId,
|
||||||
const QString& toId,
|
const QString& toId,
|
||||||
|
@ -1214,6 +1238,9 @@ Q_SIGNALS: // SIGNALS
|
||||||
const QString& conversationId,
|
const QString& conversationId,
|
||||||
int code,
|
int code,
|
||||||
const QString& what);
|
const QString& what);
|
||||||
|
void conversationPreferencesUpdated(const QString& accountId,
|
||||||
|
const QString& conversationId,
|
||||||
|
const MapStringString& message);
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace org {
|
namespace org {
|
||||||
|
|
Loading…
Add table
Reference in a new issue