Better handling for changes in the persistent data of a contact.

cusax-fix
Emil Ivov 17 years ago
parent ad5c4b846c
commit c3929a69a7

@ -8,6 +8,7 @@
import java.io.*;
import java.util.*;
import javax.xml.parsers.*;
import org.osgi.framework.*;
@ -242,7 +243,7 @@ public void stop ()
this.started = false;
synchronized(contactListRWLock)
{
this.contactListRWLock.notifyAll();
MclStorageManager.contactListRWLock.notifyAll();
}
}
@ -372,13 +373,13 @@ void start(BundleContext bc,
*/
private void scheduleContactListStorage() throws IOException
{
synchronized(this.contactListRWLock)
synchronized(MclStorageManager.contactListRWLock)
{
if (!isStarted())
return;
this.isModified = true;
this.contactListRWLock.notifyAll();
MclStorageManager.contactListRWLock.notifyAll();
}
}
@ -505,10 +506,10 @@ private void updatePersistentDataForMetaContact(MetaContact metaContact)
Element metaContactNode =
findMetaContactNode(metaContact.getMetaUID());
Iterator iter = metaContact.getContacts();
Iterator<Contact> iter = metaContact.getContacts();
while (iter.hasNext())
{
Contact item = (Contact)iter.next();
Contact item = iter.next();
if(item.getPersistentData() != null)
{
@ -651,7 +652,7 @@ private void processGroupXmlNode(
String accountID,
Element groupNode,
MetaContactGroup parentGroup,
Map parentProtoGroups)
Map<String, ContactGroup> parentProtoGroups)
{
//first resolve the group itself.(unless this is the meta contact list
//root which is already resolved)
@ -660,7 +661,8 @@ private void processGroupXmlNode(
//in this map we store all proto groups that we find in this meta group
//(unless this is the MCL root)in order to pass them as parent
//references to any subgroups.
Map protoGroupsMap = new Hashtable();
Map<String, ContactGroup> protoGroupsMap
= new Hashtable<String, ContactGroup>();
if(parentGroup == null)
{
@ -770,8 +772,9 @@ private void processGroupXmlNode(
String displayName = XMLUtils.getText(displayNameNode);
//extract a map of all encapsulated proto contacts
List protoContacts
= extractProtoContacts( (Element) currentMetaContactNode
List<MclStorageManager.StoredProtoContactDescriptor>
protoContacts = extractProtoContacts(
(Element) currentMetaContactNode
, accountID
, protoGroupsMap);
@ -781,7 +784,8 @@ private void processGroupXmlNode(
continue;
// Extract contact details.
Hashtable details = new Hashtable();
Hashtable<String, List<String>> details
= new Hashtable<String, List<String>>();
try
{
List detailsNodes = XMLUtils.findChildren(
@ -796,7 +800,7 @@ private void processGroupXmlNode(
Object detailsObj = details.get(name);
if(detailsObj == null)
{
ArrayList ds = new ArrayList();
ArrayList<String> ds = new ArrayList<String>();
ds.add(value);
details.put(name, ds);
}
@ -923,7 +927,8 @@ private void processGroupXmlNode(
* contact descriptors.
* @return a java.util.List containing contact descriptors.
*/
private List extractProtoContacts(Element metaContactNode,
private List<MclStorageManager.StoredProtoContactDescriptor>
extractProtoContacts(Element metaContactNode,
String accountID,
Map protoGroups)
{
@ -1450,6 +1455,43 @@ public void metaContactRenamed(MetaContactRenamedEvent evt)
}
}
/**
* Updates the data stored for the contact that caused this event.
*
* @param evt the MetaContactListEvent containing the corresponding contact
*/
public void protoContactModified(ProtoContactEvent evt)
{
Element metaContactNode = findMetaContactNode(
evt.getParent().getMetaUID());
//not sure what to do in case of null. we'll be logging an internal err
//for now and that's all.
if(metaContactNode == null)
{
logger.error("Save after proto contact modification failed. "
+"Contact not found: "
+ evt.getParent());
return;
}
updatePersistentDataForMetaContact(evt.getParent());
// i don't think we could do anything else in addition to updating the
// persistent data.
try{
scheduleContactListStorage();
}
catch (IOException ex){
/**given we're being invoked from an event dispatch thread that was
probably triggered by a net operation - we could not do much.
so ... log and @todo one day we'll have a global error dispatcher */
logger.error("Writing CL failed after rename of "
+ evt.getParent(), ex);
}
}
/**
* Indicates that a MetaContact has been modified.
* @param evt the MetaContactModifiedEvent containing the corresponding contact

@ -700,7 +700,8 @@ public void createMetaContactGroup(MetaContactGroup parent,
//make sure that "parent" does not already contain a subgroup called
//"groupName"
Iterator<MetaContactGroupImpl> subgroups = parent.getSubgroups();
Iterator<MetaContactGroupImpl> subgroups
= ((MetaContactGroupImpl)parent).getSubgroups();
while(subgroups.hasNext())
{
@ -2128,11 +2129,25 @@ public void contactModified(ContactPropertyChangeEvent evt)
evt.getSourceContact());
if( ContactPropertyChangeEvent.PROPERTY_DISPLAY_NAME
.equals(evt.getPropertyName())
&& evt.getOldValue() != null
&& ((String)evt.getOldValue()).equals(mc.getDisplayName()))
.equals(evt.getPropertyName()))
{
renameMetaContact(mc, (String)evt.getNewValue());
if( evt.getOldValue() != null
&& ((String)evt.getOldValue()).equals(mc.getDisplayName()))
{
renameMetaContact(mc, (String)evt.getNewValue());
}
else
{
//we get here if the name of a contact has changed but the
//meta contact list is not going to reflect any change
//because it is not displaying that name. in this case we
//simply make sure everyone (e.g. the storage manager)
//knows about the change.
fireProtoContactEvent(evt.getSourceContact(),
ProtoContactEvent.PROTO_CONTACT_MODIFIED,
mc,
mc);
}
}
else if( ContactPropertyChangeEvent.PROPERTY_IMAGE
.equals(evt.getPropertyName())
@ -2532,16 +2547,18 @@ private void fireProtoContactEvent(Contact source,
{
listener.protoContactAdded(event);
}
else if (eventName.equals(ProtoContactEvent
.PROTO_CONTACT_MOVED))
else if (eventName.equals(ProtoContactEvent.PROTO_CONTACT_MOVED))
{
listener.protoContactMoved(event);
}
else if (eventName.equals(ProtoContactEvent
.PROTO_CONTACT_REMOVED))
else if (eventName.equals(ProtoContactEvent.PROTO_CONTACT_REMOVED))
{
listener.protoContactRemoved(event);
}
else if (eventName.equals(ProtoContactEvent.PROTO_CONTACT_MODIFIED))
{
listener.protoContactModified(event);
}
}
}

@ -51,12 +51,12 @@ public class MetaContactChatPanel
/*
* There is some problem when adding the icon to the check box, the check
* box disappears.
*
*
* new ImageIcon(ImageLoader.getImage(ImageLoader.SEND_SMS_ICON))
*/
private ProtocolContactSelectorBox contactSelectorBox;
private Message sentSmsMessage = null;
/**
@ -80,7 +80,7 @@ public MetaContactChatPanel( ChatWindow chatWindow,
//Add the contact to the list of contacts contained in this panel
getChatContactListPanel().addContact(chatContact);
setupListeners(true);
// Initialize the "send via" selector box and adds it to the send panel.
@ -105,7 +105,7 @@ public MetaContactChatPanel( ChatWindow chatWindow,
amap.put("ChangeProtocol", new ChangeProtocolAction());
InputMap imap = this.getInputMap(
JComponent.WHEN_IN_FOCUSED_WINDOW);
JComponent.WHEN_IN_FOCUSED_WINDOW);
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_P,
KeyEvent.CTRL_DOWN_MASK), "ChangeProtocol");
@ -113,7 +113,7 @@ public MetaContactChatPanel( ChatWindow chatWindow,
/*
* (non-Javadoc)
*
*
* @see net.java.sip.communicator.impl.gui.main.chat.ChatPanel#dispose()
*/
public void dispose()
@ -131,7 +131,7 @@ public void dispose()
/**
* Adds or removes the listeners which observe the model displayed by this
* view.
*
*
* @param add <tt>true</tt> to add the listeners to the model displayed by
* this view; <tt>false</tt> to remove the previously-installed
* listeners from the model
@ -196,7 +196,7 @@ public void run()
// Used to disable/enable history flash buttons in the chat
// window tool bar.
loadHistoryPeriod();
// Load the last N=CHAT_HISTORY_SIZE messages from history.
Collection historyList = msgHistory.findLast(
metaContact, ConfigurationManager.getChatHistorySize());
@ -205,12 +205,12 @@ public void run()
class ProcessHistory implements Runnable
{
Collection historyList;
ProcessHistory(Collection historyList)
{
this.historyList = historyList;
}
public void run()
{
processHistory(historyList, null);
@ -226,7 +226,7 @@ public void run()
* Loads history messages ignoring the message given by the
* escapedMessageID. Implements the
* <tt>ChatPanel.loadHistory(String)</tt> method.
*
*
* @param escapedMessageID The id of the message that should be ignored.
*/
public void loadHistory(final String escapedMessageID)
@ -245,13 +245,13 @@ public void loadHistory(final String escapedMessageID)
// Used to disable/enable history flash buttons in the chat
// window tool bar.
loadHistoryPeriod();
Collection historyList = msgHistory.findLast(
metaContact, ConfigurationManager.getChatHistorySize());
processHistory(historyList, escapedMessageID);
}
/**
* Loads history period dates for the current chat.
*/
@ -268,7 +268,7 @@ private void loadHistoryPeriod()
Collection firstMessage = msgHistory
.findFirstMessagesAfter(metaContact, new Date(0), 1);
if(firstMessage.size() > 0)
{
Iterator i = firstMessage.iterator();
@ -279,37 +279,37 @@ private void loadHistoryPeriod()
{
MessageDeliveredEvent evt
= (MessageDeliveredEvent)o;
this.firstHistoryMsgTimestamp = evt.getTimestamp();
}
else if(o instanceof MessageReceivedEvent)
{
MessageReceivedEvent evt = (MessageReceivedEvent)o;
this.firstHistoryMsgTimestamp = evt.getTimestamp();
}
}
}
Collection lastMessage = msgHistory
.findLastMessagesBefore(metaContact, new Date(Long.MAX_VALUE), 1);
if(lastMessage.size() > 0)
{
Iterator i1 = lastMessage.iterator();
Object o1 = i1.next();
if(o1 instanceof MessageDeliveredEvent)
{
MessageDeliveredEvent evt
= (MessageDeliveredEvent)o1;
this.lastHistoryMsgTimestamp = evt.getTimestamp();
}
else if(o1 instanceof MessageReceivedEvent)
{
MessageReceivedEvent evt = (MessageReceivedEvent)o1;
this.lastHistoryMsgTimestamp = evt.getTimestamp();
}
}
@ -317,7 +317,7 @@ else if(o1 instanceof MessageReceivedEvent)
/**
* Returns the date of the first message in history for this chat.
*
*
* @return the date of the first message in history for this chat.
*/
public Date getFirstHistoryMsgTimestamp()
@ -327,17 +327,17 @@ public Date getFirstHistoryMsgTimestamp()
/**
* Returns the date of the last message in history for this chat.
*
*
* @return the date of the last message in history for this chat.
*/
public Date getLastHistoryMsgTimestamp()
{
return lastHistoryMsgTimestamp;
}
/**
* Returns the name of this chat.
*
*
* @return the name of this chat
*/
public String getChatName()
@ -349,10 +349,10 @@ public String getChatName()
return Messages.getI18NString("unknown").getText();
}
/**
* Returns the identifier of this chat.
*
*
* @return the identifier of this chat
*/
public Object getChatIdentifier()
@ -375,7 +375,7 @@ public ImageIcon getChatStatusIcon()
/**
* Updates the status of the given contact in this chat panel.
*
*
* @param contact the contact, which changed the status
* @param newStatus the new status of the contact
*/
@ -384,7 +384,7 @@ public void updateContactStatus(Contact contact, PresenceStatus newStatus)
// Update the status of the given contact in the "send via" selector
// box.
contactSelectorBox.updateContactStatus(contact);
// Update the status of the source meta contact in the contact details
// panel on the right.
if(metaContact.getDefaultContact().equals(contact))
@ -418,7 +418,7 @@ public void updateContactStatus(Contact contact, PresenceStatus newStatus)
}
}
}
/**
* Implements the <tt>ChatPanel.sendMessage</tt> method. Obtains the
* appropriate operation set and sends the message, contained in the write
@ -447,12 +447,12 @@ protected void sendMessage()
public void metaContactRenamed(MetaContactRenamedEvent evt)
{
String newName = evt.getNewDisplayName();
if(evt.getSourceMetaContact().equals(metaContact))
{
ChatContact chatContact
= findChatContactByMetaContact(evt.getSourceMetaContact());
getChatContactListPanel().renameContact(chatContact);
getChatWindow().setTabTitle(this, newName);
@ -463,7 +463,7 @@ public void metaContactRenamed(MetaContactRenamedEvent evt)
}
}
}
/**
* Implements <tt>MetaContactListListener.metaContactModified</tt> method.
* Indicates that a MetaContact has been modified.
@ -477,9 +477,9 @@ public void metaContactModified(MetaContactModifiedEvent evt)
* When a proto contact is added, updates the "send via" selector box.
*/
public void protoContactAdded(ProtoContactEvent evt)
{
{
if (evt.getNewParent().equals(metaContact))
{
{
this.contactSelectorBox.addProtoContact(evt.getProtoContact());
}
}
@ -496,6 +496,16 @@ public void protoContactRemoved(ProtoContactEvent evt)
}
}
/**
* Implements the <tt>MetaContactListListener.protoContactModified</tt>
* method with an empty body since we are not interested in proto contact
* specific changes (such as the persistent data) in the user interface.
*/
public void protoContactModified(ProtoContactEvent evt)
{
//currently ignored
}
/**
* Implements <tt>MetaContactListListener.protoContactMoved</tt> method.
* When a proto contact is moved, updates the "send via" selector box.
@ -506,7 +516,7 @@ public void protoContactMoved(ProtoContactEvent evt)
{
contactSelectorBox.removeProtoContact(evt.getProtoContact());
}
if (evt.getNewParent().equals(metaContact))
{
contactSelectorBox.addProtoContact(evt.getProtoContact());
@ -543,12 +553,12 @@ public int sendTypingNotification(int typingState)
{
Contact protocolContact
= contactSelectorBox.getSelectedProtocolContact();
OperationSetTypingNotifications tnOperationSet
= (OperationSetTypingNotifications)
protocolContact.getProtocolProvider()
.getOperationSet(OperationSetTypingNotifications.class);
if(protocolContact.getProtocolProvider().isRegistered()
&& tnOperationSet != null)
{
@ -556,17 +566,17 @@ public int sendTypingNotification(int typingState)
{
tnOperationSet.sendTypingNotification(
protocolContact, typingState);
return ChatPanel.TYPING_NOTIFICATION_SUCCESSFULLY_SENT;
}
catch (Exception ex)
{
logger.error("Failed to send typing notifications.", ex);
return ChatPanel.TYPING_NOTIFICATION_SEND_FAILED;
}
}
return ChatPanel.TYPING_NOTIFICATION_SEND_FAILED;
}
@ -582,7 +592,7 @@ public void treatReceivedMessage(Contact sourceContact)
contactSelectorBox.setSelected(sourceContact);
}
}
/**
* The <tt>ChangeProtocolAction</tt> is an <tt>AbstractAction</tt> that
* opens the menu, containing all available protocol contacts.
@ -622,12 +632,12 @@ public void run()
{
ChatConversationPanel conversationPanel
= getChatConversationPanel();
Date firstMsgDate
= conversationPanel.getPageFirstMsgTimestamp();
Collection c = null;
if(firstMsgDate != null)
{
c = msgHistory.findLastMessagesBefore(
@ -635,13 +645,13 @@ public void run()
firstMsgDate,
MESSAGES_PER_PAGE);
}
if(c !=null && c.size() > 0)
{
{
SwingUtilities.invokeLater(
new HistoryMessagesLoader(c));
}
}
}
}.start();
}
@ -669,52 +679,52 @@ public void run()
Collection c = null;
if(lastMsgDate != null)
{
{
c = msgHistory.findFirstMessagesAfter(
metaContact,
lastMsgDate,
MESSAGES_PER_PAGE);
}
if(c != null && c.size() > 0)
SwingUtilities.invokeLater(
new HistoryMessagesLoader(c));
}
}
}.start();
}
/**
* From a given collection of messages shows the history in the chat window.
*/
private class HistoryMessagesLoader implements Runnable
{
{
private Collection msgHistory;
public HistoryMessagesLoader(Collection msgHistory)
{
this.msgHistory = msgHistory;
}
public void run()
{
getChatConversationPanel().clear();
processHistory(msgHistory, "");
getChatConversationPanel().setDefaultContent();
}
}
/**
* Returns the <tt>MetaContact</tt> corresponding to the chat.
*
*
* @return the <tt>MetaContact</tt> corresponding to the chat.
*/
public MetaContact getMetaContact()
{
return metaContact;
}
public void subscriptionCreated(SubscriptionEvent evt)
{}
@ -747,11 +757,11 @@ public void contactModified(ContactPropertyChangeEvent evt)
chatContactPanel.setContactPhoto(chatContact.getImage());
}
}
/**
* Returns the <tt>ChatContact</tt> corresponding to the given
* <tt>MetaContact</tt>.
*
*
* @param metaContact the <tt>MetaContact</tt> to search for
* @return the <tt>ChatContact</tt> corresponding to the given
* <tt>MetaContact</tt>.
@ -760,33 +770,33 @@ private ChatContact findChatContactByMetaContact(MetaContact metaContact)
{
Iterator chatContacts
= getChatContactListPanel().getChatContacts();
while(chatContacts.hasNext())
{
ChatContact chatContact
= (ChatContact) chatContacts.next();
Object chatSourceContact = chatContact.getSourceContact();
if(chatSourceContact instanceof Contact)
{
MetaContact parentMetaContact
= GuiActivator.getMetaContactListService()
.findMetaContactByContact((Contact)chatSourceContact);
if(parentMetaContact != null
&& parentMetaContact.equals(metaContact))
return chatContact;
}
}
return null;
}
/**
* Returns the <tt>ChatContact</tt> corresponding to the given
* <tt>Contact</tt>.
*
*
* @param metaContact the <tt>MetaContact</tt> to search for
* @return the <tt>ChatContact</tt> corresponding to the given
* <tt>Contact</tt>.
@ -795,21 +805,21 @@ private ChatContact findChatContactByContact(Contact contact)
{
Iterator chatContacts
= getChatContactListPanel().getChatContacts();
while(chatContacts.hasNext())
{
ChatContact chatContact
= (ChatContact) chatContacts.next();
Object chatSourceContact = chatContact.getSourceContact();
if(chatSourceContact instanceof Contact
&& chatSourceContact.equals(contact))
{
return chatContact;
}
}
return null;
}
@ -888,7 +898,7 @@ private void sendSmsMessage()
Messages.getI18NString("msgDeliveryInternalError")
.getText(), "text");
}
return;
}
*/
@ -1032,15 +1042,15 @@ private void sendInstantMessage()
/**
* Changes the "Send as SMS" check box state.
*
*
* @param isSmsSelected <code>true</code> to set the "Send as SMS" check box
* selected, <code>false</code> - otherwise.
* selected, <code>false</code> - otherwise.
*/
public void setSmsSelected(boolean isSmsSelected)
{
sendSmsCheckBox.setSelected(isSmsSelected);
}
private class SmsMessageListener implements MessageListener
{
private OperationSetSmsMessaging smsOpSet;
@ -1053,13 +1063,13 @@ public SmsMessageListener(OperationSetSmsMessaging smsOpSet)
public void messageDelivered(MessageDeliveredEvent evt)
{
Message msg = evt.getSourceMessage();
// if there is no sms sent or this event is not for our sms ignore it
if(sentSmsMessage == null || !sentSmsMessage.equals(msg))
return;
sentSmsMessage = null;
Contact contact = evt.getDestinationContact();
processMessage(
@ -1079,15 +1089,15 @@ public void messageDelivered(MessageDeliveredEvent evt)
public void messageDeliveryFailed(MessageDeliveryFailedEvent evt)
{
logger.error(evt.getReason());
String errorMsg = null;
Message sourceMessage = (Message) evt.getSource();
// if there is no sms sent or this event is not for our sms ignore it
if(sentSmsMessage == null || !sentSmsMessage.equals(sourceMessage))
return;
sentSmsMessage = null;
Contact sourceContact = evt.getDestinationContact();
@ -1095,7 +1105,7 @@ public void messageDeliveryFailed(MessageDeliveryFailedEvent evt)
MetaContact metaContact = chatWindow.getMainFrame().getContactList()
.findMetaContactByContact(sourceContact);
if (evt.getErrorCode()
if (evt.getErrorCode()
== MessageDeliveryFailedEvent.OFFLINE_MESSAGES_NOT_SUPPORTED)
{
errorMsg = Messages.getI18NString(
@ -1141,17 +1151,17 @@ else if (evt.getErrorCode()
public void messageReceived(MessageReceivedEvent evt)
{}
}
/**
* Returns the selected protocol contact.
*
*
* @return the selected protocol contact
*/
public Contact getSelectedProtocolContact()
{
return contactSelectorBox.getSelectedProtocolContact();
}
public ProtocolContactSelectorBox getProtocolContactSelectorBox()
{
return contactSelectorBox;

@ -30,7 +30,7 @@
* custom data model and a custom list cell renderer is used. This class manages
* all meta contact list events, like <code>metaContactAdded</code>,
* <code>metaContactMoved</code>, <code>metaContactGroupAdded</code>, etc.
*
*
* @author Yana Stamcheva
*/
public class ContactList
@ -69,10 +69,10 @@ public class ContactList
private ContactRightButtonMenu contactRightButtonMenu;
private ContactListDraggable draggedElement;
/**
* Creates an instance of the <tt>ContactList</tt>.
*
*
* @param mainFrame The main application window.
*/
public ContactList(MainFrame mainFrame)
@ -111,9 +111,9 @@ public void focusLost(FocusEvent e)
}
}
});
this.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e)
public void keyPressed(KeyEvent e)
{
if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
{
@ -125,7 +125,7 @@ public void keyPressed(KeyEvent e)
}
}
});
this.addListSelectionListener(new ListSelectionListener()
{
public void valueChanged(ListSelectionEvent e)
@ -138,10 +138,10 @@ public void valueChanged(ListSelectionEvent e)
});
this.setShowOffline(ConfigurationManager.isShowOffline());
new ContactListRefresh().start();
}
/**
* Handles the <tt>MetaContactEvent</tt>. Refreshes the list model.
*/
@ -158,7 +158,7 @@ public void metaContactRenamed(MetaContactRenamedEvent evt)
{
this.refreshContact(evt.getSourceMetaContact());
}
/**
* Handles the <tt>MetaContactModifiedEvent</tt>.
* Indicates that a MetaContact has been modified.
@ -174,7 +174,7 @@ public void metaContactModified(MetaContactModifiedEvent evt)
public void protoContactAdded(ProtoContactEvent evt)
{
MetaContact parentMetaContact = evt.getNewParent();
this.refreshContact(parentMetaContact);
}
@ -195,11 +195,21 @@ public void protoContactMoved(ProtoContactEvent evt)
{
MetaContact oldParentMetaContact = evt.getOldParent();
MetaContact newParentMetaContact = evt.getNewParent();
this.refreshContact(oldParentMetaContact);
this.refreshContact(newParentMetaContact);
}
/**
* Implements the <tt>MetaContactListListener.protoContactModified</tt>
* method with an empty body since we are not interested in proto contact
* specific changes (such as the persistent data) in the user interface.
*/
public void protoContactModified(ProtoContactEvent evt)
{
//currently ignored
}
/**
* Handles the <tt>MetaContactEvent</tt>. Refreshes the list when a meta
* contact has been removed.
@ -271,7 +281,7 @@ public void childContactsReordered(MetaContactGroupEvent evt)
/**
* Returns the next list element that starts with a prefix.
*
*
* @param prefix the string to test for a match
* @param startIndex the index for starting the search
* @param bias the search direction, either Position.Bias.Forward or
@ -326,7 +336,7 @@ public int getNextMatch(String prefix, int startIndex, Position.Bias bias)
/**
* Returns the list of all groups.
*
*
* @return The list of all groups.
*/
public Iterator getAllGroups()
@ -336,7 +346,7 @@ public Iterator getAllGroups()
/**
* Returns the Meta Contact Group corresponding to the given MetaUID.
*
*
* @param metaUID An identifier of a group.
* @return The Meta Contact Group corresponding to the given MetaUID.
*/
@ -357,7 +367,7 @@ public MetaContactGroup getGroupByID(String metaUID)
/**
* Adds a listener for <tt>ContactListEvent</tt>s.
*
*
* @param listener the listener to add
*/
public void addContactListListener(ContactListListener listener)
@ -371,7 +381,7 @@ public void addContactListListener(ContactListListener listener)
/**
* Removes a listener previously added with <tt>addContactListListener</tt>.
*
*
* @param listener the listener to remove
*/
public void removeContactListListener(ContactListListener listener)
@ -384,7 +394,7 @@ public void removeContactListListener(ContactListListener listener)
/**
* Adds a listener for <tt>ContactListEvent</tt>s.
*
*
* @param listener the listener to add
*/
public void addExcContactListListener(ContactListListener listener)
@ -398,7 +408,7 @@ public void addExcContactListListener(ContactListListener listener)
/**
* Removes a listener previously added with <tt>addContactListListener</tt>.
*
*
* @param listener the listener to remove
*/
public void removeExcContactListListener(ContactListListener listener)
@ -412,7 +422,7 @@ public void removeExcContactListListener(ContactListListener listener)
/**
* Creates the corresponding ContactListEvent and notifies all
* <tt>ContactListListener</tt>s that a contact is selected.
*
*
* @param source the contact that this event is about.
* @param eventID the id indicating the exact type of the event to fire.
* @param clickCount the number of clicks accompanying the event.
@ -432,7 +442,7 @@ public void fireContactListEvent(Object source, int eventID, int clickCount)
{
ContactListListener listener
= (ContactListListener) listeners.next();
switch (evt.getEventID())
{
case ContactListEvent.CONTACT_SELECTED:
@ -483,7 +493,7 @@ public void fireContactListEvent(Object source, int eventID, int clickCount)
/**
* Creates the corresponding ContactListEvent and notifies all
* <tt>ContactListListener</tt>s that a contact is selected.
*
*
* @param sourceContact the contact that this event is about
* @param protocolContact the protocol contact the this event is about
* @param eventID the id indicating the exact type of the event to fire.
@ -517,10 +527,10 @@ public void fireContactListEvent(MetaContact sourceContact,
}
}
/**
* Manages a mouse click over the contact list.
*
*
* When the left mouse button is clicked on a contact cell different things
* may happen depending on the contained component under the mouse. If the
* mouse is double clicked on the "contact name" the chat window is opened,
@ -528,17 +538,17 @@ public void fireContactListEvent(MetaContact sourceContact,
* MetaContact. If the mouse is clicked on one of the protocol icons, the
* chat window is opened, configured to use the protocol contact
* corresponding to the given icon.
*
*
* When the right mouse button is clicked on a contact cell, the cell is
* selected and the <tt>ContactRightButtonMenu</tt> is opened.
*
*
* When the right mouse button is clicked on a group cell, the cell is
* selected and the <tt>GroupRightButtonMenu</tt> is opened.
*
*
* When the middle mouse button is clicked on a cell, the cell is selected.
*/
public void mouseClicked(MouseEvent e)
{
{
int selectedIndex = this.getSelectedIndex();
Object selectedValue = this.getSelectedValue();
@ -553,10 +563,10 @@ public void mouseClicked(MouseEvent e)
if (selectedValue instanceof MetaContactGroup)
{
MetaContactGroup group = (MetaContactGroup) selectedValue;
// Closes or opens a group on a double click.
if (e.getClickCount() > 1)
{
{
if (listModel.isGroupClosed(group))
{
listModel.openGroup(group);
@ -693,11 +703,11 @@ else if (component instanceof JPanel)
public void mouseEntered(MouseEvent e)
{
}
public void mouseExited(MouseEvent e)
{
}
/**
* Handle a mouse pressed event over the contact list.
*
@ -749,12 +759,12 @@ public void mousePressed(MouseEvent e)
Image image = new BufferedImage(component.getWidth(),
component.getHeight(),
BufferedImage.TYPE_INT_ARGB);
Graphics g = image.getGraphics();
g.setColor(getBackground());
g.fillRect(0, 0, image.getWidth(null), image.getHeight(null));
component.paint(image.getGraphics());
draggedElement = new ContactListDraggable( this,
mContact,
@ -787,7 +797,7 @@ else if (component instanceof JPanel)
}
}
}
if (draggedElement != null)
{
mainFrame.setGlassPane(draggedElement);
@ -798,7 +808,7 @@ else if (component instanceof JPanel)
draggedElement.setLocation(p);
}
}
/**
* If we are moving a <tt>Contact</tt> or <tt>MetaContact</tt> we
* update the coordinates of the dragged element and paint it at its new
@ -816,7 +826,7 @@ public void mouseDragged(MouseEvent e)
draggedElement.repaint();
}
}
/**
* If we were performing a drag'n drop operation when the mouse is released,
* complete it by moving the <tt>Contact</tt> and/or <tt>MetaContact</tt> enclosed
@ -858,7 +868,7 @@ public void mouseReleased(MouseEvent e)
contact,
contactDest).start();
}
}
}
}
@ -918,7 +928,7 @@ public void mouseMoved(MouseEvent e)
/**
* Returns the component positioned at the given x in the given container.
* It's used like getComponentAt.
*
*
* @param c the container where to search
* @param x the x coordinate of the searched component
* @return the component positioned at the given x in the given container
@ -1047,7 +1057,7 @@ else if (o instanceof MetaContactEvent)
/**
* Refreshes the given group content.
*
*
* @param group the group to update
*/
private class RefreshGroup
@ -1109,7 +1119,7 @@ else if (operation.equals(REMOVE_OPERATION))
/**
* Refreshes the given contact content.
*
*
* @param group the contact to refresh
*/
private class RefreshContact
@ -1164,7 +1174,7 @@ else if (operation.equals(REMOVE_OPERATION))
/**
* Refreshes the given group content.
*
*
* @param group the group to refresh
*/
public void modifyGroup(MetaContactGroup group)
@ -1220,7 +1230,7 @@ public void removeGroup(MetaContactGroup group)
/**
* Refreshes the given meta contact content.
*
*
* @param contact the meta contact to refresh
*/
public void refreshContact(MetaContact contact)
@ -1238,7 +1248,7 @@ public void refreshContact(MetaContact contact)
}
}
}
/**
* Refreshes the whole contact list.
*/
@ -1282,10 +1292,10 @@ public void removeContact(MetaContactEvent event)
}
}
}
/**
* Selects the given object in the list.
*
*
* @param o the object to select
*/
public void setSelectedValue(Object o)
@ -1303,7 +1313,7 @@ public void setSelectedValue(Object o)
/**
* Returns the right button menu for a contact.
*
*
* @return the right button menu for a contact
*/
public ContactRightButtonMenu getContactRightButtonMenu()
@ -1313,7 +1323,7 @@ public ContactRightButtonMenu getContactRightButtonMenu()
/**
* Returns the right button menu for a group.
*
*
* @return the right button menu for a group
*/
public GroupRightButtonMenu getGroupRightButtonMenu()
@ -1323,20 +1333,20 @@ public GroupRightButtonMenu getGroupRightButtonMenu()
/**
* Sets the showOffline property.
*
*
* @param isShowOffline TRUE to show all offline users, FALSE to hide
* offline users.
*/
public void setShowOffline(boolean isShowOffline)
{
int listSize = listModel.getSize();
listModel.setShowOffline(isShowOffline);
ConfigurationManager.setShowOffline(isShowOffline);
int newListSize = listModel.getSize();
//hide offline users
if(!isShowOffline && listSize > 0)
{
@ -1358,12 +1368,12 @@ else if(isShowOffline && newListSize > 0)
}
else
listModel.contentAdded(0, newListSize - 1);
}
}
}
/**
* Returns the main frame.
*
*
* @return the main frame
*/
public MainFrame getMainFrame()
@ -1500,7 +1510,7 @@ public MoveMetaContactThread( MetaContact srcContact,
this.srcContact = srcContact;
this.destGroup = destGroup;
}
public void run()
{
if (!ConfigurationManager.isMoveContactConfirmationRequested())

@ -20,7 +20,7 @@
/**
* The <tt>FirstWizardPage</tt> is the page, where user could enter the user
* ID and the password of the account.
*
*
* @author Yana Stamcheva
* @author Damian Minkov
*/
@ -113,7 +113,7 @@ public class FirstWizardPage
/**
* Creates an instance of <tt>FirstWizardPage</tt>.
*
*
* @param wizard the parent wizard
*/
public FirstWizardPage(JabberAccountRegistrationWizard wizard)
@ -265,11 +265,11 @@ public void removeUpdate(DocumentEvent evt)
public void actionPerformed(ActionEvent evt)
{
logger.debug("Reg OK");
// Open the new account dialog.
jabberNewAccountDialog = new JabberNewAccountDialog();
jabberNewAccountDialog = new JabberNewAccountDialog();
if (jabberNewAccountDialog.isOK == true)
{
serverField.setText(jabberNewAccountDialog.server);
@ -306,7 +306,7 @@ public void actionPerformed(ActionEvent evt)
/**
* Implements the <code>WizardPage.getIdentifier</code> to return this
* page identifier.
*
*
* @return the id of the first wizard page.
*/
public Object getIdentifier()
@ -317,7 +317,7 @@ public Object getIdentifier()
/**
* Implements the <code>WizardPage.getNextPageIdentifier</code> to return
* the next page identifier - the summary page.
*
*
* @return the id of the next wizard page.
*/
public Object getNextPageIdentifier()
@ -328,7 +328,7 @@ public Object getNextPageIdentifier()
/**
* Implements the <code>WizardPage.getBackPageIdentifier</code> to return
* the next back identifier - the default page.
*
*
* @return the id of the default wizard page.
*/
public Object getBackPageIdentifier()
@ -339,7 +339,7 @@ public Object getBackPageIdentifier()
/**
* Implements the <code>WizardPage.getWizardForm</code> to return this
* panel.
*
*
* @return this wizard page.
*/
public Object getWizardForm()
@ -363,6 +363,8 @@ public void commitPage()
{
String userID = userIDField.getText();
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!userID" + userID);
if (!wizard.isModification() && isExistingAccount(userID))
{
nextPageIdentifier = FIRST_PAGE_IDENTIFIER;
@ -418,7 +420,7 @@ private void setNextButtonAccordingToUserIDAndResource()
* Handles the <tt>DocumentEvent</tt> triggered when user types in the
* UserID field. Enables or disables the "Next" wizard button according to
* whether the UserID field is empty.
*
*
* @param evt the document event that has triggered this method call.
*/
public void insertUpdate(DocumentEvent evt)
@ -432,7 +434,7 @@ public void insertUpdate(DocumentEvent evt)
* Handles the <tt>DocumentEvent</tt> triggered when user deletes letters
* from the User ID field. Enables or disables the "Next" wizard button
* according to whether the User ID field is empty.
*
*
* @param evt the document event that has triggered this method call.
*/
public void removeUpdate(DocumentEvent evt)
@ -461,7 +463,7 @@ public void pageBack()
/**
* Fills the User ID and Password fields in this panel with the data coming
* from the given protocolProvider.
*
*
* @param protocolProvider The <tt>ProtocolProviderService</tt> to load
* the data from.
*/
@ -558,10 +560,10 @@ private void setNextButtonAccordingToPortAndPriority()
/**
* Checks if the accountName corresponds to an already existing account.
*
*
* @param accountName the name of the account to check
* @return TRUE if an account with the specified name already exists, FALSE -
* otherwise.
* otherwise.
*/
private boolean isExistingAccount(String accountName)
{
@ -581,12 +583,12 @@ private boolean isExistingAccount(String accountName)
}
return false;
}
public Object getSimpleForm()
{
return userIDPassPanel;
}
public boolean isCommitted()
{
return isCommitted;

@ -11,9 +11,12 @@
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.Logger;
import org.osgi.framework.*;
import com.jcraft.jsch.*;
/**
* The <tt>JabberAccountRegistrationWizard</tt> is an implementation of the
* <tt>AccountRegistrationWizard</tt> for the Jabber protocol. It should allow
@ -24,6 +27,9 @@
public class JabberAccountRegistrationWizard
implements AccountRegistrationWizard
{
private static final Logger logger =
Logger.getLogger(JabberAccountRegistrationWizard.class);
private static final String GOOGLE_USER_SUFFIX = "gmail.com";
private static final String GOOGLE_CONNECT_SRV = "talk.google.com";
@ -63,11 +69,11 @@ public byte[] getIcon()
{
return Resources.getImage(Resources.PROTOCOL_ICON);
}
/**
* Implements the <code>AccountRegistrationWizard.getPageImage</code> method.
* Returns the image used to decorate the wizard page
*
*
* @return byte[] the image used to decorate the wizard page
*/
public byte[] getPageImage()
@ -143,7 +149,7 @@ public Iterator getSummary()
/**
* Installs the account created through this wizard.
*
*
* @return ProtocolProviderService
*/
public ProtocolProviderService signin()
@ -168,7 +174,7 @@ public ProtocolProviderService signin(String userName, String password)
/**
* Creates an account for the given user and password.
*
*
* @param providerFactory the ProtocolProviderFactory which will create
* the account
* @param user the user identifier
@ -180,6 +186,10 @@ public ProtocolProviderService installAccount(
String userName,
String passwd)
{
if(logger.isTraceEnabled())
{
logger.trace("Preparing to install account for user " + userName);
}
Hashtable accountProperties = new Hashtable();
if (registration.isRememberPassword())
@ -223,6 +233,13 @@ public ProtocolProviderService installAccount(
try
{
if(logger.isTraceEnabled())
{
logger.trace("Will install account for user " + userName
+ " with the following properties."
+ accountProperties);
}
AccountID accountID = providerFactory.installAccount(
userName, accountProperties);
@ -235,6 +252,7 @@ public ProtocolProviderService installAccount(
}
catch (IllegalArgumentException exc)
{
logger.warn("Failed to create a jabber account.", exc);
JabberAccRegWizzActivator.getUIService().getPopupDialog()
.showMessagePopupDialog(exc.getMessage(),
Resources.getString("error"),
@ -242,6 +260,7 @@ public ProtocolProviderService installAccount(
}
catch (IllegalStateException exc)
{
logger.warn("Failed to create a jabber account.", exc);
JabberAccRegWizzActivator.getUIService().getPopupDialog()
.showMessagePopupDialog(exc.getMessage(),
Resources.getString("error"),
@ -271,7 +290,7 @@ public void loadAccount(ProtocolProviderService protocolProvider)
/**
* Indicates if this wizard is opened for modification or for creating a
* new account.
*
*
* @return <code>true</code> if this wizard is opened for modification and
* <code>false</code> otherwise.
*/
@ -282,7 +301,7 @@ public boolean isModification()
/**
* Returns the wizard container, where all pages are added.
*
*
* @return the wizard container, where all pages are added
*/
public WizardContainer getWizardContainer()
@ -293,7 +312,7 @@ public WizardContainer getWizardContainer()
/**
* Returns the registration object, which will store all the data through
* the wizard.
*
*
* @return the registration object, which will store all the data through
* the wizard
*/
@ -310,7 +329,7 @@ public Dimension getSize()
{
return new Dimension(300, 480);
}
/**
* Returns the identifier of the page to show first in the wizard.
* @return the identifier of the page to show first in the wizard.
@ -332,9 +351,9 @@ public Object getLastPageIdentifier()
/**
* Sets the modification property to indicate if this wizard is opened for
* a modification.
*
*
* @param isModification indicates if this wizard is opened for modification
* or for creating a new account.
* or for creating a new account.
*/
public void setModification(boolean isModification)
{

@ -1,6 +1,6 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
*
* Distributable under LGPL license. See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.msnaccregwizz;
@ -17,7 +17,7 @@
/**
* The <tt>FirstWizardPage</tt> is the page, where user could enter the uin
* and the password of the account.
*
*
* @author Yana Stamcheva
* @author Damian Minkov
*/
@ -64,7 +64,7 @@ public class FirstWizardPage
/**
* Creates an instance of <tt>FirstWizardPage</tt>.
*
*
* @param wizard the parent wizard
*/
public FirstWizardPage( MsnAccountRegistrationWizard wizard)
@ -254,7 +254,7 @@ public void pageBack()
/**
* Fills the UIN and Password fields in this panel with the data comming
* from the given protocolProvider.
*
*
* @param protocolProvider The <tt>ProtocolProviderService</tt> to load
* the data from.
*/
@ -290,12 +290,12 @@ private boolean isExistingAccount(String accountName)
}
return false;
}
public Object getSimpleForm()
{
return mainPanel;
}
public boolean isCommitted()
{
return isCommitted;

@ -14,7 +14,7 @@
/**
* Activates the profiler plug-in.
*
* @author Vladimir Škarupelov
* @author Vladimir Skarupelov
*/
public class ProfilerActivator implements BundleActivator {

@ -14,7 +14,7 @@
* The Messages class manages the access to the internationalization properties
* files.
*
* @author Vladimir Škarupelov;
* @author Vladimir Skarupelov;
*/
public class Resources
{

@ -9,7 +9,7 @@
/**
* Menu entry for the profiler plug-in
*
* @author Vladimir Å karupelov
* @author Vladimir Skarupelov
*/
import java.awt.event.*;
import javax.swing.*;

@ -34,7 +34,7 @@ public interface MetaContactGroup
* @return an Iterator over the protocol specific groups that this group
* represents.
*/
public Iterator getContactGroups();
public Iterator<ContactGroup> getContactGroups();
/**
* Returns all protocol specific ContactGroups, encapsulated by this
@ -51,7 +51,8 @@ public interface MetaContactGroup
* @return an <tt>Iterator</tt> over all contacts encapsulated in this
* <tt>MetaContact</tt> and originating from the specified provider.
*/
public Iterator getContactGroupsForProvider(ProtocolProviderService provider);
public Iterator<ContactGroup> getContactGroupsForProvider(
ProtocolProviderService provider);
/**
* Returns all protocol specific ContactGroups, encapsulated by this
@ -70,7 +71,7 @@ public interface MetaContactGroup
* <tt>MetaContact</tt> and originating from the provider with the specified
* account id.
*/
public Iterator getContactGroupsForAccountID(String accountID);
public Iterator<ContactGroup> getContactGroupsForAccountID(String accountID);
/**

@ -41,6 +41,17 @@ public interface MetaContactListListener
*/
public void protoContactAdded(ProtoContactEvent evt);
/**
* Indicates that one of the protocol specific <tt>Contact</tt> instances
* encapsulated by this <tt>MetaContact</tt> has been modified in some way.
* The event
* added to the list of protocol specific buddies in this
* <tt>MetaContact</tt>
* @param evt a reference to the corresponding
* <tt>ProtoContactEvent</tt>
*/
public void protoContactModified(ProtoContactEvent evt);
/**
* Indicates that a protocol specific <tt>Contact</tt> instance has been
* removed from the list of protocol specific buddies in this
@ -101,7 +112,7 @@ public interface MetaContactListListener
* event.
*/
public void childContactsReordered(MetaContactGroupEvent evt);
/**
* Indicates that a MetaContact has been modified.
* @param evt the MetaContactModifiedEvent containing the corresponding contact

@ -61,7 +61,15 @@ public abstract class MetaContactPropertyChangeEvent
* Indicates that the meta contact has been modified. The old and new value
* arguments contain the old and new values of the modification.
*/
public static final String META_CONTACT_MODIFIED = "MetaContactModifiedEvent";
public static final String PROTO_CONTACT_MODIFIED
= "ProtoContactModifiedEvent";
/**
* Indicates that the meta contact has been modified. The old and new value
* arguments contain the old and new values of the modification.
*/
public static final String META_CONTACT_MODIFIED
= "MetaContactModifiedEvent";
/**
* Creates an instnace of this event.

@ -38,6 +38,12 @@ public class ProtoContactEvent
*/
public static final String PROTO_CONTACT_MOVED = "ProtoContactMoved";
/**
* Indicates that this event instance was triggered by changing a protocol
* specific contact in some way.
*/
public static final String PROTO_CONTACT_MODIFIED = "ProtoContactModified";
/**
* Creates an instance of this <tt>ProtoContactEvent</tt>.
* @param source the proto <tt>Contact</tt> that this event is about.

@ -17,13 +17,19 @@ public class ContactPropertyChangeEvent
* contact.
*/
public static final String PROPERTY_DISPLAY_NAME = "DisplayName";
/**
* Indicates that a change has occurred in the image of the source
* contact.
*/
public static final String PROPERTY_IMAGE = "Image";
/**
* Indicates that a change has occurred in the data that the contact is
* storing in external sources.
*/
public static final String PROPERTY_PERSISTENT_DATA = "PersistentData";
/**
* Creates a ContactPropertyChangeEvent indicating that a change has
* occurred for property <tt>propertyName</tt> in the <tt>source</tt>

@ -1165,6 +1165,15 @@ public void protoContactMoved(ProtoContactEvent evt)
collectedMetaContactEvents.add(evt);
}
/**
* Implements the <tt>MetaContactListListener.protoContactModified</tt>
* method with an empty body since we are not interested in proto contact
* specific changes (such as the persistent data).
*/
public void protoContactModified(ProtoContactEvent evt)
{
//currently ignored
}
/**
* Indicates that a protocol specific <tt>Contact</tt> instance has been

Loading…
Cancel
Save