diff --git a/src/ruqolacore/CMakeLists.txt b/src/ruqolacore/CMakeLists.txt index d6001b8b..96828888 100644 --- a/src/ruqolacore/CMakeLists.txt +++ b/src/ruqolacore/CMakeLists.txt @@ -1,221 +1,220 @@ set(Ruqola_ddpapi_SRCS ddpapi/ddpclient.cpp ) set (Ruqola_model_core_srcs model/messagemodel.cpp model/roommodel.cpp model/roomfilterproxymodel.cpp model/usersforroommodel.cpp model/usersforroomfilterproxymodel.cpp model/usersmodel.cpp model/usercompleterfilterproxymodel.cpp model/usercompletermodel.cpp model/statusmodel.cpp model/filesforroommodel.cpp model/filesforroomfilterproxymodel.cpp model/searchchannelmodel.cpp model/searchchannelfilterproxymodel.cpp model/inputcompletermodel.cpp model/loginmethodmodel.cpp model/searchmessagemodel.cpp model/searchmessagefilterproxymodel.cpp model/rocketchataccountmodel.cpp model/rocketchataccountfilterproxymodel.cpp model/emoticonmodel.cpp model/notificationpreferencemodel.cpp model/mentionsmodel.cpp model/mentionsfilterproxymodel.cpp model/notificationdesktopdurationpreferencemodel.cpp model/notificationdesktopsoundpreferencemodel.cpp model/discussionsmodel.cpp model/discussionsfilterproxymodel.cpp model/threadsmodel.cpp model/threadsfilterproxymodel.cpp model/emoticoncategoriesmodel.cpp model/threadmessagemodel.cpp model/pinnedmessagemodel.cpp ) set(Ruqola_plugins_srcs plugins/pluginauthenticationinterface.cpp plugins/pluginauthentication.cpp ) set(Ruqola_aboutdata_srcs aboutdata/qmlaboutdata.cpp aboutdata/qmlaboutdataauthormodel.cpp ) set(Ruqola_emoticons_srcs emoticons/emoji.cpp emoticons/emojimanager.cpp emoticons/unicodeemoticon.cpp emoticons/unicodeemoticonparser.cpp ) set(Ruqola_messages_srcs messages/message.cpp messages/messageattachment.cpp messages/messageurl.cpp messages/messagestarred.cpp messages/reactions.cpp messages/reaction.cpp messages/messagepinned.cpp ) set(Ruqola_message_convertertextjob_SRCS convertertextjob/convertertextabstractjob.cpp convertertextjob/translatetextjob.cpp ) set (Ruqola_core_srcs ${Ruqola_message_convertertextjob_SRCS} ${Ruqola_emoticons_srcs} ${Ruqola_messages_srcs} ${Ruqola_model_core_srcs} ${Ruqola_plugins_srcs} ${Ruqola_aboutdata_srcs} ${Ruqola_ddpapi_SRCS} authenticationinfo.cpp room.cpp roomwrapper.cpp notificationoptionswrapper.cpp ruqola.cpp ruqolautils.cpp rocketchatbackend.cpp notification.cpp messagequeue.cpp rocketchatmessage.cpp typingnotification.cpp changetemporarystatus.cpp user.cpp utils.cpp clipboardproxy.cpp otr.cpp otrmanager.cpp abstractwebsocket.cpp ruqolawebsocket.cpp rocketchataccount.cpp rocketchataccountsettings.cpp ruqolalogger.cpp ruqolaregisterengine.cpp ruqolaserverconfig.cpp rocketchatcache.cpp texthighlighter.cpp textconverter.cpp loadrecenthistorymanager.cpp file.cpp channel.cpp inputtextmanager.cpp authenticationmanager.cpp searchmessage.cpp accountmanager.cpp managerdatapaths.cpp notificationoptions.cpp syntaxhighlightingmanager.cpp copyfilejob.cpp receivetypingnotificationmanager.cpp serverconfiginfo.cpp notificationpreferences.cpp mentions.cpp mention.cpp roles.cpp role.cpp avatarmanager.cpp discussion.cpp discussions.cpp thread.cpp threads.cpp emoticoncategory.cpp listmessages.cpp - threadmessage.cpp messagedownloadmanager.cpp fileattachments.cpp ) if (NOT WIN32) set(Ruqola_core_srcs ${Ruqola_core_srcs} unityservicemanager.cpp) endif() ecm_qt_declare_logging_category(Ruqola_core_srcs HEADER ruqola_debug.h IDENTIFIER RUQOLA_LOG CATEGORY_NAME org.kde.ruqola) ecm_qt_declare_logging_category(Ruqola_core_srcs HEADER ruqola_message_debug.h IDENTIFIER RUQOLA_MESSAGE_LOG CATEGORY_NAME org.kde.ruqola.message) ecm_qt_declare_logging_category(Ruqola_core_srcs HEADER ruqola_ddpapi_debug.h IDENTIFIER RUQOLA_DDPAPI_LOG CATEGORY_NAME org.kde.ruqola.ddpapi) ecm_qt_declare_logging_category(Ruqola_core_srcs HEADER ruqola_ddpapi_command_debug.h IDENTIFIER RUQOLA_DDPAPI_COMMAND_LOG CATEGORY_NAME org.kde.ruqola.ddpapi.command) ecm_qt_declare_logging_category(Ruqola_core_srcs HEADER ruqola_unknown_collectiontype_debug.h IDENTIFIER RUQOLA_UNKNOWN_COLLECTIONTYPE_LOG CATEGORY_NAME org.kde.ruqola.ddp.collectiontype) qt5_add_resources(libruqolacore_RSC ruqolacore.qrc) add_library(libruqolacore ${Ruqola_core_srcs} ${libruqolacore_RSC}) generate_export_header(libruqolacore BASE_NAME libruqolacore) target_link_libraries(libruqolacore Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Qml Qt5::Quick Qt5::WebSockets Qt5::Network Qt5::NetworkAuth KF5::CoreAddons KF5::I18n KF5::Notifications KF5::SyntaxHighlighting librocketchatrestapi-qt5 ) if (NOT WIN32) target_link_libraries(libruqolacore Qt5::DBus) endif() if (WIN32 OR APPLE) target_link_libraries(libruqolacore KF5::IconThemes) endif() if (Qt5Keychain_FOUND) target_link_libraries(libruqolacore qt5keychain) target_include_directories(libruqolacore PRIVATE ${QTKEYCHAIN_INCLUDE_DIRS}) endif() set_target_properties(libruqolacore PROPERTIES OUTPUT_NAME ruqolacore VERSION ${RUQOLA_LIB_VERSION} SOVERSION ${RUQOLA_LIB_SOVERSION} ) install(TARGETS libruqolacore ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP) diff --git a/src/ruqolacore/listmessages.cpp b/src/ruqolacore/listmessages.cpp index c3cf2aff..5bd169ce 100644 --- a/src/ruqolacore/listmessages.cpp +++ b/src/ruqolacore/listmessages.cpp @@ -1,109 +1,109 @@ /* Copyright (c) 2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "listmessages.h" #include "ruqola_debug.h" #include #include ListMessages::ListMessages() { } void ListMessages::parseMessages(const QJsonObject &threadsObj) { - mThreadMessagesCount = threadsObj[QStringLiteral("count")].toInt(); + mMessagesCount = threadsObj[QStringLiteral("count")].toInt(); mOffset = threadsObj[QStringLiteral("offset")].toInt(); mTotal = threadsObj[QStringLiteral("total")].toInt(); const QJsonArray threadsArray = threadsObj[QStringLiteral("messages")].toArray(); - mThreadMessages.clear(); - mThreadMessages.reserve(threadsArray.count()); + mListMessages.clear(); + mListMessages.reserve(threadsArray.count()); for (const QJsonValue ¤t : threadsArray) { if (current.type() == QJsonValue::Object) { const QJsonObject threadMessageObject = current.toObject(); - ThreadMessage m; + Message m; m.parseMessage(threadMessageObject, true); - mThreadMessages.append(m); + mListMessages.append(m); } else { qCWarning(RUQOLA_LOG) << "Problem when parsing thread" << current; } } } int ListMessages::offset() const { return mOffset; } void ListMessages::setOffset(int offset) { mOffset = offset; } int ListMessages::total() const { return mTotal; } void ListMessages::setTotal(int total) { mTotal = total; } -int ListMessages::threadMessagesCount() const +int ListMessages::messagesCount() const { - return mThreadMessagesCount; + return mMessagesCount; } -void ListMessages::setThreadMessagesCount(int threadMessagesCount) +void ListMessages::setMessagesCount(int count) { - mThreadMessagesCount = threadMessagesCount; + mMessagesCount = count; } bool ListMessages::isEmpty() const { - return mThreadMessages.isEmpty(); + return mListMessages.isEmpty(); } void ListMessages::clear() { - mThreadMessages.clear(); + mListMessages.clear(); } int ListMessages::count() const { - return mThreadMessages.count(); + return mListMessages.count(); } -ThreadMessage ListMessages::at(int index) const +Message ListMessages::at(int index) const { - return mThreadMessages.at(index); + return mListMessages.at(index); } QDebug operator <<(QDebug d, const ListMessages &t) { d << "total " << t.total(); d << "offset " << t.offset(); - d << "threadMessagesCount " << t.threadMessagesCount(); + d << "threadMessagesCount " << t.messagesCount(); for (int i = 0, total = t.count(); i < total; ++i) { d << t.at(i); } return d; } diff --git a/src/ruqolacore/listmessages.h b/src/ruqolacore/listmessages.h index b5cb7710..75f2f283 100644 --- a/src/ruqolacore/listmessages.h +++ b/src/ruqolacore/listmessages.h @@ -1,53 +1,53 @@ /* Copyright (c) 2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef THREADMESSAGES_H -#define THREADMESSAGES_H +#ifndef LISTMESSAGES_H +#define LISTMESSAGES_H #include "libruqola_private_export.h" -#include "threadmessage.h" +#include "messages/message.h" #include class LIBRUQOLACORE_TESTS_EXPORT ListMessages { public: ListMessages(); void parseMessages(const QJsonObject &threadsObj); Q_REQUIRED_RESULT int offset() const; void setOffset(int offset); Q_REQUIRED_RESULT int total() const; void setTotal(int total); - Q_REQUIRED_RESULT int threadMessagesCount() const; - void setThreadMessagesCount(int threadMessagesCount); + Q_REQUIRED_RESULT int messagesCount() const; + void setMessagesCount(int listMessagesCount); Q_REQUIRED_RESULT bool isEmpty() const; void clear(); Q_REQUIRED_RESULT int count() const; - Q_REQUIRED_RESULT ThreadMessage at(int index) const; + Q_REQUIRED_RESULT Message at(int index) const; private: - QVector mThreadMessages; - int mThreadMessagesCount = 0; + QVector mListMessages; + int mMessagesCount = 0; int mOffset = 0; int mTotal = 0; }; Q_DECLARE_METATYPE(ListMessages) LIBRUQOLACORE_EXPORT QDebug operator <<(QDebug d, const ListMessages &t); -#endif // THREADMESSAGES_H +#endif // LISTMESSAGES_H diff --git a/src/ruqolacore/threadmessage.cpp b/src/ruqolacore/threadmessage.cpp deleted file mode 100644 index c1e6bb9c..00000000 --- a/src/ruqolacore/threadmessage.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (c) 2019 Montel Laurent - - This library is free software; you can redistribute it and/or modify - it under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2 of the License or - ( at your option ) version 3 or, at the discretion of KDE e.V. - ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "threadmessage.h" - -ThreadMessage::ThreadMessage() -{ -} diff --git a/src/ruqolacore/threadmessage.h b/src/ruqolacore/threadmessage.h deleted file mode 100644 index 76655464..00000000 --- a/src/ruqolacore/threadmessage.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (c) 2019 Montel Laurent - - This library is free software; you can redistribute it and/or modify - it under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2 of the License or - ( at your option ) version 3 or, at the discretion of KDE e.V. - ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef THREADMESSAGE_H -#define THREADMESSAGE_H - -#include "libruqola_private_export.h" -#include "messages/message.h" -#include -class LIBRUQOLACORE_TESTS_EXPORT ThreadMessage : public Message -{ -public: - ThreadMessage(); -}; -Q_DECLARE_METATYPE(ThreadMessage) -Q_DECLARE_TYPEINFO(ThreadMessage, Q_MOVABLE_TYPE); - -#endif // THREADMESSAGE_H