/** * Returns the fully qualified JID of the contact. (If available). Otherwise will * return the bare jid. * * @return the fully qualified jid (ex. derek@jivesoftware.com). * @deprecated use {@link #getJid()} instead. */ @Deprecated public String getJID() { return getJid().toString(); }
private boolean isContactItemInGroup(Collection<ContactItem> contactItems, ContactGroup group) { boolean contactInGroup = false; for (ContactItem ci : contactItems) { if (group.getContactItemByJID(ci.getJid(), true) != null) { contactInGroup = true; break; } } return contactInGroup; }
/** * Returns a <code>ContactItem</code> from offlineContacts by the users bare bareJID. * * @param bareJID the bareJID of the user. * @return the ContactItem. */ public ContactItem getOfflineContactItemByJID(BareJid bareJID) { for (ContactItem item : new ArrayList<>( offlineContacts )) { if (item.getJid().equals(bareJID)) { return item; } } return null; }
/** * Returns a <code>ContactItem</code> by the users bare bareJID. * * @param bareJID the bareJID of the user. * @return the ContactItem. */ public ContactItem getContactItemByJID(BareJid bareJID) { for (ContactItem item : new ArrayList<>( contactItems )) { if (item != null && item.getJid().equals(bareJID)) { return item; } } return null; }
public void actionPerformed(ActionEvent e) { for (ContactItem item : contactList.getSelectedUsers()) { BareJid bareAddress = item .getJid().asBareJid(); sparkContacts.add(bareAddress); } } };
public void actionPerformed(ActionEvent e) { for (ContactItem item : contactList.getSelectedUsers()) { BareJid bareAddress = item .getJid().asBareJid(); sparkContacts.remove(bareAddress); } } };
/** * Removes an offline <code>ContactItem</code> from the offline contact model and ui. * * @param jid the offline contact item to remove. */ public void removeOfflineContactItem(BareJid jid) { final List<ContactItem> items = new ArrayList<>( offlineContacts ); for (ContactItem item : items) { if (item.getJid().equals(jid)) { removeOfflineContactItem(item); } } }
public void actionPerformed(ActionEvent actionEvent) { ContactItem item = contactList.getSelectedUsers().iterator().next(); final BareJid jid = item.getJid(); transcript = new HistoryTranscript(notificationDateFormatter, messageDateFormatter); transcript.showHistory(jid); //showHistory(jid); } };
/** * Returns the url of the avatar belonging to this contact. * * @return the url of the avatar. * @throws MalformedURLException thrown if the address is invalid. */ public URL getAvatarURL() throws MalformedURLException { contactsDir.mkdirs(); if (ModelUtil.hasLength(hash)) { final File imageFile = new File(contactsDir, hash); if (imageFile.exists()) { return imageFile.toURI().toURL(); } } return SparkManager.getVCardManager().getAvatarURLIfAvailable(getJid()); }
public boolean importData(JComponent comp, Transferable t) { if (t.isDataFlavorSupported(flavors[0])) { try { final Object o = t.getTransferData(flavors[0]); if (o instanceof ContactItem) { // Invite User final ContactItem contactItem = (ContactItem)o; BareJid jid = contactItem.getJid(); groupChatRoom.inviteUser(jid.asEntityBareJidOrThrow(), "Please join the conference room."); return true; } } catch (Exception e) { Log.error(e); } } return false; } }
/** * Persists the avatar locally based on the new hash. */ private void updateAvatar() { SparkManager.getVCardManager().addToQueue(getJid().asBareJid()); }
public void actionPerformed(ActionEvent e) { VCardManager vcardSupport = SparkManager.getVCardManager(); BareJid jid = item.getJid().asBareJid(); vcardSupport.viewProfile(jid, SparkManager.getWorkspace()); } };
public void sendFileTo(ContactItem item) { FileDialog fileChooser = getFileChooser(SparkManager.getMainWindow(), Res.getString("title.select.file.to.send")); if (defaultDirectory != null) { fileChooser.setDirectory( defaultDirectory.getAbsolutePath() ); } fileChooser.setVisible(true); final File[] files = fileChooser.getFiles(); if ( files.length == 0) { // no selection return; } File file = files[0]; // Single-file selection is used. Using the first array item is safe. if (file.exists()) { defaultDirectory = file.getParentFile(); sendFile( file, item.getJid() ); } }
/** * Returns the full jid w/ resource of a user by their display name * in the ContactList. * * @param displayName the displayed name of the user. * @return the full jid w/ resource of the user. */ public EntityFullJid getJIDFromDisplayName(CharSequence displayName) { ContactList contactList = SparkManager.getWorkspace().getContactList(); ContactItem item = contactList.getContactItemByDisplayName(displayName); if (item != null) { return getFullJID(item.getJid()); } return null; }
private void registerListener() { preferences = SettingsManager.getLocalPreferences(); // Iterate through all online users and add them to the list. ContactList contactList = SparkManager.getWorkspace().getContactList(); for (ContactGroup contactGroup : contactList.getContactGroups()) { for (ContactItem item : contactGroup.getContactItems()) { if (item != null && item.getJid() != null && item.getPresence().isAvailable()) { BareJid bareJID = item.getJid().asBareJid(); onlineUsers.add(bareJID); } } } // Add Presence Listener SparkManager.getConnection().addAsyncStanzaListener(this, new StanzaTypeFilter(Presence.class)); }
private void removeContactFromRoster(ContactItem item) { Roster roster = Roster.getInstanceFor( SparkManager.getConnection() ); RosterEntry entry = roster.getEntry(item.getJid().asBareJid()); if (entry != null) { try { roster.removeEntry(entry); } catch (XMPPException | SmackException | InterruptedException e) { Log.warning("Unable to remove roster entry.", e); } } }
public void actionPerformed(ActionEvent actionEvent) { try { String client = ""; if (item.getPresence().getType() != Presence.Type.unavailable) { client = item.getPresence().getFrom().toString(); if ((client != null) && (client.lastIndexOf("/") != -1)) { client = client.substring(client.lastIndexOf("/")); } else client = "/"; } Jid jid = JidCreate.from(item.getJid().toString() + client); LastActivity activity = LastActivityManager.getInstanceFor( SparkManager.getConnection() ).getLastActivity(jid); long idleTime = (activity.getIdleTime() * 1000); String time = ModelUtil.getTimeFromLong(idleTime); UIManager.put("OptionPane.okButtonText", Res.getString("ok")); JOptionPane.showMessageDialog(getGUI(), Res.getString("message.idle.for", time), Res.getString("title.last.activity"), JOptionPane.INFORMATION_MESSAGE); } catch (Exception e1) { UIManager.put("OptionPane.okButtonText", Res.getString("ok")); JOptionPane.showMessageDialog(getGUI(), Res.getString("message.unable.to.retrieve.last.activity", item.getJID()), Res.getString("title.error"), JOptionPane.ERROR_MESSAGE); } } };
@Override public void doRun() { // Check to see if the user is offline, if so, move them to the offline group. Presence userPresence = PresenceManager.getPresence(bareJID); if (userPresence.isAvailable()) { return; } item.setPresence(presence); // Check for ContactItemHandler. group.removeContactItem(item); checkGroup(group); if (offlineGroup.getContactItemByJID(item.getJid()) == null) { moveToOffline(item); offlineGroup.fireContactGroupUpdated(); } } }, timeToRun);
private void startConference(Collection<ContactItem> items) { final ContactList contactList = SparkManager.getWorkspace().getContactList(); List<Jid> jids = new ArrayList<>(); for (ContactItem item : items) { ContactGroup contactGroup = contactList.getContactGroup(item.getGroupName()); contactGroup.clearSelection(); if (item.isAvailable()) { jids.add(item.getJid()); } } Localpart userName = SparkManager.getSessionManager().getJID().getLocalpart(); final EntityBareJid roomName = JidCreate.entityBareFromOrThrowUnchecked(userName + "_" + StringUtils.randomString(3)); DomainBareJid serviceName = getDefaultServiceName(); if (serviceName != null) { ConferenceUtils.inviteUsersToRoom(serviceName, roomName, jids, true); } }
public void removeIconsForList(SparkPrivacyList list) throws SmackException.NotConnectedException { for (PrivacyItem pItem : list.getPrivacyItems()) { if (pItem.getType().equals(PrivacyItem.Type.jid)) { removeBlockedIconFromContact(pItem.getValue()); if (pItem.isFilterPresenceOut()) { sendRealPresenceTo(pItem.getValue()); } } if (pItem.getType().equals(PrivacyItem.Type.group)) { ContactGroup group = SparkManager.getWorkspace().getContactList().getContactGroup(pItem.getValue()); for (ContactItem citem : group.getContactItems()) { removeBlockedIconFromContact(citem.getJid()); if (pItem.isFilterPresenceOut()) { sendRealPresenceTo(citem.getJid()); } } } } SparkManager.getContactList().updateUI(); }