Beispiel #1
0
  /**
   * Creates an instance of <tt>FileMenu</tt>.
   *
   * @param parentWindow The parent <tt>ChatWindow</tt>.
   */
  public FileMenu(ChatWindow parentWindow) {
    super(GuiActivator.getResources().getI18NString("service.gui.FILE"));

    this.setOpaque(false);

    this.parentWindow = parentWindow;

    this.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.FILE"));

    this.add(myChatRoomsItem);
    this.add(historyItem);

    this.addSeparator();

    this.add(closeMenuItem);

    this.myChatRoomsItem.setName("myChatRooms");
    this.historyItem.setName("history");
    this.closeMenuItem.setName("close");

    this.myChatRoomsItem.addActionListener(this);
    this.historyItem.addActionListener(this);
    this.closeMenuItem.addActionListener(this);

    this.myChatRoomsItem.setMnemonic(
        GuiActivator.getResources().getI18nMnemonic("service.gui.MY_CHAT_ROOMS"));
    this.historyItem.setMnemonic(
        GuiActivator.getResources().getI18nMnemonic("service.gui.HISTORY"));
    this.closeMenuItem.setMnemonic(
        GuiActivator.getResources().getI18nMnemonic("service.gui.CLOSE"));
  }
Beispiel #2
0
  /** Reloads button resources. */
  public void loadSkin() {
    addButton.setIcon(
        GuiActivator.getResources().getImage("service.gui.icons.ADD_CONTACT_16x16_ICON"));
    callButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.CALL_16x16_ICON"));

    if (smsButton != null)
      smsButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.SMS_BUTTON_ICON"));
  }
  /** Constructs the <tt>AuthenticationWindow</tt>. */
  private void init() {
    this.idValue =
        new JTextField(
            chatRoom.getParentProvider().getProtocolProvider().getAccountID().getUserID());

    this.infoTextArea.setOpaque(false);
    this.infoTextArea.setLineWrap(true);
    this.infoTextArea.setWrapStyleWord(true);
    this.infoTextArea.setFont(infoTextArea.getFont().deriveFont(Font.BOLD));
    this.infoTextArea.setEditable(false);
    this.infoTextArea.setText(
        GuiActivator.getResources()
            .getI18NString(
                "service.gui.CHAT_ROOM_REQUIRES_PASSWORD",
                new String[] {chatRoom.getChatRoomName()}));

    this.idLabel.setFont(idLabel.getFont().deriveFont(Font.BOLD));
    this.passwdLabel.setFont(passwdLabel.getFont().deriveFont(Font.BOLD));

    this.labelsPanel.add(idLabel);
    this.labelsPanel.add(passwdLabel);

    this.textFieldsPanel.add(idValue);
    this.textFieldsPanel.add(passwdField);

    this.buttonsPanel.add(loginButton);
    this.buttonsPanel.add(cancelButton);

    this.mainPanel.add(infoTextArea, BorderLayout.NORTH);
    this.mainPanel.add(labelsPanel, BorderLayout.WEST);
    this.mainPanel.add(textFieldsPanel, BorderLayout.CENTER);
    this.mainPanel.add(buttonsPanel, BorderLayout.SOUTH);

    this.backgroundPanel.add(mainPanel, BorderLayout.CENTER);

    this.loginButton.setName("ok");
    this.cancelButton.setName("cancel");

    this.loginButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.OK"));
    this.cancelButton.setMnemonic(
        GuiActivator.getResources().getI18nMnemonic("service.gui.CANCEL"));

    this.loginButton.addActionListener(this);
    this.cancelButton.addActionListener(this);

    this.getRootPane().setDefaultButton(loginButton);

    this.setTransparent(true);
  }
