/**
     * Details have been retrieved.
     *
     * @param details the details retrieved if any.
     */
    public void detailsRetrieved(Iterator<GenericDetail> details) {
      // if treenode has changed ignore
      if (!source.equals(treeNode)) return;

      while (details.hasNext()) {
        GenericDetail d = details.next();

        if (d instanceof PhoneNumberDetail
            && !(d instanceof PagerDetail)
            && !(d instanceof FaxDetail)) {
          final PhoneNumberDetail pnd = (PhoneNumberDetail) d;
          if (pnd.getNumber() != null && pnd.getNumber().length() > 0) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    callButton.setEnabled(true);

                    if (pnd instanceof VideoDetail) {
                      callVideoButton.setEnabled(true);
                      desktopSharingButton.setEnabled(true);
                    }

                    treeContactList.refreshContact(uiContact);
                  }
                });

            return;
          }
        }
      }
    }
Beispiel #2
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);
  }
  /**
   * Calls the given treeNode.
   *
   * @param treeNode the <tt>TreeNode</tt> to call
   */
  private void call(TreeNode treeNode, JButton button, boolean isVideo, boolean isDesktopSharing) {
    if (!(treeNode instanceof ContactNode)) return;

    UIContact contactDescriptor = ((ContactNode) treeNode).getContactDescriptor();

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

    SwingUtilities.convertPointToScreen(location, treeContactList);

    location.y = location.y + treeContactList.getPathBounds(treeContactList.getSelectionPath()).y;
    location.x += 8;
    location.y -= 8;

    CallManager.call(contactDescriptor, isVideo, isDesktopSharing, treeContactList, location);
  }
  /**
   * Shows the appropriate user interface that would allow the user to add the given
   * <tt>SourceUIContact</tt> to their contact list.
   *
   * @param contact the contact to add
   */
  private void addContact(SourceUIContact contact) {
    SourceContact sourceContact = (SourceContact) contact.getDescriptor();

    List<ContactDetail> details =
        sourceContact.getContactDetails(OperationSetPersistentPresence.class);
    int detailsCount = details.size();

    if (detailsCount > 1) {
      JMenuItem addContactMenu =
          TreeContactList.createAddContactMenu((SourceContact) contact.getDescriptor());

      JPopupMenu popupMenu = ((JMenu) addContactMenu).getPopupMenu();

      // Add a title label.
      JLabel infoLabel = new JLabel();
      infoLabel.setText(
          "<html><b>"
              + GuiActivator.getResources().getI18NString("service.gui.ADD_CONTACT")
              + "</b></html>");

      popupMenu.insert(infoLabel, 0);
      popupMenu.insert(new Separator(), 1);

      popupMenu.setFocusable(true);
      popupMenu.setInvoker(treeContactList);

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

      SwingUtilities.convertPointToScreen(location, treeContactList);

      location.y = location.y + treeContactList.getPathBounds(treeContactList.getSelectionPath()).y;

      popupMenu.setLocation(location.x + 8, location.y - 8);
      popupMenu.setVisible(true);
    } else if (details.size() == 1) {
      TreeContactList.showAddContactDialog(details.get(0), sourceContact.getDisplayName());
    }
  }