Update of /cvsroot/mahogany/M/include
In directory usw-pr-cvs1:/tmp/cvs-serv21563/include
Modified Files:
Message.h MessageCC.h
Log Message:
reworked Message::GetAllHeaders() API once again, now we have HeaderIterator class
which solves the problem with multiple headers
Index: Message.h
===================================================================
RCS file: /cvsroot/mahogany/M/include/Message.h,v
retrieving revision 1.64
retrieving revision 1.65
diff -b -u -2 -r1.64 -r1.65
--- Message.h 17 Jul 2002 14:43:55 -0000 1.64
+++ Message.h 3 Sep 2002 12:28:18 -0000 1.65
@@ -14,4 +14,8 @@
#define MESSAGE_H
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
#include "MObject.h"
@@ -27,5 +31,5 @@
// ----------------------------------------------------------------------------
-// Message class
+// constants
// ----------------------------------------------------------------------------
@@ -42,4 +46,62 @@
};
+// ----------------------------------------------------------------------------
+// HeaderIterator
+// ----------------------------------------------------------------------------
+
+/**
+ HeaderIterator extracts the individual headers from the full message header
+ and returns them to the caller one by one
+ */
+class HeaderIterator
+{
+public:
+ /**
+ Ctor takes the full message header. Normally it is only used by the
+ Message::GetHeaderIterator() function.
+ */
+ HeaderIterator(const String& header);
+
+ /**
+ Fills the provided name and value pointers with the next header from the
+ message
+
+ @param name is the pointer to the header name, can't be NULL
+ @param value is the pointer which receives the header value and may be NULL
+ @return true if ok, false if no more headers
+ */
+ bool GetNext(String *name, String *value);
+
+ /**
+ Get all headers at once. If a header occurs more than once, its values are
+ concatenated together with "\r\n" separating them.
+
+ @param names the array to return the header names in
+ @param values the array to return the header values in
+ @return the number of headers in the arrays
+ */
+ size_t GetAll(wxArrayString *names, wxArrayString *values);
+
+ /**
+ Resets the iterator so that the next call to GetNext() will return the
+ first header of the message (again).
+ */
+ void Reset();
+
+private:
+ /// the full header
+ String m_header;
+
+ /// temp string which we don't realloc all the time for efficiency
+ String m_str;
+
+ /// the pointer to the current position inside m_header
+ const char *m_pcCurrent;
+};
+
+// ----------------------------------------------------------------------------
+// Message
+// ----------------------------------------------------------------------------
+
/**
Message class represents a message in a mail folder. It provides access to
@@ -58,5 +120,9 @@
/** @name Headers access
*/
+ //@{
+ /**
+ @name Accessing generic headers
+ */
//@{
@@ -84,4 +150,18 @@
/**
+ Return the object which may be used for iterating over the headers.
+
+ @return iterator object
+ */
+ HeaderIterator GetHeaderIterator() const
+ { return HeaderIterator(GetHeader()); }
+
+ /**
+ NB: this method is deprecated because its API is bad and doesn't deal
+ satisfactory with the repeating headers (if some header occurs twice
+ or more the corresponding value will be the concatenation of all of
+ its values which is not always what the caller wants), use
+ HeaderIterator instead of it!
+
Get the names and values of all headers of the message.
@@ -90,6 +170,5 @@
@return the number of headers in the arrays
*/
- virtual size_t GetAllHeaders(wxArrayString *names,
- wxArrayString *values) const = 0;
+ size_t GetAllHeaders(wxArrayString *names, wxArrayString *values) const;
/** Get the complete header text.
@@ -98,8 +177,10 @@
virtual String GetHeader(void) const = 0;
- /** get Subject line
- @return Subject entry
+ //@}
+
+ /**
+ @name Headers containing the addresses
*/
- virtual String Subject(void) const = 0;
+ //@{
/**
@@ -131,4 +212,28 @@
String GetAddressesString(MessageAddressType type) const;
+ /**
+ Get the list of all unique addresses appearing in this message headers
+ (including from, to, reply-to, cc, bcc, ...)
+
+ @param [out] array filled with unique addresses
+ @return the number of addresses retrieved
+ */
+ virtual size_t ExtractAddressesFromHeader(wxArrayString& addresses);
+
+ //@}
+
+ /**
+ @name Special accessors for the common headers
+ */
+ //@{
+
+ /**
+ Get the subject (this is more efficient than GetHeaderLine() as it takes
+ the subject from the envelope)
+
+ @return the subject header value
+ */
+ virtual String Subject(void) const = 0;
+
/** get From line
@return From entry
@@ -155,13 +260,4 @@
virtual String GetNewsgroups() const = 0;
- /**
- Get the list of all unique addresses appearing in this message headers
- (including from, to, reply-to, cc, bcc, ...)
-
- @param [out] array filled with unique addresses
- @return the number of addresses retrieved
- */
- virtual size_t ExtractAddressesFromHeader(wxArrayString& addresses);
-
/** Return the numeric status of message.
@return flags of message (combination of MailFolder::MSG_STAT_XXX flags)
@@ -177,5 +273,7 @@
//@}
- /** @name Accessors
+ //@}
+
+ /** @name Other accessors
*/
@@ -355,5 +453,5 @@
/** @name Address stuff
- THESE FUNCTIONS ARE DEPRECATED, USE Address and AddressList INSTEAD!
+ THESE FUNCTIONS ARE DEPRECATED, USE Address AND AddressList INSTEAD!
*/
//@{
Index: MessageCC.h
===================================================================
RCS file: /cvsroot/mahogany/M/include/MessageCC.h,v
retrieving revision 1.52
retrieving revision 1.53
diff -b -u -2 -r1.52 -r1.53
--- MessageCC.h 11 Jun 2002 20:22:27 -0000 1.52
+++ MessageCC.h 3 Sep 2002 12:28:18 -0000 1.53
@@ -35,7 +35,4 @@
virtual String GetHeader(void) const;
- virtual size_t GetAllHeaders(wxArrayString *names,
- wxArrayString *values) const;
-
/** @name Envelop headers */
//@{
-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone? Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates