added tcutils, a utility for unmounting usb drives remotely

This commit is contained in:
Laxmikant Rashinkar 2013-08-25 18:02:04 -07:00
parent fa40106a69
commit f8f648c574
15 changed files with 2598 additions and 0 deletions

29
tcutils/README.txt Normal file
View File

@ -0,0 +1,29 @@
A QT based utility program for thinclients using xrdp and NeutrinoRDP
This program sends commands to NeutrinoRDP to do something
useful on the client end (such as unmounting a USB drive,
or powering down the client)
Required packages to build tcutils:
-----------------------------------
libqt4-gui
qt4-dev-tools
to build tcutils:
-----------------
qmake
make
To run tcutils:
---------------
include xrdpapi/.libs in your LD_LIBRARY_PATH
Example:
--------
export LD_LIBRARY_PATH=../xrdpapi/.libs
run tcutils inside the xfreerdp session
this is how we run xfreerdp:
----------------------------
./xfreerdp --sec rdp --plugin tcutils 192.168.2.149

11
tcutils/main.cpp Normal file
View File

@ -0,0 +1,11 @@
#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

234
tcutils/mainwindow.cpp Normal file
View File

@ -0,0 +1,234 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
wtsChannel = NULL;
okToQuit = false;
savedGeometry = this->geometry();
/* setup tab to unmount drives */
ui->tabWidget->setTabText(0, "Unmount drives");
connect(ui->btnRefresh, SIGNAL(clicked()), this, SLOT(onBtnRefreshClicked()));
connect(ui->btnUnmount, SIGNAL(clicked()), this, SLOT(onBtnUnmountClicked()));
ui->tabWidget->setTabText(1, "");
if (initWtsChannel())
{
okToQuit = true;
QTimer::singleShot(10, qApp, SLOT(quit()));
return;
}
setupSystemTray();
/* set up status bar to display messages */
statusBar = new QStatusBar;
this->setStatusBar(statusBar);
setStatusMsg("Connected to client");
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::setupSystemTray()
{
trayMenu = new QMenu(this);
trayMenu->addAction("Launch Thinclient Utils", this, SLOT(onActionLaunch()));
trayMenu->addSeparator();
trayMenu->addAction("Quit", this, SLOT(onActionQuit()));
trayIcon = new QSystemTrayIcon;
trayIcon->setContextMenu(trayMenu);
trayIcon->setIcon(QIcon(":/images/resources/images/tools.gif"));
trayIcon->show();
trayIcon->showMessage("TCutils", "Click on the tcutils icon to launch tcutils",
QSystemTrayIcon::Information, 3000);
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(onSystemTrayClicked(QSystemTrayIcon::ActivationReason)));
}
/**
*
*****************************************************************************/
int MainWindow::initWtsChannel()
{
/* init the channel just once */
if (wtsChannel)
return 0;
/* open a WTS channel and connect to remote client */
wtsChannel = WTSVirtualChannelOpenEx(WTS_CURRENT_SESSION, "tcutils", 0);
if (wtsChannel == NULL)
{
QMessageBox::information(this, "Open virtual channel", "Error "
"connecting to remote client. This program "
"can only be used when connected via "
"NeutrinoRDP.\n\nClick ok to close this "
"application");
return -1;
}
return 0;
}
/**
*
*****************************************************************************/
int MainWindow::deinitWtsChannel()
{
if (!wtsChannel)
return -1;
WTSVirtualChannelClose(wtsChannel);
return 0;
}
/**
* Display a msg on the status bar
*
* @param msg message to display in status bar
*****************************************************************************/
void MainWindow::setStatusMsg(QString msg)
{
statusBar->showMessage(msg, 30000);
}
/**
*
*****************************************************************************/
void MainWindow::closeEvent(QCloseEvent *event)
{
if (!okToQuit)
{
savedGeometry = this->geometry();
this->hide();
event->ignore();
return;
}
if (wtsChannel)
deinitWtsChannel();
event->accept();
}
/******************************************************************************
** **
** slots go here **
** **
******************************************************************************/
#if 1
void MainWindow::onBtnRefreshClicked()
{
int i;
/* clear drive list */
if (itemList.count())
{
for (i = 0; i < itemList.count(); i++)
ui->listWidget->removeItemWidget(itemList.at(i));
itemList.clear();
}
ui->listWidget->clear();
if (Utils::getMountList(wtsChannel, &itemList))
{
QMessageBox::information(this, "Get device list", "\nError getting "
"device list from client");
return;
}
if (itemList.count() == 0)
{
QMessageBox::information(this, "Get device list",
"\nNo devices found!");
return;
}
/* add mount point to list widget */
for (i = 0; i < itemList.count(); i++)
ui->listWidget->insertItem(i, itemList.at(i));
}
#else
void MainWindow::onBtnRefreshClicked()
{
QListWidgetItem *item;
int i;
int j;
/* clear drive list */
if (itemList.count())
{
for (i = 0; i < itemList.count(); i++)
ui->listWidget->removeItemWidget(itemList.at(i));
itemList.clear();
}
ui->listWidget->clear();
QDir dir(QDir::homePath() + "/xrdp_client");
QStringList sl = dir.entryList();
for (i = 0, j = 0; i < sl.count(); i++)
{
/* skip files starting with . */
if (sl.at(i).startsWith("."))
continue;
/* add mount point to list widget */
item = new QListWidgetItem;
item->setText(sl.at(i));
ui->listWidget->insertItem(j++, item);
itemList.append(item);
}
}
#endif
void MainWindow::onBtnUnmountClicked()
{
QListWidgetItem *item = ui->listWidget->currentItem();
if (!item)
{
QMessageBox::information(this, "Unmount device", "\nNo device selected. "
"You must select a device to unmount");
return;
}
if (Utils::unmountDevice(wtsChannel, item->text(), statusBar) == 0)
{
delete ui->listWidget->takeItem(itemList.indexOf(item));
itemList.removeOne(item);
}
}
void MainWindow::onActionQuit()
{
okToQuit = true;
this->close();
}
void MainWindow::onActionLaunch()
{
this->show();
this->setGeometry(savedGeometry);
}
void MainWindow::onSystemTrayClicked(QSystemTrayIcon::ActivationReason)
{
trayMenu->popup(QCursor::pos());
}

