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());
|
||||
auto chatRoomAddress = chatRoom->getPeerAddress()->clone();
|
||||
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());
|
||||
if (chatRoom->hasCapability((int)linphone::ChatRoom::Capabilities::Basic)) {
|
||||
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::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;
|
||||
for (auto &eventLog : history) {
|
||||
lHistory.push_back(eventLog);
|
||||
}
|
||||
|
||||
QList<QSharedPointer<EventLogCore>> eventList;
|
||||
for (auto &event : lHistory) {
|
||||
auto eventLogCore = EventLogCore::create(event);
|
||||
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()) {
|
||||
for (auto content : isMessage->getChatMessageContentList()) {
|
||||
if (content->isFile() && !content->isVoiceRecording()) {
|
||||
|
|
@ -258,6 +270,7 @@ void ChatCore::setSelf(QSharedPointer<ChatCore> me) {
|
|||
auto event = EventLogCore::create(e);
|
||||
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]() {
|
||||
appendEventLogsToEventLogList(list);
|
||||
emit lUpdateUnreadCount();
|
||||
|
|
@ -723,6 +736,7 @@ QSharedPointer<AccountCore> ChatCore::getLocalAccount() const {
|
|||
|
||||
void ChatCore::updateInfo(const std::shared_ptr<linphone::Friend> &updatedFriend, bool isRemoval) {
|
||||
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);
|
||||
bool isThisFriend = mFriendModel && updatedFriend == mFriendModel->getFriend();
|
||||
if (!isThisFriend)
|
||||
|
|
|
|||
|
|
@ -89,11 +89,14 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
|
|||
QList<QSharedPointer<ChatCore>> *chats = new QList<QSharedPointer<ChatCore>>();
|
||||
auto currentAccount = CoreModel::getInstance()->getCore()->getDefaultAccount();
|
||||
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));
|
||||
for (auto it : linphoneChatRooms) {
|
||||
auto model = createChatCore(it);
|
||||
chats->push_back(model);
|
||||
}
|
||||
// TODO FIXME t'es pas déjà dans le thread du core ici ?
|
||||
mModelConnection->invokeToCore([this, chats]() {
|
||||
for (auto &chat : getSharedList<ChatCore>()) {
|
||||
if (chat) {
|
||||
|
|
@ -139,6 +142,7 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
|
|||
}
|
||||
|
||||
auto chatCore = ChatCore::create(room);
|
||||
// TODO FIXME t'es pas déjà dans le thread du core ici ?
|
||||
mModelConnection->invokeToCore([this, chatCore] {
|
||||
auto chatList = getSharedList<ChatCore>();
|
||||
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,
|
||||
const std::shared_ptr<linphone::ChatRoom> &room,
|
||||
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());
|
||||
});
|
||||
mModelConnection->makeConnectToModel(
|
||||
|
|
|
|||
|
|
@ -55,10 +55,7 @@ int AbstractEventCountNotifier::getCurrentEventCount() const {
|
|||
else {
|
||||
auto currentAccount = CoreModel::getInstance()->getCore()->getDefaultAccount();
|
||||
if (currentAccount) {
|
||||
auto linphoneChatRooms = currentAccount->filterChatRooms("");
|
||||
for (const auto &chatRoom : linphoneChatRooms) {
|
||||
count += chatRoom->getUnreadMessagesCount();
|
||||
}
|
||||
count += currentAccount->getUnreadChatMessageCount();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -395,6 +395,7 @@ void Notifier::notifyReceivedMessages(const std::shared_ptr<linphone::ChatRoom>
|
|||
});
|
||||
auto settings = SettingsModel::getInstance();
|
||||
if (settings && !settings->dndEnabled()) {
|
||||
// TODO FIXME on serait pas sur le mauvais thread ici ?
|
||||
CoreModel::getInstance()->getCore()->playLocal(
|
||||
Utils::appStringToCoreString(settings->getChatNotificationSoundPath()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,9 +44,10 @@ AccountModel::AccountModel(const std::shared_ptr<linphone::Account> &account, QO
|
|||
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());
|
||||
});
|
||||
});*/
|
||||
connect(CoreModel::getInstance().get(), &CoreModel::accountRemoved, this,
|
||||
[this](const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::Account> &account) {
|
||||
if (account == mMonitor) {
|
||||
|
|
|
|||
|
|
@ -52,27 +52,20 @@ QDateTime ChatModel::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 {
|
||||
return Utils::coreStringToAppString(mMonitor->getIdentifier());
|
||||
}
|
||||
|
||||
QString ChatModel::getTitle() {
|
||||
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());
|
||||
} else {
|
||||
if (mMonitor->hasCapability((int)linphone::ChatRoom::Capabilities::OneToOne)) {
|
||||
auto participants = mMonitor->getParticipants();
|
||||
if (participants.size() > 0) {
|
||||
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()) : "";
|
||||
} else {
|
||||
return "";
|
||||
|
|
@ -106,9 +99,6 @@ int ChatModel::getUnreadMessagesCount() const {
|
|||
|
||||
void ChatModel::markAsRead() {
|
||||
mMonitor->markAsRead();
|
||||
for (auto &message : getHistory()) {
|
||||
message->markAsRead();
|
||||
}
|
||||
emit messagesRead();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ public:
|
|||
bool hasCapability(int capability) const;
|
||||
int getUnreadMessagesCount() const;
|
||||
void markAsRead();
|
||||
std::list<std::shared_ptr<linphone::ChatMessage>> getHistory() const;
|
||||
QString getIdentifier() const;
|
||||
void deleteHistory();
|
||||
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() {
|
||||
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();
|
||||
mCore =
|
||||
linphone::Factory::get()->createCore(Utils::appStringToCoreString(Paths::getConfigFilePath(mConfigPath)),
|
||||
|
|
@ -122,6 +113,12 @@ void CoreModel::start() {
|
|||
mCore->enableFriendListSubscription(true);
|
||||
if (mCore->getLogCollectionUploadServerUrl().empty())
|
||||
mCore->setLogCollectionUploadServerUrl(Constants::DefaultUploadLogsServer);
|
||||
|
||||
mIterateTimer = new QTimer(this);
|
||||
mIterateTimer->setInterval(20);
|
||||
connect(mIterateTimer, &QTimer::timeout, [this]() {
|
||||
mCore->iterate();
|
||||
});
|
||||
mIterateTimer->start();
|
||||
|
||||
auto linphoneSearch = mCore->createMagicSearch();
|
||||
|
|
|
|||
|
|
@ -196,8 +196,8 @@ QString ToolModel::encodeTextToQmlRichFormat(const QString &text,
|
|||
auto foundParticipant = *it;
|
||||
// participants.at(std::distance(participants.begin(), it));
|
||||
auto address = foundParticipant->getAddress()->clone();
|
||||
auto isFriend = findFriendByAddress(address);
|
||||
address->clean();
|
||||
auto isFriend = findFriendByAddress(address);
|
||||
auto addressString = Utils::coreStringToAppString(address->asStringUriOnly());
|
||||
if (isFriend)
|
||||
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) {
|
||||
auto defaultFriendList = CoreModel::getInstance()->getCore()->getDefaultFriendList();
|
||||
if (!defaultFriendList) return nullptr;
|
||||
auto linphoneAddr = ToolModel::interpretUrl(address);
|
||||
if (linphoneAddr) return ToolModel::findFriendByAddress(linphoneAddr);
|
||||
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