1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-04-21 21:52:03 +02:00

conversations: support new APIs for user search

Gitlab: #4
Change-Id: I7570099c20d2d406e538aea4c366ba7d85777686
This commit is contained in:
ababi 2020-08-18 17:21:28 +02:00
parent 449eda362a
commit 0b68664220
18 changed files with 378 additions and 265 deletions

View file

@ -386,7 +386,9 @@ AccountAdapter::connectAccount(const QString &accountId)
[this, accountId](const QString &contactUri) { [this, accountId](const QString &contactUri) {
auto &accInfo = LRCInstance::accountModel().getAccountInfo( auto &accInfo = LRCInstance::accountModel().getAccountInfo(
accountId); accountId);
auto conversation = LRCInstance::getCurrentConversation(); auto* convModel = LRCInstance::getCurrentConversationModel();
const auto conversation = convModel->getConversationForUID(
LRCInstance::getCurrentConvUid());
if (conversation.uid.isEmpty()) { if (conversation.uid.isEmpty()) {
return; return;
} }

View file

@ -37,7 +37,8 @@ AvAdapter::initQmlObject()
QVariantMap QVariantMap
AvAdapter::populateVideoDeviceContextMenuItem() AvAdapter::populateVideoDeviceContextMenuItem()
{ {
auto conversation = LRCInstance::getCurrentConversation(); auto* convModel = LRCInstance::getCurrentConversationModel();
const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
auto call = LRCInstance::getCallInfoForConversation(conversation); auto call = LRCInstance::getCallInfoForConversation(conversation);
if (!call) { if (!call) {
return QVariantMap(); return QVariantMap();
@ -129,4 +130,4 @@ AvAdapter::shareScreenArea(int screenNumber, int x, int y, int width, int height
rect.y() + y, rect.y() + y,
width < 128 ? 128 : width, width < 128 ? 128 : width,
height < 128 ? 128 : height); height < 128 ? 128 : height);
} }

View file

@ -62,25 +62,26 @@ CallAdapter::slotAccountChanged()
void void
CallAdapter::placeAudioOnlyCall() CallAdapter::placeAudioOnlyCall()
{ {
auto convInfo = LRCInstance::getCurrentConversation(); const auto convUid = LRCInstance::getCurrentConvUid();
if (!convInfo.uid.isEmpty()) { if (!convUid.isEmpty()) {
LRCInstance::getCurrentConversationModel()->placeAudioOnlyCall(convInfo.uid); LRCInstance::getCurrentConversationModel()->placeAudioOnlyCall(convUid);
} }
} }
void void
CallAdapter::placeCall() CallAdapter::placeCall()
{ {
auto convInfo = LRCInstance::getCurrentConversation(); const auto convUid = LRCInstance::getCurrentConvUid();
if (!convInfo.uid.isEmpty()) { if (!convUid.isEmpty()) {
LRCInstance::getCurrentConversationModel()->placeCall(convInfo.uid); LRCInstance::getCurrentConversationModel()->placeCall(convUid);
} }
} }
void void
CallAdapter::hangUpACall(const QString &accountId, const QString &convUid) CallAdapter::hangUpACall(const QString &accountId, const QString &convUid)
{ {
auto convInfo = LRCInstance::getConversationFromConvUid(convUid, accountId); auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid);
if (!convInfo.uid.isEmpty()) { if (!convInfo.uid.isEmpty()) {
LRCInstance::getAccountInfo(accountId).callModel->hangUp(convInfo.callId); LRCInstance::getAccountInfo(accountId).callModel->hangUp(convInfo.callId);
} }
@ -89,7 +90,8 @@ CallAdapter::hangUpACall(const QString &accountId, const QString &convUid)
void void
CallAdapter::refuseACall(const QString &accountId, const QString &convUid) CallAdapter::refuseACall(const QString &accountId, const QString &convUid)
{ {
auto convInfo = LRCInstance::getConversationFromConvUid(convUid, accountId); auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid);
if (!convInfo.uid.isEmpty()) { if (!convInfo.uid.isEmpty()) {
LRCInstance::getAccountInfo(accountId).callModel->refuse(convInfo.callId); LRCInstance::getAccountInfo(accountId).callModel->refuse(convInfo.callId);
} }
@ -99,7 +101,8 @@ void
CallAdapter::acceptACall(const QString &accountId, const QString &convUid) CallAdapter::acceptACall(const QString &accountId, const QString &convUid)
{ {
emit incomingCallNeedToSetupMainView(accountId, convUid); emit incomingCallNeedToSetupMainView(accountId, convUid);
auto convInfo = LRCInstance::getConversationFromConvUid(convUid, accountId); auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid);
if (!convInfo.uid.isEmpty()) { if (!convInfo.uid.isEmpty()) {
LRCInstance::getAccountInfo(accountId).callModel->accept(convInfo.callId); LRCInstance::getAccountInfo(accountId).callModel->accept(convInfo.callId);
auto &accInfo = LRCInstance::getAccountInfo(convInfo.accountId); auto &accInfo = LRCInstance::getAccountInfo(convInfo.accountId);
@ -110,7 +113,7 @@ CallAdapter::acceptACall(const QString &accountId, const QString &convUid)
void void
CallAdapter::slotShowIncomingCallView(const QString &accountId, const conversation::Info &convInfo) CallAdapter::slotShowIncomingCallView(const QString &accountId, const conversation::Info &convInfo)
{ {
auto callModel = LRCInstance::getCurrentCallModel(); auto* callModel = LRCInstance::getCurrentCallModel();
if (!callModel->hasCall(convInfo.callId)) { if (!callModel->hasCall(convInfo.callId)) {
/* /*
@ -190,7 +193,8 @@ CallAdapter::updateCall(const QString &convUid, const QString &accountId, bool f
accountId_ = accountId.isEmpty() ? accountId_ : accountId; accountId_ = accountId.isEmpty() ? accountId_ : accountId;
convUid_ = convUid.isEmpty() ? convUid_ : convUid; convUid_ = convUid.isEmpty() ? convUid_ : convUid;
auto convInfo = LRCInstance::getConversationFromConvUid(convUid_, accountId_); auto *convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid_);
if (convInfo.uid.isEmpty()) { if (convInfo.uid.isEmpty()) {
return; return;
} }
@ -220,7 +224,8 @@ bool
CallAdapter::shouldShowPreview(bool force) CallAdapter::shouldShowPreview(bool force)
{ {
bool shouldShowPreview{false}; bool shouldShowPreview{false};
auto convInfo = LRCInstance::getConversationFromConvUid(convUid_, accountId_); auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid_);
if (convInfo.uid.isEmpty()) { if (convInfo.uid.isEmpty()) {
return shouldShowPreview; return shouldShowPreview;
} }
@ -236,7 +241,8 @@ QVariantList
CallAdapter::getConferencesInfos() CallAdapter::getConferencesInfos()
{ {
QVariantList map; QVariantList map;
auto convInfo = LRCInstance::getConversationFromConvUid(convUid_, accountId_); auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid_);
if (convInfo.uid.isEmpty()) if (convInfo.uid.isEmpty())
return map; return map;
auto callId = convInfo.confId.isEmpty()? convInfo.callId : convInfo.confId; auto callId = convInfo.confId.isEmpty()? convInfo.callId : convInfo.confId;
@ -287,7 +293,7 @@ CallAdapter::connectCallModel(const QString &accountId)
auto &accInfo = LRCInstance::accountModel().getAccountInfo(accountId); auto &accInfo = LRCInstance::accountModel().getAccountInfo(accountId);
auto &callModel = accInfo.callModel; auto &callModel = accInfo.callModel;
auto call = callModel->getCall(confId); auto call = callModel->getCall(confId);
auto convInfo = LRCInstance::getConversationFromCallId(confId); const auto convInfo = LRCInstance::getConversationFromCallId(confId);
if (!convInfo.uid.isEmpty()) { if (!convInfo.uid.isEmpty()) {
// Convert to QML // Convert to QML
QVariantList map; QVariantList map;
@ -324,12 +330,12 @@ CallAdapter::connectCallModel(const QString &accountId)
[this, accountId](const QString &callId) { [this, accountId](const QString &callId) {
auto &accInfo = LRCInstance::accountModel().getAccountInfo(accountId); auto &accInfo = LRCInstance::accountModel().getAccountInfo(accountId);
auto &callModel = accInfo.callModel; auto &callModel = accInfo.callModel;
auto call = callModel->getCall(callId); const auto call = callModel->getCall(callId);
/* /*
* Change status label text. * Change status label text.
*/ */
auto convInfo = LRCInstance::getConversationFromCallId(callId); const auto convInfo = LRCInstance::getConversationFromCallId(callId);
if (!convInfo.uid.isEmpty()) { if (!convInfo.uid.isEmpty()) {
emit callStatusChanged(lrc::api::call::to_string(call.status), emit callStatusChanged(lrc::api::call::to_string(call.status),
accountId, accountId,
@ -383,7 +389,7 @@ CallAdapter::connectCallModel(const QString &accountId)
} }
case lrc::api::call::Status::CONNECTED: case lrc::api::call::Status::CONNECTED:
case lrc::api::call::Status::IN_PROGRESS: { case lrc::api::call::Status::IN_PROGRESS: {
auto convInfo = LRCInstance::getConversationFromCallId(callId, accountId); const auto convInfo = LRCInstance::getConversationFromCallId(callId, accountId);
if (!convInfo.uid.isEmpty() && convInfo.uid == LRCInstance::getCurrentConvUid()) { if (!convInfo.uid.isEmpty() && convInfo.uid == LRCInstance::getCurrentConvUid()) {
accInfo.conversationModel->selectConversation(convInfo.uid); accInfo.conversationModel->selectConversation(convInfo.uid);
} }
@ -439,7 +445,7 @@ CallAdapter::updateCallOverlay(const lrc::api::conversation::Info &convInfo)
void void
CallAdapter::hangupCall(const QString& uri) CallAdapter::hangupCall(const QString& uri)
{ {
auto convInfo = LRCInstance::getConversationFromPeerUri(uri, accountId_); const auto convInfo = LRCInstance::getConversationFromPeerUri(uri, accountId_);
if (!convInfo.uid.isEmpty()) { if (!convInfo.uid.isEmpty()) {
auto callModel = LRCInstance::getAccountInfo(accountId_).callModel.get(); auto callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
if (callModel->hasCall(convInfo.callId)) { if (callModel->hasCall(convInfo.callId)) {
@ -466,17 +472,20 @@ CallAdapter::hangupCall(const QString& uri)
void void
CallAdapter::maximizeParticipant(const QString& uri, bool isActive) CallAdapter::maximizeParticipant(const QString& uri, bool isActive)
{ {
auto callModel = LRCInstance::getAccountInfo(accountId_).callModel.get(); auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
auto confId = LRCInstance::getCurrentConversation().confId; auto* convModel = LRCInstance::getCurrentConversationModel();
const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
const auto confId = conversation.confId;
QString callId; QString callId;
if (LRCInstance::getCurrentAccountInfo().profileInfo.uri != uri) { if (LRCInstance::getCurrentAccountInfo().profileInfo.uri != uri) {
auto convInfo = LRCInstance::getConversationFromPeerUri(uri, accountId_); const auto convInfo = LRCInstance::getConversationFromPeerUri(uri, accountId_);
if (!convInfo.uid.isEmpty()) { if (!convInfo.uid.isEmpty()) {
callId = convInfo.callId; callId = convInfo.callId;
} }
} }
try { try {
auto call = callModel->getCall(confId); const auto call = callModel->getCall(confId);
switch (call.layout) { switch (call.layout) {
case lrc::api::call::Layout::GRID: case lrc::api::call::Layout::GRID:
callModel->setActiveParticipant(confId, callId); callModel->setActiveParticipant(confId, callId);
@ -498,8 +507,10 @@ CallAdapter::maximizeParticipant(const QString& uri, bool isActive)
void void
CallAdapter::minimizeParticipant() CallAdapter::minimizeParticipant()
{ {
auto callModel = LRCInstance::getAccountInfo(accountId_).callModel.get(); auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
auto confId = LRCInstance::getCurrentConversation().confId; auto* convModel = LRCInstance::getCurrentConversationModel();
const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
const auto confId = conversation.confId;
try { try {
auto call = callModel->getCall(confId); auto call = callModel->getCall(confId);
switch (call.layout) { switch (call.layout) {
@ -518,9 +529,10 @@ CallAdapter::minimizeParticipant()
void void
CallAdapter::hangUpThisCall() CallAdapter::hangUpThisCall()
{ {
auto convInfo = LRCInstance::getConversationFromConvUid(convUid_, accountId_); auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid_);
if (!convInfo.uid.isEmpty()) { if (!convInfo.uid.isEmpty()) {
auto callModel = LRCInstance::getAccountInfo(accountId_).callModel.get(); auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
if (!convInfo.confId.isEmpty() && callModel->hasCall(convInfo.confId)) { if (!convInfo.confId.isEmpty() && callModel->hasCall(convInfo.confId)) {
callModel->hangUp(convInfo.confId); callModel->hangUp(convInfo.confId);
} else if (callModel->hasCall(convInfo.callId)) { } else if (callModel->hasCall(convInfo.callId)) {
@ -533,7 +545,8 @@ bool
CallAdapter::isRecordingThisCall() CallAdapter::isRecordingThisCall()
{ {
auto &accInfo = LRCInstance::accountModel().getAccountInfo(accountId_); auto &accInfo = LRCInstance::accountModel().getAccountInfo(accountId_);
auto convInfo = LRCInstance::getConversationFromConvUid(convUid_, accountId_); auto &convModel = accInfo.conversationModel;
const auto convInfo = convModel->getConversationForUID(convUid_);
return accInfo.callModel->isRecording(convInfo.confId) return accInfo.callModel->isRecording(convInfo.confId)
|| accInfo.callModel->isRecording(convInfo.callId); || accInfo.callModel->isRecording(convInfo.callId);
} }
@ -541,9 +554,10 @@ CallAdapter::isRecordingThisCall()
bool bool
CallAdapter::isCurrentMaster() const CallAdapter::isCurrentMaster() const
{ {
auto convInfo = LRCInstance::getConversationFromConvUid(convUid_, accountId_); auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid_);
if (!convInfo.uid.isEmpty()) { if (!convInfo.uid.isEmpty()) {
auto callModel = LRCInstance::getAccountInfo(accountId_).callModel.get(); auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
try { try {
if (!convInfo.confId.isEmpty() && callModel->hasCall(convInfo.confId)) { if (!convInfo.confId.isEmpty() && callModel->hasCall(convInfo.confId)) {
return true; return true;
@ -559,9 +573,10 @@ CallAdapter::isCurrentMaster() const
int int
CallAdapter::getCurrentLayoutType() const CallAdapter::getCurrentLayoutType() const
{ {
auto convInfo = LRCInstance::getConversationFromConvUid(convUid_, accountId_); auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid_);
if (!convInfo.uid.isEmpty()) { if (!convInfo.uid.isEmpty()) {
auto callModel = LRCInstance::getAccountInfo(accountId_).callModel.get(); auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
try { try {
auto call = callModel->getCall(convInfo.confId); auto call = callModel->getCall(convInfo.confId);
return Utils::toUnderlyingValue(call.layout); return Utils::toUnderlyingValue(call.layout);
@ -573,11 +588,11 @@ CallAdapter::getCurrentLayoutType() const
void void
CallAdapter::holdThisCallToggle() CallAdapter::holdThisCallToggle()
{ {
auto callId = LRCInstance::getCallIdForConversationUid(convUid_, accountId_); const auto callId = LRCInstance::getCallIdForConversationUid(convUid_, accountId_);
if (callId.isEmpty() || !LRCInstance::getCurrentCallModel()->hasCall(callId)) { if (callId.isEmpty() || !LRCInstance::getCurrentCallModel()->hasCall(callId)) {
return; return;
} }
auto callModel = LRCInstance::getCurrentCallModel(); auto* callModel = LRCInstance::getCurrentCallModel();
if (callModel->hasCall(callId)) { if (callModel->hasCall(callId)) {
callModel->togglePause(callId); callModel->togglePause(callId);
} }
@ -587,11 +602,11 @@ CallAdapter::holdThisCallToggle()
void void
CallAdapter::muteThisCallToggle() CallAdapter::muteThisCallToggle()
{ {
auto callId = LRCInstance::getCallIdForConversationUid(convUid_, accountId_); const auto callId = LRCInstance::getCallIdForConversationUid(convUid_, accountId_);
if (callId.isEmpty() || !LRCInstance::getCurrentCallModel()->hasCall(callId)) { if (callId.isEmpty() || !LRCInstance::getCurrentCallModel()->hasCall(callId)) {
return; return;
} }
auto callModel = LRCInstance::getCurrentCallModel(); auto* callModel = LRCInstance::getCurrentCallModel();
if (callModel->hasCall(callId)) { if (callModel->hasCall(callId)) {
callModel->toggleMedia(callId, lrc::api::NewCallModel::Media::AUDIO); callModel->toggleMedia(callId, lrc::api::NewCallModel::Media::AUDIO);
} }
@ -600,11 +615,11 @@ CallAdapter::muteThisCallToggle()
void void
CallAdapter::recordThisCallToggle() CallAdapter::recordThisCallToggle()
{ {
auto callId = LRCInstance::getCallIdForConversationUid(convUid_, accountId_); const auto callId = LRCInstance::getCallIdForConversationUid(convUid_, accountId_);
if (callId.isEmpty() || !LRCInstance::getCurrentCallModel()->hasCall(callId)) { if (callId.isEmpty() || !LRCInstance::getCurrentCallModel()->hasCall(callId)) {
return; return;
} }
auto callModel = LRCInstance::getCurrentCallModel(); auto* callModel = LRCInstance::getCurrentCallModel();
if (callModel->hasCall(callId)) { if (callModel->hasCall(callId)) {
callModel->toggleAudioRecord(callId); callModel->toggleAudioRecord(callId);
} }
@ -613,11 +628,11 @@ CallAdapter::recordThisCallToggle()
void void
CallAdapter::videoPauseThisCallToggle() CallAdapter::videoPauseThisCallToggle()
{ {
auto callId = LRCInstance::getCallIdForConversationUid(convUid_, accountId_); const auto callId = LRCInstance::getCallIdForConversationUid(convUid_, accountId_);
if (callId.isEmpty() || !LRCInstance::getCurrentCallModel()->hasCall(callId)) { if (callId.isEmpty() || !LRCInstance::getCurrentCallModel()->hasCall(callId)) {
return; return;
} }
auto callModel = LRCInstance::getCurrentCallModel(); auto* callModel = LRCInstance::getCurrentCallModel();
if (callModel->hasCall(callId)) { if (callModel->hasCall(callId)) {
callModel->toggleMedia(callId, lrc::api::NewCallModel::Media::VIDEO); callModel->toggleMedia(callId, lrc::api::NewCallModel::Media::VIDEO);
} }
@ -627,14 +642,14 @@ CallAdapter::videoPauseThisCallToggle()
void void
CallAdapter::setTime(const QString &accountId, const QString &convUid) CallAdapter::setTime(const QString &accountId, const QString &convUid)
{ {
auto callId = LRCInstance::getCallIdForConversationUid(convUid, accountId); const auto callId = LRCInstance::getCallIdForConversationUid(convUid, accountId);
if (callId.isEmpty() || !LRCInstance::getCurrentCallModel()->hasCall(callId)) { if (callId.isEmpty() || !LRCInstance::getCurrentCallModel()->hasCall(callId)) {
return; return;
} }
auto callInfo = LRCInstance::getCurrentCallModel()->getCall(callId); const auto callInfo = LRCInstance::getCurrentCallModel()->getCall(callId);
if (callInfo.status == lrc::api::call::Status::IN_PROGRESS if (callInfo.status == lrc::api::call::Status::IN_PROGRESS
|| callInfo.status == lrc::api::call::Status::PAUSED) { || callInfo.status == lrc::api::call::Status::PAUSED) {
auto timeString = LRCInstance::getCurrentCallModel()->getFormattedCallDuration(callId); auto timeString = LRCInstance::getCurrentCallModel()->getFormattedCallDuration(callId);
emit updateTimeText(timeString); emit updateTimeText(timeString);
} }
} }

View file

@ -91,8 +91,9 @@ void
ContactAdapter::contactSelected(int index) ContactAdapter::contactSelected(int index)
{ {
auto contactIndex = selectableProxyModel_->index(index, 0); auto contactIndex = selectableProxyModel_->index(index, 0);
auto callModel = LRCInstance::getCurrentCallModel(); auto* callModel = LRCInstance::getCurrentCallModel();
auto conversation = LRCInstance::getCurrentConversation(); auto* convModel = LRCInstance::getCurrentConversationModel();
const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
if (contactIndex.isValid()) { if (contactIndex.isValid()) {
switch (listModeltype_) { switch (listModeltype_) {
@ -100,15 +101,15 @@ ContactAdapter::contactSelected(int index)
/* /*
* Conference. * Conference.
*/ */
auto sectionName = contactIndex.data(SmartListModel::Role::SectionName).value<QString>(); const auto sectionName = contactIndex.data(SmartListModel::Role::SectionName).value<QString>();
if (!sectionName.isEmpty()) { if (!sectionName.isEmpty()) {
smartListModel_->toggleSection(sectionName); smartListModel_->toggleSection(sectionName);
return; return;
} }
auto convUid = contactIndex.data(SmartListModel::Role::UID).value<QString>(); const auto convUid = contactIndex.data(SmartListModel::Role::UID).value<QString>();
auto accId = contactIndex.data(SmartListModel::Role::AccountId).value<QString>(); const auto accId = contactIndex.data(SmartListModel::Role::AccountId).value<QString>();
auto callId = LRCInstance::getCallIdForConversationUid(convUid, accId); const auto callId = LRCInstance::getCallIdForConversationUid(convUid, accId);
if (!callId.isEmpty()) { if (!callId.isEmpty()) {
if (conversation.uid.isEmpty()) { if (conversation.uid.isEmpty()) {
@ -119,7 +120,7 @@ ContactAdapter::contactSelected(int index)
callModel->joinCalls(thisCallId, callId); callModel->joinCalls(thisCallId, callId);
} else { } else {
auto contactUri = contactIndex.data(SmartListModel::Role::URI).value<QString>(); const auto contactUri = contactIndex.data(SmartListModel::Role::URI).value<QString>();
auto call = LRCInstance::getCallInfoForConversation(conversation); auto call = LRCInstance::getCallInfoForConversation(conversation);
if (!call) { if (!call) {
return; return;
@ -131,12 +132,12 @@ ContactAdapter::contactSelected(int index)
/* /*
* SIP Transfer. * SIP Transfer.
*/ */
auto contactUri = contactIndex.data(SmartListModel::Role::URI).value<QString>(); const auto contactUri = contactIndex.data(SmartListModel::Role::URI).value<QString>();
if (conversation.uid.isEmpty()) { if (conversation.uid.isEmpty()) {
return; return;
} }
auto callId = conversation.confId.isEmpty() ? conversation.callId : conversation.confId; const auto callId = conversation.confId.isEmpty() ? conversation.callId : conversation.confId;
QString destCallId; QString destCallId;
@ -144,7 +145,7 @@ ContactAdapter::contactSelected(int index)
/* /*
* Check if the call exist - (check non-finished calls). * Check if the call exist - (check non-finished calls).
*/ */
auto callInfo = callModel->getCallFromURI(contactUri, true); const auto callInfo = callModel->getCallFromURI(contactUri, true);
destCallId = callInfo.id; destCallId = callInfo.id;
} catch (std::exception &e) { } catch (std::exception &e) {
qDebug().noquote() << e.what(); qDebug().noquote() << e.what();

View file

@ -36,8 +36,7 @@ ConversationsAdapter::initQmlObject()
{ {
conversationSmartListModel_ = new SmartListModel(LRCInstance::getCurrAccId(), this); conversationSmartListModel_ = new SmartListModel(LRCInstance::getCurrAccId(), this);
QMetaObject::invokeMethod(qmlObj_, QMetaObject::invokeMethod(qmlObj_, "setModel",
"setModel",
Q_ARG(QVariant, QVariant::fromValue(conversationSmartListModel_))); Q_ARG(QVariant, QVariant::fromValue(conversationSmartListModel_)));
connect(&LRCInstance::behaviorController(), connect(&LRCInstance::behaviorController(),
@ -71,30 +70,25 @@ ConversationsAdapter::selectConversation(const QString &accountId,
const QString &convUid, const QString &convUid,
bool preventSendingSignal) bool preventSendingSignal)
{ {
selectConversation(LRCInstance::getConversationFromConvUid(convUid, accountId), auto &accInfo = LRCInstance::getAccountInfo(accountId);
preventSendingSignal); const auto convInfo = accInfo.conversationModel->getConversationForUID(convUid);
selectConversation(convInfo, preventSendingSignal);
} }
void void
ConversationsAdapter::selectConversation(int index) ConversationsAdapter::selectConversation(const QString &convUid)
{ {
auto convModel = LRCInstance::getCurrentConversationModel(); auto* convModel = LRCInstance::getCurrentConversationModel();
if (convModel == nullptr) { if (convModel == nullptr) {
return; return;
} }
const auto item = convModel->filteredConversation(index); const auto &conversation = convModel->getConversationForUID(convUid);
if (selectConversation(item, false)) { if (selectConversation(conversation, false)) {
auto convUid = conversationSmartListModel_
->data(conversationSmartListModel_->index(index, 0), // If it is calling, show callview (can use showChatView signal, since it will be determined on qml).
static_cast<int>(SmartListModel::Role::UID))
.toString();
auto &conversation = LRCInstance::getConversationFromConvUid(convUid);
/*
* If it is calling, show callview (can use showChatView signal, since it will be determined on qml).
*/
if (!conversation.uid.isEmpty() if (!conversation.uid.isEmpty()
&& LRCInstance::getCurrentCallModel()->hasCall(conversation.callId)) { && LRCInstance::getCurrentCallModel()->hasCall(conversation.callId)) {
emit showChatView(LRCInstance::getCurrAccId(), conversation.uid); emit showChatView(LRCInstance::getCurrAccId(), conversation.uid);
@ -106,11 +100,9 @@ bool
ConversationsAdapter::selectConversation(const lrc::api::conversation::Info &item, ConversationsAdapter::selectConversation(const lrc::api::conversation::Info &item,
bool preventSendingSignal) bool preventSendingSignal)
{ {
/* // accInfo.conversationModel->selectConversation(item.uid) only emit ui
* accInfo.conversationModel->selectConversation(item.uid) only emit ui // behavior control signals, but sometimes we do not want that,
* behavior control signals, but sometimes we do not want that, // preventSendingSignal boolean can help us to determine.
* preventSendingSignal boolean can help us to determine.
*/
if (LRCInstance::getCurrentConvUid() == item.uid) { if (LRCInstance::getCurrentConvUid() == item.uid) {
return false; return false;
} else if (item.participants.size() > 0) { } else if (item.participants.size() > 0) {
@ -143,9 +135,7 @@ ConversationsAdapter::deselectConversation()
void void
ConversationsAdapter::accountChangedSetUp(const QString &accountId) ConversationsAdapter::accountChangedSetUp(const QString &accountId)
{ {
/* // Should be called when current account is changed.
* Should be called when current account is changed.
*/
auto &accountInfo = LRCInstance::accountModel().getAccountInfo(accountId); auto &accountInfo = LRCInstance::accountModel().getAccountInfo(accountId);
currentTypeFilter_ = accountInfo.profileInfo.type; currentTypeFilter_ = accountInfo.profileInfo.type;
LRCInstance::getCurrentConversationModel()->setFilter(accountInfo.profileInfo.type); LRCInstance::getCurrentConversationModel()->setFilter(accountInfo.profileInfo.type);
@ -157,9 +147,7 @@ ConversationsAdapter::accountChangedSetUp(const QString &accountId)
void void
ConversationsAdapter::updateConversationsFilterWidget() ConversationsAdapter::updateConversationsFilterWidget()
{ {
/* // Update status of "Conversations" and "Invitations".
* Update status of "Conversations" and "Invitations".
*/
auto invites = LRCInstance::getCurrentAccountInfo().contactModel->pendingRequestCount(); auto invites = LRCInstance::getCurrentAccountInfo().contactModel->pendingRequestCount();
if (invites == 0 && currentTypeFilter_ == lrc::api::profile::Type::PENDING) { if (invites == 0 && currentTypeFilter_ == lrc::api::profile::Type::PENDING) {
currentTypeFilter_ = lrc::api::profile::Type::RING; currentTypeFilter_ = lrc::api::profile::Type::RING;
@ -171,10 +159,8 @@ ConversationsAdapter::updateConversationsFilterWidget()
void void
ConversationsAdapter::setConversationFilter(const QString &type) ConversationsAdapter::setConversationFilter(const QString &type)
{ {
/* // Set conversation filter according to type,
* Set conversation filter according to type, // type needs to be recognizable by lrc::api::profile::to_type.
* type needs to be recognizable by lrc::api::profile::to_type.
*/
if (type.isEmpty()) { if (type.isEmpty()) {
if (LRCInstance::getCurrentAccountInfo().profileInfo.type == lrc::api::profile::Type::RING) if (LRCInstance::getCurrentAccountInfo().profileInfo.type == lrc::api::profile::Type::RING)
setConversationFilter(lrc::api::profile::Type::RING); setConversationFilter(lrc::api::profile::Type::RING);
@ -198,10 +184,8 @@ ConversationsAdapter::setConversationFilter(lrc::api::profile::Type filter)
bool bool
ConversationsAdapter::connectConversationModel() ConversationsAdapter::connectConversationModel()
{ {
/* // Signal connections
* Signal connections auto currentConversationModel = LRCInstance::getCurrentConversationModel();
*/
auto currentConversationModel = LRCInstance::getCurrentAccountInfo().conversationModel.get();
QObject::disconnect(modelSortedConnection_); QObject::disconnect(modelSortedConnection_);
QObject::disconnect(modelUpdatedConnection_); QObject::disconnect(modelUpdatedConnection_);
@ -211,81 +195,98 @@ ConversationsAdapter::connectConversationModel()
QObject::disconnect(conversationClearedConnection); QObject::disconnect(conversationClearedConnection);
QObject::disconnect(newInteractionConnection_); QObject::disconnect(newInteractionConnection_);
QObject::disconnect(interactionRemovedConnection_); QObject::disconnect(interactionRemovedConnection_);
QObject::disconnect(searchStatusChangedConnection_);
QObject::disconnect(searchResultUpdatedConnection_);
modelSortedConnection_ = QObject::connect( modelSortedConnection_ = QObject::connect(currentConversationModel,
currentConversationModel, &lrc::api::ConversationModel::modelSorted, [this]() { &lrc::api::ConversationModel::modelSorted,
updateConversationsFilterWidget(); [this]() {
QMetaObject::invokeMethod(qmlObj_, "updateConversationSmartListView"); conversationSmartListModel_->fillConversationsList();
auto convUid = LRCInstance::getCurrentConversation().uid; updateConversationsFilterWidget();
auto convModel = LRCInstance::getCurrentConversationModel(); QMetaObject::invokeMethod(qmlObj_, "updateConversationSmartListView");
auto &conversation = LRCInstance::getConversationFromConvUid(convUid); auto* convModel = LRCInstance::getCurrentConversationModel();
if (conversation.uid.isEmpty()) { const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
return;
}
auto contactURI = conversation.participants[0];
if (contactURI.isEmpty()
|| convModel->owner.contactModel->getContact(contactURI).profileInfo.type
== lrc::api::profile::Type::TEMPORARY) {
return;
}
QMetaObject::invokeMethod(qmlObj_, "modelSorted", Q_ARG(QVariant, contactURI));
});
modelUpdatedConnection_ if (conversation.uid.isEmpty() || conversation.participants.isEmpty()) {
= QObject::connect(currentConversationModel, return;
&lrc::api::ConversationModel::conversationUpdated, }
[this](const QString &convUid) { const auto contactURI = conversation.participants[0];
Q_UNUSED(convUid); if (contactURI.isEmpty()
updateConversationsFilterWidget(); || convModel->owner.contactModel->getContact(contactURI).profileInfo.type
QMetaObject::invokeMethod(qmlObj_, "updateConversationSmartListView"); == lrc::api::profile::Type::TEMPORARY) {
}); return;
}
QMetaObject::invokeMethod(qmlObj_, "modelSorted", Q_ARG(QVariant, contactURI));
});
filterChangedConnection_ = QObject::connect( modelUpdatedConnection_ = QObject::connect(currentConversationModel,
currentConversationModel, &lrc::api::ConversationModel::filterChanged, [this]() { &lrc::api::ConversationModel::conversationUpdated,
QMetaObject::invokeMethod(qmlObj_, [this](const QString &convUid) {
"updateSmartList", conversationSmartListModel_->updateConversation(convUid);
Q_ARG(QVariant, LRCInstance::getCurrAccId())); updateConversationsFilterWidget();
updateConversationsFilterWidget(); QMetaObject::invokeMethod(qmlObj_, "updateConversationSmartListView");
QMetaObject::invokeMethod(qmlObj_, "updateConversationSmartListView"); });
});
newConversationConnection_ filterChangedConnection_ = QObject::connect(currentConversationModel,
= QObject::connect(currentConversationModel, &lrc::api::ConversationModel::filterChanged,
&lrc::api::ConversationModel::newConversation, [this]() {
[this](const QString &convUid) { conversationSmartListModel_->fillConversationsList();
QMetaObject::invokeMethod(qmlObj_, QMetaObject::invokeMethod(qmlObj_,
"updateSmartList", "updateSmartList",
Q_ARG(QVariant, Q_ARG(QVariant, LRCInstance::getCurrAccId()));
LRCInstance::getCurrAccId())); updateConversationsFilterWidget();
updateConversationForNewContact(convUid); QMetaObject::invokeMethod(qmlObj_, "updateConversationSmartListView");
}); });
conversationRemovedConnection_ newConversationConnection_ = QObject::connect(currentConversationModel,
= QObject::connect(currentConversationModel, &lrc::api::ConversationModel::newConversation,
&lrc::api::ConversationModel::conversationRemoved, [this](const QString &convUid) {
[this]() { backToWelcomePage(); }); conversationSmartListModel_->fillConversationsList();
QMetaObject::invokeMethod(qmlObj_,
"updateSmartList",
Q_ARG(QVariant, LRCInstance::getCurrAccId()));
updateConversationForNewContact(convUid);
});
conversationClearedConnection conversationRemovedConnection_ = QObject::connect(currentConversationModel,
= QObject::connect(currentConversationModel, &lrc::api::ConversationModel::conversationRemoved,
&lrc::api::ConversationModel::conversationCleared, [this]() {
[this](const QString &convUid) { conversationSmartListModel_->fillConversationsList();
/* backToWelcomePage();
* If currently selected, });
* switch to welcome screen (deselecting current smartlist item ).
*/
if (convUid != LRCInstance::getCurrentConvUid()) {
return;
}
backToWelcomePage();
});
newInteractionConnection_ conversationClearedConnection = QObject::connect(currentConversationModel,
= QObject::connect(currentConversationModel, &lrc::api::ConversationModel::conversationCleared,
&lrc::api::ConversationModel::newInteraction, [this](const QString &convUid) {
[this] { // If currently selected, switch to welcome screen (deselecting current smartlist item ).
updateConversationsFilterWidget(); if (convUid != LRCInstance::getCurrentConvUid()) {
QMetaObject::invokeMethod(qmlObj_, "updateConversationSmartListView"); return;
}); }
backToWelcomePage();
});
newInteractionConnection_ = QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::newInteraction,
[this] {
conversationSmartListModel_->fillConversationsList();
updateConversationsFilterWidget();
QMetaObject::invokeMethod(qmlObj_, "updateConversationSmartListView");
});
searchStatusChangedConnection_ = QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::searchStatusChanged,
[this](const QString &status) {
emit showSearchStatus(status);
});
searchResultUpdatedConnection_ = QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::searchResultUpdated,
[this]() {
conversationSmartListModel_->fillConversationsList();
QMetaObject::invokeMethod(qmlObj_, "updateSmartList",
Q_ARG(QVariant, LRCInstance::getCurrAccId()));
QMetaObject::invokeMethod(qmlObj_, "updateConversationSmartListView");
});
currentConversationModel->setFilter(""); currentConversationModel->setFilter("");
return true; return true;
@ -294,15 +295,15 @@ ConversationsAdapter::connectConversationModel()
void void
ConversationsAdapter::updateConversationForNewContact(const QString &convUid) ConversationsAdapter::updateConversationForNewContact(const QString &convUid)
{ {
auto convModel = LRCInstance::getCurrentConversationModel(); auto* convModel = LRCInstance::getCurrentConversationModel();
if (convModel == nullptr) { if (convModel == nullptr) {
return; return;
} }
auto selectedUid = LRCInstance::getCurrentConvUid(); const auto selectedUid = LRCInstance::getCurrentConvUid();
auto &conversation = LRCInstance::getConversationFromConvUid(convUid, {}, true); const auto conversation = convModel->getConversationForUID(convUid);
if (!conversation.uid.isEmpty()) { if (!conversation.uid.isEmpty() && !conversation.participants.isEmpty()) {
try { try {
auto contact = convModel->owner.contactModel->getContact(conversation.participants[0]); const auto contact = convModel->owner.contactModel->getContact(conversation.participants[0]);
if (!contact.profileInfo.uri.isEmpty() && contact.profileInfo.uri == selectedUid) { if (!contact.profileInfo.uri.isEmpty() && contact.profileInfo.uri == selectedUid) {
LRCInstance::setSelectedConvId(convUid); LRCInstance::setSelectedConvId(convUid);
convModel->selectConversation(convUid); convModel->selectConversation(convUid);
@ -311,4 +312,4 @@ ConversationsAdapter::updateConversationForNewContact(const QString &convUid)
return; return;
} }
} }
} }

View file

@ -37,7 +37,7 @@ public:
Q_INVOKABLE void selectConversation(const QString &accountId, Q_INVOKABLE void selectConversation(const QString &accountId,
const QString &convUid, const QString &convUid,
bool preventSendingSignal = true); bool preventSendingSignal = true);
Q_INVOKABLE void selectConversation(int index); Q_INVOKABLE void selectConversation(const QString &uid);
Q_INVOKABLE void deselectConversation(); Q_INVOKABLE void deselectConversation();
Q_INVOKABLE void accountChangedSetUp(const QString &accountId); Q_INVOKABLE void accountChangedSetUp(const QString &accountId);
Q_INVOKABLE void updateConversationsFilterWidget(); Q_INVOKABLE void updateConversationsFilterWidget();
@ -46,6 +46,7 @@ public:
signals: signals:
void showChatView(const QString &accountId, const QString &convUid); void showChatView(const QString &accountId, const QString &convUid);
void showConversationTabs(bool visible); void showConversationTabs(bool visible);
void showSearchStatus(const QString &status);
public slots: public slots:
void slotAccountChanged(); void slotAccountChanged();
@ -75,4 +76,6 @@ private:
QMetaObject::Connection selectedCallChanged_; QMetaObject::Connection selectedCallChanged_;
QMetaObject::Connection smartlistSelectionConnection_; QMetaObject::Connection smartlistSelectionConnection_;
QMetaObject::Connection interactionRemovedConnection_; QMetaObject::Connection interactionRemovedConnection_;
QMetaObject::Connection searchStatusChangedConnection_;
QMetaObject::Connection searchResultUpdatedConnection_;
}; };

View file

@ -156,7 +156,8 @@ public:
static QString static QString
getCallIdForConversationUid(const QString &convUid, const QString &accountId) getCallIdForConversationUid(const QString &convUid, const QString &accountId)
{ {
auto convInfo = LRCInstance::getConversationFromConvUid(convUid, accountId); auto &accInfo = LRCInstance::getAccountInfo(accountId);
auto convInfo = accInfo.conversationModel->getConversationForUID(convUid);
if (convInfo.uid.isEmpty()) { if (convInfo.uid.isEmpty()) {
return {}; return {};
} }
@ -233,16 +234,6 @@ public:
filtered); filtered);
} }
static const conversation::Info & static const conversation::Info &
getConversationFromConvUid(const QString &convUid,
const QString &accountId = {},
bool filtered = false)
{
return getConversation(
!accountId.isEmpty() ? accountId : getCurrAccId(),
[&](const conversation::Info &conv) -> bool { return convUid == conv.uid; },
filtered);
}
static const conversation::Info &
getConversationFromPeerUri(const QString &peerUri, getConversationFromPeerUri(const QString &peerUri,
const QString &accountId = {}, const QString &accountId = {},
bool filtered = false) bool filtered = false)
@ -252,11 +243,6 @@ public:
[&](const conversation::Info &conv) -> bool { return peerUri == conv.participants[0]; }, [&](const conversation::Info &conv) -> bool { return peerUri == conv.participants[0]; },
filtered); filtered);
} }
static const conversation::Info &
getCurrentConversation()
{
return getConversationFromConvUid(getCurrentConvUid());
}
static ConversationModel * static ConversationModel *
getCurrentConversationModel() getCurrentConversationModel()

View file

@ -25,7 +25,7 @@ ListView {
id: conversationSmartListView id: conversationSmartListView
signal needToAccessMessageWebView(string currentUserDisplayName, string currentUserAlias, string currentUID, bool callStackViewShouldShow, bool isAudioOnly, string callStateStr) signal needToAccessMessageWebView(string currentUserDisplayName, string currentUserAlias, string currentUID, bool callStackViewShouldShow, bool isAudioOnly, string callStateStr)
signal needToSelectItems(int index) signal needToSelectItems(string conversationUid)
signal needToDeselectItems signal needToDeselectItems
signal needToBackToWelcomePage signal needToBackToWelcomePage
signal needToGrabFocus signal needToGrabFocus

View file

@ -84,13 +84,15 @@ ItemDelegate {
anchors.left: conversationSmartListUserImage.right anchors.left: conversationSmartListUserImage.right
anchors.leftMargin: 16 anchors.leftMargin: 16
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: 16 anchors.topMargin: conversationSmartListUserLastInteractionMessage.text !== "" ?
16 : parent.height/2-conversationSmartListUserName.height/2
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 10 anchors.rightMargin: 10
Text { Text {
id: conversationSmartListUserName id: conversationSmartListUserName
Layout.alignment: Qt.AlignLeft Layout.alignment: conversationSmartListUserLastInteractionMessage.text !== "" ?
Qt.AlignLeft : Qt.AlignLeft | Qt.AlignVCenter
TextMetrics { TextMetrics {
id: textMetricsConversationSmartListUserName id: textMetricsConversationSmartListUserName
@ -197,7 +199,7 @@ ItemDelegate {
smartListContextMenu.openMenu() smartListContextMenu.openMenu()
} else if (mouse.button === Qt.LeftButton) { } else if (mouse.button === Qt.LeftButton) {
conversationSmartListView.currentIndex = index conversationSmartListView.currentIndex = index
conversationSmartListView.needToSelectItems(index) conversationSmartListView.needToSelectItems(UID)
conversationSmartListView.needToGrabFocus() conversationSmartListView.needToGrabFocus()
} }
} }

View file

@ -98,7 +98,7 @@ Rectangle {
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
Layout.preferredWidth: userNameOrIdRect.width Layout.preferredWidth: userNameOrIdRect.width
Layout.preferredHeight: textMetricsuserAliasLabel.boundingRect.height Layout.preferredHeight: textMetricsuserAliasLabel.boundingRect.height
Layout.topMargin: userUserNameLabel.text == "" ? 0 : 10 Layout.topMargin: userUserNameLabel.text === "" ? 0 : 10
font.pointSize: JamiTheme.menuFontSize font.pointSize: JamiTheme.menuFontSize
@ -119,7 +119,7 @@ Rectangle {
Label { Label {
id: userUserNameLabel id: userUserNameLabel
visible: (text != "") visible: (text !== "")
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
Layout.preferredWidth: userNameOrIdRect.width Layout.preferredWidth: userNameOrIdRect.width
Layout.preferredHeight: textMetricsuserUserNameLabel.boundingRect.height Layout.preferredHeight: textMetricsuserUserNameLabel.boundingRect.height

View file

@ -136,13 +136,13 @@ Rectangle {
} }
function stopRecording() { function stopRecording() {
if (pathRecorder != "") { if (pathRecorder !== "") {
ClientWrapper.avmodel.stopLocalRecorder(pathRecorder) ClientWrapper.avmodel.stopLocalRecorder(pathRecorder)
} }
} }
function sendRecord() { function sendRecord() {
if (pathRecorder != "") { if (pathRecorder !== "") {
MessagesAdapter.sendFile(pathRecorder) MessagesAdapter.sendFile(pathRecorder)
} }
} }

View file

@ -152,12 +152,68 @@ Rectangle {
height: tabBarVisible ? 64 : 0 height: tabBarVisible ? 64 : 0
} }
Rectangle {
id: searchStatusRect
visible: lblSearchStatus.text !== ""
anchors.top: tabBarVisible ? sidePanelTabBar.bottom : contactSearchBar.bottom
anchors.topMargin: tabBarVisible ? 0 : 10
width: parent.width
height: 72
color: "transparent"
Image {
id: searchIcon
anchors.left: searchStatusRect.left
anchors.leftMargin: 24
anchors.verticalCenter: searchStatusRect.verticalCenter
width: 24
height: 24
fillMode: Image.PreserveAspectFit
mipmap: true
source: "qrc:/images/icons/ic_baseline-search-24px.svg"
}
Label {
id: lblSearchStatus
anchors.verticalCenter: searchStatusRect.verticalCenter
anchors.left: searchIcon.right
anchors.leftMargin: 24
width: searchStatusRect.width - searchIcon.width - 24*2 - 8
text: ""
wrapMode: Text.WordWrap
font.pointSize: JamiTheme.menuFontSize
}
MouseArea {
id: mouseAreaSearchRect
anchors.fill: parent
hoverEnabled: true
onReleased: {
searchStatusRect.color = JamiTheme.releaseColor
}
onEntered: {
searchStatusRect.color = JamiTheme.hoverColor
}
onExited: {
searchStatusRect.color = JamiTheme.backgroundColor
}
}
}
ConversationSmartListView { ConversationSmartListView {
id: conversationSmartListView id: conversationSmartListView
anchors.top: tabBarVisible ? sidePanelTabBar.bottom : contactSearchBar.bottom anchors.top: searchStatusRect.visible ? searchStatusRect.bottom : (tabBarVisible ? sidePanelTabBar.bottom : contactSearchBar.bottom)
anchors.topMargin: tabBarVisible ? 0 : 10 anchors.topMargin: (tabBarVisible || searchStatusRect.visible) ? 0 : 10
width: parent.width width: parent.width
height: tabBarVisible ? sidePanelRect.height - sidePanelTabBar.height - contactSearchBar.height - 20 : height: tabBarVisible ? sidePanelRect.height - sidePanelTabBar.height - contactSearchBar.height - 20 :
sidePanelRect.height - contactSearchBar.height - 20 sidePanelRect.height - contactSearchBar.height - 20
@ -175,10 +231,14 @@ Rectangle {
updatePendingRequestCount() updatePendingRequestCount()
updateTotalUnreadMessagesCount() updateTotalUnreadMessagesCount()
} }
function onShowSearchStatus(status) {
lblSearchStatus.text = status
}
} }
onNeedToSelectItems: { onNeedToSelectItems: {
ConversationsAdapter.selectConversation(index) ConversationsAdapter.selectConversation(conversationUid)
} }
onNeedToBackToWelcomePage: { onNeedToBackToWelcomePage: {

View file

@ -57,8 +57,13 @@ MessagesAdapter::slotAccountChanged()
void void
MessagesAdapter::setupChatView(const QString &uid) MessagesAdapter::setupChatView(const QString &uid)
{ {
auto &convInfo = LRCInstance::getConversationFromConvUid(uid);
if (convInfo.uid.isEmpty()) { auto* convModel = LRCInstance::getCurrentConversationModel();
if (convModel == nullptr) {
return;
}
const auto &convInfo = convModel->getConversationForUID(uid);
if (convInfo.uid.isEmpty() || convInfo.participants.isEmpty()) {
return; return;
} }
@ -111,36 +116,28 @@ MessagesAdapter::setupChatView(const QString &uid)
void void
MessagesAdapter::connectConversationModel() MessagesAdapter::connectConversationModel()
{ {
auto currentConversationModel = LRCInstance::getCurrentAccountInfo().conversationModel.get(); auto currentConversationModel = LRCInstance::getCurrentConversationModel();
QObject::disconnect(newInteractionConnection_); QObject::disconnect(newInteractionConnection_);
QObject::disconnect(interactionRemovedConnection_); QObject::disconnect(interactionRemovedConnection_);
QObject::disconnect(interactionStatusUpdatedConnection_); QObject::disconnect(interactionStatusUpdatedConnection_);
newInteractionConnection_ newInteractionConnection_ = QObject::connect(currentConversationModel,
= QObject::connect(currentConversationModel, &lrc::api::ConversationModel::newInteraction,
&lrc::api::ConversationModel::newInteraction, [this](const QString &convUid, uint64_t interactionId,
[this](const QString &convUid, const lrc::api::interaction::Info &interaction) {
uint64_t interactionId, auto accountId = LRCInstance::getCurrAccId();
const lrc::api::interaction::Info &interaction) { newInteraction(accountId, convUid, interactionId, interaction);
auto accountId = LRCInstance::getCurrAccId(); });
newInteraction(accountId, convUid, interactionId, interaction);
});
interactionStatusUpdatedConnection_ = QObject::connect( interactionStatusUpdatedConnection_ = QObject::connect(currentConversationModel,
currentConversationModel, &lrc::api::ConversationModel::interactionStatusUpdated,
&lrc::api::ConversationModel::interactionStatusUpdated, [this](const QString &convUid, uint64_t interactionId,
[this](const QString &convUid, const lrc::api::interaction::Info &interaction) {
uint64_t interactionId, auto currentConversationModel = LRCInstance::getCurrentConversationModel();
const lrc::api::interaction::Info &interaction) { currentConversationModel->clearUnreadInteractions(convUid);
if (convUid != LRCInstance::getCurrentConvUid()) { updateInteraction(*currentConversationModel, interactionId, interaction);
return; });
}
auto &currentAccountInfo = LRCInstance::getCurrentAccountInfo();
auto currentConversationModel = currentAccountInfo.conversationModel.get();
currentConversationModel->clearUnreadInteractions(convUid);
updateInteraction(*currentConversationModel, interactionId, interaction);
});
interactionRemovedConnection_ interactionRemovedConnection_
= QObject::connect(currentConversationModel, = QObject::connect(currentConversationModel,
@ -156,16 +153,16 @@ MessagesAdapter::connectConversationModel()
void void
MessagesAdapter::sendContactRequest() MessagesAdapter::sendContactRequest()
{ {
auto convInfo = LRCInstance::getCurrentConversation(); const auto convUid = LRCInstance::getCurrentConvUid();
if (!convInfo.uid.isEmpty()) { if (!convUid.isEmpty()) {
LRCInstance::getCurrentConversationModel()->makePermanent(convInfo.uid); LRCInstance::getCurrentConversationModel()->makePermanent(convUid);
} }
} }
void void
MessagesAdapter::accountChangedSetUp(const QString &accoountId) MessagesAdapter::accountChangedSetUp(const QString &accountId)
{ {
Q_UNUSED(accoountId) Q_UNUSED(accountId)
connectConversationModel(); connectConversationModel();
} }
@ -173,8 +170,8 @@ MessagesAdapter::accountChangedSetUp(const QString &accoountId)
void void
MessagesAdapter::updateConversationForAddedContact() MessagesAdapter::updateConversationForAddedContact()
{ {
auto conversation = LRCInstance::getCurrentConversation(); auto* convModel = LRCInstance::getCurrentConversationModel();
auto convModel = LRCInstance::getCurrentConversationModel(); const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
clear(); clear();
setConversationProfileData(conversation); setConversationProfileData(conversation);
@ -211,8 +208,8 @@ MessagesAdapter::slotUpdateDraft(const QString &content)
void void
MessagesAdapter::slotMessagesCleared() MessagesAdapter::slotMessagesCleared()
{ {
auto &convInfo = LRCInstance::getConversationFromConvUid(LRCInstance::getCurrentConvUid()); auto* convModel = LRCInstance::getCurrentConversationModel();
auto convModel = LRCInstance::getCurrentConversationModel(); const auto convInfo = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
printHistory(*convModel, convInfo.interactions); printHistory(*convModel, convInfo.interactions);
@ -231,7 +228,7 @@ void
MessagesAdapter::sendMessage(const QString &message) MessagesAdapter::sendMessage(const QString &message)
{ {
try { try {
auto convUid = LRCInstance::getCurrentConvUid(); const auto convUid = LRCInstance::getCurrentConvUid();
LRCInstance::getCurrentConversationModel()->sendMessage(convUid, message); LRCInstance::getCurrentConversationModel()->sendMessage(convUid, message);
} catch (...) { } catch (...) {
qDebug() << "Exception during sendMessage:" << message; qDebug() << "Exception during sendMessage:" << message;
@ -373,7 +370,7 @@ MessagesAdapter::refuseFile(const QString &arg)
{ {
try { try {
auto interactionUid = arg.toLongLong(); auto interactionUid = arg.toLongLong();
auto convUid = LRCInstance::getCurrentConvUid(); const auto convUid = LRCInstance::getCurrentConvUid();
LRCInstance::getCurrentConversationModel()->cancelTransfer(convUid, interactionUid); LRCInstance::getCurrentConversationModel()->cancelTransfer(convUid, interactionUid);
} catch (...) { } catch (...) {
qDebug() << "JS bridging - exception during refuseFile:" << arg; qDebug() << "JS bridging - exception during refuseFile:" << arg;
@ -436,10 +433,15 @@ MessagesAdapter::onComposing(bool isComposing)
void void
MessagesAdapter::setConversationProfileData(const lrc::api::conversation::Info &convInfo) MessagesAdapter::setConversationProfileData(const lrc::api::conversation::Info &convInfo)
{ {
auto convModel = LRCInstance::getCurrentConversationModel(); auto* convModel = LRCInstance::getCurrentConversationModel();
auto accInfo = &LRCInstance::getCurrentAccountInfo(); auto accInfo = &LRCInstance::getCurrentAccountInfo();
auto contactUri = convInfo.participants.front(); const auto conv = convModel->getConversationForUID(convInfo.uid);
if (conv.participants.isEmpty()) {
return;
}
auto contactUri = conv.participants.front();
if (contactUri.isEmpty()) { if (contactUri.isEmpty()) {
return; return;
} }
@ -473,7 +475,7 @@ MessagesAdapter::newInteraction(const QString &accountId,
try { try {
auto &accountInfo = LRCInstance::getAccountInfo(accountId); auto &accountInfo = LRCInstance::getAccountInfo(accountId);
auto &convModel = accountInfo.conversationModel; auto &convModel = accountInfo.conversationModel;
auto &conversation = LRCInstance::getConversationFromConvUid(convUid, accountId); const auto conversation = convModel->getConversationForUID(convUid);
if (conversation.uid.isEmpty()) { if (conversation.uid.isEmpty()) {
return; return;
@ -646,7 +648,7 @@ MessagesAdapter::contactIsComposing(const QString &uid, const QString &contactUr
void void
MessagesAdapter::acceptInvitation() MessagesAdapter::acceptInvitation()
{ {
auto convUid = LRCInstance::getCurrentConvUid(); const auto convUid = LRCInstance::getCurrentConvUid();
LRCInstance::getCurrentConversationModel()->makePermanent(convUid); LRCInstance::getCurrentConversationModel()->makePermanent(convUid);
} }

View file

@ -35,7 +35,7 @@ public:
Q_INVOKABLE void setupChatView(const QString &uid); Q_INVOKABLE void setupChatView(const QString &uid);
Q_INVOKABLE void connectConversationModel(); Q_INVOKABLE void connectConversationModel();
Q_INVOKABLE void sendContactRequest(); Q_INVOKABLE void sendContactRequest();
Q_INVOKABLE void accountChangedSetUp(const QString &accoountId); Q_INVOKABLE void accountChangedSetUp(const QString &accountId);
Q_INVOKABLE void updateConversationForAddedContact(); Q_INVOKABLE void updateConversationForAddedContact();
/* /*
@ -109,4 +109,4 @@ private:
QMetaObject::Connection newInteractionConnection_; QMetaObject::Connection newInteractionConnection_;
QMetaObject::Connection interactionStatusUpdatedConnection_; QMetaObject::Connection interactionStatusUpdatedConnection_;
QMetaObject::Connection interactionRemovedConnection_; QMetaObject::Connection interactionRemovedConnection_;
}; };

View file

@ -53,7 +53,9 @@ public:
/* /*
* For contact_xxx, xxx is "" initially * For contact_xxx, xxx is "" initially
*/ */
auto convInfo = LRCInstance::getConversationFromConvUid(list[1]);
auto convModel = LRCInstance::getCurrentConversationModel();
auto convInfo = convModel->getConversationForUID(list[1]);
auto contact = LRCInstance::getCurrentAccountInfo().contactModel->getContact( auto contact = LRCInstance::getCurrentAccountInfo().contactModel->getContact(
convInfo.participants.at(0)); convInfo.participants.at(0));
return QPair(QrType::Contact, contact.profileInfo.uri); return QPair(QrType::Contact, contact.profileInfo.uri);
@ -90,4 +92,4 @@ public:
else else
return Utils::setupQRCode(uri, 0); return Utils::setupQRCode(uri, 0);
} }
}; };

View file

@ -65,7 +65,8 @@ SmartListModel::rowCount(const QModelIndex &parent) const
} }
return rowCount; return rowCount;
} }
return accInfo.conversationModel->allFilteredConversations().size(); return accInfo.conversationModel->allFilteredConversations().size()
+ accInfo.conversationModel->getAllSearchResults().size();
} }
return 0; return 0;
} }
@ -130,11 +131,11 @@ SmartListModel::data(const QModelIndex &index, int role) const
if (role == Role::AccountId) { if (role == Role::AccountId) {
return QVariant(itemAccId); return QVariant(itemAccId);
} }
item = LRCInstance::getConversationFromConvUid(itemConvUid, itemAccId);
auto &itemAccountInfo = LRCInstance::accountModel().getAccountInfo(itemAccId); auto &itemAccountInfo = LRCInstance::accountModel().getAccountInfo(itemAccId);
item = itemAccountInfo.conversationModel->getConversationForUID(itemConvUid);
return getConversationItemData(item, itemAccountInfo, role); return getConversationItemData(item, itemAccountInfo, role);
} else if (listModelType_ == Type::CONVERSATION) { } else if (listModelType_ == Type::CONVERSATION) {
item = convModel->filteredConversation(index.row()); item = conversations_.at(index.row());
return getConversationItemData(item, accountInfo, role); return getConversationItemData(item, accountInfo, role);
} }
} catch (const std::exception &e) { } catch (const std::exception &e) {
@ -179,6 +180,35 @@ SmartListModel::setConferenceableFilter(const QString &filter)
endResetModel(); endResetModel();
} }
void
SmartListModel::fillConversationsList()
{
beginResetModel();
auto* convModel = LRCInstance::getCurrentConversationModel();
conversations_.clear();
for (auto convSearch : convModel->getAllSearchResults()) {
conversations_.emplace_back(convSearch);
}
for (auto convFilt : convModel->allFilteredConversations()) {
conversations_.emplace_back(convFilt);
}
endResetModel();
}
void
SmartListModel::updateConversation(const QString &convUid)
{
auto* convModel = LRCInstance::getCurrentConversationModel();
for (lrc::api::conversation::Info &conversation : conversations_) {
if (conversation.uid == convUid) {
conversation = convModel->getConversationForUID(convUid);
return;
}
}
}
void void
SmartListModel::toggleSection(const QString &section) SmartListModel::toggleSection(const QString &section)
{ {
@ -194,7 +224,7 @@ SmartListModel::toggleSection(const QString &section)
int int
SmartListModel::currentUidSmartListModelIndex() SmartListModel::currentUidSmartListModelIndex()
{ {
auto convUid = LRCInstance::getCurrentConvUid(); const auto convUid = LRCInstance::getCurrentConvUid();
for (int i = 0; i < rowCount(); i++) { for (int i = 0; i < rowCount(); i++) {
if (convUid == data(index(i, 0), Role::UID)) if (convUid == data(index(i, 0), Role::UID))
return i; return i;
@ -278,17 +308,19 @@ SmartListModel::getConversationItemData(const conversation::Info &item,
case Role::UID: case Role::UID:
return QVariant(item.uid); return QVariant(item.uid);
case Role::InCall: { case Role::InCall: {
auto &convInfo = LRCInstance::getConversationFromConvUid(item.uid); auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(item.uid);
if (!convInfo.uid.isEmpty()) { if (!convInfo.uid.isEmpty()) {
auto callModel = LRCInstance::getCurrentCallModel(); auto* callModel = LRCInstance::getCurrentCallModel();
return QVariant(callModel->hasCall(convInfo.callId)); return QVariant(callModel->hasCall(convInfo.callId));
} }
return QVariant(false); return QVariant(false);
} }
case Role::IsAudioOnly: { case Role::IsAudioOnly: {
auto &convInfo = LRCInstance::getConversationFromConvUid(item.uid); auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(item.uid);
if (!convInfo.uid.isEmpty()) { if (!convInfo.uid.isEmpty()) {
auto call = LRCInstance::getCallInfoForConversation(convInfo); auto* call = LRCInstance::getCallInfoForConversation(convInfo);
if (call) { if (call) {
return QVariant(call->isAudioOnly); return QVariant(call->isAudioOnly);
} }
@ -296,10 +328,11 @@ SmartListModel::getConversationItemData(const conversation::Info &item,
return QVariant(); return QVariant();
} }
case Role::CallStackViewShouldShow: { case Role::CallStackViewShouldShow: {
auto &convInfo = LRCInstance::getConversationFromConvUid(item.uid); auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(item.uid);
if (!convInfo.uid.isEmpty()) { if (!convInfo.uid.isEmpty()) {
auto callModel = LRCInstance::getCurrentCallModel(); auto* callModel = LRCInstance::getCurrentCallModel();
auto call = callModel->getCall(convInfo.callId); const auto call = callModel->getCall(convInfo.callId);
return QVariant(callModel->hasCall(convInfo.callId) return QVariant(callModel->hasCall(convInfo.callId)
&& ((!call.isOutgoing && ((!call.isOutgoing
&& (call.status == lrc::api::call::Status::IN_PROGRESS && (call.status == lrc::api::call::Status::IN_PROGRESS
@ -309,9 +342,10 @@ SmartListModel::getConversationItemData(const conversation::Info &item,
return QVariant(false); return QVariant(false);
} }
case Role::CallStateStr: { case Role::CallStateStr: {
auto &convInfo = LRCInstance::getConversationFromConvUid(item.uid); auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(item.uid);
if (!convInfo.uid.isEmpty()) { if (!convInfo.uid.isEmpty()) {
auto call = LRCInstance::getCallInfoForConversation(convInfo); auto* call = LRCInstance::getCallInfoForConversation(convInfo);
if (call) { if (call) {
auto statusString = call::to_string(call->status); auto statusString = call::to_string(call->status);
return QVariant(statusString); return QVariant(statusString);
@ -323,7 +357,7 @@ SmartListModel::getConversationItemData(const conversation::Info &item,
return QVariant(QString()); return QVariant(QString());
case Role::Draft: { case Role::Draft: {
if (!item.uid.isEmpty()) { if (!item.uid.isEmpty()) {
auto draft = LRCInstance::getContentDraft(item.uid, accountInfo.id); const auto draft = LRCInstance::getContentDraft(item.uid, accountInfo.id);
if (!draft.isEmpty()) { if (!draft.isEmpty()) {
/* /*
* Pencil Emoji * Pencil Emoji

View file

@ -82,6 +82,8 @@ public:
Q_INVOKABLE void setConferenceableFilter(const QString &filter = {}); Q_INVOKABLE void setConferenceableFilter(const QString &filter = {});
Q_INVOKABLE void toggleSection(const QString &section); Q_INVOKABLE void toggleSection(const QString &section);
Q_INVOKABLE int currentUidSmartListModelIndex(); Q_INVOKABLE int currentUidSmartListModelIndex();
Q_INVOKABLE void fillConversationsList();
Q_INVOKABLE void updateConversation(const QString &conv);
private: private:
QString accountId_; QString accountId_;
@ -96,4 +98,5 @@ private:
Type listModelType_; Type listModelType_;
QMap<QString, bool> sectionState_; QMap<QString, bool> sectionState_;
QMap<ConferenceableItem, ConferenceableValue> conferenceables_; QMap<ConferenceableItem, ConferenceableValue> conferenceables_;
}; ConversationModel::ConversationQueue conversations_;
};

View file

@ -616,7 +616,7 @@ Utils::isInteractionGenerated(const lrc::api::interaction::Type &type)
bool bool
Utils::isContactValid(const QString &contactUid, const lrc::api::ConversationModel &model) Utils::isContactValid(const QString &contactUid, const lrc::api::ConversationModel &model)
{ {
auto contact = model.owner.contactModel->getContact(contactUid); const auto contact = model.owner.contactModel->getContact(contactUid);
return (contact.profileInfo.type == lrc::api::profile::Type::PENDING return (contact.profileInfo.type == lrc::api::profile::Type::PENDING
|| contact.profileInfo.type == lrc::api::profile::Type::TEMPORARY || contact.profileInfo.type == lrc::api::profile::Type::TEMPORARY
|| contact.profileInfo.type == lrc::api::profile::Type::RING || contact.profileInfo.type == lrc::api::profile::Type::RING
@ -638,7 +638,8 @@ Utils::conversationPhoto(const QString &convUid,
const lrc::api::account::Info &accountInfo, const lrc::api::account::Info &accountInfo,
bool filtered) bool filtered)
{ {
auto convInfo = LRCInstance::getConversationFromConvUid(convUid, accountInfo.id, filtered); auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid);
if (!convInfo.uid.isEmpty()) { if (!convInfo.uid.isEmpty()) {
return GlobalInstances::pixmapManipulator() return GlobalInstances::pixmapManipulator()
.decorationRole(convInfo, accountInfo) .decorationRole(convInfo, accountInfo)
@ -934,17 +935,15 @@ Utils::humanFileSize(qint64 fileSize)
const QString const QString
UtilsAdapter::getBestName(const QString &accountId, const QString &uid) UtilsAdapter::getBestName(const QString &accountId, const QString &uid)
{ {
auto convModel = LRCInstance::getAccountInfo(accountId).conversationModel.get(); auto* convModel = LRCInstance::getAccountInfo(accountId).conversationModel.get();
return Utils::bestNameForConversation(LRCInstance::getConversationFromConvUid(uid, accountId), return Utils::bestNameForConversation(convModel->getConversationForUID(uid), *convModel);
*convModel);
} }
const QString const QString
UtilsAdapter::getBestId(const QString &accountId, const QString &uid) UtilsAdapter::getBestId(const QString &accountId, const QString &uid)
{ {
auto convModel = LRCInstance::getAccountInfo(accountId).conversationModel.get(); auto* convModel = LRCInstance::getAccountInfo(accountId).conversationModel.get();
return Utils::bestIdForConversation(LRCInstance::getConversationFromConvUid(uid, accountId), return Utils::bestIdForConversation(convModel->getConversationForUID(uid), *convModel);
*convModel);
} }
int int
@ -952,11 +951,11 @@ UtilsAdapter::getTotalUnreadMessages()
{ {
int totalUnreadMessages{0}; int totalUnreadMessages{0};
if (LRCInstance::getCurrentAccountInfo().profileInfo.type != lrc::api::profile::Type::SIP) { if (LRCInstance::getCurrentAccountInfo().profileInfo.type != lrc::api::profile::Type::SIP) {
auto convModel = LRCInstance::getCurrentConversationModel(); auto* convModel = LRCInstance::getCurrentConversationModel();
auto ringConversations = convModel->getFilteredConversations(lrc::api::profile::Type::RING); auto ringConversations = convModel->getFilteredConversations(lrc::api::profile::Type::RING);
std::for_each(ringConversations.begin(), std::for_each(ringConversations.begin(),
ringConversations.end(), ringConversations.end(),
[&totalUnreadMessages, convModel](const auto &conversation) { [&totalUnreadMessages](const auto &conversation) {
totalUnreadMessages += conversation.unreadMessages; totalUnreadMessages += conversation.unreadMessages;
}); });
} }
@ -1009,8 +1008,8 @@ UtilsAdapter::getAccountListSize()
void void
UtilsAdapter::setCurrentCall(const QString &accountId, const QString &convUid) UtilsAdapter::setCurrentCall(const QString &accountId, const QString &convUid)
{ {
auto convInfo = LRCInstance::getConversationFromConvUid(convUid, accountId);
auto &accInfo = LRCInstance::getAccountInfo(accountId); auto &accInfo = LRCInstance::getAccountInfo(accountId);
const auto convInfo = accInfo.conversationModel->getConversationForUID(convUid);
accInfo.callModel->setCurrentCall(convInfo.callId); accInfo.callModel->setCurrentCall(convInfo.callId);
} }
@ -1037,7 +1036,9 @@ UtilsAdapter::hasVideoCall()
const QString const QString
UtilsAdapter::getCallId(const QString &accountId, const QString &convUid) UtilsAdapter::getCallId(const QString &accountId, const QString &convUid)
{ {
auto convInfo = LRCInstance::getConversationFromConvUid(convUid, accountId); auto &accInfo = LRCInstance::getAccountInfo(accountId);
const auto convInfo = accInfo.conversationModel->getConversationForUID(convUid);
if (convInfo.uid.isEmpty()) { if (convInfo.uid.isEmpty()) {
return ""; return "";
} }