Branch 'kolab/integration/4.13.0' - incidenceeditor-ng/opencomposerjob.cpp kmail/kmkernel.cpp kmail/kmkernel.h

Sandro Knauß knauss at kolabsys.com
Mon Aug 18 18:40:05 CEST 2014


 incidenceeditor-ng/opencomposerjob.cpp |    4 -
 kmail/kmkernel.cpp                     |   89 ++++++++++++++++++++++-----------
 kmail/kmkernel.h                       |   27 +++++++---
 3 files changed, 84 insertions(+), 36 deletions(-)

New commits:
commit 5c2fb1f1a8ae7511e05f0613bac467122f71fca6
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Sat Aug 16 17:57:13 2014 +0200

    remove the scary hidden parameter from KMail::openComposer
    
    The hidden parameter was only recognized, if the mail is not an iTip
    invitation. Actually if calling openComposer an composer should be
    opend. No need to habe the parameter hidden.
    
    REVIEW: 119810
    
    Conflicts:
    	kmail/kmkernel.cpp
    	kmail/kmkernel.h

diff --git a/incidenceeditor-ng/opencomposerjob.cpp b/incidenceeditor-ng/opencomposerjob.cpp
index 052449a..14199af 100644
--- a/incidenceeditor-ng/opencomposerjob.cpp
+++ b/incidenceeditor-ng/opencomposerjob.cpp
@@ -132,10 +132,10 @@ void OpenComposerJob::processMail()
         QString attachParamValue = attachment->contentType()->parameter(QLatin1String("method"));
         QByteArray attachData = attachment->encodedBody();
 
-        messages << mTo << mCc << mBcc << subject << body << hidden
+        messages << mTo << mCc << mBcc << subject << body
                  << attachName << attachCte << attachData << attachType << attachSubType
                  << attachParamAttr << attachParamValue << attachContDisp << attachCharset
-                 << identity << false;
+                 << identity;
     }
     QDBusInterface kmailObj(QLatin1String("org.kde.kmail"), QLatin1String("/KMail"), QLatin1String("org.kde.kmail.kmail"));
 
diff --git a/kmail/kmkernel.cpp b/kmail/kmkernel.cpp
index b4d7dc5..8eafc34 100644
--- a/kmail/kmkernel.cpp
+++ b/kmail/kmkernel.cpp
@@ -657,17 +657,64 @@ int KMKernel::openComposer(const QString &to, const QString &cc,
                            const QByteArray &attachCharset,
                            unsigned int identity)
 {
-    return openComposer(to, cc, bcc,
-                        subject, body, hidden,
+    KMail::Composer *cWin;
+    bool iCalAutoSend = fillComposer(cWin, to, cc, bcc,
+                        subject, body,
                         attachName, attachCte, attachData,
                         attachType, attachSubType, attachParamAttr, attachParamValue,
-                        attachContDisp, attachCharset, identity, true);
+                        attachContDisp, attachCharset, identity);
+
+    if ( !hidden && !iCalAutoSend ) {
+        cWin->show();
+        // Activate window - doing this instead of KWin::activateWindow(cWin->winId());
+        // so that it also works when called from KMailApplication::newInstance()
+#if defined Q_WS_X11 && ! defined K_WS_QTONLY
+        KStartupInfo::setNewStartupId( cWin, kapp->startupId() );
+#endif
+    } else {
+
+        // Always disable word wrap when we don't show the composer, since otherwise QTextEdit
+        // gets the widget size wrong and wraps much too early.
+        cWin->disableWordWrap();
+        cWin->slotSendNow();
+    }
+    return 1;
 }
 
+int KMKernel::openComposer(const QString &to, const QString &cc,
+                           const QString &bcc, const QString &subject,
+                           const QString &body,
+                           const QString &attachName,
+                           const QByteArray &attachCte,
+                           const QByteArray &attachData,
+                           const QByteArray &attachType,
+                           const QByteArray &attachSubType,
+                           const QByteArray &attachParamAttr,
+                           const QString &attachParamValue,
+                           const QByteArray &attachContDisp,
+                           const QByteArray &attachCharset,
+                           unsigned int identity)
+{
+    KMail::Composer *cWin;
+    fillComposer(cWin, to, cc, bcc,
+                 subject, body,
+                 attachName, attachCte, attachData,
+                 attachType, attachSubType, attachParamAttr, attachParamValue,
+                 attachContDisp, attachCharset, identity);
+    cWin->show();
+    // Activate window - doing this instead of KWin::activateWindow(cWin->winId());
+    // so that it also works when called from KMailApplication::newInstance()
+#if defined Q_WS_X11 && ! defined K_WS_QTONLY
+    KStartupInfo::setNewStartupId( cWin, kapp->startupId() );
+#endif
+
+    return 1;
+}
 
