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

List:       kmail-devel
Subject:    Re: [PATCH] ClientInterface (next try)
From:       Andreas Gungl <a.gungl () gmx ! de>
Date:       2003-08-06 21:06:40
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Okay, some improvements (although I didn't solve the two big issues with the 
dialogs yet):

- - Namespace KMail is used for the new classes.

- - I cleaned up the diverse statusMessage() variants in kmsender. I inspected 
the code carefully but didn't test all variants. At least I'm convinced the 
methods in kmsender are no longer needed.

- - I introduced a new class Notifier which now holds some declarative 
elements needed by the Client class. This switches the dependencies so that 
client classes are dependent on the kernel classes but NOT the other way 
round as in my first patch. IMO Notifier is a kernel (helper) class.

- - Coupling between Notifier and Client is done via signals/slots. Further 
extensions can be made easily (even the DCOP way if ever decided to go for 
that).

I'm not sure who is interested in the details of this change. Nevertheless I 
want to give a chance to object before I commit my work to CVS (when I have 
finished kmsender - but feedback is welcome already now).

Andreas

On Sunday 27 July 2003 00:19, Cornelius Schumacher wrote:
> On Sunday 27 July 2003 00:16, Andreas Gungl wrote:
> > Any comments, hints and whatever are welcome as everytime.
>
> Just a little nitpicking, I can't comment on the content of the patch,
> because I didn't really look at it:
>
> - Instead of naming the class "KMailClient" it might be better to name
> it "Client" and put it into the "KMail" namespace. This has the same
> effect, but makes the code a little bit clearer inside of KMail.
>
> - The include guard should better be "#define KMAIL_CLIENT_H" instead of
> "#define CLIENT_H". Chances that KMail sometimes includes another
> CLIENT_H somewhere aren't high but probably above zero.

- -- 
    ~
  ' v '
 //   \\
/(     )\  Powered by Penguin.
  ^ ' ^

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)

iD8DBQE/MW3rVhjiFd4beU8RAs1hAKC8t84lETj1BwcZZZOq2WM1+wj/NgCgwMwX
BQ2ACxByNiv+wBrsjylDZkc=
=Fiol
-----END PGP SIGNATURE-----

["client.h" (text/x-chdr)]

/*
    This file is part of KMail.
    Copyright (c) 2003 Andreas Gungl <a.gungl@gmx.de>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
#ifndef KMAIL_CLIENT_H
#define KMAIL_CLIENT_H

#include "notifier.h"

namespace KMail {

  /**
  * @short KMail standard GUI client wrapper (singleton).
  * @author Andreas Gungl <a.gungl@gmx.de>
  **/
  class Client : public QObject
  {
    Q_OBJECT

  protected:
    Client();
    static Client* self;

  public:
    static Client* instance();

    void initConnections(Notifier& notifier);

  public slots:
    /** Show an information message. No interaction is possible.
    * @param infoId The ID specifies the message to be shown.
    * @param argList The optional list contains arguments for placeholders.
    */
    virtual void slotMsgBoxInformation( const Notifier::InfoId infoId,
                                        QStringList* argList = NULL );

    /** Show an error message. No interaction is possible.
    * @param errorId The ID specifies the message to be shown.
    * @param argList The optional list contains arguments for placeholders.
    */
    virtual void slotMsgBoxError( const Notifier::ErrorId errorId,
                                  QStringList* argList = NULL );


    /** Show a yes/no messagebox.
    * @param text      The i18n'ed message to be shown.
    * @param caption   The i18n'ed message to be shown.
    * @param buttonYes The i18n'ed message to be shown.
    * @param buttonNo  The i18n'ed message to be shown.
    */
    virtual int showMsgBoxWarningYesNo( const QString& text,
            const QString& caption, const QString& buttonYes,
            const QString& buttonNo );


    /** Set the status message.
    * @param msg The i18n'ed message to be shown.
    */
// FIXME    virtual void slotSetStatusMsg( const QString& msg );

    /** Set the status message.
    * @param msgId The ID specifies the message to be shown.
    * @param argList The optional list contains arguments for placeholders.
    */
    virtual void slotSetStatusMsg( const Notifier::StatusMsgId msgId,
                                   QStringList* argList = NULL );

    /** Set the current progress for sent messages in the status bar.
    * @param sentMessages The n-th message being sent in the moment.
    * @param totalMessages Number of all messages to be sent.
    */
    virtual void slotSetStatusSendCount( const int sentMessages,
                                         const int totalMessages );

    /** Set the percentage value for the status bar.
    * @param msg The i18n'ed message to be shown.
    * @param percentage The value in the range 0-100.
    */
    virtual void slotSetStatusProgressPercent( const QString& msg,
                                               const int percentage );
  };

  inline Client* Client::instance()
  {
    if (!self) self = new Client();
    return self;
  }

} // namespace KMail

