Subversion Repositories OpenInventory

Rev

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
 
248 pingvin 27
 
241 pingvin 28
    QString query_string;
248 pingvin 29
//    error = false; //  
241 pingvin 30
    query_string = tr("wmic -U ");
31
    query_string.append(user_name);
249 pingvin 32
    query_string.append("%\"");
241 pingvin 33
    query_string.append(password);
249 pingvin 34
    query_string.append("\"");
241 pingvin 35
    query_string.append(tr(" //"));
36
    query_string.append(host);
37
    query_string.append(tr(" \""));
38
    query_string.append(wmi_string);
39
    query_string.append(tr("\""));
242 pingvin 40
    // process.start(query_string);
248 pingvin 41
//    process.start("ls\n");
242 pingvin 42
//    while (!stopped) {;}
243 pingvin 43
 
249 pingvin 44
    qDebug() << query_string;
248 pingvin 45
    woker.setProcessString(query_string);
243 pingvin 46
    woker.startProcess();
47
 
247 pingvin 48
    loop.exec();
248 pingvin 49
    p_buffer = woker.workBuffer();
240 pingvin 50
}
51
 
52
void WmiThread::stop(){
53
      mutex.lock();
54
      stopped = true;
55
      mutex.unlock();
56
}
57
 
58
void WmiThread::readStandartProcessOutput(){
59
p_buffer = process.readAllStandardOutput();
242 pingvin 60
 qDebug() << QString(p_buffer);
241 pingvin 61
mutex.lock();
62
stopped = true;
63
mutex.unlock();
242 pingvin 64
process.close();
65
exit();
240 pingvin 66
}
67
 
68
void WmiThread::readStandartProcessError(){
69
p_buffer = process.readAllStandardError();
241 pingvin 70
error = true; //  ,     WMI-
240 pingvin 71
}
243 pingvin 72
 
73
 
74
void WmiThread::wokerIsStopped(){
75
exit();
76
}