]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Redo window naming system to use window name identifiers.
authorChris Porter <redacted>
Thu, 4 Dec 2008 23:47:22 +0000 (23:47 +0000)
committerChris Porter <redacted>
Thu, 4 Dec 2008 23:47:22 +0000 (23:47 +0000)
Add messages window.
Sort various queries/messages so they go to it.
Bump version.

js/irc/baseircclient.js
js/irc/commandparser.js
js/irc/ircclient.js
js/ui/baseui.js
js/ui/baseuiwindow.js
js/ui/mochaui.js
js/ui/optionspane.js
js/ui/qui.js
js/ui/swmui.js
js/ui/uglyui.js
js/version.js

index 8a2e7c5bc7af12dfa22a95e2913a7200b7171489..9c77b873356ef6385945208c250258e296e53ad6 100644 (file)
@@ -383,8 +383,16 @@ qwebirc.irc.BaseIRCClient = new Class({
     this.genericError(target, message);
     return true;
   },
+  irc_genericQueryError: function(prefix, params) {
+    var target = params[1];
+    var message = params.indexFromEnd(-1);
+    
+    this.genericQueryError(target, message);
+    return true;
+  },
   setupGenericErrors: function() {
-    this.irc_ERR_CHANOPPRIVSNEEDED = this.irc_ERR_NOSUCHNICK = this.irc_ERR_CANNOTSENDTOCHAN = this.irc_genericError;
+    this.irc_ERR_CHANOPPRIVSNEEDED = this.irc_ERR_CANNOTSENDTOCHAN = this.irc_genericError;
+    this.irc_ERR_NOSUCHNICK = this.irc_genericQueryError;
     return true;
   },
   irc_RPL_AWAY: function(prefix, params) {
index 178a026a2523466bc451b143f0cf302f9aff9ac2..f445bf351970dfd8d77863c5ffddf4f93fd7ec25 100644 (file)
@@ -3,14 +3,17 @@ qwebirc.irc.BaseCommandParser = new Class({
     this.send = parentObject.send;
     this.parentObject = parentObject;
   },
-  newTargetLine: function(target, type, message, extra) {
+  buildExtra: function(extra, target, message) {
     if(!extra)
       extra = {}
 
     extra["n"] = this.parentObject.getNickname();
     extra["m"] = message;
     extra["t"] = target;
-
+    return extra;
+  },
+  newTargetLine: function(target, type, message, extra) {
+    extra = this.buildExtra(extra, target, message);
     var window = this.parentObject.getWindow(target);
     var channel;
     if(!window) {
@@ -26,6 +29,19 @@ qwebirc.irc.BaseCommandParser = new Class({
 
     this.parentObject.newLine(target, "OUR" + type, extra);
   },
+  newQueryLine: function(target, type, message, extra) {
+    extra = this.buildExtra(extra, target, message);
+    
+    if(this.parentObject.ui.uiOptions.DEDICATED_MSG_WINDOW) {
+      var window = this.parentObject.getWindow(target);
+      if(!window) {
+        var w = this.parentObject.ui.newWindow(this.parentObject, qwebirc.ui.WINDOW_MESSAGES, "Messages");
+        w.addLine("OURTARGETED" + type, extra);
+        return;
+      }
+    }
+    return this.newTargetLine(target, type, message, extra);
+  },
   dispatch: function(line) {
     if(line.length == 0)
       return;
@@ -59,7 +75,7 @@ qwebirc.irc.BaseCommandParser = new Class({
       var fn = cmdopts[3];
       
       var w = this.getActiveWindow();
-      if(activewin && w.type == qwebirc.ui.WINDOW_STATUS) {
+      if(activewin && (w.type != qwebirc.ui.WINDOW_CHANNEL && w.type != qwebirc.ui.WINDOW_QUERY)) {
         w.errorMessage("Can't use this command in this window");
         return;
       }
@@ -121,7 +137,7 @@ qwebirc.irc.CommandParser = new Class({
     if(!this.send("PRIVMSG " + target + " :\x01ACTION " + args + "\x01"))
       return;
 
-    this.newTargetLine(target, "ACTION", args);
+    this.newQueryLine(target, "ACTION", args);
   }],
   cmd_CTCP: [false, 3, 2, function(args) {
     var target = args[0];
@@ -148,7 +164,7 @@ qwebirc.irc.CommandParser = new Class({
     if(!this.parentObject.isChannel(target))
       this.parentObject.pushLastNick(target);
     if(this.send("PRIVMSG " + target + " :" + message))
-      this.newTargetLine(target, "MSG", message, {});  
+      this.newQueryLine(target, "MSG", message, {});  
   }],
   cmd_NOTICE: [false, 2, 2, function(args) {
     var target = args[0];
@@ -268,7 +284,7 @@ qwebirc.irc.CommandParser = new Class({
     var message = "";
     var channel;
     
-    if(w.type == qwebirc.ui.WINDOW_STATUS) {
+    if(w.type != qwebirc.ui.WINDOW_CHANNEL) {
       if(!args || args.length == 0) {
         w.errorMessage("Insufficient arguments for command.");
         return;
index ae1e1114d91a1267c6fda967a402b494600f5197..3739f2c454dde3213c2dcbf4af1121c2ae0cc05b 100644 (file)
@@ -106,6 +106,30 @@ qwebirc.irc.IRCClient = new Class({
       
     return w;
   },
+  newQueryWindow: function(name) {
+    if(this.ui.uiOptions.DEDICATED_MSG_WINDOW)
+      return this.ui.newWindow(this, qwebirc.ui.WINDOW_MESSAGES, "Messages");
+    return this.newWindow(name, qwebirc.ui.WINDOW_QUERY, false);
+  },
+  newQueryLine: function(window, type, data, active) {
+    if(this.getWindow(window))
+      return this.newLine(window, type, data);
+      
+    var w = this.ui.getWindow(this, qwebirc.ui.WINDOW_MESSAGES);
+    
+    if(this.ui.uiOptions.DEDICATED_MSG_WINDOW && w) {
+      return w.addLine(type, data);
+    } else {
+      if(active) {
+        return this.newActiveLine(window, type, data);
+      } else {
+        return this.newLine(window, type, data);
+      }
+    }
+  },
+  newQueryOrActiveLine: function(window, type, data) {
+    this.newQueryLine(window, type, data, true);
+  },
   getActiveWindow: function() {
     return this.ui.getActiveIRCWindow(this);
   },
@@ -286,8 +310,8 @@ qwebirc.irc.IRCClient = new Class({
       args = "";
     
     if(type == "ACTION") {      
-      this.newWindow(nick, qwebirc.ui.WINDOW_QUERY);
-      this.newLine(nick, "PRIVACTION", {"m": args, "x": type, "h": host, "n": nick});
+      this.newQueryWindow(nick);
+      this.newQueryLine(nick, "PRIVACTION", {"m": args, "x": type, "h": host, "n": nick});
       return;
     }
     
@@ -312,9 +336,9 @@ qwebirc.irc.IRCClient = new Class({
     var nick = user.hostToNick();
     var host = user.hostToHost();
     
-    this.newWindow(nick, qwebirc.ui.WINDOW_QUERY);
+    this.newQueryWindow(nick);
     this.pushLastNick(nick);
-    this.newLine(nick, "PRIVMSG", {"m": message, "h": host, "n": nick});
+    this.newQueryLine(nick, "PRIVMSG", {"m": message, "h": host, "n": nick});
   },
   serverNotice: function(message) {
     this.newServerLine("SERVERNOTICE", {"m": message});
@@ -389,7 +413,7 @@ qwebirc.irc.IRCClient = new Class({
     this.disconnect();
   },
   awayMessage: function(nick, message) {
-    this.newLine(nick, "AWAY", {"n": nick, "m": message});
+    this.newQueryLine(nick, "AWAY", {"n": nick, "m": message});
   },
   whois: function(nick, type, data) {
     var ndata = {"n": nick};
@@ -443,6 +467,9 @@ qwebirc.irc.IRCClient = new Class({
   genericError: function(target, message) {
     this.newTargetOrActiveLine(target, "GENERICERROR", {m: message, t: target});
   },
+  genericQueryError: function(target, message) {
+    this.newQueryOrActiveLine(target, "GENERICERROR", {m: message, t: target});
+  },
   awayStatus: function(state, message) {
     this.newActiveLine("GENERICMESSAGE", {m: message});
   },
index 627a55b871301aaef6d4817c767f290351fde4d0..6b2887f39051f7ff578faa569ad562b36af2289b 100644 (file)
@@ -3,6 +3,7 @@ qwebirc.ui.WINDOW_QUERY = 2;
 qwebirc.ui.WINDOW_CHANNEL = 3;
 qwebirc.ui.WINDOW_CUSTOM = 4;
 qwebirc.ui.WINDOW_CONNECT = 5;
+qwebirc.ui.WINDOW_MESSAGES = 6;
 qwebirc.ui.CUSTOM_CLIENT = "custom";
 
 qwebirc.ui.BaseUI = new Class({
@@ -50,22 +51,37 @@ qwebirc.ui.BaseUI = new Class({
       return client.id;
     }
   },
-  newWindow: function(client, type, name) {
-    var identifier = name;
+  getWindowIdentifier: function(type, name) {
+    if(type == qwebirc.ui.WINDOW_MESSAGES)
+      return "-M";
     if(type == qwebirc.ui.WINDOW_STATUS)
-      identifier = "";
+      return "";
+    return "_" + name;
+  },
+  newWindow: function(client, type, name) {
+    var w = this.getWindow(client, type, name);
+    if($defined(w))
+      return w;
       
-    var w = this.windows[this.getClientId(client)][identifier] = new this.windowClass(this, client, type, name, identifier);
+    var wId = this.getWindowIdentifier(type, name);
+    var w = this.windows[this.getClientId(client)][wId] = new this.windowClass(this, client, type, name, wId);
     this.windowArray.push(w);
     
     return w;
   },
+  getWindow: function(client, type, name) {
+    var c = this.windows[this.getClientId(client)];
+    if(!$defined(c))
+      return null;
+      
+    return c[this.getWindowIdentifier(type, name)];
+  },
   getActiveWindow: function() {
     return this.active;
   },
   getActiveIRCWindow: function(client) {
     if(!this.active || this.active.type == qwebirc.ui.WINDOW_CUSTOM) {
-      return this.windows[this.getClientId(client)][""];
+      return this.windows[this.getClientId(client)][this.getWindowIdentifier(qwebirc.ui.WINDOW_STATUS)];
     } else {
       return this.active;
     }
@@ -193,7 +209,7 @@ qwebirc.ui.StandardUI = new Class({
       
     var w = this.newWindow(qwebirc.ui.CUSTOM_CLIENT, type, name);
     w.addEvent("close", function(w) {
-      delete this.windows[qwebirc.ui.CUSTOM_CLIENT][name];
+      delete this.windows[qwebirc.ui.CUSTOM_CLIENT][w.identifier];
     }.bind(this));
     
     if(select)
index 3dc7026931e7c95b9e09914ead2c2d12ce65a63d..01e0ff17c4a906a9827e7c00ab45f906439a28ee 100644 (file)
@@ -76,8 +76,12 @@ qwebirc.ui.Window = new Class({
       hilight = qwebirc.ui.HILIGHT_ACTIVITY;
       
       if(type.match(/(NOTICE|ACTION|MSG)$/)) {
-        if(this.type == qwebirc.ui.WINDOW_QUERY) {
-          hilight = qwebirc.ui.HILIGHT_US;
+        if(this.type == qwebirc.ui.WINDOW_QUERY || this.type == qwebirc.ui.WINDOW_MESSAGES) {
+          if(type.match(/^OUR/)) {
+            hilight = qwebirc.ui.HILIGHT_ACTIVITY;
+          } else {
+            hilight = qwebirc.ui.HILIGHT_US;
+          }
         }
         if(!type.match(/^OUR/) && this.client.hilightController.match(line["m"])) {
           lhilight = true;
index 8eb1b583b503e7e6fd9be3b956f7f9814bc039d6..a769558605a327b8b0ff2f3441ee44ac037dc2a0 100644 (file)
@@ -57,8 +57,8 @@ qwebirc.ui.MochaUI = new Class({
 qwebirc.ui.MochaUI.Window = new Class({
   Extends: qwebirc.ui.Window,
   
-  initialize: function(parentObject, client, type, name) {
-    this.parent(parentObject, client, type, name);
+  initialize: function(parentObject, client, type, name, identifier) {
+    this.parent(parentObject, client, type, name, identifier);
 
     this.lines = new Element("div", {styles: {overflow: "auto", "width": "90"}});
 
index dfbaa6b523d30ea6d8b1792ccb2aafefae3084e4..bada8e1cf6060e201c2a9ad0fddd6e19afe0f201 100644 (file)
@@ -15,7 +15,8 @@ qwebirc.config.DEFAULT_OPTIONS = [
         ui.setBeepOnMention(value);
     }
   }],
-  [2, "OPEN_QUERIES", "Open new queries automatically", false]
+  [2, "DEDICATED_MSG_WINDOW", "Use dedicated messages window", false],
+  [3, "TEXT_STATUS", "Show status (@/+) before nicknames", true]
 ];
 
 qwebirc.config.DefaultOptions = null;
index 2206107d2a704efbc2135bcb3f2378eac6d0fce8..bd5128f98dee46e54e6181c4367a5580d116f964 100644 (file)
@@ -221,8 +221,8 @@ qwebirc.ui.QUI.JSUI = new Class({
 qwebirc.ui.QUI.Window = new Class({
   Extends: qwebirc.ui.Window,
   
-  initialize: function(parentObject, client, type, name) {
-    this.parent(parentObject, client, type, name);
+  initialize: function(parentObject, client, type, name, identifier) {
+    this.parent(parentObject, client, type, name, identifier);
 
     this.tab = new Element("a", {"href": "#"});
     this.tab.addClass("tab");
index 8517a5c335407e150e3e672d33a735f7a69a9245..e49ee67edda67234e43cbfa826ee016251f64076 100644 (file)
@@ -55,8 +55,8 @@ qwebirc.ui.SWMUI = new Class({
 qwebirc.ui.SWMUI.Window = new Class({
   Extends: qwebirc.ui.Window,
   
-  initialize: function(parentObject, client, type, name) {
-    this.parent(parentObject, client, type, name);
+  initialize: function(parentObject, client, type, name, identifier) {
+    this.parent(parentObject, client, type, name, identifier);
     this.contentPanel = new qwebirc.ui.SWMUI.Panel(parentObject.mainPanel, true);
     this.contentPanel.addClass("content");
 
index 14d8df400c87837b263968a3336db451756edb9a..05875443fff8b53c6155a5b0e0e0accc82b32d63 100644 (file)
@@ -40,8 +40,8 @@ qwebirc.ui.UglyUI = new Class({
 qwebirc.ui.UglyUI.Window = new Class({
   Extends: qwebirc.ui.Window,
   
-  initialize: function(parentObject, client, type, name) {
-    this.parent(parentObject, client, type, name);
+  initialize: function(parentObject, client, type, name, identifier) {
+    this.parent(parentObject, client, type, name, identifier);
         
     this.outerContainer = new Element("div");
     this.outerContainer.addClass("outercontainer");
index 686c37845c1a0712bfcc45ab250cc73b7d3610c1..242ecd8642f9f2bdfceae6029f1b49b2bcbde391 100644 (file)
@@ -1 +1 @@
-qwebirc.VERSION = "0.53"
+qwebirc.VERSION = "0.60"