#ifndef PCAPWIN_H
#define PCAPWIN_H

#include "basewin.h"
#define HAVE_REMOTE
#include "pcap.h"
#include <QThread>

#define LINE_LEN 16

class PcapThread : public QThread {
    Q_OBJECT
public:
    explicit PcapThread(pcap *pcap);
    ~PcapThread() {
        pcap_close(pcap);
    }
    pcap *pcap;
    std::atomic<char> status{0};
protected:
    void run();
signals:
    void onMsg(const QString &);
    void onError(char *);
};

class PcapWin : public BaseWin {
    Q_OBJECT
public:
    static PcapWin *newIns(QByteArray &, QWidget *);

    explicit PcapWin(pcap *, pcap *, QWidget *parent = nullptr);
    ~PcapWin() {
        pcap_close(pcap);
        thd->status = 2;
    }
    PcapThread *thd{0};
    pcap *pcap;
};

#endif // PCAPWIN_H
