Редакция 248 | Редакция 250 | К новейшей редакции | Только различия | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 248 | Редакция 249 | ||
---|---|---|---|
1 | #ifndef WMITHREAD_H
|
1 | #ifndef WMITHREAD_H
|
2 | #define WMITHREAD_H
|
2 | #define WMITHREAD_H
|
3 | 3 | ||
4 | #include <QThread>
|
4 | #include <QThread>
|
5 | #include <QProcess>
|
5 | #include <QProcess>
|
6 | #include <QMutex>
|
6 | #include <QMutex>
|
7 | #include <QDebug>
|
7 | #include <QDebug>
|
8 | #include <QEventLoop>
|
8 | #include <QEventLoop>
|
9 | #include "woker.h"
|
9 | #include "woker.h"
|
10 | 10 | ||
11 | class WmiThread : public QThread |
11 | class WmiThread : public QThread |
12 | {
|
12 | {
|
13 | Q_OBJECT |
13 | Q_OBJECT |
14 | public: |
14 | public: |
15 | explicit WmiThread(QObject *parent = 0); |
15 | explicit WmiThread(QObject *parent = 0); |
16 | void run(); |
16 | void run(); |
17 | void stop(); |
17 | void stop(); |
18 | void setHost(QString new_host){host = new_host;} |
18 | void setHost(QString new_host){host = new_host;} |
19 | void setUser(QString new_user){user_name = new_user;} |
19 | void setUser(QString new_user){user_name = new_user;} |
20 | void setPassword(QString new_password){password = new_password;} |
20 | void setPassword(QString new_password){password = new_password;} |
21 | QByteArray buffer(){return p_buffer;} |
21 | QByteArray buffer(){return p_buffer;} |
22 | void clearBuffer(){p_buffer.clear();} |
22 | void clearBuffer(){p_buffer.clear();} |
23 | bool isError(){return error;} |
23 | bool isError(){return error;} |
24 | bool isStopped(){ |
24 | bool isStopped(){ |
25 | mutex.lock(); |
25 | mutex.lock(); |
26 | return stopped; |
26 | return stopped; |
27 | mutex.unlock(); |
27 | mutex.unlock(); |
28 | 28 | ||
29 | }
|
29 | }
|
30 | void setWmiString(QString new_wmi_string){wmi_string = new_wmi_string;} |
30 | void setWmiString(QString new_wmi_string){wmi_string = new_wmi_string;} |
31 | QString resultString(){ |
31 | QString resultString(){ |
32 | QTextCodec *codec = QTextCodec::codecForName("cp1251"); |
32 | // static QTextCodec *codec = QTextCodec::codecForName("cp1251");
|
33 | QTextCodec *codecUTF = QTextCodec::codecForName("utf8"); |
33 | // static QTextCodec *codecUTF = QTextCodec::codecForName("utf8");
|
34 | QTextCodec::setCodecForTr(codecUTF); |
34 | // QTextCodec::setCodecForTr(codecUTF);
|
35 | return QString(tr(p_buffer)); |
35 | return QString(tr(p_buffer)); |
36 | QTextCodec::setCodecForTr(codec); |
36 | // QTextCodec::setCodecForTr(codec);
|
37 | }
|
37 | }
|
38 | volatile bool stopped; |
38 | volatile bool stopped; |
39 | private: |
39 | private: |
40 | 40 | ||
41 | volatile bool error; |
41 | volatile bool error; |
42 | 42 | ||
43 | QProcess process;
|
43 | QProcess process;
|
44 | QString host;
|
44 | QString host;
|
45 | QString user_name;
|
45 | QString user_name;
|
46 | QString password;
|
46 | QString password;
|
47 | QMutex mutex;
|
47 | QMutex mutex;
|
48 | QByteArray p_buffer; //çäåñü áóäåì õðàíèòü äàííûå, ñ÷èòàííûå èç ñòàíäàðòíîãî ïîòîêà äëÿ ÷òåíèÿ (ïðîöåññà) |
48 | QByteArray p_buffer; //çäåñü áóäåì õðàíèòü äàííûå, ñ÷èòàííûå èç ñòàíäàðòíîãî ïîòîêà äëÿ ÷òåíèÿ (ïðîöåññà) |
49 | QString wmi_string; //çäåñü áóäåì õðàíèòü wmi-çàïðîñ |
49 | QString wmi_string; //çäåñü áóäåì õðàíèòü wmi-çàïðîñ |
50 | 50 | ||
51 | signals:
|
51 | signals:
|
52 | 52 | ||
53 | public slots: |
53 | public slots: |
54 | void readStandartProcessOutput(); |
54 | void readStandartProcessOutput(); |
55 | void readStandartProcessError(); |
55 | void readStandartProcessError(); |
56 | void wokerIsStopped(); |
56 | void wokerIsStopped(); |
57 | 57 | ||
58 | private slots: |
58 | private slots: |
59 | 59 | ||
60 | 60 | ||
61 | 61 | ||
62 | }; |
62 | }; |
63 | 63 | ||
64 | #endif // WMITHREAD_H
|
64 | #endif // WMITHREAD_H
|
65 | 65 |