plugins: Add context-aware logging in case of errors
Also clean up some unneeded statements
This commit is contained in:
parent
1631ada5b3
commit
abb6dfcc6e
7 changed files with 6 additions and 15 deletions
|
@ -71,7 +71,7 @@ QString KdeConnectPlugin::dbusPath() const
|
||||||
|
|
||||||
void KdeConnectPlugin::receivePacket(const NetworkPacket &np)
|
void KdeConnectPlugin::receivePacket(const NetworkPacket &np)
|
||||||
{
|
{
|
||||||
qCWarning(KDECONNECT_CORE) << metaObject()->className() << "tried to send an recieve an unhandled packet type" << np.type();
|
qCWarning(KDECONNECT_CORE) << metaObject()->className() << "received a packet of type" << np.type() << "but doesn't implement receivePacket";
|
||||||
}
|
}
|
||||||
QString KdeConnectPlugin::iconName() const
|
QString KdeConnectPlugin::iconName() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -108,10 +108,6 @@ void BatteryPlugin::slotChargeChanged()
|
||||||
|
|
||||||
void BatteryPlugin::receivePacket(const NetworkPacket &np)
|
void BatteryPlugin::receivePacket(const NetworkPacket &np)
|
||||||
{
|
{
|
||||||
if (PACKET_TYPE_BATTERY != np.type()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_isCharging = np.get<bool>(QStringLiteral("isCharging"), false);
|
m_isCharging = np.get<bool>(QStringLiteral("isCharging"), false);
|
||||||
m_charge = np.get<int>(QStringLiteral("currentCharge"), -1);
|
m_charge = np.get<int>(QStringLiteral("currentCharge"), -1);
|
||||||
const int thresholdEvent = np.get<int>(QStringLiteral("thresholdEvent"), (int)ThresholdNone);
|
const int thresholdEvent = np.get<int>(QStringLiteral("thresholdEvent"), (int)ThresholdNone);
|
||||||
|
|
|
@ -88,6 +88,7 @@ void ClipboardPlugin::receivePacket(const NetworkPacket &np)
|
||||||
qint64 packetTime = np.get<qint64>(QStringLiteral("timestamp"));
|
qint64 packetTime = np.get<qint64>(QStringLiteral("timestamp"));
|
||||||
// If the packetTime is 0, it means the timestamp is unknown (so do nothing).
|
// If the packetTime is 0, it means the timestamp is unknown (so do nothing).
|
||||||
if (packetTime == 0 || packetTime < ClipboardListener::instance()->updateTimestamp()) {
|
if (packetTime == 0 || packetTime < ClipboardListener::instance()->updateTimestamp()) {
|
||||||
|
qCWarning(KDECONNECT_PLUGIN_CLIPBOARD) << "Ignoring clipboard without timestamp";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,6 @@ int ConnectivityReportPlugin::cellularNetworkStrength() const
|
||||||
|
|
||||||
void ConnectivityReportPlugin::receivePacket(const NetworkPacket &np)
|
void ConnectivityReportPlugin::receivePacket(const NetworkPacket &np)
|
||||||
{
|
{
|
||||||
if (PACKET_TYPE_CONNECTIVITY_REPORT != np.type()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto subscriptions = np.get<QVariantMap>(QStringLiteral("signalStrengths"), QVariantMap());
|
auto subscriptions = np.get<QVariantMap>(QStringLiteral("signalStrengths"), QVariantMap());
|
||||||
if (!subscriptions.isEmpty()) {
|
if (!subscriptions.isEmpty()) {
|
||||||
auto networkInfo = subscriptions.first().toMap();
|
auto networkInfo = subscriptions.first().toMap();
|
||||||
|
|
|
@ -53,9 +53,6 @@ void ContactsPlugin::receivePacket(const NetworkPacket &np)
|
||||||
handleResponseUIDsTimestamps(np);
|
handleResponseUIDsTimestamps(np);
|
||||||
} else if (np.type() == PACKET_TYPE_CONTACTS_RESPONSE_VCARDS) {
|
} else if (np.type() == PACKET_TYPE_CONTACTS_RESPONSE_VCARDS) {
|
||||||
handleResponseVCards(np);
|
handleResponseVCards(np);
|
||||||
} else {
|
|
||||||
// Is this check necessary?
|
|
||||||
qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "Unknown packet type received from device: " << device()->name() << ". Maybe you need to upgrade KDE Connect?";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,9 @@ void NotificationsPlugin::connected()
|
||||||
|
|
||||||
void NotificationsPlugin::receivePacket(const NetworkPacket &np)
|
void NotificationsPlugin::receivePacket(const NetworkPacket &np)
|
||||||
{
|
{
|
||||||
if (np.get<bool>(QStringLiteral("request")))
|
if (np.get<bool>(QStringLiteral("request"))) {
|
||||||
return;
|
qCWarning(KDECONNECT_PLUGIN_NOTIFICATION) << "Unexpected notification request. Maybe the paired client is very old?";
|
||||||
|
}
|
||||||
|
|
||||||
if (np.get<bool>(QStringLiteral("isCancel"))) {
|
if (np.get<bool>(QStringLiteral("isCancel"))) {
|
||||||
QString id = np.get<QString>(QStringLiteral("id"));
|
QString id = np.get<QString>(QStringLiteral("id"));
|
||||||
|
|
|
@ -126,7 +126,7 @@ void SftpPlugin::receivePacket(const NetworkPacket &np)
|
||||||
const QStringList keysList = np.body().keys();
|
const QStringList keysList = np.body().keys();
|
||||||
const auto keys = QSet(keysList.begin(), keysList.end());
|
const auto keys = QSet(keysList.begin(), keysList.end());
|
||||||
if (!(fields_c - keys).isEmpty() && !np.has(QStringLiteral("errorMessage"))) {
|
if (!(fields_c - keys).isEmpty() && !np.has(QStringLiteral("errorMessage"))) {
|
||||||
// packet is invalid
|
qCWarning(KDECONNECT_PLUGIN_SFTP) << "Invalid sftp packet received";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue