Subversion Repositories OpenInventory

Rev

Rev 241 | Rev 243 | 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
{
242 pingvin 6
    process.moveToThread(this);
241 pingvin 7
    mutex.lock();
8
    stopped = false;
9
    mutex.unlock();
242 pingvin 10
    connect(&process, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandartProcessOutput()));
11
    connect(&process, SIGNAL(readyReadStandardError()), this, SLOT(readStandartProcessError()));
240 pingvin 12
 
13
 
14
 
15
}
16
 
17
void WmiThread::run(){
18
 
241 pingvin 19
 
20
 
242 pingvin 21
 
241 pingvin 22
    QString query_string;
23
    error = false; //  
24
    query_string = tr("wmic -U ");
25
    query_string.append(user_name);
26
    query_string.append(tr("%"));
27
    query_string.append(password);
28
    query_string.append(tr(" //"));
29
    query_string.append(host);
30
    query_string.append(tr(" \""));
31
    query_string.append(wmi_string);
32
    query_string.append(tr("\""));
242 pingvin 33
    // process.start(query_string);
34
    process.start("ls\n");
35
//    while (!stopped) {;}
36
    exec();
37
   // quit();
240 pingvin 38
}
39
 
40
void WmiThread::stop(){
41
      mutex.lock();
42
      stopped = true;
43
      mutex.unlock();
44
}
45
 
46
void WmiThread::readStandartProcessOutput(){
47
p_buffer = process.readAllStandardOutput();
242 pingvin 48
 qDebug() << QString(p_buffer);
241 pingvin 49
mutex.lock();
50
stopped = true;
51
mutex.unlock();
242 pingvin 52
process.close();
53
exit();
240 pingvin 54
}
55
 
56
void WmiThread::readStandartProcessError(){
57
p_buffer = process.readAllStandardError();
241 pingvin 58
error = true; //  ,     WMI-
240 pingvin 59
}