Subversion Repositories OpenInventory

Rev

Rev 255 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
239 pingvin 1
#ifndef WMITHREAD_H
2
#define WMITHREAD_H
3
 
4
#include <QThread>
5
#include <QProcess>
6
#include <QMutex>
242 pingvin 7
#include <QDebug>
243 pingvin 8
#include <QEventLoop>
9
#include "woker.h"
239 pingvin 10
 
11
class WmiThread : public QThread
12
{
13
    Q_OBJECT
14
public:
15
    explicit WmiThread(QObject *parent = 0);
16
    void run();
17
    void stop();
18
    void setHost(QString new_host){host = new_host;}
19
    void setUser(QString new_user){user_name = new_user;}
20
    void setPassword(QString new_password){password = new_password;}
21
    QByteArray buffer(){return p_buffer;}
22
    void clearBuffer(){p_buffer.clear();}
241 pingvin 23
    bool isError(){return error;}
242 pingvin 24
    bool isStopped(){
25
        mutex.lock();
26
        return stopped;
27
        mutex.unlock();
28
 
248 pingvin 29
                        }
241 pingvin 30
    void setWmiString(QString new_wmi_string){wmi_string = new_wmi_string;}
248 pingvin 31
    QString resultString(){
250 pingvin 32
 
255 pingvin 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;
248 pingvin 41
                            }
243 pingvin 42
volatile bool stopped;
239 pingvin 43
private:
243 pingvin 44
 
239 pingvin 45
    volatile bool error;
243 pingvin 46
 
242 pingvin 47
   QProcess process;
239 pingvin 48
    QString host;
49
    QString user_name;
50
    QString password;
51
    QMutex mutex;
52
    QByteArray p_buffer; //   ,       ()
241 pingvin 53
    QString wmi_string;  //   wmi-
256 pingvin 54
    QEventLoop *loop;
239 pingvin 55
 
56
signals:
256 pingvin 57
    void stop_now();
239 pingvin 58
 
59
public slots:
241 pingvin 60
    void readStandartProcessOutput();
61
    void readStandartProcessError();
250 pingvin 62
 //   void wokerIsStopped();
239 pingvin 63
 
64
private slots:
65
 
66
 
241 pingvin 67
 
239 pingvin 68
};
69
 
70
#endif // WMITHREAD_H