|
@@ -28,6 +28,7 @@ import com.dmdirc.actions.wrappers.AliasWrapper;
|
28
|
28
|
import com.dmdirc.commandparser.CommandManager;
|
29
|
29
|
import com.dmdirc.config.ConfigManager;
|
30
|
30
|
import com.dmdirc.config.Identity;
|
|
31
|
+import com.dmdirc.interfaces.AwayStateListener;
|
31
|
32
|
import com.dmdirc.interfaces.InviteListener;
|
32
|
33
|
import com.dmdirc.logger.ErrorLevel;
|
33
|
34
|
import com.dmdirc.logger.Logger;
|
|
@@ -1054,26 +1055,6 @@ public final class Server extends WritableFrameContainer implements Serializable
|
1054
|
1055
|
Integer.valueOf(numeric), tokens);
|
1055
|
1056
|
}
|
1056
|
1057
|
|
1057
|
|
- /**
|
1058
|
|
- * Called when our away state changes.
|
1059
|
|
- *
|
1060
|
|
- * @param currentState The new aray state
|
1061
|
|
- * @param reason Our away reason, if applicable
|
1062
|
|
- */
|
1063
|
|
- public void onAwayState(final boolean currentState, final String reason) {
|
1064
|
|
- if (currentState) {
|
1065
|
|
- awayMessage = reason;
|
1066
|
|
-
|
1067
|
|
- ActionManager.processEvent(CoreActionType.SERVER_AWAY, null, this, awayMessage);
|
1068
|
|
- } else {
|
1069
|
|
- awayMessage = "";
|
1070
|
|
-
|
1071
|
|
- ActionManager.processEvent(CoreActionType.SERVER_BACK, null, this);
|
1072
|
|
- }
|
1073
|
|
-
|
1074
|
|
- window.setAwayIndicator(isAway());
|
1075
|
|
- }
|
1076
|
|
-
|
1077
|
1058
|
/**
|
1078
|
1059
|
* Called when the socket has been closed.
|
1079
|
1060
|
*/
|
|
@@ -1254,5 +1235,45 @@ public final class Server extends WritableFrameContainer implements Serializable
|
1254
|
1235
|
listener.inviteExpired(this, invite);
|
1255
|
1236
|
}
|
1256
|
1237
|
}
|
|
1238
|
+
|
|
1239
|
+ // ----------------------------------------------- AWAY STATE HANDLING -----
|
|
1240
|
+
|
|
1241
|
+ /**
|
|
1242
|
+ * Adds an away state lisener to this server.
|
|
1243
|
+ *
|
|
1244
|
+ * @param listener The listener to be added
|
|
1245
|
+ */
|
|
1246
|
+ public void addAwayStateListener(final AwayStateListener listener) {
|
|
1247
|
+ listeners.add(AwayStateListener.class, listener);
|
|
1248
|
+ }
|
|
1249
|
+
|
|
1250
|
+ /**
|
|
1251
|
+ * Removes an away state lisener from this server.
|
|
1252
|
+ *
|
|
1253
|
+ * @param listener The listener to be removed
|
|
1254
|
+ */
|
|
1255
|
+ public void removeAwayStateListener(final AwayStateListener listener) {
|
|
1256
|
+ listeners.remove(AwayStateListener.class, listener);
|
|
1257
|
+ }
|
|
1258
|
+
|
|
1259
|
+ /**
|
|
1260
|
+ * Updates our away state and fires the relevant listeners.
|
|
1261
|
+ *
|
|
1262
|
+ * @param message The away message to use, or an empty string if we're not
|
|
1263
|
+ * away
|
|
1264
|
+ */
|
|
1265
|
+ public void updateAwayState(final String message) {
|
|
1266
|
+ awayMessage = message;
|
|
1267
|
+
|
|
1268
|
+ if (message.isEmpty()) {
|
|
1269
|
+ for (AwayStateListener listener : listeners.get(AwayStateListener.class)) {
|
|
1270
|
+ listener.onBack();
|
|
1271
|
+ }
|
|
1272
|
+ } else {
|
|
1273
|
+ for (AwayStateListener listener : listeners.get(AwayStateListener.class)) {
|
|
1274
|
+ listener.onAway(message);
|
|
1275
|
+ }
|
|
1276
|
+ }
|
|
1277
|
+ }
|
1257
|
1278
|
|
1258
|
1279
|
}
|