Subversion Repositories OpenInventory

Rev

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

Rev 240 Rev 241
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
-
 
7
-
 
-
 
6
    connect(&process, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandartProcessOutput()));
-
 
7
    connect(&process, SIGNAL(readyReadStandardError()), this, SLOT(readStandartProcessError()));
-
 
8
    mutex.lock();
-
 
9
    stopped = false;
-
 
10
    mutex.unlock();
8
11
9
12
10
13
11
}
14
}
12
15
13
void WmiThread::run(){
16
void WmiThread::run(){
14
error = false; //ñáðîñèì ôëàã îøèáêè
-
 
15
17
-
 
18
-
 
19
-
 
20
    QString query_string;
-
 
21
    error = false; //ñáðîñèì ôëàã îøèáêè
-
 
22
    query_string = tr("wmic -U ");
-
 
23
    query_string.append(user_name);
-
 
24
    query_string.append(tr("%"));
-
 
25
    query_string.append(password);
-
 
26
    query_string.append(tr(" //"));
-
 
27
    query_string.append(host);
-
 
28
    query_string.append(tr(" \""));
-
 
29
    query_string.append(wmi_string);
-
 
30
    query_string.append(tr("\""));
-
 
31
    process.start(query_string);
-
 
32
-
 
33
    while (!stopped);
-
 
34
  //  exec();
16
}
35
}
17
36
18
void WmiThread::stop(){
37
void WmiThread::stop(){
19
      mutex.lock();
38
      mutex.lock();
20
      stopped = true;
39
      stopped = true;
21
      mutex.unlock();
40
      mutex.unlock();
22
}
41
}
23
42
24
void WmiThread::readStandartProcessOutput(){
43
void WmiThread::readStandartProcessOutput(){
25
p_buffer = process.readAllStandardOutput();
44
p_buffer = process.readAllStandardOutput();
-
 
45
mutex.lock();
-
 
46
stopped = true;
-
 
47
mutex.unlock();
26
}
48
}
27
49
28
void WmiThread::readStandartProcessError(){
50
void WmiThread::readStandartProcessError(){
29
p_buffer = process.readAllStandardError();
51
p_buffer = process.readAllStandardError();
30
error = true;
52
error = true; // åñëè îøèáêà, óñòàíîâèì ôëàã îøèáêè âûïîëíåíèÿ WMI-çàïðîñà
31
}
53
}