[Pkg-mozext-commits] [sieve-extension] 20/34: Imported Upstream version 0.2.3g+dfsg

Michael Fladischer fladi at moszumanska.debian.org
Mon Sep 21 09:03:30 UTC 2015


This is an automated email from the git hooks/post-receive script.

fladi pushed a commit to branch master
in repository sieve-extension.

commit b9b017c85ac7a4e6a49d5d0f58cd6ba5d3410f98
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date:   Tue Jul 28 18:35:25 2015 +0200

    Imported Upstream version 0.2.3g+dfsg
---
 .../content/editor/SieveFilterEditor.html          |  48 +-
 .../content/editor/SieveFilterEditor.js            | 544 +++++++--------------
 .../content/editor/SieveFilterEditor.xul           |  10 +-
 chrome/chromeFiles/content/editor/SieveStatus.js   |  13 +-
 .../content/editor/sieve.editor.glue.js            |  11 +
 .../content/editor/sieve.editor.text.glue.js       | 171 +++++++
 .../content/editor/sieve.editor.text.js            | 247 ++++++++++
 .../content/editor/sieve.iframe.glue.js            |  89 ++++
 .../libs/libManageSieve/SieveAbstractClient.js     |   8 +-
 .../libs/libSieveDOM/RFC5228/logic/SieveActions.js |   3 +-
 .../libs/libSieveDOM/RFC5228/logic/SieveNumbers.js |   4 +-
 .../libSieveDOM/RFC5229/logic/SieveVariables.js    | 431 ++++++++++++----
 .../content/libs/libSieveDOM/SieveGui.html         |   5 +-
 .../content/libs/libSieveDOM/toolkit/SieveLexer.js |  10 +-
 14 files changed, 1080 insertions(+), 514 deletions(-)

diff --git a/chrome/chromeFiles/content/editor/SieveFilterEditor.html b/chrome/chromeFiles/content/editor/SieveFilterEditor.html
index e5235c1..c612092 100644
--- a/chrome/chromeFiles/content/editor/SieveFilterEditor.html
+++ b/chrome/chromeFiles/content/editor/SieveFilterEditor.html
@@ -14,6 +14,9 @@
 	
     <script src="./../libs/CodeMirror/mode/sieve/sieve.js"></script>
 	
+	<script src="./sieve.iframe.glue.js"></script>
+	<script src="./sieve.editor.text.js"></script>
+	
     <style>
       .CodeMirror-fullscreen {
         display: block;
@@ -51,49 +54,8 @@
     <form>
     <textarea id="code" name="code"></textarea>
     </form> 
-    
     <script>
- 
-      function winHeight() {
-        return window.innerHeight || (document.documentElement || document.body).clientHeight;
-      }
-  
-      function setFullScreen(cm) {
-        var wrap = cm.getWrapperElement();
-        wrap.className += " CodeMirror-fullscreen";
-        wrap.style.height = winHeight() + "px";
-        document.documentElement.style.overflow = "hidden";
-        cm.refresh();
-      }
-    
-      CodeMirror.on(window, "resize", function() {
-        document.body.getElementsByClassName("CodeMirror-fullscreen")[0]
-        .CodeMirror.getWrapperElement().style.height = winHeight() + "px";
-      });
-    
-      var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
-        lineNumbers: true,
-        theme: "eclipse",
-        matchBrackets: true
-      });
-  
-      setFullScreen(editor,true);
-    
-      var hlLine = editor.addLineClass(0, "background", "activeline");
-    
-      // This function is called externaly upon reloading and updating scripts  
-      function onActiveLineChange() 
-      {
-        var cur = editor.getLineHandle(editor.getCursor().line);
-        
-        if (cur != hlLine) {
-          editor.removeLineClass(hlLine, "background", "activeline");
-          hlLine = editor.addLineClass(cur, "background", "activeline");
-        }
-      }
-      
-      editor.on("cursorActivity", onActiveLineChange);    
-    
-    </script>
+      net.tschmid.sieve.editor.text.init();
+	</script>    
   </body>
 </html>
diff --git a/chrome/chromeFiles/content/editor/SieveFilterEditor.js b/chrome/chromeFiles/content/editor/SieveFilterEditor.js
index fffdff1..1630c8d 100644
--- a/chrome/chromeFiles/content/editor/SieveFilterEditor.js
+++ b/chrome/chromeFiles/content/editor/SieveFilterEditor.js
@@ -30,10 +30,6 @@ SieveOverlayManager.require("/sieve/SieveAccounts.js",this,window);
 var gBackHistory = new Array();
 var gForwardHistory = new Array();
 
-var gPrintSettings = null;
-
-
-
 var gEditorStatus =
 {
   checkScriptDelay  : 200,
@@ -75,12 +71,13 @@ SieveFilterEditor.prototype.onChannelReady
       // Script does not exists, or was deleted
       
       // if we have a server checksum, we are reconnecting and our
-      // editor contains valid data. A typical szenario is having
+      // editor contains valid data. A typical scenario is having
       // an unsaved script, losing the connection and then clicking 
       // on reconnect.
       if (gEditorStatus.checksum.server)
       {
-        that.onScriptLoaded(that.getScript())
+      
+     	that.getScriptAsync( function(script) { that.onScriptLoaded(script) } );
         return;
       }
       
@@ -144,64 +141,71 @@ SieveFilterEditor.prototype._calcChecksum
 SieveFilterEditor.prototype.onGetScriptResponse
     = function(response)
 {
-   
-  // The sercer checksum is empty, so we have nothing to compare, which means...
-  // ...the script was never loaded
-  if (!gEditorStatus.checksum.server)  
-  {
-    this.onScriptLoaded(response.getScriptBody());
-    return;
-  }
-   
-  var remoteScript = this._calcChecksum(response.getScriptBody());
   
-  // The server side script is equal to out current script. We are perfectly
-  // in sync. And do not need to do anything... 
-  if (remoteScript == this._calcChecksum(this.getScript()))
-  {
-    this.onScriptLoaded(this.getScript()); 
-    return;
-  }
-  
-  // The server side script is equal to our last save. So no third party changed
-  // anything. We can be sure the local script is newer. 
-  if (remoteScript == gEditorStatus.checksum.server)
-  {
-    this.onScriptLoaded(this.getScript());
-    return;
-  }
+  var that = this;
+  var remoteScript = response.getScriptBody();
+
+  this.getScriptAsync( function(localScript) {
+  	 
+    // The server checksum is empty, so we have nothing to compare, which means...
+    // ...the script was never loaded
+    if (!gEditorStatus.checksum.server)  
+    {
+      that.onScriptLoaded(remoteScript);
+      return;
+    }  
+
+    var remoteCheckSum = that._calcChecksum(remoteScript);
+    var localCheckSum  = that._calcChecksum(localScript);
   
+    // The server side script is equal to out current script. We are perfectly
+    // in sync. And do not need to do anything... 
+    if (remoteCheckSum == localCheckSum)
+    {
+      that.onScriptLoaded(localScript); 
+      return;
+    }
+    
+    // The server side script is equal to our last save. So no third party changed
+    // anything. We can be sure the local script is newer. 
+    if (remoteCheckSum == gEditorStatus.checksum.server)
+    {
+      that.onScriptLoaded(localScript);
+      return;
+    }  
   
-  // not so good. We got out of sync, we can't descide which one is newer...
-  this.onStatusChange(10,{local:this.getScript(),remote:response.getScriptBody()});  
+    // not so good. We got out of sync, we can't descide which one is newer...
+    that.onStatusChange(10, {local: localScript, remote: remoteScript });    
+  });
 }
 
 SieveFilterEditor.prototype.onPutScriptResponse
     = function(response)
-{  
-  // update the last save shadow copy
-  var script = this.getScript();
-  
-  // update the gui checksum & the editor script only when needed
-  if (!document.getElementById('btnViewSource').checked)
-  {
-    document.getElementById("sivEditor2").contentWindow.editor.setValue(script);
-    gEditorStatus.checksum.gui = this._calcChecksum(script);
-  }
-  
-  gEditorStatus.checksum.server =  this._calcChecksum(script);
+{
+  var that = this;
+	
+  // the script was updated, which means we need to update the checksum...
+  this.getScriptAsync( function(script) {
+  	
+  	if (!document.getElementById('btnViewSource').checked)
+    {
+      glue.setScript(script);
+      // Update the gui checksum...
+      gEditorStatus.checksum.gui = that._calcChecksum(script);
+    }
+
+    // ... and the editor checksum  
+    gEditorStatus.checksum.server =  that._calcChecksum(script);
       
-  this.setScriptName();
+    that.setScriptName();
   
-  // check if tab is in the progress of closing
-  if (!gEditorStatus.closeListener)
-    return;
+    // check if tab is in the progress of closing
+    if (!gEditorStatus.closeListener)
+      return;
 
-  if (closeTab())
-    return;
-            
-  // just calling close is for some reason broken, so we use our helper...
-  //window.arguments[0].wrappedJSObject["close"]();      
+    if (closeTab())
+      return;
+  } );
 }
 
 SieveFilterEditor.prototype.onCheckScriptResponse
@@ -259,25 +263,18 @@ SieveFilterEditor.prototype.onScriptLoaded
 {  
   this.onStatusChange(0);
   gEditorStatus.persistedScript = null;
-
-  var editor = document.getElementById("sivEditor2").contentWindow.editor;
   
-  editor.setCursor({line:0,ch:0});
-  editor.setValue(script);
-  editor.clearHistory();
-
-    
-  // Ugly workaround...
-  document.getElementById("sivEditor2").contentWindow.onActiveLineChange();
-
+  var that = this;  
+  
+  glue.loadScript(script, function() {
 
-  if (gEditorStatus.checksum.server == null) {
-    gEditorStatus.checksum.server = this._calcChecksum(this.getScript());
-    this.setScriptName();
-  }
+  	if (gEditorStatus.checksum.server == null) {
+      gEditorStatus.checksum.server = that._calcChecksum(script);        
+      gSFE.setScriptName();
+    }
   
-  document.getElementById("sivEditor2").focus();  
-  editor.focus();
+    glue.focus();
+  });  
 }
 
 SieveFilterEditor.prototype.observe
@@ -330,14 +327,17 @@ SieveFilterEditor.prototype.onStatusChange
 
 
 SieveFilterEditor.prototype.getScript
-    = function ()
+    = function (editor)
 {
   if (gEditorStatus.persistedScript)
     return gEditorStatus.persistedScript;
     
+  if (!editor)
+    editor = document.getElementById("sivEditor2").contentWindow.editor.getValue();
+  
   // Thunderbird scrambles linebreaks to single \n so we have to fix that
-  var editor = document.getElementById("sivEditor2").contentWindow.editor.getValue()
-                  .replace(/\r\n|\r|\n|\u0085|\u000C|\u2028|\u2029/g,"\r\n");
+  if (editor)
+    editor = editor.replace(/\r\n|\r|\n|\u0085|\u000C|\u2028|\u2029/g,"\r\n");
                   
   if (document.getElementById('btnViewSource').checked)
     return  editor;
@@ -351,6 +351,35 @@ SieveFilterEditor.prototype.getScript
   return widget;
 }
 
+SieveFilterEditor.prototype.getScriptAsync
+    = function (callback) {
+
+  if (!callback)
+    return;
+
+  if (gEditorStatus.persistedScript) {
+  	callback(gEditorStatus.persistedScript);
+  	return;
+  }
+  
+  // In case it's the source we return the plaintext editor...
+  if (document.getElementById('btnViewSource').checked) {
+  	
+  	glue.getScript( function(script) {
+      // Sanatize the line breaks to a single \n. Thunderbird scrambles them sometimes...
+      script = script.replace(/\r\n|\r|\n|\u0085|\u000C|\u2028|\u2029/g,"\r\n");
+      
+      callback(script);
+    } );
+    
+    return;
+  }
+
+  var widget =  document.getElementById("sivWidgetEditor")
+                    .contentWindow.getSieveScript(); 
+  callback(widget);
+}
+
 SieveFilterEditor.prototype.hasChanged
     = function()
 {
@@ -372,8 +401,14 @@ SieveFilterEditor.prototype.putScript
   if (typeof(scriptName) == "undefined")
     scriptName = this.getScriptName();
     
-  if (typeof(content) == "undefined")
-    content = this.getScript();
+  if (typeof(content) == "undefined") {
+  	
+  	// We postpone the call. First we get the script from the editor,
+  	// and then call the method again...
+  	var that = this;
+  	this.getScriptAsync( function(script) { that.putScript(scriptName, script) } );
+  	return;    
+  }
     
   var event = {
     onError : function(response)
@@ -418,7 +453,7 @@ SieveFilterEditor.prototype.getScriptName
 
 function onCompile()
 { 
-  gSFE.checkScript(gSFE.getScript());
+  gSFE.getScriptAsync( function(script) {gSFE.checkScript(script) } );
 }
 
 function onInput()
@@ -458,10 +493,52 @@ function onWindowPersist()
   return args; 
 }
 
+var glue = null;
+
+var sivEditorListener = {
+	onChange : function() {
+		onInput();
+	},
+		
+	onStringFound : function() {
+	  document.getElementById("boxSearchError").setAttribute('hidden','true');
+	}	
+}
+
+function onFindString()
+{   
+  document.getElementById("boxSearchError").removeAttribute('hidden');  
+
+  var token = document.getElementById("txtToken").value;
+  
+  var isReverse = !!document.getElementById('cbxBackward').checked;  
+  var isCaseSensitive = document.getElementById('cbxCaseSensitive').checked;  
+    
+  glue.findString(token, isCaseSensitive, isReverse);
+  
+  return;
+}
+
+function onReplaceString()
+{
+  document.getElementById("boxSearchError").removeAttribute('hidden');  
+  
+  var oldToken = document.getElementById("txtToken").value;
+  var newToken = document.getElementById("txtReplace").value;
+  
+  var isReverse = !!document.getElementById('cbxBackward').checked;
+  var isCaseSensitive = document.getElementById('cbxCaseSensitive').checked;
+	
+  glue.replaceString(oldToken, newToken, isCaseSensitive, isReverse);
+  
+  return;  
+}
+
+
 function onWindowLoad()
 {
-  document.getElementById("sivEditor2")
-    .contentWindow.editor.on("change",onInput);
+  glue = new net.tschmid.sieve.editor.text.glue("sivEditor2");  	
+  glue.setListener( sivEditorListener );	
   
   // hack to prevent links to be opened in the default browser window...
   document.getElementById("ifSideBar").
@@ -571,7 +648,7 @@ function onViewSource(visible,aNoUpdate)
     if (aNoUpdate || (gEditorStatus.checksum.gui == gSFE._calcChecksum(script)))
       return;
 
-    document.getElementById("sivEditor2").contentWindow.editor.setValue(script);
+    glue.setScript(script);
     
     onInput();
     return;
@@ -592,22 +669,20 @@ function onViewSource(visible,aNoUpdate)
   
   deck.selectedIndex = 1;
   
-  // Make GUI seem to be more agile...
-  window.setTimeout( function() {updateWidgets()} ,0);    
+  // Finally we need to transfer the current script from the editor into the gui...
+  glue.getScript( function(script) { updateWidgets(script) } );
 }
 
-function updateWidgets()
+function updateWidgets(script)
 {
    
   try {
     var capabilities = SieveConnections
       .getChannel(gSFE._sid,gSFE._cid).extensions;
-       
-    var script = document.getElementById("sivEditor2").contentWindow.editor.getValue();
 
     // set script content...
     document.getElementById("sivWidgetEditor")
-      .contentWindow.setSieveScript(script,capabilities)
+      .contentWindow.setSieveScript(script,capabilities);
     
     // ... and create a shadow copy
     gEditorStatus.checksum.gui = gSFE._calcChecksum(
@@ -820,7 +895,7 @@ function onImport()
   scriptableStream.close();
   inputStream.close();
 
-  document.getElementById("sivEditor2").contentWindow.editor.replaceSelection(script);
+  glue.replaceSelection(script);
   
   onInput();
 }
@@ -843,19 +918,21 @@ function onExport()
   if ((result != filePicker.returnOK) && (result != filePicker.returnReplace))
     return;
 
-  var file = filePicker.file;
+  gSFE.getScriptAsync( function(data) { 
+    var file = filePicker.file;
 
-  if (file.exists() == false)
-    file.create(Ci.nsIFile.NORMAL_FILE_TYPE, parseInt("0644", 8));
+    if (file.exists() == false)
+      file.create(Ci.nsIFile.NORMAL_FILE_TYPE, parseInt("0644", 8));  
+  
+    var outputStream = Cc["@mozilla.org/network/file-output-stream;1"]
+          .createInstance(Ci.nsIFileOutputStream);
 
-  var outputStream = Cc["@mozilla.org/network/file-output-stream;1"]
-      .createInstance(Ci.nsIFileOutputStream);
+    outputStream.init(file, 0x04 | 0x08 | 0x20, parseInt("0644", 8), null);
 
-  outputStream.init(file, 0x04 | 0x08 | 0x20, parseInt("0644", 8), null);
 
-  var data = gSFE.getScript();
-  outputStream.write(data, data.length);
-  outputStream.close();
+    outputStream.write(data, data.length);
+    outputStream.close();
+  } );
 }
 
 function onErrorBar(visible,aSilent)
@@ -946,267 +1023,6 @@ function onSearchBar(visible)
   return;
 }
 
-function onFindString()
-{   
-  document.getElementById("boxSearchError").removeAttribute('hidden');
-        
-  // ... convert to lowercase, if the search is not case sensitive...
-  var editor = document.getElementById("sivEditor2").contentWindow.editor;
-  var reverse = !!document.getElementById('cbxBackward').checked;
-  
-  
-  function maxCursor(start,end)
-  {
-    if (start.line > end.line)
-      return start
-
-    if (start.line < end.line)
-      return end;
-    
-    // start.line == end.line
-    if (start.ch > end.ch)
-      return start;
-      
-    return end;
-  }
-  
-  function minCursor(start,end)
-  {
-    if (start.line <end.line)
-      return start
-
-    if (start.line > end.line)
-      return end;
-    
-    // start.line == end.line
-    if (start.ch > end.ch)
-      return end;
-      
-    return start;
-  }
-  
-  var start = editor.getCursor(true);
-  var end = editor.getCursor(false);
-  
-  var cursor = editor.getSearchCursor(
-    document.getElementById("txtToken").value,
-    reverse ? minCursor(start,end) : maxCursor(start,end),
-    !document.getElementById('cbxCaseSensitive').checked);
-  
-  if (!cursor.find(reverse))
-  { 
-    // warp search at top or bottom
-    cursor = editor.getSearchCursor(
-       document.getElementById("txtToken").value,
-       reverse ? {line: editor.lineCount() - 1} : {line: 0, ch: 0},
-       !document.getElementById('cbxCaseSensitive').checked);
-    
-    if (!cursor.find(reverse))
-      return;
-  }
-  
-  if (reverse)
-    editor.setSelection(cursor.from(), cursor.to());
-  else
-    editor.setSelection(cursor.to(), cursor.from());
-
-  document.getElementById("boxSearchError").setAttribute('hidden','true');  
-  return;
-}
-
-function onReplaceString()
-{
-  var token = document.getElementById("txtToken").value;
-  var editor = document.getElementById("sivEditor2").contentWindow.editor;
-  var caseSensitive = document.getElementById('cbxCaseSensitive').checked;
-    
-  if (caseSensitive) 
-  {
-    if (editor.getSelection() != token)
-      onFindString();
-      
-    if (editor.getSelection() != token)
-      return;
-  }
-    
-  if (!caseSensitive)
-  {
-    if (editor.getSelection().toLowerCase() != token.toLowerCase())
-      onFindString();
-      
-    if (editor.getSelection().toLowerCase() != token.toLowerCase())
-      return;
-  }
-
-  editor.replaceSelection(document.getElementById("txtReplace").value);
-
-  onInput();
-  
-  return;  
-}
-
-
-
-function getPrintSettings()
-{
-  var pref = Components.classes["@mozilla.org/preferences-service;1"]
-               .getService(Components.interfaces.nsIPrefBranch);
-  if (pref) 
-  {
-    var gPrintSettingsAreGlobal = pref.getBoolPref("print.use_global_printsettings", false);
-    var gSavePrintSettings = pref.getBoolPref("print.save_print_settings", false);
-  }
- 
-  var printSettings;
-  try 
-  {
-    var PSSVC = Components.classes["@mozilla.org/gfx/printsettings-service;1"]
-                  .getService(Components.interfaces.nsIPrintSettingsService);
-    if (gPrintSettingsAreGlobal) 
-    {
-      printSettings = PSSVC.globalPrintSettings;
-      this.setPrinterDefaultsForSelectedPrinter(PSSVC, printSettings);
-    }
-    else
-    {
-      printSettings = PSSVC.newPrintSettings;
-    }
-  }
-  catch (e)
-  {
-    alert("getPrintSettings: "+e+"\n");
-  }
-  return printSettings;
-}
-
-
-function onPrint()
-{
-  // we print in xml this means any specail charaters have to be html entities...
-  // ... so we need a dirty hack to convert all entities...
-  alert("Print");
-  var script = document.getElementById("sivContentEditor").value;
-  script = (new XMLSerializer()).serializeToString(document.createTextNode(script));
-  
-  script = script.replace(/\r\n/g,"\r");
-  script = script.replace(/\n/g,"\r");
-  script = script.replace(/\r/g,"\r\n");
- 
-  var data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" 
-     + "<?xml-stylesheet type=\"text/css\" href=\"chrome://sieve/content/editor/print.css\"?>\r\n"
-     + "<SieveScript>\r\n"
-       + "<title xmlns=\"http://www.w3.org/1999/xhtml\">\r\n"
-         + gSFE.getScriptName()
-       + "</title>\r\n"
-       + "<SieveScriptName>\r\n" 
-         + gSFE.getScriptName()
-       + "</SieveScriptName>\r\n"   
-       + "<SieveScriptLine>\r\n"       
-         + script
-       + "</SieveScriptLine>\r\n"          
-     + "</SieveScript>\r\n";    
-  
-  data =  "data:application/xml;base64,"+btoa(data);  
-
-   /*// get URI and add to list for printing
-  var messageList =  new Array(1);
-  messageList[0] = data;
-     
-  var prevPS = gPrintSettings;
- 
-  var printSettingsService = 
-        Components.classes["@mozilla.org/gfx/printsettings-service;1"]
-          .getService(Components.interfaces.nsIPrintSettingsService);
-   
-  var printSettings = printSettingsService.CreatePrintSettings();
-  // var printSettings = printSettingsService.globalPrintSettings;
-
-  printEngineWindow = window.openDialog("chrome://messenger/content/msgPrintEngine.xul",
-                                        "",
-                                        "chrome,dialog=no,all,centerscreen",
-                                        messageList.length, messageList, statusFeedback, 
-                                        printSettings, false, 
-                                        Components.interfaces.nsIMsgPrintEngine.MNAB_PRINT_MSG,
-                                        window)*/
-                  
-
-   var printSettings;// = getPrintSettings();
-   /* get the print engine instance */
-   var printEngine = Components.classes["@mozilla.org/messenger/msgPrintEngine;1"].createInstance();
-   printEngine.QueryInterface(Components.interfaces.nsIMsgPrintEngine);
-
-   var printSettingsService = 
-        Components.classes["@mozilla.org/gfx/printsettings-service;1"]
-          .getService(Components.interfaces.nsIPrintSettingsService);
-   var printSettings = printSettingsService.newPrintSettings;
-   
-   printEngine.setWindow(window);
-   printEngine.doPrintPreview = false;
-   printEngine.showWindow(false);
-   printEngine.setMsgType(Components.interfaces.nsIMsgPrintEngine.MNAB_PRINT_MSG);
-   printEngine.setParentWindow(null);
-   //printEngine.setParentWindow(window);   
-
-   var messageList =  new Array(1);
-   messageList[0] = data;
- 
-   printEngine.setPrintURICount(messageList.length);
-   printEngine.addPrintURI(messageList);
-   
-   printEngine.startPrintOperation(printSettings);
- 
-//     printEngine.setStatusFeedback(statusFeedback);
-//     printEngine.setStartupPPObserver(gStartupPPObserver);
-                     
-  alert("End Print");
-}
-/*function onPrint()
-{  
-  var statusFeedback;
-  statusFeedback = Components.classes["@mozilla.org/messenger/statusfeedback;1"].createInstance();
-  statusFeedback = statusFeedback.QueryInterface(Components.interfaces.nsIMsgStatusFeedback);
-
-  // we print in xml this means any specail charaters have to be html entities...
-  // ... so we need a dirty hack to convert all entities...
-  
-  var script = document.getElementById("sivContentEditor").value;
-  script = (new XMLSerializer()).serializeToString(document.createTextNode(script));
-  
-  script = script.replace(/\r\n/g,"\r");
-  script = script.replace(/\n/g,"\r");
-  script = script.replace(/\r/g,"\r\n");
- 
-  var data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" 
-     + "<?xml-stylesheet type=\"text/css\" href=\"chrome://sieve/content/editor/print.css\"?>\r\n"
-     + "<SieveScript>\r\n"
-       + "<title xmlns=\"http://www.w3.org/1999/xhtml\">\r\n"
-         + document.getElementById("txtName").value
-       + "</title>\r\n"
-       + "<SieveScriptName>\r\n" 
-         + document.getElementById("txtName").value
-       + "</SieveScriptName>\r\n"   
-       + "<SieveScriptLine>\r\n"       
-         + script
-       + "</SieveScriptLine>\r\n"          
-     + "</SieveScript>\r\n";    
-  
-  data =  "data:application/xml;base64,"+btoa(data);  
-  
-
-  if (gPrintSettings == null) 
-    gPrintSettings = PrintUtils.getPrintSettings();    
-
-  printEngineWindow = window.openDialog("chrome://messenger/content/msgPrintEngine.xul",
-                                         "",
-                                         "chrome,dialog=no,all,centerscreen",
-                                          1, [data], statusFeedback,
-                                          gPrintSettings,false,
-                                          Components.interfaces.nsIMsgPrintEngine.MNAB_PRINT_MSG,
-                                          window);
-
-  return;
-}*/
-
 function onKeepLocalScript()
 {
   gSFE.onScriptLoaded(gSFE.getScript());
@@ -1217,16 +1033,6 @@ function onUseRemoteScript(script)
   gSFE.onScriptLoaded(script);
 }
 
-function onUndo()
-{
-  document.getElementById("sivEditor2").contentWindow.editor.undo();
-}
-
-function onRedo()
-{
-  document.getElementById("sivEditor2").contentWindow.editor.redo();
-}
-
 
 function onEditorShowMenu()
 {
@@ -1270,14 +1076,12 @@ function onEditorShowMenu()
 
 function onDelete()
 {
-  document.getElementById("sivEditor2").contentWindow.editor.replaceSelection("");
+  glue.replaceSelection();
 }
 
 function onSelectAll()
 {
-  var editor = document.getElementById("sivEditor2").contentWindow.editor;
-  editor.setSelection({line:0,ch:0},{line: editor.lineCount() - 1});
+  glue.selectAll();
 }
 
-
 var gSFE = new SieveFilterEditor();
\ No newline at end of file
diff --git a/chrome/chromeFiles/content/editor/SieveFilterEditor.xul b/chrome/chromeFiles/content/editor/SieveFilterEditor.xul
index 786a239..4053dae 100644
--- a/chrome/chromeFiles/content/editor/SieveFilterEditor.xul
+++ b/chrome/chromeFiles/content/editor/SieveFilterEditor.xul
@@ -38,6 +38,10 @@
           src="chrome://sieve/content/libs/libManageSieve/SieveAbstractClient.js"/>           
   <script type="application/javascript" 
           src="chrome://sieve/content/editor/SieveFilterEditor.js" />
+  <script type="application/javascript" 
+          src="chrome://sieve/content/editor/sieve.iframe.glue.js" />
+  <script type="application/javascript" 
+          src="chrome://sieve/content/editor/sieve.editor.text.glue.js" />
  <!-- <script type="application/javascript" 
           src="chrome://global/content/printUtils.js"/>
   <script type="application/javascript" 
@@ -52,7 +56,7 @@
   <menupopup id="ctxEditor" onpopupshowing="onEditorShowMenu();">
     <menuitem id="ctxUndo"
               label="&undoCmd.label;" accesskey="&undoCmd.accesskey;"
-              oncommand="onUndo();  event.stopPropagation();" />
+              oncommand="glue.onUndo();  event.stopPropagation();" />
     <menuseparator/>
     <menuitem id="ctxCut"
               label="&cutCmd.label;" accesskey="&cutCmd.accesskey;"
@@ -83,10 +87,10 @@
     <toolbarspacer />      
     <toolbarbutton id="btnUndo"
                    label="&edit.toolbar.undo;" class="toolbarbutton-1"
-                   oncommand="onUndo()/*goDoCommand('cmd_undo')*/;" />    
+                   oncommand="glue.onUndo()/*goDoCommand('cmd_undo')*/;" />    
     <toolbarbutton id="btnRedo"
                    label="&edit.toolbar.redo;" class="toolbarbutton-1"
-                   oncommand="onRedo()/*goDoCommand('cmd_redo');*/" />                    
+                   oncommand="glue.onRedo()/*goDoCommand('cmd_redo');*/" />                    
     <toolbarspacer />
     <toolbarbutton id="btnCut"
                    label="&edit.toolbar.cut;" class="toolbarbutton-1"
diff --git a/chrome/chromeFiles/content/editor/SieveStatus.js b/chrome/chromeFiles/content/editor/SieveStatus.js
index c99992a..4adbfac 100644
--- a/chrome/chromeFiles/content/editor/SieveStatus.js
+++ b/chrome/chromeFiles/content/editor/SieveStatus.js
@@ -31,6 +31,7 @@ var gAccount = null;
 var gCallback = null;
 var gCallbacks = null;
 
+var gCertStatus = null;
 
 var gAutoConfigEvent =
 {
@@ -100,8 +101,10 @@ function onBadCertOverride(targetSite,permanent)
                             .getService(Ci.nsICertOverrideService);
  
     var status = null;
-    
-    if (Cc["@mozilla.org/security/recentbadcerts;1"])
+    if (gCertStatus) {
+      status = gCertStatus;
+    } 
+    else if (Cc["@mozilla.org/security/recentbadcerts;1"])
     {
       status = Cc["@mozilla.org/security/recentbadcerts;1"]
                    .getService(Ci.nsIRecentBadCertsService)
@@ -134,6 +137,8 @@ function onBadCertOverride(targetSite,permanent)
       !permanent);
      
     gCallback();
+    
+    gCertStatus = null;
   }
   catch (ex)
   {
@@ -202,7 +207,9 @@ function onStatus(state, message)
     // server error
     case 4: document.getElementById('StatusErrorMsg').textContent = message;    
             break;            
-    case 5: document.getElementById("btnIgnoreBadCert").setAttribute("message", message);
+    case 5: 
+            gCertStatus = message.status;
+            document.getElementById("btnIgnoreBadCert").setAttribute("message", message.site);
             document.getElementById("btnIgnoreBadCert").setAttribute("oncommand", 
               "onBadCertOverride(this.getAttribute('message'),document.getElementById('cbBadCertRemember').checked);");
               
diff --git a/chrome/chromeFiles/content/editor/sieve.editor.glue.js b/chrome/chromeFiles/content/editor/sieve.editor.glue.js
new file mode 100644
index 0000000..3d461f5
--- /dev/null
+++ b/chrome/chromeFiles/content/editor/sieve.editor.glue.js
@@ -0,0 +1,11 @@
+
+
+sieve.editor.glue
+
+sieve.editor.glue.showSource();
+sieve.editor.glue.showGui();
+
+sieve.editor.glue.switch();
+
+sieve.editor.glue.getScript( callback);
+sieve.editor.glue.setScript(script);
diff --git a/chrome/chromeFiles/content/editor/sieve.editor.text.glue.js b/chrome/chromeFiles/content/editor/sieve.editor.text.glue.js
new file mode 100644
index 0000000..b090b52
--- /dev/null
+++ b/chrome/chromeFiles/content/editor/sieve.editor.text.glue.js
@@ -0,0 +1,171 @@
+"use strict"
+
+if (!net)
+  var net = {}
+  
+if (!net.tschmid)
+  net.tschmid = {};
+  
+if (!net.tschmid.sieve)
+  net.tschmid.sieve = {};
+
+if (!net.tschmid.sieve.editor)
+  net.tschmid.sieve.editor = {};
+
+if (!net.tschmid.sieve.editor.text)
+  net.tschmid.sieve.editor.text = {};  
+  
+if (!net.tschmid.sieve.editor.text.glue)
+  net.tschmid.sieve.editor.text.glue = {};  
+
+  
+(function() {
+
+  function SieveTextEditorGlue(id) {  
+  	this.glue = new net.tschmid.sieve.iframe.glue(id);
+  	this.id = id;
+  }
+  
+  SieveTextEditorGlue.prototype = {
+  	
+    glue : null,
+    listener : null,
+    callbacks : null,
+    id : null,
+    
+    setListener : function(listener) {      
+      this.listener = listener;
+      
+      var that = this;
+      this.glue.setListener( function(event, data) { that.onMessage(event, data); });  	
+    },
+    
+    
+    onCallback : function(event, data) {
+    	
+      if (!this.callbacks)
+        return;
+      	
+       if (!this.callbacks[event])
+      	 return;
+      	  
+       if (!Array.isArray(this.callbacks[event]))
+         return;
+      	
+       this.callbacks[event].forEach(
+         function (element) { element(data); }
+       );
+       
+       delete this.callbacks[event];      	
+    },
+    
+    onListener : function(event, data) {
+      
+      if (!this.listener)
+        return;
+    
+      if (event == "onChange")
+        this.listener.onChange();
+        
+     /* if (event == "onGetScript")
+        this.listener.onGetScript(data);*/
+      
+      if (event == "onActiveLineChange")
+        this.listener.onActiveLineChange();
+        
+      if (event == "onStringFound")
+        this.listener.onStringFound();    	
+    },
+    
+    
+    onMessage : function(event, data) {
+      // we first handle call backs...
+      this.onCallback(event,data);
+      // and then the default listeners
+      this.onListener(event,data);
+    },
+    
+    addCallback : function(id, callback) {    
+      
+      if (!this.callbacks)
+        this.callbacks = {};
+      
+      if (!this.callbacks[id])
+        this.callbacks[id] = [];
+        
+      this.callbacks[id].push(callback);
+    },
+  
+    loadScript : function(script, callback) {
+      if (callback)
+        this.addCallback("onScriptLoaded", callback);
+    	
+      this.glue.sendMessage("loadScript", script);
+    },
+    
+    getScript : function(callback) 
+    {
+      if (callback)
+        this.addCallback("onGetScript", callback);
+        
+      this.glue.sendMessage("getScript");
+    },
+  
+    setScript : function(script) 
+    {
+  	  this.glue.sendMessage("setScript", script);
+    },
+    
+    replaceSelection : function(text)
+    {
+      this.glue.sendMessage("replaceSelection",text);
+    },
+    
+    selectAll : function()
+    {
+      this.glue.sendMessage("selectAll");
+    },
+    
+    undo : function()
+    {
+      this.glue.sendMessage("undo");
+    },
+    
+    redo : function()
+    {
+      this.glue.sendMessage("redo");
+    },
+    
+    findString : function(token, isCaseSensitive, isReverse) 
+    { 
+      var data = {};
+      data.token = token;
+      data.isCaseSensitive = isCaseSensitive;
+      data.isReverse = isReverse;
+    	
+      this.glue.sendMessage("findString", data);
+    },
+    
+    replaceString : function(oldToken, newToken, isCaseSensitive, isReverse)
+    {
+      var data = {};
+      data.oldToken = oldToken;
+      data.newToken = newToken;
+      data.isCaseSensitive = isCaseSensitive;
+      data.isReverse = isReverse;
+      
+      this.glue.sendMessage("replaceString", data);
+    },
+    
+    focus : function() {
+      document.getElementById(this.id).focus();
+      this.glue.sendMessage("focus");	      	
+    }
+    
+  }    
+  
+  // Export the constructor...
+  net.tschmid.sieve.editor.text.glue = SieveTextEditorGlue;
+  
+}());
+  
\ No newline at end of file
diff --git a/chrome/chromeFiles/content/editor/sieve.editor.text.js b/chrome/chromeFiles/content/editor/sieve.editor.text.js
new file mode 100644
index 0000000..b9d6426
--- /dev/null
+++ b/chrome/chromeFiles/content/editor/sieve.editor.text.js
@@ -0,0 +1,247 @@
+"use strict"
+
+if (!net)
+  var net = {}
+  
+if (!net.tschmid)
+  net.tschmid = {};
+  
+if (!net.tschmid.sieve)
+  net.tschmid.sieve = {};
+
+if (!net.tschmid.sieve.editor)
+  net.tschmid.sieve.editor = {};
+
+if (!net.tschmid.sieve.editor.text)
+  net.tschmid.sieve.editor.text = {};  
+  
+// We need two global variables for backward compatiblity...
+// they may be removed as soon as the editor communication is migrated to post message
+var editor = null;
+var onActiveLineChange = null;
+
+
+/**
+ * Glues two frame via html5 post message.
+ **/
+  
+(function() {
+
+  var hlLine = null;
+  var listener = {}
+  
+  var glue = new net.tschmid.sieve.iframe.glue();  	
+  glue.setListener(function(event, data) { listener.onMessage(event, data) });  
+		
+  
+  function winHeight() {
+    return window.innerHeight || (document.documentElement || document.body).clientHeight;
+  }
+  
+  function setFullScreen(cm) {
+    var wrap = cm.getWrapperElement();
+    wrap.className += " CodeMirror-fullscreen";
+    wrap.style.height = winHeight() + "px";
+    document.documentElement.style.overflow = "hidden";
+    cm.refresh();
+  }        
+    
+  // This function is called externaly upon reloading and updating scripts  
+  onActiveLineChange = function() 
+  {
+    var cur = editor.getLineHandle(editor.getCursor().line);
+        
+    if (cur == hlLine)
+      return;
+    	
+    editor.removeLineClass(hlLine, "background", "activeline");
+    hlLine = editor.addLineClass(cur, "background", "activeline");
+  }    	  
+
+  function onChange() {
+  	glue.sendMessage("onChange");
+  }
+
+  function findString(token, isCaseSensitive, isReverse) { 
+  	
+    // ... convert to lowercase, if the search is not case sensitive...
+  
+    function maxCursor(start,end)
+    {
+      if (start.line > end.line)
+        return start
+
+      if (start.line < end.line)
+        return end;
+    
+      // start.line == end.line
+      if (start.ch > end.ch)
+        return start;
+      
+      return end;
+    }
+  
+    function minCursor(start,end)
+    {
+      if (start.line <end.line)
+        return start
+
+      if (start.line > end.line)
+        return end;
+    
+      // start.line == end.line
+      if (start.ch > end.ch)
+        return end;
+      
+      return start;
+    }
+  
+    var start = editor.getCursor(true);
+    var end = editor.getCursor(false);
+  
+    var cursor = editor.getSearchCursor(
+      token,
+      isReverse ? minCursor(start,end) : maxCursor(start,end),
+      !isCaseSensitive);
+  
+    if (!cursor.find(isReverse))
+    { 
+      // warp search at top or bottom
+      cursor = editor.getSearchCursor(
+        token,
+        isReverse ? {line: editor.lineCount() - 1} : {line: 0, ch: 0},
+        !isCaseSensitive);
+    
+      if (!cursor.find(isReverse))
+        return;
+    }
+  
+    if (isReverse)
+      editor.setSelection(cursor.from(), cursor.to());
+    else
+      editor.setSelection(cursor.to(), cursor.from());
+
+    glue.sendMessage("onStringFound", true);  
+    return;
+  }
+  
+  function replaceString(oldToken, newToken, isCaseSensitive, isReverse) {  	
+  	
+    if (isCaseSensitive) 
+    {
+      if (editor.getSelection() != oldToken)
+        findString(oldToken, isSensitive, isReverse);
+      
+      if (editor.getSelection() != oldToken)
+        return;
+    }
+    
+    if (!isCaseSensitive)
+    {
+      if (editor.getSelection().toLowerCase() != oldToken.toLowerCase())
+        findString(oldToken, isCaseSensitive, isReverse);
+      
+      if (editor.getSelection().toLowerCase() != oldToken.toLowerCase())
+        return;
+    }
+
+    editor.replaceSelection(newToken);    
+
+    onChange();
+  }
+
+  	 	 
+  listener.onMessage = function(event, data) {  
+  	
+  	if (event == "focus") {
+      editor.focus();			
+  	}
+  	  	
+  	// Load a new script. It will discard the current script
+  	// the history and the cursorposition are reset to defaults.
+  	if (event == "loadScript") {
+  	  editor.setValue(data);
+      editor.setCursor({line:0,ch:0});
+      editor.clearHistory();
+      
+      // ensure the active line cursor changed...
+      onActiveLineChange();
+      
+      glue.sendMessage("onScriptLoaded");
+        
+      return;
+  	}
+  	  
+  	// Updates the current script. The history as well as 
+  	// the cursor position is maintained.
+	if (event == "setScript") { 
+	  editor.setValue(data);
+	  return;
+	}
+		
+	if (event == "getScript") {
+	  	
+	  // Get the current script...
+	  var script = editor.getValue();
+	  // ... and ensure the line endings are sanatized
+	  script = script.replace(/\r\n|\r|\n|\u0085|\u000C|\u2028|\u2029/g,"\r\n");
+	  	
+	  glue.sendMessage("onGetScript", script);	    
+	  return;
+	}
+	  
+	if (event == "replaceSelection") {
+	  editor.replaceSelection(data);
+	  return;
+	}
+	  
+	if (event == "selectAll") {
+	  editor.setSelection({line:0,ch:0},{line: editor.lineCount() - 1});
+	  return;
+	}
+	  
+	if (event == "undo") {
+	  editor.undo();
+	  return;
+	}
+	  
+	if (event == "redo") {
+	  editor.redo();
+	  return;
+	}
+	  
+	if (event == "replaceString") {	
+	  replaceString(data.oldToken, data.newToken, data.isSensitive, data.isReverse);
+	  return;
+	}
+	  
+	if (event == "findString") {
+	  findString(data.token, data.isCaseSensitive, data.isReverse);
+	  return;
+	}	
+  };
+
+  // Export the constructor...
+  net.tschmid.sieve.editor.text.init = function() {
+  	
+    CodeMirror.on(window, "resize", function() {
+      document.body.getElementsByClassName("CodeMirror-fullscreen")[0]
+        .CodeMirror.getWrapperElement().style.height = winHeight() + "px";
+    });
+    
+    editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+      lineNumbers: true,
+      theme: "eclipse",
+      matchBrackets: true
+    });
+  
+    setFullScreen(editor,true);
+    
+    hlLine = editor.addLineClass(0, "background", "activeline");
+  
+    editor.on("cursorActivity", function() { onActiveLineChange(); });        
+    editor.on("change", function() { onChange(); });    
+  };
+  
+}());
+  
\ No newline at end of file
diff --git a/chrome/chromeFiles/content/editor/sieve.iframe.glue.js b/chrome/chromeFiles/content/editor/sieve.iframe.glue.js
new file mode 100644
index 0000000..c101474
--- /dev/null
+++ b/chrome/chromeFiles/content/editor/sieve.iframe.glue.js
@@ -0,0 +1,89 @@
+"use strict"
+
+
+if (!net)
+  var net = {}
+  
+if (!net.tschmid)
+  net.tschmid = {};
+  
+if (!net.tschmid.sieve)
+  net.tschmid.sieve = {};
+
+if (!net.tschmid.sieve.iframe)
+  net.tschmid.sieve.iframe = {};
+  
+if (!net.tschmid.sieve.iframe.glue)
+  net.tschmid.sieve.iframe.glue = {};
+
+  
+/**
+ * Glues two frame via html5 post message.
+ **/
+  
+(function() {
+
+  function SieveIframeGlue(target) {
+    this.target = target;
+  }
+  
+  SieveIframeGlue.prototype = {
+  	
+    target : null,
+    listener : null,
+
+    getTarget : function() {    	
+    	  
+      if (!this.target)
+        return parent;
+            		
+      var elm = document.getElementById(this.target);  	 
+      
+  	  if (elm && elm.contentWindow)
+  	    return elm.contentWindow;
+          	
+  	  throw "No Target Element found";  	  
+    },  
+    
+    sendMessage : function(event, data) {
+    	
+  	  var msg = {};
+  	  msg.event = event;
+  	  msg.data = data  
+  	
+  	  var target = this.getTarget();
+  	  target.postMessage(JSON.stringify(msg),'*');
+    },
+	  
+    setListener : function(listener) {
+  	
+  	  var that = this;
+  	  
+  	  if (!this.listener)
+  	    window.addEventListener("message", function(event) { that.onMessage(event); }, false);
+    	   	 
+  	  this.listener = listener;
+    },
+    
+    getListener : function() {
+    	return this.listener;
+    },
+  
+    onMessage : function(event) {
+       // Do we trust the sender of this message?
+      //if (event.origin !== "http://example.com:8080")
+      //  return;
+    
+      if (!this.listener)
+        return;
+              
+      var msg = JSON.parse(event.data)      
+      this.listener(msg.event, msg.data);
+    }
+  } 
+    
+  // Export the constructor...
+  net.tschmid.sieve.iframe.glue = SieveIframeGlue;
+  
+}());
+  
\ No newline at end of file
diff --git a/chrome/chromeFiles/content/libs/libManageSieve/SieveAbstractClient.js b/chrome/chromeFiles/content/libs/libManageSieve/SieveAbstractClient.js
index 9665569..faa8853 100644
--- a/chrome/chromeFiles/content/libs/libManageSieve/SieveAbstractClient.js
+++ b/chrome/chromeFiles/content/libs/libManageSieve/SieveAbstractClient.js
@@ -127,9 +127,13 @@ SieveAbstractClient.prototype.onStatusChange
 }
   
 SieveAbstractClient.prototype.onBadCert
-    = function(targetSite)
+    = function(targetSite, status )
 {
-  this.disconnect(5,targetSite);
+  var message = {};
+  message.status = status;
+  message.site = targetSite;
+  
+  this.disconnect(5,message);
 }
   
 SieveAbstractClient.prototype.observe
diff --git a/chrome/chromeFiles/content/libs/libSieveDOM/RFC5228/logic/SieveActions.js b/chrome/chromeFiles/content/libs/libSieveDOM/RFC5228/logic/SieveActions.js
index 9347497..b134f55 100644
--- a/chrome/chromeFiles/content/libs/libSieveDOM/RFC5228/logic/SieveActions.js
+++ b/chrome/chromeFiles/content/libs/libSieveDOM/RFC5228/logic/SieveActions.js
@@ -219,8 +219,7 @@ function SieveFileInto(docshell,id)
   
   this.semicolon = this._createByName("atom/semicolon");
       
-  this.string = this._createByName("string");
-  this.string.init("\"INBOX\"");
+  this.string = this._createByName("string","\"INBOX\"");
 }
 
 SieveFileInto.prototype = Object.create(SieveAbstractElement.prototype);
diff --git a/chrome/chromeFiles/content/libs/libSieveDOM/RFC5228/logic/SieveNumbers.js b/chrome/chromeFiles/content/libs/libSieveDOM/RFC5228/logic/SieveNumbers.js
index c7b2323..6cd8cb6 100644
--- a/chrome/chromeFiles/content/libs/libSieveDOM/RFC5228/logic/SieveNumbers.js
+++ b/chrome/chromeFiles/content/libs/libSieveDOM/RFC5228/logic/SieveNumbers.js
@@ -39,7 +39,7 @@ SieveNumber.prototype.init
 {
   this._number = parser.extractNumber();
 
-  if (parser.isChar(['K','M','G']))
+  if (parser.isChar(['K','k','M','m','G','g']))
     this._unit = parser.extractChar();
   
   return this;
@@ -64,7 +64,7 @@ SieveNumber.prototype.unit
   = function (unit)
 {
   if (typeof(unit) === "undefined")
-    return this._unit;
+    return this._unit.toUpperCase();
 
   if ((unit != "") && (unit != "K") && (unit != "M") && (unit != "G"))
     throw "Invalid unit mut be either K, M or G";  
diff --git a/chrome/chromeFiles/content/libs/libSieveDOM/RFC5229/logic/SieveVariables.js b/chrome/chromeFiles/content/libs/libSieveDOM/RFC5229/logic/SieveVariables.js
index 264076c..ad5fdd0 100644
--- a/chrome/chromeFiles/content/libs/libSieveDOM/RFC5229/logic/SieveVariables.js
+++ b/chrome/chromeFiles/content/libs/libSieveDOM/RFC5229/logic/SieveVariables.js
@@ -16,13 +16,31 @@
 // set [MODIFIER] <name: string> <value: string>
 
 
+/**
+ * The "set" action stores the specified value in the variable identified by name.  
+ * The name MUST be a constant string and conform to the syntax of variable-name.  
+ * Match variables cannot be set.  A namespace cannot be used unless an extension 
+ * explicitly allows its use in "set". An invalid name MUST be detected as a syntax error.
+ *
+ * Variable names are case insensitive.
+ * 
+ * Syntax:  set [MODIFIER] <name: string> <value: string>
+ * 
+ * @param {} docshell
+ * @param {} id
+ */
 function SieveSetVariable(docshell,id) 
 {
   SieveAbstractElement.call(this,docshell,id); 
   
-  this.whiteSpace = this._createByName("whitespace"," ");
-  this.flaglist = this._createByName("stringlist");
-  this.semicolon = this._createByName("atom/semicolon");
+  this.items = [];
+  
+  this.items[0] = this._createByName("whitespace"," ");  
+  this.items[1] = this._createByName("modifier","");
+  this.items[2] = this._createByName("string","\"variable\"");
+  this.items[3] = this._createByName("whitespace"," ");
+  this.items[4] = this._createByName("string","\"value\""); 
+  this.items[5] = this._createByName("atom/semicolon");
 }
 
 SieveSetVariable.prototype = Object.create(SieveAbstractElement.prototype);
@@ -55,19 +73,26 @@ SieveSetVariable.nodeType  = function () {
 SieveSetVariable.prototype.init
     = function (parser)
 {  
+  //debugger;	
   parser.extract("set");
-  
-  // ... eat the deadcode before the string...
-  this.whiteSpace.init(parser);
+    
+  // ... eat the deadcode before the modifier...
+  this.items[0].init(parser);
       
   // the optional modifier
-  
+  this.items[1].init(parser);
+    
   // the name
+  this.items[2].init(parser);
+  
+  // the separating whitespace
+  this.items[3].init(parser);
   
   // the value
-  //this.flaglist.init(parser)
-
-  this.semicolon.init(parser);
+  this.items[4].init(parser);
+  
+  // semicolon
+  this.items[5].init(parser);
     
   return this;
 }
@@ -76,10 +101,16 @@ SieveSetVariable.prototype.init
 SieveSetVariable.prototype.toScript
     = function ()
 {
-  return "set"
-    + this.whiteSpace.toScript()
-    + this.flaglist.toScript()
-    + this.semicolon.toScript();
+ // debugger;
+  
+  var result = "set"
+  
+  this.items.forEach( function(element, index, array) {
+  	if (element)
+  	  result += element.toScript();
+  });  
+  
+  return result;
 }
 
 
@@ -97,13 +128,21 @@ function SieveTestString(docshell,id)
 {
   SieveAbstractElement.call(this,docshell,id); 
 
-  this.whiteSpace = [];
-  this.whiteSpace[0] = this._createByName("whitespace", " ");
-  this.whiteSpace[1] = this._createByName("whitespace", " ");
-  this.whiteSpace[2] = this._createByName("whitespace", " ");    
-
-  this.matchType      = null;
-  this.flaglist = this._createByName("stringlist");
+  this.items = [];
+ 
+  this.items[0] = this._createByName("whitespace", " ");
+  // Matchtype
+  this.items[1] = this._createByName("match-type");
+  this.items[2] = this._createByName("whitespace", " ");
+  // Comparator
+  this.items[3] = this._createByName("comparator");    
+  this.items[4] = this._createByName("whitespace", " ");
+  // Source
+  this.items[5] = this._createByName("stringlist");
+  this.items[6] = this._createByName("whitespace", " ");
+  // key list
+  this.items[7] = this._createByName("stringlist");
+  
 }
 
 SieveTestString.prototype = Object.create(SieveAbstractElement.prototype);
@@ -141,20 +180,31 @@ SieveTestString.nodeType  = function () {
 SieveTestString.prototype.init
     = function (parser)
 {
-  parser.extract("hasflag")
-  
-  this.whiteSpace[0].init(parser)
+  parser.extract("string");
   
+  this.items[0].init(parser);
   
+  // match-types
   if (this._probeByName("match-type",parser))
   {
-    this.matchType = this._createByName("match-type",parser);    
-    this.whiteSpace[1].init(parser);
+    this.items[1] = this._createByName("match-type",parser);    
+    this.items[2].init(parser);
+  }
+
+  // Comparator
+  if (this._probeByName("comparator",parser))
+  {
+    this.items[3] = this._createByName("comparator");    
+    this.items[4].init(parser);  	
   }
+
+  // Source
+  this.items[5].init(parser);
+  this.items[6].init(parser);
+  
+  // Keylist
+  this.items[7].init(parser);
   
-  this.flaglist.init(parser);
-  this.whiteSpace[2].init(parser);
-      
   return this;
 }    
 
@@ -163,16 +213,110 @@ SieveTestString.prototype.init
 SieveTestString.prototype.toScript
     = function ()
 {
-  return "hasflag"
-    + this.whiteSpace[0].toScript()
-    + ((this.matchType != null)?this.matchType[0].toScript():"")
-    + ((this.matchType != null)?this.whiteSpace[1].toScript():"")
-    + this.flaglist.toScript()
-    + this.whiteSpace[2].toScript();
+	var result = "string";
+	
+	result += this.items[0].toScript();
+	
+	if (!this.items[1].isOptional()) {
+		result += this.items[1].toScript();
+		result += this.items[2].toScript();
+	}
+	
+	if (!this.items[3].isOptional()) {
+		result += this.items[3].toScript();
+		result += this.items[4].toScript();
+	}
+	
+	result += this.items[5].toScript();
+	result += this.items[6].toScript();
+	
+	result += this.items[7].toScript();
+
+	return result;
 }
 
 
+//*******************************************************************//
+
+function SieveLowerModifier(docshell, id) {
+  SieveAbstractElement.call(this, docshell, id);
+}
 
+SieveLowerModifier.prototype = Object.create(SieveAbstractElement.prototype);
+SieveLowerModifier.prototype.constructor = SieveLowerModifier;
+
+SieveLowerModifier.nodeName = function () {
+  return "modifier/lower";
+}
+
+SieveLowerModifier.nodeType  = function () {
+  return "modifier/";
+}
+
+SieveLowerModifier.isElement
+    = function (parser, lexer)
+{    
+
+  if (parser.startsWith(":lower"))
+    return true;
+  
+  return false;
+}
+
+
+SieveLowerModifier.prototype.init
+    = function (parser)
+{	
+  parser.extract(":lower");    
+  return this;
+}
+
+SieveLowerModifier.prototype.toScript
+    = function ()
+{    
+  return ":lower";
+}
+
+//*******************************************************************//
+
+function SieveUpperModifier(docshell, id) {
+  SieveAbstractElement.call(this, docshell, id);
+}
+
+SieveUpperModifier.prototype = Object.create(SieveAbstractElement.prototype);
+SieveUpperModifier.prototype.constructor = SieveUpperModifier;
+
+SieveUpperModifier.nodeName = function () {
+  return "modifier/upper";
+}
+
+SieveUpperModifier.nodeType  = function () {
+  return "modifier/";
+}
+
+SieveUpperModifier.isElement
+    = function (parser, lexer)
+{    
+
+  if (parser.startsWith(":upper"))
+    return true;
+  
+  return false;
+}
+
+
+SieveUpperModifier.prototype.init
+    = function (parser)
+{	
+  parser.extract(":upper");    
+  return this;
+}
+
+SieveUpperModifier.prototype.toScript
+    = function ()
+{    
+  return ":upper";
+}
 
 //*******************************************************************//
 
@@ -215,93 +359,210 @@ SieveLowerFirstModifier.prototype.toScript
   return ":lowerfirst";
 }
 
+//*******************************************************************//
+
+function SieveUpperFirstModifier(docshell, id) {
+  SieveAbstractElement.call(this, docshell, id);
+}
+
+SieveUpperFirstModifier.prototype = Object.create(SieveAbstractElement.prototype);
+SieveUpperFirstModifier.prototype.constructor = SieveUpperFirstModifier;
+
+SieveUpperFirstModifier.nodeName = function () {
+  return "modifier/upperFirst";
+}
+
+SieveUpperFirstModifier.nodeType  = function () {
+  return "modifier/";
+}
+
+SieveUpperFirstModifier.isElement
+    = function (parser, lexer)
+{    
+
+  if (parser.startsWith(":upperfirst"))
+    return true;
+  
+  return false;
+}
+
+
+SieveUpperFirstModifier.prototype.init
+    = function (parser)
+{	
+  parser.extract(":upperfirst");    
+  return this;
+}
+
+SieveUpperFirstModifier.prototype.toScript
+    = function ()
+{    
+  return ":upperfirst";
+}
 
 //*******************************************************************//
 
-function SieveModifier(docshell, id) {
-	// call super constructor.
-	SieveAbstractElement.call(this, docshell, id);
-	
-	// the default matchtype is by definition a :is
-	this.type = this._createByName("match-type/is",":is");
-	this.optional = true;
+function SieveQuoteWildcardModifier(docshell, id) {
+  SieveAbstractElement.call(this, docshell, id);
 }
 
-SieveModifier.prototype = Object.create(SieveAbstractElement.prototype);
-SieveModifier.prototype.constructor = SieveModifier;
+SieveQuoteWildcardModifier.prototype = Object.create(SieveAbstractElement.prototype);
+SieveQuoteWildcardModifier.prototype.constructor = SieveQuoteWildcardModifier;
 
-SieveModifier.nodeName = function () {
-  return "match-type";
+SieveQuoteWildcardModifier.nodeName = function () {
+  return "modifier/quotewildcard";
 }
 
-SieveModifier.nodeType  = function () {
-  return "comparison";
+SieveQuoteWildcardModifier.nodeType  = function () {
+  return "modifier/";
 }
 
-SieveModifier.isElement
+SieveQuoteWildcardModifier.isElement
     = function (parser, lexer)
-{
-  return lexer.probeByClass(["match-type/"], parser);
+{    
+
+  if (parser.startsWith(":quotewildcard"))
+    return true;
+  
+  return false;
 }
 
-SieveModifier.prototype.require
-    = function (imports)
+
+SieveQuoteWildcardModifier.prototype.init
+    = function (parser)
+{	
+  parser.extract(":quotewildcard");    
+  return this;
+}
+
+SieveQuoteWildcardModifier.prototype.toScript
+    = function ()
+{    
+  return ":quotewildcard";
+}
+
+
+
+//*******************************************************************//
+
+function SieveLengthModifier(docshell, id) {
+  SieveAbstractElement.call(this, docshell, id);
+}
+
+SieveLengthModifier.prototype = Object.create(SieveAbstractElement.prototype);
+SieveLengthModifier.prototype.constructor = SieveLengthModifier;
+
+SieveLengthModifier.nodeName = function () {
+  return "modifier/length";
+}
+
+SieveLengthModifier.nodeType  = function () {
+  return "modifier/";
+}
+
+SieveLengthModifier.isElement
+    = function (parser, lexer)
+{    
+
+  if (parser.startsWith(":length"))
+    return true;
+  
+  return false;
+}
+
+
+SieveLengthModifier.prototype.init
+    = function (parser)
+{	
+  parser.extract(":length");    
+  return this;
+}
+
+SieveLengthModifier.prototype.toScript
+    = function ()
+{    
+  return ":length";
+}
+
+/******************************************************************************/
+
+function SieveModifierList(docshell,id)
 {
-  this.type.require(imports);
+  SieveAbstractElement.call(this,docshell,id);
+  this.modifiers = [];
 }
 
-SieveModifier.prototype.init
-    = function (parser)    
+SieveModifierList.prototype = Object.create(SieveAbstractElement.prototype);
+SieveModifierList.prototype.constructor = SieveModifierList;
+
+SieveModifierList.isElement
+   = function (parser, lexer)
 {
-  this.type = this._createByClass(["match-type/"],parser);
+  return lexer.probeByClass(["modifier/"],parser);
+}
+
+SieveModifierList.nodeName = function () {
+  return "modifier";
+}
+
+SieveModifierList.nodeType  = function () {
+  return "modifier";
+}
 
-  if (this.type instanceof SieveIsMatch)
-    this.optional = false;  
+SieveModifierList.prototype.init
+    = function (parser)
+{   
+  this.modifiers = [];
   
+  while (this._probeByClass("modifier/", parser)) {
+
+  	// extract the modifier
+  	this.modifiers.push(this._createByClass("modifier/", parser));
+  	
+  	// and the white space we know there has to be one...
+  	this.modifiers.push(this._createByName("whitespace", parser)); 	
+  }
+   
   return this;
 }
 
-SieveModifier.prototype.modifier
-    = function (value)
+SieveModifierList.prototype.toScript
+    = function()
 {
-  if(typeof(value) === "undefined")
-    return this.type.toScript();
-    
-  value = value.toLowerCase();
+  var result = "";
   
-  if (!this._probeByClass(["match-type/"],value)) 
-    throw "Unkonwn Match type >>"+value+"<<";
+  this.modifiers.forEach(function(element, index, array) {
+  	  result += element.toScript();
+  } );
     
-  this.type = this._createByClass(["match-type/"],value);	     
-  
-  return this;
+  return result;  
 }
 
-SieveModifier.prototype.toScript
-    = function ()
+SieveModifierList.prototype.require
+    = function (imports)
 {
-  if (this.isOptional())
-    return "";
-    
-  return this.type.toScript();
+  this.modifiers.forEach( function(element, index, array) {
+  	element.require(imports);
+  });
 }
 
 
-/******************************************************************************/
 
 if (!SieveLexer)
   throw "Could not register variables extension";
 
 SieveLexer.register(SieveSetVariable);
-            
+
 SieveLexer.register(SieveTestString);
 
-//SieveLexer.register(SieveLengthModifier);
-//SieveLexer.register(SieveQuoteWildcardModifier);
-//SieveLexer.register(SieveUpperModifier);
-//SieveLexer.register(SieveLowerModifier);
-//SieveLexer.register(SieveUpperFirstModifier);
-//SieveLexer.register(SieveLowerFirstModifier);
+// The order matters here, first the longer strings then the shorter.
+// Otherwise Lower will match before lowerfirst.
+SieveLexer.register(SieveLowerFirstModifier);
+SieveLexer.register(SieveUpperFirstModifier);
+SieveLexer.register(SieveLowerModifier);
+SieveLexer.register(SieveUpperModifier);
+SieveLexer.register(SieveQuoteWildcardModifier);
+SieveLexer.register(SieveLengthModifier);
 
-SieveLexer.register(SieveModifier);
+SieveLexer.register(SieveModifierList);
  
\ No newline at end of file
diff --git a/chrome/chromeFiles/content/libs/libSieveDOM/SieveGui.html b/chrome/chromeFiles/content/libs/libSieveDOM/SieveGui.html
index 2017d0a..7ba3920 100644
--- a/chrome/chromeFiles/content/libs/libSieveDOM/SieveGui.html
+++ b/chrome/chromeFiles/content/libs/libSieveDOM/SieveGui.html
@@ -8,8 +8,7 @@
 
   <!-- Global Imports -->  
   <script type="application/javascript" src="./../jQuery/jquery-2.1.1.min.js"></script>
-  <!--<script type="application/javascript" src="UI/jquery-ui.js"></script>-->
-  
+    
   <!-- Basic Sieve Elements -->
   <script type="application/javascript" src="toolkit/SieveParser.js"></script>
   <script type="application/javascript" src="toolkit/SieveLexer.js"></script>
@@ -244,7 +243,7 @@ function debug(obj)
       </div>
     </div>
 	
-<div id="debug2">
+<div id="debug2" style="display:none">
 <div>
    <div id="boxScript" style="display:none;overflow: hidden;width: 100%; ">  
      <div style="float:left; padding:5px;">
diff --git a/chrome/chromeFiles/content/libs/libSieveDOM/toolkit/SieveLexer.js b/chrome/chromeFiles/content/libs/libSieveDOM/toolkit/SieveLexer.js
index cad4560..a2cf4e5 100644
--- a/chrome/chromeFiles/content/libs/libSieveDOM/toolkit/SieveLexer.js
+++ b/chrome/chromeFiles/content/libs/libSieveDOM/toolkit/SieveLexer.js
@@ -52,7 +52,11 @@ var SieveLexer =
   
   getConstructor : function(selectors, token)
   {
-    if (!selectors.length)
+  	if (typeof(selectors) === "string")
+  	  selectors = [selectors];
+  	
+  	  
+    if (!Array.isArray(selectors))
       throw "Invalid Type list, not an array";
       
     // enumerate all selectors...
@@ -130,6 +134,9 @@ var SieveLexer =
     // If there's no data then skip
     if ((typeof(parser) === "undefined") || parser.empty())
       return false;
+      
+    if (typeof(this.names[name]) === "undefined")
+      throw "Unknown name " +name;
 
     if (!this.names[name].onCapable(this._capabilities))
       return false;
@@ -143,6 +150,7 @@ var SieveLexer =
   /**
    * Tests if the given Data is parsable
    * @param {} type
+   *   either a single type as string or a list of things containing all type to test.
    * @param {} data
    * @return {Boolean}
    */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/sieve-extension.git



More information about the Pkg-mozext-commits mailing list