Browse Source

Issue 661


git-svn-id: http://svn.dmdirc.com/trunk@3961 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Shane Mc Cormack 16 years ago
parent
commit
116e2ff888

+ 6
- 4
src/com/dmdirc/addons/dcc/DCCChatWindow.java View File

@@ -22,6 +22,8 @@
22 22
 
23 23
 package com.dmdirc.addons.dcc;
24 24
 
25
+import com.dmdirc.actions.ActionManager;
26
+import com.dmdirc.addons.dcc.actions.DCCActions;
25 27
 import com.dmdirc.Main;
26 28
 
27 29
 /**
@@ -72,7 +74,7 @@ public class DCCChatWindow extends DCCFrame implements DCCChatInterface {
72 74
 	public void sendLine(final String line) {
73 75
 		if (dcc.isWriteable()) {
74 76
 			final StringBuffer buff = new StringBuffer("DCCChatSelfMessage");
75
-			//ActionManager.processEvent(DCCActionType.DCC_CHAT_SELFMESSAGE, buff, this, line);
77
+			ActionManager.processEvent(DCCActions.DCC_CHAT_SELFMESSAGE, buff, this, line);
76 78
 			addLine(buff, nickname, myWindow.getTranscoder().encode(line));
77 79
 			dcc.sendLine(line);
78 80
 		} else {
@@ -90,7 +92,7 @@ public class DCCChatWindow extends DCCFrame implements DCCChatInterface {
90 92
     @Override
91 93
 	public void handleChatMessage(final DCCChat dcc, final String message) {
92 94
 		final StringBuffer buff = new StringBuffer("DCCChatMessage");
93
-		//ActionManager.processEvent(DCCActionType.DCC_CHAT_MESSAGE, buff, this, otherNickname, message);
95
+		ActionManager.processEvent(DCCActions.DCC_CHAT_MESSAGE, buff, this, otherNickname, message);
94 96
 		addLine(buff, otherNickname, myWindow.getTranscoder().encode(message));
95 97
 	}
96 98
 	
@@ -102,7 +104,7 @@ public class DCCChatWindow extends DCCFrame implements DCCChatInterface {
102 104
     @Override
103 105
 	public void socketClosed(final DCCChat dcc) {
104 106
 		final StringBuffer buff = new StringBuffer("DCCChatInfo");
105
-		//ActionManager.processEvent(DCCActionType.DCC_CHAT_SOCKETCLOSED, buff, this);
107
+		ActionManager.processEvent(DCCActions.DCC_CHAT_SOCKETCLOSED, buff, this);
106 108
 		addLine(buff, "Socket closed");
107 109
 	}
108 110
 	
@@ -114,7 +116,7 @@ public class DCCChatWindow extends DCCFrame implements DCCChatInterface {
114 116
     @Override
115 117
 	public void socketOpened(final DCCChat dcc) {
116 118
 		final StringBuffer buff = new StringBuffer("DCCChatInfo");
117
-		//ActionManager.processEvent(DCCActionType.DCC_CHAT_SOCKETOPENED, buff, this);
119
+		ActionManager.processEvent(DCCActions.DCC_CHAT_SOCKETOPENED, buff, this);
118 120
 		addLine(buff, "Socket opened");
119 121
 	}
120 122
 	

+ 8
- 1
src/com/dmdirc/addons/dcc/DCCCommand.java View File

@@ -23,12 +23,16 @@
23 23
 package com.dmdirc.addons.dcc;
24 24
 
25 25
 import com.dmdirc.Main;
26
+import com.dmdirc.Server;
26 27
 import com.dmdirc.parser.IRCParser;
27 28
 import com.dmdirc.config.IdentityManager;
28 29
 import com.dmdirc.commandparser.CommandManager;
29 30
 import com.dmdirc.commandparser.commands.GlobalCommand;
30 31
 import com.dmdirc.ui.interfaces.InputWindow;
31 32
 
33
+import com.dmdirc.actions.ActionManager;
34
+import com.dmdirc.addons.dcc.actions.DCCActions;
35
+
32 36
 import javax.swing.JFileChooser;
33 37
 import javax.swing.JFrame;
34 38
 
@@ -67,13 +71,16 @@ public final class DCCCommand extends GlobalCommand {
67 71
 			final String type = args[0];
68 72
 			final String target = args[1];
69 73
 			if (type.equalsIgnoreCase("chat")) {
70
-				final IRCParser parser = origin.getContainer().getServer().getParser();
74
+				final Server server = origin.getContainer().getServer();
75
+				final IRCParser parser = server.getParser();
71 76
 				final String myNickname = parser.getMyNickname();
72 77
 				final DCCChat chat = new DCCChat();
73 78
 				chat.listen();
74 79
 				final DCCChatWindow window = new DCCChatWindow(myPlugin, chat, "*Chat: "+target, myNickname, target);
75 80
 				parser.sendCTCP(target, "DCC", "CHAT chat "+DCC.ipToLong(chat.getHost())+" "+chat.getPort());
76 81
 				
82
+				ActionManager.processEvent(DCCActions.DCC_CHAT_REQUEST_SENT, null, server, target);
83
+				
77 84
 				sendLine(origin, isSilent, "DCCChatStarting", target, chat.getHost(), chat.getPort());
78 85
 				window.getFrame().addLine("DCCChatStarting", target, chat.getHost(), chat.getPort());
79 86
 			} else if (type.equalsIgnoreCase("send")) {

+ 4
- 0
src/com/dmdirc/addons/dcc/DCCPlugin.java View File

@@ -44,6 +44,8 @@ import com.dmdirc.ui.WindowManager;
44 44
 import com.dmdirc.ui.swing.components.JWrappingLabel;
45 45
 import com.dmdirc.ui.swing.components.TextFrame;
46 46
 
47
+import com.dmdirc.addons.dcc.actions.DCCActions;
48
+
47 49
 import java.io.File;
48 50
 import java.io.IOException;
49 51
 
@@ -226,6 +228,7 @@ public final class DCCPlugin extends Plugin implements ActionListener {
226 228
 						f.getFrame().addLine("DCCChatStarting", nickname, chat.getHost(), chat.getPort());
227 229
 						chat.connect();
228 230
 					} else {
231
+						ActionManager.processEvent(DCCActions.DCC_CHAT_REQUEST, null, ((Server)arguments[0]), nickname);
229 232
 						askQuestion("User "+nickname+" on "+((Server)arguments[0]).toString()+" would like to start a DCC Chat with you.\n\nDo you want to continue?", "DCC Chat Request", JOptionPane.YES_OPTION, type, format, arguments);
230 233
 						return;
231 234
 					}
@@ -428,6 +431,7 @@ public final class DCCPlugin extends Plugin implements ActionListener {
428 431
 		}
429 432
 
430 433
 		command = new DCCCommand(this);
434
+		ActionManager.registerActionTypes(DCCActions.values());
431 435
 		ActionManager.addListener(this, CoreActionType.SERVER_CTCP);
432 436
 	}
433 437
 

src/com/dmdirc/addons/dcc/actions/DccActions.java → src/com/dmdirc/addons/dcc/actions/DCCActions.java View File

@@ -27,41 +27,49 @@ import com.dmdirc.actions.interfaces.ActionType;
27 27
 
28 28
 /**
29 29
  * DCC actions.
30
- * 
30
+ *
31 31
  * @author chris
32 32
  */
