Хранилища Subversion OpenInventory

Редакция

Редакция 249 | Редакция 255 | К новейшей редакции | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS

Редакция 249 Редакция 250
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
                           // static QTextCodec *codec = QTextCodec::codecForName("cp1251");
-
 
33
                           // static QTextCodec *codecUTF = QTextCodec::codecForName("utf8");
-
 
34
                           // QTextCodec::setCodecForTr(codecUTF);
-
 
35
                            return QString(tr(p_buffer));
32
                            return QString(tr(p_buffer));
36
                           // QTextCodec::setCodecForTr(codec);
-
 
-
 
33
37
                            }
34
                            }
38
volatile bool stopped;
35
volatile bool stopped;
39
private:
36
private:
40
37
41
    volatile bool error;
38
    volatile bool error;
42
39
43
   QProcess process;
40
   QProcess process;
44
    QString host;
41
    QString host;
45
    QString user_name;
42
    QString user_name;
46
    QString password;
43
    QString password;
47
    QMutex mutex;
44
    QMutex mutex;
48
    QByteArray p_buffer; //çäåñü áóäåì õðàíèòü äàííûå, ñ÷èòàííûå èç ñòàíäàðòíîãî ïîòîêà äëÿ ÷òåíèÿ (ïðîöåññà)
45
    QByteArray p_buffer; //çäåñü áóäåì õðàíèòü äàííûå, ñ÷èòàííûå èç ñòàíäàðòíîãî ïîòîêà äëÿ ÷òåíèÿ (ïðîöåññà)
49
    QString wmi_string;  //çäåñü áóäåì õðàíèòü wmi-çàïðîñ
46
    QString wmi_string;  //çäåñü áóäåì õðàíèòü wmi-çàïðîñ
50
47
51
signals:
48
signals:
52
49
53
public slots:
50
public slots:
54
    void readStandartProcessOutput();
51
    void readStandartProcessOutput();
55
    void readStandartProcessError();
52
    void readStandartProcessError();
56
    void wokerIsStopped();
53
 //   void wokerIsStopped();
57
54
58
private slots:
55
private slots:
59
56
60
57
61
58
62
};
59
};
63
60
64
#endif // WMITHREAD_H
61
#endif // WMITHREAD_H
65
 
62