summaryrefslogtreecommitdiffstats
path: root/mimelib/multipar.h
blob: ab9c0d5cb1fdefd52d31ee12f7cadbb231325aa6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//=============================================================================
// File:       multipar.h
// Contents:   Declarations for MultiparBodyPart and MultipartMessage
// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
// WWW:        http://www.fwb.gulf.net/~dwsauder/mimepp.html
// $Revision: 1.5 $
// $Date: 1997/09/27 11:54:11 $
//
// Copyright (c) 1996, 1997 Douglas W. Sauder
// All rights reserved.
// 
// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
//
//=============================================================================

#ifndef MULTIPAR_H
#define MULTIPAR_H

#include "basicmsg.h"


class MultipartBodyPart {

public:

    MultipartBodyPart();
    virtual ~MultipartBodyPart();

    // Get or set the 'Content-Type' header field
    // + The member functions that involve enumerated types (ints)
    //   will work only for well-known types or subtypes.  The enum
    //   values are defined in <mimepp/enum.h>.
    // Type
    const DwString& TypeStr() const;
    int Type() const;
    void SetTypeStr(const DwString& aStr);
    void SetType(int aType);
    // Subtype
    const DwString& SubtypeStr() const;
    int Subtype() const;
    void SetSubtypeStr(const DwString& aStr);
    void SetSubtype(int aSubtype);

    // Get or set the 'Content-Transfer-Encoding' header field
    // + The member functions that involve enumerated types (ints)
    //   will work only for well-known encodings.  The enum values
    //   are defined in <mimepp/enum.h>.
    const DwString& ContentTransferEncodingStr() const;
    int ContentTransferEncoding() const;
    void SetContentTransferEncodingStr(const DwString& aStr);
    void SetContentTransferEncoding(int aCte);

    // Cte is short for ContentTransferEncoding.
    // These functions are an alternative to the ones with longer names.
    const DwString& CteStr() const;
    int Cte() const;
    void SetCteStr(const DwString& aStr);
    void SetCte(int aCte);

    // Get or set the 'Content-Description' header field
    const DwString& ContentDescription() const;
    void SetContentDescription(const DwString& aStr);
    
    // Get or set the 'Content-Disposition' header field
    const DwString& ContentDisposition() const;
    void SetContentDisposition(const DwString& aStr);

    // Get or set the body of this body part
    const DwString& Body() const;
    void SetBody(const DwString& aStr);
    
protected:
    
    DwString mType;
    DwString mSubtype;
    DwString mCte;
    DwString mContentDescription;
    DwString mContentDisposition;
    DwString mBody;

};


class MultipartMessage : public BasicMessage {

public:

    // Use this constructor to create a new multipart message
    MultipartMessage();

    // Use this constructor to create a wrapper for a DwMessage that has
    // been parsed and has been verified as a multipart
    MultipartMessage(DwMessage* aMsg);

    virtual ~MultipartMessage();

    // This virtual function is overridden from BasicMessage.  In
    // MultipartMessage, we add the Content-Type header field with
    // type Multipart and subtype Mixed
    virtual void SetAutomaticFields();

    // Return the number of body parts contained
    int NumberOfParts() const;

    // Get the body part at position in aIdx.  Indexing starts at 0.
    // If there is no body part at that index, aPart will have its
    // attributes set to empty values.
    void BodyPart(int aIdx, MultipartBodyPart& aPart);
    
    // Set the body part at position in aIdx.  Indexing starts at 0.
    // If you have aIdx = 10 and there are only 2 body parts, 7 empty
    // body parts will be created to fill slots 2 through 8.  If you
    // just want to add a body part at the end, use AddBodyPart().
    void SetBodyPart(int aIdx, const MultipartBodyPart& aPart);
    
    // Append a body part to the message.
    void AddBodyPart(const MultipartBodyPart& aPart);

};

#endif