Ejemplo n.º 1
0
  /** Saves the provided server settings. */
  private void saveSettings() {
    logEnter(LOG_TAG, "saveSettings");

    boolean acceptable;
    final LinkedList<String> reasons = new LinkedList<String>();

    ServerInstance newInstance = null;
    try {
      newInstance = createInstance();
      acceptable = newInstance.isDefinitionValid(this, reasons);
    } catch (final NumberFormatException nfe) {
      logException(LOG_TAG, "saveSettings", nfe);

      acceptable = false;
      reasons.add(getString(R.string.edit_server_err_port_not_int));
    }

    if (acceptable) {
      final String instanceID = newInstance.getID();

      try {
        final LinkedHashMap<String, ServerInstance> instanceMap =
            new LinkedHashMap<String, ServerInstance>(ServerInstance.getInstances(this));
        instanceMap.put(instanceID, newInstance);
        ServerInstance.saveInstances(this, instanceMap);
        instance = newInstance;
        finish();
        return;
      } catch (final Exception e) {
        logException(LOG_TAG, "saveSettings", e);

        reasons.add(getExceptionMessage(e));
      }
    }

    final Intent i = new Intent(this, PopUp.class);
    i.putExtra(PopUp.BUNDLE_FIELD_TITLE, getString(R.string.edit_server_popup_title_failed));
    i.putExtra(
        PopUp.BUNDLE_FIELD_TEXT,
        getString(R.string.edit_server_popup_text_failed, listToString(reasons)));
    startActivity(i);
  }
Ejemplo n.º 2
0
  /**
   * Performs all necessary processing when this activity is created.
   *
   * @param state The state information for this activity.
   */
  @Override()
  protected void onCreate(final Bundle state) {
    logEnter(LOG_TAG, "onCreate", state);

    super.onCreate(state);

    final Intent i = getIntent();
    final Bundle extras = i.getExtras();
    restoreState(extras);

    id = instance.getID();
    host = instance.getHost();
    port = instance.getPort();
    useSSL = instance.useSSL();
    useStartTLS = instance.useStartTLS();
    bindDN = instance.getBindDN();
    bindPW = instance.getBindPassword();
    baseDN = instance.getBaseDN();
  }