void addAccount() {

    try {
      String accountName = editAccountName.getText().toString();
      String accountType = serverInfo.getAccountType();
      Properties propSettings = serverInfo.getAccountParamsAsProperties();

      AccountSettings settings = null;

      if (accountType.equals(org.exfio.csyncdroid.Constants.ACCOUNT_TYPE_FXACCOUNT)) {
        settings = new FxAccountAccountSettings();
      } else if (accountType.equals(org.exfio.csyncdroid.Constants.ACCOUNT_TYPE_LEGACYV5)) {
        settings = new LegacyV5AccountSettings();
      } else {
        settings = new ExfioPeerAccountSettings();

        // FIXME - Complete migration of this code from QueryServerDialogFrament

        /*
        WeaveClient weaveClient = WeaveClientFactory.getInstance(adParams);

        // Check underlying weave account is initialised
        if ( !weaveClient.isInitialised() ) {
        	throw new WeaveException(String.format("Weave account '%s@%s' not initialised.", adParams.user, adParams.accountServer));
        }

        ExfioPeerV1 auth = new ExfioPeerV1(weaveClient);

        // Check exfio peer account is initialised
        if ( !auth.isInitialised() ) {
        	throw new WeaveException(String.format("eXfio Peer account '%s@%s' not initialised.", adParams.user, adParams.accountServer));
        }

        //Initialise sqldroid jdbc provider
        Class.forName("org.sqldroid.SQLDroidDriver");

        String clientName = OSUtils.getPrettyName();

        //Build unique account guid that is also valid filename
        guid = WeaveAccount.generateAccountGuid(accountServer, username);

        //Create database file if it does not already exist

        android.database.sqlite.SQLiteDatabase database = null;
        try {
        	database = getContext().openOrCreateDatabase(guid, Context.MODE_PRIVATE, null);
        } catch(Exception e) {
        	Log.e(TAG, e.getMessage());
        } finally {
        	if ( database != null ) {
        		database.close();
        	}
        }
        String databasePath = getContext().getDatabasePath(guid).getAbsolutePath();

        // Request authorisation from existing client
        Log.i(TAG, String.format("Requesting client auth for client '%s'", clientName));

        auth.requestClientAuth(clientName, password, databasePath);
        String authCode = auth.getAuthCode();

        Log.i(TAG, String.format("Client auth request pending with auth code '%s'", authCode));
        */
      }

      Account account = null;
      try {
        account = settings.createAccount(getActivity(), accountName, propSettings);
      } catch (WeaveException e) {
        Toast.makeText(
                getActivity(),
                "Couldn't create account (account with this name already existing?)",
                Toast.LENGTH_LONG)
            .show();
        return;
      }

      // Register addressbook
      if (serverInfo.getAddressBook().isEnabled()) {
        ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
        ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
      } else {
        ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 0);
      }

      // TODO - support multiple calendars

      // Register calendar
      if (serverInfo.getCalendar().isEnabled()) {
        LocalCalendar.create(account, getActivity().getContentResolver(), serverInfo.getCalendar());
        ContentResolver.setIsSyncable(account, CalendarContract.AUTHORITY, 1);
        ContentResolver.setSyncAutomatically(account, CalendarContract.AUTHORITY, true);
      } else {
        ContentResolver.setIsSyncable(account, CalendarContract.AUTHORITY, 0);
      }

      getActivity().finish();

    } catch (Exception e) {
      Log.getInstance().error(String.format("Error creating account - %s", e.getMessage()));
      Toast.makeText(getActivity(), "Couldn't create account", Toast.LENGTH_LONG).show();
    }
  }