#endif // KMAIL_CLIENT_H

["notifier.cpp" (text/x-c++src)]

/*
    This file is part of KMail.
    Copyright (c) 2003 Andreas Gungl <a.gungl@gmx.de>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include "notifier.h"

namespace KMail
{
  Notifier* Notifier::self = NULL;

  Notifier::Notifier() : QObject() {}
}

void KMail::Notifier::msgBoxInformation( const InfoId infoId,
                                         QStringList* argList )
{
  emit sigMsgBoxInformation( infoId, argList );
}


void KMail::Notifier::msgBoxError( const ErrorId errorId,
                                   QStringList* argList )
{
  emit sigMsgBoxError( errorId, argList );
}


/* FIXME
void KMail::Notifier::setStatusMsg( const QString& msg )
{
  emit sigSetStatusMsg( msg );
}
*/


void KMail::Notifier::setStatusMsg( StatusMsgId msgId,
                                    QStringList* argList )
{
  emit sigSetStatusMsg( msgId, argList );
}


void KMail::Notifier::setStatusSendCount( const int sentMessages,
                                          const int totalMessages )
{
  emit sigSetStatusSendCount( sentMessages, totalMessages );
}


void KMail::Notifier::setStatusProgressPercent( const QString& msg,
                                                const int percentage )
{
  emit sigSetStatusProgressPercent( msg, percentage );
}

#include "notifier.moc"

["notifier.h" (text/x-chdr)]

