/** * 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); }
/** * Adds all contacts contained in the given <tt>MetaContactGroup</tt> matching the current filter * and not contained in the contact list. * * @param metaGroup the <tt>MetaContactGroup</tt>, which matching contacts to add * @param query the <tt>MetaContactQuery</tt> that notifies interested listeners of the results of * this matching * @param resultCount the initial result count we would insert directly to the contact list * without firing events */ private void addMatching(MetaContactGroup metaGroup, MetaContactQuery query, int resultCount) { Iterator<MetaContact> childContacts = metaGroup.getChildContacts(); while (childContacts.hasNext() && !query.isCanceled()) { MetaContact metaContact = childContacts.next(); if (isMatching(metaContact)) { resultCount++; if (resultCount <= INITIAL_CONTACT_COUNT) { UIGroup uiGroup = null; if (!MetaContactListSource.isRootGroup(metaGroup)) { synchronized (metaGroup) { uiGroup = MetaContactListSource.getUIGroup(metaGroup); if (uiGroup == null) uiGroup = MetaContactListSource.createUIGroup(metaGroup); } } if (logger.isDebugEnabled()) logger.debug("Presence filter contact added: " + metaContact.getDisplayName()); UIContactImpl newUIContact; synchronized (metaContact) { newUIContact = MetaContactListSource.getUIContact(metaContact); if (newUIContact == null) { newUIContact = MetaContactListSource.createUIContact(metaContact); } } GuiActivator.getContactList().addContact(newUIContact, uiGroup, true, true); query.setInitialResultCount(resultCount); } else { query.fireQueryEvent(metaContact); } } } // If in the meantime the filtering has been stopped we return here. if (query.isCanceled()) return; Iterator<MetaContactGroup> subgroups = metaGroup.getSubgroups(); while (subgroups.hasNext() && !query.isCanceled()) { MetaContactGroup subgroup = subgroups.next(); if (isMatching(subgroup)) { UIGroup uiGroup; synchronized (subgroup) { uiGroup = MetaContactListSource.getUIGroup(subgroup); if (uiGroup == null) uiGroup = MetaContactListSource.createUIGroup(subgroup); } GuiActivator.getContactList().addGroup(uiGroup, true); addMatching(subgroup, query, resultCount); } } }
/** * Returns <tt>true</tt> if offline contacts are shown or if the given <tt>MetaContactGroup</tt> * contains online contacts. * * @param metaGroup the <tt>MetaContactGroup</tt> to check * @return <tt>true</tt> if the given <tt>MetaContactGroup</tt> is matching this filter */ private boolean isMatching(MetaContactGroup metaGroup) { return isShowOffline || (metaGroup.countOnlineChildContacts() > 0) || MetaContactListSource.isNewGroup(metaGroup); }