summaryrefslogtreecommitdiff
path: root/noncore/net/mail/composemail.cpp
Unidiff
Diffstat (limited to 'noncore/net/mail/composemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/composemail.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp
index 6708779..f51a8fe 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 <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
13ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 13ComposeMail::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
74void ComposeMail::pickAddress( QLineEdit *line ) 74void 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
85void ComposeMail::setTo( const QString & to ) 85void 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*/
94toLine->setText( to ); 94toLine->setText( to );
95} 95}
96 96
97void ComposeMail::setSubject( const QString & subject ) 97void ComposeMail::setSubject( const QString & subject )
98{ 98{
99 subjectLine->setText( subject ); 99 subjectLine->setText( subject );
100} 100}
101 101
102void ComposeMail::setInReplyTo( const QString & messageId ) 102void ComposeMail::setInReplyTo( const QString & messageId )
103{ 103{
104 104
105} 105}
106 106
107void ComposeMail::setMessage( const QString & text ) 107void ComposeMail::setMessage( const QString & text )
108{ 108{
109 message->setText( text ); 109 message->setText( text );
110} 110}
111 111
112 112
113void ComposeMail::pickAddressTo() 113void ComposeMail::pickAddressTo()
114{ 114{
115 pickAddress( toLine ); 115 pickAddress( toLine );
116} 116}
117 117
118void ComposeMail::pickAddressCC() 118void ComposeMail::pickAddressCC()
119{ 119{
120 pickAddress( ccLine ); 120 pickAddress( ccLine );
121} 121}
122 122
123void ComposeMail::pickAddressBCC() 123void ComposeMail::pickAddressBCC()
124{ 124{
125 pickAddress( bccLine ); 125 pickAddress( bccLine );
126} 126}
127 127
128void ComposeMail::pickAddressReply() 128void ComposeMail::pickAddressReply()
129{ 129{
130 pickAddress( replyLine ); 130 pickAddress( replyLine );
131} 131}
132 132
133void ComposeMail::fillValues( int current ) 133void 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
153void ComposeMail::slotAdjustColumns() 153void 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
164void ComposeMail::addAttachment() 164void ComposeMail::addAttachment()
165{ 165{
166 DocLnk lnk = Opie::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
173void ComposeMail::removeAttachment() 173void 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
184void ComposeMail::accept() 184void 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
229AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) 229AttachViewItem::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