package com.saki.qq.wtlogin.unpack;

import com.saki.tools.Zip;

public abstract class RecviePack {
    protected byte[] data;
    private byte[] allData;
    public Info info;

    public RecviePack(byte[] data) {
        this.data = data;
    }

    protected byte[] checkZip(byte[] bin) {
        if (bin.length >= 2) {
            if (bin[0] == (byte) 0x78 && bin[1] == (byte) 0xDA) {
                return Zip.Inflater(bin);
            } else if (bin[0] == (byte) 0x01 && bin[1] == (byte) 0x78) {
                byte[] mbin = new byte[bin.length - 1];
                System.arraycopy(bin, 1, mbin, 0, mbin.length);
                return Zip.Inflater(mbin);
            }
        }
        return bin;
    }

    public byte[] getData() {
        return allData;
    }

    public RecviePack setData(byte[] data) {
        this.allData = data;
        return this;
    }

    public RecviePack setInfo(Info info) {
        this.info = info;
        return this;
    }
}
