Browse Source

Merge pull request #619 from csmith/tidying

Disable numeric formatting, remove dead code.
pull/620/head
Greg Holmes 8 years ago
parent
commit
dcaf58b0e4
27 changed files with 15 additions and 1205 deletions
  1. 0
    4
      src/com/dmdirc/Channel.java
  2. 2
    5
      src/com/dmdirc/ChannelFactory.java
  3. 0
    2
      src/com/dmdirc/ClientModule.java
  4. 0
    24
      src/com/dmdirc/FrameContainer.java
  5. 1
    4
      src/com/dmdirc/GlobalWindow.java
  6. 0
    3
      src/com/dmdirc/Query.java
  7. 6
    8
      src/com/dmdirc/QueryFactory.java
  8. 0
    3
      src/com/dmdirc/Server.java
  9. 1
    17
      src/com/dmdirc/ServerEventHandler.java
  10. 3
    8
      src/com/dmdirc/ServerFactoryImpl.java
  11. 0
    58
      src/com/dmdirc/ui/messages/sink/AllMessageSink.java
  12. 0
    78
      src/com/dmdirc/ui/messages/sink/ChannelMessageSink.java
  13. 0
    84
      src/com/dmdirc/ui/messages/sink/CommonChannelsMessageSink.java
  14. 0
    83
      src/com/dmdirc/ui/messages/sink/CustomWindowMessageSink.java
  15. 0
    60
      src/com/dmdirc/ui/messages/sink/ForkMessageSink.java
  16. 0
    58
      src/com/dmdirc/ui/messages/sink/FormatMessageSink.java
  17. 0
    68
      src/com/dmdirc/ui/messages/sink/GroupMessageSink.java
  18. 0
    90
      src/com/dmdirc/ui/messages/sink/LastCommandMessageSink.java
  19. 0
    60
      src/com/dmdirc/ui/messages/sink/MessageSink.java
  20. 0
    124
      src/com/dmdirc/ui/messages/sink/MessageSinkManager.java
  21. 0
    110
      src/com/dmdirc/ui/messages/sink/MessagesModule.java
  22. 0
    58
      src/com/dmdirc/ui/messages/sink/NullMessageSink.java
  23. 0
    58
      src/com/dmdirc/ui/messages/sink/SelfMessageSink.java
  24. 0
    58
      src/com/dmdirc/ui/messages/sink/ServerMessageSink.java
  25. 0
    73
      src/com/dmdirc/ui/messages/sink/StatusBarMessageSink.java
  26. 2
    4
      test/com/dmdirc/WritableFrameContainerTest.java
  27. 0
    3
      test/com/dmdirc/harness/TestWritableFrameContainer.java

+ 0
- 4
src/com/dmdirc/Channel.java View File

49
 import com.dmdirc.ui.input.TabCompletionType;
49
 import com.dmdirc.ui.input.TabCompletionType;
50
 import com.dmdirc.ui.messages.BackBufferFactory;
50
 import com.dmdirc.ui.messages.BackBufferFactory;
51
 import com.dmdirc.ui.messages.Styliser;
51
 import com.dmdirc.ui.messages.Styliser;
52
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
53
 import com.dmdirc.util.colours.Colour;
52
 import com.dmdirc.util.colours.Colour;
54
 import com.dmdirc.util.colours.ColourUtils;
53
 import com.dmdirc.util.colours.ColourUtils;
55
 
54
 
101
      * @param newChannelInfo      The parser's channel object that corresponds to this channel
100
      * @param newChannelInfo      The parser's channel object that corresponds to this channel
102
      * @param configMigrator      The config migrator which provides the config for this channel.
101
      * @param configMigrator      The config migrator which provides the config for this channel.
103
      * @param tabCompleterFactory The factory to use to create tab completers.
102
      * @param tabCompleterFactory The factory to use to create tab completers.
104
-     * @param messageSinkManager  The sink manager to use to despatch messages.
105
      */
103
      */
106
     public Channel(
104
     public Channel(
107
             final Connection connection,
105
             final Connection connection,
108
             final ChannelInfo newChannelInfo,
106
             final ChannelInfo newChannelInfo,
109
             final ConfigProviderMigrator configMigrator,
107
             final ConfigProviderMigrator configMigrator,
110
             final TabCompleterFactory tabCompleterFactory,
108
             final TabCompleterFactory tabCompleterFactory,
111
-            final MessageSinkManager messageSinkManager,
112
             final BackBufferFactory backBufferFactory,
109
             final BackBufferFactory backBufferFactory,
113
             final GroupChatUserManager groupChatUserManager) {
110
             final GroupChatUserManager groupChatUserManager) {
114
         super(connection.getWindowModel(), "channel-inactive",
111
         super(connection.getWindowModel(), "channel-inactive",
119
                 tabCompleterFactory.getTabCompleter(connection.getWindowModel().getTabCompleter(),
116
                 tabCompleterFactory.getTabCompleter(connection.getWindowModel().getTabCompleter(),
120
                         configMigrator.getConfigProvider(), CommandType.TYPE_CHANNEL,
117
                         configMigrator.getConfigProvider(), CommandType.TYPE_CHANNEL,
121
                         CommandType.TYPE_CHAT),
118
                         CommandType.TYPE_CHAT),
122
-                messageSinkManager,
123
                 connection.getWindowModel().getEventBus(),
119
                 connection.getWindowModel().getEventBus(),
124
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
120
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
125
                         WindowComponent.INPUTFIELD.getIdentifier(),
121
                         WindowComponent.INPUTFIELD.getIdentifier(),

+ 2
- 5
src/com/dmdirc/ChannelFactory.java View File

31
 import com.dmdirc.ui.WindowManager;
31
 import com.dmdirc.ui.WindowManager;
32
 import com.dmdirc.ui.input.TabCompleterFactory;
32
 import com.dmdirc.ui.input.TabCompleterFactory;
33
 import com.dmdirc.ui.messages.BackBufferFactory;
33
 import com.dmdirc.ui.messages.BackBufferFactory;
34
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
35
 
34
 
36
 import javax.inject.Inject;
35
 import javax.inject.Inject;
37
 import javax.inject.Singleton;
36
 import javax.inject.Singleton;
44
 
43
 
45
     private final TabCompleterFactory tabCompleterFactory;
44
     private final TabCompleterFactory tabCompleterFactory;
46
     private final CommandController commandController;
45
     private final CommandController commandController;
47
-    private final MessageSinkManager messageSinkManager;
48
     private final DMDircMBassador eventBus;
46
     private final DMDircMBassador eventBus;
49
     private final BackBufferFactory backBufferFactory;
47
     private final BackBufferFactory backBufferFactory;
50
     private final GroupChatUserManager groupChatUserManager;
48
     private final GroupChatUserManager groupChatUserManager;
52
 
50
 
53
     @Inject
51
     @Inject
54
     public ChannelFactory(final TabCompleterFactory tabCompleterFactory,
52
     public ChannelFactory(final TabCompleterFactory tabCompleterFactory,
55
-            final CommandController commandController, final MessageSinkManager messageSinkManager,
53
+            final CommandController commandController,
56
             final DMDircMBassador eventBus, final BackBufferFactory backBufferFactory,
54
             final DMDircMBassador eventBus, final BackBufferFactory backBufferFactory,
57
             final GroupChatUserManager groupChatUserManager, final WindowManager windowManager) {
55
             final GroupChatUserManager groupChatUserManager, final WindowManager windowManager) {
58
         this.tabCompleterFactory = tabCompleterFactory;
56
         this.tabCompleterFactory = tabCompleterFactory;
59
         this.commandController = commandController;
57
         this.commandController = commandController;
60
-        this.messageSinkManager = messageSinkManager;
61
         this.eventBus = eventBus;
58
         this.eventBus = eventBus;
62
         this.backBufferFactory = backBufferFactory;
59
         this.backBufferFactory = backBufferFactory;
63
         this.groupChatUserManager = groupChatUserManager;
60
         this.groupChatUserManager = groupChatUserManager;
68
             final ChannelInfo channelInfo,
65
             final ChannelInfo channelInfo,
69
             final ConfigProviderMigrator configMigrator) {
66
             final ConfigProviderMigrator configMigrator) {
70
         final Channel channel = new Channel(connection, channelInfo, configMigrator,
67
         final Channel channel = new Channel(connection, channelInfo, configMigrator,
71
-                tabCompleterFactory, messageSinkManager, backBufferFactory, groupChatUserManager);
68
+                tabCompleterFactory, backBufferFactory, groupChatUserManager);
72
         channel.setCommandParser(new ChannelCommandParser(connection.getWindowModel(),
69
         channel.setCommandParser(new ChannelCommandParser(connection.getWindowModel(),
73
                 commandController, eventBus, channel));
70
                 commandController, eventBus, channel));
74
         windowManager.addWindow(connection.getWindowModel(), channel);
71
         windowManager.addWindow(connection.getWindowModel(), channel);

+ 0
- 2
src/com/dmdirc/ClientModule.java View File

42
 import com.dmdirc.ui.messages.ColourManager;
42
 import com.dmdirc.ui.messages.ColourManager;
43
 import com.dmdirc.ui.messages.ColourManagerFactory;
43
 import com.dmdirc.ui.messages.ColourManagerFactory;
44
 import com.dmdirc.ui.messages.UiMessagesModule;
44
 import com.dmdirc.ui.messages.UiMessagesModule;
45
-import com.dmdirc.ui.messages.sink.MessagesModule;
46
 import com.dmdirc.ui.themes.ThemeManager;
45
 import com.dmdirc.ui.themes.ThemeManager;
47
 import com.dmdirc.updater.UpdaterModule;
46
 import com.dmdirc.updater.UpdaterModule;
48
 import com.dmdirc.util.LoggingExecutorService;
47
 import com.dmdirc.util.LoggingExecutorService;
71
                 CommandLineOptionsModule.class,
70
                 CommandLineOptionsModule.class,
72
                 CommandModule.class,
71
                 CommandModule.class,
73
                 ConfigModule.class,
72
                 ConfigModule.class,
74
-                MessagesModule.class,
75
                 PluginModule.class,
73
                 PluginModule.class,
76
                 ProfilesModule.class,
74
                 ProfilesModule.class,
77
                 UiMessagesModule.class,
75
                 UiMessagesModule.class,

+ 0
- 24
src/com/dmdirc/FrameContainer.java View File

40
 import com.dmdirc.ui.messages.BackBufferFactory;
40
 import com.dmdirc.ui.messages.BackBufferFactory;
41
 import com.dmdirc.ui.messages.Formatter;
41
 import com.dmdirc.ui.messages.Formatter;
42
 import com.dmdirc.ui.messages.UnreadStatusManager;
42
 import com.dmdirc.ui.messages.UnreadStatusManager;
43
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
44
 import com.dmdirc.util.ChildEventBusManager;
43
 import com.dmdirc.util.ChildEventBusManager;
45
 import com.dmdirc.util.collections.ListenerList;
44
 import com.dmdirc.util.collections.ListenerList;
46
 
45
 
95
     /** The back buffer for this container. */
94
     /** The back buffer for this container. */
96
     private BackBuffer backBuffer;
95
     private BackBuffer backBuffer;
97
 
96
 
98
-    /**
99
-     * The manager to use to dispatch messages to sinks.
100
-     * <p>
101
-     * Only defined if this container is {@link #writable}.
102
-     */
103
-    private final Optional<MessageSinkManager> messageSinkManager;
104
     /**
97
     /**
105
      * The tab completer to use.
98
      * The tab completer to use.
106
      * <p>
99
      * <p>
134
         this.components = new HashSet<>(components);
127
         this.components = new HashSet<>(components);
135
         this.writable = false;
128
         this.writable = false;
136
         this.tabCompleter = Optional.empty();
129
         this.tabCompleter = Optional.empty();
137
-        this.messageSinkManager = Optional.empty();
138
         this.backBufferFactory = backBufferFactory;
130
         this.backBufferFactory = backBufferFactory;
139
 
131
 
140
         eventBusManager = new ChildEventBusManager(eventBus);
132
         eventBusManager = new ChildEventBusManager(eventBus);
158
             final AggregateConfigProvider config,
150
             final AggregateConfigProvider config,
159
             final BackBufferFactory backBufferFactory,
151
             final BackBufferFactory backBufferFactory,
160
             final TabCompleter tabCompleter,
152
             final TabCompleter tabCompleter,
161
-            final MessageSinkManager messageSinkManager,
162
             final DMDircMBassador eventBus,
153
             final DMDircMBassador eventBus,
163
             final Collection<String> components) {
154
             final Collection<String> components) {
164
         this.parent = Optional.ofNullable(parent);
155
         this.parent = Optional.ofNullable(parent);
168
         this.components = new HashSet<>(components);
159
         this.components = new HashSet<>(components);
169
         this.writable = true;
160
         this.writable = true;
170
         this.tabCompleter = Optional.of(tabCompleter);
161
         this.tabCompleter = Optional.of(tabCompleter);
171
-        this.messageSinkManager = Optional.of(messageSinkManager);
172
         this.backBufferFactory = backBufferFactory;
162
         this.backBufferFactory = backBufferFactory;
173
 
163
 
174
         eventBusManager = new ChildEventBusManager(eventBus);
164
         eventBusManager = new ChildEventBusManager(eventBus);
406
         return lines;
396
         return lines;
407
     }
397
     }
408
 
398
 
409
-    /**
410
-     * Handles general server notifications (i.e., ones not tied to a specific window). The user can
411
-     * select where the notifications should go in their config.
412
-     *
413
-     * @param date        The date/time at which the event occurred
414
-     * @param messageType The type of message that is being sent
415
-     * @param args        The arguments for the message
416
-     */
417
-    @Deprecated
418
-    public void handleNotification(final Date date, final String messageType, final Object... args) {
419
-        checkState(writable);
420
-        messageSinkManager.get().dispatchMessage(this, date, messageType, args);
421
-    }
422
-
423
     /**
399
     /**
424
      * Sets the composition state for the local user for this chat.
400
      * Sets the composition state for the local user for this chat.
425
      *
401
      *

+ 1
- 4
src/com/dmdirc/GlobalWindow.java View File

33
 import com.dmdirc.ui.core.components.WindowComponent;
33
 import com.dmdirc.ui.core.components.WindowComponent;
34
 import com.dmdirc.ui.input.TabCompleterFactory;
34
 import com.dmdirc.ui.input.TabCompleterFactory;
35
 import com.dmdirc.ui.messages.BackBufferFactory;
35
 import com.dmdirc.ui.messages.BackBufferFactory;
36
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
37
 
36
 
38
 import java.util.Arrays;
37
 import java.util.Arrays;
39
 import java.util.Optional;
38
 import java.util.Optional;
54
     @Inject
53
     @Inject
55
     public GlobalWindow(@GlobalConfig final AggregateConfigProvider config,
54
     public GlobalWindow(@GlobalConfig final AggregateConfigProvider config,
56
             final GlobalCommandParser parser, final TabCompleterFactory tabCompleterFactory,
55
             final GlobalCommandParser parser, final TabCompleterFactory tabCompleterFactory,
57
-            final MessageSinkManager messageSinkManager,
58
             final DMDircMBassador eventBus, final BackBufferFactory backBufferFactory) {
56
             final DMDircMBassador eventBus, final BackBufferFactory backBufferFactory) {
59
         super(null, "icon", "Global", "(Global)", config, backBufferFactory,
57
         super(null, "icon", "Global", "(Global)", config, backBufferFactory,
60
-                tabCompleterFactory.getTabCompleter(config, CommandType.TYPE_GLOBAL),
61
-                messageSinkManager, eventBus,
58
+                tabCompleterFactory.getTabCompleter(config, CommandType.TYPE_GLOBAL), eventBus,
62
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
59
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
63
                         WindowComponent.INPUTFIELD.getIdentifier()));
60
                         WindowComponent.INPUTFIELD.getIdentifier()));
64
         initBackBuffer();
61
         initBackBuffer();

+ 0
- 3
src/com/dmdirc/Query.java View File

47
 import com.dmdirc.ui.core.components.WindowComponent;
47
 import com.dmdirc.ui.core.components.WindowComponent;
48
 import com.dmdirc.ui.input.TabCompleterFactory;
48
 import com.dmdirc.ui.input.TabCompleterFactory;
49
 import com.dmdirc.ui.messages.BackBufferFactory;
49
 import com.dmdirc.ui.messages.BackBufferFactory;
50
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
51
 
50
 
52
 import java.awt.Toolkit;
51
 import java.awt.Toolkit;
53
 import java.util.Arrays;
52
 import java.util.Arrays;
71
             final Connection connection,
70
             final Connection connection,
72
             final User user,
71
             final User user,
73
             final TabCompleterFactory tabCompleterFactory,
72
             final TabCompleterFactory tabCompleterFactory,
74
-            final MessageSinkManager messageSinkManager,
75
             final BackBufferFactory backBufferFactory) {
73
             final BackBufferFactory backBufferFactory) {
76
         super(connection.getWindowModel(), "query",
74
         super(connection.getWindowModel(), "query",
77
                 user.getNickname(),
75
                 user.getNickname(),
81
                 tabCompleterFactory.getTabCompleter(connection.getWindowModel().getTabCompleter(),
79
                 tabCompleterFactory.getTabCompleter(connection.getWindowModel().getTabCompleter(),
82
                         connection.getWindowModel().getConfigManager(),
80
                         connection.getWindowModel().getConfigManager(),
83
                         CommandType.TYPE_QUERY, CommandType.TYPE_CHAT),
81
                         CommandType.TYPE_QUERY, CommandType.TYPE_CHAT),
84
-                messageSinkManager,
85
                 connection.getWindowModel().getEventBus(),
82
                 connection.getWindowModel().getEventBus(),
86
                 Arrays.asList(
83
                 Arrays.asList(
87
                         WindowComponent.TEXTAREA.getIdentifier(),
84
                         WindowComponent.TEXTAREA.getIdentifier(),

+ 6
- 8
src/com/dmdirc/QueryFactory.java View File

30
 import com.dmdirc.ui.WindowManager;
30
 import com.dmdirc.ui.WindowManager;
31
 import com.dmdirc.ui.input.TabCompleterFactory;
31
 import com.dmdirc.ui.input.TabCompleterFactory;
32
 import com.dmdirc.ui.messages.BackBufferFactory;
32
 import com.dmdirc.ui.messages.BackBufferFactory;
33
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
34
 
33
 
35
 import javax.inject.Inject;
34
 import javax.inject.Inject;
36
 import javax.inject.Singleton;
35
 import javax.inject.Singleton;
43
 
42
 
44
     private final TabCompleterFactory tabCompleterFactory;
43
     private final TabCompleterFactory tabCompleterFactory;
45
     private final CommandController commandController;
44
     private final CommandController commandController;
46
-    private final MessageSinkManager messageSinkManager;
47
     private final BackBufferFactory backBufferFactory;
45
     private final BackBufferFactory backBufferFactory;
48
     private final WindowManager windowManager;
46
     private final WindowManager windowManager;
49
 
47
 
50
     @Inject
48
     @Inject
51
-    public QueryFactory(final TabCompleterFactory tabCompleterFactory,
52
-            final CommandController commandController, final MessageSinkManager messageSinkManager,
53
-            final BackBufferFactory backBufferFactory, final WindowManager windowManager) {
49
+    public QueryFactory(
50
+            final TabCompleterFactory tabCompleterFactory,
51
+            final CommandController commandController,
52
+            final BackBufferFactory backBufferFactory,
53
+            final WindowManager windowManager) {
54
         this.tabCompleterFactory = tabCompleterFactory;
54
         this.tabCompleterFactory = tabCompleterFactory;
55
         this.commandController = commandController;
55
         this.commandController = commandController;
56
-        this.messageSinkManager = messageSinkManager;
57
         this.backBufferFactory = backBufferFactory;
56
         this.backBufferFactory = backBufferFactory;
58
         this.windowManager = windowManager;
57
         this.windowManager = windowManager;
59
     }
58
     }
60
 
59
 
61
     public Query getQuery(final Connection connection, final User user) {
60
     public Query getQuery(final Connection connection, final User user) {
62
-        final Query query = new Query(connection, user, tabCompleterFactory,
63
-                messageSinkManager, backBufferFactory);
61
+        final Query query = new Query(connection, user, tabCompleterFactory, backBufferFactory);
64
         query.setCommandParser(new QueryCommandParser(connection.getWindowModel(),
62
         query.setCommandParser(new QueryCommandParser(connection.getWindowModel(),
65
                 commandController, connection.getWindowModel().getEventBus(), query));
63
                 commandController, connection.getWindowModel().getEventBus(), query));
66
         windowManager.addWindow(connection.getWindowModel(), query);
64
         windowManager.addWindow(connection.getWindowModel(), query);

+ 0
- 3
src/com/dmdirc/Server.java View File

57
 import com.dmdirc.ui.messages.ColourManager;
57
 import com.dmdirc.ui.messages.ColourManager;
58
 import com.dmdirc.ui.messages.Formatter;
58
 import com.dmdirc.ui.messages.Formatter;
59
 import com.dmdirc.ui.messages.HighlightManager;
59
 import com.dmdirc.ui.messages.HighlightManager;
60
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
61
 
60
 
62
 import java.net.NoRouteToHostException;
61
 import java.net.NoRouteToHostException;
63
 import java.net.SocketException;
62
 import java.net.SocketException;
178
             final ParserFactory parserFactory,
177
             final ParserFactory parserFactory,
179
             final TabCompleterFactory tabCompleterFactory,
178
             final TabCompleterFactory tabCompleterFactory,
180
             final IdentityFactory identityFactory,
179
             final IdentityFactory identityFactory,
181
-            final MessageSinkManager messageSinkManager,
182
             final QueryFactory queryFactory,
180
             final QueryFactory queryFactory,
183
             final DMDircMBassador eventBus,
181
             final DMDircMBassador eventBus,
184
             final MessageEncoderFactory messageEncoderFactory,
182
             final MessageEncoderFactory messageEncoderFactory,
196
                 backBufferFactory,
194
                 backBufferFactory,
197
                 tabCompleterFactory.getTabCompleter(configMigrator.getConfigProvider(),
195
                 tabCompleterFactory.getTabCompleter(configMigrator.getConfigProvider(),
198
                         CommandType.TYPE_SERVER, CommandType.TYPE_GLOBAL),
196
                         CommandType.TYPE_SERVER, CommandType.TYPE_GLOBAL),
199
-                messageSinkManager,
200
                 eventBus,
197
                 eventBus,
201
                 Arrays.asList(
198
                 Arrays.asList(
202
                         WindowComponent.TEXTAREA.getIdentifier(),
199
                         WindowComponent.TEXTAREA.getIdentifier(),

+ 1
- 17
src/com/dmdirc/ServerEventHandler.java View File

86
 import com.dmdirc.parser.events.WallopEvent;
86
 import com.dmdirc.parser.events.WallopEvent;
87
 import com.dmdirc.parser.events.WalluserEvent;
87
 import com.dmdirc.parser.events.WalluserEvent;
88
 import com.dmdirc.ui.StatusMessage;
88
 import com.dmdirc.ui.StatusMessage;
89
-import com.dmdirc.util.EventUtils;
90
-
91
-import com.google.common.base.Strings;
92
 
89
 
93
 import java.util.List;
90
 import java.util.List;
94
 import java.util.Optional;
91
 import java.util.Optional;
245
 
242
 
246
     @Handler
243
     @Handler
247
     public void onNumeric(final NumericEvent event) {
244
     public void onNumeric(final NumericEvent event) {
248
-        final String sansIrcd = "numeric_" + Strings
249
-                .padStart(String.valueOf(event.getNumeric()), 3, '0');
250
-        String target = "";
251
-
252
-        if (owner.getConfigManager().hasOptionString("formatter", sansIrcd)) {
253
-            target = sansIrcd;
254
-        } else if (owner.getConfigManager().hasOptionString("formatter", "numeric_unknown")) {
255
-            target = "numeric_unknown";
256
-        }
257
-
258
-        final ServerNumericEvent coreEvent = new ServerNumericEvent(owner, event.getNumeric(),
259
-                event.getToken());
260
-        final String format = EventUtils.postDisplayable(eventBus, coreEvent, target);
261
-        owner.handleNotification(event.getDate(), format, (Object[]) event.getToken());
245
+        eventBus.publishAsync(new ServerNumericEvent(owner, event.getNumeric(), event.getToken()));
262
     }
246
     }
263
 
247
 
264
     @Handler
248
     @Handler

+ 3
- 8
src/com/dmdirc/ServerFactoryImpl.java View File

30
 import com.dmdirc.interfaces.config.IdentityFactory;
30
 import com.dmdirc.interfaces.config.IdentityFactory;
31
 import com.dmdirc.ui.input.TabCompleterFactory;
31
 import com.dmdirc.ui.input.TabCompleterFactory;
32
 import com.dmdirc.ui.messages.BackBufferFactory;
32
 import com.dmdirc.ui.messages.BackBufferFactory;
33
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
34
 
33
 
35
 import java.net.URI;
34
 import java.net.URI;
36
 import java.util.concurrent.ScheduledExecutorService;
35
 import java.util.concurrent.ScheduledExecutorService;
48
     private final ParserFactory parserFactory;
47
     private final ParserFactory parserFactory;
49
     private final TabCompleterFactory tabCompleterFactory;
48
     private final TabCompleterFactory tabCompleterFactory;
50
     private final IdentityFactory identityFactory;
49
     private final IdentityFactory identityFactory;
51
-    private final MessageSinkManager messageSinkManager;
52
     private final Provider<QueryFactory> queryFactory;
50
     private final Provider<QueryFactory> queryFactory;
53
     private final Provider<CommandController> commandController;
51
     private final Provider<CommandController> commandController;
54
     private final DMDircMBassador eventBus;
52
     private final DMDircMBassador eventBus;
63
             final ParserFactory parserFactory,
61
             final ParserFactory parserFactory,
64
             final TabCompleterFactory tabCompleterFactory,
62
             final TabCompleterFactory tabCompleterFactory,
65
             final IdentityFactory identityFactory,
63
             final IdentityFactory identityFactory,
66
-            final MessageSinkManager messageSinkManager,
67
             final Provider<QueryFactory> queryFactory,
64
             final Provider<QueryFactory> queryFactory,
68
             final Provider<CommandController> commandController,
65
             final Provider<CommandController> commandController,
69
             final DMDircMBassador eventBus,
66
             final DMDircMBassador eventBus,
75
         this.parserFactory = parserFactory;
72
         this.parserFactory = parserFactory;
76
         this.tabCompleterFactory = tabCompleterFactory;
73
         this.tabCompleterFactory = tabCompleterFactory;
77
         this.identityFactory = identityFactory;
74
         this.identityFactory = identityFactory;
78
-        this.messageSinkManager = messageSinkManager;
79
         this.queryFactory = queryFactory;
75
         this.queryFactory = queryFactory;
80
         this.commandController = commandController;
76
         this.commandController = commandController;
81
         this.eventBus = eventBus;
77
         this.eventBus = eventBus;
92
             final URI uri,
88
             final URI uri,
93
             final Profile profile) {
89
             final Profile profile) {
94
         final Server server = new Server(configMigrator, parserFactory,
90
         final Server server = new Server(configMigrator, parserFactory,
95
-                tabCompleterFactory, identityFactory, messageSinkManager,
96
-                queryFactory.get(), eventBus, messageEncoderFactory, userSettings,
97
-                groupChatManagerFactory, executorService, uri, profile, backBufferFactory,
98
-                userManager);
91
+                tabCompleterFactory, identityFactory, queryFactory.get(), eventBus,
92
+                messageEncoderFactory, userSettings, groupChatManagerFactory, executorService,
93
+                uri, profile, backBufferFactory, userManager);
99
         server.setCommandParser(new ServerCommandParser(server.getConfigManager(),
94
         server.setCommandParser(new ServerCommandParser(server.getConfigManager(),
100
                 commandController.get(), eventBus, server));
95
                 commandController.get(), eventBus, server));
101
         return server;
96
         return server;

+ 0
- 58
src/com/dmdirc/ui/messages/sink/AllMessageSink.java View File

1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.ui.messages.sink;
24
-
25
-import com.dmdirc.interfaces.WindowModel;
26
-
27
-import java.util.Date;
28
-import java.util.regex.Pattern;
29
-
30
-import javax.inject.Inject;
31
-
32
-/**
33
- * A message sink which adds the message to all of the container's server's children.
34
- */
35
-@Deprecated
36
-public class AllMessageSink implements MessageSink {
37
-
38
-    /** The pattern to use to match this sink. */
39
-    private static final Pattern PATTERN = Pattern.compile("all");
40
-
41
-    @Inject
42
-    public AllMessageSink() {
43
-    }
44
-
45
-    @Override
46
-    public Pattern getPattern() {
47
-        return PATTERN;
48
-    }
49
-
50
-    @Override
51
-    public void handleMessage(final MessageSinkManager dispatcher,
52
-            final WindowModel source,
53
-            final String[] patternMatches, final Date date,
54
-            final String messageType, final Object... args) {
55
-        source.getConnection().get().addLineToAll(messageType, date, args);
56
-    }
57
-
58
-}

+ 0
- 78
src/com/dmdirc/ui/messages/sink/ChannelMessageSink.java View File

1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.ui.messages.sink;
24
-
25
-import com.dmdirc.interfaces.Connection;
26
-import com.dmdirc.interfaces.GroupChat;
27
-import com.dmdirc.interfaces.WindowModel;
28
-
29
-import java.util.Date;
30
-import java.util.Optional;
31
-import java.util.regex.Pattern;
32
-
33
-import javax.inject.Inject;
34
-
35
-/**
36
- * A message sink which adds the message to a named channel. An optional fallback may be specified
37
- * for use if the channel does not exist. If no fallback is specified and the channel does not
38
- * exist, the message is dispatched to the source.
39
- */
40
-@Deprecated
41
-public class ChannelMessageSink implements MessageSink {
42
-
43
-    /** The pattern to use to match this sink. */
44
-    private static final Pattern PATTERN = Pattern.compile("channel:(.*?)(?:\\s(.*))?");
45
-
46
-    @Inject
47
-    public ChannelMessageSink() {
48
-    }
49
-
50
-    @Override
51
-    public Pattern getPattern() {
52
-        return PATTERN;
53
-    }
54
-
55
-    @Override
56
-    public void handleMessage(final MessageSinkManager dispatcher,
57
-            final WindowModel source,
58
-            final String[] patternMatches, final Date date,
59
-            final String messageType, final Object... args) {
60
-        final String channelName = String.format(patternMatches[0], args);
61
-        final Connection connection = source.getConnection().get();
62
-        final Optional<GroupChat> channel = connection.getGroupChatManager()
63
-                .getChannel(channelName);
64
-
65
-        if (channel.isPresent()) {
66
-            channel.get().getWindowModel().addLine(messageType, date, args);
67
-        } else {
68
-            if (patternMatches[1] == null) {
69
-                // No fallback specified
70
-                source.addLine(messageType, date, args);
71
-            } else {
72
-                // They specified a fallback
73
-                dispatcher.dispatchMessage(source, date, messageType, patternMatches[1], args);
74
-            }
75
-        }
76
-    }
77
-
78
-}

+ 0
- 84
src/com/dmdirc/ui/messages/sink/CommonChannelsMessageSink.java View File

1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.ui.messages.sink;
24
-
25
-import com.dmdirc.interfaces.Connection;
26
-import com.dmdirc.interfaces.GroupChat;
27
-import com.dmdirc.interfaces.User;
28
-import com.dmdirc.interfaces.WindowModel;
29
-
30
-import java.util.Date;
31
-import java.util.regex.Pattern;
32
-
33
-import javax.inject.Inject;
34
-
35
-/**
36
- * A message sink which adds the message to all channels the local user has in common with a
37
- * specified remote user. An optional fallback may be specified for use if there are no common
38
- * channels with the user. If no fallback is specified and there are no common channels, the message
39
- * is dispatched to the source.
40
- */
41
-@Deprecated
42
-public class CommonChannelsMessageSink implements MessageSink {
43
-
44
-    /** The pattern to use to match this sink. */
45
-    private static final Pattern PATTERN = Pattern.compile("comchans:(.*?)(?:\\s(.*))?");
46
-
47
-    @Inject
48
-    public CommonChannelsMessageSink() {
49
-    }
50
-
51
-    @Override
52
-    public Pattern getPattern() {
53
-        return PATTERN;
54
-    }
55
-
56
-    @Override
57
-    public void handleMessage(final MessageSinkManager dispatcher,
58
-            final WindowModel source,
59
-            final String[] patternMatches, final Date date,
60
-            final String messageType, final Object... args) {
61
-        final String username = String.format(patternMatches[0], args);
62
-        final Connection connection = source.getConnection().get();
63
-        final User user = connection.getUser(username);
64
-        boolean found = false;
65
-
66
-        for (GroupChat channel : connection.getGroupChatManager().getChannels()) {
67
-            if (channel.getUser(user).isPresent()) {
68
-                channel.getWindowModel().addLine(messageType, date, args);
69
-                found = true;
70
-            }
71
-        }
72
-
73
-        if (!found) {
74
-            if (patternMatches[1] == null) {
75
-                // No fallback specified
76
-                source.addLine(messageType, date, args);
77
-            } else {
78
-                // They specified a fallback
79
-                dispatcher.dispatchMessage(source, date, messageType, patternMatches[1], args);
80
-            }
81
-        }
82
-    }
83
-
84
-}

+ 0
- 83
src/com/dmdirc/ui/messages/sink/CustomWindowMessageSink.java View File

1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.ui.messages.sink;
24
-
25
-import com.dmdirc.CustomWindow;
26
-import com.dmdirc.interfaces.WindowModel;
27
-import com.dmdirc.ui.WindowManager;
28
-import com.dmdirc.ui.messages.BackBufferFactory;
29
-
30
-import java.util.Date;
31
-import java.util.regex.Pattern;
32
-
33
-import javax.inject.Inject;
34
-
35
-/**
36
- * A message sink which adds the message to a custom window, creating it if necessary.
37
- */
38
-@Deprecated
39
-public class CustomWindowMessageSink implements MessageSink {
40
-
41
-    /** The pattern to use to match this sink. */
42
-    private static final Pattern PATTERN = Pattern.compile("window:(.*)");
43
-    /** Window management. */
44
-    private final WindowManager windowManager;
45
-    /** Back buffer Factory. */
46
-    private final BackBufferFactory backBufferFactory;
47
-
48
-    /**
49
-     * Creates a new custom window message sink.
50
-     */
51
-    @Inject
52
-    public CustomWindowMessageSink(
53
-            final WindowManager windowManager,
54
-            final BackBufferFactory backBufferFactory) {
55
-        this.windowManager = windowManager;
56
-        this.backBufferFactory = backBufferFactory;
57
-    }
58
-
59
-    @Override
60
-    public Pattern getPattern() {
61
-        return PATTERN;
62
-    }
63
-
64
-    @Override
65
-    public void handleMessage(final MessageSinkManager dispatcher,
66
-            final WindowModel source,
67
-            final String[] patternMatches, final Date date,
68
-            final String messageType, final Object... args) {
69
-        final WindowModel connectionContainer =
70
-                source.getConnection().get().getWindowModel();
71
-        WindowModel targetWindow = windowManager
72
-                .findCustomWindow(connectionContainer, patternMatches[0]);
73
-
74
-        if (targetWindow == null) {
75
-            targetWindow = new CustomWindow(patternMatches[0], patternMatches[0],
76
-                    connectionContainer, backBufferFactory);
77
-            windowManager.addWindow(connectionContainer, targetWindow);
78
-        }
79
-
80
-        targetWindow.addLine(messageType, date, args);
81
-    }
82
-
83
-}

+ 0
- 60
src/com/dmdirc/ui/messages/sink/ForkMessageSink.java View File

1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.ui.messages.sink;
24
-
25
-import com.dmdirc.interfaces.WindowModel;
26
-
27
-import java.util.Date;
28
-import java.util.regex.Pattern;
29
-
30
-import javax.inject.Inject;
31
-
32
-/**
33
- * A message sink which allows the message to be forked into multiple other sinks.
34
- */
35
-@Deprecated
36
-public class ForkMessageSink implements MessageSink {
37
-
38
-    /** The pattern to use to match this sink. */
39
-    private static final Pattern PATTERN = Pattern.compile("fork:(.*)");
40
-
41
-    @Inject
42
-    public ForkMessageSink() {
43
-    }
44
-
45
-    @Override
46
-    public Pattern getPattern() {
47
-        return PATTERN;
48
-    }
49
-
50
-    @Override
51
-    public void handleMessage(final MessageSinkManager dispatcher,
52
-            final WindowModel source,
53
-            final String[] patternMatches, final Date date,
54
-            final String messageType, final Object... args) {
55
-        for (String target : patternMatches[0].split("\\|")) {
56
-            dispatcher.dispatchMessage(source, date, target, args);
57
-        }
58
-    }
59
-
60
-}

+ 0
- 58
src/com/dmdirc/ui/messages/sink/FormatMessageSink.java View File

1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.ui.messages.sink;
24
-
25
-import com.dmdirc.interfaces.WindowModel;
26
-
27
-import java.util.Date;
28
-import java.util.regex.Pattern;
29
-
30
-import javax.inject.Inject;
31
-
32
-/**
33
- * A message sink which changes the format of the message and then re-dispatches it.
34
- */
35
-@Deprecated
36
-public class FormatMessageSink implements MessageSink {
37
-
38
-    /** The pattern to use to match this sink. */
39
-    private static final Pattern PATTERN = Pattern.compile("format:(.*?):(.*)");
40
-
41
-    @Inject
42
-    public FormatMessageSink() {
43
-    }
44
-
45
-    @Override
46
-    public Pattern getPattern() {
47
-        return PATTERN;
48
-    }
49
-
50
-    @Override
51
-    public void handleMessage(final MessageSinkManager dispatcher,
52
-            final WindowModel source,
53
-            final String[] patternMatches, final Date date,
54
-            final String messageType, final Object... args) {
55
-        dispatcher.dispatchMessage(source, date, patternMatches[0], patternMatches[1], args);
56
-    }
57
-
58
-}

+ 0
- 68
src/com/dmdirc/ui/messages/sink/GroupMessageSink.java View File

1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.ui.messages.sink;
24
-
25
-import com.dmdirc.interfaces.WindowModel;
26
-
27
-import java.util.Date;
28
-import java.util.regex.Pattern;
29
-
30
-import javax.inject.Inject;
31
-
32
-/**
33
- * A message sink which changes the sink to the value of a named configuration setting to allow
34
- * grouping of sinks.
35
- */
36
-@Deprecated
37
-public class GroupMessageSink implements MessageSink {
38
-
39
-    /** The pattern to use to match this sink. */
40
-    private static final Pattern PATTERN = Pattern.compile("group:(.*)");
41
-
42
-    @Inject
43
-    public GroupMessageSink() {
44
-    }
45
-
46
-    @Override
47
-    public Pattern getPattern() {
48
-        return PATTERN;
49
-    }
50
-
51
-    @Override
52
-    public void handleMessage(final MessageSinkManager dispatcher,
53
-            final WindowModel source,
54
-            final String[] patternMatches, final Date date,
55
-            final String messageType, final Object... args) {
56
-        final String target;
57
-        if (source.getConfigManager().hasOptionString(MessageSinkManager.CONFIG_DOMAIN,
58
-                patternMatches[0])) {
59
-            target = source.getConfigManager().getOption(MessageSinkManager.CONFIG_DOMAIN,
60
-                    patternMatches[0]);
61
-        } else {
62
-            target = MessageSinkManager.DEFAULT_SINK;
63
-        }
64
-
65
-        dispatcher.dispatchMessage(source, date, messageType, target, args);
66
-    }
67
-
68
-}

+ 0
- 90
src/com/dmdirc/ui/messages/sink/LastCommandMessageSink.java View File

1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.ui.messages.sink;
24
-
25
-import com.dmdirc.interfaces.WindowModel;
26
-
27
-import java.util.ArrayList;
28
-import java.util.Collection;
29
-import java.util.Date;
30
-import java.util.regex.Pattern;
31
-
32
-import javax.inject.Inject;
33
-
34
-/**
35
- * A message sink which adds the message to the window where a command matching the provided regex
36
- * was most recently executed. If no such window is found, falls back to the source.
37
- */
38
-@Deprecated
39
-public class LastCommandMessageSink implements MessageSink {
40
-
41
-    /** The pattern to use to match this sink. */
42
-    private static final Pattern PATTERN = Pattern.compile("lastcommand:(.*)");
43
-
44
-    @Inject
45
-    public LastCommandMessageSink() {
46
-    }
47
-
48
-    @Override
49
-    public Pattern getPattern() {
50
-        return PATTERN;
51
-    }
52
-
53
-    @Override
54
-    public void handleMessage(final MessageSinkManager dispatcher,
55
-            final WindowModel source,
56
-            final String[] patternMatches, final Date date,
57
-            final String messageType, final Object... args) {
58
-        final Object[] escapedargs = new Object[args.length];
59
-
60
-        for (int i = 0; i < args.length; i++) {
61
-            escapedargs[i] = "\\Q" + args[i] + "\\E";
62
-        }
63
-
64
-        final String command = String.format(patternMatches[0], escapedargs);
65
-
66
-        WindowModel best = source;
67
-
68
-        final Collection<WindowModel> containers = new ArrayList<>();
69
-
70
-        final WindowModel connectionContainer = source.getConnection().get().getWindowModel();
71
-        containers.add(connectionContainer);
72
-        containers.addAll(connectionContainer.getChildren());
73
-
74
-        long besttime = 0;
75
-        for (WindowModel container : containers) {
76
-            if (!container.isWritable()) {
77
-                continue;
78
-            }
79
-
80
-            final long time = container.getCommandParser().getCommandTime(command);
81
-            if (time > besttime) {
82
-                besttime = time;
83
-                best = container;
84
-            }
85
-        }
86
-
87
-        best.addLine(messageType, date, args);
88
-    }
89
-
90
-}

+ 0
- 60
src/com/dmdirc/ui/messages/sink/MessageSink.java View File

1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.ui.messages.sink;
24
-
25
-import com.dmdirc.interfaces.WindowModel;
26
-
27
-import java.util.Date;
28
-import java.util.regex.Pattern;
29
-
30
-/**
31
- * Represents a possible destination (sink) for a generic DMDirc message.
32
- */
33
-@Deprecated
34
-public interface MessageSink {
35
-
36
-    /**
37
-     * Returns a regular expression pattern that can be used to determine if this sink matches a
38
-     * given configuration entry. If the pattern contains groups, the values of the matched groups
39
-     * are passed into the handleMessage method.
40
-     *
41
-     * @return Pattern to matches a config entry
42
-     */
43
-    Pattern getPattern();
44
-
45
-    /**
46
-     * Handles a message which has been directed to this sink.
47
-     *
48
-     * @param dispatcher     The manager that is dispatching the message
49
-     * @param source         The original source of the message
50
-     * @param patternMatches An array of groups matched from this sink's pattern
51
-     * @param date           The date at which the message occurred
52
-     * @param messageType    The type of the message (used for formatting)
53
-     * @param args           The message arguments
54
-     */
55
-    void handleMessage(final MessageSinkManager dispatcher,
56
-            final WindowModel source,
57
-            final String[] patternMatches, final Date date,
58
-            final String messageType, final Object... args);
59
-
60
-}

+ 0
- 124
src/com/dmdirc/ui/messages/sink/MessageSinkManager.java View File

1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.ui.messages.sink;
24
-
25
-import com.dmdirc.interfaces.WindowModel;
26
-
27
-import java.util.ArrayList;
28
-import java.util.Collection;
29
-import java.util.Date;
30
-import java.util.regex.Matcher;
31
-
32
-import org.slf4j.Logger;
33
-import org.slf4j.LoggerFactory;
34
-
35
-import static com.dmdirc.util.LogUtils.USER_ERROR;
36
-
37
-/**
38
- * Manages message sinks and facilitates dispatching of messages to sinks.
39
- */
40
-@Deprecated
41
-public class MessageSinkManager {
42
-
43
-    private static final Logger LOG = LoggerFactory.getLogger(MessageSinkManager.class);
44
-    /** The configuration domain to use for looking up default sinks. */
45
-    public static final String CONFIG_DOMAIN = "notifications";
46
-    /** The default sink to use if none is specified or in case of error. */
47
-    public static final String DEFAULT_SINK = "self";
48
-    /** A list of known sinks. */
49
-    private final Collection<MessageSink> sinks = new ArrayList<>();
50
-
51
-    /**
52
-     * Adds a new sink to the list of known sinks.
53
-     *
54
-     * @param sink The sink to be added
55
-     */
56
-    public void addSink(final MessageSink sink) {
57
-        sinks.add(sink);
58
-    }
59
-
60
-    /**
61
-     * Removes an existing sink from the list of known sinks.
62
-     *
63
-     * @param sink The sink to be removed
64
-     */
65
-    public void removeSink(final MessageSink sink) {
66
-        sinks.remove(sink);
67
-    }
68
-
69
-    /**
70
-     * Dispatches a message to the appropriate sink. This method will attempt to select an
71
-     * appropriate target sink from the user's configuration.
72
-     *
73
-     * @param source      The source of the message
74
-     * @param date        The date at which the message occurred
75
-     * @param messageType The type (or 'format') of the message
76
-     * @param args        The message arguments
77
-     */
78
-    public void dispatchMessage(final WindowModel source, final Date date,
79
-            final String messageType, final Object... args) {
80
-        final String target;
81
-        if (source.getConfigManager().hasOptionString(CONFIG_DOMAIN, messageType)) {
82
-            target = source.getConfigManager().getOption(CONFIG_DOMAIN, messageType);
83
-        } else {
84
-            target = DEFAULT_SINK;
85
-        }
86
-
87
-        dispatchMessage(source, date, messageType, target, args);
88
-    }
89
-
90
-    /**
91
-     * Dispatches a message to the appropriate sink.
92
-     *
93
-     * @param source      The source of the message
94
-     * @param date        The date at which the message occurred
95
-     * @param messageType The type (or 'format') of the message
96
-     * @param targetSink  The textual representation of the destination sink
97
-     * @param args        The message arguments
98
-     */
99
-    public void dispatchMessage(final WindowModel source, final Date date,
100
-            final String messageType, final String targetSink, final Object... args) {
101
-        for (MessageSink sink : sinks) {
102
-            final Matcher matcher = sink.getPattern().matcher(targetSink);
103
-
104
-            if (matcher.matches()) {
105
-                final String[] matches = new String[matcher.groupCount()];
106
-
107
-                for (int i = 0; i < matcher.groupCount(); i++) {
108
-                    matches[i] = matcher.group(i + 1);
109
-                }
110
-
111
-                sink.handleMessage(this, source, matches, date, messageType, args);
112
-                return;
113
-            }
114
-        }
115
-
116
-        // None of the sinks matched :(
117
-        LOG.warn(USER_ERROR, "Invalid target message sink for type {}: {}", messageType, targetSink);
118
-
119
-        if (!DEFAULT_SINK.equals(targetSink)) {
120
-            dispatchMessage(source, date, messageType, DEFAULT_SINK, args);
121
-        }
122
-    }
123
-
124
-}

+ 0
- 110
src/com/dmdirc/ui/messages/sink/MessagesModule.java View File

1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.ui.messages.sink;
24
-
25
-import com.dmdirc.DMDircMBassador;
26
-
27
-import java.util.Set;
28
-
29
-import javax.inject.Singleton;
30
-
31
-import dagger.Module;
32
-import dagger.Provides;
33
-
34
-/**
35
- * Module for dependency injecting the {@link MessageSinkManager} and its default sinks.
36
- */
37
-@Deprecated
38
-@Module(library = true, complete = false)
39
-public class MessagesModule {
40
-
41
-    @Provides
42
-    @Singleton
43
-    public MessageSinkManager getMessageSinkManager(final DMDircMBassador eventBus,
44
-            final Set<MessageSink> defaultSinks) {
45
-        final MessageSinkManager messageSinkManager = new MessageSinkManager();
46
-        defaultSinks.forEach(messageSinkManager::addSink);
47
-        return messageSinkManager;
48
-    }
49
-
50
-    @Provides(type = Provides.Type.SET)
51
-    public MessageSink getAllMessageSink(final AllMessageSink sink) {
52
-        return sink;
53
-    }
54
-
55
-    @Provides(type = Provides.Type.SET)
56
-    public MessageSink getChannelMessageSink(final ChannelMessageSink sink) {
57
-        return sink;
58
-    }
59
-
60
-    @Provides(type = Provides.Type.SET)
61
-    public MessageSink getCommonChannelsMessageSink(final CommonChannelsMessageSink sink) {
62
-        return sink;
63
-    }
64
-
65
-    @Provides(type = Provides.Type.SET)
66
-    public MessageSink getCustomWindowMessageSink(final CustomWindowMessageSink sink) {
67
-        return sink;
68
-    }
69
-
70
-    @Provides(type = Provides.Type.SET)
71
-    public MessageSink getForkMessageSink(final ForkMessageSink sink) {
72
-        return sink;
73
-    }
74
-
75
-    @Provides(type = Provides.Type.SET)
76
-    public MessageSink getFormatMessageSink(final FormatMessageSink sink) {
77
-        return sink;
78
-    }
79
-
80
-    @Provides(type = Provides.Type.SET)
81
-    public MessageSink getGroupMessageSink(final GroupMessageSink sink) {
82
-        return sink;
83
-    }
84
-
85
-    @Provides(type = Provides.Type.SET)
86
-    public MessageSink getLastCommandMessageSink(final LastCommandMessageSink sink) {
87
-        return sink;
88
-    }
89
-
90
-    @Provides(type = Provides.Type.SET)
91
-    public MessageSink getNullMessageSink(final NullMessageSink sink) {
92
-        return sink;
93
-    }
94
-
95
-    @Provides(type = Provides.Type.SET)
96
-    public MessageSink getSelfMessageSink(final SelfMessageSink sink) {
97
-        return sink;
98
-    }
99
-
100
-    @Provides(type = Provides.Type.SET)
101
-    public MessageSink getServerMessageSink(final ServerMessageSink sink) {
102
-        return sink;
103
-    }
104
-
105
-    @Provides(type = Provides.Type.SET)
106
-    public MessageSink getStatusBarMessageSink(final StatusBarMessageSink sink) {
107
-        return sink;
108
-    }
109
-
110
-}

+ 0
- 58
src/com/dmdirc/ui/messages/sink/NullMessageSink.java View File

1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.ui.messages.sink;
24
-
25
-import com.dmdirc.interfaces.WindowModel;
26
-
27
-import java.util.Date;
28
-import java.util.regex.Pattern;
29
-
30
-import javax.inject.Inject;
31
-
32
-/**
33
- * A message sink which does nothing with the message.
34
- */
35
-@Deprecated
36
-public class NullMessageSink implements MessageSink {
37
-
38
-    /** The pattern to use to match this sink. */
39
-    private static final Pattern PATTERN = Pattern.compile("none");
40
-
41
-    @Inject
42
-    public NullMessageSink() {
43
-    }
44
-
45
-    @Override
46
-    public Pattern getPattern() {
47
-        return PATTERN;
48
-    }
49
-
50
-    @Override
51
-    public void handleMessage(final MessageSinkManager dispatcher,
52
-            final WindowModel source,
53
-            final String[] patternMatches, final Date date,
54
-            final String messageType, final Object... args) {
55
-        // Do nothing
56
-    }
57
-
58
-}

+ 0
- 58
src/com/dmdirc/ui/messages/sink/SelfMessageSink.java View File

1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.ui.messages.sink;
24
-
25
-import com.dmdirc.interfaces.WindowModel;
26
-
27
-import java.util.Date;
28
-import java.util.regex.Pattern;
29
-
30
-import javax.inject.Inject;
31
-
32
-/**
33
- * A message sink which adds the message to the container that dispatched it.
34
- */
35
-@Deprecated
36
-public class SelfMessageSink implements MessageSink {
37
-
38
-    /** The pattern to use to match this sink. */
39
-    private static final Pattern PATTERN = Pattern.compile("self");
40
-
41
-    @Inject
42
-    public SelfMessageSink() {
43
-    }
44
-
45
-    @Override
46
-    public Pattern getPattern() {
47
-        return PATTERN;
48
-    }
49
-
50
-    @Override
51
-    public void handleMessage(final MessageSinkManager dispatcher,
52
-            final WindowModel source,
53
-            final String[] patternMatches, final Date date,
54
-            final String messageType, final Object... args) {
55
-        source.addLine(messageType, date, args);
56
-    }
57
-
58
-}

+ 0
- 58
src/com/dmdirc/ui/messages/sink/ServerMessageSink.java View File

1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.ui.messages.sink;
24
-
25
-import com.dmdirc.interfaces.WindowModel;
26
-
27
-import java.util.Date;
28
-import java.util.regex.Pattern;
29
-
30
-import javax.inject.Inject;
31
-
32
-/**
33
- * A message sink which adds the message to the container's server.
34
- */
35
-@Deprecated
36
-public class ServerMessageSink implements MessageSink {
37
-
38
-    /** The pattern to use to match this sink. */
39
-    private static final Pattern PATTERN = Pattern.compile("server");
40
-
41
-    @Inject
42
-    public ServerMessageSink() {
43
-    }
44
-
45
-    @Override
46
-    public Pattern getPattern() {
47
-        return PATTERN;
48
-    }
49
-
50
-    @Override
51
-    public void handleMessage(final MessageSinkManager dispatcher,
52
-            final WindowModel source,
53
-            final String[] patternMatches, final Date date,
54
-            final String messageType, final Object... args) {
55
-        source.getConnection().get().getWindowModel().addLine(messageType, date, args);
56
-    }
57
-
58
-}

+ 0
- 73
src/com/dmdirc/ui/messages/sink/StatusBarMessageSink.java View File

1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.ui.messages.sink;
24
-
25
-import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.events.StatusBarMessageEvent;
27
-import com.dmdirc.interfaces.WindowModel;
28
-import com.dmdirc.ui.StatusMessage;
29
-import com.dmdirc.ui.messages.Formatter;
30
-
31
-import java.util.Date;
32
-import java.util.regex.Pattern;
33
-
34
-import javax.inject.Inject;
35
-
36
-/**
37
- * A message sink which adds the message to the status bar.
38
- */
39
-@Deprecated
40
-public class StatusBarMessageSink implements MessageSink {
41
-
42
-    /** The pattern to use to match this sink. */
43
-    private static final Pattern PATTERN = Pattern.compile("statusbar");
44
-    /** The event bus to post status messages to. */
45
-    private final DMDircMBassador eventBus;
46
-
47
-    /**
48
-     * Creates a new instance of {@link StatusBarMessageSink}.
49
-     *
50
-     * @param eventBus The event bus to post status messages to
51
-     */
52
-    @Inject
53
-    public StatusBarMessageSink(final DMDircMBassador eventBus) {
54
-        this.eventBus = eventBus;
55
-    }
56
-
57
-    @Override
58
-    public Pattern getPattern() {
59
-        return PATTERN;
60
-    }
61
-
62
-    @Override
63
-    public void handleMessage(final MessageSinkManager dispatcher,
64
-            final WindowModel source,
65
-            final String[] patternMatches, final Date date,
66
-            final String messageType, final Object... args) {
67
-        final String message = Formatter.formatMessage(source.getConfigManager(),
68
-                messageType, args);
69
-        eventBus.publishAsync(new StatusBarMessageEvent(new StatusMessage(message,
70
-                source.getConfigManager())));
71
-    }
72
-
73
-}

+ 2
- 4
test/com/dmdirc/WritableFrameContainerTest.java View File

28
 import com.dmdirc.interfaces.ConnectionManager;
28
 import com.dmdirc.interfaces.ConnectionManager;
29
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
29
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
30
 import com.dmdirc.ui.messages.BackBufferFactory;
30
 import com.dmdirc.ui.messages.BackBufferFactory;
31
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
32
 
31
 
33
 import java.util.Arrays;
32
 import java.util.Arrays;
34
 
33
 
48
     @Mock private AggregateConfigProvider acp;
47
     @Mock private AggregateConfigProvider acp;
49
     @Mock private ConfigBinder configBinder;
48
     @Mock private ConfigBinder configBinder;
50
     @Mock private ConnectionManager connectionManager;
49
     @Mock private ConnectionManager connectionManager;
51
-    @Mock private MessageSinkManager messageSinkManager;
52
     @Mock private DMDircMBassador eventBus;
50
     @Mock private DMDircMBassador eventBus;
53
     @Mock private BackBufferFactory backBufferFactory;
51
     @Mock private BackBufferFactory backBufferFactory;
54
     @Mock private Provider<GlobalWindow> globalWindowProvider;
52
     @Mock private Provider<GlobalWindow> globalWindowProvider;
66
     @Test
64
     @Test
67
     public void testGetNumLines() {
65
     public void testGetNumLines() {
68
         final FrameContainer container10 = new TestWritableFrameContainer(10, acp, commands,
66
         final FrameContainer container10 = new TestWritableFrameContainer(10, acp, commands,
69
-                messageSinkManager, eventBus, backBufferFactory);
67
+                eventBus, backBufferFactory);
70
 
68
 
71
         final int res0a = container10.getNumLines("");
69
         final int res0a = container10.getNumLines("");
72
         final int res0b = container10.getNumLines("\r");
70
         final int res0b = container10.getNumLines("\r");
96
     @Test
94
     @Test
97
     public void testSplitLine() {
95
     public void testSplitLine() {
98
         final FrameContainer container10 = new TestWritableFrameContainer(10, acp, commands,
96
         final FrameContainer container10 = new TestWritableFrameContainer(10, acp, commands,
99
-                messageSinkManager, eventBus, backBufferFactory);
97
+                eventBus, backBufferFactory);
100
         final String[][][] tests = new String[][][]{
98
         final String[][][] tests = new String[][][]{
101
             {{""}, {""}},
99
             {{""}, {""}},
102
             {{"0123456789"}, {"0123456789"}},
100
             {{"0123456789"}, {"0123456789"}},

+ 0
- 3
test/com/dmdirc/harness/TestWritableFrameContainer.java View File

30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
31
 import com.dmdirc.ui.input.TabCompleter;
31
 import com.dmdirc.ui.input.TabCompleter;
32
 import com.dmdirc.ui.messages.BackBufferFactory;
32
 import com.dmdirc.ui.messages.BackBufferFactory;
33
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
34
 
33
 
35
 import java.util.Collections;
34
 import java.util.Collections;
36
 import java.util.Optional;
35
 import java.util.Optional;
41
 
40
 
42
     public TestWritableFrameContainer(final int lineLength,
41
     public TestWritableFrameContainer(final int lineLength,
43
             final AggregateConfigProvider cm, final CommandManager commandManager,
42
             final AggregateConfigProvider cm, final CommandManager commandManager,
44
-            final MessageSinkManager messageSinkManager,
45
             final DMDircMBassador eventBus,
43
             final DMDircMBassador eventBus,
46
             final BackBufferFactory backBufferFactory) {
44
             final BackBufferFactory backBufferFactory) {
47
         super(null, "raw", "Raw", "(Raw)", cm, backBufferFactory,
45
         super(null, "raw", "Raw", "(Raw)", cm, backBufferFactory,
48
                 new TabCompleter(cm),
46
                 new TabCompleter(cm),
49
-                messageSinkManager,
50
                 eventBus,
47
                 eventBus,
51
                 Collections.<String>emptySet());
48
                 Collections.<String>emptySet());
52
 
49
 

Loading…
Cancel
Save