33
-public enum DccActions implements ActionType {
34
-    
35
-    /** Chat request. */
36
-    DCC_CHAT_REQUEST(DccEvents.DCC_CHAT_REQUEST, "Chat request"),
37
-    /** File offered. */
38
-    DCC_FILE_OFFERED(DccEvents.DCC_FILE_REQUEST, "File offered");
39
-    
40
-    /** The type of this action. */
41
-    private final ActionMetaType type;
42
-    
43
-    /** The name of this action. */
44
-    private final String name;
45
-    
46
-    /**
47
-     * Constructs a new core action.
48
-     * @param type The type of this action
49
-     * @param name The name of this action
50
-     */
51
-    DccActions(final ActionMetaType type, final String name) {
52
-        this.type = type;
53
-        this.name = name;
54
-    }
55
-    
56
-    /** {@inheritDoc} */
57
-    @Override
58
-    public ActionMetaType getType() {
59
-        return type;
60
-    }
61
-    
62
-    /** {@inheritDoc} */
63
-    @Override
64
-    public String getName() {
65
-        return name;
66
-    }
33
+public enum DCCActions implements ActionType {
34
+	
35
+	/** DCC Chat Request. */
36
+	DCC_CHAT_REQUEST(DCCEvents.DCC_CHAT_REQUEST, "DCC Chat Requested"),
37
+	/** DCC Chat Request Sent. */
38
+	DCC_CHAT_REQUEST_SENT(DCCEvents.DCC_CHAT_REQUEST_SENT, "DCC Chat Request Sent"),
39
+	/** DCC Message from another person. */
40
+	DCC_CHAT_MESSAGE(DCCEvents.DCC_CHAT_MESSAGE, "DCC Chat Message Recieved"),
41
+	/** DCC Message to another person. */
42
+	DCC_CHAT_SELFMESSAGE(DCCEvents.DCC_CHAT_SELFMESSAGE, "DCC Chat Message Sent"),
43
+	/** DCC Chat Socket Opened. */
44
+	DCC_CHAT_SOCKETCLOSED(DCCEvents.DCC_CHAT_SOCKETCLOSED, "DCC Chat Socket Closed"),
45
+	/** DCC Chat Socket Closed. */
46
+	DCC_CHAT_SOCKETOPENED(DCCEvents.DCC_CHAT_SOCKETOPENED, "DCC Chat Socket Opened");
47
+	
48
+	/** The type of this action. */
49
+	private final ActionMetaType type;
50
+	
51
+	/** The name of this action. */
52
+	private final String name;
53
+	
54
+	/**
55
+	 * Constructs a new core action.
56
+	 * @param type The type of this action
57
+	 * @param name The name of this action
58
+	 */
59
+	DCCActions(final ActionMetaType type, final String name) {
60
+		this.type = type;
61
+		this.name = name;
62
+	}
63
+	
64
+	/** {@inheritDoc} */
65
+	@Override
66
+	public ActionMetaType getType() {
67
+		return type;
68
+	}
69
+	
70
+	/** {@inheritDoc} */
71
+	@Override
72
+	public String getName() {
73
+		return name;
74
+	}
67 75
 }

+ 86
- 0
src/com/dmdirc/addons/dcc/actions/DCCEvents.java View File

@@ -0,0 +1,86 @@
1
+/*
2
+ * Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes
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.addons.dcc.actions;
24
+
25
+import com.dmdirc.Server;
26
+import com.dmdirc.actions.interfaces.ActionMetaType;
27
+import com.dmdirc.parser.ClientInfo;
28
+
29
+import com.dmdirc.addons.dcc.DCCChatWindow;
30
+
31
+/**
32
+ * Defines DCC-related events.
33
+ *
34
+ * @author Chris
35
+ */
36
+public enum DCCEvents implements ActionMetaType {
37
+	/** DCC Chat Request. */
38
+	DCC_CHAT_REQUEST(new String[]{"server", "client"}, Server.class, String.class),
39
+	/** DCC Chat Request Sent. */
40
+	DCC_CHAT_REQUEST_SENT(new String[]{"server", "client"}, Server.class, String.class),
41
+	/** DCC Message from another person. */
42
+	DCC_CHAT_MESSAGE(new String[]{"DCCChatWindow", "Nickname", "Message"}, DCCChatWindow.class, String.class, String.class),
43
+	/** DCC Message to another person. */
44
+	DCC_CHAT_SELFMESSAGE(new String[]{"DCCChatWindow", "Message"}, DCCChatWindow.class, String.class),
45
+	/** DCC Chat Socket Opened. */
46
+	DCC_CHAT_SOCKETCLOSED(new String[]{"DCCChatWindow"}, DCCChatWindow.class),
47
+	/** DCC Chat Socket Closed. */
48
+	DCC_CHAT_SOCKETOPENED(new String[]{"DCCChatWindow"}, DCCChatWindow.class);
49
+    
50
+	/** The names of the arguments for this meta type. */
51
+	private String[] argNames;
52
+	/** The classes of the arguments for this meta type. */
53
+	private Class[] argTypes;
54
+	
55
+	/**
56
+	 * Creates a new instance of this meta-type.
57
+	 *
58
+	 * @param argNames The names of the meta-type's arguments
59
+	 * @param argTypes The types of the meta-type's arguments
60
+	 */
61
+	DCCEvents(final String[] argNames, final Class ... argTypes) {
62
+		this.argNames = argNames;
63
+		this.argTypes = argTypes;
64
+	}
65
+	
66
+	/** {@inheritDoc} */
67
+	public int getArity() {
68
+		return argNames.length;
69
+	}
70
+	
71
+	/** {@inheritDoc} */
72
+	public Class[] getArgTypes() {
73
+		return argTypes;
74
+	}
75
+	
76
+	/** {@inheritDoc} */
77
+	public String[] getArgNames() {
78
+		return argNames;
79
+	}
80
+	
81
+	/** {@inheritDoc} */
82
+	public String getGroup() {
83
+		return "DCC Events";
84
+	}
85
+	
86
+}

+ 0
- 77
src/com/dmdirc/addons/dcc/actions/DccEvents.java View File

@@ -1,77 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes
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.addons.dcc.actions;
24
-
25
-import com.dmdirc.Server;
26
-import com.dmdirc.actions.interfaces.ActionMetaType;
27
-import com.dmdirc.parser.ClientInfo;
28
-
29
-/**
30
- * Defines DCC-related events.
31
- *
32
- * @author Chris
33
- */
34
-public enum DccEvents implements ActionMetaType {
35
-
36
-    /** Chat request. */
37
-    DCC_CHAT_REQUEST(new String[]{"server", "client"}, Server.class, ClientInfo.class),
38
-    /** File transfer request. */
39
-    DCC_FILE_REQUEST(new String[]{"server", "client", "file name"}, Server.class, ClientInfo.class, String.class);
40
-    
41
-    /** The names of the arguments for this meta type. */
42
-    private String[] argNames;
43
-    /** The classes of the arguments for this meta type. */
44
-    private Class[] argTypes;
45
-    
46
-    /**
47
-     * Creates a new instance of this meta-type.
48
-     *
49
-     * @param argNames The names of the meta-type's arguments
50
-     * @param argTypes The types of the meta-type's arguments
51
-     */
52
-    DccEvents(final String[] argNames, final Class ... argTypes) {
53
-        this.argNames = argNames;
54
-        this.argTypes = argTypes;
55
-    }
56
-    
57
-    /** {@inheritDoc} */
58
-    public int getArity() {
59
-        return argNames.length;
60
-    }
61
-    
62
-    /** {@inheritDoc} */
63
-    public Class[] getArgTypes() {
64
-        return argTypes;
65
-    }
66
-    
67
-    /** {@inheritDoc} */
68
-    public String[] getArgNames() {
69
-        return argNames;
70
-    }
71
-    
72
-    /** {@inheritDoc} */
73
-    public String getGroup() {
74
-        return "DCC Events";
75
-    }    
76
-    
77
-}

+ 3
- 1
src/com/dmdirc/addons/dcc/plugin.info View File

@@ -5,4 +5,6 @@ description=Adds DCC Support to dmdirc
5 5
 name=dcc
6 6
 nicename=DCC Plugin
7 7
 minversion=0
8
-require-ui=com.dmdirc.ui.swing
8
+require-ui=com.dmdirc.ui.swing
9
+persistant-com.dmdirc.addons.dcc.actions.DCCActions=true
10
+persistant-com.dmdirc.addons.dcc.actions.DCCEvents=true

Loading…
Cancel
Save