409
410
// Overwrite the value for complete messages and all headers!
410
411
bool logContents = true;
412
if( field() == "<message>" ) {
413
if( kasciistricmp( field(), "<message>" ) == 0 ) {
413
414
msgContents = msg->encodedContent();
414
415
logContents = false;
415
} else if ( field() == "<body>" ) {
416
} else if ( kasciistricmp( field(), "<body>" ) == 0 ) {
416
417
msgContents = msg->body();
417
418
logContents = false;
418
} else if ( field() == "<any header>" ) {
419
} else if ( kasciistricmp( field(), "<any header>" ) == 0 ) {
419
420
msgContents = msg->head();
420
421
logContents = false;
421
} else if ( field() == "<recipients>" ) {
422
} else if ( kasciistricmp( field(), "<recipients>" ) == 0 ) {
422
423
// (mmutz 2001-11-05) hack to fix "<recipients> !contains foo" to
423
424
// meet user's expectations. See FAQ entry in KDE 2.2.2's KMail
485
486
void SearchRuleString::addQueryTerms(Nepomuk::Query::GroupTerm& groupTerm) const
487
488
Nepomuk::Query::OrTerm termGroup;
488
if ( field().toLower() == "to" || field() == "<recipients>" || field() == "<any header>" || field() == "<message>" )
489
if ( kasciistricmp( field(), "<message>" ) == 0 || kasciistricmp( field(), "<recipients>" ) ==0 || kasciistricmp( field(), "<any header>" ) == 0 ) {
490
const Nepomuk::Query::ComparisonTerm valueTerm( Vocabulary::NCO::emailAddress(), Nepomuk::Query::LiteralTerm( contents() ), nepomukComparator() );
491
const Nepomuk::Query::ComparisonTerm addressTerm( Vocabulary::NCO::hasEmailAddress(), valueTerm, Nepomuk::Query::ComparisonTerm::Equal );
492
const Nepomuk::Query::ComparisonTerm personTerm( Vocabulary::NMO::to(), addressTerm, Nepomuk::Query::ComparisonTerm::Equal );
493
const Nepomuk::Query::ComparisonTerm personTermTo( Vocabulary::NMO::cc(), personTerm, Nepomuk::Query::ComparisonTerm::Equal );
494
const Nepomuk::Query::ComparisonTerm personTermCC( Vocabulary::NMO::bcc(), personTermTo, Nepomuk::Query::ComparisonTerm::Equal );
496
if ( kasciistricmp( field(), "<any header>" ) == 0 ) {
497
const Nepomuk::Query::ComparisonTerm personTermBCC( Vocabulary::NMO::from(), personTermTo, Nepomuk::Query::ComparisonTerm::Equal );
498
termGroup.addSubTerm( personTermBCC );
501
termGroup.addSubTerm( personTermCC );
504
if ( kasciistricmp( field(), "to" ) == 0 )
489
505
addPersonTerm( termGroup, Vocabulary::NMO::to() );
490
if ( field().toLower() == "cc" || field() == "<recipients>" || field() == "<any header>" || field() == "<message>" )
506
else if ( kasciistricmp( field(), "cc" ) == 0 )
491
507
addPersonTerm( termGroup, Vocabulary::NMO::cc() );
492
if ( field().toLower() == "bcc" || field() == "<recipients>" || field() == "<any header>" || field() == "<message>" )
508
else if ( kasciistricmp( field(), "bcc" ) == 0 )
493
509
addPersonTerm( termGroup, Vocabulary::NMO::bcc() );
495
if ( field().toLower() == "from" || field() == "<any header>" || field() == "<message>" )
510
else if ( kasciistricmp( field(), "from" ) == 0 )
496
511
addPersonTerm( termGroup, Vocabulary::NMO::from() );
498
if ( field().toLower() == "subject" || field() == "<any header>" || field() == "<message>" ) {
513
if ( kasciistricmp( field(), "subject" ) == 0 || kasciistricmp( field(), "<any header>" ) == 0 || kasciistricmp( field(), "<message>" ) == 0 ) {
499
514
const Nepomuk::Query::ComparisonTerm subjectTerm( Vocabulary::NMO::messageSubject(), Nepomuk::Query::LiteralTerm( contents() ), nepomukComparator() );
500
515
termGroup.addSubTerm( subjectTerm );
517
if ( kasciistricmp( field(), "reply-to" ) == 0 ) {
518
const Nepomuk::Query::ComparisonTerm replyToTerm( Vocabulary::NMO::messageReplyTo(), Nepomuk::Query::LiteralTerm( contents() ), nepomukComparator() );
519
termGroup.addSubTerm( replyToTerm );
522
if ( kasciistricmp( field(), "list-id" ) == 0 ) {
525
else if ( kasciistricmp( field(), "resent-from" ) == 0 ) {
528
else if ( kasciistricmp( field(), "x-loop" ) == 0 ) {
531
else if ( kasciistricmp( field(), "x-mailing-list" ) == 0 ) {
534
else if ( kasciistricmp( field(), "x-spam-flag" ) == 0 ) {
503
538
// TODO complete for other headers, generic headers
505
if ( field() == "<tag>" ) {
540
if ( kasciistricmp( field(), "organization" ) == 0 ) {
541
const Nepomuk::Query::ComparisonTerm headerTerm( Vocabulary::NMO::headerName(), Nepomuk::Query::LiteralTerm( contents() ), nepomukComparator() );
542
termGroup.addSubTerm( headerTerm );
547
if ( kasciistricmp( field(), "<tag>" ) == 0 ) {
506
548
const Nepomuk::Tag tag( contents() );
507
549
addAndNegateTerm( Nepomuk::Query::ComparisonTerm( Soprano::Vocabulary::NAO::hasTag(),
508
550
Nepomuk::Query::ResourceTerm( tag ),
644
685
stream.writeStartElement( func );
646
if ( field().toLower() == "subject" ||
647
field().toLower() == "to" ||
648
field().toLower() == "cc" ||
649
field().toLower() == "bcc" ||
650
field().toLower() == "from" ||
651
field().toLower() == "sender" ) {
687
if ( field().toLower() == "subject" ||
688
field().toLower() == "to" ||
689
field().toLower() == "cc" ||
690
field().toLower() == "bcc" ||
691
field().toLower() == "from" ||
692
field().toLower() == "sender" ) {
652
693
stream.writeStartElement( QLatin1String("field") );
653
694
stream.writeAttribute( QLatin1String("name"), field().toLower() );
690
731
qint64 numericalMsgContents = 0;
691
732
qint64 numericalValue = 0;
693
if ( field() == "<size>" ) {
734
if ( kasciistricmp( field(), "<size>" ) == 0 ) {
694
735
numericalMsgContents = item.size();
695
736
numericalValue = contents().toLongLong();
696
737
msgContents.setNum( numericalMsgContents );
697
} else if ( field() == "<age in days>" ) {
738
} else if ( kasciistricmp( field(), "<age in days>" ) == 0 ) {
698
739
QDateTime msgDateTime = msg->date()->dateTime().dateTime();
699
740
numericalMsgContents = msgDateTime.daysTo( QDateTime::currentDateTime() );
700
741
numericalValue = contents().toInt();
769
810
void SearchRuleNumerical::addQueryTerms(Nepomuk::Query::GroupTerm& groupTerm) const
771
if ( field() == "<size>" ) {
812
if ( kasciistricmp( field() , "<size>" ) == 0 ) {
772
813
const Nepomuk::Query::ComparisonTerm sizeTerm( Vocabulary::NIE::byteSize(),
773
814
Nepomuk::Query::LiteralTerm( contents().toInt() ),
774
815
nepomukComparator() );
775
816
addAndNegateTerm( sizeTerm, groupTerm );
776
} else if ( field() == "<age in days>" ) {
777
kDebug() << "AKONADI PORT: Disabled code in " << Q_FUNC_INFO;
817
} else if ( kasciistricmp( field(), "<age in days>" ) == 0 ) {
818
QDate date = QDate::currentDate();
819
date = date.addDays( contents().toInt() );
820
const Nepomuk::Query::ComparisonTerm dateTerm( Vocabulary::NMO::sentDate(),Nepomuk::Query::LiteralTerm(date ),nepomukComparator() );
821
addAndNegateTerm( dateTerm, groupTerm );