[Kde-pim] Review Request: Enable direct attaching of folders in kmail

Laurent Montel montel at kde.org
Thu Sep 1 08:43:38 BST 2011


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/102501/#review6204
-----------------------------------------------------------


Hi,
I looked at your patch:
So first:
Could you try to merge attachmentfromfolder.h and attachmentfromurljob.h they used same variable.
So create a attachmenturlbase.h for example.

After that you use KZip *zip; but leak it in several place.

for example here:
+    zip = new KZip ( &dev );
+    if ( !zip->open ( QIODevice::WriteOnly ) ) {
+        q->setError ( KJob::UserDefinedError );
+        q->setErrorText ( i18n ( "Could not create compressed file." ) );
+        q->emitResult();
+        return;
+    }

=> add delete zip; zip = 0;


void AttachmentFromFolder::AttachmentFromFolder::Private::addEntity ( QFileInfoList f, QString path )
use const ref:
=> void AttachmentFromFolder::AttachmentFromFolder::Private::addEntity ( const QFileInfoList& f, const QString& path )



+  if ( url.isLocalFile() && qstrcmp(KMimeType::findByUrl(url)->name().toAscii(),"inode/directory") == 0 ){
+    kDebug() << "Creating attachment from folder";
+     AttachmentFromFolder *ajob = new AttachmentFromFolder ( url, this );
+       if( MessageComposer::MessageComposerSettings::maximumAttachmentSize() > 0 ) {
+    ajob->setMaximumAllowedSize( MessageComposer::MessageComposerSettings::maximumAttachmentSize() * 1024 * 1024 );
+  }
+  connect( ajob, SIGNAL(result(KJob*)), this, SLOT(loadJobResult(KJob*)) );
+  ajob->start();
+  }
+  else{
   AttachmentFromUrlJob *ajob = new AttachmentFromUrlJob( url, this );
-  if( MessageComposer::MessageComposerSettings::maximumAttachmentSize() > 0 ) {
+  kDebug() << "Creating attachment from file";
+    if( MessageComposer::MessageComposerSettings::maximumAttachmentSize() > 0 ) {
     ajob->setMaximumAllowedSize( MessageComposer::MessageComposerSettings::maximumAttachmentSize() * 1024 * 1024 );
   }
   connect( ajob, SIGNAL(result(KJob*)), this, SLOT(loadJobResult(KJob*)) );
   ajob->start();
+  }
+


if you create a class base you can reduce duplicate code here

+  AttachmentUrlBase *ajob;
+  if ( url.isLocalFile() && qstrcmp(KMimeType::findByUrl(url)->name().toAscii(),"inode/directory") == 0 ){
+    kDebug() << "Creating attachment from folder";
+     ajob = new AttachmentFromFolder ( url, this );
+  }
+  else{
   ajob = new AttachmentFromUrlJob( url, this );
+  kDebug() << "Creating attachment from file";
+}
if( MessageComposer::MessageComposerSettings::maximumAttachmentSize() > 0 ) {
     ajob->setMaximumAllowedSize( MessageComposer::MessageComposerSettings::maximumAttachmentSize() * 1024 * 1024 );
   }
connect( ajob, SIGNAL(result(KJob*)), this, SLOT(loadJobResult(KJob*)) );
ajob->start();


"url.isLocalFile()" we can't compress not local file ?


Regards

- Laurent


On Aug. 31, 2011, 11:54 p.m., Martin Bednar wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/102501/
> -----------------------------------------------------------
> 
> (Updated Aug. 31, 2011, 11:54 p.m.)
> 
> 
> Review request for KDEPIM.
> 
> 
> Summary
> -------
> 
> Creates a new class attachmentfromfolder that enables automatic compression (zip) and attachment of folders dropped on the messagecomposer window.
> 
> 
> This addresses bug 42767.
>     http://bugs.kde.org/show_bug.cgi?id=42767
> 
> 
> Diffs
> -----
> 
>   messagecomposer/attachmentcontrollerbase.cpp f8aea5c 
>   messagecore/CMakeLists.txt 821625f 
>   messagecore/attachmentfromfolder.h PRE-CREATION 
>   messagecore/attachmentfromfolder.cpp PRE-CREATION 
> 
> Diff: http://git.reviewboard.kde.org/r/102501/diff
> 
> 
> Testing
> -------
> 
> Sent myself an email with a dropped folder attached. The folder contained a .ogg and a text file. The .ogg played correctly, the text file was readable with correct contents.
> 
> 
> Thanks,
> 
> Martin
> 
>

_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list