Skip to content

Commit

Permalink
Add events for sent messages/ctcps/notices/raw lines.
Browse files Browse the repository at this point in the history
  • Loading branch information
csmith committed Feb 16, 2016
1 parent 4764f49 commit 7bfdf45
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 10 deletions.
15 changes: 11 additions & 4 deletions res/com/dmdirc/ui/messages/format.yml
Expand Up @@ -8,6 +8,9 @@ ServerCtcpEvent:
ServerCtcpReplyEvent:
format: "-!- CTCP {{type}} reply from {{user.nickname}}: {{content}}."
colour: 4
ServerCtcpSentEvent:
format: "->- [{{target}}] {{line}}"
colour: 4
ServerConnectingEvent:
format: "Connecting to {{uri.host}}:{{uri.port}}..."
ServerDisconnectedEvent:
Expand Down Expand Up @@ -82,6 +85,11 @@ ServerWallusersEvent:
ServerWalldesyncEvent:
format: "/{{user.nickname}}/ {{message}}"
colour: 5
ServerMessageSentEvent:
format: ">[{{target}}]> {{message}}"
ServerNoticeSentEvent:
format: ">{{target}}> {{message}}"
colour: 5

################## Channel join/part/quit events ###################################################

Expand Down Expand Up @@ -214,14 +222,13 @@ UserInfoResponseEvent:
iterate: "properties"
format: "{{friendlyName}}: {{rawValue}}"
colour: 10
ServerRawLineSentEvent:
format: ">>> {{line}}"
colour: 10

