|
@@ -90,6 +90,9 @@ public class XmppParser extends BaseSocketAwareParser {
|
90
|
90
|
/** The connection to use. */
|
91
|
91
|
private XMPPConnection connection;
|
92
|
92
|
|
|
93
|
+ /** The state manager for the current connection. */
|
|
94
|
+ private ChatStateManager stateManager;
|
|
95
|
+
|
93
|
96
|
/** A cache of known chats. */
|
94
|
97
|
private final Map<String, Chat> chats = new HashMap<String, Chat>();
|
95
|
98
|
|
|
@@ -451,7 +454,7 @@ public class XmppParser extends BaseSocketAwareParser {
|
451
|
454
|
connection.sendPacket(new Presence(Presence.Type.available, null, priority, Presence.Mode.available));
|
452
|
455
|
connection.getRoster().addRosterListener(new RosterListenerImpl());
|
453
|
456
|
|
454
|
|
- ChatStateManager.getInstance(connection);
|
|
457
|
+ stateManager = ChatStateManager.getInstance(connection);
|
455
|
458
|
|
456
|
459
|
setServerName(connection.getServiceName());
|
457
|
460
|
|
|
@@ -522,6 +525,35 @@ public class XmppParser extends BaseSocketAwareParser {
|
522
|
525
|
AwayState.AWAY, AwayState.HERE, null);
|
523
|
526
|
}
|
524
|
527
|
|
|
528
|
+ /** {@inheritDoc} */
|
|
529
|
+ @Override
|
|
530
|
+ public void setCompositionState(final String host, final CompositionState state) {
|
|
531
|
+ final Chat chat = chats.get(parseHostmask(host)[0]);
|
|
532
|
+
|
|
533
|
+ ChatState newState;
|
|
534
|
+
|
|
535
|
+ switch (state) {
|
|
536
|
+ case ENTERED_TEXT:
|
|
537
|
+ newState = ChatState.paused;
|
|
538
|
+ break;
|
|
539
|
+ case TYPING:
|
|
540
|
+ newState = ChatState.composing;
|
|
541
|
+ break;
|
|
542
|
+ case IDLE:
|
|
543
|
+ default:
|
|
544
|
+ newState = ChatState.active;
|
|
545
|
+ break;
|
|
546
|
+ }
|
|
547
|
+
|
|
548
|
+ if (chat != null && stateManager != null) {
|
|
549
|
+ try {
|
|
550
|
+ stateManager.setCurrentState(newState, chat);
|
|
551
|
+ } catch (XMPPException ex) {
|
|
552
|
+ // Can't set chat state... Oh well?
|
|
553
|
+ }
|
|
554
|
+ }
|
|
555
|
+ }
|
|
556
|
+
|
525
|
557
|
private class ConnectionListenerImpl implements ConnectionListener {
|
526
|
558
|
|
527
|
559
|
/** {@inheritDoc} */
|