~ubuntu-branches/ubuntu/raring/kdepim/raring-proposed

« back to all changes in this revision

Viewing changes to kmail/attachmentcontroller.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-06-07 07:56:38 UTC
  • mfrom: (0.2.27)
  • Revision ID: package-import@ubuntu.com-20120607075638-0luhdq11z7sgvs4m
Tags: 4:4.8.80-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
  Akonadi::ItemFetchJob *itemFetchJob = new Akonadi::ItemFetchJob( items, this );
107
107
  itemFetchJob->fetchScope().fetchFullPayload( true );
108
108
  itemFetchJob->fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
109
 
  connect( itemFetchJob, SIGNAL(result(KJob*)), this, SLOT(slotFetchJob(KJob*)) );
110
 
}
111
 
 
112
 
void AttachmentController::slotFetchJob( KJob *job )
113
 
{
114
 
  if ( job->error() ) {
115
 
    MailCommon::Util::showJobErrorMessage( job );
116
 
    return;
117
 
  }
118
 
  Akonadi::ItemFetchJob *fjob = dynamic_cast<Akonadi::ItemFetchJob*>( job );
119
 
  if ( !fjob )
120
 
    return;
121
 
  Akonadi::Item::List items = fjob->items();
122
 
 
123
 
  if ( items.isEmpty() )
124
 
    return;
125
 
 
126
 
  if ( items.first().mimeType() == KMime::Message::mimeType() ) {
127
 
    uint identity = 0;
128
 
    if ( items.at( 0 ).isValid() && items.at( 0 ).parentCollection().isValid() ) {
129
 
      QSharedPointer<FolderCollection> fd( FolderCollection::forCollection( items.at( 0 ).parentCollection(), false ) );
130
 
      identity = fd->identity();
131
 
    }
132
 
    KMCommand *command = new KMForwardAttachedCommand( mComposer, items,identity, mComposer );
133
 
    command->start();
134
 
  } else {
135
 
    foreach ( const Akonadi::Item &item, items ) {
136
 
      QString attachmentName = QLatin1String( "attachment" );
137
 
      if ( item.hasPayload<KABC::Addressee>() ) {
138
 
        const KABC::Addressee contact = item.payload<KABC::Addressee>();
139
 
        attachmentName = contact.realName() + QLatin1String( ".vcf" );
140
 
      }
141
 
 
142
 
      mComposer->addAttachment( attachmentName, KMime::Headers::CEbase64, QString(), item.payloadData(), item.mimeType().toLatin1() );
143
 
    }
144
 
  }
 
109
  connect( itemFetchJob, SIGNAL(result(KJob*)), mComposer, SLOT(slotFetchJob(KJob*)) );
145
110
}
146
111
 
147
112
void AttachmentController::selectionChanged()