################## TODO ############################################################################
# selfCTCP=4->- [%1$s] %2$s
# selfNotice=5>%1$s> %2$s
# selfMessage=>[%1$s]> %2$s
# serverDisconnectInProgress=A disconnection attempt is in progress, please wait...
# serverConnectInProgress=A connection attempt is in progress, please wait...
# rawCommand=10>>> %1$s
# commandOutput=%1$s
# actionTooLong=Warning: action too long to be sent
# numeric_006=%4$s
Expand Down
7 changes: 5 additions & 2 deletions src/com/dmdirc/commandparser/commands/server/Ctcp.java
Expand Up @@ -31,6 +31,7 @@
import com.dmdirc.commandparser.commands.IntelligentCommand;
import com.dmdirc.commandparser.commands.context.CommandContext;
import com.dmdirc.commandparser.commands.context.ServerCommandContext;
import com.dmdirc.events.ServerCtcpSentEvent;
import com.dmdirc.interfaces.CommandController;
import com.dmdirc.interfaces.Connection;
import com.dmdirc.interfaces.WindowModel;
Expand Down Expand Up @@ -70,8 +71,10 @@ public void execute(@Nonnull final WindowModel origin,
} else {
connection.getParser().get().sendCTCP(args.getArguments()[0],
args.getArguments()[1], args.getArgumentsAsString(2));
sendLine(origin, args.isSilent(), "selfCTCP", args.getArguments()[0],
args.getArgumentsAsString(1));
if (!args.isSilent()) {
origin.getEventBus().publishAsync(new ServerCtcpSentEvent(
connection, args.getArguments()[0], args.getArgumentsAsString(1)));
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/com/dmdirc/commandparser/commands/server/Message.java
Expand Up @@ -32,6 +32,7 @@
import com.dmdirc.commandparser.commands.WrappableCommand;
import com.dmdirc.commandparser.commands.context.CommandContext;
import com.dmdirc.commandparser.commands.context.ServerCommandContext;
import com.dmdirc.events.ServerMessageSentEvent;
import com.dmdirc.interfaces.CommandController;
import com.dmdirc.interfaces.Connection;
import com.dmdirc.interfaces.GroupChat;
Expand Down Expand Up @@ -76,7 +77,10 @@ public void execute(@Nonnull final WindowModel origin,
} else {
final String target = args.getArguments()[0];
final String message = args.getArgumentsAsString(1);
sendLine(origin, args.isSilent(), "selfMessage", target, message);
if (!args.isSilent()) {
origin.getEventBus().publishAsync(
new ServerMessageSentEvent(connection, target, message));
}

// If this is a known server or channel, and this is not a silent
// invocation, use sendLine, else send it raw to the parser.
Expand Down
7 changes: 5 additions & 2 deletions src/com/dmdirc/commandparser/commands/server/Notice.java
Expand Up @@ -31,6 +31,7 @@
import com.dmdirc.commandparser.commands.IntelligentCommand;
import com.dmdirc.commandparser.commands.context.CommandContext;
import com.dmdirc.commandparser.commands.context.ServerCommandContext;
import com.dmdirc.events.ServerNoticeSentEvent;
import com.dmdirc.interfaces.CommandController;
import com.dmdirc.interfaces.Connection;
import com.dmdirc.interfaces.WindowModel;
Expand Down Expand Up @@ -70,8 +71,10 @@ public void execute(@Nonnull final WindowModel origin,
} else {
connection.getParser().get().sendNotice(args.getArguments()[0],
args.getArgumentsAsString(1));
sendLine(origin, args.isSilent(), "selfNotice", args.getArguments()[0],
args.getArgumentsAsString(1));
if (!args.isSilent()) {
origin.getEventBus().publishAsync(new ServerNoticeSentEvent(
connection, args.getArguments()[0], args.getArgumentsAsString(1)));
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/com/dmdirc/commandparser/commands/server/Raw.java
Expand Up @@ -30,6 +30,7 @@
import com.dmdirc.commandparser.commands.CommandOptions;
import com.dmdirc.commandparser.commands.context.CommandContext;
import com.dmdirc.commandparser.commands.context.ServerCommandContext;
import com.dmdirc.events.ServerRawLineSentEvent;
import com.dmdirc.interfaces.CommandController;
import com.dmdirc.interfaces.Connection;
import com.dmdirc.interfaces.WindowModel;
Expand Down Expand Up @@ -65,7 +66,9 @@ public void execute(@Nonnull final WindowModel origin,
final String line = args.getArgumentsAsString();

connection.getParser().get().sendRawMessage(line);
sendLine(origin, args.isSilent(), "rawCommand", line);
if (!args.isSilent()) {
origin.getEventBus().publishAsync(new ServerRawLineSentEvent(connection, line));
}
}

}
56 changes: 56 additions & 0 deletions src/com/dmdirc/events/ServerCtcpSentEvent.java
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2006-2015 DMDirc Developers
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.dmdirc.events;

import com.dmdirc.interfaces.Connection;

/**
* Fired when a CTCP is manually sent from the local client.
*/
public class ServerCtcpSentEvent extends ServerDisplayableEvent {

private final String target;
private final String data;

public ServerCtcpSentEvent(final long timestamp, final Connection connection,
final String target, final String data) {
super(timestamp, connection);
this.target = target;
this.data = data;
}

public ServerCtcpSentEvent(final Connection connection, final String target, final String data) {
super(connection);
this.target = target;
this.data = data;
}

public String getTarget() {
return target;
}

public String getData() {
return data;
}

}
57 changes: 57 additions & 0 deletions src/com/dmdirc/events/ServerMessageSentEvent.java
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2006-2015 DMDirc Developers
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.dmdirc.events;

import com.dmdirc.interfaces.Connection;

/**
* Fired when a message is manually sent from the local client.
*/
public class ServerMessageSentEvent extends ServerDisplayableEvent {

private final String target;
private final String message;

public ServerMessageSentEvent(final long timestamp, final Connection connection,
final String target, final String message) {
super(timestamp, connection);
this.target = target;
this.message = message;
}

public ServerMessageSentEvent(final Connection connection, final String target,
final String message) {
super(connection);
this.target = target;
this.message = message;
}

public String getTarget() {
return target;
}

public String getMessage() {
return message;
}

}
57 changes: 57 additions & 0 deletions src/com/dmdirc/events/ServerNoticeSentEvent.java
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2006-2015 DMDirc Developers
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.dmdirc.events;

import com.dmdirc.interfaces.Connection;

/**
* Fired when a notice is manually sent from the local client.
*/
public class ServerNoticeSentEvent extends ServerDisplayableEvent {

private final String target;
private final String message;

public ServerNoticeSentEvent(final long timestamp, final Connection connection,
final String target, final String message) {
super(timestamp, connection);
this.target = target;
this.message = message;
}

public ServerNoticeSentEvent(final Connection connection, final String target,
final String message) {
super(connection);
this.target = target;
this.message = message;
}

public String getTarget() {
return target;
}

public String getMessage() {
return message;
}

}
49 changes: 49 additions & 0 deletions src/com/dmdirc/events/ServerRawLineSentEvent.java
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2006-2015 DMDirc Developers
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.dmdirc.events;

import com.dmdirc.interfaces.Connection;

/**
* Fired when a raw line is manually sent from the local client.
*/
public class ServerRawLineSentEvent extends ServerDisplayableEvent {

private final String line;

public ServerRawLineSentEvent(final long timestamp, final Connection connection,
final String line) {
super(timestamp, connection);
this.line = line;
}

public ServerRawLineSentEvent(final Connection connection, final String line) {
super(connection);
this.line = line;
}

public String getLine() {
return line;
}

}

0 comments on commit 7bfdf45

Please sign in to comment.