27 /*! |
42 /*! |
28 Constructor |
43 Constructor |
29 */ |
44 */ |
30 NmMessage::NmMessage() |
45 NmMessage::NmMessage() |
31 { |
46 { |
|
47 d = new NmMessagePrivate(); |
32 } |
48 } |
33 |
49 |
34 /*! |
50 /*! |
35 Constructs message with id \a id, parent id and mailbox id is set to null id |
51 Constructs message with id \a id, parent id and mailbox id is set to null id |
36 */ |
52 */ |
37 NmMessage::NmMessage(const NmId &id):NmMessagePart(id) |
53 NmMessage::NmMessage(const NmId &messageId) : NmMessagePart(0) |
38 { |
54 { |
39 mEnvelope.setId(id); |
55 d = new NmMessagePrivate(); |
|
56 d->mEnvelope.setMessageId(messageId); |
40 } |
57 } |
41 |
58 |
42 /*! |
59 /*! |
43 Constructs message part with id \a id and with parent id \a parentId, |
60 Constructs message part with id \a id and with parent id \a parentId, |
44 mailbox id is set to null id |
61 mailbox id is set to null id |
45 */ |
62 */ |
46 NmMessage::NmMessage(const NmId &id, const NmId &parentId) |
63 NmMessage::NmMessage(const NmId &messageId, const NmId &folderId) |
47 :NmMessagePart(id, parentId) |
64 : NmMessagePart(0) |
48 { |
65 { |
49 mEnvelope.setId(id); |
66 d = new NmMessagePrivate(); |
|
67 d->mEnvelope.setMessageId(messageId); |
|
68 d->mEnvelope.setFolderId(folderId); |
50 } |
69 } |
51 |
70 |
52 /*! |
71 /*! |
53 Constructs message with id \a id, with parent id \a parentId and |
72 Constructs message with id \a id, with parent id \a parentId and |
54 with mailbox id \a mailboxId |
73 with mailbox id \a mailboxId |
55 */ |
74 */ |
56 NmMessage::NmMessage(const NmId &id, |
75 NmMessage::NmMessage(const NmId &messageId, |
57 const NmId &parentId, |
76 const NmId &folderId, |
58 const NmId &mailboxId) |
77 const NmId &mailboxId) |
59 :NmMessagePart(id, parentId, mailboxId) |
78 :NmMessagePart(0) |
60 { |
79 { |
61 mEnvelope.setId(id); |
80 d = new NmMessagePrivate(); |
62 } |
81 d->mEnvelope.setMessageId(messageId); |
63 |
82 d->mEnvelope.setFolderId(folderId); |
64 /*! |
83 d->mEnvelope.setMailboxId(mailboxId); |
65 Constructs message with meta data |
84 } |
|
85 |
|
86 /*! |
|
87 Constructs message from envelope |
66 */ |
88 */ |
67 NmMessage::NmMessage(const NmMessageEnvelope &envelope) |
89 NmMessage::NmMessage(const NmMessageEnvelope &envelope) |
68 { |
90 { |
69 mEnvelope = envelope; |
91 d = new NmMessagePrivate(); |
70 // set message id same as meta data id |
92 d->mEnvelope = envelope; |
71 this->setId(envelope.id()); |
93 // set message id same as envelope id |
|
94 //this->setMessageId(envelope.messageId()); |
|
95 } |
|
96 |
|
97 /*! |
|
98 Constructs message from envelope and message part private |
|
99 */ |
|
100 NmMessage::NmMessage(const NmMessageEnvelope &envelope, |
|
101 QExplicitlySharedDataPointer<NmMessagePartPrivate> nmPrivateMessagePart) |
|
102 : NmMessagePart(nmPrivateMessagePart) |
|
103 { |
|
104 d = new NmMessagePrivate(); |
|
105 d->mEnvelope = envelope; |
|
106 // set message id same as envelope id |
|
107 //this->setMessageId(envelope.messageId()); |
72 } |
108 } |
73 |
109 |
74 /*! |
110 /*! |
75 Copy constructor |
111 Copy constructor |
76 */ |
112 */ |
77 NmMessage::NmMessage(const NmMessagePart& message):NmMessagePart(message) |
113 NmMessage::NmMessage(const NmMessagePart& message):NmMessagePart(message) |
78 { |
114 { |
79 mEnvelope.setId( message.id() ); |
115 d = new NmMessagePrivate(); |
80 } |
116 } |
81 |
117 |
82 NmMessage::NmMessage(const NmMessage& message):NmMessagePart(message) |
118 NmMessage::NmMessage(const NmMessage& message):NmMessagePart(message), d(message.d) |
83 { |
119 { |
84 mEnvelope.setId( message.id() ); |
|
85 } |
120 } |
86 |
121 |
87 /*! |
122 /*! |
88 Assignment operator |
123 Assignment operator |
89 */ |
124 */ |
90 NmMessage &NmMessage::operator=(const NmMessage &message) |
125 NmMessage &NmMessage::operator=(const NmMessage &message) |
91 { |
126 { |
92 if (this != &message) { |
127 if (this != &message) { |
93 mEnvelope.setId( message.id() ); |
128 d = message.d; |
94 } |
129 } |
95 return *this; |
130 return *this; |
96 } |
131 } |
97 |
132 |
98 /*! |
133 /*! |
101 NmMessage::~NmMessage() |
136 NmMessage::~NmMessage() |
102 { |
137 { |
103 } |
138 } |
104 |
139 |
105 /*! |
140 /*! |
106 returns id of envelope |
|
107 */ |
|
108 NmId NmMessage::id() const |
|
109 { |
|
110 return mEnvelope.id(); |
|
111 } |
|
112 |
|
113 |
|
114 /*! |
|
115 Sets id to envelope |
|
116 */ |
|
117 void NmMessage::setId(const NmId &id) |
|
118 { |
|
119 //NmMessagePart::setId(id); |
|
120 mEnvelope.setId(id); |
|
121 } |
|
122 |
|
123 /*! |
|
124 Returns pointer to plain text body, if plain text body is not found |
141 Returns pointer to plain text body, if plain text body is not found |
125 returns null pointer. Ownership of message part object is not transferred. |
142 returns null pointer. Ownership of message part object is not transferred. |
126 Do not delete returned pointer. Non-modifying version. |
143 Do not delete returned pointer. Non-modifying version. |
127 */ |
144 */ |
128 const NmMessagePart *NmMessage::plainTextBodyPart() const |
145 const NmMessagePart *NmMessage::plainTextBodyPart() const |
167 ret = findContentPart(NmContentTypeTextHtml); |
184 ret = findContentPart(NmContentTypeTextHtml); |
168 return ret; |
185 return ret; |
169 } |
186 } |
170 |
187 |
171 /*! |
188 /*! |
172 Sets message meta data. If meta data id is different than null id, messages |
|
173 id is set to \a envelope's id |
|
174 */ |
|
175 void NmMessage::setEnvelope(const NmMessageEnvelope &envelope) |
|
176 { |
|
177 mEnvelope = envelope; |
|
178 if (envelope.id() != 0) { |
|
179 this->setId(envelope.id()); |
|
180 } else { |
|
181 mEnvelope.setId(this->id()); |
|
182 } |
|
183 } |
|
184 |
|
185 /*! |
|
186 Returns reference to message envelope |
189 Returns reference to message envelope |
187 */ |
190 */ |
188 NmMessageEnvelope &NmMessage::envelope() |
191 NmMessageEnvelope &NmMessage::envelope() |
189 { |
192 { |
190 return mEnvelope; |
193 return d->mEnvelope; |
191 } |
194 } |
192 |
195 |
193 /*! |
196 /*! |
194 Returns reference to message envelope |
197 Returns reference to message envelope |
195 */ |
198 */ |
196 const NmMessageEnvelope &NmMessage::envelope() const |
199 const NmMessageEnvelope &NmMessage::envelope() const |
197 { |
200 { |
198 return mEnvelope; |
201 return d->mEnvelope; |
199 } |
202 } |
200 |
203 |
201 /** |
204 /** |
202 * Returns a flat list of message parts that can be handled as attachments. |
205 * Returns a flat list of message parts that can be handled as attachments. |
203 * Excludes message parts that are multipart and parts that are considered |
206 * Excludes message parts that are multipart and parts that are considered |
219 // find plain text body part from the list |
222 // find plain text body part from the list |
220 const NmMessagePart* txtPart = findContentPart(NmContentTypeTextPlain); |
223 const NmMessagePart* txtPart = findContentPart(NmContentTypeTextPlain); |
221 if ( txtPart ) { |
224 if ( txtPart ) { |
222 // remove plain text body part from attachment list |
225 // remove plain text body part from attachment list |
223 for ( int i = parts.count() - 1; i >= 0; --i ) { |
226 for ( int i = parts.count() - 1; i >= 0; --i ) { |
224 if ( parts.at(i)->id() == txtPart->id() ) { |
227 if ( parts.at(i)->partId() == txtPart->partId() ) { |
225 parts.removeAt(i); |
228 parts.removeAt(i); |
226 break; |
229 break; |
227 } |
230 } |
228 } |
231 } |
229 } |
232 } |
230 // find html body part from the list |
233 // find html body part from the list |
231 const NmMessagePart* htmlPart = findContentPart(NmContentTypeTextHtml); |
234 const NmMessagePart* htmlPart = findContentPart(NmContentTypeTextHtml); |
232 if ( htmlPart ) { |
235 if ( htmlPart ) { |
233 // remove html body part from attachment list |
236 // remove html body part from attachment list |
234 for ( int i = parts.count() - 1; i >= 0; --i ) { |
237 for ( int i = parts.count() - 1; i >= 0; --i ) { |
235 if ( parts.at(i)->id() == htmlPart->id() ) { |
238 if ( parts.at(i)->partId() == htmlPart->partId() ) { |
236 parts.removeAt(i); |
239 parts.removeAt(i); |
237 break; |
240 break; |
238 } |
241 } |
239 } |
242 } |
240 } |
243 } |