diff options
author | Vitaly Wool <vitaly.wool@konsulko.com> | 2018-11-28 16:50:01 +0100 |
---|---|---|
committer | Vitaly Wool <vitaly.wool@konsulko.com> | 2018-11-28 16:51:28 +0100 |
commit | d466bf191f581f4e3a3d1988845bffad01f7b3e1 (patch) | |
tree | 4f8b56616aaeaddf78c1aa2ea62ab9f30a420c8f /app/taskmanager.cpp | |
parent | f52f93fa42ffc213653e4772acedfcf849707ce8 (diff) |
Add kill button and relevant functionalityguppy_6.99.2guppy/6.99.26.99.2
Add 'Kill' and 'Info' (for future use: display detailed info on
process in a separate window) buttons to the Task Manager UI and
implement sending kill command to the service.
Signed-off-by: Vitaly Wool <vitaly.wool@konsulko.com>
Change-Id: Iac50f6ce46fc91471d94118587c6e7ea0842beca
Diffstat (limited to 'app/taskmanager.cpp')
-rw-r--r-- | app/taskmanager.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/app/taskmanager.cpp b/app/taskmanager.cpp index 1b913d0..be95fd7 100644 --- a/app/taskmanager.cpp +++ b/app/taskmanager.cpp @@ -14,22 +14,30 @@ TaskManager::TaskManager(QObject* parent) : QObject(parent) { void TaskManager::open(const QUrl &bindingAddress) { m_socket.open(bindingAddress); timer = new QTimer(); - connect(timer, SIGNAL(timeout()), this, SLOT(callService())); + connect(timer, SIGNAL(timeout()), this, SLOT(query())); timer->start(3000); } -void TaskManager::callService() { +void TaskManager::kill(int tid) { + callService(QString("kill_process"), QJsonValue(tid)); +} + +void TaskManager::query() { + callService(QString("get_process_list"), QJsonValue()); +} + +void TaskManager::callService(const QString& command, QJsonValue value) { QJsonArray msg; msg.append(2); // Call msg.append(QString::number(m_nextCallId)); - msg.append(QString("taskmanager/get_process_list")); - msg.append(QJsonValue()); + msg.append(QString("taskmanager/") + command); + msg.append(value); m_nextCallId++; - QJsonDocument value; - value.setArray(msg); + QJsonDocument jsonDoc; + jsonDoc.setArray(msg); - m_socket.sendTextMessage(value.toJson(QJsonDocument::Compact)); + m_socket.sendTextMessage(jsonDoc.toJson(QJsonDocument::Compact)); } void TaskManager::onSocketTextReceived(QString msg) |