From e60be47e5a46b794846b166993260f17a54a19ad Mon Sep 17 00:00:00 2001 From: cyBerta Date: Sat, 23 Nov 2013 03:23:05 +0100 Subject: switch provider part 1 --- src/se/leap/bitmaskclient/Dashboard.java | 38 +++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'src/se/leap/bitmaskclient/Dashboard.java') diff --git a/src/se/leap/bitmaskclient/Dashboard.java b/src/se/leap/bitmaskclient/Dashboard.java index ca619e9f..116d043b 100644 --- a/src/se/leap/bitmaskclient/Dashboard.java +++ b/src/se/leap/bitmaskclient/Dashboard.java @@ -40,6 +40,7 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import android.os.ResultReceiver; +import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -63,12 +64,17 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf protected static final int CONFIGURE_LEAP = 0; protected static final int SWITCH_PROVIDER = 1; + private static final String TAG_EIP_FRAGMENT = "EIP_DASHBOARD_FRAGMENT"; final public static String SHARED_PREFERENCES = "LEAPPreferences"; final public static String ACTION_QUIT = "quit"; public static final String REQUEST_CODE = "request_code"; + public static final String LOGOUT_FIRST = "logout_first"; + public static final String STOP_FIRST = "stop_first"; + + private ProgressBar mProgressBar; private TextView eipStatus; private ProviderAPIBroadcastReceiver_Update providerAPI_broadcast_receiver_update; @@ -89,8 +95,9 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf app = this; PRNGFixes.apply(); - //mProgressBar = (ProgressBar) findViewById(R.id.progressbar_dashboard); - + // mProgressBar = (ProgressBar) findViewById(R.id.progressbar_dashboard); + // mProgressBar = (ProgressBar) findViewById(R.id.eipProgress); + // eipStatus = (TextView) findViewById(R.id.eipStatus); providerAPI_broadcast_receiver_update = new ProviderAPIBroadcastReceiver_Update(); IntentFilter update_intent_filter = new IntentFilter(ProviderAPI.UPDATE_ACTION); @@ -116,8 +123,16 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf @Override protected void onActivityResult(int requestCode, int resultCode, Intent data){ if ( requestCode == CONFIGURE_LEAP || requestCode == SWITCH_PROVIDER) { + // It should be equivalent: if ( (requestCode == CONFIGURE_LEAP) || (data!= null && data.hasExtra(STOP_FIRST))) { if ( resultCode == RESULT_OK ){ ConfigHelper.saveSharedPref(EIP.AUTHED_EIP, authed_eip); + if ((data != null) && (data.hasExtra(STOP_FIRST))){ + Log.d(TAG_EIP_FRAGMENT, "onActivityResult() -> eipStop!"); + eipStop(); + }else{ + Log.d(TAG_EIP_FRAGMENT, "onActivityResult() -> has no Extra STOP_FIRST"); + } + startService( new Intent(EIP.ACTION_UPDATE_EIP_SERVICE) ); buildDashboard(); if(data != null && data.hasExtra(LogInDialog.VERB)) { @@ -299,14 +314,13 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters); provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver); - //if(mProgressDialog != null) mProgressDialog.dismiss(); - //mProgressDialog = ProgressDialog.show(this, getResources().getString(R.string.logout_title), getResources().getString(R.string.logout_message), true); if(mProgressBar == null) mProgressBar = (ProgressBar) findViewById(R.id.eipProgress); mProgressBar.setVisibility(ProgressBar.VISIBLE); if(eipStatus == null) eipStatus = (TextView) findViewById(R.id.eipStatus); eipStatus.setText("Starting to logout"); - //mProgressBar.setMax(1); startService(provider_API_command); + //mProgressBar.setMax(1); + } /** @@ -456,7 +470,21 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf eip_intent.putExtra(EIP.RECEIVER_TAG, eip_receiver); startService(eip_intent); } + + /** + * Send a command to EIP + * + */ + private void eipStop(){ + // TODO validate "action"...how do we get the list of intent-filters for a class via Android API? + Intent eip_intent = new Intent(this, EIP.class); + eip_intent.setAction(EIP.ACTION_STOP_EIP); + // eip_intent.putExtra(EIP.RECEIVER_TAG, eip_receiver); + startService(eip_intent); + Log.d(TAG_EIP_FRAGMENT, "eipStop() -> service started to stop"); + } + public class ProviderAPIBroadcastReceiver_Update extends BroadcastReceiver { @Override -- cgit v1.2.3 From 6dfb02da9cd6c28b8a3016cf78454add6408c13d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Tue, 3 Dec 2013 22:26:31 +0100 Subject: Vpn profiles get updated after switching provider. parsedEipSerial wasn't being reset after switching provider, so updating gateways thought there was no real update. After switching provider, we also remove all other vpn profiles. --- src/se/leap/bitmaskclient/Dashboard.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/se/leap/bitmaskclient/Dashboard.java') diff --git a/src/se/leap/bitmaskclient/Dashboard.java b/src/se/leap/bitmaskclient/Dashboard.java index 116d043b..24cf13f6 100644 --- a/src/se/leap/bitmaskclient/Dashboard.java +++ b/src/se/leap/bitmaskclient/Dashboard.java @@ -106,7 +106,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf ConfigHelper.setSharedPreferences(getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE)); preferences = ConfigHelper.shared_preferences; - + authed_eip = ConfigHelper.getBoolFromSharedPref(EIP.AUTHED_EIP); if (ConfigHelper.getStringFromSharedPref(Provider.KEY).isEmpty()) startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP); @@ -125,14 +125,15 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf if ( requestCode == CONFIGURE_LEAP || requestCode == SWITCH_PROVIDER) { // It should be equivalent: if ( (requestCode == CONFIGURE_LEAP) || (data!= null && data.hasExtra(STOP_FIRST))) { if ( resultCode == RESULT_OK ){ - ConfigHelper.saveSharedPref(EIP.AUTHED_EIP, authed_eip); if ((data != null) && (data.hasExtra(STOP_FIRST))){ Log.d(TAG_EIP_FRAGMENT, "onActivityResult() -> eipStop!"); eipStop(); - }else{ + } else{ Log.d(TAG_EIP_FRAGMENT, "onActivityResult() -> has no Extra STOP_FIRST"); } + ConfigHelper.saveSharedPref(EIP.PARSED_SERIAL, 0); + ConfigHelper.saveSharedPref(EIP.AUTHED_EIP, authed_eip); startService( new Intent(EIP.ACTION_UPDATE_EIP_SERVICE) ); buildDashboard(); if(data != null && data.hasExtra(LogInDialog.VERB)) { -- cgit v1.2.3 From 8c54cb758514aef996a362d0c021bf0f93006ea2 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Tue, 3 Dec 2013 22:05:12 +0100 Subject: logout simplified and logs removed --- src/se/leap/bitmaskclient/Dashboard.java | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/se/leap/bitmaskclient/Dashboard.java') diff --git a/src/se/leap/bitmaskclient/Dashboard.java b/src/se/leap/bitmaskclient/Dashboard.java index 24cf13f6..65ff2800 100644 --- a/src/se/leap/bitmaskclient/Dashboard.java +++ b/src/se/leap/bitmaskclient/Dashboard.java @@ -70,8 +70,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf final public static String SHARED_PREFERENCES = "LEAPPreferences"; final public static String ACTION_QUIT = "quit"; public static final String REQUEST_CODE = "request_code"; - public static final String LOGOUT_FIRST = "logout_first"; - public static final String STOP_FIRST = "stop_first"; + @@ -124,18 +123,12 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf protected void onActivityResult(int requestCode, int resultCode, Intent data){ if ( requestCode == CONFIGURE_LEAP || requestCode == SWITCH_PROVIDER) { // It should be equivalent: if ( (requestCode == CONFIGURE_LEAP) || (data!= null && data.hasExtra(STOP_FIRST))) { - if ( resultCode == RESULT_OK ){ - if ((data != null) && (data.hasExtra(STOP_FIRST))){ - Log.d(TAG_EIP_FRAGMENT, "onActivityResult() -> eipStop!"); - eipStop(); - } else{ - Log.d(TAG_EIP_FRAGMENT, "onActivityResult() -> has no Extra STOP_FIRST"); - } - + if ( resultCode == RESULT_OK ){ ConfigHelper.saveSharedPref(EIP.PARSED_SERIAL, 0); ConfigHelper.saveSharedPref(EIP.AUTHED_EIP, authed_eip); startService( new Intent(EIP.ACTION_UPDATE_EIP_SERVICE) ); buildDashboard(); + if(data != null && data.hasExtra(LogInDialog.VERB)) { View view = ((ViewGroup)findViewById(android.R.id.content)).getChildAt(0); logInDialog(view, Bundle.EMPTY); @@ -146,7 +139,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf configErrorDialog(); } } - + /** * Dialog shown when encountering a configuration error. Such errors require * reconfiguring LEAP or aborting the application. @@ -244,6 +237,12 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf startActivity(intent); return true; case R.id.switch_provider: + if (Provider.getInstance().hasEIP()){ + if (ConfigHelper.getBoolFromSharedPref(EIP.AUTHED_EIP)){ + logOut(); + } + eipStop(); + } startActivityForResult(new Intent(this,ConfigurationWizard.class), SWITCH_PROVIDER); return true; case R.id.login_button: @@ -482,7 +481,6 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf eip_intent.setAction(EIP.ACTION_STOP_EIP); // eip_intent.putExtra(EIP.RECEIVER_TAG, eip_receiver); startService(eip_intent); - Log.d(TAG_EIP_FRAGMENT, "eipStop() -> service started to stop"); } -- cgit v1.2.3