/**
   * You are exiting the application! Definitely tell the network so it can tell EVERYONE else and
   * remove you from rooms that you were in. Save any history (new friends made, recordings of
   * discussions, chats, etc.), and delete the the unimportant data. Delete privateSpaces that you
   * were moderator of
   */
  public void disconnect() {
    // Leave all side chats (after leaving all of the side chats, the screen
    // should be at the main space
    for (Space s : Space.getAllSpaces().values()) {
      if (!s.isMainSpace()) {
        if (D) Log.v(TAG, "leaving a side chat");
        // s.getParticipantController().leaveSpace(false);
        s.getMUC().leave();
      } else {
        // Leave main space
        if (D) Log.v(TAG, "leaving the main space");
        s.getMUC().leave();
      }
    }
    userPrimary = null;
    Space.setMainSpace(null);
    buddyList = null;
    buddySelection = null;
    PrivateSpaceIconView.allPSIcons.clear();

    // Disconnect
    if (D) Log.v(TAG, "starting disconnect");

    // Disconnect and return to login screen
    LoginController.xmppService.disconnect();
    LoginController.xmppService = null;

    // if (D) Log.v(TAG,
    // "is there a connection? "+LoginController.xmppService.getXMPPConnection().isConnected());
    finishFromChild(this);

    if (D) Log.v(TAG, "starting intent stuff");

    Intent i = new Intent(MainApplication.this, LoginView.class);
    startActivity(i);
  }