/** * 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; }
/** * Loads the tooltip with the data for current metacontact. * * @param tip the tooltip to fill. */ private void loadTooltip(final ExtendedTooltip tip) { Iterator<Contact> i = metaContact.getContacts(); ContactPhoneUtil contactPhoneUtil = ContactPhoneUtil.getPhoneUtil(metaContact); String statusMessage = null; Contact protocolContact; boolean isLoading = false; while (i.hasNext()) { protocolContact = i.next(); // Set the first found status message. if (statusMessage == null && protocolContact.getStatusMessage() != null && protocolContact.getStatusMessage().length() > 0) statusMessage = protocolContact.getStatusMessage(); if (ConfigurationUtils.isHideAccountStatusSelectorsEnabled()) break; ImageIcon protocolStatusIcon = ImageLoader.getIndexedProtocolIcon( ImageUtils.getBytesInImage(protocolContact.getPresenceStatus().getStatusIcon()), protocolContact.getProtocolProvider()); String contactAddress = protocolContact.getAddress(); // String statusMessage = protocolContact.getStatusMessage(); tip.addLine(protocolStatusIcon, contactAddress); addContactResourceTooltipLines(tip, protocolContact); if (!protocolContact.getProtocolProvider().isRegistered()) continue; contactPhoneUtil.addDetailsResponseListener( protocolContact, new OperationSetServerStoredContactInfo.DetailsResponseListener() { public void detailsRetrieved(final Iterator<GenericDetail> details) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater( new Runnable() { public void run() { detailsRetrieved(details); } }); return; } // remove previously shown information // as it contains "Loading..." text tip.removeAllLines(); // load it again loadTooltip(tip); } }); List<String> phones = contactPhoneUtil.getPhones(protocolContact); if (phones != null) { addPhoneTooltipLines(tip, phones.iterator()); } else isLoading = true; } if (isLoading) tip.addLine(null, GuiActivator.getResources().getI18NString("service.gui.LOADING")); if (statusMessage != null) tip.setBottomText(statusMessage); }