author | alwin <alwin> | 2003-12-28 17:32:43 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-28 17:32:43 (UTC) |
commit | 696a2dcfcb65fbb24b709bbae0a18a7854e2d72c (patch) (unidiff) | |
tree | e813c9508881796cf999e9c25c05e4482c6fd9e8 /noncore/net/mail/composemail.cpp | |
parent | b900cad9c050c2d5963228a2191e13053457ef1d (diff) | |
download | opie-696a2dcfcb65fbb24b709bbae0a18a7854e2d72c.zip opie-696a2dcfcb65fbb24b709bbae0a18a7854e2d72c.tar.gz opie-696a2dcfcb65fbb24b709bbae0a18a7854e2d72c.tar.bz2 |
reduced to the max...
- from address isn't setup any longer within the smtp account (it makes realy no
sense, a smtp account describes the connection to a smtp server, not the
identity of the sender)
- from address is taken from the personal info of the addressbook (thats why this
info exists). Of course the user can change it when sending an email.
- user can select a from with a selection of the mails given in their personal
infos.
- in addresspicker: use "<Firstname> <Lastname>" instead of "Filename"
- settings ui: switched of the part within the smtp accounts describing the
identitiy of user
ToDo: a dialog setting up a default signature
Diffstat (limited to 'noncore/net/mail/composemail.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/composemail.cpp | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp index 73d1a43..13c7900 100644 --- a/noncore/net/mail/composemail.cpp +++ b/noncore/net/mail/composemail.cpp | |||
@@ -1,47 +1,70 @@ | |||
1 | #include <qt.h> | 1 | #include <qt.h> |
2 | 2 | ||
3 | #include <opie/ofiledialog.h> | 3 | #include <opie/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> | ||
7 | #include <qpe/contact.h> | ||
6 | 8 | ||
7 | #include "composemail.h" | 9 | #include "composemail.h" |
8 | #include "smtpwrapper.h" | 10 | #include "smtpwrapper.h" |
9 | 11 | ||
10 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) | 12 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) |
11 | : ComposeMailUI( parent, name, modal, flags ) | 13 | : ComposeMailUI( parent, name, modal, flags ) |
12 | { | 14 | { |
13 | settings = s; | 15 | settings = s; |
14 | 16 | ||
17 | QString vfilename = Global::applicationFileName("addressbook", | ||
18 | "businesscard.vcf"); | ||
19 | Contact c; | ||
20 | if (QFile::exists(vfilename)) { | ||
21 | c = Contact::readVCard( vfilename )[0]; | ||
22 | } | ||
23 | |||
24 | QStringList mails = c.emailList(); | ||
25 | QString defmail = c.defaultEmail(); | ||
26 | |||
27 | if (defmail.length()!=0) { | ||
28 | fromBox->insertItem(defmail); | ||
29 | } | ||
30 | QStringList::ConstIterator sit = mails.begin(); | ||
31 | for (;sit!=mails.end();++sit) { | ||
32 | if ( (*sit)==defmail) | ||
33 | continue; | ||
34 | fromBox->insertItem((*sit)); | ||
35 | } | ||
36 | senderNameEdit->setText(c.firstName()+" "+c.lastName()); | ||
15 | Config cfg( "mail" ); | 37 | Config cfg( "mail" ); |
16 | cfg.setGroup( "Compose" ); | 38 | cfg.setGroup( "Compose" ); |
17 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); | 39 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); |
18 | 40 | ||
19 | attList->addColumn( tr( "Name" ) ); | 41 | attList->addColumn( tr( "Name" ) ); |
20 | attList->addColumn( tr( "Size" ) ); | 42 | attList->addColumn( tr( "Size" ) ); |
21 | 43 | ||
22 | QList<Account> accounts = settings->getAccounts(); | 44 | QList<Account> accounts = settings->getAccounts(); |
45 | |||
23 | Account *it; | 46 | Account *it; |
24 | for ( it = accounts.first(); it; it = accounts.next() ) { | 47 | for ( it = accounts.first(); it; it = accounts.next() ) { |
25 | if ( it->getType().compare( "SMTP" ) == 0 ) { | 48 | if ( it->getType().compare( "SMTP" ) == 0 ) { |
26 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); | 49 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); |
27 | fromBox->insertItem( smtp->getMail() ); | 50 | smtpAccountBox->insertItem( smtp->getAccountName() ); |
28 | smtpAccounts.append( smtp ); | 51 | smtpAccounts.append( smtp ); |
29 | } | 52 | } |
30 | } | 53 | } |
31 | 54 | ||
32 | if ( smtpAccounts.count() > 0 ) { | 55 | if ( smtpAccounts.count() > 0 ) { |
33 | fillValues( fromBox->currentItem() ); | 56 | fillValues( smtpAccountBox->currentItem() ); |
34 | } else { | 57 | } else { |
35 | QMessageBox::information( this, tr( "Problem" ), | 58 | QMessageBox::information( this, tr( "Problem" ), |
36 | tr( "<p>Please create an SMTP account first.</p>" ), | 59 | tr( "<p>Please create an SMTP account first.</p>" ), |
37 | tr( "Ok" ) ); | 60 | tr( "Ok" ) ); |
38 | return; | 61 | return; |
39 | } | 62 | } |
40 | 63 | ||
41 | connect( fromBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) ); | 64 | connect( smtpAccountBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) ); |
42 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); | 65 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); |
43 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); | 66 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); |
44 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); | 67 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); |
45 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); | 68 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); |
46 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); | 69 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); |
47 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); | 70 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); |
@@ -105,28 +128,28 @@ void ComposeMail::pickAddressReply() | |||
105 | { | 128 | { |
106 | pickAddress( replyLine ); | 129 | pickAddress( replyLine ); |
107 | } | 130 | } |
108 | 131 | ||
109 | void ComposeMail::fillValues( int current ) | 132 | void ComposeMail::fillValues( int current ) |
110 | { | 133 | { |
134 | #if 0 | ||
111 | SMTPaccount *smtp = smtpAccounts.at( current ); | 135 | SMTPaccount *smtp = smtpAccounts.at( current ); |
112 | |||
113 | ccLine->clear(); | 136 | ccLine->clear(); |
114 | if ( smtp->getUseCC() ) { | 137 | if ( smtp->getUseCC() ) { |
115 | ccLine->setText( smtp->getCC() ); | 138 | ccLine->setText( smtp->getCC() ); |
116 | } | 139 | } |
117 | bccLine->clear(); | 140 | bccLine->clear(); |
118 | if ( smtp->getUseBCC() ) { | 141 | if ( smtp->getUseBCC() ) { |
119 | bccLine->setText( smtp->getBCC() ); | 142 | bccLine->setText( smtp->getBCC() ); |
120 | } | 143 | } |
121 | replyLine->clear(); | 144 | replyLine->clear(); |
122 | if ( smtp->getUseReply() ) { | 145 | if ( smtp->getUseReply() ) { |
123 | replyLine->setText( smtp->getReply() ); | 146 | replyLine->setText( smtp->getReply() ); |
124 | } | 147 | } |
125 | |||
126 | sigMultiLine->setText( smtp->getSignature() ); | 148 | sigMultiLine->setText( smtp->getSignature() ); |
149 | #endif | ||
127 | } | 150 | } |
128 | 151 | ||
129 | void ComposeMail::slotAdjustColumns() | 152 | void ComposeMail::slotAdjustColumns() |
130 | { | 153 | { |
131 | int currPage = tabWidget->currentPageIndex(); | 154 | int currPage = tabWidget->currentPageIndex(); |
132 | 155 | ||
@@ -160,46 +183,47 @@ void ComposeMail::removeAttachment() | |||
160 | void ComposeMail::accept() | 183 | void ComposeMail::accept() |
161 | { | 184 | { |
162 | if ( checkBoxLater->isChecked() ) { | 185 | if ( checkBoxLater->isChecked() ) { |
163 | qDebug( "Send later" ); | 186 | qDebug( "Send later" ); |
164 | } | 187 | } |
165 | 188 | ||
166 | 189 | #if 0 | |
167 | qDebug( "Sending Mail with " + | 190 | qDebug( "Sending Mail with " + |
168 | smtpAccounts.at( fromBox->currentItem() )->getAccountName() ); | 191 | smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); |
192 | #endif | ||
169 | Mail *mail = new Mail(); | 193 | Mail *mail = new Mail(); |
170 | SMTPaccount *smtp = smtpAccounts.at( fromBox->currentItem() ); | ||
171 | 194 | ||
172 | mail->setMail( smtp->getMail() ); | 195 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); |
173 | mail->setName( smtp->getName() ); | 196 | mail->setMail(fromBox->currentText()); |
174 | 197 | ||
175 | if ( !toLine->text().isEmpty() ) { | 198 | if ( !toLine->text().isEmpty() ) { |
176 | mail->setTo( toLine->text() ); | 199 | mail->setTo( toLine->text() ); |
177 | } else { | 200 | } else { |
178 | qDebug( "No Reciever spezified -> returning" ); | 201 | qDebug( "No Reciever spezified -> returning" ); |
179 | return; | 202 | return; |
180 | } | 203 | } |
181 | 204 | mail->setName(senderNameEdit->text()); | |
182 | mail->setCC( ccLine->text() ); | 205 | mail->setCC( ccLine->text() ); |
183 | mail->setBCC( bccLine->text() ); | 206 | mail->setBCC( bccLine->text() ); |
184 | mail->setReply( replyLine->text() ); | 207 | mail->setReply( replyLine->text() ); |
185 | mail->setSubject( subjectLine->text() ); | 208 | mail->setSubject( subjectLine->text() ); |
186 | QString txt = message->text(); | 209 | QString txt = message->text(); |
187 | if ( !sigMultiLine->text().isEmpty() ) { | 210 | if ( !sigMultiLine->text().isEmpty() ) { |
188 | txt.append( "\n--\n" ); | 211 | txt.append( "\n--\n" ); |
189 | txt.append( sigMultiLine->text() ); | 212 | txt.append( sigMultiLine->text() ); |
190 | } | 213 | } |
214 | qDebug(txt); | ||
191 | mail->setMessage( txt ); | 215 | mail->setMessage( txt ); |
192 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 216 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
193 | while ( it != NULL ) { | 217 | while ( it != NULL ) { |
194 | mail->addAttachment( it->getAttachment() ); | 218 | mail->addAttachment( it->getAttachment() ); |
195 | it = (AttachViewItem *) it->nextSibling(); | 219 | it = (AttachViewItem *) it->nextSibling(); |
196 | } | 220 | } |
197 | 221 | ||
198 | SMTPwrapper wrapper( settings ); | 222 | SMTPwrapper wrapper( settings ); |
199 | wrapper.sendMail( *mail,checkBoxLater->isChecked() ); | 223 | wrapper.sendMail( *mail,smtp,checkBoxLater->isChecked() ); |
200 | 224 | ||
201 | QDialog::accept(); | 225 | QDialog::accept(); |
202 | } | 226 | } |
203 | 227 | ||
204 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) | 228 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) |
205 | : QListViewItem( parent ) | 229 | : QListViewItem( parent ) |