Skip to content
Snippets Groups Projects
Commit d4bb2483 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Sébastien Blin
Browse files

smartlist: update info when contact not found


Update temporary contact when receive lookup return.
Note: like the "Not found" label, don't add the query to the
"Searching…" label

Change-Id: I4fd7dce67ee10132f4b63564d9fbd5d4acb95c30
Reviewed-by: default avatarSebastien Blin <sebastien.blin@savoirfairelinux.com>
parent 16d5d67f
No related branches found
No related tags found
No related merge requests found
......@@ -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());
}
}
......
......@@ -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
......
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment