Do not connect to server when user/pass is missing
[fonbot.git] / src / ro / ieval / fonbot / FonBotMainService.java
index 8bc69ae7541ad8c2bea7857f1af8c43d8037246f..5508557d749fcc5699312dbc54e2e1144710acf0 100644 (file)
@@ -8,6 +8,8 @@ import java.util.Collections;
 import java.util.EnumSet;
 import java.util.Set;
 
+import javax.net.ssl.SSLException;
+
 import org.eclipse.jdt.annotation.Nullable;
 
 import ro.ieval.fonbot.Address.Protocol;
@@ -82,6 +84,8 @@ public final class FonBotMainService extends Service {
                                        runnable.doRun();
                                } catch (final SocketTimeoutException e){
                                        Log.d("LongPollRunnable", "Socket timeout, refreshing connection");
+                               } catch (final SSLException e){
+                                       Log.d("LongPollRunnable", "Got SSLException, refreshing connection");
                                } catch (final Exception ex){
                                        ex.printStackTrace();
                                        break;
@@ -202,7 +206,10 @@ public final class FonBotMainService extends Service {
                        Utils.processCommand(this, toNonNull(words[0]), args, toNonNull(address));
                }
 
-               if(longPollThread == null || !longPollThread.isAlive()){
+               final String user=PreferenceManager.getDefaultSharedPreferences(this).getString("username", null);
+               final String password=PreferenceManager.getDefaultSharedPreferences(this).getString("password", null);
+               final boolean has_user_pass = user != null && password != null && user.length() > 0 && password.length() > 0;
+               if((longPollThread == null || !longPollThread.isAlive()) && has_user_pass){
                        longPollThread = new Thread(new LongPollRunnable());
                        longPollThread.start();
                }
This page took 0.010449 seconds and 4 git commands to generate.