Exemplo n.º 1
0
  @Test
  public void testCreateStoreUriImapNoExtra() {
    ServerSettings settings =
        new ServerSettings(
            ImapStore.STORE_TYPE,
            "server",
            143,
            ConnectionSecurity.NONE,
            AuthType.PLAIN,
            "user",
            "pass",
            null);

    String uri = RemoteStore.createStoreUri(settings);

    assertEquals("imap://*****:*****@server:143/1%7C", uri);
  }
Exemplo n.º 2
0
  @Test
  public void testCreateStoreUriImapAutoDetectNamespace() {
    Map<String, String> extra = new HashMap<String, String>();
    extra.put("autoDetectNamespace", "true");

    ServerSettings settings =
        new ServerSettings(
            ImapStore.STORE_TYPE,
            "server",
            143,
            ConnectionSecurity.NONE,
            AuthType.PLAIN,
            "user",
            "pass",
            null,
            extra);

    String uri = RemoteStore.createStoreUri(settings);

    assertEquals("imap://*****:*****@server:143/1%7C", uri);
  }
Exemplo n.º 3
0
  @Test
  public void testCreateDecodeStoreUriWithSpecialCharactersInUsernameAndPassword() {
    ServerSettings settings =
        new ServerSettings(
            ImapStore.STORE_TYPE,
            "server",
            143,
            ConnectionSecurity.NONE,
            AuthType.PLAIN,
            "user@doma:n",
            "p@ssw:rd%",
            null,
            null);

    String uri = RemoteStore.createStoreUri(settings);

    assertEquals("imap://*****:*****@server:143/1%7C", uri);

    ServerSettings outSettings = RemoteStore.decodeStoreUri(uri);
    assertEquals("user@doma:n", outSettings.username);
    assertEquals("p@ssw:rd%", outSettings.password);
  }
  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);
    }
  }