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

@ -48,14 +48,17 @@ ScreensaverInhibitPlugin::ScreensaverInhibitPlugin(QObject* parent, const QVaria
if (reply.errorMessage() != NULL) {
qCDebug(KDECONNECT_PLUGIN_SCREENSAVERINHIBIT) << "Unable to inhibit the screensaver: " << reply.errorMessage();
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()
{
if (inhibitCookie == 0) return;
QDBusInterface inhibitInterface(INHIBIT_SERVICE, INHIBIT_PATH, INHIBIT_INTERFACE);
inhibitInterface.call(UNINHIBIT_METHOD, this->inhibitCookie);
@ -69,7 +72,9 @@ ScreensaverInhibitPlugin::~ScreensaverInhibitPlugin()
}
void ScreensaverInhibitPlugin::connected()
{}
{
}
bool ScreensaverInhibitPlugin::receivePackage(const NetworkPackage& np)
{