protected void fixAlarm(VObject vObject, boolean fromServer) {
    if (vObject.vObjects != null) {
      if (Settings.getBooleanProperty("davmail.caldavDisableReminders", false)) {
        ArrayList<VObject> vAlarms = null;
        for (VObject vAlarm : vObject.vObjects) {
          if ("VALARM".equals(vAlarm.type)) {
            if (vAlarms == null) {
              vAlarms = new ArrayList<VObject>();
            }
            vAlarms.add(vAlarm);
          }
        }
        // remove all vAlarms
        if (vAlarms != null) {
          for (VObject vAlarm : vAlarms) {
            vObject.vObjects.remove(vAlarm);
          }
        }

      } else {
        for (VObject vAlarm : vObject.vObjects) {
          if ("VALARM".equals(vAlarm.type)) {
            String action = vAlarm.getPropertyValue("ACTION");
            if (fromServer
                && "DISPLAY".equals(action)
                // convert DISPLAY to AUDIO only if user defined an alarm sound
                && Settings.getProperty("davmail.caldavAlarmSound") != null) {
              // Convert alarm to audio for iCal
              vAlarm.setPropertyValue("ACTION", "AUDIO");

              if (vAlarm.getPropertyValue("ATTACH") == null) {
                // Add defined sound into the audio alarm
                VProperty vProperty =
                    new VProperty("ATTACH", Settings.getProperty("davmail.caldavAlarmSound"));
                vProperty.addParam("VALUE", "URI");
                vAlarm.addProperty(vProperty);
              }

            } else if (!fromServer && "AUDIO".equals(action)) {
              // Use the alarm action that exchange (and blackberry) understand
              // (exchange and blackberry don't understand audio actions)
              vAlarm.setPropertyValue("ACTION", "DISPLAY");
            }
          }
        }
      }
    }
  }
  protected void createAndShowGUI() {
    System.setProperty("swing.defaultlaf", UIManager.getSystemLookAndFeelClassName());

    image = DavGatewayTray.loadImage("tray.png");
    image2 = DavGatewayTray.loadImage(AwtGatewayTray.TRAY_ACTIVE_PNG);
    inactiveImage = DavGatewayTray.loadImage(AwtGatewayTray.TRAY_INACTIVE_PNG);

    mainFrame = new JFrame();
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setTitle(BundleMessage.format("UI_DAVMAIL_GATEWAY"));
    mainFrame.setIconImage(image);

    JPanel errorPanel = new JPanel();
    errorPanel.setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_LAST_MESSAGE")));
    errorPanel.setLayout(new BoxLayout(errorPanel, BoxLayout.X_AXIS));
    errorArea = new JTextPane();
    errorArea.setEditable(false);
    errorArea.setBackground(mainFrame.getBackground());
    errorLabel = new JLabel();
    errorPanel.add(errorLabel);
    errorPanel.add(errorArea);

    JPanel messagePanel = new JPanel();
    messagePanel.setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_LAST_LOG")));
    messagePanel.setLayout(new BoxLayout(messagePanel, BoxLayout.X_AXIS));

    messageArea = new JTextPane();
    messageArea.setText(BundleMessage.format("LOG_STARTING_DAVMAIL"));
    messageArea.setEditable(false);
    messageArea.setBackground(mainFrame.getBackground());
    messagePanel.add(messageArea);

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(errorPanel);
    mainPanel.add(messagePanel);
    mainFrame.add(mainPanel);

    aboutFrame = new AboutFrame();
    settingsFrame = new SettingsFrame();
    buildMenu();

    mainFrame.setMinimumSize(new Dimension(400, 180));
    mainFrame.pack();
    // workaround MacOSX
    if (mainFrame.getSize().width < 400 || mainFrame.getSize().height < 180) {
      mainFrame.setSize(
          Math.max(mainFrame.getSize().width, 400), Math.max(mainFrame.getSize().height, 180));
    }
    // center frame
    mainFrame.setLocation(
        mainFrame.getToolkit().getScreenSize().width / 2 - mainFrame.getSize().width / 2,
        mainFrame.getToolkit().getScreenSize().height / 2 - mainFrame.getSize().height / 2);
    mainFrame.setVisible(true);

    // display settings frame on first start
    if (Settings.isFirstStart()) {
      settingsFrame.setVisible(true);
      settingsFrame.toFront();
      settingsFrame.requestFocus();
    }
  }