-rw-r--r-- | noncore/net/mail/composemail.cpp | 17 | ||||
-rw-r--r-- | noncore/net/mail/composemail.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.cpp | 13 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.cpp | 29 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 6 |
7 files changed, 61 insertions, 17 deletions
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp index f8ac76f..b5cd75b 100644 --- a/noncore/net/mail/composemail.cpp +++ b/noncore/net/mail/composemail.cpp | |||
@@ -1,240 +1,239 @@ | |||
1 | #include <qt.h> | 1 | #include <qt.h> |
2 | 2 | ||
3 | #include <opie2/ofiledialog.h> | 3 | #include <opie2/ofiledialog.h> |
4 | #include <qpe/resource.h> | 4 | #include <qpe/resource.h> |
5 | #include <qpe/config.h> | 5 | #include <qpe/config.h> |
6 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
7 | #include <qpe/contact.h> | 7 | #include <qpe/contact.h> |
8 | 8 | ||
9 | #include "composemail.h" | 9 | #include "composemail.h" |
10 | 10 | ||
11 | #include <libmailwrapper/smtpwrapper.h> | 11 | #include <libmailwrapper/smtpwrapper.h> |
12 | 12 | ||
13 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) | 13 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) |
14 | : ComposeMailUI( parent, name, modal, flags ) | 14 | : ComposeMailUI( parent, name, modal, flags ) |
15 | { | 15 | { |
16 | settings = s; | 16 | settings = s; |
17 | m_replyid = ""; | ||
17 | 18 | ||
18 | QString vfilename = Global::applicationFileName("addressbook", | 19 | QString vfilename = Global::applicationFileName("addressbook", |
19 | "businesscard.vcf"); | 20 | "businesscard.vcf"); |
20 | Contact c; | 21 | Contact c; |
21 | if (QFile::exists(vfilename)) { | 22 | if (QFile::exists(vfilename)) { |
22 | c = Contact::readVCard( vfilename )[0]; | 23 | c = Contact::readVCard( vfilename )[0]; |
23 | } | 24 | } |
24 | 25 | ||
25 | QStringList mails = c.emailList(); | 26 | QStringList mails = c.emailList(); |
26 | QString defmail = c.defaultEmail(); | 27 | QString defmail = c.defaultEmail(); |
27 | 28 | ||
28 | if (defmail.length()!=0) { | 29 | if (defmail.length()!=0) { |
29 | fromBox->insertItem(defmail); | 30 | fromBox->insertItem(defmail); |
30 | } | 31 | } |
31 | QStringList::ConstIterator sit = mails.begin(); | 32 | QStringList::ConstIterator sit = mails.begin(); |
32 | for (;sit!=mails.end();++sit) { | 33 | for (;sit!=mails.end();++sit) { |
33 | if ( (*sit)==defmail) | 34 | if ( (*sit)==defmail) |
34 | continue; | 35 | continue; |
35 | fromBox->insertItem((*sit)); | 36 | fromBox->insertItem((*sit)); |
36 | } | 37 | } |
37 | senderNameEdit->setText(c.firstName()+" "+c.lastName()); | 38 | senderNameEdit->setText(c.firstName()+" "+c.lastName()); |
38 | Config cfg( "mail" ); | 39 | Config cfg( "mail" ); |
39 | cfg.setGroup( "Compose" ); | 40 | cfg.setGroup( "Compose" ); |
40 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); | 41 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); |
41 | 42 | ||
42 | attList->addColumn( tr( "Name" ) ); | 43 | attList->addColumn( tr( "Name" ) ); |
43 | attList->addColumn( tr( "Size" ) ); | 44 | attList->addColumn( tr( "Size" ) ); |
44 | 45 | ||
45 | QList<Account> accounts = settings->getAccounts(); | 46 | QList<Account> accounts = settings->getAccounts(); |
46 | 47 | ||
47 | Account *it; | 48 | Account *it; |
48 | for ( it = accounts.first(); it; it = accounts.next() ) { | 49 | for ( it = accounts.first(); it; it = accounts.next() ) { |
49 | if ( it->getType()==MAILLIB::A_SMTP ) { | 50 | if ( it->getType()==MAILLIB::A_SMTP ) { |
50 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); | 51 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); |
51 | smtpAccountBox->insertItem( smtp->getAccountName() ); | 52 | smtpAccountBox->insertItem( smtp->getAccountName() ); |
52 | smtpAccounts.append( smtp ); | 53 | smtpAccounts.append( smtp ); |
53 | } | 54 | } |
54 | } | 55 | } |
55 | 56 | ||
56 | if ( smtpAccounts.count() > 0 ) { | 57 | if ( smtpAccounts.count() > 0 ) { |
57 | fillValues( smtpAccountBox->currentItem() ); | 58 | fillValues( smtpAccountBox->currentItem() ); |
58 | } else { | 59 | } else { |
59 | QMessageBox::information( this, tr( "Problem" ), | 60 | QMessageBox::information( this, tr( "Problem" ), |
60 | tr( "<p>Please create an SMTP account first.</p>" ), | 61 | tr( "<p>Please create an SMTP account first.</p>" ), |
61 | tr( "Ok" ) ); | 62 | tr( "Ok" ) ); |
62 | return; | 63 | return; |
63 | } | 64 | } |
64 | 65 | ||
65 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); | 66 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); |
66 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); | 67 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); |
67 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); | 68 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); |
68 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); | 69 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); |
69 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); | 70 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); |
70 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); | 71 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); |
71 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); | 72 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); |
72 | } | 73 | } |
73 | 74 | ||
74 | void ComposeMail::pickAddress( QLineEdit *line ) | 75 | void ComposeMail::pickAddress( QLineEdit *line ) |
75 | { | 76 | { |
76 | QString names = AddressPicker::getNames(); | 77 | QString names = AddressPicker::getNames(); |
77 | if ( line->text().isEmpty() ) { | 78 | if ( line->text().isEmpty() ) { |
78 | line->setText( names ); | 79 | line->setText( names ); |
79 | } else if ( !names.isEmpty() ) { | 80 | } else if ( !names.isEmpty() ) { |
80 | line->setText( line->text() + ", " + names ); | 81 | line->setText( line->text() + ", " + names ); |
81 | } | 82 | } |
82 | } | 83 | } |
83 | 84 | ||
84 | 85 | ||
85 | void ComposeMail::setTo( const QString & to ) | 86 | void ComposeMail::setTo( const QString & to ) |
86 | { | 87 | { |
87 | /* QString toline; | 88 | toLine->setText( to ); |
88 | QStringList toEntry = to; | ||
89 | for ( QStringList::Iterator it = toEntry.begin(); it != toEntry.end(); ++it ) { | ||
90 | toline += (*it); | ||
91 | } | ||
92 | toLine->setText( toline ); | ||
93 | */ | ||
94 | toLine->setText( to ); | ||
95 | } | 89 | } |
96 | 90 | ||
97 | void ComposeMail::setSubject( const QString & subject ) | 91 | void ComposeMail::setSubject( const QString & subject ) |
98 | { | 92 | { |
99 | subjectLine->setText( subject ); | 93 | subjectLine->setText( subject ); |
100 | } | 94 | } |
101 | 95 | ||
102 | void ComposeMail::setInReplyTo( const QString & messageId ) | 96 | void ComposeMail::setInReplyTo( const QString & messageId ) |
103 | { | 97 | { |
104 | 98 | m_replyid = messageId; | |
105 | } | 99 | } |
106 | 100 | ||
107 | void ComposeMail::setMessage( const QString & text ) | 101 | void ComposeMail::setMessage( const QString & text ) |
108 | { | 102 | { |
109 | message->setText( text ); | 103 | message->setText( text ); |
110 | } | 104 | } |
111 | 105 | ||
112 | 106 | ||
113 | void ComposeMail::pickAddressTo() | 107 | void ComposeMail::pickAddressTo() |
114 | { | 108 | { |
115 | pickAddress( toLine ); | 109 | pickAddress( toLine ); |
116 | } | 110 | } |
117 | 111 | ||
118 | void ComposeMail::pickAddressCC() | 112 | void ComposeMail::pickAddressCC() |
119 | { | 113 | { |
120 | pickAddress( ccLine ); | 114 | pickAddress( ccLine ); |
121 | } | 115 | } |
122 | 116 | ||
123 | void ComposeMail::pickAddressBCC() | 117 | void ComposeMail::pickAddressBCC() |
124 | { | 118 | { |
125 | pickAddress( bccLine ); | 119 | pickAddress( bccLine ); |
126 | } | 120 | } |
127 | 121 | ||
128 | void ComposeMail::pickAddressReply() | 122 | void ComposeMail::pickAddressReply() |
129 | { | 123 | { |
130 | pickAddress( replyLine ); | 124 | pickAddress( replyLine ); |
131 | } | 125 | } |
132 | 126 | ||
133 | void ComposeMail::fillValues( int current ) | 127 | void ComposeMail::fillValues( int current ) |
134 | { | 128 | { |
135 | #if 0 | 129 | #if 0 |
136 | SMTPaccount *smtp = smtpAccounts.at( current ); | 130 | SMTPaccount *smtp = smtpAccounts.at( current ); |
137 | ccLine->clear(); | 131 | ccLine->clear(); |
138 | if ( smtp->getUseCC() ) { | 132 | if ( smtp->getUseCC() ) { |
139 | ccLine->setText( smtp->getCC() ); | 133 | ccLine->setText( smtp->getCC() ); |
140 | } | 134 | } |
141 | bccLine->clear(); | 135 | bccLine->clear(); |
142 | if ( smtp->getUseBCC() ) { | 136 | if ( smtp->getUseBCC() ) { |
143 | bccLine->setText( smtp->getBCC() ); | 137 | bccLine->setText( smtp->getBCC() ); |
144 | } | 138 | } |
145 | replyLine->clear(); | 139 | replyLine->clear(); |
146 | if ( smtp->getUseReply() ) { | 140 | if ( smtp->getUseReply() ) { |
147 | replyLine->setText( smtp->getReply() ); | 141 | replyLine->setText( smtp->getReply() ); |
148 | } | 142 | } |
149 | sigMultiLine->setText( smtp->getSignature() ); | 143 | sigMultiLine->setText( smtp->getSignature() ); |
150 | #endif | 144 | #endif |
151 | } | 145 | } |
152 | 146 | ||
153 | void ComposeMail::slotAdjustColumns() | 147 | void ComposeMail::slotAdjustColumns() |
154 | { | 148 | { |
155 | int currPage = tabWidget->currentPageIndex(); | 149 | int currPage = tabWidget->currentPageIndex(); |
156 | 150 | ||
157 | tabWidget->showPage( attachTab ); | 151 | tabWidget->showPage( attachTab ); |
158 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); | 152 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); |
159 | attList->setColumnWidth( 1, 80 ); | 153 | attList->setColumnWidth( 1, 80 ); |
160 | 154 | ||
161 | tabWidget->setCurrentPage( currPage ); | 155 | tabWidget->setCurrentPage( currPage ); |
162 | } | 156 | } |
163 | 157 | ||
164 | void ComposeMail::addAttachment() | 158 | void ComposeMail::addAttachment() |
165 | { | 159 | { |
166 | DocLnk lnk = Opie::OFileDialog::getOpenFileName( 1, "/" ); | 160 | DocLnk lnk = Opie::OFileDialog::getOpenFileName( 1, "/" ); |
167 | if ( !lnk.name().isEmpty() ) { | 161 | if ( !lnk.name().isEmpty() ) { |
168 | Attachment *att = new Attachment( lnk ); | 162 | Attachment *att = new Attachment( lnk ); |
169 | (void) new AttachViewItem( attList, att ); | 163 | (void) new AttachViewItem( attList, att ); |
170 | } | 164 | } |
171 | } | 165 | } |
172 | 166 | ||
173 | void ComposeMail::removeAttachment() | 167 | void ComposeMail::removeAttachment() |
174 | { | 168 | { |
175 | if ( !attList->currentItem() ) { | 169 | if ( !attList->currentItem() ) { |
176 | QMessageBox::information( this, tr( "Error" ), | 170 | QMessageBox::information( this, tr( "Error" ), |
177 | tr( "<p>Please select a File.</p>" ), | 171 | tr( "<p>Please select a File.</p>" ), |
178 | tr( "Ok" ) ); | 172 | tr( "Ok" ) ); |
179 | } else { | 173 | } else { |
180 | attList->takeItem( attList->currentItem() ); | 174 | attList->takeItem( attList->currentItem() ); |
181 | } | 175 | } |
182 | } | 176 | } |
183 | 177 | ||
184 | void ComposeMail::accept() | 178 | void ComposeMail::accept() |
185 | { | 179 | { |
186 | if ( checkBoxLater->isChecked() ) { | 180 | if ( checkBoxLater->isChecked() ) { |
187 | qDebug( "Send later" ); | 181 | qDebug( "Send later" ); |
188 | } | 182 | } |
189 | 183 | ||
190 | #if 0 | 184 | #if 0 |
191 | qDebug( "Sending Mail with " + | 185 | qDebug( "Sending Mail with " + |
192 | smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); | 186 | smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); |
193 | #endif | 187 | #endif |
194 | Mail *mail = new Mail(); | 188 | Mail *mail = new Mail(); |
195 | 189 | ||
196 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); | 190 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); |
197 | mail->setMail(fromBox->currentText()); | 191 | mail->setMail(fromBox->currentText()); |
198 | 192 | ||
199 | if ( !toLine->text().isEmpty() ) { | 193 | if ( !toLine->text().isEmpty() ) { |
200 | mail->setTo( toLine->text() ); | 194 | mail->setTo( toLine->text() ); |
201 | } else { | 195 | } else { |
202 | qDebug( "No Reciever spezified -> returning" ); | 196 | qDebug( "No Reciever spezified -> returning" ); |
203 | return; | 197 | return; |
204 | } | 198 | } |
205 | mail->setName(senderNameEdit->text()); | 199 | mail->setName(senderNameEdit->text()); |
206 | mail->setCC( ccLine->text() ); | 200 | mail->setCC( ccLine->text() ); |
207 | mail->setBCC( bccLine->text() ); | 201 | mail->setBCC( bccLine->text() ); |
208 | mail->setReply( replyLine->text() ); | 202 | mail->setReply( replyLine->text() ); |
209 | mail->setSubject( subjectLine->text() ); | 203 | mail->setSubject( subjectLine->text() ); |
204 | if (!m_replyid.isEmpty()) { | ||
205 | QStringList ids; | ||
206 | ids.append(m_replyid); | ||
207 | mail->setInreply(ids); | ||
208 | } | ||
210 | QString txt = message->text(); | 209 | QString txt = message->text(); |
211 | if ( !sigMultiLine->text().isEmpty() ) { | 210 | if ( !sigMultiLine->text().isEmpty() ) { |
212 | txt.append( "\n--\n" ); | 211 | txt.append( "\n--\n" ); |
213 | txt.append( sigMultiLine->text() ); | 212 | txt.append( sigMultiLine->text() ); |
214 | } | 213 | } |
215 | qDebug(txt); | 214 | qDebug(txt); |
216 | mail->setMessage( txt ); | 215 | mail->setMessage( txt ); |
217 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 216 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
218 | while ( it != NULL ) { | 217 | while ( it != NULL ) { |
219 | mail->addAttachment( it->getAttachment() ); | 218 | mail->addAttachment( it->getAttachment() ); |
220 | it = (AttachViewItem *) it->nextSibling(); | 219 | it = (AttachViewItem *) it->nextSibling(); |
221 | } | 220 | } |
222 | 221 | ||
223 | SMTPwrapper wrapper( smtp ); | 222 | SMTPwrapper wrapper( smtp ); |
224 | wrapper.sendMail( *mail,checkBoxLater->isChecked() ); | 223 | wrapper.sendMail( *mail,checkBoxLater->isChecked() ); |
225 | 224 | ||
226 | QDialog::accept(); | 225 | QDialog::accept(); |
227 | } | 226 | } |
228 | 227 | ||
229 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) | 228 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) |
230 | : QListViewItem( parent ) | 229 | : QListViewItem( parent ) |
231 | { | 230 | { |
232 | attachment = att; | 231 | attachment = att; |
233 | qDebug( att->getMimeType() ); | 232 | qDebug( att->getMimeType() ); |
234 | setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? | 233 | setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? |
235 | Resource::loadPixmap( "UnknownDocument-14" ) : | 234 | Resource::loadPixmap( "UnknownDocument-14" ) : |
236 | attachment->getDocLnk().pixmap() ); | 235 | attachment->getDocLnk().pixmap() ); |
237 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); | 236 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); |
238 | setText( 1, QString::number( att->getSize() ) ); | 237 | setText( 1, QString::number( att->getSize() ) ); |
239 | } | 238 | } |
240 | 239 | ||
diff --git a/noncore/net/mail/composemail.h b/noncore/net/mail/composemail.h index 604c862..886fb1d 100644 --- a/noncore/net/mail/composemail.h +++ b/noncore/net/mail/composemail.h | |||
@@ -1,76 +1,74 @@ | |||
1 | #ifndef COMPOSEMAIL_H | 1 | #ifndef COMPOSEMAIL_H |
2 | #define COMPOSEMAIL_H | 2 | #define COMPOSEMAIL_H |
3 | 3 | ||
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | #include <qlistview.h> | 5 | #include <qlistview.h> |
6 | 6 | ||
7 | #include "composemailui.h" | 7 | #include "composemailui.h" |
8 | #include "addresspickerui.h" | 8 | #include "addresspickerui.h" |
9 | #include <libmailwrapper/settings.h> | 9 | #include <libmailwrapper/settings.h> |
10 | #include <libmailwrapper/mailwrapper.h> | 10 | #include <libmailwrapper/mailwrapper.h> |
11 | 11 | ||
12 | 12 | ||
13 | 13 | ||
14 | class AddressPicker : public AddressPickerUI | 14 | class AddressPicker : public AddressPickerUI |
15 | { | 15 | { |
16 | Q_OBJECT | 16 | Q_OBJECT |
17 | 17 | ||
18 | public: | 18 | public: |
19 | AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); | 19 | AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); |
20 | static QString getNames(); | 20 | static QString getNames(); |
21 | 21 | ||
22 | protected: | 22 | protected: |
23 | QString selectedNames; | 23 | QString selectedNames; |
24 | void accept(); | 24 | void accept(); |
25 | 25 | ||
26 | }; | 26 | }; |
27 | 27 | ||
28 | 28 | ||
29 | class ComposeMail : public ComposeMailUI | 29 | class ComposeMail : public ComposeMailUI |
30 | { | 30 | { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | 32 | ||
33 | public: | 33 | public: |
34 | ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); | 34 | ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); |
35 | 35 | ||
36 | public slots: | 36 | public slots: |
37 | void slotAdjustColumns(); | 37 | void slotAdjustColumns(); |
38 | 38 | ||
39 | void setTo( const QString & to ); | 39 | void setTo( const QString & to ); |
40 | void setSubject( const QString & subject ); | 40 | void setSubject( const QString & subject ); |
41 | void setInReplyTo( const QString & messageId ); | 41 | void setInReplyTo( const QString & messageId ); |
42 | void setMessage( const QString & text ); | 42 | void setMessage( const QString & text ); |
43 | 43 | ||
44 | protected slots: | 44 | protected slots: |
45 | void accept(); | 45 | void accept(); |
46 | 46 | ||
47 | private slots: | 47 | private slots: |
48 | void fillValues( int current ); | 48 | void fillValues( int current ); |
49 | void pickAddress( QLineEdit *line ); | 49 | void pickAddress( QLineEdit *line ); |
50 | void pickAddressTo(); | 50 | void pickAddressTo(); |
51 | void pickAddressCC(); | 51 | void pickAddressCC(); |
52 | void pickAddressBCC(); | 52 | void pickAddressBCC(); |
53 | void pickAddressReply(); | 53 | void pickAddressReply(); |
54 | void addAttachment(); | 54 | void addAttachment(); |
55 | void removeAttachment(); | 55 | void removeAttachment(); |
56 | 56 | ||
57 | 57 | protected: | |
58 | |||
59 | private: | ||
60 | Settings *settings; | 58 | Settings *settings; |
61 | QList<SMTPaccount> smtpAccounts; | 59 | QList<SMTPaccount> smtpAccounts; |
62 | 60 | QString m_replyid; | |
63 | }; | 61 | }; |
64 | 62 | ||
65 | class AttachViewItem : public QListViewItem | 63 | class AttachViewItem : public QListViewItem |
66 | { | 64 | { |
67 | public: | 65 | public: |
68 | AttachViewItem( QListView *parent, Attachment *att ); | 66 | AttachViewItem( QListView *parent, Attachment *att ); |
69 | Attachment *getAttachment() { return attachment; } | 67 | Attachment *getAttachment() { return attachment; } |
70 | 68 | ||
71 | private: | 69 | private: |
72 | Attachment *attachment; | 70 | Attachment *attachment; |
73 | 71 | ||
74 | }; | 72 | }; |
75 | 73 | ||
76 | #endif | 74 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index bf91c63..96e0fd5 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp | |||
@@ -1,344 +1,357 @@ | |||
1 | #include "mailtypes.h" | 1 | #include "mailtypes.h" |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | RecMail::RecMail() | 4 | RecMail::RecMail() |
5 | :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) | 5 | :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) |
6 | { | 6 | { |
7 | init(); | 7 | init(); |
8 | } | 8 | } |
9 | 9 | ||
10 | RecMail::RecMail(const RecMail&old) | 10 | RecMail::RecMail(const RecMail&old) |
11 | :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) | 11 | :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) |
12 | { | 12 | { |
13 | init(); | 13 | init(); |
14 | copy_old(old); | 14 | copy_old(old); |
15 | qDebug("Copy constructor RecMail"); | 15 | qDebug("Copy constructor RecMail"); |
16 | } | 16 | } |
17 | 17 | ||
18 | RecMail::~RecMail() | 18 | RecMail::~RecMail() |
19 | { | 19 | { |
20 | wrapper = 0; | 20 | wrapper = 0; |
21 | } | 21 | } |
22 | 22 | ||
23 | void RecMail::copy_old(const RecMail&old) | 23 | void RecMail::copy_old(const RecMail&old) |
24 | { | 24 | { |
25 | subject = old.subject; | 25 | subject = old.subject; |
26 | date = old.date; | 26 | date = old.date; |
27 | mbox = old.mbox; | 27 | mbox = old.mbox; |
28 | msg_id = old.msg_id; | 28 | msg_id = old.msg_id; |
29 | msg_size = old.msg_size; | 29 | msg_size = old.msg_size; |
30 | msg_number = old.msg_number; | 30 | msg_number = old.msg_number; |
31 | from = old.from; | 31 | from = old.from; |
32 | msg_flags = old.msg_flags; | 32 | msg_flags = old.msg_flags; |
33 | to = old.to; | 33 | to = old.to; |
34 | cc = old.cc; | 34 | cc = old.cc; |
35 | bcc = old.bcc; | 35 | bcc = old.bcc; |
36 | wrapper = old.wrapper; | 36 | wrapper = old.wrapper; |
37 | in_reply_to = old.in_reply_to; | ||
37 | } | 38 | } |
38 | 39 | ||
39 | void RecMail::init() | 40 | void RecMail::init() |
40 | { | 41 | { |
41 | to.clear(); | 42 | to.clear(); |
42 | cc.clear(); | 43 | cc.clear(); |
43 | bcc.clear(); | 44 | bcc.clear(); |
45 | in_reply_to.clear(); | ||
44 | wrapper = 0; | 46 | wrapper = 0; |
45 | } | 47 | } |
46 | 48 | ||
47 | void RecMail::setWrapper(AbstractMail*awrapper) | 49 | void RecMail::setWrapper(AbstractMail*awrapper) |
48 | { | 50 | { |
49 | wrapper = awrapper; | 51 | wrapper = awrapper; |
50 | } | 52 | } |
51 | 53 | ||
52 | AbstractMail* RecMail::Wrapper() | 54 | AbstractMail* RecMail::Wrapper() |
53 | { | 55 | { |
54 | return wrapper; | 56 | return wrapper; |
55 | } | 57 | } |
56 | 58 | ||
57 | void RecMail::setTo(const QStringList&list) | 59 | void RecMail::setTo(const QStringList&list) |
58 | { | 60 | { |
59 | to = list; | 61 | to = list; |
60 | } | 62 | } |
61 | 63 | ||
62 | const QStringList&RecMail::To()const | 64 | const QStringList&RecMail::To()const |
63 | { | 65 | { |
64 | return to; | 66 | return to; |
65 | } | 67 | } |
66 | 68 | ||
67 | void RecMail::setCC(const QStringList&list) | 69 | void RecMail::setCC(const QStringList&list) |
68 | { | 70 | { |
69 | cc = list; | 71 | cc = list; |
70 | } | 72 | } |
71 | 73 | ||
72 | const QStringList&RecMail::CC()const | 74 | const QStringList&RecMail::CC()const |
73 | { | 75 | { |
74 | return cc; | 76 | return cc; |
75 | } | 77 | } |
76 | 78 | ||
77 | void RecMail::setBcc(const QStringList&list) | 79 | void RecMail::setBcc(const QStringList&list) |
78 | { | 80 | { |
79 | bcc = list; | 81 | bcc = list; |
80 | } | 82 | } |
81 | 83 | ||
82 | const QStringList& RecMail::Bcc()const | 84 | const QStringList& RecMail::Bcc()const |
83 | { | 85 | { |
84 | return bcc; | 86 | return bcc; |
85 | } | 87 | } |
86 | 88 | ||
89 | void RecMail::setInreply(const QStringList&list) | ||
90 | { | ||
91 | in_reply_to = list; | ||
92 | } | ||
93 | |||
94 | const QStringList& RecMail::Inreply()const | ||
95 | { | ||
96 | return in_reply_to; | ||
97 | } | ||
98 | |||
99 | |||
87 | RecPart::RecPart() | 100 | RecPart::RecPart() |
88 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) | 101 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) |
89 | { | 102 | { |
90 | m_Parameters.clear(); | 103 | m_Parameters.clear(); |
91 | m_poslist.clear(); | 104 | m_poslist.clear(); |
92 | } | 105 | } |
93 | 106 | ||
94 | RecPart::~RecPart() | 107 | RecPart::~RecPart() |
95 | { | 108 | { |
96 | } | 109 | } |
97 | 110 | ||
98 | void RecPart::setSize(unsigned int size) | 111 | void RecPart::setSize(unsigned int size) |
99 | { | 112 | { |
100 | m_size = size; | 113 | m_size = size; |
101 | } | 114 | } |
102 | 115 | ||
103 | const unsigned int RecPart::Size()const | 116 | const unsigned int RecPart::Size()const |
104 | { | 117 | { |
105 | return m_size; | 118 | return m_size; |
106 | } | 119 | } |
107 | 120 | ||
108 | void RecPart::setLines(unsigned int lines) | 121 | void RecPart::setLines(unsigned int lines) |
109 | { | 122 | { |
110 | m_lines = lines; | 123 | m_lines = lines; |
111 | } | 124 | } |
112 | 125 | ||
113 | const unsigned int RecPart::Lines()const | 126 | const unsigned int RecPart::Lines()const |
114 | { | 127 | { |
115 | return m_lines; | 128 | return m_lines; |
116 | } | 129 | } |
117 | 130 | ||
118 | const QString& RecPart::Type()const | 131 | const QString& RecPart::Type()const |
119 | { | 132 | { |
120 | return m_type; | 133 | return m_type; |
121 | } | 134 | } |
122 | 135 | ||
123 | void RecPart::setType(const QString&type) | 136 | void RecPart::setType(const QString&type) |
124 | { | 137 | { |
125 | m_type = type; | 138 | m_type = type; |
126 | } | 139 | } |
127 | 140 | ||
128 | const QString& RecPart::Subtype()const | 141 | const QString& RecPart::Subtype()const |
129 | { | 142 | { |
130 | return m_subtype; | 143 | return m_subtype; |
131 | } | 144 | } |
132 | 145 | ||
133 | void RecPart::setSubtype(const QString&subtype) | 146 | void RecPart::setSubtype(const QString&subtype) |
134 | { | 147 | { |
135 | m_subtype = subtype; | 148 | m_subtype = subtype; |
136 | } | 149 | } |
137 | 150 | ||
138 | const QString& RecPart::Identifier()const | 151 | const QString& RecPart::Identifier()const |
139 | { | 152 | { |
140 | return m_identifier; | 153 | return m_identifier; |
141 | } | 154 | } |
142 | 155 | ||
143 | void RecPart::setIdentifier(const QString&identifier) | 156 | void RecPart::setIdentifier(const QString&identifier) |
144 | { | 157 | { |
145 | m_identifier = identifier; | 158 | m_identifier = identifier; |
146 | } | 159 | } |
147 | 160 | ||
148 | const QString& RecPart::Encoding()const | 161 | const QString& RecPart::Encoding()const |
149 | { | 162 | { |
150 | return m_encoding; | 163 | return m_encoding; |
151 | } | 164 | } |
152 | 165 | ||
153 | void RecPart::setEncoding(const QString&encoding) | 166 | void RecPart::setEncoding(const QString&encoding) |
154 | { | 167 | { |
155 | m_encoding = encoding; | 168 | m_encoding = encoding; |
156 | } | 169 | } |
157 | 170 | ||
158 | const QString& RecPart::Description()const | 171 | const QString& RecPart::Description()const |
159 | { | 172 | { |
160 | return m_description; | 173 | return m_description; |
161 | } | 174 | } |
162 | 175 | ||
163 | void RecPart::setDescription(const QString&desc) | 176 | void RecPart::setDescription(const QString&desc) |
164 | { | 177 | { |
165 | m_description = desc; | 178 | m_description = desc; |
166 | } | 179 | } |
167 | 180 | ||
168 | void RecPart::setParameters(const part_plist_t&list) | 181 | void RecPart::setParameters(const part_plist_t&list) |
169 | { | 182 | { |
170 | m_Parameters = list; | 183 | m_Parameters = list; |
171 | } | 184 | } |
172 | 185 | ||
173 | const part_plist_t& RecPart::Parameters()const | 186 | const part_plist_t& RecPart::Parameters()const |
174 | { | 187 | { |
175 | return m_Parameters; | 188 | return m_Parameters; |
176 | } | 189 | } |
177 | 190 | ||
178 | void RecPart::addParameter(const QString&key,const QString&value) | 191 | void RecPart::addParameter(const QString&key,const QString&value) |
179 | { | 192 | { |
180 | m_Parameters[key]=value; | 193 | m_Parameters[key]=value; |
181 | } | 194 | } |
182 | 195 | ||
183 | const QString RecPart::searchParamter(const QString&key)const | 196 | const QString RecPart::searchParamter(const QString&key)const |
184 | { | 197 | { |
185 | QString value(""); | 198 | QString value(""); |
186 | part_plist_t::ConstIterator it = m_Parameters.find(key); | 199 | part_plist_t::ConstIterator it = m_Parameters.find(key); |
187 | if (it != m_Parameters.end()) { | 200 | if (it != m_Parameters.end()) { |
188 | value = it.data(); | 201 | value = it.data(); |
189 | } | 202 | } |
190 | return value; | 203 | return value; |
191 | } | 204 | } |
192 | 205 | ||
193 | void RecPart::setPositionlist(const QValueList<int>&poslist) | 206 | void RecPart::setPositionlist(const QValueList<int>&poslist) |
194 | { | 207 | { |
195 | m_poslist = poslist; | 208 | m_poslist = poslist; |
196 | } | 209 | } |
197 | 210 | ||
198 | const QValueList<int>& RecPart::Positionlist()const | 211 | const QValueList<int>& RecPart::Positionlist()const |
199 | { | 212 | { |
200 | return m_poslist; | 213 | return m_poslist; |
201 | } | 214 | } |
202 | 215 | ||
203 | RecBody::RecBody() | 216 | RecBody::RecBody() |
204 | : m_BodyText(),m_PartsList(),m_description() | 217 | : m_BodyText(),m_PartsList(),m_description() |
205 | { | 218 | { |
206 | m_PartsList.clear(); | 219 | m_PartsList.clear(); |
207 | } | 220 | } |
208 | 221 | ||
209 | RecBody::~RecBody() | 222 | RecBody::~RecBody() |
210 | { | 223 | { |
211 | } | 224 | } |
212 | 225 | ||
213 | void RecBody::setBodytext(const QString&bodyText) | 226 | void RecBody::setBodytext(const QString&bodyText) |
214 | { | 227 | { |
215 | m_BodyText = bodyText; | 228 | m_BodyText = bodyText; |
216 | } | 229 | } |
217 | 230 | ||
218 | const QString& RecBody::Bodytext()const | 231 | const QString& RecBody::Bodytext()const |
219 | { | 232 | { |
220 | return m_BodyText; | 233 | return m_BodyText; |
221 | } | 234 | } |
222 | 235 | ||
223 | void RecBody::setParts(const QValueList<RecPart>&parts) | 236 | void RecBody::setParts(const QValueList<RecPart>&parts) |
224 | { | 237 | { |
225 | m_PartsList.clear(); | 238 | m_PartsList.clear(); |
226 | m_PartsList = parts; | 239 | m_PartsList = parts; |
227 | } | 240 | } |
228 | 241 | ||
229 | const QValueList<RecPart>& RecBody::Parts()const | 242 | const QValueList<RecPart>& RecBody::Parts()const |
230 | { | 243 | { |
231 | return m_PartsList; | 244 | return m_PartsList; |
232 | } | 245 | } |
233 | 246 | ||
234 | void RecBody::addPart(const RecPart& part) | 247 | void RecBody::addPart(const RecPart& part) |
235 | { | 248 | { |
236 | m_PartsList.append(part); | 249 | m_PartsList.append(part); |
237 | } | 250 | } |
238 | 251 | ||
239 | void RecBody::setDescription(const RecPart&des) | 252 | void RecBody::setDescription(const RecPart&des) |
240 | { | 253 | { |
241 | m_description = des; | 254 | m_description = des; |
242 | } | 255 | } |
243 | 256 | ||
244 | const RecPart& RecBody::Description()const | 257 | const RecPart& RecBody::Description()const |
245 | { | 258 | { |
246 | return m_description; | 259 | return m_description; |
247 | } | 260 | } |
248 | 261 | ||
249 | /* handling encoded content */ | 262 | /* handling encoded content */ |
250 | encodedString::encodedString() | 263 | encodedString::encodedString() |
251 | { | 264 | { |
252 | init(); | 265 | init(); |
253 | } | 266 | } |
254 | 267 | ||
255 | encodedString::encodedString(const char*nContent,unsigned int nSize) | 268 | encodedString::encodedString(const char*nContent,unsigned int nSize) |
256 | { | 269 | { |
257 | init(); | 270 | init(); |
258 | setContent(nContent,nSize); | 271 | setContent(nContent,nSize); |
259 | } | 272 | } |
260 | 273 | ||
261 | encodedString::encodedString(char*nContent,unsigned int nSize) | 274 | encodedString::encodedString(char*nContent,unsigned int nSize) |
262 | { | 275 | { |
263 | init(); | 276 | init(); |
264 | setContent(nContent,nSize); | 277 | setContent(nContent,nSize); |
265 | } | 278 | } |
266 | 279 | ||
267 | encodedString::encodedString(const encodedString&old) | 280 | encodedString::encodedString(const encodedString&old) |
268 | { | 281 | { |
269 | init(); | 282 | init(); |
270 | copy_old(old); | 283 | copy_old(old); |
271 | qDebug("encodedeString: copy constructor!"); | 284 | qDebug("encodedeString: copy constructor!"); |
272 | } | 285 | } |
273 | 286 | ||
274 | encodedString& encodedString::operator=(const encodedString&old) | 287 | encodedString& encodedString::operator=(const encodedString&old) |
275 | { | 288 | { |
276 | init(); | 289 | init(); |
277 | copy_old(old); | 290 | copy_old(old); |
278 | qDebug("encodedString: assign operator!"); | 291 | qDebug("encodedString: assign operator!"); |
279 | return *this; | 292 | return *this; |
280 | } | 293 | } |
281 | 294 | ||
282 | encodedString::~encodedString() | 295 | encodedString::~encodedString() |
283 | { | 296 | { |
284 | clean(); | 297 | clean(); |
285 | } | 298 | } |
286 | 299 | ||
287 | void encodedString::init() | 300 | void encodedString::init() |
288 | { | 301 | { |
289 | content = 0; | 302 | content = 0; |
290 | size = 0; | 303 | size = 0; |
291 | } | 304 | } |
292 | 305 | ||
293 | void encodedString::clean() | 306 | void encodedString::clean() |
294 | { | 307 | { |
295 | if (content) { | 308 | if (content) { |
296 | free(content); | 309 | free(content); |
297 | } | 310 | } |
298 | content = 0; | 311 | content = 0; |
299 | size = 0; | 312 | size = 0; |
300 | } | 313 | } |
301 | 314 | ||
302 | void encodedString::copy_old(const encodedString&old) | 315 | void encodedString::copy_old(const encodedString&old) |
303 | { | 316 | { |
304 | clean(); | 317 | clean(); |
305 | if (old.size>0 && old.content) { | 318 | if (old.size>0 && old.content) { |
306 | content = (char*)malloc(old.size*sizeof(char)); | 319 | content = (char*)malloc(old.size*sizeof(char)); |
307 | memcpy(content,old.content,size); | 320 | memcpy(content,old.content,size); |
308 | size = old.size; | 321 | size = old.size; |
309 | } | 322 | } |
310 | } | 323 | } |
311 | 324 | ||
312 | const char*encodedString::Content()const | 325 | const char*encodedString::Content()const |
313 | { | 326 | { |
314 | return content; | 327 | return content; |
315 | } | 328 | } |
316 | 329 | ||
317 | const int encodedString::Length()const | 330 | const int encodedString::Length()const |
318 | { | 331 | { |
319 | return size; | 332 | return size; |
320 | } | 333 | } |
321 | 334 | ||
322 | void encodedString::setContent(const char*nContent,int nSize) | 335 | void encodedString::setContent(const char*nContent,int nSize) |
323 | { | 336 | { |
324 | if (nSize>0 && nContent) { | 337 | if (nSize>0 && nContent) { |
325 | content = (char*)malloc(nSize*sizeof(char)); | 338 | content = (char*)malloc(nSize*sizeof(char)); |
326 | memcpy(content,nContent,nSize); | 339 | memcpy(content,nContent,nSize); |
327 | size = nSize; | 340 | size = nSize; |
328 | } | 341 | } |
329 | } | 342 | } |
330 | 343 | ||
331 | void encodedString::setContent(char*nContent,int nSize) | 344 | void encodedString::setContent(char*nContent,int nSize) |
332 | { | 345 | { |
333 | content = nContent; | 346 | content = nContent; |
334 | size = nSize; | 347 | size = nSize; |
335 | } | 348 | } |
336 | 349 | ||
337 | folderStat&folderStat::operator=(const folderStat&old) | 350 | folderStat&folderStat::operator=(const folderStat&old) |
338 | { | 351 | { |
339 | message_count = old.message_count; | 352 | message_count = old.message_count; |
340 | message_unseen = old.message_unseen; | 353 | message_unseen = old.message_unseen; |
341 | message_recent = old.message_recent; | 354 | message_recent = old.message_recent; |
342 | return *this; | 355 | return *this; |
343 | } | 356 | } |
344 | 357 | ||
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index b2047cb..1420f79 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h | |||
@@ -1,193 +1,195 @@ | |||
1 | #ifndef __MAIL_TYPES_H | 1 | #ifndef __MAIL_TYPES_H |
2 | #define __MAIL_TYPES_H | 2 | #define __MAIL_TYPES_H |
3 | 3 | ||
4 | #define FLAG_ANSWERED 0 | 4 | #define FLAG_ANSWERED 0 |
5 | #define FLAG_FLAGGED 1 | 5 | #define FLAG_FLAGGED 1 |
6 | #define FLAG_DELETED 2 | 6 | #define FLAG_DELETED 2 |
7 | #define FLAG_SEEN 3 | 7 | #define FLAG_SEEN 3 |
8 | #define FLAG_DRAFT 4 | 8 | #define FLAG_DRAFT 4 |
9 | #define FLAG_RECENT 5 | 9 | #define FLAG_RECENT 5 |
10 | 10 | ||
11 | #include <qlist.h> | 11 | #include <qlist.h> |
12 | #include <qbitarray.h> | 12 | #include <qbitarray.h> |
13 | #include <qstring.h> | 13 | #include <qstring.h> |
14 | #include <qstringlist.h> | 14 | #include <qstringlist.h> |
15 | #include <qmap.h> | 15 | #include <qmap.h> |
16 | #include <qvaluelist.h> | 16 | #include <qvaluelist.h> |
17 | 17 | ||
18 | class AbstractMail; | 18 | class AbstractMail; |
19 | /* a class to describe mails in a mailbox */ | 19 | /* a class to describe mails in a mailbox */ |
20 | /* Attention! | 20 | /* Attention! |
21 | From programmers point of view it would make sense to | 21 | From programmers point of view it would make sense to |
22 | store the mail body into this class, too. | 22 | store the mail body into this class, too. |
23 | But: not from the point of view of the device. | 23 | But: not from the point of view of the device. |
24 | Mailbodies can be real large. So we request them when | 24 | Mailbodies can be real large. So we request them when |
25 | needed from the mail-wrapper class direct from the server itself | 25 | needed from the mail-wrapper class direct from the server itself |
26 | (imap) or from a file-based cache (pop3?) | 26 | (imap) or from a file-based cache (pop3?) |
27 | So there is no interface "const QString&body()" but you should | 27 | So there is no interface "const QString&body()" but you should |
28 | make a request to the mailwrapper with this class as parameter to | 28 | make a request to the mailwrapper with this class as parameter to |
29 | get the body. Same words for the attachments. | 29 | get the body. Same words for the attachments. |
30 | */ | 30 | */ |
31 | class RecMail | 31 | class RecMail |
32 | { | 32 | { |
33 | public: | 33 | public: |
34 | RecMail(); | 34 | RecMail(); |
35 | RecMail(const RecMail&old); | 35 | RecMail(const RecMail&old); |
36 | virtual ~RecMail(); | 36 | virtual ~RecMail(); |
37 | 37 | ||
38 | const int getNumber()const{return msg_number;} | 38 | const int getNumber()const{return msg_number;} |
39 | void setNumber(int number){msg_number=number;} | 39 | void setNumber(int number){msg_number=number;} |
40 | const QString&getDate()const{ return date; } | 40 | const QString&getDate()const{ return date; } |
41 | void setDate( const QString&a ) { date = a; } | 41 | void setDate( const QString&a ) { date = a; } |
42 | const QString&getFrom()const{ return from; } | 42 | const QString&getFrom()const{ return from; } |
43 | void setFrom( const QString&a ) { from = a; } | 43 | void setFrom( const QString&a ) { from = a; } |
44 | const QString&getSubject()const { return subject; } | 44 | const QString&getSubject()const { return subject; } |
45 | void setSubject( const QString&s ) { subject = s; } | 45 | void setSubject( const QString&s ) { subject = s; } |
46 | const QString&getMbox()const{return mbox;} | 46 | const QString&getMbox()const{return mbox;} |
47 | void setMbox(const QString&box){mbox = box;} | 47 | void setMbox(const QString&box){mbox = box;} |
48 | void setMsgid(const QString&id){msg_id=id;} | 48 | void setMsgid(const QString&id){msg_id=id;} |
49 | const QString&Msgid()const{return msg_id;} | 49 | const QString&Msgid()const{return msg_id;} |
50 | void setReplyto(const QString&reply){replyto=reply;} | 50 | void setReplyto(const QString&reply){replyto=reply;} |
51 | const QString&Replyto()const{return replyto;} | 51 | const QString&Replyto()const{return replyto;} |
52 | void setMsgsize(int size){msg_size = size;} | 52 | void setMsgsize(int size){msg_size = size;} |
53 | const int Msgsize()const{return msg_size;} | 53 | const int Msgsize()const{return msg_size;} |
54 | 54 | ||
55 | 55 | ||
56 | void setTo(const QStringList&list); | 56 | void setTo(const QStringList&list); |
57 | const QStringList&To()const; | 57 | const QStringList&To()const; |
58 | void setCC(const QStringList&list); | 58 | void setCC(const QStringList&list); |
59 | const QStringList&CC()const; | 59 | const QStringList&CC()const; |
60 | void setBcc(const QStringList&list); | 60 | void setBcc(const QStringList&list); |
61 | const QStringList&Bcc()const; | 61 | const QStringList&Bcc()const; |
62 | void setInreply(const QStringList&list); | ||
63 | const QStringList&Inreply()const; | ||
62 | const QBitArray&getFlags()const{return msg_flags;} | 64 | const QBitArray&getFlags()const{return msg_flags;} |
63 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 65 | void setFlags(const QBitArray&flags){msg_flags = flags;} |
64 | 66 | ||
65 | void setWrapper(AbstractMail*wrapper); | 67 | void setWrapper(AbstractMail*wrapper); |
66 | AbstractMail* Wrapper(); | 68 | AbstractMail* Wrapper(); |
67 | 69 | ||
68 | protected: | 70 | protected: |
69 | QString subject,date,from,mbox,msg_id,replyto; | 71 | QString subject,date,from,mbox,msg_id,replyto; |
70 | int msg_number,msg_size; | 72 | int msg_number,msg_size; |
71 | QBitArray msg_flags; | 73 | QBitArray msg_flags; |
72 | QStringList to,cc,bcc; | 74 | QStringList to,cc,bcc,in_reply_to; |
73 | AbstractMail*wrapper; | 75 | AbstractMail*wrapper; |
74 | void init(); | 76 | void init(); |
75 | void copy_old(const RecMail&old); | 77 | void copy_old(const RecMail&old); |
76 | }; | 78 | }; |
77 | 79 | ||
78 | typedef QMap<QString,QString> part_plist_t; | 80 | typedef QMap<QString,QString> part_plist_t; |
79 | 81 | ||
80 | class RecPart | 82 | class RecPart |
81 | { | 83 | { |
82 | protected: | 84 | protected: |
83 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; | 85 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; |
84 | unsigned int m_lines,m_size; | 86 | unsigned int m_lines,m_size; |
85 | part_plist_t m_Parameters; | 87 | part_plist_t m_Parameters; |
86 | /* describes the position in the mail */ | 88 | /* describes the position in the mail */ |
87 | QValueList<int> m_poslist; | 89 | QValueList<int> m_poslist; |
88 | 90 | ||
89 | public: | 91 | public: |
90 | RecPart(); | 92 | RecPart(); |
91 | virtual ~RecPart(); | 93 | virtual ~RecPart(); |
92 | 94 | ||
93 | const QString&Type()const; | 95 | const QString&Type()const; |
94 | void setType(const QString&type); | 96 | void setType(const QString&type); |
95 | const QString&Subtype()const; | 97 | const QString&Subtype()const; |
96 | void setSubtype(const QString&subtype); | 98 | void setSubtype(const QString&subtype); |
97 | const QString&Identifier()const; | 99 | const QString&Identifier()const; |
98 | void setIdentifier(const QString&identifier); | 100 | void setIdentifier(const QString&identifier); |
99 | const QString&Encoding()const; | 101 | const QString&Encoding()const; |
100 | void setEncoding(const QString&encoding); | 102 | void setEncoding(const QString&encoding); |
101 | const QString&Description()const; | 103 | const QString&Description()const; |
102 | void setDescription(const QString&desc); | 104 | void setDescription(const QString&desc); |
103 | void setLines(unsigned int lines); | 105 | void setLines(unsigned int lines); |
104 | const unsigned int Lines()const; | 106 | const unsigned int Lines()const; |
105 | void setSize(unsigned int size); | 107 | void setSize(unsigned int size); |
106 | const unsigned int Size()const; | 108 | const unsigned int Size()const; |
107 | 109 | ||
108 | 110 | ||
109 | void setParameters(const part_plist_t&list); | 111 | void setParameters(const part_plist_t&list); |
110 | const part_plist_t&Parameters()const; | 112 | const part_plist_t&Parameters()const; |
111 | void addParameter(const QString&key,const QString&value); | 113 | void addParameter(const QString&key,const QString&value); |
112 | const QString searchParamter(const QString&key)const; | 114 | const QString searchParamter(const QString&key)const; |
113 | void setPositionlist(const QValueList<int>&poslist); | 115 | void setPositionlist(const QValueList<int>&poslist); |
114 | const QValueList<int>& Positionlist()const; | 116 | const QValueList<int>& Positionlist()const; |
115 | }; | 117 | }; |
116 | 118 | ||
117 | class RecBody | 119 | class RecBody |
118 | { | 120 | { |
119 | protected: | 121 | protected: |
120 | QString m_BodyText; | 122 | QString m_BodyText; |
121 | QValueList<RecPart> m_PartsList; | 123 | QValueList<RecPart> m_PartsList; |
122 | RecPart m_description; | 124 | RecPart m_description; |
123 | 125 | ||
124 | public: | 126 | public: |
125 | RecBody(); | 127 | RecBody(); |
126 | virtual ~RecBody(); | 128 | virtual ~RecBody(); |
127 | void setBodytext(const QString&); | 129 | void setBodytext(const QString&); |
128 | const QString& Bodytext()const; | 130 | const QString& Bodytext()const; |
129 | 131 | ||
130 | void setDescription(const RecPart&des); | 132 | void setDescription(const RecPart&des); |
131 | const RecPart& Description()const; | 133 | const RecPart& Description()const; |
132 | 134 | ||
133 | void setParts(const QValueList<RecPart>&parts); | 135 | void setParts(const QValueList<RecPart>&parts); |
134 | const QValueList<RecPart>& Parts()const; | 136 | const QValueList<RecPart>& Parts()const; |
135 | void addPart(const RecPart&part); | 137 | void addPart(const RecPart&part); |
136 | }; | 138 | }; |
137 | 139 | ||
138 | class encodedString | 140 | class encodedString |
139 | { | 141 | { |
140 | public: | 142 | public: |
141 | encodedString(); | 143 | encodedString(); |
142 | /* | 144 | /* |
143 | creates an new content string. | 145 | creates an new content string. |
144 | it makes a deep copy of it! | 146 | it makes a deep copy of it! |
145 | */ | 147 | */ |
146 | encodedString(const char*nContent,unsigned int length); | 148 | encodedString(const char*nContent,unsigned int length); |
147 | /* | 149 | /* |
148 | Take over the nContent. Means: it will just copy the pointer, not the content. | 150 | Take over the nContent. Means: it will just copy the pointer, not the content. |
149 | so make sure: No one else frees the string, the string has allocated with | 151 | so make sure: No one else frees the string, the string has allocated with |
150 | malloc for compatibility with c-based libs | 152 | malloc for compatibility with c-based libs |
151 | */ | 153 | */ |
152 | encodedString(char*nContent,unsigned int nSize); | 154 | encodedString(char*nContent,unsigned int nSize); |
153 | /* copy construkor - makes ALWAYS a deep copy!!!! */ | 155 | /* copy construkor - makes ALWAYS a deep copy!!!! */ |
154 | encodedString(const encodedString&old); | 156 | encodedString(const encodedString&old); |
155 | /* assign operator - makes ALWAYS a deep copy!!!! */ | 157 | /* assign operator - makes ALWAYS a deep copy!!!! */ |
156 | encodedString& operator=(const encodedString&old); | 158 | encodedString& operator=(const encodedString&old); |
157 | /* destructor - cleans the content */ | 159 | /* destructor - cleans the content */ |
158 | virtual ~encodedString(); | 160 | virtual ~encodedString(); |
159 | 161 | ||
160 | /* returns a pointer to the content - do not delete yoursel! */ | 162 | /* returns a pointer to the content - do not delete yoursel! */ |
161 | const char*Content()const; | 163 | const char*Content()const; |
162 | /* returns the lengths of the content 'cause it must not be a null-terminated string! */ | 164 | /* returns the lengths of the content 'cause it must not be a null-terminated string! */ |
163 | const int Length()const; | 165 | const int Length()const; |
164 | 166 | ||
165 | /* | 167 | /* |
166 | makes a deep copy of nContent! | 168 | makes a deep copy of nContent! |
167 | */ | 169 | */ |
168 | void setContent(const char*nContent,int nSize); | 170 | void setContent(const char*nContent,int nSize); |
169 | /* | 171 | /* |
170 | Take over the nContent. Means: it will just copy the pointer, not the content. | 172 | Take over the nContent. Means: it will just copy the pointer, not the content. |
171 | so make sure: No one else frees the string, the string has allocated with | 173 | so make sure: No one else frees the string, the string has allocated with |
172 | malloc for compatibility with c-based libs | 174 | malloc for compatibility with c-based libs |
173 | */ | 175 | */ |
174 | void setContent(char*nContent,int nSize); | 176 | void setContent(char*nContent,int nSize); |
175 | 177 | ||
176 | protected: | 178 | protected: |
177 | char * content; | 179 | char * content; |
178 | unsigned int size; | 180 | unsigned int size; |
179 | 181 | ||
180 | void init(); | 182 | void init(); |
181 | void copy_old(const encodedString&old); | 183 | void copy_old(const encodedString&old); |
182 | void clean(); | 184 | void clean(); |
183 | }; | 185 | }; |
184 | 186 | ||
185 | struct folderStat | 187 | struct folderStat |
186 | { | 188 | { |
187 | unsigned int message_count; | 189 | unsigned int message_count; |
188 | unsigned int message_unseen; | 190 | unsigned int message_unseen; |
189 | unsigned int message_recent; | 191 | unsigned int message_recent; |
190 | folderStat&operator=(const folderStat&old); | 192 | folderStat&operator=(const folderStat&old); |
191 | }; | 193 | }; |
192 | 194 | ||
193 | #endif | 195 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h index caaa3a2..3a9f97b 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.h +++ b/noncore/net/mail/libmailwrapper/mailwrapper.h | |||
@@ -1,99 +1,102 @@ | |||
1 | #ifndef MAILWRAPPER_H | 1 | #ifndef MAILWRAPPER_H |
2 | #define MAILWRAPPER_H | 2 | #define MAILWRAPPER_H |
3 | 3 | ||
4 | #include <qpe/applnk.h> | 4 | #include <qpe/applnk.h> |
5 | 5 | ||
6 | #include <qbitarray.h> | 6 | #include <qbitarray.h> |
7 | #include <qdatetime.h> | 7 | #include <qdatetime.h> |
8 | 8 | ||
9 | #include "settings.h" | 9 | #include "settings.h" |
10 | 10 | ||
11 | class Attachment | 11 | class Attachment |
12 | { | 12 | { |
13 | public: | 13 | public: |
14 | Attachment( DocLnk lnk ); | 14 | Attachment( DocLnk lnk ); |
15 | virtual ~Attachment(){} | 15 | virtual ~Attachment(){} |
16 | const QString getFileName()const{ return doc.file(); } | 16 | const QString getFileName()const{ return doc.file(); } |
17 | const QString getName()const{ return doc.name(); } | 17 | const QString getName()const{ return doc.name(); } |
18 | const QString getMimeType()const{ return doc.type(); } | 18 | const QString getMimeType()const{ return doc.type(); } |
19 | const QPixmap getPixmap()const{ return doc.pixmap(); } | 19 | const QPixmap getPixmap()const{ return doc.pixmap(); } |
20 | const int getSize()const { return size; } | 20 | const int getSize()const { return size; } |
21 | DocLnk getDocLnk() { return doc; } | 21 | DocLnk getDocLnk() { return doc; } |
22 | 22 | ||
23 | protected: | 23 | protected: |
24 | DocLnk doc; | 24 | DocLnk doc; |
25 | int size; | 25 | int size; |
26 | 26 | ||
27 | }; | 27 | }; |
28 | 28 | ||
29 | class Mail | 29 | class Mail |
30 | { | 30 | { |
31 | public: | 31 | public: |
32 | Mail(); | 32 | Mail(); |
33 | /* Possible that this destructor must not be declared virtual | 33 | /* Possible that this destructor must not be declared virtual |
34 | * 'cause it seems that it will never have some child classes. | 34 | * 'cause it seems that it will never have some child classes. |
35 | * in this case this object will not get a virtual table -> memory and | 35 | * in this case this object will not get a virtual table -> memory and |
36 | * speed will be a little bit better? | 36 | * speed will be a little bit better? |
37 | */ | 37 | */ |
38 | virtual ~Mail(){} | 38 | virtual ~Mail(){} |
39 | void addAttachment( Attachment *att ) { attList.append( att ); } | 39 | void addAttachment( Attachment *att ) { attList.append( att ); } |
40 | const QList<Attachment>& getAttachments()const { return attList; } | 40 | const QList<Attachment>& getAttachments()const { return attList; } |
41 | void removeAttachment( Attachment *att ) { attList.remove( att ); } | 41 | void removeAttachment( Attachment *att ) { attList.remove( att ); } |
42 | const QString&getName()const { return name; } | 42 | const QString&getName()const { return name; } |
43 | void setName( QString s ) { name = s; } | 43 | void setName( QString s ) { name = s; } |
44 | const QString&getMail()const{ return mail; } | 44 | const QString&getMail()const{ return mail; } |
45 | void setMail( const QString&s ) { mail = s; } | 45 | void setMail( const QString&s ) { mail = s; } |
46 | const QString&getTo()const{ return to; } | 46 | const QString&getTo()const{ return to; } |
47 | void setTo( const QString&s ) { to = s; } | 47 | void setTo( const QString&s ) { to = s; } |
48 | const QString&getCC()const{ return cc; } | 48 | const QString&getCC()const{ return cc; } |
49 | void setCC( const QString&s ) { cc = s; } | 49 | void setCC( const QString&s ) { cc = s; } |
50 | const QString&getBCC()const { return bcc; } | 50 | const QString&getBCC()const { return bcc; } |
51 | void setBCC( const QString&s ) { bcc = s; } | 51 | void setBCC( const QString&s ) { bcc = s; } |
52 | const QString&getMessage()const { return message; } | 52 | const QString&getMessage()const { return message; } |
53 | void setMessage( const QString&s ) { message = s; } | 53 | void setMessage( const QString&s ) { message = s; } |
54 | const QString&getSubject()const { return subject; } | 54 | const QString&getSubject()const { return subject; } |
55 | void setSubject( const QString&s ) { subject = s; } | 55 | void setSubject( const QString&s ) { subject = s; } |
56 | const QString&getReply()const{ return reply; } | 56 | const QString&getReply()const{ return reply; } |
57 | void setReply( const QString&a ) { reply = a; } | 57 | void setReply( const QString&a ) { reply = a; } |
58 | void setInreply(const QStringList&list){m_in_reply_to = list;} | ||
59 | const QStringList&Inreply()const{return m_in_reply_to;} | ||
58 | 60 | ||
59 | private: | 61 | private: |
60 | QList<Attachment> attList; | 62 | QList<Attachment> attList; |
61 | QString name, mail, to, cc, bcc, reply, subject, message; | 63 | QString name, mail, to, cc, bcc, reply, subject, message; |
64 | QStringList m_in_reply_to; | ||
62 | }; | 65 | }; |
63 | 66 | ||
64 | class Folder : public QObject | 67 | class Folder : public QObject |
65 | { | 68 | { |
66 | Q_OBJECT | 69 | Q_OBJECT |
67 | 70 | ||
68 | public: | 71 | public: |
69 | Folder( const QString&init_name,const QString&sep ); | 72 | Folder( const QString&init_name,const QString&sep ); |
70 | const QString&getDisplayName()const { return nameDisplay; } | 73 | const QString&getDisplayName()const { return nameDisplay; } |
71 | const QString&getName()const { return name; } | 74 | const QString&getName()const { return name; } |
72 | const QString&getPrefix()const{return prefix; } | 75 | const QString&getPrefix()const{return prefix; } |
73 | virtual bool may_select()const{return true;} | 76 | virtual bool may_select()const{return true;} |
74 | virtual bool no_inferior()const{return true;} | 77 | virtual bool no_inferior()const{return true;} |
75 | const QString&Separator()const; | 78 | const QString&Separator()const; |
76 | 79 | ||
77 | protected: | 80 | protected: |
78 | QString nameDisplay, name, separator,prefix; | 81 | QString nameDisplay, name, separator,prefix; |
79 | }; | 82 | }; |
80 | 83 | ||
81 | class MHFolder : public Folder | 84 | class MHFolder : public Folder |
82 | { | 85 | { |
83 | Q_OBJECT | 86 | Q_OBJECT |
84 | public: | 87 | public: |
85 | MHFolder(const QString&disp_name,const QString&mbox); | 88 | MHFolder(const QString&disp_name,const QString&mbox); |
86 | }; | 89 | }; |
87 | 90 | ||
88 | class IMAPFolder : public Folder | 91 | class IMAPFolder : public Folder |
89 | { | 92 | { |
90 | public: | 93 | public: |
91 | IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" ); | 94 | IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" ); |
92 | virtual bool may_select()const{return m_MaySelect;} | 95 | virtual bool may_select()const{return m_MaySelect;} |
93 | virtual bool no_inferior()const{return m_NoInferior;} | 96 | virtual bool no_inferior()const{return m_NoInferior;} |
94 | private: | 97 | private: |
95 | static QString decodeFolderName( const QString &name ); | 98 | static QString decodeFolderName( const QString &name ); |
96 | bool m_MaySelect,m_NoInferior; | 99 | bool m_MaySelect,m_NoInferior; |
97 | }; | 100 | }; |
98 | 101 | ||
99 | #endif | 102 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index d7a005e..63acfd5 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp | |||
@@ -1,873 +1,900 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <sys/stat.h> | 2 | #include <sys/stat.h> |
3 | #include <sys/types.h> | 3 | #include <sys/types.h> |
4 | #include <unistd.h> | 4 | #include <unistd.h> |
5 | #include <fcntl.h> | 5 | #include <fcntl.h> |
6 | #include <string.h> | 6 | #include <string.h> |
7 | #include <qt.h> | 7 | #include <qt.h> |
8 | 8 | ||
9 | #include <qpe/config.h> | 9 | #include <qpe/config.h> |
10 | #include <qpe/qcopenvelope_qws.h> | 10 | #include <qpe/qcopenvelope_qws.h> |
11 | 11 | ||
12 | #include <libetpan/libetpan.h> | 12 | #include <libetpan/libetpan.h> |
13 | 13 | ||
14 | #include "smtpwrapper.h" | 14 | #include "smtpwrapper.h" |
15 | #include "mailwrapper.h" | 15 | #include "mailwrapper.h" |
16 | #include "abstractmail.h" | 16 | #include "abstractmail.h" |
17 | #include "logindialog.h" | 17 | #include "logindialog.h" |
18 | #include "mailtypes.h" | 18 | #include "mailtypes.h" |
19 | #include "sendmailprogress.h" | 19 | #include "sendmailprogress.h" |
20 | 20 | ||
21 | const char* SMTPwrapper::USER_AGENT="OpieMail v0.4"; | 21 | const char* SMTPwrapper::USER_AGENT="OpieMail v0.4"; |
22 | 22 | ||
23 | progressMailSend*SMTPwrapper::sendProgress = 0; | 23 | progressMailSend*SMTPwrapper::sendProgress = 0; |
24 | 24 | ||
25 | SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp ) | 25 | SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp ) |
26 | : QObject() | 26 | : QObject() |
27 | { | 27 | { |
28 | m_SmtpAccount = aSmtp; | 28 | m_SmtpAccount = aSmtp; |
29 | Config cfg( "mail" ); | 29 | Config cfg( "mail" ); |
30 | cfg.setGroup( "Status" ); | 30 | cfg.setGroup( "Status" ); |
31 | m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); | 31 | m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); |
32 | emit queuedMails( m_queuedMail ); | 32 | emit queuedMails( m_queuedMail ); |
33 | connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) ); | 33 | connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) ); |
34 | m_smtp = 0; | 34 | m_smtp = 0; |
35 | } | 35 | } |
36 | 36 | ||
37 | SMTPwrapper::~SMTPwrapper() | 37 | SMTPwrapper::~SMTPwrapper() |
38 | { | 38 | { |
39 | disc_server(); | 39 | disc_server(); |
40 | } | 40 | } |
41 | 41 | ||
42 | void SMTPwrapper::emitQCop( int queued ) { | 42 | void SMTPwrapper::emitQCop( int queued ) { |
43 | QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); | 43 | QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); |
44 | env << queued; | 44 | env << queued; |
45 | } | 45 | } |
46 | 46 | ||
47 | QString SMTPwrapper::mailsmtpError( int errnum ) { | 47 | QString SMTPwrapper::mailsmtpError( int errnum ) { |
48 | switch ( errnum ) { | 48 | switch ( errnum ) { |
49 | case MAILSMTP_NO_ERROR: | 49 | case MAILSMTP_NO_ERROR: |
50 | return tr( "No error" ); | 50 | return tr( "No error" ); |
51 | case MAILSMTP_ERROR_UNEXPECTED_CODE: | 51 | case MAILSMTP_ERROR_UNEXPECTED_CODE: |
52 | return tr( "Unexpected error code" ); | 52 | return tr( "Unexpected error code" ); |
53 | case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: | 53 | case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: |
54 | return tr( "Service not available" ); | 54 | return tr( "Service not available" ); |
55 | case MAILSMTP_ERROR_STREAM: | 55 | case MAILSMTP_ERROR_STREAM: |
56 | return tr( "Stream error" ); | 56 | return tr( "Stream error" ); |
57 | case MAILSMTP_ERROR_HOSTNAME: | 57 | case MAILSMTP_ERROR_HOSTNAME: |
58 | return tr( "gethostname() failed" ); | 58 | return tr( "gethostname() failed" ); |
59 | case MAILSMTP_ERROR_NOT_IMPLEMENTED: | 59 | case MAILSMTP_ERROR_NOT_IMPLEMENTED: |
60 | return tr( "Not implemented" ); | 60 | return tr( "Not implemented" ); |
61 | case MAILSMTP_ERROR_ACTION_NOT_TAKEN: | 61 | case MAILSMTP_ERROR_ACTION_NOT_TAKEN: |
62 | return tr( "Error, action not taken" ); | 62 | return tr( "Error, action not taken" ); |
63 | case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: | 63 | case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: |
64 | return tr( "Data exceeds storage allocation" ); | 64 | return tr( "Data exceeds storage allocation" ); |
65 | case MAILSMTP_ERROR_IN_PROCESSING: | 65 | case MAILSMTP_ERROR_IN_PROCESSING: |
66 | return tr( "Error in processing" ); | 66 | return tr( "Error in processing" ); |
67 | case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED: | 67 | case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED: |
68 | return tr( "Starttls not supported" ); | 68 | return tr( "Starttls not supported" ); |
69 | // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: | 69 | // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: |
70 | // return tr( "Insufficient system storage" ); | 70 | // return tr( "Insufficient system storage" ); |
71 | case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: | 71 | case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: |
72 | return tr( "Mailbox unavailable" ); | 72 | return tr( "Mailbox unavailable" ); |
73 | case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: | 73 | case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: |
74 | return tr( "Mailbox name not allowed" ); | 74 | return tr( "Mailbox name not allowed" ); |
75 | case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: | 75 | case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: |
76 | return tr( "Bad command sequence" ); | 76 | return tr( "Bad command sequence" ); |
77 | case MAILSMTP_ERROR_USER_NOT_LOCAL: | 77 | case MAILSMTP_ERROR_USER_NOT_LOCAL: |
78 | return tr( "User not local" ); | 78 | return tr( "User not local" ); |
79 | case MAILSMTP_ERROR_TRANSACTION_FAILED: | 79 | case MAILSMTP_ERROR_TRANSACTION_FAILED: |
80 | return tr( "Transaction failed" ); | 80 | return tr( "Transaction failed" ); |
81 | case MAILSMTP_ERROR_MEMORY: | 81 | case MAILSMTP_ERROR_MEMORY: |
82 | return tr( "Memory error" ); | 82 | return tr( "Memory error" ); |
83 | case MAILSMTP_ERROR_CONNECTION_REFUSED: | 83 | case MAILSMTP_ERROR_CONNECTION_REFUSED: |
84 | return tr( "Connection refused" ); | 84 | return tr( "Connection refused" ); |
85 | default: | 85 | default: |
86 | return tr( "Unknown error code" ); | 86 | return tr( "Unknown error code" ); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | mailimf_mailbox *SMTPwrapper::newMailbox(const QString&name, const QString&mail ) { | 90 | mailimf_mailbox *SMTPwrapper::newMailbox(const QString&name, const QString&mail ) { |
91 | return mailimf_mailbox_new( strdup( name.latin1() ), | 91 | return mailimf_mailbox_new( strdup( name.latin1() ), |
92 | strdup( mail.latin1() ) ); | 92 | strdup( mail.latin1() ) ); |
93 | } | 93 | } |
94 | 94 | ||
95 | mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) { | 95 | mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) { |
96 | mailimf_address_list *addresses; | 96 | mailimf_address_list *addresses; |
97 | 97 | ||
98 | if ( addr.isEmpty() ) | 98 | if ( addr.isEmpty() ) |
99 | return NULL; | 99 | return NULL; |
100 | 100 | ||
101 | addresses = mailimf_address_list_new_empty(); | 101 | addresses = mailimf_address_list_new_empty(); |
102 | 102 | ||
103 | bool literal_open = false; | 103 | bool literal_open = false; |
104 | unsigned int startpos = 0; | 104 | unsigned int startpos = 0; |
105 | QStringList list; | 105 | QStringList list; |
106 | QString s; | 106 | QString s; |
107 | unsigned int i = 0; | 107 | unsigned int i = 0; |
108 | for (; i < addr.length();++i) { | 108 | for (; i < addr.length();++i) { |
109 | switch (addr[i]) { | 109 | switch (addr[i]) { |
110 | case '\"': | 110 | case '\"': |
111 | literal_open = !literal_open; | 111 | literal_open = !literal_open; |
112 | break; | 112 | break; |
113 | case ',': | 113 | case ',': |
114 | if (!literal_open) { | 114 | if (!literal_open) { |
115 | s = addr.mid(startpos,i-startpos); | 115 | s = addr.mid(startpos,i-startpos); |
116 | if (!s.isEmpty()) { | 116 | if (!s.isEmpty()) { |
117 | list.append(s); | 117 | list.append(s); |
118 | qDebug("Appended %s",s.latin1()); | 118 | qDebug("Appended %s",s.latin1()); |
119 | } | 119 | } |
120 | // !!!! this is a MUST BE! | 120 | // !!!! this is a MUST BE! |
121 | startpos = ++i; | 121 | startpos = ++i; |
122 | } | 122 | } |
123 | break; | 123 | break; |
124 | default: | 124 | default: |
125 | break; | 125 | break; |
126 | } | 126 | } |
127 | } | 127 | } |
128 | s = addr.mid(startpos,i-startpos); | 128 | s = addr.mid(startpos,i-startpos); |
129 | if (!s.isEmpty()) { | 129 | if (!s.isEmpty()) { |
130 | list.append(s); | 130 | list.append(s); |
131 | qDebug("Appended %s",s.latin1()); | 131 | qDebug("Appended %s",s.latin1()); |
132 | } | 132 | } |
133 | QStringList::Iterator it; | 133 | QStringList::Iterator it; |
134 | for ( it = list.begin(); it != list.end(); it++ ) { | 134 | for ( it = list.begin(); it != list.end(); it++ ) { |
135 | int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); | 135 | int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); |
136 | if ( err != MAILIMF_NO_ERROR ) { | 136 | if ( err != MAILIMF_NO_ERROR ) { |
137 | qDebug( "Error parsing" ); | 137 | qDebug( "Error parsing" ); |
138 | qDebug( *it ); | 138 | qDebug( *it ); |
139 | } else { | 139 | } else { |
140 | qDebug( "Parse success! %s",(*it).latin1()); | 140 | qDebug( "Parse success! %s",(*it).latin1()); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | return addresses; | 143 | return addresses; |
144 | } | 144 | } |
145 | 145 | ||
146 | mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) { | 146 | mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) { |
147 | mailimf_fields *fields; | 147 | mailimf_fields *fields; |
148 | mailimf_field *xmailer; | 148 | mailimf_field *xmailer; |
149 | mailimf_mailbox *sender=0,*fromBox=0; | 149 | mailimf_mailbox *sender=0,*fromBox=0; |
150 | mailimf_mailbox_list *from=0; | 150 | mailimf_mailbox_list *from=0; |
151 | mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; | 151 | mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; |
152 | clist*in_reply_to = 0; | ||
152 | char *subject = strdup( mail.getSubject().latin1() ); | 153 | char *subject = strdup( mail.getSubject().latin1() ); |
153 | int err; | 154 | int err; |
154 | 155 | ||
155 | sender = newMailbox( mail.getName(), mail.getMail() ); | 156 | sender = newMailbox( mail.getName(), mail.getMail() ); |
156 | if ( sender == NULL ) | 157 | if ( sender == NULL ) |
157 | goto err_free; | 158 | goto err_free; |
158 | 159 | ||
159 | fromBox = newMailbox( mail.getName(), mail.getMail() ); | 160 | fromBox = newMailbox( mail.getName(), mail.getMail() ); |
160 | if ( fromBox == NULL ) | 161 | if ( fromBox == NULL ) |
161 | goto err_free_sender; | 162 | goto err_free_sender; |
162 | 163 | ||
163 | from = mailimf_mailbox_list_new_empty(); | 164 | from = mailimf_mailbox_list_new_empty(); |
164 | if ( from == NULL ) | 165 | if ( from == NULL ) |
165 | goto err_free_fromBox; | 166 | goto err_free_fromBox; |
166 | 167 | ||
167 | err = mailimf_mailbox_list_add( from, fromBox ); | 168 | err = mailimf_mailbox_list_add( from, fromBox ); |
168 | if ( err != MAILIMF_NO_ERROR ) | 169 | if ( err != MAILIMF_NO_ERROR ) |
169 | goto err_free_from; | 170 | goto err_free_from; |
170 | 171 | ||
171 | to = parseAddresses( mail.getTo() ); | 172 | to = parseAddresses( mail.getTo() ); |
172 | if ( to == NULL ) | 173 | if ( to == NULL ) |
173 | goto err_free_from; | 174 | goto err_free_from; |
174 | 175 | ||
175 | cc = parseAddresses( mail.getCC() ); | 176 | cc = parseAddresses( mail.getCC() ); |
176 | bcc = parseAddresses( mail.getBCC() ); | 177 | bcc = parseAddresses( mail.getBCC() ); |
177 | reply = parseAddresses( mail.getReply() ); | 178 | reply = parseAddresses( mail.getReply() ); |
179 | |||
180 | if (mail.Inreply().count()>0) { | ||
181 | in_reply_to = clist_new(); | ||
182 | char*c_reply; | ||
183 | unsigned int nsize = 0; | ||
184 | for (QStringList::ConstIterator it=mail.Inreply().begin(); | ||
185 | it != mail.Inreply().end();++it) { | ||
186 | /* yes! must be malloc! */ | ||
187 | if ((*it).isEmpty()) | ||
188 | continue; | ||
189 | QString h((*it)); | ||
190 | while (h.length()>0 && h[0]=='<') { | ||
191 | h.remove(0,1); | ||
192 | } | ||
193 | while (h.length()>0 && h[h.length()-1]=='>') { | ||
194 | h.remove(h.length()-1,1); | ||
195 | } | ||
196 | if (h.isEmpty()) continue; | ||
197 | nsize = strlen(h.latin1()); | ||
198 | c_reply = (char*)malloc( (nsize+1)*sizeof(char)); | ||
199 | memset(c_reply,0,nsize+1); | ||
200 | memcpy(c_reply,h.latin1(),nsize); | ||
201 | clist_append(in_reply_to,c_reply); | ||
202 | qDebug("In reply to: %s",c_reply); | ||
203 | } | ||
204 | } | ||
178 | 205 | ||
179 | fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, | 206 | fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, |
180 | NULL, NULL, subject ); | 207 | in_reply_to, NULL, subject ); |
181 | if ( fields == NULL ) | 208 | if ( fields == NULL ) |
182 | goto err_free_reply; | 209 | goto err_free_reply; |
183 | 210 | ||
184 | xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), | 211 | xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), |
185 | strdup( USER_AGENT ) ); | 212 | strdup( USER_AGENT ) ); |
186 | if ( xmailer == NULL ) | 213 | if ( xmailer == NULL ) |
187 | goto err_free_fields; | 214 | goto err_free_fields; |
188 | 215 | ||
189 | err = mailimf_fields_add( fields, xmailer ); | 216 | err = mailimf_fields_add( fields, xmailer ); |
190 | if ( err != MAILIMF_NO_ERROR ) | 217 | if ( err != MAILIMF_NO_ERROR ) |
191 | goto err_free_xmailer; | 218 | goto err_free_xmailer; |
192 | 219 | ||
193 | return fields; // Success :) | 220 | return fields; // Success :) |
194 | 221 | ||
195 | err_free_xmailer: | 222 | err_free_xmailer: |
196 | if (xmailer) | 223 | if (xmailer) |
197 | mailimf_field_free( xmailer ); | 224 | mailimf_field_free( xmailer ); |
198 | err_free_fields: | 225 | err_free_fields: |
199 | if (fields) | 226 | if (fields) |
200 | mailimf_fields_free( fields ); | 227 | mailimf_fields_free( fields ); |
201 | err_free_reply: | 228 | err_free_reply: |
202 | if (reply) | 229 | if (reply) |
203 | mailimf_address_list_free( reply ); | 230 | mailimf_address_list_free( reply ); |
204 | if (bcc) | 231 | if (bcc) |
205 | mailimf_address_list_free( bcc ); | 232 | mailimf_address_list_free( bcc ); |
206 | if (cc) | 233 | if (cc) |
207 | mailimf_address_list_free( cc ); | 234 | mailimf_address_list_free( cc ); |
208 | if (to) | 235 | if (to) |
209 | mailimf_address_list_free( to ); | 236 | mailimf_address_list_free( to ); |
210 | err_free_from: | 237 | err_free_from: |
211 | if (from) | 238 | if (from) |
212 | mailimf_mailbox_list_free( from ); | 239 | mailimf_mailbox_list_free( from ); |
213 | err_free_fromBox: | 240 | err_free_fromBox: |
214 | mailimf_mailbox_free( fromBox ); | 241 | mailimf_mailbox_free( fromBox ); |
215 | err_free_sender: | 242 | err_free_sender: |
216 | if (sender) | 243 | if (sender) |
217 | mailimf_mailbox_free( sender ); | 244 | mailimf_mailbox_free( sender ); |
218 | err_free: | 245 | err_free: |
219 | if (subject) | 246 | if (subject) |
220 | free( subject ); | 247 | free( subject ); |
221 | qDebug( "createImfFields - error" ); | 248 | qDebug( "createImfFields - error" ); |
222 | 249 | ||
223 | return NULL; // Error :( | 250 | return NULL; // Error :( |
224 | } | 251 | } |
225 | 252 | ||
226 | mailmime *SMTPwrapper::buildTxtPart(const QString&str ) { | 253 | mailmime *SMTPwrapper::buildTxtPart(const QString&str ) { |
227 | mailmime *txtPart; | 254 | mailmime *txtPart; |
228 | mailmime_fields *fields; | 255 | mailmime_fields *fields; |
229 | mailmime_content *content; | 256 | mailmime_content *content; |
230 | mailmime_parameter *param; | 257 | mailmime_parameter *param; |
231 | int err; | 258 | int err; |
232 | 259 | ||
233 | param = mailmime_parameter_new( strdup( "charset" ), | 260 | param = mailmime_parameter_new( strdup( "charset" ), |
234 | strdup( "iso-8859-1" ) ); | 261 | strdup( "iso-8859-1" ) ); |
235 | if ( param == NULL ) | 262 | if ( param == NULL ) |
236 | goto err_free; | 263 | goto err_free; |
237 | 264 | ||
238 | content = mailmime_content_new_with_str( "text/plain" ); | 265 | content = mailmime_content_new_with_str( "text/plain" ); |
239 | if ( content == NULL ) | 266 | if ( content == NULL ) |
240 | goto err_free_param; | 267 | goto err_free_param; |
241 | 268 | ||
242 | err = clist_append( content->ct_parameters, param ); | 269 | err = clist_append( content->ct_parameters, param ); |
243 | if ( err != MAILIMF_NO_ERROR ) | 270 | if ( err != MAILIMF_NO_ERROR ) |
244 | goto err_free_content; | 271 | goto err_free_content; |
245 | 272 | ||
246 | fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); | 273 | fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); |
247 | if ( fields == NULL ) | 274 | if ( fields == NULL ) |
248 | goto err_free_content; | 275 | goto err_free_content; |
249 | 276 | ||
250 | txtPart = mailmime_new_empty( content, fields ); | 277 | txtPart = mailmime_new_empty( content, fields ); |
251 | if ( txtPart == NULL ) | 278 | if ( txtPart == NULL ) |
252 | goto err_free_fields; | 279 | goto err_free_fields; |
253 | 280 | ||
254 | err = mailmime_set_body_text( txtPart, (char*)str.data(), str.length() ); | 281 | err = mailmime_set_body_text( txtPart, (char*)str.data(), str.length() ); |
255 | if ( err != MAILIMF_NO_ERROR ) | 282 | if ( err != MAILIMF_NO_ERROR ) |
256 | goto err_free_txtPart; | 283 | goto err_free_txtPart; |
257 | 284 | ||
258 | return txtPart; // Success :) | 285 | return txtPart; // Success :) |
259 | 286 | ||
260 | err_free_txtPart: | 287 | err_free_txtPart: |
261 | mailmime_free( txtPart ); | 288 | mailmime_free( txtPart ); |
262 | err_free_fields: | 289 | err_free_fields: |
263 | mailmime_fields_free( fields ); | 290 | mailmime_fields_free( fields ); |
264 | err_free_content: | 291 | err_free_content: |
265 | mailmime_content_free( content ); | 292 | mailmime_content_free( content ); |
266 | err_free_param: | 293 | err_free_param: |
267 | mailmime_parameter_free( param ); | 294 | mailmime_parameter_free( param ); |
268 | err_free: | 295 | err_free: |
269 | qDebug( "buildTxtPart - error" ); | 296 | qDebug( "buildTxtPart - error" ); |
270 | 297 | ||
271 | return NULL; // Error :( | 298 | return NULL; // Error :( |
272 | } | 299 | } |
273 | 300 | ||
274 | mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) { | 301 | mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) { |
275 | mailmime * filePart = 0; | 302 | mailmime * filePart = 0; |
276 | mailmime_fields * fields = 0; | 303 | mailmime_fields * fields = 0; |
277 | mailmime_content * content = 0; | 304 | mailmime_content * content = 0; |
278 | mailmime_parameter * param = 0; | 305 | mailmime_parameter * param = 0; |
279 | char*name = 0; | 306 | char*name = 0; |
280 | char*file = 0; | 307 | char*file = 0; |
281 | int err; | 308 | int err; |
282 | 309 | ||
283 | int pos = filename.findRev( '/' ); | 310 | int pos = filename.findRev( '/' ); |
284 | 311 | ||
285 | if (filename.length()>0) { | 312 | if (filename.length()>0) { |
286 | QString tmp = filename.right( filename.length() - ( pos + 1 ) ); | 313 | QString tmp = filename.right( filename.length() - ( pos + 1 ) ); |
287 | name = strdup( tmp.latin1() ); // just filename | 314 | name = strdup( tmp.latin1() ); // just filename |
288 | file = strdup( filename.latin1() ); // full name with path | 315 | file = strdup( filename.latin1() ); // full name with path |
289 | } | 316 | } |
290 | 317 | ||
291 | int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; | 318 | int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; |
292 | int mechanism = MAILMIME_MECHANISM_BASE64; | 319 | int mechanism = MAILMIME_MECHANISM_BASE64; |
293 | 320 | ||
294 | if ( mimetype.startsWith( "text/" ) ) { | 321 | if ( mimetype.startsWith( "text/" ) ) { |
295 | param = mailmime_parameter_new( strdup( "charset" ), | 322 | param = mailmime_parameter_new( strdup( "charset" ), |
296 | strdup( "iso-8859-1" ) ); | 323 | strdup( "iso-8859-1" ) ); |
297 | mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 324 | mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
298 | } | 325 | } |
299 | 326 | ||
300 | fields = mailmime_fields_new_filename( | 327 | fields = mailmime_fields_new_filename( |
301 | disptype, name, | 328 | disptype, name, |
302 | mechanism ); | 329 | mechanism ); |
303 | content = mailmime_content_new_with_str( (char*)mimetype.latin1() ); | 330 | content = mailmime_content_new_with_str( (char*)mimetype.latin1() ); |
304 | if (content!=0 && fields != 0) { | 331 | if (content!=0 && fields != 0) { |
305 | if (param) { | 332 | if (param) { |
306 | clist_append(content->ct_parameters,param); | 333 | clist_append(content->ct_parameters,param); |
307 | param = 0; | 334 | param = 0; |
308 | } | 335 | } |
309 | if (filename.length()>0) { | 336 | if (filename.length()>0) { |
310 | QFileInfo f(filename); | 337 | QFileInfo f(filename); |
311 | param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); | 338 | param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); |
312 | clist_append(content->ct_parameters,param); | 339 | clist_append(content->ct_parameters,param); |
313 | param = 0; | 340 | param = 0; |
314 | } | 341 | } |
315 | filePart = mailmime_new_empty( content, fields ); | 342 | filePart = mailmime_new_empty( content, fields ); |
316 | } | 343 | } |
317 | if (filePart) { | 344 | if (filePart) { |
318 | if (filename.length()>0) { | 345 | if (filename.length()>0) { |
319 | err = mailmime_set_body_file( filePart, file ); | 346 | err = mailmime_set_body_file( filePart, file ); |
320 | } else { | 347 | } else { |
321 | err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length()); | 348 | err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length()); |
322 | } | 349 | } |
323 | if (err != MAILIMF_NO_ERROR) { | 350 | if (err != MAILIMF_NO_ERROR) { |
324 | qDebug("Error setting body with file %s",file); | 351 | qDebug("Error setting body with file %s",file); |
325 | mailmime_free( filePart ); | 352 | mailmime_free( filePart ); |
326 | filePart = 0; | 353 | filePart = 0; |
327 | } | 354 | } |
328 | } | 355 | } |
329 | 356 | ||
330 | if (!filePart) { | 357 | if (!filePart) { |
331 | if ( param != NULL ) { | 358 | if ( param != NULL ) { |
332 | mailmime_parameter_free( param ); | 359 | mailmime_parameter_free( param ); |
333 | } | 360 | } |
334 | if (content) { | 361 | if (content) { |
335 | mailmime_content_free( content ); | 362 | mailmime_content_free( content ); |
336 | } | 363 | } |
337 | if (fields) { | 364 | if (fields) { |
338 | mailmime_fields_free( fields ); | 365 | mailmime_fields_free( fields ); |
339 | } else { | 366 | } else { |
340 | if (name) { | 367 | if (name) { |
341 | free( name ); | 368 | free( name ); |
342 | } | 369 | } |
343 | if (file) { | 370 | if (file) { |
344 | free( file ); | 371 | free( file ); |
345 | } | 372 | } |
346 | } | 373 | } |
347 | } | 374 | } |
348 | return filePart; // Success :) | 375 | return filePart; // Success :) |
349 | 376 | ||
350 | } | 377 | } |
351 | 378 | ||
352 | void SMTPwrapper::addFileParts( mailmime *message,const QList<Attachment>&files ) { | 379 | void SMTPwrapper::addFileParts( mailmime *message,const QList<Attachment>&files ) { |
353 | const Attachment *it; | 380 | const Attachment *it; |
354 | unsigned int count = files.count(); | 381 | unsigned int count = files.count(); |
355 | qDebug("List contains %i values",count); | 382 | qDebug("List contains %i values",count); |
356 | for ( unsigned int i = 0; i < count; ++i ) { | 383 | for ( unsigned int i = 0; i < count; ++i ) { |
357 | qDebug( "Adding file" ); | 384 | qDebug( "Adding file" ); |
358 | mailmime *filePart; | 385 | mailmime *filePart; |
359 | int err; | 386 | int err; |
360 | it = ((QList<Attachment>)files).at(i); | 387 | it = ((QList<Attachment>)files).at(i); |
361 | 388 | ||
362 | filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); | 389 | filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); |
363 | if ( filePart == NULL ) { | 390 | if ( filePart == NULL ) { |
364 | qDebug( "addFileParts: error adding file:" ); | 391 | qDebug( "addFileParts: error adding file:" ); |
365 | qDebug( it->getFileName() ); | 392 | qDebug( it->getFileName() ); |
366 | continue; | 393 | continue; |
367 | } | 394 | } |
368 | err = mailmime_smart_add_part( message, filePart ); | 395 | err = mailmime_smart_add_part( message, filePart ); |
369 | if ( err != MAILIMF_NO_ERROR ) { | 396 | if ( err != MAILIMF_NO_ERROR ) { |
370 | mailmime_free( filePart ); | 397 | mailmime_free( filePart ); |
371 | qDebug("error smart add"); | 398 | qDebug("error smart add"); |
372 | } | 399 | } |
373 | } | 400 | } |
374 | } | 401 | } |
375 | 402 | ||
376 | mailmime *SMTPwrapper::createMimeMail(const Mail &mail ) { | 403 | mailmime *SMTPwrapper::createMimeMail(const Mail &mail ) { |
377 | mailmime *message, *txtPart; | 404 | mailmime *message, *txtPart; |
378 | mailimf_fields *fields; | 405 | mailimf_fields *fields; |
379 | int err; | 406 | int err; |
380 | 407 | ||
381 | fields = createImfFields( mail ); | 408 | fields = createImfFields( mail ); |
382 | if ( fields == NULL ) | 409 | if ( fields == NULL ) |
383 | goto err_free; | 410 | goto err_free; |
384 | 411 | ||
385 | message = mailmime_new_message_data( NULL ); | 412 | message = mailmime_new_message_data( NULL ); |
386 | if ( message == NULL ) | 413 | if ( message == NULL ) |
387 | goto err_free_fields; | 414 | goto err_free_fields; |
388 | 415 | ||
389 | mailmime_set_imf_fields( message, fields ); | 416 | mailmime_set_imf_fields( message, fields ); |
390 | 417 | ||
391 | txtPart = buildTxtPart( mail.getMessage() ); | 418 | txtPart = buildTxtPart( mail.getMessage() ); |
392 | 419 | ||
393 | if ( txtPart == NULL ) | 420 | if ( txtPart == NULL ) |
394 | goto err_free_message; | 421 | goto err_free_message; |
395 | 422 | ||
396 | err = mailmime_smart_add_part( message, txtPart ); | 423 | err = mailmime_smart_add_part( message, txtPart ); |
397 | if ( err != MAILIMF_NO_ERROR ) | 424 | if ( err != MAILIMF_NO_ERROR ) |
398 | goto err_free_txtPart; | 425 | goto err_free_txtPart; |
399 | 426 | ||
400 | addFileParts( message, mail.getAttachments() ); | 427 | addFileParts( message, mail.getAttachments() ); |
401 | 428 | ||
402 | return message; // Success :) | 429 | return message; // Success :) |
403 | 430 | ||
404 | err_free_txtPart: | 431 | err_free_txtPart: |
405 | mailmime_free( txtPart ); | 432 | mailmime_free( txtPart ); |
406 | err_free_message: | 433 | err_free_message: |
407 | mailmime_free( message ); | 434 | mailmime_free( message ); |
408 | err_free_fields: | 435 | err_free_fields: |
409 | mailimf_fields_free( fields ); | 436 | mailimf_fields_free( fields ); |
410 | err_free: | 437 | err_free: |
411 | qDebug( "createMimeMail: error" ); | 438 | qDebug( "createMimeMail: error" ); |
412 | 439 | ||
413 | return NULL; // Error :( | 440 | return NULL; // Error :( |
414 | } | 441 | } |
415 | 442 | ||
416 | mailimf_field *SMTPwrapper::getField( mailimf_fields *fields, int type ) { | 443 | mailimf_field *SMTPwrapper::getField( mailimf_fields *fields, int type ) { |
417 | mailimf_field *field; | 444 | mailimf_field *field; |
418 | clistiter *it; | 445 | clistiter *it; |
419 | 446 | ||
420 | it = clist_begin( fields->fld_list ); | 447 | it = clist_begin( fields->fld_list ); |
421 | while ( it ) { | 448 | while ( it ) { |
422 | field = (mailimf_field *) it->data; | 449 | field = (mailimf_field *) it->data; |
423 | if ( field->fld_type == type ) { | 450 | if ( field->fld_type == type ) { |
424 | return field; | 451 | return field; |
425 | } | 452 | } |
426 | it = it->next; | 453 | it = it->next; |
427 | } | 454 | } |
428 | 455 | ||
429 | return NULL; | 456 | return NULL; |
430 | } | 457 | } |
431 | 458 | ||
432 | void SMTPwrapper::addRcpts( clist *list, mailimf_address_list *addr_list ) { | 459 | void SMTPwrapper::addRcpts( clist *list, mailimf_address_list *addr_list ) { |
433 | clistiter *it, *it2; | 460 | clistiter *it, *it2; |
434 | 461 | ||
435 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { | 462 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { |
436 | mailimf_address *addr; | 463 | mailimf_address *addr; |
437 | addr = (mailimf_address *) it->data; | 464 | addr = (mailimf_address *) it->data; |
438 | 465 | ||
439 | if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { | 466 | if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { |
440 | esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); | 467 | esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); |
441 | } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { | 468 | } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { |
442 | clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; | 469 | clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; |
443 | for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { | 470 | for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { |
444 | mailimf_mailbox *mbox; | 471 | mailimf_mailbox *mbox; |
445 | mbox = (mailimf_mailbox *) it2->data; | 472 | mbox = (mailimf_mailbox *) it2->data; |
446 | esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); | 473 | esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); |
447 | } | 474 | } |
448 | } | 475 | } |
449 | } | 476 | } |
450 | } | 477 | } |
451 | 478 | ||
452 | clist *SMTPwrapper::createRcptList( mailimf_fields *fields ) { | 479 | clist *SMTPwrapper::createRcptList( mailimf_fields *fields ) { |
453 | clist *rcptList; | 480 | clist *rcptList; |
454 | mailimf_field *field; | 481 | mailimf_field *field; |
455 | 482 | ||
456 | rcptList = esmtp_address_list_new(); | 483 | rcptList = esmtp_address_list_new(); |
457 | 484 | ||
458 | field = getField( fields, MAILIMF_FIELD_TO ); | 485 | field = getField( fields, MAILIMF_FIELD_TO ); |
459 | if ( field && (field->fld_type == MAILIMF_FIELD_TO) | 486 | if ( field && (field->fld_type == MAILIMF_FIELD_TO) |
460 | && field->fld_data.fld_to->to_addr_list ) { | 487 | && field->fld_data.fld_to->to_addr_list ) { |
461 | addRcpts( rcptList, field->fld_data.fld_to->to_addr_list ); | 488 | addRcpts( rcptList, field->fld_data.fld_to->to_addr_list ); |
462 | } | 489 | } |
463 | 490 | ||
464 | field = getField( fields, MAILIMF_FIELD_CC ); | 491 | field = getField( fields, MAILIMF_FIELD_CC ); |
465 | if ( field && (field->fld_type == MAILIMF_FIELD_CC) | 492 | if ( field && (field->fld_type == MAILIMF_FIELD_CC) |
466 | && field->fld_data.fld_cc->cc_addr_list ) { | 493 | && field->fld_data.fld_cc->cc_addr_list ) { |
467 | addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list ); | 494 | addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list ); |
468 | } | 495 | } |
469 | 496 | ||
470 | field = getField( fields, MAILIMF_FIELD_BCC ); | 497 | field = getField( fields, MAILIMF_FIELD_BCC ); |
471 | if ( field && (field->fld_type == MAILIMF_FIELD_BCC) | 498 | if ( field && (field->fld_type == MAILIMF_FIELD_BCC) |
472 | && field->fld_data.fld_bcc->bcc_addr_list ) { | 499 | && field->fld_data.fld_bcc->bcc_addr_list ) { |
473 | addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list ); | 500 | addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list ); |
474 | } | 501 | } |
475 | 502 | ||
476 | return rcptList; | 503 | return rcptList; |
477 | } | 504 | } |
478 | 505 | ||
479 | char *SMTPwrapper::getFrom( mailimf_field *ffrom) { | 506 | char *SMTPwrapper::getFrom( mailimf_field *ffrom) { |
480 | char *from = NULL; | 507 | char *from = NULL; |
481 | if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM) | 508 | if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM) |
482 | && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) { | 509 | && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) { |
483 | clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list; | 510 | clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list; |
484 | clistiter *it; | 511 | clistiter *it; |
485 | for ( it = clist_begin( cl ); it; it = it->next ) { | 512 | for ( it = clist_begin( cl ); it; it = it->next ) { |
486 | mailimf_mailbox *mb = (mailimf_mailbox *) it->data; | 513 | mailimf_mailbox *mb = (mailimf_mailbox *) it->data; |
487 | from = strdup( mb->mb_addr_spec ); | 514 | from = strdup( mb->mb_addr_spec ); |
488 | } | 515 | } |
489 | } | 516 | } |
490 | 517 | ||
491 | return from; | 518 | return from; |
492 | } | 519 | } |
493 | 520 | ||
494 | char *SMTPwrapper::getFrom( mailmime *mail ) { | 521 | char *SMTPwrapper::getFrom( mailmime *mail ) { |
495 | /* no need to delete - its just a pointer to structure content */ | 522 | /* no need to delete - its just a pointer to structure content */ |
496 | mailimf_field *ffrom = 0; | 523 | mailimf_field *ffrom = 0; |
497 | ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); | 524 | ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); |
498 | return getFrom(ffrom); | 525 | return getFrom(ffrom); |
499 | } | 526 | } |
500 | 527 | ||
501 | void SMTPwrapper::progress( size_t current, size_t maximum ) { | 528 | void SMTPwrapper::progress( size_t current, size_t maximum ) { |
502 | if (SMTPwrapper::sendProgress) { | 529 | if (SMTPwrapper::sendProgress) { |
503 | SMTPwrapper::sendProgress->setSingleMail(current, maximum ); | 530 | SMTPwrapper::sendProgress->setSingleMail(current, maximum ); |
504 | qApp->processEvents(); | 531 | qApp->processEvents(); |
505 | } | 532 | } |
506 | } | 533 | } |
507 | 534 | ||
508 | void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) { | 535 | void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) { |
509 | if (!mail) | 536 | if (!mail) |
510 | return; | 537 | return; |
511 | QString localfolders = AbstractMail::defaultLocalfolder(); | 538 | QString localfolders = AbstractMail::defaultLocalfolder(); |
512 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); | 539 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); |
513 | wrap->createMbox(box); | 540 | wrap->createMbox(box); |
514 | wrap->storeMessage(mail,length,box); | 541 | wrap->storeMessage(mail,length,box); |
515 | delete wrap; | 542 | delete wrap; |
516 | } | 543 | } |
517 | 544 | ||
518 | void SMTPwrapper::smtpSend( mailmime *mail,bool later) { | 545 | void SMTPwrapper::smtpSend( mailmime *mail,bool later) { |
519 | clist *rcpts = 0; | 546 | clist *rcpts = 0; |
520 | char *from, *data; | 547 | char *from, *data; |
521 | size_t size; | 548 | size_t size; |
522 | 549 | ||
523 | from = data = 0; | 550 | from = data = 0; |
524 | 551 | ||
525 | mailmessage * msg = 0; | 552 | mailmessage * msg = 0; |
526 | msg = mime_message_init(mail); | 553 | msg = mime_message_init(mail); |
527 | mime_message_set_tmpdir(msg,getenv( "HOME" )); | 554 | mime_message_set_tmpdir(msg,getenv( "HOME" )); |
528 | int r = mailmessage_fetch(msg,&data,&size); | 555 | int r = mailmessage_fetch(msg,&data,&size); |
529 | mime_message_detach_mime(msg); | 556 | mime_message_detach_mime(msg); |
530 | mailmessage_free(msg); | 557 | mailmessage_free(msg); |
531 | if (r != MAIL_NO_ERROR || !data) { | 558 | if (r != MAIL_NO_ERROR || !data) { |
532 | if (data) | 559 | if (data) |
533 | free(data); | 560 | free(data); |
534 | qDebug("Error fetching mime..."); | 561 | qDebug("Error fetching mime..."); |
535 | return; | 562 | return; |
536 | } | 563 | } |
537 | msg = 0; | 564 | msg = 0; |
538 | if (later) { | 565 | if (later) { |
539 | storeMail(data,size,"Outgoing"); | 566 | storeMail(data,size,"Outgoing"); |
540 | if (data) | 567 | if (data) |
541 | free( data ); | 568 | free( data ); |
542 | Config cfg( "mail" ); | 569 | Config cfg( "mail" ); |
543 | cfg.setGroup( "Status" ); | 570 | cfg.setGroup( "Status" ); |
544 | cfg.writeEntry( "outgoing", ++m_queuedMail ); | 571 | cfg.writeEntry( "outgoing", ++m_queuedMail ); |
545 | emit queuedMails( m_queuedMail ); | 572 | emit queuedMails( m_queuedMail ); |
546 | return; | 573 | return; |
547 | } | 574 | } |
548 | from = getFrom( mail ); | 575 | from = getFrom( mail ); |
549 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); | 576 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); |
550 | smtpSend(from,rcpts,data,size); | 577 | smtpSend(from,rcpts,data,size); |
551 | if (data) { | 578 | if (data) { |
552 | free(data); | 579 | free(data); |
553 | } | 580 | } |
554 | if (from) { | 581 | if (from) { |
555 | free(from); | 582 | free(from); |
556 | } | 583 | } |
557 | if (rcpts) | 584 | if (rcpts) |
558 | smtp_address_list_free( rcpts ); | 585 | smtp_address_list_free( rcpts ); |
559 | } | 586 | } |
560 | 587 | ||
561 | void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage) | 588 | void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage) |
562 | { | 589 | { |
563 | if (data) { | 590 | if (data) { |
564 | storeMail(data,size,"Sendfailed"); | 591 | storeMail(data,size,"Sendfailed"); |
565 | } | 592 | } |
566 | if (failuremessage) { | 593 | if (failuremessage) { |
567 | QMessageBox::critical(0,tr("Error sending mail"), | 594 | QMessageBox::critical(0,tr("Error sending mail"), |
568 | tr("<center>%1</center>").arg(failuremessage)); | 595 | tr("<center>%1</center>").arg(failuremessage)); |
569 | } | 596 | } |
570 | } | 597 | } |
571 | 598 | ||
572 | int SMTPwrapper::start_smtp_tls() | 599 | int SMTPwrapper::start_smtp_tls() |
573 | { | 600 | { |
574 | if (!m_smtp) { | 601 | if (!m_smtp) { |
575 | return MAILSMTP_ERROR_IN_PROCESSING; | 602 | return MAILSMTP_ERROR_IN_PROCESSING; |
576 | } | 603 | } |
577 | int err = mailesmtp_starttls(m_smtp); | 604 | int err = mailesmtp_starttls(m_smtp); |
578 | if (err != MAILSMTP_NO_ERROR) return err; | 605 | if (err != MAILSMTP_NO_ERROR) return err; |
579 | mailstream_low * low; | 606 | mailstream_low * low; |
580 | mailstream_low * new_low; | 607 | mailstream_low * new_low; |
581 | low = mailstream_get_low(m_smtp->stream); | 608 | low = mailstream_get_low(m_smtp->stream); |
582 | if (!low) { | 609 | if (!low) { |
583 | return MAILSMTP_ERROR_IN_PROCESSING; | 610 | return MAILSMTP_ERROR_IN_PROCESSING; |
584 | } | 611 | } |
585 | int fd = mailstream_low_get_fd(low); | 612 | int fd = mailstream_low_get_fd(low); |
586 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 613 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
587 | mailstream_low_free(low); | 614 | mailstream_low_free(low); |
588 | mailstream_set_low(m_smtp->stream, new_low); | 615 | mailstream_set_low(m_smtp->stream, new_low); |
589 | } else { | 616 | } else { |
590 | return MAILSMTP_ERROR_IN_PROCESSING; | 617 | return MAILSMTP_ERROR_IN_PROCESSING; |
591 | } | 618 | } |
592 | return err; | 619 | return err; |
593 | } | 620 | } |
594 | 621 | ||
595 | void SMTPwrapper::connect_server() | 622 | void SMTPwrapper::connect_server() |
596 | { | 623 | { |
597 | const char *server, *user, *pass; | 624 | const char *server, *user, *pass; |
598 | bool ssl; | 625 | bool ssl; |
599 | uint16_t port; | 626 | uint16_t port; |
600 | ssl = false; | 627 | ssl = false; |
601 | bool try_tls = true; | 628 | bool try_tls = true; |
602 | bool force_tls=false; | 629 | bool force_tls=false; |
603 | server = user = pass = 0; | 630 | server = user = pass = 0; |
604 | QString failuretext = ""; | 631 | QString failuretext = ""; |
605 | 632 | ||
606 | if (m_smtp || !m_SmtpAccount) { | 633 | if (m_smtp || !m_SmtpAccount) { |
607 | return; | 634 | return; |
608 | } | 635 | } |
609 | server = m_SmtpAccount->getServer().latin1(); | 636 | server = m_SmtpAccount->getServer().latin1(); |
610 | if ( m_SmtpAccount->ConnectionType() == 2 ) { | 637 | if ( m_SmtpAccount->ConnectionType() == 2 ) { |
611 | ssl = true; | 638 | ssl = true; |
612 | try_tls = false; | 639 | try_tls = false; |
613 | } else if (m_SmtpAccount->ConnectionType() == 1) { | 640 | } else if (m_SmtpAccount->ConnectionType() == 1) { |
614 | force_tls = true; | 641 | force_tls = true; |
615 | } | 642 | } |
616 | int result = 1; | 643 | int result = 1; |
617 | port = m_SmtpAccount->getPort().toUInt(); | 644 | port = m_SmtpAccount->getPort().toUInt(); |
618 | 645 | ||
619 | m_smtp = mailsmtp_new( 20, &progress ); | 646 | m_smtp = mailsmtp_new( 20, &progress ); |
620 | if ( m_smtp == NULL ) { | 647 | if ( m_smtp == NULL ) { |
621 | /* no failure message cause this happens when problems with memory - than we | 648 | /* no failure message cause this happens when problems with memory - than we |
622 | we can not display any messagebox */ | 649 | we can not display any messagebox */ |
623 | return; | 650 | return; |
624 | } | 651 | } |
625 | 652 | ||
626 | int err = MAILSMTP_NO_ERROR; | 653 | int err = MAILSMTP_NO_ERROR; |
627 | qDebug( "Servername %s at port %i", server, port ); | 654 | qDebug( "Servername %s at port %i", server, port ); |
628 | if ( ssl ) { | 655 | if ( ssl ) { |
629 | qDebug( "SSL session" ); | 656 | qDebug( "SSL session" ); |
630 | err = mailsmtp_ssl_connect( m_smtp, server, port ); | 657 | err = mailsmtp_ssl_connect( m_smtp, server, port ); |
631 | } else { | 658 | } else { |
632 | qDebug( "No SSL session" ); | 659 | qDebug( "No SSL session" ); |
633 | err = mailsmtp_socket_connect( m_smtp, server, port ); | 660 | err = mailsmtp_socket_connect( m_smtp, server, port ); |
634 | } | 661 | } |
635 | if ( err != MAILSMTP_NO_ERROR ) { | 662 | if ( err != MAILSMTP_NO_ERROR ) { |
636 | qDebug("Error init connection"); | 663 | qDebug("Error init connection"); |
637 | failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); | 664 | failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); |
638 | result = 0; | 665 | result = 0; |
639 | } | 666 | } |
640 | 667 | ||
641 | /* switch to tls after init 'cause there it will send the ehlo */ | 668 | /* switch to tls after init 'cause there it will send the ehlo */ |
642 | if (result) { | 669 | if (result) { |
643 | err = mailsmtp_init( m_smtp ); | 670 | err = mailsmtp_init( m_smtp ); |
644 | if (err != MAILSMTP_NO_ERROR) { | 671 | if (err != MAILSMTP_NO_ERROR) { |
645 | result = 0; | 672 | result = 0; |
646 | failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); | 673 | failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); |
647 | } | 674 | } |
648 | } | 675 | } |
649 | 676 | ||
650 | if (try_tls) { | 677 | if (try_tls) { |
651 | err = start_smtp_tls(); | 678 | err = start_smtp_tls(); |
652 | if (err != MAILSMTP_NO_ERROR) { | 679 | if (err != MAILSMTP_NO_ERROR) { |
653 | try_tls = false; | 680 | try_tls = false; |
654 | } else { | 681 | } else { |
655 | err = mailesmtp_ehlo(m_smtp); | 682 | err = mailesmtp_ehlo(m_smtp); |
656 | } | 683 | } |
657 | } | 684 | } |
658 | 685 | ||
659 | if (!try_tls && force_tls) { | 686 | if (!try_tls && force_tls) { |
660 | result = 0; | 687 | result = 0; |
661 | failuretext = tr("Error init SMTP tls: %1").arg(mailsmtpError(err)); | 688 | failuretext = tr("Error init SMTP tls: %1").arg(mailsmtpError(err)); |
662 | } | 689 | } |
663 | 690 | ||
664 | if (result==1 && m_SmtpAccount->getLogin() ) { | 691 | if (result==1 && m_SmtpAccount->getLogin() ) { |
665 | qDebug("smtp with auth"); | 692 | qDebug("smtp with auth"); |
666 | if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) { | 693 | if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) { |
667 | // get'em | 694 | // get'em |
668 | LoginDialog login( m_SmtpAccount->getUser(), | 695 | LoginDialog login( m_SmtpAccount->getUser(), |
669 | m_SmtpAccount->getPassword(), NULL, 0, true ); | 696 | m_SmtpAccount->getPassword(), NULL, 0, true ); |
670 | login.show(); | 697 | login.show(); |
671 | if ( QDialog::Accepted == login.exec() ) { | 698 | if ( QDialog::Accepted == login.exec() ) { |
672 | // ok | 699 | // ok |
673 | user = login.getUser().latin1(); | 700 | user = login.getUser().latin1(); |
674 | pass = login.getPassword().latin1(); | 701 | pass = login.getPassword().latin1(); |
675 | } else { | 702 | } else { |
676 | result = 0; | 703 | result = 0; |
677 | failuretext=tr("Login aborted - storing mail to localfolder"); | 704 | failuretext=tr("Login aborted - storing mail to localfolder"); |
678 | } | 705 | } |
679 | } else { | 706 | } else { |
680 | user = m_SmtpAccount->getUser().latin1(); | 707 | user = m_SmtpAccount->getUser().latin1(); |
681 | pass = m_SmtpAccount->getPassword().latin1(); | 708 | pass = m_SmtpAccount->getPassword().latin1(); |
682 | } | 709 | } |
683 | qDebug( "session->auth: %i", m_smtp->auth); | 710 | qDebug( "session->auth: %i", m_smtp->auth); |
684 | if (result) { | 711 | if (result) { |
685 | err = mailsmtp_auth( m_smtp, (char*)user, (char*)pass ); | 712 | err = mailsmtp_auth( m_smtp, (char*)user, (char*)pass ); |
686 | if ( err == MAILSMTP_NO_ERROR ) { | 713 | if ( err == MAILSMTP_NO_ERROR ) { |
687 | qDebug("auth ok"); | 714 | qDebug("auth ok"); |
688 | } else { | 715 | } else { |
689 | failuretext = tr("Authentification failed"); | 716 | failuretext = tr("Authentification failed"); |
690 | result = 0; | 717 | result = 0; |
691 | } | 718 | } |
692 | } | 719 | } |
693 | } | 720 | } |
694 | } | 721 | } |
695 | 722 | ||
696 | void SMTPwrapper::disc_server() | 723 | void SMTPwrapper::disc_server() |
697 | { | 724 | { |
698 | if (m_smtp) { | 725 | if (m_smtp) { |
699 | mailsmtp_quit( m_smtp ); | 726 | mailsmtp_quit( m_smtp ); |
700 | mailsmtp_free( m_smtp ); | 727 | mailsmtp_free( m_smtp ); |
701 | m_smtp = 0; | 728 | m_smtp = 0; |
702 | } | 729 | } |
703 | } | 730 | } |
704 | 731 | ||
705 | int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size ) | 732 | int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size ) |
706 | { | 733 | { |
707 | int err,result; | 734 | int err,result; |
708 | QString failuretext = ""; | 735 | QString failuretext = ""; |
709 | 736 | ||
710 | connect_server(); | 737 | connect_server(); |
711 | 738 | ||
712 | result = 1; | 739 | result = 1; |
713 | if (m_smtp) { | 740 | if (m_smtp) { |
714 | err = mailsmtp_send( m_smtp, from, rcpts, data, size ); | 741 | err = mailsmtp_send( m_smtp, from, rcpts, data, size ); |
715 | if ( err != MAILSMTP_NO_ERROR ) { | 742 | if ( err != MAILSMTP_NO_ERROR ) { |
716 | failuretext=tr("Error sending mail: %1").arg(mailsmtpError(err)); | 743 | failuretext=tr("Error sending mail: %1").arg(mailsmtpError(err)); |
717 | result = 0; | 744 | result = 0; |
718 | } | 745 | } |
719 | } else { | 746 | } else { |
720 | result = 0; | 747 | result = 0; |
721 | } | 748 | } |
722 | 749 | ||
723 | if (!result) { | 750 | if (!result) { |
724 | storeFailedMail(data,size,failuretext); | 751 | storeFailedMail(data,size,failuretext); |
725 | } else { | 752 | } else { |
726 | qDebug( "Mail sent." ); | 753 | qDebug( "Mail sent." ); |
727 | storeMail(data,size,"Sent"); | 754 | storeMail(data,size,"Sent"); |
728 | } | 755 | } |
729 | return result; | 756 | return result; |
730 | } | 757 | } |
731 | 758 | ||
732 | void SMTPwrapper::sendMail(const Mail&mail,bool later ) | 759 | void SMTPwrapper::sendMail(const Mail&mail,bool later ) |
733 | { | 760 | { |
734 | mailmime * mimeMail; | 761 | mailmime * mimeMail; |
735 | 762 | ||
736 | mimeMail = createMimeMail(mail ); | 763 | mimeMail = createMimeMail(mail ); |
737 | if ( mimeMail == NULL ) { | 764 | if ( mimeMail == NULL ) { |
738 | qDebug( "sendMail: error creating mime mail" ); | 765 | qDebug( "sendMail: error creating mime mail" ); |
739 | } else { | 766 | } else { |
740 | sendProgress = new progressMailSend(); | 767 | sendProgress = new progressMailSend(); |
741 | sendProgress->show(); | 768 | sendProgress->show(); |
742 | sendProgress->setMaxMails(1); | 769 | sendProgress->setMaxMails(1); |
743 | smtpSend( mimeMail,later); | 770 | smtpSend( mimeMail,later); |
744 | qDebug("Clean up done"); | 771 | qDebug("Clean up done"); |
745 | sendProgress->hide(); | 772 | sendProgress->hide(); |
746 | delete sendProgress; | 773 | delete sendProgress; |
747 | sendProgress = 0; | 774 | sendProgress = 0; |
748 | mailmime_free( mimeMail ); | 775 | mailmime_free( mimeMail ); |
749 | } | 776 | } |
750 | } | 777 | } |
751 | 778 | ||
752 | int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,RecMail*which) { | 779 | int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,RecMail*which) { |
753 | size_t curTok = 0; | 780 | size_t curTok = 0; |
754 | mailimf_fields *fields = 0; | 781 | mailimf_fields *fields = 0; |
755 | mailimf_field*ffrom = 0; | 782 | mailimf_field*ffrom = 0; |
756 | clist *rcpts = 0; | 783 | clist *rcpts = 0; |
757 | char*from = 0; | 784 | char*from = 0; |
758 | int res = 0; | 785 | int res = 0; |
759 | 786 | ||
760 | encodedString * data = wrap->fetchRawBody(*which); | 787 | encodedString * data = wrap->fetchRawBody(*which); |
761 | if (!data) | 788 | if (!data) |
762 | return 0; | 789 | return 0; |
763 | int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); | 790 | int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); |
764 | if (err != MAILIMF_NO_ERROR) { | 791 | if (err != MAILIMF_NO_ERROR) { |
765 | delete data; | 792 | delete data; |
766 | delete wrap; | 793 | delete wrap; |
767 | return 0; | 794 | return 0; |
768 | } | 795 | } |
769 | 796 | ||
770 | rcpts = createRcptList( fields ); | 797 | rcpts = createRcptList( fields ); |
771 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); | 798 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); |
772 | from = getFrom(ffrom); | 799 | from = getFrom(ffrom); |
773 | 800 | ||
774 | if (rcpts && from) { | 801 | if (rcpts && from) { |
775 | res = smtpSend(from,rcpts,data->Content(),data->Length()); | 802 | res = smtpSend(from,rcpts,data->Content(),data->Length()); |
776 | } | 803 | } |
777 | if (fields) { | 804 | if (fields) { |
778 | mailimf_fields_free(fields); | 805 | mailimf_fields_free(fields); |
779 | fields = 0; | 806 | fields = 0; |
780 | } | 807 | } |
781 | if (data) { | 808 | if (data) { |
782 | delete data; | 809 | delete data; |
783 | } | 810 | } |
784 | if (from) { | 811 | if (from) { |
785 | free(from); | 812 | free(from); |
786 | } | 813 | } |
787 | if (rcpts) { | 814 | if (rcpts) { |
788 | smtp_address_list_free( rcpts ); | 815 | smtp_address_list_free( rcpts ); |
789 | } | 816 | } |
790 | return res; | 817 | return res; |
791 | } | 818 | } |
792 | 819 | ||
793 | /* this is a special fun */ | 820 | /* this is a special fun */ |
794 | bool SMTPwrapper::flushOutbox() { | 821 | bool SMTPwrapper::flushOutbox() { |
795 | bool returnValue = true; | 822 | bool returnValue = true; |
796 | 823 | ||
797 | qDebug("Sending the queue"); | 824 | qDebug("Sending the queue"); |
798 | if (!m_SmtpAccount) { | 825 | if (!m_SmtpAccount) { |
799 | qDebug("No smtp account given"); | 826 | qDebug("No smtp account given"); |
800 | return false; | 827 | return false; |
801 | } | 828 | } |
802 | 829 | ||
803 | bool reset_user_value = false; | 830 | bool reset_user_value = false; |
804 | QString localfolders = AbstractMail::defaultLocalfolder(); | 831 | QString localfolders = AbstractMail::defaultLocalfolder(); |
805 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); | 832 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); |
806 | if (!wrap) { | 833 | if (!wrap) { |
807 | qDebug("memory error"); | 834 | qDebug("memory error"); |
808 | return false; | 835 | return false; |
809 | } | 836 | } |
810 | QString oldPw, oldUser; | 837 | QString oldPw, oldUser; |
811 | QList<RecMail> mailsToSend; | 838 | QList<RecMail> mailsToSend; |
812 | QList<RecMail> mailsToRemove; | 839 | QList<RecMail> mailsToRemove; |
813 | QString mbox("Outgoing"); | 840 | QString mbox("Outgoing"); |
814 | wrap->listMessages(mbox,mailsToSend); | 841 | wrap->listMessages(mbox,mailsToSend); |
815 | if (mailsToSend.count()==0) { | 842 | if (mailsToSend.count()==0) { |
816 | delete wrap; | 843 | delete wrap; |
817 | qDebug("No mails to send"); | 844 | qDebug("No mails to send"); |
818 | return false; | 845 | return false; |
819 | } | 846 | } |
820 | 847 | ||
821 | oldPw = m_SmtpAccount->getPassword(); | 848 | oldPw = m_SmtpAccount->getPassword(); |
822 | oldUser = m_SmtpAccount->getUser(); | 849 | oldUser = m_SmtpAccount->getUser(); |
823 | if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { | 850 | if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { |
824 | // get'em | 851 | // get'em |
825 | QString user,pass; | 852 | QString user,pass; |
826 | LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true ); | 853 | LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true ); |
827 | login.show(); | 854 | login.show(); |
828 | if ( QDialog::Accepted == login.exec() ) { | 855 | if ( QDialog::Accepted == login.exec() ) { |
829 | // ok | 856 | // ok |
830 | user = login.getUser().latin1(); | 857 | user = login.getUser().latin1(); |
831 | pass = login.getPassword().latin1(); | 858 | pass = login.getPassword().latin1(); |
832 | reset_user_value = true; | 859 | reset_user_value = true; |
833 | m_SmtpAccount->setUser(user); | 860 | m_SmtpAccount->setUser(user); |
834 | m_SmtpAccount->setPassword(pass); | 861 | m_SmtpAccount->setPassword(pass); |
835 | } else { | 862 | } else { |
836 | return true; | 863 | return true; |
837 | } | 864 | } |
838 | } | 865 | } |
839 | 866 | ||
840 | 867 | ||
841 | mailsToSend.setAutoDelete(false); | 868 | mailsToSend.setAutoDelete(false); |
842 | sendProgress = new progressMailSend(); | 869 | sendProgress = new progressMailSend(); |
843 | sendProgress->show(); | 870 | sendProgress->show(); |
844 | sendProgress->setMaxMails(mailsToSend.count()); | 871 | sendProgress->setMaxMails(mailsToSend.count()); |
845 | 872 | ||
846 | while (mailsToSend.count()>0) { | 873 | while (mailsToSend.count()>0) { |
847 | if (sendQueuedMail(wrap,mailsToSend.at(0))==0) { | 874 | if (sendQueuedMail(wrap,mailsToSend.at(0))==0) { |
848 | QMessageBox::critical(0,tr("Error sending mail"), | 875 | QMessageBox::critical(0,tr("Error sending mail"), |
849 | tr("Error sending queued mail - breaking")); | 876 | tr("Error sending queued mail - breaking")); |
850 | returnValue = false; | 877 | returnValue = false; |
851 | break; | 878 | break; |
852 | } | 879 | } |
853 | mailsToRemove.append(mailsToSend.at(0)); | 880 | mailsToRemove.append(mailsToSend.at(0)); |
854 | mailsToSend.removeFirst(); | 881 | mailsToSend.removeFirst(); |
855 | sendProgress->setCurrentMails(mailsToRemove.count()); | 882 | sendProgress->setCurrentMails(mailsToRemove.count()); |
856 | } | 883 | } |
857 | if (reset_user_value) { | 884 | if (reset_user_value) { |
858 | m_SmtpAccount->setUser(oldUser); | 885 | m_SmtpAccount->setUser(oldUser); |
859 | m_SmtpAccount->setPassword(oldPw); | 886 | m_SmtpAccount->setPassword(oldPw); |
860 | } | 887 | } |
861 | Config cfg( "mail" ); | 888 | Config cfg( "mail" ); |
862 | cfg.setGroup( "Status" ); | 889 | cfg.setGroup( "Status" ); |
863 | m_queuedMail = 0; | 890 | m_queuedMail = 0; |
864 | cfg.writeEntry( "outgoing", m_queuedMail ); | 891 | cfg.writeEntry( "outgoing", m_queuedMail ); |
865 | emit queuedMails( m_queuedMail ); | 892 | emit queuedMails( m_queuedMail ); |
866 | sendProgress->hide(); | 893 | sendProgress->hide(); |
867 | delete sendProgress; | 894 | delete sendProgress; |
868 | sendProgress = 0; | 895 | sendProgress = 0; |
869 | wrap->deleteMails(mbox,mailsToRemove); | 896 | wrap->deleteMails(mbox,mailsToRemove); |
870 | mailsToSend.setAutoDelete(true); | 897 | mailsToSend.setAutoDelete(true); |
871 | delete wrap; | 898 | delete wrap; |
872 | return returnValue; | 899 | return returnValue; |
873 | } | 900 | } |
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index ec93f8d..84f8a90 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -1,469 +1,471 @@ | |||
1 | #include "composemail.h" | 1 | #include "composemail.h" |
2 | #include "viewmail.h" | 2 | #include "viewmail.h" |
3 | 3 | ||
4 | /* OPIE */ | 4 | /* OPIE */ |
5 | #include <libmailwrapper/settings.h> | 5 | #include <libmailwrapper/settings.h> |
6 | #include <libmailwrapper/abstractmail.h> | 6 | #include <libmailwrapper/abstractmail.h> |
7 | #include <libmailwrapper/mailtypes.h> | 7 | #include <libmailwrapper/mailtypes.h> |
8 | 8 | ||
9 | #include <opie2/ofiledialog.h> | 9 | #include <opie2/ofiledialog.h> |
10 | #include <qpe/config.h> | 10 | #include <qpe/config.h> |
11 | #include <qpe/qpeapplication.h> | 11 | #include <qpe/qpeapplication.h> |
12 | 12 | ||
13 | /* QT */ | 13 | /* QT */ |
14 | #include <qtextbrowser.h> | 14 | #include <qtextbrowser.h> |
15 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
16 | #include <qtextstream.h> | 16 | #include <qtextstream.h> |
17 | #include <qaction.h> | 17 | #include <qaction.h> |
18 | #include <qpopupmenu.h> | 18 | #include <qpopupmenu.h> |
19 | #include <qfile.h> | 19 | #include <qfile.h> |
20 | 20 | ||
21 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 21 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
22 | const QString&fsize,int num,const QValueList<int>&path) | 22 | const QString&fsize,int num,const QValueList<int>&path) |
23 | : QListViewItem(parent,after),_partNum(num) | 23 | : QListViewItem(parent,after),_partNum(num) |
24 | { | 24 | { |
25 | _path=path; | 25 | _path=path; |
26 | setText(0, mime); | 26 | setText(0, mime); |
27 | setText(1, desc); | 27 | setText(1, desc); |
28 | setText(2, file); | 28 | setText(2, file); |
29 | setText(3, fsize); | 29 | setText(3, fsize); |
30 | } | 30 | } |
31 | 31 | ||
32 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 32 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
33 | const QString&fsize,int num,const QValueList<int>&path) | 33 | const QString&fsize,int num,const QValueList<int>&path) |
34 | : QListViewItem(parent,after),_partNum(num) | 34 | : QListViewItem(parent,after),_partNum(num) |
35 | { | 35 | { |
36 | _path=path; | 36 | _path=path; |
37 | setText(0, mime); | 37 | setText(0, mime); |
38 | setText(1, desc); | 38 | setText(1, desc); |
39 | setText(2, file); | 39 | setText(2, file); |
40 | setText(3, fsize); | 40 | setText(3, fsize); |
41 | } | 41 | } |
42 | 42 | ||
43 | bool AttachItem::isParentof(const QValueList<int>&path) | 43 | bool AttachItem::isParentof(const QValueList<int>&path) |
44 | { | 44 | { |
45 | /* if not set, then no parent */ | 45 | /* if not set, then no parent */ |
46 | if (path.count()==0||_path.count()==0) return false; | 46 | if (path.count()==0||_path.count()==0) return false; |
47 | /* the parent must have one digit less then a child */ | 47 | /* the parent must have one digit less then a child */ |
48 | if (path.count()!=_path.count()+1) return false; | 48 | if (path.count()!=_path.count()+1) return false; |
49 | for (unsigned int i=0; i < _path.count();++i) | 49 | for (unsigned int i=0; i < _path.count();++i) |
50 | { | 50 | { |
51 | if (_path[i]!=path[i]) return false; | 51 | if (_path[i]!=path[i]) return false; |
52 | } | 52 | } |
53 | return true; | 53 | return true; |
54 | } | 54 | } |
55 | 55 | ||
56 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) | 56 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) |
57 | { | 57 | { |
58 | QListViewItemIterator it( attachments ); | 58 | QListViewItemIterator it( attachments ); |
59 | for ( ; it.current(); ++it ) | 59 | for ( ; it.current(); ++it ) |
60 | { | 60 | { |
61 | AttachItem*ati = (AttachItem*)it.current(); | 61 | AttachItem*ati = (AttachItem*)it.current(); |
62 | if (ati->isParentof(path)) return ati; | 62 | if (ati->isParentof(path)) return ati; |
63 | } | 63 | } |
64 | return 0; | 64 | return 0; |
65 | } | 65 | } |
66 | 66 | ||
67 | AttachItem* ViewMail::lastChild(AttachItem*parent) | 67 | AttachItem* ViewMail::lastChild(AttachItem*parent) |
68 | { | 68 | { |
69 | if (!parent) return 0; | 69 | if (!parent) return 0; |
70 | AttachItem* item = (AttachItem*)parent->firstChild(); | 70 | AttachItem* item = (AttachItem*)parent->firstChild(); |
71 | if (!item) return item; | 71 | if (!item) return item; |
72 | AttachItem*temp=0; | 72 | AttachItem*temp=0; |
73 | while( (temp=(AttachItem*)item->nextSibling())) | 73 | while( (temp=(AttachItem*)item->nextSibling())) |
74 | { | 74 | { |
75 | item = temp; | 75 | item = temp; |
76 | } | 76 | } |
77 | return item; | 77 | return item; |
78 | } | 78 | } |
79 | 79 | ||
80 | void ViewMail::setBody( RecBody body ) | 80 | void ViewMail::setBody( RecBody body ) |
81 | { | 81 | { |
82 | 82 | ||
83 | m_body = body; | 83 | m_body = body; |
84 | m_mail[2] = body.Bodytext(); | 84 | m_mail[2] = body.Bodytext(); |
85 | attachbutton->setEnabled(body.Parts().count()>0); | 85 | attachbutton->setEnabled(body.Parts().count()>0); |
86 | attachments->setEnabled(body.Parts().count()>0); | 86 | attachments->setEnabled(body.Parts().count()>0); |
87 | if (body.Parts().count()==0) | 87 | if (body.Parts().count()==0) |
88 | { | 88 | { |
89 | return; | 89 | return; |
90 | } | 90 | } |
91 | AttachItem * curItem=0; | 91 | AttachItem * curItem=0; |
92 | AttachItem * parentItem = 0; | 92 | AttachItem * parentItem = 0; |
93 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); | 93 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); |
94 | QString desc,fsize; | 94 | QString desc,fsize; |
95 | double s = body.Description().Size(); | 95 | double s = body.Description().Size(); |
96 | int w; | 96 | int w; |
97 | w=0; | 97 | w=0; |
98 | 98 | ||
99 | while (s>1024) | 99 | while (s>1024) |
100 | { | 100 | { |
101 | s/=1024; | 101 | s/=1024; |
102 | ++w; | 102 | ++w; |
103 | if (w>=2) break; | 103 | if (w>=2) break; |
104 | } | 104 | } |
105 | 105 | ||
106 | QString q=""; | 106 | QString q=""; |
107 | switch(w) | 107 | switch(w) |
108 | { | 108 | { |
109 | case 1: | 109 | case 1: |
110 | q="k"; | 110 | q="k"; |
111 | break; | 111 | break; |
112 | case 2: | 112 | case 2: |
113 | q="M"; | 113 | q="M"; |
114 | break; | 114 | break; |
115 | default: | 115 | default: |
116 | break; | 116 | break; |
117 | } | 117 | } |
118 | 118 | ||
119 | { | 119 | { |
120 | /* I did not found a method to make a CONTENT reset on a QTextStream | 120 | /* I did not found a method to make a CONTENT reset on a QTextStream |
121 | so I use this construct that the stream will re-constructed in each | 121 | so I use this construct that the stream will re-constructed in each |
122 | loop. To let it work, the textstream is packed into a own area of | 122 | loop. To let it work, the textstream is packed into a own area of |
123 | code is it will be destructed after finishing its small job. | 123 | code is it will be destructed after finishing its small job. |
124 | */ | 124 | */ |
125 | QTextOStream o(&fsize); | 125 | QTextOStream o(&fsize); |
126 | if (w>0) o.precision(2); else o.precision(0); | 126 | if (w>0) o.precision(2); else o.precision(0); |
127 | o.setf(QTextStream::fixed); | 127 | o.setf(QTextStream::fixed); |
128 | o << s << " " << q << "Byte"; | 128 | o << s << " " << q << "Byte"; |
129 | } | 129 | } |
130 | 130 | ||
131 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist()); | 131 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist()); |
132 | QString filename = ""; | 132 | QString filename = ""; |
133 | 133 | ||
134 | for (unsigned int i = 0; i < body.Parts().count();++i) | 134 | for (unsigned int i = 0; i < body.Parts().count();++i) |
135 | { | 135 | { |
136 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); | 136 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); |
137 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); | 137 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); |
138 | for (;it!=body.Parts()[i].Parameters().end();++it) | 138 | for (;it!=body.Parts()[i].Parameters().end();++it) |
139 | { | 139 | { |
140 | qDebug(it.key()); | 140 | qDebug(it.key()); |
141 | if (it.key().lower()=="name") | 141 | if (it.key().lower()=="name") |
142 | { | 142 | { |
143 | filename=it.data(); | 143 | filename=it.data(); |
144 | } | 144 | } |
145 | } | 145 | } |
146 | s = body.Parts()[i].Size(); | 146 | s = body.Parts()[i].Size(); |
147 | w = 0; | 147 | w = 0; |
148 | while (s>1024) | 148 | while (s>1024) |
149 | { | 149 | { |
150 | s/=1024; | 150 | s/=1024; |
151 | ++w; | 151 | ++w; |
152 | if (w>=2) break; | 152 | if (w>=2) break; |
153 | } | 153 | } |
154 | switch(w) | 154 | switch(w) |
155 | { | 155 | { |
156 | case 1: | 156 | case 1: |
157 | q="k"; | 157 | q="k"; |
158 | break; | 158 | break; |
159 | case 2: | 159 | case 2: |
160 | q="M"; | 160 | q="M"; |
161 | break; | 161 | break; |
162 | default: | 162 | default: |
163 | q=""; | 163 | q=""; |
164 | break; | 164 | break; |
165 | } | 165 | } |
166 | QTextOStream o(&fsize); | 166 | QTextOStream o(&fsize); |
167 | if (w>0) o.precision(2); else o.precision(0); | 167 | if (w>0) o.precision(2); else o.precision(0); |
168 | o.setf(QTextStream::fixed); | 168 | o.setf(QTextStream::fixed); |
169 | o << s << " " << q << "Byte"; | 169 | o << s << " " << q << "Byte"; |
170 | desc = body.Parts()[i].Description(); | 170 | desc = body.Parts()[i].Description(); |
171 | parentItem = searchParent(body.Parts()[i].Positionlist()); | 171 | parentItem = searchParent(body.Parts()[i].Positionlist()); |
172 | if (parentItem) | 172 | if (parentItem) |
173 | { | 173 | { |
174 | AttachItem*temp = lastChild(parentItem); | 174 | AttachItem*temp = lastChild(parentItem); |
175 | if (temp) curItem = temp; | 175 | if (temp) curItem = temp; |
176 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); | 176 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); |
177 | attachments->setRootIsDecorated(true); | 177 | attachments->setRootIsDecorated(true); |
178 | curItem = parentItem; | 178 | curItem = parentItem; |
179 | } | 179 | } |
180 | else | 180 | else |
181 | { | 181 | { |
182 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); | 182 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); |
183 | } | 183 | } |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | 187 | ||
188 | void ViewMail::slotShowHtml( bool state ) | 188 | void ViewMail::slotShowHtml( bool state ) |
189 | { | 189 | { |
190 | m_showHtml = state; | 190 | m_showHtml = state; |
191 | setText(); | 191 | setText(); |
192 | } | 192 | } |
193 | 193 | ||
194 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) | 194 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) |
195 | { | 195 | { |
196 | if (!item ) | 196 | if (!item ) |
197 | return; | 197 | return; |
198 | 198 | ||
199 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 199 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
200 | { | 200 | { |
201 | setText(); | 201 | setText(); |
202 | return; | 202 | return; |
203 | } | 203 | } |
204 | QPopupMenu *menu = new QPopupMenu(); | 204 | QPopupMenu *menu = new QPopupMenu(); |
205 | int ret=0; | 205 | int ret=0; |
206 | 206 | ||
207 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) | 207 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) |
208 | { | 208 | { |
209 | menu->insertItem( tr( "Show Text" ), 1 ); | 209 | menu->insertItem( tr( "Show Text" ), 1 ); |
210 | } | 210 | } |
211 | menu->insertItem( tr( "Save Attachment" ), 0 ); | 211 | menu->insertItem( tr( "Save Attachment" ), 0 ); |
212 | menu->insertSeparator(1); | 212 | menu->insertSeparator(1); |
213 | 213 | ||
214 | ret = menu->exec( point, 0 ); | 214 | ret = menu->exec( point, 0 ); |
215 | 215 | ||
216 | switch(ret) | 216 | switch(ret) |
217 | { | 217 | { |
218 | case 0: | 218 | case 0: |
219 | { | 219 | { |
220 | MimeTypes types; | 220 | MimeTypes types; |
221 | types.insert( "all", "*" ); | 221 | types.insert( "all", "*" ); |
222 | QString str = Opie::OFileDialog::getSaveFileName( 1, | 222 | QString str = Opie::OFileDialog::getSaveFileName( 1, |
223 | "/", item->text( 2 ) , types, 0 ); | 223 | "/", item->text( 2 ) , types, 0 ); |
224 | 224 | ||
225 | if( !str.isEmpty() ) | 225 | if( !str.isEmpty() ) |
226 | { | 226 | { |
227 | encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 227 | encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
228 | if (content) | 228 | if (content) |
229 | { | 229 | { |
230 | QFile output(str); | 230 | QFile output(str); |
231 | output.open(IO_WriteOnly); | 231 | output.open(IO_WriteOnly); |
232 | output.writeBlock(content->Content(),content->Length()); | 232 | output.writeBlock(content->Content(),content->Length()); |
233 | output.close(); | 233 | output.close(); |
234 | delete content; | 234 | delete content; |
235 | } | 235 | } |
236 | } | 236 | } |
237 | } | 237 | } |
238 | break ; | 238 | break ; |
239 | 239 | ||
240 | case 1: | 240 | case 1: |
241 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 241 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
242 | { | 242 | { |
243 | setText(); | 243 | setText(); |
244 | } | 244 | } |
245 | else | 245 | else |
246 | { | 246 | { |
247 | if ( m_recMail.Wrapper() != 0l ) | 247 | if ( m_recMail.Wrapper() != 0l ) |
248 | { // make sure that there is a wrapper , even after delete or simular actions | 248 | { // make sure that there is a wrapper , even after delete or simular actions |
249 | browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 249 | browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
250 | } | 250 | } |
251 | } | 251 | } |
252 | break; | 252 | break; |
253 | } | 253 | } |
254 | delete menu; | 254 | delete menu; |
255 | } | 255 | } |
256 | 256 | ||
257 | 257 | ||
258 | void ViewMail::setMail( RecMail mail ) | 258 | void ViewMail::setMail( RecMail mail ) |
259 | { | 259 | { |
260 | 260 | ||
261 | m_recMail = mail; | 261 | m_recMail = mail; |
262 | 262 | ||
263 | m_mail[0] = mail.getFrom(); | 263 | m_mail[0] = mail.getFrom(); |
264 | m_mail[1] = mail.getSubject(); | 264 | m_mail[1] = mail.getSubject(); |
265 | m_mail[3] = mail.getDate(); | 265 | m_mail[3] = mail.getDate(); |
266 | m_mail[4] = mail.Msgid(); | 266 | m_mail[4] = mail.Msgid(); |
267 | 267 | ||
268 | m_mail2[0] = mail.To(); | 268 | m_mail2[0] = mail.To(); |
269 | m_mail2[1] = mail.CC(); | 269 | m_mail2[1] = mail.CC(); |
270 | m_mail2[2] = mail.Bcc(); | 270 | m_mail2[2] = mail.Bcc(); |
271 | 271 | ||
272 | setText(); | 272 | setText(); |
273 | } | 273 | } |
274 | 274 | ||
275 | 275 | ||
276 | 276 | ||
277 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 277 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
278 | : ViewMailBase(parent, name, fl), _inLoop(false) | 278 | : ViewMailBase(parent, name, fl), _inLoop(false) |
279 | { | 279 | { |
280 | m_gotBody = false; | 280 | m_gotBody = false; |
281 | deleted = false; | 281 | deleted = false; |
282 | 282 | ||
283 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); | 283 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
284 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); | 284 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); |
285 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); | 285 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); |
286 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); | 286 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); |
287 | 287 | ||
288 | attachments->setEnabled(m_gotBody); | 288 | attachments->setEnabled(m_gotBody); |
289 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); | 289 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); |
290 | 290 | ||
291 | readConfig(); | 291 | readConfig(); |
292 | attachments->setSorting(-1); | 292 | attachments->setSorting(-1); |
293 | } | 293 | } |
294 | 294 | ||
295 | void ViewMail::readConfig() | 295 | void ViewMail::readConfig() |
296 | { | 296 | { |
297 | Config cfg( "mail" ); | 297 | Config cfg( "mail" ); |
298 | cfg.setGroup( "Settings" ); | 298 | cfg.setGroup( "Settings" ); |
299 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); | 299 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); |
300 | showHtml->setOn( m_showHtml ); | 300 | showHtml->setOn( m_showHtml ); |
301 | } | 301 | } |
302 | 302 | ||
303 | void ViewMail::setText() | 303 | void ViewMail::setText() |
304 | { | 304 | { |
305 | 305 | ||
306 | QString toString; | 306 | QString toString; |
307 | QString ccString; | 307 | QString ccString; |
308 | QString bccString; | 308 | QString bccString; |
309 | 309 | ||
310 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) | 310 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) |
311 | { | 311 | { |
312 | toString += (*it); | 312 | toString += (*it); |
313 | } | 313 | } |
314 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) | 314 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) |
315 | { | 315 | { |
316 | ccString += (*it); | 316 | ccString += (*it); |
317 | } | 317 | } |
318 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) | 318 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) |
319 | { | 319 | { |
320 | bccString += (*it); | 320 | bccString += (*it); |
321 | } | 321 | } |
322 | 322 | ||
323 | setCaption( caption().arg( m_mail[0] ) ); | 323 | setCaption( caption().arg( m_mail[0] ) ); |
324 | 324 | ||
325 | m_mailHtml = "<html><body>" | 325 | m_mailHtml = "<html><body>" |
326 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 326 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
327 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 327 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
328 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 328 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
329 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 329 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
330 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 330 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
331 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 331 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
332 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + | 332 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + |
333 | "</td></tr></table><font face=fixed>"; | 333 | "</td></tr></table><font face=fixed>"; |
334 | 334 | ||
335 | if ( !m_showHtml ) | 335 | if ( !m_showHtml ) |
336 | { | 336 | { |
337 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 337 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
338 | } | 338 | } |
339 | else | 339 | else |
340 | { | 340 | { |
341 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); | 341 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); |
342 | } | 342 | } |
343 | // remove later in favor of a real handling | 343 | // remove later in favor of a real handling |
344 | m_gotBody = true; | 344 | m_gotBody = true; |
345 | } | 345 | } |
346 | 346 | ||
347 | 347 | ||
348 | ViewMail::~ViewMail() | 348 | ViewMail::~ViewMail() |
349 | { | 349 | { |
350 | m_recMail.Wrapper()->cleanMimeCache(); | 350 | m_recMail.Wrapper()->cleanMimeCache(); |
351 | hide(); | 351 | hide(); |
352 | } | 352 | } |
353 | 353 | ||
354 | void ViewMail::hide() | 354 | void ViewMail::hide() |
355 | { | 355 | { |
356 | QWidget::hide(); | 356 | QWidget::hide(); |
357 | 357 | ||
358 | if (_inLoop) | 358 | if (_inLoop) |
359 | { | 359 | { |
360 | _inLoop = false; | 360 | _inLoop = false; |
361 | qApp->exit_loop(); | 361 | qApp->exit_loop(); |
362 | 362 | ||
363 | } | 363 | } |
364 | 364 | ||
365 | } | 365 | } |
366 | 366 | ||
367 | void ViewMail::exec() | 367 | void ViewMail::exec() |
368 | { | 368 | { |
369 | show(); | 369 | show(); |
370 | 370 | ||
371 | if (!_inLoop) | 371 | if (!_inLoop) |
372 | { | 372 | { |
373 | _inLoop = true; | 373 | _inLoop = true; |
374 | qApp->enter_loop(); | 374 | qApp->enter_loop(); |
375 | } | 375 | } |
376 | 376 | ||
377 | } | 377 | } |
378 | 378 | ||
379 | QString ViewMail::deHtml(const QString &string) | 379 | QString ViewMail::deHtml(const QString &string) |
380 | { | 380 | { |
381 | QString string_ = string; | 381 | QString string_ = string; |
382 | string_.replace(QRegExp("&"), "&"); | 382 | string_.replace(QRegExp("&"), "&"); |
383 | string_.replace(QRegExp("<"), "<"); | 383 | string_.replace(QRegExp("<"), "<"); |
384 | string_.replace(QRegExp(">"), ">"); | 384 | string_.replace(QRegExp(">"), ">"); |
385 | string_.replace(QRegExp("\\n"), "<br>"); | 385 | string_.replace(QRegExp("\\n"), "<br>"); |
386 | return string_; | 386 | return string_; |
387 | } | 387 | } |
388 | 388 | ||
389 | void ViewMail::slotReply() | 389 | void ViewMail::slotReply() |
390 | { | 390 | { |
391 | if (!m_gotBody) | 391 | if (!m_gotBody) |
392 | { | 392 | { |
393 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 393 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); |
394 | return; | 394 | return; |
395 | } | 395 | } |
396 | 396 | ||
397 | QString rtext; | 397 | QString rtext; |
398 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 398 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
399 | .arg( m_mail[0] ) | 399 | .arg( m_mail[0] ) |
400 | .arg( m_mail[3] ); | 400 | .arg( m_mail[3] ); |
401 | 401 | ||
402 | QString text = m_mail[2]; | 402 | QString text = m_mail[2]; |
403 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 403 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
404 | QStringList::Iterator it; | 404 | QStringList::Iterator it; |
405 | for (it = lines.begin(); it != lines.end(); it++) | 405 | for (it = lines.begin(); it != lines.end(); it++) |
406 | { | 406 | { |
407 | rtext += "> " + *it + "\n"; | 407 | rtext += "> " + *it + "\n"; |
408 | } | 408 | } |
409 | rtext += "\n"; | 409 | rtext += "\n"; |
410 | 410 | ||
411 | QString prefix; | 411 | QString prefix; |
412 | if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; | 412 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
413 | else prefix = "Re: "; // no i18n on purpose | 413 | else prefix = "Re: "; // no i18n on purpose |
414 | 414 | ||
415 | Settings *settings = new Settings(); | 415 | Settings *settings = new Settings(); |
416 | ComposeMail composer( settings ,this, 0, true); | 416 | ComposeMail composer( settings ,this, 0, true); |
417 | composer.setTo( m_mail[0] ); | 417 | composer.setTo( m_mail[0] ); |
418 | composer.setSubject( "Re: " + m_mail[1] ); | 418 | composer.setSubject( prefix + m_mail[1] ); |
419 | composer.setMessage( rtext ); | 419 | composer.setMessage( rtext ); |
420 | composer.setInReplyTo(m_recMail.Msgid()); | ||
421 | |||
420 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) ) | 422 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) ) |
421 | { | 423 | { |
422 | m_recMail.Wrapper()->answeredMail(m_recMail); | 424 | m_recMail.Wrapper()->answeredMail(m_recMail); |
423 | } | 425 | } |
424 | } | 426 | } |
425 | 427 | ||
426 | void ViewMail::slotForward() | 428 | void ViewMail::slotForward() |
427 | { | 429 | { |
428 | if (!m_gotBody) | 430 | if (!m_gotBody) |
429 | { | 431 | { |
430 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); | 432 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); |
431 | return; | 433 | return; |
432 | } | 434 | } |
433 | 435 | ||
434 | QString ftext; | 436 | QString ftext; |
435 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 437 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
436 | .arg( m_mail[0] ); | 438 | .arg( m_mail[0] ); |
437 | if (!m_mail[3].isNull()) | 439 | if (!m_mail[3].isNull()) |
438 | ftext += QString("Date: %1\n") | 440 | ftext += QString("Date: %1\n") |
439 | .arg( m_mail[3] ); | 441 | .arg( m_mail[3] ); |
440 | if (!m_mail[0].isNull()) | 442 | if (!m_mail[0].isNull()) |
441 | ftext += QString("From: %1\n") | 443 | ftext += QString("From: %1\n") |
442 | .arg( m_mail[0] ); | 444 | .arg( m_mail[0] ); |
443 | if (!m_mail[1].isNull()) | 445 | if (!m_mail[1].isNull()) |
444 | ftext += QString("Subject: %1\n") | 446 | ftext += QString("Subject: %1\n") |
445 | .arg( m_mail[1] ); | 447 | .arg( m_mail[1] ); |
446 | 448 | ||
447 | ftext += QString("\n%1\n") | 449 | ftext += QString("\n%1\n") |
448 | .arg( m_mail[2]); | 450 | .arg( m_mail[2]); |
449 | 451 | ||
450 | ftext += QString("----- End forwarded message -----\n"); | 452 | ftext += QString("----- End forwarded message -----\n"); |
451 | 453 | ||
452 | Settings *settings = new Settings(); | 454 | Settings *settings = new Settings(); |
453 | ComposeMail composer( settings ,this, 0, true); | 455 | ComposeMail composer( settings ,this, 0, true); |
454 | composer.setSubject( "Fwd: " + m_mail[1] ); | 456 | composer.setSubject( "Fwd: " + m_mail[1] ); |
455 | composer.setMessage( ftext ); | 457 | composer.setMessage( ftext ); |
456 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer )) | 458 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer )) |
457 | { | 459 | { |
458 | } | 460 | } |
459 | } | 461 | } |
460 | 462 | ||
461 | void ViewMail::slotDeleteMail( ) | 463 | void ViewMail::slotDeleteMail( ) |
462 | { | 464 | { |
463 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 465 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
464 | { | 466 | { |
465 | m_recMail.Wrapper()->deleteMail( m_recMail ); | 467 | m_recMail.Wrapper()->deleteMail( m_recMail ); |
466 | hide(); | 468 | hide(); |
467 | deleted = true; | 469 | deleted = true; |
468 | } | 470 | } |
469 | } | 471 | } |