Beispiel #4
0
  /** Initializes the call button. */
  private void initCallButton() {
    List<ProtocolProviderService> telephonyProviders = CallManager.getTelephonyProviders();

    if (telephonyProviders != null && telephonyProviders.size() > 0) {
      if (callButton.getParent() != null) return;

      callButton.setAlignmentX(JButton.CENTER_ALIGNMENT);

      callButton.setMnemonic(
          GuiActivator.getResources().getI18nMnemonic("service.gui.CALL_CONTACT"));

      buttonPanel.add(callButton);

      callButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              String searchText = parentWindow.getCurrentSearchText();

              if (searchText == null) return;

              CallManager.createCall(searchText, callButton);
            }
          });
    } else {
      buttonPanel.remove(callButton);
    }
  }
  /**
   * Creates an instance of the <tt>LoginWindow</tt>.
   *
   * @param chatRoom the chat room for which we're authenticating
   */
  public ChatRoomAuthenticationWindow(ChatRoomWrapper chatRoom) {
    this.chatRoom = chatRoom;

    ImageIcon logoImage = new ImageIcon(chatRoom.getParentProvider().getImage());

    backgroundPanel = new LoginWindowBackground(logoImage);

    this.backgroundPanel.setPreferredSize(new Dimension(420, 230));

    this.backgroundPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    this.backgroundPanel.setBorder(BorderFactory.createEmptyBorder(20, 5, 5, 5));

    this.getContentPane().setLayout(new BorderLayout());

    this.init();

    this.getContentPane().add(backgroundPanel, BorderLayout.CENTER);

    this.setResizable(false);

    this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

    this.setTitle(
        GuiActivator.getResources()
            .getI18NString(
                "service.gui.AUTHENTICATION_WINDOW_TITLE",
                new String[] {chatRoom.getParentProvider().getName()}));

    this.enableKeyActions();
  }
  /** Opens the currently selected chat. */
  void openChatForSelection() {
    Object selectedValue = this.chatRoomsTableModel.getValueAt(this.chatRoomList.getSelectedRow());

    ChatRoomWrapper chatRoomWrapper;
    if (selectedValue instanceof ChatRoomWrapper) chatRoomWrapper = (ChatRoomWrapper) selectedValue;
    else return;

    if (!chatRoomWrapper.getChatRoom().isJoined()) {
      GuiActivator.getUIService().getConferenceChatManager().joinChatRoom(chatRoomWrapper);
    }

    ChatWindowManager chatWindowManager = GuiActivator.getUIService().getChatWindowManager();
    ChatPanel chatPanel = chatWindowManager.getMultiChat(chatRoomWrapper, true);

    chatWindowManager.openChat(chatPanel, true);
  }
  /** Removes the room that is currently selected. */
  void removeSelectedRoom() {
    ChatRoomWrapper chatRoomWrapper = chatRoomsTableModel.getValueAt(chatRoomList.getSelectedRow());

    ConferenceChatManager conferenceManager =
        GuiActivator.getUIService().getConferenceChatManager();
    conferenceManager.removeChatRoom(chatRoomWrapper);
  }
Beispiel #8
0
  /**
   * Handles the <tt>ActionEvent</tt> when one of the menu items is selected.
   *
   * @param e the <tt>ActionEvent</tt> that notified us
   */
  public void actionPerformed(ActionEvent e) {
    JMenuItem menuItem = (JMenuItem) e.getSource();
    String itemText = menuItem.getName();

    if (itemText.equalsIgnoreCase("myChatRooms")) {
      ChatRoomTableDialog.showChatRoomTableDialog();
    } else if (itemText.equals("history")) {
      HistoryWindow history;

      HistoryWindowManager historyWindowManager =
          GuiActivator.getUIService().getHistoryWindowManager();

      ChatPanel chatPanel = this.parentWindow.getCurrentChatPanel();
      ChatSession chatSession = chatPanel.getChatSession();

      if (historyWindowManager.containsHistoryWindowForContact(chatSession.getDescriptor())) {
        history = historyWindowManager.getHistoryWindowForContact(chatSession.getDescriptor());

        if (history.getState() == JFrame.ICONIFIED) history.setState(JFrame.NORMAL);

        history.toFront();
      } else {
        history = new HistoryWindow(chatPanel.getChatSession().getDescriptor());

        history.setVisible(true);

        historyWindowManager.addHistoryWindowForContact(chatSession.getDescriptor(), history);
      }
    } else if (itemText.equalsIgnoreCase("close")) {
      this.parentWindow.setVisible(false);
      this.parentWindow.dispose();
    }
  }
  private String getNickname() {
    String nickName = null;
    ChatOperationReasonDialog reasonDialog =
        new ChatOperationReasonDialog(
            GuiActivator.getResources().getI18NString("service.gui.CHANGE_NICKNAME"),
            GuiActivator.getResources().getI18NString("service.gui.CHANGE_NICKNAME_LABEL"));

    reasonDialog.setReasonFieldText("");

    int result = reasonDialog.showDialog();

    if (result == MessageDialog.OK_RETURN_CODE) {
      nickName = reasonDialog.getReason().trim();
    }

    return nickName;
  }
