2018-10-11 21:52:42 +01:00
/**
2020-08-17 10:48:10 +01:00
* SPDX - FileCopyrightText : 2018 Aleix Pol Gonzalez < aleixpol @ kde . org >
* SPDX - FileCopyrightText : 2018 Simon Redman < simon @ ergotech . com >
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
*
2020-08-17 10:48:10 +01:00
* SPDX - License - Identifier : GPL - 2.0 - only OR GPL - 3.0 - only OR LicenseRef - KDE - Accepted - GPL
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
*/
# include "conversationlistmodel.h"
2019-07-19 18:33:15 +01:00
# include <QPainter>
2022-09-10 22:23:52 +01:00
# include <QString>
2019-07-19 16:29:28 +01:00
# include <KLocalizedString>
2023-07-23 15:53:57 +01:00
# include "dbushelpers.h"
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
# include "interfaces/conversationmessage.h"
2018-10-08 04:46:25 +01:00
# include "interfaces/dbusinterfaces.h"
2020-05-26 17:55:47 +01:00
# include "sms_conversations_list_debug.h"
2022-09-10 22:23:52 +01:00
# include "smshelper.h"
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
2020-03-21 22:57:28 +00:00
# define INVALID_THREAD_ID -1
# define INVALID_DATE -1
2022-09-10 22:23:52 +01:00
ConversationListModel : : ConversationListModel ( QObject * parent )
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
: QStandardItemModel ( parent )
, m_conversationsInterface ( nullptr )
{
2022-09-10 22:23:52 +01:00
// qCDebug(KDECONNECT_SMS_CONVERSATIONS_LIST_MODEL) << "Constructing" << this;
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
auto roles = roleNames ( ) ;
2023-12-23 20:33:08 +00:00
roles . insert ( Qt : : DisplayRole , " displayNames " ) ;
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
roles . insert ( FromMeRole , " fromMe " ) ;
2019-07-19 18:33:15 +01:00
roles . insert ( SenderRole , " sender " ) ;
roles . insert ( DateRole , " date " ) ;
roles . insert ( AddressesRole , " addresses " ) ;
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
roles . insert ( ConversationIdRole , " conversationId " ) ;
2019-07-19 16:29:28 +01:00
roles . insert ( MultitargetRole , " isMultitarget " ) ;
2020-09-27 04:51:17 +01:00
roles . insert ( AttachmentPreview , " attachmentPreview " ) ;
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
setItemRoleNames ( roles ) ;
ConversationMessage : : registerDbusType ( ) ;
}
ConversationListModel : : ~ ConversationListModel ( )
{
}
2022-09-10 22:23:52 +01:00
void ConversationListModel : : setDeviceId ( const QString & deviceId )
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
{
2018-10-08 04:46:25 +01:00
if ( deviceId = = m_deviceId ) {
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
return ;
2018-10-08 04:46:25 +01:00
}
2019-04-30 17:11:42 +01:00
if ( deviceId . isEmpty ( ) ) {
2019-01-23 01:27:10 +00:00
return ;
}
2018-10-08 04:46:25 +01:00
qCDebug ( KDECONNECT_SMS_CONVERSATIONS_LIST_MODEL ) < < " setDeviceId " < < deviceId < < " of " < < this ;
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
if ( m_conversationsInterface ) {
2023-08-08 21:51:30 +01:00
disconnect ( m_conversationsInterface , & DeviceConversationsDbusInterface : : conversationCreated , this , & ConversationListModel : : handleCreatedConversation ) ;
disconnect ( m_conversationsInterface , & DeviceConversationsDbusInterface : : conversationUpdated , this , & ConversationListModel : : handleConversationUpdated ) ;
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
delete m_conversationsInterface ;
2018-10-08 04:46:25 +01:00
m_conversationsInterface = nullptr ;
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
}
2018-10-08 04:46:25 +01:00
// This method still gets called *with a valid deviceID* when the device is not connected while the component is setting up
// Detect that case and don't do anything.
DeviceDbusInterface device ( deviceId ) ;
if ( ! ( device . isValid ( ) & & device . isReachable ( ) ) ) {
return ;
}
2019-05-05 19:11:23 +01:00
m_deviceId = deviceId ;
Q_EMIT deviceIdChanged ( ) ;
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
m_conversationsInterface = new DeviceConversationsDbusInterface ( deviceId , this ) ;
2023-08-08 21:51:30 +01:00
connect ( m_conversationsInterface , & DeviceConversationsDbusInterface : : conversationCreated , this , & ConversationListModel : : handleCreatedConversation ) ;
connect ( m_conversationsInterface , & DeviceConversationsDbusInterface : : conversationUpdated , this , & ConversationListModel : : handleConversationUpdated ) ;
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
2019-07-21 11:55:25 +01:00
refresh ( ) ;
}
void ConversationListModel : : refresh ( )
{
if ( m_deviceId . isEmpty ( ) ) {
qWarning ( ) < < " refreshing null device " ;
return ;
}
prepareConversationsList ( ) ;
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
m_conversationsInterface - > requestAllConversationThreads ( ) ;
}
void ConversationListModel : : prepareConversationsList ( )
{
2018-10-08 04:46:25 +01:00
if ( ! m_conversationsInterface - > isValid ( ) ) {
qCWarning ( KDECONNECT_SMS_CONVERSATIONS_LIST_MODEL ) < < " Tried to prepareConversationsList with an invalid interface! " ;
return ;
}
2020-04-08 09:46:35 +01:00
const QDBusPendingReply < QVariantList > validThreadIDsReply = m_conversationsInterface - > activeConversations ( ) ;
2018-10-08 04:46:25 +01:00
2022-09-10 22:23:52 +01:00
setWhenAvailable (
validThreadIDsReply ,
2024-09-09 12:31:31 +01:00
[ this ] ( bool error , const QVariantList & convs ) {
2022-09-10 22:23:52 +01:00
clear ( ) ; // If we clear before we receive the reply, there might be a (several second) visual gap!
2024-09-09 12:31:31 +01:00
if ( error ) {
return ;
}
2022-09-10 22:23:52 +01:00
for ( const QVariant & headMessage : convs ) {
createRowFromMessage ( qdbus_cast < ConversationMessage > ( headMessage ) ) ;
}
displayContacts ( ) ;
} ,
this ) ;
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
}
2022-09-10 22:23:52 +01:00
void ConversationListModel : : handleCreatedConversation ( const QDBusVariant & msg )
2018-10-08 04:46:25 +01:00
{
2020-04-08 09:46:35 +01:00
const ConversationMessage message = ConversationMessage : : fromDBus ( msg ) ;
2019-07-19 18:33:15 +01:00
createRowFromMessage ( message ) ;
2018-10-08 04:46:25 +01:00
}
2022-09-10 22:23:52 +01:00
void ConversationListModel : : handleConversationUpdated ( const QDBusVariant & msg )
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
{
2020-04-08 09:46:35 +01:00
const ConversationMessage message = ConversationMessage : : fromDBus ( msg ) ;
2019-07-19 18:33:15 +01:00
createRowFromMessage ( message ) ;
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
}
2022-09-10 22:23:52 +01:00
void ConversationListModel : : printDBusError ( const QDBusError & error )
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
{
qCWarning ( KDECONNECT_SMS_CONVERSATIONS_LIST_MODEL ) < < error ;
}
2022-09-10 22:23:52 +01:00
QStandardItem * ConversationListModel : : conversationForThreadId ( qint32 threadId )
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
{
2022-09-10 22:23:52 +01:00
for ( int i = 0 , c = rowCount ( ) ; i < c ; + + i ) {
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
auto it = item ( i , 0 ) ;
if ( it - > data ( ConversationIdRole ) = = threadId )
return it ;
}
return nullptr ;
}
2022-09-10 22:23:52 +01:00
QStandardItem * ConversationListModel : : getConversationForAddress ( const QString & address )
2020-04-08 18:15:20 +01:00
{
2022-09-10 22:23:52 +01:00
for ( int i = 0 ; i < rowCount ( ) ; + + i ) {
const auto & it = item ( i , 0 ) ;
2020-03-21 22:57:28 +00:00
if ( ! it - > data ( MultitargetRole ) . toBool ( ) ) {
if ( SmsHelper : : isPhoneNumberMatch ( it - > data ( SenderRole ) . toString ( ) , address ) ) {
return it ;
}
}
}
return nullptr ;
}
2022-09-10 22:23:52 +01:00
void ConversationListModel : : createRowFromMessage ( const ConversationMessage & message )
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
{
2018-10-06 01:01:30 +01:00
if ( message . type ( ) = = - 1 ) {
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
// The Android side currently hacks in -1 if something weird comes up
// TODO: Remove this hack when MMS support is implemented
return ;
}
2020-03-21 22:57:28 +00:00
/** The address of everyone involved in this conversation, which we should not display (check if they are known contacts first) */
2020-04-08 09:46:35 +01:00
const QList < ConversationAddress > rawAddresses = message . addresses ( ) ;
2020-03-21 22:57:28 +00:00
if ( rawAddresses . isEmpty ( ) ) {
qWarning ( ) < < " no addresses! " < < message . body ( ) ;
return ;
}
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
bool toadd = false ;
2022-09-10 22:23:52 +01:00
QStandardItem * item = conversationForThreadId ( message . threadID ( ) ) ;
// Check if we have a contact with which to associate this message, needed if there is no conversation with the contact and we received a message from them
2020-03-21 22:57:28 +00:00
if ( ! item & & ! message . isMultitarget ( ) ) {
2022-09-10 22:23:52 +01:00
item = getConversationForAddress ( rawAddresses [ 0 ] . address ( ) ) ;
if ( item ) {
item - > setData ( message . threadID ( ) , ConversationIdRole ) ;
2020-03-21 22:57:28 +00:00
}
2022-09-10 22:23:52 +01:00
}
2020-03-21 22:57:28 +00:00
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
if ( ! item ) {
toadd = true ;
item = new QStandardItem ( ) ;
2019-07-19 18:33:15 +01:00
2020-04-08 09:46:35 +01:00
const QString displayNames = SmsHelper : : getTitleForAddresses ( rawAddresses ) ;
const QIcon displayIcon = SmsHelper : : getIconForAddresses ( rawAddresses ) ;
2019-07-19 18:33:15 +01:00
item - > setText ( displayNames ) ;
2024-06-17 03:00:41 +01:00
item - > setData ( displayIcon , Qt : : DecorationRole ) ;
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
item - > setData ( message . threadID ( ) , ConversationIdRole ) ;
2019-07-19 18:33:15 +01:00
item - > setData ( rawAddresses [ 0 ] . address ( ) , SenderRole ) ;
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
}
2018-10-08 04:46:25 +01:00
2019-07-19 16:29:28 +01:00
// Get the body that we should display
2020-08-09 20:00:57 +01:00
QString displayBody ;
if ( message . containsTextBody ( ) ) {
displayBody = message . body ( ) ;
} else if ( message . containsAttachment ( ) ) {
const QString mimeType = message . attachments ( ) . last ( ) . mimeType ( ) ;
2020-09-13 05:42:47 +01:00
if ( mimeType . startsWith ( QStringLiteral ( " image " ) ) ) {
2020-09-27 04:51:17 +01:00
displayBody = i18nc ( " Used as a text placeholder when the most-recent message is an image " , " Picture " ) ;
2022-09-10 22:23:52 +01:00
} else if ( mimeType . startsWith ( QStringLiteral ( " video " ) ) ) {
2020-09-27 04:51:17 +01:00
displayBody = i18nc ( " Used as a text placeholder when the most-recent message is a video " , " Video " ) ;
2020-09-13 05:42:47 +01:00
} else {
// Craft a somewhat-descriptive string, like "pdf file"
2020-09-27 04:51:17 +01:00
displayBody = i18nc ( " Used as a text placeholder when the most-recent message is an arbitrary attachment, resulting in something like \" pdf file \" " ,
2022-09-10 22:23:52 +01:00
" %1 file " ,
mimeType . right ( mimeType . indexOf ( QStringLiteral ( " / " ) ) ) ) ;
2020-09-13 05:42:47 +01:00
}
2020-09-27 04:51:17 +01:00
}
// Get the preview from the attachment, if it exists
QIcon attachmentPreview ;
if ( message . containsAttachment ( ) ) {
attachmentPreview = SmsHelper : : getThumbnailForAttachment ( message . attachments ( ) . last ( ) ) ;
2020-08-09 20:00:57 +01:00
}
2019-07-19 16:29:28 +01:00
2020-05-06 19:19:02 +01:00
// For displaying single line subtitle out of the multiline messages to keep the ListItems consistent
displayBody = displayBody . mid ( 0 , displayBody . indexOf ( QStringLiteral ( " \n " ) ) ) ;
2019-07-19 18:33:15 +01:00
// Prepend the sender's name
if ( message . isOutgoing ( ) ) {
displayBody = i18n ( " You: %1 " , displayBody ) ;
} else {
// If the message is incoming, the sender is the first Address
2020-04-08 09:46:35 +01:00
const QString senderAddress = item - > data ( SenderRole ) . toString ( ) ;
2019-07-21 12:19:01 +01:00
const auto sender = SmsHelper : : lookupPersonByAddress ( senderAddress ) ;
2022-09-10 22:23:52 +01:00
const QString senderName = sender = = nullptr ? senderAddress : SmsHelper : : lookupPersonByAddress ( senderAddress ) - > name ( ) ;
2019-07-19 18:33:15 +01:00
displayBody = i18n ( " %1: %2 " , senderName , displayBody ) ;
2019-07-19 16:29:28 +01:00
}
2019-07-19 18:33:15 +01:00
2018-10-08 04:46:25 +01:00
// Update the message if the data is newer
// This will be true if a conversation receives a new message, but false when the user
// does something to trigger past conversation history loading
bool oldDateExists ;
2020-04-08 09:46:35 +01:00
const qint64 oldDate = item - > data ( DateRole ) . toLongLong ( & oldDateExists ) ;
2018-10-08 04:46:25 +01:00
if ( ! oldDateExists | | message . date ( ) > = oldDate ) {
// If there was no old data or incoming data is newer, update the record
2019-07-19 18:33:15 +01:00
item - > setData ( QVariant : : fromValue ( message . addresses ( ) ) , AddressesRole ) ;
item - > setData ( message . isOutgoing ( ) , FromMeRole ) ;
2019-07-19 16:29:28 +01:00
item - > setData ( displayBody , Qt : : ToolTipRole ) ;
2018-10-08 04:46:25 +01:00
item - > setData ( message . date ( ) , DateRole ) ;
2019-07-19 16:29:28 +01:00
item - > setData ( message . isMultitarget ( ) , MultitargetRole ) ;
2020-09-27 04:51:17 +01:00
if ( ! attachmentPreview . isNull ( ) ) {
item - > setData ( attachmentPreview , AttachmentPreview ) ;
}
2018-10-08 04:46:25 +01:00
}
(WIP) Upgrade Telephony plugin to read SMS history (KDE side)
Summary:
For real usecases of SMS support, we will almost always need access to the message history in some way
Specifically resolve T8338
Incidentally resolve T6651 since Telephony shall no longer create a notification
Test Plan:
Setup:
- Build corresponding Android-side diff (D11698)
- Build this diff
Step 1: Does anything at all work?
- Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object
- Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
- Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation
Step 2: DBus
- Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId>
- Poke activeConversations and verify an empty array is returned
- Poke requestAllConversationThreads
- Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds
- Use a conversationId to call getFirstFromConversation
- Verify that the returned Message object is one which you recognize
- Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!"
Step 3: SMS App
- Use ccmake (or similar) to set SMSAPP_ENABLE to ON
- Build the project
- Run ./bin/kdeconnect-sms
- Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out)
- If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number
Reviewers: #kde_connect, nicolasfella, apol
Reviewed By: #kde_connect, nicolasfella, apol
Subscribers: andyholmes, apol, nicolasfella, #kde_connect
Tags: #kde_connect
Maniphest Tasks: T8338, T6651
Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
if ( toadd )
appendRow ( item ) ;
}
2020-03-21 22:57:28 +00:00
2020-04-08 18:15:20 +01:00
void ConversationListModel : : displayContacts ( )
{
2020-03-21 22:57:28 +00:00
const QList < QSharedPointer < KPeople : : PersonData > > personDataList = SmsHelper : : getAllPersons ( ) ;
2022-09-10 22:23:52 +01:00
for ( const auto & person : personDataList ) {
2020-03-21 22:57:28 +00:00
const QVariantList allPhoneNumbers = person - > contactCustomProperty ( QStringLiteral ( " all-phoneNumber " ) ) . toList ( ) ;
2022-09-10 22:23:52 +01:00
for ( const QVariant & rawPhoneNumber : allPhoneNumbers ) {
// check for any duplicate phoneNumber and eliminate it
2020-03-21 22:57:28 +00:00
if ( ! getConversationForAddress ( rawPhoneNumber . toString ( ) ) ) {
2022-09-10 22:23:52 +01:00
QStandardItem * item = new QStandardItem ( ) ;
2020-03-21 22:57:28 +00:00
item - > setText ( person - > name ( ) ) ;
item - > setIcon ( person - > photo ( ) ) ;
QList < ConversationAddress > addresses ;
addresses . append ( ConversationAddress ( rawPhoneNumber . toString ( ) ) ) ;
item - > setData ( QVariant : : fromValue ( addresses ) , AddressesRole ) ;
2020-04-08 09:46:35 +01:00
const QString displayBody = i18n ( " %1 " , rawPhoneNumber . toString ( ) ) ;
2020-03-21 22:57:28 +00:00
item - > setData ( displayBody , Qt : : ToolTipRole ) ;
item - > setData ( false , MultitargetRole ) ;
item - > setData ( qint64 ( INVALID_THREAD_ID ) , ConversationIdRole ) ;
item - > setData ( qint64 ( INVALID_DATE ) , DateRole ) ;
item - > setData ( rawPhoneNumber . toString ( ) , SenderRole ) ;
appendRow ( item ) ;
}
}
}
}
2020-03-22 09:33:04 +00:00
2022-09-10 22:23:52 +01:00
void ConversationListModel : : createConversationForAddress ( const QString & address )
2020-04-08 18:15:20 +01:00
{
2022-09-10 22:23:52 +01:00
QStandardItem * item = new QStandardItem ( ) ;
2020-04-08 18:15:20 +01:00
const QString canonicalizedAddress = SmsHelper : : canonicalizePhoneNumber ( address ) ;
item - > setText ( canonicalizedAddress ) ;
2020-03-22 09:33:04 +00:00
QList < ConversationAddress > addresses ;
2020-04-08 18:15:20 +01:00
addresses . append ( ConversationAddress ( canonicalizedAddress ) ) ;
2020-03-22 09:33:04 +00:00
item - > setData ( QVariant : : fromValue ( addresses ) , AddressesRole ) ;
2020-04-08 18:15:20 +01:00
QString displayBody = i18n ( " %1 " , canonicalizedAddress ) ;
2020-03-22 09:33:04 +00:00
item - > setData ( displayBody , Qt : : ToolTipRole ) ;
item - > setData ( false , MultitargetRole ) ;
item - > setData ( qint64 ( INVALID_THREAD_ID ) , ConversationIdRole ) ;
item - > setData ( qint64 ( INVALID_DATE ) , DateRole ) ;
item - > setData ( address , SenderRole ) ;
appendRow ( item ) ;
}
2023-07-26 09:15:11 +01:00
# include "moc_conversationlistmodel.cpp"