Java 类org.jivesoftware.smackx.ChatState 实例源码

项目:Beem    文件:ChatAdapter.java   
/**
 * {@inheritDoc}
 */
@Override
public void stateChanged(Chat chat, ChatState state) {
    mState = state.name();
    final int n = mRemoteListeners.beginBroadcast();

    for (int i = 0; i < n; i++) {
    IMessageListener listener = mRemoteListeners.getBroadcastItem(i);
    try {
        listener.stateChanged(ChatAdapter.this);
    } catch (RemoteException e) {
        Log.w(TAG, e.getMessage());
    }
    }
    mRemoteListeners.finishBroadcast();
}
项目:beem-fork-xmpp    文件:ChatAdapter.java   
/**
 * {@inheritDoc}
 */
@Override
public void stateChanged(Chat chat, ChatState state) {
    mState = state.name();
    final int n = mRemoteListeners.beginBroadcast();

    for (int i = 0; i < n; i++) {
    IMessageListener listener = mRemoteListeners.getBroadcastItem(i);
    try {
        listener.stateChanged(ChatAdapter.this);
    } catch (RemoteException e) {
        Log.w(TAG, e.getMessage());
    }
    }
    mRemoteListeners.finishBroadcast();
}
项目:spark-svn-mirror    文件:ChatRoomImpl.java   
public void closeChatRoom() {
    // If already closed, don't bother.
    if (!active) {
        return;
    }

    super.closeChatRoom();

    removeListeners();

    sendChatState(ChatState.gone);
    sendGoneNotification = false;

    SparkManager.getChatManager().removeChat(this);

    SparkManager.getConnection().removePacketListener(this);
    if (typingTimerTask != null) {
        TaskEngine.getInstance().cancelScheduledTask(typingTimerTask);
        typingTimerTask = null;
    }
    active = false;
    vcardPanel = null;

    this.removeAll();
}
项目:spark-svn-mirror    文件:ChatRoomImpl.java   
/**
 * The current SendField has been updated somehow.
 *
 * @param e - the DocumentEvent to respond to.
 */
public void insertUpdate(DocumentEvent e) {
    checkForText(e);

    if (!sendChatStateNotification) {
        return;
    }
    startNotificationSendingTime = System.currentTimeMillis();

    // If the user pauses for more than two seconds, send out a new notice.
    if (sendComposingNotification) {
        try {
            //SparkManager.getMessageEventManager().sendComposingNotification(getParticipantJID(), threadID);               
            sendChatState(ChatState.composing);

            sendPausingNotification = true;
            sendInactiveNotification = true;
            sendGoneNotification = true;
            sendComposingNotification = false;
        }            
        catch (Exception exception) {
            Log.error("Error updating", exception);
        }
    }
}
项目:spark-svn-mirror    文件:ChatManager.java   
/**
 * Filters all incoming messages.
 *
 * @param room    the room the message belongs to.
 * @param message the message to filter.
 */
