Хранилища Subversion OpenInventory

Редакция

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

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