/** * Resets the rollover state of all rollover components in the current cell except the component * given as a parameter. * * @param excludeComponent the component to exclude from the reset */ public void resetRolloverState(Component excludeComponent) { if (!chatButton.equals(excludeComponent)) chatButton.getModel().setRollover(false); if (!callButton.equals(excludeComponent)) callButton.getModel().setRollover(false); if (!callVideoButton.equals(excludeComponent)) callVideoButton.getModel().setRollover(false); if (!desktopSharingButton.equals(excludeComponent)) desktopSharingButton.getModel().setRollover(false); if (!addContactButton.equals(excludeComponent)) addContactButton.getModel().setRollover(false); if (customActionButtons != null) { Iterator<JButton> buttonsIter = customActionButtons.iterator(); while (buttonsIter.hasNext()) { JButton button = buttonsIter.next(); if (!button.equals(excludeComponent)) button.getModel().setRollover(false); } } if (customActionButtonsUIGroup != null) { Iterator<JButton> buttonsIter = customActionButtonsUIGroup.iterator(); while (buttonsIter.hasNext()) { JButton button = buttonsIter.next(); if (!button.equals(excludeComponent)) button.getModel().setRollover(false); } } }
/** * Put the JAIN-SIP stack in a state where it cannot receive any data and frees the network ports * used. That is to say remove JAIN-SIP <tt>ListeningPoint</tt>s and <tt>SipProvider</tt>s. */ @SuppressWarnings("unchecked") // jain-sip legacy code private void stopListening() { try { this.secureJainSipProvider.removeSipListener(this); this.stack.deleteSipProvider(this.secureJainSipProvider); this.secureJainSipProvider = null; this.clearJainSipProvider.removeSipListener(this); this.stack.deleteSipProvider(this.clearJainSipProvider); this.clearJainSipProvider = null; Iterator<ListeningPoint> it = this.stack.getListeningPoints(); Vector<ListeningPoint> lpointsToRemove = new Vector<ListeningPoint>(); while (it.hasNext()) { lpointsToRemove.add(it.next()); } it = lpointsToRemove.iterator(); while (it.hasNext()) { this.stack.deleteListeningPoint(it.next()); } this.stack.stop(); if (logger.isTraceEnabled()) logger.trace("stopped listening"); } catch (ObjectInUseException ex) { logger.fatal("Failed to stop listening", ex); } }
/** * Searches for additional phone numbers found in contact information * * @return additional phone numbers found in contact information; */ private List<UIContactDetail> getAdditionalNumbers(boolean onlyMobile) { List<UIContactDetail> telephonyContacts = new ArrayList<UIContactDetail>(); Iterator<Contact> contacts = getMetaContact().getContacts(); while (contacts.hasNext()) { Contact contact = contacts.next(); OperationSetServerStoredContactInfo infoOpSet = contact.getProtocolProvider().getOperationSet(OperationSetServerStoredContactInfo.class); Iterator<GenericDetail> details; ArrayList<String> phones = new ArrayList<String>(); if (infoOpSet != null) { details = infoOpSet.getAllDetailsForContact(contact); while (details.hasNext()) { GenericDetail d = details.next(); boolean process = false; if (onlyMobile) { if (d instanceof MobilePhoneDetail) process = true; } else if (d instanceof PhoneNumberDetail && !(d instanceof PagerDetail) && !(d instanceof FaxDetail)) { process = true; } if (process) { PhoneNumberDetail pnd = (PhoneNumberDetail) d; if (pnd.getNumber() != null && pnd.getNumber().length() > 0) { // skip phones which were already added if (phones.contains(pnd.getNumber())) continue; phones.add(pnd.getNumber()); UIContactDetail cd = new UIContactDetailImpl( pnd.getNumber(), pnd.getNumber() + " (" + getLocalizedPhoneNumber(d) + ")", null, new ArrayList<String>(), GuiActivator.getResources().getImage("service.gui.icons.EXTERNAL_PHONE"), null, null, pnd) { @Override public PresenceStatus getPresenceStatus() { return null; } }; telephonyContacts.add(cd); } } } } } return telephonyContacts; }
/** * Indicates whether some other object is "equal to" this one which in terms of contact groups * translates to having the equal names and matching subgroups and child contacts. The resolved * status of contactgroups and contacts is deliberately ignored so that groups and/or contacts * would be assumed equal even if it differs. * * <p> * * @param obj the reference object with which to compare. * @return <code>true</code> if this contact group has the equal child contacts and subgroups to * those of the <code>obj</code> argument. */ @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof MockContactGroup)) return false; MockContactGroup mockGroup = (MockContactGroup) obj; if (!mockGroup.getGroupName().equals(getGroupName()) || !mockGroup.getUID().equals(getUID()) || mockGroup.countContacts() != countContacts() || mockGroup.countSubgroups() != countSubgroups()) return false; // traverse child contacts Iterator<Contact> theirContacts = mockGroup.contacts(); while (theirContacts.hasNext()) { MockContact theirContact = (MockContact) theirContacts.next(); MockContact ourContact = (MockContact) getContact(theirContact.getAddress()); if (ourContact == null || !ourContact.equals(theirContact)) return false; } // traverse subgroups Iterator<ContactGroup> theirSubgroups = mockGroup.subgroups(); while (theirSubgroups.hasNext()) { MockContactGroup theirSubgroup = (MockContactGroup) theirSubgroups.next(); MockContactGroup ourSubgroup = (MockContactGroup) getGroup(theirSubgroup.getGroupName()); if (ourSubgroup == null || !ourSubgroup.equals(theirSubgroup)) return false; } return true; }
/** * Initializes custom contact action buttons. * * @param contactActionButtons the list of buttons to initialize * @param gridX the X grid of the first button * @param xBounds the x bounds of the first button * @return the new grid X coordinate after adding all the buttons */ private int initGroupActionButtons( Collection<SIPCommButton> contactActionButtons, int gridX, int xBounds) { // Reinit the labels to take the whole horizontal space. addLabels(gridX + contactActionButtons.size()); Iterator<SIPCommButton> actionsIter = contactActionButtons.iterator(); while (actionsIter.hasNext()) { final SIPCommButton actionButton = actionsIter.next(); // 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.sharedInstance().unregisterComponent(actionButton); if (customActionButtonsUIGroup == null) customActionButtonsUIGroup = new LinkedList<JButton>(); customActionButtonsUIGroup.add(actionButton); xBounds += addButton(actionButton, ++gridX, xBounds, false); } return gridX; }
/** * 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; } } } }
/** * Permanently removes locally stored message history for the metacontact, remove any recent * contacts if any. */ public void eraseLocallyStoredHistory(MetaContact contact) throws IOException { List<ComparableEvtObj> toRemove = null; synchronized (recentMessages) { toRemove = new ArrayList<ComparableEvtObj>(); Iterator<Contact> iter = contact.getContacts(); while (iter.hasNext()) { Contact item = iter.next(); String id = item.getAddress(); ProtocolProviderService provider = item.getProtocolProvider(); for (ComparableEvtObj msc : recentMessages) { if (msc.getProtocolProviderService().equals(provider) && msc.getContactAddress().equals(id)) { toRemove.add(msc); } } } recentMessages.removeAll(toRemove); } if (recentQuery != null) { for (ComparableEvtObj msc : toRemove) { recentQuery.fireContactRemoved(msc); } } }
/** * Shows "call via" menu allowing user to selected from multiple providers. * * @param context the android context * @param v the View that will contain the popup menu. * @param destination target callee name. */ private static void showCallViaMenu(final Context context, View v, final String destination) { PopupMenu popup = new PopupMenu(context, v); Menu menu = popup.getMenu(); Iterator<ProtocolProviderService> registeredProviders = AccountUtils.getRegisteredProviders().iterator(); while (registeredProviders.hasNext()) { final ProtocolProviderService provider = registeredProviders.next(); String accountAddress = provider.getAccountID().getAccountAddress(); MenuItem menuItem = menu.add(Menu.NONE, Menu.NONE, Menu.NONE, accountAddress); menuItem.setOnMenuItemClickListener( new MenuItem.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { createCall(context, destination, provider); return false; } }); } popup.show(); }
/** * Converts the form field values in the <tt>ffValuesIter</tt> into a caps string. * * @param ffValuesIter the {@link Iterator} containing the form field values. * @param capsBldr a <tt>StringBuilder</tt> to which the caps string representing the form field * values is to be appended */ private static void formFieldValuesToCaps(Iterator<String> ffValuesIter, StringBuilder capsBldr) { SortedSet<String> fvs = new TreeSet<String>(); while (ffValuesIter.hasNext()) fvs.add(ffValuesIter.next()); for (String fv : fvs) capsBldr.append(fv).append('<'); }
/** * Remove records telling what entity caps node a contact has. * * @param contact the contact */ public void removeContactCapsNode(Contact contact) { Caps caps = null; String lastRemovedJid = null; Iterator<String> iter = userCaps.keySet().iterator(); while (iter.hasNext()) { String jid = iter.next(); if (StringUtils.parseBareAddress(jid).equals(contact.getAddress())) { caps = userCaps.get(jid); lastRemovedJid = jid; iter.remove(); } } // fire only for the last one, at the end the event out // of the protocol will be one and for the contact if (caps != null) { UserCapsNodeListener[] listeners; synchronized (userCapsNodeListeners) { listeners = userCapsNodeListeners.toArray(NO_USER_CAPS_NODE_LISTENERS); } if (listeners.length != 0) { String nodeVer = caps.getNodeVer(); for (UserCapsNodeListener listener : listeners) listener.userCapsNodeRemoved(lastRemovedJid, nodeVer, false); } } }
/** * Adds resources for contact. * * @param tip the tool tip * @param protocolContact the protocol contact, which resources we're looking for */ private void addContactResourceTooltipLines(ExtendedTooltip tip, Contact protocolContact) { Collection<ContactResource> contactResources = protocolContact.getResources(); if (contactResources == null) return; Iterator<ContactResource> resourcesIter = contactResources.iterator(); while (resourcesIter.hasNext()) { ContactResource contactResource = resourcesIter.next(); // We only add the status icon if we have more than one resources, // otherwise it will always be identical to the contact status icon. ImageIcon protocolStatusIcon = null; if (contactResources.size() > 1) { protocolStatusIcon = ImageLoader.getIndexedProtocolIcon( ImageUtils.getBytesInImage(contactResource.getPresenceStatus().getStatusIcon()), protocolContact.getProtocolProvider()); } String resourceName = (contactResource.getPriority() >= 0) ? contactResource.getResourceName() + " (" + contactResource.getPriority() + ")" : contactResource.getResourceName(); if (protocolStatusIcon == null) tip.addSubLine(protocolStatusIcon, resourceName, 27); else tip.addSubLine(protocolStatusIcon, resourceName, 20); } tip.revalidate(); tip.repaint(); }
/** Clears the custom action buttons. */ private void clearCustomActionButtons() { if (customActionButtons != null && customActionButtons.size() > 0) { Iterator<JButton> buttonsIter = customActionButtons.iterator(); while (buttonsIter.hasNext()) { remove(buttonsIter.next()); } customActionButtons.clear(); } if (customActionButtonsUIGroup != null && customActionButtonsUIGroup.size() > 0) { Iterator<JButton> buttonsIter = customActionButtonsUIGroup.iterator(); while (buttonsIter.hasNext()) { remove(buttonsIter.next()); } customActionButtonsUIGroup.clear(); } }
/** * Fills the tooltip with details. * * @param tip the tooltip to fill * @param phones the available phone details. */ private void addPhoneTooltipLines(ExtendedTooltip tip, Iterator<String> phones) { while (phones.hasNext()) { tip.addSubLine(null, phones.next(), 27); } tip.revalidate(); tip.repaint(); }
/** * Returns the <tt>Contact</tt> with the specified address or identifier. * * @param id the addres or identifier of the <tt>Contact</tt> we are looking for. * @return the <tt>Contact</tt> with the specified id or address. */ public Contact getContact(String id) { Iterator<Contact> contactsIter = contacts(); while (contactsIter.hasNext()) { Contact contact = contactsIter.next(); if (contact.getAddress().equals(id)) return contact; } return null; }
/** * Returns the subgroup with the specified name. * * @param groupName the name of the <tt>ContactGroup</tt> to retrieve. * @return the <tt>ContactGroup</tt> with the specified index. */ public ContactGroup getGroup(String groupName) { Iterator<ContactGroup> groupsIter = subgroups(); while (groupsIter.hasNext()) { ContactGroup contactGroup = groupsIter.next(); if (contactGroup.getGroupName().equals(groupName)) return contactGroup; } return null; }
/** * Creates an {@link OtrContactMenu} for each {@link Contact} contained in the * <tt>metaContact</tt>. * * @param metaContact The {@link MetaContact} this {@link OtrMetaContactMenu} refers to. */ private void createOtrContactMenus(MetaContact metaContact) { JMenu menu = getMenu(); // Remove any existing OtrContactMenu items. menu.removeAll(); // Create the new OtrContactMenu items. if (metaContact != null) { Iterator<Contact> contacts = metaContact.getContacts(); if (metaContact.getContactCount() == 1) { new OtrContactMenu(contacts.next(), inMacOSXScreenMenuBar, menu, false); } else while (contacts.hasNext()) { new OtrContactMenu(contacts.next(), inMacOSXScreenMenuBar, menu, true); } } }
/** * Returns a list of all <tt>UIContactDetail</tt>s within this <tt>UIContact</tt>. * * @return a list of all <tt>UIContactDetail</tt>s within this <tt>UIContact</tt> */ public List<UIContactDetail> getContactDetails() { List<UIContactDetail> resultList = new LinkedList<UIContactDetail>(); Iterator<Contact> contacts = metaContact.getContacts(); while (contacts.hasNext()) { resultList.add(new MetaContactDetail(contacts.next())); } return resultList; }
/** * Returns the {@link CallJabberImpl} containing a {@link CallPeerJabberImpl} whose corresponding * jingle session has the specified jingle <tt>sid</tt>. * * @param sid the jingle <tt>sid</tt> we're looking for. * @return the {@link CallJabberImpl} containing the peer with the specified <tt>sid</tt> or * <tt>null</tt> if we couldn't find one matching it. */ public T findSID(String sid) { Iterator<T> calls = getActiveCalls(); while (calls.hasNext()) { T call = calls.next(); if (call.containsSID(sid)) return call; } return null; }
/** * Returns a list of <tt>UIContactDetail</tt>s supporting the given <tt>OperationSet</tt> class. * * @param opSetClass the <tt>OperationSet</tt> class we're interested in * @return a list of <tt>UIContactDetail</tt>s supporting the given <tt>OperationSet</tt> class */ public List<UIContactDetail> getContactDetailsForOperationSet( Class<? extends OperationSet> opSetClass) { List<UIContactDetail> resultList = new LinkedList<UIContactDetail>(); Iterator<Contact> contacts = metaContact.getContactsForOperationSet(opSetClass).iterator(); while (contacts.hasNext()) { resultList.add(new MetaContactDetail(contacts.next())); } return resultList; }
/** * Returns the {@link CallPeerJabberImpl} whose session-init's ID has the specified IQ * <tt>id</tt>. * * @param id the IQ <tt>id</tt> we're looking for. * @return the {@link CallPeerJabberImpl} with the specified <tt>id</tt> or <tt>null</tt> if we * couldn't find one matching it. */ public U findCallPeerBySessInitPacketID(String id) { Iterator<T> calls = getActiveCalls(); while (calls.hasNext()) { T call = calls.next(); U peer = call.getPeerBySessInitPacketID(id); if (peer != null) return peer; } return null; }
/** * Returns the {@link CallPeerJabberImpl} whose jingle session has the specified jingle * <tt>sid</tt>. * * @param sid the jingle <tt>sid</tt> we're looking for. * @return the {@link CallPeerJabberImpl} with the specified <tt>sid</tt> or <tt>null</tt> if we * couldn't find one matching it. */ public U findCallPeer(String sid) { Iterator<T> calls = getActiveCalls(); while (calls.hasNext()) { T call = calls.next(); U peer = call.getPeer(sid); if (peer != null) return peer; } return null; }
/** * Delivers the file transfer to all registered listeners. * * @param event the <tt>FileTransferEvent</tt> that we'd like delivered to all registered file * transfer listeners. */ void fireFileTransferCreated(FileTransferCreatedEvent event) { Iterator<FileTransferListener> listeners = null; synchronized (fileTransferListeners) { listeners = new ArrayList<FileTransferListener>(fileTransferListeners).iterator(); } while (listeners.hasNext()) { FileTransferListener listener = listeners.next(); listener.fileTransferCreated(event); } }
/** * Loads the list of enabled and disabled encryption protocols with their priority. * * @param enabledEncryptionProtocols The list of enabled encryption protocol available for this * account. * @param disabledEncryptionProtocols The list of disabled encryption protocol available for this * account. */ private void loadEncryptionProtocols( Map<String, Integer> encryptionProtocols, Map<String, Boolean> encryptionProtocolStatus) { int nbEncryptionProtocols = ENCRYPTION_PROTOCOLS.length; String[] encryptions = new String[nbEncryptionProtocols]; boolean[] selectedEncryptions = new boolean[nbEncryptionProtocols]; // Load stored values. int prefixeLength = ProtocolProviderFactory.ENCRYPTION_PROTOCOL.length() + 1; String encryptionProtocolPropertyName; String name; int index; boolean enabled; Iterator<String> encryptionProtocolNames = encryptionProtocols.keySet().iterator(); while (encryptionProtocolNames.hasNext()) { encryptionProtocolPropertyName = encryptionProtocolNames.next(); index = encryptionProtocols.get(encryptionProtocolPropertyName); // If the property is set. if (index != -1) { name = encryptionProtocolPropertyName.substring(prefixeLength); if (isExistingEncryptionProtocol(name)) { enabled = encryptionProtocolStatus.get( ProtocolProviderFactory.ENCRYPTION_PROTOCOL_STATUS + "." + name); encryptions[index] = name; selectedEncryptions[index] = enabled; } } } // Load default values. String encryptionProtocol; boolean set; int j = 0; for (int i = 0; i < ENCRYPTION_PROTOCOLS.length; ++i) { encryptionProtocol = ENCRYPTION_PROTOCOLS[i]; // Specify a default value only if there is no specific value set. if (!encryptionProtocols.containsKey( ProtocolProviderFactory.ENCRYPTION_PROTOCOL + "." + encryptionProtocol)) { set = false; // Search for the first empty element. while (j < encryptions.length && !set) { if (encryptions[j] == null) { encryptions[j] = encryptionProtocol; // By default only ZRTP is set to true. selectedEncryptions[j] = encryptionProtocol.equals("ZRTP"); set = true; } ++j; } } } this.encryptionConfigurationTableModel.init(encryptions, selectedEncryptions); }
@Override protected void run() { Iterator<ChatRoomProviderWrapper> chatRoomProviders = mucService.getChatRoomProviders(); while (chatRoomProviders.hasNext()) { ChatRoomProviderWrapper provider = chatRoomProviders.next(); providerAdded(provider, true); } if (getStatus() != QUERY_CANCELED) setStatus(QUERY_COMPLETED); }
/** * Returns the index of the contact in the contact results list. * * @param contact the contact. * @return the index of the contact in the contact results list. */ public synchronized int indexOf(ChatRoomSourceContact contact) { Iterator<ChatRoomSourceContact> it = contactResults.iterator(); int i = 0; while (it.hasNext()) { if (contact.equals(it.next())) { return i; } i++; } return -1; }
/** * Creates new call to target <tt>destination</tt>. * * @param context the android context * @param destination the target callee name that will be used. */ private static void createCall(Context context, String destination) { Iterator<ProtocolProviderService> allProviders = AccountUtils.getRegisteredProviders().iterator(); if (!allProviders.hasNext()) { logger.error("No registered providers found"); return; } createCall(context, destination, allProviders.next()); }
/** Initializes all search strings for this <tt>MetaUIGroup</tt>. */ private void initSearchStrings() { searchStrings.add(metaContact.getDisplayName()); Iterator<Contact> contacts = metaContact.getContacts(); while (contacts.hasNext()) { Contact contact = contacts.next(); searchStrings.add(contact.getDisplayName()); searchStrings.add(contact.getAddress()); } }
/** * Returns the group that is parent of the specified mockContact or null if no parent was found. * * @param mockContact the contact whose parent we're looking for. * @return the MockContactGroup instance that mockContact belongs to or null if no parent was * found. */ public MockContactGroup findContactParent(MockContact mockContact) { if (contacts.contains(mockContact)) return this; Iterator<ContactGroup> subGroupsIter = subgroups(); while (subGroupsIter.hasNext()) { MockContactGroup subgroup = (MockContactGroup) subGroupsIter.next(); MockContactGroup parent = subgroup.findContactParent(mockContact); if (parent != null) return parent; } return null; }
public WhiteboardSessionManager() { if (WhiteboardActivator.getWhiteboardOperationSets() == null) return; Iterator opSets = WhiteboardActivator.getWhiteboardOperationSets().iterator(); while (opSets.hasNext()) { OperationSetWhiteboarding whiteboardOpSet = (OperationSetWhiteboarding) opSets.next(); whiteboardOpSet.addInvitationListener(new InvitationListener()); whiteboardOpSet.addPresenceListener(new PresenceListener()); } }
/** * Returns a String representation of this group and the contacts it contains (may turn out to be * a relatively long string). * * @return a String representing this group and its child contacts. */ @Override public String toString() { StringBuffer buff = new StringBuffer(getGroupName()); buff.append(".subGroups=" + countSubgroups() + ":\n"); Iterator<ContactGroup> subGroups = subgroups(); while (subGroups.hasNext()) { ContactGroup group = subGroups.next(); buff.append(group.toString()); if (subGroups.hasNext()) buff.append("\n"); } buff.append("\nChildContacts=" + countContacts() + ":["); Iterator<Contact> contacts = contacts(); while (contacts.hasNext()) { Contact contact = contacts.next(); buff.append(contact.toString()); if (contacts.hasNext()) buff.append(", "); } return buff.append("]").toString(); }