Browse Source

Fixed ParserError again.

IRCParser now does all debugging via onDebugInfo regardless of bDebug. (altho some will be removed if bDebug is set to false)


git-svn-id: http://svn.dmdirc.com/trunk@185 00569f92-eb28-0410-84fd-f71c24880f
tags/0.1
Shane Mc Cormack 17 years ago
parent
commit
f7e1a55ba3

+ 32
- 23
src/uk/org/ownage/dmdirc/parser/IRCParser.java View File

@@ -50,6 +50,8 @@ public class IRCParser implements Runnable {
50 50
 	/** Socket Debug Information. */	
51 51
 	public static final int ndSocket = 2; // Socket Errors
52 52
 //	public static final int ndSomething = 4; //Next thingy
53
+	/** Socket Debug Information. */	
54
+	public static final int ndGeneral = 4096; // General Debug Info. This will never be used if bDebug is false.
53 55
 
54 56
 	/** Used in Error Reporting, Error is potentially Fatal, Desync 99% Guarenteed! */
55 57
 	public static final int errFatal = 1;
@@ -1207,7 +1209,7 @@ public class IRCParser implements Runnable {
1207 1209
 	 * @param data Debugging Information
1208 1210
 	 */
1209 1211
 	protected boolean callDebugInfo(int level, String data) {
1210
-		if (bDebug) { System.out.printf("[DEBUG] {%d} %s\n", level, data); }
1212
+		// if (bDebug) { System.out.printf("[DEBUG] {%d} %s\n", level, data); }
1211 1213
 		boolean bResult = false;
1212 1214
 		for (int i = 0; i < cbDebugInfo.size(); i++) {
1213 1215
 			try {
@@ -1222,6 +1224,13 @@ public class IRCParser implements Runnable {
1222 1224
 		return bResult;
1223 1225
 	}
1224 1226
 	
1227
+	/**
1228
+	 * Used for generalDebug stuff, when bDebug is false, this is never used.
1229
+	 */
1230
+	protected boolean doDebug(String data, Object... args) {
1231
+		return callDebugInfo(ndGeneral, String.format(data, args));
1232
+	}
1233
+	
1225 1234
 	/**
1226 1235
 	 * Add callback for MOTDEnd (onMOTDEnd).
1227 1236
 	 *
@@ -1417,7 +1426,7 @@ public class IRCParser implements Runnable {
1417 1426
 	 * @param data Error Information
1418 1427
 	 */
1419 1428
 	protected boolean callErrorInfo(ParserError errorInfo) {
1420
-		if (bDebug) { System.out.printf("[ERROR] {%d} %s\n", errorInfo.getLevel(), errorInfo.getData()); }
1429
+		if (bDebug) { doDebug("[ERROR] {%d} %s\n", errorInfo.getLevel(), errorInfo.getData()); }
1421 1430
 		boolean bResult = false;
1422 1431
 		for (int i = 0; i < cbErrorInfo.size(); i++) {
1423 1432
 			try {
@@ -2623,12 +2632,12 @@ public class IRCParser implements Runnable {
2623 2632
 			} else {
2624 2633
 				socket = new Socket(server.sHost,server.nPort);
2625 2634
 			}
2626
-			if (bDebug) { System.out.printf("\t\t-> 1\n"); }
2635
+			if (bDebug) { doDebug("\t\t-> 1\n"); }
2627 2636
 			out = new PrintWriter(socket.getOutputStream(), true);
2628 2637
 			nSocketState = stateOpen;
2629
-			if (bDebug) { System.out.printf("\t\t-> 2\n"); }
2638
+			if (bDebug) { doDebug("\t\t-> 2\n"); }
2630 2639
 			in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
2631
-			if (bDebug) { System.out.printf("\t\t-> 3\n"); }
2640
+			if (bDebug) { doDebug("\t\t-> 3\n"); }
2632 2641
 		} catch (Exception e) { throw e; }
2633 2642
 	}
2634 2643
 	
@@ -2725,9 +2734,9 @@ public class IRCParser implements Runnable {
2725 2734
 	 * @return ClientInfo Object for the client, or null
2726 2735
 	 */
2727 2736
 	public ClientInfo getClientInfo(String sWho) {
2728
-		if (bDebug) { System.out.printf("\t\tInput: %s | ",sWho); }
2737
+		if (bDebug) { doDebug("\t\tInput: %s | ",sWho); }
2729 2738
 		sWho = ClientInfo.ParseHost(sWho);
2730
-		if (bDebug) { System.out.printf("Client Name: %s\n",sWho); }
2739
+		if (bDebug) { doDebug("Client Name: %s\n",sWho); }
2731 2740
 		sWho = sWho.toLowerCase();
2732 2741
 		if (hClientList.containsKey(sWho)) { return hClientList.get(sWho); } else { return null; }
2733 2742
 	}
@@ -2964,7 +2973,7 @@ public class IRCParser implements Runnable {
2964 2973
 					// (de) OP/Voice someone
2965 2974
 					sModeParam = sModestr[nParam++];
2966 2975
 					nValue = hPrefixModes.get(cMode);
2967
-					if (bDebug) { System.out.printf("User Mode: %c [%s] {Positive: %b}\n",cMode, sModeParam, bPositive); }
2976
+					if (bDebug) { doDebug("User Mode: %c [%s] {Positive: %b}\n",cMode, sModeParam, bPositive); }
2968 2977
 					iChannelClientInfo = iChannel.getUser(sModeParam);
2969 2978
 					if (iChannelClientInfo == null) {
2970 2979
 						// Client not known?
@@ -2992,22 +3001,22 @@ public class IRCParser implements Runnable {
2992 3001
 				}
2993 3002
 				
2994 3003
 				if (bBooleanMode) {
2995
-					if (bDebug) { System.out.printf("Boolean Mode: %c [%d] {Positive: %b}\n",cMode, nValue, bPositive); }
3004
+					if (bDebug) { doDebug("Boolean Mode: %c [%d] {Positive: %b}\n",cMode, nValue, bPositive); }
2996 3005
 					if (bPositive) { nCurrent = nCurrent + nValue; }
2997 3006
 					else { nCurrent = nCurrent - nValue; }
2998 3007
 				} else {
2999 3008
 					if (nValue == cmList) {
3000 3009
 						sModeParam = sModestr[nParam++];
3001 3010
 						iChannel.setListModeParam(cMode, sModeParam, bPositive);
3002
-						if (bDebug) { System.out.printf("List Mode: %c [%s] {Positive: %b}\n",cMode, sModeParam, bPositive); }
3011
+						if (bDebug) { doDebug("List Mode: %c [%s] {Positive: %b}\n",cMode, sModeParam, bPositive); }
3003 3012
 					} else {
3004 3013
 						if (bPositive) { 
3005 3014
 							sModeParam = sModestr[nParam++];
3006
-							if (bDebug) { System.out.printf("Set Mode: %c [%s] {Positive: %b}\n",cMode, sModeParam, bPositive); }
3015
+							if (bDebug) { doDebug("Set Mode: %c [%s] {Positive: %b}\n",cMode, sModeParam, bPositive); }
3007 3016
 							iChannel.setModeParam(cMode,sModeParam);
3008 3017
 						} else {
3009 3018
 							if ((nValue & cmUnset) == cmUnset) { sModeParam = sModestr[nParam++]; } else { sModeParam = ""; }
3010
-							if (bDebug) { System.out.printf("Unset Mode: %c [%s] {Positive: %b}\n",cMode, sModeParam, bPositive); }
3019
+							if (bDebug) { doDebug("Unset Mode: %c [%s] {Positive: %b}\n",cMode, sModeParam, bPositive); }
3011 3020
 							iChannel.setModeParam(cMode,"");
3012 3021
 						}
3013 3022
 					}
@@ -3054,7 +3063,7 @@ public class IRCParser implements Runnable {
3054 3063
 					nNextKeyUser = nNextKeyUser*2;
3055 3064
 				}
3056 3065
 				
3057
-				if (bDebug) { System.out.printf("User Mode: %c [%d] {Positive: %b}\n",cMode, nValue, bPositive); }
3066
+				if (bDebug) { doDebug("User Mode: %c [%d] {Positive: %b}\n",cMode, nValue, bPositive); }
3058 3067
 				if (bPositive) { nCurrent = nCurrent + nValue; }
3059 3068
 				else { nCurrent = nCurrent - nValue; }
3060 3069
 			}
@@ -3172,7 +3181,7 @@ public class IRCParser implements Runnable {
3172 3181
 				if (bits.length > 1) { sMessage = bits[1]; } else { sMessage = ""; }
3173 3182
 				bits = bits[0].split(Char1.toString());
3174 3183
 				sCTCP = bits[1];
3175
-				if (bDebug) { System.out.printf("CTCP: \"%s\" \"%s\"\n",sCTCP,sMessage); }
3184
+				if (bDebug) { doDebug("CTCP: \"%s\" \"%s\"\n",sCTCP,sMessage); }
3176 3185
 			}
3177 3186
 		}
3178 3187
 
@@ -3215,7 +3224,7 @@ public class IRCParser implements Runnable {
3215 3224
 				}
3216 3225
 			}
3217 3226
 		} else {
3218
-			if (bDebug) { System.out.printf("Message for Other ("+token[2]+")\n"); }
3227
+			if (bDebug) { doDebug("Message for Other ("+token[2]+")\n"); }
3219 3228
 			if (sParam.equalsIgnoreCase("PRIVMSG")) {
3220 3229
 				if (!isAction) {
3221 3230
 					if (isCTCP) {
@@ -3402,7 +3411,7 @@ public class IRCParser implements Runnable {
3402 3411
 				Bits = token[i].split("=",2);
3403 3412
 				sKey = Bits[0].toUpperCase();
3404 3413
 				if (Bits.length == 2) { sValue = Bits[1]; } else { sValue = ""; }
3405
-				if (bDebug) { System.out.printf("%s => %s \r\n",sKey,sValue); }
3414
+				if (bDebug) { doDebug("%s => %s \r\n",sKey,sValue); }
3406 3415
 				h005Info.put(sKey,sValue);
3407 3416
 			}
3408 3417
 		}
@@ -3433,7 +3442,7 @@ public class IRCParser implements Runnable {
3433 3442
 		// List modes.
3434 3443
 		for (int i = 0; i < Bits[0].length(); ++i) {
3435 3444
 			Character cMode = Bits[0].charAt(i);
3436
-			if (bDebug) { System.out.printf("List Mode: %c\n",cMode); }
3445
+			if (bDebug) { doDebug("List Mode: %c\n",cMode); }
3437 3446
 			if (!hChanModesOther.containsKey(cMode)) { hChanModesOther.put(cMode,cmList); }
3438 3447
 		}
3439 3448
 		
@@ -3441,21 +3450,21 @@ public class IRCParser implements Runnable {
3441 3450
 		Byte nBoth = (cmSet+cmUnset);
3442 3451
 		for (int i = 0; i < Bits[1].length(); ++i) {
3443 3452
 			Character cMode = Bits[1].charAt(i);
3444
-			if (bDebug) { System.out.printf("Set/Unset Mode: %c\n",cMode); }
3453
+			if (bDebug) { doDebug("Set/Unset Mode: %c\n",cMode); }
3445 3454
 			if (!hChanModesOther.containsKey(cMode)) { hChanModesOther.put(cMode,nBoth); }
3446 3455
 		}
3447 3456
 		
3448 3457
 		// Param just for Set
3449 3458
 		for (int i = 0; i < Bits[2].length(); ++i) {
3450 3459
 			Character cMode = Bits[2].charAt(i);
3451
-			if (bDebug) { System.out.printf("Set Only Mode: %c\n",cMode); }
3460
+			if (bDebug) { doDebug("Set Only Mode: %c\n",cMode); }
3452 3461
 			if (!hChanModesOther.containsKey(cMode)) { hChanModesOther.put(cMode,cmSet); }
3453 3462
 		}
3454 3463
 		
3455 3464
 		// Boolean Mode
3456 3465
 		for (int i = 0; i < Bits[3].length(); ++i) {
3457 3466
 			Character cMode = Bits[3].charAt(i);
3458
-			if (bDebug) { System.out.printf("Boolean Mode: %c [%d]\n",cMode,nNextKeyCMBool); }
3467
+			if (bDebug) { doDebug("Boolean Mode: %c [%d]\n",cMode,nNextKeyCMBool); }
3459 3468
 			if (!hChanModesBool.containsKey(cMode)) {
3460 3469
 				hChanModesBool.put(cMode,nNextKeyCMBool);
3461 3470
 				nNextKeyCMBool = nNextKeyCMBool*2;
@@ -3480,7 +3489,7 @@ public class IRCParser implements Runnable {
3480 3489
 		// Boolean Mode
3481 3490
 		for (int i = 0; i < ModeStr.length(); ++i) {
3482 3491
 			Character cMode = ModeStr.charAt(i);
3483
-			if (bDebug) { System.out.printf("User Mode: %c [%d]\n",cMode,nNextKeyUser); }
3492
+			if (bDebug) { doDebug("User Mode: %c [%d]\n",cMode,nNextKeyUser); }
3484 3493
 			if (!hUserModes.containsKey(cMode)) {
3485 3494
 				hUserModes.put(cMode,nNextKeyUser);
3486 3495
 				nNextKeyUser = nNextKeyUser*2;
@@ -3504,7 +3513,7 @@ public class IRCParser implements Runnable {
3504 3513
 		// Boolean Mode
3505 3514
 		for (int i = 0; i < ModeStr.length(); ++i) {
3506 3515
 			Character cMode = ModeStr.charAt(i);
3507
-			if (bDebug) { System.out.printf("Chan Prefix: %c\n",cMode); }
3516
+			if (bDebug) { doDebug("Chan Prefix: %c\n",cMode); }
3508 3517
 			if (!hChanPrefix.containsKey(cMode)) { hChanPrefix.put(cMode,true); }
3509 3518
 		}
3510 3519
 	}		
@@ -3539,7 +3548,7 @@ public class IRCParser implements Runnable {
3539 3548
 		for (int i = Bits[0].length()-1; i > -1; --i) {
3540 3549
 			Character cMode = Bits[0].charAt(i);
3541 3550
 			Character cPrefix = Bits[1].charAt(i);
3542
-			if (bDebug) { System.out.printf("Prefix Mode: %c => %c [%d]\n",cMode,cPrefix,nNextKeyPrefix); }
3551
+			if (bDebug) { doDebug("Prefix Mode: %c => %c [%d]\n",cMode,cPrefix,nNextKeyPrefix); }
3543 3552
 			if (!hPrefixModes.containsKey(cMode)) {
3544 3553
 				hPrefixModes.put(cMode,nNextKeyPrefix);
3545 3554
 				hPrefixMap.put(cMode,cPrefix);

+ 1
- 1
src/uk/org/ownage/dmdirc/parser/ParserError.java View File

@@ -99,7 +99,7 @@ public class ParserError {
99 99
 	 *
100 100
 	 * @param newException The exception object to store
101 101
 	 */
102
-	public boolean setException(Exception newException) {
102
+	public void setException(Exception newException) {
103 103
 		exceptionInfo = newException;
104 104
 		if (!this.isException()) {
105 105
 			this.errorLevel = this.errorLevel+errException;

Loading…
Cancel
Save