コード例 #1
0
ファイル: kcalconversiontest.cpp プロジェクト: maxyz/libkolab
void compareAttendeesVectors(const KCalCore::Attendee::List &list, const KCalCore::Attendee::List &other)
{
    QCOMPARE(list.size(), other.size());
    for (int i = 0 ; i < list.size(); i++) {
        KCalCore::Attendee::Ptr at1 = list.at(i).constCast<KCalCore::Attendee>();
        at1->setUid(QString());
        KCalCore::Attendee::Ptr at2 = other.at(i).constCast<KCalCore::Attendee>();
        at2->setUid(QString());
        QCOMPARE(*at1, *at2);
    }
}
コード例 #2
0
ファイル: mailclient_p.cpp プロジェクト: lenggi/kcalcore
void MailClient::mailAttendees( const KCalCore::IncidenceBase::Ptr &incidence,
                                const KPIMIdentities::Identity &identity,
                                bool bccMe, const QString &attachment,
                                const QString &mailTransport )
{
  Q_ASSERT( incidence );
  KCalCore::Attendee::List attendees = incidence->attendees();
  if ( attendees.isEmpty() ) {
    kWarning() << "There are no attendees to e-mail";
    emit finished( ResultNoAttendees, i18n( "There are no attendees to e-mail" ) );
    return;
  }

  const QString from = incidence->organizer()->fullName();
  const QString organizerEmail = incidence->organizer()->email();

  QStringList toList;
  QStringList ccList;
  const int numberOfAttendees = attendees.count();
  for ( int i=0; i<numberOfAttendees; ++i ) {
    KCalCore::Attendee::Ptr a = attendees.at( i );

    const QString email = a->email();
    if ( email.isEmpty() ) {
      continue;
    }

    // In case we (as one of our identities) are the organizer we are sending
    // this mail. We could also have added ourselves as an attendee, in which
    // case we don't want to send ourselves a notification mail.
    if ( organizerEmail == email ) {
      continue;
    }

    // Build a nice address for this attendee including the CN.
    QString tname, temail;
    const QString username = KPIMUtils::quoteNameIfNecessary( a->name() );
    // ignore the return value from extractEmailAddressAndName() because
    // it will always be false since tusername does not contain "@domain".
    KPIMUtils::extractEmailAddressAndName( username, temail/*byref*/, tname/*byref*/ );
    tname += QLatin1String( " <" ) + email + QLatin1Char( '>' );

    // Optional Participants and Non-Participants are copied on the email
    if ( a->role() == KCalCore::Attendee::OptParticipant ||
         a->role() == KCalCore::Attendee::NonParticipant ) {
      ccList << tname;
    } else {
      toList << tname;
    }
  }
  if( toList.isEmpty() && ccList.isEmpty() ) {
    // Not really to be called a groupware meeting, eh
    kWarning() << "There are really no attendees to e-mail";
    emit finished( ResultReallyNoAttendees, i18n( "There are no attendees to e-mail" ) );
    return;
  }
  QString to;
  if ( !toList.isEmpty() ) {
    to = toList.join( QLatin1String( ", " ) );
  }
  QString cc;
  if ( !ccList.isEmpty() ) {
    cc = ccList.join( QLatin1String( ", " ) );
  }

  QString subject;
  if ( incidence->type() != KCalCore::Incidence::TypeFreeBusy ) {
    KCalCore::Incidence::Ptr inc = incidence.staticCast<KCalCore::Incidence>();
    subject = inc->summary();
  } else {
    subject = i18n( "Free Busy Object" );
  }

  const QString body = KCalUtils::IncidenceFormatter::mailBodyStr( incidence,
                                                                   KSystemTimeZones::local() );

  send( identity, from, to, cc, subject, body, false, bccMe, attachment, mailTransport );
}