Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 241 → Rev 242

/trunk/DBViewer/mainwindow.h
128,7 → 128,7
 
 
 
WmiThread * wmiThread;
WmiThread wmiThread;
/////// QSqlTableModel * sql_mogel;
 
MyModel * sql_mogel;
/trunk/DBViewer/wmithread.cpp
3,11 → 3,12
WmiThread::WmiThread(QObject *parent) :
QThread(parent)
{
connect(&process, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandartProcessOutput()));
connect(&process, SIGNAL(readyReadStandardError()), this, SLOT(readStandartProcessError()));
process.moveToThread(this);
mutex.lock();
stopped = false;
mutex.unlock();
connect(&process, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandartProcessOutput()));
connect(&process, SIGNAL(readyReadStandardError()), this, SLOT(readStandartProcessError()));
 
 
 
17,6 → 18,7
 
 
 
 
QString query_string;
error = false; //ñáðîñèì ôëàã îøèáêè
query_string = tr("wmic -U ");
28,10 → 30,11
query_string.append(tr(" \""));
query_string.append(wmi_string);
query_string.append(tr("\""));
process.start(query_string);
 
while (!stopped);
// exec();
// process.start(query_string);
process.start("ls\n");
// while (!stopped) {;}
exec();
// quit();
}
 
void WmiThread::stop(){
42,9 → 45,12
 
void WmiThread::readStandartProcessOutput(){
p_buffer = process.readAllStandardOutput();
qDebug() << QString(p_buffer);
mutex.lock();
stopped = true;
mutex.unlock();
process.close();
exit();
}
 
void WmiThread::readStandartProcessError(){
/trunk/DBViewer/wmithread.h
4,6 → 4,7
#include <QThread>
#include <QProcess>
#include <QMutex>
#include <QDebug>
 
class WmiThread : public QThread
{
18,11 → 19,17
QByteArray buffer(){return p_buffer;}
void clearBuffer(){p_buffer.clear();}
bool isError(){return error;}
bool isStopped(){
mutex.lock();
return stopped;
mutex.unlock();
 
};
void setWmiString(QString new_wmi_string){wmi_string = new_wmi_string;}
private:
volatile bool stopped;
volatile bool error;
QProcess process;
QProcess process;
QString host;
QString user_name;
QString password;
/trunk/DBViewer/mainwindow.cpp
129,7 → 129,7
// buildReport(true);
 
all_reading = false; // íåò ïðî÷èòàííûõ äàííûõ èç ïðîöåññà
wmiThread = new WmiThread(this);
// wmiThread = new WmiThread(this);
 
}
 
1821,19 → 1821,25
TWmiVideoCard MainWindow::getWmiVideoGard(QString host, QString user_name, QString password){
TWmiVideoCard result;
bool ok;
wmiThread->setHost(host); // çàäàåì õîñò
wmiThread->setUser(user_name);//çàäàåì èìÿ ïîëüçîâàòåëÿ
wmiThread->setPassword( password);
wmiThread->start(QThread::NormalPriority);
wmiThread->setWmiString(tr("select * from Win32_ComputerSystem"));
ok = wmiThread->wait(10000);
wmiThread.moveToThread(&wmiThread);
wmiThread.setHost(host); // çàäàåì õîñò
wmiThread.setUser(user_name);//çàäàåì èìÿ ïîëüçîâàòåëÿ
wmiThread.setPassword( password);
wmiThread.setWmiString(tr("select * from Win32_ComputerSystem"));
wmiThread.start(QThread::NormalPriority);
//for (;;) {if (wmiThread.isStopped()) break;}
int t;
t++;
 
 
ok = wmiThread.wait(10000);
if (ok){
int m;
m++;
}
else {
wmiThread->stop();
ok = wmiThread->wait(10000);
wmiThread.stop();
ok = wmiThread.wait(10000);
int k;
k++;
}