From d9e0df16d9424b381711f491237abd018a74d467 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Mon, 20 Feb 2023 19:05:55 +0200 Subject: [PATCH 01/15] Fixup installing service --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index fbfd40f..8160f5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,11 @@ install(FILES data/org.nemomobile.qmlmessages.service DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/dbus-1/services) +install(FILES + data/glacier-messages.service + DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/user/) + + install(FILES data/glacier-messages.client DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/telepathy/clients) From abee0759f06cb7962c6606e7a7df6d3a5f073143 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Fri, 13 Oct 2023 14:47:41 +0000 Subject: [PATCH 02/15] Start move to qt6 --- CMakeLists.txt | 19 ++++-------- data/glacier-messages.client | 17 ---------- data/glacier-messages.service | 4 +-- ...sktop.Telepathy.Client.qmlmessages.service | 4 --- src/CMakeLists.txt | 10 +++--- src/qml/components/ChatTextInput.qml | 14 ++++----- .../components/ConversationListDelegate.qml | 10 +++--- src/qml/components/ConversationListWidget.qml | 13 +++----- src/qml/components/MessagesService.qml | 4 +-- src/qml/components/MessagesView.qml | 11 +++---- src/qml/components/TargetEditBox.qml | 9 +++--- src/qml/glacier-messages.qml | 31 +++---------------- src/qml/pages/ConversationListPage.qml | 10 +++--- src/qml/pages/ConversationPage.qml | 24 +++----------- 14 files changed, 52 insertions(+), 128 deletions(-) delete mode 100644 data/glacier-messages.client delete mode 100644 data/org.freedesktop.Telepathy.Client.qmlmessages.service diff --git a/CMakeLists.txt b/CMakeLists.txt index 8160f5c..3aae102 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,27 +1,27 @@ cmake_minimum_required(VERSION 3.6.0) project(glacier-messages - VERSION 0.1.2 + VERSION 0.3 DESCRIPTION "The Glacier messages") set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_INSTALL_PREFIX /usr) include(FeatureSummary) include(GNUInstallDirs) -set(QT_MIN_VERSION "5.12.0") -find_package(Qt5 COMPONENTS Gui Qml Quick DBus LinguistTools REQUIRED) -find_package(Glacier 0.8 COMPONENTS App REQUIRED) -find_package(Qt5QuickCompiler) +set(QT_MIN_VERSION "6.0.0") +find_package(Qt6 COMPONENTS Gui Qml Quick DBus LinguistTools REQUIRED) +find_package(Glacier 1.0 COMPONENTS App REQUIRED) add_subdirectory(src) # Translations file(GLOB TS_FILES translations/*.ts) -qt5_add_translation(QM_FILES ${TS_FILES}) +qt6_add_translation(QM_FILES ${TS_FILES}) add_custom_target(translations DEPENDS ${QM_FILES}) add_dependencies(glacier-messages translations) @@ -40,16 +40,9 @@ install(FILES ${SVG_FILES} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/glacier-messages/images) install(FILES - data/org.freedesktop.Telepathy.Client.qmlmessages.service data/org.nemomobile.qmlmessages.service DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/dbus-1/services) install(FILES data/glacier-messages.service DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/user/) - - -install(FILES - data/glacier-messages.client - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/telepathy/clients) - diff --git a/data/glacier-messages.client b/data/glacier-messages.client deleted file mode 100644 index 65aed65..0000000 --- a/data/glacier-messages.client +++ /dev/null @@ -1,17 +0,0 @@ -[org.freedesktop.Telepathy.Client] -Interfaces=org.freedesktop.Telepathy.Client.Handler;org.freedesktop.Telepathy.Client.Interface.Requests - -[org.freedesktop.Telepathy.Client.Handler] -BypassApproval=true - -[org.freedesktop.Telepathy.Client.Handler.HandlerChannelFilter 0] -org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.Text -org.freedesktop.Telepathy.Channel.TargetHandleType u=0 - -[org.freedesktop.Telepathy.Client.Handler.HandlerChannelFilter 1] -org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.Text -org.freedesktop.Telepathy.Channel.TargetHandleType u=1 - -[org.freedesktop.Telepathy.Client.Handler.HandlerChannelFilter 2] -org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.Text -org.freedesktop.Telepathy.Channel.TargetHandleType u=2 diff --git a/data/glacier-messages.service b/data/glacier-messages.service index 444c4a3..2cd6647 100644 --- a/data/glacier-messages.service +++ b/data/glacier-messages.service @@ -1,7 +1,7 @@ [Unit] Description=Glacier messaging application -Requires=dbus.socket mission-control-5.service lipstick.service -After=dbus.socket mission-control-5.service lipstick.service +Requires=dbus.socket lipstick.service +After=dbus.socket lipstick.service [Service] Type=dbus diff --git a/data/org.freedesktop.Telepathy.Client.qmlmessages.service b/data/org.freedesktop.Telepathy.Client.qmlmessages.service deleted file mode 100644 index 4d46286..0000000 --- a/data/org.freedesktop.Telepathy.Client.qmlmessages.service +++ /dev/null @@ -1,4 +0,0 @@ -[D-BUS Service] -Name=org.freedesktop.Telepathy.Client.qmlmessages -Exec=/usr/bin/false -SystemdService=glacier-messages.service diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6982589..6d127b6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,15 +2,15 @@ set(SRC main.cpp ) -qtquick_compiler_add_resources(RESOURCES qml/glacier-messages.qrc) +qt_add_resources(RESOURCES qml/glacier-messages.qrc) add_executable(glacier-messages ${SRC} ${RESOURCES}) target_link_libraries(glacier-messages - Qt5::Gui - Qt5::Qml - Qt5::Quick - Qt5::DBus + Qt6::Gui + Qt6::Qml + Qt6::Quick + Qt6::DBus Glacier::App) install(TARGETS glacier-messages RUNTIME diff --git a/src/qml/components/ChatTextInput.qml b/src/qml/components/ChatTextInput.qml index 3798a07..d98f952 100644 --- a/src/qml/components/ChatTextInput.qml +++ b/src/qml/components/ChatTextInput.qml @@ -30,13 +30,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import QtQuick 2.6 +import QtQuick +import QtQuick.Controls -import QtQuick.Controls 1.0 -import QtQuick.Controls.Nemo 1.0 -import QtQuick.Controls.Styles.Nemo 1.0 - -import QtQuick.Controls.Styles 1.4 +import Nemo +import Nemo.Controls Item { id: textArea @@ -86,14 +84,14 @@ Item { visible: (!textInput.focus && !inputFocusScope.focus) || textInput.text.lenght == 0 } - style: TextAreaStyle { + /*style: TextAreaStyle { backgroundColor: Theme.fillDarkColor font.pixelSize: Theme.fontSizeMedium font.family: Theme.fontFamily textColor: Theme.textColor selectedTextColor: Theme.textColor selectionColor: Theme.accentColor - } + }*/ } } diff --git a/src/qml/components/ConversationListDelegate.qml b/src/qml/components/ConversationListDelegate.qml index 7188883..728b43b 100644 --- a/src/qml/components/ConversationListDelegate.qml +++ b/src/qml/components/ConversationListDelegate.qml @@ -30,13 +30,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import QtQuick 2.6 +import QtQuick +import QtQuick.Controls -import QtQuick.Controls 1.0 -import QtQuick.Controls.Nemo 1.0 -import QtQuick.Controls.Styles.Nemo 1.0 - -import org.nemomobile.qmlcontacts 1.0 +import Nemo +import Nemo.Controls ListViewItemWithActions { id: converstationListDelegate diff --git a/src/qml/components/ConversationListWidget.qml b/src/qml/components/ConversationListWidget.qml index a3449d5..e3d5f52 100644 --- a/src/qml/components/ConversationListWidget.qml +++ b/src/qml/components/ConversationListWidget.qml @@ -29,14 +29,11 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import QtQuick +import QtQuick.Controls -import QtQuick 2.6 - -import QtQuick.Controls 1.0 -import QtQuick.Controls.Nemo 1.0 -import QtQuick.Controls.Styles.Nemo 1.0 - -import org.nemomobile.messages.internal 1.0 +import Nemo +import Nemo.Controls Item { Label{ @@ -53,7 +50,7 @@ Item { focus: true keyNavigationWraps: false clip: true - model: groupModel +// model: groupModel delegate: ConversationListDelegate { onClicked: { diff --git a/src/qml/components/MessagesService.qml b/src/qml/components/MessagesService.qml index 081225a..75ce8c7 100644 --- a/src/qml/components/MessagesService.qml +++ b/src/qml/components/MessagesService.qml @@ -1,5 +1,5 @@ -import QtQuick 2.6 -import Nemo.DBus 2.0 +import QtQuick +import Nemo.DBus Item { id: rootObject diff --git a/src/qml/components/MessagesView.qml b/src/qml/components/MessagesView.qml index 64024e1..2a7ac59 100644 --- a/src/qml/components/MessagesView.qml +++ b/src/qml/components/MessagesView.qml @@ -29,14 +29,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import QtQuick 2.6 +import QtQuick +import QtQuick.Controls -import QtQuick.Controls 1.0 -import QtQuick.Controls.Nemo 1.0 -import QtQuick.Controls.Styles.Nemo 1.0 - -import org.nemomobile.messages.internal 1.0 -import org.nemomobile.commhistory 1.0 +import Nemo +import Nemo.Controls Item { property alias model: view.model diff --git a/src/qml/components/TargetEditBox.qml b/src/qml/components/TargetEditBox.qml index c51c6c3..319c025 100644 --- a/src/qml/components/TargetEditBox.qml +++ b/src/qml/components/TargetEditBox.qml @@ -28,12 +28,11 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import QtQuick +import QtQuick.Controls -import QtQuick 2.6 - -import QtQuick.Controls 1.0 -import QtQuick.Controls.Nemo 1.0 -import QtQuick.Controls.Styles.Nemo 1.0 +import Nemo +import Nemo.Controls Item { id: targetEdirBox diff --git a/src/qml/glacier-messages.qml b/src/qml/glacier-messages.qml index 6003be2..a4ef48b 100644 --- a/src/qml/glacier-messages.qml +++ b/src/qml/glacier-messages.qml @@ -30,15 +30,14 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import QtQuick 2.6 +import QtQuick +import QtQuick.Controls +import QtQuick.Window -import QtQuick.Controls 1.0 -import QtQuick.Controls.Nemo 1.0 -import QtQuick.Controls.Styles.Nemo 1.0 +import Nemo +import Nemo.Controls -import org.nemomobile.messages.internal 1.0 import org.nemomobile.contacts 1.0 -import org.nemomobile.commhistory 1.0 import "components" import "pages" @@ -46,30 +45,10 @@ import "pages" ApplicationWindow { id: app - // Shared AccountsModel - TelepathyAccountsModel { - id: accountsModel - } - PeopleModel { id: peopleModel } - TelepathyChannelManager { - id: channelManager - handlerName: "qmlmessages" - } - - CommGroupManager { - id: groupManager - useBackgroundThread: true - } - - CommGroupModel { - id: groupModel - manager: groupManager - } - MessagesService{ id: messageService diff --git a/src/qml/pages/ConversationListPage.qml b/src/qml/pages/ConversationListPage.qml index 9d99077..fb445b6 100644 --- a/src/qml/pages/ConversationListPage.qml +++ b/src/qml/pages/ConversationListPage.qml @@ -30,11 +30,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import QtQuick 2.6 +import QtQuick +import QtQuick.Controls -import QtQuick.Controls 1.0 -import QtQuick.Controls.Nemo 1.0 -import QtQuick.Controls.Styles.Nemo 1.0 +import Nemo +import Nemo.Controls import "../components" @@ -47,7 +47,7 @@ Page { ToolButton{ iconSource: "image://theme/user-plus" onClicked: { - pageStack.push(Qt.resolvedUrl("../pages/ConversationPage.qml"), {add : true}); + app.push(Qt.resolvedUrl("../pages/ConversationPage.qml"), {add : true}); } } ] diff --git a/src/qml/pages/ConversationPage.qml b/src/qml/pages/ConversationPage.qml index d5e90e2..1215aa8 100644 --- a/src/qml/pages/ConversationPage.qml +++ b/src/qml/pages/ConversationPage.qml @@ -30,17 +30,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import QtQuick 2.6 - -import QtQuick.Controls 1.0 -import QtQuick.Controls.Nemo 1.0 -import QtQuick.Controls.Styles.Nemo 1.0 - -import org.nemomobile.messages.internal 1.0 -import org.nemomobile.qmlcontacts 1.0 -import org.nemomobile.commhistory 1.0 -import org.nemomobile.voicecall 1.0 +import QtQuick +import QtQuick.Controls +import Nemo +import Nemo.Controls import "../components" @@ -77,10 +71,6 @@ Page { markAsRead() } - VoiceCallManager { - id:callManager - } - TextField { id: targetEditor visible: !channel @@ -99,12 +89,6 @@ Page { } - CommConversationModel { - id: conversationModel - useBackgroundThread: true - groupId: group ? group.id : -1 - } - MessagesView { id: messagesView anchors { From 34def0dd1452184ac1403ad0a0001433f761c593 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Fri, 13 Oct 2023 15:05:13 +0000 Subject: [PATCH 03/15] Add qml debug option --- CMakeLists.txt | 2 ++ src/CMakeLists.txt | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3aae102..d8e50b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,8 @@ set(CMAKE_INSTALL_PREFIX /usr) include(FeatureSummary) include(GNUInstallDirs) +option(QML_DEBUG "Don't pack QML into binary for debug and develop" OFF) + set(QT_MIN_VERSION "6.0.0") find_package(Qt6 COMPONENTS Gui Qml Quick DBus LinguistTools REQUIRED) find_package(Glacier 1.0 COMPONENTS App REQUIRED) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6d127b6..c7f86dd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,7 +2,9 @@ set(SRC main.cpp ) +if(!QML_DEBUG) qt_add_resources(RESOURCES qml/glacier-messages.qrc) +endif() add_executable(glacier-messages ${SRC} ${RESOURCES}) @@ -15,3 +17,8 @@ target_link_libraries(glacier-messages install(TARGETS glacier-messages RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +if(QML_DEBUG) +install(DIRECTORY qml + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/glacier-messages) +endif() From 348e356fe002c59f0d55faada4db6af8781a86e7 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Sat, 14 Oct 2023 15:24:48 +0000 Subject: [PATCH 04/15] Add messaged proto --- CMakeLists.txt | 5 +++++ daemon/CMakeLists.txt | 15 +++++++++++++ daemon/main.cpp | 43 ++++++++++++++++++++++++++++++++++++++ daemon/messageshandler.cpp | 38 +++++++++++++++++++++++++++++++++ daemon/messageshandler.h | 23 ++++++++++++++++++++ 5 files changed, 124 insertions(+) create mode 100644 daemon/CMakeLists.txt create mode 100644 daemon/main.cpp create mode 100644 daemon/messageshandler.cpp create mode 100644 daemon/messageshandler.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d8e50b5..b1ada56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,12 @@ set(QT_MIN_VERSION "6.0.0") find_package(Qt6 COMPONENTS Gui Qml Quick DBus LinguistTools REQUIRED) find_package(Glacier 1.0 COMPONENTS App REQUIRED) +find_package(PkgConfig REQUIRED) +pkg_check_modules(QOFONO qofono-qt6 REQUIRED IMPORTED_TARGET) +pkg_check_modules(NEMONOTIFICATIONS nemonotifications-qt6 REQUIRED IMPORTED_TARGET) + add_subdirectory(src) +add_subdirectory(daemon) # Translations file(GLOB TS_FILES translations/*.ts) diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt new file mode 100644 index 0000000..e11b170 --- /dev/null +++ b/daemon/CMakeLists.txt @@ -0,0 +1,15 @@ +set(SRC main.cpp + messageshandler.cpp) + +set(HEADERS messageshandler.h) + +add_executable(messagesd ${SRC} ${HEADERS}) + +target_link_libraries(messagesd + Qt6::Core + Qt6::DBus + PkgConfig::QOFONO + PkgConfig::NEMONOTIFICATIONS) + +install(TARGETS messagesd RUNTIME + DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/daemon/main.cpp b/daemon/main.cpp new file mode 100644 index 0000000..d2a75da --- /dev/null +++ b/daemon/main.cpp @@ -0,0 +1,43 @@ +/* Copyright (C) 2023 Chupligin Sergey + * + * You may use this file under the terms of the BSD license as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Nemo Mobile nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "messageshandler.h" + +int main(int argc, char** argv) +{ + QCoreApplication* app = QCoreApplication::instance(); + app->setOrganizationName("NemoMobile"); + app->setApplicationName("messaged"); + + MessagesHandler messageHandler; + + return app->exec(); +} diff --git a/daemon/messageshandler.cpp b/daemon/messageshandler.cpp new file mode 100644 index 0000000..f267d79 --- /dev/null +++ b/daemon/messageshandler.cpp @@ -0,0 +1,38 @@ +#include "messageshandler.h" +#include + +MessagesHandler::MessagesHandler(QObject *parent) + : QObject(parent) + , m_ofonoManager(new QOfonoManager(this)) +{ + connect(m_ofonoManager, &QOfonoManager::modemsChanged, this, &MessagesHandler::onModemsChanged); +} + +void MessagesHandler::onModemsChanged(const QStringList &modems) +{ + foreach (QOfonoMessageManager* manager, m_messageManagers) { + manager->disconnect(); + } + m_messageManagers.clear(); + + foreach (QString modem, modems) { + QOfonoMessageManager* manager = new QOfonoMessageManager(this); + manager->setModemPath(modem); + connect(manager, &QOfonoMessageManager::incomingMessage, this, &MessagesHandler::onIncomingMessage); + } +} + +void MessagesHandler::onIncomingMessage(const QString &message, const QVariantMap &info) +{ + qDebug() << message; + qDebug() << info; + + Notification newMessageNotification; + newMessageNotification.setAppName(tr("Messages")); + newMessageNotification.setSummary(info.key("Sender")); + newMessageNotification.setBody(message); + newMessageNotification.setIcon("/usr/share/glacier-messages/glacier-messages.png"); + newMessageNotification.setUrgency(Notification::Urgency::Normal); + + newMessageNotification.publish(); +} diff --git a/daemon/messageshandler.h b/daemon/messageshandler.h new file mode 100644 index 0000000..3da3598 --- /dev/null +++ b/daemon/messageshandler.h @@ -0,0 +1,23 @@ +#ifndef MESSAGESHANDLER_H +#define MESSAGESHANDLER_H + +#include +#include +#include + +class MessagesHandler : public QObject +{ + Q_OBJECT +public: + explicit MessagesHandler(QObject *parent = nullptr); + +private slots: + void onModemsChanged(const QStringList &modems); + void onIncomingMessage(const QString &message, const QVariantMap &info); + +private: + QOfonoManager* m_ofonoManager; + QList m_messageManagers; +}; + +#endif // MESSAGESHANDLER_H From 39b5ec388d3593c0451a8d120ed2cd7eb41cc127 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Sat, 14 Oct 2023 15:25:51 +0000 Subject: [PATCH 05/15] Return commhistory stuff --- src/qml/components/ConversationListWidget.qml | 2 +- src/qml/glacier-messages.qml | 13 +++++++++++++ src/qml/pages/ConversationPage.qml | 8 ++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/qml/components/ConversationListWidget.qml b/src/qml/components/ConversationListWidget.qml index e3d5f52..beff9fc 100644 --- a/src/qml/components/ConversationListWidget.qml +++ b/src/qml/components/ConversationListWidget.qml @@ -50,7 +50,7 @@ Item { focus: true keyNavigationWraps: false clip: true -// model: groupModel + model: groupModel delegate: ConversationListDelegate { onClicked: { diff --git a/src/qml/glacier-messages.qml b/src/qml/glacier-messages.qml index a4ef48b..6ab8237 100644 --- a/src/qml/glacier-messages.qml +++ b/src/qml/glacier-messages.qml @@ -37,7 +37,10 @@ import QtQuick.Window import Nemo import Nemo.Controls +import QOfono + import org.nemomobile.contacts 1.0 +import org.nemomobile.commhistory 1.0 import "components" import "pages" @@ -45,6 +48,16 @@ import "pages" ApplicationWindow { id: app + CommGroupModel { + id: groupModel + manager: groupManager + } + + CommGroupManager { + id: groupManager + useBackgroundThread: true + } + PeopleModel { id: peopleModel } diff --git a/src/qml/pages/ConversationPage.qml b/src/qml/pages/ConversationPage.qml index 1215aa8..c062834 100644 --- a/src/qml/pages/ConversationPage.qml +++ b/src/qml/pages/ConversationPage.qml @@ -36,6 +36,8 @@ import QtQuick.Controls import Nemo import Nemo.Controls +import org.nemomobile.commhistory 1.0 + import "../components" /* ConversationPage has two states, depending on if it has an active @@ -89,6 +91,12 @@ Page { } + CommConversationModel { + id: conversationModel + useBackgroundThread: true + groupId: group ? group.id : -1 + } + MessagesView { id: messagesView anchors { From 16fbb966452c65dba438e55f42f9dac175309977 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Sun, 15 Oct 2023 16:53:55 +0000 Subject: [PATCH 06/15] Add commhistory event handler --- CMakeLists.txt | 1 + daemon/CMakeLists.txt | 3 ++- daemon/messageshandler.cpp | 17 ++++++++++++++--- daemon/messageshandler.h | 4 ++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1ada56..0b0e151 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ find_package(Glacier 1.0 COMPONENTS App REQUIRED) find_package(PkgConfig REQUIRED) pkg_check_modules(QOFONO qofono-qt6 REQUIRED IMPORTED_TARGET) pkg_check_modules(NEMONOTIFICATIONS nemonotifications-qt6 REQUIRED IMPORTED_TARGET) +pkg_check_modules(COMMHISTORY commhistory-qt6 REQUIRED IMPORTED_TARGET) add_subdirectory(src) add_subdirectory(daemon) diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt index e11b170..d4d3c0f 100644 --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -9,7 +9,8 @@ target_link_libraries(messagesd Qt6::Core Qt6::DBus PkgConfig::QOFONO - PkgConfig::NEMONOTIFICATIONS) + PkgConfig::NEMONOTIFICATIONS + PkgConfig::COMMHISTORY) install(TARGETS messagesd RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/daemon/messageshandler.cpp b/daemon/messageshandler.cpp index f267d79..0efeec7 100644 --- a/daemon/messageshandler.cpp +++ b/daemon/messageshandler.cpp @@ -1,9 +1,12 @@ +#include + #include "messageshandler.h" #include MessagesHandler::MessagesHandler(QObject *parent) : QObject(parent) , m_ofonoManager(new QOfonoManager(this)) + , m_commhistoryEventModel(new CommHistory::EventModel(this)) { connect(m_ofonoManager, &QOfonoManager::modemsChanged, this, &MessagesHandler::onModemsChanged); } @@ -24,8 +27,12 @@ void MessagesHandler::onModemsChanged(const QStringList &modems) void MessagesHandler::onIncomingMessage(const QString &message, const QVariantMap &info) { - qDebug() << message; - qDebug() << info; + CommHistory::Event event; + event.setType(CommHistory::Event::SMSEvent); + event.setIsRead(false); + event.setDirection(CommHistory::Event::Inbound); + event.setFreeText(message.trimmed()); + event.setStartTime(info.value("SentTime").toDateTime()); Notification newMessageNotification; newMessageNotification.setAppName(tr("Messages")); @@ -34,5 +41,9 @@ void MessagesHandler::onIncomingMessage(const QString &message, const QVariantMa newMessageNotification.setIcon("/usr/share/glacier-messages/glacier-messages.png"); newMessageNotification.setUrgency(Notification::Urgency::Normal); - newMessageNotification.publish(); + if(m_commhistoryEventModel->addEvent(event)) { + newMessageNotification.publish(); + } else { + qWarning() << "Can`t save event"; + } } diff --git a/daemon/messageshandler.h b/daemon/messageshandler.h index 3da3598..74bcc31 100644 --- a/daemon/messageshandler.h +++ b/daemon/messageshandler.h @@ -5,6 +5,9 @@ #include #include +#include +#include + class MessagesHandler : public QObject { Q_OBJECT @@ -18,6 +21,7 @@ private slots: private: QOfonoManager* m_ofonoManager; QList m_messageManagers; + CommHistory::EventModel* m_commhistoryEventModel; }; #endif // MESSAGESHANDLER_H From e191c79d1a17c80ea9e615bba18fd43a0138b3f4 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Mon, 16 Oct 2023 11:04:27 +0000 Subject: [PATCH 07/15] Fixup daemon start --- daemon/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/main.cpp b/daemon/main.cpp index d2a75da..5bd47a6 100644 --- a/daemon/main.cpp +++ b/daemon/main.cpp @@ -33,7 +33,7 @@ int main(int argc, char** argv) { - QCoreApplication* app = QCoreApplication::instance(); + QCoreApplication* app = new QCoreApplication(argc, argv); app->setOrganizationName("NemoMobile"); app->setApplicationName("messaged"); From b1773fa221e786ab2441ddba931185e04521af23 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Mon, 16 Oct 2023 11:08:28 +0000 Subject: [PATCH 08/15] Fixup codestyle --- daemon/main.cpp | 2 +- daemon/messageshandler.cpp | 18 +++++++++++------- daemon/messageshandler.h | 9 ++++----- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/daemon/main.cpp b/daemon/main.cpp index 5bd47a6..c94e1ac 100644 --- a/daemon/main.cpp +++ b/daemon/main.cpp @@ -28,8 +28,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include "messageshandler.h" +#include int main(int argc, char** argv) { diff --git a/daemon/messageshandler.cpp b/daemon/messageshandler.cpp index 0efeec7..0e15d67 100644 --- a/daemon/messageshandler.cpp +++ b/daemon/messageshandler.cpp @@ -3,15 +3,16 @@ #include "messageshandler.h" #include -MessagesHandler::MessagesHandler(QObject *parent) +MessagesHandler::MessagesHandler(QObject* parent) : QObject(parent) , m_ofonoManager(new QOfonoManager(this)) , m_commhistoryEventModel(new CommHistory::EventModel(this)) { - connect(m_ofonoManager, &QOfonoManager::modemsChanged, this, &MessagesHandler::onModemsChanged); + connect(m_ofonoManager, &QOfonoManager::modemsChanged, this, + &MessagesHandler::onModemsChanged); } -void MessagesHandler::onModemsChanged(const QStringList &modems) +void MessagesHandler::onModemsChanged(const QStringList& modems) { foreach (QOfonoMessageManager* manager, m_messageManagers) { manager->disconnect(); @@ -21,11 +22,13 @@ void MessagesHandler::onModemsChanged(const QStringList &modems) foreach (QString modem, modems) { QOfonoMessageManager* manager = new QOfonoMessageManager(this); manager->setModemPath(modem); - connect(manager, &QOfonoMessageManager::incomingMessage, this, &MessagesHandler::onIncomingMessage); + connect(manager, &QOfonoMessageManager::incomingMessage, this, + &MessagesHandler::onIncomingMessage); } } -void MessagesHandler::onIncomingMessage(const QString &message, const QVariantMap &info) +void MessagesHandler::onIncomingMessage(const QString& message, + const QVariantMap& info) { CommHistory::Event event; event.setType(CommHistory::Event::SMSEvent); @@ -38,10 +41,11 @@ void MessagesHandler::onIncomingMessage(const QString &message, const QVariantMa newMessageNotification.setAppName(tr("Messages")); newMessageNotification.setSummary(info.key("Sender")); newMessageNotification.setBody(message); - newMessageNotification.setIcon("/usr/share/glacier-messages/glacier-messages.png"); + newMessageNotification.setIcon( + "/usr/share/glacier-messages/glacier-messages.png"); newMessageNotification.setUrgency(Notification::Urgency::Normal); - if(m_commhistoryEventModel->addEvent(event)) { + if (m_commhistoryEventModel->addEvent(event)) { newMessageNotification.publish(); } else { qWarning() << "Can`t save event"; diff --git a/daemon/messageshandler.h b/daemon/messageshandler.h index 74bcc31..f9f6232 100644 --- a/daemon/messageshandler.h +++ b/daemon/messageshandler.h @@ -8,15 +8,14 @@ #include #include -class MessagesHandler : public QObject -{ +class MessagesHandler : public QObject { Q_OBJECT public: - explicit MessagesHandler(QObject *parent = nullptr); + explicit MessagesHandler(QObject* parent = nullptr); private slots: - void onModemsChanged(const QStringList &modems); - void onIncomingMessage(const QString &message, const QVariantMap &info); + void onModemsChanged(const QStringList& modems); + void onIncomingMessage(const QString& message, const QVariantMap& info); private: QOfonoManager* m_ofonoManager; From 56d176bd4a61ee2161311ec38a67aa9e5fa1ece1 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Mon, 16 Oct 2023 13:52:34 +0000 Subject: [PATCH 09/15] Fixup getting groupID --- daemon/messageshandler.cpp | 45 +++++++++++++++++++++++++++++++++++--- daemon/messageshandler.h | 7 ++++++ 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/daemon/messageshandler.cpp b/daemon/messageshandler.cpp index 0e15d67..8bfc577 100644 --- a/daemon/messageshandler.cpp +++ b/daemon/messageshandler.cpp @@ -7,7 +7,14 @@ MessagesHandler::MessagesHandler(QObject* parent) : QObject(parent) , m_ofonoManager(new QOfonoManager(this)) , m_commhistoryEventModel(new CommHistory::EventModel(this)) + , m_groupModel(new CommHistory::GroupModel(this)) { + qDebug() << Q_FUNC_INFO; + + m_groupModel->setResolveContacts(CommHistory::GroupManager::DoNotResolve); + if (!m_groupModel->getGroups()) { + qFatal() << "Can't load CommHistory::GroupModel"; + } connect(m_ofonoManager, &QOfonoManager::modemsChanged, this, &MessagesHandler::onModemsChanged); } @@ -27,19 +34,51 @@ void MessagesHandler::onModemsChanged(const QStringList& modems) } } -void MessagesHandler::onIncomingMessage(const QString& message, - const QVariantMap& info) +int MessagesHandler::getGroupId(QString sender) { + CommHistory::Recipient recipient(LOCAL_UID, sender); + for (int i = 0; i < m_groupModel->rowCount(); i++) { + CommHistory::Group group = m_groupModel->group(m_groupModel->index(i, 0)); + if (group.recipients().first() == recipient) { + qDebug() << "GROUP ID is " << group.id(); + return group.id(); + } + } + + CommHistory::Group group; + group.setLocalUid(LOCAL_UID); + group.setRecipients(recipient); + group.setChatType(CommHistory::Group::ChatTypeP2P); + group.setChatName(sender); + + if (m_groupModel->addGroup(group)) { + qDebug() << "New GROUP ID is " << group.id(); + return group.id(); + } + + return -1; +} + +void MessagesHandler::onIncomingMessage(const QString& message, const QVariantMap& info) +{ + QString sender = info.key("Sender"); + + int groupId = getGroupId(sender); + if (groupId < 0) { + return; + } + CommHistory::Event event; event.setType(CommHistory::Event::SMSEvent); event.setIsRead(false); event.setDirection(CommHistory::Event::Inbound); event.setFreeText(message.trimmed()); event.setStartTime(info.value("SentTime").toDateTime()); + event.setGroupId(groupId); Notification newMessageNotification; newMessageNotification.setAppName(tr("Messages")); - newMessageNotification.setSummary(info.key("Sender")); + newMessageNotification.setSummary(sender); newMessageNotification.setBody(message); newMessageNotification.setIcon( "/usr/share/glacier-messages/glacier-messages.png"); diff --git a/daemon/messageshandler.h b/daemon/messageshandler.h index f9f6232..80ab9e8 100644 --- a/daemon/messageshandler.h +++ b/daemon/messageshandler.h @@ -7,6 +7,10 @@ #include #include +#include +#include + +static QString LOCAL_UID = "/org/glacier/messagesd"; class MessagesHandler : public QObject { Q_OBJECT @@ -18,9 +22,12 @@ private slots: void onIncomingMessage(const QString& message, const QVariantMap& info); private: + int getGroupId(QString sender); + QOfonoManager* m_ofonoManager; QList m_messageManagers; CommHistory::EventModel* m_commhistoryEventModel; + CommHistory::GroupModel* m_groupModel; }; #endif // MESSAGESHANDLER_H From eeab9aa3677659d3175413d03b53d0c43e5c26d0 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Mon, 16 Oct 2023 13:52:56 +0000 Subject: [PATCH 10/15] Cleanup QML --- .../components/ConversationListDelegate.qml | 2 +- src/qml/components/ConversationListWidget.qml | 6 +-- src/qml/components/MessagesView.qml | 8 ++-- src/qml/glacier-messages.qml | 17 +++++++ src/qml/pages/ConversationPage.qml | 47 ++----------------- 5 files changed, 30 insertions(+), 50 deletions(-) diff --git a/src/qml/components/ConversationListDelegate.qml b/src/qml/components/ConversationListDelegate.qml index 728b43b..eb532d1 100644 --- a/src/qml/components/ConversationListDelegate.qml +++ b/src/qml/components/ConversationListDelegate.qml @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021 Chupligin Serhey +/* Copyright (C) 2018-2023 Chupligin Serhey * Copyright (C) 2012 John Brooks * Copyright (C) 2011 Robin Burchell * diff --git a/src/qml/components/ConversationListWidget.qml b/src/qml/components/ConversationListWidget.qml index beff9fc..e438efc 100644 --- a/src/qml/components/ConversationListWidget.qml +++ b/src/qml/components/ConversationListWidget.qml @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Chupligin Serhey +/* Copyright (C) 2018-2023 Chupligin Serhey * Copyright (C) 2012 John Brooks * Copyright (C) 2011 Robin Burchell * @@ -54,9 +54,7 @@ Item { delegate: ConversationListDelegate { onClicked: { - var group = model.group - var channel = channelManager.getConversation(group.localUid, group.remoteUids[0]) - pageStack.push(Qt.resolvedUrl("../pages/ConversationPage.qml"), { "channel": channel, "group": group }) + app.push(Qt.resolvedUrl("../pages/ConversationPage.qml"), { "group": model.group }) } } diff --git a/src/qml/components/MessagesView.qml b/src/qml/components/MessagesView.qml index 2a7ac59..ae9bc60 100644 --- a/src/qml/components/MessagesView.qml +++ b/src/qml/components/MessagesView.qml @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021 Chupligin Sergey +/* Copyright (C) 2018-2023 Chupligin Sergey * Copyright (C) 2012 John Brooks * * You may use this file under the terms of the BSD license as follows: @@ -35,6 +35,8 @@ import QtQuick.Controls import Nemo import Nemo.Controls +import org.nemomobile.commhistory 1.0 + Item { property alias model: view.model // The event model is in descending order, but we need to display ascending. @@ -51,12 +53,12 @@ Item { Connections { target: model || null - onRowsInserted: { + function onRowsInserted(first, last) { if (first === 0) { view.positionViewAtBeginning() } } - onModelReset: view.positionViewAtBeginning() + function onModelReset() { view.positionViewAtBeginning() } } delegate: Item{ diff --git a/src/qml/glacier-messages.qml b/src/qml/glacier-messages.qml index 6ab8237..a211c28 100644 --- a/src/qml/glacier-messages.qml +++ b/src/qml/glacier-messages.qml @@ -58,6 +58,23 @@ ApplicationWindow { useBackgroundThread: true } + OfonoManager { + id: manager + } + + OfonoMessageManager{ + id: messageManager + modemPath: manager.defaultModem + onMessageAdded: { + console.log("HELLO MESSAGE") + console.log(message) + } + + Component.onCompleted: { + messageManager.sendMessage("+79962491221", "Hello nemo") + } + } + PeopleModel { id: peopleModel } diff --git a/src/qml/pages/ConversationPage.qml b/src/qml/pages/ConversationPage.qml index c062834..2c7fb3e 100644 --- a/src/qml/pages/ConversationPage.qml +++ b/src/qml/pages/ConversationPage.qml @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021 Chupligin Sergey +/* Copyright (C) 2018-2023 Chupligin Sergey * Copyright (C) 2012 John Brooks * Copyright (C) 2011 Robin Burchell * @@ -47,7 +47,6 @@ import "../components" Page { id: conversationPage - property QtObject channel: null property QtObject group property QtObject person: group ? peopleModel.personById(group.contactId) : null property string remoteUid: "" @@ -75,7 +74,6 @@ Page { TextField { id: targetEditor - visible: !channel width: parent.width-Theme.itemSpacingLarge*2 height: Theme.itemHeightExtraLarge-Theme.itemSpacingLarge*2 @@ -119,50 +117,20 @@ Page { width: parent.width onSendMessage: { - if (text.length < 1 && (!channel && targetEditor.length < 1)) { + if (text.length < 1 && (targetEditor.length < 1)) { return } - if(!channel) { - channel = channelManager.getConversation(accountsModel.get(0, TelepathyAccountsModel.AccountUidRole),targetEditor.text) - hTools.title = targetEditor.text - } - - groupManager.createOutgoingMessageEvent(group.id, channel.localUid, group.remoteUids[0], text, function(eventId) { + groupManager.createOutgoingMessageEvent(group.id, group.localUid, group.remoteUids[0], text, function(eventId) { console.log("groupId" + group.id) - console.log("channel.localUid" + channel.localUid) + console.log("group.localUid" + group.localUid) console.log("group.remoteUids[0]" + group.remoteUids[0]) console.log("eventId" + eventId) - channel.sendMessage(text, eventId) }) clear() } } - states: [ - State { - name: "new" - when: channel == null - - PropertyChanges { - target: targetEditor - visible: true - } - - AnchorChanges { - target: messagesView - anchors.top: targetEditor.bottom - } - } - ] - - onChannelChanged: { - if (channel != null) { - channel.ensureChannel() - _updateGroup() - } - } - Connections { target: groupManager @@ -170,14 +138,9 @@ Page { function onGroupUpdated() { _updateGroup() } } - Connections { - target: Qt.application - onActiveChanged: markAsRead() - } - function _updateGroup() { if (group === null) - group = groupManager.findGroup(channel.localUid, channel.remoteUid) + group = groupManager.findGroup(group.localUid, group.remoteUid) } function markAsRead() { From 9329387b39f3f0ab692c62d120c12b2794771b09 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Tue, 17 Oct 2023 14:33:40 +0000 Subject: [PATCH 11/15] Fixup notification actions --- daemon/CMakeLists.txt | 3 ++- daemon/constants.h | 10 ++++++++++ daemon/messageshandler.cpp | 33 ++++++++++++++++++++++++--------- daemon/messageshandler.h | 2 -- 4 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 daemon/constants.h diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt index d4d3c0f..e3ce15c 100644 --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -1,7 +1,8 @@ set(SRC main.cpp messageshandler.cpp) -set(HEADERS messageshandler.h) +set(HEADERS messageshandler.h + constants.h) add_executable(messagesd ${SRC} ${HEADERS}) diff --git a/daemon/constants.h b/daemon/constants.h new file mode 100644 index 0000000..54e7e8d --- /dev/null +++ b/daemon/constants.h @@ -0,0 +1,10 @@ +#ifndef CONSTANTS_H +#define CONSTANTS_H + +#define LOCAL_UID QString("/org/glacier/messagesd") + +#define MESSAGING_SERVICE_NAME QString("org.nemomobile.qmlmessages") +#define MESSAGING_INTERFACE QString("org.nemomobile.qmlmessages") +#define START_CONVERSATION_METHOD QString("startConversation") + +#endif // CONSTANTS_H diff --git a/daemon/messageshandler.cpp b/daemon/messageshandler.cpp index 8bfc577..df0d37e 100644 --- a/daemon/messageshandler.cpp +++ b/daemon/messageshandler.cpp @@ -1,5 +1,6 @@ #include +#include "constants.h" #include "messageshandler.h" #include @@ -61,7 +62,7 @@ int MessagesHandler::getGroupId(QString sender) void MessagesHandler::onIncomingMessage(const QString& message, const QVariantMap& info) { - QString sender = info.key("Sender"); + QString sender = info.value("Sender").toString(); int groupId = getGroupId(sender); if (groupId < 0) { @@ -76,15 +77,29 @@ void MessagesHandler::onIncomingMessage(const QString& message, const QVariantMa event.setStartTime(info.value("SentTime").toDateTime()); event.setGroupId(groupId); - Notification newMessageNotification; - newMessageNotification.setAppName(tr("Messages")); - newMessageNotification.setSummary(sender); - newMessageNotification.setBody(message); - newMessageNotification.setIcon( - "/usr/share/glacier-messages/glacier-messages.png"); - newMessageNotification.setUrgency(Notification::Urgency::Normal); - if (m_commhistoryEventModel->addEvent(event)) { + Notification newMessageNotification; + newMessageNotification.setAppName(tr("Messages")); + newMessageNotification.setSummary(sender); + newMessageNotification.setBody(message); + newMessageNotification.setIcon("/usr/share/glacier-messages/glacier-messages.png"); + newMessageNotification.setUrgency(Notification::Urgency::Normal); + newMessageNotification.setTimestamp(QDateTime::currentDateTimeUtc()); + newMessageNotification.setHintValue("x-nemo-display-on", true); + newMessageNotification.setHintValue("x-nemo-priority", 120); + + QVariantList remoteActions; + remoteActions.append(Notification::remoteAction("default", + QString(), + MESSAGING_SERVICE_NAME, + "/", + MESSAGING_INTERFACE, + START_CONVERSATION_METHOD, + QVariantList() << LOCAL_UID + << sender + << true)); + + newMessageNotification.setRemoteActions(remoteActions); newMessageNotification.publish(); } else { qWarning() << "Can`t save event"; diff --git a/daemon/messageshandler.h b/daemon/messageshandler.h index 80ab9e8..93f283c 100644 --- a/daemon/messageshandler.h +++ b/daemon/messageshandler.h @@ -10,8 +10,6 @@ #include #include -static QString LOCAL_UID = "/org/glacier/messagesd"; - class MessagesHandler : public QObject { Q_OBJECT public: From 22be259421be09bea87802a46d9602c0cb827f96 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Tue, 17 Oct 2023 15:12:58 +0000 Subject: [PATCH 12/15] Fixup warning --- daemon/constants.h | 6 +++--- src/qml/pages/ConversationPage.qml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/daemon/constants.h b/daemon/constants.h index 54e7e8d..616e7a6 100644 --- a/daemon/constants.h +++ b/daemon/constants.h @@ -1,10 +1,10 @@ #ifndef CONSTANTS_H #define CONSTANTS_H -#define LOCAL_UID QString("/org/glacier/messagesd") +#define LOCAL_UID QString("/org/glacier/messagesd") -#define MESSAGING_SERVICE_NAME QString("org.nemomobile.qmlmessages") -#define MESSAGING_INTERFACE QString("org.nemomobile.qmlmessages") +#define MESSAGING_SERVICE_NAME QString("org.nemomobile.qmlmessages") +#define MESSAGING_INTERFACE QString("org.nemomobile.qmlmessages") #define START_CONVERSATION_METHOD QString("startConversation") #endif // CONSTANTS_H diff --git a/src/qml/pages/ConversationPage.qml b/src/qml/pages/ConversationPage.qml index 2c7fb3e..e96ae8a 100644 --- a/src/qml/pages/ConversationPage.qml +++ b/src/qml/pages/ConversationPage.qml @@ -47,7 +47,7 @@ import "../components" Page { id: conversationPage - property QtObject group + property var group: null property QtObject person: group ? peopleModel.personById(group.contactId) : null property string remoteUid: "" From f2528c01c5b1de8f1783386945b0fa55155ea384 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Wed, 18 Oct 2023 17:09:40 +0000 Subject: [PATCH 13/15] Move dbus adaptor to cpp --- daemon/messageshandler.cpp | 30 ++++++++++ daemon/messageshandler.h | 30 ++++++++++ src/CMakeLists.txt | 6 +- src/dbusadaptor.cpp | 78 ++++++++++++++++++++++++++ src/dbusadaptor.h | 56 ++++++++++++++++++ src/main.cpp | 5 +- src/qml/components/MessagesService.qml | 26 --------- src/qml/glacier-messages.qml | 17 +----- 8 files changed, 206 insertions(+), 42 deletions(-) create mode 100644 src/dbusadaptor.cpp create mode 100644 src/dbusadaptor.h delete mode 100644 src/qml/components/MessagesService.qml diff --git a/daemon/messageshandler.cpp b/daemon/messageshandler.cpp index df0d37e..7331f9b 100644 --- a/daemon/messageshandler.cpp +++ b/daemon/messageshandler.cpp @@ -1,3 +1,33 @@ +/* Copyright (C) 2023 Chupligin Sergey + * + * You may use this file under the terms of the BSD license as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Nemo Mobile nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #include #include "constants.h" diff --git a/daemon/messageshandler.h b/daemon/messageshandler.h index 93f283c..7656e78 100644 --- a/daemon/messageshandler.h +++ b/daemon/messageshandler.h @@ -1,3 +1,33 @@ +/* Copyright (C) 2023 Chupligin Sergey + * + * You may use this file under the terms of the BSD license as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Nemo Mobile nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef MESSAGESHANDLER_H #define MESSAGESHANDLER_H diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c7f86dd..e887414 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,12 +1,16 @@ set(SRC main.cpp + dbusadaptor.cpp ) +set(HEADERS + dbusadaptor.h) + if(!QML_DEBUG) qt_add_resources(RESOURCES qml/glacier-messages.qrc) endif() -add_executable(glacier-messages ${SRC} ${RESOURCES}) +add_executable(glacier-messages ${SRC} ${HEADERS} ${RESOURCES}) target_link_libraries(glacier-messages Qt6::Gui diff --git a/src/dbusadaptor.cpp b/src/dbusadaptor.cpp new file mode 100644 index 0000000..6641c45 --- /dev/null +++ b/src/dbusadaptor.cpp @@ -0,0 +1,78 @@ +/* Copyright (C) 2023 Chupligin Sergey + * + * You may use this file under the terms of the BSD license as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Nemo Mobile nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "dbusadaptor.h" +#include "qquickwindow.h" + +#include +#include +#include + +DBusAdaptor::DBusAdaptor(QQuickWindow* window) + : QDBusAbstractAdaptor(window) + , m_window(window) +{ + QDBusConnection sessionbus = QDBusConnection::sessionBus(); + + if (sessionbus.interface()->isServiceRegistered("org.nemomobile.qmlmessages")) { + qWarning() << "Second start of glacier dialler"; + QCoreApplication::quit(); + } + + QDBusConnection::sessionBus().registerService("org.nemomobile.qmlmessages"); + if (!QDBusConnection::sessionBus().registerObject("/", m_window)) { + qWarning() << Q_FUNC_INFO << "Cannot register DBus object!"; + } +} + +void DBusAdaptor::showGroupsWindow() +{ + m_window->raise(); +} + +void DBusAdaptor::showGroupsWindow(const QStringList& a) +{ + QMetaObject::invokeMethod(m_window, "startSMS", Q_ARG(QStringList, a)); + m_window->raise(); +} + +void DBusAdaptor::startConversation(const QString& localUid, const QString& remoteUid, bool show) +{ + QMetaObject::invokeMethod(m_window, "showConversation", Q_ARG(QVariant, localUid), Q_ARG(QVariant, remoteUid)); + if (show) { + m_window->raise(); + } +} + +void DBusAdaptor::startSMS(const QString& phoneNumber) +{ + QMetaObject::invokeMethod(m_window, "startSMS", Q_ARG(QVariant, phoneNumber)); + m_window->raise(); +} diff --git a/src/dbusadaptor.h b/src/dbusadaptor.h new file mode 100644 index 0000000..e5b6325 --- /dev/null +++ b/src/dbusadaptor.h @@ -0,0 +1,56 @@ +/* Copyright (C) 2023 Chupligin Sergey + * + * You may use this file under the terms of the BSD license as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Nemo Mobile nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DBUSADAPTOR_H +#define DBUSADAPTOR_H + +#include +#include +#include + +class DBusAdaptor : public QDBusAbstractAdaptor { + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.nemomobile.qmlmessages") + +public: + explicit DBusAdaptor(QQuickWindow* window); + +public slots: + void showGroupsWindow(); + void showGroupsWindow(const QStringList& a); + + void startConversation(const QString& localUid, const QString& remoteUid, bool show); + void startSMS(const QString& phoneNumber); + +private: + QQuickWindow* m_window; +}; + +#endif // DBUSADAPTOR_H diff --git a/src/main.cpp b/src/main.cpp index 476b753..34b3ba7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Chupligin Sergey +/* Copyright (C) 2018-2023 Chupligin Sergey * Copyright (C) 2012 John Brooks * Copyright (C) 2011 Robin Burchell * @@ -40,6 +40,8 @@ #include +#include "dbusadaptor.h" + Q_DECL_EXPORT int main(int argc, char** argv) { QGuiApplication* app = GlacierApp::app(argc, argv); @@ -49,5 +51,6 @@ Q_DECL_EXPORT int main(int argc, char** argv) window->setTitle(QObject::tr("Messages")); window->setIcon(QIcon("/usr/share/glacier-messages/glacier-messages.png")); + DBusAdaptor* adaptor = new DBusAdaptor(window); return app->exec(); } diff --git a/src/qml/components/MessagesService.qml b/src/qml/components/MessagesService.qml deleted file mode 100644 index 75ce8c7..0000000 --- a/src/qml/components/MessagesService.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick -import Nemo.DBus - -Item { - id: rootObject - signal startConversation(string localUid, string remoteUid, bool show) - - DBusAdaptor { - service: "org.nemomobile.qmlmessages" - path: "/" - iface: "org.nemomobile.qmlmessages" - - xml: ' \n' + - ' \n' + - ' \n' + - ' \n' + - ' \n' + - ' \n' + - ' \n' - - function startConversation(localUid, remoteUid, show) { - rootObject.startConversation(localUid, remoteUid, show) - } - } -} - diff --git a/src/qml/glacier-messages.qml b/src/qml/glacier-messages.qml index a211c28..b9686b4 100644 --- a/src/qml/glacier-messages.qml +++ b/src/qml/glacier-messages.qml @@ -79,16 +79,6 @@ ApplicationWindow { id: peopleModel } - MessagesService{ - id: messageService - - onStartConversation: { - console.log("start conversation: " + localUid + ", " + remoteUid + ", " + show) - showConversation(localUid,remoteUid) - app.show() - } - } - CommHistoryService { id: commHistory @@ -108,12 +98,11 @@ ApplicationWindow { } } - function showConversation(localUid, remoteUid) + function showConversation(localUid, remoteUid, show) { - var channel = channelManager.getConversation(localUid, remoteUid) var group = groupManager.findGroup(localUid, remoteUid) - if (!channel) { + if (!group) { return } @@ -125,7 +114,7 @@ ApplicationWindow { pageStack.push(Qt.resolvedUrl("pages/ConversationListPage.qml")) } - pageStack.push(Qt.resolvedUrl("pages/ConversationPage.qml"), { channel: channel, group: group, remoteUid: remoteUid }) + pageStack.push(Qt.resolvedUrl("pages/ConversationPage.qml"), { group: group, remoteUid: remoteUid }) app.raise() } From 601dcdec66507b9ea109638fccee4425ef4cfb47 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Thu, 19 Oct 2023 11:12:44 +0000 Subject: [PATCH 14/15] Add systemd service --- daemon/CMakeLists.txt | 3 +++ daemon/messagesd.service | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 daemon/messagesd.service diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt index e3ce15c..e5a2138 100644 --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -15,3 +15,6 @@ target_link_libraries(messagesd install(TARGETS messagesd RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +install(FILES messagesd.service + DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/user/) diff --git a/daemon/messagesd.service b/daemon/messagesd.service new file mode 100644 index 0000000..3eab258 --- /dev/null +++ b/daemon/messagesd.service @@ -0,0 +1,11 @@ +[Unit] +Description=Messages handler daemon +After=dbus.socket ofono.service +Requires=dbus.socket + +[Service] +ExecStart=/usr/bin/messagesd +Restart=always + +[Install] +WantedBy=graphical-session.target From 174742ea2014208025a298a39aaf311749c94f2e Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Thu, 19 Oct 2023 11:13:03 +0000 Subject: [PATCH 15/15] Remove no needed debug message --- daemon/messageshandler.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/daemon/messageshandler.cpp b/daemon/messageshandler.cpp index 7331f9b..2bfb580 100644 --- a/daemon/messageshandler.cpp +++ b/daemon/messageshandler.cpp @@ -40,8 +40,6 @@ MessagesHandler::MessagesHandler(QObject* parent) , m_commhistoryEventModel(new CommHistory::EventModel(this)) , m_groupModel(new CommHistory::GroupModel(this)) { - qDebug() << Q_FUNC_INFO; - m_groupModel->setResolveContacts(CommHistory::GroupManager::DoNotResolve); if (!m_groupModel->getGroups()) { qFatal() << "Can't load CommHistory::GroupModel";