[Pkg-mozext-commits] [nostalgy] 89/235: *** empty log message ***

David Prévot taffit at alioth.debian.org
Tue Oct 8 20:41:50 UTC 2013


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

taffit pushed a commit to branch master
in repository nostalgy.

commit 5e107a90b418be756ec02eafc5c06c57d7ce4d09
Author: frisch <frisch at 56b81dcf-5a2f-0410-9db0-014be2e416ff>
Date:   Sat May 26 13:05:15 2007 +0000

    *** empty log message ***
    
    
    git-svn-id: http://nostalgy.googlecode.com/svn/trunk@89 56b81dcf-5a2f-0410-9db0-014be2e416ff
---
 CHANGES                        |    1 +
 content/QREditor.xul           |   11 -----
 content/about.xhtml            |   34 ++++++++++++++-
 content/dummy_window.xul       |    4 ++
 content/edit_prefs.js          |   52 ++++++++++++++++++++++
 content/edit_prefs.xul         |    2 +
 content/messageOverlay.xul     |    9 ++++
 content/nostalgy.js            |   94 ++++++++++++++++++++++------------------
 content/thunderbirdOverlay.xul |    9 ++++
 files                          |   16 +++----
 10 files changed, 169 insertions(+), 63 deletions(-)

diff --git a/CHANGES b/CHANGES
index 3d2c280..5fcbafa 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,5 @@
 Since 0.2.13
+  - a system to export/import Nostalgy's rules (through e-mails)
   - bug fix: custom shortcuts should not be recognized when typing
     in a text box (QuickSearch or Nostalgy's completion box)
 
diff --git a/content/QREditor.xul b/content/QREditor.xul
deleted file mode 100644
index 102db05..0000000
--- a/content/QREditor.xul
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0"?>
-<!-- This window is necessary because the mozilla sendmsg function needs to close a window for many reasons-->
-<window id="QREditor" 
-			xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-            title="Sending Message Now"
-            persist="sizemode">
-
-<hbox id="QREditorBox" persist="height width" height="10" width="10">
-    <editor type="content-primary" id="QRtemp-content-frame" src="about:blank" name="browser.message.body" width="2"/>
-</hbox>
-</window>
diff --git a/content/about.xhtml b/content/about.xhtml
index e288ab6..cd31620 100644
--- a/content/about.xhtml
+++ b/content/about.xhtml
@@ -22,6 +22,13 @@
    <h2>Usage directions for Nostalgy</h2>
 
    <p>
+   Please visit
+   <a href="http://alain.frisch.fr/soft_mozilla.html">Nostalgy's
+   homepage</a>. It contains a copy of this page that might be
+   better read in your browser!
+   </p>
+
+   <p>
    Nostalgy adds several keyboard shortcuts to improve your
    productivity with Thunderbird. A custom preference dialog 
    for Nostalgy is available through the Tools menu. Below we
@@ -143,6 +150,31 @@ uppercase, you don't need to press Shift.</p>
    it is global.
    </p>
 
+   <h3>Exporting and importing rules</h3>
+
+   <p>
+   Nostalgy comes with a backup system for rules. In the Preferences
+   dialog (tab "Rules"), there is a button "Send rules by email".
+   It allows you to send an e-mail to any address (your own address
+   by default). This special e-mail contains a copy of all your rules.
+   When you read such an e-mail, Thunderbird will show you
+   a button "Import Nostalgy rules", which will allow you to import
+   all the rules found in the message.
+   </p>
+
+   <p>
+   This import/export feature can be used as a backup mechanism, or to
+   exchange rules between various computer or Thunderbird profiles.
+   </p>
+
+   <p>
+   <b>IMPORTANT:</b> importing rules from an e-email will destroy your
+   current rules. Use this feature with caution. Also, don't import
+   rules from an e-mail sent by a user you don't trust (this could
+   allow arbitration Javascript code execution).
+   </p>
+   
+
    <h3>QuickSearch</h3>
 
    <p>Nostalgy adds a few features to Thunderbird's QuickSearh features.</p>
@@ -253,7 +285,7 @@ the input box starts with a colon character, or if no folder matches.
 
    <hr/>
 
-   <p>The Nostalgy extension has been written by Alain Frisch (<tt>Alain.Frisch at inria.fr</tt>). Comments and suggestions are welcome!  Donations
+   <p>The Nostalgy extension has been written by Alain Frisch (<a href="mailto:alain at frisch.fr">alain at frisch.fr</a>). Comments and suggestions are welcome!  Donations
 can be sent to the Paypal account <tt>alain at frisch.fr</tt>.</p>
   </body>
 </html>
diff --git a/content/dummy_window.xul b/content/dummy_window.xul
new file mode 100644
index 0000000..2aafc28
--- /dev/null
+++ b/content/dummy_window.xul
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<window	xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+       	title="Sending Message ...">
+</window>
diff --git a/content/edit_prefs.js b/content/edit_prefs.js
index 8407607..be10367 100644
--- a/content/edit_prefs.js
+++ b/content/edit_prefs.js
@@ -45,6 +45,58 @@ var keys = [
    };
 })();
 
+function NostalgySendRules() {
+  var sAccountManager = 
+    Components.classes["@mozilla.org/messenger/account-manager;1"].
+    getService(Components.interfaces.nsIMsgAccountManager);
+  
+  var identity = 
+    sAccountManager.allIdentities.GetElementAt(0).
+    QueryInterface(Components.interfaces.nsIMsgIdentity);
+
+  var to = prompt("Do you want to send a mail to yourself (or someone else)\n"
++ "with your current set of Nostalgy's rules?  If yes, choose the address.", identity.email);
+  if (!to) return;
+
+  var gMsgCompose = 
+    Components.classes["@mozilla.org/messengercompose/compose;1"].
+    createInstance(Components.interfaces.nsIMsgCompose);
+  
+  var params = 
+    Components.classes["@mozilla.org/messengercompose/composeparams;1"].
+    createInstance(Components.interfaces.nsIMsgComposeParams);
+  
+  var compfields =
+    Components.classes["@mozilla.org/messengercompose/composefields;1"].
+    createInstance(Components.interfaces.nsIMsgCompFields);
+  
+  var progress = 
+    Components.classes["@mozilla.org/messenger/progress;1"].
+    createInstance(Components.interfaces.nsIMsgProgress);
+
+  var account = sAccountManager.defaultAccount;
+  
+  compfields.to = to;
+  compfields.subject = "Nostalgy Rules from " + identity.fullName;
+  compfields.body = "This e-mail was automatically generated by Nostalgy (Thunderbird Extension). It stores a set of Nostalgy rules.\nIf you read this message under Thunderbird, with Nostalgy installed, you can import these rules by clicking on the 'Extract Nostalgy rules' button that should appear above.\n\nFor more information about Nostalgy: http://alain.frisch.fr/soft_mozilla.html\n\nBEGIN RULES\n" + MkPrefStr() + "\nEND RULES\n\n";
+  
+  params.identity = identity;
+  params.composeFields = compfields;
+  params.format = 2;  // PlainText
+  
+  var tmp_win = 
+    window.open("chrome://nostalgy/content/dummy_window.xul", "_blank", 
+		"chrome,dialog='no',width=0,height=0,centerscreen,alwaysLowered");
+  setTimeout(function(){ tmp_win.minimize(); },2000);
+
+  gMsgCompose.Initialize(tmp_win, params );
+
+  gMsgCompose.SendMsg(Components.interfaces.nsIMsgCompDeliverMode.Now, 
+		      identity, account.key, null, progress);
+}
+
+
+
 function SetItem(item, rule) {
   var f = item.childNodes.item(0);
   var lab = "";
diff --git a/content/edit_prefs.xul b/content/edit_prefs.xul
index d442ec7..aaf2d1d 100644
--- a/content/edit_prefs.xul
+++ b/content/edit_prefs.xul
@@ -55,6 +55,8 @@ shortcuts to move/copy the message to this folder.</label>
   <separator orient="vertical"/>
   <button label="Move up" oncommand="DoMoveUp();"/>
   <button label="Move down" oncommand="DoMoveDown();"/>
+  <separator orient="vertical"/>
+  <button label="Send rules by email" oncommand="NostalgySendRules();"/>
   </hbox>
  </vbox>
  </groupbox>
diff --git a/content/messageOverlay.xul b/content/messageOverlay.xul
index 07b7fcc..297e409 100644
--- a/content/messageOverlay.xul
+++ b/content/messageOverlay.xul
@@ -50,4 +50,13 @@
   </statusbarpanel>
  </statusbar>
 
+ <hbox id="expandedHeaderView">
+   <vbox insertafter="editMessageBox" class="header-part1">
+    <spacer flex="1"/>
+    <button id="nostalgy_extract_rules_buttons"
+	label="Import Nostalgy rules" oncommand="NostalgyExtractRules();" hidden="true"/>
+    <spacer flex="1"/>
+   </vbox>
+ </hbox>
+
 </overlay>
diff --git a/content/nostalgy.js b/content/nostalgy.js
index ae2fda0..4326930 100644
--- a/content/nostalgy.js
+++ b/content/nostalgy.js
@@ -7,6 +7,7 @@ var nostalgy_statusBar = null;
 var nostalgy_label = null;
 var nostalgy_th_statusBar = null;
 var nostalgy_cmdLabel = null;
+var nostalgy_extracted_rules = "";
 var custom_keys = { };
 var timeout_regkey = 0;
 
@@ -157,6 +158,17 @@ var NostalgyRules =
 
 NostalgyRules.register();
 
+function NostalgyExtractRules() {
+  var s = nostalgy_extracted_rules;
+  if (s == "") return;
+  if (confirm(
+"Do you want to install the rules contained in this message?\n"+
+"This will overwrite your current set of rules.\n"+
+"IMPORTANT: do this only if you trust the sender of this e-mail.\n"
+)) 
+    NostalgyRules._branch.setCharPref("rules", s)
+}
+
 /** Driver **/
 
 var default_label = "";
@@ -230,11 +242,50 @@ function onNostalgyLoad() {
  if (mSession) 
    mSession.AddFolderListener(NostalgyFolderListener, 
       nsIFolderListener.added | nsIFolderListener.removed);
+
+ Components.classes["@mozilla.org/observer-service;1"].
+   getService(Components.interfaces.nsIObserverService).
+   addObserver(NostalgyObserver, "MsgMsgDisplayed", false);
+
 }
 
+var NostalgyObserver = {
+  observe: function (subject, topic, state) {
+    if (!state) return;
+
+    subject = subject.QueryInterface(Components.interfaces.nsIMsgHeaderSink);
+    if (subject != msgWindow.msgHeaderSink) return; // another window
+
+    if (nostalgy_extracted_rules != "") {
+      var button = gEBI("nostalgy_extract_rules_buttons");
+      nostalgy_extracted_rules = "";
+      button.hidden = true;
+    }
+    
+    var doc = document.getElementById('messagepane').contentDocument;
+    var content = doc.body.textContent;
+    var b = "BEGIN RULES\n";
+    var i = content.indexOf(b);
+    if (i < 0) return;
+    i += b.length;
+    var j = content.indexOf("END RULES\n", i);
+    if (j < 0) return;
+
+    nostalgy_extracted_rules = content.substr(i, j - i);
+    if (nostalgy_extracted_rules != "") {
+      var button = gEBI("nostalgy_extract_rules_buttons");
+      button.hidden = false;
+    }
+  }
+};
+
 function onNostalgyUnload() {
  var mSession = NostalgyMailSession();
  if (mSession) mSession.RemoveFolderListener(NostalgyFolderListener);
+
+ Components.classes["@mozilla.org/observer-service;1"].
+   getService(Components.interfaces.nsIObserverService).
+   removeObserver(NostalgyObserver, "MsgMsgDisplayed");
 }
 
 function NostalgyHideIfBlurred() {
@@ -607,49 +658,6 @@ function onNostalgyKeyPress(ev) {
       GetSearchInput().focus();
       ev.preventDefault();
     }
-    if (ev.charCode == 120) { // X
-      var gMsgCompose = 
-	Components.classes["@mozilla.org/messengercompose/compose;1"].
-	createInstance(Components.interfaces.nsIMsgCompose);
-      var sAccountManager = 
-	Components.classes["@mozilla.org/messenger/account-manager;1"].
-	getService(Components.interfaces.nsIMsgAccountManager);
-
-      var identity = 
-	sAccountManager.allIdentities.GetElementAt(0).
-	QueryInterface(Components.interfaces.nsIMsgIdentity);
-      alert(identity.fullName);
-      var account = 
-	sAccountManager.defaultAccount;
-      alert(account);
-      var deliverMode = Components.interfaces.nsIMsgCompDeliverMode;
-      alert(msgWindow);
-      var progress = 
-	Components.classes["@mozilla.org/messenger/progress;1"].
-	createInstance(Components.interfaces.nsIMsgProgress);
-      var gTempEditorWindow = 
-	window.open("chrome://nostalgy/content/QREditor.xul", "_blank", "chrome,extrachrome,dialog='no',width=80,height=80,centerscreen,alwaysRaised");
-      var params = 
-	Components.classes["@mozilla.org/messengercompose/composeparams;1"].
-	createInstance(Components.interfaces.nsIMsgComposeParams);
-
-      var compfields = 
-	Components.classes["@mozilla.org/messengercompose/composefields;1"].
-	createInstance(Components.interfaces.nsIMsgCompFields);
-      
-      compfields.to = "alain.frisch at inria.fr";
-      compfields.subject = "Coucou !";
-      compfields.body = "this is the body\n:-)\n";
-
-      params.identity = identity;
-      params.composeFields = compfields;
-      params.format = 2;  // PlainText
-
-      gMsgCompose.Initialize(gTempEditorWindow, params );
-      msgWindow.SetDOMWindow(window);
-      gMsgCompose.SendMsg(deliverMode.Now, identity, account.key, 
-			  msgWindow, progress);
-    }
     return;
   } 
   if (!nostalgy_statusBar.hidden &&
diff --git a/content/thunderbirdOverlay.xul b/content/thunderbirdOverlay.xul
index feb60c2..caf4913 100644
--- a/content/thunderbirdOverlay.xul
+++ b/content/thunderbirdOverlay.xul
@@ -80,6 +80,15 @@
   </statusbarpanel>
  </statusbar>
 
+ <hbox id="expandedHeaderView">
+   <vbox insertafter="editMessageBox" class="header-part1">
+    <spacer flex="1"/>
+    <button id="nostalgy_extract_rules_buttons"
+	label="Import Nostalgy rules" oncommand="NostalgyExtractRules();" hidden="true"/>
+    <spacer flex="1"/>
+   </vbox>
+ </hbox>
+
 </overlay>
 
 
diff --git a/files b/files
index aad9b15..75c2411 100644
--- a/files
+++ b/files
@@ -1,16 +1,16 @@
-content/about.xhtml
 content/about.xul
-content/composer.js
-content/composerOverlay.xul
-content/edit_prefs.js
 content/edit_prefs.xul
-content/edit_rule.js
+content/thunderbirdOverlay.xul
+content/dummy_window.xul
+content/composer.js
+content/messageOverlay.xul
+content/about.xhtml
 content/edit_rule.xul
 content/folders.js
-content/messageOverlay.xul
+content/edit_rule.js
+content/composerOverlay.xul
+content/edit_prefs.js
 content/nostalgy.js
-content/thunderbirdOverlay.xul
-content/.#nostalgy.js.1.34
 locale/en-US/nostalgy.dtd
 locale/en-US/nostalgy.properties
 defaults/preferences/nostalgy.js

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



More information about the Pkg-mozext-commits mailing list