Updating contact item.

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@7429 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Derek DeMoro
2007-03-09 18:13:52 +00:00
committed by derek
parent 641e5fadfb
commit fda9e0d9ab
19 changed files with 215 additions and 80 deletions

View File

@ -334,7 +334,7 @@ public class UserManager {
ContactList contactList = SparkManager.getWorkspace().getContactList();
ContactItem item = contactList.getContactItemByNickname(nickname);
if (item != null) {
return getFullJID(item.getFullJID());
return getFullJID(item.getJID());
}
return null;
@ -400,7 +400,7 @@ public class UserManager {
parent.setGlassPane(glassPane);
parent.getGlassPane().setVisible(false);
contactField.dispose();
SparkManager.getChatManager().activateChat(item.getFullJID(), item.getNickname());
SparkManager.getChatManager().activateChat(item.getJID(), item.getNickname());
}
}
@ -422,7 +422,7 @@ public class UserManager {
parent.setGlassPane(glassPane);
parent.getGlassPane().setVisible(false);
contactField.dispose();
SparkManager.getChatManager().activateChat(item.getFullJID(), item.getNickname());
SparkManager.getChatManager().activateChat(item.getJID(), item.getNickname());
}
}
}

View File

@ -15,7 +15,6 @@ import org.jivesoftware.Spark;
import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.Roster;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.FromContainsFilter;
@ -184,7 +183,7 @@ public class SparkTransferManager {
ChatRoom chatRoom = null;
Iterator iter = files.iterator();
while (iter.hasNext()) {
chatRoom = sendFile((File)iter.next(), item.getFullJID());
chatRoom = sendFile((File)iter.next(), item.getJID());
}
if (chatRoom != null) {
@ -282,7 +281,7 @@ public class SparkTransferManager {
File file = files[i];
if (file.exists()) {
defaultDirectory = file.getParentFile();
sendFile(file, item.getFullJID());
sendFile(file, item.getJID());
}
}
}

View File

@ -183,7 +183,7 @@ public class PhoneManager implements ChatRoomListener, ContextMenuListener, Cont
ContactItem contactItem = (ContactItem)object;
final List<Action> actions = new ArrayList<Action>();
for (Phone phone : phones) {
final Collection<Action> itemActions = phone.getPhoneActions(contactItem.getFullJID());
final Collection<Action> itemActions = phone.getPhoneActions(contactItem.getJID());
for (Action action : itemActions) {
actions.add(action);
}
@ -223,7 +223,7 @@ public class PhoneManager implements ChatRoomListener, ContextMenuListener, Cont
public void handleContactInfo(ContactInfoWindow contactInfo) {
final ContactItem contactItem = contactInfo.getContactItem();
final String jid = contactItem.getContactJID();
final String jid = contactItem.getJID();
final List<Action> actions = new ArrayList<Action>();
for (Phone phone : phones) {
final Collection<Action> itemActions = phone.getPhoneActions(jid);

View File

@ -220,7 +220,7 @@ public class ContactGroup extends CollapsiblePane implements MouseListener {
public void removeOfflineContactItem(String jid) {
final List<ContactItem> items = new ArrayList<ContactItem>(offlineContacts);
for (ContactItem item : items) {
if (item.getFullJID().equals(jid)) {
if (item.getJID().equals(jid)) {
removeOfflineContactItem(item);
}
}
@ -253,7 +253,7 @@ public class ContactGroup extends CollapsiblePane implements MouseListener {
*/
public void addContactItem(ContactItem item) {
// Remove from offline group if it exists
removeOfflineContactItem(item.getFullJID());
removeOfflineContactItem(item.getJID());
if (model.contains(noContacts)) {
model.remove(0);
@ -407,7 +407,7 @@ public class ContactGroup extends CollapsiblePane implements MouseListener {
final Iterator iter = new ArrayList(contactItems).iterator();
while (iter.hasNext()) {
ContactItem item = (ContactItem)iter.next();
if (item.getFullJID().equals(bareJID)) {
if (item.getJID().equals(bareJID)) {
return item;
}
}

View File

@ -130,7 +130,7 @@ public class ContactGroupTransferHandler extends TransferHandler {
if (o instanceof java.util.Collection) {
Collection files = (Collection)o;
ContactItem source = (ContactItem)list.getSelectedValue();
if (source == null || source.getFullJID() == null) {
if (source == null || source.getJID() == null) {
return false;
}
@ -219,7 +219,7 @@ public class ContactGroupTransferHandler extends TransferHandler {
}
private void addContactItem(final ContactGroup contactGroup, final ContactItem item) {
ContactItem newContact = new ContactItem(item.getNickname(), item.getFullJID());
ContactItem newContact = new ContactItem(item.getNickname(), item.getJID());
newContact.setPresence(item.getPresence());
newContact.setIcon(item.getIcon());
newContact.getNicknameLabel().setFont(item.getNicknameLabel().getFont());
@ -231,7 +231,7 @@ public class ContactGroupTransferHandler extends TransferHandler {
SwingWorker worker = new SwingWorker() {
public Object construct() {
Roster roster = SparkManager.getConnection().getRoster();
RosterEntry entry = roster.getEntry(item.getFullJID());
RosterEntry entry = roster.getEntry(item.getJID());
RosterGroup groupFound = null;
@ -287,7 +287,7 @@ public class ContactGroupTransferHandler extends TransferHandler {
// Remove entry from Roster Group
Roster roster = SparkManager.getConnection().getRoster();
RosterEntry entry = roster.getEntry(item.getFullJID());
RosterEntry entry = roster.getEntry(item.getJID());
RosterGroup rosterGroup = null;

View File

@ -217,7 +217,7 @@ public class ContactInfoWindow extends JPanel implements MouseListener {
ContactItem item = (ContactItem)group.getList().getModel().getElementAt(loc);
if (item == null || item.getFullJID() == null) {
if (item == null || item.getJID() == null) {
return;
}
@ -278,15 +278,15 @@ public class ContactInfoWindow extends JPanel implements MouseListener {
}
statusLabel.setText(status);
Transport transport = TransportUtils.getTransport(StringUtils.parseServer(contactItem.getFullJID()));
Transport transport = TransportUtils.getTransport(StringUtils.parseServer(contactItem.getJID()));
if (transport != null) {
fullJIDLabel.setIcon(transport.getIcon());
String name = StringUtils.parseName(contactItem.getFullJID());
String name = StringUtils.parseName(contactItem.getJID());
name = StringUtils.unescapeNode(name);
fullJIDLabel.setText(transport.getName() + " - " + name);
}
else {
fullJIDLabel.setText(contactItem.getFullJID());
fullJIDLabel.setText(contactItem.getJID());
fullJIDLabel.setIcon(null);
}

View File

@ -19,9 +19,8 @@ import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.RosterPacket;
import org.jivesoftware.smackx.packet.VCard;
import org.jivesoftware.spark.ChatManager;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.PresenceManager;
import org.jivesoftware.spark.ui.status.StatusItem;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.util.GraphicUtils;
import org.jivesoftware.spark.util.ModelUtil;
import org.jivesoftware.spark.util.log.Log;
@ -44,12 +43,15 @@ import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
/**
* Represent a single contact within the <code>ContactList</code>.
*/
public class ContactItem extends JPanel {
private JLabel imageLabel;
private JLabel nicknameLabel;
private JLabel descriptionLabel;
private String nickname;
private String fullJID;
private String fullyQualifiedJID;
private Icon icon;
private String status;
@ -66,7 +68,13 @@ public class ContactItem extends JPanel {
private JLabel sideIcon;
public ContactItem(String nickname, String fullJID) {
/**
* Creates a new instance of a contact.
*
* @param nickname the nickname of the contact.
* @param fullyQualifiedJID the fully-qualified jid of the contact (ex. derek@jivesoftware.com)
*/
public ContactItem(String nickname, String fullyQualifiedJID) {
setLayout(new GridBagLayout());
// Set default presence
@ -98,52 +106,90 @@ public class ContactItem extends JPanel {
add(sideIcon, new GridBagConstraints(3, 0, 1, 2, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0));
setNickname(nickname);
setFullJID(fullJID);
this.fullyQualifiedJID = fullyQualifiedJID;
}
/**
* Returns the nickname of the contact.
*
* @return the nickname.
*/
public String getNickname() {
return nickname;
}
/**
* Sets the nickname of the contact.
*
* @param nickname the contact nickname.
*/
public void setNickname(String nickname) {
this.nickname = nickname;
nicknameLabel.setText(nickname);
}
public String getFullJID() {
return fullJID;
}
public void setFullJID(String fullJID) {
this.fullJID = fullJID;
/**
* 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).
*/
public String getJID() {
return fullyQualifiedJID;
}
/**
* Returns the icon showing the contacts current state or presence.
*
* @return the icon.
*/
public Icon getIcon() {
return icon;
}
/**
* Sets the current icon to use.
*
* @param icon the current icon to use.
*/
public void setIcon(Icon icon) {
this.icon = icon;
imageLabel.setIcon(icon);
}
/**
* Returns the contacts current status based on their presence.
*
* @return the contacts current status.
*/
public String getStatus() {
return status;
}
/**
* Sets the contacts current status.
*
* @param status the contacts current status.
*/
public void setStatus(String status) {
this.status = status;
}
public String getContactJID() {
return fullJID;
}
/**
* Returns the name of the <code>ContactGroup</code> that this contact belongs to.
*
* @return the name of the <code>ContactGroup</code>.
*/
public String getGroupName() {
return groupName;
}
/**
* Sets the name of the <code>ContactGrouop</code> that this contact belongs to.
*
* @param groupName the name of the ContactGroup.
*/
public void setGroupName(String groupName) {
this.groupName = groupName;
}
@ -156,14 +202,29 @@ public class ContactItem extends JPanel {
this.available = available;
}
/**
* Returns the <code>JLabel</code> showing the users nickname.
*
* @return the nickname label.
*/
public JLabel getNicknameLabel() {
return nicknameLabel;
}
/**
* Returns the <code>JLabel</code> representing the description.
*
* @return the description label.
*/
public JLabel getDescriptionLabel() {
return descriptionLabel;
}
/**
* Returns the current presence of the contact.
*
* @return the users current presence.
*/
public Presence getPresence() {
return presence;
}
@ -171,7 +232,7 @@ public class ContactItem extends JPanel {
/**
* Sets the current presence on this contact item.
*
* @param presence
* @param presence the presence.
*/
public void setPresence(Presence presence) {
@ -196,6 +257,12 @@ public class ContactItem extends JPanel {
updatePresenceIcon(presence);
}
/**
* Checks to see if the hash already exists.
*
* @param hash the hash.
* @return true if the hash exists, otherwise false.
*/
private boolean hashExists(String hash) {
contactsDir.mkdirs();
@ -203,6 +270,12 @@ public class ContactItem extends JPanel {
return imageFile.exists();
}
/**
* 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();
@ -216,6 +289,11 @@ public class ContactItem extends JPanel {
return null;
}
/**
* Persists the avatar locally based on the new hash.
*
* @param hash the new hash.
*/
private void updateAvatar(final String hash) {
Thread updateAvatarThread = new Thread(new Runnable() {
public void run() {
@ -223,7 +301,7 @@ public class ContactItem extends JPanel {
final File imageFile = new File(contactsDir, hash);
VCard vcard = SparkManager.getVCardManager().getVCard(getFullJID(), false);
VCard vcard = SparkManager.getVCardManager().reloadVCard(getJID());
try {
byte[] bytes = vcard.getAvatar();
@ -235,8 +313,6 @@ public class ContactItem extends JPanel {
ImageIO.write(image, "PNG", imageFile);
}
}
SparkManager.getVCardManager().addVCard(getFullJID(), vcard);
}
catch (Exception e) {
Log.error("Unable to update avatar in Contact Item.", e);
@ -252,6 +328,11 @@ public class ContactItem extends JPanel {
}
/**
* Updates the icon of the user based on their presence.
*
* @param presence the users presence.
*/
public void updatePresenceIcon(Presence presence) {
ChatManager chatManager = SparkManager.getChatManager();
boolean handled = chatManager.fireContactItemPresenceChanged(this, presence);
@ -295,7 +376,7 @@ public class ContactItem extends JPanel {
getNicknameLabel().setFont(new Font("Dialog", Font.PLAIN, 11));
getNicknameLabel().setForeground((Color)UIManager.get("ContactItemOffline.color"));
RosterEntry entry = SparkManager.getConnection().getRoster().getEntry(getFullJID());
RosterEntry entry = SparkManager.getConnection().getRoster().getEntry(getJID());
if (entry != null && (entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from)
&& RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == entry.getStatus()) {
// Do not move out of group.
@ -324,7 +405,7 @@ public class ContactItem extends JPanel {
getNicknameLabel().setFont(new Font("Dialog", Font.PLAIN, 11));
getNicknameLabel().setForeground((Color)UIManager.get("ContactItemOffline.color"));
RosterEntry entry = SparkManager.getConnection().getRoster().getEntry(getFullJID());
RosterEntry entry = SparkManager.getConnection().getRoster().getEntry(getJID());
if (entry != null && (entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from)
&& RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == entry.getStatus()) {
// Do not move out of group.
@ -385,6 +466,11 @@ public class ContactItem extends JPanel {
setAvailable(true);
}
/**
* Sets the status label text based on the users status.
*
* @param status the users status.
*/
public void setStatusText(String status) {
setStatus(status);
@ -396,16 +482,28 @@ public class ContactItem extends JPanel {
}
}
/**
* The icon to use to show extra information about this contact. An example would be to
* represent that this user is from a 3rd party transport.
*
* @param icon the icon to use.
*/
public void setSideIcon(Icon icon) {
sideIcon.setIcon(icon);
}
/**
* Shows that the user is coming online.
*/
public void showUserComingOnline() {
// Change Font
getNicknameLabel().setFont(new Font("Dialog", Font.BOLD, 11));
getNicknameLabel().setForeground(new Color(255, 128, 0));
}
/**
* Shows that the user is going offline.
*/
public void showUserGoingOfflineOnline() {
// Change Font
getNicknameLabel().setFont(new Font("Dialog", Font.BOLD, 11));

View File

@ -345,7 +345,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
group.removeContactItem(item);
checkGroup(group);
if (offlineGroup.getContactItemByJID(item.getFullJID()) == null) {
if (offlineGroup.getContactItemByJID(item.getJID()) == null) {
moveToOffline(item);
offlineGroup.fireContactGroupUpdated();
}
@ -1073,7 +1073,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
}
else if (e.getSource() == chatMenu) {
if (activeItem != null) {
SparkManager.getChatManager().activateChat(activeItem.getContactJID(), activeItem.getNickname());
SparkManager.getChatManager().activateChat(activeItem.getJID(), activeItem.getNickname());
}
}
else if (e.getSource() == addContactMenu) {
@ -1096,7 +1096,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
String oldNickname = activeItem.getNickname();
String newNickname = JOptionPane.showInputDialog(this, Res.getString("label.rename.to") + ":", oldNickname);
if (ModelUtil.hasLength(newNickname)) {
String address = activeItem.getFullJID();
String address = activeItem.getJID();
ContactGroup contactGroup = getContactGroup(activeItem.getGroupName());
ContactItem contactItem = contactGroup.getContactItemByNickname(activeItem.getNickname());
contactItem.setNickname(newNickname);
@ -1130,7 +1130,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
String groupName = item.getGroupName();
ContactGroup contactGroup = getContactGroup(groupName);
Roster roster = SparkManager.getConnection().getRoster();
RosterEntry entry = roster.getEntry(item.getFullJID());
RosterEntry entry = roster.getEntry(item.getJID());
if (entry != null && contactGroup != offlineGroup) {
try {
RosterGroup rosterGroup = roster.getGroup(groupName);
@ -1140,7 +1140,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
rosterGroup.removeEntry(rosterEntry);
}
}
contactGroup.removeContactItem(contactGroup.getContactItemByJID(item.getFullJID()));
contactGroup.removeContactItem(contactGroup.getContactItemByJID(item.getJID()));
checkGroup(contactGroup);
}
catch (Exception e) {
@ -1151,7 +1151,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
private void removeContactFromRoster(ContactItem item) {
Roster roster = SparkManager.getConnection().getRoster();
RosterEntry entry = roster.getEntry(item.getFullJID());
RosterEntry entry = roster.getEntry(item.getJID());
if (entry != null) {
try {
roster.removeEntry(entry);
@ -1190,7 +1190,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
boolean handled = chatManager.fireContactItemDoubleClicked(item);
if (!handled) {
chatManager.activateChat(item.getContactJID(), item.getNickname());
chatManager.activateChat(item.getJID(), item.getNickname());
}
clearSelectionList(item);
@ -1280,7 +1280,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
* @param item the ContactItem
*/
public void showPopup(MouseEvent e, final ContactItem item) {
if (item.getFullJID() == null) {
if (item.getJID() == null) {
return;
}
@ -1314,7 +1314,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
// Only show "Remove Contact From Group" if the user belongs to more than one group.
if (!contactGroup.isSharedGroup() && !contactGroup.isOfflineGroup() && contactGroup != unfiledGroup) {
Roster roster = SparkManager.getConnection().getRoster();
RosterEntry entry = roster.getEntry(item.getFullJID());
RosterEntry entry = roster.getEntry(item.getJID());
if (entry != null) {
int groupCount = entry.getGroups().size();
@ -1341,7 +1341,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
while (contactGroups.hasNext()) {
ContactGroup cGroup = (ContactGroup)contactGroups.next();
if (cGroup.isSharedGroup()) {
ContactItem it = cGroup.getContactItemByJID(item.getFullJID());
ContactItem it = cGroup.getContactItemByJID(item.getJID());
if (it != null) {
isInSharedGroup = true;
}
@ -1359,7 +1359,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
Action viewProfile = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
VCardManager vcardSupport = SparkManager.getVCardManager();
String jid = item.getFullJID();
String jid = item.getJID();
vcardSupport.viewProfile(jid, SparkManager.getWorkspace());
}
};
@ -1374,7 +1374,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
Action lastActivityAction = new AbstractAction() {
public void actionPerformed(ActionEvent actionEvent) {
try {
LastActivity activity = LastActivity.getLastActivity(SparkManager.getConnection(), item.getFullJID());
LastActivity activity = LastActivity.getLastActivity(SparkManager.getConnection(), item.getJID());
long idleTime = (activity.getIdleTime() * 1000);
String time = ModelUtil.getTimeFromLong(idleTime);
JOptionPane.showMessageDialog(getGUI(), Res.getString("message.idle.for", time), Res.getString("title.last.activity"), JOptionPane.INFORMATION_MESSAGE);
@ -1394,7 +1394,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
Action subscribeAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
String jid = item.getFullJID();
String jid = item.getJID();
Presence response = new Presence(Presence.Type.subscribe);
response.setTo(jid);
@ -1406,7 +1406,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
subscribeAction.putValue(Action.NAME, Res.getString("menuitem.subscribe.to"));
Roster roster = SparkManager.getConnection().getRoster();
RosterEntry entry = roster.getEntry(item.getFullJID());
RosterEntry entry = roster.getEntry(item.getJID());
if (entry != null && entry.getType() == RosterPacket.ItemType.from) {
popup.add(subscribeAction);
}
@ -1473,7 +1473,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
contactGroup.clearSelection();
if (item.isAvailable()) {
Message mess = new Message();
mess.setTo(item.getFullJID());
mess.setTo(item.getJID());
mess.setBody(messageText);
SparkManager.getConnection().sendPacket(mess);
@ -2043,13 +2043,13 @@ public final class ContactList extends JPanel implements ActionListener, Contact
offlineGroup.addContactItem(contactItem);
String jid = contactItem.getFullJID();
String jid = contactItem.getJID();
final Roster roster = SparkManager.getConnection().getRoster();
for (RosterGroup group : roster.getEntry(jid).getGroups()) {
ContactGroup contactGroup = getContactGroup(group.getName());
if (contactGroup != null) {
contactGroup.addOfflineContactItem(contactItem.getNickname(), contactItem.getFullJID());
contactGroup.addOfflineContactItem(contactItem.getNickname(), contactItem.getJID());
}
}
}

View File

@ -68,7 +68,7 @@ public class GroupChatRoomTransferHandler extends TransferHandler {
if (o instanceof ContactItem) {
// Invite User
final ContactItem contactItem = (ContactItem)o;
String jid = contactItem.getFullJID();
String jid = contactItem.getJID();
groupChatRoom.inviteUser(jid, "Please join the conference room.");
return true;

View File

@ -147,7 +147,7 @@ public class RosterPickList extends JPanel {
final int no = values != null ? values.length : 0;
for (int i = 0; i < no; i++) {
ContactItem item = (ContactItem)values[i];
selectedContacts.add(item.getFullJID());
selectedContacts.add(item.getJID());
}
return selectedContacts;

View File

@ -332,7 +332,7 @@ public class ConferencePlugin {
contactGroup.clearSelection();
if (item.isAvailable()) {
jids.add(item.getFullJID());
jids.add(item.getJID());
}
}

View File

@ -106,7 +106,7 @@ public class BroadcastPlugin extends SparkTabHandler implements Plugin, PacketLi
Iterator selectedUsersIterator = selectedUsers.iterator();
if (selectedUsersIterator.hasNext()) {
ContactItem contactItem = (ContactItem)selectedUsersIterator.next();
selectedUser = contactItem.getFullJID();
selectedUser = contactItem.getJID();
}
String jid = (String)JOptionPane.showInputDialog(SparkManager.getMainWindow(), Res.getString("label.enter.address"), Res.getString("title.start.chat"), JOptionPane.QUESTION_MESSAGE, null, null, selectedUser);
@ -327,9 +327,9 @@ public class BroadcastPlugin extends SparkTabHandler implements Plugin, PacketLi
ContactList contactList = SparkManager.getWorkspace().getContactList();
for (ContactGroup contactGroup : contactList.getContactGroups()) {
for (ContactItem item : contactGroup.getContactItems()) {
if (item != null && item.getFullJID() != null) {
if (item != null && item.getJID() != null) {
final Message message = new Message();
message.setTo(item.getFullJID());
message.setTo(item.getJID());
message.setBody(messageText);
message.setProperty("broadcast", true);
SparkManager.getConnection().sendPacket(message);
@ -355,7 +355,7 @@ public class BroadcastPlugin extends SparkTabHandler implements Plugin, PacketLi
if (ModelUtil.hasLength(messageText)) {
for (ContactItem item : group.getContactItems()) {
final Message message = new Message();
message.setTo(item.getFullJID());
message.setTo(item.getJID());
message.setProperty("broadcast", true);
message.setBody(messageText);
buf.append(item.getNickname()).append("\n");

View File

@ -78,13 +78,13 @@ public class ChatInfoPlugin implements Plugin, ContactInfoHandler {
}
});
lookupEmailAddress(contactInfoWindow.getContactItem().getContactJID());
lookupEmailAddress(contactInfoWindow.getContactItem().getJID());
}
private void lookupEmailAddress(final String jid) {
final VCard vcard = SparkManager.getVCardManager().getVCardFromMemory(jid);
if (contactInfoWindow.getContactItem() == null || !contactInfoWindow.getContactItem().getContactJID().equals(jid)) {
if (contactInfoWindow.getContactItem() == null || !contactInfoWindow.getContactItem().getJID().equals(jid)) {
return;
}
@ -111,7 +111,7 @@ public class ChatInfoPlugin implements Plugin, ContactInfoHandler {
*/
private void startConversation(ContactItem item) {
contactInfoWindow.dispose();
chatManager.activateChat(item.getContactJID(), item.getNickname());
chatManager.activateChat(item.getJID(), item.getNickname());
}
/**
@ -122,7 +122,7 @@ public class ChatInfoPlugin implements Plugin, ContactInfoHandler {
private void sendEmail(ContactItem item) {
contactInfoWindow.dispose();
final VCard vcard = SparkManager.getVCardManager().getVCard(item.getContactJID());
final VCard vcard = SparkManager.getVCardManager().getVCard(item.getJID());
String emailHome = vcard.getEmailHome();

View File

@ -169,11 +169,24 @@ public class ContactListAssistantPlugin implements Plugin {
public void uninstall() {
}
/**
* Copies or moves a new <code>ContactItem</code> into the <code>ContactGroup</code>.
*
* @param contactGroup the ContactGroup.
* @param item the ContactItem to move.
* @param move true if the ContactItem should be moved, otherwise false.
*/
private void addContactItem(final ContactGroup contactGroup, final ContactItem item, final boolean move) {
ContactItem newContact = new ContactItem(item.getNickname(), item.getFullJID());
ContactItem newContact = new ContactItem(item.getNickname(), item.getJID());
newContact.setPresence(item.getPresence());
newContact.setIcon(item.getIcon());
newContact.getNicknameLabel().setFont(item.getNicknameLabel().getFont());
// Do not copy/move a contact item only if it is not already in the Group.
if (contactGroup.getContactItemByJID(item.getJID()) != null) {
return;
}
contactGroup.addContactItem(newContact);
contactGroup.clearSelection();
@ -182,7 +195,7 @@ public class ContactListAssistantPlugin implements Plugin {
SwingWorker worker = new SwingWorker() {
public Object construct() {
Roster roster = SparkManager.getConnection().getRoster();
RosterEntry entry = roster.getEntry(item.getFullJID());
RosterEntry entry = roster.getEntry(item.getJID());
RosterGroup groupFound = null;
@ -240,7 +253,7 @@ public class ContactListAssistantPlugin implements Plugin {
// Remove entry from Roster Group
Roster roster = SparkManager.getConnection().getRoster();
RosterEntry entry = roster.getEntry(item.getFullJID());
RosterEntry entry = roster.getEntry(item.getJID());
RosterGroup rosterGroup = null;

View File

@ -104,11 +104,11 @@ public class PresenceChangePlugin implements Plugin {
final Iterator contactItems = new ArrayList(contacts).iterator();
while (contactItems.hasNext()) {
ContactItem item = (ContactItem)contactItems.next();
if (item.getFullJID().equals(StringUtils.parseBareAddress(from))) {
if (item.getJID().equals(StringUtils.parseBareAddress(from))) {
contacts.remove(item);
ChatManager chatManager = SparkManager.getChatManager();
ChatRoom chatRoom = chatManager.createChatRoom(item.getFullJID(), item.getNickname(), item.getNickname());
ChatRoom chatRoom = chatManager.createChatRoom(item.getJID(), item.getNickname(), item.getNickname());
String time = SparkManager.DATE_SECOND_FORMATTER.format(new Date());
@ -116,7 +116,7 @@ public class PresenceChangePlugin implements Plugin {
String infoText = Res.getString("message.user.now.available.to.chat", item.getNickname(), time);
chatRoom.getTranscriptWindow().insertNotificationMessage(infoText, ChatManager.NOTIFICATION_COLOR);
Message message = new Message();
message.setFrom(item.getFullJID());
message.setFrom(item.getJID());
message.setBody(infoText);
chatManager.getChatContainer().messageReceived(chatRoom, message);
}

View File

@ -176,7 +176,7 @@ public class PhonePlugin implements Plugin {
try {
phoneEnabled = phoneClient.isPhoneEnabled(item.getFullJID());
phoneEnabled = phoneClient.isPhoneEnabled(item.getJID());
}
catch (Exception e) {
Log.error("There was an error retrieving phone information.", e);
@ -185,7 +185,7 @@ public class PhonePlugin implements Plugin {
if (phoneEnabled) {
Action callAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
callJID(item.getFullJID());
callJID(item.getJID());
}
};

View File

@ -69,7 +69,7 @@ public class ChatTranscriptPlugin implements ChatRoomListener {
final Action viewHistoryAction = new AbstractAction() {
public void actionPerformed(ActionEvent actionEvent) {
ContactItem item = (ContactItem)contactList.getSelectedUsers().iterator().next();
final String jid = item.getFullJID();
final String jid = item.getJID();
showHistory(jid);
}

View File

@ -78,8 +78,8 @@ public class NotificationPlugin implements Plugin, PacketListener {
ContactList contactList = SparkManager.getWorkspace().getContactList();
for (ContactGroup contactGroup : contactList.getContactGroups()) {
for (ContactItem item : contactGroup.getContactItems()) {
if (item != null && item.getFullJID() != null && item.getPresence() != null) {
String bareJID = StringUtils.parseBareAddress(item.getFullJID());
if (item != null && item.getJID() != null && item.getPresence() != null) {
String bareJID = StringUtils.parseBareAddress(item.getJID());
onlineUsers.add(bareJID);
}
}

View File

@ -430,6 +430,31 @@ public class VCardManager {
return vcards.get(jid);
}
/**
* Forces a reload of a <code>VCard</code>.
*
* @param jid the jid of the user.
* @return the new VCard.
*/
public VCard reloadVCard(String jid) {
jid = StringUtils.parseBareAddress(jid);
VCard vcard = new VCard();
try {
vcard.load(SparkManager.getConnection(), jid);
vcard.setJabberId(jid);
vcards.put(jid, vcard);
}
catch (XMPPException e) {
vcard.setError(new XMPPError(409));
vcards.put(jid, vcard);
}
// Persist XML
persistVCard(jid, vcard);
return vcards.get(jid);
}
/**
* Adds a new vCard to the cache.
*