aboutsummaryrefslogtreecommitdiff
path: root/singleapplication.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'singleapplication.cpp')
-rw-r--r--singleapplication.cpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/singleapplication.cpp b/singleapplication.cpp
index 4e1c6ac..7857440 100644
--- a/singleapplication.cpp
+++ b/singleapplication.cpp
@@ -252,27 +252,27 @@ void SingleApplicationPrivate::slotConnectionEstablished()
{
Q_Q(SingleApplication);
- QLocalSocket *socket = server->nextPendingConnection();
+ QLocalSocket *nextConnSocket = server->nextPendingConnection();
// Verify that the new connection follows the SingleApplication protocol
char connectionType = '\0'; // Invalid connection
quint32 instanceId;
QByteArray initMsg, tmp;
- if( socket->waitForReadyRead( 100 ) ) {
- tmp = socket->read( blockServerName.length() );
+ if( nextConnSocket->waitForReadyRead( 100 ) ) {
+ tmp = nextConnSocket->read( blockServerName.length() );
// Verify that the socket data start with blockServerName
if( tmp == blockServerName.toLatin1() ) {
initMsg = tmp;
- // Verify that the next charecter is N/S/R (connecion type)
+ // Verify that the next character is N/S/R (connection type)
// Stands for New Instance/Secondary Instance/Reconnect
- connectionType = socket->read( 1 )[0];
+ connectionType = nextConnSocket->read( 1 )[0];
switch( connectionType ) {
case 'N':
case 'S':
case 'R':
{
initMsg += connectionType;
- tmp = socket->read( sizeof(quint32) );
+ tmp = nextConnSocket->read( sizeof(quint32) );
const char * data = tmp.constData();
instanceId = (quint32)*data;
initMsg += tmp;
@@ -281,7 +281,7 @@ void SingleApplicationPrivate::slotConnectionEstablished()
qChecksum( initMsg.constData(), initMsg.length() ),
256
);
- tmp = socket->read( checksum.length() );
+ tmp = nextConnSocket->read( checksum.length() );
if( checksum == tmp )
break; // Otherwise set to invalid connection (next line)
}
@@ -292,26 +292,26 @@ void SingleApplicationPrivate::slotConnectionEstablished()
}
if( connectionType == '\0' ) {
- socket->close();
- delete socket;
+ nextConnSocket->close();
+ delete nextConnSocket;
return;
}
QObject::connect(
- socket,
+ nextConnSocket,
&QLocalSocket::aboutToClose,
this,
- [socket, instanceId, this]() {
- Q_EMIT this->slotClientConnectionClosed( socket, instanceId );
+ [nextConnSocket, instanceId, this]() {
+ Q_EMIT this->slotClientConnectionClosed( nextConnSocket, instanceId );
}
);
QObject::connect(
- socket,
+ nextConnSocket,
&QLocalSocket::readyRead,
this,
- [socket, instanceId, this]() {
- Q_EMIT this->slotDataAvailable( socket, instanceId );
+ [nextConnSocket, instanceId, this]() {
+ Q_EMIT this->slotDataAvailable( nextConnSocket, instanceId );
}
);
@@ -323,22 +323,22 @@ void SingleApplicationPrivate::slotConnectionEstablished()
Q_EMIT q->instanceStarted();
}
- if( socket->bytesAvailable() > 0 ) {
- Q_EMIT this->slotDataAvailable( socket, instanceId );
+ if( nextConnSocket->bytesAvailable() > 0 ) {
+ Q_EMIT this->slotDataAvailable( nextConnSocket, instanceId );
}
}
-void SingleApplicationPrivate::slotDataAvailable( QLocalSocket *socket, quint32 instanceId )
+void SingleApplicationPrivate::slotDataAvailable( QLocalSocket *dataSocket, quint32 instanceId )
{
Q_Q(SingleApplication);
- Q_EMIT q->receivedMessage( instanceId, socket->readAll() );
+ Q_EMIT q->receivedMessage( instanceId, dataSocket->readAll() );
}
-void SingleApplicationPrivate::slotClientConnectionClosed( QLocalSocket *socket, quint32 instanceId )
+void SingleApplicationPrivate::slotClientConnectionClosed( QLocalSocket *closedSocket, quint32 instanceId )
{
- if( socket->bytesAvailable() > 0 )
- Q_EMIT slotDataAvailable( socket, instanceId );
- socket->deleteLater();
+ if( closedSocket->bytesAvailable() > 0 )
+ Q_EMIT slotDataAvailable( closedSocket, instanceId );
+ closedSocket->deleteLater();
}
/**