public void filterIncomingMessage(ChatRoom room, Message message) {
    // Fire Message Filters
    final ChatManager chatManager = SparkManager.getChatManager();
    Iterator<MessageFilter> filters = chatManager.getMessageFilters().iterator();
    try {
        cancelledNotification(message.getFrom(), ChatState.paused);
    }
    catch (Exception e) {
        Log.error(e);
    }

    // Notify MessageFilters.
    while (filters.hasNext()) {
        (filters.next()).filterIncoming(room, message);
    }
}
项目:spark-svn-mirror    文件:ChatManager.java   
public void composingNotification(final String from) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            final ContactList contactList = SparkManager.getWorkspace().getContactList();

            ChatRoom chatRoom;
            try {
                chatRoom = getChatContainer().getChatRoom(StringUtils.parseBareAddress(from));
                if (chatRoom != null && chatRoom instanceof ChatRoomImpl) {                     
                    typingNotificationList.add(chatRoom);
                    // Notify Decorators
                    notifySparkTabHandlers(chatRoom);
                    ((ChatRoomImpl)chatRoom).notifyChatStateChange(ChatState.composing);
                }
            }
            catch (ChatRoomNotFoundException e) {
                // Do nothing
            }
            contactList.setIconFor(from, SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_EDIT_IMAGE));
        }
    });
}
项目:spark-svn-mirror    文件:ChatManager.java   
public void cancelledNotification(final String from, final ChatState state) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            ContactList contactList = SparkManager.getWorkspace().getContactList();

            ChatRoom chatRoom;
            try {
                chatRoom = getChatContainer().getChatRoom(StringUtils.parseBareAddress(from));
                if (chatRoom != null && chatRoom instanceof ChatRoomImpl) {
                    typingNotificationList.remove(chatRoom);
                    // Notify Decorators
                    notifySparkTabHandlers(chatRoom);
                    ((ChatRoomImpl)chatRoom).notifyChatStateChange(state);
                }
            }
            catch (ChatRoomNotFoundException e) {
                // Do nothing
            }
            contactList.useDefaults(from);
        }
    });
}
项目:EIM    文件:ChatStateExtension.java   
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
    ChatState state;
    try {
        state = ChatState.valueOf(parser.getName());
    }
    catch (Exception ex) {
        state = ChatState.active;
    }
    return new ChatStateExtension(state);
}
项目:androidPN-client.    文件:ChatStateExtension.java   
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
    ChatState state;
    try {
        state = ChatState.valueOf(parser.getName());
    }
    catch (Exception ex) {
        state = ChatState.active;
    }
    return new ChatStateExtension(state);
}
项目:xmppsupport_v2    文件:ChatStateExtension.java   
public PacketExtension parseExtension(XmlPullParser parser)
        throws Exception {
    ChatState state;
    try {
        state = ChatState.valueOf(parser.getName());
    } catch (Exception ex) {
        state = ChatState.active;
    }
    return new ChatStateExtension(state);
}
项目:Openfire    文件:XMPPSession.java   
/**
 * @see net.sf.kraken.session.TransportSession#sendChatState(org.xmpp.packet.JID, net.sf.kraken.type.ChatStateType)
 */
@Override
public void sendChatState(JID jid, ChatStateType chatState) {
    final Presence presence = conn.getRoster().getPresence(jid.toString());
    if (presence == null  || presence.getType().equals(Presence.Type.unavailable)) {
        // don't send chat state to contacts that are offline.
        return;
    }
    Chat chat = conn.getChatManager().createChat(getTransport().convertJIDToID(jid), listener);
    try {
        ChatState state = ChatState.active;
        switch (chatState) {
            case active:    state = ChatState.active;    break;
            case composing: state = ChatState.composing; break;
            case paused:    state = ChatState.paused;    break;
            case inactive:  state = ChatState.inactive;  break;
            case gone:      state = ChatState.gone;      break;
        }

        Message message = new Message();
        message.addExtension(new ChatStateExtension(state));
        chat.sendMessage(message);
    }
    catch (XMPPException e) {
        // Ignore
    }
}
项目:g3server    文件:XMPPSession.java   
/**
 * @see net.sf.kraken.session.TransportSession#sendChatState(org.xmpp.packet.JID, net.sf.kraken.type.ChatStateType)
 */
@Override
public void sendChatState(JID jid, ChatStateType chatState) {
    final Presence presence = conn.getRoster().getPresence(jid.toString());
    if (presence == null  || presence.getType().equals(Presence.Type.unavailable)) {
        // don't send chat state to contacts that are offline.
        return;
    }
    Chat chat = conn.getChatManager().createChat(getTransport().convertJIDToID(jid), listener);
    try {
        ChatState state = ChatState.active;
        switch (chatState) {
            case active:    state = ChatState.active;    break;
            case composing: state = ChatState.composing; break;
            case paused:    state = ChatState.paused;    break;
            case inactive:  state = ChatState.inactive;  break;
            case gone:      state = ChatState.gone;      break;
        }

        Message message = new Message();
        message.addExtension(new ChatStateExtension(state));
        chat.sendMessage(message);
    }
    catch (XMPPException e) {
        // Ignore
    }
}
项目:openfire    文件:XMPPSession.java   
/**
 * @see net.sf.kraken.session.TransportSession#sendChatState(org.xmpp.packet.JID, net.sf.kraken.type.ChatStateType)
 */
