author | alwin <alwin> | 2003-12-23 01:37:58 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-23 01:37:58 (UTC) |
commit | 04a7006c0392c02941e263d4d35edeeb2f98223d (patch) (unidiff) | |
tree | b146f699fec46c2a2208fd91097952b6303ba2f8 | |
parent | be95b109fdd37e86b179bf63b15a647acc58a445 (diff) | |
download | opie-04a7006c0392c02941e263d4d35edeeb2f98223d.zip opie-04a7006c0392c02941e263d4d35edeeb2f98223d.tar.gz opie-04a7006c0392c02941e263d4d35edeeb2f98223d.tar.bz2 |
fix a problem while appending attachments to a new mail
-rw-r--r-- | noncore/net/mail/composemail.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp index f532815..73d1a43 100644 --- a/noncore/net/mail/composemail.cpp +++ b/noncore/net/mail/composemail.cpp | |||
@@ -1,215 +1,215 @@ | |||
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 | 6 | ||
7 | #include "composemail.h" | 7 | #include "composemail.h" |
8 | #include "smtpwrapper.h" | 8 | #include "smtpwrapper.h" |
9 | 9 | ||
10 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) | 10 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) |
11 | : ComposeMailUI( parent, name, modal, flags ) | 11 | : ComposeMailUI( parent, name, modal, flags ) |
12 | { | 12 | { |
13 | settings = s; | 13 | settings = s; |
14 | 14 | ||
15 | Config cfg( "mail" ); | 15 | Config cfg( "mail" ); |
16 | cfg.setGroup( "Compose" ); | 16 | cfg.setGroup( "Compose" ); |
17 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); | 17 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); |
18 | 18 | ||
19 | attList->addColumn( tr( "Name" ) ); | 19 | attList->addColumn( tr( "Name" ) ); |
20 | attList->addColumn( tr( "Size" ) ); | 20 | attList->addColumn( tr( "Size" ) ); |
21 | 21 | ||
22 | QList<Account> accounts = settings->getAccounts(); | 22 | QList<Account> accounts = settings->getAccounts(); |
23 | Account *it; | 23 | Account *it; |
24 | for ( it = accounts.first(); it; it = accounts.next() ) { | 24 | for ( it = accounts.first(); it; it = accounts.next() ) { |
25 | if ( it->getType().compare( "SMTP" ) == 0 ) { | 25 | if ( it->getType().compare( "SMTP" ) == 0 ) { |
26 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); | 26 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); |
27 | fromBox->insertItem( smtp->getMail() ); | 27 | fromBox->insertItem( smtp->getMail() ); |
28 | smtpAccounts.append( smtp ); | 28 | smtpAccounts.append( smtp ); |
29 | } | 29 | } |
30 | } | 30 | } |
31 | 31 | ||
32 | if ( smtpAccounts.count() > 0 ) { | 32 | if ( smtpAccounts.count() > 0 ) { |
33 | fillValues( fromBox->currentItem() ); | 33 | fillValues( fromBox->currentItem() ); |
34 | } else { | 34 | } else { |
35 | QMessageBox::information( this, tr( "Problem" ), | 35 | QMessageBox::information( this, tr( "Problem" ), |
36 | tr( "<p>Please create an SMTP account first.</p>" ), | 36 | tr( "<p>Please create an SMTP account first.</p>" ), |
37 | tr( "Ok" ) ); | 37 | tr( "Ok" ) ); |
38 | return; | 38 | return; |
39 | } | 39 | } |
40 | 40 | ||
41 | connect( fromBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) ); | 41 | connect( fromBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) ); |
42 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); | 42 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); |
43 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); | 43 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); |
44 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); | 44 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); |
45 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); | 45 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); |
46 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); | 46 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); |
47 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); | 47 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); |
48 | } | 48 | } |
49 | 49 | ||
50 | void ComposeMail::pickAddress( QLineEdit *line ) | 50 | void ComposeMail::pickAddress( QLineEdit *line ) |
51 | { | 51 | { |
52 | QString names = AddressPicker::getNames(); | 52 | QString names = AddressPicker::getNames(); |
53 | if ( line->text().isEmpty() ) { | 53 | if ( line->text().isEmpty() ) { |
54 | line->setText( names ); | 54 | line->setText( names ); |
55 | } else if ( !names.isEmpty() ) { | 55 | } else if ( !names.isEmpty() ) { |
56 | line->setText( line->text() + ", " + names ); | 56 | line->setText( line->text() + ", " + names ); |
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | 60 | ||
61 | void ComposeMail::setTo( const QString & to ) | 61 | void ComposeMail::setTo( const QString & to ) |
62 | { | 62 | { |
63 | /* QString toline; | 63 | /* QString toline; |
64 | QStringList toEntry = to; | 64 | QStringList toEntry = to; |
65 | for ( QStringList::Iterator it = toEntry.begin(); it != toEntry.end(); ++it ) { | 65 | for ( QStringList::Iterator it = toEntry.begin(); it != toEntry.end(); ++it ) { |
66 | toline += (*it); | 66 | toline += (*it); |
67 | } | 67 | } |
68 | toLine->setText( toline ); | 68 | toLine->setText( toline ); |
69 | */ | 69 | */ |
70 | toLine->setText( to ); | 70 | toLine->setText( to ); |
71 | } | 71 | } |
72 | 72 | ||
73 | void ComposeMail::setSubject( const QString & subject ) | 73 | void ComposeMail::setSubject( const QString & subject ) |
74 | { | 74 | { |
75 | subjectLine->setText( subject ); | 75 | subjectLine->setText( subject ); |
76 | } | 76 | } |
77 | 77 | ||
78 | void ComposeMail::setInReplyTo( const QString & messageId ) | 78 | void ComposeMail::setInReplyTo( const QString & messageId ) |
79 | { | 79 | { |
80 | 80 | ||
81 | } | 81 | } |
82 | 82 | ||
83 | void ComposeMail::setMessage( const QString & text ) | 83 | void ComposeMail::setMessage( const QString & text ) |
84 | { | 84 | { |
85 | message->setText( text ); | 85 | message->setText( text ); |
86 | } | 86 | } |
87 | 87 | ||
88 | 88 | ||
89 | void ComposeMail::pickAddressTo() | 89 | void ComposeMail::pickAddressTo() |
90 | { | 90 | { |
91 | pickAddress( toLine ); | 91 | pickAddress( toLine ); |
92 | } | 92 | } |
93 | 93 | ||
94 | void ComposeMail::pickAddressCC() | 94 | void ComposeMail::pickAddressCC() |
95 | { | 95 | { |
96 | pickAddress( ccLine ); | 96 | pickAddress( ccLine ); |
97 | } | 97 | } |
98 | 98 | ||
99 | void ComposeMail::pickAddressBCC() | 99 | void ComposeMail::pickAddressBCC() |
100 | { | 100 | { |
101 | pickAddress( bccLine ); | 101 | pickAddress( bccLine ); |
102 | } | 102 | } |
103 | 103 | ||
104 | void ComposeMail::pickAddressReply() | 104 | void ComposeMail::pickAddressReply() |
105 | { | 105 | { |
106 | pickAddress( replyLine ); | 106 | pickAddress( replyLine ); |
107 | } | 107 | } |
108 | 108 | ||
109 | void ComposeMail::fillValues( int current ) | 109 | void ComposeMail::fillValues( int current ) |
110 | { | 110 | { |
111 | SMTPaccount *smtp = smtpAccounts.at( current ); | 111 | SMTPaccount *smtp = smtpAccounts.at( current ); |
112 | 112 | ||
113 | ccLine->clear(); | 113 | ccLine->clear(); |
114 | if ( smtp->getUseCC() ) { | 114 | if ( smtp->getUseCC() ) { |
115 | ccLine->setText( smtp->getCC() ); | 115 | ccLine->setText( smtp->getCC() ); |
116 | } | 116 | } |
117 | bccLine->clear(); | 117 | bccLine->clear(); |
118 | if ( smtp->getUseBCC() ) { | 118 | if ( smtp->getUseBCC() ) { |
119 | bccLine->setText( smtp->getBCC() ); | 119 | bccLine->setText( smtp->getBCC() ); |
120 | } | 120 | } |
121 | replyLine->clear(); | 121 | replyLine->clear(); |
122 | if ( smtp->getUseReply() ) { | 122 | if ( smtp->getUseReply() ) { |
123 | replyLine->setText( smtp->getReply() ); | 123 | replyLine->setText( smtp->getReply() ); |
124 | } | 124 | } |
125 | 125 | ||
126 | sigMultiLine->setText( smtp->getSignature() ); | 126 | sigMultiLine->setText( smtp->getSignature() ); |
127 | } | 127 | } |
128 | 128 | ||
129 | void ComposeMail::slotAdjustColumns() | 129 | void ComposeMail::slotAdjustColumns() |
130 | { | 130 | { |
131 | int currPage = tabWidget->currentPageIndex(); | 131 | int currPage = tabWidget->currentPageIndex(); |
132 | 132 | ||
133 | tabWidget->showPage( attachTab ); | 133 | tabWidget->showPage( attachTab ); |
134 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); | 134 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); |
135 | attList->setColumnWidth( 1, 80 ); | 135 | attList->setColumnWidth( 1, 80 ); |
136 | 136 | ||
137 | tabWidget->setCurrentPage( currPage ); | 137 | tabWidget->setCurrentPage( currPage ); |
138 | } | 138 | } |
139 | 139 | ||
140 | void ComposeMail::addAttachment() | 140 | void ComposeMail::addAttachment() |
141 | { | 141 | { |
142 | DocLnk lnk = OFileDialog::getOpenFileName( 1, "/" ); | 142 | DocLnk lnk = OFileDialog::getOpenFileName( 1, "/" ); |
143 | if ( !lnk.name().isEmpty() ) { | 143 | if ( !lnk.name().isEmpty() ) { |
144 | Attachment *att = new Attachment( lnk ); | 144 | Attachment *att = new Attachment( lnk ); |
145 | (void) new AttachViewItem( attList, att ); | 145 | (void) new AttachViewItem( attList, att ); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | void ComposeMail::removeAttachment() | 149 | void ComposeMail::removeAttachment() |
150 | { | 150 | { |
151 | if ( !attList->currentItem() ) { | 151 | if ( !attList->currentItem() ) { |
152 | QMessageBox::information( this, tr( "Error" ), | 152 | QMessageBox::information( this, tr( "Error" ), |
153 | tr( "<p>Please select a File.</p>" ), | 153 | tr( "<p>Please select a File.</p>" ), |
154 | tr( "Ok" ) ); | 154 | tr( "Ok" ) ); |
155 | } else { | 155 | } else { |
156 | attList->takeItem( attList->currentItem() ); | 156 | attList->takeItem( attList->currentItem() ); |
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | void ComposeMail::accept() | 160 | void ComposeMail::accept() |
161 | { | 161 | { |
162 | if ( checkBoxLater->isChecked() ) { | 162 | if ( checkBoxLater->isChecked() ) { |
163 | qDebug( "Send later" ); | 163 | qDebug( "Send later" ); |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
167 | qDebug( "Sending Mail with " + | 167 | qDebug( "Sending Mail with " + |
168 | smtpAccounts.at( fromBox->currentItem() )->getAccountName() ); | 168 | smtpAccounts.at( fromBox->currentItem() )->getAccountName() ); |
169 | Mail *mail = new Mail(); | 169 | Mail *mail = new Mail(); |
170 | SMTPaccount *smtp = smtpAccounts.at( fromBox->currentItem() ); | 170 | SMTPaccount *smtp = smtpAccounts.at( fromBox->currentItem() ); |
171 | 171 | ||
172 | mail->setMail( smtp->getMail() ); | 172 | mail->setMail( smtp->getMail() ); |
173 | mail->setName( smtp->getName() ); | 173 | mail->setName( smtp->getName() ); |
174 | 174 | ||
175 | if ( !toLine->text().isEmpty() ) { | 175 | if ( !toLine->text().isEmpty() ) { |
176 | mail->setTo( toLine->text() ); | 176 | mail->setTo( toLine->text() ); |
177 | } else { | 177 | } else { |
178 | qDebug( "No Reciever spezified -> returning" ); | 178 | qDebug( "No Reciever spezified -> returning" ); |
179 | return; | 179 | return; |
180 | } | 180 | } |
181 | 181 | ||
182 | mail->setCC( ccLine->text() ); | 182 | mail->setCC( ccLine->text() ); |
183 | mail->setBCC( bccLine->text() ); | 183 | mail->setBCC( bccLine->text() ); |
184 | mail->setReply( replyLine->text() ); | 184 | mail->setReply( replyLine->text() ); |
185 | mail->setSubject( subjectLine->text() ); | 185 | mail->setSubject( subjectLine->text() ); |
186 | QString txt = message->text(); | 186 | QString txt = message->text(); |
187 | if ( !sigMultiLine->text().isEmpty() ) { | 187 | if ( !sigMultiLine->text().isEmpty() ) { |
188 | txt.append( "\n--\n" ); | 188 | txt.append( "\n--\n" ); |
189 | txt.append( sigMultiLine->text() ); | 189 | txt.append( sigMultiLine->text() ); |
190 | } | 190 | } |
191 | mail->setMessage( txt ); | 191 | mail->setMessage( txt ); |
192 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 192 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
193 | while ( it != NULL ) { | 193 | while ( it != NULL ) { |
194 | mail->addAttachment( it->getAttachment() ); | 194 | mail->addAttachment( it->getAttachment() ); |
195 | it = (AttachViewItem *) it->itemBelow(); | 195 | it = (AttachViewItem *) it->nextSibling(); |
196 | } | 196 | } |
197 | 197 | ||
198 | SMTPwrapper wrapper( settings ); | 198 | SMTPwrapper wrapper( settings ); |
199 | wrapper.sendMail( *mail,checkBoxLater->isChecked() ); | 199 | wrapper.sendMail( *mail,checkBoxLater->isChecked() ); |
200 | 200 | ||
201 | QDialog::accept(); | 201 | QDialog::accept(); |
202 | } | 202 | } |
203 | 203 | ||
204 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) | 204 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) |
205 | : QListViewItem( parent ) | 205 | : QListViewItem( parent ) |
206 | { | 206 | { |
207 | attachment = att; | 207 | attachment = att; |
208 | qDebug( att->getMimeType() ); | 208 | qDebug( att->getMimeType() ); |
209 | setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? | 209 | setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? |
210 | Resource::loadPixmap( "UnknownDocument-14" ) : | 210 | Resource::loadPixmap( "UnknownDocument-14" ) : |
211 | attachment->getDocLnk().pixmap() ); | 211 | attachment->getDocLnk().pixmap() ); |
212 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); | 212 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); |
213 | setText( 1, QString::number( att->getSize() ) ); | 213 | setText( 1, QString::number( att->getSize() ) ); |
214 | } | 214 | } |
215 | 215 | ||