~ubuntu-branches/ubuntu/quantal/kdepim/quantal

« back to all changes in this revision

Viewing changes to messagecomposer/attachmentcontrollerbase.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-15 14:17:51 UTC
  • mto: This revision was merged to the branch mainline in revision 193.
  • Revision ID: package-import@ubuntu.com-20111215141751-bmhdpiwl23wd9w26
Tags: upstream-4.7.90
ImportĀ upstreamĀ versionĀ 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
#include <libkleo/ui/keyselectiondialog.h>
55
55
 
56
56
#include <messagecore/attachmentcompressjob.h>
 
57
#include <messagecore/attachmentfromfolderjob.h>
57
58
#include <messagecore/attachmentfrommimecontentjob.h>
58
59
#include <messagecore/attachmentfromurljob.h>
59
60
#include <messagecore/attachmentpropertiesdialog.h>
212
213
    return;
213
214
  }
214
215
 
215
 
  Q_ASSERT( dynamic_cast<AttachmentFromUrlJob*>( job ) );
216
 
  AttachmentFromUrlJob *ajob = static_cast<AttachmentFromUrlJob*>( job );
 
216
  Q_ASSERT( dynamic_cast<AttachmentLoadJob*>( job ) );
 
217
  AttachmentLoadJob *ajob = static_cast<AttachmentLoadJob*>( job );
217
218
  AttachmentPart::Ptr part = ajob->attachmentPart();
218
219
  q->addAttachment( part );
219
220
}
451
452
    kDebug() << "Compressing part.";
452
453
 
453
454
    AttachmentCompressJob *ajob = new AttachmentCompressJob( part, this );
454
 
    connect( ajob, SIGNAL(result(KJob*)), this, SLOT( compressJobResult(KJob*)) );
 
455
    connect( ajob, SIGNAL(result(KJob*)), this, SLOT(compressJobResult(KJob*)) );
455
456
    ajob->start();
456
457
  } else {
457
458
    kDebug() << "Uncompressing part.";
509
510
  Message::Composer *composer = new Message::Composer;
510
511
  composer->globalPart()->setFallbackCharsetEnabled( true );
511
512
  Message::AttachmentJob *attachmentJob = new Message::AttachmentJob( part, composer );
512
 
  connect( attachmentJob, SIGNAL( result( KJob*) ),
513
 
           this, SLOT( slotAttachmentContentCreated( KJob* ) ) );
 
513
  connect( attachmentJob, SIGNAL(result(KJob*)),
 
514
           this, SLOT(slotAttachmentContentCreated(KJob*)) );
514
515
  attachmentJob->start();
515
516
}
516
517
 
585
586
void AttachmentControllerBase::byteArrayToRemoteFile(const QByteArray &aData, const KUrl &aURL, bool overwrite)
586
587
{
587
588
  KIO::StoredTransferJob *job = KIO::storedPut( aData, aURL, -1, overwrite ? KIO::Overwrite : KIO::DefaultFlags );
588
 
  connect( job, SIGNAL(result(KJob *)), SLOT(slotPutResult(KJob *)) );
 
589
  connect( job, SIGNAL(result(KJob*)), SLOT(slotPutResult(KJob*)) );
589
590
}
590
591
 
591
592
void AttachmentControllerBase::slotPutResult(KJob *job)
630
631
      i18n( "Attach File" ), KFileDialog::Other, d->wParent );
631
632
 
632
633
  dialog->okButton()->setGuiItem( KGuiItem( i18n("&Attach"), QLatin1String( "document-open" ) ) );
633
 
  dialog->setMode( KFile::Files );
 
634
  dialog->setMode( KFile::Files|KFile::Directory );
634
635
  if( dialog->exec() == KDialog::Accepted && dialog ) {
635
636
    const KUrl::List files = dialog->selectedUrls();
636
637
    foreach( const KUrl &url, files ) {
662
663
 
663
664
void AttachmentControllerBase::addAttachment( const KUrl &url )
664
665
{
665
 
  AttachmentFromUrlJob *ajob = new AttachmentFromUrlJob( url, this );
 
666
  AttachmentFromUrlBaseJob *ajob = 0;
 
667
  if( KMimeType::findByUrl( url )->name() == QLatin1String( "inode/directory" ) ) {
 
668
    kDebug() << "Creating attachment from folder";
 
669
     ajob = new AttachmentFromFolderJob ( url, this );
 
670
  }
 
671
  else{
 
672
    ajob = new AttachmentFromUrlJob( url, this );
 
673
    kDebug() << "Creating attachment from file";
 
674
  }
666
675
  if( MessageComposer::MessageComposerSettings::maximumAttachmentSize() > 0 ) {
667
676
    ajob->setMaximumAllowedSize( MessageComposer::MessageComposerSettings::maximumAttachmentSize() * 1024 * 1024 );
668
677
  }