Bug 22101: templated custom headers (wishlist)
Opened:2001-03-11 14:03
Product:knode
Component:general
Version:unspecified
Status:RESOLVED
Platform:Debian testing
Resolution:FIXED
Reporter:growler tula net
Assigned to:KNode Developers

(*** This bug was imported into bugs.kde.org ***)

Package:           knode
Version:           KDE 2.1.0
Severity:          wishlist
Installed from:    Debian Packages
Compiler:          Not Specified
OS:                Linux
OS/Compiler notes: Not Specified

It would be a nice idea to extends custom headers KNode functinality and make it possible to specify templated custom headers e.g.:
X-Comment-To: %REPLYNAME
where %REPLYNAME is a special word wich will be replaced by either name or e-mail address (if name does not exists) of person you are replying to. Such ability is quite usefull e.g. for Internet-to-FIDONet gateways since they translate X-Comment-To news header to FIDONet "To:" message field.

(Submitted via bugs.kde.org)


------- Additional Comment #1 From Jakob Schröter 2004-11-26 19:21 -------
*** Bug 93782 has been marked as a duplicate of this bug. ***


------- Additional Comment #2 From Jakob Schröter 2004-11-27 14:44 -------
CVS commit by schrot:

- save pgp key (93908)
- don't close search dialog when it is minimised (40266)
- add macros to custom headers (22101)
- exclude ignored messages from unread count (41973)
I will backport where appropriate.

BUG: 93908, 40266, 22101, 41973


  M +9 -2      knode/knarticlefactory.cpp   1.84
  M +7 -2      knode/knconfigwidgets.cpp   1.121
  M +7 -4      knode/kngroup.cpp   1.78
  M +1 -0      knode/kngroup.h   1.33
  M +1 -7      knode/knsearchdialog.cpp   1.19
  M +0 -2      knode/knsearchdialog.h   1.9
  M +6 -1      libkpgp/kpgpui.cpp   1.59
  M +1 -0      libkpgp/kpgpui.h   1.25


------- Additional Comment #3 From Jakob Schröter 2005-05-31 15:24 -------
SVN commit 420155 by schrot:

- fix %NAME and %EMAIL macros and their description
- markup for consistency with kmail
CCBUG: 93782,22101


 M  +13 -7     knarticlefactory.cpp  
 M  +1 -1      knarticlefactory.h  
 M  +2 -2      knconfigwidgets.cpp  


--- trunk/KDE/kdepim/knode/knarticlefactory.cpp #420154:420155
 at  at  -118,7 +118,7  at  at
 
   //create new article
   QString sig;
-  KNLocalArticle *art=newArticle(g, sig, chset);
+  KNLocalArticle *art=newArticle(g, sig, chset, true, a);
   if(!art)
     return;
 
 at  at  -786,7 +786,7  at  at
 }
 
 
