mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 03:18:07 +00:00
TODOs, FIXMEs et questions
This commit is contained in:
parent
4fca0a4140
commit
46ffdca53c
10 changed files with 35 additions and 33 deletions
|
|
@ -47,6 +47,7 @@ ChatCore::ChatCore(const std::shared_ptr<linphone::ChatRoom> &chatRoom) : QObjec
|
||||||
mLastUpdatedTime = QDateTime::fromSecsSinceEpoch(chatRoom->getLastUpdateTime());
|
mLastUpdatedTime = QDateTime::fromSecsSinceEpoch(chatRoom->getLastUpdateTime());
|
||||||
auto chatRoomAddress = chatRoom->getPeerAddress()->clone();
|
auto chatRoomAddress = chatRoom->getPeerAddress()->clone();
|
||||||
chatRoomAddress->clean();
|
chatRoomAddress->clean();
|
||||||
|
// TODO FIXME Ne pas stocker les Address sous forme de string et avoir à les re-parser en Address après, autant garder directement le shared_ptr en mémoire
|
||||||
mChatRoomAddress = Utils::coreStringToAppString(chatRoomAddress->asStringUriOnly());
|
mChatRoomAddress = Utils::coreStringToAppString(chatRoomAddress->asStringUriOnly());
|
||||||
if (chatRoom->hasCapability((int)linphone::ChatRoom::Capabilities::Basic)) {
|
if (chatRoom->hasCapability((int)linphone::ChatRoom::Capabilities::Basic)) {
|
||||||
mTitle = ToolModel::getDisplayName(chatRoomAddress);
|
mTitle = ToolModel::getDisplayName(chatRoomAddress);
|
||||||
|
|
@ -90,15 +91,26 @@ ChatCore::ChatCore(const std::shared_ptr<linphone::ChatRoom> &chatRoom) : QObjec
|
||||||
static_cast<int>(linphone::ChatRoom::HistoryFilter::InfoNoDevice)
|
static_cast<int>(linphone::ChatRoom::HistoryFilter::InfoNoDevice)
|
||||||
: static_cast<int>(linphone::ChatRoom::HistoryFilter::ChatMessage);
|
: static_cast<int>(linphone::ChatRoom::HistoryFilter::ChatMessage);
|
||||||
|
|
||||||
auto history = chatRoom->getHistory(0, filter);
|
// TODO FIXME Tu récupère l'historique entier de chaque chat room qui est mise dans la liste, du coup ça prend du temps
|
||||||
|
// et potentiellement ça sert a rien si l'utilisateur va jamais dedans.
|
||||||
|
// Peut-être il faudrait un ChatListCore/ChatListModel pour juste la partie liste ?
|
||||||
|
|
||||||
|
// TODO FIXME Aussi il ne faut pas tout charger mais uniquement mettons les 30 derniers messages
|
||||||
|
// et les charger à la volée quand l'utilisateur scrolle vers le haut
|
||||||
|
|
||||||
|
// Dernière question : pourquoi bouger les eventLog depuis history dans lHistory et pas faire directement
|
||||||
|
// lHistory = chatRoom->getHistory(0, filter); ?
|
||||||
|
auto history = chatRoom->getHistory(30, filter);
|
||||||
std::list<std::shared_ptr<linphone::EventLog>> lHistory;
|
std::list<std::shared_ptr<linphone::EventLog>> lHistory;
|
||||||
for (auto &eventLog : history) {
|
for (auto &eventLog : history) {
|
||||||
lHistory.push_back(eventLog);
|
lHistory.push_back(eventLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QSharedPointer<EventLogCore>> eventList;
|
QList<QSharedPointer<EventLogCore>> eventList;
|
||||||
for (auto &event : lHistory) {
|
for (auto &event : lHistory) {
|
||||||
auto eventLogCore = EventLogCore::create(event);
|
auto eventLogCore = EventLogCore::create(event);
|
||||||
eventList.append(eventLogCore);
|
eventList.append(eventLogCore);
|
||||||
|
// TODO faudra que tu m'expliques pourquoi tu as besoin de cette liste des fichiers de chaque message de la chat room
|
||||||
if (auto isMessage = eventLogCore->getChatMessageCore()) {
|
if (auto isMessage = eventLogCore->getChatMessageCore()) {
|
||||||
for (auto content : isMessage->getChatMessageContentList()) {
|
for (auto content : isMessage->getChatMessageContentList()) {
|
||||||
if (content->isFile() && !content->isVoiceRecording()) {
|
if (content->isFile() && !content->isVoiceRecording()) {
|
||||||
|
|
@ -258,6 +270,7 @@ void ChatCore::setSelf(QSharedPointer<ChatCore> me) {
|
||||||
auto event = EventLogCore::create(e);
|
auto event = EventLogCore::create(e);
|
||||||
list.push_back(event);
|
list.push_back(event);
|
||||||
}
|
}
|
||||||
|
// TODO FIXME On devrait déjà être dans le thread du Core ici, du coup je pense que c'est pas nécessaire
|
||||||
mChatModelConnection->invokeToCore([this, list]() {
|
mChatModelConnection->invokeToCore([this, list]() {
|
||||||
appendEventLogsToEventLogList(list);
|
appendEventLogsToEventLogList(list);
|
||||||
emit lUpdateUnreadCount();
|
emit lUpdateUnreadCount();
|
||||||
|
|
@ -723,6 +736,7 @@ QSharedPointer<AccountCore> ChatCore::getLocalAccount() const {
|
||||||
|
|
||||||
void ChatCore::updateInfo(const std::shared_ptr<linphone::Friend> &updatedFriend, bool isRemoval) {
|
void ChatCore::updateInfo(const std::shared_ptr<linphone::Friend> &updatedFriend, bool isRemoval) {
|
||||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||||
|
// TODO FIXME Je sais pas quand UpdateInfo() est appelé ni pourquoi mais le check sur la peerAddress ne marchera que pour les Basic
|
||||||
auto fAddress = ToolModel::interpretUrl(mPeerAddress);
|
auto fAddress = ToolModel::interpretUrl(mPeerAddress);
|
||||||
bool isThisFriend = mFriendModel && updatedFriend == mFriendModel->getFriend();
|
bool isThisFriend = mFriendModel && updatedFriend == mFriendModel->getFriend();
|
||||||
if (!isThisFriend)
|
if (!isThisFriend)
|
||||||
|
|
|
||||||
|
|
@ -89,11 +89,14 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
|
||||||
QList<QSharedPointer<ChatCore>> *chats = new QList<QSharedPointer<ChatCore>>();
|
QList<QSharedPointer<ChatCore>> *chats = new QList<QSharedPointer<ChatCore>>();
|
||||||
auto currentAccount = CoreModel::getInstance()->getCore()->getDefaultAccount();
|
auto currentAccount = CoreModel::getInstance()->getCore()->getDefaultAccount();
|
||||||
if (!currentAccount) return;
|
if (!currentAccount) return;
|
||||||
|
// TODO FIXME J'ai pas réussi à trouver si c'était le cas mais il ne faut pas re-trier la liste des chat rooms renvoyée par filterChatRooms()
|
||||||
|
// Tu ne dois le faire uniquement que dans les callback onMessageSent() et onMessagesReceived()
|
||||||
auto linphoneChatRooms = currentAccount->filterChatRooms(Utils::appStringToCoreString(mFilter));
|
auto linphoneChatRooms = currentAccount->filterChatRooms(Utils::appStringToCoreString(mFilter));
|
||||||
for (auto it : linphoneChatRooms) {
|
for (auto it : linphoneChatRooms) {
|
||||||
auto model = createChatCore(it);
|
auto model = createChatCore(it);
|
||||||
chats->push_back(model);
|
chats->push_back(model);
|
||||||
}
|
}
|
||||||
|
// TODO FIXME t'es pas déjà dans le thread du core ici ?
|
||||||
mModelConnection->invokeToCore([this, chats]() {
|
mModelConnection->invokeToCore([this, chats]() {
|
||||||
for (auto &chat : getSharedList<ChatCore>()) {
|
for (auto &chat : getSharedList<ChatCore>()) {
|
||||||
if (chat) {
|
if (chat) {
|
||||||
|
|
@ -139,6 +142,7 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto chatCore = ChatCore::create(room);
|
auto chatCore = ChatCore::create(room);
|
||||||
|
// TODO FIXME t'es pas déjà dans le thread du core ici ?
|
||||||
mModelConnection->invokeToCore([this, chatCore] {
|
mModelConnection->invokeToCore([this, chatCore] {
|
||||||
auto chatList = getSharedList<ChatCore>();
|
auto chatList = getSharedList<ChatCore>();
|
||||||
auto it = std::find_if(chatList.begin(), chatList.end(), [chatCore](const QSharedPointer<ChatCore> item) {
|
auto it = std::find_if(chatList.begin(), chatList.end(), [chatCore](const QSharedPointer<ChatCore> item) {
|
||||||
|
|
@ -163,6 +167,7 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
|
||||||
[this, addChatToList](const std::shared_ptr<linphone::Core> &core,
|
[this, addChatToList](const std::shared_ptr<linphone::Core> &core,
|
||||||
const std::shared_ptr<linphone::ChatRoom> &room,
|
const std::shared_ptr<linphone::ChatRoom> &room,
|
||||||
const std::list<std::shared_ptr<linphone::ChatMessage>> &messages) {
|
const std::list<std::shared_ptr<linphone::ChatMessage>> &messages) {
|
||||||
|
// TODO FIXME c'est normal que seul le premier des messages soit ajouté à la liste et pas tous ?
|
||||||
addChatToList(core, room, messages.front());
|
addChatToList(core, room, messages.front());
|
||||||
});
|
});
|
||||||
mModelConnection->makeConnectToModel(
|
mModelConnection->makeConnectToModel(
|
||||||
|
|
|
||||||
|
|
@ -55,10 +55,7 @@ int AbstractEventCountNotifier::getCurrentEventCount() const {
|
||||||
else {
|
else {
|
||||||
auto currentAccount = CoreModel::getInstance()->getCore()->getDefaultAccount();
|
auto currentAccount = CoreModel::getInstance()->getCore()->getDefaultAccount();
|
||||||
if (currentAccount) {
|
if (currentAccount) {
|
||||||
auto linphoneChatRooms = currentAccount->filterChatRooms("");
|
count += currentAccount->getUnreadChatMessageCount();
|
||||||
for (const auto &chatRoom : linphoneChatRooms) {
|
|
||||||
count += chatRoom->getUnreadMessagesCount();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -395,6 +395,7 @@ void Notifier::notifyReceivedMessages(const std::shared_ptr<linphone::ChatRoom>
|
||||||
});
|
});
|
||||||
auto settings = SettingsModel::getInstance();
|
auto settings = SettingsModel::getInstance();
|
||||||
if (settings && !settings->dndEnabled()) {
|
if (settings && !settings->dndEnabled()) {
|
||||||
|
// TODO FIXME on serait pas sur le mauvais thread ici ?
|
||||||
CoreModel::getInstance()->getCore()->playLocal(
|
CoreModel::getInstance()->getCore()->playLocal(
|
||||||
Utils::appStringToCoreString(settings->getChatNotificationSoundPath()));
|
Utils::appStringToCoreString(settings->getChatNotificationSoundPath()));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,10 @@ AccountModel::AccountModel(const std::shared_ptr<linphone::Account> &account, QO
|
||||||
Utils::coreStringToAppString(mMonitor->getParams()->getIdentityAddress()->getDisplayName()));
|
Utils::coreStringToAppString(mMonitor->getParams()->getIdentityAddress()->getDisplayName()));
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(CoreModel::getInstance().get(), &CoreModel::unreadNotificationsChanged, this, [this]() {
|
// TODO FIXME infinite loop
|
||||||
|
/*connect(CoreModel::getInstance().get(), &CoreModel::unreadNotificationsChanged, this, [this]() {
|
||||||
emit unreadNotificationsChanged(mMonitor->getUnreadChatMessageCount(), mMonitor->getMissedCallsCount());
|
emit unreadNotificationsChanged(mMonitor->getUnreadChatMessageCount(), mMonitor->getMissedCallsCount());
|
||||||
});
|
});*/
|
||||||
connect(CoreModel::getInstance().get(), &CoreModel::accountRemoved, this,
|
connect(CoreModel::getInstance().get(), &CoreModel::accountRemoved, this,
|
||||||
[this](const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::Account> &account) {
|
[this](const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::Account> &account) {
|
||||||
if (account == mMonitor) {
|
if (account == mMonitor) {
|
||||||
|
|
|
||||||
|
|
@ -52,27 +52,20 @@ QDateTime ChatModel::getLastUpdateTime() {
|
||||||
return QDateTime::fromSecsSinceEpoch(mMonitor->getLastUpdateTime());
|
return QDateTime::fromSecsSinceEpoch(mMonitor->getLastUpdateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<std::shared_ptr<linphone::ChatMessage>> ChatModel::getHistory() const {
|
|
||||||
auto history = mMonitor->getHistory(0, (int)linphone::ChatRoom::HistoryFilter::ChatMessage);
|
|
||||||
std::list<std::shared_ptr<linphone::ChatMessage>> res;
|
|
||||||
for (auto &eventLog : history) {
|
|
||||||
if (!eventLog->getChatMessage()) res.push_back(eventLog->getChatMessage());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ChatModel::getIdentifier() const {
|
QString ChatModel::getIdentifier() const {
|
||||||
return Utils::coreStringToAppString(mMonitor->getIdentifier());
|
return Utils::coreStringToAppString(mMonitor->getIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChatModel::getTitle() {
|
QString ChatModel::getTitle() {
|
||||||
if (mMonitor->hasCapability((int)linphone::ChatRoom::Capabilities::Basic)) {
|
if (mMonitor->hasCapability((int)linphone::ChatRoom::Capabilities::Basic)) {
|
||||||
|
// TODO FIXME Ne pas cloner les addresses si possible, ça prend beaucoup de ressources !
|
||||||
return ToolModel::getDisplayName(mMonitor->getPeerAddress()->clone());
|
return ToolModel::getDisplayName(mMonitor->getPeerAddress()->clone());
|
||||||
} else {
|
} else {
|
||||||
if (mMonitor->hasCapability((int)linphone::ChatRoom::Capabilities::OneToOne)) {
|
if (mMonitor->hasCapability((int)linphone::ChatRoom::Capabilities::OneToOne)) {
|
||||||
auto participants = mMonitor->getParticipants();
|
auto participants = mMonitor->getParticipants();
|
||||||
if (participants.size() > 0) {
|
if (participants.size() > 0) {
|
||||||
auto peer = participants.front();
|
auto peer = participants.front();
|
||||||
|
// TODO FIXME Ne pas cloner les addresses si possible, ça prend beaucoup de ressources !
|
||||||
return peer ? ToolModel::getDisplayName(peer->getAddress()->clone()) : "";
|
return peer ? ToolModel::getDisplayName(peer->getAddress()->clone()) : "";
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
|
|
@ -106,9 +99,6 @@ int ChatModel::getUnreadMessagesCount() const {
|
||||||
|
|
||||||
void ChatModel::markAsRead() {
|
void ChatModel::markAsRead() {
|
||||||
mMonitor->markAsRead();
|
mMonitor->markAsRead();
|
||||||
for (auto &message : getHistory()) {
|
|
||||||
message->markAsRead();
|
|
||||||
}
|
|
||||||
emit messagesRead();
|
emit messagesRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ public:
|
||||||
bool hasCapability(int capability) const;
|
bool hasCapability(int capability) const;
|
||||||
int getUnreadMessagesCount() const;
|
int getUnreadMessagesCount() const;
|
||||||
void markAsRead();
|
void markAsRead();
|
||||||
std::list<std::shared_ptr<linphone::ChatMessage>> getHistory() const;
|
|
||||||
QString getIdentifier() const;
|
QString getIdentifier() const;
|
||||||
void deleteHistory();
|
void deleteHistory();
|
||||||
void deleteMessage(std::shared_ptr<linphone::ChatMessage> message);
|
void deleteMessage(std::shared_ptr<linphone::ChatMessage> message);
|
||||||
|
|
|
||||||
|
|
@ -70,15 +70,6 @@ std::shared_ptr<CoreModel> CoreModel::create(const QString &configPath, QThread
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoreModel::start() {
|
void CoreModel::start() {
|
||||||
mIterateTimer = new QTimer(this);
|
|
||||||
mIterateTimer->setInterval(30);
|
|
||||||
connect(mIterateTimer, &QTimer::timeout, [this]() {
|
|
||||||
static int iterateCount = 0;
|
|
||||||
if (iterateCount != 0) lCritical() << log().arg("Multi Iterate ! ");
|
|
||||||
++iterateCount;
|
|
||||||
mCore->iterate();
|
|
||||||
--iterateCount;
|
|
||||||
});
|
|
||||||
setPathBeforeCreation();
|
setPathBeforeCreation();
|
||||||
mCore =
|
mCore =
|
||||||
linphone::Factory::get()->createCore(Utils::appStringToCoreString(Paths::getConfigFilePath(mConfigPath)),
|
linphone::Factory::get()->createCore(Utils::appStringToCoreString(Paths::getConfigFilePath(mConfigPath)),
|
||||||
|
|
@ -122,6 +113,12 @@ void CoreModel::start() {
|
||||||
mCore->enableFriendListSubscription(true);
|
mCore->enableFriendListSubscription(true);
|
||||||
if (mCore->getLogCollectionUploadServerUrl().empty())
|
if (mCore->getLogCollectionUploadServerUrl().empty())
|
||||||
mCore->setLogCollectionUploadServerUrl(Constants::DefaultUploadLogsServer);
|
mCore->setLogCollectionUploadServerUrl(Constants::DefaultUploadLogsServer);
|
||||||
|
|
||||||
|
mIterateTimer = new QTimer(this);
|
||||||
|
mIterateTimer->setInterval(20);
|
||||||
|
connect(mIterateTimer, &QTimer::timeout, [this]() {
|
||||||
|
mCore->iterate();
|
||||||
|
});
|
||||||
mIterateTimer->start();
|
mIterateTimer->start();
|
||||||
|
|
||||||
auto linphoneSearch = mCore->createMagicSearch();
|
auto linphoneSearch = mCore->createMagicSearch();
|
||||||
|
|
|
||||||
|
|
@ -196,8 +196,8 @@ QString ToolModel::encodeTextToQmlRichFormat(const QString &text,
|
||||||
auto foundParticipant = *it;
|
auto foundParticipant = *it;
|
||||||
// participants.at(std::distance(participants.begin(), it));
|
// participants.at(std::distance(participants.begin(), it));
|
||||||
auto address = foundParticipant->getAddress()->clone();
|
auto address = foundParticipant->getAddress()->clone();
|
||||||
auto isFriend = findFriendByAddress(address);
|
|
||||||
address->clean();
|
address->clean();
|
||||||
|
auto isFriend = findFriendByAddress(address);
|
||||||
auto addressString = Utils::coreStringToAppString(address->asStringUriOnly());
|
auto addressString = Utils::coreStringToAppString(address->asStringUriOnly());
|
||||||
if (isFriend)
|
if (isFriend)
|
||||||
part = "@" + Utils::coreStringToAppString(isFriend->getAddress()->getDisplayName());
|
part = "@" + Utils::coreStringToAppString(isFriend->getAddress()->getDisplayName());
|
||||||
|
|
@ -221,8 +221,6 @@ QString ToolModel::encodeTextToQmlRichFormat(const QString &text,
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<linphone::Friend> ToolModel::findFriendByAddress(const QString &address) {
|
std::shared_ptr<linphone::Friend> ToolModel::findFriendByAddress(const QString &address) {
|
||||||
auto defaultFriendList = CoreModel::getInstance()->getCore()->getDefaultFriendList();
|
|
||||||
if (!defaultFriendList) return nullptr;
|
|
||||||
auto linphoneAddr = ToolModel::interpretUrl(address);
|
auto linphoneAddr = ToolModel::interpretUrl(address);
|
||||||
if (linphoneAddr) return ToolModel::findFriendByAddress(linphoneAddr);
|
if (linphoneAddr) return ToolModel::findFriendByAddress(linphoneAddr);
|
||||||
else return nullptr;
|
else return nullptr;
|
||||||
|
|
|
||||||
2
external/linphone-sdk
vendored
2
external/linphone-sdk
vendored
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0802fb170fd2458d83bfd16623ececf97d0ba7db
|
Subproject commit 1ddbb4e933a06fcdd9b1c968065017c36bae3da6
|
||||||
Loading…
Add table
Reference in a new issue