コード例 #1
0
  @Override
  public void onClick(View v) {
    int id = v.getId();

    if (id == R.id.setup_apply) {
      if (login.getText() == null
          || login.length() == 0
          || password.getText() == null
          || password.length() == 0) {
        Toast.makeText(
                getActivity(),
                getString(R.string.first_launch_no_login_password),
                Toast.LENGTH_LONG)
            .show();
        return;
      }

      SetupActivity.instance()
          .genericLogIn(login.getText().toString(), password.getText().toString(), domain);
    }
  }
コード例 #2
0
  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);
          }
        };

    final Context context =
        SetupActivity.instance() == null
            ? LinphoneService.instance().getApplicationContext()
            : SetupActivity.instance();

    try {
      XMLRPCClient client = new XMLRPCClient(new URL(context.getString(R.string.wizard_url)));

      XMLRPCCallback listener =
          new XMLRPCCallback() {
            Runnable runNotOk =
                new Runnable() {
                  public void run() {
                    errorMessage.setText(R.string.wizard_failed);
                  }
                };

            Runnable runOk =
                new Runnable() {
                  public void run() {
                    SetupActivity.instance()
                        .saveCreatedAccount(
                            username, password, context.getString(R.string.default_domain));
                    SetupActivity.instance().displayWizardConfirm(username);
                  }
                };

            public void onResponse(long id, Object result) {
              int answer = (Integer) result;
              if (answer != 0) {
                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,
          "create_account_with_useragent",
          username,
          password,
          email,
          LinphoneManager.getInstance().getUserAgent());
    } catch (Exception ex) {
      mHandler.post(runNotReachable);
    }
  }