mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-20 21:28:07 +00:00
Fix call notification managment :
- Add a function to Call Model for ending process - Switch to the new chat room after creation - Missed Call notification is done by Chat Room Model from Call Model, and not by call lists model - Sort timelines by the max of update time and last call event - avoid to reset count if chat room is not selected while application go to foreground - On call, create a simple new chat room if not exist - On call, if outgoing, switch to the chat room Fix call event status Fix showing the main window instead of call window on some call initiation
This commit is contained in:
parent
ce9b2bf3b9
commit
280295e774
19 changed files with 421 additions and 287 deletions
|
|
@ -73,14 +73,8 @@ CallModel::CallModel (shared_ptr<linphone::Call> call){
|
|||
}
|
||||
|
||||
CoreHandlers *coreHandlers = coreManager->getHandlers().get();
|
||||
QObject::connect(
|
||||
coreHandlers, &CoreHandlers::callStateChanged,
|
||||
this, &CallModel::handleCallStateChanged
|
||||
);
|
||||
QObject::connect(
|
||||
coreHandlers, &CoreHandlers::callEncryptionChanged,
|
||||
this, &CallModel::handleCallEncryptionChanged
|
||||
);
|
||||
QObject::connect(coreHandlers, &CoreHandlers::callStateChanged, this, &CallModel::handleCallStateChanged );
|
||||
QObject::connect(coreHandlers, &CoreHandlers::callEncryptionChanged, this, &CallModel::handleCallEncryptionChanged );
|
||||
|
||||
// Update fields and make a search to know to who the call belong
|
||||
mMagicSearch = CoreManager::getInstance()->getCore()->createMagicSearch();
|
||||
|
|
@ -665,6 +659,25 @@ void CallModel::searchReceived(std::list<std::shared_ptr<linphone::SearchResult>
|
|||
}
|
||||
}
|
||||
|
||||
void CallModel::callEnded(){
|
||||
ChatRoomModel * model = getChatRoomModel();
|
||||
|
||||
if(model){
|
||||
model->callEnded(mCall);
|
||||
}else{// No chat rooms have been associated for this call. Search one in current chat room list
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
std::shared_ptr<linphone::ChatRoomParams> params = core->createDefaultChatRoomParams();
|
||||
std::list<std::shared_ptr<linphone::Address>> participants;
|
||||
|
||||
auto chatRoom = core->searchChatRoom(params, mCall->getCallLog()->getLocalAddress()
|
||||
, mCall->getRemoteAddress()
|
||||
, participants);
|
||||
std::shared_ptr<ChatRoomModel> chatRoomModel= CoreManager::getInstance()->getTimelineListModel()->getChatRoomModel(chatRoom, false);
|
||||
if(chatRoomModel)
|
||||
chatRoomModel->callEnded(mCall);
|
||||
}
|
||||
}
|
||||
|
||||
void CallModel::setRemoteDisplayName(const std::string& name){
|
||||
mRemoteAddress->setDisplayName(name);
|
||||
emit fullPeerAddressChanged();
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ public:
|
|||
public slots:
|
||||
// Set remote display name when a search has been done
|
||||
void searchReceived(std::list<std::shared_ptr<linphone::SearchResult>> results);
|
||||
void callEnded();
|
||||
|
||||
signals:
|
||||
void callErrorChanged (const QString &callError);
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ void CallsListModel::askForTransfer (CallModel *callModel) {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
void CallsListModel::launchAudioCall (const QString &sipAddress, const QHash<QString, QString> &headers) const {
|
||||
CoreManager::getInstance()->getTimelineListModel()->mAutoSelectAfterCreation = true;
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
|
||||
shared_ptr<linphone::Address> address = core->interpretUrl(Utils::appStringToCoreString(sipAddress));
|
||||
|
|
@ -138,6 +139,7 @@ void CallsListModel::launchAudioCall (const QString &sipAddress, const QHash<QSt
|
|||
}
|
||||
|
||||
void CallsListModel::launchSecureAudioCall (const QString &sipAddress, LinphoneEnums::MediaEncryption encryption, const QHash<QString, QString> &headers) const {
|
||||
CoreManager::getInstance()->getTimelineListModel()->mAutoSelectAfterCreation = true;
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
|
||||
shared_ptr<linphone::Address> address = core->interpretUrl(Utils::appStringToCoreString(sipAddress));
|
||||
|
|
@ -175,6 +177,7 @@ void CallsListModel::launchSecureAudioCall (const QString &sipAddress, LinphoneE
|
|||
}
|
||||
|
||||
void CallsListModel::launchVideoCall (const QString &sipAddress) const {
|
||||
CoreManager::getInstance()->getTimelineListModel()->mAutoSelectAfterCreation = true;
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
if (!core->videoSupported()) {
|
||||
qWarning() << QStringLiteral("Unable to launch video call. (Video not supported.) Launching audio call...");
|
||||
|
|
@ -194,6 +197,7 @@ void CallsListModel::launchVideoCall (const QString &sipAddress) const {
|
|||
}
|
||||
|
||||
ChatRoomModel* CallsListModel::launchSecureChat (const QString &sipAddress) const {
|
||||
CoreManager::getInstance()->getTimelineListModel()->mAutoSelectAfterCreation = true;
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
shared_ptr<linphone::Address> address = core->interpretUrl(Utils::appStringToCoreString(sipAddress));
|
||||
if (!address)
|
||||
|
|
@ -227,10 +231,11 @@ ChatRoomModel* CallsListModel::launchSecureChat (const QString &sipAddress) cons
|
|||
QVariantMap CallsListModel::launchChat(const QString &sipAddress, const int& securityLevel) const{
|
||||
QVariantList participants;
|
||||
participants << sipAddress;
|
||||
return createChatRoom("", securityLevel, participants);
|
||||
return createChatRoom("", securityLevel, participants, true);
|
||||
}
|
||||
|
||||
ChatRoomModel* CallsListModel::createChat (const QString &participantAddress) const{
|
||||
CoreManager::getInstance()->getTimelineListModel()->mAutoSelectAfterCreation = true;
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
shared_ptr<linphone::Address> address = core->interpretUrl(Utils::appStringToCoreString(participantAddress));
|
||||
if (!address)
|
||||
|
|
@ -262,6 +267,7 @@ ChatRoomModel* CallsListModel::createChat (const CallModel * model) const{
|
|||
}
|
||||
|
||||
bool CallsListModel::createSecureChat (const QString& subject, const QString &participantAddress) const{
|
||||
CoreManager::getInstance()->getTimelineListModel()->mAutoSelectAfterCreation = true;
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
shared_ptr<linphone::Address> address = core->interpretUrl(Utils::appStringToCoreString(participantAddress));
|
||||
if (!address)
|
||||
|
|
@ -283,11 +289,14 @@ bool CallsListModel::createSecureChat (const QString& subject, const QString &pa
|
|||
return chatRoom != nullptr;
|
||||
}
|
||||
// Created, timeline that can be used
|
||||
QVariantMap CallsListModel::createChatRoom(const QString& subject, const int& securityLevel, const QVariantList& participants) const{
|
||||
QVariantMap CallsListModel::createChatRoom(const QString& subject, const int& securityLevel, const QVariantList& participants, const bool& selectAfterCreation) const{
|
||||
CoreManager::getInstance()->getTimelineListModel()->mAutoSelectAfterCreation = selectAfterCreation;
|
||||
QVariantMap result;
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
std::shared_ptr<linphone::ChatRoom> chatRoom;
|
||||
QList< std::shared_ptr<linphone::Address>> admins;
|
||||
std::shared_ptr<TimelineModel> timeline;
|
||||
auto timelineList = CoreManager::getInstance()->getTimelineListModel();
|
||||
qWarning() << "ChatRoom creation of " << subject << " at " << securityLevel << " security and with " << participants;
|
||||
|
||||
std::shared_ptr<linphone::ChatRoomParams> params = core->createDefaultChatRoomParams();
|
||||
|
|
@ -335,16 +344,21 @@ QVariantMap CallsListModel::createChatRoom(const QString& subject, const int& se
|
|||
chatRoom = core->createChatRoom(params, localAddress, chatRoomParticipants);
|
||||
if(chatRoom != nullptr && admins.size() > 0)
|
||||
ChatRoomInitializer::setAdminsAsync(params->getSubject(), params->getBackend(), params->groupEnabled(), admins );
|
||||
timeline = timelineList->getTimeline(chatRoom, false);
|
||||
}else{
|
||||
if(admins.size() > 0){
|
||||
ChatRoomInitializer::setAdminsSync(chatRoom, admins);
|
||||
}
|
||||
auto timelineList = CoreManager::getInstance()->getTimelineListModel();
|
||||
auto timeline = timelineList->getTimeline(chatRoom, true);
|
||||
QTimer::singleShot(200, [timeline](){// Delay process in order to let GUI time for Timeline building/linking before doing actions
|
||||
timeline->setSelected(true);
|
||||
});
|
||||
timeline = timelineList->getTimeline(chatRoom, true);
|
||||
}
|
||||
if(timeline){
|
||||
CoreManager::getInstance()->getTimelineListModel()->mAutoSelectAfterCreation = false;
|
||||
result["chatRoomModel"] = QVariant::fromValue(timeline->getChatRoomModel());
|
||||
if(selectAfterCreation) {// The timeline here will not receive the first creation event. Set Selected if needed
|
||||
QTimer::singleShot(200, [timeline](){// Delay process in order to let GUI time for Timeline building/linking before doing actions
|
||||
timeline->setSelected(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
result["created"] = (chatRoom != nullptr);
|
||||
|
|
@ -420,12 +434,11 @@ void CallsListModel::handleCallStateChanged (const shared_ptr<linphone::Call> &c
|
|||
break;
|
||||
|
||||
case linphone::Call::State::End:
|
||||
case linphone::Call::State::Error:
|
||||
if (call->getCallLog()->getStatus() == linphone::Call::Status::Missed)
|
||||
emit callMissed(&call->getData<CallModel>("call-model"));
|
||||
case linphone::Call::State::Error:{
|
||||
CallModel * model = &call->getData<CallModel>("call-model");
|
||||
model->callEnded();
|
||||
removeCall(call);
|
||||
break;
|
||||
|
||||
} break;
|
||||
case linphone::Call::State::StreamsRunning: {
|
||||
int index = findCallIndex(mList, call);
|
||||
emit callRunning(index, &call->getData<CallModel>("call-model"));
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public:
|
|||
Q_INVOKABLE ChatRoomModel* createChat (const CallModel * ) const;
|
||||
Q_INVOKABLE bool createSecureChat (const QString& subject, const QString &participantAddress) const;
|
||||
|
||||
Q_INVOKABLE QVariantMap createChatRoom(const QString& subject, const int& securityLevel, const QVariantList& participants) const;
|
||||
Q_INVOKABLE QVariantMap createChatRoom(const QString& subject, const int& securityLevel, const QVariantList& participants, const bool& selectAfterCreation) const;
|
||||
|
||||
Q_INVOKABLE int getRunningCallsNumber () const;
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@
|
|||
#include "components/presence/Presence.hpp"
|
||||
#include "components/timeline/TimelineModel.hpp"
|
||||
#include "components/timeline/TimelineListModel.hpp"
|
||||
#include "components/core/event-count-notifier/AbstractEventCountNotifier.hpp"
|
||||
#include "utils/QExifImageHeader.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
#include "utils/LinphoneEnums.hpp"
|
||||
|
|
@ -199,8 +200,19 @@ ChatRoomModel::ChatRoomModel (std::shared_ptr<linphone::ChatRoom> chatRoom, QObj
|
|||
mChatRoom = chatRoom;
|
||||
mChatRoomModelListener = std::make_shared<ChatRoomModelListener>(this, parent);
|
||||
mChatRoom->addListener(mChatRoomModelListener);
|
||||
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(mChatRoom->getLastUpdateTime()));
|
||||
|
||||
// Get Max updatetime from chat room and last call event
|
||||
|
||||
auto callHistory = CoreManager::getInstance()->getCore()->getCallHistory(mChatRoom->getPeerAddress(), mChatRoom->getLocalAddress());
|
||||
if(callHistory.size() > 0){
|
||||
auto callDate = callHistory.front()->getStartDate();
|
||||
if( callHistory.front()->getStatus() == linphone::Call::Status::Success )
|
||||
callDate += callHistory.front()->getDuration();
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(max(mChatRoom->getLastUpdateTime(), callDate )*1000));
|
||||
}else
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(mChatRoom->getLastUpdateTime()*1000));
|
||||
|
||||
|
||||
setUnreadMessagesCount(mChatRoom->getUnreadMessagesCount());
|
||||
setMissedCallsCount(0);
|
||||
|
||||
|
|
@ -518,6 +530,16 @@ void ChatRoomModel::setLastUpdateTime(const QDateTime& lastUpdateDate) {
|
|||
}
|
||||
}
|
||||
|
||||
void ChatRoomModel::updateLastUpdateTime(){
|
||||
QDateTime lastDateTime = QDateTime::fromMSecsSinceEpoch(mChatRoom->getLastUpdateTime()*1000);
|
||||
QDateTime lastCallTime = lastDateTime;
|
||||
for(auto e : mEntries){
|
||||
if(e->mType == CallEntry && e->mTimestamp > lastCallTime)
|
||||
lastCallTime = e->mTimestamp;
|
||||
}
|
||||
setLastUpdateTime(lastCallTime);
|
||||
}
|
||||
|
||||
void ChatRoomModel::setUnreadMessagesCount(const int& count){
|
||||
if(count != mUnreadMessagesCount){
|
||||
mUnreadMessagesCount = count;
|
||||
|
|
@ -532,6 +554,15 @@ void ChatRoomModel::setMissedCallsCount(const int& count){
|
|||
}
|
||||
}
|
||||
|
||||
void ChatRoomModel::addMissedCallsCount(std::shared_ptr<linphone::Call> call){
|
||||
insertCall(call->getCallLog());
|
||||
auto timeline = CoreManager::getInstance()->getTimelineListModel()->getTimeline(mChatRoom, false);
|
||||
if(!timeline || !timeline->mSelected){
|
||||
setMissedCallsCount(mMissedCallsCount+1);
|
||||
CoreManager::getInstance()->getEventCountNotifier()->handleCallMissed(&call->getData<CallModel>("call-model"));
|
||||
}
|
||||
}
|
||||
|
||||
void ChatRoomModel::setEphemeralEnabled(bool enabled){
|
||||
if(isEphemeralEnabled() != enabled){
|
||||
mChatRoom->enableEphemeral(enabled);
|
||||
|
|
@ -811,12 +842,21 @@ void ChatRoomModel::loadMoreEntries(){
|
|||
for(auto entry : entries)
|
||||
mEntries.prepend(entry);
|
||||
endInsertRows();
|
||||
updateLastUpdateTime();
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
//-------------------------------------------------
|
||||
|
||||
void ChatRoomModel::callEnded(std::shared_ptr<linphone::Call> call){
|
||||
if( call->getCallLog()->getStatus() == linphone::Call::Status::Missed)
|
||||
addMissedCallsCount(call);
|
||||
else{
|
||||
insertCall(call->getCallLog());
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void ChatRoomModel::insertCall (const std::shared_ptr<linphone::CallLog> &callLog) {
|
||||
|
|
@ -836,6 +876,7 @@ void ChatRoomModel::insertCall (const std::shared_ptr<linphone::CallLog> &callLo
|
|||
endInsertRows();
|
||||
}
|
||||
}
|
||||
updateLastUpdateTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -928,6 +969,8 @@ void ChatRoomModel::insertNotices (const QList<std::shared_ptr<linphone::EventLo
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
void ChatRoomModel::handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::Call::State state) {
|
||||
|
||||
/*
|
||||
if (state == linphone::Call::State::End || state == linphone::Call::State::Error){
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
std::shared_ptr<linphone::ChatRoomParams> params = core->createDefaultChatRoomParams();
|
||||
|
|
@ -941,9 +984,11 @@ void ChatRoomModel::handleCallStateChanged (const std::shared_ptr<linphone::Call
|
|||
setMissedCallsCount(mMissedCallsCount+1);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void ChatRoomModel::handleCallCreated(const shared_ptr<linphone::Call> &call){
|
||||
|
||||
}
|
||||
|
||||
void ChatRoomModel::handlePresenceStatusReceived(std::shared_ptr<linphone::Friend> contact){
|
||||
|
|
@ -988,12 +1033,12 @@ void ChatRoomModel::onIsComposingReceived(const std::shared_ptr<linphone::ChatRo
|
|||
if(isComposing)
|
||||
mComposers[remoteAddress] = Utils::getDisplayName(remoteAddress);
|
||||
emit isRemoteComposingChanged();
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
}
|
||||
|
||||
void ChatRoomModel::onMessageReceived(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<linphone::ChatMessage> & message){
|
||||
setUnreadMessagesCount(chatRoom->getUnreadMessagesCount());
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
}
|
||||
|
||||
void ChatRoomModel::onNewEvent(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::EventLog> & eventLog){
|
||||
|
|
@ -1002,14 +1047,14 @@ void ChatRoomModel::onNewEvent(const std::shared_ptr<linphone::ChatRoom> & chatR
|
|||
}else if( eventLog->getType() == linphone::EventLog::Type::ConferenceCreated ){
|
||||
emit fullPeerAddressChanged();
|
||||
}
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
}
|
||||
|
||||
void ChatRoomModel::onChatMessageReceived(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::EventLog> & eventLog) {
|
||||
auto message = eventLog->getChatMessage();
|
||||
if(message){
|
||||
insertMessageAtEnd(message);
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
emit messageReceived(message);
|
||||
}
|
||||
}
|
||||
|
|
@ -1018,13 +1063,13 @@ void ChatRoomModel::onChatMessageSending(const std::shared_ptr<linphone::ChatRoo
|
|||
auto message = eventLog->getChatMessage();
|
||||
if(message){
|
||||
insertMessageAtEnd(message);
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
emit messageReceived(message);
|
||||
}
|
||||
}
|
||||
|
||||
void ChatRoomModel::onChatMessageSent(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::EventLog> & eventLog){
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
}
|
||||
|
||||
void ChatRoomModel::onParticipantAdded(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::EventLog> & eventLog){
|
||||
|
|
@ -1032,7 +1077,7 @@ void ChatRoomModel::onParticipantAdded(const std::shared_ptr<linphone::ChatRoom>
|
|||
auto e = std::find(events.begin(), events.end(), eventLog);
|
||||
if( e != events.end() )
|
||||
insertNotice(*e);
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
emit participantAdded(chatRoom, eventLog);
|
||||
emit fullPeerAddressChanged();
|
||||
}
|
||||
|
|
@ -1042,7 +1087,7 @@ void ChatRoomModel::onParticipantRemoved(const std::shared_ptr<linphone::ChatRoo
|
|||
auto e = std::find(events.begin(), events.end(), eventLog);
|
||||
if( e != events.end() )
|
||||
insertNotice(*e);
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
emit participantRemoved(chatRoom, eventLog);
|
||||
emit fullPeerAddressChanged();
|
||||
}
|
||||
|
|
@ -1052,13 +1097,13 @@ void ChatRoomModel::onParticipantAdminStatusChanged(const std::shared_ptr<linpho
|
|||
auto e = std::find(events.begin(), events.end(), eventLog);
|
||||
if( e != events.end() )
|
||||
insertNotice(*e);
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
emit participantAdminStatusChanged(chatRoom, eventLog);
|
||||
emit isMeAdminChanged(); // It is not the case all the time but calling getters is not a heavy request
|
||||
}
|
||||
|
||||
void ChatRoomModel::onStateChanged(const std::shared_ptr<linphone::ChatRoom> & chatRoom, linphone::ChatRoom::State newState){
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
emit stateChanged(getState());
|
||||
}
|
||||
|
||||
|
|
@ -1067,7 +1112,7 @@ void ChatRoomModel::onSecurityEvent(const std::shared_ptr<linphone::ChatRoom> &
|
|||
auto e = std::find(events.begin(), events.end(), eventLog);
|
||||
if( e != events.end() )
|
||||
insertNotice(*e);
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
emit securityLevelChanged((int)chatRoom->getSecurityLevel());
|
||||
}
|
||||
void ChatRoomModel::onSubjectChanged(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::EventLog> & eventLog) {
|
||||
|
|
@ -1075,22 +1120,22 @@ void ChatRoomModel::onSubjectChanged(const std::shared_ptr<linphone::ChatRoom> &
|
|||
auto e = std::find(events.begin(), events.end(), eventLog);
|
||||
if( e != events.end() )
|
||||
insertNotice(*e);
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
emit subjectChanged(getSubject());
|
||||
emit usernameChanged();
|
||||
}
|
||||
|
||||
void ChatRoomModel::onUndecryptableMessageReceived(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<linphone::ChatMessage> & message){
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
}
|
||||
|
||||
void ChatRoomModel::onParticipantDeviceAdded(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::EventLog> & eventLog){
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
emit participantDeviceAdded(chatRoom, eventLog);
|
||||
}
|
||||
|
||||
void ChatRoomModel::onParticipantDeviceRemoved(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::EventLog> & eventLog){
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
emit participantDeviceRemoved(chatRoom, eventLog);
|
||||
}
|
||||
|
||||
|
|
@ -1106,7 +1151,7 @@ void ChatRoomModel::onConferenceJoined(const std::shared_ptr<linphone::ChatRoom>
|
|||
insertNotice(*e);
|
||||
}
|
||||
setUnreadMessagesCount(mChatRoom->getUnreadMessagesCount()); // Update message count. In the case of joining conference, the conference id was not valid thus, the missing count was not about the chat room but a global one.
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
emit usernameChanged();
|
||||
emit conferenceJoined(chatRoom, eventLog);
|
||||
emit hasBeenLeftChanged();
|
||||
|
|
@ -1124,7 +1169,7 @@ void ChatRoomModel::onConferenceLeft(const std::shared_ptr<linphone::ChatRoom> &
|
|||
if(e != events.end() )
|
||||
insertNotice(*e);
|
||||
}
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
emit conferenceLeft(chatRoom, eventLog);
|
||||
emit hasBeenLeftChanged();
|
||||
}
|
||||
|
|
@ -1135,23 +1180,23 @@ void ChatRoomModel::onEphemeralEvent(const std::shared_ptr<linphone::ChatRoom> &
|
|||
auto e = std::find(events.begin(), events.end(), eventLog);
|
||||
if(e != events.end() )
|
||||
insertNotice(*e);
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
}
|
||||
|
||||
void ChatRoomModel::onEphemeralMessageTimerStarted(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::EventLog> & eventLog){
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
}
|
||||
|
||||
void ChatRoomModel::onEphemeralMessageDeleted(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::EventLog> & eventLog){
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
}
|
||||
|
||||
void ChatRoomModel::onConferenceAddressGeneration(const std::shared_ptr<linphone::ChatRoom> & chatRoom){
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
}
|
||||
|
||||
void ChatRoomModel::onParticipantRegistrationSubscriptionRequested(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::Address> & participantAddress){
|
||||
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(chatRoom->getLastUpdateTime()));
|
||||
updateLastUpdateTime();
|
||||
emit participantRegistrationSubscriptionRequested(chatRoom, participantAddress);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -200,9 +200,11 @@ public:
|
|||
//---- Setters
|
||||
void setSubject(QString& subject);
|
||||
void setLastUpdateTime(const QDateTime& lastUpdateDate);
|
||||
void updateLastUpdateTime();
|
||||
|
||||
void setUnreadMessagesCount(const int& count);
|
||||
void setUnreadMessagesCount(const int& count);
|
||||
void setMissedCallsCount(const int& count);
|
||||
void addMissedCallsCount(std::shared_ptr<linphone::Call> call);
|
||||
void setEphemeralEnabled(bool enabled);
|
||||
void setEphemeralLifetime(long lifetime);
|
||||
|
||||
|
|
@ -217,6 +219,7 @@ public:
|
|||
void resetMessageCount ();
|
||||
Q_INVOKABLE void initEntries();
|
||||
Q_INVOKABLE void loadMoreEntries();
|
||||
void callEnded(std::shared_ptr<linphone::Call> call);
|
||||
|
||||
QDateTime mLastUpdateTime;
|
||||
int mUnreadMessagesCount = 0;
|
||||
|
|
@ -227,6 +230,14 @@ public:
|
|||
int mLastEntriesStep = 50; // Retrieve a part of the history to avoid too much processing
|
||||
|
||||
|
||||
void insertCall (const std::shared_ptr<linphone::CallLog> &callLog);
|
||||
void insertCalls (const QList<std::shared_ptr<linphone::CallLog> > &calls);
|
||||
void insertMessageAtEnd (const std::shared_ptr<linphone::ChatMessage> &message);
|
||||
void insertMessages (const QList<std::shared_ptr<linphone::ChatMessage> > &messages);
|
||||
void insertNotice (const std::shared_ptr<linphone::EventLog> &enventLog);
|
||||
void insertNotices (const QList<std::shared_ptr<linphone::EventLog>> &eventLogs);
|
||||
|
||||
|
||||
//-------------------- CHAT ROOM HANDLER
|
||||
|
||||
public slots:
|
||||
|
|
@ -306,12 +317,6 @@ signals:
|
|||
void conferenceLeft(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::EventLog> & eventLog);
|
||||
|
||||
private:
|
||||
void insertCall (const std::shared_ptr<linphone::CallLog> &callLog);
|
||||
void insertCalls (const QList<std::shared_ptr<linphone::CallLog> > &calls);
|
||||
void insertMessageAtEnd (const std::shared_ptr<linphone::ChatMessage> &message);
|
||||
void insertMessages (const QList<std::shared_ptr<linphone::ChatMessage> > &messages);
|
||||
void insertNotice (const std::shared_ptr<linphone::EventLog> &enventLog);
|
||||
void insertNotices (const QList<std::shared_ptr<linphone::EventLog>> &eventLogs);
|
||||
|
||||
void handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::Call::State state);
|
||||
void handleCallCreated(const std::shared_ptr<linphone::Call> &call);// Count an event call
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include "components/chat-events/ChatNoticeModel.hpp"
|
||||
#include "components/chat-events/ChatCallModel.hpp"
|
||||
#include "components/timeline/TimelineListModel.hpp"
|
||||
#include "components/timeline/TimelineModel.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
|
|
@ -301,8 +302,11 @@ static inline QWindow *getParentWindow (QObject *object) {
|
|||
|
||||
void ChatRoomProxyModel::handleIsActiveChanged (QWindow *window) {
|
||||
if (mChatRoomModel && window->isActive() && getParentWindow(this) == window) {
|
||||
mChatRoomModel->resetMessageCount();
|
||||
mChatRoomModel->focused();
|
||||
auto timeline = CoreManager::getInstance()->getTimelineListModel()->getTimeline(mChatRoomModel->getChatRoom(), false);
|
||||
if(timeline && timeline->mSelected){
|
||||
mChatRoomModel->resetMessageCount();
|
||||
mChatRoomModel->focused();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,6 +118,11 @@ void CoreManager::initCoreManager(){
|
|||
qInfo() << QStringLiteral("CoreManager initialized");
|
||||
emit coreManagerInitialized();
|
||||
}
|
||||
|
||||
AbstractEventCountNotifier * CoreManager::getEventCountNotifier(){
|
||||
return mEventCountNotifier;
|
||||
}
|
||||
|
||||
CoreManager *CoreManager::getInstance (){
|
||||
return mInstance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
class QTimer;
|
||||
|
||||
class AbstractEventCountNotifier;
|
||||
class AccountSettingsModel;
|
||||
class CallsListModel;
|
||||
class ChatRoomModel;
|
||||
|
|
@ -48,187 +49,190 @@ class TimelineListModel;
|
|||
|
||||
|
||||
class CoreManager : public QObject {
|
||||
Q_OBJECT;
|
||||
|
||||
Q_PROPERTY(QString version READ getVersion CONSTANT)
|
||||
Q_PROPERTY(QString downloadUrl READ getDownloadUrl CONSTANT)
|
||||
Q_PROPERTY(int eventCount READ getEventCount NOTIFY eventCountChanged)
|
||||
|
||||
Q_OBJECT;
|
||||
|
||||
Q_PROPERTY(QString version READ getVersion CONSTANT)
|
||||
Q_PROPERTY(QString downloadUrl READ getDownloadUrl CONSTANT)
|
||||
Q_PROPERTY(int eventCount READ getEventCount NOTIFY eventCountChanged)
|
||||
|
||||
public:
|
||||
bool started () const {
|
||||
return mStarted;
|
||||
}
|
||||
|
||||
std::shared_ptr<linphone::Core> getCore () {
|
||||
return mCore;
|
||||
}
|
||||
|
||||
std::shared_ptr<CoreHandlers> getHandlers () {
|
||||
Q_CHECK_PTR(mHandlers);
|
||||
return mHandlers;
|
||||
}
|
||||
|
||||
//std::shared_ptr<ChatRoomModel> getChatRoomModel (const QString &peerAddress, const QString &localAddress, const bool &isSecure);
|
||||
//std::shared_ptr<ChatRoomModel> getChatRoomModel (ChatRoomModel * data);// Get the shared pointer. This can be done becuase of unicity of ChatRoomModel
|
||||
//std::shared_ptr<ChatRoomModel> getChatRoomModel (std::shared_ptr<linphone::ChatRoom> chatRoom, const bool& create = true);
|
||||
//bool chatRoomModelExists (const QString &sipAddress, const QString &localAddress, const bool &isSecure);
|
||||
//bool chatRoomModelExists (std::shared_ptr<linphone::ChatRoom> chatRoom);
|
||||
|
||||
HistoryModel* getHistoryModel();
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Video render lock.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void lockVideoRender () {
|
||||
mMutexVideoRender.lock();
|
||||
}
|
||||
|
||||
void unlockVideoRender () {
|
||||
mMutexVideoRender.unlock();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Singleton models.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
CallsListModel *getCallsListModel () const {
|
||||
Q_CHECK_PTR(mCallsListModel);
|
||||
return mCallsListModel;
|
||||
}
|
||||
/* Timelines
|
||||
bool started () const {
|
||||
return mStarted;
|
||||
}
|
||||
|
||||
std::shared_ptr<linphone::Core> getCore () {
|
||||
return mCore;
|
||||
}
|
||||
|
||||
std::shared_ptr<CoreHandlers> getHandlers () {
|
||||
Q_CHECK_PTR(mHandlers);
|
||||
return mHandlers;
|
||||
}
|
||||
|
||||
//std::shared_ptr<ChatRoomModel> getChatRoomModel (const QString &peerAddress, const QString &localAddress, const bool &isSecure);
|
||||
//std::shared_ptr<ChatRoomModel> getChatRoomModel (ChatRoomModel * data);// Get the shared pointer. This can be done becuase of unicity of ChatRoomModel
|
||||
//std::shared_ptr<ChatRoomModel> getChatRoomModel (std::shared_ptr<linphone::ChatRoom> chatRoom, const bool& create = true);
|
||||
//bool chatRoomModelExists (const QString &sipAddress, const QString &localAddress, const bool &isSecure);
|
||||
//bool chatRoomModelExists (std::shared_ptr<linphone::ChatRoom> chatRoom);
|
||||
|
||||
HistoryModel* getHistoryModel();
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Video render lock.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void lockVideoRender () {
|
||||
mMutexVideoRender.lock();
|
||||
}
|
||||
|
||||
void unlockVideoRender () {
|
||||
mMutexVideoRender.unlock();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Singleton models.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
CallsListModel *getCallsListModel () const {
|
||||
Q_CHECK_PTR(mCallsListModel);
|
||||
return mCallsListModel;
|
||||
}
|
||||
/* Timelines
|
||||
ChatRoomListModel *getChatRoomListModel () const {
|
||||
Q_CHECK_PTR(mChatRoomListModel);
|
||||
return mChatRoomListModel;
|
||||
Q_CHECK_PTR(mChatRoomListModel);
|
||||
return mChatRoomListModel;
|
||||
}*/
|
||||
|
||||
|
||||
ContactsListModel *getContactsListModel () const {
|
||||
Q_CHECK_PTR(mContactsListModel);
|
||||
return mContactsListModel;
|
||||
}
|
||||
|
||||
ContactsImporterListModel *getContactsImporterListModel () const {
|
||||
Q_CHECK_PTR(mContactsImporterListModel);
|
||||
return mContactsImporterListModel;
|
||||
}
|
||||
|
||||
TimelineListModel *getTimelineListModel () const {
|
||||
return mTimelineListModel;
|
||||
}
|
||||
|
||||
SipAddressesModel *getSipAddressesModel () const {
|
||||
Q_CHECK_PTR(mSipAddressesModel);
|
||||
return mSipAddressesModel;
|
||||
}
|
||||
|
||||
SettingsModel *getSettingsModel () const {
|
||||
Q_CHECK_PTR(mSettingsModel);
|
||||
return mSettingsModel;
|
||||
}
|
||||
|
||||
AccountSettingsModel *getAccountSettingsModel () const {
|
||||
Q_CHECK_PTR(mAccountSettingsModel);
|
||||
return mAccountSettingsModel;
|
||||
}
|
||||
|
||||
|
||||
ContactsListModel *getContactsListModel () const {
|
||||
Q_CHECK_PTR(mContactsListModel);
|
||||
return mContactsListModel;
|
||||
}
|
||||
|
||||
ContactsImporterListModel *getContactsImporterListModel () const {
|
||||
Q_CHECK_PTR(mContactsImporterListModel);
|
||||
return mContactsImporterListModel;
|
||||
}
|
||||
|
||||
TimelineListModel *getTimelineListModel () const {
|
||||
return mTimelineListModel;
|
||||
}
|
||||
|
||||
SipAddressesModel *getSipAddressesModel () const {
|
||||
Q_CHECK_PTR(mSipAddressesModel);
|
||||
return mSipAddressesModel;
|
||||
}
|
||||
|
||||
SettingsModel *getSettingsModel () const {
|
||||
Q_CHECK_PTR(mSettingsModel);
|
||||
return mSettingsModel;
|
||||
}
|
||||
|
||||
AccountSettingsModel *getAccountSettingsModel () const {
|
||||
Q_CHECK_PTR(mAccountSettingsModel);
|
||||
return mAccountSettingsModel;
|
||||
}
|
||||
LdapListModel *getLdapListModel() const{
|
||||
return mLdapListModel;
|
||||
}
|
||||
static CoreManager *getInstance ();
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Initialization.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static void init (QObject *parent, const QString &configPath);
|
||||
static void uninit ();
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Must be used in a qml scene.
|
||||
// Warning: The ownership of `VcardModel` is `QQmlEngine::JavaScriptOwnership` by default.
|
||||
Q_INVOKABLE VcardModel *createDetachedVcardModel () const;
|
||||
|
||||
Q_INVOKABLE void forceRefreshRegisters ();
|
||||
void updateUnreadMessageCount();
|
||||
|
||||
Q_INVOKABLE void sendLogs () const;
|
||||
Q_INVOKABLE void cleanLogs () const;
|
||||
|
||||
int getMissedCallCount(const QString &peerAddress, const QString &localAddress) const;// Get missed call count from a chat (useful for showing bubbles on Timelines)
|
||||
int getMissedCallCountFromLocal(const QString &localAddress) const;// Get missed call count from a chat (useful for showing bubbles on Timelines)
|
||||
|
||||
static bool isInstanciated(){return mInstance!=nullptr;}
|
||||
|
||||
bool isLastRemoteProvisioningGood();
|
||||
|
||||
|
||||
AbstractEventCountNotifier * getEventCountNotifier();
|
||||
|
||||
static CoreManager *getInstance ();
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Initialization.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static void init (QObject *parent, const QString &configPath);
|
||||
static void uninit ();
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Must be used in a qml scene.
|
||||
// Warning: The ownership of `VcardModel` is `QQmlEngine::JavaScriptOwnership` by default.
|
||||
Q_INVOKABLE VcardModel *createDetachedVcardModel () const;
|
||||
|
||||
Q_INVOKABLE void forceRefreshRegisters ();
|
||||
void updateUnreadMessageCount();
|
||||
|
||||
Q_INVOKABLE void sendLogs () const;
|
||||
Q_INVOKABLE void cleanLogs () const;
|
||||
|
||||
int getMissedCallCount(const QString &peerAddress, const QString &localAddress) const;// Get missed call count from a chat (useful for showing bubbles on Timelines)
|
||||
int getMissedCallCountFromLocal(const QString &localAddress) const;// Get missed call count from a chat (useful for showing bubbles on Timelines)
|
||||
|
||||
static bool isInstanciated(){return mInstance!=nullptr;}
|
||||
|
||||
bool isLastRemoteProvisioningGood();
|
||||
|
||||
public slots:
|
||||
void initCoreManager();
|
||||
void startIterate();
|
||||
void stopIterate();
|
||||
void setLastRemoteProvisioningState(const linphone::ConfiguringState& state);
|
||||
void createLinphoneCore (const QString &configPath);// In order to delay creation
|
||||
void handleChatRoomCreated(const std::shared_ptr<ChatRoomModel> &chatRoomModel);
|
||||
|
||||
void initCoreManager();
|
||||
void startIterate();
|
||||
void stopIterate();
|
||||
void setLastRemoteProvisioningState(const linphone::ConfiguringState& state);
|
||||
void createLinphoneCore (const QString &configPath);// In order to delay creation
|
||||
void handleChatRoomCreated(const std::shared_ptr<ChatRoomModel> &chatRoomModel);
|
||||
|
||||
signals:
|
||||
void coreManagerInitialized ();
|
||||
|
||||
void chatRoomModelCreated (const std::shared_ptr<ChatRoomModel> &chatRoomModel);
|
||||
void historyModelCreated (HistoryModel *historyModel);
|
||||
|
||||
void logsUploaded (const QString &url);
|
||||
|
||||
void eventCountChanged ();
|
||||
|
||||
void coreManagerInitialized ();
|
||||
|
||||
void chatRoomModelCreated (const std::shared_ptr<ChatRoomModel> &chatRoomModel);
|
||||
void historyModelCreated (HistoryModel *historyModel);
|
||||
|
||||
void logsUploaded (const QString &url);
|
||||
|
||||
void eventCountChanged ();
|
||||
|
||||
private:
|
||||
CoreManager (QObject *parent, const QString &configPath);
|
||||
~CoreManager ();
|
||||
|
||||
void setDatabasesPaths ();
|
||||
void setOtherPaths ();
|
||||
void setResourcesPaths ();
|
||||
|
||||
void migrate ();
|
||||
|
||||
QString getVersion () const;
|
||||
|
||||
int getEventCount () const;
|
||||
|
||||
void iterate ();
|
||||
|
||||
void handleLogsUploadStateChanged (linphone::Core::LogCollectionUploadState state, const std::string &info);
|
||||
|
||||
static QString getDownloadUrl ();
|
||||
|
||||
std::shared_ptr<linphone::Core> mCore;
|
||||
std::shared_ptr<CoreHandlers> mHandlers;
|
||||
|
||||
bool mStarted = false;
|
||||
linphone::ConfiguringState mLastRemoteProvisioningState;
|
||||
|
||||
CallsListModel *mCallsListModel = nullptr;
|
||||
ContactsListModel *mContactsListModel = nullptr;
|
||||
ContactsImporterListModel *mContactsImporterListModel = nullptr;
|
||||
TimelineListModel *mTimelineListModel = nullptr;
|
||||
ChatRoomListModel *mChatRoomListModel = nullptr;
|
||||
|
||||
SipAddressesModel *mSipAddressesModel = nullptr;
|
||||
SettingsModel *mSettingsModel = nullptr;
|
||||
AccountSettingsModel *mAccountSettingsModel = nullptr;
|
||||
|
||||
EventCountNotifier *mEventCountNotifier = nullptr;
|
||||
|
||||
//QHash<QPair<bool, QPair<QString, QString> >, std::weak_ptr<ChatRoomModel>> mChatRoomModels;
|
||||
//QHash<std::shared_ptr<linphone::ChatRoom>, std::weak_ptr<ChatRoomModel>> mChatRoomModels;
|
||||
//QList<QPair<std::shared_ptr<linphone::ChatRoom>, std::weak_ptr<ChatRoomModel>>> mChatRoomModels;
|
||||
HistoryModel * mHistoryModel = nullptr;
|
||||
LdapListModel *mLdapListModel = nullptr;
|
||||
|
||||
QTimer *mCbsTimer = nullptr;
|
||||
|
||||
QMutex mMutexVideoRender;
|
||||
|
||||
static CoreManager *mInstance;
|
||||
CoreManager (QObject *parent, const QString &configPath);
|
||||
~CoreManager ();
|
||||
|
||||
void setDatabasesPaths ();
|
||||
void setOtherPaths ();
|
||||
void setResourcesPaths ();
|
||||
|
||||
void migrate ();
|
||||
|
||||
QString getVersion () const;
|
||||
|
||||
int getEventCount () const;
|
||||
|
||||
void iterate ();
|
||||
|
||||
void handleLogsUploadStateChanged (linphone::Core::LogCollectionUploadState state, const std::string &info);
|
||||
|
||||
static QString getDownloadUrl ();
|
||||
|
||||
std::shared_ptr<linphone::Core> mCore;
|
||||
std::shared_ptr<CoreHandlers> mHandlers;
|
||||
|
||||
bool mStarted = false;
|
||||
linphone::ConfiguringState mLastRemoteProvisioningState;
|
||||
|
||||
CallsListModel *mCallsListModel = nullptr;
|
||||
ContactsListModel *mContactsListModel = nullptr;
|
||||
ContactsImporterListModel *mContactsImporterListModel = nullptr;
|
||||
TimelineListModel *mTimelineListModel = nullptr;
|
||||
ChatRoomListModel *mChatRoomListModel = nullptr;
|
||||
|
||||
SipAddressesModel *mSipAddressesModel = nullptr;
|
||||
SettingsModel *mSettingsModel = nullptr;
|
||||
AccountSettingsModel *mAccountSettingsModel = nullptr;
|
||||
|
||||
EventCountNotifier *mEventCountNotifier = nullptr;
|
||||
|
||||
//QHash<QPair<bool, QPair<QString, QString> >, std::weak_ptr<ChatRoomModel>> mChatRoomModels;
|
||||
//QHash<std::shared_ptr<linphone::ChatRoom>, std::weak_ptr<ChatRoomModel>> mChatRoomModels;
|
||||
//QList<QPair<std::shared_ptr<linphone::ChatRoom>, std::weak_ptr<ChatRoomModel>>> mChatRoomModels;
|
||||
HistoryModel * mHistoryModel = nullptr;
|
||||
LdapListModel *mLdapListModel = nullptr;
|
||||
|
||||
QTimer *mCbsTimer = nullptr;
|
||||
|
||||
QMutex mMutexVideoRender;
|
||||
|
||||
static CoreManager *mInstance;
|
||||
};
|
||||
|
||||
#endif // CORE_MANAGER_H_
|
||||
|
|
|
|||
|
|
@ -53,10 +53,11 @@ AbstractEventCountNotifier::AbstractEventCountNotifier (QObject *parent) : QObje
|
|||
coreManager->getSettingsModel(), &SettingsModel::chatEnabledChanged,
|
||||
this, &AbstractEventCountNotifier::internalnotifyEventCount
|
||||
);
|
||||
/*
|
||||
QObject::connect(
|
||||
coreManager->getCallsListModel(), &CallsListModel::callMissed,
|
||||
this, &AbstractEventCountNotifier::handleCallMissed
|
||||
);
|
||||
);*/
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
@ -129,7 +130,13 @@ void AbstractEventCountNotifier::handleResetMissedCalls (ChatRoomModel *chatRoom
|
|||
internalnotifyEventCount();
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractEventCountNotifier::handleCallMissed (CallModel *callModel) {
|
||||
++mMissedCalls[{ Utils::cleanSipAddress(callModel->getPeerAddress()), Utils::cleanSipAddress(callModel->getLocalAddress()) }];
|
||||
internalnotifyEventCount();
|
||||
}
|
||||
|
||||
void AbstractEventCountNotifier::handleCallMissed (const QString& localAddress, const QString& peerAddress) {
|
||||
++mMissedCalls[{ peerAddress, localAddress }];
|
||||
internalnotifyEventCount();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
// =============================================================================
|
||||
|
||||
namespace linphone {
|
||||
class ChatMessage;
|
||||
class ChatMessage;
|
||||
}
|
||||
|
||||
class CallModel;
|
||||
|
|
@ -38,45 +38,46 @@ class ChatRoomModel;
|
|||
class HistoryModel;
|
||||
|
||||
class AbstractEventCountNotifier : public QObject {
|
||||
Q_OBJECT;
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AbstractEventCountNotifier (QObject *parent = Q_NULLPTR);
|
||||
|
||||
void updateUnreadMessageCount ();
|
||||
|
||||
int getUnreadMessageCount () const { return mUnreadMessageCount; }
|
||||
int getMissedCallCount () const {
|
||||
int t = 0;
|
||||
for (int n : mMissedCalls) t += n;
|
||||
return t;
|
||||
}
|
||||
|
||||
int getEventCount () const { return mUnreadMessageCount + getMissedCallCount(); }
|
||||
int getMissedCallCount(const QString &peerAddress, const QString &localAddress) const;// Get missed call count from a chat (useful for showing bubbles on Timelines)
|
||||
int getMissedCallCountFromLocal(const QString &localAddress) const;// Get missed call count from a chat (useful for showing bubbles on Timelines)
|
||||
|
||||
AbstractEventCountNotifier (QObject *parent = Q_NULLPTR);
|
||||
|
||||
void updateUnreadMessageCount ();
|
||||
|
||||
int getUnreadMessageCount () const { return mUnreadMessageCount; }
|
||||
int getMissedCallCount () const {
|
||||
int t = 0;
|
||||
for (int n : mMissedCalls) t += n;
|
||||
return t;
|
||||
}
|
||||
|
||||
int getEventCount () const { return mUnreadMessageCount + getMissedCallCount(); }
|
||||
int getMissedCallCount(const QString &peerAddress, const QString &localAddress) const;// Get missed call count from a chat (useful for showing bubbles on Timelines)
|
||||
int getMissedCallCountFromLocal(const QString &localAddress) const;// Get missed call count from a chat (useful for showing bubbles on Timelines)
|
||||
|
||||
signals:
|
||||
void eventCountChanged ();
|
||||
|
||||
void eventCountChanged ();
|
||||
|
||||
public slots:
|
||||
void handleCallMissed (const QString& localAddress, const QString& peerAddress);
|
||||
void handleResetAllMissedCalls ();
|
||||
void handleResetMissedCalls (ChatRoomModel *chatRoomModel);
|
||||
void handleCallMissed (CallModel *callModel);
|
||||
|
||||
protected:
|
||||
virtual void notifyEventCount (int n) = 0;
|
||||
|
||||
virtual void notifyEventCount (int n) = 0;
|
||||
|
||||
private:
|
||||
using ConferenceId = QPair<QString, QString>;
|
||||
|
||||
void internalnotifyEventCount ();
|
||||
|
||||
void handleChatRoomModelCreated (const std::shared_ptr<ChatRoomModel> &chatRoomModel);
|
||||
void handleHistoryModelCreated (HistoryModel *historyModel);
|
||||
|
||||
|
||||
void handleResetAllMissedCalls ();
|
||||
void handleResetMissedCalls (ChatRoomModel *chatRoomModel);
|
||||
void handleCallMissed (CallModel *callModel);
|
||||
|
||||
QHash<ConferenceId, int> mMissedCalls;
|
||||
int mUnreadMessageCount = 0;
|
||||
using ConferenceId = QPair<QString, QString>;
|
||||
|
||||
void internalnotifyEventCount ();
|
||||
|
||||
void handleChatRoomModelCreated (const std::shared_ptr<ChatRoomModel> &chatRoomModel);
|
||||
void handleHistoryModelCreated (HistoryModel *historyModel);
|
||||
|
||||
QHash<ConferenceId, int> mMissedCalls;
|
||||
int mUnreadMessageCount = 0;
|
||||
};
|
||||
|
||||
#endif // ABSTRACT_EVENT_COUNT_NOTIFIER_H_
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "components/core/CoreHandlers.hpp"
|
||||
#include "components/calls/CallsListModel.hpp"
|
||||
#include "components/settings/AccountSettingsModel.hpp"
|
||||
#include "components/settings/SettingsModel.hpp"
|
||||
#include "components/sip-addresses/SipAddressesModel.hpp"
|
||||
|
|
@ -44,6 +45,9 @@ TimelineListModel::TimelineListModel (QObject *parent) : QAbstractListModel(pare
|
|||
connect(coreHandlers, &CoreHandlers::messageReceived, this, &TimelineListModel::update);
|
||||
connect(coreHandlers, &CoreHandlers::messageReceived, this, &TimelineListModel::updated);
|
||||
|
||||
QObject::connect(coreHandlers, &CoreHandlers::callStateChanged, this, &TimelineListModel::onCallStateChanged);
|
||||
QObject::connect(coreHandlers, &CoreHandlers::callCreated, this, &TimelineListModel::onCallCreated);
|
||||
|
||||
connect(CoreManager::getInstance()->getSettingsModel(), &SettingsModel::hideEmptyChatRoomsChanged, this, &TimelineListModel::update);
|
||||
connect(CoreManager::getInstance()->getAccountSettingsModel(), &AccountSettingsModel::defaultRegistrationChanged, this, &TimelineListModel::update);
|
||||
updateTimelines ();
|
||||
|
|
@ -323,6 +327,39 @@ void TimelineListModel::onChatRoomStateChanged(const std::shared_ptr<linphone::C
|
|||
}else if(state == linphone::ChatRoom::State::Deleted){
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineListModel::onCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::Call::State state) {
|
||||
}
|
||||
|
||||
void TimelineListModel::onCallCreated(const std::shared_ptr<linphone::Call> &call){
|
||||
std::shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
std::shared_ptr<linphone::ChatRoomParams> params = core->createDefaultChatRoomParams();
|
||||
std::list<std::shared_ptr<linphone::Address>> participants;
|
||||
|
||||
// Find all chat rooms with local address. If not, create one.
|
||||
bool isOutgoing = (call->getDir() == linphone::Call::Dir::Outgoing) ;
|
||||
bool found = false;
|
||||
auto callLog = call->getCallLog();
|
||||
auto callLocalAddress = callLog->getLocalAddress();
|
||||
auto chatRoom = core->searchChatRoom(params, callLocalAddress
|
||||
, callLog->getRemoteAddress()
|
||||
, participants);
|
||||
if(chatRoom){
|
||||
for(auto timeline : mTimelines){
|
||||
if( chatRoom == timeline->mChatRoomModel->getChatRoom()){
|
||||
found = true;
|
||||
if(isOutgoing)// If outgoing, we switch to this chat room
|
||||
timeline->setSelected(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!found){// Create a default chat room
|
||||
QVariantList participants;
|
||||
participants << Utils::coreStringToAppString(callLog->getRemoteAddress()->asStringUriOnly());
|
||||
CoreManager::getInstance()->getCallsListModel()->createChatRoom("", 0, participants, isOutgoing);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void TimelineListModel::onConferenceLeft(const std::shared_ptr<linphone::ChatRoom> &chatRoom, , const std::shared_ptr<const linphone::EventLog> & eventLog){
|
||||
remove(getTimeline(chatRoom, false).get());
|
||||
|
|
|
|||
|
|
@ -56,12 +56,16 @@ public:
|
|||
void remove(std::shared_ptr<TimelineModel> model);
|
||||
int mSelectedCount;
|
||||
|
||||
bool mAutoSelectAfterCreation = false;// Request to select the next chat room after creation
|
||||
|
||||
void setSelectedCount(int selectedCount);
|
||||
public slots:
|
||||
void update();
|
||||
void removeChatRoomModel(std::shared_ptr<ChatRoomModel> model);
|
||||
void onSelectedHasChanged(bool selected);
|
||||
void onChatRoomStateChanged(const std::shared_ptr<linphone::ChatRoom> &chatRoom,linphone::ChatRoom::State state);
|
||||
void onCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::Call::State state) ;
|
||||
void onCallCreated(const std::shared_ptr<linphone::Call> &call);
|
||||
//void onConferenceLeft();
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -49,15 +49,11 @@ std::shared_ptr<TimelineModel> TimelineModel::create(std::shared_ptr<linphone::C
|
|||
TimelineModel::TimelineModel (std::shared_ptr<linphone::ChatRoom> chatRoom, QObject *parent) : QObject(parent) {
|
||||
App::getInstance()->getEngine()->setObjectOwnership(this, QQmlEngine::CppOwnership);// Avoid QML to destroy it when passing by Q_INVOKABLE
|
||||
mChatRoomModel = ChatRoomModel::create(chatRoom);
|
||||
// mChatRoomModel = CoreManager::getInstance()->getTimelineListModel()->getChatRoomModel(chatRoom);
|
||||
if( mChatRoomModel ){
|
||||
CoreManager::getInstance()->handleChatRoomCreated(mChatRoomModel);
|
||||
QObject::connect(this, &TimelineModel::selectedChanged, this, &TimelineModel::updateUnreadCount);
|
||||
QObject::connect(CoreManager::getInstance()->getAccountSettingsModel(), &AccountSettingsModel::defaultProxyChanged, this, &TimelineModel::onDefaultProxyChanged);
|
||||
}
|
||||
|
||||
//QObject::connect(mChatRoomModel.get(), &ChatRoomModel::conferenceLeft, this, &TimelineModel::onConferenceLeft);
|
||||
//mTimestamp = QDateTime::fromMSecsSinceEpoch(mChatRoomModel->getChatRoom()->getLastUpdateTime());
|
||||
mSelected = false;
|
||||
}
|
||||
|
||||
|
|
@ -133,10 +129,12 @@ void TimelineModel::onParticipantAdded(const std::shared_ptr<linphone::ChatRoom>
|
|||
void TimelineModel::onParticipantRemoved(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::EventLog> & eventLog){}
|
||||
void TimelineModel::onParticipantAdminStatusChanged(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::EventLog> & eventLog){}
|
||||
void TimelineModel::onStateChanged(const std::shared_ptr<linphone::ChatRoom> & chatRoom, linphone::ChatRoom::State newState){
|
||||
if(newState == linphone::ChatRoom::State::Created)
|
||||
if(newState == linphone::ChatRoom::State::Created && CoreManager::getInstance()->getTimelineListModel()->mAutoSelectAfterCreation) {
|
||||
CoreManager::getInstance()->getTimelineListModel()->mAutoSelectAfterCreation = false;
|
||||
QTimer::singleShot(200, [=](){// Delay process in order to let GUI time for Timeline building/linking before doing actions
|
||||
setSelected(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
void TimelineModel::onSecurityEvent(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::EventLog> & eventLog){}
|
||||
void TimelineModel::onSubjectChanged(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::EventLog> & eventLog)
|
||||
|
|
|
|||
|
|
@ -61,14 +61,10 @@ public:
|
|||
|
||||
void setSelected(const bool& selected);
|
||||
|
||||
|
||||
//Q_INVOKABLE std::shared_ptr<ChatRoomModel> getChatRoomModel() const;
|
||||
Q_INVOKABLE ChatRoomModel* getChatRoomModel() const;
|
||||
|
||||
bool mSelected;
|
||||
//QDateTime mTimestamp;
|
||||
std::shared_ptr<ChatRoomModel> mChatRoomModel;
|
||||
//std::shared_ptr<linphone::ChatRoom> mChatRoom;
|
||||
|
||||
virtual void onIsComposingReceived(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::Address> & remoteAddress, bool isComposing) override;
|
||||
virtual void onMessageReceived(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<linphone::ChatMessage> & message) override;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import QtQuick 2.7
|
|||
|
||||
import Common 1.0
|
||||
import Linphone 1.0
|
||||
import LinphoneEnums 1.0
|
||||
import Linphone.Styles 1.0
|
||||
import Utils 1.0
|
||||
|
||||
|
|
@ -9,30 +10,29 @@ import Utils 1.0
|
|||
|
||||
Row {
|
||||
property string _type: {
|
||||
var status = $chatEntry.state
|
||||
|
||||
if (status === ChatRoomModel.CallStatusSuccess) {
|
||||
var status = $chatEntry.status
|
||||
if (status == LinphoneEnums.CallStatusSuccess) {
|
||||
if (!$chatEntry.isStart) {
|
||||
return 'ended_call'
|
||||
}
|
||||
return $chatEntry.isOutgoing ? 'outgoing_call' : 'incoming_call'
|
||||
}
|
||||
if (status === ChatRoomModel.CallStatusDeclined) {
|
||||
if (status == LinphoneEnums.CallStatusDeclined) {
|
||||
return $chatEntry.isOutgoing ? 'declined_outgoing_call' : 'declined_incoming_call'
|
||||
}
|
||||
if (status === ChatRoomModel.CallStatusMissed) {
|
||||
if (status == LinphoneEnums.CallStatusMissed) {
|
||||
return $chatEntry.isOutgoing ? 'missed_outgoing_call' : 'missed_incoming_call'
|
||||
}
|
||||
if (status === ChatRoomModel.CallStatusAborted) {
|
||||
if (status == LinphoneEnums.CallStatusAborted) {
|
||||
return $chatEntry.isOutgoing ? 'outgoing_call' : 'incoming_call'
|
||||
}
|
||||
if (status === ChatRoomModel.CallStatusEarlyAborted) {
|
||||
if (status == LinphoneEnums.CallStatusEarlyAborted) {
|
||||
return $chatEntry.isOutgoing ? 'missed_outgoing_call' : 'missed_incoming_call'
|
||||
}
|
||||
if (status === ChatRoomModel.CallStatusAcceptedElsewhere) {
|
||||
if (status == LinphoneEnums.CallStatusAcceptedElsewhere) {
|
||||
return $chatEntry.isOutgoing ? 'outgoing_call' : 'incoming_call'
|
||||
}
|
||||
if (status === ChatRoomModel.CallStatusDeclinedElsewhere) {
|
||||
if (status == LinphoneEnums.CallStatusDeclinedElsewhere) {
|
||||
return $chatEntry.isOutgoing ? 'declined_outgoing_call' : 'declined_incoming_call'
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ DialogPlus {
|
|||
capitalization: Font.AllUppercase
|
||||
|
||||
onClicked: {
|
||||
if(CallsListModel.createChatRoom(subject.text, secureSwitch.checked, selectedParticipants.getParticipants() ))
|
||||
if(CallsListModel.createChatRoom(subject.text, secureSwitch.checked, selectedParticipants.getParticipants(), true ))
|
||||
exit(1)
|
||||
}
|
||||
TooltipArea{
|
||||
|
|
|
|||
|
|
@ -59,8 +59,9 @@ function unlockView () {
|
|||
}
|
||||
|
||||
function setView (view, props) {
|
||||
function apply (view, props) {
|
||||
Linphone.App.smartShowWindow(window)
|
||||
function apply (view, props, showWindow) {
|
||||
if(showWindow)
|
||||
Linphone.App.smartShowWindow(window)
|
||||
|
||||
var item = mainLoader.item
|
||||
|
||||
|
|
@ -71,7 +72,7 @@ function setView (view, props) {
|
|||
|
||||
var lockedInfo = window._lockedInfo
|
||||
if (!lockedInfo) {
|
||||
apply(view, props)
|
||||
apply(view, props, false)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +81,7 @@ function setView (view, props) {
|
|||
}, function (status) {
|
||||
if (status) {
|
||||
unlockView()
|
||||
apply(view, props)
|
||||
apply(view, props, true)
|
||||
} else {
|
||||
updateSelectedEntry(window._currentView, props)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ ApplicationWindow {
|
|||
if (entry.contact && SettingsModel.contactsEnabled) {
|
||||
window.setView('ContactEdit', { sipAddress: entry.sipAddress })
|
||||
} else {
|
||||
CallsListModel.createChatRoom( "", false, [entry] )
|
||||
CallsListModel.createChatRoom( "", false, [entry], true )
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue