Kaynağa Gözat

* Added action handling for channels

* Implemented all methods of ChannelCommandParser
* Updated abstract ChannelCommand class to include origin

git-svn-id: http://svn.dmdirc.com/trunk@180 00569f92-eb28-0410-84fd-f71c24880f
tags/0.1
Chris Smith 17 yıl önce
ebeveyn
işleme
110c9e6a99

+ 12
- 1
src/uk/org/ownage/dmdirc/Channel.java Dosyayı Görüntüle

@@ -39,7 +39,7 @@ import uk.org.ownage.dmdirc.ui.MainFrame;
39 39
 public class Channel implements IRCParser.IChannelMessage,
40 40
         IRCParser.IChannelGotNames, IRCParser.IChannelTopic,
41 41
         IRCParser.IChannelJoin, IRCParser.IChannelPart, IRCParser.IChannelKick,
42
-        IRCParser.IChannelQuit {
42
+        IRCParser.IChannelQuit, IRCParser.IChannelAction {
43 43
     
44 44
     /** The parser's pChannel class */
45 45
     private ChannelInfo channelInfo;
@@ -69,6 +69,7 @@ public class Channel implements IRCParser.IChannelMessage,
69 69
         server.getParser().addChannelPart(this, channelInfo.getName());
70 70
         server.getParser().addChannelQuit(this, channelInfo.getName());
71 71
         server.getParser().addChannelKick(this, channelInfo.getName());
72
+        server.getParser().addChannelAction(this, channelInfo.getName());
72 73
         
73 74
         updateTitle();
74 75
     }
@@ -135,5 +136,15 @@ public class Channel implements IRCParser.IChannelMessage,
135 136
         frame.addLine("* "+cChannelClient+" has quit IRC ("+sReason+")");
136 137
         frame.removeName(cChannelClient);
137 138
     }
139
+
140
+    public void onChannelAction(IRCParser tParser, ChannelInfo cChannel, ChannelClientInfo cChannelClient, String sMessage, String sHost) {
141
+        String source;
142
+        if (cChannelClient == null) {
143
+            source = sHost;
144
+        } else {
145
+            source = cChannelClient.toString();
146
+        }
147
+        frame.addLine("* "+source+" "+sMessage);
148
+    }
138 149
     
139 150
 }

+ 4
- 3
src/uk/org/ownage/dmdirc/commandparser/ChannelCommand.java Dosyayı Görüntüle

@@ -30,7 +30,7 @@ import uk.org.ownage.dmdirc.Server;
30 30
  * @author chris
31 31
  */
32 32
 public abstract class ChannelCommand extends Command {
33
-       
33
+    
34 34
     /** Creates a new instance of ChannelCommand */
35 35
     public ChannelCommand() {
36 36
         super();
@@ -38,9 +38,10 @@ public abstract class ChannelCommand extends Command {
38 38
     
39 39
     /**
40 40
      * Executes this command
41
+     * @param origin The window in which the command was typed
41 42
      * @param server The server instance that this command is being executed on
42 43
      * @param channel The channel instance that this command is being executed on
43 44
      * @param args Arguments passed to this command
44
-     */    
45
-    public abstract void execute(Server server, Channel channel, String... args);    
45
+     */
46
+    public abstract void execute(CommandWindow origin, Server server, Channel channel, String... args);
46 47
 }

+ 9
- 4
src/uk/org/ownage/dmdirc/commandparser/ChannelCommandParser.java Dosyayı Görüntüle

@@ -55,7 +55,8 @@ public class ChannelCommandParser extends CommandParser {
55 55
     
56 56
     /** Loads the relevant commands into the parser */
57 57
     protected void loadCommands() {
58
-        throw new UnsupportedOperationException("Not implemented yet");
58
+        CommandManager.loadChannelCommands(this);
59
+        CommandManager.loadServerCommands(this);
59 60
     }
60 61
     
61 62
     /**
@@ -65,7 +66,11 @@ public class ChannelCommandParser extends CommandParser {
65 66
      * @param args The arguments to the command
66 67
      */    
67 68
     protected void executeCommand(CommandWindow origin, Command command, String... args) {
68
-        throw new UnsupportedOperationException("Not implemented yet");
69
+        if (command instanceof ChannelCommand) {
70
+            ((ChannelCommand) command).execute(origin, server, channel, args);
71
+        } else {
72
+            ((ServerCommand) command).execute(origin, server, args);
73
+        }
69 74
     }
70 75
     
71 76
     /**
@@ -77,7 +82,7 @@ public class ChannelCommandParser extends CommandParser {
77 82
      * @param args The arguments passed to the command
78 83
      */    
79 84
     protected void handleInvalidCommand(CommandWindow origin, String command, String... args) {
80
-        throw new UnsupportedOperationException("Not implemented yet");
85
+        origin.addLine("Unknown command: "+command+"/"+(args.length-1));
81 86
     }
82 87
     
83 88
     /**
@@ -87,7 +92,7 @@ public class ChannelCommandParser extends CommandParser {
87 92
      * @param line The line input by the user
88 93
      */    
89 94
     protected void handleNonCommand(CommandWindow origin, String line) {
90
-        throw new UnsupportedOperationException("Not implemented yet");
95
+        channel.sendLine(line);
91 96
     }
92 97
     
93 98
 }

Loading…
İptal
Kaydet