57
tcutils/mainwindow.h Normal file
View File

@ -0,0 +1,57 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <xrdpapi.h>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QCloseEvent>
#include <QFileDialog>
#include <QDir>
#include <QListWidgetItem>
#include <QList>
#include <QMessageBox>
#include <QTimer>
#include <QStatusBar>
//#include <QDebug>
#include "utils.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
void *wtsChannel;
QSystemTrayIcon *trayIcon;
QMenu *trayMenu;
bool okToQuit;
QRect savedGeometry;
QStatusBar *statusBar;
QList<QListWidgetItem *> itemList;
void setupSystemTray();
int initWtsChannel();
int deinitWtsChannel();
void setStatusMsg(QString msg);
void closeEvent(QCloseEvent * event);
private slots:
void onBtnRefreshClicked();
void onBtnUnmountClicked();
void onActionQuit();
void onActionLaunch();
void onSystemTrayClicked(QSystemTrayIcon::ActivationReason);
};
#endif // MAINWINDOW_H

100
tcutils/mainwindow.ui Normal file
View File

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>541</width>
<height>355</height>
</rect>
</property>
<property name="windowTitle">
<string>TC Utils</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QTabWidget" name="tabWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>511</width>
<height>291</height>
</rect>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabUnmount">
<attribute name="title">
<string>Tab 1</string>
</attribute>
<widget class="QListWidget" name="listWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>321</width>
<height>221</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="btnUnmount">
<property name="geometry">
<rect>
<x>350</x>
<y>60</y>
<width>141</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Unmount device</string>
</property>
</widget>
<widget class="QPushButton" name="btnRefresh">
<property name="geometry">
<rect>
<x>350</x>
<y>10</y>
<width>141</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Get device list</string>
</property>
</widget>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>541</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

104
tcutils/moc_mainwindow.cpp Normal file
View File

