Fixed uninitialized members

This commit is contained in:
Albert Vaca 2015-04-04 10:05:55 -07:00
parent 70e3aec278
commit 6c6f2b1a03
8 changed files with 62 additions and 48 deletions

View file

@ -29,38 +29,14 @@
#include <QHostInfo>
#include <QTcpServer>
#include <QUdpSocket>
#include <QtGlobal>
#include "landevicelink.h"
#include <kdeconnectconfig.h>
void LanLinkProvider::configureSocket(QTcpSocket* socket)
{
int fd = socket->socketDescriptor();
socket->setSocketOption(QAbstractSocket::KeepAliveOption, QVariant(1));
#ifdef TCP_KEEPIDLE
// time to start sending keepalive packets (seconds)
int maxIdle = 10;
setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &maxIdle, sizeof(maxIdle));
#endif
#ifdef TCP_KEEPINTVL
// interval between keepalive packets after the initial period (seconds)
int interval = 5;
setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &interval, sizeof(interval));
#endif
#ifdef TCP_KEEPCNT
// number of missed keepalive packets before disconnecting
int count = 3;
setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &count, sizeof(count));
#endif
}
LanLinkProvider::LanLinkProvider()
{
mTcpPort = 0;
mUdpServer = new QUdpSocket(this);
connect(mUdpServer, SIGNAL(readyRead()), this, SLOT(newUdpConnection()));
@ -70,6 +46,11 @@ LanLinkProvider::LanLinkProvider()
}
LanLinkProvider::~LanLinkProvider()
{
}
void LanLinkProvider::onStart()
{
mUdpServer->bind(QHostAddress::Any, port, QUdpSocket::ShareAddress);
@ -102,6 +83,8 @@ void LanLinkProvider::onNetworkChange(QNetworkSession::State state)
return;
}
Q_ASSERT(mTcpPort != 0);
NetworkPackage np("");
NetworkPackage::createIdentityPackage(&np);
np.set("tcpPort", mTcpPort);
@ -295,7 +278,28 @@ void LanLinkProvider::deviceLinkDestroyed(QObject* destroyedDeviceLink)
}
LanLinkProvider::~LanLinkProvider()
void LanLinkProvider::configureSocket(QTcpSocket* socket)
{
int fd = socket->socketDescriptor();
socket->setSocketOption(QAbstractSocket::KeepAliveOption, QVariant(1));
#ifdef TCP_KEEPIDLE
// time to start sending keepalive packets (seconds)
int maxIdle = 10;
setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &maxIdle, sizeof(maxIdle));
#endif
#ifdef TCP_KEEPINTVL
// interval between keepalive packets after the initial period (seconds)
int interval = 5;
setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &interval, sizeof(interval));
#endif
#ifdef TCP_KEEPCNT
// number of missed keepalive packets before disconnecting
int count = 3;
setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &count, sizeof(count));
#endif
}

View file

@ -19,6 +19,7 @@
*/
#include <qalgorithms.h>
#include <QtGlobal>
#include "uploadjob.h"
#include "core_debug.h"
@ -28,6 +29,7 @@ UploadJob::UploadJob(const QSharedPointer<QIODevice>& source): KJob()
mInput = source;
mServer = new QTcpServer(this);
mSocket = 0;
mPort = 0;
connect(mInput.data(), SIGNAL(readyRead()), this, SLOT(readyRead()));
connect(mInput.data(), SIGNAL(aboutToClose()), this, SLOT(aboutToClose()));
@ -91,10 +93,10 @@ void UploadJob::aboutToClose()
QVariantMap UploadJob::getTransferInfo()
{
Q_ASSERT(mPort != 0);
QVariantMap ret;
ret["port"] = mPort;
return ret;
}

View file

@ -42,7 +42,7 @@ private:
QSharedPointer<QIODevice> mInput;
QTcpServer* mServer;
QTcpSocket* mSocket;
qint16 mPort;
quint16 mPort;
private Q_SLOTS:
void readyRead();

View file

