diff --git a/src/callbackshandler.cpp b/src/callbackshandler.cpp index ceca711444a5cf77b86e2473bdeb945318fda3c2..1814fca47b0fc176bcf6b8d86ce8dc1c46055df0 100644 --- a/src/callbackshandler.cpp +++ b/src/callbackshandler.cpp @@ -202,6 +202,8 @@ CallbacksHandler::slotRegisteredNameFound(const Account* account, NameDirectory: if (!account) return; if (status == NameDirectory::LookupStatus::SUCCESS) { emit registeredNameFound(account->id().toStdString(), address.toStdString(), name.toStdString()); + } else if((!address.trimmed().isEmpty() || !name.trimmed().isEmpty())) { + emit registeredNameNotFound(account->id().toStdString(), address.toStdString(), name.toStdString()); } } diff --git a/src/callbackshandler.h b/src/callbackshandler.h index cd022132bf68b1da8f50d8050f0b36eee720d786..06cf3b673ee5956c1f65c74d057ddefc82faaed4 100644 --- a/src/callbackshandler.h +++ b/src/callbackshandler.h @@ -127,6 +127,16 @@ Q_SIGNALS: void registeredNameFound(const std::string& accountId, const std::string& uri, const std::string& registeredName); + + /** + * Connect this signal to know when a name is not found + * @param accountId the account who receives this signal + * @param uri the search uri + * @param name the search name + */ + void registeredNameNotFound(const std::string& accountId, + const std::string& uri, + const std::string& name); /** * Connect this signal to know where a VCard is incoming * @param callId the call linked to this VCard diff --git a/src/contactmodel.cpp b/src/contactmodel.cpp index c44017502498e7947f72145e38542f6d279115f6..9503c54cdf9e87bf3497efcb196a190ebad5ed85 100644 --- a/src/contactmodel.cpp +++ b/src/contactmodel.cpp @@ -119,6 +119,13 @@ public Q_SLOTS: * @param registeredName of the contact found */ void slotRegisteredNameFound(const std::string& accountId, const std::string& uri, const std::string& registeredName); + /** + * Listen CallbacksHandler when a name is not found + * @param accountId account linked + * @param uri the uri to search + * @param name the name to search + */ + void slotRegisteredNameNotFound(const std::string& accountId, const std::string& uri, const std::string& name); /** * Listen CallbacksHandler when an incoming request arrives * @param accountId account linked @@ -352,7 +359,7 @@ ContactModel::searchContact(const std::string& query) } else { // Default searching profile::Info profileInfo; - profileInfo.alias = "Searching… " + query; + profileInfo.alias = "Searching…"; profileInfo.type = profile::Type::TEMPORARY; temporaryContact.profileInfo = profileInfo; temporaryContact.registeredName = query; @@ -408,6 +415,8 @@ ContactModelPimpl::ContactModelPimpl(const ContactModel& linked, this, &ContactModelPimpl::slotIncomingContactRequest); connect(&callbacksHandler, &CallbacksHandler::registeredNameFound, this, &ContactModelPimpl::slotRegisteredNameFound); + connect(&callbacksHandler, &CallbacksHandler::registeredNameNotFound, + this, &ContactModelPimpl::slotRegisteredNameNotFound); connect(&*linked.owner.callModel, &NewCallModel::newIncomingCall, this, &ContactModelPimpl::slotIncomingCall); connect(&callbacksHandler, &lrc::CallbacksHandler::newAccountMessage, @@ -428,6 +437,8 @@ ContactModelPimpl::~ContactModelPimpl() this, &ContactModelPimpl::slotIncomingContactRequest); disconnect(&callbacksHandler, &CallbacksHandler::registeredNameFound, this, &ContactModelPimpl::slotRegisteredNameFound); + disconnect(&callbacksHandler, &CallbacksHandler::registeredNameNotFound, + this, &ContactModelPimpl::slotRegisteredNameNotFound); disconnect(&*linked.owner.callModel, &NewCallModel::newIncomingCall, this, &ContactModelPimpl::slotIncomingCall); disconnect(&callbacksHandler, &lrc::CallbacksHandler::newAccountMessage, @@ -683,6 +694,24 @@ ContactModelPimpl::slotRegisteredNameFound(const std::string& accountId, } +void +ContactModelPimpl::slotRegisteredNameNotFound(const std::string& accountId, + const std::string& uri, + const std::string& name) +{ + if (accountId != linked.owner.id) return; + + auto& temporaryContact = contacts[""]; + if (temporaryContact.registeredName != uri && temporaryContact.registeredName != name) { + return; + } + { + std::lock_guard<std::mutex> lk(contactsMtx_); + temporaryContact.profileInfo.alias = "Not found"; + } + emit linked.modelUpdated(uri); +} + void ContactModelPimpl::slotIncomingContactRequest(const std::string& accountId, const std::string& contactUri,