-int KMKernel::openComposer (const QString &to, const QString &cc,
+bool KMKernel::fillComposer (KMail::Composer *&cWin,
+                            const QString &to, const QString &cc,
                             const QString &bcc, const QString &subject,
-                            const QString &body, bool hidden,
+                            const QString &body,
                             const QString &attachName,
                             const QByteArray &attachCte,
                             const QByteArray &attachData,
@@ -677,10 +724,8 @@ int KMKernel::openComposer (const QString &to, const QString &cc,
                             const QString &attachParamValue,
                             const QByteArray &attachContDisp,
                             const QByteArray &attachCharset,
-                            unsigned int identity,
-                            bool allowDefaultSend)
+                            unsigned int identity)
 {
-    kDebug();
     KMail::Composer::TemplateContext context = KMail::Composer::New;
     KMime::Message::Ptr msg( new KMime::Message );
     KMime::Content *msgPart = 0;
@@ -696,7 +741,6 @@ int KMKernel::openComposer (const QString &to, const QString &cc,
     }
     if ( !body.isEmpty() ) {
         msg->setBody(body.toUtf8());
-        context = KMail::Composer::NoTemplate;
     } else {
         TemplateParser::TemplateParser parser( msg, TemplateParser::TemplateParser::NewMessage );
         parser.setIdentityManager( KMKernel::self()->identityManager() );
@@ -718,7 +762,6 @@ int KMKernel::openComposer (const QString &to, const QString &cc,
              MessageViewer::GlobalSettings::self()->legacyBodyInvites() ) {
             // KOrganizer invitation caught and to be sent as body instead
             msg->setBody( attachData );
-            context = KMail::Composer::NoTemplate;
             msg->contentType()->from7BitString(
                         QString::fromLatin1("text/calendar; method=%1; "
                                             "charset=\"utf-8\"" ).
@@ -749,7 +792,12 @@ int KMKernel::openComposer (const QString &to, const QString &cc,
     }
 
     msg->assemble();
-    KMail::Composer * cWin = KMail::makeComposer( KMime::Message::Ptr(), false, false,context );
+
+    if (!msg->body().isEmpty()) {
+        context = KMail::Composer::NoTemplate;
+    }
+
+    cWin = KMail::makeComposer( KMime::Message::Ptr(), false, false, context);
     cWin->setMessage( msg, false, false, !isICalInvitation /* mayAutoSign */ );
     cWin->setSigningAndEncryptionDisabled( isICalInvitation
                                            && MessageViewer::GlobalSettings::self()->legacyBodyInvites() );
@@ -758,27 +806,12 @@ int KMKernel::openComposer (const QString &to, const QString &cc,
     if ( msgPart )
         cWin->addAttach( msgPart );
     if ( isICalInvitation ) {
+        cWin->disableWordWrap();
         cWin->forceDisableHtml();
         //cWin->disableRecipientNumberCheck();
         cWin->disableForgottenAttachmentsCheck();
     }
-
-    if ( !hidden && !(allowDefaultSend && iCalAutoSend)  ) {
-        cWin->show();
-        // Activate window - doing this instead of KWin::activateWindow(cWin->winId());
-        // so that it also works when called from KMailApplication::newInstance()
-#if defined Q_WS_X11 && ! defined K_WS_QTONLY
-        KStartupInfo::setNewStartupId( cWin, kapp->startupId() );
-#endif
-    } else {
-
-        // Always disable word wrap when we don't show the composer, since otherwise QTextEdit
-        // gets the widget size wrong and wraps much too early.
-        cWin->disableWordWrap();
-        cWin->slotSendNow();
-    }
-
-    return 1;
+    return iCalAutoSend;
 }
 
 QDBusObjectPath KMKernel::openComposer( const QString &to, const QString &cc,
diff --git a/kmail/kmkernel.h b/kmail/kmkernel.h
index bf3f549..abed081 100644
--- a/kmail/kmkernel.h
+++ b/kmail/kmkernel.h
@@ -245,7 +245,6 @@ public Q_SLOTS:
    * @param bcc A comma separated list of BCC addresses.
    * @param subject The message subject.
    * @param body The message body.
-   * @param hidden Whether the composer window shall initially be hidden.
    * @param attachName The name of the attachment.
    * @param attachCte The content transfer encoding of the attachment.
    * @param attachData The raw data of the attachment.
@@ -256,15 +255,12 @@ public Q_SLOTS:
    * @param attachContDisp The content display type of the attachment.
    * @param attachCharset The charset of the attachment.
    * @param identity The identity identifier which will be used as sender identity.
-   * @param allowDefaultSend Overwrite automatic sending feature,
-   *                         to make sure a composer is opend
    */
     Q_SCRIPTABLE int openComposer( const QString & to,
                                    const QString & cc,
                                    const QString & bcc,
                                    const QString & subject,
                                    const QString & body,
-                                   bool hidden,
                                    const QString & attachName,
                                    const QByteArray & attachCte,
                                    const QByteArray  &attachData,
@@ -274,8 +270,7 @@ public Q_SLOTS:
                                    const QString & attachParamValue,
                                    const QByteArray & attachContDisp,
                                    const QByteArray & attachCharset,
-                                   unsigned int identity,
-                                   bool allowDefaultSend );
+                                   unsigned int identity);
 
 
     /**
@@ -536,6 +531,26 @@ private slots:
     void slotCollectionChanged(const Akonadi::Collection &, const QSet<QByteArray> &set);
 
 private:
+    /*
+     * Fills a composer cWin
+     *
+     * @returns true if attached message is a valid iCal message
+    */
+    bool fillComposer (KMail::Composer *&cWin,
+        const QString &to, const QString &cc,
+        const QString &bcc, const QString &subject,
+        const QString &body,
+        const QString &attachName,
+        const QByteArray &attachCte,
+        const QByteArray &attachData,
+        const QByteArray &attachType,
+        const QByteArray &attachSubType,
+        const QByteArray &attachParamAttr,
+        const QString &attachParamValue,
+        const QByteArray &attachContDisp,
+        const QByteArray &attachCharset,
+        unsigned int identity);
+
     void resourceGoOnLine();
     void openReader( bool onlyCheck );
     QSharedPointer<MailCommon::FolderCollection> currentFolderCollection();




More information about the commits mailing list