// Decompiled by DJ v3.12.12.96 Copyright 2011 Atanas Neshkov  Date: 12.08.2011 2:53:57
// Home Page: http://members.fortunecity.com/neshkov/dj.html  http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3) 

import agent.JAgent;
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.Display;

public final class r
    implements Runnable
{

    public r()
    {
    }

    public final synchronized void a(String s)
    {
        JAgent.a.setCurrent(x.a());
        a_java_lang_String_fld = s;
        a_java_lang_Thread_fld = new Thread(this);
        a_java_lang_Thread_fld.start();
    }

    public final synchronized void a()
    {
        a_boolean_fld = true;
        try
        {
            a_java_io_InputStream_fld.close();
        }
        catch(Exception _ex)
        {
            a_java_io_InputStream_fld = null;
            break MISSING_BLOCK_LABEL_37;
        }
        a_java_io_InputStream_fld = null;
        break MISSING_BLOCK_LABEL_37;
        Exception exception;
        exception;
        a_java_io_InputStream_fld = null;
        throw exception;
        try
        {
            a_java_io_OutputStream_fld.close();
        }
        catch(Exception _ex)
        {
            a_java_io_OutputStream_fld = null;
            break MISSING_BLOCK_LABEL_69;
        }
        a_java_io_OutputStream_fld = null;
        break MISSING_BLOCK_LABEL_69;
        Exception exception1;
        exception1;
        a_java_io_OutputStream_fld = null;
        throw exception1;
        try
        {
            a_javax_microedition_io_SocketConnection_fld.close();
        }
        catch(Exception _ex)
        {
            a_javax_microedition_io_SocketConnection_fld = null;
            break MISSING_BLOCK_LABEL_105;
        }
        a_javax_microedition_io_SocketConnection_fld = null;
        break MISSING_BLOCK_LABEL_105;
        Exception exception2;
        exception2;
        a_javax_microedition_io_SocketConnection_fld = null;
        throw exception2;
        Thread.yield();
        return;
    }

    public final void a(h h1)
    {
        if(a_java_io_OutputStream_fld == null || a_java_io_InputStream_fld == null)
        {
            ac.a(new ac(126));
            return;
        }
        OutputStream outputstream = a_java_io_OutputStream_fld;
        JVM INSTR monitorenter ;
        h1.a(o.a());
        byte abyte0[] = h1.a();
        u.b(1, abyte0.length);
        a_java_io_OutputStream_fld.write(abyte0);
        a_java_io_OutputStream_fld.flush();
        break MISSING_BLOCK_LABEL_87;
        JVM INSTR dup ;
        IOException ioexception;
        ioexception;
        printStackTrace();
        ac.a(new ac(121));
        return;
        Exception exception;
        exception;
        outputstream;
        JVM INSTR monitorexit ;
        throw exception;
    }

    public final void run()
    {
        byte abyte0[];
        try
        {
            a_javax_microedition_io_SocketConnection_fld = (SocketConnection)Connector.open("socket://" + a_java_lang_String_fld, 3);
            a_javax_microedition_io_SocketConnection_fld.setSocketOption((byte)2, 1);
            a_java_io_InputStream_fld = a_javax_microedition_io_SocketConnection_fld.openInputStream();
            a_java_io_OutputStream_fld = a_javax_microedition_io_SocketConnection_fld.openOutputStream();
            a_boolean_fld = false;
        }
        catch(ConnectionNotFoundException _ex)
        {
            ac.a(new ac(123));
        }
        catch(IllegalArgumentException _ex)
        {
            ac.a(new ac(125));
        }
        catch(IOException _ex)
        {
            ac.a(new ac(120));
        }
        catch(SecurityException _ex)
        {
            ac.a(new ac(130));
        }
        if(o.a == 2)
        {
            h h1 = h.a();
            a(h1);
            x.a(v.a(227));
            x.a(20);
        }
        abyte0 = new byte[44];
_L2:
        int i;
        if(a_boolean_fld)
            break MISSING_BLOCK_LABEL_511;
        i = 0;
        boolean flag = false;
        do
        {
            if(a_java_io_InputStream_fld.available() != 0)
                break;
            Thread.sleep(250L);
        } while(a_java_io_InputStream_fld != null);
        if(a_java_io_InputStream_fld == null)
            break MISSING_BLOCK_LABEL_611;
        if(o.a == 1)
        {
            boolean flag1 = false;
            StringBuffer stringbuffer = new StringBuffer();
            char c;
            try
            {
                while((c = (char)a_java_io_InputStream_fld.read()) >= '0' && c <= '9' || c == '.' || c == ':') 
                    stringbuffer.append(c);
            }
            catch(Exception _ex) { }
            x.a(v.a(277));
            x.a(10);
            o.a(stringbuffer.toString());
            return;
        }
        int k;
        while((k = a_java_io_InputStream_fld.read(abyte0, i, abyte0.length - i)) != -1 && (i += k) < abyte0.length) ;
        if(k == -1)
            break MISSING_BLOCK_LABEL_611;
        if(p.a(abyte0, 0) != 0xdeadbeef)
            throw new ac(127);
        if(p.a(abyte0, 4) < 0x1000b)
            throw new ac(128);
        h h2;
        (h2 = new h(p.a(abyte0, 12))).a(p.a(abyte0, 8));
        int l = p.a(abyte0, 16);
        u.b(0, 44 + l);
        byte abyte1[] = new byte[l];
        for(int j = 0; (k = a_java_io_InputStream_fld.read(abyte1, j, l - j)) != -1 && (j += k) < l;);
        h2.a(abyte1);
        if(k == -1 && h2.a() != 4100)
            break MISSING_BLOCK_LABEL_611;
        o.a(h2);
        if(true) goto _L2; else goto _L1
_L1:
        return;
        ClassCastException classcastexception;
        classcastexception;
        y.a(40, classcastexception.toString() + ":" + classcastexception.getMessage());
        return;
        JVM INSTR dup ;
        Object obj;
        obj;
        printStackTrace();
        ac ac1;
        if(!a_boolean_fld)
            ac.a(ac1 = new ac(ac.b));
        a_boolean_fld = false;
        return;
        JVM INSTR pop ;
        return;
        JVM INSTR dup ;
        obj;
        ac.a();
        return;
        JVM INSTR pop ;
        ac ac2;
        if(!a_boolean_fld)
            ac.a(ac2 = new ac(122));
    }

    private SocketConnection a_javax_microedition_io_SocketConnection_fld;
    public volatile boolean a_boolean_fld;
    public volatile Thread a_java_lang_Thread_fld;
    private String a_java_lang_String_fld;
    private InputStream a_java_io_InputStream_fld;
    private OutputStream a_java_io_OutputStream_fld;
}