/*
    This file is part of KMail.
    Copyright (c) 2003 Andreas Gungl <a.gungl@gmx.de>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
#ifndef KMAIL_NOTIFIER_H
#define KMAIL_NOTIFIER_H

#include <qobject.h>
#include <qstring.h>
#include <qstringlist.h>

namespace KMail {

  /**
  * @short KMail kernel's notifications towards the client (singleton).
  * @author Andreas Gungl <a.gungl@gmx.de>
  **/
  class Notifier : public QObject
  {
    Q_OBJECT

  public:
    enum InfoId {
      INFOBOX_ACCOUNT_MISSING,
      INFOBOX_MAILER_EXEC_FAILED,   // Params: 1=mailer program
      INFOBOX_MAILER_UNSPECIFIED,   // Params: 1=hint; 2=transport URL
      INFOBOX_OUT_OF_SPACE,
      INFOBOX_OUTBOX_PROBLEM
    };

    enum ErrorId {
      ERRORBOX_MOVING_MSG,          // Params: 1=subject
      ERRORBOX_SENDING_ABORTED,     // Params: 1=error; 2=transport URL
      ERRORBOX_SENDING_FAILED       // Params: 1=error; 2=transport URL
    };

    enum StatusMsgId {
      STATUSMSG_CURR_SENT_SUBJECT,  // Params: 1=sent+failed; 2=total; 3=subject
      STATUSMSG_INIT_SENDER,
      STATUSMSG_PRECOMMAND,         // Params: 1=precommand
      STATUSMSG_SEND_ABORTED,
      STATUSMSG_SEND_FAILED,
      STATUSMSG_UNKNOWN_TRANSPORT
    };


  protected:
    Notifier();
    static Notifier* self;

  public:
    static Notifier* instance();

    /** Show an information message. No interaction is possible.
    * @param infoId The ID specifies the message to be shown.
    * @param argList The optional list contains arguments for placeholders.
    */
    virtual void msgBoxInformation( const InfoId infoId,
                                    QStringList* argList = NULL );

    /** Show an error message. No interaction is possible.
    * @param errorId The ID specifies the message to be shown.
    * @param argList The optional list contains arguments for placeholders.
    */
    virtual void msgBoxError( const ErrorId errorId,
                              QStringList* argList = NULL );


    /** Set the status message.
    * @param msg The i18n'ed message to be shown.
    */
/* FIXME
    virtual void setStatusMsg( const QString& msg );
*/

    /** Set the status message.
    * @param msgId The ID specifies the message to be shown.
    * @param argList The optional list contains arguments for placeholders.
    */
    virtual void setStatusMsg( const StatusMsgId msgId,
                               QStringList* argList = NULL );

    /** Set the current progress for sent messages in the status bar.
    * @param sentMessages The n-th message being sent in the moment.
    * @param totalMessages Number of all messages to be sent.
    */
    virtual void setStatusSendCount( const int sentMessages,
                                     const int totalMessages );

    /** Set the percentage value for the status bar.
    * @param msg The i18n'ed message to be shown.
    * @param percentage The value in the range 0-100.
    */
    virtual void setStatusProgressPercent( const QString& msg,
                                           const int percentage );

  signals:
    /** This signal is sent when an information message needs to be shown.
    * @param infoId The ID specifies the message to be shown.
    * @param argList The list contains arguments for placeholders.
    */
    void sigMsgBoxInformation( const Notifier::InfoId infoId,
                               QStringList* argList );

    /** This signal is sent when an error message needs to be shown.
    * @param errorId The ID specifies the message to be shown.
    * @param argList The list contains arguments for placeholders.
    */
    void sigMsgBoxError( const Notifier::ErrorId errorId,
                         QStringList* argList );


    /** This signal is sent when the status message should get set.
    * @param msg The i18n'ed message to be shown.
    */
    void sigSetStatusMsg( const QString& msg );

    /** This signal is sent when the status message should get set.
    * @param msgId The ID specifies the message to be shown.
    * @param argList The optional list contains arguments for placeholders.
    */
    void sigSetStatusMsg( const Notifier::StatusMsgId msgId,
                          QStringList* argList = NULL );

    /** This signal is sent when the current progress for sent
    * messages in the status bar needs to be changed.
    * @param sentMessages The n-th message being sent in the moment.
    * @param totalMessages Number of all messages to be sent.
    */
    void sigSetStatusSendCount( const int sentMessages,
                                const int totalMessages );

    /** This signal is sent when the percentage value for
    * the status bar needs to be changed.
    * @param msg The i18n'ed message to be shown.
    * @param percentage The value in the range 0-100.
    */
    void sigSetStatusProgressPercent( const QString& msg,
                                      const int percentage );
  };

  inline Notifier* Notifier::instance()
  {
    if (!self) self = new Notifier();
    return self;
  }

} // namespace KMail

#endif // KMAIL_NOTIFIER_H

["client.cpp" (text/x-c++src)]

