Diffstat (limited to 'noncore/net/mail/viewmail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index f00d2cb..156e11d 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -69,40 +69,40 @@ AttachItem* ViewMail::lastChild(AttachItem*parent) | |||
69 | { | 69 | { |
70 | if (!parent) return 0; | 70 | if (!parent) return 0; |
71 | AttachItem* item = (AttachItem*)parent->firstChild(); | 71 | AttachItem* item = (AttachItem*)parent->firstChild(); |
72 | if (!item) return item; | 72 | if (!item) return item; |
73 | AttachItem*temp=0; | 73 | AttachItem*temp=0; |
74 | while( (temp=(AttachItem*)item->nextSibling())) | 74 | while( (temp=(AttachItem*)item->nextSibling())) |
75 | { | 75 | { |
76 | item = temp; | 76 | item = temp; |
77 | } | 77 | } |
78 | return item; | 78 | return item; |
79 | } | 79 | } |
80 | 80 | ||
81 | void ViewMail::setBody( RecBody body ) | 81 | void ViewMail::setBody(const RecBodyP&body ) |
82 | { | 82 | { |
83 | 83 | ||
84 | m_body = body; | 84 | m_body = body; |
85 | m_mail[2] = body.Bodytext(); | 85 | m_mail[2] = body->Bodytext(); |
86 | attachbutton->setEnabled(body.Parts().count()>0); | 86 | attachbutton->setEnabled(body->Parts().count()>0); |
87 | attachments->setEnabled(body.Parts().count()>0); | 87 | attachments->setEnabled(body->Parts().count()>0); |
88 | if (body.Parts().count()==0) | 88 | if (body->Parts().count()==0) |
89 | { | 89 | { |
90 | return; | 90 | return; |
91 | } | 91 | } |
92 | AttachItem * curItem=0; | 92 | AttachItem * curItem=0; |
93 | AttachItem * parentItem = 0; | 93 | AttachItem * parentItem = 0; |
94 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); | 94 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); |
95 | QString desc,fsize; | 95 | QString desc,fsize; |
96 | double s = body.Description().Size(); | 96 | double s = body->Description()->Size(); |
97 | int w; | 97 | int w; |
98 | w=0; | 98 | w=0; |
99 | 99 | ||
100 | while (s>1024) | 100 | while (s>1024) |
101 | { | 101 | { |
102 | s/=1024; | 102 | s/=1024; |
103 | ++w; | 103 | ++w; |
104 | if (w>=2) break; | 104 | if (w>=2) break; |
105 | } | 105 | } |
106 | 106 | ||
107 | QString q=""; | 107 | QString q=""; |
108 | switch(w) | 108 | switch(w) |
@@ -120,77 +120,77 @@ void ViewMail::setBody( RecBody body ) | |||
120 | { | 120 | { |
121 | /* I did not found a method to make a CONTENT reset on a QTextStream | 121 | /* I did not found a method to make a CONTENT reset on a QTextStream |
122 | so I use this construct that the stream will re-constructed in each | 122 | so I use this construct that the stream will re-constructed in each |
123 | loop. To let it work, the textstream is packed into a own area of | 123 | loop. To let it work, the textstream is packed into a own area of |
124 | code is it will be destructed after finishing its small job. | 124 | code is it will be destructed after finishing its small job. |
125 | */ | 125 | */ |
126 | QTextOStream o(&fsize); | 126 | QTextOStream o(&fsize); |
127 | if (w>0) o.precision(2); else o.precision(0); | 127 | if (w>0) o.precision(2); else o.precision(0); |
128 | o.setf(QTextStream::fixed); | 128 | o.setf(QTextStream::fixed); |
129 | o << s << " " << q << "Byte"; | 129 | o << s << " " << q << "Byte"; |
130 | } | 130 | } |
131 | 131 | ||
132 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist()); | 132 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); |
133 | QString filename = ""; | 133 | QString filename = ""; |
134 | 134 | ||
135 | for (unsigned int i = 0; i < body.Parts().count();++i) | 135 | for (unsigned int i = 0; i < body->Parts().count();++i) |
136 | { | 136 | { |
137 | filename = ""; | 137 | filename = ""; |
138 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); | 138 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); |
139 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); | 139 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); |
140 | for (;it!=body.Parts()[i].Parameters().end();++it) | 140 | for (;it!=body->Parts()[i]->Parameters().end();++it) |
141 | { | 141 | { |
142 | qDebug(it.key()); | 142 | qDebug(it.key()); |
143 | if (it.key().lower()=="name") | 143 | if (it.key().lower()=="name") |
144 | { | 144 | { |
145 | filename=it.data(); | 145 | filename=it.data(); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | s = body.Parts()[i].Size(); | 148 | s = body->Parts()[i]->Size(); |
149 | w = 0; | 149 | w = 0; |
150 | while (s>1024) | 150 | while (s>1024) |
151 | { | 151 | { |
152 | s/=1024; | 152 | s/=1024; |
153 | ++w; | 153 | ++w; |
154 | if (w>=2) break; | 154 | if (w>=2) break; |
155 | } | 155 | } |
156 | switch(w) | 156 | switch(w) |
157 | { | 157 | { |
158 | case 1: | 158 | case 1: |
159 | q="k"; | 159 | q="k"; |
160 | break; | 160 | break; |
161 | case 2: | 161 | case 2: |
162 | q="M"; | 162 | q="M"; |
163 | break; | 163 | break; |
164 | default: | 164 | default: |
165 | q=""; | 165 | q=""; |
166 | break; | 166 | break; |
167 | } | 167 | } |
168 | QTextOStream o(&fsize); | 168 | QTextOStream o(&fsize); |
169 | if (w>0) o.precision(2); else o.precision(0); | 169 | if (w>0) o.precision(2); else o.precision(0); |
170 | o.setf(QTextStream::fixed); | 170 | o.setf(QTextStream::fixed); |
171 | o << s << " " << q << "Byte"; | 171 | o << s << " " << q << "Byte"; |
172 | desc = body.Parts()[i].Description(); | 172 | desc = body->Parts()[i]->Description(); |
173 | parentItem = searchParent(body.Parts()[i].Positionlist()); | 173 | parentItem = searchParent(body->Parts()[i]->Positionlist()); |
174 | if (parentItem) | 174 | if (parentItem) |
175 | { | 175 | { |
176 | AttachItem*temp = lastChild(parentItem); | 176 | AttachItem*temp = lastChild(parentItem); |
177 | if (temp) curItem = temp; | 177 | if (temp) curItem = temp; |
178 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); | 178 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
179 | attachments->setRootIsDecorated(true); | 179 | attachments->setRootIsDecorated(true); |
180 | curItem = parentItem; | 180 | curItem = parentItem; |
181 | } | 181 | } |
182 | else | 182 | else |
183 | { | 183 | { |
184 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); | 184 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | 189 | ||
190 | void ViewMail::slotShowHtml( bool state ) | 190 | void ViewMail::slotShowHtml( bool state ) |
191 | { | 191 | { |
192 | m_showHtml = state; | 192 | m_showHtml = state; |
193 | setText(); | 193 | setText(); |
194 | } | 194 | } |
195 | 195 | ||
196 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) | 196 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) |
@@ -217,56 +217,56 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int | |||
217 | 217 | ||
218 | switch(ret) | 218 | switch(ret) |
219 | { | 219 | { |
220 | case 0: | 220 | case 0: |
221 | { | 221 | { |
222 | MimeTypes types; | 222 | MimeTypes types; |
223 | types.insert( "all", "*" ); | 223 | types.insert( "all", "*" ); |
224 | QString str = OFileDialog::getSaveFileName( 1, | 224 | QString str = OFileDialog::getSaveFileName( 1, |
225 | "/", item->text( 2 ) , types, 0 ); | 225 | "/", item->text( 2 ) , types, 0 ); |
226 | 226 | ||
227 | if( !str.isEmpty() ) | 227 | if( !str.isEmpty() ) |
228 | { | 228 | { |
229 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 229 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
230 | if (content) | 230 | if (content) |
231 | { | 231 | { |
232 | QFile output(str); | 232 | QFile output(str); |
233 | output.open(IO_WriteOnly); | 233 | output.open(IO_WriteOnly); |
234 | output.writeBlock(content->Content(),content->Length()); | 234 | output.writeBlock(content->Content(),content->Length()); |
235 | output.close(); | 235 | output.close(); |
236 | delete content; | 236 | delete content; |
237 | } | 237 | } |
238 | } | 238 | } |
239 | } | 239 | } |
240 | break ; | 240 | break ; |
241 | 241 | ||
242 | case 1: | 242 | case 1: |
243 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 243 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
244 | { | 244 | { |
245 | setText(); | 245 | setText(); |
246 | } | 246 | } |
247 | else | 247 | else |
248 | { | 248 | { |
249 | if ( m_recMail->Wrapper() != 0l ) | 249 | if ( m_recMail->Wrapper() != 0l ) |
250 | { // make sure that there is a wrapper , even after delete or simular actions | 250 | { // make sure that there is a wrapper , even after delete or simular actions |
251 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 251 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | break; | 254 | break; |
255 | } | 255 | } |
256 | delete menu; | 256 | delete menu; |
257 | } | 257 | } |
258 | 258 | ||
259 | 259 | ||
260 | void ViewMail::setMail( RecMailP mail ) | 260 | void ViewMail::setMail(const RecMailP&mail ) |
261 | { | 261 | { |
262 | 262 | ||
263 | m_recMail = mail; | 263 | m_recMail = mail; |
264 | 264 | ||
265 | m_mail[0] = mail->getFrom(); | 265 | m_mail[0] = mail->getFrom(); |
266 | m_mail[1] = mail->getSubject(); | 266 | m_mail[1] = mail->getSubject(); |
267 | m_mail[3] = mail->getDate(); | 267 | m_mail[3] = mail->getDate(); |
268 | m_mail[4] = mail->Msgid(); | 268 | m_mail[4] = mail->Msgid(); |
269 | 269 | ||
270 | m_mail2[0] = mail->To(); | 270 | m_mail2[0] = mail->To(); |
271 | m_mail2[1] = mail->CC(); | 271 | m_mail2[1] = mail->CC(); |
272 | m_mail2[2] = mail->Bcc(); | 272 | m_mail2[2] = mail->Bcc(); |