package TX_OtherClass;

import java.io.IOException;
import java.net.ConnectException;
import java.net.MalformedURLException;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.nio.ByteBuffer;
import java.util.ArrayList;

import AdThreeAnalysis.AnalysisAd;
import TX_OtherClass.o;
import zip.d;

public class ParessAd {
    public String i_url;
    public long j;
    public long k;
    public long l;
    public long m;
    public long n;
    public long o;
    public long p;
    public int q;
    private long r_time;
    public JceStruct f ;
    private ServerInfo s;
    volatile boolean c = false;
	
	 
	    public final void paressAddata_(int i, String str, byte[] bArr, Exception exception) {
	        if (!this.c) {
	            if (i == 0) {
	                int i2;
	                if (str == null || !str.toLowerCase().startsWith("text")) {
	                    i2 = 0;
	                } else {
	                    i2 = 1;
	                }
	                if (i2 != 0) {
	                    String str2 = "";
	                    if (bArr != null) {
	                        str2 = new String(bArr);
	                    }
	                   // a(-803, new Exception(str2), null);
	                    return;
	                } else if (bArr == null || bArr.length <= 0) {
	                  //  a(-840, null, null);
	                    return;
	                } else {
	                    byte[] bArr2 = null;
	                    int i3;
	                    ResponseCommand unPackageResponse;
	                    ResponseHead responseHead;
	                    this.o = (long) bArr.length;
	                    this.m = System.currentTimeMillis();
	                    int[] iArr = new int[1];
	                    if (bArr != null) {
	                        try {
	                            if (bArr.length != 0) {
	                                ByteBuffer wrap = ByteBuffer.wrap(bArr);
	                                if (wrap.get() != (byte)19) {
	                                    bArr2 = null;
	                                    
	                                } else if (wrap.getInt() != bArr.length) {
	                                    bArr2 = null;
	                                } else {
	                                    wrap.getShort();
	                                    if ((wrap.getShort() & 65535) != 65281) {
	                                        bArr2 = null;
	                                    } else {
	                                        wrap.getShort();
	                                        i2 = wrap.getShort() & 65535;
	                                        if (i2 != 0) {
	                                            iArr[0] = i2;
	                                            bArr2 = null;
	                                        } else {
	                                            wrap.getLong();
	                                            i2 = wrap.getInt();
	                                            if ((i2 & 2) <= 0) {
	                                                i2 = 0;
	                                            } else if ((i2 & 16) > 0) {
	                                                i2 = 1;
	                                            } else {
	                                                iArr[0] = -867;
	                                                bArr2 = null;
	                                            }
	                                            if (wrap.getInt() != 10012) {
	                                                bArr2 = null;
	                                            } else {
	                                                wrap.getLong();
	                                                wrap.position(wrap.position() + 32);
	                                                wrap.get();
	                                                wrap.position(wrap.position() + 10);
	                                                wrap.get();
	                                                wrap.position((wrap.getShort() & 65535) + wrap.position());
	                                                i3 = wrap.getShort() & 65535;
	                                                wrap.position(wrap.position() + i3);
	                                                i3 = (i3 + 2) + 83;
	                                                int i4 = wrap.getInt();
	                                                int i5 = i3 + 4;
	                                                if (wrap.get(bArr.length - 1) != (byte) 3) {
	                                                    iArr[0] = -869;
	                                                    bArr2 = null;
	                                                } else {
	                                                    int length = (bArr.length - i5) - 1;
	                                                    if (length <= 0) {
	                                                        iArr[0] = -868;
	                                                        bArr2 = null;
	                                                    } else {
	                                                        Object obj = new byte[length];
	                                                        System.arraycopy(bArr, i5, obj, 0, length);
	                                                        if (i2 != 0) {
	                                                            obj = d.b((byte[]) obj);//解压数据
	                                                            if (obj == null || ((byte[]) obj).length != i4) {
	                                                                iArr[0] = -871;
	                                                                bArr2 = null;
	                                                            }
	                                                        }
	                                                        Object obj2 = obj;
	                                                        ByteBuffer wrap2 = ByteBuffer.wrap((byte[]) obj2);
	                                                        length = wrap2.position() + 16;
	                                                        if (wrap2.get() != (byte) 38) {
	                                                            iArr[0] = -869;
	                                                            bArr2 = null;
	                                                        } else if (wrap2.get(((byte[]) obj2).length - 1) != (byte) 40) {
	                                                            iArr[0] = -869;
	                                                            bArr2 = null;
	                                                        } else {
	                                                            i4 = (((byte[]) obj2).length - length) - 1;
	                                                            if (i4 <= 0) {
	                                                                iArr[0] = -869;
	                                                                bArr2 = null;
	                                                            } else {
	                                                                bArr2 = new byte[i4];
	                                                                System.arraycopy(obj2, length, bArr2, 0, i4);
	                                                            }
	                                                        }
	                                                    }
	                                                }
	                                            }
	                                        }
	                                    }
	                                }
	                                
	                                //解析第一层结构
	                                unPackageResponse = ProtocolPackage.unPackageResponse(bArr2);
	                                if (unPackageResponse == null) {
	                                    return;
	                                }
	                              
	                                //解析第二层结构
	                                JceStruct unPackageJceResponse = ProtocolPackage.unPackageJceResponse(this.f, unPackageResponse.body, null);
	                                if (unPackageJceResponse == null) {
	                                    return;
	                                }
	                                
	                                //解析第三层结构
	                                ArrayList retad= new ArrayList();
	                                AnalysisAd analysisad = new AnalysisAd();
	                                retad = analysisad.GetAd(unPackageJceResponse);
	                                
	                                
	                                
	                                
	                  
	                            }
	                        } catch (Throwable th) {
	                            bArr2 = null;
	                        }
	                    }
	                    return;
	                }
	            }
	            if (exception != null) {
	                exception.printStackTrace();
	                if (exception instanceof MalformedURLException) {
	                    i = -820;
	                } else if (exception instanceof ConnectException) {
	                    i = -824;
	                } else if (exception instanceof SocketTimeoutException) {
	                    i = -823;
	                } else if (exception instanceof SocketException) {
	                    i = -825;
	                } else if (exception instanceof IOException) {
	                    i = -826;
	                } else {
	                    i = -827;
	                }
	            }
	            //a(i, exception, null);
	        }
	    }
	    