@ -0,0 +1,104 @@
/****************************************************************************
** Meta object code from reading C++ file 'mainwindow.h'
**
** Created: Sun Aug 25 15:11:44 2013
** by: The Qt Meta Object Compiler version 63 (Qt 4.8.1)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "mainwindow.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'mainwindow.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 63
#error "This file was generated using the moc from 4.8.1. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_MainWindow[] = {
// content:
6, // revision
0, // classname
0, 0, // classinfo
5, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
// slots: signature, parameters, type, tag, flags
12, 11, 11, 11, 0x08,
34, 11, 11, 11, 0x08,
56, 11, 11, 11, 0x08,
71, 11, 11, 11, 0x08,
88, 11, 11, 11, 0x08,
0 // eod
};
static const char qt_meta_stringdata_MainWindow[] = {
"MainWindow\0\0onBtnRefreshClicked()\0"
"onBtnUnmountClicked()\0onActionQuit()\0"
"onActionLaunch()\0"
"onSystemTrayClicked(QSystemTrayIcon::ActivationReason)\0"
};
void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
Q_ASSERT(staticMetaObject.cast(_o));
MainWindow *_t = static_cast<MainWindow *>(_o);
switch (_id) {
case 0: _t->onBtnRefreshClicked(); break;
case 1: _t->onBtnUnmountClicked(); break;
case 2: _t->onActionQuit(); break;
case 3: _t->onActionLaunch(); break;
case 4: _t->onSystemTrayClicked((*reinterpret_cast< QSystemTrayIcon::ActivationReason(*)>(_a[1]))); break;
default: ;
}
}
}
const QMetaObjectExtraData MainWindow::staticMetaObjectExtraData = {
0, qt_static_metacall
};
const QMetaObject MainWindow::staticMetaObject = {
{ &QMainWindow::staticMetaObject, qt_meta_stringdata_MainWindow,
qt_meta_data_MainWindow, &staticMetaObjectExtraData }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &MainWindow::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *MainWindow::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *MainWindow::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_MainWindow))
return static_cast<void*>(const_cast< MainWindow*>(this));
return QMainWindow::qt_metacast(_clname);
}
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QMainWindow::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 5)
qt_static_metacall(this, _c, _id, _a);
_id -= 5;
}
return _id;
}
QT_END_MOC_NAMESPACE

1191
tcutils/qrc_resources.cpp Normal file

File diff suppressed because it is too large Load Diff

5
tcutils/resources.qrc Normal file
View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/images">
<file>resources/images/tools.gif</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
tcutils/tcutils Executable file

Binary file not shown.

30
tcutils/tcutils.pro Normal file
View File

@ -0,0 +1,30 @@
#-------------------------------------------------
#
# Project created by QtCreator 2013-08-18T13:54:44
#
#-------------------------------------------------
QT += core gui
TARGET = tcutils
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
utils.cpp
HEADERS += mainwindow.h \
utils.h
FORMS += mainwindow.ui
# added by LK Rashinkar
INCLUDEPATH += ../xrdpapi
LIBS += -Wl,-rpath
LIBS += -Wl,/usr/local/lib/xrdp
LIBS += -L../xrdpapi/.libs -lxrdpapi
RESOURCES += \
resources.qrc

365
tcutils/tcutils.pro.user Normal file
View File

@ -0,0 +1,365 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by Qt Creator 2.4.1, 2013-08-25T13:35:29. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QString" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">System</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">true</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">2</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap"/>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Target.DesktopTarget</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-32bit./usr/bin/gdb</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.1 in PATH (System) Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/lk/projects/jtech/nlabs_xrdp_tcutils/tcutils-build-desktop-Qt_4_8_1_in_PATH__System__Release</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">1</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-32bit./usr/bin/gdb</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.1 in PATH (System) Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/lk/projects/jtech/nlabs_xrdp_tcutils/tcutils-build-desktop-Qt_4_8_1_in_PATH__System__Debug</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">1</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-32bit./usr/bin/gdb</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.1 (System) Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/lk/projects/jtech/nlabs_xrdp_tcutils/tcutils-build-desktop-Qt_4_8_1__System__Release</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">2</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.3">
<value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-32bit./usr/bin/gdb</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.1 (System) Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/lk/projects/jtech/nlabs_xrdp_tcutils/tcutils-build-desktop-Qt_4_8_1__System__Debug</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">2</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">4</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Project.UseGlobal">true</value>
<value type="bool" key="Analyzer.Project.UseGlobal">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">tcutils</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase">2</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">tcutils.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
<value type="QString">{9a0d9632-2baf-44e0-864a-a12692180779}</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">10</value>
</data>
</qtcreator>

105
tcutils/ui_mainwindow.h Normal file
View File

@ -0,0 +1,105 @@
/********************************************************************************
** Form generated from reading UI file 'mainwindow.ui'
**
** Created: Sun Aug 25 15:11:42 2013
** by: Qt User Interface Compiler version 4.8.1
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_MAINWINDOW_H
#define UI_MAINWINDOW_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QHeaderView>
#include <QtGui/QListWidget>
#include <QtGui/QMainWindow>
#include <QtGui/QMenuBar>
#include <QtGui/QPushButton>
#include <QtGui/QStatusBar>
#include <QtGui/QTabWidget>
#include <QtGui/QToolBar>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class Ui_MainWindow
{
public:
QWidget *centralWidget;
QTabWidget *tabWidget;
QWidget *tabUnmount;
QListWidget *listWidget;
QPushButton *btnUnmount;
QPushButton *btnRefresh;
QWidget *tab_2;
QMenuBar *menuBar;
QToolBar *mainToolBar;
QStatusBar *statusBar;
void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
MainWindow->resize(541, 355);
centralWidget = new QWidget(MainWindow);
centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
tabWidget = new QTabWidget(centralWidget);
tabWidget->setObjectName(QString::fromUtf8("tabWidget"));
tabWidget->setGeometry(QRect(0, 0, 511, 291));
tabUnmount = new QWidget();
tabUnmount->setObjectName(QString::fromUtf8("tabUnmount"));
listWidget = new QListWidget(tabUnmount);
listWidget->setObjectName(QString::fromUtf8("listWidget"));
listWidget->setGeometry(QRect(10, 10, 321, 221));
btnUnmount = new QPushButton(tabUnmount);
btnUnmount->setObjectName(QString::fromUtf8("btnUnmount"));
btnUnmount->setGeometry(QRect(350, 60, 141, 27));
btnRefresh = new QPushButton(tabUnmount);
btnRefresh->setObjectName(QString::fromUtf8("btnRefresh"));
btnRefresh->setGeometry(QRect(350, 10, 141, 27));
tabWidget->addTab(tabUnmount, QString());
tab_2 = new QWidget();
tab_2->setObjectName(QString::fromUtf8("tab_2"));
tabWidget->addTab(tab_2, QString());
MainWindow->setCentralWidget(centralWidget);
menuBar = new QMenuBar(MainWindow);
menuBar->setObjectName(QString::fromUtf8("menuBar"));
menuBar->setGeometry(QRect(0, 0, 541, 25));
MainWindow->setMenuBar(menuBar);
mainToolBar = new QToolBar(MainWindow);
mainToolBar->setObjectName(QString::fromUtf8("mainToolBar"));
MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar);
statusBar = new QStatusBar(MainWindow);
statusBar->setObjectName(QString::fromUtf8("statusBar"));
MainWindow->setStatusBar(statusBar);
retranslateUi(MainWindow);
tabWidget->setCurrentIndex(0);
QMetaObject::connectSlotsByName(MainWindow);
} // setupUi
void retranslateUi(QMainWindow *MainWindow)
{
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "TC Utils", 0, QApplication::UnicodeUTF8));
btnUnmount->setText(QApplication::translate("MainWindow", "Unmount device", 0, QApplication::UnicodeUTF8));
btnRefresh->setText(QApplication::translate("MainWindow", "Get device list", 0, QApplication::UnicodeUTF8));
tabWidget->setTabText(tabWidget->indexOf(tabUnmount), QApplication::translate("MainWindow", "Tab 1", 0, QApplication::UnicodeUTF8));
tabWidget->setTabText(tabWidget->indexOf(tab_2), QApplication::translate("MainWindow", "Tab 2", 0, QApplication::UnicodeUTF8));
} // retranslateUi
};
namespace Ui {
class MainWindow: public Ui_MainWindow {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_MAINWINDOW_H

217
tcutils/utils.cpp Normal file
View File

@ -0,0 +1,217 @@
#include "utils.h"
Utils::Utils()
{
}
int Utils::getMountList(void *wtsChannel, QList<QListWidgetItem *> *itemList)
{
QListWidgetItem *item;
STREAM s;
quint32 bytesToSend;
quint32 bytesWritten;
quint32 bytesRead;
quint32 cmdLen;
quint32 cmd;
int rv;
int i;
int nentries;
char buf[2048];
if (!wtsChannel)
return -1;
qstream_new(s, 1024 * 8);
/*
* command format:
* 4 bytes cmd_len length of this command
* 1 byte cmd TCU_CMD_GET_MOUNT_LIST
*/
/* setup command */
qstream_wr_u32(&s, 1);
qstream_wr_u8(&s, TCU_CMD_GET_MOUNT_LIST);
bytesToSend = 5;
/* send command */
rv = WTSVirtualChannelWrite(wtsChannel, s.data, bytesToSend, &bytesWritten);
if (rv)
{
QMessageBox::information(NULL, "Get device list", "\nError sending "
"command to client");
return -1;
}
qstream_set_pos(&s, 0); /* reuse stream */
/* get response */
/*
* response format
* 4 bytes cmd_len length of this command
* 4 bytes cmd TCU_CMD_GET_MOUNT_LIST
* 1 byte nentries number of entries in this pkt
* n bytes entry_list nentries null terminated strings
*/
rv = WTSVirtualChannelRead(wtsChannel, 1000 * 5, s.data, 1024 * 8, &bytesRead);
if (rv == 0 || bytesRead == 0)
goto error;
/* did we get the entire cmd? */
qstream_rd_u32(&s, cmdLen);
if (cmdLen != bytesRead - 4)
goto error;
/* did we get the right response? */
qstream_rd_u32(&s, cmd);
if (cmd != TCU_CMD_GET_MOUNT_LIST)
goto error;
qstream_rd_u8(&s, nentries);
if (nentries == 0)
goto done;
for (i = 0; i < nentries; i++)
{
strcpy(buf, s.pos);
qstream_inc_pos(&s, strlen(buf) + 1);
item = new QListWidgetItem;
item->setText(QString(buf));
itemList->append(item);
}
done:
qstream_free(&s);
return 0;
error:
qstream_free(&s);
return -1;
}
int Utils::unmountDevice(void *wtsChannel, QString device, QStatusBar *statusBar)
{
STREAM s;
quint32 bytesRead;
quint32 cmdLen;
quint32 cmd;
quint32 bytesWritten;
int bytesToSend;
int rv;
int seconds = 0;
char status;
char* buf;
if (!wtsChannel)
return -1;
qstream_new(s, 1024);
buf = device.toAscii().data();
/*
* command format:
* 4 bytes cmd_len length of this command
* 4 bytes cmd TCU_CMD_UNMOUNT_DEVICE
* n bytes device null terminated device name
*/
/* setup command */
bytesToSend = 4 + 4 + device.count() + 1;
qstream_wr_u32(&s, bytesToSend - 4);
qstream_wr_u32(&s, TCU_CMD_UNMOUNT_DEVICE);
strcpy(s.pos, buf);
/* send command */
rv = WTSVirtualChannelWrite(wtsChannel, s.data, bytesToSend, &bytesWritten);
if (rv)
{
QMessageBox::information(NULL, "Unmount device", "\nError sending "
"command to client");
return -1;
}
qstream_set_pos(&s, 0); /* reuse stream */
/* get response */
/*
* command format
* 4 bytes cmd_len number of bytes in this pkt
* 4 bytes cmd TCU_CMD_UNMOUNT_DEVICE
* 1 byte status operation status code
*/
while (1)
{
rv = WTSVirtualChannelRead(wtsChannel, 1000 * 1, s.data, 1024, &bytesRead);
if (rv == 0)
goto error;
if (bytesRead)
break;
statusBar->showMessage("Waiting for client to unmount device: " +
QString::number(++seconds) + " seconds", 30000);
}
statusBar->showMessage("");
/* did we get the entire pkt? */
qstream_rd_u32(&s, cmdLen);
if (cmdLen != bytesRead - 4)
goto error;
/* did we get the right response? */
qstream_rd_u32(&s, cmd);
if (cmd != TCU_CMD_UNMOUNT_DEVICE)
goto error;
/* get status */
qstream_rd_u8(&s, status);
switch(status)
{
case UMOUNT_SUCCESS:
goto done;
break;
case UMOUNT_BUSY:
QMessageBox::information(NULL, "Unmount error", "\nCannot unmount device "
"because it is in use");
break;
case UMOUNT_NOT_MOUNTED:
QMessageBox::information(NULL, "Unmount error", "\nCannot unmount device "
"because it is not mounted");
break;
case UMOUNT_OP_NOT_PERMITTED:
QMessageBox::information(NULL, "Unmount error", "\nOperation not "
"permitted. The device may be in use");
break;
case UMOUNT_PERMISSION_DENIED:
QMessageBox::information(NULL, "Unmount error", "\nYou don't have "
"permission to unmount this device");
break;
case UMOUNT_UNKNOWN:
QMessageBox::information(NULL, "Unmount error", "Cannot unmount "
"device, an unknown error has occurred. The "
"drive may be in use or you do not have "
"permission to unmount it");
break;
}
goto error;
done:
qstream_free(&s);
return 0;
error:
qstream_free(&s);
return -1;
}

