Beispiel #1
0
void MapiResource::error(const Akonadi::Collection &collection, const QString &body)
{
    static QString prefix = QString::fromAscii("Error %1(%2): %3");
    QString message = prefix.arg(collection.remoteId()).arg(collection.name()).arg(body);

    error(message);
}
void XXPortManager::slotImport( const QString &identifier )
{
  const XXPort *xxport = mFactory.createXXPort( identifier, mParentWidget );
  if( !xxport ) {
    return;
  }

  const KABC::Addressee::List contacts = xxport->importContacts();

  delete xxport;

  if ( contacts.isEmpty() ) { // nothing to import
    return;
  }

  const QStringList mimeTypes( KABC::Addressee::mimeType() );

  QPointer<Akonadi::CollectionDialog> dlg = new Akonadi::CollectionDialog( mParentWidget );
  dlg->setMimeTypeFilter( mimeTypes );
  dlg->setAccessRightsFilter( Akonadi::Collection::CanCreateItem );
  dlg->setCaption( i18n( "Select Address Book" ) );
  dlg->setDescription(
    i18n( "Select the address book the imported contact(s) shall be saved in:" ) );
  dlg->setDefaultCollection( mDefaultAddressBook );

  if ( !dlg->exec() || !dlg ) {
    delete dlg;
    return;
  }

  const Akonadi::Collection collection = dlg->selectedCollection();
  delete dlg;

  if ( !mImportProgressDialog ) {
    mImportProgressDialog = new KProgressDialog( mParentWidget, i18n( "Import Contacts" ) );
    mImportProgressDialog->setLabelText(
      i18np( "Importing one contact to %2", "Importing %1 contacts to %2",
             contacts.count(), collection.name() ) );
    mImportProgressDialog->setAllowCancel( false );
    mImportProgressDialog->setAutoClose( true );
    mImportProgressDialog->progressBar()->setRange( 1, contacts.count() );
  }

  mImportProgressDialog->show();

  for ( int i = 0; i < contacts.count(); ++i ) {
    Akonadi::Item item;
    item.setPayload<KABC::Addressee>( contacts.at( i ) );
    item.setMimeType( KABC::Addressee::mimeType() );

    Akonadi::ItemCreateJob *job = new Akonadi::ItemCreateJob( item, collection );
    connect( job, SIGNAL(result(KJob*)), SLOT(slotImportJobDone(KJob*)) );
  }
}
Beispiel #3
0
Akonadi::Collection VirtualResource::createCollection(const Akonadi::Collection &collection)
{
    // kDebug() << collection.name() << collection.parentCollection().remoteId();
    // kDebug() << "contentMimeTypes: " << collection.contentMimeTypes();

    Q_ASSERT(!collection.name().isEmpty());
    Collection col = collection;
    if (!col.parentCollection().isValid()) {
        col.setParentCollection(mRootCollection);
    }
    CollectionCreateJob *create = new CollectionCreateJob(col, mSession);
    EXEC(create);
    return create->collection();
}
Beispiel #4
0
Akonadi::Collection VirtualResource::createRootCollection(const Akonadi::Collection &collection)
{
    kDebug() << collection.name();
    mRootCollection = createCollection(collection);
    return mRootCollection;
}