/*
    This file is part of KMail.
    Copyright (c) 2003 Andreas Gungl <a.gungl@gmx.de>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include "client.h"
#include "kmbroadcaststatus.h"

#include <klocale.h>
#include <kmessagebox.h>


int applyArgsFromList( QString& str, QStringList* strList, int expectedArgs )
{
  int appliedArgs = 0;
  if ( strList != NULL )
  {
    while ( !strList->isEmpty() && expectedArgs-- )
    {
      str = str.arg( strList->first() );
      strList->pop_front();
      ++appliedArgs;
    }
  }
  return appliedArgs;
}


namespace KMail
{

  Client* Client::self = NULL;

  Client::Client() : QObject() {}

  void Client::initConnections(Notifier& notifier)
  {
    connect( &notifier,
             SIGNAL(sigMsgBoxInformation( const Notifier::InfoId, QStringList*)),
             self,
             SLOT(slotMsgBoxInformation( const Notifier::InfoId, QStringList*)));

    connect( &notifier,
             SIGNAL(sigMsgBoxError( const Notifier::ErrorId, QStringList*)),
             self,
             SLOT(slotMsgBoxError( const Notifier::ErrorId, QStringList*)));

    connect( &notifier,
             SIGNAL(sigSetStatusMsg( const QString&)),
             self,
             SLOT(slotSetStatusMsg( const QString&)));

    connect( &notifier,
             SIGNAL(sigSetStatusMsg( const Notifier::StatusMsgId, QStringList*)),
             self,
             SLOT(slotSetStatusMsg( const Notifier::StatusMsgId, QStringList*)));

    connect( &notifier,
             SIGNAL(sigSetStatusSendCount( const int, const int)),
             self,
             SLOT(slotSetStatusSendCount( const int, const int)));

    connect( &notifier,
             SIGNAL(sigSetStatusProgressPercent( const QString&, const int)),
             self,
             SLOT(slotSetStatusProgressPercent( const QString&, const int)));

  }

}


void KMail::Client::slotMsgBoxInformation( const Notifier::InfoId infoId,
                                           QStringList* argList )
{
  QString msg;
  switch( infoId )
  {
    case Notifier::INFOBOX_ACCOUNT_MISSING:
      msg = i18n( "Please create an account for sending and try again." );
      break;
    case Notifier::INFOBOX_MAILER_EXEC_FAILED:
      msg = i18n( "Failed to execute mailer program %1" );
      applyArgsFromList( msg, argList, 1 );
      break;
    case Notifier::INFOBOX_MAILER_UNSPECIFIED:
      msg = i18n("Sending failed:\n%1\n"
        "The message will stay in the 'outbox' folder and will be resent.\n"
        "Please remove it from there if you do not want the message to "
        "be resent.\n"
        "The following transport protocol was used:\n  %2");
      applyArgsFromList( msg, argList, 2 );
      break;
    case Notifier::INFOBOX_OUT_OF_SPACE:
      msg = i18n( "Critical error: Unable to process sent mail (out of space?) "
                  "Moving failing message to \"sent-mail\" folder." );
      break;
    case Notifier::INFOBOX_OUTBOX_PROBLEM:
      msg = i18n( "Cannot add message to outbox folder" );
      break;
  }
  KMessageBox::information( 0, msg);
}


void KMail::Client::slotMsgBoxError( const Notifier::ErrorId errorId,
                                     QStringList* argList )
{
  QString msg;
  switch( errorId )
  {
    case Notifier::ERRORBOX_MOVING_MSG:
      msg = i18n("Moving the sent message \"%1\" from the "
            "\"outbox\" to the \"sent-mail\" folder failed.\n"
            "Possible reasons are lack of disk space or write permission. "
            "Please try to fix the problem and move the message manually.");
      applyArgsFromList( msg, argList, 1 );
      break;
    case Notifier::ERRORBOX_SENDING_ABORTED:
      msg = i18n("Sending aborted:\n%1\n"
            "The message will stay in the 'outbox' folder until you either "
            "fix the problem (e.g. a broken address) or remove the message "
            "from the 'outbox' folder.\n"
            "The following transport protocol was used:\n  %2");
      applyArgsFromList( msg, argList, 2 );
      break;
    case Notifier::ERRORBOX_SENDING_FAILED:
      msg = i18n("Sending failed:\n%1\n"
            "The message will stay in the 'outbox' folder until you either "
            "fix the problem (e.g. a broken address) or remove the message "
            "from the 'outbox' folder.\n"
            "The following transport protocol was used:\n %2");
      applyArgsFromList( msg, argList, 2 );
      break;
  }
  KMessageBox::error( 0, msg);
}


int KMail::Client::showMsgBoxWarningYesNo( const QString& text,
    const QString& caption, const QString& buttonYes, const QString& buttonNo )
{
  int res = KMessageBox::warningYesNo( 0, text, caption, buttonYes, buttonNo);
  return res;
}


/*
void KMail::Client::slotSetStatusMsg( const QString& msg )
{
  KMBroadcastStatus::instance()->setStatusMsg( msg );
}
*/


void KMail::Client::slotSetStatusMsg( Notifier::StatusMsgId msgId,
                                      QStringList* argList )
{
  QString msg;
  switch( msgId )
  {
    case Notifier::STATUSMSG_CURR_SENT_SUBJECT:
      msg = i18n("%3: subject of message","Sending message %1 of %2: %3");
      applyArgsFromList( msg, argList, 3 );
      break;
    case Notifier::STATUSMSG_INIT_SENDER:
      msg = i18n("Initiating sender process...");
      break;
    case Notifier::STATUSMSG_PRECOMMAND:
      msg = i18n("Executing precommand %1");
      applyArgsFromList( msg, argList, 1 );
      break;
    case Notifier::STATUSMSG_SEND_ABORTED:
      msg = i18n( "Sending aborted." );
      break;
    case Notifier::STATUSMSG_SEND_FAILED:
      msg = i18n("Failed to send (some) queued messages.");
      break;
    case Notifier::STATUSMSG_UNKNOWN_TRANSPORT:
      msg = i18n("Unrecognized transport protocol. Unable to send message.");
      break;
  }
  KMBroadcastStatus::instance()->setStatusMsg( msg );
}