	    public final void paressAddata(int i, String str, byte[] bArr, Exception exception) {
	        if (!this.c) {
	            if (i == 0) {
	                int i2;
	                if (str == null || !str.toLowerCase().startsWith("text")) {
	                    i2 = 0;
	                } else {
	                    i2 = 1;
	                }
	                if (i2 != 0) {
	                    String str2 = "";
	                    if (bArr != null) {
	                        str2 = new String(bArr);
	                    }
	                   // a(-803, new Exception(str2), null);
	                    return;
	                } else if (bArr == null || bArr.length <= 0) {
	                  //  a(-840, null, null);
	                    return;
	                } else {
	                    byte[] bArr2 = null;
	                    int i3;
	                    ResponseCommand unPackageResponse;
	                    ResponseHead responseHead;
	                    this.o = (long) bArr.length;
	                    this.m = System.currentTimeMillis();
	                    int[] iArr = new int[1];
	                    if (bArr != null) {
	                        try {
	                            if (bArr.length != 0) {
	                                ByteBuffer wrap = ByteBuffer.wrap(bArr);
	                                if (wrap.get() != (byte) 19) {
	                                    bArr2 = null;
	                                } if (wrap.getInt() != bArr.length) {
	                          
	                                    wrap.getShort();
	                                    if (true) {
	                                
	                                        wrap.getShort();
	                                        i2 = wrap.getShort() & 65535;
	                                        if (i2 != 0) {
	                                            iArr[0] = i2;
	                                          
	                                        
	                                            wrap.getLong();
	                                            i2 = wrap.getInt();
	                                            if ((i2 & 2) <= 0) {
	                                                i2 = 0;
	                                            } else if ((i2 & 16) > 0) {
	                                                i2 = 1;
	                                            } else {
	                                                iArr[0] = -867;
	                                                bArr2 = null;
	                                            }
	                                            if (wrap.getInt() != 10012) {
	                                      
	                                                wrap.getLong();
	                                                wrap.position(wrap.position() + 32);
	                                                wrap.get();
	                                                wrap.position(wrap.position() + 10);
	                                                wrap.get();
	                                                wrap.position((wrap.getShort() & 65535) + wrap.position());
	                                                i3 = wrap.getShort() & 65535;
	                                                wrap.position(wrap.position() + i3);
	                                                i3 = (i3 + 2) + 83;
	                                                int i4 = wrap.getInt();
	                                                int i5 = i3 + 4;
	                                                if (wrap.get(bArr.length - 1) != (byte) 3) {
	                                                    iArr[0] = -869;
	                                                    bArr2 = null;
	                                                } else {
	                                                    int length = (bArr.length - i5) - 1;
	                                                    if (length <= 0) {
	                                                        iArr[0] = -868;
	                                                        bArr2 = null;
	                                                    } else {
	                                                        Object obj = new byte[length];
	                                                        System.arraycopy(bArr, i5, obj, 0, length);
	                                                        if (i2 != 0) {
	                                                            obj = d.b((byte[]) obj);
	                                                            if (obj == null || ((byte[]) obj).length != i4) {
	                                                                iArr[0] = -871;
	                                                                bArr2 = null;
	                                                            }
	                                                        }
	                                                        Object obj2 = obj;
	                                                        ByteBuffer wrap2 = ByteBuffer.wrap((byte[]) obj2);
	                                                        length = wrap2.position() + 16;
	                                                        if (wrap2.get() != (byte) 38) {
	                                                            iArr[0] = -869;
	                                                            bArr2 = null;
	                                                        } else if (wrap2.get(((byte[]) obj2).length - 1) != (byte) 40) {
	                                                            iArr[0] = -869;
	                                                            bArr2 = null;
	                                                        } else {
	                                                            i4 = (((byte[]) obj2).length - length) - 1;
	                                                            if (i4 <= 0) {
	                                                                iArr[0] = -869;
	                                                                bArr2 = null;
	                                                            } else {
	                                                                bArr2 = new byte[i4];
	                                                                System.arraycopy(obj2, length, bArr2, 0, i4);
	                                                            }
	                                                        }
	                                                    }
	                                                }
	                                            }
	                                        }
	                                    }
	                                }
	                                unPackageResponse = ProtocolPackage.unPackageResponse(bArr2);
	                                if (unPackageResponse != null) {
	                                    i3 = iArr[0];
	                                    if (i3 > 0) {
	                                        i3 += 1000000;
	                                    } else if (i3 >= 0) {
	                                        i3 -= 1000000;
	                                    } else {
	                                        i3 = -861;
	                                    }
	                                    //a(i3, null, null);
	                                    return;
	                                }
	                                responseHead = unPackageResponse.head;
	                                if (responseHead == null && responseHead.errCode == 0) {
	                                    if (unPackageResponse.body == null || unPackageResponse.body.length == 0) {
	                                        //a(-872, null, null);
	                                        return;
	                                    }
	                                    JceStruct unPackageJceResponse = ProtocolPackage.unPackageJceResponse(this.f, unPackageResponse.body, null);
	                                    if (unPackageJceResponse != null) {
	                                        //a(0, null, unPackageJceResponse);
	                                        return;
	                                    } else {
	                                        //a(-862, null, null);
	                                        return;
	                                    }
	                                } else if (responseHead == null) {
	                                    i3 = responseHead.errCode;
	                                    if (i3 <= 0) {
	                                        i3 += 3000000;
	                                    } else {
	                                        i3 -= 3000000;
	                                    }
	                                   // a(i3, null, null);
	                                    return;
	                                } else {
	                                   // a(-870, null, null);
	                                    return;
	                                }
	                            }
	                        } catch (Throwable th) {
	                           // e.a("NetWorkTask", th);
	                            bArr2 = null;
	                        }
	                    }
	                    bArr2 = null;
	                    unPackageResponse = ProtocolPackage.unPackageResponse(bArr2);
	                    if (unPackageResponse != null) {
	                        responseHead = unPackageResponse.head;
	                        if (responseHead == null) {
	                        }
	                        if (responseHead == null) {
	                           // a(-870, null, null);
	                            return;
	                        }
	                        i3 = responseHead.errCode;
	                        if (i3 <= 0) {
	                            i3 -= 3000000;
	                        } else {
	                            i3 += 3000000;
	                        }
	                        //a(i3, null, null);
	                        return;
	                    }
	                    i3 = iArr[0];
	                    if (i3 > 0) {
	                        i3 += 1000000;
	                    } else if (i3 >= 0) {
	                        i3 = -861;
	                    } else {
	                        i3 -= 1000000;
	                    }
	                    //a(i3, null, null);
	                    return;
	                }
	            }
	            if (exception != null) {
	                exception.printStackTrace();
	                if (exception instanceof MalformedURLException) {
	                    i = -820;
	                } else if (exception instanceof ConnectException) {
	                    i = -824;
	                } else if (exception instanceof SocketTimeoutException) {
	                    i = -823;
	                } else if (exception instanceof SocketException) {
	                    i = -825;
	                } else if (exception instanceof IOException) {
	                    i = -826;
	                } else {
	                    i = -827;
	                }
	            }
	            //a(i, exception, null);
	        }
	    }


}
