diff --git a/.classpath b/.classpath
index be759ecd4..9d1298ecb 100644
--- a/.classpath
+++ b/.classpath
@@ -7,5 +7,6 @@
+
diff --git a/libs/aXMLRPC.jar b/libs/aXMLRPC.jar
new file mode 100644
index 000000000..9cf8f61e0
Binary files /dev/null and b/libs/aXMLRPC.jar differ
diff --git a/res/.DS_Store b/res/.DS_Store
new file mode 100644
index 000000000..67c254cc5
Binary files /dev/null and b/res/.DS_Store differ
diff --git a/res/drawable/.DS_Store b/res/drawable/.DS_Store
new file mode 100644
index 000000000..308abc851
Binary files /dev/null and b/res/drawable/.DS_Store differ
diff --git a/res/drawable/notok.png b/res/drawable/notok.png
new file mode 100644
index 000000000..84813bc2d
Binary files /dev/null and b/res/drawable/notok.png differ
diff --git a/res/drawable/ok.png b/res/drawable/ok.png
new file mode 100644
index 000000000..769986fb7
Binary files /dev/null and b/res/drawable/ok.png differ
diff --git a/res/layout/wizard.xml b/res/layout/wizard.xml
new file mode 100644
index 000000000..25dd1f314
--- /dev/null
+++ b/res/layout/wizard.xml
@@ -0,0 +1,115 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 14fe29bf1..bd55d666f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -227,4 +227,20 @@
pref_nb_accounts_extra
pref_default_account
SIP Accounts
+
+Username
+Password
+Confirmation
+Email
+Account Wizard
+Create Account
+Cancel
+An error occurred, try again later.
+Server unreachable, verify your internet connection.
+This username is already in use.
+Your username is not valid.
+Your email is not valid.
+Your password is not valid (6 characters min).
+Passwords entered are different.
+You need to activate your account with the link that was send to your email.
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index caa02b9fe..c76cd7115 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -21,6 +21,7 @@
+
= 6;
+ }
+
+ private void createAccount(final String username, final String password, String email, boolean suscribe) {
+ final Runnable runNotReachable = new Runnable() {
+ public void run() {
+ errorMessage.setText(R.string.wizard_server_unavailable);
+ }
+ };
+
+ try {
+ XMLRPCClient client = new XMLRPCClient(new URL("https://www.linphone.org/wizard.php"));
+
+ XMLRPCCallback listener = new XMLRPCCallback() {
+ Runnable runNotOk = new Runnable() {
+ public void run() {
+ errorMessage.setText(R.string.wizard_failed);
+ }
+ };
+
+ Runnable runOk = new Runnable() {
+ public void run() {
+ addExtraAccountPreferencesButton(accounts, nbAccounts, true);
+ fillLinphoneAccount(nbAccounts, username, password);
+ nbAccounts++;
+ createDynamicAccountsPreferences();
+ wizardDialog.dismiss();
+
+ Toast.makeText(LinphonePreferencesActivity.this, R.string.wizard_need_activation, Toast.LENGTH_LONG).show();
+ }
+ };
+
+ public void onResponse(long id, Object result) {
+ int answer = (Integer) result;
+ if (answer != 0) {
+ runOnUiThread(runNotOk);
+ } else {
+ runOnUiThread(runOk);
+ }
+ }
+
+ public void onError(long id, XMLRPCException error) {
+ runOnUiThread(runNotReachable);
+ }
+
+ public void onServerError(long id, XMLRPCServerException error) {
+ runOnUiThread(runNotReachable);
+ }
+ };
+
+ client.callAsync(listener, "create_account", username, password, email, suscribe ? 1 : 0);
+ }
+ catch(Exception ex) {
+ runOnUiThread(runNotReachable);
+ }
+ }
+
+ private void addXMLRPCUsernameHandler(final EditText field, final ImageView icon) {
+ field.addTextChangedListener(new TextWatcher() {
+ public void afterTextChanged(Editable arg0) {
+
+ }
+
+ public void beforeTextChanged(CharSequence arg0, int arg1,
+ int arg2, int arg3) {
+
+ }
+
+ public void onTextChanged(CharSequence arg0, int arg1, int arg2,
+ int arg3)
+ {
+ usernameOk = false;
+ if (isUsernameCorrect(field.getText().toString()))
+ {
+ isUsernameRegistred(field.getText().toString(), icon);
+ }
+ else {
+ errorMessage.setText(R.string.wizard_username_incorrect);
+ icon.setImageResource(R.drawable.notok);
+ }
+ }
+ });
+ }
+
+ private void addXMLRPCEmailHandler(final EditText field, final ImageView icon) {
+ field.addTextChangedListener(new TextWatcher() {
+ public void afterTextChanged(Editable arg0) {
+
+ }
+
+ public void beforeTextChanged(CharSequence arg0, int arg1,
+ int arg2, int arg3) {
+
+ }
+
+ public void onTextChanged(CharSequence arg0, int arg1, int arg2,
+ int arg3)
+ {
+ emailOk = false;
+ if (isEmailCorrect(field.getText().toString())) {
+ icon.setImageResource(R.drawable.ok);
+ emailOk = true;
+ errorMessage.setText("");
+ }
+ else {
+ errorMessage.setText(R.string.wizard_email_incorrect);
+ icon.setImageResource(R.drawable.notok);
+ }
+ createAccount.setEnabled(usernameOk && passwordOk && emailOk);
+ }
+ });
+ }
+
+ private void addXMLRPCPasswordHandler(final EditText field1, final EditText field2, final ImageView icon) {
+ TextWatcher passwordListener = new TextWatcher() {
+ public void afterTextChanged(Editable arg0) {
+
+ }
+
+ public void beforeTextChanged(CharSequence arg0, int arg1,
+ int arg2, int arg3) {
+
+ }
+
+ public void onTextChanged(CharSequence arg0, int arg1, int arg2,
+ int arg3)
+ {
+ passwordOk = false;
+ if (isPasswordCorrect(field1.getText().toString()) && field1.getText().toString().equals(field2.getText().toString())) {
+ passwordOk = true;
+ icon.setImageResource(R.drawable.ok);
+ errorMessage.setText("");
+ }
+ else {
+ if (isPasswordCorrect(field1.getText().toString())) {
+ errorMessage.setText(R.string.wizard_passwords_unmatched);
+ }
+ else {
+ errorMessage.setText(R.string.wizard_password_incorrect);
+ }
+ icon.setImageResource(R.drawable.notok);
+ }
+ createAccount.setEnabled(usernameOk && passwordOk && emailOk);
+ }
+ };
+
+ field1.addTextChangedListener(passwordListener);
+ field2.addTextChangedListener(passwordListener);
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -169,6 +480,7 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
addPreferencesFromResource(R.xml.preferences);
createDynamicAccountsPreferences();
+ addWizardAccount();
addTransportChecboxesListener();
ecCalibratePref = (CheckBoxPreference) findPreference(pref_echo_canceller_calibration_key);
diff --git a/src/org/linphone/LinphonePreferencesSIPAccountActivity.java b/src/org/linphone/LinphonePreferencesSIPAccountActivity.java
index 47bcfad77..0c5a247f4 100644
--- a/src/org/linphone/LinphonePreferencesSIPAccountActivity.java
+++ b/src/org/linphone/LinphonePreferencesSIPAccountActivity.java
@@ -1,4 +1,22 @@
package org.linphone;
+/*
+LinphonePreferencesSIPAccountActivity.java
+Copyright (C) 2011 Belledonne Communications, Grenoble, France
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
import org.linphone.core.Log;
@@ -64,7 +82,7 @@ public class LinphonePreferencesSIPAccountActivity extends PreferenceActivity {
delete.setTitle("Delete this account");
delete.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
- int nbAccounts = prefs.getInt(getString(R.string.pref_extra_accounts), 1);
+ int nbAccounts = prefs.getInt(getString(R.string.pref_extra_accounts), 0);
SharedPreferences.Editor editor = prefs.edit();
for (int i = n; i < nbAccounts - 1; i++) {