150
tcutils/utils.h Normal file
View File

@ -0,0 +1,150 @@
#ifndef UTILS_H
#define UTILS_H
#include <QDebug>
#include <QListWidgetItem>
#include <QMessageBox>
#include <QStatusBar>
#include <xrdpapi.h>
/*
* stream definition and macros to access them;
* all definitions default to little endian
*/
typedef struct stream
{
char* data; /* holds stream data */
char* pos; /* current read/write position */
int size; /* number of bytes in data */
} STREAM;
#define qstream_new(_s, _size) \
do \
{ \
(_s).data = (char *) malloc(_size); \
(_s).pos = (_s).data; \
(_s).size = (_size); \
} \
while (0)
#define qstream_new_zero(_s, _size) \
do \
{ \
(_s).data = (char *) calloc((_size), 1); \
(_s).pos = (_s).data; \
(_s).size = (_size); \
} \
while (0)
#define qstream_free(_s) \
do \
{ \
if ((_s)->data) \
free((_s)->data); \
} \
while (0)
#define qstream_set_pos(_s, _p) \
do \
{ \
(_s)->pos = (_s)->data + (_p); \
} \
while (0)
#define qstream_inc_pos(_s, _v) \
do \
{ \
(_s)->pos += (_v); \
} \
while (0)
#define qstream_rd_u8(_s, _v) \
do \
{ \
(_v) = *((unsigned char *) ((_s)->pos)); \
(_s)->pos++; \
} \
while (0)
#define qstream_rd_u16(_s, _v) \
do \
{ \
(_v) = (unsigned short) \
( \
(*((unsigned char *) ((_s)->pos + 0)) << 0) | \
(*((unsigned char *) ((_s)->pos + 1)) << 8) \
); \
(_s)->pos += 2; \
} while (0)
#define qstream_rd_u32(_s, _v) \
do \
{ \
(_v) = (unsigned int) \
( \
(*((unsigned char *) ((_s)->pos + 0)) << 0) | \
(*((unsigned char *) ((_s)->pos + 1)) << 8) | \
(*((unsigned char *) ((_s)->pos + 2)) << 16) | \
(*((unsigned char *) ((_s)->pos + 3)) << 24) \
); \
(_s)->pos += 4; \
} while (0)
#define qstream_wr_u8(_s, _v) \
do \
{ \
*((_s)->pos) = (unsigned char) (_v); \
(_s)->pos++; \
} while (0)
#define qstream_wr_u16(_s, _v) \
do \
{ \
*((_s)->pos) = (unsigned char) ((_v) >> 0); \
(_s)->pos++; \
*((_s)->pos) = (unsigned char) ((_v) >> 8); \
(_s)->pos++; \
} while (0)
#define qstream_wr_u32(_s, _v) \
do \
{ \
*((_s)->pos) = (unsigned char) ((_v) >> 0); \
(_s)->pos++; \
*((_s)->pos) = (unsigned char) ((_v) >> 8); \
(_s)->pos++; \
*((_s)->pos) = (unsigned char) ((_v) >> 16); \
(_s)->pos++; \
*((_s)->pos) = (unsigned char) ((_v) >> 24); \
(_s)->pos++; \
} while (0)
/* list of commands we support; this list should match the one in */
/* NeutrinoRDP channels/tcutils/tcutils_main.h */
enum TCU_COMMANDS
{
TCU_CMD_GET_MOUNT_LIST = 1,
TCU_CMD_UNMOUNT_DEVICE
};
/* umount error codes */
enum TCU_UMOUNT_ERROR
{
UMOUNT_SUCCESS = 0,
UMOUNT_BUSY,
UMOUNT_NOT_MOUNTED,
UMOUNT_OP_NOT_PERMITTED,
UMOUNT_PERMISSION_DENIED,
UMOUNT_UNKNOWN
};
class Utils
{
public:
Utils();
static int getMountList(void *wtsChannel, QList<QListWidgetItem *> *itemList);
static int unmountDevice(void *wtsChannel, QString device, QStatusBar *statusBar);
};
#endif // UTILS_H