Update linphone to get XmlRpc methods + replaced old xmlrpc API in CreateAccountActivationFragment
This commit is contained in:
parent
db3a38360a
commit
937b7d9953
3 changed files with 47 additions and 55 deletions
|
@ -19,9 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
package org.linphone;
|
package org.linphone;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
|
@ -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
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
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.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.app.Fragment;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -30,17 +34,16 @@ import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.Toast;
|
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
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class CreateAccountActivationFragment extends Fragment {
|
public class CreateAccountActivationFragment extends Fragment implements LinphoneXmlRpcRequestListener {
|
||||||
private String username, password;
|
private String username, password;
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
private Button checkAccount;
|
private Button checkAccount;
|
||||||
|
private LinphoneXmlRpcSession xmlRpcSession;
|
||||||
|
private LinphoneXmlRpcRequest xmlRpcRequest;
|
||||||
|
private Runnable runNotOk, runOk, runNotReachable;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
@ -58,58 +61,49 @@ public class CreateAccountActivationFragment extends Fragment {
|
||||||
isAccountVerified(username);
|
isAccountVerified(username);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return view;
|
runNotOk = new Runnable() {
|
||||||
}
|
public void run() {
|
||||||
|
checkAccount.setEnabled(true);
|
||||||
private void isAccountVerified(final String username) {
|
Toast.makeText(getActivity(), getString(R.string.assistant_account_not_validated), Toast.LENGTH_LONG).show();
|
||||||
final Runnable runNotReachable = new 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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
runNotReachable = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Toast.makeText(getActivity(), getString(R.string.wizard_server_unavailable), Toast.LENGTH_LONG).show();
|
Toast.makeText(getActivity(), getString(R.string.wizard_server_unavailable), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
xmlRpcSession = new LinphoneXmlRpcSessionImpl(LinphoneManager.getLcIfManagerNotDestroyedOrNull(), getString(R.string.wizard_url));
|
||||||
XMLRPCClient client = new XMLRPCClient(new URL(getString(R.string.wizard_url)));
|
xmlRpcRequest = new LinphoneXmlRpcRequestImpl("check_account_validated", LinphoneXmlRpcRequest.ArgType.Int);
|
||||||
|
xmlRpcRequest.setListener(this);
|
||||||
XMLRPCCallback listener = new XMLRPCCallback() {
|
|
||||||
Runnable runNotOk = new Runnable() {
|
return view;
|
||||||
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);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
client.callAsync(listener, "check_account_validated", username + "@" + getString(R.string.default_domain));
|
@Override
|
||||||
}
|
public void onXmlRpcRequestResponse(LinphoneXmlRpcRequest request) {
|
||||||
catch(Exception ex) {
|
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);
|
mHandler.post(runNotReachable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void isAccountVerified(final String username) {
|
||||||
|
xmlRpcRequest.addStringArg(username + "@" + getString(R.string.default_domain));
|
||||||
|
xmlRpcSession.sendRequest(xmlRpcRequest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 442cd8b9db8dc29aab1c5e9952bab389dd8d478c
|
Subproject commit eb17eca54aba68112788af79d81bd2614c3ef6f6
|
Loading…
Reference in a new issue