28 #include <kstandarddirs.h>
30 #include <QDesktopWidget>
31 #include <QApplication>
36 m_host(std::string()),
38 m_privateKey(std::string()),
42 m_client.setSessionData(&m_data);
44 QDesktopWidget *desktop = QApplication::desktop();
45 int currentScreen = desktop->screenNumber();
46 QRect rect = desktop->screenGeometry(currentScreen);
47 m_client.setResolution(rect.width(), rect.height());
48 m_client.setDepth(24);
49 m_client.setRender(
true);
51 m_data.sessionName =
"krdcSession";
54 m_data.linkType =
"adsl";
56 m_data.backingstore =
"when_requested";
57 m_data.imageCompressionMethod = 2;
58 m_data.keyboard =
"defkeymap";
60 m_data.agentServer =
"";
61 m_data.agentUser =
"";
62 m_data.agentPass =
"";
64 m_data.suspended =
false;
65 m_data.fullscreen =
false;
66 m_data.encryption =
true;
67 m_data.terminate =
false;
78 m_client.setExternalCallbacks(callbacks);
83 QMutexLocker locker(&m_mutex);
84 QByteArray tmp = host.toAscii();
90 QMutexLocker locker(&m_mutex);
96 QMutexLocker locker(&m_mutex);
97 std::string userNameStr = std::string(userName.toAscii().data());
98 m_client.setUsername(userNameStr);
103 QMutexLocker locker(&m_mutex);
104 std::string passwordStr = std::string(password.toAscii());
105 m_client.setPassword(passwordStr);
110 QMutexLocker locker(&m_mutex);
111 m_data.geometry = width +
'x' + height +
"+0+0";
116 QMutexLocker locker(&m_mutex);
117 QByteArray tmp = desktopType.toAscii();
118 m_data.sessionType = tmp.data();
123 QMutexLocker locker(&m_mutex);
124 QByteArray tmp = keyboardLayout.toAscii();
125 m_data.kbtype = tmp.data();
130 QMutexLocker locker(&m_mutex);
131 QByteArray tmp = privateKey.toAscii();
132 m_privateKey = tmp.data();
137 QMutexLocker locker(&m_mutex);
138 m_data.suspended = suspended;
143 QMutexLocker locker(&m_mutex);
144 QByteArray tmp =
id.toAscii();
145 m_data.id = tmp.data();
150 QMutexLocker locker(&m_mutex);
156 if (m_privateKey.compare(
"default") == 0) {
157 const QString keyfilename = QString(
"default.dsa.key");
158 const QString keyfilepath = KGlobal::dirs()->findResource(
"appdata", keyfilename);
160 QFile file(keyfilepath);
161 if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
165 while (!file.atEnd())
166 key += file.readLine();
168 m_client.invokeNXSSH(
"supplied", m_host,
true, key.data(), m_port);
170 m_client.invokeNXSSH(
"supplied", m_host,
true, m_privateKey, m_port);
172 nxcl::notQProcess* p;
173 while (!m_client.getIsFinished() && !m_stopped) {
174 if (!m_client.getReadyForProxy()) {
175 p = m_client.getNXSSHProcess();
178 p = m_client.getNXSSHProcess();
180 p = m_client.getNXProxyProcess();
185 this->m_xid = m_client.getXID();
197 m_client.runSession();
200 #include "moc_nxclientthread.cpp"
void setPrivateKey(const QString &privateKey)
void setResolution(int width, int height)
void setId(const QString &id)
void setCallbacks(NxCallbacks *callbacks)
void setDesktopType(const QString &desktopType)
void setKeyboardLayout(const QString &keyboardLayout)
void setSuspended(bool suspended)
void setPassword(const QString &password)
void setHost(const QString &host)
NxClientThread(QObject *parent=0)
void hasXid(int xid)
Emitted when the X Window ID of the main NX window is received.
void setUserName(const QString &userName)