mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
remove dead code
This commit is contained in:
@@ -27,11 +27,7 @@ public class DcContext {
|
||||
public final static int DC_EVENT_IMEX_FILE_WRITTEN = 2052;
|
||||
public final static int DC_EVENT_SECUREJOIN_INVITER_PROGRESS = 2060;
|
||||
public final static int DC_EVENT_SECUREJOIN_JOINER_PROGRESS = 2061;
|
||||
public final static int DC_EVENT_IS_OFFLINE = 2081;
|
||||
public final static int DC_EVENT_GET_STRING = 2091;
|
||||
public final static int DC_EVENT_GET_QUANTITIY_STRING = 2092;
|
||||
public final static int DC_EVENT_HTTP_GET = 2100;
|
||||
public final static int DC_EVENT_HTTP_POST = 2110;
|
||||
|
||||
public final static int DC_IMEX_EXPORT_SELF_KEYS = 1;
|
||||
public final static int DC_IMEX_IMPORT_SELF_KEYS = 2;
|
||||
|
||||
@@ -566,76 +566,6 @@ public class ApplicationDcContext extends DcContext {
|
||||
handleError(event, true, dataToString(data2));
|
||||
break;
|
||||
|
||||
case DC_EVENT_HTTP_GET:
|
||||
// calling this from the main thread may result in NetworkOnMainThreadException error
|
||||
String httpContent = null;
|
||||
try {
|
||||
URL url = new URL(dataToString(data1));
|
||||
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
|
||||
try {
|
||||
urlConnection.setConnectTimeout(10 * 1000);
|
||||
InputStream inputStream = new BufferedInputStream(urlConnection.getInputStream());
|
||||
|
||||
BufferedReader r = new BufferedReader(new InputStreamReader(inputStream));
|
||||
|
||||
StringBuilder total = new StringBuilder();
|
||||
String line;
|
||||
while ((line = r.readLine()) != null) {
|
||||
total.append(line).append('\n');
|
||||
}
|
||||
httpContent = total.toString();
|
||||
} finally {
|
||||
urlConnection.disconnect();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return stringToData(httpContent);
|
||||
|
||||
case DC_EVENT_HTTP_POST:
|
||||
// calling this from the main thread may result in NetworkOnMainThreadException error
|
||||
String postContent = null;
|
||||
try {
|
||||
String urlStr = dataToString(data1);
|
||||
String paramStr = "";
|
||||
if(urlStr.contains("?")) {
|
||||
paramStr = urlStr.substring(urlStr.indexOf("?")+1);
|
||||
urlStr = urlStr.substring(0, urlStr.indexOf("?"));
|
||||
}
|
||||
byte[] bytes = paramStr.getBytes();
|
||||
|
||||
URL url = new URL(urlStr);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
try {
|
||||
conn.setConnectTimeout(15 * 1000);
|
||||
conn.setReadTimeout(15 * 1000);
|
||||
conn.setDoOutput(true);
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
conn.setRequestProperty("Content-Length", String.valueOf(bytes.length));
|
||||
conn.getOutputStream().write(bytes);
|
||||
|
||||
int responseCode = conn.getResponseCode();
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(new BufferedInputStream(conn.getInputStream())));
|
||||
StringBuilder total = new StringBuilder();
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
total.append(line).append('\n');
|
||||
}
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
postContent = total.toString();
|
||||
}
|
||||
else {
|
||||
Log.i("DeltaChat", String.format("DC_EVENT_HTTP_POST error: %s", total.toString()));
|
||||
}
|
||||
} finally {
|
||||
conn.disconnect();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return stringToData(postContent);
|
||||
|
||||
case DC_EVENT_GET_STRING:
|
||||
String s;
|
||||
switch ((int) data1) {
|
||||
|
||||
Reference in New Issue
Block a user