public String insertProfile(Profile profile) throws SQLException { String r = "New profile inserted!"; if (this.getProfileID(profile) == -1) { try { // creates a SQL Statement object in order to execute the SQL insert command stmt = conn.createStatement(); // String login = (firstName, lastName, password)).createLogin(); if (profile.getEmail() != null) { stmt.execute( "INSERT INTO Profiles (FirstName, LastName, Login, Password, Email, IsAdmin) " + "VALUES ('" + profile.getFirstName() + "', '" + profile.getLastName() + "', " + "'" + profile.getLogin() + "', '" + profile.getPassword() + "', " + "'" + profile.getEmail() + "', " + profile.isAdmin() + ")"); } else { stmt.execute( "INSERT INTO Profiles (FirstName, LastName, Login, Password, IsAdmin) " + "VALUES ('" + profile.getFirstName() + "', '" + profile.getLastName() + "', " + "'" + profile.getLogin() + "', '" + profile.getPassword() + "', " + profile.isAdmin() + ") "); } stmt.close(); // System.out.println("Requête executée"); } catch (SQLException e) { // System.err.println(e.toString()); r = e.toString(); throw e; } } return r; }
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); }
/** 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; }