Skip to content
Snippets Groups Projects
Commit ddc8524f authored by Sébastien Blin's avatar Sébastien Blin
Browse files

newaccountmodel: load avatar for account from database


Change-Id: Icff9e2532a931ed1190915147ea21d86aaf1f40d
Reviewed-by: default avatarOlivier Soldano <olivier.soldano@savoirfairelinux.com>
parent e0f52c1f
Branches
No related tags found
No related merge requests found
...@@ -96,6 +96,20 @@ getPeerParticipantsForConversation(Database& db, const std::string& profileId, c ...@@ -96,6 +96,20 @@ getPeerParticipantsForConversation(Database& db, const std::string& profileId, c
{{":id", conversationId}, {":participant_id", profileId}}).payloads; {{":id", conversationId}, {":participant_id", profileId}}).payloads;
} }
std::string
getAvatarForProfileId(Database& db, const std::string& profileId)
{
auto returnFromDb = db.select("photo",
"profiles",
"id=:id",
{{":id", profileId}});
if (returnFromDb.nbrOfCols == 1 && returnFromDb.payloads.size() >= 1) {
auto payloads = returnFromDb.payloads;
return payloads[0];
}
return "";
}
api::contact::Info api::contact::Info
buildContactFromProfileId(Database& db, const std::string& profileId) buildContactFromProfileId(Database& db, const std::string& profileId)
{ {
......
...@@ -77,6 +77,13 @@ std::vector<std::string> getPeerParticipantsForConversation(Database& db, ...@@ -77,6 +77,13 @@ std::vector<std::string> getPeerParticipantsForConversation(Database& db,
const std::string& profileId, const std::string& profileId,
const std::string& conversationId); const std::string& conversationId);
/**
* @param db
* @param profileId
* @return the avatar in the database for a profile
*/
std::string getAvatarForProfileId(Database& db, const std::string& profileId);
api::contact::Info buildContactFromProfileId(Database& db, const std::string& profileId); api::contact::Info buildContactFromProfileId(Database& db, const std::string& profileId);
/** /**
......
...@@ -167,7 +167,6 @@ NewAccountModelPimpl::addToAccounts(const std::string& accountId) ...@@ -167,7 +167,6 @@ NewAccountModelPimpl::addToAccounts(const std::string& accountId)
auto& owner = item.second; auto& owner = item.second;
owner.id = accountId; owner.id = accountId;
owner.enabled = details["Account.enable"] == QString("true"); owner.enabled = details["Account.enable"] == QString("true");
// TODO get avatar;
owner.profileInfo.type = details["Account.type"] == "RING" ? profile::Type::RING : profile::Type::SIP; owner.profileInfo.type = details["Account.type"] == "RING" ? profile::Type::RING : profile::Type::SIP;
owner.profileInfo.alias = details["Account.alias"].toStdString(); owner.profileInfo.alias = details["Account.alias"].toStdString();
owner.registeredName = owner.profileInfo.type == profile::Type::RING ? owner.registeredName = owner.profileInfo.type == profile::Type::RING ?
...@@ -176,9 +175,12 @@ NewAccountModelPimpl::addToAccounts(const std::string& accountId) ...@@ -176,9 +175,12 @@ NewAccountModelPimpl::addToAccounts(const std::string& accountId)
details["Account.username"].toStdString().substr(std::string("ring:").size()) details["Account.username"].toStdString().substr(std::string("ring:").size())
: details["Account.username"].toStdString(); : details["Account.username"].toStdString();
// Add profile into database // Add profile into database
authority::database::getOrInsertProfile(database, owner.profileInfo.uri, auto accountProfileId = authority::database::getOrInsertProfile(database, owner.profileInfo.uri,
owner.profileInfo.alias, "", owner.profileInfo.alias, "",
details["Account.type"].toStdString()); details["Account.type"].toStdString());
// Retrieve avatar from database
auto avatar = authority::database::getAvatarForProfileId(database, accountProfileId);
owner.profileInfo.avatar = avatar;
// Init models for this account // Init models for this account
owner.callModel = std::make_unique<NewCallModel>(owner, callbacksHandler); owner.callModel = std::make_unique<NewCallModel>(owner, callbacksHandler);
owner.contactModel = std::make_unique<ContactModel>(owner, database, callbacksHandler); owner.contactModel = std::make_unique<ContactModel>(owner, database, callbacksHandler);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment