public void initialize() {
    final MainWindow mainWindow = SparkManager.getMainWindow();

    SparkManager.getMainWindow()
        .addMainWindowListener(
            new MainWindowListener() {
              public void shutdown() {
                int x = mainWindow.getX();
                int y = mainWindow.getY();
                int width = mainWindow.getWidth();
                int height = mainWindow.getHeight();

                LayoutSettings settings = LayoutSettingsManager.getLayoutSettings();

                settings.setMainWindowHeight(height);
                settings.setMainWindowWidth(width);
                settings.setMainWindowX(x);
                settings.setMainWindowY(y);
                if (mainWindow.isDocked()) {
                  settings.setSplitPaneDividerLocation(
                      mainWindow.getSplitPane().getDividerLocation());
                } else {
                  settings.setSplitPaneDividerLocation(-1);
                }
                LayoutSettingsManager.saveLayoutSettings();
              }

              public void mainWindowActivated() {}

              public void mainWindowDeactivated() {}
            });
  }
  /** Initializes the core phone objects. */
  private void initializePhone() {
    // Load Preferences
    loadPreferences();

    if (preferences == null) {
      return;
    }

    guiManager = new GuiManager();
    guiManager.addUserActionListener(this);
    logManager = new LogManagerImpl(this);

    this.getLogManager().setRemoteLogging(true);

    try {
      EventQueue.invokeAndWait(
          new Runnable() {
            @Override
            public void run() {
              registerMenu = new JCheckBoxMenuItem(PhoneRes.getIString("phone.enabled"));
            }
          });
    } catch (Exception e) {
      Log.error(e);
    }

    registerMenu.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            if (getStatus() == SipRegisterStatus.Unregistered
                || getStatus() == SipRegisterStatus.RegistrationFailed) {

              register();
            } else {
              handleUnregisterRequest();
            }
          }
        });

    SIPConfig.setPreferredNetworkAddress(preferences.getPreferredAddress());
    NetworkAddressManager.start();

    try {
      EventQueue.invokeAndWait(
          new Runnable() {
            @Override
            public void run() {
              // Initialize Missed calls
              missedCalls = new MissedCalls();
            }
          });
    } catch (Exception e) {
      Log.error(e);
    }

    final JMenu actionsMenu =
        SparkManager.getMainWindow().getMenuByName(Res.getString("menuitem.actions"));
    actionsMenu.add(registerMenu);
  }
Beispiel #3
0
 /** Displays the About Box for Spark. */
 private static void showAboutBox() {
   JOptionPane.showMessageDialog(
       SparkManager.getMainWindow(),
       Default.getString(Default.APPLICATION_NAME) + " " + JiveInfo.getVersion(),
       Res.getString("title.about"),
       JOptionPane.INFORMATION_MESSAGE,
       SparkRes.getImageIcon(SparkRes.MAIN_IMAGE));
 }
Beispiel #4
0
  public void showDialog() {
    if (notesFrame != null && notesFrame.isVisible()) {
      return;
    }

    notesFrame = new JFrame(FpRes.getString("title.chat.notes"));
    notesFrame.setIconImage(SparkManager.getMainWindow().getIconImage());
    notesFrame.getContentPane().setLayout(new BorderLayout());
    notesFrame.getContentPane().add(new JScrollPane(this), BorderLayout.CENTER);
    notesFrame.pack();
    notesFrame.setSize(500, 400);

    notesFrame.setLocationRelativeTo(SparkManager.getChatManager().getChatContainer());
    notesFrame.setVisible(true);

    textPane.requestFocusInWindow();
  }
  public PreferenceManager() {
    // Initialize base preferences
    ChatPreference chatPreferences = new ChatPreference();
    addPreference(chatPreferences);
    chatPreferences.load();

    GroupChatPreference groupChatPreferences = new GroupChatPreference();
    addPreference(groupChatPreferences);
    groupChatPreferences.load();

    MediaPreference preferenes = new MediaPreference();
    addPreference(preferenes);
    preferenes.load();

    //        PrivacyPreferences privacy = new PrivacyPreferences();
    //        addPreference(privacy);
    //        privacy.load();

    LocalPreference localPreferences = new LocalPreference();
    addPreference(localPreferences);
    localPreferences.load();

    getPreferences();

    SparkManager.getMainWindow()
        .addMainWindowListener(
            new MainWindowListener() {
              public void shutdown() {
                fireShutdown();
              }

              public void mainWindowActivated() {}

              public void mainWindowDeactivated() {}
            });
  }
Beispiel #6
0
  /** Saves the VCard. */
  private void saveVCard() {
    final VCard vcard = new VCard();

    // Save personal info
    vcard.setFirstName(personalPanel.getFirstName());
    vcard.setLastName(personalPanel.getLastName());
    vcard.setMiddleName(personalPanel.getMiddleName());
    vcard.setEmailHome(personalPanel.getEmailAddress());
    vcard.setNickName(personalPanel.getNickname());

    // Save business info
    vcard.setOrganization(businessPanel.getCompany());
    vcard.setAddressFieldWork("STREET", businessPanel.getStreetAddress());
    vcard.setAddressFieldWork("LOCALITY", businessPanel.getCity());
    vcard.setAddressFieldWork("REGION", businessPanel.getState());
    vcard.setAddressFieldWork("PCODE", businessPanel.getZipCode());
    vcard.setAddressFieldWork("CTRY", businessPanel.getCountry());
    vcard.setField("TITLE", businessPanel.getJobTitle());
    vcard.setOrganizationUnit(businessPanel.getDepartment());
    vcard.setPhoneWork("VOICE", businessPanel.getPhone());
    vcard.setPhoneWork("FAX", businessPanel.getFax());
    vcard.setPhoneWork("PAGER", businessPanel.getPager());
    vcard.setPhoneWork("CELL", businessPanel.getMobile());
    vcard.setField("URL", businessPanel.getWebPage());

    // Save Home Info
    vcard.setAddressFieldHome("STREET", homePanel.getStreetAddress());
    vcard.setAddressFieldHome("LOCALITY", homePanel.getCity());
    vcard.setAddressFieldHome("REGION", homePanel.getState());
    vcard.setAddressFieldHome("PCODE", homePanel.getZipCode());
    vcard.setAddressFieldHome("CTRY", homePanel.getCountry());
    vcard.setPhoneHome("VOICE", homePanel.getPhone());
    vcard.setPhoneHome("FAX", homePanel.getFax());
    vcard.setPhoneHome("PAGER", homePanel.getPager());
    vcard.setPhoneHome("CELL", homePanel.getMobile());

    // Save Avatar
    final File avatarFile = avatarPanel.getAvatarFile();
    byte[] avatarBytes = avatarPanel.getAvatarBytes();

    if (avatarFile != null) {
      try {
        // Make it 48x48
        ImageIcon icon = new ImageIcon(avatarFile.toURI().toURL());
        Image image = icon.getImage();
        image = image.getScaledInstance(-1, 48, Image.SCALE_SMOOTH);
        avatarBytes = GraphicUtils.getBytesFromImage(image);
      } catch (MalformedURLException e) {
        Log.error("Unable to set avatar.", e);
      }
    }

    // If avatar bytes, persist as vcard.
    if (avatarBytes != null) {
      vcard.setAvatar(avatarBytes);
    }

    try {
      final VCardManager vcardManager = SparkManager.getVCardManager();
      vcardManager.setPersonalVCard(vcard);

      vcard.save(SparkManager.getConnection());

      // Notify users.
      if (avatarFile != null || avatarBytes != null) {
        Presence presence = SparkManager.getWorkspace().getStatusBar().getPresence();
        Presence newPresence =
            new Presence(
                presence.getType(),
                presence.getStatus(),
                presence.getPriority(),
                presence.getMode());

        // Change my own presence
        SparkManager.getSessionManager().changePresence(newPresence);

        // Chnage avatar in status bar.
        StatusBar statusBar = SparkManager.getWorkspace().getStatusBar();
        statusBar.setAvatar(new ImageIcon(vcard.getAvatar()));
      } else {
        String firstName = vcard.getFirstName();
        String lastName = vcard.getLastName();
        StatusBar statusBar = SparkManager.getWorkspace().getStatusBar();
        if (ModelUtil.hasLength(firstName) && ModelUtil.hasLength(lastName)) {
          statusBar.setNickname(firstName + " " + lastName);
        } else if (ModelUtil.hasLength(firstName)) {
          statusBar.setNickname(firstName);
        }

        statusBar.setAvatar(null);
      }

      // Notify listenres
      SparkManager.getVCardManager().notifyVCardListeners();
    } catch (XMPPException e) {
      Log.error(e);
      JOptionPane.showMessageDialog(
          SparkManager.getMainWindow(),
          Res.getString("message.vcard.not.supported"),
          Res.getString("title.error"),
          JOptionPane.ERROR_MESSAGE);
    }
  }
Beispiel #7
0
  /** Displays the broadcast dialog. */
  public void invokeDialog() {
    final JDialog dlg;

    TitlePanel titlePanel;

    // Create the title panel for this dialog
    titlePanel =
        new TitlePanel(
            Res.getString("title.broadcast.message"),
            Res.getString("message.enter.broadcast.message"),
            null,
            true);

    // Construct main panel w/ layout.
    final JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(titlePanel, BorderLayout.NORTH);

    // The user should only be able to close this dialog.
    JButton okButton = new JButton(Res.getString("ok"));
    JButton closeButton = new JButton(Res.getString("close"));

    mainPanel.add(this, BorderLayout.CENTER);

    JPanel buttonpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    buttonpanel.add(okButton);
    buttonpanel.add(closeButton);

    mainPanel.add(buttonpanel, BorderLayout.SOUTH);

    dlg = new JDialog(SparkManager.getMainWindow(), Res.getString("broadcast"));
    dlg.setContentPane(mainPanel);
    dlg.pack();
    dlg.setSize(800, 600);
    dlg.setResizable(false);
    dlg.setLocationRelativeTo(SparkManager.getMainWindow());

    // Add listener
    okButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (sendBroadcasts(dlg)) {
              dlg.setVisible(false);
            }
          }
        });

    closeButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            dlg.setVisible(false);
          }
        });

    dlg.setVisible(true);
    dlg.toFront();
    dlg.requestFocus();

    messageBox.requestFocus();
  }
  public void display() {
    final JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new GridBagLayout());

    // Setup resource
    ResourceUtils.resLabel(addressLabel, addressField, Res.getString("label.jabber.address") + ":");

    RolloverButton backButton = new RolloverButton();
    backButton.setIcon(SparkRes.getImageIcon(SparkRes.LEFT_ARROW_IMAGE));
    backButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            int selectedItem = addressField.getSelectedIndex();
            if (selectedItem > 0) {
              Object historyItem = addressField.getItemAt(selectedItem - 1);
              browse((String) historyItem);
            }
          }
        });

    mainPanel.add(
        backButton,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    mainPanel.add(
        addressLabel,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    mainPanel.add(
        addressField,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            0,
            0));

    JButton browseButton = new JButton("");
    ResourceUtils.resButton(browseButton, Res.getString("button.browse"));
    browseButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String serviceName = (String) addressField.getSelectedItem();
            if (!ModelUtil.hasLength(serviceName)) {
              return;
            }
            browse(serviceName);
          }
        });
    mainPanel.add(
        addressField,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            0,
            0));
    mainPanel.add(
        browseButton,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));

    browsePanel = new JPanel();
    browsePanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    browsePanel.setBackground(Color.white);

    JScrollPane pane =
        new JScrollPane(
            browsePanel,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    browsePanel.setPreferredSize(new Dimension(0, 0));
    mainPanel.add(
        pane,
        new GridBagConstraints(
            0,
            1,
            4,
            1,
            1.0,
            1.0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));

    JFrame frame = new JFrame();
    frame.setIconImage(SparkRes.getImageIcon(SparkRes.FIND_IMAGE).getImage());

    JDialog dialog = new JDialog(frame, Res.getString("title.jabber.browser"));
    dialog.getContentPane().setLayout(new BorderLayout());
    dialog.getContentPane().add(mainPanel, BorderLayout.CENTER);
    dialog.pack();
    dialog.setSize(600, 400);
    dialog.setLocationRelativeTo(SparkManager.getMainWindow());
    dialog.setVisible(true);
  }
  public void showPreferences() {
    preferenceDialog = new PreferenceDialog();

    preferenceDialog.invoke(SparkManager.getMainWindow(), new PreferencesPanel(getPreferences()));
  }