Beispiel #10
0
  /**
   * Handles the <tt>ActionEvent</tt>, when one of the tool bar buttons is clicked.
   *
   * @param e the <tt>ActionEvent</tt> that notified us
   */
  public void actionPerformed(ActionEvent e) {
    AbstractButton button = (AbstractButton) e.getSource();
    String buttonText = button.getName();

    ChatPanel chatPanel = chatContainer.getCurrentChat();

    if (buttonText.equals("previous")) {
      chatPanel.loadPreviousPageFromHistory();
    } else if (buttonText.equals("next")) {
      chatPanel.loadNextPageFromHistory();
    } else if (buttonText.equals("sendFile")) {
      SipCommFileChooser scfc =
          GenericFileDialog.create(
              null,
              "Send file...",
              SipCommFileChooser.LOAD_FILE_OPERATION,
              ConfigurationUtils.getSendFileLastDir());
      File selectedFile = scfc.getFileFromDialog();
      if (selectedFile != null) {
        ConfigurationUtils.setSendFileLastDir(selectedFile.getParent());
        chatContainer.getCurrentChat().sendFile(selectedFile);
      }
    } else if (buttonText.equals("invite")) {
      ChatInviteDialog inviteDialog = new ChatInviteDialog(chatPanel);

      inviteDialog.setVisible(true);
    } else if (buttonText.equals("leave")) {
      ChatRoomWrapper chatRoomWrapper =
          (ChatRoomWrapper) chatPanel.getChatSession().getDescriptor();
      ChatRoomWrapper leavedRoomWrapped =
          GuiActivator.getMUCService().leaveChatRoom(chatRoomWrapper);
    } else if (buttonText.equals("call")) {
      call(false, false);
    } else if (buttonText.equals("callVideo")) {
      call(true, false);
    } else if (buttonText.equals("desktop")) {
      call(true, true);
    } else if (buttonText.equals("options")) {
      GuiActivator.getUIService().getConfigurationContainer().setVisible(true);
    } else if (buttonText.equals("font")) chatPanel.showFontChooserDialog();
    else if (buttonText.equals("createConference")) {
      chatPanel.showChatConferenceDialog();
    }
  }
  /** Loads all images and colors. */
  public void loadSkin() {
    openedGroupIcon = new ImageIcon(ImageLoader.getImage(ImageLoader.OPENED_GROUP_ICON));

    closedGroupIcon = new ImageIcon(ImageLoader.getImage(ImageLoader.CLOSED_GROUP_ICON));

    callButton.setIconImage(ImageLoader.getImage(ImageLoader.CALL_BUTTON_SMALL));
    callButton.setRolloverIcon(ImageLoader.getImage(ImageLoader.CALL_BUTTON_SMALL_ROLLOVER));
    callButton.setPressedIcon(ImageLoader.getImage(ImageLoader.CALL_BUTTON_SMALL_PRESSED));

    chatButton.setIconImage(ImageLoader.getImage(ImageLoader.CHAT_BUTTON_SMALL));
    chatButton.setRolloverIcon(ImageLoader.getImage(ImageLoader.CHAT_BUTTON_SMALL_ROLLOVER));
    chatButton.setPressedIcon(ImageLoader.getImage(ImageLoader.CHAT_BUTTON_SMALL_PRESSED));

    msgReceivedImage = ImageLoader.getImage(ImageLoader.MESSAGE_RECEIVED_ICON);

    int groupForegroundProperty =
        GuiActivator.getResources().getColor("service.gui.CONTACT_LIST_GROUP_FOREGROUND");

    if (groupForegroundProperty > -1) groupForegroundColor = new Color(groupForegroundProperty);

    int contactForegroundProperty =
        GuiActivator.getResources().getColor("service.gui.CONTACT_LIST_CONTACT_FOREGROUND");

    if (contactForegroundProperty > -1)
      contactForegroundColor = new Color(contactForegroundProperty);

    callVideoButton.setIconImage(ImageLoader.getImage(ImageLoader.CALL_VIDEO_BUTTON_SMALL));
    callVideoButton.setRolloverIcon(
        ImageLoader.getImage(ImageLoader.CALL_VIDEO_BUTTON_SMALL_ROLLOVER));
    callVideoButton.setPressedIcon(
        ImageLoader.getImage(ImageLoader.CALL_VIDEO_BUTTON_SMALL_PRESSED));

    desktopSharingButton.setIconImage(ImageLoader.getImage(ImageLoader.DESKTOP_BUTTON_SMALL));
    desktopSharingButton.setRolloverIcon(
        ImageLoader.getImage(ImageLoader.DESKTOP_BUTTON_SMALL_ROLLOVER));
    desktopSharingButton.setPressedIcon(
        ImageLoader.getImage(ImageLoader.DESKTOP_BUTTON_SMALL_PRESSED));

    addContactButton.setIconImage(ImageLoader.getImage(ImageLoader.ADD_CONTACT_BUTTON_SMALL));
    addContactButton.setRolloverIcon(
        ImageLoader.getImage(ImageLoader.ADD_CONTACT_BUTTON_SMALL_ROLLOVER));
    addContactButton.setPressedIcon(
        ImageLoader.getImage(ImageLoader.ADD_CONTACT_BUTTON_SMALL_PRESSED));
  }
  /**
   * Handles the <tt>ActionEvent</tt>. Determines which menu item was selected and makes the
   * appropriate operations.
   *
   * @param e the event.
   */
  public void actionPerformed(ActionEvent e) {
    JMenuItem menuItem = (JMenuItem) e.getSource();
    String itemName = menuItem.getName();

    ConferenceChatManager conferenceManager =
        GuiActivator.getUIService().getConferenceChatManager();

    if (itemName.equals("removeChatRoom")) {
      conferenceManager.removeChatRoom(chatRoomWrapper);
    } else if (itemName.equals("leaveChatRoom")) {
      conferenceManager.leaveChatRoom(chatRoomWrapper);
    } else if (itemName.equals("joinChatRoom")) {
      conferenceManager.joinChatRoom(chatRoomWrapper);
    } else if (itemName.equals("openChatRoom")) {
      if (chatRoomWrapper.getChatRoom() != null) {
        if (!chatRoomWrapper.getChatRoom().isJoined()) {
          conferenceManager.joinChatRoom(chatRoomWrapper);
        }
      } else {
        // this is not a server persistent room we must create it
        // and join
        chatRoomWrapper =
            GuiActivator.getUIService()
                .getConferenceChatManager()
                .createChatRoom(
                    chatRoomWrapper.getChatRoomName(),
                    chatRoomWrapper.getParentProvider().getProtocolProvider(),
                    new ArrayList<String>(),
                    "",
                    true,
                    true);
      }

      ChatWindowManager chatWindowManager = GuiActivator.getUIService().getChatWindowManager();
      ChatPanel chatPanel = chatWindowManager.getMultiChat(chatRoomWrapper, true);

      chatWindowManager.openChat(chatPanel, true);
    } else if (itemName.equals("joinAsChatRoom")) {
      ChatRoomAuthenticationWindow authWindow = new ChatRoomAuthenticationWindow(chatRoomWrapper);

      authWindow.setVisible(true);
    }
  }
