/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

(function (aGlobal) {
  const Cu = Components.utils;
  Cu.import("resource://gre/modules/XPCOMUtils.jsm");
  XPCOMUtils.defineLazyModuleGetter(this,
                                    "prefs",
                                    "resource://tb-bug766495-modules/lib/prefs.js");
  var tbBug766495 = {
    init: function() {
      window.removeEventListener('DOMContentLoaded', this, false);
      window.addEventListener('unload', this, false);
      document.documentElement.addEventListener('compose-window-init', this, false);
      document.documentElement.addEventListener('compose-window-close', this, false);
    },
    destroy: function() {
      window.removeEventListener('unload', this, false);
      document.documentElement.removeEventListener('compose-window-init', this, false);
      document.documentElement.removeEventListener('compose-window-close', this, false);
    },
    activateComposeWindow: function() {
    },
    deactivateComposeWindow: function() {
    },

    handleEvent: function(aEvent) {
      switch (aEvent.type) {
      case 'DOMContentLoaded':
        this.init();
        return;

      case 'unload':
        this.destroy();
        return;

      case 'compose-window-init':
        this.activateComposeWindow();
        break;

      case 'compose-window-close':
        this.deactivateComposeWindow();
        break;
      }
    }
  };
  window.addEventListener('DOMContentLoaded', tbBug766495, false);
  aGlobal.tbBug766495 = tbBug766495;
})(this);

@@ -478,16 +478,56 @@
 s.js%22);%0A
+  var oldPurgeAsk, oldPurgeThresholdMB;%0A
   var tb
@@ -1177,52 +1177,405 @@
     
-%7D,%0A    deactivateComposeWindow: function() %7B
+  oldPurgeAsk = prefs.getPref(%22mail.purge.ask%22);%0A      oldPurgeThresholdMB = prefs.getPref(%22mail.purge_threshhold_mb%22);%0A      prefs.setPref(%22mail.purge.ask%22, true);%0A      prefs.setPref(%22mail.purge_threshhold_mb%22, 1000 * 1000);%0A    %7D,%0A    deactivateComposeWindow: function() %7B%0A      prefs.setPref(%22mail.purge.ask%22, oldPurgeAsk);%0A      prefs.setPref(%22mail.purge_threshhold_mb%22, oldPurgeThresholdMB);
 %0A   

Add concept code for a single compose window to force stop automatic compaction