void KMail::Client::slotSetStatusSendCount( const int sentMessages,
                                            const int totalMessages )
{
  if ( sentMessages == totalMessages ) {
    KMBroadcastStatus::instance()->setStatusMsg(
      i18n( "%n queued message successfully sent.",
            "%n queued messages successfully sent.",
            sentMessages));
  } else {
    KMBroadcastStatus::instance()->setStatusMsg(
      i18n( "%1 of %2 queued messages successfully sent." )
        .arg( sentMessages ).arg( totalMessages ));
  }
}


void KMail::Client::slotSetStatusProgressPercent( const QString& msg,
                                                  int percentage )
{
  KMBroadcastStatus::instance()->setStatusProgressPercent(msg, percentage);
}

#include "client.moc"

["ui-separation.diff" (text/x-diff)]

Index: Makefile.am
===================================================================
RCS file: /home/kde/kdepim/kmail/Makefile.am,v
retrieving revision 1.227
diff -u -3 -p -u -b -r1.227 Makefile.am
--- Makefile.am	3 Aug 2003 02:10:40 -0000	1.227
+++ Makefile.am	6 Aug 2003 20:49:52 -0000
@@ -82,7 +82,8 @@ libkmailcommon_la_SOURCES = kmmessage.cp
 		subscriptiondialog.cpp kmailicalifaceimpl.cpp aboutdata.cpp \
 		folderIface.cpp folderIface.skel mailserviceimpl.cpp \
 		attachmentlistview.cpp ssllabel.cpp \
-        iobserver.cpp isubject.cpp bodyvisitor.cpp
+		iobserver.cpp isubject.cpp bodyvisitor.cpp \
+		client.cpp notifier.cpp
 
 kmail_SOURCES = main.cpp
 
Index: kmsender.cpp
===================================================================
RCS file: /home/kde/kdepim/kmail/kmsender.cpp,v
retrieving revision 1.186
diff -u -3 -p -u -b -r1.186 kmsender.cpp
--- kmsender.cpp	6 Aug 2003 16:48:48 -0000	1.186
+++ kmsender.cpp	6 Aug 2003 20:49:53 -0000
@@ -33,8 +33,13 @@ using namespace KMime::Types;
 #include "kmfoldermgr.h"
 #include "kmmsgdict.h"
 #include "kmmsgpart.h"
+// FIXME (client.h needs to get removed)
+#include "client.h"
+#include "notifier.h"
 #include <mimelib/mediatyp.h>
 
+using namespace KMail;
+
 #define SENDER_GROUP "sending mail"
 
 //-----------------------------------------------------------------------------
@@ -66,12 +71,6 @@ KMSender::~KMSender()
 }
 
 //-----------------------------------------------------------------------------
