diff --git a/src/org/linphone/ContactsManager.java b/src/org/linphone/ContactsManager.java index c5cf25d75..bd3d457dc 100644 --- a/src/org/linphone/ContactsManager.java +++ b/src/org/linphone/ContactsManager.java @@ -19,9 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package org.linphone; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Calendar; import java.util.Collections; import java.util.List; import java.util.Locale; diff --git a/src/org/linphone/assistant/CreateAccountActivationFragment.java b/src/org/linphone/assistant/CreateAccountActivationFragment.java index 8bd601c63..0b1c7e721 100644 --- a/src/org/linphone/assistant/CreateAccountActivationFragment.java +++ b/src/org/linphone/assistant/CreateAccountActivationFragment.java @@ -17,9 +17,13 @@ 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 java.net.URL; - +import org.linphone.LinphoneManager; import org.linphone.R; +import org.linphone.core.LinphoneXmlRpcRequest; +import org.linphone.core.LinphoneXmlRpcRequest.LinphoneXmlRpcRequestListener; +import org.linphone.core.LinphoneXmlRpcRequestImpl; +import org.linphone.core.LinphoneXmlRpcSession; +import org.linphone.core.LinphoneXmlRpcSessionImpl; import android.app.Fragment; import android.os.Bundle; @@ -30,17 +34,16 @@ import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.Toast; -import de.timroes.axmlrpc.XMLRPCCallback; -import de.timroes.axmlrpc.XMLRPCClient; -import de.timroes.axmlrpc.XMLRPCException; -import de.timroes.axmlrpc.XMLRPCServerException; /** * @author Sylvain Berfini */ -public class CreateAccountActivationFragment extends Fragment { +public class CreateAccountActivationFragment extends Fragment implements LinphoneXmlRpcRequestListener { private String username, password; private Handler mHandler = new Handler(); private Button checkAccount; + private LinphoneXmlRpcSession xmlRpcSession; + private LinphoneXmlRpcRequest xmlRpcRequest; + private Runnable runNotOk, runOk, runNotReachable; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, @@ -58,58 +61,49 @@ public class CreateAccountActivationFragment extends Fragment { isAccountVerified(username); } }); - - return view; - } - - private void isAccountVerified(final String username) { - final Runnable runNotReachable = new Runnable() { + + runNotOk = new Runnable() { + public void run() { + checkAccount.setEnabled(true); + Toast.makeText(getActivity(), getString(R.string.assistant_account_not_validated), Toast.LENGTH_LONG).show(); + } + }; + runOk = new Runnable() { + public void run() { + checkAccount.setEnabled(true); + AssistantActivity.instance().saveCreatedAccount(username,password,null, getString(R.string.default_domain),null); + AssistantActivity.instance().isAccountVerified(username); + } + }; + runNotReachable = new Runnable() { public void run() { Toast.makeText(getActivity(), getString(R.string.wizard_server_unavailable), Toast.LENGTH_LONG).show(); } }; - try { - XMLRPCClient client = new XMLRPCClient(new URL(getString(R.string.wizard_url))); - - XMLRPCCallback listener = new XMLRPCCallback() { - Runnable runNotOk = new Runnable() { - public void run() { - checkAccount.setEnabled(true); - Toast.makeText(getActivity(), getString(R.string.assistant_account_not_validated), Toast.LENGTH_LONG).show(); - } - }; - - Runnable runOk = new Runnable() { - public void run() { - checkAccount.setEnabled(true); - AssistantActivity.instance().saveCreatedAccount(username,password,null, getString(R.string.default_domain),null); - AssistantActivity.instance().isAccountVerified(username); - } - }; - - public void onResponse(long id, Object result) { - int answer = (Integer) result; - if (answer != 1) { - mHandler.post(runNotOk); - } else { - mHandler.post(runOk); - } - } - - public void onError(long id, XMLRPCException error) { - mHandler.post(runNotReachable); - } - - public void onServerError(long id, XMLRPCServerException error) { - mHandler.post(runNotReachable); - } - }; + xmlRpcSession = new LinphoneXmlRpcSessionImpl(LinphoneManager.getLcIfManagerNotDestroyedOrNull(), getString(R.string.wizard_url)); + xmlRpcRequest = new LinphoneXmlRpcRequestImpl("check_account_validated", LinphoneXmlRpcRequest.ArgType.Int); + xmlRpcRequest.setListener(this); + + return view; + } - client.callAsync(listener, "check_account_validated", username + "@" + getString(R.string.default_domain)); - } - catch(Exception ex) { + @Override + public void onXmlRpcRequestResponse(LinphoneXmlRpcRequest request) { + if (request.getStatus() == LinphoneXmlRpcRequest.Status.Ok) { + int response = request.getIntResponse(); + if (response != 1) { + mHandler.post(runNotOk); + } else { + mHandler.post(runOk); + } + } else if (request.getStatus() == LinphoneXmlRpcRequest.Status.Failed) { mHandler.post(runNotReachable); } } + + private void isAccountVerified(final String username) { + xmlRpcRequest.addStringArg(username + "@" + getString(R.string.default_domain)); + xmlRpcSession.sendRequest(xmlRpcRequest); + } } diff --git a/submodules/linphone b/submodules/linphone index 442cd8b9d..eb17eca54 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 442cd8b9db8dc29aab1c5e9952bab389dd8d478c +Subproject commit eb17eca54aba68112788af79d81bd2614c3ef6f6