Beispiel #13
0
  /**
   * Returns the display details for the underlying <tt>MetaContact</tt>.
   *
   * @return the display details for the underlying <tt>MetaContact</tt>
   */
  public String getDisplayDetails() {
    String displayDetails = null;

    Iterator<Contact> protoContacts = metaContact.getContacts();

    String subscriptionDetails = null;

    while (protoContacts.hasNext()) {
      Contact protoContact = protoContacts.next();

      OperationSetExtendedAuthorizations authOpSet =
          protoContact
              .getProtocolProvider()
              .getOperationSet(OperationSetExtendedAuthorizations.class);

      if (authOpSet != null
          && authOpSet.getSubscriptionStatus(protoContact) != null
          && !authOpSet.getSubscriptionStatus(protoContact).equals(SubscriptionStatus.Subscribed)) {
        SubscriptionStatus status = authOpSet.getSubscriptionStatus(protoContact);

        if (status.equals(SubscriptionStatus.SubscriptionPending))
          subscriptionDetails =
              GuiActivator.getResources().getI18NString("service.gui.WAITING_AUTHORIZATION");
        else if (status.equals(SubscriptionStatus.NotSubscribed))
          subscriptionDetails =
              GuiActivator.getResources().getI18NString("service.gui.NOT_AUTHORIZED");
      } else if (protoContact.getStatusMessage() != null
          && protoContact.getStatusMessage().length() > 0) {
        subscribed = true;
        displayDetails = protoContact.getStatusMessage();
        break;
      } else {
        subscribed = true;
      }
    }

    if ((displayDetails == null || displayDetails.length() <= 0)
        && !subscribed
        && subscriptionDetails != null
        && subscriptionDetails.length() > 0) displayDetails = subscriptionDetails;

    return displayDetails;
  }
