Skip to content
Snippets Groups Projects
Commit 1bf29f26 authored by Nicolas Jager's avatar Nicolas Jager Committed by Guillaume Roguez
Browse files

ContactRequest : implement block()


- this function allow to block (ban) a contact request.

Change-Id: I0c3347194f7787090d2b4e65485669e6ca5852cb
Reviewed-by: default avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent d1b64920
No related branches found
No related tags found
No related merge requests found
...@@ -83,6 +83,16 @@ bool ContactRequest::discard() ...@@ -83,6 +83,16 @@ bool ContactRequest::discard()
return false; return false;
} }
/**
* block the contact request.
*/
void
ContactRequest::block()
{
ConfigurationManager::instance().removeContact(d_ptr->m_pAccount->id(), d_ptr->m_pCertificate->remoteId());
emit requestBlocked();
}
/** /**
* get the data by role selection * get the data by role selection
* @param role define the role to select * @param role define the role to select
......
...@@ -46,6 +46,7 @@ public: ...@@ -46,6 +46,7 @@ public:
//Mutator //Mutator
Q_INVOKABLE bool accept (); Q_INVOKABLE bool accept ();
Q_INVOKABLE bool discard(); Q_INVOKABLE bool discard();
Q_INVOKABLE void block();
// Operator // Operator
bool operator==(const ContactRequest& another) const; bool operator==(const ContactRequest& another) const;
...@@ -60,4 +61,5 @@ private: ...@@ -60,4 +61,5 @@ private:
Q_SIGNALS: Q_SIGNALS:
void requestAccepted (); void requestAccepted ();
void requestDiscarded(); void requestDiscarded();
void requestBlocked();
}; };
...@@ -133,6 +133,11 @@ void PendingContactRequestModelPrivate::addRequest(ContactRequest* r) ...@@ -133,6 +133,11 @@ void PendingContactRequestModelPrivate::addRequest(ContactRequest* r)
emit q_ptr->requestDiscarded(r); emit q_ptr->requestDiscarded(r);
}); });
QObject::connect(r, &ContactRequest::requestBlocked, [this,r]() {
// the request was handled so it can be removed, from the pending list
removeRequest(r);
});
emit q_ptr->requestAdded(r); emit q_ptr->requestAdded(r);
} }
......
...@@ -639,6 +639,11 @@ public Q_SLOTS: // METHODS ...@@ -639,6 +639,11 @@ public Q_SLOTS: // METHODS
DRing::sendTrustRequest(accountId.toStdString(), from.toStdString(), raw); DRing::sendTrustRequest(accountId.toStdString(), from.toStdString(), raw);
} }
void removeContact(const QString &accountId, const QString &uri)
{
DRing::removeContact(accountId.toStdString(), uri.toStdString());
}
uint64_t sendTextMessage(const QString& accountId, const QString& to, const QMap<QString,QString>& payloads) uint64_t sendTextMessage(const QString& accountId, const QString& to, const QMap<QString,QString>& payloads)
{ {
return DRing::sendAccountTextMessage(accountId.toStdString(), to.toStdString(), convertMap(payloads)); return DRing::sendAccountTextMessage(accountId.toStdString(), to.toStdString(), convertMap(payloads));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment