Order messages from receiving time.

Fix H264 download URL on Linux.
Hide Admin status in One-to-one chats.
Add Sanitizer build.
This commit is contained in:
Julien Wadel 2022-05-23 16:44:39 +02:00
parent e7d3dc37f4
commit a4196cd9fa
9 changed files with 48 additions and 15 deletions

View file

@ -92,6 +92,20 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -DQT_NO_DEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG" )
#############################
#Sanitizer
if(ENABLE_SANITIZER)
set(sanitize_flags "-fsanitize=address,undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls")
set(sanitize_linker_flags "-fsanitize=address,undefined")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${sanitize_flags}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${sanitize_flags}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${sanitize_linker_flags}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${sanitize_linker_flags}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${sanitize_linker_flags}")
endif()
#############################
if( WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WINSOCKAPI_")#remove error from windows headers order
endif()

View file

@ -34,7 +34,7 @@ public:
ChatRoomModel::EntryType mType;
virtual QDateTime getTimestamp() const;
virtual void setTimestamp(const QDateTime& timestamp);
virtual void setTimestamp(const QDateTime& timestamp = QDateTime::currentDateTime());
virtual void deleteEvent();

View file

@ -139,10 +139,13 @@ ChatMessageModel::ChatMessageModel ( std::shared_ptr<linphone::ChatMessage> chat
txt += content->getUtf8Text().c_str();
}
mContent = txt;
auto appData = AppDataManager(QString::fromStdString(getChatMessage()->getAppdata()));
if(appData.mData.contains("timestamp"))
mTimestamp = QDateTime::fromMSecsSinceEpoch(appData.mData["timestamp"].toLongLong());
else
mTimestamp = QDateTime::fromMSecsSinceEpoch(chatMessage->getTime() * 1000);
}
mWasDownloaded = false;
mTimestamp = QDateTime::fromMSecsSinceEpoch(chatMessage->getTime() * 1000);
mContentListModel = std::make_shared<ContentListModel>(this);
}
@ -266,6 +269,16 @@ void ChatMessageModel::setWasDownloaded(bool wasDownloaded){
}
}
void ChatMessageModel::setTimestamp(const QDateTime& timestamp) {
mTimestamp = timestamp;
auto timeT = timestamp.toMSecsSinceEpoch();
auto appData = AppDataManager(QString::fromStdString(getChatMessage()->getAppdata()));
if(appData.mData["timestamp"].toLongLong() != timeT) {
appData.mData["timestamp"] = timeT;
getChatMessage()->setAppdata(appData.toString().toStdString());
}
}
//-----------------------------------------------------------------------------------------------------------------------
void ChatMessageModel::resendMessage (){

View file

@ -149,12 +149,13 @@ public:
//----------------------------------------------------------------------------
void setWasDownloaded(bool wasDownloaded);
virtual void setTimestamp(const QDateTime& timestamp = QDateTime::currentDateTime()) override;
//----------------------------------------------------------------------------
Q_INVOKABLE void resendMessage ();
virtual void deleteEvent();
virtual void deleteEvent() override;
void updateFileTransferInformation();
// Linphone callbacks
void onFileTransferRecv(const std::shared_ptr<linphone::ChatMessage> & message, const std::shared_ptr<linphone::Content> & content, const std::shared_ptr<const linphone::Buffer> & buffer) ;

View file

@ -1118,9 +1118,10 @@ void ChatRoomModel::insertCalls (const QList<std::shared_ptr<linphone::CallLog>
}
}
void ChatRoomModel::insertMessageAtEnd (const std::shared_ptr<linphone::ChatMessage> &message) {
std::shared_ptr<ChatMessageModel> ChatRoomModel::insertMessageAtEnd (const std::shared_ptr<linphone::ChatMessage> &message) {
std::shared_ptr<ChatMessageModel> model;
if(mIsInitialized){
std::shared_ptr<ChatMessageModel> model = ChatMessageModel::create(message, this);
model = ChatMessageModel::create(message, this);
if(model){
setUnreadMessagesCount(mChatRoom->getUnreadMessagesCount());
int row = mEntries.count();
@ -1129,6 +1130,7 @@ void ChatRoomModel::insertMessageAtEnd (const std::shared_ptr<linphone::ChatMess
endInsertRows();
}
}
return model;
}
void ChatRoomModel::insertMessages (const QList<std::shared_ptr<linphone::ChatMessage> > &messages) {
@ -1275,8 +1277,11 @@ void ChatRoomModel::onNewEvent(const std::shared_ptr<linphone::ChatRoom> & chatR
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);
updateLastUpdateTime();
auto messageModel = insertMessageAtEnd(message);
if(messageModel){
messageModel->setTimestamp();
updateLastUpdateTime();
}
emit messageReceived(message);
}
}

View file

@ -252,7 +252,7 @@ public:
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);
std::shared_ptr<ChatMessageModel> 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);

