Quellcode durchsuchen

Renamed: CallbackNotFound -> CallbackNotFoundException

Renamed: ProcessorNotFound -> ProcessorNotFoundException
pre005 isValidChannelName() now checks if the first character is either #, &, !, or + rather than just returning true regardless
ProcessMessage now allows for messages without a message param (eg ":foo!bar@baz privmsg #qux" is treated as ":foo!bar@baz privmsg #qux :", although I do believe this should enver happen)
ProcessMessage now also checks to see if it has accidentally recieved a NOTICE AUTH message, and forwards it to the correct processor if it has (Checks: Source is server, tokens 1+2 are "NOTICE AUTH")
"Got Join for channel I am not on" message now gives the parsers current host, not the user who joined (That can be seen in "lastline")
General Installer Changes
- Installer is now a thread that StepInstall calls to make the installing information appear as it happens, not all at once
- Shortcuts are now handled using an enum, and "Installers" can now specify which shortcut types apply to them.
Windows Installer Changes:
- Now copes with vista's changes to file locations
- Should in theory work on windows 95 and up (Altho java 6 only works on NT-Based versions of windows from 2000 and up so this is untested)
Linux Installer Changes:
- .desktop files created by root now call themselves DMDirc (Global)
- installing as root will not prompt to create a desktop shortcut


git-svn-id: http://svn.dmdirc.com/trunk@2022 00569f92-eb28-0410-84fd-f71c24880f
tags/0.5
Shane Mc Cormack vor 16 Jahren
Ursprung
Commit
8c4860040b

+ 2
- 2
src/com/dmdirc/Channel.java Datei anzeigen

@@ -33,7 +33,7 @@ import com.dmdirc.parser.ChannelInfo;
33 33
 import com.dmdirc.parser.ClientInfo;
34 34
 import com.dmdirc.parser.IRCParser;
35 35
 import com.dmdirc.parser.callbacks.CallbackManager;
36
-import com.dmdirc.parser.callbacks.CallbackNotFound;
36
+import com.dmdirc.parser.callbacks.CallbackNotFoundException;
37 37
 import com.dmdirc.parser.callbacks.interfaces.IAwayStateOther;
38 38
 import com.dmdirc.parser.callbacks.interfaces.IChannelAction;
39 39
 import com.dmdirc.parser.callbacks.interfaces.IChannelCTCP;
@@ -164,7 +164,7 @@ public final class Channel extends MessageTarget implements
164 164
             for (String callback : CALLBACKS) {
165 165
                 callbackManager.addCallback(callback, this, channel);
166 166
             }
167
-        } catch (CallbackNotFound ex) {
167
+        } catch (CallbackNotFoundException ex) {
168 168
             Logger.appError(ErrorLevel.FATAL, "Unable to load channel", ex);
169 169
         }
170 170
     }

+ 3
- 3
src/com/dmdirc/Query.java Datei anzeigen

@@ -30,7 +30,7 @@ import com.dmdirc.logger.Logger;
30 30
 import com.dmdirc.parser.ClientInfo;
31 31
 import com.dmdirc.parser.IRCParser;
32 32
 import com.dmdirc.parser.callbacks.CallbackManager;
33
-import com.dmdirc.parser.callbacks.CallbackNotFound;
33
+import com.dmdirc.parser.callbacks.CallbackNotFoundException;
34 34
 import com.dmdirc.parser.callbacks.interfaces.INickChanged;
35 35
 import com.dmdirc.parser.callbacks.interfaces.IPrivateAction;
36 36
 import com.dmdirc.parser.callbacks.interfaces.IPrivateMessage;
@@ -231,7 +231,7 @@ public final class Query extends MessageTarget implements
231 231
             callbackManager.addCallback("onPrivateMessage", this, ClientInfo.parseHost(host));
232 232
             callbackManager.addCallback("onQuit", this);
233 233
             callbackManager.addCallback("onNickChanged", this);
234
-        } catch (CallbackNotFound ex) {
234
+        } catch (CallbackNotFoundException ex) {
235 235
             Logger.appError(ErrorLevel.HIGH, "Unable to get query events", ex);
236 236
         }
237 237
     }
@@ -248,7 +248,7 @@ public final class Query extends MessageTarget implements
248 248
             try {
249 249
                 callbackManager.addCallback("onPrivateAction", this, cClient.getNickname());
250 250
                 callbackManager.addCallback("onPrivateMessage", this, cClient.getNickname());
251
-            } catch (CallbackNotFound ex) {
251
+            } catch (CallbackNotFoundException ex) {
252 252
                 Logger.appError(ErrorLevel.HIGH, "Unable to get query events", ex);
253 253
             }
254 254
             

+ 2
- 2
src/com/dmdirc/Raw.java Datei anzeigen

@@ -25,7 +25,7 @@ package com.dmdirc;
25 25
 import com.dmdirc.logger.ErrorLevel;
26 26
 import com.dmdirc.logger.Logger;
27 27
 import com.dmdirc.parser.IRCParser;
28
-import com.dmdirc.parser.callbacks.CallbackNotFound;
28
+import com.dmdirc.parser.callbacks.CallbackNotFoundException;
29 29
 import com.dmdirc.parser.callbacks.interfaces.IDataIn;
30 30
 import com.dmdirc.parser.callbacks.interfaces.IDataOut;
31 31
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -80,7 +80,7 @@ public final class Raw extends WritableFrameContainer implements IDataIn,
80 80
         try {
81 81
             server.getParser().getCallbackManager().addCallback("OnDataIn", this);
82 82
             server.getParser().getCallbackManager().addCallback("OnDataOut", this);
83
-        } catch (CallbackNotFound ex) {
83
+        } catch (CallbackNotFoundException ex) {
84 84
             Logger.appError(ErrorLevel.HIGH, "Unable to register raw callbacks", ex);
85 85
         }
86 86
     }

+ 2
- 2
src/com/dmdirc/Server.java Datei anzeigen

