protocolContact passed through chat instead of protocolProvider

cusax-fix
Yana Stamcheva 20 years ago
parent 714907f6bc
commit ed5de732aa

@ -123,8 +123,7 @@ public Component getListCellRendererComponent(
= new ContactProtocolButton(protocolStatusIcon,
protocolStatusIcon);
contactProtocolButton.setProtocolProvider
(protocolContact.getProtocolProvider());
contactProtocolButton.setProtocolContact(protocolContact);
contactProtocolButton.setSize(protocolStatusIcon.getWidth(null),
protocolStatusIcon.getHeight(null));

@ -229,7 +229,7 @@ public void mousePressed(MouseEvent e) {
SwingUtilities.invokeLater
(new RunMessageWindow(contact,
((ContactProtocolButton)c)
.getProtocolProvider()));
.getProtocolContact()));
}
}
@ -248,18 +248,18 @@ public void mouseReleased(MouseEvent e) {
public class RunMessageWindow implements Runnable {
private MetaContact contactItem;
private ProtocolProviderService protocolProvider;
private Contact protocolContact;
public RunMessageWindow(MetaContact contactItem) {
this.contactItem = contactItem;
this.protocolProvider
= contactItem.getDefaultContact().getProtocolProvider();
this.protocolContact
= contactItem.getDefaultContact();
}
public RunMessageWindow(MetaContact contactItem,
ProtocolProviderService protocolProvider){
Contact protocolContact){
this.contactItem = contactItem;
this.protocolProvider = protocolProvider;
this.protocolContact = protocolContact;
}
public void run() {
@ -291,7 +291,7 @@ public void run() {
contactMsgWindows.put(this.contactItem, msgWindow);
msgWindow.addChat(this.contactItem,
contactStatus, protocolProvider);
contactStatus, protocolContact);
msgWindow.pack();
@ -324,7 +324,7 @@ public void windowClosing(WindowEvent e) {
// If there's no open tab for the given contact.
ChatPanel chatPanel = tabbedChatWindow.addChatTab(this.contactItem,
contactStatus, protocolProvider);
contactStatus, protocolContact);
tabbedChatWindow.setCurrentChatPanel(chatPanel);
@ -404,8 +404,8 @@ public void messageReceived(MessageReceivedEvent evt) {
= ((ContactListModel)this.contactList.getModel())
.getMetaContactStatus(metaContact);
ProtocolProviderService protocolProvider
= evt.getSourceContact().getProtocolProvider();
Contact protocolContact
= evt.getSourceContact();
if(!Constants.TABBED_CHAT_WINDOW){
//If in mode "open all messages in new window"
@ -434,7 +434,7 @@ public void messageReceived(MessageReceivedEvent evt) {
contactMsgWindows.put(metaContact, msgWindow);
msgWindow.addChat(metaContact, contactStatus,
protocolProvider);
protocolContact);
msgWindow.getCurrentChatPanel().getConversationPanel()
.processMessage(evt.getSourceContact().getDisplayName(),
@ -472,7 +472,7 @@ public void windowClosing(WindowEvent e) {
// If there's no open tab for the given contact.
chatPanel
= tabbedChatWindow.addChatTab(metaContact, contactStatus,
protocolProvider);
protocolContact);
chatPanel.getConversationPanel()
.processMessage(evt.getSourceContact().getDisplayName(),
@ -547,13 +547,12 @@ public void messageDeliveryFailed(MessageDeliveryFailedEvent evt) {
public void typingNotificationReceifed(TypingNotificationEvent evt) {
String notificationMsg = "";
notificationMsg
+= this.mainFrame.getContactList()
String contactName = this.mainFrame.getContactList()
.findMetaContactByContact(evt.getSourceContact())
.getDisplayName() + " ";
if(notificationMsg.equals("")){
notificationMsg += Messages.getString("unknown") + " ";
if(contactName.equals("")){
contactName = Messages.getString("unknown") + " ";
}
int typingState = evt.getTypingState();
@ -562,16 +561,16 @@ public void typingNotificationReceifed(TypingNotificationEvent evt) {
.findMetaContactByContact(evt.getSourceContact());
if(typingState == OperationSetTypingNotifications.STATE_TYPING){
notificationMsg += Messages.getString("contactTyping");
notificationMsg = Messages.getString("contactTyping", contactName);
}
else if(typingState == OperationSetTypingNotifications.STATE_PAUSED){
notificationMsg = "";
notificationMsg = Messages.getString("contactPausedTyping", contactName);
}
else if(typingState == OperationSetTypingNotifications.STATE_STOPPED){
notificationMsg = "";
}
else if(typingState == OperationSetTypingNotifications.STATE_STALE){
notificationMsg += Messages.getString("contactTypingStateStale");
notificationMsg = Messages.getString("contactTypingStateStale");
}
else if(typingState == OperationSetTypingNotifications.STATE_UNKNOWN){
//TODO: Implement state unknown

@ -3,21 +3,22 @@
import java.awt.Image;
import net.java.sip.communicator.impl.gui.main.customcontrols.SIPCommButton;
import net.java.sip.communicator.service.protocol.Contact;
import net.java.sip.communicator.service.protocol.ProtocolProviderService;
public class ContactProtocolButton extends SIPCommButton {
private ProtocolProviderService protocolProvider;
private Contact protocolContact;
public ContactProtocolButton(Image bgImage, Image rolloverImage){
super(bgImage, rolloverImage);
}
public ProtocolProviderService getProtocolProvider() {
return protocolProvider;
public Contact getProtocolContact() {
return protocolContact;
}
public void setProtocolProvider(ProtocolProviderService protocolProvider) {
this.protocolProvider = protocolProvider;
public void setProtocolContact(Contact protocolContact) {
this.protocolContact = protocolContact;
}
}

@ -23,7 +23,9 @@
import javax.swing.SwingUtilities;
import net.java.sip.communicator.service.contactlist.MetaContact;
import net.java.sip.communicator.service.protocol.Contact;
import net.java.sip.communicator.service.protocol.OperationSetBasicInstantMessaging;
import net.java.sip.communicator.service.protocol.OperationSetTypingNotifications;
import net.java.sip.communicator.service.protocol.PresenceStatus;
import net.java.sip.communicator.service.protocol.ProtocolProviderService;
@ -64,7 +66,9 @@ public class ChatPanel extends JPanel {
private OperationSetBasicInstantMessaging imOperationSet;
private ProtocolProviderService protocolProvider;
private OperationSetTypingNotifications tnOperationSet;
private Contact protocolContact;
/**
* Creates a chat panel which is added to the
@ -74,14 +78,18 @@ public class ChatPanel extends JPanel {
* chat panel.
*/
public ChatPanel(ChatWindow chatWindow,
ProtocolProviderService protocolProvider){
Contact protocolContact){
super(new BorderLayout());
this.chatWindow = chatWindow;
this.protocolProvider = protocolProvider;
this.protocolContact = protocolContact;
this.imOperationSet = this.chatWindow.getMainFrame()
.getProtocolIM(protocolProvider);;
.getProtocolIM(protocolContact
.getProtocolProvider());
this.tnOperationSet = this.chatWindow.getMainFrame()
.getTypingNotifications(protocolContact
.getProtocolProvider());
this.conversationPanel = new ChatConversationPanel(this);
@ -102,8 +110,6 @@ public ChatPanel(ChatWindow chatWindow,
this.init();
this.sendPanel.setSelectedProtocol(protocolProvider);
addComponentListener(new TabSelectionFocusGainListener());
}
@ -134,7 +140,9 @@ public void addContactToChat(MetaContact contactItem,
this.chatConferencePanel.addContactToChat(contactItem, status);
this.sendPanel.addProtocols(contactItem);
this.sendPanel.addProtocolContacts(contactItem);
this.sendPanel.setSelectedProtocolContact(this.protocolContact);
}
/**
@ -148,7 +156,7 @@ public void addContactToChat(MetaContact contactItem){
this.chatConferencePanel.addContactToChat(contactItem);
this.sendPanel.addProtocols(contactItem);
this.sendPanel.addProtocolContacts(contactItem);
}
/**
@ -250,6 +258,27 @@ public OperationSetBasicInstantMessaging getImOperationSet() {
this.imOperationSet = imOperationSet;
}
/**
* Returns the typing notifications operation set for
* this chat panel.
*
* @return OperationSetTypingNotifications The typing
* notifications operation set for this chat panel.
*/
public OperationSetTypingNotifications getTnOperationSet() {
return tnOperationSet;
}
/**
* Sets the typing notifications operation set for
* this chat panel.
* @param tnOperationSet The operation set to be set.
*/
public void setTnOperationSet
(OperationSetTypingNotifications tnOperationSet) {
this.tnOperationSet = tnOperationSet;
}
/**
* Returns the chat send panel.
* @return ChatSendPanel The chat send panel.
@ -294,4 +323,12 @@ public void run(){
public void componentHidden(ComponentEvent e) {
}
}
public Contact getProtocolContact() {
return protocolContact;
}
public void setProtocolContact(Contact protocolContact) {
this.protocolContact = protocolContact;
}
}

@ -33,6 +33,7 @@
import net.java.sip.communicator.service.protocol.Contact;
import net.java.sip.communicator.service.protocol.Message;
import net.java.sip.communicator.service.protocol.OperationSetBasicInstantMessaging;
import net.java.sip.communicator.service.protocol.OperationSetTypingNotifications;
import net.java.sip.communicator.service.protocol.ProtocolProviderService;
public class ChatSendPanel extends JPanel
@ -51,7 +52,7 @@ public class ChatSendPanel extends JPanel
private ArrayList protocolCList = new ArrayList();
SIPCommSelectorBox protocolSelectorBox = new SIPCommSelectorBox();
private SIPCommSelectorBox contactSelectorBox = new SIPCommSelectorBox();
public ChatSendPanel(ChatPanel chatPanel) {
@ -64,7 +65,7 @@ public ChatSendPanel(ChatPanel chatPanel) {
this.statusPanel.add(statusLabel);
this.sendPanel.add(sendButton, BorderLayout.CENTER);
this.sendPanel.add(protocolSelectorBox, BorderLayout.WEST);
this.sendPanel.add(contactSelectorBox, BorderLayout.WEST);
this.add(statusPanel, BorderLayout.CENTER);
this.add(sendPanel, BorderLayout.EAST);
@ -98,11 +99,15 @@ public void actionPerformed(ActionEvent e) {
this.chatPanel.getChatWindow()
.getMainFrame().getWaitToBeDeliveredMsgs()
.put(msg.getMessageUID(), this.chatPanel);
.put(msg.getMessageUID(), this.chatPanel);
try{
im.sendInstantMessage(chatPanel.getDefaultContact()
.getDefaultContact(), msg);
Contact contact = (Contact)contactSelectorBox.getSelectedObject();
//Send TYPING STOPPED event before sending the message
chatPanel.getWriteMessagePanel().stopTyping();
try{
im.sendInstantMessage(contact, msg);
}
catch(IllegalStateException ex){
String errorMsg = Messages.getString("msgSendConnectionProblem");
@ -119,7 +124,7 @@ public JButton getSendButton() {
return sendButton;
}
public void addProtocols(MetaContact metaContact) {
public void addProtocolContacts(MetaContact metaContact) {
Iterator protocolContacts = metaContact.getContacts();
while(protocolContacts.hasNext()){
@ -131,7 +136,7 @@ public void addProtocols(MetaContact metaContact) {
String protocolName = contact.getProtocolProvider()
.getProtocolName();
protocolSelectorBox.addItem(contact.getDisplayName(),
contactSelectorBox.addItem(contact.getDisplayName(),
new ImageIcon(Constants.getProtocolIcon(protocolName)),
new ProtocolItemListener());
}
@ -141,9 +146,11 @@ public void setTypingStatus(String statusMessage){
statusLabel.setText(statusMessage);
}
public void setSelectedProtocol(ProtocolProviderService protocolProvider){
protocolSelectorBox.setIcon(new ImageIcon(Constants
.getProtocolIcon(protocolProvider.getProtocolName())));
public void setSelectedProtocolContact(Contact protocolContact){
contactSelectorBox.setIcon(new ImageIcon(Constants
.getProtocolIcon(protocolContact.getProtocolProvider()
.getProtocolName())));
contactSelectorBox.setSelectedObject(protocolContact);
}
private class ProtocolItemListener implements ActionListener{
@ -161,8 +168,9 @@ public void actionPerformed(ActionEvent e){
.getProtocolIM(protocolContact.getProtocolProvider());
chatPanel.setImOperationSet(im);
chatPanel.setProtocolContact(protocolContact);
protocolSelectorBox.setSelected(menuItem);
contactSelectorBox.setSelected(menuItem);
}
}
}

@ -28,6 +28,7 @@
import net.java.sip.communicator.impl.gui.utils.Constants;
import net.java.sip.communicator.impl.gui.utils.ImageLoader;
import net.java.sip.communicator.service.contactlist.MetaContact;
import net.java.sip.communicator.service.protocol.Contact;
import net.java.sip.communicator.service.protocol.OperationSetBasicInstantMessaging;
import net.java.sip.communicator.service.protocol.PresenceStatus;
import net.java.sip.communicator.service.protocol.ProtocolProviderService;
@ -196,9 +197,9 @@ public void actionPerformed(ActionEvent e)
*/
public void addChat(MetaContact contact,
PresenceStatus status,
ProtocolProviderService protocolProvider){
Contact protocolContact){
this.setCurrentChatPanel(new ChatPanel(this, protocolProvider));
this.setCurrentChatPanel(new ChatPanel(this, protocolContact));
this.currentChatPanel.addContactToChat(contact, status);
@ -219,13 +220,13 @@ public void addChat(MetaContact contact,
*/
public ChatPanel addChatTab(MetaContact contact,
PresenceStatus status,
ProtocolProviderService protocolProvider){
Contact protocolContact){
ChatPanel chatPanel = null;
if(chatTabbedPane == null){
//Initialize the tabbed pane for the first time
chatPanel = new ChatPanel(this, protocolProvider);
chatPanel = new ChatPanel(this, protocolContact);
chatPanel.addContactToChat(contact, status);
@ -234,9 +235,8 @@ public ChatPanel addChatTab(MetaContact contact,
chatTabbedPane.addCloseListener(new CloseListener(){
public void closeOperation(MouseEvent e){
int selectedIndex = chatTabbedPane.getOverTabIndex();
removeContactTab(selectedIndex);
int tabIndex = chatTabbedPane.getOverTabIndex();
removeContactTab(tabIndex);
}
});
@ -254,7 +254,7 @@ public void closeOperation(MouseEvent e){
if(chatTabbedPane.getTabCount() > 0){
//The tabbed pane contains already tabs.
chatPanel = new ChatPanel(this, protocolProvider);
chatPanel = new ChatPanel(this, protocolContact);
chatPanel.addContactToChat(contact, status);
@ -280,7 +280,7 @@ public void closeOperation(MouseEvent e){
(currentContactStatus)),
firstChatPanel);
chatPanel = new ChatPanel(this, protocolProvider);
chatPanel = new ChatPanel(this, protocolContact);
chatPanel.addContactToChat(contact, status);
@ -336,22 +336,16 @@ public void removeContactTab(int index){
String title = chatTabbedPane.getTitleAt(index);
ChatPanel selectedChat
ChatPanel closeChat
= (ChatPanel)chatTabbedPane.getComponentAt(index);
if(title != null){
if(chatTabbedPane.getTabCount() > 1)
this.contactTabsTable.remove
(selectedChat.getDefaultContact().getMetaUID());
this.contactTabsTable.remove
(closeChat.getDefaultContact().getMetaUID());
Enumeration contactTabs = this.contactTabsTable.elements();
int selectedIndex = chatTabbedPane.getSelectedIndex();
if( selectedIndex > index){
chatTabbedPane.setSelectedIndex(selectedIndex - 1);
}
if(chatTabbedPane.getTabCount() > 1)
chatTabbedPane.remove(index);

Loading…
Cancel
Save