From 06ed35edf795ea4cc79bbe0d1096eb8973055432 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Sun, 24 Jul 2005 15:54:05 +0000 Subject: [PATCH] Allow getting/setting importance directly from/on message header. --- src/misc/importanceHelper.cpp | 18 +++++++++++++++--- vmime/misc/importanceHelper.hpp | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/misc/importanceHelper.cpp b/src/misc/importanceHelper.cpp index 0fc9e16a..96f80183 100644 --- a/src/misc/importanceHelper.cpp +++ b/src/misc/importanceHelper.cpp @@ -27,8 +27,12 @@ namespace misc { void importanceHelper::resetImportance(ref msg) { - ref
hdr = msg->getHeader(); + resetImportance(msg->getHeader()); +} + +void importanceHelper::resetImportance(ref
hdr) +{ try { ref fld = hdr->findField("X-Priority"); @@ -53,8 +57,12 @@ void importanceHelper::resetImportance(ref msg) const importanceHelper::Importance importanceHelper::getImportance(const ref msg) { - const ref hdr = msg->getHeader(); + return getImportance(msg->getHeader()); +} + +const importanceHelper::Importance importanceHelper::getImportance(const ref hdr) +{ try { const ref fld = hdr->findField("X-Priority").dynamicCast (); @@ -98,8 +106,12 @@ const importanceHelper::Importance importanceHelper::getImportance(const ref msg, const Importance i) { - ref
hdr = msg->getHeader(); + setImportance(msg->getHeader(), i); +} + +void importanceHelper::setImportance(ref
hdr, const Importance i) +{ // "X-Priority:" Field ref fld = hdr->getField("X-Priority").dynamicCast (); diff --git a/vmime/misc/importanceHelper.hpp b/vmime/misc/importanceHelper.hpp index b9118659..1f2b4553 100644 --- a/vmime/misc/importanceHelper.hpp +++ b/vmime/misc/importanceHelper.hpp @@ -56,6 +56,12 @@ public: */ static void resetImportance(ref msg); + /** Reset the importance of the message to the default importance. + * + * @param hdr message header on which to reset importance + */ + static void resetImportance(ref
hdr); + /** Return the importance of the specified message. * * @param msg message from which to retrieve importance @@ -64,12 +70,27 @@ public: */ static const Importance getImportance(const ref msg); + /** Return the importance of the specified message. + * + * @param hdr message header from which to retrieve importance + * @return importance of the message, or default importance is no + * information about importance is given in the message + */ + static const Importance getImportance(const ref hdr); + /** Set the importance of the specified message. * * @param msg message on which to set importance * @param i new message importance */ static void setImportance(ref msg, const Importance i); + + /** Set the importance of the specified message. + * + * @param hdr message header on which to set importance + * @param i new message importance + */ + static void setImportance(ref
hdr, const Importance i); };