-void KMSender::setStatusMsg(const QString &msg)
-{
-  KMBroadcastStatus::instance()->setStatusMsg(msg);
-}
-
-//-----------------------------------------------------------------------------
 void KMSender::readConfig(void)
 {
   QString str;
@@ -99,7 +98,8 @@ bool KMSender::settingsOk() const
 {
   if (KMTransportInfo::availableTransports().isEmpty())
   {
-    KMessageBox::information(0,i18n("Please create an account for sending and try again."));
+    Notifier::instance()
+      ->msgBoxInformation( Notifier::INFOBOX_ACCOUNT_MISSING );
     return false;
   }
   return true;
@@ -150,11 +150,13 @@ bool KMSender::send(KMMessage* aMsg, sho
     aMsg->setFrom(f + QString(" (by way of %1 <%2>)")
       .arg(ident.fullName()).arg(ident.emailAddr()));
   }
+  aMsg->setComplete( true );
 
   rc = kernel->outboxFolder()->addMsg(aMsg);
   if (rc)
   {
-    KMessageBox::information(0,i18n("Cannot add message to outbox folder"));
+    Notifier::instance()
+      ->msgBoxInformation( Notifier::INFOBOX_OUTBOX_PROBLEM );
     return FALSE;
   }
 
@@ -216,7 +218,7 @@ void KMSender::emitProgressInfo( int cur
 {
   int percent = (mTotalBytes) ? ( 100 * (mSentBytes+currentFileProgress) / mTotalBytes ) : 0;
   if (percent > 100) percent = 100;
-  KMBroadcastStatus::instance()->setStatusProgressPercent("Sender", percent);
+    Notifier::instance()->setStatusProgressPercent("Sender", percent);
 }
 
 //-----------------------------------------------------------------------------
@@ -294,9 +296,8 @@ kdDebug(5006) << "KMSender::doSendMsg() 
     switch (processResult) {
     case 2:
       perror("Critical error: Unable to process sent mail (out of space?)");
-      KMessageBox::information(0, i18n("Critical error: "
-				       "Unable to process sent mail (out of space?)"
-				       "Moving failing message to \"sent-mail\" folder."));
+      Notifier::instance()
+        ->msgBoxInformation( Notifier::INFOBOX_OUT_OF_SPACE );
       sentFolder->quiet(TRUE);
       sentFolder->moveMsg(mCurrentMsg);
       if ( sentFolder != kernel->sentFolder() )
@@ -308,11 +309,9 @@ kdDebug(5006) << "KMSender::doSendMsg() 
       sentFolder->quiet(TRUE);
       if (sentFolder->moveMsg(mCurrentMsg) != 0)
       {
-        KMessageBox::error(0, i18n("Moving the sent message \"%1\" from the "
-          "\"outbox\" to the \"sent-mail\" folder failed.\n"
-          "Possible reasons are lack of disk space or write permission. "
-          "Please try to fix the problem and move the message manually.")
-          .arg(mCurrentMsg->subject()));
+        QStringList args( mCurrentMsg->subject() );
+        Notifier::instance()
+	  ->msgBoxError( Notifier::ERRORBOX_MOVING_MSG, &args);
         cleanup();
         sentFolder->quiet(FALSE);
         return;
@@ -346,14 +345,8 @@ kdDebug(5006) << "KMSender::doSendMsg() 
     if ( ( sentFolder != kernel->sentFolder() ) && ( sentFolder != 0 ) )
         sentFolder->close();
     if (someSent) {
-      if ( mSentMessages == mTotalMessages ) {
-        setStatusMsg(i18n("%n queued message successfully sent.",
-		       	  "%n queued messages successfully sent.",
-			  mSentMessages));
-      } else {
-        setStatusMsg(i18n("%1 of %2 queued messages successfully sent.")
-            .arg(mSentMessages).arg( mTotalMessages ));
-      }
+      Notifier::instance()
+        ->setStatusSendCount( mSentMessages, mTotalMessages );
     }
     cleanup();
     return;
@@ -370,7 +363,8 @@ kdDebug(5006) << "KMSender::doSendMsg() 
     kapp->ref();
 
     mSendInProgress = TRUE;
-    setStatusMsg(i18n("Initiating sender process..."));
+    Notifier::instance()
+      ->setStatusMsg( Notifier::STATUSMSG_INIT_SENDER );
   }
 
   QString msgTransport = mCurrentMsg->headerField("X-KMail-Transport");
@@ -397,8 +391,9 @@ kdDebug(5006) << "KMSender::doSendMsg() 
       // Run the precommand if there is one
       if (!mTransportInfo->precommand.isEmpty())
       {
-        setStatusMsg(i18n("Executing precommand %1")
-          .arg(mTransportInfo->precommand));
+        QStringList args(mTransportInfo->precommand);
+        Notifier::instance()
+          ->setStatusMsg( Notifier::STATUSMSG_PRECOMMAND, &args);
         mPrecommand = new KMPrecommand(mTransportInfo->precommand);
         connect(mPrecommand, SIGNAL(finished(bool)),
           SLOT(slotPrecommandFinished(bool)));
@@ -427,7 +422,8 @@ void KMSender::sendProcStarted(bool succ
     if (mSendProc)
        mSendProc->finish(true);
     else
-      setStatusMsg(i18n("Unrecognized transport protocol. Unable to send message."));
+    Notifier::instance()
+      ->setStatusMsg( Notifier::STATUSMSG_UNKNOWN_TRANSPORT );
     mSendProc = 0;
     mSendProcStarted = false;
     cleanup();
@@ -445,13 +441,17 @@ void KMSender::doSendMsgAux()
   // start sending the current message
 
   mSendProc->preSendInit();
-  setStatusMsg(i18n("%3: subject of message","Sending message %1 of %2: %3")
-	       .arg(mSentMessages+mFailedMessages+1).arg(mTotalMessages)
-	       .arg(mCurrentMsg->subject()));
+  QStringList args;
+  args.append( QString::number( mSentMessages+mFailedMessages+1 ) );
+  args.append( QString::number( mTotalMessages ) );
+  args.append( mCurrentMsg->subject() );
+  Notifier::instance()
+    ->setStatusMsg( Notifier::STATUSMSG_CURR_SENT_SUBJECT, &args );
   if (!mSendProc->send(mCurrentMsg))
   {
     cleanup();
-    setStatusMsg(i18n("Failed to send (some) queued messages."));
+    Notifier::instance()
+      ->setStatusMsg( Notifier::STATUSMSG_SEND_FAILED );
     return;
   }
   // Do *not* add code here, after send(). It can happen that this method
@@ -513,15 +513,16 @@ void KMSender::slotIdle()
 
   if (mSendAborted) {
     // sending of message aborted
-    msg = i18n("Sending aborted:\n%1\n"
-        "The message will stay in the 'outbox' folder until you either "
-        "fix the problem (e.g. a broken address) or remove the message "
-        "from the 'outbox' folder.\n"
-        "The following transport protocol was used:\n  %2")
-      .arg(errString)
-      .arg(mMethodStr);
-    if (!errString.isEmpty()) KMessageBox::error(0,msg);
-    setStatusMsg( i18n( "Sending aborted." ) );
+    if (!errString.isEmpty())
+    {
+      QStringList args;
+      args.append( errString );
+      args.append( mMethodStr );
+      Notifier::instance()
+        ->msgBoxError( Notifier::ERRORBOX_SENDING_ABORTED, &args );
+    }
+    Notifier::instance()
+      ->setStatusMsg( Notifier::STATUSMSG_SEND_ABORTED );
   } else {
     if (!mSendProc->sendOk()) {
       mCurrentMsg->setTransferInProgress( false );
@@ -531,6 +532,7 @@ void KMSender::slotIdle()
       if (!errString.isEmpty()) {
         int res = KMessageBox::Yes;
         if (mSentMessages+mFailedMessages != mTotalMessages) {
+	  // TODO  - this needs some more effort to separate kernel and GUI
           msg = i18n("<p>Sending failed:</p>"
             "<p>%1</p>"
             "<p>The message will stay in the 'outbox' folder until you either "
@@ -540,25 +542,23 @@ void KMSender::slotIdle()
             "<p>Do you want me to continue sending the remaining messages?</p>")
             .arg(errString)
             .arg(mMethodStr);
-          res = KMessageBox::warningYesNo( 0 , msg ,
+          res = Client::instance()->showMsgBoxWarningYesNo( msg ,
                   i18n( "Continue sending" ), i18n( "&Continue sending" ),
                   i18n("&Abort sending") );
         } else {
-          msg = i18n("Sending failed:\n%1\n"
-            "The message will stay in the 'outbox' folder until you either "
-            "fix the problem (e.g. a broken address) or remove the message "
-            "from the 'outbox' folder.\n"
-            "The following transport protocol was used:\n %2")
-            .arg(errString)
-            .arg(mMethodStr);
-          KMessageBox::error(0,msg);
+          QStringList args;
+          args.append( errString );
+          args.append( mMethodStr );
+          Notifier::instance()
+            ->msgBoxError( Notifier::ERRORBOX_SENDING_FAILED, &args );
         }
         if (res == KMessageBox::Yes) {
           // Try the next one.
           doSendMsg();
           return;
         } else {
-          setStatusMsg( i18n( "Sending aborted." ) );
+          Notifier::instance()
+            ->setStatusMsg( Notifier::STATUSMSG_SEND_ABORTED );
         }
       }
     } else {
@@ -816,12 +816,6 @@ QCString KMSendProc::prepareStr(const QC
 #endif
 
 //-----------------------------------------------------------------------------
-void KMSendProc::statusMsg(const QString& aMsg)
-{
-  if (mSender) mSender->setStatusMsg(aMsg);
-}
-
-//-----------------------------------------------------------------------------
 bool KMSendProc::addRecipients( const AddrSpecList & al )
 {
   for ( AddrSpecList::const_iterator it = al.begin() ; it != al.end() ; ++it )
@@ -850,16 +844,12 @@ void KMSendSendmail::start(void)
 {
   if (mSender->transportInfo()->host.isEmpty())
   {
-    QString str = i18n("Please specify a mailer program in the settings.");
-    QString msg;
-    msg = i18n("Sending failed:\n%1\n"
-	"The message will stay in the 'outbox' folder and will be resent.\n"
-        "Please remove it from there if you do not want the message to "
-		"be resent.\n"
-	"The following transport protocol was used:\n  %2")
-    .arg(str + "\n")
-    .arg("sendmail://");
-    KMessageBox::information(0,msg);
+    QStringList args;
+    args.append( i18n( "Please specify a mailer program in the settings." )
+                 + "\n" );
+    args.append("sendmail://");
+    Notifier::instance()
+      ->msgBoxInformation( Notifier::INFOBOX_MAILER_UNSPECIFIED, &args );
     emit started(false);
     return;
   }
@@ -923,8 +913,9 @@ bool KMSendSendmail::send(KMMessage* aMs
 
   if (!mMailerProc->start(KProcess::NotifyOnExit,KProcess::All))
   {
-    KMessageBox::information(0,i18n("Failed to execute mailer program %1")
-			     .arg(mSender->transportInfo()->host));
+    QStringList args( mSender->transportInfo()->host);
+    Notifier::instance()
+      ->msgBoxInformation( Notifier::INFOBOX_MAILER_EXEC_FAILED, &args );
     return FALSE;
   }
   mMsgPos  = mMsgStr.data();
@@ -1070,6 +1061,7 @@ bool KMSendSMTP::send(KMMessage *aMsg)
       int result;
 
       KCursorSaver idle(KBusyPtr::idle());
+// TODO - this needs effort to separate kernel and GUI
       result = KIO::PasswordDialog::getNameAndPassword(ti->user, ti->pass,
 	&b, i18n("You need to supply a username and a password to use this "
 	     "SMTP server."), FALSE, QString::null, ti->name, QString::null);
Index: kmsender.h
===================================================================
RCS file: /home/kde/kdepim/kmail/kmsender.h,v
retrieving revision 1.45
diff -u -3 -p -u -b -r1.45 kmsender.h
--- kmsender.h	26 Jul 2003 14:51:50 -0000	1.45
+++ kmsender.h	6 Aug 2003 20:49:53 -0000
@@ -77,19 +77,12 @@ public:
   /** Write configuration to global config with optional sync() */
   virtual void writeConfig(bool withSync=TRUE);
 
-  /** sets a status msg and emits statusMsg() */
-  void setStatusMsg(const QString&);
-
   /** sets replied/forwarded status in the linked message for @p aMsg. */
   void setStatusByLink(const KMMessage *aMsg);
 
   /** Emit progress info - calculates a percent value based on the amount of bytes sent */
   void emitProgressInfo( int currentFileProgress );
 
-signals:
-  /** Emitted regularly to inform the user of what is going on */
-  void statusMsg(const QString&);
-
 protected slots:
   /** Start sending */
   virtual void slotPrecommandFinished(bool);
@@ -200,7 +193,7 @@ protected:
 #endif
 
   /** Informs the user about what is going on. */
-  virtual void statusMsg(const QString&);
+// FIXME  virtual void statusMsg(const QString&);
 
   /** Called once for the contents of the header fields To, Cc, and Bcc.
     Returns TRUE on success and FALSE on failure.
Index: main.cpp
===================================================================
RCS file: /home/kde/kdepim/kmail/main.cpp,v
retrieving revision 1.182
diff -u -3 -p -u -b -r1.182 main.cpp
--- main.cpp	8 Jun 2003 20:16:40 -0000	1.182
+++ main.cpp	6 Aug 2003 20:49:53 -0000
@@ -8,6 +8,7 @@
 #include <knotifyclient.h>
 #include <dcopclient.h>
 #include "kmkernel.h" //control center
+#include "client.h"
 #include <kcmdlineargs.h>
 #include <qtimer.h>
 
@@ -190,6 +191,8 @@ int main(int argc, char *argv[])
 
   kapp->dcopClient()->resume(); // Ok. We are ready for DCOP requests.
   kernel->setStartingUp( false ); // Starting up is finished
+
+  KMail::Client::instance()->initConnections(*(KMail::Notifier::instance()));
   // Go!
   int ret = kapp->exec();
 


_______________________________________________
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