/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.java.sip.communicator.impl.gui.main.chat;
import java.util.*;
import javax.swing.*;
import net.java.sip.communicator.service.filehistory.*;
import net.java.sip.communicator.service.msghistory.*;
import net.java.sip.communicator.service.protocol.*;
/**
* @author Yana Stamcheva
* @author Lubomir Marinov
*/
public abstract class ChatSession
{
/**
* The chat history filter.
*/
protected final String[] chatHistoryFilter
= new String[]{ MessageHistoryService.class.getName(),
FileHistoryService.class.getName()};
/**
* The list of ChatContacts contained in this chat session.
*/
protected final List> chatParticipants
= new ArrayList>();
/**
* The list of ChatTransports available in this session.
*/
protected final List chatTransports
= new LinkedList();
/**
* The list of all ChatSessionChangeListener-s registered to listen
* for transport modifications.
*/
private final List
chatTransportChangeListeners
= new ArrayList();
/**
* The persistable address of the contact from the session.
*/
protected String persistableAddress = null;
/**
* Returns the descriptor of this chat session.
*
* @return the descriptor of this chat session.
*/
public abstract Object getDescriptor();
/**
* Returns the persistable address of the contact from the session.
* @return the persistable address.
*/
public String getPersistableAddress()
{
return persistableAddress;
}
/**
* Returns true if this chat session descriptor is persistent,
* otherwise returns false.
* @return true if this chat session descriptor is persistent,
* otherwise returns false.
*/
public abstract boolean isDescriptorPersistent();
/**
* Returns an iterator to the list of all participants contained in this
* chat session.
*
* @return an iterator to the list of all participants contained in this
* chat session.
*/
public Iterator> getParticipants()
{
return chatParticipants.iterator();
}
/**
* Returns all available chat transports for this chat session. Each chat
* transport is corresponding to a protocol provider.
*
* @return all available chat transports for this chat session.
*/
public Iterator getChatTransports()
{
return chatTransports.iterator();
}
/**
* Returns the currently used transport for all operation within this chat
* session.
*
* @return the currently used transport for all operation within this chat
* session.
*/
public abstract ChatTransport getCurrentChatTransport();
/**
* Returns a list of all ChatTransports contained in this session
* supporting the given opSetClass.
* @param opSetClass the OperationSet class we're looking for
* @return a list of all ChatTransports contained in this session
* supporting the given opSetClass
*/
public List getTransportsForOperationSet(
Class extends OperationSet> opSetClass)
{
LinkedList opSetTransports
= new LinkedList();
for (ChatTransport transport : chatTransports)
{
if(transport.getProtocolProvider()
.getOperationSet(opSetClass) != null)
opSetTransports.add(transport);
}
return opSetTransports;
}
/**
* Returns the ChatSessionRenderer that provides the connection
* between this chat session and its UI.
*
* @return The ChatSessionRenderer.
*/
public abstract ChatSessionRenderer getChatSessionRenderer();
/**
* Sets the transport that will be used for all operations within this chat
* session.
*
* @param chatTransport The transport to set as a default transport for this
* session.
*/
public abstract void setCurrentChatTransport(ChatTransport chatTransport);
/**
* Returns the name of the chat. If this chat panel corresponds to a single
* chat it will return the name of the MetaContact, otherwise it
* will return the name of the chat room.
*
* @return the name of the chat
*/
public abstract String getChatName();
/**
* Returns a collection of the last N number of history messages given by
* count.
*
* @param count The number of messages from history to return.
* @return a collection of the last N number of messages given by count.
*/
public abstract Collection