Commit b869417b authored by LNJ's avatar LNJ 💬

RosterManager: Add rename contact function

Co-authored-by: Robert Maerkisch's avatarRobert Maerkisch <zatroxde@protonmail.ch>
parent 6231493f
......@@ -335,6 +335,11 @@ signals:
*/
void removeContact(QString jid);
/**
* Change a contact's name
*/
void renameContact(const QString &jid, const QString &newContactName);
/**
* Downloads an attached media file of a message
*
......
......@@ -64,9 +64,8 @@ RosterManager::RosterManager(Kaidan *kaidan,
});
connect(&manager, &QXmppRosterManager::itemChanged,
this, [this, model] (QString jid) {
emit model->updateItemRequested(m_chatPartner,
[this, &jid] (RosterItem &item) {
this, [this, model] (const QString &jid) {
emit model->updateItemRequested(m_chatPartner, [=] (RosterItem &item) {
item.setName(manager.getRosterEntry(jid).name());
});
});
......@@ -102,6 +101,7 @@ RosterManager::RosterManager(Kaidan *kaidan,
// user actions
connect(kaidan, &Kaidan::addContact, this, &RosterManager::addContact);
connect(kaidan, &Kaidan::removeContact, this, &RosterManager::removeContact);
connect(kaidan, &Kaidan::renameContact, this, &RosterManager::renameContact);
connect(kaidan, &Kaidan::sendMessage, this, &RosterManager::handleSendMessage);
connect(client, &QXmppClient::messageReceived, this, &RosterManager::handleMessage);
......@@ -152,6 +152,19 @@ void RosterManager::removeContact(const QString &jid)
}
}
void RosterManager::renameContact(const QString &jid, const QString &newContactName)
{
if (client->state() == QXmppClient::ConnectedState) {
manager.renameItem(jid, newContactName);
} else {
emit kaidan->passiveNotificationRequested(
tr("Could not rename contact, as a result of not being connected.")
);
qWarning() << "[client] [RosterManager] Could not rename contact, as a result of "
"not being connected.";
}
}
void RosterManager::handleSendMessage(const QString &jid, const QString &message,
bool isSpoiler, const QString &spoilerHint)
{
......
......@@ -55,6 +55,7 @@ public:
public slots:
void addContact(const QString &jid, const QString &name, const QString &msg);
void removeContact(const QString &jid);
void renameContact(const QString &jid, const QString &newContactName);
void handleSendMessage(const QString &jid, const QString &message,
bool isSpoiler = false, const QString &spoilerHint = QString());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment