コード例 #1
0
  protected void onNext() {
    try {

      ConnectionSecurity connectionSecurity = getSelectedSecurity();

      String username = mUsernameView.getText().toString();
      String password = null;
      String clientCertificateAlias = null;

      AuthType authType = getSelectedAuthType();
      if (authType == AuthType.EXTERNAL) {
        clientCertificateAlias = mClientCertificateSpinner.getAlias();
      } else {
        password = mPasswordView.getText().toString();
      }
      String host = mServerView.getText().toString();
      int port = Integer.parseInt(mPortView.getText().toString());

      Map<String, String> extra = null;
      if (Type.IMAP == mStoreType) {
        extra = new HashMap<String, String>();
        extra.put(
            ImapStoreSettings.AUTODETECT_NAMESPACE_KEY,
            Boolean.toString(mImapAutoDetectNamespaceView.isChecked()));
        extra.put(ImapStoreSettings.PATH_PREFIX_KEY, mImapPathPrefixView.getText().toString());
      } else if (Type.WebDAV == mStoreType) {
        extra = new HashMap<String, String>();
        extra.put(WebDavStoreSettings.PATH_KEY, mWebdavPathPrefixView.getText().toString());
        extra.put(WebDavStoreSettings.AUTH_PATH_KEY, mWebdavAuthPathView.getText().toString());
        extra.put(
            WebDavStoreSettings.MAILBOX_PATH_KEY, mWebdavMailboxPathView.getText().toString());
      }

      mAccount.deleteCertificate(host, port, CheckDirection.INCOMING);
      ServerSettings settings =
          new ServerSettings(
              mStoreType,
              host,
              port,
              connectionSecurity,
              authType,
              username,
              password,
              clientCertificateAlias,
              extra);

      mAccount.setStoreUri(RemoteStore.createStoreUri(settings));

      mAccount.setCompression(NetworkType.MOBILE, mCompressionMobile.isChecked());
      mAccount.setCompression(NetworkType.WIFI, mCompressionWifi.isChecked());
      mAccount.setCompression(NetworkType.OTHER, mCompressionOther.isChecked());
      // mAccount.setSubscribedFoldersOnly(mSubscribedFoldersOnly.isChecked());

      // visual voicemail specific setup
      if (!Intent.ACTION_EDIT.equals(getIntent().getAction())) {
        mAccount.setRequiresCellular(mRequiresCellular.isChecked());
        mAccount.setDescription(mAccountName.getText().toString());
        mAccount.setPhoneNumber("");
        mAccount = AccountCreator.initialVisualVoicemailSetup(AccountSetupIncoming.this, mAccount);
      }

      AccountSetupCheckSettings.actionCheckSettings(this, mAccount, CheckDirection.INCOMING);
    } catch (Exception e) {
      failure(e);
    }
  }