Changeset View
Changeset View
Standalone View
Standalone View
plugins/sms/conversationsdbusinterface.cpp
- This file was moved from plugins/telephony/conversationsdbusinterface.cpp.
Show All 21 Lines | |||||
22 | #include "interfaces/dbusinterfaces.h" | 22 | #include "interfaces/dbusinterfaces.h" | ||
23 | #include "interfaces/conversationmessage.h" | 23 | #include "interfaces/conversationmessage.h" | ||
24 | 24 | | |||
25 | #include <QDBusConnection> | 25 | #include <QDBusConnection> | ||
26 | 26 | | |||
27 | #include <core/device.h> | 27 | #include <core/device.h> | ||
28 | #include <core/kdeconnectplugin.h> | 28 | #include <core/kdeconnectplugin.h> | ||
29 | 29 | | |||
30 | #include "telephonyplugin.h" | 30 | #include "smsplugin.h" | ||
31 | 31 | | |||
32 | ConversationsDbusInterface::ConversationsDbusInterface(KdeConnectPlugin* plugin) | 32 | ConversationsDbusInterface::ConversationsDbusInterface(KdeConnectPlugin* plugin) | ||
33 | : QDBusAbstractAdaptor(const_cast<Device*>(plugin->device())) | 33 | : QDBusAbstractAdaptor(const_cast<Device*>(plugin->device())) | ||
34 | , m_device(plugin->device()) | 34 | , m_device(plugin->device()) | ||
35 | , m_plugin(plugin) | 35 | , m_plugin(plugin) | ||
36 | , m_lastId(0) | 36 | , m_lastId(0) | ||
37 | , m_telephonyInterface(m_device->id()) | 37 | , m_telephonyInterface(m_device->id()) | ||
38 | { | 38 | { | ||
Show All 11 Lines | |||||
50 | 50 | | |||
51 | void ConversationsDbusInterface::requestConversation(const QString& conversationID, int start, int end) | 51 | void ConversationsDbusInterface::requestConversation(const QString& conversationID, int start, int end) | ||
52 | { | 52 | { | ||
53 | const auto messagesList = m_conversations[conversationID]; | 53 | const auto messagesList = m_conversations[conversationID]; | ||
54 | 54 | | |||
55 | if (messagesList.isEmpty()) | 55 | if (messagesList.isEmpty()) | ||
56 | { | 56 | { | ||
57 | // Since there are no messages in the conversation, it's likely that it is a junk ID, but go ahead anyway | 57 | // Since there are no messages in the conversation, it's likely that it is a junk ID, but go ahead anyway | ||
58 | qCWarning(KDECONNECT_PLUGIN_TELEPHONY) << "Got a conversationID for a conversation with no messages!" << conversationID; | 58 | qCWarning(KDECONNECT_PLUGIN_SMS) << "Got a conversationID for a conversation with no messages!" << conversationID; | ||
59 | } | 59 | } | ||
60 | 60 | | |||
61 | m_telephonyInterface.requestConversation(conversationID); | 61 | m_telephonyInterface.requestConversation(conversationID); | ||
62 | 62 | | |||
63 | for(int i=start; i<end; ++i) { | 63 | for(int i=start; i<end; ++i) { | ||
64 | if (i<messagesList.size()) { | 64 | if (i<messagesList.size()) { | ||
65 | Q_EMIT conversationMessageReceived(messagesList.at(i).toVariant(), i); | 65 | Q_EMIT conversationMessageReceived(messagesList.at(i).toVariant(), i); | ||
66 | } | 66 | } | ||
Show All 31 Lines | |||||
98 | } | 98 | } | ||
99 | 99 | | |||
100 | void ConversationsDbusInterface::replyToConversation(const QString& conversationID, const QString& message) | 100 | void ConversationsDbusInterface::replyToConversation(const QString& conversationID, const QString& message) | ||
101 | { | 101 | { | ||
102 | const auto messagesList = m_conversations[conversationID]; | 102 | const auto messagesList = m_conversations[conversationID]; | ||
103 | if (messagesList.isEmpty()) | 103 | if (messagesList.isEmpty()) | ||
104 | { | 104 | { | ||
105 | // Since there are no messages in the conversation, we can't do anything sensible | 105 | // Since there are no messages in the conversation, we can't do anything sensible | ||
106 | qCWarning(KDECONNECT_PLUGIN_TELEPHONY) << "Got a conversationID for a conversation with no messages!"; | 106 | qCWarning(KDECONNECT_PLUGIN_SMS) << "Got a conversationID for a conversation with no messages!"; | ||
107 | return; | 107 | return; | ||
108 | } | 108 | } | ||
109 | const QString& address = messagesList.front().address(); | 109 | const QString& address = messagesList.front().address(); | ||
110 | m_telephonyInterface.sendSms(address, message); | 110 | m_telephonyInterface.sendSms(address, message); | ||
111 | } | 111 | } | ||
112 | 112 | | |||
113 | void ConversationsDbusInterface::requestAllConversationThreads() | 113 | void ConversationsDbusInterface::requestAllConversationThreads() | ||
114 | { | 114 | { | ||
115 | // Prepare the list of conversations by requesting the first in every thread | 115 | // Prepare the list of conversations by requesting the first in every thread | ||
116 | m_telephonyInterface.requestAllConversations(); | 116 | m_telephonyInterface.requestAllConversations(); | ||
117 | } | 117 | } | ||
118 | 118 | | |||
119 | QString ConversationsDbusInterface::newId() | 119 | QString ConversationsDbusInterface::newId() | ||
120 | { | 120 | { | ||
121 | return QString::number(++m_lastId); | 121 | return QString::number(++m_lastId); | ||
122 | } | 122 | } |