Changeset View
Changeset View
Standalone View
Standalone View
plugins/sms/smsplugin.cpp
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | |||||
70 | 70 | | |||
71 | void SmsPlugin::requestAllConversations() | 71 | void SmsPlugin::requestAllConversations() | ||
72 | { | 72 | { | ||
73 | NetworkPacket np(PACKET_TYPE_SMS_REQUEST_CONVERSATIONS); | 73 | NetworkPacket np(PACKET_TYPE_SMS_REQUEST_CONVERSATIONS); | ||
74 | 74 | | |||
75 | sendPacket(np); | 75 | sendPacket(np); | ||
76 | } | 76 | } | ||
77 | 77 | | |||
78 | void SmsPlugin::requestConversation (const QString& conversationID) const | 78 | void SmsPlugin::requestConversation (const qint32& conversationID) const | ||
79 | { | 79 | { | ||
80 | NetworkPacket np(PACKET_TYPE_SMS_REQUEST_CONVERSATION); | 80 | NetworkPacket np(PACKET_TYPE_SMS_REQUEST_CONVERSATION); | ||
apol: Why this change? | |||||
Because some places we had ints (specifically, this is how Android stores the value) and some places we had strings. It was a bit of a pain for me to remember which went where, so I declared everything should be int. Declaring everything should be string would be just as valid sredman: Because some places we had ints (specifically, this is how Android stores the value) and some… | |||||
81 | np.set("threadID", conversationID.toInt()); | 81 | np.set("threadID", conversationID); | ||
82 | 82 | | |||
83 | sendPacket(np); | 83 | sendPacket(np); | ||
84 | } | 84 | } | ||
85 | 85 | | |||
apol: Definitely not. | |||||
86 | void SmsPlugin::forwardToTelepathy(const ConversationMessage& message) | 86 | void SmsPlugin::forwardToTelepathy(const ConversationMessage& message) | ||
87 | { | 87 | { | ||
88 | // If we don't have a valid Telepathy interface, bail out | 88 | // If we don't have a valid Telepathy interface, bail out | ||
89 | if (!(m_telepathyInterface.isValid())) return; | 89 | if (!(m_telepathyInterface.isValid())) return; | ||
90 | 90 | | |||
91 | qCDebug(KDECONNECT_PLUGIN_SMS) << "Passing a text message to the telepathy interface"; | 91 | qCDebug(KDECONNECT_PLUGIN_SMS) << "Passing a text message to the telepathy interface"; | ||
92 | connect(&m_telepathyInterface, SIGNAL(messageReceived(QString,QString)), SLOT(sendSms(QString,QString)), Qt::UniqueConnection); | 92 | connect(&m_telepathyInterface, SIGNAL(messageReceived(QString,QString)), SLOT(sendSms(QString,QString)), Qt::UniqueConnection); | ||
93 | const QString messageBody = message.body(); | 93 | const QString messageBody = message.body(); | ||
94 | const QString contactName; // TODO: When telepathy support is improved, look up the contact with KPeople | 94 | const QString contactName; // TODO: When telepathy support is improved, look up the contact with KPeople | ||
95 | const QString phoneNumber = message.address(); | 95 | const QString phoneNumber = message.address(); | ||
96 | m_telepathyInterface.call(QDBus::NoBlock, QStringLiteral("sendMessage"), phoneNumber, contactName, messageBody); | 96 | m_telepathyInterface.call(QDBus::NoBlock, QStringLiteral("sendMessage"), phoneNumber, contactName, messageBody); | ||
97 | } | 97 | } | ||
98 | 98 | | |||
99 | bool SmsPlugin::handleBatchMessages(const NetworkPacket& np) | 99 | bool SmsPlugin::handleBatchMessages(const NetworkPacket& np) | ||
100 | { | 100 | { | ||
101 | const auto messages = np.get<QVariantList>("messages"); | 101 | const auto messages = np.get<QVariantList>("messages"); | ||
102 | QList<ConversationMessage> messagesList; | ||||
103 | messagesList.reserve(messages.count()); | ||||
102 | 104 | | |||
103 | for (const QVariant& body : messages) { | 105 | for (const QVariant& body : messages) { | ||
104 | ConversationMessage message(body.toMap()); | 106 | ConversationMessage message(body.toMap()); | ||
105 | if (message.containsTextBody()) { | 107 | if (message.containsTextBody()) { | ||
106 | forwardToTelepathy(message); | 108 | forwardToTelepathy(message); | ||
107 | m_conversationInterface->addMessage(message); | 109 | messagesList.append(message); | ||
108 | } | 110 | } | ||
109 | } | 111 | } | ||
110 | 112 | | |||
113 | m_conversationInterface->addMessages(messagesList); | ||||
114 | | ||||
111 | return true; | 115 | return true; | ||
112 | } | 116 | } | ||
113 | 117 | | |||
114 | 118 | | |||
115 | QString SmsPlugin::dbusPath() const | 119 | QString SmsPlugin::dbusPath() const | ||
116 | { | 120 | { | ||
117 | return "/modules/kdeconnect/devices/" + device()->id() + "/sms"; | 121 | return "/modules/kdeconnect/devices/" + device()->id() + "/sms"; | ||
118 | } | 122 | } | ||
119 | 123 | | |||
120 | #include "smsplugin.moc" | 124 | #include "smsplugin.moc" | ||
121 | 125 | |
Why this change?