[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    [PATCH]Re: Forward strip
From:       "Juan F.Codagnone" <juam () arnet ! com ! ar>
Date:       2001-11-29 4:59:23
[Download RAW message or body]

Here i send a basic patch that adds what i want.

NOTE1: this is the first time i write in c++ (i am in the 3erd chapter of the "The \
C++ Programming Language". i do c), so i don't know if i should free something or \
things like that.

NOTE2: 
int anti_spam = 1; should be replaced with an opcion in the config i guess.

Please tell me what you think.


On Wednesday 28 November 2001 18:54, Juan F. Codagnone wrote:
> (cc me: im not in the list)
> 
> I thought of a nice feature when you forward a message.
> An option that if it is enable tries to strips all the From, To  and CC
> emails directions. Only stays the names.
> 
> I saw the code of  kmmessage.cpp and it seems easy to add. (the only thing
> that is missing is a way to strip severals mails (KMMessage::stripEmailAddr
> only strips one)
> 
> I am thinking something that is alredy in the next release (im using 1.3.1)
> or i try to add it, or has non sense?
> 
> Juan.


["strip.patch" (text/x-diff)]

diff -u kdenetwork-2.2.2/kmail/kmmessage.cpp kdenetwork-2.2.2-juam/kmail/kmmessage.cpp
--- kdenetwork-2.2.2/kmail/kmmessage.cpp	Sat Aug  4 21:42:17 2001
+++ kdenetwork-2.2.2-juam/kmail/kmmessage.cpp	Thu Nov 29 01:41:42 2001
@@ -962,7 +962,6 @@
   return msg;
 }
 
-
 //-----------------------------------------------------------------------------
 KMMessage* KMMessage::createForward(void)
 {
@@ -972,6 +971,7 @@
   QString s;
   QString id;
   int i;
+  int anti_spam = 1;
 
   id = headerField("X-KMail-Identity");
   if ( id.isEmpty() && parent() )
@@ -987,9 +987,9 @@
     s = "\n\n----------  " + sForwardStr + "  ----------\n\n";
     s += "Subject: " + subject() + "\n";
     s += "Date: " + dateStr() + "\n";
-    s += "From: " + from() + "\n";
-    s += "To: " + to() + "\n";
-    if (!cc().isEmpty()) s += "Cc: " + cc() + "\n";
+    s += "From: " + ((anti_spam) ? fromStrip() : from()) + "\n";
+    s += "To: " +   ((anti_spam) ? toStrip() : to()) + "\n";
+    if (!cc().isEmpty()) s += "Cc: " + ( (anti_spam) ? ccStrip() : cc())+ "\n";
     s += "\n";
     str = asQuotedString(s, "", QString::null, FALSE, false, false);
     str += "\n-------------------------------------------------------\n";
@@ -1288,7 +1288,18 @@
 //-----------------------------------------------------------------------------
 QString KMMessage::toStrip(void) const
 {
-  return stripEmailAddr(headerField("To"));
+  QStringList rcpt;
+  QString nRet;
+
+  rcpt = splitEmailAddrList( headerField("To") );
+  nRet = "";
+
+  for(QStringList::Iterator it = rcpt.begin(); it != rcpt.end(); ++it)
+  {  if( it != rcpt.begin() )
+	     nRet += ", ";
+     nRet += stripEmailAddr(*it);
+  }
+  return nRet;
 }
 
 //-----------------------------------------------------------------------------
@@ -1325,6 +1336,25 @@
   setHeaderField("Cc",aStr);
 }
 
+
+//-----------------------------------------------------------------------------
+QString KMMessage::ccStrip(void) const
+{ 
+  QStringList rcpt;
+  QString nRet;
+
+  rcpt = splitEmailAddrList( headerField("Cc") );
+  nRet = "";
+
+  for(QStringList::Iterator it = rcpt.begin(); it != rcpt.end(); 
+	++it)
+  {  if( it != rcpt.begin() )
+	nRet += ", ";
+     nRet += stripEmailAddr(*it);
+  }
+
+  return nRet;
+}
 
 //-----------------------------------------------------------------------------
 QString KMMessage::bcc(void) const
diff -u kdenetwork-2.2.2/kmail/kmmessage.h kdenetwork-2.2.2-juam/kmail/kmmessage.h
--- kdenetwork-2.2.2/kmail/kmmessage.h	Sun Jul 29 01:57:36 2001
+++ kdenetwork-2.2.2-juam/kmail/kmmessage.h	Thu Nov 29 01:35:19 2001
@@ -157,6 +157,7 @@
   /** Get or set the 'Cc' header field */
   virtual QString cc(void) const;
   virtual void setCc(const QString& aStr);
+  virtual QString ccStrip(void) const;
 
   /** Get or set the 'Bcc' header field */
   virtual QString bcc(void) const;

_______________________________________________
kmail Developers mailing list
kmail@mail.kde.org
http://mail.kde.org/mailman/listinfo/kmail


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic