diff --git a/src/account.cpp b/src/account.cpp index f00c2c0184711ad30d6c322965ce93bbc58d3aeb..a9231b39fe5d97f0c7a24332117a6a81f0e7353a 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -1455,13 +1455,45 @@ bool Account::removeContact(const ContactMethod* c) bool Account::removeContact( Certificate* c ) { if ((!c) || (c->remoteId().isEmpty())) - return false; + return false; ConfigurationManager::instance().removeContact(id(), c->remoteId(), false); + return true; +} + +bool Account::addContact( const URI& uri ) +{ + if (uri.isEmpty()) + return false; + + ConfigurationManager::instance().addContact(id(), uri); + + return true; +} + +bool Account::addContact(const ContactMethod* c) +{ + if (!c) + return false; + + return addContact(c->uri()); +} + +bool Account::addContact( Certificate* c ) +{ + if ((!c) || (c->remoteId().isEmpty())) + return false; + ConfigurationManager::instance().addContact(id(), c->remoteId()); return true; } +bool Account::hasContact(ContactMethod* c ) +{ + auto contacts = getContacts(); + return contacts.indexOf(c) != -1; +} + uint Account::internalId() const { return d_ptr->m_InternalId; diff --git a/src/account.h b/src/account.h index 77ba182148cf9efd51f2201aab0073c2a393e834..4f79ad5da6bf61b514ebc59ce88f5d7e415efed0 100644 --- a/src/account.h +++ b/src/account.h @@ -485,6 +485,10 @@ class LIB_EXPORT Account : public ItemBase { Q_INVOKABLE bool removeContact(Certificate* c); Q_INVOKABLE bool removeContact(const ContactMethod* c); Q_INVOKABLE bool removeContact(const URI& uri); + Q_INVOKABLE bool addContact(Certificate* c); + Q_INVOKABLE bool addContact(const ContactMethod* c); + Q_INVOKABLE bool addContact(const URI& uri); + Q_INVOKABLE bool hasContact(ContactMethod* c); Q_INVOKABLE QString accountDetail(const QString& param) const; //Setters