View file

@ -38,13 +38,13 @@
// =============================================================================
ContentModel::ContentModel(ChatMessageModel* chatModel) : mAppData(""){
ContentModel::ContentModel(ChatMessageModel* chatModel) : mAppData(chatModel ? QString::fromStdString(chatModel->getChatMessage()->getAppdata()) : ""){
App::getInstance()->getEngine()->setObjectOwnership(this, QQmlEngine::CppOwnership);// Avoid QML to destroy it when passing by Q_INVOKABLE
mChatMessageModel = chatModel;
mWasDownloaded = false;
mFileOffset = 0;
}
ContentModel::ContentModel(std::shared_ptr<linphone::Content> content, ChatMessageModel* chatModel) : mAppData(""){
ContentModel::ContentModel(std::shared_ptr<linphone::Content> content, ChatMessageModel* chatModel) : mAppData(chatModel ? QString::fromStdString(chatModel->getChatMessage()->getAppdata()) : ""){
App::getInstance()->getEngine()->setObjectOwnership(this, QQmlEngine::CppOwnership);// Avoid QML to destroy it when passing by Q_INVOKABLE
mChatMessageModel = chatModel;
mWasDownloaded = false;

View file

@ -151,7 +151,7 @@ public:
#ifdef Q_PROCESSOR_X86_64
static constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/libopenh264-2.1.0-linux64.5.so.bz2";
#else
static constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/libopenh264-2.1-0-linux32.5.so.bz2";
static constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/libopenh264-2.1.0-linux32.5.so.bz2";
#endif // ifdef Q_PROCESSOR_X86_64
#elif defined(Q_OS_WIN)
static constexpr char LibraryExtension[] = "dll";

View file

@ -125,7 +125,7 @@ ColumnLayout {
Layout.topMargin: 15
Layout.preferredHeight: implicitHeight
Layout.alignment: Qt.AlignBottom
visible:chatRoomModel.isMeAdmin && !usernameEdit.visible
visible:chatRoomModel.isMeAdmin && !usernameEdit.visible && !chatRoomModel.isOneToOne
Icon{
id:adminIcon
@ -153,7 +153,7 @@ ColumnLayout {
visible: !usernameEdit.visible
contactDescriptionStyle: ConversationStyle.bar.contactDescription
username: avatar.username
usernameClickable: chatRoomModel.isMeAdmin
usernameClickable: chatRoomModel.isMeAdmin && !chatRoomModel.isOneToOne
participants: if(chatRoomModel) {
if(chatRoomModel.groupEnabled) {
return chatRoomModel.participants.displayNamesToString;
@ -187,7 +187,7 @@ ColumnLayout {
Item{
Layout.fillHeight: true
Layout.fillWidth: true
visible: chatRoomModel.isMeAdmin
visible: chatRoomModel.isMeAdmin && !chatRoomModel.isOneToOne
}
}
Icon{