eudora style redirect and nl_NL locale

View: New views
4 Messages — Rating Filter:   Alert me  

eudora style redirect and nl_NL locale

by Kevin Levie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi there,

In my organisation there was a need for a visible, Eudora style ('by way
of...') redirect instead of a 'transparent' RFC2822 redirect.
Therefore, I added an extra option 'eudoraStyleRedirect' to mailredirect
- see the attached diff file for my changes.
I'm not very proficient in writing these extensions but at least it
works ;-)

I hope you'll consider merging it into mailredirect. If not - I saw it
has been discussed in the past - I'd like to know under which licence
the original source is available and if I'd be able to release it
seperately, since there seems to be quite a lot of interest in this
functionality...

While I was at it, I also wrote an nl_NL (Dutch) locale for mailredirect
- see the attached zipfile. Feel free to use it.

Hope this is of use to someone out there,
Yours,

Kevin Levie

diff -r -u ../mailredirect/content/mailredirect-compose.js ./content/mailredirect-compose.js
--- ../mailredirect/content/mailredirect-compose.js 2006-02-13 11:22:49.000000000 +0100
+++ ./content/mailredirect-compose.js 2007-01-05 22:23:22.000000000 +0100
@@ -38,7 +38,8 @@
 var mimeHeaderParser;
 var mailredirectRecipients = null;
 var aSender = null;
-  
+var aSenderEudoraStyle = null;
+
 // redirected mail states..
 var mstate = {
   selectedURIs : null,
@@ -1114,22 +1115,54 @@
   return aSender;
 }
 
-function getResentHeaders()
+function getSenderEudoraStyle()
 {
-  var resenthdrs = "Resent-From: " + getSender() + "\r\n";
-  var recipientsStrings = getRecipients(false);
-  if (recipientsStrings.to) resenthdrs += "Resent-To: " + recipientsStrings.to + "\r\n";
-  if (recipientsStrings.cc) resenthdrs += "Resent-Cc: " + recipientsStrings.cc + "\r\n";
-  // if (recipientsStrings.bcc) resenthdrs += "Resent-Bcc: " + recipientsStrings.bcc + "\r\n";
-  resenthdrs += "Resent-Date: " + getResentDate() + "\r\n";
+  if (! aSenderEudoraStyle) {
+    var hdrParser = Components.classes["@mozilla.org/messenger/headerparser;1"]
+      .getService(Components.interfaces.nsIMsgHeaderParser);
+    aSenderEudoraStyle = QPencode(aCurrentIdentity.fullName) + " - " + aCurrentIdentity.email;
+  }
+  return aSenderEudoraStyle;
+}
+
+function getResentHeaders(eudoraStyle)
+{
+  if ( eudoraStyle ) {
+
+   var resenthdrs = "X-Resent: This message has been redirected\r\n";
+   // we will add a 'by way of' in the from header, but adding a sender header makes redirecting feel like slightly less of a rfc violation -klevie
+   resenthdrs += "Sender: " + getSender() + "\r\n";
+   var recipientsStrings = getRecipients(false);
+   if (recipientsStrings.to) resenthdrs += "To: " + recipientsStrings.to + "\r\n";
+   if (recipientsStrings.cc) resenthdrs += "Cc: " + recipientsStrings.cc + "\r\n";
+   if (recipientsStrings.bcc) resenthdrs += "Bcc: " + recipientsStrings.bcc + "\r\n";
+   resenthdrs += "Date: " + getResentDate() + "\r\n";
   var msgID = Components.classes["@mozilla.org/messengercompose/computils;1"]
     .createInstance(Components.interfaces.nsIMsgCompUtils)
     .msgGenerateMessageId(aCurrentIdentity);
-  if (msgID) resenthdrs += "Resent-Message-Id: " + msgID + "\r\n";
+  if (msgID) resenthdrs += "Message-Id: " + msgID + "\r\n";
   var useragent = getUserAgent();
-  if (useragent) resenthdrs += "Resent-User-Agent: " + useragent + "\r\n";
+  if (useragent) resenthdrs += "User-Agent: " + useragent + "\r\n";
+
+  } else {
+
+   var resenthdrs = "Resent-From: " + getSender() + "\r\n";
+   var recipientsStrings = getRecipients(false);
+   if (recipientsStrings.to) resenthdrs += "Resent-To: " + recipientsStrings.to + "\r\n";
+   if (recipientsStrings.cc) resenthdrs += "Resent-Cc: " + recipientsStrings.cc + "\r\n";
+   // if (recipientsStrings.bcc) resenthdrs += "Resent-Bcc: " + recipientsStrings.bcc + "\r\n";
+   resenthdrs += "Resent-Date: " + getResentDate() + "\r\n";
+   var msgID = Components.classes["@mozilla.org/messengercompose/computils;1"]
+     .createInstance(Components.interfaces.nsIMsgCompUtils)
+     .msgGenerateMessageId(aCurrentIdentity);
+   if (msgID) resenthdrs += "Resent-Message-Id: " + msgID + "\r\n";
+   var useragent = getUserAgent();
+   if (useragent) resenthdrs += "Resent-User-Agent: " + useragent + "\r\n";
+  
+  }
 
   // dumper.dump('resent-headers\n' + resenthdrs);
+  
   return resenthdrs;
 }
 
