// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package com.oliodevices.assist.app.detectors.web.api; import android.app.DownloadManager; import android.content.Context; import android.database.Cursor; import android.net.Uri; import com.olio.communication.actions.WebAction; import com.olio.communication.actions.WebHeader; import com.olio.util.ALog; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Iterator; import java.util.List; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.StatusLine; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.jdeferred.DeferredCallable; // Referenced classes of package com.oliodevices.assist.app.detectors.web.api: // OlioDownloadException, OlioApiResponse, OlioApiException public class HttpAsyncCallable extends DeferredCallable { WebAction action; Context context; public HttpAsyncCallable(WebAction webaction, Context context1) { action = webaction; context = context1; } private static String convertInputStreamToString(InputStream inputstream) throws IOException { BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(inputstream)); StringBuffer stringbuffer = new StringBuffer(""); do { String s = bufferedreader.readLine(); if (s != null) { stringbuffer.append(s); } else { inputstream.close(); return stringbuffer.toString(); } } while (true); } private OlioApiResponse delete(WebAction webaction) throws Exception { return takeAction(webaction, new HttpDelete(webaction.getUrl())); } private OlioApiResponse download(Context context1, WebAction webaction) throws Exception { DownloadManager downloadmanager; android.app.DownloadManager.Query query; boolean flag; long l; downloadmanager = (DownloadManager)context1.getSystemService("download"); context1 = new android.app.DownloadManager.Request(Uri.parse(webaction.getUrl())); context1.setNotificationVisibility(2); l = downloadmanager.enqueue(context1); query = new android.app.DownloadManager.Query(); query.setFilterById(new long[] { l }); flag = false; context1 = null; _L11: if (flag) goto _L2; else goto _L1 _L1: webaction = context1; Thread.sleep(200L); webaction = context1; Cursor cursor = downloadmanager.query(query); webaction = cursor; int i = cursor.getColumnIndex("status"); webaction = cursor; cursor.moveToFirst(); webaction = cursor; i = cursor.getInt(i); webaction = cursor; int j = cursor.getColumnIndex("reason"); webaction = cursor; int k = cursor.getColumnIndex("bytes_so_far"); i; JVM INSTR lookupswitch 5: default 367 // 1: 299 // 2: 323 // 4: 253 // 8: 347 // 16: 235; goto _L3 _L4 _L5 _L6 _L7 _L8 _L3: webaction = cursor; ALog.e("Unknown download error", new Object[0]); webaction = cursor; throw new OlioDownloadException(-1); context1; if (webaction != null) { webaction.close(); } throw context1; _L8: webaction = cursor; throw new OlioDownloadException(cursor.getInt(j)); _L6: webaction = cursor; notify(Integer.valueOf(cursor.getInt(k))); i = ((flag) ? 1 : 0); _L9: flag = i; context1 = cursor; if (cursor != null) { cursor.close(); flag = i; context1 = cursor; } continue; /* Loop/switch isn't completed */ _L4: webaction = cursor; notify(Integer.valueOf(cursor.getInt(k))); i = ((flag) ? 1 : 0); continue; /* Loop/switch isn't completed */ _L5: webaction = cursor; notify(Integer.valueOf(cursor.getInt(k))); i = ((flag) ? 1 : 0); continue; /* Loop/switch isn't completed */ _L7: i = 1; if (true) goto _L9; else goto _L2 _L2: return new OlioApiResponse(0, Long.toString(l)); if (true) goto _L11; else goto _L10 _L10: } private OlioApiResponse getAction(WebAction webaction) throws Exception { return takeAction(webaction, new HttpGet(webaction.getUrl())); } private OlioApiResponse post(WebAction webaction) throws Exception { return takeAction(webaction, new HttpPost(webaction.getUrl())); } private OlioApiResponse put(WebAction webaction) throws Exception { return takeAction(webaction, new HttpPut(webaction.getUrl())); } private OlioApiResponse takeAction(WebAction webaction, HttpRequestBase httprequestbase) throws Exception { Object obj; String s; int i; s = ""; i = 0; obj = s; DefaultHttpClient defaulthttpclient = new DefaultHttpClient(); obj = s; Iterator iterator = webaction.getHeaders().iterator(); _L2: obj = s; if (!iterator.hasNext()) { break; /* Loop/switch isn't completed */ } obj = s; WebHeader webheader = (WebHeader)iterator.next(); obj = s; httprequestbase.addHeader(webheader.getHeader(), webheader.getValue()); if (true) goto _L2; else goto _L1 webaction; ALog.e("Get failed for WebAction", new Object[0]); webaction = ((WebAction) (obj)); _L3: int j; if (i >= 200 && i < 300 && webaction != null) { return new OlioApiResponse(i, webaction); } else { throw new OlioApiException(new OlioApiResponse(i, webaction)); } _L1: obj = s; if (!(httprequestbase instanceof HttpEntityEnclosingRequestBase)) { break MISSING_BLOCK_LABEL_160; } obj = s; webaction = new StringEntity(webaction.getPayload()); obj = s; ((HttpEntityEnclosingRequestBase)httprequestbase).setEntity(webaction); obj = s; httprequestbase = defaulthttpclient.execute(httprequestbase); obj = s; webaction = httprequestbase.getEntity().getContent(); if (webaction == null) { break MISSING_BLOCK_LABEL_221; } obj = s; webaction = convertInputStreamToString(webaction); _L4: obj = webaction; j = httprequestbase.getStatusLine().getStatusCode(); i = j; goto _L3 webaction = null; goto _L4 } public OlioApiResponse call() throws Exception { if (action.getHttpVerb() == com.olio.communication.actions.WebAction.HttpVerb.POST) { return post(action); } if (action.getHttpVerb() == com.olio.communication.actions.WebAction.HttpVerb.GET) { return getAction(action); } if (action.getHttpVerb() == com.olio.communication.actions.WebAction.HttpVerb.PUT) { return put(action); } if (action.getHttpVerb() == com.olio.communication.actions.WebAction.HttpVerb.DOWNLOAD) { return download(context, action); } else { return null; } } public volatile Object call() throws Exception { return call(); } }