private void onProfileChange(String oldProfileName) { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); mProfile.getProfile(settings); Editor ed = settings.edit(); ed.putString(oldProfileName, mProfile.toString()); ed.commit(); String profileString = settings.getString(profile, ""); if (profileString.equals("")) { mProfile.init(); mProfile.setName(getProfileName(profile)); } else { mProfile.decodeJson(profileString); } hostText.setText(mProfile.getHost()); userText.setText(mProfile.getUser()); passwordText.setText(mProfile.getPassword()); domainText.setText(mProfile.getDomain()); certificateText.setText(mProfile.getCertificate()); proxyTypeList.setValue(mProfile.getProxyType()); ssidList.setValue(mProfile.getSsid()); isAuthCheck.setChecked(mProfile.isAuth()); isNTLMCheck.setChecked(mProfile.isNTLM()); isAutoConnectCheck.setChecked(mProfile.isAutoConnect()); isAutoSetProxyCheck.setChecked(mProfile.isAutoSetProxy()); isBypassAppsCheck.setChecked(mProfile.isBypassApps()); isDNSProxyCheck.setChecked(mProfile.isDNSProxy()); isPACCheck.setChecked(mProfile.isPAC()); portText.setText(Integer.toString(mProfile.getPort())); Log.d(TAG, mProfile.toString()); mProfile.setProfile(settings); }
@Override public boolean equals(final Object obj) { if (!(obj instanceof Profile)) { return false; } final Profile profile = (Profile) obj; if (!getHost().equals(profile.getHost())) { return false; } if (getPort() != profile.getPort()) { return false; } if (!getUser().equals(profile.getUser())) { return false; } return true; }
/** Called when connect button is clicked. */ private boolean serviceStart() { if (Utils.isWorking()) return false; SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); mProfile.getProfile(settings); try { Intent it = new Intent(ProxyDroid.this, ProxyDroidService.class); Bundle bundle = new Bundle(); bundle.putString("host", mProfile.getHost()); bundle.putString("user", mProfile.getUser()); bundle.putString("bypassAddrs", mProfile.getBypassAddrs()); bundle.putString("password", mProfile.getPassword()); bundle.putString("domain", mProfile.getDomain()); bundle.putString("certificate", mProfile.getCertificate()); bundle.putString("proxyType", mProfile.getProxyType()); bundle.putBoolean("isAutoSetProxy", mProfile.isAutoSetProxy()); bundle.putBoolean("isBypassApps", mProfile.isBypassApps()); bundle.putBoolean("isAuth", mProfile.isAuth()); bundle.putBoolean("isNTLM", mProfile.isNTLM()); bundle.putBoolean("isDNSProxy", mProfile.isDNSProxy()); bundle.putBoolean("isPAC", mProfile.isPAC()); bundle.putInt("port", mProfile.getPort()); it.putExtras(bundle); startService(it); } catch (Exception ignore) { // Nothing return false; } return true; }
/** * create a profile based on command line arguments * * <ul> * <li>-u: username * <li>-p: password * <li>-c: character name (defaults to username) * <li>-h: hostname * <li>-P: port * <li>-S: pre authentication seed * </ul> * * @param args command line arguments * @return profile */ public static Profile createFromCommandline(String[] args) { Profile profile = new Profile(); int i = 0; while (i != args.length) { if (args[i].equals("-u")) { profile.setUser(args[i + 1]); } else if (args[i].equals("-p")) { profile.setPassword(args[i + 1]); } else if (args[i].equals("-c")) { profile.setCharacter(args[i + 1]); } else if (args[i].equals("-h")) { profile.setHost(args[i + 1]); } else if (args[i].equals("-P")) { profile.setPort(Integer.parseInt(args[i + 1])); } else if (args[i].equals("-S")) { profile.setSeed(args[i + 1]); } i++; } if (profile.getCharacter() == null) { profile.setCharacter(profile.getUser()); } return profile; }