diff options
Diffstat (limited to 'examples/maildirresource/libmaildir/maildir.cpp')
-rw-r--r-- | examples/maildirresource/libmaildir/maildir.cpp | 166 |
1 files changed, 83 insertions, 83 deletions
diff --git a/examples/maildirresource/libmaildir/maildir.cpp b/examples/maildirresource/libmaildir/maildir.cpp index f8ca606..daf2e8f 100644 --- a/examples/maildirresource/libmaildir/maildir.cpp +++ b/examples/maildirresource/libmaildir/maildir.cpp | |||
@@ -142,7 +142,6 @@ public: | |||
142 | { | 142 | { |
143 | // KeyCache* keyCache = KeyCache::self(); | 143 | // KeyCache* keyCache = KeyCache::self(); |
144 | // if (keyCache->isNewKey(path, key)) { | 144 | // if (keyCache->isNewKey(path, key)) { |
145 | qWarning() << path + QString::fromLatin1("/new/") + key; | ||
146 | if (QFile::exists(path + QString::fromLatin1("/new/") + key)) { | 145 | if (QFile::exists(path + QString::fromLatin1("/new/") + key)) { |
147 | #ifdef DEBUG_KEYCACHE_CONSITENCY | 146 | #ifdef DEBUG_KEYCACHE_CONSITENCY |
148 | if (!QFile::exists(path + QString::fromLatin1("/new/") + key)) { | 147 | if (!QFile::exists(path + QString::fromLatin1("/new/") + key)) { |
@@ -688,88 +687,89 @@ bool Maildir::removeEntry(const QString& key) | |||
688 | // return QFile::remove(realKey); | 687 | // return QFile::remove(realKey); |
689 | } | 688 | } |
690 | 689 | ||
691 | // QString Maildir::changeEntryFlags(const QString& key, const Sink::Item::Flags& flags) | 690 | QString Maildir::changeEntryFlags(const QString& key, const Maildir::Flags& flags) |
692 | // { | 691 | { |
693 | // QString realKey(d->findRealKey(key)); | 692 | QString realKey(d->findRealKey(key)); |
694 | // if (realKey.isEmpty()) { | 693 | if (realKey.isEmpty()) { |
695 | // qWarning() << "Maildir::changeEntryFlags unable to find: " << key; | 694 | qWarning() << "Maildir::changeEntryFlags unable to find: " << key; |
696 | // d->lastError = i18n("Cannot locate mail file %1." , key); | 695 | // d->lastError = i18n("Cannot locate mail file %1." , key); |
697 | // return QString(); | 696 | return QString(); |
698 | // } | 697 | } |
699 | // | 698 | |
700 | // const QRegExp rx = *(statusSeparatorRx()); | 699 | const QRegExp rx = *(statusSeparatorRx()); |
701 | // QString finalKey = key.left(key.indexOf(rx)); | 700 | QString finalKey = key.left(key.indexOf(rx)); |
702 | // | 701 | |
703 | // QStringList mailDirFlags; | 702 | QStringList mailDirFlags; |
704 | // Q_FOREACH (const Sink::Item::Flag &flag, flags) { | 703 | if (flags & Forwarded) |
705 | // if (flag == Sink::MessageFlags::Forwarded) | 704 | mailDirFlags << QLatin1String("P"); |
706 | // mailDirFlags << QLatin1String("P"); | 705 | if (flags & Replied) |
707 | // if (flag == Sink::MessageFlags::Replied) | 706 | mailDirFlags << QLatin1String("R"); |
708 | // mailDirFlags << QLatin1String("R"); | 707 | if (flags & Seen) |
709 | // if (flag == Sink::MessageFlags::Seen) | 708 | mailDirFlags << QLatin1String("S"); |
710 | // mailDirFlags << QLatin1String("S"); | 709 | if (flags & Deleted) |
711 | // if (flag == Sink::MessageFlags::Deleted) | 710 | mailDirFlags << QLatin1String("T"); |
712 | // mailDirFlags << QLatin1String("T"); | 711 | if (flags & Flagged) |
713 | // if (flag == Sink::MessageFlags::Flagged) | 712 | mailDirFlags << QLatin1String("F"); |
714 | // mailDirFlags << QLatin1String("F"); | 713 | |
715 | // } | 714 | mailDirFlags.sort(); |
716 | // mailDirFlags.sort(); | 715 | if (!mailDirFlags.isEmpty()) { |
717 | // if (!mailDirFlags.isEmpty()) { | 716 | #ifdef Q_OS_WIN |
718 | // #ifdef Q_OS_WIN | 717 | finalKey.append(QLatin1String("!2,") + mailDirFlags.join(QString())); |
719 | // finalKey.append(QLatin1String("!2,") + mailDirFlags.join(QString())); | 718 | #else |
720 | // #else | 719 | finalKey.append(QLatin1String(":2,") + mailDirFlags.join(QString())); |
721 | // finalKey.append(QLatin1String(":2,") + mailDirFlags.join(QString())); | 720 | #endif |
722 | // #endif | 721 | } |
723 | // } | 722 | |
724 | // | 723 | QString newUniqueKey = finalKey; //key without path |
725 | // QString newUniqueKey = finalKey; //key without path | 724 | finalKey.prepend(d->path + QString::fromLatin1("/cur/")); |
726 | // finalKey.prepend(d->path + QString::fromLatin1("/cur/")); | 725 | |
727 | // | 726 | if (realKey == finalKey) { |
728 | // if (realKey == finalKey) { | 727 | // Somehow it already is named this way (e.g. migration bug -> wrong status in sink) |
729 | // // Somehow it already is named this way (e.g. migration bug -> wrong status in sink) | 728 | qWarning() << "File already named that way: " << newUniqueKey << finalKey; |
730 | // return newUniqueKey; | 729 | return newUniqueKey; |
731 | // } | 730 | } |
732 | // | 731 | |
733 | // QFile f(realKey); | 732 | QFile f(realKey); |
734 | // if (QFile::exists(finalKey)) { | 733 | if (QFile::exists(finalKey)) { |
735 | // QFile destFile(finalKey); | 734 | QFile destFile(finalKey); |
736 | // QByteArray destContent; | 735 | QByteArray destContent; |
737 | // if (destFile.open(QIODevice::ReadOnly)) { | 736 | if (destFile.open(QIODevice::ReadOnly)) { |
738 | // destContent = destFile.readAll(); | 737 | destContent = destFile.readAll(); |
739 | // destFile.close(); | 738 | destFile.close(); |
740 | // } | 739 | } |
741 | // QByteArray sourceContent; | 740 | QByteArray sourceContent; |
742 | // if (f.open(QIODevice::ReadOnly)) { | 741 | if (f.open(QIODevice::ReadOnly)) { |
743 | // sourceContent = f.readAll(); | 742 | sourceContent = f.readAll(); |
744 | // f.close(); | 743 | f.close(); |
745 | // } | 744 | } |
746 | // | 745 | |
747 | // if (destContent != sourceContent) { | 746 | if (destContent != sourceContent) { |
748 | // QString newFinalKey = QLatin1String("1-") + newUniqueKey; | 747 | QString newFinalKey = QLatin1String("1-") + newUniqueKey; |
749 | // int i = 1; | 748 | int i = 1; |
750 | // while (QFile::exists(d->path + QString::fromLatin1("/cur/") + newFinalKey)) { | 749 | while (QFile::exists(d->path + QString::fromLatin1("/cur/") + newFinalKey)) { |
751 | // i++; | 750 | i++; |
752 | // newFinalKey = QString::number(i) + QLatin1Char('-') + newUniqueKey; | 751 | newFinalKey = QString::number(i) + QLatin1Char('-') + newUniqueKey; |
753 | // } | 752 | } |
754 | // finalKey = d->path + QString::fromLatin1("/cur/") + newFinalKey; | 753 | finalKey = d->path + QString::fromLatin1("/cur/") + newFinalKey; |
755 | // } else { | 754 | } else { |
756 | // QFile::remove(finalKey); //they are the same | 755 | QFile::remove(finalKey); //they are the same |
757 | // } | 756 | } |
758 | // } | 757 | } |
759 | // | 758 | |
760 | // if (!f.rename(finalKey)) { | 759 | if (!f.rename(finalKey)) { |
761 | // qWarning() << "Maildir: Failed to rename entry: " << f.fileName() << " to " << finalKey << "! Error: " << f.errorString(); | 760 | qWarning() << "Maildir: Failed to rename entry: " << f.fileName() << " to " << finalKey << "! Error: " << f.errorString(); |
762 | // d->lastError = i18n("Failed to update the file name %1 to %2 on the disk. The error was: %3." , f.fileName(), finalKey, f.errorString()); | 761 | // d->lastError = i18n("Failed to update the file name %1 to %2 on the disk. The error was: %3." , f.fileName(), finalKey, f.errorString()); |
763 | // return QString(); | 762 | return QString(); |
764 | // } | 763 | } |
765 | // | 764 | qWarning() << "Renamed file: " << f.fileName() << finalKey; |
766 | // KeyCache *keyCache = KeyCache::self(); | 765 | |
767 | // keyCache->removeKey(d->path, key); | 766 | // KeyCache *keyCache = KeyCache::self(); |
768 | // keyCache->addCurKey(d->path, newUniqueKey); | 767 | // keyCache->removeKey(d->path, key); |
769 | // | 768 | // keyCache->addCurKey(d->path, newUniqueKey); |
770 | // return newUniqueKey; | 769 | |
771 | // } | 770 | return newUniqueKey; |
772 | // | 771 | } |
772 | |||
773 | Maildir::Flags Maildir::readEntryFlags(const QString& key) | 773 | Maildir::Flags Maildir::readEntryFlags(const QString& key) |
774 | { | 774 | { |
775 | Flags flags; | 775 | Flags flags; |