@@ -36,7 +36,7 @@ import com.dmdirc.parser.IRCParser;
36 36
 import com.dmdirc.parser.MyInfo;
37 37
 import com.dmdirc.parser.ParserError;
38 38
 import com.dmdirc.parser.ServerInfo;
39
-import com.dmdirc.parser.callbacks.CallbackNotFound;
39
+import com.dmdirc.parser.callbacks.CallbackNotFoundException;
40 40
 import com.dmdirc.parser.callbacks.interfaces.IAwayState;
41 41
 import com.dmdirc.parser.callbacks.interfaces.IAwayStateOther;
42 42
 import com.dmdirc.parser.callbacks.interfaces.IChannelSelfJoin;
@@ -300,7 +300,7 @@ public final class Server extends WritableFrameContainer implements
300 300
             for (String callback : CALLBACKS) {
301 301
                 parser.getCallbackManager().addCallback(callback, this);
302 302
             }
303
-        } catch (CallbackNotFound ex) {
303
+        } catch (CallbackNotFoundException ex) {
304 304
             Logger.appError(ErrorLevel.FATAL, "Unable to register server event handlers", ex);
305 305
         }
306 306
         

+ 45
- 13
src/com/dmdirc/installer/Installer.java Datei anzeigen

@@ -36,27 +36,50 @@ import java.nio.channels.FileChannel;
36 36
  *
37 37
  * @author Shane Mc Cormack
38 38
  */
39
-public abstract class Installer {
40
-	/** Put a shortcut on the desktop */
41
-	public static final int SHORTCUT_DESKTOP = 1;
42
-	/** Put a shortcut on the menu (kmenu, start menu etc) */
43
-	public static final int SHORTCUT_MENU = 2;
44
-	/** Put a shortcut on the quicklaunch bar (Windows Only) */
45
-	public static final int SHORTCUT_QUICKLAUNCH = 4;
39
+public abstract class Installer extends Thread {
40
+	/** Types of shortcut */
41
+	public static enum ShortcutType { DESKTOP, MENU, QUICKLAUNCH; }
42
+	
43
+	/** Step where things happen. */
44
+	protected StepInstall step = null;
46 45
 	
47 46
 	/**
48 47
 	 * Get the default install location
49 48
 	 */
50 49
 	abstract String defaultInstallLocation();
51 50
 	
51
+	/**
52
+	 * This is what helps actually perform the installation in run().
53
+	 * This is a hack to keep the installing and the GUI separate.
54
+	 *
55
+	 * @param step The step that called this
56
+	 */
57
+	public final void setInstallStep(final StepInstall step) {
58
+		this.step = step;
59
+	}
60
+	
61
+	/**
62
+	 * Create a new Installer
63
+	 */
64
+	public final void Installer() {
65
+		this.setName("Installer-Thread");
66
+	}
67
+	
68
+	/**
69
+	 * This step performs the installation, via the StepInstall step.
70
+	 */
71
+	public final void run() {
72
+		step.performInstall(this);
73
+	}
74
+	
52 75
 	/**
53 76
 	 * Main Setup stuff
54 77
 	 *
55 78
 	 * @param location Location where app will be installed to.
56 79
 	 * @param step The step that called this
57
-	 * @return TRue if installation passed, else false; 
80
+	 * @return True if installation passed, else false; 
58 81
 	 */
59
-	public boolean doSetup(final String location, final TextStep step) {
82
+	public boolean doSetup(final String location) {
60 83
 		// Create the directory
61 84
 		final File directory = new File(location);
62 85
 		if (!directory.exists()) { directory.mkdir(); }
@@ -88,13 +111,22 @@ public abstract class Installer {
88 111
 	}
89 112
 	
90 113
 	/**
91
-	 * Setup shortcuts
114
+	 * Check if this OS supports a given shortcut Type
115
+	 *
116
+	 * @param shortcutType Type of shortcut to check
117
+	 * @return True if this OS supports a given shortcut Type
118
+	 */
119
+	public boolean supportsShortcut(final ShortcutType shortcutType) {
120
+		return false;
121
+	}
122
+	
123
+	/**
124
+	 * Setup shortcut
92 125
 	 *
93 126
 	 * @param location Location where app will be installed to.
94
-	 * @param step The step that called this
95
-	 * @param shortcutType TYpe of shortcuts to add.
127
+	 * @param shortcutType Type of shortcut to add.
96 128
 	 */
97
-	abstract void setupShortcuts(final String location, final TextStep step, final int shortcutType);
129
+	abstract void setupShortcut(final String location, final ShortcutType shortcutType);
98 130
 	
99 131
 	/**
100 132
 	 * Copy a file from one location to another.

+ 63
- 18
src/com/dmdirc/installer/LinuxInstaller.java Datei anzeigen

@@ -34,43 +34,84 @@ import java.io.IOException;
34 34
  * @author Shane Mc Cormack
35 35
  */
36 36
 public class LinuxInstaller extends Installer {
37
+	/**
38
+	 * Are we running as root?
39
+	 */
40
+	private boolean isRoot() {
41
+		return (CLIParser.getCLIParser().getParamNumber("-isroot") > 0);
42
+	}
43
+
37 44
 	/**
38 45
 	 * Get the default install location
39 46
 	 */
40 47
 	public String defaultInstallLocation() {
41
-		if (CLIParser.getCLIParser().getParamNumber("-isroot") > 0) {
48
+		if (isRoot()) {
42 49
 			return "/usr/local/DMDirc";
43 50
 		} else {
44 51
 			return System.getProperty("user.home") + "/DMDirc";
45 52
 		}
46 53
 	}
47
-	 
54
+	
48 55
 	/**
49
-	 * Setup shortcuts
56
+	 * Check if this OS supports a given shortcut Type
57
+	 *
58
+	 * @param shortcutType Type of shortcut to check
59
+	 * @return True if this OS supports a given shortcut Type
60
+	 */
61
+	public boolean supportsShortcut(final ShortcutType shortcutType) {
62
+		switch (shortcutType) {
63
+			case QUICKLAUNCH:
64
+				return false;
65
+			case DESKTOP:
66
+				// No desktop for root
67
+				return !isRoot();
68
+			case MENU:
69
+				// Both root and non-root have a menu
70
+				return true;
71
+			default:
72
+				// Anything else that gets added should be false until the relevent
73
+				// code is added
74
+				return false;
75
+		}
76
+	}
77
+
78
+	/**
79
+	 * Setup shortcut
50 80
 	 *
51 81
 	 * @param location Location where app will be installed to.
52
-	 * @param step The step that called this
53
-	 * @param shortcutType TYpe of shortcuts to add.
82
+	 * @param shortcutType Type of shortcut to add.
54 83
 	 */
55
-	public void setupShortcuts(final String location, final TextStep step, final int shortcutType) {
84
+	public void setupShortcut(final String location, final ShortcutType shortcutType) {
85
+		if (!supportsShortcut(shortcutType)) {
86
+			step.addText(" - Error creating shortcut. Not applicable to this Operating System");
87
+			return;
88
+		}
89
+		
56 90
 		PrintWriter writer = null;
57 91
 		try {
58 92
 			String filename;
59
-			if ((shortcutType & SHORTCUT_DESKTOP) == SHORTCUT_DESKTOP) {
60
-				filename = System.getProperty("user.home")+"/Desktop/DMDirc.desktop";
61
-			} else if ((shortcutType & SHORTCUT_MENU) == SHORTCUT_MENU) {
62
-				if (CLIParser.getCLIParser().getParamNumber("-isroot") > 0) {
63
-					filename = "/usr/share/applications/DMDirc.desktop";
64
-				} else {
65
-					filename = System.getProperty("user.home")+"/.local/share/applications/DMDirc.desktop";
66
-				}
67
-			} else {
68
-				return;
93
+
94
+			switch (shortcutType) {
95
+				case DESKTOP:
96
+					filename = System.getProperty("user.home")+"/Desktop/DMDirc.desktop";
97
+					break;
98
+					
99
+				case MENU:
100
+					if (CLIParser.getCLIParser().getParamNumber("-isroot") > 0) {
101
+						filename = "/usr/share/applications/DMDirc.desktop";
102
+					} else {
103
+						filename = System.getProperty("user.home")+"/.local/share/applications/DMDirc.desktop";
104
+					}
105
+					break;
106
+					
107
+				default:
108
+					step.addText(" - Error creating shortcut. Not applicable to this Operating System");
109
+					return;
69 110
 			}
70 111
 			writer = new PrintWriter(filename);
71 112
 			writeFile(writer, location);
72 113
 		} catch (Exception e) {
73
-			step.addText("Error creating shortcuts: "+e.toString());
114
+			step.addText(" - Error creating shortcut: "+e.toString());
74 115
 		} finally {
75 116
 			if (writer != null) {
76 117
 				writer.close();
@@ -93,7 +134,11 @@ public class LinuxInstaller extends Installer {
93 134
 		writer.println("Exec=java -jar "+location+"/DMDirc.jar");
94 135
 		writer.println("GenericName=IRC Client");
95 136
 		writer.println("Icon="+location+"/icon.svg");
96
-		writer.println("Name=DMDirc");
137
+		if (isRoot()) {
138
+			writer.println("Name=DMDirc (Global)");
139
+		} else {
140
+			writer.println("Name=DMDirc");
141
+		}
97 142
 		writer.println("StartupNotify=true");
98 143
 		writer.println("Terminal=false");
99 144
 		writer.println("TerminalOptions=");

+ 22
- 9
src/com/dmdirc/installer/Main.java Datei anzeigen

@@ -57,14 +57,14 @@ public final class Main implements Wizard {
57 57
 	public void stepChanged(final int oldStep, final int newStep) {	}
58 58
 
59 59
 	/**
60
-	 * Called when the wizard finishes. 
60
+	 * Called when the wizard finishes.
61 61
 	 */
62 62
 	public void wizardFinished() { }
63 63
 
64 64
 	/**
65
-	 * Displays the Installer wizard.
65
+	 * Creates and Displays the Installer wizard.
66 66
 	 */
67
-	public void display() {
67
+	private Main() {
68 68
 		final List<Step> steps = new ArrayList<Step>();
69 69
 		final String osName = System.getProperty("os.name");
70 70
 		
@@ -82,9 +82,8 @@ public final class Main implements Wizard {
82 82
 			releaseName = " "+cli.getParam("-release").getStringValue();
83 83
 		}
84 84
 		
85
-		wizardDialog = new WizardDialog("DMDirc"+releaseName+" Installer", steps, this);
85
+		setWizardDialog(new WizardDialog("DMDirc"+releaseName+" Installer", steps, this));
86 86
 		wizardDialog.setPreferredSize(new Dimension(400, 350));
87
-		wizardDialog.display();
88 87
 	}
89 88
 	
90 89
 	/**
@@ -111,24 +110,38 @@ public final class Main implements Wizard {
111 110
 	 */
112 111
 	private static void setupCLIParser() {
113 112
 		cli.clear();
114
-		cli.add(new BooleanParam((char)0, "isRoot", "Installing as Root"));
113
+		cli.add(new BooleanParam((char)0, "isroot", "Installing as Root"));
115 114
 		cli.add(new StringParam('r', "release", "Release Name"));
116 115
 	}
117 116
 	
118 117
 	/**
119 118
 	 * Get the WizardDialog
119
+	 *
120
+	 * @return The current wizardDialog
120 121
 	 */
121
-	public static WizardDialog getWizardDialog () {
122
+	public static synchronized WizardDialog getWizardDialog() {
123
+		if (wizardDialog == null) {
124
+			new Main();
125
+		}
122 126
 		return wizardDialog;
123 127
 	}
128
+	
129
+	/**
130
+	 * Set the WizardDialog
131
+	 *
132
+	 * @return Set the current wizardDialog to the given one
133
+	 */
134
+	private static void setWizardDialog(final WizardDialog dialog) {
135
+		wizardDialog = dialog;
136
+	}
124 137
 
125 138
 	/**
126 139
 	 * Run the installer
127 140
 	 */
128 141
 	public static void main (String[] args) {
142
+		System.out.println("");
129 143
 		setupCLIParser();
130 144
 		cli.parseArgs(args, false);
131
-		
132
-		new Main().display();
145
+		getWizardDialog().display();
133 146
 	}
134 147
 }

+ 14
- 9
src/com/dmdirc/installer/StepConfirm.java Datei anzeigen

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.installer;
24 24
 
25
+import com.dmdirc.installer.Installer.ShortcutType;
25 26
 import com.dmdirc.installer.WindowsInstaller;
26 27
 import com.dmdirc.ui.swing.dialogs.wizard.SpecialStep;
27 28
 import com.dmdirc.ui.swing.dialogs.wizard.Step;
@@ -73,19 +74,23 @@ public final class StepConfirm extends Step implements SpecialStep {
73 74
 		
74 75
 		StepSettings settings = ((StepSettings) Main.getWizardDialog().getStep(1));
75 76
 		
76
-		if (settings.getShortcutMenuState()) {
77
-			shortcutText = shortcutText + " - Do Set up Menu shortcuts"+ "\n";
78
-		} else {
79
-			shortcutText = shortcutText + " - Do Not Set up Menu shortcuts"+ "\n";
77
+		if (Main.getInstaller().supportsShortcut(ShortcutType.MENU)) {
78
+			if (settings.getShortcutMenuState()) {
79
+				shortcutText = shortcutText + " - Do Set up Menu shortcuts"+ "\n";
80
+			} else {
81
+				shortcutText = shortcutText + " - Do Not Set up Menu shortcuts"+ "\n";
82
+			}
80 83
 		}
81 84
 		
82
-		if (settings.getShortcutDesktopState()) {
83
-			shortcutText = shortcutText + " - Do Set up Desktop shortcuts"+ "\n";
84
-		} else {
85
-			shortcutText = shortcutText + " - Do Not Set up Desktop shortcuts"+ "\n";
85
+		if (Main.getInstaller().supportsShortcut(ShortcutType.DESKTOP)) {
86
+			if (settings.getShortcutDesktopState()) {
87
+				shortcutText = shortcutText + " - Do Set up Desktop shortcuts"+ "\n";
88
+			} else {
89
+				shortcutText = shortcutText + " - Do Not Set up Desktop shortcuts"+ "\n";
90
+			}
86 91
 		}
87 92
 		
88
-		if (Main.getInstaller() instanceof WindowsInstaller && ((WindowsInstaller)Main.getInstaller()).showQuicklaunch()) {
93
+		if (Main.getInstaller().supportsShortcut(ShortcutType.QUICKLAUNCH)) {
89 94
 			if (settings.getShortcutQuickState()) {
90 95
 				shortcutText = shortcutText + " - Do Set up Quick Launch shortcuts"+ "\n";
91 96
 			} else {

+ 29
- 16
src/com/dmdirc/installer/StepInstall.java Datei anzeigen

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.installer;
24 24
 
25
-import com.dmdirc.installer.WindowsInstaller;
25
+import com.dmdirc.installer.Installer.ShortcutType;
26 26
 import com.dmdirc.ui.swing.dialogs.wizard.SpecialStep;
27 27
 import com.dmdirc.ui.swing.dialogs.wizard.TextStep;
28 28
 import com.dmdirc.ui.swing.dialogs.wizard.Step;
@@ -80,34 +80,47 @@ public final class StepInstall extends Step implements SpecialStep, TextStep {
80 80
 	 */
81 81
 	public void showStep() {
82 82
 		Main.getWizardDialog().enableNextStep(false);
83
+		Main.getWizardDialog().enablePreviousStep(false);
84
+		Main.getInstaller().setInstallStep(this);
85
+		Main.getInstaller().start();
86
+	}
87
+	
88
+	/**
89
+	 * Perform the installation.
90
+	 */
91
+	public void performInstall(final Installer myInstaller) {
83 92
 		infoLabel.setText("Beginning Install..\n");
84 93
 		final String location = ((StepSettings) Main.getWizardDialog().getStep(1)).getInstallLocation();
85 94
 		
86 95
 		addText("Installing files to: "+location);
87
-		Main.getInstaller().doSetup(location, this);
96
+		myInstaller.doSetup(location);
88 97
 		
89 98
 		StepSettings settings = ((StepSettings) Main.getWizardDialog().getStep(1));
90 99
 		
91
-		if (settings.getShortcutMenuState()) {
92
-			addText("Setting up Menu shortcuts");
93
-			Main.getInstaller().setupShortcuts(location, this, Installer.SHORTCUT_MENU);
94
-		} else {
95
-			addText("Not setting up Menu shortcuts");
100
+		if (Main.getInstaller().supportsShortcut(ShortcutType.MENU)) {
101
+			if (settings.getShortcutMenuState()) {
102
+				addText("Setting up Menu shortcut");
103
+				myInstaller.setupShortcut(location, ShortcutType.MENU);
104
+			} else {
105
+				addText("Not setting up Menu shortcut");
106
+			}
96 107
 		}
97 108
 		
98
-		if (settings.getShortcutDesktopState()) {
99
-			addText("Setting up Desktop shortcuts");
100
-			Main.getInstaller().setupShortcuts(location, this, Installer.SHORTCUT_DESKTOP);
101
-		} else {
102
-			addText("Not setting up Desktop shortcuts");
109
+		if (Main.getInstaller().supportsShortcut(ShortcutType.DESKTOP)) {
110
+			if (settings.getShortcutDesktopState()) {
111
+				addText("Setting up Desktop shortcut");
112
+				myInstaller.setupShortcut(location, ShortcutType.DESKTOP);
113
+			} else {
114
+				addText("Not setting up Desktop shortcut");
115
+			}
103 116
 		}
104 117
 		
105
-		if (Main.getInstaller() instanceof WindowsInstaller && ((WindowsInstaller)Main.getInstaller()).showQuicklaunch()) {
118
+		if (Main.getInstaller().supportsShortcut(ShortcutType.QUICKLAUNCH)) {
106 119
 			if (settings.getShortcutQuickState()) {
107
-				addText("Setting up QuickLaunch shortcuts");
108
-				Main.getInstaller().setupShortcuts(location, this, Installer.SHORTCUT_QUICKLAUNCH);
120
+				addText("Setting up QuickLaunch shortcut");
121
+				myInstaller.setupShortcut(location, ShortcutType.QUICKLAUNCH);
109 122
 			} else {
110
-				addText("Not setting up QuickLaunch shortcuts");
123
+				addText("Not setting up QuickLaunch shortcut");
111 124
 			}
112 125
 		}
113 126
 		

+ 12
- 6
src/com/dmdirc/installer/StepSettings.java Datei anzeigen

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.installer;
24 24
 
25
+import com.dmdirc.installer.Installer.ShortcutType;
25 26
 import com.dmdirc.installer.WindowsInstaller;
26 27
 import com.dmdirc.ui.swing.dialogs.wizard.Step;
27 28
 import static com.dmdirc.ui.swing.UIUtilities.LARGE_BORDER;
@@ -97,16 +98,21 @@ public final class StepSettings extends Step {
97 98
 		add(location, constraints);
98 99
 		
99 100
 		constraints.gridwidth = 2;
100
-		constraints.gridy = 3;
101 101
 		constraints.gridx = 0;
102 102
 		constraints.insets = new Insets(SMALL_BORDER, 0, 0, 0);
103
-		add(shortcutMenu, constraints);
104 103
 		
105
-		constraints.gridy = 4;
106
-		add(shortcutDesktop, constraints);
104
+		if (Main.getInstaller().supportsShortcut(ShortcutType.MENU)) {
105
+			constraints.gridy = (constraints.gridy + 1);
106
+			add(shortcutMenu, constraints);
107
+		}
108
+		
109
+		if (Main.getInstaller().supportsShortcut(ShortcutType.DESKTOP)) {
110
+			constraints.gridy = (constraints.gridy + 1);
111
+			add(shortcutDesktop, constraints);
112
+		}
107 113
 		
108
-		if (Main.getInstaller() instanceof WindowsInstaller && ((WindowsInstaller)Main.getInstaller()).showQuicklaunch()) {
109
-			constraints.gridy = 5;
114
+		if (Main.getInstaller().supportsShortcut(ShortcutType.QUICKLAUNCH)) {
115
+			constraints.gridy = (constraints.gridy + 1);
110 116
 			add(shortcutQuick, constraints);
111 117
 		}
112 118
 		

+ 19
- 2
src/com/dmdirc/installer/StreamReader.java Datei anzeigen

@@ -31,6 +31,9 @@ public class StreamReader extends Thread {
31 31
 	/** This is the Input Stream we are reading */
32 32
 	private InputStream stream;
33 33
 	
34
+	/** This is the Input Stream we are reading */
35
+	private String prefix = null;
36
+	
34 37
 	/**
35 38
 	 * Create a new Stream Reader
36 39
 	 *
@@ -39,12 +42,26 @@ public class StreamReader extends Thread {
39 42
 	public StreamReader(final InputStream stream) {
40 43
 		this.stream = stream;
41 44
 	}
45
+	
46
+	/**
47
+	 * Create a new Stream Reader that outputs to the console
48
+	 *
49
+	 * @param stream The stream to read
50
+	 * @param prefix Prefix of outputed messages
51
+	 */
52
+	public StreamReader(final InputStream stream, final String prefix) {
53
+		this.stream = stream;
54
+		this.prefix = prefix;
55
+	}
42 56
 
43 57
 	public void run() {
44 58
 		BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
45 59
 		try {
46
-			while (reader.readLine() != null) {
47
-				/* Do Nothing */
60
+			String line;
61
+			while ((line = reader.readLine()) != null) {
62
+				if (prefix != null) {
63
+					System.out.printf("[%s] %s%n", prefix, line);
64
+				}
48 65
 			}
49 66
 		} catch (IOException e) {
50 67
 			e.printStackTrace();

+ 68
- 39
src/com/dmdirc/installer/WindowsInstaller.java Datei anzeigen

@@ -67,56 +67,78 @@ public class WindowsInstaller extends Installer {
67 67
 	}
68 68
 	
69 69
 	/**
70
-	 * Check if this OS has quicklaunch
70
+	 * Check if this OS supports a given shortcut Type
71 71
 	 *
72
-	 * @return True if this OS hash a quick launch toolbar
72
+	 * @param shortcutType Type of shortcut to check
73
+	 * @return True if this OS supports a given shortcut Type
73 74
 	 */
74
-	public boolean showQuicklaunch() {
75
-		// return !(System.getProperty("os.name").indexOf("95") >= 0);
76
-		
77
-		// Disabled due to quicklaunch not being in a fixed location/language
78
-		return false;
75
+	public boolean supportsShortcut(final ShortcutType shortcutType) {
76
+		switch (shortcutType) {
77
+			case QUICKLAUNCH:
78
+				// Only windows 95 doesn't have quick launch
79
+				return !(System.getProperty("os.name").indexOf("95") >= 0);
80
+			case DESKTOP:
81
+			case MENU:
82
+				// All versions of windows have desktop and menu
83
+				return true;
84
+			default:
85
+				// Anything else that gets added should be false until the relevent
86
+				// code is added
87
+				return false;
88
+		}
79 89
 	}
80 90
 	
81 91
 	/**
82
-	 * Setup shortcuts
92
+	 * Setup shortcut
83 93
 	 *
84 94
 	 * @param location Location where app will be installed to.
85
-	 * @param step The step that called this
86
-	 * @param shortcutType TYpe of shortcuts to add.
95
+	 * @param shortcutType Type of shortcut to add.
87 96
 	 */
88
-	public void setupShortcuts(final String location, final TextStep step, final int shortcutType) {
97
+	public void setupShortcut(final String location, final ShortcutType shortcutType) {
89 98
 		// Shortcut.exe is from http://www.optimumx.com/download/#Shortcut
99
+		
100
+		if (!supportsShortcut(shortcutType)) {
101
+			step.addText(" - Error creating shortcut. Not applicable to this Operating System");
102
+			return;
103
+		}
104
+		
90 105
 		if (new File("Shortcut.exe").exists()) {
91 106
 			String filename = "";
92 107
 			File dir;
93 108
 			
94
-			if ((shortcutType & SHORTCUT_DESKTOP) == SHORTCUT_DESKTOP) {
95
-				if (isNT() || isVista()) {
96
-					filename = System.getProperty("user.home")+"\\Desktop";
97
-				} else {
98
-					filename = System.getenv("WINDIR")+"\\Desktop";
99
-				}
100
-			} else if ((shortcutType & SHORTCUT_MENU) == SHORTCUT_MENU) {
101
-				if (isVista()) {
102
-					filename = System.getenv("APPDATA")+"\\Roaming\\Microsoft\\Windows";
103
-				} else {
104
-					filename = System.getProperty("user.home");
105
-				}
106
-				filename = filename+"\\Start Menu\\Programs\\DMDirc";
107
-			
108
-			} else if ((shortcutType & SHORTCUT_QUICKLAUNCH) == SHORTCUT_QUICKLAUNCH && showQuicklaunch()) {
109
-				if (isVista()) {
110
-				
111
-				} else {
112
-					filename = System.getProperty("user.home")+"\\Application Data\\Microsoft\\Internet Explorer\\Quick Launch";
113
-				}
114
-			} else {
115
-				return;
109
+			switch (shortcutType) {
110
+				case DESKTOP:
111
+					if (isNT() || isVista()) {
112
+						filename = System.getProperty("user.home")+"\\Desktop";
113
+					} else {
114
+						filename = System.getenv("WINDIR")+"\\Desktop";
115
+					}
116
+					break;
117
+					
118
+				case MENU:
119
+					if (isVista()) {
120
+						filename = System.getenv("APPDATA")+"\\Microsoft\\Windows";
121
+					} else {
122
+						filename = System.getProperty("user.home");
123
+					}
124
+					filename = filename+"\\Start Menu\\Programs\\DMDirc";
125
+					break;
126
+					
127
+				case QUICKLAUNCH:
128
+					if (isVista()) {
129
+						filename = System.getProperty("user.home")+"\\AppData\\Roaming\\Microsoft\\Internet Explorer\\Quick Launch";
130
+					} else {
131
+						filename = System.getProperty("user.home")+"\\Application Data\\Microsoft\\Internet Explorer\\Quick Launch";
132
+					}
133
+					break;
134
+					
135
+				default:
136
+					step.addText(" - Error creating shortcut. Not applicable to this Operating System");
137
+					return;
116 138
 			}
117 139
 			
118 140
 			if (filename.length() == 0) {
119
-				step.addText("Error creating shortcut. Not applicable to this System");
141
+				step.addText(" - Error creating shortcut. Not applicable to this System");
120 142
 				return;
121 143
 			}
122 144
 			
@@ -130,7 +152,7 @@ public class WindowsInstaller extends Installer {
130 152
 			
131 153
 			try {
132 154
 //				final String thisDirName = new File("").getAbsolutePath();
133
-				final Process shortcutProcess = Runtime.getRuntime().exec(new String[] {
155
+					final String[] command = new String[] {
134 156
 //				                      thisDirName+"/Shortcut.exe",
135 157
 				                      "Shortcut.exe",
136 158
 				                      "/F:"+filename+"\\DMDirc.lnk",
@@ -141,18 +163,25 @@ public class WindowsInstaller extends Installer {
141 163
 				                      "/W:"+location,
142 164
 				                      "/I:"+location+"\\icon.ico",
143 165
 				                      "/D:DMDirc IRC Client"
144
-				                      });
166
+				                      };
167
+				final Process shortcutProcess = Runtime.getRuntime().exec(command);
145 168
 				new StreamReader(shortcutProcess.getInputStream()).start();
146 169
 				new StreamReader(shortcutProcess.getErrorStream()).start();
147 170
 				shortcutProcess.waitFor();
148 171
 				if (shortcutProcess.exitValue() != 0) {
149
-					step.addText("Error creating shortcuts: Unknown Reason");
172
+					step.addText(" - Error creating shortcut: Unknown Reason");
173
+					System.out.println(java.util.Arrays.toString(command));
174
+					System.out.println("");
175
+					for (String bit : command) {
176
+						System.out.print(bit+' ');
177
+					}
178
+					System.out.println("");
150 179
 				}
151 180
 			} catch (Exception e) {
152
-				step.addText("Error creating shortcut: "+e.getMessage());
181
+				step.addText(" - Error creating shortcut: "+e.getMessage());
153 182
 			}
154 183
 		} else {
155
-			step.addText("Error creating shortcuts: Unable to find Shortcut.exe");
184
+			step.addText(" - Error creating shortcut: Unable to find Shortcut.exe");
156 185
 		}
157 186
 	}
158 187
 }

+ 7
- 2
src/com/dmdirc/parser/IRCParser.java Datei anzeigen

@@ -1474,11 +1474,16 @@ public final class IRCParser implements Runnable {
1474 1474
 		if (sChannelName == null || sChannelName.isEmpty()) { return false; }
1475 1475
 		// Check its not ourself (PM recieved before 005)
1476 1476
 		if (equalsIgnoreCase(getMyNickname(), sChannelName)) { return false; }
1477
+		// Check if we know of any valid chan prefixes
1478
+		if (hChanPrefix.size() == 0) {
1479
+			// We don't. Lets check against RFC2811-Specified channel types
1480
+			char first = sChannelName.charAt(0);
1481
+			return first == '#' || first == '&' || first == '!' || first == '+';
1482
+		}
1477 1483
 		// Otherwise return true if:
1478
-		// 005 has not been recieved yet
1479 1484
 		// Channel equals "0"
1480 1485
 		// first character of the channel name is a valid channel prefix.
1481
-		return hChanPrefix.size() == 0 || hChanPrefix.containsKey(sChannelName.charAt(0)) || sChannelName.equals("0");
1486
+		return hChanPrefix.containsKey(sChannelName.charAt(0)) || sChannelName.equals("0");
1482 1487
 	}
1483 1488
 	
1484 1489
 	/**

+ 1
- 1
src/com/dmdirc/parser/ProcessJoin.java Datei anzeigen

@@ -56,7 +56,7 @@ public class ProcessJoin extends IRCProcessor {
56 56
 		if (iClient.getHost().isEmpty()) { iClient.setUserBits(token[0],false); }
57 57
 		if (iChannel == null) { 
58 58
 			if (iClient != myParser.cMyself) {
59
-				callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Got join for channel ("+token[token.length-1]+") that I am not on. [User: "+token[0]+"]", myParser.getLastLine()));
59
+				callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Got join for channel ("+token[token.length-1]+") that I am not on. [Me: "+myParser.getMyself()+"]", myParser.getLastLine()));
60 60
 			}
61 61
 			iChannel = new ChannelInfo(myParser, token[token.length-1]);
62 62
 			myParser.hChannelList.put(myParser.toLowerCase(iChannel.getName()),iChannel);

+ 16
- 3
src/com/dmdirc/parser/ProcessMessage.java Datei anzeigen

@@ -69,14 +69,27 @@ public class ProcessMessage extends IRCProcessor {
69 69
 		if (myParser.getIgnoreList().matches(sMessage) > -1) { return; }
70 70
 		
71 71
 		// Lines such as:
72
-		// "nick!user@host PRIVMSG #channel"
72
+		// "nick!user@host PRIVMSG"
73 73
 		// are invalid, stop processing.
74
-		if (token.length < 4) { return; }
74
+		if (token.length < 3) { return; }
75
+		
76
+		// Is this actually a notice auth?
77
+		if (token[0].indexOf('!') == -1 && token[1].equalsIgnoreCase("NOTICE") && token[2].equalsIgnoreCase("AUTH")) {
78
+			try {
79
+				myParser.getProcessingManager().process("Notice Auth", token);
80
+			} catch (ProcessorNotFoundException e) { }
81
+			return;
82
+		}
75 83
 		
76 84
 		ChannelClientInfo iChannelClient = null;
77 85
 		ChannelInfo iChannel = null;
78 86
 		ClientInfo iClient = null;
79
-		sMessage = token[token.length-1];
87
+		// "nick!user@host PRIVMSG #Channel" should be processed as "nick!user@host PRIVMSG #Channel :"
88
+		if (token.length < 4) {
89
+			sMessage = "";
90
+		} else {
91
+			sMessage = token[token.length-1];
92
+		}
80 93
 		String bits[] = sMessage.split(" ", 2);
81 94
 		final Character Char1 = Character.valueOf((char)1);
82 95
 		String sCTCP = "";

+ 5
- 5
src/com/dmdirc/parser/ProcessingManager.java Datei anzeigen

@@ -189,11 +189,11 @@ public class ProcessingManager {
189 189
 	 * @param sParam Type of line to process ("005", "PRIVMSG" etc)
190 190
 	 * @return IRCProcessor for the given param.
191 191
 	 */
192
-	public IRCProcessor getProcessor(final String sParam) throws ProcessorNotFound {
192
+	public IRCProcessor getProcessor(final String sParam) throws ProcessorNotFoundException {
193 193
 		if (processHash.containsKey(sParam.toLowerCase())) {
194 194
 			return processHash.get(sParam.toLowerCase());
195 195
 		} else {
196
-			throw new ProcessorNotFound("No processors will handle "+sParam);
196
+			throw new ProcessorNotFoundException("No processors will handle "+sParam);
197 197
 		}
198 198
 	}
199 199
 	
@@ -202,14 +202,14 @@ public class ProcessingManager {
202 202
 	 *
203 203
 	 * @param sParam Type of line to process ("005", "PRIVMSG" etc)
204 204
 	 * @param token IRCTokenised line to process
205
-	 * @throws ProcessorNotFound exception if no processors exists to handle the line
205
+	 * @throws ProcessorNotFoundException exception if no processors exists to handle the line
206 206
 	 */
207
-	public void process(final String sParam, final String[] token) throws ProcessorNotFound {
207
+	public void process(final String sParam, final String[] token) throws ProcessorNotFoundException {
208 208
 		IRCProcessor messageProcessor = null;
209 209
 		try {
210 210
 			messageProcessor = getProcessor(sParam);
211 211
 			messageProcessor.process(sParam, token);
212
-		} catch (ProcessorNotFound p) {
212
+		} catch (ProcessorNotFoundException p) {
213 213
 			throw p;
214 214
 		} catch (Exception e) {
215 215
 			final StringBuilder line = new StringBuilder();

src/com/dmdirc/parser/ProcessorNotFound.java → src/com/dmdirc/parser/ProcessorNotFoundException.java Datei anzeigen

@@ -30,7 +30,7 @@ package com.dmdirc.parser;
30 30
  * @author Shane Mc Cormack
31 31
  * @version $Id$
32 32
  */
33
-public class ProcessorNotFound extends Exception {
33
+public class ProcessorNotFoundException extends Exception {
34 34
 	/**
35 35
 	 * A version number for this class. It should be changed whenever the class
36 36
 	 * structure is changed (or anything else that would prevent serialized
@@ -43,7 +43,7 @@ public class ProcessorNotFound extends Exception {
43 43
 	 *
44 44
 	 * @param message Reason for exception
45 45
 	 */
46
-	public ProcessorNotFound(final String message) { super(message); }
46
+	public ProcessorNotFoundException(final String message) { super(message); }
47 47
 	
48 48
 	/**
49 49
 	 * Get SVN Version information.

+ 9
- 9
src/com/dmdirc/parser/callbacks/CallbackManager.java Datei anzeigen

@@ -177,35 +177,35 @@ public final class CallbackManager {
177 177
 	
178 178
 	/**
179 179
 	 * Add a callback.
180
- 	 * This method will throw a CallbackNotFound Exception if the callback does not exist.
180
+ 	 * This method will throw a CallbackNotFoundException if the callback does not exist.
181 181
 	 *
182 182
 	 * @param callbackName Name of callback object.
183 183
 	 * @param o instance of ICallbackInterface to add.
184
-	 * @throws CallbackNotFound If callback is not found.
184
+	 * @throws CallbackNotFoundException If callback is not found.
185 185
 	 * @throws NullPointerException If 'o' is null
186 186
 	 */
187
-	public void addCallback(final String callbackName, final ICallbackInterface o) throws CallbackNotFound {
187
+	public void addCallback(final String callbackName, final ICallbackInterface o) throws CallbackNotFoundException {
188 188
 		if (o == null) { throw new NullPointerException("CallbackInterface is null"); }
189 189
 		final CallbackObject cb = getCallbackType(callbackName);
190 190
 		if (cb != null) { cb.add(o); }
191
-		else { throw new CallbackNotFound("Callback '"+callbackName+"' could not be found."); }
191
+		else { throw new CallbackNotFoundException("Callback '"+callbackName+"' could not be found."); }
192 192
 	}
193 193
 	
194 194
 	/**
195 195
 	 * Add a callback with a specific target.
196
- 	 * This method will throw a CallbackNotFound Exception if the callback does not exist.
196
+ 	 * This method will throw a CallbackNotFoundException if the callback does not exist.
197 197
 	 *
198 198
 	 * @param callbackName Name of callback object.
199 199
 	 * @param o instance of ICallbackInterface to add.
200 200
 	 * @param target Parameter to specify that a callback should only fire for specific things
201
-	 * @throws CallbackNotFound If callback is not found.
201
+	 * @throws CallbackNotFoundException If callback is not found.
202 202
 	 * @throws NullPointerException If 'o' is null
203 203
 	 */
204
-	public void addCallback(final String callbackName, final ICallbackInterface o, final String target) throws CallbackNotFound {
204
+	public void addCallback(final String callbackName, final ICallbackInterface o, final String target) throws CallbackNotFoundException {
205 205
 		if (o == null) { throw new NullPointerException("CallbackInterface is null"); }
206 206
 		CallbackObjectSpecific cb = (CallbackObjectSpecific)getCallbackType(callbackName);
207 207
 		if (cb != null) { cb.add(o,target); }
208
-		else { throw new CallbackNotFound("Callback '"+callbackName+"' could not be found."); }
208
+		else { throw new CallbackNotFoundException("Callback '"+callbackName+"' could not be found."); }
209 209
 	}
210 210
 	
211 211
 	/**
@@ -230,7 +230,7 @@ public final class CallbackManager {
230 230
 	 * @param callbackName Name of callback object.
231 231
 	 * @param o instance of ICallbackInterface to add.
232 232
 	 * @param target Parameter to specify that a callback should only fire for specific things
233
-	 * @throws CallbackNotFound If callback is not found.
233
+	 * @throws CallbackNotFoundException If callback is not found.
234 234
 	 */
235 235
 	public boolean addNonCriticalCallback(final String callbackName, final ICallbackInterface o, final String target) {
236 236
 		try {

src/com/dmdirc/parser/callbacks/CallbackNotFound.java → src/com/dmdirc/parser/callbacks/CallbackNotFoundException.java Datei anzeigen

@@ -30,7 +30,7 @@ package com.dmdirc.parser.callbacks;
30 30
  * @author            Shane Mc Cormack
31 31
  * @version           $Id$
32 32
  */
33
-public class CallbackNotFound extends Exception {
33
+public class CallbackNotFoundException extends Exception {
34 34
 	/**
35 35
 	 * A version number for this class. It should be changed whenever the class
36 36
 	 * structure is changed (or anything else that would prevent serialized
@@ -43,7 +43,7 @@ public class CallbackNotFound extends Exception {
43 43
 	 *
44 44
 	 * @param message Reason for exception
45 45
 	 */
46
-	public CallbackNotFound(final String message) { super(message); }
46
+	public CallbackNotFoundException(final String message) { super(message); }
47 47
 	
48 48
 	/**
49 49
 	 * Get SVN Version information.

+ 9
- 0
src/com/dmdirc/ui/swing/dialogs/wizard/WizardDialog.java Datei anzeigen

@@ -253,6 +253,15 @@ public final class WizardDialog extends JFrame implements ActionListener,
253 253
         next.setEnabled(newValue);
254 254
     }
255 255
     
256
+    /**
257
+     * Enables or disables the "previous step" button.
258
+     *
259
+     * @param newValue boolean true to make "previous" button enabled, else false
260
+     */
261
+    public void enablePreviousStep(final boolean newValue) {
262
+        prev.setEnabled(newValue);
263
+    }
264
+    
256 265
     /** Moves to the next step. */
257 266
     private void nextStep() {
258 267
         steps.get(currentStep).setVisible(false);

Laden…
Abbrechen
Speichern