@@ -1286,10 +1319,18 @@
   var leftovers = "";
   var buf = "";
 
+  // check if we want an Eudora style redirect
+  var pref = Components.classes["@mozilla.org/preferences-service;1"]
+    .getService(Components.interfaces.nsIPrefBranch);
+  var eudoraStyleRedirect = false;
+  try {
+     eudoraStyleRedirect = pref.getBoolPref("extensions.mailredirect.eudoraStyleRedirect");
+  } catch(ex) { }
+
   var aCopyListener = {
     onStartRequest: function(aRequest, aContext) {
                       // write out Resent-* headers
-                      resenthdrs = getResentHeaders();
+                      resenthdrs = getResentHeaders(eudoraStyleRedirect);
                       ret = aFileOutputStream.write(resenthdrs, resenthdrs.length);
                     },
 
@@ -1425,6 +1466,19 @@
                                }
                              }
 
+     // replace original headers if eudora style
+     if ( inHeader && eudoraStyleRedirect ) {
+         // build new From header
+ line = line.replace(/^From: (.*) *<(.*)>/i,"From: $1 (by way of "+getSenderEudoraStyle()+") <$2>");
+
+ // replace other headers
+ line = line.replace(/^To: /i,"Original-To: ");
+ line = line.replace(/^CC: /i,"Original-CC: ");
+ line = line.replace(/^Date: /i,"Original-Date: ");
+ line = line.replace(/^User-Agent: /i,"Original-User-Agent: ");
+ line = line.replace(/^Message-ID: /i,"Original-Message-ID: ");
+     }
+
                              // remove sensitive headers (vide: nsMsgSendPart.cpp)
                              // From_ line format - http://www.qmail.org/man/man5/mbox.html
                              if ( inHeader &&
@@ -1442,6 +1496,12 @@
                                   /^return-path: /i.test(line) ||
                                   /^delivered-to: /i.test(line) ||
 
+  // added some more, why would we want those?
+  /^received: /i.test(line) ||
+  /^x-virus: /i.test(line) ||
+  /^x-spam: /i.test(line) ||
+  /^x-resent: /i.test(line) ||
+
                                   // for drafts
                                   /^FCC: /i.test(line) ||
                                   /^x-identity-key: /i.test(line) ||
diff -r -u ../mailredirect/content/mailredirect-prefs.js ./content/mailredirect-prefs.js
--- ../mailredirect/content/mailredirect-prefs.js 2005-09-21 20:57:04.000000000 +0200
+++ ./content/mailredirect-prefs.js 2007-01-05 19:54:05.000000000 +0100
@@ -1,6 +1,6 @@
 // need to be global variable
 // List of persisted elements (required by seamonkey to save prefs)
-var _elementIDs = ["copyToSentMail", "debug", "concurrentConnections"];
+var _elementIDs = ["copyToSentMail", "debug", "concurrentConnections", "eudoraStyleRedirect"];
     
 function initPrefs()
 {
diff -r -u ../mailredirect/content/mailredirect-prefs-moz.xul ./content/mailredirect-prefs-moz.xul
--- ../mailredirect/content/mailredirect-prefs-moz.xul 2005-09-21 20:57:20.000000000 +0200
+++ ./content/mailredirect-prefs-moz.xul 2007-01-05 19:55:37.000000000 +0100
@@ -24,6 +24,11 @@
   
   <groupbox>
     <caption label="&prefsGroup.label;"/>
+
+    <checkbox id="eudoraStyleRedirect" label="&eudoraStyleRedirect.label;" accesskey="&eudoraStyleRedirect.accesskey;" tooltip="xToolTip" xtooltiptext="©ToSentMails.tooltip;" prefstring="extensions.mailredirect.eudoraStyleRedirect" preftype="bool" pref="true" prefdefval="true" />
+
+   <separator class="thick"/>
+
     <checkbox id="copyToSentMail" label="©ToSentMails.label;" accesskey="©ToSentMails.accesskey;"
       tooltip="xToolTip" xtooltiptext="©ToSentMails.tooltip;"
       prefstring="extensions.mailredirect.copyToSentMail" preftype="bool" pref="true" prefdefval="true" />
diff -r -u ../mailredirect/content/mailredirect-prefs.xul ./content/mailredirect-prefs.xul
--- ../mailredirect/content/mailredirect-prefs.xul 2005-09-19 10:45:29.000000000 +0200
+++ ./content/mailredirect-prefs.xul 2007-01-05 20:07:17.000000000 +0100
@@ -20,6 +20,13 @@
 
 <groupbox>
   <caption label="&prefsGroup.label;"/>
+
+  <checkbox id="eudoraStyleRedirect" label="&eudoraStyleRedirect.label;" accesskey="&eudoraStyleRedirect.accesskey;"
+  tooltip="xToolTip" xtooltiptext="©ToSentMails.tooltip;"
+  prefstring="extensions.mailredirect.eudoraStyleRedirect" preftype="bool" pref="true" prefdefval="true" />
+
+  <separator class="thick"/>
+
   <checkbox id="copyToSentMail" label="©ToSentMails.label;" accesskey="©ToSentMails.accesskey;"
     tooltip="xToolTip" xtooltiptext="©ToSentMails.tooltip;"
     prefstring="extensions.mailredirect.copyToSentMail" preftype="bool" pref="true" prefdefval="true" />
Alleen in .: diffcommand
diff -r -u ../mailredirect/install.js.template ./install.js.template
--- ../mailredirect/install.js.template 2006-01-12 10:32:42.000000000 +0100
+++ ./install.js.template 2007-01-05 19:24:36.000000000 +0100
@@ -1,6 +1,6 @@
 
 // 1. Set parameters of package installation
-const APP_DISPLAY_NAME = "Mail Redirect";
+const APP_DISPLAY_NAME = "Mail Redirect Plus";
 const APP_NAME = "mailredirect";
 const APP_VERSION = "@VERSION@";
 
diff -r -u ../mailredirect/install.rdf.template ./install.rdf.template
--- ../mailredirect/install.rdf.template 2006-04-21 09:26:28.000000000 +0200
+++ ./install.rdf.template 2007-01-05 19:48:44.000000000 +0100
@@ -3,11 +3,12 @@
 <RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
 
   <Description about="urn:mozilla:install-manifest">
-    <em:id>{CC3C233D-6668-41bc-AAEB-F3A1D1D594F5}</em:id>
-    <em:name>Mail Redirect</em:name>
+    <em:id>{763E9E90-6CBF-4A57-83A2-6B46AA4A992A}</em:id>
+    <em:name>Mail Redirect Plus</em:name>
     <em:version>@VERSION@</em:version>
-    <em:description>Allow to redirect (a.k.a. "bounce") mail messages to other recipients</em:description>
+    <em:description>Allow to redirect (a.k.a. "bounce") mail messages to other recipients, either transparently or Eudora style</em:description>
     <em:creator>Paweł Krześniak</em:creator>
+    <em:contributor>Kevin Levie</em:contributor>
     <em:homepageURL>http://mailredirect.mozdev.org</em:homepageURL>
     <em:optionsURL>chrome://mailredirect/content/mailredirect-prefs.xul</em:optionsURL>
     <em:iconURL>chrome://mailredirect/skin/mailredirect-icon.png</em:iconURL>
@@ -28,6 +29,7 @@
         <em:locale>locale/es-AR/</em:locale> <!-- Thad McGinnis <charlesmcginnisREMOVE@...> -->
         <em:locale>locale/sk-SK/</em:locale> <!-- Branislav Rozbora <rozboraREMOVE@...> -->
         <em:locale>locale/pl-PL/</em:locale> <!-- Lukasz Stelmach <lukasz.stelmachREMOVE@...> -->
+        <em:locale>locale/nl-NL/</em:locale> <!-- Kevin Levie <kevinREMOVE@...> -->
       </Description>
       <Description about="urn:mozilla:extension:file:mailredirect-skin.jar">
         <em:skin>skin/classic/</em:skin>
diff -r -u ../mailredirect/locale/en-US/mailredirect-prefs.dtd ./locale/en-US/mailredirect-prefs.dtd
--- ../mailredirect/locale/en-US/mailredirect-prefs.dtd 2004-11-29 15:29:32.000000000 +0100
+++ ./locale/en-US/mailredirect-prefs.dtd 2007-01-05 19:57:58.000000000 +0100
@@ -7,6 +7,11 @@
 <!-- LOCALIZATION NOTE (copyToSentMails.tooltip): do not translate \n -->
 <!ENTITY copyToSentMails.tooltip "If this option is checked copy of redirected message is placed in Sent folder. If option is unchecked copy of redirected message is not copied to any folder.\nNote: If this option is checked and your settings for account used for redirecting are 'not to save sent messages at all' copy of redirected messages will not be saved either.">
 
+<!ENTITY eudoraStyleRedirect.label "Redirect Eudora style ('by way of')">
+<!ENTITY eudoraStyleRedirect.accesskey "e">
+<!-- LOCALIZATION NOTE: apparently, this may not be translated \n -->
+<!ENTITY eudoraStyleRedirect.tooltip "If this option is checked, emails are redirected Eudora style instead of transparently. This means that the From line will be changed to 'OriginalSender (by way of YourName <YourEmail>) <OriginalEmail>' and the addressee will be changed to the Resent-To/CC/BCC addresses.">
+
 <!ENTITY debug.label "Debug">
 <!ENTITY debug.accesskey "D">
 <!ENTITY debug.tooltip "Turn on/off debugging for mailredirect extension. Logs are directed to JavaScript Console.">
diff -r -u ../mailredirect/version.txt ./version.txt
--- ../mailredirect/version.txt 2006-04-21 10:56:50.000000000 +0200
+++ ./version.txt 2007-01-05 20:03:25.000000000 +0100
@@ -1 +1 @@
-0.7.4
+0.7.4+


_______________________________________________
Mailredirect mailing list
Mailredirect@...
http://mozdev.org/mailman/listinfo/mailredirect

mailredirect.locale.nl_NL.tar.bz2 (4K) Download Attachment

Re: eudora style redirect and nl_NL locale

by im0 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Kevin Levie on [2007-01-06 14:50]:
> Hi there,

Hi Kevin,

> In my organisation there was a need for a visible, Eudora style ('by way
> of...') redirect instead of a 'transparent' RFC2822 redirect.
> Therefore, I added an extra option 'eudoraStyleRedirect' to mailredirect
> - see the attached diff file for my changes.

thanks that you made it. quite a lot people was asking me for this
feature, but my idea for redirect functionality is rfc way.
i'm not going to support this functionality in mailredirect extension.
you can obviously maintain code with this patch - mailredirect is under
GPL license. (btw: mailredirect plus sounds nice :)

> I'm not very proficient in writing these extensions but at least it
> works ;-)

don't worry - mailredirect was my first code for mozilla :)
"developers" learn and sometimes community gain more or less valuable
"product".

ps. nl_NL locale will be bundled in next version of mailredirect.

cheers,
--
Pawel


_______________________________________________
Mailredirect mailing list
Mailredirect@...
http://mozdev.org/mailman/listinfo/mailredirect

Re: eudora style redirect and nl_NL locale

by R. Karlsen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Pawel Krzesniak wrote:
>> * Kevin Levie on [2007-01-06 14:50]:
>>>> Hi there,
>>
>> Hi Kevin,
>>
>>>> In my organisation there was a need for a visible, Eudora style
>>>>
('by way
>>>> of...') redirect instead of a 'transparent' RFC2822 redirect.
>>>> Therefore, I added an extra option 'eudoraStyleRedirect' to
mailredirect
>>>> - see the attached diff file for my changes.
>>
>> thanks that you made it. quite a lot people was asking me for this
>> feature, but my idea for redirect functionality is rfc way. i'm not
>> going to support this functionality in mailredirect extension.

Since there is a switch for this behaviour the default will still be RFC
like.

>> you can obviously maintain code with this patch - mailredirect is
>> under GPL license. (btw: mailredirect plus sounds nice :)

IMO project splits for a single option that "quite a lot people were
asking..for" should be avoided to focus development.

But since you are the maintainer and main developer it is your call :-)

my 2 cents.

Reimer
_______________________________________________
Mailredirect mailing list
Mailredirect@...
http://mozdev.org/mailman/listinfo/mailredirect

Re: eudora style redirect and nl_NL locale

by Kevin Levie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi there,

For whoever is interested:
The functionality described below (a visible Eudora style redirect) is
now (at last) available as a bundled extension called
'mailredirectalternative' via http://mailredirectalternative.mozdev.org/

-Kevin


Pawel Krzesniak wrote:

> * Kevin Levie on [2007-01-06 14:50]:
>> Hi there,
>
> Hi Kevin,
>
>> In my organisation there was a need for a visible, Eudora style ('by way
>> of...') redirect instead of a 'transparent' RFC2822 redirect.
>> Therefore, I added an extra option 'eudoraStyleRedirect' to mailredirect
>> - see the attached diff file for my changes.
>
> thanks that you made it. quite a lot people was asking me for this
> feature, but my idea for redirect functionality is rfc way.
> i'm not going to support this functionality in mailredirect extension.
> you can obviously maintain code with this patch - mailredirect is under
> GPL license. (btw: mailredirect plus sounds nice :)
>
>> I'm not very proficient in writing these extensions but at least it
>> works ;-)
>
> don't worry - mailredirect was my first code for mozilla :)
> "developers" learn and sometimes community gain more or less valuable
> "product".
>
> ps. nl_NL locale will be bundled in next version of mailredirect.
>
> cheers,


> Kevin Levie wrote:
>> Hi there,
>>
>> In my organisation there was a need for a visible, Eudora style ('by way
>> of...') redirect instead of a 'transparent' RFC2822 redirect.
>> Therefore, I added an extra option 'eudoraStyleRedirect' to mailredirect
>> - see the attached diff file for my changes.
>> I'm not very proficient in writing these extensions but at least it
>> works ;-)
>>
>> I hope you'll consider merging it into mailredirect. If not - I saw it
>> has been discussed in the past - I'd like to know under which licence
>> the original source is available and if I'd be able to release it
>> seperately, since there seems to be quite a lot of interest in this
>> functionality...
>>
>> While I was at it, I also wrote an nl_NL (Dutch) locale for mailredirect
>> - see the attached zipfile. Feel free to use it.
>>
>> Hope this is of use to someone out there,
>> Yours,
>>
>> Kevin Levie


_______________________________________________
Mailredirect mailing list
Mailredirect@...
http://mozdev.org/mailman/listinfo/mailredirect