Changeset View
Changeset View
Standalone View
Standalone View
core/networkpackage.cpp
Context not available. | |||||
44 | return s.space(); | 44 | return s.space(); | ||
---|---|---|---|---|---|
45 | } | 45 | } | ||
46 | 46 | | |||
47 | const int NetworkPackage::ProtocolVersion = 7; | 47 | const int NetworkPackage::s_protocolVersion = 7; | ||
48 | 48 | | |||
49 | NetworkPackage::NetworkPackage(const QString& type, const QVariantMap &body) | 49 | NetworkPackage::NetworkPackage(const QString& type, const QVariantMap& body) | ||
50 | : mId(QString::number(QDateTime::currentMSecsSinceEpoch())) | 50 | : m_id(QString::number(QDateTime::currentMSecsSinceEpoch())) | ||
51 | , mType(type) | 51 | , m_type(type) | ||
52 | , mBody(body) | 52 | , m_body(body) | ||
53 | , mPayload() | 53 | , m_payload() | ||
54 | , mPayloadSize(0) | 54 | , m_payloadSize(0) | ||
55 | { | 55 | { | ||
56 | } | 56 | } | ||
57 | 57 | | |||
58 | void NetworkPackage::createIdentityPackage(NetworkPackage* np) | 58 | void NetworkPackage::createIdentityPackage(NetworkPackage* np) | ||
59 | { | 59 | { | ||
60 | KdeConnectConfig* config = KdeConnectConfig::instance(); | 60 | KdeConnectConfig* config = KdeConnectConfig::instance(); | ||
61 | np->mId = QString::number(QDateTime::currentMSecsSinceEpoch()); | 61 | np->m_id = QString::number(QDateTime::currentMSecsSinceEpoch()); | ||
62 | np->mType = PACKAGE_TYPE_IDENTITY; | 62 | np->m_type = PACKAGE_TYPE_IDENTITY; | ||
63 | np->mPayload = QSharedPointer<QIODevice>(); | 63 | np->m_payload = QSharedPointer<QIODevice>(); | ||
64 | np->mPayloadSize = 0; | 64 | np->m_payloadSize = 0; | ||
65 | np->set(QStringLiteral("deviceId"), config->deviceId()); | 65 | np->set(QStringLiteral("deviceId"), config->deviceId()); | ||
66 | np->set(QStringLiteral("deviceName"), config->name()); | 66 | np->set(QStringLiteral("deviceName"), config->name()); | ||
67 | np->set(QStringLiteral("deviceType"), config->deviceType()); | 67 | np->set(QStringLiteral("deviceType"), config->deviceType()); | ||
68 | np->set(QStringLiteral("protocolVersion"), NetworkPackage::ProtocolVersion); | 68 | np->set(QStringLiteral("protocolVersion"), NetworkPackage::s_protocolVersion); | ||
69 | np->set(QStringLiteral("incomingCapabilities"), PluginLoader::instance()->incomingCapabilities()); | 69 | np->set(QStringLiteral("incomingCapabilities"), PluginLoader::instance()->incomingCapabilities()); | ||
70 | np->set(QStringLiteral("outgoingCapabilities"), PluginLoader::instance()->outgoingCapabilities()); | 70 | np->set(QStringLiteral("outgoingCapabilities"), PluginLoader::instance()->outgoingCapabilities()); | ||
71 | 71 | | |||
Context not available. | |||||
97 | if (hasPayload()) { | 97 | if (hasPayload()) { | ||
98 | //qCDebug(KDECONNECT_CORE) << "Serializing payloadTransferInfo"; | 98 | //qCDebug(KDECONNECT_CORE) << "Serializing payloadTransferInfo"; | ||
99 | variant[QStringLiteral("payloadSize")] = payloadSize(); | 99 | variant[QStringLiteral("payloadSize")] = payloadSize(); | ||
100 | variant[QStringLiteral("payloadTransferInfo")] = mPayloadTransferInfo; | 100 | variant[QStringLiteral("payloadTransferInfo")] = m_payloadTransferInfo; | ||
101 | } | 101 | } | ||
102 | 102 | | |||
103 | //QVariant -> json | 103 | //QVariant -> json | ||
Context not available. | |||||
147 | auto variant = parser.toVariant().toMap(); | 147 | auto variant = parser.toVariant().toMap(); | ||
148 | qvariant2qobject(variant, np); | 148 | qvariant2qobject(variant, np); | ||
149 | 149 | | |||
150 | np->mPayloadSize = variant[QStringLiteral("payloadSize")].toInt(); //Will return 0 if was not present, which is ok | 150 | np->m_payloadSize = variant[QStringLiteral("payloadSize")].toInt(); //Will return 0 if was not present, which is ok | ||
151 | if (np->mPayloadSize == -1) { | 151 | if (np->m_payloadSize == -1) { | ||
152 | np->mPayloadSize = np->get<int>(QStringLiteral("size"), -1); | 152 | np->m_payloadSize = np->get<int>(QStringLiteral("size"), -1); | ||
153 | } | 153 | } | ||
154 | np->mPayloadTransferInfo = variant[QStringLiteral("payloadTransferInfo")].toMap(); //Will return an empty qvariantmap if was not present, which is ok | 154 | np->m_payloadTransferInfo = variant[QStringLiteral("payloadTransferInfo")].toMap(); //Will return an empty qvariantmap if was not present, which is ok | ||
155 | 155 | | |||
156 | //Ids containing characters that are not allowed as dbus paths would make app crash | 156 | //Ids containing characters that are not allowed as dbus paths would make app crash | ||
157 | if (np->mBody.contains(QStringLiteral("deviceId"))) | 157 | if (np->m_body.contains(QStringLiteral("deviceId"))) | ||
158 | { | 158 | { | ||
159 | QString deviceId = np->get<QString>(QStringLiteral("deviceId")); | 159 | QString deviceId = np->get<QString>(QStringLiteral("deviceId")); | ||
160 | DbusHelper::filterNonExportableCharacters(deviceId); | 160 | DbusHelper::filterNonExportableCharacters(deviceId); | ||
Context not available. | |||||
165 | 165 | | |||
166 | } | 166 | } | ||
167 | 167 | | |||
168 | FileTransferJob* NetworkPackage::createPayloadTransferJob(const QUrl &destination) const | 168 | FileTransferJob* NetworkPackage::createPayloadTransferJob(const QUrl& destination) const | ||
169 | { | 169 | { | ||
170 | return new FileTransferJob(payload(), payloadSize(), destination); | 170 | return new FileTransferJob(payload(), payloadSize(), destination); | ||
171 | } | 171 | } | ||
Context not available. |