Beispiel #14
0
  /** Sets the names of the call buttons depending on the chat session type. */
  private void setCallButtonsName() {
    if (chatSession instanceof ConferenceChatSession) {
      callButton.setName("createConference");
      callVideoButton.setName("createConference");
      this.callButton.setToolTipText(
          GuiActivator.getResources().getI18NString("service.gui.CREATE_JOIN_VIDEO_CONFERENCE"));

      this.callVideoButton.setToolTipText(
          GuiActivator.getResources().getI18NString("service.gui.CREATE_JOIN_VIDEO_CONFERENCE"));
    } else {
      callButton.setName("call");
      callVideoButton.setName("callVideo");
      this.callButton.setToolTipText(
          GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT"));

      this.callVideoButton.setToolTipText(
          GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT"));
    }
  }
Beispiel #15
0
  /**
   * Updates the text area to take into account the new search text.
   *
   * @param searchText the search text to update
   */
  private void updateTextArea(String searchText) {
    if (callButton.getParent() != null) {
      textArea.setText(
          GuiActivator.getResources()
              .getI18NString(
                  "service.gui.NO_CONTACTS_FOUND", new String[] {'"' + searchText + '"'}));

      this.revalidate();
      this.repaint();
    }
  }
  /**
   * The handler for the security event received. The security event for starting establish a secure
   * connection.
   *
   * @param evt the security started event received
   */
  public void securityNegotiationStarted(CallPeerSecurityNegotiationStartedEvent evt) {
    if (Boolean.parseBoolean(
        GuiActivator.getResources().getSettingsString("impl.gui.PARANOIA_UI"))) {
      SrtpControl srtpControl = null;
      if (callPeer instanceof MediaAwareCallPeer) srtpControl = evt.getSecurityController();

      securityPanel = new ParanoiaTimerSecurityPanel<SrtpControl>(srtpControl);

      setSecurityPanelVisible(true);
    }
  }
Beispiel #17
0
  /** Constructs the <tt>SearchPanel</tt>. */
  private void init() {
    String searchString = GuiActivator.getResources().getI18NString("service.gui.SEARCH");
    JLabel searchLabel = new JLabel(searchString + ": ");

    searchButton =
        new JButton(searchString, new ImageIcon(ImageLoader.getImage(ImageLoader.SEARCH_ICON)));

    this.searchTextField.getDocument().addDocumentListener(this);

    this.add(searchLabel, BorderLayout.WEST);
    this.add(searchTextField, BorderLayout.CENTER);

    searchButton.setName("search");
    searchButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.SEARCH"));

    searchButton.addActionListener(this);

    this.historyWindow.getRootPane().setDefaultButton(searchButton);

    this.add(searchButton, BorderLayout.EAST);
  }
Beispiel #18
0
  /** Initializes the call button. */
  private void initSMSButton() {
    if (!parentWindow.hasOperationSet(OperationSetSmsMessaging.class)) return;

    smsButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.SEND_SMS"));

    smsButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.SMS_BUTTON_ICON"));

    buttonPanel.add(smsButton);

    smsButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            final String searchText = parentWindow.getCurrentSearchText();

            if (searchText == null) return;

            SMSManager.sendSMS(smsButton, searchText);
          }
        });
  }