-KNLocalArticle* KNArticleFactory::newArticle(KNCollection *col, QString &sig, QCString defChset, bool withXHeaders)
+KNLocalArticle* KNArticleFactory::newArticle(KNCollection *col, QString &sig, QCString defChset, bool withXHeaders, KNArticle *origPost)
 {
   KNConfig::PostNewsTechnical *pnt=knGlobals.configManager()->postNewsTechnical();
 
 at  at  -883,12 +883,18  at  at
   if(withXHeaders) {
     KNConfig::XHeaders::Iterator it;
     for(it=pnt->xHeaders().begin(); it!=pnt->xHeaders().end(); ++it) {
-      QString name(art->from()->name());
-      if (name.isEmpty())
-        name = QString::fromLatin1(art->from()->email());
       QString value = (*it).value();
-      value.replace(QRegExp("%NAME"), name);
-      value.replace(QRegExp("%EMAIL"), QString::fromLatin1(art->from()->email()));
+      if(origPost) {
+        QString name(origPost->from()->name());
+        if (name.isEmpty())
+          name = QString::fromLatin1(origPost->from()->email());
+        value.replace(QRegExp("%NAME"), name);
+        value.replace(QRegExp("%EMAIL"), QString::fromLatin1(origPost->from()->email()));
+      }
+      else
+        if(value.find("%NAME") != -1 || value.find("%EMAIL") != -1)
+          continue;
+
       art->setHeader( new KMime::Headers::Generic( (QCString("X-")+(*it).name()), art, value, pnt->charset() ) );
     }
   }
--- trunk/KDE/kdepim/knode/knarticlefactory.h #420154:420155
 at  at  -78,7 +78,7  at  at
 
     //article generation
     // col: group or account
-    KNLocalArticle* newArticle(KNCollection *col, QString &sig, QCString defChset, bool withXHeaders=true);
+    KNLocalArticle* newArticle(KNCollection *col, QString &sig, QCString defChset, bool withXHeaders=true, KNArticle *origPost=0);
 
     //cancel & supersede
     bool cancelAllowed(KNArticle *a);
--- trunk/KDE/kdepim/knode/knconfigwidgets.cpp #420154:420155
 at  at  -1966,7 +1966,7  at  at
   connect(e_ditBtn, SIGNAL(clicked()), SLOT(slotEditBtnClicked()));
   xgbL->addWidget(e_ditBtn, 3,1);
 
-  QLabel *placeHolders = new QLabel(i18n("<qt>Placeholders: %NAME=name, %EMAIL=email address</qt>"), xgb);
+  QLabel *placeHolders = new QLabel(i18n("<qt>Placeholders for replies: <b>%NAME</b>=sender's name, <b>%EMAIL</b>=sender's address</qt>"), xgb);
   xgbL->addMultiCellWidget(placeHolders, 5, 5, 0, 1);
 
   i_ncUaCB=new QCheckBox(i18n("Do not add the \"&User-Agent\" identification header"), xgb);
 at  at  -2173,7 +2173,7  at  at
   i_ntro=new KLineEdit(replyB);
   replyL->addMultiCellWidget(new QLabel(i_ntro,i18n("&Introduction phrase:"), replyB),1,1,0,1);
   replyL->addMultiCellWidget(i_ntro, 2,2,0,1);
-  replyL->addMultiCellWidget(new QLabel(i18n("Placeholders: %NAME=name, %EMAIL=email address,\n%DATE=date, %MSID=message-id, %GROUP=group name, %L=line break"), replyB),3,3,0,1);
+  replyL->addMultiCellWidget(new QLabel(i18n("<qt>Placeholders: <b>%NAME</b>=sender's name, <b>%EMAIL</b>=sender's address,<br><b>%DATE</b>=date, <b>%MSID</b>=message-id, <b>%GROUP</b>=group name, <b>%L</b>=line break</qt>"), replyB),3,3,0,1);
   connect(i_ntro, SIGNAL(textChanged(const QString&)), SLOT(slotEmitChanged()));
 
   r_ewrapCB=new QCheckBox(i18n("Rewrap quoted te&xt automatically"), replyB);


------- Additional Comment #4 From Jakob Schröter 2005-05-31 15:37 -------
SVN commit 420163 by schrot:

non-string backport from trunk:
- fix %NAME and %EMAIL macros
CCBUG: 22101


 M  +13 -7     knarticlefactory.cpp  
 M  +1 -1      knarticlefactory.h  


--- branches/KDE/3.4/kdepim/knode/knarticlefactory.cpp #420162:420163
 at  at  -118,7 +118,7  at  at
 
   //create new article
   QString sig;
-  KNLocalArticle *art=newArticle(g, sig, chset);
+  KNLocalArticle *art=newArticle(g, sig, chset, true, a);
   if(!art)
     return;
 
 at  at  -786,7 +786,7  at  at
 }
 
 
-KNLocalArticle* KNArticleFactory::newArticle(KNCollection *col, QString &sig, QCString defChset, bool withXHeaders)
+KNLocalArticle* KNArticleFactory::newArticle(KNCollection *col, QString &sig, QCString defChset, bool withXHeaders, KNArticle *origPost)
 {
   KNConfig::PostNewsTechnical *pnt=knGlobals.configManager()->postNewsTechnical();
 
 at  at  -883,12 +883,18  at  at
   if(withXHeaders) {
     KNConfig::XHeaders::Iterator it;
     for(it=pnt->xHeaders().begin(); it!=pnt->xHeaders().end(); ++it) {
-      QString name(art->from()->name());
-      if (name.isEmpty())
-        name = QString::fromLatin1(art->from()->email());
       QString value = (*it).value();
-      value.replace(QRegExp("%NAME"), name);
-      value.replace(QRegExp("%EMAIL"), QString::fromLatin1(art->from()->email()));
+      if(origPost) {
+        QString name(origPost->from()->name());
+        if (name.isEmpty())
+          name = QString::fromLatin1(origPost->from()->email());
+        value.replace(QRegExp("%NAME"), name);
+        value.replace(QRegExp("%EMAIL"), QString::fromLatin1(origPost->from()->email()));
+      }
+      else
+        if(value.find("%NAME") != -1 || value.find("%EMAIL") != -1)
+          continue;
+
       art->setHeader( new KMime::Headers::Generic( (QCString("X-")+(*it).name()), art, value, pnt->charset() ) );
     }
   }
--- branches/KDE/3.4/kdepim/knode/knarticlefactory.h #420162:420163
 at  at  -78,7 +78,7  at  at
 
     //article generation
     // col: group or account
-    KNLocalArticle* newArticle(KNCollection *col, QString &sig, QCString defChset, bool withXHeaders=true);
+    KNLocalArticle* newArticle(KNCollection *col, QString &sig, QCString defChset, bool withXHeaders=true, KNArticle *origPost=0);
 
     //cancel & supersede
     bool cancelAllowed(KNArticle *a);


Votes: 0    Show votes for this bug    Vote for this bug

Additional Comments:


View Bug Activity   |   Format For Printing


Attachment Type Modified Status Actions
Create a New Attachment (proposed patch, testcase, etc.) View All


Actions: Query | Reports Search:   New Account | Log In