Skip to content

Commit

Permalink
Moved connection timeout to Connection class
Browse files Browse the repository at this point in the history
  • Loading branch information
iniju committed Dec 25, 2012
1 parent e0cfe55 commit 17ffea9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
8 changes: 1 addition & 7 deletions src/com/ichi2/anki/Info.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import com.ichi2.async.Connection.OldAnkiDeckFilter;
import com.ichi2.async.Connection.Payload;
import com.ichi2.libanki.Utils;
import com.ichi2.libanki.sync.BasicHttpSyncer;
import com.ichi2.themes.StyledDialog;
import com.ichi2.themes.StyledProgressDialog;
import com.ichi2.themes.Themes;
Expand All @@ -60,10 +59,7 @@
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.conn.ssl.X509HostnameVerifier;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.SingleClientConnManager;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.*;
import org.apache.http.util.EntityUtils;
Expand Down Expand Up @@ -96,8 +92,6 @@ public class Info extends Activity {

private static final int LOG_IN_FOR_SYNC = 0;

private static final int CONN_TIMEOUT = 30000;

private String mDialogMessage;

private int mType;
Expand Down Expand Up @@ -455,7 +449,7 @@ protected String doInBackground(String... params) {
httpParams.setParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
httpParams.setParameter(CoreProtocolPNames.USER_AGENT, "AnkiDroid-" + AnkiDroidApp.getPkgVersion());
HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);
HttpConnectionParams.setSoTimeout(httpParams, CONN_TIMEOUT);
HttpConnectionParams.setSoTimeout(httpParams, Connection.CONN_TIMEOUT);

// Registry
SchemeRegistry registry = new SchemeRegistry();
Expand Down
1 change: 1 addition & 0 deletions src/com/ichi2/async/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public class Connection extends AsyncTask<Connection.Payload, Object, Connection
public static final int TASK_TYPE_REGISTER = 6;
public static final int TASK_TYPE_UPGRADE_DECKS = 7;
public static final int TASK_TYPE_DOWNLOAD_SHARED_DECK = 8;
public static final int CONN_TIMEOUT = 30000;

private static Context sContext;

Expand Down
3 changes: 1 addition & 2 deletions src/com/ichi2/libanki/sync/BasicHttpSyncer.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public class BasicHttpSyncer implements HttpSyncer {

private static final String BOUNDARY = "Anki-sync-boundary";
public static final String ANKIWEB_STATUS_OK = "OK";
private static final int SYNC_TIMEOUT = 30000;

public volatile long bytesSent = 0;
public volatile long bytesReceived = 0;
Expand Down Expand Up @@ -185,7 +184,7 @@ public HttpResponse req(String method, InputStream fobj, int comp, boolean hkey,
params.setParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
params.setParameter(CoreProtocolPNames.USER_AGENT, "AnkiDroid-" + AnkiDroidApp.getPkgVersion());
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpConnectionParams.setSoTimeout(params, SYNC_TIMEOUT);
HttpConnectionParams.setSoTimeout(params, Connection.CONN_TIMEOUT);

// Registry
SchemeRegistry registry = new SchemeRegistry();
Expand Down

0 comments on commit 17ffea9

Please sign in to comment.