summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/remoteclient_p.h
diff options
context:
space:
mode:
authorkh <karsten.heimrich@theqtcompany.com>2014-11-27 15:35:52 +0100
committerKai Koehne <kai.koehne@theqtcompany.com>2014-12-02 13:28:47 +0100
commit5e4f49fd4edbffc302bd14b972f6ea046230a333 (patch)
tree1cb90f2e8073d34a03276baa15cd84edf2d3274c /src/libs/installer/remoteclient_p.h
parentd872d37e840d63d338ece1eb684aa9cd4b0d9fbc (diff)
Move and rename connect method, adapt depending code.
Move the connect into the remote object class and rename. Avoids passing around the socket and possible writing to the socket in a different thread. Also inherit the private remote client class from remote object to avoid code duplication (connect and send). Change-Id: I6e747dbbd8eff2846362d7f5fa4fa170495ac503 Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'src/libs/installer/remoteclient_p.h')
-rw-r--r--src/libs/installer/remoteclient_p.h32
1 files changed, 12 insertions, 20 deletions
diff --git a/src/libs/installer/remoteclient_p.h b/src/libs/installer/remoteclient_p.h
index 23dcc9c14..fed0576a4 100644
--- a/src/libs/installer/remoteclient_p.h
+++ b/src/libs/installer/remoteclient_p.h
@@ -40,26 +40,26 @@
#include "messageboxhandler.h"
#include "protocol.h"
#include "remoteclient.h"
+#include "remoteobject.h"
#include "utils.h"
#include <QCoreApplication>
#include <QElapsedTimer>
#include <QHostAddress>
#include <QMutex>
-#include <QTcpSocket>
#include <QThread>
-#include <QTimer>
namespace QInstaller {
-class RemoteClientPrivate
+class RemoteClientPrivate : public RemoteObject
{
Q_DECLARE_PUBLIC(RemoteClient)
Q_DISABLE_COPY(RemoteClientPrivate)
public:
RemoteClientPrivate(RemoteClient *parent)
- : q_ptr(parent)
+ : RemoteObject(QLatin1String("RemoteClientPrivate"))
+ , q_ptr(parent)
, m_mutex(QMutex::Recursive)
, m_address(QLatin1String(Protocol::DefaultHostAddress))
, m_port(Protocol::DefaultPort)
@@ -142,10 +142,11 @@ public:
const QMessageBox::Button res =
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
QLatin1String("AuthorizationError"),
- RemoteClient::tr("Could not get authorization."),
- RemoteClient::tr("Could not get authorization that is needed for continuing "
- "the installation.\n Either abort the installation or use the fallback "
- "solution by running\n\n%1\n\nas root and then clicking OK.").arg(fallback),
+ QCoreApplication::translate("RemoteClient", "Could not get authorization."),
+ QCoreApplication::translate("RemoteClient", "Could not get authorization that "
+ "is needed for continuing the installation.\n Either abort the "
+ "installation or use the fallback solution by running\n\n%1\n\nas root "
+ "and then clicking OK.").arg(fallback),
QMessageBox::Abort | QMessageBox::Ok, QMessageBox::Ok);
if (res == QMessageBox::Ok)
@@ -161,9 +162,7 @@ public:
t.start();
// 30 seconds ought to be enough for the app to start
while (m_serverStarting && m_serverStarted && t.elapsed() < 30000) {
- Q_Q(RemoteClient);
- QTcpSocket socket;
- if (q->connect(&socket))
+ if (authorize())
m_serverStarting = false;
}
}
@@ -182,15 +181,8 @@ public:
if (!m_serverStarted)
return;
- Q_Q(RemoteClient);
- QTcpSocket socket;
- if (q->connect(&socket)) {
- QDataStream stream(&socket);
- stream << QString::fromLatin1(Protocol::Authorize);
- stream << m_key;
- stream << QString::fromLatin1(Protocol::Shutdown);
- socket.flush();
- }
+ if (authorize())
+ callRemoteMethod(QString::fromLatin1(Protocol::Shutdown));
m_serverStarted = false;
}