@ -128,7 +128,7 @@ void FileTransferJob::readyRead()
//If a least 1 second has passed since last update
int secondsSinceLastTime = mTime.secsTo(QTime::currentTime());
if (secondsSinceLastTime > 0 && mSpeedBytes > 0) {
float speed = (mWritten - mSpeedBytes) / secondsSinceLastTime;
float speed = (mWritten - mSpeedBytes) / float(secondsSinceLastTime);
emitSpeed(speed);
mTime = QTime::currentTime();

View file

@ -26,6 +26,8 @@
BatteryDbusInterface::BatteryDbusInterface(const Device *device)
: QDBusAbstractAdaptor(const_cast<Device*>(device))
, mCharge(-1)
, mIsCharging(false)
{
}

View file

@ -46,7 +46,7 @@ Q_SIGNALS:
private:
int mCharge;
bool mIsCharging : 1;
bool mIsCharging;
};

View file

@ -40,6 +40,7 @@ Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_MPRIS, "kdeconnect.plugin.mpris")
MprisControlPlugin::MprisControlPlugin(QObject* parent, const QVariantList& args)
: KdeConnectPlugin(parent, args)
{
prevVolume = -1;
//Detect new interfaces
connect(QDBusConnection::sessionBus().interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),

View file

@ -42,34 +42,39 @@ const QString SIMULATE_ACTIVITY_METHOD = "SimulateUserActivity";
ScreensaverInhibitPlugin::ScreensaverInhibitPlugin(QObject* parent, const QVariantList& args)
: KdeConnectPlugin(parent, args)
{
QDBusInterface inhibitInterface(INHIBIT_SERVICE, INHIBIT_PATH, INHIBIT_INTERFACE);
QDBusInterface inhibitInterface(INHIBIT_SERVICE, INHIBIT_PATH, INHIBIT_INTERFACE);
QDBusMessage reply = inhibitInterface.call(INHIBIT_METHOD, "kdeconnect", "Phone is connected");
QDBusMessage reply = inhibitInterface.call(INHIBIT_METHOD, "kdeconnect", "Phone is connected");
if (reply.errorMessage() != NULL) {
if (reply.errorMessage() != NULL) {
qCDebug(KDECONNECT_PLUGIN_SCREENSAVERINHIBIT) << "Unable to inhibit the screensaver: " << reply.errorMessage();
} else {
inhibitCookie = 0;
} else {
// Store the cookie we receive, this will be sent back when sending the uninhibit call.
this->inhibitCookie = reply.arguments().first().toUInt();
}
inhibitCookie = reply.arguments().first().toUInt();
}
}
ScreensaverInhibitPlugin::~ScreensaverInhibitPlugin()
{
QDBusInterface inhibitInterface(INHIBIT_SERVICE, INHIBIT_PATH, INHIBIT_INTERFACE);
inhibitInterface.call(UNINHIBIT_METHOD, this->inhibitCookie);
if (inhibitCookie == 0) return;
/*
* Simulate user activity because what ever manages the screensaver does not seem to start the timer
* automatically when all inhibitions are lifted and the user does nothing which results in an
* unlocked desktop which would be dangerous. Ideally we should not be doing this and the screen should
* be locked anyway.
*/
inhibitInterface.call(SIMULATE_ACTIVITY_METHOD);
QDBusInterface inhibitInterface(INHIBIT_SERVICE, INHIBIT_PATH, INHIBIT_INTERFACE);
inhibitInterface.call(UNINHIBIT_METHOD, this->inhibitCookie);
/*
* Simulate user activity because what ever manages the screensaver does not seem to start the timer
* automatically when all inhibitions are lifted and the user does nothing which results in an
* unlocked desktop which would be dangerous. Ideally we should not be doing this and the screen should
* be locked anyway.
*/
inhibitInterface.call(SIMULATE_ACTIVITY_METHOD);
}
void ScreensaverInhibitPlugin::connected()
{}
{
}
bool ScreensaverInhibitPlugin::receivePackage(const NetworkPackage& np)
{