diff --git a/interfaces/conversationmessage.cpp b/interfaces/conversationmessage.cpp index 8cb40f8a7..8fada475c 100644 --- a/interfaces/conversationmessage.cpp +++ b/interfaces/conversationmessage.cpp @@ -33,7 +33,7 @@ ConversationMessage::ConversationMessage(const QVariantMap& args, QObject* paren m_read(args["read"].toInt()), m_threadID(args["thread_id"].toInt()), m_uID(args["_id"].toInt()) - { +{ } ConversationMessage::ConversationMessage (const QString& body, const QString& address, const qint64& date, @@ -49,7 +49,6 @@ ConversationMessage::ConversationMessage (const QString& body, const QString& ad , m_threadID(threadID) , m_uID(uID) { - } ConversationMessage::ConversationMessage(const ConversationMessage& other, QObject* parent) @@ -62,7 +61,6 @@ ConversationMessage::ConversationMessage(const ConversationMessage& other, QObje , m_threadID(other.m_threadID) , m_uID(other.m_uID) { - } ConversationMessage::~ConversationMessage() { } diff --git a/interfaces/conversationmessage.h b/interfaces/conversationmessage.h index 70b36250e..aad56608c 100644 --- a/interfaces/conversationmessage.h +++ b/interfaces/conversationmessage.h @@ -42,8 +42,7 @@ class KDECONNECTINTERFACES_EXPORT ConversationMessage public: // TYPE field values from Android - enum Types - { + enum Types { MessageTypeAll = 0, MessageTypeInbox = 1, MessageTypeSent = 2, diff --git a/plugins/sms/conversationsdbusinterface.cpp b/plugins/sms/conversationsdbusinterface.cpp index 3ed907cf2..f8937d3bc 100644 --- a/plugins/sms/conversationsdbusinterface.cpp +++ b/plugins/sms/conversationsdbusinterface.cpp @@ -52,8 +52,7 @@ void ConversationsDbusInterface::requestConversation(const QString& conversation { const auto messagesList = m_conversations[conversationID].values(); - if (messagesList.isEmpty()) - { + if (messagesList.isEmpty()) { // Since there are no messages in the conversation, it's likely that it is a junk ID, but go ahead anyway qCWarning(KDECONNECT_CONVERSATIONS) << "Got a conversationID for a conversation with no messages!" << conversationID; } @@ -64,12 +63,10 @@ void ConversationsDbusInterface::requestConversation(const QString& conversation // messages (smallest timestamp number) // Therefore, return the end of the list first (most recent messages) int i = start; - for(auto it = messagesList.crbegin(); it != messagesList.crend(); ++it) - { + for(auto it = messagesList.crbegin(); it != messagesList.crend(); ++it) { Q_EMIT conversationMessageReceived(it->toVariant(), i); i++; - if (i >= end) - { + if (i >= end) { break; } } @@ -79,8 +76,7 @@ void ConversationsDbusInterface::addMessage(const ConversationMessage &message) { const QString& threadId = QString::number(message.threadID()); - if (m_known_messages[threadId].contains(message.uID())) - { + if (m_known_messages[threadId].contains(message.uID())) { // This message has already been processed. Don't do anything. return; } @@ -91,11 +87,9 @@ void ConversationsDbusInterface::addMessage(const ConversationMessage &message) m_known_messages[threadId].insert(message.uID()); // Tell the world about what just happened - if (newConversation) - { + if (newConversation) { Q_EMIT conversationCreated(threadId); - } else - { + } else { Q_EMIT conversationUpdated(message.toVariant()); } } @@ -108,8 +102,7 @@ void ConversationsDbusInterface::removeMessage(const QString& internalId) void ConversationsDbusInterface::replyToConversation(const QString& conversationID, const QString& message) { const auto messagesList = m_conversations[conversationID]; - if (messagesList.isEmpty()) - { + if (messagesList.isEmpty()) { // Since there are no messages in the conversation, we can't do anything sensible qCWarning(KDECONNECT_CONVERSATIONS) << "Got a conversationID for a conversation with no messages!"; return; diff --git a/plugins/sms/conversationsdbusinterface.h b/plugins/sms/conversationsdbusinterface.h index fbde4f3ee..65c1bb957 100644 --- a/plugins/sms/conversationsdbusinterface.h +++ b/plugins/sms/conversationsdbusinterface.h @@ -1,5 +1,6 @@ /** * Copyright 2013 Albert Vaca + * Copyright 2018 Simon Redman * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/plugins/sms/smsplugin.cpp b/plugins/sms/smsplugin.cpp index 26a51f6e4..92c67ae6f 100644 --- a/plugins/sms/smsplugin.cpp +++ b/plugins/sms/smsplugin.cpp @@ -1,5 +1,6 @@ /** * Copyright 2013 Albert Vaca + * Copyright 2018 Simon Redman * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -99,8 +100,7 @@ bool SmsPlugin::handleBatchMessages(const NetworkPacket& np) { const auto messages = np.get("messages"); - for (const QVariant& body : messages) - { + for (const QVariant& body : messages) { ConversationMessage message(body.toMap()); forwardToTelepathy(message); m_conversationInterface->addMessage(message); diff --git a/plugins/sms/smsplugin.h b/plugins/sms/smsplugin.h index 61ed1f79a..276b5feb6 100644 --- a/plugins/sms/smsplugin.h +++ b/plugins/sms/smsplugin.h @@ -1,5 +1,6 @@ /** * Copyright 2013 Albert Vaca + * Copyright 2018 Simon Redman * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -123,7 +124,6 @@ private: */ bool handleBatchMessages(const NetworkPacket& np); - QDBusInterface m_telepathyInterface; ConversationsDbusInterface* m_conversationInterface; diff --git a/plugins/telephony/telephonyplugin.cpp b/plugins/telephony/telephonyplugin.cpp index 79dddd20e..fae9468e0 100644 --- a/plugins/telephony/telephonyplugin.cpp +++ b/plugins/telephony/telephonyplugin.cpp @@ -107,10 +107,8 @@ bool TelephonyPlugin::receivePacket(const NetworkPacket& np) const QString& event = np.get(QStringLiteral("event"), QStringLiteral("unknown")); // Handle old-style packets - if (np.type() == PACKET_TYPE_TELEPHONY) - { - if (event == QLatin1String("sms")) - { + if (np.type() == PACKET_TYPE_TELEPHONY) { + if (event == QLatin1String("sms")) { return false; } KNotification* n = createNotification(np); diff --git a/smsapp/conversationlistmodel.cpp b/smsapp/conversationlistmodel.cpp index ea8c9ebe2..1bbbcc548 100644 --- a/smsapp/conversationlistmodel.cpp +++ b/smsapp/conversationlistmodel.cpp @@ -2,6 +2,7 @@ * This file is part of KDE Telepathy Chat * * Copyright (C) 2018 Aleix Pol Gonzalez + * Copyright (C) 2018 Simon Redman * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -104,8 +105,7 @@ void ConversationListModel::createRowFromMessage(const QVariantMap& msg, int row return; const ConversationMessage message(msg); - if (message.type() == -1) - { + if (message.type() == -1) { // The Android side currently hacks in -1 if something weird comes up // TODO: Remove this hack when MMS support is implemented return; @@ -117,14 +117,11 @@ void ConversationListModel::createRowFromMessage(const QVariantMap& msg, int row toadd = true; item = new QStandardItem(); QScopedPointer personData(lookupPersonByAddress(message.address())); - if (personData) - { + if (personData) { item->setText(personData->name()); item->setIcon(QIcon(personData->photo())); item->setData(personData->personUri(), PersonUriRole); - } - else - { + } else { item->setData(QString(), PersonUriRole); item->setText(message.address()); } @@ -142,16 +139,14 @@ void ConversationListModel::createRowFromMessage(const QVariantMap& msg, int row KPeople::PersonData* ConversationListModel::lookupPersonByAddress(const QString& address) { int rowIndex = 0; - for (rowIndex = 0; rowIndex < m_people.rowCount(); rowIndex++) - { + for (rowIndex = 0; rowIndex < m_people.rowCount(); rowIndex++) { const QString& uri = m_people.get(rowIndex, KPeople::PersonsModel::PersonUriRole).toString(); KPeople::PersonData* person = new KPeople::PersonData(uri); const QString& email = person->email(); const QString& phoneNumber = canonicalizePhoneNumber(person->contactCustomProperty("phoneNumber").toString()); - if (address == email || canonicalizePhoneNumber(address) == phoneNumber) - { + if (address == email || canonicalizePhoneNumber(address) == phoneNumber) { qCDebug(KDECONNECT_SMS_CONVERSATIONS_LIST_MODEL) << "Matched" << address << "to" << person->name(); return person; } diff --git a/smsapp/conversationlistmodel.h b/smsapp/conversationlistmodel.h index e75fd169a..21bceede5 100644 --- a/smsapp/conversationlistmodel.h +++ b/smsapp/conversationlistmodel.h @@ -2,6 +2,7 @@ * This file is part of KDE Telepathy Chat * * Copyright (C) 2018 Aleix Pol Gonzalez + * Copyright (C) 2018 Simon Redman * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/smsapp/conversationmodel.h b/smsapp/conversationmodel.h index 0de265c4f..80805c300 100644 --- a/smsapp/conversationmodel.h +++ b/smsapp/conversationmodel.h @@ -2,6 +2,7 @@ * This file is part of KDE Telepathy Chat * * Copyright (C) 2018 Aleix Pol Gonzalez + * Copyright (C) 2018 Simon Redman * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/smsapp/main.cpp b/smsapp/main.cpp index 4ed669be6..00a7cc0dc 100644 --- a/smsapp/main.cpp +++ b/smsapp/main.cpp @@ -1,7 +1,8 @@ /* * This file is part of KDE Telepathy Chat * - * Copyright (C) 2015 Aleix Pol Gonzalez + * Copyright (C) 2018 Aleix Pol Gonzalez + * Copyright (C) 2018 Simon Redman * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -37,6 +38,8 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); KAboutData aboutData("org.kde.kdeconnect.sms", i18n("SMS Instant Messaging"), QStringLiteral(KDECONNECT_VERSION_STRING), i18n("KDE Connect SMS"), KAboutLicense::GPL, i18n("(c) 2018, Aleix Pol Gonzalez")); aboutData.addAuthor(i18n("Aleix Pol Gonzalez"), {}, "aleixpol@kde.org"); + aboutData.addAuthor(i18n("Nicolas Fella"), {}, "nicolas.fella@gmx.de"); + aboutData.addAuthor(i18n("Simon Redman"), {}, "simon@ergotech.com"); KAboutData::setApplicationData(aboutData); {