@Override
public void sendChatState(JID jid, ChatStateType chatState) {
    final Presence presence = conn.getRoster().getPresence(jid.toString());
    if (presence == null  || presence.getType().equals(Presence.Type.unavailable)) {
        // don't send chat state to contacts that are offline.
        return;
    }
    Chat chat = conn.getChatManager().createChat(getTransport().convertJIDToID(jid), listener);
    try {
        ChatState state = ChatState.active;
        switch (chatState) {
            case active:    state = ChatState.active;    break;
            case composing: state = ChatState.composing; break;
            case paused:    state = ChatState.paused;    break;
            case inactive:  state = ChatState.inactive;  break;
            case gone:      state = ChatState.gone;      break;
        }

        Message message = new Message();
        message.addExtension(new ChatStateExtension(state));
        chat.sendMessage(message);
    }
    catch (XMPPException e) {
        // Ignore
    }
}
项目:java-bells    文件:ChatStateExtension.java   
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
    ChatState state;
    try {
        state = ChatState.valueOf(parser.getName());
    }
    catch (Exception ex) {
        state = ChatState.active;
    }
    return new ChatStateExtension(state);
}
项目:telegraph    文件:ChatStateExtension.java   
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
    ChatState state;
    try {
        state = ChatState.valueOf(parser.getName());
    }
    catch (Exception ex) {
        state = ChatState.active;
    }
    return new ChatStateExtension(state);
}
项目:NewCommunication-Android    文件:ChatStateExtension.java   
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
    ChatState state;
    try {
        state = ChatState.valueOf(parser.getName());
    }
    catch (Exception ex) {
        state = ChatState.active;
    }
    return new ChatStateExtension(state);
}
项目:openfire-bespoke    文件:XMPPSession.java   
/**
 * @see net.sf.kraken.session.TransportSession#sendChatState(org.xmpp.packet.JID, net.sf.kraken.type.ChatStateType)
 */
@Override
public void sendChatState(JID jid, ChatStateType chatState) {
    final Presence presence = conn.getRoster().getPresence(jid.toString());
    if (presence == null  || presence.getType().equals(Presence.Type.unavailable)) {
        // don't send chat state to contacts that are offline.
        return;
    }
    Chat chat = conn.getChatManager().createChat(getTransport().convertJIDToID(jid), listener);
    try {
        ChatState state = ChatState.active;
        switch (chatState) {
            case active:    state = ChatState.active;    break;
            case composing: state = ChatState.composing; break;
            case paused:    state = ChatState.paused;    break;
            case inactive:  state = ChatState.inactive;  break;
            case gone:      state = ChatState.gone;      break;
        }

        Message message = new Message();
        message.addExtension(new ChatStateExtension(state));
        chat.sendMessage(message);
    }
    catch (XMPPException e) {
        // Ignore
    }
}
项目:spark-svn-mirror    文件:ChatRoomImpl.java   
protected void createChatStateTimerTask() {
    typingTimerTask = new TimerTask() {
        public void run() {                
            if (!sendChatStateNotification) {
                return;
            }
            long now = System.currentTimeMillis();
            long time = now - startNotificationSendingTime;
            if (inBetween(time, pauseTimePeriod, inactiveTimePeriod)) {
                if (sendPausingNotification) {
                    // send cancel
                    //SparkManager.getMessageEventManager().sendCancelledNotification(getParticipantJID(), threadID);
                    sendChatState(ChatState.paused);
                    sendPausingNotification = false;
                    sendComposingNotification = true;
                }
            } else if (inBetween(time, inactiveTimePeriod, goneTimePeriod)) {
                if(sendInactiveNotification) {
                    sendChatState(ChatState.inactive);
                    sendInactiveNotification = false;
                }
            } else if (time > goneTimePeriod) {
                if (sendGoneNotification) {
                    sendChatState(ChatState.gone);
                    sendGoneNotification = false;
                }
            }                
        }
    };
    TaskEngine.getInstance().scheduleAtFixedRate(typingTimerTask, pauseTimePeriod, pauseTimePeriod);      
}
项目:spark-svn-mirror    文件:ChatRoomImpl.java   
public void activateChatStateNotificationSystem() {
    startNotificationSendingTime = System.currentTimeMillis();
    sendInactiveNotification = true;        
    sendGoneNotification = true;
    sendPausingNotification = false;
    sendComposingNotification = true;
    if (lastNotificationSent == null || !lastNotificationSent.equals(ChatState.active)) {
        sendChatState(ChatState.active);
    }
}
项目:spark-svn-mirror    文件:ChatRoomImpl.java   
public void inactivateChatStateNotificationSystem() {
    startNotificationSendingTime = System.currentTimeMillis();
    sendInactiveNotification = false;       
    sendGoneNotification = true;
    sendPausingNotification = false;
    sendComposingNotification = false;
    if (lastNotificationSent != null && !lastNotificationSent.equals(ChatState.inactive) && !lastNotificationSent.equals(ChatState.gone)) {
        sendChatState(ChatState.inactive);
    }
}
项目:spark-svn-mirror    文件:ChatRoomImpl.java   
private void sendChatState(ChatState state) {
    Connection connection = SparkManager.getConnection();
    boolean connected = connection.isConnected();
if (connected) {
    Chat chat = connection.getChatManager().createChat(getParticipantJID(), null);
    try {
        ChatStateManager.getInstance(connection).setCurrentState(state, chat);
        lastNotificationSent = state;
    } catch (XMPPException e) {
        Log.error("Cannot send " + state + " chat notification");
    }
}
  }
