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

List:       kmail-devel
Subject:    Patch for KMail
From:       Frerich Raabe <frerichraabe () gmx ! de>
Date:       2000-09-30 16:10:50
[Download RAW message or body]

Hi,

I've attached a small patch for KMail which basically makes an ugly
hack (by David, shame on him ;-) obsolete. It adds a --body
commandline parameter which lets you pass a template body text to
KMail without using an extra file. Besides that, it saves some copies
of QString's. Please tell me whether this can be committed so that I
can commit the patch to KApplication::invokeMailer(), too. :-)

Another thing: I noticed, while testing that --body parameter, that
KMail sets the focus to the to-address line edit. IMHO it's more
convenient to give the focus to the body multiline edit if KMail is
passed a body text. I browsed through the code a bit but couldn't
find how to reach the composer's widgets so - any comments/ideas on
this? :-)

- Frerich

P.S.: As I'm currently not subscribed to this list (at least from this 
account), I'd greatly appreciate a CC of postings on this thread. :-}

["kmail.diff" (text/x-c++)]

Index: kmailIface.h
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmailIface.h,v
retrieving revision 1.2
diff -u -3 -p -r1.2 kmailIface.h
--- kmailIface.h	2000/07/31 11:18:26	1.2
+++ kmailIface.h	2000/09/22 21:27:22
@@ -21,8 +21,10 @@ class KMailIface : virtual public DCOPOb
 k_dcop:
   virtual void checkMail() = 0;
   virtual void openReader() = 0;
-  virtual int openComposer(QString to, QString cc, QString bcc, QString subject,
-                           int hidden, KURL messageFile) = 0;
+  virtual int openComposer(const QString &to, const QString &cc,
+                           const QString &bcc, const QString &subject,
+                           const QString &body, int hidden,
+                           const KURL &messageFile) = 0;
   virtual int send(int composerId, int how) = 0; //0=default,1=now,2=later
   virtual int addAttachment(int composerId, KURL url,
                             QString comment) = 0;
Index: kmkernel.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmkernel.cpp,v
retrieving revision 1.22
diff -u -3 -p -r1.22 kmkernel.cpp
--- kmkernel.cpp	2000/09/02 17:39:04	1.22
+++ kmkernel.cpp	2000/09/22 21:27:23
@@ -90,9 +90,10 @@ void KMKernel::openReader()
   KWin::setActiveWindow(mWin->winId());
 }
 
-int KMKernel::openComposer (QString to, QString cc,
-                            QString bcc, QString subject, int hidden,
-			    KURL messageFile )
+int KMKernel::openComposer (const QString &to, const QString &cc,
+                            const QString &bcc, const QString &subject,
+                            const QString &body, int hidden,
+                            const KURL &messageFile)
 {
   kdDebug() << "KMKernel::openComposer called" << endl;
 
@@ -106,6 +107,8 @@ int KMKernel::openComposer (QString to, 
   if (!messageFile.isEmpty() && messageFile.isLocalFile())
     msg->setBody( kFileToString( messageFile.path(), true, false ) );
 
+  if (!body.isEmpty()) msg->setBody(body);
+
   KMComposeWin *cWin = new KMComposeWin(msg);
   if (hidden == 0)
     cWin->show();
@@ -502,12 +505,14 @@ void KMKernel::dumpDeadLetters()
 
 
 
-void KMKernel::action(bool mailto, bool check, QString to, QString cc,
-                      QString bcc, QString subj, KURL messageFile)
+void KMKernel::action(bool mailto, bool check, const QString &to,
+                      const QString &cc, const QString &bcc,
+                      const QString &subj, const QString &body,
+                      const KURL &messageFile)
 {
 
   if (mailto)
-    openComposer (to, cc, bcc, subj, 0, messageFile);
+    openComposer (to, cc, bcc, subj, body, 0, messageFile);
   else
     openReader();
 
Index: kmkernel.h
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmkernel.h,v
retrieving revision 1.9
diff -u -3 -p -r1.9 kmkernel.h
--- kmkernel.h	2000/07/31 11:18:26	1.9
+++ kmkernel.h	2000/09/22 21:27:23
@@ -36,8 +36,9 @@ public:
   
   void checkMail ();
   //returns id of composer if more are opened
-  int openComposer (QString to, QString cc, QString bcc, QString subject,
-                    int hidden, KURL messageFile);
+  int openComposer (const QString &to, const QString &cc, const QString &bcc,
+                    const QString &subject, const QString &body, int hidden,
+                    const KURL &messageFile);
   void openReader();
   int ready();
   int send(int composerId, int how); //0=now, 1=later
@@ -58,8 +59,9 @@ public:
   void kmailMsgHandler(QtMsgType aType, const char* aMsg);
   void dumpDeadLetters();
   bool doSessionManagement ();
-  void action (bool mailto, bool check, QString to, QString cc,
-               QString bcc, QString subj, KURL messageFile);
+  void action (bool mailto, bool check, const QString &to, const QString &cc,
+               const QString &bcc, const QString &subj, const QString &body,
+               const KURL &messageFile);
   
   inline KMFolder *inboxFolder() { return the_inboxFolder; }
   inline KMFolder *outboxFolder() { return the_outboxFolder; }
Index: main.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/main.cpp,v
retrieving revision 1.107
diff -u -3 -p -r1.107 main.cpp
--- main.cpp	2000/09/13 14:34:35	1.107
+++ main.cpp	2000/09/22 21:27:23
@@ -71,6 +71,7 @@ static KCmdLineOptions kmoptions[] =
   { "h", 0 , 0 },
   { "header <header>",		I18N_NOOP("Add 'header' to msg."), 0 },
   { "msg <file>",		I18N_NOOP("Read msg-body from 'file'."), 0 },
+  { "body <text>",              I18N_NOOP("Set body of msg."), 0 },
   { "check",			I18N_NOOP("Check for new mail only."), 0 },
   { "composer",			I18N_NOOP("Open only composer window."), 0 },
   { "+[address]",		I18N_NOOP("Send msg to 'address'."), 0 },
@@ -126,7 +127,7 @@ public:
 
 int KMailApplication::newInstance()
 {
-  QString to, cc, bcc, subj;
+  QString to, cc, bcc, subj, body;
   KURL messageFile = QString::null;
   bool mailto = false;
   bool checkMail = false;
@@ -158,6 +159,12 @@ int KMailApplication::newInstance()
      messageFile = QString::fromLocal8Bit(args->getOption("msg"));
   }
 
+  if (args->getOption("body"))
+  {
+     mailto = true;
+     body = args->getOption("body");
+  }
+
   if (args->isSet("composer"))
     mailto = true;
 
@@ -177,7 +184,7 @@ int KMailApplication::newInstance()
 
   args->clear();
 
-  kernel->action (mailto, checkMail, to, cc, bcc, subj, messageFile);
+  kernel->action (mailto, checkMail, to, cc, bcc, subj, body, messageFile);
   return 0;
 }
 

_______________________________________________
Kmail Developers mailing list
Kmail@master.kde.org
http://master.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