Subversion Repositories OpenInventory

Rev

Rev 241 | Rev 243 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 241 Rev 242
Line 1... Line 1...
1
#include "wmithread.h"
1
#include "wmithread.h"
2
2
3
WmiThread::WmiThread(QObject *parent) :
3
WmiThread::WmiThread(QObject *parent) :
4
    QThread(parent)
4
    QThread(parent)
5
{
5
{
6
    connect(&process, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandartProcessOutput()));
-
 
7
    connect(&process, SIGNAL(readyReadStandardError()), this, SLOT(readStandartProcessError()));
6
    process.moveToThread(this);
8
    mutex.lock();
7
    mutex.lock();
9
    stopped = false;
8
    stopped = false;
10
    mutex.unlock();
9
    mutex.unlock();
-
 
10
    connect(&process, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandartProcessOutput()));
-
 
11
    connect(&process, SIGNAL(readyReadStandardError()), this, SLOT(readStandartProcessError()));
11
12
12
13
13
14
14
}
15
}
15
16
16
void WmiThread::run(){
17
void WmiThread::run(){
17
18
18
19
19
20
-
 
21
20
    QString query_string;
22
    QString query_string;
21
    error = false; //ñáðîñèì ôëàã îøèáêè
23
    error = false; //ñáðîñèì ôëàã îøèáêè
22
    query_string = tr("wmic -U ");
24
    query_string = tr("wmic -U ");
23
    query_string.append(user_name);
25
    query_string.append(user_name);
24
    query_string.append(tr("%"));
26
    query_string.append(tr("%"));
Line 26... Line 28...
26
    query_string.append(tr(" //"));
28
    query_string.append(tr(" //"));
27
    query_string.append(host);
29
    query_string.append(host);
28
    query_string.append(tr(" \""));
30
    query_string.append(tr(" \""));
29
    query_string.append(wmi_string);
31
    query_string.append(wmi_string);
30
    query_string.append(tr("\""));
32
    query_string.append(tr("\""));
31
    process.start(query_string);
33
    // process.start(query_string);
32
-
 
-
 
34
    process.start("ls\n");
33
    while (!stopped);
35
//    while (!stopped) {;}
34
  //  exec();
36
    exec();
-
 
37
   // quit();
35
}
38
}
36
39
37
void WmiThread::stop(){
40
void WmiThread::stop(){
38
      mutex.lock();
41
      mutex.lock();
39
      stopped = true;
42
      stopped = true;
40
      mutex.unlock();
43
      mutex.unlock();
41
}
44
}
42
45
43
void WmiThread::readStandartProcessOutput(){
46
void WmiThread::readStandartProcessOutput(){
44
p_buffer = process.readAllStandardOutput();
47
p_buffer = process.readAllStandardOutput();
-
 
48
 qDebug() << QString(p_buffer);
45
mutex.lock();
49
mutex.lock();
46
stopped = true;
50
stopped = true;
47
mutex.unlock();
51
mutex.unlock();
-
 
52
process.close();
-
 
53
exit();
48
}
54
}
49
55
50
void WmiThread::readStandartProcessError(){
56
void WmiThread::readStandartProcessError(){
51
p_buffer = process.readAllStandardError();
57
p_buffer = process.readAllStandardError();
52
error = true; // åñëè îøèáêà, óñòàíîâèì ôëàã îøèáêè âûïîëíåíèÿ WMI-çàïðîñà
58
error = true; // åñëè îøèáêà, óñòàíîâèì ôëàã îøèáêè âûïîëíåíèÿ WMI-çàïðîñà