项目:spark-svn-mirror    文件:ChatRoomImpl.java   
public void notifyChatStateChange(ChatState state) {
    if (chatStatePanel != null) {
        getEditorWrapperBar().remove(chatStatePanel);
    }

    chatStatePanel = new ChatStatePanel(state, getParticipantNickname());       
    getEditorWrapperBar().add(chatStatePanel, BorderLayout.SOUTH);
    getEditorWrapperBar().revalidate();
    getEditorWrapperBar().repaint();
}
项目:spark-svn-mirror    文件:ChatStatePanel.java   
public ChatStatePanel(ChatState state, String nickname) {
    setLayout(new FlowLayout(FlowLayout.LEFT, 1, 1));
    label = new JLabel(Res.getString(state.name(), nickname));
    label.setFont(new Font("Courier New", Font.PLAIN, 9));
    label.setForeground(Color.gray);
    label.setHorizontalTextPosition(JLabel.LEFT);
    label.setVerticalTextPosition(JLabel.BOTTOM);
    add(label);
}
项目:spark-svn-mirror    文件:ChatManager.java   
/**
    * Called by smack when the state of a chat changes.
    *
    * @param chat the chat that is concerned by this event.
    * @param state the new state of the chat.
    */
@Override
   public void stateChanged(Chat chat, ChatState state) {
    String participant = chat.getParticipant();
       if (ChatState.composing.equals(state)) {
           composingNotification(participant);
       } else {
        cancelledNotification(participant, state);
       }

   }
项目:spark-svn-mirror    文件:SysTrayPlugin.java   
@Override
public void stateChanged(Chat chat, ChatState state) {      
       if (ChatState.composing.equals(state)) {
        changeSysTrayIcon();
       } else {
        if (!newMessage)
            trayIcon.setImage(availableIcon.getImage());
        else {
            trayIcon.setImage(newMessageIcon.getImage());
        }
       }
}
项目:aceim    文件:XMPPChatListener.java   
@Override
public void stateChanged(Chat chat, ChatState state) {
    if (state == ChatState.composing) {
        getInternalService().getService().getCoreService().typingNotification(getInternalService().getService().getEntityAdapter().normalizeJID(chat.getParticipant()));
    }
}
项目:EIM    文件:ChatStateExtension.java   
/**
 * Default constructor. The argument provided is the state that the extension will represent.
 *
 * @param state the state that the extension represents.
 */
public ChatStateExtension(ChatState state) {
    this.state = state;
}
项目:androidPN-client.    文件:ChatStateExtension.java   
/**
 * Default constructor. The argument provided is the state that the extension will represent.
 *
 * @param state the state that the extension represents.
 */
public ChatStateExtension(ChatState state) {
    this.state = state;
}
项目:xmppsupport_v2    文件:ChatStateExtension.java   
/**
 * Default constructor. The argument provided is the state that the
 * extension will represent.
 * 
 * @param state
 *            the state that the extension represents.
 */
public ChatStateExtension(ChatState state) {
    this.state = state;
}
项目:java-bells    文件:ChatStateExtension.java   
/**
 * Default constructor. The argument provided is the state that the extension will represent.
 *
 * @param state the state that the extension represents.
 */
public ChatStateExtension(ChatState state) {
    this.state = state;
}
项目:telegraph    文件:ChatStateExtension.java   
/**
 * Default constructor. The argument provided is the state that the extension will represent.
 *
 * @param state the state that the extension represents.
 */
public ChatStateExtension(ChatState state) {
    this.state = state;
}
项目:NewCommunication-Android    文件:ChatStateExtension.java   
/**
 * Default constructor. The argument provided is the state that the extension will represent.
 *
 * @param state the state that the extension represents.
 */
public ChatStateExtension(ChatState state) {
    this.state = state;
}