Subversion Repositories OpenInventory

Rev

Rev 246 | Rev 248 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
240 pingvin 1
#include "wmithread.h"
2
 
3
WmiThread::WmiThread(QObject *parent) :
4
    QThread(parent)
5
{
243 pingvin 6
  //  woker.moveToThread(this);
241 pingvin 7
    mutex.lock();
8
    stopped = false;
9
    mutex.unlock();
240 pingvin 10
 
243 pingvin 11
 //   connect(&process, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandartProcessOutput()));
12
 //   connect(&process, SIGNAL(readyReadStandardError()), this, SLOT(readStandartProcessError()));
240 pingvin 13
 
14
 
243 pingvin 15
 
240 pingvin 16
}
17
 
18
void WmiThread::run(){
19
 
241 pingvin 20
 
247 pingvin 21
   QEventLoop loop; // = new QEventLoop();
243 pingvin 22
    Woker woker; //      
241 pingvin 23
 
243 pingvin 24
    // connect(&woker, SIGNAL(workEnd()), this, SLOT(wokerIsStopped()));
247 pingvin 25
connect(&woker, SIGNAL(workEnd()), &loop, SLOT(quit()));
246 pingvin 26
 
243 pingvin 27
/*
241 pingvin 28
    QString query_string;
29
    error = false; //  
30
    query_string = tr("wmic -U ");
31
    query_string.append(user_name);
32
    query_string.append(tr("%"));
33
    query_string.append(password);
34
    query_string.append(tr(" //"));
35
    query_string.append(host);
36
    query_string.append(tr(" \""));
37
    query_string.append(wmi_string);
38
    query_string.append(tr("\""));
242 pingvin 39
    // process.start(query_string);
40
    process.start("ls\n");
41
//    while (!stopped) {;}
243 pingvin 42
 
246 pingvin 43
*/
243 pingvin 44
 
45
 
46
    woker.startProcess();
47
 
247 pingvin 48
    loop.exec();
240 pingvin 49
}
50
 
51
void WmiThread::stop(){
52
      mutex.lock();
53
      stopped = true;
54
      mutex.unlock();
55
}
56
 
57
void WmiThread::readStandartProcessOutput(){
58
p_buffer = process.readAllStandardOutput();
242 pingvin 59
 qDebug() << QString(p_buffer);
241 pingvin 60
mutex.lock();
61
stopped = true;
62
mutex.unlock();
242 pingvin 63
process.close();
64
exit();
240 pingvin 65
}
66
 
67
void WmiThread::readStandartProcessError(){
68
p_buffer = process.readAllStandardError();
241 pingvin 69
error = true; //  ,     WMI-
240 pingvin 70
}
243 pingvin 71
 
72
 
73
void WmiThread::wokerIsStopped(){
74
exit();
75
}