Beispiel #19
0
  /**
   * Creates the <tt>UnknownContactPanel</tt> by specifying the parent window.
   *
   * @param window the parent window
   */
  public UnknownContactPanel(MainFrame window) {
    super(new BorderLayout());

    this.parentWindow = window;

    TransparentPanel mainPanel = new TransparentPanel(new BorderLayout());

    this.add(mainPanel, BorderLayout.NORTH);

    if (!ConfigurationUtils.isAddContactDisabled()) {
      initAddContactButton();
    }

    initCallButton();

    initSMSButton();

    initTextArea();
    mainPanel.add(textArea, BorderLayout.CENTER);

    if (callButton.getParent() != null) {
      textArea.setText(
          GuiActivator.getResources()
              .getI18NString(
                  "service.gui.NO_CONTACTS_FOUND",
                  new String[] {'"' + parentWindow.getCurrentSearchText() + '"'}));
    } else {
      textArea.setText(
          GuiActivator.getResources().getI18NString("service.gui.NO_CONTACTS_FOUND_SHORT"));
    }

    if (buttonPanel.getComponentCount() > 0) {
      TransparentPanel southPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));
      southPanel.add(buttonPanel);

      mainPanel.add(southPanel, BorderLayout.SOUTH);
    }

    loadSkin();
  }
  /**
   * Handles the <tt>ActionEvent</tt> triggered when one of the buttons is clicked. When "Login"
   * button is choosen installs a new account from the user input and logs in.
   *
   * @param evt the action event that has just occurred.
   */
  public void actionPerformed(ActionEvent evt) {
    JButton button = (JButton) evt.getSource();
    String buttonName = button.getName();

    if (buttonName.equals("ok")) {
      GuiActivator.getUIService()
          .getConferenceChatManager()
          .joinChatRoom(
              chatRoom, idValue.getText(), new String(passwdField.getPassword()).getBytes());
    }

    this.dispose();
  }
  /**
   * Handles buttons action events.
   *
   * @param evt the <tt>ActionEvent</tt> that notified us
   */
  public void actionPerformed(ActionEvent evt) {
    JButton sourceButton = (JButton) evt.getSource();

    if (sourceButton.equals(openFileButton)) {
      this.openFile(downloadFile);
    } else if (sourceButton.equals(openFolderButton)) {
      try {
        File downloadDir = GuiActivator.getFileAccessService().getDefaultDownloadDirectory();

        GuiActivator.getDesktopService().open(downloadDir);
      } catch (IllegalArgumentException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_DOES_NOT_EXIST"));
      } catch (NullPointerException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_DOES_NOT_EXIST"));
      } catch (UnsupportedOperationException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FILE_OPEN_NOT_SUPPORTED"));
      } catch (SecurityException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_OPEN_NO_PERMISSION"));
      } catch (IOException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_OPEN_NO_APPLICATION"));
      } catch (Exception e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open file.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_OPEN_FAILED"));
      }
    } else if (sourceButton.equals(cancelButton)) {
      if (fileTransfer != null) fileTransfer.cancel();
    }
  }
Beispiel #22
0
  /**
   * Establishes a call.
   *
   * @param isVideo indicates if a video call should be established.
   * @param isDesktopSharing indicates if a desktopSharing should be established.
   */
  private void call(boolean isVideo, boolean isDesktopSharing) {
    ChatPanel chatPanel = chatContainer.getCurrentChat();

    ChatSession chatSession = chatPanel.getChatSession();

    Class<? extends OperationSet> opSetClass;
    if (isVideo) {
      if (isDesktopSharing) opSetClass = OperationSetDesktopSharingServer.class;
      else opSetClass = OperationSetVideoTelephony.class;
    } else opSetClass = OperationSetBasicTelephony.class;

    List<ChatTransport> telTransports = null;
    if (chatSession != null) telTransports = chatSession.getTransportsForOperationSet(opSetClass);

    List<ChatTransport> contactOpSetSupported;

    contactOpSetSupported = getOperationSetForCapabilities(telTransports, opSetClass);

    List<UIContactDetail> res = new ArrayList<UIContactDetail>();
    for (ChatTransport ct : contactOpSetSupported) {
      HashMap<Class<? extends OperationSet>, ProtocolProviderService> m =
          new HashMap<Class<? extends OperationSet>, ProtocolProviderService>();
      m.put(opSetClass, ct.getProtocolProvider());

      UIContactDetailImpl d =
          new UIContactDetailImpl(
              ct.getName(), ct.getDisplayName(), null, null, null, m, null, ct.getName());
      PresenceStatus status = ct.getStatus();
      byte[] statusIconBytes = status.getStatusIcon();

      if (statusIconBytes != null && statusIconBytes.length > 0) {
        d.setStatusIcon(
            new ImageIcon(
                ImageLoader.getIndexedProtocolImage(
                    ImageUtils.getBytesInImage(statusIconBytes), ct.getProtocolProvider())));
      }

      res.add(d);
    }

    Point location = new Point(callButton.getX(), callButton.getY() + callButton.getHeight());

    SwingUtilities.convertPointToScreen(location, this);

    MetaContact metaContact = GuiActivator.getUIService().getChatContact(chatPanel);
    UIContactImpl uiContact = null;
    if (metaContact != null) uiContact = MetaContactListSource.getUIContact(metaContact);

    CallManager.call(res, uiContact, isVideo, isDesktopSharing, callButton, location);
  }
Beispiel #23
0
  private void initSmiliesSelectorBox() {
    this.smileysBox = new SmileysSelectorBox();

    this.smileysBox.setName("smiley");
    this.smileysBox.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.INSERT_SMILEY") + " Ctrl-M");

    SIPCommMenuBar smileyMenuBar = new SIPCommMenuBar();
    smileyMenuBar.setOpaque(false);
    smileyMenuBar.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
    smileyMenuBar.add(smileysBox);

    this.add(smileyMenuBar);
  }
  /** Inializes button tool tips. */
  private void initButtonToolTips() {
    callButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT"));
    callVideoButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.VIDEO_CALL"));
    desktopSharingButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.SHARE_DESKTOP"));
    chatButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.SEND_MESSAGE"));
    addContactButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.ADD_CONTACT"));

    // We need to explicitly remove the buttons from the tooltip manager,
    // because we're going to manager the tooltip ourselves in the
    // DefaultTreeContactList class. We need to do this in order to have
    // a different tooltip for every button and for non button area.
    ToolTipManager ttManager = ToolTipManager.sharedInstance();
    ttManager.unregisterComponent(callButton);
    ttManager.unregisterComponent(callVideoButton);
    ttManager.unregisterComponent(desktopSharingButton);
    ttManager.unregisterComponent(chatButton);
    ttManager.unregisterComponent(addContactButton);
  }
  /**
   * Creates a new <tt>JMenuItem</tt> and adds it to this <tt>JPopupMenu</tt>.
   *
   * @param textKey the key of the internationalized string in the resources of the application
   *     which represents the text of the new <tt>JMenuItem</tt>
   * @param iconID the <tt>ImageID</tt> of the image in the resources of the application which
   *     represents the icon of the new <tt>JMenuItem</tt>
   * @param name the name of the new <tt>JMenuItem</tt>
   * @return a new <tt>JMenuItem</tt> instance which has been added to this <tt>JPopupMenu</tt>
   */
  private JMenuItem createMenuItem(String textKey, ImageID iconID, String name) {
    ResourceManagementService resources = GuiActivator.getResources();
    JMenuItem menuItem =
        new JMenuItem(
            resources.getI18NString(textKey), new ImageIcon(ImageLoader.getImage(iconID)));

    menuItem.setMnemonic(resources.getI18nMnemonic(textKey));
    menuItem.setName(name);

    menuItem.addActionListener(this);

    add(menuItem);

    return menuItem;
  }
Beispiel #26
0
  /** Reloads icons. */
  public void loadSkin() {
    boolean fullScreen = this.callContainer.isFullScreen();

    setIconImage(
        ImageLoader.getImage(
            fullScreen
                ? ImageLoader.EXIT_FULL_SCREEN_BUTTON
                : ImageLoader.ENTER_FULL_SCREEN_BUTTON));
    setPreferredSize(new Dimension(44, 38));
    setToolTipText(
        GuiActivator.getResources()
            .getI18NString(
                fullScreen
                    ? "service.gui.EXIT_FULL_SCREEN_TOOL_TIP"
                    : "service.gui.ENTER_FULL_SCREEN_TOOL_TIP"));
  }
