author | alwin <alwin> | 2004-02-19 13:42:40 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-02-19 13:42:40 (UTC) |
commit | c2eb77f6b8933b02bd8bd59ec7325da0bfc956cb (patch) (unidiff) | |
tree | 41cd0ca977bcec1f8bc3ad44f128d73324724388 | |
parent | 51992ef09a92db868234936484fcc3aec0d2d4ad (diff) | |
download | opie-c2eb77f6b8933b02bd8bd59ec7325da0bfc956cb.zip opie-c2eb77f6b8933b02bd8bd59ec7325da0bfc956cb.tar.gz opie-c2eb77f6b8933b02bd8bd59ec7325da0bfc956cb.tar.bz2 |
use stuff from libopie2
ToDo: after merge pim-classes to opie2, do the same with it.
-rw-r--r-- | noncore/net/mail/composemail.cpp | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/libmailwrapper.control | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mhwrapper.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mail/mail.pro | 4 | ||||
-rw-r--r-- | noncore/net/mail/main.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mail/opie-mail.control | 4 | ||||
-rw-r--r-- | noncore/net/mail/taskbarapplet/mailapplet.cpp | 4 | ||||
-rw-r--r-- | noncore/net/mail/taskbarapplet/opie-mailapplet.control | 4 | ||||
-rw-r--r-- | noncore/net/mail/taskbarapplet/taskbarapplet.pro | 2 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 4 |
10 files changed, 17 insertions, 17 deletions
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp index abcc3f6..6708779 100644 --- a/noncore/net/mail/composemail.cpp +++ b/noncore/net/mail/composemail.cpp | |||
@@ -1,240 +1,240 @@ | |||
1 | #include <qt.h> | 1 | #include <qt.h> |
2 | 2 | ||
3 | #include <opie/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 | 17 | ||
18 | QString vfilename = Global::applicationFileName("addressbook", | 18 | QString vfilename = Global::applicationFileName("addressbook", |
19 | "businesscard.vcf"); | 19 | "businesscard.vcf"); |
20 | Contact c; | 20 | Contact c; |
21 | if (QFile::exists(vfilename)) { | 21 | if (QFile::exists(vfilename)) { |
22 | c = Contact::readVCard( vfilename )[0]; | 22 | c = Contact::readVCard( vfilename )[0]; |
23 | } | 23 | } |
24 | 24 | ||
25 | QStringList mails = c.emailList(); | 25 | QStringList mails = c.emailList(); |
26 | QString defmail = c.defaultEmail(); | 26 | QString defmail = c.defaultEmail(); |
27 | 27 | ||
28 | if (defmail.length()!=0) { | 28 | if (defmail.length()!=0) { |
29 | fromBox->insertItem(defmail); | 29 | fromBox->insertItem(defmail); |
30 | } | 30 | } |
31 | QStringList::ConstIterator sit = mails.begin(); | 31 | QStringList::ConstIterator sit = mails.begin(); |
32 | for (;sit!=mails.end();++sit) { | 32 | for (;sit!=mails.end();++sit) { |
33 | if ( (*sit)==defmail) | 33 | if ( (*sit)==defmail) |
34 | continue; | 34 | continue; |
35 | fromBox->insertItem((*sit)); | 35 | fromBox->insertItem((*sit)); |
36 | } | 36 | } |
37 | senderNameEdit->setText(c.firstName()+" "+c.lastName()); | 37 | senderNameEdit->setText(c.firstName()+" "+c.lastName()); |
38 | Config cfg( "mail" ); | 38 | Config cfg( "mail" ); |
39 | cfg.setGroup( "Compose" ); | 39 | cfg.setGroup( "Compose" ); |
40 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); | 40 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); |
41 | 41 | ||
42 | attList->addColumn( tr( "Name" ) ); | 42 | attList->addColumn( tr( "Name" ) ); |
43 | attList->addColumn( tr( "Size" ) ); | 43 | attList->addColumn( tr( "Size" ) ); |
44 | 44 | ||
45 | QList<Account> accounts = settings->getAccounts(); | 45 | QList<Account> accounts = settings->getAccounts(); |
46 | 46 | ||
47 | Account *it; | 47 | Account *it; |
48 | for ( it = accounts.first(); it; it = accounts.next() ) { | 48 | for ( it = accounts.first(); it; it = accounts.next() ) { |
49 | if ( it->getType().compare( "SMTP" ) == 0 ) { | 49 | if ( it->getType().compare( "SMTP" ) == 0 ) { |
50 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); | 50 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); |
51 | smtpAccountBox->insertItem( smtp->getAccountName() ); | 51 | smtpAccountBox->insertItem( smtp->getAccountName() ); |
52 | smtpAccounts.append( smtp ); | 52 | smtpAccounts.append( smtp ); |
53 | } | 53 | } |
54 | } | 54 | } |
55 | 55 | ||
56 | if ( smtpAccounts.count() > 0 ) { | 56 | if ( smtpAccounts.count() > 0 ) { |
57 | fillValues( smtpAccountBox->currentItem() ); | 57 | fillValues( smtpAccountBox->currentItem() ); |
58 | } else { | 58 | } else { |
59 | QMessageBox::information( this, tr( "Problem" ), | 59 | QMessageBox::information( this, tr( "Problem" ), |
60 | tr( "<p>Please create an SMTP account first.</p>" ), | 60 | tr( "<p>Please create an SMTP account first.</p>" ), |
61 | tr( "Ok" ) ); | 61 | tr( "Ok" ) ); |
62 | return; | 62 | return; |
63 | } | 63 | } |
64 | 64 | ||
65 | connect( smtpAccountBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) ); | 65 | connect( smtpAccountBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) ); |
66 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); | 66 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); |
67 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); | 67 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); |
68 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); | 68 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); |
69 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); | 69 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); |
70 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); | 70 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); |
71 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); | 71 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); |
72 | } | 72 | } |
73 | 73 | ||
74 | void ComposeMail::pickAddress( QLineEdit *line ) | 74 | void ComposeMail::pickAddress( QLineEdit *line ) |
75 | { | 75 | { |
76 | QString names = AddressPicker::getNames(); | 76 | QString names = AddressPicker::getNames(); |
77 | if ( line->text().isEmpty() ) { | 77 | if ( line->text().isEmpty() ) { |
78 | line->setText( names ); | 78 | line->setText( names ); |
79 | } else if ( !names.isEmpty() ) { | 79 | } else if ( !names.isEmpty() ) { |
80 | line->setText( line->text() + ", " + names ); | 80 | line->setText( line->text() + ", " + names ); |
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||
84 | 84 | ||
85 | void ComposeMail::setTo( const QString & to ) | 85 | void ComposeMail::setTo( const QString & to ) |
86 | { | 86 | { |
87 | /* QString toline; | 87 | /* QString toline; |
88 | QStringList toEntry = to; | 88 | QStringList toEntry = to; |
89 | for ( QStringList::Iterator it = toEntry.begin(); it != toEntry.end(); ++it ) { | 89 | for ( QStringList::Iterator it = toEntry.begin(); it != toEntry.end(); ++it ) { |
90 | toline += (*it); | 90 | toline += (*it); |
91 | } | 91 | } |
92 | toLine->setText( toline ); | 92 | toLine->setText( toline ); |
93 | */ | 93 | */ |
94 | toLine->setText( to ); | 94 | toLine->setText( to ); |
95 | } | 95 | } |
96 | 96 | ||
97 | void ComposeMail::setSubject( const QString & subject ) | 97 | void ComposeMail::setSubject( const QString & subject ) |
98 | { | 98 | { |
99 | subjectLine->setText( subject ); | 99 | subjectLine->setText( subject ); |
100 | } | 100 | } |
101 | 101 | ||
102 | void ComposeMail::setInReplyTo( const QString & messageId ) | 102 | void ComposeMail::setInReplyTo( const QString & messageId ) |
103 | { | 103 | { |
104 | 104 | ||
105 | } | 105 | } |
106 | 106 | ||
107 | void ComposeMail::setMessage( const QString & text ) | 107 | void ComposeMail::setMessage( const QString & text ) |
108 | { | 108 | { |
109 | message->setText( text ); | 109 | message->setText( text ); |
110 | } | 110 | } |
111 | 111 | ||
112 | 112 | ||
113 | void ComposeMail::pickAddressTo() | 113 | void ComposeMail::pickAddressTo() |
114 | { | 114 | { |
115 | pickAddress( toLine ); | 115 | pickAddress( toLine ); |
116 | } | 116 | } |
117 | 117 | ||
118 | void ComposeMail::pickAddressCC() | 118 | void ComposeMail::pickAddressCC() |
119 | { | 119 | { |
120 | pickAddress( ccLine ); | 120 | pickAddress( ccLine ); |
121 | } | 121 | } |
122 | 122 | ||
123 | void ComposeMail::pickAddressBCC() | 123 | void ComposeMail::pickAddressBCC() |
124 | { | 124 | { |
125 | pickAddress( bccLine ); | 125 | pickAddress( bccLine ); |
126 | } | 126 | } |
127 | 127 | ||
128 | void ComposeMail::pickAddressReply() | 128 | void ComposeMail::pickAddressReply() |
129 | { | 129 | { |
130 | pickAddress( replyLine ); | 130 | pickAddress( replyLine ); |
131 | } | 131 | } |
132 | 132 | ||
133 | void ComposeMail::fillValues( int current ) | 133 | void ComposeMail::fillValues( int current ) |
134 | { | 134 | { |
135 | #if 0 | 135 | #if 0 |
136 | SMTPaccount *smtp = smtpAccounts.at( current ); | 136 | SMTPaccount *smtp = smtpAccounts.at( current ); |
137 | ccLine->clear(); | 137 | ccLine->clear(); |
138 | if ( smtp->getUseCC() ) { | 138 | if ( smtp->getUseCC() ) { |
139 | ccLine->setText( smtp->getCC() ); | 139 | ccLine->setText( smtp->getCC() ); |
140 | } | 140 | } |
141 | bccLine->clear(); | 141 | bccLine->clear(); |
142 | if ( smtp->getUseBCC() ) { | 142 | if ( smtp->getUseBCC() ) { |
143 | bccLine->setText( smtp->getBCC() ); | 143 | bccLine->setText( smtp->getBCC() ); |
144 | } | 144 | } |
145 | replyLine->clear(); | 145 | replyLine->clear(); |
146 | if ( smtp->getUseReply() ) { | 146 | if ( smtp->getUseReply() ) { |
147 | replyLine->setText( smtp->getReply() ); | 147 | replyLine->setText( smtp->getReply() ); |
148 | } | 148 | } |
149 | sigMultiLine->setText( smtp->getSignature() ); | 149 | sigMultiLine->setText( smtp->getSignature() ); |
150 | #endif | 150 | #endif |
151 | } | 151 | } |
152 | 152 | ||
153 | void ComposeMail::slotAdjustColumns() | 153 | void ComposeMail::slotAdjustColumns() |
154 | { | 154 | { |
155 | int currPage = tabWidget->currentPageIndex(); | 155 | int currPage = tabWidget->currentPageIndex(); |
156 | 156 | ||
157 | tabWidget->showPage( attachTab ); | 157 | tabWidget->showPage( attachTab ); |
158 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); | 158 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); |
159 | attList->setColumnWidth( 1, 80 ); | 159 | attList->setColumnWidth( 1, 80 ); |
160 | 160 | ||
161 | tabWidget->setCurrentPage( currPage ); | 161 | tabWidget->setCurrentPage( currPage ); |
162 | } | 162 | } |
163 | 163 | ||
164 | void ComposeMail::addAttachment() | 164 | void ComposeMail::addAttachment() |
165 | { | 165 | { |
166 | DocLnk lnk = OFileDialog::getOpenFileName( 1, "/" ); | 166 | DocLnk lnk = Opie::OFileDialog::getOpenFileName( 1, "/" ); |
167 | if ( !lnk.name().isEmpty() ) { | 167 | if ( !lnk.name().isEmpty() ) { |
168 | Attachment *att = new Attachment( lnk ); | 168 | Attachment *att = new Attachment( lnk ); |
169 | (void) new AttachViewItem( attList, att ); | 169 | (void) new AttachViewItem( attList, att ); |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | void ComposeMail::removeAttachment() | 173 | void ComposeMail::removeAttachment() |
174 | { | 174 | { |
175 | if ( !attList->currentItem() ) { | 175 | if ( !attList->currentItem() ) { |
176 | QMessageBox::information( this, tr( "Error" ), | 176 | QMessageBox::information( this, tr( "Error" ), |
177 | tr( "<p>Please select a File.</p>" ), | 177 | tr( "<p>Please select a File.</p>" ), |
178 | tr( "Ok" ) ); | 178 | tr( "Ok" ) ); |
179 | } else { | 179 | } else { |
180 | attList->takeItem( attList->currentItem() ); | 180 | attList->takeItem( attList->currentItem() ); |
181 | } | 181 | } |
182 | } | 182 | } |
183 | 183 | ||
184 | void ComposeMail::accept() | 184 | void ComposeMail::accept() |
185 | { | 185 | { |
186 | if ( checkBoxLater->isChecked() ) { | 186 | if ( checkBoxLater->isChecked() ) { |
187 | qDebug( "Send later" ); | 187 | qDebug( "Send later" ); |
188 | } | 188 | } |
189 | 189 | ||
190 | #if 0 | 190 | #if 0 |
191 | qDebug( "Sending Mail with " + | 191 | qDebug( "Sending Mail with " + |
192 | smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); | 192 | smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); |
193 | #endif | 193 | #endif |
194 | Mail *mail = new Mail(); | 194 | Mail *mail = new Mail(); |
195 | 195 | ||
196 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); | 196 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); |
197 | mail->setMail(fromBox->currentText()); | 197 | mail->setMail(fromBox->currentText()); |
198 | 198 | ||
199 | if ( !toLine->text().isEmpty() ) { | 199 | if ( !toLine->text().isEmpty() ) { |
200 | mail->setTo( toLine->text() ); | 200 | mail->setTo( toLine->text() ); |
201 | } else { | 201 | } else { |
202 | qDebug( "No Reciever spezified -> returning" ); | 202 | qDebug( "No Reciever spezified -> returning" ); |
203 | return; | 203 | return; |
204 | } | 204 | } |
205 | mail->setName(senderNameEdit->text()); | 205 | mail->setName(senderNameEdit->text()); |
206 | mail->setCC( ccLine->text() ); | 206 | mail->setCC( ccLine->text() ); |
207 | mail->setBCC( bccLine->text() ); | 207 | mail->setBCC( bccLine->text() ); |
208 | mail->setReply( replyLine->text() ); | 208 | mail->setReply( replyLine->text() ); |
209 | mail->setSubject( subjectLine->text() ); | 209 | mail->setSubject( subjectLine->text() ); |
210 | QString txt = message->text(); | 210 | QString txt = message->text(); |
211 | if ( !sigMultiLine->text().isEmpty() ) { | 211 | if ( !sigMultiLine->text().isEmpty() ) { |
212 | txt.append( "\n--\n" ); | 212 | txt.append( "\n--\n" ); |
213 | txt.append( sigMultiLine->text() ); | 213 | txt.append( sigMultiLine->text() ); |
214 | } | 214 | } |
215 | qDebug(txt); | 215 | qDebug(txt); |
216 | mail->setMessage( txt ); | 216 | mail->setMessage( txt ); |
217 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 217 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
218 | while ( it != NULL ) { | 218 | while ( it != NULL ) { |
219 | mail->addAttachment( it->getAttachment() ); | 219 | mail->addAttachment( it->getAttachment() ); |
220 | it = (AttachViewItem *) it->nextSibling(); | 220 | it = (AttachViewItem *) it->nextSibling(); |
221 | } | 221 | } |
222 | 222 | ||
223 | SMTPwrapper wrapper( smtp ); | 223 | SMTPwrapper wrapper( smtp ); |
224 | wrapper.sendMail( *mail,checkBoxLater->isChecked() ); | 224 | wrapper.sendMail( *mail,checkBoxLater->isChecked() ); |
225 | 225 | ||
226 | QDialog::accept(); | 226 | QDialog::accept(); |
227 | } | 227 | } |
228 | 228 | ||
229 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) | 229 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) |
230 | : QListViewItem( parent ) | 230 | : QListViewItem( parent ) |
231 | { | 231 | { |
232 | attachment = att; | 232 | attachment = att; |
233 | qDebug( att->getMimeType() ); | 233 | qDebug( att->getMimeType() ); |
234 | setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? | 234 | setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? |
235 | Resource::loadPixmap( "UnknownDocument-14" ) : | 235 | Resource::loadPixmap( "UnknownDocument-14" ) : |
236 | attachment->getDocLnk().pixmap() ); | 236 | attachment->getDocLnk().pixmap() ); |
237 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); | 237 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); |
238 | setText( 1, QString::number( att->getSize() ) ); | 238 | setText( 1, QString::number( att->getSize() ) ); |
239 | } | 239 | } |
240 | 240 | ||
diff --git a/noncore/net/mail/libmailwrapper/libmailwrapper.control b/noncore/net/mail/libmailwrapper/libmailwrapper.control index 0e9e3ed..8b319c8 100644 --- a/noncore/net/mail/libmailwrapper/libmailwrapper.control +++ b/noncore/net/mail/libmailwrapper/libmailwrapper.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: libmailwrapper | 1 | Package: libmailwrapper |
2 | Files: lib/libmailwrapper.so* | 2 | Files: lib/libmailwrapper.so* |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: libs | 4 | Section: libs |
5 | Maintainer: Rajko Albrecht <alwin@handhelds.org>, Juergen Graf <jgf@handhelds.org>, Maximilian Reiß <harlekin@handhelds.org> | 5 | Maintainer: Rajko Albrecht <alwin@handhelds.org>, Juergen Graf <jgf@handhelds.org>, Maximilian Reiß <harlekin@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: 0.4-$SUB_VERSION | 7 | Version: 0.5-$SUB_VERSION |
8 | Depends: task-opie-minimal, libopie1, libetpan | 8 | Depends: task-opie-minimal, libopiecore2, libopieui2, libetpan (>= 0.33pre) |
9 | Description: wrapper lib needed by Opie's mailer | 9 | Description: wrapper lib needed by Opie's mailer |
10 | License: LGPL | 10 | License: LGPL |
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp index 5090f4a..dfc00d8 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp | |||
@@ -1,445 +1,445 @@ | |||
1 | #include "mhwrapper.h" | 1 | #include "mhwrapper.h" |
2 | #include "mailtypes.h" | 2 | #include "mailtypes.h" |
3 | #include "mailwrapper.h" | 3 | #include "mailwrapper.h" |
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | #include <qdir.h> | 5 | #include <qdir.h> |
6 | #include <qmessagebox.h> | 6 | #include <qmessagebox.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <qpe/global.h> | 8 | #include <qpe/global.h> |
9 | #include <opie/oprocess.h> | 9 | #include <opie2/oprocess.h> |
10 | 10 | ||
11 | const QString MHwrapper::wrapperType="MH"; | 11 | const QString MHwrapper::wrapperType="MH"; |
12 | 12 | ||
13 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) | 13 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) |
14 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) | 14 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) |
15 | { | 15 | { |
16 | if (MHPath.length()>0) { | 16 | if (MHPath.length()>0) { |
17 | if (MHPath[MHPath.length()-1]=='/') { | 17 | if (MHPath[MHPath.length()-1]=='/') { |
18 | MHPath=MHPath.left(MHPath.length()-1); | 18 | MHPath=MHPath.left(MHPath.length()-1); |
19 | } | 19 | } |
20 | qDebug(MHPath); | 20 | qDebug(MHPath); |
21 | QDir dir(MHPath); | 21 | QDir dir(MHPath); |
22 | if (!dir.exists()) { | 22 | if (!dir.exists()) { |
23 | dir.mkdir(MHPath); | 23 | dir.mkdir(MHPath); |
24 | } | 24 | } |
25 | init_storage(); | 25 | init_storage(); |
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 | ||
29 | void MHwrapper::init_storage() | 29 | void MHwrapper::init_storage() |
30 | { | 30 | { |
31 | int r; | 31 | int r; |
32 | QString pre = MHPath; | 32 | QString pre = MHPath; |
33 | if (!m_storage) { | 33 | if (!m_storage) { |
34 | m_storage = mailstorage_new(NULL); | 34 | m_storage = mailstorage_new(NULL); |
35 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); | 35 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); |
36 | if (r != MAIL_NO_ERROR) { | 36 | if (r != MAIL_NO_ERROR) { |
37 | qDebug("error initializing storage"); | 37 | qDebug("error initializing storage"); |
38 | mailstorage_free(m_storage); | 38 | mailstorage_free(m_storage); |
39 | m_storage = 0; | 39 | m_storage = 0; |
40 | return; | 40 | return; |
41 | } | 41 | } |
42 | } | 42 | } |
43 | r = mailstorage_connect(m_storage); | 43 | r = mailstorage_connect(m_storage); |
44 | if (r!=MAIL_NO_ERROR) { | 44 | if (r!=MAIL_NO_ERROR) { |
45 | qDebug("error connecting storage"); | 45 | qDebug("error connecting storage"); |
46 | mailstorage_free(m_storage); | 46 | mailstorage_free(m_storage); |
47 | m_storage = 0; | 47 | m_storage = 0; |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | void MHwrapper::clean_storage() | 51 | void MHwrapper::clean_storage() |
52 | { | 52 | { |
53 | if (m_storage) { | 53 | if (m_storage) { |
54 | mailstorage_disconnect(m_storage); | 54 | mailstorage_disconnect(m_storage); |
55 | mailstorage_free(m_storage); | 55 | mailstorage_free(m_storage); |
56 | m_storage = 0; | 56 | m_storage = 0; |
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | MHwrapper::~MHwrapper() | 60 | MHwrapper::~MHwrapper() |
61 | { | 61 | { |
62 | clean_storage(); | 62 | clean_storage(); |
63 | } | 63 | } |
64 | 64 | ||
65 | void MHwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) | 65 | void MHwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) |
66 | { | 66 | { |
67 | init_storage(); | 67 | init_storage(); |
68 | if (!m_storage) { | 68 | if (!m_storage) { |
69 | return; | 69 | return; |
70 | } | 70 | } |
71 | QString f = buildPath(mailbox); | 71 | QString f = buildPath(mailbox); |
72 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 72 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
73 | if (r!=MAIL_NO_ERROR) { | 73 | if (r!=MAIL_NO_ERROR) { |
74 | qDebug("listMessages: error selecting folder!"); | 74 | qDebug("listMessages: error selecting folder!"); |
75 | return; | 75 | return; |
76 | } | 76 | } |
77 | parseList(target,m_storage->sto_session,f); | 77 | parseList(target,m_storage->sto_session,f); |
78 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 78 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
79 | } | 79 | } |
80 | 80 | ||
81 | QList<Folder>* MHwrapper::listFolders() | 81 | QList<Folder>* MHwrapper::listFolders() |
82 | { | 82 | { |
83 | QList<Folder> * folders = new QList<Folder>(); | 83 | QList<Folder> * folders = new QList<Folder>(); |
84 | folders->setAutoDelete( false ); | 84 | folders->setAutoDelete( false ); |
85 | /* this is needed! */ | 85 | /* this is needed! */ |
86 | if (m_storage) mailstorage_disconnect(m_storage); | 86 | if (m_storage) mailstorage_disconnect(m_storage); |
87 | init_storage(); | 87 | init_storage(); |
88 | if (!m_storage) { | 88 | if (!m_storage) { |
89 | return folders; | 89 | return folders; |
90 | } | 90 | } |
91 | mail_list*flist = 0; | 91 | mail_list*flist = 0; |
92 | clistcell*current=0; | 92 | clistcell*current=0; |
93 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); | 93 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); |
94 | if (r != MAIL_NO_ERROR || !flist) { | 94 | if (r != MAIL_NO_ERROR || !flist) { |
95 | qDebug("error getting folder list"); | 95 | qDebug("error getting folder list"); |
96 | return folders; | 96 | return folders; |
97 | } | 97 | } |
98 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { | 98 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { |
99 | QString t = (char*)current->data; | 99 | QString t = (char*)current->data; |
100 | t.replace(0,MHPath.length(),""); | 100 | t.replace(0,MHPath.length(),""); |
101 | folders->append(new MHFolder(t,MHPath)); | 101 | folders->append(new MHFolder(t,MHPath)); |
102 | } | 102 | } |
103 | mail_list_free(flist); | 103 | mail_list_free(flist); |
104 | return folders; | 104 | return folders; |
105 | } | 105 | } |
106 | 106 | ||
107 | void MHwrapper::deleteMail(const RecMail&mail) | 107 | void MHwrapper::deleteMail(const RecMail&mail) |
108 | { | 108 | { |
109 | init_storage(); | 109 | init_storage(); |
110 | if (!m_storage) { | 110 | if (!m_storage) { |
111 | return; | 111 | return; |
112 | } | 112 | } |
113 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); | 113 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); |
114 | if (r!=MAIL_NO_ERROR) { | 114 | if (r!=MAIL_NO_ERROR) { |
115 | qDebug("error selecting folder!"); | 115 | qDebug("error selecting folder!"); |
116 | return; | 116 | return; |
117 | } | 117 | } |
118 | r = mailsession_remove_message(m_storage->sto_session,mail.getNumber()); | 118 | r = mailsession_remove_message(m_storage->sto_session,mail.getNumber()); |
119 | if (r != MAIL_NO_ERROR) { | 119 | if (r != MAIL_NO_ERROR) { |
120 | qDebug("error deleting mail"); | 120 | qDebug("error deleting mail"); |
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | void MHwrapper::answeredMail(const RecMail&) | 124 | void MHwrapper::answeredMail(const RecMail&) |
125 | { | 125 | { |
126 | } | 126 | } |
127 | 127 | ||
128 | RecBody MHwrapper::fetchBody( const RecMail &mail ) | 128 | RecBody MHwrapper::fetchBody( const RecMail &mail ) |
129 | { | 129 | { |
130 | RecBody body; | 130 | RecBody body; |
131 | init_storage(); | 131 | init_storage(); |
132 | if (!m_storage) { | 132 | if (!m_storage) { |
133 | return body; | 133 | return body; |
134 | } | 134 | } |
135 | mailmessage * msg; | 135 | mailmessage * msg; |
136 | char*data=0; | 136 | char*data=0; |
137 | size_t size; | 137 | size_t size; |
138 | 138 | ||
139 | /* mail should hold the complete path! */ | 139 | /* mail should hold the complete path! */ |
140 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); | 140 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); |
141 | if (r != MAIL_NO_ERROR) { | 141 | if (r != MAIL_NO_ERROR) { |
142 | return body; | 142 | return body; |
143 | } | 143 | } |
144 | r = mailsession_get_message(m_storage->sto_session, mail.getNumber(), &msg); | 144 | r = mailsession_get_message(m_storage->sto_session, mail.getNumber(), &msg); |
145 | if (r != MAIL_NO_ERROR) { | 145 | if (r != MAIL_NO_ERROR) { |
146 | qDebug("Error fetching mail %i",mail.getNumber()); | 146 | qDebug("Error fetching mail %i",mail.getNumber()); |
147 | return body; | 147 | return body; |
148 | } | 148 | } |
149 | body = parseMail(msg); | 149 | body = parseMail(msg); |
150 | mailmessage_fetch_result_free(msg,data); | 150 | mailmessage_fetch_result_free(msg,data); |
151 | return body; | 151 | return body; |
152 | } | 152 | } |
153 | 153 | ||
154 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) | 154 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) |
155 | { | 155 | { |
156 | qDebug("MH %i von %i",current,maximum); | 156 | qDebug("MH %i von %i",current,maximum); |
157 | } | 157 | } |
158 | 158 | ||
159 | QString MHwrapper::buildPath(const QString&p) | 159 | QString MHwrapper::buildPath(const QString&p) |
160 | { | 160 | { |
161 | QString f=""; | 161 | QString f=""; |
162 | if (p.length()==0||p=="/") | 162 | if (p.length()==0||p=="/") |
163 | return MHPath; | 163 | return MHPath; |
164 | if (!p.startsWith(MHPath)) { | 164 | if (!p.startsWith(MHPath)) { |
165 | f+=MHPath; | 165 | f+=MHPath; |
166 | } | 166 | } |
167 | if (!p.startsWith("/")) { | 167 | if (!p.startsWith("/")) { |
168 | f+="/"; | 168 | f+="/"; |
169 | } | 169 | } |
170 | f+=p; | 170 | f+=p; |
171 | return f; | 171 | return f; |
172 | } | 172 | } |
173 | 173 | ||
174 | int MHwrapper::createMbox(const QString&folder,const Folder*pfolder,const QString&,bool ) | 174 | int MHwrapper::createMbox(const QString&folder,const Folder*pfolder,const QString&,bool ) |
175 | { | 175 | { |
176 | init_storage(); | 176 | init_storage(); |
177 | if (!m_storage) { | 177 | if (!m_storage) { |
178 | return 0; | 178 | return 0; |
179 | } | 179 | } |
180 | QString f; | 180 | QString f; |
181 | if (!pfolder) { | 181 | if (!pfolder) { |
182 | // toplevel folder | 182 | // toplevel folder |
183 | f = buildPath(folder); | 183 | f = buildPath(folder); |
184 | } else { | 184 | } else { |
185 | f = pfolder->getName(); | 185 | f = pfolder->getName(); |
186 | f+="/"; | 186 | f+="/"; |
187 | f+=folder; | 187 | f+=folder; |
188 | } | 188 | } |
189 | qDebug(f); | 189 | qDebug(f); |
190 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); | 190 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); |
191 | if (r != MAIL_NO_ERROR) { | 191 | if (r != MAIL_NO_ERROR) { |
192 | qDebug("error creating folder %i",r); | 192 | qDebug("error creating folder %i",r); |
193 | return 0; | 193 | return 0; |
194 | } | 194 | } |
195 | qDebug("Folder created"); | 195 | qDebug("Folder created"); |
196 | return 1; | 196 | return 1; |
197 | } | 197 | } |
198 | 198 | ||
199 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) | 199 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) |
200 | { | 200 | { |
201 | init_storage(); | 201 | init_storage(); |
202 | if (!m_storage) { | 202 | if (!m_storage) { |
203 | return; | 203 | return; |
204 | } | 204 | } |
205 | QString f = buildPath(Folder); | 205 | QString f = buildPath(Folder); |
206 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 206 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
207 | if (r!=MAIL_NO_ERROR) { | 207 | if (r!=MAIL_NO_ERROR) { |
208 | qDebug("error selecting folder!"); | 208 | qDebug("error selecting folder!"); |
209 | return; | 209 | return; |
210 | } | 210 | } |
211 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); | 211 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); |
212 | if (r!=MAIL_NO_ERROR) { | 212 | if (r!=MAIL_NO_ERROR) { |
213 | qDebug("error storing mail"); | 213 | qDebug("error storing mail"); |
214 | } | 214 | } |
215 | return; | 215 | return; |
216 | } | 216 | } |
217 | 217 | ||
218 | encodedString* MHwrapper::fetchRawBody(const RecMail&mail) | 218 | encodedString* MHwrapper::fetchRawBody(const RecMail&mail) |
219 | { | 219 | { |
220 | encodedString*result = 0; | 220 | encodedString*result = 0; |
221 | init_storage(); | 221 | init_storage(); |
222 | if (!m_storage) { | 222 | if (!m_storage) { |
223 | return result; | 223 | return result; |
224 | } | 224 | } |
225 | mailmessage * msg = 0; | 225 | mailmessage * msg = 0; |
226 | char*data=0; | 226 | char*data=0; |
227 | size_t size; | 227 | size_t size; |
228 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); | 228 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); |
229 | if (r!=MAIL_NO_ERROR) { | 229 | if (r!=MAIL_NO_ERROR) { |
230 | qDebug("error selecting folder!"); | 230 | qDebug("error selecting folder!"); |
231 | return result; | 231 | return result; |
232 | } | 232 | } |
233 | r = mailsession_get_message(m_storage->sto_session, mail.getNumber(), &msg); | 233 | r = mailsession_get_message(m_storage->sto_session, mail.getNumber(), &msg); |
234 | if (r != MAIL_NO_ERROR) { | 234 | if (r != MAIL_NO_ERROR) { |
235 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); | 235 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
236 | return 0; | 236 | return 0; |
237 | } | 237 | } |
238 | r = mailmessage_fetch(msg,&data,&size); | 238 | r = mailmessage_fetch(msg,&data,&size); |
239 | if (r != MAIL_NO_ERROR) { | 239 | if (r != MAIL_NO_ERROR) { |
240 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); | 240 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
241 | if (msg) mailmessage_free(msg); | 241 | if (msg) mailmessage_free(msg); |
242 | return 0; | 242 | return 0; |
243 | } | 243 | } |
244 | result = new encodedString(data,size); | 244 | result = new encodedString(data,size); |
245 | if (msg) mailmessage_free(msg); | 245 | if (msg) mailmessage_free(msg); |
246 | return result; | 246 | return result; |
247 | } | 247 | } |
248 | 248 | ||
249 | void MHwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) | 249 | void MHwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) |
250 | { | 250 | { |
251 | QString f = buildPath(mailbox); | 251 | QString f = buildPath(mailbox); |
252 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 252 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
253 | if (r!=MAIL_NO_ERROR) { | 253 | if (r!=MAIL_NO_ERROR) { |
254 | qDebug("deleteMails: error selecting folder!"); | 254 | qDebug("deleteMails: error selecting folder!"); |
255 | return; | 255 | return; |
256 | } | 256 | } |
257 | RecMail*c = 0; | 257 | RecMail*c = 0; |
258 | for (unsigned int i=0; i < target.count();++i) { | 258 | for (unsigned int i=0; i < target.count();++i) { |
259 | c = target.at(i); | 259 | c = target.at(i); |
260 | r = mailsession_remove_message(m_storage->sto_session,c->getNumber()); | 260 | r = mailsession_remove_message(m_storage->sto_session,c->getNumber()); |
261 | if (r != MAIL_NO_ERROR) { | 261 | if (r != MAIL_NO_ERROR) { |
262 | qDebug("error deleting mail"); | 262 | qDebug("error deleting mail"); |
263 | break; | 263 | break; |
264 | } | 264 | } |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | int MHwrapper::deleteAllMail(const Folder*tfolder) | 268 | int MHwrapper::deleteAllMail(const Folder*tfolder) |
269 | { | 269 | { |
270 | init_storage(); | 270 | init_storage(); |
271 | if (!m_storage) { | 271 | if (!m_storage) { |
272 | return 0; | 272 | return 0; |
273 | } | 273 | } |
274 | int res = 1; | 274 | int res = 1; |
275 | if (!tfolder) return 0; | 275 | if (!tfolder) return 0; |
276 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 276 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
277 | if (r!=MAIL_NO_ERROR) { | 277 | if (r!=MAIL_NO_ERROR) { |
278 | qDebug("error selecting folder!"); | 278 | qDebug("error selecting folder!"); |
279 | return 0; | 279 | return 0; |
280 | } | 280 | } |
281 | mailmessage_list*l=0; | 281 | mailmessage_list*l=0; |
282 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | 282 | r = mailsession_get_messages_list(m_storage->sto_session,&l); |
283 | if (r != MAIL_NO_ERROR) { | 283 | if (r != MAIL_NO_ERROR) { |
284 | qDebug("Error message list"); | 284 | qDebug("Error message list"); |
285 | res = 0; | 285 | res = 0; |
286 | } | 286 | } |
287 | unsigned j = 0; | 287 | unsigned j = 0; |
288 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | 288 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { |
289 | mailmessage * msg; | 289 | mailmessage * msg; |
290 | msg = (mailmessage*)carray_get(l->msg_tab, i); | 290 | msg = (mailmessage*)carray_get(l->msg_tab, i); |
291 | j = msg->msg_index; | 291 | j = msg->msg_index; |
292 | r = mailsession_remove_message(m_storage->sto_session,j); | 292 | r = mailsession_remove_message(m_storage->sto_session,j); |
293 | if (r != MAIL_NO_ERROR) { | 293 | if (r != MAIL_NO_ERROR) { |
294 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 294 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
295 | res = 0; | 295 | res = 0; |
296 | break; | 296 | break; |
297 | } | 297 | } |
298 | } | 298 | } |
299 | if (l) mailmessage_list_free(l); | 299 | if (l) mailmessage_list_free(l); |
300 | return res; | 300 | return res; |
301 | } | 301 | } |
302 | 302 | ||
303 | int MHwrapper::deleteMbox(const Folder*tfolder) | 303 | int MHwrapper::deleteMbox(const Folder*tfolder) |
304 | { | 304 | { |
305 | init_storage(); | 305 | init_storage(); |
306 | if (!m_storage) { | 306 | if (!m_storage) { |
307 | return 0; | 307 | return 0; |
308 | } | 308 | } |
309 | if (!tfolder) return 0; | 309 | if (!tfolder) return 0; |
310 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; | 310 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; |
311 | 311 | ||
312 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 312 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
313 | 313 | ||
314 | if (r != MAIL_NO_ERROR) { | 314 | if (r != MAIL_NO_ERROR) { |
315 | qDebug("error deleting mail box"); | 315 | qDebug("error deleting mail box"); |
316 | return 0; | 316 | return 0; |
317 | } | 317 | } |
318 | QString cmd = "rm -rf "+tfolder->getName(); | 318 | QString cmd = "rm -rf "+tfolder->getName(); |
319 | QStringList command; | 319 | QStringList command; |
320 | command << "/bin/sh"; | 320 | command << "/bin/sh"; |
321 | command << "-c"; | 321 | command << "-c"; |
322 | command << cmd.latin1(); | 322 | command << cmd.latin1(); |
323 | OProcess *process = new OProcess(); | 323 | OProcess *process = new OProcess(); |
324 | 324 | ||
325 | connect(process, SIGNAL(processExited(OProcess *)), | 325 | connect(process, SIGNAL(processExited(OProcess *)), |
326 | this, SLOT( processEnded(OProcess *))); | 326 | this, SLOT( processEnded(OProcess *))); |
327 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), | 327 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), |
328 | this, SLOT( oprocessStderr(OProcess *, char *, int))); | 328 | this, SLOT( oprocessStderr(OProcess *, char *, int))); |
329 | 329 | ||
330 | *process << command; | 330 | *process << command; |
331 | removeMboxfailed = false; | 331 | removeMboxfailed = false; |
332 | if(!process->start(OProcess::Block, OProcess::All) ) { | 332 | if(!process->start(OProcess::Block, OProcess::All) ) { |
333 | qDebug("could not start process"); | 333 | qDebug("could not start process"); |
334 | return 0; | 334 | return 0; |
335 | } | 335 | } |
336 | qDebug("mail box deleted"); | 336 | qDebug("mail box deleted"); |
337 | return 1; | 337 | return 1; |
338 | } | 338 | } |
339 | 339 | ||
340 | void MHwrapper::processEnded(OProcess *p) | 340 | void MHwrapper::processEnded(OProcess *p) |
341 | { | 341 | { |
342 | if (p) delete p; | 342 | if (p) delete p; |
343 | } | 343 | } |
344 | 344 | ||
345 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) | 345 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) |
346 | { | 346 | { |
347 | QString lineStr = buffer; | 347 | QString lineStr = buffer; |
348 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); | 348 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); |
349 | removeMboxfailed = true; | 349 | removeMboxfailed = true; |
350 | } | 350 | } |
351 | 351 | ||
352 | void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 352 | void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
353 | { | 353 | { |
354 | init_storage(); | 354 | init_storage(); |
355 | if (!m_storage) { | 355 | if (!m_storage) { |
356 | return; | 356 | return; |
357 | } | 357 | } |
358 | target_stat.message_count = 0; | 358 | target_stat.message_count = 0; |
359 | target_stat.message_unseen = 0; | 359 | target_stat.message_unseen = 0; |
360 | target_stat.message_recent = 0; | 360 | target_stat.message_recent = 0; |
361 | QString f = buildPath(mailbox); | 361 | QString f = buildPath(mailbox); |
362 | int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, | 362 | int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, |
363 | &target_stat.message_recent,&target_stat.message_unseen); | 363 | &target_stat.message_recent,&target_stat.message_unseen); |
364 | if (r != MAIL_NO_ERROR) { | 364 | if (r != MAIL_NO_ERROR) { |
365 | Global::statusMessage(tr("Error retrieving status")); | 365 | Global::statusMessage(tr("Error retrieving status")); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | 368 | ||
369 | const QString&MHwrapper::getType()const | 369 | const QString&MHwrapper::getType()const |
370 | { | 370 | { |
371 | return wrapperType; | 371 | return wrapperType; |
372 | } | 372 | } |
373 | 373 | ||
374 | const QString&MHwrapper::getName()const | 374 | const QString&MHwrapper::getName()const |
375 | { | 375 | { |
376 | return MHName; | 376 | return MHName; |
377 | } | 377 | } |
378 | void MHwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 378 | void MHwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
379 | { | 379 | { |
380 | init_storage(); | 380 | init_storage(); |
381 | if (!m_storage) { | 381 | if (!m_storage) { |
382 | return; | 382 | return; |
383 | } | 383 | } |
384 | if (targetWrapper != this) { | 384 | if (targetWrapper != this) { |
385 | qDebug("Using generic"); | 385 | qDebug("Using generic"); |
386 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 386 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
387 | return; | 387 | return; |
388 | } | 388 | } |
389 | qDebug("Using internal routines for move/copy"); | 389 | qDebug("Using internal routines for move/copy"); |
390 | QString tf = buildPath(targetFolder); | 390 | QString tf = buildPath(targetFolder); |
391 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); | 391 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); |
392 | if (r != MAIL_NO_ERROR) { | 392 | if (r != MAIL_NO_ERROR) { |
393 | qDebug("Error selecting source mailbox"); | 393 | qDebug("Error selecting source mailbox"); |
394 | return; | 394 | return; |
395 | } | 395 | } |
396 | if (moveit) { | 396 | if (moveit) { |
397 | r = mailsession_move_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); | 397 | r = mailsession_move_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); |
398 | } else { | 398 | } else { |
399 | r = mailsession_copy_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); | 399 | r = mailsession_copy_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); |
400 | } | 400 | } |
401 | if (r != MAIL_NO_ERROR) { | 401 | if (r != MAIL_NO_ERROR) { |
402 | qDebug("Error copy/moving mail internal (%i)",r); | 402 | qDebug("Error copy/moving mail internal (%i)",r); |
403 | } | 403 | } |
404 | } | 404 | } |
405 | 405 | ||
406 | void MHwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 406 | void MHwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
407 | { | 407 | { |
408 | init_storage(); | 408 | init_storage(); |
409 | if (!m_storage) { | 409 | if (!m_storage) { |
410 | return; | 410 | return; |
411 | } | 411 | } |
412 | if (targetWrapper != this) { | 412 | if (targetWrapper != this) { |
413 | qDebug("Using generic"); | 413 | qDebug("Using generic"); |
414 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | 414 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); |
415 | return; | 415 | return; |
416 | } | 416 | } |
417 | if (!fromFolder) return; | 417 | if (!fromFolder) return; |
418 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); | 418 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); |
419 | if (r!=MAIL_NO_ERROR) { | 419 | if (r!=MAIL_NO_ERROR) { |
420 | qDebug("error selecting source folder!"); | 420 | qDebug("error selecting source folder!"); |
421 | return; | 421 | return; |
422 | } | 422 | } |
423 | QString tf = buildPath(targetFolder); | 423 | QString tf = buildPath(targetFolder); |
424 | mailmessage_list*l=0; | 424 | mailmessage_list*l=0; |
425 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | 425 | r = mailsession_get_messages_list(m_storage->sto_session,&l); |
426 | if (r != MAIL_NO_ERROR) { | 426 | if (r != MAIL_NO_ERROR) { |
427 | qDebug("Error message list"); | 427 | qDebug("Error message list"); |
428 | } | 428 | } |
429 | unsigned j = 0; | 429 | unsigned j = 0; |
430 | for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { | 430 | for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { |
431 | mailmessage * msg; | 431 | mailmessage * msg; |
432 | msg = (mailmessage*)carray_get(l->msg_tab, i); | 432 | msg = (mailmessage*)carray_get(l->msg_tab, i); |
433 | j = msg->msg_index; | 433 | j = msg->msg_index; |
434 | if (moveit) { | 434 | if (moveit) { |
435 | r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); | 435 | r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); |
436 | } else { | 436 | } else { |
437 | r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); | 437 | r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); |
438 | } | 438 | } |
439 | if (r != MAIL_NO_ERROR) { | 439 | if (r != MAIL_NO_ERROR) { |
440 | qDebug("Error copy/moving mail internal (%i)",r); | 440 | qDebug("Error copy/moving mail internal (%i)",r); |
441 | break; | 441 | break; |
442 | } | 442 | } |
443 | } | 443 | } |
444 | if (l) mailmessage_list_free(l); | 444 | if (l) mailmessage_list_free(l); |
445 | } | 445 | } |
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro index 184b5b3..d3d2ab1 100644 --- a/noncore/net/mail/mail.pro +++ b/noncore/net/mail/mail.pro | |||
@@ -1,61 +1,61 @@ | |||
1 | CONFIG += qt warn_on debug quick-app | 1 | CONFIG += qt warn_on debug quick-app |
2 | 2 | ||
3 | HEADERS = defines.h \ | 3 | HEADERS = defines.h \ |
4 | editaccounts.h \ | 4 | editaccounts.h \ |
5 | composemail.h \ | 5 | composemail.h \ |
6 | accountview.h \ | 6 | accountview.h \ |
7 | accountitem.h \ | 7 | accountitem.h \ |
8 | mainwindow.h \ | 8 | mainwindow.h \ |
9 | viewmail.h \ | 9 | viewmail.h \ |
10 | viewmailbase.h \ | 10 | viewmailbase.h \ |
11 | opiemail.h \ | 11 | opiemail.h \ |
12 | mailistviewitem.h \ | 12 | mailistviewitem.h \ |
13 | settingsdialog.h \ | 13 | settingsdialog.h \ |
14 | statuswidget.h \ | 14 | statuswidget.h \ |
15 | newmaildir.h \ | 15 | newmaildir.h \ |
16 | selectstore.h \ | 16 | selectstore.h \ |
17 | selectsmtp.h | 17 | selectsmtp.h |
18 | 18 | ||
19 | SOURCES = main.cpp \ | 19 | SOURCES = main.cpp \ |
20 | opiemail.cpp \ | 20 | opiemail.cpp \ |
21 | mainwindow.cpp \ | 21 | mainwindow.cpp \ |
22 | accountview.cpp \ | 22 | accountview.cpp \ |
23 | accountitem.cpp \ | 23 | accountitem.cpp \ |
24 | composemail.cpp \ | 24 | composemail.cpp \ |
25 | addresspicker.cpp \ | 25 | addresspicker.cpp \ |
26 | editaccounts.cpp \ | 26 | editaccounts.cpp \ |
27 | viewmail.cpp \ | 27 | viewmail.cpp \ |
28 | viewmailbase.cpp \ | 28 | viewmailbase.cpp \ |
29 | mailistviewitem.cpp \ | 29 | mailistviewitem.cpp \ |
30 | settingsdialog.cpp \ | 30 | settingsdialog.cpp \ |
31 | statuswidget.cpp \ | 31 | statuswidget.cpp \ |
32 | newmaildir.cpp \ | 32 | newmaildir.cpp \ |
33 | selectstore.cpp \ | 33 | selectstore.cpp \ |
34 | selectsmtp.cpp | 34 | selectsmtp.cpp |
35 | 35 | ||
36 | INTERFACES = editaccountsui.ui \ | 36 | INTERFACES = editaccountsui.ui \ |
37 | selectmailtypeui.ui \ | 37 | selectmailtypeui.ui \ |
38 | imapconfigui.ui \ | 38 | imapconfigui.ui \ |
39 | pop3configui.ui \ | 39 | pop3configui.ui \ |
40 | nntpconfigui.ui \ | 40 | nntpconfigui.ui \ |
41 | smtpconfigui.ui \ | 41 | smtpconfigui.ui \ |
42 | addresspickerui.ui \ | 42 | addresspickerui.ui \ |
43 | composemailui.ui \ | 43 | composemailui.ui \ |
44 | settingsdialogui.ui \ | 44 | settingsdialogui.ui \ |
45 | statuswidgetui.ui \ | 45 | statuswidgetui.ui \ |
46 | newmaildirui.ui \ | 46 | newmaildirui.ui \ |
47 | selectstoreui.ui | 47 | selectstoreui.ui |
48 | 48 | ||
49 | 49 | ||
50 | INCLUDEPATH += $(OPIEDIR)/include | 50 | INCLUDEPATH += $(OPIEDIR)/include |
51 | 51 | ||
52 | CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) | 52 | CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) |
53 | contains( CONFTEST, y ){ | 53 | contains( CONFTEST, y ){ |
54 | LIBS += -lqpe -lopie -lmailwrapper -liconv | 54 | LIBS += -lqpe -lopieui2 -lopiecore2 -lopie -lmailwrapper -liconv |
55 | }else{ | 55 | }else{ |
56 | LIBS += -lqpe -lopie -lmailwrapper | 56 | LIBS += -lqpe -lopieui2 -lopiecore2 -lopie -lmailwrapper |
57 | } | 57 | } |
58 | 58 | ||
59 | TARGET = opiemail | 59 | TARGET = opiemail |
60 | 60 | ||
61 | include ( $(OPIEDIR)/include.pro ) | 61 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/net/mail/main.cpp b/noncore/net/mail/main.cpp index 3bfcb4a..54ac7fb 100644 --- a/noncore/net/mail/main.cpp +++ b/noncore/net/mail/main.cpp | |||
@@ -1,5 +1,5 @@ | |||
1 | #include <opie/oapplicationfactory.h> | 1 | #include <opie2/oapplicationfactory.h> |
2 | 2 | ||
3 | #include "opiemail.h" | 3 | #include "opiemail.h" |
4 | 4 | ||
5 | OPIE_EXPORT_APP( OApplicationFactory<OpieMail> ) | 5 | OPIE_EXPORT_APP( OApplicationFactory<OpieMail> ) |
diff --git a/noncore/net/mail/opie-mail.control b/noncore/net/mail/opie-mail.control index 0e11c4a..5f25414 100644 --- a/noncore/net/mail/opie-mail.control +++ b/noncore/net/mail/opie-mail.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: opie-mail | 1 | Package: opie-mail |
2 | Files: plugins/application/libopiemail.so* bin/opiemail apps/1Pim/mail.desktop pics/mail/*.png | 2 | Files: plugins/application/libopiemail.so* bin/opiemail apps/1Pim/mail.desktop pics/mail/*.png |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/pim | 4 | Section: opie/pim |
5 | Maintainer: Rajko Albrecht <alwin@handhelds.org>, Juergen Graf <jgf@handhelds.org>, Maximilian Reiß <harlekin@handhelds.org> | 5 | Maintainer: Rajko Albrecht <alwin@handhelds.org>, Juergen Graf <jgf@handhelds.org>, Maximilian Reiß <harlekin@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: 0.4-$SUB_VERSION | 7 | Version: 0.5-$SUB_VERSION |
8 | Depends: task-opie-minimal, libopie1, libmailwrapper | 8 | Depends: task-opie-minimal, libopie1, libopiecore2, libopieui2, libmailwrapper (>= 0.4) |
9 | Description: Opie's mail and news client (POP3, IMAP and NNTP) | 9 | Description: Opie's mail and news client (POP3, IMAP and NNTP) |
10 | License: LGPL | 10 | License: LGPL |
diff --git a/noncore/net/mail/taskbarapplet/mailapplet.cpp b/noncore/net/mail/taskbarapplet/mailapplet.cpp index a0805ba..de32007 100644 --- a/noncore/net/mail/taskbarapplet/mailapplet.cpp +++ b/noncore/net/mail/taskbarapplet/mailapplet.cpp | |||
@@ -1,145 +1,145 @@ | |||
1 | #include <qpainter.h> | 1 | #include <qpainter.h> |
2 | #include <qtimer.h> | 2 | #include <qtimer.h> |
3 | 3 | ||
4 | #include <qpe/qcopenvelope_qws.h> | 4 | #include <qpe/qcopenvelope_qws.h> |
5 | #include <qpe/resource.h> | 5 | #include <qpe/resource.h> |
6 | #include <qpe/config.h> | 6 | #include <qpe/config.h> |
7 | #include <qpe/applnk.h> | 7 | #include <qpe/applnk.h> |
8 | 8 | ||
9 | #include <opie/odevice.h> | 9 | #include <opie2/odevice.h> |
10 | 10 | ||
11 | #include <libmailwrapper/settings.h> | 11 | #include <libmailwrapper/settings.h> |
12 | 12 | ||
13 | #include "mailapplet.h" | 13 | #include "mailapplet.h" |
14 | 14 | ||
15 | using namespace Opie; | 15 | using namespace Opie; |
16 | 16 | ||
17 | MailApplet::MailApplet( QWidget *parent ) | 17 | MailApplet::MailApplet( QWidget *parent ) |
18 | : QWidget( parent ) { | 18 | : QWidget( parent ) { |
19 | 19 | ||
20 | m_config = new Config( "mail" ); | 20 | m_config = new Config( "mail" ); |
21 | m_config->setGroup( "Applet" ); | 21 | m_config->setGroup( "Applet" ); |
22 | 22 | ||
23 | setFixedWidth( AppLnk::smallIconSize() ); | 23 | setFixedWidth( AppLnk::smallIconSize() ); |
24 | setFixedHeight( AppLnk::smallIconSize() ); | 24 | setFixedHeight( AppLnk::smallIconSize() ); |
25 | 25 | ||
26 | hide(); | 26 | hide(); |
27 | 27 | ||
28 | m_newMails = 0; | 28 | m_newMails = 0; |
29 | m_statusMail = 0l; | 29 | m_statusMail = 0l; |
30 | 30 | ||
31 | if ( !m_config->readBoolEntry( "Disabled", false ) ) { | 31 | if ( !m_config->readBoolEntry( "Disabled", false ) ) { |
32 | // delay 5 sec until the whole mail backend gets started .-) | 32 | // delay 5 sec until the whole mail backend gets started .-) |
33 | QTimer::singleShot( 5000, this, SLOT( startup() ) ); | 33 | QTimer::singleShot( 5000, this, SLOT( startup() ) ); |
34 | } | 34 | } |
35 | repaint( true ); | 35 | repaint( true ); |
36 | } | 36 | } |
37 | 37 | ||
38 | 38 | ||
39 | MailApplet::~MailApplet() { | 39 | MailApplet::~MailApplet() { |
40 | if ( m_statusMail ) | 40 | if ( m_statusMail ) |
41 | delete m_statusMail; | 41 | delete m_statusMail; |
42 | if ( m_config ) | 42 | if ( m_config ) |
43 | delete m_config; | 43 | delete m_config; |
44 | } | 44 | } |
45 | 45 | ||
46 | void MailApplet::paintEvent( QPaintEvent* ) { | 46 | void MailApplet::paintEvent( QPaintEvent* ) { |
47 | QPainter p( this ); | 47 | QPainter p( this ); |
48 | p.drawPixmap( 0, 0, Resource::loadPixmap( "mail/inbox" ) ); | 48 | p.drawPixmap( 0, 0, Resource::loadPixmap( "mail/inbox" ) ); |
49 | QFont f( "vera", AppLnk::smallIconSize() ); | 49 | QFont f( "vera", AppLnk::smallIconSize() ); |
50 | QFontMetrics fm( f ); | 50 | QFontMetrics fm( f ); |
51 | p.setFont( f ); | 51 | p.setFont( f ); |
52 | p.setPen( Qt::blue ); | 52 | p.setPen( Qt::blue ); |
53 | p.drawText( AppLnk::smallIconSize()/3, AppLnk::smallIconSize() - 2, QString::number( m_newMails ) ); | 53 | p.drawText( AppLnk::smallIconSize()/3, AppLnk::smallIconSize() - 2, QString::number( m_newMails ) ); |
54 | return; | 54 | return; |
55 | 55 | ||
56 | } | 56 | } |
57 | 57 | ||
58 | void MailApplet::mouseReleaseEvent( QMouseEvent* e ) { | 58 | void MailApplet::mouseReleaseEvent( QMouseEvent* e ) { |
59 | slotClicked(); | 59 | slotClicked(); |
60 | } | 60 | } |
61 | 61 | ||
62 | void MailApplet::slotClicked() { | 62 | void MailApplet::slotClicked() { |
63 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 63 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
64 | e << QString( "opiemail" ); | 64 | e << QString( "opiemail" ); |
65 | 65 | ||
66 | ODevice *device = ODevice::inst(); | 66 | ODevice *device = ODevice::inst(); |
67 | if ( !device-> ledList().isEmpty() ) { | 67 | if ( !device-> ledList().isEmpty() ) { |
68 | OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; | 68 | OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; |
69 | 69 | ||
70 | device->setLedState( led, Led_Off ); | 70 | device->setLedState( led, Led_Off ); |
71 | } | 71 | } |
72 | 72 | ||
73 | if (m_statusMail) | 73 | if (m_statusMail) |
74 | m_statusMail->reset_status(); | 74 | m_statusMail->reset_status(); |
75 | 75 | ||
76 | hide(); | 76 | hide(); |
77 | } | 77 | } |
78 | 78 | ||
79 | void MailApplet::startup() { | 79 | void MailApplet::startup() { |
80 | Settings *settings = new Settings(); | 80 | Settings *settings = new Settings(); |
81 | QList<Account> ma = settings->getAccounts(); | 81 | QList<Account> ma = settings->getAccounts(); |
82 | m_statusMail = new StatusMail( ma ); | 82 | m_statusMail = new StatusMail( ma ); |
83 | delete settings; | 83 | delete settings; |
84 | 84 | ||
85 | m_intervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; | 85 | m_intervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; |
86 | m_intervalTimer = new QTimer(); | 86 | m_intervalTimer = new QTimer(); |
87 | m_intervalTimer->start( m_intervalMs ); | 87 | m_intervalTimer->start( m_intervalMs ); |
88 | connect( m_intervalTimer, SIGNAL( timeout() ), this, SLOT( slotCheck() ) ); | 88 | connect( m_intervalTimer, SIGNAL( timeout() ), this, SLOT( slotCheck() ) ); |
89 | } | 89 | } |
90 | 90 | ||
91 | void MailApplet::slotCheck() { | 91 | void MailApplet::slotCheck() { |
92 | // Check wether the check interval has been changed. | 92 | // Check wether the check interval has been changed. |
93 | int newIntervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; | 93 | int newIntervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; |
94 | if ( newIntervalMs != m_intervalMs ) { | 94 | if ( newIntervalMs != m_intervalMs ) { |
95 | m_intervalTimer->changeInterval( newIntervalMs ); | 95 | m_intervalTimer->changeInterval( newIntervalMs ); |
96 | m_intervalMs = newIntervalMs; | 96 | m_intervalMs = newIntervalMs; |
97 | } | 97 | } |
98 | 98 | ||
99 | if (m_statusMail == 0) { | 99 | if (m_statusMail == 0) { |
100 | return; | 100 | return; |
101 | } | 101 | } |
102 | 102 | ||
103 | folderStat stat; | 103 | folderStat stat; |
104 | m_statusMail->check_current_stat( stat ); | 104 | m_statusMail->check_current_stat( stat ); |
105 | int newMailsOld = m_newMails; | 105 | int newMailsOld = m_newMails; |
106 | m_newMails = stat.message_unseen; | 106 | m_newMails = stat.message_unseen; |
107 | qDebug( QString( "test %1" ).arg( m_newMails ) ); | 107 | qDebug( QString( "test %1" ).arg( m_newMails ) ); |
108 | if ( m_newMails > 0 && newMailsOld != m_newMails ) { | 108 | if ( m_newMails > 0 && newMailsOld != m_newMails ) { |
109 | ODevice *device = ODevice::inst(); | 109 | ODevice *device = ODevice::inst(); |
110 | if ( isHidden() ) | 110 | if ( isHidden() ) |
111 | show(); | 111 | show(); |
112 | if ( m_config->readBoolEntry( "BlinkLed", true ) ) { | 112 | if ( m_config->readBoolEntry( "BlinkLed", true ) ) { |
113 | if ( !device->ledList().isEmpty() ) { | 113 | if ( !device->ledList().isEmpty() ) { |
114 | OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; | 114 | OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; |
115 | device->setLedState( led, device->ledStateList( led ).contains( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On ); | 115 | device->setLedState( led, device->ledStateList( led ).contains( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On ); |
116 | } | 116 | } |
117 | } | 117 | } |
118 | if ( m_config->readBoolEntry( "PlaySound", false ) ) | 118 | if ( m_config->readBoolEntry( "PlaySound", false ) ) |
119 | device->alarmSound(); | 119 | device->playAlarmSound(); |
120 | 120 | ||
121 | Config cfg( "mail" ); | 121 | Config cfg( "mail" ); |
122 | cfg.setGroup( "Status" ); | 122 | cfg.setGroup( "Status" ); |
123 | cfg.writeEntry( "newMails", m_newMails ); | 123 | cfg.writeEntry( "newMails", m_newMails ); |
124 | QCopEnvelope env( "QPE/Pim", "newMails(int)" ); | 124 | QCopEnvelope env( "QPE/Pim", "newMails(int)" ); |
125 | env << m_newMails; | 125 | env << m_newMails; |
126 | repaint( true ); | 126 | repaint( true ); |
127 | 127 | ||
128 | } else { | 128 | } else { |
129 | ODevice *device = ODevice::inst(); | 129 | ODevice *device = ODevice::inst(); |
130 | if ( !isHidden() ) | 130 | if ( !isHidden() ) |
131 | hide(); | 131 | hide(); |
132 | if ( !device->ledList().isEmpty() ) { | 132 | if ( !device->ledList().isEmpty() ) { |
133 | OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; | 133 | OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; |
134 | device->setLedState( led, Led_Off ); | 134 | device->setLedState( led, Led_Off ); |
135 | } | 135 | } |
136 | 136 | ||
137 | if ( newMailsOld != m_newMails ) { | 137 | if ( newMailsOld != m_newMails ) { |
138 | Config cfg( "mail" ); | 138 | Config cfg( "mail" ); |
139 | cfg.setGroup( "Status" ); | 139 | cfg.setGroup( "Status" ); |
140 | cfg.writeEntry( "newMails", m_newMails ); | 140 | cfg.writeEntry( "newMails", m_newMails ); |
141 | QCopEnvelope env( "QPE/Pim", "newMails(int)" ); | 141 | QCopEnvelope env( "QPE/Pim", "newMails(int)" ); |
142 | env << m_newMails; | 142 | env << m_newMails; |
143 | } | 143 | } |
144 | } | 144 | } |
145 | } | 145 | } |
diff --git a/noncore/net/mail/taskbarapplet/opie-mailapplet.control b/noncore/net/mail/taskbarapplet/opie-mailapplet.control index 84adc7b..f9822a5 100644 --- a/noncore/net/mail/taskbarapplet/opie-mailapplet.control +++ b/noncore/net/mail/taskbarapplet/opie-mailapplet.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: opie-mailapplet | 1 | Package: opie-mailapplet |
2 | Files: plugins/applets/libmailapplet.so* | 2 | Files: plugins/applets/libmailapplet.so* |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applets | 4 | Section: opie/applets |
5 | Maintainer: Rajko Albrecht <alwin@handhelds.org>, Juergen Graf <jgf@handhelds.org>, Maximilian Reiß <harlekin@handhelds.org> | 5 | Maintainer: Rajko Albrecht <alwin@handhelds.org>, Juergen Graf <jgf@handhelds.org>, Maximilian Reiß <harlekin@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: 0.4-$SUB_VERSION | 7 | Version: 0.5-$SUB_VERSION |
8 | Depends: task-opie-minimal, libopie1, opie-mail | 8 | Depends: task-opie-minimal, libopiecore2, opie-mail |
9 | Description: A Biff-like mailchecker | 9 | Description: A Biff-like mailchecker |
10 | License: LGPL | 10 | License: LGPL |
diff --git a/noncore/net/mail/taskbarapplet/taskbarapplet.pro b/noncore/net/mail/taskbarapplet/taskbarapplet.pro index c54e87f..e4ac6d1 100644 --- a/noncore/net/mail/taskbarapplet/taskbarapplet.pro +++ b/noncore/net/mail/taskbarapplet/taskbarapplet.pro | |||
@@ -1,12 +1,12 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG +=qt plugin warn_on release | 2 | CONFIG +=qt plugin warn_on release |
3 | HEADERS +=mailapplet.h \ | 3 | HEADERS +=mailapplet.h \ |
4 | mailappletimpl.h | 4 | mailappletimpl.h |
5 | SOURCES +=mailapplet.cpp \ | 5 | SOURCES +=mailapplet.cpp \ |
6 | mailappletimpl.cpp | 6 | mailappletimpl.cpp |
7 | INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/noncore/net/mail | 7 | INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/noncore/net/mail |
8 | LIBS +=-lmailwrapper -lqpe -lopie | 8 | LIBS +=-lmailwrapper -lqpe -lopiecore2 |
9 | TARGET =mailapplet | 9 | TARGET =mailapplet |
10 | DESTDIR +=$(OPIEDIR)/plugins/applets/ | 10 | DESTDIR +=$(OPIEDIR)/plugins/applets/ |
11 | 11 | ||
12 | include ( $(OPIEDIR)/include.pro ) | 12 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index 9ca6383..99965d4 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -1,429 +1,429 @@ | |||
1 | #include <qtextbrowser.h> | 1 | #include <qtextbrowser.h> |
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <qaction.h> | 4 | #include <qaction.h> |
5 | #include <qpopupmenu.h> | 5 | #include <qpopupmenu.h> |
6 | #include <qfile.h> | 6 | #include <qfile.h> |
7 | #include <qapplication.h> | 7 | #include <qapplication.h> |
8 | #include <qvaluelist.h> | 8 | #include <qvaluelist.h> |
9 | 9 | ||
10 | #include <qpe/config.h> | 10 | #include <qpe/config.h> |
11 | 11 | ||
12 | #include <opie/ofiledialog.h> | 12 | #include <opie2/ofiledialog.h> |
13 | 13 | ||
14 | #include <libmailwrapper/settings.h> | 14 | #include <libmailwrapper/settings.h> |
15 | #include "composemail.h" | 15 | #include "composemail.h" |
16 | #include "viewmail.h" | 16 | #include "viewmail.h" |
17 | #include <libmailwrapper/abstractmail.h> | 17 | #include <libmailwrapper/abstractmail.h> |
18 | #include "accountview.h" | 18 | #include "accountview.h" |
19 | #include <libmailwrapper/mailtypes.h> | 19 | #include <libmailwrapper/mailtypes.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 | if (_path[i]!=path[i]) return false; | 50 | if (_path[i]!=path[i]) return false; |
51 | } | 51 | } |
52 | return true; | 52 | return true; |
53 | } | 53 | } |
54 | 54 | ||
55 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) | 55 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) |
56 | { | 56 | { |
57 | QListViewItemIterator it( attachments ); | 57 | QListViewItemIterator it( attachments ); |
58 | for ( ; it.current(); ++it ) { | 58 | for ( ; it.current(); ++it ) { |
59 | AttachItem*ati = (AttachItem*)it.current(); | 59 | AttachItem*ati = (AttachItem*)it.current(); |
60 | if (ati->isParentof(path)) return ati; | 60 | if (ati->isParentof(path)) return ati; |
61 | } | 61 | } |
62 | return 0; | 62 | return 0; |
63 | } | 63 | } |
64 | 64 | ||
65 | AttachItem* ViewMail::lastChild(AttachItem*parent) | 65 | AttachItem* ViewMail::lastChild(AttachItem*parent) |
66 | { | 66 | { |
67 | if (!parent) return 0; | 67 | if (!parent) return 0; |
68 | AttachItem* item = (AttachItem*)parent->firstChild(); | 68 | AttachItem* item = (AttachItem*)parent->firstChild(); |
69 | if (!item) return item; | 69 | if (!item) return item; |
70 | AttachItem*temp=0; | 70 | AttachItem*temp=0; |
71 | while( (temp=(AttachItem*)item->nextSibling())) { | 71 | while( (temp=(AttachItem*)item->nextSibling())) { |
72 | item = temp; | 72 | item = temp; |
73 | } | 73 | } |
74 | return item; | 74 | return item; |
75 | } | 75 | } |
76 | 76 | ||
77 | void ViewMail::setBody( RecBody body ) { | 77 | void ViewMail::setBody( RecBody body ) { |
78 | 78 | ||
79 | m_body = body; | 79 | m_body = body; |
80 | m_mail[2] = body.Bodytext(); | 80 | m_mail[2] = body.Bodytext(); |
81 | attachbutton->setEnabled(body.Parts().count()>0); | 81 | attachbutton->setEnabled(body.Parts().count()>0); |
82 | attachments->setEnabled(body.Parts().count()>0); | 82 | attachments->setEnabled(body.Parts().count()>0); |
83 | if (body.Parts().count()==0) { | 83 | if (body.Parts().count()==0) { |
84 | return; | 84 | return; |
85 | } | 85 | } |
86 | AttachItem * curItem=0; | 86 | AttachItem * curItem=0; |
87 | AttachItem * parentItem = 0; | 87 | AttachItem * parentItem = 0; |
88 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); | 88 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); |
89 | QString desc,fsize; | 89 | QString desc,fsize; |
90 | double s = body.Description().Size(); | 90 | double s = body.Description().Size(); |
91 | int w; | 91 | int w; |
92 | w=0; | 92 | w=0; |
93 | 93 | ||
94 | while (s>1024) { | 94 | while (s>1024) { |
95 | s/=1024; | 95 | s/=1024; |
96 | ++w; | 96 | ++w; |
97 | if (w>=2) break; | 97 | if (w>=2) break; |
98 | } | 98 | } |
99 | 99 | ||
100 | QString q=""; | 100 | QString q=""; |
101 | switch(w) { | 101 | switch(w) { |
102 | case 1: | 102 | case 1: |
103 | q="k"; | 103 | q="k"; |
104 | break; | 104 | break; |
105 | case 2: | 105 | case 2: |
106 | q="M"; | 106 | q="M"; |
107 | break; | 107 | break; |
108 | default: | 108 | default: |
109 | break; | 109 | break; |
110 | } | 110 | } |
111 | 111 | ||
112 | { | 112 | { |
113 | /* I did not found a method to make a CONTENT reset on a QTextStream | 113 | /* I did not found a method to make a CONTENT reset on a QTextStream |
114 | so I use this construct that the stream will re-constructed in each | 114 | so I use this construct that the stream will re-constructed in each |
115 | loop. To let it work, the textstream is packed into a own area of | 115 | loop. To let it work, the textstream is packed into a own area of |
116 | code is it will be destructed after finishing its small job. | 116 | code is it will be destructed after finishing its small job. |
117 | */ | 117 | */ |
118 | QTextOStream o(&fsize); | 118 | QTextOStream o(&fsize); |
119 | if (w>0) o.precision(2); else o.precision(0); | 119 | if (w>0) o.precision(2); else o.precision(0); |
120 | o.setf(QTextStream::fixed); | 120 | o.setf(QTextStream::fixed); |
121 | o << s << " " << q << "Byte"; | 121 | o << s << " " << q << "Byte"; |
122 | } | 122 | } |
123 | 123 | ||
124 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist()); | 124 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist()); |
125 | QString filename = ""; | 125 | QString filename = ""; |
126 | 126 | ||
127 | for (unsigned int i = 0; i < body.Parts().count();++i) { | 127 | for (unsigned int i = 0; i < body.Parts().count();++i) { |
128 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); | 128 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); |
129 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); | 129 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); |
130 | for (;it!=body.Parts()[i].Parameters().end();++it) { | 130 | for (;it!=body.Parts()[i].Parameters().end();++it) { |
131 | qDebug(it.key()); | 131 | qDebug(it.key()); |
132 | if (it.key().lower()=="name") { | 132 | if (it.key().lower()=="name") { |
133 | filename=it.data(); | 133 | filename=it.data(); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | s = body.Parts()[i].Size(); | 136 | s = body.Parts()[i].Size(); |
137 | w = 0; | 137 | w = 0; |
138 | while (s>1024) { | 138 | while (s>1024) { |
139 | s/=1024; | 139 | s/=1024; |
140 | ++w; | 140 | ++w; |
141 | if (w>=2) break; | 141 | if (w>=2) break; |
142 | } | 142 | } |
143 | switch(w) { | 143 | switch(w) { |
144 | case 1: | 144 | case 1: |
145 | q="k"; | 145 | q="k"; |
146 | break; | 146 | break; |
147 | case 2: | 147 | case 2: |
148 | q="M"; | 148 | q="M"; |
149 | break; | 149 | break; |
150 | default: | 150 | default: |
151 | q=""; | 151 | q=""; |
152 | break; | 152 | break; |
153 | } | 153 | } |
154 | QTextOStream o(&fsize); | 154 | QTextOStream o(&fsize); |
155 | if (w>0) o.precision(2); else o.precision(0); | 155 | if (w>0) o.precision(2); else o.precision(0); |
156 | o.setf(QTextStream::fixed); | 156 | o.setf(QTextStream::fixed); |
157 | o << s << " " << q << "Byte"; | 157 | o << s << " " << q << "Byte"; |
158 | desc = body.Parts()[i].Description(); | 158 | desc = body.Parts()[i].Description(); |
159 | parentItem = searchParent(body.Parts()[i].Positionlist()); | 159 | parentItem = searchParent(body.Parts()[i].Positionlist()); |
160 | if (parentItem) { | 160 | if (parentItem) { |
161 | AttachItem*temp = lastChild(parentItem); | 161 | AttachItem*temp = lastChild(parentItem); |
162 | if (temp) curItem = temp; | 162 | if (temp) curItem = temp; |
163 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); | 163 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); |
164 | attachments->setRootIsDecorated(true); | 164 | attachments->setRootIsDecorated(true); |
165 | curItem = parentItem; | 165 | curItem = parentItem; |
166 | } else { | 166 | } else { |
167 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); | 167 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | void ViewMail::slotShowHtml( bool state ) { | 173 | void ViewMail::slotShowHtml( bool state ) { |
174 | m_showHtml = state; | 174 | m_showHtml = state; |
175 | setText(); | 175 | setText(); |
176 | } | 176 | } |
177 | 177 | ||
178 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) { | 178 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) { |
179 | if (!item ) | 179 | if (!item ) |
180 | return; | 180 | return; |
181 | 181 | ||
182 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { | 182 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { |
183 | setText(); | 183 | setText(); |
184 | return; | 184 | return; |
185 | } | 185 | } |
186 | QPopupMenu *menu = new QPopupMenu(); | 186 | QPopupMenu *menu = new QPopupMenu(); |
187 | int ret=0; | 187 | int ret=0; |
188 | 188 | ||
189 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) { | 189 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) { |
190 | menu->insertItem( tr( "Show Text" ), 1 ); | 190 | menu->insertItem( tr( "Show Text" ), 1 ); |
191 | } | 191 | } |
192 | menu->insertItem( tr( "Save Attachment" ), 0 ); | 192 | menu->insertItem( tr( "Save Attachment" ), 0 ); |
193 | menu->insertSeparator(1); | 193 | menu->insertSeparator(1); |
194 | 194 | ||
195 | ret = menu->exec( point, 0 ); | 195 | ret = menu->exec( point, 0 ); |
196 | 196 | ||
197 | switch(ret) { | 197 | switch(ret) { |
198 | case 0: | 198 | case 0: |
199 | { MimeTypes types; | 199 | { MimeTypes types; |
200 | types.insert( "all", "*" ); | 200 | types.insert( "all", "*" ); |
201 | QString str = OFileDialog::getSaveFileName( 1, | 201 | QString str = Opie::OFileDialog::getSaveFileName( 1, |
202 | "/", item->text( 2 ) , types, 0 ); | 202 | "/", item->text( 2 ) , types, 0 ); |
203 | 203 | ||
204 | if( !str.isEmpty() ) { | 204 | if( !str.isEmpty() ) { |
205 | encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 205 | encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
206 | if (content) { | 206 | if (content) { |
207 | QFile output(str); | 207 | QFile output(str); |
208 | output.open(IO_WriteOnly); | 208 | output.open(IO_WriteOnly); |
209 | output.writeBlock(content->Content(),content->Length()); | 209 | output.writeBlock(content->Content(),content->Length()); |
210 | output.close(); | 210 | output.close(); |
211 | delete content; | 211 | delete content; |
212 | } | 212 | } |
213 | } | 213 | } |
214 | } | 214 | } |
215 | break ; | 215 | break ; |
216 | 216 | ||
217 | case 1: | 217 | case 1: |
218 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { | 218 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { |
219 | setText(); | 219 | setText(); |
220 | } else { | 220 | } else { |
221 | if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions | 221 | if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions |
222 | browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 222 | browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | break; | 225 | break; |
226 | } | 226 | } |
227 | delete menu; | 227 | delete menu; |
228 | } | 228 | } |
229 | 229 | ||
230 | 230 | ||
231 | void ViewMail::setMail( RecMail mail ) { | 231 | void ViewMail::setMail( RecMail mail ) { |
232 | 232 | ||
233 | m_recMail = mail; | 233 | m_recMail = mail; |
234 | 234 | ||
235 | m_mail[0] = mail.getFrom(); | 235 | m_mail[0] = mail.getFrom(); |
236 | m_mail[1] = mail.getSubject(); | 236 | m_mail[1] = mail.getSubject(); |
237 | m_mail[3] = mail.getDate(); | 237 | m_mail[3] = mail.getDate(); |
238 | m_mail[4] = mail.Msgid(); | 238 | m_mail[4] = mail.Msgid(); |
239 | 239 | ||
240 | m_mail2[0] = mail.To(); | 240 | m_mail2[0] = mail.To(); |
241 | m_mail2[1] = mail.CC(); | 241 | m_mail2[1] = mail.CC(); |
242 | m_mail2[2] = mail.Bcc(); | 242 | m_mail2[2] = mail.Bcc(); |
243 | 243 | ||
244 | setText(); | 244 | setText(); |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | 248 | ||
249 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 249 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
250 | : ViewMailBase(parent, name, fl), _inLoop(false) | 250 | : ViewMailBase(parent, name, fl), _inLoop(false) |
251 | { | 251 | { |
252 | m_gotBody = false; | 252 | m_gotBody = false; |
253 | deleted = false; | 253 | deleted = false; |
254 | 254 | ||
255 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); | 255 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
256 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); | 256 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); |
257 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); | 257 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); |
258 | connect( showHtml, SIGNAL( toggled( bool ) ), SLOT( slotShowHtml( bool ) ) ); | 258 | connect( showHtml, SIGNAL( toggled( bool ) ), SLOT( slotShowHtml( bool ) ) ); |
259 | 259 | ||
260 | attachments->setEnabled(m_gotBody); | 260 | attachments->setEnabled(m_gotBody); |
261 | connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); | 261 | connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); |
262 | 262 | ||
263 | readConfig(); | 263 | readConfig(); |
264 | attachments->setSorting(-1); | 264 | attachments->setSorting(-1); |
265 | } | 265 | } |
266 | 266 | ||
267 | void ViewMail::readConfig() { | 267 | void ViewMail::readConfig() { |
268 | Config cfg( "mail" ); | 268 | Config cfg( "mail" ); |
269 | cfg.setGroup( "Settings" ); | 269 | cfg.setGroup( "Settings" ); |
270 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); | 270 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); |
271 | showHtml->setOn( m_showHtml ); | 271 | showHtml->setOn( m_showHtml ); |
272 | } | 272 | } |
273 | 273 | ||
274 | void ViewMail::setText() | 274 | void ViewMail::setText() |
275 | { | 275 | { |
276 | 276 | ||
277 | QString toString; | 277 | QString toString; |
278 | QString ccString; | 278 | QString ccString; |
279 | QString bccString; | 279 | QString bccString; |
280 | 280 | ||
281 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { | 281 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { |
282 | toString += (*it); | 282 | toString += (*it); |
283 | } | 283 | } |
284 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { | 284 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { |
285 | ccString += (*it); | 285 | ccString += (*it); |
286 | } | 286 | } |
287 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { | 287 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { |
288 | bccString += (*it); | 288 | bccString += (*it); |
289 | } | 289 | } |
290 | 290 | ||
291 | setCaption( caption().arg( m_mail[0] ) ); | 291 | setCaption( caption().arg( m_mail[0] ) ); |
292 | 292 | ||
293 | m_mailHtml = "<html><body>" | 293 | m_mailHtml = "<html><body>" |
294 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 294 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
295 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 295 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
296 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 296 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
297 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 297 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
298 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 298 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
299 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 299 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
300 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + | 300 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + |
301 | "</td></tr></table><font face=fixed>"; | 301 | "</td></tr></table><font face=fixed>"; |
302 | 302 | ||
303 | if ( !m_showHtml ) { | 303 | if ( !m_showHtml ) { |
304 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 304 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
305 | } else { | 305 | } else { |
306 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); | 306 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); |
307 | } | 307 | } |
308 | // remove later in favor of a real handling | 308 | // remove later in favor of a real handling |
309 | m_gotBody = true; | 309 | m_gotBody = true; |
310 | } | 310 | } |
311 | 311 | ||
312 | 312 | ||
313 | ViewMail::~ViewMail() | 313 | ViewMail::~ViewMail() |
314 | { | 314 | { |
315 | m_recMail.Wrapper()->cleanMimeCache(); | 315 | m_recMail.Wrapper()->cleanMimeCache(); |
316 | hide(); | 316 | hide(); |
317 | } | 317 | } |
318 | 318 | ||
319 | void ViewMail::hide() | 319 | void ViewMail::hide() |
320 | { | 320 | { |
321 | QWidget::hide(); | 321 | QWidget::hide(); |
322 | 322 | ||
323 | if (_inLoop) { | 323 | if (_inLoop) { |
324 | _inLoop = false; | 324 | _inLoop = false; |
325 | qApp->exit_loop(); | 325 | qApp->exit_loop(); |
326 | 326 | ||
327 | } | 327 | } |
328 | 328 | ||
329 | } | 329 | } |
330 | 330 | ||
331 | void ViewMail::exec() | 331 | void ViewMail::exec() |
332 | { | 332 | { |
333 | show(); | 333 | show(); |
334 | 334 | ||
335 | if (!_inLoop) { | 335 | if (!_inLoop) { |
336 | _inLoop = true; | 336 | _inLoop = true; |
337 | qApp->enter_loop(); | 337 | qApp->enter_loop(); |
338 | } | 338 | } |
339 | 339 | ||
340 | } | 340 | } |
341 | 341 | ||
342 | QString ViewMail::deHtml(const QString &string) | 342 | QString ViewMail::deHtml(const QString &string) |
343 | { | 343 | { |
344 | QString string_ = string; | 344 | QString string_ = string; |
345 | string_.replace(QRegExp("&"), "&"); | 345 | string_.replace(QRegExp("&"), "&"); |
346 | string_.replace(QRegExp("<"), "<"); | 346 | string_.replace(QRegExp("<"), "<"); |
347 | string_.replace(QRegExp(">"), ">"); | 347 | string_.replace(QRegExp(">"), ">"); |
348 | string_.replace(QRegExp("\\n"), "<br>"); | 348 | string_.replace(QRegExp("\\n"), "<br>"); |
349 | return string_; | 349 | return string_; |
350 | } | 350 | } |
351 | 351 | ||
352 | void ViewMail::slotReply() | 352 | void ViewMail::slotReply() |
353 | { | 353 | { |
354 | if (!m_gotBody) { | 354 | if (!m_gotBody) { |
355 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 355 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); |
356 | return; | 356 | return; |
357 | } | 357 | } |
358 | 358 | ||
359 | QString rtext; | 359 | QString rtext; |
360 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 360 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
361 | .arg( m_mail[0] ) | 361 | .arg( m_mail[0] ) |
362 | .arg( m_mail[3] ); | 362 | .arg( m_mail[3] ); |
363 | 363 | ||
364 | QString text = m_mail[2]; | 364 | QString text = m_mail[2]; |
365 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 365 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
366 | QStringList::Iterator it; | 366 | QStringList::Iterator it; |
367 | for (it = lines.begin(); it != lines.end(); it++) { | 367 | for (it = lines.begin(); it != lines.end(); it++) { |
368 | rtext += "> " + *it + "\n"; | 368 | rtext += "> " + *it + "\n"; |
369 | } | 369 | } |
370 | rtext += "\n"; | 370 | rtext += "\n"; |
371 | 371 | ||
372 | QString prefix; | 372 | QString prefix; |
373 | if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; | 373 | if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; |
374 | else prefix = "Re: "; // no i18n on purpose | 374 | else prefix = "Re: "; // no i18n on purpose |
375 | 375 | ||
376 | Settings *settings = new Settings(); | 376 | Settings *settings = new Settings(); |
377 | ComposeMail composer( settings ,this, 0, true); | 377 | ComposeMail composer( settings ,this, 0, true); |
378 | composer.setTo( m_mail[0] ); | 378 | composer.setTo( m_mail[0] ); |
379 | composer.setSubject( "Re: " + m_mail[1] ); | 379 | composer.setSubject( "Re: " + m_mail[1] ); |
380 | composer.setMessage( rtext ); | 380 | composer.setMessage( rtext ); |
381 | composer.showMaximized(); | 381 | composer.showMaximized(); |
382 | if ( QDialog::Accepted==composer.exec()) { | 382 | if ( QDialog::Accepted==composer.exec()) { |
383 | m_recMail.Wrapper()->answeredMail(m_recMail); | 383 | m_recMail.Wrapper()->answeredMail(m_recMail); |
384 | } | 384 | } |
385 | } | 385 | } |
386 | 386 | ||
387 | void ViewMail::slotForward() | 387 | void ViewMail::slotForward() |
388 | { | 388 | { |
389 | if (!m_gotBody) { | 389 | if (!m_gotBody) { |
390 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); | 390 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); |
391 | return; | 391 | return; |
392 | } | 392 | } |
393 | 393 | ||
394 | QString ftext; | 394 | QString ftext; |
395 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 395 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
396 | .arg( m_mail[0] ); | 396 | .arg( m_mail[0] ); |
397 | if (!m_mail[3].isNull()) | 397 | if (!m_mail[3].isNull()) |
398 | ftext += QString("Date: %1\n") | 398 | ftext += QString("Date: %1\n") |
399 | .arg( m_mail[3] ); | 399 | .arg( m_mail[3] ); |
400 | if (!m_mail[0].isNull()) | 400 | if (!m_mail[0].isNull()) |
401 | ftext += QString("From: %1\n") | 401 | ftext += QString("From: %1\n") |
402 | .arg( m_mail[0] ); | 402 | .arg( m_mail[0] ); |
403 | if (!m_mail[1].isNull()) | 403 | if (!m_mail[1].isNull()) |
404 | ftext += QString("Subject: %1\n") | 404 | ftext += QString("Subject: %1\n") |
405 | .arg( m_mail[1] ); | 405 | .arg( m_mail[1] ); |
406 | 406 | ||
407 | ftext += QString("\n%1\n") | 407 | ftext += QString("\n%1\n") |
408 | .arg( m_mail[2]); | 408 | .arg( m_mail[2]); |
409 | 409 | ||
410 | ftext += QString("----- End forwarded message -----\n"); | 410 | ftext += QString("----- End forwarded message -----\n"); |
411 | 411 | ||
412 | Settings *settings = new Settings(); | 412 | Settings *settings = new Settings(); |
413 | ComposeMail composer( settings ,this, 0, true); | 413 | ComposeMail composer( settings ,this, 0, true); |
414 | composer.setSubject( "Fwd: " + m_mail[1] ); | 414 | composer.setSubject( "Fwd: " + m_mail[1] ); |
415 | composer.setMessage( ftext ); | 415 | composer.setMessage( ftext ); |
416 | composer.showMaximized(); | 416 | composer.showMaximized(); |
417 | if ( QDialog::Accepted==composer.exec()) { | 417 | if ( QDialog::Accepted==composer.exec()) { |
418 | 418 | ||
419 | } | 419 | } |
420 | } | 420 | } |
421 | 421 | ||
422 | void ViewMail::slotDeleteMail( ) | 422 | void ViewMail::slotDeleteMail( ) |
423 | { | 423 | { |
424 | 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 ) { | 424 | 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 ) { |
425 | m_recMail.Wrapper()->deleteMail( m_recMail ); | 425 | m_recMail.Wrapper()->deleteMail( m_recMail ); |
426 | hide(); | 426 | hide(); |
427 | deleted = true; | 427 | deleted = true; |
428 | } | 428 | } |
429 | } | 429 | } |