Patch sumbitted by Linus Wallgren. This patch includes two methods allowing other bundles than the gui to obtain existing chats and the contact corresponding to a chat. Thanks Linus!

cusax-fix
Yana Stamcheva 16 years ago
parent 8f13a9632d
commit 766d4bbb8f

@ -1137,4 +1137,39 @@ public boolean dispatchKeyEvent(KeyEvent e)
return false;
}
}
/**
* Returns a list containing all open Chats
*
* @return A list of all open Chats.
*/
public List<Chat> getChats()
{
List<Chat> chats = new ArrayList<Chat>();
for (ChatPanel chat : chatWindowManager.getChatPanels())
{
chats.add(chat);
}
return chats;
}
/**
* Get the MetaContact corresponding to the chat.
* The chat must correspond to a one on one conversation, otherwise this
* method will return null.
*
* @param chat The chat to get the MetaContact from
* @return The MetaContact corresponding to the chat or null in case
* it is a chat with more then one person.
*/
public MetaContact getChatContact(Chat chat)
{
Object contact = ((ChatPanel) chat).getChatSession().getDescriptor();
// If it is a one on one conversation this would be a MetaContact
if (contact instanceof MetaContact)
return (MetaContact) contact;
// If not, we are talking to more then one person and we return null
else
return null;
}
}

@ -542,6 +542,16 @@ public ChatPanel getMultiChat( ChatRoom chatRoom,
}
}
/**
* Returns all open ChatPanel´s
*
* @return A list of ChatPanels
*/
public List<ChatPanel> getChatPanels()
{
return chatPanels;
}
/**
* Closes the selected chat tab or the window if there are no tabs.
*

@ -8,8 +8,10 @@
import java.awt.*;
import java.util.*;
import java.util.List;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.contactlist.*;
/**
* The <tt>UIService</tt> offers generic access to the graphical user interface
@ -211,6 +213,23 @@ public ExportedWindow getExportedWindow(WindowID windowID, Object[] params)
*/
public Chat getChat(ChatRoom chatRoom);
/**
* Returns a list of all open Chats
*
* @return A list of all open Chats
*/
public List<Chat> getChats();
/**
* Get the MetaContact corresponding to the chat.
* The chat must correspond to a one on one conversation. If it is a
* group chat an exception will be thrown.
*
* @param chat The chat to get the MetaContact from
* @return The MetaContact corresponding to the chat.
*/
public MetaContact getChatContact(Chat chat);
/**
* Returns the selected <tt>Chat</tt>.
*

Loading…
Cancel
Save