Beispiel #27
0
  private void initAddContactButton() {
    addButton.setAlignmentX(JButton.CENTER_ALIGNMENT);

    addButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.ADD_CONTACT"));

    buttonPanel.add(addButton);

    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            AddContactDialog dialog = new AddContactDialog(parentWindow);

            dialog.setContactAddress(parentWindow.getCurrentSearchText());
            dialog.setVisible(true);
          }
        });
  }
Beispiel #28
0
  /**
   * Creates a full filename for the call by combining the directory, file prefix and extension. If
   * the directory is <tt>null</tt> user's home directory is used.
   *
   * @param savedCallsPath the path to the directory in which the generated file name is to be
   *     placed
   * @return a full filename for the call
   */
  private String createDefaultFilename(String savedCallsPath) {
    // set to user's home when null
    if (savedCallsPath == null) {
      try {
        savedCallsPath =
            GuiActivator.getFileAccessService().getDefaultDownloadDirectory().getAbsolutePath();
      } catch (IOException ioex) {
        // Leave it in the current directory.
      }
    }

    String ext = configuration.getString(Recorder.FORMAT);

    // Use a default format when the configured one seems invalid.
    if ((ext == null) || (ext.length() == 0) || !isSupportedFormat(ext))
      ext = SoundFileUtils.DEFAULT_CALL_RECORDING_FORMAT;
    return ((savedCallsPath == null) ? "" : (savedCallsPath + File.separator))
        + generateCallFilename(ext);
  }
Beispiel #29
0
  /**
   * Implements ChatChangeListener#chatChanged(ChatPanel).
   *
   * @param chatPanel the <tt>ChatPanel</tt>, which changed
   */
  public void chatChanged(ChatPanel chatPanel) {
    if (chatPanel == null) {
      setChatSession(null);
    } else {
      MetaContact contact = GuiActivator.getUIService().getChatContact(chatPanel);

      for (PluginComponent c : pluginContainer.getPluginComponents()) c.setCurrentContact(contact);

      ChatSession chatSession = chatPanel.getChatSession();
      setChatSession(chatSession);

      leaveChatRoomButton.setEnabled(chatSession instanceof ConferenceChatSession);

      desktopSharingButton.setEnabled(!(chatSession instanceof ConferenceChatSession));

      inviteButton.setEnabled(chatPanel.findInviteChatTransport() != null);

      sendFileButton.setEnabled(chatPanel.findFileTransferChatTransport() != null);
      inviteButton.setEnabled(!chatPanel.isPrivateMessagingChat());

      if (chatSession instanceof ConferenceChatSession) {
        updateInviteContactButton();

        callButton.setVisible(false);
        callVideoButton.setVisible(false);
        callButton.setEnabled(true);
        callVideoButton.setEnabled(true);
      } else if (contact != null) {
        callButton.setVisible(true);
        callVideoButton.setVisible(true);
        new UpdateCallButtonWorker(contact).start();
      }

      changeHistoryButtonsState(chatPanel);

      setCallButtonsName();
      setCallButtonsIcons();

      currentChatTransportChanged(chatSession);
    }
  }
Beispiel #30
0
  /**
   * Implements ChatChangeListener#chatChanged(ChatPanel).
   *
   * @param chatPanel the <tt>ChatPanel</tt>, which changed
   */
  public void chatChanged(ChatPanel chatPanel) {
    if (chatPanel == null) {
      setChatSession(null);
    } else {
      MetaContact contact = GuiActivator.getUIService().getChatContact(chatPanel);

      for (PluginComponent c : pluginContainer.getPluginComponents()) c.setCurrentContact(contact);

      setChatSession(chatPanel.chatSession);

      leaveChatRoomButton.setEnabled(chatPanel.chatSession instanceof ConferenceChatSession);

      inviteButton.setEnabled(chatPanel.findInviteChatTransport() != null);

      sendFileButton.setEnabled(chatPanel.findFileTransferChatTransport() != null);

      new UpdateCallButtonWorker(contact).start();

      changeHistoryButtonsState(chatPanel);
    }
  }